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