@justybase/spreadsheet-tasks 2.0.0 → 2.1.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,43 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ - `convertXlsbToXlsx` and `convertXlsxToXlsb` — Windows/Excel COM conversions
13
+ with protected destinations and optional explicit overwriting.
14
+
15
+ ### Fixed
16
+
17
+ - Destination replacement during Excel conversion now preserves files created
18
+ concurrently and rolls back safely when the final rename fails.
19
+
20
+ ## [2.1.0] - 2026-08-07
21
+
22
+ ### Added
23
+
24
+ - `XlsxUpdater` and `XlsbUpdater` — replace the data of a worksheet inside an
25
+ existing `.xlsx` / `.xlsb` file without rebuilding the workbook. Pivot tables,
26
+ other sheets, styles and defined names are preserved; shared strings are
27
+ appended (never reordered), column styles are inherited, and pivot cache
28
+ ranges + `refreshOnLoad` are updated automatically.
29
+ - Shared helpers: `xmlUtils.ts` (XML escaping, column letters, shared strings
30
+ parsing) and `biff12Utils.ts` (BIFF12 record helpers for XLSB).
31
+ - `examples/update-existing.ts` — end-to-end example for refreshing a data
32
+ sheet in an existing XLSX / XLSB report.
33
+
34
+ ### Fixed
35
+
36
+ - `XlsbUpdater` pivot source range was one row too long when `headers` were not
37
+ provided, causing an empty trailing row (and a "(blank)" item in pivot
38
+ tables). The range now ends exactly at the last data row.
39
+ - Both updaters now trim trailing rows that contain only empty cells (padding
40
+ rows from SQL exports), so they don't appear as "(blank)" in pivot tables.
41
+ - `XlsbUpdater` no longer removes the worksheet's row-block terminator records
42
+ (0x92/0x217/0x1dd/0x1dc) and keeps the sheet dimension record (0x98) in sync
43
+ with the new row count — without these, Excel hid the last written row.
44
+
8
45
  ## [2.0.0] - 2026-07-25
9
46
 
10
47
  ### Breaking
package/README.md CHANGED
@@ -1,43 +1,73 @@
1
- # SpreadsheetTasks
1
+ # @justybase/spreadsheet-tasks
2
2
 
3
- A high-performance TypeScript library for reading and writing Excel files in XLSB and XLSX formats.
3
+ High-performance TypeScript library for reading and writing Excel files in XLSB and XLSX formats.
4
4
 
5
- [![npm version](https://badge.fury.io/js/@justybase%2Fspreadsheet-tasks.svg)](https://www.npmjs.com/package/@justybase/spreadsheet-tasks)
5
+ [![npm version](https://img.shields.io/npm/v/@justybase/spreadsheet-tasks.svg)](https://www.npmjs.com/package/@justybase/spreadsheet-tasks)
6
+ [![CI](https://github.com/justybase/justybase_spreadsheet_tasks/actions/workflows/ci.yml/badge.svg)](https://github.com/justybase/justybase_spreadsheet_tasks/actions/workflows/ci.yml)
6
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
8
 
8
- ## 🚀 Features
9
-
10
- - **High Performance** - XLSB format is 3.3x faster to write and 2.1x faster to read than XLSX
11
- - **Small File Size** - XLSB files are ~47% smaller than equivalent XLSX files
12
- - **TypeScript First** - Full TypeScript support with type definitions
13
- - **Dual Format Support** - Read and write both XLSB and XLSX formats
14
- - **Zero External Dependencies** - Uses only Node.js built-in modules and minimal zip libraries
15
- - **Streaming Support** - Efficient memory usage for large files
16
- - **Multiple Sheets** - Support for multiple worksheets per workbook
17
- - **Auto-filter** - Automatic filter headers support
18
-
19
- ## 📊 Benchmark Results
9
+ ## Table of Contents
10
+
11
+ - [Features](#features)
12
+ - [Benchmark Results](#benchmark-results)
13
+ - [Requirements](#requirements)
14
+ - [Installation](#installation)
15
+ - [Browser Support](#browser-support)
16
+ - [Quick Start](#quick-start)
17
+ - [API Documentation](#api-documentation)
18
+ - [Examples](#examples)
19
+ - [When to Use XLSB vs XLSX](#when-to-use-xlsb-vs-xlsx)
20
+ - [Contributing](#contributing)
21
+ - [License](#license)
22
+ - [Acknowledgments](#acknowledgments)
23
+
24
+ ## Features
25
+
26
+ - **High Performance** — XLSB is about 3.3× faster to write and 2.3× faster to read than XLSX (see [benchmarks](#benchmark-results))
27
+ - **Small File Size** — XLSB files are ~47% smaller than equivalent XLSX files
28
+ - **TypeScript First** — Full TypeScript support with type definitions
29
+ - **Dual Format Support** — Read and write both XLSB and XLSX formats
30
+ - **Lightweight Node Dependencies** — Small ZIP-focused runtime deps (`adm-zip`, `archiver`, `yauzl`); no heavy Excel framework
31
+ - **Streaming Support** — Efficient memory usage for large files
32
+ - **Multiple Sheets** — Support for multiple worksheets per workbook
33
+ - **Auto-filter** — Automatic filter headers support
34
+ - **Excel COM Conversion** — Convert XLSB and XLSX through desktop Microsoft Excel on Windows
35
+ - **In-place Updates** — Replace the data of a worksheet inside an existing XLSX or XLSB (e.g. `report.xlsx` / `report.xlsb`) while keeping pivot tables, other sheets and formatting untouched
36
+
37
+ ## Benchmark Results
38
+
39
+ Measured with `npm run benchmark` (50K rows). Your results may vary by hardware and dataset.
20
40
 
21
41
  | Operation | XLSB | XLSX | Performance Gain |
22
42
  |-----------|------|------|------------------|
23
- | Write (50K rows) | 140 ms | 467 ms | **3.3x faster** |
24
- | Read (50K rows) | 118 ms | 276 ms | **2.3x faster** |
43
+ | Write (50K rows) | 140 ms | 467 ms | **3.3× faster** |
44
+ | Read (50K rows) | 118 ms | 276 ms | **2.3× faster** |
25
45
  | File Size | 1.49 MB | 2.83 MB | **47% smaller** |
26
46
 
47
+ ## Requirements
48
+
49
+ - **Node.js** 16 or newer ([`engines`](./package.json) in `package.json`)
50
+ - XLSB/XLSX conversion additionally requires Windows, PowerShell and desktop Microsoft Excel with COM automation
51
+
27
52
  ## Installation
28
53
 
29
54
  ```bash
30
55
  npm install @justybase/spreadsheet-tasks
31
56
  ```
32
57
 
33
- CJS and ESM are both supported:
58
+ CommonJS:
34
59
 
35
60
  ```js
36
61
  const { XlsbWriter } = require('@justybase/spreadsheet-tasks');
62
+ ```
63
+
64
+ ES modules:
65
+
66
+ ```js
37
67
  import { XlsbWriter } from '@justybase/spreadsheet-tasks';
38
68
  ```
39
69
 
40
- ## Browser Support & CDN (Zero Dependencies)
70
+ ## Browser Support
41
71
 
42
72
  Browser writers live in TypeScript under `src/browser/` and are bundled with:
43
73
 
@@ -50,6 +80,8 @@ This produces:
50
80
  - `browser/justybase-spreadsheet.min.js` — IIFE (`JustybaseSpreadsheet` global)
51
81
  - `browser/browser-spreadsheet.js` — ESM for local demos (`demo.html`, `test.html`)
52
82
 
83
+ The browser bundle has **no runtime npm dependencies** (ZIP logic is inlined).
84
+
53
85
  ```html
54
86
  <script type="module">
55
87
  import { downloadXlsb, downloadXlsx, F } from './browser-spreadsheet.js';
@@ -67,7 +99,8 @@ This produces:
67
99
  ```
68
100
 
69
101
  **Features included in the browser build:**
70
- - Built-in Zip archiving (no external libraries needed)
102
+
103
+ - Built-in ZIP archiving (no external libraries in the bundle)
71
104
  - Memory-efficient `Uint8Array` buffer handling
72
105
  - Auto-fitted column widths
73
106
  - Frozen and styled headers (styles: `bold`, `fill`, `bold+fill`)
@@ -140,13 +173,13 @@ await writer.finalize();
140
173
  ```
141
174
 
142
175
  **Benefits of Streaming API:**
143
- - ✅ Constant memory usage regardless of dataset size
144
- - ✅ Write millions of rows without loading all data into RAM
145
- - ✅ Generate data on-the-fly from databases, APIs, or other sources
146
- - ✅ Same performance as batch mode
147
176
 
148
- ### Reading Excel Files
177
+ - Constant memory usage regardless of dataset size
178
+ - Write millions of rows without loading all data into RAM
179
+ - Generate data on-the-fly from databases, APIs, or other sources
180
+ - Same performance as batch mode
149
181
 
182
+ ### Reading Excel Files
150
183
 
151
184
  ```typescript
152
185
  import { XlsbReader, XlsxReader, ReaderFactory } from '@justybase/spreadsheet-tasks';
@@ -171,28 +204,93 @@ await xlsbReader.open('data.xlsb');
171
204
  // ... same API as above
172
205
  ```
173
206
 
174
- ## 📖 API Documentation
207
+ ### Updating Data in an Existing Workbook
208
+
209
+ `XlsxUpdater` and `XlsbUpdater` replace the cell data of a worksheet inside an
210
+ existing workbook without rebuilding it. Everything else — pivot tables, charts,
211
+ other sheets, styles, defined names — is preserved, so you can keep an advanced
212
+ Excel file (like a report with pivot tables wired to a data sheet) and only
213
+ refresh its data:
214
+
215
+ ```typescript
216
+ import { XlsxUpdater, XlsbUpdater } from '@justybase/spreadsheet-tasks';
217
+
218
+ // XLSX
219
+ const xlsx = new XlsxUpdater('report.xlsx');
220
+ xlsx.replaceSheetData('data1', rows, { headers: ['ID', 'NAME', 'AMOUNT'] });
221
+ xlsx.save(); // overwrite in place, or xlsx.save('report_new.xlsx')
222
+
223
+ // XLSB — the same API
224
+ const xlsb = new XlsbUpdater('report.xlsb');
225
+ xlsb.replaceSheetData('data1', rows, { headers: ['ID', 'NAME', 'AMOUNT'] });
226
+ xlsb.save('report_new.xlsb');
227
+ ```
228
+
229
+ **What happens under the hood:**
230
+
231
+ - The target sheet's cell data is cleared and replaced with the new rows.
232
+ - New strings are appended to the shared strings table (existing entries and
233
+ their indices are never moved, so other sheets stay valid).
234
+ - New cells reuse the dominant style of their column from the original data
235
+ (dates stay dates, numbers stay numbers). Pass `styleFallback: 'general'`
236
+ to write everything as General.
237
+ - Pivot tables whose cache source is the updated sheet get their source range
238
+ and record count adjusted, and `refreshOnLoad` is enabled so Excel refreshes
239
+ them automatically on open.
240
+
241
+ > **Tip:** always pass the `headers` matching the original columns. When
242
+ > `headers` are omitted, the first data row lands in row 1 and becomes the
243
+ > pivot's field names (Excel reads the first row of the source range as
244
+ > headers), so the pivot's columns would be replaced by the first record's
245
+ > values.
246
+
247
+ ### Converting XLSB and XLSX with Excel
248
+
249
+ On Windows, existing workbooks can be converted by asking the installed desktop
250
+ Microsoft Excel to perform `SaveAs` through COM. The source file is opened
251
+ read-only and the destination is written separately:
252
+
253
+ ```typescript
254
+ import {
255
+ convertXlsbToXlsx,
256
+ convertXlsxToXlsb,
257
+ } from '@justybase/spreadsheet-tasks';
258
+
259
+ await convertXlsbToXlsx('report.xlsb', 'report.xlsx');
260
+ await convertXlsxToXlsb('report.xlsx', 'report.xlsb');
261
+
262
+ // Existing destinations are protected by default.
263
+ await convertXlsbToXlsx('report.xlsb', 'report.xlsx', { overwrite: true });
264
+ ```
265
+
266
+ Conversion is a Node.js-only API and requires Windows plus desktop Microsoft
267
+ Excel. Unsupported files, unavailable COM automation, and Excel conversion
268
+ errors are reported as rejected promises. VBA/macros are not guaranteed when
269
+ the target format does not support them.
270
+
271
+ ## API Documentation
175
272
 
176
273
  See [API Documentation](./docs/API.md) for detailed API reference.
177
274
 
178
- ## 💡 Examples
275
+ ## Examples
179
276
 
180
277
  Check out the [examples](./examples) folder for more usage examples:
181
278
 
182
- - [Basic Write](./examples/basic-write.ts) - Writing data to Excel files
183
- - [Basic Read](./examples/basic-read.ts) - Reading data from Excel files
184
- - [Multiple Sheets](./examples/multiple-sheets.ts) - Working with multiple worksheets
185
- - [Large Dataset](./examples/large-dataset.ts) - Handling large datasets efficiently
186
- - [Streaming Example](./examples/streaming-example.ts) - Write millions of rows without loading all data in memory
279
+ - [Basic Write](./examples/basic-write.ts) — Writing data to Excel files
280
+ - [Basic Read](./examples/basic-read.ts) — Reading data from Excel files
281
+ - [Multiple Sheets](./examples/multiple-sheets.ts) — Working with multiple worksheets
282
+ - [Update Existing Workbook](./examples/update-existing.ts) — Replacing the data of a sheet in an existing XLSX/XLSB with pivot tables
283
+ - [Large Dataset](./examples/large-dataset.ts) — Handling large datasets efficiently
284
+ - [Streaming Example](./examples/streaming-example.ts) — Write millions of rows without loading all data in memory
187
285
 
188
286
  Run examples with:
287
+
189
288
  ```bash
190
289
  npm run build
191
290
  npx ts-node examples/basic-write.ts
192
291
  ```
193
292
 
194
-
195
- ## 🔍 When to Use XLSB vs XLSX
293
+ ## When to Use XLSB vs XLSX
196
294
 
197
295
  | Use XLSB When | Use XLSX When |
198
296
  |---------------|---------------|
@@ -201,14 +299,30 @@ npx ts-node examples/basic-write.ts
201
299
  | Internal/backend processing | Human-readable XML is needed |
202
300
  | Storage space is limited | Third-party integrations require it |
203
301
 
204
- ## 🤝 Contributing
302
+ ## Contributing
303
+
304
+ Contributions are welcome. To work on the project locally:
305
+
306
+ ```bash
307
+ git clone https://github.com/justybase/justybase_spreadsheet_tasks.git
308
+ cd justybase_spreadsheet_tasks
309
+ npm install
310
+ npm run build
311
+ npm test
312
+ ```
313
+
314
+ Before opening a pull request:
315
+
316
+ 1. Run `npm run lint` and `npm test`.
317
+ 2. Add or update tests if you change behavior.
318
+ 3. Update [CHANGELOG.md](./CHANGELOG.md) for user-visible changes.
205
319
 
206
- Contributions are welcome! Please feel free to submit a Pull Request.
320
+ Please open an issue or pull request on [GitHub](https://github.com/justybase/justybase_spreadsheet_tasks).
207
321
 
208
- ## 📄 License
322
+ ## License
209
323
 
210
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
324
+ This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
211
325
 
212
- ## 🙏 Acknowledgments
326
+ ## Acknowledgments
213
327
 
214
- - Inspired by and reimplemented from [SpreadSheetTasks](https://github.com/KrzysztofDusko/SpreadSheetTasks)
328
+ - Inspired by and reimplemented from [SpreadSheetTasks](https://github.com/justybae/SpreadSheetTasks)
@@ -399,7 +399,14 @@ var BrowserXlsxWriter = class {
399
399
  }
400
400
  }
401
401
  if (!need) return s;
402
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f]/g, "");
402
+ const escaped = s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
403
+ let out = "";
404
+ for (let i = 0; i < escaped.length; i++) {
405
+ const c = escaped.charCodeAt(i);
406
+ if (c <= 8 || c === 11 || c === 12 || c >= 14 && c <= 31) continue;
407
+ out += escaped[i];
408
+ }
409
+ return out;
403
410
  }
404
411
  _fmn(n) {
405
412
  return /[\s\-+=()!@#$%^&]/.test(n) || /^[0-9]/.test(n) ? `'${n.replace(/'/g, "''")}'` : n;
@@ -530,7 +537,7 @@ var BrowserXlsxWriter = class {
530
537
  if (headerStyle === "fill") hs = 4;
531
538
  else if (headerStyle === "bold+fill") hs = 5;
532
539
  const bb = new BrowserBigBuffer();
533
- let cc = rows.length > 0 ? rows[0].length : headers ? headers.length : 0;
540
+ const cc = rows.length > 0 ? rows[0].length : headers ? headers.length : 0;
534
541
  this._cw = new Array(cc).fill(-1);
535
542
  const cl = new Array(cc);
536
543
  for (let i = 0; i < cc; i++) cl[i] = this._cl(i);
@@ -2656,7 +2663,7 @@ var BrowserXlsbWriter = class {
2656
2663
  if (headerStyle === "fill") hs = 4;
2657
2664
  else if (headerStyle === "bold+fill") hs = 5;
2658
2665
  const bb = new BrowserBigBuffer();
2659
- let colCount = rows.length > 0 ? rows[0].length : headers ? headers.length : 0;
2666
+ const colCount = rows.length > 0 ? rows[0].length : headers ? headers.length : 0;
2660
2667
  this._colWidths = new Array(colCount).fill(-1);
2661
2668
  if (headers) {
2662
2669
  for (let i = 0; i < colCount; i++) {
@@ -1,4 +1,4 @@
1
- "use strict";var JustybaseSpreadsheet=(()=>{var $=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var O=(d,t)=>{for(var e in t)$(d,e,{get:t[e],enumerable:!0})},H=(d,t,e,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of z(t))!b.call(d,s)&&s!==e&&$(d,s,{get:()=>t[s],enumerable:!(x=M(t,s))||x.enumerable});return d};var W=d=>H($({},"__esModule",{value:!0}),d);var G={};O(G,{BrowserBigBuffer:()=>y,BrowserXlsbWriter:()=>C,BrowserXlsxWriter:()=>S,BrowserZip:()=>F,F:()=>V,downloadXlsb:()=>q,downloadXlsbMultiSheet:()=>j,downloadXlsx:()=>X,downloadXlsxMultiSheet:()=>Y});var y=class{constructor(t=65536){this.chunkSize=t,this.chunks=[],this.currentBuffer=new Uint8Array(t),this.dataView=new DataView(this.currentBuffer.buffer),this.cursor=0,this._textEncoder=new TextEncoder}ensureCapacity(t){this.cursor+t>this.chunkSize&&this._flush()}_flush(){this.cursor>0&&(this.chunks.push(this.currentBuffer.slice(0,this.cursor)),this.currentBuffer=new Uint8Array(this.chunkSize),this.dataView=new DataView(this.currentBuffer.buffer),this.cursor=0)}write(t){let e=t.length,x=0;for(;e>0;){let s=this.chunkSize-this.cursor;s===0&&(this._flush(),s=this.chunkSize);let r=Math.min(e,s);this.currentBuffer.set(t.subarray(x,x+r),this.cursor),this.cursor+=r,x+=r,e-=r}}writeByte(t){this.ensureCapacity(1),this.currentBuffer[this.cursor]=t,this.cursor++}writeUnsafeByte(t){this.currentBuffer[this.cursor++]=t}writeInt32LE(t){this.ensureCapacity(4),this.dataView.setInt32(this.cursor,t,!0),this.cursor+=4}writeUnsafeInt32LE(t){this.dataView.setInt32(this.cursor,t,!0),this.cursor+=4}writeDoubleLE(t){this.ensureCapacity(8),this.dataView.setFloat64(this.cursor,t,!0),this.cursor+=8}writeUnsafeDoubleLE(t){this.dataView.setFloat64(this.cursor,t,!0),this.cursor+=8}writeString(t){let e=this._textEncoder.encode(t),x=e.length;if(this.cursor+x<=this.chunkSize){this.currentBuffer.set(e,this.cursor),this.cursor+=x;return}this._flush(),x>this.chunkSize?this.chunks.push(e):(this.currentBuffer.set(e,this.cursor),this.cursor+=x)}writeUtf16LE(t){let e=t.length*2;if(this.cursor+e<=this.chunkSize){for(let x=0;x<t.length;x++){let s=t.charCodeAt(x);this.currentBuffer[this.cursor++]=s&255,this.currentBuffer[this.cursor++]=s>>8&255}return}if(this._flush(),e>this.chunkSize){let x=new Uint8Array(e);for(let s=0;s<t.length;s++){let r=t.charCodeAt(s);x[s*2]=r&255,x[s*2+1]=r>>8&255}this.chunks.push(x)}else for(let x=0;x<t.length;x++){let s=t.charCodeAt(x);this.currentBuffer[this.cursor++]=s&255,this.currentBuffer[this.cursor++]=s>>8&255}}getChunks(){return this.cursor>0&&(this.chunks.push(this.currentBuffer.slice(0,this.cursor)),this.currentBuffer=new Uint8Array(this.chunkSize),this.dataView=new DataView(this.currentBuffer.buffer),this.cursor=0),this.chunks}toUint8Array(){let t=this.getChunks(),e=0;for(let r of t)e+=r.length;let x=new Uint8Array(e),s=0;for(let r of t)x.set(r,s),s+=r.length;return x}reset(){this.chunks=[],this.cursor=0}};var F=class d{constructor(){this.files=[]}addFile(t,e){let x;if(typeof e=="string")x=new TextEncoder().encode(e);else if(Array.isArray(e)){let s=0;for(let o of e)s+=o.length;x=new Uint8Array(s);let r=0;for(let o of e)x.set(o,r),r+=o.length}else x=e;this.files.push({name:t,data:x})}toBlob(){let t=[],e=[],x=0;for(let n of this.files){let f=new TextEncoder().encode(n.name),c=this._crc32(n.data),h=new Uint8Array(30+f.length),l=new DataView(h.buffer);l.setUint32(0,67324752,!0),l.setUint16(4,20,!0),l.setUint16(6,0,!0),l.setUint16(8,0,!0),l.setUint16(10,0,!0),l.setUint16(12,0,!0),l.setUint32(14,c,!0),l.setUint32(18,n.data.length,!0),l.setUint32(22,n.data.length,!0),l.setUint16(26,f.length,!0),l.setUint16(28,0,!0),h.set(f,30),t.push(h),t.push(n.data);let a=new Uint8Array(46+f.length),m=new DataView(a.buffer);m.setUint32(0,33639248,!0),m.setUint16(4,20,!0),m.setUint16(6,20,!0),m.setUint16(8,0,!0),m.setUint16(10,0,!0),m.setUint16(12,0,!0),m.setUint16(14,0,!0),m.setUint32(16,c,!0),m.setUint32(20,n.data.length,!0),m.setUint32(24,n.data.length,!0),m.setUint16(28,f.length,!0),m.setUint16(30,0,!0),m.setUint16(32,0,!0),m.setUint16(34,0,!0),m.setUint16(36,0,!0),m.setUint32(38,0,!0),m.setUint32(42,x,!0),a.set(f,46),e.push(a),x+=h.length+n.data.length}let s=x,r=0;for(let n of e)t.push(n),r+=n.length;let o=new Uint8Array(22),i=new DataView(o.buffer);return i.setUint32(0,101010256,!0),i.setUint16(4,0,!0),i.setUint16(6,0,!0),i.setUint16(8,this.files.length,!0),i.setUint16(10,this.files.length,!0),i.setUint32(12,r,!0),i.setUint32(16,s,!0),i.setUint16(20,0,!0),t.push(o),new Blob(t,{type:"application/octet-stream"})}_crc32(t){if(!d._crc32Table){d._crc32Table=new Uint32Array(256);for(let s=0;s<256;s++){let r=s;for(let o=0;o<8;o++)r=r&1?3988292384^r>>>1:r>>>1;d._crc32Table[s]=r}}let e=d._crc32Table,x=4294967295;for(let s=0;s<t.length;s++)x=e[(x^t[s])&255]^x>>>8;return(x^4294967295)>>>0}};F._crc32Table=null;var V={THOUSANDS_SEP:"#,##0",CURRENCY_PLN:'#,##0.00 "z\u0142"',CURRENCY_EUR:"#,##0.00 \u20AC",PERCENTAGE:"0%",SCIENTIFIC:"0.00E+00",TWO_DECIMALS:"#,##0.00",TEXT:"@",LEADING_ZEROS:"000000000",DATE_SHORT:"dd.mm.yyyy",DATE_LONG:"d mmmm yyyy",DATE_DAY_MONTH_YEAR:"dd-mm-yyyy",DATE_ISO:"yyyy-mm-dd",DATE_MONTH_YEAR:"mmmm yyyy",DATE_WEEKDAY:"dddd, d mmmm yyyy",DATE_DAY_MONTH:"d mmmm",DATE_YEAR_ONLY:"yyyy",DATETIME_SHORT:"dd.mm.yyyy hh:mm",DATETIME_LONG:"d mmmm yyyy hh:mm:ss",TIME_HH_MM:"hh:mm",TIME_HH_MM_SS:"hh:mm:ss",TIME_12H:"h:mm AM/PM",DATETIME_24H:"dd.mm.yyyy hh:mm:ss",DATETIME_ISO:'yyyy-mm-dd"T"hh:mm:ss',TIME_MS:"hh:mm:ss.000"};function A(d){return d!=null&&typeof d=="object"&&"format"in d&&typeof d.format=="string"}function D(d){return A(d)?d.value:d}function T(d){return A(d)?d.format:null}var N=(()=>{let d=[];for(let e=65;e<91;e++)d.push(String.fromCharCode(e));let t=[];for(let e of d)for(let x=65;x<91;x++)t.push(e+String.fromCharCode(x));return d.push(...t),d})(),S=class{constructor(){this._zip=new F,this._sc=0,this._sl=[],this._sstA=[],this._sstM=new Map,this._sstCnt=0,this._cw=[],this._afOn=!1,this._oaE=Date.UTC(1899,11,30),this._csb=null,this._csrn=0,this._csSC=0,this._csEC=0,this._csAF=!1,this._isS=!1,this._csCL=[],this._fmtReg=new Map,this._fmtXf=new Map,this._nextNfmt=165,this._nextXf=6}_cl(t){return t<N.length?N[t]:"A"}_san(t){if(!t||typeof t!="string")return`Sheet${this._sc+1}`;let e=t.replace(/[\\/*?[\]:]/g,"_");return e.length>31&&(e=e.substring(0,31)),e.trim()||(e=`Sheet${this._sc+1}`),e}_ex(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}_esc(t){if(typeof t!="string")return t;let e=!1;for(let x=0;x<t.length;x++){let s=t.charCodeAt(x);if(s===38||s===60||s===62||s===34||s===39||s>=0&&s<=8||s===11||s===12||s>=14&&s<=31){e=!0;break}}return e?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f]/g,""):t}_fmn(t){return/[\s\-+=()!@#$%^&]/.test(t)||/^[0-9]/.test(t)?`'${t.replace(/'/g,"''")}'`:t}addSheet(t,e=!1){let x=this._san(t);this._sc++,this._sl.push({name:x,path:`xl/worksheets/sheet${this._sc}.xml`,hidden:e,fn:`sheet${this._sc}.xml`,id:this._sc,rId:`rId${this._sc}`,fhr:null})}_wsc(t,e,x,s,r){let o=this._sstM.get(e);o===void 0&&(o=this._sstA.length,this._sstA.push(e),this._sstM.set(e,o)),this._sstCnt++;let i=r!==void 0?` s="${r}"`:"";t.writeString(`<c r="${x}${s}" t="s"${i}><v>${o}</v></c>`)}_wscStyle(t,e,x,s,r){let o=this._sstM.get(e);o===void 0&&(o=this._sstA.length,this._sstA.push(e),this._sstM.set(e,o)),this._sstCnt++,t.writeString(`<c r="${x}${s}" t="s" s="${r}"><v>${o}</v></c>`)}_oa(t){return(t.getTime()-this._oaE)/864e5}_regFmt(t){if(this._fmtXf.has(t))return this._fmtXf.get(t);let e=this._nextNfmt++;this._fmtReg.set(t,e);let x=this._nextXf++;return this._fmtXf.set(t,x),x}_wcv(t,e,x,s){if(e==null)return;let r=T(e),o=r!==null?D(e):e,i=r!==null?this._regFmt(r):-1,n=i>=0?` s="${i}"`:"";if(typeof o=="number")Number.isFinite(o)?t.writeString(`<c r="${x}${s}"${n}><v>${o}</v></c>`):this._wsc(t,o.toString(),x,s,i>=0?i:void 0);else if(typeof o=="bigint")this._wsc(t,o.toString(),x,s,i>=0?i:void 0);else if(typeof o=="boolean")t.writeString(`<c r="${x}${s}" t="b"${n}><v>${o?1:0}</v></c>`);else if(o instanceof Date){let f=this._oa(o);Number.isFinite(f)?t.writeString(`<c r="${x}${s}" s="${i>=0?i:1}"><v>${f}</v></c>`):this._wsc(t,o.toString(),x,s,i>=0?i:void 0)}else this._wsc(t,o.toString(),x,s,i>=0?i:void 0)}_sheetHead(t,e,x,s){t.writeString('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'),t.writeString('<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">'),t.writeString('<dimension ref="A1"/>'),s?t.writeString(`<sheetViews><sheetView ${x?'tabSelected="1" ':""}workbookViewId="0"><pane ySplit="1" topLeftCell="A2" activePane="bottomLeft" state="frozen"/><selection pane="bottomLeft"/></sheetView></sheetViews><sheetFormatPr defaultRowHeight="15"/>`):t.writeString(`<sheetViews><sheetView ${x?'tabSelected="1" ':""}workbookViewId="0"/></sheetViews><sheetFormatPr defaultRowHeight="15"/>`),t.writeString("<cols>");for(let r=0;r<e;r++){let o=this._cw[r]>0?this._cw[r]:10;t.writeString(`<col min="${r+1}" max="${r+1}" width="${o}" bestFit="1" customWidth="1"/>`)}t.writeString("</cols><sheetData>")}startSheet(t,e,x,s={}){if(this._isS)throw new Error("Already streaming");let{hidden:r=!1,doAutofilter:o=!0,headerStyle:i="bold"}=s,n=3;i==="fill"?n=4:i==="bold+fill"&&(n=5),this.addSheet(t,r),this._isS=!0,this._csb=new y,this._csrn=0,this._csSC=0,this._csEC=e,this._csAF=o&&x!==void 0,this._cw=new Array(e).fill(-1);let f=new Array(e);for(let c=0;c<e;c++)f[c]=this._cl(c);if(this._csCL=f,x)for(let c=0;c<e;c++){let h=1.3*(x[c]?x[c].length:0)+3;h>80&&(h=80),this._cw[c]<h&&(this._cw[c]=h)}if(this._sheetHead(this._csb,e,this._sc===1,this._csAF),x){this._csrn++,this._csb.writeString(`<row r="${this._csrn}">`);for(let c=0;c<x.length;c++)this._wscStyle(this._csb,x[c],f[c],this._csrn,n);this._csb.writeString("</row>")}}writeRow(t){if(!this._isS)throw new Error("Not streaming");this._csrn++,this._csb.writeString(`<row r="${this._csrn}">`);for(let e=0;e<t.length;e++)this._wcv(this._csb,t[e],this._csCL[e],this._csrn);this._csb.writeString("</row>")}endSheet(){if(!this._isS)throw new Error("Not streaming");if(this._csb.writeString("</sheetData>"),this._csAF&&this._csEC>0){this._afOn=!0;let t=`A1:${this._csCL[this._csEC-1]}${this._csrn}`;this._csb.writeString(`<autoFilter ref="${t}"/>`);let e=this._sl[this._sc-1];e.fhr=`${this._fmn(e.name)}!$A$1:$${this._csCL[this._csEC-1]}$${this._csrn}`}this._csb.writeString("</worksheet>"),this._zip.addFile(this._sl[this._sc-1].path,this._csb.toUint8Array()),this._isS=!1,this._csb=null}writeSheet(t,e=null,x={}){let s=x.doAutofilter!==!1,r=x.headerStyle||"bold",o=3;r==="fill"?o=4:r==="bold+fill"&&(o=5);let i=new y,n=t.length>0?t[0].length:e?e.length:0;this._cw=new Array(n).fill(-1);let f=new Array(n);for(let l=0;l<n;l++)f[l]=this._cl(l);if(e)for(let l=0;l<n;l++){let a=1.3*(e[l]?e[l].length:0)+3;a>80&&(a=80),this._cw[l]<a&&(this._cw[l]=a)}for(let l=0;l<Math.min(t.length,100);l++)for(let a=0;a<t[l].length;a++){let m=t[l][a];if(m==null)continue;let g=A(m)?m.value:m,p=1.3*(g instanceof Date?10:g.toString().length)+3;p>80&&(p=80),this._cw[a]<p&&(this._cw[a]=p)}let c=t.length+(e?1:0);this._sheetHead(i,n,this._sc===1,s&&!!e);let h=0;if(e){h++,i.writeString(`<row r="${h}">`);for(let l=0;l<e.length;l++)this._wscStyle(i,e[l],f[l],h,o);i.writeString("</row>")}for(let l=0;l<t.length;l++){h++,i.writeString(`<row r="${h}">`);for(let a=0;a<t[l].length;a++)this._wcv(i,t[l][a],f[a],h);i.writeString("</row>")}if(i.writeString("</sheetData>"),s&&e&&n>0){this._afOn=!0;let l=`A1:${f[n-1]}${c}`;i.writeString(`<autoFilter ref="${l}"/>`);let a=this._sl[this._sc-1];a.fhr=`${this._fmn(a.name)}!$A$1:$${f[n-1]}$${c}`}i.writeString("</worksheet>"),this._zip.addFile(this._sl[this._sc-1].path,i.toUint8Array())}finalize(){return this._writeSst(),this._writeStyles(),this._writeWb(),this._writeCt(),this._writeRels(),this._zip.toBlob()}_writeSst(){let t=new y;t.writeString('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'),t.writeString(`<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="${this._sstCnt}" uniqueCount="${this._sstA.length}">`);for(let e of this._sstA){let x=this._esc(e);x.length>0&&(x[0]===" "||x[x.length-1]===" "||/[\t\n\r]/.test(x))?t.writeString(`<si><t xml:space="preserve">${x}</t></si>`):t.writeString(`<si><t>${x}</t></si>`)}t.writeString("</sst>"),this._zip.addFile("xl/sharedStrings.xml",t.toUint8Array())}_writeStyles(){let t='<numFmt numFmtId="164" formatCode="yyyy\\-mm\\-dd\\ hh:mm:ss"/>',e=1,x=['<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>','<xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>','<xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>','<xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/>','<xf numFmtId="0" fontId="0" fillId="1" borderId="0" xfId="0" applyFill="1"/>','<xf numFmtId="0" fontId="1" fillId="1" borderId="0" xfId="0" applyFont="1" applyFill="1"/>'];for(let[r,o]of this._fmtReg){let i=r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;");t+=`<numFmt numFmtId="${o}" formatCode="${i}"/>`,e++}let s=[...this._fmtXf.entries()].sort((r,o)=>r[1]-o[1]);for(let[r]of s){let o=this._fmtReg.get(r);x.push(`<xf numFmtId="${o}" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>`)}this._zip.addFile("xl/styles.xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
+ "use strict";var JustybaseSpreadsheet=(()=>{var $=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var O=(d,t)=>{for(var e in t)$(d,e,{get:t[e],enumerable:!0})},H=(d,t,e,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of z(t))!b.call(d,s)&&s!==e&&$(d,s,{get:()=>t[s],enumerable:!(x=M(t,s))||x.enumerable});return d};var W=d=>H($({},"__esModule",{value:!0}),d);var G={};O(G,{BrowserBigBuffer:()=>y,BrowserXlsbWriter:()=>C,BrowserXlsxWriter:()=>S,BrowserZip:()=>F,F:()=>V,downloadXlsb:()=>q,downloadXlsbMultiSheet:()=>j,downloadXlsx:()=>X,downloadXlsxMultiSheet:()=>Y});var y=class{constructor(t=65536){this.chunkSize=t,this.chunks=[],this.currentBuffer=new Uint8Array(t),this.dataView=new DataView(this.currentBuffer.buffer),this.cursor=0,this._textEncoder=new TextEncoder}ensureCapacity(t){this.cursor+t>this.chunkSize&&this._flush()}_flush(){this.cursor>0&&(this.chunks.push(this.currentBuffer.slice(0,this.cursor)),this.currentBuffer=new Uint8Array(this.chunkSize),this.dataView=new DataView(this.currentBuffer.buffer),this.cursor=0)}write(t){let e=t.length,x=0;for(;e>0;){let s=this.chunkSize-this.cursor;s===0&&(this._flush(),s=this.chunkSize);let i=Math.min(e,s);this.currentBuffer.set(t.subarray(x,x+i),this.cursor),this.cursor+=i,x+=i,e-=i}}writeByte(t){this.ensureCapacity(1),this.currentBuffer[this.cursor]=t,this.cursor++}writeUnsafeByte(t){this.currentBuffer[this.cursor++]=t}writeInt32LE(t){this.ensureCapacity(4),this.dataView.setInt32(this.cursor,t,!0),this.cursor+=4}writeUnsafeInt32LE(t){this.dataView.setInt32(this.cursor,t,!0),this.cursor+=4}writeDoubleLE(t){this.ensureCapacity(8),this.dataView.setFloat64(this.cursor,t,!0),this.cursor+=8}writeUnsafeDoubleLE(t){this.dataView.setFloat64(this.cursor,t,!0),this.cursor+=8}writeString(t){let e=this._textEncoder.encode(t),x=e.length;if(this.cursor+x<=this.chunkSize){this.currentBuffer.set(e,this.cursor),this.cursor+=x;return}this._flush(),x>this.chunkSize?this.chunks.push(e):(this.currentBuffer.set(e,this.cursor),this.cursor+=x)}writeUtf16LE(t){let e=t.length*2;if(this.cursor+e<=this.chunkSize){for(let x=0;x<t.length;x++){let s=t.charCodeAt(x);this.currentBuffer[this.cursor++]=s&255,this.currentBuffer[this.cursor++]=s>>8&255}return}if(this._flush(),e>this.chunkSize){let x=new Uint8Array(e);for(let s=0;s<t.length;s++){let i=t.charCodeAt(s);x[s*2]=i&255,x[s*2+1]=i>>8&255}this.chunks.push(x)}else for(let x=0;x<t.length;x++){let s=t.charCodeAt(x);this.currentBuffer[this.cursor++]=s&255,this.currentBuffer[this.cursor++]=s>>8&255}}getChunks(){return this.cursor>0&&(this.chunks.push(this.currentBuffer.slice(0,this.cursor)),this.currentBuffer=new Uint8Array(this.chunkSize),this.dataView=new DataView(this.currentBuffer.buffer),this.cursor=0),this.chunks}toUint8Array(){let t=this.getChunks(),e=0;for(let i of t)e+=i.length;let x=new Uint8Array(e),s=0;for(let i of t)x.set(i,s),s+=i.length;return x}reset(){this.chunks=[],this.cursor=0}};var F=class d{constructor(){this.files=[]}addFile(t,e){let x;if(typeof e=="string")x=new TextEncoder().encode(e);else if(Array.isArray(e)){let s=0;for(let n of e)s+=n.length;x=new Uint8Array(s);let i=0;for(let n of e)x.set(n,i),i+=n.length}else x=e;this.files.push({name:t,data:x})}toBlob(){let t=[],e=[],x=0;for(let o of this.files){let f=new TextEncoder().encode(o.name),c=this._crc32(o.data),h=new Uint8Array(30+f.length),l=new DataView(h.buffer);l.setUint32(0,67324752,!0),l.setUint16(4,20,!0),l.setUint16(6,0,!0),l.setUint16(8,0,!0),l.setUint16(10,0,!0),l.setUint16(12,0,!0),l.setUint32(14,c,!0),l.setUint32(18,o.data.length,!0),l.setUint32(22,o.data.length,!0),l.setUint16(26,f.length,!0),l.setUint16(28,0,!0),h.set(f,30),t.push(h),t.push(o.data);let a=new Uint8Array(46+f.length),m=new DataView(a.buffer);m.setUint32(0,33639248,!0),m.setUint16(4,20,!0),m.setUint16(6,20,!0),m.setUint16(8,0,!0),m.setUint16(10,0,!0),m.setUint16(12,0,!0),m.setUint16(14,0,!0),m.setUint32(16,c,!0),m.setUint32(20,o.data.length,!0),m.setUint32(24,o.data.length,!0),m.setUint16(28,f.length,!0),m.setUint16(30,0,!0),m.setUint16(32,0,!0),m.setUint16(34,0,!0),m.setUint16(36,0,!0),m.setUint32(38,0,!0),m.setUint32(42,x,!0),a.set(f,46),e.push(a),x+=h.length+o.data.length}let s=x,i=0;for(let o of e)t.push(o),i+=o.length;let n=new Uint8Array(22),r=new DataView(n.buffer);return r.setUint32(0,101010256,!0),r.setUint16(4,0,!0),r.setUint16(6,0,!0),r.setUint16(8,this.files.length,!0),r.setUint16(10,this.files.length,!0),r.setUint32(12,i,!0),r.setUint32(16,s,!0),r.setUint16(20,0,!0),t.push(n),new Blob(t,{type:"application/octet-stream"})}_crc32(t){if(!d._crc32Table){d._crc32Table=new Uint32Array(256);for(let s=0;s<256;s++){let i=s;for(let n=0;n<8;n++)i=i&1?3988292384^i>>>1:i>>>1;d._crc32Table[s]=i}}let e=d._crc32Table,x=4294967295;for(let s=0;s<t.length;s++)x=e[(x^t[s])&255]^x>>>8;return(x^4294967295)>>>0}};F._crc32Table=null;var V={THOUSANDS_SEP:"#,##0",CURRENCY_PLN:'#,##0.00 "z\u0142"',CURRENCY_EUR:"#,##0.00 \u20AC",PERCENTAGE:"0%",SCIENTIFIC:"0.00E+00",TWO_DECIMALS:"#,##0.00",TEXT:"@",LEADING_ZEROS:"000000000",DATE_SHORT:"dd.mm.yyyy",DATE_LONG:"d mmmm yyyy",DATE_DAY_MONTH_YEAR:"dd-mm-yyyy",DATE_ISO:"yyyy-mm-dd",DATE_MONTH_YEAR:"mmmm yyyy",DATE_WEEKDAY:"dddd, d mmmm yyyy",DATE_DAY_MONTH:"d mmmm",DATE_YEAR_ONLY:"yyyy",DATETIME_SHORT:"dd.mm.yyyy hh:mm",DATETIME_LONG:"d mmmm yyyy hh:mm:ss",TIME_HH_MM:"hh:mm",TIME_HH_MM_SS:"hh:mm:ss",TIME_12H:"h:mm AM/PM",DATETIME_24H:"dd.mm.yyyy hh:mm:ss",DATETIME_ISO:'yyyy-mm-dd"T"hh:mm:ss',TIME_MS:"hh:mm:ss.000"};function A(d){return d!=null&&typeof d=="object"&&"format"in d&&typeof d.format=="string"}function D(d){return A(d)?d.value:d}function T(d){return A(d)?d.format:null}var N=(()=>{let d=[];for(let e=65;e<91;e++)d.push(String.fromCharCode(e));let t=[];for(let e of d)for(let x=65;x<91;x++)t.push(e+String.fromCharCode(x));return d.push(...t),d})(),S=class{constructor(){this._zip=new F,this._sc=0,this._sl=[],this._sstA=[],this._sstM=new Map,this._sstCnt=0,this._cw=[],this._afOn=!1,this._oaE=Date.UTC(1899,11,30),this._csb=null,this._csrn=0,this._csSC=0,this._csEC=0,this._csAF=!1,this._isS=!1,this._csCL=[],this._fmtReg=new Map,this._fmtXf=new Map,this._nextNfmt=165,this._nextXf=6}_cl(t){return t<N.length?N[t]:"A"}_san(t){if(!t||typeof t!="string")return`Sheet${this._sc+1}`;let e=t.replace(/[\\/*?[\]:]/g,"_");return e.length>31&&(e=e.substring(0,31)),e.trim()||(e=`Sheet${this._sc+1}`),e}_ex(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}_esc(t){if(typeof t!="string")return t;let e=!1;for(let i=0;i<t.length;i++){let n=t.charCodeAt(i);if(n===38||n===60||n===62||n===34||n===39||n>=0&&n<=8||n===11||n===12||n>=14&&n<=31){e=!0;break}}if(!e)return t;let x=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),s="";for(let i=0;i<x.length;i++){let n=x.charCodeAt(i);n<=8||n===11||n===12||n>=14&&n<=31||(s+=x[i])}return s}_fmn(t){return/[\s\-+=()!@#$%^&]/.test(t)||/^[0-9]/.test(t)?`'${t.replace(/'/g,"''")}'`:t}addSheet(t,e=!1){let x=this._san(t);this._sc++,this._sl.push({name:x,path:`xl/worksheets/sheet${this._sc}.xml`,hidden:e,fn:`sheet${this._sc}.xml`,id:this._sc,rId:`rId${this._sc}`,fhr:null})}_wsc(t,e,x,s,i){let n=this._sstM.get(e);n===void 0&&(n=this._sstA.length,this._sstA.push(e),this._sstM.set(e,n)),this._sstCnt++;let r=i!==void 0?` s="${i}"`:"";t.writeString(`<c r="${x}${s}" t="s"${r}><v>${n}</v></c>`)}_wscStyle(t,e,x,s,i){let n=this._sstM.get(e);n===void 0&&(n=this._sstA.length,this._sstA.push(e),this._sstM.set(e,n)),this._sstCnt++,t.writeString(`<c r="${x}${s}" t="s" s="${i}"><v>${n}</v></c>`)}_oa(t){return(t.getTime()-this._oaE)/864e5}_regFmt(t){if(this._fmtXf.has(t))return this._fmtXf.get(t);let e=this._nextNfmt++;this._fmtReg.set(t,e);let x=this._nextXf++;return this._fmtXf.set(t,x),x}_wcv(t,e,x,s){if(e==null)return;let i=T(e),n=i!==null?D(e):e,r=i!==null?this._regFmt(i):-1,o=r>=0?` s="${r}"`:"";if(typeof n=="number")Number.isFinite(n)?t.writeString(`<c r="${x}${s}"${o}><v>${n}</v></c>`):this._wsc(t,n.toString(),x,s,r>=0?r:void 0);else if(typeof n=="bigint")this._wsc(t,n.toString(),x,s,r>=0?r:void 0);else if(typeof n=="boolean")t.writeString(`<c r="${x}${s}" t="b"${o}><v>${n?1:0}</v></c>`);else if(n instanceof Date){let f=this._oa(n);Number.isFinite(f)?t.writeString(`<c r="${x}${s}" s="${r>=0?r:1}"><v>${f}</v></c>`):this._wsc(t,n.toString(),x,s,r>=0?r:void 0)}else this._wsc(t,n.toString(),x,s,r>=0?r:void 0)}_sheetHead(t,e,x,s){t.writeString('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'),t.writeString('<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">'),t.writeString('<dimension ref="A1"/>'),s?t.writeString(`<sheetViews><sheetView ${x?'tabSelected="1" ':""}workbookViewId="0"><pane ySplit="1" topLeftCell="A2" activePane="bottomLeft" state="frozen"/><selection pane="bottomLeft"/></sheetView></sheetViews><sheetFormatPr defaultRowHeight="15"/>`):t.writeString(`<sheetViews><sheetView ${x?'tabSelected="1" ':""}workbookViewId="0"/></sheetViews><sheetFormatPr defaultRowHeight="15"/>`),t.writeString("<cols>");for(let i=0;i<e;i++){let n=this._cw[i]>0?this._cw[i]:10;t.writeString(`<col min="${i+1}" max="${i+1}" width="${n}" bestFit="1" customWidth="1"/>`)}t.writeString("</cols><sheetData>")}startSheet(t,e,x,s={}){if(this._isS)throw new Error("Already streaming");let{hidden:i=!1,doAutofilter:n=!0,headerStyle:r="bold"}=s,o=3;r==="fill"?o=4:r==="bold+fill"&&(o=5),this.addSheet(t,i),this._isS=!0,this._csb=new y,this._csrn=0,this._csSC=0,this._csEC=e,this._csAF=n&&x!==void 0,this._cw=new Array(e).fill(-1);let f=new Array(e);for(let c=0;c<e;c++)f[c]=this._cl(c);if(this._csCL=f,x)for(let c=0;c<e;c++){let h=1.3*(x[c]?x[c].length:0)+3;h>80&&(h=80),this._cw[c]<h&&(this._cw[c]=h)}if(this._sheetHead(this._csb,e,this._sc===1,this._csAF),x){this._csrn++,this._csb.writeString(`<row r="${this._csrn}">`);for(let c=0;c<x.length;c++)this._wscStyle(this._csb,x[c],f[c],this._csrn,o);this._csb.writeString("</row>")}}writeRow(t){if(!this._isS)throw new Error("Not streaming");this._csrn++,this._csb.writeString(`<row r="${this._csrn}">`);for(let e=0;e<t.length;e++)this._wcv(this._csb,t[e],this._csCL[e],this._csrn);this._csb.writeString("</row>")}endSheet(){if(!this._isS)throw new Error("Not streaming");if(this._csb.writeString("</sheetData>"),this._csAF&&this._csEC>0){this._afOn=!0;let t=`A1:${this._csCL[this._csEC-1]}${this._csrn}`;this._csb.writeString(`<autoFilter ref="${t}"/>`);let e=this._sl[this._sc-1];e.fhr=`${this._fmn(e.name)}!$A$1:$${this._csCL[this._csEC-1]}$${this._csrn}`}this._csb.writeString("</worksheet>"),this._zip.addFile(this._sl[this._sc-1].path,this._csb.toUint8Array()),this._isS=!1,this._csb=null}writeSheet(t,e=null,x={}){let s=x.doAutofilter!==!1,i=x.headerStyle||"bold",n=3;i==="fill"?n=4:i==="bold+fill"&&(n=5);let r=new y,o=t.length>0?t[0].length:e?e.length:0;this._cw=new Array(o).fill(-1);let f=new Array(o);for(let l=0;l<o;l++)f[l]=this._cl(l);if(e)for(let l=0;l<o;l++){let a=1.3*(e[l]?e[l].length:0)+3;a>80&&(a=80),this._cw[l]<a&&(this._cw[l]=a)}for(let l=0;l<Math.min(t.length,100);l++)for(let a=0;a<t[l].length;a++){let m=t[l][a];if(m==null)continue;let g=A(m)?m.value:m,p=1.3*(g instanceof Date?10:g.toString().length)+3;p>80&&(p=80),this._cw[a]<p&&(this._cw[a]=p)}let c=t.length+(e?1:0);this._sheetHead(r,o,this._sc===1,s&&!!e);let h=0;if(e){h++,r.writeString(`<row r="${h}">`);for(let l=0;l<e.length;l++)this._wscStyle(r,e[l],f[l],h,n);r.writeString("</row>")}for(let l=0;l<t.length;l++){h++,r.writeString(`<row r="${h}">`);for(let a=0;a<t[l].length;a++)this._wcv(r,t[l][a],f[a],h);r.writeString("</row>")}if(r.writeString("</sheetData>"),s&&e&&o>0){this._afOn=!0;let l=`A1:${f[o-1]}${c}`;r.writeString(`<autoFilter ref="${l}"/>`);let a=this._sl[this._sc-1];a.fhr=`${this._fmn(a.name)}!$A$1:$${f[o-1]}$${c}`}r.writeString("</worksheet>"),this._zip.addFile(this._sl[this._sc-1].path,r.toUint8Array())}finalize(){return this._writeSst(),this._writeStyles(),this._writeWb(),this._writeCt(),this._writeRels(),this._zip.toBlob()}_writeSst(){let t=new y;t.writeString('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'),t.writeString(`<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="${this._sstCnt}" uniqueCount="${this._sstA.length}">`);for(let e of this._sstA){let x=this._esc(e);x.length>0&&(x[0]===" "||x[x.length-1]===" "||/[\t\n\r]/.test(x))?t.writeString(`<si><t xml:space="preserve">${x}</t></si>`):t.writeString(`<si><t>${x}</t></si>`)}t.writeString("</sst>"),this._zip.addFile("xl/sharedStrings.xml",t.toUint8Array())}_writeStyles(){let t='<numFmt numFmtId="164" formatCode="yyyy\\-mm\\-dd\\ hh:mm:ss"/>',e=1,x=['<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>','<xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>','<xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>','<xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/>','<xf numFmtId="0" fontId="0" fillId="1" borderId="0" xfId="0" applyFill="1"/>','<xf numFmtId="0" fontId="1" fillId="1" borderId="0" xfId="0" applyFont="1" applyFill="1"/>'];for(let[i,n]of this._fmtReg){let r=i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;");t+=`<numFmt numFmtId="${n}" formatCode="${r}"/>`,e++}let s=[...this._fmtXf.entries()].sort((i,n)=>i[1]-n[1]);for(let[i]of s){let n=this._fmtReg.get(i);x.push(`<xf numFmtId="${n}" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>`)}this._zip.addFile("xl/styles.xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
2
  <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
3
3
  <numFmts count="${e}">${t}</numFmts>
4
4
  <fonts count="2">
@@ -14,23 +14,23 @@ ${x.join(`
14
14
  </cellXfs>
15
15
  <cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>
16
16
  <dxfs count="0"/><tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleLight16"/>
17
- </styleSheet>`)}_writeWb(){let t='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><fileVersion appName="xl" lastEdited="4" lowestEdited="4" rupBuild="4505"/><workbookPr defaultThemeVersion="124226"/><bookViews><workbookView xWindow="240" yWindow="15" windowWidth="16095" windowHeight="9660"/></bookViews><sheets>';for(let e of this._sl)t+=`<sheet name="${this._ex(e.name)}" sheetId="${e.id}"${e.hidden?' state="hidden"':""} r:id="${e.rId}"/>`;if(t+="</sheets>",this._afOn){t+="<definedNames>";for(let e of this._sl)e.fhr&&(t+=`<definedName name="_xlnm._FilterDatabase" localSheetId="${e.id-1}" hidden="1">${this._esc(e.fhr)}</definedName>`);t+="</definedNames>"}t+='<calcPr calcId="124519" fullCalcOnLoad="1"/></workbook>',this._zip.addFile("xl/workbook.xml",t)}_writeCt(){let t='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/><Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"/>';for(let e of this._sl)t+=`<Override PartName="/${e.path}" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`;t+="</Types>",this._zip.addFile("[Content_Types].xml",t)}_writeRels(){this._zip.addFile("_rels/.rels",'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>');let t='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">';for(let x of this._sl)t+=`<Relationship Id="${x.rId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/${x.fn}"/>`;let e=this._sl.length+1;t+=`<Relationship Id="rId${e++}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>`,t+=`<Relationship Id="rId${e++}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/>`,t+="</Relationships>",this._zip.addFile("xl/_rels/workbook.xml.rels",t)}};var P=/[\\/*?[\]:]/g,C=class{constructor(){this._zip=new F,this._sheetCount=0,this._sheetList=[],this._sstDic=new Map,this._sstCntUnique=0,this._sstCntAll=0,this._colWidths=[],this._autofilterIsOn=!1,this._oaEpoch=Date.UTC(1899,11,30),this._isStreaming=!1,this._currentSheetBuffer=null,this._currentSheetRowNum=0,this._currentSheetStartCol=0,this._currentSheetEndCol=0,this._currentSheetDoAutofilter=!1,this._fmtMap=new Map,this._nextNid=167,this._nextXf=4,this._sheet1Bytes=new Uint8Array([129,1,0,147,1,23,203,4,2,0,64,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,148,1,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,1,0,137,1,30,220,3,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,152,1,36,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,138,1,0,134,1,0,37,6,1,0,2,14,0,128,149,8,2,5,0,38,0,229,3,12,255,255,255,255,8,0,44,1,0,0,0,0,145,1,0,37,6,1,0,2,14,0,128,128,8,2,5,0,38,0,0,25,0,0,0,0,0,0,0,0,44,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,7,12,0,0,0,0,0,0,0,0,0,0,0,0,146,1,0,151,4,66,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,221,3,2,16,0,220,3,48,102,102,102,102,102,102,230,63,102,102,102,102,102,102,230,63,0,0,0,0,0,0,232,63,0,0,0,0,0,0,232,63,51,51,51,51,51,51,211,63,51,51,51,51,51,51,211,63,37,6,1,0,0,16,0,128,128,24,16,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,38,0,130,1,0]),this._workbookBinStart=new Uint8Array([131,1,0,128,1,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,120,0,108,0,1,0,0,0,55,0,1,0,0,0,54,0,5,0,0,0,50,0,52,0,51,0,50,0,54,0,153,1,12,32,0,1,0,0,0,0,0,0,0,0,0,37,6,1,0,3,15,0,128,151,16,52,24,0,0,0,67,0,58,0,92,0,115,0,113,0,108,0,115,0,92,0,84,0,101,0,115,0,116,0,121,0,90,0,97,0,112,0,105,0,115,0,117,0,88,0,108,0,115,0,98,0,92,0,38,0,37,6,1,0,0,16,0,128,129,24,130,1,0,0,0,0,0,0,0,0,47,0,0,0,49,0,51,0,95,0,110,0,99,0,114,0,58,0,49,0,95,0,123,0,49,0,54,0,53,0,48,0,56,0,68,0,54,0,57,0,45,0,67,0,70,0,56,0,55,0,45,0,52,0,55,0,54,0,57,0,45,0,56,0,52,0,53,0,54,0,45,0,68,0,52,0,65,0,52,0,48,0,49,0,49,0,51,0,49,0,53,0,54,0,55,0,125,0,47,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,0,135,1,0,37,6,1,0,2,16,0,128,128,24,16,0,0,0,0,13,0,0,0,255,255,255,255,0,0,0,0,38,0,158,1,29,0,0,0,0,158,22,0,0,180,105,0,0,232,38,0,0,88,2,0,0,0,0,0,0,0,0,0,0,120,136,1,0,143,1,0]),this._workbookBinMiddle=new Uint8Array([144,1,0]),this._workbookBinEnd=new Uint8Array([157,1,26,53,234,2,0,1,0,0,0,100,0,0,0,252,169,241,210,77,98,80,63,1,0,0,0,106,0,155,1,1,0,35,4,3,15,0,0,171,16,1,1,36,0,132,1,0]),this._stylesBin=new Uint8Array([150,2,0,231,4,4,2,0,0,0,44,44,164,0,19,0,0,0,121,0,121,0,121,0,121,0,92,0,45,0,109,0,109,0,92,0,45,0,100,0,100,0,92,0,32,0,104,0,104,0,58,0,109,0,109,0,44,30,166,0,12,0,0,0,121,0,121,0,121,0,121,0,92,0,45,0,109,0,109,0,92,0,45,0,100,0,100,0,232,4,0,227,4,4,2,0,0,0,43,39,220,0,0,0,144,1,0,0,0,2,0,0,7,1,0,0,0,0,0,255,2,7,0,0,0,67,0,97,0,108,0,105,0,98,0,114,0,105,0,43,39,220,0,1,0,188,2,0,0,0,2,238,0,7,1,0,0,0,0,0,255,2,7,0,0,0,67,0,97,0,108,0,105,0,98,0,114,0,105,0,37,6,1,0,2,14,0,128,129,8,0,38,0,228,4,0,219,4,4,2,0,0,0,45,68,0,0,0,0,3,64,0,0,0,0,0,255,3,65,0,0,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,45,68,17,0,0,0,3,64,0,0,0,0,0,255,3,65,0,0,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,220,4,0,229,4,4,1,0,0,0,46,51,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,230,4,0,242,4,4,1,0,0,0,47,16,255,255,0,0,0,0,0,0,0,0,0,0,16,16,0,0,243,4,0,233,4,4,6,0,0,0,47,16,0,0,0,0,0,0,0,0,0,0,0,0,16,16,0,0,47,16,0,0,164,0,0,0,0,0,0,0,0,0,16,16,1,0,47,16,0,0,166,0,0,0,0,0,0,0,0,0,16,16,1,0,47,16,0,0,0,0,1,0,0,0,0,0,0,0,16,16,1,0,47,16,0,0,0,0,0,0,1,0,0,0,0,0,16,16,1,0,47,16,0,0,0,0,1,0,1,0,0,0,0,0,16,16,1,0,234,4,0,235,4,4,1,0,0,0,37,6,1,0,2,17,0,128,128,24,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,0,48,28,0,0,0,0,1,0,0,0,8,0,0,0,78,0,111,0,114,0,109,0,97,0,108,0,110,0,121,0,236,4,0,249,3,4,0,0,0,0,250,3,0,252,3,80,0,0,0,0,17,0,0,0,84,0,97,0,98,0,108,0,101,0,83,0,116,0,121,0,108,0,101,0,77,0,101,0,100,0,105,0,117,0,109,0,50,0,17,0,0,0,80,0,105,0,118,0,111,0,116,0,83,0,116,0,121,0,108,0,101,0,76,0,105,0,103,0,104,0,116,0,49,0,54,0,253,3,0,35,4,2,14,0,0,235,8,0,246,8,42,0,0,0,0,17,0,0,0,83,0,108,0,105,0,99,0,101,0,114,0,83,0,116,0,121,0,108,0,101,0,76,0,105,0,103,0,104,0,116,0,49,0,247,8,0,236,8,0,36,0,35,4,3,15,0,0,176,16,0,178,16,50,0,0,0,0,21,0,0,0,84,0,105,0,109,0,101,0,83,0,108,0,105,0,99,0,101,0,114,0,83,0,116,0,121,0,108,0,101,0,76,0,105,0,103,0,104,0,116,0,49,0,179,16,0,177,16,0,36,0,151,2,0]),this._binaryIndexBin=new Uint8Array([42,24,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,149,2,0]),this._rRkIntegerLowerLimit=-1<<29,this._rRkIntegerUpperLimit=(1<<29)-1,this._autoFilterStartBytes=new Uint8Array([161,1,16]),this._autoFilterEndBytes=new Uint8Array([162,1,0]),this._stickHeaderA1bytes=new Uint8Array([151,1,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,63,1,0,0,0,0,0,0,0,2,0,0,0,3]),this._magicFilterExcel2016Fix0=new Uint8Array([225,2,0,229,2,0,234,2]),this._magicFilterExcel2016Fix1=new Uint8Array([39,70,33,0,0,0,0,255,0,0,0,15,0,0,0,95,0,70,0,105,0,108,0,116,0,101,0,114,0,68,0,97,0,116,0,97,0,98,0,97,0,115,0,101,0,15,0,0,0,59,255,0]),this._magicFilterExcel2016Fix2=new Uint8Array([0,0,0,0,255,255,255,255])}_sanitizeSheetName(t){if(!t||typeof t!="string")return`Sheet${this._sheetCount+1}`;let e=t.replace(P,"_");return e.length>31&&(e=e.substring(0,31)),e.trim().length===0&&(e=`Sheet${this._sheetCount+1}`),e}_registerFormat(t){if(this._fmtMap.has(t))return this._fmtMap.get(t).xf;let e=this._nextNid++,x=this._nextXf++;return this._fmtMap.set(t,{nid:e,xf:x}),x}_buildStylesBin(){if(this._fmtMap.size===0)return this._stylesBin;let t=this._stylesBin,e=-1;for(let u=3;u<t.length-3;u++)if(t[u]===232&&t[u+1]===4&&t[u+2]===0){e=u;break}let x=-1;for(let u=e+3;u<t.length-2;u++)if(t[u]===233&&t[u+1]===4){x=u;break}let s=-1;for(let u=x;u<t.length-3;u++)if(t[u]===234&&t[u+1]===4&&t[u+2]===0){s=u;break}let r=-1;for(let u=e+3;u<t.length-2;u++)if(t[u]===227&&t[u+1]===4){r=u;break}let o=2+this._fmtMap.size,i=4+this._fmtMap.size,n=[];function f(u){let w=[];for(;u>=128;)w.push(u&127|128),u>>>=7;return w.push(u&127),w}function c(u,w){return new Uint8Array([...f(u),...f(w.length),...w])}function h(u,w){let I=w.length,B=6+I*2,_=new Uint8Array(2+B);_[0]=44,_[1]=B;let U=new DataView(_.buffer);U.setUint16(2,u,!0),U.setUint32(4,I,!0);for(let E=0;E<I;E++){let L=w.charCodeAt(E);_[8+E*2]=L&255,_[8+E*2+1]=L>>8&255}return _}function l(u,w,I,B=0){let _=new Uint8Array(18),U=new DataView(_.buffer);return _[0]=47,_[1]=16,U.setUint16(2,u,!0),U.setUint16(4,w,!0),_[6]=B,_[14]=16,_[15]=16,U.setUint16(16,I,!0),_}n.push(t.subarray(0,3));let a=new Uint8Array(4);new DataView(a.buffer).setUint16(0,o,!0),n.push(c(615,a)),n.push(h(164,"yyyy\\-mm\\-dd\\ hh:mm:ss")),n.push(h(166,"yyyy\\-mm\\-dd"));for(let[u,w]of this._fmtMap)n.push(h(w.nid,u));n.push(c(616,new Uint8Array(0))),n.push(t.subarray(r,x));let m=new Uint8Array(4);new DataView(m.buffer).setUint16(0,i,!0),n.push(c(617,m)),n.push(l(0,0,0)),n.push(l(0,164,1)),n.push(l(0,166,1)),n.push(l(1,0,0,1));let g=[...this._fmtMap.entries()].sort((u,w)=>u[1].xf-w[1].xf);for(let[,u]of g)n.push(l(0,u.nid,1));n.push(c(618,new Uint8Array(0))),n.push(t.subarray(s+3));let p=0;for(let u of n)p+=u.length;let v=new Uint8Array(p),R=0;for(let u of n)v.set(u,R),R+=u.length;return v}addSheet(t,e=!1){let x=this._sanitizeSheetName(t);this._sheetCount++,this._sheetList.push({name:x,pathInArchive:`xl/worksheets/sheet${this._sheetCount}.bin`,hidden:e,nameInArchive:`sheet${this._sheetCount}.bin`,sheetId:this._sheetCount,filterHeaderRange:null})}startSheet(t,e,x,s={}){if(this._isStreaming)throw new Error("Already streaming");let{hidden:r=!1,doAutofilter:o=!0,headerStyle:i="bold"}=s,n=3;if(i==="fill"?n=4:i==="bold+fill"&&(n=5),this.addSheet(t,r),this._isStreaming=!0,this._currentSheetBuffer=new y,this._currentSheetRowNum=0,this._currentSheetStartCol=0,this._currentSheetEndCol=e,this._currentSheetDoAutofilter=o&&x!==void 0,this._colWidths=new Array(e).fill(-1),x)for(let f=0;f<e;f++){let h=1.3*(x[f]?x[f].length:0)+3;h>80&&(h=80),this._colWidths[f]<h&&(this._colWidths[f]=h)}if(this._writeSheetHeader(this._currentSheetBuffer,this._currentSheetStartCol,this._currentSheetEndCol,this._currentSheetDoAutofilter),x){this.createRowHeader(this._currentSheetBuffer,this._currentSheetRowNum,this._currentSheetStartCol,this._currentSheetEndCol);for(let f=0;f<x.length;f++)this.writeString(this._currentSheetBuffer,x[f],f,n);this._currentSheetRowNum++}}writeRow(t){if(!this._isStreaming)throw new Error("Not streaming");let e=this._currentSheetBuffer;this.createRowHeader(e,this._currentSheetRowNum,this._currentSheetStartCol,this._currentSheetEndCol);for(let x=0;x<t.length;x++)this._writeCell(e,t[x],x);this._currentSheetRowNum++}endSheet(){if(!this._isStreaming)throw new Error("Not streaming");let t=this._currentSheetBuffer;if(t.write(this._sheet1Bytes.subarray(218,290)),this._currentSheetDoAutofilter){this._autofilterIsOn=!0,t.write(this._autoFilterStartBytes);let e=new Uint8Array(8),x=new DataView(e.buffer);x.setInt32(0,0,!0),x.setInt32(4,this._currentSheetRowNum-1,!0),t.write(e);let s=new Uint8Array(8),r=new DataView(s.buffer);r.setInt32(0,this._currentSheetStartCol,!0),r.setInt32(4,this._currentSheetEndCol-1,!0),t.write(s),t.write(this._autoFilterEndBytes),this._sheetList[this._sheetCount-1].filterData={startRow:0,endRow:this._currentSheetRowNum-1,startColumn:this._currentSheetStartCol,endColumn:this._currentSheetEndCol-1}}t.write(this._sheet1Bytes.subarray(290)),this._zip.addFile(this._sheetList[this._sheetCount-1].pathInArchive,t.toUint8Array()),this._isStreaming=!1,this._currentSheetBuffer=null}writeSheet(t,e=null,x={}){let s=x.doAutofilter!==!1,r=x.headerStyle||"bold",o=3;r==="fill"?o=4:r==="bold+fill"&&(o=5);let i=new y,n=t.length>0?t[0].length:e?e.length:0;if(this._colWidths=new Array(n).fill(-1),e)for(let h=0;h<n;h++){let a=1.3*(e[h]?e[h].length:0)+3;a>80&&(a=80),this._colWidths[h]<a&&(this._colWidths[h]=a)}for(let h=0;h<Math.min(t.length,100);h++)for(let l=0;l<t[h].length;l++){let a=t[h][l];if(a==null)continue;let m=A(a)?a.value:a,p=1.3*(m instanceof Date?10:m.toString().length)+3;p>80&&(p=80),this._colWidths[l]<p&&(this._colWidths[l]=p)}let f=s&&!!e;this._writeSheetHeader(i,0,n,f);let c=0;if(e){this.createRowHeader(i,c,0,n);for(let h=0;h<e.length;h++)this.writeString(i,e[h],h,o);c++}for(let h=0;h<t.length;h++){this.createRowHeader(i,c,0,n);for(let l=0;l<t[h].length;l++)this._writeCell(i,t[h][l],l);c++}if(i.write(this._sheet1Bytes.subarray(218,290)),f){this._autofilterIsOn=!0,i.write(this._autoFilterStartBytes);let h=new Uint8Array(8),l=new DataView(h.buffer);l.setInt32(0,0,!0),l.setInt32(4,c-1,!0),i.write(h);let a=new Uint8Array(8),m=new DataView(a.buffer);m.setInt32(0,0,!0),m.setInt32(4,n-1,!0),i.write(a),i.write(this._autoFilterEndBytes),this._sheetList[this._sheetCount-1].filterData={startRow:0,endRow:c,startColumn:0,endColumn:n-1}}i.write(this._sheet1Bytes.subarray(290)),this._zip.addFile(this._sheetList[this._sheetCount-1].pathInArchive,i.toUint8Array())}_writeSheetHeader(t,e,x,s){let r=new Uint8Array(this._sheet1Bytes),o=new DataView(r.buffer);o.setInt32(40,e,!0),o.setInt32(44,x,!0),this._sheetCount!==1&&(r[54]=156),t.write(r.subarray(0,84)),s&&t.write(this._stickHeaderA1bytes),t.write(r.subarray(84,159)),t.writeByte(134),t.writeByte(3);for(let i=e;i<x;i++){t.writeByte(0),t.writeByte(60),t.writeByte(18),t.writeInt32LE(i),t.writeInt32LE(i);let n=this._colWidths[i]>0?this._colWidths[i]:10;t.writeInt32LE(Math.round(n*256)),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(2)}t.writeByte(0),t.writeByte(135),t.writeByte(3),t.writeByte(0),t.write(r.subarray(159,175)),t.write(new Uint8Array([38,0]))}_writeCell(t,e,x){if(e==null)return;let s=T(e),r=s!==null?D(e):e,o=s!==null?this._registerFormat(s):0;if(typeof r=="number")Number.isInteger(r)&&r>=this._rRkIntegerLowerLimit&&r<=this._rRkIntegerUpperLimit?this.writeRkNumberInteger(t,r,x,o):this.writeDouble(t,r,x,o);else if(typeof r=="bigint")this.writeString(t,r.toString(),x);else if(typeof r=="boolean")this.writeBool(t,r,x);else if(r instanceof Date){let i=(r.getTime()-this._oaEpoch)/864e5;this.writeDouble(t,i,x,s!==null?o:1)}else this.writeString(t,r.toString(),x,0,s!==null?o:void 0)}createRowHeader(t,e,x,s){t.ensureCapacity(27),t.writeUnsafeByte(0),t.writeUnsafeByte(25),t.writeUnsafeInt32LE(e),t.writeUnsafeInt32LE(0),t.writeUnsafeByte(44),t.writeUnsafeByte(1),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(1),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeInt32LE(x),t.writeUnsafeInt32LE(s)}writeRkNumberInteger(t,e,x,s=0){t.ensureCapacity(14),t.writeUnsafeByte(2),t.writeUnsafeByte(12),t.writeUnsafeInt32LE(x),t.writeUnsafeByte(s),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeInt32LE(e<<2|2)}writeDouble(t,e,x,s=0){t.ensureCapacity(18),t.writeUnsafeByte(5),t.writeUnsafeByte(16),t.writeUnsafeInt32LE(x),t.writeUnsafeByte(s),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeDoubleLE(e)}writeBool(t,e,x){t.ensureCapacity(13),t.writeUnsafeByte(4),t.writeUnsafeByte(9),t.writeUnsafeInt32LE(x),t.writeUnsafeInt32LE(0),t.writeUnsafeByte(e?1:0)}writeDateTime(t,e,x){this.writeDouble(t,(e.getTime()-this._oaEpoch)/864e5,x,1)}writeString(t,e,x,s=0,r=void 0){let o;this._sstDic.has(e)?o=this._sstDic.get(e):(o=this._sstCntUnique++,this._sstDic.set(e,o)),this._sstCntAll++;let i=r!==void 0?r:s;t.ensureCapacity(17),t.writeUnsafeByte(7),t.writeUnsafeByte(12),t.writeUnsafeInt32LE(x),t.writeUnsafeByte(i),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeInt32LE(o)}_saveSst(){let t=new y;t.writeByte(159),t.writeByte(1),t.writeByte(8),t.writeInt32LE(this._sstCntUnique),t.writeInt32LE(this._sstCntAll);for(let[e]of this._sstDic){let x=e.length;t.writeByte(19);let s=5+2*x;if(s>=128){t.writeByte(128+s%128);let r=s>>7;r>=256?t.writeByte(128+r%128):t.writeByte(r),t.writeByte(s>>14),s>>14>0&&t.writeByte(0)}else t.writeByte(s&255),t.writeByte(s>>8&255);t.writeInt32LE(x),t.writeUtf16LE(e)}t.writeByte(160),t.writeByte(1),t.writeByte(0),this._zip.addFile("xl/sharedStrings.bin",t.toUint8Array())}_writeFilterDefinedName(t,e,x){let s=e.filterData,r=new Uint8Array(this._magicFilterExcel2016Fix1);r[7]=e.sheetId-1,r[r.length-2]=x,t.push(r);let o=new Uint8Array(8),i=new DataView(o.buffer);i.setInt32(0,s.startRow,!0),i.setInt32(4,s.endRow,!0),t.push(o);let n=new Uint8Array(4),f=new DataView(n.buffer);f.setInt16(0,s.startColumn,!0),f.setInt16(2,s.endColumn,!0),t.push(n),t.push(this._magicFilterExcel2016Fix2)}finalize(){this._saveSst(),this._zip.addFile("xl/styles.bin",this._buildStylesBin());let t=[this._workbookBinStart];for(let i of this._sheetList){let n=`rId${i.sheetId}`,f=i.name,c=16+f.length*2+n.length*2,h=new Uint8Array(3+c),l=new DataView(h.buffer);h[0]=156,h[1]=1,h[2]=c;let a=3;l.setInt32(a,i.hidden?1:0,!0),a+=4,l.setInt32(a,i.sheetId,!0),a+=4,l.setInt32(a,n.length,!0),a+=4;for(let m=0;m<n.length;m++){let g=n.charCodeAt(m);h[a++]=g&255,h[a++]=g>>8&255}l.setInt32(a,f.length,!0),a+=4;for(let m=0;m<f.length;m++){let g=f.charCodeAt(m);h[a++]=g&255,h[a++]=g>>8&255}t.push(h)}if(t.push(this._workbookBinMiddle),this._autofilterIsOn){let i=this._sheetList.filter(n=>n.filterData);if(i.length>0){t.push(this._magicFilterExcel2016Fix0);let n=i.length,f=n<=20?16+(n-1)*12:128+(n-21)*12;t.push(n<=10?new Uint8Array([f,n,0,0,0]):new Uint8Array([f,Math.floor((n-1)/10),n,0,0,0]));for(let c=0;c<i.length;c++){let h=i[c].sheetId-1,l=new Uint8Array(12);l[4]=h,l[8]=h,t.push(l)}t.push(new Uint8Array([226,2,0]));for(let c=0;c<i.length;c++)this._writeFilterDefinedName(t,i[c],c)}}t.push(this._workbookBinEnd);let e=0;for(let i of t)e+=i.length;let x=new Uint8Array(e),s=0;for(let i of t)x.set(i,s),s+=i.length;this._zip.addFile("xl/workbook.bin",x);for(let i of this._sheetList)this._zip.addFile(`xl/worksheets/binaryIndex${i.sheetId}.bin`,this._binaryIndexBin);let r=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
17
+ </styleSheet>`)}_writeWb(){let t='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><fileVersion appName="xl" lastEdited="4" lowestEdited="4" rupBuild="4505"/><workbookPr defaultThemeVersion="124226"/><bookViews><workbookView xWindow="240" yWindow="15" windowWidth="16095" windowHeight="9660"/></bookViews><sheets>';for(let e of this._sl)t+=`<sheet name="${this._ex(e.name)}" sheetId="${e.id}"${e.hidden?' state="hidden"':""} r:id="${e.rId}"/>`;if(t+="</sheets>",this._afOn){t+="<definedNames>";for(let e of this._sl)e.fhr&&(t+=`<definedName name="_xlnm._FilterDatabase" localSheetId="${e.id-1}" hidden="1">${this._esc(e.fhr)}</definedName>`);t+="</definedNames>"}t+='<calcPr calcId="124519" fullCalcOnLoad="1"/></workbook>',this._zip.addFile("xl/workbook.xml",t)}_writeCt(){let t='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/><Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"/>';for(let e of this._sl)t+=`<Override PartName="/${e.path}" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`;t+="</Types>",this._zip.addFile("[Content_Types].xml",t)}_writeRels(){this._zip.addFile("_rels/.rels",'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>');let t='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">';for(let x of this._sl)t+=`<Relationship Id="${x.rId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/${x.fn}"/>`;let e=this._sl.length+1;t+=`<Relationship Id="rId${e++}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>`,t+=`<Relationship Id="rId${e++}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/>`,t+="</Relationships>",this._zip.addFile("xl/_rels/workbook.xml.rels",t)}};var P=/[\\/*?[\]:]/g,C=class{constructor(){this._zip=new F,this._sheetCount=0,this._sheetList=[],this._sstDic=new Map,this._sstCntUnique=0,this._sstCntAll=0,this._colWidths=[],this._autofilterIsOn=!1,this._oaEpoch=Date.UTC(1899,11,30),this._isStreaming=!1,this._currentSheetBuffer=null,this._currentSheetRowNum=0,this._currentSheetStartCol=0,this._currentSheetEndCol=0,this._currentSheetDoAutofilter=!1,this._fmtMap=new Map,this._nextNid=167,this._nextXf=4,this._sheet1Bytes=new Uint8Array([129,1,0,147,1,23,203,4,2,0,64,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,148,1,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,1,0,137,1,30,220,3,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,152,1,36,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,138,1,0,134,1,0,37,6,1,0,2,14,0,128,149,8,2,5,0,38,0,229,3,12,255,255,255,255,8,0,44,1,0,0,0,0,145,1,0,37,6,1,0,2,14,0,128,128,8,2,5,0,38,0,0,25,0,0,0,0,0,0,0,0,44,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,7,12,0,0,0,0,0,0,0,0,0,0,0,0,146,1,0,151,4,66,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,221,3,2,16,0,220,3,48,102,102,102,102,102,102,230,63,102,102,102,102,102,102,230,63,0,0,0,0,0,0,232,63,0,0,0,0,0,0,232,63,51,51,51,51,51,51,211,63,51,51,51,51,51,51,211,63,37,6,1,0,0,16,0,128,128,24,16,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,38,0,130,1,0]),this._workbookBinStart=new Uint8Array([131,1,0,128,1,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,120,0,108,0,1,0,0,0,55,0,1,0,0,0,54,0,5,0,0,0,50,0,52,0,51,0,50,0,54,0,153,1,12,32,0,1,0,0,0,0,0,0,0,0,0,37,6,1,0,3,15,0,128,151,16,52,24,0,0,0,67,0,58,0,92,0,115,0,113,0,108,0,115,0,92,0,84,0,101,0,115,0,116,0,121,0,90,0,97,0,112,0,105,0,115,0,117,0,88,0,108,0,115,0,98,0,92,0,38,0,37,6,1,0,0,16,0,128,129,24,130,1,0,0,0,0,0,0,0,0,47,0,0,0,49,0,51,0,95,0,110,0,99,0,114,0,58,0,49,0,95,0,123,0,49,0,54,0,53,0,48,0,56,0,68,0,54,0,57,0,45,0,67,0,70,0,56,0,55,0,45,0,52,0,55,0,54,0,57,0,45,0,56,0,52,0,53,0,54,0,45,0,68,0,52,0,65,0,52,0,48,0,49,0,49,0,51,0,49,0,53,0,54,0,55,0,125,0,47,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,0,135,1,0,37,6,1,0,2,16,0,128,128,24,16,0,0,0,0,13,0,0,0,255,255,255,255,0,0,0,0,38,0,158,1,29,0,0,0,0,158,22,0,0,180,105,0,0,232,38,0,0,88,2,0,0,0,0,0,0,0,0,0,0,120,136,1,0,143,1,0]),this._workbookBinMiddle=new Uint8Array([144,1,0]),this._workbookBinEnd=new Uint8Array([157,1,26,53,234,2,0,1,0,0,0,100,0,0,0,252,169,241,210,77,98,80,63,1,0,0,0,106,0,155,1,1,0,35,4,3,15,0,0,171,16,1,1,36,0,132,1,0]),this._stylesBin=new Uint8Array([150,2,0,231,4,4,2,0,0,0,44,44,164,0,19,0,0,0,121,0,121,0,121,0,121,0,92,0,45,0,109,0,109,0,92,0,45,0,100,0,100,0,92,0,32,0,104,0,104,0,58,0,109,0,109,0,44,30,166,0,12,0,0,0,121,0,121,0,121,0,121,0,92,0,45,0,109,0,109,0,92,0,45,0,100,0,100,0,232,4,0,227,4,4,2,0,0,0,43,39,220,0,0,0,144,1,0,0,0,2,0,0,7,1,0,0,0,0,0,255,2,7,0,0,0,67,0,97,0,108,0,105,0,98,0,114,0,105,0,43,39,220,0,1,0,188,2,0,0,0,2,238,0,7,1,0,0,0,0,0,255,2,7,0,0,0,67,0,97,0,108,0,105,0,98,0,114,0,105,0,37,6,1,0,2,14,0,128,129,8,0,38,0,228,4,0,219,4,4,2,0,0,0,45,68,0,0,0,0,3,64,0,0,0,0,0,255,3,65,0,0,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,45,68,17,0,0,0,3,64,0,0,0,0,0,255,3,65,0,0,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,220,4,0,229,4,4,1,0,0,0,46,51,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,230,4,0,242,4,4,1,0,0,0,47,16,255,255,0,0,0,0,0,0,0,0,0,0,16,16,0,0,243,4,0,233,4,4,6,0,0,0,47,16,0,0,0,0,0,0,0,0,0,0,0,0,16,16,0,0,47,16,0,0,164,0,0,0,0,0,0,0,0,0,16,16,1,0,47,16,0,0,166,0,0,0,0,0,0,0,0,0,16,16,1,0,47,16,0,0,0,0,1,0,0,0,0,0,0,0,16,16,1,0,47,16,0,0,0,0,0,0,1,0,0,0,0,0,16,16,1,0,47,16,0,0,0,0,1,0,1,0,0,0,0,0,16,16,1,0,234,4,0,235,4,4,1,0,0,0,37,6,1,0,2,17,0,128,128,24,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,0,48,28,0,0,0,0,1,0,0,0,8,0,0,0,78,0,111,0,114,0,109,0,97,0,108,0,110,0,121,0,236,4,0,249,3,4,0,0,0,0,250,3,0,252,3,80,0,0,0,0,17,0,0,0,84,0,97,0,98,0,108,0,101,0,83,0,116,0,121,0,108,0,101,0,77,0,101,0,100,0,105,0,117,0,109,0,50,0,17,0,0,0,80,0,105,0,118,0,111,0,116,0,83,0,116,0,121,0,108,0,101,0,76,0,105,0,103,0,104,0,116,0,49,0,54,0,253,3,0,35,4,2,14,0,0,235,8,0,246,8,42,0,0,0,0,17,0,0,0,83,0,108,0,105,0,99,0,101,0,114,0,83,0,116,0,121,0,108,0,101,0,76,0,105,0,103,0,104,0,116,0,49,0,247,8,0,236,8,0,36,0,35,4,3,15,0,0,176,16,0,178,16,50,0,0,0,0,21,0,0,0,84,0,105,0,109,0,101,0,83,0,108,0,105,0,99,0,101,0,114,0,83,0,116,0,121,0,108,0,101,0,76,0,105,0,103,0,104,0,116,0,49,0,179,16,0,177,16,0,36,0,151,2,0]),this._binaryIndexBin=new Uint8Array([42,24,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,149,2,0]),this._rRkIntegerLowerLimit=-1<<29,this._rRkIntegerUpperLimit=(1<<29)-1,this._autoFilterStartBytes=new Uint8Array([161,1,16]),this._autoFilterEndBytes=new Uint8Array([162,1,0]),this._stickHeaderA1bytes=new Uint8Array([151,1,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,63,1,0,0,0,0,0,0,0,2,0,0,0,3]),this._magicFilterExcel2016Fix0=new Uint8Array([225,2,0,229,2,0,234,2]),this._magicFilterExcel2016Fix1=new Uint8Array([39,70,33,0,0,0,0,255,0,0,0,15,0,0,0,95,0,70,0,105,0,108,0,116,0,101,0,114,0,68,0,97,0,116,0,97,0,98,0,97,0,115,0,101,0,15,0,0,0,59,255,0]),this._magicFilterExcel2016Fix2=new Uint8Array([0,0,0,0,255,255,255,255])}_sanitizeSheetName(t){if(!t||typeof t!="string")return`Sheet${this._sheetCount+1}`;let e=t.replace(P,"_");return e.length>31&&(e=e.substring(0,31)),e.trim().length===0&&(e=`Sheet${this._sheetCount+1}`),e}_registerFormat(t){if(this._fmtMap.has(t))return this._fmtMap.get(t).xf;let e=this._nextNid++,x=this._nextXf++;return this._fmtMap.set(t,{nid:e,xf:x}),x}_buildStylesBin(){if(this._fmtMap.size===0)return this._stylesBin;let t=this._stylesBin,e=-1;for(let u=3;u<t.length-3;u++)if(t[u]===232&&t[u+1]===4&&t[u+2]===0){e=u;break}let x=-1;for(let u=e+3;u<t.length-2;u++)if(t[u]===233&&t[u+1]===4){x=u;break}let s=-1;for(let u=x;u<t.length-3;u++)if(t[u]===234&&t[u+1]===4&&t[u+2]===0){s=u;break}let i=-1;for(let u=e+3;u<t.length-2;u++)if(t[u]===227&&t[u+1]===4){i=u;break}let n=2+this._fmtMap.size,r=4+this._fmtMap.size,o=[];function f(u){let w=[];for(;u>=128;)w.push(u&127|128),u>>>=7;return w.push(u&127),w}function c(u,w){return new Uint8Array([...f(u),...f(w.length),...w])}function h(u,w){let I=w.length,B=6+I*2,_=new Uint8Array(2+B);_[0]=44,_[1]=B;let U=new DataView(_.buffer);U.setUint16(2,u,!0),U.setUint32(4,I,!0);for(let E=0;E<I;E++){let L=w.charCodeAt(E);_[8+E*2]=L&255,_[8+E*2+1]=L>>8&255}return _}function l(u,w,I,B=0){let _=new Uint8Array(18),U=new DataView(_.buffer);return _[0]=47,_[1]=16,U.setUint16(2,u,!0),U.setUint16(4,w,!0),_[6]=B,_[14]=16,_[15]=16,U.setUint16(16,I,!0),_}o.push(t.subarray(0,3));let a=new Uint8Array(4);new DataView(a.buffer).setUint16(0,n,!0),o.push(c(615,a)),o.push(h(164,"yyyy\\-mm\\-dd\\ hh:mm:ss")),o.push(h(166,"yyyy\\-mm\\-dd"));for(let[u,w]of this._fmtMap)o.push(h(w.nid,u));o.push(c(616,new Uint8Array(0))),o.push(t.subarray(i,x));let m=new Uint8Array(4);new DataView(m.buffer).setUint16(0,r,!0),o.push(c(617,m)),o.push(l(0,0,0)),o.push(l(0,164,1)),o.push(l(0,166,1)),o.push(l(1,0,0,1));let g=[...this._fmtMap.entries()].sort((u,w)=>u[1].xf-w[1].xf);for(let[,u]of g)o.push(l(0,u.nid,1));o.push(c(618,new Uint8Array(0))),o.push(t.subarray(s+3));let p=0;for(let u of o)p+=u.length;let v=new Uint8Array(p),R=0;for(let u of o)v.set(u,R),R+=u.length;return v}addSheet(t,e=!1){let x=this._sanitizeSheetName(t);this._sheetCount++,this._sheetList.push({name:x,pathInArchive:`xl/worksheets/sheet${this._sheetCount}.bin`,hidden:e,nameInArchive:`sheet${this._sheetCount}.bin`,sheetId:this._sheetCount,filterHeaderRange:null})}startSheet(t,e,x,s={}){if(this._isStreaming)throw new Error("Already streaming");let{hidden:i=!1,doAutofilter:n=!0,headerStyle:r="bold"}=s,o=3;if(r==="fill"?o=4:r==="bold+fill"&&(o=5),this.addSheet(t,i),this._isStreaming=!0,this._currentSheetBuffer=new y,this._currentSheetRowNum=0,this._currentSheetStartCol=0,this._currentSheetEndCol=e,this._currentSheetDoAutofilter=n&&x!==void 0,this._colWidths=new Array(e).fill(-1),x)for(let f=0;f<e;f++){let h=1.3*(x[f]?x[f].length:0)+3;h>80&&(h=80),this._colWidths[f]<h&&(this._colWidths[f]=h)}if(this._writeSheetHeader(this._currentSheetBuffer,this._currentSheetStartCol,this._currentSheetEndCol,this._currentSheetDoAutofilter),x){this.createRowHeader(this._currentSheetBuffer,this._currentSheetRowNum,this._currentSheetStartCol,this._currentSheetEndCol);for(let f=0;f<x.length;f++)this.writeString(this._currentSheetBuffer,x[f],f,o);this._currentSheetRowNum++}}writeRow(t){if(!this._isStreaming)throw new Error("Not streaming");let e=this._currentSheetBuffer;this.createRowHeader(e,this._currentSheetRowNum,this._currentSheetStartCol,this._currentSheetEndCol);for(let x=0;x<t.length;x++)this._writeCell(e,t[x],x);this._currentSheetRowNum++}endSheet(){if(!this._isStreaming)throw new Error("Not streaming");let t=this._currentSheetBuffer;if(t.write(this._sheet1Bytes.subarray(218,290)),this._currentSheetDoAutofilter){this._autofilterIsOn=!0,t.write(this._autoFilterStartBytes);let e=new Uint8Array(8),x=new DataView(e.buffer);x.setInt32(0,0,!0),x.setInt32(4,this._currentSheetRowNum-1,!0),t.write(e);let s=new Uint8Array(8),i=new DataView(s.buffer);i.setInt32(0,this._currentSheetStartCol,!0),i.setInt32(4,this._currentSheetEndCol-1,!0),t.write(s),t.write(this._autoFilterEndBytes),this._sheetList[this._sheetCount-1].filterData={startRow:0,endRow:this._currentSheetRowNum-1,startColumn:this._currentSheetStartCol,endColumn:this._currentSheetEndCol-1}}t.write(this._sheet1Bytes.subarray(290)),this._zip.addFile(this._sheetList[this._sheetCount-1].pathInArchive,t.toUint8Array()),this._isStreaming=!1,this._currentSheetBuffer=null}writeSheet(t,e=null,x={}){let s=x.doAutofilter!==!1,i=x.headerStyle||"bold",n=3;i==="fill"?n=4:i==="bold+fill"&&(n=5);let r=new y,o=t.length>0?t[0].length:e?e.length:0;if(this._colWidths=new Array(o).fill(-1),e)for(let h=0;h<o;h++){let a=1.3*(e[h]?e[h].length:0)+3;a>80&&(a=80),this._colWidths[h]<a&&(this._colWidths[h]=a)}for(let h=0;h<Math.min(t.length,100);h++)for(let l=0;l<t[h].length;l++){let a=t[h][l];if(a==null)continue;let m=A(a)?a.value:a,p=1.3*(m instanceof Date?10:m.toString().length)+3;p>80&&(p=80),this._colWidths[l]<p&&(this._colWidths[l]=p)}let f=s&&!!e;this._writeSheetHeader(r,0,o,f);let c=0;if(e){this.createRowHeader(r,c,0,o);for(let h=0;h<e.length;h++)this.writeString(r,e[h],h,n);c++}for(let h=0;h<t.length;h++){this.createRowHeader(r,c,0,o);for(let l=0;l<t[h].length;l++)this._writeCell(r,t[h][l],l);c++}if(r.write(this._sheet1Bytes.subarray(218,290)),f){this._autofilterIsOn=!0,r.write(this._autoFilterStartBytes);let h=new Uint8Array(8),l=new DataView(h.buffer);l.setInt32(0,0,!0),l.setInt32(4,c-1,!0),r.write(h);let a=new Uint8Array(8),m=new DataView(a.buffer);m.setInt32(0,0,!0),m.setInt32(4,o-1,!0),r.write(a),r.write(this._autoFilterEndBytes),this._sheetList[this._sheetCount-1].filterData={startRow:0,endRow:c,startColumn:0,endColumn:o-1}}r.write(this._sheet1Bytes.subarray(290)),this._zip.addFile(this._sheetList[this._sheetCount-1].pathInArchive,r.toUint8Array())}_writeSheetHeader(t,e,x,s){let i=new Uint8Array(this._sheet1Bytes),n=new DataView(i.buffer);n.setInt32(40,e,!0),n.setInt32(44,x,!0),this._sheetCount!==1&&(i[54]=156),t.write(i.subarray(0,84)),s&&t.write(this._stickHeaderA1bytes),t.write(i.subarray(84,159)),t.writeByte(134),t.writeByte(3);for(let r=e;r<x;r++){t.writeByte(0),t.writeByte(60),t.writeByte(18),t.writeInt32LE(r),t.writeInt32LE(r);let o=this._colWidths[r]>0?this._colWidths[r]:10;t.writeInt32LE(Math.round(o*256)),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(2)}t.writeByte(0),t.writeByte(135),t.writeByte(3),t.writeByte(0),t.write(i.subarray(159,175)),t.write(new Uint8Array([38,0]))}_writeCell(t,e,x){if(e==null)return;let s=T(e),i=s!==null?D(e):e,n=s!==null?this._registerFormat(s):0;if(typeof i=="number")Number.isInteger(i)&&i>=this._rRkIntegerLowerLimit&&i<=this._rRkIntegerUpperLimit?this.writeRkNumberInteger(t,i,x,n):this.writeDouble(t,i,x,n);else if(typeof i=="bigint")this.writeString(t,i.toString(),x);else if(typeof i=="boolean")this.writeBool(t,i,x);else if(i instanceof Date){let r=(i.getTime()-this._oaEpoch)/864e5;this.writeDouble(t,r,x,s!==null?n:1)}else this.writeString(t,i.toString(),x,0,s!==null?n:void 0)}createRowHeader(t,e,x,s){t.ensureCapacity(27),t.writeUnsafeByte(0),t.writeUnsafeByte(25),t.writeUnsafeInt32LE(e),t.writeUnsafeInt32LE(0),t.writeUnsafeByte(44),t.writeUnsafeByte(1),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(1),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeInt32LE(x),t.writeUnsafeInt32LE(s)}writeRkNumberInteger(t,e,x,s=0){t.ensureCapacity(14),t.writeUnsafeByte(2),t.writeUnsafeByte(12),t.writeUnsafeInt32LE(x),t.writeUnsafeByte(s),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeInt32LE(e<<2|2)}writeDouble(t,e,x,s=0){t.ensureCapacity(18),t.writeUnsafeByte(5),t.writeUnsafeByte(16),t.writeUnsafeInt32LE(x),t.writeUnsafeByte(s),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeDoubleLE(e)}writeBool(t,e,x){t.ensureCapacity(13),t.writeUnsafeByte(4),t.writeUnsafeByte(9),t.writeUnsafeInt32LE(x),t.writeUnsafeInt32LE(0),t.writeUnsafeByte(e?1:0)}writeDateTime(t,e,x){this.writeDouble(t,(e.getTime()-this._oaEpoch)/864e5,x,1)}writeString(t,e,x,s=0,i=void 0){let n;this._sstDic.has(e)?n=this._sstDic.get(e):(n=this._sstCntUnique++,this._sstDic.set(e,n)),this._sstCntAll++;let r=i!==void 0?i:s;t.ensureCapacity(17),t.writeUnsafeByte(7),t.writeUnsafeByte(12),t.writeUnsafeInt32LE(x),t.writeUnsafeByte(r),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeByte(0),t.writeUnsafeInt32LE(n)}_saveSst(){let t=new y;t.writeByte(159),t.writeByte(1),t.writeByte(8),t.writeInt32LE(this._sstCntUnique),t.writeInt32LE(this._sstCntAll);for(let[e]of this._sstDic){let x=e.length;t.writeByte(19);let s=5+2*x;if(s>=128){t.writeByte(128+s%128);let i=s>>7;i>=256?t.writeByte(128+i%128):t.writeByte(i),t.writeByte(s>>14),s>>14>0&&t.writeByte(0)}else t.writeByte(s&255),t.writeByte(s>>8&255);t.writeInt32LE(x),t.writeUtf16LE(e)}t.writeByte(160),t.writeByte(1),t.writeByte(0),this._zip.addFile("xl/sharedStrings.bin",t.toUint8Array())}_writeFilterDefinedName(t,e,x){let s=e.filterData,i=new Uint8Array(this._magicFilterExcel2016Fix1);i[7]=e.sheetId-1,i[i.length-2]=x,t.push(i);let n=new Uint8Array(8),r=new DataView(n.buffer);r.setInt32(0,s.startRow,!0),r.setInt32(4,s.endRow,!0),t.push(n);let o=new Uint8Array(4),f=new DataView(o.buffer);f.setInt16(0,s.startColumn,!0),f.setInt16(2,s.endColumn,!0),t.push(o),t.push(this._magicFilterExcel2016Fix2)}finalize(){this._saveSst(),this._zip.addFile("xl/styles.bin",this._buildStylesBin());let t=[this._workbookBinStart];for(let r of this._sheetList){let o=`rId${r.sheetId}`,f=r.name,c=16+f.length*2+o.length*2,h=new Uint8Array(3+c),l=new DataView(h.buffer);h[0]=156,h[1]=1,h[2]=c;let a=3;l.setInt32(a,r.hidden?1:0,!0),a+=4,l.setInt32(a,r.sheetId,!0),a+=4,l.setInt32(a,o.length,!0),a+=4;for(let m=0;m<o.length;m++){let g=o.charCodeAt(m);h[a++]=g&255,h[a++]=g>>8&255}l.setInt32(a,f.length,!0),a+=4;for(let m=0;m<f.length;m++){let g=f.charCodeAt(m);h[a++]=g&255,h[a++]=g>>8&255}t.push(h)}if(t.push(this._workbookBinMiddle),this._autofilterIsOn){let r=this._sheetList.filter(o=>o.filterData);if(r.length>0){t.push(this._magicFilterExcel2016Fix0);let o=r.length,f=o<=20?16+(o-1)*12:128+(o-21)*12;t.push(o<=10?new Uint8Array([f,o,0,0,0]):new Uint8Array([f,Math.floor((o-1)/10),o,0,0,0]));for(let c=0;c<r.length;c++){let h=r[c].sheetId-1,l=new Uint8Array(12);l[4]=h,l[8]=h,t.push(l)}t.push(new Uint8Array([226,2,0]));for(let c=0;c<r.length;c++)this._writeFilterDefinedName(t,r[c],c)}}t.push(this._workbookBinEnd);let e=0;for(let r of t)e+=r.length;let x=new Uint8Array(e),s=0;for(let r of t)x.set(r,s),s+=r.length;this._zip.addFile("xl/workbook.bin",x);for(let r of this._sheetList)this._zip.addFile(`xl/worksheets/binaryIndex${r.sheetId}.bin`,this._binaryIndexBin);let i=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
18
18
  <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
19
19
  <Default Extension="bin" ContentType="application/vnd.ms-excel.sheet.binary.macroEnabled.main"/>
20
20
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
21
- <Default Extension="xml" ContentType="application/xml"/>`;for(let i of this._sheetList)r+=`<Override PartName="/${i.pathInArchive}" ContentType="application/vnd.ms-excel.worksheet"/>
22
- <Override PartName="/xl/worksheets/binaryIndex${i.sheetId}.bin" ContentType="application/vnd.ms-excel.binIndexWs"/>
23
- `;r+=`<Override PartName="/xl/styles.bin" ContentType="application/vnd.ms-excel.styles"/>
21
+ <Default Extension="xml" ContentType="application/xml"/>`;for(let r of this._sheetList)i+=`<Override PartName="/${r.pathInArchive}" ContentType="application/vnd.ms-excel.worksheet"/>
22
+ <Override PartName="/xl/worksheets/binaryIndex${r.sheetId}.bin" ContentType="application/vnd.ms-excel.binIndexWs"/>
23
+ `;i+=`<Override PartName="/xl/styles.bin" ContentType="application/vnd.ms-excel.styles"/>
24
24
  <Override PartName="/xl/sharedStrings.bin" ContentType="application/vnd.ms-excel.sharedStrings"/>
25
- </Types>`,this._zip.addFile("[Content_Types].xml",r);let o=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
25
+ </Types>`,this._zip.addFile("[Content_Types].xml",i);let n=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
26
26
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
27
- `;for(let i of this._sheetList)o+=`<Relationship Id="rId${i.sheetId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/${i.nameInArchive}"/>
28
- `;o+=`<Relationship Id="rId${this._sheetList.length+2}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.bin"/>
27
+ `;for(let r of this._sheetList)n+=`<Relationship Id="rId${r.sheetId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/${r.nameInArchive}"/>
28
+ `;n+=`<Relationship Id="rId${this._sheetList.length+2}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.bin"/>
29
29
  <Relationship Id="rId${this._sheetList.length+3}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.bin"/>
30
- </Relationships>`,this._zip.addFile("xl/_rels/workbook.bin.rels",o),this._zip.addFile("_rels/.rels",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
30
+ </Relationships>`,this._zip.addFile("xl/_rels/workbook.bin.rels",n),this._zip.addFile("_rels/.rels",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
31
31
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
32
32
  <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.bin"/>
33
- </Relationships>`);for(let i of this._sheetList)this._zip.addFile(`xl/worksheets/_rels/${i.nameInArchive}.rels`,`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
33
+ </Relationships>`);for(let r of this._sheetList)this._zip.addFile(`xl/worksheets/_rels/${r.nameInArchive}.rels`,`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
34
34
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
35
- <Relationship Id="rId1" Type="http://schemas.microsoft.com/office/2006/relationships/xlBinaryIndex" Target="binaryIndex${i.sheetId}.bin"/>
35
+ <Relationship Id="rId1" Type="http://schemas.microsoft.com/office/2006/relationships/xlBinaryIndex" Target="binaryIndex${r.sheetId}.bin"/>
36
36
  </Relationships>`);return this._zip.toBlob()}};function k(d,t){let e=URL.createObjectURL(d),x=document.createElement("a");x.href=e,x.download=t,document.body.appendChild(x),x.click(),document.body.removeChild(x),setTimeout(()=>URL.revokeObjectURL(e),5e3)}function X(d,t,e,x="Sheet1"){let s=new S;s.addSheet(x),s.writeSheet(t,e,{doAutofilter:!0}),k(s.finalize(),d)}function Y(d,t){let e=new S;for(let x of t)e.addSheet(x.name),e.writeSheet(x.rows,x.headers,{doAutofilter:!0});k(e.finalize(),d)}function q(d,t,e,x="Sheet1"){let s=new C;s.addSheet(x),s.writeSheet(t,e,{doAutofilter:!0}),k(s.finalize(),d)}function j(d,t){let e=new C;for(let x of t)e.addSheet(x.name),e.writeSheet(x.rows,x.headers,{doAutofilter:!0});k(e.finalize(),d)}return W(G);})();