@cj-tech-master/excelts 9.5.3 → 9.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v9.5.3
2
+ * @cj-tech-master/excelts v9.5.4
3
3
  * Zero-dependency TypeScript toolkit — Excel (XLSX), PDF, CSV, Markdown, XML, ZIP/TAR, and streaming.
4
4
  * (c) 2026 cjnoname
5
5
  * Released under the MIT License
@@ -34,7 +34,7 @@ var ExcelTS=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Modu
34
34
  `)return{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`
35
35
  `,rawStart:h,rawEnd:p};if(t===`\r`)return p+1<u&&e[p+1]===`
36
36
  `?{fields:d,quoted:f,endPos:p+2,complete:!0,needMore:!1,newline:`\r
37
- `,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}}}return r&&(d.length>0||p>t)?{fields:d,quoted:f,endPos:p,complete:!0,needMore:!1,unterminatedQuote:m||void 0,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p,complete:!1,needMore:!r,resumePos:t,unterminatedQuote:m||void 0,rawStart:h,rawEnd:p}}function Gt(e){let t={...Lt,...e},n=Rt(),r=[],i=[];return{get config(){return t},scanRow(e,n=0,r=!1){return Wt(e,n,t,r)},feed(e){n.buffer+=e},nextRow(){if(n.position>=n.buffer.length)return null;let e=Wt(n.buffer,n.position,t,!1,r,i);if(e.needMore)return null;if(e.complete){e.raw=n.buffer.slice(e.rawStart,e.rawEnd),n.position=e.endPos;let t=n.position,r=n.buffer.length;return(t>65536||t>r/2&&t>4096)&&(n.buffer=n.buffer.slice(n.position),n.position=0),e}return null},flush(){if(n.position>=n.buffer.length)return null;let e=Wt(n.buffer,n.position,t,!0,r,i);return e.fields.length===0&&e.endPos===n.position?null:(e.raw=n.buffer.slice(e.rawStart,e.rawEnd),n.position=e.endPos,e)},reset(){n=Rt(),r.length=0,i.length=0},getBuffer(){return n.buffer.slice(n.position)}}}function Kt(e){let t={lineNumber:0,dataRowCount:0,skippedDataRows:0,truncated:!1,headerRow:null,originalHeaders:null,useHeaders:!1,headerRowProcessed:!1,renamedHeadersForMeta:null,currentRowStartLine:+!!e.infoOption,currentRowStartOffset:0,currentRowQuoted:[],currentRawRow:``},{headers:n,groupColumnsByName:r}=e;if(n===!0)t.useHeaders=!0;else if(Array.isArray(n)){let e=_t([],{headers:n,groupColumnsByName:r},null);e&&(t.headerRow=e.headers,t.originalHeaders=e.originalHeaders,t.renamedHeadersForMeta=e.renamedHeaders),t.useHeaders=!0,t.headerRowProcessed=!0}else typeof n==`function`&&(t.useHeaders=!0);return t}function qt(e,t,n,r,i){t&&(e.currentRowQuoted=[],e.currentRowStartLine=r,e.currentRowStartOffset=i),n&&(e.currentRawRow=``)}let Jt=Object.freeze(Array(256).fill(!1));function Yt(e){return e<=256?Jt:Array(e).fill(!1)}function Xt(e){return typeof e==`boolean`?{isValid:e,reason:`Validation failed`}:{isValid:e.isValid,reason:e.reason||`Validation failed`}}function Zt(e,t,n){return gt(e,null,t||!1,n)}function Qt(e){return e.length>0?e:void 0}function $t(e,t){return{delimiter:e.delimiter,linebreak:e.linebreak,aborted:!1,truncated:t.truncated,cursor:t.dataRowCount,fields:t.headerRow?Ct(t.headerRow):void 0,renamedHeaders:t.renamedHeadersForMeta}}function en(e,t){return t.trimFieldIsIdentity?e:e.map(t.trimField)}function*tn(e,t,n,r){if(e===``)return;let i=0;for(let{line:a,lineLengthWithEnding:o}of At(e,t.linebreakRegex)){if(n.lineNumber++,t.toLine!==void 0&&n.lineNumber>t.toLine){n.truncated=!0;break}if(n.lineNumber<=t.skipLines){i+=o;continue}if(a===``&&t.shouldSkipEmpty){i+=o;continue}if(t.maxRowBytes!==void 0&&Ie(a)>t.maxRowBytes)throw Error(`Row exceeds the maximum size of ${t.maxRowBytes} bytes`);t.infoOption&&(n.currentRowStartLine=n.lineNumber,n.currentRowStartOffset=i),t.rawOption&&(n.currentRawRow=a);let e=en(a.split(t.delimiter),t);if(t.infoOption&&(n.currentRowQuoted=Yt(e.length)),t.comment&&e[0]?.trimStart().startsWith(t.comment)){i+=o;continue}if(t.shouldSkipEmpty&&ye(e,t.shouldSkipEmpty)){i+=o;continue}let s=It(e,n,t,r,n.lineNumber);if(i+=o,s.stop){yield s;return}(!s.skipped||s.error)&&(yield s),qt(n,t.infoOption,t.rawOption,n.lineNumber+1,i)}}function*nn(e,t,n,r){let i=Et(t),a=e.length,o=0;for(t.infoOption&&(n.currentRowStartOffset=0);o<a;){let a=Wt(e,o,i,!0);if(a.fields.length===0&&a.endPos===o)break;let s=en(a.fields,t),c=n.lineNumber+1;{let t=a.rawStart,r=a.rawEnd,i=1;for(let n=t;n<r;n++){let t=e.charCodeAt(n);t===10?i++:t===13&&(n+1<r&&e.charCodeAt(n+1)===10&&n++,i++)}n.lineNumber+=i}if(t.toLine!==void 0&&n.lineNumber>t.toLine){n.truncated=!0;break}let l=a.rawEnd;if(n.lineNumber<=t.skipLines){o=a.endPos;continue}if(t.maxRowBytes!==void 0&&Ie(e.slice(a.rawStart,l))>t.maxRowBytes)throw Error(`Row exceeds the maximum size of ${t.maxRowBytes} bytes`);if(t.comment&&s[0]?.trimStart().startsWith(t.comment)){o=a.endPos;continue}if(t.shouldSkipEmpty&&ye(s,t.shouldSkipEmpty)){o=a.endPos;continue}t.infoOption&&(n.currentRowStartLine=c,n.currentRowStartOffset=a.rawStart,n.currentRowQuoted=a.quoted),t.rawOption&&(n.currentRawRow=e.slice(a.rawStart,l)),a.unterminatedQuote&&r.push({code:`MissingQuotes`,message:`Quoted field unterminated`,line:n.lineNumber});let u=It(s,n,t,r,n.lineNumber);if(u.stop){yield u;return}(!u.skipped||u.error)&&(yield u),o=a.endPos,t.infoOption&&(n.currentRowStartOffset=a.endPos)}}function rn(e,t={}){let{config:n,processedInput:r}=Tt(e,t),i=Kt(n),a=[],o=[],s=n.fastMode?tn(r,n,i,a):nn(r,n,i,a);if(!i.useHeaders){let e=[];for(let r of s){if(r.row&&!r.skipped){let i=r.row;if(t.rowTransform){let e=t.rowTransform(i);if(e==null)continue;i=e}if(t.validate){let{isValid:e,reason:n}=Xt(t.validate(i));if(!e){o.push({row:i,reason:n});continue}}(n.dynamicTyping||n.castDate)&&(i=Zt(i,n.dynamicTyping,n.castDate)),n.infoOption&&r.info?e.push({record:i,info:r.info}):e.push(i)}else r.row&&r.skipped&&r.error&&o.push({row:r.row,reason:r.reason||r.error.message});if(r.stop)break}let r=$t(n,i);return n.infoOption||t.validate?{headers:void 0,rows:e,invalidRows:Qt(o),errors:Qt(a),meta:r}:e}let c=[];for(let e of s){if(e.row&&!e.skipped){let r=Pt(e.row,i,n);if(e.extras&&e.extras.length>0&&(r._extra=e.extras),t.rowTransform){let e=t.rowTransform(r);if(e==null)continue;r=e}if(t.validate){let{isValid:n,reason:i}=Xt(t.validate(r));if(!n){o.push({row:e.row,reason:i});continue}}n.infoOption&&e.info?c.push({record:r,info:e.info}):c.push(r)}else e.row&&e.skipped&&e.error&&o.push({row:e.row,reason:e.reason||e.error.message});if(e.stop)break}let l=$t(n,i),{objname:u}=t;if(u&&i.headerRow){let e=Object.create(null);for(let t of c){let r=(n.infoOption?t.record:t)[u],i=r==null?``:String(r);i!==`__proto__`&&(e[i]=t)}return{headers:l.fields,rows:e,invalidRows:Qt(o),errors:Qt(a),meta:l}}return{headers:l.fields,rows:c,invalidRows:Qt(o),errors:Qt(a),meta:l}}function an(e){return!!e&&typeof e==`object`&&typeof e.getReader==`function`}function on(e){return!!e&&typeof e==`object`&&typeof e.getWriter==`function`}function sn(e){return!!e&&typeof e==`object`&&!!e.readable&&!!e.writable&&an(e.readable)&&on(e.writable)}let cn=new TextEncoder,ln=new TextDecoder(`utf-8`,{ignoreBOM:!0}),un=new Map;function dn(e){let t=(e??`utf-8`).trim().toLowerCase();return t===``||t===`utf8`||t===`utf-8`?`utf-8`:t===`utf16le`||t===`utf-16le`||t===`ucs2`||t===`ucs-2`?`utf-16le`:t===`binary`?`latin1`:t}function fn(e){let t=dn(e);if(t===`utf-8`)return ln;let n=un.get(t);return n||(n=pn(t),un.set(t,n)),n}function pn(e,t){try{return new TextDecoder(e,t)}catch(t){throw TypeError(`Unsupported text encoding: ${e}`,{cause:t})}}function mn(e){let t=dn(e);switch(t){case`hex`:return new hn;case`base64`:return new yn(!1);case`base64url`:return new yn(!0);case`ascii`:return new bn;default:return pn(t,{ignoreBOM:!0})}}var hn=class{decode(e){let t=``;for(let n=0;n<e.length;n++)t+=gn[e[n]];return t}};let gn=(()=>{let e=Array(256);for(let t=0;t<256;t++)e[t]=t.toString(16).padStart(2,`0`);return e})(),_n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,vn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`;var yn=class{constructor(e){this._remainder=null,this._chars=e?vn:_n}decode(e,t){let n;if(this._remainder){let t=new Uint8Array(this._remainder.length+e.length);t.set(this._remainder),t.set(e,this._remainder.length),n=t}else n=e;if(t?.stream??!1){let e=n.length%3,t=n.length-e;return this._remainder=e>0?n.slice(t):null,t>0?this._encodeBytes(n,t):``}return this._remainder=null,n.length>0?this._encodeBytes(n,n.length):``}_encodeBytes(e,t){let n=this._chars,r=n===vn,i=``,a=0;for(;a+2<t;a+=3){let t=e[a],r=e[a+1],o=e[a+2];i+=n[t>>>2]+n[(t&3)<<4|r>>>4]+n[(r&15)<<2|o>>>6]+n[o&63]}let o=t-a;if(o===1){let t=e[a];i+=n[t>>>2]+n[(t&3)<<4],r||(i+=`==`)}else if(o===2){let t=e[a],o=e[a+1];i+=n[t>>>2]+n[(t&3)<<4|o>>>4]+n[(o&15)<<2],r||(i+=`=`)}return i}},bn=class{decode(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]&127);return t}};function xn(e){let t=``;for(let n=0;n<e.length;n++)t+=gn[e[n]];return t}function Sn(e,t){let n=t?vn:_n,r=``,i=0;for(;i+2<e.length;i+=3){let t=e[i],a=e[i+1],o=e[i+2];r+=n[t>>>2]+n[(t&3)<<4|a>>>4]+n[(a&15)<<2|o>>>6]+n[o&63]}let a=e.length-i;if(a===1){let a=e[i];r+=n[a>>>2]+n[(a&3)<<4],t||(r+=`==`)}else if(a===2){let a=e[i],o=e[i+1];r+=n[a>>>2]+n[(a&3)<<4|o>>>4]+n[(o&15)<<2],t||(r+=`=`)}return r}function Cn(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]&127);return t}function wn(e,t){let n=dn(t);switch(n){case`hex`:return xn(e);case`base64`:return Sn(e,!1);case`base64url`:return Sn(e,!0);case`ascii`:return Cn(e);default:return fn(n).decode(e)}}function Tn(e){return cn.encode(e)}function En(e,t){return fn(t).decode(e)}function Dn(e,t){let n=e.length;if(n===0)return new Uint8Array;if(n===1){let t=e[0];return t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if(t===void 0){let r=0;for(let t=0;t<n;t++)r+=e[t].length;t=r}let r=new Uint8Array(t),i=0;for(let t=0;t<n;t++){let n=e[t];r.set(n,i),i+=n.length}return r}function On(e){if(e instanceof Uint8Array)return e;if(typeof e==`string`)return cn.encode(e);if(e instanceof ArrayBuffer||Array.isArray(e))return new Uint8Array(e);throw TypeError(`Expected Uint8Array, got ${typeof e}`)}function kn(e){let t=globalThis.Buffer;return t?t.from(e.buffer,e.byteOffset,e.byteLength):e}async function*An(e){let t=e.getReader();try{for(;;){let e=await t.read();if(e.done)return;e.value!==void 0&&e.value!==null&&(yield e.value)}}finally{try{await t.cancel?.()}catch{}try{t.releaseLock?.()}catch{}}}function jn(e){return e?16:65536}var Mn=class extends n{constructor(e,t){super(e,t),this.name=`StreamError`}},Nn=class extends Mn{constructor(e,t,n){super(`Cannot ${e}: ${t}`,n),this.operation=e,this.state=t,this.name=`StreamStateError`}},Pn=class extends Mn{constructor(e,t,n){super(`Expected ${e}, got ${t}`,n),this.expectedType=e,this.actualType=t,this.name=`StreamTypeError`}};let Fn=e=>Array.isArray(e);var In=class e{constructor(){this.__excelts_stream=!0,this._listeners=new Map,this._maxListeners=e.defaultMaxListeners}static{this.defaultMaxListeners=10}addListener(e,t){return this.on(e,t)}_listenerCount(e){return e?Fn(e)?e.length:1:0}_hasListeners(e){return this._listenerCount(this._listeners.get(e))>0}on(e,t){e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t);let n=this._listeners.get(e);if(this._maxListeners>0){let t=this._listenerCount(n);t>=this._maxListeners&&console?.warn?.(`MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${t+1} ${String(e)} listeners added. Use emitter.setMaxListeners() to increase limit`)}return n?Fn(n)?n.push(t):this._listeners.set(e,[n,t]):this._listeners.set(e,t),this}prependListener(e,t){e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t);let n=this._listeners.get(e);return n?Fn(n)?n.unshift(t):this._listeners.set(e,[t,n]):this._listeners.set(e,t),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.on(e,n)}prependOnceListener(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.prependListener(e,n)}removeListener(e,t){return this.off(e,t)}off(e,t){let n=this._listeners.get(e);if(!n)return this;if(!Fn(n))return(n===t||n.listener===t)&&(this._listeners.delete(e),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t)),this;let r=n;if(r.length===0)return this._listeners.delete(e),this;let i=r.lastIndexOf(t);if(i!==-1)r.splice(i,1);else for(let e=r.length-1;e>=0;e--)if(r[e].listener===t){r.splice(e,1);break}return r.length===0?this._listeners.delete(e):r.length===1&&this._listeners.set(e,r[0]),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t),this}emit(e,...t){let n=this._listeners.get(e);if(!n){if(e===`error`){let e=t[0];if(e instanceof Error)throw e;let n=`Unhandled error.${e===void 0?` (undefined)`:` (${e})`}`;throw Error(n)}return!1}if(!Fn(n))return n.apply(this,t),!0;let r=n,i=r.length;if(i===0){if(e===`error`){let e=t[0];if(e instanceof Error)throw e;let n=`Unhandled error.${e===void 0?` (undefined)`:` (${e})`}`;throw Error(n)}return!1}if(i===1)return r[0].apply(this,t),!0;let a=r.slice();for(let e=0;e<a.length;e++)a[e].apply(this,t);return!0}removeAllListeners(e){if(e!==void 0){if(e!==`removeListener`&&this._hasListeners(`removeListener`)){let t=this._listeners.get(e);if(t){let n=Fn(t)?t.slice():[t];this._listeners.delete(e);for(let t of n){let n=t.listener??t;this.emit(`removeListener`,e,n)}return this}}this._listeners.delete(e)}else{if(this._hasListeners(`removeListener`)){let e=[...this._listeners.keys()];for(let t of e)if(t!==`removeListener`){let e=this._listeners.get(t);if(e){let n=Fn(e)?e.slice():[e];this._listeners.delete(t);for(let e of n){let n=e.listener??e;this.emit(`removeListener`,t,n)}}}}this._listeners.clear()}return this}listenerCount(e){return this._listenerCount(this._listeners.get(e))}listeners(e){let t=this._listeners.get(e);return t?(Fn(t)?t:[t]).map(e=>e.listener??e):[]}rawListeners(e){let t=this._listeners.get(e);return t?Fn(t)?t.slice():[t]:[]}eventNames(){return[...this._listeners.keys()]}setMaxListeners(e){return this._maxListeners=e,this}getMaxListeners(){return this._maxListeners}};In.prototype.addListener=In.prototype.on,In.prototype.removeListener=In.prototype.off;function Ln(e,t){let n=(t??`utf-8`).trim().toLowerCase();switch(n){case``:case`utf8`:case`utf-8`:return cn.encode(e);case`latin1`:case`binary`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}case`ascii`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&127;return t}case`hex`:{let t=e.length>>>1,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=parseInt(e.substring(r*2,r*2+2),16);return n}case`base64`:{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}case`base64url`:{let t=e.replace(/-/g,`+`).replace(/_/g,`/`);for(;t.length%4!=0;)t+=`=`;let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}case`utf16le`:case`utf-16le`:case`ucs2`:case`ucs-2`:{let t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>>8&255}return t}default:throw Rn(n)}}function Rn(e){let t=TypeError(`Unknown encoding: ${e}`);return t.code=`ERR_UNKNOWN_ENCODING`,t}function zn(e,t,n){return{chunk:typeof e==`function`?void 0:e,encoding:typeof t==`string`?t:void 0,cb:typeof e==`function`?e:typeof t==`function`?t:n}}let Bn=0;function w(e){queueMicrotask(()=>{Bn++;try{e()}finally{Bn--}})}function Vn(){return Bn>0}let Hn=null;function Un(){return Hn}function Wn(e){Hn=e}var Gn=class{constructor(e){this._items=[],this._index=0,this._front=[],this._byteSize=0,this._objectMode=e}_chunkSize(e){return e instanceof Uint8Array?e.byteLength:1}get length(){return this._front.length+(this._items.length-this._index)}get byteSize(){return this._byteSize}push(e){this._items.push(e),this._objectMode||(this._byteSize+=this._chunkSize(e))}shift(){let e;return this._front.length>0?e=this._front.pop():(e=this._items[this._index++],this._index===this._items.length?(this._items.length=0,this._index=0):this._index>1024&&this._index*2>this._items.length&&(this._items=this._items.slice(this._index),this._index=0)),this._objectMode||(this._byteSize-=this._chunkSize(e)),e}unshift(e){this._index===0?this._front.push(e):(this._index--,this._items[this._index]=e),this._objectMode||(this._byteSize+=this._chunkSize(e))}peek(){let e=this._front.length;return e>0?this._front[e-1]:this._index<this._items.length?this._items[this._index]:null}toArray(){let e=this._front.length,t=this._items.length-this._index,n=Array(e+t);for(let t=0;t<e;t++)n[t]=this._front[e-1-t];for(let r=0;r<t;r++)n[e+r]=this._items[this._index+r];return n}clear(){this._items.length=0,this._index=0,this._front.length=0,this._byteSize=0}consumeBytes(e){if(e===0)return new Uint8Array;let t=this.peek();if(t instanceof Uint8Array&&t.byteLength===e)return this.shift();if(t instanceof Uint8Array&&t.byteLength>e){this._shiftFrontChunk();let n=t.subarray(0,e),r=t.subarray(e);return this.unshift(r),n}let n=new Uint8Array(e),r=0;for(;r<e;){let t=this.shift();if(t instanceof Uint8Array){let i=e-r;t.byteLength<=i?(n.set(t,r),r+=t.byteLength):(n.set(t.subarray(0,i),r),this.unshift(t.subarray(i)),r+=i)}}return n}consumeAll(){let e=this._front.length,t=e+(this._items.length-this._index);if(t===0)return new Uint8Array;if(t===1)return this.shift();let n=this._byteSize,r=new Uint8Array(n),i=0;for(let t=e-1;t>=0;t--){let e=this._front[t];e instanceof Uint8Array&&(r.set(e,i),i+=e.byteLength)}for(let e=this._index;e<this._items.length;e++){let t=this._items[e];t instanceof Uint8Array&&(r.set(t,i),i+=t.byteLength)}return this.clear(),r}_shiftFrontChunk(){return this.shift()}};let Kn=(e,t,n)=>{typeof e.off==`function`?e.off(t,n):typeof e.removeListener==`function`&&e.removeListener(t,n)},qn=(e,t,n,r)=>(r?.once?typeof e.once==`function`&&e.once(t,n):typeof e.on==`function`&&e.on(t,n),()=>Kn(e,t,n)),Jn=()=>{let e=[];return{add:(t,n,r)=>{e.push(qn(t,n,r))},once:(t,n,r)=>{e.push(qn(t,n,r,{once:!0}))},cleanup:()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}};var Yn=class{constructor(e){this._source=e,this._destinations=[],this._listeners=new Map,this._sourceOverride=null}setSource(e){this._sourceOverride=e}get _emitSource(){return this._sourceOverride??this._source}pipe(e,t){let n=e,r=n,i=typeof n?.write==`function`,a=typeof n?.end==`function`,o=typeof r?.on==`function`,s=typeof r?.once==`function`,c=typeof r?.off==`function`;if(!i||!a||!s&&!o||!c&&!r?.removeListener)throw new Pn(`Writable`,typeof n);this._destinations.push(n);let l,u=()=>{l&&=(Kn(r,`drain`,l),void 0)},d=e=>{if(!n.write(e)&&(this._source.pause(),!l)){l=()=>{u(),this._source.resume()},r.on(`drain`,l);let e=this._listeners.get(n);e&&(e.drain=l)}},f=t?.end===!1?void 0:()=>{n.end()},p=()=>{this.unpipe(n)},m=typeof r.once==`function`?`once`:`on`;return r[m](`close`,p),r[m](`finish`,p),this._listeners.set(n,{data:d,end:f,destClose:p,destFinish:p,eventTarget:r}),this._source.on(`data`,d),f&&this._source.once(`end`,f),r.emit?.(`pipe`,this._emitSource),this._source.resume(),e}unpipe(e){if(e){let t=this._destinations.indexOf(e);t!==-1&&(this._destinations.splice(t,1),this._removeListeners(e),this._destinations.length===0&&this._source.pause())}else{let e=this._destinations.length>0;for(let e of this._destinations)this._removeListeners(e);this._destinations=[],e&&this._source.pause()}}_removeListeners(e){let t=this._listeners.get(e);t&&(this._source.off(`data`,t.data),t.end&&this._source.off(`end`,t.end),t.drain&&Kn(t.eventTarget,`drain`,t.drain),t.destClose&&Kn(t.eventTarget,`close`,t.destClose),t.destFinish&&Kn(t.eventTarget,`finish`,t.destFinish),t.eventTarget.emit?.(`unpipe`,this._emitSource),this._listeners.delete(e))}};function Xn(e){return wn(this,e??`utf-8`)}var T=class e extends In{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.on==`function`&&`readableFlowing`in t}constructor(e){super(),this._reader=null,this._reading=!1,this._ended=!1,this._endEmitted=!1,this._destroyed=!1,this._internalDestroy=!1,this._errored=null,this._closed=!1,this._flowing=!1,this._resumeScheduled=!1,this._hasFlowed=!1,this._encoding=null,this._decoder=null,this._didRead=!1,this._pushMode=!1,this._webStreamMode=!1,this._hasReadImpl=!1,this._constructed=!0,this._asyncIterState=null,this.__excelts_stream=!0,this._objectMode=e?.objectMode??!1,this._highWaterMark=e?.highWaterMark??jn(this._objectMode),this._buf=new Gn(this._objectMode),this._pipes=new Yn(this),this._autoDestroy=e?.autoDestroy??!0,this._emitClose=e?.emitClose??!0,e?.read?(this._read=e.read.bind(this),this._hasReadImpl=!0,this._pushMode=!0):this._hasSubclassRead()&&(this._hasReadImpl=!0,this._pushMode=!0),e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this)),e?.stream?(this._stream=e.stream,this._webStreamMode=!0):this._stream=null,e?.encoding&&this.setEncoding(e.encoding),e?.signal&&this._setupAbortSignal(e.signal),this._maybeConstruct()}_maybeConstruct(){(this._constructFunc||this._hasSubclassConstruct())&&(this._constructed=!1,w(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){this.destroy(e);return}this._constructed=!0,this._hasReadImpl&&this._flowing&&!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)})}))}_hasSubclassConstruct(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}_hasSubclassRead(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_read`))return!0;t=Object.getPrototypeOf(t)}return!1}_setupAbortSignal(e){if(e.aborted){this.destroy(i(e.reason));return}let t=()=>{r(),this.destroy(i(e.reason))},n=()=>{r()},r=()=>{e.removeEventListener(`abort`,t),this.off(`close`,n),this.off(`end`,n),this.off(`error`,n)};e.addEventListener(`abort`,t,{once:!0}),this.on(`close`,n),this.on(`end`,n),this.on(`error`,n)}static from(t,n){if(t&&typeof t.getReader==`function`)return e.fromWeb(t,n);if(typeof Blob<`u`&&t instanceof Blob)return e.fromWeb(t.stream(),n);if(t==null||typeof t!=`object`&&typeof t!=`string`){let e=TypeError(`The "iterable" argument must be an instance of Iterable. Received type ${typeof t} (${String(t)})`);throw e.code=`ERR_INVALID_ARG_TYPE`,e}let r=typeof t[Symbol.iterator]==`function`,i=typeof t[Symbol.asyncIterator]==`function`;if(!r&&!i&&typeof t!=`string`){let e=t?.constructor?.name??`Object`,n=TypeError(`The "iterable" argument must be an instance of Iterable. Received an instance of ${e}`);throw n.code=`ERR_INVALID_ARG_TYPE`,n}let a=new e({...n,objectMode:n?.objectMode??!0}),o=t;return rr(a,nr(typeof o==`string`?[o]:o)),a}static isDisturbed(e){return e._didRead||(e._destroyed||e._errored!==null)&&!e._endEmitted}static isReadable(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.read==`function`?t.destroyed||t._destroyed||t.readableEnded||t._endEmitted?!1:t.readable!==!1:null}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e._webStream}static wrap(t,n){return new e({objectMode:t.readableObjectMode??t.objectMode??!0,...n,destroy(e,n){typeof t.destroy==`function`&&t.destroy(e??void 0),n(e)}}).wrap(t)}push(e,t){if(this._destroyed)return!1;if(this._pushMode=!0,e!==null&&typeof e==`string`&&!this._objectMode){let n=Ln(e,t||`utf8`);n.toString=Xn,e=n}if(this._ended&&e!==null){let e=Error(`stream.push() after EOF`);return e.code=`ERR_STREAM_PUSH_AFTER_EOF`,w(()=>this.emit(`error`,e)),!1}if(e===null)return this._ended?!1:(this._ended=!0,this._buf.length===0&&w(()=>this._emitEndOnce()),!1);if(!this._objectMode&&(typeof e==`string`?e.length:e?.byteLength??e?.length??0)===0)return!0;if(this._flowing)return this._buf.length>0?(this._buf.push(e),this._objectMode?this._buf.length<this._highWaterMark:this._buf.byteSize<this._highWaterMark):(this._didRead=!0,this.emit(`data`,this._applyEncoding(e)),this._flowing?(this._hasReadImpl&&!this._ended&&w(()=>{this._flowing&&!this._ended&&!this._destroyed&&(this._callRead(this._highWaterMark),this._ended&&this._buf.length===0&&this._emitEndOnce())}),!0):!1);{let t=this._buf.length===0;return this._buf.push(e),t&&w(()=>this.emit(`readable`)),this._objectMode?this._buf.length<this._highWaterMark:this._buf.byteSize<this._highWaterMark}}_emitEndOnce(){if(this._endEmitted||this._destroyed||this._buf.length>0)return;let e=this._flushDecoder();e&&this.emit(`data`,e),this._endEmitted=!0,this.emit(`end`),this._autoDestroy&&this.destroy()}unshift(e,t){if(this._destroyed)return;if(e===null){this._ended||(this._ended=!0,this._buf.length===0&&w(()=>this._emitEndOnce()));return}if(this._endEmitted){let e=Error(`stream.unshift() after end event`);e.code=`ERR_STREAM_UNSHIFT_AFTER_END_EVENT`,w(()=>this.emit(`error`,e));return}if(typeof e==`string`&&!this._objectMode){let n=Ln(e,t||`utf8`);n.toString=Xn,e=n}let n=this._buf.length===0;this._buf.unshift(e),this._flowing?w(()=>{for(;this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}this._ended&&this._buf.length===0&&this._emitEndOnce()}):n&&w(()=>this.emit(`readable`))}_callRead(e){try{this._read(e)}catch(e){let t=e instanceof Error?e:Error(String(e));this._internalDestroy=!0,this.destroy(t)}}read(e){this._didRead=!0;let t;if(e!=null){if(t=parseInt(e,10),isNaN(t))t=void 0;else if(t<=0){if(t===0&&!this._ended&&!this._destroyed&&this._constructed){let e=this._objectMode?this._buf.length:this._buf.byteSize;(e<this._highWaterMark||e===0)&&this._callRead(this._highWaterMark)}return null}}if(this._buf.length===0)return!this._ended&&!this._destroyed&&this._constructed&&this._callRead(this._highWaterMark),null;if(this._objectMode){let e=this._buf.shift();return this._ended&&this._buf.length===0&&w(()=>this._emitEndOnce()),this._hasReadImpl&&!this._ended&&!this._destroyed&&this._constructed&&this._buf.length<this._highWaterMark&&w(()=>{!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)}),e}let n;if(t==null)n=this._applyEncoding(this._buf.shift());else if(this._buf.byteSize<t)if(this._ended)n=this._applyEncoding(this._buf.consumeAll());else return this._hasReadImpl&&this._constructed&&this._callRead(Math.max(t,this._highWaterMark)),null;else n=this._applyEncoding(this._buf.consumeBytes(t));return this._hasReadImpl&&!this._ended&&!this._destroyed&&this._buf.byteSize<this._highWaterMark&&w(()=>{!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)}),this._ended&&this._buf.length===0&&w(()=>this._emitEndOnce()),!this._flowing&&this._buf.length>0&&w(()=>this.emit(`readable`)),n}_flushDecoder(){if(!this._decoder)return null;let e=this._decoder.decode(new Uint8Array,{stream:!1});return this._decoder=null,e||null}setEncoding(e){return this._encoding=e,this._decoder=mn(e),this}_applyEncoding(e){return this._encoding&&e instanceof Uint8Array?(this._decoder||=mn(this._encoding),this._decoder.decode(e,{stream:!0})):e}wrap(e){let t=!1;return e.on(`data`,n=>{this.push(n)||(e.pause(),t=!0)}),e.on(`end`,()=>this.push(null)),e.on(`error`,e=>this.destroy(e)),e.on(`close`,()=>this.destroy()),this._hasReadImpl=!0,this._read=()=>{t&&(t=!1,e.resume())},this}pause(){return this._flowing?(this._flowing=!1,this.emit(`pause`)):this._hasFlowed=!0,this}resume(){return this._flowing||(this._flowing=!0,this._hasFlowed=!0,this._resumeScheduled||(this._resumeScheduled=!0,w(()=>{this._resumeScheduled=!1,this.emit(`resume`)}))),this._buf.length>0?w(()=>{for(;this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}if(this._ended&&this._buf.length===0&&this._emitEndOnce(),this._flowing&&this._buf.length===0&&this._webStreamMode&&!this._pushMode&&!this._ended&&!this._destroyed&&this._startReading(),this._hasReadImpl&&this._flowing&&!this._ended&&!this._destroyed&&this._constructed){let e=this._objectMode?this._buf.length:this._buf.byteSize;(e<this._highWaterMark||e===0)&&this._callRead(this._highWaterMark)}}):this._ended&&this._buf.length===0?w(()=>this._emitEndOnce()):this._webStreamMode&&!this._pushMode?this._startReading():this._hasReadImpl&&w(()=>{this._flowing&&!this._ended&&!this._destroyed&&this._constructed&&(this._callRead(this._highWaterMark),this._ended&&this._buf.length===0&&this._emitEndOnce())}),this}on(e,t){return super.on(e,t),e===`data`?this.resume():e===`readable`&&(this._hasFlowed=!0,this._flowing=!1,(this._buf.length>0||this._ended)&&w(()=>this.emit(`readable`))),this}isPaused(){return this.readableFlowing===!1}pipe(e,t){return this._pipes.pipe(e,t)}unpipe(e){return this._pipes.unpipe(e),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._readableOverride=void 0,this.unpipe(),this._reader){let e=this._reader;this._reader=null,e.cancel().catch(()=>{}).finally(()=>{try{e.releaseLock()}catch{}})}let t=e=>{let t=e||null;t&&(this._errored=t),this._closed=!0;let n=()=>{t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)},r=this._endEmitted||this._internalDestroy;this._internalDestroy=!1,Vn()&&!this._hasDestroyHook()&&r?n():w(n)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._destroyed=!1,this._closed=!1,this._errored=null}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}get _webStream(){if(this._stream)return this._stream;let e=this,t=!1,n=new ReadableStream({pull(n){return new Promise((r,i)=>{if(t)return r();let a=()=>{if(e._destroyed){if(e._errored){t=!0;try{n.error(e._errored)}catch{}return i(e._errored)}t=!0;try{n.close()}catch{}return r()}let o=e.read();if(o!==null){try{n.enqueue(o)}catch{}return r()}if(e._endEmitted){t=!0;try{n.close()}catch{}return r()}let s=()=>{d(),a()},c=()=>{d(),t=!0;try{n.close()}catch{}r()},l=e=>{d(),t=!0;try{n.error(e)}catch{}i(e)},u=()=>{if(d(),!t){t=!0;try{n.close()}catch{}}r()},d=()=>{e.off(`readable`,s),e.off(`end`,c),e.off(`error`,l),e.off(`close`,u)};e.once(`readable`,s),e.once(`end`,c),e.once(`error`,l),e.once(`close`,u)};a()})},cancel(){e.destroy()}});return this._stream=n,n}get readable(){return this._readableOverride===void 0?!this._destroyed&&!this._endEmitted:this._readableOverride}set readable(e){this._readableOverride=e}get readableEnded(){return this._endEmitted}get readableLength(){return this._objectMode?this._buf.length:this._buf.byteSize}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e}get errored(){return this._errored}get closed(){return this._closed}get readableFlowing(){return this._flowing?!0:this._hasFlowed?!1:null}set readableFlowing(e){e===!0?(this._flowing=!0,this._hasFlowed=!0):e===!1?(this._flowing=!1,this._hasFlowed=!0):(this._flowing=!1,this._hasFlowed=!1)}_setReadableFlowing(e){this.readableFlowing=e}get readableAborted(){return this._readableOverride===!1?!1:(this._destroyed||!!this._errored)&&!this._endEmitted}get readableDidRead(){return this._didRead}get readableEncoding(){return this._encoding}get readableObjectMode(){return this._objectMode}get readableHighWaterMark(){return this._highWaterMark}get readableBuffer(){return this._buf.toArray()}_releaseReader(){if(this._reader){let e=this._reader;this._reader=null;try{e.releaseLock()}catch{}}}async _startReading(){if(!(this._reading||this._destroyed||!this._flowing)){this._reading=!0;try{for(this._reader||=this._stream.getReader();this._flowing&&!this._destroyed&&!this._pushMode;){let{done:e,value:t}=await this._reader.read();if(this._pushMode){this._releaseReader();break}if(e){this._ended=!0,this._buf.length===0&&w(()=>this._emitEndOnce()),this._releaseReader();break}if(t!==void 0){let e=this._buf.length===0;for(this._buf.push(t),e&&w(()=>this.emit(`readable`));this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}if(!this._flowing)break}}}catch(e){this.emit(`error`,e),this._releaseReader()}finally{this._reading=!1}}}async*[Symbol.asyncIterator](){this._asyncIterState||=this._initAsyncIterState();let e=this._asyncIterState;e.activeCount++;try{for(;;){if(e.streamError)throw e.streamError;if(e.dataQueueIndex<e.dataQueue.length){let t=e.dataQueue[e.dataQueueIndex];e.dataQueue[e.dataQueueIndex]=void 0,e.dataQueueIndex++,e.queuedSize-=this._chunkSizeForBackpressure(t),e.dataQueueIndex>=1024&&e.dataQueueIndex*2>=e.dataQueue.length&&(e.dataQueue.splice(0,e.dataQueueIndex),e.dataQueueIndex=0),this._maybeResumeIterState(e),yield t;continue}if(e.done)break;let t=await new Promise((t,n)=>{e.resolverQueue.push({resolve:t,reject:n})});if(t===null)break;yield t}}finally{e.activeCount--,e.activeCount===0&&this._teardownAsyncIterState(),this._destroyed||this.destroy()}}_chunkSizeForBackpressure(e){return this._objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?e.length:1}_maybeResumeIterState(e){e.pausedByIterator&&e.queuedSize<this._highWaterMark&&!e.done&&!this._destroyed&&(e.pausedByIterator=!1,this.resume())}_initAsyncIterState(){let e=this._highWaterMark,t={dataQueue:[],dataQueueIndex:0,queuedSize:0,resolverQueue:[],done:!1,streamError:null,activeCount:0,listenersAttached:!1,pausedByIterator:!1,dataHandler:null,doneHandler:null,errorHandler:null};for(t.dataHandler=n=>{if(t.resolverQueue.length>0){let{resolve:e}=t.resolverQueue.shift();e(n);return}t.dataQueue.push(n),t.queuedSize+=this._chunkSizeForBackpressure(n),!t.pausedByIterator&&t.queuedSize>=e&&(t.pausedByIterator=!0,this.pause())},t.doneHandler=()=>{t.done=!0;for(let{resolve:e}of t.resolverQueue)e(null);t.resolverQueue.length=0},t.errorHandler=e=>{t.done=!0,t.streamError=e;for(let{reject:n}of t.resolverQueue)n(e);t.resolverQueue.length=0};this._buf.length>0;){let e=this._applyEncoding(this._buf.shift());t.dataQueue.push(e),t.queuedSize+=this._chunkSizeForBackpressure(e)}if(this._ended){let e=this._flushDecoder();e&&(t.dataQueue.push(e),t.queuedSize+=this._chunkSizeForBackpressure(e)),t.done=!0}else this.on(`data`,t.dataHandler),this.on(`end`,t.doneHandler),this.on(`error`,t.errorHandler),this.on(`close`,t.doneHandler),t.listenersAttached=!0,this.resume();return t}_teardownAsyncIterState(){let e=this._asyncIterState;e&&(e.listenersAttached&&(this.off(`data`,e.dataHandler),this.off(`end`,e.doneHandler),this.off(`error`,e.errorHandler),this.off(`close`,e.doneHandler)),this._asyncIterState=null)}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this._endEmitted?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}iterator(e){if(e?.destroyOnReturn??!0)return this[Symbol.asyncIterator]();let t=this,n=null,r=null,i=!1,a=null,s=()=>{if(!n)return;let e=t.read();if(e!==null){let t=n;n=null,r=null,t({done:!1,value:e})}},c=()=>{s()},l=()=>{if(i=!0,n){let e=n;n=null,r=null,e({done:!0,value:void 0})}},u=e=>{if(i=!0,a=e,r){let t=r;n=null,r=null,t(e)}};t.on(`readable`,c),t.on(`end`,l),t.on(`error`,u);let d=()=>{t.off(`readable`,c),t.off(`end`,l),t.off(`error`,u)};return{next:async()=>{if(a)throw o(a);let e=t.read();return e===null?i?(d(),{done:!0,value:void 0}):new Promise((e,t)=>{n=e,r=t,s()}):{done:!1,value:e}},return:async e=>(d(),{done:!0,value:e}),throw:async e=>(d(),t.destroy(e),{done:!0,value:void 0}),[Symbol.asyncIterator](){return this}}}map(t,n){let r=n?.signal;Zn(r);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0});return rr(c,(async function*(e){try{yield*tr(e,e=>t(e,{signal:s}),a,r)}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),r&&r.addEventListener(`abort`,()=>{c.destroy(i())},{once:!0}),c}filter(t,n){let r=n?.signal;Zn(r);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0}),l=Symbol(`skip`);return rr(c,(async function*(e){try{if(a<=1)for await(let n of e)Qn(r),await t(n,{signal:s})&&(yield n);else for await(let n of tr(e,async e=>await t(e,{signal:s})?e:l,a,r))n!==l&&(yield n)}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),r&&r.addEventListener(`abort`,()=>{c.destroy(i())},{once:!0}),c}async forEach(e,t){let n=t?.signal;Zn(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1)for await(let t of this)Qn(n),await e(t,{signal:a});else for await(let t of tr(this,async t=>{await e(t,{signal:a})},r,n));}finally{i.abort()}}async toArray(e){let t=e?.signal;Zn(t);let n=[];for await(let e of this)Qn(t),n.push(e);return n}async some(e,t){let n=t?.signal;Zn(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(Qn(n),await e(t,{signal:a}))return this.destroy(),!0}else for await(let t of tr(this,t=>e(t,{signal:a}),r,n))if(t)return this.destroy(),!0;return!1}finally{i.abort()}}async find(e,t){let n=t?.signal;Zn(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(Qn(n),await e(t,{signal:a}))return this.destroy(),t}else for await(let t of tr(this,async t=>({chunk:t,match:await e(t,{signal:a})}),r,n))if(t.match)return this.destroy(),t.chunk;return}finally{i.abort()}}async every(e,t){let n=t?.signal;Zn(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(Qn(n),!await e(t,{signal:a}))return this.destroy(),!1}else for await(let t of tr(this,t=>e(t,{signal:a}),r,n))if(!t)return this.destroy(),!1;return!0}finally{i.abort()}}flatMap(t,n){let r=n?.signal;Zn(r);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0});return rr(c,(async function*(e){try{if(a<=1)for await(let n of e){Qn(r);let e=await t(n,{signal:s});if(e&&typeof e[Symbol.asyncIterator]==`function`)for await(let t of e)yield t;else if(e&&typeof e[Symbol.iterator]==`function`)for(let t of e)yield t}else for await(let n of tr(e,async e=>{let n=await t(e,{signal:s}),r=[];if(n&&typeof n[Symbol.asyncIterator]==`function`)for await(let e of n)r.push(e);else if(n&&typeof n[Symbol.iterator]==`function`)for(let e of n)r.push(e);return r},a,r))for(let e of n)yield e}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),r&&r.addEventListener(`abort`,()=>{c.destroy(i())},{once:!0}),c}drop(t,n){let r=n?.signal;Zn(r),$n(t,`limit`);let a=new e({objectMode:!0});return rr(a,(async function*(e){let n=0;for await(let i of e)Qn(r),n>=t&&(yield i),n++})(this)),a.once(`close`,()=>{this.destroyed||this.destroy()}),r&&r.addEventListener(`abort`,()=>{a.destroy(i())},{once:!0}),a}take(t,n){let r=n?.signal;Zn(r),$n(t,`limit`);let a=new e({objectMode:!0});return rr(a,(async function*(e){let n=0;for await(let i of e){if(Qn(r),n>=t)break;yield i,n++}})(this)),a.once(`close`,()=>{this.destroyed||this.destroy()}),r&&r.addEventListener(`abort`,()=>{a.destroy(i())},{once:!0}),a}async reduce(e,t,n){let r=n?.signal;Zn(r);let i=new AbortController,a=i.signal,o,s=arguments.length>=2,c=!0;try{for await(let n of this){if(Qn(r),c&&!s){o=n,c=!1;continue}c&&=(o=t,!1),o=await e(o,n,{signal:a})}if(c&&!s)throw TypeError(`Reduce of an empty stream requires an initial value`);return c?t:o}finally{i.abort()}}asIndexedPairs(e){let t=0;return this.map(e=>[t++,e],e)}compose(t,n){if(typeof t==`function`){let n=new e({objectMode:!0});rr(n,t(this)),n.once(`close`,()=>{this.destroyed||this.destroy()});let r=Un();return r?r(n):n}let r=t;if(this.pipe(r),r._readable&&r._writable)return r;if(r._readable){let e=Un();return e?e(r._readable):r._readable}let i=Un();return i?i(r):r}};T.prototype.addListener=T.prototype.on,T.prototype._read=function(e){let t=Error(`The _read() method is not implemented`);throw t.code=`ERR_METHOD_NOT_IMPLEMENTED`,t};function Zn(e){if(e!==void 0&&!(e instanceof AbortSignal))throw TypeError(`options.signal must be an AbortSignal`)}function Qn(e){if(e?.aborted)throw i(e.reason)}function $n(e,t){if(typeof e!=`number`||Number.isNaN(e)||e<0||Math.floor(e)!==e)throw RangeError(`The value of "${t}" must be a non-negative integer. Received ${e}`)}let er=Symbol(`EOF`);async function*tr(e,t,n,r){if(n<=1){for await(let n of e)Qn(r),yield await t(n);return}let i=[],a=null,s=!1,c=e[Symbol.asyncIterator]();async function l(){let e=await c.next();return e.done?(s=!0,er):(Qn(r),t(e.value))}function u(){i.push(l().catch(e=>{throw a=e,e}))}try{for(;i.length<n&&!s&&!a;)Qn(r),u();for(;i.length>0;){Qn(r);let e=await i.shift();if(a)throw o(a);e!==er&&(yield e,!s&&!a&&u())}}finally{s||await c.return?.()}}function nr(e){return e&&typeof e[Symbol.asyncIterator]==`function`?e:(async function*(){for(let t of e)yield t})()}function rr(e,t){let n=t[Symbol.asyncIterator](),r=!1,i=!1;e._hasReadImpl=!0,e._read=function(){r||i||(r=!0,(async()=>{try{if(e.destroyed){if(!i){i=!0;let e=n.return?.();e&&typeof e.then==`function`&&e.catch(()=>{})}return}let{value:t,done:r}=await n.next();if(r){i=!0,e.push(null);return}e.push(t)}catch(t){e.destroy(t)}finally{r=!1}})())},e._pushMode=!0}function ir(e){return wn(this,e??`utf-8`)}var ar=class e extends In{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&`writableFinished`in t}constructor(e){if(super(),this._stream=null,this._writer=null,this._ended=!1,this._finished=!1,this._syncFinish=!1,this._destroyed=!1,this._errored=null,this._errorEmitted=!1,this._closed=!1,this._writableLength=0,this._needDrain=!1,this._corked=0,this._corkedChunks=[],this._defaultEncoding=`utf8`,this._ownsStream=!1,this._directWrite=!1,this._writeQueue=[],this._writing=!1,this._pendingEnd=null,this._constructed=!0,this._resolvedWritev=null,this.__excelts_stream=!0,this._objectMode=e?.objectMode??!1,this._highWaterMark=e?.highWaterMark??jn(this._objectMode),this._autoDestroy=e?.autoDestroy??!0,this._emitClose=e?.emitClose??!0,this._decodeStrings=e?.decodeStrings??!0,this._defaultEncoding=e?.defaultEncoding??`utf8`,e?.stream)this._stream=e.stream,this._ownsStream=!1,this._directWrite=!1;else{if(e?.write&&(this._writeFunc=e.write.bind(this)),e?.final)this._finalFunc=e.final.bind(this);else{let e=this._getSubclassFinal();e&&(this._finalFunc=e)}if(e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this)),e?.writev&&(this._writevFunc=e.writev.bind(this)),this._ownsStream=!0,this._writeFunc)this._directWrite=!0,this._stream=null;else{let t=e?.construct||this._hasSubclassConstruct(),n=this._getSubclassWrite();t&&n?(this._writeFunc=n,this._directWrite=!0,this._stream=null):(this._directWrite=!1,this._stream=new WritableStream({write:async e=>{this._write&&await new Promise((t,n)=>{this._write(e,`utf8`,e=>{e?n(e):t()})})},close:async()=>{if(this._finalFunc){let e=await new Promise(e=>{this._finalFunc(t=>{e(t??null)})});if(e){this._errored=e,this._errorEmitted=!0,this.emit(`error`,e),this._autoDestroy&&this.destroy(e);return}}this._finished=!0,this.emit(`finish`),this._autoDestroy&&this.destroy()},abort:e=>{this.emit(`error`,e)}}))}}e?.signal&&this._setupAbortSignal(e.signal),this._resolvedWritev=this._writevFunc??this._getWritevHook(),this._maybeConstruct()}_maybeConstruct(){(this._constructFunc||this._hasSubclassConstruct())&&(this._constructed=!1,w(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){this.destroy(e);return}if(this._constructed=!0,this._directWrite&&this._writeQueue.length>0&&!this._writing)this._writing=!0,this._drainWriteQueue();else if(this._pendingEnd&&!this._writing){let{cb:e}=this._pendingEnd;this._pendingEnd=null,this._doFinish(e)}})}))}_hasSubclassConstruct(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}_getSubclassWrite(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_write`))return t._write.bind(this);t=Object.getPrototypeOf(t)}return null}_getSubclassFinal(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_final`))return t._final.bind(this);t=Object.getPrototypeOf(t)}return null}_getWritevHook(){let t=Object.getPrototypeOf(this);return t._writev&&t._writev!==e.prototype._writev?t._writev.bind(this):null}_setupAbortSignal(e){if(e.aborted){this.destroy(i(e.reason));return}let t=()=>{r(),this.destroy(i(e.reason))},n=()=>{r()},r=()=>{e.removeEventListener(`abort`,t),this.off(`close`,n),this.off(`finish`,n),this.off(`error`,n)};e.addEventListener(`abort`,t,{once:!0}),this.on(`close`,n),this.on(`finish`,n),this.on(`error`,n)}setDefaultEncoding(e){return Ln(``,e),this._defaultEncoding=e,this}cork(){this._corked++}uncork(){if(this._corked>0&&this._corked--,this._corked===0){let e=this._corkedChunks;if(this._corkedChunks=[],e.length===0)return;for(let{chunk:t}of e)this._writableLength-=this._getChunkSize(t);let t=this._resolvedWritev;if(t&&e.length>1){let n=e.map(({chunk:e,encoding:t})=>({chunk:e,encoding:t})),r=n.reduce((e,{chunk:t})=>e+this._getChunkSize(t),0);this._writableLength+=r,this._writing=!0;try{t(n,t=>{if(this._writableLength-=r,this._writing=!1,t){this._destroyed||(this._errored=t,this.emit(`error`,t),this._autoDestroy&&this.destroy(t));for(let{callback:n}of e)n?.(t);return}this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,w(()=>this.emit(`drain`)));for(let{callback:t}of e)t?.(null);this._drainWriteQueue()})}catch(t){this._writableLength-=r,this._writing=!1;let n=t instanceof Error?t:Error(String(t));this._destroyed||(this._errored=n,this.emit(`error`,n),this._autoDestroy&&this.destroy(n));for(let{callback:t}of e)t?.(n)}}else for(let{chunk:t,encoding:n,callback:r}of e)this._doWrite(t,n,r)}}write(e,t,n){if(e===null){let e=TypeError(`May not write null values to stream`);throw e.code=`ERR_STREAM_NULL_VALUES`,e}if(this._destroyed||this._ended){let e=this._destroyed&&!this._ended,r=Error(e?`Cannot call write after a stream was destroyed`:`write after end`);r.code=e?`ERR_STREAM_DESTROYED`:`ERR_STREAM_WRITE_AFTER_END`;let i=typeof t==`function`?t:n;return this._errored||=r,i&&w(()=>i(r)),!this._destroyed&&!this._errorEmitted&&(this._errorEmitted=!0,w(()=>this.emit(`error`,r))),!1}let r=typeof t==`string`?t:this._defaultEncoding,i=typeof t==`function`?t:n;if(this._corked>0){let t=this._normalizeWriteChunk(e,r);this._corkedChunks.push({chunk:t.chunk,encoding:t.encoding,callback:i});let n=this._getChunkSize(t.chunk,t.encoding);this._writableLength+=n;let a=this._writableLength<this._highWaterMark;return a||(this._needDrain=!0),a}let a=this._normalizeWriteChunk(e,r),o=this._doWrite(a.chunk,a.encoding,i);return o||(this._needDrain=!0),o}_doWrite(e,t,n){let r=this._getChunkSize(e,t);return this._writableLength+=r,this._directWrite?this._writing||!this._constructed?this._writeQueue.push({chunk:e,chunkSize:r,encoding:t,callback:n}):(this._writing=!0,this._callWriteFunc(e,r,t,n)):this._getWriter().write(e).then(()=>{this._writableLength-=r,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,w(()=>this.emit(`drain`))),n?.(null)}).catch(e=>{this._writableLength-=r,this._destroyed||(this._errored=e,this._errorEmitted=!0,this.emit(`error`,e),this._autoDestroy&&this.destroy(e)),n?.(e)}),this._writableLength<this._highWaterMark}_callWriteFunc(e,t,n,r){try{let i=this._objectMode?void 0:n,a=!1,o=!0;this._writeFunc(e,i,e=>{if(a){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(a=!0,e){if(this._writableLength-=t,this._destroyed?r?.(e):(this._errored=e,this._errorEmitted=!0,o?w(()=>{r?.(e),this.emit(`error`,e),this._autoDestroy&&this.destroy(e)}):(r?.(e),this.emit(`error`,e),this._autoDestroy&&this.destroy(e))),this._writing=!1,this._flushWriteQueueOnError(e),this._pendingEnd){let{cb:t}=this._pendingEnd;this._pendingEnd=null,t?.(e)}return}this._writableLength-=t,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,w(()=>this.emit(`drain`))),r?.(null),this._drainWriteQueue()}),o=!1}catch(e){this._writableLength-=t;let n=e instanceof Error?e:Error(String(e));if(this._destroyed||(this._errored=n,this.emit(`error`,n),this._autoDestroy&&this.destroy(n)),r?.(n),this._writing=!1,this._flushWriteQueueOnError(n),this._pendingEnd){let{cb:e}=this._pendingEnd;this._pendingEnd=null,e?.(n)}}}_drainWriteQueue(){if(this._writeQueue.length===0){if(this._writing=!1,this._pendingEnd){let{cb:e}=this._pendingEnd;this._pendingEnd=null,this._doFinish(e)}return}let e=this._resolvedWritev;if(e&&this._writeQueue.length>1){let t=this._writeQueue;this._writeQueue=[];let n=0,r=Array(t.length);for(let e=0;e<t.length;e++){let i=t[e];r[e]={chunk:i.chunk,encoding:i.encoding},n+=i.chunkSize}try{e(r,e=>{if(e){this._writableLength-=n,this._destroyed||(this._errored=e,this._errorEmitted=!0,this.emit(`error`,e));for(let n of t)n.callback?.(e);this._writing=!1,this._flushWriteQueueOnError(e);return}this._writableLength-=n,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,w(()=>this.emit(`drain`)));for(let e of t)e.callback?.(null);this._drainWriteQueue()})}catch(e){this._writableLength-=n,this._writing=!1;let r=e instanceof Error?e:Error(String(e));this._destroyed||(this._errored=r,this.emit(`error`,r));for(let e of t)e.callback?.(r)}}else{let e=this._writeQueue.shift();this._callWriteFunc(e.chunk,e.chunkSize,e.encoding,e.callback)}}_flushWriteQueueOnError(e){let t=this._writeQueue;this._writeQueue=[];for(let n of t)this._writableLength-=n.chunkSize,n.callback?.(e)}_doFinish(e){if(this._finalFunc)this._finalFunc(t=>{if(t){this._errorEmitted=!0,this.emit(`error`,t),e&&(this._pendingEnd={cb:e}),this._autoDestroy&&!this._destroyed&&this.destroy(t);return}let n=()=>{if(this._destroyed){e?.();return}this._finished=!0,this.emit(`prefinish`),e?.(),this.emit(`finish`),this._autoDestroy&&this.destroy()};this._syncFinish?(this._syncFinish=!1,n()):w(n)});else{let t=()=>{if(this._destroyed){e?.();return}this._finished=!0,this.emit(`prefinish`),e?.(),this.emit(`finish`),this._autoDestroy&&this.destroy()};Vn()?t():w(t)}}_getChunkSize(e,t){return this._objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?sr(e,t):0}_normalizeWriteChunk(e,t){if(this._objectMode||typeof e!=`string`||!this._decodeStrings)return{chunk:e,encoding:t};let n=Ln(e,t);return n.toString=ir,{chunk:n,encoding:`buffer`}}end(e,t,n){if(this._ended){let{chunk:r,encoding:i,cb:a}=zn(e,t,n);if(r!==void 0)return this.write(r,i??this._defaultEncoding,e=>{a?.(e??null)}),this;if(this._finished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,w(()=>a(e))}else w(()=>a?.(null));return this}this._ended=!0,this._writableOverride=void 0;let{chunk:r,encoding:i,cb:a}=zn(e,t,n);if(this._corked>0&&(this._corked=1,this.uncork()),this._directWrite){if(r!==void 0){let e=this._normalizeWriteChunk(r,i??this._defaultEncoding);this._doWrite(e.chunk,e.encoding)}if(this._errored){let e=this._errored;return w(()=>a?.(e)),this}return this._writing||this._writeQueue.length>0?this._pendingEnd={cb:a}:this._doFinish(a),this}return(async()=>{try{let e=this._getWriter();if(r!==void 0){let{chunk:t}=this._normalizeWriteChunk(r,i??this._defaultEncoding);await e.write(t)}if(await e.close(),this._writer===e){this._writer=null;try{e.releaseLock()}catch{}}this._ownsStream||(this._finished=!0,this.emit(`finish`),this._autoDestroy&&this.destroy()),a&&a()}catch(e){this.emit(`error`,e)}})(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._writableOverride=void 0,e&&!this._errored&&(this._errored=e),this._writeQueue.length>0&&this._flushWriteQueueOnError(e??Error(`Cannot call write after a stream was destroyed`)),this._corkedChunks.length>0){let t=e??Error(`Cannot call write after a stream was destroyed`);for(let e of this._corkedChunks)e.callback?.(t);this._corkedChunks=[]}let t=this._pendingEnd?.cb;if(this._pendingEnd=null,this._writing=!1,this._writer){let t=this._writer;this._writer=null,t.abort(e).catch(()=>{}).finally(()=>{try{t.releaseLock()}catch{}})}let n=e=>{let n=e||null;n&&(this._errored=n),this._closed=!0;let r=()=>{n&&!this._errorEmitted&&(this._errorEmitted=!0,this.emit(`error`,n)),this._emitClose&&this.emit(`close`),t?.(n)};Vn()&&!this._hasDestroyHook()&&this._finished?r():w(r)};if(this._hasDestroyHook())try{this._destroy(e??null,n)}catch(e){n(e instanceof Error?e:Error(String(e)))}else n(e);return this}_destroy(e,t){t(e)}_undestroy(){this._destroyed=!1,this._closed=!1,this._errored=null,this._errorEmitted=!1}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this._finished?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}get _webStream(){return this._stream||=new WritableStream({write:e=>new Promise((t,n)=>{let r=this._objectMode?void 0:this._defaultEncoding;this._writeFunc(e,r,e=>{e?n(e):t()})}),close:async()=>{this._finalFunc&&await new Promise((e,t)=>{this._finalFunc(n=>{n?t(n):e()})})},abort:e=>{this.emit(`error`,e)}}),this._stream}get writable(){return this._writableOverride===void 0?!this._destroyed&&!this._ended:this._writableOverride}set writable(e){this._writableOverride=e}get writableEnded(){return this._ended}get writableFinished(){return this._finished}get writableLength(){return this._writableLength}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e}get errored(){return this._errored}get closed(){return this._closed}get writableNeedDrain(){return this._needDrain}get writableCorked(){return this._corked}get writableAborted(){return this._writableOverride===!1?!1:(this._destroyed||!!this._errored)&&!this._finished}get writableObjectMode(){return this._objectMode}get writableHighWaterMark(){return this._highWaterMark}get writableBuffer(){let e=this._corkedChunks.map(e=>e.chunk);for(let t of this._writeQueue)e.push(t.chunk);return e}pipe(){let e=new Nn(`pipe`,`not readable`);e.code=`ERR_STREAM_CANNOT_PIPE`,w(()=>this.emit(`error`,e))}_getWriter(){return this._writer||=this._webStream.getWriter(),this._writer}static isDisturbed(e){return e&&e._readable instanceof T?T.isDisturbed(e._readable):T.isDisturbed(e)}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e._webStream}};ar.prototype._writev=null,ar.prototype._write=function(e,t,n){let r=Error(`The _write() method is not implemented`);throw r.code=`ERR_METHOD_NOT_IMPLEMENTED`,r};function or(e){return e instanceof ar?e:e?.getWriter?new ar({stream:e}):e}function sr(e,t){let n=(t??`utf8`).toLowerCase();return n===`ascii`||n===`latin1`||n===`binary`?e.length:n===`utf16le`||n===`utf-16le`||n===`ucs2`?e.length*2:cr(e)}function cr(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<=127?t+=1:r<=2047?t+=2:r>=55296&&r<=56319?(t+=4,n++):t+=3}return t}var lr=class e extends In{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&`readableFlowing`in t&&`writableFinished`in t}static isDisturbed(e){return e&&e._readable instanceof T?T.isDisturbed(e._readable):T.isDisturbed(e)}static from(t){if(t instanceof e)return t;let n=(e,t)=>{let n=new ar({objectMode:t.readableObjectMode,write(e,n,r){t.push(e),r()},final(e){t.push(null),e()}}),r=qn(e,`error`,e=>{t.emit(`error`,e)});qn(e,`end`,r,{once:!0}),qn(e,`close`,r,{once:!0}),qn(n,`finish`,r,{once:!0}),e.pipe(n)};if(t instanceof Promise){let r=new e({objectMode:!0});return t.then(t=>{n(e.from(t),r)}).catch(e=>{r.destroy(e instanceof Error?e:Error(String(e)))}),r}if(typeof t==`string`){let r=T.from([t]),i=new e({objectMode:!0});return n(r,i),i}if(typeof Blob<`u`&&t instanceof Blob){let r=T.fromWeb(t.stream()),i=new e;return n(r,i),i}if(typeof t==`object`&&t&&`readable`in t&&`writable`in t){let r=t,i=new e({readableObjectMode:r.readable?.readableObjectMode,writableObjectMode:r.writable?.writableObjectMode,write:r.writable?(e,t,n)=>{r.writable.write(e,t,n)}:void 0,final:r.writable?e=>{r.writable.end(e)}:void 0,destroy:(e,t)=>{r.readable&&!r.readable.destroyed&&r.readable.destroy(e??void 0),r.writable&&!r.writable.destroyed&&r.writable.destroy(e??void 0),t(e)}});return r.readable&&n(r.readable,i),i}if(typeof t==`object`&&t&&typeof t.getReader==`function`&&typeof t.cancel==`function`){let r=T.fromWeb(t),i=new e({objectMode:r.readableObjectMode});return n(r,i),i}if(typeof t==`object`&&t&&typeof t.getWriter==`function`&&typeof t.close==`function`){let n=ar.fromWeb(t);return new e({objectMode:n.writableObjectMode,write(e,t,r){n.write(e,t,r)},final(e){n.end(e)},destroy(e,t){n.destroyed||n.destroy(e??void 0),t(e)}})}if(typeof t==`object`&&t&&(Symbol.asyncIterator in t||Symbol.iterator in t)){let r=T.from(t),i=new e({objectMode:r.readableObjectMode});return n(r,i),i}if(t instanceof T){let r=new e({objectMode:t.readableObjectMode});return n(t,r),r}if(t instanceof ar)return new e({objectMode:t.writableObjectMode,write(e,n,r){t.write(e,n,r)},final(e){t.end(e)}});throw new Pn(`Duplex-compatible source`,typeof t)}static fromWeb(t,n){let r=new e(n),i=new T({stream:t.readable,objectMode:r.readableObjectMode}),a=new ar({stream:t.writable,objectMode:r.writableObjectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return{readable:T.toWeb(e._readable),writable:ar.toWeb(e._writable)}}_getSubclassHook(t){let n=Object.getPrototypeOf(this);for(;n&&n!==e.prototype&&n!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(n,t)){let e=this[t];return typeof e==`function`?e.bind(this):void 0}n=Object.getPrototypeOf(n)}}constructor(e){super(),this._dataForwardingSetup=!1,this._destroyed=!1,this._errored=null,this._closed=!1,this._sideForwardingCleanup=null,this._constructed=!0,this.__excelts_stream=!0,this.allowHalfOpen=e?.allowHalfOpen??!0,this._emitClose=e?.emitClose??!0,this._autoDestroy=e?.autoDestroy??!0;let t=e?.objectMode??!1,n=e?.readableObjectMode??t,r=e?.writableObjectMode??t,i=e!=null&&Object.prototype.hasOwnProperty.call(e,`highWaterMark`),a=i?e.highWaterMark:e?.readableHighWaterMark,o=i?e.highWaterMark:e?.writableHighWaterMark;e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this));let s,c,l=this._hasConstructHook(),u=e?.read?e.read.bind(this):this._getSubclassHook(`_read`),d=e?.write?e.write.bind(this):this._getSubclassHook(`_write`),f=e?.writev?e.writev.bind(this):this._getSubclassHook(`_writev`),p=e?.final?e.final.bind(this):this._getSubclassHook(`_final`);this._readable=new T({highWaterMark:a,objectMode:n,read:u,encoding:e?.encoding,emitClose:!1,autoDestroy:!1,construct:l?e=>{s=e}:void 0}),this._writable=new ar({highWaterMark:o,objectMode:r,write:d,writev:f,final:p,decodeStrings:e?.decodeStrings,defaultEncoding:e?.defaultEncoding,emitClose:!1,autoDestroy:!1,construct:l?e=>{c=e}:void 0});let m=()=>{};this._readable.on(`error`,m),this._writable.on(`error`,m),this._setupSideForwarding(),e?.signal&&this._setupAbortSignal(e.signal),l&&(this._constructed=!1,w(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){s?.(e),c?.(e),this.destroy(e);return}this._constructed=!0,s?.(),c?.()})}))}_setupAbortSignal(e){if(e.aborted){this.destroy(i(e.reason));return}let t=()=>{this.destroy(i(e.reason))};e.addEventListener(`abort`,t,{once:!0}),this.once(`close`,()=>{e.removeEventListener(`abort`,t)})}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable._pipes?.setSource(this);let e=Jn(),t=!1,n=e=>{t||(t=!0,this.emit(`error`,e))},r=!1,i=!1,a=()=>{this._autoDestroy&&r&&i&&!this._destroyed&&this.destroy()};e.once(this._readable,`end`,()=>{this.emit(`end`),r=!0,this.allowHalfOpen||this._writable.end(),a()}),e.add(this._readable,`error`,n);let o=()=>{this.emit(`readable`)};In.prototype.on.call(this._readable,`readable`,o),e.add(this._readable,`pause`,()=>this.emit(`pause`)),e.add(this._readable,`resume`,()=>this.emit(`resume`)),e.add(this._writable,`error`,n),e.once(this._writable,`prefinish`,()=>this.emit(`prefinish`)),e.once(this._writable,`finish`,()=>{this.emit(`finish`),i=!0,a()}),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.add(this._writable,`pipe`,e=>this.emit(`pipe`,e)),e.add(this._writable,`unpipe`,e=>this.emit(`unpipe`,e)),e.once(this._writable,`finish`,()=>{!this.allowHalfOpen&&!this._readable.readableEnded&&this._readable.push(null)});let s=this._readable.destroy.bind(this._readable);this._readable.destroy=e=>{let t=s(e);return this._destroyed||this.destroy(e),t},this._sideForwardingCleanup=()=>{e.cleanup(),this._readable.off(`readable`,o),this._readable.destroy=s}}on(e,t){return super.on(e,t),e===`data`&&!this._dataForwardingSetup?(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>this.emit(`data`,e))):e===`readable`&&this._readable._setReadableFlowing(!1),this}push(e,t){return this._readable.push(e,t)}unshift(e,t){this._readable.unshift(e,t)}read(e){return this._readable.read(e)}write(e,t,n){let r=typeof t==`string`?t:void 0,i=typeof t==`function`?t:n;return r===void 0?this._writable.write(e,i):this._writable.write(e,r,i)}end(e,t,n){let{chunk:r,encoding:i,cb:a}=zn(e,t,n);if(this._writable.writableEnded){if(r!==void 0)return this.write(r,i,e=>{a?.(e??null)}),this;if(this.writableFinished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,w(()=>a(e))}else a&&w(()=>a(null));return this}if(a){let e=!1,t=()=>{e||(e=!0,a())};this.once(`finish`,t),this.once(`close`,t)}if(r!==void 0){let e=e=>{e&&!this.destroyed&&this.destroy(e)};i===void 0?this._writable.write(r,e):this._writable.write(r,i,e)}return this._writable.end(),this}cork(){this._writable.cork()}uncork(){this._writable.uncork()}setEncoding(e){return this._readable.setEncoding(e),this}setDefaultEncoding(e){return this._writable.setDefaultEncoding(e),this}pipe(e,t){return this._readable.pipe(e,t),e}unpipe(e){return this._readable.unpipe(e),this}pause(){return this._readable.pause(),this}resume(){return this._readable.resume(),this}isPaused(){return this._readable.isPaused()}destroy(e){if(this._destroyed)return this;this._destroyed=!0,this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let t=e=>{let t=e||null;t&&(this._errored=t),this._closed=!0,this._readable.destroy(),this._writable.destroy();let n=()=>{t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)};Vn()&&!this._hasDestroyHook()&&this.readableEnded&&this.writableFinished?n():w(n)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._readable._undestroy(),this._writable._undestroy(),this._destroyed=!1,this._closed=!1,this._errored=null,this._setupSideForwarding()}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}_hasConstructHook(){if(this._constructFunc)return!0;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this.writableFinished?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}get readable(){return this._readable.readable}set readable(e){this._readable.readable=e}get writable(){return this._writable.writable}set writable(e){this._writable.writable=e}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e,this._readable.destroyed=e,this._writable.destroyed=e}get writableCorked(){return this._writable.writableCorked}get writableNeedDrain(){return this._writable.writableNeedDrain}get readableObjectMode(){return this._readable.readableObjectMode}get writableObjectMode(){return this._writable.writableObjectMode}get readableFlowing(){return this._readable.readableFlowing}get readableAborted(){return this._readable.readableAborted}get readableDidRead(){return this._readable.readableDidRead}get readableEncoding(){return this._readable.readableEncoding}get errored(){return this._errored??this._readable.errored??this._writable.errored}get closed(){return this._closed}get readableBuffer(){return this._readable.readableBuffer}get writableBuffer(){return this._writable.writableBuffer}wrap(e){return this._readable.wrap(e),this}iterator(e){return e?.destroyOnReturn===!1?this._readable.iterator(e):this._wrapAsyncIterator(this._readable[Symbol.asyncIterator]())}[Symbol.asyncIterator](){return this._wrapAsyncIterator(this._readable[Symbol.asyncIterator]())}_wrapAsyncIterator(e){let t=this;return{next(){return e.next()},async return(){let n=await e.return?.();return t.destroyed||t.destroy(),n??{value:void 0,done:!0}},async throw(n){let r=await e.throw?.(n);return t.destroyed||t.destroy(n instanceof Error?n:void 0),r??{value:void 0,done:!0}},[Symbol.asyncIterator](){return this}}}map(e,t){return this._readable.map(e,t)}filter(e,t){return this._readable.filter(e,t)}async forEach(e,t){return this._readable.forEach(e,t)}async toArray(e){return this._readable.toArray(e)}async some(e,t){return this._readable.some(e,t)}async find(e,t){return this._readable.find(e,t)}async every(e,t){return this._readable.every(e,t)}flatMap(e,t){return this._readable.flatMap(e,t)}drop(e,t){return this._readable.drop(e,t)}take(e,t){return this._readable.take(e,t)}async reduce(e,t,n){return arguments.length>=2?this._readable.reduce(e,t,n):this._readable.reduce(e)}compose(e,t){return this._readable.compose(e,t)}};lr.prototype.addListener=lr.prototype.on,lr.prototype._writev=null;var ur=class e extends In{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&typeof t._transform==`function`&&`readableFlowing`in t&&`writableFinished`in t}push(e,t){return this._readable.push(e,t)}constructor(t){super(),this._destroyed=!1,this._closed=!1,this._ended=!1,this._errored=null,this._dataForwardingSetup=!1,this._syncFinal=!1,this._endCalledFromSync=!1,this._endGeneration=0,this._endCallback=null,this._webStream=null,this._sideForwardingCleanup=null,this._afterTransformCallback=null,this.__excelts_stream=!0;let n=t?.objectMode??!1,r=t?.readableObjectMode??n,i=t?.writableObjectMode??n;this.allowHalfOpen=t?.allowHalfOpen??!0,this._emitClose=t?.emitClose??!0,this._autoDestroy=t?.autoDestroy??!0,this._transformImpl=t?.transform,this._flushImpl=t?.flush;let a=t!=null&&Object.prototype.hasOwnProperty.call(t,`highWaterMark`),o=a?t.highWaterMark:t?.readableHighWaterMark,s=a?t.highWaterMark:t?.writableHighWaterMark;t?.destroy&&(this._destroy=t.destroy.bind(this)),t?.construct&&(this._constructFunc=t.construct.bind(this));let c,l,u=this._hasConstructHook();this._readable=new T({highWaterMark:o,objectMode:r,encoding:t?.encoding,emitClose:!1,autoDestroy:!1,construct:u?e=>{c=e}:void 0}),this._readable._hasReadImpl=!0,this._readable._read=()=>{if(this._afterTransformCallback){let e=this._afterTransformCallback;this._afterTransformCallback=null,e(null)}},this._readable._pipes.setSource(this);let d=t?.write?(e,n,r)=>{t.write.call(this,e,n,r)}:(e,t,n)=>{let r=this._readable.readableLength,i=()=>{let e=this._readable.readableLength,t=this._readable.readableHighWaterMark;this._writable.writableEnded||r===e||e<t?n(null):this._afterTransformCallback=n},a=this._runTransformSync(e,t);a===void 0?i():a.then(()=>i(),e=>n(e))},f=t?.final?e=>{t.final.call(this,t=>{if(t){e(t);return}this._readable.push(null),e(null)})}:t=>{typeof this._final==`function`&&this._final!==e.prototype._final?this._final.call(this,e=>{if(e){t(e);return}t(null)}):this._hasSubclassFlush()||this._flushImpl?this._runFlush().then(()=>{this._readable.push(null),t(null)}).catch(e=>t(e)):this._syncFinal?(this._readable.push(null),this._readable._emitEndOnce(),t(null)):w(()=>{this._readable.push(null),t(null)})};this._writable=new ar({highWaterMark:s,objectMode:i,emitClose:!1,autoDestroy:!1,write:d,writev:t?.writev?.bind(this),final:f,decodeStrings:t?.decodeStrings,defaultEncoding:t?.defaultEncoding,construct:u?e=>{l=e}:void 0});let p=()=>{};this._readable.on(`error`,p),this._writable.on(`error`,p),this._setupSideForwarding(),t?.signal&&this._setupAbortSignal(t.signal),u&&w(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){c?.(e),l?.(e),this.destroy(e);return}c?.(),l?.()})})}_setupAbortSignal(e){if(e.aborted){this.destroy(i(e.reason));return}let t=()=>{this.destroy(i(e.reason))};e.addEventListener(`abort`,t,{once:!0}),this.once(`close`,()=>{e.removeEventListener(`abort`,t)})}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable._pipes?.setSource(this);let e=Jn(),t=!1,n=!1,r=()=>{this._autoDestroy&&t&&n&&!this._destroyed&&this.destroy()};e.once(this._readable,`end`,()=>{this.emit(`end`),t=!0,this.allowHalfOpen||this._writable.end(),r()}),e.add(this._readable,`error`,e=>this._emitErrorOnce(e));let i=()=>{this.emit(`readable`)};In.prototype.on.call(this._readable,`readable`,i),e.add(this._readable,`pause`,()=>this.emit(`pause`)),e.add(this._readable,`resume`,()=>this.emit(`resume`)),e.once(this._writable,`prefinish`,()=>this.emit(`prefinish`)),e.once(this._writable,`finish`,()=>{this.emit(`finish`),n=!0,r()}),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.add(this._writable,`error`,e=>this._emitErrorOnce(e)),e.once(this._writable,`finish`,()=>{!this.allowHalfOpen&&!this._readable.readableEnded&&this._readable.push(null)}),this._sideForwardingCleanup=()=>{e.cleanup(),this._readable.off(`readable`,i)}}_scheduleEnd(){if(this._destroyed||this._errored||this._writable.writableEnded)return;let t=++this._endGeneration;w(()=>{t===this._endGeneration&&(this._destroyed||this._errored||this._writable.writableEnded||(this._endCalledFromSync&&!this._hasSubclassFlush()&&!this._flushImpl&&!(typeof this._final==`function`&&this._final!==e.prototype._final)&&this._readable._pipes._destinations.length===0&&(this._syncFinal=!0,this._writable._syncFinish=!0),this._writable.end(),this._syncFinal=!1,this._writable._syncFinish=!1))})}_emitErrorOnce(e){if(this._errored)return;let t=e instanceof Error?e:Error(String(e));this._errored=t,this._destroyed||this.destroy(t)}_hasSubclassTransform(){if(this._isSubclassTransform!==void 0)return this._isSubclassTransform;if(this._transformImpl)return this._isSubclassTransform=!1,!1;let t=Object.getPrototypeOf(this);return this._isSubclassTransform=t._transform!==e.prototype._transform,this._isSubclassTransform}_hasSubclassFlush(){if(this._flushImpl)return!1;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_flush`))return!0;t=Object.getPrototypeOf(t)}return!1}_runTransformSync(e,t){if(this._destroyed||this._errored)return;if(this._hasSubclassTransform()){let n=!0,r=!1,i=null,a,s=!1,c=null,l=null;if(this._transform(e,t,(e,t)=>{if(s){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(s=!0,n){r=!0,i=e??null,a=t;return}if(e){l?.(e);return}t!==void 0&&this.push(t),c?.()}),n=!1,r){if(i)throw o(i);a!==void 0&&this.push(a);return}return new Promise((e,t)=>{c=e,l=t})}let n=this._transformImpl;if(!n){let n=!0,r=!1,i=null,a,s=null,c=null;if(this._transform(e,t,(e,t)=>{if(n){r=!0,i=e??null,a=t;return}if(e){c?.(e);return}t!==void 0&&this.push(t),s?.()}),n=!1,r){if(i)throw o(i);a!==void 0&&this.push(a);return}return new Promise((e,t)=>{s=e,c=t})}let r=!0,i=!1,a=null,s,c=!1,l=null,u=null,d=new Promise((e,t)=>{l=e,u=t});if(n.call(this,e,t,(e,t)=>{if(c){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(c=!0,r){i=!0,a=e??null,s=t;return}if(e){u?.(e);return}t!==void 0&&this.push(t),l?.()}),r=!1,i){if(a)throw o(a);s!==void 0&&this.push(s);return}return d}async _runFlush(){if(this._destroyed||this._errored)return;if(this._hasSubclassFlush()){await new Promise((e,t)=>{this._flush((n,r)=>{if(n){t(n);return}r!==void 0&&this.push(r),e()})});return}let e=this._flushImpl;e&&await new Promise((t,n)=>{e.call(this,(e,r)=>{if(e){n(e);return}r!==void 0&&this.push(r),t()})})}on(e,t){return super.on(e,t),e===`data`&&!this._dataForwardingSetup?(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>{this.emit(`data`,e)})):e===`readable`&&this._readable._setReadableFlowing(!1),this}write(e,t,n){let r=typeof t==`string`?t:void 0,i=typeof t==`function`?t:n;if(this._ended){let e=Error(`write after end`);return e.code=`ERR_STREAM_WRITE_AFTER_END`,w(()=>this.emit(`error`,e)),i&&w(()=>i(e)),!1}return r===void 0?this._writable.write(e,i):this._writable.write(e,r,i)}end(e,t,n){if(this._ended){let{chunk:r,encoding:i,cb:a}=zn(e,t,n);if(r!==void 0)return this.write(r,i,e=>{a?.(e??null)}),this;if(this.writableFinished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,w(()=>a(e))}else a&&w(()=>a(null));return this}let{chunk:r,encoding:i,cb:a}=zn(e,t,n);if(a&&(this._endCallback=a,this.once(`finish`,()=>{let e=this._endCallback;e&&(this._endCallback=null,e())})),r!==void 0){let e=e=>{e&&!this._destroyed&&this.destroy(e)};i===void 0?this._writable.write(r,e):this._writable.write(r,i,e)}return this._ended=!0,this._endCalledFromSync=!Vn(),this._scheduleEnd(),this}read(e){return this._readable.read(e)}pipe(e,t){return this._readable.pipe(e,t)}unpipe(e){return this._readable.unpipe(e),this}isPaused(){return this._readable.isPaused()}resume(){return this._readable.resume(),this}pause(){return this._readable.pause(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._endGeneration++,this._afterTransformCallback){let t=this._afterTransformCallback;this._afterTransformCallback=null,t(e??null)}this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let t=e=>{let t=e||null;this._readable.destroy(),this._writable.destroy();let n=this._endCallback;this._endCallback=null,this._closed=!0;let r=()=>{n&&n(),t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)};Vn()&&!this._hasDestroyHook()&&this.readableEnded&&this.writableFinished?r():w(r)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._readable._undestroy(),this._writable._undestroy(),this._destroyed=!1,this._closed=!1,this._errored=null,this._setupSideForwarding()}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}_hasConstructHook(){if(this._constructFunc)return!0;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this.writableFinished?t():n(Error(`Premature close`))};this.closed?r():this.once(`close`,r)})}_getWebStream(){if(this._webStream)return this._webStream;let e=this[Symbol.asyncIterator](),t=new ReadableStream({pull:async t=>{let{done:n,value:r}=await e.next();if(n){t.close();return}t.enqueue(r)},cancel:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}}),n=new WritableStream({write:e=>new Promise((t,n)=>{this.write(e,e=>{e?n(e):t()})}),close:()=>new Promise(e=>{this.end(()=>e())}),abort:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}});return this._webStream={readable:t,writable:n},this._webStream}get readable(){return this._readable.readable}set readable(e){this._readable.readable=e}get writable(){return this._writable.writable}set writable(e){this._writable.writable=e}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._ended||this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get readableObjectMode(){return this._readable.readableObjectMode}get readableFlowing(){return this._readable.readableFlowing}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e,this._readable.destroyed=e,this._writable.destroyed=e}cork(){this._writable.cork()}uncork(){this._writable.uncork()}setEncoding(e){return this._readable.setEncoding(e),this}setDefaultEncoding(e){return this._writable.setDefaultEncoding(e),this}unshift(e,t){this._readable.unshift(e,t)}wrap(e){return this._readable.wrap(e),this}iterator(e){return this._readable.iterator(e)}get writableCorked(){return this._writable.writableCorked}get writableNeedDrain(){return this._writable.writableNeedDrain}get writableObjectMode(){return this._writable.writableObjectMode}get readableAborted(){return this._readable.readableAborted}get readableDidRead(){return this._readable.readableDidRead}get readableEncoding(){return this._readable.readableEncoding}get errored(){return this._errored??this._readable.errored??this._writable.errored}get closed(){return this._closed}get readableBuffer(){return this._readable.readableBuffer}get writableBuffer(){return this._writable.writableBuffer}async*[Symbol.asyncIterator](){yield*this._readable[Symbol.asyncIterator]()}map(e,t){return this._readable.map(e,t)}filter(e,t){return this._readable.filter(e,t)}async forEach(e,t){return this._readable.forEach(e,t)}async toArray(e){return this._readable.toArray(e)}async some(e,t){return this._readable.some(e,t)}async find(e,t){return this._readable.find(e,t)}async every(e,t){return this._readable.every(e,t)}flatMap(e,t){return this._readable.flatMap(e,t)}drop(e,t){return this._readable.drop(e,t)}take(e,t){return this._readable.take(e,t)}async reduce(e,t,n){return arguments.length>=2?this._readable.reduce(e,t,n):this._readable.reduce(e)}compose(e,t){return this._readable.compose(e,t)}static isDisturbed(e){return e&&e._readable instanceof T?T.isDisturbed(e._readable):T.isDisturbed(e)}static from(e){return lr.from(e)}static fromWeb(t,n){let r=new e(n);r._webStream=t;let i=T.fromWeb(t.readable,{objectMode:n?.objectMode}),a=ar.fromWeb(t.writable,{objectMode:n?.objectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return e._getWebStream()}_transform(e,t,n){let r=Error(`The _transform() method is not implemented`);throw r.code=`ERR_METHOD_NOT_IMPLEMENTED`,r}_final(e){typeof this._flush==`function`&&!this.destroyed?this._flush((t,n)=>{if(t){e(t);return}n!=null&&this.push(n),this.push(null),e()}):(this.push(null),e())}};ur.prototype.addListener=ur.prototype.on,ur.prototype._writev=null;var dr=class extends ur{_transform(e,t,n){n(null,e)}};let fr=e=>!e||typeof e!=`object`||typeof e.pipe==`function`||typeof e.write==`function`||typeof e.end==`function`||typeof e.getReader==`function`||typeof e.getWriter==`function`?!1:Object.prototype.hasOwnProperty.call(e,`signal`)||Object.prototype.hasOwnProperty.call(e,`end`),pr=e=>`readableEnded`in e||`readable`in e||typeof e.read==`function`,mr=e=>`writableFinished`in e||`writable`in e||typeof e.write==`function`,hr=e=>{let t=!pr(e)||!!e.readableEnded,n=!mr(e)||!!e.writableFinished;return t&&n},gr=()=>{let e=Error(`Premature close`);return e.code=`ERR_STREAM_PREMATURE_CLOSE`,e.name=`Error [ERR_STREAM_PREMATURE_CLOSE]`,e},_r=(e,t,n)=>{let r=e;if(r.closed||r._closed){t();return}`_emitClose`in r&&`_autoDestroy`in r&&r._emitClose!==!1&&r._autoDestroy!==!1?n.once(e,`close`,()=>t()):t()},vr=e=>e instanceof T||e instanceof ar||e instanceof ur||e instanceof lr?e:sn(e)?ur.fromWeb(e):an(e)?T.fromWeb(e):on(e)?ar.fromWeb(e):e,yr=e=>typeof e==`function`&&!(e instanceof T)&&!(e instanceof ar),br=(e,t)=>{let n=t(e);return T.from(n)};function xr(...e){let t,n={},r,a=e[e.length-1];if(typeof a==`function`){r=a;let i=e[e.length-2];fr(i)?(n=i,t=e.slice(0,-2)):t=e.slice(0,-1)}else fr(a)?(n=a,t=e.slice(0,-1)):t=e;let o=new Promise((e,r)=>{if(t.length<2){r(Error(`Pipeline requires at least 2 streams`));return}let a=t.map(vr),o=[],s=[],c=a[0];o.push(c),s.push(c);for(let e=1;e<a.length;e++){let t=a[e];yr(t)?(c=br(c,t),o.push(c),s[s.length-1]=c):(o.push(t),s.push(t),c=t)}let l=s[0],u=s[s.length-1],d=s.slice(1,-1);for(let e of o)if(e.destroyed&&!hr(e)){r(gr());return}let f=!1,p=Jn(),m,h=t=>{if(!f){if(f=!0,m&&n.signal&&n.signal.removeEventListener(`abort`,m),t){let e=()=>{};for(let n of o)typeof n.on==`function`&&n.on(`error`,e),typeof n.destroy==`function`&&!n.destroyed&&n.destroy(t)}p.cleanup(),t?r(t):e()}};if(n.signal){if(n.signal.aborted){h(i(n.signal.reason));return}m=()=>h(i(n.signal.reason)),n.signal.addEventListener(`abort`,m)}c=l;for(let e of d)c.pipe(e),c=e;if(n.end!==!1)c.pipe(u);else{let e=!1,t=!1,n=()=>{t=!1,e&&typeof c.resume==`function`&&(e=!1,c.resume())};p.add(c,`data`,r=>{!u.write(r)&&!t&&(t=!0,!e&&typeof c.pause==`function`&&(e=!0,c.pause()),p.once(u,`drain`,n))}),p.once(c,`end`,()=>{_r(c,h,p)})}n.end!==!1&&p.once(u,`finish`,()=>{_r(u,h,p)});for(let e of o)p.once(e,`close`,()=>{f||hr(e)||h(gr())});for(let e of o)p.once(e,`error`,e=>h(e))});return r&&o.then(()=>r()).catch(e=>r(e)),o}function Sr(e,t,n){let r={},a;typeof t==`function`?a=t:(r=t??{},a=n);let o=new Promise((t,n)=>{let a=vr(e),o=!1,s=Jn(),c,l=()=>{s.cleanup(),c&&r.signal&&r.signal.removeEventListener(`abort`,c)},u=e=>{o||(o=!0,l(),e?n(e):t())};if(r.signal){if(r.signal.aborted){u(i(r.signal.reason));return}c=()=>u(i(r.signal.reason)),r.signal.addEventListener(`abort`,c)}let d=a;if(d.destroyed||d._destroyed){if(d.errored||d._errored)u(d.errored??d._errored);else{let e=`readableEnded`in d||`readable`in d||typeof d.read==`function`,t=`writableFinished`in d||`writable`in d||typeof d.write==`function`,n=r.readable!==!1&&e,i=r.writable!==!1&&t,a=!n||!!(d.readableEnded||d._endEmitted),o=!i||!!(d.writableFinished||d._finished);a&&o?u():u(gr())}return}let f=`readableEnded`in a||`readable`in a||typeof a.read==`function`,p=`writableFinished`in a||`writable`in a||typeof a.write==`function`,m=r.readable!==!1&&f,h=r.writable!==!1&&p,g=!m||!!a.readableEnded,_=!h||!!a.writableFinished,v=a,y=`_emitClose`in v&&`_autoDestroy`in v&&v._emitClose!==!1&&v._autoDestroy!==!1&&!v._closed,b=()=>{if(g&&_){if(y)return;u()}};if(g&&_&&(!y||a.closed)){u();return}h&&!_&&s.once(a,`finish`,()=>{_=!0,b()}),m&&!g&&s.once(a,`end`,()=>{g=!0,b()}),r.error!==!1&&s.once(a,`error`,e=>u(e)),s.once(a,`close`,()=>{let e=g||!!a.readableEnded,t=_||!!a.writableFinished;if(e&&t){g=e,_=t,u(a.errored??a._errored??void 0);return}let n=a.errored??a._errored;if(n){u(n);return}let r=Error(`Premature close`);r.code=`ERR_STREAM_PREMATURE_CLOSE`,r.name=`Error [ERR_STREAM_PREMATURE_CLOSE]`,u(r)})});return a&&o.then(()=>a()).catch(e=>a(e)),o}Wn(e=>lr.from(e));function Cr(e){return e.length<2}function wr(e){return e.length<2}var Tr=class extends ur{constructor(e={}){super({objectMode:e.objectMode!==!1}),this.parseErrorsSink=[],this.buffer=``,this._rowTransform=null,this._rowValidator=null,this.autoDetectDelimiter=!1,this.delimiterDetected=!1,this.chunkBuffer=[],this.totalRowsProcessed=0,this.isFirstChunk=!0,this.chunkAborted=!1,this.beforeFirstChunkApplied=!1,this.bomStripped=!1,this.toLineReached=!1,this.headersEmitted=!1,this.totalCharsProcessed=0,this.backpressure=!1,this.pendingCallback=null,this.options=e,this.chunkSize=e.chunkSize??1e3,this.decoder=new TextDecoder(e.encoding||`utf-8`);let t=e.delimiter??`,`;this.autoDetectDelimiter=t===``;let{config:n}=wt({options:e});this.parseConfig=n,this.parseState=Kt(n),this.scanner=Gt(Et(n)),e.rowTransform&&this.transform(e.rowTransform),e.validate&&this.validate(e.validate)}_read(e){if(this.backpressure&&this.pendingCallback){this.backpressure=!1;let e=this.pendingCallback;this.pendingCallback=null,e()}}transform(e){if(typeof e!=`function`)throw TypeError(`The transform should be a function`);return Cr(e)?this._rowTransform=(t,n)=>{try{n(null,e(t))}catch(e){n(e)}}:this._rowTransform=e,this}validate(e){if(typeof e!=`function`)throw TypeError(`The validate should be a function`);return wr(e)?this._rowValidator=(t,n)=>{try{let r=e(t);typeof r==`boolean`?n(null,r):n(null,r.isValid,r.reason)}catch(e){n(e)}}:this._rowValidator=e,this}_transform(e,t,n){if(this.chunkAborted||this.toLineReached){n();return}try{let t=typeof e==`string`?e:this.decoder.decode(e,{stream:!0});if(this.buffer+=t,!this.beforeFirstChunkApplied&&this.options.beforeFirstChunk){this.beforeFirstChunkApplied=!0;let e=this.options.beforeFirstChunk(this.buffer);typeof e==`string`&&(this.buffer=e)}if(this.bomStripped||=(this.buffer=g(this.buffer),!0),this.autoDetectDelimiter&&!this.delimiterDetected){let e=this.options.comment,t=!1,n=0,r=this.buffer.length;for(;n<r;){let i=n;for(;i<r&&this.buffer[i]!==`
37
+ `,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}}}return r&&(d.length>0||p>t)?{fields:d,quoted:f,endPos:p,complete:!0,needMore:!1,unterminatedQuote:m||void 0,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p,complete:!1,needMore:!r,resumePos:t,unterminatedQuote:m||void 0,rawStart:h,rawEnd:p}}function Gt(e){let t={...Lt,...e},n=Rt(),r=[],i=[];return{get config(){return t},scanRow(e,n=0,r=!1){return Wt(e,n,t,r)},feed(e){n.buffer+=e},nextRow(){if(n.position>=n.buffer.length)return null;let e=Wt(n.buffer,n.position,t,!1,r,i);if(e.needMore)return null;if(e.complete){e.raw=n.buffer.slice(e.rawStart,e.rawEnd),n.position=e.endPos;let t=n.position,r=n.buffer.length;return(t>65536||t>r/2&&t>4096)&&(n.buffer=n.buffer.slice(n.position),n.position=0),e}return null},flush(){if(n.position>=n.buffer.length)return null;let e=Wt(n.buffer,n.position,t,!0,r,i);return e.fields.length===0&&e.endPos===n.position?null:(e.raw=n.buffer.slice(e.rawStart,e.rawEnd),n.position=e.endPos,e)},reset(){n=Rt(),r.length=0,i.length=0},getBuffer(){return n.buffer.slice(n.position)}}}function Kt(e){let t={lineNumber:0,dataRowCount:0,skippedDataRows:0,truncated:!1,headerRow:null,originalHeaders:null,useHeaders:!1,headerRowProcessed:!1,renamedHeadersForMeta:null,currentRowStartLine:+!!e.infoOption,currentRowStartOffset:0,currentRowQuoted:[],currentRawRow:``},{headers:n,groupColumnsByName:r}=e;if(n===!0)t.useHeaders=!0;else if(Array.isArray(n)){let e=_t([],{headers:n,groupColumnsByName:r},null);e&&(t.headerRow=e.headers,t.originalHeaders=e.originalHeaders,t.renamedHeadersForMeta=e.renamedHeaders),t.useHeaders=!0,t.headerRowProcessed=!0}else typeof n==`function`&&(t.useHeaders=!0);return t}function qt(e,t,n,r,i){t&&(e.currentRowQuoted=[],e.currentRowStartLine=r,e.currentRowStartOffset=i),n&&(e.currentRawRow=``)}let Jt=Object.freeze(Array(256).fill(!1));function Yt(e){return e<=256?Jt:Array(e).fill(!1)}function Xt(e){return typeof e==`boolean`?{isValid:e,reason:`Validation failed`}:{isValid:e.isValid,reason:e.reason||`Validation failed`}}function Zt(e,t,n){return gt(e,null,t||!1,n)}function Qt(e){return e.length>0?e:void 0}function $t(e,t){return{delimiter:e.delimiter,linebreak:e.linebreak,aborted:!1,truncated:t.truncated,cursor:t.dataRowCount,fields:t.headerRow?Ct(t.headerRow):void 0,renamedHeaders:t.renamedHeadersForMeta}}function en(e,t){return t.trimFieldIsIdentity?e:e.map(t.trimField)}function*tn(e,t,n,r){if(e===``)return;let i=0;for(let{line:a,lineLengthWithEnding:o}of At(e,t.linebreakRegex)){if(n.lineNumber++,t.toLine!==void 0&&n.lineNumber>t.toLine){n.truncated=!0;break}if(n.lineNumber<=t.skipLines){i+=o;continue}if(a===``&&t.shouldSkipEmpty){i+=o;continue}if(t.maxRowBytes!==void 0&&Ie(a)>t.maxRowBytes)throw Error(`Row exceeds the maximum size of ${t.maxRowBytes} bytes`);t.infoOption&&(n.currentRowStartLine=n.lineNumber,n.currentRowStartOffset=i),t.rawOption&&(n.currentRawRow=a);let e=en(a.split(t.delimiter),t);if(t.infoOption&&(n.currentRowQuoted=Yt(e.length)),t.comment&&e[0]?.trimStart().startsWith(t.comment)){i+=o;continue}if(t.shouldSkipEmpty&&ye(e,t.shouldSkipEmpty)){i+=o;continue}let s=It(e,n,t,r,n.lineNumber);if(i+=o,s.stop){yield s;return}(!s.skipped||s.error)&&(yield s),qt(n,t.infoOption,t.rawOption,n.lineNumber+1,i)}}function*nn(e,t,n,r){let i=Et(t),a=e.length,o=0;for(t.infoOption&&(n.currentRowStartOffset=0);o<a;){let a=Wt(e,o,i,!0);if(a.fields.length===0&&a.endPos===o)break;let s=en(a.fields,t),c=n.lineNumber+1;{let t=a.rawStart,r=a.rawEnd,i=1;for(let n=t;n<r;n++){let t=e.charCodeAt(n);t===10?i++:t===13&&(n+1<r&&e.charCodeAt(n+1)===10&&n++,i++)}n.lineNumber+=i}if(t.toLine!==void 0&&n.lineNumber>t.toLine){n.truncated=!0;break}let l=a.rawEnd;if(n.lineNumber<=t.skipLines){o=a.endPos;continue}if(t.maxRowBytes!==void 0&&Ie(e.slice(a.rawStart,l))>t.maxRowBytes)throw Error(`Row exceeds the maximum size of ${t.maxRowBytes} bytes`);if(t.comment&&s[0]?.trimStart().startsWith(t.comment)){o=a.endPos;continue}if(t.shouldSkipEmpty&&ye(s,t.shouldSkipEmpty)){o=a.endPos;continue}t.infoOption&&(n.currentRowStartLine=c,n.currentRowStartOffset=a.rawStart,n.currentRowQuoted=a.quoted),t.rawOption&&(n.currentRawRow=e.slice(a.rawStart,l)),a.unterminatedQuote&&r.push({code:`MissingQuotes`,message:`Quoted field unterminated`,line:n.lineNumber});let u=It(s,n,t,r,n.lineNumber);if(u.stop){yield u;return}(!u.skipped||u.error)&&(yield u),o=a.endPos,t.infoOption&&(n.currentRowStartOffset=a.endPos)}}function rn(e,t={}){let{config:n,processedInput:r}=Tt(e,t),i=Kt(n),a=[],o=[],s=n.fastMode?tn(r,n,i,a):nn(r,n,i,a);if(!i.useHeaders){let e=[];for(let r of s){if(r.row&&!r.skipped){let i=r.row;if(t.rowTransform){let e=t.rowTransform(i);if(e==null)continue;i=e}if(t.validate){let{isValid:e,reason:n}=Xt(t.validate(i));if(!e){o.push({row:i,reason:n});continue}}(n.dynamicTyping||n.castDate)&&(i=Zt(i,n.dynamicTyping,n.castDate)),n.infoOption&&r.info?e.push({record:i,info:r.info}):e.push(i)}else r.row&&r.skipped&&r.error&&o.push({row:r.row,reason:r.reason||r.error.message});if(r.stop)break}let r=$t(n,i);return n.infoOption||t.validate?{headers:void 0,rows:e,invalidRows:Qt(o),errors:Qt(a),meta:r}:e}let c=[];for(let e of s){if(e.row&&!e.skipped){let r=Pt(e.row,i,n);if(e.extras&&e.extras.length>0&&(r._extra=e.extras),t.rowTransform){let e=t.rowTransform(r);if(e==null)continue;r=e}if(t.validate){let{isValid:n,reason:i}=Xt(t.validate(r));if(!n){o.push({row:e.row,reason:i});continue}}n.infoOption&&e.info?c.push({record:r,info:e.info}):c.push(r)}else e.row&&e.skipped&&e.error&&o.push({row:e.row,reason:e.reason||e.error.message});if(e.stop)break}let l=$t(n,i),{objname:u}=t;if(u&&i.headerRow){let e=Object.create(null);for(let t of c){let r=(n.infoOption?t.record:t)[u],i=r==null?``:String(r);i!==`__proto__`&&(e[i]=t)}return{headers:l.fields,rows:e,invalidRows:Qt(o),errors:Qt(a),meta:l}}return{headers:l.fields,rows:c,invalidRows:Qt(o),errors:Qt(a),meta:l}}function an(e){return!!e&&typeof e==`object`&&typeof e.getReader==`function`}function on(e){return!!e&&typeof e==`object`&&typeof e.getWriter==`function`}function sn(e){return!!e&&typeof e==`object`&&!!e.readable&&!!e.writable&&an(e.readable)&&on(e.writable)}let cn=new TextEncoder,ln=new TextDecoder(`utf-8`,{ignoreBOM:!0}),un=new Map;function dn(e){let t=(e??`utf-8`).trim().toLowerCase();return t===``||t===`utf8`||t===`utf-8`?`utf-8`:t===`utf16le`||t===`utf-16le`||t===`ucs2`||t===`ucs-2`?`utf-16le`:t===`binary`?`latin1`:t}function fn(e){let t=dn(e);if(t===`utf-8`)return ln;let n=un.get(t);return n||(n=pn(t),un.set(t,n)),n}function pn(e,t){try{return new TextDecoder(e,t)}catch(t){throw TypeError(`Unsupported text encoding: ${e}`,{cause:t})}}function mn(e){let t=dn(e);switch(t){case`hex`:return new hn;case`base64`:return new yn(!1);case`base64url`:return new yn(!0);case`ascii`:return new bn;default:return pn(t,{ignoreBOM:!0})}}var hn=class{decode(e){let t=``;for(let n=0;n<e.length;n++)t+=gn[e[n]];return t}};let gn=(()=>{let e=Array(256);for(let t=0;t<256;t++)e[t]=t.toString(16).padStart(2,`0`);return e})(),_n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,vn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`;var yn=class{constructor(e){this._remainder=null,this._chars=e?vn:_n}decode(e,t){let n;if(this._remainder){let t=new Uint8Array(this._remainder.length+e.length);t.set(this._remainder),t.set(e,this._remainder.length),n=t}else n=e;if(t?.stream??!1){let e=n.length%3,t=n.length-e;return this._remainder=e>0?n.slice(t):null,t>0?this._encodeBytes(n,t):``}return this._remainder=null,n.length>0?this._encodeBytes(n,n.length):``}_encodeBytes(e,t){let n=this._chars,r=n===vn,i=``,a=0;for(;a+2<t;a+=3){let t=e[a],r=e[a+1],o=e[a+2];i+=n[t>>>2]+n[(t&3)<<4|r>>>4]+n[(r&15)<<2|o>>>6]+n[o&63]}let o=t-a;if(o===1){let t=e[a];i+=n[t>>>2]+n[(t&3)<<4],r||(i+=`==`)}else if(o===2){let t=e[a],o=e[a+1];i+=n[t>>>2]+n[(t&3)<<4|o>>>4]+n[(o&15)<<2],r||(i+=`=`)}return i}},bn=class{decode(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]&127);return t}};function xn(e){let t=``;for(let n=0;n<e.length;n++)t+=gn[e[n]];return t}function Sn(e,t){let n=t?vn:_n,r=``,i=0;for(;i+2<e.length;i+=3){let t=e[i],a=e[i+1],o=e[i+2];r+=n[t>>>2]+n[(t&3)<<4|a>>>4]+n[(a&15)<<2|o>>>6]+n[o&63]}let a=e.length-i;if(a===1){let a=e[i];r+=n[a>>>2]+n[(a&3)<<4],t||(r+=`==`)}else if(a===2){let a=e[i],o=e[i+1];r+=n[a>>>2]+n[(a&3)<<4|o>>>4]+n[(o&15)<<2],t||(r+=`=`)}return r}function Cn(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]&127);return t}function wn(e,t){let n=dn(t);switch(n){case`hex`:return xn(e);case`base64`:return Sn(e,!1);case`base64url`:return Sn(e,!0);case`ascii`:return Cn(e);default:return fn(n).decode(e)}}function Tn(e){return cn.encode(e)}function En(e,t){return fn(t).decode(e)}function Dn(e,t){let n=e.length;if(n===0)return new Uint8Array;if(n===1){let t=e[0];return t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if(t===void 0){let r=0;for(let t=0;t<n;t++)r+=e[t].length;t=r}let r=new Uint8Array(t),i=0;for(let t=0;t<n;t++){let n=e[t];r.set(n,i),i+=n.length}return r}function On(e){if(e instanceof Uint8Array)return e;if(typeof e==`string`)return cn.encode(e);if(e instanceof ArrayBuffer||Array.isArray(e))return new Uint8Array(e);throw TypeError(`Expected Uint8Array, got ${typeof e}`)}function kn(e){let t=globalThis.Buffer;return t?t.from(e.buffer,e.byteOffset,e.byteLength):e}async function*An(e){let t=e.getReader();try{for(;;){let e=await t.read();if(e.done)return;e.value!==void 0&&e.value!==null&&(yield e.value)}}finally{try{await t.cancel?.()}catch{}try{t.releaseLock?.()}catch{}}}function jn(e){return e?16:65536}var Mn=class extends n{constructor(e,t){super(e,t),this.name=`StreamError`}},Nn=class extends Mn{constructor(e,t,n){super(`Cannot ${e}: ${t}`,n),this.operation=e,this.state=t,this.name=`StreamStateError`}},Pn=class extends Mn{constructor(e,t,n){super(`Expected ${e}, got ${t}`,n),this.expectedType=e,this.actualType=t,this.name=`StreamTypeError`}};let Fn=e=>Array.isArray(e);var In=class e{constructor(){this.__excelts_stream=!0,this._listeners=new Map,this._maxListeners=e.defaultMaxListeners}static{this.defaultMaxListeners=10}addListener(e,t){return this.on(e,t)}_listenerCount(e){return e?Fn(e)?e.length:1:0}_hasListeners(e){return this._listenerCount(this._listeners.get(e))>0}on(e,t){e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t);let n=this._listeners.get(e);if(this._maxListeners>0){let t=this._listenerCount(n);t>=this._maxListeners&&console?.warn?.(`MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${t+1} ${String(e)} listeners added. Use emitter.setMaxListeners() to increase limit`)}return n?Fn(n)?n.push(t):this._listeners.set(e,[n,t]):this._listeners.set(e,t),this}prependListener(e,t){e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t);let n=this._listeners.get(e);return n?Fn(n)?n.unshift(t):this._listeners.set(e,[t,n]):this._listeners.set(e,t),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.on(e,n)}prependOnceListener(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.prependListener(e,n)}removeListener(e,t){return this.off(e,t)}off(e,t){let n=this._listeners.get(e);if(!n)return this;if(!Fn(n))return(n===t||n.listener===t)&&(this._listeners.delete(e),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t)),this;let r=n;if(r.length===0)return this._listeners.delete(e),this;let i=r.lastIndexOf(t);if(i!==-1)r.splice(i,1);else for(let e=r.length-1;e>=0;e--)if(r[e].listener===t){r.splice(e,1);break}return r.length===0?this._listeners.delete(e):r.length===1&&this._listeners.set(e,r[0]),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t),this}emit(e,...t){let n=this._listeners.get(e);if(!n){if(e===`error`){let e=t[0];if(e instanceof Error)throw e;let n=`Unhandled error.${e===void 0?` (undefined)`:` (${e})`}`;throw Error(n)}return!1}if(!Fn(n))return n.apply(this,t),!0;let r=n,i=r.length;if(i===0){if(e===`error`){let e=t[0];if(e instanceof Error)throw e;let n=`Unhandled error.${e===void 0?` (undefined)`:` (${e})`}`;throw Error(n)}return!1}if(i===1)return r[0].apply(this,t),!0;let a=r.slice();for(let e=0;e<a.length;e++)a[e].apply(this,t);return!0}removeAllListeners(e){if(e!==void 0){if(e!==`removeListener`&&this._hasListeners(`removeListener`)){let t=this._listeners.get(e);if(t){let n=Fn(t)?t.slice():[t];this._listeners.delete(e);for(let t of n){let n=t.listener??t;this.emit(`removeListener`,e,n)}return this}}this._listeners.delete(e)}else{if(this._hasListeners(`removeListener`)){let e=[...this._listeners.keys()];for(let t of e)if(t!==`removeListener`){let e=this._listeners.get(t);if(e){let n=Fn(e)?e.slice():[e];this._listeners.delete(t);for(let e of n){let n=e.listener??e;this.emit(`removeListener`,t,n)}}}}this._listeners.clear()}return this}listenerCount(e){return this._listenerCount(this._listeners.get(e))}listeners(e){let t=this._listeners.get(e);return t?(Fn(t)?t:[t]).map(e=>e.listener??e):[]}rawListeners(e){let t=this._listeners.get(e);return t?Fn(t)?t.slice():[t]:[]}eventNames(){return[...this._listeners.keys()]}setMaxListeners(e){return this._maxListeners=e,this}getMaxListeners(){return this._maxListeners}};In.prototype.addListener=In.prototype.on,In.prototype.removeListener=In.prototype.off;function Ln(e,t){let n=(t??`utf-8`).trim().toLowerCase();switch(n){case``:case`utf8`:case`utf-8`:return cn.encode(e);case`latin1`:case`binary`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}case`ascii`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&127;return t}case`hex`:{let t=e.length>>>1,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=parseInt(e.substring(r*2,r*2+2),16);return n}case`base64`:{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}case`base64url`:{let t=e.replace(/-/g,`+`).replace(/_/g,`/`);for(;t.length%4!=0;)t+=`=`;let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}case`utf16le`:case`utf-16le`:case`ucs2`:case`ucs-2`:{let t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>>8&255}return t}default:throw Rn(n)}}function Rn(e){let t=TypeError(`Unknown encoding: ${e}`);return t.code=`ERR_UNKNOWN_ENCODING`,t}function zn(e,t,n){return{chunk:typeof e==`function`?void 0:e,encoding:typeof t==`string`?t:void 0,cb:typeof e==`function`?e:typeof t==`function`?t:n}}let Bn=0;function w(e){queueMicrotask(()=>{Bn++;try{e()}finally{Bn--}})}function Vn(){return Bn>0}let Hn=null;function Un(){return Hn}function Wn(e){Hn=e}var Gn=class{constructor(e){this._items=[],this._index=0,this._front=[],this._byteSize=0,this._objectMode=e}_chunkSize(e){return e instanceof Uint8Array?e.byteLength:1}get length(){return this._front.length+(this._items.length-this._index)}get byteSize(){return this._byteSize}push(e){this._items.push(e),this._objectMode||(this._byteSize+=this._chunkSize(e))}shift(){let e;return this._front.length>0?e=this._front.pop():(e=this._items[this._index++],this._index===this._items.length?(this._items.length=0,this._index=0):this._index>1024&&this._index*2>this._items.length&&(this._items=this._items.slice(this._index),this._index=0)),this._objectMode||(this._byteSize-=this._chunkSize(e)),e}unshift(e){this._index===0?this._front.push(e):(this._index--,this._items[this._index]=e),this._objectMode||(this._byteSize+=this._chunkSize(e))}peek(){let e=this._front.length;return e>0?this._front[e-1]:this._index<this._items.length?this._items[this._index]:null}toArray(){let e=this._front.length,t=this._items.length-this._index,n=Array(e+t);for(let t=0;t<e;t++)n[t]=this._front[e-1-t];for(let r=0;r<t;r++)n[e+r]=this._items[this._index+r];return n}clear(){this._items.length=0,this._index=0,this._front.length=0,this._byteSize=0}consumeBytes(e){if(e===0)return new Uint8Array;let t=this.peek();if(t instanceof Uint8Array&&t.byteLength===e)return this.shift();if(t instanceof Uint8Array&&t.byteLength>e){this._shiftFrontChunk();let n=t.subarray(0,e),r=t.subarray(e);return this.unshift(r),n}let n=new Uint8Array(e),r=0;for(;r<e;){let t=this.shift();if(t instanceof Uint8Array){let i=e-r;t.byteLength<=i?(n.set(t,r),r+=t.byteLength):(n.set(t.subarray(0,i),r),this.unshift(t.subarray(i)),r+=i)}}return n}consumeAll(){let e=this._front.length,t=e+(this._items.length-this._index);if(t===0)return new Uint8Array;if(t===1)return this.shift();let n=this._byteSize,r=new Uint8Array(n),i=0;for(let t=e-1;t>=0;t--){let e=this._front[t];e instanceof Uint8Array&&(r.set(e,i),i+=e.byteLength)}for(let e=this._index;e<this._items.length;e++){let t=this._items[e];t instanceof Uint8Array&&(r.set(t,i),i+=t.byteLength)}return this.clear(),r}_shiftFrontChunk(){return this.shift()}};let Kn=(e,t,n)=>{typeof e.off==`function`?e.off(t,n):typeof e.removeListener==`function`&&e.removeListener(t,n)},qn=(e,t,n,r)=>(r?.once?typeof e.once==`function`&&e.once(t,n):typeof e.on==`function`&&e.on(t,n),()=>Kn(e,t,n)),Jn=()=>{let e=[];return{add:(t,n,r)=>{e.push(qn(t,n,r))},once:(t,n,r)=>{e.push(qn(t,n,r,{once:!0}))},cleanup:()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}};var Yn=class{constructor(e){this._source=e,this._destinations=[],this._listeners=new Map,this._sourceOverride=null}setSource(e){this._sourceOverride=e}get _emitSource(){return this._sourceOverride??this._source}pipe(e,t){let n=e,r=n,i=typeof n?.write==`function`,a=typeof n?.end==`function`,o=typeof r?.on==`function`,s=typeof r?.once==`function`,c=typeof r?.off==`function`;if(!i||!a||!s&&!o||!c&&!r?.removeListener)throw new Pn(`Writable`,typeof n);this._destinations.push(n);let l,u=()=>{l&&=(Kn(r,`drain`,l),void 0)},d=e=>{if(!n.write(e)&&(this._source.pause(),!l)){l=()=>{u(),this._source.resume()},r.on(`drain`,l);let e=this._listeners.get(n);e&&(e.drain=l)}},f=t?.end===!1?void 0:()=>{n.end()},p=()=>{this.unpipe(n)},m=typeof r.once==`function`?`once`:`on`;return r[m](`close`,p),r[m](`finish`,p),this._listeners.set(n,{data:d,end:f,destClose:p,destFinish:p,eventTarget:r}),this._source.on(`data`,d),f&&this._source.once(`end`,f),r.emit?.(`pipe`,this._emitSource),this._source.resume(),e}unpipe(e){if(e){let t=this._destinations.indexOf(e);t!==-1&&(this._destinations.splice(t,1),this._removeListeners(e),this._destinations.length===0&&this._source.pause())}else{let e=this._destinations.length>0;for(let e of this._destinations)this._removeListeners(e);this._destinations=[],e&&this._source.pause()}}_removeListeners(e){let t=this._listeners.get(e);t&&(this._source.off(`data`,t.data),t.end&&this._source.off(`end`,t.end),t.drain&&Kn(t.eventTarget,`drain`,t.drain),t.destClose&&Kn(t.eventTarget,`close`,t.destClose),t.destFinish&&Kn(t.eventTarget,`finish`,t.destFinish),t.eventTarget.emit?.(`unpipe`,this._emitSource),this._listeners.delete(e))}};function Xn(e){return wn(this,e??`utf-8`)}var T=class e extends In{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.on==`function`&&`readableFlowing`in t}constructor(e){super(),this._reader=null,this._reading=!1,this._ended=!1,this._endEmitted=!1,this._destroyed=!1,this._internalDestroy=!1,this._errored=null,this._closed=!1,this._flowing=!1,this._resumeScheduled=!1,this._hasFlowed=!1,this._encoding=null,this._decoder=null,this._didRead=!1,this._pushMode=!1,this._webStreamMode=!1,this._hasReadImpl=!1,this._constructed=!0,this._asyncIterState=null,this.__excelts_stream=!0,this._objectMode=e?.objectMode??!1,this._highWaterMark=e?.highWaterMark??jn(this._objectMode),this._buf=new Gn(this._objectMode),this._pipes=new Yn(this),this._autoDestroy=e?.autoDestroy??!0,this._emitClose=e?.emitClose??!0,e?.read?(this._read=e.read.bind(this),this._hasReadImpl=!0,this._pushMode=!0):this._hasSubclassRead()&&(this._hasReadImpl=!0,this._pushMode=!0),e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this)),e?.stream?(this._stream=e.stream,this._webStreamMode=!0):this._stream=null,e?.encoding&&this.setEncoding(e.encoding),e?.signal&&this._setupAbortSignal(e.signal),this._maybeConstruct()}_maybeConstruct(){(this._constructFunc||this._hasSubclassConstruct())&&(this._constructed=!1,w(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){this.destroy(e);return}this._constructed=!0,this._hasReadImpl&&this._flowing&&!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)})}))}_hasSubclassConstruct(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}_hasSubclassRead(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_read`))return!0;t=Object.getPrototypeOf(t)}return!1}_setupAbortSignal(e){if(e.aborted){this.destroy(i(e.reason));return}let t=()=>{r(),this.destroy(i(e.reason))},n=()=>{r()},r=()=>{e.removeEventListener(`abort`,t),this.off(`close`,n),this.off(`end`,n),this.off(`error`,n)};e.addEventListener(`abort`,t,{once:!0}),this.on(`close`,n),this.on(`end`,n),this.on(`error`,n)}static from(t,n){if(t&&typeof t.getReader==`function`)return e.fromWeb(t,n);if(typeof Blob<`u`&&t instanceof Blob)return e.fromWeb(t.stream(),n);if(t==null||typeof t!=`object`&&typeof t!=`string`){let e=TypeError(`The "iterable" argument must be an instance of Iterable. Received type ${typeof t} (${String(t)})`);throw e.code=`ERR_INVALID_ARG_TYPE`,e}let r=typeof t[Symbol.iterator]==`function`,i=typeof t[Symbol.asyncIterator]==`function`;if(!r&&!i&&typeof t!=`string`){let e=t?.constructor?.name??`Object`,n=TypeError(`The "iterable" argument must be an instance of Iterable. Received an instance of ${e}`);throw n.code=`ERR_INVALID_ARG_TYPE`,n}let a=new e({...n,objectMode:n?.objectMode??!0}),o=t;return rr(a,nr(typeof o==`string`?[o]:o)),a}static isDisturbed(e){return e._didRead||(e._destroyed||e._errored!==null)&&!e._endEmitted}static isReadable(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.read==`function`?t.destroyed||t._destroyed||t.readableEnded||t._endEmitted?!1:t.readable!==!1:null}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e._webStream}static wrap(t,n){return new e({objectMode:t.readableObjectMode??t.objectMode??!0,...n,destroy(e,n){typeof t.destroy==`function`&&t.destroy(e??void 0),n(e)}}).wrap(t)}push(e,t){if(this._destroyed)return!1;if(this._pushMode=!0,e!==null&&typeof e==`string`&&!this._objectMode){let n=Ln(e,t||`utf8`);n.toString=Xn,e=n}if(this._ended&&e!==null){let e=Error(`stream.push() after EOF`);return e.code=`ERR_STREAM_PUSH_AFTER_EOF`,w(()=>this.emit(`error`,e)),!1}if(e===null)return this._ended?!1:(this._ended=!0,this._buf.length===0&&w(()=>this._emitEndOnce()),!1);if(!this._objectMode&&(typeof e==`string`?e.length:e?.byteLength??e?.length??0)===0)return!0;if(this._flowing)return this._buf.length>0?(this._buf.push(e),this._objectMode?this._buf.length<this._highWaterMark:this._buf.byteSize<this._highWaterMark):(this._didRead=!0,this.emit(`data`,this._applyEncoding(e)),this._flowing?(this._hasReadImpl&&!this._ended&&w(()=>{this._flowing&&!this._ended&&!this._destroyed&&(this._callRead(this._highWaterMark),this._ended&&this._buf.length===0&&this._emitEndOnce())}),!0):!1);{let t=this._buf.length===0;return this._buf.push(e),t&&w(()=>this.emit(`readable`)),this._objectMode?this._buf.length<this._highWaterMark:this._buf.byteSize<this._highWaterMark}}_emitEndOnce(){if(this._endEmitted||this._destroyed||this._buf.length>0)return;let e=this._flushDecoder();e&&this.emit(`data`,e),this._endEmitted=!0,this.emit(`end`),this._autoDestroy&&this.destroy()}unshift(e,t){if(this._destroyed)return;if(e===null){this._ended||(this._ended=!0,this._buf.length===0&&w(()=>this._emitEndOnce()));return}if(this._endEmitted){let e=Error(`stream.unshift() after end event`);e.code=`ERR_STREAM_UNSHIFT_AFTER_END_EVENT`,w(()=>this.emit(`error`,e));return}if(typeof e==`string`&&!this._objectMode){let n=Ln(e,t||`utf8`);n.toString=Xn,e=n}let n=this._buf.length===0;this._buf.unshift(e),this._flowing?w(()=>{for(;this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}this._ended&&this._buf.length===0&&this._emitEndOnce()}):n&&w(()=>this.emit(`readable`))}_callRead(e){try{this._read(e)}catch(e){let t=e instanceof Error?e:Error(String(e));this._internalDestroy=!0,this.destroy(t)}}read(e){this._didRead=!0;let t;if(e!=null){if(t=parseInt(e,10),isNaN(t))t=void 0;else if(t<=0){if(t===0&&!this._ended&&!this._destroyed&&this._constructed){let e=this._objectMode?this._buf.length:this._buf.byteSize;(e<this._highWaterMark||e===0)&&this._callRead(this._highWaterMark)}return null}}if(this._buf.length===0)return!this._ended&&!this._destroyed&&this._constructed&&this._callRead(this._highWaterMark),null;if(this._objectMode){let e=this._buf.shift();return this._ended&&this._buf.length===0&&w(()=>this._emitEndOnce()),this._hasReadImpl&&!this._ended&&!this._destroyed&&this._constructed&&this._buf.length<this._highWaterMark&&w(()=>{!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)}),e}let n;if(t==null)n=this._applyEncoding(this._buf.consumeAll());else if(this._buf.byteSize<t)if(this._ended)n=this._applyEncoding(this._buf.consumeAll());else return this._hasReadImpl&&this._constructed&&this._callRead(Math.max(t,this._highWaterMark)),null;else n=this._applyEncoding(this._buf.consumeBytes(t));return this._hasReadImpl&&!this._ended&&!this._destroyed&&this._buf.byteSize<this._highWaterMark&&w(()=>{!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)}),this._ended&&this._buf.length===0&&w(()=>this._emitEndOnce()),!this._flowing&&this._buf.length>0&&w(()=>this.emit(`readable`)),n}_flushDecoder(){if(!this._decoder)return null;let e=this._decoder.decode(new Uint8Array,{stream:!1});return this._decoder=null,e||null}setEncoding(e){return this._encoding=e,this._decoder=mn(e),this}_applyEncoding(e){return this._encoding&&e instanceof Uint8Array?(this._decoder||=mn(this._encoding),this._decoder.decode(e,{stream:!0})):e}wrap(e){let t=!1;return e.on(`data`,n=>{this.push(n)||(e.pause(),t=!0)}),e.on(`end`,()=>this.push(null)),e.on(`error`,e=>this.destroy(e)),e.on(`close`,()=>this.destroy()),this._hasReadImpl=!0,this._read=()=>{t&&(t=!1,e.resume())},this}pause(){return this._flowing?(this._flowing=!1,this.emit(`pause`)):this._hasFlowed=!0,this}resume(){return this._flowing||(this._flowing=!0,this._hasFlowed=!0,this._resumeScheduled||(this._resumeScheduled=!0,w(()=>{this._resumeScheduled=!1,this.emit(`resume`)}))),this._buf.length>0?w(()=>{for(;this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}if(this._ended&&this._buf.length===0&&this._emitEndOnce(),this._flowing&&this._buf.length===0&&this._webStreamMode&&!this._pushMode&&!this._ended&&!this._destroyed&&this._startReading(),this._hasReadImpl&&this._flowing&&!this._ended&&!this._destroyed&&this._constructed){let e=this._objectMode?this._buf.length:this._buf.byteSize;(e<this._highWaterMark||e===0)&&this._callRead(this._highWaterMark)}}):this._ended&&this._buf.length===0?w(()=>this._emitEndOnce()):this._webStreamMode&&!this._pushMode?this._startReading():this._hasReadImpl&&w(()=>{this._flowing&&!this._ended&&!this._destroyed&&this._constructed&&(this._callRead(this._highWaterMark),this._ended&&this._buf.length===0&&this._emitEndOnce())}),this}on(e,t){return super.on(e,t),e===`data`?this.resume():e===`readable`&&(this._hasFlowed=!0,this._flowing=!1,(this._buf.length>0||this._ended)&&w(()=>this.emit(`readable`))),this}isPaused(){return this.readableFlowing===!1}pipe(e,t){return this._pipes.pipe(e,t)}unpipe(e){return this._pipes.unpipe(e),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._readableOverride=void 0,this.unpipe(),this._reader){let e=this._reader;this._reader=null,e.cancel().catch(()=>{}).finally(()=>{try{e.releaseLock()}catch{}})}let t=e=>{let t=e||null;t&&(this._errored=t),this._closed=!0;let n=()=>{t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)},r=this._endEmitted||this._internalDestroy;this._internalDestroy=!1,Vn()&&!this._hasDestroyHook()&&r?n():w(n)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._destroyed=!1,this._closed=!1,this._errored=null}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}get _webStream(){if(this._stream)return this._stream;let e=this,t=!1,n=new ReadableStream({pull(n){return new Promise((r,i)=>{if(t)return r();let a=()=>{if(e._destroyed){if(e._errored){t=!0;try{n.error(e._errored)}catch{}return i(e._errored)}t=!0;try{n.close()}catch{}return r()}let o=e.read();if(o!==null){try{n.enqueue(o)}catch{}return r()}if(e._endEmitted){t=!0;try{n.close()}catch{}return r()}let s=()=>{d(),a()},c=()=>{d(),t=!0;try{n.close()}catch{}r()},l=e=>{d(),t=!0;try{n.error(e)}catch{}i(e)},u=()=>{if(d(),!t){t=!0;try{n.close()}catch{}}r()},d=()=>{e.off(`readable`,s),e.off(`end`,c),e.off(`error`,l),e.off(`close`,u)};e.once(`readable`,s),e.once(`end`,c),e.once(`error`,l),e.once(`close`,u)};a()})},cancel(){e.destroy()}});return this._stream=n,n}get readable(){return this._readableOverride===void 0?!this._destroyed&&!this._endEmitted:this._readableOverride}set readable(e){this._readableOverride=e}get readableEnded(){return this._endEmitted}get readableLength(){return this._objectMode?this._buf.length:this._buf.byteSize}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e}get errored(){return this._errored}get closed(){return this._closed}get readableFlowing(){return this._flowing?!0:this._hasFlowed?!1:null}set readableFlowing(e){e===!0?(this._flowing=!0,this._hasFlowed=!0):e===!1?(this._flowing=!1,this._hasFlowed=!0):(this._flowing=!1,this._hasFlowed=!1)}_setReadableFlowing(e){this.readableFlowing=e}get readableAborted(){return this._readableOverride===!1?!1:(this._destroyed||!!this._errored)&&!this._endEmitted}get readableDidRead(){return this._didRead}get readableEncoding(){return this._encoding}get readableObjectMode(){return this._objectMode}get readableHighWaterMark(){return this._highWaterMark}get readableBuffer(){return this._buf.toArray()}_releaseReader(){if(this._reader){let e=this._reader;this._reader=null;try{e.releaseLock()}catch{}}}async _startReading(){if(!(this._reading||this._destroyed||!this._flowing)){this._reading=!0;try{for(this._reader||=this._stream.getReader();this._flowing&&!this._destroyed&&!this._pushMode;){let{done:e,value:t}=await this._reader.read();if(this._pushMode){this._releaseReader();break}if(e){this._ended=!0,this._buf.length===0&&w(()=>this._emitEndOnce()),this._releaseReader();break}if(t!==void 0){let e=this._buf.length===0;for(this._buf.push(t),e&&w(()=>this.emit(`readable`));this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}if(!this._flowing)break}}}catch(e){this.emit(`error`,e),this._releaseReader()}finally{this._reading=!1}}}async*[Symbol.asyncIterator](){this._asyncIterState||=this._initAsyncIterState();let e=this._asyncIterState;e.activeCount++;try{for(;;){if(e.streamError)throw e.streamError;if(e.dataQueueIndex<e.dataQueue.length){let t=e.dataQueue[e.dataQueueIndex];e.dataQueue[e.dataQueueIndex]=void 0,e.dataQueueIndex++,e.queuedSize-=this._chunkSizeForBackpressure(t),e.dataQueueIndex>=1024&&e.dataQueueIndex*2>=e.dataQueue.length&&(e.dataQueue.splice(0,e.dataQueueIndex),e.dataQueueIndex=0),this._maybeResumeIterState(e),yield t;continue}if(e.done)break;let t=await new Promise((t,n)=>{e.resolverQueue.push({resolve:t,reject:n})});if(t===null)break;yield t}}finally{e.activeCount--,e.activeCount===0&&this._teardownAsyncIterState(),this._destroyed||this.destroy()}}_chunkSizeForBackpressure(e){return this._objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?e.length:1}_maybeResumeIterState(e){e.pausedByIterator&&e.queuedSize<this._highWaterMark&&!e.done&&!this._destroyed&&(e.pausedByIterator=!1,this.resume())}_initAsyncIterState(){let e=this._highWaterMark,t={dataQueue:[],dataQueueIndex:0,queuedSize:0,resolverQueue:[],done:!1,streamError:null,activeCount:0,listenersAttached:!1,pausedByIterator:!1,dataHandler:null,doneHandler:null,errorHandler:null};for(t.dataHandler=n=>{if(t.resolverQueue.length>0){let{resolve:e}=t.resolverQueue.shift();e(n);return}t.dataQueue.push(n),t.queuedSize+=this._chunkSizeForBackpressure(n),!t.pausedByIterator&&t.queuedSize>=e&&(t.pausedByIterator=!0,this.pause())},t.doneHandler=()=>{t.done=!0;for(let{resolve:e}of t.resolverQueue)e(null);t.resolverQueue.length=0},t.errorHandler=e=>{t.done=!0,t.streamError=e;for(let{reject:n}of t.resolverQueue)n(e);t.resolverQueue.length=0};this._buf.length>0;){let e=this._applyEncoding(this._buf.shift());t.dataQueue.push(e),t.queuedSize+=this._chunkSizeForBackpressure(e)}if(this._ended){let e=this._flushDecoder();e&&(t.dataQueue.push(e),t.queuedSize+=this._chunkSizeForBackpressure(e)),t.done=!0}else this.on(`data`,t.dataHandler),this.on(`end`,t.doneHandler),this.on(`error`,t.errorHandler),this.on(`close`,t.doneHandler),t.listenersAttached=!0,this.resume();return t}_teardownAsyncIterState(){let e=this._asyncIterState;e&&(e.listenersAttached&&(this.off(`data`,e.dataHandler),this.off(`end`,e.doneHandler),this.off(`error`,e.errorHandler),this.off(`close`,e.doneHandler)),this._asyncIterState=null)}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this._endEmitted?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}iterator(e){if(e?.destroyOnReturn??!0)return this[Symbol.asyncIterator]();let t=this,n=null,r=null,i=!1,a=null,s=()=>{if(!n)return;let e=t.read();if(e!==null){let t=n;n=null,r=null,t({done:!1,value:e})}},c=()=>{s()},l=()=>{if(i=!0,n){let e=n;n=null,r=null,e({done:!0,value:void 0})}},u=e=>{if(i=!0,a=e,r){let t=r;n=null,r=null,t(e)}};t.on(`readable`,c),t.on(`end`,l),t.on(`error`,u);let d=()=>{t.off(`readable`,c),t.off(`end`,l),t.off(`error`,u)};return{next:async()=>{if(a)throw o(a);let e=t.read();return e===null?i?(d(),{done:!0,value:void 0}):new Promise((e,t)=>{n=e,r=t,s()}):{done:!1,value:e}},return:async e=>(d(),{done:!0,value:e}),throw:async e=>(d(),t.destroy(e),{done:!0,value:void 0}),[Symbol.asyncIterator](){return this}}}map(t,n){let r=n?.signal;Zn(r);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0});return rr(c,(async function*(e){try{yield*tr(e,e=>t(e,{signal:s}),a,r)}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),r&&r.addEventListener(`abort`,()=>{c.destroy(i())},{once:!0}),c}filter(t,n){let r=n?.signal;Zn(r);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0}),l=Symbol(`skip`);return rr(c,(async function*(e){try{if(a<=1)for await(let n of e)Qn(r),await t(n,{signal:s})&&(yield n);else for await(let n of tr(e,async e=>await t(e,{signal:s})?e:l,a,r))n!==l&&(yield n)}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),r&&r.addEventListener(`abort`,()=>{c.destroy(i())},{once:!0}),c}async forEach(e,t){let n=t?.signal;Zn(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1)for await(let t of this)Qn(n),await e(t,{signal:a});else for await(let t of tr(this,async t=>{await e(t,{signal:a})},r,n));}finally{i.abort()}}async toArray(e){let t=e?.signal;Zn(t);let n=[];for await(let e of this)Qn(t),n.push(e);return n}async some(e,t){let n=t?.signal;Zn(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(Qn(n),await e(t,{signal:a}))return this.destroy(),!0}else for await(let t of tr(this,t=>e(t,{signal:a}),r,n))if(t)return this.destroy(),!0;return!1}finally{i.abort()}}async find(e,t){let n=t?.signal;Zn(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(Qn(n),await e(t,{signal:a}))return this.destroy(),t}else for await(let t of tr(this,async t=>({chunk:t,match:await e(t,{signal:a})}),r,n))if(t.match)return this.destroy(),t.chunk;return}finally{i.abort()}}async every(e,t){let n=t?.signal;Zn(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(Qn(n),!await e(t,{signal:a}))return this.destroy(),!1}else for await(let t of tr(this,t=>e(t,{signal:a}),r,n))if(!t)return this.destroy(),!1;return!0}finally{i.abort()}}flatMap(t,n){let r=n?.signal;Zn(r);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0});return rr(c,(async function*(e){try{if(a<=1)for await(let n of e){Qn(r);let e=await t(n,{signal:s});if(e&&typeof e[Symbol.asyncIterator]==`function`)for await(let t of e)yield t;else if(e&&typeof e[Symbol.iterator]==`function`)for(let t of e)yield t}else for await(let n of tr(e,async e=>{let n=await t(e,{signal:s}),r=[];if(n&&typeof n[Symbol.asyncIterator]==`function`)for await(let e of n)r.push(e);else if(n&&typeof n[Symbol.iterator]==`function`)for(let e of n)r.push(e);return r},a,r))for(let e of n)yield e}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),r&&r.addEventListener(`abort`,()=>{c.destroy(i())},{once:!0}),c}drop(t,n){let r=n?.signal;Zn(r),$n(t,`limit`);let a=new e({objectMode:!0});return rr(a,(async function*(e){let n=0;for await(let i of e)Qn(r),n>=t&&(yield i),n++})(this)),a.once(`close`,()=>{this.destroyed||this.destroy()}),r&&r.addEventListener(`abort`,()=>{a.destroy(i())},{once:!0}),a}take(t,n){let r=n?.signal;Zn(r),$n(t,`limit`);let a=new e({objectMode:!0});return rr(a,(async function*(e){let n=0;for await(let i of e){if(Qn(r),n>=t)break;yield i,n++}})(this)),a.once(`close`,()=>{this.destroyed||this.destroy()}),r&&r.addEventListener(`abort`,()=>{a.destroy(i())},{once:!0}),a}async reduce(e,t,n){let r=n?.signal;Zn(r);let i=new AbortController,a=i.signal,o,s=arguments.length>=2,c=!0;try{for await(let n of this){if(Qn(r),c&&!s){o=n,c=!1;continue}c&&=(o=t,!1),o=await e(o,n,{signal:a})}if(c&&!s)throw TypeError(`Reduce of an empty stream requires an initial value`);return c?t:o}finally{i.abort()}}asIndexedPairs(e){let t=0;return this.map(e=>[t++,e],e)}compose(t,n){if(typeof t==`function`){let n=new e({objectMode:!0});rr(n,t(this)),n.once(`close`,()=>{this.destroyed||this.destroy()});let r=Un();return r?r(n):n}let r=t;if(this.pipe(r),r._readable&&r._writable)return r;if(r._readable){let e=Un();return e?e(r._readable):r._readable}let i=Un();return i?i(r):r}};T.prototype.addListener=T.prototype.on,T.prototype._read=function(e){let t=Error(`The _read() method is not implemented`);throw t.code=`ERR_METHOD_NOT_IMPLEMENTED`,t};function Zn(e){if(e!==void 0&&!(e instanceof AbortSignal))throw TypeError(`options.signal must be an AbortSignal`)}function Qn(e){if(e?.aborted)throw i(e.reason)}function $n(e,t){if(typeof e!=`number`||Number.isNaN(e)||e<0||Math.floor(e)!==e)throw RangeError(`The value of "${t}" must be a non-negative integer. Received ${e}`)}let er=Symbol(`EOF`);async function*tr(e,t,n,r){if(n<=1){for await(let n of e)Qn(r),yield await t(n);return}let i=[],a=null,s=!1,c=e[Symbol.asyncIterator]();async function l(){let e=await c.next();return e.done?(s=!0,er):(Qn(r),t(e.value))}function u(){i.push(l().catch(e=>{throw a=e,e}))}try{for(;i.length<n&&!s&&!a;)Qn(r),u();for(;i.length>0;){Qn(r);let e=await i.shift();if(a)throw o(a);e!==er&&(yield e,!s&&!a&&u())}}finally{s||await c.return?.()}}function nr(e){return e&&typeof e[Symbol.asyncIterator]==`function`?e:(async function*(){for(let t of e)yield t})()}function rr(e,t){let n=t[Symbol.asyncIterator](),r=!1,i=!1;e._hasReadImpl=!0,e._read=function(){r||i||(r=!0,(async()=>{try{if(e.destroyed){if(!i){i=!0;let e=n.return?.();e&&typeof e.then==`function`&&e.catch(()=>{})}return}let{value:t,done:r}=await n.next();if(r){i=!0,e.push(null);return}e.push(t)}catch(t){e.destroy(t)}finally{r=!1}})())},e._pushMode=!0}function ir(e){return wn(this,e??`utf-8`)}var ar=class e extends In{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&`writableFinished`in t}constructor(e){if(super(),this._stream=null,this._writer=null,this._ended=!1,this._finished=!1,this._syncFinish=!1,this._destroyed=!1,this._errored=null,this._errorEmitted=!1,this._closed=!1,this._writableLength=0,this._needDrain=!1,this._corked=0,this._corkedChunks=[],this._defaultEncoding=`utf8`,this._ownsStream=!1,this._directWrite=!1,this._writeQueue=[],this._writing=!1,this._pendingEnd=null,this._constructed=!0,this._resolvedWritev=null,this.__excelts_stream=!0,this._objectMode=e?.objectMode??!1,this._highWaterMark=e?.highWaterMark??jn(this._objectMode),this._autoDestroy=e?.autoDestroy??!0,this._emitClose=e?.emitClose??!0,this._decodeStrings=e?.decodeStrings??!0,this._defaultEncoding=e?.defaultEncoding??`utf8`,e?.stream)this._stream=e.stream,this._ownsStream=!1,this._directWrite=!1;else{if(e?.write&&(this._writeFunc=e.write.bind(this)),e?.final)this._finalFunc=e.final.bind(this);else{let e=this._getSubclassFinal();e&&(this._finalFunc=e)}if(e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this)),e?.writev&&(this._writevFunc=e.writev.bind(this)),this._ownsStream=!0,this._writeFunc)this._directWrite=!0,this._stream=null;else{let t=e?.construct||this._hasSubclassConstruct(),n=this._getSubclassWrite();t&&n?(this._writeFunc=n,this._directWrite=!0,this._stream=null):(this._directWrite=!1,this._stream=new WritableStream({write:async e=>{this._write&&await new Promise((t,n)=>{this._write(e,`utf8`,e=>{e?n(e):t()})})},close:async()=>{if(this._finalFunc){let e=await new Promise(e=>{this._finalFunc(t=>{e(t??null)})});if(e){this._errored=e,this._errorEmitted=!0,this.emit(`error`,e),this._autoDestroy&&this.destroy(e);return}}this._finished=!0,this.emit(`finish`),this._autoDestroy&&this.destroy()},abort:e=>{this.emit(`error`,e)}}))}}e?.signal&&this._setupAbortSignal(e.signal),this._resolvedWritev=this._writevFunc??this._getWritevHook(),this._maybeConstruct()}_maybeConstruct(){(this._constructFunc||this._hasSubclassConstruct())&&(this._constructed=!1,w(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){this.destroy(e);return}if(this._constructed=!0,this._directWrite&&this._writeQueue.length>0&&!this._writing)this._writing=!0,this._drainWriteQueue();else if(this._pendingEnd&&!this._writing){let{cb:e}=this._pendingEnd;this._pendingEnd=null,this._doFinish(e)}})}))}_hasSubclassConstruct(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}_getSubclassWrite(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_write`))return t._write.bind(this);t=Object.getPrototypeOf(t)}return null}_getSubclassFinal(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_final`))return t._final.bind(this);t=Object.getPrototypeOf(t)}return null}_getWritevHook(){let t=Object.getPrototypeOf(this);return t._writev&&t._writev!==e.prototype._writev?t._writev.bind(this):null}_setupAbortSignal(e){if(e.aborted){this.destroy(i(e.reason));return}let t=()=>{r(),this.destroy(i(e.reason))},n=()=>{r()},r=()=>{e.removeEventListener(`abort`,t),this.off(`close`,n),this.off(`finish`,n),this.off(`error`,n)};e.addEventListener(`abort`,t,{once:!0}),this.on(`close`,n),this.on(`finish`,n),this.on(`error`,n)}setDefaultEncoding(e){return Ln(``,e),this._defaultEncoding=e,this}cork(){this._corked++}uncork(){if(this._corked>0&&this._corked--,this._corked===0){let e=this._corkedChunks;if(this._corkedChunks=[],e.length===0)return;for(let{chunk:t}of e)this._writableLength-=this._getChunkSize(t);let t=this._resolvedWritev;if(t&&e.length>1){let n=e.map(({chunk:e,encoding:t})=>({chunk:e,encoding:t})),r=n.reduce((e,{chunk:t})=>e+this._getChunkSize(t),0);this._writableLength+=r,this._writing=!0;try{t(n,t=>{if(this._writableLength-=r,this._writing=!1,t){this._destroyed||(this._errored=t,this.emit(`error`,t),this._autoDestroy&&this.destroy(t));for(let{callback:n}of e)n?.(t);return}this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,w(()=>this.emit(`drain`)));for(let{callback:t}of e)t?.(null);this._drainWriteQueue()})}catch(t){this._writableLength-=r,this._writing=!1;let n=t instanceof Error?t:Error(String(t));this._destroyed||(this._errored=n,this.emit(`error`,n),this._autoDestroy&&this.destroy(n));for(let{callback:t}of e)t?.(n)}}else for(let{chunk:t,encoding:n,callback:r}of e)this._doWrite(t,n,r)}}write(e,t,n){if(e===null){let e=TypeError(`May not write null values to stream`);throw e.code=`ERR_STREAM_NULL_VALUES`,e}if(this._destroyed||this._ended){let e=this._destroyed&&!this._ended,r=Error(e?`Cannot call write after a stream was destroyed`:`write after end`);r.code=e?`ERR_STREAM_DESTROYED`:`ERR_STREAM_WRITE_AFTER_END`;let i=typeof t==`function`?t:n;return this._errored||=r,i&&w(()=>i(r)),!this._destroyed&&!this._errorEmitted&&(this._errorEmitted=!0,w(()=>this.emit(`error`,r))),!1}let r=typeof t==`string`?t:this._defaultEncoding,i=typeof t==`function`?t:n;if(this._corked>0){let t=this._normalizeWriteChunk(e,r);this._corkedChunks.push({chunk:t.chunk,encoding:t.encoding,callback:i});let n=this._getChunkSize(t.chunk,t.encoding);this._writableLength+=n;let a=this._writableLength<this._highWaterMark;return a||(this._needDrain=!0),a}let a=this._normalizeWriteChunk(e,r),o=this._doWrite(a.chunk,a.encoding,i);return o||(this._needDrain=!0),o}_doWrite(e,t,n){let r=this._getChunkSize(e,t);return this._writableLength+=r,this._directWrite?this._writing||!this._constructed?this._writeQueue.push({chunk:e,chunkSize:r,encoding:t,callback:n}):(this._writing=!0,this._callWriteFunc(e,r,t,n)):this._getWriter().write(e).then(()=>{this._writableLength-=r,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,w(()=>this.emit(`drain`))),n?.(null)}).catch(e=>{this._writableLength-=r,this._destroyed||(this._errored=e,this._errorEmitted=!0,this.emit(`error`,e),this._autoDestroy&&this.destroy(e)),n?.(e)}),this._writableLength<this._highWaterMark}_callWriteFunc(e,t,n,r){try{let i=this._objectMode?void 0:n,a=!1,o=!0;this._writeFunc(e,i,e=>{if(a){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(a=!0,e){if(this._writableLength-=t,this._destroyed?r?.(e):(this._errored=e,this._errorEmitted=!0,o?w(()=>{r?.(e),this.emit(`error`,e),this._autoDestroy&&this.destroy(e)}):(r?.(e),this.emit(`error`,e),this._autoDestroy&&this.destroy(e))),this._writing=!1,this._flushWriteQueueOnError(e),this._pendingEnd){let{cb:t}=this._pendingEnd;this._pendingEnd=null,t?.(e)}return}this._writableLength-=t,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,w(()=>this.emit(`drain`))),r?.(null),this._drainWriteQueue()}),o=!1}catch(e){this._writableLength-=t;let n=e instanceof Error?e:Error(String(e));if(this._destroyed||(this._errored=n,this.emit(`error`,n),this._autoDestroy&&this.destroy(n)),r?.(n),this._writing=!1,this._flushWriteQueueOnError(n),this._pendingEnd){let{cb:e}=this._pendingEnd;this._pendingEnd=null,e?.(n)}}}_drainWriteQueue(){if(this._writeQueue.length===0){if(this._writing=!1,this._pendingEnd){let{cb:e}=this._pendingEnd;this._pendingEnd=null,this._doFinish(e)}return}let e=this._resolvedWritev;if(e&&this._writeQueue.length>1){let t=this._writeQueue;this._writeQueue=[];let n=0,r=Array(t.length);for(let e=0;e<t.length;e++){let i=t[e];r[e]={chunk:i.chunk,encoding:i.encoding},n+=i.chunkSize}try{e(r,e=>{if(e){this._writableLength-=n,this._destroyed||(this._errored=e,this._errorEmitted=!0,this.emit(`error`,e));for(let n of t)n.callback?.(e);this._writing=!1,this._flushWriteQueueOnError(e);return}this._writableLength-=n,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,w(()=>this.emit(`drain`)));for(let e of t)e.callback?.(null);this._drainWriteQueue()})}catch(e){this._writableLength-=n,this._writing=!1;let r=e instanceof Error?e:Error(String(e));this._destroyed||(this._errored=r,this.emit(`error`,r));for(let e of t)e.callback?.(r)}}else{let e=this._writeQueue.shift();this._callWriteFunc(e.chunk,e.chunkSize,e.encoding,e.callback)}}_flushWriteQueueOnError(e){let t=this._writeQueue;this._writeQueue=[];for(let n of t)this._writableLength-=n.chunkSize,n.callback?.(e)}_doFinish(e){if(this._finalFunc)this._finalFunc(t=>{if(t){this._errorEmitted=!0,this.emit(`error`,t),e&&(this._pendingEnd={cb:e}),this._autoDestroy&&!this._destroyed&&this.destroy(t);return}let n=()=>{if(this._destroyed){e?.();return}this._finished=!0,this.emit(`prefinish`),e?.(),this.emit(`finish`),this._autoDestroy&&this.destroy()};this._syncFinish?(this._syncFinish=!1,n()):w(n)});else{let t=()=>{if(this._destroyed){e?.();return}this._finished=!0,this.emit(`prefinish`),e?.(),this.emit(`finish`),this._autoDestroy&&this.destroy()};Vn()?t():w(t)}}_getChunkSize(e,t){return this._objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?sr(e,t):0}_normalizeWriteChunk(e,t){if(this._objectMode||typeof e!=`string`||!this._decodeStrings)return{chunk:e,encoding:t};let n=Ln(e,t);return n.toString=ir,{chunk:n,encoding:`buffer`}}end(e,t,n){if(this._ended){let{chunk:r,encoding:i,cb:a}=zn(e,t,n);if(r!==void 0)return this.write(r,i??this._defaultEncoding,e=>{a?.(e??null)}),this;if(this._finished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,w(()=>a(e))}else w(()=>a?.(null));return this}this._ended=!0,this._writableOverride=void 0;let{chunk:r,encoding:i,cb:a}=zn(e,t,n);if(this._corked>0&&(this._corked=1,this.uncork()),this._directWrite){if(r!==void 0){let e=this._normalizeWriteChunk(r,i??this._defaultEncoding);this._doWrite(e.chunk,e.encoding)}if(this._errored){let e=this._errored;return w(()=>a?.(e)),this}return this._writing||this._writeQueue.length>0?this._pendingEnd={cb:a}:this._doFinish(a),this}return(async()=>{try{let e=this._getWriter();if(r!==void 0){let{chunk:t}=this._normalizeWriteChunk(r,i??this._defaultEncoding);await e.write(t)}if(await e.close(),this._writer===e){this._writer=null;try{e.releaseLock()}catch{}}this._ownsStream||(this._finished=!0,this.emit(`finish`),this._autoDestroy&&this.destroy()),a&&a()}catch(e){this.emit(`error`,e)}})(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._writableOverride=void 0,e&&!this._errored&&(this._errored=e),this._writeQueue.length>0&&this._flushWriteQueueOnError(e??Error(`Cannot call write after a stream was destroyed`)),this._corkedChunks.length>0){let t=e??Error(`Cannot call write after a stream was destroyed`);for(let e of this._corkedChunks)e.callback?.(t);this._corkedChunks=[]}let t=this._pendingEnd?.cb;if(this._pendingEnd=null,this._writing=!1,this._writer){let t=this._writer;this._writer=null,t.abort(e).catch(()=>{}).finally(()=>{try{t.releaseLock()}catch{}})}let n=e=>{let n=e||null;n&&(this._errored=n),this._closed=!0;let r=()=>{n&&!this._errorEmitted&&(this._errorEmitted=!0,this.emit(`error`,n)),this._emitClose&&this.emit(`close`),t?.(n)};Vn()&&!this._hasDestroyHook()&&this._finished?r():w(r)};if(this._hasDestroyHook())try{this._destroy(e??null,n)}catch(e){n(e instanceof Error?e:Error(String(e)))}else n(e);return this}_destroy(e,t){t(e)}_undestroy(){this._destroyed=!1,this._closed=!1,this._errored=null,this._errorEmitted=!1}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this._finished?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}get _webStream(){return this._stream||=new WritableStream({write:e=>new Promise((t,n)=>{let r=this._objectMode?void 0:this._defaultEncoding;this._writeFunc(e,r,e=>{e?n(e):t()})}),close:async()=>{this._finalFunc&&await new Promise((e,t)=>{this._finalFunc(n=>{n?t(n):e()})})},abort:e=>{this.emit(`error`,e)}}),this._stream}get writable(){return this._writableOverride===void 0?!this._destroyed&&!this._ended:this._writableOverride}set writable(e){this._writableOverride=e}get writableEnded(){return this._ended}get writableFinished(){return this._finished}get writableLength(){return this._writableLength}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e}get errored(){return this._errored}get closed(){return this._closed}get writableNeedDrain(){return this._needDrain}get writableCorked(){return this._corked}get writableAborted(){return this._writableOverride===!1?!1:(this._destroyed||!!this._errored)&&!this._finished}get writableObjectMode(){return this._objectMode}get writableHighWaterMark(){return this._highWaterMark}get writableBuffer(){let e=this._corkedChunks.map(e=>e.chunk);for(let t of this._writeQueue)e.push(t.chunk);return e}pipe(){let e=new Nn(`pipe`,`not readable`);e.code=`ERR_STREAM_CANNOT_PIPE`,w(()=>this.emit(`error`,e))}_getWriter(){return this._writer||=this._webStream.getWriter(),this._writer}static isDisturbed(e){return e&&e._readable instanceof T?T.isDisturbed(e._readable):T.isDisturbed(e)}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e._webStream}};ar.prototype._writev=null,ar.prototype._write=function(e,t,n){let r=Error(`The _write() method is not implemented`);throw r.code=`ERR_METHOD_NOT_IMPLEMENTED`,r};function or(e){return e instanceof ar?e:e?.getWriter?new ar({stream:e}):e}function sr(e,t){let n=(t??`utf8`).toLowerCase();return n===`ascii`||n===`latin1`||n===`binary`?e.length:n===`utf16le`||n===`utf-16le`||n===`ucs2`?e.length*2:cr(e)}function cr(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<=127?t+=1:r<=2047?t+=2:r>=55296&&r<=56319?(t+=4,n++):t+=3}return t}var lr=class e extends In{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&`readableFlowing`in t&&`writableFinished`in t}static isDisturbed(e){return e&&e._readable instanceof T?T.isDisturbed(e._readable):T.isDisturbed(e)}static from(t){if(t instanceof e)return t;let n=(e,t)=>{let n=new ar({objectMode:t.readableObjectMode,write(e,n,r){t.push(e),r()},final(e){t.push(null),e()}}),r=qn(e,`error`,e=>{t.emit(`error`,e)});qn(e,`end`,r,{once:!0}),qn(e,`close`,r,{once:!0}),qn(n,`finish`,r,{once:!0}),e.pipe(n)};if(t instanceof Promise){let r=new e({objectMode:!0});return t.then(t=>{n(e.from(t),r)}).catch(e=>{r.destroy(e instanceof Error?e:Error(String(e)))}),r}if(typeof t==`string`){let r=T.from([t]),i=new e({objectMode:!0});return n(r,i),i}if(typeof Blob<`u`&&t instanceof Blob){let r=T.fromWeb(t.stream()),i=new e;return n(r,i),i}if(typeof t==`object`&&t&&`readable`in t&&`writable`in t){let r=t,i=new e({readableObjectMode:r.readable?.readableObjectMode,writableObjectMode:r.writable?.writableObjectMode,write:r.writable?(e,t,n)=>{r.writable.write(e,t,n)}:void 0,final:r.writable?e=>{r.writable.end(e)}:void 0,destroy:(e,t)=>{r.readable&&!r.readable.destroyed&&r.readable.destroy(e??void 0),r.writable&&!r.writable.destroyed&&r.writable.destroy(e??void 0),t(e)}});return r.readable&&n(r.readable,i),i}if(typeof t==`object`&&t&&typeof t.getReader==`function`&&typeof t.cancel==`function`){let r=T.fromWeb(t),i=new e({objectMode:r.readableObjectMode});return n(r,i),i}if(typeof t==`object`&&t&&typeof t.getWriter==`function`&&typeof t.close==`function`){let n=ar.fromWeb(t);return new e({objectMode:n.writableObjectMode,write(e,t,r){n.write(e,t,r)},final(e){n.end(e)},destroy(e,t){n.destroyed||n.destroy(e??void 0),t(e)}})}if(typeof t==`object`&&t&&(Symbol.asyncIterator in t||Symbol.iterator in t)){let r=T.from(t),i=new e({objectMode:r.readableObjectMode});return n(r,i),i}if(t instanceof T){let r=new e({objectMode:t.readableObjectMode});return n(t,r),r}if(t instanceof ar)return new e({objectMode:t.writableObjectMode,write(e,n,r){t.write(e,n,r)},final(e){t.end(e)}});throw new Pn(`Duplex-compatible source`,typeof t)}static fromWeb(t,n){let r=new e(n),i=new T({stream:t.readable,objectMode:r.readableObjectMode}),a=new ar({stream:t.writable,objectMode:r.writableObjectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return{readable:T.toWeb(e._readable),writable:ar.toWeb(e._writable)}}_getSubclassHook(t){let n=Object.getPrototypeOf(this);for(;n&&n!==e.prototype&&n!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(n,t)){let e=this[t];return typeof e==`function`?e.bind(this):void 0}n=Object.getPrototypeOf(n)}}constructor(e){super(),this._dataForwardingSetup=!1,this._destroyed=!1,this._errored=null,this._closed=!1,this._sideForwardingCleanup=null,this._constructed=!0,this.__excelts_stream=!0,this.allowHalfOpen=e?.allowHalfOpen??!0,this._emitClose=e?.emitClose??!0,this._autoDestroy=e?.autoDestroy??!0;let t=e?.objectMode??!1,n=e?.readableObjectMode??t,r=e?.writableObjectMode??t,i=e!=null&&Object.prototype.hasOwnProperty.call(e,`highWaterMark`),a=i?e.highWaterMark:e?.readableHighWaterMark,o=i?e.highWaterMark:e?.writableHighWaterMark;e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this));let s,c,l=this._hasConstructHook(),u=e?.read?e.read.bind(this):this._getSubclassHook(`_read`),d=e?.write?e.write.bind(this):this._getSubclassHook(`_write`),f=e?.writev?e.writev.bind(this):this._getSubclassHook(`_writev`),p=e?.final?e.final.bind(this):this._getSubclassHook(`_final`);this._readable=new T({highWaterMark:a,objectMode:n,read:u,encoding:e?.encoding,emitClose:!1,autoDestroy:!1,construct:l?e=>{s=e}:void 0}),this._writable=new ar({highWaterMark:o,objectMode:r,write:d,writev:f,final:p,decodeStrings:e?.decodeStrings,defaultEncoding:e?.defaultEncoding,emitClose:!1,autoDestroy:!1,construct:l?e=>{c=e}:void 0});let m=()=>{};this._readable.on(`error`,m),this._writable.on(`error`,m),this._setupSideForwarding(),e?.signal&&this._setupAbortSignal(e.signal),l&&(this._constructed=!1,w(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){s?.(e),c?.(e),this.destroy(e);return}this._constructed=!0,s?.(),c?.()})}))}_setupAbortSignal(e){if(e.aborted){this.destroy(i(e.reason));return}let t=()=>{this.destroy(i(e.reason))};e.addEventListener(`abort`,t,{once:!0}),this.once(`close`,()=>{e.removeEventListener(`abort`,t)})}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable._pipes?.setSource(this);let e=Jn(),t=!1,n=e=>{t||(t=!0,this.emit(`error`,e))},r=!1,i=!1,a=()=>{this._autoDestroy&&r&&i&&!this._destroyed&&this.destroy()};e.once(this._readable,`end`,()=>{this.emit(`end`),r=!0,this.allowHalfOpen||this._writable.end(),a()}),e.add(this._readable,`error`,n);let o=()=>{this.emit(`readable`)};In.prototype.on.call(this._readable,`readable`,o),e.add(this._readable,`pause`,()=>this.emit(`pause`)),e.add(this._readable,`resume`,()=>this.emit(`resume`)),e.add(this._writable,`error`,n),e.once(this._writable,`prefinish`,()=>this.emit(`prefinish`)),e.once(this._writable,`finish`,()=>{this.emit(`finish`),i=!0,a()}),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.add(this._writable,`pipe`,e=>this.emit(`pipe`,e)),e.add(this._writable,`unpipe`,e=>this.emit(`unpipe`,e)),e.once(this._writable,`finish`,()=>{!this.allowHalfOpen&&!this._readable.readableEnded&&this._readable.push(null)});let s=this._readable.destroy.bind(this._readable);this._readable.destroy=e=>{let t=s(e);return this._destroyed||this.destroy(e),t},this._sideForwardingCleanup=()=>{e.cleanup(),this._readable.off(`readable`,o),this._readable.destroy=s}}on(e,t){return super.on(e,t),e===`data`&&!this._dataForwardingSetup?(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>this.emit(`data`,e))):e===`readable`&&this._readable._setReadableFlowing(!1),this}push(e,t){return this._readable.push(e,t)}unshift(e,t){this._readable.unshift(e,t)}read(e){return this._readable.read(e)}write(e,t,n){let r=typeof t==`string`?t:void 0,i=typeof t==`function`?t:n;return r===void 0?this._writable.write(e,i):this._writable.write(e,r,i)}end(e,t,n){let{chunk:r,encoding:i,cb:a}=zn(e,t,n);if(this._writable.writableEnded){if(r!==void 0)return this.write(r,i,e=>{a?.(e??null)}),this;if(this.writableFinished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,w(()=>a(e))}else a&&w(()=>a(null));return this}if(a){let e=!1,t=()=>{e||(e=!0,a())};this.once(`finish`,t),this.once(`close`,t)}if(r!==void 0){let e=e=>{e&&!this.destroyed&&this.destroy(e)};i===void 0?this._writable.write(r,e):this._writable.write(r,i,e)}return this._writable.end(),this}cork(){this._writable.cork()}uncork(){this._writable.uncork()}setEncoding(e){return this._readable.setEncoding(e),this}setDefaultEncoding(e){return this._writable.setDefaultEncoding(e),this}pipe(e,t){return this._readable.pipe(e,t),e}unpipe(e){return this._readable.unpipe(e),this}pause(){return this._readable.pause(),this}resume(){return this._readable.resume(),this}isPaused(){return this._readable.isPaused()}destroy(e){if(this._destroyed)return this;this._destroyed=!0,this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let t=e=>{let t=e||null;t&&(this._errored=t),this._closed=!0,this._readable.destroy(),this._writable.destroy();let n=()=>{t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)};Vn()&&!this._hasDestroyHook()&&this.readableEnded&&this.writableFinished?n():w(n)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._readable._undestroy(),this._writable._undestroy(),this._destroyed=!1,this._closed=!1,this._errored=null,this._setupSideForwarding()}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}_hasConstructHook(){if(this._constructFunc)return!0;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this.writableFinished?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}get readable(){return this._readable.readable}set readable(e){this._readable.readable=e}get writable(){return this._writable.writable}set writable(e){this._writable.writable=e}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e,this._readable.destroyed=e,this._writable.destroyed=e}get writableCorked(){return this._writable.writableCorked}get writableNeedDrain(){return this._writable.writableNeedDrain}get readableObjectMode(){return this._readable.readableObjectMode}get writableObjectMode(){return this._writable.writableObjectMode}get readableFlowing(){return this._readable.readableFlowing}get readableAborted(){return this._readable.readableAborted}get readableDidRead(){return this._readable.readableDidRead}get readableEncoding(){return this._readable.readableEncoding}get errored(){return this._errored??this._readable.errored??this._writable.errored}get closed(){return this._closed}get readableBuffer(){return this._readable.readableBuffer}get writableBuffer(){return this._writable.writableBuffer}wrap(e){return this._readable.wrap(e),this}iterator(e){return e?.destroyOnReturn===!1?this._readable.iterator(e):this._wrapAsyncIterator(this._readable[Symbol.asyncIterator]())}[Symbol.asyncIterator](){return this._wrapAsyncIterator(this._readable[Symbol.asyncIterator]())}_wrapAsyncIterator(e){let t=this;return{next(){return e.next()},async return(){let n=await e.return?.();return t.destroyed||t.destroy(),n??{value:void 0,done:!0}},async throw(n){let r=await e.throw?.(n);return t.destroyed||t.destroy(n instanceof Error?n:void 0),r??{value:void 0,done:!0}},[Symbol.asyncIterator](){return this}}}map(e,t){return this._readable.map(e,t)}filter(e,t){return this._readable.filter(e,t)}async forEach(e,t){return this._readable.forEach(e,t)}async toArray(e){return this._readable.toArray(e)}async some(e,t){return this._readable.some(e,t)}async find(e,t){return this._readable.find(e,t)}async every(e,t){return this._readable.every(e,t)}flatMap(e,t){return this._readable.flatMap(e,t)}drop(e,t){return this._readable.drop(e,t)}take(e,t){return this._readable.take(e,t)}async reduce(e,t,n){return arguments.length>=2?this._readable.reduce(e,t,n):this._readable.reduce(e)}compose(e,t){return this._readable.compose(e,t)}};lr.prototype.addListener=lr.prototype.on,lr.prototype._writev=null;var ur=class e extends In{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&typeof t._transform==`function`&&`readableFlowing`in t&&`writableFinished`in t}push(e,t){return this._readable.push(e,t)}constructor(t){super(),this._destroyed=!1,this._closed=!1,this._ended=!1,this._errored=null,this._dataForwardingSetup=!1,this._syncFinal=!1,this._endCalledFromSync=!1,this._endGeneration=0,this._endCallback=null,this._webStream=null,this._sideForwardingCleanup=null,this._afterTransformCallback=null,this.__excelts_stream=!0;let n=t?.objectMode??!1,r=t?.readableObjectMode??n,i=t?.writableObjectMode??n;this.allowHalfOpen=t?.allowHalfOpen??!0,this._emitClose=t?.emitClose??!0,this._autoDestroy=t?.autoDestroy??!0,this._transformImpl=t?.transform,this._flushImpl=t?.flush;let a=t!=null&&Object.prototype.hasOwnProperty.call(t,`highWaterMark`),o=a?t.highWaterMark:t?.readableHighWaterMark,s=a?t.highWaterMark:t?.writableHighWaterMark;t?.destroy&&(this._destroy=t.destroy.bind(this)),t?.construct&&(this._constructFunc=t.construct.bind(this));let c,l,u=this._hasConstructHook();this._readable=new T({highWaterMark:o,objectMode:r,encoding:t?.encoding,emitClose:!1,autoDestroy:!1,construct:u?e=>{c=e}:void 0}),this._readable._hasReadImpl=!0,this._readable._read=()=>{if(this._afterTransformCallback){let e=this._afterTransformCallback;this._afterTransformCallback=null,e(null)}},this._readable._pipes.setSource(this);let d=t?.write?(e,n,r)=>{t.write.call(this,e,n,r)}:(e,t,n)=>{let r=this._readable.readableLength,i=()=>{let e=this._readable.readableLength,t=this._readable.readableHighWaterMark;this._writable.writableEnded||r===e||e<t?n(null):this._afterTransformCallback=n},a=this._runTransformSync(e,t);a===void 0?i():a.then(()=>i(),e=>n(e))},f=t?.final?e=>{t.final.call(this,t=>{if(t){e(t);return}this._readable.push(null),e(null)})}:t=>{typeof this._final==`function`&&this._final!==e.prototype._final?this._final.call(this,e=>{if(e){t(e);return}t(null)}):this._hasSubclassFlush()||this._flushImpl?this._runFlush().then(()=>{this._readable.push(null),t(null)}).catch(e=>t(e)):this._syncFinal?(this._readable.push(null),this._readable._emitEndOnce(),t(null)):w(()=>{this._readable.push(null),t(null)})};this._writable=new ar({highWaterMark:s,objectMode:i,emitClose:!1,autoDestroy:!1,write:d,writev:t?.writev?.bind(this),final:f,decodeStrings:t?.decodeStrings,defaultEncoding:t?.defaultEncoding,construct:u?e=>{l=e}:void 0});let p=()=>{};this._readable.on(`error`,p),this._writable.on(`error`,p),this._setupSideForwarding(),t?.signal&&this._setupAbortSignal(t.signal),u&&w(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){c?.(e),l?.(e),this.destroy(e);return}c?.(),l?.()})})}_setupAbortSignal(e){if(e.aborted){this.destroy(i(e.reason));return}let t=()=>{this.destroy(i(e.reason))};e.addEventListener(`abort`,t,{once:!0}),this.once(`close`,()=>{e.removeEventListener(`abort`,t)})}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable._pipes?.setSource(this);let e=Jn(),t=!1,n=!1,r=()=>{this._autoDestroy&&t&&n&&!this._destroyed&&this.destroy()};e.once(this._readable,`end`,()=>{this.emit(`end`),t=!0,this.allowHalfOpen||this._writable.end(),r()}),e.add(this._readable,`error`,e=>this._emitErrorOnce(e));let i=()=>{this.emit(`readable`)};In.prototype.on.call(this._readable,`readable`,i),e.add(this._readable,`pause`,()=>this.emit(`pause`)),e.add(this._readable,`resume`,()=>this.emit(`resume`)),e.once(this._writable,`prefinish`,()=>this.emit(`prefinish`)),e.once(this._writable,`finish`,()=>{this.emit(`finish`),n=!0,r()}),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.add(this._writable,`error`,e=>this._emitErrorOnce(e)),e.once(this._writable,`finish`,()=>{!this.allowHalfOpen&&!this._readable.readableEnded&&this._readable.push(null)}),this._sideForwardingCleanup=()=>{e.cleanup(),this._readable.off(`readable`,i)}}_scheduleEnd(){if(this._destroyed||this._errored||this._writable.writableEnded)return;let t=++this._endGeneration;w(()=>{t===this._endGeneration&&(this._destroyed||this._errored||this._writable.writableEnded||(this._endCalledFromSync&&!this._hasSubclassFlush()&&!this._flushImpl&&!(typeof this._final==`function`&&this._final!==e.prototype._final)&&this._readable._pipes._destinations.length===0&&(this._syncFinal=!0,this._writable._syncFinish=!0),this._writable.end(),this._syncFinal=!1,this._writable._syncFinish=!1))})}_emitErrorOnce(e){if(this._errored)return;let t=e instanceof Error?e:Error(String(e));this._errored=t,this._destroyed||this.destroy(t)}_hasSubclassTransform(){if(this._isSubclassTransform!==void 0)return this._isSubclassTransform;if(this._transformImpl)return this._isSubclassTransform=!1,!1;let t=Object.getPrototypeOf(this);return this._isSubclassTransform=t._transform!==e.prototype._transform,this._isSubclassTransform}_hasSubclassFlush(){if(this._flushImpl)return!1;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_flush`))return!0;t=Object.getPrototypeOf(t)}return!1}_runTransformSync(e,t){if(this._destroyed||this._errored)return;if(this._hasSubclassTransform()){let n=!0,r=!1,i=null,a,s=!1,c=null,l=null;if(this._transform(e,t,(e,t)=>{if(s){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(s=!0,n){r=!0,i=e??null,a=t;return}if(e){l?.(e);return}t!==void 0&&this.push(t),c?.()}),n=!1,r){if(i)throw o(i);a!==void 0&&this.push(a);return}return new Promise((e,t)=>{c=e,l=t})}let n=this._transformImpl;if(!n){let n=!0,r=!1,i=null,a,s=null,c=null;if(this._transform(e,t,(e,t)=>{if(n){r=!0,i=e??null,a=t;return}if(e){c?.(e);return}t!==void 0&&this.push(t),s?.()}),n=!1,r){if(i)throw o(i);a!==void 0&&this.push(a);return}return new Promise((e,t)=>{s=e,c=t})}let r=!0,i=!1,a=null,s,c=!1,l=null,u=null,d=new Promise((e,t)=>{l=e,u=t});if(n.call(this,e,t,(e,t)=>{if(c){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(c=!0,r){i=!0,a=e??null,s=t;return}if(e){u?.(e);return}t!==void 0&&this.push(t),l?.()}),r=!1,i){if(a)throw o(a);s!==void 0&&this.push(s);return}return d}async _runFlush(){if(this._destroyed||this._errored)return;if(this._hasSubclassFlush()){await new Promise((e,t)=>{this._flush((n,r)=>{if(n){t(n);return}r!==void 0&&this.push(r),e()})});return}let e=this._flushImpl;e&&await new Promise((t,n)=>{e.call(this,(e,r)=>{if(e){n(e);return}r!==void 0&&this.push(r),t()})})}on(e,t){return super.on(e,t),e===`data`&&!this._dataForwardingSetup?(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>{this.emit(`data`,e)})):e===`readable`&&this._readable._setReadableFlowing(!1),this}write(e,t,n){let r=typeof t==`string`?t:void 0,i=typeof t==`function`?t:n;if(this._ended){let e=Error(`write after end`);return e.code=`ERR_STREAM_WRITE_AFTER_END`,w(()=>this.emit(`error`,e)),i&&w(()=>i(e)),!1}return r===void 0?this._writable.write(e,i):this._writable.write(e,r,i)}end(e,t,n){if(this._ended){let{chunk:r,encoding:i,cb:a}=zn(e,t,n);if(r!==void 0)return this.write(r,i,e=>{a?.(e??null)}),this;if(this.writableFinished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,w(()=>a(e))}else a&&w(()=>a(null));return this}let{chunk:r,encoding:i,cb:a}=zn(e,t,n);if(a&&(this._endCallback=a,this.once(`finish`,()=>{let e=this._endCallback;e&&(this._endCallback=null,e())})),r!==void 0){let e=e=>{e&&!this._destroyed&&this.destroy(e)};i===void 0?this._writable.write(r,e):this._writable.write(r,i,e)}return this._ended=!0,this._endCalledFromSync=!Vn(),this._scheduleEnd(),this}read(e){return this._readable.read(e)}pipe(e,t){return this._readable.pipe(e,t)}unpipe(e){return this._readable.unpipe(e),this}isPaused(){return this._readable.isPaused()}resume(){return this._readable.resume(),this}pause(){return this._readable.pause(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._endGeneration++,this._afterTransformCallback){let t=this._afterTransformCallback;this._afterTransformCallback=null,t(e??null)}this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let t=e=>{let t=e||null;this._readable.destroy(),this._writable.destroy();let n=this._endCallback;this._endCallback=null,this._closed=!0;let r=()=>{n&&n(),t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)};Vn()&&!this._hasDestroyHook()&&this.readableEnded&&this.writableFinished?r():w(r)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._readable._undestroy(),this._writable._undestroy(),this._destroyed=!1,this._closed=!1,this._errored=null,this._setupSideForwarding()}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}_hasConstructHook(){if(this._constructFunc)return!0;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this.writableFinished?t():n(Error(`Premature close`))};this.closed?r():this.once(`close`,r)})}_getWebStream(){if(this._webStream)return this._webStream;let e=this[Symbol.asyncIterator](),t=new ReadableStream({pull:async t=>{let{done:n,value:r}=await e.next();if(n){t.close();return}t.enqueue(r)},cancel:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}}),n=new WritableStream({write:e=>new Promise((t,n)=>{this.write(e,e=>{e?n(e):t()})}),close:()=>new Promise(e=>{this.end(()=>e())}),abort:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}});return this._webStream={readable:t,writable:n},this._webStream}get readable(){return this._readable.readable}set readable(e){this._readable.readable=e}get writable(){return this._writable.writable}set writable(e){this._writable.writable=e}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._ended||this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get readableObjectMode(){return this._readable.readableObjectMode}get readableFlowing(){return this._readable.readableFlowing}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e,this._readable.destroyed=e,this._writable.destroyed=e}cork(){this._writable.cork()}uncork(){this._writable.uncork()}setEncoding(e){return this._readable.setEncoding(e),this}setDefaultEncoding(e){return this._writable.setDefaultEncoding(e),this}unshift(e,t){this._readable.unshift(e,t)}wrap(e){return this._readable.wrap(e),this}iterator(e){return this._readable.iterator(e)}get writableCorked(){return this._writable.writableCorked}get writableNeedDrain(){return this._writable.writableNeedDrain}get writableObjectMode(){return this._writable.writableObjectMode}get readableAborted(){return this._readable.readableAborted}get readableDidRead(){return this._readable.readableDidRead}get readableEncoding(){return this._readable.readableEncoding}get errored(){return this._errored??this._readable.errored??this._writable.errored}get closed(){return this._closed}get readableBuffer(){return this._readable.readableBuffer}get writableBuffer(){return this._writable.writableBuffer}async*[Symbol.asyncIterator](){yield*this._readable[Symbol.asyncIterator]()}map(e,t){return this._readable.map(e,t)}filter(e,t){return this._readable.filter(e,t)}async forEach(e,t){return this._readable.forEach(e,t)}async toArray(e){return this._readable.toArray(e)}async some(e,t){return this._readable.some(e,t)}async find(e,t){return this._readable.find(e,t)}async every(e,t){return this._readable.every(e,t)}flatMap(e,t){return this._readable.flatMap(e,t)}drop(e,t){return this._readable.drop(e,t)}take(e,t){return this._readable.take(e,t)}async reduce(e,t,n){return arguments.length>=2?this._readable.reduce(e,t,n):this._readable.reduce(e)}compose(e,t){return this._readable.compose(e,t)}static isDisturbed(e){return e&&e._readable instanceof T?T.isDisturbed(e._readable):T.isDisturbed(e)}static from(e){return lr.from(e)}static fromWeb(t,n){let r=new e(n);r._webStream=t;let i=T.fromWeb(t.readable,{objectMode:n?.objectMode}),a=ar.fromWeb(t.writable,{objectMode:n?.objectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return e._getWebStream()}_transform(e,t,n){let r=Error(`The _transform() method is not implemented`);throw r.code=`ERR_METHOD_NOT_IMPLEMENTED`,r}_final(e){typeof this._flush==`function`&&!this.destroyed?this._flush((t,n)=>{if(t){e(t);return}n!=null&&this.push(n),this.push(null),e()}):(this.push(null),e())}};ur.prototype.addListener=ur.prototype.on,ur.prototype._writev=null;var dr=class extends ur{_transform(e,t,n){n(null,e)}};let fr=e=>!e||typeof e!=`object`||typeof e.pipe==`function`||typeof e.write==`function`||typeof e.end==`function`||typeof e.getReader==`function`||typeof e.getWriter==`function`?!1:Object.prototype.hasOwnProperty.call(e,`signal`)||Object.prototype.hasOwnProperty.call(e,`end`),pr=e=>`readableEnded`in e||`readable`in e||typeof e.read==`function`,mr=e=>`writableFinished`in e||`writable`in e||typeof e.write==`function`,hr=e=>{let t=!pr(e)||!!e.readableEnded,n=!mr(e)||!!e.writableFinished;return t&&n},gr=()=>{let e=Error(`Premature close`);return e.code=`ERR_STREAM_PREMATURE_CLOSE`,e.name=`Error [ERR_STREAM_PREMATURE_CLOSE]`,e},_r=(e,t,n)=>{let r=e;if(r.closed||r._closed){t();return}`_emitClose`in r&&`_autoDestroy`in r&&r._emitClose!==!1&&r._autoDestroy!==!1?n.once(e,`close`,()=>t()):t()},vr=e=>e instanceof T||e instanceof ar||e instanceof ur||e instanceof lr?e:sn(e)?ur.fromWeb(e):an(e)?T.fromWeb(e):on(e)?ar.fromWeb(e):e,yr=e=>typeof e==`function`&&!(e instanceof T)&&!(e instanceof ar),br=(e,t)=>{let n=t(e);return T.from(n)};function xr(...e){let t,n={},r,a=e[e.length-1];if(typeof a==`function`){r=a;let i=e[e.length-2];fr(i)?(n=i,t=e.slice(0,-2)):t=e.slice(0,-1)}else fr(a)?(n=a,t=e.slice(0,-1)):t=e;let o=new Promise((e,r)=>{if(t.length<2){r(Error(`Pipeline requires at least 2 streams`));return}let a=t.map(vr),o=[],s=[],c=a[0];o.push(c),s.push(c);for(let e=1;e<a.length;e++){let t=a[e];yr(t)?(c=br(c,t),o.push(c),s[s.length-1]=c):(o.push(t),s.push(t),c=t)}let l=s[0],u=s[s.length-1],d=s.slice(1,-1);for(let e of o)if(e.destroyed&&!hr(e)){r(gr());return}let f=!1,p=Jn(),m,h=t=>{if(!f){if(f=!0,m&&n.signal&&n.signal.removeEventListener(`abort`,m),t){let e=()=>{};for(let n of o)typeof n.on==`function`&&n.on(`error`,e),typeof n.destroy==`function`&&!n.destroyed&&n.destroy(t)}p.cleanup(),t?r(t):e()}};if(n.signal){if(n.signal.aborted){h(i(n.signal.reason));return}m=()=>h(i(n.signal.reason)),n.signal.addEventListener(`abort`,m)}c=l;for(let e of d)c.pipe(e),c=e;if(n.end!==!1)c.pipe(u);else{let e=!1,t=!1,n=()=>{t=!1,e&&typeof c.resume==`function`&&(e=!1,c.resume())};p.add(c,`data`,r=>{!u.write(r)&&!t&&(t=!0,!e&&typeof c.pause==`function`&&(e=!0,c.pause()),p.once(u,`drain`,n))}),p.once(c,`end`,()=>{_r(c,h,p)})}n.end!==!1&&p.once(u,`finish`,()=>{_r(u,h,p)});for(let e of o)p.once(e,`close`,()=>{f||hr(e)||h(gr())});for(let e of o)p.once(e,`error`,e=>h(e))});return r&&o.then(()=>r()).catch(e=>r(e)),o}function Sr(e,t,n){let r={},a;typeof t==`function`?a=t:(r=t??{},a=n);let o=new Promise((t,n)=>{let a=vr(e),o=!1,s=Jn(),c,l=()=>{s.cleanup(),c&&r.signal&&r.signal.removeEventListener(`abort`,c)},u=e=>{o||(o=!0,l(),e?n(e):t())};if(r.signal){if(r.signal.aborted){u(i(r.signal.reason));return}c=()=>u(i(r.signal.reason)),r.signal.addEventListener(`abort`,c)}let d=a;if(d.destroyed||d._destroyed){if(d.errored||d._errored)u(d.errored??d._errored);else{let e=`readableEnded`in d||`readable`in d||typeof d.read==`function`,t=`writableFinished`in d||`writable`in d||typeof d.write==`function`,n=r.readable!==!1&&e,i=r.writable!==!1&&t,a=!n||!!(d.readableEnded||d._endEmitted),o=!i||!!(d.writableFinished||d._finished);a&&o?u():u(gr())}return}let f=`readableEnded`in a||`readable`in a||typeof a.read==`function`,p=`writableFinished`in a||`writable`in a||typeof a.write==`function`,m=r.readable!==!1&&f,h=r.writable!==!1&&p,g=!m||!!a.readableEnded,_=!h||!!a.writableFinished,v=a,y=`_emitClose`in v&&`_autoDestroy`in v&&v._emitClose!==!1&&v._autoDestroy!==!1&&!v._closed,b=()=>{if(g&&_){if(y)return;u()}};if(g&&_&&(!y||a.closed)){u();return}h&&!_&&s.once(a,`finish`,()=>{_=!0,b()}),m&&!g&&s.once(a,`end`,()=>{g=!0,b()}),r.error!==!1&&s.once(a,`error`,e=>u(e)),s.once(a,`close`,()=>{let e=g||!!a.readableEnded,t=_||!!a.writableFinished;if(e&&t){g=e,_=t,u(a.errored??a._errored??void 0);return}let n=a.errored??a._errored;if(n){u(n);return}let r=Error(`Premature close`);r.code=`ERR_STREAM_PREMATURE_CLOSE`,r.name=`Error [ERR_STREAM_PREMATURE_CLOSE]`,u(r)})});return a&&o.then(()=>a()).catch(e=>a(e)),o}Wn(e=>lr.from(e));function Cr(e){return e.length<2}function wr(e){return e.length<2}var Tr=class extends ur{constructor(e={}){super({objectMode:e.objectMode!==!1}),this.parseErrorsSink=[],this.buffer=``,this._rowTransform=null,this._rowValidator=null,this.autoDetectDelimiter=!1,this.delimiterDetected=!1,this.chunkBuffer=[],this.totalRowsProcessed=0,this.isFirstChunk=!0,this.chunkAborted=!1,this.beforeFirstChunkApplied=!1,this.bomStripped=!1,this.toLineReached=!1,this.headersEmitted=!1,this.totalCharsProcessed=0,this.backpressure=!1,this.pendingCallback=null,this.options=e,this.chunkSize=e.chunkSize??1e3,this.decoder=new TextDecoder(e.encoding||`utf-8`);let t=e.delimiter??`,`;this.autoDetectDelimiter=t===``;let{config:n}=wt({options:e});this.parseConfig=n,this.parseState=Kt(n),this.scanner=Gt(Et(n)),e.rowTransform&&this.transform(e.rowTransform),e.validate&&this.validate(e.validate)}_read(e){if(this.backpressure&&this.pendingCallback){this.backpressure=!1;let e=this.pendingCallback;this.pendingCallback=null,e()}}transform(e){if(typeof e!=`function`)throw TypeError(`The transform should be a function`);return Cr(e)?this._rowTransform=(t,n)=>{try{n(null,e(t))}catch(e){n(e)}}:this._rowTransform=e,this}validate(e){if(typeof e!=`function`)throw TypeError(`The validate should be a function`);return wr(e)?this._rowValidator=(t,n)=>{try{let r=e(t);typeof r==`boolean`?n(null,r):n(null,r.isValid,r.reason)}catch(e){n(e)}}:this._rowValidator=e,this}_transform(e,t,n){if(this.chunkAborted||this.toLineReached){n();return}try{let t=typeof e==`string`?e:this.decoder.decode(e,{stream:!0});if(this.buffer+=t,!this.beforeFirstChunkApplied&&this.options.beforeFirstChunk){this.beforeFirstChunkApplied=!0;let e=this.options.beforeFirstChunk(this.buffer);typeof e==`string`&&(this.buffer=e)}if(this.bomStripped||=(this.buffer=g(this.buffer),!0),this.autoDetectDelimiter&&!this.delimiterDetected){let e=this.options.comment,t=!1,n=0,r=this.buffer.length;for(;n<r;){let i=n;for(;i<r&&this.buffer[i]!==`
38
38
  `&&this.buffer[i]!==`\r`;)i++;let a=this.buffer.slice(n,i).trim();if(a!==``&&(!e||!a.startsWith(e))){t=!0;break}if(n=i,n<r&&this.buffer[n]===`\r`&&n++,n<r&&this.buffer[n]===`
39
39
  `&&n++,n===i)break}if(t){let e=this.options.skipEmptyLines;this.parseConfig.delimiter=y(this.buffer,this.parseConfig.quote||`"`,this.options.delimitersToGuess,this.options.comment,e),this.delimiterDetected=!0,this.emit(`delimiter`,this.parseConfig.delimiter),this.scanner=Gt(Et(this.parseConfig))}}this.processBuffer(n)}catch(e){n(e)}}_flush(e){if(this.chunkAborted||this.toLineReached){e();return}try{let t=this.decoder.decode();if(t&&(this.buffer+=t),this.buffer){this.processBuffer(t=>{if(t){e(t);return}this.flushCurrentRow(t=>{if(t){e(t);return}this.flushFinalChunk(e)})});return}this.flushCurrentRow(t=>{if(t){e(t);return}this.flushFinalChunk(e)})}catch(t){e(t)}}_destroy(e,t){this.pendingCallback=null,this.backpressure=!1,this.buffer=``,this.chunkBuffer=[],this.scanner.reset(),t(e)}flushCurrentRow(e){if(this.toLineReached){e();return}if(this.parseConfig.fastMode){this.flushFastModeRemainder(e);return}let t=this.scanner.flush();if(!t||t.fields.length===0){e();return}let n=this.parseConfig.trimFieldIsIdentity?t.fields.slice():t.fields.map(this.parseConfig.trimField),r=[],i=this._handleParsedRow({fields:n,charLength:0,raw:t.raw,quoted:t.quoted,pendingRows:r,shouldSkipEmpty:this.options.skipEmptyLines||!1,skipLines:this.options.skipLines??0,callback:e});i===`stop`||i===`error`||this.processPendingRows(r,e)}flushFastModeRemainder(e){let t=this.buffer;if(this.buffer=``,t.endsWith(`\r`)&&(t=t.slice(0,-1)),t===``){e();return}let n=[],r=t.split(this.parseConfig.delimiter),i=this.parseConfig.trimFieldIsIdentity?r:r.map(this.parseConfig.trimField),a=this.parseConfig.infoOption?Yt(i.length):void 0,o=this._handleParsedRow({fields:i,charLength:0,raw:t,quoted:a,pendingRows:n,shouldSkipEmpty:this.options.skipEmptyLines||!1,skipLines:this.options.skipLines??0,callback:e});o===`stop`||o===`error`||this.processPendingRows(n,e)}pushBufferedRows(e){let t=this.options.objectMode===!1;for(let n of e)if(!this.push(t?JSON.stringify(n):n))return!1;return!0}pushRow(e){let t=this.options.objectMode===!1;return this.push(t?JSON.stringify(e):e)}invokeChunkCallback(e,t,n){let r=this.options.chunk(e,t);r instanceof Promise?r.then(e=>{e===!1&&(this.chunkAborted=!0),n()}).catch(e=>n(e)):(r===!1&&(this.chunkAborted=!0),n())}flushFinalChunk(e){if(this.chunkBuffer.length>0&&this.options.chunk){let t=this.chunkBuffer.length,n={cursor:this.totalRowsProcessed-t,rowCount:t,isFirstChunk:this.isFirstChunk,isLastChunk:!0};this.pushBufferedRows(this.chunkBuffer);let r=this.chunkBuffer;this.chunkBuffer=[],this.invokeChunkCallback(r,n,e)}else e()}processBuffer(e){let{skipEmptyLines:t=!1,skipLines:n=0}=this.options,r=t;if(this.parseConfig.fastMode){this.processBufferFastMode(e,r);return}let i=[];this.scanner.feed(this.buffer),this.buffer=``;let a;for(;(a=this.scanner.nextRow())!==null;){let t=a.raw,o=(a.raw?.length??0)+(a.newline?.length??0),s=this.parseConfig.trimFieldIsIdentity?a.fields.slice():a.fields.map(this.parseConfig.trimField),c=this._handleParsedRow({fields:s,charLength:o,raw:t,quoted:a.quoted,pendingRows:i,shouldSkipEmpty:r,skipLines:n,callback:e});if(c===`stop`||c===`error`)return}this.processPendingRows(i,e)}getFastModeCompleteDataEnd(e){let{linebreakRegex:t}=this.parseConfig;if(typeof t==`string`){let n=t;if(n===``)return-1;let r=e.length-n.length;if(r<0)return-1;let i=e.lastIndexOf(n,r);return i===-1?-1:i+n.length}if(t===je){let t=e.lastIndexOf(`
40
40
  `),n=e.lastIndexOf(`\r`),r;return r=n>t?n===e.length-1?t:n:t,r===-1?-1:r+1}let n=new RegExp(t.source,`${t.flags}g`),r=-1;for(let t=n.exec(e);t;t=n.exec(e))r=t.index+t[0].length,t[0].length===0&&n.lastIndex++;return r}processBufferFastMode(e,t){let{skipLines:n=0}=this.options,r=[],i=this.getFastModeCompleteDataEnd(this.buffer);if(i===-1){e();return}let a=this.buffer.slice(0,i);this.buffer=this.buffer.slice(i);for(let{line:i,lineLengthWithEnding:o}of At(a,this.parseConfig.linebreakRegex)){if(i===``&&t){this.parseState.lineNumber++,this.totalCharsProcessed+=o;continue}let a=i.split(this.parseConfig.delimiter),s=this.parseConfig.trimFieldIsIdentity?a:a.map(this.parseConfig.trimField),c=this.parseConfig.infoOption?Yt(s.length):void 0,l=this._handleParsedRow({fields:s,charLength:o,raw:i,quoted:c,pendingRows:r,shouldSkipEmpty:t,skipLines:n,callback:e});if(l===`stop`||l===`error`)return}this.processPendingRows(r,e)}buildRow(e,t){let{dynamicTyping:n,castDate:r,groupColumnsByName:i=!1}=this.options,a;if(this.options.headers&&this.parseState.headerRow){let t=xt(e,this.parseState.headerRow,this.parseState.originalHeaders,i);a=n||r?ht(t,n||!1,r):t}else a=n||r?gt(e,this.parseState.headerRow?Ct(this.parseState.headerRow):null,n||!1,r):e;return this.parseConfig.infoOption?(t||={index:0,line:this.parseState.currentRowStartLine,offset:this.parseState.currentRowStartOffset,quoted:[...this.parseState.currentRowQuoted],raw:this.parseConfig.rawOption?this.parseState.currentRawRow:void 0},{record:a,info:t}):a}_handleParsedRow(e){let{fields:t,charLength:n,raw:r,quoted:i,pendingRows:a,shouldSkipEmpty:o,skipLines:s,callback:c}=e,l=this.parseState.lineNumber+1;if(r!==void 0){let e=1;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);n===10?e++:n===13&&(t+1<r.length&&r.charCodeAt(t+1)===10&&t++,e++)}this.parseState.lineNumber+=e}else this.parseState.lineNumber++;let{toLine:u}=this.options;return u!==void 0&&this.parseState.lineNumber>u?(this.toLineReached=!0,this.totalCharsProcessed+=n,this.processPendingRows(a,c),`stop`):this.parseState.lineNumber<=s?(this.totalCharsProcessed+=n,`skip`):(this.parseConfig.infoOption&&(this.parseState.currentRowStartLine=l,this.parseState.currentRowStartOffset=this.totalCharsProcessed,i&&(this.parseState.currentRowQuoted=i)),this.totalCharsProcessed+=n,r!==void 0&&this.parseConfig.maxRowBytes!==void 0&&Ie(r)>this.parseConfig.maxRowBytes?(c(Error(`Row exceeds the maximum size of ${this.parseConfig.maxRowBytes} bytes`)),`error`):(this.parseConfig.rawOption&&r!==void 0&&(this.parseState.currentRawRow=r),this.shouldSkipRow(t,o)?`skip`:this.processCompletedRow(t,a)?`continue`:(this.processPendingRows(a,c),`stop`)))}processCompletedRow(e,t){let n=It(e,this.parseState,this.parseConfig,this.parseErrorsSink,this.parseState.lineNumber);if(this.parseErrorsSink.length=0,this.emitHeaders(),n.reason&&this.emit(`data-invalid`,e,n.reason),n.stop)return!1;if(n.skipped)return!0;if(n.row){let e=this.buildRow(n.row,n.info);if(n.extras&&n.extras.length>0){let t=this.parseConfig.infoOption?e.record:e;t._extra=n.extras}t.push(e)}return!0}emitHeaders(){!this.headersEmitted&&this.parseState.headerRow&&(this.headersEmitted=!0,this.emit(`headers`,Ct(this.parseState.headerRow)))}shouldSkipRow(e,t){return Ft(e,this.parseConfig.comment,t,!1)}processPendingRows(e,t){if(e.length===0){t();return}if(this.chunkAborted){t();return}if(!this._rowTransform&&!this._rowValidator){let n=0,r=()=>{for(;n<e.length&&!this.chunkAborted;){let i=e[n++];if(this.options.chunk){if(this.chunkBuffer.push(i),this.totalRowsProcessed++,this.chunkBuffer.length>=this.chunkSize){this.flushChunk(e=>{if(e){t(e);return}if(this.chunkAborted){t();return}n%1e3==0?setTimeout(r,0):r()});return}}else if(!this.pushRow(i)){this.backpressure=!0,this.pendingCallback=()=>r();return}}t()};r();return}let n=0,r=()=>{if(n>=e.length){t();return}let i=e[n++];this.transformAndValidateRow(i,(e,i)=>{if(e){t(e);return}if(i&&i.isValid&&i.row!==null){if(this.options.chunk){if(this.chunkBuffer.push(i.row),this.totalRowsProcessed++,this.chunkBuffer.length>=this.chunkSize){this.flushChunk(e=>{if(e){t(e);return}n%1e3==0?setTimeout(r,0):r()});return}}else if(!this.pushRow(i.row)){this.backpressure=!0,this.pendingCallback=()=>r();return}}else i&&!i.isValid&&this.emit(`data-invalid`,i.row,i.reason);n%1e3==0?setTimeout(r,0):r()})};r()}flushChunk(e){if(this.chunkBuffer.length===0||!this.options.chunk){e();return}let t=this.chunkBuffer.length,n={cursor:this.totalRowsProcessed-t,rowCount:t,isFirstChunk:this.isFirstChunk,isLastChunk:!1};this.isFirstChunk=!1;let r=this.chunkBuffer;this.chunkBuffer=[],this.pushBufferedRows(r),this.invokeChunkCallback(r,n,e)}transformAndValidateRow(e,t){this._rowTransform?this._rowTransform(e,(e,n)=>{if(e){t(e);return}if(n==null){t(null,{row:null,isValid:!0});return}this.validateRow(n,t)}):this.validateRow(e,t)}validateRow(e,t){this._rowValidator?this._rowValidator(e,(n,r,i)=>{if(n){t(n);return}t(null,{row:e,isValid:r??!1,reason:i})}):t(null,{row:e,isValid:!0})}};function Er(e={}){return new Tr(e)}var Dr=class extends ur{constructor(e={}){super({objectMode:e.objectMode!==!1,writableObjectMode:e.objectMode!==!1}),this.headerWritten=!1,this.keys=null,this.displayHeaders=null,this.sourceRowIndex=0,this.outputRowIndex=0,this.options=e,this.formatConfig=re(e);let t=this.formatConfig;this.rowOptions={quoteLookup:t.shouldQuoteColumn,delimiter:t.delimiter,headers:void 0,isHeader:!1,outputRowIndex:0,quoteAll:t.quoteAll,escapeFormulae:t.escapeFormulae,decimalSeparator:t.decimalSeparator,transform:t.typeTransform};let n=_e(e.columns);n?(this.keys=n.keys,this.displayHeaders=n.headers):Array.isArray(e.headers)&&(this.keys=e.headers,this.displayHeaders=e.headers),this.displayHeaders&&=he(this.displayHeaders)}detectHeadersFromRow(e){let t=me(e);t.length>0&&(this.keys=t,this.displayHeaders=he(t))}_transform(e,t,n){try{!this.headerWritten&&this.formatConfig.bom&&this.push(``),this.headerWritten||=(this.options.headers===!0&&!this.keys&&this.detectHeadersFromRow(e),this.formatConfig.writeHeaders&&this.displayHeaders&&this.push(this.formatRow(this.displayHeaders,!0)),!0);let t=e,r=this.sourceRowIndex++;if(this.formatConfig.typeTransform?.row&&(t=this.formatConfig.typeTransform.row(e,r),t===null)){n();return}this.formatAndPush(t),this.outputRowIndex++,n()}catch(e){n(e)}}_destroy(e,t){this.keys=null,this.displayHeaders=null,t(e)}_flush(e){!this.headerWritten&&this.displayHeaders&&this.formatConfig.writeHeaders&&(this.formatConfig.bom&&this.push(``),this.push(this.formatRow(this.displayHeaders,!0)),this.headerWritten=!0);let t=this.formatConfig.writeHeaders&&this.displayHeaders||this.outputRowIndex>0;this.formatConfig.trailingNewline&&t&&this.push(this.formatConfig.lineEnding),e()}formatAndPush(e){let t=pe(e,this.keys);this.push(this.formatRow(t,!1))}formatRow(e,t=!1){let n=this.formatConfig,r=this.rowOptions;r.quoteLookup=t?n.shouldQuoteHeader:n.shouldQuoteColumn,r.headers=this.displayHeaders??void 0,r.isHeader=t,r.outputRowIndex=this.outputRowIndex;let i=De(e,n.regex,r);return t||!(n.writeHeaders&&this.displayHeaders)&&this.outputRowIndex===0?i:n.lineEnding+i}};function Or(e={}){return new Dr(e)}function E(){throw Error("No chart support is installed. Call `installChartSupport()` from `@cj-tech-master/excelts/chart` once at startup to enable chart creation, loading, and serialisation during `workbook.xlsx.writeFile()`.")}function kr(){return null}var Ar=class{constructor(e,t,n){this.id=t,this.name=n,this.workbook=e}_unsupported(e){throw Error(`${e}() is not supported on a Chart attached to a chartsheet. Use the Chartsheet APIs (chartsheet.chartModel, chartsheet.replaceChart, …) instead.`)}getRow(e){this._unsupported(`Worksheet.getRow`)}addRow(){this._unsupported(`Worksheet.addRow`)}addRows(){this._unsupported(`Worksheet.addRows`)}getColumn(e){this._unsupported(`Worksheet.getColumn`)}getCell(){this._unsupported(`Worksheet.getCell`)}addTable(){this._unsupported(`Worksheet.addTable`)}getTables(){this._unsupported(`Worksheet.getTables`)}},jr=class{constructor(e,t){this._model=e,this._workbook=t}get id(){return this._model.id}get sheetNo(){return this._model.sheetNo}get name(){return this._model.name}set name(e){this._workbook?this._model.name=this._workbook.validateSheetName(e,this._model):this._model.name=e}get state(){return this._model.state}set state(e){this._model.state=e}get chartNumber(){return this._model.chartNumber}get chartExNumber(){return this._model.chartExNumber}get chartModel(){return this._model.chartNumber?this._workbook?.getChartEntry(this._model.chartNumber)?.model:void 0}get chartExModel(){return this._model.chartExNumber?this._workbook?.getChartExStructuredEntry(this._model.chartExNumber)?.model:void 0}get chart(){if(!this._workbook||!this._model.chartNumber&&!this._model.chartExNumber)return;let e=new Ar(this._workbook,this._model.id,this._model.name);return E().createChart(e,{chartNumber:this._model.chartNumber,chartExNumber:this._model.chartExNumber},`A1:K15`)}get isChartEx(){return!!this._model.chartExNumber}get model(){return this._model}get pageMargins(){return this._model.pageMargins}set pageMargins(e){this._model.pageMargins=e}get pageSetup(){return this._model.pageSetup}set pageSetup(e){this._model.pageSetup=e}get tabSelected(){return this._model.tabSelected}set tabSelected(e){this._model.tabSelected=e}get zoomScale(){return this._model.zoomScale}set zoomScale(e){this._model.zoomScale=e}get workbookViewId(){return this._model.workbookViewId}set workbookViewId(e){this._model.workbookViewId=e}get zoomToFit(){return this._model.zoomToFit}set zoomToFit(e){this._model.zoomToFit=e}rename(e){return this._workbook?.renameChartsheet(this.name,e)??!1}remove(){return this._workbook?.removeChartsheet(this.name)??!1}copy(e){return this._workbook?.copyChartsheet(this.name,e)}replaceChart(e){return this._workbook?.replaceChartsheetChart(this.name,e)??!1}},Mr=class extends n{constructor(e,t){super(e,t),this.name=`ExcelError`}};function Nr(e){return e instanceof Mr}var Pr=class extends Mr{constructor(...e){super(...e),this.name=`WorksheetNameError`}},Fr=class extends Mr{constructor(e,t,n){super(t?`Invalid address "${e}": ${t}`:`Invalid address: ${e}`,n),this.address=e,this.name=`InvalidAddressError`}},Ir=class extends Mr{constructor(e,t,n){super(t?`Column ${e} is out of bounds: ${t}`:`Column ${e} is out of bounds. Excel supports columns from 1 to 16384`,n),this.column=e,this.name=`ColumnOutOfBoundsError`}},Lr=class extends Mr{constructor(e,t,n){super(t?`Row ${e} is out of bounds: ${t}`:`Row ${e} is out of bounds`,n),this.row=e,this.name=`RowOutOfBoundsError`}},Rr=class extends Mr{constructor(e,t){super(e??`Cannot merge already merged cells`,t),this.name=`MergeConflictError`}},zr=class extends Mr{constructor(e,t,n){super(t??`Cannot process value of type: ${e}`,n),this.valueType=e,this.name=`InvalidValueTypeError`}},Br=class extends Mr{constructor(e,t,n){super(t??`Unexpected XML content in ${e}`,n),this.context=e,this.name=`XmlParseError`}},Vr=class extends Mr{constructor(e,t,n){super(t?`${e}: ${t}`:`${e} is not supported`,n),this.operation=e,this.reason=t,this.name=`ExcelNotSupportedError`}},Hr=class extends Mr{constructor(e,t,n,r){super(n?`Failed to ${t} Excel file "${e}": ${n}`:`Failed to ${t} Excel file "${e}"`,r),this.path=e,this.operation=t,this.name=`ExcelFileError`}},Ur=class extends Mr{constructor(e,t,n){super(`Cannot ${e}: ${t}`,n),this.operation=e,this.state=t,this.name=`ExcelStreamStateError`}},Wr=class extends Mr{constructor(e,t,n,r){super(`Failed to download from "${e}": HTTP ${t} ${n}`,r),this.url=e,this.status=t,this.statusText=n,this.name=`ExcelDownloadError`}},Gr=class extends Mr{constructor(...e){super(...e),this.name=`PivotTableError`}},Kr=class extends Mr{constructor(...e){super(...e),this.name=`ChartOptionsError`}},qr=class extends Mr{constructor(...e){super(...e),this.name=`TableError`}},Jr=class extends Mr{constructor(...e){super(...e),this.name=`ImageError`}},Yr=class extends Mr{constructor(e,t,n){super(`Max ${e} count (${t}) exceeded`,n),this.itemType=e,this.maxItems=t,this.name=`MaxItemsExceededError`}};let Xr=/^[A-Z]+\d+$/,D={_dictionary:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``),_l2nFill:0,_l2n:{},_n2l:[],_level(e){return e<=26?1:e<=676?2:3},_fill(e){let t,n,r,i,a,o=1;if(e>=4)throw new Ir(e,`Excel supports columns from 1 to 16384`);if(this._l2nFill<1&&e>=1){for(;o<=26;)t=this._dictionary[o-1],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=1}if(this._l2nFill<2&&e>=2){for(o=27;o<=702;)n=o-27,r=n%26,i=Math.floor(n/26),t=this._dictionary[i]+this._dictionary[r],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=2}if(this._l2nFill<3&&e>=3){for(o=703;o<=16384;)n=o-703,r=n%26,i=Math.floor(n/26)%26,a=Math.floor(n/676),t=this._dictionary[a]+this._dictionary[i]+this._dictionary[r],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=3}},l2n(e){if(this._l2n[e]||this._fill(e.length),!this._l2n[e])throw new Ir(e,`Invalid column letter: ${e}`);return this._l2n[e]},n2l(e){if(e<1||e>16384)throw new Ir(e);return this._n2l[e]||this._fill(this._level(e)),this._n2l[e]},_hash:{},decodeCol(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>=65&&r<=90)t=t*26+r-64;else break}return t},validateAddress(e){if(!Xr.test(e))throw new Fr(e);return!0},decodeAddress(e){if(!e||typeof e!=`string`)throw Error(`Invalid Address: ${e}`);let t=e.length<5&&this._hash[e];if(t)return t;let n=0,r=0,i=!1,a=!1,o=0,s=0;for(let t=0;t<e.length;t++){let c=e.charCodeAt(t);if(c===36){!i&&!a&&(s=t+1);continue}if(!a&&c>=65&&c<=90)i=!0,n=n*26+c-64,o=t+1;else if(c>=48&&c<=57)a=!0,r=r*10+c-48;else if(a&&i)break}if(!i)n=void 0;else if(n>16384){let t=e.slice(0,o);throw new Ir(t,`Invalid column letter: ${t}`)}a||(r=void 0);let c=i?e.slice(s,o):``,l=a?String(r):``,u=c+l,d={address:u,col:n,row:r,$col$row:`$${c}$${l}`};return n<=100&&r<=100&&(this._hash[u]=d,this._hash[d.$col$row]=d),d},getAddress(e,t){if(t){let n=this.n2l(t)+e;return this.decodeAddress(n)}return this.decodeAddress(e)},decode(e){if(!e||typeof e!=`string`)throw Error(`Invalid Address: ${e}`);let t=e.split(`:`);if(t.length===2){let e=this.decodeAddress(t[0]),n=this.decodeAddress(t[1]),r={top:Math.min(e.row,n.row),left:Math.min(e.col,n.col),bottom:Math.max(e.row,n.row),right:Math.max(e.col,n.col),tl:``,br:``,dimensions:``};return r.tl=this.n2l(r.left)+r.top,r.br=this.n2l(r.right)+r.bottom,r.dimensions=`${r.tl}:${r.br}`,r}return this.decodeAddress(e)},decodeEx(e){if(!e||typeof e!=`string`)throw Error(`Invalid Address: ${e}`);let t=e.match(/^(?:(?:(?:'((?:[^']|'')+?)')|([^'^ !]+?))!)?(.*)$/),n=t[1]||t[2],r=t[3],i=r.split(`:`);if(i.length>1){let e=this.decodeAddress(i[0]),t=this.decodeAddress(i[1]),r=Math.min(e.row,t.row),a=Math.min(e.col,t.col),o=Math.max(e.row,t.row),s=Math.max(e.col,t.col),c=this.n2l(a)+r,l=this.n2l(s)+o;return{top:r,left:a,bottom:o,right:s,sheetName:n,tl:{address:c,col:a,row:r,$col$row:`$${this.n2l(a)}$${r}`,sheetName:n},br:{address:l,col:s,row:o,$col$row:`$${this.n2l(s)}$${o}`,sheetName:n},dimensions:`${c}:${l}`}}if(r.indexOf(`#`)===0)return n?{sheetName:n,error:r}:{error:r};let a=this.decodeAddress(r);return n?{sheetName:n,...a}:a},encodeAddress(e,t){return D.n2l(t)+e},encode(...e){switch(e.length){case 2:return D.encodeAddress(e[0],e[1]);case 4:return`${D.encodeAddress(e[0],e[1])}:${D.encodeAddress(e[2],e[3])}`;default:throw new Fr(String(e.length),`Can only encode with 2 or 4 arguments`)}},compareAddress(e,t){let n=D.decodeAddress(e),r=D.decodeAddress(t);return n.col-r.col||n.row-r.row},inRange(e,t){let[n,r,,i,a]=e,[o,s]=t;return o>=n&&o<=i&&s>=r&&s<=a}};var Zr=class e{constructor(...e){this.model={top:0,left:0,bottom:0,right:0},this.decode(e)}setTLBR(e,t,n,r,i){if(typeof e==`string`&&typeof t==`string`){let r=D.decodeAddress(e),i=D.decodeAddress(t);this.model={top:Math.min(r.row,i.row),left:Math.min(r.col,i.col),bottom:Math.max(r.row,i.row),right:Math.max(r.col,i.col),sheetName:typeof n==`string`?n:void 0}}else typeof e==`number`&&typeof t==`number`&&typeof n==`number`&&typeof r==`number`&&(this.model={top:Math.min(e,n),left:Math.min(t,r),bottom:Math.max(e,n),right:Math.max(t,r),sheetName:i})}decode(t){switch(t.length){case 5:typeof t[0]==`number`&&typeof t[1]==`number`&&typeof t[2]==`number`&&typeof t[3]==`number`&&typeof t[4]==`string`&&this.setTLBR(t[0],t[1],t[2],t[3],t[4]);break;case 4:typeof t[0]==`number`&&typeof t[1]==`number`&&typeof t[2]==`number`&&typeof t[3]==`number`&&this.setTLBR(t[0],t[1],t[2],t[3]);break;case 3:typeof t[0]==`string`&&typeof t[1]==`string`&&typeof t[2]==`string`&&this.setTLBR(t[0],t[1],t[2]);break;case 2:typeof t[0]==`string`&&typeof t[1]==`string`&&this.setTLBR(t[0],t[1]);break;case 1:{let n=t[0];if(n instanceof e)this.model={top:n.model.top,left:n.model.left,bottom:n.model.bottom,right:n.model.right,sheetName:n.sheetName};else if(Array.isArray(n))this.decode(n);else if(typeof n==`object`&&`top`in n&&`left`in n&&`bottom`in n&&`right`in n)this.model={top:n.top,left:n.left,bottom:n.bottom,right:n.right,sheetName:n.sheetName};else if(typeof n==`string`){let e=D.decodeEx(n);`top`in e?this.model={top:e.top,left:e.left,bottom:e.bottom,right:e.right,sheetName:e.sheetName}:`row`in e&&(this.model={top:e.row,left:e.col,bottom:e.row,right:e.col,sheetName:e.sheetName})}break}case 0:this.model={top:0,left:0,bottom:0,right:0};break;default:throw new Mr(`Invalid number of arguments to _getDimensions() - ${t.length}`)}}get top(){return this.model.top||1}set top(e){this.model.top=e}get left(){return this.model.left||1}set left(e){this.model.left=e}get bottom(){return this.model.bottom||1}set bottom(e){this.model.bottom=e}get right(){return this.model.right||1}set right(e){this.model.right=e}get sheetName(){return this.model.sheetName}set sheetName(e){this.model.sheetName=e}get _serialisedSheetName(){let{sheetName:e}=this.model;return e?/^[a-zA-Z0-9]*$/.test(e)?`${e}!`:`'${e.replace(/'/g,`''`)}'!`:``}expand(e,t,n,r){(!this.model.top||e<this.top)&&(this.top=e),(!this.model.left||t<this.left)&&(this.left=t),(!this.model.bottom||n>this.bottom)&&(this.bottom=n),(!this.model.right||r>this.right)&&(this.right=r)}expandRow(e){if(e){let{dimensions:t,number:n}=e;t&&this.expand(n,t.min,n,t.max)}}expandToAddress(e){let t=D.decodeEx(e);`row`in t&&`col`in t&&this.expand(t.row,t.col,t.row,t.col)}get tl(){return D.n2l(this.left)+this.top}get $t$l(){return`$${D.n2l(this.left)}$${this.top}`}get br(){return D.n2l(this.right)+this.bottom}get $b$r(){return`$${D.n2l(this.right)}$${this.bottom}`}get range(){return`${this._serialisedSheetName+this.tl}:${this.br}`}get $range(){return`${this._serialisedSheetName+this.$t$l}:${this.$b$r}`}get shortRange(){return this.count>1?this.range:this._serialisedSheetName+this.tl}get $shortRange(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}get count(){return(1+this.bottom-this.top)*(1+this.right-this.left)}toString(){return this.range}intersects(e){return!(e.sheetName&&this.sheetName&&e.sheetName!==this.sheetName||e.bottom<this.top||e.top>this.bottom||e.right<this.left||e.left>this.right)}contains(e){let t=D.decodeEx(e);return`row`in t&&`col`in t?this.containsEx(t):!1}containsEx(e){return e.sheetName&&this.sheetName&&e.sheetName!==this.sheetName?!1:e.row>=this.top&&e.row<=this.bottom&&e.col>=this.left&&e.col<=this.right}forEachAddress(e){for(let t=this.left;t<=this.right;t++)for(let n=this.top;n<=this.bottom;n++)e(D.encodeAddress(n,t),n,t)}};function Qr(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>Qr(e));let t={};for(let n of Object.keys(e))n!==`__proto__`&&n!==`constructor`&&n!==`prototype`&&(t[n]=Qr(e[n]));return t}var $r=class{constructor(e){this.template=e,this.sheets=new Map}addCell(e){this.addCellEx(D.decodeEx(e))}getCell(e){return this.findCellEx(D.decodeEx(e),!0)}findCell(e){return this.findCellEx(D.decodeEx(e),!1)}findCellAt(e,t,n){let r=this.sheets.get(e),i=r&&r[t];return i&&i[n]}addCellEx(e){if(e.top!==void 0)for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++)this.getCellAt(e.sheetName,t,n);else this.findCellEx(e,!0)}getCellEx(e){return this.findCellEx(e,!0)}findCellEx(e,t){let n=this.findSheet(e,t),r=this.findSheetRow(n,e,t);return this.findRowCell(r,e,t)}getCellAt(e,t,n){let r=this.sheets.get(e);r||(r=[],this.sheets.set(e,r));let i=t>>>0,a=n>>>0,o=r[i]||(r[i]=[]);return o[a]||(o[a]={sheetName:e,address:D.n2l(n)+t,row:t,col:n})}removeCellEx(e){let t=this.findSheet(e,!1);if(!t)return;let n=this.findSheetRow(t,e,!1);n&&(n[e.col>>>0]=void 0)}forEachInSheet(e,t){let n=this.sheets.get(e);n&&n.forEach((e,n)=>{e&&e.forEach((e,r)=>{e&&t(e,n,r)})})}forEach(e){for(let t of this.sheets.keys())this.forEachInSheet(t,e)}map(e){let t=[];return this.forEach(n=>{t.push(e(n))}),t}findSheet(e,t){let n=e.sheetName;if(this.sheets.has(n))return this.sheets.get(n);if(t){let e=[];return this.sheets.set(n,e),e}}findSheetRow(e,t,n){let r=t.row>>>0;if(e&&e[r])return e[r];if(n)return e[r]=[]}findRowCell(e,t,n){let r=t.col>>>0;if(e&&e[r])return e[r];if(n)return e[r]=this.template?{...t,...Qr(this.template)}:t}spliceRows(e,t,n,r){let i=this.sheets.get(e);if(i){let e=[];for(let t=0;t<r;t++)e.push([]);i.splice(t,n,...e)}}spliceColumns(e,t,n,r){let i=this.sheets.get(e);if(i){let e=[];for(let t=0;t<r;t++)e.push(null);i.forEach(r=>{r.splice(t,n,...e)})}}};function ei(){return null}let ti=/[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/,ni=/^[$]?[A-Za-z]{1,3}[$]?\d+(:[$]?[A-Za-z]{1,3}[$]?\d+)?$/,ri=/^[$]?\d+:[$]?\d+$/,ii=/^[$]?[A-Za-z]{1,3}:[$]?[A-Za-z]{1,3}$/;function ai(e){if(e.startsWith(`{`)||e.endsWith(`}`))return!1;let t=e.split(`!`).pop()??``;if(!ni.test(t)&&!ri.test(t)&&!ii.test(t))return!1;try{let t=D.decodeEx(e);return`row`in t&&typeof t.row==`number`||`top`in t&&typeof t.top==`number`||`left`in t&&typeof t.left==`number`}catch{return!1}}function oi(e){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`))return[];let n=[],r=!1,i=``;return e.split(`,`).forEach(e=>{if(!e)return;let t=(e.match(/'/g)??[]).length;if(!t){r?i+=`${e},`:ai(e)&&n.push(e);return}let a=t%2==0;!r&&a&&ai(e)?n.push(e):r&&!a?(r=!1,ai(i+e)&&n.push(i+e),i=``):(r=!0,i+=`${e},`)}),n}function si(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];if(r===`'`)t=!t;else if(r===`(`&&!t)return!0}return!1}function ci(e,t,n){if(e===void 0)return t.length>0?{kind:`reference`,ranges:t}:{kind:`opaque`,ranges:[]};let r=e.trim();if(r.length===0)return{kind:`opaque`,ranges:[]};let i=r.startsWith(`{`)&&r.endsWith(`}`),a=r.startsWith(`"`)&&r.endsWith(`"`),o=r.startsWith(`#`),s=i||a||o;if(si(r)&&!s)return n&&n(r)?{kind:`formula`,ranges:[r],formulaExpression:r}:{kind:`opaque`,ranges:[]};let c=oi(e);return c.length>0?{kind:`reference`,ranges:c}:s?{kind:`opaque`,ranges:[]}:n&&n(r)?{kind:`formula`,ranges:[r],formulaExpression:r}:{kind:`opaque`,ranges:[]}}function li(e,t){return t===void 0?e:`${e}\0${t}`}var ui=class{constructor(e){this.matrixMap={},this.formulaMap={},this.localSheetIdMap={},this.hiddenMap={},this.opaqueMap={},this.nameForKey={},this._explicitProbe=e??null}getMatrix(e){return this.matrixMap[e]||(this.matrixMap[e]=new $r)}add(e,t){let n=D.decodeEx(e);`error`in n||(delete this.formulaMap[t],delete this.opaqueMap[t],this.nameForKey[t]=t,this.addEx(n,t))}addHidden(e,t){this.add(e,t),this.hiddenMap[t]=!0}addEx(e,t){let n=this.getMatrix(t);if(`top`in e)for(let t=e.left;t<=e.right;t++)for(let r=e.top;r<=e.bottom;r++){let i={sheetName:e.sheetName,address:D.n2l(t)+r,row:r,col:t};n.addCellEx(i)}else n.addCellEx(e)}addFormula(e,t){delete this.matrixMap[e],delete this.opaqueMap[e],this.nameForKey[e]=e,this.formulaMap[e]=t}remove(e,t){let n=D.decodeEx(e);`error`in n||this.removeEx(n,t)}removeEx(e,t){let n=this.getMatrix(t);if(`top`in e)for(let t=e.left;t<=e.right;t++)for(let r=e.top;r<=e.bottom;r++)n.removeCellEx({sheetName:e.sheetName,address:D.n2l(t)+r,row:r,col:t});else n.removeCellEx(e)}removeAllNames(e){Object.values(this.matrixMap).forEach(t=>{if(`top`in e)for(let n=e.left;n<=e.right;n++)for(let r=e.top;r<=e.bottom;r++)t.removeCellEx({sheetName:e.sheetName,address:D.n2l(n)+r,row:r,col:n});else t.removeCellEx(e)})}forEach(e){Object.entries(this.matrixMap).forEach(([t,n])=>{let r=this.nameForKey[t]??t;n.forEach(t=>{e(r,t)})})}getNames(e){let t=D.decodeEx(e);return`error`in t||`top`in t?[]:this.getNamesEx(t)}getNamesEx(e){return Object.entries(this.matrixMap).map(([t,n])=>n.findCellEx(e,!1)&&(this.nameForKey[t]??t)).filter(e=>!!e)}getAllNames(){return this.getAllEntries().map(e=>e.localSheetId===void 0?{name:e.name}:{name:e.name,localSheetId:e.localSheetId})}getAllEntries(){let e=[],t=new Set;for(let n of Object.keys(this.matrixMap)){if(t.has(n))continue;t.add(n);let r=this.getRanges(n),i=this.localSheetIdMap[n];e.push(i===void 0?r:{...r,localSheetId:i})}for(let n of Object.keys(this.formulaMap)){if(t.has(n))continue;t.add(n);let r=this.getRanges(n),i=this.localSheetIdMap[n];e.push(i===void 0?r:{...r,localSheetId:i})}for(let n of Object.keys(this.opaqueMap)){if(t.has(n))continue;t.add(n);let r=this.nameForKey[n]??n,i=this.opaqueMap[n];e.push({name:r,ranges:[],rawText:i.rawText,localSheetId:i.localSheetId,kind:`opaque`})}return e}_explore(e,t){t.mark=!1;let n=t.sheetName,r=new Zr(t.row,t.col,t.row,t.col,n),i,a,o=(t,r)=>e.findCellAt(n,t,r);function s(e,n){let i=o(e,t.col);return!i||!i.mark?!1:(r[n]=e,i.mark=!1,!0)}for(a=t.row-1;s(a,`top`);a--);for(a=t.row+1;s(a,`bottom`);a++);function c(e,t){let n=[];for(a=r.top;a<=r.bottom;a++){let t=o(a,e);if(t&&t.mark)n.push(t);else return!1}r[t]=e;for(let e=0;e<n.length;e++)n[e].mark=!1;return!0}for(i=t.col-1;c(i,`left`);i--);for(i=t.col+1;c(i,`right`);i++);return r}getRangesScoped(e,t){let n=li(e,t);return this.getRanges(n)}getRanges(e,t){let n=this.formulaMap[e];t||=this.matrixMap[e];let r=this.nameForKey[e]??e;return t?(t.forEach(e=>{e.mark=!0}),{name:r,ranges:t.map(e=>e.mark&&this._explore(t,e)).filter(e=>!!e).map(e=>e.$shortRange)}):n?{name:r,ranges:[n],formulaExpression:n}:{name:r,ranges:[]}}normaliseMatrix(e,t){e.forEachInSheet(t,(e,t,n)=>{e&&(e.row!==t||e.col!==n)&&(e.row=t,e.col=n,e.address=D.n2l(n)+t)})}spliceRows(e,t,n,r){Object.values(this.matrixMap).forEach(i=>{i.spliceRows(e,t,n,r),this.normaliseMatrix(i,e)})}spliceColumns(e,t,n,r){Object.values(this.matrixMap).forEach(i=>{i.spliceColumns(e,t,n,r),this.normaliseMatrix(i,e)})}get model(){let e=Object.entries(this.matrixMap).map(([e,t])=>{let n=this.getRanges(e,t),r=this.localSheetIdMap[e],i=this.hiddenMap[e],a={...n};return r!==void 0&&(a.localSheetId=r),i&&(a.hidden=!0),a}).filter(e=>e.ranges.length),t=Object.entries(this.formulaMap).filter(([e])=>!this.matrixMap[e]).map(([e,t])=>{let n={name:this.nameForKey[e]??e,ranges:[t],formulaExpression:t},r=this.localSheetIdMap[e];return r!==void 0&&(n.localSheetId=r),this.hiddenMap[e]&&(n.hidden=!0),n}),n=Object.entries(this.opaqueMap).map(([e,t])=>{let n={name:this.nameForKey[e]??e,ranges:[],rawText:t.rawText,localSheetId:t.localSheetId,kind:`opaque`};return this.hiddenMap[e]&&(n.hidden=!0),n});return[...e,...t,...n]}set model(e){let t=this.matrixMap={},n=this.formulaMap={},r=this.localSheetIdMap={},i=this.hiddenMap={},a=this.opaqueMap={},o=this.nameForKey={},s=this._explicitProbe??ei();for(let c of e){let e=li(c.name,c.localSheetId);if(o[e]=c.name,c.localSheetId!==void 0&&(r[e]=c.localSheetId),c.hidden&&(i[e]=!0),c.formulaExpression&&c.rawText===void 0){n[e]=c.formulaExpression;continue}let l=ci(c.rawText,c.ranges,s);switch(l.kind){case`reference`:{let n=t[e]=new $r;for(let e of l.ranges)ti.test(e.split(`!`).pop()??``)&&n.addCell(e);break}case`formula`:n[e]=l.formulaExpression;break;case`opaque`:c.rawText&&(a[e]={rawText:c.rawText,localSheetId:c.localSheetId});break}}}};function di(e){return D.l2n(e.toUpperCase())-1}function fi(e){return D.n2l(e+1)}function pi(e){return parseInt(e,10)-1}function mi(e){return String(e+1)}function hi(e){let t=D.decodeAddress(e.toUpperCase());return{c:t.col-1,r:t.row-1}}function gi(e){return D.encodeAddress(e.r+1,e.c+1)}function _i(e){let t=e.indexOf(`:`);if(t===-1){let t=hi(e);return{s:t,e:{...t}}}return{s:hi(e.slice(0,t)),e:hi(e.slice(t+1))}}function vi(e,t){if(t===void 0){let t=e;return vi(t.s,t.e)}let n=gi(e),r=gi(t);return n===r?n:`${n}:${r}`}function yi(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)?e:`'${e.replace(/'/g,`''`)}'`}function bi(e,t,n,r){let i=e.chartFormats??[],a=n??(i.length===0?0:Math.max(...i.map(e=>e.format??0))+1),o=r??t.pivotChartOptions;return Si(e,a),xi(e,o),{...t,pivotSource:{name:Ci(e),fmtId:a,options:o}}}function xi(e,t){t&&(e.pivotChartOptions=t,t.refreshOnOpen&&e.cacheDefinition&&(e.cacheDefinition.refreshOnLoad=`1`))}function Si(e,t){e.chartFormat??=1,e.chartFormats??=[],e.chartFormats.some(e=>e.chart===0&&e.format===t)||e.chartFormats.push({chart:0,format:t,series:!0,pivotAreaXml:`<pivotArea type="data" outline="0" fieldPosition="0"><references count="1"><reference field="4294967294" count="1" selected="0"><x v="0"/></reference></references></pivotArea>`})}function Ci(e){let t=e.name??`PivotTable${e.tableNumber}`;return e.worksheetName?`${yi(e.worksheetName)}!${t}`:t}let wi=new Uint8Array;function Ti(e,t,n=0){let r=e.length,i=t.length;if(i===0)return 0;if(i>r)return-1;let a=n|0;if(a<0&&(a=0),a>r-i)return-1;if(i===1)return e.indexOf(t[0],a);if(i===2){let n=t[0],i=t[1],o=r-2,s=e.indexOf(n,a);for(;s!==-1&&s<=o;){if(e[s+1]===i)return s;s=e.indexOf(n,s+1)}return-1}if(i===3){let n=t[0],i=t[1],o=t[2],s=r-3,c=e.indexOf(n,a);for(;c!==-1&&c<=s;){if(e[c+1]===i&&e[c+2]===o)return c;c=e.indexOf(n,c+1)}return-1}if(i===4){let n=t[0],i=t[1],o=t[2],s=t[3],c=r-4,l=e.indexOf(n,a);for(;l!==-1&&l<=c;){if(e[l+1]===i&&e[l+2]===o&&e[l+3]===s)return l;l=e.indexOf(n,l+1)}return-1}for(let n=a;n<=r-i;n++){let r=!0;for(let a=0;a<i;a++)if(e[n+a]!==t[a]){r=!1;break}if(r)return n}return-1}var Ei=class{_activeChunkCount(){return this._chunks.length-this._chunkHead}_headChunk(){return this._chunks[this._chunkHead]}_compactConsumedChunks(){if(this._chunkHead!==0){if(this._chunkHead>=this._chunks.length){this._chunks=[],this._chunkHead=0;return}this._chunkHead>32&&this._chunkHead*2>=this._chunks.length&&(this._chunks=this._chunks.slice(this._chunkHead),this._chunkHead=0)}}_dropHeadChunk(){this._chunkHead++,this._headOffset=0,this._compactConsumedChunks()}constructor(e){this._chunks=[],this._chunkHead=0,this._headOffset=0,this._length=0,this._cachedView=null,this._cachedLength=0,e&&e.length>0&&this.reset(e)}get length(){return this._length}isEmpty(){return this.length===0}view(){if(this._length===0)return wi;if(this._activeChunkCount()===1)return this._headChunk().subarray(this._headOffset,this._headOffset+this._length);if(this._cachedView&&this._cachedLength===this._length)return this._cachedView;let e=new Uint8Array(this._length),t=0;for(let n=this._chunkHead;n<this._chunks.length;n++){let r=this._chunks[n],i=n===this._chunkHead?this._headOffset:0,a=n===this._chunks.length-1?i+(this._length-t):r.length;if(e.set(r.subarray(i,a),t),t+=a-i,t>=e.length)break}return this._cachedView=e,this._cachedLength=this._length,e}reset(e){if(this._cachedView=null,this._cachedLength=0,this._chunks=[],this._chunkHead=0,this._headOffset=0,this._length=0,!e||e.length===0)return;let t=new Uint8Array(e.length);t.set(e),this._chunks=[t],this._chunkHead=0,this._headOffset=0,this._length=t.length}append(e){e.length!==0&&(this._cachedView=null,this._cachedLength=0,this._chunks.push(e),this._length+=e.length)}read(e){if(e<=0)return wi;if(e>this._length)throw RangeError(`ByteQueue: read beyond available data`);if(this._cachedView=null,this._cachedLength=0,this._activeChunkCount()===1){let t=this._headChunk(),n=this._headOffset,r=n+e,i=t.subarray(n,r);return this._headOffset=r,this._length-=e,this._length===0?(this._chunks=[],this._chunkHead=0,this._headOffset=0):this._headOffset>=t.length&&this._dropHeadChunk(),i}let t=new Uint8Array(e),n=0,r=e;for(;r>0;){let e=this._headChunk(),i=this._headOffset,a=e.length-i,o=Math.min(a,r);t.set(e.subarray(i,i+o),n),n+=o,r-=o,this._headOffset+=o,this._length-=o,this._headOffset>=e.length&&this._dropHeadChunk()}return this._length===0&&(this._chunks=[],this._chunkHead=0,this._headOffset=0),t}peekChunks(e){if(e<=0)return[];if(e>this._length)throw RangeError(`ByteQueue: peek beyond available data`);if(this._activeChunkCount()===1){let t=this._headChunk(),n=this._headOffset;return[t.subarray(n,n+e)]}let t=[],n=e;for(let e=this._chunkHead;e<this._chunks.length&&n>0;e++){let r=this._chunks[e],i=e===this._chunkHead?this._headOffset:0,a=r.length-i;if(a<=0)continue;let o=Math.min(a,n);t.push(r.subarray(i,i+o)),n-=o}return t}discard(e){if(e<=0)return;if(e>=this._length){this._chunks=[],this._chunkHead=0,this._headOffset=0,this._length=0,this._cachedView=null,this._cachedLength=0;return}this._cachedView=null,this._cachedLength=0;let t=e;for(;t>0;){let e=this._headChunk(),n=this._headOffset,r=e.length-n,i=Math.min(r,t);this._headOffset+=i,this._length-=i,t-=i,this._headOffset>=e.length&&this._dropHeadChunk()}this._length===0&&(this._chunks=[],this._chunkHead=0,this._headOffset=0)}indexOfPattern(e,t=0){let n=e.length;if(n===0)return 0;let r=this._length;if(n>r)return-1;let i=t|0;if(i<0&&(i=0),i>r-n)return-1;if(this._activeChunkCount()===1){let t=this._headChunk(),a=this._headOffset,o=t.subarray(a,a+r);return n===1?o.indexOf(e[0],i):Ti(o,e,i)}if(n>4)return Ti(this.view(),e,i);let a=e[0],o=n>=2?e[1]:0,s=n>=3?e[2]:0,c=n>=4?e[3]:0,l=this._chunks,u=this._chunkHead,d=(e,t)=>{let n=e,r=t;for(;n<l.length;){let e=l[n];if(r<e.length)return e[r]|0;r-=e.length,n++}return null},f=0;for(let e=u;e<l.length;e++){let t=l[e],p=e===u?this._headOffset:0,m=t.length-p;if(m<=0)continue;let h=f,g=h+m,_=i<=h?p:i>=g?t.length:p+(i-h);if(_>t.length-1){f+=m;continue}let v=t.length-1,y=t.indexOf(a,_);for(;y!==-1&&y<=v;){let i=h+(y-p);if(i>r-n)return-1;if(n===1)return i;if(y+n<=t.length){if(t[y+1]!==o){y=t.indexOf(a,y+1);continue}if(n===2)return i;if(t[y+2]!==s){y=t.indexOf(a,y+1);continue}if(n===3)return i;if(t[y+3]!==c){y=t.indexOf(a,y+1);continue}return i}let l=d(e,y+1);if(l===null||l!==o){y=t.indexOf(a,y+1);continue}if(n===2)return i;let u=d(e,y+2);if(u===null||u!==s){y=t.indexOf(a,y+1);continue}if(n===3)return i;let f=d(e,y+3);if(f===null||f!==c){y=t.indexOf(a,y+1);continue}return i}f+=m}return-1}peekUint32LE(e){let t=e|0;if(t<0||t+4>this._length)return null;let n=this._chunks,r=t;for(let e=this._chunkHead;e<n.length;e++){let t=n[e],i=e===this._chunkHead?this._headOffset:0,a=t.length-i;if(r<a){let a=i+r;if(a+4<=t.length){let e=t[a]|0,n=t[a+1]|0,r=t[a+2]|0,i=t[a+3]|0;return(e|n<<8|r<<16|i<<24)>>>0}let o=t[a]|0,s=0,c=0,l=0,u=e,d=a+1;for(let e=1;e<4;e++)for(;u<n.length;){let t=n[u];if(d<t.length){let n=t[d]|0;e===1?s=n:e===2?c=n:l=n,d++;break}u++,d=0}return(o|s<<8|c<<16|l<<24)>>>0}r-=a}return null}peekByte(e){let t=e|0;if(t<0||t>=this._length)throw RangeError(`ByteQueue: peek beyond available data`);let n=t;for(let e=this._chunkHead;e<this._chunks.length;e++){let t=this._chunks[e],r=e===this._chunkHead?this._headOffset:0,i=t.length-r;if(n<i)return t[r+n]|0;n-=i}throw RangeError(`ByteQueue: peek beyond available data`)}};function Di(){try{return typeof CompressionStream>`u`?!1:(new CompressionStream(`deflate-raw`),!0)}catch{return!1}}function Oi(){try{return typeof DecompressionStream>`u`?!1:(new DecompressionStream(`deflate-raw`),!0)}catch{return!1}}let ki=null,Ai=null;function ji(){return typeof CompressionStream>`u`?!1:(ki===null&&(ki=Di()),ki)}function Mi(){return typeof DecompressionStream>`u`?!1:(Ai===null&&(Ai=Oi()),Ai)}function Ni(){return ji()&&Mi()}async function Pi(e){let t=new Ei;for(;;){let{done:n,value:r}=await e.read();if(n)break;t.append(r)}return t.read(t.length)}async function Fi(e,t){let n=t.writable.getWriter(),r=t.readable.getReader();try{let t=Pi(r);return await n.write(e),await n.close(),await t}finally{try{n.releaseLock()}catch{}try{r.releaseLock()}catch{}}}async function Ii(e){return Fi(e,new DecompressionStream(`deflate-raw`))}let Li=65521;function Ri(e){let t=1,n=0;for(let r=0;r<e.length;){let i=Math.min(r+5552,e.length);for(;r<i;)t+=e[r++],n+=t;t%=Li,n%=Li}return n<<16|t}let zi={};function Bi(e,t){let n=`${e}:${t}`;return()=>{let r=e===`compression`?typeof CompressionStream<`u`?CompressionStream:void 0:typeof DecompressionStream<`u`?DecompressionStream:void 0;if(!r)return!1;let i=zi[n];if(i!=null)return i;try{new r(t),zi[n]=!0}catch{zi[n]=!1}return zi[n]}}Bi(`compression`,`gzip`),Bi(`decompression`,`gzip`),Bi(`compression`,`deflate`),Bi(`decompression`,`deflate`);let Vi={0:new Uint8Array([120,1]),1:new Uint8Array([120,1]),2:new Uint8Array([120,94]),3:new Uint8Array([120,94]),4:new Uint8Array([120,94]),5:new Uint8Array([120,94]),6:new Uint8Array([120,156]),7:new Uint8Array([120,218]),8:new Uint8Array([120,218]),9:new Uint8Array([120,218])};function Hi(e){return Vi[Math.max(0,Math.min(9,e))]??Vi[6]}function Ui(e){let t=new Uint8Array(4);return t[0]=e>>>24&255,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t}let Wi=(()=>{let e=new Uint8Array(288);for(let t=0;t<=143;t++)e[t]=8;for(let t=144;t<=255;t++)e[t]=9;for(let t=256;t<=279;t++)e[t]=7;for(let t=280;t<=287;t++)e[t]=8;return e})(),Gi=new Uint8Array(32).fill(5),Ki=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],qi=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Ji=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Yi=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Xi=[[1,0,0],[2,1,0],[3,2,0],[4,3,0],[6,4,1],[8,5,1],[12,6,2],[16,7,2],[24,8,3],[32,9,3],[48,10,4],[64,11,4],[96,12,5],[128,13,5],[192,14,6],[256,15,6],[384,16,7],[512,17,7],[768,18,8],[1024,19,8],[1536,20,9],[2048,21,9],[3072,22,10],[4096,23,10],[6144,24,11],[8192,25,11],[12288,26,12],[16384,27,12],[24576,28,13],[32768,29,13]],Zi=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function Qi(e,t){let n=new Uint16Array(16);for(let r=0;r<t;r++)e[r]>0&&n[e[r]]++;let r=new Uint16Array(16),i=0;for(let e=1;e<=15;e++)i=i+n[e-1]<<1,r[e]=i;let a={};for(let n=0;n<t;n++){let t=e[n];if(t===0)continue;i=r[t]++;let o=a;for(let e=t-1;e>=0;e--)i>>e&1?(o.right||={},o=o.right):(o.left||={},o=o.left);o.symbol=n}return a}var $i=class{constructor(e){this.data=e,this.pos=0,this.bitBuf=0,this.bitCount=0}readBits(e){for(;this.bitCount<e;){if(this.pos>=this.data.length)throw Error(`Unexpected end of DEFLATE data`);this.bitBuf|=this.data[this.pos++]<<this.bitCount,this.bitCount+=8}let t=this.bitBuf&(1<<e)-1;return this.bitBuf>>=e,this.bitCount-=e,t}decodeSymbol(e){let t=e;for(;t.symbol===void 0;)if(t=this.readBits(1)===0?t.left:t.right,!t)throw Error(`Invalid Huffman code`);return t.symbol}alignToByte(){this.bitBuf=0,this.bitCount=0}readByte(){if(this.pos>=this.data.length)throw Error(`Unexpected end of data`);return this.data[this.pos++]}readUint16(){return this.readByte()|this.readByte()<<8}};function ea(e){let t=new $i(e),n=[],r=!1;for(;!r;){r=t.readBits(1)===1;let e=t.readBits(2);if(e===0){t.alignToByte();let e=t.readUint16();if((e^t.readUint16())!==65535)throw Error(`Invalid stored block length`);for(let r=0;r<e;r++)n.push(t.readByte())}else if(e===1||e===2){let r,i;if(e===1)r=Qi(Wi,288),i=Qi(Gi,32);else{let e=t.readBits(5)+257,n=t.readBits(5)+1,a=t.readBits(4)+4,o=new Uint8Array(19);for(let e=0;e<a;e++)o[Zi[e]]=t.readBits(3);let s=Qi(o,19),c=new Uint8Array(e+n),l=0;for(;l<e+n;){let e=t.decodeSymbol(s);if(e<16)c[l++]=e;else if(e===16){let e=t.readBits(2)+3,n=c[l-1];for(let t=0;t<e;t++)c[l++]=n}else if(e===17){let e=t.readBits(3)+3;for(let t=0;t<e;t++)c[l++]=0}else if(e===18){let e=t.readBits(7)+11;for(let t=0;t<e;t++)c[l++]=0}}r=Qi(c.subarray(0,e),e),i=Qi(c.subarray(e),n)}for(;;){let e=t.decodeSymbol(r);if(e<256)n.push(e);else if(e===256)break;else{let r=e-257,a=Ki[r]+t.readBits(qi[r]),o=t.decodeSymbol(i),s=Ji[o]+t.readBits(Yi[o]),c=n.length-s;for(let e=0;e<a;e++)n.push(n[c+e])}}}else throw Error(`Invalid DEFLATE block type: `+e)}return new Uint8Array(n)}function ta(e){let t=65535,n=Math.ceil(e.length/t)||1,r=n*5+e.length,i=new Uint8Array(r),a=0,o=0;for(let r=0;r<n;r++){let s=r===n-1,c=Math.min(t,e.length-o);i[a++]=+!!s,i[a++]=c&255,i[a++]=c>>8&255,i[a++]=~c&255,i[a++]=~c>>8&255,i.set(e.subarray(o,o+c),a),a+=c,o+=c}return i.subarray(0,a)}let na=32768;na-1;let ra=32768;function ia(e){return e<=1?{maxChainLen:4,goodLen:4,niceLen:8,lazy:!1}:e<=3?{maxChainLen:8,goodLen:8,niceLen:32,lazy:!0}:e<=5?{maxChainLen:32,goodLen:16,niceLen:128,lazy:!0}:e<=7?{maxChainLen:64,goodLen:32,niceLen:258,lazy:!0}:{maxChainLen:128,goodLen:64,niceLen:258,lazy:!0}}function aa(e,t,n){return(e<<16|t<<8|n)*506832829>>>17&32767}function oa(e,t=6){if(e.length===0)return new Uint8Array([3,0]);if(e.length<100)return ta(e);let n=ia(t),r=ha(e,0,e.length,n,null),i=new sa;return ma(i,r,!0),i.finish()}var sa=class{constructor(){this.chunks=[],this.buffer=[],this.bitBuf=0,this.bitCount=0}alignToByte(){this.bitCount>0&&this.writeBits(0,8-this.bitCount)}writeBits(e,t){for(this.bitBuf|=e<<this.bitCount,this.bitCount+=t;this.bitCount>=8;)this.buffer.push(this.bitBuf&255),this.bitBuf>>=8,this.bitCount-=8,this.buffer.length>=65536&&(this.chunks.push(new Uint8Array(this.buffer)),this.buffer=[])}writeBitsReverse(e,t){let n=0;for(let r=0;r<t;r++)n=n<<1|e>>r&1;this.writeBits(n,t)}finish(){return this.bitCount>0&&this.buffer.push(this.bitBuf&255),this.chunks.length===0?new Uint8Array(this.buffer):(this.chunks.push(new Uint8Array(this.buffer)),Dn(this.chunks))}flushBytes(){if(this.chunks.length===0&&this.buffer.length===0)return new Uint8Array;let e;return this.chunks.length===0?e=new Uint8Array(this.buffer):(this.chunks.push(new Uint8Array(this.buffer)),e=Dn(this.chunks),this.chunks=[]),this.buffer=[],e}};let ca=(()=>{let e=[];for(let t=0;t<=287;t++){let n,r;t<=143?(n=48+t,r=8):t<=255?(n=400+(t-144),r=9):t<=279?(n=t-256,r=7):(n=192+(t-280),r=8),e[t]=[n,r]}return e})();function la(e,t){let[n,r]=ca[t];e.writeBitsReverse(n,r)}function ua(e){for(let t=0;t<Ki.length;t++)if(t===Ki.length-1||e<Ki[t+1])return{code:257+t,extra:e-Ki[t],extraBits:qi[t]};return{code:285,extra:0,extraBits:0}}function da(e){for(let t=0;t<Xi.length;t++){let[n,r,i]=Xi[t];if(e<=n)return{code:r,extra:e-(t===0?1:Xi[t-1][0]+1),extraBits:i}}return{code:29,extra:0,extraBits:13}}function fa(e,t){let n=e.length,r=new Uint8Array(n),i=[];for(let t=0;t<n;t++)e[t]>0&&i.push({sym:t,freq:e[t]});if(i.length===0)return r;if(i.length===1)return r[i[0].sym]=1,r;i.sort((e,t)=>e.freq-t.freq||e.sym-t.sym);let a=i.map(e=>({freq:e.freq,sym:e.sym,left:null,right:null})),o=0,s=0,c=[];function l(){let e=o<a.length,t=s<c.length;return e&&t?a[o].freq<=c[s].freq?a[o++]:c[s++]:e?a[o++]:c[s++]}let u=i.length;for(let e=0;e<u-1;e++){let e=l(),t=l(),n={freq:e.freq+t.freq,sym:-1,left:e,right:t};c.push(n)}let d=c[c.length-1];function f(e,t){if(e.sym>=0){r[e.sym]=t;return}e.left&&f(e.left,t+1),e.right&&f(e.right,t+1)}f(d,0);let p=new Uint16Array(t+1);for(let e=0;e<n;e++)r[e]>0&&(r[e]>t?(p[t]++,r[e]=t):p[r[e]]++);let m=0;for(let e=1;e<=t;e++)m+=p[e]<<t-e;let h=1<<t;if(m===h)return r;for(;m>h;){let e=t-1;for(;e>0&&p[e]===0;)e--;if(e===0)break;p[e]--,p[t]++,m-=(1<<t-e)-1}for(;m<h;)p[t]++,m++;let g=[];for(let t=0;t<n;t++)r[t]>0&&g.push({sym:t,origLen:r[t],freq:e[t]});g.sort((e,t)=>t.origLen-e.origLen||e.freq-t.freq),r.fill(0);let _=0;for(let e=t;e>=1;e--)for(let t=p[e];t>0;t--)_<g.length&&(r[g[_].sym]=e,_++);return r}function pa(e){let t=e.length,n=Array(t),r=new Uint16Array(16);for(let n=0;n<t;n++)e[n]>0&&r[e[n]]++;let i=new Uint16Array(16),a=0;for(let e=1;e<=15;e++)a=a+r[e-1]<<1,i[e]=a;for(let r=0;r<t;r++){let t=e[r];t>0?n[r]=[i[t]++,t]:n[r]=[0,0]}return n}function ma(e,t,n){let r=new Uint32Array(286),i=new Uint32Array(30);r[256]=1;for(let e of t)if(e.dist===0)r[e.litOrLen]++;else{let t=ua(e.litOrLen);r[t.code]++;let n=da(e.dist);i[n.code]++}let a=fa(r,15),o=fa(i,15),s=!1;for(let e=0;e<o.length;e++)if(o[e]>0){s=!0;break}s||(o=new Uint8Array(30),o[0]=1,o[1]=1);let c=pa(a),l=pa(o),u=286;for(;u>257&&a[u-1]===0;)u--;let d=30;for(;d>1&&o[d-1]===0;)d--;let f=new Uint8Array(u+d);f.set(a.subarray(0,u)),f.set(o.subarray(0,d),u);let p=[],m=new Uint32Array(19);for(let e=0;e<f.length;){let t=f[e];if(t===0){let t=1;for(;e+t<f.length&&f[e+t]===0;)t++;for(;t>0;)if(t>=11){let n=Math.min(t,138);p.push({sym:18,extra:n-11,extraBits:7}),m[18]++,t-=n,e+=n}else if(t>=3){let n=Math.min(t,10);p.push({sym:17,extra:n-3,extraBits:3}),m[17]++,t-=n,e+=n}else p.push({sym:0,extra:0,extraBits:0}),m[0]++,t--,e++}else{p.push({sym:t,extra:0,extraBits:0}),m[t]++,e++;let n=0;for(;e+n<f.length&&f[e+n]===t;)n++;for(;n>=3;){let t=Math.min(n,6);p.push({sym:16,extra:t-3,extraBits:2}),m[16]++,n-=t,e+=t}for(;n>0;)p.push({sym:t,extra:0,extraBits:0}),m[t]++,n--,e++}}let h=fa(m,7),g=pa(h),_=19;for(;_>4&&h[Zi[_-1]]===0;)_--;e.writeBits(+!!n,1),e.writeBits(2,2),e.writeBits(u-257,5),e.writeBits(d-1,5),e.writeBits(_-4,4);for(let t=0;t<_;t++)e.writeBits(h[Zi[t]],3);for(let t of p){let[n,r]=g[t.sym];e.writeBitsReverse(n,r),t.extraBits>0&&e.writeBits(t.extra,t.extraBits)}for(let n of t)if(n.dist===0){let[t,r]=c[n.litOrLen];e.writeBitsReverse(t,r)}else{let t=ua(n.litOrLen),[r,i]=c[t.code];e.writeBitsReverse(r,i),t.extraBits>0&&e.writeBits(t.extra,t.extraBits);let a=da(n.dist),[o,s]=l[a.code];e.writeBitsReverse(o,s),a.extraBits>0&&e.writeBits(a.extra,a.extraBits)}let[v,y]=c[256];e.writeBitsReverse(v,y)}function ha(e,t,n,r,i){let a=[],o=r.maxChainLen,s=r.goodLen,c=r.niceLen,l=r.lazy,u,d,f,p,m,h,g,_,v;i?(u=i.head,d=i.prev,f=i.window,p=i.windowLen,m=i.totalIn,h=i.hasPrevMatch,g=i.prevMatchLen,_=i.prevMatchDist,v=i.prevLiteral):(u=new Int32Array(na),d=new Int32Array(ra),f=null,p=0,m=0,h=!1,g=0,_=0,v=0);let y=i?r=>{let i=r-m;return i>=t&&i<n?e[i]:f[r&ra-1]}:t=>e[t],b=i?t=>{if(t+2>=n)return;let r=aa(e[t],e[t+1],e[t+2]),i=m+t;d[i&ra-1]=u[r],u[r]=i+1}:t=>{if(t+2>=n)return;let r=aa(e[t],e[t+1],e[t+2]);d[t&ra-1]=u[r],u[r]=t+1},x=i?(t,n)=>{for(let r=0;r<n;r++)f[p+r&ra-1]=e[t+r];p+=n}:(e,t)=>{},S=t;for(;S<n;){let t=0,r=0;if(S+2<n){let a=aa(e[S],e[S+1],e[S+2]),f=i?m+S:S,p=l&&h&&g>=s?o>>2:o,_=u[a];for(;_>0&&p-- >0;){let i=_-1,a=f-i;if(a>ra||a<=0)break;if(t>=3&&y(i+t)!==e[S+t]){_=d[i&ra-1];continue}let o=Math.min(258,n-S),s=0;for(;s<o&&y(i+s)===e[S+s];)s++;if(s>t&&(t=s,r=a,s>=c))break;_=d[i&ra-1]}i?(d[f&ra-1]=u[a],u[a]=f+1):(d[S&ra-1]=u[a],u[a]=S+1)}if(l&&h)if(t>g)a.push({litOrLen:v,dist:0}),g=t,_=r,v=e[S],x(S,1),S++;else{a.push({litOrLen:g,dist:_});let e=Math.min(S-1+g,n);for(let t=S;t<e;t++)b(t);x(S,e-S),S=e,h=!1,g=0}else if(t>=3)if(l)h=!0,g=t,_=r,v=e[S],x(S,1),S++;else{a.push({litOrLen:t,dist:r});let e=Math.min(S+t,n);for(let t=S+1;t<e;t++)b(t);x(S,e-S),S=e}else h&&(a.push({litOrLen:g,dist:_}),h=!1,g=0),a.push({litOrLen:e[S],dist:0}),x(S,1),S++}if(h){a.push({litOrLen:g,dist:_});let e=Math.min(S-1+g,n);for(let t=S;t<e;t++)b(t);x(S,e-S),h=!1,g=0}return i&&(i.windowLen=p,i.totalIn=m+(n-t),i.hasPrevMatch=h,i.prevMatchLen=g,i.prevMatchDist=_,i.prevLiteral=v),a}var ga=class{constructor(e=6){this._output=new sa,this._state={head:new Int32Array(na),prev:new Int32Array(ra),window:new Uint8Array(ra),windowLen:0,totalIn:0,hasPrevMatch:!1,prevMatchLen:0,prevMatchDist:0,prevLiteral:0},this._level=Math.max(0,Math.min(9,e)),this._config=ia(this._level)}write(e){if(e.length===0)return new Uint8Array;let t=this._output;return this._level===0?(this._writeStore(e),t.flushBytes()):(ma(t,ha(e,0,e.length,this._config,this._state),!1),t.flushBytes())}finish(){let e=this._output;return e.writeBits(1,1),e.writeBits(1,2),la(e,256),e.finish()}_writeStore(e){let t=this._output,n=0;for(;n<e.length;){let r=e.length-n,i=Math.min(65535,r);t.alignToByte(),t.writeBits(0,1),t.writeBits(0,2),t.alignToByte(),t.writeBits(i&255,8),t.writeBits(i>>8&255,8),t.writeBits(~i&255,8),t.writeBits(~i>>8&255,8);for(let r=0;r<i;r++)t.writeBits(e[n+r],8);n+=i}}},_a=class extends n{constructor(e,t){super(e,t),this.name=`ArchiveError`}},va=class extends _a{constructor(e,t,n){super(`CRC32 mismatch for "${e}": expected 0x${t.toString(16).padStart(8,`0`)}, got 0x${n.toString(16).padStart(8,`0`)}`),this.path=e,this.expected=t,this.actual=n,this.name=`Crc32MismatchError`}},ya=class extends _a{constructor(e,t,n,r){let i=r===`too-many-bytes`?`Entry "${e}" produced more bytes than declared: expected ${t}, got at least ${n}`:`Entry "${e}" produced fewer bytes than declared: expected ${t}, got ${n}`;super(i),this.path=e,this.expected=t,this.actual=n,this.reason=r,this.name=`EntrySizeMismatchError`}isZipBomb(){return this.reason===`too-many-bytes`}isCorruption(){return this.reason===`too-few-bytes`}},ba=class extends _a{constructor(e,t){super(t?`Failed to decrypt "${e}": ${t}`:`Failed to decrypt "${e}": incorrect password or corrupted data`),this.name=`DecryptionError`}},xa=class extends _a{constructor(e){super(`File "${e}" is encrypted. Please provide a password to extract.`),this.name=`PasswordRequiredError`}},Sa=class extends _a{constructor(e){super(`Unsupported compression method: ${e}`),this.name=`UnsupportedCompressionError`}};let Ca=null;function wa(){if(Ca)return Ca;let e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}return Ca=e,e}function Ta(e,t){let n=wa();for(let r=0;r<t.length;r++)e=n[(e^t[r])&255]^e>>>8;return e}function Ea(e){return(e^4294967295)>>>0}function Da(e){return Ea(Ta(4294967295,e))}function Oa(e,t){return(wa()[(e^t)&255]^e>>>8)>>>0}let ka=`ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\xA0`;function Aa(e){let t=!1;for(let n=0;n<e.length;n++)if(e[n]>=128){t=!0;break}if(!t)return Ra(e);let n=Array(e.length);for(let t=0;t<e.length;t++){let r=e[t];r<128?n[t]=String.fromCharCode(r):n[t]=ka[r-128]}return n.join(``)}function ja(e){if(e.length===0)return wi;let t=new Uint8Array(e.length),n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r),a=i;if(i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);t>=56320&&t<=57343&&(a=(i-55296<<10)+(t-56320)+65536,r++)}if(a<128){t[n++]=a;continue}if(a>65535){t[n++]=63;continue}let o=Ma.get(String.fromCharCode(a));t[n++]=o??63}return n===t.length?t:t.subarray(0,n)}let Ma=(()=>{let e=new Map;for(let t=0;t<128;t++)e.set(ka[t],128+t);return e})(),Na={name:`utf-8`,encode:Tn,decode:En,useUtf8Flag:!0,useUnicodeExtraFields:!1},Pa={name:`cp437`,encode:ja,decode:Aa,useUtf8Flag:!1,useUnicodeExtraFields:!0},Fa=new WeakMap;function Ia(e){if(!e||e===`utf-8`)return Na;if(e===`cp437`)return Pa;let t=e,n=Fa.get(t);if(n)return n;let r=t.useUtf8Flag??t.name===`utf-8`,i={...t,useUtf8Flag:r,useUnicodeExtraFields:t.useUnicodeExtraFields??!r};return Fa.set(t,i),i}function La(e,t){return e?t.encode(e):wi}function Ra(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n){let i=e.subarray(r,Math.min(r+n,e.length));t+=String.fromCharCode(...i)}return t}function za(e,t,n,r){return e.length===0?``:(t??0)&2048?En(e):n&&n.version===1&&n.originalCrc32===Da(e)?n.unicodeValue:r?r.decode(e):Aa(e)}function Ba(e,t,n,r){return za(e,t,n?.unicodePath,r)}function Va(e,t,n,r){return za(e,t,n?.unicodeComment,r)}function Ha(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer.constructor===ArrayBuffer?e.buffer:e.slice().buffer}function Ua(e){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e>>>0,!0),t}function Wa(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t,!0)}var Ga=class{constructor(e,t=0){this.data=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.offset=t}get position(){return this.offset}set position(e){this.offset=e}get remaining(){return this.data.length-this.offset}readUint8(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}readUint16(){let e=this.view.getUint16(this.offset,!0);return this.offset+=2,e}readUint32(){let e=this.view.getUint32(this.offset,!0);return this.offset+=4,e}readBigUint64(){let e=this.view.getBigUint64(this.offset,!0);return this.offset+=8,e}readBytes(e){let t=this.data.subarray(this.offset,this.offset+e);return this.offset+=e,t}readString(e,t=!0){let n=this.readBytes(e);return t?En(n):Aa(n)}skip(e){this.offset+=e}slice(e,t){return this.data.subarray(e,t)}peekUint32(e){return this.view.getUint32(e,!0)}};function Ka(e,t){let n={},r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=0;for(let[a,o]of t){if(e.length>=i+o)switch(o){case 1:n[a]=r.getUint8(i);break;case 2:n[a]=r.getUint16(i,!0);break;case 4:n[a]=r.getUint32(i,!0);break;case 8:{let e=r.getUint32(i,!0);n[a]=r.getUint32(i+4,!0)*4294967296+e;break}default:throw Error(`Unsupported UInt LE size!`)}else n[a]=null;i+=o}return n}function qa(e,t){return Ka(e,t)}function Ja(e){return!Number.isFinite(e)||e<=0?0:e>=4294967295?4294967295:e>>>0}function Ya(e){return Ja(Math.floor(e.getTime()/1e3))}function Xa(e){if(typeof BigInt!=`function`)throw Error(`NTFS timestamps require BigInt support`);return BigInt(e.getTime())*10000n+116444736000000000n}function Za(e,t){let n=t?.atime!==void 0,r=t?.ctime!==void 0,i=1;n&&(i|=2),r&&(i|=4);let a=5+(n?4:0)+(r?4:0),o=new Uint8Array(4+a),s=new DataView(o.buffer);s.setUint16(0,21589,!0),s.setUint16(2,a,!0),o[4]=i,s.setUint32(5,Ya(e),!0);let c=9;return n&&(s.setUint32(c,Ya(t.atime),!0),c+=4),r&&s.setUint32(c,Ya(t.ctime),!0),o}function Qa(e,t){if(typeof BigInt!=`function`)throw Error(`NTFS timestamps require BigInt support`);let n=t?.atime??e,r=t?.ctime??e,i=t?.birthTime??e,a=new Uint8Array(44),o=new DataView(a.buffer);o.setUint16(0,10,!0),o.setUint16(2,40,!0),o.setUint32(4,0,!0),o.setUint16(8,1,!0),o.setUint16(10,32,!0);let s=12;return o.setBigUint64(s,Xa(e),!0),s+=8,o.setBigUint64(s,Xa(n),!0),s+=8,o.setBigUint64(s,Xa(r),!0),s+=8,o.setBigUint64(s,Xa(i),!0),a}function $a(e){return[(e.getHours()&31)<<11|(e.getMinutes()&63)<<5|e.getSeconds()>>1&31,(e.getFullYear()-1980&127)<<9|(e.getMonth()+1&15)<<5|e.getDate()&31]}function eo(e,t){let n=e&31,r=e>>5&15,i=(e>>9&127)+1980,a=t?(t&31)*2:0,o=t?t>>5&63:0,s=t?t>>11:0;return new Date(Date.UTC(i,r-1,n,s,o,a))}function to(e,t,n){return n===void 0?eo(e,t):new Date(n*1e3)}function no(e,t,n){if(t===`dos`)return new Uint8Array;let r=[Za(e,n)];return t===`dos+utc+ntfs`&&r.push(Qa(e,n)),Dn(r)}function ro(e){let[t,n]=$a(e);return{dosTime:t,dosDate:n}}function io(e){return e<128?e<<1:e<<1^283}function ao(e){let t=e.length/4,n=t+6,r=[];for(let n=0;n<t;n++)r.push(new Uint8Array([e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]]));for(let e=t;e<4*(n+1);e++){let n=new Uint8Array(r[e-1]);if(e%t===0){let r=n[0];n[0]=go[n[1]]^_o[e/t-1],n[1]=go[n[2]],n[2]=go[n[3]],n[3]=go[r]}else t>6&&e%t===4&&(n[0]=go[n[0]],n[1]=go[n[1]],n[2]=go[n[2]],n[3]=go[n[3]]);let i=new Uint8Array(4);for(let a=0;a<4;a++)i[a]=r[e-t][a]^n[a];r.push(i)}return r}function oo(e,t){let n=t.length/4-1,r=new Uint8Array(16);r.set(e);for(let e=0;e<4;e++)for(let n=0;n<4;n++)r[4*e+n]^=t[e][n];for(let e=1;e<n;e++){for(let e=0;e<16;e++)r[e]=go[r[e]];let n;n=r[1],r[1]=r[5],r[5]=r[9],r[9]=r[13],r[13]=n,n=r[2],r[2]=r[10],r[10]=n,n=r[6],r[6]=r[14],r[14]=n,n=r[15],r[15]=r[11],r[11]=r[7],r[7]=r[3],r[3]=n;for(let e=0;e<4;e++){let t=r[4*e],n=r[4*e+1],i=r[4*e+2],a=r[4*e+3];r[4*e]=io(t)^io(n)^n^i^a,r[4*e+1]=t^io(n)^io(i)^i^a,r[4*e+2]=t^n^io(i)^io(a)^a,r[4*e+3]=io(t)^t^n^i^io(a)}let i=e*4;for(let e=0;e<4;e++)for(let n=0;n<4;n++)r[4*e+n]^=t[i+e][n]}for(let e=0;e<16;e++)r[e]=go[r[e]];let i;i=r[1],r[1]=r[5],r[5]=r[9],r[9]=r[13],r[13]=i,i=r[2],r[2]=r[10],r[10]=i,i=r[6],r[6]=r[14],r[14]=i,i=r[15],r[15]=r[11],r[11]=r[7],r[7]=r[3],r[3]=i;for(let e=0;e<4;e++)for(let i=0;i<4;i++)r[4*e+i]^=t[n*4+e][i];return r}function so(e,t,n){let r=16-e.length%16,i=new Uint8Array(e.length+r);i.set(e);for(let t=e.length;t<i.length;t++)i[t]=r;let a=ao(t),o=i.length/16,s=new Uint8Array(i.length),c=n;for(let e=0;e<o;e++){let t=new Uint8Array(16);for(let n=0;n<16;n++)t[n]=i[e*16+n]^c[n];let n=oo(t,a);s.set(n,e*16),c=n}return s}function co(e,t,n){if(e.length%16!=0)throw Error(`aesCbcEncryptRaw: plaintext length must be a multiple of 16`);let r=ao(t),i=e.length/16,a=new Uint8Array(e.length),o=n;for(let t=0;t<i;t++){let n=new Uint8Array(16);for(let r=0;r<16;r++)n[r]=e[t*16+r]^o[r];let i=oo(n,r);a.set(i,t*16),o=i}return a}function lo(e,t){return oo(e,ao(t))}function uo(e,t){return(e>>>t|e<<32-t)>>>0}function fo(e){let t=e.length,n=Math.ceil((t+9)/64)*64,r=new Uint8Array(n);r.set(e),r[t]=128;let i=t*8,a=new DataView(r.buffer,r.byteOffset,r.byteLength);a.setUint32(n-8,0,!1),a.setUint32(n-4,i,!1);let o=vo[0],s=vo[1],c=vo[2],l=vo[3],u=vo[4],d=vo[5],f=vo[6],p=vo[7],m=new Uint32Array(64);for(let e=0;e<n;e+=64){for(let t=0;t<16;t++)m[t]=a.getUint32(e+t*4,!1);for(let e=16;e<64;e++){let t=uo(m[e-15],7)^uo(m[e-15],18)^m[e-15]>>>3,n=uo(m[e-2],17)^uo(m[e-2],19)^m[e-2]>>>10;m[e]=m[e-16]+t+m[e-7]+n>>>0}let t=o,n=s,r=c,i=l,h=u,g=d,_=f,v=p;for(let e=0;e<64;e++){let a=uo(h,6)^uo(h,11)^uo(h,25),o=h&g^~h&_,s=v+a+o+yo[e]+m[e]>>>0,c=(uo(t,2)^uo(t,13)^uo(t,22))+(t&n^t&r^n&r)>>>0;v=_,_=g,g=h,h=i+s>>>0,i=r,r=n,n=t,t=s+c>>>0}o=o+t>>>0,s=s+n>>>0,c=c+r>>>0,l=l+i>>>0,u=u+h>>>0,d=d+g>>>0,f=f+_>>>0,p=p+v>>>0}let h=new Uint8Array(32),g=new DataView(h.buffer);return g.setUint32(0,o,!1),g.setUint32(4,s,!1),g.setUint32(8,c,!1),g.setUint32(12,l,!1),g.setUint32(16,u,!1),g.setUint32(20,d,!1),g.setUint32(24,f,!1),g.setUint32(28,p,!1),h}function po(e){let t=new Uint8Array(e);return globalThis.crypto.getRandomValues(t),t}async function mo(e,t){let n=await globalThis.crypto.subtle.digest(ho(e),t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));return new Uint8Array(n)}function ho(e){switch(e.toLowerCase().replace(/-/g,``)){case`sha1`:return`SHA-1`;case`sha256`:return`SHA-256`;case`sha384`:return`SHA-384`;case`sha512`:return`SHA-512`;default:return e}}var go,_o,vo,yo,bo=t((()=>{go=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),_o=[1,2,4,8,16,32,64,128,27,54],vo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),yo=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745])}));bo();let xo={128:8,192:12,256:16},So={128:16,192:24,256:32},Co={128:1,192:2,256:3},wo={1:128,2:192,3:256};function To(){if(globalThis.crypto?.subtle!==void 0)return globalThis.crypto.subtle;throw Error(`Web Crypto API not available`)}async function Eo(e,t,n){let r=To(),i=typeof e==`string`?Tn(e):e,a=So[n],o=a+32+2,s=await r.importKey(`raw`,Ha(i),`PBKDF2`,!1,[`deriveBits`]),c=await r.deriveBits({name:`PBKDF2`,salt:Ha(t),iterations:1e3,hash:`SHA-1`},s,o*8),l=new Uint8Array(c);return{encryptionKey:l.subarray(0,a),hmacKey:l.subarray(a,a+32),passwordVerify:l.subarray(a+32,a+34)}}async function Do(e,t){let n=To(),r=await n.importKey(`raw`,Ha(e),{name:`HMAC`,hash:`SHA-1`},!1,[`sign`]),i=await n.sign(`HMAC`,r,Ha(t));return new Uint8Array(i,0,10)}function Oo(e){let t=new Uint8Array(16);return new DataView(t.buffer).setUint32(0,e,!0),t}async function ko(e,t,n=!0){let r=To(),i=await r.importKey(`raw`,Ha(e),{name:`AES-CTR`},!1,[`encrypt`,`decrypt`]),a=Oo(1),o=await r.encrypt({name:`AES-CTR`,counter:Ha(a),length:128},i,Ha(t));return new Uint8Array(o)}function Ao(e,t,n){let r=new Uint8Array(11),i=new DataView(r.buffer);return i.setUint16(0,39169,!0),i.setUint16(2,7,!0),i.setUint16(4,e,!0),i.setUint16(6,17729,!0),r[8]=Co[t],i.setUint16(9,n,!0),r}function jo(e,t){let n=xo[t],r=n+2+10;return e.length<r?null:{salt:e.subarray(0,n),storedVerify:e.subarray(n,n+2),ciphertext:e.subarray(n+2,e.length-10),storedHmac:e.subarray(e.length-10)}}function Mo(e,t){return e[0]===t[0]&&e[1]===t[1]}function No(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function Po(e,t,n){let r=jo(e,n);if(!r)throw Error(`Encrypted data too short`);let{salt:i,storedVerify:a,ciphertext:o,storedHmac:s}=r,c=await Eo(t,i,n);if(!Mo(c.passwordVerify,a))throw Error(`Password verification failed`);if(!No(await Do(c.hmacKey,o),s))throw Error(`HMAC verification failed`);return ko(c.encryptionKey,o,!1)}async function Fo(e,t,n){let r=xo[n],i=po(r),a=await Eo(t,i,n),o=await ko(a.encryptionKey,e,!0),s=await Do(a.hmacKey,o),c=new Uint8Array(r+2+o.length+10),l=0;return c.set(i,l),l+=r,c.set(a.passwordVerify,l),l+=2,c.set(o,l),l+=o.length,c.set(s,l),c}function Io(e,t,n){let r=Tn(n),i=5+r.length,a=new Uint8Array(4+i),o=new DataView(a.buffer,a.byteOffset,a.byteLength);return o.setUint16(0,e,!0),o.setUint16(2,i,!0),a[4]=1,o.setUint32(5,Da(t)>>>0,!0),a.set(r,9),a}function Lo(e,t){return Io(28789,e,t)}function Ro(e,t){return Io(25461,e,t)}let zo=BigInt(2**53-1);function Bo(e,t){return e.getBigUint64(t,!0)}function Vo(e){return typeof e.getBigUint64==`function`}function Ho(e){if(!(e>zo))return Number(e)}function Uo(e,t){let n={};if(e.length<4)return n;let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=Vo(r),a=0;for(;a+4<=e.length;){let o=r.getUint16(a,!0),s=r.getUint16(a+2,!0),c=a+4,l=c+s;if(l>e.length)break;if(o===1){let e=c;if(t.uncompressedSize===4294967295&&e+8<=l){let i=Bo(r,e);n.uncompressedSize64=i,t.uncompressedSize64=i;let a=Ho(i);a!==void 0&&(n.uncompressedSize=a,t.uncompressedSize=a),e+=8}if(t.compressedSize===4294967295&&e+8<=l){let i=Bo(r,e);n.compressedSize64=i,t.compressedSize64=i;let a=Ho(i);a!==void 0&&(n.compressedSize=a,t.compressedSize=a),e+=8}if(t.offsetToLocalFileHeader===4294967295&&e+8<=l){let i=Bo(r,e);n.offsetToLocalFileHeader64=i,t.offsetToLocalFileHeader64=i;let a=Ho(i);a!==void 0&&(n.offsetToLocalFileHeader=a,t.offsetToLocalFileHeader=a)}}else if(o===21589){if(s>=1){let t=e[c],i=c+1;t&1&&i+4<=l&&(n.mtimeUnixSeconds=r.getUint32(i,!0)>>>0,i+=4),t&2&&i+4<=l&&(n.atimeUnixSeconds=r.getUint32(i,!0)>>>0,i+=4),t&4&&i+4<=l&&(n.ctimeUnixSeconds=r.getUint32(i,!0)>>>0)}}else if(o===10){if(i&&s>=8){let e=c+4;for(;e+4<=l;){let t=r.getUint16(e,!0),i=r.getUint16(e+2,!0),a=e+4,o=a+i;if(o>l)break;t===1&&i>=32&&a+32<=o&&(n.ntfsTimes={mtime:r.getBigUint64(a+0,!0),atime:r.getBigUint64(a+8,!0),ctime:r.getBigUint64(a+16,!0),birthTime:r.getBigUint64(a+24,!0)}),e=o}}}else if(o===39169){if(s>=7){let t=r.getUint16(c,!0),i=r.getUint16(c+2,!0),a=e[c+4],o=r.getUint16(c+5,!0);if(i===17729){let e=wo[a];e&&(t===1||t===2)&&(n.aesInfo={version:t,keyStrength:e,compressionMethod:o})}}}else o===28789?s>=5&&(n.unicodePath={version:e[c],originalCrc32:r.getUint32(c+1,!0),unicodeValue:En(e.subarray(c+5,l))}):o===25461&&s>=5&&(n.unicodeComment={version:e[c],originalCrc32:r.getUint32(c+1,!0),unicodeValue:En(e.subarray(c+5,l))});a=l}return n}let Wo=67324752,Go=33639248,Ko=101010256,qo=134695760,Jo=101075792,Yo=117853008,Xo=2048,Zo=61440,Qo=40960,$o=16384;function es(e){return e>>16&65535}function ts(e){return(e&Zo)===Qo}function ns(e){return(e&Zo)===$o}let rs=4294967295;function is(e,t,n,r){let i=r.versionNeeded??20;return t.setUint32(n+0,Wo,!0),t.setUint16(n+4,i,!0),t.setUint16(n+6,r.flags,!0),t.setUint16(n+8,r.compressionMethod,!0),t.setUint16(n+10,r.dosTime,!0),t.setUint16(n+12,r.dosDate,!0),t.setUint32(n+14,r.crc32,!0),t.setUint32(n+18,r.compressedSize,!0),t.setUint32(n+22,r.uncompressedSize,!0),t.setUint16(n+26,r.fileName.length,!0),t.setUint16(n+28,r.extraField.length,!0),e.set(r.fileName,n+30),r.extraField.length>0&&e.set(r.extraField,n+30+r.fileName.length),30+r.fileName.length+r.extraField.length}function as(e){let t=new Uint8Array(30+e.fileName.length+e.extraField.length);return is(t,new DataView(t.buffer,t.byteOffset,t.byteLength),0,e),t}function os(e,t,n,r){let i=r.versionMadeBy??20,a=r.versionNeeded??20,o=r.externalAttributes??0;return t.setUint32(n+0,Go,!0),t.setUint16(n+4,i,!0),t.setUint16(n+6,a,!0),t.setUint16(n+8,r.flags,!0),t.setUint16(n+10,r.compressionMethod,!0),t.setUint16(n+12,r.dosTime,!0),t.setUint16(n+14,r.dosDate,!0),t.setUint32(n+16,r.crc32,!0),t.setUint32(n+20,r.compressedSize,!0),t.setUint32(n+24,r.uncompressedSize,!0),t.setUint16(n+28,r.fileName.length,!0),t.setUint16(n+30,r.extraField.length,!0),t.setUint16(n+32,r.comment.length,!0),t.setUint16(n+34,0,!0),t.setUint16(n+36,0,!0),t.setUint32(n+38,o,!0),t.setUint32(n+42,r.localHeaderOffset,!0),e.set(r.fileName,n+46),r.extraField.length>0&&e.set(r.extraField,n+46+r.fileName.length),r.comment.length>0&&e.set(r.comment,n+46+r.fileName.length+r.extraField.length),46+r.fileName.length+r.extraField.length+r.comment.length}function ss(e,t,n,r){return t.setUint32(n+0,Ko,!0),t.setUint16(n+4,0,!0),t.setUint16(n+6,0,!0),t.setUint16(n+8,r.entryCount,!0),t.setUint16(n+10,r.entryCount,!0),t.setUint32(n+12,r.centralDirSize,!0),t.setUint32(n+16,r.centralDirOffset,!0),t.setUint16(n+20,r.comment.length,!0),r.comment.length>0&&e.set(r.comment,n+22),22+r.comment.length}function cs(e,t,n){let r=new Uint8Array(16),i=new DataView(r.buffer);return i.setUint32(0,qo,!0),i.setUint32(4,e,!0),i.setUint32(8,t,!0),i.setUint32(12,n,!0),r}function ls(e,t,n){let r=n>>>0,i=Math.floor(n/4294967296)>>>0;e.setUint32(t,r,!0),e.setUint32(t+4,i,!0)}function us(e,t,n){let r=new Uint8Array(24),i=new DataView(r.buffer,r.byteOffset,r.byteLength);return i.setUint32(0,qo,!0),i.setUint32(4,e,!0),ls(i,8,t),ls(i,16,n),r}function ds(e){let t=e.uncompressedSize!==void 0,n=e.compressedSize!==void 0,r=e.localHeaderOffset!==void 0,i=e.diskNumberStart!==void 0,a=0;if(t&&(a+=8),n&&(a+=8),r&&(a+=8),i&&(a+=4),a===0)return wi;let o=new Uint8Array(4+a),s=new DataView(o.buffer,o.byteOffset,o.byteLength);s.setUint16(0,1,!0),s.setUint16(2,a,!0);let c=4;return t&&(ls(s,c,e.uncompressedSize),c+=8),n&&(ls(s,c,e.compressedSize),c+=8),r&&(ls(s,c,e.localHeaderOffset),c+=8),i&&s.setUint32(c,e.diskNumberStart,!0),o}function fs(e,t){return Dn([e,t])}function ps(e,t,n,r){let i=r.versionMadeBy??20,a=r.versionNeeded??45,o=r.diskNumber??0,s=r.centralDirectoryDiskNumber??0;return t.setUint32(n+0,Jo,!0),ls(t,n+4,44),t.setUint16(n+12,i,!0),t.setUint16(n+14,a,!0),t.setUint32(n+16,o,!0),t.setUint32(n+20,s,!0),ls(t,n+24,r.entryCountOnDisk),ls(t,n+32,r.entryCountTotal),ls(t,n+40,r.centralDirSize),ls(t,n+48,r.centralDirOffset),56}function ms(e,t,n,r){let i=r.zip64EndOfCentralDirectoryDiskNumber??0,a=r.totalDisks??1;return t.setUint32(n+0,Yo,!0),t.setUint32(n+4,i,!0),ls(t,n+8,r.zip64EndOfCentralDirectoryOffset),t.setUint32(n+16,a,!0),20}let hs=[[`version`,4],[`pubKeyLength`,4],[`signatureLength`,4]],gs=[[`versionsNeededToExtract`,2],[`flags`,2],[`compressionMethod`,2],[`lastModifiedTime`,2],[`lastModifiedDate`,2],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4],[`fileNameLength`,2],[`extraFieldLength`,2]],_s=[[`dataDescriptorSignature`,4],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4]],vs=[[`versionMadeBy`,2],[`versionsNeededToExtract`,2],[`flags`,2],[`compressionMethod`,2],[`lastModifiedTime`,2],[`lastModifiedDate`,2],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4],[`fileNameLength`,2],[`extraFieldLength`,2],[`fileCommentLength`,2],[`diskNumber`,2],[`internalFileAttributes`,2],[`externalFileAttributes`,4],[`offsetToLocalFileHeader`,4]],ys=[[`diskNumber`,2],[`diskStart`,2],[`numberOfRecordsOnDisk`,2],[`numberOfRecords`,2],[`sizeOfCentralDirectory`,4],[`offsetToStartOfCentralDirectory`,4],[`commentLength`,2]],bs=Ua(qo);function xs(e){return((e||0)&Xo)!==0}function Ss(e){if(e.length===0)return!1;let t=e.charCodeAt(e.length-1);return t===47||t===92}function Cs(e,t){return t===0&&Ss(e)?`Directory`:`File`}function ws(e,t,n){return{path:e,pathBuffer:t,flags:{isUnicode:xs(n)}}}function Ts(e,t){let n=e.lastModifiedDate||0,r=e.lastModifiedTime||0,i=eo(n,r),a=t.mtimeUnixSeconds;return a===void 0?i:to(n,r,a)}let Es=Uo;function Ds(e){return((e||0)&8)!=0}function Os(e,t){return!Ds(e)||(t||0)>0}async function ks(e){let t=await e(12),n=t.length>=12?Ls(t):qa(t,hs),r=n.pubKeyLength||0,i=await e(r+(n.signatureLength||0));return n.publicKey=i.subarray(0,r),n.signature=i.subarray(r),n}async function As(e){let t=await e(26),n=t.length>=26?Rs(t):qa(t,gs);return{vars:n,fileNameBuffer:await e(n.fileNameLength||0),extraFieldData:await e(n.extraFieldLength||0)}}async function js(e){let t=await e(16);return t.length>=16?zs(t):qa(t,_s)}async function Ms(e){let t=qa(await e(42),vs);await e(t.fileNameLength||0),await e(t.extraFieldLength||0),await e(t.fileCommentLength||0)}async function Ns(e){await e(qa(await e(18),ys).commentLength||0)}function Ps(e){switch(e){case Wo:case Go:case Ko:case Jo:case Yo:return!0;default:return!1}}function Fs(e,t){return(e[t]|0|(e[t+1]|0)<<8|(e[t+2]|0)<<16|(e[t+3]|0)<<24)>>>0}function Is(e,t){return(e[t]|(e[t+1]|0)<<8)>>>0}function Ls(e){return{version:Fs(e,0),pubKeyLength:Fs(e,4),signatureLength:Fs(e,8)}}function Rs(e){return{versionsNeededToExtract:Is(e,0),flags:Is(e,2),compressionMethod:Is(e,4),lastModifiedTime:Is(e,6),lastModifiedDate:Is(e,8),crc32:Fs(e,10),compressedSize:Fs(e,14),uncompressedSize:Fs(e,18),fileNameLength:Is(e,22),extraFieldLength:Is(e,24)}}function zs(e){return{dataDescriptorSignature:Fs(e,0),crc32:Fs(e,4),compressedSize:Fs(e,8),uncompressedSize:Fs(e,12)}}let Bs=Ua(Ko);async function Vs(e,t,n,r,i){for(;;){let a=await t.pull(4);if(a.length===0){n.emitClose();return}let o=Wa(a,0);if(o===875721283){r.crxHeader=await ks(async e=>t.pull(e)),n.emitCrxHeader(r.crxHeader);continue}if(o===67324752){await i(e,t,n,r);continue}if(o===33639248){r.reachedCD=!0,await Ms(async e=>t.pull(e));continue}if(o===101010256){await Ns(async e=>t.pull(e)),t.setDone(),n.emitClose();return}if(r.reachedCD){await t.pullUntil(Bs,!0),await Ns(async e=>t.pull(e)),t.setDone(),n.emitClose();return}n.emitError(Error(`invalid signature: 0x`+o.toString(16))),n.emitClose();return}}var Hs=class{constructor(e){this.searchFrom=0,this.pattern=e,this.overlap=Math.max(0,e.length-1)}find(e){return e.indexOfPattern(this.pattern,this.searchFrom)}onConsume(e){e>0&&(this.searchFrom=Math.max(0,this.searchFrom-e))}onNoMatch(e){this.searchFrom=Math.max(this.searchFrom,Math.max(0,e-this.overlap))}};function Us(e){return e instanceof Error?e.code===`ERR_STREAM_PREMATURE_CLOSE`||e.message===`Premature close`:!1}async function Ws(e){try{await Sr(e,{readable:!1})}catch(e){if(!Us(e))throw e}}let Gs=256*1024;function Ks(e){let t=e.pipe(new ur({transform(e,t,n){n()}}));return t.promise=()=>new Promise((e,n)=>{t.on(`finish`,e),t.on(`error`,n)}),t}function qs(e){return new Promise((t,n)=>{let r=[],i=new ur({transform(e,t,n){r.push(e),n()}});i.on(`finish`,()=>{t(r.length===1?r[0]:Dn(r))}),i.on(`error`,n),e.on(`error`,n).pipe(i)})}function Js(e){let{source:t,dataDescriptorSignature:n}=e,r=e.keepTailBytes??20,i=e.errorMessage??`FILE_ENDED: Data descriptor not found`,a=new dr({highWaterMark:Gs}),o=!1,s=!1,c=0,l=new Hs(n),u,d=()=>{u&&=(u(),void 0)},f=()=>{s=!1,p()},p=()=>{if(o||s)return;let e=t.getLength();for(e===0&&t.maybeReleaseWriteCallback?.();e>0;){let n=!1;for(;;){let r=l.find(t);if(r===-1)break;let i=r+16;if(i+4<=e){let e=t.peekUint32LE(i),n=t.peekUint32LE(r+8),u=c+r>>>0;if(e!==null&&n!==null&&Ps(e)&&n===u){if(r>0)if(t.peekChunks&&t.discard){let e=t.peekChunks(r),n=0;for(let t of e){let e=a.write(t);if(n+=t.length,!e){s=!0,a.once(`drain`,f);break}}if(n>0&&(t.discard(n),c+=n,l.onConsume(n)),s)return}else{let e=a.write(t.read(r));if(c+=r,l.onConsume(r),!e){s=!0,a.once(`drain`,f);return}}o=!0,t.maybeReleaseWriteCallback?.(),d(),a.end();return}l.searchFrom=r+1;continue}if(l.searchFrom=r,n=!0,t.isFinished()&&r+16<=e){let e=t.peekUint32LE(r+8),n=c+r>>>0;if(e!==null&&e===n){if(r>0)if(t.peekChunks&&t.discard){let e=t.peekChunks(r),n=0;for(let t of e)a.write(t),n+=t.length;n>0&&(t.discard(n),c+=n,l.onConsume(n))}else a.write(t.read(r)),c+=r,l.onConsume(r);o=!0,t.maybeReleaseWriteCallback?.(),d(),a.end();return}}break}n||l.onNoMatch(e);let i=e-r;n&&(i=Math.min(i,l.searchFrom));let u=Math.max(0,i);if(u>0){if(t.peekChunks&&t.discard){let n=t.peekChunks(u),i=0;for(let e of n){let t=a.write(e);if(i+=e.length,!t){s=!0,a.once(`drain`,f);break}}i>0&&(t.discard(i),c+=i,e-=i,l.onConsume(i)),e<=r&&t.maybeReleaseWriteCallback?.();return}let n=a.write(t.read(u));c+=u,e-=u,l.onConsume(u),e<=r&&t.maybeReleaseWriteCallback?.(),n||(s=!0,a.once(`drain`,f));return}t.maybeReleaseWriteCallback?.();break}!o&&t.isFinished()&&(o=!0,d(),a.destroy(Error(i)))};return u=t.onDataAvailable(p),queueMicrotask(p),a}async function Ys(e,t,n,r,i,a){let o=e.thresholdBytes??5242880;await Vs(e,t,n,i,async(s,c,l,u)=>{await Zs(e,t,n,r,i,o,a)})}async function Xs(e,t,n,r){let i=r,a=null,s=e=>{a=e};t.once(`error`,s),n.once(`error`,s);let c=!1,l=t,u=null,d=()=>{try{l?.removeListener?.(`drain`,p)}catch{}try{n.removeListener(`__autodrain`,m)}catch{}try{n.removeListener(`close`,h)}catch{}},f=()=>{let e=u;e&&(u=null,d(),e())},p=()=>{f()},m=()=>{f()},h=()=>{f()},g=async()=>{await new Promise(e=>{u=e,typeof l?.once==`function`&&l.once(`drain`,p),n.once(`__autodrain`,m),n.once(`close`,h),(n.__autodraining||n.destroyed)&&f()})},_=async()=>{if(!c){c=!0;try{let e=t;typeof e.unpipe==`function`&&e.unpipe(n)}catch{}try{!n.writableEnded&&!n.destroyed&&n.end()}catch{}try{let e=t;typeof e.destroy==`function`&&e.destroy()}catch{}}};try{for(t.pipe(n);i>0;){if(a)throw o(a);!c&&(n.__autodraining||n.destroyed)&&await _();let r=Math.min(262144,i),s=await e.pull(r);if(s.length!==r)throw Error(`FILE_ENDED`);i-=s.length,c||t.write(s)||await g()}c||t.end(),await Ws(n)}finally{t.removeListener(`error`,s),n.removeListener(`error`,s)}}async function Zs(e,t,n,r,i,a,o){let{vars:s,fileNameBuffer:c,extraFieldData:l}=await As(async e=>t.pull(e)),u=s;i.crxHeader&&(u.crxHeader=i.crxHeader);let d={uncompressedSize:u.uncompressedSize??0,compressedSize:u.compressedSize??0},f=Es(l,d);u.uncompressedSize=d.uncompressedSize,u.compressedSize=d.compressedSize;let p=e.encoding?Ia(e.encoding):void 0,m=Ba(c,u.flags,f,p),h=new dr({highWaterMark:Gs}),g=!1;h.autodrain=function(){return g=!0,h.__autodraining=!0,h.emit(`__autodrain`),Ks(h)},h.buffer=function(){return qs(h)},h.path=m,h.props=ws(m,c,u.flags),h.type=Cs(m,u.uncompressedSize??0),e.verbose&&(h.type===`Directory`?console.log(` creating:`,m):h.type===`File`&&(u.compressionMethod===0?console.log(` extracting:`,m):console.log(` inflating:`,m))),u.lastModifiedDateTime=Ts({flags:u.flags,uncompressedSize:u.uncompressedSize??0,lastModifiedDate:u.lastModifiedDate,lastModifiedTime:u.lastModifiedTime},f),h.vars=u,h.extraFields=f,h.__autodraining=g;let _=Os(u.flags,u.compressedSize);_&&(h.size=u.uncompressedSize??0),e.forceStream?n.pushEntry(h):(n.emitEntry(h),n.pushEntryIfPiped(h)),e.verbose&&console.log({filename:m,vars:u,extraFields:h.extraFields});let v=((u.flags??0)&1)!=0||u.compressionMethod===99,y=u.compressionMethod!==0&&!v&&!g,b=!Ds(u.flags),x=u.compressedSize??0,S=u.uncompressedSize??0;if(b&&_&&o&&y&&x<=a&&S<=a){let e=o(await t.pull(x));h.end(e),await Ws(h);return}let ee=y?r():new dr({highWaterMark:Gs});if(_){if(await Xs(t,ee,h,u.compressedSize??0),Ds(u.flags)){let e=await js(async e=>t.pull(e));h.size||=e.uncompressedSize??0}return}try{await xr(t.streamUntilDataDescriptor(),ee,h)}catch(e){if(!Us(e))throw e;try{h.size=(await js(async e=>t.pull(e))).uncompressedSize??0}catch{}return}h.size=(await js(async e=>t.pull(e))).uncompressedSize??0}var Qs=class extends lr{constructor(){super({writableHighWaterMark:512*1024,readableHighWaterMark:512*1024,write:(e,t,n)=>{this._doWrite(e,n)},final:e=>{this._closeWriter(()=>{e()})}}),this.reading=!1,this.writeClosed=!1,this._junkError=!1,this._bytesIn=0,this._bytesOut=0,this._readingDone=!1,this._pendingWrites=0,this._writeFinishedPromise=null,this._resolveWriteFinished=null,this.decompressionStream=new DecompressionStream(`deflate-raw`),this.writer=this.decompressionStream.writable.getWriter(),this.reader=this.decompressionStream.readable.getReader(),this._readingDonePromise=new Promise(e=>{this._resolveReadingDone=e}),this._startReading()}_doWrite(e,t){if(this._junkError){t&&t();return}this._bytesIn+=e.length,this._pendingWrites++,this.writer.write(e).then(()=>{this._pendingWrites--,this._pendingWrites===0&&this._resolveWriteFinished&&this._resolveWriteFinished(),t&&t()}).catch(e=>{this._pendingWrites--,this._pendingWrites===0&&this._resolveWriteFinished&&this._resolveWriteFinished();let n=e instanceof Error?e.message:String(e);n.includes(`Junk`)||n.includes(`junk`)?(this._junkError=!0,t&&t()):t?t(e):this.emit(`error`,e)})}async _startReading(){if(!this.reading){this.reading=!0;try{for(;;){let{done:e,value:t}=await this.reader.read();if(e)break;this._bytesOut+=t.length,this.push(t)}}catch(e){let t=e instanceof Error?e.message:String(e);t.includes(`Junk`)||t.includes(`junk`)?this._junkError=!0:this.emit(`error`,e)}finally{this._readingDone=!0,this._resolveReadingDone(),this.push(null)}}}_closeWriter(e){if(this.writeClosed){this._readingDonePromise.then(()=>{e&&e()});return}this.writeClosed=!0,(this._pendingWrites>0?new Promise(e=>{this._writeFinishedPromise=new Promise(e=>{this._resolveWriteFinished=e}),this._writeFinishedPromise.then(e)}):Promise.resolve()).then(()=>this.writer.close()).catch(()=>{}).finally(()=>{this._readingDonePromise.then(()=>{e&&e()})})}destroy(e){return this.writeClosed||this.writer.abort(e??void 0).catch(()=>{}),this.reader.cancel(e??void 0).catch(()=>{}),super.destroy(e??void 0)}};let $s=null;function ec(e){if(typeof e==`string`&&e.length>0)return e;if($s)return $s;let t=new Blob([`