@cj-tech-master/excelts 5.1.2 → 5.1.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.
@@ -1,13 +1,13 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v5.1.2
2
+ * @cj-tech-master/excelts v5.1.3
3
3
  * TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.
4
4
  * (c) 2026 cjnoname
5
5
  * Released under the MIT License
6
6
  */
7
- var ExcelTS=(function(e){let t=/^[A-Z]+\d+$/,n={_dictionary:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``),_l2nFill:0,_l2n:{},_n2l:[],_level(e){return e<=26?1:e<=676?2:3},_fill(e){let t,n,r,i,a,o=1;if(e>=4)throw Error(`Out of bounds. Excel supports columns from 1 to 16384`);if(this._l2nFill<1&&e>=1){for(;o<=26;)t=this._dictionary[o-1],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=1}if(this._l2nFill<2&&e>=2){for(o=27;o<=702;)n=o-27,r=n%26,i=Math.floor(n/26),t=this._dictionary[i]+this._dictionary[r],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=2}if(this._l2nFill<3&&e>=3){for(o=703;o<=16384;)n=o-703,r=n%26,i=Math.floor(n/26)%26,a=Math.floor(n/676),t=this._dictionary[a]+this._dictionary[i]+this._dictionary[r],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=3}},l2n(e){if(this._l2n[e]||this._fill(e.length),!this._l2n[e])throw Error(`Out of bounds. Invalid column letter: ${e}`);return this._l2n[e]},n2l(e){if(e<1||e>16384)throw Error(`${e} is out of bounds. Excel supports columns from 1 to 16384`);return this._n2l[e]||this._fill(this._level(e)),this._n2l[e]},_hash:{},validateAddress(e){if(!t.test(e))throw Error(`Invalid Address: ${e}`);return!0},decodeAddress(e){let t=e.length<5&&this._hash[e];if(t)return t;let n=!1,r=``,i=0,a=!1,o=``,s=0;for(let t=0,c;t<e.length;t++)if(c=e.charCodeAt(t),!a&&c>=65&&c<=90)n=!0,r+=e[t],i=i*26+c-64;else if(c>=48&&c<=57)a=!0,o+=e[t],s=s*10+c-48;else if(a&&n&&c!==36)break;if(!n)i=void 0;else if(i>16384)throw Error(`Out of bounds. Invalid column letter: ${r}`);a||(s=void 0),e=r+o;let c={address:e,col:i,row:s,$col$row:`$${r}$${o}`};return i<=100&&s<=100&&(this._hash[e]=c,this._hash[c.$col$row]=c),c},getAddress(e,t){if(t){let n=this.n2l(t)+e;return this.decodeAddress(n)}return this.decodeAddress(e)},decode(e){let t=e.split(`:`);if(t.length===2){let e=this.decodeAddress(t[0]),n=this.decodeAddress(t[1]),r={top:Math.min(e.row,n.row),left:Math.min(e.col,n.col),bottom:Math.max(e.row,n.row),right:Math.max(e.col,n.col),tl:``,br:``,dimensions:``};return r.tl=this.n2l(r.left)+r.top,r.br=this.n2l(r.right)+r.bottom,r.dimensions=`${r.tl}:${r.br}`,r}return this.decodeAddress(e)},decodeEx(e){let t=e.match(/^(?:(?:(?:'((?:[^']|'')+?)')|([^'^ !]+?))!)?(.*)$/),n=t[1]||t[2],r=t[3],i=r.split(`:`);if(i.length>1){let e=this.decodeAddress(i[0]),t=this.decodeAddress(i[1]),r=Math.min(e.row,t.row),a=Math.min(e.col,t.col),o=Math.max(e.row,t.row),s=Math.max(e.col,t.col),c=this.n2l(a)+r,l=this.n2l(s)+o;return{top:r,left:a,bottom:o,right:s,sheetName:n,tl:{address:c,col:a,row:r,$col$row:`$${this.n2l(a)}$${r}`,sheetName:n},br:{address:l,col:s,row:o,$col$row:`$${this.n2l(s)}$${o}`,sheetName:n},dimensions:`${c}:${l}`}}if(r.indexOf(`#`)===0)return n?{sheetName:n,error:r}:{error:r};let a=this.decodeAddress(r);return n?{sheetName:n,...a}:a},encodeAddress(e,t){return n.n2l(t)+e},encode(...e){switch(e.length){case 2:return n.encodeAddress(e[0],e[1]);case 4:return`${n.encodeAddress(e[0],e[1])}:${n.encodeAddress(e[2],e[3])}`;default:throw Error(`Can only encode with 2 or 4 arguments`)}},inRange(e,t){let[n,r,,i,a]=e,[o,s]=t;return o>=n&&o<=i&&s>=r&&s<=a}};var r=class e{constructor(...e){this.model={top:0,left:0,bottom:0,right:0},this.decode(e)}setTLBR(e,t,r,i,a){if(typeof e==`string`&&typeof t==`string`){let i=n.decodeAddress(e),a=n.decodeAddress(t);this.model={top:Math.min(i.row,a.row),left:Math.min(i.col,a.col),bottom:Math.max(i.row,a.row),right:Math.max(i.col,a.col),sheetName:typeof r==`string`?r:void 0}}else typeof e==`number`&&typeof t==`number`&&typeof r==`number`&&typeof i==`number`&&(this.model={top:Math.min(e,r),left:Math.min(t,i),bottom:Math.max(e,r),right:Math.max(t,i),sheetName:a})}decode(t){switch(t.length){case 5:typeof t[0]==`number`&&typeof t[1]==`number`&&typeof t[2]==`number`&&typeof t[3]==`number`&&typeof t[4]==`string`&&this.setTLBR(t[0],t[1],t[2],t[3],t[4]);break;case 4:typeof t[0]==`number`&&typeof t[1]==`number`&&typeof t[2]==`number`&&typeof t[3]==`number`&&this.setTLBR(t[0],t[1],t[2],t[3]);break;case 3:typeof t[0]==`string`&&typeof t[1]==`string`&&typeof t[2]==`string`&&this.setTLBR(t[0],t[1],t[2]);break;case 2:typeof t[0]==`string`&&typeof t[1]==`string`&&this.setTLBR(t[0],t[1]);break;case 1:{let r=t[0];if(r instanceof e)this.model={top:r.model.top,left:r.model.left,bottom:r.model.bottom,right:r.model.right,sheetName:r.sheetName};else if(Array.isArray(r))this.decode(r);else if(typeof r==`object`&&`top`in r&&`left`in r&&`bottom`in r&&`right`in r)this.model={top:r.top,left:r.left,bottom:r.bottom,right:r.right,sheetName:r.sheetName};else if(typeof r==`string`){let e=n.decodeEx(r);`top`in e?this.model={top:e.top,left:e.left,bottom:e.bottom,right:e.right,sheetName:e.sheetName}:`row`in e&&(this.model={top:e.row,left:e.col,bottom:e.row,right:e.col,sheetName:e.sheetName})}break}case 0:this.model={top:0,left:0,bottom:0,right:0};break;default:throw Error(`Invalid number of arguments to _getDimensions() - ${t.length}`)}}get top(){return this.model.top||1}set top(e){this.model.top=e}get left(){return this.model.left||1}set left(e){this.model.left=e}get bottom(){return this.model.bottom||1}set bottom(e){this.model.bottom=e}get right(){return this.model.right||1}set right(e){this.model.right=e}get sheetName(){return this.model.sheetName}set sheetName(e){this.model.sheetName=e}get _serialisedSheetName(){let{sheetName:e}=this.model;return e?/^[a-zA-Z0-9]*$/.test(e)?`${e}!`:`'${e}'!`:``}expand(e,t,n,r){(!this.model.top||e<this.top)&&(this.top=e),(!this.model.left||t<this.left)&&(this.left=t),(!this.model.bottom||n>this.bottom)&&(this.bottom=n),(!this.model.right||r>this.right)&&(this.right=r)}expandRow(e){if(e){let{dimensions:t,number:n}=e;t&&this.expand(n,t.min,n,t.max)}}expandToAddress(e){let t=n.decodeEx(e);`row`in t&&`col`in t&&this.expand(t.row,t.col,t.row,t.col)}get tl(){return n.n2l(this.left)+this.top}get $t$l(){return`$${n.n2l(this.left)}$${this.top}`}get br(){return n.n2l(this.right)+this.bottom}get $b$r(){return`$${n.n2l(this.right)}$${this.bottom}`}get range(){return`${this._serialisedSheetName+this.tl}:${this.br}`}get $range(){return`${this._serialisedSheetName+this.$t$l}:${this.$b$r}`}get shortRange(){return this.count>1?this.range:this._serialisedSheetName+this.tl}get $shortRange(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}get count(){return(1+this.bottom-this.top)*(1+this.right-this.left)}toString(){return this.range}intersects(e){return!(e.sheetName&&this.sheetName&&e.sheetName!==this.sheetName||e.bottom<this.top||e.top>this.bottom||e.right<this.left||e.left>this.right)}contains(e){let t=n.decodeEx(e);return`row`in t&&`col`in t?this.containsEx(t):!1}containsEx(e){return e.sheetName&&this.sheetName&&e.sheetName!==this.sheetName?!1:e.row>=this.top&&e.row<=this.bottom&&e.col>=this.left&&e.col<=this.right}forEachAddress(e){for(let t=this.left;t<=this.right;t++)for(let r=this.top;r<=this.bottom;r++)e(n.encodeAddress(r,t),r,t)}};let i=function(e){return e[e.Null=0]=`Null`,e[e.Merge=1]=`Merge`,e[e.Number=2]=`Number`,e[e.String=3]=`String`,e[e.Date=4]=`Date`,e[e.Hyperlink=5]=`Hyperlink`,e[e.Formula=6]=`Formula`,e[e.SharedString=7]=`SharedString`,e[e.RichText=8]=`RichText`,e[e.Boolean=9]=`Boolean`,e[e.Error=10]=`Error`,e[e.JSON=11]=`JSON`,e[e.Checkbox=12]=`Checkbox`,e}({}),a=function(e){return e[e.None=0]=`None`,e[e.Master=1]=`Master`,e[e.Shared=2]=`Shared`,e}({}),o=function(e){return e[e.None=0]=`None`,e[e.OfficeDocument=1]=`OfficeDocument`,e[e.Worksheet=2]=`Worksheet`,e[e.CalcChain=3]=`CalcChain`,e[e.SharedStrings=4]=`SharedStrings`,e[e.Styles=5]=`Styles`,e[e.Theme=6]=`Theme`,e[e.Hyperlink=7]=`Hyperlink`,e}({}),s=function(e){return e[e.Xlsx=1]=`Xlsx`,e}({}),c=function(e){return e[e.LeftToRight=1]=`LeftToRight`,e[e.RightToLeft=2]=`RightToLeft`,e}({}),l={NotApplicable:`#N/A`,Ref:`#REF!`,Name:`#NAME?`,DivZero:`#DIV/0!`,Null:`#NULL!`,Value:`#VALUE!`,Num:`#NUM!`},u={ValueType:i,FormulaType:a,RelationshipType:o,DocumentType:s,ReadingOrder:c,ErrorValue:l},d={'"':`&quot;`,"&":`&amp;`,"<":`&lt;`,">":`&gt;`},f=/["&<>]/g;function p(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;let n=typeof e;if(n!==typeof t||n!==`object`)return!1;let r=Array.isArray(e);if(r!==Array.isArray(t))return!1;if(r){let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!p(e[r],t[r]))return!1;return!0}let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(let n=0,r=i.length;n<r;n++){let r=i[n];if(!Object.prototype.hasOwnProperty.call(t,r)||!p(e[r],t[r]))return!1}return!0}function m(e){return e.replace(f,e=>d[e])}function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function g(...e){let t=e[0]||{},n=e.length;for(let r=1;r<n;r++){let n=e[r];if(n)if(Array.isArray(n))for(let e=0,r=n.length;e<r;e++){let r=n[e];if(r===void 0)continue;let i=t[e];Array.isArray(r)?t[e]=g(Array.isArray(i)?i:[],r):h(r)?t[e]=g(h(i)?i:{},r):t[e]=r}else{let e=Object.keys(n);for(let r=0,i=e.length;r<i;r++){let i=e[r];if(i===`__proto__`||i===`constructor`||i===`prototype`)continue;let a=n[i];if(a===void 0)continue;let o=t[i];Array.isArray(a)?t[i]=g(Array.isArray(o)?o:[],a):h(a)?t[i]=g(h(o)?o:{},a):t[i]=a}}}return t}var _=class e{static{this.DEFAULT_CONFIGS={note:{margins:{insetmode:`auto`,inset:[.13,.13,.25,.25]},protection:{locked:`True`,lockText:`True`},editAs:`absolute`},type:`note`}}constructor(e){this.note=e}get model(){let t=null;switch(typeof this.note){case`string`:t={type:`note`,note:{texts:[{text:this.note}]}};break;default:t={type:`note`,note:this.note};break}return g({},e.DEFAULT_CONFIGS,t)}set model(e){let{note:t}=e,{texts:n}=t;n&&n.length===1&&Object.keys(n[0]).length===1?this.note=n[0].text:this.note=t}static fromModel(t){let n=new e;return n.model=t,n}};let v=/(([a-z_\-0-9]*)!)?([a-z0-9_$]{2,})([(])?/gi,y=/^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i;function b(e,t,r){let i=n.decode(t),a=n.decode(r);return e.replace(v,(e,t,r,o,s)=>{if(s)return e;let c=y.exec(o);if(c){let r=c[1],o=c[2].toUpperCase(),s=c[3],l=c[4];if(o.length>3||o.length===3&&o>`XFD`)return e;let u=n.l2n(o),d=parseInt(l,10);return r||(u+=a.col-i.col),s||(d+=a.row-i.row),(t??``)+(r??``)+n.n2l(u)+(s??``)+d}return e})}var x=class e{static{this.Types=u.ValueType}constructor(t,r,i){if(!t||!r)throw Error(`A Cell needs a Row`);this._row=t,this._column=r,n.validateAddress(i),this._address=i,this._value=D.create(e.Types.Null,this),this.style=this._mergeStyle(t.style,r.style,{}),this._mergeCount=0}get worksheet(){return this._row.worksheet}get workbook(){return this._row.worksheet.workbook}destroy(){delete this.style,delete this._value,delete this._row,delete this._column,delete this._address}get numFmt(){return this.style.numFmt}set numFmt(e){this.style.numFmt=e}get font(){return this.style.font}set font(e){this.style.font=e}get alignment(){return this.style.alignment}set alignment(e){this.style.alignment=e}get border(){return this.style.border}set border(e){this.style.border=e}get fill(){return this.style.fill}set fill(e){this.style.fill=e}get protection(){return this.style.protection}set protection(e){this.style.protection=e}_mergeStyle(e,t,n){let r=e&&e.numFmt||t&&t.numFmt;r&&(n.numFmt=r);let i=e&&e.font||t&&t.font;i&&(n.font=i);let a=e&&e.alignment||t&&t.alignment;a&&(n.alignment=a);let o=e&&e.border||t&&t.border;o&&(n.border=o);let s=e&&e.fill||t&&t.fill;s&&(n.fill=s);let c=e&&e.protection||t&&t.protection;return c&&(n.protection=c),n}get address(){return this._address}get row(){return this._row.number}get col(){return this._column.number}get $col$row(){return`$${this._column.letter}$${this.row}`}get type(){return this._value.type}get effectiveType(){return this._value.effectiveType}toCsvString(){return this._value.toCsvString()}addMergeRef(){this._mergeCount++}releaseMergeRef(){this._mergeCount--}get isMerged(){return this._mergeCount>0||this.type===e.Types.Merge}merge(t,n){this._value.release(),this._value=D.create(e.Types.Merge,this,t),n||(this.style=t.style)}unmerge(){this.type===e.Types.Merge&&(this._value.release(),this._value=D.create(e.Types.Null,this),this.style=this._mergeStyle(this._row.style,this._column.style,{...this.style}))}isMergedTo(t){return this._value.type===e.Types.Merge?this._value.isMergedTo(t):!1}get master(){return this.type===e.Types.Merge?this._value.master:this}get isHyperlink(){return this._value.type===e.Types.Hyperlink}get hyperlink(){return this._value.hyperlink}get value(){return this._value.value}set value(t){if(this.type===e.Types.Merge){this._value.master.value=t;return}this._value.release(),this._value=D.create(D.getType(t),this,t)}get note(){if(this._comment)return this._comment.note}set note(e){this._comment=new _(e)}get comment(){return this._comment}set comment(e){e===void 0?this._comment=void 0:e instanceof _?this._comment=e:this._comment=new _(e)}get text(){return this._value.toString()}get html(){return m(this.text)}toString(){return this.text}_upgradeToHyperlink(t){this.type===e.Types.String&&(this._value=D.create(e.Types.Hyperlink,this,{text:String(this._value.value),hyperlink:t}))}get formula(){return this._value.formula}get result(){return this._value.result}get formulaType(){return this._value.formulaType}get fullAddress(){let{worksheet:e}=this._row;return{sheetName:e.name,address:this.address,row:this.row,col:this.col}}get name(){return this.names[0]}set name(e){this.names=[e]}get names(){return this.workbook.definedNames.getNamesEx(this.fullAddress)}set names(e){let{definedNames:t}=this.workbook;t.removeAllNames(this.fullAddress),e.forEach(e=>{t.addEx(this.fullAddress,e)})}addName(e){this.workbook.definedNames.addEx(this.fullAddress,e)}removeName(e){this.workbook.definedNames.removeEx(this.fullAddress,e)}removeAllNames(){this.workbook.definedNames.removeAllNames(this.fullAddress)}get _dataValidations(){return this.worksheet.dataValidations}get dataValidation(){return this._dataValidations.find(this.address)}set dataValidation(e){this._dataValidations.add(this.address,e)}get model(){let{model:e}=this._value;return e.style=this.style,this._comment&&(e.comment=this._comment.model),e}set model(e){if(this._value.release(),this._value=D.create(e.type,this),this._value.model=e,e.comment)switch(e.comment.type){case`note`:this._comment=_.fromModel(e.comment);break}e.style?this.style=e.style:this.style={}}},ee=class{constructor(e){this.model={address:e.address,type:x.Types.Null}}get value(){return null}set value(e){}get type(){return x.Types.Null}get effectiveType(){return x.Types.Null}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return``}release(){}toString(){return``}},S=class{constructor(e,t){this.model={address:e.address,type:x.Types.Number,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.Number}get effectiveType(){return x.Types.Number}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}},te=class{constructor(e,t){this.model={address:e.address,type:x.Types.String,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.String}get effectiveType(){return x.Types.String}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return`"${this.model.value.replace(/"/g,`""`)}"`}release(){}toString(){return this.model.value}},ne=class{constructor(e,t){this.model={address:e.address,type:x.Types.String,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}toString(){return this.model.value.richText.map(e=>e.text).join(``)}get type(){return x.Types.RichText}get effectiveType(){return x.Types.RichText}get address(){return this.model.address}set address(e){this.model.address=e}get text(){return this.toString()}toCsvString(){return`"${this.text.replace(/"/g,`""`)}"`}release(){}},C=class{constructor(e,t){this.model={address:e.address,type:x.Types.Date,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.Date}get effectiveType(){return x.Types.Date}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toISOString()}release(){}toString(){return this.model.value.toString()}},w=class{constructor(e,t){this.model={address:e.address,type:x.Types.Hyperlink,text:t?t.text:void 0,hyperlink:t?t.hyperlink:void 0},t&&t.tooltip&&(this.model.tooltip=t.tooltip)}get value(){return{text:this.model.text??``,hyperlink:this.model.hyperlink??``,tooltip:this.model.tooltip}}set value(e){this.model.text=e.text,this.model.hyperlink=e.hyperlink,e.tooltip&&(this.model.tooltip=e.tooltip)}get text(){return this.model.text}set text(e){this.model.text=e}get hyperlink(){return this.model.hyperlink}set hyperlink(e){this.model.hyperlink=e}get type(){return x.Types.Hyperlink}get effectiveType(){return x.Types.Hyperlink}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.hyperlink??``}release(){}toString(){return this.model.text??``}},re=class{constructor(e,t){this.model={address:e.address,type:x.Types.Merge,master:t?t.address:void 0},this._master=t,t&&t.addMergeRef()}get value(){return this._master.value}set value(e){e instanceof x?(this._master&&this._master.releaseMergeRef(),e.addMergeRef(),this._master=e):this._master.value=e}isMergedTo(e){return e===this._master}get master(){return this._master}get type(){return x.Types.Merge}get effectiveType(){return this._master.effectiveType}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return``}release(){this._master.releaseMergeRef()}toString(){return this.value.toString()}},T=class{constructor(e,t){this.cell=e,this.model={address:e.address,type:x.Types.Formula,shareType:t?t.shareType:void 0,ref:t?t.ref:void 0,formula:t?t.formula:void 0,sharedFormula:t?t.sharedFormula:void 0,result:t?t.result:void 0}}_copyModel(e){let t={};return e.formula&&(t.formula=e.formula),e.result!==void 0&&(t.result=e.result),e.ref&&(t.ref=e.ref),e.shareType&&(t.shareType=e.shareType),e.sharedFormula&&(t.sharedFormula=e.sharedFormula),t}get value(){return this._copyModel(this.model)}set value(e){e.formula&&(this.model.formula=e.formula),e.result!==void 0&&(this.model.result=e.result),e.ref&&(this.model.ref=e.ref),e.shareType&&(this.model.shareType=e.shareType),e.sharedFormula&&(this.model.sharedFormula=e.sharedFormula)}validate(e){switch(D.getType(e)){case x.Types.Null:case x.Types.String:case x.Types.Number:case x.Types.Date:break;case x.Types.Hyperlink:case x.Types.Formula:default:throw Error(`Cannot process that type of result value`)}}get dependencies(){return{ranges:this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),cells:this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g,``).match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g)}}get formula(){return this.model.formula||this._getTranslatedFormula()||``}set formula(e){this.model.formula=e}get formulaType(){return this.model.formula?u.FormulaType.Master:this.model.sharedFormula?u.FormulaType.Shared:u.FormulaType.None}get result(){return this.model.result}set result(e){this.model.result=e}get type(){return x.Types.Formula}get effectiveType(){let e=this.model.result;return e==null?u.ValueType.Null:e instanceof String||typeof e==`string`?u.ValueType.String:typeof e==`number`?u.ValueType.Number:e instanceof Date?u.ValueType.Date:typeof e==`object`&&`error`in e?u.ValueType.Error:u.ValueType.Null}get address(){return this.model.address}set address(e){this.model.address=e}_getTranslatedFormula(){if(!this._translatedFormula&&this.model.sharedFormula){let{worksheet:e}=this.cell,t=e.findCell(this.model.sharedFormula);this._translatedFormula=t&&b(t.formula,t.address,this.model.address)}return this._translatedFormula}toCsvString(){return`${this.model.result??``}`}release(){}toString(){return this.model.result?this.model.result.toString():``}},ie=class{constructor(e,t){this.model={address:e.address,type:x.Types.SharedString,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.SharedString}get effectiveType(){return x.Types.SharedString}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}},ae=class{constructor(e,t){this.model={address:e.address,type:x.Types.Boolean,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.Boolean}get effectiveType(){return x.Types.Boolean}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}},oe=class{constructor(e,t){this.model={address:e.address,type:x.Types.Checkbox,value:t.checkbox}}get value(){return{checkbox:this.model.value}}set value(e){this.model.value=e.checkbox}get type(){return x.Types.Checkbox}get effectiveType(){return x.Types.Boolean}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}},E=class{constructor(e,t){this.model={address:e.address,type:x.Types.Error,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.Error}get effectiveType(){return x.Types.Error}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.toString()}release(){}toString(){return this.model.value.error.toString()}},se=class{constructor(e,t){this.model={address:e.address,type:x.Types.String,value:JSON.stringify(t),rawValue:t}}get value(){return this.model.rawValue}set value(e){this.model.rawValue=e,this.model.value=JSON.stringify(e)}get type(){return x.Types.String}get effectiveType(){return x.Types.String}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value}release(){}toString(){return this.model.value}};let D={getType(e){if(e==null)return x.Types.Null;if(e instanceof String||typeof e==`string`)return x.Types.String;if(typeof e==`number`)return x.Types.Number;if(typeof e==`boolean`)return x.Types.Boolean;if(e instanceof Date)return x.Types.Date;if(typeof e==`object`){if(`checkbox`in e&&typeof e.checkbox==`boolean`)return x.Types.Checkbox;if(`text`in e&&e.text&&`hyperlink`in e&&e.hyperlink)return x.Types.Hyperlink;if(`formula`in e&&e.formula||`sharedFormula`in e&&e.sharedFormula)return x.Types.Formula;if(`richText`in e&&e.richText)return x.Types.RichText;if(`sharedString`in e&&e.sharedString)return x.Types.SharedString;if(`error`in e&&e.error)return x.Types.Error}return x.Types.JSON},types:[{t:x.Types.Null,f:ee},{t:x.Types.Number,f:S},{t:x.Types.String,f:te},{t:x.Types.Date,f:C},{t:x.Types.Hyperlink,f:w},{t:x.Types.Formula,f:T},{t:x.Types.Merge,f:re},{t:x.Types.JSON,f:se},{t:x.Types.SharedString,f:ie},{t:x.Types.RichText,f:ne},{t:x.Types.Boolean,f:ae},{t:x.Types.Error,f:E},{t:x.Types.Checkbox,f:oe}].reduce((e,t)=>(e[t.t]=t.f,e),[]),create(e,t,n){let r=this.types[e];if(!r)throw Error(`Could not create Value of type ${e}`);return new r(t,n)}};var ce=class{constructor(e,t){this._worksheet=e,this._number=t,this._cells=[],this.style={},this.outlineLevel=0}get number(){return this._number}get worksheet(){return this._worksheet}commit(){this._worksheet._commitRow(this)}destroy(){delete this._worksheet,delete this._cells,delete this.style}findCell(e){return this._cells[e-1]}getCellEx(e){let t=this._cells[e.col-1];if(!t){let n=this._worksheet.getColumn(e.col);t=new x(this,n,e.address),this._cells[e.col-1]=t}return t}getCell(e){let t;if(typeof e==`string`){let r=this._worksheet.getColumnKey(e);t=r?r.number:n.l2n(e)}else t=e;return this._cells[t-1]||this.getCellEx({address:n.encodeAddress(this._number,t),row:this._number,col:t})}splice(e,t,...n){let r=e+t,i=n.length-t,a=this._cells.length,o,s,c;if(i<0)for(o=e+n.length;o<=a;o++)c=this._cells[o-1],s=this._cells[o-i-1],s?(c=this.getCell(o),c.value=s.value,c.style=s.style,c.comment=s.comment):c&&(c.value=null,c.style={},c.comment=void 0);else if(i>0)for(o=a;o>=r;o--)s=this._cells[o-1],s?(c=this.getCell(o+i),c.value=s.value,c.style=s.style,c.comment=s.comment):this._cells[o+i-1]=void 0;for(o=0;o<n.length;o++)c=this.getCell(e+o),c.value=n[o],c.style={},c.comment=void 0}eachCell(e,t){let n=null,r;if(typeof e==`function`?r=e:(n=e,r=t),n&&n.includeEmpty){let e=this._cells.length;for(let t=1;t<=e;t++)r(this.getCell(t),t)}else this._cells.forEach((e,t)=>{e&&e.type!==u.ValueType.Null&&r(e,t+1)})}addPageBreak(e,t){let n=this._worksheet,r=Math.max(0,(e??0)-1)||0,i=Math.max(0,(t??0)-1)||16838,a={id:this._number,max:i,man:1};r&&(a.min=r),n.rowBreaks.push(a)}get values(){let e=[];return this._cells.forEach(t=>{t&&t.type!==u.ValueType.Null&&(e[t.col]=t.value)}),e}set values(e){if(this._cells=[],e)if(e instanceof Array){let t=0;Object.prototype.hasOwnProperty.call(e,`0`)&&(t=1),e.forEach((e,r)=>{e!==void 0&&(this.getCellEx({address:n.encodeAddress(this._number,r+t),row:this._number,col:r+t}).value=e)})}else this._worksheet.eachColumnKey((t,r)=>{e[r]!==void 0&&(this.getCellEx({address:n.encodeAddress(this._number,t.number),row:this._number,col:t.number}).value=e[r])})}getValues(){let e=[];return this._cells.forEach(t=>{t&&t.type!==u.ValueType.Null&&(e[t.col-1]=t.value)}),e}valuesToString(e=`,`){return this.getValues().join(e)}get hasValues(){return this._cells.some(e=>e&&e.type!==u.ValueType.Null)}get cellCount(){return this._cells.length}get actualCellCount(){let e=0;return this.eachCell(()=>{e++}),e}get dimensions(){let e=0,t=0;return this._cells.forEach(n=>{n&&n.type!==u.ValueType.Null&&((!e||e>n.col)&&(e=n.col),t<n.col&&(t=n.col))}),e>0?{min:e,max:t}:null}_applyStyle(e,t){this.style[e]=t,this._cells.forEach(n=>{n&&(n.style[e]=t)})}get numFmt(){return this.style.numFmt}set numFmt(e){e!==void 0&&this._applyStyle(`numFmt`,e)}get font(){return this.style.font}set font(e){e!==void 0&&this._applyStyle(`font`,e)}get alignment(){return this.style.alignment}set alignment(e){e!==void 0&&this._applyStyle(`alignment`,e)}get protection(){return this.style.protection}set protection(e){e!==void 0&&this._applyStyle(`protection`,e)}get border(){return this.style.border}set border(e){e!==void 0&&this._applyStyle(`border`,e)}get fill(){return this.style.fill}set fill(e){e!==void 0&&this._applyStyle(`fill`,e)}get hidden(){return!!this._hidden}set hidden(e){this._hidden=e}get outlineLevel(){return this._outlineLevel??0}set outlineLevel(e){this._outlineLevel=e}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelRow)}get model(){let e=[],t=0,n=0;return this._cells.forEach(r=>{if(r){let i=r.model;i&&((!t||t>r.col)&&(t=r.col),n<r.col&&(n=r.col),e.push(i))}}),this.height||e.length?{cells:e,number:this.number,min:t,max:n,height:this.height,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,collapsed:this.collapsed,dyDescent:this.dyDescent}:null}set model(e){if(e.number!==this._number)throw Error(`Invalid row number in model`);this._cells=[];let t;e.cells.forEach(e=>{switch(e.type){case x.Types.Merge:break;default:{let r;if(e.address)r=n.decodeAddress(e.address);else if(t){let{row:e}=t,i=t.col+1;r={row:e,col:i,address:n.encodeAddress(e,i),$col$row:`$${n.n2l(i)}$${e}`}}t=r;let i=this.getCellEx(r);i.model=e;break}}}),e.height?this.height=e.height:delete this.height,this.hidden=e.hidden,this.outlineLevel=e.outlineLevel??0,this.dyDescent=e.dyDescent,this.style=e.style&&JSON.parse(JSON.stringify(e.style))||{}}},O=class e{constructor(e,t,n){this._worksheet=e,this._number=t,n!==!1&&(this.defn=n)}get number(){return this._number}get worksheet(){return this._worksheet}get letter(){return n.n2l(this._number)}get isCustomWidth(){return this.width!==void 0&&this.width!==9}get defn(){return{header:this._header,key:this.key,width:this.width,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,bestFit:this.bestFit}}set defn(e){e?(this.key=e.key,this.width=e.width===void 0?9:e.width,this.outlineLevel=e.outlineLevel,e.style?this.style=e.style:this.style={},this.header=e.header,this._hidden=!!e.hidden,this.bestFit=e.bestFit):(delete this._header,delete this._key,delete this.width,this.style={},this.outlineLevel=0,delete this.bestFit)}get headers(){return Array.isArray(this._header)?this._header:this._header===void 0?[]:[this._header]}get header(){return this._header}set header(e){e===void 0?this._header=void 0:(this._header=e,this.headers.forEach((e,t)=>{this._worksheet.getCell(t+1,this.number).value=e}))}get key(){return this._key}set key(e){(this._key&&this._worksheet.getColumnKey(this._key))===this&&this._worksheet.deleteColumnKey(this._key),this._key=e,e&&this._worksheet.setColumnKey(this._key,this)}get hidden(){return!!this._hidden}set hidden(e){this._hidden=e}get outlineLevel(){return this._outlineLevel??0}set outlineLevel(e){this._outlineLevel=e}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelCol)}toString(){return JSON.stringify({key:this.key,width:this.width,headers:this.headers.length?this.headers:void 0})}equivalentTo(e){return this.width===e.width&&this.hidden===e.hidden&&this.outlineLevel===e.outlineLevel&&p(this.style,e.style)}equivalentToModel(e){return this.width===e.width&&this.hidden===e.hidden&&this.outlineLevel===e.outlineLevel&&this.bestFit===e.bestFit&&p(this.style,e.style)}get isDefault(){if(this.isCustomWidth||this.hidden||this.outlineLevel||this.bestFit)return!1;let e=this.style;return!(e&&(e.font||e.numFmt||e.alignment||e.border||e.fill||e.protection))}get headerCount(){return this.headers.length}eachCell(e,t){let n=this.number,r,i;typeof e==`function`?(r={},i=e):(r=e,i=t),this._worksheet.eachRow(r,(e,t)=>{i(e.getCell(n),t)})}get values(){let e=[];return this.eachCell((t,n)=>{t&&t.type!==u.ValueType.Null&&(e[n]=t.value)}),e}set values(e){if(!e)return;let t=this.number,n=0;Object.prototype.hasOwnProperty.call(e,`0`)&&(n=1),e.forEach((e,r)=>{this._worksheet.getCell(r+n,t).value=e})}addPageBreak(e,t){let n=this._worksheet,r=Math.max(0,(e??0)-1)||0,i=Math.max(0,(t??0)-1)||1048575,a={id:this._number,max:i,man:1};r&&(a.min=r),n.colBreaks.push(a)}get numFmt(){return this.style.numFmt}set numFmt(e){this.style.numFmt=e,this.eachCell(t=>{t.numFmt=e})}get font(){return this.style.font}set font(e){this.style.font=e,this.eachCell(t=>{t.font=e})}get alignment(){return this.style.alignment}set alignment(e){this.style.alignment=e,this.eachCell(t=>{t.alignment=e})}get protection(){return this.style.protection}set protection(e){this.style.protection=e,this.eachCell(t=>{t.protection=e})}get border(){return this.style.border}set border(e){this.style.border=e,this.eachCell(t=>{t.border=e})}get fill(){return this.style.fill}set fill(e){this.style.fill=e,this.eachCell(t=>{t.fill=e})}static toModel(e){let t=[],n=null;return e&&e.forEach((e,r)=>{e.isDefault?n&&=null:!n||!e.equivalentToModel(n)?(n={min:r+1,max:r+1,width:e.width===void 0?9:e.width,style:e.style,isCustomWidth:e.isCustomWidth,hidden:e.hidden,outlineLevel:e.outlineLevel,collapsed:e.collapsed,bestFit:e.bestFit},t.push(n)):n.max=r+1}),t.length?t:void 0}static fromModel(t,n){let r=t,i=Array.isArray(t)?t:n??[];i??=[];let a=[],o=1,s=0;for(i=i.sort(function(e,t){return e.min-t.min});s<i.length;){let t=i[s++];for(;o<t.min;)a.push(new e(r,o++));for(;o<=t.max;)a.push(new e(r,o++,t))}return a.length?a:null}};function le(e){return typeof e==`object`&&`nativeCol`in e&&`nativeRow`in e&&`nativeColOff`in e&&`nativeRowOff`in e}function ue(e){return typeof e==`object`&&`col`in e&&`row`in e}var k=class e{constructor(e,t,r=0){if(this.worksheet=e,!t)this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0;else if(typeof t==`string`){let e=n.decodeAddress(t);this.nativeCol=e.col+r,this.nativeColOff=0,this.nativeRow=e.row+r,this.nativeRowOff=0}else le(t)?(this.nativeCol=t.nativeCol??0,this.nativeColOff=t.nativeColOff??0,this.nativeRow=t.nativeRow??0,this.nativeRowOff=t.nativeRowOff??0):ue(t)?(this.col=t.col+r,this.row=t.row+r):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0)}static asInstance(t){return t==null?null:t instanceof e?t:new e(void 0,t)}get col(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth}set col(e){this.nativeCol=Math.floor(e),this.nativeColOff=Math.floor((e-this.nativeCol)*this.colWidth)}get row(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight}set row(e){this.nativeRow=Math.floor(e),this.nativeRowOff=Math.floor((e-this.nativeRow)*this.rowHeight)}get colWidth(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(this.worksheet.getColumn(this.nativeCol+1).width*1e4):64e4}get rowHeight(){return this.worksheet&&this.worksheet.getRow(this.nativeRow+1)&&this.worksheet.getRow(this.nativeRow+1).height?Math.floor(this.worksheet.getRow(this.nativeRow+1).height*1e4):18e4}get model(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}}set model(e){this.nativeCol=e.nativeCol,this.nativeColOff=e.nativeColOff,this.nativeRow=e.nativeRow,this.nativeRowOff=e.nativeRowOff}},de=class{constructor(e,t){this.worksheet=e,t&&(this.model=t)}get model(){switch(this.type){case`background`:return{type:this.type,imageId:this.imageId};case`image`:return{type:this.type,imageId:this.imageId,hyperlinks:this.range.hyperlinks,range:{tl:this.range.tl.model,br:this.range.br&&this.range.br.model,ext:this.range.ext,editAs:this.range.editAs}};default:throw Error(`Invalid Image Type`)}}set model({type:e,imageId:t,range:r,hyperlinks:i}){if(this.type=e,this.imageId=t,e===`image`)if(typeof r==`string`){let e=n.decode(r);`top`in e&&(this.range={tl:new k(this.worksheet,{col:e.left,row:e.top},-1),br:new k(this.worksheet,{col:e.right,row:e.bottom},0),editAs:`oneCell`})}else r&&(this.range={tl:new k(this.worksheet,r.tl,0),br:r.br?new k(this.worksheet,r.br,0):void 0,ext:r.ext,editAs:r.editAs,hyperlinks:i||(`hyperlinks`in r?r.hyperlinks:void 0)})}},fe=class{constructor(e,t,n){this.table=e,this.column=t,this.index=n}_set(e,t){this.table.cacheState(),this.column[e]=t}get name(){return this.column.name}set name(e){this._set(`name`,e)}get filterButton(){return this.column.filterButton}set filterButton(e){this.column.filterButton=e}get style(){return this.column.style}set style(e){this.column.style=e}get totalsRowLabel(){return this.column.totalsRowLabel}set totalsRowLabel(e){this._set(`totalsRowLabel`,e)}get totalsRowFunction(){return this.column.totalsRowFunction}set totalsRowFunction(e){this._set(`totalsRowFunction`,e)}get totalsRowResult(){return this.column.totalsRowResult}set totalsRowResult(e){this._set(`totalsRowResult`,e)}get totalsRowFormula(){return this.column.totalsRowFormula}set totalsRowFormula(e){this._set(`totalsRowFormula`,e)}},pe=class{constructor(e,t){if(this.worksheet=e,t){if(this.table=t,Array.isArray(t.rows)&&t.rows.length===0&&t.tableRef){let r=n.decode(t.tableRef);if(`dimensions`in r){let n=r.top+(t.headerRow===!1?0:1),i=r.bottom-(t.totalsRow===!0?1:0);if(i>=n)for(let a=n;a<=i;a++){let n=e.getRow(a),i=[];for(let e=r.left;e<=r.right;e++)i.push(n.getCell(e).value);t.rows.push(i)}}}this.validate(),this.store()}}getFormula(e){switch(e.totalsRowFunction){case`none`:return null;case`average`:return`SUBTOTAL(101,${this.table.name}[${e.name}])`;case`countNums`:return`SUBTOTAL(102,${this.table.name}[${e.name}])`;case`count`:return`SUBTOTAL(103,${this.table.name}[${e.name}])`;case`max`:return`SUBTOTAL(104,${this.table.name}[${e.name}])`;case`min`:return`SUBTOTAL(105,${this.table.name}[${e.name}])`;case`stdDev`:return`SUBTOTAL(106,${this.table.name}[${e.name}])`;case`var`:return`SUBTOTAL(107,${this.table.name}[${e.name}])`;case`sum`:return`SUBTOTAL(109,${this.table.name}[${e.name}])`;case`custom`:return e.totalsRowFormula??null;default:throw Error(`Invalid Totals Row Function: ${e.totalsRowFunction}`)}}get width(){return this.table.columns.length}get height(){return this.table.rows.length}get filterHeight(){return this.height+(this.table.headerRow?1:0)}get tableHeight(){return this.filterHeight+(this.table.totalsRow?1:0)}validate(){let{table:e}=this,t=(e,t,n)=>{e[t]===void 0&&(e[t]=n)};t(e,`headerRow`,!0),t(e,`totalsRow`,!1),t(e,`style`,{}),t(e.style,`theme`,`TableStyleMedium2`),t(e.style,`showFirstColumn`,!1),t(e.style,`showLastColumn`,!1),t(e.style,`showRowStripes`,!1),t(e.style,`showColumnStripes`,!1);let r=(e,t)=>{if(!e)throw Error(t)};r(!!e.ref,`Table must have ref`),r(!!e.columns,`Table must have column definitions`),r(!!e.rows,`Table must have row definitions`),e.tl=n.decodeAddress(e.ref);let{row:i,col:a}=e.tl;r(i>0,`Table must be on valid row`),r(a>0,`Table must be on valid col`);let{width:o,tableHeight:s}=this;e.autoFilterRef=n.encode(i,a,i,a+o-1),e.tableRef=n.encode(i,a,i+s-1,a+o-1),e.columns.forEach((e,n)=>{r(!!e.name,`Column ${n} must have a name`),n===0?t(e,`totalsRowLabel`,`Total`):(t(e,`totalsRowFunction`,`none`),e.totalsRowFormula=this.getFormula(e)??void 0)})}store(){let e=(e,t)=>{t&&Object.assign(e.style,t)},{worksheet:t,table:n}=this,{row:r,col:i}=n.tl,a=0;if(n.headerRow){let o=t.getRow(r+ a++);n.columns.forEach((t,n)=>{let{style:r,name:a}=t,s=o.getCell(i+n);s.value=a,e(s,r)})}if(n.rows.forEach(o=>{let s=t.getRow(r+ a++);o.forEach((t,r)=>{let a=s.getCell(i+r),o=t?.formula;if(typeof o==`string`){let e=n.qualifyImplicitStructuredReferences===!0;a.value={...t,formula:e?o.replace(/(^|[^A-Za-z0-9_])\[@\[?([^\[\]]+?)\]?\]/g,`$1${n.name}[[#This Row],[$2]]`):o}}else a.value=t;e(a,n.columns[r].style)})}),n.totalsRow){let o=t.getRow(r+ a++);n.columns.forEach((t,n)=>{let r=o.getCell(i+n);n===0?r.value=t.totalsRowLabel:this.getFormula(t)?r.value={formula:t.totalsRowFormula,result:t.totalsRowResult}:r.value=null,e(r,t.style)})}}load(e){let{table:t}=this,{row:n,col:r}=t.tl,i=0;if(t.headerRow){let a=e.getRow(n+ i++);t.columns.forEach((e,t)=>{let n=a.getCell(r+t);n.value=e.name})}if(t.rows.forEach(t=>{let a=e.getRow(n+ i++);t.forEach((e,t)=>{let n=a.getCell(r+t);n.value=e})}),t.totalsRow){let a=e.getRow(n+ i++);t.columns.forEach((e,t)=>{let n=a.getCell(r+t);t===0?n.value=e.totalsRowLabel:this.getFormula(e)&&(n.value={formula:e.totalsRowFormula,result:e.totalsRowResult})})}}get model(){return this.table}set model(e){this.table=e}cacheState(){this._cache||={ref:this.ref,width:this.width,tableHeight:this.tableHeight}}commit(){if(!this._cache)return;this.validate();let e=n.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(let t=0;t<this._cache.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=0;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}else{for(let t=this.tableHeight;t<this._cache.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=0;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}for(let t=0;t<this.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=this.width;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}}this.store(),this._cache=void 0}addRow(e,t,n){this.cacheState(),t===void 0?this.table.rows.push(e):this.table.rows.splice(t,0,e),n?.commit!==!1&&this.commit()}removeRows(e,t=1,n){this.cacheState(),this.table.rows.splice(e,t),n?.commit!==!1&&this.commit()}getColumn(e){let t=this.table.columns[e];return new fe(this,t,e)}addColumn(e,t,n){this.cacheState(),n===void 0?(this.table.columns.push(e),this.table.rows.forEach((e,n)=>{e.push(t[n])})):(this.table.columns.splice(n,0,e),this.table.rows.forEach((e,r)=>{e.splice(n,0,t[r])}))}removeColumns(e,t=1){this.cacheState(),this.table.columns.splice(e,t),this.table.rows.forEach(n=>{n.splice(e,t)})}_assign(e,t,n){this.cacheState(),e[t]=n}get ref(){return this.table.ref}set ref(e){this._assign(this.table,`ref`,e)}get name(){return this.table.name}set name(e){this.table.name=e}get displayName(){return this.table.displayName||this.table.name}set displayName(e){this.table.displayName=e}get headerRow(){return this.table.headerRow}set headerRow(e){this._assign(this.table,`headerRow`,e)}get totalsRow(){return this.table.totalsRow}set totalsRow(e){this._assign(this.table,`totalsRow`,e)}get theme(){return this.table.style.theme}set theme(e){this.table.style.theme=e}get showFirstColumn(){return this.table.style.showFirstColumn}set showFirstColumn(e){this.table.style.showFirstColumn=e}get showLastColumn(){return this.table.style.showLastColumn}set showLastColumn(e){this.table.style.showLastColumn=e}get showRowStripes(){return this.table.style.showRowStripes}set showRowStripes(e){this.table.style.showRowStripes=e}get showColumnStripes(){return this.table.style.showColumnStripes}set showColumnStripes(e){this.table.style.showColumnStripes=e}},me=class{constructor(e){this.model=e||{}}add(e,t){return this.model[e]=t}find(e){let t=this.model[e];if(t!==void 0)return t;let r;for(let t in this.model){if(!t.startsWith(`range:`))continue;r||=n.decodeAddress(e);let i=t.slice(6),a=n.decodeEx(i);if(!a.dimensions)continue;let o=a.tl,s=a.br;if(r.row>=o.row&&r.row<=s.row&&r.col>=o.col&&r.col<=s.col)return this.model[t]}}remove(e){this.model[e]=void 0}};let he=9525,ge=12700,_e=142875,ve=28575,ye=276225,be=190500;var xe=class e{constructor(e,t,n){this.worksheet=e;let{tl:r,br:i}=this._parseRange(t),a=1025+(e.formControls?.length??0),o;n?.link&&(o=this._toAbsoluteRef(n.link)),this.model={shapeId:a,ctrlPropId:0,tl:r,br:i,link:o,checked:n?.checked?`Checked`:`Unchecked`,text:n?.text??``,noThreeD:n?.noThreeD??!0,print:n?.print??!1}}get checked(){return this.model.checked===`Checked`}set checked(e){this.model.checked=e?`Checked`:`Unchecked`}get link(){return this.model.link}set link(e){this.model.link=e?this._toAbsoluteRef(e):void 0}get text(){return this.model.text}set text(e){this.model.text=e}_toAbsoluteRef(e){if(e.includes(`$`))return e;let t=n.decodeAddress(e);return`$${n.n2l(t.col)}$${t.row}`}_parseRange(e){let t,r;if(typeof e==`string`)if(e.includes(`:`)){let i=n.decode(e);if(`top`in i)if(i.left===i.right&&i.top===i.bottom){let e=i.left-1,n=i.top-1;t={col:e,colOff:_e,row:n,rowOff:ve},r={col:e+2,colOff:ye,row:n+1,rowOff:be}}else t={col:i.left-1,colOff:_e,row:i.top-1,rowOff:ve},r={col:i.right-1,colOff:ye,row:i.bottom-1,rowOff:be};else t={col:i.col-1,colOff:_e,row:i.row-1,rowOff:ve},r={col:i.col+1,colOff:ye,row:i.row,rowOff:be}}else{let i=n.decodeAddress(e);t={col:i.col-1,colOff:_e,row:i.row-1,rowOff:ve},r={col:i.col+1,colOff:ye,row:i.row,rowOff:be}}else if(`startCol`in e)t={col:e.startCol,colOff:e.startColOff??_e,row:e.startRow,rowOff:e.startRowOff??ve},r={col:e.endCol,colOff:e.endColOff??ye,row:e.endRow,rowOff:e.endRowOff??be};else{if(typeof e.tl==`string`){let r=n.decodeAddress(e.tl);t={col:r.col-1,colOff:_e,row:r.row-1,rowOff:ve}}else t={col:e.tl.col,colOff:e.tl.colOff??_e,row:e.tl.row,rowOff:e.tl.rowOff??ve};if(e.br)if(typeof e.br==`string`){let t=n.decodeAddress(e.br);r={col:t.col-1,colOff:ye,row:t.row-1,rowOff:be}}else r={col:e.br.col,colOff:e.br.colOff??ye,row:e.br.row,rowOff:e.br.rowOff??be};else r={col:t.col+2,colOff:ye,row:t.row+1,rowOff:be}}return{tl:t,br:r}}getVmlAnchor(){return e.getVmlAnchor(this.model)}getVmlStyle(){return e.getVmlStyle(this.model)}getVmlCheckedValue(){return e.getVmlCheckedValue(this.model)}static getVmlAnchor(e){let{tl:t,br:n}=e,r=Math.round(t.colOff/he),i=Math.round(t.rowOff/he),a=Math.round(n.colOff/he),o=Math.round(n.rowOff/he);return`${t.col}, ${r}, ${t.row}, ${i}, ${n.col}, ${a}, ${n.row}, ${o}`}static getVmlStyle(e){return`position:absolute;margin-left:${Math.round(e.tl.colOff/ge)}pt;margin-top:${Math.round(e.tl.rowOff/ge)}pt;width:96pt;height:18pt;z-index:1;visibility:visible`}static getVmlCheckedValue(e){switch(e.checked){case`Checked`:return 1;case`Mixed`:return 2;default:return 0}}};function Se(){return typeof process<`u`&&!!process.versions?.node}function Ce(e){if(Se())return Buffer.from(e,`base64`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function we(e,t){return 25569+e.getTime()/(24*3600*1e3)-(t?1462:0)}function Te(e,t){let n=Math.round((e-25569+(t?1462:0))*24*3600*1e3);return new Date(n)}function Ee(e){return new Date(e.endsWith(`Z`)?e:e+`Z`)}let De={lt:`<`,gt:`>`,amp:`&`,quot:`"`,apos:`'`};function Oe(e){return e.indexOf(`&`)===-1?e:e.replace(/&(#\d+|#x[0-9A-Fa-f]+|\w+);/g,(e,t)=>{if(t[0]===`#`){let n=t[1]===`x`?parseInt(t.slice(2),16):parseInt(t.slice(1));return Number.isNaN(n)?e:String.fromCodePoint(n)}return De[t]||e})}let ke=/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/;function A(e){let t=ke.exec(e);if(!t)return e;let n=[],r=0;for(let i=t.index;i<e.length;i++){let t=e.charCodeAt(i),a=null;switch(t){case 34:a=`&quot;`;break;case 38:a=`&amp;`;break;case 39:a=`&apos;`;break;case 60:a=`&lt;`;break;case 62:a=`&gt;`;break;case 127:a=``;break;default:if(t<=31&&(t<=8||t>=11&&t!==13)){a=``;break}continue}r!==i&&n.push(e.substring(r,i)),r=i+1,a&&n.push(a)}return r<e.length&&n.push(e.substring(r)),n.join(``)}function Ae(e){let t=typeof e==`number`?e:parseInt(e,10);return Number.isNaN(t)?0:t}function je(e){if(!e||e.indexOf(`@`)>-1)return!1;let t=e.replace(/\[[^\]]*\]/g,``);return t=t.replace(/"[^"]*"/g,``),t.match(/[ymdhMsb]+/)!==null}function j(e){return e===!0||e===`true`||e===1||e===`1`}function*Me(e,t,n=1){let r=n>0?(e,t)=>e<t:(e,t)=>e>t;for(let i=e;r(i,t);i+=n)yield i}function Ne(e){let t=Array.from(e);return t.length<=1?t:t.every(e=>Number.isFinite(e))?t.sort((e,t)=>e-t):t.every(e=>e instanceof Date)?t.sort((e,t)=>e.getTime()-t.getTime()):t.sort((e,t)=>{let n=Pe(e),r=Pe(t);return n===r?n===0?e-t:n===1?e.getTime()-t.getTime():String(e).localeCompare(String(t)):n-r})}function Pe(e){return Number.isFinite(e)?0:e instanceof Date?1:2}let Fe=new TextDecoder(`utf-8`),Ie;try{Ie=new TextDecoder(`latin1`)}catch{Ie=void 0}function Le(e){return typeof e==`string`?e:Fe.decode(e)}function Re(e){if(Se())return Buffer.from(e).toString(`base64`);if(Ie)try{return btoa(Ie.decode(e))}catch{}let t=32768,n=[];for(let r=0;r<e.length;r+=t)n.push(String.fromCharCode.apply(null,e.subarray(r,r+t)));return btoa(n.join(``))}function ze(e){let t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>8&255}return t}let Be=e=>Array.isArray(e);var M=class e{constructor(){this.__excelts_stream=!0,this._listeners=new Map,this._maxListeners=e.defaultMaxListeners}static{this.defaultMaxListeners=10}addListener(e,t){return this.on(e,t)}_listenerCount(e){return e?Be(e)?e.length:1:0}_hasListeners(e){return this._listenerCount(this._listeners.get(e))>0}on(e,t){let n=this._listeners.get(e);if(this._maxListeners>0){let t=this._listenerCount(n);t>=this._maxListeners&&console?.warn?.(`MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${t+1} ${String(e)} listeners added. Use emitter.setMaxListeners() to increase limit`)}return n?Be(n)?n.push(t):this._listeners.set(e,[n,t]):this._listeners.set(e,t),e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t),this}prependListener(e,t){let n=this._listeners.get(e);return n?Be(n)?n.unshift(t):this._listeners.set(e,[t,n]):this._listeners.set(e,t),e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.on(e,n)}prependOnceListener(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.prependListener(e,n)}removeListener(e,t){return this.off(e,t)}off(e,t){let n=this._listeners.get(e);if(!n)return this;if(!Be(n))return(n===t||n.listener===t)&&(this._listeners.delete(e),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t)),this;let r=n;if(r.length===0)return this._listeners.delete(e),this;let i=r.indexOf(t);if(i!==-1)r.splice(i,1);else for(let e=0,n=r.length;e<n;e++)if(r[e].listener===t){r.splice(e,1);break}return r.length===0?this._listeners.delete(e):r.length===1&&this._listeners.set(e,r[0]),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t),this}emit(e,...t){let n=this._listeners.get(e);if(!n)return!1;if(!Be(n)){try{n.apply(this,t)}catch(t){e!==`error`&&this.emit(`error`,t)}return!0}let r=n,i=r.length;if(i===0)return!1;if(i===1){try{r[0].apply(this,t)}catch(t){e!==`error`&&this.emit(`error`,t)}return!0}if(i===2){let n=r[0],i=r[1];try{n.apply(this,t)}catch(t){e!==`error`&&this.emit(`error`,t)}try{i.apply(this,t)}catch(t){e!==`error`&&this.emit(`error`,t)}return!0}let a=r.slice();for(let n=0;n<a.length;n++)try{a[n].apply(this,t)}catch(t){e!==`error`&&this.emit(`error`,t)}return!0}removeAllListeners(e){return e===void 0?this._listeners.clear():this._listeners.delete(e),this}listenerCount(e){return this._listenerCount(this._listeners.get(e))}listeners(e){let t=this._listeners.get(e);return t?Be(t)?t.slice():[t]:[]}rawListeners(e){let t=this._listeners.get(e);return t?Be(t)?t.slice():[t]:[]}eventNames(){return[...this._listeners.keys()]}setMaxListeners(e){return this._maxListeners=e,this}getMaxListeners(){return this._maxListeners}};let Ve=new TextEncoder,He=new TextDecoder(`utf-8`,{ignoreBOM:!0}),Ue=new Map;function We(e){if(!e||e===`utf-8`||e===`utf8`)return He;let t=e,n=Ue.get(t);return n||(n=new TextDecoder(t),Ue.set(t,n)),n}function Ge(e){return Ve.encode(e)}function Ke(e,t){let n=e.length;if(n===0)return new Uint8Array;if(n===1)return e[0];if(t===void 0){let r=0;for(let t=0;t<n;t++)r+=e[t].length;t=r}let r=new Uint8Array(t),i=0;for(let t=0;t<n;t++){let n=e[t];r.set(n,i),i+=n.length}return r}function qe(e){return!!e&&typeof e==`object`&&typeof e.getReader==`function`}function Je(e){return!!e&&typeof e==`object`&&typeof e.getWriter==`function`}function Ye(e){return!!e&&(typeof e==`object`||typeof e==`function`)&&typeof e[Symbol.asyncIterator]==`function`}function Xe(e){return!!e&&typeof e==`object`&&!!e.readable&&!!e.writable&&qe(e.readable)&&Je(e.writable)}let Ze=(e,t,n)=>{typeof e.off==`function`?e.off(t,n):typeof e.removeListener==`function`&&e.removeListener(t,n)},Qe=(e,t,n,r)=>(r?.once&&typeof e.once==`function`?e.once(t,n):e.on(t,n),()=>Ze(e,t,n)),$e=()=>{let e=[];return{add:(t,n,r)=>{e.push(Qe(t,n,r))},once:(t,n,r)=>{e.push(Qe(t,n,r,{once:!0}))},cleanup:()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}};var N=class e extends M{constructor(e){if(super(),this._reader=null,this._buffer=[],this._bufferIndex=0,this._unshiftBuffer=[],this._bufferSize=0,this._reading=!1,this._ended=!1,this._endEmitted=!1,this._destroyed=!1,this._errored=null,this._closed=!1,this._paused=!0,this._flowing=!1,this._pipeTo=[],this._pipeListeners=new Map,this._encoding=null,this._decoder=null,this._didRead=!1,this._aborted=!1,this._pushMode=!1,this._webStreamMode=!1,this.objectMode=e?.objectMode??!1,this.readableHighWaterMark=e?.highWaterMark??16384,this.autoDestroy=e?.autoDestroy??!0,this.emitClose=e?.emitClose??!0,e?.read&&(this._read=e.read.bind(this),this._pushMode=!0),e?.stream)this._stream=e.stream,this._webStreamMode=!0;else{let e;this._stream=new ReadableStream({start:t=>{e=t},pull:async()=>{this.emit(`drain`)},cancel:e=>{this._ended=!0,this._aborted=!0,this.emitClose&&this.emit(`close`)}}),this._controller=e}}static from(t,n){let r=new e({...n,objectMode:n?.objectMode??!0});return tt(r,et(t)),r}static isDisturbed(e){return e._didRead||e._ended||e._destroyed}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e.webStream}push(e){if(this._destroyed)return!1;this._pushMode=!0;let t=this._controller;if(e===null){if(this._ended)return!1;if(this._ended=!0,t)try{t.close()}catch{}return this._bufferedLength()===0&&this._emitEndOnce(),!1}if(t&&!this._webStreamMode)try{t.enqueue(e)}catch{}if(this._flowing)return this.emit(`data`,this._applyEncoding(e)),this._flowing?(this._read&&!this._ended&&queueMicrotask(()=>{this._flowing&&!this._ended&&!this._destroyed&&this._read(this.readableHighWaterMark)}),!0):!1;{let t=this._bufferedLength()===0;return this._buffer.push(e),this.objectMode||(this._bufferSize+=this._getChunkSize(e)),t&&queueMicrotask(()=>this.emit(`readable`)),this.objectMode?this._bufferedLength()<this.readableHighWaterMark:this._bufferSize<this.readableHighWaterMark}}_emitEndOnce(){this._endEmitted||(this._endEmitted=!0,this.emit(`end`))}unshift(e){this._destroyed||(this._bufferUnshift(e),this.objectMode||(this._bufferSize+=this._getChunkSize(e)))}read(e){if(this._didRead=!0,this._bufferedLength()>0){if(this.objectMode||e===void 0){let e=this._bufferShift();this.objectMode||(this._bufferSize-=this._getChunkSize(e));let t=this._applyEncoding(e);return this._ended&&this._bufferedLength()===0&&queueMicrotask(()=>this._emitEndOnce()),t}let t=this._bufferShift();this.objectMode||(this._bufferSize-=this._getChunkSize(t));let n=this._applyEncoding(t);return this._ended&&this._bufferedLength()===0&&queueMicrotask(()=>this._emitEndOnce()),n}return null}_bufferedLength(){return this._unshiftBuffer.length+(this._buffer.length-this._bufferIndex)}_bufferPeek(){let e=this._unshiftBuffer.length;return e>0?this._unshiftBuffer[e-1]:this._bufferIndex<this._buffer.length?this._buffer[this._bufferIndex]:null}_bufferShift(){if(this._unshiftBuffer.length>0)return this._unshiftBuffer.pop();let e=this._buffer[this._bufferIndex++];return this._bufferIndex===this._buffer.length?(this._buffer.length=0,this._bufferIndex=0,e):(this._bufferIndex>1024&&this._bufferIndex*2>this._buffer.length&&(this._buffer=this._buffer.slice(this._bufferIndex),this._bufferIndex=0),e)}_bufferUnshift(e){if(this._bufferIndex===0){this._unshiftBuffer.push(e);return}this._bufferIndex--,this._buffer[this._bufferIndex]=e}_getChunkSize(e){return e instanceof Uint8Array?e.byteLength:1}setEncoding(e){return this._encoding=e,e===`utf-8`||e===`utf8`?this._decoder=He:this._decoder=null,this}_applyEncoding(e){return this._encoding&&e instanceof Uint8Array?(this._decoder||=We(this._encoding),this._decoder.decode(e)):e}wrap(e){return e.on(`data`,t=>{this.push(t)||e.pause()}),e.on(`end`,()=>this.push(null)),e.on(`error`,e=>this.destroy(e)),e.on(`close`,()=>this.destroy()),this}pause(){return this._paused=!0,this._flowing=!1,this}resume(){for(this._paused=!1,this._flowing=!0;this._bufferedLength()>0&&this._flowing;){let e=this._bufferShift();this.objectMode||(this._bufferSize-=this._getChunkSize(e)),this.emit(`data`,this._applyEncoding(e))}return this._ended&&this._bufferedLength()===0?this._emitEndOnce():this._read?queueMicrotask(()=>{this._flowing&&!this._ended&&!this._destroyed&&this._read(this.readableHighWaterMark)}):this._webStreamMode&&!this._pushMode&&this._startReading(),this}on(e,t){return super.on(e,t),e===`data`&&this.resume(),this}isPaused(){return this._paused}pipe(e){let t=e,n=t,r=typeof t?.write==`function`,i=typeof t?.end==`function`,a=typeof n?.on==`function`,o=typeof n?.once==`function`,s=typeof n?.off==`function`;if(!r||!i||!o&&!a||!s&&!n?.removeListener)throw Error(`Readable.pipe: invalid destination`);this._pipeTo.push(t);let c,l=()=>{c&&=(typeof n.off==`function`?n.off(`drain`,c):typeof n.removeListener==`function`&&n.removeListener(`drain`,c),void 0)},u=e=>{if(!t.write(e)&&(this.pause(),!c)){c=()=>{l(),this.resume()},n.on(`drain`,c);let e=this._pipeListeners.get(t);e&&(e.drain=c)}},d=()=>{t.end()},f=e=>{typeof t.destroy==`function`?t.destroy(e):n.emit?.(`error`,e)};return this._pipeListeners.set(t,{data:u,end:d,error:f,eventTarget:n}),this.on(`data`,u),this.once(`end`,d),this.once(`error`,f),this.resume(),e}unpipe(e){if(e){let t=this._pipeTo.indexOf(e);t!==-1&&this._pipeTo.splice(t,1);let n=this._pipeListeners.get(e);n&&(this.off(`data`,n.data),this.off(`end`,n.end),this.off(`error`,n.error),n.drain&&(typeof n.eventTarget?.off==`function`?n.eventTarget.off(`drain`,n.drain):typeof n.eventTarget?.removeListener==`function`&&n.eventTarget.removeListener(`drain`,n.drain)),this._pipeListeners.delete(e))}else{for(let e of this._pipeTo){let t=this._pipeListeners.get(e);t&&(this.off(`data`,t.data),this.off(`end`,t.end),this.off(`error`,t.error),t.drain&&(typeof t.eventTarget?.off==`function`?t.eventTarget.off(`drain`,t.drain):typeof t.eventTarget?.removeListener==`function`&&t.eventTarget.removeListener(`drain`,t.drain)),this._pipeListeners.delete(e))}this._pipeTo=[]}return this.pause(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._ended=!0,this.unpipe(),e&&(this._errored=e,this.emit(`error`,e)),this._reader){let e=this._reader;this._reader=null,e.cancel().catch(()=>{}).finally(()=>{try{e.releaseLock()}catch{}})}return this._closed=!0,this.emit(`close`),this}get webStream(){return this._stream}get readable(){return!this._destroyed&&!this._ended}get readableEnded(){return this._ended}get readableLength(){return this._bufferedLength()}get destroyed(){return this._destroyed}get errored(){return this._errored}get closed(){return this._closed}get readableFlowing(){return!this._paused&&!this._ended?this._flowing:this._flowing?!0:null}get readableAborted(){return this._aborted}get readableDidRead(){return this._didRead}get readableEncoding(){return this._encoding}get readableObjectMode(){return this.objectMode}get readableBuffer(){return{length:this._bufferedLength(),head:this._bufferPeek()}}async _startReading(){if(!(this._reading||this._destroyed||!this._flowing)){this._reading=!0;try{for(this._reader||=this._stream.getReader();this._flowing&&!this._destroyed&&!this._pushMode;){let{done:e,value:t}=await this._reader.read();if(this._pushMode){if(this._reader){let e=this._reader;this._reader=null;try{e.releaseLock()}catch{}}break}if(e){if(this._ended=!0,this._emitEndOnce(),this._reader){let e=this._reader;this._reader=null;try{e.releaseLock()}catch{}}break}t!==void 0&&(this._flowing?this.emit(`data`,this._applyEncoding(t)):(this._buffer.push(t),this.objectMode||(this._bufferSize+=this._getChunkSize(t))))}}catch(e){if(this.emit(`error`,e),this._reader){let e=this._reader;this._reader=null;try{e.releaseLock()}catch{}}}finally{this._reading=!1}}}async*[Symbol.asyncIterator](){for(;this._bufferedLength()>0;){let e=this._bufferShift();this.objectMode||(this._bufferSize-=this._getChunkSize(e)),yield this._applyEncoding(e)}if(this._ended)return;let e=this.readableHighWaterMark,t=Math.max(0,Math.floor(e/2)),n=e=>this.objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?e.length:1,r=[],i=0,a=0,o=null,s=null,c=!1,l=!1,u=null,d=t=>{o?(o(t),o=null,s=null):r.push(t),a+=n(t),!l&&a>=e&&(l=!0,this.pause())},f=()=>{c=!0,o&&(o(null),o=null,s=null)},p=()=>{c=!0,o&&(o(null),o=null,s=null)},m=e=>{c=!0,u=e,s&&=(s(e),o=null,null)};this.on(`data`,d),this.on(`end`,f),this.on(`error`,m),this.on(`close`,p);try{for(this.resume();;){if(u)throw u;if(i<r.length){let e=r[i++];a-=n(e),i>=1024&&i*2>=r.length&&(r.splice(0,i),i=0),l&&a<=t&&!c&&!this._destroyed&&(l=!1,this.resume()),yield e;continue}if(c)break;let e=await new Promise((e,t)=>{o=e,s=t});e!==null&&(a-=n(e),l&&a<=t&&!c&&!this._destroyed&&(l=!1,this.resume()),yield e)}}finally{this.off(`data`,d),this.off(`end`,f),this.off(`error`,m),this.off(`close`,p)}}iterator(e){let t=e?.destroyOnReturn??!0,n=this[Symbol.asyncIterator]();return t?{next:async()=>n.next(),return:async e=>(this.destroy(),{done:!0,value:e}),[Symbol.asyncIterator](){return this}}:n}async*map(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);yield await e(t,{signal:n})}}async*filter(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);await e(t,{signal:n})&&(yield t)}}async*flatMap(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);let r=await e(t,{signal:n});for await(let e of r)yield e}}async*take(e,t){let n=t?.signal,r=0;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);if(r>=e)break;yield t,r++}}async*drop(e,t){let n=t?.signal,r=0;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);r>=e&&(yield t),r++}}async reduce(e,t,n){let r=n?.signal,i=t,a=!0;for await(let t of this){if(r?.aborted)throw Error(`AbortError`);a&&i===void 0?(i=t,a=!1):i=await e(i,t,{signal:r})}if(i===void 0)throw TypeError(`Reduce of empty stream with no initial value`);return i}async every(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);if(!await e(t,{signal:n}))return!1}return!0}async some(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);if(await e(t,{signal:n}))return!0}return!1}async find(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);if(await e(t,{signal:n}))return t}}async forEach(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);await e(t,{signal:n})}}async toArray(e){let t=e?.signal,n=[];for await(let e of this){if(t?.aborted)throw Error(`AbortError`);n.push(e)}return n}async*asIndexedPairs(e){let t=e?.signal,n=0;for await(let e of this){if(t?.aborted)throw Error(`AbortError`);yield[n++,e]}}compose(t){if(typeof t==`function`){let n=t(this);return e.from(n)}return this.pipe(t),t}};function et(e){return e&&typeof e[Symbol.asyncIterator]==`function`?e:(async function*(){for(let t of e)yield t})()}function tt(e,t){(async()=>{try{for await(let n of t)e.push(n)||await new Promise(e=>setTimeout(e,0));e.push(null)}catch(t){e.destroy(t)}})()}var nt=class e extends M{constructor(e){if(super(),this._writer=null,this._ended=!1,this._finished=!1,this._destroyed=!1,this._errored=null,this._closed=!1,this._pendingWrites=0,this._writableLength=0,this._needDrain=!1,this._corked=0,this._corkedChunks=[],this._defaultEncoding=`utf8`,this._aborted=!1,this._ownsStream=!1,this.objectMode=e?.objectMode??!1,this.writableHighWaterMark=e?.highWaterMark??16384,this.autoDestroy=e?.autoDestroy??!0,this.emitClose=e?.emitClose??!0,this._defaultEncoding=e?.defaultEncoding??`utf8`,e?.write&&(this._writeFunc=e.write.bind(this)),e?.final&&(this._finalFunc=e.final.bind(this)),e?.stream)this._stream=e.stream,this._ownsStream=!1;else{this._ownsStream=!0;let e=()=>this._writeFunc,t=()=>this._finalFunc,n=()=>this._defaultEncoding,r=e=>{this._finished=e},i=e=>{this._aborted=e},a=this.emit.bind(this),o=()=>this.emitClose,s=e=>this._write?.(e);this._stream=new WritableStream({write:async t=>{let r=e();r?await new Promise((e,i)=>{r(t,n(),t=>{t?i(t):e()})}):s(t)},close:async()=>{let e=t();e&&await new Promise((t,n)=>{e(e=>{e?n(e):t()})}),r(!0),a(`finish`),o()&&a(`close`)},abort:e=>{i(!0),a(`error`,e)}})}}setDefaultEncoding(e){return this._defaultEncoding=e,this}cork(){this._corked++}uncork(){if(this._corked>0&&this._corked--,this._corked===0){let e=this._corkedChunks;this._corkedChunks=[];for(let{chunk:t,callback:n}of e)this._doWrite(t,n)}}write(e,t,n){if(this._destroyed||this._ended)return(typeof t==`function`?t:n)?.(Error(`Cannot write after stream destroyed/ended`)),!1;let r=typeof t==`function`?t:n;if(this._corked>0){this._corkedChunks.push({chunk:e,callback:r});let t=this._getChunkSize(e);return this._writableLength+=t,this._writableLength<this.writableHighWaterMark}let i=this._doWrite(e,r);return i||(this._needDrain=!0),i}_doWrite(e,t){let n=this._getChunkSize(e);return this._pendingWrites++,this._writableLength+=n,this._getWriter().write(e).then(()=>{this._pendingWrites--,this._writableLength-=n,this._needDrain&&this._writableLength<this.writableHighWaterMark&&(this._needDrain=!1,this.emit(`drain`)),t?.(null)}).catch(e=>{this._pendingWrites--,this._writableLength-=n,this._destroyed||(this._errored=e,this.emit(`error`,e)),t?.(e)}),this._writableLength<this.writableHighWaterMark}_getChunkSize(e){return this.objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?e.length:0}end(e,t,n){if(this._ended)return this;this._ended=!0;let r=typeof e==`function`?void 0:e,i=typeof e==`function`?e:typeof t==`function`?t:n;return(async()=>{try{let e=this._getWriter();if(r!==void 0&&await e.write(r),await e.close(),this._writer===e){this._writer=null;try{e.releaseLock()}catch{}}this._ownsStream||(this._finished=!0,this.emit(`finish`),this.emitClose&&this.emit(`close`)),i&&i()}catch(e){this.emit(`error`,e)}})(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._ended=!0,e&&!this._errored&&(this._errored=e,this.emit(`error`,e)),this._writer){let t=this._writer;this._writer=null,t.abort(e).catch(()=>{}).finally(()=>{try{t.releaseLock()}catch{}})}return this._closed=!0,this.emit(`close`),this}get webStream(){return this._stream}get writable(){return!this._destroyed&&!this._ended}get writableEnded(){return this._ended}get writableFinished(){return this._finished}get writableLength(){return this._writableLength}get destroyed(){return this._destroyed}get errored(){return this._errored}get closed(){return this._closed}get writableNeedDrain(){return this._writableLength>=this.writableHighWaterMark}get writableCorked(){return this._corked}get writableAborted(){return this._aborted}get writableObjectMode(){return this.objectMode}get defaultEncoding(){return this._defaultEncoding}get writableBuffer(){return{length:this._corkedChunks.length,head:this._corkedChunks.length>0?this._corkedChunks[0].chunk:null}}_writev(e,t){let n=0,r=()=>{if(n>=e.length){t(null);return}let{chunk:i}=e[n++];this._doWrite(i,e=>{if(e){t(e);return}r()})};r()}writev(e,t){return this._destroyed||this._ended?(t?.(Error(`Cannot write after stream destroyed/ended`)),!1):(this._writev(e,t??(()=>{})),this._writableLength<this.writableHighWaterMark)}_getWriter(){return this._writer||=this._stream.getWriter(),this._writer}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e.webStream}};function rt(e){return e instanceof nt?e:e?.getWriter?new nt({stream:e}):e}var it=class e extends M{push(e){return this._readable.push(e)}constructor(e){super(),this._destroyed=!1,this._ended=!1,this._errored=!1,this._dataForwardingSetup=!1,this._endTimer=null,this._webStream=null,this._sideForwardingCleanup=null,this.objectMode=e?.objectMode??!1,this._transformImpl=e?.transform,this._flushImpl=e?.flush,this._readable=new N({objectMode:this.objectMode}),this._writable=new nt({objectMode:this.objectMode,write:(e,t,n)=>{this._runTransform(e).then(()=>n(null)).catch(e=>n(e))},final:e=>{this._runFlush().then(()=>{this._readable.push(null),e(null)}).catch(t=>e(t))}}),this._setupSideForwarding()}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let e=$e();e.once(this._readable,`end`,()=>this.emit(`end`)),e.add(this._readable,`error`,e=>this._emitErrorOnce(e)),e.once(this._writable,`finish`,()=>this.emit(`finish`)),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.add(this._writable,`error`,e=>this._emitErrorOnce(e)),this._sideForwardingCleanup=()=>e.cleanup()}_scheduleEnd(){this._destroyed||this._errored||this._writable.writableEnded||(this._endTimer&&clearTimeout(this._endTimer),this._endTimer=setTimeout(()=>{this._endTimer=null,!(this._destroyed||this._errored||this._writable.writableEnded)&&this._writable.end()},0))}_emitErrorOnce(e){if(this._errored)return;this._errored=!0;let t=e instanceof Error?e:Error(String(e));this.emit(`error`,t),this._destroyed||(this._destroyed=!0,this._readable.destroy(t),this._writable.destroy(t),queueMicrotask(()=>this.emit(`close`)))}_hasSubclassTransform(){return this._transformImpl?!1:Object.getPrototypeOf(this)._transform!==e.prototype._transform}_hasSubclassFlush(){return this._flushImpl?!1:Object.getPrototypeOf(this)._flush!==e.prototype._flush}async _runTransform(e){if(this._destroyed||this._errored)throw Error(this._errored?`Cannot write after stream errored`:`Cannot write after stream destroyed`);try{if(this._hasSubclassTransform()){await new Promise((t,n)=>{this._transform(e,`utf8`,(e,r)=>{if(e){n(e);return}r!==void 0&&this.push(r),t()})});return}let t=this._transformImpl;if(!t){this.push(e);return}let n=t.length;if(n>=3){await new Promise((n,r)=>{t.call(this,e,`utf8`,(e,t)=>{if(e){r(e);return}t!==void 0&&this.push(t),n()})});return}if(n===2){await new Promise((n,r)=>{t.call(this,e,(e,t)=>{if(e){r(e);return}t!==void 0&&this.push(t),n()})});return}let r=t.call(this,e);if(r&&typeof r.then==`function`){let e=await r;e!==void 0&&this.push(e);return}r!==void 0&&this.push(r)}catch(e){throw this._emitErrorOnce(e),e}}async _runFlush(){if(!(this._destroyed||this._errored))try{if(this._hasSubclassFlush()){await new Promise((e,t)=>{this._flush((n,r)=>{if(n){t(n);return}r!==void 0&&this.push(r),e()})});return}let e=this._flushImpl;if(!e)return;if(e.length>=1){await new Promise((t,n)=>{e.call(this,(e,r)=>{if(e){n(e);return}r!==void 0&&this.push(r),t()})});return}let t=e.call(this);if(t&&typeof t.then==`function`){let e=await t;e!=null&&this.push(e);return}t!=null&&this.push(t)}catch(e){throw this._emitErrorOnce(e),e}}on(e,t){return e===`data`&&!this._dataForwardingSetup&&(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>this.emit(`data`,e))),super.on(e,t)}write(e,t,n){let r=typeof t==`function`?t:n;return this._ended&&!this._writable.writableEnded&&this._scheduleEnd(),this._writable.write(e,r)}end(e,t,n){if(this._ended)return this;this._ended=!0;let r=typeof e==`function`?void 0:e,i=typeof e==`function`?e:typeof t==`function`?t:n;return i&&this.once(`finish`,i),r!==void 0&&this._writable.write(r),this._scheduleEnd(),this}read(e){return this._readable.read(e)}pipe(e){return this._readable.pipe(e)}unpipe(e){return this._readable.unpipe(e),this}isPaused(){return this._readable.isPaused()}resume(){return this._readable.resume(),this}pause(){return this._readable.pause(),this}destroy(e){this._destroyed||(this._destroyed=!0,this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable.destroy(e),this._writable.destroy(e),queueMicrotask(()=>this.emit(`close`)))}get webStream(){if(this._webStream)return this._webStream;let e=this[Symbol.asyncIterator]();return this._webStream={readable:new ReadableStream({pull:async t=>{let{done:n,value:r}=await e.next();if(n){t.close();return}t.enqueue(r)},cancel:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}}),writable:new WritableStream({write:e=>new Promise((t,n)=>{this.write(e,e=>{e?n(e):t()})}),close:()=>new Promise(e=>{this.end(()=>e())}),abort:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}})},this._webStream}get readable(){return this._readable.readable}get writable(){return this._writable.writable}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get readableObjectMode(){return this._readable.readableObjectMode??this._readable.objectMode}get readableFlowing(){return this._readable.readableFlowing}get destroyed(){return this._destroyed}async*[Symbol.asyncIterator](){yield*this._readable[Symbol.asyncIterator]()}static fromWeb(t,n){let r=new e(n);r._webStream=t;let i=N.fromWeb(t.readable,{objectMode:n?.objectMode}),a=nt.fromWeb(t.writable,{objectMode:n?.objectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return e.webStream}_transform(e,t,n){n(null,e)}_flush(e){e()}},at=class e extends M{static from(t){if(t instanceof e)return t;let n=(e,t)=>{let n=new nt({objectMode:t.readableObjectMode,write(e,n,r){t.push(e),r()},final(e){t.push(null),e()}}),r=Qe(e,`error`,e=>{t.emit(`error`,e)});Qe(e,`end`,r,{once:!0}),Qe(e,`close`,r,{once:!0}),Qe(n,`finish`,r,{once:!0}),e.pipe(n)};if(typeof t==`object`&&t&&`readable`in t&&`writable`in t){let r=t,i=new e({readableObjectMode:r.readable?.readableObjectMode,writableObjectMode:r.writable?.writableObjectMode,write:r.writable?(e,t,n)=>{r.writable.write(e,t,n)}:void 0,final:r.writable?e=>{r.writable.end(e)}:void 0});return r.readable&&n(r.readable,i),i}if(typeof t==`object`&&t&&(Symbol.asyncIterator in t||Symbol.iterator in t)){let r=N.from(t),i=new e;return n(r,i),i}if(t instanceof N){let r=new e;return n(t,r),r}if(t instanceof nt)return new e({objectMode:!0,write(e,n,r){t.write(e,n,r)},final(e){t.end(e)}});throw Error(`Duplex.from: unsupported source type`)}static fromWeb(t,n){let r=new e(n),i=new N({stream:t.readable,objectMode:r.readableObjectMode}),a=new nt({stream:t.writable,objectMode:r.writableObjectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return{readable:e._readable.webStream,writable:e._writable.webStream}}constructor(e){super(),this._dataForwardingSetup=!1,this._sideForwardingCleanup=null,this.allowHalfOpen=e?.allowHalfOpen??!0;let t=e?.objectMode??!1;this.readableObjectMode=e?.readableObjectMode??t,this.writableObjectMode=e?.writableObjectMode??t,this._readable=new N({highWaterMark:e?.readableHighWaterMark,objectMode:this.readableObjectMode,read:e?.read?.bind(this)}),this._writable=new nt({highWaterMark:e?.writableHighWaterMark,objectMode:this.writableObjectMode,write:e?.write?.bind(this),final:e?.final?.bind(this)}),this._setupSideForwarding()}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let e=$e();e.once(this._readable,`end`,()=>{this.emit(`end`),this.allowHalfOpen||this._writable.end()}),e.add(this._readable,`error`,e=>this.emit(`error`,e)),e.add(this._writable,`error`,e=>this.emit(`error`,e)),e.once(this._writable,`finish`,()=>this.emit(`finish`)),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.once(this._writable,`close`,()=>{!this.allowHalfOpen&&!this._readable.destroyed&&this._readable.destroy()}),this._sideForwardingCleanup=()=>e.cleanup()}on(e,t){return e===`data`&&!this._dataForwardingSetup&&(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>this.emit(`data`,e))),super.on(e,t)}push(e){return this._readable.push(e)}unshift(e){this._readable.unshift(e)}read(e){return this._readable.read(e)}write(e,t,n){let r=typeof t==`function`?t:n;return this._writable.write(e,r)}end(e,t,n){let r=typeof e==`function`?void 0:e,i=typeof e==`function`?e:typeof t==`function`?t:n;return i&&this.once(`finish`,i),r!==void 0&&this._writable.write(r),this._writable.end(),this}cork(){this._writable.cork()}uncork(){this._writable.uncork()}setEncoding(e){return this._readable.setEncoding(e),this}setDefaultEncoding(e){return this._writable.setDefaultEncoding(e),this}pipe(e){return e instanceof it?(this._readable.pipe(e._writable),e):(this._readable.pipe(e),e)}unpipe(e){return this._readable.unpipe(e),this}pause(){return this._readable.pause(),this}resume(){return this._readable.resume(),this}isPaused(){return this._readable.isPaused()}destroy(e){return this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable.destroy(e),this._writable.destroy(e),this}get readable(){return this._readable.readable}get writable(){return this._writable.writable}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get destroyed(){return this._readable.destroyed&&this._writable.destroyed}get writableCorked(){return this._writable.writableCorked}get writableNeedDrain(){return this._writable.writableNeedDrain}[Symbol.asyncIterator](){return this._readable[Symbol.asyncIterator]()}},ot=class extends it{constructor(e){super({...e,transform:e=>e})}};let st=e=>!e||typeof e!=`object`||typeof e.pipe==`function`||typeof e.write==`function`||typeof e.end==`function`||typeof e.getReader==`function`||typeof e.getWriter==`function`?!1:Object.prototype.hasOwnProperty.call(e,`signal`)||Object.prototype.hasOwnProperty.call(e,`end`),ct=e=>e instanceof N||e instanceof nt||e instanceof it||e instanceof at?e:Xe(e)?it.fromWeb(e):qe(e)?N.fromWeb(e):Je(e)?nt.fromWeb(e):e;function lt(...e){let t,n={},r,i=e[e.length-1];typeof i==`function`?(r=i,t=e.slice(0,-1)):st(i)?(n=i,t=e.slice(0,-1)):t=e;let a=new Promise((e,r)=>{if(t.length<2){r(Error(`Pipeline requires at least 2 streams`));return}let i=t.map(ct),a=i[0],o=i[i.length-1],s=i.slice(1,-1),c=!1,l=[a,...s,o],u=$e(),d,f=t=>{if(!c)if(c=!0,u.cleanup(),d&&n.signal&&n.signal.removeEventListener(`abort`,d),t){for(let e of l)typeof e.destroy==`function`&&e.destroy(t);r(t)}else e()};if(n.signal){if(n.signal.aborted){f(Error(`Pipeline aborted`));return}d=()=>f(Error(`Pipeline aborted`)),n.signal.addEventListener(`abort`,d)}let p=a;for(let e of s)p.pipe(e),p=e;if(n.end!==!1)p.pipe(o);else{let e=!1,t=!1,n=()=>{t=!1,e&&typeof p.resume==`function`&&(e=!1,p.resume())};u.add(p,`data`,r=>{!o.write(r)&&!t&&(t=!0,!e&&typeof p.pause==`function`&&(e=!0,p.pause()),u.once(o,`drain`,n))}),u.once(p,`end`,()=>f())}u.once(o,`finish`,()=>f());for(let e of l)u.once(e,`error`,e=>f(e))});return r&&a.then(()=>r(null)).catch(e=>r(e)),a}function ut(e,t,n){let r={},i;typeof t==`function`?i=t:t&&(r=t,i=n);let a=new Promise((t,n)=>{let i=ct(e),a=!1,o=$e(),s,c=()=>{o.cleanup(),s&&r.signal&&r.signal.removeEventListener(`abort`,s)},l=e=>{a||(a=!0,c(),e&&!r.error?n(e):t())};if(r.signal){if(r.signal.aborted){l(Error(`Aborted`));return}s=()=>l(Error(`Aborted`)),r.signal.addEventListener(`abort`,s)}let u=r.readable!==!1,d=r.writable!==!1;if(u&&i.readableEnded){l();return}if(d&&i.writableFinished){l();return}d&&o.once(i,`finish`,()=>l()),u&&o.once(i,`end`,()=>l()),o.once(i,`error`,e=>l(e)),o.once(i,`close`,()=>l())});return i&&a.then(()=>i(null)).catch(e=>i(e)),a}function dt(e){let t=new Uint8Array(4);return t[0]=e&255,t[1]=e>>8&255,t[2]=e>>16&255,t[3]=e>>24&255,t}let ft={async hash(e,...t){let n=Ke(t),r=await crypto.subtle.digest(e,new Uint8Array(n));return new Uint8Array(r)},async convertPasswordToHash(e,t,n,r){let i=ze(e),a=Ce(n),o=await this.hash(t,a,i);for(let e=0;e<r;e++)o=await this.hash(t,o,dt(e));return Re(o)},randomBytes(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}};var pt=class{constructor(e){this.code=e}toString(){return`#${this.code}`}};let mt={sum:`Sum`,count:`Count`,average:`Average`,max:`Max`,min:`Min`,product:`Product`,countNums:`Count Numbers`,stdDev:`StdDev`,stdDevP:`StdDevP`,var:`Var`,varP:`VarP`},ht=new Set(Object.keys(mt));function gt(e){let t=e.model;if(t.headerRow===!1)throw Error(`Cannot create pivot table from a table without headers. Set headerRow: true on the table.`);if(!t.rows||t.rows.length===0)throw Error(`Cannot create pivot table from an empty table. Add data rows to the table.`);let r=t.columns.map(e=>e.name),i=new Set;for(let e of r){if(i.has(e))throw Error(`Duplicate column name "${e}" found in table. Pivot tables require unique column names.`);i.add(e)}let a=[void 0,...r],o=t.rows.map(e=>[void 0,...e]),s=t.tl;if(!s)throw Error(`Table "${t.name}" is missing top-left cell address (tl)`);let c=s.row,l=s.col,u=c+t.rows.length,d=l+r.length-1,f=n.encode(c,l,u,d);return{name:e.worksheet.name,tableName:t.name,getRow(e){if(e===1)return{values:a};let t=e-2;return t>=0&&t<o.length?{values:o[t]}:{values:[]}},getColumn(e){if(e<1||e>r.length)return{values:[]};let n=[];n[1]=r[e-1];for(let r=0;r<t.rows.length;r++)n[r+2]=t.rows[r][e-1];return{values:n}},getSheetValues(){let e=[];e[1]=a;for(let t=0;t<o.length;t++)e[t+2]=o[t];return e},dimensions:{shortRange:f}}}function _t(e){if(e.sourceSheet&&e.sourceTable)throw Error(`Cannot specify both sourceSheet and sourceTable. Choose one.`);if(e.sourceTable)return gt(e.sourceTable);if(!e.sourceSheet)throw Error(`Either sourceSheet or sourceTable must be provided.`);return e.sourceSheet}function vt(e){return typeof e==`string`?e:e.name}function yt(e){return typeof e==`string`?void 0:e.metric}function bt(e,t){let n=_t(t);xt(t,n);let{rows:r}=t,i=t.columns??[],a=t.pages??[],o=t.values.map(vt),s=t.metric??`sum`,c=t.values.map(e=>yt(e)??s),l=Ct(n,[...r,...i,...a],o),u={};for(let e=0;e<l.length;e++)u[l[e].name]=e;let d=(e,t)=>{let n=u[e];if(n===void 0)throw Error(`${t} field "${e}" not found in cache fields`);return n},f=r.map(e=>d(e,`Row`)),p=i.map(e=>d(e,`Column`)),m=o.map(e=>d(e,`Value`)),h=a.map(e=>d(e,`Page`)),g=e.workbook.pivotTables.map(e=>e.tableNumber).filter(e=>Number.isFinite(e)),_=g.length>0?g.reduce((e,t)=>e>t?e:t,-1/0)+1:1,v=e.workbook.pivotTables.map(e=>parseInt(e.cacheId,10)).filter(e=>Number.isFinite(e)),y=v.length>0?v.reduce((e,t)=>e>t?e:t,-1/0)+1:10+_-1;return{source:n,rows:f,columns:p,values:m,pages:h,metric:s,valueMetrics:c,cacheFields:l,cacheId:String(y),applyWidthHeightFormats:t.applyWidthHeightFormats??`1`,tableNumber:_}}function xt(e,t){let n=e.columns??[],r=e.pages??[],i=e.values.map(vt),a=t.getRow(1).values.slice(1);for(let e=0;e<a.length;e++){let n=a[e];if(n==null||n===``||typeof n==`string`&&n.trim()===``)throw Error(`Empty or missing header name at column ${e+1} in ${t.name}. Pivot tables require all columns to have non-empty headers.`)}let o=new Set;for(let e of a){let n=String(e);if(o.has(n))throw Error(`Duplicate header name "${n}" found in ${t.name}. Pivot tables require unique column names.`);o.add(n)}let s=new Set(a.map(String)),c=e=>{if(!s.has(e))throw Error(`The header name "${e}" was not found in ${t.name}.`)};for(let t of e.rows)c(t);for(let e of n)c(e);for(let e of i)c(e);for(let e of r)c(e);let l=new Map,u=[{name:`rows`,fields:e.rows},{name:`columns`,fields:n},{name:`pages`,fields:r}];for(let e of u)for(let t of e.fields){let n=l.get(t);if(n===e.name)throw Error(`Duplicate field "${t}" in ${e.name}. Each field can only appear once per axis area.`);if(n)throw Error(`Field "${t}" cannot appear in both ${n} and ${e.name}. Each field can only be assigned to one axis area.`);l.set(t,e.name)}if(!e.rows.length)throw Error(`No pivot table rows specified.`);if(e.values.length<1)throw Error(`Must have at least one value.`);if(e.metric!==void 0&&!ht.has(e.metric))throw Error(`Invalid metric "${e.metric}". Must be one of: ${[...ht].join(`, `)}.`);for(let t of e.values){let e=yt(t);if(e!==void 0&&!ht.has(e))throw Error(`Invalid metric "${e}" on value field "${vt(t)}". Must be one of: ${[...ht].join(`, `)}.`)}let d=new Set;for(let e of i){if(d.has(e))throw Error(`Duplicate value field "${e}". Each value field name must be unique.`);d.add(e)}}function St(e){if(e==null)return null;if(typeof e!=`object`||e instanceof Date||e instanceof pt)return e;let t=e;if(typeof t.error==`string`){let e=t.error;return new pt(e.startsWith(`#`)?e.slice(1):e)}if(`formula`in t||`sharedFormula`in t){let e=t.result;return e==null?null:St(e)}return Array.isArray(t.richText)?t.richText.map(e=>e.text??``).join(``):typeof t.text==`string`&&typeof t.hyperlink==`string`?t.text:typeof t.checkbox==`boolean`?t.checkbox:String(e)}function Ct(e,t,n){let r=e.getRow(1).values,i=new Set(t),a=new Set(n),o=t=>{let n=e.getColumn(t).values,r=new Set,i=new Map,a=!1;for(let e=2;e<n.length;e++){let t=St(n[e]);t===null||typeof t==`number`&&isNaN(t)?a=!0:t instanceof pt?i.has(t.code)||(i.set(t.code,t),r.add(t)):r.add(t)}let o=Ne(r);return a&&o.push(null),o},s=t=>{let n=e.getColumn(t).values,r=1/0,i=-1/0,a=!1,o=!0;for(let e=2;e<n.length;e++){let t=St(n[e]);typeof t==`number`&&!isNaN(t)&&(a=!0,t<r&&(r=t),t>i&&(i=t),Number.isInteger(t)||(o=!1))}return a?{minValue:r,maxValue:i,allInteger:o}:null},c=[];for(let e of Me(1,r.length)){let t=r[e],n=String(t);if(i.has(n))c.push({name:n,sharedItems:o(e)});else if(a.has(n)){let t=s(e);c.push({name:n,sharedItems:null,containsNumber:t?`1`:void 0,minValue:t?.minValue,maxValue:t?.maxValue,containsInteger:t?.allInteger?`1`:void 0})}else c.push({name:n,sharedItems:null})}return c}let wt=(e,t)=>({...e,...t.reduce((t,n)=>(e[n]&&(t[n]={...e[n]}),t),{})}),P=(e,t,n,r=[])=>{e[n]&&(t[n]=wt(e[n],r))},Tt=e=>Object.keys(e).length===0,Et=e=>{if(!e)return e;if(Tt(e))return{};let t={...e};return P(e,t,`font`,[`color`]),P(e,t,`alignment`),P(e,t,`protection`),e.border&&(P(e,t,`border`),P(e.border,t.border,`top`,[`color`]),P(e.border,t.border,`left`,[`color`]),P(e.border,t.border,`bottom`,[`color`]),P(e.border,t.border,`right`,[`color`]),P(e.border,t.border,`diagonal`,[`color`])),e.fill&&(P(e,t,`fill`,[`fgColor`,`bgColor`,`center`]),e.fill.stops&&(t.fill.stops=e.fill.stops.map(e=>wt(e,[`color`])))),t};var Dt=class{constructor(e){e||={},this._workbook=e.workbook,this.id=e.id??0,this.orderNo=e.orderNo??0,this.name=e.name||`sheet${this.id}`,this.state=e.state??`visible`,this._rows=[],this._columns=null,this._keys={},this._merges={},this.rowBreaks=[],this.colBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,outlineLevelCol:0,outlineLevelRow:0},e.properties),this.pageSetup=Object.assign({},{margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:`portrait`,horizontalDpi:void 0,verticalDpi:void 0,fitToPage:!!(e.pageSetup&&(e.pageSetup.fitToWidth||e.pageSetup.fitToHeight)&&!e.pageSetup.scale),pageOrder:`downThenOver`,blackAndWhite:!1,draft:!1,cellComments:`None`,errors:`displayed`,scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,firstPageNumber:void 0,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},e.pageSetup),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},e.headerFooter),this.dataValidations=new me,this.views=e.views??[],this.autoFilter=e.autoFilter??null,this._media=[],this.sheetProtection=null,this.tables={},this.pivotTables=[],this.conditionalFormattings=[],this.formControls=[]}get name(){return this._name}set name(e){if(e===void 0&&(e=`sheet${this.id}`),this._name!==e){if(typeof e!=`string`)throw Error(`The name has to be a string.`);if(e===``)throw Error(`The name can't be empty.`);if(e===`History`)throw Error(`The name "History" is protected. Please use a different name.`);if(/[*?:/\\[\]]/.test(e))throw Error(`Worksheet name ${e} cannot include any of the following characters: * ? : \\ / [ ]`);if(/(^')|('$)/.test(e))throw Error(`The first or last character of worksheet name cannot be a single quotation mark: ${e}`);if(e&&e.length>31&&(e=e.substring(0,31)),this._workbook.worksheets.find(t=>t&&t.name.toLowerCase()===e.toLowerCase()))throw Error(`Worksheet name already exists: ${e}`);this._name=e}}get workbook(){return this._workbook}destroy(){this._workbook.removeWorksheetEx(this)}get dimensions(){let e=new r;return this._rows.forEach(t=>{if(t){let n=t.dimensions;n&&e.expand(t.number,n.min,t.number,n.max)}}),e}get columns(){return this._columns}set columns(e){this._headerRowCount=e.reduce((e,t)=>{let n=Array.isArray(t.header)?t.header.length:t.header?1:0;return Math.max(e,n)},0);let t=1,n=this._columns=[];e.forEach(e=>{let r=new O(this,t++,!1);n.push(r),r.defn=e})}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){Object.keys(this._keys).forEach(t=>e(this._keys[t],t))}getColumn(e){let t;if(typeof e==`string`){let r=this._keys[e];if(r)return r;t=n.l2n(e)}else t=e;if(this._columns||=[],t>this._columns.length){let e=this._columns.length+1;for(;e<=t;)this._columns.push(new O(this,e++))}return this._columns[t-1]}spliceColumns(e,t,...n){for(let e of Object.values(this._merges))for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++){let e=this.findCell(t,n);e&&e.type===u.ValueType.Merge&&e.unmerge()}let r=this._rows.length;if(n.length>0)for(let i=0;i<r;i++){let r=n.map(e=>e[i]??null);this.getRow(i+1).splice(e,t,...r)}else this._rows.forEach(n=>{n&&n.splice(e,t)});let i=n.length-t,a=e+t,o=this._columns?this._columns.length:0;if(i<0)for(let t=e+n.length;t<=o;t++)this.getColumn(t).defn=this.getColumn(t-i).defn;else if(i>0)for(let e=o;e>=a;e--)this.getColumn(e+i).defn=this.getColumn(e).defn;for(let t=e;t<e+n.length;t++)this.getColumn(t).defn=void 0;if(this.workbook.definedNames.spliceColumns(this.name,e,t,n.length),i!==0){for(let t of this._media)if(t.type===`image`&&t.range){let{tl:n,br:r}=t.range;n&&n.nativeCol>=e-1&&(n.nativeCol=Math.max(0,n.nativeCol+i)),r&&r.nativeCol>=e-1&&(r.nativeCol=Math.max(0,r.nativeCol+i))}}this._spliceMerges(`col`,e,t,n.length)}get lastColumn(){return this.getColumn(this.columnCount)}get columnCount(){let e=0;return this.eachRow(t=>{e=Math.max(e,t.cellCount)}),e}get actualColumnCount(){let e=[],t=0;return this.eachRow(n=>{n.eachCell(({col:n})=>{e[n]||(e[n]=!0,t++)})}),t}_commitRow(e){}get _lastRowNumber(){let e=this._rows,t=e.length;for(;t>0&&e[t-1]===void 0;)t--;return t}get _nextRow(){return this._lastRowNumber+1}get lastRow(){if(this._rows.length)return this._rows[this._rows.length-1]}findRow(e){return this._rows[e-1]}findRows(e,t){return this._rows.slice(e-1,e-1+t)}get rowCount(){return this._lastRowNumber}get actualRowCount(){let e=0;return this.eachRow(()=>{e++}),e}getRow(e){let t=this._rows[e-1];return t||=this._rows[e-1]=new ce(this,e),t}getRows(e,t){if(t<1)return;let n=[];for(let r=e;r<e+t;r++)n.push(this.getRow(r));return n}addRow(e,t=`n`){let n=this._nextRow,r=this.getRow(n);return r.values=e,this._setStyleOption(n,t[0]===`i`?t:`n`),r}addRows(e,t=`n`){let n=[];return e.forEach(e=>{n.push(this.addRow(e,t))}),n}insertRow(e,t,n=`n`){return this.spliceRows(e,0,t),this._setStyleOption(e,n),this.getRow(e)}insertRows(e,t,n=`n`){if(this.spliceRows(e,0,...t),n!==`n`)for(let r=0;r<t.length;r++)n[0]===`o`&&this.findRow(t.length+e+r)!==void 0?this._copyStyle(t.length+e+r,e+r,n[1]===`+`):n[0]===`i`&&this.findRow(e-1)!==void 0&&this._copyStyle(e-1,e+r,n[1]===`+`);return this.getRows(e,t.length)}_setStyleOption(e,t=`n`){t[0]===`o`&&this.findRow(e+1)!==void 0?this._copyStyle(e+1,e,t[1]===`+`):t[0]===`i`&&this.findRow(e-1)!==void 0&&this._copyStyle(e-1,e,t[1]===`+`)}_copyStyle(e,t,n=!1){let r=this.getRow(e),i=this.getRow(t);i.style=Et(r.style),r.eachCell({includeEmpty:n},(e,t)=>{i.getCell(t).style=Et(e.style)}),i.height=r.height}duplicateRow(e,t,n=!1){let r=this._rows[e-1],i=Array.from({length:t}).fill(r.values),a=[];for(let t of Object.values(this._merges))t.top===e&&t.bottom===e&&a.push(t);this.spliceRows(e+1,n?0:t,...i);for(let n=0;n<t;n++){let t=this._rows[e+n];t.style=r.style,t.height=r.height,r.eachCell({includeEmpty:!0},(e,n)=>{t.getCell(n).style=e.style})}if(a.length>0)for(let r=0;r<t;r++){let t=e+1+r;if(!n){let e=[];for(let[n,r]of Object.entries(this._merges))r.top<=t&&r.bottom>=t&&e.push(n);for(let t of e)this._unMergeMaster(this.getCell(t))}for(let e of a)this.mergeCellsWithoutStyle(t,e.left,t,e.right)}}spliceRows(e,t,...n){for(let e of Object.values(this._merges))for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++){let e=this.findCell(t,n);e&&e.type===u.ValueType.Merge&&e.unmerge()}let r=e+t,i=n.length,a=i-t,o=this._rows.length,s,c;if(a<0)for(e===o&&(this._rows[o-1]=void 0),s=r;s<=o;s++)if(c=this._rows[s-1],c){let e=this.getRow(s+a);e.values=c.values,e.style=c.style,e.height=c.height,c.eachCell({includeEmpty:!0},(t,n)=>{e.getCell(n).style=t.style}),this._rows[s-1]=void 0}else this._rows[s+a-1]=void 0;else if(a>0)for(s=o;s>=r;s--)if(c=this._rows[s-1],c){let e=this.getRow(s+a);e.values=c.values,e.style=c.style,e.height=c.height,c.eachCell({includeEmpty:!0},(t,n)=>{e.getCell(n).style=t.style})}else this._rows[s+a-1]=void 0;for(s=0;s<i;s++){let t=this.getRow(e+s);t.style={},t.values=n[s]}if(this.workbook.definedNames.spliceRows(this.name,e,t,i),a!==0){for(let t of this._media)if(t.type===`image`&&t.range){let{tl:n,br:r}=t.range;n&&n.nativeRow>=e-1&&(n.nativeRow=Math.max(0,n.nativeRow+a)),r&&r.nativeRow>=e-1&&(r.nativeRow=Math.max(0,r.nativeRow+a))}}this._spliceMerges(`row`,e,t,i)}eachRow(e,t){let n,r;if(typeof e==`function`?r=e:(n=e,r=t),n&&n.includeEmpty){let e=this._rows.length;for(let t=1;t<=e;t++)r(this.getRow(t),t)}else this._rows.forEach(e=>{e&&e.hasValues&&r(e,e.number)})}getSheetValues(){let e=[];return this._rows.forEach(t=>{t&&(e[t.number]=t.values)}),e}findCell(e,t){let r=n.getAddress(e,t),i=this._rows[r.row-1];return i?i.findCell(r.col):void 0}getCell(e,t){let r=n.getAddress(e,t);return this.getRow(r.row).getCellEx(r)}mergeCells(...e){let t=new r(e);this._mergeCellsInternal(t)}mergeCellsWithoutStyle(...e){let t=new r(e);this._mergeCellsInternal(t,!0)}_mergeCellsInternal(e,t){Object.values(this._merges).forEach(t=>{if(t.intersects(e))throw Error(`Cannot merge already merged cells`)});let n=this.getCell(e.top,e.left);for(let r=e.top;r<=e.bottom;r++)for(let i=e.left;i<=e.right;i++)(r>e.top||i>e.left)&&this.getCell(r,i).merge(n,t);this._merges[n.address]=e}_unMergeMaster(e){let t=this._merges[e.address];if(t){for(let e=t.top;e<=t.bottom;e++)for(let n=t.left;n<=t.right;n++)this.getCell(e,n).unmerge();delete this._merges[e.address]}}_spliceMerges(e,t,i,a){let o=a-i;if(o===0&&i===0)return;let s=t+i,c=e===`row`,l={};for(let e of Object.values(this._merges)){let{top:a,left:u,bottom:d,right:f}=e.model,p=c?a:u,m=c?d:f;if(o<=0&&i>0){let i=s-1;if(p>i){let e=c?new r(a+o,u,d+o,f):new r(a,u+o,d,f+o);l[n.encodeAddress(e.top,e.left)]=e}else if(m<t)l[n.encodeAddress(a,u)]=e;else if(!(p>=t&&m<=i)){let e=a,i=u,s=d,p=f;c?(e=a<t?a:t,s=Math.max(e,d+o)):(i=u<t?u:t,p=Math.max(i,f+o));let m=new r(e,i,s,p);e===s&&i===p||(l[n.encodeAddress(m.top,m.left)]=m)}}else if(p>=s){let e=c?new r(a+o,u,d+o,f):new r(a,u+o,d,f+o);l[n.encodeAddress(e.top,e.left)]=e}else m<s||(c?e.model.bottom=d+o:e.model.right=f+o),l[n.encodeAddress(a,u)]=e}this._merges=l;for(let e of Object.values(l)){let t=this.getCell(e.top,e.left);for(let n=e.top;n<=e.bottom;n++)for(let r=e.left;r<=e.right;r++)(n>e.top||r>e.left)&&this.getCell(n,r).merge(t,!0)}}get hasMerges(){return Object.values(this._merges).some(Boolean)}unMergeCells(...e){let t=new r(e);for(let e=t.top;e<=t.bottom;e++)for(let n=t.left;n<=t.right;n++){let t=this.findCell(e,n);t&&(t.type===u.ValueType.Merge?this._unMergeMaster(t.master):this._merges[t.address]&&this._unMergeMaster(t))}}fillFormula(e,t,r,i=`shared`){let{top:a,left:o,bottom:s,right:c}=n.decode(e),l=c-o+1,u=n.encodeAddress(a,o),d=i===`shared`,f;f=typeof r==`function`?r:Array.isArray(r)?Array.isArray(r[0])?(e,t)=>r[e-a][t-o]:(e,t)=>r[(e-a)*l+(t-o)]:()=>void 0;let p=!0;for(let n=a;n<=s;n++)for(let r=o;r<=c;r++)if(p){let a=this.getCell(n,r);a.value={shareType:i,formula:t,ref:e,result:f(n,r)},p=!1}else this.getCell(n,r).value=d?{sharedFormula:u,result:f(n,r)}:f(n,r)}addImage(e,t){let n={type:`image`,imageId:String(e),range:t};this._media.push(new de(this,n))}getImages(){return this._media.filter(e=>e.type===`image`)}addBackgroundImage(e){let t={type:`background`,imageId:String(e)};this._media.push(new de(this,t))}getBackgroundImageId(){let e=this._media.find(e=>e.type===`background`);return e&&e.imageId}addFormCheckbox(e,t){let n=new xe(this,e,t);return this.formControls.push(n),n}getFormCheckboxes(){return this.formControls}async protect(e,t){this.sheetProtection={sheet:!0},t&&`spinCount`in t&&(t.spinCount=Number.isFinite(t.spinCount)?Math.round(Math.max(0,t.spinCount)):1e5),e&&(this.sheetProtection.algorithmName=`SHA-512`,this.sheetProtection.saltValue=Re(ft.randomBytes(16)),this.sheetProtection.spinCount=t&&`spinCount`in t?t.spinCount:1e5,this.sheetProtection.hashValue=await ft.convertPasswordToHash(e,`SHA-512`,this.sheetProtection.saltValue,this.sheetProtection.spinCount)),t&&(this.sheetProtection=Object.assign(this.sheetProtection,t),!e&&`spinCount`in t&&delete this.sheetProtection.spinCount)}unprotect(){this.sheetProtection=null}addTable(e){let t=new pe(this,e);return this.tables[e.name]=t,t}getTable(e){return this.tables[e]}removeTable(e){delete this.tables[e]}getTables(){return Object.values(this.tables)}addPivotTable(e){let t=bt(this,e);return this.pivotTables.push(t),this.workbook.pivotTables.push(t),t}addConditionalFormatting(e){this.conditionalFormattings.push(e)}removeConditionalFormatting(e){typeof e==`number`?this.conditionalFormattings.splice(e,1):e instanceof Function?this.conditionalFormattings=this.conditionalFormattings.filter(e):this.conditionalFormattings=[]}get model(){let e={id:this.id,name:this.name,dataValidations:this.dataValidations.model,properties:this.properties,state:this.state,pageSetup:this.pageSetup,headerFooter:this.headerFooter,rowBreaks:this.rowBreaks,colBreaks:this.colBreaks,views:this.views,autoFilter:this.autoFilter,media:this._media.map(e=>e.model),sheetProtection:this.sheetProtection,tables:Object.values(this.tables).map(e=>e.model),pivotTables:this.pivotTables,conditionalFormattings:this.conditionalFormattings,formControls:this.formControls.map(e=>e.model),drawing:this._drawing};e.cols=O.toModel(this.columns??[]);let t=e.rows=[],n=e.dimensions=new r;return this._rows.forEach(e=>{let r=e&&e.model;r&&(n.expand(r.number,r.min,r.number,r.max),t.push(r))}),e.merges=[],Object.values(this._merges).forEach(t=>{e.merges.push(t.range)}),e}_parseRows(e){this._rows=[],e.rows&&e.rows.forEach(e=>{let t=new ce(this,e.number);this._rows[t.number-1]=t,t.model=e})}_parseMergeCells(e){e.mergeCells&&e.mergeCells.forEach(e=>{this.mergeCellsWithoutStyle(e)})}set model(e){this.name=e.name,this._columns=O.fromModel(this,e.cols),this._parseRows(e),this._parseMergeCells(e),this.dataValidations=new me(e.dataValidations),this.properties=e.properties,this.pageSetup=e.pageSetup,this.headerFooter=e.headerFooter,this.rowBreaks=e.rowBreaks??[],this.colBreaks=e.colBreaks??[],this.views=e.views,this.autoFilter=e.autoFilter,this._media=e.media.map(e=>new de(this,e)),this.sheetProtection=e.sheetProtection,this.tables=e.tables.reduce((e,t)=>{let n=new pe(this,t);return n.model=t,e[t.name]=n,e},{}),this.pivotTables=e.pivotTables,this.conditionalFormattings=e.conditionalFormattings,this.formControls=[],this._drawing=e.drawing}};function Ot(e){return typeof e==`number`?!0:e!==`__proto__`&&e!==`constructor`&&e!==`prototype`}function kt(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>kt(e));let t={};for(let n of Object.keys(e))Ot(n)&&(t[n]=kt(e[n]));return t}var At=class{constructor(e){this.template=e,this.sheets={}}addCell(e){this.addCellEx(n.decodeEx(e))}getCell(e){return this.findCellEx(n.decodeEx(e),!0)}findCell(e){return this.findCellEx(n.decodeEx(e),!1)}findCellAt(e,t,n){let r=this.sheets[e],i=r&&r[t];return i&&i[n]}addCellEx(e){if(e.top!==void 0)for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++)this.getCellAt(e.sheetName,t,n);else this.findCellEx(e,!0)}getCellEx(e){return this.findCellEx(e,!0)}findCellEx(e,t){let n=this.findSheet(e,t),r=this.findSheetRow(n,e,t);return this.findRowCell(r,e,t)}getCellAt(e,t,r){if(!Ot(e))throw Error(`Invalid sheet name: ${e}`);let i=this.sheets[e]||(this.sheets[e]=[]),a=i[t]||(i[t]=[]);return a[r]||(a[r]={sheetName:e,address:n.n2l(r)+t,row:t,col:r})}removeCellEx(e){let t=this.findSheet(e,!1);if(!t)return;let n=this.findSheetRow(t,e,!1);n&&delete n[e.col]}forEachInSheet(e,t){let n=this.sheets[e];n&&n.forEach((e,n)=>{e&&e.forEach((e,r)=>{e&&t(e,n,r)})})}forEach(e){Object.keys(this.sheets).forEach(t=>{this.forEachInSheet(t,e)})}map(e){let t=[];return this.forEach(n=>{t.push(e(n))}),t}findSheet(e,t){let n=e.sheetName;if(!Ot(n))throw Error(`Invalid sheet name: ${n}`);if(Object.prototype.hasOwnProperty.call(this.sheets,n))return this.sheets[n];if(t)return this.sheets[n]=[]}findSheetRow(e,t,n){let{row:r}=t;if(!Ot(r))throw Error(`Invalid row: ${r}`);if(e&&e[r])return e[r];if(n)return e[r]=[]}findRowCell(e,t,n){let{col:r}=t;if(!Ot(r))throw Error(`Invalid column: ${r}`);if(e&&e[r])return e[r];if(n)return e[r]=this.template?{...t,...kt(this.template)}:t}spliceRows(e,t,n,r){let i=this.sheets[e];if(i){let e=[];for(let t=0;t<r;t++)e.push([]);i.splice(t,n,...e)}}spliceColumns(e,t,n,r){let i=this.sheets[e];if(i){let e=[];for(let t=0;t<r;t++)e.push(null);Object.values(i).forEach(r=>{r.splice(t,n,...e)})}}};let jt=/[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;var Mt=class{constructor(){this.matrixMap={}}getMatrix(e){return this.matrixMap[e]||(this.matrixMap[e]=new At)}add(e,t){let r=n.decodeEx(e);`error`in r||this.addEx(r,t)}addEx(e,t){let r=this.getMatrix(t);if(`top`in e)for(let t=e.left;t<=e.right;t++)for(let i=e.top;i<=e.bottom;i++){let a={sheetName:e.sheetName,address:n.n2l(t)+i,row:i,col:t};r.addCellEx(a)}else r.addCellEx(e)}remove(e,t){let r=n.decodeEx(e);`error`in r||this.removeEx(r,t)}removeEx(e,t){let r=this.getMatrix(t);if(`top`in e)for(let t=e.left;t<=e.right;t++)for(let i=e.top;i<=e.bottom;i++)r.removeCellEx({sheetName:e.sheetName,address:n.n2l(t)+i,row:i,col:t});else r.removeCellEx(e)}removeAllNames(e){Object.values(this.matrixMap).forEach(t=>{if(`top`in e)for(let r=e.left;r<=e.right;r++)for(let i=e.top;i<=e.bottom;i++)t.removeCellEx({sheetName:e.sheetName,address:n.n2l(r)+i,row:i,col:r});else t.removeCellEx(e)})}forEach(e){Object.entries(this.matrixMap).forEach(([t,n])=>{n.forEach(n=>{e(t,n)})})}getNames(e){let t=n.decodeEx(e);return`error`in t||`top`in t?[]:this.getNamesEx(t)}getNamesEx(e){return Object.entries(this.matrixMap).map(([t,n])=>n.findCellEx(e,!1)&&t).filter(e=>!!e)}_explore(e,t){t.mark=!1;let{sheetName:n}=t,i=new r(t.row,t.col,t.row,t.col,n),a,o,s=(t,r)=>e.findCellAt(n,t,r);function c(e,n){let r=s(e,t.col);return!r||!r.mark?!1:(i[n]=e,r.mark=!1,!0)}for(o=t.row-1;c(o,`top`);o--);for(o=t.row+1;c(o,`bottom`);o++);function l(e,t){let n=[];for(o=i.top;o<=i.bottom;o++){let t=s(o,e);if(t&&t.mark)n.push(t);else return!1}i[t]=e;for(let e=0;e<n.length;e++)n[e].mark=!1;return!0}for(a=t.col-1;l(a,`left`);a--);for(a=t.col+1;l(a,`right`);a++);return i}getRanges(e,t){return t||=this.matrixMap[e],t?(t.forEach(e=>{e.mark=!0}),{name:e,ranges:t.map(e=>e.mark&&this._explore(t,e)).filter(Boolean).map(e=>e.$shortRange)}):{name:e,ranges:[]}}normaliseMatrix(e,t){e.forEachInSheet(t,(e,t,r)=>{e&&(e.row!==t||e.col!==r)&&(e.row=t,e.col=r,e.address=n.n2l(r)+t)})}spliceRows(e,t,n,r){Object.values(this.matrixMap).forEach(i=>{i.spliceRows(e,t,n,r),this.normaliseMatrix(i,e)})}spliceColumns(e,t,n,r){Object.values(this.matrixMap).forEach(i=>{i.spliceColumns(e,t,n,r),this.normaliseMatrix(i,e)})}get model(){return Object.entries(this.matrixMap).map(([e,t])=>this.getRanges(e,t)).filter(e=>e.ranges.length)}set model(e){let t=this.matrixMap={};e.forEach(e=>{let n=t[e.name]=new At;e.ranges.forEach(e=>{jt.test(e.split(`!`).pop()??``)&&n.addCell(e)})})}};let Nt=1e4;function Pt(e,t,n){e.push(` ${t}="${A(n.toString())}"`)}function Ft(e,t){if(t){let n=[];for(let e in t){if(!Object.prototype.hasOwnProperty.call(t,e))continue;let r=t[e];r!==void 0&&Pt(n,e,r)}e.push(n.join(``))}}var F=class{constructor(){this._xml=[],this._chunks=[],this._stack=[],this._rollbacks=[],this.leaf=!1,this.open=!1}_consolidate(){this._rollbacks.length>0||this._xml.length>=Nt&&(this._chunks.push(this._xml.join(``)),this._xml.length=0)}get tos(){return this._stack.length?this._stack[this._stack.length-1]:void 0}get cursor(){return this._chunks.length*Nt+this._xml.length}openXml(e){let t=this._xml;t.push(`<?xml`),Ft(t,e),t.push(`?>
7
+ var ExcelTS=(function(e){let t=/^[A-Z]+\d+$/,n={_dictionary:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``),_l2nFill:0,_l2n:{},_n2l:[],_level(e){return e<=26?1:e<=676?2:3},_fill(e){let t,n,r,i,a,o=1;if(e>=4)throw Error(`Out of bounds. Excel supports columns from 1 to 16384`);if(this._l2nFill<1&&e>=1){for(;o<=26;)t=this._dictionary[o-1],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=1}if(this._l2nFill<2&&e>=2){for(o=27;o<=702;)n=o-27,r=n%26,i=Math.floor(n/26),t=this._dictionary[i]+this._dictionary[r],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=2}if(this._l2nFill<3&&e>=3){for(o=703;o<=16384;)n=o-703,r=n%26,i=Math.floor(n/26)%26,a=Math.floor(n/676),t=this._dictionary[a]+this._dictionary[i]+this._dictionary[r],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=3}},l2n(e){if(this._l2n[e]||this._fill(e.length),!this._l2n[e])throw Error(`Out of bounds. Invalid column letter: ${e}`);return this._l2n[e]},n2l(e){if(e<1||e>16384)throw Error(`${e} is out of bounds. Excel supports columns from 1 to 16384`);return this._n2l[e]||this._fill(this._level(e)),this._n2l[e]},_hash:{},validateAddress(e){if(!t.test(e))throw Error(`Invalid Address: ${e}`);return!0},decodeAddress(e){let t=e.length<5&&this._hash[e];if(t)return t;let n=!1,r=``,i=0,a=!1,o=``,s=0;for(let t=0,c;t<e.length;t++)if(c=e.charCodeAt(t),!a&&c>=65&&c<=90)n=!0,r+=e[t],i=i*26+c-64;else if(c>=48&&c<=57)a=!0,o+=e[t],s=s*10+c-48;else if(a&&n&&c!==36)break;if(!n)i=void 0;else if(i>16384)throw Error(`Out of bounds. Invalid column letter: ${r}`);a||(s=void 0),e=r+o;let c={address:e,col:i,row:s,$col$row:`$${r}$${o}`};return i<=100&&s<=100&&(this._hash[e]=c,this._hash[c.$col$row]=c),c},getAddress(e,t){if(t){let n=this.n2l(t)+e;return this.decodeAddress(n)}return this.decodeAddress(e)},decode(e){let t=e.split(`:`);if(t.length===2){let e=this.decodeAddress(t[0]),n=this.decodeAddress(t[1]),r={top:Math.min(e.row,n.row),left:Math.min(e.col,n.col),bottom:Math.max(e.row,n.row),right:Math.max(e.col,n.col),tl:``,br:``,dimensions:``};return r.tl=this.n2l(r.left)+r.top,r.br=this.n2l(r.right)+r.bottom,r.dimensions=`${r.tl}:${r.br}`,r}return this.decodeAddress(e)},decodeEx(e){let t=e.match(/^(?:(?:(?:'((?:[^']|'')+?)')|([^'^ !]+?))!)?(.*)$/),n=t[1]||t[2],r=t[3],i=r.split(`:`);if(i.length>1){let e=this.decodeAddress(i[0]),t=this.decodeAddress(i[1]),r=Math.min(e.row,t.row),a=Math.min(e.col,t.col),o=Math.max(e.row,t.row),s=Math.max(e.col,t.col),c=this.n2l(a)+r,l=this.n2l(s)+o;return{top:r,left:a,bottom:o,right:s,sheetName:n,tl:{address:c,col:a,row:r,$col$row:`$${this.n2l(a)}$${r}`,sheetName:n},br:{address:l,col:s,row:o,$col$row:`$${this.n2l(s)}$${o}`,sheetName:n},dimensions:`${c}:${l}`}}if(r.indexOf(`#`)===0)return n?{sheetName:n,error:r}:{error:r};let a=this.decodeAddress(r);return n?{sheetName:n,...a}:a},encodeAddress(e,t){return n.n2l(t)+e},encode(...e){switch(e.length){case 2:return n.encodeAddress(e[0],e[1]);case 4:return`${n.encodeAddress(e[0],e[1])}:${n.encodeAddress(e[2],e[3])}`;default:throw Error(`Can only encode with 2 or 4 arguments`)}},inRange(e,t){let[n,r,,i,a]=e,[o,s]=t;return o>=n&&o<=i&&s>=r&&s<=a}};var r=class e{constructor(...e){this.model={top:0,left:0,bottom:0,right:0},this.decode(e)}setTLBR(e,t,r,i,a){if(typeof e==`string`&&typeof t==`string`){let i=n.decodeAddress(e),a=n.decodeAddress(t);this.model={top:Math.min(i.row,a.row),left:Math.min(i.col,a.col),bottom:Math.max(i.row,a.row),right:Math.max(i.col,a.col),sheetName:typeof r==`string`?r:void 0}}else typeof e==`number`&&typeof t==`number`&&typeof r==`number`&&typeof i==`number`&&(this.model={top:Math.min(e,r),left:Math.min(t,i),bottom:Math.max(e,r),right:Math.max(t,i),sheetName:a})}decode(t){switch(t.length){case 5:typeof t[0]==`number`&&typeof t[1]==`number`&&typeof t[2]==`number`&&typeof t[3]==`number`&&typeof t[4]==`string`&&this.setTLBR(t[0],t[1],t[2],t[3],t[4]);break;case 4:typeof t[0]==`number`&&typeof t[1]==`number`&&typeof t[2]==`number`&&typeof t[3]==`number`&&this.setTLBR(t[0],t[1],t[2],t[3]);break;case 3:typeof t[0]==`string`&&typeof t[1]==`string`&&typeof t[2]==`string`&&this.setTLBR(t[0],t[1],t[2]);break;case 2:typeof t[0]==`string`&&typeof t[1]==`string`&&this.setTLBR(t[0],t[1]);break;case 1:{let r=t[0];if(r instanceof e)this.model={top:r.model.top,left:r.model.left,bottom:r.model.bottom,right:r.model.right,sheetName:r.sheetName};else if(Array.isArray(r))this.decode(r);else if(typeof r==`object`&&`top`in r&&`left`in r&&`bottom`in r&&`right`in r)this.model={top:r.top,left:r.left,bottom:r.bottom,right:r.right,sheetName:r.sheetName};else if(typeof r==`string`){let e=n.decodeEx(r);`top`in e?this.model={top:e.top,left:e.left,bottom:e.bottom,right:e.right,sheetName:e.sheetName}:`row`in e&&(this.model={top:e.row,left:e.col,bottom:e.row,right:e.col,sheetName:e.sheetName})}break}case 0:this.model={top:0,left:0,bottom:0,right:0};break;default:throw Error(`Invalid number of arguments to _getDimensions() - ${t.length}`)}}get top(){return this.model.top||1}set top(e){this.model.top=e}get left(){return this.model.left||1}set left(e){this.model.left=e}get bottom(){return this.model.bottom||1}set bottom(e){this.model.bottom=e}get right(){return this.model.right||1}set right(e){this.model.right=e}get sheetName(){return this.model.sheetName}set sheetName(e){this.model.sheetName=e}get _serialisedSheetName(){let{sheetName:e}=this.model;return e?/^[a-zA-Z0-9]*$/.test(e)?`${e}!`:`'${e}'!`:``}expand(e,t,n,r){(!this.model.top||e<this.top)&&(this.top=e),(!this.model.left||t<this.left)&&(this.left=t),(!this.model.bottom||n>this.bottom)&&(this.bottom=n),(!this.model.right||r>this.right)&&(this.right=r)}expandRow(e){if(e){let{dimensions:t,number:n}=e;t&&this.expand(n,t.min,n,t.max)}}expandToAddress(e){let t=n.decodeEx(e);`row`in t&&`col`in t&&this.expand(t.row,t.col,t.row,t.col)}get tl(){return n.n2l(this.left)+this.top}get $t$l(){return`$${n.n2l(this.left)}$${this.top}`}get br(){return n.n2l(this.right)+this.bottom}get $b$r(){return`$${n.n2l(this.right)}$${this.bottom}`}get range(){return`${this._serialisedSheetName+this.tl}:${this.br}`}get $range(){return`${this._serialisedSheetName+this.$t$l}:${this.$b$r}`}get shortRange(){return this.count>1?this.range:this._serialisedSheetName+this.tl}get $shortRange(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}get count(){return(1+this.bottom-this.top)*(1+this.right-this.left)}toString(){return this.range}intersects(e){return!(e.sheetName&&this.sheetName&&e.sheetName!==this.sheetName||e.bottom<this.top||e.top>this.bottom||e.right<this.left||e.left>this.right)}contains(e){let t=n.decodeEx(e);return`row`in t&&`col`in t?this.containsEx(t):!1}containsEx(e){return e.sheetName&&this.sheetName&&e.sheetName!==this.sheetName?!1:e.row>=this.top&&e.row<=this.bottom&&e.col>=this.left&&e.col<=this.right}forEachAddress(e){for(let t=this.left;t<=this.right;t++)for(let r=this.top;r<=this.bottom;r++)e(n.encodeAddress(r,t),r,t)}};let i=function(e){return e[e.Null=0]=`Null`,e[e.Merge=1]=`Merge`,e[e.Number=2]=`Number`,e[e.String=3]=`String`,e[e.Date=4]=`Date`,e[e.Hyperlink=5]=`Hyperlink`,e[e.Formula=6]=`Formula`,e[e.SharedString=7]=`SharedString`,e[e.RichText=8]=`RichText`,e[e.Boolean=9]=`Boolean`,e[e.Error=10]=`Error`,e[e.JSON=11]=`JSON`,e[e.Checkbox=12]=`Checkbox`,e}({}),a=function(e){return e[e.None=0]=`None`,e[e.Master=1]=`Master`,e[e.Shared=2]=`Shared`,e}({}),o=function(e){return e[e.None=0]=`None`,e[e.OfficeDocument=1]=`OfficeDocument`,e[e.Worksheet=2]=`Worksheet`,e[e.CalcChain=3]=`CalcChain`,e[e.SharedStrings=4]=`SharedStrings`,e[e.Styles=5]=`Styles`,e[e.Theme=6]=`Theme`,e[e.Hyperlink=7]=`Hyperlink`,e}({}),s=function(e){return e[e.Xlsx=1]=`Xlsx`,e}({}),c=function(e){return e[e.LeftToRight=1]=`LeftToRight`,e[e.RightToLeft=2]=`RightToLeft`,e}({}),l={NotApplicable:`#N/A`,Ref:`#REF!`,Name:`#NAME?`,DivZero:`#DIV/0!`,Null:`#NULL!`,Value:`#VALUE!`,Num:`#NUM!`},u={ValueType:i,FormulaType:a,RelationshipType:o,DocumentType:s,ReadingOrder:c,ErrorValue:l},d={'"':`&quot;`,"&":`&amp;`,"<":`&lt;`,">":`&gt;`},f=/["&<>]/g;function p(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;let n=typeof e;if(n!==typeof t||n!==`object`)return!1;let r=Array.isArray(e);if(r!==Array.isArray(t))return!1;if(r){let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!p(e[r],t[r]))return!1;return!0}let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(let n=0,r=i.length;n<r;n++){let r=i[n];if(!Object.prototype.hasOwnProperty.call(t,r)||!p(e[r],t[r]))return!1}return!0}function m(e){return e.replace(f,e=>d[e])}function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function g(...e){let t=e[0]||{},n=e.length;for(let r=1;r<n;r++){let n=e[r];if(n)if(Array.isArray(n))for(let e=0,r=n.length;e<r;e++){let r=n[e];if(r===void 0)continue;let i=t[e];Array.isArray(r)?t[e]=g(Array.isArray(i)?i:[],r):h(r)?t[e]=g(h(i)?i:{},r):t[e]=r}else{let e=Object.keys(n);for(let r=0,i=e.length;r<i;r++){let i=e[r];if(i===`__proto__`||i===`constructor`||i===`prototype`)continue;let a=n[i];if(a===void 0)continue;let o=t[i];Array.isArray(a)?t[i]=g(Array.isArray(o)?o:[],a):h(a)?t[i]=g(h(o)?o:{},a):t[i]=a}}}return t}var _=class e{static{this.DEFAULT_CONFIGS={note:{margins:{insetmode:`auto`,inset:[.13,.13,.25,.25]},protection:{locked:`True`,lockText:`True`},editAs:`absolute`},type:`note`}}constructor(e){this.note=e}get model(){let t=null;switch(typeof this.note){case`string`:t={type:`note`,note:{texts:[{text:this.note}]}};break;default:t={type:`note`,note:this.note};break}return g({},e.DEFAULT_CONFIGS,t)}set model(e){let{note:t}=e,{texts:n}=t;n&&n.length===1&&Object.keys(n[0]).length===1?this.note=n[0].text:this.note=t}static fromModel(t){let n=new e;return n.model=t,n}};let v=/(([a-z_\-0-9]*)!)?([a-z0-9_$]{2,})([(])?/gi,y=/^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i;function b(e,t,r){let i=n.decode(t),a=n.decode(r);return e.replace(v,(e,t,r,o,s)=>{if(s)return e;let c=y.exec(o);if(c){let r=c[1],o=c[2].toUpperCase(),s=c[3],l=c[4];if(o.length>3||o.length===3&&o>`XFD`)return e;let u=n.l2n(o),d=parseInt(l,10);return r||(u+=a.col-i.col),s||(d+=a.row-i.row),(t??``)+(r??``)+n.n2l(u)+(s??``)+d}return e})}var x=class e{static{this.Types=u.ValueType}constructor(t,r,i){if(!t||!r)throw Error(`A Cell needs a Row`);this._row=t,this._column=r,n.validateAddress(i),this._address=i,this._value=D.create(e.Types.Null,this),this.style=this._mergeStyle(t.style,r.style,{}),this._mergeCount=0}get worksheet(){return this._row.worksheet}get workbook(){return this._row.worksheet.workbook}destroy(){delete this.style,delete this._value,delete this._row,delete this._column,delete this._address}get numFmt(){return this.style.numFmt}set numFmt(e){this.style.numFmt=e}get font(){return this.style.font}set font(e){this.style.font=e}get alignment(){return this.style.alignment}set alignment(e){this.style.alignment=e}get border(){return this.style.border}set border(e){this.style.border=e}get fill(){return this.style.fill}set fill(e){this.style.fill=e}get protection(){return this.style.protection}set protection(e){this.style.protection=e}_mergeStyle(e,t,n){let r=e&&e.numFmt||t&&t.numFmt;r&&(n.numFmt=r);let i=e&&e.font||t&&t.font;i&&(n.font=i);let a=e&&e.alignment||t&&t.alignment;a&&(n.alignment=a);let o=e&&e.border||t&&t.border;o&&(n.border=o);let s=e&&e.fill||t&&t.fill;s&&(n.fill=s);let c=e&&e.protection||t&&t.protection;return c&&(n.protection=c),n}get address(){return this._address}get row(){return this._row.number}get col(){return this._column.number}get $col$row(){return`$${this._column.letter}$${this.row}`}get type(){return this._value.type}get effectiveType(){return this._value.effectiveType}toCsvString(){return this._value.toCsvString()}addMergeRef(){this._mergeCount++}releaseMergeRef(){this._mergeCount--}get isMerged(){return this._mergeCount>0||this.type===e.Types.Merge}merge(t,n){this._value.release(),this._value=D.create(e.Types.Merge,this,t),n||(this.style=t.style)}unmerge(){this.type===e.Types.Merge&&(this._value.release(),this._value=D.create(e.Types.Null,this),this.style=this._mergeStyle(this._row.style,this._column.style,{...this.style}))}isMergedTo(t){return this._value.type===e.Types.Merge?this._value.isMergedTo(t):!1}get master(){return this.type===e.Types.Merge?this._value.master:this}get isHyperlink(){return this._value.type===e.Types.Hyperlink}get hyperlink(){return this._value.hyperlink}get value(){return this._value.value}set value(t){if(this.type===e.Types.Merge){this._value.master.value=t;return}this._value.release(),this._value=D.create(D.getType(t),this,t)}get note(){if(this._comment)return this._comment.note}set note(e){this._comment=new _(e)}get comment(){return this._comment}set comment(e){e===void 0?this._comment=void 0:e instanceof _?this._comment=e:this._comment=new _(e)}get text(){return this._value.toString()}get html(){return m(this.text)}toString(){return this.text}_upgradeToHyperlink(t){this.type===e.Types.String&&(this._value=D.create(e.Types.Hyperlink,this,{text:String(this._value.value),hyperlink:t}))}get formula(){return this._value.formula}get result(){return this._value.result}get formulaType(){return this._value.formulaType}get fullAddress(){let{worksheet:e}=this._row;return{sheetName:e.name,address:this.address,row:this.row,col:this.col}}get name(){return this.names[0]}set name(e){this.names=[e]}get names(){return this.workbook.definedNames.getNamesEx(this.fullAddress)}set names(e){let{definedNames:t}=this.workbook;t.removeAllNames(this.fullAddress),e.forEach(e=>{t.addEx(this.fullAddress,e)})}addName(e){this.workbook.definedNames.addEx(this.fullAddress,e)}removeName(e){this.workbook.definedNames.removeEx(this.fullAddress,e)}removeAllNames(){this.workbook.definedNames.removeAllNames(this.fullAddress)}get _dataValidations(){return this.worksheet.dataValidations}get dataValidation(){return this._dataValidations.find(this.address)}set dataValidation(e){this._dataValidations.add(this.address,e)}get model(){let{model:e}=this._value;return e.style=this.style,this._comment&&(e.comment=this._comment.model),e}set model(e){if(this._value.release(),this._value=D.create(e.type,this),this._value.model=e,e.comment)switch(e.comment.type){case`note`:this._comment=_.fromModel(e.comment);break}e.style?this.style=e.style:this.style={}}},ee=class{constructor(e){this.model={address:e.address,type:x.Types.Null}}get value(){return null}set value(e){}get type(){return x.Types.Null}get effectiveType(){return x.Types.Null}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return``}release(){}toString(){return``}},S=class{constructor(e,t){this.model={address:e.address,type:x.Types.Number,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.Number}get effectiveType(){return x.Types.Number}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}},te=class{constructor(e,t){this.model={address:e.address,type:x.Types.String,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.String}get effectiveType(){return x.Types.String}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return`"${this.model.value.replace(/"/g,`""`)}"`}release(){}toString(){return this.model.value}},ne=class{constructor(e,t){this.model={address:e.address,type:x.Types.String,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}toString(){return this.model.value.richText.map(e=>e.text).join(``)}get type(){return x.Types.RichText}get effectiveType(){return x.Types.RichText}get address(){return this.model.address}set address(e){this.model.address=e}get text(){return this.toString()}toCsvString(){return`"${this.text.replace(/"/g,`""`)}"`}release(){}},C=class{constructor(e,t){this.model={address:e.address,type:x.Types.Date,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.Date}get effectiveType(){return x.Types.Date}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toISOString()}release(){}toString(){return this.model.value.toString()}},w=class{constructor(e,t){this.model={address:e.address,type:x.Types.Hyperlink,text:t?t.text:void 0,hyperlink:t?t.hyperlink:void 0},t&&t.tooltip&&(this.model.tooltip=t.tooltip)}get value(){return{text:this.model.text??``,hyperlink:this.model.hyperlink??``,tooltip:this.model.tooltip}}set value(e){this.model.text=e.text,this.model.hyperlink=e.hyperlink,e.tooltip&&(this.model.tooltip=e.tooltip)}get text(){return this.model.text}set text(e){this.model.text=e}get hyperlink(){return this.model.hyperlink}set hyperlink(e){this.model.hyperlink=e}get type(){return x.Types.Hyperlink}get effectiveType(){return x.Types.Hyperlink}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.hyperlink??``}release(){}toString(){return this.model.text??``}},re=class{constructor(e,t){this.model={address:e.address,type:x.Types.Merge,master:t?t.address:void 0},this._master=t,t&&t.addMergeRef()}get value(){return this._master.value}set value(e){e instanceof x?(this._master&&this._master.releaseMergeRef(),e.addMergeRef(),this._master=e):this._master.value=e}isMergedTo(e){return e===this._master}get master(){return this._master}get type(){return x.Types.Merge}get effectiveType(){return this._master.effectiveType}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return``}release(){this._master.releaseMergeRef()}toString(){return this.value.toString()}},T=class{constructor(e,t){this.cell=e,this.model={address:e.address,type:x.Types.Formula,shareType:t?t.shareType:void 0,ref:t?t.ref:void 0,formula:t?t.formula:void 0,sharedFormula:t?t.sharedFormula:void 0,result:t?t.result:void 0}}_copyModel(e){let t={};return e.formula&&(t.formula=e.formula),e.result!==void 0&&(t.result=e.result),e.ref&&(t.ref=e.ref),e.shareType&&(t.shareType=e.shareType),e.sharedFormula&&(t.sharedFormula=e.sharedFormula),t}get value(){return this._copyModel(this.model)}set value(e){e.formula&&(this.model.formula=e.formula),e.result!==void 0&&(this.model.result=e.result),e.ref&&(this.model.ref=e.ref),e.shareType&&(this.model.shareType=e.shareType),e.sharedFormula&&(this.model.sharedFormula=e.sharedFormula)}validate(e){switch(D.getType(e)){case x.Types.Null:case x.Types.String:case x.Types.Number:case x.Types.Date:break;case x.Types.Hyperlink:case x.Types.Formula:default:throw Error(`Cannot process that type of result value`)}}get dependencies(){return{ranges:this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),cells:this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g,``).match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g)}}get formula(){return this.model.formula||this._getTranslatedFormula()||``}set formula(e){this.model.formula=e}get formulaType(){return this.model.formula?u.FormulaType.Master:this.model.sharedFormula?u.FormulaType.Shared:u.FormulaType.None}get result(){return this.model.result}set result(e){this.model.result=e}get type(){return x.Types.Formula}get effectiveType(){let e=this.model.result;return e==null?u.ValueType.Null:e instanceof String||typeof e==`string`?u.ValueType.String:typeof e==`number`?u.ValueType.Number:e instanceof Date?u.ValueType.Date:typeof e==`object`&&`error`in e?u.ValueType.Error:u.ValueType.Null}get address(){return this.model.address}set address(e){this.model.address=e}_getTranslatedFormula(){if(!this._translatedFormula&&this.model.sharedFormula){let{worksheet:e}=this.cell,t=e.findCell(this.model.sharedFormula);this._translatedFormula=t&&b(t.formula,t.address,this.model.address)}return this._translatedFormula}toCsvString(){return`${this.model.result??``}`}release(){}toString(){return this.model.result?this.model.result.toString():``}},ie=class{constructor(e,t){this.model={address:e.address,type:x.Types.SharedString,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.SharedString}get effectiveType(){return x.Types.SharedString}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}},ae=class{constructor(e,t){this.model={address:e.address,type:x.Types.Boolean,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.Boolean}get effectiveType(){return x.Types.Boolean}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}},oe=class{constructor(e,t){this.model={address:e.address,type:x.Types.Checkbox,value:t.checkbox}}get value(){return{checkbox:this.model.value}}set value(e){this.model.value=e.checkbox}get type(){return x.Types.Checkbox}get effectiveType(){return x.Types.Boolean}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}},E=class{constructor(e,t){this.model={address:e.address,type:x.Types.Error,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return x.Types.Error}get effectiveType(){return x.Types.Error}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.toString()}release(){}toString(){return this.model.value.error.toString()}},se=class{constructor(e,t){this.model={address:e.address,type:x.Types.String,value:JSON.stringify(t),rawValue:t}}get value(){return this.model.rawValue}set value(e){this.model.rawValue=e,this.model.value=JSON.stringify(e)}get type(){return x.Types.String}get effectiveType(){return x.Types.String}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value}release(){}toString(){return this.model.value}};let D={getType(e){if(e==null)return x.Types.Null;if(e instanceof String||typeof e==`string`)return x.Types.String;if(typeof e==`number`)return x.Types.Number;if(typeof e==`boolean`)return x.Types.Boolean;if(e instanceof Date)return x.Types.Date;if(typeof e==`object`){if(`checkbox`in e&&typeof e.checkbox==`boolean`)return x.Types.Checkbox;if(`text`in e&&e.text&&`hyperlink`in e&&e.hyperlink)return x.Types.Hyperlink;if(`formula`in e&&e.formula||`sharedFormula`in e&&e.sharedFormula)return x.Types.Formula;if(`richText`in e&&e.richText)return x.Types.RichText;if(`sharedString`in e&&e.sharedString)return x.Types.SharedString;if(`error`in e&&e.error)return x.Types.Error}return x.Types.JSON},types:[{t:x.Types.Null,f:ee},{t:x.Types.Number,f:S},{t:x.Types.String,f:te},{t:x.Types.Date,f:C},{t:x.Types.Hyperlink,f:w},{t:x.Types.Formula,f:T},{t:x.Types.Merge,f:re},{t:x.Types.JSON,f:se},{t:x.Types.SharedString,f:ie},{t:x.Types.RichText,f:ne},{t:x.Types.Boolean,f:ae},{t:x.Types.Error,f:E},{t:x.Types.Checkbox,f:oe}].reduce((e,t)=>(e[t.t]=t.f,e),[]),create(e,t,n){let r=this.types[e];if(!r)throw Error(`Could not create Value of type ${e}`);return new r(t,n)}};var ce=class{constructor(e,t){this._worksheet=e,this._number=t,this._cells=[],this.style={},this.outlineLevel=0}get number(){return this._number}get worksheet(){return this._worksheet}commit(){this._worksheet._commitRow(this)}destroy(){delete this._worksheet,delete this._cells,delete this.style}findCell(e){return this._cells[e-1]}getCellEx(e){let t=this._cells[e.col-1];if(!t){let n=this._worksheet.getColumn(e.col);t=new x(this,n,e.address),this._cells[e.col-1]=t}return t}getCell(e){let t;if(typeof e==`string`){let r=this._worksheet.getColumnKey(e);t=r?r.number:n.l2n(e)}else t=e;return this._cells[t-1]||this.getCellEx({address:n.encodeAddress(this._number,t),row:this._number,col:t})}splice(e,t,...n){let r=e+t,i=n.length-t,a=this._cells.length,o,s,c;if(i<0)for(o=e+n.length;o<=a;o++)c=this._cells[o-1],s=this._cells[o-i-1],s?(c=this.getCell(o),c.value=s.value,c.style=s.style,c.comment=s.comment):c&&(c.value=null,c.style={},c.comment=void 0);else if(i>0)for(o=a;o>=r;o--)s=this._cells[o-1],s?(c=this.getCell(o+i),c.value=s.value,c.style=s.style,c.comment=s.comment):this._cells[o+i-1]=void 0;for(o=0;o<n.length;o++)c=this.getCell(e+o),c.value=n[o],c.style={},c.comment=void 0}eachCell(e,t){let n=null,r;if(typeof e==`function`?r=e:(n=e,r=t),n&&n.includeEmpty){let e=this._cells.length;for(let t=1;t<=e;t++)r(this.getCell(t),t)}else this._cells.forEach((e,t)=>{e&&e.type!==u.ValueType.Null&&r(e,t+1)})}addPageBreak(e,t){let n=this._worksheet,r=Math.max(0,(e??0)-1)||0,i=Math.max(0,(t??0)-1)||16838,a={id:this._number,max:i,man:1};r&&(a.min=r),n.rowBreaks.push(a)}get values(){let e=[];return this._cells.forEach(t=>{t&&t.type!==u.ValueType.Null&&(e[t.col]=t.value)}),e}set values(e){if(this._cells=[],e)if(e instanceof Array){let t=0;Object.prototype.hasOwnProperty.call(e,`0`)&&(t=1),e.forEach((e,r)=>{e!==void 0&&(this.getCellEx({address:n.encodeAddress(this._number,r+t),row:this._number,col:r+t}).value=e)})}else this._worksheet.eachColumnKey((t,r)=>{e[r]!==void 0&&(this.getCellEx({address:n.encodeAddress(this._number,t.number),row:this._number,col:t.number}).value=e[r])})}getValues(){let e=[];return this._cells.forEach(t=>{t&&t.type!==u.ValueType.Null&&(e[t.col-1]=t.value)}),e}valuesToString(e=`,`){return this.getValues().join(e)}get hasValues(){return this._cells.some(e=>e&&e.type!==u.ValueType.Null)}get cellCount(){return this._cells.length}get actualCellCount(){let e=0;return this.eachCell(()=>{e++}),e}get dimensions(){let e=0,t=0;return this._cells.forEach(n=>{n&&n.type!==u.ValueType.Null&&((!e||e>n.col)&&(e=n.col),t<n.col&&(t=n.col))}),e>0?{min:e,max:t}:null}_applyStyle(e,t){this.style[e]=t,this._cells.forEach(n=>{n&&(n.style[e]=t)})}get numFmt(){return this.style.numFmt}set numFmt(e){e!==void 0&&this._applyStyle(`numFmt`,e)}get font(){return this.style.font}set font(e){e!==void 0&&this._applyStyle(`font`,e)}get alignment(){return this.style.alignment}set alignment(e){e!==void 0&&this._applyStyle(`alignment`,e)}get protection(){return this.style.protection}set protection(e){e!==void 0&&this._applyStyle(`protection`,e)}get border(){return this.style.border}set border(e){e!==void 0&&this._applyStyle(`border`,e)}get fill(){return this.style.fill}set fill(e){e!==void 0&&this._applyStyle(`fill`,e)}get hidden(){return!!this._hidden}set hidden(e){this._hidden=e}get outlineLevel(){return this._outlineLevel??0}set outlineLevel(e){this._outlineLevel=e}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelRow)}get model(){let e=[],t=0,n=0;return this._cells.forEach(r=>{if(r){let i=r.model;i&&((!t||t>r.col)&&(t=r.col),n<r.col&&(n=r.col),e.push(i))}}),this.height||e.length?{cells:e,number:this.number,min:t,max:n,height:this.height,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,collapsed:this.collapsed,dyDescent:this.dyDescent}:null}set model(e){if(e.number!==this._number)throw Error(`Invalid row number in model`);this._cells=[];let t;e.cells.forEach(e=>{switch(e.type){case x.Types.Merge:break;default:{let r;if(e.address)r=n.decodeAddress(e.address);else if(t){let{row:e}=t,i=t.col+1;r={row:e,col:i,address:n.encodeAddress(e,i),$col$row:`$${n.n2l(i)}$${e}`}}t=r;let i=this.getCellEx(r);i.model=e;break}}}),e.height?this.height=e.height:delete this.height,this.hidden=e.hidden,this.outlineLevel=e.outlineLevel??0,this.dyDescent=e.dyDescent,this.style=e.style&&JSON.parse(JSON.stringify(e.style))||{}}},O=class e{constructor(e,t,n){this._worksheet=e,this._number=t,n!==!1&&(this.defn=n)}get number(){return this._number}get worksheet(){return this._worksheet}get letter(){return n.n2l(this._number)}get isCustomWidth(){return this.width!==void 0&&this.width!==9}get defn(){return{header:this._header,key:this.key,width:this.width,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,bestFit:this.bestFit}}set defn(e){e?(this.key=e.key,this.width=e.width===void 0?9:e.width,this.outlineLevel=e.outlineLevel,e.style?this.style=e.style:this.style={},this.header=e.header,this._hidden=!!e.hidden,this.bestFit=e.bestFit):(delete this._header,delete this._key,delete this.width,this.style={},this.outlineLevel=0,delete this.bestFit)}get headers(){return Array.isArray(this._header)?this._header:this._header===void 0?[]:[this._header]}get header(){return this._header}set header(e){e===void 0?this._header=void 0:(this._header=e,this.headers.forEach((e,t)=>{this._worksheet.getCell(t+1,this.number).value=e}))}get key(){return this._key}set key(e){(this._key&&this._worksheet.getColumnKey(this._key))===this&&this._worksheet.deleteColumnKey(this._key),this._key=e,e&&this._worksheet.setColumnKey(this._key,this)}get hidden(){return!!this._hidden}set hidden(e){this._hidden=e}get outlineLevel(){return this._outlineLevel??0}set outlineLevel(e){this._outlineLevel=e}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelCol)}toString(){return JSON.stringify({key:this.key,width:this.width,headers:this.headers.length?this.headers:void 0})}equivalentTo(e){return this.width===e.width&&this.hidden===e.hidden&&this.outlineLevel===e.outlineLevel&&p(this.style,e.style)}equivalentToModel(e){return this.width===e.width&&this.hidden===e.hidden&&this.outlineLevel===e.outlineLevel&&this.bestFit===e.bestFit&&p(this.style,e.style)}get isDefault(){if(this.isCustomWidth||this.hidden||this.outlineLevel||this.bestFit)return!1;let e=this.style;return!(e&&(e.font||e.numFmt||e.alignment||e.border||e.fill||e.protection))}get headerCount(){return this.headers.length}eachCell(e,t){let n=this.number,r,i;typeof e==`function`?(r={},i=e):(r=e,i=t),this._worksheet.eachRow(r,(e,t)=>{i(e.getCell(n),t)})}get values(){let e=[];return this.eachCell((t,n)=>{t&&t.type!==u.ValueType.Null&&(e[n]=t.value)}),e}set values(e){if(!e)return;let t=this.number,n=0;Object.prototype.hasOwnProperty.call(e,`0`)&&(n=1),e.forEach((e,r)=>{this._worksheet.getCell(r+n,t).value=e})}addPageBreak(e,t){let n=this._worksheet,r=Math.max(0,(e??0)-1)||0,i=Math.max(0,(t??0)-1)||1048575,a={id:this._number,max:i,man:1};r&&(a.min=r),n.colBreaks.push(a)}get numFmt(){return this.style.numFmt}set numFmt(e){this.style.numFmt=e,this.eachCell(t=>{t.numFmt=e})}get font(){return this.style.font}set font(e){this.style.font=e,this.eachCell(t=>{t.font=e})}get alignment(){return this.style.alignment}set alignment(e){this.style.alignment=e,this.eachCell(t=>{t.alignment=e})}get protection(){return this.style.protection}set protection(e){this.style.protection=e,this.eachCell(t=>{t.protection=e})}get border(){return this.style.border}set border(e){this.style.border=e,this.eachCell(t=>{t.border=e})}get fill(){return this.style.fill}set fill(e){this.style.fill=e,this.eachCell(t=>{t.fill=e})}static toModel(e){let t=[],n=null;return e&&e.forEach((e,r)=>{e.isDefault?n&&=null:!n||!e.equivalentToModel(n)?(n={min:r+1,max:r+1,width:e.width===void 0?9:e.width,style:e.style,isCustomWidth:e.isCustomWidth,hidden:e.hidden,outlineLevel:e.outlineLevel,collapsed:e.collapsed,bestFit:e.bestFit},t.push(n)):n.max=r+1}),t.length?t:void 0}static fromModel(t,n){let r=t,i=Array.isArray(t)?t:n??[];i??=[];let a=[],o=1,s=0;for(i=i.sort(function(e,t){return e.min-t.min});s<i.length;){let t=i[s++];for(;o<t.min;)a.push(new e(r,o++));for(;o<=t.max;)a.push(new e(r,o++,t))}return a.length?a:null}};function le(e){return typeof e==`object`&&`nativeCol`in e&&`nativeRow`in e&&`nativeColOff`in e&&`nativeRowOff`in e}function ue(e){return typeof e==`object`&&`col`in e&&`row`in e}var k=class e{constructor(e,t,r=0){if(this.worksheet=e,!t)this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0;else if(typeof t==`string`){let e=n.decodeAddress(t);this.nativeCol=e.col+r,this.nativeColOff=0,this.nativeRow=e.row+r,this.nativeRowOff=0}else le(t)?(this.nativeCol=t.nativeCol??0,this.nativeColOff=t.nativeColOff??0,this.nativeRow=t.nativeRow??0,this.nativeRowOff=t.nativeRowOff??0):ue(t)?(this.col=t.col+r,this.row=t.row+r):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0)}static asInstance(t){return t==null?null:t instanceof e?t:new e(void 0,t)}get col(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth}set col(e){this.nativeCol=Math.floor(e),this.nativeColOff=Math.floor((e-this.nativeCol)*this.colWidth)}get row(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight}set row(e){this.nativeRow=Math.floor(e),this.nativeRowOff=Math.floor((e-this.nativeRow)*this.rowHeight)}get colWidth(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(this.worksheet.getColumn(this.nativeCol+1).width*1e4):64e4}get rowHeight(){return this.worksheet&&this.worksheet.getRow(this.nativeRow+1)&&this.worksheet.getRow(this.nativeRow+1).height?Math.floor(this.worksheet.getRow(this.nativeRow+1).height*1e4):18e4}get model(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}}set model(e){this.nativeCol=e.nativeCol,this.nativeColOff=e.nativeColOff,this.nativeRow=e.nativeRow,this.nativeRowOff=e.nativeRowOff}clone(t){return new e(t??this.worksheet,this.model)}},de=class e{constructor(e,t){this.worksheet=e,t&&(this.model=t)}get model(){switch(this.type){case`background`:return{type:this.type,imageId:this.imageId};case`image`:return{type:this.type,imageId:this.imageId,hyperlinks:this.range.hyperlinks,range:{tl:this.range.tl.model,br:this.range.br&&this.range.br.model,ext:this.range.ext,editAs:this.range.editAs}};default:throw Error(`Invalid Image Type`)}}set model({type:e,imageId:t,range:r,hyperlinks:i}){if(this.type=e,this.imageId=t,e===`image`)if(typeof r==`string`){let e=n.decode(r);`top`in e&&(this.range={tl:new k(this.worksheet,{col:e.left,row:e.top},-1),br:new k(this.worksheet,{col:e.right,row:e.bottom},0),editAs:`oneCell`})}else r&&(this.range={tl:new k(this.worksheet,r.tl,0),br:r.br?new k(this.worksheet,r.br,0):void 0,ext:r.ext,editAs:r.editAs,hyperlinks:i||(`hyperlinks`in r?r.hyperlinks:void 0)})}clone(t){let n=t??this.worksheet,r=new e(n);return r.type=this.type,r.imageId=this.imageId,this.range&&(r.range={tl:this.range.tl.clone(n),br:this.range.br?this.range.br.clone(n):void 0,ext:this.range.ext?{...this.range.ext}:void 0,editAs:this.range.editAs,hyperlinks:this.range.hyperlinks?{...this.range.hyperlinks}:void 0}),r}},fe=class{constructor(e,t,n){this.table=e,this.column=t,this.index=n}_set(e,t){this.table.cacheState(),this.column[e]=t}get name(){return this.column.name}set name(e){this._set(`name`,e)}get filterButton(){return this.column.filterButton}set filterButton(e){this.column.filterButton=e}get style(){return this.column.style}set style(e){this.column.style=e}get totalsRowLabel(){return this.column.totalsRowLabel}set totalsRowLabel(e){this._set(`totalsRowLabel`,e)}get totalsRowFunction(){return this.column.totalsRowFunction}set totalsRowFunction(e){this._set(`totalsRowFunction`,e)}get totalsRowResult(){return this.column.totalsRowResult}set totalsRowResult(e){this._set(`totalsRowResult`,e)}get totalsRowFormula(){return this.column.totalsRowFormula}set totalsRowFormula(e){this._set(`totalsRowFormula`,e)}},pe=class{constructor(e,t){if(this.worksheet=e,t){if(this.table=t,Array.isArray(t.rows)&&t.rows.length===0&&t.tableRef){let r=n.decode(t.tableRef);if(`dimensions`in r){let n=r.top+(t.headerRow===!1?0:1),i=r.bottom-(t.totalsRow===!0?1:0);if(i>=n)for(let a=n;a<=i;a++){let n=e.getRow(a),i=[];for(let e=r.left;e<=r.right;e++)i.push(n.getCell(e).value);t.rows.push(i)}}}this.validate(),this.store()}}getFormula(e){switch(e.totalsRowFunction){case`none`:return null;case`average`:return`SUBTOTAL(101,${this.table.name}[${e.name}])`;case`countNums`:return`SUBTOTAL(102,${this.table.name}[${e.name}])`;case`count`:return`SUBTOTAL(103,${this.table.name}[${e.name}])`;case`max`:return`SUBTOTAL(104,${this.table.name}[${e.name}])`;case`min`:return`SUBTOTAL(105,${this.table.name}[${e.name}])`;case`stdDev`:return`SUBTOTAL(106,${this.table.name}[${e.name}])`;case`var`:return`SUBTOTAL(107,${this.table.name}[${e.name}])`;case`sum`:return`SUBTOTAL(109,${this.table.name}[${e.name}])`;case`custom`:return e.totalsRowFormula??null;default:throw Error(`Invalid Totals Row Function: ${e.totalsRowFunction}`)}}get width(){return this.table.columns.length}get height(){return this.table.rows.length}get filterHeight(){return this.height+(this.table.headerRow?1:0)}get tableHeight(){return this.filterHeight+(this.table.totalsRow?1:0)}validate(){let{table:e}=this,t=(e,t,n)=>{e[t]===void 0&&(e[t]=n)};t(e,`headerRow`,!0),t(e,`totalsRow`,!1),t(e,`style`,{}),t(e.style,`theme`,`TableStyleMedium2`),t(e.style,`showFirstColumn`,!1),t(e.style,`showLastColumn`,!1),t(e.style,`showRowStripes`,!1),t(e.style,`showColumnStripes`,!1);let r=(e,t)=>{if(!e)throw Error(t)};r(!!e.ref,`Table must have ref`),r(!!e.columns,`Table must have column definitions`),r(!!e.rows,`Table must have row definitions`),e.tl=n.decodeAddress(e.ref);let{row:i,col:a}=e.tl;r(i>0,`Table must be on valid row`),r(a>0,`Table must be on valid col`);let{width:o,tableHeight:s}=this;e.autoFilterRef=n.encode(i,a,i,a+o-1),e.tableRef=n.encode(i,a,i+s-1,a+o-1),e.columns.forEach((e,n)=>{r(!!e.name,`Column ${n} must have a name`),n===0?t(e,`totalsRowLabel`,`Total`):(t(e,`totalsRowFunction`,`none`),e.totalsRowFormula=this.getFormula(e)??void 0)})}store(){let e=(e,t)=>{t&&Object.assign(e.style,t)},{worksheet:t,table:n}=this,{row:r,col:i}=n.tl,a=0;if(n.headerRow){let o=t.getRow(r+ a++);n.columns.forEach((t,n)=>{let{style:r,name:a}=t,s=o.getCell(i+n);s.value=a,e(s,r)})}if(n.rows.forEach(o=>{let s=t.getRow(r+ a++);o.forEach((t,r)=>{let a=s.getCell(i+r),o=t?.formula;if(typeof o==`string`){let e=n.qualifyImplicitStructuredReferences===!0;a.value={...t,formula:e?o.replace(/(^|[^A-Za-z0-9_])\[@\[?([^\[\]]+?)\]?\]/g,`$1${n.name}[[#This Row],[$2]]`):o}}else a.value=t;e(a,n.columns[r].style)})}),n.totalsRow){let o=t.getRow(r+ a++);n.columns.forEach((t,n)=>{let r=o.getCell(i+n);n===0?r.value=t.totalsRowLabel:this.getFormula(t)?r.value={formula:t.totalsRowFormula,result:t.totalsRowResult}:r.value=null,e(r,t.style)})}}load(e){let{table:t}=this,{row:n,col:r}=t.tl,i=0;if(t.headerRow){let a=e.getRow(n+ i++);t.columns.forEach((e,t)=>{let n=a.getCell(r+t);n.value=e.name})}if(t.rows.forEach(t=>{let a=e.getRow(n+ i++);t.forEach((e,t)=>{let n=a.getCell(r+t);n.value=e})}),t.totalsRow){let a=e.getRow(n+ i++);t.columns.forEach((e,t)=>{let n=a.getCell(r+t);t===0?n.value=e.totalsRowLabel:this.getFormula(e)&&(n.value={formula:e.totalsRowFormula,result:e.totalsRowResult})})}}get model(){return this.table}set model(e){this.table=e}cacheState(){this._cache||={ref:this.ref,width:this.width,tableHeight:this.tableHeight}}commit(){if(!this._cache)return;this.validate();let e=n.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(let t=0;t<this._cache.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=0;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}else{for(let t=this.tableHeight;t<this._cache.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=0;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}for(let t=0;t<this.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=this.width;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}}this.store(),this._cache=void 0}addRow(e,t,n){this.cacheState(),t===void 0?this.table.rows.push(e):this.table.rows.splice(t,0,e),n?.commit!==!1&&this.commit()}removeRows(e,t=1,n){this.cacheState(),this.table.rows.splice(e,t),n?.commit!==!1&&this.commit()}getColumn(e){let t=this.table.columns[e];return new fe(this,t,e)}addColumn(e,t,n){this.cacheState(),n===void 0?(this.table.columns.push(e),this.table.rows.forEach((e,n)=>{e.push(t[n])})):(this.table.columns.splice(n,0,e),this.table.rows.forEach((e,r)=>{e.splice(n,0,t[r])}))}removeColumns(e,t=1){this.cacheState(),this.table.columns.splice(e,t),this.table.rows.forEach(n=>{n.splice(e,t)})}_assign(e,t,n){this.cacheState(),e[t]=n}get ref(){return this.table.ref}set ref(e){this._assign(this.table,`ref`,e)}get name(){return this.table.name}set name(e){this.table.name=e}get displayName(){return this.table.displayName||this.table.name}set displayName(e){this.table.displayName=e}get headerRow(){return this.table.headerRow}set headerRow(e){this._assign(this.table,`headerRow`,e)}get totalsRow(){return this.table.totalsRow}set totalsRow(e){this._assign(this.table,`totalsRow`,e)}get theme(){return this.table.style.theme}set theme(e){this.table.style.theme=e}get showFirstColumn(){return this.table.style.showFirstColumn}set showFirstColumn(e){this.table.style.showFirstColumn=e}get showLastColumn(){return this.table.style.showLastColumn}set showLastColumn(e){this.table.style.showLastColumn=e}get showRowStripes(){return this.table.style.showRowStripes}set showRowStripes(e){this.table.style.showRowStripes=e}get showColumnStripes(){return this.table.style.showColumnStripes}set showColumnStripes(e){this.table.style.showColumnStripes=e}},me=class{constructor(e){this.model=e||{}}add(e,t){return this.model[e]=t}find(e){let t=this.model[e];if(t!==void 0)return t;let r;for(let t in this.model){if(!t.startsWith(`range:`))continue;r||=n.decodeAddress(e);let i=t.slice(6),a=n.decodeEx(i);if(!a.dimensions)continue;let o=a.tl,s=a.br;if(r.row>=o.row&&r.row<=s.row&&r.col>=o.col&&r.col<=s.col)return this.model[t]}}remove(e){this.model[e]=void 0}};let he=9525,ge=12700,_e=142875,ve=28575,ye=276225,be=190500;var xe=class e{constructor(e,t,n){this.worksheet=e;let{tl:r,br:i}=this._parseRange(t),a=1025+(e.formControls?.length??0),o;n?.link&&(o=this._toAbsoluteRef(n.link)),this.model={shapeId:a,ctrlPropId:0,tl:r,br:i,link:o,checked:n?.checked?`Checked`:`Unchecked`,text:n?.text??``,noThreeD:n?.noThreeD??!0,print:n?.print??!1}}get checked(){return this.model.checked===`Checked`}set checked(e){this.model.checked=e?`Checked`:`Unchecked`}get link(){return this.model.link}set link(e){this.model.link=e?this._toAbsoluteRef(e):void 0}get text(){return this.model.text}set text(e){this.model.text=e}_toAbsoluteRef(e){if(e.includes(`$`))return e;let t=n.decodeAddress(e);return`$${n.n2l(t.col)}$${t.row}`}_parseRange(e){let t,r;if(typeof e==`string`)if(e.includes(`:`)){let i=n.decode(e);if(`top`in i)if(i.left===i.right&&i.top===i.bottom){let e=i.left-1,n=i.top-1;t={col:e,colOff:_e,row:n,rowOff:ve},r={col:e+2,colOff:ye,row:n+1,rowOff:be}}else t={col:i.left-1,colOff:_e,row:i.top-1,rowOff:ve},r={col:i.right-1,colOff:ye,row:i.bottom-1,rowOff:be};else t={col:i.col-1,colOff:_e,row:i.row-1,rowOff:ve},r={col:i.col+1,colOff:ye,row:i.row,rowOff:be}}else{let i=n.decodeAddress(e);t={col:i.col-1,colOff:_e,row:i.row-1,rowOff:ve},r={col:i.col+1,colOff:ye,row:i.row,rowOff:be}}else if(`startCol`in e)t={col:e.startCol,colOff:e.startColOff??_e,row:e.startRow,rowOff:e.startRowOff??ve},r={col:e.endCol,colOff:e.endColOff??ye,row:e.endRow,rowOff:e.endRowOff??be};else{if(typeof e.tl==`string`){let r=n.decodeAddress(e.tl);t={col:r.col-1,colOff:_e,row:r.row-1,rowOff:ve}}else t={col:e.tl.col,colOff:e.tl.colOff??_e,row:e.tl.row,rowOff:e.tl.rowOff??ve};if(e.br)if(typeof e.br==`string`){let t=n.decodeAddress(e.br);r={col:t.col-1,colOff:ye,row:t.row-1,rowOff:be}}else r={col:e.br.col,colOff:e.br.colOff??ye,row:e.br.row,rowOff:e.br.rowOff??be};else r={col:t.col+2,colOff:ye,row:t.row+1,rowOff:be}}return{tl:t,br:r}}getVmlAnchor(){return e.getVmlAnchor(this.model)}getVmlStyle(){return e.getVmlStyle(this.model)}getVmlCheckedValue(){return e.getVmlCheckedValue(this.model)}static getVmlAnchor(e){let{tl:t,br:n}=e,r=Math.round(t.colOff/he),i=Math.round(t.rowOff/he),a=Math.round(n.colOff/he),o=Math.round(n.rowOff/he);return`${t.col}, ${r}, ${t.row}, ${i}, ${n.col}, ${a}, ${n.row}, ${o}`}static getVmlStyle(e){return`position:absolute;margin-left:${Math.round(e.tl.colOff/ge)}pt;margin-top:${Math.round(e.tl.rowOff/ge)}pt;width:96pt;height:18pt;z-index:1;visibility:visible`}static getVmlCheckedValue(e){switch(e.checked){case`Checked`:return 1;case`Mixed`:return 2;default:return 0}}};function Se(){return typeof process<`u`&&!!process.versions?.node}function Ce(e){if(Se())return Buffer.from(e,`base64`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function we(e,t){return 25569+e.getTime()/(24*3600*1e3)-(t?1462:0)}function Te(e,t){let n=Math.round((e-25569+(t?1462:0))*24*3600*1e3);return new Date(n)}function Ee(e){return new Date(e.endsWith(`Z`)?e:e+`Z`)}let De={lt:`<`,gt:`>`,amp:`&`,quot:`"`,apos:`'`};function Oe(e){return e.indexOf(`&`)===-1?e:e.replace(/&(#\d+|#x[0-9A-Fa-f]+|\w+);/g,(e,t)=>{if(t[0]===`#`){let n=t[1]===`x`?parseInt(t.slice(2),16):parseInt(t.slice(1));return Number.isNaN(n)?e:String.fromCodePoint(n)}return De[t]||e})}let ke=/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/;function A(e){let t=ke.exec(e);if(!t)return e;let n=[],r=0;for(let i=t.index;i<e.length;i++){let t=e.charCodeAt(i),a=null;switch(t){case 34:a=`&quot;`;break;case 38:a=`&amp;`;break;case 39:a=`&apos;`;break;case 60:a=`&lt;`;break;case 62:a=`&gt;`;break;case 127:a=``;break;default:if(t<=31&&(t<=8||t>=11&&t!==13)){a=``;break}continue}r!==i&&n.push(e.substring(r,i)),r=i+1,a&&n.push(a)}return r<e.length&&n.push(e.substring(r)),n.join(``)}function Ae(e){let t=typeof e==`number`?e:parseInt(e,10);return Number.isNaN(t)?0:t}function je(e){if(!e||e.indexOf(`@`)>-1)return!1;let t=e.replace(/\[[^\]]*\]/g,``);return t=t.replace(/"[^"]*"/g,``),t.match(/[ymdhMsb]+/)!==null}function j(e){return e===!0||e===`true`||e===1||e===`1`}function*Me(e,t,n=1){let r=n>0?(e,t)=>e<t:(e,t)=>e>t;for(let i=e;r(i,t);i+=n)yield i}function Ne(e){let t=Array.from(e);return t.length<=1?t:t.every(e=>Number.isFinite(e))?t.sort((e,t)=>e-t):t.every(e=>e instanceof Date)?t.sort((e,t)=>e.getTime()-t.getTime()):t.sort((e,t)=>{let n=Pe(e),r=Pe(t);return n===r?n===0?e-t:n===1?e.getTime()-t.getTime():String(e).localeCompare(String(t)):n-r})}function Pe(e){return Number.isFinite(e)?0:e instanceof Date?1:2}let Fe=new TextDecoder(`utf-8`),Ie;try{Ie=new TextDecoder(`latin1`)}catch{Ie=void 0}function Le(e){return typeof e==`string`?e:Fe.decode(e)}function Re(e){if(Se())return Buffer.from(e).toString(`base64`);if(Ie)try{return btoa(Ie.decode(e))}catch{}let t=32768,n=[];for(let r=0;r<e.length;r+=t)n.push(String.fromCharCode.apply(null,e.subarray(r,r+t)));return btoa(n.join(``))}function ze(e){let t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>8&255}return t}let Be=e=>Array.isArray(e);var M=class e{constructor(){this.__excelts_stream=!0,this._listeners=new Map,this._maxListeners=e.defaultMaxListeners}static{this.defaultMaxListeners=10}addListener(e,t){return this.on(e,t)}_listenerCount(e){return e?Be(e)?e.length:1:0}_hasListeners(e){return this._listenerCount(this._listeners.get(e))>0}on(e,t){let n=this._listeners.get(e);if(this._maxListeners>0){let t=this._listenerCount(n);t>=this._maxListeners&&console?.warn?.(`MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${t+1} ${String(e)} listeners added. Use emitter.setMaxListeners() to increase limit`)}return n?Be(n)?n.push(t):this._listeners.set(e,[n,t]):this._listeners.set(e,t),e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t),this}prependListener(e,t){let n=this._listeners.get(e);return n?Be(n)?n.unshift(t):this._listeners.set(e,[t,n]):this._listeners.set(e,t),e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.on(e,n)}prependOnceListener(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.prependListener(e,n)}removeListener(e,t){return this.off(e,t)}off(e,t){let n=this._listeners.get(e);if(!n)return this;if(!Be(n))return(n===t||n.listener===t)&&(this._listeners.delete(e),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t)),this;let r=n;if(r.length===0)return this._listeners.delete(e),this;let i=r.indexOf(t);if(i!==-1)r.splice(i,1);else for(let e=0,n=r.length;e<n;e++)if(r[e].listener===t){r.splice(e,1);break}return r.length===0?this._listeners.delete(e):r.length===1&&this._listeners.set(e,r[0]),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t),this}emit(e,...t){let n=this._listeners.get(e);if(!n)return!1;if(!Be(n)){try{n.apply(this,t)}catch(t){e!==`error`&&this.emit(`error`,t)}return!0}let r=n,i=r.length;if(i===0)return!1;if(i===1){try{r[0].apply(this,t)}catch(t){e!==`error`&&this.emit(`error`,t)}return!0}if(i===2){let n=r[0],i=r[1];try{n.apply(this,t)}catch(t){e!==`error`&&this.emit(`error`,t)}try{i.apply(this,t)}catch(t){e!==`error`&&this.emit(`error`,t)}return!0}let a=r.slice();for(let n=0;n<a.length;n++)try{a[n].apply(this,t)}catch(t){e!==`error`&&this.emit(`error`,t)}return!0}removeAllListeners(e){return e===void 0?this._listeners.clear():this._listeners.delete(e),this}listenerCount(e){return this._listenerCount(this._listeners.get(e))}listeners(e){let t=this._listeners.get(e);return t?Be(t)?t.slice():[t]:[]}rawListeners(e){let t=this._listeners.get(e);return t?Be(t)?t.slice():[t]:[]}eventNames(){return[...this._listeners.keys()]}setMaxListeners(e){return this._maxListeners=e,this}getMaxListeners(){return this._maxListeners}};let Ve=new TextEncoder,He=new TextDecoder(`utf-8`,{ignoreBOM:!0}),Ue=new Map;function We(e){if(!e||e===`utf-8`||e===`utf8`)return He;let t=e,n=Ue.get(t);return n||(n=new TextDecoder(t),Ue.set(t,n)),n}function Ge(e){return Ve.encode(e)}function Ke(e,t){let n=e.length;if(n===0)return new Uint8Array;if(n===1)return e[0];if(t===void 0){let r=0;for(let t=0;t<n;t++)r+=e[t].length;t=r}let r=new Uint8Array(t),i=0;for(let t=0;t<n;t++){let n=e[t];r.set(n,i),i+=n.length}return r}function qe(e){return!!e&&typeof e==`object`&&typeof e.getReader==`function`}function Je(e){return!!e&&typeof e==`object`&&typeof e.getWriter==`function`}function Ye(e){return!!e&&(typeof e==`object`||typeof e==`function`)&&typeof e[Symbol.asyncIterator]==`function`}function Xe(e){return!!e&&typeof e==`object`&&!!e.readable&&!!e.writable&&qe(e.readable)&&Je(e.writable)}let Ze=(e,t,n)=>{typeof e.off==`function`?e.off(t,n):typeof e.removeListener==`function`&&e.removeListener(t,n)},Qe=(e,t,n,r)=>(r?.once&&typeof e.once==`function`?e.once(t,n):e.on(t,n),()=>Ze(e,t,n)),$e=()=>{let e=[];return{add:(t,n,r)=>{e.push(Qe(t,n,r))},once:(t,n,r)=>{e.push(Qe(t,n,r,{once:!0}))},cleanup:()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}};var N=class e extends M{constructor(e){if(super(),this._reader=null,this._buffer=[],this._bufferIndex=0,this._unshiftBuffer=[],this._bufferSize=0,this._reading=!1,this._ended=!1,this._endEmitted=!1,this._destroyed=!1,this._errored=null,this._closed=!1,this._paused=!0,this._flowing=!1,this._pipeTo=[],this._pipeListeners=new Map,this._encoding=null,this._decoder=null,this._didRead=!1,this._aborted=!1,this._pushMode=!1,this._webStreamMode=!1,this.objectMode=e?.objectMode??!1,this.readableHighWaterMark=e?.highWaterMark??16384,this.autoDestroy=e?.autoDestroy??!0,this.emitClose=e?.emitClose??!0,e?.read&&(this._read=e.read.bind(this),this._pushMode=!0),e?.stream)this._stream=e.stream,this._webStreamMode=!0;else{let e;this._stream=new ReadableStream({start:t=>{e=t},pull:async()=>{this.emit(`drain`)},cancel:e=>{this._ended=!0,this._aborted=!0,this.emitClose&&this.emit(`close`)}}),this._controller=e}}static from(t,n){let r=new e({...n,objectMode:n?.objectMode??!0});return tt(r,et(t)),r}static isDisturbed(e){return e._didRead||e._ended||e._destroyed}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e.webStream}push(e){if(this._destroyed)return!1;this._pushMode=!0;let t=this._controller;if(e===null){if(this._ended)return!1;if(this._ended=!0,t)try{t.close()}catch{}return this._bufferedLength()===0&&this._emitEndOnce(),!1}if(t&&!this._webStreamMode)try{t.enqueue(e)}catch{}if(this._flowing)return this.emit(`data`,this._applyEncoding(e)),this._flowing?(this._read&&!this._ended&&queueMicrotask(()=>{this._flowing&&!this._ended&&!this._destroyed&&this._read(this.readableHighWaterMark)}),!0):!1;{let t=this._bufferedLength()===0;return this._buffer.push(e),this.objectMode||(this._bufferSize+=this._getChunkSize(e)),t&&queueMicrotask(()=>this.emit(`readable`)),this.objectMode?this._bufferedLength()<this.readableHighWaterMark:this._bufferSize<this.readableHighWaterMark}}_emitEndOnce(){this._endEmitted||(this._endEmitted=!0,this.emit(`end`))}unshift(e){this._destroyed||(this._bufferUnshift(e),this.objectMode||(this._bufferSize+=this._getChunkSize(e)))}read(e){if(this._didRead=!0,this._bufferedLength()>0){if(this.objectMode||e===void 0){let e=this._bufferShift();this.objectMode||(this._bufferSize-=this._getChunkSize(e));let t=this._applyEncoding(e);return this._ended&&this._bufferedLength()===0&&queueMicrotask(()=>this._emitEndOnce()),t}let t=this._bufferShift();this.objectMode||(this._bufferSize-=this._getChunkSize(t));let n=this._applyEncoding(t);return this._ended&&this._bufferedLength()===0&&queueMicrotask(()=>this._emitEndOnce()),n}return null}_bufferedLength(){return this._unshiftBuffer.length+(this._buffer.length-this._bufferIndex)}_bufferPeek(){let e=this._unshiftBuffer.length;return e>0?this._unshiftBuffer[e-1]:this._bufferIndex<this._buffer.length?this._buffer[this._bufferIndex]:null}_bufferShift(){if(this._unshiftBuffer.length>0)return this._unshiftBuffer.pop();let e=this._buffer[this._bufferIndex++];return this._bufferIndex===this._buffer.length?(this._buffer.length=0,this._bufferIndex=0,e):(this._bufferIndex>1024&&this._bufferIndex*2>this._buffer.length&&(this._buffer=this._buffer.slice(this._bufferIndex),this._bufferIndex=0),e)}_bufferUnshift(e){if(this._bufferIndex===0){this._unshiftBuffer.push(e);return}this._bufferIndex--,this._buffer[this._bufferIndex]=e}_getChunkSize(e){return e instanceof Uint8Array?e.byteLength:1}setEncoding(e){return this._encoding=e,e===`utf-8`||e===`utf8`?this._decoder=He:this._decoder=null,this}_applyEncoding(e){return this._encoding&&e instanceof Uint8Array?(this._decoder||=We(this._encoding),this._decoder.decode(e)):e}wrap(e){return e.on(`data`,t=>{this.push(t)||e.pause()}),e.on(`end`,()=>this.push(null)),e.on(`error`,e=>this.destroy(e)),e.on(`close`,()=>this.destroy()),this}pause(){return this._paused=!0,this._flowing=!1,this}resume(){for(this._paused=!1,this._flowing=!0;this._bufferedLength()>0&&this._flowing;){let e=this._bufferShift();this.objectMode||(this._bufferSize-=this._getChunkSize(e)),this.emit(`data`,this._applyEncoding(e))}return this._ended&&this._bufferedLength()===0?this._emitEndOnce():this._read?queueMicrotask(()=>{this._flowing&&!this._ended&&!this._destroyed&&this._read(this.readableHighWaterMark)}):this._webStreamMode&&!this._pushMode&&this._startReading(),this}on(e,t){return super.on(e,t),e===`data`&&this.resume(),this}isPaused(){return this._paused}pipe(e){let t=e,n=t,r=typeof t?.write==`function`,i=typeof t?.end==`function`,a=typeof n?.on==`function`,o=typeof n?.once==`function`,s=typeof n?.off==`function`;if(!r||!i||!o&&!a||!s&&!n?.removeListener)throw Error(`Readable.pipe: invalid destination`);this._pipeTo.push(t);let c,l=()=>{c&&=(typeof n.off==`function`?n.off(`drain`,c):typeof n.removeListener==`function`&&n.removeListener(`drain`,c),void 0)},u=e=>{if(!t.write(e)&&(this.pause(),!c)){c=()=>{l(),this.resume()},n.on(`drain`,c);let e=this._pipeListeners.get(t);e&&(e.drain=c)}},d=()=>{t.end()},f=e=>{typeof t.destroy==`function`?t.destroy(e):n.emit?.(`error`,e)};return this._pipeListeners.set(t,{data:u,end:d,error:f,eventTarget:n}),this.on(`data`,u),this.once(`end`,d),this.once(`error`,f),this.resume(),e}unpipe(e){if(e){let t=this._pipeTo.indexOf(e);t!==-1&&this._pipeTo.splice(t,1);let n=this._pipeListeners.get(e);n&&(this.off(`data`,n.data),this.off(`end`,n.end),this.off(`error`,n.error),n.drain&&(typeof n.eventTarget?.off==`function`?n.eventTarget.off(`drain`,n.drain):typeof n.eventTarget?.removeListener==`function`&&n.eventTarget.removeListener(`drain`,n.drain)),this._pipeListeners.delete(e))}else{for(let e of this._pipeTo){let t=this._pipeListeners.get(e);t&&(this.off(`data`,t.data),this.off(`end`,t.end),this.off(`error`,t.error),t.drain&&(typeof t.eventTarget?.off==`function`?t.eventTarget.off(`drain`,t.drain):typeof t.eventTarget?.removeListener==`function`&&t.eventTarget.removeListener(`drain`,t.drain)),this._pipeListeners.delete(e))}this._pipeTo=[]}return this.pause(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._ended=!0,this.unpipe(),e&&(this._errored=e,this.emit(`error`,e)),this._reader){let e=this._reader;this._reader=null,e.cancel().catch(()=>{}).finally(()=>{try{e.releaseLock()}catch{}})}return this._closed=!0,this.emit(`close`),this}get webStream(){return this._stream}get readable(){return!this._destroyed&&!this._ended}get readableEnded(){return this._ended}get readableLength(){return this._bufferedLength()}get destroyed(){return this._destroyed}get errored(){return this._errored}get closed(){return this._closed}get readableFlowing(){return!this._paused&&!this._ended?this._flowing:this._flowing?!0:null}get readableAborted(){return this._aborted}get readableDidRead(){return this._didRead}get readableEncoding(){return this._encoding}get readableObjectMode(){return this.objectMode}get readableBuffer(){return{length:this._bufferedLength(),head:this._bufferPeek()}}async _startReading(){if(!(this._reading||this._destroyed||!this._flowing)){this._reading=!0;try{for(this._reader||=this._stream.getReader();this._flowing&&!this._destroyed&&!this._pushMode;){let{done:e,value:t}=await this._reader.read();if(this._pushMode){if(this._reader){let e=this._reader;this._reader=null;try{e.releaseLock()}catch{}}break}if(e){if(this._ended=!0,this._emitEndOnce(),this._reader){let e=this._reader;this._reader=null;try{e.releaseLock()}catch{}}break}t!==void 0&&(this._flowing?this.emit(`data`,this._applyEncoding(t)):(this._buffer.push(t),this.objectMode||(this._bufferSize+=this._getChunkSize(t))))}}catch(e){if(this.emit(`error`,e),this._reader){let e=this._reader;this._reader=null;try{e.releaseLock()}catch{}}}finally{this._reading=!1}}}async*[Symbol.asyncIterator](){for(;this._bufferedLength()>0;){let e=this._bufferShift();this.objectMode||(this._bufferSize-=this._getChunkSize(e)),yield this._applyEncoding(e)}if(this._ended)return;let e=this.readableHighWaterMark,t=Math.max(0,Math.floor(e/2)),n=e=>this.objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?e.length:1,r=[],i=0,a=0,o=null,s=null,c=!1,l=!1,u=null,d=t=>{o?(o(t),o=null,s=null):r.push(t),a+=n(t),!l&&a>=e&&(l=!0,this.pause())},f=()=>{c=!0,o&&(o(null),o=null,s=null)},p=()=>{c=!0,o&&(o(null),o=null,s=null)},m=e=>{c=!0,u=e,s&&=(s(e),o=null,null)};this.on(`data`,d),this.on(`end`,f),this.on(`error`,m),this.on(`close`,p);try{for(this.resume();;){if(u)throw u;if(i<r.length){let e=r[i++];a-=n(e),i>=1024&&i*2>=r.length&&(r.splice(0,i),i=0),l&&a<=t&&!c&&!this._destroyed&&(l=!1,this.resume()),yield e;continue}if(c)break;let e=await new Promise((e,t)=>{o=e,s=t});e!==null&&(a-=n(e),l&&a<=t&&!c&&!this._destroyed&&(l=!1,this.resume()),yield e)}}finally{this.off(`data`,d),this.off(`end`,f),this.off(`error`,m),this.off(`close`,p)}}iterator(e){let t=e?.destroyOnReturn??!0,n=this[Symbol.asyncIterator]();return t?{next:async()=>n.next(),return:async e=>(this.destroy(),{done:!0,value:e}),[Symbol.asyncIterator](){return this}}:n}async*map(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);yield await e(t,{signal:n})}}async*filter(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);await e(t,{signal:n})&&(yield t)}}async*flatMap(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);let r=await e(t,{signal:n});for await(let e of r)yield e}}async*take(e,t){let n=t?.signal,r=0;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);if(r>=e)break;yield t,r++}}async*drop(e,t){let n=t?.signal,r=0;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);r>=e&&(yield t),r++}}async reduce(e,t,n){let r=n?.signal,i=t,a=!0;for await(let t of this){if(r?.aborted)throw Error(`AbortError`);a&&i===void 0?(i=t,a=!1):i=await e(i,t,{signal:r})}if(i===void 0)throw TypeError(`Reduce of empty stream with no initial value`);return i}async every(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);if(!await e(t,{signal:n}))return!1}return!0}async some(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);if(await e(t,{signal:n}))return!0}return!1}async find(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);if(await e(t,{signal:n}))return t}}async forEach(e,t){let n=t?.signal;for await(let t of this){if(n?.aborted)throw Error(`AbortError`);await e(t,{signal:n})}}async toArray(e){let t=e?.signal,n=[];for await(let e of this){if(t?.aborted)throw Error(`AbortError`);n.push(e)}return n}async*asIndexedPairs(e){let t=e?.signal,n=0;for await(let e of this){if(t?.aborted)throw Error(`AbortError`);yield[n++,e]}}compose(t){if(typeof t==`function`){let n=t(this);return e.from(n)}return this.pipe(t),t}};function et(e){return e&&typeof e[Symbol.asyncIterator]==`function`?e:(async function*(){for(let t of e)yield t})()}function tt(e,t){(async()=>{try{for await(let n of t)e.push(n)||await new Promise(e=>setTimeout(e,0));e.push(null)}catch(t){e.destroy(t)}})()}var nt=class e extends M{constructor(e){if(super(),this._writer=null,this._ended=!1,this._finished=!1,this._destroyed=!1,this._errored=null,this._closed=!1,this._pendingWrites=0,this._writableLength=0,this._needDrain=!1,this._corked=0,this._corkedChunks=[],this._defaultEncoding=`utf8`,this._aborted=!1,this._ownsStream=!1,this.objectMode=e?.objectMode??!1,this.writableHighWaterMark=e?.highWaterMark??16384,this.autoDestroy=e?.autoDestroy??!0,this.emitClose=e?.emitClose??!0,this._defaultEncoding=e?.defaultEncoding??`utf8`,e?.write&&(this._writeFunc=e.write.bind(this)),e?.final&&(this._finalFunc=e.final.bind(this)),e?.stream)this._stream=e.stream,this._ownsStream=!1;else{this._ownsStream=!0;let e=()=>this._writeFunc,t=()=>this._finalFunc,n=()=>this._defaultEncoding,r=e=>{this._finished=e},i=e=>{this._aborted=e},a=this.emit.bind(this),o=()=>this.emitClose,s=e=>this._write?.(e);this._stream=new WritableStream({write:async t=>{let r=e();r?await new Promise((e,i)=>{r(t,n(),t=>{t?i(t):e()})}):s(t)},close:async()=>{let e=t();e&&await new Promise((t,n)=>{e(e=>{e?n(e):t()})}),r(!0),a(`finish`),o()&&a(`close`)},abort:e=>{i(!0),a(`error`,e)}})}}setDefaultEncoding(e){return this._defaultEncoding=e,this}cork(){this._corked++}uncork(){if(this._corked>0&&this._corked--,this._corked===0){let e=this._corkedChunks;this._corkedChunks=[];for(let{chunk:t,callback:n}of e)this._doWrite(t,n)}}write(e,t,n){if(this._destroyed||this._ended)return(typeof t==`function`?t:n)?.(Error(`Cannot write after stream destroyed/ended`)),!1;let r=typeof t==`function`?t:n;if(this._corked>0){this._corkedChunks.push({chunk:e,callback:r});let t=this._getChunkSize(e);return this._writableLength+=t,this._writableLength<this.writableHighWaterMark}let i=this._doWrite(e,r);return i||(this._needDrain=!0),i}_doWrite(e,t){let n=this._getChunkSize(e);return this._pendingWrites++,this._writableLength+=n,this._getWriter().write(e).then(()=>{this._pendingWrites--,this._writableLength-=n,this._needDrain&&this._writableLength<this.writableHighWaterMark&&(this._needDrain=!1,this.emit(`drain`)),t?.(null)}).catch(e=>{this._pendingWrites--,this._writableLength-=n,this._destroyed||(this._errored=e,this.emit(`error`,e)),t?.(e)}),this._writableLength<this.writableHighWaterMark}_getChunkSize(e){return this.objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?e.length:0}end(e,t,n){if(this._ended)return this;this._ended=!0;let r=typeof e==`function`?void 0:e,i=typeof e==`function`?e:typeof t==`function`?t:n;return(async()=>{try{let e=this._getWriter();if(r!==void 0&&await e.write(r),await e.close(),this._writer===e){this._writer=null;try{e.releaseLock()}catch{}}this._ownsStream||(this._finished=!0,this.emit(`finish`),this.emitClose&&this.emit(`close`)),i&&i()}catch(e){this.emit(`error`,e)}})(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._ended=!0,e&&!this._errored&&(this._errored=e,this.emit(`error`,e)),this._writer){let t=this._writer;this._writer=null,t.abort(e).catch(()=>{}).finally(()=>{try{t.releaseLock()}catch{}})}return this._closed=!0,this.emit(`close`),this}get webStream(){return this._stream}get writable(){return!this._destroyed&&!this._ended}get writableEnded(){return this._ended}get writableFinished(){return this._finished}get writableLength(){return this._writableLength}get destroyed(){return this._destroyed}get errored(){return this._errored}get closed(){return this._closed}get writableNeedDrain(){return this._writableLength>=this.writableHighWaterMark}get writableCorked(){return this._corked}get writableAborted(){return this._aborted}get writableObjectMode(){return this.objectMode}get defaultEncoding(){return this._defaultEncoding}get writableBuffer(){return{length:this._corkedChunks.length,head:this._corkedChunks.length>0?this._corkedChunks[0].chunk:null}}_writev(e,t){let n=0,r=()=>{if(n>=e.length){t(null);return}let{chunk:i}=e[n++];this._doWrite(i,e=>{if(e){t(e);return}r()})};r()}writev(e,t){return this._destroyed||this._ended?(t?.(Error(`Cannot write after stream destroyed/ended`)),!1):(this._writev(e,t??(()=>{})),this._writableLength<this.writableHighWaterMark)}_getWriter(){return this._writer||=this._stream.getWriter(),this._writer}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e.webStream}};function rt(e){return e instanceof nt?e:e?.getWriter?new nt({stream:e}):e}var it=class e extends M{push(e){return this._readable.push(e)}constructor(e){super(),this._destroyed=!1,this._ended=!1,this._errored=!1,this._dataForwardingSetup=!1,this._endTimer=null,this._webStream=null,this._sideForwardingCleanup=null,this.objectMode=e?.objectMode??!1,this._transformImpl=e?.transform,this._flushImpl=e?.flush,this._readable=new N({objectMode:this.objectMode}),this._writable=new nt({objectMode:this.objectMode,write:(e,t,n)=>{this._runTransform(e).then(()=>n(null)).catch(e=>n(e))},final:e=>{this._runFlush().then(()=>{this._readable.push(null),e(null)}).catch(t=>e(t))}}),this._setupSideForwarding()}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let e=$e();e.once(this._readable,`end`,()=>this.emit(`end`)),e.add(this._readable,`error`,e=>this._emitErrorOnce(e)),e.once(this._writable,`finish`,()=>this.emit(`finish`)),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.add(this._writable,`error`,e=>this._emitErrorOnce(e)),this._sideForwardingCleanup=()=>e.cleanup()}_scheduleEnd(){this._destroyed||this._errored||this._writable.writableEnded||(this._endTimer&&clearTimeout(this._endTimer),this._endTimer=setTimeout(()=>{this._endTimer=null,!(this._destroyed||this._errored||this._writable.writableEnded)&&this._writable.end()},0))}_emitErrorOnce(e){if(this._errored)return;this._errored=!0;let t=e instanceof Error?e:Error(String(e));this.emit(`error`,t),this._destroyed||(this._destroyed=!0,this._readable.destroy(t),this._writable.destroy(t),queueMicrotask(()=>this.emit(`close`)))}_hasSubclassTransform(){return this._transformImpl?!1:Object.getPrototypeOf(this)._transform!==e.prototype._transform}_hasSubclassFlush(){return this._flushImpl?!1:Object.getPrototypeOf(this)._flush!==e.prototype._flush}async _runTransform(e){if(this._destroyed||this._errored)throw Error(this._errored?`Cannot write after stream errored`:`Cannot write after stream destroyed`);try{if(this._hasSubclassTransform()){await new Promise((t,n)=>{this._transform(e,`utf8`,(e,r)=>{if(e){n(e);return}r!==void 0&&this.push(r),t()})});return}let t=this._transformImpl;if(!t){this.push(e);return}let n=t.length;if(n>=3){await new Promise((n,r)=>{t.call(this,e,`utf8`,(e,t)=>{if(e){r(e);return}t!==void 0&&this.push(t),n()})});return}if(n===2){await new Promise((n,r)=>{t.call(this,e,(e,t)=>{if(e){r(e);return}t!==void 0&&this.push(t),n()})});return}let r=t.call(this,e);if(r&&typeof r.then==`function`){let e=await r;e!==void 0&&this.push(e);return}r!==void 0&&this.push(r)}catch(e){throw this._emitErrorOnce(e),e}}async _runFlush(){if(!(this._destroyed||this._errored))try{if(this._hasSubclassFlush()){await new Promise((e,t)=>{this._flush((n,r)=>{if(n){t(n);return}r!==void 0&&this.push(r),e()})});return}let e=this._flushImpl;if(!e)return;if(e.length>=1){await new Promise((t,n)=>{e.call(this,(e,r)=>{if(e){n(e);return}r!==void 0&&this.push(r),t()})});return}let t=e.call(this);if(t&&typeof t.then==`function`){let e=await t;e!=null&&this.push(e);return}t!=null&&this.push(t)}catch(e){throw this._emitErrorOnce(e),e}}on(e,t){return e===`data`&&!this._dataForwardingSetup&&(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>this.emit(`data`,e))),super.on(e,t)}write(e,t,n){let r=typeof t==`function`?t:n;return this._ended&&!this._writable.writableEnded&&this._scheduleEnd(),this._writable.write(e,r)}end(e,t,n){if(this._ended)return this;this._ended=!0;let r=typeof e==`function`?void 0:e,i=typeof e==`function`?e:typeof t==`function`?t:n;return i&&this.once(`finish`,i),r!==void 0&&this._writable.write(r),this._scheduleEnd(),this}read(e){return this._readable.read(e)}pipe(e){return this._readable.pipe(e)}unpipe(e){return this._readable.unpipe(e),this}isPaused(){return this._readable.isPaused()}resume(){return this._readable.resume(),this}pause(){return this._readable.pause(),this}destroy(e){this._destroyed||(this._destroyed=!0,this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable.destroy(e),this._writable.destroy(e),queueMicrotask(()=>this.emit(`close`)))}get webStream(){if(this._webStream)return this._webStream;let e=this[Symbol.asyncIterator]();return this._webStream={readable:new ReadableStream({pull:async t=>{let{done:n,value:r}=await e.next();if(n){t.close();return}t.enqueue(r)},cancel:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}}),writable:new WritableStream({write:e=>new Promise((t,n)=>{this.write(e,e=>{e?n(e):t()})}),close:()=>new Promise(e=>{this.end(()=>e())}),abort:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}})},this._webStream}get readable(){return this._readable.readable}get writable(){return this._writable.writable}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get readableObjectMode(){return this._readable.readableObjectMode??this._readable.objectMode}get readableFlowing(){return this._readable.readableFlowing}get destroyed(){return this._destroyed}async*[Symbol.asyncIterator](){yield*this._readable[Symbol.asyncIterator]()}static fromWeb(t,n){let r=new e(n);r._webStream=t;let i=N.fromWeb(t.readable,{objectMode:n?.objectMode}),a=nt.fromWeb(t.writable,{objectMode:n?.objectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return e.webStream}_transform(e,t,n){n(null,e)}_flush(e){e()}},at=class e extends M{static from(t){if(t instanceof e)return t;let n=(e,t)=>{let n=new nt({objectMode:t.readableObjectMode,write(e,n,r){t.push(e),r()},final(e){t.push(null),e()}}),r=Qe(e,`error`,e=>{t.emit(`error`,e)});Qe(e,`end`,r,{once:!0}),Qe(e,`close`,r,{once:!0}),Qe(n,`finish`,r,{once:!0}),e.pipe(n)};if(typeof t==`object`&&t&&`readable`in t&&`writable`in t){let r=t,i=new e({readableObjectMode:r.readable?.readableObjectMode,writableObjectMode:r.writable?.writableObjectMode,write:r.writable?(e,t,n)=>{r.writable.write(e,t,n)}:void 0,final:r.writable?e=>{r.writable.end(e)}:void 0});return r.readable&&n(r.readable,i),i}if(typeof t==`object`&&t&&(Symbol.asyncIterator in t||Symbol.iterator in t)){let r=N.from(t),i=new e;return n(r,i),i}if(t instanceof N){let r=new e;return n(t,r),r}if(t instanceof nt)return new e({objectMode:!0,write(e,n,r){t.write(e,n,r)},final(e){t.end(e)}});throw Error(`Duplex.from: unsupported source type`)}static fromWeb(t,n){let r=new e(n),i=new N({stream:t.readable,objectMode:r.readableObjectMode}),a=new nt({stream:t.writable,objectMode:r.writableObjectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return{readable:e._readable.webStream,writable:e._writable.webStream}}constructor(e){super(),this._dataForwardingSetup=!1,this._sideForwardingCleanup=null,this.allowHalfOpen=e?.allowHalfOpen??!0;let t=e?.objectMode??!1;this.readableObjectMode=e?.readableObjectMode??t,this.writableObjectMode=e?.writableObjectMode??t,this._readable=new N({highWaterMark:e?.readableHighWaterMark,objectMode:this.readableObjectMode,read:e?.read?.bind(this)}),this._writable=new nt({highWaterMark:e?.writableHighWaterMark,objectMode:this.writableObjectMode,write:e?.write?.bind(this),final:e?.final?.bind(this)}),this._setupSideForwarding()}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let e=$e();e.once(this._readable,`end`,()=>{this.emit(`end`),this.allowHalfOpen||this._writable.end()}),e.add(this._readable,`error`,e=>this.emit(`error`,e)),e.add(this._writable,`error`,e=>this.emit(`error`,e)),e.once(this._writable,`finish`,()=>this.emit(`finish`)),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.once(this._writable,`close`,()=>{!this.allowHalfOpen&&!this._readable.destroyed&&this._readable.destroy()}),this._sideForwardingCleanup=()=>e.cleanup()}on(e,t){return e===`data`&&!this._dataForwardingSetup&&(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>this.emit(`data`,e))),super.on(e,t)}push(e){return this._readable.push(e)}unshift(e){this._readable.unshift(e)}read(e){return this._readable.read(e)}write(e,t,n){let r=typeof t==`function`?t:n;return this._writable.write(e,r)}end(e,t,n){let r=typeof e==`function`?void 0:e,i=typeof e==`function`?e:typeof t==`function`?t:n;return i&&this.once(`finish`,i),r!==void 0&&this._writable.write(r),this._writable.end(),this}cork(){this._writable.cork()}uncork(){this._writable.uncork()}setEncoding(e){return this._readable.setEncoding(e),this}setDefaultEncoding(e){return this._writable.setDefaultEncoding(e),this}pipe(e){return e instanceof it?(this._readable.pipe(e._writable),e):(this._readable.pipe(e),e)}unpipe(e){return this._readable.unpipe(e),this}pause(){return this._readable.pause(),this}resume(){return this._readable.resume(),this}isPaused(){return this._readable.isPaused()}destroy(e){return this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable.destroy(e),this._writable.destroy(e),this}get readable(){return this._readable.readable}get writable(){return this._writable.writable}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get destroyed(){return this._readable.destroyed&&this._writable.destroyed}get writableCorked(){return this._writable.writableCorked}get writableNeedDrain(){return this._writable.writableNeedDrain}[Symbol.asyncIterator](){return this._readable[Symbol.asyncIterator]()}},ot=class extends it{constructor(e){super({...e,transform:e=>e})}};let st=e=>!e||typeof e!=`object`||typeof e.pipe==`function`||typeof e.write==`function`||typeof e.end==`function`||typeof e.getReader==`function`||typeof e.getWriter==`function`?!1:Object.prototype.hasOwnProperty.call(e,`signal`)||Object.prototype.hasOwnProperty.call(e,`end`),ct=e=>e instanceof N||e instanceof nt||e instanceof it||e instanceof at?e:Xe(e)?it.fromWeb(e):qe(e)?N.fromWeb(e):Je(e)?nt.fromWeb(e):e;function lt(...e){let t,n={},r,i=e[e.length-1];typeof i==`function`?(r=i,t=e.slice(0,-1)):st(i)?(n=i,t=e.slice(0,-1)):t=e;let a=new Promise((e,r)=>{if(t.length<2){r(Error(`Pipeline requires at least 2 streams`));return}let i=t.map(ct),a=i[0],o=i[i.length-1],s=i.slice(1,-1),c=!1,l=[a,...s,o],u=$e(),d,f=t=>{if(!c)if(c=!0,u.cleanup(),d&&n.signal&&n.signal.removeEventListener(`abort`,d),t){for(let e of l)typeof e.destroy==`function`&&e.destroy(t);r(t)}else e()};if(n.signal){if(n.signal.aborted){f(Error(`Pipeline aborted`));return}d=()=>f(Error(`Pipeline aborted`)),n.signal.addEventListener(`abort`,d)}let p=a;for(let e of s)p.pipe(e),p=e;if(n.end!==!1)p.pipe(o);else{let e=!1,t=!1,n=()=>{t=!1,e&&typeof p.resume==`function`&&(e=!1,p.resume())};u.add(p,`data`,r=>{!o.write(r)&&!t&&(t=!0,!e&&typeof p.pause==`function`&&(e=!0,p.pause()),u.once(o,`drain`,n))}),u.once(p,`end`,()=>f())}u.once(o,`finish`,()=>f());for(let e of l)u.once(e,`error`,e=>f(e))});return r&&a.then(()=>r(null)).catch(e=>r(e)),a}function ut(e,t,n){let r={},i;typeof t==`function`?i=t:t&&(r=t,i=n);let a=new Promise((t,n)=>{let i=ct(e),a=!1,o=$e(),s,c=()=>{o.cleanup(),s&&r.signal&&r.signal.removeEventListener(`abort`,s)},l=e=>{a||(a=!0,c(),e&&!r.error?n(e):t())};if(r.signal){if(r.signal.aborted){l(Error(`Aborted`));return}s=()=>l(Error(`Aborted`)),r.signal.addEventListener(`abort`,s)}let u=r.readable!==!1,d=r.writable!==!1;if(u&&i.readableEnded){l();return}if(d&&i.writableFinished){l();return}d&&o.once(i,`finish`,()=>l()),u&&o.once(i,`end`,()=>l()),o.once(i,`error`,e=>l(e)),o.once(i,`close`,()=>l())});return i&&a.then(()=>i(null)).catch(e=>i(e)),a}function dt(e){let t=new Uint8Array(4);return t[0]=e&255,t[1]=e>>8&255,t[2]=e>>16&255,t[3]=e>>24&255,t}let ft={async hash(e,...t){let n=Ke(t),r=await crypto.subtle.digest(e,new Uint8Array(n));return new Uint8Array(r)},async convertPasswordToHash(e,t,n,r){let i=ze(e),a=Ce(n),o=await this.hash(t,a,i);for(let e=0;e<r;e++)o=await this.hash(t,o,dt(e));return Re(o)},randomBytes(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}};var pt=class{constructor(e){this.code=e}toString(){return`#${this.code}`}};let mt={sum:`Sum`,count:`Count`,average:`Average`,max:`Max`,min:`Min`,product:`Product`,countNums:`Count Numbers`,stdDev:`StdDev`,stdDevP:`StdDevP`,var:`Var`,varP:`VarP`},ht=new Set(Object.keys(mt));function gt(e){let t=e.model;if(t.headerRow===!1)throw Error(`Cannot create pivot table from a table without headers. Set headerRow: true on the table.`);if(!t.rows||t.rows.length===0)throw Error(`Cannot create pivot table from an empty table. Add data rows to the table.`);let r=t.columns.map(e=>e.name),i=new Set;for(let e of r){if(i.has(e))throw Error(`Duplicate column name "${e}" found in table. Pivot tables require unique column names.`);i.add(e)}let a=[void 0,...r],o=t.rows.map(e=>[void 0,...e]),s=t.tl;if(!s)throw Error(`Table "${t.name}" is missing top-left cell address (tl)`);let c=s.row,l=s.col,u=c+t.rows.length,d=l+r.length-1,f=n.encode(c,l,u,d);return{name:e.worksheet.name,tableName:t.name,getRow(e){if(e===1)return{values:a};let t=e-2;return t>=0&&t<o.length?{values:o[t]}:{values:[]}},getColumn(e){if(e<1||e>r.length)return{values:[]};let n=[];n[1]=r[e-1];for(let r=0;r<t.rows.length;r++)n[r+2]=t.rows[r][e-1];return{values:n}},getSheetValues(){let e=[];e[1]=a;for(let t=0;t<o.length;t++)e[t+2]=o[t];return e},dimensions:{shortRange:f}}}function _t(e){if(e.sourceSheet&&e.sourceTable)throw Error(`Cannot specify both sourceSheet and sourceTable. Choose one.`);if(e.sourceTable)return gt(e.sourceTable);if(!e.sourceSheet)throw Error(`Either sourceSheet or sourceTable must be provided.`);return e.sourceSheet}function vt(e){return typeof e==`string`?e:e.name}function yt(e){return typeof e==`string`?void 0:e.metric}function bt(e,t){let n=_t(t);xt(t,n);let{rows:r}=t,i=t.columns??[],a=t.pages??[],o=t.values.map(vt),s=t.metric??`sum`,c=t.values.map(e=>yt(e)??s),l=Ct(n,[...r,...i,...a],o),u={};for(let e=0;e<l.length;e++)u[l[e].name]=e;let d=(e,t)=>{let n=u[e];if(n===void 0)throw Error(`${t} field "${e}" not found in cache fields`);return n},f=r.map(e=>d(e,`Row`)),p=i.map(e=>d(e,`Column`)),m=o.map(e=>d(e,`Value`)),h=a.map(e=>d(e,`Page`)),g=e.workbook.pivotTables.map(e=>e.tableNumber).filter(e=>Number.isFinite(e)),_=g.length>0?g.reduce((e,t)=>e>t?e:t,-1/0)+1:1,v=e.workbook.pivotTables.map(e=>parseInt(e.cacheId,10)).filter(e=>Number.isFinite(e)),y=v.length>0?v.reduce((e,t)=>e>t?e:t,-1/0)+1:10+_-1;return{source:n,rows:f,columns:p,values:m,pages:h,metric:s,valueMetrics:c,cacheFields:l,cacheId:String(y),applyWidthHeightFormats:t.applyWidthHeightFormats??`1`,tableNumber:_}}function xt(e,t){let n=e.columns??[],r=e.pages??[],i=e.values.map(vt),a=t.getRow(1).values.slice(1);for(let e=0;e<a.length;e++){let n=a[e];if(n==null||n===``||typeof n==`string`&&n.trim()===``)throw Error(`Empty or missing header name at column ${e+1} in ${t.name}. Pivot tables require all columns to have non-empty headers.`)}let o=new Set;for(let e of a){let n=String(e);if(o.has(n))throw Error(`Duplicate header name "${n}" found in ${t.name}. Pivot tables require unique column names.`);o.add(n)}let s=new Set(a.map(String)),c=e=>{if(!s.has(e))throw Error(`The header name "${e}" was not found in ${t.name}.`)};for(let t of e.rows)c(t);for(let e of n)c(e);for(let e of i)c(e);for(let e of r)c(e);let l=new Map,u=[{name:`rows`,fields:e.rows},{name:`columns`,fields:n},{name:`pages`,fields:r}];for(let e of u)for(let t of e.fields){let n=l.get(t);if(n===e.name)throw Error(`Duplicate field "${t}" in ${e.name}. Each field can only appear once per axis area.`);if(n)throw Error(`Field "${t}" cannot appear in both ${n} and ${e.name}. Each field can only be assigned to one axis area.`);l.set(t,e.name)}if(!e.rows.length)throw Error(`No pivot table rows specified.`);if(e.values.length<1)throw Error(`Must have at least one value.`);if(e.metric!==void 0&&!ht.has(e.metric))throw Error(`Invalid metric "${e.metric}". Must be one of: ${[...ht].join(`, `)}.`);for(let t of e.values){let e=yt(t);if(e!==void 0&&!ht.has(e))throw Error(`Invalid metric "${e}" on value field "${vt(t)}". Must be one of: ${[...ht].join(`, `)}.`)}let d=new Set;for(let e of i){if(d.has(e))throw Error(`Duplicate value field "${e}". Each value field name must be unique.`);d.add(e)}}function St(e){if(e==null)return null;if(typeof e!=`object`||e instanceof Date||e instanceof pt)return e;let t=e;if(typeof t.error==`string`){let e=t.error;return new pt(e.startsWith(`#`)?e.slice(1):e)}if(`formula`in t||`sharedFormula`in t){let e=t.result;return e==null?null:St(e)}return Array.isArray(t.richText)?t.richText.map(e=>e.text??``).join(``):typeof t.text==`string`&&typeof t.hyperlink==`string`?t.text:typeof t.checkbox==`boolean`?t.checkbox:String(e)}function Ct(e,t,n){let r=e.getRow(1).values,i=new Set(t),a=new Set(n),o=t=>{let n=e.getColumn(t).values,r=new Set,i=new Map,a=!1;for(let e=2;e<n.length;e++){let t=St(n[e]);t===null||typeof t==`number`&&isNaN(t)?a=!0:t instanceof pt?i.has(t.code)||(i.set(t.code,t),r.add(t)):r.add(t)}let o=Ne(r);return a&&o.push(null),o},s=t=>{let n=e.getColumn(t).values,r=1/0,i=-1/0,a=!1,o=!0;for(let e=2;e<n.length;e++){let t=St(n[e]);typeof t==`number`&&!isNaN(t)&&(a=!0,t<r&&(r=t),t>i&&(i=t),Number.isInteger(t)||(o=!1))}return a?{minValue:r,maxValue:i,allInteger:o}:null},c=[];for(let e of Me(1,r.length)){let t=r[e],n=String(t);if(i.has(n))c.push({name:n,sharedItems:o(e)});else if(a.has(n)){let t=s(e);c.push({name:n,sharedItems:null,containsNumber:t?`1`:void 0,minValue:t?.minValue,maxValue:t?.maxValue,containsInteger:t?.allInteger?`1`:void 0})}else c.push({name:n,sharedItems:null})}return c}let wt=(e,t)=>({...e,...t.reduce((t,n)=>(e[n]&&(t[n]={...e[n]}),t),{})}),P=(e,t,n,r=[])=>{e[n]&&(t[n]=wt(e[n],r))},Tt=e=>Object.keys(e).length===0,Et=e=>{if(!e)return e;if(Tt(e))return{};let t={...e};return P(e,t,`font`,[`color`]),P(e,t,`alignment`),P(e,t,`protection`),e.border&&(P(e,t,`border`),P(e.border,t.border,`top`,[`color`]),P(e.border,t.border,`left`,[`color`]),P(e.border,t.border,`bottom`,[`color`]),P(e.border,t.border,`right`,[`color`]),P(e.border,t.border,`diagonal`,[`color`])),e.fill&&(P(e,t,`fill`,[`fgColor`,`bgColor`,`center`]),e.fill.stops&&(t.fill.stops=e.fill.stops.map(e=>wt(e,[`color`])))),t};var Dt=class{constructor(e){e||={},this._workbook=e.workbook,this.id=e.id??0,this.orderNo=e.orderNo??0,this.name=e.name||`sheet${this.id}`,this.state=e.state??`visible`,this._rows=[],this._columns=null,this._keys={},this._merges={},this.rowBreaks=[],this.colBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,outlineLevelCol:0,outlineLevelRow:0},e.properties),this.pageSetup=Object.assign({},{margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:`portrait`,horizontalDpi:void 0,verticalDpi:void 0,fitToPage:!!(e.pageSetup&&(e.pageSetup.fitToWidth||e.pageSetup.fitToHeight)&&!e.pageSetup.scale),pageOrder:`downThenOver`,blackAndWhite:!1,draft:!1,cellComments:`None`,errors:`displayed`,scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,firstPageNumber:void 0,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},e.pageSetup),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},e.headerFooter),this.dataValidations=new me,this.views=e.views??[],this.autoFilter=e.autoFilter??null,this._media=[],this.sheetProtection=null,this.tables={},this.pivotTables=[],this.conditionalFormattings=[],this.formControls=[]}get name(){return this._name}set name(e){if(e===void 0&&(e=`sheet${this.id}`),this._name!==e){if(typeof e!=`string`)throw Error(`The name has to be a string.`);if(e===``)throw Error(`The name can't be empty.`);if(e===`History`)throw Error(`The name "History" is protected. Please use a different name.`);if(/[*?:/\\[\]]/.test(e))throw Error(`Worksheet name ${e} cannot include any of the following characters: * ? : \\ / [ ]`);if(/(^')|('$)/.test(e))throw Error(`The first or last character of worksheet name cannot be a single quotation mark: ${e}`);if(e&&e.length>31&&(e=e.substring(0,31)),this._workbook.worksheets.find(t=>t&&t.name.toLowerCase()===e.toLowerCase()))throw Error(`Worksheet name already exists: ${e}`);this._name=e}}get workbook(){return this._workbook}destroy(){this._workbook.removeWorksheetEx(this)}get dimensions(){let e=new r;return this._rows.forEach(t=>{if(t){let n=t.dimensions;n&&e.expand(t.number,n.min,t.number,n.max)}}),e}get columns(){return this._columns}set columns(e){this._headerRowCount=e.reduce((e,t)=>{let n=Array.isArray(t.header)?t.header.length:t.header?1:0;return Math.max(e,n)},0);let t=1,n=this._columns=[];e.forEach(e=>{let r=new O(this,t++,!1);n.push(r),r.defn=e})}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){Object.keys(this._keys).forEach(t=>e(this._keys[t],t))}getColumn(e){let t;if(typeof e==`string`){let r=this._keys[e];if(r)return r;t=n.l2n(e)}else t=e;if(this._columns||=[],t>this._columns.length){let e=this._columns.length+1;for(;e<=t;)this._columns.push(new O(this,e++))}return this._columns[t-1]}spliceColumns(e,t,...n){for(let e of Object.values(this._merges))for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++){let e=this.findCell(t,n);e&&e.type===u.ValueType.Merge&&e.unmerge()}let r=this._rows.length;if(n.length>0)for(let i=0;i<r;i++){let r=n.map(e=>e[i]??null);this.getRow(i+1).splice(e,t,...r)}else this._rows.forEach(n=>{n&&n.splice(e,t)});let i=n.length-t,a=e+t,o=this._columns?this._columns.length:0;if(i<0)for(let t=e+n.length;t<=o;t++)this.getColumn(t).defn=this.getColumn(t-i).defn;else if(i>0)for(let e=o;e>=a;e--)this.getColumn(e+i).defn=this.getColumn(e).defn;for(let t=e;t<e+n.length;t++)this.getColumn(t).defn=void 0;if(this.workbook.definedNames.spliceColumns(this.name,e,t,n.length),i!==0){for(let t of this._media)if(t.type===`image`&&t.range){let{tl:n,br:r}=t.range;n&&n.nativeCol>=e-1&&(n.nativeCol=Math.max(0,n.nativeCol+i)),r&&r.nativeCol>=e-1&&(r.nativeCol=Math.max(0,r.nativeCol+i))}}this._spliceMerges(`col`,e,t,n.length)}get lastColumn(){return this.getColumn(this.columnCount)}get columnCount(){let e=0;return this.eachRow(t=>{e=Math.max(e,t.cellCount)}),e}get actualColumnCount(){let e=[],t=0;return this.eachRow(n=>{n.eachCell(({col:n})=>{e[n]||(e[n]=!0,t++)})}),t}_commitRow(e){}get _lastRowNumber(){let e=this._rows,t=e.length;for(;t>0&&e[t-1]===void 0;)t--;return t}get _nextRow(){return this._lastRowNumber+1}get lastRow(){if(this._rows.length)return this._rows[this._rows.length-1]}findRow(e){return this._rows[e-1]}findRows(e,t){return this._rows.slice(e-1,e-1+t)}get rowCount(){return this._lastRowNumber}get actualRowCount(){let e=0;return this.eachRow(()=>{e++}),e}getRow(e){let t=this._rows[e-1];return t||=this._rows[e-1]=new ce(this,e),t}getRows(e,t){if(t<1)return;let n=[];for(let r=e;r<e+t;r++)n.push(this.getRow(r));return n}addRow(e,t=`n`){let n=this._nextRow,r=this.getRow(n);return r.values=e,this._setStyleOption(n,t[0]===`i`?t:`n`),r}addRows(e,t=`n`){let n=[];return e.forEach(e=>{n.push(this.addRow(e,t))}),n}insertRow(e,t,n=`n`){return this.spliceRows(e,0,t),this._setStyleOption(e,n),this.getRow(e)}insertRows(e,t,n=`n`){if(this.spliceRows(e,0,...t),n!==`n`)for(let r=0;r<t.length;r++)n[0]===`o`&&this.findRow(t.length+e+r)!==void 0?this._copyStyle(t.length+e+r,e+r,n[1]===`+`):n[0]===`i`&&this.findRow(e-1)!==void 0&&this._copyStyle(e-1,e+r,n[1]===`+`);return this.getRows(e,t.length)}_setStyleOption(e,t=`n`){t[0]===`o`&&this.findRow(e+1)!==void 0?this._copyStyle(e+1,e,t[1]===`+`):t[0]===`i`&&this.findRow(e-1)!==void 0&&this._copyStyle(e-1,e,t[1]===`+`)}_copyStyle(e,t,n=!1){let r=this.getRow(e),i=this.getRow(t);i.style=Et(r.style),r.eachCell({includeEmpty:n},(e,t)=>{i.getCell(t).style=Et(e.style)}),i.height=r.height}duplicateRow(e,t,n=!1){let r=this._rows[e-1],i=Array.from({length:t}).fill(r.values),a=[];for(let t of Object.values(this._merges))t.top===e&&t.bottom===e&&a.push(t);let o=[],s=e-1;for(let e of this._media)e.type===`image`&&e.range&&e.range.tl.nativeRow===s&&o.push(e);this.spliceRows(e+1,n?0:t,...i);for(let n=0;n<t;n++){let t=this._rows[e+n];t.style=r.style,t.height=r.height,r.eachCell({includeEmpty:!0},(e,n)=>{t.getCell(n).style=e.style})}if(a.length>0)for(let r=0;r<t;r++){let t=e+1+r;if(!n){let e=[];for(let[n,r]of Object.entries(this._merges))r.top<=t&&r.bottom>=t&&e.push(n);for(let t of e)this._unMergeMaster(this.getCell(t))}for(let e of a)this.mergeCellsWithoutStyle(t,e.left,t,e.right)}if(!n){let n=e,r=e+t-1;this._media=this._media.filter(e=>{if(e.type===`image`&&e.range){let t=e.range.tl.nativeRow;return t<n||t>r}return!0})}for(let e=0;e<t;e++){let t=e+1;for(let e of o){let n=e.clone();if(n.range.tl.nativeRow=s+t,n.range.br){let r=e.range.br.nativeRow-s;n.range.br.nativeRow=s+t+r}this._media.push(n)}}}spliceRows(e,t,...n){for(let e of Object.values(this._merges))for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++){let e=this.findCell(t,n);e&&e.type===u.ValueType.Merge&&e.unmerge()}let r=e+t,i=n.length,a=i-t,o=this._rows.length,s,c;if(a<0)for(e===o&&(this._rows[o-1]=void 0),s=r;s<=o;s++)if(c=this._rows[s-1],c){let e=this.getRow(s+a);e.values=c.values,e.style=c.style,e.height=c.height,c.eachCell({includeEmpty:!0},(t,n)=>{e.getCell(n).style=t.style}),this._rows[s-1]=void 0}else this._rows[s+a-1]=void 0;else if(a>0)for(s=o;s>=r;s--)if(c=this._rows[s-1],c){let e=this.getRow(s+a);e.values=c.values,e.style=c.style,e.height=c.height,c.eachCell({includeEmpty:!0},(t,n)=>{e.getCell(n).style=t.style})}else this._rows[s+a-1]=void 0;for(s=0;s<i;s++){let t=this.getRow(e+s);t.style={},t.values=n[s]}if(this.workbook.definedNames.spliceRows(this.name,e,t,i),a!==0){for(let t of this._media)if(t.type===`image`&&t.range){let{tl:n,br:r}=t.range;n&&n.nativeRow>=e-1&&(n.nativeRow=Math.max(0,n.nativeRow+a)),r&&r.nativeRow>=e-1&&(r.nativeRow=Math.max(0,r.nativeRow+a))}}this._spliceMerges(`row`,e,t,i)}eachRow(e,t){let n,r;if(typeof e==`function`?r=e:(n=e,r=t),n&&n.includeEmpty){let e=this._rows.length;for(let t=1;t<=e;t++)r(this.getRow(t),t)}else this._rows.forEach(e=>{e&&e.hasValues&&r(e,e.number)})}getSheetValues(){let e=[];return this._rows.forEach(t=>{t&&(e[t.number]=t.values)}),e}findCell(e,t){let r=n.getAddress(e,t),i=this._rows[r.row-1];return i?i.findCell(r.col):void 0}getCell(e,t){let r=n.getAddress(e,t);return this.getRow(r.row).getCellEx(r)}mergeCells(...e){let t=new r(e);this._mergeCellsInternal(t)}mergeCellsWithoutStyle(...e){let t=new r(e);this._mergeCellsInternal(t,!0)}_mergeCellsInternal(e,t){Object.values(this._merges).forEach(t=>{if(t.intersects(e))throw Error(`Cannot merge already merged cells`)});let n=this.getCell(e.top,e.left);for(let r=e.top;r<=e.bottom;r++)for(let i=e.left;i<=e.right;i++)(r>e.top||i>e.left)&&this.getCell(r,i).merge(n,t);this._merges[n.address]=e}_unMergeMaster(e){let t=this._merges[e.address];if(t){for(let e=t.top;e<=t.bottom;e++)for(let n=t.left;n<=t.right;n++)this.getCell(e,n).unmerge();delete this._merges[e.address]}}_spliceMerges(e,t,i,a){let o=a-i;if(o===0&&i===0)return;let s=t+i,c=e===`row`,l={};for(let e of Object.values(this._merges)){let{top:a,left:u,bottom:d,right:f}=e.model,p=c?a:u,m=c?d:f;if(o<=0&&i>0){let i=s-1;if(p>i){let e=c?new r(a+o,u,d+o,f):new r(a,u+o,d,f+o);l[n.encodeAddress(e.top,e.left)]=e}else if(m<t)l[n.encodeAddress(a,u)]=e;else if(!(p>=t&&m<=i)){let e=a,i=u,s=d,p=f;c?(e=a<t?a:t,s=Math.max(e,d+o)):(i=u<t?u:t,p=Math.max(i,f+o));let m=new r(e,i,s,p);e===s&&i===p||(l[n.encodeAddress(m.top,m.left)]=m)}}else if(p>=s){let e=c?new r(a+o,u,d+o,f):new r(a,u+o,d,f+o);l[n.encodeAddress(e.top,e.left)]=e}else m<s||(c?e.model.bottom=d+o:e.model.right=f+o),l[n.encodeAddress(a,u)]=e}this._merges=l;for(let e of Object.values(l)){let t=this.getCell(e.top,e.left);for(let n=e.top;n<=e.bottom;n++)for(let r=e.left;r<=e.right;r++)(n>e.top||r>e.left)&&this.getCell(n,r).merge(t,!0)}}get hasMerges(){return Object.values(this._merges).some(Boolean)}unMergeCells(...e){let t=new r(e);for(let e=t.top;e<=t.bottom;e++)for(let n=t.left;n<=t.right;n++){let t=this.findCell(e,n);t&&(t.type===u.ValueType.Merge?this._unMergeMaster(t.master):this._merges[t.address]&&this._unMergeMaster(t))}}fillFormula(e,t,r,i=`shared`){let{top:a,left:o,bottom:s,right:c}=n.decode(e),l=c-o+1,u=n.encodeAddress(a,o),d=i===`shared`,f;f=typeof r==`function`?r:Array.isArray(r)?Array.isArray(r[0])?(e,t)=>r[e-a][t-o]:(e,t)=>r[(e-a)*l+(t-o)]:()=>void 0;let p=!0;for(let n=a;n<=s;n++)for(let r=o;r<=c;r++)if(p){let a=this.getCell(n,r);a.value={shareType:i,formula:t,ref:e,result:f(n,r)},p=!1}else this.getCell(n,r).value=d?{sharedFormula:u,result:f(n,r)}:f(n,r)}addImage(e,t){let n={type:`image`,imageId:String(e),range:t};this._media.push(new de(this,n))}getImages(){return this._media.filter(e=>e.type===`image`)}addBackgroundImage(e){let t={type:`background`,imageId:String(e)};this._media.push(new de(this,t))}getBackgroundImageId(){let e=this._media.find(e=>e.type===`background`);return e&&e.imageId}addFormCheckbox(e,t){let n=new xe(this,e,t);return this.formControls.push(n),n}getFormCheckboxes(){return this.formControls}async protect(e,t){this.sheetProtection={sheet:!0},t&&`spinCount`in t&&(t.spinCount=Number.isFinite(t.spinCount)?Math.round(Math.max(0,t.spinCount)):1e5),e&&(this.sheetProtection.algorithmName=`SHA-512`,this.sheetProtection.saltValue=Re(ft.randomBytes(16)),this.sheetProtection.spinCount=t&&`spinCount`in t?t.spinCount:1e5,this.sheetProtection.hashValue=await ft.convertPasswordToHash(e,`SHA-512`,this.sheetProtection.saltValue,this.sheetProtection.spinCount)),t&&(this.sheetProtection=Object.assign(this.sheetProtection,t),!e&&`spinCount`in t&&delete this.sheetProtection.spinCount)}unprotect(){this.sheetProtection=null}addTable(e){let t=new pe(this,e);return this.tables[e.name]=t,t}getTable(e){return this.tables[e]}removeTable(e){delete this.tables[e]}getTables(){return Object.values(this.tables)}addPivotTable(e){let t=bt(this,e);return this.pivotTables.push(t),this.workbook.pivotTables.push(t),t}addConditionalFormatting(e){this.conditionalFormattings.push(e)}removeConditionalFormatting(e){typeof e==`number`?this.conditionalFormattings.splice(e,1):e instanceof Function?this.conditionalFormattings=this.conditionalFormattings.filter(e):this.conditionalFormattings=[]}get model(){let e={id:this.id,name:this.name,dataValidations:this.dataValidations.model,properties:this.properties,state:this.state,pageSetup:this.pageSetup,headerFooter:this.headerFooter,rowBreaks:this.rowBreaks,colBreaks:this.colBreaks,views:this.views,autoFilter:this.autoFilter,media:this._media.map(e=>e.model),sheetProtection:this.sheetProtection,tables:Object.values(this.tables).map(e=>e.model),pivotTables:this.pivotTables,conditionalFormattings:this.conditionalFormattings,formControls:this.formControls.map(e=>e.model),drawing:this._drawing};e.cols=O.toModel(this.columns??[]);let t=e.rows=[],n=e.dimensions=new r;return this._rows.forEach(e=>{let r=e&&e.model;r&&(n.expand(r.number,r.min,r.number,r.max),t.push(r))}),e.merges=[],Object.values(this._merges).forEach(t=>{e.merges.push(t.range)}),e}_parseRows(e){this._rows=[],e.rows&&e.rows.forEach(e=>{let t=new ce(this,e.number);this._rows[t.number-1]=t,t.model=e})}_parseMergeCells(e){e.mergeCells&&e.mergeCells.forEach(e=>{this.mergeCellsWithoutStyle(e)})}set model(e){this.name=e.name,this._columns=O.fromModel(this,e.cols),this._parseRows(e),this._parseMergeCells(e),this.dataValidations=new me(e.dataValidations),this.properties=e.properties,this.pageSetup=e.pageSetup,this.headerFooter=e.headerFooter,this.rowBreaks=e.rowBreaks??[],this.colBreaks=e.colBreaks??[],this.views=e.views,this.autoFilter=e.autoFilter,this._media=e.media.map(e=>new de(this,e)),this.sheetProtection=e.sheetProtection,this.tables=e.tables.reduce((e,t)=>{let n=new pe(this,t);return n.model=t,e[t.name]=n,e},{}),this.pivotTables=e.pivotTables,this.conditionalFormattings=e.conditionalFormattings,this.formControls=[],this._drawing=e.drawing}};function Ot(e){return typeof e==`number`?!0:e!==`__proto__`&&e!==`constructor`&&e!==`prototype`}function kt(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>kt(e));let t={};for(let n of Object.keys(e))Ot(n)&&(t[n]=kt(e[n]));return t}var At=class{constructor(e){this.template=e,this.sheets={}}addCell(e){this.addCellEx(n.decodeEx(e))}getCell(e){return this.findCellEx(n.decodeEx(e),!0)}findCell(e){return this.findCellEx(n.decodeEx(e),!1)}findCellAt(e,t,n){let r=this.sheets[e],i=r&&r[t];return i&&i[n]}addCellEx(e){if(e.top!==void 0)for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++)this.getCellAt(e.sheetName,t,n);else this.findCellEx(e,!0)}getCellEx(e){return this.findCellEx(e,!0)}findCellEx(e,t){let n=this.findSheet(e,t),r=this.findSheetRow(n,e,t);return this.findRowCell(r,e,t)}getCellAt(e,t,r){if(!Ot(e))throw Error(`Invalid sheet name: ${e}`);let i=this.sheets[e]||(this.sheets[e]=[]),a=i[t]||(i[t]=[]);return a[r]||(a[r]={sheetName:e,address:n.n2l(r)+t,row:t,col:r})}removeCellEx(e){let t=this.findSheet(e,!1);if(!t)return;let n=this.findSheetRow(t,e,!1);n&&delete n[e.col]}forEachInSheet(e,t){let n=this.sheets[e];n&&n.forEach((e,n)=>{e&&e.forEach((e,r)=>{e&&t(e,n,r)})})}forEach(e){Object.keys(this.sheets).forEach(t=>{this.forEachInSheet(t,e)})}map(e){let t=[];return this.forEach(n=>{t.push(e(n))}),t}findSheet(e,t){let n=e.sheetName;if(!Ot(n))throw Error(`Invalid sheet name: ${n}`);if(Object.prototype.hasOwnProperty.call(this.sheets,n))return this.sheets[n];if(t)return this.sheets[n]=[]}findSheetRow(e,t,n){let{row:r}=t;if(!Ot(r))throw Error(`Invalid row: ${r}`);if(e&&e[r])return e[r];if(n)return e[r]=[]}findRowCell(e,t,n){let{col:r}=t;if(!Ot(r))throw Error(`Invalid column: ${r}`);if(e&&e[r])return e[r];if(n)return e[r]=this.template?{...t,...kt(this.template)}:t}spliceRows(e,t,n,r){let i=this.sheets[e];if(i){let e=[];for(let t=0;t<r;t++)e.push([]);i.splice(t,n,...e)}}spliceColumns(e,t,n,r){let i=this.sheets[e];if(i){let e=[];for(let t=0;t<r;t++)e.push(null);Object.values(i).forEach(r=>{r.splice(t,n,...e)})}}};let jt=/[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;var Mt=class{constructor(){this.matrixMap={}}getMatrix(e){return this.matrixMap[e]||(this.matrixMap[e]=new At)}add(e,t){let r=n.decodeEx(e);`error`in r||this.addEx(r,t)}addEx(e,t){let r=this.getMatrix(t);if(`top`in e)for(let t=e.left;t<=e.right;t++)for(let i=e.top;i<=e.bottom;i++){let a={sheetName:e.sheetName,address:n.n2l(t)+i,row:i,col:t};r.addCellEx(a)}else r.addCellEx(e)}remove(e,t){let r=n.decodeEx(e);`error`in r||this.removeEx(r,t)}removeEx(e,t){let r=this.getMatrix(t);if(`top`in e)for(let t=e.left;t<=e.right;t++)for(let i=e.top;i<=e.bottom;i++)r.removeCellEx({sheetName:e.sheetName,address:n.n2l(t)+i,row:i,col:t});else r.removeCellEx(e)}removeAllNames(e){Object.values(this.matrixMap).forEach(t=>{if(`top`in e)for(let r=e.left;r<=e.right;r++)for(let i=e.top;i<=e.bottom;i++)t.removeCellEx({sheetName:e.sheetName,address:n.n2l(r)+i,row:i,col:r});else t.removeCellEx(e)})}forEach(e){Object.entries(this.matrixMap).forEach(([t,n])=>{n.forEach(n=>{e(t,n)})})}getNames(e){let t=n.decodeEx(e);return`error`in t||`top`in t?[]:this.getNamesEx(t)}getNamesEx(e){return Object.entries(this.matrixMap).map(([t,n])=>n.findCellEx(e,!1)&&t).filter(e=>!!e)}_explore(e,t){t.mark=!1;let{sheetName:n}=t,i=new r(t.row,t.col,t.row,t.col,n),a,o,s=(t,r)=>e.findCellAt(n,t,r);function c(e,n){let r=s(e,t.col);return!r||!r.mark?!1:(i[n]=e,r.mark=!1,!0)}for(o=t.row-1;c(o,`top`);o--);for(o=t.row+1;c(o,`bottom`);o++);function l(e,t){let n=[];for(o=i.top;o<=i.bottom;o++){let t=s(o,e);if(t&&t.mark)n.push(t);else return!1}i[t]=e;for(let e=0;e<n.length;e++)n[e].mark=!1;return!0}for(a=t.col-1;l(a,`left`);a--);for(a=t.col+1;l(a,`right`);a++);return i}getRanges(e,t){return t||=this.matrixMap[e],t?(t.forEach(e=>{e.mark=!0}),{name:e,ranges:t.map(e=>e.mark&&this._explore(t,e)).filter(Boolean).map(e=>e.$shortRange)}):{name:e,ranges:[]}}normaliseMatrix(e,t){e.forEachInSheet(t,(e,t,r)=>{e&&(e.row!==t||e.col!==r)&&(e.row=t,e.col=r,e.address=n.n2l(r)+t)})}spliceRows(e,t,n,r){Object.values(this.matrixMap).forEach(i=>{i.spliceRows(e,t,n,r),this.normaliseMatrix(i,e)})}spliceColumns(e,t,n,r){Object.values(this.matrixMap).forEach(i=>{i.spliceColumns(e,t,n,r),this.normaliseMatrix(i,e)})}get model(){return Object.entries(this.matrixMap).map(([e,t])=>this.getRanges(e,t)).filter(e=>e.ranges.length)}set model(e){let t=this.matrixMap={};e.forEach(e=>{let n=t[e.name]=new At;e.ranges.forEach(e=>{jt.test(e.split(`!`).pop()??``)&&n.addCell(e)})})}};let Nt=1e4;function Pt(e,t,n){e.push(` ${t}="${A(n.toString())}"`)}function Ft(e,t){if(t){let n=[];for(let e in t){if(!Object.prototype.hasOwnProperty.call(t,e))continue;let r=t[e];r!==void 0&&Pt(n,e,r)}e.push(n.join(``))}}var F=class{constructor(){this._xml=[],this._chunks=[],this._stack=[],this._rollbacks=[],this.leaf=!1,this.open=!1}_consolidate(){this._rollbacks.length>0||this._xml.length>=Nt&&(this._chunks.push(this._xml.join(``)),this._xml.length=0)}get tos(){return this._stack.length?this._stack[this._stack.length-1]:void 0}get cursor(){return this._chunks.length*Nt+this._xml.length}openXml(e){let t=this._xml;t.push(`<?xml`),Ft(t,e),t.push(`?>
8
8
  `)}openNode(e,t){let n=this.tos,r=this._xml;n&&this.open&&r.push(`>`),this._stack.push(e),r.push(`<`),r.push(e),Ft(r,t),this.leaf=!0,this.open=!0}addAttribute(e,t){if(!this.open)throw Error(`Cannot write attributes to node if it is not open`);t!==void 0&&Pt(this._xml,e,t)}addAttributes(e){if(!this.open)throw Error(`Cannot write attributes to node if it is not open`);Ft(this._xml,e)}writeText(e){let t=this._xml;this.open&&=(t.push(`>`),!1),this.leaf=!1,t.push(A(e.toString()))}writeXml(e){this.open&&=(this._xml.push(`>`),!1),this.leaf=!1,this._xml.push(e)}closeNode(){let e=this._stack.pop(),t=this._xml;this.leaf?t.push(`/>`):(t.push(`</`),t.push(e),t.push(`>`)),this.open=!1,this.leaf=!1,this._consolidate()}leafNode(e,t,n){this.openNode(e,t),n!==void 0&&this.writeText(n),this.closeNode()}closeAll(){for(;this._stack.length;)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf??!1,open:this.open??!1,chunksLength:this._chunks.length}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let e=this._rollbacks.pop();this._xml.length>e.xml&&(this._xml.length=e.xml),this._stack.length>e.stack&&(this._stack.length=e.stack),this._chunks.length>e.chunksLength&&(this._chunks.length=e.chunksLength),this.leaf=e.leaf,this.open=e.open}get xml(){return this.closeAll(),this._chunks.length===0?this._xml.join(``):(this._xml.length>0&&this._chunks.push(this._xml.join(``)),this._chunks.join(``))}static{this.StdDocAttributes={version:`1.0`,encoding:`UTF-8`,standalone:`yes`}}};let It=Array(128);for(let e=0;e<128;e++)It[e]=String.fromCharCode(e);function I(e){return e<128?It[e]:String.fromCodePoint(e)}let Lt=new Uint8Array(128);for(let e=97;e<=122;e++)Lt[e]=1;for(let e=65;e<=90;e++)Lt[e]=1;Lt[95]=1,Lt[58]=1;let Rt=new Uint8Array(128);for(let e=97;e<=122;e++)Rt[e]=1;for(let e=65;e<=90;e++)Rt[e]=1;for(let e=48;e<=57;e++)Rt[e]=1;Rt[95]=1,Rt[58]=1,Rt[45]=1,Rt[46]=1;function zt(e){return e===32||e===10||e===13||e===9}function Bt(e){return e===34||e===39}function Vt(e){return e<128?Lt[e]===1:e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e===8204||e===8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function Ht(e){return e<128?Rt[e]===1:e===183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=768&&e<=879||e>=880&&e<=893||e>=895&&e<=8191||e===8204||e===8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function Ut(e){return e>=32&&e<=55295||e===10||e===13||e===9||e>=57344&&e<=65533||e>=65536&&e<=1114111}let Wt={amp:`&`,gt:`>`,lt:`<`,quot:`"`,apos:`'`};var Gt=class{constructor(e){this.state=0,this.chunk=``,this.i=0,this.prevI=0,this.text=``,this.name=``,this.q=null,this.tags=[],this.tag=null,this.attribList=[],this.entity=``,this.entityReturnState=0,this.openWakaBang=``,this.sawRoot=!1,this.closedRoot=!1,this._closed=!1,this.reportedTextBeforeRoot=!1,this.reportedTextAfterRoot=!1,this.line=1,this.column=0,this.positionAtNewLine=0,this.chunkPosition=0,this.ENTITIES={...Wt},this.trackPosition=e?.position!==!1,this.fileName=e?.fileName,this.fragment=e?.fragment??!1,this._init()}get closed(){return this._closed}get position(){return this.chunkPosition+this.i}_init(){this.state=(this.fragment,0),this.text=``,this.name=``,this.q=null,this.tags=[],this.tag=null,this.attribList=[],this.entity=``,this.openWakaBang=``,this.sawRoot=this.fragment,this.closedRoot=this.fragment,this.reportedTextBeforeRoot=this.fragment,this.reportedTextAfterRoot=this.fragment,this.carriedFromPrevious=void 0,this._closed=!1,this.line=1,this.column=0,this.positionAtNewLine=0,this.chunkPosition=0,this.chunk=``,this.i=0,this.prevI=0}on(e,t){switch(e){case`text`:this.textHandler=t;break;case`opentag`:this.openTagHandler=t;break;case`closetag`:this.closeTagHandler=t;break;case`error`:this.errorHandler=t;break}}off(e){switch(e){case`text`:this.textHandler=void 0;break;case`opentag`:this.openTagHandler=void 0;break;case`closetag`:this.closeTagHandler=void 0;break;case`error`:this.errorHandler=void 0;break}}makeError(e){let t=this.fileName??``;return this.trackPosition&&(t.length>0&&(t+=`:`),t+=`${this.line}:${this.column}`),t.length>0&&(t+=`: `),Error(t+e)}fail(e){let t=this.makeError(e);if(this.errorHandler)this.errorHandler(t);else throw t;return this}write(e){if(this._closed)return this.fail(`cannot write after close`);let t=!1;e===null&&(t=!0,e=``),this.carriedFromPrevious!==void 0&&(e=this.carriedFromPrevious+e,this.carriedFromPrevious=void 0);let n=e.length;if(!t&&n>0){let t=e.charCodeAt(n-1);(t===13||t>=55296&&t<=56319)&&(this.carriedFromPrevious=e[n-1],n--,e=e.slice(0,n))}for(this.chunk=e,this.i=0;this.i<n;)this.processState();return this.chunkPosition+=n,t?this.end():this}close(){return this.write(null)}getCode(){let{chunk:e,i:t}=this;if(this.prevI=t,this.i=t+1,t>=e.length)return-1;let n=e.charCodeAt(t);if(n<10||n>13&&n<55296)return this.trackPosition&&this.column++,n;if(n>=55296&&n<=56319){let r=e.charCodeAt(t+1);if(r>=56320&&r<=57343)return this.i=t+2,this.trackPosition&&this.column++,65536+((n-55296)*1024+(r-56320))}return n===13?(e.charCodeAt(t+1)===10&&(this.i=t+2),this.trackPosition&&(this.line++,this.column=0,this.positionAtNewLine=this.position),10):(n===10&&this.trackPosition?(this.line++,this.column=0,this.positionAtNewLine=this.position):this.trackPosition&&this.column++,n)}unget(){this.i=this.prevI,this.trackPosition&&this.column--}processState(){switch(this.state){case 0:this.sText();break;case 1:this.sOpenWaka();break;case 2:this.sOpenWakaBang();break;case 3:this.sOpenTag();break;case 4:this.sOpenTagSlash();break;case 5:this.sAttrib();break;case 6:this.sAttribName();break;case 7:this.sAttribNameSawWhite();break;case 8:this.sAttribValue();break;case 9:this.sAttribValueQuoted();break;case 10:this.sAttribValueClosed();break;case 11:this.sCloseTag();break;case 12:this.sCloseTagSawWhite();break;case 13:this.sComment();break;case 14:this.sCommentEnding();break;case 15:this.sCommentEnded();break;case 16:this.sCData();break;case 17:this.sCDataEnding();break;case 18:this.sCDataEnding2();break;case 19:this.sPI();break;case 20:this.sPIEnding();break;case 21:this.sDoctype();break;case 22:this.sDoctypeQuote();break;case 23:this.sDoctypeDTD();break;case 24:this.sDoctypeDTDQuoted();break;case 25:this.sEntity();break}}sText(){this.tags.length===0?this.handleTextOutsideRoot():this.handleTextInRoot()}handleTextInRoot(){let{chunk:e}=this,{i:t}=this,n=this.textHandler;for(;;){let r=this.getCode();if(r===-1){n&&t<this.i&&(this.text+=e.slice(t,this.i));return}if(r===60){if(n){let r=e.slice(t,this.prevI);this.text.length>0?(n(this.text+r),this.text=``):r.length>0&&n(r)}this.state=1;return}if(r===38){n&&(this.text+=e.slice(t,this.prevI)),this.state=25,this.entityReturnState=0,this.entity=``;return}r===10&&(n&&(this.text+=e.slice(t,this.prevI)+`
9
9
  `),t=this.i)}}handleTextOutsideRoot(){let{chunk:e}=this,{i:t}=this,n=this.textHandler,r=!1;for(;;){let i=this.getCode();if(i===-1){n&&t<this.i&&(this.text+=e.slice(t,this.i));break}if(i===60){if(n){let r=e.slice(t,this.prevI);this.text.length>0?(n(this.text+r),this.text=``):r.length>0&&n(r)}this.state=1;break}if(i===38){n&&(this.text+=e.slice(t,this.prevI)),this.state=25,this.entityReturnState=0,this.entity=``,r=!0;break}i===10?(n&&(this.text+=e.slice(t,this.prevI)+`
10
- `),t=this.i):zt(i)||(r=!0)}r&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail(`text data outside of root node.`),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail(`text data outside of root node.`),this.reportedTextAfterRoot=!0))}sOpenWaka(){let e=this.getCode();if(Vt(e)){this.state=3,this.name=I(e);return}switch(e){case 47:this.state=11,this.name=``;break;case 33:this.state=2,this.openWakaBang=``;break;case 63:this.state=19,this.text=``;break;default:this.fail(`unexpected character in tag`),this.state=0}}sOpenWakaBang(){let e=this.getCode();switch(this.openWakaBang+=I(e),this.openWakaBang){case`[CDATA[`:this.state=16,this.text=``,this.openWakaBang=``;break;case`--`:this.state=13,this.text=``,this.openWakaBang=``;break;case`DOCTYPE`:this.state=21,this.text=``,this.openWakaBang=``;break;default:this.openWakaBang.length>=7&&(this.fail(`incorrect syntax`),this.state=0)}}sOpenTag(){let e=this.getCode();if(e!==-1){if(Ht(e)){this.name+=I(e);return}this.tag={name:this.name,attributes:Object.create(null),isSelfClosing:!1},this.attribList=[],this.sawRoot=!0,e===62?this.openTag():e===47?this.state=4:(zt(e)||this.fail(`unexpected character in tag`),this.state=5)}}sOpenTagSlash(){this.getCode()===62?this.openSelfClosingTag():(this.fail(`expected >`),this.state=5)}sAttrib(){let e=this.skipSpaces();e!==-1&&(Vt(e)?(this.name=I(e),this.state=6):e===62?this.openTag():e===47?this.state=4:this.fail(`unexpected character in attribute`))}sAttribName(){let e=this.getCode();if(e!==-1){if(Ht(e)){this.name+=I(e);return}e===61?this.state=8:zt(e)?this.state=7:e===62?(this.fail(`attribute without value`),this.attribList.push({name:this.name,value:this.name}),this.name=``,this.openTag()):this.fail(`unexpected character in attribute name`)}}sAttribNameSawWhite(){let e=this.skipSpaces();e!==-1&&(e===61?this.state=8:(this.fail(`attribute without value`),this.name=``,this.text=``,e===62?this.openTag():Vt(e)?(this.name=I(e),this.state=6):(this.fail(`unexpected character`),this.state=5)))}sAttribValue(){let e=this.skipSpaces();e!==-1&&(Bt(e)?(this.q=e,this.text=``,this.state=9):(this.fail(`unquoted attribute value`),this.state=0))}sAttribValueQuoted(){let{q:e,chunk:t}=this,{i:n}=this;for(;;){let r=this.getCode();if(r===-1){this.text+=t.slice(n,this.i);return}if(r===e){this.attribList.push({name:this.name,value:this.text+t.slice(n,this.prevI)}),this.name=``,this.text=``,this.q=null,this.state=10;return}if(r===38){this.text+=t.slice(n,this.prevI),this.state=25,this.entityReturnState=9,this.entity=``;return}if((r===10||r===9)&&(this.text+=t.slice(n,this.prevI)+` `,n=this.i),r===60){this.text+=t.slice(n,this.prevI),this.fail(`< not allowed in attribute value`);return}}}sAttribValueClosed(){let e=this.getCode();e!==-1&&(zt(e)?this.state=5:e===62?this.openTag():e===47?this.state=4:Vt(e)?(this.fail(`no whitespace between attributes`),this.name=I(e),this.state=6):this.fail(`unexpected character after attribute`))}sCloseTag(){let e=this.getCode();e!==-1&&(Ht(e)?this.name+=I(e):e===62?this.closeTag():zt(e)?this.state=12:this.fail(`unexpected character in close tag`))}sCloseTagSawWhite(){let e=this.skipSpaces();e!==-1&&(e===62?this.closeTag():this.fail(`unexpected character in close tag`))}sComment(){let e=this.getCode();e!==-1&&(e===45?this.state=14:this.text+=I(e))}sCommentEnding(){let e=this.getCode();e===45?this.state=15:(this.text+=`-`+I(e),this.state=13)}sCommentEnded(){let e=this.getCode();e===62?(this.text=``,this.state=0):e===45?this.text+=`-`:(this.fail(`malformed comment`),this.text+=`--`+I(e),this.state=13)}sCData(){let e=this.getCode();e!==-1&&(e===93?this.state=17:this.text+=I(e))}sCDataEnding(){let e=this.getCode();e===93?this.state=18:(this.text+=`]`+I(e),this.state=16)}sCDataEnding2(){let e=this.getCode();e===62?(this.textHandler&&this.text.length>0&&this.textHandler(this.text),this.text=``,this.state=0):e===93?this.text+=`]`:(this.text+=`]]`+I(e),this.state=16)}sPI(){let e=this.getCode();e!==-1&&(e===63?this.state=20:this.text+=I(e))}sPIEnding(){let e=this.getCode();e===62?(this.text=``,this.state=0):e===63?this.text+=`?`:(this.text+=`?`+I(e),this.state=19)}sDoctype(){let e=this.getCode();e!==-1&&(e===62?(this.text=``,this.state=0):Bt(e)?(this.q=e,this.state=22):e===91?this.state=23:this.text+=I(e))}sDoctypeQuote(){let e=this.getCode();e!==-1&&(e===this.q?(this.q=null,this.state=21):this.text+=I(e))}sDoctypeDTD(){let e=this.getCode();e!==-1&&(e===93?this.state=21:Bt(e)&&(this.q=e,this.state=24))}sDoctypeDTDQuoted(){let e=this.getCode();e!==-1&&e===this.q&&(this.q=null,this.state=23)}sEntity(){let e=this.getCode();if(e!==-1)if(e===59){let e=this.entity,t;e===``?(this.fail(`empty entity`),t=`&;`):t=this.parseEntity(e),this.text+=t,this.state=this.entityReturnState,this.entity=``}else Ht(e)||e===35?this.entity+=I(e):(this.fail(`invalid entity character`),this.text+=`&`+this.entity+I(e),this.state=this.entityReturnState,this.entity=``)}parseEntity(e){if(e[0]!==`#`){let t=this.ENTITIES[e];return t===void 0?(this.fail(`undefined entity: `+e),`&`+e+`;`):t}let t;return t=e[1]===`x`||e[1]===`X`?parseInt(e.slice(2),16):parseInt(e.slice(1),10),isNaN(t)||!Ut(t)?(this.fail(`invalid character entity`),`&`+e+`;`):String.fromCodePoint(t)}skipSpaces(){for(;;){let e=this.getCode();if(e===-1||!zt(e))return e}}openTag(){let e=this.tag;e.isSelfClosing=!1;for(let{name:t,value:n}of this.attribList)e.attributes[t]=n;this.attribList=[],this.openTagHandler?.(e),this.tags.push(e),this.name=``,this.state=0}openSelfClosingTag(){let e=this.tag;e.isSelfClosing=!0;for(let{name:t,value:n}of this.attribList)e.attributes[t]=n;this.attribList=[],this.openTagHandler?.(e),this.closeTagHandler?.(e),this.tags.length===0&&(this.closedRoot=!0),this.name=``,this.state=0}closeTag(){let{tags:e,name:t}=this;if(this.state=0,this.name=``,t===``){this.fail(`empty close tag`),this.text+=`</>`;return}let n=!1;for(let r=e.length-1;r>=0;r--)if(e[r].name===t){for(;e.length>r;){let t=e.pop();this.closeTagHandler?.(t),e.length>r&&this.fail(`unclosed tag: `+t.name)}n=!0;break}n||(this.fail(`unmatched close tag: `+t),this.text+=`</`+t+`>`),e.length===0&&(this.closedRoot=!0)}end(){for(this.sawRoot||this.fail(`document must contain a root element`);this.tags.length>0;){let e=this.tags.pop();this.fail(`unclosed tag: `+e.name)}return this.text.length>0&&this.textHandler&&(this.textHandler(this.text),this.text=``),this._closed=!0,this._init(),this}};async function*Kt(e){let t=new Gt({xmlns:!1,position:!0}),n;t.on(`error`,e=>{n=e});let r=[];t.on(`opentag`,e=>r.push({eventType:`opentag`,value:e})),t.on(`text`,e=>r.push({eventType:`text`,value:e})),t.on(`closetag`,e=>r.push({eventType:`closetag`,value:e}));for await(let i of e){let e=Le(i);if(t.write(e),n)throw n;yield r,r=[]}if(t.close(),n)throw n;r.length>0&&(yield r)}let qt=new Set([`ep`,`cp`,`dc`,`dcterms`,`dcmitype`,`vt`]);function Jt(e,t){for(let e in t)if(e.length>6&&e.startsWith(`xmlns:`)){let n=e.slice(6);if(t[e]===`http://schemas.openxmlformats.org/spreadsheetml/2006/main`)return n;if(qt.has(n))return null}let n=e.indexOf(`:`);return n!==-1&&qt.has(e.slice(0,n))?null:void 0}function Yt(e,t){let n=e.indexOf(`:`);if(n===-1)return e;let r=e.slice(0,n);return r===t||qt.has(r)?e.slice(n+1):e}var L=class e{prepare(e,t){}render(e,t){}parseOpen(e){}parseText(e){}parseClose(e){return!1}reconcile(e,t){}reset(){this.model=void 0,this.map&&Object.values(this.map).forEach(t=>{t instanceof e?t.reset():t.xform&&t.xform.reset()})}mergeModel(e){this.model=Object.assign(this.model||{},e)}async parse(e){let t=!1,n,r=0,i=null;for await(let a of e)if(!t){for(let{eventType:e,value:o}of a)if(e===`opentag`){if(r===1){this.parseOpen(o);continue}if(r===0){let e=Jt(o.name,o.attributes);if(e===void 0){r=1,this.parseOpen(o);continue}r=2,i=e}o.name=Yt(o.name,i),this.parseOpen(o)}else if(e===`text`)this.parseText(o);else if(e===`closetag`){if(r===1){if(!this.parseClose(o.name)){t=!0,n=this.model;break}continue}if(!this.parseClose(Yt(o.name,i))){t=!0,n=this.model;break}}}return t?n:this.model}async parseStream(e){return this.parse(Kt(e))}get xml(){return this.toXml(this.model)}toXml(e){let t=new F;return this.render(t,e),t.xml}static toAttribute(e,t,n=!1){if(e===void 0){if(n)return t}else if(n||e!==t)return e.toString()}static toStringAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toStringValue(e,t){return e===void 0?t:e}static toBoolAttribute(e,t,n=!1){if(e===void 0){if(n)return t}else if(n||e!==t)return e?`1`:`0`}static toBoolValue(e,t){return e===void 0?t:e===`1`}static toIntAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toIntValue(e,t){return e===void 0?t:parseInt(e,10)}static toFloatAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toFloatValue(e,t){return e===void 0?t:parseFloat(e)}};function Xt(e,t){e.openNode(t.tag,t.$),t.c&&t.c.forEach(t=>{Xt(e,t)}),t.t&&e.writeText(t.t),e.closeNode()}var Zt=class extends L{constructor(e){super(),this._model=e}render(e){if(!this._xml){let e=new F;Xt(e,this._model),this._xml=e.xml}e.writeXml(this._xml)}parseOpen(){return!0}parseText(){}parseClose(e){switch(e){case this._model.tag:return!1;default:return!0}}},R=class extends L{constructor(e){super(),this.tag=e.tag,this.always=!!e.always,this.count=e.count,this.empty=e.empty,this.$count=e.$count??`count`,this.$=e.$,this.childXform=e.childXform,this.maxItems=e.maxItems}prepare(e,t){let{childXform:n}=this;e&&e.forEach((e,r)=>{t.index=r,n.prepare(e,t)})}render(e,t){if(this.always||t&&t.length){e.openNode(this.tag,this.$),this.count&&e.addAttribute(this.$count,t?.length??0);let{childXform:n}=this;(t??[]).forEach((t,r)=>{n.render(e,t,r)}),e.closeNode()}else this.empty&&e.leafNode(this.tag)}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model=[],!0):this.childXform.parseOpen(e)?(this.parser=this.childXform,!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)&&(this.model.push(this.parser.model),this.parser=void 0,this.maxItems&&this.model.length>this.maxItems))throw Error(`Max ${this.childXform.tag} count (${this.maxItems}) exceeded`);return!0}return!1}reconcile(e,t){if(e){let{childXform:n}=this;e.forEach(e=>{n.reconcile(e,t)})}}reset(){super.reset(),this.childXform&&this.childXform.reset()}},z=class extends L{constructor(e){super(),this.name=e??`color`}get tag(){return this.name}render(e,t){return t?(e.openNode(this.name),t.argb?e.addAttribute(`rgb`,t.argb):t.theme===void 0?t.indexed===void 0?e.addAttribute(`auto`,`1`):e.addAttribute(`indexed`,t.indexed):(e.addAttribute(`theme`,t.theme),t.tint!==void 0&&e.addAttribute(`tint`,t.tint)),e.closeNode(),!0):!1}parseOpen(e){return e.name===this.name?(e.attributes.rgb?this.model={argb:e.attributes.rgb}:e.attributes.theme?(this.model={theme:parseInt(e.attributes.theme,10)},e.attributes.tint&&(this.model.tint=parseFloat(e.attributes.tint))):e.attributes.indexed?this.model={indexed:parseInt(e.attributes.indexed,10)}:this.model=void 0,!0):!1}parseText(){}parseClose(){return!1}},Qt=class extends L{constructor(e){super(),this.tag=e.tag,this.attr=e.attr}render(e,t){t&&(e.openNode(this.tag),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.model=!0)}parseText(){}parseClose(){return!1}},$t=class extends L{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.zero=e.zero,this.text=[]}render(e,t){(t||this.zero)&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,t):e.writeText(t),e.closeNode())}parseOpen(e){return e.name===this.tag?(this.attr?this.model=parseInt(e.attributes[this.attr],10):this.text=[],!0):!1}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=parseInt(this.text.join(``)||`0`,10)),!1}},B=class extends L{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.text=[]}render(e,t){t!==void 0&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,t):e.writeText(t),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.attr?this.model=e.attributes[this.attr]:this.text=[])}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=this.text.join(``)),!1}},en=class e extends L{static{this.Attributes={single:{},double:{val:`double`},singleAccounting:{val:`singleAccounting`},doubleAccounting:{val:`doubleAccounting`}}}constructor(e){super(),this.model=e}get tag(){return`u`}render(t,n){if(n||=this.model,n===!0)t.leafNode(`u`);else{let r=e.Attributes[n];r&&t.leafNode(`u`,r)}}parseOpen(e){e.name===`u`&&(this.model=e.attributes.val||!0)}parseText(){}parseClose(){return!1}},tn=class e extends L{constructor(t){super(),this.options=t||e.OPTIONS;let n=[{tag:`b`,prop:`bold`,xform:new Qt({tag:`b`,attr:`val`})},{tag:`i`,prop:`italic`,xform:new Qt({tag:`i`,attr:`val`})},{tag:`u`,prop:`underline`,xform:new en},{tag:`strike`,prop:`strike`,xform:new Qt({tag:`strike`,attr:`val`})},{tag:`condense`,prop:`condense`,xform:new Qt({tag:`condense`,attr:`val`})},{tag:`extend`,prop:`extend`,xform:new Qt({tag:`extend`,attr:`val`})},{tag:`outline`,prop:`outline`,xform:new Qt({tag:`outline`,attr:`val`})},{tag:`shadow`,prop:`shadow`,xform:new Qt({tag:`shadow`,attr:`val`})},{tag:`sz`,prop:`size`,xform:new $t({tag:`sz`,attr:`val`})},{tag:`color`,prop:`color`,xform:new z},{tag:this.options.fontNameTag,prop:`name`,xform:new B({tag:this.options.fontNameTag,attr:`val`})},{tag:`family`,prop:`family`,xform:new $t({tag:`family`,attr:`val`})},{tag:`scheme`,prop:`scheme`,xform:new B({tag:`scheme`,attr:`val`})},{tag:`charset`,prop:`charset`,xform:new $t({tag:`charset`,attr:`val`})},{tag:`vertAlign`,prop:`vertAlign`,xform:new B({tag:`vertAlign`,attr:`val`})}];this.map=Object.fromEntries(n.map(e=>[e.tag,{prop:e.prop,xform:e.xform}])),this.renderOrder=n.map(e=>e.tag)}get tag(){return this.options.tagName}render(e,t){let{map:n,renderOrder:r}=this;e.openNode(this.options.tagName),r.forEach(r=>{n[r].xform.render(e,t[n[r].prop])}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;if(this.map[e.name])return this.parser=this.map[e.name].xform,this.parser.parseOpen(e);switch(e.name){case this.options.tagName:return this.model={},!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser&&!this.parser.parseClose(e)){let t=this.map[e];return this.parser.model&&(this.model[t.prop]=this.parser.model),this.parser=void 0,!0}switch(e){case this.options.tagName:return!1;default:return!0}}static{this.OPTIONS={tagName:`font`,fontNameTag:`name`}}},nn=class extends L{constructor(){super(),this.map={color:new z}}get tag(){return`stop`}render(e,t){e.openNode(`stop`),e.addAttribute(`position`,t.position),this.map.color.render(e,t.color),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`stop`:return this.model={position:parseFloat(e.attributes.position)},!0;case`color`:return this.parser=this.map.color,this.parser.parseOpen(e),!0;default:return!1}}parseText(){}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model.color=this.parser.model,this.parser=void 0),!0):!1}},rn=class extends L{constructor(){super(),this.map={fgColor:new z(`fgColor`),bgColor:new z(`bgColor`)}}get name(){return`pattern`}get tag(){return`patternFill`}render(e,t){e.openNode(`patternFill`),e.addAttribute(`patternType`,t.pattern),t.fgColor&&this.map.fgColor.render(e,t.fgColor),t.bgColor&&this.map.bgColor.render(e,t.bgColor),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`patternFill`:return this.model={type:`pattern`,pattern:e.attributes.patternType},!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser.model&&(this.model[e]=this.parser.model),this.parser=void 0),!0):!1}},an=class extends L{constructor(){super(),this.map={stop:new nn}}get name(){return`gradient`}get tag(){return`gradientFill`}render(e,t){switch(e.openNode(`gradientFill`),t.gradient){case`angle`:e.addAttribute(`degree`,t.degree);break;case`path`:e.addAttribute(`type`,`path`),t.center.left&&(e.addAttribute(`left`,t.center.left),t.center.right===void 0&&e.addAttribute(`right`,t.center.left)),t.center.right&&e.addAttribute(`right`,t.center.right),t.center.top&&(e.addAttribute(`top`,t.center.top),t.center.bottom===void 0&&e.addAttribute(`bottom`,t.center.top)),t.center.bottom&&e.addAttribute(`bottom`,t.center.bottom);break;default:break}let n=this.map.stop;t.stops.forEach(t=>{n.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`gradientFill`:{let t=this.model={stops:[]};return e.attributes.degree?(t.gradient=`angle`,t.degree=parseInt(e.attributes.degree,10)):e.attributes.type===`path`&&(t.gradient=`path`,t.center={left:e.attributes.left?parseFloat(e.attributes.left):0,top:e.attributes.top?parseFloat(e.attributes.top):0},e.attributes.right!==e.attributes.left&&(t.center.right=e.attributes.right?parseFloat(e.attributes.right):0),e.attributes.bottom!==e.attributes.top&&(t.center.bottom=e.attributes.bottom?parseFloat(e.attributes.bottom):0)),!0}case`stop`:return this.parser=this.map.stop,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model.stops.push(this.parser.model),this.parser=void 0),!0):!1}},on=class e extends L{constructor(){super(),this.map={patternFill:new rn,gradientFill:new an}}get tag(){return`fill`}render(e,t){switch(e.addRollback(),e.openNode(`fill`),t.type){case`pattern`:this.map.patternFill.render(e,t);break;case`gradient`:this.map.gradientFill.render(e,t);break;default:e.rollback();return}e.closeNode(),e.commit()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`fill`:return this.model={},!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model=this.parser.model,this.model.type=this.parser.name,this.parser=void 0),!0):!1}validStyle(t){return e.validPatternValues[t]}static{this.validPatternValues=[`none`,`solid`,`darkVertical`,`darkGray`,`mediumGray`,`lightGray`,`gray125`,`gray0625`,`darkHorizontal`,`darkVertical`,`darkDown`,`darkUp`,`darkGrid`,`darkTrellis`,`lightHorizontal`,`lightVertical`,`lightDown`,`lightUp`,`lightGrid`,`lightTrellis`,`lightGrid`].reduce((e,t)=>(e[t]=!0,e),{})}static{this.StopXform=nn}static{this.PatternFillXform=rn}static{this.GradientFillXform=an}},sn=class e extends L{constructor(e){super(),this.name=e,this.map={color:new z}}get tag(){return this.name}render(e,t,n){let r=t&&t.color||n||this.defaultColor;e.openNode(this.name),t&&t.style&&(e.addAttribute(`style`,t.style),r&&this.map.color.render(e,r)),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.name:{let{style:t}=e.attributes;return t?this.model={style:t}:this.model=void 0,!0}case`color`:return this.parser=this.map.color,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):(e===this.name&&this.map.color.model&&(this.model||={},this.model.color=this.map.color.model),!1)}validStyle(t){return e.validStyleValues[t]}static{this.validStyleValues=[`thin`,`dashed`,`dotted`,`dashDot`,`hair`,`dashDotDot`,`slantDashDot`,`mediumDashed`,`mediumDashDotDot`,`mediumDashDot`,`medium`,`double`,`thick`].reduce((e,t)=>(e[t]=!0,e),{})}},cn=class extends L{constructor(){super(),this.map={top:new sn(`top`),left:new sn(`left`),bottom:new sn(`bottom`),right:new sn(`right`),diagonal:new sn(`diagonal`)}}render(e,t){let{color:n}=t;e.openNode(`border`),t.diagonal&&t.diagonal.style&&(t.diagonal.up&&e.addAttribute(`diagonalUp`,`1`),t.diagonal.down&&e.addAttribute(`diagonalDown`,`1`));let r=(r,i)=>{let a=r;a&&!a.color&&t.color&&(a={...a,color:t.color}),i.render(e,a,n)};r(t.left,this.map.left),r(t.right,this.map.right),r(t.top,this.map.top),r(t.bottom,this.map.bottom),r(t.diagonal,this.map.diagonal),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`border`:return this.reset(),this.diagonalUp=j(e.attributes.diagonalUp),this.diagonalDown=j(e.attributes.diagonalDown),!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;if(e===`border`){let e=this.model={},t=(t,n,r)=>{n&&(r&&Object.assign(n,r),e[t]=n)};t(`left`,this.map.left.model),t(`right`,this.map.right.model),t(`top`,this.map.top.model),t(`bottom`,this.map.bottom.model),t(`diagonal`,this.map.diagonal.model,{up:this.diagonalUp,down:this.diagonalDown})}return!1}};let ln={0:{f:`General`},1:{f:`0`},2:{f:`0.00`},3:{f:`#,##0`},4:{f:`#,##0.00`},9:{f:`0%`},10:{f:`0.00%`},11:{f:`0.00E+00`},12:{f:`# ?/?`},13:{f:`# ??/??`},14:{f:`mm-dd-yy`},15:{f:`d-mmm-yy`},16:{f:`d-mmm`},17:{f:`mmm-yy`},18:{f:`h:mm AM/PM`},19:{f:`h:mm:ss AM/PM`},20:{f:`h:mm`},21:{f:`h:mm:ss`},22:{f:`m/d/yy "h":mm`},27:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},28:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},29:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},30:{"zh-tw":`m/d/yy `,"zh-cn":`m-d-yy`,"ja-jp":`m/d/yy`,"ko-kr":`mm-dd-yy`},31:{"zh-tw":`yyyy"年"m"月"d"日"`,"zh-cn":`yyyy"年"m"月"d"日"`,"ja-jp":`yyyy"年"m"月"d"日"`,"ko-kr":`yyyy"년" mm"월" dd"일"`},32:{"zh-tw":`hh"時"mm"分"`,"zh-cn":`h"时"mm"分"`,"ja-jp":`h"時"mm"分"`,"ko-kr":`h"시" mm"분"`},33:{"zh-tw":`hh"時"mm"分"ss"秒"`,"zh-cn":`h"时"mm"分"ss"秒"`,"ja-jp":`h"時"mm"分"ss"秒"`,"ko-kr":`h"시" mm"분" ss"초"`},34:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`上午/下午 h"时"mm"分"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},35:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`上午/下午 h"时"mm"分"ss"秒"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},36:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},37:{f:`#,##0 ;(#,##0)`},38:{f:`#,##0 ;[Red](#,##0)`},39:{f:`#,##0.00 ;(#,##0.00)`},40:{f:`#,##0.00 ;[Red](#,##0.00)`},45:{f:`mm:ss`},46:{f:`[h]:mm:ss`},47:{f:`mmss.0`},48:{f:`##0.0E+0`},49:{f:`@`},50:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},51:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},52:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},53:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`m"月"d"日"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},54:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},55:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`上午/下午 h"时"mm"分"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},56:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`上午/下午 h"时"mm"分"ss"秒"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},57:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},58:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},59:{"th-th":`t0`},60:{"th-th":`t0.00`},61:{"th-th":`t#,##0`},62:{"th-th":`t#,##0.00`},67:{"th-th":`t0%`},68:{"th-th":`t0.00%`},69:{"th-th":`t# ?/?`},70:{"th-th":`t# ??/??`},81:{"th-th":`d/m/bb`}};function un(){let e={};return Object.entries(ln).forEach(([t,n])=>{n.f&&(e[n.f]=parseInt(t,10))}),e}let dn=un();var fn=class extends L{constructor(e,t){super(),this.id=e,this.formatCode=t}get tag(){return`numFmt`}render(e,t){e.leafNode(`numFmt`,{numFmtId:t.id,formatCode:t.formatCode})}parseOpen(e){switch(e.name){case`numFmt`:return this.model={id:parseInt(e.attributes.numFmtId,10),formatCode:e.attributes.formatCode.replace(/[\\](.)/g,`$1`)},!0;default:return!1}}parseText(){}parseClose(){return!1}static getDefaultFmtId(e){return dn[e]}static getDefaultFmtCode(e){return ln[e]&&ln[e].f}};let pn={ReadingOrder:{LeftToRight:1,RightToLeft:2}},mn={horizontalValues:[`left`,`center`,`right`,`fill`,`centerContinuous`,`distributed`,`justify`].reduce((e,t)=>(e[t]=!0,e),{}),horizontal(e){return this.horizontalValues[e]?e:void 0},verticalValues:[`top`,`middle`,`bottom`,`distributed`,`justify`].reduce((e,t)=>(e[t]=!0,e),{}),vertical(e){return e===`middle`?`center`:this.verticalValues[e]?e:void 0},wrapText(e){return e?!0:void 0},shrinkToFit(e){return e?!0:void 0},textRotation(e){switch(e){case`vertical`:return e;default:{let t=Ae(e);return t!==void 0&&t>=-90&&t<=90?t:void 0}}},indent(e){let t=Ae(e);return Math.max(0,t)},readingOrder(e){switch(e){case`ltr`:return pn.ReadingOrder.LeftToRight;case`rtl`:return pn.ReadingOrder.RightToLeft;default:return}}},hn={toXml(e){let t=mn.textRotation(e);if(t){if(t===`vertical`)return 255;let e=Math.round(t);if(e>=0&&e<=90)return e;if(e<0&&e>=-90)return 90-e}},toModel(e){let t=Ae(e);if(t!==void 0){if(t===255)return`vertical`;if(t>=0&&t<=90)return t;if(t>90&&t<=180)return 90-t}}};var gn=class extends L{get tag(){return`alignment`}render(e,t){e.addRollback(),e.openNode(`alignment`);let n=!1;function r(t,r){r&&(e.addAttribute(t,r),n=!0)}r(`horizontal`,mn.horizontal(t.horizontal)),r(`vertical`,mn.vertical(t.vertical)),r(`wrapText`,mn.wrapText(t.wrapText)?`1`:!1),r(`shrinkToFit`,mn.shrinkToFit(t.shrinkToFit)?`1`:!1),r(`indent`,mn.indent(t.indent)),r(`textRotation`,hn.toXml(t.textRotation)),r(`readingOrder`,mn.readingOrder(t.readingOrder)),e.closeNode(),n?e.commit():e.rollback()}parseOpen(e){let t={},n=!1;function r(e,r,i){e&&(t[r]=i,n=!0)}r(e.attributes.horizontal,`horizontal`,e.attributes.horizontal),r(e.attributes.vertical,`vertical`,e.attributes.vertical===`center`?`middle`:e.attributes.vertical),r(e.attributes.wrapText,`wrapText`,j(e.attributes.wrapText)),r(e.attributes.shrinkToFit,`shrinkToFit`,j(e.attributes.shrinkToFit)),r(e.attributes.indent,`indent`,parseInt(e.attributes.indent,10)),r(e.attributes.textRotation,`textRotation`,hn.toModel(e.attributes.textRotation)),r(e.attributes.readingOrder,`readingOrder`,e.attributes.readingOrder===`2`?`rtl`:`ltr`),this.model=n?t:null}parseText(){}parseClose(){return!1}};let _n={boolean(e,t){return e===void 0?t:e}};var vn=class extends L{get tag(){return`protection`}render(e,t){e.addRollback(),e.openNode(`protection`);let n=!1;function r(t,r){r!==void 0&&(e.addAttribute(t,r),n=!0)}r(`locked`,_n.boolean(t.locked,!0)?void 0:`0`),r(`hidden`,_n.boolean(t.hidden,!1)?`1`:void 0),e.closeNode(),n?e.commit():e.rollback()}parseOpen(e){let t={locked:e.attributes.locked!==`0`,hidden:e.attributes.hidden===`1`};this.model=!t.locked||t.hidden?t:null}parseText(){}parseClose(){return!1}},yn=class extends L{constructor(e){super(),this.xfId=!!(e&&e.xfId),this.map={alignment:new gn,protection:new vn}}get tag(){return`xf`}render(e,t){e.openNode(`xf`,{numFmtId:t.numFmtId??0,fontId:t.fontId??0,fillId:t.fillId??0,borderId:t.borderId??0}),this.xfId&&e.addAttribute(`xfId`,t.xfId??0),(t.applyNumberFormat||t.numFmtId)&&e.addAttribute(`applyNumberFormat`,`1`),(t.applyFont||t.fontId)&&e.addAttribute(`applyFont`,`1`),(t.applyFill||t.fillId)&&e.addAttribute(`applyFill`,`1`),(t.applyBorder||t.borderId)&&e.addAttribute(`applyBorder`,`1`),(t.applyAlignment||t.alignment)&&e.addAttribute(`applyAlignment`,`1`),(t.applyProtection||t.protection)&&e.addAttribute(`applyProtection`,`1`),t.pivotButton&&e.addAttribute(`pivotButton`,`1`),t.alignment&&this.map.alignment.render(e,t.alignment),t.protection&&this.map.protection.render(e,t.protection),t.checkbox&&t.xfComplementIndex!==void 0&&(e.openNode(`extLst`),e.openNode(`ext`,{"xmlns:xfpb":`http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag`,uri:`{C7286773-470A-42A8-94C5-96B5CB345126}`}),e.leafNode(`xfpb:xfComplement`,{i:t.xfComplementIndex}),e.closeNode(),e.closeNode()),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`xf`:this.model={numFmtId:parseInt(e.attributes.numFmtId,10),fontId:parseInt(e.attributes.fontId,10),fillId:parseInt(e.attributes.fillId,10),borderId:parseInt(e.attributes.borderId,10)},this.xfId&&(this.model.xfId=parseInt(e.attributes.xfId,10)),e.attributes.pivotButton===`1`&&(this.model.pivotButton=!0);for(let t of[`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])e.attributes[t]===`1`&&(this.model[t]=!0);return!0;case`alignment`:return this.parser=this.map.alignment,this.parser.parseOpen(e),!0;case`protection`:return this.parser=this.map.protection,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.map.protection===this.parser?this.model.protection=this.parser.model:this.model.alignment=this.parser.model,this.parser=void 0),!0):e!==`xf`}},bn=class extends L{constructor(){super(),this.map={alignment:new gn,border:new cn,fill:new on,font:new tn,numFmt:new fn,protection:new vn}}get tag(){return`dxf`}render(e,t){if(e.openNode(this.tag),t.font&&this.map.font.render(e,t.font),t.numFmt&&t.numFmtId){let n={id:t.numFmtId,formatCode:t.numFmt};this.map.numFmt.render(e,n)}t.fill&&this.map.fill.render(e,t.fill),t.alignment&&this.map.alignment.render(e,t.alignment),t.border&&this.map.border.render(e,t.border),t.protection&&this.map.protection.render(e,t.protection),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:return this.reset(),!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):e===this.tag?(this.model={alignment:this.map.alignment.model,border:this.map.border.model,fill:this.map.fill.model,font:this.map.font.model,numFmt:this.map.numFmt.model,protection:this.map.protection.model},!1):!0}},xn=class e extends L{constructor(t){super(),this.map={numFmts:new R({tag:`numFmts`,count:!0,childXform:new fn}),fonts:new R({tag:`fonts`,count:!0,childXform:new tn,$:{"x14ac:knownFonts":1}}),fills:new R({tag:`fills`,count:!0,childXform:new on}),borders:new R({tag:`borders`,count:!0,childXform:new cn}),cellStyleXfs:new R({tag:`cellStyleXfs`,count:!0,childXform:new yn}),cellXfs:new R({tag:`cellXfs`,count:!0,childXform:new yn({xfId:!0})}),dxfs:new R({tag:`dxfs`,always:!0,count:!0,childXform:new bn}),numFmt:new fn,font:new tn,fill:new on,border:new cn,style:new yn({xfId:!0}),cellStyles:e.STATIC_XFORMS.cellStyles,tableStyles:e.STATIC_XFORMS.tableStyles,extLst:e.STATIC_XFORMS.extLst},t&&this.init()}initIndex(){this.index={style:{},numFmt:{},numFmtNextId:164,font:{},border:{},fill:{}}}init(){this.model={styles:[],numFmts:[],fonts:[],borders:[],fills:[],dxfs:[]},this.initIndex(),this._addBorder({}),this._addStyle({numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}),this._addFill({type:`pattern`,pattern:`none`}),this._addFill({type:`pattern`,pattern:`gray125`}),this.weakMap=new WeakMap,this._hasCheckboxes=!1}setDefaultFont(e){this.defaultFont=e}render(t,n){let r=n||this.model;t.openXml(F.StdDocAttributes),t.openNode(`styleSheet`,e.STYLESHEET_ATTRIBUTES),this.index?(r.numFmts&&r.numFmts.length&&(t.openNode(`numFmts`,{count:r.numFmts.length}),r.numFmts.forEach(e=>{t.writeXml(e)}),t.closeNode()),r.fonts.length||this._addFont(this.defaultFont||{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`}),t.openNode(`fonts`,{count:r.fonts.length,"x14ac:knownFonts":1}),r.fonts.forEach(e=>{t.writeXml(e)}),t.closeNode(),t.openNode(`fills`,{count:r.fills.length}),r.fills.forEach(e=>{t.writeXml(e)}),t.closeNode(),t.openNode(`borders`,{count:r.borders.length}),r.borders.forEach(e=>{t.writeXml(e)}),t.closeNode(),this.map.cellStyleXfs.render(t,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),t.openNode(`cellXfs`,{count:r.styles.length}),r.styles.forEach(e=>{t.writeXml(e)}),t.closeNode()):(this.map.numFmts.render(t,r.numFmts),this.map.fonts.render(t,r.fonts),this.map.fills.render(t,r.fills),this.map.borders.render(t,r.borders),this.map.cellStyleXfs.render(t,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),this.map.cellXfs.render(t,r.styles)),e.STATIC_XFORMS.cellStyles.render(t),this.map.dxfs.render(t,r.dxfs),e.STATIC_XFORMS.tableStyles.render(t),e.STATIC_XFORMS.extLst.render(t),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`styleSheet`:return this.initIndex(),!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`styleSheet`:{this.model={};let e=(e,t)=>{t.model&&t.model.length&&(this.model[e]=t.model)};if(e(`numFmts`,this.map.numFmts),e(`fonts`,this.map.fonts),e(`fills`,this.map.fills),e(`borders`,this.map.borders),e(`styles`,this.map.cellXfs),e(`dxfs`,this.map.dxfs),this.map.fonts.model&&this.map.fonts.model.length>0&&(this.defaultFont=this.map.fonts.model[0]),this.index={model:[],numFmt:{}},this.model.numFmts){let e=this.index.numFmt;this.model.numFmts.forEach(t=>{e[t.id]=t.formatCode})}return!1}default:return!0}}addStyleModel(e,t){if(!e)return 0;this.model.fonts.length||this._addFont(this.defaultFont||{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`});let n=t||u.ValueType.Number;if(n!==u.ValueType.Checkbox&&this.weakMap&&this.weakMap.has(e))return this.weakMap.get(e);let r={};if(e.numFmt)r.numFmtId=this._addNumFmtStr(e.numFmt);else switch(n){case u.ValueType.Number:r.numFmtId=this._addNumFmtStr(`General`);break;case u.ValueType.Date:r.numFmtId=this._addNumFmtStr(`mm-dd-yy`);break;default:break}e.font&&(r.fontId=this._addFont(e.font)),e.border&&(r.borderId=this._addBorder(e.border)),e.fill&&(r.fillId=this._addFill(e.fill)),e.alignment&&(r.alignment=e.alignment),e.protection&&(r.protection=e.protection);for(let t of[`pivotButton`,`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])e[t]&&(r[t]=!0);n===u.ValueType.Checkbox&&(this._hasCheckboxes=!0,r.alignment=r.alignment||{},r.checkbox=!0,r.xfComplementIndex=0);let i=this._addStyle(r);return n!==u.ValueType.Checkbox&&this.weakMap&&this.weakMap.set(e,i),i}getStyleModel(e){let t=this.model.styles[e];if(!t)return null;let n=this.index.model[e];if(n)return n;if(n=this.index.model[e]={},t.numFmtId){let e=this.index.numFmt[t.numFmtId]||fn.getDefaultFmtCode(t.numFmtId);e&&(n.numFmt=e)}function r(e,t,r){if(r||r===0){let i=t[r];i&&(n[e]=i)}}r(`font`,this.model.fonts,t.fontId),r(`border`,this.model.borders,t.borderId),r(`fill`,this.model.fills,t.fillId),t.alignment&&(n.alignment=t.alignment),t.protection&&(n.protection=t.protection);for(let e of[`pivotButton`,`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])t[e]&&(n[e]=!0);return n}addDxfStyle(e){return e.numFmt&&(e.numFmtId=this._addNumFmtStr(e.numFmt)),this.model.dxfs.push(e),this.model.dxfs.length-1}getDxfStyle(e){return this.model.dxfs[e]}get hasCheckboxes(){return!!this._hasCheckboxes}_addStyle(e){let t=this.map.style.toXml(e),n=this.index.style[t];return n===void 0&&(n=this.index.style[t]=this.model.styles.length,this.model.styles.push(t)),n}_addNumFmtStr(e){let t=fn.getDefaultFmtId(e);if(t!==void 0||(t=this.index.numFmt[e],t!==void 0))return t;t=this.index.numFmt[e]=164+this.model.numFmts.length;let n=this.map.numFmt.toXml({id:t,formatCode:e});return this.model.numFmts.push(n),t}_addFont(e){let t=this.map.font.toXml(e),n=this.index.font[t];return n===void 0&&(n=this.index.font[t]=this.model.fonts.length,this.model.fonts.push(t)),n}_addBorder(e){let t=this.map.border.toXml(e),n=this.index.border[t];return n===void 0&&(n=this.index.border[t]=this.model.borders.length,this.model.borders.push(t)),n}_addFill(e){let t=this.map.fill.toXml(e),n=this.index.fill[t];return n===void 0&&(n=this.index.fill[t]=this.model.fills.length,this.model.fills.push(t)),n}static{this.STYLESHEET_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"mc:Ignorable":`x14ac x16r2`,"xmlns:x14ac":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac`,"xmlns:x16r2":`http://schemas.microsoft.com/office/spreadsheetml/2015/02/main`}}static{this.STATIC_XFORMS={cellStyles:new Zt({tag:`cellStyles`,$:{count:1},c:[{tag:`cellStyle`,$:{name:`Normal`,xfId:0,builtinId:0}}]}),dxfs:new Zt({tag:`dxfs`,$:{count:0}}),tableStyles:new Zt({tag:`tableStyles`,$:{count:0,defaultTableStyle:`TableStyleMedium2`,defaultPivotStyle:`PivotStyleLight16`}}),extLst:new Zt({tag:`extLst`,c:[{tag:`ext`,$:{uri:`{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`},c:[{tag:`x14:slicerStyles`,$:{defaultSlicerStyle:`SlicerStyleLight1`}}]},{tag:`ext`,$:{uri:`{9260A510-F301-46a8-8635-F512D64BE5F5}`,"xmlns:x15":`http://schemas.microsoft.com/office/spreadsheetml/2010/11/main`},c:[{tag:`x15:timelineStyles`,$:{defaultTimelineStyle:`TimeSlicerStyleLight1`}}]}]})}}};xn.Mock=class extends xn{constructor(){super(),this.model={styles:[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}],numFmts:[],fonts:[{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`}],borders:[{}],fills:[{type:`pattern`,pattern:`none`},{type:`pattern`,pattern:`gray125`}]}}parseStream(e){return e.autodrain(),Promise.resolve()}addStyleModel(e,t){switch(t){case u.ValueType.Checkbox:throw Error(`Checkbox cells require styles to be enabled (useStyles: true)`);case u.ValueType.Date:return this.dateStyleId;default:return 0}}get hasCheckboxes(){return!1}get dateStyleId(){if(!this._dateStyleId){let e={numFmtId:fn.getDefaultFmtId(`mm-dd-yy`)};this._dateStyleId=this.model.styles.length,this.model.styles.push(e)}return this._dateStyleId}getStyleModel(){return{}}};var Sn=class extends L{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.text=[],this._format=e.format||function(e){try{return Number.isNaN(e.getTime())?``:e.toISOString()}catch{return``}},this._parse=e.parse||function(e){return new Date(e)}}render(e,t){t&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,this._format(t)):e.writeText(this._format(t)),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.attr?this.model=this._parse(e.attributes[this.attr]):this.text=[])}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=this._parse(this.text.join(``))),!1}};let V={creator:`dc:creator`,title:`dc:title`,subject:`dc:subject`,description:`dc:description`,identifier:`dc:identifier`,language:`dc:language`,keywords:`cp:keywords`,category:`cp:category`,lastModifiedBy:`cp:lastModifiedBy`,lastPrinted:`cp:lastPrinted`,revision:`cp:revision`,version:`cp:version`,contentStatus:`cp:contentStatus`,contentType:`cp:contentType`,created:`dcterms:created`,modified:`dcterms:modified`};var Cn=class e extends L{constructor(){super(),this.map={creator:new B({tag:V.creator}),title:new B({tag:V.title}),subject:new B({tag:V.subject}),description:new B({tag:V.description}),identifier:new B({tag:V.identifier}),language:new B({tag:V.language}),keywords:new B({tag:V.keywords}),category:new B({tag:V.category}),lastModifiedBy:new B({tag:V.lastModifiedBy}),lastPrinted:new Sn({tag:V.lastPrinted,format:e.DateFormat}),revision:new $t({tag:V.revision}),version:new B({tag:V.version}),contentStatus:new B({tag:V.contentStatus}),contentType:new B({tag:V.contentType}),created:new Sn({tag:V.created,attrs:e.DateAttrs,format:e.DateFormat}),modified:new Sn({tag:V.modified,attrs:e.DateAttrs,format:e.DateFormat})}}render(t,n){t.openXml(F.StdDocAttributes),t.openNode(`cp:coreProperties`,e.CORE_PROPERTY_ATTRIBUTES);for(let e of Object.keys(V))this.map[e].render(t,n[e]);t.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):(e.name!==`coreProperties`&&(this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e)),!0)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;if(e===`coreProperties`){this.model={};for(let e of Object.keys(V)){let t=this.map[e].model;t!==void 0&&t!==``&&(this.model[e]=t)}return!1}return!0}static{this.DateFormat=function(e){return e.toISOString().replace(/[.]\d{3}/,``)}}static{this.DateAttrs={"xsi:type":`dcterms:W3CDTF`}}static{this.CORE_PROPERTY_ATTRIBUTES={"xmlns:cp":`http://schemas.openxmlformats.org/package/2006/metadata/core-properties`,"xmlns:dc":`http://purl.org/dc/elements/1.1/`,"xmlns:dcterms":`http://purl.org/dc/terms/`,"xmlns:dcmitype":`http://purl.org/dc/dcmitype/`,"xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`}}},wn=class extends L{get tag(){return`t`}render(e,t){e.openNode(`t`),/^\s|\n|\s$/.test(t)&&e.addAttribute(`xml:space`,`preserve`),e.writeText(t),e.closeNode()}parseOpen(e){return e.name===`t`?(this._text=[],this.model=``,!0):!1}parseText(e){this._text.push(e),this.model=this._text.join(``).replace(/_x([0-9A-F]{4})_/g,(e,t)=>String.fromCharCode(parseInt(t,16)))}parseClose(){return!1}},Tn=class e extends L{constructor(e){super(),this.model=e}get tag(){return`r`}get textXform(){return this._textXform||=new wn}get fontXform(){return this._fontXform||=new tn(e.FONT_OPTIONS)}render(e,t){let n=t||this.model;e.openNode(`r`),n.font&&this.fontXform.render(e,n.font),this.textXform.render(e,n.text),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`r`:return this.model={},!0;case`t`:return this.parser=this.textXform,this.parser.parseOpen(e),!0;case`rPr`:return this.parser=this.fontXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){switch(e){case`r`:return!1;case`t`:return this.model.text=this.parser.model,this.parser=void 0,!0;case`rPr`:return this.model.font=this.parser.model,this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(e),!0}}static{this.FONT_OPTIONS={tagName:`rPr`,fontNameTag:`rFont`}}},En=class extends L{constructor(){super(),this.map={r:new Tn,t:new wn}}get tag(){return`rPh`}render(e,t){if(e.openNode(this.tag,{sb:t.sb??0,eb:t.eb??0}),t&&Object.prototype.hasOwnProperty.call(t,`richText`)&&t.richText){let{r:n}=this.map;t.richText.forEach(t=>{n.render(e,t)})}else t&&this.map.t.render(e,t.text);e.closeNode()}parseOpen(e){let{name:t}=e;return this.parser?(this.parser.parseOpen(e),!0):t===this.tag?(this.model={sb:parseInt(e.attributes.sb,10),eb:parseInt(e.attributes.eb,10)},!0):(this.parser=this.map[t],this.parser?(this.parser.parseOpen(e),!0):!1)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){switch(e){case`r`:{let e=this.model.richText;e||=this.model.richText=[],e.push(this.parser.model);break}case`t`:this.model.text=this.parser.model;break;default:break}this.parser=void 0}return!0}switch(e){case this.tag:return!1;default:return!0}}},Dn=class extends L{constructor(e){super(),this.model=e,this.map={r:new Tn,t:new wn,rPh:new En}}get tag(){return`si`}render(e,t){e.openNode(this.tag),t&&typeof t==`object`&&Object.prototype.hasOwnProperty.call(t,`richText`)&&t.richText?t.richText.length?t.richText.forEach(t=>{this.map.r.render(e,t)}):this.map.t.render(e,``):t!=null&&this.map.t.render(e,t),e.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model={},!0):(this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){switch(e){case`r`:{let e=this.model.richText;e||=this.model.richText=[],e.push(this.parser.model);break}case`t`:this.model=this.parser.model;break;default:break}this.parser=void 0}return!0}switch(e){case this.tag:return!1;default:return!0}}},On=class extends L{constructor(e){super(),this.model=e||{values:[],count:0},this.hash=Object.create(null),this.rich=Object.create(null)}get sharedStringXform(){return this._sharedStringXform||=new Dn}get values(){return this.model.values}get uniqueCount(){return this.model.values.length}get count(){return this.model.count}getString(e){return this.model.values[e]}add(e){return e.richText?this.addRichText(e):this.addText(e)}addText(e){let t=this.hash[e];return t===void 0&&(t=this.hash[e]=this.model.values.length,this.model.values.push(e)),this.model.count++,t}addRichText(e){let t=this.sharedStringXform.toXml(e),n=this.rich[t];return n===void 0&&(n=this.rich[t]=this.model.values.length,this.model.values.push(e)),this.model.count++,n}render(e,t){let n=t||this._values;e.openXml(F.StdDocAttributes),e.openNode(`sst`,{xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,count:n.count,uniqueCount:n.values.length});let r=this.sharedStringXform;n.values.forEach(t=>{r.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`sst`:return!0;case`si`:return this.parser=this.sharedStringXform,this.parser.parseOpen(e),!0;default:throw Error(`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.values.push(this.parser.model),this.model.count++,this.parser=void 0),!0;switch(e){case`sst`:return!1;default:throw Error(`Unexpected xml node in parseClose: ${e}`)}}},kn=class extends L{render(e,t){e.leafNode(`Relationship`,t)}parseOpen(e){switch(e.name){case`Relationship`:return this.model=e.attributes,!0;default:return!1}}parseText(){}parseClose(){return!1}},H=class e extends L{constructor(){super(),this.map={Relationship:new kn}}render(t,n){let r=n||this._values;t.openXml(F.StdDocAttributes),t.openNode(`Relationships`,e.RELATIONSHIPS_ATTRIBUTES),r.forEach(e=>{this.map.Relationship.render(t,e)}),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`Relationships`:return this.model=[],!0;default:if(this.parser=this.map[e.name],this.parser)return this.parser.parseOpen(e),!0;throw Error(`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.push(this.parser.model),this.parser=void 0),!0;switch(e){case`Relationships`:return!1;default:throw Error(`Unexpected xml node in parseClose: ${e}`)}}static{this.RELATIONSHIPS_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/package/2006/relationships`}}};let U={contentTypes:`[Content_Types].xml`,rootRels:`_rels/.rels`,docPropsApp:`docProps/app.xml`,docPropsCore:`docProps/core.xml`,xlWorkbook:`xl/workbook.xml`,xlWorkbookRels:`xl/_rels/workbook.xml.rels`,xlSharedStrings:`xl/sharedStrings.xml`,xlStyles:`xl/styles.xml`,xlTheme1:`xl/theme/theme1.xml`,xlFeaturePropertyBag:`xl/featurePropertyBag/featurePropertyBag.xml`},An=/^xl\/worksheets\/sheet(\d+)[.]xml$/,jn=/^xl\/worksheets\/_rels\/sheet(\d+)[.]xml[.]rels$/,Mn=/^xl\/theme\/[a-zA-Z0-9]+[.]xml$/,Nn=/^xl\/media\/([a-zA-Z0-9]+[.][a-zA-Z0-9]{3,4})$/,Pn=/^xl\/drawings\/(drawing\d+)[.]xml$/,Fn=/^xl\/drawings\/_rels\/(drawing\d+)[.]xml[.]rels$/,In=/^xl\/drawings\/(vmlDrawing\d+)[.]vml$/,Ln=/^xl\/comments(\d+)[.]xml$/,Rn=/^xl\/tables\/(table\d+)[.]xml$/,zn=/^xl\/pivotTables\/(pivotTable\d+)[.]xml$/,Bn=/^xl\/pivotTables\/_rels\/(pivotTable\d+)[.]xml[.]rels$/,Vn=/^xl\/pivotCache\/(pivotCacheDefinition\d+)[.]xml$/,Hn=/^xl\/pivotCache\/_rels\/(pivotCacheDefinition\d+)[.]xml[.]rels$/,Un=/^xl\/pivotCache\/(pivotCacheRecords\d+)[.]xml$/;function Wn(e){return e.startsWith(`/`)?e.slice(1):e}function Gn(e){let t=An.exec(e);if(t)return parseInt(t[1],10)}function Kn(e){let t=jn.exec(e);if(t)return parseInt(t[1],10)}function qn(e){return e.startsWith(`xl/media/`)}function Jn(e){let t=Nn.exec(e);return t?t[1]:void 0}function Yn(e){return Mn.test(e)}function Xn(e){let t=/^xl\/theme\/([a-zA-Z0-9]+)[.]xml$/.exec(e);return t?t[1]:void 0}function Zn(e){return qn(e)||Yn(e)}function Qn(e){let t=Pn.exec(e);return t?t[1]:void 0}function $n(e){let t=Fn.exec(e);return t?t[1]:void 0}function er(e){let t=In.exec(e);return t?t[1]:void 0}function tr(e){let t=Ln.exec(e);return t?t[1]:void 0}function nr(e){let t=Rn.exec(e);return t?t[1]:void 0}function rr(e){let t=zn.exec(e);return t?t[1]:void 0}function ir(e){let t=Bn.exec(e);return t?t[1]:void 0}function ar(e){let t=Vn.exec(e);return t?t[1]:void 0}function or(e){let t=Hn.exec(e);return t?t[1]:void 0}function sr(e){let t=Un.exec(e);return t?t[1]:void 0}function W(e){return e.startsWith(`/`)?e:`/${e}`}function cr(e){return`xl/theme/${e}.xml`}function lr(e){return`xl/media/${e}`}function ur(e){return`xl/worksheets/sheet${e}.xml`}function dr(e){return`xl/worksheets/_rels/sheet${e}.xml.rels`}function fr(e){return`worksheets/sheet${e}.xml`}function pr(e){return`xl/comments${e}.xml`}function mr(e){return`xl/${e}.xml`}function hr(e){return`xl/drawings/vmlDrawing${e}.vml`}function gr(e){return`xl/tables/${e}`}function _r(e){return`xl/drawings/${e}.xml`}function vr(e){return`xl/drawings/_rels/${e}.xml.rels`}function yr(e){return`xl/pivotCache/pivotCacheDefinition${e}.xml`}function br(e){return`xl/pivotCache/_rels/pivotCacheDefinition${e}.xml.rels`}function xr(e){return`xl/pivotCache/pivotCacheRecords${e}.xml`}function Sr(e){return`pivotCacheRecords${e}.xml`}function Cr(e){return`xl/pivotTables/pivotTable${e}.xml`}function wr(e){return`xl/pivotTables/_rels/pivotTable${e}.xml.rels`}function Tr(e){return`../pivotCache/pivotCacheDefinition${e}.xml`}let Er={workbookStyles:`styles.xml`,workbookSharedStrings:`sharedStrings.xml`,workbookTheme1:`theme/theme1.xml`,workbookFeaturePropertyBag:`featurePropertyBag/featurePropertyBag.xml`};function Dr(e){return`pivotCache/pivotCacheDefinition${e}.xml`}function Or(e){return`../comments${e}.xml`}function kr(e){return`../drawings/vmlDrawing${e}.vml`}function Ar(e){return`../drawings/${e}.xml`}function jr(e){return`../drawings/${e}.vml`}function Mr(e){return`../${e}.xml`}function Nr(e){return`../pivotTables/pivotTable${e}.xml`}function Pr(e){return`../pivotTables/${e}.xml`}function Fr(e){return`../tables/${e}`}function Ir(e){return`../tables/${e}.xml`}function Lr(e){return`../media/${e}`}function Rr(e){return`xl/ctrlProps/ctrlProp${e}.xml`}function zr(e){return`../ctrlProps/ctrlProp${e}.xml`}var Br=class e extends L{render(t,n){t.openXml(F.StdDocAttributes),t.openNode(`Types`,e.PROPERTY_ATTRIBUTES);let r={};if((n.media??[]).forEach(e=>{if(e.type===`image`){let n=e.extension;r[n]||(r[n]=!0,t.leafNode(`Default`,{Extension:n,ContentType:`image/${n}`}))}}),t.leafNode(`Default`,{Extension:`rels`,ContentType:`application/vnd.openxmlformats-package.relationships+xml`}),t.leafNode(`Default`,{Extension:`xml`,ContentType:`application/xml`}),t.leafNode(`Override`,{PartName:W(U.xlWorkbook),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml`}),n.worksheets.forEach((e,n)=>{let r=e.fileIndex||n+1;t.leafNode(`Override`,{PartName:W(ur(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml`})}),(n.pivotTables??[]).length){let e=new Set;(n.pivotTables??[]).forEach(n=>{let r=n.tableNumber,i=n.cacheId;e.has(i)||(e.add(i),t.leafNode(`Override`,{PartName:W(yr(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml`}),(!n.isLoaded||n.cacheRecords)&&t.leafNode(`Override`,{PartName:W(xr(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml`})),t.leafNode(`Override`,{PartName:W(Cr(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml`})})}t.leafNode(`Override`,{PartName:W(U.xlTheme1),ContentType:`application/vnd.openxmlformats-officedocument.theme+xml`}),t.leafNode(`Override`,{PartName:W(U.xlStyles),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml`}),n.hasCheckboxes&&t.leafNode(`Override`,{PartName:W(U.xlFeaturePropertyBag),ContentType:`application/vnd.ms-excel.featurepropertybag+xml`}),n.sharedStrings&&n.sharedStrings.count&&t.leafNode(`Override`,{PartName:W(U.xlSharedStrings),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml`}),n.tables&&n.tables.forEach(e=>{t.leafNode(`Override`,{PartName:W(gr(e.target)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml`})}),n.drawings&&n.drawings.forEach(e=>{t.leafNode(`Override`,{PartName:W(_r(e.name)),ContentType:`application/vnd.openxmlformats-officedocument.drawing+xml`})});let i=n.commentRefs&&n.commentRefs.length>0,a=n.formControlRefs&&n.formControlRefs.length>0;if((i||a)&&t.leafNode(`Default`,{Extension:`vml`,ContentType:`application/vnd.openxmlformats-officedocument.vmlDrawing`}),i&&n.commentRefs.forEach(({commentName:e})=>{t.leafNode(`Override`,{PartName:W(mr(e)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml`})}),a)for(let e of n.formControlRefs)t.leafNode(`Override`,{PartName:W(Rr(e)),ContentType:`application/vnd.ms-excel.controlproperties+xml`});if(n.passthroughContentTypes)for(let{partName:e,contentType:r}of n.passthroughContentTypes)t.leafNode(`Override`,{PartName:W(e),ContentType:r});t.leafNode(`Override`,{PartName:W(U.docPropsCore),ContentType:`application/vnd.openxmlformats-package.core-properties+xml`}),t.leafNode(`Override`,{PartName:W(U.docPropsApp),ContentType:`application/vnd.openxmlformats-officedocument.extended-properties+xml`}),t.closeNode()}parseOpen(){return!1}parseText(){}parseClose(){return!1}static{this.PROPERTY_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/package/2006/content-types`}}},Vr=class extends L{render(e,t){e.openNode(`HeadingPairs`),e.openNode(`vt:vector`,{size:2,baseType:`variant`}),e.openNode(`vt:variant`),e.leafNode(`vt:lpstr`,void 0,`Worksheets`),e.closeNode(),e.openNode(`vt:variant`),e.leafNode(`vt:i4`,void 0,t.length),e.closeNode(),e.closeNode(),e.closeNode()}parseOpen(e){return e.name===`HeadingPairs`}parseText(){}parseClose(e){return e!==`HeadingPairs`}},Hr=class extends L{render(e,t){e.openNode(`TitlesOfParts`),e.openNode(`vt:vector`,{size:t.length,baseType:`lpstr`}),t.forEach(t=>{e.leafNode(`vt:lpstr`,void 0,t.name)}),e.closeNode(),e.closeNode()}parseOpen(e){return e.name===`TitlesOfParts`}parseText(){}parseClose(e){return e!==`TitlesOfParts`}},Ur=class e extends L{constructor(){super(),this.map={Company:new B({tag:`Company`}),Manager:new B({tag:`Manager`}),HeadingPairs:new Vr,TitlesOfParts:new Hr}}render(t,n){t.openXml(F.StdDocAttributes),t.openNode(`Properties`,e.PROPERTY_ATTRIBUTES),t.leafNode(`Application`,void 0,`Microsoft Excel`),t.leafNode(`DocSecurity`,void 0,`0`),t.leafNode(`ScaleCrop`,void 0,`false`),this.map.HeadingPairs.render(t,n.worksheets),this.map.TitlesOfParts.render(t,n.worksheets),this.map.Company.render(t,n.company??``),this.map.Manager.render(t,n.manager),t.leafNode(`LinksUpToDate`,void 0,`false`),t.leafNode(`SharedDoc`,void 0,`false`),t.leafNode(`HyperlinksChanged`,void 0,`false`),t.leafNode(`AppVersion`,void 0,`16.0300`),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`Properties`:return!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`Properties`:return this.model={worksheets:this.map.TitlesOfParts.model,company:this.map.Company.model,manager:this.map.Manager.model},!1;default:return!0}}static{this.DateFormat=function(e){return e.toISOString().replace(/[.]\d{3,6}/,``)}}static{this.DateAttrs={"xsi:type":`dcterms:W3CDTF`}}static{this.PROPERTY_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/officeDocument/2006/extended-properties`,"xmlns:vt":`http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes`}}},Wr=class extends L{constructor(){super(),this._parsedText=[]}render(e,t){e.openNode(`definedName`,{name:t.name,localSheetId:t.localSheetId}),e.writeText(t.ranges.join(`,`)),e.closeNode()}parseOpen(e){switch(e.name){case`definedName`:return this._parsedName=e.attributes.name,this._parsedLocalSheetId=e.attributes.localSheetId,this._parsedText=[],!0;default:return!1}}parseText(e){this._parsedText.push(e)}parseClose(){return this.model={name:this._parsedName,ranges:Yr(this._parsedText.join(``))},this._parsedLocalSheetId!==void 0&&(this.model.localSheetId=parseInt(this._parsedLocalSheetId,10)),!1}};let Gr=/^[$]?[A-Za-z]{1,3}[$]?\d+(:[$]?[A-Za-z]{1,3}[$]?\d+)?$/,Kr=/^[$]?\d+:[$]?\d+$/,qr=/^[$]?[A-Za-z]{1,3}:[$]?[A-Za-z]{1,3}$/;function Jr(e){if(e.startsWith(`{`)||e.endsWith(`}`))return!1;let t=e.split(`!`).pop()??``;if(!Gr.test(t)&&!Kr.test(t)&&!qr.test(t))return!1;try{let t=n.decodeEx(e);return`row`in t&&typeof t.row==`number`||`top`in t&&typeof t.top==`number`||`left`in t&&typeof t.left==`number`}catch{return!1}}function Yr(e){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`))return[];let n=[],r=!1,i=``;return e.split(`,`).forEach(e=>{if(!e)return;let t=(e.match(/'/g)??[]).length;if(!t){r?i+=`${e},`:Jr(e)&&n.push(e);return}let a=t%2==0;!r&&a&&Jr(e)?n.push(e):r&&!a?(r=!1,Jr(i+e)&&n.push(i+e),i=``):(r=!0,i+=`${e},`)}),n}var Xr=class extends L{render(e,t){e.leafNode(`sheet`,{name:t.name,sheetId:t.id,state:t.state===`visible`?void 0:t.state,"r:id":t.rId})}parseOpen(e){return e.name===`sheet`?(this.model={name:Oe(e.attributes.name),id:parseInt(e.attributes.sheetId,10),state:e.attributes.state,rId:e.attributes[`r:id`]},!0):!1}parseText(){}parseClose(){return!1}},Zr=class extends L{render(e,t){let n={xWindow:t.x??0,yWindow:t.y??0,windowWidth:t.width??12e3,windowHeight:t.height??24e3,firstSheet:t.firstSheet,activeTab:t.activeTab};t.visibility&&t.visibility!==`visible`&&(n.visibility=t.visibility),e.leafNode(`workbookView`,n)}parseOpen(e){if(e.name===`workbookView`){let t=this.model={},n=function(e,n,r){t[e]=n===void 0?r:n},r=function(e,n,r){let i=n===void 0?r:parseInt(n,10);i!==void 0&&(t[e]=i)};return r(`x`,e.attributes.xWindow,0),r(`y`,e.attributes.yWindow,0),r(`width`,e.attributes.windowWidth,25e3),r(`height`,e.attributes.windowHeight,1e4),n(`visibility`,e.attributes.visibility,`visible`),r(`activeTab`,e.attributes.activeTab,void 0),r(`firstSheet`,e.attributes.firstSheet,void 0),!0}return!1}parseText(){}parseClose(){return!1}},Qr=class extends L{render(e,t){e.leafNode(`workbookPr`,{date1904:t.date1904?1:void 0,filterPrivacy:1})}parseOpen(e){return e.name===`workbookPr`?(this.model={date1904:e.attributes.date1904===`1`},!0):!1}parseText(){}parseClose(){return!1}},$r=class extends L{render(e,t){e.leafNode(`calcPr`,{calcId:171027,fullCalcOnLoad:t.fullCalcOnLoad?1:void 0})}parseOpen(e){return e.name===`calcPr`?(this.model={},!0):!1}parseText(){}parseClose(){return!1}},ei=class extends L{render(e,t){e.leafNode(`pivotCache`,{cacheId:t.cacheId,"r:id":t.rId})}parseOpen(e){return e.name===`pivotCache`?(this.model={cacheId:e.attributes.cacheId,rId:e.attributes[`r:id`]},!0):!1}parseText(){}parseClose(){return!1}},ti=class e extends L{constructor(){super(),this.map={fileVersion:e.STATIC_XFORMS.fileVersion,workbookPr:new Qr,bookViews:new R({tag:`bookViews`,count:!1,childXform:new Zr}),sheets:new R({tag:`sheets`,count:!1,childXform:new Xr}),definedNames:new R({tag:`definedNames`,count:!1,childXform:new Wr}),calcPr:new $r,pivotCaches:new R({tag:`pivotCaches`,count:!1,childXform:new ei})}}prepare(e){e.sheets=e.worksheets;let t=[],n=0;e.sheets.forEach(e=>{if(e.pageSetup&&e.pageSetup.printArea&&e.pageSetup.printArea.split(`&&`).forEach(r=>{let i=r.split(`:`),a={name:`_xlnm.Print_Area`,ranges:[`'${e.name}'!$${i[0]}:$${i[1]}`],localSheetId:n};t.push(a)}),e.pageSetup&&(e.pageSetup.printTitlesRow||e.pageSetup.printTitlesColumn)){let r=[];if(e.pageSetup.printTitlesColumn){let t=e.pageSetup.printTitlesColumn.split(`:`);r.push(`'${e.name}'!$${t[0]}:$${t[1]}`)}if(e.pageSetup.printTitlesRow){let t=e.pageSetup.printTitlesRow.split(`:`);r.push(`'${e.name}'!$${t[0]}:$${t[1]}`)}let i={name:`_xlnm.Print_Titles`,ranges:r,localSheetId:n};t.push(i)}n++}),t.length&&(e.definedNames=e.definedNames.concat(t)),(e.media??[]).forEach((e,t)=>{e.name=e.type+(t+1)})}render(t,n){t.openXml(F.StdDocAttributes),t.openNode(`workbook`,e.WORKBOOK_ATTRIBUTES),this.map.fileVersion.render(t),this.map.workbookPr.render(t,n.properties),this.map.bookViews.render(t,n.views),this.map.sheets.render(t,n.sheets),this.map.definedNames.render(t,n.definedNames),this.map.calcPr.render(t,n.calcProperties);let r=n.pivotTables??[],i=new Set,a=r.filter(e=>i.has(e.cacheId)?!1:(i.add(e.cacheId),!0));this.map.pivotCaches.render(t,a),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`workbook`:return!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`workbook`:return this.model={sheets:this.map.sheets.model,properties:this.map.workbookPr.model||{},views:this.map.bookViews.model,calcProperties:{}},this.map.definedNames.model&&(this.model.definedNames=this.map.definedNames.model),this.map.pivotCaches.model&&this.map.pivotCaches.model.length>0&&(this.model.pivotCaches=this.map.pivotCaches.model),!1;default:return!0}}reconcile(e){let t=(e.workbookRels??[]).reduce((e,t)=>(e[t.Id]=t,e),{}),r=[],i,a=0;(e.sheets??[]).forEach(n=>{let o=t[n.rId];o&&(i=e.worksheetHash[`xl/${o.Target.replace(/^(\s|\/xl\/)+/,``)}`],i&&(i.name=n.name,i.id=n.id,i.state=n.state,r[a++]=i))});let o=[];e.definedNames&&e.definedNames.forEach(e=>{if(e.name===`_xlnm.Print_Area`){if(i=r[e.localSheetId],i){i.pageSetup||={};let t=n.decodeEx(e.ranges[0]);i.pageSetup.printArea=i.pageSetup.printArea?`${i.pageSetup.printArea}&&${t.dimensions}`:t.dimensions}}else if(e.name===`_xlnm.Print_Titles`){if(i=r[e.localSheetId],i){i.pageSetup||={};let t=e.ranges.join(`,`),n=/\$/g,r=t.match(/\$\d+:\$\d+/);if(r&&r.length){let e=r[0];i.pageSetup.printTitlesRow=e.replace(n,``)}let a=t.match(/\$[A-Z]+:\$[A-Z]+/);if(a&&a.length){let e=a[0];i.pageSetup.printTitlesColumn=e.replace(n,``)}}}else o.push(e)}),e.definedNames=o,e.media.forEach((e,t)=>{e.index=t})}static{this.WORKBOOK_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"mc:Ignorable":`x15`,"xmlns:x15":`http://schemas.microsoft.com/office/spreadsheetml/2010/11/main`}}static{this.STATIC_XFORMS={fileVersion:new Zt({tag:`fileVersion`,$:{appName:`xl`,lastEdited:5,lowestEdited:5,rupBuild:9303}})}}};let G={OfficeDocument:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument`,Worksheet:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet`,CalcChain:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain`,SharedStrings:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings`,Styles:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles`,Theme:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme`,Hyperlink:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`,Image:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`,CoreProperties:`http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties`,ExtenderProperties:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties`,Comments:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments`,VmlDrawing:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing`,Table:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/table`,PivotCacheDefinition:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition`,PivotCacheRecords:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords`,PivotTable:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable`,FeaturePropertyBag:`http://schemas.microsoft.com/office/2022/11/relationships/FeaturePropertyBag`,CtrlProp:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp`};var ni=class{constructor(){this.merges={}}add(e){if(this.merges[e.master])this.merges[e.master].expandToAddress(e.address);else{let t=`${e.master}:${e.address}`;this.merges[e.master]=new r(t)}}get mergeCells(){return Object.values(this.merges).map(e=>e.range)}reconcile(e,t){e.forEach(e=>{let r=n.decode(e);for(let e=r.top;e<=r.bottom;e++){let i=t[e-1];for(let t=r.left;t<=r.right;t++){let a=i.cells[t-1];a?a.type===u.ValueType.Merge&&(a.master=r.tl):i.cells[t]={type:u.ValueType.Null,address:n.encodeAddress(e,t)}}}})}getMasterAddress(e){let t=this.hash[e];return t&&t.tl}};function ri(e){if(e==null)return u.ValueType.Null;if(e instanceof String||typeof e==`string`)return u.ValueType.String;if(typeof e==`number`)return u.ValueType.Number;if(typeof e==`boolean`)return u.ValueType.Boolean;if(e instanceof Date)return u.ValueType.Date;if(e.text&&e.hyperlink)return u.ValueType.Hyperlink;if(e.formula)return u.ValueType.Formula;if(e.error)return u.ValueType.Error;throw Error(`I could not understand type of value`)}function ii(e){switch(e.type){case u.ValueType.Formula:return ri(e.result);default:return e.type}}var ai=class extends L{constructor(){super(),this.richTextXform=new Tn}get tag(){return`c`}prepare(e,t){let n=t.styles.addStyleModel(e.style||{},ii(e));switch(n&&(e.styleId=n),e.comment&&t.comments.push({...e.comment,ref:e.address}),e.type){case u.ValueType.String:case u.ValueType.RichText:t.sharedStrings&&(e.ssId=t.sharedStrings.add(e.value));break;case u.ValueType.Date:t.date1904&&(e.date1904=!0);break;case u.ValueType.Hyperlink:t.sharedStrings&&e.text!==void 0&&e.text!==null&&(e.ssId=t.sharedStrings.add(e.text)),t.hyperlinks.push({address:e.address,target:e.hyperlink,tooltip:e.tooltip});break;case u.ValueType.Merge:t.merges.add(e);break;case u.ValueType.Formula:if(t.date1904&&(e.date1904=!0),e.shareType===`shared`&&(e.si=t.siFormulae++),e.formula)t.formulae[e.address]=e;else if(e.sharedFormula){let n=t.formulae[e.sharedFormula];if(!n)throw Error(`Shared Formula master must exist above and or left of clone for cell ${e.address}`);n.si===void 0?(n.shareType=`shared`,n.si=t.siFormulae++,n.range=new r(n.address,e.address)):n.range&&n.range.expandToAddress(e.address),e.si=n.si}break;default:break}}renderFormula(e,t){let n=null;switch(t.shareType){case`shared`:n={t:`shared`,ref:t.ref||t.range.range,si:t.si};break;case`array`:n={t:`array`,ref:t.ref};break;default:t.si!==void 0&&(n={t:`shared`,si:t.si});break}switch(ri(t.result)){case u.ValueType.Null:e.leafNode(`f`,n,t.formula);break;case u.ValueType.String:e.addAttribute(`t`,`str`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result);break;case u.ValueType.Number:e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result);break;case u.ValueType.Boolean:e.addAttribute(`t`,`b`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result?1:0);break;case u.ValueType.Error:e.addAttribute(`t`,`e`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result.error);break;case u.ValueType.Date:e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,we(t.result,t.date1904));break;default:throw Error(`I could not understand type of value`)}}render(e,t){if(!(t.type===u.ValueType.Null&&!t.styleId)){switch(e.openNode(`c`),e.addAttribute(`r`,t.address),t.styleId&&e.addAttribute(`s`,t.styleId),t.type){case u.ValueType.Null:break;case u.ValueType.Number:e.leafNode(`v`,null,t.value);break;case u.ValueType.Boolean:e.addAttribute(`t`,`b`),e.leafNode(`v`,null,t.value?`1`:`0`);break;case u.ValueType.Checkbox:e.addAttribute(`t`,`b`),e.leafNode(`v`,null,t.value?`1`:`0`);break;case u.ValueType.Error:e.addAttribute(`t`,`e`),e.leafNode(`v`,null,t.value.error);break;case u.ValueType.String:case u.ValueType.RichText:t.ssId===void 0?t.value&&t.value.richText?(e.addAttribute(`t`,`inlineStr`),e.openNode(`is`),t.value.richText.forEach(t=>{this.richTextXform.render(e,t)}),e.closeNode(`is`)):(e.addAttribute(`t`,`str`),e.leafNode(`v`,null,t.value)):(e.addAttribute(`t`,`s`),e.leafNode(`v`,null,t.ssId));break;case u.ValueType.Date:e.leafNode(`v`,null,we(t.value,t.date1904));break;case u.ValueType.Hyperlink:t.ssId===void 0?(e.addAttribute(`t`,`str`),e.leafNode(`v`,null,t.text)):(e.addAttribute(`t`,`s`),e.leafNode(`v`,null,t.ssId));break;case u.ValueType.Formula:this.renderFormula(e,t);break;case u.ValueType.Merge:break;default:break}e.closeNode()}}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`c`:return this.model={address:e.attributes.r},this.t=e.attributes.t,e.attributes.s&&(this.model.styleId=parseInt(e.attributes.s,10)),!0;case`f`:return this.currentNode=`f`,this.model.si=e.attributes.si,this.model.shareType=e.attributes.t,this.model.ref=e.attributes.ref,!0;case`v`:return this.currentNode=`v`,!0;case`t`:return this.currentNode=`t`,!0;case`r`:return this.parser=this.richTextXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){if(this.parser){this.parser.parseText(e);return}switch(this.currentNode){case`f`:this.model.formula=this.model.formula?this.model.formula+e:e;break;case`v`:case`t`:this.model.value&&this.model.value.richText?this.model.value.richText.text=this.model.value.richText.text?this.model.value.richText.text+e:e:this.model.value=this.model.value?this.model.value+e:e;break;default:break}}parseClose(e){switch(e){case`c`:{let{model:e}=this;if(e.formula||e.shareType)e.type=u.ValueType.Formula,e.value&&=(this.t===`str`?e.result=Oe(e.value):this.t===`b`?e.result=parseInt(e.value,10)!==0:this.t===`e`?e.result={error:e.value}:e.result=parseFloat(e.value),void 0);else if(e.value!==void 0)switch(this.t){case`s`:e.type=u.ValueType.String,e.value=parseInt(e.value,10);break;case`str`:e.type=u.ValueType.String,e.value=Oe(e.value);break;case`inlineStr`:e.type=u.ValueType.String;break;case`b`:e.type=u.ValueType.Boolean,e.value=parseInt(e.value,10)!==0;break;case`e`:e.type=u.ValueType.Error,e.value={error:e.value};break;case`d`:e.type=u.ValueType.Date,e.value=new Date(e.value);break;default:e.type=u.ValueType.Number,e.value=parseFloat(e.value);break}else e.styleId?e.type=u.ValueType.Null:e.type=u.ValueType.Merge;return!1}case`f`:case`v`:case`is`:return this.currentNode=void 0,!0;case`t`:return this.parser?(this.parser.parseClose(e),!0):(this.currentNode=void 0,!0);case`r`:return this.model.value=this.model.value||{},this.model.value.richText=this.model.value.richText??[],this.model.value.richText.push(this.parser.model),this.parser=void 0,this.currentNode=void 0,!0;default:return this.parser?(this.parser.parseClose(e),!0):!1}}reconcile(e,t){let n=e.styleId!==void 0&&t.styles&&t.styles.getStyleModel(e.styleId);switch(n&&(e.style=n),e.styleId!==void 0&&(e.styleId=void 0),e.type){case u.ValueType.String:typeof e.value==`number`&&t.sharedStrings&&(e.value=t.sharedStrings.getString(e.value)),e.value.richText&&(e.type=u.ValueType.RichText);break;case u.ValueType.Number:n&&je(n.numFmt)&&(e.type=u.ValueType.Date,e.value=Te(e.value,t.date1904));break;case u.ValueType.Formula:e.result!==void 0&&typeof e.result==`number`&&n&&je(n.numFmt)&&(e.result=Te(e.result,t.date1904)),e.shareType===`shared`&&(e.ref?t.formulae[e.si]=e.address:(e.sharedFormula=t.formulae[e.si],delete e.shareType),delete e.si);break;default:break}let r=t.hyperlinkMap[e.address];r&&(e.type===u.ValueType.Formula?(e.text=e.result,e.result=void 0):(e.text=e.value,e.value=void 0),e.type=u.ValueType.Hyperlink,e.hyperlink=r);let i=t.commentsMap&&t.commentsMap[e.address];i&&(e.comment=i)}},oi=class extends L{constructor(e){super(),this.maxItems=e&&e.maxItems,this.map={c:new ai}}get tag(){return`row`}reset(){super.reset(),this.numRowsSeen=0,this.lastCellCol=0}prepare(e,t){let n=t.styles.addStyleModel(e.style);n&&(e.styleId=n);let r=this.map.c;e.cells.forEach(e=>{r.prepare(e,t)})}render(e,t,n){if(!t)return;e.openNode(`row`),e.addAttribute(`r`,t.number),t.height&&(e.addAttribute(`ht`,t.height),e.addAttribute(`customHeight`,`1`)),t.hidden&&e.addAttribute(`hidden`,`1`),t.min>0&&t.max>0&&t.min<=t.max&&e.addAttribute(`spans`,`${t.min}:${t.max}`),t.styleId&&(e.addAttribute(`s`,t.styleId),e.addAttribute(`customFormat`,`1`)),t.dyDescent!==void 0&&e.addAttribute(`x14ac:dyDescent`,t.dyDescent),t.outlineLevel&&e.addAttribute(`outlineLevel`,t.outlineLevel),t.collapsed&&e.addAttribute(`collapsed`,`1`);let r=this.map.c;t.cells.forEach(t=>{r.render(e,t,n)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;if(e.name===`row`){this.numRowsSeen+=1,this.lastCellCol=0;let t=e.attributes.spans?e.attributes.spans.split(`:`).map(e=>parseInt(e,10)):[void 0,void 0],n=this.model={number:e.attributes.r?parseInt(e.attributes.r,10):this.numRowsSeen,min:t[0],max:t[1],cells:[]};return e.attributes.s&&(n.styleId=parseInt(e.attributes.s,10)),j(e.attributes.hidden)&&(n.hidden=!0),j(e.attributes.bestFit)&&(n.bestFit=!0),e.attributes.ht&&(n.height=parseFloat(e.attributes.ht)),e.attributes.outlineLevel&&(n.outlineLevel=parseInt(e.attributes.outlineLevel,10)),j(e.attributes.collapsed)&&(n.collapsed=!0),e.attributes[`x14ac:dyDescent`]!==void 0&&(n.dyDescent=parseFloat(e.attributes[`x14ac:dyDescent`])),!0}return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){let e=this.parser.model;if(e.address?this.lastCellCol=n.decodeAddress(e.address).col:(this.lastCellCol+=1,e.address=n.encodeAddress(this.model.number,this.lastCellCol)),this.model.cells.push(e),this.maxItems&&this.model.cells.length>this.maxItems)throw Error(`Max column count (${this.maxItems}) exceeded`);this.parser=void 0}return!0}return!1}reconcile(e,t){e.style=e.styleId===void 0?{}:t.styles.getStyleModel(e.styleId),e.styleId!==void 0&&(e.styleId=void 0);let n=this.map.c;e.cells.forEach(e=>{n.reconcile(e,t)})}},si=class extends L{get tag(){return`col`}prepare(e,t){let n=t.styles.addStyleModel(e.style||{});n&&(e.styleId=n)}render(e,t){e.openNode(`col`),e.addAttribute(`min`,t.min),e.addAttribute(`max`,t.max),t.width&&e.addAttribute(`width`,t.width),t.styleId&&e.addAttribute(`style`,t.styleId),t.hidden&&e.addAttribute(`hidden`,`1`),t.bestFit&&e.addAttribute(`bestFit`,`1`),t.outlineLevel&&e.addAttribute(`outlineLevel`,t.outlineLevel),t.collapsed&&e.addAttribute(`collapsed`,`1`),e.addAttribute(`customWidth`,`1`),e.closeNode()}parseOpen(e){if(e.name===`col`){let t=this.model={min:parseInt(e.attributes.min??`0`,10),max:parseInt(e.attributes.max??`0`,10),width:e.attributes.width===void 0?void 0:parseFloat(e.attributes.width??`0`)};return e.attributes.style&&(t.styleId=parseInt(e.attributes.style,10)),j(e.attributes.hidden)&&(t.hidden=!0),j(e.attributes.bestFit)&&(t.bestFit=!0),e.attributes.outlineLevel&&(t.outlineLevel=parseInt(e.attributes.outlineLevel,10)),j(e.attributes.collapsed)&&(t.collapsed=!0),!0}return!1}parseText(){}parseClose(){return!1}reconcile(e,t){e.styleId!==void 0&&(e.style=t.styles.getStyleModel(e.styleId))}},ci=class extends L{get tag(){return`dimension`}render(e,t){t&&e.leafNode(`dimension`,{ref:t})}parseOpen(e){return e.name===`dimension`?(this.model=e.attributes.ref,!0):!1}parseText(){}parseClose(){return!1}},li=class extends L{get tag(){return`hyperlink`}render(e,t){this.isInternalLink(t)?e.leafNode(`hyperlink`,{ref:t.address,"r:id":t.rId,tooltip:t.tooltip,location:t.target}):e.leafNode(`hyperlink`,{ref:t.address,"r:id":t.rId,tooltip:t.tooltip})}parseOpen(e){return e.name===`hyperlink`?(this.model={address:e.attributes.ref,rId:e.attributes[`r:id`],tooltip:e.attributes.tooltip},e.attributes.location&&(this.model.target=e.attributes.location),!0):!1}parseText(){}parseClose(){return!1}isInternalLink(e){return!!(e.target&&/^[^!]+![a-zA-Z]+[\d]+$/.test(e.target))}},ui=class extends L{get tag(){return`mergeCell`}render(e,t){e.leafNode(`mergeCell`,{ref:t})}parseOpen(e){return e.name===`mergeCell`?(this.model=e.attributes.ref,!0):!1}parseText(){}parseClose(){return!1}};function di(e,t,n,r){let i=t[n];i===void 0?r!==void 0&&(e[n]=r):e[n]=i}function fi(e,t,n,r){let i=t[n];i===void 0?r!==void 0&&(e[n]=r):e[n]=j(i)}function pi(e){if(!e)return[];let t=[],r={};for(let[n,i]of Object.entries(e))if(i!=null)if(n.startsWith(`range:`)){let e=n.slice(6),{sqref:r,...a}=i;t.push({...a,sqref:e})}else r[n]=i;if(Object.keys(r).length===0)return t;let i=Object.entries(r).map(([e,t])=>({address:e,dataValidation:t,marked:!1})).sort((e,t)=>e.address.localeCompare(t.address)),a=Object.fromEntries(i.map(e=>[e.address,e])),o=(e,t,i)=>{for(let a=0;a<t;a++){let t=n.encodeAddress(e.row+a,i);if(!r[t]||!p(r[e.address],r[t]))return!1}return!0},s=i.map(e=>{if(!e.marked){let t=n.decodeEx(e.address);if(t.dimensions)return a[t.dimensions].marked=!0,{...e.dataValidation,sqref:e.address};let i=1,s=n.encodeAddress(t.row+i,t.col);for(;r[s]&&p(e.dataValidation,r[s]);)i++,s=n.encodeAddress(t.row+i,t.col);let c=1;for(;o(t,i,t.col+c);)c++;for(let e=0;e<i;e++)for(let r=0;r<c;r++)s=n.encodeAddress(t.row+e,t.col+r),a[s].marked=!0;if(i>1||c>1){let r=t.row+(i-1),a=t.col+(c-1);return{...e.dataValidation,sqref:`${e.address}:${n.encodeAddress(r,a)}`}}return{...e.dataValidation,sqref:e.address}}return null}).filter(Boolean);return[...t,...s]}var mi=class extends L{get tag(){return`dataValidations`}render(e,t){let n=pi(t);n.length&&(e.openNode(`dataValidations`,{count:n.length}),n.forEach(t=>{e.openNode(`dataValidation`),t.type!==`any`&&(e.addAttribute(`type`,t.type),t.operator&&t.type!==`list`&&t.operator!==`between`&&e.addAttribute(`operator`,t.operator),t.allowBlank&&e.addAttribute(`allowBlank`,`1`)),t.showInputMessage&&e.addAttribute(`showInputMessage`,`1`),t.promptTitle&&e.addAttribute(`promptTitle`,t.promptTitle),t.prompt&&e.addAttribute(`prompt`,t.prompt),t.showErrorMessage&&e.addAttribute(`showErrorMessage`,`1`),t.errorStyle&&e.addAttribute(`errorStyle`,t.errorStyle),t.errorTitle&&e.addAttribute(`errorTitle`,t.errorTitle),t.error&&e.addAttribute(`error`,t.error),e.addAttribute(`sqref`,t.sqref),(t.formulae??[]).forEach((n,r)=>{e.openNode(`formula${r+1}`),t.type===`date`?e.writeText(we(new Date(n))):e.writeText(n),e.closeNode()}),e.closeNode()}),e.closeNode())}parseOpen(e){switch(e.name){case`dataValidations`:return this.model={},!0;case`dataValidation`:{this._address=e.attributes.sqref;let t={type:e.attributes.type??`any`,formulae:[]};switch(e.attributes.type&&fi(t,e.attributes,`allowBlank`),fi(t,e.attributes,`showInputMessage`),fi(t,e.attributes,`showErrorMessage`),t.type){case`any`:case`list`:case`custom`:break;default:di(t,e.attributes,`operator`,`between`);break}return di(t,e.attributes,`promptTitle`),di(t,e.attributes,`prompt`),di(t,e.attributes,`errorStyle`),di(t,e.attributes,`errorTitle`),di(t,e.attributes,`error`),this._dataValidation=t,!0}case`formula1`:case`formula2`:return this._formula=[],!0;default:return!1}}parseText(e){this._formula&&this._formula.push(e)}parseClose(e){switch(e){case`dataValidations`:return!1;case`dataValidation`:return(!this._dataValidation.formulae||!this._dataValidation.formulae.length)&&(delete this._dataValidation.formulae,delete this._dataValidation.operator),this._address.split(/\s+/g).forEach(e=>{e.includes(`:`)?this.model[`range:${e}`]=this._dataValidation:this.model[e]=this._dataValidation}),!0;case`formula1`:case`formula2`:{let e=this._formula.join(``);switch(this._dataValidation.type){case`whole`:case`textLength`:e=parseInt(e,10);break;case`decimal`:e=parseFloat(e);break;case`date`:e=Te(parseFloat(e));break;default:break}return this._dataValidation.formulae.push(e),this._formula=void 0,!0}default:return!0}}},hi=class extends L{get tag(){return`pageSetUpPr`}render(e,t){return t&&t.fitToPage?(e.leafNode(this.tag,{fitToPage:t.fitToPage?`1`:void 0}),!0):!1}parseOpen(e){return e.name===this.tag?(this.model={fitToPage:e.attributes.fitToPage===`1`},!0):!1}parseText(){}parseClose(){return!1}};let gi=e=>e!==void 0;var _i=class extends L{get tag(){return`outlinePr`}render(e,t){return t&&(gi(t.summaryBelow)||gi(t.summaryRight))?(e.leafNode(this.tag,{summaryBelow:gi(t.summaryBelow)?Number(t.summaryBelow):void 0,summaryRight:gi(t.summaryRight)?Number(t.summaryRight):void 0}),!0):!1}parseOpen(e){return e.name===this.tag?(this.model={summaryBelow:gi(e.attributes.summaryBelow)?!!Number(e.attributes.summaryBelow):void 0,summaryRight:gi(e.attributes.summaryRight)?!!Number(e.attributes.summaryRight):void 0},!0):!1}parseText(){}parseClose(){return!1}},vi=class extends L{constructor(){super(),this.map={tabColor:new z(`tabColor`),pageSetUpPr:new hi,outlinePr:new _i}}get tag(){return`sheetPr`}render(e,t){if(t){e.addRollback(),e.openNode(`sheetPr`);let n=!1;n=this.map.tabColor.render(e,t.tabColor)||n,n=this.map.pageSetUpPr.render(e,t.pageSetup)||n,n=this.map.outlinePr.render(e,t.outlineProperties)||n,n?(e.closeNode(),e.commit()):e.rollback()}}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.reset(),!0):this.map[e.name]?(this.parser=this.map[e.name],this.parser.parseOpen(e),!0):!1}parseText(e){return this.parser?(this.parser.parseText(e),!0):!1}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):(this.map.tabColor.model||this.map.pageSetUpPr.model||this.map.outlinePr.model?(this.model={},this.map.tabColor.model&&(this.model.tabColor=this.map.tabColor.model),this.map.pageSetUpPr.model&&(this.model.pageSetup=this.map.pageSetUpPr.model),this.map.outlinePr.model&&(this.model.outlineProperties=this.map.outlinePr.model)):this.model=null,!1)}},yi=class extends L{get tag(){return`sheetFormatPr`}render(e,t){if(t){let n={defaultRowHeight:t.defaultRowHeight,outlineLevelRow:t.outlineLevelRow||void 0,outlineLevelCol:t.outlineLevelCol||void 0,"x14ac:dyDescent":t.dyDescent!==void 0&&t.dyDescent!==0?t.dyDescent:void 0};t.defaultColWidth&&(n.defaultColWidth=t.defaultColWidth),t.customHeight&&(n.customHeight=`1`),Object.values(n).some(e=>e!==void 0)&&e.leafNode(`sheetFormatPr`,n)}}parseOpen(e){return e.name===`sheetFormatPr`?(this.model={defaultRowHeight:parseFloat(e.attributes.defaultRowHeight??`0`),dyDescent:e.attributes[`x14ac:dyDescent`]===void 0?void 0:parseFloat(e.attributes[`x14ac:dyDescent`]),outlineLevelRow:parseInt(e.attributes.outlineLevelRow??`0`,10),outlineLevelCol:parseInt(e.attributes.outlineLevelCol??`0`,10)},e.attributes.defaultColWidth&&(this.model.defaultColWidth=parseFloat(e.attributes.defaultColWidth)),e.attributes.customHeight===`1`&&(this.model.customHeight=!0),!0):!1}parseText(){}parseClose(){return!1}};let bi={frozen:`frozen`,frozenSplit:`frozen`,split:`split`};var xi=class extends L{get tag(){return`sheetView`}prepare(e){switch(e.state){case`frozen`:case`split`:break;default:e.state=`normal`;break}}render(e,t){let r={};t.tabSelected&&(r.tabSelected=`1`),r.workbookViewId=t.workbookViewId??0,e.openNode(`sheetView`,r);let i=function(t,n,r){r&&e.addAttribute(t,n)};i(`rightToLeft`,`1`,t.rightToLeft===!0),i(`showRuler`,`0`,t.showRuler===!1),i(`showRowColHeaders`,`0`,t.showRowColHeaders===!1),i(`showGridLines`,`0`,t.showGridLines===!1),i(`zoomScale`,t.zoomScale,t.zoomScale!==void 0&&t.zoomScale!==100),i(`zoomScaleNormal`,t.zoomScaleNormal,t.zoomScaleNormal!==void 0&&t.zoomScaleNormal!==100),i(`view`,t.style,t.style);let a,o,s,c;switch(t.state){case`frozen`:o=t.xSplit??0,s=t.ySplit??0,a=t.topLeftCell||n.getAddress(s+1,o+1).address,c=t.xSplit&&t.ySplit&&`bottomRight`||t.xSplit&&`topRight`||`bottomLeft`,e.leafNode(`pane`,{xSplit:t.xSplit||void 0,ySplit:t.ySplit||void 0,topLeftCell:a,activePane:c,state:`frozen`}),e.leafNode(`selection`,{pane:c,activeCell:t.activeCell,sqref:t.activeCell});break;case`split`:t.activePane===`topLeft`&&(t.activePane=void 0),e.leafNode(`pane`,{xSplit:t.xSplit||void 0,ySplit:t.ySplit||void 0,topLeftCell:t.topLeftCell,activePane:t.activePane}),e.leafNode(`selection`,{pane:t.activePane,activeCell:t.activeCell,sqref:t.activeCell});break;case`normal`:t.activeCell&&e.leafNode(`selection`,{activeCell:t.activeCell,sqref:t.activeCell});break;default:break}e.closeNode()}parseOpen(e){switch(e.name){case`sheetView`:return this.sheetView={workbookViewId:parseInt(e.attributes.workbookViewId,10),rightToLeft:e.attributes.rightToLeft===`1`,tabSelected:e.attributes.tabSelected===`1`,showRuler:e.attributes.showRuler!==`0`,showRowColHeaders:e.attributes.showRowColHeaders!==`0`,showGridLines:e.attributes.showGridLines!==`0`,zoomScale:parseInt(e.attributes.zoomScale??`100`,10),zoomScaleNormal:parseInt(e.attributes.zoomScaleNormal??`100`,10),style:e.attributes.view},this.pane=void 0,this.selections={},!0;case`pane`:return this.pane={xSplit:parseInt(e.attributes.xSplit??`0`,10),ySplit:parseInt(e.attributes.ySplit??`0`,10),topLeftCell:e.attributes.topLeftCell,activePane:e.attributes.activePane??`topLeft`,state:e.attributes.state},!0;case`selection`:{let t=e.attributes.pane??`topLeft`;return this.selections[t]={pane:t,activeCell:e.attributes.activeCell},!0}default:return!1}}parseText(){}parseClose(e){let t,n;switch(e){case`sheetView`:return this.sheetView&&this.pane?(t=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,tabSelected:this.sheetView.tabSelected,state:bi[this.pane.state]??`split`,xSplit:this.pane.xSplit,ySplit:this.pane.ySplit,topLeftCell:this.pane.topLeftCell,showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},this.model.state===`split`&&(t.activePane=this.pane.activePane),n=this.selections[this.pane.activePane],n&&n.activeCell&&(t.activeCell=n.activeCell),this.sheetView.style&&(t.style=this.sheetView.style)):(t=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,tabSelected:this.sheetView.tabSelected,state:`normal`,showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},n=this.selections.topLeft,n&&n.activeCell&&(t.activeCell=n.activeCell),this.sheetView.style&&(t.style=this.sheetView.style)),!1;default:return!0}}reconcile(){}};function K(e,t){return e?t:void 0}function q(e,t){return e===t?!0:void 0}var Si=class extends L{get tag(){return`sheetProtection`}render(e,t){if(t){let n={sheet:K(t.sheet,`1`),selectLockedCells:t.selectLockedCells===!1?`1`:void 0,selectUnlockedCells:t.selectUnlockedCells===!1?`1`:void 0,formatCells:K(t.formatCells,`0`),formatColumns:K(t.formatColumns,`0`),formatRows:K(t.formatRows,`0`),insertColumns:K(t.insertColumns,`0`),insertRows:K(t.insertRows,`0`),insertHyperlinks:K(t.insertHyperlinks,`0`),deleteColumns:K(t.deleteColumns,`0`),deleteRows:K(t.deleteRows,`0`),sort:K(t.sort,`0`),autoFilter:K(t.autoFilter,`0`),pivotTables:K(t.pivotTables,`0`)};t.sheet&&(n.algorithmName=t.algorithmName,n.hashValue=t.hashValue,n.saltValue=t.saltValue,n.spinCount=t.spinCount,n.objects=K(t.objects===!1,`1`),n.scenarios=K(t.scenarios===!1,`1`)),Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={sheet:q(e.attributes.sheet,`1`),objects:e.attributes.objects===`1`?!1:void 0,scenarios:e.attributes.scenarios===`1`?!1:void 0,selectLockedCells:e.attributes.selectLockedCells===`1`?!1:void 0,selectUnlockedCells:e.attributes.selectUnlockedCells===`1`?!1:void 0,formatCells:q(e.attributes.formatCells,`0`),formatColumns:q(e.attributes.formatColumns,`0`),formatRows:q(e.attributes.formatRows,`0`),insertColumns:q(e.attributes.insertColumns,`0`),insertRows:q(e.attributes.insertRows,`0`),insertHyperlinks:q(e.attributes.insertHyperlinks,`0`),deleteColumns:q(e.attributes.deleteColumns,`0`),deleteRows:q(e.attributes.deleteRows,`0`),sort:q(e.attributes.sort,`0`),autoFilter:q(e.attributes.autoFilter,`0`),pivotTables:q(e.attributes.pivotTables,`0`)},e.attributes.algorithmName&&(this.model.algorithmName=e.attributes.algorithmName,this.model.hashValue=e.attributes.hashValue,this.model.saltValue=e.attributes.saltValue,this.model.spinCount=parseInt(e.attributes.spinCount,10)),!0;default:return!1}}parseText(){}parseClose(){return!1}},Ci=class extends L{get tag(){return`pageMargins`}render(e,t){if(t){let n={left:t.left,right:t.right,top:t.top,bottom:t.bottom,header:t.header,footer:t.footer};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={left:parseFloat(e.attributes.left||.7),right:parseFloat(e.attributes.right||.7),top:parseFloat(e.attributes.top||.75),bottom:parseFloat(e.attributes.bottom||.75),header:parseFloat(e.attributes.header||.3),footer:parseFloat(e.attributes.footer||.3)},!0;default:return!1}}parseText(){}parseClose(){return!1}};function wi(e){return e?`1`:void 0}function Ti(e){switch(e){case`overThenDown`:return e;default:return}}function Ei(e){switch(e){case`atEnd`:case`asDisplyed`:return e;default:return}}function Di(e){switch(e){case`dash`:case`blank`:case`NA`:return e;default:return}}function Oi(e){return e===void 0?void 0:parseInt(e,10)}var ki=class extends L{get tag(){return`pageSetup`}_dpiToXml(e){if(e!==void 0&&Number.isFinite(e)&&e!==4294967295)return e}render(e,t){if(t){let n={paperSize:t.paperSize,orientation:t.orientation,horizontalDpi:this._dpiToXml(t.horizontalDpi),verticalDpi:this._dpiToXml(t.verticalDpi),pageOrder:Ti(t.pageOrder),blackAndWhite:wi(t.blackAndWhite),draft:wi(t.draft),cellComments:Ei(t.cellComments),errors:Di(t.errors),scale:t.scale===100?void 0:t.scale,fitToWidth:t.fitToWidth===1?void 0:t.fitToWidth,fitToHeight:t.fitToHeight===1?void 0:t.fitToHeight,firstPageNumber:t.firstPageNumber,useFirstPageNumber:wi(!!t.firstPageNumber),usePrinterDefaults:wi(t.usePrinterDefaults),copies:t.copies};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={paperSize:Oi(e.attributes.paperSize),orientation:e.attributes.orientation??`portrait`,horizontalDpi:parseInt(e.attributes.horizontalDpi??`4294967295`,10),verticalDpi:parseInt(e.attributes.verticalDpi??`4294967295`,10),pageOrder:e.attributes.pageOrder??`downThenOver`,blackAndWhite:e.attributes.blackAndWhite===`1`,draft:e.attributes.draft===`1`,cellComments:e.attributes.cellComments??`None`,errors:e.attributes.errors??`displayed`,scale:parseInt(e.attributes.scale??`100`,10),fitToWidth:parseInt(e.attributes.fitToWidth??`1`,10),fitToHeight:parseInt(e.attributes.fitToHeight??`1`,10),firstPageNumber:parseInt(e.attributes.firstPageNumber??`1`,10),useFirstPageNumber:e.attributes.useFirstPageNumber===`1`,usePrinterDefaults:e.attributes.usePrinterDefaults===`1`,copies:parseInt(e.attributes.copies??`1`,10)},!0;default:return!1}}parseText(){}parseClose(){return!1}};function Ai(e){return e?`1`:void 0}var ji=class extends L{get tag(){return`printOptions`}render(e,t){if(t){let n={headings:Ai(t.showRowColHeaders),gridLines:Ai(t.showGridLines),horizontalCentered:Ai(t.horizontalCentered),verticalCentered:Ai(t.verticalCentered)};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={showRowColHeaders:e.attributes.headings===`1`,showGridLines:e.attributes.gridLines===`1`,horizontalCentered:e.attributes.horizontalCentered===`1`,verticalCentered:e.attributes.verticalCentered===`1`},!0;default:return!1}}parseText(){}parseClose(){return!1}},Mi=class extends L{get tag(){return`autoFilter`}render(e,t){if(t)if(typeof t==`string`)e.leafNode(`autoFilter`,{ref:t});else{let r=function(e){return typeof e==`string`?e:n.getAddress(e.row,e.column).address},i=r(t.from),a=r(t.to);i&&a&&e.leafNode(`autoFilter`,{ref:`${i}:${a}`})}}parseOpen(e){e.name===`autoFilter`&&(this.model=e.attributes.ref)}},Ni=class extends L{get tag(){return`picture`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},Pi=class extends L{get tag(){return`drawing`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},Fi=class extends L{get tag(){return`tablePart`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},Ii=class extends L{get tag(){return`brk`}render(e,t){e.leafNode(`brk`,t)}parseOpen(e){if(e.name===`brk`){let{id:t,max:n,man:r,min:i}=e.attributes;return this.model={id:+t,max:+n,man:+r},i!==void 0&&(this.model.min=+i),!0}return!1}parseText(){}parseClose(){return!1}},Li=class extends R{constructor(){super({tag:`rowBreaks`,count:!0,childXform:new Ii})}render(e,t){if(t&&t.length){e.openNode(this.tag,this.$),e.addAttribute(this.$count,t.length),e.addAttribute(`manualBreakCount`,t.length);let{childXform:n}=this;for(let r of t)n.render(e,r);e.closeNode()}}},Ri=class extends R{constructor(){super({tag:`colBreaks`,count:!0,childXform:new Ii})}render(e,t){if(t&&t.length){e.openNode(this.tag,this.$),e.addAttribute(this.$count,t.length),e.addAttribute(`manualBreakCount`,t.length);let{childXform:n}=this;for(let r of t)n.render(e,r);e.closeNode()}}},zi=class extends L{get tag(){return`headerFooter`}render(e,t){if(t){e.addRollback();let n=!1;e.openNode(`headerFooter`),t.differentFirst&&(e.addAttribute(`differentFirst`,`1`),n=!0),t.differentOddEven&&(e.addAttribute(`differentOddEven`,`1`),n=!0),t.oddHeader&&typeof t.oddHeader==`string`&&(e.leafNode(`oddHeader`,null,t.oddHeader),n=!0),t.oddFooter&&typeof t.oddFooter==`string`&&(e.leafNode(`oddFooter`,null,t.oddFooter),n=!0),t.evenHeader&&typeof t.evenHeader==`string`&&(e.leafNode(`evenHeader`,null,t.evenHeader),n=!0),t.evenFooter&&typeof t.evenFooter==`string`&&(e.leafNode(`evenFooter`,null,t.evenFooter),n=!0),t.firstHeader&&typeof t.firstHeader==`string`&&(e.leafNode(`firstHeader`,null,t.firstHeader),n=!0),t.firstFooter&&typeof t.firstFooter==`string`&&(e.leafNode(`firstFooter`,null,t.firstFooter),n=!0),n?(e.closeNode(),e.commit()):e.rollback()}}parseOpen(e){switch(e.name){case`headerFooter`:return this.model={},e.attributes.differentFirst&&(this.model.differentFirst=parseInt(e.attributes.differentFirst,0)===1),e.attributes.differentOddEven&&(this.model.differentOddEven=parseInt(e.attributes.differentOddEven,0)===1),!0;case`oddHeader`:return this.currentNode=`oddHeader`,!0;case`oddFooter`:return this.currentNode=`oddFooter`,!0;case`evenHeader`:return this.currentNode=`evenHeader`,!0;case`evenFooter`:return this.currentNode=`evenFooter`,!0;case`firstHeader`:return this.currentNode=`firstHeader`,!0;case`firstFooter`:return this.currentNode=`firstFooter`,!0;default:return!1}}parseText(e){switch(this.currentNode){case`oddHeader`:this.model.oddHeader=(this.model.oddHeader??``)+e;break;case`oddFooter`:this.model.oddFooter=(this.model.oddFooter??``)+e;break;case`evenHeader`:this.model.evenHeader=(this.model.evenHeader??``)+e;break;case`evenFooter`:this.model.evenFooter=(this.model.evenFooter??``)+e;break;case`firstHeader`:this.model.firstHeader=(this.model.firstHeader??``)+e;break;case`firstFooter`:this.model.firstFooter=(this.model.firstFooter??``)+e;break;default:break}}parseClose(){switch(this.currentNode){case`oddHeader`:case`oddFooter`:case`evenHeader`:case`evenFooter`:case`firstHeader`:case`firstFooter`:return this.currentNode=void 0,!0;default:return!1}}},J=class extends L{createNewModel(e){return{}}parseOpen(e){return this.parser=this.parser||this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model=this.createNewModel(e),!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}onParserClose(e,t){this.model[e]=t.model}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.onParserClose(e,this.parser),this.parser=void 0),!0):e!==this.tag}get tag(){return``}},Bi=class extends L{get tag(){return`cfvo`}render(e,t){e.leafNode(this.tag,{type:t.type,val:t.value})}parseOpen(e){this.model={type:e.attributes.type,value:L.toFloatValue(e.attributes.val)}}parseClose(e){return e!==this.tag}},Vi=class extends J{constructor(){super(),this.map={cfvo:this.cfvoXform=new Bi,color:this.colorXform=new z}}get tag(){return`dataBar`}render(e,t){e.openNode(this.tag),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),this.colorXform.render(e,t.color),e.closeNode()}createNewModel(){return{cfvo:[]}}onParserClose(e,t){switch(e){case`cfvo`:this.model.cfvo.push(t.model);break;case`color`:this.model.color=t.model;break}}},Hi=class extends L{get tag(){return`x14:id`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},Ui=class extends J{constructor(){super(),this.map={"x14:id":this.idXform=new Hi}}get tag(){return`ext`}render(e,t){e.openNode(this.tag,{uri:`{B025F937-C7B1-47D3-B67F-A62EFF666E3E}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`}),this.idXform.render(e,t.x14Id),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){this.model.x14Id=t.model}},Wi=class extends J{constructor(){super(),this.map={ext:new Ui}}get tag(){return`extLst`}render(e,t){e.openNode(this.tag),this.map.ext.render(e,t),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){Object.assign(this.model,t.model)}},Gi=class extends L{get tag(){return`formula`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},Ki=class extends J{constructor(){super(),this.map={cfvo:this.cfvoXform=new Bi,color:this.colorXform=new z}}get tag(){return`colorScale`}render(e,t){e.openNode(this.tag),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),t.color.forEach(t=>{this.colorXform.render(e,t)}),e.closeNode()}createNewModel(e){return{cfvo:[],color:[]}}onParserClose(e,t){this.model[e].push(t.model)}},qi=class extends J{constructor(){super(),this.map={cfvo:this.cfvoXform=new Bi}}get tag(){return`iconSet`}render(e,t){e.openNode(this.tag,{iconSet:L.toStringAttribute(t.iconSet,`3TrafficLights`),reverse:L.toBoolAttribute(t.reverse,!1),showValue:L.toBoolAttribute(t.showValue,!0)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),e.closeNode()}createNewModel({attributes:e}){return{iconSet:L.toStringValue(e.iconSet,`3TrafficLights`),reverse:L.toBoolValue(e.reverse),showValue:L.toBoolValue(e.showValue),cfvo:[]}}onParserClose(e,t){this.model[e].push(t.model)}};let Ji={"3Triangles":!0,"3Stars":!0,"5Boxes":!0},Yi=e=>{if(e.formulae&&e.formulae[0])return e.formulae[0];let{tl:t}=new r(e.ref);switch(e.operator){case`containsText`:return`NOT(ISERROR(SEARCH("${e.text}",${t})))`;case`containsBlanks`:return`LEN(TRIM(${t}))=0`;case`notContainsBlanks`:return`LEN(TRIM(${t}))>0`;case`containsErrors`:return`ISERROR(${t})`;case`notContainsErrors`:return`NOT(ISERROR(${t}))`;default:return}},Xi=e=>{if(e.formulae&&e.formulae[0])return e.formulae[0];let{tl:t}=new r(e.ref);switch(e.timePeriod){case`thisWeek`:return`AND(TODAY()-ROUNDDOWN(${t},0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(${t},0)-TODAY()<=7-WEEKDAY(TODAY()))`;case`lastWeek`:return`AND(TODAY()-ROUNDDOWN(${t},0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(${t},0)<(WEEKDAY(TODAY())+7))`;case`nextWeek`:return`AND(ROUNDDOWN(${t},0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(${t},0)-TODAY()<(15-WEEKDAY(TODAY())))`;case`yesterday`:return`FLOOR(${t},1)=TODAY()-1`;case`today`:return`FLOOR(${t},1)=TODAY()`;case`tomorrow`:return`FLOOR(${t},1)=TODAY()+1`;case`last7Days`:return`AND(TODAY()-FLOOR(${t},1)<=6,FLOOR(${t},1)<=TODAY())`;case`lastMonth`:return`AND(MONTH(${t})=MONTH(EDATE(TODAY(),0-1)),YEAR(${t})=YEAR(EDATE(TODAY(),0-1)))`;case`thisMonth`:return`AND(MONTH(${t})=MONTH(TODAY()),YEAR(${t})=YEAR(TODAY()))`;case`nextMonth`:return`AND(MONTH(${t})=MONTH(EDATE(TODAY(),0+1)),YEAR(${t})=YEAR(EDATE(TODAY(),0+1)))`;default:return}},Zi=e=>{let{type:t,operator:n}=e;switch(t){case`containsText`:case`containsBlanks`:case`notContainsBlanks`:case`containsErrors`:case`notContainsErrors`:return{type:`containsText`,operator:t};default:return{type:t,operator:n}}};var Qi=class e extends J{constructor(){super(),this.map={dataBar:this.databarXform=new Vi,extLst:this.extLstRefXform=new Wi,formula:this.formulaXform=new Gi,colorScale:this.colorScaleXform=new Ki,iconSet:this.iconSetXform=new qi}}get tag(){return`cfRule`}static isPrimitive(e){return!(e.type===`iconSet`&&(e.custom||Ji[e.iconSet]))}render(e,t){switch(t.type){case`expression`:this.renderExpression(e,t);break;case`cellIs`:this.renderCellIs(e,t);break;case`top10`:this.renderTop10(e,t);break;case`aboveAverage`:this.renderAboveAverage(e,t);break;case`dataBar`:this.renderDataBar(e,t);break;case`colorScale`:this.renderColorScale(e,t);break;case`iconSet`:this.renderIconSet(e,t);break;case`containsText`:this.renderText(e,t);break;case`timePeriod`:this.renderTimePeriod(e,t);break}}renderExpression(e,t){e.openNode(this.tag,{type:`expression`,dxfId:t.dxfId,priority:t.priority}),this.formulaXform.render(e,t.formulae[0]),e.closeNode()}renderCellIs(e,t){e.openNode(this.tag,{type:`cellIs`,dxfId:t.dxfId,priority:t.priority,operator:t.operator}),t.formulae.forEach(t=>{this.formulaXform.render(e,t)}),e.closeNode()}renderTop10(e,t){e.leafNode(this.tag,{type:`top10`,dxfId:t.dxfId,priority:t.priority,percent:L.toBoolAttribute(t.percent,!1),bottom:L.toBoolAttribute(t.bottom,!1),rank:L.toIntValue(t.rank,10)})}renderAboveAverage(e,t){e.leafNode(this.tag,{type:`aboveAverage`,dxfId:t.dxfId,priority:t.priority,aboveAverage:L.toBoolAttribute(t.aboveAverage,!0)})}renderDataBar(e,t){e.openNode(this.tag,{type:`dataBar`,priority:t.priority}),this.databarXform.render(e,t),this.extLstRefXform.render(e,t),e.closeNode()}renderColorScale(e,t){e.openNode(this.tag,{type:`colorScale`,priority:t.priority}),this.colorScaleXform.render(e,t),e.closeNode()}renderIconSet(t,n){e.isPrimitive(n)&&(t.openNode(this.tag,{type:`iconSet`,priority:n.priority}),this.iconSetXform.render(t,n),t.closeNode())}renderText(e,t){e.openNode(this.tag,{type:t.operator,dxfId:t.dxfId,priority:t.priority,operator:L.toStringAttribute(t.operator,`containsText`)});let n=Yi(t);n&&this.formulaXform.render(e,n),e.closeNode()}renderTimePeriod(e,t){e.openNode(this.tag,{type:`timePeriod`,dxfId:t.dxfId,priority:t.priority,timePeriod:t.timePeriod});let n=Xi(t);n&&this.formulaXform.render(e,n),e.closeNode()}createNewModel({attributes:e}){return{...Zi(e),dxfId:L.toIntValue(e.dxfId),priority:L.toIntValue(e.priority),timePeriod:e.timePeriod,percent:L.toBoolValue(e.percent),bottom:L.toBoolValue(e.bottom),rank:L.toIntValue(e.rank),aboveAverage:L.toBoolValue(e.aboveAverage)}}onParserClose(e,t){switch(e){case`dataBar`:case`extLst`:case`colorScale`:case`iconSet`:Object.assign(this.model,t.model);break;case`formula`:this.model.formulae=this.model.formulae??[],this.model.formulae.push(t.model);break}}},$i=class extends J{constructor(){super(),this.map={cfRule:new Qi}}get tag(){return`conditionalFormatting`}render(e,t){t.rules.some(Qi.isPrimitive)&&(e.openNode(this.tag,{sqref:t.ref}),t.rules.forEach(n=>{Qi.isPrimitive(n)&&(n.ref=t.ref,this.map.cfRule.render(e,n))}),e.closeNode())}createNewModel({attributes:e}){return{ref:e.sqref,rules:[]}}onParserClose(e,t){this.model.rules.push(t.model)}},ea=class extends L{constructor(){super(),this.cfXform=new $i}get tag(){return`conditionalFormatting`}reset(){this.model=[]}prepare(e,t){let n=e.reduce((e,t)=>Math.max(e,...t.rules.map(e=>e.priority??0)),1);e.forEach(e=>{e.rules.forEach(e=>{e.priority||=n++,e.style&&(e.dxfId=t.styles.addDxfStyle(e.style)),e.type===`dataBar`&&((!e.cfvo||e.cfvo.length<2)&&(e.cfvo=[{type:`min`},{type:`max`}]),e.color||={argb:`FF638EC6`})})})}render(e,t){t.forEach(t=>{this.cfXform.render(e,t)})}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`conditionalFormatting`:return this.parser=this.cfXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?this.parser.parseClose(e)?!0:(this.model.push(this.parser.model),this.parser=void 0,!1):!1}reconcile(e,t){e.forEach(e=>{e.rules.forEach(e=>{e.dxfId!==void 0&&(e.style=t.styles.getDxfStyle(e.dxfId),delete e.dxfId)})})}},ta=class extends L{get tag(){return`xm:f`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},na=class extends J{constructor(){super(),this.map={"xm:f":this.fExtXform=new ta}}get tag(){return`x14:cfvo`}render(e,t){e.openNode(this.tag,{type:t.type}),t.value!==void 0&&this.fExtXform.render(e,t.value),e.closeNode()}createNewModel(e){return{type:e.attributes.type}}onParserClose(e,t){switch(e){case`xm:f`:this.model.value=t.model?parseFloat(t.model):0;break}}},ra=class extends J{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new na,"x14:borderColor":this.borderColorXform=new z(`x14:borderColor`),"x14:negativeBorderColor":this.negativeBorderColorXform=new z(`x14:negativeBorderColor`),"x14:negativeFillColor":this.negativeFillColorXform=new z(`x14:negativeFillColor`),"x14:axisColor":this.axisColorXform=new z(`x14:axisColor`)}}static isExt(e){return!e.gradient}get tag(){return`x14:dataBar`}render(e,t){e.openNode(this.tag,{minLength:L.toIntAttribute(t.minLength,0,!0),maxLength:L.toIntAttribute(t.maxLength,100,!0),border:L.toBoolAttribute(t.border,!1),gradient:L.toBoolAttribute(t.gradient,!0),negativeBarColorSameAsPositive:L.toBoolAttribute(t.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:L.toBoolAttribute(t.negativeBarBorderColorSameAsPositive,!0),axisPosition:L.toAttribute(t.axisPosition,`auto`),direction:L.toAttribute(t.direction,`leftToRight`)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),this.borderColorXform.render(e,t.borderColor),this.negativeBorderColorXform.render(e,t.negativeBorderColor),this.negativeFillColorXform.render(e,t.negativeFillColor),this.axisColorXform.render(e,t.axisColor),e.closeNode()}createNewModel({attributes:e}){return{cfvo:[],minLength:L.toIntValue(e.minLength,0),maxLength:L.toIntValue(e.maxLength,100),border:L.toBoolValue(e.border,!1),gradient:L.toBoolValue(e.gradient,!0),negativeBarColorSameAsPositive:L.toBoolValue(e.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:L.toBoolValue(e.negativeBarBorderColorSameAsPositive,!0),axisPosition:L.toStringValue(e.axisPosition,`auto`),direction:L.toStringValue(e.direction,`leftToRight`)}}onParserClose(e,t){let[,n]=e.split(`:`);switch(n){case`cfvo`:this.model.cfvo.push(t.model);break;default:this.model[n]=t.model;break}}},ia=class extends L{get tag(){return`x14:cfIcon`}render(e,t){e.leafNode(this.tag,{iconSet:t.iconSet,iconId:t.iconId})}parseOpen({attributes:e}){this.model={iconSet:e.iconSet,iconId:L.toIntValue(e.iconId)}}parseClose(e){return e!==this.tag}},aa=class extends J{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new na,"x14:cfIcon":this.cfIconXform=new ia}}get tag(){return`x14:iconSet`}render(e,t){e.openNode(this.tag,{iconSet:L.toStringAttribute(t.iconSet),reverse:L.toBoolAttribute(t.reverse,!1),showValue:L.toBoolAttribute(t.showValue,!0),custom:L.toBoolAttribute(t.icons,!1)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),t.icons&&t.icons.forEach((t,n)=>{t.iconId=n,this.cfIconXform.render(e,t)}),e.closeNode()}createNewModel({attributes:e}){return{cfvo:[],iconSet:L.toStringValue(e.iconSet,`3TrafficLights`),reverse:L.toBoolValue(e.reverse,!1),showValue:L.toBoolValue(e.showValue,!0)}}onParserClose(e,t){let[,n]=e.split(`:`);switch(n){case`cfvo`:this.model.cfvo.push(t.model);break;case`cfIcon`:this.model.icons||(this.model.icons=[]),this.model.icons.push(t.model);break;default:this.model[n]=t.model;break}}};function Y(e){return e.toString(16).padStart(2,`0`)}function oa(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=e;return Y(t[0])+Y(t[1])+Y(t[2])+Y(t[3])+`-`+Y(t[4])+Y(t[5])+`-`+Y(t[6])+Y(t[7])+`-`+Y(t[8])+Y(t[9])+`-`+Y(t[10])+Y(t[11])+Y(t[12])+Y(t[13])+Y(t[14])+Y(t[15])}function sa(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);if(e?.getRandomValues)return e.getRandomValues(t),oa(t);for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return oa(t)}let ca={"3Triangles":!0,"3Stars":!0,"5Boxes":!0};var la=class e extends J{constructor(){super(),this.map={"x14:dataBar":this.databarXform=new ra,"x14:iconSet":this.iconSetXform=new aa}}get tag(){return`x14:cfRule`}static isExt(e){return e.type===`dataBar`?ra.isExt(e):!!(e.type===`iconSet`&&(e.custom||ca[e.iconSet]))}prepare(t){e.isExt(t)&&(t.x14Id=`{${sa()}}`.toUpperCase())}render(t,n){if(e.isExt(n))switch(n.type){case`dataBar`:this.renderDataBar(t,n);break;case`iconSet`:this.renderIconSet(t,n);break}}renderDataBar(e,t){e.openNode(this.tag,{type:`dataBar`,id:t.x14Id}),this.databarXform.render(e,t),e.closeNode()}renderIconSet(e,t){e.openNode(this.tag,{type:`iconSet`,priority:t.priority,id:t.x14Id??`{${sa()}}`}),this.iconSetXform.render(e,t),e.closeNode()}createNewModel({attributes:e}){return{type:e.type,x14Id:e.id,priority:L.toIntValue(e.priority)}}onParserClose(e,t){Object.assign(this.model,t.model)}},ua=class extends L{get tag(){return`xm:sqref`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},da=class extends J{constructor(){super(),this.map={"xm:sqref":this.sqRef=new ua,"x14:cfRule":this.cfRule=new la}}get tag(){return`x14:conditionalFormatting`}prepare(e){e.rules.forEach(e=>{this.cfRule.prepare(e)})}render(e,t){t.rules.some(la.isExt)&&(e.openNode(this.tag,{"xmlns:xm":`http://schemas.microsoft.com/office/excel/2006/main`}),t.rules.filter(la.isExt).forEach(t=>this.cfRule.render(e,t)),this.sqRef.render(e,t.ref),e.closeNode())}createNewModel(){return{rules:[]}}onParserClose(e,t){switch(e){case`xm:sqref`:this.model.ref=t.model;break;case`x14:cfRule`:this.model.rules.push(t.model);break}}},fa=class extends J{constructor(){super(),this.map={"x14:conditionalFormatting":this.cfXform=new da}}get tag(){return`x14:conditionalFormattings`}hasContent(e){return e.hasExtContent===void 0&&(e.hasExtContent=e.some(e=>e.rules.some(la.isExt))),e.hasExtContent}prepare(e){e.forEach(e=>{this.cfXform.prepare(e)})}render(e,t){this.hasContent(t)&&(e.openNode(this.tag),t.forEach(t=>this.cfXform.render(e,t)),e.closeNode())}createNewModel(){return[]}onParserClose(e,t){this.model.push(t.model)}},pa=class extends J{constructor(){super(),this.map={"x14:conditionalFormattings":this.conditionalFormattings=new fa}}get tag(){return`ext`}hasContent(e){return this.conditionalFormattings.hasContent(e.conditionalFormattings)}prepare(e){this.conditionalFormattings.prepare(e.conditionalFormattings)}render(e,t){e.openNode(`ext`,{uri:`{78C0D931-6437-407d-A8EE-F0AAD7539E65}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`}),this.conditionalFormattings.render(e,t.conditionalFormattings),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){this.model[e]=t.model}},ma=class extends J{constructor(){super(),this.map={ext:this.ext=new pa}}get tag(){return`extLst`}prepare(e,t){this.ext.prepare(e)}hasContent(e){return this.ext.hasContent(e)}render(e,t){this.hasContent(t)&&(e.openNode(`extLst`),this.ext.render(e,t),e.closeNode())}createNewModel(){return{}}onParserClose(e,t){this.model[e]=t.model}};let ha=(e,t)=>{Object.keys(t).forEach(n=>{let r=e[n],i=t[n];r===void 0&&i!==void 0&&(e[n]=i)})},ga=(e,t)=>{if(!t||!t.length)return e;if(!e||!e.length)return t;let n={},r={};return e.forEach(e=>{n[e.ref]=e,e.rules.forEach(e=>{let{x14Id:t}=e;t&&(r[t]=e)})}),t.forEach(t=>{t.rules.forEach(i=>{let a=r[i.x14Id];a?ha(a,i):n[t.ref]?n[t.ref].rules.push(i):e.push({ref:t.ref,rules:[i]})})}),e};var _a=class e extends L{static{this.WORKSHEET_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"xmlns:x14ac":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac`,"mc:Ignorable":`x14ac`}}constructor(e){super();let{maxRows:t,maxCols:n,ignoreNodes:r}=e||{};this.ignoreNodes=r??[],this.map={sheetPr:new vi,dimension:new ci,sheetViews:new R({tag:`sheetViews`,count:!1,childXform:new xi}),sheetFormatPr:new yi,cols:new R({tag:`cols`,count:!1,childXform:new si}),sheetData:new R({tag:`sheetData`,count:!1,empty:!0,childXform:new oi({maxItems:n}),maxItems:t}),autoFilter:new Mi,mergeCells:new R({tag:`mergeCells`,count:!0,childXform:new ui}),rowBreaks:new Li,colBreaks:new Ri,hyperlinks:new R({tag:`hyperlinks`,count:!1,childXform:new li}),pageMargins:new Ci,dataValidations:new mi,pageSetup:new ki,headerFooter:new zi,printOptions:new ji,picture:new Ni,drawing:new Pi,sheetProtection:new Si,tableParts:new R({tag:`tableParts`,count:!0,childXform:new Fi}),conditionalFormatting:new ea,extLst:new ma}}prepare(e,t){t.merges=new ni,e.hyperlinks=t.hyperlinks=[],e.comments=t.comments=[],e.formControls&&e.formControls.length>0&&(!e.views||e.views.length===0)&&(e.views=[{workbookViewId:0}]),t.formulae={},t.siFormulae=0,this.map.cols.prepare(e.cols,t),this.map.sheetData.prepare(e.rows,t),this.map.conditionalFormatting.prepare(e.conditionalFormattings,t),e.mergeCells=t.merges.mergeCells;let r=e.rels=[];function i(e){return`rId${e.length+1}`}if(e.hyperlinks.forEach(e=>{let t=i(r);e.rId=t,r.push({Id:t,Type:G.Hyperlink,Target:e.target,TargetMode:`External`})}),e.comments.length>0){let a={Id:i(r),Type:G.Comments,Target:Or(e.id)};r.push(a);let o={Id:i(r),Type:G.VmlDrawing,Target:kr(e.id)};r.push(o),e.comments.forEach(e=>{e.refAddress=n.decodeAddress(e.ref)}),t.commentRefs.push({commentName:`comments${e.id}`,vmlDrawing:`vmlDrawing${e.id}`})}if(e.drawing&&e.drawing.anchors){let n=e.drawing;n.rId=i(r),n.name||=`drawing${++t.drawingsCount}`,t.drawings.push(n),r.push({Id:n.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:Ar(n.name)})}let a=[],o;if(e.media.forEach(n=>{if(n.type===`background`){let a=i(r);o=t.media[n.imageId],r.push({Id:a,Type:G.Image,Target:Lr(`${o.name}.${o.extension}`)}),e.background={rId:a},e.image=t.media[n.imageId]}else if(n.type===`image`){let{drawing:s}=e;o=t.media[n.imageId],s||(s=e.drawing={rId:i(r),name:`drawing${++t.drawingsCount}`,anchors:[],rels:[]},t.drawings.push(s),r.push({Id:s.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:Ar(s.name)}));let c=this.preImageId===n.imageId?a[n.imageId]:a[s.rels.length];c||(c=i(s.rels),a[s.rels.length]=c,s.rels.push({Id:c,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`,Target:Lr(`${o.name}.${o.extension}`)}));let l={picture:{rId:c},range:n.range};if(n.hyperlinks&&n.hyperlinks.hyperlink){let e=i(s.rels);a[s.rels.length]=e,l.picture.hyperlinks={tooltip:n.hyperlinks.tooltip,rId:e},s.rels.push({Id:e,Type:G.Hyperlink,Target:n.hyperlinks.hyperlink,TargetMode:`External`})}this.preImageId=n.imageId,s.anchors.push(l)}}),e.tables.forEach(e=>{let n=i(r);e.rId=n,r.push({Id:n,Type:G.Table,Target:Fr(e.target)}),e.columns.forEach(e=>{let{style:n}=e;n&&(e.dxfId=t.styles.addDxfStyle(n))})}),(e.pivotTables??[]).forEach(e=>{r.push({Id:i(r),Type:G.PivotTable,Target:Nr(e.tableNumber)})}),e.formControls&&e.formControls.length>0){let{drawing:n}=e;n||(n=e.drawing={rId:i(r),name:`drawing${++t.drawingsCount}`,anchors:[],rels:[]},t.drawings.push(n),r.push({Id:n.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:Ar(n.name)})),e.comments.length===0&&r.push({Id:i(r),Type:G.VmlDrawing,Target:kr(e.id)});let a=e=>({nativeCol:e.col,nativeColOff:e.colOff,nativeRow:e.row,nativeRowOff:e.rowOff});for(let o of e.formControls){let e=t.formControlRefs.length+1;o.ctrlPropId=e;let s=i(r);o.ctrlPropRelId=s,r.push({Id:s,Type:G.CtrlProp,Target:zr(e)}),t.formControlRefs.push(e);let c=`Check Box ${Math.max(1,o.shapeId-1024)}`;n.anchors.push({range:{editAs:`absolute`,tl:a(o.tl),br:a(o.br)},alternateContent:{requires:`a14`},shape:{cNvPrId:o.shapeId,name:o.name||c,hidden:!0,spid:`_x0000_s${o.shapeId}`,text:o.text}})}}this.map.extLst.prepare(e,t)}render(t,n){t.openXml(F.StdDocAttributes);let r={...e.WORKSHEET_ATTRIBUTES};n.formControls&&n.formControls.length>0&&(r[`xmlns:x14`]=`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`,r[`xmlns:xdr`]=`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,r[`mc:Ignorable`]=`${r[`mc:Ignorable`]} x14`),t.openNode(`worksheet`,r);let i=n.properties?{defaultRowHeight:n.properties.defaultRowHeight,dyDescent:n.properties.dyDescent,outlineLevelCol:n.properties.outlineLevelCol,outlineLevelRow:n.properties.outlineLevelRow,customHeight:n.properties.customHeight}:void 0;n.properties&&n.properties.defaultColWidth&&(i.defaultColWidth=n.properties.defaultColWidth);let a={outlineProperties:n.properties&&n.properties.outlineProperties,tabColor:n.properties&&n.properties.tabColor,pageSetup:n.pageSetup&&n.pageSetup.fitToPage?{fitToPage:n.pageSetup.fitToPage}:void 0},o=n.pageSetup&&n.pageSetup.margins,s={showRowColHeaders:n.pageSetup&&n.pageSetup.showRowColHeaders,showGridLines:n.pageSetup&&n.pageSetup.showGridLines,horizontalCentered:n.pageSetup&&n.pageSetup.horizontalCentered,verticalCentered:n.pageSetup&&n.pageSetup.verticalCentered},c=n.sheetProtection;if(this.map.sheetPr.render(t,a),this.map.dimension.render(t,n.dimensions),this.map.sheetViews.render(t,n.views),this.map.sheetFormatPr.render(t,i),this.map.cols.render(t,n.cols),this.map.sheetData.render(t,n.rows),this.map.sheetProtection.render(t,c),this.map.autoFilter.render(t,n.autoFilter),this.map.mergeCells.render(t,n.mergeCells),this.map.conditionalFormatting.render(t,n.conditionalFormattings),this.map.dataValidations.render(t,n.dataValidations),this.map.hyperlinks.render(t,n.hyperlinks),this.map.printOptions.render(t,s),this.map.pageMargins.render(t,o),this.map.pageSetup.render(t,n.pageSetup),this.map.headerFooter.render(t,n.headerFooter),this.map.rowBreaks.render(t,n.rowBreaks),this.map.colBreaks.render(t,n.colBreaks),this.map.drawing.render(t,n.drawing),this.map.picture.render(t,n.background),n.rels&&n.rels.forEach(e=>{e.Type===G.VmlDrawing&&t.leafNode(`legacyDrawing`,{"r:id":e.Id})}),n.formControls&&n.formControls.length>0){t.openNode(`mc:AlternateContent`),t.openNode(`mc:Choice`,{Requires:`x14`}),t.openNode(`controls`);for(let e of n.formControls){if(!e.ctrlPropRelId)continue;let n=`Check Box ${Math.max(1,e.shapeId-1024)}`;t.openNode(`mc:AlternateContent`),t.openNode(`mc:Choice`,{Requires:`x14`}),t.openNode(`control`,{shapeId:e.shapeId,"r:id":e.ctrlPropRelId,name:e.name||n}),t.openNode(`controlPr`,{locked:0,defaultSize:0,print:e.print?1:0,autoFill:0,autoLine:0,autoPict:0}),t.openNode(`anchor`),t.openNode(`from`),t.leafNode(`xdr:col`,void 0,e.tl.col),t.leafNode(`xdr:colOff`,void 0,e.tl.colOff),t.leafNode(`xdr:row`,void 0,e.tl.row),t.leafNode(`xdr:rowOff`,void 0,e.tl.rowOff),t.closeNode(),t.openNode(`to`),t.leafNode(`xdr:col`,void 0,e.br.col),t.leafNode(`xdr:colOff`,void 0,e.br.colOff),t.leafNode(`xdr:row`,void 0,e.br.row),t.leafNode(`xdr:rowOff`,void 0,e.br.rowOff),t.closeNode(),t.closeNode(),t.closeNode(),t.closeNode(),t.closeNode(),t.leafNode(`mc:Fallback`),t.closeNode()}t.closeNode(),t.closeNode(),t.leafNode(`mc:Fallback`),t.closeNode()}this.map.tableParts.render(t,n.tables),this.map.extLst.render(t,n),t.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===`worksheet`?(Object.values(this.map).forEach(e=>{e.reset()}),!0):(this.map[e.name]&&!this.ignoreNodes.includes(e.name)&&(this.parser=this.map[e.name],this.parser.parseOpen(e)),!0)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`worksheet`:{let e=this.map.sheetFormatPr.model||{};this.map.sheetPr.model&&this.map.sheetPr.model.tabColor&&(e.tabColor=this.map.sheetPr.model.tabColor),this.map.sheetPr.model&&this.map.sheetPr.model.outlineProperties&&(e.outlineProperties=this.map.sheetPr.model.outlineProperties);let t={fitToPage:this.map.sheetPr.model&&this.map.sheetPr.model.pageSetup&&this.map.sheetPr.model.pageSetup.fitToPage||!1,margins:this.map.pageMargins.model},n=Object.assign(t,this.map.pageSetup.model,this.map.printOptions.model),r=ga(this.map.conditionalFormatting.model,this.map.extLst.model&&this.map.extLst.model[`x14:conditionalFormattings`]);return this.model={dimensions:this.map.dimension.model,cols:this.map.cols.model,rows:this.map.sheetData.model,mergeCells:this.map.mergeCells.model,hyperlinks:this.map.hyperlinks.model,dataValidations:this.map.dataValidations.model,properties:e,views:this.map.sheetViews.model,pageSetup:n,headerFooter:this.map.headerFooter.model,background:this.map.picture.model,drawing:this.map.drawing.model,tables:this.map.tableParts.model,conditionalFormattings:r,rowBreaks:this.map.rowBreaks.model??[],colBreaks:this.map.colBreaks.model??[]},this.map.autoFilter.model&&(this.model.autoFilter=this.map.autoFilter.model),this.map.sheetProtection.model&&(this.model.sheetProtection=this.map.sheetProtection.model),!1}default:return!0}}reconcile(e,t){let n=(e.relationships??[]).reduce((n,r)=>{if(n[r.Id]=r,r.Type===G.Comments&&(e.comments=t.comments[r.Target].comments),r.Type===G.VmlDrawing&&e.comments&&e.comments.length){let n=t.vmlDrawings[r.Target].comments;e.comments.forEach((e,t)=>{e.note=Object.assign({},e.note,n[t])})}return n},{});if(t.commentsMap=(e.comments??[]).reduce((e,t)=>(t.ref&&(e[t.ref]=t),e),{}),t.hyperlinkMap=(e.hyperlinks??[]).reduce((e,t)=>(t.rId&&(e[t.address]=n[t.rId].Target),e),{}),t.formulae={},e.rows=e.rows?.filter(Boolean)??[],e.rows.forEach(e=>{e.cells=e.cells?.filter(Boolean)??[]}),this.map.cols.reconcile(e.cols,t),this.map.sheetData.reconcile(e.rows,t),this.map.conditionalFormatting.reconcile(e.conditionalFormattings,t),e.media=[],e.drawing){let r=n[e.drawing.rId].Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);if(r){let n=r[1],i=t.drawings[n];i&&(e.drawing={...i,name:n,rels:t.drawingRels?.[n]??i.rels??[]},i.anchors.forEach(t=>{if(t.medium){let n={type:`image`,imageId:t.medium.index,range:t.range,hyperlinks:t.picture.hyperlinks};e.media.push(n)}}))}}let r=e.background&&n[e.background.rId];if(r){let n=r.Target.split(`/media/`)[1],i=t.mediaIndex&&t.mediaIndex[n];i!==void 0&&e.media.push({type:`background`,imageId:i})}e.tables=(e.tables??[]).map(e=>{let r=n[e.rId];return t.tables[r.Target]}),e.pivotTables=[],(e.relationships??[]).forEach(n=>{if(n.Type===G.PivotTable&&t.pivotTables){let r=t.pivotTables[n.Target];r&&e.pivotTables.push(r)}}),delete e.relationships,delete e.hyperlinks,delete e.comments}},va=class extends L{render(e){e.openXml({version:`1.0`,encoding:`UTF-8`,standalone:`yes`}),e.openNode(`FeaturePropertyBags`,{xmlns:`http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag`}),e.leafNode(`bag`,{type:`Checkbox`}),e.openNode(`bag`,{type:`XFControls`}),e.leafNode(`bagId`,{k:`CellControl`},`0`),e.closeNode(),e.openNode(`bag`,{type:`XFComplement`}),e.leafNode(`bagId`,{k:`XFControls`},`1`),e.closeNode(),e.openNode(`bag`,{type:`XFComplements`,extRef:`XFComplementsMapperExtRef`}),e.openNode(`a`,{k:`MappedFeaturePropertyBags`}),e.leafNode(`bagId`,{},`2`),e.closeNode(),e.closeNode(),e.closeNode()}parseOpen(){return!1}parseText(){}parseClose(){return!1}},ya=class extends L{parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={range:{editAs:e.attributes.editAs??`oneCell`}};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}reconcilePicture(e,t){if(e&&e.rId){let n=t.rels[e.rId].Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);if(n){let e=n[1],r=t.mediaIndex[e];return t.media[r]}}}},ba=class extends L{constructor(e){super(),this.tag=e.tag,this.map={"xdr:col":new $t({tag:`xdr:col`,zero:!0}),"xdr:colOff":new $t({tag:`xdr:colOff`,zero:!0}),"xdr:row":new $t({tag:`xdr:row`,zero:!0}),"xdr:rowOff":new $t({tag:`xdr:rowOff`,zero:!0})},this.model={nativeCol:0,nativeColOff:0,nativeRow:0,nativeRowOff:0}}render(e,t){e.openNode(this.tag),this.map[`xdr:col`].render(e,t.nativeCol),this.map[`xdr:colOff`].render(e,t.nativeColOff),this.map[`xdr:row`].render(e,t.nativeRow),this.map[`xdr:rowOff`].render(e,t.nativeRowOff),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model={nativeCol:this.map[`xdr:col`].model,nativeColOff:this.map[`xdr:colOff`].model,nativeRow:this.map[`xdr:row`].model,nativeRowOff:this.map[`xdr:rowOff`].model},!1;default:return!0}}},xa=class extends L{constructor(){super(),this.model={rId:``}}get tag(){return`a:blip`}render(e,t){e.leafNode(this.tag,{"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"r:embed":t.rId,cstate:`print`})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:embed`]},!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},Sa=class extends L{constructor(){super(),this.map={"a:blip":new xa}}get tag(){return`xdr:blipFill`}render(e,t){e.openNode(this.tag),this.map[`a:blip`].render(e,t),e.openNode(`a:stretch`),e.leafNode(`a:fillRect`),e.closeNode(),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`a:blip`].model,!1;default:return!0}}},Ca=class extends L{constructor(){super(),this.model={}}get tag(){return`a:hlinkClick`}render(e,t){t.hyperlinks&&t.hyperlinks.rId&&e.leafNode(this.tag,{"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"r:id":t.hyperlinks.rId,tooltip:t.hyperlinks.tooltip})}parseOpen(e){switch(e.name){case this.tag:return this.model={hyperlinks:{rId:e.attributes[`r:id`],tooltip:e.attributes.tooltip}},!0;default:return!0}}parseText(){}parseClose(){return!1}},wa=class extends L{get tag(){return`a:extLst`}render(e){e.openNode(this.tag),e.openNode(`a:ext`,{uri:`{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}`}),e.leafNode(`a16:creationId`,{"xmlns:a16":`http://schemas.microsoft.com/office/drawing/2014/main`,id:`{00000000-0008-0000-0000-000002000000}`}),e.closeNode(),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:return!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},Ta=class extends L{constructor(){super(),this.map={"a:hlinkClick":new Ca,"a:extLst":new wa}}get tag(){return`xdr:cNvPr`}render(e,t){e.openNode(this.tag,{id:t.index,name:`Picture ${t.index}`}),this.map[`a:hlinkClick`].render(e,t),this.map[`a:extLst`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`a:hlinkClick`].model,!1;default:return!0}}},Ea=class extends L{get tag(){return`xdr:cNvPicPr`}render(e){e.openNode(this.tag),e.leafNode(`a:picLocks`,{noChangeAspect:`1`}),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:return!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},Da=class extends L{constructor(){super(),this.map={"xdr:cNvPr":new Ta,"xdr:cNvPicPr":new Ea}}get tag(){return`xdr:nvPicPr`}render(e,t){e.openNode(this.tag),this.map[`xdr:cNvPr`].render(e,t),this.map[`xdr:cNvPicPr`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`xdr:cNvPr`].model,!1;default:return!0}}};let Oa={tag:`xdr:spPr`,c:[{tag:`a:xfrm`,c:[{tag:`a:off`,$:{x:`0`,y:`0`}},{tag:`a:ext`,$:{cx:`0`,cy:`0`}}]},{tag:`a:prstGeom`,$:{prst:`rect`},c:[{tag:`a:avLst`}]}]};var ka=class extends L{constructor(){super(),this.map={"xdr:nvPicPr":new Da,"xdr:blipFill":new Sa,"xdr:spPr":new Zt(Oa)}}get tag(){return`xdr:pic`}prepare(e,t){e.index=t.index+1}render(e,t){e.openNode(this.tag),this.map[`xdr:nvPicPr`].render(e,t),this.map[`xdr:blipFill`].render(e,t),this.map[`xdr:spPr`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.mergeModel(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:return!0}}},Aa=class extends L{get tag(){return`xdr:sp`}render(e,t){t&&(e.openNode(this.tag,{macro:``,textlink:``}),e.openNode(`xdr:nvSpPr`),e.openNode(`xdr:cNvPr`,{id:t.cNvPrId,name:t.name,hidden:t.hidden?`1`:void 0}),e.openNode(`a:extLst`),e.openNode(`a:ext`,{uri:`{63B3BB69-23CF-44E3-9099-C40C66FF867C}`}),e.leafNode(`a14:compatExt`,{spid:t.spid,"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`},void 0),e.closeNode(),e.closeNode(),e.closeNode(),e.leafNode(`xdr:cNvSpPr`),e.closeNode(),e.openNode(`xdr:spPr`,{bwMode:`auto`}),e.openNode(`a:xfrm`),e.leafNode(`a:off`,{x:0,y:0}),e.leafNode(`a:ext`,{cx:0,cy:0}),e.closeNode(),e.openNode(`a:prstGeom`,{prst:`rect`}),e.leafNode(`a:avLst`),e.closeNode(),e.leafNode(`a:noFill`),e.openNode(`a:ln`),e.leafNode(`a:noFill`),e.closeNode(),e.openNode(`a:extLst`),e.openNode(`a:ext`,{uri:`{909E8E84-426E-40DD-AFC4-6F175D3DCCD1}`}),e.openNode(`a14:hiddenFill`,{"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`F0F0F0`}),e.closeNode(),e.closeNode(),e.closeNode(),e.openNode(`a:ext`,{uri:`{91240B29-F687-4F45-9708-019B960494DF}`}),e.openNode(`a14:hiddenLine`,{w:9525,"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`000000`}),e.closeNode(),e.leafNode(`a:miter`,{lim:8e5}),e.leafNode(`a:headEnd`),e.leafNode(`a:tailEnd`),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode(),e.openNode(`xdr:txBody`),e.leafNode(`a:bodyPr`,{vertOverflow:`clip`,wrap:`square`,lIns:18288,tIns:18288,rIns:0,bIns:18288,anchor:`ctr`,upright:1}),e.leafNode(`a:lstStyle`),e.openNode(`a:p`),e.openNode(`a:pPr`,{algn:`l`,rtl:0}),e.leafNode(`a:defRPr`,{sz:1e3}),e.closeNode(),e.openNode(`a:r`),e.openNode(`a:rPr`,{lang:`en-US`,sz:800,b:0,i:0,u:`none`,strike:`noStrike`,baseline:0}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`000000`}),e.closeNode(),e.leafNode(`a:latin`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.leafNode(`a:ea`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.leafNode(`a:cs`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.closeNode(),e.openNode(`a:t`),e.writeText(t.text??``),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode())}},ja=class extends ya{constructor(){super(),this.map={"xdr:from":new ba({tag:`xdr:from`}),"xdr:to":new ba({tag:`xdr:to`}),"xdr:pic":new ka,"xdr:sp":new Aa,"xdr:clientData":new Zt({tag:`xdr:clientData`})}}get tag(){return`xdr:twoCellAnchor`}prepare(e,t){e.picture&&this.map[`xdr:pic`].prepare(e.picture,t)}render(e,t){let n=!!t.alternateContent;n&&(e.openNode(`mc:AlternateContent`,{"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`}),e.openNode(`mc:Choice`,{Requires:t.alternateContent?.requires,...t.alternateContent?.requires===`a14`?{"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}:{}})),e.openNode(this.tag,{editAs:t.range.editAs??`oneCell`}),this.map[`xdr:from`].render(e,t.range.tl),this.map[`xdr:to`].render(e,t.range.br),t.picture?this.map[`xdr:pic`].render(e,t.picture):t.shape&&this.map[`xdr:sp`].render(e,t.shape),this.map[`xdr:clientData`].render(e,{}),e.closeNode(),n&&(e.closeNode(),e.leafNode(`mc:Fallback`),e.closeNode())}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.range.tl=this.map[`xdr:from`].model,this.model.range.br=this.map[`xdr:to`].model,this.model.picture=this.map[`xdr:pic`].model,!1;default:return!0}}reconcile(e,t){e.medium=this.reconcilePicture(e.picture,t)}};let Ma=9525;var Na=class extends L{constructor(e){super(),this.tag=e.tag,this.map={},this.model={width:0,height:0}}render(e,t){e.openNode(this.tag);let n=Math.floor(t.width*Ma),r=Math.floor(t.height*Ma);e.addAttribute(`cx`,n),e.addAttribute(`cy`,r),e.closeNode()}parseOpen(e){return e.name===this.tag?(this.model={width:parseInt(e.attributes.cx??`0`,10)/Ma,height:parseInt(e.attributes.cy??`0`,10)/Ma},!0):!1}parseText(e){}parseClose(e){return!1}},Pa=class extends ya{constructor(){super(),this.map={"xdr:from":new ba({tag:`xdr:from`}),"xdr:ext":new Na({tag:`xdr:ext`}),"xdr:pic":new ka,"xdr:clientData":new Zt({tag:`xdr:clientData`})}}get tag(){return`xdr:oneCellAnchor`}prepare(e,t){this.map[`xdr:pic`].prepare(e.picture,t)}render(e,t){e.openNode(this.tag,{editAs:t.range.editAs??`oneCell`}),this.map[`xdr:from`].render(e,t.range.tl),this.map[`xdr:ext`].render(e,t.range.ext),this.map[`xdr:pic`].render(e,t.picture),this.map[`xdr:clientData`].render(e,{}),e.closeNode()}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.range.tl=this.map[`xdr:from`].model,this.model.range.ext=this.map[`xdr:ext`].model,this.model.picture=this.map[`xdr:pic`].model,!1;default:return!0}}reconcile(e,t){e.medium=this.reconcilePicture(e.picture,t)}};function Fa(e){return(typeof e.range==`string`?n.decode(e.range):e.range).br?`xdr:twoCellAnchor`:`xdr:oneCellAnchor`}var Ia=class e extends L{constructor(){super(),this.map={"xdr:twoCellAnchor":new ja,"xdr:oneCellAnchor":new Pa},this.model={anchors:[]}}prepare(e){e.anchors.forEach((e,t)=>{e.anchorType=Fa(e),this.map[e.anchorType].prepare(e,{index:t})})}get tag(){return`xdr:wsDr`}render(t,n){let r=n||this.model;t.openXml(F.StdDocAttributes),t.openNode(this.tag,e.DRAWING_ATTRIBUTES),r.anchors.forEach(e=>{this.map[e.anchorType].render(t,e)}),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={anchors:[]};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.anchors.push(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:return!0}}reconcile(e,t){e.anchors.forEach(e=>{e.br?this.map[`xdr:twoCellAnchor`].reconcile(e,t):this.map[`xdr:oneCellAnchor`].reconcile(e,t)})}static{this.DRAWING_ATTRIBUTES={"xmlns:xdr":`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,"xmlns:a":`http://schemas.openxmlformats.org/drawingml/2006/main`}}},La=class extends L{constructor(){super(),this.model={val:``}}get tag(){return`customFilter`}render(e,t){e.leafNode(this.tag,{val:t.val,operator:t.operator})}parseOpen(e){return e.name===this.tag?(this.model={val:e.attributes.val,operator:e.attributes.operator},!0):!1}parseText(){}parseClose(){return!1}},Ra=class extends L{constructor(){super(),this.model={val:``}}get tag(){return`filter`}render(e,t){e.leafNode(this.tag,{val:t.val})}parseOpen(e){return e.name===this.tag?(this.model={val:e.attributes.val},!0):!1}parseText(){}parseClose(){return!1}},za=class extends L{constructor(){super(),this.map={customFilters:new R({tag:`customFilters`,count:!1,empty:!0,childXform:new La}),filters:new R({tag:`filters`,count:!1,empty:!0,childXform:new Ra})},this.model={filterButton:!1}}get tag(){return`filterColumn`}prepare(e,t){e.colId=t.index.toString()}render(e,t){if(t.customFilters){e.openNode(this.tag,{colId:t.colId,hiddenButton:t.filterButton?`0`:`1`}),this.map.customFilters.render(e,t.customFilters),e.closeNode();return}e.leafNode(this.tag,{colId:t.colId,hiddenButton:t.filterButton?`0`:`1`})}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;let{attributes:t}=e;switch(e.name){case this.tag:return this.model={filterButton:t.hiddenButton===`0`},!0;case`dynamicFilter`:return!0;default:if(this.parser=this.map[e.name],this.parser)return this.parseOpen(e),!0;throw Error(`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.customFilters=this.map.customFilters.model,!1;default:return!0}}},Ba=class extends L{constructor(){super(),this.map={filterColumn:new za},this.model={autoFilterRef:``,columns:[]}}get tag(){return`autoFilter`}prepare(e){e.columns.forEach((e,t)=>{this.map.filterColumn.prepare(e,{index:t})})}render(e,t){e.openNode(this.tag,{ref:t.autoFilterRef}),t.columns.forEach(t=>{this.map.filterColumn.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:return this.model={autoFilterRef:e.attributes.ref,columns:[]},!0;default:if(this.parser=this.map[e.name],this.parser)return this.parseOpen(e),!0;throw Error(`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.columns.push(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:throw Error(`Unexpected xml node in parseClose: ${e}`)}}},Va=class extends L{constructor(){super(),this.model={name:``}}get tag(){return`tableColumn`}prepare(e,t){e.id=t.index+1}render(e,t){e.leafNode(this.tag,{id:t.id.toString(),name:t.name,totalsRowLabel:t.totalsRowLabel,totalsRowFunction:t.totalsRowFunction===`none`?void 0:t.totalsRowFunction,dxfId:t.dxfId})}parseOpen(e){if(e.name===this.tag){let{attributes:t}=e;return this.model={name:t.name,totalsRowLabel:t.totalsRowLabel,totalsRowFunction:t.totalsRowFunction,dxfId:t.dxfId},!0}return!1}parseText(){}parseClose(){return!1}},Ha=class extends L{constructor(){super(),this.model={theme:null,showFirstColumn:!1,showLastColumn:!1,showRowStripes:!1,showColumnStripes:!1}}get tag(){return`tableStyleInfo`}render(e,t){e.leafNode(this.tag,{name:t.theme?t.theme:void 0,showFirstColumn:t.showFirstColumn?`1`:`0`,showLastColumn:t.showLastColumn?`1`:`0`,showRowStripes:t.showRowStripes?`1`:`0`,showColumnStripes:t.showColumnStripes?`1`:`0`})}parseOpen(e){if(e.name===this.tag){let{attributes:t}=e;return this.model={theme:t.name?t.name:null,showFirstColumn:t.showFirstColumn===`1`,showLastColumn:t.showLastColumn===`1`,showRowStripes:t.showRowStripes===`1`,showColumnStripes:t.showColumnStripes===`1`},!0}return!1}parseText(){}parseClose(){return!1}},Ua=class e extends L{constructor(){super(),this.map={autoFilter:new Ba,tableColumns:new R({tag:`tableColumns`,count:!0,empty:!0,childXform:new Va}),tableStyleInfo:new Ha},this.model={id:0,name:``,tableRef:``,columns:[]}}prepare(e,t){this.map.autoFilter.prepare(e),this.map.tableColumns.prepare(e.columns,t)}get tag(){return`table`}render(t,n){t.openXml(F.StdDocAttributes),t.openNode(this.tag,{...e.TABLE_ATTRIBUTES,id:n.id,name:n.name,displayName:n.displayName||n.name,ref:n.tableRef,totalsRowCount:n.totalsRow?`1`:void 0,headerRowCount:n.headerRow?void 0:`0`}),this.map.autoFilter.render(t,n),this.map.tableColumns.render(t,n.columns),this.map.tableStyleInfo.render(t,n.style),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;let{name:t,attributes:n}=e;switch(t){case this.tag:this.reset(),this.model={name:n.name,displayName:n.displayName||n.name,tableRef:n.ref,totalsRow:n.totalsRowCount===`1`,headerRow:n.headerRowCount!==`0`};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.columns=this.map.tableColumns.model,this.map.autoFilter.model&&(this.model.autoFilterRef=this.map.autoFilter.model.autoFilterRef,this.map.autoFilter.model.columns.forEach((e,t)=>{this.model.columns[t].filterButton=e.filterButton})),this.model.style=this.map.tableStyleInfo.model,!1;default:return!0}}reconcile(e,t){e.tableRef&&!e.ref&&(e.ref=e.tableRef),e.rows||=[],e.columns.forEach(e=>{e.dxfId!==void 0&&(e.style=t.styles.getDxfStyle(e.dxfId))})}static{this.TABLE_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`}}};function Wa(e){return isNaN(e.getTime())?``:e.toISOString().replace(/\.\d{3}Z$/,``)}function Ga(e){let t=A(e.name),n=e.numFmtId??`0`,r=qa(e.extraAttrs),i=e.fieldGroupXml?`\n ${e.fieldGroupXml}`:``;if(e.sharedItems===null){if(e.isLoaded)return i?`<cacheField name="${t}" numFmtId="${n}"${r}>${i}\n </cacheField>`:`<cacheField name="${t}" numFmtId="${n}"${r} />`;let a;return a=e.minValue!==void 0&&e.maxValue!==void 0?` containsSemiMixedTypes="0" containsString="0" containsNumber="1"${e.containsInteger?` containsInteger="1"`:``} minValue="${e.minValue}" maxValue="${e.maxValue}"`:``,`<cacheField name="${t}" numFmtId="${n}"${r}>
10
+ `),t=this.i):zt(i)||(r=!0)}r&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail(`text data outside of root node.`),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail(`text data outside of root node.`),this.reportedTextAfterRoot=!0))}sOpenWaka(){let e=this.getCode();if(Vt(e)){this.state=3,this.name=I(e);return}switch(e){case 47:this.state=11,this.name=``;break;case 33:this.state=2,this.openWakaBang=``;break;case 63:this.state=19,this.text=``;break;default:this.fail(`unexpected character in tag`),this.state=0}}sOpenWakaBang(){let e=this.getCode();switch(this.openWakaBang+=I(e),this.openWakaBang){case`[CDATA[`:this.state=16,this.text=``,this.openWakaBang=``;break;case`--`:this.state=13,this.text=``,this.openWakaBang=``;break;case`DOCTYPE`:this.state=21,this.text=``,this.openWakaBang=``;break;default:this.openWakaBang.length>=7&&(this.fail(`incorrect syntax`),this.state=0)}}sOpenTag(){let e=this.getCode();if(e!==-1){if(Ht(e)){this.name+=I(e);return}this.tag={name:this.name,attributes:Object.create(null),isSelfClosing:!1},this.attribList=[],this.sawRoot=!0,e===62?this.openTag():e===47?this.state=4:(zt(e)||this.fail(`unexpected character in tag`),this.state=5)}}sOpenTagSlash(){this.getCode()===62?this.openSelfClosingTag():(this.fail(`expected >`),this.state=5)}sAttrib(){let e=this.skipSpaces();e!==-1&&(Vt(e)?(this.name=I(e),this.state=6):e===62?this.openTag():e===47?this.state=4:this.fail(`unexpected character in attribute`))}sAttribName(){let e=this.getCode();if(e!==-1){if(Ht(e)){this.name+=I(e);return}e===61?this.state=8:zt(e)?this.state=7:e===62?(this.fail(`attribute without value`),this.attribList.push({name:this.name,value:this.name}),this.name=``,this.openTag()):this.fail(`unexpected character in attribute name`)}}sAttribNameSawWhite(){let e=this.skipSpaces();e!==-1&&(e===61?this.state=8:(this.fail(`attribute without value`),this.name=``,this.text=``,e===62?this.openTag():Vt(e)?(this.name=I(e),this.state=6):(this.fail(`unexpected character`),this.state=5)))}sAttribValue(){let e=this.skipSpaces();e!==-1&&(Bt(e)?(this.q=e,this.text=``,this.state=9):(this.fail(`unquoted attribute value`),this.state=0))}sAttribValueQuoted(){let{q:e,chunk:t}=this,{i:n}=this;for(;;){let r=this.getCode();if(r===-1){this.text+=t.slice(n,this.i);return}if(r===e){this.attribList.push({name:this.name,value:this.text+t.slice(n,this.prevI)}),this.name=``,this.text=``,this.q=null,this.state=10;return}if(r===38){this.text+=t.slice(n,this.prevI),this.state=25,this.entityReturnState=9,this.entity=``;return}if((r===10||r===9)&&(this.text+=t.slice(n,this.prevI)+` `,n=this.i),r===60){this.text+=t.slice(n,this.prevI),this.fail(`< not allowed in attribute value`);return}}}sAttribValueClosed(){let e=this.getCode();e!==-1&&(zt(e)?this.state=5:e===62?this.openTag():e===47?this.state=4:Vt(e)?(this.fail(`no whitespace between attributes`),this.name=I(e),this.state=6):this.fail(`unexpected character after attribute`))}sCloseTag(){let e=this.getCode();e!==-1&&(Ht(e)?this.name+=I(e):e===62?this.closeTag():zt(e)?this.state=12:this.fail(`unexpected character in close tag`))}sCloseTagSawWhite(){let e=this.skipSpaces();e!==-1&&(e===62?this.closeTag():this.fail(`unexpected character in close tag`))}sComment(){let e=this.getCode();e!==-1&&(e===45?this.state=14:this.text+=I(e))}sCommentEnding(){let e=this.getCode();e===45?this.state=15:(this.text+=`-`+I(e),this.state=13)}sCommentEnded(){let e=this.getCode();e===62?(this.text=``,this.state=0):e===45?this.text+=`-`:(this.fail(`malformed comment`),this.text+=`--`+I(e),this.state=13)}sCData(){let e=this.getCode();e!==-1&&(e===93?this.state=17:this.text+=I(e))}sCDataEnding(){let e=this.getCode();e===93?this.state=18:(this.text+=`]`+I(e),this.state=16)}sCDataEnding2(){let e=this.getCode();e===62?(this.textHandler&&this.text.length>0&&this.textHandler(this.text),this.text=``,this.state=0):e===93?this.text+=`]`:(this.text+=`]]`+I(e),this.state=16)}sPI(){let e=this.getCode();e!==-1&&(e===63?this.state=20:this.text+=I(e))}sPIEnding(){let e=this.getCode();e===62?(this.text=``,this.state=0):e===63?this.text+=`?`:(this.text+=`?`+I(e),this.state=19)}sDoctype(){let e=this.getCode();e!==-1&&(e===62?(this.text=``,this.state=0):Bt(e)?(this.q=e,this.state=22):e===91?this.state=23:this.text+=I(e))}sDoctypeQuote(){let e=this.getCode();e!==-1&&(e===this.q?(this.q=null,this.state=21):this.text+=I(e))}sDoctypeDTD(){let e=this.getCode();e!==-1&&(e===93?this.state=21:Bt(e)&&(this.q=e,this.state=24))}sDoctypeDTDQuoted(){let e=this.getCode();e!==-1&&e===this.q&&(this.q=null,this.state=23)}sEntity(){let e=this.getCode();if(e!==-1)if(e===59){let e=this.entity,t;e===``?(this.fail(`empty entity`),t=`&;`):t=this.parseEntity(e),this.text+=t,this.state=this.entityReturnState,this.entity=``}else Ht(e)||e===35?this.entity+=I(e):(this.fail(`invalid entity character`),this.text+=`&`+this.entity+I(e),this.state=this.entityReturnState,this.entity=``)}parseEntity(e){if(e[0]!==`#`){let t=this.ENTITIES[e];return t===void 0?(this.fail(`undefined entity: `+e),`&`+e+`;`):t}let t;return t=e[1]===`x`||e[1]===`X`?parseInt(e.slice(2),16):parseInt(e.slice(1),10),isNaN(t)||!Ut(t)?(this.fail(`invalid character entity`),`&`+e+`;`):String.fromCodePoint(t)}skipSpaces(){for(;;){let e=this.getCode();if(e===-1||!zt(e))return e}}openTag(){let e=this.tag;e.isSelfClosing=!1;for(let{name:t,value:n}of this.attribList)e.attributes[t]=n;this.attribList=[],this.openTagHandler?.(e),this.tags.push(e),this.name=``,this.state=0}openSelfClosingTag(){let e=this.tag;e.isSelfClosing=!0;for(let{name:t,value:n}of this.attribList)e.attributes[t]=n;this.attribList=[],this.openTagHandler?.(e),this.closeTagHandler?.(e),this.tags.length===0&&(this.closedRoot=!0),this.name=``,this.state=0}closeTag(){let{tags:e,name:t}=this;if(this.state=0,this.name=``,t===``){this.fail(`empty close tag`),this.text+=`</>`;return}let n=!1;for(let r=e.length-1;r>=0;r--)if(e[r].name===t){for(;e.length>r;){let t=e.pop();this.closeTagHandler?.(t),e.length>r&&this.fail(`unclosed tag: `+t.name)}n=!0;break}n||(this.fail(`unmatched close tag: `+t),this.text+=`</`+t+`>`),e.length===0&&(this.closedRoot=!0)}end(){for(this.sawRoot||this.fail(`document must contain a root element`);this.tags.length>0;){let e=this.tags.pop();this.fail(`unclosed tag: `+e.name)}return this.text.length>0&&this.textHandler&&(this.textHandler(this.text),this.text=``),this._closed=!0,this._init(),this}};async function*Kt(e){let t=new Gt({xmlns:!1,position:!0}),n;t.on(`error`,e=>{n=e});let r=[];t.on(`opentag`,e=>r.push({eventType:`opentag`,value:e})),t.on(`text`,e=>r.push({eventType:`text`,value:e})),t.on(`closetag`,e=>r.push({eventType:`closetag`,value:e}));for await(let i of e){let e=Le(i);if(t.write(e),n)throw n;yield r,r=[]}if(t.close(),n)throw n;r.length>0&&(yield r)}let qt=new Set([`ep`,`cp`,`dc`,`dcterms`,`dcmitype`,`vt`]);function Jt(e,t){for(let e in t)if(e.length>6&&e.startsWith(`xmlns:`)){let n=e.slice(6);if(t[e]===`http://schemas.openxmlformats.org/spreadsheetml/2006/main`)return n;if(qt.has(n))return null}let n=e.indexOf(`:`);return n!==-1&&qt.has(e.slice(0,n))?null:void 0}function Yt(e,t){let n=e.indexOf(`:`);if(n===-1)return e;let r=e.slice(0,n);return r===t||qt.has(r)?e.slice(n+1):e}var L=class e{prepare(e,t){}render(e,t){}parseOpen(e){}parseText(e){}parseClose(e){return!1}reconcile(e,t){}reset(){this.model=void 0,this.map&&Object.values(this.map).forEach(t=>{t instanceof e?t.reset():t.xform&&t.xform.reset()})}mergeModel(e){this.model=Object.assign(this.model||{},e)}async parse(e){let t=!1,n,r=0,i=null;for await(let a of e)if(!t){for(let{eventType:e,value:o}of a)if(e===`opentag`){if(r===1){this.parseOpen(o);continue}if(r===0){let e=Jt(o.name,o.attributes);if(e===void 0){r=1,this.parseOpen(o);continue}r=2,i=e}o.name=Yt(o.name,i),this.parseOpen(o)}else if(e===`text`)this.parseText(o);else if(e===`closetag`){if(r===1){if(!this.parseClose(o.name)){t=!0,n=this.model;break}continue}if(!this.parseClose(Yt(o.name,i))){t=!0,n=this.model;break}}}return t?n:this.model}async parseStream(e){return this.parse(Kt(e))}get xml(){return this.toXml(this.model)}toXml(e){let t=new F;return this.render(t,e),t.xml}static toAttribute(e,t,n=!1){if(e===void 0){if(n)return t}else if(n||e!==t)return e.toString()}static toStringAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toStringValue(e,t){return e===void 0?t:e}static toBoolAttribute(e,t,n=!1){if(e===void 0){if(n)return t}else if(n||e!==t)return e?`1`:`0`}static toBoolValue(e,t){return e===void 0?t:e===`1`}static toIntAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toIntValue(e,t){return e===void 0?t:parseInt(e,10)}static toFloatAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toFloatValue(e,t){return e===void 0?t:parseFloat(e)}};function Xt(e,t){e.openNode(t.tag,t.$),t.c&&t.c.forEach(t=>{Xt(e,t)}),t.t&&e.writeText(t.t),e.closeNode()}var Zt=class extends L{constructor(e){super(),this._model=e}render(e){if(!this._xml){let e=new F;Xt(e,this._model),this._xml=e.xml}e.writeXml(this._xml)}parseOpen(){return!0}parseText(){}parseClose(e){switch(e){case this._model.tag:return!1;default:return!0}}},R=class extends L{constructor(e){super(),this.tag=e.tag,this.always=!!e.always,this.count=e.count,this.empty=e.empty,this.$count=e.$count??`count`,this.$=e.$,this.childXform=e.childXform,this.maxItems=e.maxItems}prepare(e,t){let{childXform:n}=this;e&&e.forEach((e,r)=>{t.index=r,n.prepare(e,t)})}render(e,t){if(this.always||t&&t.length){e.openNode(this.tag,this.$),this.count&&e.addAttribute(this.$count,t?.length??0);let{childXform:n}=this;(t??[]).forEach((t,r)=>{n.render(e,t,r)}),e.closeNode()}else this.empty&&e.leafNode(this.tag)}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model=[],!0):this.childXform.parseOpen(e)?(this.parser=this.childXform,!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)&&(this.model.push(this.parser.model),this.parser=void 0,this.maxItems&&this.model.length>this.maxItems))throw Error(`Max ${this.childXform.tag} count (${this.maxItems}) exceeded`);return!0}return!1}reconcile(e,t){if(e){let{childXform:n}=this;e.forEach(e=>{n.reconcile(e,t)})}}reset(){super.reset(),this.childXform&&this.childXform.reset()}},z=class extends L{constructor(e){super(),this.name=e??`color`}get tag(){return this.name}render(e,t){return t?(e.openNode(this.name),t.argb?e.addAttribute(`rgb`,t.argb):t.theme===void 0?t.indexed===void 0?e.addAttribute(`auto`,`1`):e.addAttribute(`indexed`,t.indexed):(e.addAttribute(`theme`,t.theme),t.tint!==void 0&&e.addAttribute(`tint`,t.tint)),e.closeNode(),!0):!1}parseOpen(e){return e.name===this.name?(e.attributes.rgb?this.model={argb:e.attributes.rgb}:e.attributes.theme?(this.model={theme:parseInt(e.attributes.theme,10)},e.attributes.tint&&(this.model.tint=parseFloat(e.attributes.tint))):e.attributes.indexed?this.model={indexed:parseInt(e.attributes.indexed,10)}:this.model=void 0,!0):!1}parseText(){}parseClose(){return!1}},Qt=class extends L{constructor(e){super(),this.tag=e.tag,this.attr=e.attr}render(e,t){t&&(e.openNode(this.tag),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.model=!0)}parseText(){}parseClose(){return!1}},$t=class extends L{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.zero=e.zero,this.text=[]}render(e,t){(t||this.zero)&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,t):e.writeText(t),e.closeNode())}parseOpen(e){return e.name===this.tag?(this.attr?this.model=parseInt(e.attributes[this.attr],10):this.text=[],!0):!1}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=parseInt(this.text.join(``)||`0`,10)),!1}},B=class extends L{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.text=[]}render(e,t){t!==void 0&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,t):e.writeText(t),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.attr?this.model=e.attributes[this.attr]:this.text=[])}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=this.text.join(``)),!1}},en=class e extends L{static{this.Attributes={single:{},double:{val:`double`},singleAccounting:{val:`singleAccounting`},doubleAccounting:{val:`doubleAccounting`}}}constructor(e){super(),this.model=e}get tag(){return`u`}render(t,n){if(n||=this.model,n===!0)t.leafNode(`u`);else{let r=e.Attributes[n];r&&t.leafNode(`u`,r)}}parseOpen(e){e.name===`u`&&(this.model=e.attributes.val||!0)}parseText(){}parseClose(){return!1}},tn=class e extends L{constructor(t){super(),this.options=t||e.OPTIONS;let n=[{tag:`b`,prop:`bold`,xform:new Qt({tag:`b`,attr:`val`})},{tag:`i`,prop:`italic`,xform:new Qt({tag:`i`,attr:`val`})},{tag:`u`,prop:`underline`,xform:new en},{tag:`strike`,prop:`strike`,xform:new Qt({tag:`strike`,attr:`val`})},{tag:`condense`,prop:`condense`,xform:new Qt({tag:`condense`,attr:`val`})},{tag:`extend`,prop:`extend`,xform:new Qt({tag:`extend`,attr:`val`})},{tag:`outline`,prop:`outline`,xform:new Qt({tag:`outline`,attr:`val`})},{tag:`shadow`,prop:`shadow`,xform:new Qt({tag:`shadow`,attr:`val`})},{tag:`sz`,prop:`size`,xform:new $t({tag:`sz`,attr:`val`})},{tag:`color`,prop:`color`,xform:new z},{tag:this.options.fontNameTag,prop:`name`,xform:new B({tag:this.options.fontNameTag,attr:`val`})},{tag:`family`,prop:`family`,xform:new $t({tag:`family`,attr:`val`})},{tag:`scheme`,prop:`scheme`,xform:new B({tag:`scheme`,attr:`val`})},{tag:`charset`,prop:`charset`,xform:new $t({tag:`charset`,attr:`val`})},{tag:`vertAlign`,prop:`vertAlign`,xform:new B({tag:`vertAlign`,attr:`val`})}];this.map=Object.fromEntries(n.map(e=>[e.tag,{prop:e.prop,xform:e.xform}])),this.renderOrder=n.map(e=>e.tag)}get tag(){return this.options.tagName}render(e,t){let{map:n,renderOrder:r}=this;e.openNode(this.options.tagName),r.forEach(r=>{n[r].xform.render(e,t[n[r].prop])}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;if(this.map[e.name])return this.parser=this.map[e.name].xform,this.parser.parseOpen(e);switch(e.name){case this.options.tagName:return this.model={},!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser&&!this.parser.parseClose(e)){let t=this.map[e];return this.parser.model&&(this.model[t.prop]=this.parser.model),this.parser=void 0,!0}switch(e){case this.options.tagName:return!1;default:return!0}}static{this.OPTIONS={tagName:`font`,fontNameTag:`name`}}},nn=class extends L{constructor(){super(),this.map={color:new z}}get tag(){return`stop`}render(e,t){e.openNode(`stop`),e.addAttribute(`position`,t.position),this.map.color.render(e,t.color),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`stop`:return this.model={position:parseFloat(e.attributes.position)},!0;case`color`:return this.parser=this.map.color,this.parser.parseOpen(e),!0;default:return!1}}parseText(){}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model.color=this.parser.model,this.parser=void 0),!0):!1}},rn=class extends L{constructor(){super(),this.map={fgColor:new z(`fgColor`),bgColor:new z(`bgColor`)}}get name(){return`pattern`}get tag(){return`patternFill`}render(e,t){e.openNode(`patternFill`),e.addAttribute(`patternType`,t.pattern),t.fgColor&&this.map.fgColor.render(e,t.fgColor),t.bgColor&&this.map.bgColor.render(e,t.bgColor),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`patternFill`:return this.model={type:`pattern`,pattern:e.attributes.patternType},!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser.model&&(this.model[e]=this.parser.model),this.parser=void 0),!0):!1}},an=class extends L{constructor(){super(),this.map={stop:new nn}}get name(){return`gradient`}get tag(){return`gradientFill`}render(e,t){switch(e.openNode(`gradientFill`),t.gradient){case`angle`:e.addAttribute(`degree`,t.degree);break;case`path`:e.addAttribute(`type`,`path`),t.center.left&&(e.addAttribute(`left`,t.center.left),t.center.right===void 0&&e.addAttribute(`right`,t.center.left)),t.center.right&&e.addAttribute(`right`,t.center.right),t.center.top&&(e.addAttribute(`top`,t.center.top),t.center.bottom===void 0&&e.addAttribute(`bottom`,t.center.top)),t.center.bottom&&e.addAttribute(`bottom`,t.center.bottom);break;default:break}let n=this.map.stop;t.stops.forEach(t=>{n.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`gradientFill`:{let t=this.model={stops:[]};return e.attributes.degree?(t.gradient=`angle`,t.degree=parseInt(e.attributes.degree,10)):e.attributes.type===`path`&&(t.gradient=`path`,t.center={left:e.attributes.left?parseFloat(e.attributes.left):0,top:e.attributes.top?parseFloat(e.attributes.top):0},e.attributes.right!==e.attributes.left&&(t.center.right=e.attributes.right?parseFloat(e.attributes.right):0),e.attributes.bottom!==e.attributes.top&&(t.center.bottom=e.attributes.bottom?parseFloat(e.attributes.bottom):0)),!0}case`stop`:return this.parser=this.map.stop,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model.stops.push(this.parser.model),this.parser=void 0),!0):!1}},on=class e extends L{constructor(){super(),this.map={patternFill:new rn,gradientFill:new an}}get tag(){return`fill`}render(e,t){switch(e.addRollback(),e.openNode(`fill`),t.type){case`pattern`:this.map.patternFill.render(e,t);break;case`gradient`:this.map.gradientFill.render(e,t);break;default:e.rollback();return}e.closeNode(),e.commit()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`fill`:return this.model={},!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model=this.parser.model,this.model.type=this.parser.name,this.parser=void 0),!0):!1}validStyle(t){return e.validPatternValues[t]}static{this.validPatternValues=[`none`,`solid`,`darkVertical`,`darkGray`,`mediumGray`,`lightGray`,`gray125`,`gray0625`,`darkHorizontal`,`darkVertical`,`darkDown`,`darkUp`,`darkGrid`,`darkTrellis`,`lightHorizontal`,`lightVertical`,`lightDown`,`lightUp`,`lightGrid`,`lightTrellis`,`lightGrid`].reduce((e,t)=>(e[t]=!0,e),{})}static{this.StopXform=nn}static{this.PatternFillXform=rn}static{this.GradientFillXform=an}},sn=class e extends L{constructor(e){super(),this.name=e,this.map={color:new z}}get tag(){return this.name}render(e,t,n){let r=t&&t.color||n||this.defaultColor;e.openNode(this.name),t&&t.style&&(e.addAttribute(`style`,t.style),r&&this.map.color.render(e,r)),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.name:{let{style:t}=e.attributes;return t?this.model={style:t}:this.model=void 0,!0}case`color`:return this.parser=this.map.color,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):(e===this.name&&this.map.color.model&&(this.model||={},this.model.color=this.map.color.model),!1)}validStyle(t){return e.validStyleValues[t]}static{this.validStyleValues=[`thin`,`dashed`,`dotted`,`dashDot`,`hair`,`dashDotDot`,`slantDashDot`,`mediumDashed`,`mediumDashDotDot`,`mediumDashDot`,`medium`,`double`,`thick`].reduce((e,t)=>(e[t]=!0,e),{})}},cn=class extends L{constructor(){super(),this.map={top:new sn(`top`),left:new sn(`left`),bottom:new sn(`bottom`),right:new sn(`right`),diagonal:new sn(`diagonal`)}}render(e,t){let{color:n}=t;e.openNode(`border`),t.diagonal&&t.diagonal.style&&(t.diagonal.up&&e.addAttribute(`diagonalUp`,`1`),t.diagonal.down&&e.addAttribute(`diagonalDown`,`1`));let r=(r,i)=>{let a=r;a&&!a.color&&t.color&&(a={...a,color:t.color}),i.render(e,a,n)};r(t.left,this.map.left),r(t.right,this.map.right),r(t.top,this.map.top),r(t.bottom,this.map.bottom),r(t.diagonal,this.map.diagonal),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`border`:return this.reset(),this.diagonalUp=j(e.attributes.diagonalUp),this.diagonalDown=j(e.attributes.diagonalDown),!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;if(e===`border`){let e=this.model={},t=(t,n,r)=>{n&&(r&&Object.assign(n,r),e[t]=n)};t(`left`,this.map.left.model),t(`right`,this.map.right.model),t(`top`,this.map.top.model),t(`bottom`,this.map.bottom.model),t(`diagonal`,this.map.diagonal.model,{up:this.diagonalUp,down:this.diagonalDown})}return!1}};let ln={0:{f:`General`},1:{f:`0`},2:{f:`0.00`},3:{f:`#,##0`},4:{f:`#,##0.00`},9:{f:`0%`},10:{f:`0.00%`},11:{f:`0.00E+00`},12:{f:`# ?/?`},13:{f:`# ??/??`},14:{f:`mm-dd-yy`},15:{f:`d-mmm-yy`},16:{f:`d-mmm`},17:{f:`mmm-yy`},18:{f:`h:mm AM/PM`},19:{f:`h:mm:ss AM/PM`},20:{f:`h:mm`},21:{f:`h:mm:ss`},22:{f:`m/d/yy "h":mm`},27:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},28:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},29:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},30:{"zh-tw":`m/d/yy `,"zh-cn":`m-d-yy`,"ja-jp":`m/d/yy`,"ko-kr":`mm-dd-yy`},31:{"zh-tw":`yyyy"年"m"月"d"日"`,"zh-cn":`yyyy"年"m"月"d"日"`,"ja-jp":`yyyy"年"m"月"d"日"`,"ko-kr":`yyyy"년" mm"월" dd"일"`},32:{"zh-tw":`hh"時"mm"分"`,"zh-cn":`h"时"mm"分"`,"ja-jp":`h"時"mm"分"`,"ko-kr":`h"시" mm"분"`},33:{"zh-tw":`hh"時"mm"分"ss"秒"`,"zh-cn":`h"时"mm"分"ss"秒"`,"ja-jp":`h"時"mm"分"ss"秒"`,"ko-kr":`h"시" mm"분" ss"초"`},34:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`上午/下午 h"时"mm"分"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},35:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`上午/下午 h"时"mm"分"ss"秒"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},36:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},37:{f:`#,##0 ;(#,##0)`},38:{f:`#,##0 ;[Red](#,##0)`},39:{f:`#,##0.00 ;(#,##0.00)`},40:{f:`#,##0.00 ;[Red](#,##0.00)`},45:{f:`mm:ss`},46:{f:`[h]:mm:ss`},47:{f:`mmss.0`},48:{f:`##0.0E+0`},49:{f:`@`},50:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},51:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},52:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},53:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`m"月"d"日"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},54:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},55:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`上午/下午 h"时"mm"分"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},56:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`上午/下午 h"时"mm"分"ss"秒"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},57:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},58:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},59:{"th-th":`t0`},60:{"th-th":`t0.00`},61:{"th-th":`t#,##0`},62:{"th-th":`t#,##0.00`},67:{"th-th":`t0%`},68:{"th-th":`t0.00%`},69:{"th-th":`t# ?/?`},70:{"th-th":`t# ??/??`},81:{"th-th":`d/m/bb`}};function un(){let e={};return Object.entries(ln).forEach(([t,n])=>{n.f&&(e[n.f]=parseInt(t,10))}),e}let dn=un();var fn=class extends L{constructor(e,t){super(),this.id=e,this.formatCode=t}get tag(){return`numFmt`}render(e,t){e.leafNode(`numFmt`,{numFmtId:t.id,formatCode:t.formatCode})}parseOpen(e){switch(e.name){case`numFmt`:return this.model={id:parseInt(e.attributes.numFmtId,10),formatCode:e.attributes.formatCode.replace(/[\\](.)/g,`$1`)},!0;default:return!1}}parseText(){}parseClose(){return!1}static getDefaultFmtId(e){return dn[e]}static getDefaultFmtCode(e){return ln[e]&&ln[e].f}};let pn={ReadingOrder:{LeftToRight:1,RightToLeft:2}},mn={horizontalValues:[`left`,`center`,`right`,`fill`,`centerContinuous`,`distributed`,`justify`].reduce((e,t)=>(e[t]=!0,e),{}),horizontal(e){return this.horizontalValues[e]?e:void 0},verticalValues:[`top`,`middle`,`bottom`,`distributed`,`justify`].reduce((e,t)=>(e[t]=!0,e),{}),vertical(e){return e===`middle`?`center`:this.verticalValues[e]?e:void 0},wrapText(e){return e?!0:void 0},shrinkToFit(e){return e?!0:void 0},textRotation(e){switch(e){case`vertical`:return e;default:{let t=Ae(e);return t!==void 0&&t>=-90&&t<=90?t:void 0}}},indent(e){let t=Ae(e);return Math.max(0,t)},readingOrder(e){switch(e){case`ltr`:return pn.ReadingOrder.LeftToRight;case`rtl`:return pn.ReadingOrder.RightToLeft;default:return}}},hn={toXml(e){let t=mn.textRotation(e);if(t){if(t===`vertical`)return 255;let e=Math.round(t);if(e>=0&&e<=90)return e;if(e<0&&e>=-90)return 90-e}},toModel(e){let t=Ae(e);if(t!==void 0){if(t===255)return`vertical`;if(t>=0&&t<=90)return t;if(t>90&&t<=180)return 90-t}}};var gn=class extends L{get tag(){return`alignment`}render(e,t){e.addRollback(),e.openNode(`alignment`);let n=!1;function r(t,r){r&&(e.addAttribute(t,r),n=!0)}r(`horizontal`,mn.horizontal(t.horizontal)),r(`vertical`,mn.vertical(t.vertical)),r(`wrapText`,mn.wrapText(t.wrapText)?`1`:!1),r(`shrinkToFit`,mn.shrinkToFit(t.shrinkToFit)?`1`:!1),r(`indent`,mn.indent(t.indent)),r(`textRotation`,hn.toXml(t.textRotation)),r(`readingOrder`,mn.readingOrder(t.readingOrder)),e.closeNode(),n?e.commit():e.rollback()}parseOpen(e){let t={},n=!1;function r(e,r,i){e&&(t[r]=i,n=!0)}r(e.attributes.horizontal,`horizontal`,e.attributes.horizontal),r(e.attributes.vertical,`vertical`,e.attributes.vertical===`center`?`middle`:e.attributes.vertical),r(e.attributes.wrapText,`wrapText`,j(e.attributes.wrapText)),r(e.attributes.shrinkToFit,`shrinkToFit`,j(e.attributes.shrinkToFit)),r(e.attributes.indent,`indent`,parseInt(e.attributes.indent,10)),r(e.attributes.textRotation,`textRotation`,hn.toModel(e.attributes.textRotation)),r(e.attributes.readingOrder,`readingOrder`,e.attributes.readingOrder===`2`?`rtl`:`ltr`),this.model=n?t:null}parseText(){}parseClose(){return!1}};let _n={boolean(e,t){return e===void 0?t:e}};var vn=class extends L{get tag(){return`protection`}render(e,t){e.addRollback(),e.openNode(`protection`);let n=!1;function r(t,r){r!==void 0&&(e.addAttribute(t,r),n=!0)}r(`locked`,_n.boolean(t.locked,!0)?void 0:`0`),r(`hidden`,_n.boolean(t.hidden,!1)?`1`:void 0),e.closeNode(),n?e.commit():e.rollback()}parseOpen(e){let t={locked:e.attributes.locked!==`0`,hidden:e.attributes.hidden===`1`};this.model=!t.locked||t.hidden?t:null}parseText(){}parseClose(){return!1}},yn=class extends L{constructor(e){super(),this.xfId=!!(e&&e.xfId),this.map={alignment:new gn,protection:new vn}}get tag(){return`xf`}render(e,t){e.openNode(`xf`,{numFmtId:t.numFmtId??0,fontId:t.fontId??0,fillId:t.fillId??0,borderId:t.borderId??0}),this.xfId&&e.addAttribute(`xfId`,t.xfId??0),(t.applyNumberFormat||t.numFmtId)&&e.addAttribute(`applyNumberFormat`,`1`),(t.applyFont||t.fontId)&&e.addAttribute(`applyFont`,`1`),(t.applyFill||t.fillId)&&e.addAttribute(`applyFill`,`1`),(t.applyBorder||t.borderId)&&e.addAttribute(`applyBorder`,`1`),(t.applyAlignment||t.alignment)&&e.addAttribute(`applyAlignment`,`1`),(t.applyProtection||t.protection)&&e.addAttribute(`applyProtection`,`1`),t.pivotButton&&e.addAttribute(`pivotButton`,`1`),t.alignment&&this.map.alignment.render(e,t.alignment),t.protection&&this.map.protection.render(e,t.protection),t.checkbox&&t.xfComplementIndex!==void 0&&(e.openNode(`extLst`),e.openNode(`ext`,{"xmlns:xfpb":`http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag`,uri:`{C7286773-470A-42A8-94C5-96B5CB345126}`}),e.leafNode(`xfpb:xfComplement`,{i:t.xfComplementIndex}),e.closeNode(),e.closeNode()),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`xf`:this.model={numFmtId:parseInt(e.attributes.numFmtId,10),fontId:parseInt(e.attributes.fontId,10),fillId:parseInt(e.attributes.fillId,10),borderId:parseInt(e.attributes.borderId,10)},this.xfId&&(this.model.xfId=parseInt(e.attributes.xfId,10)),e.attributes.pivotButton===`1`&&(this.model.pivotButton=!0);for(let t of[`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])e.attributes[t]===`1`&&(this.model[t]=!0);return!0;case`alignment`:return this.parser=this.map.alignment,this.parser.parseOpen(e),!0;case`protection`:return this.parser=this.map.protection,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.map.protection===this.parser?this.model.protection=this.parser.model:this.model.alignment=this.parser.model,this.parser=void 0),!0):e!==`xf`}},bn=class extends L{constructor(){super(),this.map={alignment:new gn,border:new cn,fill:new on,font:new tn,numFmt:new fn,protection:new vn}}get tag(){return`dxf`}render(e,t){if(e.openNode(this.tag),t.font&&this.map.font.render(e,t.font),t.numFmt&&t.numFmtId){let n={id:t.numFmtId,formatCode:t.numFmt};this.map.numFmt.render(e,n)}t.fill&&this.map.fill.render(e,t.fill),t.alignment&&this.map.alignment.render(e,t.alignment),t.border&&this.map.border.render(e,t.border),t.protection&&this.map.protection.render(e,t.protection),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:return this.reset(),!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):e===this.tag?(this.model={alignment:this.map.alignment.model,border:this.map.border.model,fill:this.map.fill.model,font:this.map.font.model,numFmt:this.map.numFmt.model,protection:this.map.protection.model},!1):!0}},xn=class e extends L{constructor(t){super(),this.map={numFmts:new R({tag:`numFmts`,count:!0,childXform:new fn}),fonts:new R({tag:`fonts`,count:!0,childXform:new tn,$:{"x14ac:knownFonts":1}}),fills:new R({tag:`fills`,count:!0,childXform:new on}),borders:new R({tag:`borders`,count:!0,childXform:new cn}),cellStyleXfs:new R({tag:`cellStyleXfs`,count:!0,childXform:new yn}),cellXfs:new R({tag:`cellXfs`,count:!0,childXform:new yn({xfId:!0})}),dxfs:new R({tag:`dxfs`,always:!0,count:!0,childXform:new bn}),numFmt:new fn,font:new tn,fill:new on,border:new cn,style:new yn({xfId:!0}),cellStyles:e.STATIC_XFORMS.cellStyles,tableStyles:e.STATIC_XFORMS.tableStyles,extLst:e.STATIC_XFORMS.extLst},t&&this.init()}initIndex(){this.index={style:{},numFmt:{},numFmtNextId:164,font:{},border:{},fill:{}}}init(){this.model={styles:[],numFmts:[],fonts:[],borders:[],fills:[],dxfs:[]},this.initIndex(),this._addBorder({}),this._addStyle({numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}),this._addFill({type:`pattern`,pattern:`none`}),this._addFill({type:`pattern`,pattern:`gray125`}),this.weakMap=new WeakMap,this._hasCheckboxes=!1}setDefaultFont(e){this.defaultFont=e}render(t,n){let r=n||this.model;t.openXml(F.StdDocAttributes),t.openNode(`styleSheet`,e.STYLESHEET_ATTRIBUTES),this.index?(r.numFmts&&r.numFmts.length&&(t.openNode(`numFmts`,{count:r.numFmts.length}),r.numFmts.forEach(e=>{t.writeXml(e)}),t.closeNode()),r.fonts.length||this._addFont(this.defaultFont||{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`}),t.openNode(`fonts`,{count:r.fonts.length,"x14ac:knownFonts":1}),r.fonts.forEach(e=>{t.writeXml(e)}),t.closeNode(),t.openNode(`fills`,{count:r.fills.length}),r.fills.forEach(e=>{t.writeXml(e)}),t.closeNode(),t.openNode(`borders`,{count:r.borders.length}),r.borders.forEach(e=>{t.writeXml(e)}),t.closeNode(),this.map.cellStyleXfs.render(t,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),t.openNode(`cellXfs`,{count:r.styles.length}),r.styles.forEach(e=>{t.writeXml(e)}),t.closeNode()):(this.map.numFmts.render(t,r.numFmts),this.map.fonts.render(t,r.fonts),this.map.fills.render(t,r.fills),this.map.borders.render(t,r.borders),this.map.cellStyleXfs.render(t,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),this.map.cellXfs.render(t,r.styles)),e.STATIC_XFORMS.cellStyles.render(t),this.map.dxfs.render(t,r.dxfs),e.STATIC_XFORMS.tableStyles.render(t),e.STATIC_XFORMS.extLst.render(t),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`styleSheet`:return this.initIndex(),!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`styleSheet`:{this.model={};let e=(e,t)=>{t.model&&t.model.length&&(this.model[e]=t.model)};if(e(`numFmts`,this.map.numFmts),e(`fonts`,this.map.fonts),e(`fills`,this.map.fills),e(`borders`,this.map.borders),e(`styles`,this.map.cellXfs),e(`dxfs`,this.map.dxfs),this.map.fonts.model&&this.map.fonts.model.length>0&&(this.defaultFont=this.map.fonts.model[0]),this.index={model:[],numFmt:{}},this.model.numFmts){let e=this.index.numFmt;this.model.numFmts.forEach(t=>{e[t.id]=t.formatCode})}return!1}default:return!0}}addStyleModel(e,t){if(!e)return 0;this.model.fonts.length||this._addFont(this.defaultFont||{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`});let n=t||u.ValueType.Number;if(n!==u.ValueType.Checkbox&&this.weakMap&&this.weakMap.has(e))return this.weakMap.get(e);let r={};if(e.numFmt)r.numFmtId=this._addNumFmtStr(e.numFmt);else switch(n){case u.ValueType.Number:r.numFmtId=this._addNumFmtStr(`General`);break;case u.ValueType.Date:r.numFmtId=this._addNumFmtStr(`mm-dd-yy`);break;default:break}e.font&&(r.fontId=this._addFont(e.font)),e.border&&(r.borderId=this._addBorder(e.border)),e.fill&&(r.fillId=this._addFill(e.fill)),e.alignment&&(r.alignment=e.alignment),e.protection&&(r.protection=e.protection);for(let t of[`pivotButton`,`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])e[t]&&(r[t]=!0);n===u.ValueType.Checkbox&&(this._hasCheckboxes=!0,r.alignment=r.alignment||{},r.checkbox=!0,r.xfComplementIndex=0);let i=this._addStyle(r);return n!==u.ValueType.Checkbox&&this.weakMap&&this.weakMap.set(e,i),i}getStyleModel(e){let t=this.model.styles[e];if(!t)return null;let n=this.index.model[e];if(n)return n;if(n=this.index.model[e]={},t.numFmtId){let e=this.index.numFmt[t.numFmtId]||fn.getDefaultFmtCode(t.numFmtId);e&&(n.numFmt=e)}function r(e,t,r){if(r||r===0){let i=t[r];i&&(n[e]=i)}}r(`font`,this.model.fonts,t.fontId),r(`border`,this.model.borders,t.borderId),r(`fill`,this.model.fills,t.fillId),t.alignment&&(n.alignment=t.alignment),t.protection&&(n.protection=t.protection);for(let e of[`pivotButton`,`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])t[e]&&(n[e]=!0);return n}addDxfStyle(e){return e.numFmt&&(e.numFmtId=this._addNumFmtStr(e.numFmt)),this.model.dxfs.push(e),this.model.dxfs.length-1}getDxfStyle(e){return this.model.dxfs[e]}get hasCheckboxes(){return!!this._hasCheckboxes}_addStyle(e){let t=this.map.style.toXml(e),n=this.index.style[t];return n===void 0&&(n=this.index.style[t]=this.model.styles.length,this.model.styles.push(t)),n}_addNumFmtStr(e){let t=fn.getDefaultFmtId(e);if(t!==void 0||(t=this.index.numFmt[e],t!==void 0))return t;t=this.index.numFmt[e]=164+this.model.numFmts.length;let n=this.map.numFmt.toXml({id:t,formatCode:e});return this.model.numFmts.push(n),t}_addFont(e){let t=this.map.font.toXml(e),n=this.index.font[t];return n===void 0&&(n=this.index.font[t]=this.model.fonts.length,this.model.fonts.push(t)),n}_addBorder(e){let t=this.map.border.toXml(e),n=this.index.border[t];return n===void 0&&(n=this.index.border[t]=this.model.borders.length,this.model.borders.push(t)),n}_addFill(e){let t=this.map.fill.toXml(e),n=this.index.fill[t];return n===void 0&&(n=this.index.fill[t]=this.model.fills.length,this.model.fills.push(t)),n}static{this.STYLESHEET_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"mc:Ignorable":`x14ac x16r2`,"xmlns:x14ac":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac`,"xmlns:x16r2":`http://schemas.microsoft.com/office/spreadsheetml/2015/02/main`}}static{this.STATIC_XFORMS={cellStyles:new Zt({tag:`cellStyles`,$:{count:1},c:[{tag:`cellStyle`,$:{name:`Normal`,xfId:0,builtinId:0}}]}),dxfs:new Zt({tag:`dxfs`,$:{count:0}}),tableStyles:new Zt({tag:`tableStyles`,$:{count:0,defaultTableStyle:`TableStyleMedium2`,defaultPivotStyle:`PivotStyleLight16`}}),extLst:new Zt({tag:`extLst`,c:[{tag:`ext`,$:{uri:`{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`},c:[{tag:`x14:slicerStyles`,$:{defaultSlicerStyle:`SlicerStyleLight1`}}]},{tag:`ext`,$:{uri:`{9260A510-F301-46a8-8635-F512D64BE5F5}`,"xmlns:x15":`http://schemas.microsoft.com/office/spreadsheetml/2010/11/main`},c:[{tag:`x15:timelineStyles`,$:{defaultTimelineStyle:`TimeSlicerStyleLight1`}}]}]})}}};xn.Mock=class extends xn{constructor(){super(),this.model={styles:[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}],numFmts:[],fonts:[{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`}],borders:[{}],fills:[{type:`pattern`,pattern:`none`},{type:`pattern`,pattern:`gray125`}]}}parseStream(e){return e.autodrain(),Promise.resolve()}addStyleModel(e,t){switch(t){case u.ValueType.Checkbox:throw Error(`Checkbox cells require styles to be enabled (useStyles: true)`);case u.ValueType.Date:return this.dateStyleId;default:return 0}}get hasCheckboxes(){return!1}get dateStyleId(){if(!this._dateStyleId){let e={numFmtId:fn.getDefaultFmtId(`mm-dd-yy`)};this._dateStyleId=this.model.styles.length,this.model.styles.push(e)}return this._dateStyleId}getStyleModel(){return{}}};var Sn=class extends L{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.text=[],this._format=e.format||function(e){try{return Number.isNaN(e.getTime())?``:e.toISOString()}catch{return``}},this._parse=e.parse||function(e){return new Date(e)}}render(e,t){t&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,this._format(t)):e.writeText(this._format(t)),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.attr?this.model=this._parse(e.attributes[this.attr]):this.text=[])}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=this._parse(this.text.join(``))),!1}};let V={creator:`dc:creator`,title:`dc:title`,subject:`dc:subject`,description:`dc:description`,identifier:`dc:identifier`,language:`dc:language`,keywords:`cp:keywords`,category:`cp:category`,lastModifiedBy:`cp:lastModifiedBy`,lastPrinted:`cp:lastPrinted`,revision:`cp:revision`,version:`cp:version`,contentStatus:`cp:contentStatus`,contentType:`cp:contentType`,created:`dcterms:created`,modified:`dcterms:modified`};var Cn=class e extends L{constructor(){super(),this.map={creator:new B({tag:V.creator}),title:new B({tag:V.title}),subject:new B({tag:V.subject}),description:new B({tag:V.description}),identifier:new B({tag:V.identifier}),language:new B({tag:V.language}),keywords:new B({tag:V.keywords}),category:new B({tag:V.category}),lastModifiedBy:new B({tag:V.lastModifiedBy}),lastPrinted:new Sn({tag:V.lastPrinted,format:e.DateFormat}),revision:new $t({tag:V.revision}),version:new B({tag:V.version}),contentStatus:new B({tag:V.contentStatus}),contentType:new B({tag:V.contentType}),created:new Sn({tag:V.created,attrs:e.DateAttrs,format:e.DateFormat}),modified:new Sn({tag:V.modified,attrs:e.DateAttrs,format:e.DateFormat})}}render(t,n){t.openXml(F.StdDocAttributes),t.openNode(`cp:coreProperties`,e.CORE_PROPERTY_ATTRIBUTES);for(let e of Object.keys(V))this.map[e].render(t,n[e]);t.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):(e.name!==`coreProperties`&&(this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e)),!0)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;if(e===`coreProperties`){this.model={};for(let e of Object.keys(V)){let t=this.map[e].model;t!==void 0&&t!==``&&(this.model[e]=t)}return!1}return!0}static{this.DateFormat=function(e){return e.toISOString().replace(/[.]\d{3}/,``)}}static{this.DateAttrs={"xsi:type":`dcterms:W3CDTF`}}static{this.CORE_PROPERTY_ATTRIBUTES={"xmlns:cp":`http://schemas.openxmlformats.org/package/2006/metadata/core-properties`,"xmlns:dc":`http://purl.org/dc/elements/1.1/`,"xmlns:dcterms":`http://purl.org/dc/terms/`,"xmlns:dcmitype":`http://purl.org/dc/dcmitype/`,"xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`}}},wn=class extends L{get tag(){return`t`}render(e,t){e.openNode(`t`),/^\s|\n|\s$/.test(t)&&e.addAttribute(`xml:space`,`preserve`),e.writeText(t),e.closeNode()}parseOpen(e){return e.name===`t`?(this._text=[],this.model=``,!0):!1}parseText(e){this._text.push(e),this.model=this._text.join(``).replace(/_x([0-9A-F]{4})_/g,(e,t)=>String.fromCharCode(parseInt(t,16)))}parseClose(){return!1}},Tn=class e extends L{constructor(e){super(),this.model=e}get tag(){return`r`}get textXform(){return this._textXform||=new wn}get fontXform(){return this._fontXform||=new tn(e.FONT_OPTIONS)}render(e,t){let n=t||this.model;e.openNode(`r`),n.font&&this.fontXform.render(e,n.font),this.textXform.render(e,n.text),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`r`:return this.model={},!0;case`t`:return this.parser=this.textXform,this.parser.parseOpen(e),!0;case`rPr`:return this.parser=this.fontXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){switch(e){case`r`:return!1;case`t`:return this.model.text=this.parser.model,this.parser=void 0,!0;case`rPr`:return this.model.font=this.parser.model,this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(e),!0}}static{this.FONT_OPTIONS={tagName:`rPr`,fontNameTag:`rFont`}}},En=class extends L{constructor(){super(),this.map={r:new Tn,t:new wn}}get tag(){return`rPh`}render(e,t){if(e.openNode(this.tag,{sb:t.sb??0,eb:t.eb??0}),t&&Object.prototype.hasOwnProperty.call(t,`richText`)&&t.richText){let{r:n}=this.map;t.richText.forEach(t=>{n.render(e,t)})}else t&&this.map.t.render(e,t.text);e.closeNode()}parseOpen(e){let{name:t}=e;return this.parser?(this.parser.parseOpen(e),!0):t===this.tag?(this.model={sb:parseInt(e.attributes.sb,10),eb:parseInt(e.attributes.eb,10)},!0):(this.parser=this.map[t],this.parser?(this.parser.parseOpen(e),!0):!1)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){switch(e){case`r`:{let e=this.model.richText;e||=this.model.richText=[],e.push(this.parser.model);break}case`t`:this.model.text=this.parser.model;break;default:break}this.parser=void 0}return!0}switch(e){case this.tag:return!1;default:return!0}}},Dn=class extends L{constructor(e){super(),this.model=e,this.map={r:new Tn,t:new wn,rPh:new En}}get tag(){return`si`}render(e,t){e.openNode(this.tag),t&&typeof t==`object`&&Object.prototype.hasOwnProperty.call(t,`richText`)&&t.richText?t.richText.length?t.richText.forEach(t=>{this.map.r.render(e,t)}):this.map.t.render(e,``):t!=null&&this.map.t.render(e,t),e.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model={},!0):(this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){switch(e){case`r`:{let e=this.model.richText;e||=this.model.richText=[],e.push(this.parser.model);break}case`t`:this.model=this.parser.model;break;default:break}this.parser=void 0}return!0}switch(e){case this.tag:return!1;default:return!0}}},On=class extends L{constructor(e){super(),this.model=e||{values:[],count:0},this.hash=Object.create(null),this.rich=Object.create(null)}get sharedStringXform(){return this._sharedStringXform||=new Dn}get values(){return this.model.values}get uniqueCount(){return this.model.values.length}get count(){return this.model.count}getString(e){return this.model.values[e]}add(e){return e.richText?this.addRichText(e):this.addText(e)}addText(e){let t=this.hash[e];return t===void 0&&(t=this.hash[e]=this.model.values.length,this.model.values.push(e)),this.model.count++,t}addRichText(e){let t=this.sharedStringXform.toXml(e),n=this.rich[t];return n===void 0&&(n=this.rich[t]=this.model.values.length,this.model.values.push(e)),this.model.count++,n}render(e,t){let n=t||this._values;e.openXml(F.StdDocAttributes),e.openNode(`sst`,{xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,count:n.count,uniqueCount:n.values.length});let r=this.sharedStringXform;n.values.forEach(t=>{r.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`sst`:return!0;case`si`:return this.parser=this.sharedStringXform,this.parser.parseOpen(e),!0;default:throw Error(`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.values.push(this.parser.model),this.model.count++,this.parser=void 0),!0;switch(e){case`sst`:return!1;default:throw Error(`Unexpected xml node in parseClose: ${e}`)}}},kn=class extends L{render(e,t){e.leafNode(`Relationship`,t)}parseOpen(e){switch(e.name){case`Relationship`:return this.model=e.attributes,!0;default:return!1}}parseText(){}parseClose(){return!1}},H=class e extends L{constructor(){super(),this.map={Relationship:new kn}}render(t,n){let r=n||this._values;t.openXml(F.StdDocAttributes),t.openNode(`Relationships`,e.RELATIONSHIPS_ATTRIBUTES),r.forEach(e=>{this.map.Relationship.render(t,e)}),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`Relationships`:return this.model=[],!0;default:if(this.parser=this.map[e.name],this.parser)return this.parser.parseOpen(e),!0;throw Error(`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.push(this.parser.model),this.parser=void 0),!0;switch(e){case`Relationships`:return!1;default:throw Error(`Unexpected xml node in parseClose: ${e}`)}}static{this.RELATIONSHIPS_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/package/2006/relationships`}}};let U={contentTypes:`[Content_Types].xml`,rootRels:`_rels/.rels`,docPropsApp:`docProps/app.xml`,docPropsCore:`docProps/core.xml`,xlWorkbook:`xl/workbook.xml`,xlWorkbookRels:`xl/_rels/workbook.xml.rels`,xlSharedStrings:`xl/sharedStrings.xml`,xlStyles:`xl/styles.xml`,xlTheme1:`xl/theme/theme1.xml`,xlFeaturePropertyBag:`xl/featurePropertyBag/featurePropertyBag.xml`},An=/^xl\/worksheets\/sheet(\d+)[.]xml$/,jn=/^xl\/worksheets\/_rels\/sheet(\d+)[.]xml[.]rels$/,Mn=/^xl\/theme\/[a-zA-Z0-9]+[.]xml$/,Nn=/^xl\/media\/([a-zA-Z0-9]+[.][a-zA-Z0-9]{3,4})$/,Pn=/^xl\/drawings\/(drawing\d+)[.]xml$/,Fn=/^xl\/drawings\/_rels\/(drawing\d+)[.]xml[.]rels$/,In=/^xl\/drawings\/(vmlDrawing\d+)[.]vml$/,Ln=/^xl\/comments(\d+)[.]xml$/,Rn=/^xl\/tables\/(table\d+)[.]xml$/,zn=/^xl\/pivotTables\/(pivotTable\d+)[.]xml$/,Bn=/^xl\/pivotTables\/_rels\/(pivotTable\d+)[.]xml[.]rels$/,Vn=/^xl\/pivotCache\/(pivotCacheDefinition\d+)[.]xml$/,Hn=/^xl\/pivotCache\/_rels\/(pivotCacheDefinition\d+)[.]xml[.]rels$/,Un=/^xl\/pivotCache\/(pivotCacheRecords\d+)[.]xml$/;function Wn(e){return e.startsWith(`/`)?e.slice(1):e}function Gn(e){let t=An.exec(e);if(t)return parseInt(t[1],10)}function Kn(e){let t=jn.exec(e);if(t)return parseInt(t[1],10)}function qn(e){return e.startsWith(`xl/media/`)}function Jn(e){let t=Nn.exec(e);return t?t[1]:void 0}function Yn(e){return Mn.test(e)}function Xn(e){let t=/^xl\/theme\/([a-zA-Z0-9]+)[.]xml$/.exec(e);return t?t[1]:void 0}function Zn(e){return qn(e)||Yn(e)}function Qn(e){let t=Pn.exec(e);return t?t[1]:void 0}function $n(e){let t=Fn.exec(e);return t?t[1]:void 0}function er(e){let t=In.exec(e);return t?t[1]:void 0}function tr(e){let t=Ln.exec(e);return t?t[1]:void 0}function nr(e){let t=Rn.exec(e);return t?t[1]:void 0}function rr(e){let t=zn.exec(e);return t?t[1]:void 0}function ir(e){let t=Bn.exec(e);return t?t[1]:void 0}function ar(e){let t=Vn.exec(e);return t?t[1]:void 0}function or(e){let t=Hn.exec(e);return t?t[1]:void 0}function sr(e){let t=Un.exec(e);return t?t[1]:void 0}function W(e){return e.startsWith(`/`)?e:`/${e}`}function cr(e){return`xl/theme/${e}.xml`}function lr(e){return`xl/media/${e}`}function ur(e){return`xl/worksheets/sheet${e}.xml`}function dr(e){return`xl/worksheets/_rels/sheet${e}.xml.rels`}function fr(e){return`worksheets/sheet${e}.xml`}function pr(e){return`xl/comments${e}.xml`}function mr(e){return`xl/${e}.xml`}function hr(e){return`xl/drawings/vmlDrawing${e}.vml`}function gr(e){return`xl/tables/${e}`}function _r(e){return`xl/drawings/${e}.xml`}function vr(e){return`xl/drawings/_rels/${e}.xml.rels`}function yr(e){return`xl/pivotCache/pivotCacheDefinition${e}.xml`}function br(e){return`xl/pivotCache/_rels/pivotCacheDefinition${e}.xml.rels`}function xr(e){return`xl/pivotCache/pivotCacheRecords${e}.xml`}function Sr(e){return`pivotCacheRecords${e}.xml`}function Cr(e){return`xl/pivotTables/pivotTable${e}.xml`}function wr(e){return`xl/pivotTables/_rels/pivotTable${e}.xml.rels`}function Tr(e){return`../pivotCache/pivotCacheDefinition${e}.xml`}let Er={workbookStyles:`styles.xml`,workbookSharedStrings:`sharedStrings.xml`,workbookTheme1:`theme/theme1.xml`,workbookFeaturePropertyBag:`featurePropertyBag/featurePropertyBag.xml`};function Dr(e){return`pivotCache/pivotCacheDefinition${e}.xml`}function Or(e){return`../comments${e}.xml`}function kr(e){return`../drawings/vmlDrawing${e}.vml`}function Ar(e){return`../drawings/${e}.xml`}function jr(e){return`../drawings/${e}.vml`}function Mr(e){return`../${e}.xml`}function Nr(e){return`../pivotTables/pivotTable${e}.xml`}function Pr(e){return`../pivotTables/${e}.xml`}function Fr(e){return`../tables/${e}`}function Ir(e){return`../tables/${e}.xml`}function Lr(e){return`../media/${e}`}function Rr(e){return`xl/ctrlProps/ctrlProp${e}.xml`}function zr(e){return`../ctrlProps/ctrlProp${e}.xml`}var Br=class e extends L{render(t,n){t.openXml(F.StdDocAttributes),t.openNode(`Types`,e.PROPERTY_ATTRIBUTES);let r={};if((n.media??[]).forEach(e=>{if(e.type===`image`){let n=e.extension;r[n]||(r[n]=!0,t.leafNode(`Default`,{Extension:n,ContentType:`image/${n}`}))}}),t.leafNode(`Default`,{Extension:`rels`,ContentType:`application/vnd.openxmlformats-package.relationships+xml`}),t.leafNode(`Default`,{Extension:`xml`,ContentType:`application/xml`}),t.leafNode(`Override`,{PartName:W(U.xlWorkbook),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml`}),n.worksheets.forEach((e,n)=>{let r=e.fileIndex||n+1;t.leafNode(`Override`,{PartName:W(ur(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml`})}),(n.pivotTables??[]).length){let e=new Set;(n.pivotTables??[]).forEach(n=>{let r=n.tableNumber,i=n.cacheId;e.has(i)||(e.add(i),t.leafNode(`Override`,{PartName:W(yr(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml`}),(!n.isLoaded||n.cacheRecords)&&t.leafNode(`Override`,{PartName:W(xr(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml`})),t.leafNode(`Override`,{PartName:W(Cr(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml`})})}t.leafNode(`Override`,{PartName:W(U.xlTheme1),ContentType:`application/vnd.openxmlformats-officedocument.theme+xml`}),t.leafNode(`Override`,{PartName:W(U.xlStyles),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml`}),n.hasCheckboxes&&t.leafNode(`Override`,{PartName:W(U.xlFeaturePropertyBag),ContentType:`application/vnd.ms-excel.featurepropertybag+xml`}),n.sharedStrings&&n.sharedStrings.count&&t.leafNode(`Override`,{PartName:W(U.xlSharedStrings),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml`}),n.tables&&n.tables.forEach(e=>{t.leafNode(`Override`,{PartName:W(gr(e.target)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml`})}),n.drawings&&n.drawings.forEach(e=>{t.leafNode(`Override`,{PartName:W(_r(e.name)),ContentType:`application/vnd.openxmlformats-officedocument.drawing+xml`})});let i=n.commentRefs&&n.commentRefs.length>0,a=n.formControlRefs&&n.formControlRefs.length>0;if((i||a)&&t.leafNode(`Default`,{Extension:`vml`,ContentType:`application/vnd.openxmlformats-officedocument.vmlDrawing`}),i&&n.commentRefs.forEach(({commentName:e})=>{t.leafNode(`Override`,{PartName:W(mr(e)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml`})}),a)for(let e of n.formControlRefs)t.leafNode(`Override`,{PartName:W(Rr(e)),ContentType:`application/vnd.ms-excel.controlproperties+xml`});if(n.passthroughContentTypes)for(let{partName:e,contentType:r}of n.passthroughContentTypes)t.leafNode(`Override`,{PartName:W(e),ContentType:r});t.leafNode(`Override`,{PartName:W(U.docPropsCore),ContentType:`application/vnd.openxmlformats-package.core-properties+xml`}),t.leafNode(`Override`,{PartName:W(U.docPropsApp),ContentType:`application/vnd.openxmlformats-officedocument.extended-properties+xml`}),t.closeNode()}parseOpen(){return!1}parseText(){}parseClose(){return!1}static{this.PROPERTY_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/package/2006/content-types`}}},Vr=class extends L{render(e,t){e.openNode(`HeadingPairs`),e.openNode(`vt:vector`,{size:2,baseType:`variant`}),e.openNode(`vt:variant`),e.leafNode(`vt:lpstr`,void 0,`Worksheets`),e.closeNode(),e.openNode(`vt:variant`),e.leafNode(`vt:i4`,void 0,t.length),e.closeNode(),e.closeNode(),e.closeNode()}parseOpen(e){return e.name===`HeadingPairs`}parseText(){}parseClose(e){return e!==`HeadingPairs`}},Hr=class extends L{render(e,t){e.openNode(`TitlesOfParts`),e.openNode(`vt:vector`,{size:t.length,baseType:`lpstr`}),t.forEach(t=>{e.leafNode(`vt:lpstr`,void 0,t.name)}),e.closeNode(),e.closeNode()}parseOpen(e){return e.name===`TitlesOfParts`}parseText(){}parseClose(e){return e!==`TitlesOfParts`}},Ur=class e extends L{constructor(){super(),this.map={Company:new B({tag:`Company`}),Manager:new B({tag:`Manager`}),HeadingPairs:new Vr,TitlesOfParts:new Hr}}render(t,n){t.openXml(F.StdDocAttributes),t.openNode(`Properties`,e.PROPERTY_ATTRIBUTES),t.leafNode(`Application`,void 0,`Microsoft Excel`),t.leafNode(`DocSecurity`,void 0,`0`),t.leafNode(`ScaleCrop`,void 0,`false`),this.map.HeadingPairs.render(t,n.worksheets),this.map.TitlesOfParts.render(t,n.worksheets),this.map.Company.render(t,n.company??``),this.map.Manager.render(t,n.manager),t.leafNode(`LinksUpToDate`,void 0,`false`),t.leafNode(`SharedDoc`,void 0,`false`),t.leafNode(`HyperlinksChanged`,void 0,`false`),t.leafNode(`AppVersion`,void 0,`16.0300`),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`Properties`:return!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`Properties`:return this.model={worksheets:this.map.TitlesOfParts.model,company:this.map.Company.model,manager:this.map.Manager.model},!1;default:return!0}}static{this.DateFormat=function(e){return e.toISOString().replace(/[.]\d{3,6}/,``)}}static{this.DateAttrs={"xsi:type":`dcterms:W3CDTF`}}static{this.PROPERTY_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/officeDocument/2006/extended-properties`,"xmlns:vt":`http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes`}}},Wr=class extends L{constructor(){super(),this._parsedText=[]}render(e,t){e.openNode(`definedName`,{name:t.name,localSheetId:t.localSheetId}),e.writeText(t.ranges.join(`,`)),e.closeNode()}parseOpen(e){switch(e.name){case`definedName`:return this._parsedName=e.attributes.name,this._parsedLocalSheetId=e.attributes.localSheetId,this._parsedText=[],!0;default:return!1}}parseText(e){this._parsedText.push(e)}parseClose(){return this.model={name:this._parsedName,ranges:Yr(this._parsedText.join(``))},this._parsedLocalSheetId!==void 0&&(this.model.localSheetId=parseInt(this._parsedLocalSheetId,10)),!1}};let Gr=/^[$]?[A-Za-z]{1,3}[$]?\d+(:[$]?[A-Za-z]{1,3}[$]?\d+)?$/,Kr=/^[$]?\d+:[$]?\d+$/,qr=/^[$]?[A-Za-z]{1,3}:[$]?[A-Za-z]{1,3}$/;function Jr(e){if(e.startsWith(`{`)||e.endsWith(`}`))return!1;let t=e.split(`!`).pop()??``;if(!Gr.test(t)&&!Kr.test(t)&&!qr.test(t))return!1;try{let t=n.decodeEx(e);return`row`in t&&typeof t.row==`number`||`top`in t&&typeof t.top==`number`||`left`in t&&typeof t.left==`number`}catch{return!1}}function Yr(e){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`))return[];let n=[],r=!1,i=``;return e.split(`,`).forEach(e=>{if(!e)return;let t=(e.match(/'/g)??[]).length;if(!t){r?i+=`${e},`:Jr(e)&&n.push(e);return}let a=t%2==0;!r&&a&&Jr(e)?n.push(e):r&&!a?(r=!1,Jr(i+e)&&n.push(i+e),i=``):(r=!0,i+=`${e},`)}),n}var Xr=class extends L{render(e,t){e.leafNode(`sheet`,{name:t.name,sheetId:t.id,state:t.state===`visible`?void 0:t.state,"r:id":t.rId})}parseOpen(e){return e.name===`sheet`?(this.model={name:Oe(e.attributes.name),id:parseInt(e.attributes.sheetId,10),state:e.attributes.state,rId:e.attributes[`r:id`]},!0):!1}parseText(){}parseClose(){return!1}},Zr=class extends L{render(e,t){let n={xWindow:t.x??0,yWindow:t.y??0,windowWidth:t.width??12e3,windowHeight:t.height??24e3,firstSheet:t.firstSheet,activeTab:t.activeTab};t.visibility&&t.visibility!==`visible`&&(n.visibility=t.visibility),e.leafNode(`workbookView`,n)}parseOpen(e){if(e.name===`workbookView`){let t=this.model={},n=function(e,n,r){t[e]=n===void 0?r:n},r=function(e,n,r){let i=n===void 0?r:parseInt(n,10);i!==void 0&&(t[e]=i)};return r(`x`,e.attributes.xWindow,0),r(`y`,e.attributes.yWindow,0),r(`width`,e.attributes.windowWidth,25e3),r(`height`,e.attributes.windowHeight,1e4),n(`visibility`,e.attributes.visibility,`visible`),r(`activeTab`,e.attributes.activeTab,void 0),r(`firstSheet`,e.attributes.firstSheet,void 0),!0}return!1}parseText(){}parseClose(){return!1}},Qr=class extends L{render(e,t){e.leafNode(`workbookPr`,{date1904:t.date1904?1:void 0,filterPrivacy:1})}parseOpen(e){return e.name===`workbookPr`?(this.model={date1904:e.attributes.date1904===`1`},!0):!1}parseText(){}parseClose(){return!1}},$r=class extends L{render(e,t){e.leafNode(`calcPr`,{calcId:171027,fullCalcOnLoad:t.fullCalcOnLoad?1:void 0})}parseOpen(e){return e.name===`calcPr`?(this.model={},!0):!1}parseText(){}parseClose(){return!1}},ei=class extends L{render(e,t){e.leafNode(`pivotCache`,{cacheId:t.cacheId,"r:id":t.rId})}parseOpen(e){return e.name===`pivotCache`?(this.model={cacheId:e.attributes.cacheId,rId:e.attributes[`r:id`]},!0):!1}parseText(){}parseClose(){return!1}},ti=class e extends L{constructor(){super(),this.map={fileVersion:e.STATIC_XFORMS.fileVersion,workbookPr:new Qr,bookViews:new R({tag:`bookViews`,count:!1,childXform:new Zr}),sheets:new R({tag:`sheets`,count:!1,childXform:new Xr}),definedNames:new R({tag:`definedNames`,count:!1,childXform:new Wr}),calcPr:new $r,pivotCaches:new R({tag:`pivotCaches`,count:!1,childXform:new ei})}}prepare(e){e.sheets=e.worksheets;let t=[],n=0;e.sheets.forEach(e=>{if(e.pageSetup&&e.pageSetup.printArea&&e.pageSetup.printArea.split(`&&`).forEach(r=>{let i=r.split(`:`),a={name:`_xlnm.Print_Area`,ranges:[`'${e.name}'!$${i[0]}:$${i[1]}`],localSheetId:n};t.push(a)}),e.pageSetup&&(e.pageSetup.printTitlesRow||e.pageSetup.printTitlesColumn)){let r=[];if(e.pageSetup.printTitlesColumn){let t=e.pageSetup.printTitlesColumn.split(`:`);r.push(`'${e.name}'!$${t[0]}:$${t[1]}`)}if(e.pageSetup.printTitlesRow){let t=e.pageSetup.printTitlesRow.split(`:`);r.push(`'${e.name}'!$${t[0]}:$${t[1]}`)}let i={name:`_xlnm.Print_Titles`,ranges:r,localSheetId:n};t.push(i)}n++}),t.length&&(e.definedNames=e.definedNames.concat(t)),(e.media??[]).forEach((e,t)=>{e.name=e.type+(t+1)})}render(t,n){t.openXml(F.StdDocAttributes),t.openNode(`workbook`,e.WORKBOOK_ATTRIBUTES),this.map.fileVersion.render(t),this.map.workbookPr.render(t,n.properties),this.map.bookViews.render(t,n.views),this.map.sheets.render(t,n.sheets),this.map.definedNames.render(t,n.definedNames),this.map.calcPr.render(t,n.calcProperties);let r=n.pivotTables??[],i=new Set,a=r.filter(e=>i.has(e.cacheId)?!1:(i.add(e.cacheId),!0));this.map.pivotCaches.render(t,a),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`workbook`:return!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`workbook`:return this.model={sheets:this.map.sheets.model,properties:this.map.workbookPr.model||{},views:this.map.bookViews.model,calcProperties:{}},this.map.definedNames.model&&(this.model.definedNames=this.map.definedNames.model),this.map.pivotCaches.model&&this.map.pivotCaches.model.length>0&&(this.model.pivotCaches=this.map.pivotCaches.model),!1;default:return!0}}reconcile(e){let t=(e.workbookRels??[]).reduce((e,t)=>(e[t.Id]=t,e),{}),r=[],i,a=0;(e.sheets??[]).forEach(n=>{let o=t[n.rId];o&&(i=e.worksheetHash[`xl/${o.Target.replace(/^(\s|\/xl\/)+/,``)}`],i&&(i.name=n.name,i.id=n.id,i.state=n.state,r[a++]=i))});let o=[];e.definedNames&&e.definedNames.forEach(e=>{if(e.name===`_xlnm.Print_Area`){if(i=r[e.localSheetId],i){i.pageSetup||={};let t=n.decodeEx(e.ranges[0]);i.pageSetup.printArea=i.pageSetup.printArea?`${i.pageSetup.printArea}&&${t.dimensions}`:t.dimensions}}else if(e.name===`_xlnm.Print_Titles`){if(i=r[e.localSheetId],i){i.pageSetup||={};let t=e.ranges.join(`,`),n=/\$/g,r=t.match(/\$\d+:\$\d+/);if(r&&r.length){let e=r[0];i.pageSetup.printTitlesRow=e.replace(n,``)}let a=t.match(/\$[A-Z]+:\$[A-Z]+/);if(a&&a.length){let e=a[0];i.pageSetup.printTitlesColumn=e.replace(n,``)}}}else o.push(e)}),e.definedNames=o,e.media.forEach((e,t)=>{e.index=t})}static{this.WORKBOOK_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"mc:Ignorable":`x15`,"xmlns:x15":`http://schemas.microsoft.com/office/spreadsheetml/2010/11/main`}}static{this.STATIC_XFORMS={fileVersion:new Zt({tag:`fileVersion`,$:{appName:`xl`,lastEdited:5,lowestEdited:5,rupBuild:9303}})}}};let G={OfficeDocument:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument`,Worksheet:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet`,CalcChain:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain`,SharedStrings:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings`,Styles:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles`,Theme:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme`,Hyperlink:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`,Image:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`,CoreProperties:`http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties`,ExtenderProperties:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties`,Comments:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments`,VmlDrawing:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing`,Table:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/table`,PivotCacheDefinition:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition`,PivotCacheRecords:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords`,PivotTable:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable`,FeaturePropertyBag:`http://schemas.microsoft.com/office/2022/11/relationships/FeaturePropertyBag`,CtrlProp:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp`};var ni=class{constructor(){this.merges={}}add(e){if(this.merges[e.master])this.merges[e.master].expandToAddress(e.address);else{let t=`${e.master}:${e.address}`;this.merges[e.master]=new r(t)}}get mergeCells(){return Object.values(this.merges).map(e=>e.range)}reconcile(e,t){e.forEach(e=>{let r=n.decode(e);for(let e=r.top;e<=r.bottom;e++){let i=t[e-1];for(let t=r.left;t<=r.right;t++){let a=i.cells[t-1];a?a.type===u.ValueType.Merge&&(a.master=r.tl):i.cells[t]={type:u.ValueType.Null,address:n.encodeAddress(e,t)}}}})}getMasterAddress(e){let t=this.hash[e];return t&&t.tl}};function ri(e){if(e==null)return u.ValueType.Null;if(e instanceof String||typeof e==`string`)return u.ValueType.String;if(typeof e==`number`)return u.ValueType.Number;if(typeof e==`boolean`)return u.ValueType.Boolean;if(e instanceof Date)return u.ValueType.Date;if(e.text&&e.hyperlink)return u.ValueType.Hyperlink;if(e.formula)return u.ValueType.Formula;if(e.error)return u.ValueType.Error;throw Error(`I could not understand type of value`)}function ii(e){switch(e.type){case u.ValueType.Formula:return ri(e.result);default:return e.type}}var ai=class extends L{constructor(){super(),this.richTextXform=new Tn}get tag(){return`c`}prepare(e,t){let n=t.styles.addStyleModel(e.style||{},ii(e));switch(n&&(e.styleId=n),e.comment&&t.comments.push({...e.comment,ref:e.address}),e.type){case u.ValueType.String:case u.ValueType.RichText:t.sharedStrings&&(e.ssId=t.sharedStrings.add(e.value));break;case u.ValueType.Date:t.date1904&&(e.date1904=!0);break;case u.ValueType.Hyperlink:t.sharedStrings&&e.text!==void 0&&e.text!==null&&(e.ssId=t.sharedStrings.add(e.text)),t.hyperlinks.push({address:e.address,target:e.hyperlink,tooltip:e.tooltip});break;case u.ValueType.Merge:t.merges.add(e);break;case u.ValueType.Formula:if(t.date1904&&(e.date1904=!0),e.shareType===`shared`&&(e.si=t.siFormulae++),e.formula)t.formulae[e.address]=e;else if(e.sharedFormula){let n=t.formulae[e.sharedFormula];if(!n)throw Error(`Shared Formula master must exist above and or left of clone for cell ${e.address}`);n.si===void 0?(n.shareType=`shared`,n.si=t.siFormulae++,n.range=new r(n.address,e.address)):n.range&&n.range.expandToAddress(e.address),e.si=n.si}break;default:break}}renderFormula(e,t){let n=null;switch(t.shareType){case`shared`:n={t:`shared`,ref:t.ref||t.range.range,si:t.si};break;case`array`:n={t:`array`,ref:t.ref};break;default:t.si!==void 0&&(n={t:`shared`,si:t.si});break}switch(ri(t.result)){case u.ValueType.Null:e.leafNode(`f`,n,t.formula);break;case u.ValueType.String:e.addAttribute(`t`,`str`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result);break;case u.ValueType.Number:e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result);break;case u.ValueType.Boolean:e.addAttribute(`t`,`b`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result?1:0);break;case u.ValueType.Error:e.addAttribute(`t`,`e`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result.error);break;case u.ValueType.Date:e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,we(t.result,t.date1904));break;default:throw Error(`I could not understand type of value`)}}render(e,t){if(!(t.type===u.ValueType.Null&&!t.styleId)){switch(e.openNode(`c`),e.addAttribute(`r`,t.address),t.styleId&&e.addAttribute(`s`,t.styleId),t.type){case u.ValueType.Null:break;case u.ValueType.Number:e.leafNode(`v`,null,t.value);break;case u.ValueType.Boolean:e.addAttribute(`t`,`b`),e.leafNode(`v`,null,t.value?`1`:`0`);break;case u.ValueType.Checkbox:e.addAttribute(`t`,`b`),e.leafNode(`v`,null,t.value?`1`:`0`);break;case u.ValueType.Error:e.addAttribute(`t`,`e`),e.leafNode(`v`,null,t.value.error);break;case u.ValueType.String:case u.ValueType.RichText:t.ssId===void 0?t.value&&t.value.richText?(e.addAttribute(`t`,`inlineStr`),e.openNode(`is`),t.value.richText.forEach(t=>{this.richTextXform.render(e,t)}),e.closeNode(`is`)):(e.addAttribute(`t`,`str`),e.leafNode(`v`,null,t.value)):(e.addAttribute(`t`,`s`),e.leafNode(`v`,null,t.ssId));break;case u.ValueType.Date:e.leafNode(`v`,null,we(t.value,t.date1904));break;case u.ValueType.Hyperlink:t.ssId===void 0?(e.addAttribute(`t`,`str`),e.leafNode(`v`,null,t.text)):(e.addAttribute(`t`,`s`),e.leafNode(`v`,null,t.ssId));break;case u.ValueType.Formula:this.renderFormula(e,t);break;case u.ValueType.Merge:break;default:break}e.closeNode()}}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`c`:return this.model={address:e.attributes.r},this.t=e.attributes.t,e.attributes.s&&(this.model.styleId=parseInt(e.attributes.s,10)),!0;case`f`:return this.currentNode=`f`,this.model.si=e.attributes.si,this.model.shareType=e.attributes.t,this.model.ref=e.attributes.ref,!0;case`v`:return this.currentNode=`v`,!0;case`t`:return this.currentNode=`t`,!0;case`r`:return this.parser=this.richTextXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){if(this.parser){this.parser.parseText(e);return}switch(this.currentNode){case`f`:this.model.formula=this.model.formula?this.model.formula+e:e;break;case`v`:case`t`:this.model.value&&this.model.value.richText?this.model.value.richText.text=this.model.value.richText.text?this.model.value.richText.text+e:e:this.model.value=this.model.value?this.model.value+e:e;break;default:break}}parseClose(e){switch(e){case`c`:{let{model:e}=this;if(e.formula||e.shareType)e.type=u.ValueType.Formula,e.value&&=(this.t===`str`?e.result=Oe(e.value):this.t===`b`?e.result=parseInt(e.value,10)!==0:this.t===`e`?e.result={error:e.value}:e.result=parseFloat(e.value),void 0);else if(e.value!==void 0)switch(this.t){case`s`:e.type=u.ValueType.String,e.value=parseInt(e.value,10);break;case`str`:e.type=u.ValueType.String,e.value=Oe(e.value);break;case`inlineStr`:e.type=u.ValueType.String;break;case`b`:e.type=u.ValueType.Boolean,e.value=parseInt(e.value,10)!==0;break;case`e`:e.type=u.ValueType.Error,e.value={error:e.value};break;case`d`:e.type=u.ValueType.Date,e.value=new Date(e.value);break;default:e.type=u.ValueType.Number,e.value=parseFloat(e.value);break}else e.styleId?e.type=u.ValueType.Null:e.type=u.ValueType.Merge;return!1}case`f`:case`v`:case`is`:return this.currentNode=void 0,!0;case`t`:return this.parser?(this.parser.parseClose(e),!0):(this.currentNode=void 0,!0);case`r`:return this.model.value=this.model.value||{},this.model.value.richText=this.model.value.richText??[],this.model.value.richText.push(this.parser.model),this.parser=void 0,this.currentNode=void 0,!0;default:return this.parser?(this.parser.parseClose(e),!0):!1}}reconcile(e,t){let n=e.styleId!==void 0&&t.styles&&t.styles.getStyleModel(e.styleId);switch(n&&(e.style=n),e.styleId!==void 0&&(e.styleId=void 0),e.type){case u.ValueType.String:typeof e.value==`number`&&t.sharedStrings&&(e.value=t.sharedStrings.getString(e.value)),e.value.richText&&(e.type=u.ValueType.RichText);break;case u.ValueType.Number:n&&je(n.numFmt)&&(e.type=u.ValueType.Date,e.value=Te(e.value,t.date1904));break;case u.ValueType.Formula:e.result!==void 0&&typeof e.result==`number`&&n&&je(n.numFmt)&&(e.result=Te(e.result,t.date1904)),e.shareType===`shared`&&(e.ref?t.formulae[e.si]=e.address:(e.sharedFormula=t.formulae[e.si],delete e.shareType),delete e.si);break;default:break}let r=t.hyperlinkMap[e.address];r&&(e.type===u.ValueType.Formula?(e.text=e.result,e.result=void 0):(e.text=e.value,e.value=void 0),e.type=u.ValueType.Hyperlink,e.hyperlink=r);let i=t.commentsMap&&t.commentsMap[e.address];i&&(e.comment=i)}},oi=class extends L{constructor(e){super(),this.maxItems=e&&e.maxItems,this.map={c:new ai}}get tag(){return`row`}reset(){super.reset(),this.numRowsSeen=0,this.lastCellCol=0}prepare(e,t){let n=t.styles.addStyleModel(e.style);n&&(e.styleId=n);let r=this.map.c;e.cells.forEach(e=>{r.prepare(e,t)})}render(e,t,n){if(!t)return;e.openNode(`row`),e.addAttribute(`r`,t.number),t.height&&(e.addAttribute(`ht`,t.height),e.addAttribute(`customHeight`,`1`)),t.hidden&&e.addAttribute(`hidden`,`1`),t.min>0&&t.max>0&&t.min<=t.max&&e.addAttribute(`spans`,`${t.min}:${t.max}`),t.styleId&&(e.addAttribute(`s`,t.styleId),e.addAttribute(`customFormat`,`1`)),t.dyDescent!==void 0&&e.addAttribute(`x14ac:dyDescent`,t.dyDescent),t.outlineLevel&&e.addAttribute(`outlineLevel`,t.outlineLevel),t.collapsed&&e.addAttribute(`collapsed`,`1`);let r=this.map.c;t.cells.forEach(t=>{r.render(e,t,n)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;if(e.name===`row`){this.numRowsSeen+=1,this.lastCellCol=0;let t=e.attributes.spans?e.attributes.spans.split(`:`).map(e=>parseInt(e,10)):[void 0,void 0],n=this.model={number:e.attributes.r?parseInt(e.attributes.r,10):this.numRowsSeen,min:t[0],max:t[1],cells:[]};return e.attributes.s&&(n.styleId=parseInt(e.attributes.s,10)),j(e.attributes.hidden)&&(n.hidden=!0),j(e.attributes.bestFit)&&(n.bestFit=!0),e.attributes.ht&&(n.height=parseFloat(e.attributes.ht)),e.attributes.outlineLevel&&(n.outlineLevel=parseInt(e.attributes.outlineLevel,10)),j(e.attributes.collapsed)&&(n.collapsed=!0),e.attributes[`x14ac:dyDescent`]!==void 0&&(n.dyDescent=parseFloat(e.attributes[`x14ac:dyDescent`])),!0}return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){let e=this.parser.model;if(e.address?this.lastCellCol=n.decodeAddress(e.address).col:(this.lastCellCol+=1,e.address=n.encodeAddress(this.model.number,this.lastCellCol)),this.model.cells.push(e),this.maxItems&&this.model.cells.length>this.maxItems)throw Error(`Max column count (${this.maxItems}) exceeded`);this.parser=void 0}return!0}return!1}reconcile(e,t){e.style=e.styleId===void 0?{}:t.styles.getStyleModel(e.styleId),e.styleId!==void 0&&(e.styleId=void 0);let n=this.map.c;e.cells.forEach(e=>{n.reconcile(e,t)})}},si=class extends L{get tag(){return`col`}prepare(e,t){let n=t.styles.addStyleModel(e.style||{});n&&(e.styleId=n)}render(e,t){e.openNode(`col`),e.addAttribute(`min`,t.min),e.addAttribute(`max`,t.max),t.width&&e.addAttribute(`width`,t.width),t.styleId&&e.addAttribute(`style`,t.styleId),t.hidden&&e.addAttribute(`hidden`,`1`),t.bestFit&&e.addAttribute(`bestFit`,`1`),t.outlineLevel&&e.addAttribute(`outlineLevel`,t.outlineLevel),t.collapsed&&e.addAttribute(`collapsed`,`1`),e.addAttribute(`customWidth`,`1`),e.closeNode()}parseOpen(e){if(e.name===`col`){let t=this.model={min:parseInt(e.attributes.min??`0`,10),max:parseInt(e.attributes.max??`0`,10),width:e.attributes.width===void 0?void 0:parseFloat(e.attributes.width??`0`)};return e.attributes.style&&(t.styleId=parseInt(e.attributes.style,10)),j(e.attributes.hidden)&&(t.hidden=!0),j(e.attributes.bestFit)&&(t.bestFit=!0),e.attributes.outlineLevel&&(t.outlineLevel=parseInt(e.attributes.outlineLevel,10)),j(e.attributes.collapsed)&&(t.collapsed=!0),!0}return!1}parseText(){}parseClose(){return!1}reconcile(e,t){e.styleId!==void 0&&(e.style=t.styles.getStyleModel(e.styleId))}},ci=class extends L{get tag(){return`dimension`}render(e,t){t&&e.leafNode(`dimension`,{ref:t})}parseOpen(e){return e.name===`dimension`?(this.model=e.attributes.ref,!0):!1}parseText(){}parseClose(){return!1}},li=class extends L{get tag(){return`hyperlink`}render(e,t){this.isInternalLink(t)?e.leafNode(`hyperlink`,{ref:t.address,"r:id":t.rId,tooltip:t.tooltip,location:t.target}):e.leafNode(`hyperlink`,{ref:t.address,"r:id":t.rId,tooltip:t.tooltip})}parseOpen(e){return e.name===`hyperlink`?(this.model={address:e.attributes.ref,rId:e.attributes[`r:id`],tooltip:e.attributes.tooltip},e.attributes.location&&(this.model.target=e.attributes.location),!0):!1}parseText(){}parseClose(){return!1}isInternalLink(e){return!!(e.target&&/^[^!]+![a-zA-Z]+[\d]+$/.test(e.target))}},ui=class extends L{get tag(){return`mergeCell`}render(e,t){e.leafNode(`mergeCell`,{ref:t})}parseOpen(e){return e.name===`mergeCell`?(this.model=e.attributes.ref,!0):!1}parseText(){}parseClose(){return!1}};function di(e,t,n,r){let i=t[n];i===void 0?r!==void 0&&(e[n]=r):e[n]=i}function fi(e,t,n,r){let i=t[n];i===void 0?r!==void 0&&(e[n]=r):e[n]=j(i)}function pi(e){if(!e)return[];let t=[],r={};for(let[n,i]of Object.entries(e))if(i!=null)if(n.startsWith(`range:`)){let e=n.slice(6),{sqref:r,...a}=i;t.push({...a,sqref:e})}else r[n]=i;if(Object.keys(r).length===0)return t;let i=Object.entries(r).map(([e,t])=>({address:e,dataValidation:t,marked:!1})).sort((e,t)=>e.address.localeCompare(t.address)),a=Object.fromEntries(i.map(e=>[e.address,e])),o=(e,t,i)=>{for(let a=0;a<t;a++){let t=n.encodeAddress(e.row+a,i);if(!r[t]||!p(r[e.address],r[t]))return!1}return!0},s=i.map(e=>{if(!e.marked){let t=n.decodeEx(e.address);if(t.dimensions)return a[t.dimensions].marked=!0,{...e.dataValidation,sqref:e.address};let i=1,s=n.encodeAddress(t.row+i,t.col);for(;r[s]&&p(e.dataValidation,r[s]);)i++,s=n.encodeAddress(t.row+i,t.col);let c=1;for(;o(t,i,t.col+c);)c++;for(let e=0;e<i;e++)for(let r=0;r<c;r++)s=n.encodeAddress(t.row+e,t.col+r),a[s].marked=!0;if(i>1||c>1){let r=t.row+(i-1),a=t.col+(c-1);return{...e.dataValidation,sqref:`${e.address}:${n.encodeAddress(r,a)}`}}return{...e.dataValidation,sqref:e.address}}return null}).filter(Boolean);return[...t,...s]}var mi=class extends L{get tag(){return`dataValidations`}render(e,t){let n=pi(t);n.length&&(e.openNode(`dataValidations`,{count:n.length}),n.forEach(t=>{e.openNode(`dataValidation`),t.type!==`any`&&(e.addAttribute(`type`,t.type),t.operator&&t.type!==`list`&&t.operator!==`between`&&e.addAttribute(`operator`,t.operator),t.allowBlank&&e.addAttribute(`allowBlank`,`1`)),t.showInputMessage&&e.addAttribute(`showInputMessage`,`1`),t.promptTitle&&e.addAttribute(`promptTitle`,t.promptTitle),t.prompt&&e.addAttribute(`prompt`,t.prompt),t.showErrorMessage&&e.addAttribute(`showErrorMessage`,`1`),t.errorStyle&&e.addAttribute(`errorStyle`,t.errorStyle),t.errorTitle&&e.addAttribute(`errorTitle`,t.errorTitle),t.error&&e.addAttribute(`error`,t.error),e.addAttribute(`sqref`,t.sqref),(t.formulae??[]).forEach((n,r)=>{e.openNode(`formula${r+1}`),t.type===`date`?e.writeText(we(new Date(n))):e.writeText(n),e.closeNode()}),e.closeNode()}),e.closeNode())}parseOpen(e){switch(e.name){case`dataValidations`:return this.model={},!0;case`dataValidation`:{this._address=e.attributes.sqref;let t={type:e.attributes.type??`any`,formulae:[]};switch(e.attributes.type&&fi(t,e.attributes,`allowBlank`),fi(t,e.attributes,`showInputMessage`),fi(t,e.attributes,`showErrorMessage`),t.type){case`any`:case`list`:case`custom`:break;default:di(t,e.attributes,`operator`,`between`);break}return di(t,e.attributes,`promptTitle`),di(t,e.attributes,`prompt`),di(t,e.attributes,`errorStyle`),di(t,e.attributes,`errorTitle`),di(t,e.attributes,`error`),this._dataValidation=t,!0}case`formula1`:case`formula2`:return this._formula=[],!0;default:return!1}}parseText(e){this._formula&&this._formula.push(e)}parseClose(e){switch(e){case`dataValidations`:return!1;case`dataValidation`:return(!this._dataValidation.formulae||!this._dataValidation.formulae.length)&&(delete this._dataValidation.formulae,delete this._dataValidation.operator),this._address.split(/\s+/g).forEach(e=>{e.includes(`:`)?this.model[`range:${e}`]=this._dataValidation:this.model[e]=this._dataValidation}),!0;case`formula1`:case`formula2`:{let e=this._formula.join(``);switch(this._dataValidation.type){case`whole`:case`textLength`:e=parseInt(e,10);break;case`decimal`:e=parseFloat(e);break;case`date`:e=Te(parseFloat(e));break;default:break}return this._dataValidation.formulae.push(e),this._formula=void 0,!0}default:return!0}}},hi=class extends L{get tag(){return`pageSetUpPr`}render(e,t){return t&&t.fitToPage?(e.leafNode(this.tag,{fitToPage:t.fitToPage?`1`:void 0}),!0):!1}parseOpen(e){return e.name===this.tag?(this.model={fitToPage:e.attributes.fitToPage===`1`},!0):!1}parseText(){}parseClose(){return!1}};let gi=e=>e!==void 0;var _i=class extends L{get tag(){return`outlinePr`}render(e,t){return t&&(gi(t.summaryBelow)||gi(t.summaryRight))?(e.leafNode(this.tag,{summaryBelow:gi(t.summaryBelow)?Number(t.summaryBelow):void 0,summaryRight:gi(t.summaryRight)?Number(t.summaryRight):void 0}),!0):!1}parseOpen(e){return e.name===this.tag?(this.model={summaryBelow:gi(e.attributes.summaryBelow)?!!Number(e.attributes.summaryBelow):void 0,summaryRight:gi(e.attributes.summaryRight)?!!Number(e.attributes.summaryRight):void 0},!0):!1}parseText(){}parseClose(){return!1}},vi=class extends L{constructor(){super(),this.map={tabColor:new z(`tabColor`),pageSetUpPr:new hi,outlinePr:new _i}}get tag(){return`sheetPr`}render(e,t){if(t){e.addRollback(),e.openNode(`sheetPr`);let n=!1;n=this.map.tabColor.render(e,t.tabColor)||n,n=this.map.pageSetUpPr.render(e,t.pageSetup)||n,n=this.map.outlinePr.render(e,t.outlineProperties)||n,n?(e.closeNode(),e.commit()):e.rollback()}}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.reset(),!0):this.map[e.name]?(this.parser=this.map[e.name],this.parser.parseOpen(e),!0):!1}parseText(e){return this.parser?(this.parser.parseText(e),!0):!1}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):(this.map.tabColor.model||this.map.pageSetUpPr.model||this.map.outlinePr.model?(this.model={},this.map.tabColor.model&&(this.model.tabColor=this.map.tabColor.model),this.map.pageSetUpPr.model&&(this.model.pageSetup=this.map.pageSetUpPr.model),this.map.outlinePr.model&&(this.model.outlineProperties=this.map.outlinePr.model)):this.model=null,!1)}},yi=class extends L{get tag(){return`sheetFormatPr`}render(e,t){if(t){let n={defaultRowHeight:t.defaultRowHeight,outlineLevelRow:t.outlineLevelRow||void 0,outlineLevelCol:t.outlineLevelCol||void 0,"x14ac:dyDescent":t.dyDescent!==void 0&&t.dyDescent!==0?t.dyDescent:void 0};t.defaultColWidth&&(n.defaultColWidth=t.defaultColWidth),t.customHeight&&(n.customHeight=`1`),Object.values(n).some(e=>e!==void 0)&&e.leafNode(`sheetFormatPr`,n)}}parseOpen(e){return e.name===`sheetFormatPr`?(this.model={defaultRowHeight:parseFloat(e.attributes.defaultRowHeight??`0`),dyDescent:e.attributes[`x14ac:dyDescent`]===void 0?void 0:parseFloat(e.attributes[`x14ac:dyDescent`]),outlineLevelRow:parseInt(e.attributes.outlineLevelRow??`0`,10),outlineLevelCol:parseInt(e.attributes.outlineLevelCol??`0`,10)},e.attributes.defaultColWidth&&(this.model.defaultColWidth=parseFloat(e.attributes.defaultColWidth)),e.attributes.customHeight===`1`&&(this.model.customHeight=!0),!0):!1}parseText(){}parseClose(){return!1}};let bi={frozen:`frozen`,frozenSplit:`frozen`,split:`split`};var xi=class extends L{get tag(){return`sheetView`}prepare(e){switch(e.state){case`frozen`:case`split`:break;default:e.state=`normal`;break}}render(e,t){let r={};t.tabSelected&&(r.tabSelected=`1`),r.workbookViewId=t.workbookViewId??0,e.openNode(`sheetView`,r);let i=function(t,n,r){r&&e.addAttribute(t,n)};i(`rightToLeft`,`1`,t.rightToLeft===!0),i(`showRuler`,`0`,t.showRuler===!1),i(`showRowColHeaders`,`0`,t.showRowColHeaders===!1),i(`showGridLines`,`0`,t.showGridLines===!1),i(`zoomScale`,t.zoomScale,t.zoomScale!==void 0&&t.zoomScale!==100),i(`zoomScaleNormal`,t.zoomScaleNormal,t.zoomScaleNormal!==void 0&&t.zoomScaleNormal!==100),i(`view`,t.style,t.style);let a,o,s,c;switch(t.state){case`frozen`:o=t.xSplit??0,s=t.ySplit??0,a=t.topLeftCell||n.getAddress(s+1,o+1).address,c=t.xSplit&&t.ySplit&&`bottomRight`||t.xSplit&&`topRight`||`bottomLeft`,e.leafNode(`pane`,{xSplit:t.xSplit||void 0,ySplit:t.ySplit||void 0,topLeftCell:a,activePane:c,state:`frozen`}),e.leafNode(`selection`,{pane:c,activeCell:t.activeCell,sqref:t.activeCell});break;case`split`:t.activePane===`topLeft`&&(t.activePane=void 0),e.leafNode(`pane`,{xSplit:t.xSplit||void 0,ySplit:t.ySplit||void 0,topLeftCell:t.topLeftCell,activePane:t.activePane}),e.leafNode(`selection`,{pane:t.activePane,activeCell:t.activeCell,sqref:t.activeCell});break;case`normal`:t.activeCell&&e.leafNode(`selection`,{activeCell:t.activeCell,sqref:t.activeCell});break;default:break}e.closeNode()}parseOpen(e){switch(e.name){case`sheetView`:return this.sheetView={workbookViewId:parseInt(e.attributes.workbookViewId,10),rightToLeft:e.attributes.rightToLeft===`1`,tabSelected:e.attributes.tabSelected===`1`,showRuler:e.attributes.showRuler!==`0`,showRowColHeaders:e.attributes.showRowColHeaders!==`0`,showGridLines:e.attributes.showGridLines!==`0`,zoomScale:parseInt(e.attributes.zoomScale??`100`,10),zoomScaleNormal:parseInt(e.attributes.zoomScaleNormal??`100`,10),style:e.attributes.view},this.pane=void 0,this.selections={},!0;case`pane`:return this.pane={xSplit:parseInt(e.attributes.xSplit??`0`,10),ySplit:parseInt(e.attributes.ySplit??`0`,10),topLeftCell:e.attributes.topLeftCell,activePane:e.attributes.activePane??`topLeft`,state:e.attributes.state},!0;case`selection`:{let t=e.attributes.pane??`topLeft`;return this.selections[t]={pane:t,activeCell:e.attributes.activeCell},!0}default:return!1}}parseText(){}parseClose(e){let t,n;switch(e){case`sheetView`:return this.sheetView&&this.pane?(t=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,tabSelected:this.sheetView.tabSelected,state:bi[this.pane.state]??`split`,xSplit:this.pane.xSplit,ySplit:this.pane.ySplit,topLeftCell:this.pane.topLeftCell,showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},this.model.state===`split`&&(t.activePane=this.pane.activePane),n=this.selections[this.pane.activePane],n&&n.activeCell&&(t.activeCell=n.activeCell),this.sheetView.style&&(t.style=this.sheetView.style)):(t=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,tabSelected:this.sheetView.tabSelected,state:`normal`,showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},n=this.selections.topLeft,n&&n.activeCell&&(t.activeCell=n.activeCell),this.sheetView.style&&(t.style=this.sheetView.style)),!1;default:return!0}}reconcile(){}};function K(e,t){return e?t:void 0}function q(e,t){return e===t?!0:void 0}var Si=class extends L{get tag(){return`sheetProtection`}render(e,t){if(t){let n={sheet:K(t.sheet,`1`),selectLockedCells:t.selectLockedCells===!1?`1`:void 0,selectUnlockedCells:t.selectUnlockedCells===!1?`1`:void 0,formatCells:K(t.formatCells,`0`),formatColumns:K(t.formatColumns,`0`),formatRows:K(t.formatRows,`0`),insertColumns:K(t.insertColumns,`0`),insertRows:K(t.insertRows,`0`),insertHyperlinks:K(t.insertHyperlinks,`0`),deleteColumns:K(t.deleteColumns,`0`),deleteRows:K(t.deleteRows,`0`),sort:K(t.sort,`0`),autoFilter:K(t.autoFilter,`0`),pivotTables:K(t.pivotTables,`0`)};t.sheet&&(n.algorithmName=t.algorithmName,n.hashValue=t.hashValue,n.saltValue=t.saltValue,n.spinCount=t.spinCount,n.objects=K(t.objects===!1,`1`),n.scenarios=K(t.scenarios===!1,`1`)),Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={sheet:q(e.attributes.sheet,`1`),objects:e.attributes.objects===`1`?!1:void 0,scenarios:e.attributes.scenarios===`1`?!1:void 0,selectLockedCells:e.attributes.selectLockedCells===`1`?!1:void 0,selectUnlockedCells:e.attributes.selectUnlockedCells===`1`?!1:void 0,formatCells:q(e.attributes.formatCells,`0`),formatColumns:q(e.attributes.formatColumns,`0`),formatRows:q(e.attributes.formatRows,`0`),insertColumns:q(e.attributes.insertColumns,`0`),insertRows:q(e.attributes.insertRows,`0`),insertHyperlinks:q(e.attributes.insertHyperlinks,`0`),deleteColumns:q(e.attributes.deleteColumns,`0`),deleteRows:q(e.attributes.deleteRows,`0`),sort:q(e.attributes.sort,`0`),autoFilter:q(e.attributes.autoFilter,`0`),pivotTables:q(e.attributes.pivotTables,`0`)},e.attributes.algorithmName&&(this.model.algorithmName=e.attributes.algorithmName,this.model.hashValue=e.attributes.hashValue,this.model.saltValue=e.attributes.saltValue,this.model.spinCount=parseInt(e.attributes.spinCount,10)),!0;default:return!1}}parseText(){}parseClose(){return!1}},Ci=class extends L{get tag(){return`pageMargins`}render(e,t){if(t){let n={left:t.left,right:t.right,top:t.top,bottom:t.bottom,header:t.header,footer:t.footer};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={left:parseFloat(e.attributes.left||.7),right:parseFloat(e.attributes.right||.7),top:parseFloat(e.attributes.top||.75),bottom:parseFloat(e.attributes.bottom||.75),header:parseFloat(e.attributes.header||.3),footer:parseFloat(e.attributes.footer||.3)},!0;default:return!1}}parseText(){}parseClose(){return!1}};function wi(e){return e?`1`:void 0}function Ti(e){switch(e){case`overThenDown`:return e;default:return}}function Ei(e){switch(e){case`atEnd`:case`asDisplyed`:return e;default:return}}function Di(e){switch(e){case`dash`:case`blank`:case`NA`:return e;default:return}}function Oi(e){return e===void 0?void 0:parseInt(e,10)}var ki=class extends L{get tag(){return`pageSetup`}_dpiToXml(e){if(e!==void 0&&Number.isFinite(e)&&e!==4294967295)return e}render(e,t){if(t){let n={paperSize:t.paperSize,orientation:t.orientation,horizontalDpi:this._dpiToXml(t.horizontalDpi),verticalDpi:this._dpiToXml(t.verticalDpi),pageOrder:Ti(t.pageOrder),blackAndWhite:wi(t.blackAndWhite),draft:wi(t.draft),cellComments:Ei(t.cellComments),errors:Di(t.errors),scale:t.scale===100?void 0:t.scale,fitToWidth:t.fitToWidth===1?void 0:t.fitToWidth,fitToHeight:t.fitToHeight===1?void 0:t.fitToHeight,firstPageNumber:t.firstPageNumber,useFirstPageNumber:wi(!!t.firstPageNumber),usePrinterDefaults:wi(t.usePrinterDefaults),copies:t.copies};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={paperSize:Oi(e.attributes.paperSize),orientation:e.attributes.orientation??`portrait`,horizontalDpi:parseInt(e.attributes.horizontalDpi??`4294967295`,10),verticalDpi:parseInt(e.attributes.verticalDpi??`4294967295`,10),pageOrder:e.attributes.pageOrder??`downThenOver`,blackAndWhite:e.attributes.blackAndWhite===`1`,draft:e.attributes.draft===`1`,cellComments:e.attributes.cellComments??`None`,errors:e.attributes.errors??`displayed`,scale:parseInt(e.attributes.scale??`100`,10),fitToWidth:parseInt(e.attributes.fitToWidth??`1`,10),fitToHeight:parseInt(e.attributes.fitToHeight??`1`,10),firstPageNumber:parseInt(e.attributes.firstPageNumber??`1`,10),useFirstPageNumber:e.attributes.useFirstPageNumber===`1`,usePrinterDefaults:e.attributes.usePrinterDefaults===`1`,copies:parseInt(e.attributes.copies??`1`,10)},!0;default:return!1}}parseText(){}parseClose(){return!1}};function Ai(e){return e?`1`:void 0}var ji=class extends L{get tag(){return`printOptions`}render(e,t){if(t){let n={headings:Ai(t.showRowColHeaders),gridLines:Ai(t.showGridLines),horizontalCentered:Ai(t.horizontalCentered),verticalCentered:Ai(t.verticalCentered)};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={showRowColHeaders:e.attributes.headings===`1`,showGridLines:e.attributes.gridLines===`1`,horizontalCentered:e.attributes.horizontalCentered===`1`,verticalCentered:e.attributes.verticalCentered===`1`},!0;default:return!1}}parseText(){}parseClose(){return!1}},Mi=class extends L{get tag(){return`autoFilter`}render(e,t){if(t)if(typeof t==`string`)e.leafNode(`autoFilter`,{ref:t});else{let r=function(e){return typeof e==`string`?e:n.getAddress(e.row,e.column).address},i=r(t.from),a=r(t.to);i&&a&&e.leafNode(`autoFilter`,{ref:`${i}:${a}`})}}parseOpen(e){e.name===`autoFilter`&&(this.model=e.attributes.ref)}},Ni=class extends L{get tag(){return`picture`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},Pi=class extends L{get tag(){return`drawing`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},Fi=class extends L{get tag(){return`tablePart`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},Ii=class extends L{get tag(){return`brk`}render(e,t){e.leafNode(`brk`,t)}parseOpen(e){if(e.name===`brk`){let{id:t,max:n,man:r,min:i}=e.attributes;return this.model={id:+t,max:+n,man:+r},i!==void 0&&(this.model.min=+i),!0}return!1}parseText(){}parseClose(){return!1}},Li=class extends R{constructor(){super({tag:`rowBreaks`,count:!0,childXform:new Ii})}render(e,t){if(t&&t.length){e.openNode(this.tag,this.$),e.addAttribute(this.$count,t.length),e.addAttribute(`manualBreakCount`,t.length);let{childXform:n}=this;for(let r of t)n.render(e,r);e.closeNode()}}},Ri=class extends R{constructor(){super({tag:`colBreaks`,count:!0,childXform:new Ii})}render(e,t){if(t&&t.length){e.openNode(this.tag,this.$),e.addAttribute(this.$count,t.length),e.addAttribute(`manualBreakCount`,t.length);let{childXform:n}=this;for(let r of t)n.render(e,r);e.closeNode()}}},zi=class extends L{get tag(){return`headerFooter`}render(e,t){if(t){e.addRollback();let n=!1;e.openNode(`headerFooter`),t.differentFirst&&(e.addAttribute(`differentFirst`,`1`),n=!0),t.differentOddEven&&(e.addAttribute(`differentOddEven`,`1`),n=!0),t.oddHeader&&typeof t.oddHeader==`string`&&(e.leafNode(`oddHeader`,null,t.oddHeader),n=!0),t.oddFooter&&typeof t.oddFooter==`string`&&(e.leafNode(`oddFooter`,null,t.oddFooter),n=!0),t.evenHeader&&typeof t.evenHeader==`string`&&(e.leafNode(`evenHeader`,null,t.evenHeader),n=!0),t.evenFooter&&typeof t.evenFooter==`string`&&(e.leafNode(`evenFooter`,null,t.evenFooter),n=!0),t.firstHeader&&typeof t.firstHeader==`string`&&(e.leafNode(`firstHeader`,null,t.firstHeader),n=!0),t.firstFooter&&typeof t.firstFooter==`string`&&(e.leafNode(`firstFooter`,null,t.firstFooter),n=!0),n?(e.closeNode(),e.commit()):e.rollback()}}parseOpen(e){switch(e.name){case`headerFooter`:return this.model={},e.attributes.differentFirst&&(this.model.differentFirst=parseInt(e.attributes.differentFirst,0)===1),e.attributes.differentOddEven&&(this.model.differentOddEven=parseInt(e.attributes.differentOddEven,0)===1),!0;case`oddHeader`:return this.currentNode=`oddHeader`,!0;case`oddFooter`:return this.currentNode=`oddFooter`,!0;case`evenHeader`:return this.currentNode=`evenHeader`,!0;case`evenFooter`:return this.currentNode=`evenFooter`,!0;case`firstHeader`:return this.currentNode=`firstHeader`,!0;case`firstFooter`:return this.currentNode=`firstFooter`,!0;default:return!1}}parseText(e){switch(this.currentNode){case`oddHeader`:this.model.oddHeader=(this.model.oddHeader??``)+e;break;case`oddFooter`:this.model.oddFooter=(this.model.oddFooter??``)+e;break;case`evenHeader`:this.model.evenHeader=(this.model.evenHeader??``)+e;break;case`evenFooter`:this.model.evenFooter=(this.model.evenFooter??``)+e;break;case`firstHeader`:this.model.firstHeader=(this.model.firstHeader??``)+e;break;case`firstFooter`:this.model.firstFooter=(this.model.firstFooter??``)+e;break;default:break}}parseClose(){switch(this.currentNode){case`oddHeader`:case`oddFooter`:case`evenHeader`:case`evenFooter`:case`firstHeader`:case`firstFooter`:return this.currentNode=void 0,!0;default:return!1}}},J=class extends L{createNewModel(e){return{}}parseOpen(e){return this.parser=this.parser||this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model=this.createNewModel(e),!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}onParserClose(e,t){this.model[e]=t.model}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.onParserClose(e,this.parser),this.parser=void 0),!0):e!==this.tag}get tag(){return``}},Bi=class extends L{get tag(){return`cfvo`}render(e,t){e.leafNode(this.tag,{type:t.type,val:t.value})}parseOpen(e){this.model={type:e.attributes.type,value:L.toFloatValue(e.attributes.val)}}parseClose(e){return e!==this.tag}},Vi=class extends J{constructor(){super(),this.map={cfvo:this.cfvoXform=new Bi,color:this.colorXform=new z}}get tag(){return`dataBar`}render(e,t){e.openNode(this.tag),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),this.colorXform.render(e,t.color),e.closeNode()}createNewModel(){return{cfvo:[]}}onParserClose(e,t){switch(e){case`cfvo`:this.model.cfvo.push(t.model);break;case`color`:this.model.color=t.model;break}}},Hi=class extends L{get tag(){return`x14:id`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},Ui=class extends J{constructor(){super(),this.map={"x14:id":this.idXform=new Hi}}get tag(){return`ext`}render(e,t){e.openNode(this.tag,{uri:`{B025F937-C7B1-47D3-B67F-A62EFF666E3E}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`}),this.idXform.render(e,t.x14Id),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){this.model.x14Id=t.model}},Wi=class extends J{constructor(){super(),this.map={ext:new Ui}}get tag(){return`extLst`}render(e,t){e.openNode(this.tag),this.map.ext.render(e,t),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){Object.assign(this.model,t.model)}},Gi=class extends L{get tag(){return`formula`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},Ki=class extends J{constructor(){super(),this.map={cfvo:this.cfvoXform=new Bi,color:this.colorXform=new z}}get tag(){return`colorScale`}render(e,t){e.openNode(this.tag),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),t.color.forEach(t=>{this.colorXform.render(e,t)}),e.closeNode()}createNewModel(e){return{cfvo:[],color:[]}}onParserClose(e,t){this.model[e].push(t.model)}},qi=class extends J{constructor(){super(),this.map={cfvo:this.cfvoXform=new Bi}}get tag(){return`iconSet`}render(e,t){e.openNode(this.tag,{iconSet:L.toStringAttribute(t.iconSet,`3TrafficLights`),reverse:L.toBoolAttribute(t.reverse,!1),showValue:L.toBoolAttribute(t.showValue,!0)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),e.closeNode()}createNewModel({attributes:e}){return{iconSet:L.toStringValue(e.iconSet,`3TrafficLights`),reverse:L.toBoolValue(e.reverse),showValue:L.toBoolValue(e.showValue),cfvo:[]}}onParserClose(e,t){this.model[e].push(t.model)}};let Ji={"3Triangles":!0,"3Stars":!0,"5Boxes":!0},Yi=e=>{if(e.formulae&&e.formulae[0])return e.formulae[0];let{tl:t}=new r(e.ref);switch(e.operator){case`containsText`:return`NOT(ISERROR(SEARCH("${e.text}",${t})))`;case`containsBlanks`:return`LEN(TRIM(${t}))=0`;case`notContainsBlanks`:return`LEN(TRIM(${t}))>0`;case`containsErrors`:return`ISERROR(${t})`;case`notContainsErrors`:return`NOT(ISERROR(${t}))`;default:return}},Xi=e=>{if(e.formulae&&e.formulae[0])return e.formulae[0];let{tl:t}=new r(e.ref);switch(e.timePeriod){case`thisWeek`:return`AND(TODAY()-ROUNDDOWN(${t},0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(${t},0)-TODAY()<=7-WEEKDAY(TODAY()))`;case`lastWeek`:return`AND(TODAY()-ROUNDDOWN(${t},0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(${t},0)<(WEEKDAY(TODAY())+7))`;case`nextWeek`:return`AND(ROUNDDOWN(${t},0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(${t},0)-TODAY()<(15-WEEKDAY(TODAY())))`;case`yesterday`:return`FLOOR(${t},1)=TODAY()-1`;case`today`:return`FLOOR(${t},1)=TODAY()`;case`tomorrow`:return`FLOOR(${t},1)=TODAY()+1`;case`last7Days`:return`AND(TODAY()-FLOOR(${t},1)<=6,FLOOR(${t},1)<=TODAY())`;case`lastMonth`:return`AND(MONTH(${t})=MONTH(EDATE(TODAY(),0-1)),YEAR(${t})=YEAR(EDATE(TODAY(),0-1)))`;case`thisMonth`:return`AND(MONTH(${t})=MONTH(TODAY()),YEAR(${t})=YEAR(TODAY()))`;case`nextMonth`:return`AND(MONTH(${t})=MONTH(EDATE(TODAY(),0+1)),YEAR(${t})=YEAR(EDATE(TODAY(),0+1)))`;default:return}},Zi=e=>{let{type:t,operator:n}=e;switch(t){case`containsText`:case`containsBlanks`:case`notContainsBlanks`:case`containsErrors`:case`notContainsErrors`:return{type:`containsText`,operator:t};default:return{type:t,operator:n}}};var Qi=class e extends J{constructor(){super(),this.map={dataBar:this.databarXform=new Vi,extLst:this.extLstRefXform=new Wi,formula:this.formulaXform=new Gi,colorScale:this.colorScaleXform=new Ki,iconSet:this.iconSetXform=new qi}}get tag(){return`cfRule`}static isPrimitive(e){return!(e.type===`iconSet`&&(e.custom||Ji[e.iconSet]))}render(e,t){switch(t.type){case`expression`:this.renderExpression(e,t);break;case`cellIs`:this.renderCellIs(e,t);break;case`top10`:this.renderTop10(e,t);break;case`aboveAverage`:this.renderAboveAverage(e,t);break;case`dataBar`:this.renderDataBar(e,t);break;case`colorScale`:this.renderColorScale(e,t);break;case`iconSet`:this.renderIconSet(e,t);break;case`containsText`:this.renderText(e,t);break;case`timePeriod`:this.renderTimePeriod(e,t);break}}renderExpression(e,t){e.openNode(this.tag,{type:`expression`,dxfId:t.dxfId,priority:t.priority}),this.formulaXform.render(e,t.formulae[0]),e.closeNode()}renderCellIs(e,t){e.openNode(this.tag,{type:`cellIs`,dxfId:t.dxfId,priority:t.priority,operator:t.operator}),t.formulae.forEach(t=>{this.formulaXform.render(e,t)}),e.closeNode()}renderTop10(e,t){e.leafNode(this.tag,{type:`top10`,dxfId:t.dxfId,priority:t.priority,percent:L.toBoolAttribute(t.percent,!1),bottom:L.toBoolAttribute(t.bottom,!1),rank:L.toIntValue(t.rank,10)})}renderAboveAverage(e,t){e.leafNode(this.tag,{type:`aboveAverage`,dxfId:t.dxfId,priority:t.priority,aboveAverage:L.toBoolAttribute(t.aboveAverage,!0)})}renderDataBar(e,t){e.openNode(this.tag,{type:`dataBar`,priority:t.priority}),this.databarXform.render(e,t),this.extLstRefXform.render(e,t),e.closeNode()}renderColorScale(e,t){e.openNode(this.tag,{type:`colorScale`,priority:t.priority}),this.colorScaleXform.render(e,t),e.closeNode()}renderIconSet(t,n){e.isPrimitive(n)&&(t.openNode(this.tag,{type:`iconSet`,priority:n.priority}),this.iconSetXform.render(t,n),t.closeNode())}renderText(e,t){e.openNode(this.tag,{type:t.operator,dxfId:t.dxfId,priority:t.priority,operator:L.toStringAttribute(t.operator,`containsText`)});let n=Yi(t);n&&this.formulaXform.render(e,n),e.closeNode()}renderTimePeriod(e,t){e.openNode(this.tag,{type:`timePeriod`,dxfId:t.dxfId,priority:t.priority,timePeriod:t.timePeriod});let n=Xi(t);n&&this.formulaXform.render(e,n),e.closeNode()}createNewModel({attributes:e}){return{...Zi(e),dxfId:L.toIntValue(e.dxfId),priority:L.toIntValue(e.priority),timePeriod:e.timePeriod,percent:L.toBoolValue(e.percent),bottom:L.toBoolValue(e.bottom),rank:L.toIntValue(e.rank),aboveAverage:L.toBoolValue(e.aboveAverage)}}onParserClose(e,t){switch(e){case`dataBar`:case`extLst`:case`colorScale`:case`iconSet`:Object.assign(this.model,t.model);break;case`formula`:this.model.formulae=this.model.formulae??[],this.model.formulae.push(t.model);break}}},$i=class extends J{constructor(){super(),this.map={cfRule:new Qi}}get tag(){return`conditionalFormatting`}render(e,t){t.rules.some(Qi.isPrimitive)&&(e.openNode(this.tag,{sqref:t.ref}),t.rules.forEach(n=>{Qi.isPrimitive(n)&&(n.ref=t.ref,this.map.cfRule.render(e,n))}),e.closeNode())}createNewModel({attributes:e}){return{ref:e.sqref,rules:[]}}onParserClose(e,t){this.model.rules.push(t.model)}},ea=class extends L{constructor(){super(),this.cfXform=new $i}get tag(){return`conditionalFormatting`}reset(){this.model=[]}prepare(e,t){let n=e.reduce((e,t)=>Math.max(e,...t.rules.map(e=>e.priority??0)),1);e.forEach(e=>{e.rules.forEach(e=>{e.priority||=n++,e.style&&(e.dxfId=t.styles.addDxfStyle(e.style)),e.type===`dataBar`&&((!e.cfvo||e.cfvo.length<2)&&(e.cfvo=[{type:`min`},{type:`max`}]),e.color||={argb:`FF638EC6`})})})}render(e,t){t.forEach(t=>{this.cfXform.render(e,t)})}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`conditionalFormatting`:return this.parser=this.cfXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?this.parser.parseClose(e)?!0:(this.model.push(this.parser.model),this.parser=void 0,!1):!1}reconcile(e,t){e.forEach(e=>{e.rules.forEach(e=>{e.dxfId!==void 0&&(e.style=t.styles.getDxfStyle(e.dxfId),delete e.dxfId)})})}},ta=class extends L{get tag(){return`xm:f`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},na=class extends J{constructor(){super(),this.map={"xm:f":this.fExtXform=new ta}}get tag(){return`x14:cfvo`}render(e,t){e.openNode(this.tag,{type:t.type}),t.value!==void 0&&this.fExtXform.render(e,t.value),e.closeNode()}createNewModel(e){return{type:e.attributes.type}}onParserClose(e,t){switch(e){case`xm:f`:this.model.value=t.model?parseFloat(t.model):0;break}}},ra=class extends J{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new na,"x14:borderColor":this.borderColorXform=new z(`x14:borderColor`),"x14:negativeBorderColor":this.negativeBorderColorXform=new z(`x14:negativeBorderColor`),"x14:negativeFillColor":this.negativeFillColorXform=new z(`x14:negativeFillColor`),"x14:axisColor":this.axisColorXform=new z(`x14:axisColor`)}}static isExt(e){return!e.gradient}get tag(){return`x14:dataBar`}render(e,t){e.openNode(this.tag,{minLength:L.toIntAttribute(t.minLength,0,!0),maxLength:L.toIntAttribute(t.maxLength,100,!0),border:L.toBoolAttribute(t.border,!1),gradient:L.toBoolAttribute(t.gradient,!0),negativeBarColorSameAsPositive:L.toBoolAttribute(t.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:L.toBoolAttribute(t.negativeBarBorderColorSameAsPositive,!0),axisPosition:L.toAttribute(t.axisPosition,`auto`),direction:L.toAttribute(t.direction,`leftToRight`)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),this.borderColorXform.render(e,t.borderColor),this.negativeBorderColorXform.render(e,t.negativeBorderColor),this.negativeFillColorXform.render(e,t.negativeFillColor),this.axisColorXform.render(e,t.axisColor),e.closeNode()}createNewModel({attributes:e}){return{cfvo:[],minLength:L.toIntValue(e.minLength,0),maxLength:L.toIntValue(e.maxLength,100),border:L.toBoolValue(e.border,!1),gradient:L.toBoolValue(e.gradient,!0),negativeBarColorSameAsPositive:L.toBoolValue(e.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:L.toBoolValue(e.negativeBarBorderColorSameAsPositive,!0),axisPosition:L.toStringValue(e.axisPosition,`auto`),direction:L.toStringValue(e.direction,`leftToRight`)}}onParserClose(e,t){let[,n]=e.split(`:`);switch(n){case`cfvo`:this.model.cfvo.push(t.model);break;default:this.model[n]=t.model;break}}},ia=class extends L{get tag(){return`x14:cfIcon`}render(e,t){e.leafNode(this.tag,{iconSet:t.iconSet,iconId:t.iconId})}parseOpen({attributes:e}){this.model={iconSet:e.iconSet,iconId:L.toIntValue(e.iconId)}}parseClose(e){return e!==this.tag}},aa=class extends J{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new na,"x14:cfIcon":this.cfIconXform=new ia}}get tag(){return`x14:iconSet`}render(e,t){e.openNode(this.tag,{iconSet:L.toStringAttribute(t.iconSet),reverse:L.toBoolAttribute(t.reverse,!1),showValue:L.toBoolAttribute(t.showValue,!0),custom:L.toBoolAttribute(t.icons,!1)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),t.icons&&t.icons.forEach((t,n)=>{t.iconId=n,this.cfIconXform.render(e,t)}),e.closeNode()}createNewModel({attributes:e}){return{cfvo:[],iconSet:L.toStringValue(e.iconSet,`3TrafficLights`),reverse:L.toBoolValue(e.reverse,!1),showValue:L.toBoolValue(e.showValue,!0)}}onParserClose(e,t){let[,n]=e.split(`:`);switch(n){case`cfvo`:this.model.cfvo.push(t.model);break;case`cfIcon`:this.model.icons||(this.model.icons=[]),this.model.icons.push(t.model);break;default:this.model[n]=t.model;break}}};function Y(e){return e.toString(16).padStart(2,`0`)}function oa(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=e;return Y(t[0])+Y(t[1])+Y(t[2])+Y(t[3])+`-`+Y(t[4])+Y(t[5])+`-`+Y(t[6])+Y(t[7])+`-`+Y(t[8])+Y(t[9])+`-`+Y(t[10])+Y(t[11])+Y(t[12])+Y(t[13])+Y(t[14])+Y(t[15])}function sa(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);if(e?.getRandomValues)return e.getRandomValues(t),oa(t);for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return oa(t)}let ca={"3Triangles":!0,"3Stars":!0,"5Boxes":!0};var la=class e extends J{constructor(){super(),this.map={"x14:dataBar":this.databarXform=new ra,"x14:iconSet":this.iconSetXform=new aa}}get tag(){return`x14:cfRule`}static isExt(e){return e.type===`dataBar`?ra.isExt(e):!!(e.type===`iconSet`&&(e.custom||ca[e.iconSet]))}prepare(t){e.isExt(t)&&(t.x14Id=`{${sa()}}`.toUpperCase())}render(t,n){if(e.isExt(n))switch(n.type){case`dataBar`:this.renderDataBar(t,n);break;case`iconSet`:this.renderIconSet(t,n);break}}renderDataBar(e,t){e.openNode(this.tag,{type:`dataBar`,id:t.x14Id}),this.databarXform.render(e,t),e.closeNode()}renderIconSet(e,t){e.openNode(this.tag,{type:`iconSet`,priority:t.priority,id:t.x14Id??`{${sa()}}`}),this.iconSetXform.render(e,t),e.closeNode()}createNewModel({attributes:e}){return{type:e.type,x14Id:e.id,priority:L.toIntValue(e.priority)}}onParserClose(e,t){Object.assign(this.model,t.model)}},ua=class extends L{get tag(){return`xm:sqref`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},da=class extends J{constructor(){super(),this.map={"xm:sqref":this.sqRef=new ua,"x14:cfRule":this.cfRule=new la}}get tag(){return`x14:conditionalFormatting`}prepare(e){e.rules.forEach(e=>{this.cfRule.prepare(e)})}render(e,t){t.rules.some(la.isExt)&&(e.openNode(this.tag,{"xmlns:xm":`http://schemas.microsoft.com/office/excel/2006/main`}),t.rules.filter(la.isExt).forEach(t=>this.cfRule.render(e,t)),this.sqRef.render(e,t.ref),e.closeNode())}createNewModel(){return{rules:[]}}onParserClose(e,t){switch(e){case`xm:sqref`:this.model.ref=t.model;break;case`x14:cfRule`:this.model.rules.push(t.model);break}}},fa=class extends J{constructor(){super(),this.map={"x14:conditionalFormatting":this.cfXform=new da}}get tag(){return`x14:conditionalFormattings`}hasContent(e){return e.hasExtContent===void 0&&(e.hasExtContent=e.some(e=>e.rules.some(la.isExt))),e.hasExtContent}prepare(e){e.forEach(e=>{this.cfXform.prepare(e)})}render(e,t){this.hasContent(t)&&(e.openNode(this.tag),t.forEach(t=>this.cfXform.render(e,t)),e.closeNode())}createNewModel(){return[]}onParserClose(e,t){this.model.push(t.model)}},pa=class extends J{constructor(){super(),this.map={"x14:conditionalFormattings":this.conditionalFormattings=new fa}}get tag(){return`ext`}hasContent(e){return this.conditionalFormattings.hasContent(e.conditionalFormattings)}prepare(e){this.conditionalFormattings.prepare(e.conditionalFormattings)}render(e,t){e.openNode(`ext`,{uri:`{78C0D931-6437-407d-A8EE-F0AAD7539E65}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`}),this.conditionalFormattings.render(e,t.conditionalFormattings),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){this.model[e]=t.model}},ma=class extends J{constructor(){super(),this.map={ext:this.ext=new pa}}get tag(){return`extLst`}prepare(e,t){this.ext.prepare(e)}hasContent(e){return this.ext.hasContent(e)}render(e,t){this.hasContent(t)&&(e.openNode(`extLst`),this.ext.render(e,t),e.closeNode())}createNewModel(){return{}}onParserClose(e,t){this.model[e]=t.model}};let ha=(e,t)=>{Object.keys(t).forEach(n=>{let r=e[n],i=t[n];r===void 0&&i!==void 0&&(e[n]=i)})},ga=(e,t)=>{if(!t||!t.length)return e;if(!e||!e.length)return t;let n={},r={};return e.forEach(e=>{n[e.ref]=e,e.rules.forEach(e=>{let{x14Id:t}=e;t&&(r[t]=e)})}),t.forEach(t=>{t.rules.forEach(i=>{let a=r[i.x14Id];a?ha(a,i):n[t.ref]?n[t.ref].rules.push(i):e.push({ref:t.ref,rules:[i]})})}),e};var _a=class e extends L{static{this.WORKSHEET_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"xmlns:x14ac":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac`,"mc:Ignorable":`x14ac`}}constructor(e){super();let{maxRows:t,maxCols:n,ignoreNodes:r}=e||{};this.ignoreNodes=r??[],this.map={sheetPr:new vi,dimension:new ci,sheetViews:new R({tag:`sheetViews`,count:!1,childXform:new xi}),sheetFormatPr:new yi,cols:new R({tag:`cols`,count:!1,childXform:new si}),sheetData:new R({tag:`sheetData`,count:!1,empty:!0,childXform:new oi({maxItems:n}),maxItems:t}),autoFilter:new Mi,mergeCells:new R({tag:`mergeCells`,count:!0,childXform:new ui}),rowBreaks:new Li,colBreaks:new Ri,hyperlinks:new R({tag:`hyperlinks`,count:!1,childXform:new li}),pageMargins:new Ci,dataValidations:new mi,pageSetup:new ki,headerFooter:new zi,printOptions:new ji,picture:new Ni,drawing:new Pi,sheetProtection:new Si,tableParts:new R({tag:`tableParts`,count:!0,childXform:new Fi}),conditionalFormatting:new ea,extLst:new ma}}prepare(e,t){t.merges=new ni,e.hyperlinks=t.hyperlinks=[],e.comments=t.comments=[],e.formControls&&e.formControls.length>0&&(!e.views||e.views.length===0)&&(e.views=[{workbookViewId:0}]),t.formulae={},t.siFormulae=0,this.map.cols.prepare(e.cols,t),this.map.sheetData.prepare(e.rows,t),this.map.conditionalFormatting.prepare(e.conditionalFormattings,t),e.mergeCells=t.merges.mergeCells;let r=e.rels=[];function i(e){return`rId${e.length+1}`}if(e.hyperlinks.forEach(e=>{let t=i(r);e.rId=t,r.push({Id:t,Type:G.Hyperlink,Target:e.target,TargetMode:`External`})}),e.comments.length>0){let a={Id:i(r),Type:G.Comments,Target:Or(e.id)};r.push(a);let o={Id:i(r),Type:G.VmlDrawing,Target:kr(e.id)};r.push(o),e.comments.forEach(e=>{e.refAddress=n.decodeAddress(e.ref)}),t.commentRefs.push({commentName:`comments${e.id}`,vmlDrawing:`vmlDrawing${e.id}`})}if(e.drawing&&e.drawing.anchors){let n=e.drawing;n.rId=i(r),n.name||=`drawing${++t.drawingsCount}`;let a=(n.rels??[]).some(e=>e.Target&&e.Target.includes(`/charts/`));n.anchors=[],a||(n.rels=[]),t.drawings.push(n),r.push({Id:n.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:Ar(n.name)})}let a=[],o;if(e.media.forEach(n=>{if(n.type===`background`){let a=i(r);o=t.media[n.imageId],r.push({Id:a,Type:G.Image,Target:Lr(`${o.name}.${o.extension}`)}),e.background={rId:a},e.image=t.media[n.imageId]}else if(n.type===`image`){let{drawing:s}=e;o=t.media[n.imageId],s||(s=e.drawing={rId:i(r),name:`drawing${++t.drawingsCount}`,anchors:[],rels:[]},t.drawings.push(s),r.push({Id:s.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:Ar(s.name)}));let c=this.preImageId===n.imageId?a[n.imageId]:a[s.rels.length];c||(c=i(s.rels),a[s.rels.length]=c,s.rels.push({Id:c,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`,Target:Lr(`${o.name}.${o.extension}`)}));let l={picture:{rId:c},range:n.range};if(n.hyperlinks&&n.hyperlinks.hyperlink){let e=i(s.rels);a[s.rels.length]=e,l.picture.hyperlinks={tooltip:n.hyperlinks.tooltip,rId:e},s.rels.push({Id:e,Type:G.Hyperlink,Target:n.hyperlinks.hyperlink,TargetMode:`External`})}this.preImageId=n.imageId,s.anchors.push(l)}}),e.tables.forEach(e=>{let n=i(r);e.rId=n,r.push({Id:n,Type:G.Table,Target:Fr(e.target)}),e.columns.forEach(e=>{let{style:n}=e;n&&(e.dxfId=t.styles.addDxfStyle(n))})}),(e.pivotTables??[]).forEach(e=>{r.push({Id:i(r),Type:G.PivotTable,Target:Nr(e.tableNumber)})}),e.formControls&&e.formControls.length>0){let{drawing:n}=e;n||(n=e.drawing={rId:i(r),name:`drawing${++t.drawingsCount}`,anchors:[],rels:[]},t.drawings.push(n),r.push({Id:n.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:Ar(n.name)})),e.comments.length===0&&r.push({Id:i(r),Type:G.VmlDrawing,Target:kr(e.id)});let a=e=>({nativeCol:e.col,nativeColOff:e.colOff,nativeRow:e.row,nativeRowOff:e.rowOff});for(let o of e.formControls){let e=t.formControlRefs.length+1;o.ctrlPropId=e;let s=i(r);o.ctrlPropRelId=s,r.push({Id:s,Type:G.CtrlProp,Target:zr(e)}),t.formControlRefs.push(e);let c=`Check Box ${Math.max(1,o.shapeId-1024)}`;n.anchors.push({range:{editAs:`absolute`,tl:a(o.tl),br:a(o.br)},alternateContent:{requires:`a14`},shape:{cNvPrId:o.shapeId,name:o.name||c,hidden:!0,spid:`_x0000_s${o.shapeId}`,text:o.text}})}}this.map.extLst.prepare(e,t)}render(t,n){t.openXml(F.StdDocAttributes);let r={...e.WORKSHEET_ATTRIBUTES};n.formControls&&n.formControls.length>0&&(r[`xmlns:x14`]=`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`,r[`xmlns:xdr`]=`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,r[`mc:Ignorable`]=`${r[`mc:Ignorable`]} x14`),t.openNode(`worksheet`,r);let i=n.properties?{defaultRowHeight:n.properties.defaultRowHeight,dyDescent:n.properties.dyDescent,outlineLevelCol:n.properties.outlineLevelCol,outlineLevelRow:n.properties.outlineLevelRow,customHeight:n.properties.customHeight}:void 0;n.properties&&n.properties.defaultColWidth&&(i.defaultColWidth=n.properties.defaultColWidth);let a={outlineProperties:n.properties&&n.properties.outlineProperties,tabColor:n.properties&&n.properties.tabColor,pageSetup:n.pageSetup&&n.pageSetup.fitToPage?{fitToPage:n.pageSetup.fitToPage}:void 0},o=n.pageSetup&&n.pageSetup.margins,s={showRowColHeaders:n.pageSetup&&n.pageSetup.showRowColHeaders,showGridLines:n.pageSetup&&n.pageSetup.showGridLines,horizontalCentered:n.pageSetup&&n.pageSetup.horizontalCentered,verticalCentered:n.pageSetup&&n.pageSetup.verticalCentered},c=n.sheetProtection;if(this.map.sheetPr.render(t,a),this.map.dimension.render(t,n.dimensions),this.map.sheetViews.render(t,n.views),this.map.sheetFormatPr.render(t,i),this.map.cols.render(t,n.cols),this.map.sheetData.render(t,n.rows),this.map.sheetProtection.render(t,c),this.map.autoFilter.render(t,n.autoFilter),this.map.mergeCells.render(t,n.mergeCells),this.map.conditionalFormatting.render(t,n.conditionalFormattings),this.map.dataValidations.render(t,n.dataValidations),this.map.hyperlinks.render(t,n.hyperlinks),this.map.printOptions.render(t,s),this.map.pageMargins.render(t,o),this.map.pageSetup.render(t,n.pageSetup),this.map.headerFooter.render(t,n.headerFooter),this.map.rowBreaks.render(t,n.rowBreaks),this.map.colBreaks.render(t,n.colBreaks),this.map.drawing.render(t,n.drawing),this.map.picture.render(t,n.background),n.rels&&n.rels.forEach(e=>{e.Type===G.VmlDrawing&&t.leafNode(`legacyDrawing`,{"r:id":e.Id})}),n.formControls&&n.formControls.length>0){t.openNode(`mc:AlternateContent`),t.openNode(`mc:Choice`,{Requires:`x14`}),t.openNode(`controls`);for(let e of n.formControls){if(!e.ctrlPropRelId)continue;let n=`Check Box ${Math.max(1,e.shapeId-1024)}`;t.openNode(`mc:AlternateContent`),t.openNode(`mc:Choice`,{Requires:`x14`}),t.openNode(`control`,{shapeId:e.shapeId,"r:id":e.ctrlPropRelId,name:e.name||n}),t.openNode(`controlPr`,{locked:0,defaultSize:0,print:e.print?1:0,autoFill:0,autoLine:0,autoPict:0}),t.openNode(`anchor`),t.openNode(`from`),t.leafNode(`xdr:col`,void 0,e.tl.col),t.leafNode(`xdr:colOff`,void 0,e.tl.colOff),t.leafNode(`xdr:row`,void 0,e.tl.row),t.leafNode(`xdr:rowOff`,void 0,e.tl.rowOff),t.closeNode(),t.openNode(`to`),t.leafNode(`xdr:col`,void 0,e.br.col),t.leafNode(`xdr:colOff`,void 0,e.br.colOff),t.leafNode(`xdr:row`,void 0,e.br.row),t.leafNode(`xdr:rowOff`,void 0,e.br.rowOff),t.closeNode(),t.closeNode(),t.closeNode(),t.closeNode(),t.closeNode(),t.leafNode(`mc:Fallback`),t.closeNode()}t.closeNode(),t.closeNode(),t.leafNode(`mc:Fallback`),t.closeNode()}this.map.tableParts.render(t,n.tables),this.map.extLst.render(t,n),t.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===`worksheet`?(Object.values(this.map).forEach(e=>{e.reset()}),!0):(this.map[e.name]&&!this.ignoreNodes.includes(e.name)&&(this.parser=this.map[e.name],this.parser.parseOpen(e)),!0)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`worksheet`:{let e=this.map.sheetFormatPr.model||{};this.map.sheetPr.model&&this.map.sheetPr.model.tabColor&&(e.tabColor=this.map.sheetPr.model.tabColor),this.map.sheetPr.model&&this.map.sheetPr.model.outlineProperties&&(e.outlineProperties=this.map.sheetPr.model.outlineProperties);let t={fitToPage:this.map.sheetPr.model&&this.map.sheetPr.model.pageSetup&&this.map.sheetPr.model.pageSetup.fitToPage||!1,margins:this.map.pageMargins.model},n=Object.assign(t,this.map.pageSetup.model,this.map.printOptions.model),r=ga(this.map.conditionalFormatting.model,this.map.extLst.model&&this.map.extLst.model[`x14:conditionalFormattings`]);return this.model={dimensions:this.map.dimension.model,cols:this.map.cols.model,rows:this.map.sheetData.model,mergeCells:this.map.mergeCells.model,hyperlinks:this.map.hyperlinks.model,dataValidations:this.map.dataValidations.model,properties:e,views:this.map.sheetViews.model,pageSetup:n,headerFooter:this.map.headerFooter.model,background:this.map.picture.model,drawing:this.map.drawing.model,tables:this.map.tableParts.model,conditionalFormattings:r,rowBreaks:this.map.rowBreaks.model??[],colBreaks:this.map.colBreaks.model??[]},this.map.autoFilter.model&&(this.model.autoFilter=this.map.autoFilter.model),this.map.sheetProtection.model&&(this.model.sheetProtection=this.map.sheetProtection.model),!1}default:return!0}}reconcile(e,t){let n=(e.relationships??[]).reduce((n,r)=>{if(n[r.Id]=r,r.Type===G.Comments&&(e.comments=t.comments[r.Target].comments),r.Type===G.VmlDrawing&&e.comments&&e.comments.length){let n=t.vmlDrawings[r.Target].comments;e.comments.forEach((e,t)=>{e.note=Object.assign({},e.note,n[t])})}return n},{});if(t.commentsMap=(e.comments??[]).reduce((e,t)=>(t.ref&&(e[t.ref]=t),e),{}),t.hyperlinkMap=(e.hyperlinks??[]).reduce((e,t)=>(t.rId&&(e[t.address]=n[t.rId].Target),e),{}),t.formulae={},e.rows=e.rows?.filter(Boolean)??[],e.rows.forEach(e=>{e.cells=e.cells?.filter(Boolean)??[]}),this.map.cols.reconcile(e.cols,t),this.map.sheetData.reconcile(e.rows,t),this.map.conditionalFormatting.reconcile(e.conditionalFormattings,t),e.media=[],e.drawing){let r=n[e.drawing.rId].Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);if(r){let n=r[1],i=t.drawings[n];i&&(e.drawing={...i,name:n,rels:t.drawingRels?.[n]??i.rels??[]},i.anchors.forEach(t=>{if(t.medium){let n={type:`image`,imageId:t.medium.index,range:t.range,hyperlinks:t.picture.hyperlinks};e.media.push(n)}}))}}let r=e.background&&n[e.background.rId];if(r){let n=r.Target.split(`/media/`)[1],i=t.mediaIndex&&t.mediaIndex[n];i!==void 0&&e.media.push({type:`background`,imageId:i})}e.tables=(e.tables??[]).map(e=>{let r=n[e.rId];return t.tables[r.Target]}),e.pivotTables=[],(e.relationships??[]).forEach(n=>{if(n.Type===G.PivotTable&&t.pivotTables){let r=t.pivotTables[n.Target];r&&e.pivotTables.push(r)}}),delete e.relationships,delete e.hyperlinks,delete e.comments}},va=class extends L{render(e){e.openXml({version:`1.0`,encoding:`UTF-8`,standalone:`yes`}),e.openNode(`FeaturePropertyBags`,{xmlns:`http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag`}),e.leafNode(`bag`,{type:`Checkbox`}),e.openNode(`bag`,{type:`XFControls`}),e.leafNode(`bagId`,{k:`CellControl`},`0`),e.closeNode(),e.openNode(`bag`,{type:`XFComplement`}),e.leafNode(`bagId`,{k:`XFControls`},`1`),e.closeNode(),e.openNode(`bag`,{type:`XFComplements`,extRef:`XFComplementsMapperExtRef`}),e.openNode(`a`,{k:`MappedFeaturePropertyBags`}),e.leafNode(`bagId`,{},`2`),e.closeNode(),e.closeNode(),e.closeNode()}parseOpen(){return!1}parseText(){}parseClose(){return!1}},ya=class extends L{parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={range:{editAs:e.attributes.editAs??`oneCell`}};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}reconcilePicture(e,t){if(e&&e.rId){let n=t.rels[e.rId].Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);if(n){let e=n[1],r=t.mediaIndex[e];return t.media[r]}}}},ba=class extends L{constructor(e){super(),this.tag=e.tag,this.map={"xdr:col":new $t({tag:`xdr:col`,zero:!0}),"xdr:colOff":new $t({tag:`xdr:colOff`,zero:!0}),"xdr:row":new $t({tag:`xdr:row`,zero:!0}),"xdr:rowOff":new $t({tag:`xdr:rowOff`,zero:!0})},this.model={nativeCol:0,nativeColOff:0,nativeRow:0,nativeRowOff:0}}render(e,t){e.openNode(this.tag),this.map[`xdr:col`].render(e,t.nativeCol),this.map[`xdr:colOff`].render(e,t.nativeColOff),this.map[`xdr:row`].render(e,t.nativeRow),this.map[`xdr:rowOff`].render(e,t.nativeRowOff),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model={nativeCol:this.map[`xdr:col`].model,nativeColOff:this.map[`xdr:colOff`].model,nativeRow:this.map[`xdr:row`].model,nativeRowOff:this.map[`xdr:rowOff`].model},!1;default:return!0}}},xa=class extends L{constructor(){super(),this.model={rId:``}}get tag(){return`a:blip`}render(e,t){e.leafNode(this.tag,{"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"r:embed":t.rId,cstate:`print`})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:embed`]},!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},Sa=class extends L{constructor(){super(),this.map={"a:blip":new xa}}get tag(){return`xdr:blipFill`}render(e,t){e.openNode(this.tag),this.map[`a:blip`].render(e,t),e.openNode(`a:stretch`),e.leafNode(`a:fillRect`),e.closeNode(),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`a:blip`].model,!1;default:return!0}}},Ca=class extends L{constructor(){super(),this.model={}}get tag(){return`a:hlinkClick`}render(e,t){t.hyperlinks&&t.hyperlinks.rId&&e.leafNode(this.tag,{"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"r:id":t.hyperlinks.rId,tooltip:t.hyperlinks.tooltip})}parseOpen(e){switch(e.name){case this.tag:return this.model={hyperlinks:{rId:e.attributes[`r:id`],tooltip:e.attributes.tooltip}},!0;default:return!0}}parseText(){}parseClose(){return!1}},wa=class extends L{get tag(){return`a:extLst`}render(e){e.openNode(this.tag),e.openNode(`a:ext`,{uri:`{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}`}),e.leafNode(`a16:creationId`,{"xmlns:a16":`http://schemas.microsoft.com/office/drawing/2014/main`,id:`{00000000-0008-0000-0000-000002000000}`}),e.closeNode(),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:return!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},Ta=class extends L{constructor(){super(),this.map={"a:hlinkClick":new Ca,"a:extLst":new wa}}get tag(){return`xdr:cNvPr`}render(e,t){e.openNode(this.tag,{id:t.index,name:`Picture ${t.index}`}),this.map[`a:hlinkClick`].render(e,t),this.map[`a:extLst`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`a:hlinkClick`].model,!1;default:return!0}}},Ea=class extends L{get tag(){return`xdr:cNvPicPr`}render(e){e.openNode(this.tag),e.leafNode(`a:picLocks`,{noChangeAspect:`1`}),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:return!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},Da=class extends L{constructor(){super(),this.map={"xdr:cNvPr":new Ta,"xdr:cNvPicPr":new Ea}}get tag(){return`xdr:nvPicPr`}render(e,t){e.openNode(this.tag),this.map[`xdr:cNvPr`].render(e,t),this.map[`xdr:cNvPicPr`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`xdr:cNvPr`].model,!1;default:return!0}}};let Oa={tag:`xdr:spPr`,c:[{tag:`a:xfrm`,c:[{tag:`a:off`,$:{x:`0`,y:`0`}},{tag:`a:ext`,$:{cx:`0`,cy:`0`}}]},{tag:`a:prstGeom`,$:{prst:`rect`},c:[{tag:`a:avLst`}]}]};var ka=class extends L{constructor(){super(),this.map={"xdr:nvPicPr":new Da,"xdr:blipFill":new Sa,"xdr:spPr":new Zt(Oa)}}get tag(){return`xdr:pic`}prepare(e,t){e.index=t.index+1}render(e,t){e.openNode(this.tag),this.map[`xdr:nvPicPr`].render(e,t),this.map[`xdr:blipFill`].render(e,t),this.map[`xdr:spPr`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.mergeModel(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:return!0}}},Aa=class extends L{get tag(){return`xdr:sp`}render(e,t){t&&(e.openNode(this.tag,{macro:``,textlink:``}),e.openNode(`xdr:nvSpPr`),e.openNode(`xdr:cNvPr`,{id:t.cNvPrId,name:t.name,hidden:t.hidden?`1`:void 0}),e.openNode(`a:extLst`),e.openNode(`a:ext`,{uri:`{63B3BB69-23CF-44E3-9099-C40C66FF867C}`}),e.leafNode(`a14:compatExt`,{spid:t.spid,"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`},void 0),e.closeNode(),e.closeNode(),e.closeNode(),e.leafNode(`xdr:cNvSpPr`),e.closeNode(),e.openNode(`xdr:spPr`,{bwMode:`auto`}),e.openNode(`a:xfrm`),e.leafNode(`a:off`,{x:0,y:0}),e.leafNode(`a:ext`,{cx:0,cy:0}),e.closeNode(),e.openNode(`a:prstGeom`,{prst:`rect`}),e.leafNode(`a:avLst`),e.closeNode(),e.leafNode(`a:noFill`),e.openNode(`a:ln`),e.leafNode(`a:noFill`),e.closeNode(),e.openNode(`a:extLst`),e.openNode(`a:ext`,{uri:`{909E8E84-426E-40DD-AFC4-6F175D3DCCD1}`}),e.openNode(`a14:hiddenFill`,{"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`F0F0F0`}),e.closeNode(),e.closeNode(),e.closeNode(),e.openNode(`a:ext`,{uri:`{91240B29-F687-4F45-9708-019B960494DF}`}),e.openNode(`a14:hiddenLine`,{w:9525,"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`000000`}),e.closeNode(),e.leafNode(`a:miter`,{lim:8e5}),e.leafNode(`a:headEnd`),e.leafNode(`a:tailEnd`),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode(),e.openNode(`xdr:txBody`),e.leafNode(`a:bodyPr`,{vertOverflow:`clip`,wrap:`square`,lIns:18288,tIns:18288,rIns:0,bIns:18288,anchor:`ctr`,upright:1}),e.leafNode(`a:lstStyle`),e.openNode(`a:p`),e.openNode(`a:pPr`,{algn:`l`,rtl:0}),e.leafNode(`a:defRPr`,{sz:1e3}),e.closeNode(),e.openNode(`a:r`),e.openNode(`a:rPr`,{lang:`en-US`,sz:800,b:0,i:0,u:`none`,strike:`noStrike`,baseline:0}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`000000`}),e.closeNode(),e.leafNode(`a:latin`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.leafNode(`a:ea`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.leafNode(`a:cs`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.closeNode(),e.openNode(`a:t`),e.writeText(t.text??``),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode())}},ja=class extends ya{constructor(){super(),this.map={"xdr:from":new ba({tag:`xdr:from`}),"xdr:to":new ba({tag:`xdr:to`}),"xdr:pic":new ka,"xdr:sp":new Aa,"xdr:clientData":new Zt({tag:`xdr:clientData`})}}get tag(){return`xdr:twoCellAnchor`}prepare(e,t){e.picture&&this.map[`xdr:pic`].prepare(e.picture,t)}render(e,t){let n=!!t.alternateContent;n&&(e.openNode(`mc:AlternateContent`,{"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`}),e.openNode(`mc:Choice`,{Requires:t.alternateContent?.requires,...t.alternateContent?.requires===`a14`?{"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}:{}})),e.openNode(this.tag,{editAs:t.range.editAs??`oneCell`}),this.map[`xdr:from`].render(e,t.range.tl),this.map[`xdr:to`].render(e,t.range.br),t.picture?this.map[`xdr:pic`].render(e,t.picture):t.shape&&this.map[`xdr:sp`].render(e,t.shape),this.map[`xdr:clientData`].render(e,{}),e.closeNode(),n&&(e.closeNode(),e.leafNode(`mc:Fallback`),e.closeNode())}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.range.tl=this.map[`xdr:from`].model,this.model.range.br=this.map[`xdr:to`].model,this.model.picture=this.map[`xdr:pic`].model,!1;default:return!0}}reconcile(e,t){e.medium=this.reconcilePicture(e.picture,t)}};let Ma=9525;var Na=class extends L{constructor(e){super(),this.tag=e.tag,this.map={},this.model={width:0,height:0}}render(e,t){e.openNode(this.tag);let n=Math.floor(t.width*Ma),r=Math.floor(t.height*Ma);e.addAttribute(`cx`,n),e.addAttribute(`cy`,r),e.closeNode()}parseOpen(e){return e.name===this.tag?(this.model={width:parseInt(e.attributes.cx??`0`,10)/Ma,height:parseInt(e.attributes.cy??`0`,10)/Ma},!0):!1}parseText(e){}parseClose(e){return!1}},Pa=class extends ya{constructor(){super(),this.map={"xdr:from":new ba({tag:`xdr:from`}),"xdr:ext":new Na({tag:`xdr:ext`}),"xdr:pic":new ka,"xdr:clientData":new Zt({tag:`xdr:clientData`})}}get tag(){return`xdr:oneCellAnchor`}prepare(e,t){this.map[`xdr:pic`].prepare(e.picture,t)}render(e,t){e.openNode(this.tag,{editAs:t.range.editAs??`oneCell`}),this.map[`xdr:from`].render(e,t.range.tl),this.map[`xdr:ext`].render(e,t.range.ext),this.map[`xdr:pic`].render(e,t.picture),this.map[`xdr:clientData`].render(e,{}),e.closeNode()}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.range.tl=this.map[`xdr:from`].model,this.model.range.ext=this.map[`xdr:ext`].model,this.model.picture=this.map[`xdr:pic`].model,!1;default:return!0}}reconcile(e,t){e.medium=this.reconcilePicture(e.picture,t)}};function Fa(e){return(typeof e.range==`string`?n.decode(e.range):e.range).br?`xdr:twoCellAnchor`:`xdr:oneCellAnchor`}var Ia=class e extends L{constructor(){super(),this.map={"xdr:twoCellAnchor":new ja,"xdr:oneCellAnchor":new Pa},this.model={anchors:[]}}prepare(e){e.anchors.forEach((e,t)=>{e.anchorType=Fa(e),this.map[e.anchorType].prepare(e,{index:t})})}get tag(){return`xdr:wsDr`}render(t,n){let r=n||this.model;t.openXml(F.StdDocAttributes),t.openNode(this.tag,e.DRAWING_ATTRIBUTES),r.anchors.forEach(e=>{this.map[e.anchorType].render(t,e)}),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={anchors:[]};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.anchors.push(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:return!0}}reconcile(e,t){e.anchors.forEach(e=>{e.br?this.map[`xdr:twoCellAnchor`].reconcile(e,t):this.map[`xdr:oneCellAnchor`].reconcile(e,t)})}static{this.DRAWING_ATTRIBUTES={"xmlns:xdr":`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,"xmlns:a":`http://schemas.openxmlformats.org/drawingml/2006/main`}}},La=class extends L{constructor(){super(),this.model={val:``}}get tag(){return`customFilter`}render(e,t){e.leafNode(this.tag,{val:t.val,operator:t.operator})}parseOpen(e){return e.name===this.tag?(this.model={val:e.attributes.val,operator:e.attributes.operator},!0):!1}parseText(){}parseClose(){return!1}},Ra=class extends L{constructor(){super(),this.model={val:``}}get tag(){return`filter`}render(e,t){e.leafNode(this.tag,{val:t.val})}parseOpen(e){return e.name===this.tag?(this.model={val:e.attributes.val},!0):!1}parseText(){}parseClose(){return!1}},za=class extends L{constructor(){super(),this.map={customFilters:new R({tag:`customFilters`,count:!1,empty:!0,childXform:new La}),filters:new R({tag:`filters`,count:!1,empty:!0,childXform:new Ra})},this.model={filterButton:!1}}get tag(){return`filterColumn`}prepare(e,t){e.colId=t.index.toString()}render(e,t){if(t.customFilters){e.openNode(this.tag,{colId:t.colId,hiddenButton:t.filterButton?`0`:`1`}),this.map.customFilters.render(e,t.customFilters),e.closeNode();return}e.leafNode(this.tag,{colId:t.colId,hiddenButton:t.filterButton?`0`:`1`})}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;let{attributes:t}=e;switch(e.name){case this.tag:return this.model={filterButton:t.hiddenButton===`0`},!0;case`dynamicFilter`:return!0;default:if(this.parser=this.map[e.name],this.parser)return this.parseOpen(e),!0;throw Error(`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.customFilters=this.map.customFilters.model,!1;default:return!0}}},Ba=class extends L{constructor(){super(),this.map={filterColumn:new za},this.model={autoFilterRef:``,columns:[]}}get tag(){return`autoFilter`}prepare(e){e.columns.forEach((e,t)=>{this.map.filterColumn.prepare(e,{index:t})})}render(e,t){e.openNode(this.tag,{ref:t.autoFilterRef}),t.columns.forEach(t=>{this.map.filterColumn.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:return this.model={autoFilterRef:e.attributes.ref,columns:[]},!0;default:if(this.parser=this.map[e.name],this.parser)return this.parseOpen(e),!0;throw Error(`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.columns.push(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:throw Error(`Unexpected xml node in parseClose: ${e}`)}}},Va=class extends L{constructor(){super(),this.model={name:``}}get tag(){return`tableColumn`}prepare(e,t){e.id=t.index+1}render(e,t){e.leafNode(this.tag,{id:t.id.toString(),name:t.name,totalsRowLabel:t.totalsRowLabel,totalsRowFunction:t.totalsRowFunction===`none`?void 0:t.totalsRowFunction,dxfId:t.dxfId})}parseOpen(e){if(e.name===this.tag){let{attributes:t}=e;return this.model={name:t.name,totalsRowLabel:t.totalsRowLabel,totalsRowFunction:t.totalsRowFunction,dxfId:t.dxfId},!0}return!1}parseText(){}parseClose(){return!1}},Ha=class extends L{constructor(){super(),this.model={theme:null,showFirstColumn:!1,showLastColumn:!1,showRowStripes:!1,showColumnStripes:!1}}get tag(){return`tableStyleInfo`}render(e,t){e.leafNode(this.tag,{name:t.theme?t.theme:void 0,showFirstColumn:t.showFirstColumn?`1`:`0`,showLastColumn:t.showLastColumn?`1`:`0`,showRowStripes:t.showRowStripes?`1`:`0`,showColumnStripes:t.showColumnStripes?`1`:`0`})}parseOpen(e){if(e.name===this.tag){let{attributes:t}=e;return this.model={theme:t.name?t.name:null,showFirstColumn:t.showFirstColumn===`1`,showLastColumn:t.showLastColumn===`1`,showRowStripes:t.showRowStripes===`1`,showColumnStripes:t.showColumnStripes===`1`},!0}return!1}parseText(){}parseClose(){return!1}},Ua=class e extends L{constructor(){super(),this.map={autoFilter:new Ba,tableColumns:new R({tag:`tableColumns`,count:!0,empty:!0,childXform:new Va}),tableStyleInfo:new Ha},this.model={id:0,name:``,tableRef:``,columns:[]}}prepare(e,t){this.map.autoFilter.prepare(e),this.map.tableColumns.prepare(e.columns,t)}get tag(){return`table`}render(t,n){t.openXml(F.StdDocAttributes),t.openNode(this.tag,{...e.TABLE_ATTRIBUTES,id:n.id,name:n.name,displayName:n.displayName||n.name,ref:n.tableRef,totalsRowCount:n.totalsRow?`1`:void 0,headerRowCount:n.headerRow?void 0:`0`}),this.map.autoFilter.render(t,n),this.map.tableColumns.render(t,n.columns),this.map.tableStyleInfo.render(t,n.style),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;let{name:t,attributes:n}=e;switch(t){case this.tag:this.reset(),this.model={name:n.name,displayName:n.displayName||n.name,tableRef:n.ref,totalsRow:n.totalsRowCount===`1`,headerRow:n.headerRowCount!==`0`};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.columns=this.map.tableColumns.model,this.map.autoFilter.model&&(this.model.autoFilterRef=this.map.autoFilter.model.autoFilterRef,this.map.autoFilter.model.columns.forEach((e,t)=>{this.model.columns[t].filterButton=e.filterButton})),this.model.style=this.map.tableStyleInfo.model,!1;default:return!0}}reconcile(e,t){e.tableRef&&!e.ref&&(e.ref=e.tableRef),e.rows||=[],e.columns.forEach(e=>{e.dxfId!==void 0&&(e.style=t.styles.getDxfStyle(e.dxfId))})}static{this.TABLE_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`}}};function Wa(e){return isNaN(e.getTime())?``:e.toISOString().replace(/\.\d{3}Z$/,``)}function Ga(e){let t=A(e.name),n=e.numFmtId??`0`,r=qa(e.extraAttrs),i=e.fieldGroupXml?`\n ${e.fieldGroupXml}`:``;if(e.sharedItems===null){if(e.isLoaded)return i?`<cacheField name="${t}" numFmtId="${n}"${r}>${i}\n </cacheField>`:`<cacheField name="${t}" numFmtId="${n}"${r} />`;let a;return a=e.minValue!==void 0&&e.maxValue!==void 0?` containsSemiMixedTypes="0" containsString="0" containsNumber="1"${e.containsInteger?` containsInteger="1"`:``} minValue="${e.minValue}" maxValue="${e.maxValue}"`:``,`<cacheField name="${t}" numFmtId="${n}"${r}>
11
11
  <sharedItems${a} />${i}
12
12
  </cacheField>`}if(e.isLoaded&&e.sharedItems.length===0)return`<cacheField name="${t}" numFmtId="${n}"${r}>
13
13
  <sharedItems${Ja(e)} />${i}