@senlinz/import-export 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -148,6 +148,27 @@ const rows = await importExcel(definition);
|
|
|
148
148
|
- Grouped export objects must use `{ value?, children: [...] }` for configured `dataGroup` columns.
|
|
149
149
|
- Image columns require `imageFetcher`.
|
|
150
150
|
|
|
151
|
+
## Image fetcher with URL validation
|
|
152
|
+
|
|
153
|
+
When using `imageFetcher` for image columns, validate URLs before fetching to avoid requests to untrusted origins. The example below enforces HTTPS and checks the HTTP response status:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
const imageFetcher = async (url: string): Promise<Uint8Array> => {
|
|
157
|
+
const parsed = new URL(url);
|
|
158
|
+
if (parsed.protocol !== 'https:') {
|
|
159
|
+
throw new Error(`Refusing to fetch image from non-HTTPS URL: ${url}`);
|
|
160
|
+
}
|
|
161
|
+
const response = await fetch(url);
|
|
162
|
+
if (!response.ok) {
|
|
163
|
+
throw new Error(`Failed to fetch image: ${response.status} ${response.statusText}`);
|
|
164
|
+
}
|
|
165
|
+
const buffer = await response.arrayBuffer();
|
|
166
|
+
return new Uint8Array(buffer);
|
|
167
|
+
};
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
For server-side contexts, also consider restricting URLs to trusted domains and rejecting private/internal network addresses. See [SECURITY.md](../../SECURITY.md) for the full image fetcher trust model and additional guidance.
|
|
171
|
+
|
|
151
172
|
## Advanced supported features
|
|
152
173
|
|
|
153
174
|
These advanced features are supported and considered part of the public API:
|
|
@@ -176,6 +197,23 @@ These advanced features are supported and considered part of the public API:
|
|
|
176
197
|
|
|
177
198
|
These examples are covered by Playwright tests in [`./tests/import-export.spec.ts`](./tests/import-export.spec.ts).
|
|
178
199
|
|
|
200
|
+
## Test utilities
|
|
201
|
+
|
|
202
|
+
The package exposes a `testUtils` namespace for use in consumer test suites:
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
import { testUtils } from '@senlinz/import-export';
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
> **Warning:** `testUtils` is intended for testing purposes only. These helpers are internal implementation details and carry **no stability guarantee** — they may change or be removed in any release without notice.
|
|
209
|
+
|
|
210
|
+
| Helper | Description |
|
|
211
|
+
|---|---|
|
|
212
|
+
| `normalizeDefinition(definition)` | Normalizes and validates an `ExcelDefinition`, trimming strings and applying defaults. |
|
|
213
|
+
| `normalizeDynamicImportOptions(options?)` | Normalizes and validates dynamic import options (e.g. `headerRow`, `maxFileSizeBytes`). |
|
|
214
|
+
| `sanitizeTextCellValue(value, escapeFormulas?)` | Sanitizes a text cell value to prevent formula injection. Prefixes formula-like values with a single quote when `escapeFormulas` is `true` (the default). |
|
|
215
|
+
| `defaultMaxFileSizeBytes` | The default maximum file size in bytes (25 MB). |
|
|
216
|
+
|
|
179
217
|
## Known limitations
|
|
180
218
|
|
|
181
219
|
- Parent headers and data groups must be declared before dependent columns.
|
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class e{static __wrap(t){const _=Object.create(e.prototype);return _.__wbg_ptr=t,c.register(_,_.__wbg_ptr,_),_}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,c.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_dynamicexceldata_free(e,0)}constructor(e,t,_){const n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=R(t,O.__wbindgen_malloc),i=j,a=R(_,O.__wbindgen_malloc),l=j,s=O.dynamicexceldata_new(n,r,o,i,a,l);return this.__wbg_ptr=s,c.register(this,this.__wbg_ptr,this),this}get headers(){const e=O.__wbg_get_dynamicexceldata_headers(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get rows(){const e=O.__wbg_get_dynamicexceldata_rows(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get sheet_name(){let e,t;try{const _=O.__wbg_get_dynamicexceldata_sheet_name(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}set headers(e){const t=R(e,O.__wbindgen_malloc),_=j;O.__wbg_set_dynamicexceldata_headers(this.__wbg_ptr,t,_)}set rows(e){const t=R(e,O.__wbindgen_malloc),_=j;O.__wbg_set_dynamicexceldata_rows(this.__wbg_ptr,t,_)}set sheet_name(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_dynamicexceldata_sheet_name(this.__wbg_ptr,t,_)}}Symbol.dispose&&(e.prototype[Symbol.dispose]=e.prototype.free);class t{static __wrap(e){const _=Object.create(t.prototype);return _.__wbg_ptr=e,s.register(_,_.__wbg_ptr,_),_}static __unwrap(e){return e instanceof t?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,s.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_excelcellformat_free(e,0)}constructor(){const e=O.excelcellformat_new();return this.__wbg_ptr=e,s.register(this,this.__wbg_ptr,this),this}withAlign(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcellformat_withAlign(_,n,r);return t.__wrap(o)}withAlignVertical(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcellformat_withAlignVertical(_,n,r);return t.__wrap(o)}withBackgroundColor(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcellformat_withBackgroundColor(_,n,r);return t.__wrap(o)}withBold(e){const _=this.__destroy_into_raw(),n=O.excelcellformat_withBold(_,e);return t.__wrap(n)}withBorderColor(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcellformat_withBorderColor(_,n,r);return t.__wrap(o)}withColor(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcellformat_withColor(_,n,r);return t.__wrap(o)}withDateFormat(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcellformat_withDateFormat(_,n,r);return t.__wrap(o)}withFontSize(e){const _=this.__destroy_into_raw(),n=O.excelcellformat_withFontSize(_,e);return t.__wrap(n)}withItalic(e){const _=this.__destroy_into_raw(),n=O.excelcellformat_withItalic(_,e);return t.__wrap(n)}withRule(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcellformat_withRule(_,n,r);return t.__wrap(o)}withStrikethrough(e){const _=this.__destroy_into_raw(),n=O.excelcellformat_withStrikethrough(_,e);return t.__wrap(n)}withUnderline(e){const _=this.__destroy_into_raw(),n=O.excelcellformat_withUnderline(_,e);return t.__wrap(n)}withValue(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcellformat_withValue(_,n,r);return t.__wrap(o)}get align_vertical(){let e,t;try{const _=O.__wbg_get_excelcellformat_align_vertical(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get align(){let e,t;try{const _=O.__wbg_get_excelcellformat_align(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get background_color(){let e,t;try{const _=O.__wbg_get_excelcellformat_background_color(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get bold(){return 0!==O.__wbg_get_excelcellformat_bold(this.__wbg_ptr)}get border_color(){const e=O.__wbg_get_excelcellformat_border_color(this.__wbg_ptr);let t;return 0!==e[0]&&(t=E(e[0],e[1]).slice(),O.__wbindgen_free(e[0],1*e[1],1)),t}get color(){let e,t;try{const _=O.__wbg_get_excelcellformat_color(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get date_format(){const e=O.__wbg_get_excelcellformat_date_format(this.__wbg_ptr);let t;return 0!==e[0]&&(t=E(e[0],e[1]).slice(),O.__wbindgen_free(e[0],1*e[1],1)),t}get font_size(){return O.__wbg_get_excelcellformat_font_size(this.__wbg_ptr)}get italic(){return 0!==O.__wbg_get_excelcellformat_italic(this.__wbg_ptr)}get rule(){let e,t;try{const _=O.__wbg_get_excelcellformat_rule(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get strikethrough(){return 0!==O.__wbg_get_excelcellformat_strikethrough(this.__wbg_ptr)}get underline(){return 0!==O.__wbg_get_excelcellformat_underline(this.__wbg_ptr)}get value(){let e,t;try{const _=O.__wbg_get_excelcellformat_value(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}set align_vertical(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcellformat_align_vertical(this.__wbg_ptr,t,_)}set align(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcellformat_align(this.__wbg_ptr,t,_)}set background_color(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcellformat_background_color(this.__wbg_ptr,t,_)}set bold(e){O.__wbg_set_excelcellformat_bold(this.__wbg_ptr,e)}set border_color(e){var t=k(e)?0:A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcellformat_border_color(this.__wbg_ptr,t,_)}set color(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcellformat_color(this.__wbg_ptr,t,_)}set date_format(e){var t=k(e)?0:A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcellformat_date_format(this.__wbg_ptr,t,_)}set font_size(e){O.__wbg_set_excelcellformat_font_size(this.__wbg_ptr,e)}set italic(e){O.__wbg_set_excelcellformat_italic(this.__wbg_ptr,e)}set rule(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcellformat_rule(this.__wbg_ptr,t,_)}set strikethrough(e){O.__wbg_set_excelcellformat_strikethrough(this.__wbg_ptr,e)}set underline(e){O.__wbg_set_excelcellformat_underline(this.__wbg_ptr,e)}set value(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcellformat_value(this.__wbg_ptr,t,_)}}Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);class _{static __wrap(e){const t=Object.create(_.prototype);return t.__wbg_ptr=e,w.register(t,t.__wbg_ptr,t),t}static __unwrap(e){return e instanceof _?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,w.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_excelcolumndata_free(e,0)}constructor(e,t){const _=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),n=j,r=A(t,O.__wbindgen_malloc,O.__wbindgen_realloc),o=j,i=O.excelcolumndata_bind_new(_,n,r,o);return this.__wbg_ptr=i,w.register(this,this.__wbg_ptr,this),this}static newGroup(e,t,n){const r=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),o=j,i=A(t,O.__wbindgen_malloc,O.__wbindgen_realloc),a=j,l=R(n,O.__wbindgen_malloc),c=j,s=O.excelcolumndata_newGroup(r,o,i,a,l,c);return _.__wrap(s)}static newRootGroup(e,t){const n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=R(t,O.__wbindgen_malloc),i=j,a=O.excelcolumndata_newRootGroup(n,r,o,i);return _.__wrap(a)}withChildren(e){const t=this.__destroy_into_raw(),n=R(e,O.__wbindgen_malloc),r=j,o=O.excelcolumndata_withChildren(t,n,r);return _.__wrap(o)}get children(){const e=O.__wbg_get_excelcolumndata_children(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get key(){let e,t;try{const _=O.__wbg_get_excelcolumndata_key(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get value(){let e,t;try{const _=O.__wbg_get_excelcolumndata_value(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}set children(e){const t=R(e,O.__wbindgen_malloc),_=j;O.__wbg_set_excelcolumndata_children(this.__wbg_ptr,t,_)}set key(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcolumndata_key(this.__wbg_ptr,t,_)}set value(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcolumndata_value(this.__wbg_ptr,t,_)}}Symbol.dispose&&(_.prototype[Symbol.dispose]=_.prototype.free);class n{static __wrap(e){const t=Object.create(n.prototype);return t.__wbg_ptr=e,g.register(t,t.__wbg_ptr,t),t}static __unwrap(e){return e instanceof n?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,g.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_excelcolumninfo_free(e,0)}constructor(e,t){const _=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),n=j,r=A(t,O.__wbindgen_malloc,O.__wbindgen_realloc),o=j,i=O.excelcolumninfo_bind_new(_,n,r,o);return this.__wbg_ptr=i,g.register(this,this.__wbg_ptr,this),this}withAllowedValues(e){const t=this.__destroy_into_raw(),_=R(e,O.__wbindgen_malloc),r=j,o=O.excelcolumninfo_withAllowedValues(t,_,r);return n.__wrap(o)}withDataGroup(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcolumninfo_withDataGroup(t,_,r);return n.__wrap(o)}withDataGroupParent(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcolumninfo_withDataGroupParent(t,_,r);return n.__wrap(o)}withDataType(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcolumninfo_withDataType(t,_,r);return n.__wrap(o)}withFormat(e){const _=this.__destroy_into_raw();h(e,t);var r=e.__destroy_into_raw();const o=O.excelcolumninfo_withFormat(_,r);return n.__wrap(o)}withNote(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcolumninfo_withNote(t,_,r);return n.__wrap(o)}withParent(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j,o=O.excelcolumninfo_withParent(t,_,r);return n.__wrap(o)}withValueFormat(e){const t=this.__destroy_into_raw(),_=R(e,O.__wbindgen_malloc),r=j,o=O.excelcolumninfo_withValueFormat(t,_,r);return n.__wrap(o)}withWidth(e){const t=this.__destroy_into_raw(),_=O.excelcolumninfo_withWidth(t,e);return n.__wrap(_)}get allowed_values(){const e=O.__wbg_get_excelcolumninfo_allowed_values(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get data_group_parent(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_data_group_parent(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get data_group(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_data_group(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get data_type(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_data_type(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get format(){const e=O.__wbg_get_excelcolumninfo_format(this.__wbg_ptr);return 0===e?void 0:t.__wrap(e)}get key(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_key(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get name(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_name(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get note(){const e=O.__wbg_get_excelcolumninfo_note(this.__wbg_ptr);let t;return 0!==e[0]&&(t=E(e[0],e[1]).slice(),O.__wbindgen_free(e[0],1*e[1],1)),t}get parent(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_parent(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get value_format(){const e=O.__wbg_get_excelcolumninfo_value_format(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get width(){return O.__wbg_get_excelcolumninfo_width(this.__wbg_ptr)}set allowed_values(e){const t=R(e,O.__wbindgen_malloc),_=j;O.__wbg_set_excelcolumninfo_allowed_values(this.__wbg_ptr,t,_)}set data_group_parent(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcolumninfo_data_group_parent(this.__wbg_ptr,t,_)}set data_group(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcolumninfo_data_group(this.__wbg_ptr,t,_)}set data_type(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcolumninfo_data_type(this.__wbg_ptr,t,_)}set format(e){let _=0;k(e)||(h(e,t),_=e.__destroy_into_raw()),O.__wbg_set_excelcolumninfo_format(this.__wbg_ptr,_)}set key(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcolumninfo_key(this.__wbg_ptr,t,_)}set name(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcolumninfo_name(this.__wbg_ptr,t,_)}set note(e){var t=k(e)?0:A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcolumninfo_note(this.__wbg_ptr,t,_)}set parent(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelcolumninfo_parent(this.__wbg_ptr,t,_)}set value_format(e){const t=R(e,O.__wbindgen_malloc),_=j;O.__wbg_set_excelcolumninfo_value_format(this.__wbg_ptr,t,_)}set width(e){O.__wbg_set_excelcolumninfo_width(this.__wbg_ptr,e)}}Symbol.dispose&&(n.prototype[Symbol.dispose]=n.prototype.free);class r{static __wrap(e){const t=Object.create(r.prototype);return t.__wbg_ptr=e,u.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,u.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_exceldata_free(e,0)}constructor(e){const t=R(e,O.__wbindgen_malloc),_=j,n=O.exceldata_new(t,_);return this.__wbg_ptr=n,u.register(this,this.__wbg_ptr,this),this}get rows(){const e=O.__wbg_get_exceldata_rows(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}set rows(e){const t=R(e,O.__wbindgen_malloc),_=j;O.__wbg_set_exceldata_rows(this.__wbg_ptr,t,_)}}Symbol.dispose&&(r.prototype[Symbol.dispose]=r.prototype.free);class o{static __wrap(e){const t=Object.create(o.prototype);return t.__wbg_ptr=e,d.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,d.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_excelinfo_free(e,0)}constructor(e,t,_,n,r){const o=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),i=j,a=A(t,O.__wbindgen_malloc,O.__wbindgen_realloc),l=j,c=R(_,O.__wbindgen_malloc),s=j,w=A(n,O.__wbindgen_malloc,O.__wbindgen_realloc),g=j,u=A(r,O.__wbindgen_malloc,O.__wbindgen_realloc),b=j,f=O.excelinfo_bind_new(o,i,a,l,c,s,w,g,u,b);if(f[2])throw C(f[1]);return this.__wbg_ptr=f[0],d.register(this,this.__wbg_ptr,this),this}withDefaultRowHeight(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withDefaultRowHeight(t,e);return o.__wrap(_)}withHeaderRowHeight(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withHeaderRowHeight(t,e);return o.__wrap(_)}withImageFetcher(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withImageFetcher(t,e);return o.__wrap(_)}withIsHeaderFreeze(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withIsHeaderFreeze(t,e);return o.__wrap(_)}withOffset(e,t){const _=this.__destroy_into_raw(),n=O.excelinfo_withOffset(_,e,t);return o.__wrap(n)}withProgressCallback(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withProgressCallback(t,e);return o.__wrap(_)}withTitle(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),n=j,r=O.excelinfo_withTitle(t,_,n);return o.__wrap(r)}withTitleFormat(e){const _=this.__destroy_into_raw();h(e,t);var n=e.__destroy_into_raw();const r=O.excelinfo_withTitleFormat(_,n);return o.__wrap(r)}withTitleHeight(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withTitleHeight(t,e);return o.__wrap(_)}get author(){let e,t;try{const _=O.__wbg_get_excelinfo_author(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get columns(){const e=O.__wbg_get_excelinfo_columns(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get create_time(){let e,t;try{const _=O.__wbg_get_excelinfo_create_time(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get default_row_height(){const e=O.__wbg_get_excelinfo_default_row_height(this.__wbg_ptr);return 0===e[0]?void 0:e[1]}get dx(){return O.__wbg_get_excelinfo_dx(this.__wbg_ptr)}get dy(){return O.__wbg_get_excelinfo_dy(this.__wbg_ptr)>>>0}get header_row_height(){const e=O.__wbg_get_excelinfo_header_row_height(this.__wbg_ptr);return 0===e[0]?void 0:e[1]}get is_header_freeze(){return 0!==O.__wbg_get_excelinfo_is_header_freeze(this.__wbg_ptr)}get name(){let e,t;try{const _=O.__wbg_get_excelinfo_name(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get sheet_name(){let e,t;try{const _=O.__wbg_get_excelinfo_sheet_name(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get title_format(){const e=O.__wbg_get_excelinfo_title_format(this.__wbg_ptr);return 0===e?void 0:t.__wrap(e)}get title_height(){const e=O.__wbg_get_excelinfo_title_height(this.__wbg_ptr);return 0===e[0]?void 0:e[1]}get title(){const e=O.__wbg_get_excelinfo_title(this.__wbg_ptr);let t;return 0!==e[0]&&(t=E(e[0],e[1]).slice(),O.__wbindgen_free(e[0],1*e[1],1)),t}set author(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelinfo_author(this.__wbg_ptr,t,_)}set columns(e){const t=R(e,O.__wbindgen_malloc),_=j;O.__wbg_set_excelinfo_columns(this.__wbg_ptr,t,_)}set create_time(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelinfo_create_time(this.__wbg_ptr,t,_)}set default_row_height(e){O.__wbg_set_excelinfo_default_row_height(this.__wbg_ptr,!k(e),k(e)?0:e)}set dx(e){O.__wbg_set_excelinfo_dx(this.__wbg_ptr,e)}set dy(e){O.__wbg_set_excelinfo_dy(this.__wbg_ptr,e)}set header_row_height(e){O.__wbg_set_excelinfo_header_row_height(this.__wbg_ptr,!k(e),k(e)?0:e)}set is_header_freeze(e){O.__wbg_set_excelinfo_is_header_freeze(this.__wbg_ptr,e)}set name(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelinfo_name(this.__wbg_ptr,t,_)}set sheet_name(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelinfo_sheet_name(this.__wbg_ptr,t,_)}set title_format(e){let _=0;k(e)||(h(e,t),_=e.__destroy_into_raw()),O.__wbg_set_excelinfo_title_format(this.__wbg_ptr,_)}set title_height(e){O.__wbg_set_excelinfo_title_height(this.__wbg_ptr,!k(e),k(e)?0:e)}set title(e){var t=k(e)?0:A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=j;O.__wbg_set_excelinfo_title(this.__wbg_ptr,t,_)}}Symbol.dispose&&(o.prototype[Symbol.dispose]=o.prototype.free);class i{static __wrap(e){const t=Object.create(i.prototype);return t.__wbg_ptr=e,b.register(t,t.__wbg_ptr,t),t}static __unwrap(e){return e instanceof i?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,b.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_excelrowdata_free(e,0)}constructor(e){const t=R(e,O.__wbindgen_malloc),_=j,n=O.excelrowdata_new(t,_);return this.__wbg_ptr=n,b.register(this,this.__wbg_ptr,this),this}get columns(){const e=O.__wbg_get_excelrowdata_columns(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}set columns(e){const t=R(e,O.__wbindgen_malloc),_=j;O.__wbg_set_excelrowdata_columns(this.__wbg_ptr,t,_)}}function a(){const e={__proto__:null,__wbg_Error_3639a60ed15f87e7:function(e,t){return Error(E(e,t))},__wbg___wbindgen_debug_string_07cb72cfcc952e2b:function(e,t){const _=A(p(t),O.__wbindgen_malloc,O.__wbindgen_realloc),n=j;F().setInt32(e+4,n,!0),F().setInt32(e+0,_,!0)},__wbg___wbindgen_is_function_2f0fd7ceb86e64c5:function(e){return"function"==typeof e},__wbg___wbindgen_is_object_5b22ff2418063a9c:function(e){return"object"==typeof e&&null!==e},__wbg___wbindgen_is_undefined_244a92c34d3b6ec0:function(e){return void 0===e},__wbg___wbindgen_string_get_965592073e5d848c:function(e,t){const _="string"==typeof t?t:void 0;var n=k(_)?0:A(_,O.__wbindgen_malloc,O.__wbindgen_realloc),r=j;F().setInt32(e+4,r,!0),F().setInt32(e+0,n,!0)},__wbg___wbindgen_throw_9c75d47bf9e7731e:function(e,t){throw new Error(E(e,t))},__wbg__wbg_cb_unref_158e43e869788cdc:function(e){e._wbg_cb_unref()},__wbg_call_a41d6421b30a32c5:function(){return function(e,t){try{return e.apply(this,t)}catch(e){const t=f(e);O.__wbindgen_exn_store(t)}}((function(e,t,_){return e.call(t,_)}),arguments)},__wbg_excelcellformat_new:function(e){return t.__wrap(e)},__wbg_excelcellformat_unwrap:function(e){return t.__unwrap(e)},__wbg_excelcolumndata_new:function(e){return _.__wrap(e)},__wbg_excelcolumndata_unwrap:function(e){return _.__unwrap(e)},__wbg_excelcolumninfo_new:function(e){return n.__wrap(e)},__wbg_excelcolumninfo_unwrap:function(e){return n.__unwrap(e)},__wbg_excelrowdata_new:function(e){return i.__wrap(e)},__wbg_excelrowdata_unwrap:function(e){return i.__unwrap(e)},__wbg_length_ba3c032602efe310:function(e){return e.length},__wbg_new_8454eee672b2ba6e:function(e){return new Uint8Array(e)},__wbg_new_from_slice_5a173c243af2e823:function(e,t){return new Uint8Array(x(e,t))},__wbg_new_typed_1137602701dc87d4:function(e,t){try{var _={a:e,b:t};const n=new Promise(((e,t)=>{const n=_.a;_.a=0;try{return function(e,t,_,n){O.wasm_bindgen__convert__closures_____invoke__h9810a10231a362ef(e,t,_,n)}(n,_.b,e,t)}finally{_.a=n}}));return n}finally{_.a=0}},__wbg_now_4f457f10f864aec5:function(){return Date.now()},__wbg_prototypesetcall_fd4050e806e1d519:function(e,t,_){Uint8Array.prototype.set.call(x(e,t),_)},__wbg_queueMicrotask_40ac6ffc2848ba77:function(e){queueMicrotask(e)},__wbg_queueMicrotask_74d092439f6494c1:function(e){return e.queueMicrotask},__wbg_resolve_9feb5d906ca62419:function(e){return Promise.resolve(e)},__wbg_static_accessor_GLOBAL_THIS_1c7f1bd6c6941fdb:function(){const e="undefined"==typeof globalThis?null:globalThis;return k(e)?0:f(e)},__wbg_static_accessor_GLOBAL_e039bc914f83e74e:function(){const e="undefined"==typeof global?null:global;return k(e)?0:f(e)},__wbg_static_accessor_SELF_8bf8c48c28420ad5:function(){const e="undefined"==typeof self?null:self;return k(e)?0:f(e)},__wbg_static_accessor_WINDOW_6aeee9b51652ee0f:function(){const e="undefined"==typeof window?null:window;return k(e)?0:f(e)},__wbg_then_20a157d939b514f5:function(e,t){return e.then(t)},__wbg_then_5ef9b762bc91555c:function(e,t,_){return e.then(t,_)},__wbindgen_cast_0000000000000001:function(e,t){const _=function(e,t,_){const n={a:e,b:t,cnt:1},r=(...e)=>{n.cnt++;const t=n.a;n.a=0;try{return _(t,n.b,...e)}finally{n.a=t,r._wbg_cb_unref()}};return r._wbg_cb_unref=()=>{0==--n.cnt&&(O.__wbindgen_destroy_closure(n.a,n.b),n.a=0,m.unregister(n))},m.register(r,n,n),r}(e,t,l);return _},__wbindgen_cast_0000000000000002:function(e){return e},__wbindgen_cast_0000000000000003:function(e,t){return E(e,t)},__wbindgen_init_externref_table:function(){const e=O.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}};return{__proto__:null,"./imexport_wasm_bg.js":e}}function l(e,t,_){const n=O.wasm_bindgen__convert__closures_____invoke__hdaf915f93ddc966d(e,t,_);if(n[1])throw C(n[0])}Symbol.dispose&&(i.prototype[Symbol.dispose]=i.prototype.free);const c="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_dynamicexceldata_free(e,1))),s="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_excelcellformat_free(e,1))),w="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_excelcolumndata_free(e,1))),g="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_excelcolumninfo_free(e,1))),u="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_exceldata_free(e,1))),d="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_excelinfo_free(e,1))),b="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_excelrowdata_free(e,1)));function f(e){const t=O.__externref_table_alloc();return O.__wbindgen_externrefs.set(t,e),t}function h(e,t){if(!(e instanceof t))throw new Error(`expected instance of ${t.name}`)}const m="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbindgen_destroy_closure(e.a,e.b)));function p(e){const t=typeof e;if("number"==t||"boolean"==t||null==e)return`${e}`;if("string"==t)return`"${e}"`;if("symbol"==t){const t=e.description;return null==t?"Symbol":`Symbol(${t})`}if("function"==t){const t=e.name;return"string"==typeof t&&t.length>0?`Function(${t})`:"Function"}if(Array.isArray(e)){const t=e.length;let _="[";t>0&&(_+=p(e[0]));for(let n=1;n<t;n++)_+=", "+p(e[n]);return _+="]",_}const _=/\[object ([^\]]+)\]/.exec(toString.call(e));let n;if(!(_&&_.length>1))return toString.call(e);if(n=_[1],"Object"==n)try{return"Object("+JSON.stringify(e)+")"}catch(e){return"Object"}return e instanceof Error?`${e.name}: ${e.message}\n${e.stack}`:n}function y(e,t){e>>>=0;const _=F(),n=[];for(let r=e;r<e+4*t;r+=4)n.push(O.__wbindgen_externrefs.get(_.getUint32(r,!0)));return O.__externref_drop_slice(e,t),n}function x(e,t){return e>>>=0,$().subarray(e/1,e/1+t)}let v=null;function F(){return(null===v||!0===v.buffer.detached||void 0===v.buffer.detached&&v.buffer!==O.memory.buffer)&&(v=new DataView(O.memory.buffer)),v}function E(e,t){return function(e,t){G+=t,G>=T&&(D=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),D.decode(),G=t);return D.decode($().subarray(e,e+t))}(e>>>0,t)}let S=null;function $(){return null!==S&&0!==S.byteLength||(S=new Uint8Array(O.memory.buffer)),S}function k(e){return null==e}function z(e,t){const _=t(1*e.length,1)>>>0;return $().set(e,_/1),j=e.length,_}function R(e,t){const _=t(4*e.length,4)>>>0;for(let t=0;t<e.length;t++){const n=f(e[t]);F().setUint32(_+4*t,n,!0)}return j=e.length,_}function A(e,t,_){if(void 0===_){const _=I.encode(e),n=t(_.length,1)>>>0;return $().subarray(n,n+_.length).set(_),j=_.length,n}let n=e.length,r=t(n,1)>>>0;const o=$();let i=0;for(;i<n;i++){const t=e.charCodeAt(i);if(t>127)break;o[r+i]=t}if(i!==n){0!==i&&(e=e.slice(i)),r=_(r,n,n=i+3*e.length,1)>>>0;const t=$().subarray(r+i,r+n);i+=I.encodeInto(e,t).written,r=_(r,n,i,1)>>>0}return j=i,r}function C(e){const t=O.__wbindgen_externrefs.get(e);return O.__externref_table_dealloc(e),t}let D=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});D.decode();const T=2146435072;let G=0;const I=new TextEncoder;"encodeInto"in I||(I.encodeInto=function(e,t){const _=I.encode(e);return t.set(_),{read:e.length,written:_.length}});let O,j=0;function B(e){if(void 0!==O)return O;void 0!==e&&(Object.getPrototypeOf(e)===Object.prototype?({module:e}=e):console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const t=a();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));return function(e){return O=e.exports,v=null,S=null,O.__wbindgen_start(),O}(new WebAssembly.Instance(e,t))}const H=["text","number","date","image"],P=26214400,N=new Set(["=","+","-","@","\t","\r","\n"]),L="senlinzImportExportDownload";let M=null,V=!1;function U(e,t){const _=null!=e?e:"text";if("string"!=typeof _)throw new Error(`Invalid dataType '${String(_)}' for column '${t}'. dataType values must be strings.`);const n=_.trim().toLowerCase();if(!H.includes(n))throw new Error(`Invalid dataType '${e}' for column '${t}'. Supported values are: ${H.join(", ")}.`);return n}function W(e,t){if(void 0===e)return P;if("number"!=typeof e||!Number.isFinite(e))throw new Error(`Invalid maxFileSizeBytes '${String(e)}' for ${t}. Expected a positive finite number in bytes.`);const _=Math.trunc(e);if(_<=0)throw new Error(`Invalid maxFileSizeBytes '${e}' for ${t}. Expected a positive finite number in bytes.`);return _}function q(e,t){if(!t||""===e)return e;const _=e[0];return N.has(_)?`'${e}`:e}function J(e){const t=e/1048576;return`${t%1==0?t.toFixed(0):t.toFixed(1)} MB`}function X(e){var t,_;if(!(null===(t=e.name)||void 0===t?void 0:t.trim()))throw new Error("Excel definition must include a non-empty name.");if(!Array.isArray(e.columns)||0===e.columns.length)throw new Error(`Excel definition '${e.name}' must include at least one column.`);const n=new Set,r=new Set,o=e.name.trim(),i=W(e.maxFileSizeBytes,`definition '${o}'`),a=function(e,t){if(void 0===e)return!0;if("boolean"!=typeof e)throw new Error(`Invalid escapeFormulas '${String(e)}' for ${t}. Expected a boolean.`);return e}(e.escapeFormulas,`definition '${o}'`),l=e.columns.map((t=>{var _,o;const i=null===(_=t.key)||void 0===_?void 0:_.trim(),a=null===(o=t.name)||void 0===o?void 0:o.trim();if(!i)throw new Error(`Excel definition '${e.name}' contains a column with an empty key.`);if(!a)throw new Error(`Column '${i}' in definition '${e.name}' must include a non-empty name.`);if(n.has(i))throw new Error(`Duplicate column key '${i}' found in definition '${e.name}'.`);const l=Object.assign(Object.assign({},t),{key:i,name:a,dataType:U(t.dataType,i)});if(l.parent){const e=l.parent.trim();if(!e)throw new Error(`Column '${i}' has an empty parent reference.`);if(e===i)throw new Error(`Column '${i}' cannot reference itself as a parent.`);if(!n.has(e))throw new Error(`Column '${i}' references parent '${e}', but parent columns must be declared before their children.`);l.parent=e}if(l.dataGroup){const t=l.dataGroup.trim();if(!t)throw new Error(`Column '${i}' has an empty dataGroup value.`);if(r.has(t))throw new Error(`Duplicate dataGroup '${t}' found in definition '${e.name}'.`);r.add(t),l.dataGroup=t}if(l.dataGroupParent){const e=l.dataGroupParent.trim();if(!e)throw new Error(`Column '${i}' has an empty dataGroupParent value.`);if(l.dataGroup===e)throw new Error(`Column '${i}' cannot reference its own dataGroup '${e}' as dataGroupParent.`);if(!r.has(e))throw new Error(`Column '${i}' references dataGroupParent '${e}', but grouped parents must be declared before dependent columns.`);l.dataGroupParent=e}return n.add(i),l}));return Object.assign(Object.assign({},e),{name:o,sheetName:(null===(_=e.sheetName)||void 0===_?void 0:_.trim())||void 0,columns:l,maxFileSizeBytes:i,escapeFormulas:a})}const Y={normalizeDefinition:X,normalizeDynamicImportOptions:ee,sanitizeTextCellValue:(e,t=!0)=>q(e,t),defaultMaxFileSizeBytes:P};function K(e,t){if(""===t)return"number"===e.dataType||"date"===e.dataType?null:t;if("number"===e.dataType){const _=Number(t);if(!Number.isFinite(_))throw new Error(`Failed to parse imported number '${t}' for column '${e.key}'.`);return _}return t}function Q(e,t,_){if(null==t)return"";const n=e.data_type.toLowerCase();if("number"===n){const _="number"==typeof t?t:Number(t);if(!Number.isFinite(_))throw new Error(`Column '${e.key}' expects a finite number value.`);return _.toString()}if("date"===n){if(t instanceof Date)return ge(t);if("string"==typeof t){const e=t.trim();return e||""}throw new Error(`Column '${e.key}' expects a date string or Date instance.`)}return"text"===n?q(t.toString(),_):t.toString()}function Z(e){return e.rows.map((e=>{const t={};for(const _ of e.columns)t[_.key]=_.value;return t}))}function ee(e={}){var t;if(void 0!==e.headerRow&&(!Number.isInteger(e.headerRow)||e.headerRow<1))throw new Error("Dynamic import option 'headerRow' must be an integer greater than or equal to 1.");return{sheetName:(null===(t=e.sheetName)||void 0===t?void 0:t.trim())||void 0,headerRow:e.headerRow,maxFileSizeBytes:W(e.maxFileSizeBytes,"dynamic import options")}}async function te(e,t){const _=function(e,t){h(e,o);var _=e.__destroy_into_raw();const n=z(t,O.__wbindgen_malloc),i=j,a=O.importData(_,n,i);if(a[2])throw C(a[1]);return r.__wrap(a[0])}(we(e),t),n=function(e,t){const _=[],n={};for(const e of t)n[e.key]=e;for(const t of e.rows){const e={};for(const _ of t.columns){const t=n[_.key];t&&(e[_.key]=K(t,_.value))}_.push(e)}return _}(_,e.columns);return n}async function _e(t,_){const n=function(t,_,n){var r=k(t)?0:A(t,O.__wbindgen_malloc,O.__wbindgen_realloc),o=j;const i=z(n,O.__wbindgen_malloc),a=j,l=O.importDynamicData(r,o,k(_)?Number.MAX_SAFE_INTEGER:_>>>0,i,a);if(l[2])throw C(l[1]);return e.__wrap(l[0])}(_.sheetName,_.headerRow,t);return{sheetName:n.sheet_name,headers:[...n.headers],rows:Z(n)}}function ne(e,t=26214400){return new Promise(((_,n)=>{var r;null===(r=document.querySelector("#senlinzImportExportInput"))||void 0===r||r.remove();const o=document.createElement("input");o.id="senlinzImportExportInput",o.style.display="none",o.type="file",o.accept=".xlsx,.xls,.xlsm,.xlsb,.xla,.xlam,.ods",document.body.appendChild(o);let i=!1;const a=()=>{o.removeEventListener("change",w),o.removeEventListener("cancel",s),o.remove()},l=e=>{i||(i=!0,a(),n(e instanceof Error?e:new Error(String(e))))},c=e=>{i||(i=!0,a(),_(e))},s=()=>{l(new Error("File selection cancelled."))};function w(_){const n=_.target;if(!n||!n.files||0===n.files.length)return void l(new Error("File selection cancelled."));const r=n.files[0];try{!function(e,t){if(e.size>t)throw new Error(`Selected file '${e.name}' exceeds the ${J(t)} limit (received ${J(e.size)}).`)}(r,t)}catch(e){return void l(e)}const o=new FileReader;o.onerror=()=>{var e;l(null!==(e=o.error)&&void 0!==e?e:new Error("Failed to read import file."))},o.onabort=()=>{l(new Error("Import file read was aborted."))},o.onload=async()=>{try{const t=new Uint8Array(o.result),_=await e(t);c(_)}catch(e){l(e)}},o.readAsArrayBuffer(r)}o.addEventListener("change",w),o.addEventListener("cancel",s),o.click()}))}function re(e,t,n,r=""){const o=[];for(const l of e){const e=[];for(const o in l){const i=t[o],c=l[o];if(i&&void 0!==c)if(i.data_group){if(null!==c){if("object"!=typeof(a=c)||null===a||!Array.isArray(a.children))throw new Error(`Grouped column '${o}' must be an object with a children array.`);if(c.children.length){const a=re(c.children,t,n,o);r?e.push(_.newGroup(o,Q(i,c.value,n),a)):e.push(_.newRootGroup(o,a))}}}else e.push(new _(o,Q(i,c,n)))}o.push(new i(e))}var a;return o}async function oe(e,t){const _=we(e),n=function(e){const t={};for(const _ of e.columns)t[_.key]=_;return t}(_),i=re(t,n,e.escapeFormulas);return function(e,t){h(e,o);var _=e.__destroy_into_raw();h(t,r);var n=t.__destroy_into_raw();return O.exportData(_,n)}(_,new r(i))}async function ie(e,t){return oe(X(e),t)}async function ae(e){return function(e){h(e,o);var t=e.__destroy_into_raw();const _=O.createTemplate(t);if(_[3])throw C(_[2]);var n=x(_[0],_[1]).slice();return O.__wbindgen_free(_[0],1*_[1],1),n}(we(X(e)))}function le(e,t,_="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"){var n;ce(),null===(n=document.querySelector(`#${L}`))||void 0===n||n.remove();const r=document.createElement("a");r.id=L,r.download=t;const o=new Blob([e],{type:_}),i=URL.createObjectURL(o);r.href=i,function(){if(V||"undefined"==typeof window)return;const e=()=>ce();window.addEventListener("focus",e),window.addEventListener("pagehide",e),document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&e()})),V=!0}(),M=i,r.click()}function ce(){M&&(URL.revokeObjectURL(M),M=null)}function se(e){let _=new t;return e.rule&&(_=_.withRule(e.rule)),e.value&&(_=_.withValue(e.value)),e.color&&(_=_.withColor(e.color)),e.bold&&(_=_.withBold(e.bold)),e.italic&&(_=_.withItalic(e.italic)),e.underline&&(_=_.withUnderline(e.underline)),e.strikethrough&&(_=_.withStrikethrough(e.strikethrough)),e.fontSize&&(_=_.withFontSize(e.fontSize)),e.backgroundColor&&(_=_.withBackgroundColor(e.backgroundColor)),e.align&&(_=_.withAlign(e.align)),e.alignVertical&&(_=_.withAlignVertical(e.alignVertical)),e.borderColor&&(_=_.withBorderColor(e.borderColor)),e.dateFormat&&(_=_.withDateFormat(e.dateFormat)),_}function we(e){var t,_,r,i,a;const l=e.columns.map((e=>{let t=new n(e.key,e.name);if(e.width&&(t=t.withWidth(e.width)),e.dataType&&(t=t.withDataType(e.dataType)),e.note&&(t=t.withNote(e.note)),e.allowedValues&&(t=t.withAllowedValues(e.allowedValues)),e.parent&&(t=t.withParent(e.parent)),e.format&&(t=t.withFormat(se(e.format))),e.valueFormat){const _=Array.isArray(e.valueFormat)?e.valueFormat:[e.valueFormat];t=t.withValueFormat(_.map(se))}return e.dataGroup&&(t=t.withDataGroup(e.dataGroup)),e.dataGroupParent&&(t=t.withDataGroupParent(e.dataGroupParent)),t}));let c=new o(e.name,null!==(t=e.sheetName)&&void 0!==t?t:"sheet1",l,null!==(_=e.author)&&void 0!==_?_:"",ge(null!==(r=e.createTime)&&void 0!==r?r:new Date));const s=null!==(i=e.dx)&&void 0!==i?i:0,w=null!==(a=e.dy)&&void 0!==a?a:0;return c=c.withOffset(s,w),e.title&&(c=c.withTitle(e.title)),e.titleHeight&&(c=c.withTitleHeight(e.titleHeight)),e.titleFormat&&(c=c.withTitleFormat(se(e.titleFormat))),e.defaultRowHeight&&(c=c.withDefaultRowHeight(e.defaultRowHeight)),e.headerRowHeight&&(c=c.withHeaderRowHeight(e.headerRowHeight)),e.isHeaderFreeze&&(c=c.withIsHeaderFreeze(e.isHeaderFreeze)),e.progressCallback&&(c=c.withProgressCallback(e.progressCallback)),e.imageFetcher&&(c=c.withImageFetcher(e.imageFetcher)),c}function ge(e){if("string"==typeof e)return e;const t=e.getFullYear(),_=e.getMonth()+1,n=e.getDate(),r=e.getHours(),o=e.getMinutes(),i=e.getSeconds(),a=e=>e<10?`0${e}`:e.toString();return`${t}-${a(_)}-${a(n)} ${a(r)}:${a(o)}:${a(i)}`}var ue=new URL("assets/imexport_wasm_bg-lSJMSNpC.wasm",import.meta.url).href;let de=!1,be=null;async function fe(){const e=await function(){if("function"!=typeof fetch)throw new Error("WASM initialization requires a global fetch implementation in this runtime.");return fetch}()(ue);if(!e.ok)throw new Error(`Failed to load the bundled Excel WASM asset from '${ue}'. HTTP ${e.status}.`);return new Uint8Array(await e.arrayBuffer())}async function he(){if(!de)return be||(be=(async()=>{try{B({module:await fe()}),de=!0}catch(e){throw new Error(`Failed to initialize the bundled Excel WASM runtime. ${e instanceof Error?e.message:String(e)}`)}finally{be=null}})()),be}async function me(e){return await he(),function(e){const t=X(e);return ne((e=>te(t,e)),t.maxFileSizeBytes)}(e)}async function pe(e){return await he(),function(e){const t=ee(e);return ne((e=>_e(e,t)),t.maxFileSizeBytes)}(e)}async function ye(e,t){return await he(),async function(e,t){le(await ie(e,t),`${e.name}.xlsx`)}(e,t)}async function xe(e,t){return await he(),async function(e,t){return te(X(e),t)}(e,t)}async function ve(e,t){return await he(),async function(e,t){return _e(e,ee(t))}(e,t)}async function Fe(e,t){return await he(),ie(e,t)}async function Ee(e){return await he(),async function(e){const t=`${e.name}.xlsx`;le(await ae(e),t)}(e)}async function Se(e){return await he(),ae(e)}export{Ee as downloadExcelTemplate,ye as exportExcel,xe as fromExcel,ve as fromExcelDynamic,Se as generateExcelTemplate,me as importExcel,pe as importExcelDynamic,Y as testUtils,Fe as toExcel};
|
|
1
|
+
class e{static __wrap(t){const _=Object.create(e.prototype);return _.__wbg_ptr=t,c.register(_,_.__wbg_ptr,_),_}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,c.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_dynamicexceldata_free(e,0)}constructor(e,t,_){const n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=R(t,O.__wbindgen_malloc),i=B,a=R(_,O.__wbindgen_malloc),l=B,s=O.dynamicexceldata_new(n,r,o,i,a,l);return this.__wbg_ptr=s,c.register(this,this.__wbg_ptr,this),this}get headers(){const e=O.__wbg_get_dynamicexceldata_headers(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get rows(){const e=O.__wbg_get_dynamicexceldata_rows(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get sheet_name(){let e,t;try{const _=O.__wbg_get_dynamicexceldata_sheet_name(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}set headers(e){const t=R(e,O.__wbindgen_malloc),_=B;O.__wbg_set_dynamicexceldata_headers(this.__wbg_ptr,t,_)}set rows(e){const t=R(e,O.__wbindgen_malloc),_=B;O.__wbg_set_dynamicexceldata_rows(this.__wbg_ptr,t,_)}set sheet_name(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_dynamicexceldata_sheet_name(this.__wbg_ptr,t,_)}}Symbol.dispose&&(e.prototype[Symbol.dispose]=e.prototype.free);class t{static __wrap(e){const _=Object.create(t.prototype);return _.__wbg_ptr=e,s.register(_,_.__wbg_ptr,_),_}static __unwrap(e){return e instanceof t?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,s.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_excelcellformat_free(e,0)}constructor(){const e=O.excelcellformat_new();return this.__wbg_ptr=e,s.register(this,this.__wbg_ptr,this),this}withAlign(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcellformat_withAlign(_,n,r);return t.__wrap(o)}withAlignVertical(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcellformat_withAlignVertical(_,n,r);return t.__wrap(o)}withBackgroundColor(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcellformat_withBackgroundColor(_,n,r);return t.__wrap(o)}withBold(e){const _=this.__destroy_into_raw(),n=O.excelcellformat_withBold(_,e);return t.__wrap(n)}withBorderColor(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcellformat_withBorderColor(_,n,r);return t.__wrap(o)}withColor(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcellformat_withColor(_,n,r);return t.__wrap(o)}withDateFormat(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcellformat_withDateFormat(_,n,r);return t.__wrap(o)}withFontSize(e){const _=this.__destroy_into_raw(),n=O.excelcellformat_withFontSize(_,e);return t.__wrap(n)}withItalic(e){const _=this.__destroy_into_raw(),n=O.excelcellformat_withItalic(_,e);return t.__wrap(n)}withRule(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcellformat_withRule(_,n,r);return t.__wrap(o)}withStrikethrough(e){const _=this.__destroy_into_raw(),n=O.excelcellformat_withStrikethrough(_,e);return t.__wrap(n)}withUnderline(e){const _=this.__destroy_into_raw(),n=O.excelcellformat_withUnderline(_,e);return t.__wrap(n)}withValue(e){const _=this.__destroy_into_raw(),n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcellformat_withValue(_,n,r);return t.__wrap(o)}get align_vertical(){let e,t;try{const _=O.__wbg_get_excelcellformat_align_vertical(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get align(){let e,t;try{const _=O.__wbg_get_excelcellformat_align(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get background_color(){let e,t;try{const _=O.__wbg_get_excelcellformat_background_color(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get bold(){return 0!==O.__wbg_get_excelcellformat_bold(this.__wbg_ptr)}get border_color(){const e=O.__wbg_get_excelcellformat_border_color(this.__wbg_ptr);let t;return 0!==e[0]&&(t=E(e[0],e[1]).slice(),O.__wbindgen_free(e[0],1*e[1],1)),t}get color(){let e,t;try{const _=O.__wbg_get_excelcellformat_color(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get date_format(){const e=O.__wbg_get_excelcellformat_date_format(this.__wbg_ptr);let t;return 0!==e[0]&&(t=E(e[0],e[1]).slice(),O.__wbindgen_free(e[0],1*e[1],1)),t}get font_size(){return O.__wbg_get_excelcellformat_font_size(this.__wbg_ptr)}get italic(){return 0!==O.__wbg_get_excelcellformat_italic(this.__wbg_ptr)}get rule(){let e,t;try{const _=O.__wbg_get_excelcellformat_rule(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get strikethrough(){return 0!==O.__wbg_get_excelcellformat_strikethrough(this.__wbg_ptr)}get underline(){return 0!==O.__wbg_get_excelcellformat_underline(this.__wbg_ptr)}get value(){let e,t;try{const _=O.__wbg_get_excelcellformat_value(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}set align_vertical(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcellformat_align_vertical(this.__wbg_ptr,t,_)}set align(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcellformat_align(this.__wbg_ptr,t,_)}set background_color(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcellformat_background_color(this.__wbg_ptr,t,_)}set bold(e){O.__wbg_set_excelcellformat_bold(this.__wbg_ptr,e)}set border_color(e){var t=k(e)?0:A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcellformat_border_color(this.__wbg_ptr,t,_)}set color(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcellformat_color(this.__wbg_ptr,t,_)}set date_format(e){var t=k(e)?0:A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcellformat_date_format(this.__wbg_ptr,t,_)}set font_size(e){O.__wbg_set_excelcellformat_font_size(this.__wbg_ptr,e)}set italic(e){O.__wbg_set_excelcellformat_italic(this.__wbg_ptr,e)}set rule(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcellformat_rule(this.__wbg_ptr,t,_)}set strikethrough(e){O.__wbg_set_excelcellformat_strikethrough(this.__wbg_ptr,e)}set underline(e){O.__wbg_set_excelcellformat_underline(this.__wbg_ptr,e)}set value(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcellformat_value(this.__wbg_ptr,t,_)}}Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);class _{static __wrap(e){const t=Object.create(_.prototype);return t.__wbg_ptr=e,w.register(t,t.__wbg_ptr,t),t}static __unwrap(e){return e instanceof _?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,w.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_excelcolumndata_free(e,0)}constructor(e,t){const _=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),n=B,r=A(t,O.__wbindgen_malloc,O.__wbindgen_realloc),o=B,i=O.excelcolumndata_bind_new(_,n,r,o);return this.__wbg_ptr=i,w.register(this,this.__wbg_ptr,this),this}static newGroup(e,t,n){const r=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),o=B,i=A(t,O.__wbindgen_malloc,O.__wbindgen_realloc),a=B,l=R(n,O.__wbindgen_malloc),c=B,s=O.excelcolumndata_newGroup(r,o,i,a,l,c);return _.__wrap(s)}static newRootGroup(e,t){const n=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=R(t,O.__wbindgen_malloc),i=B,a=O.excelcolumndata_newRootGroup(n,r,o,i);return _.__wrap(a)}withChildren(e){const t=this.__destroy_into_raw(),n=R(e,O.__wbindgen_malloc),r=B,o=O.excelcolumndata_withChildren(t,n,r);return _.__wrap(o)}get children(){const e=O.__wbg_get_excelcolumndata_children(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get key(){let e,t;try{const _=O.__wbg_get_excelcolumndata_key(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get value(){let e,t;try{const _=O.__wbg_get_excelcolumndata_value(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}set children(e){const t=R(e,O.__wbindgen_malloc),_=B;O.__wbg_set_excelcolumndata_children(this.__wbg_ptr,t,_)}set key(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcolumndata_key(this.__wbg_ptr,t,_)}set value(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcolumndata_value(this.__wbg_ptr,t,_)}}Symbol.dispose&&(_.prototype[Symbol.dispose]=_.prototype.free);class n{static __wrap(e){const t=Object.create(n.prototype);return t.__wbg_ptr=e,u.register(t,t.__wbg_ptr,t),t}static __unwrap(e){return e instanceof n?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,u.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_excelcolumninfo_free(e,0)}constructor(e,t){const _=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),n=B,r=A(t,O.__wbindgen_malloc,O.__wbindgen_realloc),o=B,i=O.excelcolumninfo_bind_new(_,n,r,o);return this.__wbg_ptr=i,u.register(this,this.__wbg_ptr,this),this}withAllowedValues(e){const t=this.__destroy_into_raw(),_=R(e,O.__wbindgen_malloc),r=B,o=O.excelcolumninfo_withAllowedValues(t,_,r);return n.__wrap(o)}withDataGroup(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcolumninfo_withDataGroup(t,_,r);return n.__wrap(o)}withDataGroupParent(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcolumninfo_withDataGroupParent(t,_,r);return n.__wrap(o)}withDataType(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcolumninfo_withDataType(t,_,r);return n.__wrap(o)}withFormat(e){const _=this.__destroy_into_raw();h(e,t);var r=e.__destroy_into_raw();const o=O.excelcolumninfo_withFormat(_,r);return n.__wrap(o)}withNote(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcolumninfo_withNote(t,_,r);return n.__wrap(o)}withParent(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B,o=O.excelcolumninfo_withParent(t,_,r);return n.__wrap(o)}withValueFormat(e){const t=this.__destroy_into_raw(),_=R(e,O.__wbindgen_malloc),r=B,o=O.excelcolumninfo_withValueFormat(t,_,r);return n.__wrap(o)}withWidth(e){const t=this.__destroy_into_raw(),_=O.excelcolumninfo_withWidth(t,e);return n.__wrap(_)}get allowed_values(){const e=O.__wbg_get_excelcolumninfo_allowed_values(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get data_group_parent(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_data_group_parent(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get data_group(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_data_group(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get data_type(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_data_type(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get format(){const e=O.__wbg_get_excelcolumninfo_format(this.__wbg_ptr);return 0===e?void 0:t.__wrap(e)}get key(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_key(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get name(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_name(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get note(){const e=O.__wbg_get_excelcolumninfo_note(this.__wbg_ptr);let t;return 0!==e[0]&&(t=E(e[0],e[1]).slice(),O.__wbindgen_free(e[0],1*e[1],1)),t}get parent(){let e,t;try{const _=O.__wbg_get_excelcolumninfo_parent(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get value_format(){const e=O.__wbg_get_excelcolumninfo_value_format(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get width(){return O.__wbg_get_excelcolumninfo_width(this.__wbg_ptr)}set allowed_values(e){const t=R(e,O.__wbindgen_malloc),_=B;O.__wbg_set_excelcolumninfo_allowed_values(this.__wbg_ptr,t,_)}set data_group_parent(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcolumninfo_data_group_parent(this.__wbg_ptr,t,_)}set data_group(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcolumninfo_data_group(this.__wbg_ptr,t,_)}set data_type(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcolumninfo_data_type(this.__wbg_ptr,t,_)}set format(e){let _=0;k(e)||(h(e,t),_=e.__destroy_into_raw()),O.__wbg_set_excelcolumninfo_format(this.__wbg_ptr,_)}set key(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcolumninfo_key(this.__wbg_ptr,t,_)}set name(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcolumninfo_name(this.__wbg_ptr,t,_)}set note(e){var t=k(e)?0:A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcolumninfo_note(this.__wbg_ptr,t,_)}set parent(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelcolumninfo_parent(this.__wbg_ptr,t,_)}set value_format(e){const t=R(e,O.__wbindgen_malloc),_=B;O.__wbg_set_excelcolumninfo_value_format(this.__wbg_ptr,t,_)}set width(e){O.__wbg_set_excelcolumninfo_width(this.__wbg_ptr,e)}}Symbol.dispose&&(n.prototype[Symbol.dispose]=n.prototype.free);class r{static __wrap(e){const t=Object.create(r.prototype);return t.__wbg_ptr=e,g.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,g.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_exceldata_free(e,0)}constructor(e){const t=R(e,O.__wbindgen_malloc),_=B,n=O.exceldata_new(t,_);return this.__wbg_ptr=n,g.register(this,this.__wbg_ptr,this),this}get rows(){const e=O.__wbg_get_exceldata_rows(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}set rows(e){const t=R(e,O.__wbindgen_malloc),_=B;O.__wbg_set_exceldata_rows(this.__wbg_ptr,t,_)}}Symbol.dispose&&(r.prototype[Symbol.dispose]=r.prototype.free);class o{static __wrap(e){const t=Object.create(o.prototype);return t.__wbg_ptr=e,d.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,d.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_excelinfo_free(e,0)}constructor(e,t,_,n,r){const o=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),i=B,a=A(t,O.__wbindgen_malloc,O.__wbindgen_realloc),l=B,c=R(_,O.__wbindgen_malloc),s=B,w=A(n,O.__wbindgen_malloc,O.__wbindgen_realloc),u=B,g=A(r,O.__wbindgen_malloc,O.__wbindgen_realloc),b=B,f=O.excelinfo_bind_new(o,i,a,l,c,s,w,u,g,b);if(f[2])throw T(f[1]);return this.__wbg_ptr=f[0],d.register(this,this.__wbg_ptr,this),this}withDefaultRowHeight(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withDefaultRowHeight(t,e);return o.__wrap(_)}withHeaderRowHeight(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withHeaderRowHeight(t,e);return o.__wrap(_)}withImageFetcher(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withImageFetcher(t,e);return o.__wrap(_)}withIsHeaderFreeze(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withIsHeaderFreeze(t,e);return o.__wrap(_)}withOffset(e,t){const _=this.__destroy_into_raw(),n=O.excelinfo_withOffset(_,e,t);return o.__wrap(n)}withProgressCallback(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withProgressCallback(t,e);return o.__wrap(_)}withTitle(e){const t=this.__destroy_into_raw(),_=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),n=B,r=O.excelinfo_withTitle(t,_,n);return o.__wrap(r)}withTitleFormat(e){const _=this.__destroy_into_raw();h(e,t);var n=e.__destroy_into_raw();const r=O.excelinfo_withTitleFormat(_,n);return o.__wrap(r)}withTitleHeight(e){const t=this.__destroy_into_raw(),_=O.excelinfo_withTitleHeight(t,e);return o.__wrap(_)}get author(){let e,t;try{const _=O.__wbg_get_excelinfo_author(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get columns(){const e=O.__wbg_get_excelinfo_columns(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}get create_time(){let e,t;try{const _=O.__wbg_get_excelinfo_create_time(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get default_row_height(){const e=O.__wbg_get_excelinfo_default_row_height(this.__wbg_ptr);return 0===e[0]?void 0:e[1]}get dx(){return O.__wbg_get_excelinfo_dx(this.__wbg_ptr)}get dy(){return O.__wbg_get_excelinfo_dy(this.__wbg_ptr)>>>0}get header_row_height(){const e=O.__wbg_get_excelinfo_header_row_height(this.__wbg_ptr);return 0===e[0]?void 0:e[1]}get is_header_freeze(){return 0!==O.__wbg_get_excelinfo_is_header_freeze(this.__wbg_ptr)}get name(){let e,t;try{const _=O.__wbg_get_excelinfo_name(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get sheet_name(){let e,t;try{const _=O.__wbg_get_excelinfo_sheet_name(this.__wbg_ptr);return e=_[0],t=_[1],E(_[0],_[1])}finally{O.__wbindgen_free(e,t,1)}}get title_format(){const e=O.__wbg_get_excelinfo_title_format(this.__wbg_ptr);return 0===e?void 0:t.__wrap(e)}get title_height(){const e=O.__wbg_get_excelinfo_title_height(this.__wbg_ptr);return 0===e[0]?void 0:e[1]}get title(){const e=O.__wbg_get_excelinfo_title(this.__wbg_ptr);let t;return 0!==e[0]&&(t=E(e[0],e[1]).slice(),O.__wbindgen_free(e[0],1*e[1],1)),t}set author(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelinfo_author(this.__wbg_ptr,t,_)}set columns(e){const t=R(e,O.__wbindgen_malloc),_=B;O.__wbg_set_excelinfo_columns(this.__wbg_ptr,t,_)}set create_time(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelinfo_create_time(this.__wbg_ptr,t,_)}set default_row_height(e){O.__wbg_set_excelinfo_default_row_height(this.__wbg_ptr,!k(e),k(e)?0:e)}set dx(e){O.__wbg_set_excelinfo_dx(this.__wbg_ptr,e)}set dy(e){O.__wbg_set_excelinfo_dy(this.__wbg_ptr,e)}set header_row_height(e){O.__wbg_set_excelinfo_header_row_height(this.__wbg_ptr,!k(e),k(e)?0:e)}set is_header_freeze(e){O.__wbg_set_excelinfo_is_header_freeze(this.__wbg_ptr,e)}set name(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelinfo_name(this.__wbg_ptr,t,_)}set sheet_name(e){const t=A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelinfo_sheet_name(this.__wbg_ptr,t,_)}set title_format(e){let _=0;k(e)||(h(e,t),_=e.__destroy_into_raw()),O.__wbg_set_excelinfo_title_format(this.__wbg_ptr,_)}set title_height(e){O.__wbg_set_excelinfo_title_height(this.__wbg_ptr,!k(e),k(e)?0:e)}set title(e){var t=k(e)?0:A(e,O.__wbindgen_malloc,O.__wbindgen_realloc),_=B;O.__wbg_set_excelinfo_title(this.__wbg_ptr,t,_)}}Symbol.dispose&&(o.prototype[Symbol.dispose]=o.prototype.free);class i{static __wrap(e){const t=Object.create(i.prototype);return t.__wbg_ptr=e,b.register(t,t.__wbg_ptr,t),t}static __unwrap(e){return e instanceof i?e.__destroy_into_raw():0}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,b.unregister(this),e}free(){const e=this.__destroy_into_raw();O.__wbg_excelrowdata_free(e,0)}constructor(e){const t=R(e,O.__wbindgen_malloc),_=B,n=O.excelrowdata_new(t,_);return this.__wbg_ptr=n,b.register(this,this.__wbg_ptr,this),this}get columns(){const e=O.__wbg_get_excelrowdata_columns(this.__wbg_ptr);var t=y(e[0],e[1]).slice();return O.__wbindgen_free(e[0],4*e[1],4),t}set columns(e){const t=R(e,O.__wbindgen_malloc),_=B;O.__wbg_set_excelrowdata_columns(this.__wbg_ptr,t,_)}}function a(){const e={__proto__:null,__wbg_Error_92b29b0548f8b746:function(e,t){return Error(E(e,t))},__wbg___wbindgen_debug_string_c25d447a39f5578f:function(e,t){const _=A(p(t),O.__wbindgen_malloc,O.__wbindgen_realloc),n=B;F().setInt32(e+4,n,!0),F().setInt32(e+0,_,!0)},__wbg___wbindgen_is_function_1ff95bcc5517c252:function(e){return"function"==typeof e},__wbg___wbindgen_is_object_a27215656b807791:function(e){return"object"==typeof e&&null!==e},__wbg___wbindgen_is_undefined_c05833b95a3cf397:function(e){return void 0===e},__wbg___wbindgen_string_get_b0ca35b86a603356:function(e,t){const _="string"==typeof t?t:void 0;var n=k(_)?0:A(_,O.__wbindgen_malloc,O.__wbindgen_realloc),r=B;F().setInt32(e+4,r,!0),F().setInt32(e+0,n,!0)},__wbg___wbindgen_throw_344f42d3211c4765:function(e,t){throw new Error(E(e,t))},__wbg__wbg_cb_unref_fffb441def202758:function(e){e._wbg_cb_unref()},__wbg_call_a6e5c5dce5018821:function(){return function(e,t){try{return e.apply(this,t)}catch(e){const t=f(e);O.__wbindgen_exn_store(t)}}((function(e,t,_){return e.call(t,_)}),arguments)},__wbg_excelcellformat_new:function(e){return t.__wrap(e)},__wbg_excelcellformat_unwrap:function(e){return t.__unwrap(e)},__wbg_excelcolumndata_new:function(e){return _.__wrap(e)},__wbg_excelcolumndata_unwrap:function(e){return _.__unwrap(e)},__wbg_excelcolumninfo_new:function(e){return n.__wrap(e)},__wbg_excelcolumninfo_unwrap:function(e){return n.__unwrap(e)},__wbg_excelrowdata_new:function(e){return i.__wrap(e)},__wbg_excelrowdata_unwrap:function(e){return i.__unwrap(e)},__wbg_length_1f0964f4a5e2c6d8:function(e){return e.length},__wbg_new_cd45aabdf6073e84:function(e){return new Uint8Array(e)},__wbg_new_from_slice_77cdfb7977362f3c:function(e,t){return new Uint8Array(x(e,t))},__wbg_new_typed_1824d93f294193e5:function(e,t){try{var _={a:e,b:t};const n=new Promise(((e,t)=>{const n=_.a;_.a=0;try{return function(e,t,_,n){O.wasm_bindgen__convert__closures_____invoke__h5ea5d44b66049ea8(e,t,_,n)}(n,_.b,e,t)}finally{_.a=n}}));return n}finally{_.a=0}},__wbg_now_86c0d4ba3fa605b8:function(){return Date.now()},__wbg_prototypesetcall_4770620bbe4688a0:function(e,t,_){Uint8Array.prototype.set.call(x(e,t),_)},__wbg_queueMicrotask_0ab5b2d2393e99b9:function(e){return e.queueMicrotask},__wbg_queueMicrotask_6a09b7bc46549209:function(e){queueMicrotask(e)},__wbg_resolve_2191a4dfe481c25b:function(e){return Promise.resolve(e)},__wbg_static_accessor_GLOBAL_4ef717fb391d88b7:function(){const e="undefined"==typeof global?null:global;return k(e)?0:f(e)},__wbg_static_accessor_GLOBAL_THIS_8d1badc68b5a74f4:function(){const e="undefined"==typeof globalThis?null:globalThis;return k(e)?0:f(e)},__wbg_static_accessor_SELF_146583524fe1469b:function(){const e="undefined"==typeof self?null:self;return k(e)?0:f(e)},__wbg_static_accessor_WINDOW_f2829a2234d7819e:function(){const e="undefined"==typeof window?null:window;return k(e)?0:f(e)},__wbg_then_16d107c451e9905d:function(e,t,_){return e.then(t,_)},__wbg_then_6ec10ae38b3e92f7:function(e,t){return e.then(t)},__wbindgen_cast_0000000000000001:function(e,t){const _=function(e,t,_){const n={a:e,b:t,cnt:1},r=(...e)=>{n.cnt++;const t=n.a;n.a=0;try{return _(t,n.b,...e)}finally{n.a=t,r._wbg_cb_unref()}};return r._wbg_cb_unref=()=>{0==--n.cnt&&(O.__wbindgen_destroy_closure(n.a,n.b),n.a=0,m.unregister(n))},m.register(r,n,n),r}(e,t,l);return _},__wbindgen_cast_0000000000000002:function(e){return e},__wbindgen_cast_0000000000000003:function(e,t){return E(e,t)},__wbindgen_init_externref_table:function(){const e=O.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}};return{__proto__:null,"./imexport_wasm_bg.js":e}}function l(e,t,_){const n=O.wasm_bindgen__convert__closures_____invoke__h92faae99925693fa(e,t,_);if(n[1])throw T(n[0])}Symbol.dispose&&(i.prototype[Symbol.dispose]=i.prototype.free);const c="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_dynamicexceldata_free(e,1))),s="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_excelcellformat_free(e,1))),w="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_excelcolumndata_free(e,1))),u="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_excelcolumninfo_free(e,1))),g="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_exceldata_free(e,1))),d="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_excelinfo_free(e,1))),b="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbg_excelrowdata_free(e,1)));function f(e){const t=O.__externref_table_alloc();return O.__wbindgen_externrefs.set(t,e),t}function h(e,t){if(!(e instanceof t))throw new Error(`expected instance of ${t.name}`)}const m="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>O.__wbindgen_destroy_closure(e.a,e.b)));function p(e){const t=typeof e;if("number"==t||"boolean"==t||null==e)return`${e}`;if("string"==t)return`"${e}"`;if("symbol"==t){const t=e.description;return null==t?"Symbol":`Symbol(${t})`}if("function"==t){const t=e.name;return"string"==typeof t&&t.length>0?`Function(${t})`:"Function"}if(Array.isArray(e)){const t=e.length;let _="[";t>0&&(_+=p(e[0]));for(let n=1;n<t;n++)_+=", "+p(e[n]);return _+="]",_}const _=/\[object ([^\]]+)\]/.exec(toString.call(e));let n;if(!(_&&_.length>1))return toString.call(e);if(n=_[1],"Object"==n)try{return"Object("+JSON.stringify(e)+")"}catch(e){return"Object"}return e instanceof Error?`${e.name}: ${e.message}\n${e.stack}`:n}function y(e,t){e>>>=0;const _=F(),n=[];for(let r=e;r<e+4*t;r+=4)n.push(O.__wbindgen_externrefs.get(_.getUint32(r,!0)));return O.__externref_drop_slice(e,t),n}function x(e,t){return e>>>=0,$().subarray(e/1,e/1+t)}let v=null;function F(){return(null===v||!0===v.buffer.detached||void 0===v.buffer.detached&&v.buffer!==O.memory.buffer)&&(v=new DataView(O.memory.buffer)),v}function E(e,t){return function(e,t){I+=t,I>=D&&(C=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),C.decode(),I=t);return C.decode($().subarray(e,e+t))}(e>>>0,t)}let S=null;function $(){return null!==S&&0!==S.byteLength||(S=new Uint8Array(O.memory.buffer)),S}function k(e){return null==e}function z(e,t){const _=t(1*e.length,1)>>>0;return $().set(e,_/1),B=e.length,_}function R(e,t){const _=t(4*e.length,4)>>>0;for(let t=0;t<e.length;t++){const n=f(e[t]);F().setUint32(_+4*t,n,!0)}return B=e.length,_}function A(e,t,_){if(void 0===_){const _=G.encode(e),n=t(_.length,1)>>>0;return $().subarray(n,n+_.length).set(_),B=_.length,n}let n=e.length,r=t(n,1)>>>0;const o=$();let i=0;for(;i<n;i++){const t=e.charCodeAt(i);if(t>127)break;o[r+i]=t}if(i!==n){0!==i&&(e=e.slice(i)),r=_(r,n,n=i+3*e.length,1)>>>0;const t=$().subarray(r+i,r+n);i+=G.encodeInto(e,t).written,r=_(r,n,i,1)>>>0}return B=i,r}function T(e){const t=O.__wbindgen_externrefs.get(e);return O.__externref_table_dealloc(e),t}let C=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});C.decode();const D=2146435072;let I=0;const G=new TextEncoder;"encodeInto"in G||(G.encodeInto=function(e,t){const _=G.encode(e);return t.set(_),{read:e.length,written:_.length}});let O,B=0;async function j(e){if(void 0!==O)return O;void 0!==e&&(Object.getPrototypeOf(e)===Object.prototype?({module_or_path:e}=e):console.warn("using deprecated parameters for the initialization function; pass a single object instead")),void 0===e&&(e=new URL("imexport_wasm_bg.wasm",import.meta.url));const t=a();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:_,module:n}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(!e.ok||!function(e){switch(e){case"basic":case"cors":case"default":return!0}return!1}(e.type)||"application/wasm"===e.headers.get("Content-Type"))throw t;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",t)}const _=await e.arrayBuffer();return await WebAssembly.instantiate(_,t)}{const _=await WebAssembly.instantiate(e,t);return _ instanceof WebAssembly.Instance?{instance:_,module:e}:_}}(await e,t);return function(e){return O=e.exports,v=null,S=null,O.__wbindgen_start(),O}(_)}const H=["text","number","date","image"],L=26214400,P=new Set(["=","+","-","@","\t","\r","\n","|",";"]),N="senlinzImportExportDownload";let U=null,M=!1;function V(e,t){const _=null!=e?e:"text";if("string"!=typeof _)throw new Error(`Invalid dataType '${String(_)}' for column '${t}'. dataType values must be strings.`);const n=_.trim().toLowerCase();if(!H.includes(n))throw new Error(`Invalid dataType '${e}' for column '${t}'. Supported values are: ${H.join(", ")}.`);return n}function W(e,t){if(void 0===e)return L;if("number"!=typeof e||!Number.isFinite(e))throw new Error(`Invalid maxFileSizeBytes '${String(e)}' for ${t}. Expected a positive finite number in bytes.`);const _=Math.trunc(e);if(_<=0)throw new Error(`Invalid maxFileSizeBytes '${e}' for ${t}. Expected a positive finite number in bytes.`);return _}function q(e,t){if(!t||""===e)return e;const _=e[0];return P.has(_)?`'${e}`:e}function Z(e){const t=e/1048576;return`${t%1==0?t.toFixed(0):t.toFixed(1)} MB`}function J(e){var t,_;if(!(null===(t=e.name)||void 0===t?void 0:t.trim()))throw new Error("Excel definition must include a non-empty name.");if(!Array.isArray(e.columns)||0===e.columns.length)throw new Error(`Excel definition '${e.name}' must include at least one column.`);const n=new Set,r=new Set,o=e.name.trim(),i=W(e.maxFileSizeBytes,`definition '${o}'`),a=function(e,t){if(void 0===e)return!0;if("boolean"!=typeof e)throw new Error(`Invalid escapeFormulas '${String(e)}' for ${t}. Expected a boolean.`);return e}(e.escapeFormulas,`definition '${o}'`),l=e.columns.map((t=>{var _,o;const i=null===(_=t.key)||void 0===_?void 0:_.trim(),a=null===(o=t.name)||void 0===o?void 0:o.trim();if(!i)throw new Error(`Excel definition '${e.name}' contains a column with an empty key.`);if(!a)throw new Error(`Column '${i}' in definition '${e.name}' must include a non-empty name.`);if(n.has(i))throw new Error(`Duplicate column key '${i}' found in definition '${e.name}'.`);const l=Object.assign(Object.assign({},t),{key:i,name:a,dataType:V(t.dataType,i)});if(l.parent){const e=l.parent.trim();if(!e)throw new Error(`Column '${i}' has an empty parent reference.`);if(e===i)throw new Error(`Column '${i}' cannot reference itself as a parent.`);if(!n.has(e))throw new Error(`Column '${i}' references parent '${e}', but parent columns must be declared before their children.`);l.parent=e}if(l.dataGroup){const t=l.dataGroup.trim();if(!t)throw new Error(`Column '${i}' has an empty dataGroup value.`);if(r.has(t))throw new Error(`Duplicate dataGroup '${t}' found in definition '${e.name}'.`);r.add(t),l.dataGroup=t}if(l.dataGroupParent){const e=l.dataGroupParent.trim();if(!e)throw new Error(`Column '${i}' has an empty dataGroupParent value.`);if(l.dataGroup===e)throw new Error(`Column '${i}' cannot reference its own dataGroup '${e}' as dataGroupParent.`);if(!r.has(e))throw new Error(`Column '${i}' references dataGroupParent '${e}', but grouped parents must be declared before dependent columns.`);l.dataGroupParent=e}return n.add(i),l}));return Object.assign(Object.assign({},e),{name:o,sheetName:(null===(_=e.sheetName)||void 0===_?void 0:_.trim())||void 0,columns:l,maxFileSizeBytes:i,escapeFormulas:a})}const X={normalizeDefinition:J,normalizeDynamicImportOptions:ee,sanitizeTextCellValue:(e,t=!0)=>q(e,t),defaultMaxFileSizeBytes:L};function Y(e,t){if(""===t)return"number"===e.dataType||"date"===e.dataType?null:t;if("number"===e.dataType){const _=Number(t);if(!Number.isFinite(_))throw new Error(`Failed to parse imported number '${t}' for column '${e.key}'.`);return _}return t}function K(e,t,_){if(null==t)return"";const n=e.data_type.toLowerCase();if("number"===n){const _="number"==typeof t?t:Number(t);if(!Number.isFinite(_))throw new Error(`Column '${e.key}' expects a finite number value.`);return _.toString()}if("date"===n){if(t instanceof Date)return ue(t);if("string"==typeof t){const e=t.trim();return e||""}throw new Error(`Column '${e.key}' expects a date string or Date instance.`)}return"text"===n?q(t.toString(),_):t.toString()}function Q(e){return e.rows.map((e=>{const t={};for(const _ of e.columns)t[_.key]=_.value;return t}))}function ee(e={}){var t;if(void 0!==e.headerRow&&(!Number.isInteger(e.headerRow)||e.headerRow<1))throw new Error("Dynamic import option 'headerRow' must be an integer greater than or equal to 1.");return{sheetName:(null===(t=e.sheetName)||void 0===t?void 0:t.trim())||void 0,headerRow:e.headerRow,maxFileSizeBytes:W(e.maxFileSizeBytes,"dynamic import options")}}async function te(e,t){const _=function(e,t){h(e,o);var _=e.__destroy_into_raw();const n=z(t,O.__wbindgen_malloc),i=B,a=O.importData(_,n,i);if(a[2])throw T(a[1]);return r.__wrap(a[0])}(we(e),t),n=function(e,t){const _=[],n={};for(const e of t)n[e.key]=e;for(const t of e.rows){const e={};for(const _ of t.columns){const t=n[_.key];t&&(e[_.key]=Y(t,_.value))}_.push(e)}return _}(_,e.columns);return n}async function _e(t,_){const n=function(t,_,n){var r=k(t)?0:A(t,O.__wbindgen_malloc,O.__wbindgen_realloc),o=B;const i=z(n,O.__wbindgen_malloc),a=B,l=O.importDynamicData(r,o,k(_)?Number.MAX_SAFE_INTEGER:_>>>0,i,a);if(l[2])throw T(l[1]);return e.__wrap(l[0])}(_.sheetName,_.headerRow,t);return{sheetName:n.sheet_name,headers:[...n.headers],rows:Q(n)}}function ne(e,t=26214400){return new Promise(((_,n)=>{var r;null===(r=document.querySelector("#senlinzImportExportInput"))||void 0===r||r.remove();const o=document.createElement("input");o.id="senlinzImportExportInput",o.style.display="none",o.type="file",o.accept=".xlsx,.xls,.xlsm,.xlsb,.xla,.xlam,.ods",document.body.appendChild(o);let i=!1;const a=()=>{o.removeEventListener("change",w),o.removeEventListener("cancel",s),o.remove()},l=e=>{i||(i=!0,a(),n(e instanceof Error?e:new Error(String(e))))},c=e=>{i||(i=!0,a(),_(e))},s=()=>{l(new Error("File selection cancelled."))};function w(_){const n=_.target;if(!n||!n.files||0===n.files.length)return void l(new Error("File selection cancelled."));const r=n.files[0];try{!function(e,t){if(e.size>t)throw new Error(`Selected file '${e.name}' exceeds the ${Z(t)} limit (received ${Z(e.size)}).`)}(r,t)}catch(e){return void l(e)}const o=new FileReader;o.onerror=()=>{var e;l(null!==(e=o.error)&&void 0!==e?e:new Error("Failed to read import file."))},o.onabort=()=>{l(new Error("Import file read was aborted."))},o.onload=async()=>{try{const t=new Uint8Array(o.result),_=await e(t);c(_)}catch(e){l(e)}},o.readAsArrayBuffer(r)}o.addEventListener("change",w),o.addEventListener("cancel",s),o.click()}))}function re(e,t,n,r=""){const o=[];for(const l of e){const e=[];for(const o in l){const i=t[o],c=l[o];if(i&&void 0!==c)if(i.data_group){if(null!==c){if("object"!=typeof(a=c)||null===a||!Array.isArray(a.children))throw new Error(`Grouped column '${o}' must be an object with a children array.`);if(c.children.length){const a=re(c.children,t,n,o);r?e.push(_.newGroup(o,K(i,c.value,n),a)):e.push(_.newRootGroup(o,a))}}}else e.push(new _(o,K(i,c,n)))}o.push(new i(e))}var a;return o}async function oe(e,t){const _=we(e),n=function(e){const t={};for(const _ of e.columns)t[_.key]=_;return t}(_),i=re(t,n,e.escapeFormulas);return function(e,t){h(e,o);var _=e.__destroy_into_raw();h(t,r);var n=t.__destroy_into_raw();return O.exportData(_,n)}(_,new r(i))}async function ie(e,t){return oe(J(e),t)}async function ae(e){return function(e){h(e,o);var t=e.__destroy_into_raw();const _=O.createTemplate(t);if(_[3])throw T(_[2]);var n=x(_[0],_[1]).slice();return O.__wbindgen_free(_[0],1*_[1],1),n}(we(J(e)))}function le(e,t,_="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"){var n;ce(),null===(n=document.querySelector(`#${N}`))||void 0===n||n.remove();const r=document.createElement("a");r.id=N,r.download=t;const o=new Blob([e],{type:_}),i=URL.createObjectURL(o);r.href=i,function(){if(M||"undefined"==typeof window)return;const e=()=>ce();window.addEventListener("focus",e),window.addEventListener("pagehide",e),document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&e()})),M=!0}(),U=i,r.click(),setTimeout((()=>ce()),6e4)}function ce(){U&&(URL.revokeObjectURL(U),U=null)}function se(e){let _=new t;return e.rule&&(_=_.withRule(e.rule)),e.value&&(_=_.withValue(e.value)),e.color&&(_=_.withColor(e.color)),e.bold&&(_=_.withBold(e.bold)),e.italic&&(_=_.withItalic(e.italic)),e.underline&&(_=_.withUnderline(e.underline)),e.strikethrough&&(_=_.withStrikethrough(e.strikethrough)),e.fontSize&&(_=_.withFontSize(e.fontSize)),e.backgroundColor&&(_=_.withBackgroundColor(e.backgroundColor)),e.align&&(_=_.withAlign(e.align)),e.alignVertical&&(_=_.withAlignVertical(e.alignVertical)),e.borderColor&&(_=_.withBorderColor(e.borderColor)),e.dateFormat&&(_=_.withDateFormat(e.dateFormat)),_}function we(e){var t,_,r,i,a;const l=e.columns.map((e=>{let t=new n(e.key,e.name);if(e.width&&(t=t.withWidth(e.width)),e.dataType&&(t=t.withDataType(e.dataType)),e.note&&(t=t.withNote(e.note)),e.allowedValues&&(t=t.withAllowedValues(e.allowedValues)),e.parent&&(t=t.withParent(e.parent)),e.format&&(t=t.withFormat(se(e.format))),e.valueFormat){const _=Array.isArray(e.valueFormat)?e.valueFormat:[e.valueFormat];t=t.withValueFormat(_.map(se))}return e.dataGroup&&(t=t.withDataGroup(e.dataGroup)),e.dataGroupParent&&(t=t.withDataGroupParent(e.dataGroupParent)),t}));let c=new o(e.name,null!==(t=e.sheetName)&&void 0!==t?t:"sheet1",l,null!==(_=e.author)&&void 0!==_?_:"",ue(null!==(r=e.createTime)&&void 0!==r?r:new Date));const s=null!==(i=e.dx)&&void 0!==i?i:0,w=null!==(a=e.dy)&&void 0!==a?a:0;return c=c.withOffset(s,w),e.title&&(c=c.withTitle(e.title)),e.titleHeight&&(c=c.withTitleHeight(e.titleHeight)),e.titleFormat&&(c=c.withTitleFormat(se(e.titleFormat))),e.defaultRowHeight&&(c=c.withDefaultRowHeight(e.defaultRowHeight)),e.headerRowHeight&&(c=c.withHeaderRowHeight(e.headerRowHeight)),e.isHeaderFreeze&&(c=c.withIsHeaderFreeze(e.isHeaderFreeze)),e.progressCallback&&(c=c.withProgressCallback(e.progressCallback)),e.imageFetcher&&(c=c.withImageFetcher(e.imageFetcher)),c}function ue(e){if("string"==typeof e)return e;const t=e.getFullYear(),_=e.getMonth()+1,n=e.getDate(),r=e.getHours(),o=e.getMinutes(),i=e.getSeconds(),a=e=>e<10?`0${e}`:e.toString();return`${t}-${a(_)}-${a(n)} ${a(r)}:${a(o)}:${a(i)}`}var ge=new URL("assets/imexport_wasm_bg-BUZuccZ4.wasm",import.meta.url).href;let de=!1,be=null;async function fe(){const e=await function(){if("function"!=typeof fetch)throw new Error("WASM initialization requires a global fetch implementation in this runtime.");return fetch}()(ge);if(!e.ok)throw new Error(`Failed to load the bundled Excel WASM asset from '${ge}'. HTTP ${e.status}.`);return new Uint8Array(await e.arrayBuffer())}function he(e){return new Promise((t=>setTimeout(t,e)))}async function me(){if(!de)return be||(be=(async()=>{try{const e=await async function(){let e;for(let t=0;t<=2;t++)try{return await fe()}catch(_){e=_ instanceof Error?_:new Error(String(_)),t<2&&await he(500*Math.pow(2,t))}throw new Error(`Failed to initialize WASM runtime after 3 attempts. Last error: ${e.message}`)}();await j({module_or_path:e}),de=!0}catch(e){throw new Error(`Failed to initialize the bundled Excel WASM runtime. ${e instanceof Error?e.message:String(e)}`)}finally{be=null}})()),be}async function pe(e){return await me(),function(e){const t=J(e);return ne((e=>te(t,e)),t.maxFileSizeBytes)}(e)}async function ye(e){return await me(),function(e){const t=ee(e);return ne((e=>_e(e,t)),t.maxFileSizeBytes)}(e)}async function xe(e,t){return await me(),async function(e,t){le(await ie(e,t),`${e.name}.xlsx`)}(e,t)}async function ve(e,t){return await me(),async function(e,t){return te(J(e),t)}(e,t)}async function Fe(e,t){return await me(),async function(e,t){return _e(e,ee(t))}(e,t)}async function Ee(e,t){return await me(),ie(e,t)}async function Se(e){return await me(),async function(e){const t=`${e.name}.xlsx`;le(await ae(e),t)}(e)}async function $e(e){return await me(),ae(e)}export{Se as downloadExcelTemplate,xe as exportExcel,ve as fromExcel,Fe as fromExcelDynamic,$e as generateExcelTemplate,pe as importExcel,ye as importExcelDynamic,X as testUtils,Ee as toExcel};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExcelColumnDefinition, ExcelDefinition, DynamicExcelImportOptions, DynamicExcelImportResult } from './ExcelDefinition';
|
|
2
2
|
declare const SUPPORTED_DATA_TYPES: readonly ["text", "number", "date", "image"];
|
|
3
|
-
type NormalizedDataType = typeof SUPPORTED_DATA_TYPES[number];
|
|
3
|
+
type NormalizedDataType = (typeof SUPPORTED_DATA_TYPES)[number];
|
|
4
4
|
type NormalizedExcelColumnDefinition = Omit<ExcelColumnDefinition, 'dataType'> & {
|
|
5
5
|
dataType?: NormalizedDataType;
|
|
6
6
|
};
|
|
@@ -28,4 +28,4 @@ declare function download(data: Uint8Array | string, name: string, type?: string
|
|
|
28
28
|
declare function importExcel<T>(definition: ExcelDefinition): Promise<T[]>;
|
|
29
29
|
declare function importExcelDynamic(options?: DynamicExcelImportOptions): Promise<DynamicExcelImportResult>;
|
|
30
30
|
declare function exportExcel<T>(definition: ExcelDefinition, data: T[]): Promise<void>;
|
|
31
|
-
export { importExcel, importExcelDynamic, exportExcel, downloadExcelTemplate, _fromExcel as fromExcel, _fromExcelDynamic as fromExcelDynamic, _toExcel as toExcel, generateExcelTemplate, download, testUtils };
|
|
31
|
+
export { importExcel, importExcelDynamic, exportExcel, downloadExcelTemplate, _fromExcel as fromExcel, _fromExcelDynamic as fromExcelDynamic, _toExcel as toExcel, generateExcelTemplate, download, testUtils, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@senlinz/import-export",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "import/export excel core",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**/*.js",
|
|
@@ -21,10 +21,11 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
23
23
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
24
|
-
"@rollup/plugin-terser": "^0.
|
|
24
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
25
25
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
26
26
|
"@types/jest": "^29.5.6",
|
|
27
27
|
"@types/node": "^16.18.108",
|
|
28
|
+
"fast-check": "^4.7.0",
|
|
28
29
|
"fflate": "^0.8.2",
|
|
29
30
|
"jest": "^29.7.0",
|
|
30
31
|
"jest-cli": "^29.7.0",
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"url": "git+https://github.com/gui-xie/import-export.git"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
|
-
"@senlinz/import-export-wasm": "1.0.
|
|
43
|
+
"@senlinz/import-export-wasm": "1.0.1"
|
|
43
44
|
},
|
|
44
45
|
"keywords": [
|
|
45
46
|
"rust",
|
|
Binary file
|