UNPKG

@sheetxl/studio-vanilla

Version:

SheetXL Studio - Vanilla entry point for integrating SheetXL UI.

1,193 lines (1,181 loc) 2.7 MB
import { r as SD, g as Pf, a as xD, b as vD, c as CD } from "./yP9gBT5HfGMGV0cP.mjs"; /** * @license @sheetxl/studio-vanilla - SheetXL Studio - Vanilla entry point for integrating SheetXL UI. - v0.7.27 * * (C) 2025-present SheetXL Inc. & Michael T. Ford * License: The license can be found at https://www.sheetxl.com/license. */ function q1(n, e) { for (var t = 0; t < e.length; t++) { const o = e[t]; if (typeof o != "string" && !Array.isArray(o)) { for (const r in o) if (r !== "default" && !(r in n)) { const i = Object.getOwnPropertyDescriptor(o, r); i && Object.defineProperty(n, r, i.get ? i : { enumerable: !0, get: () => o[r] }); } } } return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" })); } const Vw = /* @__PURE__ */ new Map(), SI = (n, e = {}) => { const { message: t, icon: o, customElement: r, hide: i = !1, className: s, cssVars: a = {} } = e; if (i) return; const l = typeof n == "string" ? document.querySelector(n) : n; if (!l) return void console.warn(`Element with selector "${n}" not found for panel.`); let c; if (Mh(n), r) c = r; else { c = document.createElement("div"), c.className = s ? `sheetxl-panel ${s}` : "sheetxl-panel"; const d = Object.entries(a).map(([p, m]) => `--sheetxl-panel-${p}: ${m};`).join(" "), h = ` @keyframes sheetxl-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .sheetxl-panel { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; backdrop-filter: blur(4px); border-radius: 4px; z-index: 9999; gap: 16px; /* CSS variables with fallbacks */ color: var(--sheetxl-panel-color, #333); } .sheetxl-panel.dark { color: var(--sheetxl-panel-color, #e0e0e0); } .sheetxl-icon { width: 24px; height: 24px; color: var(--sheetxl-panel-icon-color, #1976d2); } .sheetxl-panel.loading { /* Loading panel defaults */ color: var(--sheetxl-panel-color, #333); } .sheetxl-panel.loading.dark { color: var(--sheetxl-panel-color, #e0e0e0); } .sheetxl-panel.error { /* Error panel defaults */ color: var(--sheetxl-panel-color, #d32f2f); } .sheetxl-panel.error.dark { color: var(--sheetxl-panel-color, #f44336); } .sheetxl-panel.error .sheetxl-icon { color: var(--sheetxl-panel-icon-color, #d32f2f); } .sheetxl-panel.error.dark .sheetxl-icon { color: var(--sheetxl-panel-icon-color, #f44336); } .sheetxl-message { font-size: 1.1em; font-weight: 500; letter-spacing: 0.1px; text-align: center; margin: 0; } `, u = document.createElement("style"); if (u.textContent = h, c.appendChild(u), o) { const p = document.createElement("div"); p.className = "sheetxl-icon", typeof o == "string" ? p.innerHTML = o : o instanceof HTMLElement && p.appendChild(o), c.appendChild(p); } if (t) { const p = document.createElement("div"); p.className = "sheetxl-message", p.textContent = t, c.appendChild(p); } d && (c.style.cssText += d), window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches && c.classList.add("dark"); } window.getComputedStyle(l).position === "static" && (l.style.position = "relative"), l.appendChild(c), Vw.set(n, c); }, Mh = (n) => { const e = Vw.get(n); e && e.parentNode && (e.parentNode.removeChild(e), Vw.delete(n)); }, xI = (n, e = {}) => { SI(n, { icon: ` <svg width="24" height="24" viewBox="0 0 24 24" style="animation: sheetxl-spin 1s linear infinite;"> <circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="2" stroke-dasharray="31.416" stroke-dashoffset="31.416"> <animate attributeName="stroke-dasharray" dur="2s" values="0 31.416;15.708 15.708;0 31.416" repeatCount="indefinite"/> <animate attributeName="stroke-dashoffset" dur="2s" values="0;-15.708;-31.416" repeatCount="indefinite"/> </circle> </svg> `, className: "loading", ...e }); }, vI = (n, e = {}) => { SI(n, { message: "Failed to load SheetXL", icon: ` <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"> <path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/> </svg> `, className: "error", ...e }); }, Rp = /* @__PURE__ */ new Map(); var y = SD(); const He = Pf(y), Ng = q1({ __proto__: null, default: He }, [y]); var _ = xD(); const _D = q1({ __proto__: null, default: Pf(_) }, [_]); var Uw = vD(); const jx = q1({ __proto__: null, default: Pf(Uw) }, [Uw]), ut = { Number: "n", String: "s", Boolean: "b", Error: "e", RichData: "r", Null: "z" }; var ae, Mp, yt; (Mp = ae || (ae = {})).Orientation = { Column: "column", Row: "row" }, Mp.Orientations = { ...Mp.Orientation, Both: "both" }, Mp.Direction = { Up: "up", Down: "down", Left: "left", Right: "right" }, ((n) => { n.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 }, n.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!" }; class e extends Error { constructor(x, C, E, R) { super(E, R), this._label = C, this._code = x, this.details = R; } static { this.code = n.Code.Unknown; } get isFormulaError() { return !0; } getLabel() { return this._label; } getCode() { return this._code; } equals(x) { return !!x && (this._code === x._code || this._code === x.code); } get [Symbol.toStringTag]() { return "[FormulaError]"; } toString() { return this.message || this._label; } } n.Known = e; class t extends e { constructor(x, C) { super(n.Code.Parse, n.Label.Parse, x, C); } static { this.code = n.Code.Parse; } getDetails() { const x = this.details; return { line: x?.line ?? 1, column: x?.column ?? 1, offset: x?.offset ?? 0, length: x?.length ?? 0 }; } } n.Parse = t; class o extends e { constructor(x, C) { super(n.Code.Null, n.Label.Null, x, C); } static { this.code = n.Code.Null; } } n.Null = o; class r extends e { constructor(x, C) { super(n.Code.Div0, n.Label.Div0, x, C); } static { this.code = n.Code.Div0; } } n.Div0 = r; class i extends e { constructor(x, C) { super(n.Code.Value, n.Label.Value, x, C); } static { this.code = n.Code.Value; } } n.Value = i; class s extends e { constructor(x, C) { super(n.Code.Ref, n.Label.Ref, x, C); } static { this.code = n.Code.Ref; } } n.Ref = s; class a extends e { constructor(x, C) { super(n.Code.Name, n.Label.Name, x, C); } static { this.code = n.Code.Name; } } n.Name = a; class l extends e { constructor(x, C) { super(n.Code.Num, n.Label.Num, x, C); } static { this.code = n.Code.Num; } } n.Num = l; class c extends e { constructor(x, C) { super(n.Code.NA, n.Label.NA, x, C); } static { this.code = n.Code.NA; } } n.NA = c; class d extends e { constructor(x, C) { super(n.Code.GettingData, n.Label.GettingData, x, C); } static { this.code = n.Code.GettingData; } } n.GettingData = d; class h extends e { constructor(x, C) { super(n.Code.Spill, n.Label.Spill, x, C); } static { this.code = n.Code.Spill; } } n.Spill = h; class u extends e { constructor(x, C) { super(n.Code.Connect, n.Label.Connect, x, C); } static { this.code = n.Code.Connect; } } n.Connect = u; class p extends e { constructor(x, C) { super(n.Code.Blocked, n.Label.Blocked, x, C); } static { this.code = n.Code.Blocked; } } n.Blocked = p; class m extends e { constructor(x, C) { super(n.Code.Unknown, n.Label.Unknown, x, C); } static { this.code = n.Code.Unknown; } } n.Unknown = m; class g extends e { constructor(x, C) { super(n.Code.Field, n.Label.Field, x, C); } static { this.code = n.Code.Field; } } n.Field = g; class w extends e { constructor(x, C) { super(n.Code.Calc, n.Label.Calc, x, C); } static { this.code = n.Code.Calc; } } n.Calc = w; class f extends e { constructor(x, C) { super(n.Code.Busy, n.Label.Busy, x, C); } static { this.code = n.Code.Busy; } } n.Busy = f; class b extends e { constructor(x, C) { super(n.Code.Python, n.Label.Python, x, C); } static { this.code = n.Code.Python; } } n.Python = b; class S extends e { constructor(x, C) { super(n.Code.Timeout, n.Label.Timeout, x, C); } static { this.code = n.Code.Timeout; } } n.Timeout = S; })(yt || (yt = {})); const qo = {}; qo[yt.Code.Parse] = yt.Parse, qo[yt.Code.Null] = yt.Null, qo[yt.Code.Div0] = yt.Div0, qo[yt.Code.Value] = yt.Value, qo[yt.Code.Ref] = yt.Ref, qo[yt.Code.Name] = yt.Name, qo[yt.Code.Num] = yt.Num, qo[yt.Code.NA] = yt.NA, qo[yt.Code.GettingData] = yt.GettingData, qo[yt.Code.Spill] = yt.Spill, qo[yt.Code.Connect] = yt.Connect, qo[yt.Code.Blocked] = yt.Blocked, qo[yt.Code.Unknown] = yt.Unknown, qo[yt.Code.Field] = yt.Field, qo[yt.Code.Calc] = yt.Calc, qo[yt.Code.Busy] = yt.Busy, qo[yt.Code.Python] = yt.Python, qo[yt.Code.Timeout] = yt.Timeout; const CI = /* @__PURE__ */ new Map(), K1 = /* @__PURE__ */ new Map(), _I = /* @__PURE__ */ new Map(), EI = /* @__PURE__ */ new Map(), Lx = Object.keys(qo); for (let n = 0; n < Lx.length; n++) { const e = Lx[n], t = qo[e]; _I.set(yt.Label[e], t), EI.set(yt.Code[e], t); const o = new t(); CI.set(o.getLabel(), o), K1.set(o.getCode(), o); } const ED = K1.get(yt.Code.Unknown); var vo; (vo = yt || (yt = {})).BuiltIn = { Parse: new vo.Parse(), Null: new vo.Null(), Div0: new vo.Div0(), Value: new vo.Value(), Ref: new vo.Ref(), Name: new vo.Name(), Num: new vo.Num(), NA: new vo.NA(), GettingData: new vo.GettingData(), Spill: new vo.Spill(), Connect: new vo.Connect(), Blocked: new vo.Blocked(), Unknown: new vo.Unknown(), Field: new vo.Field(), Calc: new vo.Calc(), Busy: new vo.Busy(), Python: new vo.Python(), Timeout: new vo.Timeout() }, vo.getBuiltInByLabel = (n) => CI.get(n), vo.newTypedError = (n, e, t) => { let o; return o = typeof n == "string" ? _I.get(n) : EI.get(n), o || (o = vo.Unknown), new o(e, t); }, vo.getBuiltInById = (n) => K1.get(n) || ED; const Pt = { Column: "column", Row: "row" }, Dc = { ...Pt, Both: "both" }, kD = Object.freeze({ colIndex: 0, rowIndex: 0 }), RD = Object.freeze({ colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }), kI = (n, e) => n.colStart === e.colStart ? n.rowStart - e.rowStart : n.colStart - e.colStart, RI = (n, e) => n.rowStart === e.rowStart ? n.colStart - e.colStart : n.rowStart - e.rowStart, MD = (n, e) => n.rowEnd === e.rowEnd ? e.colEnd - n.colEnd : e.rowEnd - n.rowEnd, TD = (n, e) => n.colEnd === e.colEnd ? e.rowEnd - n.rowEnd : e.colEnd - n.colEnd, Bx = (n, e) => n.colIndex === e.colIndex ? n.rowIndex - e.rowIndex : n.colIndex - e.colIndex, zx = (n, e) => n.rowIndex === e.rowIndex ? n.colIndex - e.colIndex : n.rowIndex - e.rowIndex, $x = (n, e) => n.rowIndex === e.rowIndex ? e.colIndex - n.colIndex : e.rowIndex - n.rowIndex, Wx = (n, e) => n.colIndex === e.colIndex ? e.rowIndex - n.rowIndex : e.colIndex - n.colIndex, MI = (n = Pt.Row, e = !1) => e ? n !== Pt.Column ? MD : TD : n !== Pt.Column ? RI : kI, Hx = (n, e) => n === e || !(!n || !e) && n.rowIndex === e.rowIndex && n.colIndex === e.colIndex, Gw = (n, e) => n === e || !(!n || !e) && n.rowStart === e.rowStart && n.rowEnd === e.rowEnd && n.colStart === e.colStart && n.colEnd === e.colEnd, qw = (n, e) => !(!n || !e || n.colStart > e.colEnd || e.colStart > n.colEnd || n.rowStart > e.rowEnd || e.rowStart > n.rowEnd), Vx = (n, e) => { if (n === e) return !0; if (!n || !e || n.length !== e.length) return !1; for (let t = 0; t < n.length; t++) if (!Gw(n[t], e[t])) return !1; return !0; }, R0 = (n, e, t) => { if (!n && !e) return null; if (!n) return t ? e : { ...e }; if (!e) return t ? n : { ...n }; const o = Math.min(n.colStart, e.colStart), r = Math.min(n.rowStart, e.rowStart), i = Math.max(n.colEnd, e.colEnd), s = Math.max(n.rowEnd, e.rowEnd); let a = t; return a ? (a.colStart = o, a.rowStart = r, a.colEnd = i, a.rowEnd = s) : a = { colStart: o, rowStart: r, colEnd: i, rowEnd: s }, a; }, Ux = (n, e) => { if (!e || e.length === 0) return n; const t = { ...n }; for (let o = 0; o < e.length; o++) { const r = e[o]; qw(t, r) && (t.rowStart = Math.min(t.rowStart, r.rowStart), t.colStart = Math.min(t.colStart, r.colStart), t.rowEnd = Math.max(t.rowEnd, r.rowEnd), t.colEnd = Math.max(t.colEnd, r.colEnd)); } return t; }, ID = [null, null], AD = (n, e, t) => { if (n[0].value === n[1].value) return e; }; function Gx(n, e = 2, t, o = Pt.Row, r) { let i = [...n]; if (e <= 0 || n.length <= 1) return i; let s = o === Pt.Column, a = 0, l = !1; do { const c = i.sort(MI(s ? Pt.Row : Pt.Column)); i = [], i.push(c[0]); const d = c.length; let h = 0, u = c[0], p = u.colStart, m = u.rowStart, g = u.colEnd, w = u.rowEnd; for (let f = 1; f < d; f++) { const b = c[f]; let S = !1; if (S = s ? u && m === b.rowStart && w === b.rowEnd && g + 1 === b.colStart : u && p === b.colStart && g === b.colEnd && w + 1 === b.rowStart, S) { let v = { colStart: p, rowStart: m, colEnd: s ? b.colEnd : g, rowEnd: s ? w : b.rowEnd }; if (u.value !== void 0 && (v.value = u.value), t) { const x = r ?? [null, null]; x[0] = u, x[1] = b, v = t(x, v, o); } if (v) { i[h] = v, l = !0, u = v, p = u.colStart, m = u.rowStart, g = u.colEnd, w = u.rowEnd; continue; } } i[++h] = b, u = b, p = u.colStart, m = u.rowStart, g = u.colEnd, w = u.rowEnd; } a++, s = !s, a === 1 && (l = !0); } while (a < e && l && i.length > 1); return i; } const pe = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCell: kD, EmptyRange: RD, cellToRange: (n, e) => { if (!n) return null; let t = e; return t || (t = { ...n }, delete t.colIndex, delete t.rowIndex), t.colStart = n.colIndex ?? 0, t.rowStart = n.rowIndex ?? 0, t.colEnd = n.colIndex ?? 0, t.rowEnd = n.rowIndex ?? 0, t; }, columnFirstCellComparator: Bx, columnFirstRangeComparator: kI, createCellComparator: (n = Pt.Row, e = !1) => e ? n !== Pt.Column ? $x : Wx : n !== Pt.Column ? zx : Bx, createConflatingRanges: (n, e = !1) => { const t = []; let o, r, i = Number.MIN_SAFE_INTEGER, s = Number.MIN_SAFE_INTEGER; return { append: (a, l, c) => { let d = !0; const h = c !== void 0; if (h) { const m = n ? n(r, c, e) : r === c ? c : void 0; m === void 0 ? d = !1 : c = m; } if (d && l === s + 1 && a === i) return e ? o.rowEnd = l : o.colEnd = l, s = l, void (r = c); o && t.push(o); const u = e ? a : l, p = e ? l : a; o = { colStart: u, rowStart: p, colEnd: u, rowEnd: p }, h && (o.value = c), i = a, s = l, r = c; }, done: (a) => (o && (t.push(o), o = null), a ? Gx(t, 3, a === !0 ? AD : a, e ? Pt.Column : Pt.Row, ID) : t) }; }, createRangeComparator: MI, defaultRange: (n, e, t) => n ? t ? (t.colStart = n.colStart ?? e.colStart, t.rowStart = n.rowStart ?? e.rowStart, t.colEnd = n.colEnd ?? e.colEnd, t.rowEnd = n.rowEnd ?? e.rowEnd, t) : { colStart: n.colStart ?? e.colStart, rowStart: n.rowStart ?? e.rowStart, colEnd: n.colEnd ?? e.colEnd, rowEnd: n.rowEnd ?? e.rowEnd } : e, extendRangeToIntersectingRanges: Ux, extendRangeToUnionRanges: (n, e) => { if (!e || e.length === 0) return n; let t = n, o = null; for (; !Gw(t, o); ) o = t, t = Ux(o, e); return t; }, indexOfCoords: (n, e) => { const t = { colStart: n.colIndex, rowStart: n.rowIndex, colEnd: n.colIndex, rowEnd: n.rowIndex }; for (let o = e.length - 1; o >= 0; o--) if (qw(t, e[o])) return o; return -1; }, intersectRanges: (n, e, t) => { if (!n) return t ? e : { ...e }; if (!e) return t ? n : { ...n }; if (!n && !e || n.rowStart > e.rowEnd || n.rowEnd < e.rowStart || n.colStart > e.colEnd || n.colEnd < e.colStart) return null; const o = Math.max(n.colStart, e.colStart), r = Math.max(n.rowStart, e.rowStart), i = Math.min(n.colEnd, e.colEnd), s = Math.min(n.rowEnd, e.rowEnd); let a = t; return a ? (a.colStart = o, a.rowStart = r, a.colEnd = i, a.rowEnd = s) : a = { colStart: o, rowStart: r, colEnd: i, rowEnd: s }, a; }, isCellWithinRange: (n, e) => { if (!n || !e) return !1; const t = n.rowIndex; if (t < e.rowStart || t > e.rowEnd) return !1; const o = n.colIndex; return !(o < e.colStart || o > e.colEnd); }, isEqualCells: Hx, isEqualRanges: Gw, isEqualRangesArrays: Vx, isEqualSelectionCoords: (n, e) => n === e || !(!n || !e) && n.rangeIndex === e.rangeIndex && !!Hx(n.cell, e.cell) && Vx(n.ranges, e.ranges), isRangeWithinRange: (n, e) => !(n.rowStart < e.rowStart || n.rowEnd > e.rowEnd || n.colStart < e.colStart || n.colEnd > e.colEnd), isRangesIntersect: qw, isSingleCell: (n) => !!n && n.rowEnd === n.rowStart && n.colStart === n.colEnd, isValidRange: (n) => !(!n || typeof n.colStart != "number" || n.colStart < 0 || typeof n.colEnd != "number" || n.colEnd < n.colStart || typeof n.rowStart != "number" || n.rowStart < 0 || typeof n.rowEnd != "number" || n.rowEnd < n.rowStart), mergeRangedValues: Gx, reverseColumnFirstCellComparator: Wx, reverseRowFirstCellComparator: $x, rowFirstCellComparator: zx, rowFirstRangeComparator: RI, sanitizeRange: (n) => n ? { colStart: n.colIndex ?? n.colStart ?? 0, rowStart: n.rowIndex ?? n.rowStart ?? 0, colEnd: n.colIndex ?? n.colEnd ?? 0, rowEnd: n.rowIndex ?? n.rowEnd ?? 0 } : null, translateRange: (n, e = -n.rowStart, t = -n.colStart, o) => o ? (o.colStart = n.colStart + t, o.rowStart = n.rowStart + e, o.colEnd = n.colEnd + t, o.rowEnd = n.rowEnd + e, o) : { colStart: n.colStart + t, rowStart: n.rowStart + e, colEnd: n.colEnd + t, rowEnd: n.rowEnd + e }, unionRanges: R0, unionRangesArrays: (n, e, t) => { if (!n || n.length === 0) return null; if (n.length === 1 && !e) return n[0]; let o = n[0]; for (let r = 1; r < n.length; r++) o = R0(o, n[r], t); return e && (o = R0(o, e, t)), o; } }, Symbol.toStringTag, { value: "Module" })); let TI = class { constructor() { this._onceMessageKeys = /* @__PURE__ */ new Set(); } setOverrides(n) { this._overrides = n ?? null; } getOverrides() { return this._overrides; } _write(n, e, t) { if (t?.onceKey) { const i = this._onceMessageKeys; if (i.has(t.onceKey)) return; i.add(t.onceKey); } const o = t?.details, r = this._overrides; if (r) { const i = r[n]; if (i) return void i.bind(r)(e, t); } o === void 0 ? console[n](e) : console[n](e, o); } log(n, e) { return this._write("log", n, e); } error(n, e) { return this._write("error", n, e); } warn(n, e) { return this._write("warn", n, e); } debug(n, e) { return this._write("debug", n, e); } }; const ai = new TI(), et = { Up: "up", Down: "down", Left: "left", Right: "right" }, Ut = { TopLeft: "tl", Top: "t", TopRight: "tr", Left: "l", Center: "c", Right: "r", BottomLeft: "bl", Bottom: "b", BottomRight: "br" }, yr = "text/html", $s = "text/plain", ah = "image/png", OD = Object.freeze({ left: 0, top: 0 }), FD = Object.freeze({ left: 0, top: 0, bottom: 0, right: 0 }), ND = Object.freeze({ x: 0, y: 0, width: 0, height: 0 }), ks = Object.freeze(Object.defineProperty({ __proto__: null, EmptyBounds: ND, EmptyRect: FD, EmptyTopLeft: OD }, Symbol.toStringTag, { value: "Module" })), DD = typeof Symbol == "function" && Symbol.for ? Symbol.for("react.element") : 60103; function PD(n) { return /* @__PURE__ */ (function(e) { return !!e && typeof e == "object"; })(n) && !(function(e) { const t = Object.prototype.toString.call(e); return t === "[object RegExp]" || t === "[object Date]" || (function(o) { return o.$$typeof === DD; })(e); })(n); } function Nu(n, e) { return e.clone !== !1 && e.isMergeableObject(n) ? zl((t = n, Array.isArray(t) ? [] : {}), n, e) : n; var t; } function jD(n, e, t) { return n.concat(e).map(function(o) { return Nu(o, t); }); } function qx(n) { return Object.keys(n).concat((e = n, Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(e).filter(function(t) { return Object.propertyIsEnumerable.call(e, t); }) : [])); var e; } function Kx(n, e) { try { return e in n; } catch { return !1; } } function zl(n, e, t) { (t = t || {}).arrayMerge = t.arrayMerge || jD, t.isMergeableObject = t.isMergeableObject || PD, t.cloneUnlessOtherwiseSpecified = Nu; const o = Array.isArray(e); return o === Array.isArray(n) ? o ? t.arrayMerge(n, e, t) : (function(r, i, s) { const a = {}; return s.isMergeableObject(r) && qx(r).forEach(function(l) { a[l] = Nu(r[l], s); }), qx(i).forEach(function(l) { (function(c, d) { return Kx(c, d) && !(Object.hasOwnProperty.call(c, d) && Object.propertyIsEnumerable.call(c, d)); })(r, l) || (Kx(r, l) && s.isMergeableObject(i[l]) ? a[l] = (function(c, d) { if (!d.customMerge) return zl; const h = d.customMerge(c); return typeof h == "function" ? h : zl; })(l, s)(r[l], i[l], s) : a[l] = Nu(i[l], s)); }), a; })(n, e, t) : Nu(e, t); } zl.all = function(n, e) { if (!Array.isArray(n)) throw new Error("first argument should be an array"); return n.reduce(function(t, o) { return zl(t, o, e); }, {}); }; const M0 = Object.freeze([]), LD = Object.freeze({}), Xx = (n) => n, Vm = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(n) { let e = 16 * Math.random() | 0; return (n === "x" ? e : 3 & e | 8).toString(16); }), II = (n, e) => n === e || !(!Array.isArray(n) || !Array.isArray(e) || n.length !== e.length) && n.every((t, o) => t === e[o]), zd = (n) => typeof n == "object" && !Array.isArray(n) && n !== null, AI = (n) => typeof n != "object" || Array.isArray(n) || n === null ? n : (Object.keys(n).forEach(function(e) { n[e] && typeof n[e] == "object" ? AI(n[e]) : n[e] !== null && n[e] !== void 0 || delete n[e], typeof n[e] == "object" && Object.keys(n[e]).length === 0 && delete n[e]; }), Object.keys(n).length === 0 ? null : n), BD = (n, e) => !(n !== e && !II(n, e) && !n.isEqual?.(e)), OI = (n, e, t = BD) => { if (n == null || n === e) return null; if (!n || typeof n != "object" || Array.isArray(n) || n.isImmutable?.()) return t(n, e) ? null : n; const o = Object.keys(n), r = o.length; if (r === 0) return null; let i = !1; for (let s = 0; s < r; s++) { const a = o[s]; OI(n[a], e?.[a], t) === null && (i = !0, delete n[a]); } return i && Object.keys(n).length === 0 ? null : void 0; }, Yx = typeof performance == "object" && typeof performance.now == "function" ? () => performance.now() : () => Date.now(), Jx = (n) => n == null, Zx = (n, e) => !(e.left > n.right || e.right < n.left || e.top > n.bottom || e.bottom < n.top), Qx = !(typeof window > "u" || !window.document || !window.document.createElement), Ir = { Windows: "windows", MacOS: "macos", IOS: "ios", Linux: "linux", Android: "android", Safari: "safari", Firefox: "firefox", Node: "node", Unknown: "unknown" }, Th = () => { if (FI()) return Ir.Node; const n = globalThis.navigator !== void 0 && globalThis.navigator.userAgent ? globalThis.navigator.userAgent.toLowerCase() : ""; return n ? /(win32|win64|windows|wince)/i.test(n) ? Ir.Windows : /(macintosh|macintel|macppc|mac68k|macos)/i.test(n) ? Ir.MacOS : /(iphone|ipad|ipod)/i.test(n) ? Ir.IOS : /android/.test(n) ? Ir.Android : /linux/.test(n) ? Ir.Linux : /^((?!chrome|android|).)*safari/i.test(n) ? Ir.Safari : /^((?!chrome|android|Seamonkey).)*firefox/i.test(n) ? Ir.Firefox : Ir.Unknown : Ir.Unknown; }; function FI() { return typeof process < "u" && process.release?.name === "node" || (typeof process < "u" && process.browser, !1); } const ev = (n, e = !1) => (document.hasFocus() || e) && (n === document.activeElement || n?.contains(document.activeElement)), re = Object.freeze(Object.defineProperty({ __proto__: null, EmptyArray: M0, EmptyObject: LD, OSType: Ir, arrayMove: function(n, e, t) { const o = n.slice(); return o.splice(t < 0 ? o.length + t : t, 0, o.splice(e, 1)[0]), o; }, asNumber: (n) => { const e = ((t) => 1 * t)(n); return Number.isFinite(e) ? e : 0; }, camelToPrettyCase: (n) => n.length === 1 ? n.toUpperCase() : n.replace(/([A-Z])/g, " $1").replace(/^./, function(e) { return e.toUpperCase(); }).trim(), canUseDOM: Qx, cancelTimeout: (n) => { cancelAnimationFrame(n.id); }, castToString: (n) => n == null || n === void 0 ? "" : typeof n != "string" ? "" + n : n, cloneObject: (n) => Jx(n) ? n : JSON.parse(JSON.stringify(n)), consoleWithNoSource: (...n) => new Promise((e) => { setTimeout(() => { Function("console.log.apply(console, arguments)").apply(null, n), e(); }); }), debounce: function(n, e = 300, t = !1) { let o, r, i, s, a = 0; function l() { let d = Date.now() - a; d < e && d >= 0 ? o = setTimeout(l, e - d) : (o = null, t || (s = n.apply(i, r), i = r = null)); } e == null && (e = 100); const c = function() { i = globalThis, r = arguments, a = Date.now(); var d = t && !o; return o || (o = setTimeout(l, e)), d && (s = n.apply(i, r), i = r = null), s; }; return c.clear = function() { o && (clearTimeout(o), o = null); }, c.flush = function() { o && (s = n.apply(i, r), i = r = null, clearTimeout(o), o = null); }, c; }, deepEqual: function n(e, t) { if (e === t) return !0; if (e && t && typeof e == "object" && typeof t == "object") { if (e.constructor !== t.constructor) return !1; let o, r, i; if (Array.isArray(e)) { if (o = e.length, o != t.length) return !1; for (r = o; r-- !== 0; ) if (!n(e[r], t[r])) return !1; return !0; } if (e instanceof Map && t instanceof Map) { if (e.size !== t.size) return !1; for (r of e.entries()) if (!t.has(r[0])) return !1; for (r of e.entries()) if (!n(r[1], t.get(r[0]))) return !1; return !0; } if (e instanceof Set && t instanceof Set) { if (e.size !== t.size) return !1; for (r of e.entries()) if (!t.has(r[0])) return !1; return !0; } if (ArrayBuffer.isView(e) && ArrayBuffer.isView(t)) { if (o = e.length, o != t.length) return !1; for (r = o; r-- !== 0; ) if (e[r] !== t[r]) return !1; return !0; } if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags; if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf(); if (e.toString !== Object.prototype.toString) return e.toString() === t.toString(); if (i = Object.keys(e), o = i.length, o !== Object.keys(t).length) return !1; for (r = o; r-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(t, i[r])) return !1; for (r = o; r-- !== 0; ) { let s = i[r]; if (!(s === "_owner" && e.$$typeof || n(e[s], t[s]))) return !1; } return !0; } return e != e && t != t; }, deepFreeze: function n(e) { return Object.freeze(e), Object.keys(e).forEach((t) => { typeof e[t] != "object" || e[t] === null || Object.isFrozen(e[t]) || n(e[t]); }), e; }, deepMerge: zl, diffValues: (n, e) => { const t = {}, o = Object.keys(e), r = o.length; for (let i = 0; i < r; i++) { const s = o[i], a = n[s], l = e[s]; a !== l && (t[s] = a === void 0 ? l : a); } return Object.keys(t).length === 0 ? null : t; }, findEqualOrGreater: function(n, e, t = Xx) { let o = 0, r = n.length - 1; for (; o <= r; ) { let i = Math.floor((o + r) / 2), s = t(n[i]); if (s === e) return i; s < e ? o = i + 1 : r = i - 1; } return o; }, findEqualOrLesser: function(n, e, t = Xx) { let o = n.length - 1, r = 0; for (; o >= r; ) { let i = Math.floor((o + r) / 2), s = t(n[i]); if (s === e) return i; s > e ? o = i - 1 : r = i + 1; } return o; }, findNextStep: (n, e = !0, t = 15, o = 10, r = 400) => { const i = Math.max(n - o, 0) + (e ? 1 : -1); return Math.min(r, Math[e ? "ceil" : "floor"](i / t) * t + o); }, getDPI: () => { let n = 1; return typeof window == "object" && (n = window.devicePixelRatio || 1), n; }, getFromPath: (n, e) => { const t = e.split("."); let o = n; const r = t.length; for (let i = 0; i < r; i++) { const s = t[i]; if (!o) return null; let a = o[s]; if (typeof a == "function" && (a = a.bind(o)()), !a || !zd(a)) return a; o = a; } return o ?? null; }, getOS: Th, hasFocus: ev, isDefined: (n) => n != null, isEmpty: (n) => n == null || n === "", isEqualArrays: II, isEqualBounds: (n, e) => n === e || !(n && !e || e && !n) && n.x === e.x && n.y === e.y && n.width === e.width && n.height === e.height, isEqualObjectKeys: (n, e) => { if (n === e) return !0; if (n && !e || e && !n) return !1; const t = Object.keys(n), o = t.length; if (o !== Object.keys(e).length) return !1; for (let r = 0; r < o; r++) { const i = t[r]; if (n[i] !== e[i]) return !1; } return !0; }, isNode: FI, isNullOrUndefined: Jx, isNumeric: (n) => { const e = 1 * n; return Number.isFinite(e) && typeof e == "number"; }, isObject: zd, isPromiseLike: (n) => !!n && typeof n.then == "function", isRectInsideRect: (n, e) => n.top >= e.top && n.bottom <= e.bottom && n.left >= e.left && n.right <= e.right, isRectIntersect: Zx, mergeContentful: (...n) => { const e = n.length; if (e > 0 && n[e - 1] !== void 0 && !zd(n[e - 1])) return n[e - 1]; let t = n[0] || {}; for (let o = 1; o < e; o++) t = zl(t, n[o] || {}, { arrayMerge: (r, i) => [...i] }); return t; }, nextTick: (n) => { typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(() => { n(); }) : (typeof setImmediate == "function" ? setImmediate : setTimeout)(() => { n(); }); }, openFileDialog: (n = "*.*") => new Promise((e, t) => { if (!Qx) return void t("Unable to open dialog with no dom."); const o = document.createElement("input"); o.type = "file", o.accept = n; let r = null, i = !1; globalThis.addEventListener?.("focus", () => { setTimeout(() => { r || i || (i = !0, e(null)); }, 1e3); }, { once: !0, passive: !0 }), o.onchange = () => { if (r = o.files[0], r) { if (i) return void console.warn("File open detected after faux cancel.", r); e(r); } }, o.autofocus = !0, o.click(); }), rafThrottle: (n) => { let e, t = !1, o = function() { t = !1, n(e); }; return function(r) { e = r, e && e.persist && e.persist(), t || (t = !0, requestAnimationFrame(o)); }; }, removeEmptyProperties: AI, removeEqualValues: OI, removeListenerAll: (n) => { if (!n) return M0; const e = n.length; for (let t = 0; t < e; t++) { const o = n[t]; o && o(); } return M0; }, requestTimeout: (n, e) => { const t = Yx(), o = { id: requestAnimationFrame(function r() { Yx() - t >= e ? n.call(null) : o.id = requestAnimationFrame(r); }) }; return o; }, roundAccurately: (n, e = 0) => { if (n == null || !isFinite(n)) return null; const t = 10 ** e; return Number(Math.round(n * t) / t); }, setToPath: (n, e, t) => { const o = e.split("."); let r = n; if (!r) throw new Error("Can not set path to a null path."); const i = o.length; for (let s = 0; r && s < i - 1; s++) { const a = o[s]; let l = r[a]; if (l == null && (l = {}, r[a] = l), !zd(l)) throw new Error("Can not set path to a non object path."); r = l; } if (typeof t != "number" && typeof t != "boolean" && typeof t != "string" && !zd(t)) throw new Error(`Can not set path to ${t} that is not a a supported primitive.`); return r[o[i - 1]] = t, n; }, splitNumber: (n) => { let e = Math.abs(n); if (isNaN(e) || !isFinite(n)) return null; let t = 0 | e, o = e - t, r = 0, i = 0, s = 1; if (o > 5e-8) for (; i < 8 && Math.abs(r / s - o) > 5e-8; ) i++, s *= 10, r = Math.round(o * s); return { ip: Math.trunc(n), fp: r, ipLength: Math.ceil(Math.log10(t + 1)), fpLength: i }; }, subtractRect: (n, e, t = !1) => { if (!e) return [n]; if (!Zx(n, e)) return []; const o = []; let r = n; const i = () => { e.top > r.top && e.top < r.bottom && (o.push({ ...r, bottom: e.top }), r = { ...r, top: e.top }); }, s = () => { e.bottom > r.top && e.bottom < r.bottom && (o.push({ ...r, top: e.bottom }), r = { ...r, bottom: e.bottom }); }, a = () => { e.right > r.left && e.right < r.right && (o.push({ ...r, left: e.right }), r = { ...r, right: e.right }); }, l = () => { e.left > r.left && e.left < r.right && (o.push({ ...r, right: e.left }), r = { ...r, left: e.left }); }; return t ? (l(), a(), i(), s()) : (i(), s(), a(), l()), o; }, textToKey: (n) => n.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(), throttle: function(n, e) { let t = null; return (...o) => { const r = Date.now(); (!t || r - t >= e) && (t = r, n(...o)); }; }, toSafeJSON: function n(e) { if (e === null || typeof e != "object") return e; if (typeof e.toJSON == "function") return e.toJSON(); if (Array.isArray(e)) return e.map((o) => n(o)); if (typeof e.toString == "function" && e.toString !== Object.prototype.toString) return e.toString(); const t = {}; for (const o in e) e.hasOwnProperty(o) && (t[o] = n(e[o])); return t; }, transpose: (n) => { if (!n) return n; const e = n.length, t = n[0].length, o = []; for (let r = 0; r < t; r++) o[r] = Array(e); for (let r = 0; r < e; r++) for (let i = 0; i < t; i++) o[i][r] = n[r][i]; return o; }, uuidV4: Vm, validEnumValue: (n, e) => { if (!Object.values(n).includes(e)) throw new Error(`Invalid type: ${e ?? "null"}. Must be one of: ${Object.values(e).join(", ")}.`); }, whenFocus: async (n, e = !1) => new Promise((t) => { ev(n, e) ? t(!0) : n.addEventListener("focusin", () => { t(!0); }, { once: !0 }), n.focus(); }) }, Symbol.toStringTag, { value: "Module" })), zD = Object.freeze(Object.defineProperty({ __proto__: null, MESSAGE_ERROR_INVALID_ARG: (n) => `Invalid argument: '${n}'.` }, Symbol.toStringTag, { value: "Module" })), NI = (n) => { const e = new Uint8Array(n), t = e.byteLength; let o = ""; for (let r = 0; r < t; r++) o += String.fromCharCode(e[r]); if (typeof window < "u" && typeof globalThis.btoa == "function") return globalThis.btoa(o); if (typeof Buffer < "u") return Buffer.from(o, "binary").toString("base64"); throw new Error("Unsupported environment"); }, Kw = (n) => new Promise((e, t) => { if (n) if (typeof FileReader < "u") { const o = new FileReader(); o.onload = () => { e(o.result); }, o.onerror = () => { t(o.error); }, o.readAsText(n); } else if (typeof Buffer < "u") { const o = (r) => Buffer.from(r).toString("utf-8"); n.arrayBuffer().then((r) => { e(o(r)); }).catch((r) => { t(r); }); } else t(new Error("Unsupported environment")); else e(""); }), Pc = Object.freeze(Object.defineProperty({ __proto__: null, DEFAULT_MIME_TYPE: "*/*", arrayBufferToBase64: NI, base64ToArrayBuffer: (n) => { const e = typeof window < "u" && typeof globalThis.atob == "function" ? globalThis.atob(n) : Buffer.from(n, "base64").toString("binary"), t = e.length, o = new Uint8Array(t); for (let r = 0; r < t; r++) o[r] = e.charCodeAt(r); return o.buffer; }, blobToString: Kw }, Symbol.toStringTag, { value: "Module" })), DI = "data:image/png;base64,", PI = "Unable to resolve image.", tv = (n) => new Promise(async (e, t) => { let o = null; try { o = new Image(), o.src = n, o.addEventListener("load", function() { e({ width: o.naturalWidth, height: o.naturalHeight }); }, { once: !0 }), o.addEventListener("error", function() { URL.revokeObjectURL(n), t("Invalid Image"); }, { once: !0 }), await o.decode("sync"); } catch { o?.src && URL.revokeObjectURL(o.src); } o || t(PI); }), T0 = "image/svg+xml", Um = Object.freeze(Object.defineProperty({ __proto__: null, DATA_URL_PNG_PREFIX: DI, getImageDataUrl: (n, e = 1) => new Promise(async (t, o) => { let r = null; try { r = new Image(), r.src = n, r.addEventListener("load", function() { try { const i = document.createElement("canvas"); i.width = r.naturalWidth, i.height = r.naturalHeight, i.getContext("2d").drawImage(r, 0, 0); const s = i.toDataURL("image/png", e); t({ elemImg: r, dataUrl: s }); } catch (i) { URL.revokeObjectURL(n), o(i); } }, { once: !0 }), r.addEventListener("error", function() { URL.revokeObjectURL(n), o("Invalid Image"); }, { once: !0 }), await r.decode("sync"); } catch { r?.src && URL.revokeObjectURL(r.src); } r || o(PI); }), loadImageDetails: async (n, e = null) => { let t = null; const o = async () => { try { const i = e ?? "image/*", s = URL.createObjectURL(new Blob([n], { type: i })), a = await tv(s); t = { mimeType: i, naturalSize: a, asUrl: s }; } catch { } }, r = async () => { try { const i = new TextDecoder().decode(n), s = URL.createObjectURL(new Blob([i], { type: T0 })), a = await tv(s); t = { mimeType: e ?? T0, naturalSize: a, asUrl: s, asSVGText: i }; } catch { } }; if (e === T0 ? await r() : e.startsWith("image/") ? await o() : (await o(), t || await r()), !t) throw new Error("Failed to load image"); return t; } }, Symbol.toStringTag, { value: "Module" })); function I0(n, e) { e || (e = {}), typeof e == "function" && (e = { cmp: e }); let t = typeof e.cycles == "boolean" && e.cycles; const o = e.cmp && /* @__PURE__ */ (function(i) { return function(s) { return function(a, l) { const c = { key: a, value: s[a] }, d = { key: l, value: s[l] }; return i(c, d); }; }; })(e.cmp); let r = []; return (function i(s) { if (s && s.toJSON && typeof s.toJSON == "function" && (s = s.toJSON()), s === void 0) return; if (typeof s == "number") return isFinite(s) ? "" + s : "null"; if (typeof s != "object") return JSON.stringify(s); let a; if (Array.isArray(s)) { a = "["; for (let d = 0; d < s.length; d++) d && (a += ","), a += i(s[d]) || "null"; return a + "]"; } if (s === null) return "null"; if (r.indexOf(s) !== -1) { if (t) return JSON.stringify("__cycle__"); throw new TypeError("Converting circular structure to JSON"); } const l = r.push(s) - 1, c = Object.keys(s).sort(o && o(s)); a = ""; for (let d = 0; d < c.length; d++) { const h = c[d], u = i(s[h]); u && (a && (a += ","), a += JSON.stringify(h) + ":" + u); } return r.splice(l, 1), "{" + a + "}"; })(n); } var yo, nv; (nv = yo || (yo = {})).resolveTypedUpdates = (n, e, t, o) => { if (n === null) return n; if (n === void 0) return o; let r = n; if (e?.shorthand) { const l = e?.shorthand(n, t); l !== void 0 && (r = l); } if (r !== null && e?.getSubType) { const l = e.getSubType(r); l && (e = l); } const i = e?.properties, s = e?.arrayType ?? !1; let a = r; if (e && e.merge && a && o) a = e.merge(a, o, t); else if (!s && i) { const l = Object.keys({ ...r, ...o }); a = null; const c = l.length; for (let d = 0; d < c; d++) { const h = l[d]; let u, p = r[h]; if (p !== void 0) { const m = i[h]; u = m ? (0, nv.resolveTypedUpdates)(p, m, t, o?.[h]) : p; } else u = o?.[h]; u != null && (a = a ?? {}, a[h] = u); } } return a; }; class $l extends Error { constructor(e, t = null) { super(e, t), this.name = "ChainedError", this._cause = t; } get cause() { return this._cause; } } let gt = class extends Error { constructor(n, e) { super(n, e); } }, uo = class extends gt { constructor(n = "Out of bounds", e = null) { super(n, e), this.name = "OutOfBoundsError"; } }, jI = class extends $l { constructor(n = "Partial Error", e = null) { super(n, e); } }, Qi = class extends $l { constructor(n = "Null not supported", e = null) { super(n, e); } }, ov = class extends Error { constructor(n = "Null not supported", e) { super(n), this._type = e; } get type() { return this._type; } }, LI = class extends $l { constructor(n = "Not implemented", e = null) { super(n, e); } }; const BI = (n, e = !1) => { const t = [], o = (r, i = 0) => { if (!r || (t.push({ error: r, depth: i }), e && r instanceof gt)) return; const s = r.cause; s && s instanceof Error && o(s, i + 1); }; return o(n), t.reverse(); }, rv = `The Safari browser does not support advanced copy and paste. Copy and paste will be limited to within the browser tab. Please use Chrome or Edge if external copy and paste is required.`, A0 = `You do not have permissions to access the clipboard. All copy and paste operations will be limited to the browser tab.`, zI = { Safari: `The Safari browser does not support advanced copy and paste. Copy and paste will be limited to within the browser tab. Please use Chrome or Edge if external copy and paste is required.`, Perms: A0, PermsWrite: Th() === Ir.Safari ? rv : A0, PermsRead: Th() === Ir.Safari ? rv : A0 }, O0 = async () => new Promise((n) => { document.hasFocus() ? n() : globalThis.addEventListener?.("focus", () => { n(); }, { once: !0 }), document.activeElement.focus?.(); }), F0 = async (n, e, t) => { if (Th() === Ir.Safari) return await t(new Error(zI.Safari)); try { const o = async (s) => { try { return await s(); } catch (a) { if (a.message?.includes("Document is not focused")) return !1; throw a; } }, r = await globalThis?.navigator?.permissions?.query({ name: n, allowWithoutGesture: !0, allowWithoutSanitization: !0 }); let i = !1; if (r.state === "prompt" && (i = await o(e)), i || r.state !== "granted" || (i = await e()), !i) return await t(new Error(r.state)); } catch (o) { return o.message === "No valid data on clipboard" || o.name === "DataError" ? void 0 : await t(o); } }, $I = async (n) => { try { return await n.read({ unsanitized: [yr] }); } catch { } return await n.read(); }, WI = async (n, e) => { if (!n) return null; const t = await $I(n); let o = !1; for (let r = 0; !o && t && r < t.length; r++) if (o = t[r].types.includes(e), o) return await t[r].getType(e); return o ? void 0 : null; }; if (!globalThis.ClipboardItem) { const n = (t, o) => new Blob([o], { type: t }); class e { constructor(o, r) { this._items = {}, this._types = Object.keys(o); const i = {}, s = Object.keys(o); for (let a = 0; a < s.length; a++) { const l = s[a]; let c = o[l]; i[l] = typeof c == "string" ? n(l, c) : c; } this._items = i, this._presentationStyle = r?.presentationStyle ?? "unspecified"; } get types() { return this._types; } getType(o) { return Promise.resolve(this._items[o]); } supports(o) { return !0; } } globalThis.ClipboardItem = e; } const Dg = async (n, e = yr) => new Promise(async (t, o) => { try { const r = await WI(n, e); if (r) { const i = new FileReader(); i.onload = () => { t(i.result); }, i.onerror = () => { t(""); }, i.readAsText(r); } else t(""); } catch (r) { o(r); } }), Xw = async (n, e = yr) => { const t = await Dg(n, e); if (!t) return null; let o = null; try { o = new DOMParser().parseFromString(t, yr); } catch { console.warn("Can't parse html from clipboard."); } return o; }, $D = async (n) => { n && await n.writeText(""); }, WD = WI, HD = Dg, VD = Xw, Ih = "clipboard-uuid", ic = "web text/uuid", iv = (n) => `<div style="display:none" ${Ih}="${n}"/>`, UD = (n, e) => { let t = null; try { const o = new DOMParser().parseFromString(e, yr); o.body.firstElementChild.setAttribute(Ih, n), t = o.getElementsByTagName("body")[0].innerHTML; } catch (o) { console.warn("Can't embed uuid.", o); } return t; }, sv = (n, e) => { if (!e || !n) return !1; try { const t = e.querySelectorAll(`[${Ih}="${n}"]`); if (t && t.length === 1) return !0; if (e.querySelector("parsererror")) throw new Error("We are unable to parse node"); return !1; } catch { return !1; } }; let sd = class { constructor(n) { if (n?.nativeClipboard === void 0 || n?.nativeClipboard === !0) try { this._nativeClipboard = globalThis?.navigator.clipboard; } catch { n?.nativeClipboard === !0 && console.warn("NativeClipboard option set to true but no native clipboard available."); } else this._nativeClipboard = n?.nativeClipboard === !1 ? null : n?.nativeClipboard; this._disableCheckOnFocus = n?.disableCheckOnFocus ?? !1, this._init(); } async _checkForChanges() { this._nativeClipboard && this._state && !this._disableCheckOnFocus && await F0("clipboard-read", async () => { await O0(); const n = await Dg(this._nativeClipboard, ic); if (!this._state || n && n === this._state.uuid) return !0; const e = await Xw(this._nativeClipboard, yr); return !this._state || (sv(this._state.uuid, e) || this.clear(), !0); }, async (n) => { n?.message === "denied" || n.message?.includes("Document is not focused") || Th() === Ir.Safari || console.warn("Unable to detect clipboard changes: ", n); }); } _init() { const n = this; this._listeners = /* @__PURE__ */ new Map(), this._listenersCapture = /* @__PURE__ */ new Map(), this._state = null, this._nativeClipboard && (this._onFocus = () => { n._checkForChanges(); }, this._onBlur = () => { globalThis.addEventListener?.("focus", n._onFocus, { once: !0 }); }, globalThis.addEventListener?.("blur", this._onBlur), this._nativeClipboard.addEventListener("clipboardchange", (e) => { n._checkForChanges(); })); } async read() { if (!this._nativeClipboard) return this._state?.items ?? null; const n = this; return await F0("clipboard-read", async () => { if (await O0(), this._state?.uuid) { const e = await Dg(this._nativeClipboard, ic); if (e && e === n._state.uuid) return !0; const t = await Xw(this._nativeClipboard, yr); if (sv(n._state?.uuid, t)) return !0; } return n._state = { items: await $I(this._nativeClipboard), uuid: null, ref: null }, this.dispatchEvent(new Event("clipboardread")), !0; }, async (e) => { this.dispatchEvent(new Event("clipboarderrorread")); }), this._state?.items ?? []; } async write(n) { return this._write({ uuid: Vm(), items: n, ref: null }); } async _write(n) { if (!this._nativeClipboard) return this._state = n, this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")), null; const e = this, t = [], o = n.uuid; let r = n.items ?? []; const i = () => { e._state = { uuid: o, ref: n.ref, items: t }, e.dispatchEvent(new Event("clipboardwrite")), e.dispatchEvent(new Event("clipboardchange")); }; await F0("clipboard-write", async () => { await O0(), o && r.length === 0 && (r.push(new ClipboardItem({ [ic]: new Blob([o], { type: ic }) })), r.push(new ClipboardItem({ [yr]: new Blob([iv(o)], { type: yr }) }))); for (let s = 0; s < Math.min(1, r.length); s++) { const a = r[s]; let l = a.types.indexOf(yr), c = null; if (l !== -1) { const u = await a.getType(yr); c = await Kw(u), c && (c = UD(o, c)); } if (!c && a.types.includes($s)) { const u = await a.getType($s); if (u) { let p = null; typeof u == "string" ? (console.warn("text as string", u), p = u) : p = await Kw(u), p && (c = `<div ${Ih}="${o}">${p}</div>`); } } if (!c && a.types.includes(ah)) { const u = await a.getType(ah), p = NI(await u.arrayBuffer()); c = `<div ${Ih}="${o}"><img src="${DI + p}"/></div>`; } !c && o && (c = iv(o)); const d = new Blob([c ?? ""], { type: yr }), h = {}; for (let u = 0; u < a.types.length; u++) { const p = a.types[u]; h[p] = u === l ? d : a.getType(p); } c && l === -1 && (h[yr] = d), o && (h[ic] = new Blob([o], { type: ic })), t.push(new ClipboardItem(h)); } try { t && t.length !== 0 ? await this._nativeClipboard.write(t) : await $D(this._nativeClipboard); } catch (s) { s.message?.includes("Document is not focused") || console.warn("Unable to write to native clipboard: ", s); } return i(), !0; }, async (s) => { this.dispatchEvent(new Event("clipboarderrorwrite")), i(); }); } async writeReference(n