@rosperitus/excelerate 0.14.0 → 0.16.0

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.
@@ -0,0 +1,2681 @@
1
+ /* @ts-self-types="./excelerate.d.ts" */
2
+
3
+ /**
4
+ * A workbook.
5
+ */
6
+ export class Book {
7
+ static __wrap(ptr) {
8
+ const obj = Object.create(Book.prototype);
9
+ obj.__wbg_ptr = ptr;
10
+ BookFinalization.register(obj, obj.__wbg_ptr, obj);
11
+ return obj;
12
+ }
13
+ __destroy_into_raw() {
14
+ const ptr = this.__wbg_ptr;
15
+ this.__wbg_ptr = 0;
16
+ BookFinalization.unregister(this);
17
+ return ptr;
18
+ }
19
+ free() {
20
+ const ptr = this.__destroy_into_raw();
21
+ wasm.__wbg_book_free(ptr, 0);
22
+ }
23
+ /**
24
+ * The tab a reader opens the workbook on.
25
+ * @returns {number}
26
+ */
27
+ activeSheet() {
28
+ const ret = wasm.book_activeSheet(this.__wbg_ptr);
29
+ return ret >>> 0;
30
+ }
31
+ /**
32
+ * Adds a data validation rule to a sheet, as Data - Data Validation
33
+ * does: `type` is `"whole"`, `"decimal"`, `"list"`, `"date"`, `"time"`,
34
+ * `"textLength"` or `"custom"`, `operator` one of `"between"` (the
35
+ * default), `"notBetween"`, `"equal"`, `"notEqual"`, `"greaterThan"`,
36
+ * `"lessThan"`, `"greaterThanOrEqual"`, `"lessThanOrEqual"`. Formulas are
37
+ * written for the first cell of `sqref`; a list is `"\"Yes,No\""` or a
38
+ * range such as `"$E$1:$E$5"`.
39
+ *
40
+ * ```js
41
+ * book.addDataValidation(0, { sqref: "B2:B100", type: "list", formula1: "\"Yes,No\"" });
42
+ * ```
43
+ * @param {number} sheet
44
+ * @param {NewDataValidation} rule
45
+ */
46
+ addDataValidation(sheet, rule) {
47
+ const ret = wasm.book_addDataValidation(this.__wbg_ptr, sheet, rule);
48
+ if (ret[1]) {
49
+ throw takeFromExternrefTable0(ret[0]);
50
+ }
51
+ }
52
+ /**
53
+ * Appends a sheet and returns its index.
54
+ * @param {string} title
55
+ * @returns {number}
56
+ */
57
+ addSheet(title) {
58
+ const ptr0 = passStringToWasm0(title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
59
+ const len0 = WASM_VECTOR_LEN;
60
+ const ret = wasm.book_addSheet(this.__wbg_ptr, ptr0, len0);
61
+ if (ret[2]) {
62
+ throw takeFromExternrefTable0(ret[1]);
63
+ }
64
+ return ret[0] >>> 0;
65
+ }
66
+ /**
67
+ * Draws a table over a range, the thing `Sales[Amount]` names.
68
+ *
69
+ * The first row of the range is the header unless `headerRow` says
70
+ * otherwise, and the column names are read from it. The name must be
71
+ * unique in the workbook, as Excel requires.
72
+ * @param {number} sheet
73
+ * @param {string} name
74
+ * @param {string} range
75
+ * @param {boolean | null} [header_row]
76
+ */
77
+ addTable(sheet, name, range, header_row) {
78
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
79
+ const len0 = WASM_VECTOR_LEN;
80
+ const ptr1 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
81
+ const len1 = WASM_VECTOR_LEN;
82
+ const ret = wasm.book_addTable(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(header_row) ? 0xFFFFFF : header_row ? 1 : 0);
83
+ if (ret[1]) {
84
+ throw takeFromExternrefTable0(ret[0]);
85
+ }
86
+ }
87
+ /**
88
+ * The array formulas of a sheet, as the areas they cover: `["B2:B4"]`.
89
+ * The formula itself is on the top left cell of each.
90
+ * @param {number} sheet
91
+ * @returns {string[]}
92
+ */
93
+ arrayFormulas(sheet) {
94
+ const ret = wasm.book_arrayFormulas(this.__wbg_ptr, sheet);
95
+ if (ret[3]) {
96
+ throw takeFromExternrefTable0(ret[2]);
97
+ }
98
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
99
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
100
+ return v1;
101
+ }
102
+ /**
103
+ * The autofilter over a sheet, or `undefined` when it has none. What the
104
+ * filter hides is a property of each row - see `rowHidden`.
105
+ * @param {number} sheet
106
+ * @returns {SheetAutoFilter | undefined}
107
+ */
108
+ autoFilter(sheet) {
109
+ const ret = wasm.book_autoFilter(this.__wbg_ptr, sheet);
110
+ if (ret[2]) {
111
+ throw takeFromExternrefTable0(ret[1]);
112
+ }
113
+ return takeFromExternrefTable0(ret[0]);
114
+ }
115
+ /**
116
+ * Whether a cell is bold.
117
+ *
118
+ * The one flag, without building the rest of the style: a parser that
119
+ * looks for a header row asks this of every cell, and `cellStyle` would
120
+ * make it pay for the font, fill and four borders it never reads.
121
+ * @param {number} sheet
122
+ * @param {string} address
123
+ * @returns {boolean}
124
+ */
125
+ cellBold(sheet, address) {
126
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
127
+ const len0 = WASM_VECTOR_LEN;
128
+ const ret = wasm.book_cellBold(this.__wbg_ptr, sheet, ptr0, len0);
129
+ if (ret[2]) {
130
+ throw takeFromExternrefTable0(ret[1]);
131
+ }
132
+ return ret[0] !== 0;
133
+ }
134
+ /**
135
+ * The same by 1-based row and column.
136
+ * @param {number} sheet
137
+ * @param {number} row
138
+ * @param {number} column
139
+ * @returns {boolean}
140
+ */
141
+ cellBoldAt(sheet, row, column) {
142
+ const ret = wasm.book_cellBoldAt(this.__wbg_ptr, sheet, row, column);
143
+ if (ret[2]) {
144
+ throw takeFromExternrefTable0(ret[1]);
145
+ }
146
+ return ret[0] !== 0;
147
+ }
148
+ /**
149
+ * How many non-empty cells the workbook holds, or one sheet of it.
150
+ * @param {number | null} [sheet]
151
+ * @returns {number}
152
+ */
153
+ cellCount(sheet) {
154
+ const ret = wasm.book_cellCount(this.__wbg_ptr, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
155
+ return ret >>> 0;
156
+ }
157
+ /**
158
+ * The indent of a cell, in Excel's indent steps (0 when it has none).
159
+ *
160
+ * Indent lives on the cell's style, and a spreadsheet only honours it for
161
+ * left, right and distributed alignment - but the number is returned as
162
+ * the file states it, whatever the alignment.
163
+ * @param {number} sheet
164
+ * @param {string} address
165
+ * @returns {number}
166
+ */
167
+ cellIndent(sheet, address) {
168
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
169
+ const len0 = WASM_VECTOR_LEN;
170
+ const ret = wasm.book_cellIndent(this.__wbg_ptr, sheet, ptr0, len0);
171
+ if (ret[2]) {
172
+ throw takeFromExternrefTable0(ret[1]);
173
+ }
174
+ return ret[0] >>> 0;
175
+ }
176
+ /**
177
+ * The same by 1-based row and column.
178
+ * @param {number} sheet
179
+ * @param {number} row
180
+ * @param {number} column
181
+ * @returns {number}
182
+ */
183
+ cellIndentAt(sheet, row, column) {
184
+ const ret = wasm.book_cellIndentAt(this.__wbg_ptr, sheet, row, column);
185
+ if (ret[2]) {
186
+ throw takeFromExternrefTable0(ret[1]);
187
+ }
188
+ return ret[0] >>> 0;
189
+ }
190
+ /**
191
+ * How a cell is painted: number format, font, fill, borders and text
192
+ * placement, as the file states them.
193
+ *
194
+ * A cell the file says nothing about answers with Excel's defaults, which
195
+ * is what Excel itself shows for it.
196
+ * @param {number} sheet
197
+ * @param {string} address
198
+ * @returns {CellStyle}
199
+ */
200
+ cellStyle(sheet, address) {
201
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
202
+ const len0 = WASM_VECTOR_LEN;
203
+ const ret = wasm.book_cellStyle(this.__wbg_ptr, sheet, ptr0, len0);
204
+ if (ret[2]) {
205
+ throw takeFromExternrefTable0(ret[1]);
206
+ }
207
+ return takeFromExternrefTable0(ret[0]);
208
+ }
209
+ /**
210
+ * The same by 1-based row and column.
211
+ * @param {number} sheet
212
+ * @param {number} row
213
+ * @param {number} column
214
+ * @returns {CellStyle}
215
+ */
216
+ cellStyleAt(sheet, row, column) {
217
+ const ret = wasm.book_cellStyleAt(this.__wbg_ptr, sheet, row, column);
218
+ if (ret[2]) {
219
+ throw takeFromExternrefTable0(ret[1]);
220
+ }
221
+ return takeFromExternrefTable0(ret[0]);
222
+ }
223
+ /**
224
+ * The charts on a sheet. `kinds` names the plots drawn in each -
225
+ * `barChart`, `lineChart` - and a combination chart has more than one.
226
+ * @param {number} sheet
227
+ * @returns {SheetChart[]}
228
+ */
229
+ charts(sheet) {
230
+ const ret = wasm.book_charts(this.__wbg_ptr, sheet);
231
+ if (ret[2]) {
232
+ throw takeFromExternrefTable0(ret[1]);
233
+ }
234
+ return takeFromExternrefTable0(ret[0]);
235
+ }
236
+ /**
237
+ * Whether `value` would be accepted in a cell under its data validation
238
+ * rule: `null` when it would (or there is no rule), otherwise what Excel
239
+ * would report, `{ style, title, message, sqref }`.
240
+ *
241
+ * ```js
242
+ * const problem = book.checkValidation(0, "B5", 150);
243
+ * if (problem) alert(problem.message || "Not allowed");
244
+ * ```
245
+ * @param {number} sheet
246
+ * @param {string} address
247
+ * @param {CellValue} value
248
+ * @returns {ValidationProblem | null}
249
+ */
250
+ checkValidation(sheet, address, value) {
251
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
252
+ const len0 = WASM_VECTOR_LEN;
253
+ const ret = wasm.book_checkValidation(this.__wbg_ptr, sheet, ptr0, len0, value);
254
+ if (ret[2]) {
255
+ throw takeFromExternrefTable0(ret[1]);
256
+ }
257
+ return takeFromExternrefTable0(ret[0]);
258
+ }
259
+ /**
260
+ * Empties a cell, style and all.
261
+ * @param {number} sheet
262
+ * @param {string} address
263
+ */
264
+ clear(sheet, address) {
265
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
266
+ const len0 = WASM_VECTOR_LEN;
267
+ const ret = wasm.book_clear(this.__wbg_ptr, sheet, ptr0, len0);
268
+ if (ret[1]) {
269
+ throw takeFromExternrefTable0(ret[0]);
270
+ }
271
+ }
272
+ /**
273
+ * The same by 1-based row and column.
274
+ * @param {number} sheet
275
+ * @param {number} row
276
+ * @param {number} column
277
+ */
278
+ clearAt(sheet, row, column) {
279
+ const ret = wasm.book_clearAt(this.__wbg_ptr, sheet, row, column);
280
+ if (ret[1]) {
281
+ throw takeFromExternrefTable0(ret[0]);
282
+ }
283
+ }
284
+ /**
285
+ * The same for a column, named by its letters: `columnLevel(0, "C")`.
286
+ * @param {number} sheet
287
+ * @param {string} column
288
+ * @returns {number}
289
+ */
290
+ columnLevel(sheet, column) {
291
+ const ptr0 = passStringToWasm0(column, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
292
+ const len0 = WASM_VECTOR_LEN;
293
+ const ret = wasm.book_columnLevel(this.__wbg_ptr, sheet, ptr0, len0);
294
+ if (ret[2]) {
295
+ throw takeFromExternrefTable0(ret[1]);
296
+ }
297
+ return ret[0];
298
+ }
299
+ /**
300
+ * The width of a column in characters, or `undefined` when the sheet
301
+ * leaves it to the default. `column` is 1-based.
302
+ * @param {number} sheet
303
+ * @param {number} column
304
+ * @returns {number | undefined}
305
+ */
306
+ columnWidth(sheet, column) {
307
+ const ret = wasm.book_columnWidth(this.__wbg_ptr, sheet, column);
308
+ if (ret[3]) {
309
+ throw takeFromExternrefTable0(ret[2]);
310
+ }
311
+ return ret[0] === 0 ? undefined : ret[1];
312
+ }
313
+ /**
314
+ * The notes on a sheet, in address order.
315
+ * @param {number} sheet
316
+ * @returns {SheetComment[]}
317
+ */
318
+ comments(sheet) {
319
+ const ret = wasm.book_comments(this.__wbg_ptr, sheet);
320
+ if (ret[2]) {
321
+ throw takeFromExternrefTable0(ret[1]);
322
+ }
323
+ return takeFromExternrefTable0(ret[0]);
324
+ }
325
+ /**
326
+ * The conditional formatting of a sheet, block by block. The formatting
327
+ * each rule applies is not modelled here - it lives in the workbook's
328
+ * differential styles - but what the rule tests is.
329
+ * @param {number} sheet
330
+ * @returns {SheetConditionalFormat[]}
331
+ */
332
+ conditionalFormats(sheet) {
333
+ const ret = wasm.book_conditionalFormats(this.__wbg_ptr, sheet);
334
+ if (ret[2]) {
335
+ throw takeFromExternrefTable0(ret[1]);
336
+ }
337
+ return takeFromExternrefTable0(ret[0]);
338
+ }
339
+ /**
340
+ * Copies a rectangle of cells so its top left corner lands on `to`,
341
+ * rewriting the formulas as Excel rewrites a copied formula: `=A1` one
342
+ * row down reads `=A2`, `$A$1` stays put.
343
+ *
344
+ * `toSheet` defaults to the sheet copied from. A cell the source leaves
345
+ * empty empties the target, the way pasting a block does.
346
+ * @param {number} sheet
347
+ * @param {string} range
348
+ * @param {string} to
349
+ * @param {number | null} [to_sheet]
350
+ */
351
+ copyRange(sheet, range, to, to_sheet) {
352
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
353
+ const len0 = WASM_VECTOR_LEN;
354
+ const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
355
+ const len1 = WASM_VECTOR_LEN;
356
+ const ret = wasm.book_copyRange(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(to_sheet) ? Number.MAX_SAFE_INTEGER : (to_sheet) >>> 0);
357
+ if (ret[1]) {
358
+ throw takeFromExternrefTable0(ret[0]);
359
+ }
360
+ }
361
+ /**
362
+ * The rules limiting what cells accept: the dropdown lists, the ranges,
363
+ * the dates.
364
+ * @param {number} sheet
365
+ * @returns {SheetValidation[]}
366
+ */
367
+ dataValidations(sheet) {
368
+ const ret = wasm.book_dataValidations(this.__wbg_ptr, sheet);
369
+ if (ret[2]) {
370
+ throw takeFromExternrefTable0(ret[1]);
371
+ }
372
+ return takeFromExternrefTable0(ret[0]);
373
+ }
374
+ /**
375
+ * The names the workbook defines: what `=Total` and `Print_Area` stand
376
+ * for. `sheet` is set on a name local to one sheet.
377
+ * @returns {WorkbookName[]}
378
+ */
379
+ definedNames() {
380
+ const ret = wasm.book_definedNames(this.__wbg_ptr);
381
+ return ret;
382
+ }
383
+ /**
384
+ * What Excel shows under File > Info: every text field is a string or
385
+ * `null`, dates in ISO 8601. `custom` lists the user's own fields with
386
+ * their type: `text`, `integer`, `number`, `boolean` or `date`.
387
+ * @returns {DocumentProperties}
388
+ */
389
+ documentProperties() {
390
+ const ret = wasm.book_documentProperties(this.__wbg_ptr);
391
+ return ret;
392
+ }
393
+ /**
394
+ * Evaluates a formula (with or without the leading `=`) as if it sat in
395
+ * `address` of `sheet`, and returns its result.
396
+ * @param {number} sheet
397
+ * @param {string} address
398
+ * @param {string} formula
399
+ * @returns {CellValue}
400
+ */
401
+ evaluate(sheet, address, formula) {
402
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
403
+ const len0 = WASM_VECTOR_LEN;
404
+ const ptr1 = passStringToWasm0(formula, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
405
+ const len1 = WASM_VECTOR_LEN;
406
+ const ret = wasm.book_evaluate(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1);
407
+ if (ret[2]) {
408
+ throw takeFromExternrefTable0(ret[1]);
409
+ }
410
+ return takeFromExternrefTable0(ret[0]);
411
+ }
412
+ /**
413
+ * The other workbooks this one reads, in the order `[1]Sheet1!A1` counts
414
+ * them. A path is `undefined` where the file does not name one.
415
+ * @returns {any[]}
416
+ */
417
+ externalBooks() {
418
+ const ret = wasm.book_externalBooks(this.__wbg_ptr);
419
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
420
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
421
+ return v1;
422
+ }
423
+ /**
424
+ * Copies the first row of a range into the rows below it, as Ctrl+D.
425
+ * @param {number} sheet
426
+ * @param {string} range
427
+ */
428
+ fillDown(sheet, range) {
429
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
430
+ const len0 = WASM_VECTOR_LEN;
431
+ const ret = wasm.book_fillDown(this.__wbg_ptr, sheet, ptr0, len0);
432
+ if (ret[1]) {
433
+ throw takeFromExternrefTable0(ret[0]);
434
+ }
435
+ }
436
+ /**
437
+ * Copies the first column of a range into the columns to its right, as
438
+ * Ctrl+R.
439
+ * @param {number} sheet
440
+ * @param {string} range
441
+ */
442
+ fillRight(sheet, range) {
443
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
444
+ const len0 = WASM_VECTOR_LEN;
445
+ const ret = wasm.book_fillRight(this.__wbg_ptr, sheet, ptr0, len0);
446
+ if (ret[1]) {
447
+ throw takeFromExternrefTable0(ret[0]);
448
+ }
449
+ }
450
+ /**
451
+ * Continues what the first cells of a range start, as dragging the fill
452
+ * handle does: `1, 2` goes on `3, 4`, `Кв1` to `Кв2`, `Jan` to `Feb`, a
453
+ * date by a day; anything else repeats. `"down"` fills each column,
454
+ * `"right"` each row; `"up"` and `"left"` run the series back from the
455
+ * last cells.
456
+ * @param {number} sheet
457
+ * @param {string} range
458
+ * @param {"down" | "right" | "up" | "left"} direction
459
+ */
460
+ fillSeries(sheet, range, direction) {
461
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
462
+ const len0 = WASM_VECTOR_LEN;
463
+ const ptr1 = passStringToWasm0(direction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
464
+ const len1 = WASM_VECTOR_LEN;
465
+ const ret = wasm.book_fillSeries(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1);
466
+ if (ret[1]) {
467
+ throw takeFromExternrefTable0(ret[0]);
468
+ }
469
+ }
470
+ /**
471
+ * Reads a workbook and hands sheet `sheet` over row by row, without
472
+ * building its grid: `callback(row, data)` gets the 1-based row number
473
+ * and what `getRowAt` would answer for it, and the row is dropped once
474
+ * the callback returns.
475
+ *
476
+ * The workbook comes back whole but for that sheet's cells. Only xlsx
477
+ * streams; any other format is read whole and then handed over the same
478
+ * way, so the callback sees the same rows but nothing is saved.
479
+ * A callback that throws is not called again, and what it threw comes
480
+ * out of `forEachRow` once the read is over.
481
+ * @param {Uint8Array} bytes
482
+ * @param {string | null | undefined} name
483
+ * @param {number} sheet
484
+ * @param {Function} callback
485
+ * @param {boolean | null} [formatted]
486
+ * @returns {Book}
487
+ */
488
+ static forEachRow(bytes, name, sheet, callback, formatted) {
489
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
490
+ const len0 = WASM_VECTOR_LEN;
491
+ var ptr1 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
492
+ var len1 = WASM_VECTOR_LEN;
493
+ const ret = wasm.book_forEachRow(ptr0, len0, ptr1, len1, sheet, callback, isLikeNone(formatted) ? 0xFFFFFF : formatted ? 1 : 0);
494
+ if (ret[2]) {
495
+ throw takeFromExternrefTable0(ret[1]);
496
+ }
497
+ return Book.__wrap(ret[0]);
498
+ }
499
+ /**
500
+ * Freezes the first `rows` rows and `columns` columns, so they stay put
501
+ * while the rest scrolls. `freezePanes(0, 1, 0)` pins the header row;
502
+ * `freezePanes(0, 0, 0)` unfreezes.
503
+ * @param {number} sheet
504
+ * @param {number} rows
505
+ * @param {number} columns
506
+ */
507
+ freezePanes(sheet, rows, columns) {
508
+ const ret = wasm.book_freezePanes(this.__wbg_ptr, sheet, rows, columns);
509
+ if (ret[1]) {
510
+ throw takeFromExternrefTable0(ret[0]);
511
+ }
512
+ }
513
+ /**
514
+ * The value at `address` on sheet `sheet`, as a JS number, string, boolean
515
+ * or `null`. A formula cell gives its cached result, not its text.
516
+ * @param {number} sheet
517
+ * @param {string} address
518
+ * @returns {CellValue}
519
+ */
520
+ get(sheet, address) {
521
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
522
+ const len0 = WASM_VECTOR_LEN;
523
+ const ret = wasm.book_get(this.__wbg_ptr, sheet, ptr0, len0);
524
+ if (ret[2]) {
525
+ throw takeFromExternrefTable0(ret[1]);
526
+ }
527
+ return takeFromExternrefTable0(ret[0]);
528
+ }
529
+ /**
530
+ * The same by 1-based row and column.
531
+ * @param {number} sheet
532
+ * @param {number} row
533
+ * @param {number} column
534
+ * @returns {CellValue}
535
+ */
536
+ getAt(sheet, row, column) {
537
+ const ret = wasm.book_getAt(this.__wbg_ptr, sheet, row, column);
538
+ if (ret[2]) {
539
+ throw takeFromExternrefTable0(ret[1]);
540
+ }
541
+ return takeFromExternrefTable0(ret[0]);
542
+ }
543
+ /**
544
+ * The cell as a spreadsheet would display it: the value run through its
545
+ * number format, so `0.256` under `0.0%` reads `25.6%`.
546
+ * @param {number} sheet
547
+ * @param {string} address
548
+ * @returns {string}
549
+ */
550
+ getFormatted(sheet, address) {
551
+ let deferred3_0;
552
+ let deferred3_1;
553
+ try {
554
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
555
+ const len0 = WASM_VECTOR_LEN;
556
+ const ret = wasm.book_getFormatted(this.__wbg_ptr, sheet, ptr0, len0);
557
+ var ptr2 = ret[0];
558
+ var len2 = ret[1];
559
+ if (ret[3]) {
560
+ ptr2 = 0; len2 = 0;
561
+ throw takeFromExternrefTable0(ret[2]);
562
+ }
563
+ deferred3_0 = ptr2;
564
+ deferred3_1 = len2;
565
+ return getStringFromWasm0(ptr2, len2);
566
+ } finally {
567
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
568
+ }
569
+ }
570
+ /**
571
+ * The same by 1-based row and column.
572
+ * @param {number} sheet
573
+ * @param {number} row
574
+ * @param {number} column
575
+ * @returns {string}
576
+ */
577
+ getFormattedAt(sheet, row, column) {
578
+ let deferred2_0;
579
+ let deferred2_1;
580
+ try {
581
+ const ret = wasm.book_getFormattedAt(this.__wbg_ptr, sheet, row, column);
582
+ var ptr1 = ret[0];
583
+ var len1 = ret[1];
584
+ if (ret[3]) {
585
+ ptr1 = 0; len1 = 0;
586
+ throw takeFromExternrefTable0(ret[2]);
587
+ }
588
+ deferred2_0 = ptr1;
589
+ deferred2_1 = len1;
590
+ return getStringFromWasm0(ptr1, len1);
591
+ } finally {
592
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
593
+ }
594
+ }
595
+ /**
596
+ * The formula text of a cell without its leading `=`, or `undefined` when
597
+ * the cell holds a plain value.
598
+ * @param {number} sheet
599
+ * @param {string} address
600
+ * @returns {string | undefined}
601
+ */
602
+ getFormula(sheet, address) {
603
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
604
+ const len0 = WASM_VECTOR_LEN;
605
+ const ret = wasm.book_getFormula(this.__wbg_ptr, sheet, ptr0, len0);
606
+ let v2;
607
+ if (ret[0] !== 0) {
608
+ v2 = getStringFromWasm0(ret[0], ret[1]);
609
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
610
+ }
611
+ return v2;
612
+ }
613
+ /**
614
+ * The same by 1-based row and column.
615
+ * @param {number} sheet
616
+ * @param {number} row
617
+ * @param {number} column
618
+ * @returns {string | undefined}
619
+ */
620
+ getFormulaAt(sheet, row, column) {
621
+ const ret = wasm.book_getFormulaAt(this.__wbg_ptr, sheet, row, column);
622
+ let v1;
623
+ if (ret[0] !== 0) {
624
+ v1 = getStringFromWasm0(ret[0], ret[1]);
625
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
626
+ }
627
+ return v1;
628
+ }
629
+ /**
630
+ * A rectangle of cells, row by row. One call across the boundary instead
631
+ * of one per cell, which is what makes reading a sheet worth doing.
632
+ * @param {number} sheet
633
+ * @param {string} range
634
+ * @returns {CellGrid}
635
+ */
636
+ getRange(sheet, range) {
637
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
638
+ const len0 = WASM_VECTOR_LEN;
639
+ const ret = wasm.book_getRange(this.__wbg_ptr, sheet, ptr0, len0);
640
+ if (ret[2]) {
641
+ throw takeFromExternrefTable0(ret[1]);
642
+ }
643
+ return takeFromExternrefTable0(ret[0]);
644
+ }
645
+ /**
646
+ * The same by numbers: the top-left cell, then how many rows and columns
647
+ * to take. `getRangeAt(0, 1, 1, 3, 2)` is `A1:B3`.
648
+ * @param {number} sheet
649
+ * @param {number} row
650
+ * @param {number} column
651
+ * @param {number} rows
652
+ * @param {number} columns
653
+ * @returns {CellGrid}
654
+ */
655
+ getRangeAt(sheet, row, column, rows, columns) {
656
+ const ret = wasm.book_getRangeAt(this.__wbg_ptr, sheet, row, column, rows, columns);
657
+ if (ret[2]) {
658
+ throw takeFromExternrefTable0(ret[1]);
659
+ }
660
+ return takeFromExternrefTable0(ret[0]);
661
+ }
662
+ /**
663
+ * The styles of a rectangle in one call: each distinct style once, and a
664
+ * grid of indexes into them. `cellStyle` per cell costs a crossing and a
665
+ * whole style object per cell; a formatted table of ten thousand cells
666
+ * usually has a dozen styles.
667
+ * @param {number} sheet
668
+ * @param {string} range
669
+ * @returns {RangeStyles}
670
+ */
671
+ getRangeStyles(sheet, range) {
672
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
673
+ const len0 = WASM_VECTOR_LEN;
674
+ const ret = wasm.book_getRangeStyles(this.__wbg_ptr, sheet, ptr0, len0);
675
+ if (ret[2]) {
676
+ throw takeFromExternrefTable0(ret[1]);
677
+ }
678
+ return takeFromExternrefTable0(ret[0]);
679
+ }
680
+ /**
681
+ * The same by numbers, as `getRangeAt` takes them.
682
+ * @param {number} sheet
683
+ * @param {number} row
684
+ * @param {number} column
685
+ * @param {number} rows
686
+ * @param {number} columns
687
+ * @returns {RangeStyles}
688
+ */
689
+ getRangeStylesAt(sheet, row, column, rows, columns) {
690
+ const ret = wasm.book_getRangeStylesAt(this.__wbg_ptr, sheet, row, column, rows, columns);
691
+ if (ret[2]) {
692
+ throw takeFromExternrefTable0(ret[1]);
693
+ }
694
+ return takeFromExternrefTable0(ret[0]);
695
+ }
696
+ /**
697
+ * The runs of a cell's formatted text: `{ text, font }` each, `font`
698
+ * naming only what the run changes about the cell's font, or `null` for
699
+ * a run in the cell's own. `null` for a cell without formatted text.
700
+ * @param {number} sheet
701
+ * @param {string} address
702
+ * @returns {TextRun[] | null}
703
+ */
704
+ getRichText(sheet, address) {
705
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
706
+ const len0 = WASM_VECTOR_LEN;
707
+ const ret = wasm.book_getRichText(this.__wbg_ptr, sheet, ptr0, len0);
708
+ if (ret[2]) {
709
+ throw takeFromExternrefTable0(ret[1]);
710
+ }
711
+ return takeFromExternrefTable0(ret[0]);
712
+ }
713
+ /**
714
+ * The same by 1-based row and column.
715
+ * @param {number} sheet
716
+ * @param {number} row
717
+ * @param {number} column
718
+ * @returns {TextRun[] | null}
719
+ */
720
+ getRichTextAt(sheet, row, column) {
721
+ const ret = wasm.book_getRichTextAt(this.__wbg_ptr, sheet, row, column);
722
+ if (ret[2]) {
723
+ throw takeFromExternrefTable0(ret[1]);
724
+ }
725
+ return takeFromExternrefTable0(ret[0]);
726
+ }
727
+ /**
728
+ * A whole row in one crossing of the boundary: values, displayed text,
729
+ * bold and indent, plus whether the row is hidden.
730
+ *
731
+ * The arrays run from column 1 to the last column this row has a cell in,
732
+ * so a row of ten cells costs one call rather than forty.
733
+ *
734
+ * `formatted` is what the number format makes of each value, and building
735
+ * it allocates a string per cell - which a caller reading values does not
736
+ * want to pay half a sheet over. Pass `false` and the field comes back
737
+ * `null`; `getFormattedAt` still answers for the cells that need it.
738
+ * @param {number} sheet
739
+ * @param {number} row
740
+ * @param {boolean | null} [formatted]
741
+ * @returns {SheetRow}
742
+ */
743
+ getRowAt(sheet, row, formatted) {
744
+ const ret = wasm.book_getRowAt(this.__wbg_ptr, sheet, row, isLikeNone(formatted) ? 0xFFFFFF : formatted ? 1 : 0);
745
+ if (ret[2]) {
746
+ throw takeFromExternrefTable0(ret[1]);
747
+ }
748
+ return takeFromExternrefTable0(ret[0]);
749
+ }
750
+ /**
751
+ * Finds the value of `changing` that makes the formula in `set` compute
752
+ * `target`, as Excel's Goal Seek does, both cells on `sheet`. The best
753
+ * value found is left in `changing` and what reads it is recomputed.
754
+ * `options.maxIterations` and `options.tolerance` default to the
755
+ * workbook's own iteration settings (100 and 0.001 unless it says
756
+ * otherwise). Returns `{ value, result, iterations, converged }`.
757
+ *
758
+ * ```js
759
+ * const { value, converged } = book.goalSeek(0, "B4", 300, "B1");
760
+ * ```
761
+ * @param {number} sheet
762
+ * @param {string} set
763
+ * @param {number} target
764
+ * @param {string} changing
765
+ * @param {GoalSeekOptions} [options]
766
+ * @returns {GoalSeekResult}
767
+ */
768
+ goalSeek(sheet, set, target, changing, options) {
769
+ const ptr0 = passStringToWasm0(set, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
770
+ const len0 = WASM_VECTOR_LEN;
771
+ const ptr1 = passStringToWasm0(changing, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
772
+ const len1 = WASM_VECTOR_LEN;
773
+ const ret = wasm.book_goalSeek(this.__wbg_ptr, sheet, ptr0, len0, target, ptr1, len1, options);
774
+ if (ret[2]) {
775
+ throw takeFromExternrefTable0(ret[1]);
776
+ }
777
+ return takeFromExternrefTable0(ret[0]);
778
+ }
779
+ /**
780
+ * The hyperlinks of a sheet. `external` tells a URL from a jump inside
781
+ * the workbook.
782
+ * @param {number} sheet
783
+ * @returns {SheetHyperlink[]}
784
+ */
785
+ hyperlinks(sheet) {
786
+ const ret = wasm.book_hyperlinks(this.__wbg_ptr, sheet);
787
+ if (ret[2]) {
788
+ throw takeFromExternrefTable0(ret[1]);
789
+ }
790
+ return takeFromExternrefTable0(ret[0]);
791
+ }
792
+ /**
793
+ * The bytes of one picture, by its position in `images`.
794
+ * @param {number} sheet
795
+ * @param {number} index
796
+ * @returns {Uint8Array}
797
+ */
798
+ imageData(sheet, index) {
799
+ const ret = wasm.book_imageData(this.__wbg_ptr, sheet, index);
800
+ if (ret[3]) {
801
+ throw takeFromExternrefTable0(ret[2]);
802
+ }
803
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
804
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
805
+ return v1;
806
+ }
807
+ /**
808
+ * The pictures on a sheet, without their bytes: `imageData` fetches those
809
+ * for the one that is wanted.
810
+ * @param {number} sheet
811
+ * @returns {SheetImage[]}
812
+ */
813
+ images(sheet) {
814
+ const ret = wasm.book_images(this.__wbg_ptr, sheet);
815
+ if (ret[2]) {
816
+ throw takeFromExternrefTable0(ret[1]);
817
+ }
818
+ return takeFromExternrefTable0(ret[0]);
819
+ }
820
+ /**
821
+ * Inserts blank cells over a range, pushing what was there `"down"` or
822
+ * `"right"` - Excel's "Insert Cells", which moves part of a row rather
823
+ * than the whole of it. `copyOrigin` works as in `insertRows`.
824
+ * @param {number} sheet
825
+ * @param {string} range
826
+ * @param {"down" | "right"} shift
827
+ * @param {"before" | "after" | "none"} [copyOrigin]
828
+ */
829
+ insertCells(sheet, range, shift, copyOrigin) {
830
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
831
+ const len0 = WASM_VECTOR_LEN;
832
+ const ptr1 = passStringToWasm0(shift, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
833
+ const len1 = WASM_VECTOR_LEN;
834
+ var ptr2 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
835
+ var len2 = WASM_VECTOR_LEN;
836
+ const ret = wasm.book_insertCells(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, ptr2, len2);
837
+ if (ret[1]) {
838
+ throw takeFromExternrefTable0(ret[0]);
839
+ }
840
+ }
841
+ /**
842
+ * Inserts `count` columns to the left of column `at`, 1-based.
843
+ * `copyOrigin` works as in `insertRows`, with left and right.
844
+ * @param {number} sheet
845
+ * @param {number} at
846
+ * @param {number} count
847
+ * @param {"before" | "after" | "none"} [copyOrigin]
848
+ */
849
+ insertColumns(sheet, at, count, copyOrigin) {
850
+ var ptr0 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
851
+ var len0 = WASM_VECTOR_LEN;
852
+ const ret = wasm.book_insertColumns(this.__wbg_ptr, sheet, at, count, ptr0, len0);
853
+ if (ret[1]) {
854
+ throw takeFromExternrefTable0(ret[0]);
855
+ }
856
+ }
857
+ /**
858
+ * `insertRowsMany` for columns.
859
+ * @param {number} sheet
860
+ * @param {[number, number][]} places
861
+ * @param {"before" | "after" | "none"} [copyOrigin]
862
+ */
863
+ insertColumnsMany(sheet, places, copyOrigin) {
864
+ var ptr0 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
865
+ var len0 = WASM_VECTOR_LEN;
866
+ const ret = wasm.book_insertColumnsMany(this.__wbg_ptr, sheet, places, ptr0, len0);
867
+ if (ret[1]) {
868
+ throw takeFromExternrefTable0(ret[0]);
869
+ }
870
+ }
871
+ /**
872
+ * Inserts `count` rows above row `at`, moving everything below down.
873
+ * `copyOrigin` - `"before"` (the row above), `"after"` (the row below)
874
+ * or `"none"` - says whose formatting the new rows take. Left out, it is
875
+ * `"before"`, as in Excel.
876
+ *
877
+ * Formulas across the whole workbook follow the cells they read, and so
878
+ * do merges, links, validations, tables and drawings. `at` is the number
879
+ * a user sees.
880
+ * @param {number} sheet
881
+ * @param {number} at
882
+ * @param {number} count
883
+ * @param {"before" | "after" | "none"} [copyOrigin]
884
+ */
885
+ insertRows(sheet, at, count, copyOrigin) {
886
+ var ptr0 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
887
+ var len0 = WASM_VECTOR_LEN;
888
+ const ret = wasm.book_insertRows(this.__wbg_ptr, sheet, at, count, ptr0, len0);
889
+ if (ret[1]) {
890
+ throw takeFromExternrefTable0(ret[0]);
891
+ }
892
+ }
893
+ /**
894
+ * Inserts rows at many places in one pass: `places` is `[at, count]`
895
+ * pairs, numbered as the sheet is before the call, in any order.
896
+ * `book.insertRowsMany(0, [[5, 1], [9, 1]])` puts a row above each of
897
+ * rows 5 and 9 - the old row 9, now row 10. Each new block takes its
898
+ * formatting from its own neighbour, as `copyOrigin` says.
899
+ *
900
+ * The result is that of the single inserts made from the bottom up, but
901
+ * the workbook is walked once rather than once per place: four thousand
902
+ * subtotal rows into forty thousand take milliseconds, not a minute.
903
+ * @param {number} sheet
904
+ * @param {[number, number][]} places
905
+ * @param {"before" | "after" | "none"} [copyOrigin]
906
+ */
907
+ insertRowsMany(sheet, places, copyOrigin) {
908
+ var ptr0 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
909
+ var len0 = WASM_VECTOR_LEN;
910
+ const ret = wasm.book_insertRowsMany(this.__wbg_ptr, sheet, places, ptr0, len0);
911
+ if (ret[1]) {
912
+ throw takeFromExternrefTable0(ret[0]);
913
+ }
914
+ }
915
+ /**
916
+ * The cells of a sheet whose values break their data validation rule,
917
+ * as Excel's Circle Invalid Data finds them: `["B3", "B9"]`.
918
+ * @param {number} sheet
919
+ * @returns {string[]}
920
+ */
921
+ invalidCells(sheet) {
922
+ const ret = wasm.book_invalidCells(this.__wbg_ptr, sheet);
923
+ if (ret[3]) {
924
+ throw takeFromExternrefTable0(ret[2]);
925
+ }
926
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
927
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
928
+ return v1;
929
+ }
930
+ /**
931
+ * Merges a block of cells: `merge(0, "A1:C1")`.
932
+ * @param {number} sheet
933
+ * @param {string} range
934
+ */
935
+ merge(sheet, range) {
936
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
937
+ const len0 = WASM_VECTOR_LEN;
938
+ const ret = wasm.book_merge(this.__wbg_ptr, sheet, ptr0, len0);
939
+ if (ret[1]) {
940
+ throw takeFromExternrefTable0(ret[0]);
941
+ }
942
+ }
943
+ /**
944
+ * The merged areas of a sheet, as `"A1:C1"` strings in the order the file
945
+ * lists them.
946
+ * @param {number} sheet
947
+ * @returns {string[]}
948
+ */
949
+ mergedRanges(sheet) {
950
+ const ret = wasm.book_mergedRanges(this.__wbg_ptr, sheet);
951
+ if (ret[3]) {
952
+ throw takeFromExternrefTable0(ret[2]);
953
+ }
954
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
955
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
956
+ return v1;
957
+ }
958
+ /**
959
+ * The merged areas of a sheet as numbers: four per area, `[r1, c1, r2,
960
+ * c2]`, rows and columns 1-based.
961
+ *
962
+ * One typed array instead of a JS string per area, which is what a sheet
963
+ * carrying three hundred thousand of them needs.
964
+ * @param {number} sheet
965
+ * @returns {Uint32Array}
966
+ */
967
+ mergedRangesAt(sheet) {
968
+ const ret = wasm.book_mergedRangesAt(this.__wbg_ptr, sheet);
969
+ if (ret[2]) {
970
+ throw takeFromExternrefTable0(ret[1]);
971
+ }
972
+ return takeFromExternrefTable0(ret[0]);
973
+ }
974
+ /**
975
+ * Moves a rectangle of cells, leaving the source empty.
976
+ *
977
+ * A moved formula keeps reading the cells it read; the formulas elsewhere
978
+ * that read *these* cells follow them instead, as they do when Excel cuts
979
+ * and pastes.
980
+ * @param {number} sheet
981
+ * @param {string} range
982
+ * @param {string} to
983
+ * @param {number | null} [to_sheet]
984
+ */
985
+ moveRange(sheet, range, to, to_sheet) {
986
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
987
+ const len0 = WASM_VECTOR_LEN;
988
+ const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
989
+ const len1 = WASM_VECTOR_LEN;
990
+ const ret = wasm.book_moveRange(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(to_sheet) ? Number.MAX_SAFE_INTEGER : (to_sheet) >>> 0);
991
+ if (ret[1]) {
992
+ throw takeFromExternrefTable0(ret[0]);
993
+ }
994
+ }
995
+ /**
996
+ * Moves a sheet along the tab bar. Formulas are untouched - a sheet is
997
+ * named, not numbered - but every index moves, this one included, so read
998
+ * `sheetIndex` again afterwards.
999
+ * @param {number} from
1000
+ * @param {number} to
1001
+ */
1002
+ moveSheet(from, to) {
1003
+ const ret = wasm.book_moveSheet(this.__wbg_ptr, from, to);
1004
+ if (ret[1]) {
1005
+ throw takeFromExternrefTable0(ret[0]);
1006
+ }
1007
+ }
1008
+ /**
1009
+ * A new workbook with one empty sheet.
1010
+ */
1011
+ constructor() {
1012
+ const ret = wasm.book_new();
1013
+ this.__wbg_ptr = ret;
1014
+ BookFinalization.register(this, this.__wbg_ptr, this);
1015
+ return this;
1016
+ }
1017
+ /**
1018
+ * The pivot reports laid out on a sheet. The numbers they show are cells
1019
+ * like any others; this says where a report sits and how wide its axes
1020
+ * are.
1021
+ * @param {number} sheet
1022
+ * @returns {SheetPivotTable[]}
1023
+ */
1024
+ pivotTables(sheet) {
1025
+ const ret = wasm.book_pivotTables(this.__wbg_ptr, sheet);
1026
+ if (ret[2]) {
1027
+ throw takeFromExternrefTable0(ret[1]);
1028
+ }
1029
+ return takeFromExternrefTable0(ret[0]);
1030
+ }
1031
+ /**
1032
+ * Locks a sheet against editing, optionally behind a password.
1033
+ *
1034
+ * This is the lock Excel offers under "Protect Sheet": it stops a user
1035
+ * editing, it does not encrypt anything. The password is stored as Excel
1036
+ * stores it - SHA-512 over a random salt, 100,000 spins - and
1037
+ * `verifySheetPassword` checks it back.
1038
+ * @param {number} sheet
1039
+ * @param {string | null} [password]
1040
+ */
1041
+ protectSheet(sheet, password) {
1042
+ var ptr0 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1043
+ var len0 = WASM_VECTOR_LEN;
1044
+ const ret = wasm.book_protectSheet(this.__wbg_ptr, sheet, ptr0, len0);
1045
+ if (ret[1]) {
1046
+ throw takeFromExternrefTable0(ret[0]);
1047
+ }
1048
+ }
1049
+ /**
1050
+ * Locks the structure of the workbook: which sheets there are, and their
1051
+ * order. `windows` locks the window layout as well.
1052
+ * @param {string | null} [password]
1053
+ * @param {boolean | null} [windows]
1054
+ */
1055
+ protectWorkbook(password, windows) {
1056
+ var ptr0 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1057
+ var len0 = WASM_VECTOR_LEN;
1058
+ const ret = wasm.book_protectWorkbook(this.__wbg_ptr, ptr0, len0, isLikeNone(windows) ? 0xFFFFFF : windows ? 1 : 0);
1059
+ if (ret[1]) {
1060
+ throw takeFromExternrefTable0(ret[0]);
1061
+ }
1062
+ }
1063
+ /**
1064
+ * Reads a workbook of any format this crate supports, working the format
1065
+ * out from the bytes themselves.
1066
+ *
1067
+ * `name` is the file name they came from, if the caller has one: it
1068
+ * settles what the bytes cannot say (a `.csv` against a `.html`) and names
1069
+ * the sheet of a SYLK file. `password` opens a workbook saved with a
1070
+ * password to open; without it only one encrypted to be opened
1071
+ * read-only reads.
1072
+ * @param {Uint8Array} bytes
1073
+ * @param {string | null} [name]
1074
+ * @param {number | null} [max_expanded]
1075
+ * @param {Function | null} [on_progress]
1076
+ * @param {string | null} [password]
1077
+ * @returns {Book}
1078
+ */
1079
+ static read(bytes, name, max_expanded, on_progress, password) {
1080
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1081
+ const len0 = WASM_VECTOR_LEN;
1082
+ var ptr1 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1083
+ var len1 = WASM_VECTOR_LEN;
1084
+ var ptr2 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1085
+ var len2 = WASM_VECTOR_LEN;
1086
+ const ret = wasm.book_read(ptr0, len0, ptr1, len1, !isLikeNone(max_expanded), isLikeNone(max_expanded) ? 0 : max_expanded, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress), ptr2, len2);
1087
+ if (ret[2]) {
1088
+ throw takeFromExternrefTable0(ret[1]);
1089
+ }
1090
+ return Book.__wrap(ret[0]);
1091
+ }
1092
+ /**
1093
+ * Reads CSV with the guesses overridden: the delimiter, whether a row
1094
+ * that produced no cell is skipped, whether an empty field becomes an
1095
+ * empty string rather than no cell at all.
1096
+ *
1097
+ * `Book.read` guesses all of this from the bytes, which is right for a
1098
+ * file of unknown origin; this is for one whose shape you already know.
1099
+ * @param {Uint8Array} bytes
1100
+ * @param {CsvOptions} options
1101
+ * @returns {Book}
1102
+ */
1103
+ static readCsv(bytes, options) {
1104
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1105
+ const len0 = WASM_VECTOR_LEN;
1106
+ const ret = wasm.book_readCsv(ptr0, len0, options);
1107
+ if (ret[2]) {
1108
+ throw takeFromExternrefTable0(ret[1]);
1109
+ }
1110
+ return Book.__wrap(ret[0]);
1111
+ }
1112
+ /**
1113
+ * Recomputes every formula and stores the results beside them, so that
1114
+ * `get` and `toCsv` show this engine's answers rather than the cache the
1115
+ * file was saved with. Returns how many formulas were computed.
1116
+ *
1117
+ * With no argument the whole workbook is recomputed; with a sheet index,
1118
+ * only that sheet's formulas are - though they still read the whole
1119
+ * workbook, as a cross-sheet reference must.
1120
+ * @param {number | null} [sheet]
1121
+ * @param {Function | null} [on_progress]
1122
+ * @returns {number}
1123
+ */
1124
+ recalculate(sheet, on_progress) {
1125
+ const ret = wasm.book_recalculate(this.__wbg_ptr, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
1126
+ return ret >>> 0;
1127
+ }
1128
+ /**
1129
+ * Recomputes the formula in one cell and stores its result. Returns
1130
+ * whether there was a formula there.
1131
+ *
1132
+ * Not the same as `recalculateFrom`, which recomputes the formulas
1133
+ * *reading* this cell and leaves the cell itself alone.
1134
+ * @param {number} sheet
1135
+ * @param {string} address
1136
+ * @returns {boolean}
1137
+ */
1138
+ recalculateCell(sheet, address) {
1139
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1140
+ const len0 = WASM_VECTOR_LEN;
1141
+ const ret = wasm.book_recalculateCell(this.__wbg_ptr, sheet, ptr0, len0);
1142
+ if (ret[2]) {
1143
+ throw takeFromExternrefTable0(ret[1]);
1144
+ }
1145
+ return ret[0] !== 0;
1146
+ }
1147
+ /**
1148
+ * The same by 1-based row and column.
1149
+ * @param {number} sheet
1150
+ * @param {number} row
1151
+ * @param {number} column
1152
+ * @returns {boolean}
1153
+ */
1154
+ recalculateCellAt(sheet, row, column) {
1155
+ const ret = wasm.book_recalculateCellAt(this.__wbg_ptr, sheet, row, column);
1156
+ if (ret[2]) {
1157
+ throw takeFromExternrefTable0(ret[1]);
1158
+ }
1159
+ return ret[0] !== 0;
1160
+ }
1161
+ /**
1162
+ * Recomputes only what depends on one cell that changed - the formulas
1163
+ * reading it, the formulas reading those, and so on. Returns how many were
1164
+ * computed. This is the pass to run after `set`.
1165
+ *
1166
+ * For a batch of edits use `recalculateFromMany`, which answers them all
1167
+ * in one pass.
1168
+ * @param {number} sheet
1169
+ * @param {string} address
1170
+ * @returns {number}
1171
+ */
1172
+ recalculateFrom(sheet, address) {
1173
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1174
+ const len0 = WASM_VECTOR_LEN;
1175
+ const ret = wasm.book_recalculateFrom(this.__wbg_ptr, sheet, ptr0, len0);
1176
+ if (ret[2]) {
1177
+ throw takeFromExternrefTable0(ret[1]);
1178
+ }
1179
+ return ret[0] >>> 0;
1180
+ }
1181
+ /**
1182
+ * The same by 1-based row and column.
1183
+ * @param {number} sheet
1184
+ * @param {number} row
1185
+ * @param {number} column
1186
+ * @returns {number}
1187
+ */
1188
+ recalculateFromAt(sheet, row, column) {
1189
+ const ret = wasm.book_recalculateFromAt(this.__wbg_ptr, sheet, row, column);
1190
+ if (ret[2]) {
1191
+ throw takeFromExternrefTable0(ret[1]);
1192
+ }
1193
+ return ret[0] >>> 0;
1194
+ }
1195
+ /**
1196
+ * The same for a batch of cells, all on sheet `sheet`, answered in one
1197
+ * pass: editing a hundred cells costs one walk of the workbook, not a
1198
+ * hundred.
1199
+ *
1200
+ * The index of what reads what is built on the first call and kept, so a
1201
+ * run of edits parses the formulas only once. `set` keeps it in step.
1202
+ * @param {number} sheet
1203
+ * @param {string[]} addresses
1204
+ * @returns {number}
1205
+ */
1206
+ recalculateFromMany(sheet, addresses) {
1207
+ const ptr0 = passArrayJsValueToWasm0(addresses, wasm.__wbindgen_malloc);
1208
+ const len0 = WASM_VECTOR_LEN;
1209
+ const ret = wasm.book_recalculateFromMany(this.__wbg_ptr, sheet, ptr0, len0);
1210
+ if (ret[2]) {
1211
+ throw takeFromExternrefTable0(ret[1]);
1212
+ }
1213
+ return ret[0] >>> 0;
1214
+ }
1215
+ /**
1216
+ * Registers a function of your own, callable from any formula in the
1217
+ * workbook by that name.
1218
+ *
1219
+ * The function is handed the arguments already computed - a range arrives
1220
+ * as an array of arrays - and whatever it returns becomes the value. A
1221
+ * name a built-in claims stays the built-in's: a workbook where `SUM`
1222
+ * means something else is a workbook nobody else can read.
1223
+ *
1224
+ * ```js
1225
+ * book.registerFunction("MYRATE", (base) => base * 1.5 + 0.5);
1226
+ * book.evaluate(0, "A1", "=MYRATE(10)"); // 15.5
1227
+ * ```
1228
+ * @param {string} name
1229
+ * @param {Function} _function
1230
+ */
1231
+ registerFunction(name, _function) {
1232
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1233
+ const len0 = WASM_VECTOR_LEN;
1234
+ wasm.book_registerFunction(this.__wbg_ptr, ptr0, len0, _function);
1235
+ }
1236
+ /**
1237
+ * The names registered, in no particular order.
1238
+ * @returns {string[]}
1239
+ */
1240
+ registeredFunctions() {
1241
+ const ret = wasm.book_registeredFunctions(this.__wbg_ptr);
1242
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
1243
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1244
+ return v1;
1245
+ }
1246
+ /**
1247
+ * Removes the cells of a range, pulling the rest back over the hole from
1248
+ * below (`"up"`) or from the right (`"left"`).
1249
+ * @param {number} sheet
1250
+ * @param {string} range
1251
+ * @param {"up" | "left"} shift
1252
+ */
1253
+ removeCells(sheet, range, shift) {
1254
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1255
+ const len0 = WASM_VECTOR_LEN;
1256
+ const ptr1 = passStringToWasm0(shift, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1257
+ const len1 = WASM_VECTOR_LEN;
1258
+ const ret = wasm.book_removeCells(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1);
1259
+ if (ret[1]) {
1260
+ throw takeFromExternrefTable0(ret[0]);
1261
+ }
1262
+ }
1263
+ /**
1264
+ * Removes `count` columns from column `at`, 1-based.
1265
+ * @param {number} sheet
1266
+ * @param {number} at
1267
+ * @param {number} count
1268
+ */
1269
+ removeColumns(sheet, at, count) {
1270
+ const ret = wasm.book_removeColumns(this.__wbg_ptr, sheet, at, count);
1271
+ if (ret[1]) {
1272
+ throw takeFromExternrefTable0(ret[0]);
1273
+ }
1274
+ }
1275
+ /**
1276
+ * `removeRowsMany` for columns.
1277
+ * @param {number} sheet
1278
+ * @param {[number, number][]} places
1279
+ */
1280
+ removeColumnsMany(sheet, places) {
1281
+ const ret = wasm.book_removeColumnsMany(this.__wbg_ptr, sheet, places);
1282
+ if (ret[1]) {
1283
+ throw takeFromExternrefTable0(ret[0]);
1284
+ }
1285
+ }
1286
+ /**
1287
+ * Takes a note off a cell. Answers whether there was one.
1288
+ * @param {number} sheet
1289
+ * @param {string} address
1290
+ * @returns {boolean}
1291
+ */
1292
+ removeComment(sheet, address) {
1293
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1294
+ const len0 = WASM_VECTOR_LEN;
1295
+ const ret = wasm.book_removeComment(this.__wbg_ptr, sheet, ptr0, len0);
1296
+ if (ret[2]) {
1297
+ throw takeFromExternrefTable0(ret[1]);
1298
+ }
1299
+ return ret[0] !== 0;
1300
+ }
1301
+ /**
1302
+ * Removes a defined name. Answers whether there was one.
1303
+ * @param {string} name
1304
+ * @param {number | null} [sheet]
1305
+ * @returns {boolean}
1306
+ */
1307
+ removeDefinedName(name, sheet) {
1308
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1309
+ const len0 = WASM_VECTOR_LEN;
1310
+ const ret = wasm.book_removeDefinedName(this.__wbg_ptr, ptr0, len0, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
1311
+ return ret !== 0;
1312
+ }
1313
+ /**
1314
+ * Removes the rows of a range that repeat a row above them, as Excel's
1315
+ * Remove Duplicates does: cells are compared by the text they show,
1316
+ * without regard to case. `options.columns` are the 1-based sheet
1317
+ * columns compared (all of the range when left out), and
1318
+ * `options.header` keeps the first row out of it. Returns
1319
+ * `{ removed, remaining }`.
1320
+ *
1321
+ * ```js
1322
+ * book.removeDuplicates(0, "A1:C500", { columns: [1, 3], header: true });
1323
+ * ```
1324
+ * @param {number} sheet
1325
+ * @param {string} range
1326
+ * @param {RemoveDuplicatesOptions} [options]
1327
+ * @returns {DuplicatesRemoved}
1328
+ */
1329
+ removeDuplicates(sheet, range, options) {
1330
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1331
+ const len0 = WASM_VECTOR_LEN;
1332
+ const ret = wasm.book_removeDuplicates(this.__wbg_ptr, sheet, ptr0, len0, options);
1333
+ if (ret[2]) {
1334
+ throw takeFromExternrefTable0(ret[1]);
1335
+ }
1336
+ return takeFromExternrefTable0(ret[0]);
1337
+ }
1338
+ /**
1339
+ * Takes the link off a range. Answers whether there was one.
1340
+ * @param {number} sheet
1341
+ * @param {string} range
1342
+ * @returns {boolean}
1343
+ */
1344
+ removeHyperlink(sheet, range) {
1345
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1346
+ const len0 = WASM_VECTOR_LEN;
1347
+ const ret = wasm.book_removeHyperlink(this.__wbg_ptr, sheet, ptr0, len0);
1348
+ if (ret[2]) {
1349
+ throw takeFromExternrefTable0(ret[1]);
1350
+ }
1351
+ return ret[0] !== 0;
1352
+ }
1353
+ /**
1354
+ * Removes `count` rows from row `at` down. A formula that read a removed
1355
+ * cell reads `#REF!` afterwards.
1356
+ * @param {number} sheet
1357
+ * @param {number} at
1358
+ * @param {number} count
1359
+ */
1360
+ removeRows(sheet, at, count) {
1361
+ const ret = wasm.book_removeRows(this.__wbg_ptr, sheet, at, count);
1362
+ if (ret[1]) {
1363
+ throw takeFromExternrefTable0(ret[0]);
1364
+ }
1365
+ }
1366
+ /**
1367
+ * Removes rows at many places in one pass: `[at, count]` pairs, numbered
1368
+ * as the sheet is before the call. Blocks that overlap are merged.
1369
+ * @param {number} sheet
1370
+ * @param {[number, number][]} places
1371
+ */
1372
+ removeRowsMany(sheet, places) {
1373
+ const ret = wasm.book_removeRowsMany(this.__wbg_ptr, sheet, places);
1374
+ if (ret[1]) {
1375
+ throw takeFromExternrefTable0(ret[0]);
1376
+ }
1377
+ }
1378
+ /**
1379
+ * Removes a sheet. References to it from anywhere in the workbook become
1380
+ * `#REF!`, the way Excel writes them, and the sheets after it shift down
1381
+ * by one index.
1382
+ * @param {number} sheet
1383
+ */
1384
+ removeSheet(sheet) {
1385
+ const ret = wasm.book_removeSheet(this.__wbg_ptr, sheet);
1386
+ if (ret[1]) {
1387
+ throw takeFromExternrefTable0(ret[0]);
1388
+ }
1389
+ }
1390
+ /**
1391
+ * Removes a table by name. Answers whether there was one.
1392
+ * @param {number} sheet
1393
+ * @param {string} name
1394
+ * @returns {boolean}
1395
+ */
1396
+ removeTable(sheet, name) {
1397
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1398
+ const len0 = WASM_VECTOR_LEN;
1399
+ const ret = wasm.book_removeTable(this.__wbg_ptr, sheet, ptr0, len0);
1400
+ if (ret[2]) {
1401
+ throw takeFromExternrefTable0(ret[1]);
1402
+ }
1403
+ return ret[0] !== 0;
1404
+ }
1405
+ /**
1406
+ * Renames a sheet.
1407
+ * @param {number} sheet
1408
+ * @param {string} title
1409
+ */
1410
+ renameSheet(sheet, title) {
1411
+ const ptr0 = passStringToWasm0(title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1412
+ const len0 = WASM_VECTOR_LEN;
1413
+ const ret = wasm.book_renameSheet(this.__wbg_ptr, sheet, ptr0, len0);
1414
+ if (ret[1]) {
1415
+ throw takeFromExternrefTable0(ret[0]);
1416
+ }
1417
+ }
1418
+ /**
1419
+ * The height of a row in points, or `undefined` when the sheet leaves it
1420
+ * to the default. `row` is the number a user sees.
1421
+ * @param {number} sheet
1422
+ * @param {number} row
1423
+ * @returns {number | undefined}
1424
+ */
1425
+ rowHeight(sheet, row) {
1426
+ const ret = wasm.book_rowHeight(this.__wbg_ptr, sheet, row);
1427
+ if (ret[3]) {
1428
+ throw takeFromExternrefTable0(ret[2]);
1429
+ }
1430
+ return ret[0] === 0 ? undefined : ret[1];
1431
+ }
1432
+ /**
1433
+ * Whether a row is hidden. `row` is the number a user sees.
1434
+ * @param {number} sheet
1435
+ * @param {number} row
1436
+ * @returns {boolean}
1437
+ */
1438
+ rowHidden(sheet, row) {
1439
+ const ret = wasm.book_rowHidden(this.__wbg_ptr, sheet, row);
1440
+ if (ret[2]) {
1441
+ throw takeFromExternrefTable0(ret[1]);
1442
+ }
1443
+ return ret[0] !== 0;
1444
+ }
1445
+ /**
1446
+ * How deeply a row is grouped: 0 when it is not, 1 for the outermost
1447
+ * group, and so on. `row` is the number a user sees.
1448
+ * @param {number} sheet
1449
+ * @param {number} row
1450
+ * @returns {number}
1451
+ */
1452
+ rowLevel(sheet, row) {
1453
+ const ret = wasm.book_rowLevel(this.__wbg_ptr, sheet, row);
1454
+ if (ret[2]) {
1455
+ throw takeFromExternrefTable0(ret[1]);
1456
+ }
1457
+ return ret[0];
1458
+ }
1459
+ /**
1460
+ * Writes a value: a number, boolean, or string. A string starting with `=`
1461
+ * becomes a formula.
1462
+ * @param {number} sheet
1463
+ * @param {string} address
1464
+ * @param {CellValue} value
1465
+ */
1466
+ set(sheet, address, value) {
1467
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1468
+ const len0 = WASM_VECTOR_LEN;
1469
+ const ret = wasm.book_set(this.__wbg_ptr, sheet, ptr0, len0, value);
1470
+ if (ret[1]) {
1471
+ throw takeFromExternrefTable0(ret[0]);
1472
+ }
1473
+ }
1474
+ /**
1475
+ * Sets that tab.
1476
+ * @param {number} sheet
1477
+ */
1478
+ setActiveSheet(sheet) {
1479
+ const ret = wasm.book_setActiveSheet(this.__wbg_ptr, sheet);
1480
+ if (ret[1]) {
1481
+ throw takeFromExternrefTable0(ret[0]);
1482
+ }
1483
+ }
1484
+ /**
1485
+ * The same by 1-based row and column.
1486
+ * @param {number} sheet
1487
+ * @param {number} row
1488
+ * @param {number} column
1489
+ * @param {CellValue} value
1490
+ */
1491
+ setAt(sheet, row, column, value) {
1492
+ const ret = wasm.book_setAt(this.__wbg_ptr, sheet, row, column, value);
1493
+ if (ret[1]) {
1494
+ throw takeFromExternrefTable0(ret[0]);
1495
+ }
1496
+ }
1497
+ /**
1498
+ * Paints a cell: a number format, a font, a fill, borders, alignment, or
1499
+ * any part of those.
1500
+ *
1501
+ * The patch is laid over the style the cell has, so a field left out
1502
+ * keeps what was there - `{ font: { bold: true } }` does not reset the
1503
+ * number format. Equal styles share one entry in the workbook's table,
1504
+ * so painting a column costs one style, not one per cell.
1505
+ *
1506
+ * ```js
1507
+ * book.setCellStyle(0, "B2", {
1508
+ * numberFormat: "#,##0.00",
1509
+ * font: { bold: true, color: "#FF1F4E79" },
1510
+ * fill: { pattern: "solid", foreground: "#FFFFE699" },
1511
+ * alignment: { horizontal: "right" },
1512
+ * });
1513
+ * ```
1514
+ * @param {number} sheet
1515
+ * @param {string} address
1516
+ * @param {CellStylePatch} patch
1517
+ */
1518
+ setCellStyle(sheet, address, patch) {
1519
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1520
+ const len0 = WASM_VECTOR_LEN;
1521
+ const ret = wasm.book_setCellStyle(this.__wbg_ptr, sheet, ptr0, len0, patch);
1522
+ if (ret[1]) {
1523
+ throw takeFromExternrefTable0(ret[0]);
1524
+ }
1525
+ }
1526
+ /**
1527
+ * The same by 1-based row and column.
1528
+ * @param {number} sheet
1529
+ * @param {number} row
1530
+ * @param {number} column
1531
+ * @param {CellStylePatch} patch
1532
+ */
1533
+ setCellStyleAt(sheet, row, column, patch) {
1534
+ const ret = wasm.book_setCellStyleAt(this.__wbg_ptr, sheet, row, column, patch);
1535
+ if (ret[1]) {
1536
+ throw takeFromExternrefTable0(ret[0]);
1537
+ }
1538
+ }
1539
+ /**
1540
+ * Changes the fill and outline of a chart's chart area (`format`) and
1541
+ * plot area (`plotFormat`), by its position in `charts`; each takes
1542
+ * `{ fill, line }` as `setShapeFormat` does, or `null` to leave the area
1543
+ * to the chart style.
1544
+ * @param {number} sheet
1545
+ * @param {number} index
1546
+ * @param {ChartFormatPatch} patch
1547
+ */
1548
+ setChartFormat(sheet, index, patch) {
1549
+ const ret = wasm.book_setChartFormat(this.__wbg_ptr, sheet, index, patch);
1550
+ if (ret[1]) {
1551
+ throw takeFromExternrefTable0(ret[0]);
1552
+ }
1553
+ }
1554
+ /**
1555
+ * Hides a column, or shows it again. `column` is 1-based.
1556
+ * @param {number} sheet
1557
+ * @param {number} column
1558
+ * @param {boolean} hidden
1559
+ */
1560
+ setColumnHidden(sheet, column, hidden) {
1561
+ const ret = wasm.book_setColumnHidden(this.__wbg_ptr, sheet, column, hidden);
1562
+ if (ret[1]) {
1563
+ throw takeFromExternrefTable0(ret[0]);
1564
+ }
1565
+ }
1566
+ /**
1567
+ * Sets the width of a column in characters of the default font, or gives
1568
+ * it back to the sheet default with `undefined`. `column` is 1-based.
1569
+ *
1570
+ * A run of columns that covered this one is split around it, so the
1571
+ * neighbours keep the width they had.
1572
+ * @param {number} sheet
1573
+ * @param {number} column
1574
+ * @param {number | null} [width]
1575
+ */
1576
+ setColumnWidth(sheet, column, width) {
1577
+ const ret = wasm.book_setColumnWidth(this.__wbg_ptr, sheet, column, !isLikeNone(width), isLikeNone(width) ? 0 : width);
1578
+ if (ret[1]) {
1579
+ throw takeFromExternrefTable0(ret[0]);
1580
+ }
1581
+ }
1582
+ /**
1583
+ * Puts a note on a cell, replacing any note already there.
1584
+ * @param {number} sheet
1585
+ * @param {string} address
1586
+ * @param {string} author
1587
+ * @param {string} text
1588
+ */
1589
+ setComment(sheet, address, author, text) {
1590
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1591
+ const len0 = WASM_VECTOR_LEN;
1592
+ const ptr1 = passStringToWasm0(author, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1593
+ const len1 = WASM_VECTOR_LEN;
1594
+ const ptr2 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1595
+ const len2 = WASM_VECTOR_LEN;
1596
+ const ret = wasm.book_setComment(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, ptr2, len2);
1597
+ if (ret[1]) {
1598
+ throw takeFromExternrefTable0(ret[0]);
1599
+ }
1600
+ }
1601
+ /**
1602
+ * Defines a name, replacing one of the same name. `formula` is what it
1603
+ * stands for - `Sheet1!$A$1:$A$9` or a constant - and `sheet` makes the
1604
+ * name local to that sheet instead of the workbook.
1605
+ * @param {string} name
1606
+ * @param {string} formula
1607
+ * @param {number | null} [sheet]
1608
+ */
1609
+ setDefinedName(name, formula, sheet) {
1610
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1611
+ const len0 = WASM_VECTOR_LEN;
1612
+ const ptr1 = passStringToWasm0(formula, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1613
+ const len1 = WASM_VECTOR_LEN;
1614
+ const ret = wasm.book_setDefinedName(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
1615
+ if (ret[1]) {
1616
+ throw takeFromExternrefTable0(ret[0]);
1617
+ }
1618
+ }
1619
+ /**
1620
+ * Changes the fields the patch names and leaves the rest: a string sets
1621
+ * one, `null` clears it. `custom`, when given, replaces the list; a
1622
+ * field's type is taken from `type` or else from the value (a whole
1623
+ * number is an integer).
1624
+ * @param {DocumentPropertiesPatch} patch
1625
+ */
1626
+ setDocumentProperties(patch) {
1627
+ const ret = wasm.book_setDocumentProperties(this.__wbg_ptr, patch);
1628
+ if (ret[1]) {
1629
+ throw takeFromExternrefTable0(ret[0]);
1630
+ }
1631
+ }
1632
+ /**
1633
+ * Puts a link over a cell or a block of them.
1634
+ *
1635
+ * `target` is a URL or a file path unless `inside` is true, and then it
1636
+ * is a place in this workbook: `'Sheet 2'!A1`.
1637
+ * @param {number} sheet
1638
+ * @param {string} range
1639
+ * @param {string} target
1640
+ * @param {boolean | null} [inside]
1641
+ * @param {string | null} [display]
1642
+ * @param {string | null} [tooltip]
1643
+ */
1644
+ setHyperlink(sheet, range, target, inside, display, tooltip) {
1645
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1646
+ const len0 = WASM_VECTOR_LEN;
1647
+ const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1648
+ const len1 = WASM_VECTOR_LEN;
1649
+ var ptr2 = isLikeNone(display) ? 0 : passStringToWasm0(display, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1650
+ var len2 = WASM_VECTOR_LEN;
1651
+ var ptr3 = isLikeNone(tooltip) ? 0 : passStringToWasm0(tooltip, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1652
+ var len3 = WASM_VECTOR_LEN;
1653
+ const ret = wasm.book_setHyperlink(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(inside) ? 0xFFFFFF : inside ? 1 : 0, ptr2, len2, ptr3, len3);
1654
+ if (ret[1]) {
1655
+ throw takeFromExternrefTable0(ret[0]);
1656
+ }
1657
+ }
1658
+ /**
1659
+ * Writes a rectangle of values with `at` as its top-left corner. Rows may
1660
+ * differ in length; a `null` leaves its cell empty.
1661
+ * @param {number} sheet
1662
+ * @param {string} at
1663
+ * @param {CellGrid} values
1664
+ */
1665
+ setRange(sheet, at, values) {
1666
+ const ptr0 = passStringToWasm0(at, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1667
+ const len0 = WASM_VECTOR_LEN;
1668
+ const ret = wasm.book_setRange(this.__wbg_ptr, sheet, ptr0, len0, values);
1669
+ if (ret[1]) {
1670
+ throw takeFromExternrefTable0(ret[0]);
1671
+ }
1672
+ }
1673
+ /**
1674
+ * The same with the corner given as 1-based row and column.
1675
+ * @param {number} sheet
1676
+ * @param {number} row
1677
+ * @param {number} column
1678
+ * @param {CellGrid} values
1679
+ */
1680
+ setRangeAt(sheet, row, column, values) {
1681
+ const ret = wasm.book_setRangeAt(this.__wbg_ptr, sheet, row, column, values);
1682
+ if (ret[1]) {
1683
+ throw takeFromExternrefTable0(ret[0]);
1684
+ }
1685
+ }
1686
+ /**
1687
+ * The same over a rectangle: `setRangeStyle(0, "A1:D1", { font: { bold:
1688
+ * true } })`. Cells the range covers but the sheet has no value for are
1689
+ * created empty, which is what carries the style.
1690
+ * @param {number} sheet
1691
+ * @param {string} range
1692
+ * @param {CellStylePatch} patch
1693
+ */
1694
+ setRangeStyle(sheet, range, patch) {
1695
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1696
+ const len0 = WASM_VECTOR_LEN;
1697
+ const ret = wasm.book_setRangeStyle(this.__wbg_ptr, sheet, ptr0, len0, patch);
1698
+ if (ret[1]) {
1699
+ throw takeFromExternrefTable0(ret[0]);
1700
+ }
1701
+ }
1702
+ /**
1703
+ * Paints a rectangle cell by cell in one call, `at` its top-left corner:
1704
+ * `grid` points into `styles`, each a patch as `setCellStyle` takes it,
1705
+ * and `null` or `-1` leaves its cell alone. The output of
1706
+ * `getRangeStyles` goes back in unchanged, so a block's formatting can be
1707
+ * read, edited in JS and written back - or copied somewhere else.
1708
+ * @param {number} sheet
1709
+ * @param {string} at
1710
+ * @param {RangeStylesPatch} styles
1711
+ */
1712
+ setRangeStyles(sheet, at, styles) {
1713
+ const ptr0 = passStringToWasm0(at, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1714
+ const len0 = WASM_VECTOR_LEN;
1715
+ const ret = wasm.book_setRangeStyles(this.__wbg_ptr, sheet, ptr0, len0, styles);
1716
+ if (ret[1]) {
1717
+ throw takeFromExternrefTable0(ret[0]);
1718
+ }
1719
+ }
1720
+ /**
1721
+ * The same with the corner given as 1-based row and column.
1722
+ * @param {number} sheet
1723
+ * @param {number} row
1724
+ * @param {number} column
1725
+ * @param {RangeStylesPatch} styles
1726
+ */
1727
+ setRangeStylesAt(sheet, row, column, styles) {
1728
+ const ret = wasm.book_setRangeStylesAt(this.__wbg_ptr, sheet, row, column, styles);
1729
+ if (ret[1]) {
1730
+ throw takeFromExternrefTable0(ret[0]);
1731
+ }
1732
+ }
1733
+ /**
1734
+ * Writes formatted text: runs as `getRichText` returns them, each with
1735
+ * its own text and the part of the font it changes (`font` may be left
1736
+ * out or `null` for the cell's own).
1737
+ * @param {number} sheet
1738
+ * @param {string} address
1739
+ * @param {TextRun[]} runs
1740
+ */
1741
+ setRichText(sheet, address, runs) {
1742
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1743
+ const len0 = WASM_VECTOR_LEN;
1744
+ const ret = wasm.book_setRichText(this.__wbg_ptr, sheet, ptr0, len0, runs);
1745
+ if (ret[1]) {
1746
+ throw takeFromExternrefTable0(ret[0]);
1747
+ }
1748
+ }
1749
+ /**
1750
+ * The same by 1-based row and column.
1751
+ * @param {number} sheet
1752
+ * @param {number} row
1753
+ * @param {number} column
1754
+ * @param {TextRun[]} runs
1755
+ */
1756
+ setRichTextAt(sheet, row, column, runs) {
1757
+ const ret = wasm.book_setRichTextAt(this.__wbg_ptr, sheet, row, column, runs);
1758
+ if (ret[1]) {
1759
+ throw takeFromExternrefTable0(ret[0]);
1760
+ }
1761
+ }
1762
+ /**
1763
+ * Sets the height of a row in points, or gives it back to the sheet
1764
+ * default with `undefined`. `row` is the number a user sees.
1765
+ * @param {number} sheet
1766
+ * @param {number} row
1767
+ * @param {number | null} [height]
1768
+ */
1769
+ setRowHeight(sheet, row, height) {
1770
+ const ret = wasm.book_setRowHeight(this.__wbg_ptr, sheet, row, !isLikeNone(height), isLikeNone(height) ? 0 : height);
1771
+ if (ret[1]) {
1772
+ throw takeFromExternrefTable0(ret[0]);
1773
+ }
1774
+ }
1775
+ /**
1776
+ * Hides a row, or shows it again.
1777
+ * @param {number} sheet
1778
+ * @param {number} row
1779
+ * @param {boolean} hidden
1780
+ */
1781
+ setRowHidden(sheet, row, hidden) {
1782
+ const ret = wasm.book_setRowHidden(this.__wbg_ptr, sheet, row, hidden);
1783
+ if (ret[1]) {
1784
+ throw takeFromExternrefTable0(ret[0]);
1785
+ }
1786
+ }
1787
+ /**
1788
+ * Changes how a shape looks, by its position in `shapes`:
1789
+ *
1790
+ * ```js
1791
+ * book.setShapeFormat(0, 2, {
1792
+ * fill: { type: "solid", color: "accent2" },
1793
+ * line: { width: 2 },
1794
+ * font: { bold: true, color: "#FFFFFFFF" },
1795
+ * rotation: 15,
1796
+ * });
1797
+ * ```
1798
+ *
1799
+ * `fill`, `line`, `font`, `rotation` (degrees clockwise), `flipH` and
1800
+ * `flipV`; a field left out stays as it was, `null` for `fill` or `line`
1801
+ * gives it back to the shape's style. A colour is `#RRGGBB`,
1802
+ * `#AARRGGBB` or a theme colour by name (`accent1`, `tx1`, `bg2`), which
1803
+ * follows the theme. The rest of the shape - effects, other runs, the
1804
+ * outline's dashes - stays in the file as it was.
1805
+ * @param {number} sheet
1806
+ * @param {number} index
1807
+ * @param {ShapeFormatPatch} patch
1808
+ */
1809
+ setShapeFormat(sheet, index, patch) {
1810
+ const ret = wasm.book_setShapeFormat(this.__wbg_ptr, sheet, index, patch);
1811
+ if (ret[1]) {
1812
+ throw takeFromExternrefTable0(ret[0]);
1813
+ }
1814
+ }
1815
+ /**
1816
+ * Gives a sheet a tab or takes it away: `"visible"`, `"hidden"` or
1817
+ * `"veryHidden"`.
1818
+ *
1819
+ * A very hidden sheet is not in the dialog Excel offers for unhiding one.
1820
+ * Either way the sheet keeps its index, which is what every other call
1821
+ * counts.
1822
+ * @param {number} sheet
1823
+ * @param {string} state
1824
+ */
1825
+ setSheetVisibility(sheet, state) {
1826
+ const ptr0 = passStringToWasm0(state, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1827
+ const len0 = WASM_VECTOR_LEN;
1828
+ const ret = wasm.book_setSheetVisibility(this.__wbg_ptr, sheet, ptr0, len0);
1829
+ if (ret[1]) {
1830
+ throw takeFromExternrefTable0(ret[0]);
1831
+ }
1832
+ }
1833
+ /**
1834
+ * Shows or hides the grid lines, and the row and column headings with
1835
+ * `headers`.
1836
+ * @param {number} sheet
1837
+ * @param {boolean} show
1838
+ * @param {boolean | null} [headers]
1839
+ */
1840
+ setShowGridLines(sheet, show, headers) {
1841
+ const ret = wasm.book_setShowGridLines(this.__wbg_ptr, sheet, show, isLikeNone(headers) ? 0xFFFFFF : headers ? 1 : 0);
1842
+ if (ret[1]) {
1843
+ throw takeFromExternrefTable0(ret[0]);
1844
+ }
1845
+ }
1846
+ /**
1847
+ * Filters a table by one of its columns, named by its header or
1848
+ * numbered from 1, and hides the data rows the table's criteria reject,
1849
+ * as Excel does. `null` takes the column's criterion off.
1850
+ *
1851
+ * ```js
1852
+ * book.setTableFilter("Sales", "Region", { values: ["South", "West"] });
1853
+ * book.setTableFilter("Sales", "Amount", { custom: [{ op: ">", value: 100 }] });
1854
+ * book.setTableFilter("Sales", 3, { top: 5 }); // or { bottom: 10, percent: true }
1855
+ * ```
1856
+ *
1857
+ * `values` keeps a row whose cell shows one of them, `blank: true` the
1858
+ * empty ones too; `custom` takes one or two comparisons (`=`, `<>`, `>`,
1859
+ * `>=`, `<`, `<=`; `*` and `?` in `=` and `<>`), joined by `or` unless
1860
+ * `and` is set. Criteria on several columns all have to hold.
1861
+ * @param {string} name
1862
+ * @param {string | number} column
1863
+ * @param {TableFilter | null} criteria
1864
+ */
1865
+ setTableFilter(name, column, criteria) {
1866
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1867
+ const len0 = WASM_VECTOR_LEN;
1868
+ const ret = wasm.book_setTableFilter(this.__wbg_ptr, ptr0, len0, column, criteria);
1869
+ if (ret[1]) {
1870
+ throw takeFromExternrefTable0(ret[0]);
1871
+ }
1872
+ }
1873
+ /**
1874
+ * The zoom a reader opens the sheet at, in percent; `undefined` gives it
1875
+ * back to 100.
1876
+ * @param {number} sheet
1877
+ * @param {number | null} [percent]
1878
+ */
1879
+ setZoom(sheet, percent) {
1880
+ const ret = wasm.book_setZoom(this.__wbg_ptr, sheet, isLikeNone(percent) ? Number.MAX_SAFE_INTEGER : (percent) >>> 0);
1881
+ if (ret[1]) {
1882
+ throw takeFromExternrefTable0(ret[0]);
1883
+ }
1884
+ }
1885
+ /**
1886
+ * The drawn shapes of a sheet, text and all, with the look Excel shows:
1887
+ * fill, outline and font are the shape's own with its style filling in
1888
+ * the rest, colours resolved through the workbook theme.
1889
+ * @param {number} sheet
1890
+ * @returns {SheetShape[]}
1891
+ */
1892
+ shapes(sheet) {
1893
+ const ret = wasm.book_shapes(this.__wbg_ptr, sheet);
1894
+ if (ret[2]) {
1895
+ throw takeFromExternrefTable0(ret[1]);
1896
+ }
1897
+ return takeFromExternrefTable0(ret[0]);
1898
+ }
1899
+ /**
1900
+ * The tab index of a sheet by name, or `undefined` when there is none.
1901
+ * Names are compared the way Excel does, ignoring case.
1902
+ * @param {string} name
1903
+ * @returns {number | undefined}
1904
+ */
1905
+ sheetIndex(name) {
1906
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1907
+ const len0 = WASM_VECTOR_LEN;
1908
+ const ret = wasm.book_sheetIndex(this.__wbg_ptr, ptr0, len0);
1909
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
1910
+ }
1911
+ /**
1912
+ * Sheet titles, in tab order.
1913
+ * @returns {string[]}
1914
+ */
1915
+ sheetNames() {
1916
+ const ret = wasm.book_sheetNames(this.__wbg_ptr);
1917
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
1918
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1919
+ return v1;
1920
+ }
1921
+ /**
1922
+ * Whether a sheet is locked, and whether the lock has a password.
1923
+ * @param {number} sheet
1924
+ * @returns {ProtectionInfo}
1925
+ */
1926
+ sheetProtection(sheet) {
1927
+ const ret = wasm.book_sheetProtection(this.__wbg_ptr, sheet);
1928
+ if (ret[2]) {
1929
+ throw takeFromExternrefTable0(ret[1]);
1930
+ }
1931
+ return takeFromExternrefTable0(ret[0]);
1932
+ }
1933
+ /**
1934
+ * How the sheet is frozen and shown.
1935
+ * @param {number} sheet
1936
+ * @returns {SheetViewInfo}
1937
+ */
1938
+ sheetView(sheet) {
1939
+ const ret = wasm.book_sheetView(this.__wbg_ptr, sheet);
1940
+ if (ret[2]) {
1941
+ throw takeFromExternrefTable0(ret[1]);
1942
+ }
1943
+ return takeFromExternrefTable0(ret[0]);
1944
+ }
1945
+ /**
1946
+ * Whether a sheet has a tab: `"visible"`, `"hidden"` or `"veryHidden"`.
1947
+ *
1948
+ * `sheetNames` lists every sheet, hidden ones included, because that is
1949
+ * what the index of every other call counts.
1950
+ * @param {number} sheet
1951
+ * @returns {string}
1952
+ */
1953
+ sheetVisibility(sheet) {
1954
+ let deferred2_0;
1955
+ let deferred2_1;
1956
+ try {
1957
+ const ret = wasm.book_sheetVisibility(this.__wbg_ptr, sheet);
1958
+ var ptr1 = ret[0];
1959
+ var len1 = ret[1];
1960
+ if (ret[3]) {
1961
+ ptr1 = 0; len1 = 0;
1962
+ throw takeFromExternrefTable0(ret[2]);
1963
+ }
1964
+ deferred2_0 = ptr1;
1965
+ deferred2_1 = len1;
1966
+ return getStringFromWasm0(ptr1, len1);
1967
+ } finally {
1968
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1969
+ }
1970
+ }
1971
+ /**
1972
+ * Sorts the rows of a range, or its columns. A key is a column number of
1973
+ * the sheet, 1-based (a row number when sorting columns), or the text of
1974
+ * a header when `options.header` says the first line is one; a minus
1975
+ * sorts it largest first: `[2, -4]`, `["Region", "-Amount"]`. The first
1976
+ * key decides first.
1977
+ *
1978
+ * ```js
1979
+ * book.sortRange(0, "A1:D100", ["Region", "-Amount"], { header: true });
1980
+ * ```
1981
+ * @param {number} sheet
1982
+ * @param {string} range
1983
+ * @param {SortKeys} keys
1984
+ * @param {SortRangeOptions} [options]
1985
+ */
1986
+ sortRange(sheet, range, keys, options) {
1987
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1988
+ const len0 = WASM_VECTOR_LEN;
1989
+ const ret = wasm.book_sortRange(this.__wbg_ptr, sheet, ptr0, len0, keys, options);
1990
+ if (ret[1]) {
1991
+ throw takeFromExternrefTable0(ret[0]);
1992
+ }
1993
+ }
1994
+ /**
1995
+ * Sorts the data rows of a table, found by name anywhere in the book;
1996
+ * its header and totals rows stay put. Keys name its columns, as in
1997
+ * `sortRange`: `book.sortTable("Sales", ["-Amount"])`.
1998
+ * @param {string} name
1999
+ * @param {SortKeys} keys
2000
+ */
2001
+ sortTable(name, keys) {
2002
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2003
+ const len0 = WASM_VECTOR_LEN;
2004
+ const ret = wasm.book_sortTable(this.__wbg_ptr, ptr0, len0, keys);
2005
+ if (ret[1]) {
2006
+ throw takeFromExternrefTable0(ret[0]);
2007
+ }
2008
+ }
2009
+ /**
2010
+ * The tables of a sheet: what a structured reference like `Sales[Amount]`
2011
+ * names.
2012
+ * @param {number} sheet
2013
+ * @returns {SheetTable[]}
2014
+ */
2015
+ tables(sheet) {
2016
+ const ret = wasm.book_tables(this.__wbg_ptr, sheet);
2017
+ if (ret[2]) {
2018
+ throw takeFromExternrefTable0(ret[1]);
2019
+ }
2020
+ return takeFromExternrefTable0(ret[0]);
2021
+ }
2022
+ /**
2023
+ * Splits the text of each cell in the first column of `range` across
2024
+ * the columns to its right, as Excel's Text to Columns does. Pieces that
2025
+ * read as numbers, booleans or errors become them. Returns how many
2026
+ * columns the widest row took.
2027
+ *
2028
+ * `options.delimiters` is a string of delimiter characters (`";"`,
2029
+ * `",\t"`), or `options.widths` the character positions to cut before
2030
+ * for fixed width; `mergeConsecutive` treats a run of delimiters as one,
2031
+ * `qualifier` is the quote (`"` unless given; `null` for none), and
2032
+ * `destination` is the first cell written (the range's own when left
2033
+ * out).
2034
+ *
2035
+ * ```js
2036
+ * book.textToColumns(0, "A2:A100", { delimiters: ";" });
2037
+ * book.textToColumns(0, "A2:A100", { widths: [4, 10], destination: "C2" });
2038
+ * ```
2039
+ * @param {number} sheet
2040
+ * @param {string} range
2041
+ * @param {TextToColumnsOptions} options
2042
+ * @returns {number}
2043
+ */
2044
+ textToColumns(sheet, range, options) {
2045
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2046
+ const len0 = WASM_VECTOR_LEN;
2047
+ const ret = wasm.book_textToColumns(this.__wbg_ptr, sheet, ptr0, len0, options);
2048
+ if (ret[2]) {
2049
+ throw takeFromExternrefTable0(ret[1]);
2050
+ }
2051
+ return ret[0] >>> 0;
2052
+ }
2053
+ /**
2054
+ * One sheet as CSV, comma-separated unless `options.delimiter` says
2055
+ * otherwise - a semicolon for a locale where the comma is the decimal
2056
+ * mark.
2057
+ * @param {number} sheet
2058
+ * @param {CsvOptions} [options]
2059
+ * @returns {string}
2060
+ */
2061
+ toCsv(sheet, options) {
2062
+ let deferred2_0;
2063
+ let deferred2_1;
2064
+ try {
2065
+ const ret = wasm.book_toCsv(this.__wbg_ptr, sheet, options);
2066
+ var ptr1 = ret[0];
2067
+ var len1 = ret[1];
2068
+ if (ret[3]) {
2069
+ ptr1 = 0; len1 = 0;
2070
+ throw takeFromExternrefTable0(ret[2]);
2071
+ }
2072
+ deferred2_0 = ptr1;
2073
+ deferred2_1 = len1;
2074
+ return getStringFromWasm0(ptr1, len1);
2075
+ } finally {
2076
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2077
+ }
2078
+ }
2079
+ /**
2080
+ * The workbook as an HTML page, or one sheet of it. `fragment` leaves out
2081
+ * the `<html>` wrapper, for embedding in a page that already has one.
2082
+ * @param {number | null} [sheet]
2083
+ * @param {boolean | null} [fragment]
2084
+ * @returns {string}
2085
+ */
2086
+ toHtml(sheet, fragment) {
2087
+ let deferred2_0;
2088
+ let deferred2_1;
2089
+ try {
2090
+ const ret = wasm.book_toHtml(this.__wbg_ptr, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0, isLikeNone(fragment) ? 0xFFFFFF : fragment ? 1 : 0);
2091
+ var ptr1 = ret[0];
2092
+ var len1 = ret[1];
2093
+ if (ret[3]) {
2094
+ ptr1 = 0; len1 = 0;
2095
+ throw takeFromExternrefTable0(ret[2]);
2096
+ }
2097
+ deferred2_0 = ptr1;
2098
+ deferred2_1 = len1;
2099
+ return getStringFromWasm0(ptr1, len1);
2100
+ } finally {
2101
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2102
+ }
2103
+ }
2104
+ /**
2105
+ * The workbook as an `OpenDocument` spreadsheet.
2106
+ * @returns {Uint8Array}
2107
+ */
2108
+ toOds() {
2109
+ const ret = wasm.book_toOds(this.__wbg_ptr);
2110
+ if (ret[3]) {
2111
+ throw takeFromExternrefTable0(ret[2]);
2112
+ }
2113
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2114
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2115
+ return v1;
2116
+ }
2117
+ /**
2118
+ * The workbook as a BIFF8 `.xls` file.
2119
+ *
2120
+ * Formulas are written as tokens with their cached result; what BIFF8
2121
+ * cannot hold - a structured reference, a row past 65536 - is written as
2122
+ * the value, so call `recalculate` first if the cache is stale.
2123
+ * @returns {Uint8Array}
2124
+ */
2125
+ toXls() {
2126
+ const ret = wasm.book_toXls(this.__wbg_ptr);
2127
+ if (ret[3]) {
2128
+ throw takeFromExternrefTable0(ret[2]);
2129
+ }
2130
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2131
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2132
+ return v1;
2133
+ }
2134
+ /**
2135
+ * The workbook as an xlsx package.
2136
+ * @param {Function | null} [on_progress]
2137
+ * @returns {Uint8Array}
2138
+ */
2139
+ toXlsx(on_progress) {
2140
+ const ret = wasm.book_toXlsx(this.__wbg_ptr, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
2141
+ if (ret[3]) {
2142
+ throw takeFromExternrefTable0(ret[2]);
2143
+ }
2144
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2145
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2146
+ return v1;
2147
+ }
2148
+ /**
2149
+ * Takes a merge back out. Answers whether there was one.
2150
+ * @param {number} sheet
2151
+ * @param {string} range
2152
+ * @returns {boolean}
2153
+ */
2154
+ unmerge(sheet, range) {
2155
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2156
+ const len0 = WASM_VECTOR_LEN;
2157
+ const ret = wasm.book_unmerge(this.__wbg_ptr, sheet, ptr0, len0);
2158
+ if (ret[2]) {
2159
+ throw takeFromExternrefTable0(ret[1]);
2160
+ }
2161
+ return ret[0] !== 0;
2162
+ }
2163
+ /**
2164
+ * Unlocks a sheet, password and all.
2165
+ * @param {number} sheet
2166
+ */
2167
+ unprotectSheet(sheet) {
2168
+ const ret = wasm.book_unprotectSheet(this.__wbg_ptr, sheet);
2169
+ if (ret[1]) {
2170
+ throw takeFromExternrefTable0(ret[0]);
2171
+ }
2172
+ }
2173
+ /**
2174
+ * Unlocks the workbook.
2175
+ */
2176
+ unprotectWorkbook() {
2177
+ wasm.book_unprotectWorkbook(this.__wbg_ptr);
2178
+ }
2179
+ /**
2180
+ * Forgets a function registered earlier; answers whether there was one.
2181
+ * @param {string} name
2182
+ * @returns {boolean}
2183
+ */
2184
+ unregisterFunction(name) {
2185
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2186
+ const len0 = WASM_VECTOR_LEN;
2187
+ const ret = wasm.book_unregisterFunction(this.__wbg_ptr, ptr0, len0);
2188
+ return ret !== 0;
2189
+ }
2190
+ /**
2191
+ * The used range of a sheet as `A1:D9`, or `undefined` if it holds
2192
+ * nothing. This is the rectangle to walk; the sheet itself is sparse.
2193
+ * @param {number} sheet
2194
+ * @returns {string | undefined}
2195
+ */
2196
+ usedRange(sheet) {
2197
+ const ret = wasm.book_usedRange(this.__wbg_ptr, sheet);
2198
+ let v1;
2199
+ if (ret[0] !== 0) {
2200
+ v1 = getStringFromWasm0(ret[0], ret[1]);
2201
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2202
+ }
2203
+ return v1;
2204
+ }
2205
+ /**
2206
+ * The used range of a sheet as `"A1:D20"` without walking the rows;
2207
+ * `undefined` for an empty sheet.
2208
+ *
2209
+ * Rows are exact, columns an upper bound: removing a cell never narrows
2210
+ * them. `usedRange` answers the same until a cell in an edge column is
2211
+ * removed, and walks the rows after that to give the exact rectangle.
2212
+ * @param {number} sheet
2213
+ * @returns {string | undefined}
2214
+ */
2215
+ usedRangeHint(sheet) {
2216
+ const ret = wasm.book_usedRangeHint(this.__wbg_ptr, sheet);
2217
+ if (ret[3]) {
2218
+ throw takeFromExternrefTable0(ret[2]);
2219
+ }
2220
+ let v1;
2221
+ if (ret[0] !== 0) {
2222
+ v1 = getStringFromWasm0(ret[0], ret[1]);
2223
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2224
+ }
2225
+ return v1;
2226
+ }
2227
+ /**
2228
+ * The choices of the drop-down list on a cell, as Excel shows them; an
2229
+ * empty array when the cell has no list rule.
2230
+ * @param {number} sheet
2231
+ * @param {string} address
2232
+ * @returns {string[]}
2233
+ */
2234
+ validationList(sheet, address) {
2235
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2236
+ const len0 = WASM_VECTOR_LEN;
2237
+ const ret = wasm.book_validationList(this.__wbg_ptr, sheet, ptr0, len0);
2238
+ if (ret[3]) {
2239
+ throw takeFromExternrefTable0(ret[2]);
2240
+ }
2241
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]);
2242
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
2243
+ return v2;
2244
+ }
2245
+ /**
2246
+ * Whether that password unlocks the sheet. `false` for a sheet with no
2247
+ * password on it, and for a hash this crate cannot check.
2248
+ * @param {number} sheet
2249
+ * @param {string} password
2250
+ * @returns {boolean}
2251
+ */
2252
+ verifySheetPassword(sheet, password) {
2253
+ const ptr0 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2254
+ const len0 = WASM_VECTOR_LEN;
2255
+ const ret = wasm.book_verifySheetPassword(this.__wbg_ptr, sheet, ptr0, len0);
2256
+ if (ret[2]) {
2257
+ throw takeFromExternrefTable0(ret[1]);
2258
+ }
2259
+ return ret[0] !== 0;
2260
+ }
2261
+ /**
2262
+ * Whether the workbook's structure is locked, and whether behind a
2263
+ * password.
2264
+ * @returns {ProtectionInfo}
2265
+ */
2266
+ workbookProtection() {
2267
+ const ret = wasm.book_workbookProtection(this.__wbg_ptr);
2268
+ return ret;
2269
+ }
2270
+ }
2271
+ if (Symbol.dispose) Book.prototype[Symbol.dispose] = Book.prototype.free;
2272
+ function __wbg_get_imports() {
2273
+ const import0 = {
2274
+ __proto__: null,
2275
+ __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
2276
+ const ret = Error(getStringFromWasm0(arg0, arg1));
2277
+ return ret;
2278
+ },
2279
+ __wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
2280
+ const v = arg0;
2281
+ const ret = typeof(v) === 'boolean' ? v : undefined;
2282
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2283
+ },
2284
+ __wbg___wbindgen_is_falsy_b7464e97ddc1b7a4: function(arg0) {
2285
+ const ret = !arg0;
2286
+ return ret;
2287
+ },
2288
+ __wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
2289
+ const ret = arg0 === null;
2290
+ return ret;
2291
+ },
2292
+ __wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
2293
+ const val = arg0;
2294
+ const ret = typeof(val) === 'object' && val !== null;
2295
+ return ret;
2296
+ },
2297
+ __wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
2298
+ const ret = arg0 === undefined;
2299
+ return ret;
2300
+ },
2301
+ __wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
2302
+ const obj = arg1;
2303
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2304
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2305
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2306
+ },
2307
+ __wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
2308
+ const obj = arg1;
2309
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2310
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2311
+ var len1 = WASM_VECTOR_LEN;
2312
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2313
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2314
+ },
2315
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
2316
+ throw new Error(getStringFromWasm0(arg0, arg1));
2317
+ },
2318
+ __wbg_apply_6cd9daeacef161ce: function() { return handleError(function (arg0, arg1, arg2) {
2319
+ const ret = Reflect.apply(arg0, arg1, arg2);
2320
+ return ret;
2321
+ }, arguments); },
2322
+ __wbg_call_0f2a9af232c18fd2: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2323
+ const ret = arg0.call(arg1, arg2, arg3);
2324
+ return ret;
2325
+ }, arguments); },
2326
+ __wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
2327
+ const ret = arg0.call(arg1, arg2);
2328
+ return ret;
2329
+ }, arguments); },
2330
+ __wbg_from_74f3d90e0ff11240: function(arg0) {
2331
+ const ret = Array.from(arg0);
2332
+ return ret;
2333
+ },
2334
+ __wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
2335
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
2336
+ }, arguments); },
2337
+ __wbg_getTime_63fb0332e6c4ec17: function(arg0) {
2338
+ const ret = arg0.getTime();
2339
+ return ret;
2340
+ },
2341
+ __wbg_get_971a0c45d172643f: function() { return handleError(function (arg0, arg1) {
2342
+ const ret = Reflect.get(arg0, arg1);
2343
+ return ret;
2344
+ }, arguments); },
2345
+ __wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
2346
+ const ret = arg0[arg1 >>> 0];
2347
+ return ret;
2348
+ },
2349
+ __wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
2350
+ const ret = arg0[arg1 >>> 0];
2351
+ return ret;
2352
+ },
2353
+ __wbg_isArray_6339f732981044bf: function(arg0) {
2354
+ const ret = Array.isArray(arg0);
2355
+ return ret;
2356
+ },
2357
+ __wbg_length_ecfa2c63d3d0d82c: function(arg0) {
2358
+ const ret = arg0.length;
2359
+ return ret;
2360
+ },
2361
+ __wbg_message_c141d5e68716b595: function(arg0) {
2362
+ const ret = arg0.message;
2363
+ return ret;
2364
+ },
2365
+ __wbg_new_0_f117d868b403dc07: function() {
2366
+ const ret = new Date();
2367
+ return ret;
2368
+ },
2369
+ __wbg_new_116be93542d39019: function() {
2370
+ const ret = new Array();
2371
+ return ret;
2372
+ },
2373
+ __wbg_new_ebe3e0f6837f0879: function() {
2374
+ const ret = new Object();
2375
+ return ret;
2376
+ },
2377
+ __wbg_new_from_slice_3eea173078478cfe: function(arg0, arg1) {
2378
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2379
+ return ret;
2380
+ },
2381
+ __wbg_new_from_slice_8aed4f0384605526: function(arg0, arg1) {
2382
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
2383
+ return ret;
2384
+ },
2385
+ __wbg_now_8b265300afd5f2b9: function() {
2386
+ const ret = Date.now();
2387
+ return ret;
2388
+ },
2389
+ __wbg_push_adb0107829f02d75: function(arg0, arg1) {
2390
+ const ret = arg0.push(arg1);
2391
+ return ret;
2392
+ },
2393
+ __wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {
2394
+ const ret = Reflect.set(arg0, arg1, arg2);
2395
+ return ret;
2396
+ }, arguments); },
2397
+ __wbindgen_cast_0000000000000001: function(arg0) {
2398
+ // Cast intrinsic for `F64 -> Externref`.
2399
+ const ret = arg0;
2400
+ return ret;
2401
+ },
2402
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
2403
+ // Cast intrinsic for `Ref(String) -> Externref`.
2404
+ const ret = getStringFromWasm0(arg0, arg1);
2405
+ return ret;
2406
+ },
2407
+ __wbindgen_init_externref_table: function() {
2408
+ const table = wasm.__wbindgen_externrefs;
2409
+ const offset = table.grow(4);
2410
+ table.set(0, undefined);
2411
+ table.set(offset + 0, undefined);
2412
+ table.set(offset + 1, null);
2413
+ table.set(offset + 2, true);
2414
+ table.set(offset + 3, false);
2415
+ },
2416
+ };
2417
+ return {
2418
+ __proto__: null,
2419
+ "./excelerate_bg.js": import0,
2420
+ };
2421
+ }
2422
+
2423
+ const BookFinalization = (typeof FinalizationRegistry === 'undefined')
2424
+ ? { register: () => {}, unregister: () => {} }
2425
+ : new FinalizationRegistry(ptr => wasm.__wbg_book_free(ptr, 1));
2426
+
2427
+ function addToExternrefTable0(obj) {
2428
+ const idx = wasm.__externref_table_alloc();
2429
+ wasm.__wbindgen_externrefs.set(idx, obj);
2430
+ return idx;
2431
+ }
2432
+
2433
+ function getArrayJsValueFromWasm0(ptr, len) {
2434
+ ptr = ptr >>> 0;
2435
+ const mem = getDataViewMemory0();
2436
+ const result = [];
2437
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
2438
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
2439
+ }
2440
+ wasm.__externref_drop_slice(ptr, len);
2441
+ return result;
2442
+ }
2443
+
2444
+ function getArrayU32FromWasm0(ptr, len) {
2445
+ ptr = ptr >>> 0;
2446
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
2447
+ }
2448
+
2449
+ function getArrayU8FromWasm0(ptr, len) {
2450
+ ptr = ptr >>> 0;
2451
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2452
+ }
2453
+
2454
+ let cachedDataViewMemory0 = null;
2455
+ function getDataViewMemory0() {
2456
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2457
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2458
+ }
2459
+ return cachedDataViewMemory0;
2460
+ }
2461
+
2462
+ function getStringFromWasm0(ptr, len) {
2463
+ return decodeText(ptr >>> 0, len);
2464
+ }
2465
+
2466
+ let cachedUint32ArrayMemory0 = null;
2467
+ function getUint32ArrayMemory0() {
2468
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
2469
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
2470
+ }
2471
+ return cachedUint32ArrayMemory0;
2472
+ }
2473
+
2474
+ let cachedUint8ArrayMemory0 = null;
2475
+ function getUint8ArrayMemory0() {
2476
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2477
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2478
+ }
2479
+ return cachedUint8ArrayMemory0;
2480
+ }
2481
+
2482
+ function handleError(f, args) {
2483
+ try {
2484
+ return f.apply(this, args);
2485
+ } catch (e) {
2486
+ const idx = addToExternrefTable0(e);
2487
+ wasm.__wbindgen_exn_store(idx);
2488
+ }
2489
+ }
2490
+
2491
+ function isLikeNone(x) {
2492
+ return x === undefined || x === null;
2493
+ }
2494
+
2495
+ function passArray8ToWasm0(arg, malloc) {
2496
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
2497
+ getUint8ArrayMemory0().set(arg, ptr / 1);
2498
+ WASM_VECTOR_LEN = arg.length;
2499
+ return ptr;
2500
+ }
2501
+
2502
+ function passArrayJsValueToWasm0(array, malloc) {
2503
+ const ptr = malloc(array.length * 4, 4) >>> 0;
2504
+ for (let i = 0; i < array.length; i++) {
2505
+ const add = addToExternrefTable0(array[i]);
2506
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
2507
+ }
2508
+ WASM_VECTOR_LEN = array.length;
2509
+ return ptr;
2510
+ }
2511
+
2512
+ function passStringToWasm0(arg, malloc, realloc) {
2513
+ if (realloc === undefined) {
2514
+ const buf = cachedTextEncoder.encode(arg);
2515
+ const ptr = malloc(buf.length, 1) >>> 0;
2516
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2517
+ WASM_VECTOR_LEN = buf.length;
2518
+ return ptr;
2519
+ }
2520
+
2521
+ let len = arg.length;
2522
+ let ptr = malloc(len, 1) >>> 0;
2523
+
2524
+ const mem = getUint8ArrayMemory0();
2525
+
2526
+ let offset = 0;
2527
+
2528
+ for (; offset < len; offset++) {
2529
+ const code = arg.charCodeAt(offset);
2530
+ if (code > 0x7F) break;
2531
+ mem[ptr + offset] = code;
2532
+ }
2533
+ if (offset !== len) {
2534
+ if (offset !== 0) {
2535
+ arg = arg.slice(offset);
2536
+ }
2537
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2538
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2539
+ const ret = cachedTextEncoder.encodeInto(arg, view);
2540
+
2541
+ offset += ret.written;
2542
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2543
+ }
2544
+
2545
+ WASM_VECTOR_LEN = offset;
2546
+ return ptr;
2547
+ }
2548
+
2549
+ function takeFromExternrefTable0(idx) {
2550
+ const value = wasm.__wbindgen_externrefs.get(idx);
2551
+ wasm.__externref_table_dealloc(idx);
2552
+ return value;
2553
+ }
2554
+
2555
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2556
+ cachedTextDecoder.decode();
2557
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
2558
+ let numBytesDecoded = 0;
2559
+ function decodeText(ptr, len) {
2560
+ numBytesDecoded += len;
2561
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
2562
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2563
+ cachedTextDecoder.decode();
2564
+ numBytesDecoded = len;
2565
+ }
2566
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
2567
+ }
2568
+
2569
+ const cachedTextEncoder = new TextEncoder();
2570
+
2571
+ if (!('encodeInto' in cachedTextEncoder)) {
2572
+ cachedTextEncoder.encodeInto = function (arg, view) {
2573
+ const buf = cachedTextEncoder.encode(arg);
2574
+ view.set(buf);
2575
+ return {
2576
+ read: arg.length,
2577
+ written: buf.length
2578
+ };
2579
+ };
2580
+ }
2581
+
2582
+ let WASM_VECTOR_LEN = 0;
2583
+
2584
+ let wasmModule, wasmInstance, wasm;
2585
+ function __wbg_finalize_init(instance, module) {
2586
+ wasmInstance = instance;
2587
+ wasm = instance.exports;
2588
+ wasmModule = module;
2589
+ cachedDataViewMemory0 = null;
2590
+ cachedUint32ArrayMemory0 = null;
2591
+ cachedUint8ArrayMemory0 = null;
2592
+ wasm.__wbindgen_start();
2593
+ return wasm;
2594
+ }
2595
+
2596
+ async function __wbg_load(module, imports) {
2597
+ if (typeof Response === 'function' && module instanceof Response) {
2598
+ if (!module.ok) {
2599
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
2600
+ }
2601
+
2602
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
2603
+ try {
2604
+ return await WebAssembly.instantiateStreaming(module, imports);
2605
+ } catch (e) {
2606
+ const validResponse = expectedResponseType(module.type);
2607
+
2608
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
2609
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
2610
+
2611
+ } else { throw e; }
2612
+ }
2613
+ }
2614
+
2615
+ const bytes = await module.arrayBuffer();
2616
+ return await WebAssembly.instantiate(bytes, imports);
2617
+ } else {
2618
+ const instance = await WebAssembly.instantiate(module, imports);
2619
+
2620
+ if (instance instanceof WebAssembly.Instance) {
2621
+ return { instance, module };
2622
+ } else {
2623
+ return instance;
2624
+ }
2625
+ }
2626
+
2627
+ function expectedResponseType(type) {
2628
+ switch (type) {
2629
+ case 'basic': case 'cors': case 'default': return true;
2630
+ }
2631
+ return false;
2632
+ }
2633
+ }
2634
+
2635
+ function initSync(module) {
2636
+ if (wasm !== undefined) return wasm;
2637
+
2638
+
2639
+ if (module !== undefined) {
2640
+ if (Object.getPrototypeOf(module) === Object.prototype) {
2641
+ ({module} = module)
2642
+ } else {
2643
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
2644
+ }
2645
+ }
2646
+
2647
+ const imports = __wbg_get_imports();
2648
+ if (!(module instanceof WebAssembly.Module)) {
2649
+ module = new WebAssembly.Module(module);
2650
+ }
2651
+ const instance = new WebAssembly.Instance(module, imports);
2652
+ return __wbg_finalize_init(instance, module);
2653
+ }
2654
+
2655
+ async function __wbg_init(module_or_path) {
2656
+ if (wasm !== undefined) return wasm;
2657
+
2658
+
2659
+ if (module_or_path !== undefined) {
2660
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2661
+ ({module_or_path} = module_or_path)
2662
+ } else {
2663
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
2664
+ }
2665
+ }
2666
+
2667
+ if (module_or_path === undefined) {
2668
+ module_or_path = new URL('excelerate_bg.wasm', import.meta.url);
2669
+ }
2670
+ const imports = __wbg_get_imports();
2671
+
2672
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
2673
+ module_or_path = fetch(module_or_path);
2674
+ }
2675
+
2676
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
2677
+
2678
+ return __wbg_finalize_init(instance, module);
2679
+ }
2680
+
2681
+ export { initSync, __wbg_init as default };