@cj-tech-master/excelts 7.0.0 → 7.0.1

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 v7.0.0
2
+ * @cj-tech-master/excelts v7.0.1
3
3
  * TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.
4
4
  * (c) 2026 cjnoname
5
5
  * Released under the MIT License
@@ -318,7 +318,7 @@ self.onmessage = async function(event) {
318
318
  `}let Cu=null,wu=0;function Tu(){if(Cu===null){let e=Su(),t=new Blob([e],{type:`text/javascript`});Cu=URL.createObjectURL(t)}return wu++,Cu}function Eu(){if(Cu!==null&&--wu<=0){try{URL.revokeObjectURL(Cu)}catch{}Cu=null,wu=0}}let Du=new Uint8Array,Ou={onData:e=>{},onEnd:()=>{},onError:e=>{}};function ku(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength}function Au(e){return ku(e)?e:e.slice()}var ju=class{_taskQueueSize(){return this._taskQueue.length-this._taskQueueHead}_compactTaskQueueIfNeeded(){this._taskQueueHead>32&&this._taskQueueHead*2>=this._taskQueue.length&&(this._taskQueue.splice(0,this._taskQueueHead),this._taskQueueHead=0)}_dequeueTask(){if(this._taskQueueHead>=this._taskQueue.length)return;let e=this._taskQueue[this._taskQueueHead++];return this._compactTaskQueueIfNeeded(),e}_compactPendingStreamRequestsIfNeeded(){this._pendingStreamRequestHead>32&&this._pendingStreamRequestHead*2>=this._pendingStreamRequests.length&&(this._pendingStreamRequests.splice(0,this._pendingStreamRequestHead),this._pendingStreamRequestHead=0)}_dequeuePendingStreamRequest(){if(this._pendingStreamRequestHead>=this._pendingStreamRequests.length)return;let e=this._pendingStreamRequests[this._pendingStreamRequestHead++];return this._compactPendingStreamRequestsIfNeeded(),e}_waitForStreamSlot(e){return e.slotWaitPromise||=new Promise(t=>{e.resolveSlotWait=()=>{e.slotWaitPromise=null,e.resolveSlotWait=null,t()}}),e.slotWaitPromise}_waitForStreamDrain(e){return e.drainWaitPromise||=new Promise(t=>{e.resolveDrainWait=()=>{e.drainWaitPromise=null,e.resolveDrainWait=null,t()}}),e.drainWaitPromise}_resolveSlotWaiter(e){e.resolveSlotWait?.()}_resolveDrainWaiter(e){e.resolveDrainWait?.()}constructor(e){this._workers=new Map,this._taskQueue=[],this._taskQueueHead=0,this._pendingTasks=new Map,this._nextTaskId=1,this._nextWorkerId=1,this._terminated=!1,this._completedTasks=0,this._failedTasks=0,this._pendingStreamRequests=[],this._pendingStreamRequestHead=0,this._options=vu(e),this._options.workerUrl?(this._workerUrl=this._options.workerUrl,this._useCustomUrl=!0):(this._workerUrl=Tu(),this._useCustomUrl=!1);for(let e=0;e<this._options.minWorkers;e++)this._createWorker()}async execute(e,t,n){if(this._terminated)throw Error(`Worker pool has been terminated`);if(!xu())throw Error(`Web Workers are not supported in this environment`);if(n?.signal?.aborted)throw r();let i=this._nextTaskId++,a=n?.priority??`normal`,o=bu(a);return new Promise((r,s)=>{let c={taskId:i,taskType:e,data:t,level:n?.level,priority:a,priorityValue:o,resolve:r,reject:s,signal:n?.signal,allowTransfer:n?.allowTransfer,startTime:performance.now()};n?.signal&&(c.abortHandler=()=>{this._cancelTask(i)},n.signal.addEventListener(`abort`,c.abortHandler,{once:!0})),this._pendingTasks.set(i,c),this._enqueueTask(c),this._processQueue()})}getStats(){let e=this._workers.size,t=0;for(let e of this._workers.values())e.busy&&t++;return{totalWorkers:e,activeWorkers:t,idleWorkers:e-t,pendingTasks:this._taskQueueSize(),completedTasks:this._completedTasks,failedTasks:this._failedTasks}}terminate(){if(this._terminated)return;this._terminated=!0;for(let e of this._workers.values())this._terminateWorker(e);this._workers.clear();let e=Error(`Worker pool terminated`);for(let t of this._pendingTasks.values())this._cleanupTask(t),t.reject(e);this._pendingTasks.clear(),this._taskQueue.length=0,this._taskQueueHead=0,this._pendingStreamRequests.length=0,this._pendingStreamRequestHead=0,this._useCustomUrl||Eu()}isTerminated(){return this._terminated}_createWorker(){if(this._terminated||this._workers.size>=this._options.maxWorkers)return null;let e=this._nextWorkerId++,t=new Worker(this._workerUrl),n={id:e,worker:t,busy:!1,currentTaskId:null,idleTimer:null,streamSession:null};return t.onmessage=e=>{this._handleWorkerMessage(n,e.data)},t.onerror=e=>{this._handleWorkerError(n,e)},this._workers.set(e,n),n}_terminateWorker(e){this._clearIdleTimer(e);try{e.worker.postMessage({type:`terminate`})}catch{}try{e.worker.terminate()}catch{}this._workers.delete(e.id)}_clearIdleTimer(e){e.idleTimer!==null&&(clearTimeout(e.idleTimer),e.idleTimer=null)}_findIdleWorker(){for(let e of this._workers.values())if(!e.busy)return e}_enqueueTask(e){let t=this._taskQueue,n=e.priorityValue;this._compactTaskQueueIfNeeded();let r=this._taskQueueHead,i=t.length;for(;r<i;){let e=r+i>>>1;t[e].priorityValue>=n?r=e+1:i=e}t.splice(r,0,e)}_processQueue(){for(;!this._terminated&&this._taskQueueSize()>0;){let e=this._findIdleWorker()??this._createWorker()??void 0;if(!e)return;for(;;){let t=this._dequeueTask();if(!t)return;if(t.signal?.aborted){this._pendingTasks.delete(t.taskId),this._cleanupTask(t),t.reject(r());continue}this._assignTask(e,t);break}}}_assignTask(e,t){this._clearIdleTimer(e),e.busy=!0,e.currentTaskId=t.taskId;let n=this._options.useTransferables&&t.allowTransfer===!0,r=n?Au(t.data):t.data,i={type:`task`,taskId:t.taskId,taskType:t.taskType,data:r,level:t.level};n?e.worker.postMessage(i,[r.buffer]):e.worker.postMessage(i)}_handleWorkerMessage(e,t){if(t.type!==`ready`){if(e.streamSession){let n=e.streamSession;switch(t.type){case`started`:if(t.taskId!==n.taskId)return;n.startReady=!0,n.resolveStart?.(),n.resolveStart=null,n.rejectStart=null;return;case`out`:if(t.taskId!==n.taskId)return;n.onData(t.data);return;case`ack`:if(t.taskId!==n.taskId)return;n.inflightChunkCount>0&&n.inflightChunkCount--,this._resolveSlotWaiter(n),n.inflightChunkCount===0&&n.resolveDrainWait&&this._resolveDrainWaiter(n);return;case`done`:if(t.taskId!==n.taskId)return;n.ended=!0,n.inflightChunkCount=0,n.startReady=!0,n.resolveStart?.(),n.resolveStart=null,n.rejectStart=null,this._resolveSlotWaiter(n),this._resolveDrainWaiter(n),this._completedTasks++,t.duration??performance.now()-n.startTime,n.onEnd(),e.streamSession=null,this._workerBecameIdle(e);return;case`error`:{if(t.taskId!==n.taskId)return;let r=Error(t.error??`Unknown worker error`);n.ended=!0,n.inflightChunkCount=0,n.startReady=!0,n.rejectStart?.(r),n.resolveStart=null,n.rejectStart=null,this._resolveSlotWaiter(n),this._resolveDrainWaiter(n),this._failedTasks++,n.onError(r),e.streamSession=null,this._workerBecameIdle(e);return}default:break}}switch(t.type){case`result`:case`error`:{let n=t.taskId;if(typeof n!=`number`)return;let r=this._pendingTasks.get(n);if(!r){this._workerBecameIdle(e);return}if(this._pendingTasks.delete(n),this._cleanupTask(r),t.type===`result`){this._completedTasks++;let e=t.duration??performance.now()-r.startTime;r.resolve({data:t.data,duration:e})}else this._failedTasks++,r.reject(Error(t.error??`Unknown worker error`));this._workerBecameIdle(e);return}default:return}}}_handleWorkerError(e,t){let n=e.currentTaskId;if(this._terminateWorker(e),n!==null){let e=this._pendingTasks.get(n);e&&(this._pendingTasks.delete(n),this._cleanupTask(e),this._failedTasks++,e.reject(Error(t.message||`Worker error`)))}this._processQueue()}_workerBecameIdle(e){if(e.busy=!1,e.currentTaskId=null,this._pendingStreamRequestHead<this._pendingStreamRequests.length){let t=this._dequeuePendingStreamRequest();if(t){t(e);return}}this._taskQueueSize()>0?this._processQueue():this._workers.size>this._options.minWorkers&&this._options.idleTimeout>0&&(e.idleTimer=setTimeout(()=>{!e.busy&&this._workers.size>this._options.minWorkers&&!this._terminated&&this._terminateWorker(e)},this._options.idleTimeout))}openStream(e,t=Ou){if(this._terminated)throw Error(`Worker pool has been terminated`);if(!xu())throw Error(`Web Workers are not supported in this environment`);let n=this._nextTaskId++,r=t.allowTransfer===!0,i=this._options.useTransferables&&r,a=i?Au:e=>e,o=i?(e,t,n)=>{e.postMessage(t,[n.buffer])}:(e,t,n)=>{e.postMessage(t)},s=null,c=null,l=async()=>{if(s)return s;if(c)return c;c=(async()=>{let r=this._findIdleWorker()??this._createWorker()??void 0;return r?(s=r,this._bindStreamSession(s,n,e,t.level,t),this._startStreamSession(s),s):(s=await new Promise(e=>{this._pendingStreamRequests.push(e)}),this._bindStreamSession(s,n,e,t.level,t),this._startStreamSession(s),s)})();try{return await c}finally{c=null}};l();let u=(e,t,n)=>{let r=a(n),i=t.chunkMessage;i.data=r,o(e.worker,i,r)},d=(e,t,n)=>{if(t.inflightChunkCount>=8)return this._waitForStreamSlot(t).then(()=>{t.ended||(t.inflightChunkCount++,u(e,t,n))});t.inflightChunkCount++,u(e,t,n)};return{write:async e=>{if(e.byteLength===0)return;let t=s??await l(),n=t.streamSession;if(!n||n.ended)throw Error(`Streaming session is not active`);n.writeChain=n.writeChain.then(()=>{if(!n.ended)return n.startReady?d(t,n,e):n.startPromise.then(()=>{if(!n.ended)return d(t,n,e)})}),await n.writeChain},end:async()=>{let e=await l(),t=e.streamSession;!t||t.ended||(t.startReady||await t.startPromise,await t.writeChain,t.inflightChunkCount>0&&await this._waitForStreamDrain(t),t.ended=!0,e.worker.postMessage(t.endMessage))},abort:e=>{l().then(t=>{let n=t.streamSession;if(!n)return;let r=n.abortMessage;r.error=e,t.worker.postMessage(r)})}}}_bindStreamSession(e,t,n,r,i){this._clearIdleTimer(e),e.busy=!0,e.currentTaskId=t;let a=null,o=null,s=new Promise((e,t)=>{a=e,o=t}),c=setTimeout(()=>{o?.(Error(`Worker stream start timeout`))},5e3);s.finally(()=>clearTimeout(c)),e.streamSession={taskId:t,taskType:n,startTime:performance.now(),started:!1,startReady:!1,startPromise:s,resolveStart:a,rejectStart:o,level:r,writeChain:Promise.resolve(),inflightChunkCount:0,slotWaitPromise:null,resolveSlotWait:null,drainWaitPromise:null,resolveDrainWait:null,chunkMessage:{type:`chunk`,taskId:t,data:Du},startMessage:{type:`start`,taskId:t,taskType:n,level:r},endMessage:{type:`end`,taskId:t},abortMessage:{type:`abort`,taskId:t,error:void 0},ended:!1,onData:i.onData,onEnd:i.onEnd,onError:i.onError}}_startStreamSession(e){let t=e.streamSession;!t||t.started||(t.started=!0,e.worker.postMessage(t.startMessage))}_cancelTask(e){let t=this._pendingTasks.get(e);if(!t)return;this._pendingTasks.delete(e),this._cleanupTask(t);let n=-1;for(let t=this._taskQueueHead;t<this._taskQueue.length;t++)if(this._taskQueue[t].taskId===e){n=t;break}n>=0&&this._taskQueue.splice(n,1),t.reject(r())}_cleanupTask(e){e.abortHandler&&e.signal&&e.signal.removeEventListener(`abort`,e.abortHandler)}async executeBatch(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];t[n]=this.execute(r.taskType,r.data,r.options)}return Promise.all(t)}};let Mu=null;function Nu(e){return(!Mu||Mu.isTerminated())&&(Mu=new ju(e)),Mu}async function Pu(e,t){return(await Nu().execute(`inflate`,e,t)).data}let Fu=`ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\xA0`;function Iu(e){let t=!1;for(let n=0;n<e.length;n++)if(e[n]>=128){t=!0;break}if(!t)return Wu(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]=Fu[r-128]}return n.join(``)}function Lu(e){if(e.length===0)return H;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=Ru.get(String.fromCharCode(a));t[n++]=o??63}return n===t.length?t:t.subarray(0,n)}let Ru=(()=>{let e=new Map;for(let t=0;t<128;t++)e.set(Fu[t],128+t);return e})(),zu={name:`utf-8`,encode:Hn,decode:Un,useUtf8Flag:!0,useUnicodeExtraFields:!1},Bu={name:`cp437`,encode:Lu,decode:Iu,useUtf8Flag:!1,useUnicodeExtraFields:!0},Vu=new WeakMap;function Hu(e){if(!e||e===`utf-8`)return zu;if(e===`cp437`)return Bu;let t=e,n=Vu.get(t);if(n)return n;let r=t.useUtf8Flag??t.name===`utf-8`,i={...t,useUtf8Flag:r,useUnicodeExtraFields:t.useUnicodeExtraFields??!r};return Vu.set(t,i),i}function Uu(e,t){return e?t.encode(e):H}function Wu(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 Gu(e,t,n,r){return e.length===0?``:(t??0)&2048?Un(e):n&&n.version===1&&n.originalCrc32===xl(e)?n.unicodeValue:r?r.decode(e):Iu(e)}function Ku(e,t,n,r){return Gu(e,t,n?.unicodePath,r)}function qu(e,t,n,r){return Gu(e,t,n?.unicodeComment,r)}function Ju(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer.constructor===ArrayBuffer?e.buffer:e.slice().buffer}function Yu(e){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e>>>0,!0),t}function Xu(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t,!0)}var Zu=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?Un(n):Iu(n)}skip(e){this.offset+=e}slice(e,t){return this.data.subarray(e,t)}peekUint32(e){return this.view.getUint32(e,!0)}};function Qu(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 $u(e,t){return Qu(e,t)}function ed(e,t){let n=xu();if(t.useWorker===!0)return n;if(t.useWorker===!1)return!1;let r=t.autoWorkerThreshold??1048576;return n&&e.length>=r}function td(e,t){if(t?.aborted||i(e))throw r(t?.reason??e)}let nd={hasNative:$l,native:ru,worker:Pu,jsFallback:Nl};async function rd(e,t,n){let r=e.hasNative(),i=xu(),a=n.useWorker;if(a===!0&&i)try{return await e.worker(t,{level:n.level,signal:n.signal,allowTransfer:n.allowTransfer})}catch(e){td(e,n.signal)}return r?e.native(t):a!==!0&&ed(t,n)?e.worker(t,{level:n.level,signal:n.signal,allowTransfer:n.allowTransfer}):e.jsFallback(t)}async function id(e,t={}){return rd(nd,e,t)}function ad(e){return Nl(e)}new Uint8Array([31,139,8,0,0,0,0,0,0,255]);function od(e,t,n){return k([lu(n),e,uu(au(t))])}function sd(e,t={}){let n=t.level??6;return od(n===0?Pl(e):Rl(e),e,n)}let cd=`write after end`;function ld(e,t,n){let r=a(t);n?n(r):e.emit(`error`,r)}var ud=class extends V{constructor(...e){super(...e),this.ended=!1,this.destroyed=!1,this.writeChain=Promise.resolve(),this._backend=null}setBackend(e){this._backend=e}write(e,t){if(this.ended)return ld(this,Error(cd),t),!1;if(e.byteLength===0)return t&&queueMicrotask(t),!0;let n=this._backend;if(!n)throw Error(`Backend not initialized`);let r=this.writeChain.then(()=>n.write(e));return this.writeChain=r,r.then(()=>{this.destroyed||t?.()}).catch(e=>{this.destroyed||ld(this,e,t)}),!0}end(e){if(this.ended){e?.();return}this.ended=!0;let t=this._backend;if(!t)throw Error(`Backend not initialized`);this.writeChain.then(()=>t.close()).then(()=>e?.()).catch(t=>ld(this,t,e))}destroy(e){this.ended=!0,this.destroyed=!0,this._backend?.abort(e),e&&this.emit(`error`,e)}};function dd(e,t){let n=t?new CompressionStream(e):new DecompressionStream(e),r=n.writable.getWriter(),i=n.readable.getReader(),o=new ud,s=null,c=(async()=>{try{for(;;){let{value:e,done:t}=await i.read();if(t)break;e&&o.emit(`data`,e)}o.emit(`end`)}catch(e){let t=a(e);s=t,o.emit(`error`,t)}})();return o.setBackend({write:e=>r.write(e),close:async()=>{if(await r.close(),await c,s)throw s},abort:e=>{i.cancel(e).catch(()=>{}),r.abort(e).catch(()=>{})}}),o}function fd(e,t,n,r){let i=t??Nu(),a=null,o=null,s=new Promise((e,t)=>{a=e,o=t}),c=new ud,l=i.openStream(e,{level:n,allowTransfer:r,onData:e=>c.emit(`data`,e),onEnd:()=>{c.emit(`end`),a?.()},onError:e=>{c.emit(`error`,e),o?.(e)}});return c.setBackend({write:e=>l.write(e),close:async()=>{await l.end(),await s},abort:e=>{a?.(),l.abort(e?.message)}}),c}var pd=class extends V{constructor(e){super(),this.process=e,this.chunks=[],this.ended=!1}write(e,t){return this.ended?(ld(this,Error(cd),t),!1):e.byteLength===0?(t&&queueMicrotask(t),!0):(this.chunks.push(e),t&&queueMicrotask(t),!0)}end(e){if(this.ended){e?.();return}this.ended=!0;let t=this.chunks.length,n=t===0?H:t===1?this.chunks[0]:k(this.chunks);this.chunks.length=0;try{let t=this.process(n);this.emit(`data`,t),this.emit(`end`),e?.()}catch(t){ld(this,t,e)}}destroy(e){this.ended=!0,this.chunks.length=0,e&&this.emit(`error`,e)}};function md(e,t){let n=e===`deflate`?t.level??6:void 0;return t.useWorker&&xu()?fd(e,t.workerPool,n,t.allowTransfer):eu()?dd(`deflate-raw`,e===`deflate`):new pd(e===`deflate`?Rl:Nl)}function hd(e={}){return md(`deflate`,e)}function gd(e){let t={key0:305419896,key1:591751049,key2:878082192},n=typeof e==`string`?Hn(e):e;for(let e=0;e<n.length;e++)_d(t,n[e]);return t}function _d(e,t){e.key0=Sl(e.key0,t),e.key1=e.key1+(e.key0&255)>>>0,e.key1=(Math.imul(e.key1,134775813)>>>0)+1>>>0,e.key2=Sl(e.key2,e.key1>>>24&255)}function vd(e){let t=(e.key2|2)>>>0;return Math.imul(t,t^1)>>>8&255}function yd(e,t){let n=(t^vd(e))&255;return _d(e,n),n}function bd(e,t){let n=(t^vd(e))&255;return _d(e,t),n}function xd(e,t,n,r){if(t.length!==12)return!1;let i=new Uint8Array(12);for(let n=0;n<12;n++)i[n]=yd(e,t[n]);let a=i[11];return a===(n>>>24&255)||r!==void 0&&a===(r>>>8&255)}function Sd(e,t,n){let r=new Uint8Array(12),i=n(11);for(let t=0;t<11;t++)r[t]=bd(e,i[t]);return r[11]=bd(e,t>>>24&255),r}function Cd(e,t,n,r){if(e.length<12)return null;let i=gd(t);if(!xd(i,e.subarray(0,12),n,r))return null;let a=e.length-12,o=new Uint8Array(a);for(let t=0;t<a;t++)o[t]=yd(i,e[12+t]);return o}let wd={128:8,192:12,256:16},Td={128:16,192:24,256:32},Ed={128:1,192:2,256:3},Dd={1:128,2:192,3:256};function Od(){if(globalThis.crypto?.subtle!==void 0)return globalThis.crypto.subtle;throw Error(`Web Crypto API not available`)}function kd(e){if(globalThis.crypto?.getRandomValues!==void 0)return globalThis.crypto.getRandomValues(e),e;throw Error(`crypto.getRandomValues not available`)}function Ad(e){return kd(new Uint8Array(e))}async function jd(e,t,n){let r=Od(),i=typeof e==`string`?Hn(e):e,a=Td[n],o=a+32+2,s=await r.importKey(`raw`,Ju(i),`PBKDF2`,!1,[`deriveBits`]),c=await r.deriveBits({name:`PBKDF2`,salt:Ju(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 Md(e,t){let n=Od(),r=await n.importKey(`raw`,Ju(e),{name:`HMAC`,hash:`SHA-1`},!1,[`sign`]),i=await n.sign(`HMAC`,r,Ju(t));return new Uint8Array(i,0,10)}function Nd(e){let t=new Uint8Array(16);return new DataView(t.buffer).setUint32(0,e,!0),t}async function Pd(e,t,n=!0){let r=Od(),i=await r.importKey(`raw`,Ju(e),{name:`AES-CTR`},!1,[`encrypt`,`decrypt`]),a=Nd(1),o=await r.encrypt({name:`AES-CTR`,counter:Ju(a),length:128},i,Ju(t));return new Uint8Array(o)}function Fd(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]=Ed[t],i.setUint16(9,n,!0),r}function Id(e,t){let n=wd[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 Ld(e,t){return e[0]===t[0]&&e[1]===t[1]}function Rd(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 zd(e,t,n){let r=Id(e,n);if(!r)throw Error(`Encrypted data too short`);let{salt:i,storedVerify:a,ciphertext:o,storedHmac:s}=r,c=await jd(t,i,n);if(!Ld(c.passwordVerify,a))throw Error(`Password verification failed`);if(!Rd(await Md(c.hmacKey,o),s))throw Error(`HMAC verification failed`);return Pd(c.encryptionKey,o,!1)}async function Bd(e,t,n){let r=wd[n],i=Ad(r),a=await jd(t,i,n),o=await Pd(a.encryptionKey,e,!0),s=await Md(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}let Vd={"aes-128":128,"aes-192":192,"aes-256":256};function Hd(e){return e in Vd}function Ud(e){return Vd[e]}function Wd(e){return!Number.isFinite(e)||e<=0?0:e>=4294967295?4294967295:e>>>0}function Gd(e){return Wd(Math.floor(e.getTime()/1e3))}function Kd(e){if(typeof BigInt!=`function`)throw Error(`NTFS timestamps require BigInt support`);return BigInt(e.getTime())*10000n+116444736000000000n}function qd(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,Gd(e),!0);let c=9;return n&&(s.setUint32(c,Gd(t.atime),!0),c+=4),r&&s.setUint32(c,Gd(t.ctime),!0),o}function Jd(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,Kd(e),!0),s+=8,o.setBigUint64(s,Kd(n),!0),s+=8,o.setBigUint64(s,Kd(r),!0),s+=8,o.setBigUint64(s,Kd(i),!0),a}function Yd(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 Xd(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 Zd(e,t,n){return n===void 0?Xd(e,t):new Date(n*1e3)}function Qd(e,t,n){if(t===`dos`)return new Uint8Array;let r=[qd(e,n)];return t===`dos+utc+ntfs`&&r.push(Jd(e,n)),k(r)}function $d(e){let[t,n]=Yd(e);return{dosTime:t,dosDate:n}}let ef=67324752,tf=33639248,nf=101010256,rf=134695760,af=101075792,of=117853008,sf=2048,cf=61440,lf=40960,uf=16384;function df(e){return e>>16&65535}function ff(e){return(e&cf)===lf}function pf(e){return(e&cf)===uf}let mf=4294967295;function hf(e,t,n,r){let i=r.versionNeeded??20;return t.setUint32(n+0,ef,!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 gf(e){let t=new Uint8Array(30+e.fileName.length+e.extraField.length);return hf(t,new DataView(t.buffer,t.byteOffset,t.byteLength),0,e),t}function _f(e,t,n,r){let i=r.versionMadeBy??20,a=r.versionNeeded??20,o=r.externalAttributes??0;return t.setUint32(n+0,tf,!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 vf(e,t,n,r){return t.setUint32(n+0,nf,!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 yf(e,t,n){let r=new Uint8Array(16),i=new DataView(r.buffer);return i.setUint32(0,rf,!0),i.setUint32(4,e,!0),i.setUint32(8,t,!0),i.setUint32(12,n,!0),r}function bf(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 xf(e,t,n){let r=new Uint8Array(24),i=new DataView(r.buffer,r.byteOffset,r.byteLength);return i.setUint32(0,rf,!0),i.setUint32(4,e,!0),bf(i,8,t),bf(i,16,n),r}function Sf(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 H;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&&(bf(s,c,e.uncompressedSize),c+=8),n&&(bf(s,c,e.compressedSize),c+=8),r&&(bf(s,c,e.localHeaderOffset),c+=8),i&&s.setUint32(c,e.diskNumberStart,!0),o}function Cf(e,t){return k([e,t])}function wf(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,af,!0),bf(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),bf(t,n+24,r.entryCountOnDisk),bf(t,n+32,r.entryCountTotal),bf(t,n+40,r.centralDirSize),bf(t,n+48,r.centralDirOffset),56}function Tf(e,t,n,r){let i=r.zip64EndOfCentralDirectoryDiskNumber??0,a=r.totalDisks??1;return t.setUint32(n+0,of,!0),t.setUint32(n+4,i,!0),bf(t,n+8,r.zip64EndOfCentralDirectoryOffset),t.setUint32(n+16,a,!0),20}function Ef(e,t,n){let r=Hn(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,xl(t)>>>0,!0),a.set(r,9),a}function Df(e,t){return Ef(28789,e,t)}function Of(e,t){return Ef(25461,e,t)}let kf=BigInt(2**53-1);function Af(e,t){return e.getBigUint64(t,!0)}function jf(e){return typeof e.getBigUint64==`function`}function Mf(e){if(!(e>kf))return Number(e)}function Nf(e,t){let n={};if(e.length<4)return n;let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=jf(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=Af(r,e);n.uncompressedSize64=i,t.uncompressedSize64=i;let a=Mf(i);a!==void 0&&(n.uncompressedSize=a,t.uncompressedSize=a),e+=8}if(t.compressedSize===4294967295&&e+8<=l){let i=Af(r,e);n.compressedSize64=i,t.compressedSize64=i;let a=Mf(i);a!==void 0&&(n.compressedSize=a,t.compressedSize=a),e+=8}if(t.offsetToLocalFileHeader===4294967295&&e+8<=l){let i=Af(r,e);n.offsetToLocalFileHeader64=i,t.offsetToLocalFileHeader64=i;let a=Mf(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=Dd[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:Un(e.subarray(c+5,l))}):o===25461&&s>=5&&(n.unicodeComment={version:e[c],originalCrc32:r.getUint32(c+1,!0),unicodeValue:Un(e.subarray(c+5,l))});a=l}return n}function Pf(e){return e?8:0}function Ff(e,t=!0){let n=0;return t&&(n|=sf),e&&(n|=8),n}function If(e){let t=Hu(e.codec),n=t.encode(e.name),r=Uu(e.comment,t),{dosTime:i,dosDate:a}=$d(e.modTime),o=e.atime||e.ctime||e.birthTime?{atime:e.atime,ctime:e.ctime,birthTime:e.birthTime}:void 0,s=Qd(e.modTime,e.timestamps,o);return!t.useUtf8Flag&&t.useUnicodeExtraFields&&(e.name&&(s=Cf(s,Df(n,e.name))),e.comment&&(s=Cf(s,Of(r,e.comment)))),{nameBytes:n,commentBytes:r,dosTime:i,dosDate:a,extraField:s,compressionMethod:Pf(e.deflate),flags:Ff(e.useDataDescriptor,t.useUtf8Flag)}}function Lf(e,t=20){return(e&255)<<8|t&255}function Rf(e){switch(e){case`directory`:return uf;case`symlink`:return lf;default:return 32768}}function zf(e){return e>>>0&65535}function Bf(e,t){let n=e.endsWith(`/`)||e.endsWith(`\\`);return t!==void 0&&ff(t)?`symlink`:n?`directory`:`file`}function Vf(e){let t=e.kind,n=t===`directory`?16:32,r=(e.msDosAttributes??n)&255,i=e.mode;i!==void 0&&(i&61440||(i=i&4095|Rf(t)),i=zf(i));let a=((i??0)&65535)<<16|r,o=Lf(i!==void 0||t===`symlink`?3:0);return{externalAttributes:a>>>0,versionMadeBy:o}}function Hf(e){if(e.externalAttributes!==void 0)return{externalAttributes:e.externalAttributes,versionMadeBy:e.versionMadeBy};let t=Vf({kind:Bf(e.name,e.mode),mode:e.mode,msDosAttributes:e.msDosAttributes});return{externalAttributes:t.externalAttributes,versionMadeBy:e.versionMadeBy??t.versionMadeBy}}function Uf(e){return e.replace(/\\/g,`/`)}function Wf(e){return e.replace(/^\/+/,``)}function Gf(e){return e.replace(/^[a-zA-Z]:\/?/,``)}function Kf(e){let t=e.split(`/`),n=[];for(let e of t)if(!(!e||e===`.`)){if(e===`..`){n.length>0?n.pop():n.push(`..`);continue}n.push(e)}return n.join(`/`)}function qf(e){return e.startsWith(`/`)}function Jf(e){return/^[a-zA-Z]:/.test(e)}function Yf(e,t={}){let n=t.mode??`legacy`,r=e;r=Uf(r);let i=Jf(r);if(n===`legacy`)return r=Wf(r),t.prependSlash?`/`+r:r;let a=t.stripDrive??!0;if(n===`safe`&&i&&!a)throw Error(`Unsafe ZIP path (drive): ${e}`);a&&(r=Gf(r));let o=qf(r);if(r=Wf(r),r=Kf(r),n===`safe`){if(o)throw Error(`Unsafe ZIP path (absolute): ${e}`);if(r===`..`||r.startsWith(`../`))throw Error(`Unsafe ZIP path (traversal): ${e}`)}return t.prependSlash?`/`+r:r}function Xf(e){return Math.log(e)/Math.LN2}function Zf(e,t){let n=0;for(let r=0;r<256;r++){let i=e[r];if(i===0)continue;let a=i/t;n-=a*Xf(a)}return n}function Qf(e,t){let n=new Uint32Array(256),r=0,i=0;if(Array.isArray(e))for(let a=0;a<e.length&&!(r>=t);a++){let o=e[a],s=Math.min(o.length,t-r);for(let e=0;e<s;e++){let t=o[e];n[t]===0&&(i+=1),n[t]+=1}r+=s}else for(let a of e){if(r>=t)break;let e=Math.min(a.length,t-r);for(let t=0;t<e;t++){let e=a[t];n[e]===0&&(i+=1),n[e]+=1}r+=e}return{total:r,unique:i,counts:n}}function $f(e,t={}){let n=t.sampleBytes??65536,r=t.minDecisionBytes??16384,{total:i,unique:a,counts:o}=Qf(e,n);return i<r||a<200?!1:Zf(o,i)>=7.95}function ep(e,t,n,r,i){if(!i)return 0;let a=0;return(e||t>4294967295)&&(a+=8),(e||n>4294967295)&&(a+=8),(e||r>4294967295)&&(a+=8),a>0?4+a:0}function tp(e){let t=e[0];return t?.fileName===void 0?t?.compressedData===void 0?`central`:`processed`:`input`}function np(e,t){let n=t.zip64Mode===!0,r=t.zip64Mode===!1,i=tp(e),a=0;for(let t=0;t<e.length;t++){let r=e[t],o=i===`input`?r.fileName:r.name,s=r.extraField,c=r.comment,l=i===`processed`?r.compressedData.length:r.compressedSize,u=r.uncompressedSize,d=i===`input`?r.localHeaderOffset:r.offset,f=i===`processed`?void 0:r.zip64,p=n||f===!0||d>4294967295||l>4294967295||u>4294967295;a+=46+o.length+s.length+ep(n,u,l,d,p)+(c?.length??0)}let o=e.length>65535||t.centralDirOffset>4294967295,s=n||o||a>4294967295;if(r&&s)throw Error(`ZIP64 is required but zip64=false`);let c=s?98+t.zipComment.length:22+t.zipComment.length;return{centralDirSize:a,trailerSize:c,totalSize:a+c,usedZip64:s}}function rp(e,t){let n=t.zip64Mode===!0,r=np(e,{zipComment:t.zipComment,zip64Mode:t.zip64Mode,centralDirOffset:t.centralDirOffset}),i=tp(e),a=t.offset,o=new DataView(t.out.buffer,t.out.byteOffset,t.out.byteLength);for(let r=0;r<e.length;r++){let s=e[r],c=i===`input`?s.fileName:s.name,l=s.extraField,u=s.comment,d=s.flags,f=i===`input`?s.crc32:s.crc,p=i===`processed`?s.compressedData.length:s.compressedSize,m=s.uncompressedSize,h=s.compressionMethod,g=i===`processed`?s.modTime:s.dosTime,_=i===`processed`?s.modDate:s.dosDate,v=i===`input`?s.localHeaderOffset:s.offset,y=i===`processed`?void 0:s.zip64,b=s.externalAttributes,x=s.versionMadeBy,S=n||y===!0||v>4294967295||p>4294967295||m>4294967295,ee=S?Sf({uncompressedSize:n||m>4294967295?m:void 0,compressedSize:n||p>4294967295?p:void 0,localHeaderOffset:n||v>4294967295?v:void 0}):H,C=S&&ee.length>0?Cf(l,ee):l;a+=_f(t.out,o,a,{fileName:c,extraField:C,comment:u??H,flags:d,compressionMethod:h,dosTime:g,dosDate:_,crc32:f,compressedSize:S?mf:p,uncompressedSize:S?mf:m,localHeaderOffset:S?mf:v,versionMadeBy:x??20,versionNeeded:S?45:20,externalAttributes:b})}if(r.usedZip64){let n=t.centralDirOffset+r.centralDirSize;a+=wf(t.out,o,a,{entryCountOnDisk:e.length,entryCountTotal:e.length,centralDirSize:r.centralDirSize,centralDirOffset:t.centralDirOffset}),a+=Tf(t.out,o,a,{zip64EndOfCentralDirectoryOffset:n,totalDisks:1}),vf(t.out,o,a,{entryCount:65535,centralDirSize:mf,centralDirOffset:mf,comment:t.zipComment})}else vf(t.out,o,a,{entryCount:e.length,centralDirSize:r.centralDirSize,centralDirOffset:t.centralDirOffset,comment:t.zipComment});return{centralDirSize:r.centralDirSize,trailerSize:r.trailerSize,totalWritten:r.totalSize,usedZip64:r.usedZip64}}let ip=16*1024;var ap=class{constructor(e,t){this._deflate=null,this._crc=4294967295,this._uncompressedSize=0,this._compressedSize=0,this._finalized=!1,this._headerEmitted=!1,this._ondata=null,this._onerror=null,this._centralDirEntryInfo=null,this._pendingEnd=!1,this._emittedDataDescriptor=!1,this._localHeader=null,this._zip64Mode=`auto`,this._zip64=!1,this._deflateWanted=null,this._pendingChunks=[],this._sampleLen=0,this._completeResolve=null,this._completeReject=null,this._completePromise=null,this._completeError=null,this._encryptionMethod=`none`,this._zipCryptoState=null,this._aesBuffer=[],this._aesBufferSize=0,this._originalCompressionMethod=0,this._aesExtraField=null,this._dataQueue=[],this._finalQueued=!1,this._pushChain=Promise.resolve(),this._syncDeflater=null,this._syncZlibReady=!1;let n=t?.path?Yf(e,t.path):e;this.name=n;let r=t?.modTime??new Date;if(this._modTime=r,this.level=t?.level??6,this._smartStore=t?.smartStore??!0,this._zip64Mode=t?.zip64??`auto`,this._zip64=this._zip64Mode===!0,this._encryptionMethod=t?.encryptionMethod??`none`,this._password=t?.password,this._encryptionMethod!==`none`&&!this._password)throw Error(`Password is required for encryption`);Hd(this._encryptionMethod)&&(this._aesKeyStrength=Ud(this._encryptionMethod)),this._stringCodec=Hu(t?.encoding);let i=If({name:n,comment:t?.comment,modTime:r,atime:t?.atime,ctime:t?.ctime,birthTime:t?.birthTime,timestamps:t?.timestamps??`dos`,useDataDescriptor:!0,deflate:!1,codec:this._stringCodec});this.nameBytes=i.nameBytes,this.commentBytes=i.commentBytes,this.dosTime=i.dosTime,this.dosDate=i.dosDate,this.extraField=i.extraField,this._flags=i.flags,this._compressionMethod=i.compressionMethod;let a=Hf({name:n,mode:t?.mode,msDosAttributes:t?.msDosAttributes,externalAttributes:t?.externalAttributes,versionMadeBy:t?.versionMadeBy});if(this._externalAttributes=a.externalAttributes,this._versionMadeBy=a.versionMadeBy,this._encryptionMethod!==`none`&&(this._flags|=1),!this._smartStore){let e=this.level>0;this._deflateWanted=e,this._compressionMethod=this._buildCompressionMethod(e),e&&this._initDeflateStream();return}this.level===0&&(this._deflateWanted=!1,this._compressionMethod=this._buildCompressionMethod(!1))}_buildCompressionMethod(e){return Pf(e)}_getAesExtraField(){return this._aesKeyStrength?(this._aesExtraField||=Fd(2,this._aesKeyStrength,this._originalCompressionMethod),this._aesExtraField):H}_initZipCryptoEncryption(){if(this._zipCryptoState||this._encryptionMethod!==`zipcrypto`)return;this._zipCryptoState=gd(this._password);let e=this.dosTime<<16|this.dosDate,t=Sd(this._zipCryptoState,e,Ad);this._compressedSize+=t.length,this._enqueueData(t,!1)}_zipCryptoEncryptChunk(e){if(!this._zipCryptoState)return e;let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=bd(this._zipCryptoState,e[n]);return t}_initDeflateStream(){this._deflate||(this._deflate=hd({level:this.level}),this._deflate.on(`error`,e=>{this._rejectComplete(e)}),this._deflate.on(`data`,e=>{if(this._aesKeyStrength){this._aesBuffer.push(e),this._aesBufferSize+=e.length;return}if(this._encryptionMethod===`zipcrypto`){this._initZipCryptoEncryption();let t=this._zipCryptoEncryptChunk(e);this._compressedSize+=t.length,this._enqueueData(t,!1);return}this._compressedSize+=e.length,this._enqueueData(e,!1)}),this._deflate.on(`end`,()=>{this._pendingEnd&&!this._emittedDataDescriptor&&(this._emittedDataDescriptor=!0,this._finalizeEncryptionAndEmitDescriptor())}))}_finalizeEncryptionAndEmitDescriptor(){if(this._aesKeyStrength&&this._aesBuffer.length>0){this._finalizeAesEncryption().then(()=>this._emitDataDescriptor()).catch(e=>this._rejectComplete(e));return}this._emitDataDescriptor()}async _finalizeAesEncryption(){if(!this._aesKeyStrength||this._aesBufferSize===0)return;let e;if(this._aesBuffer.length===1)e=this._aesBuffer[0];else{e=new Uint8Array(this._aesBufferSize);let t=0;for(let n=0;n<this._aesBuffer.length;n++){let r=this._aesBuffer[n];e.set(r,t),t+=r.length}}this._aesBuffer.length=0,this._aesBufferSize=0;let t=await Bd(e,this._password,this._aesKeyStrength);this._compressedSize=t.length,this._enqueueData(t,!1)}_buildLocalHeader(){let e=this.extraField,t=this._compressionMethod;return this._aesKeyStrength&&(this._originalCompressionMethod=this._compressionMethod,t=99,e=Cf(this.extraField,this._getAesExtraField())),gf({fileName:this.nameBytes,extraField:e,flags:this._flags,compressionMethod:t,dosTime:this.dosTime,dosDate:this.dosDate,crc32:0,compressedSize:0,uncompressedSize:0,versionNeeded:this._zip64?45:20})}_accumulateSampleLen(e){if(this._deflateWanted!==null||e.length===0||this._sampleLen>=ip)return;let t=Math.min(ip-this._sampleLen,e.length);t<=0||(this._sampleLen+=t)}_shouldDecide(e){return this._deflateWanted===null?e||this._sampleLen>=ip:!1}_decideCompressionIfNeeded(e,t,n=!1){if(this._deflateWanted===null){if(e&&this._sampleLen===0){this._deflateWanted=!1,this._sampleLen=0,this._compressionMethod=this._buildCompressionMethod(!1),this._localHeader=null;return}this._deflateWanted=!$f((function*(e,t){for(let t of e)t.length&&(yield t);t.length&&(yield t)})(this._pendingChunks,t),{sampleBytes:ip,minDecisionBytes:ip}),this._sampleLen=0,this._compressionMethod=this._buildCompressionMethod(this._deflateWanted),this._localHeader=null,this._deflateWanted&&(n||this._initDeflateStream())}}_emitHeaderIfNeeded(){this._headerEmitted||=(this._emitHeader(),!0)}async _flushPendingChunks(){if(this._pendingChunks.length!==0){for(let e of this._pendingChunks)await this._writeData(e);this._pendingChunks.length=0}}_enqueueData(e,t){this._ondata?this._ondata(e,t):(this._dataQueue.push(e),t&&(this._finalQueued=!0))}_flushQueue(){if(!this._ondata)return;let e=this._dataQueue.length,t=this._finalQueued?e-1:-1;for(let n=0;n<e;n++)this._ondata(this._dataQueue[n],n===t);this._dataQueue.length=0,this._finalQueued=!1}get ondata(){return this._ondata}set ondata(e){this._ondata=e,this._flushQueue()}get onerror(){return this._onerror}set onerror(e){this._onerror=e,this._completeError&&e(this._completeError)}_resolveComplete(){this._completeResolve&&this._completeResolve()}_rejectComplete(e){this._completeError||(this._completeError=e,this._onerror&&this._onerror(e),this._completeReject&&this._completeReject(e))}_ensureCompletePromise(){return this._completeError?Promise.reject(this._completeError):this._emittedDataDescriptor?Promise.resolve():(this._completePromise||=new Promise((e,t)=>{this._completeResolve=e,this._completeReject=t}),this._completePromise)}_tapCallback(e,t){t&&e.then(()=>t()).catch(e=>t(e))}_writeDataSync(e,t){if(!(e.length===0&&!t)){if(e.length>0&&(this._crc=yl(this._crc,e),this._uncompressedSize+=e.length),this._deflateWanted){if(this._syncDeflater||=new Gl(this.level),e.length>0){let t=this._syncDeflater.write(e);t.length>0&&(this._compressedSize+=t.length,this._enqueueData(t,!1))}if(t){let e=this._syncDeflater.finish();e.length>0&&(this._compressedSize+=e.length,this._enqueueData(e,!1)),this._syncDeflater=null}return}if(this._aesKeyStrength){this._aesBuffer.push(e),this._aesBufferSize+=e.length;return}if(this._encryptionMethod===`zipcrypto`){this._initZipCryptoEncryption();let t=this._zipCryptoEncryptChunk(e);this._compressedSize+=t.length,this._enqueueData(t,!1);return}e.length>0&&(this._compressedSize+=e.length,this._enqueueData(e,!1))}}_writeData(e){if(e.length===0)return Promise.resolve();if(this._crc=yl(this._crc,e),this._uncompressedSize+=e.length,this._deflate)return new Promise((t,n)=>{this._deflate.write(e,e=>{e?n(e):t()})});if(this._aesKeyStrength)return this._aesBuffer.push(e),this._aesBufferSize+=e.length,Promise.resolve();if(this._encryptionMethod===`zipcrypto`){this._initZipCryptoEncryption();let t=this._zipCryptoEncryptChunk(e);return this._compressedSize+=t.length,this._enqueueData(t,!1),Promise.resolve()}return this._compressedSize+=e.length,this._enqueueData(e,!1),Promise.resolve()}_endDeflateAndWait(){return new Promise((e,t)=>{let n=this._deflate,r=e=>{a(),t(e)},i=()=>{a(),e()},a=()=>{n.off(`error`,r),n.off(`end`,i)};n.once(`error`,r),n.once(`end`,i),n.end()})}_finalizeAfterWrite(e){this._finalized=!0,this._pendingEnd=!0;let t=this._ensureCompletePromise();return this._deflate?e.then(()=>this._endDeflateAndWait()).then(()=>t):this._aesKeyStrength&&this._aesBufferSize>0?(this._emittedDataDescriptor=!0,this._finalizeAesEncryption().then(()=>this._emitDataDescriptor()).catch(e=>this._rejectComplete(e)),t):(this._emittedDataDescriptor=!0,this._emitDataDescriptor(),t)}_pushUnchained(e,t,n){if(this._finalized){let e=Promise.reject(Error(`Cannot push to finalized ZipDeflateFile`));return this._tapCallback(e,n),e}if(this._deflateWanted===null){if(this._accumulateSampleLen(e),!this._shouldDecide(t)){e.length>0&&this._pendingChunks.push(e);let t=Promise.resolve();return this._tapCallback(t,n),t}this._decideCompressionIfNeeded(t,e),this._emitHeaderIfNeeded();let r=this._pendingChunks.length>0,i=this._flushPendingChunks(),a=i;e.length>0&&(a=r?i.then(()=>this._writeData(e)):this._writeData(e));let o=t?this._finalizeAfterWrite(a):a;return this._tapCallback(o,n),o}this._emitHeaderIfNeeded();let r=this._writeData(e),i=t?this._finalizeAfterWrite(r):r;return this._tapCallback(i,n),i}push(e,t=!1,n){if(!this._deflate&&this._encryptionMethod===`none`){try{this._pushSyncPath(e,t),n?.()}catch(e){return n?.(e instanceof Error?e:Error(String(e))),Promise.reject(e)}return Promise.resolve()}let r=this._pushChain=this._pushChain.then(()=>this._pushUnchained(e,t,n));return r.catch(()=>{}),r}_pushSyncPath(e,t=!1){if(this._finalized)throw Error(`Cannot push to finalized ZipDeflateFile`);if(this._syncZlibReady||=!0,this._deflateWanted===null){if(this._accumulateSampleLen(e),!this._shouldDecide(t)){e.length>0&&this._pendingChunks.push(e);return}this._decideCompressionIfNeeded(t,e,!0),this._emitHeaderIfNeeded();for(let e of this._pendingChunks)this._writeDataSync(e,!1);this._pendingChunks.length=0,e.length>0&&this._writeDataSync(e,t),t&&this._finalizeSyncAfterWrite();return}this._emitHeaderIfNeeded(),this._writeDataSync(e,t),t&&this._finalizeSyncAfterWrite()}_finalizeSyncAfterWrite(){if(this._finalized=!0,this._pendingEnd=!1,this._emittedDataDescriptor=!0,this._aesKeyStrength&&this._aesBufferSize>0)throw Error(`AES encryption is not supported with synchronous push`);if(this._syncDeflater){let e=this._syncDeflater.finish();e.length>0&&(this._compressedSize+=e.length,this._enqueueData(e,!1)),this._syncDeflater=null}this._emitDataDescriptor()}_emitHeader(){this._localHeader||=this._buildLocalHeader(),this._enqueueData(this._localHeader,!1)}_emitDataDescriptor(){let e=bl(this._crc),t=this._compressedSize>4294967295||this._uncompressedSize>4294967295;if(this._zip64Mode===!1&&t){this._rejectComplete(Error(`ZIP64 is required but zip64=false`));return}(this._zip64Mode===!0||t&&!this._zip64)&&(this._zip64=!0);let n=this._zip64?xf(e,this._compressedSize,this._uncompressedSize):yf(e,this._compressedSize,this._uncompressedSize),r=this._compressionMethod,i=this.extraField;this._aesKeyStrength&&(r=99,i=Cf(this.extraField,this._getAesExtraField())),this._centralDirEntryInfo={name:this.nameBytes,extraField:i,comment:this.commentBytes,flags:this._flags,crc:e,compressedSize:this._compressedSize,uncompressedSize:this._uncompressedSize,compressionMethod:r,dosTime:this.dosTime,dosDate:this.dosDate,offset:-1,zip64:this._zip64,externalAttributes:this._externalAttributes,versionMadeBy:this._versionMadeBy},this._enqueueData(n,!0),this._resolveComplete()}complete(){return this._ensureCompletePromise()}getEntryInfo(){if(!this._centralDirEntryInfo)return null;let e=this.name,t=e.endsWith(`/`)||e.endsWith(`\\`),n=this._centralDirEntryInfo.externalAttributes,r=df(n);return{path:e,type:ff(r)?`symlink`:t?`directory`:`file`,compressedSize:this._centralDirEntryInfo.compressedSize,uncompressedSize:this._centralDirEntryInfo.uncompressedSize,compressionMethod:this._centralDirEntryInfo.compressionMethod,crc32:this._centralDirEntryInfo.crc,lastModified:this._modTime,localHeaderOffset:this._centralDirEntryInfo.offset,comment:this._stringCodec.decode(this._centralDirEntryInfo.comment),externalAttributes:n,mode:r,versionMadeBy:this._centralDirEntryInfo.versionMadeBy,extraField:this._centralDirEntryInfo.extraField,isEncrypted:this._encryptionMethod!==`none`,encryptionMethod:this._aesKeyStrength?`aes`:this._encryptionMethod===`zipcrypto`?`zipcrypto`:void 0,aesKeyStrength:this._aesKeyStrength,originalCompressionMethod:this._aesKeyStrength?this._originalCompressionMethod:void 0}}getCentralDirectoryEntryInfo(){return this._centralDirEntryInfo}isComplete(){return this._emittedDataDescriptor&&this._centralDirEntryInfo!==null}abort(e){if(this._completeError)return;let t=r(e);this._finalized=!0,this._pendingEnd=!0,this._rejectComplete(t);try{let e=this._deflate;e&&typeof e.destroy==`function`&&e.destroy(t)}catch{}}},op=class{constructor(e,t){this.entries=[],this.currentOffset=0,this.ended=!1,this.endPending=!1,this.addedEntryCount=0,this.fileQueue=[],this.fileQueueIndex=0,this.activeFile=null,this.callback=e,this._stringCodec=t?.codec??Hu(t?.encoding),this.zipComment=Uu(t?.comment,this._stringCodec),this.zip64Mode=t?.zip64??`auto`}add(e){if(this.ended)throw Error(`Cannot add files after calling end() `);if(this.zip64Mode===!1&&this.addedEntryCount>=65535)throw Error(`ZIP64 is required but zip64=false`);this.addedEntryCount++,this.fileQueue.push(e),this.activeFile||this._processNextFile()}_processNextFile(){if(this.fileQueueIndex>=this.fileQueue.length){this.activeFile=null,this.fileQueue=[],this.fileQueueIndex=0,this.endPending&&this._finalize();return}let e=this.fileQueue[this.fileQueueIndex++];this.activeFile=e;let t=this.currentOffset;if(e.onerror=e=>{this.ended||(this.ended=!0,this.callback(e,H,!0))},e.ondata=(n,r)=>{if(!this.ended&&(this.currentOffset+=n.length,this.callback(null,n,!1),r)){let n=e.getCentralDirectoryEntryInfo();n&&(n.offset=t,this.entries.push(n)),this._processNextFile()}},typeof e.start==`function`)try{e.start().catch(t=>{let n=a(t);try{e.onerror?.(n)}catch{}})}catch(t){let n=a(t);try{e.onerror?.(n)}catch{}}}_finalize(){if(this.ended)return;this.ended=!0;let e=this.currentOffset,t;try{let n=np(this.entries,{zipComment:this.zipComment,zip64Mode:this.zip64Mode,centralDirOffset:e});t=new Uint8Array(n.totalSize),rp(this.entries,{zipComment:this.zipComment,zip64Mode:this.zip64Mode,centralDirOffset:e,out:t,offset:0})}catch(e){let t=a(e);this.callback(t,H,!0);return}this.callback(null,t,!0)}end(){this.endPending||this.ended||(this.endPending=!0,this.activeFile||this._finalize())}abort(e){if(this.ended)return;let t=r(e);this.ended=!0,this.endPending=!0;try{this.activeFile?.abort(t)}catch{}this.callback(t,H,!0)}};let sp=BigInt(2**53-1);function cp(e,t){if(e>sp)throw Error(`ZIP64 ${t} value ${e} exceeds Number.MAX_SAFE_INTEGER. The archive may be corrupted or malicious.`);return Number(e)}function lp(e){return e.encoding?Hu(e.encoding):void 0}function up(e,t=!1){for(let n=e.length-22;n>=0;n--)if(e[n]===80&&e[n+1]===75&&e[n+2]===5&&e[n+3]===6)if(t){let t=e[n+20]|e[n+21]<<8;if(n+22+t===e.length)return n}else return n;return-1}function dp(e,t){let n=t-20;return n<0?-1:e[n]===80&&e[n+1]===75&&e[n+2]===6&&e[n+3]===7?n:-1}function fp(e,t,n=!0,r){let i=new Zu(e,t);i.skip(4);let a=i.readUint16(),o=i.readUint16(),s=i.readUint16(),c=i.readUint16(),l=i.readUint32(),u=i.readUint32(),d=i.readUint16(),f=``;if(d>0){let e=i.readBytes(d);n&&(f=r?r.decode(e):Un(e))}return{eocd:{diskNumber:a,centralDirDisk:o,entriesOnDisk:s,totalEntries:c,centralDirSize:l,centralDirOffset:u},comment:f}}function pp(e,t){let n=new Zu(e,t);return n.readUint32()===117853008?(n.skip(4),cp(n.readBigUint64(),`EOCD locator offset`)):-1}function mp(e,t){let n=new Zu(e,t);return n.readUint32()===101075792?(n.skip(8),n.skip(2),n.skip(2),n.skip(4),n.skip(4),{entriesOnDisk:n.readBigUint64(),totalEntries:n.readBigUint64(),centralDirSize:n.readBigUint64(),centralDirOffset:n.readBigUint64()}):null}function hp(e,t){e.totalEntries===65535&&(e.totalEntries=cp(t.totalEntries,`totalEntries`)),e.entriesOnDisk===65535&&(e.entriesOnDisk=cp(t.entriesOnDisk,`entriesOnDisk`)),e.centralDirSize===4294967295&&(e.centralDirSize=cp(t.centralDirSize,`centralDirSize`)),e.centralDirOffset===4294967295&&(e.centralDirOffset=cp(t.centralDirOffset,`centralDirOffset`))}function gp(e,t,n){let r=e.readUint16();e.skip(2);let i=e.readUint16(),a=e.readUint16(),o=e.readUint16(),s=e.readUint16(),c=e.readUint32(),l=e.readUint32(),u=e.readUint32(),d=e.readUint16(),f=e.readUint16(),p=e.readUint16();e.skip(2),e.skip(2);let m=e.readUint32(),h=e.readUint32(),g=d>0?e.readBytes(d):new Uint8Array,_={},v=new Uint8Array;if(f>0){v=e.readBytes(f);let t={compressedSize:l,uncompressedSize:u,offsetToLocalFileHeader:h};_=Nf(v,t),l=t.compressedSize,u=t.uncompressedSize,h=t.offsetToLocalFileHeader??h}let y=p>0?e.readBytes(p):new Uint8Array,b=t?Ku(g,i,_,n):``,x=t?qu(y,i,_,n):``,S=df(m),ee=r>>8&255,C=ff(S),te=pf(S)||ee===0&&(m&16)!=0||b.endsWith(`/`),ne=(i&1)!=0,w=C?`symlink`:te?`directory`:`file`,T=_.mtimeUnixSeconds,E=Zd(s,o,T),re=`none`,ie,ae,oe;return ne&&(a===99&&_.aesInfo?(re=`aes`,ie=_.aesInfo.version,ae=_.aesInfo.keyStrength,oe=_.aesInfo.compressionMethod):re=`zipcrypto`),{path:b,type:w,compressedSize:l,compressedSize64:_.compressedSize64,uncompressedSize:u,uncompressedSize64:_.uncompressedSize64,compressionMethod:a,crc32:c,lastModified:E,localHeaderOffset:h,localHeaderOffset64:_.offsetToLocalFileHeader64,comment:x,externalAttributes:m,mode:S,versionMadeBy:r,extraField:v,isEncrypted:ne,encryptionMethod:re,aesVersion:ie,aesKeyStrength:ae,originalCompressionMethod:oe,dosTime:o}}function _p(e,t,n,r={}){let i=r.decodeStrings??!0,a=lp(r);if(n===0)return[];let o=Array(n),s=new Zu(e,t);for(let e=0;e<n;e++){if(s.readUint32()!==33639248)throw Error(`Invalid Central Directory header signature at entry ${e}`);o[e]=gp(s,i,a)}return o}function vp(e,t={}){let n=t.decodeStrings??!0,r=lp(t),i=up(e);if(i===-1)throw Error(`Invalid ZIP file: End of Central Directory not found`);let{eocd:a,comment:o}=fp(e,i,n,r),s=dp(e,i);if(s!==-1){let t=pp(e,s);if(t>=0){let n=mp(e,t);n&&hp(a,n)}}return{entries:_p(e,a.centralDirOffset,a.totalEntries,t),comment:o}}function yp(e){return!!e&&typeof e==`object`&&typeof e.getReader==`function`}function bp(e){return!!e&&typeof e==`object`&&typeof e.getWriter==`function`}function xp(e){return!!e&&typeof e==`object`&&!!e.readable&&!!e.writable&&yp(e.readable)&&bp(e.writable)}let Sp=512*1024*1024;async function Cp(e,t,n,r=!1,i=!0){let a;if(i&&e.uncompressedSize>Sp)throw Error(`Entry "${e.path}" declares uncompressed size of ${e.uncompressedSize} bytes, which exceeds the maximum allowed size of ${Sp} bytes. Use the streaming API for large entries.`);if(e.isEncrypted){if(!n)throw new hu(e.path);if(e.encryptionMethod===`aes`&&e.aesKeyStrength){let r=await zd(t,n,e.aesKeyStrength);if(!r)throw new mu(e.path);a=await Tp(r,e.originalCompressionMethod??0,e.path)}else if(e.encryptionMethod===`zipcrypto`){let r=Cd(t,n,e.crc32,e.dosTime);if(!r)throw new mu(e.path);a=await Tp(r,e.compressionMethod,e.path)}else throw new mu(e.path,`Unsupported encryption method`)}else a=await Tp(t,e.compressionMethod,e.path);if(i&&a.length!==e.uncompressedSize){let t=a.length>e.uncompressedSize?`too-many-bytes`:`too-few-bytes`;throw new pu(e.path,e.uncompressedSize,a.length,t)}if(e.encryptionMethod===`zipcrypto`||r&&e.encryptionMethod!==`aes`){let t=xl(a);if(t!==e.crc32)throw new fu(e.path,e.crc32,t)}return a}function wp(e,t,n,r=!0){let i;if(r&&e.uncompressedSize>Sp)throw Error(`Entry "${e.path}" declares uncompressed size of ${e.uncompressedSize} bytes, which exceeds the maximum allowed size of ${Sp} bytes. Use the streaming API for large entries.`);if(e.isEncrypted){if(!n)throw new hu(e.path);if(e.encryptionMethod===`aes`)throw Error(`File "${e.path}" uses AES encryption. Use the async extract() method instead of extractSync().`);if(e.encryptionMethod===`zipcrypto`){let r=Cd(t,n,e.crc32,e.dosTime);if(!r)throw new mu(e.path);i=Ep(r,e.compressionMethod,e.path);let a=xl(i);if(a!==e.crc32)throw new fu(e.path,e.crc32,a)}else throw new mu(e.path,`Unsupported encryption method`)}else i=Ep(t,e.compressionMethod,e.path);if(r&&i.length!==e.uncompressedSize){let t=i.length>e.uncompressedSize?`too-many-bytes`:`too-few-bytes`;throw new pu(e.path,e.uncompressedSize,i.length,t)}return i}async function Tp(e,t,n){if(t===0)return e;if(t===8)return id(e);throw new gu(t)}function Ep(e,t,n){if(t===0)return e;if(t===8)return ad(e);throw new gu(t)}function Dp(e,t){if(e.readUint32()!==67324752)throw Error(`Invalid local file header signature at offset ${t}`);e.skip(2),e.skip(2),e.skip(2),e.skip(2),e.skip(2),e.skip(4),e.skip(4),e.skip(4);let n=e.readUint16(),r=e.readUint16();return e.skip(n),e.skip(r),e.position}function Op(e,t){let n=Dp(new Zu(e,t.localHeaderOffset),t.localHeaderOffset);return e.subarray(n,n+t.compressedSize)}let kp=BigInt(2**53-1);function Ap(e){if(e.uncompressedSize64!==void 0&&e.uncompressedSize64>kp||e.compressedSize64!==void 0&&e.compressedSize64>kp)throw Error(`File "${e.path}" is too large to extract into memory (ZIP64 size > 2^53-1)`);if(e.localHeaderOffset64!==void 0&&e.localHeaderOffset64>kp)throw Error(`File "${e.path}" has a ZIP64 offset > 2^53-1 and cannot be extracted by the in-memory parser`)}function jp(e,t={}){return vp(e,{decodeStrings:t.decodeStrings,encoding:t.encoding})}async function Mp(e,t,n={}){return t.type===`directory`?H:(Ap(t),Cp(t,Op(e,t),n.password))}function Np(e,t,n={}){return t.type===`directory`?H:(Ap(t),wp(t,Op(e,t),n.password))}var Pp=class{constructor(e,t={}){this.data=e instanceof ArrayBuffer?new Uint8Array(e):e;let n=jp(this.data,t);this.entries=n.entries,this.archiveComment=n.comment,this.entryMap=new Map(this.entries.map(e=>[e.path,e])),this.password=t.password}setPassword(e){this.password=e}getEntries(){return this.entries}getEntry(e){return this.entryMap.get(e)}getRawCompressedData(e){let t=this.entryMap.get(e);return t?Op(this.data,t):null}getRawEntry(e){let t=this.entryMap.get(e);return t?{info:t,compressedData:Op(this.data,t)}:null}hasEntry(e){return this.entryMap.has(e)}childCount(e){let t=this.entryMap.get(e);if(t&&t.type!==`directory`)return 0;let n=e.endsWith(`/`)?e:e+`/`,r=t?.type===`directory`?t:this.entryMap.get(n),i=(r?.path??n).endsWith(`/`)?r?.path??n:(r?.path??n)+`/`,a=0;for(let e of this.entries)e.path.startsWith(i)&&e.path!==i&&a++;return a}getZipComment(){return this.archiveComment}hasEncryptedEntries(){return this.entries.some(e=>e.isEncrypted)}getEncryptedEntries(){return this.entries.filter(e=>e.isEncrypted)}listFiles(){return this.entries.map(e=>e.path)}async extract(e,t){let n=this.entryMap.get(e);return n?Mp(this.data,n,{password:t??this.password}):null}extractSync(e,t){let n=this.entryMap.get(e);return n?Np(this.data,n,{password:t??this.password}):null}async extractAll(e){let t=new Map,n=e??this.password;for(let e of this.entries){let r=await Mp(this.data,e,{password:n});t.set(e.path,r)}return t}extractAllSync(e){let t={},n=e??this.password;for(let e of this.entries)t[e.path]=Np(this.data,e,{password:n});return t}async forEach(e,t){let n=t??this.password;for(let t of this.entries){let r=null;if(await e(t,()=>(r||=Mp(this.data,t,{password:n}),r))===!1)break}}};function Fp(e){return e?16:65536}var Ip=class extends t{constructor(e,t){super(e,t),this.name=`StreamError`}},Lp=class extends Ip{constructor(e,t,n){super(`Cannot ${e}: ${t}`,n),this.operation=e,this.state=t,this.name=`StreamStateError`}},Rp=class extends Ip{constructor(e,t,n){super(`Expected ${e}, got ${t}`,n),this.expectedType=e,this.actualType=t,this.name=`StreamTypeError`}};function zp(e,t){let n=(t??`utf-8`).trim().toLowerCase();switch(n){case``:case`utf8`:case`utf-8`:return Tn.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 Bp(n)}}function Bp(e){let t=TypeError(`Unknown encoding: ${e}`);return t.code=`ERR_UNKNOWN_ENCODING`,t}var Vp=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 Hp=(e,t,n)=>{typeof e.off==`function`?e.off(t,n):typeof e.removeListener==`function`&&e.removeListener(t,n)},Up=(e,t,n,r)=>(r?.once?typeof e.once==`function`&&e.once(t,n):typeof e.on==`function`&&e.on(t,n),()=>Hp(e,t,n)),Wp=()=>{let e=[];return{add:(t,n,r)=>{e.push(Up(t,n,r))},once:(t,n,r)=>{e.push(Up(t,n,r,{once:!0}))},cleanup:()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}};var Gp=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 Rp(`Writable`,typeof n);this._destinations.push(n);let l,u=()=>{l&&=(Hp(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&&Hp(t.eventTarget,`drain`,t.drain),t.destClose&&Hp(t.eventTarget,`close`,t.destClose),t.destFinish&&Hp(t.eventTarget,`finish`,t.destFinish),t.eventTarget.emit?.(`unpipe`,this._emitSource),this._listeners.delete(e))}};let Kp=0;function U(e){queueMicrotask(()=>{Kp++;try{e()}finally{Kp--}})}function qp(){return Kp>0}let Jp=null;function Yp(){return Jp}function Xp(e){Jp=e}function Zp(e){return Vn(this,e??`utf-8`)}var W=class e extends V{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??Fp(this._objectMode),this._buf=new Vp(this._objectMode),this._pipes=new Gp(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,U(()=>{(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(r(e.reason));return}let t=()=>{i(),this.destroy(r(e.reason))},n=()=>{i()},i=()=>{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 im(a,rm(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=zp(e,t||`utf8`);n.toString=Zp,e=n}if(this._ended&&e!==null){let e=Error(`stream.push() after EOF`);return e.code=`ERR_STREAM_PUSH_AFTER_EOF`,U(()=>this.emit(`error`,e)),!1}if(e===null)return this._ended?!1:(this._ended=!0,this._buf.length===0&&U(()=>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&&U(()=>{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&&U(()=>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&&U(()=>this._emitEndOnce()));return}if(this._endEmitted){let e=Error(`stream.unshift() after end event`);e.code=`ERR_STREAM_UNSHIFT_AFTER_END_EVENT`,U(()=>this.emit(`error`,e));return}if(typeof e==`string`&&!this._objectMode){let n=zp(e,t||`utf8`);n.toString=Zp,e=n}let n=this._buf.length===0;this._buf.unshift(e),this._flowing?U(()=>{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&&U(()=>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&&U(()=>this._emitEndOnce()),this._hasReadImpl&&!this._ended&&!this._destroyed&&this._constructed&&this._buf.length<this._highWaterMark&&U(()=>{!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&&U(()=>{!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)}),this._ended&&this._buf.length===0&&U(()=>this._emitEndOnce()),!this._flowing&&this._buf.length>0&&U(()=>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=jn(e),this}_applyEncoding(e){return this._encoding&&e instanceof Uint8Array?(this._decoder||=jn(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,U(()=>{this._resumeScheduled=!1,this.emit(`resume`)}))),this._buf.length>0?U(()=>{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?U(()=>this._emitEndOnce()):this._webStreamMode&&!this._pushMode?this._startReading():this._hasReadImpl&&U(()=>{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)&&U(()=>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,qp()&&!this._hasDestroyHook()&&r?n():U(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&&U(()=>this._emitEndOnce()),this._releaseReader();break}if(t!==void 0){let e=this._buf.length===0;for(this._buf.push(t),e&&U(()=>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,o=()=>{if(!n)return;let e=t.read();if(e!==null){let t=n;n=null,r=null,t({done:!1,value:e})}},s=()=>{o()},c=()=>{if(i=!0,n){let e=n;n=null,r=null,e({done:!0,value:void 0})}},l=e=>{if(i=!0,a=e,r){let t=r;n=null,r=null,t(e)}};t.on(`readable`,s),t.on(`end`,c),t.on(`error`,l);let u=()=>{t.off(`readable`,s),t.off(`end`,c),t.off(`error`,l)};return{next:async()=>{if(a)throw a;let e=t.read();return e===null?i?(u(),{done:!0,value:void 0}):new Promise((e,t)=>{n=e,r=t,o()}):{done:!1,value:e}},return:async e=>(u(),{done:!0,value:e}),throw:async e=>(u(),t.destroy(e),{done:!0,value:void 0}),[Symbol.asyncIterator](){return this}}}map(t,n){let i=n?.signal;Qp(i);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0});return im(c,(async function*(e){try{yield*nm(e,e=>t(e,{signal:s}),a,i)}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{c.destroy(r())},{once:!0}),c}filter(t,n){let i=n?.signal;Qp(i);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0}),l=Symbol(`skip`);return im(c,(async function*(e){try{if(a<=1)for await(let n of e)$p(i),await t(n,{signal:s})&&(yield n);else for await(let n of nm(e,async e=>await t(e,{signal:s})?e:l,a,i))n!==l&&(yield n)}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{c.destroy(r())},{once:!0}),c}async forEach(e,t){let n=t?.signal;Qp(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1)for await(let t of this)$p(n),await e(t,{signal:a});else for await(let t of nm(this,async t=>{await e(t,{signal:a})},r,n));}finally{i.abort()}}async toArray(e){let t=e?.signal;Qp(t);let n=[];for await(let e of this)$p(t),n.push(e);return n}async some(e,t){let n=t?.signal;Qp(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if($p(n),await e(t,{signal:a}))return this.destroy(),!0}else for await(let t of nm(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;Qp(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if($p(n),await e(t,{signal:a}))return this.destroy(),t}else for await(let t of nm(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;Qp(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if($p(n),!await e(t,{signal:a}))return this.destroy(),!1}else for await(let t of nm(this,t=>e(t,{signal:a}),r,n))if(!t)return this.destroy(),!1;return!0}finally{i.abort()}}flatMap(t,n){let i=n?.signal;Qp(i);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0});return im(c,(async function*(e){try{if(a<=1)for await(let n of e){$p(i);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 nm(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,i))for(let e of n)yield e}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{c.destroy(r())},{once:!0}),c}drop(t,n){let i=n?.signal;Qp(i),em(t,`limit`);let a=new e({objectMode:!0});return im(a,(async function*(e){let n=0;for await(let r of e)$p(i),n>=t&&(yield r),n++})(this)),a.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{a.destroy(r())},{once:!0}),a}take(t,n){let i=n?.signal;Qp(i),em(t,`limit`);let a=new e({objectMode:!0});return im(a,(async function*(e){let n=0;for await(let r of e){if($p(i),n>=t)break;yield r,n++}})(this)),a.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{a.destroy(r())},{once:!0}),a}async reduce(e,t,n){let r=n?.signal;Qp(r);let i=new AbortController,a=i.signal,o,s=arguments.length>=2,c=!0;try{for await(let n of this){if($p(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});im(n,t(this)),n.once(`close`,()=>{this.destroyed||this.destroy()});let r=Yp();return r?r(n):n}let r=t;if(this.pipe(r),r._readable&&r._writable)return r;if(r._readable){let e=Yp();return e?e(r._readable):r._readable}let i=Yp();return i?i(r):r}};W.prototype.addListener=W.prototype.on,W.prototype._read=function(e){let t=Error(`The _read() method is not implemented`);throw t.code=`ERR_METHOD_NOT_IMPLEMENTED`,t};function Qp(e){if(e!==void 0&&!(e instanceof AbortSignal))throw TypeError(`options.signal must be an AbortSignal`)}function $p(e){if(e?.aborted)throw r(e.reason)}function em(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 tm=Symbol(`EOF`);async function*nm(e,t,n,r){if(n<=1){for await(let n of e)$p(r),yield await t(n);return}let i=[],a=null,o=!1,s=e[Symbol.asyncIterator]();async function c(){let e=await s.next();return e.done?(o=!0,tm):($p(r),t(e.value))}function l(){i.push(c().catch(e=>{throw a=e,e}))}try{for(;i.length<n&&!o&&!a;)$p(r),l();for(;i.length>0;){$p(r);let e=await i.shift();if(a)throw a;e!==tm&&(yield e,!o&&!a&&l())}}finally{o||await s.return?.()}}function rm(e){return e&&typeof e[Symbol.asyncIterator]==`function`?e:(async function*(){for(let t of e)yield t})()}function im(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 am(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}}function om(e){return Vn(this,e??`utf-8`)}var G=class e extends V{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??Fp(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,U(()=>{(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(r(e.reason));return}let t=()=>{i(),this.destroy(r(e.reason))},n=()=>{i()},i=()=>{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 zp(``,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,U(()=>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&&U(()=>i(r)),!this._destroyed&&!this._errorEmitted&&(this._errorEmitted=!0,U(()=>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,U(()=>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?U(()=>{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,U(()=>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,U(()=>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()):U(n)});else{let t=()=>{if(this._destroyed){e?.();return}this._finished=!0,this.emit(`prefinish`),e?.(),this.emit(`finish`),this._autoDestroy&&this.destroy()};qp()?t():U(t)}}_getChunkSize(e,t){return this._objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?cm(e,t):0}_normalizeWriteChunk(e,t){if(this._objectMode||typeof e!=`string`||!this._decodeStrings)return{chunk:e,encoding:t};let n=zp(e,t);return n.toString=om,{chunk:n,encoding:`buffer`}}end(e,t,n){if(this._ended){let{chunk:r,encoding:i,cb:a}=am(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`,U(()=>a(e))}else U(()=>a?.(null));return this}this._ended=!0,this._writableOverride=void 0;let{chunk:r,encoding:i,cb:a}=am(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 U(()=>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)};qp()&&!this._hasDestroyHook()&&this._finished?r():U(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 Lp(`pipe`,`not readable`);e.code=`ERR_STREAM_CANNOT_PIPE`,U(()=>this.emit(`error`,e))}_getWriter(){return this._writer||=this._webStream.getWriter(),this._writer}static isDisturbed(e){return e&&e._readable instanceof W?W.isDisturbed(e._readable):W.isDisturbed(e)}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e._webStream}};G.prototype._writev=null,G.prototype._write=function(e,t,n){let r=Error(`The _write() method is not implemented`);throw r.code=`ERR_METHOD_NOT_IMPLEMENTED`,r};function sm(e){return e instanceof G?e:e?.getWriter?new G({stream:e}):e}function cm(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:lm(e)}function lm(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 um=class e extends V{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 W?W.isDisturbed(e._readable):W.isDisturbed(e)}static from(t){if(t instanceof e)return t;let n=(e,t)=>{let n=new G({objectMode:t.readableObjectMode,write(e,n,r){t.push(e),r()},final(e){t.push(null),e()}}),r=Up(e,`error`,e=>{t.emit(`error`,e)});Up(e,`end`,r,{once:!0}),Up(e,`close`,r,{once:!0}),Up(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=W.from([t]),i=new e({objectMode:!0});return n(r,i),i}if(typeof Blob<`u`&&t instanceof Blob){let r=W.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=W.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=G.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=W.from(t),i=new e({objectMode:r.readableObjectMode});return n(r,i),i}if(t instanceof W){let r=new e({objectMode:t.readableObjectMode});return n(t,r),r}if(t instanceof G)return new e({objectMode:t.writableObjectMode,write(e,n,r){t.write(e,n,r)},final(e){t.end(e)}});throw new Rp(`Duplex-compatible source`,typeof t)}static fromWeb(t,n){let r=new e(n),i=new W({stream:t.readable,objectMode:r.readableObjectMode}),a=new G({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:W.toWeb(e._readable),writable:G.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 W({highWaterMark:a,objectMode:n,read:u,encoding:e?.encoding,emitClose:!1,autoDestroy:!1,construct:l?e=>{s=e}:void 0}),this._writable=new G({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,U(()=>{(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(r(e.reason));return}let t=()=>{this.destroy(r(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=Wp(),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`)};V.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}=am(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`,U(()=>a(e))}else a&&U(()=>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`)};qp()&&!this._hasDestroyHook()&&this.readableEnded&&this.writableFinished?n():U(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)}};um.prototype.addListener=um.prototype.on,um.prototype._writev=null;var dm=class e extends V{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 W({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)):U(()=>{this._readable.push(null),t(null)})};this._writable=new G({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&&U(()=>{(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(r(e.reason));return}let t=()=>{this.destroy(r(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=Wp(),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`)};V.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;U(()=>{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(){return this._isSubclassTransform===void 0?this._transformImpl?(this._isSubclassTransform=!1,!1):(this._isSubclassTransform=Object.getPrototypeOf(this)._transform!==e.prototype._transform,this._isSubclassTransform):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,o=!1,s=null,c=null;if(this._transform(e,t,(e,t)=>{if(o){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(o=!0,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 i;a!==void 0&&this.push(a);return}return new Promise((e,t)=>{s=e,c=t})}let n=this._transformImpl;if(!n){let n=!0,r=!1,i=null,a,o=null,s=null;if(this._transform(e,t,(e,t)=>{if(n){r=!0,i=e??null,a=t;return}if(e){s?.(e);return}t!==void 0&&this.push(t),o?.()}),n=!1,r){if(i)throw i;a!==void 0&&this.push(a);return}return new Promise((e,t)=>{o=e,s=t})}let r=!0,i=!1,a=null,o,s=!1,c=null,l=null,u=new Promise((e,t)=>{c=e,l=t});if(n.call(this,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,r){i=!0,a=e??null,o=t;return}if(e){l?.(e);return}t!==void 0&&this.push(t),c?.()}),r=!1,i){if(a)throw a;o!==void 0&&this.push(o);return}return u}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`,U(()=>this.emit(`error`,e)),i&&U(()=>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}=am(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`,U(()=>a(e))}else a&&U(()=>a(null));return this}let{chunk:r,encoding:i,cb:a}=am(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=!qp(),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`)};qp()&&!this._hasDestroyHook()&&this.readableEnded&&this.writableFinished?r():U(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]();return this._webStream={readable:new ReadableStream({pull:async t=>{let{done:n,value:r}=await e.next();if(n){t.close();return}t.enqueue(r)},cancel:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}}),writable:new WritableStream({write:e=>new Promise((t,n)=>{this.write(e,e=>{e?n(e):t()})}),close:()=>new Promise(e=>{this.end(()=>e())}),abort:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}})},this._webStream}get readable(){return this._readable.readable}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 W?W.isDisturbed(e._readable):W.isDisturbed(e)}static from(e){return um.from(e)}static fromWeb(t,n){let r=new e(n);r._webStream=t;let i=W.fromWeb(t.readable,{objectMode:n?.objectMode}),a=G.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())}};dm.prototype.addListener=dm.prototype.on,dm.prototype._writev=null;var fm=class extends dm{constructor(e){super(e)}_transform(e,t,n){n(null,e)}};let pm=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`),mm=e=>`readableEnded`in e||`readable`in e||typeof e.read==`function`,hm=e=>`writableFinished`in e||`writable`in e||typeof e.write==`function`,gm=e=>{let t=!mm(e)||!!e.readableEnded,n=!hm(e)||!!e.writableFinished;return t&&n},_m=()=>{let e=Error(`Premature close`);return e.code=`ERR_STREAM_PREMATURE_CLOSE`,e.name=`Error [ERR_STREAM_PREMATURE_CLOSE]`,e},vm=(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()},ym=e=>e instanceof W||e instanceof G||e instanceof dm||e instanceof um?e:xp(e)?dm.fromWeb(e):yp(e)?W.fromWeb(e):bp(e)?G.fromWeb(e):e,bm=e=>typeof e==`function`&&!(e instanceof W)&&!(e instanceof G),xm=(e,t)=>{let n=t(e);return W.from(n)};function Sm(...e){let t,n={},i,a=e[e.length-1];if(typeof a==`function`){i=a;let r=e[e.length-2];pm(r)?(n=r,t=e.slice(0,-2)):t=e.slice(0,-1)}else pm(a)?(n=a,t=e.slice(0,-1)):t=e;let o=new Promise((e,i)=>{if(t.length<2){i(Error(`Pipeline requires at least 2 streams`));return}let a=t.map(ym),o=[],s=[],c=a[0];o.push(c),s.push(c);for(let e=1;e<a.length;e++){let t=a[e];bm(t)?(c=xm(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&&!gm(e)){i(_m());return}let f=!1,p=Wp(),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?i(t):e()}};if(n.signal){if(n.signal.aborted){h(r(n.signal.reason));return}m=()=>h(r(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`,()=>{vm(c,h,p)})}n.end!==!1&&p.once(u,`finish`,()=>{vm(u,h,p)});for(let e of o)p.once(e,`close`,()=>{f||gm(e)||h(_m())});for(let e of o)p.once(e,`error`,e=>h(e))});return i&&o.then(()=>i()).catch(e=>i(e)),o}function Cm(e,t,n){let i={},a;typeof t==`function`?a=t:(i=t??{},a=n);let o=new Promise((t,n)=>{let a=ym(e),o=!1,s=Wp(),c,l=()=>{s.cleanup(),c&&i.signal&&i.signal.removeEventListener(`abort`,c)},u=e=>{o||(o=!0,l(),e?n(e):t())};if(i.signal){if(i.signal.aborted){u(r(i.signal.reason));return}c=()=>u(r(i.signal.reason)),i.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=i.readable!==!1&&e,r=i.writable!==!1&&t,a=!n||!!(d.readableEnded||d._endEmitted),o=!r||!!(d.writableFinished||d._finished);a&&o?u():u(_m())}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=i.readable!==!1&&f,h=i.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()}),i.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}async function*wm(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{}}}Xp(e=>um.from(e));let Tm=new Map([[/^xl\/charts\/chart\d+\.xml$/,`application/vnd.openxmlformats-officedocument.drawingml.chart+xml`],[/^xl\/charts\/style\d+\.xml$/,`application/vnd.ms-office.chartstyle+xml`],[/^xl\/charts\/colors\d+\.xml$/,`application/vnd.ms-office.chartcolorstyle+xml`]]),Em=[`xl/charts/`];var Dm=class e{constructor(){this.files=new Map}static isPassthroughPath(e){return Em.some(t=>e.startsWith(t))}static getContentType(e){if(!e.startsWith(`xl/charts/_rels/`)){for(let[t,n]of Tm)if(t.test(e))return n}}add(e,t){this.files.set(e,t)}get(e){return this.files.get(e)}has(e){return this.files.has(e)}getPaths(){return[...this.files.keys()]}toRecord(){let e={};for(let[t,n]of this.files)e[t]=n;return e}fromRecord(e){this.files.clear();for(let[t,n]of Object.entries(e))this.files.set(t,n)}getContentTypes(){let t=[];for(let n of this.files.keys()){let r=e.getContentType(n);r&&t.push({partName:n,contentType:r})}return t}writeToZip(e){for(let[t,n]of this.files)e.append(n,{name:t})}clear(){this.files.clear()}get size(){return this.files.size}},Om=class e{static{this.textEncoder=new TextEncoder}constructor(e){this.events=new Map,this.pipedStream=null,this.finalized=!1,this.level=e?.level??6,this.modTime=e?.modTime,this.timestamps=e?.timestamps,this.zip=new op((e,t,n)=>{if(e){this._emit(`error`,e);return}t&&t.length>0&&(this._emit(`data`,t),this.pipedStream&&this.pipedStream.write(t)),n&&(this.pipedStream&&this.pipedStream.end(),this._emit(`finish`))})}_emit(e,...t){let n=this.events.get(e);if(n)for(let e of n)e(...t)}on(e,t){let n=this.events.get(e)||new Set;return n.add(t),this.events.set(e,n),this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}off(e,t){let n=this.events.get(e);return n?(n.delete(t),n.size===0&&this.events.delete(e),this):this}pipe(e){this.pipedStream=e}append(t,n){if(this.finalized)throw new b(`append`,`stream already finalized`);let r;r=n.base64?st(typeof t==`string`?t:String(t)):typeof t==`string`?e.textEncoder.encode(t):t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer?new Uint8Array(t):t;let i=new ap(n.name,{level:this.level,modTime:this.modTime,timestamps:this.timestamps});this.zip.add(i),i.push(r,!0)}finalize(){this.finalized||(this.finalized=!0,this.zip.end())}},km=class e{static{this.RelType=R}constructor(e){this.workbook=e}createBinaryStream(e){let t=new fm;return t.end(e),t}createTextStream(e){let t=new fm;return t.end(e),t}createStreamBuf(){return new hl}bufferToString(e){return Pt(e)}createZipWriter(e){return new Om(e)}async writeToZip(e,t){let{model:n}=this.workbook;this.prepareModel(n,t),await this.addContentTypes(e,n),await this.addOfficeRels(e,n),await this.addWorkbookRels(e,n),await this.addWorkbook(e,n),await this.addWorksheets(e,n),await this.addSharedStrings(e,n),this.addDrawings(e,n),this.addTables(e,n),this.addPivotTables(e,n),this.addPassthrough(e,n),await Promise.all([this.addThemes(e,n),this.addStyles(e,n)]),await this.addFeaturePropertyBag(e,n),await this.addMedia(e,n),await Promise.all([this.addApp(e,n),this.addCore(e,n)])}async read(e,t){let n=[];return await new Promise((t,r)=>{let i=e=>{n.push(e)},a=()=>{e.off(`data`,i),e.off(`end`,a),e.off(`error`,o),t()},o=t=>{e.off(`data`,i),e.off(`end`,a),e.off(`error`,o),r(t)};e.on(`data`,i),e.on(`end`,a),e.on(`error`,o)}),this.loadBuffer(k(n),t)}async write(e,t){t||={},t.zip=t.zip||{},t.zip.modTime??=this.workbook.modified??this.workbook.created;let n=this.createZipWriter(t.zip);return n.pipe(e),await this.writeToZip(n,t),this._finalize(n)}async load(e,t){let n,r=typeof Buffer<`u`?Buffer.isBuffer(e):!1;if(!e||typeof e==`object`&&!r&&!(e instanceof Uint8Array)&&!(e instanceof ArrayBuffer))throw new y(`<input>`,`read`,`Can't read the data of 'the loaded zip file'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?`);return n=t&&t.base64?st(e.toString()):e instanceof ArrayBuffer?new Uint8Array(e):e instanceof Uint8Array?e:new Uint8Array(e),this.loadBuffer(n,t)}async loadBuffer(e,t){let n=await new Pp(e).extractAll(),r={};for(let[e,t]of n)r[e]=t;return this.loadFromFiles(r,t)}createEmptyModel(){return{worksheets:[],worksheetHash:{},worksheetRels:[],themes:{},media:[],mediaIndex:{},drawings:{},drawingRels:{},rawDrawings:{},comments:{},tables:{},vmlDrawings:{},pivotTables:{},pivotTableRels:{},pivotCacheDefinitions:{},pivotCacheRecords:{},passthrough:{}}}async collectStreamData(e){let t=[];return await new Promise((n,r)=>{e.on(`data`,e=>{typeof e==`string`?t.push(new TextEncoder().encode(e)):e instanceof Uint8Array?t.push(e):t.push(new Uint8Array(e))}),e.on(`end`,()=>n()),e.on(`error`,r)}),k(t)}drawingHasChartReference(e){return e.rels&&e.rels.some(e=>e.Target&&e.Target.includes(`/charts/`))}drawingRelsHasChartReference(e){return Array.isArray(e)&&e.some(e=>typeof e?.Target==`string`&&e.Target.includes(`/charts/`))}async _processKnownEntry(e,t,n,r){let i=_a(n);if(i!==void 0)return await this._processWorksheetEntry(e,t,i,r,n),!0;switch(n){case I.rootRels:return t.globalRels=await this.parseRels(e),!0;case I.xlWorkbook:{let n=await this.parseWorkbook(e);return t.sheets=n.sheets,t.definedNames=n.definedNames,t.views=n.views,t.properties=n.properties,t.calcProperties=n.calcProperties,t.pivotCaches=n.pivotCaches,!0}case I.xlSharedStrings:return t.sharedStrings=new $i,await t.sharedStrings.parseStream(e),!0;case I.xlWorkbookRels:return t.workbookRels=await this.parseRels(e),!0;case I.docPropsApp:{let n=await new go().parseStream(e);return n&&(t.company=n.company,t.manager=n.manager),!0}case I.docPropsCore:{let n=await new Ji().parseStream(e);return Object.assign(t,n),!0}case I.xlStyles:return t.styles=new Ki,await t.styles.parseStream(e),!0;default:return!1}}async loadFromZipEntries(e,t){let n=this.createEmptyModel();for await(let r of e){let e=!1,i=async()=>{e||(e=!0,await r.drain())};if(r.type===`Directory`){await i();continue}let a=ga(r.name),o=r.stream;try{await this._processKnownEntry(o,n,a,t)||await this._processDefaultEntry(o,n,a)||await i()}finally{try{await i()}catch{}}}return this.reconcile(n,t),this.workbook.model=n,this.workbook}async writeBuffer(e){e||={},e.zip=e.zip||{},e.zip.modTime??=this.workbook.modified??this.workbook.created;let t=this.createZipWriter(e.zip),n=this.createStreamBuf();return t.pipe(n),await this.writeToZip(t,e),await this._finalize(t),n.read()||new Uint8Array}async addMedia(e,t){await Promise.all(t.media.map(async t=>{if(t.type!==`image`)throw new C(`Unsupported media`);let n=Fa(`${t.name??`undefined`}.${t.extension}`);if(t.filename){if(this.readFileAsync){let r=await this.readFileAsync(t.filename);return e.append(r,{name:n})}throw new v(`Loading images from filename`,`not supported in this environment`)}if(t.buffer)return e.append(t.buffer,{name:n});if(t.base64){let r=t.base64.substring(t.base64.indexOf(`,`)+1);return e.append(r,{name:n,base64:!0})}throw new C(`Unsupported media`)}))}parseRels(e){return new ta().parseStream(e)}parseWorkbook(e){return new Ao().parseStream(e)}parseSharedStrings(e){return new $i().parseStream(e)}reconcile(e,t){let n=new Ao,r=new Qs(t),i=new _c,a=new wc;n.reconcile(e);let o={media:e.media,mediaIndex:e.mediaIndex};if(Object.keys(e.drawings).forEach(t=>{let n=e.drawings[t],r=e.drawingRels[t];r&&(o.rels=r.reduce((e,t)=>(e[t.Id]=t,e),{}),(n.anchors??[]).forEach(e=>{let t=e.picture&&e.picture.hyperlinks;t&&o.rels[t.rId]&&(t.hyperlink=o.rels[t.rId].Target,delete t.rId)}),i.reconcile(n,o))}),e.rawDrawings&&e.drawingRels)for(let t of Object.keys(e.rawDrawings)){let n=e.drawingRels[t];n&&!this.drawingRelsHasChartReference(n)&&delete e.rawDrawings[t]}let s={styles:e.styles};Object.values(e.tables).forEach(e=>{a.reconcile(e,s)}),this._reconcilePivotTables(e);let c={styles:e.styles,sharedStrings:e.sharedStrings,media:e.media,mediaIndex:e.mediaIndex,date1904:e.properties?.date1904,drawings:e.drawings,drawingRels:e.drawingRels,comments:e.comments,tables:e.tables,vmlDrawings:e.vmlDrawings,pivotTables:e.pivotTablesIndexed};e.worksheets.forEach(t=>{t.relationships=e.worksheetRels[t.sheetNo],r.reconcile(t,c)}),delete e.worksheetHash,delete e.worksheetRels,delete e.globalRels,delete e.sharedStrings,delete e.workbookRels,delete e.sheetDefs,e.defaultFont=e.styles?.defaultFont,delete e.styles,delete e.mediaIndex,delete e.drawings,delete e.drawingRels,delete e.vmlDrawings,delete e.pivotTableRels}_reconcilePivotTables(e){let t=e.pivotTables||{};if(typeof t!=`object`||Object.keys(t).length===0){e.pivotTables=[],e.pivotTablesIndexed={};return}let n=this._buildDefinitionToCacheIdMap(e),r=new Map;Object.entries(e.pivotCacheDefinitions||{}).forEach(([t,i])=>{let a=n.get(t);if(a!==void 0){let n=t.replace(`Definition`,`Records`);r.set(a,{definition:i,records:e.pivotCacheRecords?.[n],definitionName:t})}});let i=[],a={};Object.entries(t).forEach(([e,t])=>{let n=this._extractTableNumber(e),o=r.get(t.cacheId),s=this._determineMetric(t.dataFields),c={...t,tableNumber:n,cacheId:String(t.cacheId),cacheDefinition:o?.definition,cacheRecords:o?.records,cacheFields:o?.definition?.cacheFields??[],rows:t.rowFields.filter(e=>e>=0),columns:t.colFields.filter(e=>e>=0&&e!==-2),values:t.dataFields.map(e=>e.fld),pages:t.pageFields.map(e=>e.fld),metric:s,valueMetrics:this._determineValueMetrics(t.dataFields,s),applyWidthHeightFormats:t.applyWidthHeightFormats===`1`?`1`:`0`};i.push(c),a[oo(e)]=c}),i.sort((e,t)=>e.tableNumber-t.tableNumber),e.pivotTables=i,e.pivotTablesIndexed=a}_extractTableNumber(e){let t=e.match(/pivotTable(\d+)/);return t?parseInt(t[1],10):1}_buildCacheIdMap(e){let t=new Map,n=e.pivotCaches??[];for(let e of n)e.cacheId&&e.rId&&t.set(e.rId,parseInt(e.cacheId,10));return t}_buildDefinitionToCacheIdMap(t){let n=new Map,r=this._buildCacheIdMap(t),i=t.workbookRels??[];for(let t of i)if(t.Type===e.RelType.PivotCacheDefinition&&t.Target){let e=t.Target.match(/pivotCacheDefinition(\d+)\.xml/);if(e){let i=`pivotCacheDefinition${e[1]}`,a=r.get(t.Id);a!==void 0&&n.set(i,a)}}return n}_determineMetric(e){return e.length>0&&e[0].subtotal?e[0].subtotal:`sum`}_determineValueMetrics(e,t){return e.map(e=>e.subtotal||t)}async _processWorksheetEntry(e,t,n,r,i){let a=await new Qs(r).parseStream(e);if(!a)throw new _(i,`Failed to parse worksheet`);a.sheetNo=n,t.worksheetHash[i]=a,t.worksheets.push(a)}async _processCommentEntry(e,t,n){let r=await new Zc().parseStream(e);t.comments[io(n)]=r}async _processTableEntry(e,t,n){let r=await new wc().parseStream(e);t.tables[co(n)]=r}async _processWorksheetRelsEntry(e,t,n){let r=await new ta().parseStream(e);t.worksheetRels[n]=r}async _processMediaEntry(e,t,n){let r=n.lastIndexOf(`.`);if(r>=1){let i=n.substr(r+1),a=n.substr(0,r);await new Promise((r,o)=>{let s=this.createStreamBuf(),c=()=>{e.off(`error`,u),s.off(`error`,u),s.off(`finish`,l)},l=()=>{c(),t.mediaIndex[n]=t.media.length,t.mediaIndex[a]=t.media.length;let e={type:`image`,name:a,extension:i,buffer:s.read()};t.media.push(e),r()},u=e=>{c(),o(e)};s.once(`finish`,l),e.on(`error`,u),s.on(`error`,u),e.pipe(s)})}}async _processDrawingEntry(e,t,n,r){let i=r??await this.collectStreamData(e),a=new _c,o=this.bufferToString(i),s=await a.parseStream(this.createTextStream(o));t.drawings[n]=s,t.rawDrawings[n]=i}async _processDrawingRelsEntry(e,t,n){let r=await new ta().parseStream(e);t.drawingRels[n]=r}async _processVmlDrawingEntry(e,t,n){let r=await new al().parseStream(e);t.vmlDrawings[ro(n)]=r}async _processThemeEntry(e,t,n){await new Promise((r,i)=>{let a=this.createStreamBuf(),o=()=>{e.off(`error`,c),a.off(`error`,c),a.off(`finish`,s)},s=()=>{o();let e=a.read();t.themes[n]=e?typeof e==`string`?e:this.bufferToString(e):``,r()},c=e=>{o(),i(e)};a.once(`finish`,s),e.on(`error`,c),a.on(`error`,c),e.pipe(a)})}async _processPivotTableEntry(e,t,n){let r=await new Gc().parseStream(e);r&&(t.pivotTables[n]=r)}async _processPivotTableRelsEntry(e,t,n){let r=await new ta().parseStream(e);t.pivotTableRels[n]=r}async _processPivotCacheDefinitionEntry(e,t,n){let r=await new zc().parseStream(e);r&&(t.pivotCacheDefinitions[n]=r)}async _processPivotCacheRecordsEntry(e,t,n){let r=await new jc().parseStream(e);r&&(t.pivotCacheRecords[n]=r)}async loadFromFiles(e,t){let n=this.createEmptyModel(),r=Object.keys(e).map(t=>({name:t,dir:t.endsWith(`/`),data:e[t]}));for(let e of r)if(!e.dir){let r=ga(e.name),i=Ca(r)?this.createBinaryStream(e.data):this.createTextStream(this.bufferToString(e.data));await this._processKnownEntry(i,n,r,t)||await this._processDefaultEntry(i,n,r,e.data)}return this.reconcile(n,t),this.workbook.model=n,this.workbook}async _processDefaultEntry(e,t,n,r){let i=va(n);if(i!==void 0)return await this._processWorksheetRelsEntry(e,t,i),!0;let a=ba(n);if(a)return await this._processMediaEntry(e,t,a),!0;let o=wa(n);if(o)return await this._processDrawingEntry(e,t,o,r),!0;let s=Ta(n);if(s)return await this._processDrawingRelsEntry(e,t,s),!0;let c=Ea(n);if(c)return await this._processVmlDrawingEntry(e,t,c),!0;let l=Da(n);if(l)return await this._processCommentEntry(e,t,`comments${l}`),!0;let u=Oa(n);if(u)return await this._processTableEntry(e,t,u),!0;let d=Sa(n);if(d)return await this._processThemeEntry(e,t,d),!0;let f=ka(n);if(f)return await this._processPivotTableEntry(e,t,f),!0;let p=Aa(n);if(p)return await this._processPivotTableRelsEntry(e,t,p),!0;let m=ja(n);if(m)return await this._processPivotCacheDefinitionEntry(e,t,m),!0;if(Ma(n))return!0;let h=Na(n);return h?(await this._processPivotCacheRecordsEntry(e,t,h),!0):Dm.isPassthroughPath(n)?(r?t.passthrough[n]=r:await this._processPassthroughEntry(e,t,n),!0):!1}async _processPassthroughEntry(e,t,n){let r=await this.collectStreamData(e);t.passthrough[n]=r}async addContentTypes(e,t){let n=new po().toXml(t);e.append(n,{name:I.contentTypes})}async addApp(e,t){let n=new go().toXml(t);e.append(n,{name:I.docPropsApp})}async addCore(e,t){let n=new Ji;e.append(n.toXml(t),{name:I.docPropsCore})}async addThemes(e,t){let n=t.themes||{theme1:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
319
319
  <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> </a:lnStyleLst> <a:effectStyleLst> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="38000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> <a:scene3d> <a:camera prst="orthographicFront"> <a:rot lat="0" lon="0" rev="0"/> </a:camera> <a:lightRig rig="threePt" dir="t"> <a:rot lat="0" lon="0" rev="1200000"/> </a:lightRig> </a:scene3d> <a:sp3d> <a:bevelT w="63500" h="25400"/> </a:sp3d> </a:effectStyle> </a:effectStyleLst> <a:bgFillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="40000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="40000"> <a:schemeClr val="phClr"> <a:tint val="45000"/> <a:shade val="99000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="20000"/> <a:satMod val="255000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/> </a:path> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="80000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="30000"/> <a:satMod val="200000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="50000" r="50000" b="50000"/> </a:path> </a:gradFill> </a:bgFillStyleLst> </a:fmtScheme> </a:themeElements> <a:objectDefaults> <a:spDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="1"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="3"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="2"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="lt1"/> </a:fontRef> </a:style> </a:spDef> <a:lnDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="2"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="0"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="1"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="tx1"/> </a:fontRef> </a:style> </a:lnDef> </a:objectDefaults> <a:extraClrSchemeLst/> </a:theme>`};Object.keys(n).forEach(t=>{let r=n[t];e.append(r,{name:Pa(t)})})}async addOfficeRels(t,n){let r=new ta().toXml([{Id:`rId1`,Type:e.RelType.OfficeDocument,Target:I.xlWorkbook},{Id:`rId2`,Type:e.RelType.CoreProperties,Target:I.docPropsCore},{Id:`rId3`,Type:e.RelType.ExtenderProperties,Target:I.docPropsApp}]);t.append(r,{name:I.rootRels})}async addWorkbookRels(t,n){let r=1,i=[{Id:`rId${r++}`,Type:e.RelType.Styles,Target:Qa.workbookStyles},{Id:`rId${r++}`,Type:e.RelType.Theme,Target:Qa.workbookTheme1}];n.sharedStrings.count&&i.push({Id:`rId${r++}`,Type:e.RelType.SharedStrings,Target:Qa.workbookSharedStrings}),n.hasCheckboxes&&i.push({Id:`rId${r++}`,Type:e.RelType.FeaturePropertyBag,Target:Qa.workbookFeaturePropertyBag});let a=new Map;(n.pivotTables??[]).forEach(t=>{let n=a.get(t.cacheId);n?t.rId=n:(t.rId=`rId${r++}`,a.set(t.cacheId,t.rId),i.push({Id:t.rId,Type:e.RelType.PivotCacheDefinition,Target:$a(t.tableNumber)}))}),n.worksheets.forEach(t=>{t.rId=`rId${r++}`,i.push({Id:t.rId,Type:e.RelType.Worksheet,Target:Ra(t.fileIndex)})});let o=new ta().toXml(i);t.append(o,{name:I.xlWorkbookRels})}async addFeaturePropertyBag(e,t){if(!t.hasCheckboxes)return;let n=new $s;e.append(n.toXml({}),{name:I.xlFeaturePropertyBag})}async addSharedStrings(e,t){t.sharedStrings&&t.sharedStrings.count&&e.append(t.sharedStrings.xml,{name:I.xlSharedStrings})}async addStyles(e,t){let{xml:n}=t.styles;n&&e.append(n,{name:I.xlStyles})}async addWorkbook(e,t){let n=new Ao;e.append(n.toXml(t),{name:I.xlWorkbook})}async addWorksheets(e,t){let n=new Qs,r=new ta,i=new Zc,a=new al,o=new ol;t.worksheets.forEach(t=>{let{fileIndex:s}=t,c=new A;n.render(c,t),e.append(c.xml,{name:Ia(s)}),t.rels&&t.rels.length&&(c=new A,r.render(c,t.rels),e.append(c.xml,{name:La(s)})),t.comments.length>0&&(c=new A,i.render(c,t),e.append(c.xml,{name:za(s)}));let l=t.comments.length>0,u=t.formControls&&t.formControls.length>0;(l||u)&&(c=new A,a.render(c,{comments:l?t.comments:[],formControls:u?t.formControls:[]}),e.append(c.xml,{name:Va(s)})),u&&t.formControls.forEach(t=>{let n=o.toXml(t);e.append(n,{name:uo(t.ctrlPropId)})})})}addDrawings(e,t){let n=new _c,r=new ta,i=t.rawDrawings||{};t.worksheets.forEach(t=>{let{drawing:a}=t;if(a){if(this.drawingHasChartReference(a)&&i[a.name])e.append(i[a.name],{name:Ua(a.name)});else{let t=Ys(a.anchors??[]),r=a.anchors?{...a,anchors:t}:a;n.prepare(r);let i=n.toXml(r);e.append(i,{name:Ua(a.name)})}let t=r.toXml(a.rels);e.append(t,{name:Wa(a.name)})}})}addTables(e,t){let n=new wc;t.worksheets.forEach(t=>{let{tables:r}=t;r.forEach(t=>{n.prepare(t,{});let r=n.toXml(t);e.append(r,{name:Ha(t.target)})})})}addPassthrough(e,t){let n=new Dm;n.fromRecord(t.passthrough||{}),n.writeToZip(e)}addPivotTables(t,n){if(!n.pivotTables.length)return;let r=new jc,i=new zc,a=new Gc,o=new ta,s=new Map;n.pivotTables.forEach(n=>{let c=n.tableNumber,l=n.isLoaded,u=n.cacheId;if(!s.has(u)){if(s.set(u,c),l){if(n.cacheDefinition){let e=i.toXml(n.cacheDefinition);t.append(e,{name:Ga(c)})}if(n.cacheRecords){let e=r.toXml(n.cacheRecords);t.append(e,{name:qa(c)})}}else{let e=r.toXml(n);t.append(e,{name:qa(c)}),e=i.toXml(n),t.append(e,{name:Ga(c)})}if(!l||n.cacheRecords){let r=(l?n.cacheDefinition?.rId:void 0)??`rId1`,i=o.toXml([{Id:r,Type:e.RelType.PivotCacheRecords,Target:Ja(c)}]);t.append(i,{name:Ka(c)})}}let d=a.toXml(n);t.append(d,{name:Ya(c)});let f=s.get(u);d=o.toXml([{Id:`rId1`,Type:e.RelType.PivotCacheDefinition,Target:Za(f)}]),t.append(d,{name:Xa(c)})})}_finalize(e){return new Promise((t,n)=>{e.on(`finish`,()=>{t(this)}),e.on(`error`,n),e.finalize()})}prepareModel(e,t){e.creator=e.creator??`ExcelTS`,e.lastModifiedBy=e.lastModifiedBy??`ExcelTS`,e.created=e.created??new Date,e.modified=e.modified??new Date,e.useSharedStrings=t.useSharedStrings===void 0?!0:t.useSharedStrings,e.useStyles=t.useStyles===void 0?!0:t.useStyles,e.sharedStrings=new $i;let n=e.defaultFont;e.styles=e.useStyles?new Ki(!0):new Ki.Mock,n&&e.styles.setDefaultFont&&e.styles.setDefaultFont(n);let r=new Ao,i=new Qs;r.prepare(e);let a={sharedStrings:e.sharedStrings,styles:e.styles,date1904:e.properties?.date1904,drawingsCount:0,media:e.media};a.drawings=e.drawings=[],a.commentRefs=e.commentRefs=[],a.formControlRefs=e.formControlRefs=[];let o=0;e.tables=[],e.worksheets.forEach((t,n)=>{t.fileIndex=n+1,t.tables.forEach(t=>{o++,t.target=`table${o}.xml`,t.id=o,e.tables.push(t)}),i.prepare(t,a)}),e.hasCheckboxes=e.styles.hasCheckboxes;let s=e.passthrough||{},c=new Dm;c.fromRecord(s),e.passthroughContentTypes=c.getContentTypes()}},Am=class{constructor(){this._values=[],this._totalRefs=0,this._hash=Object.create(null)}get count(){return this._values.length}get values(){return this._values}get totalRefs(){return this._totalRefs}getString(e){return this._values[e]}add(e){let t=this._hash[e];return t===void 0&&(t=this._hash[e]=this._values.length,this._values.push(e)),this._totalRefs++,t}},jm=class{constructor(e){this.writer=e}push(e){this.writer.addHyperlink(e)}},Mm=class{constructor(e){this.id=e.id,this.count=0,this._hyperlinks=[],this._workbook=e.workbook}get stream(){return this._stream||=this._workbook._openStream(La(this.id)),this._stream}get length(){return this._hyperlinks.length}each(e){return this._hyperlinks.forEach(e)}get hyperlinksProxy(){return this._hyperlinksProxy||=new jm(this)}addHyperlink(e){if(No(e.target)){this._hyperlinks.push({address:e.address,target:e.target});return}let t={Target:e.target,Type:R.Hyperlink,TargetMode:`External`},n=this._writeRelationship(t);this._hyperlinks.push({rId:n,address:e.address})}addMedia(e){return this._writeRelationship(e)}addRelationship(e){return this._writeRelationship(e)}commit(){this.count&&(this._writeClose(),this.stream.end())}_writeOpen(){this.stream.write(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
320
320
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`)}_writeRelationship(e){this.count||this._writeOpen();let t=`rId${++this.count}`;return e.TargetMode?this.stream.write(`<Relationship Id="${t}" Type="${e.Type}" Target="${bt(e.Target)}" TargetMode="${e.TargetMode}"/>`):this.stream.write(`<Relationship Id="${t}" Type="${e.Type}" Target="${e.Target}"/>`),t}_writeClose(){this.stream.write(`</Relationships>`)}},Nm=class{constructor(e,t,n){this.id=n.id,this.count=0,this._worksheet=e,this._workbook=n.workbook,this._sheetRelsWriter=t}get commentsStream(){return this._commentsStream||=this._workbook._openStream(za(this.id)),this._commentsStream}get vmlStream(){return this._vmlStream||=this._workbook._openStream(Va(this.id)),this._vmlStream}_addRelationships(){let e={Type:R.Comments,Target:eo(this.id)};this._sheetRelsWriter.addRelationship(e);let t={Type:R.VmlDrawing,Target:to(this.id)};this.vmlRelId=this._sheetRelsWriter.addRelationship(t)}_addCommentRefs(){this._workbook.commentRefs.push({commentName:`comments${this.id}`,vmlDrawing:`vmlDrawing${this.id}`})}_writeOpen(){this.commentsStream.write(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><authors><author>Author</author></authors><commentList>`),this.vmlStream.write(`<?xml version="1.0" encoding="UTF-8"?><xml xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:x="urn:schemas-microsoft-com:office:excel"><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1" /></o:shapelayout><v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"><v:stroke joinstyle="miter" /><v:path gradientshapeok="t" o:connecttype="rect" /></v:shapetype>`)}_writeComment(e,t){let n=new Xc,r=new A;n.render(r,e),this.commentsStream.write(r.xml);let i=new il,a=new A;i.render(a,e,t),this.vmlStream.write(a.xml)}_writeClose(){this.commentsStream.write(`</commentList></comments>`),this.vmlStream.write(`</xml>`)}addComments(e){e&&e.length&&(this.startedData||=(this._worksheet.comments=[],this._writeOpen(),this._addRelationships(),this._addCommentRefs(),!0),e.forEach(e=>{e.refAddress=w.decodeAddress(e.ref)}),e.forEach(e=>{this._writeComment(e,this.count),this.count+=1}))}commit(){this.count&&(this._writeClose(),this.commentsStream.end(),this.vmlStream.end())}};let K=new ll,q={dataValidations:new Wo,sheetProperties:new Jo,sheetFormatProperties:new Yo,columns:new N({tag:`cols`,count:!1,childXform:new Ro}),row:new Lo,hyperlinks:new N({tag:`hyperlinks`,count:!1,childXform:new Mo}),sheetViews:new N({tag:`sheetViews`,count:!1,childXform:new Zo}),sheetProtection:new es,pageMargins:new ts,pageSeteup:new ss,autoFilter:new us,picture:new ds,drawing:new fs,conditionalFormattings:new Ms,headerFooter:new _s,rowBreaks:new hs,colBreaks:new gs};var Pm=class{constructor(e){this.id=e.id,this.name=e.name||`Sheet${this.id}`,this.state=e.state??`visible`,this._rows=[],this._columns=[],this._keys={},this._merges=[],this._merges.add=function(){},this._sheetRelsWriter=new Mm(e),this._sheetCommentsWriter=new Nm(this,this._sheetRelsWriter,e),this._dimensions=new T,this._rowZero=1,this._rowOffset=0,this.committed=!1,this.dataValidations=new Qe,this._formulae={},this._siFormulae=0,this.conditionalFormatting=[],this.rowBreaks=[],this.colBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,outlineLevelCol:0,outlineLevelRow:0},e.properties),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},e.headerFooter),this.pageSetup=Object.assign({},{margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:`portrait`,horizontalDpi:4294967295,verticalDpi:4294967295,fitToPage:!!(e.pageSetup&&(e.pageSetup.fitToWidth||e.pageSetup.fitToHeight)&&!e.pageSetup.scale),pageOrder:`downThenOver`,blackAndWhite:!1,draft:!1,cellComments:`None`,errors:`displayed`,scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},e.pageSetup),this.useSharedStrings=e.useSharedStrings??!1,this._workbook=e.workbook,this.hasComments=!1,this._views=e.views??[],this.autoFilter=e.autoFilter??null,this._media=[],this.sheetProtection=null,this._writeOpenWorksheet(),this.startedData=!1}get workbook(){return this._workbook}get stream(){return this._stream||=this._workbook._openStream(Ia(this.id)),this._stream}destroy(){throw new b(`destroy`,`Invalid operation for a streaming writer`)}commit(){if(!this.committed){for(let e=this._rowOffset;e<this._rows.length;e++){let t=this._rows[e];t&&this._writeRow(t)}this._rows=null,this.startedData||this._writeOpenSheetData(),this._writeCloseSheetData(),this._writeSheetProtection(),this._writeAutoFilter(),this._writeMergeCells(),this._writeHyperlinks(),this._writeConditionalFormatting(),this._writeDataValidations(),this._writePageMargins(),this._writePageSetup(),this._writeHeaderFooter(),this._writeRowBreaks(),this._writeColBreaks(),this._writeDrawing(),this._writeBackground(),this._writeLegacyData(),this._writeCloseWorksheet(),this.stream.end(),this._sheetCommentsWriter.commit(),this._sheetRelsWriter.commit(),this.committed=!0}}get dimensions(){return this._dimensions}get views(){return this._views}get columns(){return this._columns}set columns(e){this._headerRowCount=e.reduce((e,t)=>{let n=t.header&&1||t.headers&&t.headers.length||0;return Math.max(e,n)},0);let t=1,n=this._columns=[];e.forEach(e=>{let r=new Re(this,t++,!1);n.push(r),r.defn=e})}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){Object.keys(this._keys).forEach(t=>e(this._keys[t],t))}getColumn(e){if(typeof e==`string`){let t=this._keys[e];if(t)return t;e=w.l2n(e)}if(e>this._columns.length){let t=this._columns.length+1;for(;t<=e;)this._columns.push(new Re(this,t++))}return this._columns[e-1]}get _nextRow(){return this._rowZero+(this._rows.length-this._rowOffset)}eachRow(e,t){let n,r;if(typeof e==`function`?(n=e,r=void 0):(n=t,r=e),r&&r.includeEmpty){let e=this._nextRow;for(let t=this._rowZero;t<e;t++)n(this.getRow(t),t)}else this._rows.forEach(e=>{e&&e.hasValues&&n(e,e.number)})}_commitRow(e){let t=!1,n=this._rows;for(;this._rowOffset<n.length&&!t;){let r=n[this._rowOffset];n[this._rowOffset]=void 0,this._rowOffset++,this._rowZero++,r&&(this._writeRow(r),t=r.number===e.number,this._rowZero=r.number+1),this._rowOffset>1024&&this._rowOffset>n.length>>1&&(n.splice(0,this._rowOffset),this._rowOffset=0)}}get lastRow(){let e=this._rows;for(let t=e.length-1;t>=this._rowOffset;t--){let n=e[t];if(n)return n}}findRow(e){let t=e-this._rowZero+this._rowOffset;return this._rows[t]}getRow(e){let t=e-this._rowZero+this._rowOffset;if(t<this._rowOffset)throw new m(e,`this row has been committed`);let n=this._rows[t];return n||(this._rows[t]=n=new Le(this,e)),n}addRow(e){let t=new Le(this,this._nextRow);return this._rows[t.number-this._rowZero+this._rowOffset]=t,t.values=e,t}findCell(e,t){let n=w.getAddress(e,t),r=this.findRow(n.row);return r?r.findCell(n.col):void 0}getCell(e,t){let n=w.getAddress(e,t);return this.getRow(n.row).getCellEx(n)}mergeCells(...e){let t=new T(e);this._merges.forEach(e=>{if(e.intersects(t))throw new h});let{top:n,left:r,bottom:i,right:a}=t,o=Jt(n,r,i,a,(e,t)=>this.findCell(e,t)),s=this.getCell(n,r);for(let e=n;e<=i;e++)for(let t=r;t<=a;t++)(e>n||t>r)&&this.getCell(e,t).merge(s);o&&Yt(n,r,i,a,o,(e,t)=>this.getCell(e,t)),this._merges.push(t)}addConditionalFormatting(e){this.conditionalFormatting.push(e)}removeConditionalFormatting(e){typeof e==`number`?this.conditionalFormatting.splice(e,1):e instanceof Function?this.conditionalFormatting=this.conditionalFormatting.filter(e):this.conditionalFormatting=[]}addBackgroundImage(e){this._background={imageId:Number(e)}}getBackgroundImageId(){return this._background&&this._background.imageId}addImage(e,t){let n=this._parseImageRange(String(e),t);this._media.push(n)}getImages(){return this._media}_parseImageRange(e,t){if(typeof t==`string`){let n=w.decode(t);if(`top`in n)return{type:`image`,imageId:e,range:{tl:new Ve(this,{col:n.left,row:n.top},-1).model,br:new Ve(this,{col:n.right,row:n.bottom},0).model,editAs:`oneCell`}};throw Error(`Invalid image range: "${t}". Expected a range like "A1:C3".`)}return{type:`image`,imageId:e,range:{tl:new Ve(this,t.tl,0).model,br:t.br?new Ve(this,t.br,0).model:void 0,ext:t.ext,editAs:t.editAs},hyperlinks:t.hyperlinks}}async protect(e,t){this.sheetProtection={sheet:!0},this.sheetProtection=await Jn(e,t)}unprotect(){this.sheetProtection=null}_write(e){K.reset(),K.addText(e),this.stream.write(K)}_writeSheetProperties(e,t,n){let r={outlineProperties:t&&t.outlineProperties,tabColor:t&&t.tabColor,pageSetup:n&&n.fitToPage?{fitToPage:n.fitToPage}:void 0};e.addText(q.sheetProperties.toXml(r))}_writeSheetFormatProperties(e,t){let n=t?{defaultRowHeight:t.defaultRowHeight,dyDescent:t.dyDescent,outlineLevelCol:t.outlineLevelCol,outlineLevelRow:t.outlineLevelRow}:void 0;t&&t.defaultColWidth&&(n.defaultColWidth=t.defaultColWidth),e.addText(q.sheetFormatProperties.toXml(n))}_writeOpenWorksheet(){K.reset(),K.addText(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>`),K.addText(`<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">`),this._writeSheetProperties(K,this.properties,this.pageSetup),K.addText(q.sheetViews.toXml(this.views)),this._writeSheetFormatProperties(K,this.properties),this.stream.write(K)}_writeColumns(){let e=Re.toModel(this.columns);e&&(q.columns.prepare(e,{styles:this._workbook.styles}),this.stream.write(q.columns.toXml(e)))}_writeOpenSheetData(){this._write(`<sheetData>`)}_writeRow(e){if(this.startedData||=(this._writeColumns(),this._writeOpenSheetData(),!0),e.hasValues||e.height!=null){let{model:t}=e,n={styles:this._workbook.styles,sharedStrings:this.useSharedStrings?this._workbook.sharedStrings:void 0,hyperlinks:this._sheetRelsWriter.hyperlinksProxy,merges:this._merges,formulae:this._formulae,siFormulae:this._siFormulae,comments:[]};q.row.prepare(t,n),this.stream.write(q.row.toXml(t)),n.comments.length&&(this.hasComments=!0,this._sheetCommentsWriter.addComments(n.comments))}}_writeCloseSheetData(){this._write(`</sheetData>`)}_writeMergeCells(){this._merges.length&&(K.reset(),K.addText(`<mergeCells count="${this._merges.length}">`),this._merges.forEach(e=>{K.addText(`<mergeCell ref="${e}"/>`)}),K.addText(`</mergeCells>`),this.stream.write(K))}_writeHyperlinks(){this.stream.write(q.hyperlinks.toXml(this._sheetRelsWriter._hyperlinks))}_writeConditionalFormatting(){let e={styles:this._workbook.styles};q.conditionalFormattings.prepare(this.conditionalFormatting,e),this.stream.write(q.conditionalFormattings.toXml(this.conditionalFormatting))}_writeRowBreaks(){this.stream.write(q.rowBreaks.toXml(this.rowBreaks))}_writeColBreaks(){this.stream.write(q.colBreaks.toXml(this.colBreaks))}_writeDataValidations(){this.stream.write(q.dataValidations.toXml(this.dataValidations.model))}_writeSheetProtection(){this.stream.write(q.sheetProtection.toXml(this.sheetProtection))}_writePageMargins(){this.stream.write(q.pageMargins.toXml(this.pageSetup.margins))}_writePageSetup(){this.stream.write(q.pageSeteup.toXml(this.pageSetup))}_writeHeaderFooter(){this.stream.write(q.headerFooter.toXml(this.headerFooter))}_writeAutoFilter(){this.stream.write(q.autoFilter.toXml(this.autoFilter))}_writeDrawing(){if(this._media.length===0)return;let e=`drawing${this.id}`,t=this._sheetRelsWriter.addRelationship({Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:no(e)}),{anchors:n,rels:r}=Js(this._media,[],{getBookImage:e=>this._workbook.getImage(Number(e)),nextRId:e=>`rId${e.length+1}`});this._drawing={rId:t,name:e,anchors:n,rels:r},this.stream.write(q.drawing.toXml({rId:t}))}get drawing(){return this._drawing}_writeBackground(){if(this._background){if(this._background.imageId!==void 0){let e=this._workbook.getImage(this._background.imageId),t=this._sheetRelsWriter.addMedia({Target:lo(e.name),Type:R.Image});this._background={...this._background,rId:t}}this.stream.write(q.picture.toXml({rId:this._background.rId}))}}_writeLegacyData(){this.hasComments&&(K.reset(),K.addText(`<legacyDrawing r:id="${this._sheetCommentsWriter.vmlRelId}"/>`),this.stream.write(K))}_writeDimensions(){}_writeCloseWorksheet(){this._write(`</worksheet>`)}};let Fm=new Uint8Array,Im=new TextDecoder;var Lm=class{constructor(e,t){this.WorksheetWriterClass=t,this.created=e.created||new Date,this.modified=e.modified||this.created,this.creator=e.creator??`ExcelTS`,this.lastModifiedBy=e.lastModifiedBy??`ExcelTS`,this.lastPrinted=e.lastPrinted,this.useSharedStrings=e.useSharedStrings??!1,this.sharedStrings=new Am,this.styles=e.useStyles?new Ki(!0):new Ki.Mock(!0),this._definedNames=new ni,this._worksheets=[],this.views=[],this.zipOptions=e.zip;let n=e.zip?.zlib?.level??e.zip?.compressionOptions?.level??6;this.compressionLevel=Math.max(0,Math.min(9,n)),this.media=[],this.commentRefs=[],this._trueStreaming=e.trueStreaming??!1,this.zip=new op((e,t,n)=>{e?this.stream.emit(`error`,e):(this.stream.write(t),n&&this.stream.end())}),this.stream=this._createOutputStream(e),this.promise=Promise.resolve()}_createOutputStream(e){return e.stream?sm(e.stream):new hl}get definedNames(){return this._definedNames}_openStream(e){let t=new hl({bufSize:this._trueStreaming?4096:65536,batch:!this._trueStreaming}),n=new ap(e,{level:this.compressionLevel});this.zip.add(n);let r=e=>n.push(e);return t.on(`data`,r),t.once(`finish`,()=>{t.removeListener(`data`,r),n.push(Fm,!0),t.emit(`zipped`)}),t}_addFile(e,t,n){let r=new ap(t,{level:this.compressionLevel});this.zip.add(r);let i;i=n?st(typeof e==`string`?e:Im.decode(e)):typeof e==`string`?Hn(e):e,r.push(i,!0)}_commitWorksheets(){let e=this._worksheets.map(e=>e.committed?Promise.resolve():new Promise(t=>{e.stream.once(`zipped`,()=>t()),e.commit()}));return e.length?Promise.all(e).then(()=>{}):Promise.resolve()}async commit(){await this.promise,await this._commitWorksheets(),await this.addMedia(),this.addDrawings(),await Promise.all([this.addThemes(),this.addOfficeRels(),this.addContentTypes(),this.addApp(),this.addCore(),this.addSharedStrings(),this.addStyles(),this.addFeaturePropertyBag(),this.addWorkbookRels()]),await this.addWorkbook(),await this._finalize()}get nextId(){for(let e=1;e<this._worksheets.length;e++)if(!this._worksheets[e])return e;return this._worksheets.length||1}addImage(e){let t=this.media.length,n={...e,type:`image`,name:`image${t}.${e.extension}`};return this.media.push(n),t}getImage(e){return this.media[e]}addWorksheet(e,t){let n=t||{},r=n.useSharedStrings===void 0?this.useSharedStrings:n.useSharedStrings;n.tabColor&&(console.trace(`tabColor option has moved to { properties: tabColor: {...} }`),n.properties={tabColor:n.tabColor,...n.properties});let i=this.nextId;e??=`sheet${i}`;let a=new this.WorksheetWriterClass({id:i,name:e,workbook:this,useSharedStrings:r,properties:n.properties,state:n.state,pageSetup:n.pageSetup,views:n.views,autoFilter:n.autoFilter,headerFooter:n.headerFooter});return this._worksheets[i]=a,a}getWorksheet(e){if(e===void 0)return this._worksheets.find(()=>!0);if(typeof e==`number`)return this._worksheets[e];if(typeof e==`string`){let t=e.toLowerCase();return this._worksheets.find(e=>e?.name?.toLowerCase()===t)}}addStyles(){return new Promise(e=>{this._addFile(this.styles.xml,I.xlStyles),e()})}addThemes(){return new Promise(e=>{this._addFile(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
321
- <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> </a:lnStyleLst> <a:effectStyleLst> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="38000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> <a:scene3d> <a:camera prst="orthographicFront"> <a:rot lat="0" lon="0" rev="0"/> </a:camera> <a:lightRig rig="threePt" dir="t"> <a:rot lat="0" lon="0" rev="1200000"/> </a:lightRig> </a:scene3d> <a:sp3d> <a:bevelT w="63500" h="25400"/> </a:sp3d> </a:effectStyle> </a:effectStyleLst> <a:bgFillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="40000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="40000"> <a:schemeClr val="phClr"> <a:tint val="45000"/> <a:shade val="99000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="20000"/> <a:satMod val="255000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/> </a:path> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="80000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="30000"/> <a:satMod val="200000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="50000" r="50000" b="50000"/> </a:path> </a:gradFill> </a:bgFillStyleLst> </a:fmtScheme> </a:themeElements> <a:objectDefaults> <a:spDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="1"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="3"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="2"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="lt1"/> </a:fontRef> </a:style> </a:spDef> <a:lnDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="2"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="0"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="1"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="tx1"/> </a:fontRef> </a:style> </a:lnDef> </a:objectDefaults> <a:extraClrSchemeLst/> </a:theme>`,I.xlTheme1),e()})}addOfficeRels(){return new Promise(e=>{let t=new ta().toXml([{Id:`rId1`,Type:R.OfficeDocument,Target:I.xlWorkbook},{Id:`rId2`,Type:R.CoreProperties,Target:I.docPropsCore},{Id:`rId3`,Type:R.ExtenderProperties,Target:I.docPropsApp}]);this._addFile(t,I.rootRels),e()})}addContentTypes(){return new Promise(e=>{let t=this._worksheets.filter(Boolean);t.forEach(e=>{e.fileIndex=e.id});let n=t.filter(e=>e.drawing).map(e=>e.drawing),r={worksheets:t,sharedStrings:this.sharedStrings,commentRefs:this.commentRefs,media:this.media,drawings:n,hasCheckboxes:this.styles.hasCheckboxes},i=new po;this._addFile(i.toXml(r),I.contentTypes),e()})}addMedia(){return Promise.all(this.media.map(async e=>{if(e.type===`image`){let t=Fa(e.name);if(e.buffer){this._addFile(e.buffer,t);return}if(e.base64){let n=e.base64.substring(e.base64.indexOf(`,`)+1);this._addFile(n,t,!0);return}if(e.filename)throw new v(`Loading images from filename`,`not supported in browser. Use buffer or base64.`)}throw new C(`Unsupported media`)}))}addDrawings(){let e=new _c,t=new ta;for(let n of this._worksheets){if(!n?.drawing)continue;let{drawing:r}=n,i=Ys(r.anchors),a={...r,anchors:i};e.prepare(a);let o=e.toXml(a);this._addFile(o,Ua(r.name));let s=t.toXml(r.rels);this._addFile(s,Wa(r.name))}}addApp(){return new Promise(e=>{let t=new go;this._addFile(t.toXml({worksheets:this._worksheets.filter(Boolean)}),I.docPropsApp),e()})}addCore(){return new Promise(e=>{let t=new Ji;this._addFile(t.toXml(this),I.docPropsCore),e()})}addSharedStrings(){return this.sharedStrings.count?new Promise(e=>{let t=new $i;this._addFile(t.toXml(this.sharedStrings),I.xlSharedStrings),e()}):Promise.resolve()}addFeaturePropertyBag(){if(this.styles.hasCheckboxes){let e=new $s;this._addFile(e.toXml({}),I.xlFeaturePropertyBag)}return Promise.resolve()}addWorkbookRels(){let e=1,t=[{Id:`rId${e++}`,Type:R.Styles,Target:Qa.workbookStyles},{Id:`rId${e++}`,Type:R.Theme,Target:Qa.workbookTheme1}];return this.sharedStrings.count&&t.push({Id:`rId${e++}`,Type:R.SharedStrings,Target:Qa.workbookSharedStrings}),this.styles.hasCheckboxes&&t.push({Id:`rId${e++}`,Type:R.FeaturePropertyBag,Target:Qa.workbookFeaturePropertyBag}),this._worksheets.forEach(n=>{n&&(n.rId=`rId${e++}`,t.push({Id:n.rId,Type:R.Worksheet,Target:Ra(n.id)}))}),new Promise(e=>{let n=new ta;this._addFile(n.toXml(t),I.xlWorkbookRels),e()})}addWorkbook(){let e={worksheets:this._worksheets.filter(Boolean),definedNames:this._definedNames.model,views:this.views,properties:{},calcProperties:{}};return new Promise(t=>{let n=new Ao;n.prepare(e),this._addFile(n.toXml(e),I.xlWorkbook),t()})}_finalize(){return new Promise((e,t)=>{let n=e=>{this.stream.removeListener(`finish`,r),t(e)},r=()=>{this.stream.removeListener(`error`,n),e(this)};this.stream.once(`error`,n),this.stream.once(`finish`,r),this.zip.end()})}},Rm=class extends Lm{constructor(e={}){super(e,Pm)}},zm=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))}};let Bm=[[`version`,4],[`pubKeyLength`,4],[`signatureLength`,4]],Vm=[[`versionsNeededToExtract`,2],[`flags`,2],[`compressionMethod`,2],[`lastModifiedTime`,2],[`lastModifiedDate`,2],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4],[`fileNameLength`,2],[`extraFieldLength`,2]],Hm=[[`dataDescriptorSignature`,4],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4]],Um=[[`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]],Wm=[[`diskNumber`,2],[`diskStart`,2],[`numberOfRecordsOnDisk`,2],[`numberOfRecords`,2],[`sizeOfCentralDirectory`,4],[`offsetToStartOfCentralDirectory`,4],[`commentLength`,2]],Gm=Yu(rf);function Km(e){return((e||0)&sf)!==0}function qm(e){if(e.length===0)return!1;let t=e.charCodeAt(e.length-1);return t===47||t===92}function Jm(e,t){return t===0&&qm(e)?`Directory`:`File`}function Ym(e,t,n){return{path:e,pathBuffer:t,flags:{isUnicode:Km(n)}}}function Xm(e,t){let n=e.lastModifiedDate||0,r=e.lastModifiedTime||0,i=Xd(n,r),a=t.mtimeUnixSeconds;return a===void 0?i:Zd(n,r,a)}let Zm=Nf;function Qm(e){return((e||0)&8)!=0}function $m(e,t){return!Qm(e)||(t||0)>0}async function eh(e){let t=await e(12),n=t.length>=12?ch(t):$u(t,Bm),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 th(e){let t=await e(26),n=t.length>=26?lh(t):$u(t,Vm);return{vars:n,fileNameBuffer:await e(n.fileNameLength||0),extraFieldData:await e(n.extraFieldLength||0)}}async function nh(e){let t=await e(16);return t.length>=16?uh(t):$u(t,Hm)}async function rh(e){let t=$u(await e(42),Um);await e(t.fileNameLength||0),await e(t.extraFieldLength||0),await e(t.fileCommentLength||0)}async function ih(e){await e($u(await e(18),Wm).commentLength||0)}function ah(e){switch(e){case ef:case tf:case nf:case af:case of:return!0;default:return!1}}function oh(e,t){return(e[t]|0|(e[t+1]|0)<<8|(e[t+2]|0)<<16|(e[t+3]|0)<<24)>>>0}function sh(e,t){return(e[t]|(e[t+1]|0)<<8)>>>0}function ch(e){return{version:oh(e,0),pubKeyLength:oh(e,4),signatureLength:oh(e,8)}}function lh(e){return{versionsNeededToExtract:sh(e,0),flags:sh(e,2),compressionMethod:sh(e,4),lastModifiedTime:sh(e,6),lastModifiedDate:sh(e,8),crc32:oh(e,10),compressedSize:oh(e,14),uncompressedSize:oh(e,18),fileNameLength:sh(e,22),extraFieldLength:sh(e,24)}}function uh(e){return{dataDescriptorSignature:oh(e,0),crc32:oh(e,4),compressedSize:oh(e,8),uncompressedSize:oh(e,12)}}let dh=Yu(nf);async function fh(e,t,n,r,i){for(;;){let a=await t.pull(4);if(a.length===0){n.emitClose();return}let o=Xu(a,0);if(o===875721283){r.crxHeader=await eh(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 rh(async e=>t.pull(e));continue}if(o===101010256){await ih(async e=>t.pull(e)),t.setDone(),n.emitClose();return}if(r.reachedCD){await t.pullUntil(dh,!0),await ih(async e=>t.pull(e)),t.setDone(),n.emitClose();return}n.emitError(Error(`invalid signature: 0x`+o.toString(16))),n.emitClose();return}}let ph=256*1024;function mh(e){let t=e.pipe(new dm({transform(e,t,n){n()}}));return t.promise=()=>new Promise((e,n)=>{t.on(`finish`,e),t.on(`error`,n)}),t}function hh(e){return new Promise((t,n)=>{let r=[],i=new dm({transform(e,t,n){r.push(e),n()}});i.on(`finish`,()=>{t(r.length===1?r[0]:k(r))}),i.on(`error`,n),e.on(`error`,n).pipe(i)})}function gh(e){let{source:t,dataDescriptorSignature:n}=e,r=e.keepTailBytes??20,i=e.errorMessage??`FILE_ENDED: Data descriptor not found`,a=new fm({highWaterMark:ph}),o=!1,s=!1,c=0,l=new zm(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;){for(;;){let n=l.find(t);if(n===-1)break;let r=n+16;if(r+4<=e){let e=t.peekUint32LE(r),i=t.peekUint32LE(n+8),u=c+n>>>0;if(e!==null&&i!==null&&ah(e)&&i===u){if(n>0)if(t.peekChunks&&t.discard){let e=t.peekChunks(n),r=0;for(let t of e){let e=a.write(t);if(r+=t.length,!e){s=!0,a.once(`drain`,f);break}}if(r>0&&(t.discard(r),c+=r,l.onConsume(r)),s)return}else{let e=a.write(t.read(n));if(c+=n,l.onConsume(n),!e){s=!0,a.once(`drain`,f);return}}o=!0,t.maybeReleaseWriteCallback?.(),d(),a.end();return}l.searchFrom=n+1;continue}l.searchFrom=n;break}l.onNoMatch(e);let n=Math.max(0,e-r);if(n>0){if(t.peekChunks&&t.discard){let i=t.peekChunks(n),o=0;for(let e of i){let t=a.write(e);if(o+=e.length,!t){s=!0,a.once(`drain`,f);break}}o>0&&(t.discard(o),c+=o,e-=o,l.onConsume(o)),e<=r&&t.maybeReleaseWriteCallback?.();return}let i=a.write(t.read(n));c+=n,e-=n,l.onConsume(n),e<=r&&t.maybeReleaseWriteCallback?.(),i||(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 _h(e,t,n,r,i,a){let o=e.thresholdBytes??5242880;await fh(e,t,n,i,async(s,c,l,u)=>{await yh(e,t,n,r,i,o,a)})}async function vh(e,t,n,r){let i=r,a=null,o=e=>{a=e};t.once(`error`,o),n.once(`error`,o);let s=!1,c=t,l=null,u=()=>{try{c?.removeListener?.(`drain`,f)}catch{}try{n.removeListener(`__autodrain`,p)}catch{}try{n.removeListener(`close`,m)}catch{}},d=()=>{let e=l;e&&(l=null,u(),e())},f=()=>{d()},p=()=>{d()},m=()=>{d()},h=async()=>{await new Promise(e=>{l=e,typeof c?.once==`function`&&c.once(`drain`,f),n.once(`__autodrain`,p),n.once(`close`,m),(n.__autodraining||n.destroyed)&&d()})},g=async()=>{if(!s){s=!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 a;!s&&(n.__autodraining||n.destroyed)&&await g();let r=Math.min(262144,i),o=await e.pull(r);if(o.length!==r)throw Error(`FILE_ENDED`);i-=o.length,s||t.write(o)||await h()}s||t.end(),await Cm(n,{readable:!1})}finally{t.removeListener(`error`,o),n.removeListener(`error`,o)}}async function yh(e,t,n,r,i,a,o){let{vars:s,fileNameBuffer:c,extraFieldData:l}=await th(async e=>t.pull(e)),u=s;i.crxHeader&&(u.crxHeader=i.crxHeader);let d={uncompressedSize:u.uncompressedSize??0,compressedSize:u.compressedSize??0},f=Zm(l,d);u.uncompressedSize=d.uncompressedSize,u.compressedSize=d.compressedSize;let p=e.encoding?Hu(e.encoding):void 0,m=Ku(c,u.flags,f,p),h=new fm({highWaterMark:ph}),g=!1;h.autodrain=function(){return g=!0,h.__autodraining=!0,h.emit(`__autodrain`),mh(h)},h.buffer=function(){return hh(h)},h.path=m,h.props=Ym(m,c,u.flags),h.type=Jm(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=Xm({flags:u.flags,uncompressedSize:u.uncompressedSize??0,lastModifiedDate:u.lastModifiedDate,lastModifiedTime:u.lastModifiedTime},f),h.vars=u,h.extraFields=f,h.__autodraining=g;let _=$m(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=!Qm(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 Cm(h,{readable:!1});return}let ee=y?r():new fm({highWaterMark:ph});if(_){if(await vh(t,ee,h,u.compressedSize??0),Qm(u.flags)){let e=await nh(async e=>t.pull(e));h.size||=e.uncompressedSize??0}return}await Sm(t.streamUntilDataDescriptor(),ee,h),h.size=(await nh(async e=>t.pull(e))).uncompressedSize??0}var bh=class extends um{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 xh=null;function Sh(e){if(typeof e==`string`&&e.length>0)return e;if(xh)return xh;let t=new Blob([`
321
+ <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> </a:lnStyleLst> <a:effectStyleLst> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="38000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> <a:scene3d> <a:camera prst="orthographicFront"> <a:rot lat="0" lon="0" rev="0"/> </a:camera> <a:lightRig rig="threePt" dir="t"> <a:rot lat="0" lon="0" rev="1200000"/> </a:lightRig> </a:scene3d> <a:sp3d> <a:bevelT w="63500" h="25400"/> </a:sp3d> </a:effectStyle> </a:effectStyleLst> <a:bgFillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="40000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="40000"> <a:schemeClr val="phClr"> <a:tint val="45000"/> <a:shade val="99000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="20000"/> <a:satMod val="255000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/> </a:path> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="80000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="30000"/> <a:satMod val="200000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="50000" r="50000" b="50000"/> </a:path> </a:gradFill> </a:bgFillStyleLst> </a:fmtScheme> </a:themeElements> <a:objectDefaults> <a:spDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="1"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="3"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="2"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="lt1"/> </a:fontRef> </a:style> </a:spDef> <a:lnDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="2"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="0"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="1"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="tx1"/> </a:fontRef> </a:style> </a:lnDef> </a:objectDefaults> <a:extraClrSchemeLst/> </a:theme>`,I.xlTheme1),e()})}addOfficeRels(){return new Promise(e=>{let t=new ta().toXml([{Id:`rId1`,Type:R.OfficeDocument,Target:I.xlWorkbook},{Id:`rId2`,Type:R.CoreProperties,Target:I.docPropsCore},{Id:`rId3`,Type:R.ExtenderProperties,Target:I.docPropsApp}]);this._addFile(t,I.rootRels),e()})}addContentTypes(){return new Promise(e=>{let t=this._worksheets.filter(Boolean);t.forEach(e=>{e.fileIndex=e.id});let n=t.filter(e=>e.drawing).map(e=>e.drawing),r={worksheets:t,sharedStrings:this.sharedStrings,commentRefs:this.commentRefs,media:this.media,drawings:n,hasCheckboxes:this.styles.hasCheckboxes},i=new po;this._addFile(i.toXml(r),I.contentTypes),e()})}addMedia(){return Promise.all(this.media.map(async e=>{if(e.type===`image`){let t=Fa(e.name);if(e.buffer){this._addFile(e.buffer,t);return}if(e.base64){let n=e.base64.substring(e.base64.indexOf(`,`)+1);this._addFile(n,t,!0);return}if(e.filename)throw new v(`Loading images from filename`,`not supported in browser. Use buffer or base64.`)}throw new C(`Unsupported media`)}))}addDrawings(){let e=new _c,t=new ta;for(let n of this._worksheets){if(!n?.drawing)continue;let{drawing:r}=n,i=Ys(r.anchors),a={...r,anchors:i};e.prepare(a);let o=e.toXml(a);this._addFile(o,Ua(r.name));let s=t.toXml(r.rels);this._addFile(s,Wa(r.name))}}addApp(){return new Promise(e=>{let t=new go;this._addFile(t.toXml({worksheets:this._worksheets.filter(Boolean)}),I.docPropsApp),e()})}addCore(){return new Promise(e=>{let t=new Ji;this._addFile(t.toXml(this),I.docPropsCore),e()})}addSharedStrings(){return this.sharedStrings.count?new Promise(e=>{let t=new $i;this._addFile(t.toXml(this.sharedStrings),I.xlSharedStrings),e()}):Promise.resolve()}addFeaturePropertyBag(){if(this.styles.hasCheckboxes){let e=new $s;this._addFile(e.toXml({}),I.xlFeaturePropertyBag)}return Promise.resolve()}addWorkbookRels(){let e=1,t=[{Id:`rId${e++}`,Type:R.Styles,Target:Qa.workbookStyles},{Id:`rId${e++}`,Type:R.Theme,Target:Qa.workbookTheme1}];return this.sharedStrings.count&&t.push({Id:`rId${e++}`,Type:R.SharedStrings,Target:Qa.workbookSharedStrings}),this.styles.hasCheckboxes&&t.push({Id:`rId${e++}`,Type:R.FeaturePropertyBag,Target:Qa.workbookFeaturePropertyBag}),this._worksheets.forEach(n=>{n&&(n.rId=`rId${e++}`,t.push({Id:n.rId,Type:R.Worksheet,Target:Ra(n.id)}))}),new Promise(e=>{let n=new ta;this._addFile(n.toXml(t),I.xlWorkbookRels),e()})}addWorkbook(){let e={worksheets:this._worksheets.filter(Boolean),definedNames:this._definedNames.model,views:this.views,properties:{},calcProperties:{}};return new Promise(t=>{let n=new Ao;n.prepare(e),this._addFile(n.toXml(e),I.xlWorkbook),t()})}_finalize(){return new Promise((e,t)=>{let n=e=>{this.stream.removeListener(`finish`,r),t(e)},r=()=>{this.stream.removeListener(`error`,n),e(this)};this.stream.once(`error`,n),this.stream.once(`finish`,r),this.zip.end()})}},Rm=class extends Lm{constructor(e={}){super(e,Pm)}},zm=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))}};let Bm=[[`version`,4],[`pubKeyLength`,4],[`signatureLength`,4]],Vm=[[`versionsNeededToExtract`,2],[`flags`,2],[`compressionMethod`,2],[`lastModifiedTime`,2],[`lastModifiedDate`,2],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4],[`fileNameLength`,2],[`extraFieldLength`,2]],Hm=[[`dataDescriptorSignature`,4],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4]],Um=[[`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]],Wm=[[`diskNumber`,2],[`diskStart`,2],[`numberOfRecordsOnDisk`,2],[`numberOfRecords`,2],[`sizeOfCentralDirectory`,4],[`offsetToStartOfCentralDirectory`,4],[`commentLength`,2]],Gm=Yu(rf);function Km(e){return((e||0)&sf)!==0}function qm(e){if(e.length===0)return!1;let t=e.charCodeAt(e.length-1);return t===47||t===92}function Jm(e,t){return t===0&&qm(e)?`Directory`:`File`}function Ym(e,t,n){return{path:e,pathBuffer:t,flags:{isUnicode:Km(n)}}}function Xm(e,t){let n=e.lastModifiedDate||0,r=e.lastModifiedTime||0,i=Xd(n,r),a=t.mtimeUnixSeconds;return a===void 0?i:Zd(n,r,a)}let Zm=Nf;function Qm(e){return((e||0)&8)!=0}function $m(e,t){return!Qm(e)||(t||0)>0}async function eh(e){let t=await e(12),n=t.length>=12?ch(t):$u(t,Bm),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 th(e){let t=await e(26),n=t.length>=26?lh(t):$u(t,Vm);return{vars:n,fileNameBuffer:await e(n.fileNameLength||0),extraFieldData:await e(n.extraFieldLength||0)}}async function nh(e){let t=await e(16);return t.length>=16?uh(t):$u(t,Hm)}async function rh(e){let t=$u(await e(42),Um);await e(t.fileNameLength||0),await e(t.extraFieldLength||0),await e(t.fileCommentLength||0)}async function ih(e){await e($u(await e(18),Wm).commentLength||0)}function ah(e){switch(e){case ef:case tf:case nf:case af:case of:return!0;default:return!1}}function oh(e,t){return(e[t]|0|(e[t+1]|0)<<8|(e[t+2]|0)<<16|(e[t+3]|0)<<24)>>>0}function sh(e,t){return(e[t]|(e[t+1]|0)<<8)>>>0}function ch(e){return{version:oh(e,0),pubKeyLength:oh(e,4),signatureLength:oh(e,8)}}function lh(e){return{versionsNeededToExtract:sh(e,0),flags:sh(e,2),compressionMethod:sh(e,4),lastModifiedTime:sh(e,6),lastModifiedDate:sh(e,8),crc32:oh(e,10),compressedSize:oh(e,14),uncompressedSize:oh(e,18),fileNameLength:sh(e,22),extraFieldLength:sh(e,24)}}function uh(e){return{dataDescriptorSignature:oh(e,0),crc32:oh(e,4),compressedSize:oh(e,8),uncompressedSize:oh(e,12)}}let dh=Yu(nf);async function fh(e,t,n,r,i){for(;;){let a=await t.pull(4);if(a.length===0){n.emitClose();return}let o=Xu(a,0);if(o===875721283){r.crxHeader=await eh(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 rh(async e=>t.pull(e));continue}if(o===101010256){await ih(async e=>t.pull(e)),t.setDone(),n.emitClose();return}if(r.reachedCD){await t.pullUntil(dh,!0),await ih(async e=>t.pull(e)),t.setDone(),n.emitClose();return}n.emitError(Error(`invalid signature: 0x`+o.toString(16))),n.emitClose();return}}function ph(e){return e instanceof Error?e.code===`ERR_STREAM_PREMATURE_CLOSE`||e.message===`Premature close`:!1}async function mh(e){try{await Cm(e,{readable:!1})}catch(e){if(!ph(e))throw e}}let hh=256*1024;function gh(e){let t=e.pipe(new dm({transform(e,t,n){n()}}));return t.promise=()=>new Promise((e,n)=>{t.on(`finish`,e),t.on(`error`,n)}),t}function _h(e){return new Promise((t,n)=>{let r=[],i=new dm({transform(e,t,n){r.push(e),n()}});i.on(`finish`,()=>{t(r.length===1?r[0]:k(r))}),i.on(`error`,n),e.on(`error`,n).pipe(i)})}function vh(e){let{source:t,dataDescriptorSignature:n}=e,r=e.keepTailBytes??20,i=e.errorMessage??`FILE_ENDED: Data descriptor not found`,a=new fm({highWaterMark:hh}),o=!1,s=!1,c=0,l=new zm(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&&ah(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 yh(e,t,n,r,i,a){let o=e.thresholdBytes??5242880;await fh(e,t,n,i,async(s,c,l,u)=>{await xh(e,t,n,r,i,o,a)})}async function bh(e,t,n,r){let i=r,a=null,o=e=>{a=e};t.once(`error`,o),n.once(`error`,o);let s=!1,c=t,l=null,u=()=>{try{c?.removeListener?.(`drain`,f)}catch{}try{n.removeListener(`__autodrain`,p)}catch{}try{n.removeListener(`close`,m)}catch{}},d=()=>{let e=l;e&&(l=null,u(),e())},f=()=>{d()},p=()=>{d()},m=()=>{d()},h=async()=>{await new Promise(e=>{l=e,typeof c?.once==`function`&&c.once(`drain`,f),n.once(`__autodrain`,p),n.once(`close`,m),(n.__autodraining||n.destroyed)&&d()})},g=async()=>{if(!s){s=!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 a;!s&&(n.__autodraining||n.destroyed)&&await g();let r=Math.min(262144,i),o=await e.pull(r);if(o.length!==r)throw Error(`FILE_ENDED`);i-=o.length,s||t.write(o)||await h()}s||t.end(),await mh(n)}finally{t.removeListener(`error`,o),n.removeListener(`error`,o)}}async function xh(e,t,n,r,i,a,o){let{vars:s,fileNameBuffer:c,extraFieldData:l}=await th(async e=>t.pull(e)),u=s;i.crxHeader&&(u.crxHeader=i.crxHeader);let d={uncompressedSize:u.uncompressedSize??0,compressedSize:u.compressedSize??0},f=Zm(l,d);u.uncompressedSize=d.uncompressedSize,u.compressedSize=d.compressedSize;let p=e.encoding?Hu(e.encoding):void 0,m=Ku(c,u.flags,f,p),h=new fm({highWaterMark:hh}),g=!1;h.autodrain=function(){return g=!0,h.__autodraining=!0,h.emit(`__autodrain`),gh(h)},h.buffer=function(){return _h(h)},h.path=m,h.props=Ym(m,c,u.flags),h.type=Jm(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=Xm({flags:u.flags,uncompressedSize:u.uncompressedSize??0,lastModifiedDate:u.lastModifiedDate,lastModifiedTime:u.lastModifiedTime},f),h.vars=u,h.extraFields=f,h.__autodraining=g;let _=$m(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=!Qm(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 mh(h);return}let ee=y?r():new fm({highWaterMark:hh});if(_){if(await bh(t,ee,h,u.compressedSize??0),Qm(u.flags)){let e=await nh(async e=>t.pull(e));h.size||=e.uncompressedSize??0}return}try{await Sm(t.streamUntilDataDescriptor(),ee,h)}catch(e){if(!ph(e))throw e;try{h.size=(await nh(async e=>t.pull(e))).uncompressedSize??0}catch{}return}h.size=(await nh(async e=>t.pull(e))).uncompressedSize??0}var Sh=class extends um{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 Ch=null;function wh(e){if(typeof e==`string`&&e.length>0)return e;if(Ch)return Ch;let t=new Blob([`
322
322
  let ds;
323
323
  let writer;
324
324
  let reader;
@@ -390,59 +390,59 @@ onmessage = async (ev) => {
390
390
  postMessage({ t: 'error', message: m, id: msg && msg.id });
391
391
  }
392
392
  };
393
- `],{type:`text/javascript`});return xh=URL.createObjectURL(t),xh}var Ch=class extends um{constructor(e){super({write:(e,t,n)=>{this._doWrite(e,n)},final:e=>{this._doClose(e)}}),this._nextId=1,this._pendingAcks=new Map,this._workerClosed=!1,this._junkError=!1,this._terminated=!1;let t=Sh(e);this.worker=new Worker(t),this.worker.onmessage=e=>{let t=e.data;if(!(!t||typeof t.t!=`string`)){if(t.t===`data`){let e=t.chunk;this.push(e);return}if(t.t===`end`){this.push(null),this._terminateWorker();return}if(t.t===`aborted`){this._terminateWorker();return}if(t.t===`ack`){let e=t.id,n=this._pendingAcks.get(e);n&&(this._pendingAcks.delete(e),n());return}if(t.t===`error`){let e=typeof t.message==`string`?t.message:`Worker inflate error`;if(e.includes(`Junk`)||e.includes(`junk`)){this._junkError=!0,this.push(null),this._terminateWorker(),this._settlePendingAcks();return}let n=Error(e);this._settlePendingAcks(n),this.emit(`error`,n),this._terminateWorker();return}}},this.worker.onerror=e=>{let t=Error(e.message??`Worker error`);this._settlePendingAcks(t),this.emit(`error`,t),this._terminateWorker()}}_settlePendingAcks(e){if(this._pendingAcks.size!==0){for(let t of this._pendingAcks.values())t(e);this._pendingAcks.clear()}}_terminateWorker(){if(!this._terminated){this._terminated=!0;try{this.worker.terminate()}catch{}}}_doWrite(e,t){if(this._workerClosed||this._junkError){t();return}let n=this._nextId++;this._pendingAcks.set(n,t);let r=e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e:e.slice();this.worker.postMessage({t:`write`,id:n,chunk:r},[r.buffer])}_doClose(e){if(this._workerClosed){e();return}this._workerClosed=!0,this.worker.postMessage({t:`close`}),e()}destroy(e){if(!this._workerClosed){this._workerClosed=!0;try{this.worker.postMessage({t:`abort`})}catch{}}return this._terminateWorker(),super.destroy(e??void 0)}},wh=class extends um{constructor(){super({write:(e,t,n)=>{if(this._finished){n(Error(`write after end`));return}this.chunks.push(e),n()},final:e=>{this._decompress(e)}}),this.chunks=[],this._finished=!1}_decompress(e){try{let t=Nl(k(this.chunks));this.push(t),this.push(null),this._finished=!0,e()}catch(t){e(a(t))}}destroy(e){return this._finished=!0,this.chunks=[],super.destroy(e??void 0)}};function Th(){return $l()?new bh:new wh}let Eh=Gm;function Dh(e){return class extends um{constructor(t={}){super({objectMode:!0,write:(e,t,n)=>{this._handleWrite(e,n)},final:e=>{this.finished=!0,this._maybeReleaseWriteCallback(),this._wakeUp(),this.emit(`data-available`),this.emit(`chunk`,!1),this._parsingDone.then(()=>e()).catch(e)}}),this._buffer=new ql,this.finished=!1,this._driverState={},this._parsingDone=Promise.resolve(),this._opts=t;let n=Math.max(64*1024,t.inputHighWaterMarkBytes??2*1024*1024),r=Math.max(32*1024,t.inputLowWaterMarkBytes??Math.floor(n/4));this._inputHighWaterMarkBytes=n,this._inputLowWaterMarkBytes=Math.min(r,n);let i={pull:e=>this.pull(e),pullUntil:(e,t)=>this.pullUntil(e,t),stream:e=>this.stream(e),streamUntilDataDescriptor:()=>this._streamUntilDataDescriptor(),setDone:()=>{this.push(null)}},a={emitEntry:e=>{this.emit(`entry`,e)},pushEntry:e=>{this.push(e)},pushEntryIfPiped:e=>{},emitCrxHeader:e=>{this.crxHeader=e,this.emit(`crx-header`,e)},emitError:e=>{if(this.__emittedError=e,this._writeCb){let t=this._writeCb;this._writeCb=void 0,t(e)}this.emit(`error`,e)},emitClose:()=>{this.emit(`close`)}};queueMicrotask(()=>{this._parsingDone=_h(this._opts,i,a,()=>{if(this._opts.useWorkerInflate&&typeof Worker<`u`&&$l())try{return new Ch(this._opts.workerInflateUrl)}catch{return e()}return e()},this._driverState),this._parsingDone.catch(e=>{(!this.__emittedError||this.__emittedError!==e)&&(this.__emittedError=e,this.emit(`error`,e)),this.emit(`close`)})})}_handleWrite(e,t){this._buffer.append(e),this._buffer.length>=this._inputHighWaterMarkBytes?this._writeCb=t:t(),this._wakeUp(),this.emit(`data-available`),this.emit(`chunk`)}get buffer(){return this._buffer.view()}set buffer(e){this._buffer.reset(e)}_wakeUp(){if(this._pendingResolve){let e=this._pendingResolve;this._pendingResolve=void 0,this._pendingDataPromise=void 0,e()}}_maybeReleaseWriteCallback(){if(!this._writeCb||this._buffer.length>this._inputLowWaterMarkBytes)return;let e=this._writeCb;this._writeCb=void 0,e()}_waitForData(){return this._pendingDataPromise||=new Promise(e=>{this._pendingResolve=e}),this._pendingDataPromise}async _pullInternal(e){if(e===0)return H;let t=e,n=null,r=null,i=e=>{if(e.length!==0){if(!n){n=e;return}if(!r){r=[n,e];return}r.push(e)}};for(;t>0;){for(;this._buffer.length===0;){if(this.finished)throw Error(`FILE_ENDED`);await this._waitForData()}let e=Math.min(t,this._buffer.length);i(this._buffer.read(e)),t-=e,this._buffer.length===0&&this._maybeReleaseWriteCallback()}return this._maybeReleaseWriteCallback(),n?r?k(r):n:H}async _pullUntilInternal(e,t=!1){let n=null,r=null,i=new zm(e),a=e.length,o=e=>{if(e.length!==0){if(!n){n=e;return}if(!r){r=[n,e];return}r.push(e)}};for(;;){let e=this._buffer.length,s=i.find(this._buffer);if(s!==-1){this.match=s;let e=s+(t?a:0);return e>0&&(o(this._buffer.read(e)),this._maybeReleaseWriteCallback()),n?r?k(r):n:H}if(i.onNoMatch(e),this.finished)throw Error(`FILE_ENDED`);let c=this._buffer.length-a;c>0&&(o(this._buffer.read(c)),i.onConsume(c),this._maybeReleaseWriteCallback()),await this._waitForData()}}_streamFixedLength(e){let t=new fm({highWaterMark:ph}),n=e,r=!1,i=!1,a=()=>{i=!1,o()},o=()=>{if(!r&&!i){for(;n>0&&this._buffer.length>0;){let e=Math.min(n,this._buffer.length),r=this._buffer.read(e);n-=e;let o=t.write(r);if(this._maybeReleaseWriteCallback(),!o){i=!0,t.once(`drain`,a);return}}n===0?(r=!0,this.removeListener(`data-available`,o),t.end()):this.finished&&(r=!0,this.removeListener(`data-available`,o),t.destroy(Error(`FILE_ENDED`)))}};return this.on(`data-available`,o),queueMicrotask(()=>o()),t}_streamUntilPattern(e,t=!1){let n=new fm({highWaterMark:ph}),r=!1,i=e.length,a=new zm(e),o=!1,s=()=>{o=!1,c()},c=()=>{if(!(r||o))for(;!(this._buffer.length<=0);){let e=this._buffer.length,l=a.find(this._buffer);if(l!==-1){this.match=l;let e=t?l+i:l;if(e>0){let t=n.write(this._buffer.read(e));if(a.onConsume(e),this._maybeReleaseWriteCallback(),!t){o=!0,n.once(`drain`,s);return}}r=!0,this.removeListener(`data-available`,c),n.end();return}if(a.onNoMatch(e),this.finished){r=!0,this.removeListener(`data-available`,c),n.destroy(Error(`FILE_ENDED`));return}let u=e-i;if(u<=0){this._buffer.length<=i&&this._maybeReleaseWriteCallback();break}let d=n.write(this._buffer.read(u));if(a.onConsume(u),this._maybeReleaseWriteCallback(),!d){o=!0,n.once(`drain`,s);return}}};return this.on(`data-available`,c),queueMicrotask(()=>c()),n}stream(e,t){return typeof e==`number`?this._streamFixedLength(e):this._streamUntilPattern(e,t??!1)}pull(e,t){if(e===0)return Promise.resolve(H);if(typeof e==`number`){if(this.finished&&this._buffer.length<e)return Promise.reject(Error(`FILE_ENDED`));if(this._buffer.length>=e){let t=this._buffer.read(e);return this._maybeReleaseWriteCallback(),Promise.resolve(t)}return this._pullInternal(e)}return this.finished?Promise.reject(Error(`FILE_ENDED`)):this._pullUntilInternal(e,t??!1)}pullUntil(e,t){return this.pull(e,t)}_streamUntilDataDescriptor(){return gh({source:{getLength:()=>this._buffer.length,read:e=>this._buffer.read(e),peekChunks:e=>this._buffer.peekChunks(e),discard:e=>this._buffer.discard(e),indexOfPattern:(e,t)=>this._buffer.indexOfPattern(e,t),peekUint32LE:e=>this._buffer.peekUint32LE(e),isFinished:()=>this.finished,onDataAvailable:e=>(this.on(`data-available`,e),()=>this.removeListener(`data-available`,e)),maybeReleaseWriteCallback:()=>this._maybeReleaseWriteCallback()},dataDescriptorSignature:Eh})}promise(){return new Promise((e,t)=>{this.on(`finish`,e),this.on(`end`,e),this.on(`error`,t)})}}}let Oh=Dh(Th);var kh=class extends Oh{};function Ah(e){return new kh(e)}async function*jh(e){let t=[],n=null,r=e=>{t.push(e),n&&=(n(),null)};e.on(`data`,r);let i=!1,a=()=>{i=!0,n&&=(n(),null)};e.on(`end`,a);let o=!1,s=e=>{o=e,n&&=(n(),null)};e.on(`error`,s);try{for(;!i||t.length>0;)if(t.length===0?(e.resume(),await new Promise(e=>{n=e})):(e.pause(),yield t.shift()),o)throw o}finally{e.removeListener(`data`,r),e.removeListener(`end`,a),e.removeListener(`error`,s)}}var Mh=class extends V{constructor({workbook:e,id:t,iterator:n,options:r}){super(),this.workbook=e,this.id=t,this.sheetNo=typeof t==`number`?t:parseInt(String(t),10),this.iterator=n,this.options=r||{},this.name=`Sheet${this.id}`,this._columns=[],this._keys=Object.create(null),this._dimensions=new T}destroy(){throw new b(`destroy`,`Invalid operation for a streaming reader`)}get dimensions(){return this._dimensions}get columns(){return this._columns}getColumn(e){if(typeof e==`string`){let t=this._keys[e];if(t)return t;e=w.l2n(e)}if(e>this._columns.length){let t=this._columns.length+1;for(;t<=e;)this._columns.push(new Re(this,t++))}return this._columns[e-1]}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){let t=this._keys;for(let n in t)e(t[n],n)}async read(){try{for await(let e of this.parse())for(let t=0;t<e.length;t++){let n=e[t];this.emit(n.eventType,n.value)}this.emit(`finished`)}catch(e){this.emit(`error`,e)}}async*[Symbol.asyncIterator](){for await(let e of this.parse())for(let t=0;t<e.length;t++){let n=e[t];n.eventType===`row`&&(yield n.value)}}async*parse(){let{iterator:e,options:t}=this,n=!1,r=!1,i=null;switch(t.worksheets){case`emit`:n=!0;break;case`prep`:break;default:break}switch(t.hyperlinks){case`emit`:r=!0;break;case`cache`:this.hyperlinks=i=Object.create(null);break;default:break}if(!n&&!r&&!i)return;let a=r||i!==null,{sharedStrings:o,styles:s,properties:c}=this.workbook,l=!1,u=!1,d=!1,f=null,p=null,m=null,h=null;for await(let t of gi(e)){let e=null;for(let g=0;g<t.length;g++){let _=t[g],v=_.eventType,y=_.value;if(v===`opentag`){let t=y;if(n)switch(t.name){case`cols`:l=!0,f=[];break;case`sheetData`:u=!0;break;case`col`:l&&f.push({min:parseInt(t.attributes.min,10),max:parseInt(t.attributes.max,10),width:parseFloat(t.attributes.width),styleId:parseInt(t.attributes.style??`0`,10)});break;case`row`:if(u){let e=parseInt(t.attributes.r,10);if(p=new Le(this,e),t.attributes.ht&&(p.height=parseFloat(t.attributes.ht)),t.attributes.customHeight===`1`&&(p.customHeight=!0),t.attributes.s!==void 0){let e=parseInt(t.attributes.s,10),n=s.getStyleModel(e);n&&(p.style=n)}}break;case`c`:if(p){let e=t.attributes.s;m={ref:t.attributes.r,s:e===void 0?void 0:parseInt(e,10),t:t.attributes.t}}break;case`f`:m&&(h=m.f={text:``});break;case`v`:m&&(h=m.v={text:``});break;case`is`:case`t`:m&&(h=m.v={text:``});break;case`mergeCell`:break;default:break}if(a)switch(t.name){case`hyperlinks`:d=!0;break;case`hyperlink`:if(d){let n=t.attributes.location,a={ref:t.attributes.ref,rId:t.attributes[`r:id`],target:n?n.startsWith(`#`)?n:`#${n}`:void 0};r?(e||=[]).push({eventType:`hyperlink`,value:a}):i[a.ref]=a}break;default:break}}else if(v===`text`)n&&h&&(h.text+=y);else if(v===`closetag`){let t=y;if(n)switch(t.name){case`cols`:l=!1,this._columns=Re.fromModel(f);break;case`sheetData`:u=!1;break;case`row`:p&&(this._dimensions.expandRow({number:p.number,dimensions:p.dimensions??void 0}),(e||=[]).push({eventType:`row`,value:p})),p=null;break;case`c`:if(p&&m){let e=w.decodeAddress(m.ref),t=p.getCell(e.col);if(m.s!==void 0){let e=s.getStyleModel(m.s);e&&(t.style=e)}if(m.f){let e={formula:m.f.text};m.v&&(m.t===`str`?e.result=vt(m.v.text):e.result=parseFloat(m.v.text)),t.value=e}else if(m.v)switch(m.t){case`s`:{let e=parseInt(m.v.text,10);o?t.value=o[e]:t.value={sharedString:e};break}case`inlineStr`:t.value=ft(vt(m.v.text));break;case`str`:t.value=vt(m.v.text);break;case`e`:t.value={error:m.v.text};break;case`b`:t.value=parseInt(m.v.text,10)!==0;break;default:{let e=typeof t.numFmt==`string`?t.numFmt:t.numFmt?.formatCode;e&&Tt(e)?t.value=lt(parseFloat(m.v.text),c?.model?.date1904):t.value=parseFloat(m.v.text);break}}if(i){let e=i[m.ref];e&&(t.text=t.value,t.value=void 0,t.hyperlink=e)}m=null,h=null}break;default:break}if(a)switch(t.name){case`hyperlinks`:d=!1;break;default:break}}}e&&e.length>0&&(yield e)}}},Nh=class extends V{constructor({workbook:e,id:t,iterator:n,options:r}){super(),this._hyperlinkCount=0,this.workbook=e,this.id=t,this.iterator=n,this.options=r}get count(){return this.hyperlinks?this._hyperlinkCount:0}each(e){let t=this.hyperlinks;if(t)for(let n in t)e(t[n],n)}async read(){let{iterator:e}=this,t=this.options.hyperlinks,n=t===`emit`,r=t===`cache`,i=null;if(r&&(this._hyperlinkCount=0,this.hyperlinks=i=Object.create(null)),!n&&!r){this.emit(`finished`);return}try{for await(let t of gi(e))for(let{eventType:e,value:r}of t){if(e!==`opentag`)continue;let t=r;if(t.name!==`Relationship`)continue;let a=t.attributes;if(a.Type!==R.Hyperlink)continue;let o={type:D.RelationshipType.Hyperlink,rId:a.Id,target:a.Target,targetMode:a.TargetMode};if(n){this.emit(`hyperlink`,o);continue}let s=o.rId;i&&i[s]===void 0&&(this._hyperlinkCount+=1),i[s]=o}this.emit(`finished`)}catch(e){this.emit(`error`,e)}}},Ph=class extends V{getHyperlinkReader(e){return this._hyperlinkReadersBySheetNo?.[String(e)]}getHyperlink(e,t){return this.getHyperlinkReader(e)?.hyperlinks?.[t]}getHyperlinkTarget(e,t){return this.getHyperlink(e,t)?.target}constructor(e,t,n,r){super(),this._totalBufferedBytes=0,this.input=e,this.WorksheetReaderClass=n,this.HyperlinkReaderClass=r,this._maxBufferedBytes=t.maxBufferedWorksheetBytes??256*1024*1024,this.options={worksheets:`emit`,sharedStrings:`cache`,hyperlinks:`ignore`,styles:`ignore`,entries:`ignore`,...t},this.styles=new Ki,this.styles.init()}_getStream(e){if(e instanceof W)return e;if(e&&typeof e==`object`&&typeof e.getReader==`function`){let t=W.fromWeb;if(typeof t==`function`)return t(e);try{return new W({stream:e})}catch{throw new y(`<ReadableStream>`,`read`,`Could not recognise input`)}}let t=e;if(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),t instanceof Uint8Array)return W.from([t]);throw new y(String(e),`read`,`Could not recognise input`)}_cleanupWaitingWorksheets(e){for(let t of e)t&&typeof t.cleanup==`function`&&t.cleanup()}_createWorksheetReader(e){return new this.WorksheetReaderClass({workbook:this,id:e.id,iterator:e.iterator,options:e.options})}_createHyperlinkReader(e){return new this.HyperlinkReaderClass({workbook:this,id:e.id,iterator:e.iterator,options:e.options})}async read(e,t){try{for await(let{eventType:n,value:r}of this.parse(e,t))switch(n){case`shared-strings`:this.emit(n,r);break;case`worksheet`:this.emit(n,r),await r.read();break;case`hyperlinks`:this.emit(n,r);break}this.emit(`end`),this.emit(`finished`)}catch(e){this.emit(`error`,e)}}async*[Symbol.asyncIterator](){for await(let{eventType:e,value:t}of this.parse())e===`worksheet`&&(yield t)}async*parse(e,t){t&&(this.options=t);let n=this.stream=this._getStream(e||this.input),r=[];try{for await(let e of this._parseEntries(n))if(e.eventType===`waiting-worksheet`){let t=await this._storeWaitingWorksheet(e.sheetNo,e.entry);r.push(t)}else yield e;yield*this._processWaitingWorksheets(r)}catch(e){throw this._cleanupWaitingWorksheets(r),e}}_emitEntry(e){this.options.entries===`emit`&&this.emit(`entry`,e)}async _parseRels(e){this.workbookRels=await new ta().parseStream(jh(e)),this._workbookRelIdByTarget=Object.create(null);for(let e of this.workbookRels??[])e?.Target&&e?.Id&&(this._workbookRelIdByTarget[e.Target]=e.Id)}async _parseWorkbook(e){this._emitEntry({type:`workbook`});let t=new Ao;this.model=await t.parseStream(jh(e)),this.properties=t.map?.workbookPr,this._sheetByRelId=Object.create(null);for(let e of this.model?.sheets??[])this._sheetByRelId[e.rId]=e}async*_parseSharedStrings(e){switch(this._emitEntry({type:`shared-strings`}),this.options.sharedStrings){case`cache`:this.sharedStrings=[];break;case`emit`:break;default:return}let t=null,n=[],r=0,i=null,a=!1;for await(let o of gi(jh(e)))for(let{eventType:e,value:s}of o)if(e===`opentag`){let e=s;switch(e.name){case`b`:i||={},i.bold=!0;break;case`charset`:i||={},i.charset=parseInt(e.attributes.charset,10);break;case`color`:i||={},i.color={},e.attributes.rgb&&(i.color.argb=e.attributes.rgb),e.attributes.val&&(i.color.argb=e.attributes.val),e.attributes.theme&&(i.color.theme=e.attributes.theme);break;case`family`:i||={},i.family=parseInt(e.attributes.val,10);break;case`i`:i||={},i.italic=!0;break;case`outline`:i||={},i.outline=!0;break;case`rFont`:i||={},i.name=e.attributes.val;break;case`r`:a=!0;break;case`si`:i=null,n=[],t=null,a=!1;break;case`sz`:i||={},i.size=parseInt(e.attributes.val,10);break;case`strike`:i||={},i.strike=!0;break;case`t`:t=null;break;case`u`:i||={},i.underline=!0;break;case`vertAlign`:i||={},i.vertAlign=e.attributes.val;break}}else if(e===`text`)t=t?t+s:s;else if(e===`closetag`)switch(s.name){case`t`:t!=null&&(t=ft(t));break;case`r`:a&&(n.push({font:i,text:t}),i=null,t=null);break;case`si`:this.options.sharedStrings===`cache`?this.sharedStrings.push(n.length?{richText:n}:t??``):this.options.sharedStrings===`emit`&&(yield{index:r++,text:n.length?{richText:n}:t??``}),n=[],i=null,t=null,a=!1;break}}async _parseStyles(e){this._emitEntry({type:`styles`}),this.options.styles===`cache`&&(this.styles=new Ki,await this.styles.parseStream(jh(e)))}*_parseWorksheet(e,t){this._emitEntry({type:`worksheet`,id:t});let n=parseInt(t,10),r=this._createWorksheetReader({id:n,iterator:e,options:this.options});r.sheetNo=n;let i=this._workbookRelIdByTarget?.[Ra(t)],a=i?this._sheetByRelId?.[i]:void 0;a&&(r.id=a.id,r.name=a.name,r.state=a.state),this.options.worksheets===`emit`&&(yield{eventType:`worksheet`,value:r})}async*_parseHyperlinks(e,t){this._emitEntry({type:`hyperlinks`,id:t});let n=this._createHyperlinkReader({id:parseInt(t,10),iterator:e,options:this.options});if(this.options.hyperlinks===`cache`){this._hyperlinkReadersBySheetNo||=Object.create(null),this._hyperlinkReadersBySheetNo[t]=n;let e=n.read;typeof e==`function`&&await e.call(n);return}this.options.hyperlinks===`emit`&&(yield{eventType:`hyperlinks`,value:n})}async*_parseEntries(e){let t=Ah({forceStream:!0});e.on(`error`,e=>t.emit(`error`,e)),e.pipe(t);for await(let e of jh(t)){let t,n=ga(e.path);switch(n){case I.rootRels:break;case I.xlWorkbookRels:await this._parseRels(e);break;case I.xlWorkbook:await this._parseWorkbook(e);break;case I.xlSharedStrings:for await(let t of this._parseSharedStrings(e))yield{eventType:`shared-strings`,value:t};break;case I.xlStyles:await this._parseStyles(e);break;default:if(t=_a(n)?.toString(),t)if(this.workbookRels&&this.model&&(this.options.sharedStrings!==`cache`||this.sharedStrings)){yield*this._parseWorksheet(jh(e),t);continue}else{yield{eventType:`waiting-worksheet`,sheetNo:t,entry:e};continue}if(t=va(n)?.toString(),t){yield*this._parseHyperlinks(jh(e),t);continue}break}e.autodrain()}}},Fh=class extends Ph{constructor(e,t={}){super(e,t,Mh,Nh)}async _storeWaitingWorksheet(e,t){let n=[],r=new TextEncoder;for await(let e of jh(t)){let t;if(e instanceof Uint8Array)t=e;else if(typeof e==`string`)t=r.encode(e);else continue;if(this._totalBufferedBytes+=t.length,this._totalBufferedBytes>this._maxBufferedBytes)throw Error(`Buffered worksheet data exceeds limit of ${this._maxBufferedBytes} bytes. The XLSX file may be malicious (adversarial ZIP entry ordering) or too large for streaming. Increase maxBufferedWorksheetBytes if this is expected.`);n.push(t)}return{sheetNo:e,data:n}}async*_processWaitingWorksheets(e){for(let t of e){let e=(async function*(){for(let e of t.data)yield e})();yield*this._parseWorksheet(e,t.sheetNo)}}};let J=Array.from({length:60},(e,t)=>t<10?`0${t}`:`${t}`),Y=(e,t)=>(e.charCodeAt(t)-48)*10+e.charCodeAt(t+1)-48|0,Ih=(e,t)=>(e.charCodeAt(t)-48)*1e3+(e.charCodeAt(t+1)-48)*100+(e.charCodeAt(t+2)-48)*10+e.charCodeAt(t+3)-48|0,Lh=[0,31,29,31,30,31,30,31,31,30,31,30,31];function Rh(e,t,n){if(t<1||t>12||n<1||n>Lh[t])return null;let r=new Date(e,t-1,n);return r.getMonth()===t-1?r:null}function zh(e,t,n,r,i,a){return t<1||t>12||n<1||n>Lh[t]||r>23||i>59||a>59?null:new Date(e,t-1,n,r,i,a)}function Bh(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45?null:Rh(Ih(e,0),Y(e,5),Y(e,8))}function Vh(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45||e.charCodeAt(10)!==84||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:zh(Ih(e,0),Y(e,5),Y(e,8),Y(e,11),Y(e,14),Y(e,17))}function Hh(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:zh(Ih(e,0),Y(e,5),Y(e,8),Y(e,11),Y(e,14),Y(e,17))}function Uh(e){if(e.charCodeAt(19)!==90)return null;let t=new Date(e);return isNaN(t.getTime())?null:t}function Wh(e){if(e.charCodeAt(19)!==46||e.charCodeAt(23)!==90)return null;let t=new Date(e);return isNaN(t.getTime())?null:t}function Gh(e){let t=e.charCodeAt(19);if(t!==43&&t!==45)return null;let n=new Date(e);return isNaN(n.getTime())?null:n}function Kh(e){if(e.charCodeAt(19)!==46)return null;let t=e.charCodeAt(23);if(t!==43&&t!==45)return null;let n=new Date(e);return isNaN(n.getTime())?null:n}function qh(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t?null:Rh(Ih(e,6),Y(e,0),Y(e,3))}function Jh(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t?null:Rh(Ih(e,6),Y(e,3),Y(e,0))}function Yh(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:zh(Ih(e,6),Y(e,0),Y(e,3),Y(e,11),Y(e,14),Y(e,17))}function Xh(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:zh(Ih(e,6),Y(e,3),Y(e,0),Y(e,11),Y(e,14),Y(e,17))}let Zh={"YYYY-MM-DD":Bh,"YYYY-MM-DD[T]HH:mm:ss":Vh,"YYYY-MM-DD HH:mm:ss":Hh,"YYYY-MM-DD[T]HH:mm:ssZ":e=>e.length===20?Uh(e):e.length===25?Gh(e):null,"YYYY-MM-DD[T]HH:mm:ss.SSSZ":e=>e.length===24?Wh(e):e.length===29?Kh(e):null,"MM-DD-YYYY":qh,"MM-DD-YYYY HH:mm:ss":Yh,"MM/DD/YYYY HH:mm:ss":Yh,"DD-MM-YYYY":Jh,"DD-MM-YYYY HH:mm:ss":Xh,"DD/MM/YYYY HH:mm:ss":Xh},Qh=[[10,[Bh]],[19,[Vh,Hh]],[20,[Uh]],[24,[Wh]],[25,[Gh]],[29,[Kh]]];var $h=class e{constructor(e){this.parse=e=>{if(!e)return null;let t=e.trim();if(!t)return null;if(this.single)return this.fn0(t);for(let e=0,n=this.fns.length;e<n;e++){let n=this.fns[e](t);if(n)return n}return null},this.fns=e,this.single=e.length===1,this.fn0=e[0]}static create(t){return new e(t.map(e=>Zh[e]).filter(Boolean))}static iso(){let t=[];for(let[,e]of Qh)t.push(...e);return new e(t)}parseAll(e){let t=e.length,n=Array(t),r=this.parse;for(let i=0;i<t;i++)n[i]=r(e[i]);return n}parseValid(e){let t=[],n=this.parse;for(let r=0,i=e.length;r<i;r++){let i=n(e[r]);i&&t.push(i)}return t}};function eg(e){let t=-e.getTimezoneOffset(),n=t>=0?`+`:`-`,r=Math.abs(t)/60|0,i=Math.abs(t)%60;return`${n}${J[r]}:${J[i]}`}var tg=class e{constructor(e){this.format=e=>this.fn(e),this.fn=e}static iso(t=!1){return t?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let n=e.getUTCFullYear(),r=e.getUTCMonth()+1,i=e.getUTCDate(),a=e.getUTCHours(),o=e.getUTCMinutes(),s=e.getUTCSeconds(),c=e.getUTCMilliseconds();return`${n}-${J[r]}-${J[i]}T${J[a]}:${J[o]}:${J[s]}.${c<10?`00`+c:c<100?`0`+c:c}Z`}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let n=e.getFullYear(),r=e.getMonth()+1,i=e.getDate(),a=e.getHours(),o=e.getMinutes(),s=e.getSeconds(),c=e.getMilliseconds();return`${n}-${J[r]}-${J[i]}T${J[a]}:${J[o]}:${J[s]}.${c<10?`00`+c:c<100?`0`+c:c}${eg(e)}`})}static create(t,n){let r=n?.utc??!1;if(t===`YYYY-MM-DD`)return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getUTCFullYear()}-${J[e.getUTCMonth()+1]}-${J[e.getUTCDate()]}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getFullYear()}-${J[e.getMonth()+1]}-${J[e.getDate()]}`:``});if(t===`YYYY-MM-DD HH:mm:ss`)return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getUTCFullYear()}-${J[e.getUTCMonth()+1]}-${J[e.getUTCDate()]} ${J[e.getUTCHours()]}:${J[e.getUTCMinutes()]}:${J[e.getUTCSeconds()]}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getFullYear()}-${J[e.getMonth()+1]}-${J[e.getDate()]} ${J[e.getHours()]}:${J[e.getMinutes()]}:${J[e.getSeconds()]}`:``});if(t===`MM-DD-YYYY`||t===`MM/DD/YYYY`){let n=t.charAt(2);return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${J[e.getUTCMonth()+1]}${n}${J[e.getUTCDate()]}${n}${e.getUTCFullYear()}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${J[e.getMonth()+1]}${n}${J[e.getDate()]}${n}${e.getFullYear()}`:``})}if(t===`DD-MM-YYYY`||t===`DD/MM/YYYY`){let n=t.charAt(2);return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${J[e.getUTCDate()]}${n}${J[e.getUTCMonth()+1]}${n}${e.getUTCFullYear()}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${J[e.getDate()]}${n}${J[e.getMonth()+1]}${n}${e.getFullYear()}`:``})}return e.createGeneric(t,r)}static createGeneric(t,n){let r=[],i=[],a=0;for(;a<t.length;)if(t[a]===`[`){let e=t.indexOf(`]`,a+1);e===-1?(i.push(t[a]),a++):(r.push(t.slice(a+1,e)),i.push(`\x00${r.length-1}\x00`),a=e+1)}else i.push(t[a]),a++;let o=i.join(``),s=o.includes(`YYYY`),c=o.includes(`SSS`),l=o.includes(`MM`),u=o.includes(`DD`),d=o.includes(`HH`),f=o.includes(`mm`),p=o.includes(`ss`),m=o.includes(`Z`);return new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let i=o;if(s&&(i=i.replace(/YYYY/g,String(n?e.getUTCFullYear():e.getFullYear()))),c){let t=n?e.getUTCMilliseconds():e.getMilliseconds();i=i.replace(/SSS/g,t<10?`00${t}`:t<100?`0${t}`:String(t))}return l&&(i=i.replace(/MM/g,J[n?e.getUTCMonth()+1:e.getMonth()+1])),u&&(i=i.replace(/DD/g,J[n?e.getUTCDate():e.getDate()])),d&&(i=i.replace(/HH/g,J[n?e.getUTCHours():e.getHours()])),f&&(i=i.replace(/mm/g,J[n?e.getUTCMinutes():e.getMinutes()])),p&&(i=i.replace(/ss/g,J[n?e.getUTCSeconds():e.getSeconds()])),m&&(i=i.replace(/Z/g,n?`Z`:eg(e))),r.length&&(i=i.replace(/\x00(\d+)\x00/g,(e,t)=>r[+t])),i})}formatAll(e){let t=e.length,n=Array(t),r=this.fn;for(let i=0;i<t;i++)n[i]=r(e[i]);return n}};function ng(){return Object.keys(Zh)}function rg(e){if(!Array.isArray(e)||e.length===0)return!1;let t=e[0];return Array.isArray(t)&&t.length===2&&typeof t[0]==`string`}function ig(e){let t=Object.create(null);for(let[n,r]of e)n!==`__proto__`&&(t[n]=r);return t}function ag(e){return e.map(([,e])=>e)}function og(e){return e.map(([e])=>e)}function sg(e,t){for(let[n,r]of e)if(n===t)return r}function cg(e,t){if(t.length<=10)return t.map(t=>sg(e,t));let n=ig(e);return t.map(e=>n[e])}function lg(e,t){return rg(e)?t?cg(e,t):ag(e):Array.isArray(e)?e:typeof e==`object`&&e?t?t.map(t=>e[t]):Object.values(e):[e]}function ug(e){return rg(e)?og(e):!Array.isArray(e)&&typeof e==`object`&&e?Object.keys(e):[]}function dg(e){return fg(e).headers}function fg(e){let t=new Map,n=new Set,r=new Set,i=[],a={},o=!1,s=0;for(let t of e)t!=null&&t!==``&&r.add(t);for(let c=0;c<e.length;c++){let l=e[c];if(l==null){i.push(l);continue}if(l===``){let e=`_column_${c}`;for(;n.has(e)||r.has(e);)e=`_column_${c}_${s++}`;n.add(e),i.push(e),a[e]=``,o=!0;continue}if(!n.has(l)){n.add(l),t.set(l,1),i.push(l);continue}let u=t.get(l)??1,d=`${l}_${u}`;for(;n.has(d)||r.has(d);)u++,d=`${l}_${u}`;t.set(l,u+1),n.add(d),i.push(d),a[d]=l,o=!0}return{headers:i,renamedHeaders:o?a:null}}function pg(e){return!e||e.length===0?null:{keys:e.map(e=>typeof e==`string`?e:e.key),headers:e.map(e=>typeof e==`string`?e:e.header??e.key)}}let mg=/\S/;function hg(e,t){if(!t)return!1;if(t===`greedy`){for(let t of e)if(mg.test(t))return!1}else for(let t of e)if(t!==``)return!1;return!0}function gg(e){return hg(e,!0)}var _g=class extends t{constructor(...e){super(...e),this.name=`CsvError`}};function vg(e,t,n){let{headers:r,groupColumnsByName:i=!1}=t;if(n!==null&&Array.isArray(r))return null;let a,o;if(typeof r==`function`){if(a=r(e),a.length!==e.length)throw new _g(`Header function returned ${a.length} headers but row has ${e.length} columns. The header function must return an array with the same length as the input row.`);o=!0}else if(Array.isArray(r))a=r,o=!1;else if(r===!0)a=e,o=!0;else return null;let{headers:s,renamedHeaders:c}=fg(a);return{headers:s,originalHeaders:i?a.map(e=>e==null?null:String(e)):null,renamedHeaders:c,skipCurrentRow:o}}function yg(e,t,n){let{columnLess:r,columnMore:i}=n,a=e.length;if(a===t)return{isValid:!0,modified:!1};if(a>t)switch(i){case`error`:return{isValid:!1,errorCode:`TooManyFields`,reason:`expected ${t} columns, got ${a}`,modified:!1};case`truncate`:return e.length=t,{isValid:!0,errorCode:`TooManyFields`,modified:!0};case`keep`:return{isValid:!0,errorCode:`TooManyFields`,modified:!0,extras:e.splice(t)};default:throw Error(`Unknown columnMore strategy: ${i}`)}switch(r){case`error`:return{isValid:!1,errorCode:`TooFewFields`,reason:`expected ${t} columns, got ${a}`,modified:!1};case`pad`:for(;e.length<t;)e.push(``);return{isValid:!0,errorCode:`TooFewFields`,modified:!0};default:throw Error(`Unknown columnLess strategy: ${r}`)}}function bg(e){return e?(t,n)=>{try{e(t,n)}catch{}}:null}function xg(e,t){let n=Object.create(null);for(let r=0;r<t.length;r++){let i=t[r];i!=null&&i!==`__proto__`&&(n[i]=e[r]??``)}return n}function Sg(e,t,n,r){return r&&n?Cg(e,n):xg(e,t)}function Cg(e,t){let n=Object.create(null);for(let r=0;r<t.length;r++){let i=t[r];if(i!=null&&i!==`__proto__`){let t=e[r]??``;if(i in n){let e=n[i];Array.isArray(e)?e.push(t):n[i]=[e,t]}else n[i]=t}}return n}function wg(e){return e.filter(e=>e!=null)}function Tg(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Eg(e){return e===!1||e===null?{enabled:!1,char:``}:{enabled:!0,char:e??`"`}}function Dg(e,t){return e===!1||e===null?{enabled:!1,char:``}:{enabled:!0,char:e??t}}let Og=[`,`,`;`,` `,`|`],kg=new Set([`=`,`+`,`-`,`@`,` `,`\r`,`
394
- `,`=`,`+`,`-`,`@`]);function Ag(e){return e.charCodeAt(0)===65279?e.slice(1):e}function jg(e){return e.length>0&&kg.has(e[0])}function Mg(e,t=`"`){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i===t){if(n&&e[r+1]===t){r++;continue}n=!n;continue}if(!n){if(i===`\r`)return e[r+1]===`
393
+ `],{type:`text/javascript`});return Ch=URL.createObjectURL(t),Ch}var Th=class extends um{constructor(e){super({write:(e,t,n)=>{this._doWrite(e,n)},final:e=>{this._doClose(e)}}),this._nextId=1,this._pendingAcks=new Map,this._workerClosed=!1,this._junkError=!1,this._terminated=!1;let t=wh(e);this.worker=new Worker(t),this.worker.onmessage=e=>{let t=e.data;if(!(!t||typeof t.t!=`string`)){if(t.t===`data`){let e=t.chunk;this.push(e);return}if(t.t===`end`){this.push(null),this._terminateWorker();return}if(t.t===`aborted`){this._terminateWorker();return}if(t.t===`ack`){let e=t.id,n=this._pendingAcks.get(e);n&&(this._pendingAcks.delete(e),n());return}if(t.t===`error`){let e=typeof t.message==`string`?t.message:`Worker inflate error`;if(e.includes(`Junk`)||e.includes(`junk`)){this._junkError=!0,this.push(null),this._terminateWorker(),this._settlePendingAcks();return}let n=Error(e);this._settlePendingAcks(n),this.emit(`error`,n),this._terminateWorker();return}}},this.worker.onerror=e=>{let t=Error(e.message??`Worker error`);this._settlePendingAcks(t),this.emit(`error`,t),this._terminateWorker()}}_settlePendingAcks(e){if(this._pendingAcks.size!==0){for(let t of this._pendingAcks.values())t(e);this._pendingAcks.clear()}}_terminateWorker(){if(!this._terminated){this._terminated=!0;try{this.worker.terminate()}catch{}}}_doWrite(e,t){if(this._workerClosed||this._junkError){t();return}let n=this._nextId++;this._pendingAcks.set(n,t);let r=e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e:e.slice();this.worker.postMessage({t:`write`,id:n,chunk:r},[r.buffer])}_doClose(e){if(this._workerClosed){e();return}this._workerClosed=!0,this.worker.postMessage({t:`close`}),e()}destroy(e){if(!this._workerClosed){this._workerClosed=!0;try{this.worker.postMessage({t:`abort`})}catch{}}return this._terminateWorker(),super.destroy(e??void 0)}},Eh=class extends um{constructor(){super({write:(e,t,n)=>{if(this._finished){n(Error(`write after end`));return}this.chunks.push(e),n()},final:e=>{this._decompress(e)}}),this.chunks=[],this._finished=!1}_decompress(e){try{let t=Nl(k(this.chunks));this.push(t),this.push(null),this._finished=!0,e()}catch(t){e(a(t))}}destroy(e){return this._finished=!0,this.chunks=[],super.destroy(e??void 0)}};function Dh(){return $l()?new Sh:new Eh}let Oh=Gm;function kh(e){return class extends um{constructor(t={}){super({objectMode:!0,write:(e,t,n)=>{this._handleWrite(e,n)},final:e=>{this.finished=!0,this._maybeReleaseWriteCallback(),this._wakeUp(),this.emit(`data-available`),this.emit(`chunk`,!1),this._parsingDone.then(()=>e()).catch(e)}}),this._buffer=new ql,this.finished=!1,this._driverState={},this._parsingDone=Promise.resolve(),this._parserDoneFlag=!1,this._parserError=null,this._parserDeferred=null,this._parserDonePromise=null,this._entryQueue=[],this._entryWaiter=null,this._entriesDone=!1,this._opts=t,this.on(`error`,e=>{this._rejectParserDeferred(e),this._closeEntryQueue(e)});let n=Math.max(64*1024,t.inputHighWaterMarkBytes??2*1024*1024),r=Math.max(32*1024,t.inputLowWaterMarkBytes??Math.floor(n/4));this._inputHighWaterMarkBytes=n,this._inputLowWaterMarkBytes=Math.min(r,n);let i={pull:e=>this.pull(e),pullUntil:(e,t)=>this.pullUntil(e,t),stream:e=>this.stream(e),streamUntilDataDescriptor:()=>this._streamUntilDataDescriptor(),setDone:()=>{this.push(null)}},a={emitEntry:e=>{this.emit(`entry`,e)},pushEntry:e=>{this.push(e),this._enqueueEntry(e)},pushEntryIfPiped:e=>{this._enqueueEntry(e)},emitCrxHeader:e=>{this.crxHeader=e,this.emit(`crx-header`,e)},emitError:e=>{this.__emittedError=e,this.emit(`error`,e)},emitClose:()=>{this.emit(`close`)}};queueMicrotask(()=>{this._parsingDone=yh(this._opts,i,a,()=>{if(this._opts.useWorkerInflate&&typeof Worker<`u`&&$l())try{return new Th(this._opts.workerInflateUrl)}catch{return e()}return e()},this._driverState),this._parsingDone.then(()=>{this.__emittedError?(this._rejectParserDeferred(this.__emittedError),this._closeEntryQueue(this.__emittedError)):(this._resolveParserDeferred(),this._closeEntryQueue())},e=>{(!this.__emittedError||this.__emittedError!==e)&&(this.__emittedError=e,this.emit(`error`,e)),this._rejectParserDeferred(e),this._closeEntryQueue(e),this.emit(`close`)})})}_handleWrite(e,t){this._buffer.append(e),this._buffer.length>=this._inputHighWaterMarkBytes?this._writeCb=t:t(),this._wakeUp(),this.emit(`data-available`),this.emit(`chunk`)}get buffer(){return this._buffer.view()}set buffer(e){this._buffer.reset(e)}_wakeUp(){if(this._pendingResolve){let e=this._pendingResolve;this._pendingResolve=void 0,this._pendingDataPromise=void 0,e()}}_maybeReleaseWriteCallback(){if(!this._writeCb||this._buffer.length>this._inputLowWaterMarkBytes)return;let e=this._writeCb;this._writeCb=void 0,e()}_waitForData(){return this._pendingDataPromise||=new Promise(e=>{this._pendingResolve=e}),this._pendingDataPromise}async _pullInternal(e){if(e===0)return H;let t=e,n=null,r=null,i=e=>{if(e.length!==0){if(!n){n=e;return}if(!r){r=[n,e];return}r.push(e)}};for(;t>0;){for(;this._buffer.length===0;){if(this.finished)throw Error(`FILE_ENDED`);await this._waitForData()}let e=Math.min(t,this._buffer.length);i(this._buffer.read(e)),t-=e,this._buffer.length===0&&this._maybeReleaseWriteCallback()}return this._maybeReleaseWriteCallback(),n?r?k(r):n:H}async _pullUntilInternal(e,t=!1){let n=null,r=null,i=new zm(e),a=e.length,o=e=>{if(e.length!==0){if(!n){n=e;return}if(!r){r=[n,e];return}r.push(e)}};for(;;){let e=this._buffer.length,s=i.find(this._buffer);if(s!==-1){this.match=s;let e=s+(t?a:0);return e>0&&(o(this._buffer.read(e)),this._maybeReleaseWriteCallback()),n?r?k(r):n:H}if(i.onNoMatch(e),this.finished)throw Error(`FILE_ENDED`);let c=this._buffer.length-a;c>0&&(o(this._buffer.read(c)),i.onConsume(c),this._maybeReleaseWriteCallback()),await this._waitForData()}}_streamFixedLength(e){let t=new fm({highWaterMark:hh}),n=e,r=!1,i=!1,a=()=>{i=!1,o()},o=()=>{if(!r&&!i){for(;n>0&&this._buffer.length>0;){let e=Math.min(n,this._buffer.length),r=this._buffer.read(e);n-=e;let o=t.write(r);if(this._maybeReleaseWriteCallback(),!o){i=!0,t.once(`drain`,a);return}}n===0?(r=!0,this.removeListener(`data-available`,o),t.end()):this.finished&&(r=!0,this.removeListener(`data-available`,o),t.destroy(Error(`FILE_ENDED`)))}};return this.on(`data-available`,o),queueMicrotask(()=>o()),t}_streamUntilPattern(e,t=!1){let n=new fm({highWaterMark:hh}),r=!1,i=e.length,a=new zm(e),o=!1,s=()=>{o=!1,c()},c=()=>{if(!(r||o))for(;!(this._buffer.length<=0);){let e=this._buffer.length,l=a.find(this._buffer);if(l!==-1){this.match=l;let e=t?l+i:l;if(e>0){let t=n.write(this._buffer.read(e));if(a.onConsume(e),this._maybeReleaseWriteCallback(),!t){o=!0,n.once(`drain`,s);return}}r=!0,this.removeListener(`data-available`,c),n.end();return}if(a.onNoMatch(e),this.finished){r=!0,this.removeListener(`data-available`,c),n.destroy(Error(`FILE_ENDED`));return}let u=e-i;if(u<=0){this._buffer.length<=i&&this._maybeReleaseWriteCallback();break}let d=n.write(this._buffer.read(u));if(a.onConsume(u),this._maybeReleaseWriteCallback(),!d){o=!0,n.once(`drain`,s);return}}};return this.on(`data-available`,c),queueMicrotask(()=>c()),n}stream(e,t){return typeof e==`number`?this._streamFixedLength(e):this._streamUntilPattern(e,t??!1)}pull(e,t){if(e===0)return Promise.resolve(H);if(typeof e==`number`){if(this.finished&&this._buffer.length<e)return Promise.reject(Error(`FILE_ENDED`));if(this._buffer.length>=e){let t=this._buffer.read(e);return this._maybeReleaseWriteCallback(),Promise.resolve(t)}return this._pullInternal(e)}return this.finished?Promise.reject(Error(`FILE_ENDED`)):this._pullUntilInternal(e,t??!1)}pullUntil(e,t){return this.pull(e,t)}_streamUntilDataDescriptor(){return vh({source:{getLength:()=>this._buffer.length,read:e=>this._buffer.read(e),peekChunks:e=>this._buffer.peekChunks(e),discard:e=>this._buffer.discard(e),indexOfPattern:(e,t)=>this._buffer.indexOfPattern(e,t),peekUint32LE:e=>this._buffer.peekUint32LE(e),isFinished:()=>this.finished,onDataAvailable:e=>(this.on(`data-available`,e),()=>this.removeListener(`data-available`,e)),maybeReleaseWriteCallback:()=>this._maybeReleaseWriteCallback()},dataDescriptorSignature:Oh})}promise(){return this._parserDoneFlag?this._parserError?Promise.reject(this._parserError):Promise.resolve():(this._parserDonePromise||=new Promise((e,t)=>{this._parserDeferred={resolve:e,reject:t}}),this._parserDonePromise)}_resolveParserDeferred(){if(!this._parserDoneFlag&&(this._parserDoneFlag=!0,this._parserDeferred)){let{resolve:e}=this._parserDeferred;this._parserDeferred=null,e()}}_rejectParserDeferred(e){if(!this._parserDoneFlag&&(this._parserDoneFlag=!0,this._parserError=e,this._parserDeferred)){let{reject:t}=this._parserDeferred;this._parserDeferred=null,t(e)}}_enqueueEntry(e){if(this._entryWaiter){let{resolve:t}=this._entryWaiter;this._entryWaiter=null,t({value:e,done:!1})}else this._entryQueue.push(e)}_closeEntryQueue(e){if(this._entriesDone=!0,this._entryWaiter){let t=this._entryWaiter;this._entryWaiter=null,e?t.reject(e):t.resolve({value:void 0,done:!0})}}[Symbol.asyncIterator](){let e={next:()=>this._entryQueue.length>0?Promise.resolve({value:this._entryQueue.shift(),done:!1}):this._entriesDone?this._parserError?Promise.reject(this._parserError):Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{this._entryWaiter={resolve:e,reject:t}}),return:()=>(this._entriesDone=!0,this._entryQueue.length=0,this._entryWaiter=null,Promise.resolve({value:void 0,done:!0})),[Symbol.asyncIterator](){return e}};return e}}}let Ah=kh(Dh);var jh=class extends Ah{};function Mh(e){return new jh(e)}async function*Nh(e){let t=[],n=null,r=e=>{t.push(e),n&&=(n(),null)};e.on(`data`,r);let i=!1,a=()=>{i=!0,n&&=(n(),null)};e.on(`end`,a);let o=!1,s=e=>{o=e,n&&=(n(),null)};e.on(`error`,s);try{for(;!i||t.length>0;)if(t.length===0?(e.resume(),await new Promise(e=>{n=e})):(e.pause(),yield t.shift()),o)throw o}finally{e.removeListener(`data`,r),e.removeListener(`end`,a),e.removeListener(`error`,s)}}var Ph=class extends V{constructor({workbook:e,id:t,iterator:n,options:r}){super(),this.workbook=e,this.id=t,this.sheetNo=typeof t==`number`?t:parseInt(String(t),10),this.iterator=n,this.options=r||{},this.name=`Sheet${this.id}`,this._columns=[],this._keys=Object.create(null),this._dimensions=new T}destroy(){throw new b(`destroy`,`Invalid operation for a streaming reader`)}get dimensions(){return this._dimensions}get columns(){return this._columns}getColumn(e){if(typeof e==`string`){let t=this._keys[e];if(t)return t;e=w.l2n(e)}if(e>this._columns.length){let t=this._columns.length+1;for(;t<=e;)this._columns.push(new Re(this,t++))}return this._columns[e-1]}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){let t=this._keys;for(let n in t)e(t[n],n)}async read(){try{for await(let e of this.parse())for(let t=0;t<e.length;t++){let n=e[t];this.emit(n.eventType,n.value)}this.emit(`finished`)}catch(e){this.emit(`error`,e)}}async*[Symbol.asyncIterator](){for await(let e of this.parse())for(let t=0;t<e.length;t++){let n=e[t];n.eventType===`row`&&(yield n.value)}}async*parse(){let{iterator:e,options:t}=this,n=!1,r=!1,i=null;switch(t.worksheets){case`emit`:n=!0;break;case`prep`:break;default:break}switch(t.hyperlinks){case`emit`:r=!0;break;case`cache`:this.hyperlinks=i=Object.create(null);break;default:break}if(!n&&!r&&!i)return;let a=r||i!==null,{sharedStrings:o,styles:s,properties:c}=this.workbook,l=!1,u=!1,d=!1,f=null,p=null,m=null,h=null;for await(let t of gi(e)){let e=null;for(let g=0;g<t.length;g++){let _=t[g],v=_.eventType,y=_.value;if(v===`opentag`){let t=y;if(n)switch(t.name){case`cols`:l=!0,f=[];break;case`sheetData`:u=!0;break;case`col`:l&&f.push({min:parseInt(t.attributes.min,10),max:parseInt(t.attributes.max,10),width:parseFloat(t.attributes.width),styleId:parseInt(t.attributes.style??`0`,10)});break;case`row`:if(u){let e=parseInt(t.attributes.r,10);if(p=new Le(this,e),t.attributes.ht&&(p.height=parseFloat(t.attributes.ht)),t.attributes.customHeight===`1`&&(p.customHeight=!0),t.attributes.s!==void 0){let e=parseInt(t.attributes.s,10),n=s.getStyleModel(e);n&&(p.style=n)}}break;case`c`:if(p){let e=t.attributes.s;m={ref:t.attributes.r,s:e===void 0?void 0:parseInt(e,10),t:t.attributes.t}}break;case`f`:m&&(h=m.f={text:``});break;case`v`:m&&(h=m.v={text:``});break;case`is`:case`t`:m&&(h=m.v={text:``});break;case`mergeCell`:break;default:break}if(a)switch(t.name){case`hyperlinks`:d=!0;break;case`hyperlink`:if(d){let n=t.attributes.location,a={ref:t.attributes.ref,rId:t.attributes[`r:id`],target:n?n.startsWith(`#`)?n:`#${n}`:void 0};r?(e||=[]).push({eventType:`hyperlink`,value:a}):i[a.ref]=a}break;default:break}}else if(v===`text`)n&&h&&(h.text+=y);else if(v===`closetag`){let t=y;if(n)switch(t.name){case`cols`:l=!1,this._columns=Re.fromModel(f);break;case`sheetData`:u=!1;break;case`row`:p&&(this._dimensions.expandRow({number:p.number,dimensions:p.dimensions??void 0}),(e||=[]).push({eventType:`row`,value:p})),p=null;break;case`c`:if(p&&m){let e=w.decodeAddress(m.ref),t=p.getCell(e.col);if(m.s!==void 0){let e=s.getStyleModel(m.s);e&&(t.style=e)}if(m.f){let e={formula:m.f.text};m.v&&(m.t===`str`?e.result=vt(m.v.text):e.result=parseFloat(m.v.text)),t.value=e}else if(m.v)switch(m.t){case`s`:{let e=parseInt(m.v.text,10);o?t.value=o[e]:t.value={sharedString:e};break}case`inlineStr`:t.value=ft(vt(m.v.text));break;case`str`:t.value=vt(m.v.text);break;case`e`:t.value={error:m.v.text};break;case`b`:t.value=parseInt(m.v.text,10)!==0;break;default:{let e=typeof t.numFmt==`string`?t.numFmt:t.numFmt?.formatCode;e&&Tt(e)?t.value=lt(parseFloat(m.v.text),c?.model?.date1904):t.value=parseFloat(m.v.text);break}}if(i){let e=i[m.ref];e&&(t.text=t.value,t.value=void 0,t.hyperlink=e)}m=null,h=null}break;default:break}if(a)switch(t.name){case`hyperlinks`:d=!1;break;default:break}}}e&&e.length>0&&(yield e)}}},Fh=class extends V{constructor({workbook:e,id:t,iterator:n,options:r}){super(),this._hyperlinkCount=0,this.workbook=e,this.id=t,this.iterator=n,this.options=r}get count(){return this.hyperlinks?this._hyperlinkCount:0}each(e){let t=this.hyperlinks;if(t)for(let n in t)e(t[n],n)}async read(){let{iterator:e}=this,t=this.options.hyperlinks,n=t===`emit`,r=t===`cache`,i=null;if(r&&(this._hyperlinkCount=0,this.hyperlinks=i=Object.create(null)),!n&&!r){this.emit(`finished`);return}try{for await(let t of gi(e))for(let{eventType:e,value:r}of t){if(e!==`opentag`)continue;let t=r;if(t.name!==`Relationship`)continue;let a=t.attributes;if(a.Type!==R.Hyperlink)continue;let o={type:D.RelationshipType.Hyperlink,rId:a.Id,target:a.Target,targetMode:a.TargetMode};if(n){this.emit(`hyperlink`,o);continue}let s=o.rId;i&&i[s]===void 0&&(this._hyperlinkCount+=1),i[s]=o}this.emit(`finished`)}catch(e){this.emit(`error`,e)}}},Ih=class extends V{getHyperlinkReader(e){return this._hyperlinkReadersBySheetNo?.[String(e)]}getHyperlink(e,t){return this.getHyperlinkReader(e)?.hyperlinks?.[t]}getHyperlinkTarget(e,t){return this.getHyperlink(e,t)?.target}constructor(e,t,n,r){super(),this._totalBufferedBytes=0,this.input=e,this.WorksheetReaderClass=n,this.HyperlinkReaderClass=r,this._maxBufferedBytes=t.maxBufferedWorksheetBytes??256*1024*1024,this.options={worksheets:`emit`,sharedStrings:`cache`,hyperlinks:`ignore`,styles:`ignore`,entries:`ignore`,...t},this.styles=new Ki,this.styles.init()}_getStream(e){if(e instanceof W)return e;if(e&&typeof e==`object`&&typeof e.getReader==`function`){let t=W.fromWeb;if(typeof t==`function`)return t(e);try{return new W({stream:e})}catch{throw new y(`<ReadableStream>`,`read`,`Could not recognise input`)}}let t=e;if(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),t instanceof Uint8Array)return W.from([t]);throw new y(String(e),`read`,`Could not recognise input`)}_cleanupWaitingWorksheets(e){for(let t of e)t&&typeof t.cleanup==`function`&&t.cleanup()}_createWorksheetReader(e){return new this.WorksheetReaderClass({workbook:this,id:e.id,iterator:e.iterator,options:e.options})}_createHyperlinkReader(e){return new this.HyperlinkReaderClass({workbook:this,id:e.id,iterator:e.iterator,options:e.options})}async read(e,t){try{for await(let{eventType:n,value:r}of this.parse(e,t))switch(n){case`shared-strings`:this.emit(n,r);break;case`worksheet`:this.emit(n,r),await r.read();break;case`hyperlinks`:this.emit(n,r);break}this.emit(`end`),this.emit(`finished`)}catch(e){this.emit(`error`,e)}}async*[Symbol.asyncIterator](){for await(let{eventType:e,value:t}of this.parse())e===`worksheet`&&(yield t)}async*parse(e,t){t&&(this.options=t);let n=this.stream=this._getStream(e||this.input),r=[];try{for await(let e of this._parseEntries(n))if(e.eventType===`waiting-worksheet`){let t=await this._storeWaitingWorksheet(e.sheetNo,e.entry);r.push(t)}else yield e;yield*this._processWaitingWorksheets(r)}catch(e){throw this._cleanupWaitingWorksheets(r),e}}_emitEntry(e){this.options.entries===`emit`&&this.emit(`entry`,e)}async _parseRels(e){this.workbookRels=await new ta().parseStream(Nh(e)),this._workbookRelIdByTarget=Object.create(null);for(let e of this.workbookRels??[])e?.Target&&e?.Id&&(this._workbookRelIdByTarget[e.Target]=e.Id)}async _parseWorkbook(e){this._emitEntry({type:`workbook`});let t=new Ao;this.model=await t.parseStream(Nh(e)),this.properties=t.map?.workbookPr,this._sheetByRelId=Object.create(null);for(let e of this.model?.sheets??[])this._sheetByRelId[e.rId]=e}async*_parseSharedStrings(e){switch(this._emitEntry({type:`shared-strings`}),this.options.sharedStrings){case`cache`:this.sharedStrings=[];break;case`emit`:break;default:return}let t=null,n=[],r=0,i=null,a=!1;for await(let o of gi(Nh(e)))for(let{eventType:e,value:s}of o)if(e===`opentag`){let e=s;switch(e.name){case`b`:i||={},i.bold=!0;break;case`charset`:i||={},i.charset=parseInt(e.attributes.charset,10);break;case`color`:i||={},i.color={},e.attributes.rgb&&(i.color.argb=e.attributes.rgb),e.attributes.val&&(i.color.argb=e.attributes.val),e.attributes.theme&&(i.color.theme=e.attributes.theme);break;case`family`:i||={},i.family=parseInt(e.attributes.val,10);break;case`i`:i||={},i.italic=!0;break;case`outline`:i||={},i.outline=!0;break;case`rFont`:i||={},i.name=e.attributes.val;break;case`r`:a=!0;break;case`si`:i=null,n=[],t=null,a=!1;break;case`sz`:i||={},i.size=parseInt(e.attributes.val,10);break;case`strike`:i||={},i.strike=!0;break;case`t`:t=null;break;case`u`:i||={},i.underline=!0;break;case`vertAlign`:i||={},i.vertAlign=e.attributes.val;break}}else if(e===`text`)t=t?t+s:s;else if(e===`closetag`)switch(s.name){case`t`:t!=null&&(t=ft(t));break;case`r`:a&&(n.push({font:i,text:t}),i=null,t=null);break;case`si`:this.options.sharedStrings===`cache`?this.sharedStrings.push(n.length?{richText:n}:t??``):this.options.sharedStrings===`emit`&&(yield{index:r++,text:n.length?{richText:n}:t??``}),n=[],i=null,t=null,a=!1;break}}async _parseStyles(e){this._emitEntry({type:`styles`}),this.options.styles===`cache`&&(this.styles=new Ki,await this.styles.parseStream(Nh(e)))}*_parseWorksheet(e,t){this._emitEntry({type:`worksheet`,id:t});let n=parseInt(t,10),r=this._createWorksheetReader({id:n,iterator:e,options:this.options});r.sheetNo=n;let i=this._workbookRelIdByTarget?.[Ra(t)],a=i?this._sheetByRelId?.[i]:void 0;a&&(r.id=a.id,r.name=a.name,r.state=a.state),this.options.worksheets===`emit`&&(yield{eventType:`worksheet`,value:r})}async*_parseHyperlinks(e,t){this._emitEntry({type:`hyperlinks`,id:t});let n=this._createHyperlinkReader({id:parseInt(t,10),iterator:e,options:this.options});if(this.options.hyperlinks===`cache`){this._hyperlinkReadersBySheetNo||=Object.create(null),this._hyperlinkReadersBySheetNo[t]=n;let e=n.read;typeof e==`function`&&await e.call(n);return}this.options.hyperlinks===`emit`&&(yield{eventType:`hyperlinks`,value:n})}async*_parseEntries(e){let t=Mh({forceStream:!0});e.on(`error`,e=>t.emit(`error`,e)),e.pipe(t);for await(let e of Nh(t)){let t,n=ga(e.path);switch(n){case I.rootRels:break;case I.xlWorkbookRels:await this._parseRels(e);break;case I.xlWorkbook:await this._parseWorkbook(e);break;case I.xlSharedStrings:for await(let t of this._parseSharedStrings(e))yield{eventType:`shared-strings`,value:t};break;case I.xlStyles:await this._parseStyles(e);break;default:if(t=_a(n)?.toString(),t)if(this.workbookRels&&this.model&&(this.options.sharedStrings!==`cache`||this.sharedStrings)){yield*this._parseWorksheet(Nh(e),t);continue}else{yield{eventType:`waiting-worksheet`,sheetNo:t,entry:e};continue}if(t=va(n)?.toString(),t){yield*this._parseHyperlinks(Nh(e),t);continue}break}e.autodrain()}}},Lh=class extends Ih{constructor(e,t={}){super(e,t,Ph,Fh)}async _storeWaitingWorksheet(e,t){let n=[],r=new TextEncoder;for await(let e of Nh(t)){let t;if(e instanceof Uint8Array)t=e;else if(typeof e==`string`)t=r.encode(e);else continue;if(this._totalBufferedBytes+=t.length,this._totalBufferedBytes>this._maxBufferedBytes)throw Error(`Buffered worksheet data exceeds limit of ${this._maxBufferedBytes} bytes. The XLSX file may be malicious (adversarial ZIP entry ordering) or too large for streaming. Increase maxBufferedWorksheetBytes if this is expected.`);n.push(t)}return{sheetNo:e,data:n}}async*_processWaitingWorksheets(e){for(let t of e){let e=(async function*(){for(let e of t.data)yield e})();yield*this._parseWorksheet(e,t.sheetNo)}}};let J=Array.from({length:60},(e,t)=>t<10?`0${t}`:`${t}`),Y=(e,t)=>(e.charCodeAt(t)-48)*10+e.charCodeAt(t+1)-48|0,Rh=(e,t)=>(e.charCodeAt(t)-48)*1e3+(e.charCodeAt(t+1)-48)*100+(e.charCodeAt(t+2)-48)*10+e.charCodeAt(t+3)-48|0,zh=[0,31,29,31,30,31,30,31,31,30,31,30,31];function Bh(e,t,n){if(t<1||t>12||n<1||n>zh[t])return null;let r=new Date(e,t-1,n);return r.getMonth()===t-1?r:null}function Vh(e,t,n,r,i,a){return t<1||t>12||n<1||n>zh[t]||r>23||i>59||a>59?null:new Date(e,t-1,n,r,i,a)}function Hh(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45?null:Bh(Rh(e,0),Y(e,5),Y(e,8))}function Uh(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45||e.charCodeAt(10)!==84||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Vh(Rh(e,0),Y(e,5),Y(e,8),Y(e,11),Y(e,14),Y(e,17))}function Wh(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Vh(Rh(e,0),Y(e,5),Y(e,8),Y(e,11),Y(e,14),Y(e,17))}function Gh(e){if(e.charCodeAt(19)!==90)return null;let t=new Date(e);return isNaN(t.getTime())?null:t}function Kh(e){if(e.charCodeAt(19)!==46||e.charCodeAt(23)!==90)return null;let t=new Date(e);return isNaN(t.getTime())?null:t}function qh(e){let t=e.charCodeAt(19);if(t!==43&&t!==45)return null;let n=new Date(e);return isNaN(n.getTime())?null:n}function Jh(e){if(e.charCodeAt(19)!==46)return null;let t=e.charCodeAt(23);if(t!==43&&t!==45)return null;let n=new Date(e);return isNaN(n.getTime())?null:n}function Yh(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t?null:Bh(Rh(e,6),Y(e,0),Y(e,3))}function Xh(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t?null:Bh(Rh(e,6),Y(e,3),Y(e,0))}function Zh(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Vh(Rh(e,6),Y(e,0),Y(e,3),Y(e,11),Y(e,14),Y(e,17))}function Qh(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Vh(Rh(e,6),Y(e,3),Y(e,0),Y(e,11),Y(e,14),Y(e,17))}let $h={"YYYY-MM-DD":Hh,"YYYY-MM-DD[T]HH:mm:ss":Uh,"YYYY-MM-DD HH:mm:ss":Wh,"YYYY-MM-DD[T]HH:mm:ssZ":e=>e.length===20?Gh(e):e.length===25?qh(e):null,"YYYY-MM-DD[T]HH:mm:ss.SSSZ":e=>e.length===24?Kh(e):e.length===29?Jh(e):null,"MM-DD-YYYY":Yh,"MM-DD-YYYY HH:mm:ss":Zh,"MM/DD/YYYY HH:mm:ss":Zh,"DD-MM-YYYY":Xh,"DD-MM-YYYY HH:mm:ss":Qh,"DD/MM/YYYY HH:mm:ss":Qh},eg=[[10,[Hh]],[19,[Uh,Wh]],[20,[Gh]],[24,[Kh]],[25,[qh]],[29,[Jh]]];var tg=class e{constructor(e){this.parse=e=>{if(!e)return null;let t=e.trim();if(!t)return null;if(this.single)return this.fn0(t);for(let e=0,n=this.fns.length;e<n;e++){let n=this.fns[e](t);if(n)return n}return null},this.fns=e,this.single=e.length===1,this.fn0=e[0]}static create(t){return new e(t.map(e=>$h[e]).filter(Boolean))}static iso(){let t=[];for(let[,e]of eg)t.push(...e);return new e(t)}parseAll(e){let t=e.length,n=Array(t),r=this.parse;for(let i=0;i<t;i++)n[i]=r(e[i]);return n}parseValid(e){let t=[],n=this.parse;for(let r=0,i=e.length;r<i;r++){let i=n(e[r]);i&&t.push(i)}return t}};function ng(e){let t=-e.getTimezoneOffset(),n=t>=0?`+`:`-`,r=Math.abs(t)/60|0,i=Math.abs(t)%60;return`${n}${J[r]}:${J[i]}`}var rg=class e{constructor(e){this.format=e=>this.fn(e),this.fn=e}static iso(t=!1){return t?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let n=e.getUTCFullYear(),r=e.getUTCMonth()+1,i=e.getUTCDate(),a=e.getUTCHours(),o=e.getUTCMinutes(),s=e.getUTCSeconds(),c=e.getUTCMilliseconds();return`${n}-${J[r]}-${J[i]}T${J[a]}:${J[o]}:${J[s]}.${c<10?`00`+c:c<100?`0`+c:c}Z`}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let n=e.getFullYear(),r=e.getMonth()+1,i=e.getDate(),a=e.getHours(),o=e.getMinutes(),s=e.getSeconds(),c=e.getMilliseconds();return`${n}-${J[r]}-${J[i]}T${J[a]}:${J[o]}:${J[s]}.${c<10?`00`+c:c<100?`0`+c:c}${ng(e)}`})}static create(t,n){let r=n?.utc??!1;if(t===`YYYY-MM-DD`)return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getUTCFullYear()}-${J[e.getUTCMonth()+1]}-${J[e.getUTCDate()]}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getFullYear()}-${J[e.getMonth()+1]}-${J[e.getDate()]}`:``});if(t===`YYYY-MM-DD HH:mm:ss`)return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getUTCFullYear()}-${J[e.getUTCMonth()+1]}-${J[e.getUTCDate()]} ${J[e.getUTCHours()]}:${J[e.getUTCMinutes()]}:${J[e.getUTCSeconds()]}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getFullYear()}-${J[e.getMonth()+1]}-${J[e.getDate()]} ${J[e.getHours()]}:${J[e.getMinutes()]}:${J[e.getSeconds()]}`:``});if(t===`MM-DD-YYYY`||t===`MM/DD/YYYY`){let n=t.charAt(2);return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${J[e.getUTCMonth()+1]}${n}${J[e.getUTCDate()]}${n}${e.getUTCFullYear()}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${J[e.getMonth()+1]}${n}${J[e.getDate()]}${n}${e.getFullYear()}`:``})}if(t===`DD-MM-YYYY`||t===`DD/MM/YYYY`){let n=t.charAt(2);return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${J[e.getUTCDate()]}${n}${J[e.getUTCMonth()+1]}${n}${e.getUTCFullYear()}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${J[e.getDate()]}${n}${J[e.getMonth()+1]}${n}${e.getFullYear()}`:``})}return e.createGeneric(t,r)}static createGeneric(t,n){let r=[],i=[],a=0;for(;a<t.length;)if(t[a]===`[`){let e=t.indexOf(`]`,a+1);e===-1?(i.push(t[a]),a++):(r.push(t.slice(a+1,e)),i.push(`\x00${r.length-1}\x00`),a=e+1)}else i.push(t[a]),a++;let o=i.join(``),s=o.includes(`YYYY`),c=o.includes(`SSS`),l=o.includes(`MM`),u=o.includes(`DD`),d=o.includes(`HH`),f=o.includes(`mm`),p=o.includes(`ss`),m=o.includes(`Z`);return new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let i=o;if(s&&(i=i.replace(/YYYY/g,String(n?e.getUTCFullYear():e.getFullYear()))),c){let t=n?e.getUTCMilliseconds():e.getMilliseconds();i=i.replace(/SSS/g,t<10?`00${t}`:t<100?`0${t}`:String(t))}return l&&(i=i.replace(/MM/g,J[n?e.getUTCMonth()+1:e.getMonth()+1])),u&&(i=i.replace(/DD/g,J[n?e.getUTCDate():e.getDate()])),d&&(i=i.replace(/HH/g,J[n?e.getUTCHours():e.getHours()])),f&&(i=i.replace(/mm/g,J[n?e.getUTCMinutes():e.getMinutes()])),p&&(i=i.replace(/ss/g,J[n?e.getUTCSeconds():e.getSeconds()])),m&&(i=i.replace(/Z/g,n?`Z`:ng(e))),r.length&&(i=i.replace(/\x00(\d+)\x00/g,(e,t)=>r[+t])),i})}formatAll(e){let t=e.length,n=Array(t),r=this.fn;for(let i=0;i<t;i++)n[i]=r(e[i]);return n}};function ig(){return Object.keys($h)}function ag(e){if(!Array.isArray(e)||e.length===0)return!1;let t=e[0];return Array.isArray(t)&&t.length===2&&typeof t[0]==`string`}function og(e){let t=Object.create(null);for(let[n,r]of e)n!==`__proto__`&&(t[n]=r);return t}function sg(e){return e.map(([,e])=>e)}function cg(e){return e.map(([e])=>e)}function lg(e,t){for(let[n,r]of e)if(n===t)return r}function ug(e,t){if(t.length<=10)return t.map(t=>lg(e,t));let n=og(e);return t.map(e=>n[e])}function dg(e,t){return ag(e)?t?ug(e,t):sg(e):Array.isArray(e)?e:typeof e==`object`&&e?t?t.map(t=>e[t]):Object.values(e):[e]}function fg(e){return ag(e)?cg(e):!Array.isArray(e)&&typeof e==`object`&&e?Object.keys(e):[]}function pg(e){return mg(e).headers}function mg(e){let t=new Map,n=new Set,r=new Set,i=[],a={},o=!1,s=0;for(let t of e)t!=null&&t!==``&&r.add(t);for(let c=0;c<e.length;c++){let l=e[c];if(l==null){i.push(l);continue}if(l===``){let e=`_column_${c}`;for(;n.has(e)||r.has(e);)e=`_column_${c}_${s++}`;n.add(e),i.push(e),a[e]=``,o=!0;continue}if(!n.has(l)){n.add(l),t.set(l,1),i.push(l);continue}let u=t.get(l)??1,d=`${l}_${u}`;for(;n.has(d)||r.has(d);)u++,d=`${l}_${u}`;t.set(l,u+1),n.add(d),i.push(d),a[d]=l,o=!0}return{headers:i,renamedHeaders:o?a:null}}function hg(e){return!e||e.length===0?null:{keys:e.map(e=>typeof e==`string`?e:e.key),headers:e.map(e=>typeof e==`string`?e:e.header??e.key)}}let gg=/\S/;function _g(e,t){if(!t)return!1;if(t===`greedy`){for(let t of e)if(gg.test(t))return!1}else for(let t of e)if(t!==``)return!1;return!0}function vg(e){return _g(e,!0)}var yg=class extends t{constructor(...e){super(...e),this.name=`CsvError`}};function bg(e,t,n){let{headers:r,groupColumnsByName:i=!1}=t;if(n!==null&&Array.isArray(r))return null;let a,o;if(typeof r==`function`){if(a=r(e),a.length!==e.length)throw new yg(`Header function returned ${a.length} headers but row has ${e.length} columns. The header function must return an array with the same length as the input row.`);o=!0}else if(Array.isArray(r))a=r,o=!1;else if(r===!0)a=e,o=!0;else return null;let{headers:s,renamedHeaders:c}=mg(a);return{headers:s,originalHeaders:i?a.map(e=>e==null?null:String(e)):null,renamedHeaders:c,skipCurrentRow:o}}function xg(e,t,n){let{columnLess:r,columnMore:i}=n,a=e.length;if(a===t)return{isValid:!0,modified:!1};if(a>t)switch(i){case`error`:return{isValid:!1,errorCode:`TooManyFields`,reason:`expected ${t} columns, got ${a}`,modified:!1};case`truncate`:return e.length=t,{isValid:!0,errorCode:`TooManyFields`,modified:!0};case`keep`:return{isValid:!0,errorCode:`TooManyFields`,modified:!0,extras:e.splice(t)};default:throw Error(`Unknown columnMore strategy: ${i}`)}switch(r){case`error`:return{isValid:!1,errorCode:`TooFewFields`,reason:`expected ${t} columns, got ${a}`,modified:!1};case`pad`:for(;e.length<t;)e.push(``);return{isValid:!0,errorCode:`TooFewFields`,modified:!0};default:throw Error(`Unknown columnLess strategy: ${r}`)}}function Sg(e){return e?(t,n)=>{try{e(t,n)}catch{}}:null}function Cg(e,t){let n=Object.create(null);for(let r=0;r<t.length;r++){let i=t[r];i!=null&&i!==`__proto__`&&(n[i]=e[r]??``)}return n}function wg(e,t,n,r){return r&&n?Tg(e,n):Cg(e,t)}function Tg(e,t){let n=Object.create(null);for(let r=0;r<t.length;r++){let i=t[r];if(i!=null&&i!==`__proto__`){let t=e[r]??``;if(i in n){let e=n[i];Array.isArray(e)?e.push(t):n[i]=[e,t]}else n[i]=t}}return n}function Eg(e){return e.filter(e=>e!=null)}function Dg(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Og(e){return e===!1||e===null?{enabled:!1,char:``}:{enabled:!0,char:e??`"`}}function kg(e,t){return e===!1||e===null?{enabled:!1,char:``}:{enabled:!0,char:e??t}}let Ag=[`,`,`;`,` `,`|`],jg=new Set([`=`,`+`,`-`,`@`,` `,`\r`,`
394
+ `,`=`,`+`,`-`,`@`]);function Mg(e){return e.charCodeAt(0)===65279?e.slice(1):e}function Ng(e){return e.length>0&&jg.has(e[0])}function Pg(e,t=`"`){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i===t){if(n&&e[r+1]===t){r++;continue}n=!n;continue}if(!n){if(i===`\r`)return e[r+1]===`
395
395
  `?`\r
396
396
  `:`\r`;if(i===`
397
397
  `)return`
398
398
  `}}return`
399
- `}function Ng(e,t=`"`,n,r,i){let a=n??Og,o=a[0]??`,`,s=Pg(e,10,t,r,i);if(s.length===0)return o;let c=o,l,u;for(let e of a){let{avgFieldCount:n,delta:r}=Fg(s,e,t);n<=1.99||(l===void 0||r<l||r===l&&(u===void 0||n>u))&&(l=r,u=n,c=e)}return c}function Pg(e,t,n,r,i){let a=[],o=0,s=!1,c=e.length;for(let l=0;l<c&&a.length<t;l++){let t=e[l];if(n&&t===n)s&&e[l+1]===n?l++:s=!s;else if(!s&&(t===`
399
+ `}function Fg(e,t=`"`,n,r,i){let a=n??Ag,o=a[0]??`,`,s=Ig(e,10,t,r,i);if(s.length===0)return o;let c=o,l,u;for(let e of a){let{avgFieldCount:n,delta:r}=Lg(s,e,t);n<=1.99||(l===void 0||r<l||r===l&&(u===void 0||n>u))&&(l=r,u=n,c=e)}return c}function Ig(e,t,n,r,i){let a=[],o=0,s=!1,c=e.length;for(let l=0;l<c&&a.length<t;l++){let t=e[l];if(n&&t===n)s&&e[l+1]===n?l++:s=!s;else if(!s&&(t===`
400
400
  `||t===`\r`)){let n=e.slice(o,l);if(!(r&&n.startsWith(r))){let e=n.trim();!(n.length===0||i&&e===``)&&e!==``&&a.push(n)}t===`\r`&&e[l+1]===`
401
- `&&l++,o=l+1}}if(o<c&&a.length<t){let t=e.slice(o);if(!r||!t.startsWith(r)){let e=t.trim();!(t.length===0||i&&e===``)&&e!==``&&a.push(t)}}return a}function Fg(e,t,n){if(e.length===0)return{avgFieldCount:0,delta:1/0};let r=0,i=0,a;for(let o of e){let e=Ig(o,t,n)+1;if(i+=e,a===void 0){a=e;continue}r+=Math.abs(e-a),a=e}return i/=e.length,{avgFieldCount:i,delta:r}}function Ig(e,t,n){let r=0,i=!1,a=e.length,o=t.length;for(let s=0;s<a;s++)n&&e[s]===n?i&&e[s+1]===n?s++:i=!i:i||(o===1?e[s]===t&&r++:e.startsWith(t,s)&&(r++,s+=o-1));return r}let Lg=/\r\n|\r|\n/,Rg=null,zg=null,Bg=null;function Vg(){return Rg||(Rg=new TextEncoder,zg=new Uint8Array(4),Bg=new Uint8Array(4096)),Rg}function Hg(e){let t=e.length;if(t===0)return 0;if(t===1)return e.charCodeAt(0)<128?1:Vg().encodeInto(e,zg).written;let n=!0;for(let r=0;r<t;r++)if(e.charCodeAt(r)>=128){n=!1;break}if(n)return t;let r=Vg();return t*3>Bg.length&&(Bg=new Uint8Array(t*3)),r.encodeInto(e,Bg).written}function Ug(e){let{input:t,options:n,detectedDelimiter:r}=e,{delimiter:i=`,`,delimitersToGuess:a,lineEnding:o=``,quote:s=`"`,escape:c,skipEmptyLines:l=!1,trim:u=!1,ltrim:d=!1,rtrim:f=!1,headers:p=!1,comment:m,maxRows:h,toLine:g,skipLines:_=0,skipRows:v=0,columnMismatch:y,groupColumnsByName:b=!1,fastMode:x=!1,dynamicTyping:S,castDate:ee,beforeFirstChunk:C,info:te=!1,raw:ne=!1,relaxQuotes:w=!1,skipRecordsWithError:T=!1,skipRecordsWithEmptyValues:E=!1,onSkip:re,maxRowBytes:ie}=n,ae=y?.less??`error`,oe=y?.more??`error`,se;if(t!==void 0){if(se=t,C){let e=C(se);if(typeof e==`string`)se=e;else if(e!=null)throw new _g(`beforeFirstChunk must return a string or undefined, got ${typeof e}`)}se=Ag(se)}let D=l,{enabled:ce,char:le}=Eg(s),ue=Dg(c,le),de=ue.enabled?ue.char||le:``,fe;fe=r===void 0?i===``&&se!==void 0?Ng(se,le||`"`,a,m,D):i===``?`,`:i:r;let pe=o||(se===void 0?`
402
- `:Mg(se));return{config:{delimiter:fe,linebreak:pe,linebreakRegex:pe&&pe!==`
401
+ `&&l++,o=l+1}}if(o<c&&a.length<t){let t=e.slice(o);if(!r||!t.startsWith(r)){let e=t.trim();!(t.length===0||i&&e===``)&&e!==``&&a.push(t)}}return a}function Lg(e,t,n){if(e.length===0)return{avgFieldCount:0,delta:1/0};let r=0,i=0,a;for(let o of e){let e=Rg(o,t,n)+1;if(i+=e,a===void 0){a=e;continue}r+=Math.abs(e-a),a=e}return i/=e.length,{avgFieldCount:i,delta:r}}function Rg(e,t,n){let r=0,i=!1,a=e.length,o=t.length;for(let s=0;s<a;s++)n&&e[s]===n?i&&e[s+1]===n?s++:i=!i:i||(o===1?e[s]===t&&r++:e.startsWith(t,s)&&(r++,s+=o-1));return r}let zg=/\r\n|\r|\n/,Bg=null,Vg=null,Hg=null;function Ug(){return Bg||(Bg=new TextEncoder,Vg=new Uint8Array(4),Hg=new Uint8Array(4096)),Bg}function Wg(e){let t=e.length;if(t===0)return 0;if(t===1)return e.charCodeAt(0)<128?1:Ug().encodeInto(e,Vg).written;let n=!0;for(let r=0;r<t;r++)if(e.charCodeAt(r)>=128){n=!1;break}if(n)return t;let r=Ug();return t*3>Hg.length&&(Hg=new Uint8Array(t*3)),r.encodeInto(e,Hg).written}function Gg(e){let{input:t,options:n,detectedDelimiter:r}=e,{delimiter:i=`,`,delimitersToGuess:a,lineEnding:o=``,quote:s=`"`,escape:c,skipEmptyLines:l=!1,trim:u=!1,ltrim:d=!1,rtrim:f=!1,headers:p=!1,comment:m,maxRows:h,toLine:g,skipLines:_=0,skipRows:v=0,columnMismatch:y,groupColumnsByName:b=!1,fastMode:x=!1,dynamicTyping:S,castDate:ee,beforeFirstChunk:C,info:te=!1,raw:ne=!1,relaxQuotes:w=!1,skipRecordsWithError:T=!1,skipRecordsWithEmptyValues:E=!1,onSkip:re,maxRowBytes:ie}=n,ae=y?.less??`error`,oe=y?.more??`error`,se;if(t!==void 0){if(se=t,C){let e=C(se);if(typeof e==`string`)se=e;else if(e!=null)throw new yg(`beforeFirstChunk must return a string or undefined, got ${typeof e}`)}se=Mg(se)}let D=l,{enabled:ce,char:le}=Og(s),ue=kg(c,le),de=ue.enabled?ue.char||le:``,fe;fe=r===void 0?i===``&&se!==void 0?Fg(se,le||`"`,a,m,D):i===``?`,`:i:r;let pe=o||(se===void 0?`
402
+ `:Pg(se));return{config:{delimiter:fe,linebreak:pe,linebreakRegex:pe&&pe!==`
403
403
  `&&pe!==`\r
404
- `&&pe!==`\r`?pe:Lg,quote:le,escape:de,quoteEnabled:ce,trimField:Kg(u,d,f),trimFieldIsIdentity:!u&&!d&&!f,shouldSkipEmpty:D,skipLines:_,skipRows:v,maxRows:h,toLine:g,maxRowBytes:ie,comment:m,fastMode:x,relaxQuotes:w,columnLess:ae,columnMore:oe,groupColumnsByName:b,skipRecordsWithError:T,skipRecordsWithEmptyValues:E,infoOption:te,rawOption:ne,dynamicTyping:S,castDate:ee,invokeOnSkip:bg(re),headers:p},processedInput:se}}function Wg(e,t){let n=Ug({input:e,options:t});return{config:n.config,processedInput:n.processedInput}}function Gg(e){return{delimiter:e.delimiter,quote:e.quote,escape:e.escape,quoteEnabled:e.quoteEnabled,relaxQuotes:e.relaxQuotes}}function Kg(e,t,n){return e||t&&n?e=>e.trim():t?e=>e.trimStart():n?e=>e.trimEnd():e=>e}function qg(e){let t={lineNumber:0,dataRowCount:0,skippedDataRows:0,truncated:!1,headerRow:null,originalHeaders:null,useHeaders:!1,headerRowProcessed:!1,renamedHeadersForMeta:null,currentRowStartLine:e.infoOption?1:0,currentRowStartOffset:0,currentRowQuoted:[],currentRawRow:``},{headers:n,groupColumnsByName:r}=e;if(n===!0)t.useHeaders=!0;else if(Array.isArray(n)){let e=vg([],{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 Jg(e,t,n,r,i){t&&(e.currentRowQuoted=[],e.currentRowStartLine=r,e.currentRowStartOffset=i),n&&(e.currentRawRow=``)}let Yg=Object.freeze(Array(256).fill(!1));function Xg(e){return e<=256?Yg:Array(e).fill(!1)}let Zg=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,Qg=null;function $g(){return Qg||=$h.iso(),Qg}function e_(e){return!e||e.length<10?null:$g().parse(e)}function t_(e,t){return e?e===!0?!0:Array.isArray(e)&&typeof t==`string`?e.includes(t):!1:!1}function n_(e,t){return e===t||e===t-32}function r_(e){let t=e.length;if(t===0)return``;let n=e.charCodeAt(0);if(t===4){if((n===116||n===84)&&n_(e.charCodeAt(1),114)&&n_(e.charCodeAt(2),117)&&n_(e.charCodeAt(3),101))return!0;if((n===110||n===78)&&n_(e.charCodeAt(1),117)&&n_(e.charCodeAt(2),108)&&n_(e.charCodeAt(3),108))return null}else if(t===5&&(n===102||n===70)&&n_(e.charCodeAt(1),97)&&n_(e.charCodeAt(2),108)&&n_(e.charCodeAt(3),115)&&n_(e.charCodeAt(4),101))return!1;if(n>=48&&n<=57||n===45||n===46||n===73||n===78){if(e.charCodeAt(t-1)<=32)return e;if(e===`Infinity`)return 1/0;if(e===`-Infinity`)return-1/0;if(e===`NaN`)return NaN;if(n===48&&t>1){let t=e.charCodeAt(1);if(t>=48&&t<=57)return e}if(n===45&&t>2&&e.charCodeAt(1)===48){let t=e.charCodeAt(2);if(t>=48&&t<=57)return e}if(Zg.test(e)){let t=Number(e);if(!isNaN(t))return t}}return e}function i_(e){return typeof e==`function`}function a_(e,t){return t===!1?e:i_(t)?t(e):r_(e)}function o_(e,t,n,r){if(t_(r,t)){let t=e_(e);if(t!==null)return t}if(n===!0)return r_(e);if(n===!1||t===void 0)return e;let i=n[t];return i===void 0?e:a_(e,i)}function s_(e,t,n){if(t===!1&&!n)return e;for(let r in e)Object.hasOwn(e,r)&&(e[r]=o_(e[r],r,t,n));return e}function c_(e,t,n,r){return n===!1&&!r||n!==!0&&n!==!1&&!t?e:e.map((e,i)=>{let a=t?.[i];return o_(e,a,n,r)})}function l_(e,t,n){let r=vg(e,{headers:n.headers,groupColumnsByName:n.groupColumnsByName},t.headerRow);return r?(t.headerRow=r.headers,t.originalHeaders=r.originalHeaders,t.renamedHeadersForMeta=r.renamedHeaders,t.headerRowProcessed=!0,r.skipCurrentRow):(t.headerRowProcessed=!0,!1)}function u_(e,t,n){if(!t.headerRow||t.headerRow.length===0)return null;let r=t.headerRow.length,i=e.length;if(i===r)return null;let a=yg(e,r,{columnLess:n.columnLess,columnMore:n.columnMore});return a.errorCode?{errorCode:a.errorCode,message:a.errorCode===`TooManyFields`?`Too many fields: expected ${r}, found ${i}`:`Too few fields: expected ${r}, found ${i}`,isValid:a.isValid,reason:a.reason,extras:a.extras}:null}function d_(e,t,n,r){let i={index:t,line:e.currentRowStartLine,offset:e.currentRowStartOffset,quoted:e.currentRowQuoted.slice(0,r)};return n&&(i.raw=e.currentRawRow),i}function f_(e,t,n){if(t.headerRow){let r=Sg(e,t.headerRow,t.originalHeaders,n.groupColumnsByName);return(n.dynamicTyping||n.castDate)&&(r=s_(r,n.dynamicTyping||!1,n.castDate)),r}let r={};for(let t=0;t<e.length;t++)r[t]=e[t];return r}function p_(e,t,n,r){return!!(t&&e[0]?.trimStart().startsWith(t)||hg(e,n)||r&&gg(e))}function m_(e,t,n,r,i){if(t.useHeaders&&!t.headerRowProcessed&&l_(e,t,n))return{stop:!1,skipped:!0};if(t.skippedDataRows<n.skipRows)return t.skippedDataRows++,{stop:!1,skipped:!0};let a=u_(e,t,n),o;if(a){let t={code:a.errorCode,message:a.message,line:i};if(r.push(t),!a.isValid)return n.skipRecordsWithError?(n.invokeOnSkip?.({code:a.errorCode,message:a.reason||`Column mismatch`,line:i},e),{stop:!1,skipped:!0,row:e,error:{code:a.errorCode,message:a.reason||`Column mismatch`,line:i},reason:a.reason||`Column mismatch`}):{stop:!1,skipped:!0,row:e,error:t,reason:a.reason||`Column mismatch`};o=a.extras}if(n.skipRecordsWithEmptyValues&&gg(e))return{stop:!1,skipped:!0};if(n.maxRows!==void 0&&t.dataRowCount>=n.maxRows)return t.truncated=!0,{stop:!0,skipped:!1};t.dataRowCount++;let s;return n.infoOption&&(s=d_(t,t.dataRowCount-1,n.rawOption,e.length)),{stop:!1,skipped:!1,row:e,info:s,extras:o}}let h_={delimiter:`,`,quote:`"`,escape:`"`,quoteEnabled:!0,relaxQuotes:!1};function g_(){return{buffer:``,position:0}}function __(e,t){let n=e.length,r=e.indexOf(`
404
+ `&&pe!==`\r`?pe:zg,quote:le,escape:de,quoteEnabled:ce,trimField:Jg(u,d,f),trimFieldIsIdentity:!u&&!d&&!f,shouldSkipEmpty:D,skipLines:_,skipRows:v,maxRows:h,toLine:g,maxRowBytes:ie,comment:m,fastMode:x,relaxQuotes:w,columnLess:ae,columnMore:oe,groupColumnsByName:b,skipRecordsWithError:T,skipRecordsWithEmptyValues:E,infoOption:te,rawOption:ne,dynamicTyping:S,castDate:ee,invokeOnSkip:Sg(re),headers:p},processedInput:se}}function Kg(e,t){let n=Gg({input:e,options:t});return{config:n.config,processedInput:n.processedInput}}function qg(e){return{delimiter:e.delimiter,quote:e.quote,escape:e.escape,quoteEnabled:e.quoteEnabled,relaxQuotes:e.relaxQuotes}}function Jg(e,t,n){return e||t&&n?e=>e.trim():t?e=>e.trimStart():n?e=>e.trimEnd():e=>e}function Yg(e){let t={lineNumber:0,dataRowCount:0,skippedDataRows:0,truncated:!1,headerRow:null,originalHeaders:null,useHeaders:!1,headerRowProcessed:!1,renamedHeadersForMeta:null,currentRowStartLine:e.infoOption?1:0,currentRowStartOffset:0,currentRowQuoted:[],currentRawRow:``},{headers:n,groupColumnsByName:r}=e;if(n===!0)t.useHeaders=!0;else if(Array.isArray(n)){let e=bg([],{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 Xg(e,t,n,r,i){t&&(e.currentRowQuoted=[],e.currentRowStartLine=r,e.currentRowStartOffset=i),n&&(e.currentRawRow=``)}let Zg=Object.freeze(Array(256).fill(!1));function Qg(e){return e<=256?Zg:Array(e).fill(!1)}let $g=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,e_=null;function t_(){return e_||=tg.iso(),e_}function n_(e){return!e||e.length<10?null:t_().parse(e)}function r_(e,t){return e?e===!0?!0:Array.isArray(e)&&typeof t==`string`?e.includes(t):!1:!1}function i_(e,t){return e===t||e===t-32}function a_(e){let t=e.length;if(t===0)return``;let n=e.charCodeAt(0);if(t===4){if((n===116||n===84)&&i_(e.charCodeAt(1),114)&&i_(e.charCodeAt(2),117)&&i_(e.charCodeAt(3),101))return!0;if((n===110||n===78)&&i_(e.charCodeAt(1),117)&&i_(e.charCodeAt(2),108)&&i_(e.charCodeAt(3),108))return null}else if(t===5&&(n===102||n===70)&&i_(e.charCodeAt(1),97)&&i_(e.charCodeAt(2),108)&&i_(e.charCodeAt(3),115)&&i_(e.charCodeAt(4),101))return!1;if(n>=48&&n<=57||n===45||n===46||n===73||n===78){if(e.charCodeAt(t-1)<=32)return e;if(e===`Infinity`)return 1/0;if(e===`-Infinity`)return-1/0;if(e===`NaN`)return NaN;if(n===48&&t>1){let t=e.charCodeAt(1);if(t>=48&&t<=57)return e}if(n===45&&t>2&&e.charCodeAt(1)===48){let t=e.charCodeAt(2);if(t>=48&&t<=57)return e}if($g.test(e)){let t=Number(e);if(!isNaN(t))return t}}return e}function o_(e){return typeof e==`function`}function s_(e,t){return t===!1?e:o_(t)?t(e):a_(e)}function c_(e,t,n,r){if(r_(r,t)){let t=n_(e);if(t!==null)return t}if(n===!0)return a_(e);if(n===!1||t===void 0)return e;let i=n[t];return i===void 0?e:s_(e,i)}function l_(e,t,n){if(t===!1&&!n)return e;for(let r in e)Object.hasOwn(e,r)&&(e[r]=c_(e[r],r,t,n));return e}function u_(e,t,n,r){return n===!1&&!r||n!==!0&&n!==!1&&!t?e:e.map((e,i)=>{let a=t?.[i];return c_(e,a,n,r)})}function d_(e,t,n){let r=bg(e,{headers:n.headers,groupColumnsByName:n.groupColumnsByName},t.headerRow);return r?(t.headerRow=r.headers,t.originalHeaders=r.originalHeaders,t.renamedHeadersForMeta=r.renamedHeaders,t.headerRowProcessed=!0,r.skipCurrentRow):(t.headerRowProcessed=!0,!1)}function f_(e,t,n){if(!t.headerRow||t.headerRow.length===0)return null;let r=t.headerRow.length,i=e.length;if(i===r)return null;let a=xg(e,r,{columnLess:n.columnLess,columnMore:n.columnMore});return a.errorCode?{errorCode:a.errorCode,message:a.errorCode===`TooManyFields`?`Too many fields: expected ${r}, found ${i}`:`Too few fields: expected ${r}, found ${i}`,isValid:a.isValid,reason:a.reason,extras:a.extras}:null}function p_(e,t,n,r){let i={index:t,line:e.currentRowStartLine,offset:e.currentRowStartOffset,quoted:e.currentRowQuoted.slice(0,r)};return n&&(i.raw=e.currentRawRow),i}function m_(e,t,n){if(t.headerRow){let r=wg(e,t.headerRow,t.originalHeaders,n.groupColumnsByName);return(n.dynamicTyping||n.castDate)&&(r=l_(r,n.dynamicTyping||!1,n.castDate)),r}let r={};for(let t=0;t<e.length;t++)r[t]=e[t];return r}function h_(e,t,n,r){return!!(t&&e[0]?.trimStart().startsWith(t)||_g(e,n)||r&&vg(e))}function g_(e,t,n,r,i){if(t.useHeaders&&!t.headerRowProcessed&&d_(e,t,n))return{stop:!1,skipped:!0};if(t.skippedDataRows<n.skipRows)return t.skippedDataRows++,{stop:!1,skipped:!0};let a=f_(e,t,n),o;if(a){let t={code:a.errorCode,message:a.message,line:i};if(r.push(t),!a.isValid)return n.skipRecordsWithError?(n.invokeOnSkip?.({code:a.errorCode,message:a.reason||`Column mismatch`,line:i},e),{stop:!1,skipped:!0,row:e,error:{code:a.errorCode,message:a.reason||`Column mismatch`,line:i},reason:a.reason||`Column mismatch`}):{stop:!1,skipped:!0,row:e,error:t,reason:a.reason||`Column mismatch`};o=a.extras}if(n.skipRecordsWithEmptyValues&&vg(e))return{stop:!1,skipped:!0};if(n.maxRows!==void 0&&t.dataRowCount>=n.maxRows)return t.truncated=!0,{stop:!0,skipped:!1};t.dataRowCount++;let s;return n.infoOption&&(s=p_(t,t.dataRowCount-1,n.rawOption,e.length)),{stop:!1,skipped:!1,row:e,info:s,extras:o}}let __={delimiter:`,`,quote:`"`,escape:`"`,quoteEnabled:!0,relaxQuotes:!1};function v_(){return{buffer:``,position:0}}function y_(e,t){let n=e.length,r=e.indexOf(`
405
405
  `,t),i=e.indexOf(`\r`,t);return r===-1&&i===-1?[-1,0]:i===-1||r!==-1&&r<i?[r,1]:i+1<n?e[i+1]===`
406
- `?[i,2]:[i,1]:[i,-1]}function v_(e,t,n){return n.length===1?e[t]===n:e.startsWith(n,t)}function y_(e,t,n){return e.indexOf(n,t)}function b_(e,t,n,r){let{quote:i,escape:a,delimiter:o,relaxQuotes:s}=n,c=e.length,l=t+1,u=null,d=l,f=t=>{let n=t>d?e.slice(d,t):``;return u===null?n:(n&&u.push(n),u.length===1?u[0]:u.join(``))};for(;l<c;){let n=e[l];if(a&&n===a){if(l+1<c&&e[l+1]===i){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(i),l+=2,d=l;continue}if(a!==i&&l+1<c&&e[l+1]===a){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(a),l+=2,d=l;continue}if(a===i){if(l+1>=c)return r?{value:f(l),quoted:!0,endPos:l+1,needMore:!1}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t};let n=e[l+1];if((o.length===1?n===o:v_(e,l+1,o))||n===`
407
- `||n===`\r`)return{value:f(l),quoted:!0,endPos:l+1,needMore:!1};if(s){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(i),l++,d=l;continue}return{value:f(l),quoted:!0,endPos:l+1,needMore:!1}}}if(n===i&&a!==i){if(l+1>=c)return r?{value:f(l),quoted:!0,endPos:l+1,needMore:!1}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t};let n=e[l+1];if((o.length===1?n===o:v_(e,l+1,o))||n===`
406
+ `?[i,2]:[i,1]:[i,-1]}function b_(e,t,n){return n.length===1?e[t]===n:e.startsWith(n,t)}function x_(e,t,n){return e.indexOf(n,t)}function S_(e,t,n,r){let{quote:i,escape:a,delimiter:o,relaxQuotes:s}=n,c=e.length,l=t+1,u=null,d=l,f=t=>{let n=t>d?e.slice(d,t):``;return u===null?n:(n&&u.push(n),u.length===1?u[0]:u.join(``))};for(;l<c;){let n=e[l];if(a&&n===a){if(l+1<c&&e[l+1]===i){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(i),l+=2,d=l;continue}if(a!==i&&l+1<c&&e[l+1]===a){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(a),l+=2,d=l;continue}if(a===i){if(l+1>=c)return r?{value:f(l),quoted:!0,endPos:l+1,needMore:!1}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t};let n=e[l+1];if((o.length===1?n===o:b_(e,l+1,o))||n===`
407
+ `||n===`\r`)return{value:f(l),quoted:!0,endPos:l+1,needMore:!1};if(s){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(i),l++,d=l;continue}return{value:f(l),quoted:!0,endPos:l+1,needMore:!1}}}if(n===i&&a!==i){if(l+1>=c)return r?{value:f(l),quoted:!0,endPos:l+1,needMore:!1}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t};let n=e[l+1];if((o.length===1?n===o:b_(e,l+1,o))||n===`
408
408
  `||n===`\r`)return{value:f(l),quoted:!0,endPos:l+1,needMore:!1};if(s){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(i),l++,d=l;continue}return{value:f(l),quoted:!0,endPos:l+1,needMore:!1}}if(n===`\r`){if(l+1<c){if(e[l+1]===`
409
409
  `){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(`
410
410
  `),l+=2,d=l;continue}l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(`
411
411
  `),l++,d=l;continue}if(!r)return{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t};l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(`
412
- `),l++,d=l;continue}l++}return r?{value:f(l),quoted:!0,endPos:l,needMore:!1,unterminated:!0}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t}}function x_(e,t,n,r){let{delimiter:i}=n,a=e.length,o=y_(e,t,i),[s,c]=__(e,t),l,u=!1;return o===-1&&s===-1?r?{value:e.slice(t),quoted:!1,endPos:a,needMore:!1}:{value:e.slice(t),quoted:!1,endPos:a,needMore:!0,resumePos:t}:(o===-1?(l=s,u=!0):s===-1||o<s?l=o:(l=s,u=!0),u&&c===-1&&!r?{value:e.slice(t,l),quoted:!1,endPos:l,needMore:!0,resumePos:t}:{value:e.slice(t,l),quoted:!1,endPos:l,needMore:!1})}function S_(e,t,n,r,i,a){let{delimiter:o,quote:s,quoteEnabled:c}=n,l=o.length,u=e.length,d=i??[],f=a??[];i&&(i.length=0),a&&(a.length=0);let p=t,m=!1,h=t;for(;p<u;){let i=e[p];if(c&&i===s){let i=b_(e,p,n,r);if(i.needMore)return{fields:d,quoted:f,endPos:p,complete:!1,needMore:!0,resumePos:i.resumePos??t,rawStart:h,rawEnd:p};if(i.unterminated&&(m=!0),d.push(i.value),f.push(!0),p=i.endPos,p<u){if(v_(e,p,o)){p+=l,p>=u&&r&&(d.push(``),f.push(!1));continue}let n=e[p];if(n===`
412
+ `),l++,d=l;continue}l++}return r?{value:f(l),quoted:!0,endPos:l,needMore:!1,unterminated:!0}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t}}function C_(e,t,n,r){let{delimiter:i}=n,a=e.length,o=x_(e,t,i),[s,c]=y_(e,t),l,u=!1;return o===-1&&s===-1?r?{value:e.slice(t),quoted:!1,endPos:a,needMore:!1}:{value:e.slice(t),quoted:!1,endPos:a,needMore:!0,resumePos:t}:(o===-1?(l=s,u=!0):s===-1||o<s?l=o:(l=s,u=!0),u&&c===-1&&!r?{value:e.slice(t,l),quoted:!1,endPos:l,needMore:!0,resumePos:t}:{value:e.slice(t,l),quoted:!1,endPos:l,needMore:!1})}function w_(e,t,n,r,i,a){let{delimiter:o,quote:s,quoteEnabled:c}=n,l=o.length,u=e.length,d=i??[],f=a??[];i&&(i.length=0),a&&(a.length=0);let p=t,m=!1,h=t;for(;p<u;){let i=e[p];if(c&&i===s){let i=S_(e,p,n,r);if(i.needMore)return{fields:d,quoted:f,endPos:p,complete:!1,needMore:!0,resumePos:i.resumePos??t,rawStart:h,rawEnd:p};if(i.unterminated&&(m=!0),d.push(i.value),f.push(!0),p=i.endPos,p<u){if(b_(e,p,o)){p+=l,p>=u&&r&&(d.push(``),f.push(!1));continue}let n=e[p];if(n===`
413
413
  `)return{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`
414
414
  `,rawStart:h,rawEnd:p};if(n===`\r`)return p+1<u?e[p+1]===`
415
415
  `?{fields:d,quoted:f,endPos:p+2,complete:!0,needMore:!1,newline:`\r
416
- `,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}:r?{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p,complete:!1,needMore:!0,resumePos:t,rawStart:h,rawEnd:p};for(p++;p<u;){if(v_(e,p,o)){p+=l;break}if(e[p]===`
417
- `||e[p]===`\r`)break;p++}continue}continue}let a=x_(e,p,n,r);if(a.needMore)return d.push(a.value),f.push(!1),{fields:d,quoted:f,endPos:a.endPos,complete:!1,needMore:!0,resumePos:a.resumePos??t,rawStart:h,rawEnd:a.endPos};if(d.push(a.value),f.push(!1),p=a.endPos,p<u){if(v_(e,p,o)){p+=l,p>=u&&r&&(d.push(``),f.push(!1));continue}let t=e[p];if(t===`
416
+ `,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}:r?{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p,complete:!1,needMore:!0,resumePos:t,rawStart:h,rawEnd:p};for(p++;p<u;){if(b_(e,p,o)){p+=l;break}if(e[p]===`
417
+ `||e[p]===`\r`)break;p++}continue}continue}let a=C_(e,p,n,r);if(a.needMore)return d.push(a.value),f.push(!1),{fields:d,quoted:f,endPos:a.endPos,complete:!1,needMore:!0,resumePos:a.resumePos??t,rawStart:h,rawEnd:a.endPos};if(d.push(a.value),f.push(!1),p=a.endPos,p<u){if(b_(e,p,o)){p+=l,p>=u&&r&&(d.push(``),f.push(!1));continue}let t=e[p];if(t===`
418
418
  `)return{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`
419
419
  `,rawStart:h,rawEnd:p};if(t===`\r`)return p+1<u&&e[p+1]===`
420
420
  `?{fields:d,quoted:f,endPos:p+2,complete:!0,needMore:!1,newline:`\r
421
- `,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 C_(e){let t={...h_,...e},n=g_(),r=[],i=[];return{get config(){return t},scanRow(e,n=0,r=!1){return S_(e,n,t,r)},feed(e){n.buffer+=e},nextRow(){if(n.position>=n.buffer.length)return null;let e=S_(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=S_(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=g_(),r.length=0,i.length=0},getBuffer(){return n.buffer.slice(n.position)}}}let w_=new WeakMap;function T_(e){let t=w_.get(e);return t||(t=new RegExp(e.source,`${e.flags.replace(/g/g,``)}g`),w_.set(e,t)),t}function*E_(e,t){if(e===``)return;if(typeof t==`string`){let n=t;if(n===``){yield{line:e,lineEndingLength:0,lineLengthWithEnding:e.length};return}let r=0;for(;;){let t=e.indexOf(n,r);if(t===-1){if(r===e.length)return;let t=e.slice(r);yield{line:t,lineEndingLength:0,lineLengthWithEnding:t.length};return}let i=e.slice(r,t),a=n.length;yield{line:i,lineEndingLength:a,lineLengthWithEnding:i.length+a},r=t+n.length}}let n=t.global?t:T_(t),r=0;for(n.lastIndex=0;;){let t=n.exec(e);if(!t)break;let i=t.index,a=i+t[0].length,o=e.slice(r,i),s=t[0].length;yield{line:o,lineEndingLength:s,lineLengthWithEnding:o.length+s},r=a,t[0].length===0&&n.lastIndex++}if(r===e.length)return;let i=e.slice(r);yield{line:i,lineEndingLength:0,lineLengthWithEnding:i.length}}function D_(e){return typeof e==`boolean`?{isValid:e,reason:`Validation failed`}:{isValid:e.isValid,reason:e.reason||`Validation failed`}}function O_(e,t,n){return c_(e,null,t||!1,n)}function k_(e){return e.length>0?e:void 0}function A_(e,t){return{delimiter:e.delimiter,linebreak:e.linebreak,aborted:!1,truncated:t.truncated,cursor:t.dataRowCount,fields:t.headerRow?wg(t.headerRow):void 0,renamedHeaders:t.renamedHeadersForMeta}}function j_(e,t){return t.trimFieldIsIdentity?e:e.map(t.trimField)}function*M_(e,t,n,r){if(e===``)return;let i=0;for(let{line:a,lineLengthWithEnding:o}of E_(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&&Hg(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=j_(a.split(t.delimiter),t);if(t.infoOption&&(n.currentRowQuoted=Xg(e.length)),t.comment&&e[0]?.trimStart().startsWith(t.comment)){i+=o;continue}if(t.shouldSkipEmpty&&hg(e,t.shouldSkipEmpty)){i+=o;continue}let s=m_(e,n,t,r,n.lineNumber);if(i+=o,s.stop){yield s;return}(!s.skipped||s.error)&&(yield s),Jg(n,t.infoOption,t.rawOption,n.lineNumber+1,i)}}function*N_(e,t,n,r){let i=Gg(t),a=e.length,o=0;for(t.infoOption&&(n.currentRowStartOffset=0);o<a;){let a=S_(e,o,i,!0);if(a.fields.length===0&&a.endPos===o)break;let s=j_(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&&Hg(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&&hg(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=m_(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 P_(e,t={}){let{config:n,processedInput:r}=Wg(e,t),i=qg(n),a=[],o=[],s=n.fastMode?M_(r,n,i,a):N_(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}=D_(t.validate(i));if(!e){o.push({row:i,reason:n});continue}}(n.dynamicTyping||n.castDate)&&(i=O_(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=A_(n,i);return n.infoOption||t.validate?{headers:void 0,rows:e,invalidRows:k_(o),errors:k_(a),meta:r}:e}let c=[];for(let e of s){if(e.row&&!e.skipped){let r=f_(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}=D_(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=A_(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:k_(o),errors:k_(a),meta:l}}return{headers:l.fields,rows:c,invalidRows:k_(o),errors:k_(a),meta:l}}let F_=Symbol.for(`csv.FormattedValue`);function I_(e){return typeof e==`object`&&!!e&&e[F_]===!0}function L_(e){return e.length<2}function R_(e){return e.length<2}var z_=class extends dm{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`),this.autoDetectDelimiter=(e.delimiter??`,`)===``;let{config:t}=Ug({options:e});this.parseConfig=t,this.parseState=qg(t),this.scanner=C_(Gg(t)),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 L_(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 R_(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=Ag(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]!==`
421
+ `,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 T_(e){let t={...__,...e},n=v_(),r=[],i=[];return{get config(){return t},scanRow(e,n=0,r=!1){return w_(e,n,t,r)},feed(e){n.buffer+=e},nextRow(){if(n.position>=n.buffer.length)return null;let e=w_(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=w_(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=v_(),r.length=0,i.length=0},getBuffer(){return n.buffer.slice(n.position)}}}let E_=new WeakMap;function D_(e){let t=E_.get(e);return t||(t=new RegExp(e.source,`${e.flags.replace(/g/g,``)}g`),E_.set(e,t)),t}function*O_(e,t){if(e===``)return;if(typeof t==`string`){let n=t;if(n===``){yield{line:e,lineEndingLength:0,lineLengthWithEnding:e.length};return}let r=0;for(;;){let t=e.indexOf(n,r);if(t===-1){if(r===e.length)return;let t=e.slice(r);yield{line:t,lineEndingLength:0,lineLengthWithEnding:t.length};return}let i=e.slice(r,t),a=n.length;yield{line:i,lineEndingLength:a,lineLengthWithEnding:i.length+a},r=t+n.length}}let n=t.global?t:D_(t),r=0;for(n.lastIndex=0;;){let t=n.exec(e);if(!t)break;let i=t.index,a=i+t[0].length,o=e.slice(r,i),s=t[0].length;yield{line:o,lineEndingLength:s,lineLengthWithEnding:o.length+s},r=a,t[0].length===0&&n.lastIndex++}if(r===e.length)return;let i=e.slice(r);yield{line:i,lineEndingLength:0,lineLengthWithEnding:i.length}}function k_(e){return typeof e==`boolean`?{isValid:e,reason:`Validation failed`}:{isValid:e.isValid,reason:e.reason||`Validation failed`}}function A_(e,t,n){return u_(e,null,t||!1,n)}function j_(e){return e.length>0?e:void 0}function M_(e,t){return{delimiter:e.delimiter,linebreak:e.linebreak,aborted:!1,truncated:t.truncated,cursor:t.dataRowCount,fields:t.headerRow?Eg(t.headerRow):void 0,renamedHeaders:t.renamedHeadersForMeta}}function N_(e,t){return t.trimFieldIsIdentity?e:e.map(t.trimField)}function*P_(e,t,n,r){if(e===``)return;let i=0;for(let{line:a,lineLengthWithEnding:o}of O_(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&&Wg(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=N_(a.split(t.delimiter),t);if(t.infoOption&&(n.currentRowQuoted=Qg(e.length)),t.comment&&e[0]?.trimStart().startsWith(t.comment)){i+=o;continue}if(t.shouldSkipEmpty&&_g(e,t.shouldSkipEmpty)){i+=o;continue}let s=g_(e,n,t,r,n.lineNumber);if(i+=o,s.stop){yield s;return}(!s.skipped||s.error)&&(yield s),Xg(n,t.infoOption,t.rawOption,n.lineNumber+1,i)}}function*F_(e,t,n,r){let i=qg(t),a=e.length,o=0;for(t.infoOption&&(n.currentRowStartOffset=0);o<a;){let a=w_(e,o,i,!0);if(a.fields.length===0&&a.endPos===o)break;let s=N_(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&&Wg(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&&_g(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=g_(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 I_(e,t={}){let{config:n,processedInput:r}=Kg(e,t),i=Yg(n),a=[],o=[],s=n.fastMode?P_(r,n,i,a):F_(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}=k_(t.validate(i));if(!e){o.push({row:i,reason:n});continue}}(n.dynamicTyping||n.castDate)&&(i=A_(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=M_(n,i);return n.infoOption||t.validate?{headers:void 0,rows:e,invalidRows:j_(o),errors:j_(a),meta:r}:e}let c=[];for(let e of s){if(e.row&&!e.skipped){let r=m_(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}=k_(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=M_(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:j_(o),errors:j_(a),meta:l}}return{headers:l.fields,rows:c,invalidRows:j_(o),errors:j_(a),meta:l}}let L_=Symbol.for(`csv.FormattedValue`);function R_(e){return typeof e==`object`&&!!e&&e[L_]===!0}function z_(e){return e.length<2}function B_(e){return e.length<2}var V_=class extends dm{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`),this.autoDetectDelimiter=(e.delimiter??`,`)===``;let{config:t}=Gg({options:e});this.parseConfig=t,this.parseState=Yg(t),this.scanner=T_(qg(t)),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 z_(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 B_(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=Mg(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]!==`
422
422
  `&&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]===`
423
- `&&n++,n===i)break}if(t){let e=this.options.skipEmptyLines;this.parseConfig.delimiter=Ng(this.buffer,this.parseConfig.quote||`"`,this.options.delimitersToGuess,this.options.comment,e),this.delimiterDetected=!0,this.emit(`delimiter`,this.parseConfig.delimiter),this.scanner=C_(Gg(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?Xg(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===Lg){let t=e.lastIndexOf(`
424
- `),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 E_(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?Xg(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=Sg(e,this.parseState.headerRow,this.parseState.originalHeaders,i);a=n||r?s_(t,n||!1,r):t}else a=n||r?c_(e,this.parseState.headerRow?wg(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&&Hg(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=m_(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`,wg(this.parseState.headerRow)))}shouldSkipRow(e,t){return p_(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 B_(e={}){return new z_(e)}function V_(e){return e.replace(/[\\\]^-]/g,`\\$&`)}function H_(e){let{quote:t,delimiter:n,escape:r}=e,{enabled:i,char:a}=Eg(t),o=Dg(r,a);if(!i)return{needsQuoteRegex:null,escapeQuoteRegex:null,escapedQuote:``,quoteEnabled:!1,quote:``,escape:``,delimiter:n,useFastCheck:!1};let s=o.char||a,c=n.length===1&&a.length===1&&s.length===1;return{needsQuoteRegex:c?null:(()=>{let e=`${V_(n)}${V_(a)}${s===a?``:V_(s)}\r\n`;return RegExp(`[${e}]`)})(),escapeQuoteRegex:s===a?new RegExp(Tg(a),`g`):RegExp(`${Tg(a)}|${Tg(s)}`,`g`),escapedQuote:s+a,quoteEnabled:!0,quote:a,escape:s,delimiter:n,useFastCheck:c}}function U_(e){return e===!0?()=>!0:e===!1||e===void 0?()=>!1:Array.isArray(e)?t=>e[t]===!0:(t,n)=>n?e[n]===!0:!1}function W_(e){let{delimiter:t=`,`,lineEnding:n=`
425
- `,quote:r=`"`,escape:i,quoteColumns:a=!1,quoteHeaders:o=!1,writeHeaders:s,bom:c=!1,trailingNewline:l=!1,escapeFormulae:u=!1,decimalSeparator:d=`.`,typeTransform:f}=e;if(d!==`.`&&d!==`,`)throw new _g(`Invalid decimalSeparator: "${d}". Must be "." or ",".`);if(d===t)throw new _g(`decimalSeparator cannot be the same as delimiter`);let p=H_({quote:r,delimiter:t,escape:i});return{delimiter:t,lineEnding:n,quoteAll:a===!0,escapeFormulae:u,decimalSeparator:d,writeHeaders:s??!0,bom:c,trailingNewline:l,typeTransform:f,regex:p,shouldQuoteColumn:U_(a),shouldQuoteHeader:U_(o)}}let G_=/^-?\d+(,\d+)?([eE][+-]?\d+)?$/;function K_(e,t){return t===`,`?String(e).replace(`.`,`,`):String(e)}function q_(e,t){let n=e.trim();return t===`,`&&G_.test(n)?Number(n.replace(`,`,`.`)):Number(n)}function J_(e,t,n){if(e==null)return;let r=typeof e;if(r===`boolean`&&t.boolean)return t.boolean(e,n);if(e instanceof Date&&t.date)return t.date(e,n);if(r===`number`&&t.number)return t.number(e,n);if(r===`bigint`&&t.bigint)return t.bigint(e,n);if(r===`string`&&t.string)return t.string(e,n);if(r===`object`&&!Array.isArray(e)&&!(e instanceof Date)&&t.object)return t.object(e,n)}function Y_(e,t){if(e==null)return``;if(typeof e==`number`)return K_(e,t);if(e instanceof Date)return e.toISOString();if(typeof e==`bigint`)return String(e);if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return`[object Object]`}return String(e)}function X_(e,t,n,r){return e.indexOf(t)!==-1||e.indexOf(n)!==-1||r!==n&&e.indexOf(r)!==-1||e.indexOf(`
426
- `)!==-1||e.indexOf(`\r`)!==-1}function Z_(e,t,n){let{index:r,header:i,isHeader:a,outputRowIndex:o,forceQuote:s,quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d}=n,f,p;if(!a&&d){let t=J_(e,d,{column:i??r,index:o});t==null?f=Y_(e,u):I_(t)?(f=t.value,p=t.quote):f=t}else f=Y_(e,u);if(l&&p!==!1&&typeof e!=`number`&&typeof e!=`bigint`&&jg(f)&&(f=`'`+f),!t.quoteEnabled)return f;let m;if(m=p===void 0?c||s||(t.useFastCheck?X_(f,t.delimiter,t.quote,t.escape):t.needsQuoteRegex.test(f)):p,m){let e;return e=t.escape===t.quote?f.replace(t.escapeQuoteRegex,t.escapedQuote):f.replace(t.escapeQuoteRegex,e=>e===t.quote?t.escape+t.quote:t.escape+t.escape),t.quote+e+t.quote}return f}function Q_(e,t,n){let{quoteLookup:r,delimiter:i,headers:a,isHeader:o,outputRowIndex:s,quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d}=n,f=e.length;if(f===0)return``;let p={index:0,header:a?.[0],isHeader:o,outputRowIndex:s,forceQuote:r(0,a?.[0]),quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d},m=Z_(e[0],t,p);for(let n=1;n<f;n++)p.index=n,p.header=a?.[n],p.forceQuote=r(n,p.header),m+=i+Z_(e[n],t,p);return m}function $_(e,t,n){if(!e.typeTransform?.row)return t;let r=e.typeTransform.row(t,n);return r===null?null:r}function ev(e,t,n){let{headers:r,columns:i}=t;if(e.length===0)return i&&i.length>0?{keys:null,displayHeaders:i.map(e=>typeof e==`string`?e:e.header??e.key),rows:[]}:Array.isArray(r)?{keys:r,displayHeaders:r,rows:[]}:{keys:null,displayHeaders:null,rows:[]};let a=e[0];if(i&&i.length>0){let t=pg(i),r=t.keys,a=t.headers,o=[];for(let t=0;t<e.length;t++){let i=$_(n,e[t],t);if(i===null)continue;let a;a=rg(i)?cg(i,r):Array.isArray(i)?i:r.map(e=>i[e]),o.push(a)}return{keys:r,displayHeaders:a,rows:o}}if(rg(a)){let t=e,i=r===!0?og(t[0]):Array.isArray(r)?r:null,a=[];for(let e=0;e<t.length;e++){let r=$_(n,t[e],e);if(r===null)continue;let o;o=rg(r)?i?cg(r,i):ag(r):Array.isArray(r)?r:i?i.map(e=>r[e]):Object.values(r),a.push(o)}return{keys:i,displayHeaders:i,rows:a}}if(!Array.isArray(a)&&typeof a==`object`){let t=e,i=r===!0?Object.keys(t[0]):Array.isArray(r)?r:null,a=[];for(let e=0;e<t.length;e++){let r=$_(n,t[e],e);if(r===null)continue;let o=i?i.map(e=>r[e]):Object.values(r);a.push(o)}return{keys:i,displayHeaders:i,rows:a}}let o=e,s=Array.isArray(r)?r:null,c=[];for(let e=0;e<o.length;e++){let t=$_(n,o[e],e);t!==null&&c.push(t)}return{keys:s,displayHeaders:s,rows:c}}function tv(e,t={}){let n=W_(t),{displayHeaders:r,rows:i}=ev(e,t,n),a=[],o=r?dg(r):void 0;o&&n.writeHeaders&&a.push(Q_(o,n.regex,{quoteLookup:n.shouldQuoteHeader,delimiter:n.delimiter,headers:o,isHeader:!0,outputRowIndex:0,quoteAll:n.quoteAll,escapeFormulae:n.escapeFormulae,decimalSeparator:n.decimalSeparator,transform:void 0}));for(let e=0;e<i.length;e++)a.push(Q_(i[e],n.regex,{quoteLookup:n.shouldQuoteColumn,delimiter:n.delimiter,headers:o,isHeader:!1,outputRowIndex:e,quoteAll:n.quoteAll,escapeFormulae:n.escapeFormulae,decimalSeparator:n.decimalSeparator,transform:n.typeTransform}));let s=n.bom?``:``;return s+=a.join(n.lineEnding),a.length>0&&n.trailingNewline&&(s+=n.lineEnding),s}var nv=class extends dm{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=W_(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=pg(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&&=dg(this.displayHeaders)}detectHeadersFromRow(e){let t=ug(e);t.length>0&&(this.keys=t,this.displayHeaders=dg(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=lg(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=Q_(e,n.regex,r);return t||!(n.writeHeaders&&this.displayHeaders)&&this.outputRowIndex===0?i:n.lineEnding+i}};function rv(e={}){return new nv(e)}let iv=[`YYYY-MM-DD[T]HH:mm:ssZ`,`YYYY-MM-DD[T]HH:mm:ss`,`MM-DD-YYYY`,`YYYY-MM-DD`],av={true:!0,false:!1,"#N/A":{error:`#N/A`},"#REF!":{error:`#REF!`},"#NAME?":{error:`#NAME?`},"#DIV/0!":{error:`#DIV/0!`},"#NULL!":{error:`#NULL!`},"#VALUE!":{error:`#VALUE!`},"#NUM!":{error:`#NUM!`}};function ov(e,t){let n=$h.create(e),r=t?.decimalSeparator??`.`;return function(e){if(e===``)return null;if(typeof e==`string`){let t=q_(e,r);if(!Number.isNaN(t)&&t!==1/0)return t}else{let t=Number(e);if(!Number.isNaN(t)&&t!==1/0)return t}let t=n.parse(e);if(t)return t;let i=av[e];return i===void 0?e:i}}function sv(e,t){let n=e?tg.create(e,{utc:t}):tg.iso(t);return function(e){if(e){if(e.text||e.hyperlink)return e.hyperlink||e.text||``;if(e.formula||e.result)return e.result||``;if(e.richText&&Array.isArray(e.richText))return e.richText.map(e=>e.text).join(``);if(e instanceof Date)return n.format(e);if(e.error)return e.error;if(typeof e==`object`)return JSON.stringify(e)}return e}}function cv(e){return typeof e==`string`&&/^https?:\/\//i.test(e)}function lv(e){return typeof File<`u`&&e instanceof File}function uv(e){return typeof Blob<`u`&&e instanceof Blob&&!lv(e)}function dv(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t[Symbol.asyncIterator]==`function`||typeof t.pipe==`function`&&typeof t.on==`function`}function fv(e){return{delimiter:e?.delimiter??`,`,quote:e?.quote,escape:e?.escape,delimitersToGuess:e?.delimitersToGuess,lineEnding:e?.lineEnding,headers:e?.headers,skipEmptyLines:e?.skipEmptyLines,trim:e?.trim,ltrim:e?.ltrim,rtrim:e?.rtrim,comment:e?.comment,maxRows:e?.maxRows,toLine:e?.toLine,skipLines:e?.skipLines,skipRows:e?.skipRows,columnMismatch:e?.columnMismatch,groupColumnsByName:e?.groupColumnsByName,relaxQuotes:e?.relaxQuotes,fastMode:e?.fastMode,info:e?.info,raw:e?.raw,skipRecordsWithError:e?.skipRecordsWithError,skipRecordsWithEmptyValues:e?.skipRecordsWithEmptyValues,onSkip:e?.onSkip}}function pv(e){return{delimiter:e?.delimiter??`,`,quote:e?.quote,escape:e?.escape,lineEnding:e?.lineEnding,quoteColumns:e?.quoteColumns,quoteHeaders:e?.quoteHeaders,decimalSeparator:e?.decimalSeparator??`.`,escapeFormulae:e?.escapeFormulae??!0,writeHeaders:e?.writeHeaders}}var mv=class{static{this.Writer=Rm}static{this.Reader=Fh}constructor(){this.category=``,this.company=``,this.created=new Date,this.description=``,this.keywords=``,this.manager=``,this.modified=this.created,this.properties={},this.calcProperties={},this._worksheets=[],this.subject=``,this.title=``,this.views=[],this.media=[],this.pivotTables=[],this._passthrough={},this._rawDrawings={},this._definedNames=new ni}importSheet(e,t){let n=this.addWorksheet(t??e.name);return n.model={...e.model,id:n.id,name:n.name},n}get xlsx(){return this._xlsx||=new km(this),this._xlsx}async readCsv(e,t){return cv(e)?this._readCsvUrl(e,t):lv(e)?this._readCsvFile(e,t):uv(e)?this._readCsvBlob(e,t):dv(e)?this._readCsvStream(e,t):this._readCsvContent(e,t)}writeCsv(e,t){return e&&typeof e.write==`function`?this._writeCsvStream(e,t):this._writeCsvString(e)}async writeCsvBuffer(e){let t=this._writeCsvString(e);return new TextEncoder().encode(t)}async readCsvFile(e,t){throw new v(`readCsvFile()`,`not available in browser. Use readCsv(url) or readCsv(file) instead.`)}async writeCsvFile(e,t){throw new v(`writeCsvFile()`,`not available in browser. Use writeCsv() and trigger a download instead.`)}createCsvReadStream(e){let t=this.getWorksheet(e?.sheetName||e?.sheetId),n=e?.map||sv(e?.dateFormat,e?.dateUTC),r=e?.includeEmptyRows!==!1,i=new nv(pv(e));return setTimeout(t?()=>{let e=1;t.eachRow((t,a)=>{if(r)for(;e++<a-1;)i.write([]);let{values:o}=t;o.shift(),i.write(o.map(n)),e=a}),i.end()}:()=>i.end(),0),i}createCsvWriteStream(e){let t=this.addWorksheet(e?.sheetName),n=e?.dateFormats??iv,r=e?.decimalSeparator,i=e?.map||ov(n,{decimalSeparator:r}),a=new z_(fv(e)),o=!!e?.headers,s=null;return o&&a.on(`headers`,e=>{s=e,t.addRow(e)}),a.on(`data`,e=>{if(o&&s&&e&&typeof e==`object`&&!Array.isArray(e)){let n=e,r=s.map(e=>n[e]);t.addRow(r.map(i))}else Array.isArray(e)&&t.addRow(e.map(i))}),a}_readCsvContent(e,t){let n;n=typeof e==`string`?e:e instanceof ArrayBuffer||e instanceof Uint8Array?new TextDecoder().decode(e):String(e);let r=this.addWorksheet(t?.sheetName),i=t?.dateFormats??iv,a=t?.decimalSeparator,o=t?.map||ov(i,{decimalSeparator:a}),s=P_(n,fv(t));if(Array.isArray(s))for(let e of s)r.addRow(e.map(o));else{s.headers&&r.addRow(s.headers);for(let e of s.rows){let t=s.headers.map(t=>e[t]);r.addRow(t.map(o))}}return r}async _readCsvStream(e,t){let n=this.addWorksheet(t?.sheetName),r=t?.dateFormats??iv,i=t?.decimalSeparator,a=t?.map||ov(r,{decimalSeparator:i}),o=new z_(fv(t)),s=!!t?.headers,c=null;return new Promise((t,r)=>{s&&o.on(`headers`,e=>{c=e,n.addRow(e)}),o.on(`data`,e=>{if(s&&c&&e&&typeof e==`object`&&!Array.isArray(e)){let t=e,r=c.map(e=>t[e]);n.addRow(r.map(a))}else Array.isArray(e)&&n.addRow(e.map(a))}),Sm(e,o).then(()=>t(n)).catch(r)})}async _readCsvUrl(e,t){let n={method:t?.requestBody?`POST`:`GET`,headers:t?.requestHeaders,body:t?.requestBody,credentials:t?.withCredentials?`include`:`same-origin`,signal:t?.signal},r=await fetch(e,n);if(!r.ok)throw new x(e,r.status,r.statusText);if(t?.stream&&r.body){let e=wm(r.body);return this._readCsvStream(e,t)}let i=await r.text();return this._readCsvContent(i,t)}async _readCsvFile(e,t){if((t?.stream||e.size>10*1024*1024)&&typeof e.stream==`function`){let n=wm(e.stream());return this._readCsvStream(n,t)}return new Promise((n,r)=>{let i=new FileReader,a=t?.encoding??`UTF-8`;t?.onProgress&&(i.onprogress=n=>{t.onProgress(n.loaded,n.total||e.size)}),i.onload=e=>{try{let r=e.target?.result;n(this._readCsvContent(r,t))}catch(e){r(e)}},i.onerror=()=>r(Error(`Failed to read file: ${e.name}`)),i.readAsText(e,a)})}async _readCsvBlob(e,t){let n=await e.text();return this._readCsvContent(n,t)}_writeCsvString(e){let t=this.getWorksheet(e?.sheetName||e?.sheetId);if(!t)return``;let n=e?.map||sv(e?.dateFormat,e?.dateUTC),r=e?.includeEmptyRows!==!1,i=[],a=1;return t.eachRow((e,t)=>{if(r)for(;a++<t-1;)i.push([]);let{values:o}=e;o.shift(),i.push(o.map(n)),a=t}),tv(i,pv(e))}async _writeCsvStream(e,t){let n=this.getWorksheet(t?.sheetName||t?.sheetId);if(!n){e.end();return}let r=t?.map||sv(t?.dateFormat,t?.dateUTC),i=t?.includeEmptyRows!==!1,a=new nv(pv(t)),o=Sm(a,e),s=1;n.eachRow((e,t)=>{if(i)for(;s++<t-1;)a.write([]);let{values:n}=e;n.shift(),a.write(n.map(r)),s=t}),a.end(),await o}static createStreamWriter(e){return new Rm(e)}static createStreamReader(e,t){return new Fh(e,t)}get nextId(){for(let e=1;e<this._worksheets.length;e++)if(!this._worksheets[e])return e;return this._worksheets.length||1}addWorksheet(e,t){let n=this.nextId,r=this._worksheets.reduce((e,t)=>(t&&t.orderNo)>e?t.orderNo:e,0),i=new Zr({...t,id:n,name:e,orderNo:r+1,workbook:this});return this._worksheets[n]=i,i}removeWorksheetEx(e){delete this._worksheets[e.id]}removeWorksheet(e){let t=this.getWorksheet(e);t&&t.destroy()}getWorksheet(e){if(e===void 0)return this._worksheets.find(Boolean);if(typeof e==`number`)return this._worksheets[e];if(typeof e==`string`){let t=e.toLowerCase();return this._worksheets.find(e=>e&&e.name.toLowerCase()===t)}}get worksheets(){return this._worksheets.slice(1).sort((e,t)=>e.orderNo-t.orderNo).filter(Boolean)}eachSheet(e){this.worksheets.forEach(t=>{e(t,t.id)})}get definedNames(){return this._definedNames}clearThemes(){this._themes=void 0}addImage(e){let t=this.media.length;return this.media.push({...e,type:`image`}),t}getImage(e){return this.media[Number(e)]}get model(){return{creator:this.creator||`Unknown`,lastModifiedBy:this.lastModifiedBy||`Unknown`,lastPrinted:this.lastPrinted,created:this.created,modified:this.modified,properties:this.properties,worksheets:this.worksheets.map(e=>e.model),sheets:this.worksheets.map(e=>e.model).filter(Boolean),definedNames:this._definedNames.model,views:this.views,company:this.company,manager:this.manager,title:this.title,subject:this.subject,keywords:this.keywords,category:this.category,description:this.description,language:this.language,revision:this.revision,contentStatus:this.contentStatus,themes:this._themes,media:this.media,pivotTables:this.pivotTables,calcProperties:this.calcProperties,passthrough:this._passthrough,rawDrawings:this._rawDrawings,defaultFont:this._defaultFont}}set model(e){this.creator=e.creator,this.lastModifiedBy=e.lastModifiedBy,this.lastPrinted=e.lastPrinted,this.created=e.created,this.modified=e.modified,this.company=e.company,this.manager=e.manager,this.title=e.title,this.subject=e.subject,this.keywords=e.keywords,this.category=e.category,this.description=e.description,this.language=e.language,this.revision=e.revision,this.contentStatus=e.contentStatus,this.properties=e.properties,this.calcProperties=e.calcProperties,this._worksheets=[],e.worksheets.forEach(t=>{let{id:n,name:r,state:i}=t,a=e.sheets&&e.sheets.findIndex(e=>e.id===n),o=this._worksheets[n]=new Zr({id:n,name:r,orderNo:a===-1?void 0:a,state:i,workbook:this});o.model=t}),this._definedNames.model=e.definedNames,this.views=e.views,this._themes=e.themes,this.media=e.media||[],this.pivotTables=e.pivotTables||e.loadedPivotTables||[],this._passthrough=e.passthrough||{},this._rawDrawings=e.rawDrawings||{},this._defaultFont=e.defaultFont}};let hv=function(e){return e[e.Legal=5]=`Legal`,e[e.Executive=7]=`Executive`,e[e.A4=9]=`A4`,e[e.A5=11]=`A5`,e[e.B5=13]=`B5`,e[e.Envelope_10=20]=`Envelope_10`,e[e.Envelope_DL=27]=`Envelope_DL`,e[e.Envelope_C5=28]=`Envelope_C5`,e[e.Envelope_B5=34]=`Envelope_B5`,e[e.Envelope_Monarch=37]=`Envelope_Monarch`,e[e.Double_Japan_Postcard_Rotated=82]=`Double_Japan_Postcard_Rotated`,e[e.K16_197x273_mm=119]=`K16_197x273_mm`,e}({}),X={Empty:0,String:1,Number:2,Boolean:3,Date:4,RichText:5,Error:6,Formula:7,Hyperlink:8,Merge:9},gv={A3:{width:841.89,height:1190.55},A4:{width:595.28,height:841.89},A5:{width:419.53,height:595.28},LETTER:{width:612,height:792},LEGAL:{width:612,height:1008},TABLOID:{width:792,height:1224}};function _v(e){return Sv(e)?`(${e.replace(/\\/g,`\\\\`).replace(/\(/g,`\\(`).replace(/\)/g,`\\)`).replace(/\r\n/g,`\\n`).replace(/\r/g,`\\n`).replace(/\n/g,`\\n`)})`:vv(Cv(e))}function vv(e){let t=`<`;for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,`0`);return t+`>`}function yv(e){let t=`/`;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<33||r>126||r===35||r===40||r===41||r===60||r===62||r===91||r===93||r===123||r===125||r===47?t+=`#`+r.toString(16).padStart(2,`0`):t+=e[n]}return t}function Z(e){return Number.isFinite(e)?Number.isInteger(e)?e.toString():(Math.round(e*1e4)/1e4).toString():`0`}function bv(e){return`[`+e.join(` `)+`]`}function Q(e,t=0){return`${e} ${t} R`}function xv(e){return`(D:${e.getUTCFullYear().toString().padStart(4,`0`)}${(e.getUTCMonth()+1).toString().padStart(2,`0`)}${e.getUTCDate().toString().padStart(2,`0`)}${e.getUTCHours().toString().padStart(2,`0`)}${e.getUTCMinutes().toString().padStart(2,`0`)}${e.getUTCSeconds().toString().padStart(2,`0`)}Z)`}function Sv(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function Cv(e){let t=new Uint8Array(2+e.length*2);t[0]=254,t[1]=255;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[2+n*2]=r>>8&255,t[3+n*2]=r&255}return t}var $=class{constructor(){this.entries=[]}set(e,t){let n=this.entries.findIndex(([t])=>t===e);return n>=0?this.entries[n]=[e,t]:this.entries.push([e,t]),this}setIf(e,t,n){return e&&this.set(t,n),this}toString(){let e=[`<<`];for(let[t,n]of this.entries)e.push(`${yv(t)} ${n}`);return e.push(`>>`),e.join(`
427
- `)}},wv=class extends t{constructor(e,t){super(e,t),this.name=`PdfError`}},Tv=class extends wv{constructor(...e){super(...e),this.name=`PdfRenderError`}},Ev=class extends wv{constructor(...e){super(...e),this.name=`PdfFontError`}},Dv=class extends wv{constructor(...e){super(...e),this.name=`PdfStructureError`}};function Ov(e){return e instanceof wv}let kv=new Uint8Array([40,191,78,94,78,117,138,65,100,0,78,86,255,250,1,8,46,46,0,182,208,104,62,128,47,12,169,254,100,83,105,122]);function Av(e){let t=e.userPassword??``,n=e.ownerPassword,r=Vv(e.permissions),i=Hv(),a=Rv(n,t),o=zv(t,a,r,i);return{encryptionKey:o,oValue:a,uValue:Bv(o,i),permissions:r,fileId:i}}function jv(e,t,n,r){let i=new Uint8Array(r.length+5);i.set(r),i[r.length]=t&255,i[r.length+1]=t>>8&255,i[r.length+2]=t>>16&255,i[r.length+3]=n&255,i[r.length+4]=n>>8&255;let a=Nv(i),o=Math.min(r.length+5,16);return Mv(a.subarray(0,o),e)}function Mv(e,t){let n=new Uint8Array(256);for(let e=0;e<256;e++)n[e]=e;let r=0;for(let t=0;t<256;t++)r=r+n[t]+e[t%e.length]&255,[n[t],n[r]]=[n[r],n[t]];let i=new Uint8Array(t.length),a=0,o=0;for(let e=0;e<t.length;e++)a=a+1&255,o=o+n[a]&255,[n[a],n[o]]=[n[o],n[a]],i[e]=t[e]^n[n[a]+n[o]&255];return i}function Nv(e){let t=e.length,n=t*8,r=(56-(t+1)%64+64)%64+1,i=new Uint8Array(t+r+8);i.set(e),i[t]=128;let a=new DataView(i.buffer);a.setUint32(i.length-8,n>>>0,!0),a.setUint32(i.length-4,0,!0);let o=1732584193,s=4023233417,c=2562383102,l=271733878;for(let e=0;e<i.length;e+=64){let t=new Uint32Array(16);for(let n=0;n<16;n++)t[n]=a.getUint32(e+n*4,!0);let n=o,r=s,i=c,u=l;for(let e=0;e<64;e++){let a,o;e<16?(a=r&i|~r&u,o=e):e<32?(a=u&r|~u&i,o=(5*e+1)%16):e<48?(a=r^i^u,o=(3*e+5)%16):(a=i^(r|~u),o=7*e%16),a=a+n+Iv[e]+t[o]>>>0,n=u,u=i,i=r,r=r+Pv(a,Fv[e])>>>0}o=o+n>>>0,s=s+r>>>0,c=c+i>>>0,l=l+u>>>0}let u=new Uint8Array(16),d=new DataView(u.buffer);return d.setUint32(0,o,!0),d.setUint32(4,s,!0),d.setUint32(8,c,!0),d.setUint32(12,l,!0),u}function Pv(e,t){return(e<<t|e>>>32-t)>>>0}let Fv=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],Iv=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]);function Lv(e){let t=new Uint8Array(32),n=new TextEncoder().encode(e),r=Math.min(n.length,32);return t.set(n.subarray(0,r)),t.set(kv.subarray(0,32-r),r),t}function Rv(e,t){let n=Nv(Lv(e));for(let e=0;e<50;e++)n=Nv(n);let r=n.subarray(0,16),i=Mv(r,Lv(t));for(let e=1;e<=19;e++){let t=new Uint8Array(16);for(let n=0;n<16;n++)t[n]=r[n]^e;i=Mv(t,i)}return i}function zv(e,t,n,r){let i=Lv(e),a=new Uint8Array(68+r.length);a.set(i),a.set(t,32),new DataView(a.buffer,a.byteOffset).setInt32(64,n,!0),a.set(r,68);let o=Nv(a);for(let e=0;e<50;e++)o=Nv(o.subarray(0,16));return o.subarray(0,16)}function Bv(e,t){let n=new Uint8Array(32+t.length);n.set(kv),n.set(t,32);let r=Mv(e,Nv(n));for(let t=1;t<=19;t++){let n=new Uint8Array(16);for(let r=0;r<16;r++)n[r]=e[r]^t;r=Mv(n,r)}let i=new Uint8Array(32);return i.set(r),i}function Vv(e){let t=-3904;return e?.print&&(t|=4),e?.modify&&(t|=8),e?.copy&&(t|=16),e?.annotate&&(t|=32),e?.fillForms&&(t|=256),e?.accessibility&&(t|=512),e?.assemble&&(t|=1024),e?.printHighQuality&&(t|=2048),t|0}function Hv(){let e=new Uint8Array(16),t=Date.now(),n=new DataView(e.buffer);return n.setFloat64(0,t,!0),n.setFloat64(8,Math.random()*0x38d7ea4c68000,!0),Nv(e)}var Uv=class{constructor(){this.nextObjectNumber=1,this.objects=[],this.catalogRef=0,this.infoRef=0,this.encryption=null}setEncryption(e){this.encryption=e}allocObject(){return this.nextObjectNumber++}addObject(e,t){this.objects.push({objectNumber:e,offset:0,content:typeof t==`string`?t:t.toString()})}addStreamObject(e,t,n){let r=n instanceof Uint8Array?n:n.toUint8Array();if(r.length>256&&!t.toString().includes(`/Filter`)){let e=sd(r,{level:6});e.length<r.length&&(t.set(`Filter`,`/FlateDecode`),r=e)}t.set(`Length`,Z(r.length)),this.objects.push({objectNumber:e,offset:0,content:t.toString(),streamData:r})}setCatalog(e){this.catalogRef=e}addInfoDict(e){let t=this.allocObject(),n=new $;return e.title&&n.set(`Title`,_v(e.title)),e.author&&n.set(`Author`,_v(e.author)),e.subject&&n.set(`Subject`,_v(e.subject)),e.creator&&n.set(`Creator`,_v(e.creator)),n.set(`Producer`,_v(`excelts`)),n.set(`CreationDate`,xv(new Date)),this.addObject(t,n),this.infoRef=t,t}addPage(e){let t=this.allocObject(),n=`[0 0 ${Z(e.width)} ${Z(e.height)}]`,r=new $().set(`Type`,`/Page`).set(`Parent`,Q(e.parentRef)).set(`MediaBox`,n).set(`Contents`,Q(e.contentsRef)).set(`Resources`,Q(e.resourcesRef));return e.annotRefs&&e.annotRefs.length>0&&r.set(`Annots`,`[`+e.annotRefs.map(e=>Q(e)).join(` `)+`]`),this.addObject(t,r),t}addCatalog(e,t){let n=this.allocObject(),r=new $().set(`Type`,`/Catalog`).set(`Pages`,Q(e));return t&&(r.set(`Outlines`,Q(t)),r.set(`PageMode`,`/UseOutlines`)),this.addObject(n,r),this.setCatalog(n),n}build(){if(this.catalogRef===0)throw new Dv(`No catalog object set. Call addCatalog() before build().`);let e=new TextEncoder,t=[],n=0,r=e.encode(`%PDF-1.4
428
- `);t.push(r),n+=r.length;let i=new Uint8Array([37,226,227,207,211,10]);t.push(i),n+=i.length,this.objects.sort((e,t)=>e.objectNumber-t.objectNumber);let a=this.encryption?this.allocObject():0;for(let r of this.objects){r.offset=n;let i=`${r.objectNumber} 0 obj\n`,o=e.encode(i);t.push(o),n+=o.length;let s=r.content;this.encryption&&r.objectNumber!==a&&(s=Wv(s,r.objectNumber,0,this.encryption.encryptionKey));let c=null;`streamData`in r&&r.streamData&&(c=r.streamData,this.encryption&&r.objectNumber!==a&&(c=jv(c,r.objectNumber,0,this.encryption.encryptionKey),s=s.replace(/\/Length \d+/,`/Length ${c.length}`)));let l=e.encode(s+`
423
+ `&&n++,n===i)break}if(t){let e=this.options.skipEmptyLines;this.parseConfig.delimiter=Fg(this.buffer,this.parseConfig.quote||`"`,this.options.delimitersToGuess,this.options.comment,e),this.delimiterDetected=!0,this.emit(`delimiter`,this.parseConfig.delimiter),this.scanner=T_(qg(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?Qg(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===zg){let t=e.lastIndexOf(`
424
+ `),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 O_(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?Qg(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=wg(e,this.parseState.headerRow,this.parseState.originalHeaders,i);a=n||r?l_(t,n||!1,r):t}else a=n||r?u_(e,this.parseState.headerRow?Eg(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&&Wg(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=g_(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`,Eg(this.parseState.headerRow)))}shouldSkipRow(e,t){return h_(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 H_(e={}){return new V_(e)}function U_(e){return e.replace(/[\\\]^-]/g,`\\$&`)}function W_(e){let{quote:t,delimiter:n,escape:r}=e,{enabled:i,char:a}=Og(t),o=kg(r,a);if(!i)return{needsQuoteRegex:null,escapeQuoteRegex:null,escapedQuote:``,quoteEnabled:!1,quote:``,escape:``,delimiter:n,useFastCheck:!1};let s=o.char||a,c=n.length===1&&a.length===1&&s.length===1;return{needsQuoteRegex:c?null:(()=>{let e=`${U_(n)}${U_(a)}${s===a?``:U_(s)}\r\n`;return RegExp(`[${e}]`)})(),escapeQuoteRegex:s===a?new RegExp(Dg(a),`g`):RegExp(`${Dg(a)}|${Dg(s)}`,`g`),escapedQuote:s+a,quoteEnabled:!0,quote:a,escape:s,delimiter:n,useFastCheck:c}}function G_(e){return e===!0?()=>!0:e===!1||e===void 0?()=>!1:Array.isArray(e)?t=>e[t]===!0:(t,n)=>n?e[n]===!0:!1}function K_(e){let{delimiter:t=`,`,lineEnding:n=`
425
+ `,quote:r=`"`,escape:i,quoteColumns:a=!1,quoteHeaders:o=!1,writeHeaders:s,bom:c=!1,trailingNewline:l=!1,escapeFormulae:u=!1,decimalSeparator:d=`.`,typeTransform:f}=e;if(d!==`.`&&d!==`,`)throw new yg(`Invalid decimalSeparator: "${d}". Must be "." or ",".`);if(d===t)throw new yg(`decimalSeparator cannot be the same as delimiter`);let p=W_({quote:r,delimiter:t,escape:i});return{delimiter:t,lineEnding:n,quoteAll:a===!0,escapeFormulae:u,decimalSeparator:d,writeHeaders:s??!0,bom:c,trailingNewline:l,typeTransform:f,regex:p,shouldQuoteColumn:G_(a),shouldQuoteHeader:G_(o)}}let q_=/^-?\d+(,\d+)?([eE][+-]?\d+)?$/;function J_(e,t){return t===`,`?String(e).replace(`.`,`,`):String(e)}function Y_(e,t){let n=e.trim();return t===`,`&&q_.test(n)?Number(n.replace(`,`,`.`)):Number(n)}function X_(e,t,n){if(e==null)return;let r=typeof e;if(r===`boolean`&&t.boolean)return t.boolean(e,n);if(e instanceof Date&&t.date)return t.date(e,n);if(r===`number`&&t.number)return t.number(e,n);if(r===`bigint`&&t.bigint)return t.bigint(e,n);if(r===`string`&&t.string)return t.string(e,n);if(r===`object`&&!Array.isArray(e)&&!(e instanceof Date)&&t.object)return t.object(e,n)}function Z_(e,t){if(e==null)return``;if(typeof e==`number`)return J_(e,t);if(e instanceof Date)return e.toISOString();if(typeof e==`bigint`)return String(e);if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return`[object Object]`}return String(e)}function Q_(e,t,n,r){return e.indexOf(t)!==-1||e.indexOf(n)!==-1||r!==n&&e.indexOf(r)!==-1||e.indexOf(`
426
+ `)!==-1||e.indexOf(`\r`)!==-1}function $_(e,t,n){let{index:r,header:i,isHeader:a,outputRowIndex:o,forceQuote:s,quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d}=n,f,p;if(!a&&d){let t=X_(e,d,{column:i??r,index:o});t==null?f=Z_(e,u):R_(t)?(f=t.value,p=t.quote):f=t}else f=Z_(e,u);if(l&&p!==!1&&typeof e!=`number`&&typeof e!=`bigint`&&Ng(f)&&(f=`'`+f),!t.quoteEnabled)return f;let m;if(m=p===void 0?c||s||(t.useFastCheck?Q_(f,t.delimiter,t.quote,t.escape):t.needsQuoteRegex.test(f)):p,m){let e;return e=t.escape===t.quote?f.replace(t.escapeQuoteRegex,t.escapedQuote):f.replace(t.escapeQuoteRegex,e=>e===t.quote?t.escape+t.quote:t.escape+t.escape),t.quote+e+t.quote}return f}function ev(e,t,n){let{quoteLookup:r,delimiter:i,headers:a,isHeader:o,outputRowIndex:s,quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d}=n,f=e.length;if(f===0)return``;let p={index:0,header:a?.[0],isHeader:o,outputRowIndex:s,forceQuote:r(0,a?.[0]),quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d},m=$_(e[0],t,p);for(let n=1;n<f;n++)p.index=n,p.header=a?.[n],p.forceQuote=r(n,p.header),m+=i+$_(e[n],t,p);return m}function tv(e,t,n){if(!e.typeTransform?.row)return t;let r=e.typeTransform.row(t,n);return r===null?null:r}function nv(e,t,n){let{headers:r,columns:i}=t;if(e.length===0)return i&&i.length>0?{keys:null,displayHeaders:i.map(e=>typeof e==`string`?e:e.header??e.key),rows:[]}:Array.isArray(r)?{keys:r,displayHeaders:r,rows:[]}:{keys:null,displayHeaders:null,rows:[]};let a=e[0];if(i&&i.length>0){let t=hg(i),r=t.keys,a=t.headers,o=[];for(let t=0;t<e.length;t++){let i=tv(n,e[t],t);if(i===null)continue;let a;a=ag(i)?ug(i,r):Array.isArray(i)?i:r.map(e=>i[e]),o.push(a)}return{keys:r,displayHeaders:a,rows:o}}if(ag(a)){let t=e,i=r===!0?cg(t[0]):Array.isArray(r)?r:null,a=[];for(let e=0;e<t.length;e++){let r=tv(n,t[e],e);if(r===null)continue;let o;o=ag(r)?i?ug(r,i):sg(r):Array.isArray(r)?r:i?i.map(e=>r[e]):Object.values(r),a.push(o)}return{keys:i,displayHeaders:i,rows:a}}if(!Array.isArray(a)&&typeof a==`object`){let t=e,i=r===!0?Object.keys(t[0]):Array.isArray(r)?r:null,a=[];for(let e=0;e<t.length;e++){let r=tv(n,t[e],e);if(r===null)continue;let o=i?i.map(e=>r[e]):Object.values(r);a.push(o)}return{keys:i,displayHeaders:i,rows:a}}let o=e,s=Array.isArray(r)?r:null,c=[];for(let e=0;e<o.length;e++){let t=tv(n,o[e],e);t!==null&&c.push(t)}return{keys:s,displayHeaders:s,rows:c}}function rv(e,t={}){let n=K_(t),{displayHeaders:r,rows:i}=nv(e,t,n),a=[],o=r?pg(r):void 0;o&&n.writeHeaders&&a.push(ev(o,n.regex,{quoteLookup:n.shouldQuoteHeader,delimiter:n.delimiter,headers:o,isHeader:!0,outputRowIndex:0,quoteAll:n.quoteAll,escapeFormulae:n.escapeFormulae,decimalSeparator:n.decimalSeparator,transform:void 0}));for(let e=0;e<i.length;e++)a.push(ev(i[e],n.regex,{quoteLookup:n.shouldQuoteColumn,delimiter:n.delimiter,headers:o,isHeader:!1,outputRowIndex:e,quoteAll:n.quoteAll,escapeFormulae:n.escapeFormulae,decimalSeparator:n.decimalSeparator,transform:n.typeTransform}));let s=n.bom?``:``;return s+=a.join(n.lineEnding),a.length>0&&n.trailingNewline&&(s+=n.lineEnding),s}var iv=class extends dm{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=K_(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=hg(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&&=pg(this.displayHeaders)}detectHeadersFromRow(e){let t=fg(e);t.length>0&&(this.keys=t,this.displayHeaders=pg(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=dg(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=ev(e,n.regex,r);return t||!(n.writeHeaders&&this.displayHeaders)&&this.outputRowIndex===0?i:n.lineEnding+i}};function av(e={}){return new iv(e)}let ov=[`YYYY-MM-DD[T]HH:mm:ssZ`,`YYYY-MM-DD[T]HH:mm:ss`,`MM-DD-YYYY`,`YYYY-MM-DD`],sv={true:!0,false:!1,"#N/A":{error:`#N/A`},"#REF!":{error:`#REF!`},"#NAME?":{error:`#NAME?`},"#DIV/0!":{error:`#DIV/0!`},"#NULL!":{error:`#NULL!`},"#VALUE!":{error:`#VALUE!`},"#NUM!":{error:`#NUM!`}};function cv(e,t){let n=tg.create(e),r=t?.decimalSeparator??`.`;return function(e){if(e===``)return null;if(typeof e==`string`){let t=Y_(e,r);if(!Number.isNaN(t)&&t!==1/0)return t}else{let t=Number(e);if(!Number.isNaN(t)&&t!==1/0)return t}let t=n.parse(e);if(t)return t;let i=sv[e];return i===void 0?e:i}}function lv(e,t){let n=e?rg.create(e,{utc:t}):rg.iso(t);return function(e){if(e){if(e.text||e.hyperlink)return e.hyperlink||e.text||``;if(e.formula||e.result)return e.result||``;if(e.richText&&Array.isArray(e.richText))return e.richText.map(e=>e.text).join(``);if(e instanceof Date)return n.format(e);if(e.error)return e.error;if(typeof e==`object`)return JSON.stringify(e)}return e}}function uv(e){return typeof e==`string`&&/^https?:\/\//i.test(e)}function dv(e){return typeof File<`u`&&e instanceof File}function fv(e){return typeof Blob<`u`&&e instanceof Blob&&!dv(e)}function pv(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t[Symbol.asyncIterator]==`function`||typeof t.pipe==`function`&&typeof t.on==`function`}function mv(e){return{delimiter:e?.delimiter??`,`,quote:e?.quote,escape:e?.escape,delimitersToGuess:e?.delimitersToGuess,lineEnding:e?.lineEnding,headers:e?.headers,skipEmptyLines:e?.skipEmptyLines,trim:e?.trim,ltrim:e?.ltrim,rtrim:e?.rtrim,comment:e?.comment,maxRows:e?.maxRows,toLine:e?.toLine,skipLines:e?.skipLines,skipRows:e?.skipRows,columnMismatch:e?.columnMismatch,groupColumnsByName:e?.groupColumnsByName,relaxQuotes:e?.relaxQuotes,fastMode:e?.fastMode,info:e?.info,raw:e?.raw,skipRecordsWithError:e?.skipRecordsWithError,skipRecordsWithEmptyValues:e?.skipRecordsWithEmptyValues,onSkip:e?.onSkip}}function hv(e){return{delimiter:e?.delimiter??`,`,quote:e?.quote,escape:e?.escape,lineEnding:e?.lineEnding,quoteColumns:e?.quoteColumns,quoteHeaders:e?.quoteHeaders,decimalSeparator:e?.decimalSeparator??`.`,escapeFormulae:e?.escapeFormulae??!0,writeHeaders:e?.writeHeaders}}var gv=class{static{this.Writer=Rm}static{this.Reader=Lh}constructor(){this.category=``,this.company=``,this.created=new Date,this.description=``,this.keywords=``,this.manager=``,this.modified=this.created,this.properties={},this.calcProperties={},this._worksheets=[],this.subject=``,this.title=``,this.views=[],this.media=[],this.pivotTables=[],this._passthrough={},this._rawDrawings={},this._definedNames=new ni}importSheet(e,t){let n=this.addWorksheet(t??e.name);return n.model={...e.model,id:n.id,name:n.name},n}get xlsx(){return this._xlsx||=new km(this),this._xlsx}async readCsv(e,t){return uv(e)?this._readCsvUrl(e,t):dv(e)?this._readCsvFile(e,t):fv(e)?this._readCsvBlob(e,t):pv(e)?this._readCsvStream(e,t):this._readCsvContent(e,t)}writeCsv(e,t){return e&&typeof e.write==`function`?this._writeCsvStream(e,t):this._writeCsvString(e)}async writeCsvBuffer(e){let t=this._writeCsvString(e);return new TextEncoder().encode(t)}async readCsvFile(e,t){throw new v(`readCsvFile()`,`not available in browser. Use readCsv(url) or readCsv(file) instead.`)}async writeCsvFile(e,t){throw new v(`writeCsvFile()`,`not available in browser. Use writeCsv() and trigger a download instead.`)}createCsvReadStream(e){let t=this.getWorksheet(e?.sheetName||e?.sheetId),n=e?.map||lv(e?.dateFormat,e?.dateUTC),r=e?.includeEmptyRows!==!1,i=new iv(hv(e));return setTimeout(t?()=>{let e=1;t.eachRow((t,a)=>{if(r)for(;e++<a-1;)i.write([]);let{values:o}=t;o.shift(),i.write(o.map(n)),e=a}),i.end()}:()=>i.end(),0),i}createCsvWriteStream(e){let t=this.addWorksheet(e?.sheetName),n=e?.dateFormats??ov,r=e?.decimalSeparator,i=e?.map||cv(n,{decimalSeparator:r}),a=new V_(mv(e)),o=!!e?.headers,s=null;return o&&a.on(`headers`,e=>{s=e,t.addRow(e)}),a.on(`data`,e=>{if(o&&s&&e&&typeof e==`object`&&!Array.isArray(e)){let n=e,r=s.map(e=>n[e]);t.addRow(r.map(i))}else Array.isArray(e)&&t.addRow(e.map(i))}),a}_readCsvContent(e,t){let n;n=typeof e==`string`?e:e instanceof ArrayBuffer||e instanceof Uint8Array?new TextDecoder().decode(e):String(e);let r=this.addWorksheet(t?.sheetName),i=t?.dateFormats??ov,a=t?.decimalSeparator,o=t?.map||cv(i,{decimalSeparator:a}),s=I_(n,mv(t));if(Array.isArray(s))for(let e of s)r.addRow(e.map(o));else{s.headers&&r.addRow(s.headers);for(let e of s.rows){let t=s.headers.map(t=>e[t]);r.addRow(t.map(o))}}return r}async _readCsvStream(e,t){let n=this.addWorksheet(t?.sheetName),r=t?.dateFormats??ov,i=t?.decimalSeparator,a=t?.map||cv(r,{decimalSeparator:i}),o=new V_(mv(t)),s=!!t?.headers,c=null;return new Promise((t,r)=>{s&&o.on(`headers`,e=>{c=e,n.addRow(e)}),o.on(`data`,e=>{if(s&&c&&e&&typeof e==`object`&&!Array.isArray(e)){let t=e,r=c.map(e=>t[e]);n.addRow(r.map(a))}else Array.isArray(e)&&n.addRow(e.map(a))}),Sm(e,o).then(()=>t(n)).catch(r)})}async _readCsvUrl(e,t){let n={method:t?.requestBody?`POST`:`GET`,headers:t?.requestHeaders,body:t?.requestBody,credentials:t?.withCredentials?`include`:`same-origin`,signal:t?.signal},r=await fetch(e,n);if(!r.ok)throw new x(e,r.status,r.statusText);if(t?.stream&&r.body){let e=wm(r.body);return this._readCsvStream(e,t)}let i=await r.text();return this._readCsvContent(i,t)}async _readCsvFile(e,t){if((t?.stream||e.size>10*1024*1024)&&typeof e.stream==`function`){let n=wm(e.stream());return this._readCsvStream(n,t)}return new Promise((n,r)=>{let i=new FileReader,a=t?.encoding??`UTF-8`;t?.onProgress&&(i.onprogress=n=>{t.onProgress(n.loaded,n.total||e.size)}),i.onload=e=>{try{let r=e.target?.result;n(this._readCsvContent(r,t))}catch(e){r(e)}},i.onerror=()=>r(Error(`Failed to read file: ${e.name}`)),i.readAsText(e,a)})}async _readCsvBlob(e,t){let n=await e.text();return this._readCsvContent(n,t)}_writeCsvString(e){let t=this.getWorksheet(e?.sheetName||e?.sheetId);if(!t)return``;let n=e?.map||lv(e?.dateFormat,e?.dateUTC),r=e?.includeEmptyRows!==!1,i=[],a=1;return t.eachRow((e,t)=>{if(r)for(;a++<t-1;)i.push([]);let{values:o}=e;o.shift(),i.push(o.map(n)),a=t}),rv(i,hv(e))}async _writeCsvStream(e,t){let n=this.getWorksheet(t?.sheetName||t?.sheetId);if(!n){e.end();return}let r=t?.map||lv(t?.dateFormat,t?.dateUTC),i=t?.includeEmptyRows!==!1,a=new iv(hv(t)),o=Sm(a,e),s=1;n.eachRow((e,t)=>{if(i)for(;s++<t-1;)a.write([]);let{values:n}=e;n.shift(),a.write(n.map(r)),s=t}),a.end(),await o}static createStreamWriter(e){return new Rm(e)}static createStreamReader(e,t){return new Lh(e,t)}get nextId(){for(let e=1;e<this._worksheets.length;e++)if(!this._worksheets[e])return e;return this._worksheets.length||1}addWorksheet(e,t){let n=this.nextId,r=this._worksheets.reduce((e,t)=>(t&&t.orderNo)>e?t.orderNo:e,0),i=new Zr({...t,id:n,name:e,orderNo:r+1,workbook:this});return this._worksheets[n]=i,i}removeWorksheetEx(e){delete this._worksheets[e.id]}removeWorksheet(e){let t=this.getWorksheet(e);t&&t.destroy()}getWorksheet(e){if(e===void 0)return this._worksheets.find(Boolean);if(typeof e==`number`)return this._worksheets[e];if(typeof e==`string`){let t=e.toLowerCase();return this._worksheets.find(e=>e&&e.name.toLowerCase()===t)}}get worksheets(){return this._worksheets.slice(1).sort((e,t)=>e.orderNo-t.orderNo).filter(Boolean)}eachSheet(e){this.worksheets.forEach(t=>{e(t,t.id)})}get definedNames(){return this._definedNames}clearThemes(){this._themes=void 0}addImage(e){let t=this.media.length;return this.media.push({...e,type:`image`}),t}getImage(e){return this.media[Number(e)]}get model(){return{creator:this.creator||`Unknown`,lastModifiedBy:this.lastModifiedBy||`Unknown`,lastPrinted:this.lastPrinted,created:this.created,modified:this.modified,properties:this.properties,worksheets:this.worksheets.map(e=>e.model),sheets:this.worksheets.map(e=>e.model).filter(Boolean),definedNames:this._definedNames.model,views:this.views,company:this.company,manager:this.manager,title:this.title,subject:this.subject,keywords:this.keywords,category:this.category,description:this.description,language:this.language,revision:this.revision,contentStatus:this.contentStatus,themes:this._themes,media:this.media,pivotTables:this.pivotTables,calcProperties:this.calcProperties,passthrough:this._passthrough,rawDrawings:this._rawDrawings,defaultFont:this._defaultFont}}set model(e){this.creator=e.creator,this.lastModifiedBy=e.lastModifiedBy,this.lastPrinted=e.lastPrinted,this.created=e.created,this.modified=e.modified,this.company=e.company,this.manager=e.manager,this.title=e.title,this.subject=e.subject,this.keywords=e.keywords,this.category=e.category,this.description=e.description,this.language=e.language,this.revision=e.revision,this.contentStatus=e.contentStatus,this.properties=e.properties,this.calcProperties=e.calcProperties,this._worksheets=[],e.worksheets.forEach(t=>{let{id:n,name:r,state:i}=t,a=e.sheets&&e.sheets.findIndex(e=>e.id===n),o=this._worksheets[n]=new Zr({id:n,name:r,orderNo:a===-1?void 0:a,state:i,workbook:this});o.model=t}),this._definedNames.model=e.definedNames,this.views=e.views,this._themes=e.themes,this.media=e.media||[],this.pivotTables=e.pivotTables||e.loadedPivotTables||[],this._passthrough=e.passthrough||{},this._rawDrawings=e.rawDrawings||{},this._defaultFont=e.defaultFont}};let _v=function(e){return e[e.Legal=5]=`Legal`,e[e.Executive=7]=`Executive`,e[e.A4=9]=`A4`,e[e.A5=11]=`A5`,e[e.B5=13]=`B5`,e[e.Envelope_10=20]=`Envelope_10`,e[e.Envelope_DL=27]=`Envelope_DL`,e[e.Envelope_C5=28]=`Envelope_C5`,e[e.Envelope_B5=34]=`Envelope_B5`,e[e.Envelope_Monarch=37]=`Envelope_Monarch`,e[e.Double_Japan_Postcard_Rotated=82]=`Double_Japan_Postcard_Rotated`,e[e.K16_197x273_mm=119]=`K16_197x273_mm`,e}({}),X={Empty:0,String:1,Number:2,Boolean:3,Date:4,RichText:5,Error:6,Formula:7,Hyperlink:8,Merge:9},vv={A3:{width:841.89,height:1190.55},A4:{width:595.28,height:841.89},A5:{width:419.53,height:595.28},LETTER:{width:612,height:792},LEGAL:{width:612,height:1008},TABLOID:{width:792,height:1224}};function yv(e){return wv(e)?`(${e.replace(/\\/g,`\\\\`).replace(/\(/g,`\\(`).replace(/\)/g,`\\)`).replace(/\r\n/g,`\\n`).replace(/\r/g,`\\n`).replace(/\n/g,`\\n`)})`:bv(Tv(e))}function bv(e){let t=`<`;for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,`0`);return t+`>`}function xv(e){let t=`/`;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<33||r>126||r===35||r===40||r===41||r===60||r===62||r===91||r===93||r===123||r===125||r===47?t+=`#`+r.toString(16).padStart(2,`0`):t+=e[n]}return t}function Z(e){return Number.isFinite(e)?Number.isInteger(e)?e.toString():(Math.round(e*1e4)/1e4).toString():`0`}function Sv(e){return`[`+e.join(` `)+`]`}function Q(e,t=0){return`${e} ${t} R`}function Cv(e){return`(D:${e.getUTCFullYear().toString().padStart(4,`0`)}${(e.getUTCMonth()+1).toString().padStart(2,`0`)}${e.getUTCDate().toString().padStart(2,`0`)}${e.getUTCHours().toString().padStart(2,`0`)}${e.getUTCMinutes().toString().padStart(2,`0`)}${e.getUTCSeconds().toString().padStart(2,`0`)}Z)`}function wv(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function Tv(e){let t=new Uint8Array(2+e.length*2);t[0]=254,t[1]=255;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[2+n*2]=r>>8&255,t[3+n*2]=r&255}return t}var $=class{constructor(){this.entries=[]}set(e,t){let n=this.entries.findIndex(([t])=>t===e);return n>=0?this.entries[n]=[e,t]:this.entries.push([e,t]),this}setIf(e,t,n){return e&&this.set(t,n),this}toString(){let e=[`<<`];for(let[t,n]of this.entries)e.push(`${xv(t)} ${n}`);return e.push(`>>`),e.join(`
427
+ `)}},Ev=class extends t{constructor(e,t){super(e,t),this.name=`PdfError`}},Dv=class extends Ev{constructor(...e){super(...e),this.name=`PdfRenderError`}},Ov=class extends Ev{constructor(...e){super(...e),this.name=`PdfFontError`}},kv=class extends Ev{constructor(...e){super(...e),this.name=`PdfStructureError`}};function Av(e){return e instanceof Ev}let jv=new Uint8Array([40,191,78,94,78,117,138,65,100,0,78,86,255,250,1,8,46,46,0,182,208,104,62,128,47,12,169,254,100,83,105,122]);function Mv(e){let t=e.userPassword??``,n=e.ownerPassword,r=Uv(e.permissions),i=Wv(),a=Bv(n,t),o=Vv(t,a,r,i);return{encryptionKey:o,oValue:a,uValue:Hv(o,i),permissions:r,fileId:i}}function Nv(e,t,n,r){let i=new Uint8Array(r.length+5);i.set(r),i[r.length]=t&255,i[r.length+1]=t>>8&255,i[r.length+2]=t>>16&255,i[r.length+3]=n&255,i[r.length+4]=n>>8&255;let a=Fv(i),o=Math.min(r.length+5,16);return Pv(a.subarray(0,o),e)}function Pv(e,t){let n=new Uint8Array(256);for(let e=0;e<256;e++)n[e]=e;let r=0;for(let t=0;t<256;t++)r=r+n[t]+e[t%e.length]&255,[n[t],n[r]]=[n[r],n[t]];let i=new Uint8Array(t.length),a=0,o=0;for(let e=0;e<t.length;e++)a=a+1&255,o=o+n[a]&255,[n[a],n[o]]=[n[o],n[a]],i[e]=t[e]^n[n[a]+n[o]&255];return i}function Fv(e){let t=e.length,n=t*8,r=(56-(t+1)%64+64)%64+1,i=new Uint8Array(t+r+8);i.set(e),i[t]=128;let a=new DataView(i.buffer);a.setUint32(i.length-8,n>>>0,!0),a.setUint32(i.length-4,0,!0);let o=1732584193,s=4023233417,c=2562383102,l=271733878;for(let e=0;e<i.length;e+=64){let t=new Uint32Array(16);for(let n=0;n<16;n++)t[n]=a.getUint32(e+n*4,!0);let n=o,r=s,i=c,u=l;for(let e=0;e<64;e++){let a,o;e<16?(a=r&i|~r&u,o=e):e<32?(a=u&r|~u&i,o=(5*e+1)%16):e<48?(a=r^i^u,o=(3*e+5)%16):(a=i^(r|~u),o=7*e%16),a=a+n+Rv[e]+t[o]>>>0,n=u,u=i,i=r,r=r+Iv(a,Lv[e])>>>0}o=o+n>>>0,s=s+r>>>0,c=c+i>>>0,l=l+u>>>0}let u=new Uint8Array(16),d=new DataView(u.buffer);return d.setUint32(0,o,!0),d.setUint32(4,s,!0),d.setUint32(8,c,!0),d.setUint32(12,l,!0),u}function Iv(e,t){return(e<<t|e>>>32-t)>>>0}let Lv=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],Rv=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]);function zv(e){let t=new Uint8Array(32),n=new TextEncoder().encode(e),r=Math.min(n.length,32);return t.set(n.subarray(0,r)),t.set(jv.subarray(0,32-r),r),t}function Bv(e,t){let n=Fv(zv(e));for(let e=0;e<50;e++)n=Fv(n);let r=n.subarray(0,16),i=Pv(r,zv(t));for(let e=1;e<=19;e++){let t=new Uint8Array(16);for(let n=0;n<16;n++)t[n]=r[n]^e;i=Pv(t,i)}return i}function Vv(e,t,n,r){let i=zv(e),a=new Uint8Array(68+r.length);a.set(i),a.set(t,32),new DataView(a.buffer,a.byteOffset).setInt32(64,n,!0),a.set(r,68);let o=Fv(a);for(let e=0;e<50;e++)o=Fv(o.subarray(0,16));return o.subarray(0,16)}function Hv(e,t){let n=new Uint8Array(32+t.length);n.set(jv),n.set(t,32);let r=Pv(e,Fv(n));for(let t=1;t<=19;t++){let n=new Uint8Array(16);for(let r=0;r<16;r++)n[r]=e[r]^t;r=Pv(n,r)}let i=new Uint8Array(32);return i.set(r),i}function Uv(e){let t=-3904;return e?.print&&(t|=4),e?.modify&&(t|=8),e?.copy&&(t|=16),e?.annotate&&(t|=32),e?.fillForms&&(t|=256),e?.accessibility&&(t|=512),e?.assemble&&(t|=1024),e?.printHighQuality&&(t|=2048),t|0}function Wv(){let e=new Uint8Array(16),t=Date.now(),n=new DataView(e.buffer);return n.setFloat64(0,t,!0),n.setFloat64(8,Math.random()*0x38d7ea4c68000,!0),Fv(e)}var Gv=class{constructor(){this.nextObjectNumber=1,this.objects=[],this.catalogRef=0,this.infoRef=0,this.encryption=null}setEncryption(e){this.encryption=e}allocObject(){return this.nextObjectNumber++}addObject(e,t){this.objects.push({objectNumber:e,offset:0,content:typeof t==`string`?t:t.toString()})}addStreamObject(e,t,n){let r=n instanceof Uint8Array?n:n.toUint8Array();if(r.length>256&&!t.toString().includes(`/Filter`)){let e=sd(r,{level:6});e.length<r.length&&(t.set(`Filter`,`/FlateDecode`),r=e)}t.set(`Length`,Z(r.length)),this.objects.push({objectNumber:e,offset:0,content:t.toString(),streamData:r})}setCatalog(e){this.catalogRef=e}addInfoDict(e){let t=this.allocObject(),n=new $;return e.title&&n.set(`Title`,yv(e.title)),e.author&&n.set(`Author`,yv(e.author)),e.subject&&n.set(`Subject`,yv(e.subject)),e.creator&&n.set(`Creator`,yv(e.creator)),n.set(`Producer`,yv(`excelts`)),n.set(`CreationDate`,Cv(new Date)),this.addObject(t,n),this.infoRef=t,t}addPage(e){let t=this.allocObject(),n=`[0 0 ${Z(e.width)} ${Z(e.height)}]`,r=new $().set(`Type`,`/Page`).set(`Parent`,Q(e.parentRef)).set(`MediaBox`,n).set(`Contents`,Q(e.contentsRef)).set(`Resources`,Q(e.resourcesRef));return e.annotRefs&&e.annotRefs.length>0&&r.set(`Annots`,`[`+e.annotRefs.map(e=>Q(e)).join(` `)+`]`),this.addObject(t,r),t}addCatalog(e,t){let n=this.allocObject(),r=new $().set(`Type`,`/Catalog`).set(`Pages`,Q(e));return t&&(r.set(`Outlines`,Q(t)),r.set(`PageMode`,`/UseOutlines`)),this.addObject(n,r),this.setCatalog(n),n}build(){if(this.catalogRef===0)throw new kv(`No catalog object set. Call addCatalog() before build().`);let e=new TextEncoder,t=[],n=0,r=e.encode(`%PDF-1.4
428
+ `);t.push(r),n+=r.length;let i=new Uint8Array([37,226,227,207,211,10]);t.push(i),n+=i.length,this.objects.sort((e,t)=>e.objectNumber-t.objectNumber);let a=this.encryption?this.allocObject():0;for(let r of this.objects){r.offset=n;let i=`${r.objectNumber} 0 obj\n`,o=e.encode(i);t.push(o),n+=o.length;let s=r.content;this.encryption&&r.objectNumber!==a&&(s=Kv(s,r.objectNumber,0,this.encryption.encryptionKey));let c=null;`streamData`in r&&r.streamData&&(c=r.streamData,this.encryption&&r.objectNumber!==a&&(c=Nv(c,r.objectNumber,0,this.encryption.encryptionKey),s=s.replace(/\/Length \d+/,`/Length ${c.length}`)));let l=e.encode(s+`
429
429
  `);if(t.push(l),n+=l.length,c){let r=e.encode(`stream
430
430
  `);t.push(r),n+=r.length,t.push(c),n+=c.length;let i=e.encode(`
431
431
  endstream
432
432
  `);t.push(i),n+=i.length}let u=e.encode(`endobj
433
- `);t.push(u),n+=u.length}if(this.encryption){let r=new $().set(`Filter`,`/Standard`).set(`V`,`2`).set(`R`,`3`).set(`Length`,`128`).set(`P`,String(this.encryption.permissions)).set(`O`,vv(this.encryption.oValue)).set(`U`,vv(this.encryption.uValue)).toString(),i={objectNumber:a,offset:n,content:r};this.objects.push(i);let o=e.encode(`${a} 0 obj\n`);t.push(o),n+=o.length;let s=e.encode(r+`
433
+ `);t.push(u),n+=u.length}if(this.encryption){let r=new $().set(`Filter`,`/Standard`).set(`V`,`2`).set(`R`,`3`).set(`Length`,`128`).set(`P`,String(this.encryption.permissions)).set(`O`,bv(this.encryption.oValue)).set(`U`,bv(this.encryption.uValue)).toString(),i={objectNumber:a,offset:n,content:r};this.objects.push(i);let o=e.encode(`${a} 0 obj\n`);t.push(o),n+=o.length;let s=e.encode(r+`
434
434
  `);t.push(s),n+=s.length;let c=e.encode(`endobj
435
435
  `);t.push(c),n+=c.length}let o=n,s=new Map;for(let e of this.objects)s.set(e.objectNumber,e);let c=this.objects.reduce((e,t)=>Math.max(e,t.objectNumber),0),l=[];l.push(`xref`),l.push(`0 ${c+1}`);let u=[0];for(let e=1;e<=c;e++)s.has(e)||u.push(e);let d=new Map;for(let e=0;e<u.length-1;e++)d.set(u[e],u[e+1]);d.set(u[u.length-1],0);let f=(d.get(0)??0).toString().padStart(10,`0`);l.push(`${f} 65535 f `);for(let e=1;e<=c;e++){let t=s.get(e);if(t){let e=t.offset.toString().padStart(10,`0`);l.push(`${e} 00000 n `)}else{let t=(d.get(e)??0).toString().padStart(10,`0`);l.push(`${t} 65535 f `)}}let p=l.join(`
436
436
  `)+`
437
437
  `,m=e.encode(p);t.push(m);let h=`trailer
438
438
  <<
439
- `;h+=`/Size ${c+1}\n`,h+=`/Root ${Q(this.catalogRef)}\n`,this.infoRef>0&&(h+=`/Info ${Q(this.infoRef)}\n`),a>0&&(h+=`/Encrypt ${Q(a)}\n`,h+=`/ID [${vv(this.encryption.fileId)} ${vv(this.encryption.fileId)}]\n`),h+=`>>
439
+ `;h+=`/Size ${c+1}\n`,h+=`/Root ${Q(this.catalogRef)}\n`,this.infoRef>0&&(h+=`/Info ${Q(this.infoRef)}\n`),a>0&&(h+=`/Encrypt ${Q(a)}\n`,h+=`/ID [${bv(this.encryption.fileId)} ${bv(this.encryption.fileId)}]\n`),h+=`>>
440
440
  `,h+=`startxref
441
441
  `,h+=`${o}\n`,h+=`%%EOF
442
- `;let g=e.encode(h);return t.push(g),k(t)}};function Wv(e,t,n,r){let i=new TextEncoder,a=[],o=0;for(;o<e.length;)if(e[o]===`(`){let s=o;o++;let c=``,l=1;for(;o<e.length&&l>0;){let t=e[o];t===`\\`?(c+=e[o]+(e[o+1]??``),o+=2):t===`(`?(l++,c+=t,o++):t===`)`?(l--,l>0&&(c+=t),o++):(c+=t,o++)}if(l!==0){a.push(e.slice(s,o));continue}let u=Gv(c),d=jv(i.encode(u),t,n,r);a.push(vv(d))}else if(e[o]===`<`&&e[o+1]===`<`)a.push(`<<`),o+=2;else if(e[o]===`>`&&e[o+1]===`>`)a.push(`>>`),o+=2;else if(e[o]===`<`){o++;let i=``;for(;o<e.length&&e[o]!==`>`;)i+=e[o],o++;o<e.length&&o++;let s=i.replace(/\s/g,``);if(s.length===0){a.push(`<>`);continue}let c=new Uint8Array(Math.ceil(s.length/2));for(let e=0;e<c.length;e++)c[e]=parseInt(s.substring(e*2,e*2+2).padEnd(2,`0`),16);let l=jv(c,t,n,r);a.push(vv(l))}else a.push(e[o]),o++;return a.join(``)}function Gv(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r!==`\\`){t+=r;continue}let i=e[n+1];if(i===void 0){t+=`\\`;break}switch(i){case`n`:t+=`
443
- `;break;case`r`:t+=`\r`;break;case`t`:t+=` `;break;case`(`:t+=`(`;break;case`)`:t+=`)`;break;case`\\`:t+=`\\`;break;default:t+=i;break}n++}return t}let Kv={32:278,33:278,34:355,35:556,36:556,37:889,38:667,39:191,40:333,41:333,42:389,43:584,44:278,45:333,46:278,47:278,48:556,49:556,50:556,51:556,52:556,53:556,54:556,55:556,56:556,57:556,58:278,59:278,60:584,61:584,62:584,63:556,64:1015,65:667,66:667,67:722,68:722,69:667,70:611,71:778,72:722,73:278,74:500,75:667,76:556,77:833,78:722,79:778,80:667,81:778,82:722,83:667,84:611,85:722,86:667,87:944,88:667,89:667,90:611,91:278,92:278,93:278,94:469,95:556,96:333,97:556,98:556,99:500,100:556,101:556,102:278,103:556,104:556,105:222,106:222,107:500,108:222,109:833,110:556,111:556,112:556,113:556,114:333,115:500,116:278,117:556,118:500,119:722,120:500,121:500,122:500,123:334,124:260,125:334,126:584},qv={32:278,33:333,34:474,35:556,36:556,37:889,38:722,39:238,40:333,41:333,42:389,43:584,44:278,45:333,46:278,47:278,48:556,49:556,50:556,51:556,52:556,53:556,54:556,55:556,56:556,57:556,58:333,59:333,60:584,61:584,62:584,63:611,64:975,65:722,66:722,67:722,68:722,69:667,70:611,71:778,72:722,73:278,74:556,75:722,76:611,77:833,78:722,79:778,80:667,81:778,82:722,83:667,84:611,85:722,86:667,87:944,88:667,89:667,90:611,91:333,92:278,93:333,94:584,95:556,96:333,97:556,98:611,99:556,100:611,101:556,102:333,103:611,104:611,105:278,106:278,107:556,108:278,109:889,110:611,111:611,112:611,113:611,114:389,115:556,116:333,117:611,118:556,119:778,120:556,121:556,122:500,123:389,124:280,125:389,126:584},Jv={32:250,33:333,34:408,35:500,36:500,37:833,38:778,39:180,40:333,41:333,42:500,43:564,44:250,45:333,46:250,47:278,48:500,49:500,50:500,51:500,52:500,53:500,54:500,55:500,56:500,57:500,58:278,59:278,60:564,61:564,62:564,63:444,64:921,65:722,66:667,67:667,68:722,69:611,70:556,71:722,72:722,73:333,74:389,75:722,76:611,77:889,78:722,79:722,80:556,81:722,82:667,83:556,84:611,85:722,86:722,87:944,88:722,89:722,90:611,91:333,92:278,93:333,94:469,95:500,96:333,97:444,98:500,99:444,100:500,101:444,102:333,103:500,104:500,105:278,106:278,107:500,108:278,109:778,110:500,111:500,112:500,113:500,114:333,115:389,116:278,117:500,118:500,119:722,120:500,121:500,122:444,123:480,124:200,125:480,126:541},Yv={32:250,33:333,34:555,35:500,36:500,37:1e3,38:833,39:278,40:333,41:333,42:500,43:570,44:250,45:333,46:250,47:278,48:500,49:500,50:500,51:500,52:500,53:500,54:500,55:500,56:500,57:500,58:333,59:333,60:570,61:570,62:570,63:500,64:930,65:722,66:667,67:722,68:722,69:667,70:611,71:778,72:778,73:389,74:500,75:778,76:667,77:944,78:722,79:778,80:611,81:778,82:722,83:556,84:667,85:722,86:722,87:1e3,88:722,89:722,90:667,91:333,92:278,93:333,94:581,95:500,96:333,97:500,98:556,99:444,100:556,101:444,102:333,103:500,104:556,105:278,106:333,107:556,108:278,109:833,110:556,111:500,112:556,113:556,114:444,115:389,116:333,117:556,118:500,119:722,120:500,121:500,122:444,123:394,124:220,125:394,126:520},Xv={Helvetica:{ascent:718,descent:-207,capHeight:718,avgWidth:513,widths:Kv},"Helvetica-Bold":{ascent:718,descent:-207,capHeight:718,avgWidth:535,widths:qv},"Helvetica-Oblique":{ascent:718,descent:-207,capHeight:718,avgWidth:513,widths:Kv},"Helvetica-BoldOblique":{ascent:718,descent:-207,capHeight:718,avgWidth:535,widths:qv},"Times-Roman":{ascent:683,descent:-217,capHeight:662,avgWidth:478,widths:Jv},"Times-Bold":{ascent:683,descent:-217,capHeight:676,avgWidth:505,widths:Yv},"Times-Italic":{ascent:683,descent:-217,capHeight:653,avgWidth:478,widths:Jv},"Times-BoldItalic":{ascent:683,descent:-217,capHeight:669,avgWidth:505,widths:Yv},Courier:{ascent:629,descent:-157,capHeight:562,avgWidth:600,widths:null,monoWidth:600},"Courier-Bold":{ascent:629,descent:-157,capHeight:562,avgWidth:600,widths:null,monoWidth:600},"Courier-Oblique":{ascent:629,descent:-157,capHeight:562,avgWidth:600,widths:null,monoWidth:600},"Courier-BoldOblique":{ascent:629,descent:-157,capHeight:562,avgWidth:600,widths:null,monoWidth:600}};function Zv(e,t){let n=Xv[t];return n?n.monoWidth===void 0?n.widths?.[e]??n.avgWidth:n.monoWidth:Zv(e,`Helvetica`)}function Qv(e,t,n){let r=0;for(let n=0;n<e.length;n++)r+=Zv(e.charCodeAt(n),t);return r/1e3*n}function $v(e,t){return(Xv[e]??Xv.Helvetica).ascent/1e3*t}function ey(e,t){return(Xv[e]??Xv.Helvetica).descent/1e3*t}function ty(e,t){let n=Xv[e]??Xv.Helvetica;return(n.ascent-n.descent)/1e3*t}function ny(e,t,n,r){let{oldToNewGid:i,unicodeToCid:a,cidWidths:o,usedGlyphIds:s}=ry(t,n),c=iy(t,s,i),l=sd(c,{level:6}),u=e.allocObject(),d=new $().set(`Length`,Z(l.length)).set(`Length1`,Z(c.length)).set(`Filter`,`/FlateDecode`);e.addStreamObject(u,d,l);let f=1e3/t.unitsPerEm,p=e.allocObject(),m=new $().set(`Type`,`/FontDescriptor`).set(`FontName`,yv(t.postScriptName+`-Subset`)).set(`Flags`,Z(t.flags)).set(`FontBBox`,bv(t.bbox.map(e=>Z(Math.round(e*f))))).set(`ItalicAngle`,Z(t.italicAngle)).set(`Ascent`,Z(Math.round(t.ascent*f))).set(`Descent`,Z(Math.round(t.descent*f))).set(`CapHeight`,Z(Math.round(t.capHeight*f))).set(`StemV`,Z(t.stemV)).set(`FontFile2`,Q(u));e.addObject(p,m);let h=ly(o,t.unitsPerEm),g=e.allocObject(),_=new $().set(`Type`,`/Font`).set(`Subtype`,`/CIDFontType2`).set(`BaseFont`,yv(t.postScriptName+`-Subset`)).set(`CIDSystemInfo`,`<< /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>`).set(`FontDescriptor`,Q(p)).set(`DW`,Z(1e3)).set(`W`,h).set(`CIDToGIDMap`,`/Identity`);e.addObject(g,_);let v=sd(cy(a),{level:6}),y=e.allocObject(),b=new $().set(`Length`,Z(v.length)).set(`Filter`,`/FlateDecode`);e.addStreamObject(y,b,v);let x=e.allocObject(),S=new $().set(`Type`,`/Font`).set(`Subtype`,`/Type0`).set(`BaseFont`,yv(t.postScriptName+`-Subset`)).set(`Encoding`,`/Identity-H`).set(`DescendantFonts`,bv([Q(g)])).set(`ToUnicode`,Q(y));return e.addObject(x,S),{resourceName:r,fontObjNum:x,font:t,unicodeToCid:a,cidWidths:o}}function ry(e,t){let n=new Set,r=new Map;n.add(0);for(let i of t){let t=e.cmap.get(i);t!==void 0&&t>0&&(n.add(t),r.set(i,t))}let i=e.tables.get(`glyf`);if(i){let t=i.offset,r=new Set(n),a=Array.from(r);for(;a.length>0;){let i=uy(e,a.pop(),t);for(let e of i)r.has(e)||(r.add(e),n.add(e),a.push(e))}}let a=Array.from(n).sort((e,t)=>e-t),o=new Map;for(let e=0;e<a.length;e++)o.set(a[e],e);let s=new Map,c=Array(a.length).fill(0);c[0]=e.advanceWidths[0]??0;for(let[t,n]of r){let r=o.get(n);s.set(t,r),c[r]=e.advanceWidths[n]??0}return{oldToNewGid:o,unicodeToCid:s,cidWidths:c,usedGlyphIds:n}}function iy(e,t,n){let r=n.size,i=Array.from(t).sort((e,t)=>e-t),a=e.tables.get(`glyf`)?.offset??0,o=[],s=[],c=0;for(let t of i){s.push(c);let r=e.glyphOffsets[t],i=e.glyphOffsets[t+1],l=i-r;if(l>0){let t=dy(e.data.subarray(a+r,a+i),n);o.push(t),c+=l;let s=(4-l%4)%4;s>0&&(o.push(new Uint8Array(s)),c+=s)}}s.push(c);let l=k(o),u=new Uint8Array((r+1)*4),d=new DataView(u.buffer);for(let e=0;e<=r;e++)d.setUint32(e*4,s[e]??c,!1);let f=new Uint8Array(r*4),p=new DataView(f.buffer);for(let t=0;t<i.length;t++){let n=i[t];p.setUint16(t*4,e.advanceWidths[n]??0,!1),p.setInt16(t*4+2,0,!1)}let m=ay(n,e.cmap),h=e.tables.get(`head`),g=new Uint8Array(e.data.subarray(h.offset,h.offset+h.length));new DataView(g.buffer,g.byteOffset,g.byteLength).setInt16(50,1,!1);let _=e.tables.get(`hhea`),v=new Uint8Array(e.data.subarray(_.offset,_.offset+_.length));new DataView(v.buffer,v.byteOffset,v.byteLength).setUint16(34,r,!1);let y=e.tables.get(`maxp`),b=new Uint8Array(e.data.subarray(y.offset,y.offset+y.length));new DataView(b.buffer,b.byteOffset,b.byteLength).setUint16(4,r,!1);let x=new Uint8Array(32);return new DataView(x.buffer).setUint32(0,196608,!1),oy([[`head`,g],[`hhea`,v],[`maxp`,b],[`post`,x],[`cmap`,m],[`hmtx`,f],[`loca`,u],[`glyf`,l]])}function ay(e,t){let n=[];for(let[r,i]of t){let t=e.get(i);t!==void 0&&n.push([r,t])}n.sort((e,t)=>e[0]-t[0]);let r=[];for(let[e,t]of n){let n=r[r.length-1];n&&e===n.endCP+1&&t===n.startGID+(e-n.startCP)?n.endCP=e:r.push({startCP:e,endCP:e,startGID:t})}let i=16+r.length*12,a=12+i,o=new Uint8Array(a),s=new DataView(o.buffer),c=0;s.setUint16(c,0,!1),c+=2,s.setUint16(c,1,!1),c+=2,s.setUint16(c,3,!1),c+=2,s.setUint16(c,10,!1),c+=2,s.setUint32(c,12,!1),c+=4,s.setUint16(c,12,!1),c+=2,s.setUint16(c,0,!1),c+=2,s.setUint32(c,i,!1),c+=4,s.setUint32(c,0,!1),c+=4,s.setUint32(c,r.length,!1),c+=4;for(let e of r)s.setUint32(c,e.startCP,!1),c+=4,s.setUint32(c,e.endCP,!1),c+=4,s.setUint32(c,e.startGID,!1),c+=4;return o}function oy(e){let t=e.length,n=12+t*16,r=[];for(let[t,i]of e){let e=i.length,a=e+3&-4,o=new Uint8Array(a);o.set(i),r.push({tag:t,data:o,originalLength:e,offset:n,checksum:sy(o)}),n+=a}let i=new Uint8Array(n),a=new DataView(i.buffer),o=0;a.setUint32(o,65536,!1),o+=4,a.setUint16(o,t,!1),o+=2;let s=2**Math.floor(Math.log2(t));a.setUint16(o,s*16,!1),o+=2,a.setUint16(o,Math.floor(Math.log2(t)),!1),o+=2,a.setUint16(o,t*16-s*16,!1),o+=2;for(let e of r){for(let t=0;t<4;t++)i[o++]=e.tag.charCodeAt(t);a.setUint32(o,e.checksum,!1),o+=4,a.setUint32(o,e.offset,!1),o+=4,a.setUint32(o,e.originalLength,!1),o+=4}for(let e of r)i.set(e.data,e.offset);return i}function sy(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=Math.floor(e.length/4);for(let e=0;e<r;e++)n=n+t.getUint32(e*4,!1)>>>0;return n}function cy(e){let t=new Map;for(let[n,r]of e)t.set(r,n);let n=Array.from(t.entries()).sort((e,t)=>e[0]-t[0]),r=[];r.push(`/CIDInit /ProcSet findresource begin`),r.push(`12 dict begin`),r.push(`begincmap`),r.push(`/CIDSystemInfo`),r.push(`<< /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def`),r.push(`/CMapName /Adobe-Identity-UCS def`),r.push(`/CMapType 2 def`),r.push(`1 begincodespacerange`),r.push(`<0000> <FFFF>`),r.push(`endcodespacerange`);for(let e=0;e<n.length;e+=100){let t=n.slice(e,e+100);r.push(`${t.length} beginbfchar`);for(let[e,n]of t){let t=e.toString(16).toUpperCase().padStart(4,`0`),i;if(n>65535){let e=55296+(n-65536>>10),t=56320+(n-65536&1023);i=e.toString(16).toUpperCase().padStart(4,`0`)+t.toString(16).toUpperCase().padStart(4,`0`)}else i=n.toString(16).toUpperCase().padStart(4,`0`);r.push(`<${t}> <${i}>`)}r.push(`endbfchar`)}r.push(`endcmap`),r.push(`CMapName currentdict /CMap defineresource pop`),r.push(`end`),r.push(`end`);let i=r.join(`
444
- `);return new TextEncoder().encode(i)}function ly(e,t){if(e.length===0)return`[]`;let n=1e3/t;return`[0 [${e.map(e=>Z(Math.round(e*n))).join(` `)}]]`}function uy(e,t,n){let r=e.glyphOffsets[t];if(e.glyphOffsets[t+1]-r<4)return[];let i=new DataView(e.data.buffer,e.data.byteOffset,e.data.byteLength),a=n+r;if(i.getInt16(a,!1)>=0)return[];let o=a+10,s=[];for(;;){let e=i.getUint16(o,!1);o+=2;let t=i.getUint16(o,!1);if(o+=2,s.push(t),e&1?o+=4:o+=2,e&8?o+=2:e&64?o+=4:e&128&&(o+=8),!(e&32))break}return s}function dy(e,t){if(e.length<10||new DataView(e.buffer,e.byteOffset,e.byteLength).getInt16(0,!1)>=0)return e;let n=new Uint8Array(e.length);n.set(e);let r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=10;for(;;){let e=r.getUint16(i,!1);i+=2;let n=r.getUint16(i,!1),a=t.get(n)??0;if(r.setUint16(i,a,!1),i+=2,e&1?i+=4:i+=2,e&8?i+=2:e&64?i+=4:e&128&&(i+=8),!(e&32))break}return n}let fy={helvetica:`Helvetica`,arial:`Helvetica`,calibri:`Helvetica`,"segoe ui":`Helvetica`,"trebuchet ms":`Helvetica`,verdana:`Helvetica`,tahoma:`Helvetica`,"gill sans":`Helvetica`,"franklin gothic":`Helvetica`,"lucida sans":`Helvetica`,aptos:`Helvetica`,"times new roman":`Times`,times:`Times`,georgia:`Times`,garamond:`Times`,"book antiqua":`Times`,palatino:`Times`,"palatino linotype":`Times`,cambria:`Times`,"century schoolbook":`Times`,"courier new":`Courier`,courier:`Courier`,consolas:`Courier`,"lucida console":`Courier`,monaco:`Courier`,"andale mono":`Courier`,"cascadia code":`Courier`,"cascadia mono":`Courier`,menlo:`Courier`};function py(e){return fy[e.toLowerCase().trim()]??`Helvetica`}function my(e,t,n){let r=py(e);return r===`Helvetica`?t&&n?`Helvetica-BoldOblique`:t?`Helvetica-Bold`:n?`Helvetica-Oblique`:`Helvetica`:r===`Times`?t&&n?`Times-BoldItalic`:t?`Times-Bold`:n?`Times-Italic`:`Times-Roman`:r===`Courier`?t&&n?`Courier-BoldOblique`:t?`Courier-Bold`:n?`Courier-Oblique`:`Courier`:`Helvetica`}var hy=class{constructor(){this.type1Map=new Map,this.resourceToType1=new Map,this.nextType1Id=1,this.embeddedFont=null,this.embeddedResourceName=``,this.usedCodePoints=new Set,this.nextEmbeddedId=1,this._embeddedResult=null}registerEmbeddedFont(e){return this.embeddedFont=e,this.embeddedResourceName=`EF${this.nextEmbeddedId++}`,this.embeddedResourceName}hasEmbeddedFont(){return this.embeddedFont!==null}getEmbeddedResourceName(){return this.embeddedResourceName}trackText(e){if(this.embeddedFont)for(let t=0;t<e.length;t++){let n=e.codePointAt(t);this.usedCodePoints.add(n),n>65535&&t++}}ensureFont(e){let t=this.type1Map.get(e);return t||(t=`F${this.nextType1Id++}`,this.type1Map.set(e,t),this.resourceToType1.set(t,e)),t}resolveFont(e,t,n){if(this.embeddedFont)return this.embeddedResourceName;let r=my(e,t,n);return this.ensureFont(r)}getPdfFontName(e){return this.resourceToType1.get(e)??`Helvetica`}measureText(e,t,n){return this.embeddedFont&&t===this.embeddedResourceName?_y(e,this.embeddedFont,n):Qv(e,this.getPdfFontName(t),n)}getFontAscent(e,t){return this.embeddedFont&&e===this.embeddedResourceName?this.embeddedFont.ascent/this.embeddedFont.unitsPerEm*t:$v(this.getPdfFontName(e),t)}getFontDescent(e,t){return this.embeddedFont&&e===this.embeddedResourceName?this.embeddedFont.descent/this.embeddedFont.unitsPerEm*t:ey(this.getPdfFontName(e),t)}getLineHeight(e,t){if(this.embeddedFont&&e===this.embeddedResourceName){let e=this.embeddedFont;return(e.ascent-e.descent)/e.unitsPerEm*t}return ty(this.getPdfFontName(e),t)}isEmbeddedFont(e){return this.embeddedFont!==null&&e===this.embeddedResourceName}encodeText(e,t){if(!this.embeddedFont||t!==this.embeddedResourceName)return null;if(this._embeddedResult)return gy(e,this._embeddedResult.unicodeToCid);throw new Ev(`encodeText called before writeFontResources — subset mapping not available`)}writeFontResources(e){let t=new Map;for(let[n,r]of this.type1Map){let i=e.allocObject(),a=new $().set(`Type`,`/Font`).set(`Subtype`,`/Type1`).set(`BaseFont`,yv(n)).set(`Encoding`,`/WinAnsiEncoding`);e.addObject(i,a),t.set(r,i)}if(this.embeddedFont&&this.embeddedResourceName){let n=ny(e,this.embeddedFont,this.usedCodePoints,this.embeddedResourceName);t.set(this.embeddedResourceName,n.fontObjNum),this._embeddedResult=n}return t}getEmbeddedResult(){return this._embeddedResult}buildFontDictString(e){let t=[`<<`];for(let[n,r]of e)t.push(`${yv(n)} ${Q(r)}`);return t.push(`>>`),t.join(`
445
- `)}getRegisteredFonts(){let e=[];for(let[t,n]of this.type1Map)e.push({resourceName:n,pdfFontName:t});return e}};function gy(e,t){let n=`<`;for(let r=0;r<e.length;r++){let i=e.codePointAt(r);i>65535&&r++;let a=t.get(i)??0;n+=a.toString(16).toUpperCase().padStart(4,`0`)}return n+=`>`,n}function _y(e,t,n){let r=0;for(let n=0;n<e.length;n++){let i=e.codePointAt(n);i>65535&&n++;let a=t.cmap.get(i)??0;r+=t.advanceWidths[a]??0}return r/t.unitsPerEm*n}let vy=65536,yy=2e6;var by=class e{constructor(e,t=0){this.data=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.offset=t}u8(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}u16(){let e=this.view.getUint16(this.offset,!1);return this.offset+=2,e}i16(){let e=this.view.getInt16(this.offset,!1);return this.offset+=2,e}u32(){let e=this.view.getUint32(this.offset,!1);return this.offset+=4,e}i32(){let e=this.view.getInt32(this.offset,!1);return this.offset+=4,e}fixed(){return this.i32()/65536}bytes(e){let t=this.data.subarray(this.offset,this.offset+e);return this.offset+=e,t}tag(){return String.fromCharCode(this.u8(),this.u8(),this.u8(),this.u8())}skip(e){this.offset+=e}at(t){return new e(this.data,t)}u16At(e){return this.view.getUint16(e,!1)}u32At(e){return this.view.getUint32(e,!1)}i16At(e){return this.view.getInt16(e,!1)}};function xy(e){let t=new by(e),n=t.u32();if(n!==65536&&n!==1953658213)throw n===1330926671?new Ev(`CFF-flavored OpenType (.otf) is not supported. Use a TrueType (.ttf) font.`):new Ev(`Invalid TrueType font: bad sfVersion 0x${n.toString(16)}`);let r=t.u16();t.skip(6);let i=new Map;for(let e=0;e<r;e++){let e=t.tag();t.skip(4);let n=t.u32(),r=t.u32();i.set(e,{offset:n,length:r})}for(let e of[`head`,`hhea`,`maxp`,`cmap`,`hmtx`])if(!i.has(e))throw new Ev(`Missing required table '${e}' in TrueType font`);let a=Sy(t,i.get(`head`)),o=Cy(t,i.get(`hhea`)),s=wy(t,i.get(`maxp`)),c=i.has(`OS/2`)?Ty(t,i.get(`OS/2`)):null,l=i.has(`post`)?Ey(t,i.get(`post`)):null,u=i.has(`name`)?Dy(t,i.get(`name`)):null,d=Oy(t,i.get(`cmap`)),f=jy(t,i.get(`hmtx`),o.numHMetrics,s.numGlyphs),p=i.has(`loca`)&&i.has(`glyf`)?My(t,i.get(`loca`),s.numGlyphs,a.indexToLocFormat):new Uint32Array(s.numGlyphs+1),m=c?.sTypoAscender??o.ascent,h=c?.sTypoDescender??o.descent,g=c?.sCapHeight??Math.round(m*.7),_=0;l?.isFixedPitch&&(_|=1),a.macStyle&2&&(_|=64),_|=32;let v=c?.usWeightClass??400,y=Math.round(50+(v/65)**2),b=u?.familyName??`Unknown`;return{data:e,familyName:b,postScriptName:u?.postScriptName??b.replace(/\s+/g,``),unitsPerEm:a.unitsPerEm,ascent:m,descent:h,capHeight:g,italicAngle:l?.italicAngle??0,flags:_,bbox:[a.xMin,a.yMin,a.xMax,a.yMax],stemV:y,numGlyphs:s.numGlyphs,indexToLocFormat:a.indexToLocFormat,numHMetrics:o.numHMetrics,tables:i,cmap:d,advanceWidths:f,glyphOffsets:p}}function Sy(e,t){let n=e.at(t.offset);n.skip(4),n.skip(4),n.skip(4),n.skip(4),n.skip(2);let r=n.u16();n.skip(16);let i=n.i16(),a=n.i16(),o=n.i16(),s=n.i16(),c=n.u16();return n.skip(2),n.skip(2),{unitsPerEm:r,xMin:i,yMin:a,xMax:o,yMax:s,macStyle:c,indexToLocFormat:n.i16()}}function Cy(e,t){let n=e.at(t.offset);n.skip(4);let r=n.i16(),i=n.i16(),a=n.i16();return n.skip(2),n.skip(22),{ascent:r,descent:i,lineGap:a,numHMetrics:n.u16()}}function wy(e,t){let n=e.at(t.offset);return n.skip(4),{numGlyphs:n.u16()}}function Ty(e,t){let n=e.at(t.offset),r=n.u16();n.skip(2);let i=n.u16();n.skip(2),n.skip(2),n.skip(22),n.skip(10),n.skip(16),n.skip(4),n.skip(2),n.skip(2),n.skip(2);let a=n.i16(),o=n.i16();n.skip(2),n.skip(2),n.skip(2);let s;return r>=2?(n.skip(8),n.skip(2),s=n.i16()):s=Math.round(a*.7),{usWeightClass:i,sTypoAscender:a,sTypoDescender:o,sCapHeight:s}}function Ey(e,t){let n=e.at(t.offset);n.skip(4);let r=n.fixed();return n.skip(2),n.skip(2),{italicAngle:r,isFixedPitch:n.u32()!==0}}function Dy(e,t){let n=t.offset,r=e.at(n);r.skip(2);let i=r.u16(),a=n+r.u16(),o=``,s=``;for(let t=0;t<i;t++){let t=r.u16(),n=r.u16();r.skip(2);let i=r.u16(),c=r.u16(),l=r.u16();if(i!==1&&i!==6)continue;let u=e.at(a+l).bytes(c),d;if(t===3||t===0)d=Ny(u);else if(t===1&&n===0)d=Py(u);else continue;i===1&&!o&&(o=d),i===6&&!s&&(s=d)}return{familyName:o||`Unknown`,postScriptName:s||o||`Unknown`}}function Oy(e,t){let n=t.offset,r=e.at(n);r.skip(2);let i=r.u16(),a=-1,o=-1;for(let t=0;t<i;t++){let t=r.u16(),i=r.u16(),s=r.u32();if(!(t===0||t===3&&(i===1||i===10)))continue;let c=e.u16At(n+s);c===12&&o<0&&(o=n+s),c===4&&a<0&&(a=n+s)}if(o>=0)return Ay(e,o);if(a>=0)return ky(e,a);throw new Ev(`No usable Unicode cmap subtable found in font`)}function ky(e,t){let n=e.at(t);n.skip(2),n.skip(2),n.skip(2);let r=n.u16()/2;n.skip(6);let i=[];for(let e=0;e<r;e++)i.push(n.u16());n.skip(2);let a=[];for(let e=0;e<r;e++)a.push(n.u16());let o=[];for(let e=0;e<r;e++)o.push(n.i16());let s=n.offset,c=[];for(let e=0;e<r;e++)c.push(n.u16());let l=new Map;for(let t=0;t<r;t++){let n=a[t],r=i[t],u=o[t],d=c[t];if(n===65535)break;for(let i=n;i<=r;i++){let r;if(d===0)r=i+u&65535;else{let a=s+t*2+d+(i-n)*2;r=e.u16At(a),r!==0&&(r=r+u&65535)}r!==0&&l.set(i,r)}}return l}function Ay(e,t){let n=e.at(t);n.skip(2),n.skip(2),n.skip(4),n.skip(4);let r=n.u32();if(r>vy)throw new Ev(`cmap format 12 has ${r} groups, exceeding limit of ${vy}. The font file may be malicious or corrupted.`);let i=new Map,a=0;for(let e=0;e<r;e++){let e=n.u32(),t=n.u32(),r=n.u32(),o=t>=e?t-e+1:0;if(a+=o,a>yy)throw new Ev(`cmap format 12 maps too many codepoints (>${yy}). The font file may be malicious or corrupted.`);for(let n=e;n<=t;n++)i.set(n,r+(n-e))}return i}function jy(e,t,n,r){let i=e.at(t.offset),a=new Uint16Array(r),o=0;for(let e=0;e<n;e++)o=i.u16(),i.skip(2),a[e]=o;for(let e=n;e<r;e++)a[e]=o;return a}function My(e,t,n,r){let i=e.at(t.offset),a=new Uint32Array(n+1);if(r===0)for(let e=0;e<=n;e++)a[e]=i.u16()*2;else for(let e=0;e<=n;e++)a[e]=i.u32();return a}function Ny(e){let t=[];for(let n=0;n+1<e.length;n+=2){let r=e[n]<<8|e[n+1];if(r>=55296&&r<=56319&&n+3<e.length){let i=e[n+2]<<8|e[n+3];if(i>=56320&&i<=57343){t.push(String.fromCodePoint((r-55296<<10)+(i-56320)+65536)),n+=2;continue}}t.push(String.fromCharCode(r))}return t.join(``)}function Py(e){let t=[];for(let n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join(``)}function Fy(e){if(!e||e.length<6)return null;let t,n,r,i;if(e.length>=8?(t=parseInt(e.substring(0,2),16),n=parseInt(e.substring(2,4),16),r=parseInt(e.substring(4,6),16),i=parseInt(e.substring(6,8),16)):(t=255,n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16)),isNaN(n)||isNaN(r)||isNaN(i))return null;let a=t/255;return{r:n/255,g:r/255,b:i/255,...a<1?{a}:{}}}function Iy(e){if(!e)return null;if(e.argb)return Fy(e.argb);if(e.theme!==void 0){let t=Ly(e.theme);if(!t)return null;let n=e.tint;return n!==void 0&&n!==0?Ry(t,n):t}return null}function Ly(e){let t=[{r:1,g:1,b:1},{r:0,g:0,b:0},{r:.918,g:.929,b:.941},{r:.267,g:.278,b:.298},{r:.263,g:.522,b:.839},{r:.922,g:.494,b:.196},{r:.624,g:.624,b:.624},{r:1,g:.753,b:0},{r:.314,g:.686,b:.886},{r:.439,g:.678,b:.278}];return e>=0&&e<t.length?t[e]:null}function Ry(e,t){let n=e=>t<0?e*(1+t):e+(1-e)*t;return{r:Math.max(0,Math.min(1,n(e.r))),g:Math.max(0,Math.min(1,n(e.g))),b:Math.max(0,Math.min(1,n(e.b)))}}let zy={black:{r:0,g:0,b:0},white:{r:1,g:1,b:1},gridLine:{r:.816,g:.816,b:.816}};function By(e,t,n){return{fontFamily:e?.name??t,fontSize:e?.size??n,bold:e?.bold??!1,italic:e?.italic??!1,strike:e?.strike??!1,underline:!!(e?.underline&&e.underline!==`none`),textColor:Iy(e?.color)??zy.black}}function Vy(e){if(!e)return null;if(e.type===`pattern`){if(e.pattern===`solid`&&e.fgColor)return Iy(e.fgColor);if(e.pattern===`none`)return null;if(e.fgColor)return Iy(e.fgColor)}return e.type===`gradient`&&e.stops&&e.stops.length>0?Iy(e.stops[0].color):null}function Hy(e){switch(e){case`thin`:return .5;case`medium`:return 1;case`thick`:return 1.5;case`double`:return .5;case`hair`:return .25;case`dotted`:return .5;case`dashed`:return .5;case`dashDot`:return .5;case`dashDotDot`:return .5;case`slantDashDot`:return .5;case`mediumDashed`:return 1;case`mediumDashDot`:return 1;case`mediumDashDotDot`:return 1;default:return .5}}function Uy(e){switch(e){case`dotted`:return[1,1];case`dashed`:case`mediumDashed`:return[3,2];case`dashDot`:case`mediumDashDot`:return[3,1,1,1];case`dashDotDot`:case`mediumDashDotDot`:return[3,1,1,1,1,1];case`slantDashDot`:return[4,2,1,2];case`hair`:return[.5,.5];default:return[]}}function Wy(e){return!e||!e.style?null:{width:Hy(e.style),color:Iy(e.color)??zy.black,dashPattern:Uy(e.style)}}function Gy(e){return e?{top:Wy(e.top),right:Wy(e.right),bottom:Wy(e.bottom),left:Wy(e.left)}:{top:null,right:null,bottom:null,left:null}}function Ky(e){if(!e?.horizontal)return`left`;switch(e.horizontal){case`center`:case`centerContinuous`:return`center`;case`right`:return`right`;default:return`left`}}function qy(e){if(!e?.vertical)return`bottom`;switch(e.vertical){case`top`:return`top`;case`middle`:return`middle`;default:return`bottom`}}let Jy=8.43;function Yy(e,t,n){let{margins:r}=t,i=t.pageSize.width,a=t.pageSize.height;t.orientation===`landscape`&&([i,a]=[a,i]);let o=i-r.left-r.right,s=a-r.top-r.bottom,c=t.showSheetNames?20:0,l=t.showPageNumbers?20:0,u=s-c-l,d=$y(e),{columnWidths:f,visibleCols:p}=eb(e,d);if(p.length===0)return[Xy(i,a,e.name,t)];let m=f.reduce((e,t)=>e+t,0),h=t.scale;if(t.fitToPage&&m>0){let e=o/m;e<1&&(h*=e)}let g=f.map(e=>e*h),{rowHeights:_,visibleRows:v}=tb(e,h,d),y=rb(e),b=ib(_,u,typeof t.repeatRows==`number`?t.repeatRows:0,nb(e,v)),x=ab(g,o,e,p),S=[];for(let s of b)for(let l of x){let u=[],d=l.map(e=>g[e]),f=d.reduce((e,t)=>e+t,0),m=[],b=r.left;f<o&&(b=r.left+(o-f)/2);for(let e of d)m.push(b),b+=e;let x=[],ee=[],C=a-r.top-c;for(let e of s){let t=_[e]??15*h;x.push(C),ee.push(t),C-=t}for(let r=0;r<s.length;r++){let i=s[r],a=v[i];for(let o=0;o<l.length;o++){let s=p[l[o]],c=`${a}:${s}`,f=y.get(c);if(f&&!f.isMaster)continue;let g=e.rows.get(a)?.cells.get(s),_=1,b=1;if(f&&f.isMaster){let e=s+f.colSpan-1;_=0;for(let t=o;t<l.length&&p[l[t]]<=e;t++)_++;let t=a+f.rowSpan-1;b=0;for(let e=i;e<v.length&&v[e]<=t;e++)b++;_=Math.max(_,1),b=Math.max(b,1)}let S=m[o],C=x[r],te=0;for(let e=0;e<_&&o+e<d.length;e++)te+=d[o+e];let ne=0;for(let e=0;e<b&&r+e<ee.length;e++)ne+=ee[r+e];let w=C-ne;u.push(ob(g,S,w,te,ne,_,b,t,n,h))}}S.push({pageNumber:S.length+1,options:t,cells:u,width:i,height:a,sheetName:e.name,sheetCols:l.map(e=>p[e]),columnOffsets:m,columnWidths:d,sheetRows:s.map(e=>v[e]),rowYPositions:x,rowHeights:ee,images:[]})}return S.length>0&&e.images&&sb(e.images,S),S}function Xy(e,t,n,r){return{pageNumber:1,options:r,cells:[],width:e,height:t,sheetName:n,sheetCols:[],columnOffsets:[],columnWidths:[],sheetRows:[],rowYPositions:[],rowHeights:[],images:[]}}function Zy(e){let t=e.replace(/\$/g,``).toUpperCase(),n=0,r=0;for(;r<t.length&&t.charCodeAt(r)>=65&&t.charCodeAt(r)<=90;)n=n*26+(t.charCodeAt(r)-64),r++;let i=parseInt(t.substring(r),10);return{c:n-1,r:i-1}}function Qy(e){let t=e.indexOf(`:`);if(t===-1){let t=Zy(e);return{s:t,e:{...t}}}return{s:Zy(e.slice(0,t)),e:Zy(e.slice(t+1))}}function $y(e){let t=e.pageSetup?.printArea;if(!t||typeof t!=`string`)return null;let n=t.split(`&&`)[0].trim();if(!n)return null;try{let e=Qy(n);return{startRow:e.s.r+1,endRow:e.e.r+1,startCol:e.s.c+1,endCol:e.e.c+1}}catch{return null}}function eb(e,t){let n=e.bounds;if(!(n.top>0&&n.left>0))return{columnWidths:[],visibleCols:[]};let r=t?.startCol??n.left,i=t?.endCol??n.right,a=[],o=[];for(let t=r;t<=i;t++){let n=e.columns.get(t);if(n?.hidden)continue;let r=n?.width??Jy,i=Math.max(r*7,5);a.push(i),o.push(t)}return{columnWidths:a,visibleCols:o}}function tb(e,t,n){let r=e.bounds;if(r.top<=0)return{rowHeights:[],visibleRows:[]};let i=n?.startRow??r.top,a=n?.endRow??r.bottom,o=[],s=[];for(let n=i;n<=a;n++){let r=e.rows.get(n);if(r&&r.hidden)continue;let i;if(r?.height)i=r.height;else if(i=15,r)for(let n of r.cells.values()){let r=n.style?.font?.size??11,a=n.value;if(a?.richText)for(let e of a.richText){let t=e.font?.size??r;t>r&&(r=t)}let o=r*1.5,s=n.text??``,c=Math.max(1,(s.match(/\n/g)??[]).length+1),l=c;if(n.style?.alignment?.wrapText&&c===1&&s.length>0){let i=(e.columns.get(n.col)?.width??Jy)*7*t,a=r*.55,o=Math.max(1,Math.floor(i/a));l=Math.ceil(s.length/o)}let u=o*l;u>i&&(i=u)}o.push(i*t),s.push(n)}return{rowHeights:o,visibleRows:s}}function nb(e,t){let n=new Set,r=e.rowBreaks??[];if(r.length===0)return n;let i=new Map;for(let e=0;e<t.length;e++)i.set(t[e],e);for(let e of r){let t=i.get(e);t!==void 0&&n.add(t+1)}return n}function rb(e){let t=new Map,n=e.merges;if(!n||n.length===0)return t;for(let e of n){let n=Qy(e),r=n.s.r+1,i=n.s.c+1,a=n.e.r+1,o=n.e.c+1,s=a-r+1,c=o-i+1;for(let e=r;e<=a;e++)for(let n=i;n<=o;n++)t.set(`${e}:${n}`,{isMaster:e===r&&n===i,rowSpan:s,colSpan:c})}return t}function ib(e,t,n,r){if(e.length===0)return[[]];let i=[],a=[],o=0,s=!0,c=0,l=()=>{c=0;for(let r=0;r<n&&r<e.length&&!(o+e[r]>t&&a.length>0);r++)a.push(r),o+=e[r],c++};for(let u=0;u<e.length;u++){let d=e[u],f=t;for(;;){let e=r.has(u)&&a.length>0;if((e||o+d>f)&&a.length>0){if(!e&&!s&&a.length>0&&a.length===c){a=[],o=0,c=0;continue}i.push(a),a=[],o=0,c=0,s=!1,l();continue}if(!s&&u<n&&a.includes(u))break;a.push(u),o+=d;break}}return a.length>0&&i.push(a),i.length>0?i:[[]]}function ab(e,t,n,r){if(e.length===0)return[[]];let i=new Set,a=n.colBreaks??[];if(a.length>0){let e=new Map;for(let t=0;t<r.length;t++)e.set(r[t],t);for(let t of a){let n=e.get(t);n!==void 0&&i.add(n+1)}}let o=[],s=[],c=0;for(let n=0;n<e.length;n++){let r=e[n];(i.has(n)&&s.length>0||c+r>t+.01)&&s.length>0&&(o.push(s),s=[],c=0),s.push(n),c+=r}return s.length>0&&o.push(s),o.length>0?o:[Array.from({length:e.length},(e,t)=>t)]}function ob(e,t,n,r,i,a,o,s,c,l){let u=e?.text??``,d=e?.style??{},f=By(d.font,s.defaultFontFamily,s.defaultFontSize),p=f.fontSize*l;if(c.hasEmbeddedFont())c.trackText(u);else{let e=my(f.fontFamily,f.bold,f.italic);c.ensureFont(e)}let m=cb(e,s,c,l);return{text:u,rect:{x:t,y:n,width:r,height:i},fontFamily:f.fontFamily,fontSize:p,bold:f.bold,italic:f.italic,strike:f.strike,underline:f.underline,textColor:f.textColor,fillColor:Vy(d.fill),horizontalAlign:Ky(d.alignment),verticalAlign:qy(d.alignment),wrapText:d.alignment?.wrapText??!1,borders:Gy(d.border),colSpan:a,rowSpan:o,hyperlink:e?.hyperlink??null,richText:m,indent:d.alignment?.indent??0,textRotation:d.alignment?.textRotation??0}}function sb(e,t){for(let n of e){let e=n.range.tl,r=(e.nativeCol??e.col??0)+1,i=(e.nativeRow??e.row??0)+1,a=t.find(e=>e.sheetCols.includes(r)&&e.sheetRows.includes(i));if(!a)continue;let o=a.sheetCols.indexOf(r),s=a.sheetRows.indexOf(i),c=a.columnOffsets[o]??a.options.margins.left,l=a.rowYPositions[s]??a.height-a.options.margins.top-(a.options.showSheetNames?20:0),u=(e.nativeColOff??0)/12700||0,d=(e.nativeRowOff??0)/12700||0,f=c+u,p=l-d,m=100,h=100;if(n.range.ext)m=(n.range.ext.width??100)*.75,h=(n.range.ext.height??100)*.75;else if(n.range.br){let e=n.range.br,t=(e.nativeCol??e.col??0)+1,r=(e.nativeRow??e.row??0)+1,i=a.sheetCols.indexOf(t),c=a.sheetRows.indexOf(r),l=i>=0?a.columnOffsets[i]:f+(a.columnWidths[o]??100),u=c>=0?a.rowYPositions[c]:p-(a.rowHeights[s]??100),d=(e.nativeColOff??0)/12700||0,g=(e.nativeRowOff??0)/12700||0,_=l+d,v=u-g;m=_-f,h=p-v}a.images.push({data:n.data,format:n.format,rect:{x:f,y:p-h,width:Math.abs(m),height:Math.abs(h)}})}}function cb(e,t,n,r){if(!e||e.type!==X.RichText)return null;let i=e.value;return!i?.richText||i.richText.length===0?null:i.richText.map(e=>{let i=By(e.font,t.defaultFontFamily,t.defaultFontSize);if(n.hasEmbeddedFont())n.trackText(e.text);else{let e=my(i.fontFamily,i.bold,i.italic);n.ensureFont(e)}return{text:e.text,fontFamily:i.fontFamily,fontSize:i.fontSize*r,bold:i.bold,italic:i.italic,strike:i.strike,underline:i.underline,textColor:i.textColor}})}var lb=class{constructor(){this.parts=[]}save(){return this.parts.push(`q`),this}restore(){return this.parts.push(`Q`),this}setGraphicsState(e){return this.parts.push(`/${e} gs`),this}setStrokeColor(e){return this.parts.push(`${Z(e.r)} ${Z(e.g)} ${Z(e.b)} RG`),this}setFillColor(e){return this.parts.push(`${Z(e.r)} ${Z(e.g)} ${Z(e.b)} rg`),this}setLineWidth(e){return this.parts.push(`${Z(e)} w`),this}setDashPattern(e,t=0){let n=e.map(Z).join(` `);return this.parts.push(`[${n}] ${Z(t)} d`),this}setLineCap(e){return this.parts.push(`${e} J`),this}setLineJoin(e){return this.parts.push(`${e} j`),this}moveTo(e,t){return this.parts.push(`${Z(e)} ${Z(t)} m`),this}lineTo(e,t){return this.parts.push(`${Z(e)} ${Z(t)} l`),this}rect(e,t,n,r){return this.parts.push(`${Z(e)} ${Z(t)} ${Z(n)} ${Z(r)} re`),this}stroke(){return this.parts.push(`S`),this}fill(){return this.parts.push(`f`),this}fillAndStroke(){return this.parts.push(`B`),this}closePath(){return this.parts.push(`h`),this}endPath(){return this.parts.push(`n`),this}clip(){return this.parts.push(`W`),this}beginText(){return this.parts.push(`BT`),this}endText(){return this.parts.push(`ET`),this}setFont(e,t){return this.parts.push(`/${e} ${Z(t)} Tf`),this}setTextMatrix(e,t,n,r,i,a){return this.parts.push(`${Z(e)} ${Z(t)} ${Z(n)} ${Z(r)} ${Z(i)} ${Z(a)} Tm`),this}moveText(e,t){return this.parts.push(`${Z(e)} ${Z(t)} Td`),this}setTextLeading(e){return this.parts.push(`${Z(e)} TL`),this}showText(e){return db(e)?this.showTextWinAnsi(e):(this.parts.push(`(${ub(e)}) Tj`),this)}showTextWinAnsi(e){let t=`<`;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);r>65535&&n++;let i=pb(r);t+=i.toString(16).padStart(2,`0`)}return t+=`>`,this.parts.push(`${t} Tj`),this}showTextHex(e){return this.parts.push(`${e} Tj`),this}nextLineShowText(e){if(db(e)){let t=`<`;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);r>65535&&n++;let i=pb(r);t+=i.toString(16).padStart(2,`0`)}return t+=`>`,this.parts.push(`${t} '`),this}return this.parts.push(`(${ub(e)}) '`),this}setTextRise(e){return this.parts.push(`${Z(e)} Ts`),this}setCharacterSpacing(e){return this.parts.push(`${Z(e)} Tc`),this}setWordSpacing(e){return this.parts.push(`${Z(e)} Tw`),this}drawImage(e,t,n,r,i){return this.save().concat(r,0,0,i,t,n).doXObject(e).restore()}concat(e,t,n,r,i,a){return this.parts.push(`${Z(e)} ${Z(t)} ${Z(n)} ${Z(r)} ${Z(i)} ${Z(a)} cm`),this}doXObject(e){return this.parts.push(`/${e} Do`),this}fillRect(e,t,n,r,i){return this.save().setFillColor(i).rect(e,t,n,r).fill().restore()}drawLine(e,t,n,r,i,a,o=[]){return this.save().setStrokeColor(i).setLineWidth(a),o.length>0&&this.setDashPattern(o),this.moveTo(e,t).lineTo(n,r).stroke().restore()}toString(){return this.parts.join(`
446
- `)}toUint8Array(){return new TextEncoder().encode(this.toString())}};function ub(e){return e.replace(/\\/g,`\\\\`).replace(/\(/g,`\\(`).replace(/\)/g,`\\)`).replace(/\r\n/g,`\\n`).replace(/\r/g,`\\n`).replace(/\n/g,`\\n`)}function db(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!0;return!1}let fb=new Map([[8364,128],[8218,130],[402,131],[8222,132],[8230,133],[8224,134],[8225,135],[710,136],[8240,137],[352,138],[8249,139],[338,140],[381,142],[8216,145],[8217,146],[8220,147],[8221,148],[8226,149],[8211,150],[8212,151],[732,152],[8482,153],[353,154],[8250,155],[339,156],[382,158],[376,159]]);function pb(e){if(e<128||e>=160&&e<=255)return e;let t=fb.get(e);return t===void 0?63:t}function mb(e,t,n,r){let i=new lb,a=new Set;t.showGridLines&&hb(i,e,t);for(let t of e.cells)t.fillColor&&gb(i,t,a);for(let t of e.cells)_b(i,t);for(let t of e.cells)t.text&&yb(i,t,n,a);return t.showSheetNames&&kb(i,e,t,n),t.showPageNumbers&&Ab(i,e,t,n,r),{stream:i,alphaValues:a}}function hb(e,t,n){if(t.columnWidths.length===0||t.rowHeights.length===0)return;let r=n.gridLineColor;e.save(),e.setStrokeColor(r),e.setLineWidth(.25);let i=t.rowYPositions[0],a=t.rowYPositions.length-1,o=t.rowYPositions[a]-t.rowHeights[a];for(let n=0;n<=t.columnWidths.length;n++){let r=n<t.columnWidths.length?t.columnOffsets[n]:t.columnOffsets[n-1]+t.columnWidths[n-1];e.moveTo(r,i),e.lineTo(r,o)}let s=t.columnOffsets[0],c=t.columnOffsets.length-1,l=t.columnOffsets[c]+t.columnWidths[c];for(let n=0;n<=t.rowYPositions.length;n++){let r=n<t.rowYPositions.length?t.rowYPositions[n]:t.rowYPositions[n-1]-t.rowHeights[n-1];e.moveTo(s,r),e.lineTo(l,r)}e.stroke(),e.restore()}function gb(e,t,n){if(!t.fillColor)return;let r=t.fillColor.a;if(r!==void 0&&r<1){let i=Cb(r);n.add(r),e.save(),e.setGraphicsState(i),e.fillRect(t.rect.x,t.rect.y,t.rect.width,t.rect.height,t.fillColor),e.restore()}else e.fillRect(t.rect.x,t.rect.y,t.rect.width,t.rect.height,t.fillColor)}function _b(e,t){let{rect:n,borders:r}=t,{x:i,y:a,width:o,height:s}=n;r.top&&vb(e,r.top,i,a+s,i+o,a+s),r.bottom&&vb(e,r.bottom,i,a,i+o,a),r.left&&vb(e,r.left,i,a,i,a+s),r.right&&vb(e,r.right,i+o,a,i+o,a+s)}function vb(e,t,n,r,i,a){e.drawLine(n,r,i,a,t.color,t.width,t.dashPattern)}function yb(e,t,n,r){let{rect:i,text:a,fontSize:o,horizontalAlign:s,verticalAlign:c,wrapText:l}=t;if(!a&&!t.richText)return;let u=i.width-6,d=i.height-4;if(u<=0||d<=0)return;let f=t.indent*wb;e.save(),e.rect(i.x,i.y,i.width,i.height),e.clip(),e.endPath();let p=t.textColor.a;if(p!==void 0&&p<1&&(r.add(p),e.setGraphicsState(Cb(p))),t.textRotation===`vertical`){Sb(e,t,n,f),e.restore();return}if(typeof t.textRotation==`number`&&t.textRotation!==0){xb(e,t,n,f),e.restore();return}if(t.richText&&t.richText.length>0){bb(e,t,n,f),e.restore();return}let m=n.hasEmbeddedFont()?n.getEmbeddedResourceName():n.ensureFont(my(t.fontFamily,t.bold,t.italic)),h=e=>n.measureText(e,m,o),g=u-f-1,_=l?Ob(a,h,g):[a],v=o*1.2,y=n.getFontAscent(m,o),b=Tb(c,i,_.length*v,y);e.setFillColor(t.textColor),e.beginText(),e.setFont(m,o);for(let t=0;t<_.length;t++){let r=_[t],a=b-t*v,o=Eb(s,i,h(r),f);e.setTextMatrix(1,0,0,1,o,a);let c=n.encodeText(r,m);c?e.showTextHex(c):e.showText(r)}e.endText(),Db(e,t,_,v,b,h,m,n,f),e.restore()}function bb(e,t,n,r){let{rect:i,horizontalAlign:a,verticalAlign:o,wrapText:s}=t,c=t.richText,l=t.fontSize;for(let e of c)e.fontSize>l&&(l=e.fontSize);let u=l,d=u*1.2,f=n.hasEmbeddedFont(),p=e=>f?n.getEmbeddedResourceName():n.ensureFont(my(e.fontFamily,e.bold,e.italic));if(s){let t=i.width-6-r-1;if(t<=0)return;let s=c.map(e=>e.text).join(``),l=p(c[0]),f=Ob(s,e=>n.measureText(e,l,u),t),m=[];for(let e=0;e<c.length;e++)for(let t=0;t<c[e].text.length;t++)m.push(e);let h=p(c[0]),g=n.getFontAscent(h,u),_=Tb(o,i,f.length*d,g),v=0;for(let t=0;t<f.length;t++){let o=_-t*d,l=f[t].length,u=[],h=v;for(let e=0;e<l;e++){let n=m[v+e]??m.length-1,r=u[u.length-1];r&&r.run===c[n]?r.text+=f[t][e]:u.push({run:c[n],text:f[t][e],resourceName:p(c[n])})}for(v+=l;v<m.length&&v<h+l+1;){let e=t+1<f.length?s.indexOf(f[t+1],v):s.length;if(e>v){v=e;break}break}let g=0;for(let e of u)g+=n.measureText(e.text,e.resourceName,e.run.fontSize);let y=Eb(a,i,g,r);for(let t of u){let{run:r,text:i,resourceName:a}=t,s=n.measureText(i,a,r.fontSize);e.setFillColor(r.textColor),e.beginText(),e.setFont(a,r.fontSize),e.setTextMatrix(1,0,0,1,y,o);let c=n.encodeText(i,a);if(c?e.showTextHex(c):e.showText(i),e.endText(),r.strike){let t=o+n.getFontDescent(a,r.fontSize)+r.fontSize*.3;e.drawLine(y,t,y+s,t,r.textColor,.5)}if(r.underline){let t=o+n.getFontDescent(a,r.fontSize)*.5;e.drawLine(y,t,y+s,t,r.textColor,.5)}y+=s}}return}let m=0,h=[];for(let e of c){let t=p(e),r=n.measureText(e.text,t,e.fontSize);h.push({resourceName:t,width:r}),m+=r}let g=h[0]?.resourceName??`F1`,_=Tb(o,i,d,n.getFontAscent(g,u)),v=Eb(a,i,m,r);for(let t=0;t<c.length;t++){let r=c[t],{resourceName:i}=h[t];e.setFillColor(r.textColor),e.beginText(),e.setFont(i,r.fontSize),e.setTextMatrix(1,0,0,1,v,_);let a=n.encodeText(r.text,i);a?e.showTextHex(a):e.showText(r.text),e.endText();let o=h[t].width;if(r.strike){let t=_+n.getFontDescent(i,r.fontSize)+r.fontSize*.3;e.drawLine(v,t,v+o,t,r.textColor,.5)}if(r.underline){let t=_+n.getFontDescent(i,r.fontSize)*.5;e.drawLine(v,t,v+o,t,r.textColor,.5)}v+=h[t].width}}function xb(e,t,n,r){let{rect:i,text:a}=t,{fontSize:o}=t,s=n.hasEmbeddedFont()?n.getEmbeddedResourceName():n.ensureFont(my(t.fontFamily,t.bold,t.italic)),c;c=typeof t.textRotation==`number`?t.textRotation<=90?t.textRotation:-(t.textRotation-90):0;let l=c*Math.PI/180,u=Math.cos(l),d=Math.sin(l),f=n.measureText(a,s,o),p=Math.abs(d),m=Math.abs(u),h=f*m+o*p,g=f*p+o*m,_=i.width-6,v=i.height-4;if(_>0&&v>0&&(h>_||g>v)){let e=Math.min(_/h,v/g);e<1&&(o*=e)}let y=t.horizontalAlign===`left`?r/2:t.horizontalAlign===`right`?-r/2:0,b=i.x+i.width/2+y,x=i.y+i.height/2,S=n.measureText(a,s,o),ee=n.getFontAscent(s,o),C=-S/2,te=-ee/2,ne=b+C*u-te*d,w=x+C*d+te*u;e.setFillColor(t.textColor),e.beginText(),e.setFont(s,o),e.setTextMatrix(u,d,-d,u,ne,w);let T=n.encodeText(a,s);T?e.showTextHex(T):e.showText(a),e.endText()}function Sb(e,t,n,r){let{rect:i,text:a,fontSize:o}=t,s=n.hasEmbeddedFont()?n.getEmbeddedResourceName():n.ensureFont(my(t.fontFamily,t.bold,t.italic)),c=o*1.3,l=n.getFontAscent(s,o),u=i.x+i.width/2,d=i.y+i.height-2-l;e.setFillColor(t.textColor);for(let t=0;t<a.length&&!(d<i.y+2);t++){let r=a[t],i=n.measureText(r,s,o);e.beginText(),e.setFont(s,o),e.setTextMatrix(1,0,0,1,u-i/2,d);let l=n.encodeText(r,s);l?e.showTextHex(l):e.showText(r),e.endText(),d-=c}}function Cb(e){return`GS${Math.round(e*1e4)}`}let wb=10;function Tb(e,t,n,r){let i;switch(e){case`top`:i=t.y+t.height-2-r;break;case`middle`:i=t.y+t.height/2+n/2-r;break;default:i=t.y+2+(n-r);break}let a=t.y+t.height-2-r;i>a&&(i=a);let o=t.y+2;return i<o&&(i=o),i}function Eb(e,t,n,r=0){let i;switch(e){case`center`:i=t.x+(t.width-n)/2;break;case`right`:i=t.x+t.width-3-n;break;default:i=t.x+3+r;break}let a=t.x+3;return i<a&&(i=a),i}function Db(e,t,n,r,i,a,o,s,c){if(t.strike){let l=i+s.getFontDescent(o,t.fontSize)+t.fontSize*.3;for(let i=0;i<n.length;i++){let o=l-i*r,s=a(n[i]),u=Eb(t.horizontalAlign,t.rect,s,c);e.drawLine(u,o,u+s,o,t.textColor,.5)}}if(t.underline){let l=s.getFontDescent(o,t.fontSize)*.5;for(let o=0;o<n.length;o++){let s=i-o*r+l,u=a(n[o]),d=Eb(t.horizontalAlign,t.rect,u,c);e.drawLine(d,s,d+u,s,t.textColor,.5)}}}function Ob(e,t,n){if(!e)return[``];let r=e.split(/\r?\n/),i=[];for(let e of r){if(!e){i.push(``);continue}let r=e.split(/\s+/),a=``;for(let e of r){if(!a){a=e;continue}let r=a+` `+e;t(r)<=n?a=r:(i.push(a),a=e)}a&&i.push(a)}return i.length>0?i:[``]}function kb(e,t,n,r){let i=t.sheetName,a=r.hasEmbeddedFont()?r.getEmbeddedResourceName():r.ensureFont(my(n.defaultFontFamily,!0,!1)),o=r.measureText(i,a,10),s=(t.width-o)/2,c=t.height-n.margins.top+5;e.save(),e.setFillColor({r:.3,g:.3,b:.3}),e.beginText(),e.setFont(a,10),e.setTextMatrix(1,0,0,1,s,c);let l=r.encodeText(i,a);l?e.showTextHex(l):e.showText(i),e.endText(),e.restore()}function Ab(e,t,n,r,i){let a=`Page ${t.pageNumber} of ${i}`,o=r.ensureFont(my(n.defaultFontFamily,!1,!1)),s=r.measureText(a,o,9),c=(t.width-s)/2,l=Math.max(5,n.margins.bottom-15);e.save(),e.setFillColor({r:.5,g:.5,b:.5}),e.beginText(),e.setFont(o,9),e.setTextMatrix(1,0,0,1,c,l),e.showText(a),e.endText(),e.restore()}let jb=1e8;function Mb(e){if(e.length<8||e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71)throw Error(`Invalid PNG signature`);let t=8,n=0,r=0,i=0,a=0,o=[],s=null,c=null;for(;t+8<=e.length;){let l=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t,!1),u=String.fromCharCode(e[t+4],e[t+5],e[t+6],e[t+7]),d=e.subarray(t+8,t+8+l);switch(t+=8+l+4,u){case`IHDR`:{let e=new DataView(d.buffer,d.byteOffset,d.byteLength);if(n=e.getUint32(0,!1),r=e.getUint32(4,!1),i=d[8],a=d[9],d[12]!==0)throw Error(`Interlaced PNG is not supported`);if(i!==8)throw Error(`Unsupported PNG bit depth: ${i}. Only 8-bit PNGs are supported.`);if(n===0||r===0)throw Error(`Invalid PNG dimensions: ${n}x${r}`);let t=n*r;if(t>jb)throw Error(`PNG dimensions too large: ${n}x${r} (${t} pixels). Maximum allowed: ${jb} pixels.`);break}case`PLTE`:s=new Uint8Array(d);break;case`tRNS`:c=new Uint8Array(d);break;case`IDAT`:o.push(d);break;case`IEND`:break}}if(n===0||r===0)throw Error(`PNG missing IHDR chunk`);let l=k(o),u;u=l.length>6&&(l[0]&15)==8?l.subarray(2,l.length-4):l;let d=ad(u),f=Fb(a),p=Math.max(1,f*i/8),m=Math.ceil(n*f*i/8);return Ib(Nb(d,n,r,m,p),n,r,a,i,s,c)}function Nb(e,t,n,r,i){let a=new Uint8Array(n*r),o=Math.max(1,Math.floor(i)),s=0;for(let t=0;t<n;t++){let n=e[s++],i=t*r,c=t>0?(t-1)*r:-1;for(let t=0;t<r;t++){let r=e[s++]??0,l=t>=o?a[i+t-o]:0,u=c>=0?a[c+t]:0,d=c>=0&&t>=o?a[c+t-o]:0;switch(n){case 0:a[i+t]=r;break;case 1:a[i+t]=r+l&255;break;case 2:a[i+t]=r+u&255;break;case 3:a[i+t]=r+Math.floor((l+u)/2)&255;break;case 4:a[i+t]=r+Pb(l,u,d)&255;break;default:a[i+t]=r}}}return a}function Pb(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function Fb(e){switch(e){case 0:return 1;case 2:return 3;case 3:return 1;case 4:return 2;case 6:return 4;default:return 3}}function Ib(e,t,n,r,i,a,o){let s=t*n,c=new Uint8Array(s*3),l=null;switch(r){case 2:if(c.set(e.subarray(0,s*3)),o&&o.length>=6){let t=o[1],n=o[3],r=o[5];l=new Uint8Array(s),l.fill(255);for(let i=0;i<s;i++)e[i*3]===t&&e[i*3+1]===n&&e[i*3+2]===r&&(l[i]=0)}break;case 6:l=new Uint8Array(s);for(let t=0;t<s;t++)c[t*3]=e[t*4],c[t*3+1]=e[t*4+1],c[t*3+2]=e[t*4+2],l[t]=e[t*4+3];break;case 0:{let t=-1;o&&o.length>=2&&(t=o[1]),t>=0&&(l=new Uint8Array(s),l.fill(255));for(let n=0;n<s;n++){let r=e[n];c[n*3]=r,c[n*3+1]=r,c[n*3+2]=r,l&&r===t&&(l[n]=0)}break}case 4:l=new Uint8Array(s);for(let t=0;t<s;t++){let n=e[t*2];c[t*3]=n,c[t*3+1]=n,c[t*3+2]=n,l[t]=e[t*2+1]}break;case 3:if(!a)throw Error(`PNG palette color type (3) but missing PLTE chunk`);o&&o.length>0&&(l=new Uint8Array(s));for(let t=0;t<s;t++){let n=e[t];c[t*3]=a[n*3]??0,c[t*3+1]=a[n*3+1]??0,c[t*3+2]=a[n*3+2]??0,l&&(l[t]=n<o.length?o[n]:255)}break;default:throw Error(`Unsupported PNG color type: ${r}`)}if(l){let e=!0;for(let t=0;t<l.length;t++)if(l[t]!==255){e=!1;break}e&&(l=null)}return{width:t,height:n,pixels:c,alpha:l,bitsPerComponent:8}}function Lb(e,t){let n=Rb(e,t?.sheets);if(n.length===0)throw new wv(`No sheets to export. The workbook is empty or no sheets matched.`);let r=new hy,i=new Uv;if(t?.font)try{let e=xy(t.font);r.registerEmbeddedFont(e)}catch(e){throw new Tv(`Failed to parse TrueType font`,{cause:e})}let a=[];for(let e of n)try{let n=Yy(e,zb(t,e),r);a.push(...n)}catch(t){throw new Tv(`Failed to layout sheet "${e.name}"`,{cause:t})}let o=zb(t,n[0]);a.length===0&&a.push({pageNumber:1,options:o,cells:[],width:o.pageSize.width,height:o.pageSize.height,sheetName:n[0]?.name??`Sheet1`,sheetCols:[],columnOffsets:[],columnWidths:[],sheetRows:[],rowYPositions:[],rowHeights:[],images:[]});for(let e=0;e<a.length;e++)a[e].pageNumber=e+1;let s=a.length;if(r.hasEmbeddedFont())for(let e of a)e.options.showSheetNames&&r.trackText(e.sheetName);for(let e of a)e.options.showPageNumbers&&r.ensureFont(my(e.options.defaultFontFamily,!1,!1));if(!r.hasEmbeddedFont())for(let e of a)e.options.showSheetNames&&r.ensureFont(my(e.options.defaultFontFamily,!0,!1));let c=r.writeFontResources(i),l=[],u=i.allocObject(),d=new Map;for(let e of a)try{let{stream:t,alphaValues:n}=mb(e,e.options,r,s),a=new Map;if(e.images.length>0)for(let n=0;n<e.images.length;n++){let r=e.images[n],o=`Im${n+1}`,s=Wb(i,r.data,r.format);a.set(o,s),t.drawImage(o,r.rect.x,r.rect.y,r.rect.width,r.rect.height)}let o=i.allocObject(),f=new $;i.addStreamObject(o,f,t);let p=i.allocObject(),m=r.buildFontDictString(c),h=new $().set(`Font`,m);if(a.size>0){let e=[`<<`];for(let[t,n]of a)e.push(`/${t} ${Q(n)}`);e.push(`>>`),h.set(`XObject`,e.join(`
447
- `))}if(n.size>0){let e=[`<<`];for(let t of n){let n=i.allocObject(),r=new $().set(`Type`,`/ExtGState`).set(`ca`,Z(t)).set(`CA`,Z(t));i.addObject(n,r),e.push(`/${Cb(t)} ${Q(n)}`)}e.push(`>>`),h.set(`ExtGState`,e.join(`
448
- `))}i.addObject(p,h);let g=[];for(let t of e.cells)if(t.hyperlink){let e=i.allocObject(),n=`[${Z(t.rect.x)} ${Z(t.rect.y)} ${Z(t.rect.x+t.rect.width)} ${Z(t.rect.y+t.rect.height)}]`,r=new $().set(`Type`,`/Annot`).set(`Subtype`,`/Link`).set(`Rect`,n).set(`Border`,`[0 0 0]`).set(`A`,`<< /Type /Action /S /URI /URI (${t.hyperlink.replace(/[()\\]/g,`\\$&`)}) >>`);i.addObject(e,r),g.push(e)}let _=i.addPage({parentRef:u,width:e.width,height:e.height,contentsRef:o,resourcesRef:p,annotRefs:g.length>0?g:void 0});l.push(_),d.has(e.sheetName)||d.set(e.sheetName,l.length-1)}catch(t){throw new Tv(`Failed to render page ${e.pageNumber} of "${e.sheetName}"`,{cause:t})}let f=`[`+l.map(e=>Q(e)).join(` `)+`]`,p=new $().set(`Type`,`/Pages`).set(`Kids`,f).set(`Count`,String(l.length));i.addObject(u,p);let m;if(d.size>1&&(m=Ub(i,d,l)),i.addCatalog(u,m),i.addInfoDict({title:o.title||e.title||void 0,author:o.author||e.creator||void 0,subject:o.subject||e.subject||void 0,creator:o.creator}),t?.encryption){let e=Av(t.encryption);i.setEncryption(e)}return i.build()}function Rb(e,t){let n=e.sheets;if(!t||t.length===0)return n.filter(e=>e.state!==`hidden`&&e.state!==`veryHidden`);let r=[];for(let e of t)if(typeof e==`string`){let t=n.find(t=>t.name.toLowerCase()===e.toLowerCase());t&&r.push(t)}else if(typeof e==`number`){let t=n[e-1];t&&r.push(t)}return r}function zb(e,t){let n=t?.pageSetup,r=Vb(e?.pageSize,n?.paperSize),i=e?.orientation??(n?.orientation===`landscape`?`landscape`:`portrait`),a=Hb(e?.margins,n?.margins),o=Fy(e?.gridLineColor??`FFD0D0D0`)??{r:.816,g:.816,b:.816},s=e?.repeatRows??!1;if(s===!1&&n?.printTitlesRow){let e=n.printTitlesRow.match(/^(\d+)(?::(\d+))?$/);e&&(s=parseInt(e[2]??e[1],10))}return{pageSize:r,orientation:i,margins:a,fitToPage:e?.fitToPage===void 0?!0:e.fitToPage,scale:Math.max(.1,Math.min(3,e?.scale??(n?.scale?n.scale/100:1))),showGridLines:e?.showGridLines??n?.showGridLines??!1,gridLineColor:o,repeatRows:s,defaultFontFamily:e?.defaultFontFamily??`Helvetica`,defaultFontSize:e?.defaultFontSize??11,showSheetNames:e?.showSheetNames??!1,showPageNumbers:e?.showPageNumbers??!1,title:e?.title??``,author:e?.author??``,subject:e?.subject??``,creator:e?.creator??`excelts`}}let Bb={1:gv.LETTER,5:gv.LEGAL,9:gv.A4,8:gv.A3,11:gv.A5,17:gv.TABLOID};function Vb(e,t){return e?typeof e==`string`?gv[e]??gv.A4:e:t===void 0?gv.A4:Bb[t]??gv.A4}function Hb(e,t){let n=t?{top:t.top*72,right:t.right*72,bottom:t.bottom*72,left:t.left*72}:{top:72,right:72,bottom:72,left:72};return e?{top:e.top??n.top,right:e.right??n.right,bottom:e.bottom??n.bottom,left:e.left??n.left}:n}function Ub(e,t,n){let r=e.allocObject(),i=Array.from(t.entries()),a=[];for(let t=0;t<i.length;t++)a.push(e.allocObject());for(let t=0;t<i.length;t++){let[o,s]=i[t],c=n[s],l=new $().set(`Title`,_v(o)).set(`Parent`,Q(r)).set(`Dest`,`[${Q(c)} /Fit]`);t>0&&l.set(`Prev`,Q(a[t-1])),t<i.length-1&&l.set(`Next`,Q(a[t+1])),e.addObject(a[t],l)}let o=new $().set(`Type`,`/Outlines`).set(`First`,Q(a[0])).set(`Last`,Q(a[a.length-1])).set(`Count`,String(i.length));return e.addObject(r,o),r}function Wb(e,t,n){return n===`png`?Kb(e,t):Gb(e,t)}function Gb(e,t){let n=e.allocObject(),r=qb(t),i=new $().set(`Type`,`/XObject`).set(`Subtype`,`/Image`).set(`Width`,Z(r.width)).set(`Height`,Z(r.height)).set(`ColorSpace`,`/DeviceRGB`).set(`BitsPerComponent`,`8`).set(`Filter`,`/DCTDecode`);return e.addStreamObject(n,i,t),n}function Kb(e,t){let n=Mb(t),r=e.allocObject(),i=new $().set(`Type`,`/XObject`).set(`Subtype`,`/Image`).set(`Width`,Z(n.width)).set(`Height`,Z(n.height)).set(`ColorSpace`,`/DeviceRGB`).set(`BitsPerComponent`,Z(n.bitsPerComponent));if(n.alpha){let t=e.allocObject(),r=new $().set(`Type`,`/XObject`).set(`Subtype`,`/Image`).set(`Width`,Z(n.width)).set(`Height`,Z(n.height)).set(`ColorSpace`,`/DeviceGray`).set(`BitsPerComponent`,`8`);e.addStreamObject(t,r,n.alpha),i.set(`SMask`,Q(t))}return e.addStreamObject(r,i,n.pixels),r}function qb(e){let t=2;for(;t<e.length-1;){for(;t<e.length&&e[t]===255&&e[t+1]===255;)t++;if(t>=e.length-1||e[t]!==255)break;let n=e[t+1];if(n>=192&&n<=207&&n!==196&&n!==200&&n!==204){if(t+8<e.length){let n=e[t+5]<<8|e[t+6];return{width:e[t+7]<<8|e[t+8],height:n}}break}if(t+3>=e.length)break;let r=e[t+2]<<8|e[t+3];t+=2+r}return{width:1,height:1}}function Jb(e,t){return Lb(Yb(e),t)}function Yb(e){return Array.isArray(e)?{sheets:[Xb({data:e})]}:`sheets`in e?{title:e.title,creator:e.author,sheets:e.sheets.map((e,t)=>Xb(e,t))}:{sheets:[Xb(e)]}}function Xb(e,t){let n=e.data,r=e.name??`Sheet${(t??0)+1}`,i=e.columns?.map(e=>typeof e==`number`?void 0:e.header),a=i?.some(e=>e!==void 0)??!1,o=0;for(let e of n)e.length>o&&(o=e.length);let s=Math.max(o,e.columns?.length??0),c=n.length+(a?1:0);if(e.images)for(let t of e.images){let e=t.col+1,n=t.row+1;e>s&&(s=e),n>c&&(c=n)}if(s===0)return{name:r,bounds:{top:0,left:0,bottom:0,right:0},columns:new Map,rows:new Map};let l=new Map;if(e.columns)for(let t=0;t<e.columns.length;t++){let n=e.columns[t],r=typeof n==`number`?n:n.width;l.set(t+1,{width:r??12})}for(let e=1;e<=s;e++)l.has(e)||l.set(e,{width:12});let u=new Map,d=1;if(a&&i){let e=new Map;for(let t=0;t<i.length;t++){let n=i[t];n!==void 0&&e.set(t+1,{type:X.String,value:n,text:n,col:t+1,style:{font:{bold:!0}}})}u.set(1,{cells:e}),d=2}for(let e=0;e<n.length;e++){let t=e+d,r=n[e],i=new Map;for(let e=0;e<r.length;e++){let t=Zb(r[e],e+1);t&&i.set(e+1,t)}u.set(t,{cells:i})}let f;if(e.images&&e.images.length>0){f=e.images.map(e=>({data:e.data,format:e.format,range:{tl:{col:e.col,row:e.row},ext:{width:e.width,height:e.height}}}));for(let e=1;e<=s;e++)l.has(e)||l.set(e,{width:12});for(let e=1;e<=c;e++)u.has(e)||u.set(e,{cells:new Map})}return{name:r,bounds:{top:1,left:1,bottom:c,right:s},columns:l,rows:u,images:f}}function Zb(e,t){if(e==null)return null;if(typeof e==`object`&&!(e instanceof Date)&&`value`in e){let n=e,r=Zb(n.value,t);if(!r)return null;let i={};return(n.bold||n.italic||n.fontSize||n.fontColor)&&(i.font={bold:n.bold,italic:n.italic,size:n.fontSize,color:n.fontColor?{argb:n.fontColor}:void 0}),n.fillColor&&(i.fill={type:`pattern`,pattern:`solid`,fgColor:{argb:n.fillColor}}),n.align&&(i.alignment={horizontal:n.align}),r.style=i,r}return typeof e==`string`?{type:X.String,value:e,text:e,col:t}:typeof e==`number`?{type:X.Number,value:e,text:String(e),col:t}:typeof e==`boolean`?{type:X.Boolean,value:e,text:e?`TRUE`:`FALSE`,col:t}:e instanceof Date?{type:X.Date,value:e,text:e.toLocaleDateString(),col:t}:null}function Qb(e,t){return Lb($b(e),t)}function $b(e){return{title:e.title||void 0,creator:e.creator||void 0,subject:e.subject||void 0,sheets:e.worksheets.map(t=>ex(t,e))}}function ex(e,t){let n=e.dimensions,r=n&&n.model.top>0&&n.model.left>0,i=r?{top:n.model.top,left:n.model.left,bottom:n.model.bottom,right:n.model.right}:{top:0,left:0,bottom:0,right:0},a=new Map;if(r)for(let t=i.left;t<=i.right;t++){let n=e.getColumn(t);a.set(t,{hidden:n.hidden||void 0,width:n.width??void 0})}let o=new Map;if(r)for(let t=i.top;t<=i.bottom;t++){let n=e.findRow(t);if(!n)continue;let r=new Map;n.eachCell({includeEmpty:!1},e=>{r.set(e.col,tx(e))}),o.set(t,{hidden:n.hidden||void 0,height:n.height??void 0,cells:r})}let s=e.hasMerges&&e.model.mergeCells?[...e.model.mergeCells]:void 0,c=e.pageSetup,l=c?{orientation:c.orientation,paperSize:c.paperSize,margins:c.margins?{left:c.margins.left,right:c.margins.right,top:c.margins.top,bottom:c.margins.bottom}:void 0,scale:c.scale,printTitlesRow:c.printTitlesRow,showGridLines:c.showGridLines,printArea:c.printArea}:void 0,u=e.rowBreaks?.map(e=>e.id),d=e.colBreaks?.map(e=>e.id),f=px(e,t);if(f){for(let e of f){let t=e.range.tl,n=(t.nativeCol??t.col??0)+1,r=(t.nativeRow??t.row??0)+1;if(i.top===0&&i.left===0&&(i.top=1,i.left=1),n>i.right&&(i.right=n),r>i.bottom&&(i.bottom=r),e.range.br){let t=e.range.br,n=(t.nativeCol??t.col??0)+1,r=(t.nativeRow??t.row??0)+1;n>i.right&&(i.right=n),r>i.bottom&&(i.bottom=r)}}for(let t=i.left;t<=i.right;t++)if(!a.has(t)){let n=e.getColumn(t);a.set(t,{hidden:n.hidden||void 0,width:n.width??void 0})}for(let e=i.top;e<=i.bottom;e++)o.has(e)||o.set(e,{cells:new Map})}return{name:e.name,state:e.state??`visible`,bounds:i,columns:a,rows:o,merges:s,pageSetup:l,rowBreaks:u,colBreaks:d,images:f}}function tx(e){let t=nx(e.type),n=rx(e),r=ox(e.style);return{type:t,value:ax(e),text:n,style:r,hyperlink:e.hyperlink||void 0,result:e.result??void 0,col:e.col}}function nx(e){switch(e){case E.Null:return X.Empty;case E.Merge:return X.Merge;case E.Number:return X.Number;case E.String:case E.SharedString:return X.String;case E.Date:return X.Date;case E.Hyperlink:return X.Hyperlink;case E.Formula:return X.Formula;case E.RichText:return X.RichText;case E.Boolean:return X.Boolean;case E.Error:return X.Error;default:return X.String}}function rx(e){if(!e)return``;switch(e.type){case E.Null:case E.Merge:return``;case E.RichText:case E.Hyperlink:return e.text??``;case E.Error:return e.value?.error??e.text??``;case E.Formula:{let t=e.result;return t==null?e.text??``:typeof t==`object`&&`error`in t?t.error:ix(t,e.style?.numFmt)}default:{let t=e.value;return t==null?``:ix(t,e.style?.numFmt)}}}function ix(e,t){let n=typeof t==`string`?t:t?.formatCode;if(n&&(typeof e==`number`||e instanceof Date||typeof e==`boolean`))try{return Cn(e,n)}catch{}return e instanceof Date?e.toLocaleDateString():String(e)}function ax(e){if(e.type===E.RichText){let t=e.value;if(t?.richText)return{richText:t.richText.map(e=>({text:e.text,font:e.font?sx(e.font):void 0}))}}return e.value}function ox(e){if(e)return{font:e.font?sx(e.font):void 0,numFmt:e.numFmt,fill:e.fill?lx(e.fill):void 0,border:e.border?dx(e.border):void 0,alignment:e.alignment?fx(e.alignment):void 0}}function sx(e){return{name:e.name,size:e.size,bold:e.bold,italic:e.italic,strike:e.strike,underline:e.underline,color:e.color?cx(e.color):void 0}}function cx(e){return{argb:e.argb,theme:e.theme,tint:e.tint}}function lx(e){let t={type:e.type??`pattern`,pattern:e.pattern,fgColor:e.fgColor?cx(e.fgColor):void 0};return e.stops&&(t.stops=e.stops.map(e=>({color:cx(e.color)}))),t}function ux(e){return{style:e.style,color:e.color?cx(e.color):void 0}}function dx(e){return{top:e.top?ux(e.top):void 0,right:e.right?ux(e.right):void 0,bottom:e.bottom?ux(e.bottom):void 0,left:e.left?ux(e.left):void 0}}function fx(e){return{horizontal:e.horizontal,vertical:e.vertical,wrapText:e.wrapText,indent:e.indent,textRotation:e.textRotation}}function px(e,t){let n=e.getImages?.();if(!n||!Array.isArray(n)||n.length===0)return;let r=[];for(let e of n){if(!e.range?.tl)continue;let n=e.imageId,i=t.getImage?.(Number(n));if(!i)continue;let a;if(i.buffer instanceof Uint8Array?a=i.buffer:i.base64&&(a=st(i.base64)),!a||a.length===0)continue;let o=i.extension;o!==`jpeg`&&o!==`png`||r.push({data:a,format:o,range:{tl:{col:e.range.tl.col??0,row:e.range.tl.row??0,nativeCol:e.range.tl.nativeCol,nativeRow:e.range.tl.nativeRow,nativeColOff:e.range.tl.nativeColOff,nativeRowOff:e.range.tl.nativeRowOff},br:e.range.br?{col:e.range.br.col??0,row:e.range.br.row??0,nativeCol:e.range.br.nativeCol,nativeRow:e.range.br.nativeRow,nativeColOff:e.range.br.nativeColOff,nativeRowOff:e.range.br.nativeRowOff}:void 0,ext:e.range.ext?{width:e.range.ext.width,height:e.range.ext.height}:void 0}})}return r.length>0?r:void 0}return e.Anchor=Ve,e.BaseError=t,e.Cell=O,e.Column=Re,e.ColumnOutOfBoundsError=p,e.CsvFormatterStream=nv,e.CsvParserStream=z_,e.DataValidations=Qe,e.DateFormatter=tg,e.DateParser=$h,e.DefinedNames=ni,e.DocumentType=ae,e.Enums=D,e.ErrorValue=se,e.ExcelDownloadError=x,e.ExcelError=l,e.ExcelFileError=y,e.ExcelNotSupportedError=v,e.ExcelStreamStateError=b,e.FormCheckbox=at,e.FormulaType=re,e.Image=He,e.ImageError=C,e.InvalidAddressError=f,e.InvalidValueTypeError=g,e.MaxItemsExceededError=te,e.MergeConflictError=h,e.PageSizes=gv,e.PaperSize=hv,e.PdfError=wv,e.PdfFontError=Ev,e.PdfRenderError=Tv,e.PdfStructureError=Dv,e.PivotTableError=S,e.Range=T,e.ReadingOrder=oe,e.RelationshipType=ie,e.Row=Le,e.RowOutOfBoundsError=m,e.Table=Ze,e.TableError=ee,e.ValueType=E,e.Workbook=mv,e.WorkbookReader=Fh,e.WorkbookWriter=Rm,e.Worksheet=Zr,e.WorksheetNameError=d,e.WorksheetReader=Mh,e.WorksheetWriter=Pm,e.XmlParseError=_,e.base64ToUint8Array=st,e.concatUint8Arrays=k,e.createCsvFormatterStream=rv,e.createCsvParserStream=B_,e.dateToExcel=ct,e.decodeCell=qr,e.decodeCol=Ur,e.decodeRange=Yr,e.decodeRow=Gr,e.encodeCell=Jr,e.encodeCol=Wr,e.encodeRange=Xr,e.encodeRow=Kr,e.errorToJSON=o,e.excelToDate=lt,e.excelToPdf=Qb,e.getErrorChain=s,e.getRootCause=c,e.getSupportedFormats=ng,e.isExcelError=u,e.isPdfError=Ov,e.pdf=Jb,e.stringToUint8Array=Hn,e.toError=a,e.toUint8Array=Wn,e.uint8ArrayToBase64=Ft,e.uint8ArrayToString=Un,e.xmlDecode=vt,e.xmlEncode=bt,e})({});
442
+ `;let g=e.encode(h);return t.push(g),k(t)}};function Kv(e,t,n,r){let i=new TextEncoder,a=[],o=0;for(;o<e.length;)if(e[o]===`(`){let s=o;o++;let c=``,l=1;for(;o<e.length&&l>0;){let t=e[o];t===`\\`?(c+=e[o]+(e[o+1]??``),o+=2):t===`(`?(l++,c+=t,o++):t===`)`?(l--,l>0&&(c+=t),o++):(c+=t,o++)}if(l!==0){a.push(e.slice(s,o));continue}let u=qv(c),d=Nv(i.encode(u),t,n,r);a.push(bv(d))}else if(e[o]===`<`&&e[o+1]===`<`)a.push(`<<`),o+=2;else if(e[o]===`>`&&e[o+1]===`>`)a.push(`>>`),o+=2;else if(e[o]===`<`){o++;let i=``;for(;o<e.length&&e[o]!==`>`;)i+=e[o],o++;o<e.length&&o++;let s=i.replace(/\s/g,``);if(s.length===0){a.push(`<>`);continue}let c=new Uint8Array(Math.ceil(s.length/2));for(let e=0;e<c.length;e++)c[e]=parseInt(s.substring(e*2,e*2+2).padEnd(2,`0`),16);let l=Nv(c,t,n,r);a.push(bv(l))}else a.push(e[o]),o++;return a.join(``)}function qv(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r!==`\\`){t+=r;continue}let i=e[n+1];if(i===void 0){t+=`\\`;break}switch(i){case`n`:t+=`
443
+ `;break;case`r`:t+=`\r`;break;case`t`:t+=` `;break;case`(`:t+=`(`;break;case`)`:t+=`)`;break;case`\\`:t+=`\\`;break;default:t+=i;break}n++}return t}let Jv={32:278,33:278,34:355,35:556,36:556,37:889,38:667,39:191,40:333,41:333,42:389,43:584,44:278,45:333,46:278,47:278,48:556,49:556,50:556,51:556,52:556,53:556,54:556,55:556,56:556,57:556,58:278,59:278,60:584,61:584,62:584,63:556,64:1015,65:667,66:667,67:722,68:722,69:667,70:611,71:778,72:722,73:278,74:500,75:667,76:556,77:833,78:722,79:778,80:667,81:778,82:722,83:667,84:611,85:722,86:667,87:944,88:667,89:667,90:611,91:278,92:278,93:278,94:469,95:556,96:333,97:556,98:556,99:500,100:556,101:556,102:278,103:556,104:556,105:222,106:222,107:500,108:222,109:833,110:556,111:556,112:556,113:556,114:333,115:500,116:278,117:556,118:500,119:722,120:500,121:500,122:500,123:334,124:260,125:334,126:584},Yv={32:278,33:333,34:474,35:556,36:556,37:889,38:722,39:238,40:333,41:333,42:389,43:584,44:278,45:333,46:278,47:278,48:556,49:556,50:556,51:556,52:556,53:556,54:556,55:556,56:556,57:556,58:333,59:333,60:584,61:584,62:584,63:611,64:975,65:722,66:722,67:722,68:722,69:667,70:611,71:778,72:722,73:278,74:556,75:722,76:611,77:833,78:722,79:778,80:667,81:778,82:722,83:667,84:611,85:722,86:667,87:944,88:667,89:667,90:611,91:333,92:278,93:333,94:584,95:556,96:333,97:556,98:611,99:556,100:611,101:556,102:333,103:611,104:611,105:278,106:278,107:556,108:278,109:889,110:611,111:611,112:611,113:611,114:389,115:556,116:333,117:611,118:556,119:778,120:556,121:556,122:500,123:389,124:280,125:389,126:584},Xv={32:250,33:333,34:408,35:500,36:500,37:833,38:778,39:180,40:333,41:333,42:500,43:564,44:250,45:333,46:250,47:278,48:500,49:500,50:500,51:500,52:500,53:500,54:500,55:500,56:500,57:500,58:278,59:278,60:564,61:564,62:564,63:444,64:921,65:722,66:667,67:667,68:722,69:611,70:556,71:722,72:722,73:333,74:389,75:722,76:611,77:889,78:722,79:722,80:556,81:722,82:667,83:556,84:611,85:722,86:722,87:944,88:722,89:722,90:611,91:333,92:278,93:333,94:469,95:500,96:333,97:444,98:500,99:444,100:500,101:444,102:333,103:500,104:500,105:278,106:278,107:500,108:278,109:778,110:500,111:500,112:500,113:500,114:333,115:389,116:278,117:500,118:500,119:722,120:500,121:500,122:444,123:480,124:200,125:480,126:541},Zv={32:250,33:333,34:555,35:500,36:500,37:1e3,38:833,39:278,40:333,41:333,42:500,43:570,44:250,45:333,46:250,47:278,48:500,49:500,50:500,51:500,52:500,53:500,54:500,55:500,56:500,57:500,58:333,59:333,60:570,61:570,62:570,63:500,64:930,65:722,66:667,67:722,68:722,69:667,70:611,71:778,72:778,73:389,74:500,75:778,76:667,77:944,78:722,79:778,80:611,81:778,82:722,83:556,84:667,85:722,86:722,87:1e3,88:722,89:722,90:667,91:333,92:278,93:333,94:581,95:500,96:333,97:500,98:556,99:444,100:556,101:444,102:333,103:500,104:556,105:278,106:333,107:556,108:278,109:833,110:556,111:500,112:556,113:556,114:444,115:389,116:333,117:556,118:500,119:722,120:500,121:500,122:444,123:394,124:220,125:394,126:520},Qv={Helvetica:{ascent:718,descent:-207,capHeight:718,avgWidth:513,widths:Jv},"Helvetica-Bold":{ascent:718,descent:-207,capHeight:718,avgWidth:535,widths:Yv},"Helvetica-Oblique":{ascent:718,descent:-207,capHeight:718,avgWidth:513,widths:Jv},"Helvetica-BoldOblique":{ascent:718,descent:-207,capHeight:718,avgWidth:535,widths:Yv},"Times-Roman":{ascent:683,descent:-217,capHeight:662,avgWidth:478,widths:Xv},"Times-Bold":{ascent:683,descent:-217,capHeight:676,avgWidth:505,widths:Zv},"Times-Italic":{ascent:683,descent:-217,capHeight:653,avgWidth:478,widths:Xv},"Times-BoldItalic":{ascent:683,descent:-217,capHeight:669,avgWidth:505,widths:Zv},Courier:{ascent:629,descent:-157,capHeight:562,avgWidth:600,widths:null,monoWidth:600},"Courier-Bold":{ascent:629,descent:-157,capHeight:562,avgWidth:600,widths:null,monoWidth:600},"Courier-Oblique":{ascent:629,descent:-157,capHeight:562,avgWidth:600,widths:null,monoWidth:600},"Courier-BoldOblique":{ascent:629,descent:-157,capHeight:562,avgWidth:600,widths:null,monoWidth:600}};function $v(e,t){let n=Qv[t];return n?n.monoWidth===void 0?n.widths?.[e]??n.avgWidth:n.monoWidth:$v(e,`Helvetica`)}function ey(e,t,n){let r=0;for(let n=0;n<e.length;n++)r+=$v(e.charCodeAt(n),t);return r/1e3*n}function ty(e,t){return(Qv[e]??Qv.Helvetica).ascent/1e3*t}function ny(e,t){return(Qv[e]??Qv.Helvetica).descent/1e3*t}function ry(e,t){let n=Qv[e]??Qv.Helvetica;return(n.ascent-n.descent)/1e3*t}function iy(e,t,n,r){let{oldToNewGid:i,unicodeToCid:a,cidWidths:o,usedGlyphIds:s}=ay(t,n),c=oy(t,s,i),l=sd(c,{level:6}),u=e.allocObject(),d=new $().set(`Length`,Z(l.length)).set(`Length1`,Z(c.length)).set(`Filter`,`/FlateDecode`);e.addStreamObject(u,d,l);let f=1e3/t.unitsPerEm,p=e.allocObject(),m=new $().set(`Type`,`/FontDescriptor`).set(`FontName`,xv(t.postScriptName+`-Subset`)).set(`Flags`,Z(t.flags)).set(`FontBBox`,Sv(t.bbox.map(e=>Z(Math.round(e*f))))).set(`ItalicAngle`,Z(t.italicAngle)).set(`Ascent`,Z(Math.round(t.ascent*f))).set(`Descent`,Z(Math.round(t.descent*f))).set(`CapHeight`,Z(Math.round(t.capHeight*f))).set(`StemV`,Z(t.stemV)).set(`FontFile2`,Q(u));e.addObject(p,m);let h=dy(o,t.unitsPerEm),g=e.allocObject(),_=new $().set(`Type`,`/Font`).set(`Subtype`,`/CIDFontType2`).set(`BaseFont`,xv(t.postScriptName+`-Subset`)).set(`CIDSystemInfo`,`<< /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>`).set(`FontDescriptor`,Q(p)).set(`DW`,Z(1e3)).set(`W`,h).set(`CIDToGIDMap`,`/Identity`);e.addObject(g,_);let v=sd(uy(a),{level:6}),y=e.allocObject(),b=new $().set(`Length`,Z(v.length)).set(`Filter`,`/FlateDecode`);e.addStreamObject(y,b,v);let x=e.allocObject(),S=new $().set(`Type`,`/Font`).set(`Subtype`,`/Type0`).set(`BaseFont`,xv(t.postScriptName+`-Subset`)).set(`Encoding`,`/Identity-H`).set(`DescendantFonts`,Sv([Q(g)])).set(`ToUnicode`,Q(y));return e.addObject(x,S),{resourceName:r,fontObjNum:x,font:t,unicodeToCid:a,cidWidths:o}}function ay(e,t){let n=new Set,r=new Map;n.add(0);for(let i of t){let t=e.cmap.get(i);t!==void 0&&t>0&&(n.add(t),r.set(i,t))}let i=e.tables.get(`glyf`);if(i){let t=i.offset,r=new Set(n),a=Array.from(r);for(;a.length>0;){let i=fy(e,a.pop(),t);for(let e of i)r.has(e)||(r.add(e),n.add(e),a.push(e))}}let a=Array.from(n).sort((e,t)=>e-t),o=new Map;for(let e=0;e<a.length;e++)o.set(a[e],e);let s=new Map,c=Array(a.length).fill(0);c[0]=e.advanceWidths[0]??0;for(let[t,n]of r){let r=o.get(n);s.set(t,r),c[r]=e.advanceWidths[n]??0}return{oldToNewGid:o,unicodeToCid:s,cidWidths:c,usedGlyphIds:n}}function oy(e,t,n){let r=n.size,i=Array.from(t).sort((e,t)=>e-t),a=e.tables.get(`glyf`)?.offset??0,o=[],s=[],c=0;for(let t of i){s.push(c);let r=e.glyphOffsets[t],i=e.glyphOffsets[t+1],l=i-r;if(l>0){let t=py(e.data.subarray(a+r,a+i),n);o.push(t),c+=l;let s=(4-l%4)%4;s>0&&(o.push(new Uint8Array(s)),c+=s)}}s.push(c);let l=k(o),u=new Uint8Array((r+1)*4),d=new DataView(u.buffer);for(let e=0;e<=r;e++)d.setUint32(e*4,s[e]??c,!1);let f=new Uint8Array(r*4),p=new DataView(f.buffer);for(let t=0;t<i.length;t++){let n=i[t];p.setUint16(t*4,e.advanceWidths[n]??0,!1),p.setInt16(t*4+2,0,!1)}let m=sy(n,e.cmap),h=e.tables.get(`head`),g=new Uint8Array(e.data.subarray(h.offset,h.offset+h.length));new DataView(g.buffer,g.byteOffset,g.byteLength).setInt16(50,1,!1);let _=e.tables.get(`hhea`),v=new Uint8Array(e.data.subarray(_.offset,_.offset+_.length));new DataView(v.buffer,v.byteOffset,v.byteLength).setUint16(34,r,!1);let y=e.tables.get(`maxp`),b=new Uint8Array(e.data.subarray(y.offset,y.offset+y.length));new DataView(b.buffer,b.byteOffset,b.byteLength).setUint16(4,r,!1);let x=new Uint8Array(32);return new DataView(x.buffer).setUint32(0,196608,!1),cy([[`head`,g],[`hhea`,v],[`maxp`,b],[`post`,x],[`cmap`,m],[`hmtx`,f],[`loca`,u],[`glyf`,l]])}function sy(e,t){let n=[];for(let[r,i]of t){let t=e.get(i);t!==void 0&&n.push([r,t])}n.sort((e,t)=>e[0]-t[0]);let r=[];for(let[e,t]of n){let n=r[r.length-1];n&&e===n.endCP+1&&t===n.startGID+(e-n.startCP)?n.endCP=e:r.push({startCP:e,endCP:e,startGID:t})}let i=16+r.length*12,a=12+i,o=new Uint8Array(a),s=new DataView(o.buffer),c=0;s.setUint16(c,0,!1),c+=2,s.setUint16(c,1,!1),c+=2,s.setUint16(c,3,!1),c+=2,s.setUint16(c,10,!1),c+=2,s.setUint32(c,12,!1),c+=4,s.setUint16(c,12,!1),c+=2,s.setUint16(c,0,!1),c+=2,s.setUint32(c,i,!1),c+=4,s.setUint32(c,0,!1),c+=4,s.setUint32(c,r.length,!1),c+=4;for(let e of r)s.setUint32(c,e.startCP,!1),c+=4,s.setUint32(c,e.endCP,!1),c+=4,s.setUint32(c,e.startGID,!1),c+=4;return o}function cy(e){let t=e.length,n=12+t*16,r=[];for(let[t,i]of e){let e=i.length,a=e+3&-4,o=new Uint8Array(a);o.set(i),r.push({tag:t,data:o,originalLength:e,offset:n,checksum:ly(o)}),n+=a}let i=new Uint8Array(n),a=new DataView(i.buffer),o=0;a.setUint32(o,65536,!1),o+=4,a.setUint16(o,t,!1),o+=2;let s=2**Math.floor(Math.log2(t));a.setUint16(o,s*16,!1),o+=2,a.setUint16(o,Math.floor(Math.log2(t)),!1),o+=2,a.setUint16(o,t*16-s*16,!1),o+=2;for(let e of r){for(let t=0;t<4;t++)i[o++]=e.tag.charCodeAt(t);a.setUint32(o,e.checksum,!1),o+=4,a.setUint32(o,e.offset,!1),o+=4,a.setUint32(o,e.originalLength,!1),o+=4}for(let e of r)i.set(e.data,e.offset);return i}function ly(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=Math.floor(e.length/4);for(let e=0;e<r;e++)n=n+t.getUint32(e*4,!1)>>>0;return n}function uy(e){let t=new Map;for(let[n,r]of e)t.set(r,n);let n=Array.from(t.entries()).sort((e,t)=>e[0]-t[0]),r=[];r.push(`/CIDInit /ProcSet findresource begin`),r.push(`12 dict begin`),r.push(`begincmap`),r.push(`/CIDSystemInfo`),r.push(`<< /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def`),r.push(`/CMapName /Adobe-Identity-UCS def`),r.push(`/CMapType 2 def`),r.push(`1 begincodespacerange`),r.push(`<0000> <FFFF>`),r.push(`endcodespacerange`);for(let e=0;e<n.length;e+=100){let t=n.slice(e,e+100);r.push(`${t.length} beginbfchar`);for(let[e,n]of t){let t=e.toString(16).toUpperCase().padStart(4,`0`),i;if(n>65535){let e=55296+(n-65536>>10),t=56320+(n-65536&1023);i=e.toString(16).toUpperCase().padStart(4,`0`)+t.toString(16).toUpperCase().padStart(4,`0`)}else i=n.toString(16).toUpperCase().padStart(4,`0`);r.push(`<${t}> <${i}>`)}r.push(`endbfchar`)}r.push(`endcmap`),r.push(`CMapName currentdict /CMap defineresource pop`),r.push(`end`),r.push(`end`);let i=r.join(`
444
+ `);return new TextEncoder().encode(i)}function dy(e,t){if(e.length===0)return`[]`;let n=1e3/t;return`[0 [${e.map(e=>Z(Math.round(e*n))).join(` `)}]]`}function fy(e,t,n){let r=e.glyphOffsets[t];if(e.glyphOffsets[t+1]-r<4)return[];let i=new DataView(e.data.buffer,e.data.byteOffset,e.data.byteLength),a=n+r;if(i.getInt16(a,!1)>=0)return[];let o=a+10,s=[];for(;;){let e=i.getUint16(o,!1);o+=2;let t=i.getUint16(o,!1);if(o+=2,s.push(t),e&1?o+=4:o+=2,e&8?o+=2:e&64?o+=4:e&128&&(o+=8),!(e&32))break}return s}function py(e,t){if(e.length<10||new DataView(e.buffer,e.byteOffset,e.byteLength).getInt16(0,!1)>=0)return e;let n=new Uint8Array(e.length);n.set(e);let r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=10;for(;;){let e=r.getUint16(i,!1);i+=2;let n=r.getUint16(i,!1),a=t.get(n)??0;if(r.setUint16(i,a,!1),i+=2,e&1?i+=4:i+=2,e&8?i+=2:e&64?i+=4:e&128&&(i+=8),!(e&32))break}return n}let my={helvetica:`Helvetica`,arial:`Helvetica`,calibri:`Helvetica`,"segoe ui":`Helvetica`,"trebuchet ms":`Helvetica`,verdana:`Helvetica`,tahoma:`Helvetica`,"gill sans":`Helvetica`,"franklin gothic":`Helvetica`,"lucida sans":`Helvetica`,aptos:`Helvetica`,"times new roman":`Times`,times:`Times`,georgia:`Times`,garamond:`Times`,"book antiqua":`Times`,palatino:`Times`,"palatino linotype":`Times`,cambria:`Times`,"century schoolbook":`Times`,"courier new":`Courier`,courier:`Courier`,consolas:`Courier`,"lucida console":`Courier`,monaco:`Courier`,"andale mono":`Courier`,"cascadia code":`Courier`,"cascadia mono":`Courier`,menlo:`Courier`};function hy(e){return my[e.toLowerCase().trim()]??`Helvetica`}function gy(e,t,n){let r=hy(e);return r===`Helvetica`?t&&n?`Helvetica-BoldOblique`:t?`Helvetica-Bold`:n?`Helvetica-Oblique`:`Helvetica`:r===`Times`?t&&n?`Times-BoldItalic`:t?`Times-Bold`:n?`Times-Italic`:`Times-Roman`:r===`Courier`?t&&n?`Courier-BoldOblique`:t?`Courier-Bold`:n?`Courier-Oblique`:`Courier`:`Helvetica`}var _y=class{constructor(){this.type1Map=new Map,this.resourceToType1=new Map,this.nextType1Id=1,this.embeddedFont=null,this.embeddedResourceName=``,this.usedCodePoints=new Set,this.nextEmbeddedId=1,this._embeddedResult=null}registerEmbeddedFont(e){return this.embeddedFont=e,this.embeddedResourceName=`EF${this.nextEmbeddedId++}`,this.embeddedResourceName}hasEmbeddedFont(){return this.embeddedFont!==null}getEmbeddedResourceName(){return this.embeddedResourceName}trackText(e){if(this.embeddedFont)for(let t=0;t<e.length;t++){let n=e.codePointAt(t);this.usedCodePoints.add(n),n>65535&&t++}}ensureFont(e){let t=this.type1Map.get(e);return t||(t=`F${this.nextType1Id++}`,this.type1Map.set(e,t),this.resourceToType1.set(t,e)),t}resolveFont(e,t,n){if(this.embeddedFont)return this.embeddedResourceName;let r=gy(e,t,n);return this.ensureFont(r)}getPdfFontName(e){return this.resourceToType1.get(e)??`Helvetica`}measureText(e,t,n){return this.embeddedFont&&t===this.embeddedResourceName?yy(e,this.embeddedFont,n):ey(e,this.getPdfFontName(t),n)}getFontAscent(e,t){return this.embeddedFont&&e===this.embeddedResourceName?this.embeddedFont.ascent/this.embeddedFont.unitsPerEm*t:ty(this.getPdfFontName(e),t)}getFontDescent(e,t){return this.embeddedFont&&e===this.embeddedResourceName?this.embeddedFont.descent/this.embeddedFont.unitsPerEm*t:ny(this.getPdfFontName(e),t)}getLineHeight(e,t){if(this.embeddedFont&&e===this.embeddedResourceName){let e=this.embeddedFont;return(e.ascent-e.descent)/e.unitsPerEm*t}return ry(this.getPdfFontName(e),t)}isEmbeddedFont(e){return this.embeddedFont!==null&&e===this.embeddedResourceName}encodeText(e,t){if(!this.embeddedFont||t!==this.embeddedResourceName)return null;if(this._embeddedResult)return vy(e,this._embeddedResult.unicodeToCid);throw new Ov(`encodeText called before writeFontResources — subset mapping not available`)}writeFontResources(e){let t=new Map;for(let[n,r]of this.type1Map){let i=e.allocObject(),a=new $().set(`Type`,`/Font`).set(`Subtype`,`/Type1`).set(`BaseFont`,xv(n)).set(`Encoding`,`/WinAnsiEncoding`);e.addObject(i,a),t.set(r,i)}if(this.embeddedFont&&this.embeddedResourceName){let n=iy(e,this.embeddedFont,this.usedCodePoints,this.embeddedResourceName);t.set(this.embeddedResourceName,n.fontObjNum),this._embeddedResult=n}return t}getEmbeddedResult(){return this._embeddedResult}buildFontDictString(e){let t=[`<<`];for(let[n,r]of e)t.push(`${xv(n)} ${Q(r)}`);return t.push(`>>`),t.join(`
445
+ `)}getRegisteredFonts(){let e=[];for(let[t,n]of this.type1Map)e.push({resourceName:n,pdfFontName:t});return e}};function vy(e,t){let n=`<`;for(let r=0;r<e.length;r++){let i=e.codePointAt(r);i>65535&&r++;let a=t.get(i)??0;n+=a.toString(16).toUpperCase().padStart(4,`0`)}return n+=`>`,n}function yy(e,t,n){let r=0;for(let n=0;n<e.length;n++){let i=e.codePointAt(n);i>65535&&n++;let a=t.cmap.get(i)??0;r+=t.advanceWidths[a]??0}return r/t.unitsPerEm*n}let by=65536,xy=2e6;var Sy=class e{constructor(e,t=0){this.data=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.offset=t}u8(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}u16(){let e=this.view.getUint16(this.offset,!1);return this.offset+=2,e}i16(){let e=this.view.getInt16(this.offset,!1);return this.offset+=2,e}u32(){let e=this.view.getUint32(this.offset,!1);return this.offset+=4,e}i32(){let e=this.view.getInt32(this.offset,!1);return this.offset+=4,e}fixed(){return this.i32()/65536}bytes(e){let t=this.data.subarray(this.offset,this.offset+e);return this.offset+=e,t}tag(){return String.fromCharCode(this.u8(),this.u8(),this.u8(),this.u8())}skip(e){this.offset+=e}at(t){return new e(this.data,t)}u16At(e){return this.view.getUint16(e,!1)}u32At(e){return this.view.getUint32(e,!1)}i16At(e){return this.view.getInt16(e,!1)}};function Cy(e){let t=new Sy(e),n=t.u32();if(n!==65536&&n!==1953658213)throw n===1330926671?new Ov(`CFF-flavored OpenType (.otf) is not supported. Use a TrueType (.ttf) font.`):new Ov(`Invalid TrueType font: bad sfVersion 0x${n.toString(16)}`);let r=t.u16();t.skip(6);let i=new Map;for(let e=0;e<r;e++){let e=t.tag();t.skip(4);let n=t.u32(),r=t.u32();i.set(e,{offset:n,length:r})}for(let e of[`head`,`hhea`,`maxp`,`cmap`,`hmtx`])if(!i.has(e))throw new Ov(`Missing required table '${e}' in TrueType font`);let a=wy(t,i.get(`head`)),o=Ty(t,i.get(`hhea`)),s=Ey(t,i.get(`maxp`)),c=i.has(`OS/2`)?Dy(t,i.get(`OS/2`)):null,l=i.has(`post`)?Oy(t,i.get(`post`)):null,u=i.has(`name`)?ky(t,i.get(`name`)):null,d=Ay(t,i.get(`cmap`)),f=Ny(t,i.get(`hmtx`),o.numHMetrics,s.numGlyphs),p=i.has(`loca`)&&i.has(`glyf`)?Py(t,i.get(`loca`),s.numGlyphs,a.indexToLocFormat):new Uint32Array(s.numGlyphs+1),m=c?.sTypoAscender??o.ascent,h=c?.sTypoDescender??o.descent,g=c?.sCapHeight??Math.round(m*.7),_=0;l?.isFixedPitch&&(_|=1),a.macStyle&2&&(_|=64),_|=32;let v=c?.usWeightClass??400,y=Math.round(50+(v/65)**2),b=u?.familyName??`Unknown`;return{data:e,familyName:b,postScriptName:u?.postScriptName??b.replace(/\s+/g,``),unitsPerEm:a.unitsPerEm,ascent:m,descent:h,capHeight:g,italicAngle:l?.italicAngle??0,flags:_,bbox:[a.xMin,a.yMin,a.xMax,a.yMax],stemV:y,numGlyphs:s.numGlyphs,indexToLocFormat:a.indexToLocFormat,numHMetrics:o.numHMetrics,tables:i,cmap:d,advanceWidths:f,glyphOffsets:p}}function wy(e,t){let n=e.at(t.offset);n.skip(4),n.skip(4),n.skip(4),n.skip(4),n.skip(2);let r=n.u16();n.skip(16);let i=n.i16(),a=n.i16(),o=n.i16(),s=n.i16(),c=n.u16();return n.skip(2),n.skip(2),{unitsPerEm:r,xMin:i,yMin:a,xMax:o,yMax:s,macStyle:c,indexToLocFormat:n.i16()}}function Ty(e,t){let n=e.at(t.offset);n.skip(4);let r=n.i16(),i=n.i16(),a=n.i16();return n.skip(2),n.skip(22),{ascent:r,descent:i,lineGap:a,numHMetrics:n.u16()}}function Ey(e,t){let n=e.at(t.offset);return n.skip(4),{numGlyphs:n.u16()}}function Dy(e,t){let n=e.at(t.offset),r=n.u16();n.skip(2);let i=n.u16();n.skip(2),n.skip(2),n.skip(22),n.skip(10),n.skip(16),n.skip(4),n.skip(2),n.skip(2),n.skip(2);let a=n.i16(),o=n.i16();n.skip(2),n.skip(2),n.skip(2);let s;return r>=2?(n.skip(8),n.skip(2),s=n.i16()):s=Math.round(a*.7),{usWeightClass:i,sTypoAscender:a,sTypoDescender:o,sCapHeight:s}}function Oy(e,t){let n=e.at(t.offset);n.skip(4);let r=n.fixed();return n.skip(2),n.skip(2),{italicAngle:r,isFixedPitch:n.u32()!==0}}function ky(e,t){let n=t.offset,r=e.at(n);r.skip(2);let i=r.u16(),a=n+r.u16(),o=``,s=``;for(let t=0;t<i;t++){let t=r.u16(),n=r.u16();r.skip(2);let i=r.u16(),c=r.u16(),l=r.u16();if(i!==1&&i!==6)continue;let u=e.at(a+l).bytes(c),d;if(t===3||t===0)d=Fy(u);else if(t===1&&n===0)d=Iy(u);else continue;i===1&&!o&&(o=d),i===6&&!s&&(s=d)}return{familyName:o||`Unknown`,postScriptName:s||o||`Unknown`}}function Ay(e,t){let n=t.offset,r=e.at(n);r.skip(2);let i=r.u16(),a=-1,o=-1;for(let t=0;t<i;t++){let t=r.u16(),i=r.u16(),s=r.u32();if(!(t===0||t===3&&(i===1||i===10)))continue;let c=e.u16At(n+s);c===12&&o<0&&(o=n+s),c===4&&a<0&&(a=n+s)}if(o>=0)return My(e,o);if(a>=0)return jy(e,a);throw new Ov(`No usable Unicode cmap subtable found in font`)}function jy(e,t){let n=e.at(t);n.skip(2),n.skip(2),n.skip(2);let r=n.u16()/2;n.skip(6);let i=[];for(let e=0;e<r;e++)i.push(n.u16());n.skip(2);let a=[];for(let e=0;e<r;e++)a.push(n.u16());let o=[];for(let e=0;e<r;e++)o.push(n.i16());let s=n.offset,c=[];for(let e=0;e<r;e++)c.push(n.u16());let l=new Map;for(let t=0;t<r;t++){let n=a[t],r=i[t],u=o[t],d=c[t];if(n===65535)break;for(let i=n;i<=r;i++){let r;if(d===0)r=i+u&65535;else{let a=s+t*2+d+(i-n)*2;r=e.u16At(a),r!==0&&(r=r+u&65535)}r!==0&&l.set(i,r)}}return l}function My(e,t){let n=e.at(t);n.skip(2),n.skip(2),n.skip(4),n.skip(4);let r=n.u32();if(r>by)throw new Ov(`cmap format 12 has ${r} groups, exceeding limit of ${by}. The font file may be malicious or corrupted.`);let i=new Map,a=0;for(let e=0;e<r;e++){let e=n.u32(),t=n.u32(),r=n.u32(),o=t>=e?t-e+1:0;if(a+=o,a>xy)throw new Ov(`cmap format 12 maps too many codepoints (>${xy}). The font file may be malicious or corrupted.`);for(let n=e;n<=t;n++)i.set(n,r+(n-e))}return i}function Ny(e,t,n,r){let i=e.at(t.offset),a=new Uint16Array(r),o=0;for(let e=0;e<n;e++)o=i.u16(),i.skip(2),a[e]=o;for(let e=n;e<r;e++)a[e]=o;return a}function Py(e,t,n,r){let i=e.at(t.offset),a=new Uint32Array(n+1);if(r===0)for(let e=0;e<=n;e++)a[e]=i.u16()*2;else for(let e=0;e<=n;e++)a[e]=i.u32();return a}function Fy(e){let t=[];for(let n=0;n+1<e.length;n+=2){let r=e[n]<<8|e[n+1];if(r>=55296&&r<=56319&&n+3<e.length){let i=e[n+2]<<8|e[n+3];if(i>=56320&&i<=57343){t.push(String.fromCodePoint((r-55296<<10)+(i-56320)+65536)),n+=2;continue}}t.push(String.fromCharCode(r))}return t.join(``)}function Iy(e){let t=[];for(let n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join(``)}function Ly(e){if(!e||e.length<6)return null;let t,n,r,i;if(e.length>=8?(t=parseInt(e.substring(0,2),16),n=parseInt(e.substring(2,4),16),r=parseInt(e.substring(4,6),16),i=parseInt(e.substring(6,8),16)):(t=255,n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16)),isNaN(n)||isNaN(r)||isNaN(i))return null;let a=t/255;return{r:n/255,g:r/255,b:i/255,...a<1?{a}:{}}}function Ry(e){if(!e)return null;if(e.argb)return Ly(e.argb);if(e.theme!==void 0){let t=zy(e.theme);if(!t)return null;let n=e.tint;return n!==void 0&&n!==0?By(t,n):t}return null}function zy(e){let t=[{r:1,g:1,b:1},{r:0,g:0,b:0},{r:.918,g:.929,b:.941},{r:.267,g:.278,b:.298},{r:.263,g:.522,b:.839},{r:.922,g:.494,b:.196},{r:.624,g:.624,b:.624},{r:1,g:.753,b:0},{r:.314,g:.686,b:.886},{r:.439,g:.678,b:.278}];return e>=0&&e<t.length?t[e]:null}function By(e,t){let n=e=>t<0?e*(1+t):e+(1-e)*t;return{r:Math.max(0,Math.min(1,n(e.r))),g:Math.max(0,Math.min(1,n(e.g))),b:Math.max(0,Math.min(1,n(e.b)))}}let Vy={black:{r:0,g:0,b:0},white:{r:1,g:1,b:1},gridLine:{r:.816,g:.816,b:.816}};function Hy(e,t,n){return{fontFamily:e?.name??t,fontSize:e?.size??n,bold:e?.bold??!1,italic:e?.italic??!1,strike:e?.strike??!1,underline:!!(e?.underline&&e.underline!==`none`),textColor:Ry(e?.color)??Vy.black}}function Uy(e){if(!e)return null;if(e.type===`pattern`){if(e.pattern===`solid`&&e.fgColor)return Ry(e.fgColor);if(e.pattern===`none`)return null;if(e.fgColor)return Ry(e.fgColor)}return e.type===`gradient`&&e.stops&&e.stops.length>0?Ry(e.stops[0].color):null}function Wy(e){switch(e){case`thin`:return .5;case`medium`:return 1;case`thick`:return 1.5;case`double`:return .5;case`hair`:return .25;case`dotted`:return .5;case`dashed`:return .5;case`dashDot`:return .5;case`dashDotDot`:return .5;case`slantDashDot`:return .5;case`mediumDashed`:return 1;case`mediumDashDot`:return 1;case`mediumDashDotDot`:return 1;default:return .5}}function Gy(e){switch(e){case`dotted`:return[1,1];case`dashed`:case`mediumDashed`:return[3,2];case`dashDot`:case`mediumDashDot`:return[3,1,1,1];case`dashDotDot`:case`mediumDashDotDot`:return[3,1,1,1,1,1];case`slantDashDot`:return[4,2,1,2];case`hair`:return[.5,.5];default:return[]}}function Ky(e){return!e||!e.style?null:{width:Wy(e.style),color:Ry(e.color)??Vy.black,dashPattern:Gy(e.style)}}function qy(e){return e?{top:Ky(e.top),right:Ky(e.right),bottom:Ky(e.bottom),left:Ky(e.left)}:{top:null,right:null,bottom:null,left:null}}function Jy(e){if(!e?.horizontal)return`left`;switch(e.horizontal){case`center`:case`centerContinuous`:return`center`;case`right`:return`right`;default:return`left`}}function Yy(e){if(!e?.vertical)return`bottom`;switch(e.vertical){case`top`:return`top`;case`middle`:return`middle`;default:return`bottom`}}let Xy=8.43;function Zy(e,t,n){let{margins:r}=t,i=t.pageSize.width,a=t.pageSize.height;t.orientation===`landscape`&&([i,a]=[a,i]);let o=i-r.left-r.right,s=a-r.top-r.bottom,c=t.showSheetNames?20:0,l=t.showPageNumbers?20:0,u=s-c-l,d=tb(e),{columnWidths:f,visibleCols:p}=nb(e,d);if(p.length===0)return[Qy(i,a,e.name,t)];let m=f.reduce((e,t)=>e+t,0),h=t.scale;if(t.fitToPage&&m>0){let e=o/m;e<1&&(h*=e)}let g=f.map(e=>e*h),{rowHeights:_,visibleRows:v}=rb(e,h,d),y=ab(e),b=ob(_,u,typeof t.repeatRows==`number`?t.repeatRows:0,ib(e,v)),x=sb(g,o,e,p),S=[];for(let s of b)for(let l of x){let u=[],d=l.map(e=>g[e]),f=d.reduce((e,t)=>e+t,0),m=[],b=r.left;f<o&&(b=r.left+(o-f)/2);for(let e of d)m.push(b),b+=e;let x=[],ee=[],C=a-r.top-c;for(let e of s){let t=_[e]??15*h;x.push(C),ee.push(t),C-=t}for(let r=0;r<s.length;r++){let i=s[r],a=v[i];for(let o=0;o<l.length;o++){let s=p[l[o]],c=`${a}:${s}`,f=y.get(c);if(f&&!f.isMaster)continue;let g=e.rows.get(a)?.cells.get(s),_=1,b=1;if(f&&f.isMaster){let e=s+f.colSpan-1;_=0;for(let t=o;t<l.length&&p[l[t]]<=e;t++)_++;let t=a+f.rowSpan-1;b=0;for(let e=i;e<v.length&&v[e]<=t;e++)b++;_=Math.max(_,1),b=Math.max(b,1)}let S=m[o],C=x[r],te=0;for(let e=0;e<_&&o+e<d.length;e++)te+=d[o+e];let ne=0;for(let e=0;e<b&&r+e<ee.length;e++)ne+=ee[r+e];let w=C-ne;u.push(cb(g,S,w,te,ne,_,b,t,n,h))}}S.push({pageNumber:S.length+1,options:t,cells:u,width:i,height:a,sheetName:e.name,sheetCols:l.map(e=>p[e]),columnOffsets:m,columnWidths:d,sheetRows:s.map(e=>v[e]),rowYPositions:x,rowHeights:ee,images:[]})}return S.length>0&&e.images&&lb(e.images,S),S}function Qy(e,t,n,r){return{pageNumber:1,options:r,cells:[],width:e,height:t,sheetName:n,sheetCols:[],columnOffsets:[],columnWidths:[],sheetRows:[],rowYPositions:[],rowHeights:[],images:[]}}function $y(e){let t=e.replace(/\$/g,``).toUpperCase(),n=0,r=0;for(;r<t.length&&t.charCodeAt(r)>=65&&t.charCodeAt(r)<=90;)n=n*26+(t.charCodeAt(r)-64),r++;let i=parseInt(t.substring(r),10);return{c:n-1,r:i-1}}function eb(e){let t=e.indexOf(`:`);if(t===-1){let t=$y(e);return{s:t,e:{...t}}}return{s:$y(e.slice(0,t)),e:$y(e.slice(t+1))}}function tb(e){let t=e.pageSetup?.printArea;if(!t||typeof t!=`string`)return null;let n=t.split(`&&`)[0].trim();if(!n)return null;try{let e=eb(n);return{startRow:e.s.r+1,endRow:e.e.r+1,startCol:e.s.c+1,endCol:e.e.c+1}}catch{return null}}function nb(e,t){let n=e.bounds;if(!(n.top>0&&n.left>0))return{columnWidths:[],visibleCols:[]};let r=t?.startCol??n.left,i=t?.endCol??n.right,a=[],o=[];for(let t=r;t<=i;t++){let n=e.columns.get(t);if(n?.hidden)continue;let r=n?.width??Xy,i=Math.max(r*7,5);a.push(i),o.push(t)}return{columnWidths:a,visibleCols:o}}function rb(e,t,n){let r=e.bounds;if(r.top<=0)return{rowHeights:[],visibleRows:[]};let i=n?.startRow??r.top,a=n?.endRow??r.bottom,o=[],s=[];for(let n=i;n<=a;n++){let r=e.rows.get(n);if(r&&r.hidden)continue;let i;if(r?.height)i=r.height;else if(i=15,r)for(let n of r.cells.values()){let r=n.style?.font?.size??11,a=n.value;if(a?.richText)for(let e of a.richText){let t=e.font?.size??r;t>r&&(r=t)}let o=r*1.5,s=n.text??``,c=Math.max(1,(s.match(/\n/g)??[]).length+1),l=c;if(n.style?.alignment?.wrapText&&c===1&&s.length>0){let i=(e.columns.get(n.col)?.width??Xy)*7*t,a=r*.55,o=Math.max(1,Math.floor(i/a));l=Math.ceil(s.length/o)}let u=o*l;u>i&&(i=u)}o.push(i*t),s.push(n)}return{rowHeights:o,visibleRows:s}}function ib(e,t){let n=new Set,r=e.rowBreaks??[];if(r.length===0)return n;let i=new Map;for(let e=0;e<t.length;e++)i.set(t[e],e);for(let e of r){let t=i.get(e);t!==void 0&&n.add(t+1)}return n}function ab(e){let t=new Map,n=e.merges;if(!n||n.length===0)return t;for(let e of n){let n=eb(e),r=n.s.r+1,i=n.s.c+1,a=n.e.r+1,o=n.e.c+1,s=a-r+1,c=o-i+1;for(let e=r;e<=a;e++)for(let n=i;n<=o;n++)t.set(`${e}:${n}`,{isMaster:e===r&&n===i,rowSpan:s,colSpan:c})}return t}function ob(e,t,n,r){if(e.length===0)return[[]];let i=[],a=[],o=0,s=!0,c=0,l=()=>{c=0;for(let r=0;r<n&&r<e.length&&!(o+e[r]>t&&a.length>0);r++)a.push(r),o+=e[r],c++};for(let u=0;u<e.length;u++){let d=e[u],f=t;for(;;){let e=r.has(u)&&a.length>0;if((e||o+d>f)&&a.length>0){if(!e&&!s&&a.length>0&&a.length===c){a=[],o=0,c=0;continue}i.push(a),a=[],o=0,c=0,s=!1,l();continue}if(!s&&u<n&&a.includes(u))break;a.push(u),o+=d;break}}return a.length>0&&i.push(a),i.length>0?i:[[]]}function sb(e,t,n,r){if(e.length===0)return[[]];let i=new Set,a=n.colBreaks??[];if(a.length>0){let e=new Map;for(let t=0;t<r.length;t++)e.set(r[t],t);for(let t of a){let n=e.get(t);n!==void 0&&i.add(n+1)}}let o=[],s=[],c=0;for(let n=0;n<e.length;n++){let r=e[n];(i.has(n)&&s.length>0||c+r>t+.01)&&s.length>0&&(o.push(s),s=[],c=0),s.push(n),c+=r}return s.length>0&&o.push(s),o.length>0?o:[Array.from({length:e.length},(e,t)=>t)]}function cb(e,t,n,r,i,a,o,s,c,l){let u=e?.text??``,d=e?.style??{},f=Hy(d.font,s.defaultFontFamily,s.defaultFontSize),p=f.fontSize*l;if(c.hasEmbeddedFont())c.trackText(u);else{let e=gy(f.fontFamily,f.bold,f.italic);c.ensureFont(e)}let m=ub(e,s,c,l);return{text:u,rect:{x:t,y:n,width:r,height:i},fontFamily:f.fontFamily,fontSize:p,bold:f.bold,italic:f.italic,strike:f.strike,underline:f.underline,textColor:f.textColor,fillColor:Uy(d.fill),horizontalAlign:Jy(d.alignment),verticalAlign:Yy(d.alignment),wrapText:d.alignment?.wrapText??!1,borders:qy(d.border),colSpan:a,rowSpan:o,hyperlink:e?.hyperlink??null,richText:m,indent:d.alignment?.indent??0,textRotation:d.alignment?.textRotation??0}}function lb(e,t){for(let n of e){let e=n.range.tl,r=(e.nativeCol??e.col??0)+1,i=(e.nativeRow??e.row??0)+1,a=t.find(e=>e.sheetCols.includes(r)&&e.sheetRows.includes(i));if(!a)continue;let o=a.sheetCols.indexOf(r),s=a.sheetRows.indexOf(i),c=a.columnOffsets[o]??a.options.margins.left,l=a.rowYPositions[s]??a.height-a.options.margins.top-(a.options.showSheetNames?20:0),u=(e.nativeColOff??0)/12700||0,d=(e.nativeRowOff??0)/12700||0,f=c+u,p=l-d,m=100,h=100;if(n.range.ext)m=(n.range.ext.width??100)*.75,h=(n.range.ext.height??100)*.75;else if(n.range.br){let e=n.range.br,t=(e.nativeCol??e.col??0)+1,r=(e.nativeRow??e.row??0)+1,i=a.sheetCols.indexOf(t),c=a.sheetRows.indexOf(r),l=i>=0?a.columnOffsets[i]:f+(a.columnWidths[o]??100),u=c>=0?a.rowYPositions[c]:p-(a.rowHeights[s]??100),d=(e.nativeColOff??0)/12700||0,g=(e.nativeRowOff??0)/12700||0,_=l+d,v=u-g;m=_-f,h=p-v}a.images.push({data:n.data,format:n.format,rect:{x:f,y:p-h,width:Math.abs(m),height:Math.abs(h)}})}}function ub(e,t,n,r){if(!e||e.type!==X.RichText)return null;let i=e.value;return!i?.richText||i.richText.length===0?null:i.richText.map(e=>{let i=Hy(e.font,t.defaultFontFamily,t.defaultFontSize);if(n.hasEmbeddedFont())n.trackText(e.text);else{let e=gy(i.fontFamily,i.bold,i.italic);n.ensureFont(e)}return{text:e.text,fontFamily:i.fontFamily,fontSize:i.fontSize*r,bold:i.bold,italic:i.italic,strike:i.strike,underline:i.underline,textColor:i.textColor}})}var db=class{constructor(){this.parts=[]}save(){return this.parts.push(`q`),this}restore(){return this.parts.push(`Q`),this}setGraphicsState(e){return this.parts.push(`/${e} gs`),this}setStrokeColor(e){return this.parts.push(`${Z(e.r)} ${Z(e.g)} ${Z(e.b)} RG`),this}setFillColor(e){return this.parts.push(`${Z(e.r)} ${Z(e.g)} ${Z(e.b)} rg`),this}setLineWidth(e){return this.parts.push(`${Z(e)} w`),this}setDashPattern(e,t=0){let n=e.map(Z).join(` `);return this.parts.push(`[${n}] ${Z(t)} d`),this}setLineCap(e){return this.parts.push(`${e} J`),this}setLineJoin(e){return this.parts.push(`${e} j`),this}moveTo(e,t){return this.parts.push(`${Z(e)} ${Z(t)} m`),this}lineTo(e,t){return this.parts.push(`${Z(e)} ${Z(t)} l`),this}rect(e,t,n,r){return this.parts.push(`${Z(e)} ${Z(t)} ${Z(n)} ${Z(r)} re`),this}stroke(){return this.parts.push(`S`),this}fill(){return this.parts.push(`f`),this}fillAndStroke(){return this.parts.push(`B`),this}closePath(){return this.parts.push(`h`),this}endPath(){return this.parts.push(`n`),this}clip(){return this.parts.push(`W`),this}beginText(){return this.parts.push(`BT`),this}endText(){return this.parts.push(`ET`),this}setFont(e,t){return this.parts.push(`/${e} ${Z(t)} Tf`),this}setTextMatrix(e,t,n,r,i,a){return this.parts.push(`${Z(e)} ${Z(t)} ${Z(n)} ${Z(r)} ${Z(i)} ${Z(a)} Tm`),this}moveText(e,t){return this.parts.push(`${Z(e)} ${Z(t)} Td`),this}setTextLeading(e){return this.parts.push(`${Z(e)} TL`),this}showText(e){return pb(e)?this.showTextWinAnsi(e):(this.parts.push(`(${fb(e)}) Tj`),this)}showTextWinAnsi(e){let t=`<`;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);r>65535&&n++;let i=hb(r);t+=i.toString(16).padStart(2,`0`)}return t+=`>`,this.parts.push(`${t} Tj`),this}showTextHex(e){return this.parts.push(`${e} Tj`),this}nextLineShowText(e){if(pb(e)){let t=`<`;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);r>65535&&n++;let i=hb(r);t+=i.toString(16).padStart(2,`0`)}return t+=`>`,this.parts.push(`${t} '`),this}return this.parts.push(`(${fb(e)}) '`),this}setTextRise(e){return this.parts.push(`${Z(e)} Ts`),this}setCharacterSpacing(e){return this.parts.push(`${Z(e)} Tc`),this}setWordSpacing(e){return this.parts.push(`${Z(e)} Tw`),this}drawImage(e,t,n,r,i){return this.save().concat(r,0,0,i,t,n).doXObject(e).restore()}concat(e,t,n,r,i,a){return this.parts.push(`${Z(e)} ${Z(t)} ${Z(n)} ${Z(r)} ${Z(i)} ${Z(a)} cm`),this}doXObject(e){return this.parts.push(`/${e} Do`),this}fillRect(e,t,n,r,i){return this.save().setFillColor(i).rect(e,t,n,r).fill().restore()}drawLine(e,t,n,r,i,a,o=[]){return this.save().setStrokeColor(i).setLineWidth(a),o.length>0&&this.setDashPattern(o),this.moveTo(e,t).lineTo(n,r).stroke().restore()}toString(){return this.parts.join(`
446
+ `)}toUint8Array(){return new TextEncoder().encode(this.toString())}};function fb(e){return e.replace(/\\/g,`\\\\`).replace(/\(/g,`\\(`).replace(/\)/g,`\\)`).replace(/\r\n/g,`\\n`).replace(/\r/g,`\\n`).replace(/\n/g,`\\n`)}function pb(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!0;return!1}let mb=new Map([[8364,128],[8218,130],[402,131],[8222,132],[8230,133],[8224,134],[8225,135],[710,136],[8240,137],[352,138],[8249,139],[338,140],[381,142],[8216,145],[8217,146],[8220,147],[8221,148],[8226,149],[8211,150],[8212,151],[732,152],[8482,153],[353,154],[8250,155],[339,156],[382,158],[376,159]]);function hb(e){if(e<128||e>=160&&e<=255)return e;let t=mb.get(e);return t===void 0?63:t}function gb(e,t,n,r){let i=new db,a=new Set;t.showGridLines&&_b(i,e,t);for(let t of e.cells)t.fillColor&&vb(i,t,a);for(let t of e.cells)yb(i,t);for(let t of e.cells)t.text&&xb(i,t,n,a);return t.showSheetNames&&jb(i,e,t,n),t.showPageNumbers&&Mb(i,e,t,n,r),{stream:i,alphaValues:a}}function _b(e,t,n){if(t.columnWidths.length===0||t.rowHeights.length===0)return;let r=n.gridLineColor;e.save(),e.setStrokeColor(r),e.setLineWidth(.25);let i=t.rowYPositions[0],a=t.rowYPositions.length-1,o=t.rowYPositions[a]-t.rowHeights[a];for(let n=0;n<=t.columnWidths.length;n++){let r=n<t.columnWidths.length?t.columnOffsets[n]:t.columnOffsets[n-1]+t.columnWidths[n-1];e.moveTo(r,i),e.lineTo(r,o)}let s=t.columnOffsets[0],c=t.columnOffsets.length-1,l=t.columnOffsets[c]+t.columnWidths[c];for(let n=0;n<=t.rowYPositions.length;n++){let r=n<t.rowYPositions.length?t.rowYPositions[n]:t.rowYPositions[n-1]-t.rowHeights[n-1];e.moveTo(s,r),e.lineTo(l,r)}e.stroke(),e.restore()}function vb(e,t,n){if(!t.fillColor)return;let r=t.fillColor.a;if(r!==void 0&&r<1){let i=Tb(r);n.add(r),e.save(),e.setGraphicsState(i),e.fillRect(t.rect.x,t.rect.y,t.rect.width,t.rect.height,t.fillColor),e.restore()}else e.fillRect(t.rect.x,t.rect.y,t.rect.width,t.rect.height,t.fillColor)}function yb(e,t){let{rect:n,borders:r}=t,{x:i,y:a,width:o,height:s}=n;r.top&&bb(e,r.top,i,a+s,i+o,a+s),r.bottom&&bb(e,r.bottom,i,a,i+o,a),r.left&&bb(e,r.left,i,a,i,a+s),r.right&&bb(e,r.right,i+o,a,i+o,a+s)}function bb(e,t,n,r,i,a){e.drawLine(n,r,i,a,t.color,t.width,t.dashPattern)}function xb(e,t,n,r){let{rect:i,text:a,fontSize:o,horizontalAlign:s,verticalAlign:c,wrapText:l}=t;if(!a&&!t.richText)return;let u=i.width-6,d=i.height-4;if(u<=0||d<=0)return;let f=t.indent*Eb;e.save(),e.rect(i.x,i.y,i.width,i.height),e.clip(),e.endPath();let p=t.textColor.a;if(p!==void 0&&p<1&&(r.add(p),e.setGraphicsState(Tb(p))),t.textRotation===`vertical`){wb(e,t,n,f),e.restore();return}if(typeof t.textRotation==`number`&&t.textRotation!==0){Cb(e,t,n,f),e.restore();return}if(t.richText&&t.richText.length>0){Sb(e,t,n,f),e.restore();return}let m=n.hasEmbeddedFont()?n.getEmbeddedResourceName():n.ensureFont(gy(t.fontFamily,t.bold,t.italic)),h=e=>n.measureText(e,m,o),g=u-f-1,_=l?Ab(a,h,g):[a],v=o*1.2,y=n.getFontAscent(m,o),b=Db(c,i,_.length*v,y);e.setFillColor(t.textColor),e.beginText(),e.setFont(m,o);for(let t=0;t<_.length;t++){let r=_[t],a=b-t*v,o=Ob(s,i,h(r),f);e.setTextMatrix(1,0,0,1,o,a);let c=n.encodeText(r,m);c?e.showTextHex(c):e.showText(r)}e.endText(),kb(e,t,_,v,b,h,m,n,f),e.restore()}function Sb(e,t,n,r){let{rect:i,horizontalAlign:a,verticalAlign:o,wrapText:s}=t,c=t.richText,l=t.fontSize;for(let e of c)e.fontSize>l&&(l=e.fontSize);let u=l,d=u*1.2,f=n.hasEmbeddedFont(),p=e=>f?n.getEmbeddedResourceName():n.ensureFont(gy(e.fontFamily,e.bold,e.italic));if(s){let t=i.width-6-r-1;if(t<=0)return;let s=c.map(e=>e.text).join(``),l=p(c[0]),f=Ab(s,e=>n.measureText(e,l,u),t),m=[];for(let e=0;e<c.length;e++)for(let t=0;t<c[e].text.length;t++)m.push(e);let h=p(c[0]),g=n.getFontAscent(h,u),_=Db(o,i,f.length*d,g),v=0;for(let t=0;t<f.length;t++){let o=_-t*d,l=f[t].length,u=[],h=v;for(let e=0;e<l;e++){let n=m[v+e]??m.length-1,r=u[u.length-1];r&&r.run===c[n]?r.text+=f[t][e]:u.push({run:c[n],text:f[t][e],resourceName:p(c[n])})}for(v+=l;v<m.length&&v<h+l+1;){let e=t+1<f.length?s.indexOf(f[t+1],v):s.length;if(e>v){v=e;break}break}let g=0;for(let e of u)g+=n.measureText(e.text,e.resourceName,e.run.fontSize);let y=Ob(a,i,g,r);for(let t of u){let{run:r,text:i,resourceName:a}=t,s=n.measureText(i,a,r.fontSize);e.setFillColor(r.textColor),e.beginText(),e.setFont(a,r.fontSize),e.setTextMatrix(1,0,0,1,y,o);let c=n.encodeText(i,a);if(c?e.showTextHex(c):e.showText(i),e.endText(),r.strike){let t=o+n.getFontDescent(a,r.fontSize)+r.fontSize*.3;e.drawLine(y,t,y+s,t,r.textColor,.5)}if(r.underline){let t=o+n.getFontDescent(a,r.fontSize)*.5;e.drawLine(y,t,y+s,t,r.textColor,.5)}y+=s}}return}let m=0,h=[];for(let e of c){let t=p(e),r=n.measureText(e.text,t,e.fontSize);h.push({resourceName:t,width:r}),m+=r}let g=h[0]?.resourceName??`F1`,_=Db(o,i,d,n.getFontAscent(g,u)),v=Ob(a,i,m,r);for(let t=0;t<c.length;t++){let r=c[t],{resourceName:i}=h[t];e.setFillColor(r.textColor),e.beginText(),e.setFont(i,r.fontSize),e.setTextMatrix(1,0,0,1,v,_);let a=n.encodeText(r.text,i);a?e.showTextHex(a):e.showText(r.text),e.endText();let o=h[t].width;if(r.strike){let t=_+n.getFontDescent(i,r.fontSize)+r.fontSize*.3;e.drawLine(v,t,v+o,t,r.textColor,.5)}if(r.underline){let t=_+n.getFontDescent(i,r.fontSize)*.5;e.drawLine(v,t,v+o,t,r.textColor,.5)}v+=h[t].width}}function Cb(e,t,n,r){let{rect:i,text:a}=t,{fontSize:o}=t,s=n.hasEmbeddedFont()?n.getEmbeddedResourceName():n.ensureFont(gy(t.fontFamily,t.bold,t.italic)),c;c=typeof t.textRotation==`number`?t.textRotation<=90?t.textRotation:-(t.textRotation-90):0;let l=c*Math.PI/180,u=Math.cos(l),d=Math.sin(l),f=n.measureText(a,s,o),p=Math.abs(d),m=Math.abs(u),h=f*m+o*p,g=f*p+o*m,_=i.width-6,v=i.height-4;if(_>0&&v>0&&(h>_||g>v)){let e=Math.min(_/h,v/g);e<1&&(o*=e)}let y=t.horizontalAlign===`left`?r/2:t.horizontalAlign===`right`?-r/2:0,b=i.x+i.width/2+y,x=i.y+i.height/2,S=n.measureText(a,s,o),ee=n.getFontAscent(s,o),C=-S/2,te=-ee/2,ne=b+C*u-te*d,w=x+C*d+te*u;e.setFillColor(t.textColor),e.beginText(),e.setFont(s,o),e.setTextMatrix(u,d,-d,u,ne,w);let T=n.encodeText(a,s);T?e.showTextHex(T):e.showText(a),e.endText()}function wb(e,t,n,r){let{rect:i,text:a,fontSize:o}=t,s=n.hasEmbeddedFont()?n.getEmbeddedResourceName():n.ensureFont(gy(t.fontFamily,t.bold,t.italic)),c=o*1.3,l=n.getFontAscent(s,o),u=i.x+i.width/2,d=i.y+i.height-2-l;e.setFillColor(t.textColor);for(let t=0;t<a.length&&!(d<i.y+2);t++){let r=a[t],i=n.measureText(r,s,o);e.beginText(),e.setFont(s,o),e.setTextMatrix(1,0,0,1,u-i/2,d);let l=n.encodeText(r,s);l?e.showTextHex(l):e.showText(r),e.endText(),d-=c}}function Tb(e){return`GS${Math.round(e*1e4)}`}let Eb=10;function Db(e,t,n,r){let i;switch(e){case`top`:i=t.y+t.height-2-r;break;case`middle`:i=t.y+t.height/2+n/2-r;break;default:i=t.y+2+(n-r);break}let a=t.y+t.height-2-r;i>a&&(i=a);let o=t.y+2;return i<o&&(i=o),i}function Ob(e,t,n,r=0){let i;switch(e){case`center`:i=t.x+(t.width-n)/2;break;case`right`:i=t.x+t.width-3-n;break;default:i=t.x+3+r;break}let a=t.x+3;return i<a&&(i=a),i}function kb(e,t,n,r,i,a,o,s,c){if(t.strike){let l=i+s.getFontDescent(o,t.fontSize)+t.fontSize*.3;for(let i=0;i<n.length;i++){let o=l-i*r,s=a(n[i]),u=Ob(t.horizontalAlign,t.rect,s,c);e.drawLine(u,o,u+s,o,t.textColor,.5)}}if(t.underline){let l=s.getFontDescent(o,t.fontSize)*.5;for(let o=0;o<n.length;o++){let s=i-o*r+l,u=a(n[o]),d=Ob(t.horizontalAlign,t.rect,u,c);e.drawLine(d,s,d+u,s,t.textColor,.5)}}}function Ab(e,t,n){if(!e)return[``];let r=e.split(/\r?\n/),i=[];for(let e of r){if(!e){i.push(``);continue}let r=e.split(/\s+/),a=``;for(let e of r){if(!a){a=e;continue}let r=a+` `+e;t(r)<=n?a=r:(i.push(a),a=e)}a&&i.push(a)}return i.length>0?i:[``]}function jb(e,t,n,r){let i=t.sheetName,a=r.hasEmbeddedFont()?r.getEmbeddedResourceName():r.ensureFont(gy(n.defaultFontFamily,!0,!1)),o=r.measureText(i,a,10),s=(t.width-o)/2,c=t.height-n.margins.top+5;e.save(),e.setFillColor({r:.3,g:.3,b:.3}),e.beginText(),e.setFont(a,10),e.setTextMatrix(1,0,0,1,s,c);let l=r.encodeText(i,a);l?e.showTextHex(l):e.showText(i),e.endText(),e.restore()}function Mb(e,t,n,r,i){let a=`Page ${t.pageNumber} of ${i}`,o=r.ensureFont(gy(n.defaultFontFamily,!1,!1)),s=r.measureText(a,o,9),c=(t.width-s)/2,l=Math.max(5,n.margins.bottom-15);e.save(),e.setFillColor({r:.5,g:.5,b:.5}),e.beginText(),e.setFont(o,9),e.setTextMatrix(1,0,0,1,c,l),e.showText(a),e.endText(),e.restore()}let Nb=1e8;function Pb(e){if(e.length<8||e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71)throw Error(`Invalid PNG signature`);let t=8,n=0,r=0,i=0,a=0,o=[],s=null,c=null;for(;t+8<=e.length;){let l=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t,!1),u=String.fromCharCode(e[t+4],e[t+5],e[t+6],e[t+7]),d=e.subarray(t+8,t+8+l);switch(t+=8+l+4,u){case`IHDR`:{let e=new DataView(d.buffer,d.byteOffset,d.byteLength);if(n=e.getUint32(0,!1),r=e.getUint32(4,!1),i=d[8],a=d[9],d[12]!==0)throw Error(`Interlaced PNG is not supported`);if(i!==8)throw Error(`Unsupported PNG bit depth: ${i}. Only 8-bit PNGs are supported.`);if(n===0||r===0)throw Error(`Invalid PNG dimensions: ${n}x${r}`);let t=n*r;if(t>Nb)throw Error(`PNG dimensions too large: ${n}x${r} (${t} pixels). Maximum allowed: ${Nb} pixels.`);break}case`PLTE`:s=new Uint8Array(d);break;case`tRNS`:c=new Uint8Array(d);break;case`IDAT`:o.push(d);break;case`IEND`:break}}if(n===0||r===0)throw Error(`PNG missing IHDR chunk`);let l=k(o),u;u=l.length>6&&(l[0]&15)==8?l.subarray(2,l.length-4):l;let d=ad(u),f=Lb(a),p=Math.max(1,f*i/8),m=Math.ceil(n*f*i/8);return Rb(Fb(d,n,r,m,p),n,r,a,i,s,c)}function Fb(e,t,n,r,i){let a=new Uint8Array(n*r),o=Math.max(1,Math.floor(i)),s=0;for(let t=0;t<n;t++){let n=e[s++],i=t*r,c=t>0?(t-1)*r:-1;for(let t=0;t<r;t++){let r=e[s++]??0,l=t>=o?a[i+t-o]:0,u=c>=0?a[c+t]:0,d=c>=0&&t>=o?a[c+t-o]:0;switch(n){case 0:a[i+t]=r;break;case 1:a[i+t]=r+l&255;break;case 2:a[i+t]=r+u&255;break;case 3:a[i+t]=r+Math.floor((l+u)/2)&255;break;case 4:a[i+t]=r+Ib(l,u,d)&255;break;default:a[i+t]=r}}}return a}function Ib(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function Lb(e){switch(e){case 0:return 1;case 2:return 3;case 3:return 1;case 4:return 2;case 6:return 4;default:return 3}}function Rb(e,t,n,r,i,a,o){let s=t*n,c=new Uint8Array(s*3),l=null;switch(r){case 2:if(c.set(e.subarray(0,s*3)),o&&o.length>=6){let t=o[1],n=o[3],r=o[5];l=new Uint8Array(s),l.fill(255);for(let i=0;i<s;i++)e[i*3]===t&&e[i*3+1]===n&&e[i*3+2]===r&&(l[i]=0)}break;case 6:l=new Uint8Array(s);for(let t=0;t<s;t++)c[t*3]=e[t*4],c[t*3+1]=e[t*4+1],c[t*3+2]=e[t*4+2],l[t]=e[t*4+3];break;case 0:{let t=-1;o&&o.length>=2&&(t=o[1]),t>=0&&(l=new Uint8Array(s),l.fill(255));for(let n=0;n<s;n++){let r=e[n];c[n*3]=r,c[n*3+1]=r,c[n*3+2]=r,l&&r===t&&(l[n]=0)}break}case 4:l=new Uint8Array(s);for(let t=0;t<s;t++){let n=e[t*2];c[t*3]=n,c[t*3+1]=n,c[t*3+2]=n,l[t]=e[t*2+1]}break;case 3:if(!a)throw Error(`PNG palette color type (3) but missing PLTE chunk`);o&&o.length>0&&(l=new Uint8Array(s));for(let t=0;t<s;t++){let n=e[t];c[t*3]=a[n*3]??0,c[t*3+1]=a[n*3+1]??0,c[t*3+2]=a[n*3+2]??0,l&&(l[t]=n<o.length?o[n]:255)}break;default:throw Error(`Unsupported PNG color type: ${r}`)}if(l){let e=!0;for(let t=0;t<l.length;t++)if(l[t]!==255){e=!1;break}e&&(l=null)}return{width:t,height:n,pixels:c,alpha:l,bitsPerComponent:8}}function zb(e,t){let n=Bb(e,t?.sheets);if(n.length===0)throw new Ev(`No sheets to export. The workbook is empty or no sheets matched.`);let r=new _y,i=new Gv;if(t?.font)try{let e=Cy(t.font);r.registerEmbeddedFont(e)}catch(e){throw new Dv(`Failed to parse TrueType font`,{cause:e})}let a=[];for(let e of n)try{let n=Zy(e,Vb(t,e),r);a.push(...n)}catch(t){throw new Dv(`Failed to layout sheet "${e.name}"`,{cause:t})}let o=Vb(t,n[0]);a.length===0&&a.push({pageNumber:1,options:o,cells:[],width:o.pageSize.width,height:o.pageSize.height,sheetName:n[0]?.name??`Sheet1`,sheetCols:[],columnOffsets:[],columnWidths:[],sheetRows:[],rowYPositions:[],rowHeights:[],images:[]});for(let e=0;e<a.length;e++)a[e].pageNumber=e+1;let s=a.length;if(r.hasEmbeddedFont())for(let e of a)e.options.showSheetNames&&r.trackText(e.sheetName);for(let e of a)e.options.showPageNumbers&&r.ensureFont(gy(e.options.defaultFontFamily,!1,!1));if(!r.hasEmbeddedFont())for(let e of a)e.options.showSheetNames&&r.ensureFont(gy(e.options.defaultFontFamily,!0,!1));let c=r.writeFontResources(i),l=[],u=i.allocObject(),d=new Map;for(let e of a)try{let{stream:t,alphaValues:n}=gb(e,e.options,r,s),a=new Map;if(e.images.length>0)for(let n=0;n<e.images.length;n++){let r=e.images[n],o=`Im${n+1}`,s=Kb(i,r.data,r.format);a.set(o,s),t.drawImage(o,r.rect.x,r.rect.y,r.rect.width,r.rect.height)}let o=i.allocObject(),f=new $;i.addStreamObject(o,f,t);let p=i.allocObject(),m=r.buildFontDictString(c),h=new $().set(`Font`,m);if(a.size>0){let e=[`<<`];for(let[t,n]of a)e.push(`/${t} ${Q(n)}`);e.push(`>>`),h.set(`XObject`,e.join(`
447
+ `))}if(n.size>0){let e=[`<<`];for(let t of n){let n=i.allocObject(),r=new $().set(`Type`,`/ExtGState`).set(`ca`,Z(t)).set(`CA`,Z(t));i.addObject(n,r),e.push(`/${Tb(t)} ${Q(n)}`)}e.push(`>>`),h.set(`ExtGState`,e.join(`
448
+ `))}i.addObject(p,h);let g=[];for(let t of e.cells)if(t.hyperlink){let e=i.allocObject(),n=`[${Z(t.rect.x)} ${Z(t.rect.y)} ${Z(t.rect.x+t.rect.width)} ${Z(t.rect.y+t.rect.height)}]`,r=new $().set(`Type`,`/Annot`).set(`Subtype`,`/Link`).set(`Rect`,n).set(`Border`,`[0 0 0]`).set(`A`,`<< /Type /Action /S /URI /URI (${t.hyperlink.replace(/[()\\]/g,`\\$&`)}) >>`);i.addObject(e,r),g.push(e)}let _=i.addPage({parentRef:u,width:e.width,height:e.height,contentsRef:o,resourcesRef:p,annotRefs:g.length>0?g:void 0});l.push(_),d.has(e.sheetName)||d.set(e.sheetName,l.length-1)}catch(t){throw new Dv(`Failed to render page ${e.pageNumber} of "${e.sheetName}"`,{cause:t})}let f=`[`+l.map(e=>Q(e)).join(` `)+`]`,p=new $().set(`Type`,`/Pages`).set(`Kids`,f).set(`Count`,String(l.length));i.addObject(u,p);let m;if(d.size>1&&(m=Gb(i,d,l)),i.addCatalog(u,m),i.addInfoDict({title:o.title||e.title||void 0,author:o.author||e.creator||void 0,subject:o.subject||e.subject||void 0,creator:o.creator}),t?.encryption){let e=Mv(t.encryption);i.setEncryption(e)}return i.build()}function Bb(e,t){let n=e.sheets;if(!t||t.length===0)return n.filter(e=>e.state!==`hidden`&&e.state!==`veryHidden`);let r=[];for(let e of t)if(typeof e==`string`){let t=n.find(t=>t.name.toLowerCase()===e.toLowerCase());t&&r.push(t)}else if(typeof e==`number`){let t=n[e-1];t&&r.push(t)}return r}function Vb(e,t){let n=t?.pageSetup,r=Ub(e?.pageSize,n?.paperSize),i=e?.orientation??(n?.orientation===`landscape`?`landscape`:`portrait`),a=Wb(e?.margins,n?.margins),o=Ly(e?.gridLineColor??`FFD0D0D0`)??{r:.816,g:.816,b:.816},s=e?.repeatRows??!1;if(s===!1&&n?.printTitlesRow){let e=n.printTitlesRow.match(/^(\d+)(?::(\d+))?$/);e&&(s=parseInt(e[2]??e[1],10))}return{pageSize:r,orientation:i,margins:a,fitToPage:e?.fitToPage===void 0?!0:e.fitToPage,scale:Math.max(.1,Math.min(3,e?.scale??(n?.scale?n.scale/100:1))),showGridLines:e?.showGridLines??n?.showGridLines??!1,gridLineColor:o,repeatRows:s,defaultFontFamily:e?.defaultFontFamily??`Helvetica`,defaultFontSize:e?.defaultFontSize??11,showSheetNames:e?.showSheetNames??!1,showPageNumbers:e?.showPageNumbers??!1,title:e?.title??``,author:e?.author??``,subject:e?.subject??``,creator:e?.creator??`excelts`}}let Hb={1:vv.LETTER,5:vv.LEGAL,9:vv.A4,8:vv.A3,11:vv.A5,17:vv.TABLOID};function Ub(e,t){return e?typeof e==`string`?vv[e]??vv.A4:e:t===void 0?vv.A4:Hb[t]??vv.A4}function Wb(e,t){let n=t?{top:t.top*72,right:t.right*72,bottom:t.bottom*72,left:t.left*72}:{top:72,right:72,bottom:72,left:72};return e?{top:e.top??n.top,right:e.right??n.right,bottom:e.bottom??n.bottom,left:e.left??n.left}:n}function Gb(e,t,n){let r=e.allocObject(),i=Array.from(t.entries()),a=[];for(let t=0;t<i.length;t++)a.push(e.allocObject());for(let t=0;t<i.length;t++){let[o,s]=i[t],c=n[s],l=new $().set(`Title`,yv(o)).set(`Parent`,Q(r)).set(`Dest`,`[${Q(c)} /Fit]`);t>0&&l.set(`Prev`,Q(a[t-1])),t<i.length-1&&l.set(`Next`,Q(a[t+1])),e.addObject(a[t],l)}let o=new $().set(`Type`,`/Outlines`).set(`First`,Q(a[0])).set(`Last`,Q(a[a.length-1])).set(`Count`,String(i.length));return e.addObject(r,o),r}function Kb(e,t,n){return n===`png`?Jb(e,t):qb(e,t)}function qb(e,t){let n=e.allocObject(),r=Yb(t),i=new $().set(`Type`,`/XObject`).set(`Subtype`,`/Image`).set(`Width`,Z(r.width)).set(`Height`,Z(r.height)).set(`ColorSpace`,`/DeviceRGB`).set(`BitsPerComponent`,`8`).set(`Filter`,`/DCTDecode`);return e.addStreamObject(n,i,t),n}function Jb(e,t){let n=Pb(t),r=e.allocObject(),i=new $().set(`Type`,`/XObject`).set(`Subtype`,`/Image`).set(`Width`,Z(n.width)).set(`Height`,Z(n.height)).set(`ColorSpace`,`/DeviceRGB`).set(`BitsPerComponent`,Z(n.bitsPerComponent));if(n.alpha){let t=e.allocObject(),r=new $().set(`Type`,`/XObject`).set(`Subtype`,`/Image`).set(`Width`,Z(n.width)).set(`Height`,Z(n.height)).set(`ColorSpace`,`/DeviceGray`).set(`BitsPerComponent`,`8`);e.addStreamObject(t,r,n.alpha),i.set(`SMask`,Q(t))}return e.addStreamObject(r,i,n.pixels),r}function Yb(e){let t=2;for(;t<e.length-1;){for(;t<e.length&&e[t]===255&&e[t+1]===255;)t++;if(t>=e.length-1||e[t]!==255)break;let n=e[t+1];if(n>=192&&n<=207&&n!==196&&n!==200&&n!==204){if(t+8<e.length){let n=e[t+5]<<8|e[t+6];return{width:e[t+7]<<8|e[t+8],height:n}}break}if(t+3>=e.length)break;let r=e[t+2]<<8|e[t+3];t+=2+r}return{width:1,height:1}}function Xb(e,t){return zb(Zb(e),t)}function Zb(e){return Array.isArray(e)?{sheets:[Qb({data:e})]}:`sheets`in e?{title:e.title,creator:e.author,sheets:e.sheets.map((e,t)=>Qb(e,t))}:{sheets:[Qb(e)]}}function Qb(e,t){let n=e.data,r=e.name??`Sheet${(t??0)+1}`,i=e.columns?.map(e=>typeof e==`number`?void 0:e.header),a=i?.some(e=>e!==void 0)??!1,o=0;for(let e of n)e.length>o&&(o=e.length);let s=Math.max(o,e.columns?.length??0),c=n.length+(a?1:0);if(e.images)for(let t of e.images){let e=t.col+1,n=t.row+1;e>s&&(s=e),n>c&&(c=n)}if(s===0)return{name:r,bounds:{top:0,left:0,bottom:0,right:0},columns:new Map,rows:new Map};let l=new Map;if(e.columns)for(let t=0;t<e.columns.length;t++){let n=e.columns[t],r=typeof n==`number`?n:n.width;l.set(t+1,{width:r??12})}for(let e=1;e<=s;e++)l.has(e)||l.set(e,{width:12});let u=new Map,d=1;if(a&&i){let e=new Map;for(let t=0;t<i.length;t++){let n=i[t];n!==void 0&&e.set(t+1,{type:X.String,value:n,text:n,col:t+1,style:{font:{bold:!0}}})}u.set(1,{cells:e}),d=2}for(let e=0;e<n.length;e++){let t=e+d,r=n[e],i=new Map;for(let e=0;e<r.length;e++){let t=$b(r[e],e+1);t&&i.set(e+1,t)}u.set(t,{cells:i})}let f;if(e.images&&e.images.length>0){f=e.images.map(e=>({data:e.data,format:e.format,range:{tl:{col:e.col,row:e.row},ext:{width:e.width,height:e.height}}}));for(let e=1;e<=s;e++)l.has(e)||l.set(e,{width:12});for(let e=1;e<=c;e++)u.has(e)||u.set(e,{cells:new Map})}return{name:r,bounds:{top:1,left:1,bottom:c,right:s},columns:l,rows:u,images:f}}function $b(e,t){if(e==null)return null;if(typeof e==`object`&&!(e instanceof Date)&&`value`in e){let n=e,r=$b(n.value,t);if(!r)return null;let i={};return(n.bold||n.italic||n.fontSize||n.fontColor)&&(i.font={bold:n.bold,italic:n.italic,size:n.fontSize,color:n.fontColor?{argb:n.fontColor}:void 0}),n.fillColor&&(i.fill={type:`pattern`,pattern:`solid`,fgColor:{argb:n.fillColor}}),n.align&&(i.alignment={horizontal:n.align}),r.style=i,r}return typeof e==`string`?{type:X.String,value:e,text:e,col:t}:typeof e==`number`?{type:X.Number,value:e,text:String(e),col:t}:typeof e==`boolean`?{type:X.Boolean,value:e,text:e?`TRUE`:`FALSE`,col:t}:e instanceof Date?{type:X.Date,value:e,text:e.toLocaleDateString(),col:t}:null}function ex(e,t){return zb(tx(e),t)}function tx(e){return{title:e.title||void 0,creator:e.creator||void 0,subject:e.subject||void 0,sheets:e.worksheets.map(t=>nx(t,e))}}function nx(e,t){let n=e.dimensions,r=n&&n.model.top>0&&n.model.left>0,i=r?{top:n.model.top,left:n.model.left,bottom:n.model.bottom,right:n.model.right}:{top:0,left:0,bottom:0,right:0},a=new Map;if(r)for(let t=i.left;t<=i.right;t++){let n=e.getColumn(t);a.set(t,{hidden:n.hidden||void 0,width:n.width??void 0})}let o=new Map;if(r)for(let t=i.top;t<=i.bottom;t++){let n=e.findRow(t);if(!n)continue;let r=new Map;n.eachCell({includeEmpty:!1},e=>{r.set(e.col,rx(e))}),o.set(t,{hidden:n.hidden||void 0,height:n.height??void 0,cells:r})}let s=e.hasMerges&&e.model.mergeCells?[...e.model.mergeCells]:void 0,c=e.pageSetup,l=c?{orientation:c.orientation,paperSize:c.paperSize,margins:c.margins?{left:c.margins.left,right:c.margins.right,top:c.margins.top,bottom:c.margins.bottom}:void 0,scale:c.scale,printTitlesRow:c.printTitlesRow,showGridLines:c.showGridLines,printArea:c.printArea}:void 0,u=e.rowBreaks?.map(e=>e.id),d=e.colBreaks?.map(e=>e.id),f=hx(e,t);if(f){for(let e of f){let t=e.range.tl,n=(t.nativeCol??t.col??0)+1,r=(t.nativeRow??t.row??0)+1;if(i.top===0&&i.left===0&&(i.top=1,i.left=1),n>i.right&&(i.right=n),r>i.bottom&&(i.bottom=r),e.range.br){let t=e.range.br,n=(t.nativeCol??t.col??0)+1,r=(t.nativeRow??t.row??0)+1;n>i.right&&(i.right=n),r>i.bottom&&(i.bottom=r)}}for(let t=i.left;t<=i.right;t++)if(!a.has(t)){let n=e.getColumn(t);a.set(t,{hidden:n.hidden||void 0,width:n.width??void 0})}for(let e=i.top;e<=i.bottom;e++)o.has(e)||o.set(e,{cells:new Map})}return{name:e.name,state:e.state??`visible`,bounds:i,columns:a,rows:o,merges:s,pageSetup:l,rowBreaks:u,colBreaks:d,images:f}}function rx(e){let t=ix(e.type),n=ax(e),r=cx(e.style);return{type:t,value:sx(e),text:n,style:r,hyperlink:e.hyperlink||void 0,result:e.result??void 0,col:e.col}}function ix(e){switch(e){case E.Null:return X.Empty;case E.Merge:return X.Merge;case E.Number:return X.Number;case E.String:case E.SharedString:return X.String;case E.Date:return X.Date;case E.Hyperlink:return X.Hyperlink;case E.Formula:return X.Formula;case E.RichText:return X.RichText;case E.Boolean:return X.Boolean;case E.Error:return X.Error;default:return X.String}}function ax(e){if(!e)return``;switch(e.type){case E.Null:case E.Merge:return``;case E.RichText:case E.Hyperlink:return e.text??``;case E.Error:return e.value?.error??e.text??``;case E.Formula:{let t=e.result;return t==null?e.text??``:typeof t==`object`&&`error`in t?t.error:ox(t,e.style?.numFmt)}default:{let t=e.value;return t==null?``:ox(t,e.style?.numFmt)}}}function ox(e,t){let n=typeof t==`string`?t:t?.formatCode;if(n&&(typeof e==`number`||e instanceof Date||typeof e==`boolean`))try{return Cn(e,n)}catch{}return e instanceof Date?e.toLocaleDateString():String(e)}function sx(e){if(e.type===E.RichText){let t=e.value;if(t?.richText)return{richText:t.richText.map(e=>({text:e.text,font:e.font?lx(e.font):void 0}))}}return e.value}function cx(e){if(e)return{font:e.font?lx(e.font):void 0,numFmt:e.numFmt,fill:e.fill?dx(e.fill):void 0,border:e.border?px(e.border):void 0,alignment:e.alignment?mx(e.alignment):void 0}}function lx(e){return{name:e.name,size:e.size,bold:e.bold,italic:e.italic,strike:e.strike,underline:e.underline,color:e.color?ux(e.color):void 0}}function ux(e){return{argb:e.argb,theme:e.theme,tint:e.tint}}function dx(e){let t={type:e.type??`pattern`,pattern:e.pattern,fgColor:e.fgColor?ux(e.fgColor):void 0};return e.stops&&(t.stops=e.stops.map(e=>({color:ux(e.color)}))),t}function fx(e){return{style:e.style,color:e.color?ux(e.color):void 0}}function px(e){return{top:e.top?fx(e.top):void 0,right:e.right?fx(e.right):void 0,bottom:e.bottom?fx(e.bottom):void 0,left:e.left?fx(e.left):void 0}}function mx(e){return{horizontal:e.horizontal,vertical:e.vertical,wrapText:e.wrapText,indent:e.indent,textRotation:e.textRotation}}function hx(e,t){let n=e.getImages?.();if(!n||!Array.isArray(n)||n.length===0)return;let r=[];for(let e of n){if(!e.range?.tl)continue;let n=e.imageId,i=t.getImage?.(Number(n));if(!i)continue;let a;if(i.buffer instanceof Uint8Array?a=i.buffer:i.base64&&(a=st(i.base64)),!a||a.length===0)continue;let o=i.extension;o!==`jpeg`&&o!==`png`||r.push({data:a,format:o,range:{tl:{col:e.range.tl.col??0,row:e.range.tl.row??0,nativeCol:e.range.tl.nativeCol,nativeRow:e.range.tl.nativeRow,nativeColOff:e.range.tl.nativeColOff,nativeRowOff:e.range.tl.nativeRowOff},br:e.range.br?{col:e.range.br.col??0,row:e.range.br.row??0,nativeCol:e.range.br.nativeCol,nativeRow:e.range.br.nativeRow,nativeColOff:e.range.br.nativeColOff,nativeRowOff:e.range.br.nativeRowOff}:void 0,ext:e.range.ext?{width:e.range.ext.width,height:e.range.ext.height}:void 0}})}return r.length>0?r:void 0}return e.Anchor=Ve,e.BaseError=t,e.Cell=O,e.Column=Re,e.ColumnOutOfBoundsError=p,e.CsvFormatterStream=iv,e.CsvParserStream=V_,e.DataValidations=Qe,e.DateFormatter=rg,e.DateParser=tg,e.DefinedNames=ni,e.DocumentType=ae,e.Enums=D,e.ErrorValue=se,e.ExcelDownloadError=x,e.ExcelError=l,e.ExcelFileError=y,e.ExcelNotSupportedError=v,e.ExcelStreamStateError=b,e.FormCheckbox=at,e.FormulaType=re,e.Image=He,e.ImageError=C,e.InvalidAddressError=f,e.InvalidValueTypeError=g,e.MaxItemsExceededError=te,e.MergeConflictError=h,e.PageSizes=vv,e.PaperSize=_v,e.PdfError=Ev,e.PdfFontError=Ov,e.PdfRenderError=Dv,e.PdfStructureError=kv,e.PivotTableError=S,e.Range=T,e.ReadingOrder=oe,e.RelationshipType=ie,e.Row=Le,e.RowOutOfBoundsError=m,e.Table=Ze,e.TableError=ee,e.ValueType=E,e.Workbook=gv,e.WorkbookReader=Lh,e.WorkbookWriter=Rm,e.Worksheet=Zr,e.WorksheetNameError=d,e.WorksheetReader=Ph,e.WorksheetWriter=Pm,e.XmlParseError=_,e.base64ToUint8Array=st,e.concatUint8Arrays=k,e.createCsvFormatterStream=av,e.createCsvParserStream=H_,e.dateToExcel=ct,e.decodeCell=qr,e.decodeCol=Ur,e.decodeRange=Yr,e.decodeRow=Gr,e.encodeCell=Jr,e.encodeCol=Wr,e.encodeRange=Xr,e.encodeRow=Kr,e.errorToJSON=o,e.excelToDate=lt,e.excelToPdf=ex,e.getErrorChain=s,e.getRootCause=c,e.getSupportedFormats=ig,e.isExcelError=u,e.isPdfError=Av,e.pdf=Xb,e.stringToUint8Array=Hn,e.toError=a,e.toUint8Array=Wn,e.uint8ArrayToBase64=Ft,e.uint8ArrayToString=Un,e.xmlDecode=vt,e.xmlEncode=bt,e})({});