@sheetxl/scripting 0.7.21 → 0.7.23-beta.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.
Files changed (117) hide show
  1. package/README.md +208 -229
  2. package/browser/cjs/1_xhnTjP6m5oj6za.cjs +21 -0
  3. package/browser/cjs/6XTQ1BNSLrTHmFNH.cjs +1 -0
  4. package/browser/cjs/Bu4cZ8iSZ3rij-oV.cjs +1 -0
  5. package/browser/cjs/BvG8N7G_8CXIAlT-.cjs +1 -0
  6. package/browser/cjs/C_7w8EJZpHw8ueuq.cjs +1 -0
  7. package/browser/cjs/C_IEgjM-hSJCv6Gm.cjs +1 -0
  8. package/browser/cjs/CctaCN_w3o34V9AR.cjs +1 -0
  9. package/browser/cjs/DSEShe7kGtxvljOr.cjs +1 -0
  10. package/browser/cjs/GBmIbvhpXGNyZh4W.cjs +1 -0
  11. package/browser/cjs/index.cjs +1 -6
  12. package/browser/cjs/qWYyYsBboXc9p0Lw.cjs +7 -0
  13. package/browser/esm/B2O6_lZVwu7HGlcx.mjs +8 -0
  14. package/browser/esm/B7Axspg8vBnT9M3x.mjs +421 -0
  15. package/browser/esm/BVMNJQoqhXCkbrAc.mjs +87 -0
  16. package/browser/esm/BX3qwglupa6Y59lz.mjs +27 -0
  17. package/browser/esm/C1gdnq2DZdt3y7zD.mjs +23 -0
  18. package/browser/esm/CD2q23uuB7okp3Dl.mjs +152 -0
  19. package/browser/esm/CabN_0aQQRRyMDbw.mjs +12 -0
  20. package/browser/esm/D8K5BUCHuJ9gEpKs.mjs +105 -0
  21. package/browser/esm/DYjJCR6wkeLLkRm6.mjs +15 -0
  22. package/browser/esm/Qyh7uNkqdCcPtgBO.mjs +25 -0
  23. package/browser/esm/index.mjs +40 -20
  24. package/node/esm/47V_H-QS1YIyY07o.mjs +14 -0
  25. package/node/esm/B2O6_lZVwu7HGlcx.mjs +8 -0
  26. package/node/esm/CFY3Dm5Wl-fatf70.mjs +421 -0
  27. package/node/esm/CPB_iNIWuPOW5OPJ.mjs +152 -0
  28. package/node/esm/CaKTS-uKPFUYE8z9.mjs +27 -0
  29. package/node/esm/DGA9ykmJTQwzArFh.mjs +17 -0
  30. package/node/esm/DXc-q9b4X6dKKFs-.mjs +12 -0
  31. package/node/esm/index.mjs +144 -20
  32. package/node/esm/jw7wu0yKXfqYBchM.mjs +23 -0
  33. package/package.json +11 -8
  34. package/types/index.d.ts +2 -165
  35. package/types/src/ScriptCompiler.d.ts +40 -0
  36. package/types/src/ScriptCompiler.d.ts.map +1 -0
  37. package/types/src/compiler/Bundler.d.ts +7 -0
  38. package/types/src/compiler/Bundler.d.ts.map +1 -0
  39. package/types/src/compiler/TypescriptCompiler.d.ts +27 -0
  40. package/types/src/compiler/TypescriptCompiler.d.ts.map +1 -0
  41. package/types/src/compiler/TypescriptCompiler.impl.d.ts +17 -0
  42. package/types/src/compiler/TypescriptCompiler.impl.d.ts.map +1 -0
  43. package/types/src/compiler/TypescriptCompiler.worker.d.ts +2 -0
  44. package/types/src/compiler/TypescriptCompiler.worker.d.ts.map +1 -0
  45. package/types/src/compiler/compiler.browser.d.ts +8 -0
  46. package/types/src/compiler/compiler.browser.d.ts.map +1 -0
  47. package/types/src/compiler/compiler.node.d.ts +14 -0
  48. package/types/src/compiler/compiler.node.d.ts.map +1 -0
  49. package/types/src/compiler/constants.d.ts +10 -0
  50. package/types/src/compiler/constants.d.ts.map +1 -0
  51. package/types/src/compiler/insertYieldBetweenStatements.d.ts +5 -0
  52. package/types/src/compiler/insertYieldBetweenStatements.d.ts.map +1 -0
  53. package/types/src/compiler/transformAwaitToYield.d.ts +6 -0
  54. package/types/src/compiler/transformAwaitToYield.d.ts.map +1 -0
  55. package/types/src/index.d.ts +7 -0
  56. package/types/src/index.d.ts.map +1 -0
  57. package/types/src/lib/esbuild/esbuild.browser.d.ts +4 -0
  58. package/types/src/lib/esbuild/esbuild.browser.d.ts.map +1 -0
  59. package/types/src/lib/esbuild/esbuild.node.d.ts +11 -0
  60. package/types/src/lib/esbuild/esbuild.node.d.ts.map +1 -0
  61. package/types/src/lib/typescript/typescript.browser.d.ts +4 -0
  62. package/types/src/lib/typescript/typescript.browser.d.ts.map +1 -0
  63. package/types/src/lib/typescript/typescript.node.d.ts +4 -0
  64. package/types/src/lib/typescript/typescript.node.d.ts.map +1 -0
  65. package/types/src/linter/Linter.d.ts +63 -0
  66. package/types/src/linter/Linter.d.ts.map +1 -0
  67. package/types/src/linter/index.d.ts +2 -0
  68. package/types/src/linter/index.d.ts.map +1 -0
  69. package/types/src/loader/index.d.ts +2 -0
  70. package/types/src/loader/index.d.ts.map +1 -0
  71. package/types/src/loader/loadCompiledModule.d.ts +19 -0
  72. package/types/src/loader/loadCompiledModule.d.ts.map +1 -0
  73. package/types/src/loader/moduleLoader.browser.d.ts +11 -0
  74. package/types/src/loader/moduleLoader.browser.d.ts.map +1 -0
  75. package/types/src/loader/moduleLoader.node.d.ts +15 -0
  76. package/types/src/loader/moduleLoader.node.d.ts.map +1 -0
  77. package/types/src/plugin/generate.d.ts +17 -0
  78. package/types/src/plugin/generate.d.ts.map +1 -0
  79. package/types/src/plugin/vite.d.ts +24 -0
  80. package/types/src/plugin/vite.d.ts.map +1 -0
  81. package/types/src/runtime/Constants.d.ts +9 -0
  82. package/types/src/runtime/Constants.d.ts.map +1 -0
  83. package/types/src/runtime/index.d.ts +2 -0
  84. package/types/src/runtime/index.d.ts.map +1 -0
  85. package/types/src/tags/DocTags.d.ts +46 -0
  86. package/types/src/tags/DocTags.d.ts.map +1 -0
  87. package/types/src/tags/index.d.ts +2 -0
  88. package/types/src/tags/index.d.ts.map +1 -0
  89. package/types/src/type/CompileOptions.d.ts +58 -0
  90. package/types/src/type/CompileOptions.d.ts.map +1 -0
  91. package/types/src/type/CompiledModule.d.ts +70 -0
  92. package/types/src/type/CompiledModule.d.ts.map +1 -0
  93. package/types/src/type/Diagnostic.d.ts +120 -0
  94. package/types/src/type/Diagnostic.d.ts.map +1 -0
  95. package/types/src/type/Types.d.ts +72 -0
  96. package/types/src/type/Types.d.ts.map +1 -0
  97. package/types/src/type/index.d.ts +6 -0
  98. package/types/src/type/index.d.ts.map +1 -0
  99. package/types/src/worker/WorkerWrapper.d.ts +44 -0
  100. package/types/src/worker/WorkerWrapper.d.ts.map +1 -0
  101. package/types/src/worker/index.d.ts +2 -0
  102. package/types/src/worker/index.d.ts.map +1 -0
  103. package/browser/cjs/B0y4r3JJPPSwiDzx.cjs +0 -6
  104. package/browser/cjs/CGLLj80MYA2hDUWX.cjs +0 -1512
  105. package/browser/cjs/CTIIZ0KnyksL075e.cjs +0 -32
  106. package/browser/cjs/CUcC81sgg70TCSkb.cjs +0 -6
  107. package/browser/cjs/DR9eQnRTjdCvZ_vn.cjs +0 -6
  108. package/browser/esm/C3Kam_ffnenXH9Ry.mjs +0 -264
  109. package/browser/esm/CWnC_tpttjXTMAYH.mjs +0 -29
  110. package/browser/esm/D9QqdtRf0J6jc-i7.mjs +0 -21
  111. package/browser/esm/Dfs-JW1Cpyj6GJ8P.mjs +0 -1587
  112. package/browser/esm/DpMJmUGhnNbeI2fN.mjs +0 -24
  113. package/node/esm/Bk7d3p9VfcJCsNVL.mjs +0 -264
  114. package/node/esm/CLf-vRuFGkk8X4S9.mjs +0 -29
  115. package/node/esm/CQR30SbeLa27Szfg.mjs +0 -1587
  116. package/node/esm/DL3QM-qR0v00NdZZ.mjs +0 -16
  117. package/node/esm/u4BUV-OpkSGdvi-w.mjs +0 -14
@@ -1,1587 +0,0 @@
1
- /**
2
- * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.21
3
- *
4
- * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
- * License: The license can be found at https://www.sheetxl.com/license.
6
- */
7
- let c = class {
8
- constructor(e) {
9
- this._worker = null, this._nextId = 1, this._pendingRequests = /* @__PURE__ */ new Map(), this._workerFactory = e;
10
- }
11
- start() {
12
- if (typeof Worker > "u") throw new Error("Web Workers are not supported in this environment.");
13
- return this._worker || (this._worker = this._workerFactory(), this._worker.onmessage = (e) => {
14
- const { id: n, result: t, error: r } = e.data, o = this._pendingRequests.get(n);
15
- if (o) if (this._pendingRequests.delete(n), r) {
16
- const a = new Error(r.message);
17
- a.stack = r.stack, r.cause && (a.cause = r.cause), o.reject(a);
18
- } else o.resolve(t);
19
- }, this._worker.onerror = (e) => {
20
- console.error("Worker error:", e), this._pendingRequests.forEach((n) => {
21
- n.reject(new Error(`Worker failed: ${e.message}`));
22
- }), this._pendingRequests.clear(), this._worker = null;
23
- }), Promise.resolve();
24
- }
25
- execute(e) {
26
- if (!this._worker) throw new Error("Worker is not initialized. Call start() first.");
27
- const n = this._nextId++;
28
- return new Promise((t, r) => {
29
- this._pendingRequests.set(n, { resolve: t, reject: r }), this._worker.postMessage({ id: n, params: e });
30
- });
31
- }
32
- terminate() {
33
- this._worker && (this._worker.terminate(), this._worker = null);
34
- }
35
- };
36
- class u {
37
- constructor(n) {
38
- this._onExecute = n;
39
- }
40
- execute(n) {
41
- return this._onExecute(n);
42
- }
43
- start() {
44
- return Promise.resolve();
45
- }
46
- terminate() {
47
- }
48
- }
49
- const s = `/**
50
- * @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.7.21
51
- *
52
- * (C) 2025-present SheetXL Inc. & Michael T. Ford
53
- * License: The license can be found at https://www.sheetxl.com/license.
54
- */
55
- const W = { Number: "n", String: "s", Boolean: "b", Error: "e", Null: "z" };
56
- var ke, ie, d;
57
- (ie = ke || (ke = {})).Orientation = { Column: "column", Row: "row" }, ie.Orientations = { ...ie.Orientation, Both: "both" }, ie.Direction = { Up: "up", Down: "down", Left: "left", Right: "right" }, ((e) => {
58
- e.Code = { Parse: 0, Null: 1, Div0: 2, Value: 3, Ref: 4, Name: 5, Num: 6, NA: 7, GettingData: 8, Spill: 9, Connect: 10, Blocked: 11, Unknown: 12, Field: 13, Calc: 14, Busy: 16, Python: 19, Timeout: 20 }, e.Label = { Parse: "#PARSE!", Null: "#NULL!", Div0: "#DIV/0!", Value: "#VALUE!", Ref: "#REF!", Name: "#NAME?", Num: "#NUM!", NA: "#N/A", GettingData: "#GETTING_DATA", Spill: "#SPILL!", Connect: "#CONNECT!", Blocked: "#BLOCKED!", Unknown: "#UNKNOWN!", Field: "#FIELD!", Calc: "#CALC!", Busy: "#BUSY!", Python: "#PYTHON!", Timeout: "#TIMEOUT!" };
59
- class t extends Error {
60
- constructor(u, h, fe, B) {
61
- super(fe, B), this._label = h, this._code = u, this.details = B;
62
- }
63
- static {
64
- this.code = e.Code.Unknown;
65
- }
66
- get isFormulaError() {
67
- return !0;
68
- }
69
- getLabel() {
70
- return this._label;
71
- }
72
- getCode() {
73
- return this._code;
74
- }
75
- equals(u) {
76
- return !!u && (this._code === u._code || this._code === u.code);
77
- }
78
- get [Symbol.toStringTag]() {
79
- return "[FormulaError]";
80
- }
81
- toString() {
82
- return this.message || this._label;
83
- }
84
- }
85
- e.Known = t;
86
- class n extends t {
87
- constructor(u, h) {
88
- super(e.Code.Parse, e.Label.Parse, u, h);
89
- }
90
- static {
91
- this.code = e.Code.Parse;
92
- }
93
- getDetails() {
94
- const u = this.details;
95
- return { line: u?.line ?? 1, column: u?.column ?? 1, offset: u?.offset ?? 0, length: u?.length ?? 0 };
96
- }
97
- }
98
- e.Parse = n;
99
- class r extends t {
100
- constructor(u, h) {
101
- super(e.Code.Null, e.Label.Null, u, h);
102
- }
103
- static {
104
- this.code = e.Code.Null;
105
- }
106
- }
107
- e.Null = r;
108
- class o extends t {
109
- constructor(u, h) {
110
- super(e.Code.Div0, e.Label.Div0, u, h);
111
- }
112
- static {
113
- this.code = e.Code.Div0;
114
- }
115
- }
116
- e.Div0 = o;
117
- class a extends t {
118
- constructor(u, h) {
119
- super(e.Code.Value, e.Label.Value, u, h);
120
- }
121
- static {
122
- this.code = e.Code.Value;
123
- }
124
- }
125
- e.Value = a;
126
- class i extends t {
127
- constructor(u, h) {
128
- super(e.Code.Ref, e.Label.Ref, u, h);
129
- }
130
- static {
131
- this.code = e.Code.Ref;
132
- }
133
- }
134
- e.Ref = i;
135
- class l extends t {
136
- constructor(u, h) {
137
- super(e.Code.Name, e.Label.Name, u, h);
138
- }
139
- static {
140
- this.code = e.Code.Name;
141
- }
142
- }
143
- e.Name = l;
144
- class c extends t {
145
- constructor(u, h) {
146
- super(e.Code.Num, e.Label.Num, u, h);
147
- }
148
- static {
149
- this.code = e.Code.Num;
150
- }
151
- }
152
- e.Num = c;
153
- class p extends t {
154
- constructor(u, h) {
155
- super(e.Code.NA, e.Label.NA, u, h);
156
- }
157
- static {
158
- this.code = e.Code.NA;
159
- }
160
- }
161
- e.NA = p;
162
- class w extends t {
163
- constructor(u, h) {
164
- super(e.Code.GettingData, e.Label.GettingData, u, h);
165
- }
166
- static {
167
- this.code = e.Code.GettingData;
168
- }
169
- }
170
- e.GettingData = w;
171
- class g extends t {
172
- constructor(u, h) {
173
- super(e.Code.Spill, e.Label.Spill, u, h);
174
- }
175
- static {
176
- this.code = e.Code.Spill;
177
- }
178
- }
179
- e.Spill = g;
180
- class f extends t {
181
- constructor(u, h) {
182
- super(e.Code.Connect, e.Label.Connect, u, h);
183
- }
184
- static {
185
- this.code = e.Code.Connect;
186
- }
187
- }
188
- e.Connect = f;
189
- class y extends t {
190
- constructor(u, h) {
191
- super(e.Code.Blocked, e.Label.Blocked, u, h);
192
- }
193
- static {
194
- this.code = e.Code.Blocked;
195
- }
196
- }
197
- e.Blocked = y;
198
- class x extends t {
199
- constructor(u, h) {
200
- super(e.Code.Unknown, e.Label.Unknown, u, h);
201
- }
202
- static {
203
- this.code = e.Code.Unknown;
204
- }
205
- }
206
- e.Unknown = x;
207
- class A extends t {
208
- constructor(u, h) {
209
- super(e.Code.Field, e.Label.Field, u, h);
210
- }
211
- static {
212
- this.code = e.Code.Field;
213
- }
214
- }
215
- e.Field = A;
216
- class D extends t {
217
- constructor(u, h) {
218
- super(e.Code.Calc, e.Label.Calc, u, h);
219
- }
220
- static {
221
- this.code = e.Code.Calc;
222
- }
223
- }
224
- e.Calc = D;
225
- class U extends t {
226
- constructor(u, h) {
227
- super(e.Code.Busy, e.Label.Busy, u, h);
228
- }
229
- static {
230
- this.code = e.Code.Busy;
231
- }
232
- }
233
- e.Busy = U;
234
- class I extends t {
235
- constructor(u, h) {
236
- super(e.Code.Python, e.Label.Python, u, h);
237
- }
238
- static {
239
- this.code = e.Code.Python;
240
- }
241
- }
242
- e.Python = I;
243
- class J extends t {
244
- constructor(u, h) {
245
- super(e.Code.Timeout, e.Label.Timeout, u, h);
246
- }
247
- static {
248
- this.code = e.Code.Timeout;
249
- }
250
- }
251
- e.Timeout = J;
252
- })(d || (d = {}));
253
- const _ = {};
254
- _[d.Code.Parse] = d.Parse, _[d.Code.Null] = d.Null, _[d.Code.Div0] = d.Div0, _[d.Code.Value] = d.Value, _[d.Code.Ref] = d.Ref, _[d.Code.Name] = d.Name, _[d.Code.Num] = d.Num, _[d.Code.NA] = d.NA, _[d.Code.GettingData] = d.GettingData, _[d.Code.Spill] = d.Spill, _[d.Code.Connect] = d.Connect, _[d.Code.Blocked] = d.Blocked, _[d.Code.Unknown] = d.Unknown, _[d.Code.Field] = d.Field, _[d.Code.Calc] = d.Calc, _[d.Code.Busy] = d.Busy, _[d.Code.Python] = d.Python, _[d.Code.Timeout] = d.Timeout;
255
- const rt = /* @__PURE__ */ new Map(), _e = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Map(), Le = Object.keys(_);
256
- for (let e = 0; e < Le.length; e++) {
257
- const t = Le[e], n = _[t];
258
- ot.set(d.Label[t], n), at.set(d.Code[t], n);
259
- const r = new n();
260
- rt.set(r.getLabel(), r), _e.set(r.getCode(), r);
261
- }
262
- const Ct = _e.get(d.Code.Unknown);
263
- var T;
264
- (T = d || (d = {})).BuiltIn = { Parse: new T.Parse(), Null: new T.Null(), Div0: new T.Div0(), Value: new T.Value(), Ref: new T.Ref(), Name: new T.Name(), Num: new T.Num(), NA: new T.NA(), GettingData: new T.GettingData(), Spill: new T.Spill(), Connect: new T.Connect(), Blocked: new T.Blocked(), Unknown: new T.Unknown(), Field: new T.Field(), Calc: new T.Calc(), Busy: new T.Busy(), Python: new T.Python(), Timeout: new T.Timeout() }, T.getBuiltInByLabel = (e) => rt.get(e), T.newTypedError = (e, t, n) => {
265
- let r;
266
- return r = typeof e == "string" ? ot.get(e) : at.get(e), r || (r = T.Unknown), new r(t, n);
267
- }, T.getBuiltInById = (e) => _e.get(e) || Ct;
268
- /**
269
- * @license @sheetxl/utils - Utils - Utilities used by most SheetXL components. - v0.7.21
270
- *
271
- * (C) 2025-present SheetXL Inc. & Michael T. Ford
272
- * License: The license can be found at https://www.sheetxl.com/license.
273
- */
274
- const j = { Column: "column", Row: "row" }, vt = Object.freeze({ colIndex: 0, rowIndex: 0 }), Tt = Object.freeze({ colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }), it = (e, t) => e.colStart === t.colStart ? e.rowStart - t.rowStart : e.colStart - t.colStart, lt = (e, t) => e.rowStart === t.rowStart ? e.colStart - t.colStart : e.rowStart - t.rowStart, _t = (e, t) => e.rowEnd === t.rowEnd ? t.colEnd - e.colEnd : t.rowEnd - e.rowEnd, Ot = (e, t) => e.colEnd === t.colEnd ? t.rowEnd - e.rowEnd : t.colEnd - e.colEnd, Ae = (e, t) => e.colIndex === t.colIndex ? e.rowIndex - t.rowIndex : e.colIndex - t.colIndex, Me = (e, t) => e.rowIndex === t.rowIndex ? e.colIndex - t.colIndex : e.rowIndex - t.rowIndex, je = (e, t) => e.rowIndex === t.rowIndex ? t.colIndex - e.colIndex : t.rowIndex - e.rowIndex, Pe = (e, t) => e.colIndex === t.colIndex ? t.rowIndex - e.rowIndex : t.colIndex - e.colIndex, st = (e = j.Row, t = !1) => t ? e !== j.Column ? _t : Ot : e !== j.Column ? lt : it, Fe = (e, t) => e === t || !(!e || !t) && e.rowIndex === t.rowIndex && e.colIndex === t.colIndex, xe = (e, t) => e === t || !(!e || !t) && e.rowStart === t.rowStart && e.rowEnd === t.rowEnd && e.colStart === t.colStart && e.colEnd === t.colEnd, Ce = (e, t) => !(!e || !t) && !(e.colStart > t.colEnd || t.colStart > e.colEnd) && !(e.rowStart > t.rowEnd || t.rowStart > e.rowEnd), De = (e, t) => {
275
- if (e === t) return !0;
276
- if (!e || !t || e.length !== t.length) return !1;
277
- for (let n = 0; n < e.length; n++) if (!xe(e[n], t[n])) return !1;
278
- return !0;
279
- }, me = (e, t, n) => {
280
- if (!e && !t) return null;
281
- if (!e) return n ? t : { ...t };
282
- if (!t) return n ? e : { ...e };
283
- const r = Math.min(e.colStart, t.colStart), o = Math.min(e.rowStart, t.rowStart), a = Math.max(e.colEnd, t.colEnd), i = Math.max(e.rowEnd, t.rowEnd);
284
- let l = n;
285
- return l ? (l.colStart = r, l.rowStart = o, l.colEnd = a, l.rowEnd = i) : l = { colStart: r, rowStart: o, colEnd: a, rowEnd: i }, l;
286
- }, Ue = (e, t) => {
287
- if (!t || t.length === 0) return e;
288
- const n = { ...e };
289
- for (let r = 0; r < t.length; r++) {
290
- const o = t[r];
291
- Ce(n, o) && (n.rowStart = Math.min(n.rowStart, o.rowStart), n.colStart = Math.min(n.colStart, o.colStart), n.rowEnd = Math.max(n.rowEnd, o.rowEnd), n.colEnd = Math.max(n.colEnd, o.colEnd));
292
- }
293
- return n;
294
- }, It = [null, null], Nt = (e, t, n) => {
295
- if (e[0].value === e[1].value) return t;
296
- };
297
- function Be(e, t = 2, n, r = j.Row, o) {
298
- let a = [...e];
299
- if (t <= 0 || e.length <= 1) return a;
300
- let i = r === j.Column, l = 0, c = !1;
301
- do {
302
- const p = a.sort(st(i ? j.Row : j.Column));
303
- a = [], a.push(p[0]);
304
- const w = p.length;
305
- let g = 0, f = p[0], y = f.colStart, x = f.rowStart, A = f.colEnd, D = f.rowEnd;
306
- for (let U = 1; U < w; U++) {
307
- const I = p[U];
308
- let J = !1;
309
- if (J = i ? f && x === I.rowStart && D === I.rowEnd && A + 1 === I.colStart : f && y === I.colStart && A === I.colEnd && D + 1 === I.rowStart, J) {
310
- let E = { colStart: y, rowStart: x, colEnd: i ? I.colEnd : A, rowEnd: i ? D : I.rowEnd };
311
- if (f.value !== void 0 && (E.value = f.value), n) {
312
- const u = o ?? [null, null];
313
- u[0] = f, u[1] = I, E = n(u, E, r);
314
- }
315
- if (E) {
316
- a[g] = E, c = !0, f = E, y = f.colStart, x = f.rowStart, A = f.colEnd, D = f.rowEnd;
317
- continue;
318
- }
319
- }
320
- a[++g] = I, f = I, y = f.colStart, x = f.rowStart, A = f.colEnd, D = f.rowEnd;
321
- }
322
- l++, i = !i, l === 1 && (c = !0);
323
- } while (l < t && c && a.length > 1);
324
- return a;
325
- }
326
- Object.freeze(Object.defineProperty({ __proto__: null, EmptyCell: vt, EmptyRange: Tt, cellToRange: (e, t) => {
327
- if (!e) return null;
328
- let n = t;
329
- return n || (n = { ...e }, delete n.colIndex, delete n.rowIndex), n.colStart = e.colIndex ?? 0, n.rowStart = e.rowIndex ?? 0, n.colEnd = e.colIndex ?? 0, n.rowEnd = e.rowIndex ?? 0, n;
330
- }, columnFirstCellComparator: Ae, columnFirstRangeComparator: it, createCellComparator: (e = j.Row, t = !1) => t ? e !== j.Column ? je : Pe : e !== j.Column ? Me : Ae, createConflatingRanges: (e, t = !1) => {
331
- const n = [];
332
- let r, o, a = Number.MIN_SAFE_INTEGER, i = Number.MIN_SAFE_INTEGER;
333
- return { append: (l, c, p) => {
334
- let w = !0;
335
- const g = p !== void 0;
336
- if (g) {
337
- const x = e ? e(o, p, t) : o === p ? p : void 0;
338
- x === void 0 ? w = !1 : p = x;
339
- }
340
- if (w && c === i + 1 && l === a) return t ? r.rowEnd = c : r.colEnd = c, i = c, void (o = p);
341
- r && n.push(r);
342
- const f = t ? l : c, y = t ? c : l;
343
- r = { colStart: f, rowStart: y, colEnd: f, rowEnd: y }, g && (r.value = p), a = l, i = c, o = p;
344
- }, done: (l) => (r && (n.push(r), r = null), l ? Be(n, 3, l === !0 ? Nt : l, t ? j.Column : j.Row, It) : n) };
345
- }, createRangeComparator: st, defaultRange: (e, t, n) => e ? n ? (n.colStart = e.colStart ?? t.colStart, n.rowStart = e.rowStart ?? t.rowStart, n.colEnd = e.colEnd ?? t.colEnd, n.rowEnd = e.rowEnd ?? t.rowEnd, n) : { colStart: e.colStart ?? t.colStart, rowStart: e.rowStart ?? t.rowStart, colEnd: e.colEnd ?? t.colEnd, rowEnd: e.rowEnd ?? t.rowEnd } : t, extendRangeToIntersectingRanges: Ue, extendRangeToUnionRanges: (e, t) => {
346
- if (!t || t.length === 0) return e;
347
- let n = e, r = null;
348
- for (; !xe(n, r); ) r = n, n = Ue(r, t);
349
- return n;
350
- }, indexOfCoords: (e, t) => {
351
- const n = { colStart: e.colIndex, rowStart: e.rowIndex, colEnd: e.colIndex, rowEnd: e.rowIndex };
352
- for (let r = t.length - 1; r >= 0; r--) if (Ce(n, t[r])) return r;
353
- return -1;
354
- }, intersectRanges: (e, t, n) => {
355
- if (!e) return n ? t : { ...t };
356
- if (!t) return n ? e : { ...e };
357
- if (!e && !t || e.rowStart > t.rowEnd || e.rowEnd < t.rowStart || e.colStart > t.colEnd || e.colEnd < t.colStart) return null;
358
- const r = Math.max(e.colStart, t.colStart), o = Math.max(e.rowStart, t.rowStart), a = Math.min(e.colEnd, t.colEnd), i = Math.min(e.rowEnd, t.rowEnd);
359
- let l = n;
360
- return l ? (l.colStart = r, l.rowStart = o, l.colEnd = a, l.rowEnd = i) : l = { colStart: r, rowStart: o, colEnd: a, rowEnd: i }, l;
361
- }, isCellWithinRange: (e, t) => {
362
- if (!e || !t) return !1;
363
- const n = e.rowIndex;
364
- if (n < t.rowStart || n > t.rowEnd) return !1;
365
- const r = e.colIndex;
366
- return !(r < t.colStart || r > t.colEnd);
367
- }, isEqualCells: Fe, isEqualRanges: xe, isEqualRangesArrays: De, isEqualSelectionCoords: (e, t) => e === t || !(!e || !t) && e.rangeIndex === t.rangeIndex && !!Fe(e.cell, t.cell) && De(e.ranges, t.ranges), isRangeWithinRange: (e, t) => !(e.rowStart < t.rowStart || e.rowEnd > t.rowEnd) && !(e.colStart < t.colStart || e.colEnd > t.colEnd), isRangesIntersect: Ce, isSingleCell: (e) => !!e && e.rowEnd === e.rowStart && e.colStart === e.colEnd, isValidRange: (e) => !!e && !(typeof e.colStart != "number" || e.colStart < 0) && !(typeof e.colEnd != "number" || e.colEnd < e.colStart) && !(typeof e.rowStart != "number" || e.rowStart < 0) && !(typeof e.rowEnd != "number" || e.rowEnd < e.rowStart), mergeRangedValues: Be, reverseColumnFirstCellComparator: Pe, reverseRowFirstCellComparator: je, rowFirstCellComparator: Me, rowFirstRangeComparator: lt, sanitizeRange: (e) => e ? { colStart: e.colIndex ?? e.colStart ?? 0, rowStart: e.rowIndex ?? e.rowStart ?? 0, colEnd: e.colIndex ?? e.colEnd ?? 0, rowEnd: e.rowIndex ?? e.rowEnd ?? 0 } : null, translateRange: (e, t = -e.rowStart, n = -e.colStart, r) => r ? (r.colStart = e.colStart + n, r.rowStart = e.rowStart + t, r.colEnd = e.colEnd + n, r.rowEnd = e.rowEnd + t, r) : { colStart: e.colStart + n, rowStart: e.rowStart + t, colEnd: e.colEnd + n, rowEnd: e.rowEnd + t }, unionRanges: me, unionRangesArrays: (e, t, n) => {
368
- if (!e || e.length === 0) return null;
369
- if (e.length === 1 && !t) return e[0];
370
- let r = e[0];
371
- for (let o = 1; o < e.length; o++) r = me(r, e[o], n);
372
- return t && (r = me(r, t, n)), r;
373
- } }, Symbol.toStringTag, { value: "Module" }));
374
- const S = { html: "text/html", plain: "text/plain", png: "image/png" }, Rt = Object.freeze({ left: 0, top: 0 }), kt = Object.freeze({ left: 0, top: 0, bottom: 0, right: 0 }), Lt = Object.freeze({ x: 0, y: 0, width: 0, height: 0 });
375
- Object.freeze(Object.defineProperty({ __proto__: null, EmptyBounds: Lt, EmptyRect: kt, EmptyTopLeft: Rt }, Symbol.toStringTag, { value: "Module" }));
376
- function At(e) {
377
- const t = Object.prototype.toString.call(e);
378
- return t === "[object RegExp]" || t === "[object Date]" || (function(n) {
379
- return n.$$typeof === Mt;
380
- })(e);
381
- }
382
- const Mt = typeof Symbol == "function" && Symbol.for ? Symbol.for("react.element") : 60103;
383
- function jt(e) {
384
- return /* @__PURE__ */ (function(t) {
385
- return !!t && typeof t == "object";
386
- })(e) && !At(e);
387
- }
388
- function re(e, t) {
389
- return t.clone !== !1 && t.isMergeableObject(e) ? Y((n = e, Array.isArray(n) ? [] : {}), e, t) : e;
390
- var n;
391
- }
392
- function Pt(e, t, n) {
393
- return e.concat(t).map(function(r) {
394
- return re(r, n);
395
- });
396
- }
397
- function $e(e) {
398
- return Object.keys(e).concat((function(t) {
399
- return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(n) {
400
- return Object.propertyIsEnumerable.call(t, n);
401
- }) : [];
402
- })(e));
403
- }
404
- function ze(e, t) {
405
- try {
406
- return t in e;
407
- } catch {
408
- return !1;
409
- }
410
- }
411
- function Ft(e, t, n) {
412
- const r = {};
413
- return n.isMergeableObject(e) && $e(e).forEach(function(o) {
414
- r[o] = re(e[o], n);
415
- }), $e(t).forEach(function(o) {
416
- (function(a, i) {
417
- return ze(a, i) && !(Object.hasOwnProperty.call(a, i) && Object.propertyIsEnumerable.call(a, i));
418
- })(e, o) || (ze(e, o) && n.isMergeableObject(t[o]) ? r[o] = (function(a, i) {
419
- if (!i.customMerge) return Y;
420
- const l = i.customMerge(a);
421
- return typeof l == "function" ? l : Y;
422
- })(o, n)(e[o], t[o], n) : r[o] = re(t[o], n));
423
- }), r;
424
- }
425
- function Y(e, t, n) {
426
- (n = n || {}).arrayMerge = n.arrayMerge || Pt, n.isMergeableObject = n.isMergeableObject || jt, n.cloneUnlessOtherwiseSpecified = re;
427
- const r = Array.isArray(t);
428
- return r === Array.isArray(e) ? r ? n.arrayMerge(e, t, n) : Ft(e, t, n) : re(t, n);
429
- }
430
- Y.all = function(e, t) {
431
- if (!Array.isArray(e)) throw new Error("first argument should be an array");
432
- return e.reduce(function(n, r) {
433
- return Y(n, r, t);
434
- }, {});
435
- };
436
- const we = Object.freeze([]), Dt = Object.freeze({}), Ke = (e) => e, de = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
437
- let t = 16 * Math.random() | 0;
438
- return (e === "x" ? t : 3 & t | 8).toString(16);
439
- }), Ut = (e) => 1 * e, ct = (e, t) => e === t || !(!Array.isArray(e) || !Array.isArray(t) || e.length !== t.length) && e.every((n, r) => n === t[r]), ne = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, ut = (e) => typeof e != "object" || Array.isArray(e) || e === null ? e : (Object.keys(e).forEach(function(t) {
440
- e[t] && typeof e[t] == "object" ? ut(e[t]) : e[t] !== null && e[t] !== void 0 || delete e[t], typeof e[t] == "object" && Object.keys(e[t]).length === 0 && delete e[t];
441
- }), Object.keys(e).length === 0 ? null : e), Bt = (e, t) => !(e !== t && !ct(e, t)) || !!e.isEqual?.(t), dt = (e, t, n = Bt) => {
442
- if (e == null || e === t) return null;
443
- if (!e || typeof e != "object" || Array.isArray(e) || e.isImmutable?.()) return n(e, t) ? null : e;
444
- const r = Object.keys(e);
445
- if (r.length === 0) return null;
446
- let o = !1;
447
- for (let a = 0; a < r.length; a++) {
448
- const i = r[a];
449
- dt(e[i], t?.[i], n) === null && (o = !0, delete e[i]);
450
- }
451
- return o && Object.keys(e).length === 0 ? null : void 0;
452
- }, Ve = typeof performance == "object" && typeof performance.now == "function" ? () => performance.now() : () => Date.now(), qe = (e) => e == null, Ge = (e, t) => !(t.left > e.right || t.right < e.left || t.top > e.bottom || t.bottom < e.top), We = !(typeof window > "u" || !window.document || !window.document.createElement), k = { Windows: "windows", MacOS: "macos", IOS: "ios", Linux: "linux", Android: "android", Safari: "safari", Firefox: "firefox", Node: "node", Unknown: "unknown" }, oe = () => {
453
- if (ft()) return k.Node;
454
- const e = globalThis.navigator !== void 0 && globalThis.navigator.userAgent ? globalThis.navigator.userAgent.toLowerCase() : "";
455
- return e ? /(win32|win64|windows|wince)/i.test(e) ? k.Windows : /(macintosh|macintel|macppc|mac68k|macos)/i.test(e) ? k.MacOS : /(iphone|ipad|ipod)/i.test(e) ? k.IOS : /android/.test(e) ? k.Android : /linux/.test(e) ? k.Linux : /^((?!chrome|android|).)*safari/i.test(e) ? k.Safari : /^((?!chrome|android|Seamonkey).)*firefox/i.test(e) ? k.Firefox : k.Unknown : k.Unknown;
456
- };
457
- function ft() {
458
- return typeof process < "u" && process.release?.name === "node" || (typeof process < "u" && process.browser, !1);
459
- }
460
- const Ye = (e, t = !1) => (document.hasFocus() || t) && (e === document.activeElement || e?.contains(document.activeElement)), $t = Object.freeze(Object.defineProperty({ __proto__: null, EmptyArray: we, EmptyObject: Dt, OSType: k, arrayMove: function(e, t, n) {
461
- const r = e.slice();
462
- return r.splice(n < 0 ? r.length + n : n, 0, r.splice(t, 1)[0]), r;
463
- }, asNumber: (e) => {
464
- const t = Ut(e);
465
- return Number.isFinite(t) ? t : 0;
466
- }, camelToPrettyCase: (e) => e.length === 1 ? e.toUpperCase() : e.replace(/([A-Z])/g, " $1").replace(/^./, function(t) {
467
- return t.toUpperCase();
468
- }).trim(), canUseDOM: We, cancelTimeout: (e) => {
469
- cancelAnimationFrame(e.id);
470
- }, castToString: (e) => e == null || e === void 0 ? "" : typeof e != "string" ? "" + e : e, cloneObject: (e) => qe(e) ? e : JSON.parse(JSON.stringify(e)), consoleWithNoSource: (...e) => new Promise((t) => {
471
- setTimeout(() => {
472
- Function("console.log.apply(console, arguments)").apply(null, e), t();
473
- });
474
- }), debounce: function(e, t = 300, n = !1) {
475
- let r, o, a, i, l = 0;
476
- function c() {
477
- let w = Date.now() - l;
478
- w < t && w >= 0 ? r = setTimeout(c, t - w) : (r = null, n || (i = e.apply(a, o), a = o = null));
479
- }
480
- t == null && (t = 100);
481
- const p = function() {
482
- a = globalThis, o = arguments, l = Date.now();
483
- var w = n && !r;
484
- return r || (r = setTimeout(c, t)), w && (i = e.apply(a, o), a = o = null), i;
485
- };
486
- return p.clear = function() {
487
- r && (clearTimeout(r), r = null);
488
- }, p.flush = function() {
489
- r && (i = e.apply(a, o), a = o = null, clearTimeout(r), r = null);
490
- }, p;
491
- }, deepEqual: function e(t, n) {
492
- if (t === n) return !0;
493
- if (t && n && typeof t == "object" && typeof n == "object") {
494
- if (t.constructor !== n.constructor) return !1;
495
- let r, o, a;
496
- if (Array.isArray(t)) {
497
- if (r = t.length, r != n.length) return !1;
498
- for (o = r; o-- !== 0; ) if (!e(t[o], n[o])) return !1;
499
- return !0;
500
- }
501
- if (t instanceof Map && n instanceof Map) {
502
- if (t.size !== n.size) return !1;
503
- for (o of t.entries()) if (!n.has(o[0])) return !1;
504
- for (o of t.entries()) if (!e(o[1], n.get(o[0]))) return !1;
505
- return !0;
506
- }
507
- if (t instanceof Set && n instanceof Set) {
508
- if (t.size !== n.size) return !1;
509
- for (o of t.entries()) if (!n.has(o[0])) return !1;
510
- return !0;
511
- }
512
- if (ArrayBuffer.isView(t) && ArrayBuffer.isView(n)) {
513
- if (r = t.length, r != n.length) return !1;
514
- for (o = r; o-- !== 0; ) if (t[o] !== n[o]) return !1;
515
- return !0;
516
- }
517
- if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
518
- if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
519
- if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
520
- if (a = Object.keys(t), r = a.length, r !== Object.keys(n).length) return !1;
521
- for (o = r; o-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(n, a[o])) return !1;
522
- for (o = r; o-- !== 0; ) {
523
- let i = a[o];
524
- if ((i !== "_owner" || !t.$$typeof) && !e(t[i], n[i])) return !1;
525
- }
526
- return !0;
527
- }
528
- return t != t && n != n;
529
- }, deepFreeze: function e(t) {
530
- return Object.freeze(t), Object.keys(t).forEach((n) => {
531
- typeof t[n] != "object" || t[n] === null || Object.isFrozen(t[n]) || e(t[n]);
532
- }), t;
533
- }, deepMerge: Y, diffValues: (e, t) => {
534
- const n = {}, r = Object.keys(t), o = r.length;
535
- for (let a = 0; a < o; a++) {
536
- const i = r[a], l = e[i], c = t[i];
537
- l !== c && (n[i] = l === void 0 ? c : l);
538
- }
539
- return Object.keys(n).length === 0 ? null : n;
540
- }, findEqualOrGreater: function(e, t, n = Ke) {
541
- let r = 0, o = e.length - 1;
542
- for (; r <= o; ) {
543
- let a = Math.floor((r + o) / 2), i = n(e[a]);
544
- if (i === t) return a;
545
- i < t ? r = a + 1 : o = a - 1;
546
- }
547
- return r;
548
- }, findEqualOrLesser: function(e, t, n = Ke) {
549
- let r = e.length - 1, o = 0;
550
- for (; r >= o; ) {
551
- let a = Math.floor((r + o) / 2), i = n(e[a]);
552
- if (i === t) return a;
553
- i > t ? r = a - 1 : o = a + 1;
554
- }
555
- return r;
556
- }, findNextStep: (e, t = !0, n = 15, r = 10, o = 400) => {
557
- const a = Math.max(e - r, 0) + (t ? 1 : -1);
558
- return Math.min(o, Math[t ? "ceil" : "floor"](a / n) * n + r);
559
- }, getDPI: () => {
560
- let e = 1;
561
- return typeof window == "object" && (e = window.devicePixelRatio || 1), e;
562
- }, getFromPath: (e, t) => {
563
- const n = t.split(".");
564
- let r = e;
565
- for (let o = 0; o < n.length; o++) {
566
- const a = n[o];
567
- if (!r) return null;
568
- let i = r[a];
569
- if (typeof i == "function" && (i = i.bind(r)()), !i || !ne(i)) return i;
570
- r = i;
571
- }
572
- return r ?? null;
573
- }, getOS: oe, hasFocus: Ye, isDefined: (e) => e != null, isEmpty: (e) => e == null || e === "", isEqualArrays: ct, isEqualBounds: (e, t) => e === t || !(e && !t || t && !e) && e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height, isEqualObjectKeys: (e, t) => {
574
- if (e === t) return !0;
575
- if (e && !t || t && !e) return !1;
576
- const n = Object.keys(e);
577
- if (n.length !== Object.keys(t).length) return !1;
578
- for (let r = 0; r < n.length; r++) if (e[n[r]] !== t[n[r]]) return !1;
579
- return !0;
580
- }, isNode: ft, isNullOrUndefined: qe, isNumeric: (e) => {
581
- const t = 1 * e;
582
- return Number.isFinite(t) && typeof t == "number";
583
- }, isObject: ne, isPromiseLike: (e) => !!e && typeof e.then == "function", isRectInsideRect: (e, t) => e.top >= t.top && e.bottom <= t.bottom && e.left >= t.left && e.right <= t.right, isRectIntersect: Ge, mergeContentful: (...e) => {
584
- const t = e.length;
585
- if (t > 0 && e[t - 1] !== void 0 && !ne(e[t - 1])) return e[t - 1];
586
- let n = e[0] || {};
587
- for (let r = 1; r < t; r++) n = Y(n, e[r] || {}, { arrayMerge: (o, a) => [...a] });
588
- return n;
589
- }, nextTick: (e) => {
590
- typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(() => {
591
- e();
592
- }) : (typeof setImmediate == "function" ? setImmediate : setTimeout)(() => {
593
- e();
594
- });
595
- }, openFileDialog: (e = "*.*") => new Promise((t, n) => {
596
- if (!We) return void n("Unable to open dialog with no dom.");
597
- const r = document.createElement("input");
598
- r.type = "file", r.accept = e;
599
- let o = null, a = !1;
600
- globalThis.addEventListener?.("focus", () => {
601
- setTimeout(() => {
602
- o || a || (a = !0, t(null));
603
- }, 1e3);
604
- }, { once: !0, passive: !0 }), r.onchange = () => {
605
- if (o = r.files[0], o) {
606
- if (a) return void console.warn("File open detected after faux cancel.", o);
607
- t(o);
608
- }
609
- }, r.autofocus = !0, r.click();
610
- }), rafThrottle: (e) => {
611
- let t, n = !1, r = function() {
612
- n = !1, e(t);
613
- };
614
- return function(o) {
615
- t = o, t && t.persist && t.persist(), n || (n = !0, requestAnimationFrame(r));
616
- };
617
- }, removeEmptyProperties: ut, removeEqualValues: dt, removeListenerAll: (e) => {
618
- if (!e) return we;
619
- const t = e.length;
620
- for (let n = 0; n < t; n++) {
621
- const r = e[n];
622
- r && r();
623
- }
624
- return we;
625
- }, requestTimeout: (e, t) => {
626
- const n = Ve(), r = { id: requestAnimationFrame(function o() {
627
- Ve() - n >= t ? e.call(null) : r.id = requestAnimationFrame(o);
628
- }) };
629
- return r;
630
- }, roundAccurately: (e, t = 0) => {
631
- if (e == null || !isFinite(e)) return null;
632
- const n = 10 ** t;
633
- return Number(Math.round(e * n) / n);
634
- }, setToPath: (e, t, n) => {
635
- const r = t.split(".");
636
- let o = e;
637
- if (!o) throw new Error("Can not set path to a null path.");
638
- for (let a = 0; o && a < r.length - 1; a++) {
639
- const i = r[a];
640
- let l = o[i];
641
- if (l == null && (l = {}, o[i] = l), !ne(l)) throw new Error("Can not set path to a non object path.");
642
- o = l;
643
- }
644
- if (typeof n != "number" && typeof n != "boolean" && typeof n != "string" && !ne(n)) throw new Error(\`Can not set path to \${n} that is not a a supported primitive.\`);
645
- return o[r[r.length - 1]] = n, e;
646
- }, splitNumber: (e) => {
647
- let t = Math.abs(e);
648
- if (isNaN(t) || !isFinite(e)) return null;
649
- let n = 0 | t, r = t - n, o = 0, a = 0, i = 1;
650
- if (r > 5e-8) for (; a < 8 && Math.abs(o / i - r) > 5e-8; ) a++, i *= 10, o = Math.round(r * i);
651
- return { ip: Math.trunc(e), fp: o, ipLength: Math.ceil(Math.log10(n + 1)), fpLength: a };
652
- }, subtractRect: (e, t, n = !1) => {
653
- if (!t) return [e];
654
- if (!Ge(e, t)) return [];
655
- const r = [];
656
- let o = e;
657
- const a = () => {
658
- t.top > o.top && t.top < o.bottom && (r.push({ ...o, bottom: t.top }), o = { ...o, top: t.top });
659
- }, i = () => {
660
- t.bottom > o.top && t.bottom < o.bottom && (r.push({ ...o, top: t.bottom }), o = { ...o, bottom: t.bottom });
661
- }, l = () => {
662
- t.right > o.left && t.right < o.right && (r.push({ ...o, left: t.right }), o = { ...o, right: t.right });
663
- }, c = () => {
664
- t.left > o.left && t.left < o.right && (r.push({ ...o, right: t.left }), o = { ...o, left: t.left });
665
- };
666
- return n ? (c(), l(), a(), i()) : (a(), i(), l(), c()), r;
667
- }, textToKey: (e) => e.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(), throttle: function(e, t) {
668
- let n = null;
669
- return (...r) => {
670
- const o = Date.now();
671
- (!n || o - n >= t) && (n = o, e(...r));
672
- };
673
- }, toSafeJSON: function e(t) {
674
- if (t === null || typeof t != "object") return t;
675
- if (typeof t.toJSON == "function") return t.toJSON();
676
- if (Array.isArray(t)) return t.map((r) => e(r));
677
- if (typeof t.toString == "function" && t.toString !== Object.prototype.toString) return t.toString();
678
- const n = {};
679
- for (const r in t) t.hasOwnProperty(r) && (n[r] = e(t[r]));
680
- return n;
681
- }, transpose: (e) => {
682
- if (!e) return e;
683
- const t = e.length, n = e[0].length, r = [];
684
- for (let o = 0; o < n; o++) r[o] = Array(t);
685
- for (let o = 0; o < t; o++) for (let a = 0; a < n; a++) r[a][o] = e[o][a];
686
- return r;
687
- }, uuidV4: de, validEnumValue: (e, t) => {
688
- if (!Object.values(e).includes(t)) throw new Error(\`Invalid type: \${t ?? "null"}. Must be one of: \${Object.values(t).join(", ")}.\`);
689
- }, whenFocus: async (e, t = !1) => new Promise((n) => {
690
- Ye(e, t) ? n(!0) : e.addEventListener("focusin", () => {
691
- n(!0);
692
- }, { once: !0 }), e.focus();
693
- }) }, Symbol.toStringTag, { value: "Module" }));
694
- Object.freeze(Object.defineProperty({ __proto__: null, MESSAGE_ERROR_INVALID_ARG: (e) => \`Invalid argument: '\${e}'.\` }, Symbol.toStringTag, { value: "Module" }));
695
- const pt = (e) => {
696
- const t = new Uint8Array(e), n = t.byteLength;
697
- let r = "";
698
- for (let o = 0; o < n; o++) r += String.fromCharCode(t[o]);
699
- if (typeof window < "u" && typeof globalThis.btoa == "function") return globalThis.btoa(r);
700
- if (typeof Buffer < "u") return Buffer.from(r, "binary").toString("base64");
701
- throw new Error("Unsupported environment");
702
- }, ve = (e) => new Promise((t, n) => {
703
- if (e) if (typeof FileReader < "u") {
704
- const r = new FileReader();
705
- r.onload = () => {
706
- t(r.result);
707
- }, r.onerror = () => {
708
- n(r.error);
709
- }, r.readAsText(e);
710
- } else if (typeof Buffer < "u") {
711
- const r = (o) => Buffer.from(o).toString("utf-8");
712
- e.arrayBuffer().then((o) => {
713
- t(r(o));
714
- }).catch((o) => {
715
- n(o);
716
- });
717
- } else n(new Error("Unsupported environment"));
718
- else t("");
719
- });
720
- Object.freeze(Object.defineProperty({ __proto__: null, DEFAULT_MIME_TYPE: "*/*", arrayBufferToBase64: pt, base64ToArrayBuffer: (e) => {
721
- const t = typeof window < "u" && typeof globalThis.atob == "function" ? globalThis.atob(e) : Buffer.from(e, "base64").toString("binary"), n = t.length, r = new Uint8Array(n);
722
- for (let o = 0; o < n; o++) r[o] = t.charCodeAt(o);
723
- return r.buffer;
724
- }, blobToString: ve }, Symbol.toStringTag, { value: "Module" }));
725
- const ht = "data:image/png;base64,", mt = "Unable to resolve image.", Je = (e) => new Promise(async (t, n) => {
726
- let r = null;
727
- try {
728
- r = new Image(), r.src = e, r.addEventListener("load", function() {
729
- t({ width: r.naturalWidth, height: r.naturalHeight });
730
- }, { once: !0 }), r.addEventListener("error", function() {
731
- URL.revokeObjectURL(e), n("Invalid Image");
732
- }, { once: !0 }), await r.decode("sync");
733
- } catch {
734
- r?.src && URL.revokeObjectURL(r.src);
735
- }
736
- r || n(mt);
737
- }), ye = "image/svg+xml";
738
- Object.freeze(Object.defineProperty({ __proto__: null, DATA_URL_PNG_PREFIX: ht, getImageDataUrl: (e, t = 1) => new Promise(async (n, r) => {
739
- let o = null;
740
- try {
741
- o = new Image(), o.src = e, o.addEventListener("load", function() {
742
- try {
743
- const a = document.createElement("canvas");
744
- a.width = o.naturalWidth, a.height = o.naturalHeight, a.getContext("2d").drawImage(o, 0, 0);
745
- const i = a.toDataURL("image/png", t);
746
- n({ elemImg: o, dataUrl: i });
747
- } catch (a) {
748
- URL.revokeObjectURL(e), r(a);
749
- }
750
- }, { once: !0 }), o.addEventListener("error", function() {
751
- URL.revokeObjectURL(e), r("Invalid Image");
752
- }, { once: !0 }), await o.decode("sync");
753
- } catch {
754
- o?.src && URL.revokeObjectURL(o.src);
755
- }
756
- o || r(mt);
757
- }), loadImageDetails: async (e, t = null) => {
758
- let n = null;
759
- const r = async () => {
760
- try {
761
- const a = t ?? "image/*", i = URL.createObjectURL(new Blob([e], { type: a })), l = await Je(i);
762
- n = { mimeType: a, naturalSize: l, asUrl: i };
763
- } catch {
764
- }
765
- }, o = async () => {
766
- try {
767
- const a = new TextDecoder().decode(e), i = URL.createObjectURL(new Blob([a], { type: ye })), l = await Je(i);
768
- n = { mimeType: t ?? ye, naturalSize: l, asUrl: i, asSVGText: a };
769
- } catch {
770
- }
771
- };
772
- if (t === ye ? await o() : t.startsWith("image/") ? await r() : (await r(), n || await o()), !n) throw new Error("Failed to load image");
773
- return n;
774
- } }, Symbol.toStringTag, { value: "Module" }));
775
- var He, Xe;
776
- (Xe = He || (He = {})).resolveTypedUpdates = (e, t, n, r) => {
777
- if (e === null) return e;
778
- if (e === void 0) return r;
779
- let o = e;
780
- if (t?.shorthand) {
781
- const c = t?.shorthand(e, n);
782
- c !== void 0 && (o = c);
783
- }
784
- if (o !== null && t?.getSubType) {
785
- const c = t.getSubType(o);
786
- c && (t = c);
787
- }
788
- const a = t?.properties, i = t?.arrayType ?? !1;
789
- let l = o;
790
- if (t && t.merge && l && r) l = t.merge(l, r, n);
791
- else if (!i && a) {
792
- const c = Object.keys({ ...o, ...r });
793
- l = null;
794
- const p = c.length;
795
- for (let w = 0; w < p; w++) {
796
- const g = c[w];
797
- let f, y = o[g];
798
- if (y !== void 0) {
799
- const x = a[g];
800
- f = x ? (0, Xe.resolveTypedUpdates)(y, x, n, r?.[g]) : y;
801
- } else f = r?.[g];
802
- f != null && (l = l ?? {}, l[g] = f);
803
- }
804
- }
805
- return l;
806
- };
807
- const Ze = \`The Safari browser does not support advanced copy and paste.
808
- Copy and paste will be limited to within the browser tab.
809
-
810
- Please use Chrome or Edge if external copy and paste is required.\`, ge = \`You do not have permissions to access the clipboard.
811
- All copy and paste operations will be limited to the browser tab.\`, wt = { Safari: \`The Safari browser does not support advanced copy and paste.
812
- Copy and paste will be limited to within the browser tab.
813
-
814
- Please use Chrome or Edge if external copy and paste is required.\`, Perms: ge, PermsWrite: oe() === k.Safari ? Ze : ge, PermsRead: oe() === k.Safari ? Ze : ge }, be = async () => new Promise((e) => {
815
- document.hasFocus() ? e() : globalThis.addEventListener?.("focus", () => {
816
- e();
817
- }, { once: !0 }), document.activeElement.focus?.();
818
- }), Ee = async (e, t, n) => {
819
- if (oe() === k.Safari) return await n(new Error(wt.Safari));
820
- try {
821
- const r = async (i) => {
822
- try {
823
- return await i();
824
- } catch (l) {
825
- if (l.message?.includes("Document is not focused")) return !1;
826
- throw l;
827
- }
828
- }, o = await globalThis?.navigator?.permissions?.query({ name: e, allowWithoutGesture: !0, allowWithoutSanitization: !0 });
829
- let a = !1;
830
- if (o.state === "prompt" && (a = await r(t)), a || o.state !== "granted" || (a = await t()), !a) return await n(new Error(o.state));
831
- } catch (r) {
832
- return r.message === "No valid data on clipboard" || r.name === "DataError" ? void 0 : await n(r);
833
- }
834
- }, yt = async (e) => {
835
- try {
836
- return await e.read({ unsanitized: [S.html] });
837
- } catch {
838
- }
839
- return await e.read();
840
- }, zt = async (e, t) => {
841
- if (!e) return null;
842
- const n = await yt(e);
843
- let r = !1;
844
- for (let o = 0; !r && n && o < n.length; o++) if (r = n[o].types.includes(t), r)
845
- return await n[o].getType(t);
846
- return r ? void 0 : null;
847
- };
848
- if (!globalThis.ClipboardItem) {
849
- const e = (n, r) => new Blob([r], { type: n });
850
- class t {
851
- constructor(r, o) {
852
- this._items = {}, this._types = Object.keys(r);
853
- const a = {}, i = Object.keys(r);
854
- for (let l = 0; l < i.length; l++) {
855
- const c = i[l];
856
- let p = r[c];
857
- a[c] = typeof p == "string" ? e(c, p) : p;
858
- }
859
- this._items = a, this._presentationStyle = o?.presentationStyle ?? "unspecified";
860
- }
861
- get types() {
862
- return this._types;
863
- }
864
- getType(r) {
865
- return Promise.resolve(this._items[r]);
866
- }
867
- supports(r) {
868
- return !0;
869
- }
870
- }
871
- globalThis.ClipboardItem = t;
872
- }
873
- const Te = async (e, t = S.html) => new Promise(async (n, r) => {
874
- try {
875
- const o = await zt(e, t);
876
- if (o) {
877
- const a = new FileReader();
878
- a.onload = () => {
879
- n(a.result);
880
- }, a.onerror = () => {
881
- n("");
882
- }, a.readAsText(o);
883
- } else n("");
884
- } catch (o) {
885
- r(o);
886
- }
887
- }), Qe = async (e, t = S.html) => {
888
- const n = await Te(e, t);
889
- if (!n) return null;
890
- let r = null;
891
- try {
892
- r = new DOMParser().parseFromString(n, S.html);
893
- } catch {
894
- console.warn("Can't parse html from clipboard.");
895
- }
896
- return r;
897
- }, Kt = async (e) => {
898
- e && await e.writeText("");
899
- }, ae = "clipboard-uuid", Q = "web text/uuid", et = (e) => \`<div style="display:none" \${ae}="\${e}"/>\`, Vt = (e, t) => {
900
- let n = null;
901
- try {
902
- const r = new DOMParser().parseFromString(t, S.html);
903
- r.body.firstElementChild.setAttribute(ae, e), n = r.getElementsByTagName("body")[0].innerHTML;
904
- } catch (r) {
905
- console.warn("Can't embed uuid.", r);
906
- }
907
- return n;
908
- }, tt = (e, t) => {
909
- if (!t || !e) return !1;
910
- try {
911
- const n = t.querySelectorAll(\`[\${ae}="\${e}"]\`);
912
- if (n && n.length === 1) return !0;
913
- if (t.querySelector("parsererror")) throw new Error("We are unable to parse node");
914
- return !1;
915
- } catch {
916
- return !1;
917
- }
918
- };
919
- class nt {
920
- constructor(t) {
921
- if (t?.nativeClipboard === void 0 || t?.nativeClipboard === !0) try {
922
- this._nativeClipboard = globalThis?.navigator.clipboard;
923
- } catch {
924
- t?.nativeClipboard === !0 && console.warn("NativeClipboard option set to true but no native clipboard available.");
925
- }
926
- else this._nativeClipboard = t?.nativeClipboard === !1 ? null : t?.nativeClipboard;
927
- this._disableCheckOnFocus = t?.disableCheckOnFocus ?? !1, this._init();
928
- }
929
- async _checkForChanges() {
930
- this._nativeClipboard && this._state && !this._disableCheckOnFocus && await Ee("clipboard-read", async () => {
931
- await be();
932
- const t = await Te(this._nativeClipboard, Q);
933
- if (!this._state || t && t === this._state.uuid) return !0;
934
- const n = await Qe(this._nativeClipboard, S.html);
935
- return !this._state || (tt(this._state.uuid, n) || this.clear(), !0);
936
- }, async (t) => {
937
- t?.message === "denied" || t.message?.includes("Document is not focused") || oe() === k.Safari || console.warn("Unable to detect clipboard changes: ", t);
938
- });
939
- }
940
- _init() {
941
- const t = this;
942
- this._listeners = /* @__PURE__ */ new Map(), this._listenersCapture = /* @__PURE__ */ new Map(), this._state = null, this._nativeClipboard && (this._onFocus = () => {
943
- t._checkForChanges();
944
- }, this._onBlur = () => {
945
- globalThis.addEventListener?.("focus", t._onFocus, { once: !0 });
946
- }, globalThis.addEventListener?.("blur", this._onBlur), this._nativeClipboard.addEventListener("clipboardchange", (n) => {
947
- t._checkForChanges();
948
- }));
949
- }
950
- async read() {
951
- if (!this._nativeClipboard) return this._state?.items ?? null;
952
- const t = this;
953
- return await Ee("clipboard-read", async () => {
954
- if (await be(), this._state?.uuid) {
955
- const n = await Te(this._nativeClipboard, Q);
956
- if (n && n === t._state.uuid) return !0;
957
- const r = await Qe(this._nativeClipboard, S.html);
958
- if (tt(t._state?.uuid, r)) return !0;
959
- }
960
- return t._state = { items: await yt(this._nativeClipboard), uuid: null, ref: null }, this.dispatchEvent(new Event("clipboardread")), !0;
961
- }, async (n) => {
962
- this.dispatchEvent(new Event("clipboarderrorread"));
963
- }), this._state?.items ?? [];
964
- }
965
- async write(t) {
966
- return this._write({ uuid: de(), items: t, ref: null });
967
- }
968
- async _write(t) {
969
- if (!this._nativeClipboard) return this._state = t, this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")), null;
970
- const n = this, r = [], o = t.uuid;
971
- let a = t.items ?? [];
972
- const i = () => {
973
- n._state = { uuid: o, ref: t.ref, items: r }, n.dispatchEvent(new Event("clipboardwrite")), n.dispatchEvent(new Event("clipboardchange"));
974
- };
975
- await Ee("clipboard-write", async () => {
976
- await be(), o && a.length === 0 && (a.push(new ClipboardItem({ [Q]: new Blob([o], { type: Q }) })), a.push(new ClipboardItem({ [S.html]: new Blob([et(o)], { type: S.html }) })));
977
- for (let l = 0; l < Math.min(1, a.length); l++) {
978
- const c = a[l];
979
- let p = c.types.indexOf(S.html), w = null;
980
- if (p !== -1) {
981
- const y = await c.getType(S.html);
982
- w = await ve(y), w && (w = Vt(o, w));
983
- }
984
- if (!w && c.types.includes(S.plain)) {
985
- const y = await c.getType(S.plain);
986
- if (y) {
987
- let x = null;
988
- typeof y == "string" ? (console.warn("text as string", y), x = y) : x = await ve(y), x && (w = \`<div \${ae}="\${o}">\${x}</div>\`);
989
- }
990
- }
991
- if (!w && c.types.includes(S.png)) {
992
- const y = await c.getType(S.png), x = pt(await y.arrayBuffer());
993
- w = \`<div \${ae}="\${o}"><img src="\${ht + x}"/></div>\`;
994
- }
995
- !w && o && (w = et(o));
996
- const g = new Blob([w ?? ""], { type: S.html }), f = {};
997
- for (let y = 0; y < c.types.length; y++) {
998
- const x = c.types[y];
999
- f[x] = y === p ? g : c.getType(x);
1000
- }
1001
- w && p === -1 && (f[S.html] = g), o && (f[Q] = new Blob([o], { type: Q })), r.push(new ClipboardItem(f));
1002
- }
1003
- try {
1004
- r && r.length !== 0 ? await this._nativeClipboard.write(r) : await Kt(this._nativeClipboard);
1005
- } catch (l) {
1006
- l.message?.includes("Document is not focused") || console.warn("Unable to write to native clipboard: ", l);
1007
- }
1008
- return i(), !0;
1009
- }, async (l) => {
1010
- this.dispatchEvent(new Event("clipboarderrorwrite")), i();
1011
- });
1012
- }
1013
- async writeReference(t) {
1014
- if (!t) return void this.clear();
1015
- let n = null;
1016
- const r = {};
1017
- try {
1018
- const a = await t.toText?.() ?? null;
1019
- a && (r[S.plain] = new Blob([a ?? ""], { type: S.plain }));
1020
- } catch (a) {
1021
- n = a;
1022
- }
1023
- try {
1024
- const a = await t.toHtml?.() ?? null;
1025
- a && (r[S.html] = new Blob([a], { type: S.html }));
1026
- } catch (a) {
1027
- n = a, console.warn("export to html", a);
1028
- }
1029
- try {
1030
- const a = await t.toImage?.() ?? null;
1031
- a && (r[S.png] = a);
1032
- } catch (a) {
1033
- n = a, console.warn("export to png", a);
1034
- }
1035
- const o = this._write({ uuid: de(), ref: t, items: Object.keys(r).length > 0 ? [new ClipboardItem(r)] : null });
1036
- if (n) throw n;
1037
- return o;
1038
- }
1039
- clear(t = !1) {
1040
- this._state && (this._state = null, t && this._write({ uuid: null, ref: null, items: null }), this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")));
1041
- }
1042
- async readReference() {
1043
- return await this.read(), this._state?.ref ?? null;
1044
- }
1045
- readText() {
1046
- return new Promise(async (t, n) => {
1047
- const r = await this.read();
1048
- let o = null;
1049
- for (let i = 0; !o && r && i < r.length; i++) r[i].types.includes(S.plain) && (o = await r[i].getType(S.plain));
1050
- if (!o) return void t("");
1051
- const a = new FileReader();
1052
- a.onload = () => {
1053
- t(a.result);
1054
- }, a.readAsText(o), a.onerror = (i) => {
1055
- n(i);
1056
- };
1057
- });
1058
- }
1059
- async writeText(t) {
1060
- const n = [new ClipboardItem({ [S.plain]: new Blob([t], { type: S.plain }) })];
1061
- return this._write({ uuid: de(), items: n, ref: null });
1062
- }
1063
- addEventListener(t, n, r = {}) {
1064
- const o = r?.capture ? this._listenersCapture : this._listeners;
1065
- let a = o.get(t);
1066
- a || (a = /* @__PURE__ */ new Map(), o.set(t, a)), a.set(n, typeof r == "boolean" ? {} : r);
1067
- }
1068
- dispatchEvent(t) {
1069
- if (!t) return;
1070
- const n = (r) => {
1071
- const o = r.get(t.type);
1072
- o && o.forEach((a, i) => {
1073
- try {
1074
- typeof i == "function" ? i(t) : i.handleEvent && i.handleEvent(t), a.once && o.delete(i);
1075
- } catch (l) {
1076
- console.warn(l);
1077
- }
1078
- });
1079
- };
1080
- return n(this._listenersCapture), n(this._listeners), !0;
1081
- }
1082
- removeEventListener(t, n, r) {
1083
- const o = r?.capture ? this._listenersCapture : this._listeners, a = o.get(t);
1084
- a && (a.delete(n), a.size === 0 && o.delete(t));
1085
- }
1086
- close() {
1087
- globalThis.removeEventListener?.("focus", this._onFocus), globalThis.removeEventListener?.("blur", this._onBlur);
1088
- }
1089
- }
1090
- var Se;
1091
- (Se = nt || (nt = {})).ErrorMessages = wt, Se.Global = new Se();
1092
- const qt = "__SHEETXL";
1093
- let ee = null, le = null;
1094
- async function Gt() {
1095
- if (ee)
1096
- return ee;
1097
- if (le) {
1098
- if (await le, !ee)
1099
- throw new Error("ESBuild initialization promise resolved, but instance is not available.");
1100
- return ee;
1101
- }
1102
- let e, t;
1103
- le = new Promise((n, r) => {
1104
- e = n, t = r;
1105
- });
1106
- try {
1107
- const { initialize: n } = await Promise.resolve().then(function() {
1108
- return on;
1109
- });
1110
- return ee = await n(), e(), ee;
1111
- } catch (n) {
1112
- throw console.error("Failed to import or initialize esbuild:", n), le = null, t(n), n;
1113
- }
1114
- }
1115
- const Wt = {
1116
- // ESBuild.TsconfigRaw =
1117
- compilerOptions: {
1118
- target: "esnext"
1119
- }
1120
- };
1121
- async function Yt(e, t, n = "/script.js", r = qt) {
1122
- try {
1123
- const o = await Gt(), a = "@sheetxl/primitives", i = \`
1124
- export const FormulaContext = globalThis.\${r}?.FormulaContext;
1125
- export const ScalarType = globalThis.\${r}?.ScalarType;
1126
- export const Observable = globalThis.\${r}?.Observable;
1127
- export const IRange = globalThis.\${r}?.IRange;
1128
- export const FormulaError = globalThis.\${r}?.FormulaError;
1129
- // Add more exports as needed
1130
- \`, l = {
1131
- // ESBuild.Plugin = {
1132
- name: "sheetxl-esbuild-in-memory",
1133
- setup(p) {
1134
- const w = "sheetxl-" + (/* @__PURE__ */ new Date()).getTime();
1135
- p.onResolve({ filter: new RegExp(\`^(\${n.replace("/", "\\\\/")}|\${a})$\`) }, (g) => ({
1136
- path: g.path,
1137
- namespace: w
1138
- })), p.onResolve({ filter: /.*/ }, (g) => {
1139
- if (g.namespace !== w)
1140
- return console.warn(\`esbuild: Treating import "\${g.path}" as external.\`), { path: g.path, external: !0 };
1141
- }), p.onLoad({ filter: /.*/, namespace: w }, (g) => {
1142
- let f;
1143
- if (g.path === n)
1144
- f = t;
1145
- else if (g.path === a)
1146
- f = i;
1147
- else
1148
- return {
1149
- errors: [{ text: \`Cannot load unknown path in \${w}: \${g.path}\` }]
1150
- };
1151
- return {
1152
- contents: f,
1153
- loader: "ts"
1154
- // leave this as 'ts' so esbuild generates proper sourcemaps
1155
- };
1156
- });
1157
- }
1158
- }, c = await o.build({
1159
- entryPoints: [n],
1160
- // Use the virtual entry point
1161
- bundle: !0,
1162
- // IMPORTANT: Enable bundling
1163
- write: !1,
1164
- // IMPORTANT: Return result in memory
1165
- format: "esm",
1166
- // Output format
1167
- plugins: [l],
1168
- // TODO - later change to external and prepend when executing from ui
1169
- sourcemap: "inline",
1170
- // Generate separate source map string
1171
- tsconfigRaw: Wt,
1172
- // Pass the mapped options
1173
- minify: !0,
1174
- // sourcemap: 'external', // Generate separate source map string
1175
- // Or use 'inline' if you prefer data URLs embedded in the code
1176
- // To suppress warnings about dynamic import() if esbuild complains:
1177
- // supported: { 'dynamic-import': true },
1178
- platform: "neutral"
1179
- // not really needed
1180
- });
1181
- if (c.outputFiles && c.outputFiles.length > 0)
1182
- return c.outputFiles[0].text;
1183
- throw c.errors && c.errors.length > 0 ? new Error(\`esbuild bundling failed: \${c.errors.map((p) => p.text).join(\`
1184
- \`)}\`) : new Error("esbuild did not produce an output file.");
1185
- } catch (o) {
1186
- throw console.error("esbuild bundling process failed:", o), o;
1187
- }
1188
- }
1189
- const Jt = \`
1190
- /**
1191
- * Represents the completion of an asynchronous operation
1192
- */
1193
- interface Promise<T> {
1194
- /**
1195
- * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
1196
- * resolved value cannot be modified from the callback.
1197
- * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
1198
- * @returns A Promise for the completion of the callback.
1199
- */
1200
- finally(onfinally?: (() => void) | undefined | null): Promise<T>;
1201
- }
1202
- \`, Ht = \`
1203
- interface FirstTest {
1204
- isTrue?: boolean;
1205
- }
1206
- \`, Xt = async () => Ht, gt = /* @__PURE__ */ new Map([
1207
- ["IReferenceRange", "r"],
1208
- ["IRange", "l"]
1209
- ]), bt = /* @__PURE__ */ new Map([
1210
- ["IWorkbook", "workbook"],
1211
- ["ISheet", "sheet"],
1212
- ["ICellRanges", "ranges"],
1213
- ["ICellRange", "range"],
1214
- ["IFormulaContext", "context"]
1215
- ]), Oe = (e, t) => {
1216
- Array.from(t.keys()).forEach((r) => {
1217
- const o = t.get(r);
1218
- t.set(\`\${e}.\${r}\`, o);
1219
- });
1220
- }, Zt = /* @__PURE__ */ new Map([
1221
- ["Scalar", "*"],
1222
- ["FormulaError.Known", W.Error],
1223
- ["Date", "Date"],
1224
- ["JSON", "JSON"]
1225
- ]), Qt = /* @__PURE__ */ new Map([
1226
- // Repeating
1227
- ]), Ie = "SheetXL";
1228
- Oe(Ie, gt);
1229
- Oe(Ie, bt);
1230
- Oe(Ie, Qt);
1231
- const en = /* @__PURE__ */ new Map([
1232
- ["Promise", () => ({ async: !0 })],
1233
- // ['PromiseLike', (): Partial<IFunction.ReturnTypeJSON> => {
1234
- // return { async: true };
1235
- // }],
1236
- ["Observable", () => ({ stream: !0 })]
1237
- ]);
1238
- let se = null;
1239
- async function tn() {
1240
- if (se)
1241
- return se;
1242
- try {
1243
- return await (await Promise.resolve().then(function() {
1244
- return ln;
1245
- })).initialize();
1246
- } catch (e) {
1247
- throw se = null, e;
1248
- } finally {
1249
- se = null;
1250
- }
1251
- }
1252
- async function nn(e) {
1253
- const t = e?.source ?? null;
1254
- if (!t) return null;
1255
- const n = (e.disableBundle || e.declarationsOnly) ?? !1, r = [
1256
- Xt(),
1257
- //import('typescript'), // when bundled, but node check causes issues. We could bundle replace isNode but felt hacky
1258
- tn()
1259
- ], o = await Promise.all(r), a = o[0], i = o[1];
1260
- let l = "", c = null;
1261
- const p = [], w = {
1262
- allowJs: !0,
1263
- declaration: !1,
1264
- sourceMap: !1,
1265
- // was true but now bundler will do this
1266
- inlineSourceMap: !1,
1267
- inlineSources: !1,
1268
- isolatedModules: !0,
1269
- preserveConstEnums: !1,
1270
- // types: ['WebWorker'],
1271
- module: 99,
1272
- //"esNext",
1273
- noResolve: !0,
1274
- emitDeclarationOnly: !1,
1275
- target: i.ScriptTarget.ES2020
1276
- // lib: ['webworker', 'es2020', 'esnext.asynciterable'], // Use the webworker lib instead of dom
1277
- }, g = "script", f = \`\${g}.ts\`, y = "lib.d.ts", x = "global.d.ts", A = {
1278
- [f]: t,
1279
- [y]: Jt,
1280
- [x]: a
1281
- }, D = {
1282
- getSourceFile: (s, m, L, P) => i.createSourceFile(s, A[s], i.ScriptTarget.Latest, !0),
1283
- fileExists: (s) => A[s] !== void 0,
1284
- readFile: (s) => A[s],
1285
- writeFile: (s, m) => {
1286
- A[s] = m;
1287
- },
1288
- // not used
1289
- getCurrentDirectory: () => "./",
1290
- getCanonicalFileName: (s) => s,
1291
- useCaseSensitiveFileNames: () => !0,
1292
- getDefaultLibFileName: (s) => y,
1293
- getNewLine: () => \`
1294
- \`
1295
- }, U = i.createProgram([f, x], w, D), I = U.getTypeChecker(), J = U.getSourceFile(f), E = U.emit();
1296
- E.diagnostics.length > 0 && console.warn(E.diagnostics), l = A[\`\${g}.js\`];
1297
- const u = (s, m, L, P) => {
1298
- if (!s) {
1299
- $(s, new Error(\`Type is not defined for '\${m?.name ?? "return"}'.\`));
1300
- return;
1301
- }
1302
- if (s.kind === i.SyntaxKind.NumberKeyword)
1303
- m.scalar = W.Number;
1304
- else if (s.kind === i.SyntaxKind.StringKeyword)
1305
- m.scalar = W.String;
1306
- else if (s.kind === i.SyntaxKind.BooleanKeyword)
1307
- m.scalar = W.Boolean;
1308
- else if (s.kind === i.SyntaxKind.UndefinedKeyword || s.kind === i.SyntaxKind.NullKeyword || s.kind === i.SyntaxKind.VoidKeyword) {
1309
- if (P) {
1310
- $(s, new Error(\`'undefined' is not a valid type for input: '\${s?.parent?.name?.escapedText}'.\`));
1311
- return;
1312
- }
1313
- m.scalar = W.Null;
1314
- } else if (s.kind === i.SyntaxKind.BigIntKeyword)
1315
- m.scalar = W.Number;
1316
- else if (s.kind === i.SyntaxKind.AnyKeyword)
1317
- m.scalar = W.Null;
1318
- else if (s.kind === i.SyntaxKind.ArrayType) {
1319
- const M = s.elementType;
1320
- if (!M) {
1321
- $(s, new Error(\`'Array' must be typed: '\${s?.parent?.name?.escapedText}'.\`));
1322
- return;
1323
- }
1324
- m.arrayDepth = (m.arrayDepth ?? 0) + 1, u(M, m, L, P);
1325
- } else if (s.kind !== i.SyntaxKind.TupleType) {
1326
- if (s.kind === i.SyntaxKind.TypeReference) {
1327
- const M = s.typeName?.getText?.() ?? null, K = gt.get(M);
1328
- let V = !1;
1329
- K && (m.range = K, V = !0);
1330
- const q = Zt.get(M);
1331
- if (q && (m.scalar = q), q !== void 0 && (V = !0), P) {
1332
- const R = bt.get(M);
1333
- if (R)
1334
- return R;
1335
- } else {
1336
- const R = en.get(M);
1337
- if (R) {
1338
- const b = { ...m, ...R() };
1339
- let N = 0;
1340
- if (b.async && N++, b.stream && N++, N > 1) {
1341
- $(s, new Error(\`'\${M}' cannot have multiple modifiers: '\${s?.parent?.name?.escapedText}'.\`));
1342
- return;
1343
- }
1344
- m = b, V = !0;
1345
- }
1346
- }
1347
- if (!V) {
1348
- $("node", new Error(\`'\${M}' is not a valid type: '\${s?.parent?.name?.escapedText}'.\`));
1349
- return;
1350
- }
1351
- const H = s.typeArguments;
1352
- if (H) {
1353
- if (H.length !== 1) {
1354
- $(s, new Error(\`'\${M}' must be typed with exactly 1 type: '\${s?.parent?.name?.escapedText}'.\`));
1355
- return;
1356
- }
1357
- u(H[0], m, L, P);
1358
- }
1359
- }
1360
- }
1361
- }, h = (s) => (i.getCombinedModifierFlags(s) & i.ModifierFlags.Export) !== 0, fe = (s) => (i.getCombinedModifierFlags(s) & i.ModifierFlags.Default) !== 0, B = [], $ = (s, m) => {
1362
- B.push(m);
1363
- };
1364
- if (i.forEachChild(J, (s) => {
1365
- if (h(s) && i.isFunctionDeclaration(s)) {
1366
- const m = {}, L = {
1367
- parameters: {}
1368
- }, P = s?.name?.getText();
1369
- try {
1370
- m.name = P;
1371
- const K = I.getSymbolAtLocation(s.name).getDocumentationComment(I);
1372
- if (K && K.length > 0 && K[0].text) {
1373
- let R = K[0].text;
1374
- R = R.replace(/[\\r\\n]+/g, "\\\\n").trim(), L.summary = R;
1375
- }
1376
- const V = {};
1377
- u(s.type, V, m, !1), m.returnType = V;
1378
- const q = {};
1379
- fe(s) && (q.default = !0, c = P), Object.keys(q).length > 0 && (m.behavior = q), m.parameters = [];
1380
- const H = /* @__PURE__ */ new Map();
1381
- for (let R = 0; R < s.parameters.length; R++) {
1382
- const b = s.parameters[R], N = {};
1383
- N.name = b.name?.getText();
1384
- const X = u(b.type, N, m, !0);
1385
- if (X) {
1386
- if (m.parameters.length !== 0) {
1387
- const F = s?.parent?.name?.getText();
1388
- $(s, new Error(\`'\${m.name}' contexts must be the first parameter: '\${F}'.\`));
1389
- return;
1390
- }
1391
- m.context = X;
1392
- continue;
1393
- }
1394
- const z = !((b.initializer === void 0 || b.initializer === null) && (b.questionToken === void 0 || b.questionToken === null));
1395
- let v;
1396
- if (z && (N.optional = !0, b.initializer))
1397
- try {
1398
- b.initializer.kind === i.SyntaxKind.StringLiteral ? v = b.initializer.text : b.initializer.kind === i.SyntaxKind.NumericLiteral ? v = parseFloat(b.initializer.text) : b.initializer.kind === i.SyntaxKind.TrueKeyword || b.initializer.kind === i.SyntaxKind.FalseKeyword ? v = b.initializer.kind === i.SyntaxKind.TrueKeyword : b.initializer.kind === i.SyntaxKind.NullKeyword ? v = null : b.initializer.kind === i.SyntaxKind.ObjectLiteralExpression || b.initializer.kind === i.SyntaxKind.ArrayLiteralExpression ? v = b.initializer.getText() : v = b.initializer.getText?.();
1399
- } catch (O) {
1400
- console.warn(\`Couldn't extract default value for parameter '\${N.name}'\`, O);
1401
- }
1402
- b.dotDotDotToken && (N.rest = !0), m.parameters.push(N);
1403
- const C = { description: "" };
1404
- L.parameters[N.name] = C;
1405
- const G = I.getSymbolAtLocation(b.name).getDocumentationComment(I);
1406
- G && G.length > 0 && G[0].text && (C.description = G[0].text), v !== void 0 && (C.defaultValue = v), H.set(N.name, N);
1407
- }
1408
- if (s.jsDoc && s.jsDoc.length > 0) {
1409
- const R = s.jsDoc;
1410
- for (let b = 0; b < R.length; b++) {
1411
- const N = R[b]?.tags;
1412
- if (N)
1413
- for (let X = 0; X < N.length; X++) {
1414
- const z = N[X];
1415
- let v = z?.tagName?.text;
1416
- if (!v) continue;
1417
- v = v.toLowerCase();
1418
- let C = z.comment;
1419
- const G = v === "hidden";
1420
- if (!(typeof C != "string" && !G) && (typeof C == "string" && (C = C.replace(/[\\r\\n]+/g, "\\\\n").trim()), !(!G && C && (C = C.split(/\\\\n/)[0], !C || C.length === 0)))) {
1421
- if (C && typeof C == "string") {
1422
- const O = /\\{@link(code|plain)?\\s+([^}|]+)(?:\\s*\\|\\s*([^}]+))?\\}/g;
1423
- let F, Z = C, te = [];
1424
- for (; (F = O.exec(C)) !== null; ) {
1425
- const [pe, he, St, Re] = F, xt = [St.trim()];
1426
- Re && xt.push(Re.trim());
1427
- }
1428
- C = Z, te.length > 0 && v === "see" && (L.links || (L.links = []), L.links.push(...te));
1429
- }
1430
- if (v === "name") {
1431
- const O = C;
1432
- O !== P && (L.name = O);
1433
- } else if (v === "description") {
1434
- const O = C;
1435
- } else if (v === "summary") {
1436
- const O = C;
1437
- O && (L.summary = O);
1438
- } else if (v === "param") {
1439
- const O = z.name?.text, F = H.get(O);
1440
- if (!F) {
1441
- B.push(new Error(\`Parameter '\${O}' not found in function '\${P}'.\`));
1442
- continue;
1443
- }
1444
- if (z.typeExpression && z.typeExpression.type)
1445
- try {
1446
- const Z = z.typeExpression.type;
1447
- if (Z.kind === i.SyntaxKind.UnionType) {
1448
- const te = [];
1449
- F.enums = te, Z.types.forEach((pe) => {
1450
- if (pe.kind === i.SyntaxKind.LiteralType) {
1451
- const he = pe.literal.text;
1452
- he && te.push(he);
1453
- }
1454
- });
1455
- }
1456
- } catch (Z) {
1457
- console.warn("Error parsing JSDoc type expression:", Z);
1458
- }
1459
- } else if (v === "returns" || v === "return")
1460
- m.returnType.description = C;
1461
- else if (v === "category")
1462
- L.category = C;
1463
- else if (v === "hidden") {
1464
- let O = !0;
1465
- const F = C?.toLowerCase();
1466
- F === "false" ? O = !1 : F !== "true" && (O = C), O !== !1 && (L.hidden = O ?? !0);
1467
- }
1468
- }
1469
- }
1470
- }
1471
- }
1472
- Object.keys(m.returnType).length === 0 && delete m.returnType, p.push([m, L]);
1473
- } catch (M) {
1474
- $(s, new Error(\`'\${P}': \${M.message}\`));
1475
- }
1476
- }
1477
- }), B.length > 0)
1478
- throw console.warn(B), new Error("There were compilation errors.", { cause: B });
1479
- if (p.length === 0)
1480
- throw new Error("No exported functions.");
1481
- const Et = \`\${$t.uuidV4()}-script\`;
1482
- try {
1483
- !n && B.length === 0 && (l = await Yt(i, l, g));
1484
- } catch {
1485
- console.warn("Error bundling script");
1486
- }
1487
- const Ne = {
1488
- functions: p,
1489
- commitId: Et,
1490
- source: t,
1491
- name: "Script",
1492
- language: "typescript",
1493
- // default
1494
- compiled: l
1495
- };
1496
- return c && (Ne.autoRun = c), Ne;
1497
- }
1498
- self.addEventListener("message", async (e) => {
1499
- const { id: t, params: n } = e.data;
1500
- try {
1501
- const r = await nn(n);
1502
- self.postMessage({ id: t, result: r, error: null });
1503
- } catch (r) {
1504
- self.postMessage({
1505
- id: t,
1506
- result: null,
1507
- error: {
1508
- message: r.message,
1509
- stack: r.stack,
1510
- cause: r.cause
1511
- }
1512
- });
1513
- }
1514
- });
1515
- let ce = null;
1516
- async function rn() {
1517
- return ce || (ce = new Promise(async (e, t) => {
1518
- try {
1519
- const n = "0.20.2", r = \`https://esm.sh/esbuild-wasm@\${n}\`, o = \`https://esm.sh/esbuild-wasm@\${n}/esbuild.wasm\`, i = (await import(
1520
- /* webpackIgnore: true */
1521
- /* @vite-ignore */
1522
- r
1523
- )).default;
1524
- await i.initialize({
1525
- wasmURL: o,
1526
- // Provide the specific WASM URL
1527
- worker: !1
1528
- // Keep processing on the current thread
1529
- }), e(i);
1530
- } catch (n) {
1531
- console.error("Error initializing esbuild:", n), t(n);
1532
- }
1533
- }), ce);
1534
- }
1535
- var on = /* @__PURE__ */ Object.freeze({
1536
- __proto__: null,
1537
- initialize: rn
1538
- });
1539
- let ue = null;
1540
- async function an() {
1541
- return ue || (ue = new Promise(async (e, t) => {
1542
- let n = null;
1543
- try {
1544
- n = await import("https://esm.sh/typescript@5.7.2");
1545
- } catch (r) {
1546
- console.error("Error initializing Browser TypeScript module:", r);
1547
- }
1548
- n || console.log("use script fallback"), e(n);
1549
- }), ue);
1550
- }
1551
- var ln = /* @__PURE__ */ Object.freeze({
1552
- __proto__: null,
1553
- initialize: an
1554
- });
1555
- `, i = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", s], { type: "text/javascript;charset=utf-8" });
1556
- function d(e) {
1557
- let n;
1558
- try {
1559
- if (n = i && (self.URL || self.webkitURL).createObjectURL(i), !n) throw "";
1560
- const t = new Worker(n, { type: "module", name: e?.name });
1561
- return t.addEventListener("error", () => {
1562
- (self.URL || self.webkitURL).revokeObjectURL(n);
1563
- }), t;
1564
- } catch {
1565
- return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(s), { type: "module", name: e?.name });
1566
- }
1567
- }
1568
- async function p() {
1569
- if (typeof process < "u" && process.versions?.node && typeof Worker > "u")
1570
- return await l();
1571
- if (typeof Worker < "u") {
1572
- const e = new c(() => new d());
1573
- try {
1574
- return await e.start(), e;
1575
- } catch (n) {
1576
- console.error("Failed to start TypescriptCompiler worker reverting to fallback:", n);
1577
- }
1578
- }
1579
- return await l();
1580
- }
1581
- const l = async () => {
1582
- const { compileModule: e } = await import("./C3Kam_ffnenXH9Ry.mjs"), n = new u((t) => e(t));
1583
- return await n.start(), n;
1584
- };
1585
- export {
1586
- p as createCompilerWorker
1587
- };