UNPKG

@sheetxl/io

Version:

IO - Import/Export Libraries for SheetXL.

12 lines 50.8 kB
"use strict";/**
 * @license @sheetxl/io - IO - Import/Export Libraries for SheetXL. - v0.4.0
 *
 * (C) 2025-present SheetXL Inc. & Michael T. Ford
 * License: The license can be found at https://www.sheetxl.com/license.
 */const g=require("@sheetxl/sdk"),oe=require("@sheetxl/utils"),re=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",ye=new RegExp(`^[${re}][${`-${re}.0-9·̀-ͯ‿-⁀`}]*$`,"u"),be=[32,10,13,9];function ue(i){return i>=65&&i<=90||i>=97&&i<=122||i===58||i===95||i===8204||i===8205||i>=192&&i<=214||i>=216&&i<=246||i>=248&&i<=767||i>=880&&i<=893||i>=895&&i<=8191||i>=8304&&i<=8591||i>=11264&&i<=12271||i>=12289&&i<=55295||i>=63744&&i<=64975||i>=65008&&i<=65533||i>=65536&&i<=983039}const ne="A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",xe=new RegExp(`^[${ne}][${`-${ne}.0-9·̀-ͯ‿-⁀`}]*$`,"u");function de(i){return i>=65&&i<=90||i===95||i>=97&&i<=122||i>=192&&i<=214||i>=216&&i<=246||i>=248&&i<=767||i>=880&&i<=893||i>=895&&i<=8191||i>=8204&&i<=8205||i>=8304&&i<=8591||i>=11264&&i<=12271||i>=12289&&i<=55295||i>=63744&&i<=64975||i>=65008&&i<=65533||i>=65536&&i<=983039}const st=function(i){return i===32||i===10||i===13||i===9},we=function(i){return i>=32&&i<=55295||i===10||i===13||i===9||i>=57344&&i<=65533||i>=65536&&i<=1114111},qt=ue,ae=function(i){return ue(i)||i>=48&&i<=57||i===45||i===46||i===183||i>=768&&i<=879||i>=8255&&i<=8256},pe=be,ve=ye,Se=function(i){return i>=1&&i<=55295||i>=57344&&i<=65533||i>=65536&&i<=1114111},Ce=de,ke=function(i){return de(i)||i===45||i===46||i>=48&&i<=57||i===183||i>=768&&i<=879||i>=8255&&i<=8256},Ae=xe,Jt="http://www.w3.org/XML/1998/namespace",Mt="http://www.w3.org/2000/xmlns/",Ee={__proto__:null,xml:Jt,xmlns:Mt},Pe={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},R=-1,Tt=-2,tt=13,Ot=33,ht=10,Et=60,$t=61,q=62,J=63,Ft=93,Zt=i=>i===34||i===39,ge=[34,39],De=[...ge,91,q],Ie=[...ge,Et,Ft],Oe=[$t,J,...pe],Ve=[...pe,q,38,Et];function Yt(i,t,s){switch(t){case"xml":s!==Jt&&i.fail(`xml prefix must be bound to ${Jt}.`);break;case"xmlns":s!==Mt&&i.fail(`xmlns prefix must be bound to ${Mt}.`)}switch(s){case Mt:i.fail(t===""?`the default namespace may not be set to ${s}.`:`may not assign a prefix (even "xmlns") to the URI ${Mt}.`);break;case Jt:switch(t){case"xml":break;case"":i.fail(`the default namespace may not be set to ${s}.`);break;default:i.fail("may not assign the xml namespace to another prefix.")}}}const Ne=i=>Ae.test(i),Le=i=>ve.test(i),le={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"};class Re{constructor(t){this.i=0,this.prevI=0,this.opt=t??{},this.fragmentOpt=!!this.opt.fragment;const s=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,s){this.nameStartCheck=Ce,this.nameCheck=ke,this.isName=Ne,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns={__proto__:null,...Ee};const o=this.opt.additionalNamespaces;o!=null&&(function(n,a){for(const l of Object.keys(a))Yt(n,l,a[l])}(this,o),Object.assign(this.ns,o))}else this.nameStartCheck=qt,this.nameCheck=ae,this.isName=Le,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){this.openWakaBang="",this.text="",this.name="",this.piTarget="",this.entity="",this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk="",this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=0,this.attribList=[];const{fragmentOpt:t}=this;this.state=t?tt:0,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=t,this.xmlDeclPossible=!t,this.xmlDeclExpects=["version"],this.entityReturnState=void 0;let{defaultXMLVersion:s}=this.opt;if(s===void 0){if(this.opt.forceXMLVersion===!0)throw new Error("forceXMLVersion set but defaultXMLVersion is not set");s="1.0"}this.setXMLVersion(s),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(Pe),this.readyHandler?.()}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(t,s){this[le[t]]=s}off(t){this[le[t]]=void 0}makeError(t){let s=this.fileName??"";return this.trackPosition&&(s.length>0&&(s+=":"),s+=`${this.line}:${this.column}`),s.length>0&&(s+=": "),new Error(s+t)}fail(t){const s=this.makeError(t),o=this.errorHandler;if(o===void 0)throw s;return o(s),this}write(t){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");let s=!1;t===null?(s=!0,t=""):typeof t=="object"&&(t=t.toString()),this.carriedFromPrevious!==void 0&&(t=`${this.carriedFromPrevious}${t}`,this.carriedFromPrevious=void 0);let o=t.length;const n=t.charCodeAt(o-1);!s&&(n===13||n>=55296&&n<=56319)&&(this.carriedFromPrevious=t[o-1],o--,t=t.slice(0,o));const{stateTable:a}=this;for(this.chunk=t,this.i=0;this.i<o;)a[this.state].call(this);return this.chunkPosition+=o,s?this.end():this}close(){return this.write(null)}getCode10(){const t=this.chunk,s=this.i;if(this.prevI=s,this.i++,s>=t.length)return R;const o=t.charCodeAt(s);if(this.column++,o<55296){if(o>=32||o===9)return o;switch(o){case ht:return this.line++,this.column=0,this.positionAtNewLine=this.position,ht;case 13:return t.charCodeAt(s+1)===ht&&(this.i=s+2),this.line++,this.column=0,this.positionAtNewLine=this.position,Tt;default:return this.fail("disallowed character."),o}}if(o>56319)return o>=57344&&o<=65533||this.fail("disallowed character."),o;const n=65536+1024*(o-55296)+(t.charCodeAt(s+1)-56320);return this.i=s+2,n>1114111&&this.fail("disallowed character."),n}getCode11(){const{chunk:t,i:s}=this;if(this.prevI=s,this.i=s+1,s>=t.length)return R;const o=t.charCodeAt(s);if(this.column++,o<55296){if(o>31&&o<127||o>159&&o!==8232||o===9)return o;switch(o){case ht:return this.line++,this.column=0,this.positionAtNewLine=this.position,ht;case 13:{const a=t.charCodeAt(s+1);a!==ht&&a!==133||(this.i=s+2)}case 133:case 8232:return this.line++,this.column=0,this.positionAtNewLine=this.position,Tt;default:return this.fail("disallowed character."),o}}if(o>56319)return o>=57344&&o<=65533||this.fail("disallowed character."),o;const n=65536+1024*(o-55296)+(t.charCodeAt(s+1)-56320);return this.i=s+2,n>1114111&&this.fail("disallowed character."),n}getCodeNorm(){const t=this.getCode();return t===Tt?ht:t}unget(){this.i=this.prevI,this.column--}captureTo(t){let{i:s}=this;const{chunk:o}=this;for(;;){const n=this.getCode(),a=n===Tt,l=a?ht:n;if(l===R||t.includes(l))return this.text+=o.slice(s,this.prevI),l;a&&(this.text+=`${o.slice(s,this.prevI)}
`,s=this.i)}}captureToChar(t){let{i:s}=this;const{chunk:o}=this;for(;;){let n=this.getCode();switch(n){case Tt:this.text+=`${o.slice(s,this.prevI)}
`,s=this.i,n=ht;break;case R:return this.text+=o.slice(s),!1}if(n===t)return this.text+=o.slice(s,this.prevI),!0}}captureNameChars(){const{chunk:t,i:s}=this;for(;;){const o=this.getCode();if(o===R)return this.name+=t.slice(s),R;if(!ae(o))return this.name+=t.slice(s,this.prevI),o===Tt?ht:o}}skipSpaces(){for(;;){const t=this.getCodeNorm();if(t===R||!st(t))return t}}setXMLVersion(t){this.currentXMLVersion=t,t==="1.0"?(this.isChar=we,this.getCode=this.getCode10):(this.isChar=Se,this.getCode=this.getCode11)}sBegin(){this.chunk.charCodeAt(0)===65279&&(this.i++,this.column++),this.state=1}sBeginWhitespace(){const t=this.i,s=this.skipSpaces();switch(this.prevI!==t&&(this.xmlDeclPossible=!1),s){case Et:if(this.state=15,this.text.length!==0)throw new Error("no-empty text at start");break;case R:break;default:this.unget(),this.state=tt,this.xmlDeclPossible=!1}}sDoctype(){const t=this.captureTo(De);switch(t){case q:this.doctypeHandler?.(this.text),this.text="",this.state=tt,this.doctype=!0;break;case R:break;default:this.text+=String.fromCodePoint(t),t===91?this.state=4:Zt(t)&&(this.state=3,this.q=t)}}sDoctypeQuote(){const t=this.q;this.captureToChar(t)&&(this.text+=String.fromCodePoint(t),this.q=null,this.state=2)}sDTD(){const t=this.captureTo(Ie);t!==R&&(this.text+=String.fromCodePoint(t),t===Ft?this.state=2:t===Et?this.state=6:Zt(t)&&(this.state=5,this.q=t))}sDTDQuoted(){const t=this.q;this.captureToChar(t)&&(this.text+=String.fromCodePoint(t),this.state=4,this.q=null)}sDTDOpenWaka(){const t=this.getCodeNorm();switch(this.text+=String.fromCodePoint(t),t){case 33:this.state=7,this.openWakaBang="";break;case J:this.state=11;break;default:this.state=4}}sDTDOpenWakaBang(){const t=String.fromCodePoint(this.getCodeNorm()),s=this.openWakaBang+=t;this.text+=t,s!=="-"&&(this.state=s==="--"?8:4,this.openWakaBang="")}sDTDComment(){this.captureToChar(45)&&(this.text+="-",this.state=9)}sDTDCommentEnding(){const t=this.getCodeNorm();this.text+=String.fromCodePoint(t),this.state=t===45?10:8}sDTDCommentEnded(){const t=this.getCodeNorm();this.text+=String.fromCodePoint(t),t===q?this.state=4:(this.fail("malformed comment."),this.state=8)}sDTDPI(){this.captureToChar(J)&&(this.text+="?",this.state=12)}sDTDPIEnding(){const t=this.getCodeNorm();this.text+=String.fromCodePoint(t),t===q&&(this.state=4)}sText(){this.tags.length!==0?this.handleTextInRoot():this.handleTextOutsideRoot()}sEntity(){let{i:t}=this;const{chunk:s}=this;t:for(;;)switch(this.getCode()){case Tt:this.entity+=`${s.slice(t,this.prevI)}
`,t=this.i;break;case 59:{const{entityReturnState:o}=this,n=this.entity+s.slice(t,this.prevI);let a;this.state=o,n===""?(this.fail("empty entity name."),a="&;"):(a=this.parseEntity(n),this.entity=""),o===tt&&this.textHandler===void 0||(this.text+=a);break t}case R:this.entity+=s.slice(t);break t}}sOpenWaka(){const t=this.getCode();if(qt(t))this.state=34,this.unget(),this.xmlDeclPossible=!1;else switch(t){case 47:this.state=43,this.xmlDeclPossible=!1;break;case 33:this.state=16,this.openWakaBang="",this.xmlDeclPossible=!1;break;case J:this.state=23;break;default:this.fail("disallowed character in tag name"),this.state=tt,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":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),this.state=20,this.openWakaBang="";break;case"--":this.state=17,this.openWakaBang="";break;case"DOCTYPE":this.state=2,(this.doctype||this.sawRoot)&&this.fail("inappropriately located doctype declaration."),this.openWakaBang="";break;default:this.openWakaBang.length>=7&&this.fail("incorrect syntax.")}}sComment(){this.captureToChar(45)&&(this.state=18)}sCommentEnding(){const t=this.getCodeNorm();t===45?(this.state=19,this.commentHandler?.(this.text),this.text=""):(this.text+=`-${String.fromCodePoint(t)}`,this.state=17)}sCommentEnded(){const t=this.getCodeNorm();t!==q?(this.fail("malformed comment."),this.text+=`--${String.fromCodePoint(t)}`,this.state=17):this.state=tt}sCData(){this.captureToChar(Ft)&&(this.state=21)}sCDataEnding(){const t=this.getCodeNorm();t===Ft?this.state=22:(this.text+=`]${String.fromCodePoint(t)}`,this.state=20)}sCDataEnding2(){const t=this.getCodeNorm();switch(t){case q:this.cdataHandler?.(this.text),this.text="",this.state=tt;break;case Ft:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(t)}`,this.state=20}}sPIFirstChar(){const t=this.getCodeNorm();this.nameStartCheck(t)?(this.piTarget+=String.fromCodePoint(t),this.state=24):t===J||st(t)?(this.fail("processing instruction without a target."),this.state=t===J?26:25):(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(t),this.state=24)}sPIRest(){const{chunk:t,i:s}=this;for(;;){const o=this.getCodeNorm();if(o===R)return void(this.piTarget+=t.slice(s));if(!this.nameCheck(o)){this.piTarget+=t.slice(s,this.prevI);const n=o===J;n||st(o)?this.piTarget==="xml"?(this.xmlDeclPossible||this.fail("an XML declaration must be at the start of the document."),this.state=n?Ot:27):this.state=n?26:25:(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(o));break}}}sPIBody(){if(this.text.length===0){const t=this.getCodeNorm();t===J?this.state=26:st(t)||(this.text=String.fromCodePoint(t))}else this.captureToChar(J)&&(this.state=26)}sPIEnding(){const t=this.getCodeNorm();if(t===q){const{piTarget:s}=this;s.toLowerCase()==="xml"&&this.fail("the XML declaration must appear at the start of the document."),this.piHandler?.({target:s,body:this.text}),this.piTarget=this.text="",this.state=tt}else t===J?this.text+="?":(this.text+=`?${String.fromCodePoint(t)}`,this.state=25);this.xmlDeclPossible=!1}sXMLDeclNameStart(){const t=this.skipSpaces();t!==J?t!==R&&(this.state=28,this.name=String.fromCodePoint(t)):this.state=Ot}sXMLDeclName(){const t=this.captureTo(Oe);if(t===J)return this.state=Ot,this.name+=this.text,this.text="",void this.fail("XML declaration is incomplete.");if(st(t)||t===$t){if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`)}this.state=t===$t?30:29}}sXMLDeclEq(){const t=this.getCodeNorm();if(t===J)return this.state=Ot,void this.fail("XML declaration is incomplete.");st(t)||(t!==$t&&this.fail("value required."),this.state=30)}sXMLDeclValueStart(){const t=this.getCodeNorm();if(t===J)return this.state=Ot,void this.fail("XML declaration is incomplete.");st(t)||(Zt(t)?this.q=t:(this.fail("value must be quoted."),this.q=32),this.state=31)}sXMLDeclValue(){const t=this.captureTo([this.q,J]);if(t===J)return this.state=Ot,this.text="",void this.fail("XML declaration is incomplete.");if(t===R)return;const s=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];const o=s;this.xmlDecl.version=o,/^1\.[0-9]+$/.test(o)?this.opt.forceXMLVersion||this.setXMLVersion(o):this.fail("version number must match /^1\\.[0-9]+$/.");break}case"encoding":/^[A-Za-z][A-Za-z0-9._-]*$/.test(s)||this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."),this.xmlDeclExpects=["standalone"],this.xmlDecl.encoding=s;break;case"standalone":s!=="yes"&&s!=="no"&&this.fail('standalone value must match "yes" or "no".'),this.xmlDeclExpects=[],this.xmlDecl.standalone=s}this.name="",this.state=32}sXMLDeclSeparator(){const t=this.getCodeNorm();t!==J?(st(t)||(this.fail("whitespace required."),this.unget()),this.state=27):this.state=Ot}sXMLDeclEnding(){this.getCodeNorm()===q?(this.piTarget!=="xml"?this.fail("processing instructions are not allowed before root."):this.name!=="version"&&this.xmlDeclExpects.includes("version")&&this.fail("XML declaration must contain a version."),this.xmldeclHandler?.(this.xmlDecl),this.name="",this.piTarget=this.text="",this.state=tt):this.fail("The character ? is disallowed anywhere in XML declarations."),this.xmlDeclPossible=!1}sOpenTag(){const t=this.captureNameChars();if(t===R)return;const s=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name="",this.xmlnsOpt&&(this.topNS=s.ns=Object.create(null)),this.openTagStartHandler?.(s),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail("documents may contain only one root."),t){case q:this.openTag();break;case 47:this.state=35;break;default:st(t)||this.fail("disallowed character in tag name."),this.state=36}}sOpenTagSlash(){this.getCode()===q?this.openSelfClosingTag():(this.fail("forward-slash in opening tag not followed by >."),this.state=36)}sAttrib(){const t=this.skipSpaces();t!==R&&(qt(t)?(this.unget(),this.state=37):t===q?this.openTag():t===47?this.state=35:this.fail("disallowed character in attribute name."))}sAttribName(){const t=this.captureNameChars();t===$t?this.state=39:st(t)?this.state=38:t===q?(this.fail("attribute without value."),this.pushAttrib(this.name,this.name),this.name=this.text="",this.openTag()):t!==R&&this.fail("disallowed character in attribute name.")}sAttribNameSawWhite(){const t=this.skipSpaces();switch(t){case R:return;case $t:this.state=39;break;default:this.fail("attribute without value."),this.text="",this.name="",t===q?this.openTag():qt(t)?(this.unget(),this.state=37):(this.fail("disallowed character in attribute name."),this.state=36)}}sAttribValue(){const t=this.getCodeNorm();Zt(t)?(this.q=t,this.state=40):st(t)||(this.fail("unquoted attribute value."),this.state=42,this.unget())}sAttribValueQuoted(){const{q:t,chunk:s}=this;let{i:o}=this;for(;;)switch(this.getCode()){case t:return this.pushAttrib(this.name,this.text+s.slice(o,this.prevI)),this.name=this.text="",this.q=null,void(this.state=41);case 38:return this.text+=s.slice(o,this.prevI),this.state=14,void(this.entityReturnState=40);case ht:case Tt:case 9:this.text+=`${s.slice(o,this.prevI)} `,o=this.i;break;case Et:return this.text+=s.slice(o,this.prevI),void this.fail("disallowed character.");case R:return void(this.text+=s.slice(o))}}sAttribValueClosed(){const t=this.getCodeNorm();st(t)?this.state=36:t===q?this.openTag():t===47?this.state=35:qt(t)?(this.fail("no whitespace between attributes."),this.unget(),this.state=37):this.fail("disallowed character in attribute name.")}sAttribValueUnquoted(){const t=this.captureTo(Ve);switch(t){case 38:this.state=14,this.entityReturnState=42;break;case Et:this.fail("disallowed character.");break;case R:break;default:this.text.includes("]]>")&&this.fail('the string "]]>" is disallowed in char data.'),this.pushAttrib(this.name,this.text),this.name=this.text="",t===q?this.openTag():this.state=36}}sCloseTag(){const t=this.captureNameChars();t===q?this.closeTag():st(t)?this.state=44:t!==R&&this.fail("disallowed character in closing tag.")}sCloseTagSawWhite(){switch(this.skipSpaces()){case q:this.closeTag();break;case R:break;default:this.fail("disallowed character in closing tag.")}}handleTextInRoot(){let{i:t,forbiddenState:s}=this;const{chunk:o,textHandler:n}=this;t:for(;;)switch(this.getCode()){case Et:if(this.state=15,n!==void 0){const{text:a}=this,l=o.slice(t,this.prevI);a.length!==0?(n(a+l),this.text=""):l.length!==0&&n(l)}s=0;break t;case 38:this.state=14,this.entityReturnState=tt,n!==void 0&&(this.text+=o.slice(t,this.prevI)),s=0;break t;case Ft:switch(s){case 0:s=1;break;case 1:s=2;break;case 2:break;default:throw new Error("impossible state")}break;case q:s===2&&this.fail('the string "]]>" is disallowed in char data.'),s=0;break;case Tt:n!==void 0&&(this.text+=`${o.slice(t,this.prevI)}
`),t=this.i,s=0;break;case R:n!==void 0&&(this.text+=o.slice(t));break t;default:s=0}this.forbiddenState=s}handleTextOutsideRoot(){let{i:t}=this;const{chunk:s,textHandler:o}=this;let n=!1;t:for(;;){const a=this.getCode();switch(a){case Et:if(this.state=15,o!==void 0){const{text:l}=this,p=s.slice(t,this.prevI);l.length!==0?(o(l+p),this.text=""):p.length!==0&&o(p)}break t;case 38:this.state=14,this.entityReturnState=tt,o!==void 0&&(this.text+=s.slice(t,this.prevI)),n=!0;break t;case Tt:o!==void 0&&(this.text+=`${s.slice(t,this.prevI)}
`),t=this.i;break;case R:o!==void 0&&(this.text+=s.slice(t));break t;default:st(a)||(n=!0)}}n&&(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))}pushAttribNS(t,s){const{prefix:o,local:n}=this.qname(t),a={name:t,prefix:o,local:n,value:s};if(this.attribList.push(a),this.attributeHandler?.(a),o==="xmlns"){const l=s.trim();this.currentXMLVersion==="1.0"&&l===""&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[n]=l,Yt(this,n,l)}else if(t==="xmlns"){const l=s.trim();this.topNS[""]=l,Yt(this,"",l)}}pushAttribPlain(t,s){const o={name:t,value:s};this.attribList.push(o),this.attributeHandler?.(o)}end(){this.sawRoot||this.fail("document must contain a root element.");const{tags:t}=this;for(;t.length>0;){const o=t.pop();this.fail(`unclosed tag: ${o.name}`)}this.state!==0&&this.state!==tt&&this.fail("unexpected end.");const{text:s}=this;return s.length!==0&&(this.textHandler?.(s),this.text=""),this._closed=!0,this.endHandler?.(),this._init(),this}resolve(t){let s=this.topNS[t];if(s!==void 0)return s;const{tags:o}=this;for(let n=o.length-1;n>=0;n--)if(s=o[n].ns[t],s!==void 0)return s;return s=this.ns[t],s!==void 0?s:this.opt.resolvePrefix?.(t)}qname(t){const s=t.indexOf(":");if(s===-1)return{prefix:"",local:t};const o=t.slice(s+1),n=t.slice(0,s);return(n===""||o===""||o.includes(":"))&&this.fail(`malformed name: ${t}.`),{prefix:n,local:o}}processAttribsNS(){const{attribList:t}=this,s=this.tag;{const{prefix:a,local:l}=this.qname(s.name);s.prefix=a,s.local=l;const p=s.uri=this.resolve(a)??"";a!==""&&(a==="xmlns"&&this.fail('tags may not have "xmlns" as prefix.'),p===""&&(this.fail(`unbound namespace prefix: ${JSON.stringify(a)}.`),s.uri=a))}if(t.length===0)return;const{attributes:o}=s,n=new Set;for(const a of t){const{name:l,prefix:p,local:S}=a;let x,w;p===""?(x=l==="xmlns"?Mt:"",w=l):(x=this.resolve(p),x===void 0&&(this.fail(`unbound namespace prefix: ${JSON.stringify(p)}.`),x=p),w=`{${x}}${S}`),n.has(w)&&this.fail(`duplicate attribute: ${w}.`),n.add(w),a.uri=x,o[l]=a}this.attribList=[]}processAttribsPlain(){const{attribList:t}=this,s=this.tag.attributes;for(const{name:o,value:n}of t)s[o]!==void 0&&this.fail(`duplicate attribute: ${o}.`),s[o]=n;this.attribList=[]}openTag(){this.processAttribs();const{tags:t}=this,s=this.tag;s.isSelfClosing=!1,this.openTagHandler?.(s),t.push(s),this.state=tt,this.name=""}openSelfClosingTag(){this.processAttribs();const{tags:t}=this,s=this.tag;s.isSelfClosing=!0,this.openTagHandler?.(s),this.closeTagHandler?.(s),(this.tag=t[t.length-1]??null)===null&&(this.closedRoot=!0),this.state=tt,this.name=""}closeTag(){const{tags:t,name:s}=this;if(this.state=tt,this.name="",s==="")return this.fail("weird empty close tag."),void(this.text+="</>");const o=this.closeTagHandler;let n=t.length;for(;n-- >0;){const a=this.tag=t.pop();if(this.topNS=a.ns,o?.(a),a.name===s)break;this.fail("unexpected close tag.")}n===0?this.closedRoot=!0:n<0&&(this.fail(`unmatched closing tag: ${s}.`),this.text+=`</${s}>`)}parseEntity(t){if(t[0]!=="#"){const o=this.ENTITIES[t];return o!==void 0?o:(this.fail(this.isName(t)?"undefined entity.":"disallowed character in entity name."),`&${t};`)}let s=NaN;return t[1]==="x"&&/^#x[0-9a-f]+$/i.test(t)?s=parseInt(t.slice(2),16):/^#[0-9]+$/.test(t)&&(s=parseInt(t.slice(1),10)),this.isChar(s)?String.fromCodePoint(s):(this.fail("malformed character entity."),`&${t};`)}}var te,vt;(vt=te||(te={})).Events={XmlDecl:"xmldecl",Text:"text",ProcessingInstruction:"processinginstruction",Doctype:"doctype",Comment:"comment",OpenTagStart:"opentagstart",Attribute:"attribute",OpenTag:"opentag",CloseTag:"closetag",CDdata:"cdata",Error:"error",End:"end",Ready:"ready"},vt.parseStream=async(i,t,s)=>{const o=new Re({position:!1,...s});let n;if(t.onOpenTagStart&&o.on(vt.Events.OpenTagStart,t.onOpenTagStart),t.onOpenTag&&o.on(vt.Events.OpenTag,t.onOpenTag),t.onCloseTag&&o.on(vt.Events.CloseTag,t.onCloseTag),t.onAttribute&&o.on(vt.Events.Attribute,t.onAttribute),t.onText&&o.on(vt.Events.Text,t.onText),t.onError&&o.on(vt.Events.Error,t.onError),t.onEnd){t.onEnd;const a=()=>{n=t.onEnd()};o.on(vt.Events.End,a)}for(;;){const{value:a,done:l}=await i.read();if(l)break;o.write(a)}return o.close(),n};const D=i=>i===!0||i==="1"||i==="on"||i==="true"||i!==!1&&i!=="0"&&i!=="off"&&i!=="false"&&null,N=i=>{const t=parseInt(i);return isNaN(t)?null:t},yt=i=>{const t=parseFloat(i);return isNaN(t)?null:t},I=null;class $e{constructor(){this._registeredVisitors=new Map}registerVisitor(t){this._registeredVisitors.set(t.from,t)}createEventHandler(t,s,o){const n=this._registeredVisitors,a=[];let l=null,p=null,S=null,x=null;const w=[],k={key:null,source:t};let v=null,h=!1;const E=(T,m)=>{let O=S.attributes[T];if(m){if(Array.isArray(m)){for(let j=0;j<m.length;j++)if(O==null||(O=m[j](O),O==null))return}else if(O==null||(O=m(O),O==null))return}return O},f={getSource:()=>v.source,setSource:T=>{v.source=T},setKey:T=>{v.key=T},getFrom:()=>S,getAttribute:(T,m)=>E(T,m)??null,hasAttribute:T=>f.getAttribute(T)!==null,getParent:()=>w[w.length-2].source,getPath:()=>{const T=[];for(let m=0;m<a.length;m++)T.push(a[m].local);return T.join("\\")},parseAttribute:E,copyToObject:(T,m,O,j)=>{const W=E(j??m,O);W!==void 0&&(T[m]=W)},copyTo:(T,m,O)=>{const j=E(O??T,m);j!==void 0&&(v.source[T]=j)},warn:T=>{o?o?.(T):console.warn(T)}};return{onOpenTag:T=>{let m=T.name;const O=m.indexOf(":");O!==-1&&(m=m.slice(O+1));const j=n.get(m);if(l={local:m,visitor:j,tag:T,destination:null},h)return a.push(l),p=m,void(S=T);x=l?.visitor??null,j&&(v=a.length===0?k:x?.to!==null?{key:null,source:{}}:null,l.destination=v,v&&w.push(v)),a.push(l),p=m,S=T,h=x?.to===null,x?.openTag?.(f)},onCloseTag:T=>{let m=T.name;const O=m.indexOf(":");if(O!==-1&&(m=m.slice(O+1)),m!==p)throw new Error(`mismatch open/close tag: '${m}'/'${p}'`);h||x?.closeTag?.(f);const j=a.pop()??null;l=a[a.length-1]??null;const W=j?.destination;if(W){w.pop(),v=w[w.length-1]??k;const Q=j.visitor;Q&&Q.to&&W.source!==void 0&&(Array.isArray(Q.to)?v.source.push?v.source.push(W.source):o?.(`Unable to parse array for ${Q.from} at ${f.getPath()}`):W.key?v.source[W.key]=W.source:typeof Q.to=="string"&&(v.source[Q.to]=W.source))}p=l?.local??null,S=l?.tag??null,x=l?.visitor??null,h=!l?.destination},onText:T=>{x?.text?.(T,f)},onEnd:s}}}const ce=(i,t,s,o=null)=>{if(!i)return null;let n=i;n.startsWith("/")&&(n=n.substring(1));let a=o?.parsedRefs?.get(i);if(a!==void 0)return a;const l=t(n);if(!l)return null;let p=l.content;try{s&&(p=s(p))}catch(S){console.warn(S)}return o?.parsedRefs?.set(i,p),p},ee=(i,t,s,o,n=null)=>{if(!i)return null;let a=i;a.startsWith("/")&&(a=a.substring(1));let l=n?.parsedRefs?.get(i);if(l!==void 0)return l;const p=t(a);if(!p)return null;const S=p.content;try{const x=new TextDecoder().decode(S),w=s.parseFromString(x,"text/xml"),k=o.convert(w,i,n);return n?.parsedRefs?.set(i,k),k}catch(x){console.warn(x)}return null},Rt=(i,t,s,o,n=null)=>{const a=new Map;let l=t.Directory[i];const p=l?l.length:0;for(let S=0;S<p;S++){const x=l[S];if(!x)continue;let w=x;w.startsWith("/")&&(w=w.substring(1));const k=ee(w,v=>t.files[v],s,o,n);a.set(w,k)}return a},Fe=async(i,t=8388608)=>{await(async()=>{if(typeof ReadableStream>"u")if(typeof window>"u"){const{ReadableStream:a}=await Promise.resolve().then(()=>require("./CeT0UH5gtS-kMnWt.cjs"));globalThis.ReadableStream=a}else console.warn("Browser does not support ReadableStream; consider loading a polyfill.")})();const s=new TextDecoder("utf-8");let o=0;const n=i instanceof Uint8Array?i:new Uint8Array(i);return new ReadableStream({pull(a){if(o>=n.byteLength)return void a.close();const l=n.subarray(o,Math.min(o+t,n.byteLength)),p=s.decode(l,{stream:o+t<n.byteLength});a.enqueue(p),o+=l.length}}).getReader()},Me=["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],se=(i,t="dk1")=>{let s;const o=i("auto");o===void 0||o!=="1"&&o!=="true"||(s=t);const n=i("indexed");n&&(s=`index${n}`);const a=i("rgb");a&&(s=a.toLowerCase(),a.length!==8||a.startsWith("FF")||(s="FF"+a.substring(2,a.length)));const l=i("theme");l&&(s=Me[l]);let p=i("tint");if(p&&(s+=` ${g.IColor.AdjustmentType.ETint} ${parseFloat(p)}`),s)return s},fe=i=>i&&i.replace(/^\{([\s\S]+)\}$/,"$1"),me=i=>i==="true"||i==="1";class Vt{static{this.Collapsed=1}static{this.CustomFormat=2}static{this.CustomHeight=4}static{this.Hidden=8}static{this.Ht=16}static{this.OutlineLevel=32}static{this.Ph=64}static{this.R=128}static{this.S=256}static{this.Spans=512}static{this.ThickBot=1024}static{this.ThickTop=2048}}const je=(i,t,s)=>{if(i[0].value[0]===i[1].value[0])return t},he={colStart:0,colEnd:0,rowStart:0,rowEnd:0},He=(i,t,s,o,n,a)=>{let l=!1,p=!1,S=[],x=!1,w=null,k=null,v=null,h=null,E=null,f=null;const T=a?.get("richData")??[],m=g.AddressUtils.normalizeA1ToR1C1,O=g.CoordUtils.createConflatingRanges(),j=new Map,W=[];let Q=null;const jt=g.CoordUtils.createConflatingRanges();let ut,nt=!1,H=-1,F=-1,et=null,bt=null;const Ht=[];let Nt=null,Xt=-2,at=0,lt="",dt="",pt="",K="",ct="",gt="",xt="",Qt="",Pt="",Wt="",Lt="",Ut="",_t="",P="",$=!0,X=null;return{...s,onEnd:()=>{Ht.length>0&&(t.rows=Ht);let d=O.done(je);const b=d.length;if(b>0){const L=new Array(b);for(let A=0;A<b;A++){const z=d[A],B=g.AddressUtils.rangeToString(z),G=z.value[1],it=g.AddressUtils.resolveRelativeToA1(G,z.rowStart,z.colStart);L[A]=[B,it]}t.formulas=L}const C=jt.done(!0),V=C.length;if(V>0){const L=new Array(V);for(let A=0;A<V;A++){const z=C[A],B=g.AddressUtils.rangeToString(z);L[A]=B}t.volatile=L}if(W.length>0&&(t.dynamicArray=[...W]),S.length>0){S.sort(g.CoordUtils.createRangeComparator(g.IRange.Orientation.Column));const L=[];let A=null,z=-1,B=-1,G=-1,it=-1,Z=null;const ft=S.length;ft>0&&(A=S[0],z=A.colStart,B=A.colEnd,G=A.rowEnd,it=A.value,L.push(A));for(let ot=1;ot<ft;ot++)Z=S[ot],it!==Z.value||z!==Z.colStart||B!==Z.colEnd||G+1!==Z.rowEnd?(L.push(Z),A=Z,z=A.colStart,B=A.colEnd,G=A.rowEnd,it=A.value):(G=Z.rowEnd,A.rowEnd=G);let St=[];for(let ot=0;ot<L.length;ot++){const Ct=L[ot];St.push({r:{colStart:Ct.colStart,colEnd:Ct.colEnd,rowStart:Ct.rowStart,rowEnd:Ct.rowEnd},v:Ct.value})}t.directStyles=St}const Y=i.build();if(Y){const L=Y.tuples;t.data=L}s?.onEnd?.()},onOpenTag:d=>{let b=d.name;const C=b.indexOf(":");if(C!==-1&&(b=b.slice(C+1)),ut){const V=d.attributes;switch(b){case"v":p=!0;break;case"f":switch(V.t??null){case null:case"normal":x=!0;break;case"shared":const Y=V.si;k=V.ref,w=Y;break;case"array":x=!0,k=V.ref,Q=[k,!1];break;case"datatable":x=!0,k=V.ref,x=!0}V.ca!==void 0&&jt.append(H,F);break;case"is":return void(nt=!0)}return void(nt&&n?.onOpenTag(d))}if(l){if(b==="c"){ut=d;const V=d.attributes.r;F=g.AddressUtils.fastStringToCol(V);const Y=d.attributes.t;Y===void 0?bt=null:(bt=Y,bt==="str"&&(nt=!0));let L=d.attributes.s;L!==void 0&&(L=parseInt(L),X&&X.value===L&&X.colEnd+1===F?X.colEnd=F:(X={colStart:F,rowStart:H,colEnd:F,rowEnd:H,value:L},S.push(X)))}}else{if(b==="row"){l=!0;const V=d.attributes.r;if(H=parseInt(V)-1,at=0,dt=d.attributes.customHeight,dt!==void 0&&(at|=Vt.CustomHeight),dt!==Pt&&($=!0,Pt=dt),lt=d.attributes.ht,lt!==void 0&&(at|=Vt.Ht),lt!==Qt&&($=!0,Qt=lt),pt=d.attributes.hidden,pt!==void 0&&(at|=Vt.Hidden),pt!==Wt&&($=!0,Wt=pt),ct=d.attributes.s,ct!==void 0&&(at|=Vt.S),ct!==Ut&&($=!0,Ut=ct),K=d.attributes.customFormat,K!==void 0&&(at|=Vt.CustomFormat),K!==Lt&&($=!0,Lt=K),gt=d.attributes.outlineLevel,gt!==void 0&&(at|=Vt.OutlineLevel),gt!==_t&&($=!0,_t=gt),xt=d.attributes.collapsed,xt!==void 0&&(at|=Vt.Collapsed),xt!==P&&($=!0,P=xt),at!==0)if(Xt+1!==H||$){const Y=dt!==void 0&&(dt==="1"||dt==="true"),L=K!==void 0&&(K==="1"||K==="true");Nt={min:H,max:H,sz:Y&&lt!==void 0?parseFloat(lt):-1,csz:Y,h:pt!==void 0&&(pt==="1"||pt==="true"),s:Y&&ct!==void 0&&ct!=="0"?parseInt(ct):0,cs:L,l:gt===void 0||gt==="0"?0:parseInt(gt),cl:xt!==void 0&&(xt==="1"||xt==="true")},Ht.push(Nt)}else Nt.max=H;return Xt=H,void($=!1)}s?.onOpenTag(d)}},onCloseTag:d=>{if(ut){let b=d.name;const C=b.indexOf(":");if(C!==-1&&(b=b.slice(C+1)),nt)if(b==="is"||b==="v"){const V=n?.onEnd();V!==null&&i.addValue(H,F,""+V)}else n?.onCloseTag?.(d);return p&&(p=!1),void(b==="c"&&(ut=null,nt=!1))}if(l)return l=!1,void(X=null);s?.onCloseTag(d)},onText:d=>{if(d=d.trim(),p){switch(et=null,bt){case null:case"n":et=parseFloat(d);break;case"b":et=d==="1"||d==="true";break;case"s":et=d;break;case"e":if(d==="#VALUE!"){const C=ut.attributes.vm;if(C!==void 0){const V=T[parseInt(C)-1];if(V&&V.isFormulaError){et={t:g.ScalarType.Error,v:V.getCode()};break}}}const b=g.FormulaError.getBuiltInByLabel(d);b?et={t:g.ScalarType.Error,v:b.getCode()}:(et=d,o?.(`Unknown formula error '${d}' in cell ${g.AddressUtils.cellToString({colIndex:F,rowIndex:H})}`));break;case"str":case"inlineStr":nt=!0}et!==null&&i.addValue(H,F,et)}if(Q&&(bt==="e"&&(Q[1]=!0),W.push(Q),Q=null),w)if(E===w)h=f;else{if(h=j.get(w),!h){const b=[];v=m(d,H,F,b),h=[v,b,d],j.set(w,h)}E=w,f=h}if(x){const b=[];v=m(d,H,F,b),h=[v,b,d]}if(h)return O.append(H,F,h),h=null,x=!1,w=null,void(k=null);nt?n?.onText(d):l||s?.onText(d)}}},Xe=Object.freeze(Object.defineProperty({__proto__:null,fromBufferXLSX:async(i,t)=>{const{password:s,onWarning:o,constructorOptions:n={},...a}=t??{},l=Promise.resolve().then(()=>require("./DtyoMMQEFXuDrVU4.cjs")),p=Promise.resolve().then(()=>require("./DrrgUgPukvOBUCzH.cjs"));let S=null;try{S=new DOMParser}catch{}let x=null;S||(x=Promise.resolve().then(()=>require("./CzA2FLPIVh4-0iW3.cjs")).then(h=>h.index));let w=null,k=null,v=null;try{const h=await Promise.all([l,p,x]);w=h[0],k=h[1],v=h[2]}catch(h){throw new Error("Unable to load XLSX parser.",{cause:h})}try{const h=w.read(i,{type:"array",sheets:[],cellStyles:!1,bookFiles:!0});if(!h.Directory)throw new Error("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.");h.Directory.richstructure=["/xl/richData/rdrichvaluestructure.xml"],h.Directory.richdata=["/xl/richData/rdrichvalue.xml"];const E=new k.FromOOXMLConverter,f=S??new v.DOMParser,T=n?.resources??new g.ResourceCollection,m=T.beginPersist(),O={},j=new Set,W=new Map;W.set("richTypes",[]);const Q=new Map,jt=[],ut=P=>h.files[P],nt=(P,$)=>{const X=P.lastIndexOf("/"),d=P.substring(0,X+1)+"_rels/"+P.substring(X+1,P.length)+".rels";let b=$.get(d);return b||(b=((C,V,Y,L,A=null)=>{if(!C)return null;const z=ee(C,V,Y,L,A);if(!z)return null;const B=new Map,G=Object.keys(z),it=G.length;for(let Z=0;Z<it;Z++){const ft=G[Z],St=z[ft];B.set(ft,St)}return B})(d,ut,f,E,F),$.set(d,b)),b},H=(P,$,X,d=Q)=>{let b=nt($,d).get(P),C=b?.target;if(!C)return null;if(b.targetMode==="External")return b.target;const V=$.lastIndexOf("/"),Y=$.substring(0,V+1);C.startsWith("/")||(C=Y+C),C=(z=>{const B=z.split(/\/+/);return B.reduce((it,Z,ft)=>(Z==="."?it.splice(ft,1):Z===".."&&it.splice(ft-1,2),it),B).join("/")})(C);const L=E?.getVisitorParamsState().get("dxfs");let A=d.get(C);if(!A)if(b.type==="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"){const B={};A=B;const G=async()=>{const it=((U,mt,Kt,kt,wt,Dt,At)=>{const u=new $e,rt=new g.Tuple.TransposedBuilder;let _=null;u.registerVisitor({from:"autoFilter",to:"filter",openTag:e=>{e.copyTo("ref",I)}}),u.registerVisitor({from:"conditionalFormatting",to:{},openTag:e=>{const r=e.getParent();r.conditionals||(r.conditionals=[]),r.conditionals.push(e.getSource());const c=e.getAttribute("sqref");c&&(e.getSource().ref=c.split(" ").join(",")),e.copyTo("pivot",D)},closeTag:e=>{const r=e.getSource();if(r.rule){const c=Object.keys(r.rule);for(let y=0;y<c.length;y++){const M=c[y];M!=="rule"&&(r[M]=r.rule[M])}}delete r.rule}}),u.registerVisitor({from:"cfRule",to:"rule",openTag:e=>{const r=e.getParent();e.copyToObject(r,"type",I),e.copyToObject(r,"priority",N),e.copyToObject(r,"stopIfTrue",D);const c=e.getAttribute("dxfId",N);if(c!==null){let y=kt?.get(c);y||(Dt?.(`Unable to load conditional color. Invalid dxfI: '${c}' at '${e.getPath()}'.`),y={}),r.style=y}e.copyToObject(r,"aboveAverage",D),e.copyToObject(r,"equalAverage",D),e.copyToObject(r,"stdDev",N),e.copyToObject(r,"bottom",D),e.copyToObject(r,"percent",D),e.copyToObject(r,"rank",N),e.copyToObject(r,"operator",I),e.copyToObject(r,"text",I),e.copyToObject(r,"timePeriod",I)}}),u.registerVisitor({from:"colorScale",to:"colorScale"}),u.registerVisitor({from:"dataBar",to:"dataBar",openTag:e=>{e.copyTo("maxLength",N),e.copyTo("minLength",N),e.copyTo("showValue",D)}}),u.registerVisitor({from:"iconSet",to:"iconSet",openTag:e=>{e.copyTo("iconSet",I),e.copyTo("reverse",D),e.copyTo("showValue",D)}}),u.registerVisitor({from:"formula",to:null,text:(e,r)=>{const c=r.getParent();let y=c.formulas;y||(y=[],c.formulas=y),y.push(e)}}),u.registerVisitor({from:"cfvo",to:{},openTag:e=>{const r=e.getParent();r.conditions||(r.conditions=[]),r.conditions.push(e.getSource()),e.copyTo("type",I),e.copyTo("value",yt,"val"),e.copyTo("gte",D)}}),u.registerVisitor({from:"color",to:{},openTag:e=>{const r=e.getParent();r.colors||(r.colors=[]);const c=se(y=>e.getAttribute(y));r.colors.push(c)}}),u.registerVisitor({from:"filterColumn",to:"filterColumn",openTag:e=>{const r=e.getParent();r.fields||(r.fields=[]),r.fields.push(e.getSource()),e.copyTo("offset",N,"colId"),e.copyTo("hiddenButton",D),e.copyTo("showButton",D)}}),u.registerVisitor({from:"colorFilter",to:"colorFilter",openTag:e=>{const r=e.getParent();r.criteria||(r.criteria=[]),r.criteria.push(e.getSource()),e.getSource().type=g.IAutoFilter.Type.Color,e.copyTo("cellColor",D),e.copyTo("styleId",N,"dxfId")}}),u.registerVisitor({from:"dynamicFilter",to:"dynamicFilter",openTag:e=>{const r=e.getParent();r.criteria||(r.criteria=[]),r.criteria.push(e.getSource()),e.getSource().type=g.IAutoFilter.Type.Dynamic,e.copyTo("dynamicType",I,"type"),e.copyTo("val",yt),e.copyTo("maxVal",yt,"maxVal")}}),u.registerVisitor({from:"iconFilter",to:"iconFilter",openTag:e=>{const r=e.getParent();r.criteria||(r.criteria=[]),r.criteria.push(e.getSource()),e.getSource().type=g.IAutoFilter.Type.Icon,e.copyTo("iconId",N),e.copyTo("iconSet",I)}}),u.registerVisitor({from:"top10",to:"top10",openTag:e=>{const r=e.getParent();r.criteria||(r.criteria=[]),r.criteria.push(e.getSource()),e.getSource().type=g.IAutoFilter.Type.Top10,e.copyTo("filterVal",yt),e.copyTo("percent",D),e.copyTo("top",D),e.copyTo("val",yt)}}),u.registerVisitor({from:"filters",to:"filters",openTag:e=>{const r=e.getParent();r.criteria||(r.criteria=[]),r.criteria.push(e.getSource()),e.getSource().type=g.IAutoFilter.Type.Items,e.copyTo("blank",D),e.copyTo("calendarType",I)}}),u.registerVisitor({from:"dateGroupItem",to:"dateGroupItem",openTag:e=>{const r=e.getParent();r.dateGroups||(r.dateGroups=[]),r.dateGroups.push(e.getSource()),e.copyTo("group",I,"dateTimeGrouping"),e.copyTo("day",N),e.copyTo("hour",N),e.copyTo("minute",N),e.copyTo("month",N),e.copyTo("second",N),e.copyTo("year",N)}}),u.registerVisitor({from:"filter",to:"filter",openTag:e=>{const r=e.getParent();r.items||(r.items=[]),r.items.push(e.getAttribute("val",yt))}}),u.registerVisitor({from:"customFilters",to:"customFilters",openTag:e=>{const r=e.getParent();r.criteria||(r.criteria=[]),r.criteria.push(e.getSource()),e.getSource().type=g.IAutoFilter.Type.Custom,e.copyTo("and",D)}}),u.registerVisitor({from:"customFilter",to:"customFilter",openTag:e=>{const r=e.getParent();r.filters||(r.filters=[]),r.filters.push(e.getSource()),e.copyTo("operator",I),e.copyTo("value",yt,"val")}}),u.registerVisitor({from:"sortState",to:"sort",openTag:e=>{e.copyTo("ref",I)}}),u.registerVisitor({from:"sortCondition",to:"sortCondition",openTag:e=>{const r=e.getParent();r.fields||(r.fields=[]);const c=e.getSource();r.fields.push(c),e.copyTo("sortOn",I,"sortBy"),e.copyTo("dxfId",I,"sortBy"),e.copyTo("iconSet",I),e.copyTo("customList",I);const y=e.getAttribute("ref");if(y){const M=g.AddressUtils.fastStringToRange(y,he).colStart,It=g.AddressUtils.fastStringToRange(r.ref,he),Gt=It.colStart;c.offset=It?M-Gt:M}c.reverse=e.getAttribute("descending",D)??!1}}),u.registerVisitor({from:"AlternateContent",to:null});const zt=e=>{_=e.getSource(),e.copyTo("topLeft",I,"topLeftCell");const r=me(e.getAttribute("defaultGridColor")),c=e.getAttribute("colorId");c===null||r||(e.getSource().gridLineColor="index"+parseFloat(c)),e.copyTo("showZeros",D),e.copyTo("showFormulas",D),e.copyTo("zoomScale",N),e.copyTo("showRowHeaders",D,"showRowColHeaders"),e.copyTo("showColumnHeaders",D,"showRowColHeaders"),e.copyTo("showRowGridlines",D,"showGridLines"),e.copyTo("showColumnGridlines",D,"showGridLines")};u.registerVisitor({from:"sheetView",to:"view",openTag:e=>{zt(e)},closeTag:()=>{_=null}}),u.registerVisitor({from:"customSheetViews",to:"customSheetViews",openTag:e=>{e.setSource([])}}),u.registerVisitor({from:"customSheetView",to:[],openTag:e=>{zt(e)},closeTag:()=>{_=null}}),u.registerVisitor({from:"selection",to:"selection",openTag:e=>{if(!_)return;e.copyTo("cell",I,"activeCell"),e.copyTo("rangeIndex",N,"activeCellId");const r=e.getAttribute("activeCell"),c=e.getAttribute("sqref");c&&c!==r&&(e.getSource().ranges=c.split(" "))}}),u.registerVisitor({from:"pane",to:"pane",openTag:e=>{if(_&&e.getAttribute("state")==="frozen"){const r={};_.freezePanes=r,e.copyToObject(r,"topLeft",I,"topLeftCell");const c=_.topLeft?g.AddressUtils.fastStringToCell(_.topLeft):{colIndex:0,rowIndex:0},y={colIndex:0,rowIndex:0};e.copyToObject(y,"colIndex",N,"xSplit"),e.copyToObject(y,"rowIndex",N,"ySplit");const M={colIndex:c.colIndex+y.colIndex,rowIndex:c.rowIndex+y.rowIndex};r.coords=g.AddressUtils.cellToString(M)}}}),u.registerVisitor({from:"tabColor",to:null,openTag:e=>{const r=se(c=>e.getAttribute(c));r&&(U.tabColor=r)}}),u.registerVisitor({from:"pageSetUpPr",to:"pageSetUpPr",openTag:e=>{}}),u.registerVisitor({from:"outlinePr",to:"outlinePr",openTag:e=>{}}),u.registerVisitor({from:"pageMargins",to:"pageMargins",openTag:e=>{}}),u.registerVisitor({from:"pageSetup",to:"pageSetup",openTag:e=>{}}),u.registerVisitor({from:"printOptions",to:"printOptions",openTag:e=>{}}),u.registerVisitor({from:"mergeCells",to:"merges",openTag:e=>{e.setSource([])}}),u.registerVisitor({from:"mergeCell",to:[],openTag:e=>{const r=e.getAttribute("ref");e.setSource(r)}}),u.registerVisitor({from:"hyperlinks",to:"hyperlinks",openTag:e=>{e.setSource([])}}),u.registerVisitor({from:"hyperlink",to:[],openTag:e=>{const r=e.getAttribute("r:id"),c=e.getAttribute("ref");if(!c)return void console.warn("No ref found for hyperlink");e.setKey(c);let y=r?mt(r):"";if(typeof y!="string")return void console.warn("Invalid address ",y);const M=e.getAttribute("location");y.endsWith("\\")&&(y=y.substring(0,y.length-1));const It=e.getAttribute("location");if(It&&(M&&M!==It&&console.warn("display and location are different",M,It),y+="#"+It),!y)return void console.warn("No address found for hyperlink. r:id",r);let Gt;const ie=e.getAttribute("tooltip");Gt=ie?{address:y,tooltip:ie}:y,e.setSource({r:c,v:Gt})}}),u.registerVisitor({from:"drawing",to:"movables",openTag:e=>{const r=e.getAttribute("r:id");if(!r)return;const c=mt(r);c?e.setSource(c.movables):console.warn("no drawing found for rId",r)}}),u.registerVisitor({from:"tableParts",to:"tables",openTag:e=>{e.setSource([])}}),u.registerVisitor({from:"tablePart",to:[],openTag:e=>{const r=e.getAttribute("r:id");if(!r)return;const c=mt(r);c?e.setSource(c):console.warn("no table found for rId",r)}}),u.registerVisitor({from:"worksheet",to:"worksheet",openTag:e=>{}}),u.registerVisitor({from:"sheetProtection",to:"protection",openTag:e=>{let r=!1;if(e.hasAttribute("sheet")&&D(e.getAttribute("sheet"))&&(r=!0),!r)return void e.setSource(void 0);const c=M=>M===!0||M==="1"||M==="on"||M==="true"||M===!1||M==="0"||M==="off"||M==="false"||null;e.copyTo("autoFilter",c),e.copyTo("deleteColumns",c),e.copyTo("formatCells",c),e.copyTo("formatColumns",c),e.copyTo("formatRows",c),e.copyTo("insertColumns",c),e.copyTo("insertHyperlinks",c),e.copyTo("insertRows",c),e.copyTo("objects",c),e.copyTo("pivotTables",c),e.copyTo("scenarios",c),e.copyTo("selectUnlockedCells",c),e.copyTo("selectUnlockedCells",c),e.copyTo("sort",c);const y={};e.copyToObject(y,"hash",I,"hashValue"),e.copyToObject(y,"algorithm",I,"algorithmName"),e.copyToObject(y,"salt",I,"saltValue"),e.copyToObject(y,"spinCount",N),Object.keys(y).length>0&&(e.getSource().password=y)}}),u.registerVisitor({from:"protectedRanges",to:"protectedRanges",openTag:e=>{e.setSource({})}}),u.registerVisitor({from:"protectedRange",to:{},openTag:e=>{const r=e.getAttribute("sqref");e.setKey(r),e.copyTo("name"),e.copyTo("securityDescriptor");const c={};e.copyToObject(c,"hash",I,"hashValue"),e.copyToObject(c,"algorithm",I,"algorithmName"),e.copyToObject(c,"salt",I,"saltValue"),e.copyToObject(c,"spinCount",N),Object.keys(c).length>0&&(e.getSource().password=c)}}),u.registerVisitor({from:"sheetFormatPr",to:"sheetFormatPr",openTag:e=>{e.copyToObject(U,"defaultColSize",yt,"defaultColWidth"),e.copyToObject(U,"outlineLevelCol",N,"outlineLevelCol");const r=e.getAttribute("customHeight");r!=="1"&&r!=="true"||e.copyToObject(U,"defaultRowSize",yt,"defaultRowHeight"),e.copyToObject(U,"outlineLevelRow",N,"outlineLevelRow")}}),u.registerVisitor({from:"cols",to:"cols",openTag:e=>{e.setSource([])}}),u.registerVisitor({from:"col",to:[],openTag:e=>{e.copyTo("min",r=>parseInt(r)-1),e.copyTo("max",r=>parseInt(r)-1),e.copyTo("sz",yt,"width"),e.copyTo("cs",D,"customWidth"),e.copyTo("h",D,"hidden"),e.copyTo("l",N,"outlineLevel"),e.copyTo("s",N,"style")}}),u.registerVisitor({from:"oleObjects",to:null,openTag:e=>{e.warn("'OLE Objects' are not supported.")}});let Bt=null;const Te={onOpenTag:e=>{Bt===null&&(Bt="")},onText:e=>{Bt+=e},onEnd:()=>{const e=Kt(Bt);return Bt=null,e},onError:e=>{}};return He(rt,U,u.createEventHandler(U,wt,Dt),Dt,Te,At)})(B,(U,mt=!1)=>H(U,C,mt)??null,at,L,()=>{},U=>{o&&(U=C+": "+U,o?.(U))},W),Z=ce(C,ut),ft=await Fe(Z);try{await te.parseStream(ft,it,{xmlns:!1})}catch(U){throw console.warn(`Error parsing sheet: '${C}'`,U),new Error(`Error parsing sheet: '${C}'`,{cause:U})}const St=nt(C,d);let ot,Ct=new Map;if(St){const U="http://schemas.microsoft.com/office/2017/10/relationships/threadedComment";let mt;St.forEach((kt,wt)=>{kt.type===U&&(ot=H(wt,C,!1,d)?.comments,ot&&ot.forEach(At=>{Ct.set(At.id,At)}))});const Kt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";if(St.forEach((kt,wt)=>{kt.type===Kt&&(mt=H(wt,C,!1,d))}),mt||ot){const kt=ot??[],wt=mt?.comments;if(wt){const Dt=mt?.authors;for(let At=0;At<wt.length;At++){const u=wt[At];let rt=u.authorId!==void 0?Dt[u.authorId]:void 0;if((!rt||rt.startsWith("tc="))&&(rt=fe(rt.substring(3)),Ct.has(rt)))continue;let _=lt.get(rt);_||(_=dt.get(rt)),_||(_={id:g.CommonUtils.uuidV4(),displayName:rt},dt.set(_.displayName,_),lt.set(_.id,_)),rt=_?.id??null;const zt={id:g.CommonUtils.uuidV4(),personId:rt,ref:u.ref,done:!1,asNote:!0,content:u.content};kt.push(zt)}}B.comments=kt}}};jt.push(G())}else A=X?ce(C,ut,B=>{const G=T.add({buffer:B});return G.addReference(O),j.add(G),m.toResourceId(G)},F):ee(C,ut,f,E,F);return A},F={paramMap:W,getRefs:nt,getRef:H,parsedRefs:Q,onWarning:o,addPerson:P=>null},et=[];let bt=0;h.Strings&&(bt=parseInt(h.Strings.Unique??h.Strings.length??0));const Ht=h.Strings??[];for(let P=0;P<bt;P++)et.push(Ht[P]?.t??"");const Nt=new Map;let Xt=bt;const at=P=>{const $=Nt.get(P);if($!==void 0)return $;const X=Xt;return Nt.set(P,Xt++),et.push(P),X},lt=(Rt("richstructure",h,f,E,F),Rt("richdata",h,f,E,F),new Map),dt=new Map,pt=Rt("people",h,f,E);let K=null;if(pt.size>0&&(K=pt.entries().next()?.value?.[1]?.persons,K)){const P=K.length;for(let $=0;$<P;$++){const X=K[$];lt.set(X.id,X),lt.set(X.displayName,X)}}const ct=Rt("themes",h,f,E,F);let gt=null;if(ct&&ct.entries){let P=ct.entries().next();P?.value?.[1]&&(gt=P.value[1])}const xt=new g.Theme(gt);let Pt=Rt("styles",h,f,E,F).entries().next()?.value[1];Pt&&(Pt=JSON.parse(g.JSONStableStringify(Pt)));const Wt=Rt("workbooks",h,f,E,F);await Promise.all(jt);const Lt={...Wt.entries().next().value[1],styles:Pt,theme:xt.toJSON()};et.length>0&&(Lt.strings=et),K&&K.length>0&&(Lt.people=K);const Ut={...n,resources:T,json:Lt},_t=new g.Workbook(Ut);return j.forEach(P=>{P.deleteReference(O)}),m.endPersist(),_t}catch(h){let E="Unable to parse XLSX.";throw h instanceof g.OutOfBoundsError&&(E="Unable to open XLSX. There are too many rows or columns."),new Error(E,{cause:h})}},toBufferXLSX:async(i,t)=>{const s=await Promise.resolve().then(()=>require("./DtyoMMQEFXuDrVU4.cjs")),o=await i.toJSON(!0),n=s.utils.book_new();for(let a=0;a<o.sheets.length;a++){const l=o.sheets[a],p=s.utils.json_to_sheet([{}]);s.utils.book_append_sheet(n,p,l.name);const S=l.sheet,x=i.getSheetAt(a),w=x.getUsedRange();if(w?(p["!ref"]=w.getA1(),w.forEach((k,v)=>{const h={t:"z"},E=v.getCell().getStyle();if(!E.isNormal()){let f=E.getNumberFormat();f!==g.NumberFormat.Type.General&&(f===g.NumberFormat.Type.ShortDate?f="m/d/yyyy":f===g.NumberFormat.Type.MediumDate?f="d-mmm-yy":f===g.NumberFormat.Type.LongDate?f="[$-x-sysdate]dddd, mmmm dd, yyyy":f===g.NumberFormat.Type.ShortTime?f="h:mm":f===g.NumberFormat.Type.MediumTime?f="h:mm AM/PM":f===g.NumberFormat.Type.LongTime&&(f="h:mm:ss AM/PM"),h.z=f)}if(k!==null)switch(v.getType()){case g.ScalarType.Number:h.t="n",h.v=k;break;case g.ScalarType.String:h.t="s",h.v=k;break;case g.ScalarType.Boolean:h.t="b",h.v=k;break;case g.ScalarType.Error:h.t="e",h.v=k.toString();case g.ScalarType.RichData:}p[v.getA1()]=h})):p["!ref"]="A1:A1",S.merges?.length>0){const k=[];p["!merges"]=k;for(let v=0;v<S.merges.length;v++)k.push(s.utils.decode_range(S.merges[v]))}if(S.cols?.length>0){const k=[];p["!cols"]=k;const v=S.cols,h={width:S.defaultColSize??x.getColumnWidthAsFontUnit(x.getColumnHeaders().getDefaultSize())};for(let E=0;E<v.length;E++){const f=v[E];for(let m=k.length;m<=f.min-1;m++)k.push(h);const T={};f.sz!==void 0&&(T.width=f.sz),f.h!==void 0&&(T.hidden=f.h),f.l!==void 0&&(T.level=f.l);for(let m=f.min;m<=f.max;m++)k.push(T)}}}return s.write(n,{type:"array",bookType:"xlsx"}),s.write(n,{type:"array",bookType:"xlsx"})}},Symbol.toStringTag,{value:"Module"}));exports.index=Xe,exports.parseAngle=i=>parseFloat(i)/6e4,exports.parseAsBoolean=me,exports.parsePercentage=i=>parseFloat(i)/1e3,exports.processDataBarColor=se,exports.removeCurlyBraces=fe,exports.toPixels=i=>i?oe.CommonUtils.roundAccurately(parseFloat(i)/9525,1):null,exports.toPoints=i=>i?oe.CommonUtils.roundAccurately(parseFloat(i)/12700,4):null;