@sheetxl/scripting 0.1.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,828 @@
1
+ /**
2
+ * @license @sheetxl/scripting - SheetXL scripting utilities including TypeScript compilation. - v0.0.0
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
+ /**
8
+ * @license @sheetxl/utils - Utils - Utilities used by most SheetXL components. - v0.1.93
9
+ *
10
+ * (C) 2025-present SheetXL Inc. & Michael T. Ford
11
+ * License: The license can be found at https://www.sheetxl.com/license.
12
+ */
13
+ const h = "text/html", b = "text/plain", L = "image/png", Tt = Object.freeze({ left: 0, top: 0 }), Ct = Object.freeze({ left: 0, top: 0, bottom: 0, right: 0 }), Mt = Object.freeze({ x: 0, y: 0, width: 0, height: 0 });
14
+ Object.freeze(Object.defineProperty({ __proto__: null, EmptyBounds: Mt, EmptyRect: Ct, EmptyTopLeft: Tt }, Symbol.toStringTag, { value: "Module" }));
15
+ const m = "column", j = "row", Rt = Object.freeze({ colIndex: 0, rowIndex: 0 }), At = Object.freeze({ colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }), yt = (e, t) => e.colStart === t.colStart ? e.rowStart - t.rowStart : e.colStart - t.colStart, gt = (e, t) => e.rowStart === t.rowStart ? e.colStart - t.colStart : e.rowStart - t.rowStart, Ft = (e, t) => e.rowEnd === t.rowEnd ? t.colEnd - e.colEnd : t.rowEnd - e.rowEnd, Lt = (e, t) => e.colEnd === t.colEnd ? t.rowEnd - e.rowEnd : t.colEnd - e.colEnd, J = (e, t) => e.colIndex === t.colIndex ? e.rowIndex - t.rowIndex : e.colIndex - t.colIndex, H = (e, t) => e.rowIndex === t.rowIndex ? e.colIndex - t.colIndex : e.rowIndex - t.rowIndex, bt = (e = j, t = !1) => t ? e !== m ? Ft : Lt : e !== m ? gt : yt, K = (e, t) => e === t || !(!e || !t) && e.rowIndex === t.rowIndex && e.colIndex === t.colIndex, D = (e, t) => e === t || !(!e || !t) && e.rowStart === t.rowStart && e.rowEnd === t.rowEnd && e.colStart === t.colStart && e.colEnd === t.colEnd, $ = (e, t) => !(!e || !t || e.colStart > t.colEnd || t.colStart > e.colEnd || e.rowStart > t.rowEnd || t.rowStart > e.rowEnd), Y = (e, t) => {
16
+ if (e === t) return !0;
17
+ if (!e || !t || e.length !== t.length) return !1;
18
+ for (let n = 0; n < e.length; n++) if (!D(e[n], t[n])) return !1;
19
+ return !0;
20
+ }, U = (e, t, n) => {
21
+ if (!e && !t) return null;
22
+ if (!e) return n ? t : { ...t };
23
+ if (!t) return n ? e : { ...e };
24
+ 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);
25
+ let l = n;
26
+ return l ? (l.colStart = r, l.rowStart = o, l.colEnd = a, l.rowEnd = i) : l = { colStart: r, rowStart: o, colEnd: a, rowEnd: i }, l;
27
+ }, Z = (e, t) => {
28
+ if (!t || t.length === 0) return e;
29
+ const n = { ...e };
30
+ for (let r = 0; r < t.length; r++) {
31
+ const o = t[r];
32
+ $(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));
33
+ }
34
+ return n;
35
+ }, Ut = [null, null], Pt = (e, t, n) => {
36
+ if (e[0].value === e[1].value) return t;
37
+ };
38
+ function X(e, t = 2, n, r = j, o) {
39
+ let a = [...e];
40
+ if (t <= 0 || e.length <= 1) return a;
41
+ let i = r === m, l = 0, s = !1;
42
+ do {
43
+ const c = a.sort(bt(i ? j : m));
44
+ a = [], a.push(c[0]);
45
+ const d = c.length;
46
+ let w = 0, u = c[0], f = u.colStart, p = u.rowStart, x = u.colEnd, O = u.rowEnd;
47
+ for (let A = 1; A < d; A++) {
48
+ const g = c[A];
49
+ let G = !1;
50
+ if (G = i ? u && p === g.rowStart && O === g.rowEnd && x + 1 === g.colStart : u && f === g.colStart && x === g.colEnd && O + 1 === g.rowStart, G) {
51
+ let S = { colStart: f, rowStart: p, colEnd: i ? g.colEnd : x, rowEnd: i ? O : g.rowEnd };
52
+ if (u.value !== void 0 && (S.value = u.value), n) {
53
+ const F = o ?? [null, null];
54
+ F[0] = u, F[1] = g, S = n(F, S, r);
55
+ }
56
+ if (S) {
57
+ a[w] = S, s = !0, u = S, f = u.colStart, p = u.rowStart, x = u.colEnd, O = u.rowEnd;
58
+ continue;
59
+ }
60
+ }
61
+ a[++w] = g, u = g, f = u.colStart, p = u.rowStart, x = u.colEnd, O = u.rowEnd;
62
+ }
63
+ l++, i = !i, l === 1 && (s = !0);
64
+ } while (l < t && s && a.length > 1);
65
+ return a;
66
+ }
67
+ Object.freeze(Object.defineProperty({ __proto__: null, EmptyCell: Rt, EmptyRange: At, cellToRange: (e, t) => {
68
+ if (!e) return null;
69
+ let n = t;
70
+ 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;
71
+ }, columnFirstCellComparator: J, columnFirstRangeComparator: yt, createCellComparator: (e = j, t = !1) => t ? e !== m ? (n, r) => n.rowIndex === r.rowIndex ? r.colIndex - n.colIndex : r.rowIndex - n.rowIndex : (n, r) => n.colIndex === r.colIndex ? r.rowIndex - n.rowIndex : r.colIndex - n.colIndex : e !== m ? H : J, createConflatingRanges: (e, t = !1) => {
72
+ const n = [];
73
+ let r, o, a = Number.MIN_SAFE_INTEGER, i = Number.MIN_SAFE_INTEGER;
74
+ return { append: (l, s, c) => {
75
+ let d = !0;
76
+ const w = c !== void 0;
77
+ if (w) {
78
+ const p = e ? e(o, c, t) : o === c ? c : void 0;
79
+ p === void 0 ? d = !1 : c = p;
80
+ }
81
+ if (d && s === i + 1 && l === a) return t ? r.rowEnd = s : r.colEnd = s, i = s, void (o = c);
82
+ r && n.push(r);
83
+ const u = t ? l : s, f = t ? s : l;
84
+ r = { colStart: u, rowStart: f, colEnd: u, rowEnd: f }, w && (r.value = c), a = l, i = s, o = c;
85
+ }, done: (l) => (r && (n.push(r), r = null), l ? X(n, 3, l === !0 ? Pt : l, t ? m : j, Ut) : n) };
86
+ }, createRangeComparator: bt, 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: Z, extendRangeToUnionRanges: (e, t) => {
87
+ if (!t || t.length === 0) return e;
88
+ let n = e, r = null;
89
+ for (; !D(n, r); ) r = n, n = Z(r, t);
90
+ return n;
91
+ }, indexOfCoords: (e, t) => {
92
+ const n = { colStart: e.colIndex, rowStart: e.rowIndex, colEnd: e.colIndex, rowEnd: e.rowIndex };
93
+ for (let r = t.length - 1; r >= 0; r--) if ($(n, t[r])) return r;
94
+ return -1;
95
+ }, intersectRanges: (e, t, n) => {
96
+ if (!e) return n ? t : { ...t };
97
+ if (!t) return n ? e : { ...e };
98
+ if (!e && !t || e.rowStart > t.rowEnd || e.rowEnd < t.rowStart || e.colStart > t.colEnd || e.colEnd < t.colStart) return null;
99
+ 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);
100
+ let l = n;
101
+ return l ? (l.colStart = r, l.rowStart = o, l.colEnd = a, l.rowEnd = i) : l = { colStart: r, rowStart: o, colEnd: a, rowEnd: i }, l;
102
+ }, isCellWithinRange: (e, t) => !(!e || !t || e.rowIndex < t.rowStart || e.rowIndex > t.rowEnd || e.colIndex < t.colStart || e.colIndex > t.colEnd), isEqualCells: K, isEqualRanges: D, isEqualRangesArrays: Y, isEqualSelectionCoords: (e, t) => e === t || !(!e || !t) && e.rangeIndex === t.rangeIndex && !!K(e.cell, t.cell) && Y(e.ranges, t.ranges), isRangeWithinRange: (e, t) => !(e.rowStart < t.rowStart || e.rowEnd > t.rowEnd || e.colStart < t.colStart || e.colEnd > t.colEnd), isRangesIntersect: $, 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: X, rowFirstCellComparator: H, rowFirstRangeComparator: gt, 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: U, unionRangesArrays: (e, t, n) => {
103
+ if (!e || e.length === 0) return null;
104
+ if (e.length === 1 && !t) return e[0];
105
+ let r = e[0];
106
+ for (let o = 1; o < e.length; o++) r = U(r, e[o], n);
107
+ return t && (r = U(r, t, n)), r;
108
+ } }, Symbol.toStringTag, { value: "Module" }));
109
+ const kt = typeof Symbol == "function" && Symbol.for ? Symbol.for("react.element") : 60103;
110
+ function Nt(e) {
111
+ return /* @__PURE__ */ function(t) {
112
+ return !!t && typeof t == "object";
113
+ }(e) && !function(t) {
114
+ const n = Object.prototype.toString.call(t);
115
+ return n === "[object RegExp]" || n === "[object Date]" || t.$$typeof === kt;
116
+ }(e);
117
+ }
118
+ function I(e, t) {
119
+ return t.clone !== !1 && t.isMergeableObject(e) ? E((n = e, Array.isArray(n) ? [] : {}), e, t) : e;
120
+ var n;
121
+ }
122
+ function Bt(e, t, n) {
123
+ return e.concat(t).map(function(r) {
124
+ return I(r, n);
125
+ });
126
+ }
127
+ function Q(e) {
128
+ return Object.keys(e).concat((t = e, Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(n) {
129
+ return Object.propertyIsEnumerable.call(t, n);
130
+ }) : []));
131
+ var t;
132
+ }
133
+ function tt(e, t) {
134
+ try {
135
+ return t in e;
136
+ } catch {
137
+ return !1;
138
+ }
139
+ }
140
+ function E(e, t, n) {
141
+ (n = n || {}).arrayMerge = n.arrayMerge || Bt, n.isMergeableObject = n.isMergeableObject || Nt, n.cloneUnlessOtherwiseSpecified = I;
142
+ const r = Array.isArray(t);
143
+ return r === Array.isArray(e) ? r ? n.arrayMerge(e, t, n) : function(o, a, i) {
144
+ const l = {};
145
+ return i.isMergeableObject(o) && Q(o).forEach(function(s) {
146
+ l[s] = I(o[s], i);
147
+ }), Q(a).forEach(function(s) {
148
+ var c, d;
149
+ tt(c = o, d = s) && (!Object.hasOwnProperty.call(c, d) || !Object.propertyIsEnumerable.call(c, d)) || (tt(o, s) && i.isMergeableObject(a[s]) ? l[s] = function(w, u) {
150
+ if (!u.customMerge) return E;
151
+ const f = u.customMerge(w);
152
+ return typeof f == "function" ? f : E;
153
+ }(s, i)(o[s], a[s], i) : l[s] = I(a[s], i));
154
+ }), l;
155
+ }(e, t, n) : I(t, n);
156
+ }
157
+ E.all = function(e, t) {
158
+ if (!Array.isArray(e)) throw new Error("first argument should be an array");
159
+ return e.reduce(function(n, r) {
160
+ return E(n, r, t);
161
+ }, {});
162
+ };
163
+ const zt = Object.freeze([]), qt = Object.freeze({}), et = (e) => e, R = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
164
+ let t = 16 * Math.random() | 0;
165
+ return (e === "x" ? t : 3 & t | 8).toString(16);
166
+ }), mt = (e, t) => e === t || !(!Array.isArray(e) || !Array.isArray(t) || e.length !== t.length) && e.every((n, r) => n === t[r]), _ = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, Et = (e) => typeof e != "object" || Array.isArray(e) || e === null ? e : (Object.keys(e).forEach(function(t) {
167
+ e[t] && typeof e[t] == "object" ? Et(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];
168
+ }), Object.keys(e).length === 0 ? null : e), Dt = (e, t) => !(e !== t && !mt(e, t) && !e.isEqual?.(t)), St = (e, t, n = Dt) => {
169
+ if (e == null || e === t) return null;
170
+ if (!e || typeof e != "object" || Array.isArray(e) || e.isImmutable?.()) return n(e, t) ? null : e;
171
+ const r = Object.keys(e);
172
+ if (r.length === 0) return null;
173
+ let o = !1;
174
+ for (let a = 0; a < r.length; a++) {
175
+ const i = r[a];
176
+ St(e[i], t?.[i], n) === null && (o = !0, delete e[i]);
177
+ }
178
+ return o && Object.keys(e).length === 0 ? null : void 0;
179
+ }, nt = typeof performance == "object" && typeof performance.now == "function" ? () => performance.now() : () => Date.now(), rt = (e) => e == null, ot = (e, t) => !(t.left > e.right || t.right < e.left || t.top > e.bottom || t.bottom < e.top), at = !(typeof window > "u" || !window.document || !window.document.createElement), y = { Windows: "windows", MacOS: "macos", IOS: "ios", Linux: "linux", Android: "android", Safari: "safari", Firefox: "firefox", Node: "node", Unknown: "unknown" }, T = () => {
180
+ if (vt()) return y.Node;
181
+ const e = globalThis.navigator !== void 0 && globalThis.navigator.userAgent ? globalThis.navigator.userAgent.toLowerCase() : "";
182
+ return e ? /(win32|win64|windows|wince)/i.test(e) ? y.Windows : /(macintosh|macintel|macppc|mac68k|macos)/i.test(e) ? y.MacOS : /(iphone|ipad|ipod)/i.test(e) ? y.IOS : /android/.test(e) ? y.Android : /linux/.test(e) ? y.Linux : /^((?!chrome|android|).)*safari/i.test(e) ? y.Safari : /^((?!chrome|android|Seamonkey).)*firefox/i.test(e) ? y.Firefox : y.Unknown : y.Unknown;
183
+ };
184
+ function vt() {
185
+ return typeof process < "u" && process.release?.name === "node" || (typeof process < "u" && process.browser, !1);
186
+ }
187
+ const it = (e, t = !1) => (document.hasFocus() || t) && (e === document.activeElement || e?.contains(document.activeElement)), $t = Object.freeze(Object.defineProperty({ __proto__: null, EmptyArray: zt, EmptyObject: qt, OSType: y, arrayMove: function(e, t, n) {
188
+ const r = e.slice();
189
+ return r.splice(n < 0 ? r.length + n : n, 0, r.splice(t, 1)[0]), r;
190
+ }, asNumber: (e) => {
191
+ const t = ((n) => 1 * n)(e);
192
+ return Number.isFinite(t) ? t : 0;
193
+ }, camelToPrettyCase: (e) => e.length === 1 ? e.toUpperCase() : e.replace(/([A-Z])/g, " $1").replace(/^./, function(t) {
194
+ return t.toUpperCase();
195
+ }).trim(), canUseDOM: at, cancelTimeout: (e) => {
196
+ cancelAnimationFrame(e.id);
197
+ }, castToString: (e) => e == null || e === void 0 ? "" : typeof e != "string" ? "" + e : e, cloneObject: (e) => rt(e) ? e : JSON.parse(JSON.stringify(e)), consoleWithNoSource: (...e) => new Promise((t) => {
198
+ setTimeout(() => {
199
+ Function("console.log.apply(console, arguments)").apply(null, e), t();
200
+ });
201
+ }), debounce: function(e, t = 300, n = !1) {
202
+ let r, o, a, i, l = 0;
203
+ function s() {
204
+ let d = Date.now() - l;
205
+ d < t && d >= 0 ? r = setTimeout(s, t - d) : (r = null, n || (i = e.apply(a, o), a = o = null));
206
+ }
207
+ t == null && (t = 100);
208
+ const c = function() {
209
+ a = globalThis, o = arguments, l = Date.now();
210
+ var d = n && !r;
211
+ return r || (r = setTimeout(s, t)), d && (i = e.apply(a, o), a = o = null), i;
212
+ };
213
+ return c.clear = function() {
214
+ r && (clearTimeout(r), r = null);
215
+ }, c.flush = function() {
216
+ r && (i = e.apply(a, o), a = o = null, clearTimeout(r), r = null);
217
+ }, c;
218
+ }, deepEqual: function e(t, n) {
219
+ if (t === n) return !0;
220
+ if (t && n && typeof t == "object" && typeof n == "object") {
221
+ if (t.constructor !== n.constructor) return !1;
222
+ let r, o, a;
223
+ if (Array.isArray(t)) {
224
+ if (r = t.length, r != n.length) return !1;
225
+ for (o = r; o-- !== 0; ) if (!e(t[o], n[o])) return !1;
226
+ return !0;
227
+ }
228
+ if (t instanceof Map && n instanceof Map) {
229
+ if (t.size !== n.size) return !1;
230
+ for (o of t.entries()) if (!n.has(o[0])) return !1;
231
+ for (o of t.entries()) if (!e(o[1], n.get(o[0]))) return !1;
232
+ return !0;
233
+ }
234
+ if (t instanceof Set && n instanceof Set) {
235
+ if (t.size !== n.size) return !1;
236
+ for (o of t.entries()) if (!n.has(o[0])) return !1;
237
+ return !0;
238
+ }
239
+ if (ArrayBuffer.isView(t) && ArrayBuffer.isView(n)) {
240
+ if (r = t.length, r != n.length) return !1;
241
+ for (o = r; o-- !== 0; ) if (t[o] !== n[o]) return !1;
242
+ return !0;
243
+ }
244
+ if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
245
+ if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
246
+ if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
247
+ if (a = Object.keys(t), r = a.length, r !== Object.keys(n).length) return !1;
248
+ for (o = r; o-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(n, a[o])) return !1;
249
+ for (o = r; o-- !== 0; ) {
250
+ let i = a[o];
251
+ if (!(i === "_owner" && t.$$typeof || e(t[i], n[i]))) return !1;
252
+ }
253
+ return !0;
254
+ }
255
+ return t != t && n != n;
256
+ }, deepFreeze: function e(t) {
257
+ return Object.freeze(t), Object.keys(t).forEach((n) => {
258
+ typeof t[n] != "object" || t[n] === null || Object.isFrozen(t[n]) || e(t[n]);
259
+ }), t;
260
+ }, deepMerge: E, diffValues: (e, t) => {
261
+ const n = {}, r = Object.keys(t), o = r.length;
262
+ for (let a = 0; a < o; a++) {
263
+ const i = r[a];
264
+ e[i] !== t[i] && (e[i] === void 0 ? n[i] = t[i] : n[i] = e[i]);
265
+ }
266
+ return Object.keys(n).length === 0 ? null : n;
267
+ }, findEqualOrGreater: function(e, t, n = et) {
268
+ let r = 0, o = e.length - 1;
269
+ for (; r <= o; ) {
270
+ let a = Math.floor((r + o) / 2), i = n(e[a]);
271
+ if (i === t) return a;
272
+ i < t ? r = a + 1 : o = a - 1;
273
+ }
274
+ return r;
275
+ }, findEqualOrLesser: function(e, t, n = et) {
276
+ let r = e.length - 1, o = 0;
277
+ for (; r >= o; ) {
278
+ let a = Math.floor((r + o) / 2), i = n(e[a]);
279
+ if (i === t) return a;
280
+ i > t ? r = a - 1 : o = a + 1;
281
+ }
282
+ return r;
283
+ }, findNextStep: (e, t = !0, n = 15, r = 10, o = 400) => {
284
+ const a = Math.max(e - r, 0) + (t ? 1 : -1);
285
+ return Math.min(o, Math[t ? "ceil" : "floor"](a / n) * n + r);
286
+ }, getBuildEnv: () => "node-build", getDPI: () => {
287
+ let e = 1;
288
+ return typeof window == "object" && (e = window.devicePixelRatio || 1), e;
289
+ }, getFromPath: (e, t) => {
290
+ const n = t.split(".");
291
+ let r = e;
292
+ for (let o = 0; o < n.length; o++) {
293
+ const a = n[o];
294
+ if (!r) return null;
295
+ let i = r[a];
296
+ if (typeof i == "function" && (i = i.bind(r)()), !i || !_(i)) return i;
297
+ r = i;
298
+ }
299
+ return r ?? null;
300
+ }, getOS: T, hasFocus: it, isDefined: (e) => e != null, isEmpty: (e) => e == null || e === "", isEqualArrays: mt, 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) => {
301
+ if (e === t) return !0;
302
+ if (e && !t || t && !e) return !1;
303
+ const n = Object.keys(e);
304
+ if (n.length !== Object.keys(t).length) return !1;
305
+ for (let r = 0; r < n.length; r++) if (e[n[r]] !== t[n[r]]) return !1;
306
+ return !0;
307
+ }, isNode: vt, isNullOrUndefined: rt, isNumeric: (e) => {
308
+ const t = 1 * e;
309
+ return Number.isFinite(t) && typeof t == "number";
310
+ }, isObject: _, 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: ot, mergeContentful: (...e) => {
311
+ const t = e.length;
312
+ if (t > 0 && e[t - 1] !== void 0 && !_(e[t - 1])) return e[t - 1];
313
+ let n = e[0] || {};
314
+ for (let r = 1; r < t; r++) n = E(n, e[r] || {}, { arrayMerge: (o, a) => [...a] });
315
+ return n;
316
+ }, nextTick: (e) => {
317
+ typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(() => {
318
+ e();
319
+ }) : (typeof setImmediate == "function" ? setImmediate : setTimeout)(() => {
320
+ e();
321
+ });
322
+ }, openFileDialog: (e = "*.*") => new Promise((t, n) => {
323
+ if (!at) return void n("Unable to open dialog with no dom.");
324
+ const r = document.createElement("input");
325
+ r.type = "file", r.accept = e;
326
+ let o = null, a = !1;
327
+ globalThis.addEventListener?.("focus", () => {
328
+ setTimeout(() => {
329
+ o || a || (a = !0, t(null));
330
+ }, 1e3);
331
+ }, { once: !0, passive: !0 }), r.onchange = () => {
332
+ if (o = r.files[0], o) {
333
+ if (a) return void console.warn("File open detected after faux cancel.", o);
334
+ t(o);
335
+ }
336
+ }, r.autofocus = !0, r.click();
337
+ }), rafThrottle: (e) => {
338
+ let t, n = !1, r = function() {
339
+ n = !1, e(t);
340
+ };
341
+ return function(o) {
342
+ t = o, t && t.persist && t.persist(), n || (n = !0, requestAnimationFrame(r));
343
+ };
344
+ }, removeEmptyProperties: Et, removeEqualValues: St, removeListenerAll: (e) => {
345
+ if (!e) return [];
346
+ for (let t = 0; t < e.length; t++) e[t] && e[t]();
347
+ return [];
348
+ }, requestTimeout: (e, t) => {
349
+ const n = nt(), r = { id: requestAnimationFrame(function o() {
350
+ nt() - n >= t ? e.call(null) : r.id = requestAnimationFrame(o);
351
+ }) };
352
+ return r;
353
+ }, roundAccurately: (e, t = 0) => {
354
+ if (e == null || !isFinite(e)) return null;
355
+ const n = 10 ** t;
356
+ return Number(Math.round(e * n) / n);
357
+ }, setToPath: (e, t, n) => {
358
+ const r = t.split(".");
359
+ let o = e;
360
+ if (!o) throw new Error("Can not set path to a null path.");
361
+ for (let a = 0; o && a < r.length - 1; a++) {
362
+ const i = r[a];
363
+ let l = o[i];
364
+ if (l == null && (l = {}, o[i] = l), !_(l)) throw new Error("Can not set path to a non object path.");
365
+ o = l;
366
+ }
367
+ if (typeof n != "number" && typeof n != "boolean" && typeof n != "string" && !_(n)) throw new Error(`Can not set path to ${n} that is not a a supported primitive.`);
368
+ return o[r[r.length - 1]] = n, e;
369
+ }, splitNumber: (e) => {
370
+ let t = Math.abs(e);
371
+ if (isNaN(t) || !isFinite(e)) return null;
372
+ let n = 0 | t, r = t - n, o = 0, a = 0, i = 1;
373
+ if (r > 5e-8) for (; a < 8 && Math.abs(o / i - r) > 5e-8; ) a++, i *= 10, o = Math.round(r * i);
374
+ return { ip: Math.trunc(e), fp: o, ipLength: Math.ceil(Math.log10(n + 1)), fpLength: a };
375
+ }, subtractRect: (e, t, n = !1) => {
376
+ if (!t) return [e];
377
+ if (!ot(e, t)) return [];
378
+ const r = [];
379
+ let o = e;
380
+ const a = () => {
381
+ t.top > o.top && t.top < o.bottom && (r.push({ ...o, bottom: t.top }), o = { ...o, top: t.top });
382
+ }, i = () => {
383
+ t.bottom > o.top && t.bottom < o.bottom && (r.push({ ...o, top: t.bottom }), o = { ...o, bottom: t.bottom });
384
+ }, l = () => {
385
+ t.right > o.left && t.right < o.right && (r.push({ ...o, left: t.right }), o = { ...o, right: t.right });
386
+ }, s = () => {
387
+ t.left > o.left && t.left < o.right && (r.push({ ...o, right: t.left }), o = { ...o, left: t.left });
388
+ };
389
+ return n ? (s(), l(), a(), i()) : (a(), i(), l(), s()), r;
390
+ }, textToKey: (e) => e.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(), throttle: function(e, t) {
391
+ let n = null;
392
+ return (...r) => {
393
+ const o = Date.now();
394
+ (!n || o - n >= t) && (n = o, e(...r));
395
+ };
396
+ }, toSafeJSON: function e(t) {
397
+ if (t === null || typeof t != "object") return t;
398
+ if (typeof t.toJSON == "function") return t.toJSON();
399
+ if (Array.isArray(t)) return t.map((r) => e(r));
400
+ if (typeof t.toString == "function" && t.toString !== Object.prototype.toString) return t.toString();
401
+ const n = {};
402
+ for (const r in t) t.hasOwnProperty(r) && (n[r] = e(t[r]));
403
+ return n;
404
+ }, transpose: (e) => {
405
+ if (!e) return e;
406
+ const t = e.length, n = e[0].length, r = [];
407
+ for (let o = 0; o < n; o++) r[o] = Array(t);
408
+ for (let o = 0; o < t; o++) for (let a = 0; a < n; a++) r[a][o] = e[o][a];
409
+ return r;
410
+ }, uuidV4: R, validEnumValue: (e, t) => {
411
+ if (!Object.values(e).includes(t)) throw new Error(`Invalid type: ${t ?? "null"}. Must be one of: ${Object.values(t).join(", ")}.`);
412
+ }, whenFocus: async (e, t = !1) => new Promise((n) => {
413
+ it(e, t) ? n(!0) : e.addEventListener("focusin", () => {
414
+ n(!0);
415
+ }, { once: !0 }), e.focus();
416
+ }) }, Symbol.toStringTag, { value: "Module" }));
417
+ Object.freeze(Object.defineProperty({ __proto__: null, MESSAGE_ERROR_INVALID_ARG: (e) => `Invalid argument: '${e}'.` }, Symbol.toStringTag, { value: "Module" }));
418
+ const xt = (e) => {
419
+ const t = new Uint8Array(e), n = t.byteLength;
420
+ let r = "";
421
+ for (let o = 0; o < n; o++) r += String.fromCharCode(t[o]);
422
+ if (typeof window < "u" && typeof globalThis.btoa == "function") return globalThis.btoa(r);
423
+ if (typeof Buffer < "u") return Buffer.from(r, "binary").toString("base64");
424
+ throw new Error("Unsupported environment");
425
+ }, W = (e) => new Promise((t, n) => {
426
+ if (e) if (typeof FileReader < "u") {
427
+ const r = new FileReader();
428
+ r.onload = () => {
429
+ t(r.result);
430
+ }, r.onerror = () => {
431
+ n(r.error);
432
+ }, r.readAsText(e);
433
+ } else if (typeof Buffer < "u") {
434
+ const r = (o) => Buffer.from(o).toString("utf-8");
435
+ e.arrayBuffer().then((o) => {
436
+ t(r(o));
437
+ }).catch((o) => {
438
+ n(o);
439
+ });
440
+ } else n(new Error("Unsupported environment"));
441
+ else t("");
442
+ });
443
+ Object.freeze(Object.defineProperty({ __proto__: null, DEFAULT_MIME_TYPE: "*/*", arrayBufferToBase64: xt, base64ToArrayBuffer: (e) => {
444
+ 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);
445
+ for (let o = 0; o < n; o++) r[o] = t.charCodeAt(o);
446
+ return r.buffer;
447
+ }, blobToString: W }, Symbol.toStringTag, { value: "Module" }));
448
+ const Ot = "data:image/png;base64,", _t = "Unable to resolve image.", lt = (e) => new Promise(async (t, n) => {
449
+ let r = null;
450
+ try {
451
+ r = new Image(), r.src = e, r.addEventListener("load", function() {
452
+ t({ width: r.naturalWidth, height: r.naturalHeight });
453
+ }, { once: !0 }), r.addEventListener("error", function() {
454
+ URL.revokeObjectURL(e), n("Invalid Image");
455
+ }, { once: !0 }), await r.decode("sync");
456
+ } catch {
457
+ r?.src && URL.revokeObjectURL(r.src);
458
+ }
459
+ r || n(_t);
460
+ }), P = "image/svg+xml";
461
+ var st, ct;
462
+ Object.freeze(Object.defineProperty({ __proto__: null, DATA_URL_PNG_PREFIX: Ot, getImageDataUrl: (e, t = 1) => new Promise(async (n, r) => {
463
+ let o = null;
464
+ try {
465
+ o = new Image(), o.src = e, o.addEventListener("load", function() {
466
+ try {
467
+ const a = document.createElement("canvas");
468
+ a.width = o.naturalWidth, a.height = o.naturalHeight, a.getContext("2d").drawImage(o, 0, 0);
469
+ const i = a.toDataURL("image/png", t);
470
+ n({ elemImg: o, dataUrl: i });
471
+ } catch (a) {
472
+ URL.revokeObjectURL(e), r(a);
473
+ }
474
+ }, { once: !0 }), o.addEventListener("error", function() {
475
+ URL.revokeObjectURL(e), r("Invalid Image");
476
+ }, { once: !0 }), await o.decode("sync");
477
+ } catch {
478
+ o?.src && URL.revokeObjectURL(o.src);
479
+ }
480
+ o || r(_t);
481
+ }), loadImageDetails: async (e, t = null) => {
482
+ let n = null;
483
+ const r = async () => {
484
+ try {
485
+ const a = t ?? "image/*", i = URL.createObjectURL(new Blob([e], { type: a })), l = await lt(i);
486
+ n = { mimeType: a, naturalDimensions: l, asUrl: i };
487
+ } catch {
488
+ }
489
+ }, o = async () => {
490
+ try {
491
+ const a = new TextDecoder().decode(e), i = URL.createObjectURL(new Blob([a], { type: P })), l = await lt(i);
492
+ n = { mimeType: t ?? P, naturalDimensions: l, asUrl: i, asSVGText: a };
493
+ } catch {
494
+ }
495
+ };
496
+ if (t === P ? await o() : t.startsWith("image/") ? await r() : (await r(), n || await o()), !n) throw new Error("Failed to load image");
497
+ return n;
498
+ } }, Symbol.toStringTag, { value: "Module" })), (ct = st || (st = {})).resolveTypedUpdates = (e, t, n, r) => {
499
+ if (e === null) return e;
500
+ if (e === void 0) return r;
501
+ let o = e;
502
+ if (t?.shorthand) {
503
+ const s = t?.shorthand(e, n);
504
+ s !== void 0 && (o = s);
505
+ }
506
+ if (o !== null && t?.getSubType) {
507
+ const s = t.getSubType(o);
508
+ s && (t = s);
509
+ }
510
+ const a = t?.properties, i = t?.arrayType ?? !1;
511
+ let l = o;
512
+ if (t && t.merge && l && r) l = t.merge(l, r, n);
513
+ else if (!i) {
514
+ if (a) {
515
+ const s = Object.keys({ ...o, ...r });
516
+ l = null;
517
+ for (let c = 0; c < s.length; c++) {
518
+ const d = s[c];
519
+ let w, u = o[d];
520
+ if (u !== void 0) {
521
+ const f = a[d];
522
+ w = f ? (0, ct.resolveTypedUpdates)(u, f, n, r?.[d]) : u;
523
+ } else w = r?.[d];
524
+ w != null && (l = l ?? {}, l[d] = w);
525
+ }
526
+ }
527
+ }
528
+ return l;
529
+ };
530
+ const ut = `The Safari browser does not support advanced copy and paste.
531
+ Copy and paste will be limited to within the browser tab.
532
+
533
+ Please use Chrome or Edge if external copy and paste is required.`, k = `You do not have permissions to access the clipboard.
534
+ All copy and paste operations will be limited to the browser tab.`, It = { Safari: `The Safari browser does not support advanced copy and paste.
535
+ Copy and paste will be limited to within the browser tab.
536
+
537
+ Please use Chrome or Edge if external copy and paste is required.`, Perms: k, PermsWrite: T() === y.Safari ? ut : k, PermsRead: T() === y.Safari ? ut : k }, N = async () => new Promise((e) => {
538
+ document.hasFocus() ? e() : globalThis.addEventListener?.("focus", () => {
539
+ e();
540
+ }, { once: !0 }), document.activeElement.focus?.();
541
+ }), B = async (e, t, n) => {
542
+ if (T() === y.Safari) return await n(new Error(It.Safari));
543
+ try {
544
+ const r = async (i) => {
545
+ try {
546
+ return await i();
547
+ } catch (l) {
548
+ if (l.message?.includes("Document is not focused")) return !1;
549
+ throw l;
550
+ }
551
+ }, o = await globalThis?.navigator?.permissions?.query({ name: e, allowWithoutGesture: !0, allowWithoutSanitization: !0 });
552
+ let a = !1;
553
+ if (o.state === "prompt" && (a = await r(t)), a || o.state !== "granted" || (a = await t()), !a) return await n(new Error(o.state));
554
+ } catch (r) {
555
+ return r.message === "No valid data on clipboard" || r.name === "DataError" ? void 0 : await n(r);
556
+ }
557
+ }, jt = async (e) => {
558
+ try {
559
+ return await e.read({ unsanitized: [h] });
560
+ } catch {
561
+ }
562
+ return await e.read();
563
+ };
564
+ if (!globalThis.ClipboardItem) {
565
+ const e = (n, r) => new Blob([r], { type: n });
566
+ class t {
567
+ constructor(r, o) {
568
+ this._items = {}, this._types = Object.keys(r);
569
+ const a = {}, i = Object.keys(r);
570
+ for (let l = 0; l < i.length; l++) {
571
+ const s = i[l];
572
+ let c = r[s];
573
+ a[s] = typeof c == "string" ? e(s, c) : c;
574
+ }
575
+ this._items = a, this._presentationStyle = o?.presentationStyle ?? "unspecified";
576
+ }
577
+ get types() {
578
+ return this._types;
579
+ }
580
+ getType(r) {
581
+ return Promise.resolve(this._items[r]);
582
+ }
583
+ supports(r) {
584
+ return !0;
585
+ }
586
+ }
587
+ globalThis.ClipboardItem = t;
588
+ }
589
+ const V = async (e, t = h) => new Promise(async (n, r) => {
590
+ try {
591
+ const o = await (async (a, i) => {
592
+ if (!a) return null;
593
+ const l = await jt(a);
594
+ let s = !1;
595
+ for (let c = 0; !s && l && c < l.length; c++) if (s = l[c].types.includes(i), s) return await l[c].getType(i);
596
+ return s ? void 0 : null;
597
+ })(e, t);
598
+ if (o) {
599
+ const a = new FileReader();
600
+ a.onload = () => {
601
+ n(a.result);
602
+ }, a.onerror = () => {
603
+ n("");
604
+ }, a.readAsText(o);
605
+ } else n("");
606
+ } catch (o) {
607
+ r(o);
608
+ }
609
+ }), dt = async (e, t = h) => {
610
+ const n = await V(e, t);
611
+ if (!n) return null;
612
+ let r = null;
613
+ try {
614
+ r = new DOMParser().parseFromString(n, h);
615
+ } catch {
616
+ console.warn("Can't parse html from clipboard.");
617
+ }
618
+ return r;
619
+ }, C = "clipboard-uuid", v = "web text/uuid", ft = (e) => `<div style="display:none" ${C}="${e}"/>`, Wt = (e, t) => {
620
+ let n = null;
621
+ try {
622
+ const r = new DOMParser().parseFromString(t, h);
623
+ r.body.firstElementChild.setAttribute(C, e), n = r.getElementsByTagName("body")[0].innerHTML;
624
+ } catch (r) {
625
+ console.warn("Can't embed uuid.", r);
626
+ }
627
+ return n;
628
+ }, pt = (e, t) => {
629
+ if (!t || !e) return !1;
630
+ try {
631
+ const n = t.querySelectorAll(`[${C}="${e}"]`);
632
+ if (n && n.length === 1) return !0;
633
+ if (t.querySelector("parsererror")) throw new Error("We are unable to parse node");
634
+ return !1;
635
+ } catch {
636
+ return !1;
637
+ }
638
+ };
639
+ class wt {
640
+ constructor(t) {
641
+ if (t?.nativeClipboard === void 0 || t?.nativeClipboard === !0) try {
642
+ this._nativeClipboard = globalThis?.navigator.clipboard;
643
+ } catch {
644
+ t?.nativeClipboard === !0 && console.warn("NativeClipboard option set to true but no native clipboard available.");
645
+ }
646
+ else this._nativeClipboard = t?.nativeClipboard === !1 ? null : t?.nativeClipboard;
647
+ this._disableCheckOnFocus = t?.disableCheckOnFocus ?? !1, this._init();
648
+ }
649
+ async _checkForChanges() {
650
+ this._nativeClipboard && this._state && !this._disableCheckOnFocus && await B("clipboard-read", async () => {
651
+ await N();
652
+ const t = await V(this._nativeClipboard, v);
653
+ if (!this._state || t && t === this._state.uuid) return !0;
654
+ const n = await dt(this._nativeClipboard, h);
655
+ return !this._state || (pt(this._state.uuid, n) || this.clear(), !0);
656
+ }, async (t) => {
657
+ t?.message === "denied" || t.message?.includes("Document is not focused") || T() === y.Safari || console.warn("Unable to detect clipboard changes: ", t);
658
+ });
659
+ }
660
+ _init() {
661
+ const t = this;
662
+ this._listeners = /* @__PURE__ */ new Map(), this._listenersCapture = /* @__PURE__ */ new Map(), this._state = null, this._nativeClipboard && (this._onFocus = () => {
663
+ t._checkForChanges();
664
+ }, this._onBlur = () => {
665
+ globalThis.addEventListener?.("focus", t._onFocus, { once: !0 });
666
+ }, globalThis.addEventListener?.("blur", this._onBlur), this._nativeClipboard.addEventListener("clipboardchange", (n) => {
667
+ t._checkForChanges();
668
+ }));
669
+ }
670
+ async read() {
671
+ if (!this._nativeClipboard) return this._state?.items ?? null;
672
+ const t = this;
673
+ return await B("clipboard-read", async () => {
674
+ if (await N(), this._state?.uuid) {
675
+ const n = await V(this._nativeClipboard, v);
676
+ if (n && n === t._state.uuid) return !0;
677
+ const r = await dt(this._nativeClipboard, h);
678
+ if (pt(t._state?.uuid, r)) return !0;
679
+ }
680
+ return t._state = { items: await jt(this._nativeClipboard), uuid: null, ref: null }, this.dispatchEvent(new Event("clipboardread")), !0;
681
+ }, async (n) => {
682
+ this.dispatchEvent(new Event("clipboarderrorread"));
683
+ }), this._state?.items ?? [];
684
+ }
685
+ async write(t) {
686
+ return this._write({ uuid: R(), items: t, ref: null });
687
+ }
688
+ async _write(t) {
689
+ if (!this._nativeClipboard) return this._state = t, this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")), null;
690
+ const n = this, r = [], o = t.uuid;
691
+ let a = t.items ?? [];
692
+ const i = () => {
693
+ n._state = { uuid: o, ref: t.ref, items: r }, n.dispatchEvent(new Event("clipboardwrite")), n.dispatchEvent(new Event("clipboardchange"));
694
+ };
695
+ await B("clipboard-write", async () => {
696
+ await N(), o && a.length === 0 && (a.push(new ClipboardItem({ [v]: new Blob([o], { type: v }) })), a.push(new ClipboardItem({ [h]: new Blob([ft(o)], { type: h }) })));
697
+ for (let l = 0; l < Math.min(1, a.length); l++) {
698
+ const s = a[l];
699
+ let c = s.types.indexOf(h), d = null;
700
+ if (c !== -1) {
701
+ const f = await s.getType(h);
702
+ d = await W(f), d && (d = Wt(o, d));
703
+ }
704
+ if (!d && s.types.includes(b)) {
705
+ const f = await s.getType(b);
706
+ if (f) {
707
+ let p = null;
708
+ typeof f == "string" ? (console.warn("text as string", f), p = f) : p = await W(f), p && (d = `<div ${C}="${o}">${p}</div>`);
709
+ }
710
+ }
711
+ if (!d && s.types.includes(L)) {
712
+ const f = await s.getType(L), p = xt(await f.arrayBuffer());
713
+ d = `<div ${C}="${o}"><img src="${Ot + p}"/></div>`;
714
+ }
715
+ !d && o && (d = ft(o));
716
+ const w = new Blob([d ?? ""], { type: h }), u = {};
717
+ for (let f = 0; f < s.types.length; f++) {
718
+ const p = s.types[f];
719
+ u[p] = f === c ? w : s.getType(p);
720
+ }
721
+ d && c === -1 && (u[h] = w), o && (u[v] = new Blob([o], { type: v })), r.push(new ClipboardItem(u));
722
+ }
723
+ try {
724
+ r && r.length !== 0 ? await this._nativeClipboard.write(r) : await (async (l) => {
725
+ l && await l.writeText("");
726
+ })(this._nativeClipboard);
727
+ } catch (l) {
728
+ l.message?.includes("Document is not focused") || console.warn("Unable to write to native clipboard: ", l);
729
+ }
730
+ return i(), !0;
731
+ }, async (l) => {
732
+ this.dispatchEvent(new Event("clipboarderrorwrite")), i();
733
+ });
734
+ }
735
+ async writeReference(t) {
736
+ if (!t) return void this.clear();
737
+ let n = null;
738
+ const r = {};
739
+ try {
740
+ const a = await t.toText?.() ?? null;
741
+ a && (r[b] = new Blob([a ?? ""], { type: b }));
742
+ } catch (a) {
743
+ n = a;
744
+ }
745
+ try {
746
+ const a = await t.toHtml?.() ?? null;
747
+ a && (r[h] = new Blob([a], { type: h }));
748
+ } catch (a) {
749
+ n = a, console.warn("export to html", a);
750
+ }
751
+ try {
752
+ const a = await t.toImage?.() ?? null;
753
+ a && (r[L] = a);
754
+ } catch (a) {
755
+ n = a, console.warn("export to png", a);
756
+ }
757
+ const o = this._write({ uuid: R(), ref: t, items: Object.keys(r).length > 0 ? [new ClipboardItem(r)] : null });
758
+ if (n) throw n;
759
+ return o;
760
+ }
761
+ clear(t = !1) {
762
+ this._state && (this._state = null, t && this._write({ uuid: null, ref: null, items: null }), this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")));
763
+ }
764
+ async readReference() {
765
+ return await this.read(), this._state?.ref ?? null;
766
+ }
767
+ readText() {
768
+ return new Promise(async (t, n) => {
769
+ const r = await this.read();
770
+ let o = null;
771
+ for (let i = 0; !o && r && i < r.length; i++) r[i].types.includes(b) && (o = await r[i].getType(b));
772
+ if (!o) return void t("");
773
+ const a = new FileReader();
774
+ a.onload = () => {
775
+ t(a.result);
776
+ }, a.readAsText(o), a.onerror = (i) => {
777
+ n(i);
778
+ };
779
+ });
780
+ }
781
+ async writeText(t) {
782
+ const n = [new ClipboardItem({ [b]: new Blob([t], { type: b }) })];
783
+ return this._write({ uuid: R(), items: n, ref: null });
784
+ }
785
+ addEventListener(t, n, r = {}) {
786
+ const o = r?.capture ? this._listenersCapture : this._listeners;
787
+ let a = o.get(t);
788
+ a || (a = /* @__PURE__ */ new Map(), o.set(t, a)), a.set(n, typeof r == "boolean" ? {} : r);
789
+ }
790
+ dispatchEvent(t) {
791
+ if (!t) return;
792
+ const n = (r) => {
793
+ const o = r.get(t.type);
794
+ o && o.forEach((a, i) => {
795
+ try {
796
+ typeof i == "function" ? i(t) : i.handleEvent && i.handleEvent(t), a.once && o.delete(i);
797
+ } catch (l) {
798
+ console.warn(l);
799
+ }
800
+ });
801
+ };
802
+ return n(this._listenersCapture), n(this._listeners), !0;
803
+ }
804
+ removeEventListener(t, n, r) {
805
+ const o = r?.capture ? this._listenersCapture : this._listeners, a = o.get(t);
806
+ a && (a.delete(n), a.size === 0 && o.delete(t));
807
+ }
808
+ close() {
809
+ globalThis.removeEventListener?.("focus", this._onFocus), globalThis.removeEventListener?.("blur", this._onBlur);
810
+ }
811
+ }
812
+ var z;
813
+ (z = wt || (wt = {})).ErrorMessages = It, z.Global = new z();
814
+ let ht = null, q = null, M = null;
815
+ const Vt = Object.freeze({ compileTypescript: async function(e) {
816
+ if (!(e?.source ?? null)) return null;
817
+ if (q && $t.deepEqual(q, e)) return ht;
818
+ const t = await async function() {
819
+ if (M) return M;
820
+ const { TypeScriptCompiler: r } = await import("./CAR3zA9JT0oXdgEs.mjs");
821
+ return M = new r(), M;
822
+ }(), n = await t.compileModule(e);
823
+ return ht = n, q = e, n;
824
+ } });
825
+ export {
826
+ Vt as ScriptingUtils,
827
+ $t as e
828
+ };