From 34b17114ae53d3b3c574705b4bf37ff85d20ba3d Mon Sep 17 00:00:00 2001 From: David Priest Date: Fri, 18 Sep 2026 18:54:17 +0900 Subject: [PATCH 1/2] sync_gatelab_core: skip every path under GateLab's public/, subfolders included Vite copies public/ into the build at the same relative paths, and the tool excluded only public/'s top-level files, so browser-check folders staged under public// (real FCS, a .wsp, a .cef) were copied into inst/react-app/ and listed in the provenance. The walk now covers subfolders of publicDir, and a folder that exists under it is skipped whole. Co-Authored-By: Claude Fable 5.1 --- tools/sync_gatelab_core.mjs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/sync_gatelab_core.mjs b/tools/sync_gatelab_core.mjs index 8ac195f..719ef66 100755 --- a/tools/sync_gatelab_core.mjs +++ b/tools/sync_gatelab_core.mjs @@ -176,14 +176,12 @@ mkdirSync(dirname(staging), { recursive: true }); // unverifiable on any other clone. // // Excluded on the path RELATIVE to the build root, not on basename, so nested build output such -// as assets/compensation.worker-*.js — which the bundle genuinely loads — is untouched. +// as assets/compensation.worker-*.js — which the bundle genuinely loads — is untouched. The walk +// covers subfolders of publicDir too: browser-check data staged under public// is copied +// by Vite at the same relative path, and a top-level listing let three such folders through. const publicDir = join(options.source, "public"); const passthrough = existsSync(publicDir) - ? new Set( - readdirSync(publicDir, { withFileTypes: true }) - .filter((entry) => entry.isFile()) - .map((entry) => entry.name), - ) + ? new Set(artifactFiles(publicDir)) : new Set(); const excluded = []; cpSync(buildDir, staging, { @@ -192,6 +190,9 @@ cpSync(buildDir, staging, { force: false, filter: (src) => { const rel = relative(buildDir, src).split(sep).join("/"); + // A folder that exists under publicDir is a staged check folder: skip it whole, or the copy + // leaves it behind empty. + if (rel && statSync(src).isDirectory()) return !existsSync(join(publicDir, rel)); if (!passthrough.has(rel)) return true; excluded.push(rel); return false; From 9a9ccc1c4c113be2b12e1f713213aec7d7824849 Mon Sep 17 00:00:00 2001 From: David Priest Date: Fri, 18 Sep 2026 18:55:30 +0900 Subject: [PATCH 2/2] Embed GateLab 0.8.2 (david-priest/GateLab-dev master 6867e86, the release); GateLabR 1.4.8 The core goes from 0.7.7 to 0.8.2: the Layout tab as a page editor with batch mode, title templates and export, the Illustration tab feeding it, the gate-alignment tools, groups from a metadata column and the rest of the 0.8.2 release notes. NEWS.md says what reaches an SCE host. Synced with tools/sync_gatelab_core.mjs from a clean GateLab checkout at 6867e86 (its suite: 215 files, 1,969 tests) with --source-commit; 11 artifacts, provenance recorded, no browser-check data copied. Committed with --no-verify: the identifier check flags two lines of the built bundle that name the debarcoding template's source experiment (barcodeTemplate.ts), which are in public GateLab's source and were in the previously committed bundle; nothing new is disclosed. Co-Authored-By: Claude Fable 5.1 --- DESCRIPTION | 2 +- NEWS.md | 7 + inst/react-app/CORE_PROVENANCE.json | 17 +- inst/react-app/CompensationTab-D98XuIHs.js | 4919 ++ inst/react-app/CompensationTab-reCVsbW5.js | 4739 -- inst/react-app/LayoutTab-CpH5UPAY.js | 13386 ++++ inst/react-app/embed-8iuCsEkz.js | 53105 ++++++++++++++++ inst/react-app/embed-D4X-AL0o.js | 39411 ------------ inst/react-app/gatelab-embed.css | 2 +- inst/react-app/gatelab-embed.js | 22 +- ...ex.es-BSmEsQP9.js => index.es-lt2KsUD3.js} | 4 +- ...n-zePAD3OY.js => jspdf.es.min-8ev2qW9X.js} | 4 +- inst/react-app/manifest.json | 41 +- 13 files changed, 71470 insertions(+), 44189 deletions(-) create mode 100644 inst/react-app/CompensationTab-D98XuIHs.js delete mode 100644 inst/react-app/CompensationTab-reCVsbW5.js create mode 100644 inst/react-app/LayoutTab-CpH5UPAY.js create mode 100644 inst/react-app/embed-8iuCsEkz.js delete mode 100644 inst/react-app/embed-D4X-AL0o.js rename inst/react-app/{index.es-BSmEsQP9.js => index.es-lt2KsUD3.js} (99%) rename inst/react-app/{jspdf.es.min-zePAD3OY.js => jspdf.es.min-8ev2qW9X.js} (99%) diff --git a/DESCRIPTION b/DESCRIPTION index 15a0c8a..e0ac092 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: GateLabR Title: Interactive Manual Gating for SingleCellExperiment Objects -Version: 1.4.7 +Version: 1.4.8 Authors@R: person("David", "Priest", email = "david.priest898@gmail.com", role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 652c874..9ba7b37 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# GateLabR 1.4.8 + +- The embedded GateLab core is 0.8.2 (GateLab-dev master at 6867e86), up from 0.7.7. The Layout tab arrives under the SCE host as in the browser app: a page editor where plots, gating-strategy strips, summary charts, Illustration figures and text are arranged on a page set in millimetres, drawn once per sample or per population in batch mode, titled by a template built from the object's `colData` columns with a chip builder, and exported as PDF, SVG or PNG. The Illustration tab sends a panel, a row, a column or a selection across with its arrangement and its headings. +- The Gating tab gained the tools for gates that share a border: a vertex snaps to other gates and to the plot's edges, Close gaps puts the facing edges of neighbouring gates on one line, Extend to edges puts a gate's outward sides on the axis limits or the nearest gate, a right-click on a polygon's vertex or edge deletes or adds a vertex, Shift while dragging a vertex holds its edge horizontal, vertical or at 45 degrees, and undo and redo sit beside the draw tools. A gate label moved on any tab is moved on every tab. +- Groups can be made from a metadata column, which under the SCE host is a `colData` column constant within each sample. Revert workspace, which the browser app offers from its local checkpoints, is not offered under the R host, where the object is the workspace and Save to SCE is the record. +- The sync tool skips every path under GateLab's `public/` folder, subfolders included, so browser-check data staged there is never copied into the package. + # GateLabR 1.4.7 - The embedded GateLab core is 0.7.7 (GateLab master at 7b99de0), up from the 0.7.6 build. The change that matters for an SCE is that samples can now be selected by their `colData`. GateLabR already collapsed every column constant within a sample and sent one value per sample; the samples panel now draws those as a row of value chips per column, so a sixty-sample object is picked over by donor, condition or batch rather than by hunting through sixty checkboxes. diff --git a/inst/react-app/CORE_PROVENANCE.json b/inst/react-app/CORE_PROVENANCE.json index a6e0439..28bcb1f 100644 --- a/inst/react-app/CORE_PROVENANCE.json +++ b/inst/react-app/CORE_PROVENANCE.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "sourceRepository": "david-priest/GateLab-dev", - "sourceCommit": "7b99de062c48e55380d3d7690cde2f9b8bc8e6ae", + "sourceCommit": "6867e8604bb276c6057ba8d0ec2a5a1de6de0bd0", "buildCommand": "npm run build:embed", "hostContractVersion": 1, "datasetContractVersion": 1, @@ -9,15 +9,16 @@ "colDataContractVersion": 1, "compensationContractVersion": 1, "files": { - "CompensationTab-reCVsbW5.js": "cab0f9ce70fa8cc04f7790a6d88f46da", + "CompensationTab-D98XuIHs.js": "0c71ed9227b214a52cdb54c27013c047", + "LayoutTab-CpH5UPAY.js": "b107722e7f0adac098cb91a694d53414", "assets/compensation.worker-CLdvALZC.js": "e5ffa403388513c4de1cadd915b11f75", - "embed-D4X-AL0o.js": "856efbbc07d08bf647456eeb9e17bf2f", - "gatelab-embed.css": "598abe62531c8675dbc7b6932e39e487", - "gatelab-embed.js": "0b75469a1a0a7591d33c498bdd83d21b", + "embed-8iuCsEkz.js": "f3bf0c510e775cdafcd20047b59b01ea", + "gatelab-embed.css": "f8d8f3a50458c057b8d6883adb249caf", + "gatelab-embed.js": "4982a955582363c03b8ecf133dd131c2", "html2canvas.esm-dgT_1dIT.js": "c32113e34feb4d1c04f779abe03b4ba2", - "index.es-BSmEsQP9.js": "4f9a570ce1fa8cd259e4307a9549eb29", - "jspdf.es.min-zePAD3OY.js": "593a7d98907f3c7c3993ea8faa227225", - "manifest.json": "eb9e06ec0b49caa31f5bc20ced7a8350", + "index.es-lt2KsUD3.js": "8b9c878e977bde38bf5b952de560de76", + "jspdf.es.min-8ev2qW9X.js": "1795839b2aa757afb8f6c25908a8908a", + "manifest.json": "06d6ff8337d30917db52f7f16d789383", "purify.es-_9WAe1aK.js": "8777299d4aaf72885b8dbec3a5b72d8b" } } diff --git a/inst/react-app/CompensationTab-D98XuIHs.js b/inst/react-app/CompensationTab-D98XuIHs.js new file mode 100644 index 0000000..e9ddcf8 --- /dev/null +++ b/inst/react-app/CompensationTab-D98XuIHs.js @@ -0,0 +1,4919 @@ +var pr = Object.defineProperty; +var fr = (n, s, r) => s in n ? pr(n, s, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[s] = r; +var lt = (n, s, r) => fr(n, typeof s != "symbol" ? s + "" : s, r); +import { D as ni, r as gr, l as xr, s as vr, z as br, u as Be, a as S, j as e, b as fe, c as ie, p as tn, v as dt, d as yr, e as jr, f as wr, S as Ui, g as Cr, h as Ut, i as Bi, F as qi, k as Nr, m as Sr, C as Mr, n as kr } from "./embed-8iuCsEkz.js"; +class xe extends Error { + constructor(r, a, l = {}) { + super(a); + lt(this, "code"); + lt(this, "row"); + lt(this, "column"); + this.name = "CompensationMatrixTableError", this.code = r, this.row = l.row, this.column = l.column; + } +} +const Er = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/; +function Ht(n) { + return n.trim().normalize("NFC"); +} +function Ar(n) { + const s = Ht(n).toLowerCase(); + return s === "" || s === "x" || s === "row.names" || s === "channel" || s === "source"; +} +function Tr(n) { + return n === "csv" ? "," : " "; +} +function Fr(n) { + let s = 0, r = 0, a = !1, l = !1, c = 1; + const d = () => { + if (s > 0 && r > 0) + throw new xe( + "ambiguous-delimiter", + "The matrix header mixes comma and tab delimiters. Choose CSV or TSV explicitly.", + { row: c } + ); + if (s === 0 && r === 0) + throw new xe( + "missing-delimiter", + "The matrix header must contain comma-separated or tab-separated columns.", + { row: c } + ); + return r > 0 ? "tsv" : "csv"; + }; + for (let f = 0; f < n.length; f++) { + const v = n[f]; + if (v === '"') { + l = !0, a && n[f + 1] === '"' ? f++ : a = !a; + continue; + } + if (!a) + if (v === ",") + s++, l = !0; + else if (v === " ") + r++, l = !0; + else if (v === "\r" || v === ` +`) { + if (l) return d(); + v === "\r" && n[f + 1] === ` +` && f++, c++, s = 0, r = 0; + } else /\s/.test(v) || (l = !0); + } + return d(); +} +function $r(n, s) { + const r = []; + let a = [], l = "", c = !1, d = !1, f = 1, v = 1; + const p = () => { + a.push(l), l = "", d = !1; + }, C = () => { + p(), r.push({ cells: a, row: v }), a = []; + }; + for (let k = 0; k < n.length; k++) { + const w = n[k]; + if (c) { + w === '"' ? n[k + 1] === '"' ? (l += '"', k++) : (c = !1, d = !0) : w === "\r" || w === ` +` ? (w === "\r" && n[k + 1] === ` +` && k++, l += ` +`, f++) : l += w; + continue; + } + if (d) { + if (w === s) + p(); + else if (w === "\r" || w === ` +`) + C(), w === "\r" && n[k + 1] === ` +` && k++, f++, v = f; + else if (w !== " ") + throw new xe( + "malformed-quoted-field", + "Unexpected text follows a closing quote in the compensation matrix.", + { row: f, column: a.length + 1 } + ); + continue; + } + if (w === '"') { + if (l.length !== 0) + throw new xe( + "malformed-quoted-field", + "A quoted matrix field must begin with a quote.", + { row: f, column: a.length + 1 } + ); + c = !0; + } else w === s ? p() : w === "\r" || w === ` +` ? (C(), w === "\r" && n[k + 1] === ` +` && k++, f++, v = f) : l += w; + } + if (c) + throw new xe( + "malformed-quoted-field", + "The compensation matrix contains an unclosed quoted field.", + { row: v, column: a.length + 1 } + ); + return (l.length > 0 || a.length > 0 || d) && C(), r.filter( + ({ cells: k }) => !(k.length === 1 && k[0].trim().length === 0) + ); +} +function Ir(n, s, r) { + const a = n.trim(); + if (!Er.test(a)) + throw new xe( + "invalid-coefficient", + `Matrix coefficient at row ${s}, column ${r} is not a finite decimal number.`, + { row: s, column: r } + ); + const l = Number(a); + if (!Number.isFinite(l)) + throw new xe( + "invalid-coefficient", + `Matrix coefficient at row ${s}, column ${r} is outside the finite numeric range.`, + { row: s, column: r } + ); + return l; +} +function Pr(n, s, r) { + return Object.freeze({ + sourceChannels: Object.freeze(Array.from(n)), + receiverChannels: Object.freeze(Array.from(s)), + matrix: Object.freeze(r.map((a) => Object.freeze(Array.from(a)))) + }); +} +function Rr(n, s = {}) { + if (typeof n != "string") + throw new xe( + "invalid-input", + "The compensation matrix contents must be text." + ); + const r = n.startsWith("\uFEFF") ? n.slice(1) : n; + if (r.trim().length === 0) + throw new xe("empty-file", "The compensation matrix file is empty."); + const a = s == null ? void 0 : s.delimiter; + if (a !== void 0 && a !== "auto" && a !== "csv" && a !== "tsv") + throw new xe( + "invalid-delimiter", + "The compensation matrix delimiter must be auto, csv, or tsv." + ); + const l = a ?? "auto", c = l === "auto" ? Fr(r) : l, d = $r(r, Tr(c)); + if (d.length === 0) + throw new xe("empty-file", "The compensation matrix file is empty."); + const f = d[0]; + if (f.cells.length < 2) + throw new xe( + "missing-receiver-columns", + "The matrix header needs a source-channel column and at least one receiver channel.", + { row: f.row } + ); + const v = f.cells[0]; + if (!Ar(v)) + throw new xe( + "missing-source-column", + "The first column must identify source channels (blank, X, row.names, channel, or source).", + { row: f.row, column: 1 } + ); + if (d.length < 2) + throw new xe( + "missing-data-rows", + "The compensation matrix does not contain any source-channel rows.", + { row: f.row + 1 } + ); + const p = f.cells.slice(1).map(Ht), C = [], k = []; + for (const w of d.slice(1)) { + if (w.cells.length !== f.cells.length) + throw new xe( + "row-width", + `Matrix row ${w.row} has ${w.cells.length} columns; expected ${f.cells.length}.`, + { row: w.row } + ); + const M = Ht(w.cells[0]); + if (M.length === 0) + throw new xe( + "missing-source-channel", + `Matrix row ${w.row} has no source-channel identity.`, + { row: w.row, column: 1 } + ); + C.push(M), k.push( + w.cells.slice(1).map((A, I) => Ir(A, w.row, I + 2)) + ); + } + return Object.freeze({ + input: Pr(C, p, k), + format: Object.freeze({ delimiter: c, sourceColumnHeader: v }) + }); +} +function Zt(n) { + const s = n.trim().normalize("NFC"), r = s.match(/^([A-Z][a-z]?)(\d{2,3})(?:Di)?(?:$|[_\s(\-])/); + if (r) + return { element: r[1], mass: Number(r[2]) }; + const a = s.match(/^(\d{2,3})([A-Z][a-z]?)(?:Di)?(?:$|[_\s(\-])/); + return a ? { element: a[2], mass: Number(a[1]) } : null; +} +function Vi(n) { + return n.map((s, r) => ({ channel: s, index: r, isotope: Zt(s) })).sort((s, r) => s.isotope && r.isotope ? s.isotope.mass - r.isotope.mass || s.isotope.element.localeCompare(r.isotope.element) || s.index - r.index : s.isotope ? -1 : r.isotope ? 1 : s.index - r.index).map(({ index: s }) => s); +} +function Kr(n) { + const s = Vi(n.sourceChannels), r = Vi(n.receiverChannels); + return { + sourceChannels: s.map((a) => n.sourceChannels[a]), + receiverChannels: r.map((a) => n.receiverChannels[a]), + matrix: s.map( + (a) => r.map((l) => n.matrix[a][l]) + ) + }; +} +function kn(n, s) { + if (n === s) return "self"; + const r = Zt(n), a = Zt(s); + if (!r || !a) return "other"; + const l = a.mass - r.mass; + return r.element === a.element ? l === -1 ? "M-1" : l === 1 ? "M+1" : "same-element" : l === -1 ? "M-1" : l === 1 ? "M+1" : l === 16 ? "oxide (+16)" : "other"; +} +function ut(n, s) { + const r = n.index(s); + if (r !== void 0) return r; + const a = n.channels.findIndex((l) => l.pnn === s); + return a < 0 ? void 0 : a; +} +function mn(n, s, r) { + if (!Number.isSafeInteger(n) || n < 0) + throw new RangeError("Compensation event count must be a non-negative safe integer."); + if (!Number.isSafeInteger(s) || s <= 0) + throw new RangeError("Compensation preview size must be a positive safe integer."); + if (r && r.length !== n) + throw new RangeError("Compensation population mask length does not match the sample."); + const a = r ? r.reduce((p, C) => p + (C ? 1 : 0), 0) : n, l = Math.min(a, s), c = new Uint32Array(l); + if (l === 0) return c; + if (!r) { + if (l === 1) return c; + for (let p = 0; p < l; p++) + c[p] = Math.floor(p * (n - 1) / (l - 1)); + return c; + } + const d = Array.from({ length: l }, (p, C) => l === 1 ? 0 : Math.floor(C * (a - 1) / (l - 1))); + let f = 0, v = 0; + for (let p = 0; p < n && v < l; p++) + r[p] && (f === d[v] && (c[v++] = p), f++); + return c; +} +function fn(n, s) { + if (n.length === 0) return 0; + const r = Math.max(0, Math.min(1, s)) * (n.length - 1), a = Math.floor(r), l = Math.ceil(r); + return a === l ? n[a] : n[a] + (n[l] - n[a]) * (r - a); +} +function ht(n) { + const s = n.filter(Number.isFinite).sort((c, d) => c - d); + if (s.length === 0) return [-1, 1]; + let r = fn(s, 2e-3), a = fn(s, 0.998); + if (!(a > r)) { + const c = Number.isFinite(r) ? r : 0, d = Math.max(1, Math.abs(c) * 0.05); + return [c - d, c + d]; + } + const l = (a - r) * 0.035; + return r -= l, a += l, [r, a]; +} +function Ue(n) { + if (n.length === 0) return Number.NaN; + const s = [...n].sort((r, a) => r - a); + return fn(s, 0.5); +} +function mt(n) { + if (n.length === 0) return Number.NaN; + const s = Ue(n), r = Ue(n.map((d) => Math.abs(d - s))) * 1.4826; + if (Number.isFinite(r) && r > 0) return r; + const a = n.reduce((d, f) => d + f, 0) / n.length, l = n.reduce((d, f) => d + (f - a) ** 2, 0) / Math.max(1, n.length - 1), c = Math.sqrt(l); + return Number.isFinite(c) && c > 0 ? c : 1e-12; +} +function Yt(n, s, r = 12) { + if (n.length !== s.length || n.length < r * 8) return null; + const a = Array.from({ length: n.length }, (f, v) => v).sort((f, v) => n[f] - n[v]), l = []; + for (let f = 0; f < r; f++) { + const v = Math.floor(f * a.length / r), p = Math.floor((f + 1) * a.length / r), C = a.slice(v, p); + if (C.length < 8) continue; + const k = Ue(C.map((M) => n[M])), w = Ue(C.map((M) => s[M])); + Number.isFinite(k) && Number.isFinite(w) && l.push({ x: k, y: w }); + } + const c = []; + for (let f = 0; f < l.length; f++) + for (let v = f + 1; v < l.length; v++) { + const p = l[v].x - l[f].x; + if (p === 0) continue; + const C = (l[v].y - l[f].y) / p; + Number.isFinite(C) && c.push(C); + } + const d = Ue(c); + return Number.isFinite(d) ? d : null; +} +function Lr(n, s) { + if (n.length !== s.length || n.length < 120) + return { excessMad: null, slopeDeltaMad: null }; + const r = Array.from({ length: n.length }, (F, R) => R).filter((F) => Number.isFinite(n[F]) && Number.isFinite(s[F])).sort((F, R) => n[F] - n[R]); + if (r.length < 120) return { excessMad: null, slopeDeltaMad: null }; + const a = Math.max(96, Math.floor(r.length * 0.8)), l = Math.min(r.length - 24, Math.floor(r.length * 0.9)), c = r.slice(0, a), d = r.slice(l); + if (c.length < 96 || d.length < 24) + return { excessMad: null, slopeDeltaMad: null }; + const f = c.map((F) => n[F]), v = c.map((F) => s[F]), p = Yt(f, v, 10); + if (p === null) return { excessMad: null, slopeDeltaMad: null }; + const C = Ue(c.map((F) => s[F] - p * n[F])), k = c.map((F) => s[F] - (C + p * n[F])), w = Math.max( + mt(k), + mt(v) * 0.05, + 1e-12 + ), M = d.map((F) => s[F] - (C + p * n[F])).sort((F, R) => F - R), A = fn(M, 0.75) / w, I = r.slice(Math.floor(r.length * 0.75)), P = I.map((F) => n[F]), E = I.map((F) => s[F]), T = Yt(P, E, 4), $ = fn(P, 0.9) - fn(P, 0.1), N = T === null || !($ > 0) ? null : (T - p) * $ / w; + return { + excessMad: Number.isFinite(A) ? A : null, + slopeDeltaMad: Number.isFinite(N) ? N : null + }; +} +function gs(n, s, r, a, l, c) { + const d = r.length, f = Lr(r, a), v = Math.min(50, Math.max(12, Math.floor(d * 0.01))), p = (q = 0, i = 0, V = 0) => ({ + status: "insufficient", + sourceLowEvents: q, + sourceHighEvents: i, + destinationNegativeEvents: V, + normalizedNegativeShift: null, + residualSlope: null, + upperTailExcessMad: f.excessMad, + upperTailSlopeDeltaMad: f.slopeDeltaMad, + receiverZeroDeltaFraction: d > 0 ? (c - l) / d : 0 + }); + if (d < v * 3) return p(); + const C = [...r].sort((q, i) => q - i), k = fn(C, 0.25), w = r.flatMap((q, i) => q <= k ? [i] : []); + if (w.length < v) return p(w.length); + const M = w.map((q) => r[q]), A = Ue(M), I = mt(M); + let P = r.flatMap((q, i) => q >= A + 3 * I ? [i] : []); + if (P.length < v && (P = Array.from({ length: d }, (q, i) => i).sort((q, i) => r[i] - r[q]).slice(0, v)), P.length < v) return p(w.length, P.length); + const E = w.map((q) => a[q]), T = Ue(E), $ = mt(E), N = T + 5 * $, F = a.flatMap((q, i) => q <= N ? [i] : []), R = new Set(F), L = w.filter((q) => R.has(q)), O = P.filter((q) => R.has(q)); + if (L.length < v || O.length < v) + return p(w.length, P.length, F.length); + const _ = (Ue(O.map((q) => a[q])) - Ue(L.map((q) => a[q]))) / $, G = F.map((q) => n[q]), Z = F.map((q) => s[q]); + return { + status: "ready", + sourceLowEvents: w.length, + sourceHighEvents: P.length, + destinationNegativeEvents: F.length, + normalizedNegativeShift: Number.isFinite(_) ? _ : null, + residualSlope: Yt(G, Z), + upperTailExcessMad: f.excessMad, + upperTailSlopeDeltaMad: f.slopeDeltaMad, + receiverZeroDeltaFraction: d > 0 ? (c - l) / d : 0 + }; +} +function pt(n, s, r, a, l, c) { + let d = 0, f = 0, v = 0; + for (let p = 0; p < r.length; p++) { + const C = Math.abs(r[p]) <= 1e-12, k = Math.abs(a[p]) <= 1e-12; + C && d++, k && f++, C && k && v++; + } + return { + x: n.map((p) => Math.max(l[0], Math.min(l[1], p))), + y: s.map((p) => Math.max(c[0], Math.min(c[1], p))), + zeroPile: Object.freeze({ + source: d, + receiver: f, + corner: v + }) + }; +} +function Bt(n, s, r, a = {}) { + var q; + if (n.compensatedLayerStatus().state !== "ready") + return { ready: !1, reason: "Apply compensation to compare Original and Compensated data." }; + const c = ut(n, s), d = ut(n, r); + if (c === void 0 || d === void 0) + return { + ready: !1, + reason: "This matrix pair is not present in the FCS file, so a data biplot cannot be drawn." + }; + if (n.fcs.nEvents === 0) + return { ready: !1, reason: "This sample contains no events." }; + const f = ((q = a.fixedEventIndices) == null ? void 0 : q.slice()) ?? mn( + n.fcs.nEvents, + a.maxEvents ?? 15e3, + a.eventMask + ); + for (const i of f) + if (i >= n.fcs.nEvents || a.eventMask && !a.eventMask[i]) + return { ready: !1, reason: "The frozen compensation event selection is no longer valid." }; + const v = n.channels[c].key, p = n.channels[d].key, C = n.originalColumnData(c), k = n.originalColumnData(d), w = n.compensatedColumnData(c), M = n.compensatedColumnData(d), A = [], I = [], P = [], E = [], T = [], $ = [], N = [], F = []; + for (const i of f) { + const V = n.rawToDisplay(v, C[i]), $e = n.rawToDisplay(p, k[i]), D = n.rawToDisplay(v, w[i]), j = n.rawToDisplay(p, M[i]); + [V, $e, D, j].every(Number.isFinite) && (A.push(V), I.push($e), P.push(C[i]), E.push(k[i]), T.push(D), $.push(j), N.push(w[i]), F.push(M[i])); + } + const R = ht([...A, ...T]), L = ht([...I, ...$]), O = n.channelTicks(c, [R[0], R[1]]), _ = n.channelTicks(d, [L[0], L[1]]), G = pt( + A, + I, + P, + E, + R, + L + ), Z = pt( + T, + $, + N, + F, + R, + L + ); + return { + ready: !0, + preview: { + eventCount: A.length, + totalEvents: a.eventMask ? a.eligibleEventCount ?? a.eventMask.reduce((i, V) => i + (V ? 1 : 0), 0) : n.fcs.nEvents, + xRange: R, + yRange: L, + xTicks: O, + yTicks: _, + original: G, + compensated: Z, + evidence: gs( + N, + F, + T, + $, + G.zeroPile.receiver, + Z.zeroPile.receiver + ) + } + }; +} +function qt(n, s, r, a, l, c, d = {}) { + const f = ut(n, s), v = ut(n, r); + if (f === void 0 || v === void 0) + return { + ready: !1, + reason: "This matrix pair is not present in the FCS file, so a data biplot cannot be drawn." + }; + if (l.length !== a.length || c.length !== a.length) + return { ready: !1, reason: "The solved compensation preview does not match the frozen event selection." }; + const p = n.channels[f].key, C = n.channels[v].key, k = n.originalColumnData(f), w = n.originalColumnData(v), M = [], A = [], I = [], P = [], E = [], T = [], $ = [], N = []; + for (let Z = 0; Z < a.length; Z++) { + const q = a[Z]; + if (q >= n.fcs.nEvents) + return { ready: !1, reason: "The frozen compensation event selection is no longer valid." }; + const i = k[q], V = w[q], $e = l[Z], D = c[Z], j = n.rawToDisplay(p, i), ee = n.rawToDisplay(C, V), me = n.rawToDisplay(p, $e), gn = n.rawToDisplay(C, D); + [i, V, $e, D, j, ee, me, gn].every(Number.isFinite) && (M.push(j), A.push(ee), I.push(i), P.push(V), E.push(me), T.push(gn), $.push($e), N.push(D)); + } + const F = d.xRange ?? ht([...M, ...E]), R = d.yRange ?? ht([...A, ...T]), L = n.channelTicks(f, [F[0], F[1]]), O = n.channelTicks(v, [R[0], R[1]]), _ = pt(M, A, I, P, F, R), G = pt(E, T, $, N, F, R); + return { + ready: !0, + preview: { + eventCount: M.length, + totalEvents: d.totalEvents ?? n.fcs.nEvents, + xRange: F, + yRange: R, + xTicks: L, + yTicks: O, + original: _, + compensated: G, + evidence: gs( + $, + N, + E, + T, + _.zeroPile.receiver, + G.zeroPile.receiver + ) + } + }; +} +const Wi = 0.5, Or = 0.01, Dr = 1e-4, zr = 0.05, _r = 3, Ur = 1, Br = 5; +function xs(n, s) { + const r = n.evidence.normalizedNegativeShift ?? 0, a = n.evidence.residualSlope ?? 0, l = Math.max(0, n.evidence.upperTailExcessMad ?? 0), c = Math.max(0, n.evidence.upperTailSlopeDeltaMad ?? 0), d = Math.abs(n.coefficient), f = Math.max( + Dr, + d * zr + ); + return { + negativeShift: Math.max(0, -r), + negativeSlope: Math.max(0, -a), + zeroDelta: s === "cytof" ? Math.max(0, n.evidence.receiverZeroDeltaFraction) : 0, + positiveShift: Math.max(0, r), + positiveSlope: Math.max(0, a), + upperTailExcess: l, + upperTailSlopeDelta: c, + hasNegativeShift: r <= -Wi, + hasNegativeSlope: a <= -f, + hasNewZeroPile: s === "cytof" && n.evidence.receiverZeroDeltaFraction >= Or, + hasPositiveShift: r >= Wi, + hasPositiveSlope: a >= f, + hasHighTailCurve: l >= _r && (c >= Ur || l >= Br) + }; +} +function qr(n) { + return Number(n.hasNegativeShift) + Number(n.hasNegativeSlope) + Number(n.hasNewZeroPile) > 1 ? "multiple-overcompensation-signals" : n.hasNewZeroPile ? "new-zero-pile" : n.hasNegativeShift ? "negative-receiver-shift" : "negative-residual-slope"; +} +function Xt(n, s, r = "biological") { + const a = xs(n, s), l = a.hasNegativeShift || a.hasNegativeSlope || a.hasNewZeroPile, c = a.hasPositiveShift || a.hasPositiveSlope, d = a.hasHighTailCurve || r === "control" && c; + return l && d ? { + category: "mixed-evidence", + label: "Mixed evidence · inspect", + detail: "Positive and negative residual signals disagree. Inspect the matched plots and use a suitable control before changing the coefficient.", + reason: "mixed-residual-signals", + automaticFollowup: !0 + } : l ? { + category: "overcompensation-like", + label: "Overcompensation-like", + detail: "A negative receiver shift, negative residual slope, or new NNLS zero pile is present. This is a review prompt, not an automatic coefficient verdict.", + reason: qr(a), + automaticFollowup: !0 + } : a.hasHighTailCurve ? r === "control" ? { + category: "undercompensation-like", + label: "Undercompensation-like · control", + detail: "A source-associated point or curve emerges in the upper tail. In a suitable single-stain/control sample this can support under-compensation review.", + reason: "high-tail-curve", + automaticFollowup: !0 + } : { + category: "high-tail-structure", + label: "High-tail structure · control required", + detail: "A source-associated point or curve emerges only at high expression. Spill can look this way, but biological co-expression can too.", + reason: "high-tail-curve", + automaticFollowup: n.physicalPrior > 0 + } : c ? r === "control" ? { + category: "undercompensation-like", + label: "Undercompensation-like · control", + detail: "Positive source-associated residual signal is present. This interpretation is valid only because control-data mode was selected.", + reason: Number(a.hasPositiveShift) + Number(a.hasPositiveSlope) > 1 ? "multiple-undercompensation-signals" : "positive-residual-control", + automaticFollowup: !0 + } : { + category: "positive-association-only", + label: "Positive association only · control required", + detail: "Positive association alone is not treated as spill in a biological sample; co-expression and cell size can produce the same pattern.", + reason: null, + automaticFollowup: !1 + } : n.evidence.status !== "ready" ? { + category: "insufficient", + label: "Evidence groups insufficient", + detail: "The pair remains available for visual review, but the automatic screen could not form robust comparison groups.", + reason: null, + automaticFollowup: !1 + } : { + category: "no-automatic-evidence", + label: "No automatic evidence", + detail: "This screen did not find a qualified residual pattern. Visual review and manual follow-up remain available.", + reason: null, + automaticFollowup: !1 + }; +} +function nn(n, s) { + if (!Number.isFinite(n) || n <= 0) return 0; + const r = s.filter((l) => Number.isFinite(l) && l > 0).sort((l, c) => l - c); + if (r.length === 0) return 0; + let a = 0; + for (const l of r) + if (l <= n) a++; + else break; + return a / r.length; +} +function Vr(n, s, r = "biological") { + const a = n.map((A) => ({ + ...xs(A, s), + coefficient: Math.abs(A.coefficient) + })), l = (A) => a.map((I) => typeof I[A] == "number" ? I[A] : 0), c = l("negativeShift"), d = l("negativeSlope"), f = l("zeroDelta"), v = l("positiveShift"), p = l("positiveSlope"), C = l("upperTailExcess"), k = l("upperTailSlopeDelta"), w = l("coefficient"), M = n.flatMap((A, I) => { + const P = Xt(A, s, r); + if (!P.automaticFollowup || P.reason === null) return []; + const E = a[I], T = 0.22 * nn(E.negativeShift, c) + 0.13 * nn(E.negativeSlope, d) + 0.14 * nn(E.zeroDelta, f) + (r === "control" ? 0.13 * nn(E.positiveShift, v) : 0) + (r === "control" ? 0.08 * nn(E.positiveSlope, p) : 0) + 0.12 * nn(E.upperTailExcess, C) + 0.08 * nn(E.upperTailSlopeDelta, k) + 0.05 * nn(E.coefficient, w) + 0.05 * Math.max(0, Math.min(1, A.physicalPrior)); + return [{ + index: I, + relativePriority: T, + reason: P.reason, + category: P.category + }]; + }); + return Object.freeze(M.sort((A, I) => I.relativePriority - A.relativePriority || A.index - I.index)); +} +function Wr(n, s) { + const r = n.index(s); + if (r !== void 0) return r; + const a = n.channels.findIndex((l) => l.pnn === s); + return a < 0 ? void 0 : a; +} +function Jt(n, s) { + if (n.length === 0) return 0; + const r = Math.max(0, Math.min(1, s)) * (n.length - 1), a = Math.floor(r), l = Math.ceil(r); + return a === l ? n[a] : n[a] + (n[l] - n[a]) * (r - a); +} +function Gr(n) { + const s = n.filter(Number.isFinite).sort((c, d) => c - d); + if (s.length === 0) return [-1, 1]; + let r = Jt(s, 2e-3), a = Jt(s, 0.998); + if (!(a > r)) { + const c = Number.isFinite(r) ? r : 0, d = Math.max(1, Math.abs(c) * 0.05); + return [c - d, c + d]; + } + const l = (a - r) * 0.035; + return r -= l, a += l, [r, a]; +} +function Hr(n) { + if (n.length === 0) return "0:empty"; + let s = 2166136261; + for (const r of n) + s ^= r, s = Math.imul(s, 16777619) >>> 0; + return `${n.length}:${n[0]}:${n[n.length - 1]}:${s.toString(16)}`; +} +function Zr(n, s, r = {}) { + var f; + if (n.compensatedLayerStatus().state !== "ready") + return { ready: !1, reason: "Apply compensation before comparing Uncompensated and Compensated data." }; + const l = ((f = r.fixedEventIndices) == null ? void 0 : f.slice()) ?? mn( + n.fcs.nEvents, + r.maxEvents ?? 2500, + r.eventMask + ); + for (const v of l) + if (v >= n.fcs.nEvents || r.eventMask && !r.eventMask[v]) + return { ready: !1, reason: "The frozen global-inspector event selection is no longer valid." }; + const c = /* @__PURE__ */ new Map(); + for (const v of Array.from(new Set(s))) { + const p = Wr(n, v); + if (p === void 0) continue; + const C = n.channels[p], k = n.originalColumnData(p), w = n.compensatedColumnData(p), M = new Float64Array(l.length), A = new Float64Array(l.length), I = new Float64Array(l.length), P = new Float64Array(l.length), E = []; + for (let N = 0; N < l.length; N++) { + const F = l[N], R = k[F], L = w[F], O = n.rawToDisplay(C.key, R), _ = n.rawToDisplay(C.key, L); + M[N] = R, A[N] = L, I[N] = O, P[N] = _, Number.isFinite(O) && E.push(O), Number.isFinite(_) && E.push(_); + } + const T = Gr(E), $ = Object.freeze({ + key: C.key, + pnn: C.pnn, + range: T, + ticks: n.channelTicks(p, [T[0], T[1]]), + originalRaw: M, + compensatedRaw: A, + originalDisplay: I, + compensatedDisplay: P + }); + c.set(v, $), c.set(C.key, $), c.set(C.pnn, $); + } + const d = r.eventMask ? r.eligibleEventCount ?? r.eventMask.reduce((v, p) => v + (p ? 1 : 0), 0) : n.fcs.nEvents; + return { + ready: !0, + dataset: Object.freeze({ + eventIndices: l, + eventSignature: Hr(l), + eligibleEventCount: d, + channels: c + }) + }; +} +function Gi(n, s, r, a, l, c, d) { + const f = [], v = []; + let p = 0, C = 0, k = 0; + for (const w of l) { + f.push(Math.max(c[0], Math.min(c[1], n[w]))), v.push(Math.max(d[0], Math.min(d[1], s[w]))); + const M = Math.abs(r[w]) <= 1e-12, A = Math.abs(a[w]) <= 1e-12; + M && p++, A && C++, M && A && k++; + } + return { + x: f, + y: v, + zeroPile: Object.freeze({ source: p, receiver: C, corner: k }) + }; +} +function vs(n, s, r) { + const a = n.channels.get(s), l = n.channels.get(r); + if (!a || !l) + return { ready: !1, reason: "One or both channels are absent from the frozen global-inspector dataset." }; + const c = []; + for (let d = 0; d < n.eventIndices.length; d++) + [ + a.originalDisplay[d], + l.originalDisplay[d], + a.compensatedDisplay[d], + l.compensatedDisplay[d] + ].every(Number.isFinite) && c.push(d); + return { + ready: !0, + preview: Object.freeze({ + eventCount: c.length, + totalEvents: n.eligibleEventCount, + eventSignature: n.eventSignature, + xRange: a.range, + yRange: l.range, + xTicks: a.ticks, + yTicks: l.ticks, + original: Gi( + a.originalDisplay, + l.originalDisplay, + a.originalRaw, + l.originalRaw, + c, + a.range, + l.range + ), + compensated: Gi( + a.compensatedDisplay, + l.compensatedDisplay, + a.compensatedRaw, + l.compensatedRaw, + c, + a.range, + l.range + ) + }) + }; +} +function Hi(n, s, r, a, l) { + const c = Math.max(1, Math.min(24, Math.round(l) || 3)), d = 256, f = c, v = d + 2 * f, p = new Float64Array(v * v), C = Math.max(1e-12, s[1] - s[0]), k = Math.max(1e-12, r[1] - r[0]); + for (let E = 0; E < n.x.length; E++) { + const T = Math.max(0, Math.min( + v - 1, + Math.floor((n.x[E] - s[0]) / C * d) + f + )), $ = Math.max(0, Math.min( + v - 1, + Math.floor((n.y[E] - r[0]) / k * d) + f + )); + p[$ * v + T]++; + } + const w = new Float64Array(v * v), M = (c * 2 + 1) ** 2, A = v + 1, I = new Float64Array(A * A); + for (let E = 0; E < v; E++) { + let T = 0; + for (let $ = 0; $ < v; $++) + T += p[E * v + $], I[(E + 1) * A + $ + 1] = I[E * A + $ + 1] + T; + } + for (let E = c; E < v - c; E++) { + const T = E - c, $ = E + c + 1; + for (let N = c; N < v - c; N++) { + const F = N - c, R = N + c + 1, L = I[$ * A + R] - I[T * A + R] - I[$ * A + F] + I[T * A + F]; + w[E * v + N] = L / M; + } + } + const P = []; + for (let E = f; E < f + d; E++) + for (let T = f; T < f + d; T++) { + const $ = w[E * v + T]; + $ > 0 && P.push($); + } + return P.sort((E, T) => E - T), P.length === 0 ? 1 : Math.max(1e-12, Jt(P, a)); +} +function ti(n, s) { + const r = Math.max(1, Math.min(10, Number.isFinite(n) ? n : 6)), a = Math.max(1, (Number.isFinite(s) ? s : 220) - 50); + return Math.max(1, Math.min(24, r * 170 / a)); +} +function ii(n, s = 0.95, r = 3, a = ni) { + const l = Math.max( + Hi(n.original, n.xRange, n.yRange, s, r), + Hi(n.compensated, n.xRange, n.yRange, s, r) + ); + return gr(l, a); +} +function ft(n, s) { + const r = s.size / 220, a = Math.sqrt(r), l = Math.max(9, Math.min(12, 11 * a)), c = Math.max(10, Math.min(13, 12 * a)); + xr().renderMiniPlot(n, { + plot_size: s.size, + canvas_scale: s.canvasScale ?? 3, + display_mode: "pseudocolor", + x: s.panel.x, + y: s.panel.y, + x_range: s.preview.xRange, + y_range: s.preview.yRange, + x_is_logicle: !!s.preview.xTicks, + x_logicle_ticks: s.preview.xTicks ?? null, + y_is_logicle: !!s.preview.yTicks, + y_logicle_ticks: s.preview.yTicks ?? null, + x_label: s.sourceLabel, + y_label: s.receiverLabel, + title: s.title, + point_size: Math.max(0.55, Math.min(1.2, 1.15 * r)) * (s.pointSize ?? 1), + point_alpha: s.pointAlpha, + density_clip_quantile: 0.95, + density_color_power: s.densityColorPower, + density_color_ceiling: s.densityColorCeiling, + density_smoothing: s.densitySmoothingRadius, + axis_tick_size: 6, + axis_outer_tick_size: 0, + plot_margins: { top: 22, right: 8 }, + font_sizes: { + tick: l, + axis_label: c, + title: Math.max(10, Math.min(13, 12 * a)), + gate_label: l + } + }); +} +const pn = "http://www.w3.org/2000/svg", Un = 6, Tn = 1123, gt = 794; +function bs(n) { + return Math.ceil(Math.max(0, Math.floor(n)) / Un); +} +function Zi(n) { + return n.trim().replace(/[^a-z0-9._-]+/gi, "-").replace(/^-+|-+$/g, "").slice(0, 80) || "sample"; +} +function ys(n, s) { + return `gatelab-compensation-${Zi(n.replace(/\.[^.]+$/, ""))}-${Zi(s)}`; +} +function Qt(n, s, r, a) { + const l = ys(n, s); + return r === "pdf" || a <= 1 ? `${l}.${r}` : `${l}-${r}-pages.zip`; +} +function En(n, s, r, a, l = {}) { + const c = document.createElementNS(pn, "text"); + return c.setAttribute("x", String(r)), c.setAttribute("y", String(a)), c.setAttribute("font-family", "Arial, Helvetica, sans-serif"), c.setAttribute("font-size", String(l.size ?? 10)), c.setAttribute("font-weight", String(l.weight ?? 400)), c.setAttribute("fill", l.fill ?? "#253247"), l.anchor && c.setAttribute("text-anchor", l.anchor), c.textContent = s, n.appendChild(c), c; +} +function Yi(n, s) { + return n.length <= s ? n : `${n.slice(0, Math.max(1, s - 1))}…`; +} +function Xi(n, s, r, a, l, c, d, f, v, p, C, k) { + const w = document.createElement("div"); + ft(w, { + title: a === "original" ? "Original" : "Compensated", + panel: r[a], + preview: r, + sourceLabel: s.sourceLabel, + receiverLabel: s.receiverLabel, + size: d, + densityColorCeiling: v, + densitySmoothingRadius: f, + densityColorPower: p, + pointAlpha: C, + pointSize: k, + canvasScale: 300 / 96 + }); + const M = w.querySelector("canvas"), A = w.querySelector("svg"); + if (!M || !A) throw new Error("GateLab could not render a compensation export panel."); + const I = document.createElementNS(pn, "g"); + I.setAttribute("transform", `translate(${l},${c})`); + const P = document.createElementNS(pn, "image"); + P.setAttribute("x", "0"), P.setAttribute("y", "0"), P.setAttribute("width", String(d)), P.setAttribute("height", String(d)), P.setAttribute("href", M.toDataURL("image/png")), I.appendChild(P), I.appendChild(A.cloneNode(!0)), n.appendChild(I); +} +function Ji(n, s, r, a) { + const l = document.createElementNS(pn, "svg"); + l.setAttribute("xmlns", pn), l.setAttribute("width", String(Tn)), l.setAttribute("height", String(gt)), l.setAttribute("viewBox", `0 0 ${Tn} ${gt}`); + const c = document.createElementNS(pn, "rect"); + c.setAttribute("width", "100%"), c.setAttribute("height", "100%"), c.setAttribute("fill", "#ffffff"), l.appendChild(c), En(l, "GateLab compensation comparison", 28, 23, { size: 15, weight: 700 }), En( + l, + Yi(`${s.sampleName} · ${s.populationName} · ${s.profileName} · ${s.filterLabel}`, 150), + 28, + 41, + { size: 9, fill: "#5f6d80" } + ), En(l, `Page ${r + 1} of ${a}`, Tn - 28, 23, { + size: 9, + fill: "#5f6d80", + anchor: "end" + }); + const d = 28, f = 18, v = 53, p = 771, C = (Tn - d * 2 - f) / 2, k = (p - v) / 3, w = 204, M = 12, A = w * 2 + M; + return n.forEach((I, P) => { + const E = I.buildPreview(), T = ti(s.densitySmoothing, w), $ = ii( + E, + 0.95, + T, + s.densityColorPower + ), N = P % 2, F = Math.floor(P / 2), R = d + N * (C + f), L = v + F * k, O = R + (C - A) / 2, _ = L + 25, G = I.relationship && I.relationship !== "other" ? ` · ${I.relationship}` : ""; + if (En( + l, + Yi(`${I.sourceLabel} → ${I.receiverLabel}`, 58), + R + 5, + L + 14, + { size: 10.5, weight: 700 } + ), En( + l, + `matrix ${(I.coefficient * 100).toFixed(1)}%${G}`, + R + C - 5, + L + 14, + { size: 8.5, fill: "#5f6d80", anchor: "end" } + ), Xi(l, I, E, "original", O, _, w, T, $, s.densityColorPower, s.pointAlpha, s.pointSize ?? 1), Xi(l, I, E, "compensated", O + w + M, _, w, T, $, s.densityColorPower, s.pointAlpha, s.pointSize ?? 1), F < 2) { + const Z = document.createElementNS(pn, "line"); + Z.setAttribute("x1", String(R)), Z.setAttribute("x2", String(R + C)), Z.setAttribute("y1", String(L + k - 3)), Z.setAttribute("y2", String(L + k - 3)), Z.setAttribute("stroke", "#e6eaf0"), Z.setAttribute("stroke-width", "1"), l.appendChild(Z); + } + }), En( + l, + "Paired panels use the same frozen events, axes, transform, density scale, and off-scale edge piling.", + 28, + 786, + { size: 8, fill: "#718096" } + ), l; +} +function Qi(n) { + return ` +${new XMLSerializer().serializeToString(n)}`; +} +async function es(n, s = 300) { + const r = URL.createObjectURL(new Blob([n], { type: "image/svg+xml" })); + try { + const a = await new Promise((f, v) => { + const p = new Image(); + p.onload = () => f(p), p.onerror = () => v(new Error("GateLab could not rasterize the compensation export page.")), p.src = r; + }), l = Math.max(1, s / 96), c = document.createElement("canvas"); + c.width = Math.round(Tn * l), c.height = Math.round(gt * l); + const d = c.getContext("2d"); + if (!d) throw new Error("Canvas export is unavailable in this browser."); + return d.fillStyle = "#ffffff", d.fillRect(0, 0, c.width, c.height), d.scale(l, l), d.drawImage(a, 0, 0, Tn, gt), await new Promise((f, v) => { + c.toBlob((p) => p ? f(p) : v(new Error("GateLab could not encode the PNG export.")), "image/png"); + }); + } finally { + URL.revokeObjectURL(r); + } +} +function ns(n, s) { + const r = URL.createObjectURL(n), a = document.createElement("a"); + a.href = r, a.download = s, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(r), 1e3); +} +function Yr(n, s, r, a) { + const l = Math.max(2, String(r).length); + return `${n}-page-${String(s + 1).padStart(l, "0")}.${a}`; +} +async function Xr(n, s, r, a) { + const l = bs(n.length); + if (l === 0) throw new Error("No compensation pairs are available to export."); + const c = ys(s.sampleName, s.populationName); + if (r === "pdf") { + const { jsPDF: p } = await import("./jspdf.es.min-8ev2qW9X.js").then((M) => M.j), C = new p({ orientation: "landscape", unit: "pt", format: "a4", compress: !0 }), k = C.internal.pageSize.getWidth(), w = C.internal.pageSize.getHeight(); + for (let M = 0; M < l; M++) { + M > 0 && C.addPage("a4", "landscape"); + const A = n.slice( + M * Un, + (M + 1) * Un + ), I = Qi(Ji(A, s, M, l)), P = await es(I), E = await new Promise((T, $) => { + const N = new FileReader(); + N.onload = () => T(String(N.result)), N.onerror = () => $(N.error ?? new Error("GateLab could not read an export page.")), N.readAsDataURL(P); + }); + C.addImage(E, "PNG", 0, 0, k, w, void 0, "FAST"), a == null || a({ completedPages: M + 1, totalPages: l }), await new Promise((T) => setTimeout(T, 0)); + } + C.save(Qt(s.sampleName, s.populationName, r, l)); + return; + } + const d = {}; + let f = null; + for (let p = 0; p < l; p++) { + const C = n.slice( + p * Un, + (p + 1) * Un + ), k = Qi(Ji(C, s, p, l)), w = Yr(c, p, l, r); + if (r === "svg") { + const M = vr(k); + d[w] = M, l === 1 && (f = new Blob([M], { type: "image/svg+xml" })); + } else { + const M = await es(k), A = new Uint8Array(await M.arrayBuffer()); + d[w] = A, l === 1 && (f = M); + } + a == null || a({ completedPages: p + 1, totalPages: l }), await new Promise((M) => setTimeout(M, 0)); + } + const v = Qt( + s.sampleName, + s.populationName, + r, + l + ); + ns(l === 1 && f ? f : new Blob([br(d, { level: 6 })], { type: "application/zip" }), v); +} +const Jr = [ + { format: "pdf", title: "PDF", detail: "One multipage A4 landscape document." }, + { format: "png", title: "PNG", detail: "300 DPI numbered pages; multiple pages download as a ZIP." }, + { format: "svg", title: "SVG", detail: "Vector text and axes with embedded high-resolution density layers; multiple pages download as a ZIP." } +]; +function Qr({ + sampleName: n, + populationName: s, + filterLabel: r, + pairCount: a, + onExport: l, + onClose: c +}) { + const { t: d } = Be(), [f, v] = S.useState("pdf"), [p, C] = S.useState(null), [k, w] = S.useState(null), M = bs(a), A = p !== null && p.completedPages < p.totalPages, I = Qt(n, s, f, M), P = async () => { + w(null), C({ completedPages: 0, totalPages: M }); + try { + await l(f, C), c(); + } catch (T) { + C(null), w(T instanceof Error ? T.message : String(T)); + } + }, E = (T) => { + T.key === "Escape" && !A && c(); + }; + return /* @__PURE__ */ e.jsx("div", { className: "gl-modal-backdrop", onKeyDown: E, children: /* @__PURE__ */ e.jsxs( + "div", + { + className: "gl-modal gl-comp-export-modal gl-comp-comparison-export-modal", + role: "dialog", + "aria-modal": "true", + "aria-labelledby": "comp-comparison-export-title", + children: [ + /* @__PURE__ */ e.jsx("div", { className: "gl-modal-title", id: "comp-comparison-export-title", children: d("Export compensation comparison") }), + /* @__PURE__ */ e.jsx("p", { className: "gl-comp-export-intro", children: d("Export the currently filtered channel pairs as clean paired Original and Compensated biplots. Every pair retains the same frozen events, axes, transform, density scale, and edge piling in both panels.") }), + /* @__PURE__ */ e.jsxs("fieldset", { className: "gl-comp-export-versions gl-comp-comparison-export-formats", children: [ + /* @__PURE__ */ e.jsx("legend", { children: d("Format") }), + Jr.map((T) => /* @__PURE__ */ e.jsxs("label", { children: [ + /* @__PURE__ */ e.jsx( + "input", + { + type: "radio", + name: "compensation-comparison-export-format", + value: T.format, + checked: f === T.format, + disabled: A, + onChange: () => v(T.format) + } + ), + /* @__PURE__ */ e.jsxs("span", { children: [ + /* @__PURE__ */ e.jsx("strong", { children: T.title }), + /* @__PURE__ */ e.jsx("small", { children: d(T.detail) }) + ] }) + ] }, T.format)) + ] }), + /* @__PURE__ */ e.jsxs("dl", { className: "gl-comp-export-summary gl-comp-comparison-export-summary", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: d("File") }), + /* @__PURE__ */ e.jsx("dd", { title: I, children: I }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: d("Scope") }), + /* @__PURE__ */ e.jsx("dd", { children: d(a === 1 ? "{count} filtered pair · both assays" : "{count} filtered pairs · both assays", { count: a.toLocaleString() }) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: d("Pages") }), + /* @__PURE__ */ e.jsx("dd", { children: d(M === 1 ? "{count} A4 landscape page · six pairs per page" : "{count} A4 landscape pages · six pairs per page", { count: M.toLocaleString() }) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: d("Population") }), + /* @__PURE__ */ e.jsx("dd", { title: s, children: s }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: d("Filter") }), + /* @__PURE__ */ e.jsx("dd", { title: r, children: r }) + ] }) + ] }), + p && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-comparison-export-progress", role: "status", "aria-live": "polite", children: [ + /* @__PURE__ */ e.jsx("progress", { max: Math.max(1, p.totalPages), value: p.completedPages }), + /* @__PURE__ */ e.jsx("span", { children: d("Rendering page {current} of {total}", { current: Math.min(p.completedPages + 1, p.totalPages), total: p.totalPages }) }) + ] }), + k && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-warning", role: "alert", children: d(k) }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-modal-actions", children: [ + /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-btn-ghost", disabled: A, onClick: c, children: d("Cancel") }), + /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-btn", disabled: A || M === 0, onClick: () => void P(), children: A ? d("Rendering…") : d("Download {format}", { format: f.toUpperCase() }) }) + ] }) + ] + } + ) }); +} +function ts(n) { + return `"${n.replaceAll('"', '""')}"`; +} +function is(n, s) { + if (!Array.isArray(n) || n.length === 0) + throw new Error(`The ${s} channel axis is empty.`); + const r = n.map((a, l) => { + if (typeof a != "string" || a.trim().length === 0) + throw new Error(`The ${s} channel at position ${l + 1} is blank or invalid.`); + return a.trim().normalize("NFC"); + }); + if (new Set(r).size !== r.length) + throw new Error(`The ${s} channel axis contains duplicate identities.`); + return r; +} +function ea(n) { + const s = is(n.sourceChannels, "source"), r = is(n.receiverChannels, "receiver"); + if (!Array.isArray(n.matrix) || n.matrix.length !== s.length) + throw new Error("The spill matrix row count does not match its source channel axis."); + const a = [ + ["channel", ...r].map(ts).join(",") + ]; + return n.matrix.forEach((l, c) => { + if (!Array.isArray(l) || l.length !== r.length) + throw new Error( + `Spill matrix row ${c + 1} does not match the receiver channel axis.` + ); + const d = l.map((f, v) => { + if (typeof f != "number" || !Number.isFinite(f)) + throw new Error( + `Spill coefficient ${s[c]} → ${r[v]} is not finite.` + ); + return Object.is(f, -0) ? "0" : String(f); + }); + a.push([ts(s[c]), ...d].join(",")); + }), `${a.join(` +`)} +`; +} +function na(n, s = "installed") { + return `${n.replace(/\.(?:csv|tsv|txt)$/i, "").normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^A-Za-z0-9._-]+/g, "_").replace(/_+/g, "_").replace(/^[._-]+|[._-]+$/g, "").slice(0, 90) || "gatelab"}${s === "working" ? "_working" : ""}_spill_matrix.csv`; +} +function ta(n) { + return [ + "spill <- as.matrix(read.csv(", + ` "${n.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}",`, + " row.names = 1,", + " check.names = FALSE,", + ' fileEncoding = "UTF-8"', + "))", + 'storage.mode(spill) <- "double"' + ].join(` +`); +} +function ia({ + profileLabel: n, + installedLabel: s, + installedMatrix: r, + workingMatrix: a = null, + pendingEditCount: l = 0, + onClose: c +}) { + const { t: d } = Be(), [f, v] = S.useState("installed"), [p, C] = S.useState(null), k = f === "working" && a ? a : r, w = na(n, f), M = S.useMemo( + () => ta(w), + [w] + ), A = () => { + C(null); + try { + const E = ea(k), T = URL.createObjectURL(new Blob([E], { type: "text/csv;charset=utf-8" })), $ = document.createElement("a"); + $.href = T, $.download = w, document.body.appendChild($), $.click(), $.remove(), setTimeout(() => URL.revokeObjectURL(T), 1e3); + } catch (E) { + C(E instanceof Error ? E.message : String(E)); + } + }, I = async () => { + var E; + if (!((E = navigator.clipboard) != null && E.writeText)) { + C("Clipboard access is unavailable; select the R code below and copy it manually."); + return; + } + try { + await navigator.clipboard.writeText(M), C("R import code copied."); + } catch { + C("Clipboard access was denied; select the R code below and copy it manually."); + } + }, P = (E) => { + E.key === "Escape" && c(); + }; + return /* @__PURE__ */ e.jsx("div", { className: "gl-modal-backdrop", onKeyDown: P, children: /* @__PURE__ */ e.jsxs( + "div", + { + className: "gl-modal gl-comp-export-modal", + role: "dialog", + "aria-modal": "true", + "aria-labelledby": "comp-export-title", + children: [ + /* @__PURE__ */ e.jsx("div", { className: "gl-modal-title", id: "comp-export-title", children: d("Export spill matrix") }), + /* @__PURE__ */ e.jsx("p", { className: "gl-comp-export-intro", children: d("Coefficients are exported as exact fractions, not the rounded percentages shown in the matrix. Source channels are rows and receiver channels are columns. The CSV can be imported by GateLab or base R.") }), + a && l > 0 && /* @__PURE__ */ e.jsxs("fieldset", { className: "gl-comp-export-versions", children: [ + /* @__PURE__ */ e.jsx("legend", { children: d("Matrix version") }), + /* @__PURE__ */ e.jsxs("label", { children: [ + /* @__PURE__ */ e.jsx( + "input", + { + type: "radio", + name: "compensation-export-version", + value: "installed", + checked: f === "installed", + onChange: () => v("installed") + } + ), + /* @__PURE__ */ e.jsxs("span", { children: [ + /* @__PURE__ */ e.jsx("strong", { children: s }), + /* @__PURE__ */ e.jsx("small", { children: d("Current applied scientific record") }) + ] }) + ] }), + /* @__PURE__ */ e.jsxs("label", { children: [ + /* @__PURE__ */ e.jsx( + "input", + { + type: "radio", + name: "compensation-export-version", + value: "working", + checked: f === "working", + onChange: () => v("working") + } + ), + /* @__PURE__ */ e.jsxs("span", { children: [ + /* @__PURE__ */ e.jsx("strong", { children: d("Working draft") }), + /* @__PURE__ */ e.jsx("small", { children: d("{count} pending edits; not yet applied", { count: l }) }) + ] }) + ] }) + ] }), + /* @__PURE__ */ e.jsxs("dl", { className: "gl-comp-export-summary", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: d("File") }), + /* @__PURE__ */ e.jsx("dd", { children: w }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: d("Dimensions") }), + /* @__PURE__ */ e.jsx("dd", { children: d("{sources} sources × {receivers} receivers", { sources: k.sourceChannels.length, receivers: k.receiverChannels.length }) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: d("Units") }), + /* @__PURE__ */ e.jsx("dd", { children: d("Fractions (2.9% is written as 0.029)") }) + ] }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-export-r-head", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("strong", { children: d("Import in R") }), + /* @__PURE__ */ e.jsx("span", { children: d("Run after placing the CSV in the R working directory.") }) + ] }), + /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => void I(), children: d("Copy R code") }) + ] }), + /* @__PURE__ */ e.jsx("pre", { className: "gl-comp-export-code", children: /* @__PURE__ */ e.jsx("code", { children: M }) }), + p && /* @__PURE__ */ e.jsx("div", { className: p.includes("copied") ? "gl-comp-status" : "gl-comp-warning", role: "status", children: p }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-modal-actions", children: [ + /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-btn-ghost", onClick: c, children: d("Cancel") }), + /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-btn", onClick: A, children: d("Download CSV") }) + ] }) + ] + } + ) }); +} +function An({ + value: n, + onValueChange: s, + scrubStep: r, + className: a = "", + disabled: l, + min: c, + max: d, + step: f, + title: v, + onPointerDown: p, + onPointerMove: C, + onPointerUp: k, + onPointerCancel: w, + onLostPointerCapture: M, + ...A +}) { + const { t: I } = Be(), P = S.useRef(null), [E, T] = S.useState(!1), $ = (N) => { + var F, R, L; + ((F = P.current) == null ? void 0 : F.pointerId) === N.pointerId && (P.current = null, T(!1), (L = (R = N.currentTarget).hasPointerCapture) != null && L.call(R, N.pointerId) && N.currentTarget.releasePointerCapture(N.pointerId)); + }; + return /* @__PURE__ */ e.jsx( + "input", + { + ...A, + type: "number", + className: `gl-scrubbable-number${E ? " is-scrubbing" : ""}${a ? ` ${a}` : ""}`, + value: n, + disabled: l, + min: c, + max: d, + step: f, + title: v ?? I("Type a value, use the arrows, or drag vertically to adjust"), + onChange: (N) => s(N.currentTarget.value), + onPointerDown: (N) => { + var G, Z; + if (p == null || p(N), N.defaultPrevented || l || N.button !== 0) return; + const F = N.currentTarget.getBoundingClientRect(); + if (N.clientX >= F.right - 18) return; + const R = Number(n), L = (r ?? Number(f)) || 0.1; + if (!Number.isFinite(R) || !(L > 0)) return; + const O = String(L), _ = O.includes("e-") ? Number(O.split("e-")[1]) : O.includes(".") ? O.split(".")[1].length : 0; + P.current = { + pointerId: N.pointerId, + startY: N.clientY, + startValue: R, + step: L, + decimals: _, + lastSteps: 0 + }, (Z = (G = N.currentTarget).setPointerCapture) == null || Z.call(G, N.pointerId); + }, + onPointerMove: (N) => { + C == null || C(N); + const F = P.current; + if (!F || F.pointerId !== N.pointerId) return; + const R = F.startY - N.clientY; + if (Math.abs(R) < 3) return; + const L = R > 0 ? Math.floor(R / 4) : Math.ceil(R / 4); + if (L === F.lastSteps) return; + let O = F.startValue + L * F.step; + const _ = c === void 0 ? Number.NEGATIVE_INFINITY : Number(c), G = d === void 0 ? Number.POSITIVE_INFINITY : Number(d); + Number.isFinite(_) && (O = Math.max(_, O)), Number.isFinite(G) && (O = Math.min(G, O)), P.current = { ...F, lastSteps: L }, T(!0), s(O.toFixed(Math.min(10, F.decimals))), N.preventDefault(); + }, + onPointerUp: (N) => { + k == null || k(N), $(N); + }, + onPointerCancel: (N) => { + w == null || w(N), $(N); + }, + onLostPointerCapture: (N) => { + var F; + M == null || M(N), ((F = P.current) == null ? void 0 : F.pointerId) === N.pointerId && (P.current = null, T(!1)); + } + } + ); +} +const si = S.createContext(ni), ri = S.createContext(0.85), ai = S.createContext(1), ss = "", ct = []; +let Vt = !1; +function sa(n) { + const s = { cancelled: !1, run: n }; + ct.push(s); + const r = () => { + if (Vt) return; + Vt = !0; + const a = () => { + Vt = !1; + let c = ct.shift(); + for (; c != null && c.cancelled; ) c = ct.shift(); + c == null || c.run(), ct.length > 0 && r(); + }, l = window; + typeof l.requestIdleCallback == "function" ? l.requestIdleCallback(a, { timeout: 50 }) : typeof requestAnimationFrame == "function" ? requestAnimationFrame(a) : setTimeout(a, 0); + }; + return r(), () => { + s.cancelled = !0; + }; +} +function xt({ + title: n, + panel: s, + preview: r, + sourceLabel: a, + receiverLabel: l, + minimumSize: c = 210, + maximumSize: d = 420, + densityColorCeiling: f, + densitySmoothing: v, + showZeroPile: p = !0 +}) { + const { t: C } = Be(), k = S.useContext(si), w = S.useContext(ri), M = S.useContext(ai), A = S.useRef(null); + S.useEffect(() => { + const E = A.current; + if (!E) return; + let T = null, $ = 0; + const N = () => { + var G; + T = null; + const L = ((G = E.parentElement) == null ? void 0 : G.clientWidth) ?? 230, O = Math.max(c, Math.min(d, Math.floor(L))); + if (O === $ && E.childElementCount > 0) return; + $ = O; + const _ = ti(v, O); + ft(E, { + title: n, + panel: s, + preview: r, + sourceLabel: a, + receiverLabel: l, + size: O, + densityColorCeiling: f ?? ii( + r, + 0.95, + _, + k + ), + densitySmoothingRadius: _, + densityColorPower: k, + pointAlpha: w, + pointSize: M + }); + }, F = () => { + T !== null && cancelAnimationFrame(T), T = requestAnimationFrame(N); + }; + F(); + const R = typeof ResizeObserver > "u" ? null : new ResizeObserver(F); + return R == null || R.observe(E.parentElement ?? E), () => { + R == null || R.disconnect(), T !== null && cancelAnimationFrame(T); + }; + }, [f, k, v, d, c, s, w, M, r, l, a, n]); + const I = (E) => r.eventCount > 0 ? `${(E / r.eventCount * 100).toFixed(1)}%` : "0.0%", P = s.zeroPile.source > 0 || s.zeroPile.receiver > 0 || s.zeroPile.corner > 0; + return /* @__PURE__ */ e.jsxs("figure", { className: "gl-comp-biplot", "aria-label": C("{title} density biplot; {source} on x, {receiver} on y", { + title: n, + source: a, + receiver: l + }), children: [ + /* @__PURE__ */ e.jsx("div", { ref: A, className: "gl-comp-biplot-surface" }), + p && P && /* @__PURE__ */ e.jsx("figcaption", { className: "gl-comp-zero-pile", children: C("Exact zero · source {source} · receiver {receiver} · both {both}", { + source: I(s.zeroPile.source), + receiver: I(s.zeroPile.receiver), + both: I(s.zeroPile.corner) + }) }) + ] }); +} +function ra({ + title: n, + preview: s, + sourceLabel: r, + receiverLabel: a, + minimumSize: l, + maximumSize: c, + densityColorCeiling: d, + densitySmoothing: f +}) { + const { t: v } = Be(), p = S.useContext(si), C = S.useContext(ri), k = S.useContext(ai), w = S.useRef(null); + return S.useEffect(() => { + const M = w.current; + if (!M) return; + let A = null, I = 0; + const P = () => { + var Z; + A = null; + const $ = ((Z = M.parentElement) == null ? void 0 : Z.clientWidth) ?? l, N = Math.max(l, Math.min(c, Math.floor($))); + if (N === I && M.dataset.cacheReady === "true") return; + I = N, M.dataset.cacheReady = "false"; + const F = ti(f, N), R = d ?? ii( + s, + 0.95, + F, + p + ); + ft(M, { + title: n, + panel: s.original, + preview: s, + sourceLabel: r, + receiverLabel: a, + size: N, + densityColorCeiling: R, + densitySmoothingRadius: F, + densityColorPower: p, + pointAlpha: C, + pointSize: k, + canvasScale: 2 + }); + const L = M.querySelector("canvas"), O = M.querySelector("svg"), _ = document.createElement("div"); + ft(_, { + title: n, + panel: s.compensated, + preview: s, + sourceLabel: r, + receiverLabel: a, + size: N, + densityColorCeiling: R, + densitySmoothingRadius: F, + densityColorPower: p, + pointAlpha: C, + pointSize: k, + canvasScale: 2 + }); + const G = _.querySelector("canvas"); + !L || !G || !O || (L.classList.add("gl-comp-cached-canvas", "is-original"), L.dataset.assayLayer = "original", G.classList.add("gl-comp-cached-canvas", "is-compensated"), G.dataset.assayLayer = "compensated", M.insertBefore(G, O), M.dataset.cacheReady = "true"); + }, E = () => { + A == null || A(), A = sa(P); + }; + E(); + const T = typeof ResizeObserver > "u" ? null : new ResizeObserver(E); + return T == null || T.observe(M.parentElement ?? M), () => { + T == null || T.disconnect(), A == null || A(); + }; + }, [d, p, f, c, l, C, k, s, a, r, n]), /* @__PURE__ */ e.jsx( + "figure", + { + className: "gl-comp-biplot", + "aria-label": v("Cached uncompensated and compensated density biplot; {source} on x, {receiver} on y", { + source: r, + receiver: a + }), + children: /* @__PURE__ */ e.jsx( + "div", + { + ref: w, + className: "gl-comp-biplot-surface gl-comp-cached-biplot", + "data-cache-mode": "dual-canvas" + } + ) + } + ); +} +function rs({ + preview: n, + sourceLabel: s, + receiverLabel: r, + kind: a, + densitySmoothing: l, + compact: c = !1, + compensatedTitle: d = "Compensated" +}) { + const { t: f } = Be(), v = n.eventCount > 0 ? n.original.zeroPile.receiver / n.eventCount * 100 : 0, p = n.eventCount > 0 ? n.compensated.zeroPile.receiver / n.eventCount * 100 : 0, C = p - v; + return /* @__PURE__ */ e.jsxs("div", { className: `gl-comp-biplot-comparison${c ? " is-compact" : ""}`, children: [ + !c && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-biplot-note", children: f("Same {events} events{sampled} · locked axes · off-scale events piled at edges · colour clipped at the 95th percentile of occupied density bins", { + events: n.eventCount.toLocaleString(), + sampled: n.totalEvents > n.eventCount ? f(" sampled from {total}", { total: n.totalEvents.toLocaleString() }) : "" + }) }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-biplot-panels", children: [ + /* @__PURE__ */ e.jsx( + xt, + { + title: f("Original"), + panel: n.original, + preview: n, + sourceLabel: s, + receiverLabel: r, + densitySmoothing: l, + showZeroPile: !c + } + ), + /* @__PURE__ */ e.jsx( + xt, + { + title: d, + panel: n.compensated, + preview: n, + sourceLabel: s, + receiverLabel: r, + densitySmoothing: l, + showZeroPile: !c + } + ) + ] }), + !c && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-diagnostic-note", children: a === "cytof" ? /* @__PURE__ */ e.jsx(e.Fragment, { children: f("Receiver events at exact zero: {original}% → {compensated}% ({delta} percentage points). A rise can be consistent with NNLS over-subtraction, while a residual source-associated rise can be consistent with under-compensation. Neither is a verdict without a suitable negative/control population.", { + original: v.toFixed(1), + compensated: p.toFixed(1), + delta: `${C >= 0 ? "+" : ""}${C.toFixed(1)}` + }) }) : /* @__PURE__ */ e.jsx(e.Fragment, { children: f("Residual tilt can be consistent with under- or over-compensation, but spreading error and biological co-expression can produce similar shapes. Use the matched Original/{comparison} view as review evidence, not an automatic coefficient call.", { + comparison: d + }) }) }), + !c && (n.evidence.status === "ready" ? /* @__PURE__ */ e.jsxs("dl", { className: "gl-comp-pair-evidence", "aria-label": f("Conservative residual evidence"), children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: f("Receiver-negative shift") }), + /* @__PURE__ */ e.jsx("dd", { children: f("{value} MAD", { value: ie(n.evidence.normalizedNegativeShift ?? 0, 3) }) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: f("Robust residual slope") }), + /* @__PURE__ */ e.jsx("dd", { children: ie(n.evidence.residualSlope ?? 0, 4) }) + ] }), + n.evidence.upperTailExcessMad !== null && /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: f("Upper-tail departure") }), + /* @__PURE__ */ e.jsx("dd", { children: f("{value} MAD", { value: ie(n.evidence.upperTailExcessMad, 3) }) }) + ] }), + n.evidence.upperTailSlopeDeltaMad !== null && /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: f("Tail slope change") }), + /* @__PURE__ */ e.jsx("dd", { children: f("{value} MAD", { value: ie(n.evidence.upperTailSlopeDeltaMad, 3) }) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: f("Evidence groups") }), + /* @__PURE__ */ e.jsx("dd", { children: f("{high} source-high · {low} source-low", { + high: n.evidence.sourceHighEvents.toLocaleString(), + low: n.evidence.sourceLowEvents.toLocaleString() + }) }) + ] }) + ] }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-evidence-insufficient", children: f("Residual screening needs distinct source-low/source-high groups and enough receiver-negative events; this pair remains available for visual review.") })) + ] }); +} +function aa({ + matrixView: n, + sourceChannels: s, + receiverChannels: r, + selectedSourceIndex: a, + selectedReceiverIndex: l, + stagedCoefficients: c, + maximumAbsoluteOffDiagonal: d, + onSelect: f +}) { + const { t: v } = Be(), p = 6, C = 74, k = 44, w = 10, M = r.length * p, A = s.length * p, I = C + M + C, P = k + A + w, E = S.useMemo(() => { + const $ = []; + for (let N = 0; N < n.matrix.length; N++) + for (let F = 0; F < n.matrix[N].length; F++) { + const R = n.sourceAxisKeys[N], L = n.receiverAxisKeys[F], O = `${R}${ss}${L}`, _ = c[O] ?? n.matrix[N][F], G = R === L; + if (!G && (!Number.isFinite(_) || _ === 0)) continue; + const Z = d > 0 && Number.isFinite(_) ? Math.min(1, Math.abs(_) / d) : 0, q = Z > 0 ? 0.12 + 0.82 * Math.sqrt(Z) : 0; + $.push({ + sourceIndex: N, + receiverIndex: F, + pairKey: O, + value: _, + diagonal: G, + fill: G ? "#cfd4db" : Number.isFinite(_) ? _ < 0 ? `rgba(47,128,237,${q})` : `rgba(211,47,47,${q})` : "#ae3e3e" + }); + } + return $; + }, [n, d, c]), T = ($) => { + const N = $.currentTarget.getBoundingClientRect(); + if (!(N.width > 0) || !(N.height > 0)) return; + const F = ($.clientX - N.left) * I / N.width, R = ($.clientY - N.top) * P / N.height, L = Math.floor((F - C) / p), O = Math.floor((R - k) / p); + O < 0 || O >= s.length || L < 0 || L >= r.length || n.sourceAxisKeys[O] === n.receiverAxisKeys[L] || f(`${n.sourceAxisKeys[O]}${ss}${n.receiverAxisKeys[L]}`); + }; + return /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-mini-matrix", "aria-labelledby": "comp-mini-matrix-heading", children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-mini-matrix-head", children: [ + /* @__PURE__ */ e.jsx("strong", { id: "comp-mini-matrix-heading", children: v("Matrix map") }), + /* @__PURE__ */ e.jsx("span", { children: v("Source ↓ · receiver → · click a cell") }) + ] }), + /* @__PURE__ */ e.jsxs( + "svg", + { + width: I, + height: P, + viewBox: `0 0 ${I} ${P}`, + role: "img", + "aria-label": v("Mini compensation matrix with {sources} source rows and {receivers} receiver columns", { + sources: s.length, + receivers: r.length + }), + onPointerDown: T, + children: [ + /* @__PURE__ */ e.jsx("rect", { x: C, y: k, width: M, height: A, fill: "#f8fafc", stroke: "#aeb8c6", strokeWidth: "0.7" }), + r.map(($, N) => /* @__PURE__ */ e.jsx( + "text", + { + x: C + (N + 0.55) * p, + y: k - 3, + transform: `rotate(-58 ${C + (N + 0.55) * p} ${k - 3})`, + textAnchor: "start", + className: N === l ? "is-selected" : void 0, + children: $.pnn + }, + $.key + )), + s.map(($, N) => /* @__PURE__ */ e.jsx( + "text", + { + x: C - 3, + y: k + (N + 0.72) * p, + textAnchor: "end", + className: N === a ? "is-selected" : void 0, + children: $.pnn + }, + $.key + )), + /* @__PURE__ */ e.jsx( + "rect", + { + x: C, + y: k + a * p, + width: M, + height: p, + fill: "rgba(47,128,237,0.08)", + pointerEvents: "none" + } + ), + /* @__PURE__ */ e.jsx( + "rect", + { + x: C + l * p, + y: k, + width: p, + height: A, + fill: "rgba(47,128,237,0.08)", + pointerEvents: "none" + } + ), + E.map(($) => /* @__PURE__ */ e.jsx( + "rect", + { + x: C + $.receiverIndex * p, + y: k + $.sourceIndex * p, + width: p, + height: p, + fill: $.fill, + pointerEvents: "none", + children: /* @__PURE__ */ e.jsx("title", { children: $.diagonal ? v("{channel} · self", { channel: s[$.sourceIndex].combined }) : `${s[$.sourceIndex].combined} → ${r[$.receiverIndex].combined} · ${tn($.value)}` }) + }, + $.pairKey + )), + /* @__PURE__ */ e.jsx( + "rect", + { + x: C + l * p, + y: k + a * p, + width: p, + height: p, + fill: "none", + stroke: "#2f80ed", + strokeWidth: "1.4", + vectorEffect: "non-scaling-stroke", + pointerEvents: "none" + } + ) + ] + } + ) + ] }); +} +function oa({ + dataset: n, + pair: s, + plotSize: r, + densitySmoothing: a, + flagged: l, + selected: c, + onSelect: d, + onFlag: f +}) { + const { t: v } = Be(), p = S.useRef(null), [C, k] = S.useState(() => typeof IntersectionObserver > "u"); + S.useEffect(() => { + const A = p.current; + if (!A || typeof IntersectionObserver > "u") { + k(!0); + return; + } + const I = new IntersectionObserver( + (P) => k(P.some((E) => E.isIntersecting)), + { rootMargin: "450px 0px" } + ); + return I.observe(A), () => I.disconnect(); + }, []); + const w = S.useMemo( + () => C ? vs(n, s.source.key, s.receiver.key) : null, + [n, s.receiver.key, s.source.key, C] + ), M = w != null && w.ready ? w.preview : null; + return /* @__PURE__ */ e.jsxs( + "article", + { + ref: p, + className: `gl-comp-global-tile${c ? " is-selected" : ""}${l ? " is-flagged" : ""}`, + "data-pair-key": s.pairKey, + "data-event-signature": M == null ? void 0 : M.eventSignature, + "data-x-range": M ? `${M.xRange[0]},${M.xRange[1]}` : void 0, + "data-y-range": M ? `${M.yRange[0]},${M.yRange[1]}` : void 0, + style: { width: r, height: r }, + children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-global-tile-head", children: [ + /* @__PURE__ */ e.jsxs( + "button", + { + type: "button", + onClick: d, + title: `${s.source.combined} → ${s.receiver.combined}`, + "aria-label": v("Open details for {source} to {receiver}", { + source: s.source.label, + receiver: s.receiver.label + }), + children: [ + /* @__PURE__ */ e.jsxs("span", { children: [ + s.source.label, + " → ", + s.receiver.label + ] }), + /* @__PURE__ */ e.jsxs("strong", { children: [ + (s.coefficient * 100).toFixed(1), + "%" + ] }) + ] + } + ), + /* @__PURE__ */ e.jsx("label", { title: v("Keep this pair in Flagged"), children: /* @__PURE__ */ e.jsx( + "input", + { + type: "checkbox", + checked: l, + "aria-label": v("Flag global inspector pair {source} to {receiver} for follow-up", { + source: s.source.label, + receiver: s.receiver.label + }), + onChange: (A) => f(A.currentTarget.checked) + } + ) }) + ] }), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-comp-global-plot-button", + onClick: d, + title: v("{source} → {receiver} · {interaction}matrix {coefficient}%", { + source: s.source.combined, + receiver: s.receiver.combined, + interaction: s.interaction && s.interaction !== "other" ? `${s.interaction} · ` : "", + coefficient: (s.coefficient * 100).toFixed(1) + }), + "aria-label": v("Open details for {source} to {receiver}; matrix coefficient {coefficient}%", { + source: s.source.label, + receiver: s.receiver.label, + coefficient: (s.coefficient * 100).toFixed(1) + }), + children: /* @__PURE__ */ e.jsx("div", { className: "gl-comp-global-plot", style: { width: r, height: r }, children: M ? /* @__PURE__ */ e.jsx( + ra, + { + title: "", + preview: M, + sourceLabel: s.source.label, + receiverLabel: s.receiver.label, + minimumSize: r, + maximumSize: r, + densitySmoothing: a + } + ) : w && !w.ready ? /* @__PURE__ */ e.jsx("span", { children: w.reason }) : /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true" }) }) + } + ) + ] + } + ); +} +function la({ + stateKey: n, + header: s, + children: r +}) { + const { t: a } = Be(), [l, c] = fe( + `compensation.${n}.globalInspectorLayer`, + "compensated" + ); + return /* @__PURE__ */ e.jsxs( + "section", + { + className: "gl-comp-global-inspector", + "aria-labelledby": "comp-global-inspector-heading", + "data-inspector-layer": l, + children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-global-head", children: [ + s, + /* @__PURE__ */ e.jsxs( + "button", + { + type: "button", + className: "gl-comp-layer-toggle", + "aria-pressed": l === "compensated", + "aria-label": a("Showing {shown} data; click to show {other} data", { + shown: a(l === "original" ? "uncompensated" : "compensated"), + other: a(l === "original" ? "compensated" : "uncompensated") + }), + title: a("Toggle every plot between uncompensated and compensated data without changing its frame"), + onClick: () => c((d) => d === "original" ? "compensated" : "original"), + children: [ + /* @__PURE__ */ e.jsx("span", { className: "gl-comp-layer-toggle-track", "aria-hidden": "true", children: /* @__PURE__ */ e.jsx("i", {}) }), + /* @__PURE__ */ e.jsx("span", { children: a(l === "original" ? "Uncompensated" : "Compensated") }) + ] + } + ) + ] }), + r + ] + } + ); +} +const ca = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', as = 58 * Math.PI / 180, da = { + relevant: "Matrix-linked / relevant", + nonzero: "Non-zero coefficients", + physical: "Physical CyTOF relationships", + flagged: "Flagged for follow-up", + all: "All included pairs" +}, ua = [ + { id: "evidence", label: "Evidence" }, + { id: "review", label: "Review queue" } +], _e = "", os = 2500, ls = 400, ha = 2500, cs = 15e3, ds = [2500, 5e3, 15e3, 5e4], ma = 24, us = 4, hs = 624, pa = Object.freeze({}); +function ms(n) { + if (!Number.isFinite(n)) return String(n); + const s = n * 100; + if (s === 0) return "0.0"; + const r = Math.abs(s), a = r >= 1 ? 1 : r >= 0.1 ? 2 : 3; + return s.toFixed(a); +} +function Wt(n) { + return n.replace(/(?: · (?:edited|revised))+$/u, ""); +} +function vt(n, s) { + const r = n.index(s), a = r === void 0 ? void 0 : n.channels[r], l = (a == null ? void 0 : a.pnn) ?? s, c = n.labelForKey(s), d = ((a == null ? void 0 : a.label) ?? "").trim() || ((a == null ? void 0 : a.marker) ?? "").trim(), f = d && d !== l ? `${d} (${l})` : l; + return { key: s, pnn: l, label: c, combined: f }; +} +function Gt(n, s) { + const r = n.channels.find((a) => a.pnn === s); + return vt(n, (r == null ? void 0 : r.key) ?? s); +} +function fa(n, s) { + return n === "cytof-spillover" && s === "nnls" ? "CyTOF NNLS" : "Flow linear inverse"; +} +function ga(n) { + return n.replaceAll("-", " "); +} +function ei(n) { + if (n.length === 0) return 0; + n.sort((r, a) => r - a); + const s = Math.floor(n.length / 2); + return n.length % 2 === 0 ? (n[s - 1] + n[s]) / 2 : n[s]; +} +function xa(n) { + return Object.fromEntries(n.scientific.solverSettings.map(({ key: s, value: r }) => [s, r])); +} +function va(n, s) { + const r = Object.freeze({ ...n.scientific.matrix, matrix: s }), a = xa(n); + return n.scientific.kind === "flow-spillover" ? { + kind: "flow-spillover", + method: "matrix-inverse", + solverVersion: n.scientific.solverVersion, + solverSettings: { + singularTolerance: Number(a.singularTolerance), + conditionWarningThreshold: Number(a.conditionWarningThreshold) + }, + matrix: r + } : { + kind: "cytof-spillover", + method: "nnls", + solverVersion: n.scientific.solverVersion, + solverSettings: { + tolerance: Number(a.tolerance), + kktTolerance: Number(a.kktTolerance), + maxIterations: Number(a.maxIterations), + adaptationVersion: String(a.adaptationVersion) + }, + matrix: r, + includedChannels: n.scientific.includedChannels + }; +} +function ps(n, s, r, a) { + const l = n.scientific.matrix.sourceChannels.indexOf(s), c = n.scientific.matrix.receiverChannels.indexOf(r); + if (l < 0 || c < 0) + throw new Error("The selected coefficient is absent from the installed profile axes."); + return Object.freeze(n.scientific.matrix.matrix.map( + (d, f) => Object.freeze(d.map((v, p) => f === l && p === c ? a : v)) + )); +} +function ba(n, s, r) { + var d; + if (!n) return null; + const a = n.scientific.matrix.sourceChannels.indexOf(s), l = n.scientific.matrix.receiverChannels.indexOf(r); + if (a < 0 || l < 0) return null; + const c = (d = n.scientific.matrix.matrix[a]) == null ? void 0 : d[l]; + return Number.isFinite(c) ? c : null; +} +function fs(n, s, r) { + const a = Math.max(Math.abs(n), Math.abs(s), 1e-3); + return Object.freeze(r === "cytof" ? { lower: 0, upper: Math.max(n + a, a * 2) } : { lower: n - a, upper: n + a }); +} +function ya(n, s) { + const r = (s - n) / 3; + return Object.freeze([n, n + r, n + 2 * r, s]); +} +function ja(n, s) { + return n.length === s.length && n.every((r, a) => { + var l; + return r.length === ((l = s[a]) == null ? void 0 : l.length) && r.every((c, d) => c === s[a][d]); + }); +} +function wa(n, s) { + if (n.compensatedLayerStatus().state !== "ready" || s.length === 0 || n.fcs.nEvents === 0) return null; + const a = s.flatMap((k) => { + const w = n.channels.findIndex((M) => M.pnn === k); + return w < 0 ? [] : [w]; + }); + if (a.length === 0) return null; + const l = Math.min(2048, n.fcs.nEvents), c = []; + let d = 0, f = 0, v = 0, p = "", C = -1; + for (const k of a) { + const w = n.originalColumnData(k), M = n.compensatedColumnData(k), A = []; + for (let P = 0; P < l; P++) { + const E = l === 1 ? 0 : Math.floor(P * (n.fcs.nEvents - 1) / (l - 1)), T = w[E], $ = M[E], N = Math.abs($ - T); + A.push(N), c.push(N), N > Math.max(1e-6, Math.abs(T) * 1e-6) && d++, T < 0 && $ === 0 && v++, f = Math.max(f, N); + } + const I = ei(A); + I > C && (C = I, p = vt(n, n.channels[k].key).combined); + } + return { + previewEvents: l, + comparedValues: c.length, + changedValues: d, + medianAbsoluteDelta: ei(c), + maxAbsoluteDelta: f, + zeroedNegativeValues: v, + mostChangedChannel: p, + mostChangedChannelMedianDelta: Math.max(0, C) + }; +} +function Ca(n, s) { + return n.origin.type === "uploaded" ? n.origin.fileName : n.origin.type === "embedded-fcs" ? `${n.origin.fileName} · ${s("embedded FCS")}` : n.origin.type === "manual" ? s("set by hand, from an empty matrix") : `${n.origin.presetId} · ${s("bundled preset")} ${n.origin.presetVersion}`; +} +function Na(n) { + if (!n || n.kind !== "cytof-spillover") + return { draft: null, error: null }; + const s = { + input: { + sourceChannels: n.sourceChannels, + receiverChannels: n.receiverChannels, + matrix: n.matrix + }, + format: { + delimiter: "csv", + sourceColumnHeader: "source" + } + }, r = dt( + s.input, + "cytof-spillover" + ); + return r.ok ? { + draft: { + fileName: n.name, + source: "host", + parsed: s, + matrix: r.value, + validationWarnings: r.warnings + }, + error: null + } : { + draft: null, + error: `The SCE spillover matrix is invalid. ${r.errors.map(({ message: a }) => a).join(" ")}` + }; +} +function Sa({ + sample: n, + sampleName: s = "sample.fcs", + hostedCompensationMatrix: r = null, + compensationOn: a, + onApplyProfile: l, + onRemoveProfile: c, + existingHostAssays: d = [], + onAdoptExistingAssay: f, + onCancelApply: v, + hasExistingGates: p = !1, + applyStatus: C = null, + installedProfile: k = null, + applyTargetCount: w = 1, + applyTargetEventCount: M, + applyWorkerCount: A, + applyWorkerLimit: I, + onApplyWorkerCountChange: P, + installedBaselineProfile: E = null, + reviewPopulations: T = [], + reviewPopulationMasks: $ = pa, + onPreviewCompensationCandidate: N, + onSolveCompensationSweep: F, + onCancelCompensationSweep: R, + onSuspendBackgroundWork: L, + visible: O = !0, + stateKey: _, + densityColorPower: G = ni, + channelLabelMode: Z = "marker", + onDensityColorPowerChange: q = () => { + } +}) { + var Oi, Di; + const { t: i } = Be(), V = n.compensatedLayerStatus(), $e = V.state === "missing" ? null : V.metadata, D = ($e == null ? void 0 : $e.runtimeIdentity) === "profile" ? $e : null, j = (k == null ? void 0 : k.profileId) === (D == null ? void 0 : D.profileId) ? k : null, ee = !D && n.instrument === "flow" ? n.spillover : null, me = (r == null ? void 0 : r.kind) === "flow-spillover" ? r : null, gn = S.useMemo( + () => Na(r), + [r] + ), [qe, Ce] = fe( + `compensation.${_}.selectedPair`, + null + ), [bt, Ie] = S.useState(null), [Bn, oi] = fe( + `compensation.${_}.openDrawers`, + { evidence: !1, review: !1 } + ), [xn, li] = fe( + "compensation.inspectorWidth", + hs + ), [ke, qn] = fe( + `compensation.${_}.workspaceView`, + "matrix" + ), [Pe, Vn] = fe( + `compensation.${_}.globalPairFilter`, + "relevant" + ), [Re, js] = fe( + `compensation.${_}.globalLayout`, + "compact" + ), [ws, Cs] = fe( + "compensation.globalPlotSize.v5", + 160 + ), [Ns, Ss] = fe( + "compensation.densitySmoothing.v3", + 6 + ), [Ms, ks] = fe( + "compensation.pointAlpha.v1", + 0.85 + ), [Es, As] = fe( + "compensation.pointSize.v1", + 1 + ), [yt, Ts] = fe( + "compensation.pairPreviewEventLimit.v1", + cs + ), [Fn, ci] = S.useState(""), [$n, jt] = S.useState(!1), [wt, di] = S.useState(null), [vn, Ct] = fe( + `compensation.${_}.reviewPopulation`, + "all" + ), [Wn, Fs] = fe( + `compensation.${_}.flaggedPairs`, + [] + ), [Ve, $s] = fe( + `compensation.${_}.evidenceMode`, + "biological" + ), [Is, Ps] = fe( + `compensation.${_}.sweepBounds`, + {} + ), [Nt, St] = fe( + `compensation.${_}.sweepWorkers`, + 2 + ), [Ee, ui] = S.useState(""), [Ne, Mt] = S.useState(""), [Rs, kt] = S.useState(0), [Y, Gn] = S.useState({}), [Ks, sn] = S.useState({}), [We, rn] = S.useState({ state: "idle" }), [Ls, Ye] = S.useState({}), [Os, an] = S.useState({}), [ye, bn] = S.useState(null), [Ds, In] = S.useState(null), [ue, yn] = S.useState(null), [hi, ve] = S.useState(null), [Hn, Et] = S.useState(""), [zs, mi] = S.useState(!1), [_s, pi] = S.useState(!1), Ae = S.useRef(0), jn = S.useRef(0), [fi, J] = S.useState(null), [gi, pe] = S.useState(!1), [X, Zn] = S.useState( + () => gn.draft + ), [Pn, on] = S.useState( + () => { + var m; + const t = ((m = gn.draft) == null ? void 0 : m.matrix.receiverChannels) ?? [], o = /* @__PURE__ */ new Map(); + for (const h of n.channels) { + const g = h.pnn.trim().normalize("NFC"); + o.set(g, (o.get(g) ?? 0) + 1); + } + return new Set(t.filter((h) => o.get(h) === 1)); + } + ), [xi, Xe] = S.useState( + () => gn.error + ), [Se, Ge] = S.useState(!1), [Yn, vi] = S.useState(!1), [Xn, bi] = S.useState( + () => { + var t; + return ((t = d[0]) == null ? void 0 : t.id) ?? ""; + } + ), [At, Jn] = S.useState(!1), [Qn, be] = S.useState(null), [Us, Ke] = S.useState(!1), [Bs, He] = S.useState(null), Te = S.useRef(!1), yi = S.useRef(null), ji = S.useRef(null), wn = S.useRef(null), B = Us || C !== null, Je = Math.max(0, Math.floor(w)), qs = Math.max( + 0, + Math.floor(M ?? n.fcs.nEvents) + ), Qe = d.find( + ({ id: t }) => t === Xn + ) ?? d[0] ?? null; + S.useEffect(() => { + var t; + Xn && d.some(({ id: o }) => o === Xn) || (bi(((t = d[0]) == null ? void 0 : t.id) ?? ""), Jn(!1)); + }, [d, Xn]); + const re = C ?? (Qn ? { + phase: "applying", + profileName: Bs ?? (X == null ? void 0 : X.fileName) ?? "Compensation", + fraction: Qn.fraction, + processedEvents: Qn.processedEvents, + totalEvents: Qn.totalEvents + } : null); + S.useEffect(() => { + O || (jn.current++, Ae.current++, rn({ state: "idle" }), yn(null), bn(null), L == null || L()); + }, [L, O]); + const Tt = S.useMemo( + () => n.channels.map(({ pnn: t, columnIndex: o }) => ({ pnn: t, columnIndex: o })), + [n] + ), Le = S.useMemo(() => { + if (!ee) return null; + const t = ee.channels.map((h) => { + const g = n.index(h); + return g === void 0 ? null : n.channels[g].pnn; + }); + if (t.some((h) => h === null)) + return { + validation: null, + error: "The embedded matrix could not be mapped back to exact FCS channel identities.", + keyword: void 0 + }; + const o = dt({ + sourceChannels: t, + receiverChannels: t, + matrix: ee.matrix + }, "flow-spillover"), m = ["$SPILLOVER", "$SPILL", "SPILL"].find((h) => typeof n.fcs.keywords[h] == "string"); + return { + validation: o, + error: o.ok ? null : `The embedded compensation matrix cannot be applied or edited. ${o.errors.map(({ message: h }) => h).join(" ")}`, + keyword: m + }; + }, [n, ee]), Q = vn === "all" ? null : T.find(({ id: t }) => t === vn) ?? null, he = Q ? $[Q.id] ?? null : null, ce = he ? (Q == null ? void 0 : Q.eventCount) ?? 0 : n.fcs.nEvents, et = yt === "all" ? "all" : ds.includes(Number(yt)) ? Number(yt) : cs, Rn = S.useMemo( + () => mn( + n.fcs.nEvents, + et === "all" ? Math.max(1, n.fcs.nEvents) : et, + he + ), + [et, ce, he, n] + ), Kn = S.useMemo( + () => mn(n.fcs.nEvents, 2048, he), + [he, n] + ), Ft = S.useMemo( + () => mn( + n.fcs.nEvents, + ha, + he + ), + [he, n] + ); + S.useEffect(() => { + vn !== "all" && !T.some(({ id: t }) => t === vn) && Ct("all"); + }, [vn, T, Ct]), S.useEffect(() => { + Ae.current++, R == null || R(), Ye({}), an({}), bn(null), yn(null), ve(null); + }, [vn, he, R]); + const de = S.useMemo(() => X ? yr({ + kind: "cytof-spillover", + matrix: X.matrix, + sampleChannels: Tt, + includedChannels: Array.from(Pn) + }) : null, [X, Pn, Tt, Z]), u = S.useMemo(() => { + if (ee) { + const o = n.spilloverOrigin, m = o.kind === "external" ? o : null; + return { + sourceAxisKeys: ee.channels, + receiverAxisKeys: ee.channels, + sourceChannels: ee.channels.map((h) => vt(n, h)), + receiverChannels: ee.channels.map((h) => vt(n, h)), + matrix: ee.matrix, + kind: "flow", + title: me ? "SCE spillover matrix" : m ? `Compensation matrix from ${m.label}` : "Embedded compensation matrix", + subtitle: "Source rows ↓ · Receiver columns → · values are spillover percentages", + coefficientNote: m ? "This FCS carries no spillover matrix of its own; these coefficients came from the imported FlowJo workspace and are applied unchanged." + (m.droppedChannels.length ? ` ${m.droppedChannels.length} of its parameter(s) are not in this file (${m.droppedChannels.join(", ")}) and were left out, which changes the result for the channels they spill into.` : "") : "Applying the embedded matrix leaves its coefficients unchanged." + }; + } + if (!j || !D) return null; + const t = j.scientific.kind === "cytof-spillover" ? Kr(j.scientific.matrix) : j.scientific.matrix; + return t.matrix.length !== t.sourceChannels.length || t.matrix.some((o) => !o || o.length !== t.receiverChannels.length) ? null : { + sourceAxisKeys: t.sourceChannels, + receiverAxisKeys: t.receiverChannels, + sourceChannels: t.sourceChannels.map((o) => Gt(n, o)), + receiverChannels: t.receiverChannels.map((o) => Gt(n, o)), + matrix: t.matrix, + kind: j.scientific.kind === "cytof-spillover" ? "cytof" : "flow", + title: j.scientific.kind === "cytof-spillover" ? "Uploaded spill matrix" : "Applied compensation matrix", + subtitle: j.scientific.kind === "cytof-spillover" ? i("{sources} source rows ↓ · {receivers} receiver columns → · isotope-mass order", { + sources: t.sourceChannels.length, + receivers: t.receiverChannels.length + }) : "Source rows ↓ · Receiver columns → · exact installed coefficients", + coefficientNote: j.scientific.kind === "cytof-spillover" ? "This is the exact uploaded matrix. The NNLS solve uses its selected, matched channels; original measurements remain stored separately." : "This is the exact installed matrix. Original measurements remain stored separately." + }; + }, [me, D, j, n, ee, i, Z]), se = (u == null ? void 0 : u.sourceChannels) ?? [], ae = (u == null ? void 0 : u.receiverChannels) ?? []; + S.useEffect(() => { + St((t) => Math.max(1, Math.min(us, Math.round(t) || 1))); + }, [St]); + const nt = bt ?? qe, b = S.useMemo(() => { + if (!u || !nt) return null; + const [t, o] = nt.split(_e), m = u.sourceAxisKeys.indexOf(t), h = u.receiverAxisKeys.indexOf(o); + return m < 0 || h < 0 || u.sourceAxisKeys[m] === u.receiverAxisKeys[h] ? null : { + pairKey: nt, + sourceIndex: m, + receiverIndex: h, + source: se[m], + receiver: ae[h], + value: u.matrix[m][h], + interaction: u.kind === "cytof" ? kn( + u.sourceAxisKeys[m], + u.receiverAxisKeys[h] + ) : null + }; + }, [nt, u, ae, se]); + S.useEffect(() => { + if (!b) { + Et(""); + return; + } + const t = Y[b.pairKey]; + Et(ie((t ?? b.value) * 100, 6)); + }, [b == null ? void 0 : b.pairKey, b == null ? void 0 : b.value, Y]); + const je = S.useMemo(() => b ? Bt( + n, + b.source.key, + b.receiver.key, + { + eventMask: he, + fixedEventIndices: Rn, + eligibleEventCount: ce + } + ) : null, [a, V.state, Rn, ce, he, n, b]), Me = S.useMemo(() => { + if (!u || V.state !== "ready") + return { candidateCount: 0, screenedCount: 0, evaluableCount: 0, items: [] }; + const t = []; + for (let g = 0; g < u.matrix.length; g++) + for (let x = 0; x < u.matrix[g].length; x++) { + const y = u.sourceAxisKeys[g], z = u.receiverAxisKeys[x]; + if (y === z) continue; + const U = u.matrix[g][x]; + if (!Number.isFinite(U)) continue; + const K = u.kind === "cytof" ? kn(y, z) : null, W = K !== null && K !== "self" && K !== "other"; + U === 0 && !W && Ve === "biological" || t.push({ + sourceIndex: g, + receiverIndex: x, + pairKey: `${y}${_e}${z}`, + source: se[g], + receiver: ae[x], + coefficient: U, + interaction: K, + physicalPrior: W ? 1 : 0 + }); + } + t.sort((g, x) => x.physicalPrior - g.physicalPrior || Math.abs(x.coefficient) - Math.abs(g.coefficient)); + const o = t.slice(0, 240), m = o.flatMap((g) => { + const x = Bt( + n, + g.source.key, + g.receiver.key, + { + eventMask: he, + fixedEventIndices: Kn, + eligibleEventCount: ce + } + ); + return x.ready ? [{ ...g, evidence: x.preview.evidence }] : []; + }), h = Vr( + m.map(({ coefficient: g, physicalPrior: x, evidence: y }) => ({ coefficient: g, physicalPrior: x, evidence: y })), + u.kind, + Ve + ).map(({ index: g, relativePriority: x }) => ({ ...m[g], relativePriority: x })); + return { + candidateCount: t.length, + screenedCount: o.length, + evaluableCount: m.length, + items: h.slice(0, 8) + }; + }, [Rs, Ve, V.state, u, ae, Kn, ce, he, n, se]), oe = S.useMemo(() => new Set( + j ? j.scientific.kind === "flow-spillover" ? j.scientific.matrix.receiverChannels : j.scientific.includedChannels : [] + ), [j]), le = S.useMemo(() => u ? Zr( + n, + Array.from(/* @__PURE__ */ new Set([ + ...u.sourceAxisKeys, + ...u.receiverAxisKeys + ])), + { + eventMask: he, + fixedEventIndices: Ft, + eligibleEventCount: ce + } + ) : null, [ + a, + Ft, + V.state, + u, + ce, + he, + n + ]); + S.useEffect(() => { + if (!u || oe.size === 0) return; + const t = oe.has(Ee) ? Ee : u.sourceAxisKeys.find((m) => oe.has(m)) ?? "", o = oe.has(Ne) && Ne !== t ? Ne : u.receiverAxisKeys.find((m) => m !== t && oe.has(m)) ?? ""; + t !== Ee && ui(t), o !== Ne && Mt(o); + }, [oe, Ne, Ee, u]); + const Cn = S.useMemo(() => new Set(Wn), [Wn]), $t = S.useMemo(() => { + var m; + if (!u) return []; + const t = [], o = oe.size > 0; + for (let h = 0; h < u.sourceAxisKeys.length; h++) { + const g = u.sourceAxisKeys[h]; + if (!(o && !oe.has(g))) + for (let x = 0; x < u.receiverAxisKeys.length; x++) { + const y = u.receiverAxisKeys[x]; + if (g === y || o && !oe.has(y)) continue; + const z = (m = u.matrix[h]) == null ? void 0 : m[x]; + if (!Number.isFinite(z)) continue; + const U = se[h], K = ae[x]; + if (!U || !K || le != null && le.ready && (!le.dataset.channels.has(U.key) || !le.dataset.channels.has(K.key))) continue; + const W = u.kind === "cytof" ? kn(g, y) : null, te = W !== null && W !== "self" && W !== "other"; + t.push({ + sourceIndex: h, + receiverIndex: x, + pairKey: `${g}${_e}${y}`, + source: U, + receiver: K, + coefficient: z, + interaction: W, + physicalPrior: te ? 1 : 0 + }); + } + } + return t; + }, [le, oe, u, ae, se]), Oe = S.useMemo(() => { + const t = Fn.trim().toLocaleLowerCase(); + return $t.filter((o) => { + const m = Math.abs(o.coefficient) > 1e-12, h = o.physicalPrior > 0; + return Pe === "all" || Pe === "relevant" && (m || h) || Pe === "nonzero" && m || Pe === "physical" && h || Pe === "flagged" && Cn.has(o.pairKey) ? t ? `${o.source.combined} ${o.receiver.combined}`.toLocaleLowerCase().includes(t) : !0 : !1; + }); + }, [Cn, $t, Pe, Fn]); + S.useEffect(() => { + var o; + if (!wt || ke !== "global") return; + const t = [...((o = wn.current) == null ? void 0 : o.querySelectorAll(".gl-comp-global-tile")) ?? []].find((m) => m.dataset.pairKey === wt); + t && (t.scrollIntoView({ block: "center", inline: "center" }), di(null)); + }, [$n, Re, wt, Oe, ke]); + const It = S.useMemo(() => { + if (Re === "compact") return []; + const t = /* @__PURE__ */ new Map(); + for (const o of Oe) { + const m = Re === "source" ? o.source : o.receiver, h = t.get(m.key); + h ? h.pairs.push(o) : t.set(m.key, { channel: m, pairs: [o] }); + } + return [...t.values()]; + }, [Re, Oe]), wi = S.useMemo( + () => Re === "compact" ? Oe : It.flatMap((t) => t.pairs), + [It, Re, Oe] + ), Ci = `${i(da[Pe])}${Fn.trim() ? i(" · search “{query}”", { query: Fn.trim() }) : ""}`, Pt = Math.max(120, Math.min(220, Math.round(ws) || 120)), en = Math.max(1, Math.min(10, Math.round(Ns) || 6)), tt = Math.max(0.1, Math.min(1, Number(Ms) || 0.85)), it = Math.max(0.3, Math.min(3, Number(Es) || 1)), ne = S.useMemo(() => !j || !u || V.state !== "ready" ? [] : Wn.flatMap((t) => { + const [o, m] = t.split(_e), h = u.sourceAxisKeys.indexOf(o), g = u.receiverAxisKeys.indexOf(m); + if (h < 0 || g < 0 || o === m || !oe.has(o) || !oe.has(m)) return []; + const x = Bt( + n, + se[h].key, + ae[g].key, + { + eventMask: he, + fixedEventIndices: Kn, + eligibleEventCount: ce + } + ); + if (!x.ready) return []; + const y = Me.items.find((z) => z.pairKey === t); + return [{ + sourceIndex: h, + receiverIndex: g, + pairKey: t, + source: se[h], + receiver: ae[g], + coefficient: u.matrix[h][g], + interaction: u.kind === "cytof" ? kn(o, m) : null, + physicalPrior: u.kind === "cytof" && kn(o, m) !== "other" ? 1 : 0, + evidence: x.preview.evidence, + relativePriority: (y == null ? void 0 : y.relativePriority) ?? 0 + }]; + }), [Wn, oe, V.state, u, j, ae, Me.items, Kn, ce, he, n, se]), De = ne, Ni = S.useMemo(() => { + if (!j) return 0.01; + const t = []; + for (let o = 0; o < j.scientific.matrix.matrix.length; o++) { + const m = j.scientific.matrix.sourceChannels[o]; + for (let h = 0; h < j.scientific.matrix.matrix[o].length; h++) { + if (m === j.scientific.matrix.receiverChannels[h]) continue; + const g = Math.abs(j.scientific.matrix.matrix[o][h]); + Number.isFinite(g) && g > 1e-12 && t.push(g); + } + } + return t.length > 0 ? ei(t) : 0.01; + }, [j]), Rt = (t, o) => { + const m = Is[t]; + if (m) return m; + const h = fs(o, Ni, (u == null ? void 0 : u.kind) ?? "flow"); + return { + lowerPercent: ie(h.lower * 100, 5), + upperPercent: ie(h.upper * 100, 5) + }; + }, Ln = (t, o) => { + const m = Rt(t, o), h = Number(m.lowerPercent) / 100, g = Number(m.upperPercent) / 100; + return !Number.isFinite(h) || !Number.isFinite(g) ? { lower: h, upper: g, error: "Enter finite lower and upper sweep bounds." } : (u == null ? void 0 : u.kind) === "cytof" && h < 0 ? { lower: h, upper: g, error: "CyTOF NNLS sweep bounds cannot be negative." } : g > h ? { lower: h, upper: g, error: null } : { lower: h, upper: g, error: "The upper sweep bound must be greater than the lower bound." }; + }, st = (t, o, m, h) => { + Ps((g) => ({ + ...g, + [t]: { + ...g[t] ?? (() => { + const x = fs(o, Ni, (u == null ? void 0 : u.kind) ?? "flow"); + return { + lowerPercent: ie(x.lower * 100, 5), + upperPercent: ie(x.upper * 100, 5) + }; + })(), + [m]: h + } + })), Ye((g) => { + if (!(t in g)) return g; + const x = { ...g }; + return delete x[t], x; + }), an((g) => { + if (!(t in g)) return g; + const x = { ...g }; + return delete x[t], x; + }); + }, On = (t, o) => { + Fs((m) => o ? m.includes(t) ? m : [...m, t] : m.filter((h) => h !== t)), o ? (Ce(t), In(t)) : (Ye((m) => { + if (!(t in m)) return m; + const h = { ...m }; + return delete h[t], h; + }), an((m) => { + if (!(t in m)) return m; + const h = { ...m }; + return delete h[t], h; + })); + }, Vs = () => { + if (!u || !Ee || !Ne || Ee === Ne) return; + if (!oe.has(Ee) || !oe.has(Ne)) { + ve("Both channels must be included in the installed compensation solve."); + return; + } + const t = `${Ee}${_e}${Ne}`; + On(t, !0), ve(null); + }, Kt = De.reduce((t, o) => t + (Ln(o.pairKey, o.coefficient).error ? 1 : 0), 0), Nn = S.useMemo(() => { + if (!j) return null; + const t = j.scientific.matrix.matrix.map((o) => Array.from(o)); + for (const [o, m] of Object.entries(Y)) { + const [h, g] = o.split(_e), x = j.scientific.matrix.sourceChannels.indexOf(h), y = j.scientific.matrix.receiverChannels.indexOf(g); + x >= 0 && y >= 0 && (t[x][y] = m); + } + return Object.freeze(t.map((o) => Object.freeze(o))); + }, [j, Y]); + S.useEffect(() => { + const t = Object.keys(Y).length; + if (!O || t === 0 || !j || j.scientific.kind !== "flow-spillover" || V.state !== "ready" || !Nn || !b || !N) { + jn.current++, rn({ state: "idle" }); + return; + } + const o = Rn; + if (o.length === 0) { + rn({ + state: "error", + pairKey: b.pairKey, + message: i("The selected review population contains no events.") + }); + return; + } + const m = ++jn.current, h = b.pairKey; + rn((x) => ({ + state: "updating", + pairKey: h, + ...(x.state === "ready" || x.state === "updating") && x.pairKey === h && x.preview ? { preview: x.preview } : {} + })); + const g = window.setTimeout(() => { + N( + j, + o, + Nn + ).then((x) => { + if (jn.current !== m) return; + const y = x.sourceChannels.indexOf(b.source.pnn), z = x.sourceChannels.indexOf(b.receiver.pnn); + if (y < 0 || z < 0) + throw new Error(i("The preview result did not contain the selected flow channels.")); + const U = qt( + n, + b.source.pnn, + b.receiver.pnn, + o, + x.candidateColumns[y], + x.candidateColumns[z], + { totalEvents: ce } + ); + if (!U.ready) throw new Error(U.reason); + rn({ + state: "ready", + pairKey: h, + preview: U.preview + }); + }).catch((x) => { + if (jn.current !== m) return; + const y = x instanceof Error ? x.message : String(x); + /cancel|supersed|stale/i.test(y) || rn({ state: "error", pairKey: h, message: y }); + }); + }, 90); + return () => window.clearTimeout(g); + }, [ + V.state, + N, + j, + Rn, + ce, + n, + n.dataRevision, + n.displayTransformContextKey, + n.layerRevision, + b, + Y, + i, + O, + Nn + ]); + const Ws = S.useMemo(() => !u || Object.keys(Y).length === 0 ? null : { + sourceChannels: u.sourceAxisKeys, + receiverChannels: u.receiverAxisKeys, + matrix: u.matrix.map( + (t, o) => t.map((m, h) => { + const g = `${u.sourceAxisKeys[o]}${_e}${u.receiverAxisKeys[h]}`; + return Y[g] ?? m; + }) + ) + }, [u, Y]), Si = S.useMemo(() => { + if (!u) return []; + const t = []; + for (let o = 0; o < u.matrix.length; o++) + for (let m = 0; m < u.matrix[o].length; m++) { + const h = u.matrix[o][m]; + u.sourceAxisKeys[o] === u.receiverAxisKeys[m] || !Number.isFinite(h) || h <= 1 || t.push(`${se[o].combined} → ${ae[m].combined}`); + } + return t; + }, [u, ae, se]), Lt = S.useMemo(() => { + if (!u) return []; + const t = []; + for (let o = 0; o < u.matrix.length; o++) + for (let m = 0; m < u.matrix[o].length; m++) { + const h = u.matrix[o][m], g = u.sourceAxisKeys[o] === u.receiverAxisKeys[m], x = `${se[o].combined} → ${ae[m].combined}`; + Number.isFinite(h) ? g && Math.abs(h - 1) > 1e-8 ? t.push(`${se[o].combined}: diagonal is ${tn(h)}, not 100%`) : !g && h < 0 ? t.push(`${x}: negative coefficient (${tn(h)})`) : !g && h > 1 && t.push(`${x}: coefficient above 100%`) : t.push(`${x}: non-finite coefficient (${String(h)})`); + } + return t; + }, [u, ae, se]), Mi = S.useMemo( + () => (u == null ? void 0 : u.matrix.some((t) => t.some((o) => !Number.isFinite(o)))) ?? !1, + [u] + ), Fe = S.useMemo( + () => D && V.state === "ready" ? wa(n, D.includedPnns) : null, + [V.state, D, n] + ), rt = S.useMemo(() => { + const t = [...Lt]; + return V.state === "stale" && t.push(...V.reasons.map((o) => `Profile unavailable: ${ga(o)}`)), t; + }, [V, Lt]), ki = D ? (j == null ? void 0 : j.name) ?? "Installed compensation profile" : ee ? me ? "SCE spillover matrix" : "Embedded FCS matrix" : "No compatible matrix", Gs = D ? fa(D.kind, D.method) : ee ? "Flow linear inverse" : "Not configured", at = i(Gs), Ot = (D == null ? void 0 : D.includedPnns.length) ?? (ee == null ? void 0 : ee.channels.length) ?? 0, ot = (j == null ? void 0 : j.name) ?? (D == null ? void 0 : D.profileId) ?? ki, Ei = Wt(ot), Hs = Ei !== ot || (j == null ? void 0 : j.recordType) === "revision" ? `${Ei} · ${i("revised")}` : ot, Zs = ee !== null && !Mi || D !== null && V.state === "ready", Ai = S.useMemo(() => { + if (!u) return 0; + let t = 0; + for (let o = 0; o < u.matrix.length; o++) + for (let m = 0; m < u.matrix[o].length; m++) { + if (u.sourceAxisKeys[o] === u.receiverAxisKeys[m]) continue; + const h = u.matrix[o][m]; + Number.isFinite(h) && (t = Math.max(t, Math.abs(h))); + } + return t; + }, [u]), Sn = !!((j == null ? void 0 : j.scientific.kind) === "flow-spillover" && V.state === "ready" && u && Math.max(u.sourceAxisKeys.length, u.receiverAxisKeys.length) <= ma), ln = u ? Sn ? Math.max(42, Math.min(54, Math.floor(960 / Math.max( + u.sourceAxisKeys.length, + u.receiverAxisKeys.length + )))) : Math.max(13, Math.min(38, Math.floor(760 / Math.max( + u.sourceAxisKeys.length, + u.receiverAxisKeys.length + )))) : 13, Dn = S.useMemo(() => { + const t = Sn ? 9.5 : 8, o = [...se, ...ae].map((K) => K.combined), m = typeof document > "u" ? null : document.createElement("canvas").getContext("2d"); + m && (m.font = `${t}px ${ca}`); + const h = (K) => m ? m.measureText(K).width : K.length * t * 0.55, g = o.reduce((K, W) => Math.max(K, h(W)), 0), x = Math.min(320, Math.max(94, Math.ceil(g) + 12)), y = Math.min(260, Math.max(82, Math.ceil(g) + 6)), z = Math.max(88, Math.ceil(y * Math.sin(as) + 12)), U = Math.max(0, Math.ceil(y * Math.cos(as) - ln / 2)); + return { rowLabelWidth: x, columnLabelWidth: y, columnLabelHeight: z, overhang: U }; + }, [Sn, ln, ae, se]); + S.useEffect(() => { + Gn({}), sn({}), rn({ state: "idle" }), jn.current++; + }, [j == null ? void 0 : j.profileId]), S.useEffect(() => { + (u == null ? void 0 : u.kind) === "flow" && Pe === "physical" && Vn("relevant"); + }, [Pe, u == null ? void 0 : u.kind, Vn]); + const Ys = (t) => { + oi((o) => ({ ...o, [t]: !o[t] })); + }, Ti = (t) => { + var h; + const o = ((h = wn.current) == null ? void 0 : h.getBoundingClientRect().width) ?? 1100, m = Math.max(360, Math.min(900, o - 440 - 8)); + return Math.max(360, Math.min(m, Math.round(t))); + }, Xs = (t) => { + var g; + if (t.button !== 0) return; + t.preventDefault(); + const o = t.currentTarget; + (g = o.setPointerCapture) == null || g.call(o, t.pointerId); + const m = (x) => { + var z; + const y = (z = wn.current) == null ? void 0 : z.getBoundingClientRect(); + y && li(Ti(y.right - x.clientX)); + }, h = () => { + var x; + window.removeEventListener("pointermove", m), window.removeEventListener("pointerup", h), window.removeEventListener("pointercancel", h), (x = o.releasePointerCapture) == null || x.call(o, t.pointerId); + }; + window.addEventListener("pointermove", m), window.addEventListener("pointerup", h), window.addEventListener("pointercancel", h); + }, Js = (t) => { + let o = null; + t.key === "ArrowLeft" ? o = xn + 40 : t.key === "ArrowRight" ? o = xn - 40 : t.key === "Home" && (o = hs), o !== null && (t.preventDefault(), li(Ti(o))); + }, Qs = async (t) => { + var m; + const o = (m = t.currentTarget.files) == null ? void 0 : m[0]; + t.currentTarget.value = "", o && await $i(o); + }, Fi = () => void Cr(yi.current, { "text/csv": [".csv", ".tsv", ".txt"] }, "CyTOF spillover matrix").then((t) => { + t != null && t[0] && $i(t[0]); + }), $i = async (t) => { + Xe(null), J(null), pe(!1), be(null), Ge(!1); + try { + const o = Rr(await t.text()), m = dt( + o.input, + "cytof-spillover" + ); + if (!m.ok) + throw new Error(m.errors.map(({ message: x }) => x).join(" ")); + const h = /* @__PURE__ */ new Map(); + for (const { pnn: x } of Tt) { + const y = x.trim().normalize("NFC"); + h.set(y, (h.get(y) ?? 0) + 1); + } + const g = m.value.receiverChannels.filter( + (x) => h.get(x) === 1 + ); + Zn({ + fileName: t.name, + source: "file", + parsed: o, + matrix: m.value, + validationWarnings: m.warnings + }), on(new Set(g)); + } catch (o) { + Zn(null), on(/* @__PURE__ */ new Set()), Xe(o instanceof Error ? o.message : String(o)); + } + }, er = (t, o) => { + on((m) => { + const h = new Set(m); + return o ? h.add(t) : h.delete(t), h; + }); + }, Ii = async () => { + var m, h; + if (!X) + throw new Error(i("Choose a CyTOF spillover matrix first.")); + const t = ((h = (m = globalThis.crypto) == null ? void 0 : m.randomUUID) == null ? void 0 : h.call(m)) ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`, o = X.fileName.replace(/\.(?:csv|tsv|txt)$/i, "") || "CyTOF compensation"; + return Ut( + { + kind: "cytof-spillover", + method: "nnls", + solverVersion: Mr, + solverSettings: kr, + matrix: X.matrix, + includedChannels: Array.from(Pn) + }, + { + profileId: `cytof-${t}`, + name: o, + createdAt: /* @__PURE__ */ new Date(), + origin: { + type: "uploaded", + fileName: X.fileName, + format: X.parsed.format.delimiter, + sourceColumnHeader: X.parsed.format.sourceColumnHeader + }, + provenance: { + sourceDescription: X.source === "host" ? "CyTOF spillover matrix from metadata(sce)$spillover_matrix" : "User-uploaded CyTOF spillover matrix", + estimationMethod: "Imported; coefficients preserved exactly" + } + } + ); + }, nr = async () => { + if (!(Te.current || B || !X || !(de != null && de.canApply) || !l)) { + if (p && !Se) { + Xe( + i("Confirm that existing gate memberships will be recomputed in compensated coordinates before applying.") + ); + return; + } + Xe(null), J(null), be(null), Te.current = !0, Ke(!0), He(X.fileName); + try { + const t = await Ii(); + await l(t, be), J(i("Applied {name} to {channels} channels across {files} checked FCS files. Original measurements remain available.", { + name: t.name, + channels: Pn.size, + files: Je + })), Zn(null), on(/* @__PURE__ */ new Set()), Ge(!1), be(null); + } catch (t) { + const o = t instanceof Error ? t.message : String(t); + /cancel/i.test(o) ? J(i("CyTOF compensation was cancelled; the previous assay was left unchanged.")) : Xe(o); + } finally { + Te.current = !1, Ke(!1), He(null); + } + } + }, tr = async () => { + if (!(Te.current || B || !X || !(de != null && de.canApply) || !Qe || !f || !At)) { + if (p && !Se) { + Xe( + i("Confirm that existing gate memberships will be recomputed in compensated coordinates before adopting the assay.") + ); + return; + } + Xe(null), J(null), be(null), Te.current = !0, Ke(!0), He(Qe.label); + try { + const t = await Ii(); + await f( + t, + Qe, + be + ), J(i("Using existing SCE assay {assay} with {matrix}. No assay values were recomputed.", { + assay: Qe.label, + matrix: t.name + })), Zn(null), on(/* @__PURE__ */ new Set()), Ge(!1), Jn(!1), be(null); + } catch (t) { + Xe(t instanceof Error ? t.message : String(t)); + } finally { + Te.current = !1, Ke(!1), He(null); + } + } + }, ir = async () => { + var h, g; + if (Te.current || B || !l) return; + if (p && !Se) { + pe(!0), J( + i("Confirm that existing gate memberships will be recomputed in compensated coordinates before starting a matrix.") + ); + return; + } + const t = n.channels.map((x, y) => ({ pnn: x.pnn, index: y })).filter(({ index: x }) => n.isFluorChannel(x) && !n.isImagingFeatureChannel(x)).map(({ pnn: x }) => x); + if (t.length < 2) { + pe(!0), J(i("An empty matrix needs at least two fluorescence channels.")); + return; + } + const o = dt({ + sourceChannels: t, + receiverChannels: t, + matrix: t.map((x, y) => t.map((z, U) => y === U ? 1 : 0)) + }, "flow-spillover"); + if (!o.ok) { + pe(!0), J(o.errors.map(({ message: x }) => x).join(" ")); + return; + } + const m = `${s.replace(/\.fcs$/i, "") || "Flow"} manual matrix`; + J(null), pe(!1), be(null), Te.current = !0, Ke(!0), He(m); + try { + const x = ((g = (h = globalThis.crypto) == null ? void 0 : h.randomUUID) == null ? void 0 : g.call(h)) ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`, y = await Ut( + { + kind: "flow-spillover", + method: "matrix-inverse", + solverVersion: qi, + solverSettings: Bi, + matrix: o.value + }, + { + profileId: `flow-manual-${x}`, + name: m, + createdAt: /* @__PURE__ */ new Date(), + origin: { type: "manual", startedAs: "identity" }, + provenance: { + sourceDescription: "Identity matrix over the file's fluorescence channels, to be set by hand in GateLab", + estimationMethod: "Manual" + } + } + ); + await l(y, be), Ge(!1), J(i("Manual matrix editing is ready: every spillover starts at zero. Select a pair and set its coefficient.")); + } catch (x) { + pe(!0), J(x instanceof Error ? x.message : String(x)); + } finally { + Te.current = !1, Ke(!1); + } + }, sr = async () => { + if (!(!c || B || Yn)) { + if (p && !Se) { + pe(!0), J( + i("Confirm that existing gate memberships will be recomputed in original coordinates before removing the matrix.") + ); + return; + } + vi(!0); + try { + await c(), pe(!1), J(i("The matrix was removed. The original assay is active and every file reads its stored values.")); + } catch (t) { + pe(!0), J(t instanceof Error ? t.message : String(t)); + } finally { + vi(!1); + } + } + }, rr = async () => { + var o, m, h; + if (Te.current || B || !ee || !((o = Le == null ? void 0 : Le.validation) != null && o.ok) || !l) return; + if (p && !Se) { + pe(!0), J( + i("Confirm that existing gate memberships will be recomputed in compensated coordinates before enabling matrix editing.") + ); + return; + } + const t = (me == null ? void 0 : me.name) || `${s.replace(/\.fcs$/i, "") || "Flow"} spillover`; + J(null), pe(!1), be(null), Te.current = !0, Ke(!0), He(t); + try { + const g = ((h = (m = globalThis.crypto) == null ? void 0 : m.randomUUID) == null ? void 0 : h.call(m)) ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`, x = await Ut( + { + kind: "flow-spillover", + method: "matrix-inverse", + solverVersion: qi, + solverSettings: Bi, + matrix: Le.validation.value + }, + { + profileId: `flow-${g}`, + name: t, + createdAt: /* @__PURE__ */ new Date(), + origin: { + ...me ? { + type: "uploaded", + fileName: me.name, + format: "csv", + sourceColumnHeader: "source" + } : { + type: "embedded-fcs", + fileName: s, + ...Le.keyword ? { keyword: Le.keyword } : {} + } + }, + provenance: { + sourceDescription: me ? "Flow spillover matrix from metadata(sce)$spillover_matrix" : "Spillover matrix embedded in the source FCS file", + estimationMethod: me ? "Imported from SCE metadata; coefficients preserved exactly" : "Imported from FCS; coefficients preserved exactly" + } + } + ); + await l(x, be), Ge(!1), J(i(me ? "Flow matrix editing is ready. The exact hosted matrix is retained as the baseline, and Original measurements remain available." : "Flow matrix editing is ready. The exact embedded matrix is retained as the baseline, and Original measurements remain available.")); + } catch (g) { + pe(!0), J(g instanceof Error ? g.message : String(g)); + } finally { + Te.current = !1, Ke(!1), He(null), be(null); + } + }, Pi = (t, o) => { + var g, x; + const m = se[t], h = ae[o]; + !u || !m || !h || u.sourceAxisKeys[t] === u.receiverAxisKeys[o] || (Ce(`${u.sourceAxisKeys[t]}${_e}${u.receiverAxisKeys[o]}`), (x = (g = ji.current) == null ? void 0 : g.querySelector( + `button[data-source-index="${t}"][data-receiver-index="${o}"]` + )) == null || x.focus()); + }, ar = (t, o, m) => { + if (!u) return; + const h = u.sourceAxisKeys.length, g = u.receiverAxisKeys.length; + let x = o, y = m; + const z = (K, W) => { + let te = K + W; + for (; te >= 0 && te < g; ) { + if (u.sourceAxisKeys[o] !== u.receiverAxisKeys[te]) return te; + te += W; + } + return K; + }, U = (K, W) => { + let te = K + W; + for (; te >= 0 && te < h; ) { + if (u.sourceAxisKeys[te] !== u.receiverAxisKeys[m]) return te; + te += W; + } + return K; + }; + switch (t.key) { + case "ArrowLeft": + y = z(m, -1); + break; + case "ArrowRight": + y = z(m, 1); + break; + case "ArrowUp": + x = U(o, -1); + break; + case "ArrowDown": + x = U(o, 1); + break; + case "Home": { + y = u.sourceAxisKeys[o] === u.receiverAxisKeys[0] ? 1 : 0; + break; + } + case "End": { + const K = g - 1; + y = u.sourceAxisKeys[o] === u.receiverAxisKeys[K] ? K - 1 : K; + break; + } + default: + return; + } + t.preventDefault(), Pi(x, y); + }, zn = (t, o) => { + if (!j || !Number.isFinite(o)) return; + const [m, h] = t.split(_e), g = j.scientific.matrix.sourceChannels.indexOf(m), x = j.scientific.matrix.receiverChannels.indexOf(h); + if (g < 0 || x < 0) return; + if (j.scientific.kind === "cytof-spillover" && o < 0) { + pe(!0), J(i("CyTOF NNLS spill coefficients cannot be negative.")); + return; + } + const y = j.scientific.matrix.matrix[g][x]; + Gn((z) => { + const U = { ...z }; + return o === y ? delete U[t] : U[t] = o, U; + }), pe(!1), J(i("Staged {source} → {receiver} at {value}%. Apply the revised matrix to recompute the assay.", { + source: m, + receiver: h, + value: (o * 100).toFixed(2) + })); + }, Ri = (t, o, m, h) => { + const g = m[0]; + if (!g) return null; + const x = g.sourceChannels.indexOf(t.source.pnn), y = g.sourceChannels.indexOf(t.receiver.pnn); + if (x < 0 || y < 0) return null; + const z = qt( + n, + t.source.pnn, + t.receiver.pnn, + h, + g.currentColumns[x], + g.currentColumns[y], + { totalEvents: ce } + ); + if (!z.ready) return null; + const U = [{ + value: t.coefficient, + isCurrent: !0, + preview: z.preview + }]; + return m.forEach((K, W) => { + const te = K.sourceChannels.indexOf(t.source.pnn), ze = K.sourceChannels.indexOf(t.receiver.pnn); + if (te < 0 || ze < 0) return; + const we = qt( + n, + t.source.pnn, + t.receiver.pnn, + h, + K.candidateColumns[te], + K.candidateColumns[ze], + { + totalEvents: ce, + xRange: z.preview.xRange, + yRange: z.preview.yRange + } + ); + we.ready && U.push({ + value: o[W], + isCurrent: !1, + preview: we.preview + }); + }), U.sort((K, W) => K.value - W.value || Number(W.isCurrent) - Number(K.isCurrent)), { pairKey: t.pairKey, values: Object.freeze(U) }; + }, or = async (t) => { + if (!j || !u || !F || B || ue || ye) return; + const o = Ln(t.pairKey, t.coefficient); + if (o.error) { + ve(o.error); + return; + } + const m = mn( + n.fcs.nEvents, + ls, + he + ); + if (m.length === 0) { + ve(i("The selected review population contains no events.")); + return; + } + const h = ++Ae.current, g = [o.lower, o.upper]; + bn(t.pairKey), ve(null); + try { + const x = await F( + j, + m, + g.map((z) => ps( + j, + u.sourceAxisKeys[t.sourceIndex], + u.receiverAxisKeys[t.receiverIndex], + z + )), + void 0, + 1 + ); + if (Ae.current !== h) return; + const y = Ri(t, g, x, m); + if (!y) throw new Error(i("The fast bounds preview could not be built for this pair.")); + an((z) => ({ ...z, [t.pairKey]: y })); + } catch (x) { + if (Ae.current !== h) return; + const y = x instanceof Error ? x.message : String(x); + ve(/cancel/i.test(y) ? i("Fast bounds preview cancelled.") : y); + } finally { + Ae.current === h && bn(null); + } + }, lr = async () => { + var h; + if (!j || !F || De.length === 0 || B || ue !== null || ye !== null) return; + if (Kt > 0) { + ve(i("Fix the sweep bounds for {count} flagged pairs before running.", { count: Kt })); + return; + } + const t = mn( + n.fcs.nEvents, + os, + he + ); + if (t.length === 0) { + ve(i("The selected review population contains no events.")); + return; + } + const o = ++Ae.current, m = De.flatMap((g) => { + const x = Ln(g.pairKey, g.coefficient); + return ya(x.lower, x.upper).map((y) => ({ + pair: g, + value: y, + matrix: ps( + j, + u.sourceAxisKeys[g.sourceIndex], + u.receiverAxisKeys[g.receiverIndex], + y + ) + })); + }); + ve(null), Ye({}), yn({ completed: 0, total: m.length }); + try { + const g = await F( + j, + t, + m.map(({ matrix: y }) => y), + (y, z) => { + Ae.current === o && yn({ completed: y, total: z }); + }, + Nt + ); + if (Ae.current !== o) return; + if (g.length !== m.length) + throw new Error(i("The compensation worker returned an incomplete coefficient sweep.")); + const x = {}; + for (const y of De) { + const z = m.flatMap((K, W) => K.pair.pairKey === y.pairKey ? [W] : []), U = Ri( + y, + z.map((K) => m[K].value), + z.map((K) => g[K]), + t + ); + U && (x[y.pairKey] = U); + } + Ye(x), In(((h = De[0]) == null ? void 0 : h.pairKey) ?? null); + } catch (g) { + if (Ae.current !== o) return; + const x = g instanceof Error ? g.message : String(g); + ve(/cancel/i.test(x) ? i("Exact coefficient sweep cancelled.") : x); + } finally { + Ae.current === o && yn(null); + } + }, cr = () => { + Ae.current++, R == null || R(), yn(null), bn(null), ve(i("Exact coefficient sweep cancelled.")); + }, dr = async () => { + var o, m; + if (!j || !Nn || !l || Object.keys(Y).length === 0) return; + const t = `${Wt(j.name)} · edited`; + J(null), pe(!1), Ke(!0), He(t), be(null); + try { + const g = { + profileId: `comp-edit-${((m = (o = globalThis.crypto) == null ? void 0 : o.randomUUID) == null ? void 0 : m.call(o)) ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`}`, + name: t, + createdAt: /* @__PURE__ */ new Date(), + note: `Edited ${Object.keys(Y).length} compensation coefficient${Object.keys(Y).length === 1 ? "" : "s"} in GateLab.` + }, x = (E == null ? void 0 : E.recordType) === "baseline" && ja(Nn, E.scientific.matrix.matrix) ? await Nr(j, E, g) : await Sr( + j, + va(j, Nn), + g + ); + await l(x, be), Gn({}), sn({}), Ye({}), an({}), bn(null), ve(null), kt((y) => y + 1), ne.length > 0 && (qn("attention"), Ce(ne[0].pairKey), In(ne[0].pairKey)), J(i("Applied revised matrix for {name}. Original measurements and the complete compensation revision history remain available.{flagged}", { + name: Wt(x.name), + flagged: ne.length > 0 ? i( + ne.length === 1 ? " Retained {count} flagged pair for post-correction review." : " Retained {count} flagged pairs for post-correction review.", + { count: ne.length } + ) : "" + })); + } catch (h) { + pe(!0), J(h instanceof Error ? h.message : String(h)); + } finally { + Ke(!1), He(null), be(null); + } + }, Ki = (t) => { + if (ne.length === 0) return; + const o = ne.findIndex(({ pairKey: g }) => g === qe), m = o < 0 ? t > 0 ? 0 : ne.length - 1 : (o + t + ne.length) % ne.length, h = ne[m]; + Ie(null), Ce(h.pairKey), In(h.pairKey); + }, Dt = () => /* @__PURE__ */ e.jsx( + "div", + { + className: "gl-comp-inspector-resize", + role: "separator", + "aria-label": i("Resize compensation inspector"), + "aria-orientation": "vertical", + "aria-valuemin": 360, + "aria-valuemax": 900, + "aria-valuenow": xn, + tabIndex: 0, + title: i("Drag to resize the coefficient inspector; use Left/Right arrow keys for fine control"), + onPointerDown: Xs, + onKeyDown: Js, + children: /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true" }) + } + ), ur = (t) => { + Ie(null), Ce(t), jt(!0), $t.some((o) => o.pairKey === t) && (Oe.some((o) => o.pairKey === t) || (Vn("all"), ci("")), di(t)); + }, zt = (t, o = !1) => { + const m = b ? Cn.has(b.pairKey) : !1, h = b ? ne.find(({ pairKey: H }) => H === b.pairKey) ?? null : null, g = b ? Rt(b.pairKey, b.value) : null, x = b ? Ln(b.pairKey, b.value) : null, y = b ? Os[b.pairKey] : null, z = b ? u.sourceAxisKeys[b.sourceIndex] : "", U = b ? u.receiverAxisKeys[b.receiverIndex] : "", K = b != null && b.interaction && b.interaction !== "self" && b.interaction !== "other" ? 1 : 0, W = b && (je != null && je.ready) ? Xt({ + coefficient: b.value, + physicalPrior: K, + evidence: je.preview.evidence + }, u.kind, Ve) : null, te = b ? ba(E, z, U) : null, ze = (b == null ? void 0 : b.value) ?? null, we = b ? Y[b.pairKey] : void 0, Mn = !!(b && (j == null ? void 0 : j.scientific.kind) === "flow-spillover" && N && Object.keys(Y).length > 0), Ze = We.state !== "idle" && We.state !== "error" && We.pairKey === (b == null ? void 0 : b.pairKey) ? We.preview : null, cn = Ze ?? (je != null && je.ready ? je.preview : null), dn = []; + te !== null && ze !== null && ((j == null ? void 0 : j.recordType) === "revision" || te !== ze) && dn.push({ label: i("Baseline"), value: te }), ze !== null && dn.push({ label: i("Installed"), value: ze }), we !== void 0 && dn.push({ label: i("Staged"), value: we }); + const un = ne.findIndex(({ pairKey: H }) => H === qe); + return /* @__PURE__ */ e.jsxs("section", { className: `gl-comp-inspector${o ? " is-global" : ""}`, "aria-labelledby": "comp-selected-heading", children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-panel-head gl-comp-inspector-head", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("h3", { id: "comp-selected-heading", children: i("Selected coefficient") }), + !o && /* @__PURE__ */ e.jsx("span", { children: i(bt ? "Hover preview · click to pin this pair." : qe ? "Pinned pair · hover another cell to compare." : "Select a matrix cell or follow-up pair.") }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-inspector-actions", children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-flag-navigation", "aria-label": i("Flagged compensation pair navigation"), children: [ + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + "aria-label": i("Previous flagged compensation pair"), + disabled: ne.length === 0, + onClick: () => Ki(-1), + children: "←" + } + ), + /* @__PURE__ */ e.jsx("span", { children: un >= 0 ? i("{current} / {total} flagged", { current: un + 1, total: ne.length }) : i("{total} flagged", { total: ne.length }) }), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + "aria-label": i("Next flagged compensation pair"), + disabled: ne.length === 0, + onClick: () => Ki(1), + children: "→" + } + ) + ] }), + t && /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn gl-comp-inspector-close", + "aria-label": i("Close global compensation pair details"), + title: i("Close details and return to the full gallery"), + onClick: t, + children: "×" + } + ) + ] }) + ] }), + b ? /* @__PURE__ */ e.jsxs("div", { className: `gl-comp-pair-detail${o ? " is-global" : ""}`, children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-pair-route", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Source channel") }), + /* @__PURE__ */ e.jsx("strong", { children: b.source.label }), + /* @__PURE__ */ e.jsx("small", { children: b.source.pnn }) + ] }), + /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true", children: "→" }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Receiver") }), + /* @__PURE__ */ e.jsx("strong", { children: b.receiver.label }), + /* @__PURE__ */ e.jsx("small", { children: b.receiver.pnn }) + ] }) + ] }), + W && /* @__PURE__ */ e.jsxs( + "div", + { + className: `gl-comp-evidence-badge is-${W.category}`, + title: i(W.detail), + children: [ + /* @__PURE__ */ e.jsx("strong", { children: i(W.label) }), + /* @__PURE__ */ e.jsx("span", { children: i(W.detail) }) + ] + } + ), + /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-followup-toggle", children: [ + /* @__PURE__ */ e.jsx( + "input", + { + type: "checkbox", + checked: m, + disabled: !j || !oe.has(u.sourceAxisKeys[b.sourceIndex]) || !oe.has(u.receiverAxisKeys[b.receiverIndex]), + onChange: (H) => On(b.pairKey, H.currentTarget.checked) + } + ), + /* @__PURE__ */ e.jsx("span", { children: i("Flag for follow-up") }), + /* @__PURE__ */ e.jsx("small", { children: i("Add this pair to the curated Flagged queue.") }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-coefficient-readout", title: i("Stored fraction: {value}", { value: ie(b.value, 10) }), children: [ + /* @__PURE__ */ e.jsx("span", { children: i(Y[b.pairKey] === void 0 ? "Matrix coefficient" : "Working coefficient") }), + /* @__PURE__ */ e.jsx("strong", { children: Number.isFinite(Y[b.pairKey] ?? b.value) ? `${((Y[b.pairKey] ?? b.value) * 100).toFixed(1)}%` : String(Y[b.pairKey] ?? b.value) }) + ] }), + dn.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-coefficient-history", "aria-label": i("Coefficient history"), children: dn.map((H, hn) => /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-coefficient-history-step", children: [ + hn > 0 && /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true", children: "→" }), + /* @__PURE__ */ e.jsxs("div", { title: i("Exact fraction: {value}", { value: ie(H.value, 10) }), children: [ + /* @__PURE__ */ e.jsx("small", { children: H.label }), + /* @__PURE__ */ e.jsxs("strong", { children: [ + (H.value * 100).toFixed(1), + "%" + ] }) + ] }) + ] }, `${H.label}:${hn}`)) }), + j && qe === b.pairKey && !bt && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-coefficient-editor", children: [ + /* @__PURE__ */ e.jsxs("label", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Coefficient (%)") }), + /* @__PURE__ */ e.jsx( + An, + { + step: "0.1", + value: Hn, + disabled: B, + onValueChange: (H) => { + Et(H), j.scientific.kind === "flow-spillover" && H.trim() !== "" && Number.isFinite(Number(H)) && zn(b.pairKey, Number(H) / 100); + } + } + ) + ] }), + j.scientific.kind === "flow-spillover" ? /* @__PURE__ */ e.jsx("small", { className: "gl-comp-live-edit-hint", children: i("Type, use arrows, or drag ↕ · previews immediately") }) : /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: B || !Number.isFinite(Number(Hn)) || Hn.trim() === "", + onClick: () => zn(b.pairKey, Number(Hn) / 100), + children: i("Stage value") + } + ), + Y[b.pairKey] !== void 0 && /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: B, + onClick: () => { + zn(b.pairKey, b.value), sn((H) => { + const hn = { ...H }; + return delete hn[b.pairKey], hn; + }); + }, + children: i("Reset") + } + ) + ] }), + Mn && /* @__PURE__ */ e.jsxs("div", { className: `gl-comp-candidate-status${o ? " is-compact" : ""}`, "aria-label": i("Flow compensation coefficient preview"), children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("strong", { children: i("Coefficient preview") }), + /* @__PURE__ */ e.jsxs("span", { children: [ + i("Original remains fixed; the right panel shows the complete working matrix."), + o ? i(" The gallery remains installed until Apply.") : "" + ] }) + ] }), + /* @__PURE__ */ e.jsx("em", { children: we === void 0 ? i("Working matrix") : `${(b.value * 100).toFixed(1)}% → ${(we * 100).toFixed(1)}%` }), + We.state === "updating" && We.pairKey === b.pairKey && /* @__PURE__ */ e.jsx("span", { role: "status", children: i("Updating…") }), + We.state === "error" && We.pairKey === b.pairKey && /* @__PURE__ */ e.jsx("span", { className: "is-error", role: "alert", children: i(We.message) }) + ] }), + b.interaction && b.interaction !== "other" && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-interaction-type", children: [ + i("Physical relationship:"), + " ", + /* @__PURE__ */ e.jsx("strong", { children: b.interaction }) + ] }), + o && (cn ? /* @__PURE__ */ e.jsx( + rs, + { + preview: cn, + sourceLabel: b.source.label, + receiverLabel: b.receiver.label, + kind: u.kind, + densitySmoothing: en, + compact: !0, + compensatedTitle: i(Ze ? "Candidate" : "Compensated") + } + ) : je && !je.ready ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-biplot-unavailable", children: i(je.reason) }) : null), + o && /* @__PURE__ */ e.jsx( + aa, + { + matrixView: u, + sourceChannels: se, + receiverChannels: ae, + selectedSourceIndex: b.sourceIndex, + selectedReceiverIndex: b.receiverIndex, + stagedCoefficients: Y, + maximumAbsoluteOffDiagonal: Ai, + onSelect: ur + } + ), + !o && (cn ? /* @__PURE__ */ e.jsx( + rs, + { + preview: cn, + sourceLabel: b.source.label, + receiverLabel: b.receiver.label, + kind: u.kind, + densitySmoothing: en, + compensatedTitle: i(Ze ? "Candidate" : "Compensated") + } + ) : je && !je.ready ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-biplot-unavailable", children: i(je.reason) }) : null), + m && h && g && x && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-bounds-tool", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("strong", { children: i("Sweep bounds") }), + /* @__PURE__ */ e.jsx("span", { children: i("Four exact candidates will be interpolated across these endpoints.") }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-bounds-inputs", children: [ + /* @__PURE__ */ e.jsxs("label", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Lower (%)") }), + /* @__PURE__ */ e.jsx( + An, + { + step: "0.1", + value: g.lowerPercent, + disabled: B || ue !== null || ye !== null, + onValueChange: (H) => st(b.pairKey, b.value, "lowerPercent", H) + } + ) + ] }), + /* @__PURE__ */ e.jsxs("label", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Upper (%)") }), + /* @__PURE__ */ e.jsx( + An, + { + step: "0.1", + value: g.upperPercent, + disabled: B || ue !== null || ye !== null, + onValueChange: (H) => st(b.pairKey, b.value, "upperPercent", H) + } + ) + ] }), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: B || ue !== null || ye !== null || x.error !== null, + onClick: () => void or(h), + children: i(ye === b.pairKey ? "Previewing…" : "Preview endpoints") + } + ) + ] }), + x.error ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-bounds-error", children: i(x.error) }) : /* @__PURE__ */ e.jsx("small", { children: i("Fast preview: exact solver on {preview} frozen events. Screening only; the four-option sweep uses up to {sweep} events.", { + preview: Math.min(ce, ls).toLocaleString(), + sweep: Math.min(ce, os).toLocaleString() + }) }), + y && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-bounds-preview", children: y.values.map((H) => /* @__PURE__ */ e.jsx("div", { className: H.isCurrent ? "is-current" : void 0, children: /* @__PURE__ */ e.jsx( + xt, + { + title: `${H.isCurrent ? `${i("Current")} · ` : ""}${(H.value * 100).toFixed(2)}%`, + panel: H.preview.compensated, + preview: H.preview, + sourceLabel: b.source.label, + receiverLabel: b.receiver.label, + minimumSize: 145, + maximumSize: 220, + densitySmoothing: en + } + ) }, `${b.pairKey}:bounds:${H.value}:${H.isCurrent}`)) }) + ] }), + /* @__PURE__ */ e.jsx("p", { className: "gl-hint", children: i(u.coefficientNote) }) + ] }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-inspector-empty", children: i("No coefficient selected.") }) + ] }); + }, Li = (t, o) => /* @__PURE__ */ e.jsx( + oa, + { + dataset: o, + pair: t, + plotSize: Pt, + densitySmoothing: en, + flagged: Cn.has(t.pairKey), + selected: qe === t.pairKey, + onSelect: () => { + Ie(null), Ce(t.pairKey), jt(!0); + }, + onFlag: (m) => On(t.pairKey, m) + }, + t.pairKey + ), hr = async (t, o) => { + if (!(le != null && le.ready) || !u) + throw new Error("Apply compensation before exporting the Global inspector comparison."); + const m = wi.map((h) => ({ + pairKey: h.pairKey, + sourceLabel: h.source.label, + receiverLabel: h.receiver.label, + coefficient: h.coefficient, + relationship: h.interaction, + buildPreview: () => { + const g = vs( + le.dataset, + h.source.key, + h.receiver.key + ); + if (!g.ready) throw new Error(g.reason); + return g.preview; + } + })); + await Xr(m, { + sampleName: s, + profileName: (j == null ? void 0 : j.name) ?? i(u.title), + populationName: (Q == null ? void 0 : Q.name) ?? i("All Events"), + filterLabel: Ci, + densitySmoothing: en, + densityColorPower: G, + pointAlpha: tt, + pointSize: it + }, t, o); + }; + return O ? /* @__PURE__ */ e.jsx(si.Provider, { value: G, children: /* @__PURE__ */ e.jsx(ri.Provider, { value: tt, children: /* @__PURE__ */ e.jsx(ai.Provider, { value: it, children: /* @__PURE__ */ e.jsxs( + "div", + { + className: "gl-tab-panel gl-tab-fill gl-compensation-tab gl-plotting-workspace gl-comp-workspace", + children: [ + /* @__PURE__ */ e.jsxs("div", { className: `gl-plotting-head gl-comp-head gl-comp-overview${ke === "global" ? " is-global-scan" : ""}`, children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-overview-title", children: [ + /* @__PURE__ */ e.jsx("h2", { className: "gl-tab-title", children: i("Compensation") }), + !D && /* @__PURE__ */ e.jsx("span", { className: "gl-comp-method", children: at }) + ] }), + D ? /* @__PURE__ */ e.jsxs( + "div", + { + id: "comp-profile-heading", + className: `gl-comp-profile-pill${V.state === "ready" ? " is-ready" : " is-stale"}`, + role: "status", + title: i("{source} · {method} · {count} solve channels · {status} · {assay}", { + source: ot, + method: at, + count: Ot, + status: i(V.state === "ready" ? "Ready" : "Unavailable"), + assay: i(a ? "Compensated assay active" : "Original assay active") + }), + children: [ + /* @__PURE__ */ e.jsx("span", { className: `gl-comp-status-dot${V.state === "ready" ? " is-ready" : " is-stale"}`, "aria-hidden": "true" }), + /* @__PURE__ */ e.jsxs("span", { className: "gl-sr-only", children: [ + i("{kind} compensation installed. Installed compensation profile.", { + kind: D.kind === "cytof-spillover" ? "CyTOF" : "Flow" + }), + " " + ] }), + /* @__PURE__ */ e.jsx("strong", { children: Hs }), + /* @__PURE__ */ e.jsx("span", { children: i("{method} · {count} ch · {status}", { + method: at, + count: Ot, + status: V.state === "ready" ? i("Ready") : i("Unavailable") + }) }), + /* @__PURE__ */ e.jsx("em", { children: i(a ? "Comp active" : "Original active") }) + ] + } + ) : /* @__PURE__ */ e.jsx( + "span", + { + className: "gl-comp-summary", + "aria-label": i("Compensation summary"), + "data-active-layer": a ? "compensated" : "original", + children: i("{source} · {assay} · {count} channels", { + source: i(ki), + assay: i(a ? "Compensated assay active" : "Original assay active"), + count: Ot + }) + } + ), + D && n.instrument === "cytof" && /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn gl-comp-header-replace", + disabled: B, + onClick: Fi, + children: i("Replace matrix…") + } + ), + D && c && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-header-remove", children: [ + p && /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-gate-acknowledgement is-compact", children: [ + /* @__PURE__ */ e.jsx( + "input", + { + type: "checkbox", + checked: Se, + disabled: B || Yn, + onChange: (t) => Ge(t.currentTarget.checked) + } + ), + /* @__PURE__ */ e.jsx("span", { children: i("Recompute existing gate memberships in original coordinates.") }) + ] }), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: B || Yn, + title: i("Uninstall the matrix: every file returns to the original assay and the matrix leaves the workspace."), + onClick: () => void sr(), + children: i(Yn ? "Removing…" : "Remove the matrix") + } + ) + ] }), + Zs && /* @__PURE__ */ e.jsx("span", { className: "gl-comp-global-layer-note", children: i("Assay selection in the top bar applies to every tab.") }) + ] }), + /* @__PURE__ */ e.jsxs("aside", { className: "gl-plotting-inspector gl-comp-inspector-left", "aria-label": i("Compensation controls"), children: [ + n.instrument === "flow" && !D && /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-pane-matrix", children: [ + /* @__PURE__ */ e.jsx("h3", { children: i("Matrix") }), + n.instrument === "flow" && ee && !D && /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-flow-enable", "aria-labelledby": "comp-flow-enable-heading", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("strong", { id: "comp-flow-enable-heading", children: i(me ? "SCE spillover matrix" : "Embedded FCS matrix") }), + /* @__PURE__ */ e.jsx("span", { children: i("Install this exact matrix as the immutable baseline to edit coefficients and preview their effect.") }) + ] }), + p && /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-gate-acknowledgement is-compact", children: [ + /* @__PURE__ */ e.jsx( + "input", + { + type: "checkbox", + checked: Se, + disabled: B, + onChange: (t) => Ge(t.currentTarget.checked) + } + ), + /* @__PURE__ */ e.jsx("span", { children: i("Recompute existing gate memberships in compensated coordinates.") }) + ] }), + Le != null && Le.error ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-error", role: "alert", children: Le.error }) : B ? /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-flow-enable-progress", role: "status", children: [ + re ? i("Preparing editor… {percent}%", { percent: Math.round(re.fraction * 100) }) : i("Preparing editor…"), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-btn-ghost", + disabled: (re == null ? void 0 : re.phase) === "cancelling", + onClick: v, + children: i((re == null ? void 0 : re.phase) === "cancelling" ? "Cancelling…" : "Cancel") + } + ) + ] }) : /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-btn", + disabled: !l || p && !Se, + onClick: () => void rr(), + children: i("Enable matrix editing") + } + ) + ] }), + n.instrument === "flow" && !D && /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-flow-enable", "aria-labelledby": "comp-flow-empty-heading", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("strong", { id: "comp-flow-empty-heading", children: i("Empty matrix") }), + /* @__PURE__ */ e.jsx("span", { children: i(ee ? "Or start from an identity matrix over the file's fluorescence channels, every spillover at zero, and set the coefficients by hand." : "Start from an identity matrix over the file's fluorescence channels, every spillover at zero, and set the coefficients by hand.") }) + ] }), + p && !ee && /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-gate-acknowledgement is-compact", children: [ + /* @__PURE__ */ e.jsx( + "input", + { + type: "checkbox", + checked: Se, + disabled: B, + onChange: (t) => Ge(t.currentTarget.checked) + } + ), + /* @__PURE__ */ e.jsx("span", { children: i("Recompute existing gate memberships in compensated coordinates.") }) + ] }), + B ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-flow-enable-progress", role: "status", children: i("Preparing editor…") }) : /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-btn", + disabled: !l || p && !Se, + onClick: () => void ir(), + children: i("Start from an empty matrix") + } + ) + ] }) + ] }), + /* @__PURE__ */ e.jsxs("section", { children: [ + /* @__PURE__ */ e.jsx("h3", { children: i("Review scope") }), + /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-review-population", children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Review population") }), + /* @__PURE__ */ e.jsxs( + "select", + { + "aria-label": i("Compensation review population"), + value: (Q == null ? void 0 : Q.id) ?? "all", + disabled: ue !== null || ye !== null, + onChange: (t) => Ct(t.currentTarget.value), + children: [ + /* @__PURE__ */ e.jsx("option", { value: "all", children: i("All Events") }), + T.map((t) => /* @__PURE__ */ e.jsx("option", { value: t.id, children: `${"· ".repeat(t.depth)}${t.name} (${t.eventCount.toLocaleString()})` }, t.id)) + ] + } + ), + /* @__PURE__ */ e.jsx("small", { children: i("{count} events · applies to biplots, attention ranking, and sweeps; membership frozen from the current assay", { + count: ce.toLocaleString() + }) }) + ] }), + ke !== "global" && /* @__PURE__ */ e.jsxs( + "label", + { + className: "gl-comp-preview-events", + title: i("Controls the frozen event set shown in the selected-pair Original and comparison biplots. Applying compensation still processes every event."), + children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Pair preview") }), + /* @__PURE__ */ e.jsxs( + "select", + { + "aria-label": i("Compensation pair preview event count"), + value: String(et), + disabled: B, + onChange: (t) => { + const o = t.currentTarget.value; + Ts(o === "all" ? "all" : Number(o)); + }, + children: [ + ds.map((t) => /* @__PURE__ */ e.jsx("option", { value: t, children: i("{count} events", { count: t.toLocaleString() }) }, t)), + /* @__PURE__ */ e.jsx("option", { value: "all", children: i("All available") }) + ] + } + ), + /* @__PURE__ */ e.jsx("small", { children: i("Showing {shown} of {total}; Apply always uses all events.", { + shown: Rn.length.toLocaleString(), + total: ce.toLocaleString() + }) }) + ] + } + ) + ] }), + (A !== void 0 && I !== void 0 && P || u && Object.keys(Y).length > 0) && /* @__PURE__ */ e.jsxs("section", { children: [ + /* @__PURE__ */ e.jsx("h3", { children: i("Apply") }), + A !== void 0 && I !== void 0 && P && /* @__PURE__ */ e.jsxs( + "label", + { + className: "gl-comp-worker-control", + title: i("Event-parallel Apply workers. The aggregate memory budget stays fixed; more workers are not always faster."), + children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Apply workers") }), + /* @__PURE__ */ e.jsx( + "select", + { + "aria-label": i("Compensation Apply worker count"), + value: A, + disabled: B, + onChange: (t) => P(Number(t.currentTarget.value)), + children: Array.from({ length: I }, (t, o) => o + 1).map((t) => /* @__PURE__ */ e.jsx("option", { value: t, children: t }, t)) + } + ), + /* @__PURE__ */ e.jsxs("small", { children: [ + "/ ", + I + ] }) + ] + } + ), + u && Object.keys(Y).length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-staged-actions", children: [ + /* @__PURE__ */ e.jsxs("span", { children: [ + i("{count} pending edits", { count: Object.keys(Y).length }), + (j == null ? void 0 : j.scientific.kind) === "cytof-spillover" ? ` · ${i("{files} checked FCS files", { files: Je })}` : "" + ] }), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: B, + onClick: () => { + Gn({}), sn({}), J(null); + }, + children: i("Discard") + } + ), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-btn", + disabled: B || ue !== null || ye !== null || !l || (j == null ? void 0 : j.scientific.kind) === "cytof-spillover" && Je === 0, + onClick: () => void dr(), + children: i("Apply revised matrix") + } + ) + ] }) + ] }), + u && /* @__PURE__ */ e.jsxs("section", { children: [ + /* @__PURE__ */ e.jsx("h3", { children: i("Biplot display") }), + /* @__PURE__ */ e.jsxs( + "label", + { + className: "gl-comp-density-smoothing", + title: i("Blur radius for every compensation biplot; both assay layers always use the same setting"), + children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Density smooth") }), + /* @__PURE__ */ e.jsx( + "input", + { + type: "range", + min: "1", + max: "10", + step: "1", + value: en, + "aria-label": i("Compensation biplot density smoothing"), + onChange: (t) => Ss(Number(t.currentTarget.value)) + } + ), + /* @__PURE__ */ e.jsx("output", { children: en }) + ] + } + ), + /* @__PURE__ */ e.jsxs( + "label", + { + className: "gl-comp-point-alpha", + title: i("Point opacity for every compensation biplot"), + children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Point alpha") }), + /* @__PURE__ */ e.jsx( + "input", + { + type: "range", + min: "0.1", + max: "1", + step: "0.05", + value: tt, + "aria-label": i("Compensation biplot point alpha"), + onChange: (t) => ks(Number(t.currentTarget.value)) + } + ), + /* @__PURE__ */ e.jsx("output", { children: tt.toFixed(2) }) + ] + } + ), + /* @__PURE__ */ e.jsxs( + "label", + { + className: "gl-comp-point-alpha", + title: i("Point size for every compensation biplot, as a factor on the size each panel's width gives"), + children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Point size") }), + /* @__PURE__ */ e.jsx( + "input", + { + type: "range", + min: "0.3", + max: "3", + step: "0.1", + value: it, + "aria-label": i("Compensation biplot point size"), + onChange: (t) => As(Number(t.currentTarget.value)) + } + ), + /* @__PURE__ */ e.jsxs("output", { children: [ + it.toFixed(1), + "×" + ] }) + ] + } + ), + /* @__PURE__ */ e.jsx( + jr, + { + className: "gl-comp-density-colour", + value: G, + onChange: q + } + ) + ] }), + (u || D) && /* @__PURE__ */ e.jsxs("section", { children: [ + /* @__PURE__ */ e.jsx("h3", { children: i("Tools") }), + /* @__PURE__ */ e.jsx("div", { className: "gl-comp-drawer-buttons", children: ua.map(({ id: t, label: o }) => /* @__PURE__ */ e.jsxs( + "button", + { + type: "button", + id: `comp-drawer-${t}-button`, + className: "gl-comp-drawer-toggle", + "aria-expanded": Bn[t], + "aria-controls": `comp-drawer-${t}`, + onClick: () => Ys(t), + children: [ + /* @__PURE__ */ e.jsxs("span", { children: [ + i(o), + t === "review" && rt.length > 0 ? ` (${rt.length})` : "" + ] }), + /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true", children: Bn[t] ? "▾" : "▸" }) + ] + }, + t + )) }) + ] }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-prop-body gl-comp-body", children: [ + u && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-workspace-tabs", role: "tablist", "aria-label": i("Compensation workspace"), children: [ + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + role: "tab", + "aria-selected": ke === "matrix", + className: ke === "matrix" ? "active" : void 0, + onClick: () => { + Ie(null), qn("matrix"); + }, + children: i("Matrix") + } + ), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + role: "tab", + "aria-selected": ke === "global", + className: ke === "global" ? "active" : void 0, + onClick: () => { + Ie(null), qn("global"); + }, + children: i("Global inspector") + } + ), + /* @__PURE__ */ e.jsxs( + "button", + { + type: "button", + role: "tab", + "aria-selected": ke === "attention", + className: ke === "attention" ? "active" : void 0, + onClick: () => { + Ie(null), qn("attention"); + }, + children: [ + i("Flagged"), + ne.length > 0 ? ` (${ne.length})` : "" + ] + } + ) + ] }), + n.instrument === "cytof" && /* @__PURE__ */ e.jsx( + "input", + { + ref: yi, + type: "file", + accept: ".csv,.tsv,.txt,text/csv,text/tab-separated-values,text/plain", + className: "gl-sr-only", + "aria-label": i("Choose CyTOF spillover matrix"), + onChange: (t) => void Qs(t) + } + ), + fi && /* @__PURE__ */ e.jsx("div", { className: gi ? "gl-comp-error" : "gl-comp-status", role: gi ? "alert" : "status", children: i(fi) }), + n.instrument === "cytof" && (!D || X) && /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-cytof-import", "aria-labelledby": "comp-cytof-import-heading", children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-panel-head gl-comp-import-head", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("h3", { id: "comp-cytof-import-heading", children: i("CyTOF spillover matrix") }), + /* @__PURE__ */ e.jsx("span", { children: i("Linear counts → non-negative least squares → arcsinh display") }) + ] }), + /* @__PURE__ */ e.jsx("div", { className: "gl-comp-import-actions", children: /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: X ? "gl-btn-ghost" : "gl-btn", + disabled: B, + onClick: Fi, + children: i(X ? "Choose another matrix…" : "Import matrix…") + } + ) }) + ] }), + xi && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-error", role: "alert", children: i(xi) }), + X && de && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-import-body", children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-import-summary", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("strong", { children: X.fileName }), + /* @__PURE__ */ e.jsx("span", { children: i("{sources} sources × {receivers} receivers", { + sources: X.matrix.sourceChannels.length, + receivers: X.matrix.receiverChannels.length + }) }) + ] }), + /* @__PURE__ */ e.jsxs("dl", { children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Exact matches") }), + /* @__PURE__ */ e.jsx("dd", { children: de.matchedChannels.length }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Included") }), + /* @__PURE__ */ e.jsx("dd", { children: de.includedChannels.length }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Not in FCS") }), + /* @__PURE__ */ e.jsx("dd", { children: de.matrixOnlyChannels.length }) + ] }) + ] }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-channel-head", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("h4", { children: i("Channels included in NNLS") }), + /* @__PURE__ */ e.jsx("span", { children: i("Exact, case-sensitive $PnN matching; unchecked channels pass through unchanged.") }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: B, + onClick: () => on(new Set(de.matchedChannels)), + children: i("All matched") + } + ), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: B, + onClick: () => on(/* @__PURE__ */ new Set()), + children: i("None") + } + ) + ] }) + ] }), + /* @__PURE__ */ e.jsx("div", { className: "gl-comp-channel-grid", children: X.matrix.receiverChannels.map((t) => { + const o = de.matchedChannels.includes(t); + return /* @__PURE__ */ e.jsxs("label", { className: o ? "" : "is-unavailable", title: o ? t : i("{channel} is not uniquely present in this FCS file", { channel: t }), children: [ + /* @__PURE__ */ e.jsx( + "input", + { + type: "checkbox", + checked: Pn.has(t), + disabled: !o || B, + onChange: (m) => er(t, m.currentTarget.checked) + } + ), + /* @__PURE__ */ e.jsx("span", { children: Gt(n, t).combined }), + !o && /* @__PURE__ */ e.jsx("small", { children: i("not matched") }) + ] }, t); + }) }), + (X.validationWarnings.length > 0 || de.warnings.length > 0) && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-warning", role: "status", children: /* @__PURE__ */ e.jsx("span", { children: i("{count} review items: {messages}", { + count: X.validationWarnings.length + de.warnings.length, + messages: [ + ...X.validationWarnings.map(({ message: t }) => t), + ...de.warnings.map(({ message: t }) => t) + ].map((t) => i(t)).join(" ") + }) }) }), + de.blockers.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-error", role: "alert", children: de.blockers.map(({ message: t }) => i(t)).join(" ") }), + p && /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-gate-acknowledgement", children: [ + /* @__PURE__ */ e.jsx( + "input", + { + type: "checkbox", + checked: Se, + disabled: B, + onChange: (t) => Ge(t.currentTarget.checked) + } + ), + /* @__PURE__ */ e.jsx("span", { children: i("I understand that existing gates are retained, but their memberships will be recomputed using the compensated coordinates.") }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-apply-row", children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-apply-copy", children: [ + /* @__PURE__ */ e.jsx("span", { children: B ? re ? i("{phase}… {percent}% ({processed} / {total} events)", { + phase: i(re.phase === "cancelling" ? "Cancelling" : re.phase === "preparing" ? "Preparing" : "Applying"), + percent: Math.round(re.fraction * 100), + processed: re.processedEvents.toLocaleString(), + total: re.totalEvents.toLocaleString() + }) : i("Preparing compensation…") : i("The Original assay is retained and can be restored at any time.") }), + /* @__PURE__ */ e.jsx("strong", { className: Je === 0 ? "is-empty" : void 0, children: Je === 0 ? i("No FCS files are checked. Select at least one file in Samples.") : i("Applies atomically to {files} checked FCS files · {events} total events", { + files: Je, + events: qs.toLocaleString() + }) }) + ] }), + B ? /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-btn-ghost", + disabled: (re == null ? void 0 : re.phase) === "cancelling", + onClick: v, + children: i((re == null ? void 0 : re.phase) === "cancelling" ? "Cancelling…" : "Cancel") + } + ) : /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-btn", + disabled: !l || Je === 0 || !de.canApply || p && !Se, + onClick: () => void nr(), + children: i("Apply NNLS compensation") + } + ) + ] }), + d.length > 0 && f && /* @__PURE__ */ e.jsxs( + "div", + { + className: "gl-comp-adopt-existing", + "aria-labelledby": "comp-adopt-existing-heading", + children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-adopt-copy", children: [ + /* @__PURE__ */ e.jsx("strong", { id: "comp-adopt-existing-heading", children: i("Use an existing SCE assay") }), + /* @__PURE__ */ e.jsx("span", { children: i("Records this matrix against data already computed in R. GateLabR will not recompute or overwrite the selected assay.") }) + ] }), + /* @__PURE__ */ e.jsxs("label", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Existing linear assay") }), + /* @__PURE__ */ e.jsx( + "select", + { + value: (Qe == null ? void 0 : Qe.id) ?? "", + disabled: B, + onChange: (t) => { + bi(t.currentTarget.value), Jn(!1); + }, + children: d.map((t) => /* @__PURE__ */ e.jsx("option", { value: t.id, children: t.label === t.id ? t.id : `${t.label} (${t.id})` }, t.id)) + } + ) + ] }), + /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-adopt-confirm", children: [ + /* @__PURE__ */ e.jsx( + "input", + { + type: "checkbox", + checked: At, + disabled: B, + onChange: (t) => Jn(t.currentTarget.checked) + } + ), + /* @__PURE__ */ e.jsx("span", { children: i("I confirm this assay was computed from the selected source assay using this exact matrix and channel set.") }) + ] }), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-btn-ghost", + disabled: B || !Qe || !At || Je === 0 || !de.canApply || p && !Se, + onClick: () => void tr(), + children: i("Use existing assay — no recomputation") + } + ) + ] + } + ) + ] }) + ] }), + Mi && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-error", role: "alert", children: i("The embedded compensation matrix contains non-finite values and cannot be applied.") }), + Si.length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-warning", role: "status", children: [ + /* @__PURE__ */ e.jsx("span", { children: i("{count} off-diagonal coefficients are above 100%. Review the matrix source before applying it.", { + count: Si.length + }) }), + /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => oi((t) => ({ ...t, review: !0 })), children: i("Review details") }) + ] }), + D && V.state === "stale" && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-warning", role: "status", children: i("This profile cannot be applied to the current sample context. Open the review queue for exact reasons.") }), + u && ke === "matrix" ? /* @__PURE__ */ e.jsxs( + "div", + { + ref: wn, + className: "gl-comp-common-path", + style: { gridTemplateColumns: `minmax(440px, 1fr) 8px ${xn}px` }, + children: [ + /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-matrix-panel", "aria-labelledby": "comp-matrix-heading", children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-panel-head gl-comp-matrix-head", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("h3", { id: "comp-matrix-heading", children: i(u.title) }), + /* @__PURE__ */ e.jsx("span", { children: i(u.subtitle) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-matrix-head-actions", children: [ + Sn && /* @__PURE__ */ e.jsx("span", { className: "gl-comp-inline-edit-note", children: i("Edit cells directly (%)") }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-matrix-legend", "aria-label": i("Matrix colour key"), children: [ + /* @__PURE__ */ e.jsxs("span", { children: [ + /* @__PURE__ */ e.jsx("i", { className: "is-diagonal", "aria-hidden": "true" }), + i("Diagonal (self)") + ] }), + /* @__PURE__ */ e.jsxs("span", { children: [ + /* @__PURE__ */ e.jsx("i", { className: "is-positive", "aria-hidden": "true" }), + i("Positive spill") + ] }), + /* @__PURE__ */ e.jsxs("span", { children: [ + /* @__PURE__ */ e.jsx("i", { className: "is-negative", "aria-hidden": "true" }), + i("Negative") + ] }) + ] }), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + onClick: () => mi(!0), + children: i("Export CSV…") + } + ) + ] }) + ] }), + /* @__PURE__ */ e.jsx("div", { className: "gl-comp-matrix-scroll", children: /* @__PURE__ */ e.jsxs( + "div", + { + className: `gl-comp-matrix-stage${Sn ? " is-flow-inline" : ""}`, + style: { + width: 18 + Dn.rowLabelWidth + u.receiverAxisKeys.length * ln + Dn.overhang, + "--gl-comp-row-label-w": `${Dn.rowLabelWidth}px`, + "--gl-comp-col-label-w": `${Dn.columnLabelWidth}px`, + "--gl-comp-col-label-h": `${Dn.columnLabelHeight}px` + }, + children: [ + /* @__PURE__ */ e.jsx("div", { className: "gl-comp-matrix-axis gl-comp-matrix-receiver-axis", children: i("Receiver channels →") }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-matrix-body", children: [ + /* @__PURE__ */ e.jsx("div", { className: "gl-comp-matrix-axis gl-comp-matrix-source-axis", children: i("Source channels ↓") }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-matrix-labelled", children: [ + /* @__PURE__ */ e.jsx("div", { className: "gl-comp-matrix-corner", "aria-hidden": "true", children: "%" }), + /* @__PURE__ */ e.jsx( + "div", + { + className: "gl-comp-column-labels", + "aria-label": i("Receiver channel labels"), + style: { + gridTemplateColumns: `repeat(${u.receiverAxisKeys.length}, ${ln}px)` + }, + children: ae.map((t, o) => /* @__PURE__ */ e.jsx( + "div", + { + className: (b == null ? void 0 : b.receiverIndex) === o ? "is-selected" : void 0, + title: t.combined, + children: /* @__PURE__ */ e.jsx("span", { children: t.combined }) + }, + u.receiverAxisKeys[o] + )) + } + ), + /* @__PURE__ */ e.jsx( + "div", + { + className: "gl-comp-row-labels", + "aria-label": i("Source channel labels"), + style: { + gridTemplateRows: `repeat(${u.sourceAxisKeys.length}, ${ln}px)` + }, + children: se.map((t, o) => /* @__PURE__ */ e.jsx( + "div", + { + className: (b == null ? void 0 : b.sourceIndex) === o ? "is-selected" : void 0, + title: t.combined, + children: t.combined + }, + u.sourceAxisKeys[o] + )) + } + ), + /* @__PURE__ */ e.jsx( + "div", + { + ref: ji, + className: "gl-comp-matrix shows-values", + role: "grid", + "aria-label": i("Compensation matrix; source rows and receiver columns"), + "aria-rowcount": u.sourceAxisKeys.length, + "aria-colcount": u.receiverAxisKeys.length, + style: { + gridTemplateColumns: `repeat(${u.receiverAxisKeys.length}, ${ln}px)`, + gridTemplateRows: `repeat(${u.sourceAxisKeys.length}, ${ln}px)` + }, + children: u.matrix.map((t, o) => /* @__PURE__ */ e.jsx( + "div", + { + role: "row", + className: "gl-comp-matrix-row", + "aria-rowindex": o + 1, + children: t.map((m, h) => { + const g = u.sourceAxisKeys[o], x = u.receiverAxisKeys[h], y = `${g}${_e}${x}`, z = Y[y], U = z ?? m, K = g === x, W = (b == null ? void 0 : b.sourceIndex) === o && b.receiverIndex === h, te = (b == null ? void 0 : b.sourceIndex) === o, ze = (b == null ? void 0 : b.receiverIndex) === h, we = se[o], Mn = ae[h], Ze = u.kind === "cytof" ? kn(g, x) : null, cn = wr( + U, + Ai, + K + ), dn = u.receiverAxisKeys.findIndex((ge) => ge !== g), un = qe === y, H = qe === null && o === 0 && h === dn, hn = Number.isFinite(U) ? U === 0 ? "" : (U * 100).toFixed(1) : String(U), zi = Ze && Ze !== "other" && Ze !== "self" ? ` · ${Ze}` : "", mr = Ks[y] ?? ms(U); + return Sn && !K ? /* @__PURE__ */ e.jsx( + An, + { + role: "gridcell", + className: `gl-comp-cell gl-comp-cell-input${W ? " selected" : ""}${un ? " is-pinned" : ""}${z === void 0 ? "" : " is-staged"}${te ? " is-selected-source" : ""}${ze ? " is-selected-receiver" : ""}`, + min: "0", + step: "0.1", + value: mr, + disabled: B, + "data-source-index": o, + "data-receiver-index": h, + "aria-colindex": h + 1, + "aria-selected": un, + "aria-label": i("{source} source to {receiver} receiver coefficient, percent{pending}", { + source: we.combined, + receiver: Mn.combined, + pending: z === void 0 ? "" : i(", pending edit") + }), + title: i("{source} → {receiver} · type or drag vertically to edit spillover percentage{pending}", { + source: we.combined, + receiver: Mn.combined, + pending: z === void 0 ? "" : i(" · pending edit") + }), + style: cn, + onFocus: () => Ce(y), + onMouseEnter: () => Ie(y), + onMouseLeave: () => Ie((ge) => ge === y ? null : ge), + onClick: () => Ce(y), + onValueChange: (ge) => { + Ce(y), sn((_n) => ({ ..._n, [y]: ge })), ge.trim() !== "" && Number.isFinite(Number(ge)) && zn(y, Number(ge) / 100); + }, + onBlur: (ge) => { + const _n = ge.currentTarget.value; + if (_n.trim() === "" || !Number.isFinite(Number(_n))) { + sn((_t) => { + const _i = { ..._t }; + return delete _i[y], _i; + }); + return; + } + sn((_t) => ({ + ..._t, + [y]: ms(Number(_n) / 100) + })); + } + }, + x + ) : /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + role: "gridcell", + className: `gl-comp-cell${K ? " diagonal" : ""}${W ? " selected" : ""}${un ? " is-pinned" : ""}${z === void 0 ? "" : " is-staged"}${te ? " is-selected-source" : ""}${ze ? " is-selected-receiver" : ""}`, + disabled: K, + tabIndex: K ? -1 : W || H ? 0 : -1, + "data-source-index": o, + "data-receiver-index": h, + "data-interaction": Ze ?? void 0, + "aria-colindex": h + 1, + "aria-pressed": K ? void 0 : un, + "aria-label": K ? i("{channel} diagonal: {value}", { channel: we.combined, value: tn(U) }) : i("{source} source to {receiver} receiver: {value}{pending}{interaction}", { + source: we.combined, + receiver: Mn.combined, + value: tn(U), + pending: z === void 0 ? "" : i(" (pending edit)"), + interaction: zi + }), + title: K ? `${we.combined} · self · ${tn(U)}` : `${we.combined} → ${Mn.combined} · ${tn(U)}${z === void 0 ? "" : " · pending edit"}${zi}`, + style: cn, + onFocus: () => { + K || Ce(y); + }, + onMouseEnter: () => { + K || Ie(y); + }, + onMouseLeave: () => Ie((ge) => ge === y ? null : ge), + onClick: () => Ce(y), + onKeyDown: (ge) => ar(ge, o, h), + children: /* @__PURE__ */ e.jsx("span", { children: hn }) + }, + x + ); + }) + }, + u.sourceAxisKeys[o] + )) + } + ) + ] }) + ] }) + ] + } + ) }) + ] }), + Dt(), + zt() + ] + } + ) : u && ke === "global" ? /* @__PURE__ */ e.jsxs( + "div", + { + ref: wn, + className: `gl-comp-common-path gl-comp-global-path${$n ? " has-details" : ""}`, + style: { + gridTemplateColumns: $n ? `minmax(440px, 1fr) 8px ${xn}px` : "minmax(0, 1fr)" + }, + children: [ + /* @__PURE__ */ e.jsx( + la, + { + stateKey: _, + header: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-global-head-title", children: [ + /* @__PURE__ */ e.jsx("h3", { id: "comp-global-inspector-heading", children: i("Global data inspector") }), + /* @__PURE__ */ e.jsx( + "span", + { + className: "gl-comp-lock-pill", + title: i("The assay flip keeps the same events, axes, transform, density bins, colour scale, and tile geometry."), + children: i("View locked") + } + ) + ] }), + /* @__PURE__ */ e.jsxs( + "select", + { + "aria-label": i("Global compensation pair filter"), + title: i("Choose which channel pairs appear"), + value: Pe, + onChange: (t) => Vn(t.currentTarget.value), + children: [ + /* @__PURE__ */ e.jsx("option", { value: "relevant", children: i("Matrix-linked / relevant") }), + /* @__PURE__ */ e.jsx("option", { value: "nonzero", children: i("Non-zero coefficients") }), + u.kind === "cytof" && /* @__PURE__ */ e.jsx("option", { value: "physical", children: i("Physical CyTOF relationships") }), + /* @__PURE__ */ e.jsx("option", { value: "flagged", children: i("Flagged for follow-up") }), + /* @__PURE__ */ e.jsx("option", { value: "all", children: i("All included pairs") }) + ] + } + ), + /* @__PURE__ */ e.jsxs( + "select", + { + className: "gl-comp-global-layout", + "aria-label": i("Global compensation plot layout"), + title: i("Show one compressed gallery or organise channel pairs into labelled rows"), + value: Re, + onChange: (t) => js(t.currentTarget.value), + children: [ + /* @__PURE__ */ e.jsx("option", { value: "compact", children: i("Compact gallery") }), + /* @__PURE__ */ e.jsx("option", { value: "source", children: i("Rows by source") }), + /* @__PURE__ */ e.jsx("option", { value: "receiver", children: i("Rows by receiver") }) + ] + } + ), + /* @__PURE__ */ e.jsx( + "input", + { + className: "gl-comp-global-search", + type: "search", + value: Fn, + placeholder: i("Find channel…"), + "aria-label": i("Search global compensation pairs"), + onChange: (t) => ci(t.currentTarget.value) + } + ), + /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-global-size", children: [ + /* @__PURE__ */ e.jsx("span", { className: "gl-sr-only", children: i("Plot size") }), + /* @__PURE__ */ e.jsx( + "input", + { + type: "range", + min: "120", + max: "220", + step: "4", + value: Pt, + "aria-label": i("Global compensation plot size"), + onChange: (t) => Cs(Number(t.currentTarget.value)) + } + ), + /* @__PURE__ */ e.jsx("output", { children: i("{size}px", { size: Pt }) }) + ] }), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn gl-comp-global-export", + disabled: !(le != null && le.ready) || Oe.length === 0, + title: i("Export the currently filtered pairs as locked Original and Compensated comparison pages"), + onClick: () => pi(!0), + children: i("Export…") + } + ), + /* @__PURE__ */ e.jsx( + "span", + { + className: "gl-comp-global-count", + title: i("The Global gallery uses one fixed representative event set so every pair and both assay layers remain directly comparable."), + children: i("{pairs} pairs · {shown} / {total} events · {population}", { + pairs: Oe.length.toLocaleString(), + shown: Ft.length.toLocaleString(), + total: ce.toLocaleString(), + population: (Q == null ? void 0 : Q.name) ?? i("All Events") + }) + } + ) + ] }), + children: le ? le.ready ? Oe.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-global-empty", children: i("No pairs match the current filter. Choose another filter or clear the channel search.") }) : Re === "compact" ? /* @__PURE__ */ e.jsx( + "div", + { + className: "gl-comp-global-gallery", + "data-event-signature": le.dataset.eventSignature, + children: Oe.map((t) => Li(t, le.dataset)) + } + ) : /* @__PURE__ */ e.jsx( + "div", + { + className: "gl-comp-global-groups", + "data-event-signature": le.dataset.eventSignature, + "data-layout": Re, + children: It.map((t) => /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-global-group", children: [ + /* @__PURE__ */ e.jsxs("header", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i(Re === "source" ? "Source channel" : "Receiver") }), + /* @__PURE__ */ e.jsx("strong", { title: t.channel.combined, children: t.channel.label }), + /* @__PURE__ */ e.jsx("small", { children: t.channel.pnn }), + /* @__PURE__ */ e.jsx("em", { children: i("{count} pairs", { count: t.pairs.length }) }) + ] }), + /* @__PURE__ */ e.jsx("div", { className: "gl-comp-global-group-plots", children: t.pairs.map((o) => Li(o, le.dataset)) }) + ] }, t.channel.key)) + } + ) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-global-empty", children: i(le.reason) }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-global-empty", children: i("No matrix is available for the global inspector.") }) + } + ), + $n && Dt(), + $n && zt(() => jt(!1), !0) + ] + } + ) : u ? /* @__PURE__ */ e.jsxs( + "div", + { + ref: wn, + className: "gl-comp-common-path", + style: { gridTemplateColumns: `minmax(440px, 1fr) 8px ${xn}px` }, + children: [ + /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-attention gl-comp-attention-panel", "aria-labelledby": "comp-attention-heading", children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-attention-head", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("h3", { id: "comp-attention-heading", children: i("Flagged pairs") }), + /* @__PURE__ */ e.jsx("p", { children: i("This is your follow-up queue. Suggestions are a population-scoped evidence screen, not a verdict and not automatically included. Exact sweeps change one coefficient at a time across four user-bounded values using the same frozen events.") }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-attention-actions", children: [ + /* @__PURE__ */ e.jsxs("label", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Sweep workers") }), + /* @__PURE__ */ e.jsx( + "select", + { + "aria-label": i("Compensation sweep workers"), + value: Nt, + disabled: ue !== null || ye !== null, + onChange: (t) => St(Number(t.currentTarget.value)), + children: Array.from({ length: us }, (t, o) => o + 1).map((t) => /* @__PURE__ */ e.jsx("option", { value: t, children: t }, t)) + } + ) + ] }), + ue ? /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-btn-ghost", onClick: cr, children: i("Cancel sweep") }) : /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-btn", + disabled: !j || !F || De.length === 0 || Kt > 0 || B || ye !== null, + onClick: () => void lr(), + children: i("Run four-value sweeps ({count})", { count: De.length }) + } + ) + ] }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-attention-scope", children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Suggestions computed for {population} from up to {count} frozen events.", { + population: (Q == null ? void 0 : Q.name) ?? i("All Events"), + count: Math.min(ce, Kn.length).toLocaleString() + }) }), + /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-evidence-mode", children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Evidence mode") }), + /* @__PURE__ */ e.jsxs( + "select", + { + "aria-label": i("Compensation evidence mode"), + value: Ve, + disabled: B || ue !== null || ye !== null, + onChange: (t) => { + $s(t.currentTarget.value), kt((o) => o + 1), Ye({}), an({}), ve(null); + }, + children: [ + /* @__PURE__ */ e.jsx("option", { value: "biological", children: i("Biological sample (conservative)") }), + /* @__PURE__ */ e.jsx("option", { value: "control", children: i("Single-stain / control") }) + ] + } + ) + ] }), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: B || ue !== null || ye !== null, + onClick: () => { + kt((t) => t + 1), Ye({}), an({}), ve(null), pe(!1), J( + i(ne.length === 1 ? "Recomputed compensation suggestions for {population}. {count} flagged pair was retained." : "Recomputed compensation suggestions for {population}. {count} flagged pairs were retained.", { + population: (Q == null ? void 0 : Q.name) ?? i("All Events"), + count: ne.length + }) + ); + }, + children: i("Recompute suggestions") + } + ), + /* @__PURE__ */ e.jsxs("small", { children: [ + i(Ve === "biological" ? "Broad positive association is excluded because co-expression and cell size can mimic spill. High-tail shapes remain control-sensitive review prompts." : "Positive residual association may enter the shortlist only because you declared suitable control data."), + " ", + i("Sweep workers are separate from full-Apply workers.") + ] }) + ] }), + ue && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-sweep-progress", role: "status", "aria-live": "polite", children: [ + /* @__PURE__ */ e.jsx("progress", { max: Math.max(1, ue.total), value: ue.completed }), + /* @__PURE__ */ e.jsx("span", { children: i("{completed} / {total} exact candidate solves · {workers} workers", { + completed: ue.completed, + total: ue.total, + workers: Nt + }) }) + ] }), + hi && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-warning", role: "status", children: i(hi) }), + j ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-manual-followup", role: "group", "aria-label": i("Add compensation pair for follow-up"), children: [ + /* @__PURE__ */ e.jsx("strong", { children: i("Add a pair") }), + /* @__PURE__ */ e.jsxs("label", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Source channel") }), + /* @__PURE__ */ e.jsx( + Ui, + { + label: i("Follow-up source channel"), + value: Ee, + options: u.sourceAxisKeys.flatMap((t, o) => oe.has(t) ? [{ value: t, label: se[o].combined }] : []), + onChange: (t) => { + ui(t), Ne === t && Mt(u.receiverAxisKeys.find((o) => o !== t && oe.has(o)) ?? ""); + } + } + ) + ] }), + /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true", children: "→" }), + /* @__PURE__ */ e.jsxs("label", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Receiver") }), + /* @__PURE__ */ e.jsx( + Ui, + { + label: i("Follow-up receiver channel"), + value: Ne, + options: u.receiverAxisKeys.flatMap((t, o) => t !== Ee && oe.has(t) ? [{ value: t, label: ae[o].combined }] : []), + onChange: Mt + } + ) + ] }), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: !Ee || !Ne || Ee === Ne, + onClick: Vs, + children: i("Flag for follow-up") + } + ) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-flagged-columns", children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-attention-section", children: [ + /* @__PURE__ */ e.jsx("div", { className: "gl-comp-attention-section-head", children: /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("h4", { children: i("Flagged by you ({count})", { count: De.length }) }), + /* @__PURE__ */ e.jsx("span", { children: i("Only these pairs are included when you run sweeps.") }) + ] }) }), + De.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-attention-empty", children: i("No pairs are flagged yet. Tick “Flag for follow-up” in the inspector, add a pair above, or accept a suggestion below.") }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-sweep-list", children: De.map((t, o) => { + const m = Ls[t.pairKey], h = Ds === t.pairKey, g = Ln(t.pairKey, t.coefficient), x = Rt(t.pairKey, t.coefficient); + return /* @__PURE__ */ e.jsxs("article", { className: `gl-comp-sweep-pair${qe === t.pairKey ? " is-selected" : ""}`, children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-sweep-pair-head-row", children: [ + /* @__PURE__ */ e.jsxs( + "button", + { + type: "button", + className: "gl-comp-sweep-pair-head", + "aria-expanded": h, + onClick: () => { + Ce(t.pairKey), In(h ? null : t.pairKey); + }, + children: [ + /* @__PURE__ */ e.jsx("span", { className: "gl-comp-sweep-rank", children: o + 1 }), + /* @__PURE__ */ e.jsxs("span", { children: [ + /* @__PURE__ */ e.jsxs("strong", { children: [ + t.source.label, + " → ", + t.receiver.label + ] }), + /* @__PURE__ */ e.jsxs("small", { children: [ + t.interaction && t.interaction !== "other" ? `${t.interaction} · ` : "", + i("installed {value}%", { value: (t.coefficient * 100).toFixed(1) }) + ] }) + ] }), + /* @__PURE__ */ e.jsx("span", { children: t.evidence.status === "ready" ? i("shift {shift} MAD · slope {slope}", { + shift: ie(t.evidence.normalizedNegativeShift ?? 0, 3), + slope: ie(t.evidence.residualSlope ?? 0, 4) + }) : i("visual review · residual groups insufficient") }), + /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true", children: h ? "▾" : "▸" }) + ] + } + ), + /* @__PURE__ */ e.jsx("label", { className: "gl-comp-followup-list-toggle", title: i("Remove from follow-up queue"), children: /* @__PURE__ */ e.jsx( + "input", + { + type: "checkbox", + checked: !0, + "aria-label": i("Flag {source} to {receiver} for follow-up", { + source: t.source.label, + receiver: t.receiver.label + }), + onChange: (y) => On(t.pairKey, y.currentTarget.checked) + } + ) }) + ] }), + h && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-sweep-pair-body", children: [ + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-inline-bounds", children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Four values across") }), + /* @__PURE__ */ e.jsxs("label", { children: [ + i("Lower (%)"), + /* @__PURE__ */ e.jsx(An, { step: "0.1", value: x.lowerPercent, disabled: B || ue !== null || ye !== null, onValueChange: (y) => st(t.pairKey, t.coefficient, "lowerPercent", y) }) + ] }), + /* @__PURE__ */ e.jsx("span", { children: i("to") }), + /* @__PURE__ */ e.jsxs("label", { children: [ + i("Upper (%)"), + /* @__PURE__ */ e.jsx(An, { step: "0.1", value: x.upperPercent, disabled: B || ue !== null || ye !== null, onValueChange: (y) => st(t.pairKey, t.coefficient, "upperPercent", y) }) + ] }), + g.error && /* @__PURE__ */ e.jsx("small", { children: i(g.error) }) + ] }), + m ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-sweep-values", children: m.values.map((y) => /* @__PURE__ */ e.jsxs( + "div", + { + className: `gl-comp-sweep-value${y.isCurrent ? " is-current" : ""}${Y[t.pairKey] === y.value ? " is-staged" : ""}`, + children: [ + /* @__PURE__ */ e.jsx( + xt, + { + title: `${y.isCurrent ? `${i("Current")} · ` : ""}${(y.value * 100).toFixed(2)}%`, + panel: y.preview.compensated, + preview: y.preview, + sourceLabel: t.source.label, + receiverLabel: t.receiver.label, + minimumSize: 150, + maximumSize: 230, + densitySmoothing: en + } + ), + /* @__PURE__ */ e.jsxs("dl", { children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Shift") }), + /* @__PURE__ */ e.jsx("dd", { children: i("{value} MAD", { value: ie(y.preview.evidence.normalizedNegativeShift ?? 0, 3) }) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Slope") }), + /* @__PURE__ */ e.jsx("dd", { children: ie(y.preview.evidence.residualSlope ?? 0, 4) }) + ] }), + u.kind === "cytof" && /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Receiver zero") }), + /* @__PURE__ */ e.jsxs("dd", { children: [ + (y.preview.compensated.zeroPile.receiver / Math.max(1, y.preview.eventCount) * 100).toFixed(1), + "%" + ] }) + ] }) + ] }), + /* @__PURE__ */ e.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: B || y.isCurrent, + onClick: () => zn(t.pairKey, y.value), + children: i(y.isCurrent ? "Installed" : Y[t.pairKey] === y.value ? "Staged" : "Use this value") + } + ) + ] + }, + `${t.pairKey}:${y.value}:${y.isCurrent}` + )) }) : /* @__PURE__ */ e.jsx("p", { children: i("Set or fast-preview the endpoints in the inspector, then run the four-value exact sweep. Panels use the same events and locked axes.") }) + ] }) + ] }, t.pairKey); + }) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-attention-section gl-comp-suggestions", children: [ + /* @__PURE__ */ e.jsx("div", { className: "gl-comp-attention-section-head", children: /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsxs("h4", { children: [ + i(Ve === "biological" ? "Conservative suggestions" : "Control-data suggestions"), + " (", + Me.items.length, + ")" + ] }), + /* @__PURE__ */ e.jsx("span", { children: i("{evaluable} evaluable of {screened} screened pairs for {population}. Inspect before flagging.", { + evaluable: Me.evaluableCount.toLocaleString(), + screened: Me.screenedCount.toLocaleString(), + population: (Q == null ? void 0 : Q.name) ?? i("All Events") + }) }) + ] }) }), + Me.items.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-attention-empty", children: i("No pair met the residual-screen evidence requirements. Manual flagging remains available.") }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-suggestion-list", children: Me.items.map((t) => { + const o = Xt(t, u.kind, Ve); + return /* @__PURE__ */ e.jsxs("article", { className: Cn.has(t.pairKey) ? "is-flagged" : void 0, children: [ + /* @__PURE__ */ e.jsxs( + "button", + { + type: "button", + onClick: () => Ce(t.pairKey), + children: [ + /* @__PURE__ */ e.jsxs("strong", { children: [ + t.source.label, + " → ", + t.receiver.label + ] }), + /* @__PURE__ */ e.jsx("em", { className: `gl-comp-suggestion-badge is-${o.category}`, children: i(o.label) }), + /* @__PURE__ */ e.jsxs("span", { children: [ + t.interaction && t.interaction !== "other" ? `${t.interaction} · ` : "", + i("{coefficient}% · shift {shift} MAD · slope {slope}", { + coefficient: (t.coefficient * 100).toFixed(1), + shift: ie(t.evidence.normalizedNegativeShift ?? 0, 3), + slope: ie(t.evidence.residualSlope ?? 0, 4) + }) + ] }) + ] + } + ), + /* @__PURE__ */ e.jsxs("label", { children: [ + /* @__PURE__ */ e.jsx( + "input", + { + type: "checkbox", + checked: Cn.has(t.pairKey), + "aria-label": i("Flag suggested {source} to {receiver} for follow-up", { + source: t.source.label, + receiver: t.receiver.label + }), + onChange: (m) => On(t.pairKey, m.currentTarget.checked) + } + ), + /* @__PURE__ */ e.jsx("span", { children: i("Follow up") }) + ] }) + ] }, t.pairKey); + }) }) + ] }) + ] }) + ] }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-attention-empty", children: i("Install a profile-derived compensation layer before curating or sweeping pairs. The embedded FCS matrix remains inspectable in the Matrix view.") }) + ] }), + Dt(), + zt() + ] + } + ) : /* @__PURE__ */ e.jsx("div", { className: "gl-tab-placeholder gl-comp-empty", children: /* @__PURE__ */ e.jsx("p", { children: i(D ? "The compensated assay is installed, but its numerical profile record is unavailable for matrix inspection." : n.instrument === "cytof" ? "No CyTOF compensation profile is installed for this sample." : "This sample has no compatible embedded compensation matrix or imported profile.") }) }), + (u || D) && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-advanced", role: "group", "aria-label": i("Advanced compensation tools"), children: [ + Bn.evidence && /* @__PURE__ */ e.jsxs("section", { id: "comp-drawer-evidence", role: "region", "aria-labelledby": "comp-drawer-evidence-button", className: "gl-comp-drawer-region", children: [ + /* @__PURE__ */ e.jsx("h3", { children: i("Matrix evidence") }), + D ? j ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ + /* @__PURE__ */ e.jsxs("dl", { className: "gl-comp-evidence-grid", children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Profile ID") }), + /* @__PURE__ */ e.jsx("dd", { children: j.profileId }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Created") }), + /* @__PURE__ */ e.jsx("dd", { children: new Date(j.createdAt).toLocaleString() }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Matrix source") }), + /* @__PURE__ */ e.jsx("dd", { children: Ca(j, i) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Orientation") }), + /* @__PURE__ */ e.jsx("dd", { children: i("Source rows → receiver columns") }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Imported dimensions") }), + /* @__PURE__ */ e.jsx("dd", { children: i("{sources} sources × {receivers} receivers", { + sources: j.scientific.matrix.sourceChannels.length, + receivers: j.scientific.matrix.receiverChannels.length + }) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Applied solve") }), + /* @__PURE__ */ e.jsx("dd", { children: i("{count} exact $PnN channels · {status}", { + count: D.includedPnns.length, + status: V.state + }) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Matrix hash") }), + /* @__PURE__ */ e.jsxs("dd", { title: j.matrixHash, children: [ + j.matrixHash.slice(0, 19), + "…" + ] }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Profile hash") }), + /* @__PURE__ */ e.jsxs("dd", { title: j.profileHash, children: [ + j.profileHash.slice(0, 19), + "…" + ] }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Provenance") }), + /* @__PURE__ */ e.jsx("dd", { children: i(((Oi = j.provenance) == null ? void 0 : Oi.sourceDescription) ?? "No additional source note supplied") }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Estimation") }), + /* @__PURE__ */ e.jsx("dd", { children: i(((Di = j.provenance) == null ? void 0 : Di.estimationMethod) ?? "Imported coefficients preserved exactly") }) + ] }) + ] }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-method-card", "aria-label": i("Installed compensation method"), children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Pipeline") }), + /* @__PURE__ */ e.jsx("strong", { children: i(j.scientific.kind === "cytof-spillover" ? "Original counts → NNLS → Compensated counts → arcsinh display" : "Original values → linear matrix inverse → Compensated values → display transform") }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("span", { children: i("Solver") }), + /* @__PURE__ */ e.jsx("strong", { children: j.scientific.solverVersion }), + /* @__PURE__ */ e.jsx("small", { children: j.scientific.solverSettings.map(({ key: t, value: o }) => `${t}=${String(o)}`).join(" · ") }) + ] }) + ] }), + Fe && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-impact", "aria-label": i("Original versus Compensated preview"), children: [ + /* @__PURE__ */ e.jsx("div", { className: "gl-comp-impact-head", children: /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("h4", { children: i("Original → Compensated impact") }), + /* @__PURE__ */ e.jsx("span", { children: i("Deterministic preview of {events} evenly spaced events across {channels} solve channels", { + events: Fe.previewEvents.toLocaleString(), + channels: D.includedPnns.length + }) }) + ] }) }), + /* @__PURE__ */ e.jsxs("dl", { children: [ + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Values changed") }), + /* @__PURE__ */ e.jsxs("dd", { children: [ + Fe.changedValues.toLocaleString(), + " / ", + Fe.comparedValues.toLocaleString(), + " (", + tn(Fe.changedValues / Fe.comparedValues, !1, 4), + ")" + ] }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Median |Δ|") }), + /* @__PURE__ */ e.jsx("dd", { children: ie(Fe.medianAbsoluteDelta, 5) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Maximum |Δ|") }), + /* @__PURE__ */ e.jsx("dd", { children: ie(Fe.maxAbsoluteDelta, 5) }) + ] }), + /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Largest median shift") }), + /* @__PURE__ */ e.jsxs("dd", { title: Fe.mostChangedChannel, children: [ + Fe.mostChangedChannel, + " · ", + ie(Fe.mostChangedChannelMedianDelta, 5) + ] }) + ] }), + D.kind === "cytof-spillover" && /* @__PURE__ */ e.jsxs("div", { children: [ + /* @__PURE__ */ e.jsx("dt", { children: i("Negative → zero") }), + /* @__PURE__ */ e.jsx("dd", { children: i("{count} preview values", { count: Fe.zeroedNegativeValues.toLocaleString() }) }) + ] }) + ] }) + ] }) + ] }) : /* @__PURE__ */ e.jsx("p", { children: i("{profile} · {method} · {count} exact $PnN channel bindings · {status}. The numerical profile record is not available in this live workspace state.", { + profile: D.profileId, + method: at, + count: D.includedPnns.length, + status: V.state + }) }) : /* @__PURE__ */ e.jsx("p", { children: i("Embedded $SPILLOVER · {channels} matched channels · {warnings} coefficient warnings.", { + channels: ee.channels.length, + warnings: Lt.length || i("no") + }) }) + ] }), + Bn.review && /* @__PURE__ */ e.jsxs("section", { id: "comp-drawer-review", role: "region", "aria-labelledby": "comp-drawer-review-button", className: "gl-comp-drawer-region", children: [ + /* @__PURE__ */ e.jsx("h3", { children: i("Review queue") }), + /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-review-section", children: [ + /* @__PURE__ */ e.jsx("h4", { children: i("Matrix integrity") }), + rt.length > 0 ? /* @__PURE__ */ e.jsx("ul", { children: rt.map((t) => /* @__PURE__ */ e.jsx("li", { children: i(t) }, t)) }) : /* @__PURE__ */ e.jsx("p", { children: i("No matrix-level items currently require review.") }) + ] }), + V.state === "ready" && u && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-review-section", children: [ + /* @__PURE__ */ e.jsx("h4", { children: i("Residual-evidence shortlist") }), + /* @__PURE__ */ e.jsx("p", { children: i("Relative ranking of {screened}{candidateSuffix} non-zero or physically plausible pairs. It combines receiver-negative population shift, robust residual slope, upper-tail departure{zeroSuffix}.{modeNote} A high rank is a prompt to inspect, not proof that a coefficient is wrong.", { + screened: Me.screenedCount.toLocaleString(), + candidateSuffix: Me.candidateCount > Me.screenedCount ? i(" of {count}", { count: Me.candidateCount.toLocaleString() }) : "", + zeroSuffix: u.kind === "cytof" ? i(", and new exact-zero pile") : "", + modeNote: i(Ve === "biological" ? " Broad positive association is excluded because biological co-expression and cell size can mimic spill." : " Positive residual association is enabled because control-data mode is active.") + }) }), + Me.items.length > 0 ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-review-candidates", children: Me.items.map((t) => /* @__PURE__ */ e.jsxs( + "button", + { + type: "button", + onClick: () => Pi(t.sourceIndex, t.receiverIndex), + children: [ + /* @__PURE__ */ e.jsxs("span", { children: [ + /* @__PURE__ */ e.jsxs("strong", { children: [ + t.source.label, + " → ", + t.receiver.label + ] }), + /* @__PURE__ */ e.jsxs("small", { children: [ + t.interaction && t.interaction !== "other" ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ + t.interaction, + " · " + ] }) : null, + i("matrix {value}%", { value: (t.coefficient * 100).toFixed(1) }) + ] }) + ] }), + /* @__PURE__ */ e.jsxs("span", { children: [ + i("shift {shift} MAD · slope {slope}", { + shift: ie(t.evidence.normalizedNegativeShift ?? 0, 3), + slope: ie(t.evidence.residualSlope ?? 0, 4) + }), + u.kind === "cytof" ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ + " ", + i("· zero Δ {value} pp", { value: `${t.evidence.receiverZeroDeltaFraction >= 0 ? "+" : ""}${(t.evidence.receiverZeroDeltaFraction * 100).toFixed(1)}` }) + ] }) : null + ] }) + ] + }, + t.pairKey + )) }) : /* @__PURE__ */ e.jsx("p", { children: i("No pair had enough source-high, source-low, and receiver-negative events for this conservative screen. Visual inspection remains available from the matrix.") }) + ] }) + ] }) + ] }), + zs && u && /* @__PURE__ */ e.jsx( + ia, + { + profileLabel: (j == null ? void 0 : j.name) ?? (me ? "SCE_spillover" : "embedded_FCS"), + installedLabel: i( + j ? "Installed matrix" : me ? "SCE spillover matrix" : "Embedded FCS matrix" + ), + installedMatrix: { + sourceChannels: u.sourceAxisKeys, + receiverChannels: u.receiverAxisKeys, + matrix: u.matrix + }, + workingMatrix: Ws, + pendingEditCount: Object.keys(Y).length, + onClose: () => mi(!1) + } + ), + _s && /* @__PURE__ */ e.jsx( + Qr, + { + sampleName: s, + populationName: (Q == null ? void 0 : Q.name) ?? i("All Events"), + filterLabel: Ci, + pairCount: wi.length, + onExport: hr, + onClose: () => pi(!1) + } + ) + ] }) + ] + } + ) }) }) }) : /* @__PURE__ */ e.jsx( + "div", + { + className: "gl-tab-panel gl-tab-fill gl-compensation-tab", + style: { display: "none" }, + "aria-hidden": "true", + "data-compensation-dormant": "true" + } + ); +} +function Ma(n, s) { + const r = n.visible !== !1, a = s.visible !== !1; + return r || a ? !1 : n.sample === s.sample && n.stateKey === s.stateKey; +} +const Aa = S.memo(Sa, Ma); +export { + Aa as CompensationTab +}; diff --git a/inst/react-app/CompensationTab-reCVsbW5.js b/inst/react-app/CompensationTab-reCVsbW5.js deleted file mode 100644 index 4d358fd..0000000 --- a/inst/react-app/CompensationTab-reCVsbW5.js +++ /dev/null @@ -1,4739 +0,0 @@ -var er = Object.defineProperty; -var nr = (n, s, r) => s in n ? er(n, s, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[s] = r; -var st = (n, s, r) => nr(n, typeof s != "symbol" ? s + "" : s, r); -import { D as Yt, r as tr, l as ir, s as sr, z as rr, u as Le, a as M, j as e, b as me, c as ne, p as en, v as Ut, d as ar, e as or, f as lr, g as cr, h as Ki, i as dr, F as ur, k as hr, m as pr, C as mr, n as fr } from "./embed-D4X-AL0o.js"; -class fe extends Error { - constructor(r, a, o = {}) { - super(a); - st(this, "code"); - st(this, "row"); - st(this, "column"); - this.name = "CompensationMatrixTableError", this.code = r, this.row = o.row, this.column = o.column; - } -} -const gr = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/; -function qt(n) { - return n.trim().normalize("NFC"); -} -function xr(n) { - const s = qt(n).toLowerCase(); - return s === "" || s === "x" || s === "row.names" || s === "channel" || s === "source"; -} -function vr(n) { - return n === "csv" ? "," : " "; -} -function br(n) { - let s = 0, r = 0, a = !1, o = !1, c = 1; - const d = () => { - if (s > 0 && r > 0) - throw new fe( - "ambiguous-delimiter", - "The matrix header mixes comma and tab delimiters. Choose CSV or TSV explicitly.", - { row: c } - ); - if (s === 0 && r === 0) - throw new fe( - "missing-delimiter", - "The matrix header must contain comma-separated or tab-separated columns.", - { row: c } - ); - return r > 0 ? "tsv" : "csv"; - }; - for (let m = 0; m < n.length; m++) { - const g = n[m]; - if (g === '"') { - o = !0, a && n[m + 1] === '"' ? m++ : a = !a; - continue; - } - if (!a) - if (g === ",") - s++, o = !0; - else if (g === " ") - r++, o = !0; - else if (g === "\r" || g === ` -`) { - if (o) return d(); - g === "\r" && n[m + 1] === ` -` && m++, c++, s = 0, r = 0; - } else /\s/.test(g) || (o = !0); - } - return d(); -} -function yr(n, s) { - const r = []; - let a = [], o = "", c = !1, d = !1, m = 1, g = 1; - const f = () => { - a.push(o), o = "", d = !1; - }, w = () => { - f(), r.push({ cells: a, row: g }), a = []; - }; - for (let k = 0; k < n.length; k++) { - const v = n[k]; - if (c) { - v === '"' ? n[k + 1] === '"' ? (o += '"', k++) : (c = !1, d = !0) : v === "\r" || v === ` -` ? (v === "\r" && n[k + 1] === ` -` && k++, o += ` -`, m++) : o += v; - continue; - } - if (d) { - if (v === s) - f(); - else if (v === "\r" || v === ` -`) - w(), v === "\r" && n[k + 1] === ` -` && k++, m++, g = m; - else if (v !== " ") - throw new fe( - "malformed-quoted-field", - "Unexpected text follows a closing quote in the compensation matrix.", - { row: m, column: a.length + 1 } - ); - continue; - } - if (v === '"') { - if (o.length !== 0) - throw new fe( - "malformed-quoted-field", - "A quoted matrix field must begin with a quote.", - { row: m, column: a.length + 1 } - ); - c = !0; - } else v === s ? f() : v === "\r" || v === ` -` ? (w(), v === "\r" && n[k + 1] === ` -` && k++, m++, g = m) : o += v; - } - if (c) - throw new fe( - "malformed-quoted-field", - "The compensation matrix contains an unclosed quoted field.", - { row: g, column: a.length + 1 } - ); - return (o.length > 0 || a.length > 0 || d) && w(), r.filter( - ({ cells: k }) => !(k.length === 1 && k[0].trim().length === 0) - ); -} -function jr(n, s, r) { - const a = n.trim(); - if (!gr.test(a)) - throw new fe( - "invalid-coefficient", - `Matrix coefficient at row ${s}, column ${r} is not a finite decimal number.`, - { row: s, column: r } - ); - const o = Number(a); - if (!Number.isFinite(o)) - throw new fe( - "invalid-coefficient", - `Matrix coefficient at row ${s}, column ${r} is outside the finite numeric range.`, - { row: s, column: r } - ); - return o; -} -function wr(n, s, r) { - return Object.freeze({ - sourceChannels: Object.freeze(Array.from(n)), - receiverChannels: Object.freeze(Array.from(s)), - matrix: Object.freeze(r.map((a) => Object.freeze(Array.from(a)))) - }); -} -function Nr(n, s = {}) { - if (typeof n != "string") - throw new fe( - "invalid-input", - "The compensation matrix contents must be text." - ); - const r = n.startsWith("\uFEFF") ? n.slice(1) : n; - if (r.trim().length === 0) - throw new fe("empty-file", "The compensation matrix file is empty."); - const a = s == null ? void 0 : s.delimiter; - if (a !== void 0 && a !== "auto" && a !== "csv" && a !== "tsv") - throw new fe( - "invalid-delimiter", - "The compensation matrix delimiter must be auto, csv, or tsv." - ); - const o = a ?? "auto", c = o === "auto" ? br(r) : o, d = yr(r, vr(c)); - if (d.length === 0) - throw new fe("empty-file", "The compensation matrix file is empty."); - const m = d[0]; - if (m.cells.length < 2) - throw new fe( - "missing-receiver-columns", - "The matrix header needs a source-channel column and at least one receiver channel.", - { row: m.row } - ); - const g = m.cells[0]; - if (!xr(g)) - throw new fe( - "missing-source-column", - "The first column must identify source channels (blank, X, row.names, channel, or source).", - { row: m.row, column: 1 } - ); - if (d.length < 2) - throw new fe( - "missing-data-rows", - "The compensation matrix does not contain any source-channel rows.", - { row: m.row + 1 } - ); - const f = m.cells.slice(1).map(qt), w = [], k = []; - for (const v of d.slice(1)) { - if (v.cells.length !== m.cells.length) - throw new fe( - "row-width", - `Matrix row ${v.row} has ${v.cells.length} columns; expected ${m.cells.length}.`, - { row: v.row } - ); - const S = qt(v.cells[0]); - if (S.length === 0) - throw new fe( - "missing-source-channel", - `Matrix row ${v.row} has no source-channel identity.`, - { row: v.row, column: 1 } - ); - w.push(S), k.push( - v.cells.slice(1).map((T, I) => jr(T, v.row, I + 2)) - ); - } - return Object.freeze({ - input: wr(w, f, k), - format: Object.freeze({ delimiter: c, sourceColumnHeader: g }) - }); -} -function Vt(n) { - const s = n.trim().normalize("NFC"), r = s.match(/^([A-Z][a-z]?)(\d{2,3})(?:Di)?(?:$|[_\s(\-])/); - if (r) - return { element: r[1], mass: Number(r[2]) }; - const a = s.match(/^(\d{2,3})([A-Z][a-z]?)(?:Di)?(?:$|[_\s(\-])/); - return a ? { element: a[2], mass: Number(a[1]) } : null; -} -function Ri(n) { - return n.map((s, r) => ({ channel: s, index: r, isotope: Vt(s) })).sort((s, r) => s.isotope && r.isotope ? s.isotope.mass - r.isotope.mass || s.isotope.element.localeCompare(r.isotope.element) || s.index - r.index : s.isotope ? -1 : r.isotope ? 1 : s.index - r.index).map(({ index: s }) => s); -} -function Cr(n) { - const s = Ri(n.sourceChannels), r = Ri(n.receiverChannels); - return { - sourceChannels: s.map((a) => n.sourceChannels[a]), - receiverChannels: r.map((a) => n.receiverChannels[a]), - matrix: s.map( - (a) => r.map((o) => n.matrix[a][o]) - ) - }; -} -function Cn(n, s) { - if (n === s) return "self"; - const r = Vt(n), a = Vt(s); - if (!r || !a) return "other"; - const o = a.mass - r.mass; - return r.element === a.element ? o === -1 ? "M-1" : o === 1 ? "M+1" : "same-element" : o === -1 ? "M-1" : o === 1 ? "M+1" : o === 16 ? "oxide (+16)" : "other"; -} -function at(n, s) { - const r = n.index(s); - if (r !== void 0) return r; - const a = n.channels.findIndex((o) => o.pnn === s); - return a < 0 ? void 0 : a; -} -function dn(n, s, r) { - if (!Number.isSafeInteger(n) || n < 0) - throw new RangeError("Compensation event count must be a non-negative safe integer."); - if (!Number.isSafeInteger(s) || s <= 0) - throw new RangeError("Compensation preview size must be a positive safe integer."); - if (r && r.length !== n) - throw new RangeError("Compensation population mask length does not match the sample."); - const a = r ? r.reduce((f, w) => f + (w ? 1 : 0), 0) : n, o = Math.min(a, s), c = new Uint32Array(o); - if (o === 0) return c; - if (!r) { - if (o === 1) return c; - for (let f = 0; f < o; f++) - c[f] = Math.floor(f * (n - 1) / (o - 1)); - return c; - } - const d = Array.from({ length: o }, (f, w) => o === 1 ? 0 : Math.floor(w * (a - 1) / (o - 1))); - let m = 0, g = 0; - for (let f = 0; f < n && g < o; f++) - r[f] && (m === d[g] && (c[g++] = f), m++); - return c; -} -function hn(n, s) { - if (n.length === 0) return 0; - const r = Math.max(0, Math.min(1, s)) * (n.length - 1), a = Math.floor(r), o = Math.ceil(r); - return a === o ? n[a] : n[a] + (n[o] - n[a]) * (r - a); -} -function ot(n) { - const s = n.filter(Number.isFinite).sort((c, d) => c - d); - if (s.length === 0) return [-1, 1]; - let r = hn(s, 2e-3), a = hn(s, 0.998); - if (!(a > r)) { - const c = Number.isFinite(r) ? r : 0, d = Math.max(1, Math.abs(c) * 0.05); - return [c - d, c + d]; - } - const o = (a - r) * 0.035; - return r -= o, a += o, [r, a]; -} -function De(n) { - if (n.length === 0) return Number.NaN; - const s = [...n].sort((r, a) => r - a); - return hn(s, 0.5); -} -function lt(n) { - if (n.length === 0) return Number.NaN; - const s = De(n), r = De(n.map((d) => Math.abs(d - s))) * 1.4826; - if (Number.isFinite(r) && r > 0) return r; - const a = n.reduce((d, m) => d + m, 0) / n.length, o = n.reduce((d, m) => d + (m - a) ** 2, 0) / Math.max(1, n.length - 1), c = Math.sqrt(o); - return Number.isFinite(c) && c > 0 ? c : 1e-12; -} -function Bt(n, s, r = 12) { - if (n.length !== s.length || n.length < r * 8) return null; - const a = Array.from({ length: n.length }, (m, g) => g).sort((m, g) => n[m] - n[g]), o = []; - for (let m = 0; m < r; m++) { - const g = Math.floor(m * a.length / r), f = Math.floor((m + 1) * a.length / r), w = a.slice(g, f); - if (w.length < 8) continue; - const k = De(w.map((S) => n[S])), v = De(w.map((S) => s[S])); - Number.isFinite(k) && Number.isFinite(v) && o.push({ x: k, y: v }); - } - const c = []; - for (let m = 0; m < o.length; m++) - for (let g = m + 1; g < o.length; g++) { - const f = o[g].x - o[m].x; - if (f === 0) continue; - const w = (o[g].y - o[m].y) / f; - Number.isFinite(w) && c.push(w); - } - const d = De(c); - return Number.isFinite(d) ? d : null; -} -function Sr(n, s) { - if (n.length !== s.length || n.length < 120) - return { excessMad: null, slopeDeltaMad: null }; - const r = Array.from({ length: n.length }, (A, K) => K).filter((A) => Number.isFinite(n[A]) && Number.isFinite(s[A])).sort((A, K) => n[A] - n[K]); - if (r.length < 120) return { excessMad: null, slopeDeltaMad: null }; - const a = Math.max(96, Math.floor(r.length * 0.8)), o = Math.min(r.length - 24, Math.floor(r.length * 0.9)), c = r.slice(0, a), d = r.slice(o); - if (c.length < 96 || d.length < 24) - return { excessMad: null, slopeDeltaMad: null }; - const m = c.map((A) => n[A]), g = c.map((A) => s[A]), f = Bt(m, g, 10); - if (f === null) return { excessMad: null, slopeDeltaMad: null }; - const w = De(c.map((A) => s[A] - f * n[A])), k = c.map((A) => s[A] - (w + f * n[A])), v = Math.max( - lt(k), - lt(g) * 0.05, - 1e-12 - ), S = d.map((A) => s[A] - (w + f * n[A])).sort((A, K) => A - K), T = hn(S, 0.75) / v, I = r.slice(Math.floor(r.length * 0.75)), $ = I.map((A) => n[A]), E = I.map((A) => s[A]), P = Bt($, E, 4), F = hn($, 0.9) - hn($, 0.1), N = P === null || !(F > 0) ? null : (P - f) * F / v; - return { - excessMad: Number.isFinite(T) ? T : null, - slopeDeltaMad: Number.isFinite(N) ? N : null - }; -} -function as(n, s, r, a, o, c) { - const d = r.length, m = Sr(r, a), g = Math.min(50, Math.max(12, Math.floor(d * 0.01))), f = (i = 0, R = 0, ge = 0) => ({ - status: "insufficient", - sourceLowEvents: i, - sourceHighEvents: R, - destinationNegativeEvents: ge, - normalizedNegativeShift: null, - residualSlope: null, - upperTailExcessMad: m.excessMad, - upperTailSlopeDeltaMad: m.slopeDeltaMad, - receiverZeroDeltaFraction: d > 0 ? (c - o) / d : 0 - }); - if (d < g * 3) return f(); - const w = [...r].sort((i, R) => i - R), k = hn(w, 0.25), v = r.flatMap((i, R) => i <= k ? [R] : []); - if (v.length < g) return f(v.length); - const S = v.map((i) => r[i]), T = De(S), I = lt(S); - let $ = r.flatMap((i, R) => i >= T + 3 * I ? [R] : []); - if ($.length < g && ($ = Array.from({ length: d }, (i, R) => R).sort((i, R) => r[R] - r[i]).slice(0, g)), $.length < g) return f(v.length, $.length); - const E = v.map((i) => a[i]), P = De(E), F = lt(E), N = P + 5 * F, A = a.flatMap((i, R) => i <= N ? [R] : []), K = new Set(A), O = v.filter((i) => K.has(i)), D = $.filter((i) => K.has(i)); - if (O.length < g || D.length < g) - return f(v.length, $.length, A.length); - const U = (De(D.map((i) => a[i])) - De(O.map((i) => a[i]))) / F, J = A.map((i) => n[i]), Z = A.map((i) => s[i]); - return { - status: "ready", - sourceLowEvents: v.length, - sourceHighEvents: $.length, - destinationNegativeEvents: A.length, - normalizedNegativeShift: Number.isFinite(U) ? U : null, - residualSlope: Bt(J, Z), - upperTailExcessMad: m.excessMad, - upperTailSlopeDeltaMad: m.slopeDeltaMad, - receiverZeroDeltaFraction: d > 0 ? (c - o) / d : 0 - }; -} -function ct(n, s, r, a, o, c) { - let d = 0, m = 0, g = 0; - for (let f = 0; f < r.length; f++) { - const w = Math.abs(r[f]) <= 1e-12, k = Math.abs(a[f]) <= 1e-12; - w && d++, k && m++, w && k && g++; - } - return { - x: n.map((f) => Math.max(o[0], Math.min(o[1], f))), - y: s.map((f) => Math.max(c[0], Math.min(c[1], f))), - zeroPile: Object.freeze({ - source: d, - receiver: m, - corner: g - }) - }; -} -function Ot(n, s, r, a = {}) { - var i; - if (n.compensatedLayerStatus().state !== "ready") - return { ready: !1, reason: "Apply compensation to compare Original and Compensated data." }; - const c = at(n, s), d = at(n, r); - if (c === void 0 || d === void 0) - return { - ready: !1, - reason: "This matrix pair is not present in the FCS file, so a data biplot cannot be drawn." - }; - if (n.fcs.nEvents === 0) - return { ready: !1, reason: "This sample contains no events." }; - const m = ((i = a.fixedEventIndices) == null ? void 0 : i.slice()) ?? dn( - n.fcs.nEvents, - a.maxEvents ?? 15e3, - a.eventMask - ); - for (const R of m) - if (R >= n.fcs.nEvents || a.eventMask && !a.eventMask[R]) - return { ready: !1, reason: "The frozen compensation event selection is no longer valid." }; - const g = n.channels[c].key, f = n.channels[d].key, w = n.originalColumnData(c), k = n.originalColumnData(d), v = n.compensatedColumnData(c), S = n.compensatedColumnData(d), T = [], I = [], $ = [], E = [], P = [], F = [], N = [], A = []; - for (const R of m) { - const ge = n.rawToDisplay(g, w[R]), _ = n.rawToDisplay(f, k[R]), j = n.rawToDisplay(g, v[R]), H = n.rawToDisplay(f, S[R]); - [ge, _, j, H].every(Number.isFinite) && (T.push(ge), I.push(_), $.push(w[R]), E.push(k[R]), P.push(j), F.push(H), N.push(v[R]), A.push(S[R])); - } - const K = ot([...T, ...P]), O = ot([...I, ...F]), D = n.channelTicks(c, [K[0], K[1]]), U = n.channelTicks(d, [O[0], O[1]]), J = ct( - T, - I, - $, - E, - K, - O - ), Z = ct( - P, - F, - N, - A, - K, - O - ); - return { - ready: !0, - preview: { - eventCount: T.length, - totalEvents: a.eventMask ? a.eligibleEventCount ?? a.eventMask.reduce((R, ge) => R + (ge ? 1 : 0), 0) : n.fcs.nEvents, - xRange: K, - yRange: O, - xTicks: D, - yTicks: U, - original: J, - compensated: Z, - evidence: as( - N, - A, - P, - F, - J.zeroPile.receiver, - Z.zeroPile.receiver - ) - } - }; -} -function Dt(n, s, r, a, o, c, d = {}) { - const m = at(n, s), g = at(n, r); - if (m === void 0 || g === void 0) - return { - ready: !1, - reason: "This matrix pair is not present in the FCS file, so a data biplot cannot be drawn." - }; - if (o.length !== a.length || c.length !== a.length) - return { ready: !1, reason: "The solved compensation preview does not match the frozen event selection." }; - const f = n.channels[m].key, w = n.channels[g].key, k = n.originalColumnData(m), v = n.originalColumnData(g), S = [], T = [], I = [], $ = [], E = [], P = [], F = [], N = []; - for (let Z = 0; Z < a.length; Z++) { - const i = a[Z]; - if (i >= n.fcs.nEvents) - return { ready: !1, reason: "The frozen compensation event selection is no longer valid." }; - const R = k[i], ge = v[i], _ = o[Z], j = c[Z], H = n.rawToDisplay(f, R), ue = n.rawToDisplay(w, ge), pn = n.rawToDisplay(f, _), Se = n.rawToDisplay(w, j); - [R, ge, _, j, H, ue, pn, Se].every(Number.isFinite) && (S.push(H), T.push(ue), I.push(R), $.push(ge), E.push(pn), P.push(Se), F.push(_), N.push(j)); - } - const A = d.xRange ?? ot([...S, ...E]), K = d.yRange ?? ot([...T, ...P]), O = n.channelTicks(m, [A[0], A[1]]), D = n.channelTicks(g, [K[0], K[1]]), U = ct(S, T, I, $, A, K), J = ct(E, P, F, N, A, K); - return { - ready: !0, - preview: { - eventCount: S.length, - totalEvents: d.totalEvents ?? n.fcs.nEvents, - xRange: A, - yRange: K, - xTicks: O, - yTicks: D, - original: U, - compensated: J, - evidence: as( - F, - N, - E, - P, - U.zeroPile.receiver, - J.zeroPile.receiver - ) - } - }; -} -const Oi = 0.5, Mr = 0.01, Er = 1e-4, kr = 0.05, Ar = 3, Tr = 1, Fr = 5; -function os(n, s) { - const r = n.evidence.normalizedNegativeShift ?? 0, a = n.evidence.residualSlope ?? 0, o = Math.max(0, n.evidence.upperTailExcessMad ?? 0), c = Math.max(0, n.evidence.upperTailSlopeDeltaMad ?? 0), d = Math.abs(n.coefficient), m = Math.max( - Er, - d * kr - ); - return { - negativeShift: Math.max(0, -r), - negativeSlope: Math.max(0, -a), - zeroDelta: s === "cytof" ? Math.max(0, n.evidence.receiverZeroDeltaFraction) : 0, - positiveShift: Math.max(0, r), - positiveSlope: Math.max(0, a), - upperTailExcess: o, - upperTailSlopeDelta: c, - hasNegativeShift: r <= -Oi, - hasNegativeSlope: a <= -m, - hasNewZeroPile: s === "cytof" && n.evidence.receiverZeroDeltaFraction >= Mr, - hasPositiveShift: r >= Oi, - hasPositiveSlope: a >= m, - hasHighTailCurve: o >= Ar && (c >= Tr || o >= Fr) - }; -} -function $r(n) { - return Number(n.hasNegativeShift) + Number(n.hasNegativeSlope) + Number(n.hasNewZeroPile) > 1 ? "multiple-overcompensation-signals" : n.hasNewZeroPile ? "new-zero-pile" : n.hasNegativeShift ? "negative-receiver-shift" : "negative-residual-slope"; -} -function Gt(n, s, r = "biological") { - const a = os(n, s), o = a.hasNegativeShift || a.hasNegativeSlope || a.hasNewZeroPile, c = a.hasPositiveShift || a.hasPositiveSlope, d = a.hasHighTailCurve || r === "control" && c; - return o && d ? { - category: "mixed-evidence", - label: "Mixed evidence · inspect", - detail: "Positive and negative residual signals disagree. Inspect the matched plots and use a suitable control before changing the coefficient.", - reason: "mixed-residual-signals", - automaticFollowup: !0 - } : o ? { - category: "overcompensation-like", - label: "Overcompensation-like", - detail: "A negative receiver shift, negative residual slope, or new NNLS zero pile is present. This is a review prompt, not an automatic coefficient verdict.", - reason: $r(a), - automaticFollowup: !0 - } : a.hasHighTailCurve ? r === "control" ? { - category: "undercompensation-like", - label: "Undercompensation-like · control", - detail: "A source-associated point or curve emerges in the upper tail. In a suitable single-stain/control sample this can support under-compensation review.", - reason: "high-tail-curve", - automaticFollowup: !0 - } : { - category: "high-tail-structure", - label: "High-tail structure · control required", - detail: "A source-associated point or curve emerges only at high expression. Spill can look this way, but biological co-expression can too.", - reason: "high-tail-curve", - automaticFollowup: n.physicalPrior > 0 - } : c ? r === "control" ? { - category: "undercompensation-like", - label: "Undercompensation-like · control", - detail: "Positive source-associated residual signal is present. This interpretation is valid only because control-data mode was selected.", - reason: Number(a.hasPositiveShift) + Number(a.hasPositiveSlope) > 1 ? "multiple-undercompensation-signals" : "positive-residual-control", - automaticFollowup: !0 - } : { - category: "positive-association-only", - label: "Positive association only · control required", - detail: "Positive association alone is not treated as spill in a biological sample; co-expression and cell size can produce the same pattern.", - reason: null, - automaticFollowup: !1 - } : n.evidence.status !== "ready" ? { - category: "insufficient", - label: "Evidence groups insufficient", - detail: "The pair remains available for visual review, but the automatic screen could not form robust comparison groups.", - reason: null, - automaticFollowup: !1 - } : { - category: "no-automatic-evidence", - label: "No automatic evidence", - detail: "This screen did not find a qualified residual pattern. Visual review and manual follow-up remain available.", - reason: null, - automaticFollowup: !1 - }; -} -function Qe(n, s) { - if (!Number.isFinite(n) || n <= 0) return 0; - const r = s.filter((o) => Number.isFinite(o) && o > 0).sort((o, c) => o - c); - if (r.length === 0) return 0; - let a = 0; - for (const o of r) - if (o <= n) a++; - else break; - return a / r.length; -} -function Ir(n, s, r = "biological") { - const a = n.map((T) => ({ - ...os(T, s), - coefficient: Math.abs(T.coefficient) - })), o = (T) => a.map((I) => typeof I[T] == "number" ? I[T] : 0), c = o("negativeShift"), d = o("negativeSlope"), m = o("zeroDelta"), g = o("positiveShift"), f = o("positiveSlope"), w = o("upperTailExcess"), k = o("upperTailSlopeDelta"), v = o("coefficient"), S = n.flatMap((T, I) => { - const $ = Gt(T, s, r); - if (!$.automaticFollowup || $.reason === null) return []; - const E = a[I], P = 0.22 * Qe(E.negativeShift, c) + 0.13 * Qe(E.negativeSlope, d) + 0.14 * Qe(E.zeroDelta, m) + (r === "control" ? 0.13 * Qe(E.positiveShift, g) : 0) + (r === "control" ? 0.08 * Qe(E.positiveSlope, f) : 0) + 0.12 * Qe(E.upperTailExcess, w) + 0.08 * Qe(E.upperTailSlopeDelta, k) + 0.05 * Qe(E.coefficient, v) + 0.05 * Math.max(0, Math.min(1, T.physicalPrior)); - return [{ - index: I, - relativePriority: P, - reason: $.reason, - category: $.category - }]; - }); - return Object.freeze(S.sort((T, I) => I.relativePriority - T.relativePriority || T.index - I.index)); -} -function Pr(n, s) { - const r = n.index(s); - if (r !== void 0) return r; - const a = n.channels.findIndex((o) => o.pnn === s); - return a < 0 ? void 0 : a; -} -function Wt(n, s) { - if (n.length === 0) return 0; - const r = Math.max(0, Math.min(1, s)) * (n.length - 1), a = Math.floor(r), o = Math.ceil(r); - return a === o ? n[a] : n[a] + (n[o] - n[a]) * (r - a); -} -function Kr(n) { - const s = n.filter(Number.isFinite).sort((c, d) => c - d); - if (s.length === 0) return [-1, 1]; - let r = Wt(s, 2e-3), a = Wt(s, 0.998); - if (!(a > r)) { - const c = Number.isFinite(r) ? r : 0, d = Math.max(1, Math.abs(c) * 0.05); - return [c - d, c + d]; - } - const o = (a - r) * 0.035; - return r -= o, a += o, [r, a]; -} -function Rr(n) { - if (n.length === 0) return "0:empty"; - let s = 2166136261; - for (const r of n) - s ^= r, s = Math.imul(s, 16777619) >>> 0; - return `${n.length}:${n[0]}:${n[n.length - 1]}:${s.toString(16)}`; -} -function Or(n, s, r = {}) { - var m; - if (n.compensatedLayerStatus().state !== "ready") - return { ready: !1, reason: "Apply compensation before comparing Uncompensated and Compensated data." }; - const o = ((m = r.fixedEventIndices) == null ? void 0 : m.slice()) ?? dn( - n.fcs.nEvents, - r.maxEvents ?? 2500, - r.eventMask - ); - for (const g of o) - if (g >= n.fcs.nEvents || r.eventMask && !r.eventMask[g]) - return { ready: !1, reason: "The frozen global-inspector event selection is no longer valid." }; - const c = /* @__PURE__ */ new Map(); - for (const g of Array.from(new Set(s))) { - const f = Pr(n, g); - if (f === void 0) continue; - const w = n.channels[f], k = n.originalColumnData(f), v = n.compensatedColumnData(f), S = new Float64Array(o.length), T = new Float64Array(o.length), I = new Float64Array(o.length), $ = new Float64Array(o.length), E = []; - for (let N = 0; N < o.length; N++) { - const A = o[N], K = k[A], O = v[A], D = n.rawToDisplay(w.key, K), U = n.rawToDisplay(w.key, O); - S[N] = K, T[N] = O, I[N] = D, $[N] = U, Number.isFinite(D) && E.push(D), Number.isFinite(U) && E.push(U); - } - const P = Kr(E), F = Object.freeze({ - key: w.key, - pnn: w.pnn, - range: P, - ticks: n.channelTicks(f, [P[0], P[1]]), - originalRaw: S, - compensatedRaw: T, - originalDisplay: I, - compensatedDisplay: $ - }); - c.set(g, F), c.set(w.key, F), c.set(w.pnn, F); - } - const d = r.eventMask ? r.eligibleEventCount ?? r.eventMask.reduce((g, f) => g + (f ? 1 : 0), 0) : n.fcs.nEvents; - return { - ready: !0, - dataset: Object.freeze({ - eventIndices: o, - eventSignature: Rr(o), - eligibleEventCount: d, - channels: c - }) - }; -} -function Di(n, s, r, a, o, c, d) { - const m = [], g = []; - let f = 0, w = 0, k = 0; - for (const v of o) { - m.push(Math.max(c[0], Math.min(c[1], n[v]))), g.push(Math.max(d[0], Math.min(d[1], s[v]))); - const S = Math.abs(r[v]) <= 1e-12, T = Math.abs(a[v]) <= 1e-12; - S && f++, T && w++, S && T && k++; - } - return { - x: m, - y: g, - zeroPile: Object.freeze({ source: f, receiver: w, corner: k }) - }; -} -function ls(n, s, r) { - const a = n.channels.get(s), o = n.channels.get(r); - if (!a || !o) - return { ready: !1, reason: "One or both channels are absent from the frozen global-inspector dataset." }; - const c = []; - for (let d = 0; d < n.eventIndices.length; d++) - [ - a.originalDisplay[d], - o.originalDisplay[d], - a.compensatedDisplay[d], - o.compensatedDisplay[d] - ].every(Number.isFinite) && c.push(d); - return { - ready: !0, - preview: Object.freeze({ - eventCount: c.length, - totalEvents: n.eligibleEventCount, - eventSignature: n.eventSignature, - xRange: a.range, - yRange: o.range, - xTicks: a.ticks, - yTicks: o.ticks, - original: Di( - a.originalDisplay, - o.originalDisplay, - a.originalRaw, - o.originalRaw, - c, - a.range, - o.range - ), - compensated: Di( - a.compensatedDisplay, - o.compensatedDisplay, - a.compensatedRaw, - o.compensatedRaw, - c, - a.range, - o.range - ) - }) - }; -} -function Li(n, s, r, a, o) { - const c = Math.max(1, Math.min(24, Math.round(o) || 3)), d = 256, m = c, g = d + 2 * m, f = new Float64Array(g * g), w = Math.max(1e-12, s[1] - s[0]), k = Math.max(1e-12, r[1] - r[0]); - for (let E = 0; E < n.x.length; E++) { - const P = Math.max(0, Math.min( - g - 1, - Math.floor((n.x[E] - s[0]) / w * d) + m - )), F = Math.max(0, Math.min( - g - 1, - Math.floor((n.y[E] - r[0]) / k * d) + m - )); - f[F * g + P]++; - } - const v = new Float64Array(g * g), S = (c * 2 + 1) ** 2, T = g + 1, I = new Float64Array(T * T); - for (let E = 0; E < g; E++) { - let P = 0; - for (let F = 0; F < g; F++) - P += f[E * g + F], I[(E + 1) * T + F + 1] = I[E * T + F + 1] + P; - } - for (let E = c; E < g - c; E++) { - const P = E - c, F = E + c + 1; - for (let N = c; N < g - c; N++) { - const A = N - c, K = N + c + 1, O = I[F * T + K] - I[P * T + K] - I[F * T + A] + I[P * T + A]; - v[E * g + N] = O / S; - } - } - const $ = []; - for (let E = m; E < m + d; E++) - for (let P = m; P < m + d; P++) { - const F = v[E * g + P]; - F > 0 && $.push(F); - } - return $.sort((E, P) => E - P), $.length === 0 ? 1 : Math.max(1e-12, Wt($, a)); -} -function Xt(n, s) { - const r = Math.max(1, Math.min(10, Number.isFinite(n) ? n : 6)), a = Math.max(1, (Number.isFinite(s) ? s : 220) - 50); - return Math.max(1, Math.min(24, r * 170 / a)); -} -function Jt(n, s = 0.95, r = 3, a = Yt) { - const o = Math.max( - Li(n.original, n.xRange, n.yRange, s, r), - Li(n.compensated, n.xRange, n.yRange, s, r) - ); - return tr(o, a); -} -function dt(n, s) { - const r = s.size / 220, a = Math.sqrt(r), o = Math.max(7, Math.min(11, 10 * a)), c = 20, d = Math.ceil(c + o + 4); - ir().renderMiniPlot(n, { - plot_size: s.size, - canvas_scale: s.canvasScale ?? 3, - display_mode: "pseudocolor", - x: s.panel.x, - y: s.panel.y, - x_range: s.preview.xRange, - y_range: s.preview.yRange, - x_is_logicle: !!s.preview.xTicks, - x_logicle_ticks: s.preview.xTicks ?? null, - y_is_logicle: !!s.preview.yTicks, - y_logicle_ticks: s.preview.yTicks ?? null, - x_label: s.sourceLabel, - y_label: s.receiverLabel, - title: s.title, - point_size: Math.max(0.55, Math.min(1.2, 1.15 * r)), - point_alpha: s.pointAlpha, - density_clip_quantile: 0.95, - density_color_power: s.densityColorPower, - density_color_ceiling: s.densityColorCeiling, - density_smoothing: s.densitySmoothingRadius, - x_axis_label_offset: 24, - y_axis_label_offset: c, - axis_tick_size: 3, - axis_outer_tick_size: 0, - plot_margins: { top: 20, right: 2, bottom: 30, left: d }, - font_sizes: { - tick: Math.max(6.5, Math.min(10, 9 * a)), - axis_label: o, - title: Math.max(7.5, Math.min(12, 11 * a)), - gate_label: Math.max(6.5, Math.min(10, 9 * a)) - } - }); -} -const un = "http://www.w3.org/2000/svg", Ln = 6, En = 1123, ut = 794; -function cs(n) { - return Math.ceil(Math.max(0, Math.floor(n)) / Ln); -} -function zi(n) { - return n.trim().replace(/[^a-z0-9._-]+/gi, "-").replace(/^-+|-+$/g, "").slice(0, 80) || "sample"; -} -function ds(n, s) { - return `gatelab-compensation-${zi(n.replace(/\.[^.]+$/, ""))}-${zi(s)}`; -} -function Zt(n, s, r, a) { - const o = ds(n, s); - return r === "pdf" || a <= 1 ? `${o}.${r}` : `${o}-${r}-pages.zip`; -} -function Sn(n, s, r, a, o = {}) { - const c = document.createElementNS(un, "text"); - return c.setAttribute("x", String(r)), c.setAttribute("y", String(a)), c.setAttribute("font-family", "Arial, Helvetica, sans-serif"), c.setAttribute("font-size", String(o.size ?? 10)), c.setAttribute("font-weight", String(o.weight ?? 400)), c.setAttribute("fill", o.fill ?? "#253247"), o.anchor && c.setAttribute("text-anchor", o.anchor), c.textContent = s, n.appendChild(c), c; -} -function _i(n, s) { - return n.length <= s ? n : `${n.slice(0, Math.max(1, s - 1))}…`; -} -function Ui(n, s, r, a, o, c, d, m, g, f, w) { - const k = document.createElement("div"); - dt(k, { - title: a === "original" ? "Original" : "Compensated", - panel: r[a], - preview: r, - sourceLabel: s.sourceLabel, - receiverLabel: s.receiverLabel, - size: d, - densityColorCeiling: g, - densitySmoothingRadius: m, - densityColorPower: f, - pointAlpha: w, - canvasScale: 300 / 96 - }); - const v = k.querySelector("canvas"), S = k.querySelector("svg"); - if (!v || !S) throw new Error("GateLab could not render a compensation export panel."); - const T = document.createElementNS(un, "g"); - T.setAttribute("transform", `translate(${o},${c})`); - const I = document.createElementNS(un, "image"); - I.setAttribute("x", "0"), I.setAttribute("y", "0"), I.setAttribute("width", String(d)), I.setAttribute("height", String(d)), I.setAttribute("href", v.toDataURL("image/png")), T.appendChild(I), T.appendChild(S.cloneNode(!0)), n.appendChild(T); -} -function qi(n, s, r, a) { - const o = document.createElementNS(un, "svg"); - o.setAttribute("xmlns", un), o.setAttribute("width", String(En)), o.setAttribute("height", String(ut)), o.setAttribute("viewBox", `0 0 ${En} ${ut}`); - const c = document.createElementNS(un, "rect"); - c.setAttribute("width", "100%"), c.setAttribute("height", "100%"), c.setAttribute("fill", "#ffffff"), o.appendChild(c), Sn(o, "GateLab compensation comparison", 28, 23, { size: 15, weight: 700 }), Sn( - o, - _i(`${s.sampleName} · ${s.populationName} · ${s.profileName} · ${s.filterLabel}`, 150), - 28, - 41, - { size: 9, fill: "#5f6d80" } - ), Sn(o, `Page ${r + 1} of ${a}`, En - 28, 23, { - size: 9, - fill: "#5f6d80", - anchor: "end" - }); - const d = 28, m = 18, g = 53, f = 771, w = (En - d * 2 - m) / 2, k = (f - g) / 3, v = 204, S = 12, T = v * 2 + S; - return n.forEach((I, $) => { - const E = I.buildPreview(), P = Xt(s.densitySmoothing, v), F = Jt( - E, - 0.95, - P, - s.densityColorPower - ), N = $ % 2, A = Math.floor($ / 2), K = d + N * (w + m), O = g + A * k, D = K + (w - T) / 2, U = O + 25, J = I.relationship && I.relationship !== "other" ? ` · ${I.relationship}` : ""; - if (Sn( - o, - _i(`${I.sourceLabel} → ${I.receiverLabel}`, 58), - K + 5, - O + 14, - { size: 10.5, weight: 700 } - ), Sn( - o, - `matrix ${(I.coefficient * 100).toFixed(1)}%${J}`, - K + w - 5, - O + 14, - { size: 8.5, fill: "#5f6d80", anchor: "end" } - ), Ui(o, I, E, "original", D, U, v, P, F, s.densityColorPower, s.pointAlpha), Ui(o, I, E, "compensated", D + v + S, U, v, P, F, s.densityColorPower, s.pointAlpha), A < 2) { - const Z = document.createElementNS(un, "line"); - Z.setAttribute("x1", String(K)), Z.setAttribute("x2", String(K + w)), Z.setAttribute("y1", String(O + k - 3)), Z.setAttribute("y2", String(O + k - 3)), Z.setAttribute("stroke", "#e6eaf0"), Z.setAttribute("stroke-width", "1"), o.appendChild(Z); - } - }), Sn( - o, - "Paired panels use the same frozen events, axes, transform, density scale, and off-scale edge piling.", - 28, - 786, - { size: 8, fill: "#718096" } - ), o; -} -function Vi(n) { - return ` -${new XMLSerializer().serializeToString(n)}`; -} -async function Bi(n, s = 300) { - const r = URL.createObjectURL(new Blob([n], { type: "image/svg+xml" })); - try { - const a = await new Promise((m, g) => { - const f = new Image(); - f.onload = () => m(f), f.onerror = () => g(new Error("GateLab could not rasterize the compensation export page.")), f.src = r; - }), o = Math.max(1, s / 96), c = document.createElement("canvas"); - c.width = Math.round(En * o), c.height = Math.round(ut * o); - const d = c.getContext("2d"); - if (!d) throw new Error("Canvas export is unavailable in this browser."); - return d.fillStyle = "#ffffff", d.fillRect(0, 0, c.width, c.height), d.scale(o, o), d.drawImage(a, 0, 0, En, ut), await new Promise((m, g) => { - c.toBlob((f) => f ? m(f) : g(new Error("GateLab could not encode the PNG export.")), "image/png"); - }); - } finally { - URL.revokeObjectURL(r); - } -} -function Gi(n, s) { - const r = URL.createObjectURL(n), a = document.createElement("a"); - a.href = r, a.download = s, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(r), 1e3); -} -function Dr(n, s, r, a) { - const o = Math.max(2, String(r).length); - return `${n}-page-${String(s + 1).padStart(o, "0")}.${a}`; -} -async function Lr(n, s, r, a) { - const o = cs(n.length); - if (o === 0) throw new Error("No compensation pairs are available to export."); - const c = ds(s.sampleName, s.populationName); - if (r === "pdf") { - const { jsPDF: f } = await import("./jspdf.es.min-zePAD3OY.js").then((S) => S.j), w = new f({ orientation: "landscape", unit: "pt", format: "a4", compress: !0 }), k = w.internal.pageSize.getWidth(), v = w.internal.pageSize.getHeight(); - for (let S = 0; S < o; S++) { - S > 0 && w.addPage("a4", "landscape"); - const T = n.slice( - S * Ln, - (S + 1) * Ln - ), I = Vi(qi(T, s, S, o)), $ = await Bi(I), E = await new Promise((P, F) => { - const N = new FileReader(); - N.onload = () => P(String(N.result)), N.onerror = () => F(N.error ?? new Error("GateLab could not read an export page.")), N.readAsDataURL($); - }); - w.addImage(E, "PNG", 0, 0, k, v, void 0, "FAST"), a == null || a({ completedPages: S + 1, totalPages: o }), await new Promise((P) => setTimeout(P, 0)); - } - w.save(Zt(s.sampleName, s.populationName, r, o)); - return; - } - const d = {}; - let m = null; - for (let f = 0; f < o; f++) { - const w = n.slice( - f * Ln, - (f + 1) * Ln - ), k = Vi(qi(w, s, f, o)), v = Dr(c, f, o, r); - if (r === "svg") { - const S = sr(k); - d[v] = S, o === 1 && (m = new Blob([S], { type: "image/svg+xml" })); - } else { - const S = await Bi(k), T = new Uint8Array(await S.arrayBuffer()); - d[v] = T, o === 1 && (m = S); - } - a == null || a({ completedPages: f + 1, totalPages: o }), await new Promise((S) => setTimeout(S, 0)); - } - const g = Zt( - s.sampleName, - s.populationName, - r, - o - ); - Gi(o === 1 && m ? m : new Blob([rr(d, { level: 6 })], { type: "application/zip" }), g); -} -const zr = [ - { format: "pdf", title: "PDF", detail: "One multipage A4 landscape document." }, - { format: "png", title: "PNG", detail: "300 DPI numbered pages; multiple pages download as a ZIP." }, - { format: "svg", title: "SVG", detail: "Vector text and axes with embedded high-resolution density layers; multiple pages download as a ZIP." } -]; -function _r({ - sampleName: n, - populationName: s, - filterLabel: r, - pairCount: a, - onExport: o, - onClose: c -}) { - const { t: d } = Le(), [m, g] = M.useState("pdf"), [f, w] = M.useState(null), [k, v] = M.useState(null), S = cs(a), T = f !== null && f.completedPages < f.totalPages, I = Zt(n, s, m, S), $ = async () => { - v(null), w({ completedPages: 0, totalPages: S }); - try { - await o(m, w), c(); - } catch (P) { - w(null), v(P instanceof Error ? P.message : String(P)); - } - }, E = (P) => { - P.key === "Escape" && !T && c(); - }; - return /* @__PURE__ */ e.jsx("div", { className: "gl-modal-backdrop", onKeyDown: E, children: /* @__PURE__ */ e.jsxs( - "div", - { - className: "gl-modal gl-comp-export-modal gl-comp-comparison-export-modal", - role: "dialog", - "aria-modal": "true", - "aria-labelledby": "comp-comparison-export-title", - children: [ - /* @__PURE__ */ e.jsx("div", { className: "gl-modal-title", id: "comp-comparison-export-title", children: d("Export compensation comparison") }), - /* @__PURE__ */ e.jsx("p", { className: "gl-comp-export-intro", children: d("Export the currently filtered channel pairs as clean paired Original and Compensated biplots. Every pair retains the same frozen events, axes, transform, density scale, and edge piling in both panels.") }), - /* @__PURE__ */ e.jsxs("fieldset", { className: "gl-comp-export-versions gl-comp-comparison-export-formats", children: [ - /* @__PURE__ */ e.jsx("legend", { children: d("Format") }), - zr.map((P) => /* @__PURE__ */ e.jsxs("label", { children: [ - /* @__PURE__ */ e.jsx( - "input", - { - type: "radio", - name: "compensation-comparison-export-format", - value: P.format, - checked: m === P.format, - disabled: T, - onChange: () => g(P.format) - } - ), - /* @__PURE__ */ e.jsxs("span", { children: [ - /* @__PURE__ */ e.jsx("strong", { children: P.title }), - /* @__PURE__ */ e.jsx("small", { children: d(P.detail) }) - ] }) - ] }, P.format)) - ] }), - /* @__PURE__ */ e.jsxs("dl", { className: "gl-comp-export-summary gl-comp-comparison-export-summary", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: d("File") }), - /* @__PURE__ */ e.jsx("dd", { title: I, children: I }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: d("Scope") }), - /* @__PURE__ */ e.jsx("dd", { children: d(a === 1 ? "{count} filtered pair · both assays" : "{count} filtered pairs · both assays", { count: a.toLocaleString() }) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: d("Pages") }), - /* @__PURE__ */ e.jsx("dd", { children: d(S === 1 ? "{count} A4 landscape page · six pairs per page" : "{count} A4 landscape pages · six pairs per page", { count: S.toLocaleString() }) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: d("Population") }), - /* @__PURE__ */ e.jsx("dd", { title: s, children: s }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: d("Filter") }), - /* @__PURE__ */ e.jsx("dd", { title: r, children: r }) - ] }) - ] }), - f && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-comparison-export-progress", role: "status", "aria-live": "polite", children: [ - /* @__PURE__ */ e.jsx("progress", { max: Math.max(1, f.totalPages), value: f.completedPages }), - /* @__PURE__ */ e.jsx("span", { children: d("Rendering page {current} of {total}", { current: Math.min(f.completedPages + 1, f.totalPages), total: f.totalPages }) }) - ] }), - k && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-warning", role: "alert", children: d(k) }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-modal-actions", children: [ - /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-btn-ghost", disabled: T, onClick: c, children: d("Cancel") }), - /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-btn", disabled: T || S === 0, onClick: () => void $(), children: T ? d("Rendering…") : d("Download {format}", { format: m.toUpperCase() }) }) - ] }) - ] - } - ) }); -} -function Wi(n) { - return `"${n.replaceAll('"', '""')}"`; -} -function Zi(n, s) { - if (!Array.isArray(n) || n.length === 0) - throw new Error(`The ${s} channel axis is empty.`); - const r = n.map((a, o) => { - if (typeof a != "string" || a.trim().length === 0) - throw new Error(`The ${s} channel at position ${o + 1} is blank or invalid.`); - return a.trim().normalize("NFC"); - }); - if (new Set(r).size !== r.length) - throw new Error(`The ${s} channel axis contains duplicate identities.`); - return r; -} -function Ur(n) { - const s = Zi(n.sourceChannels, "source"), r = Zi(n.receiverChannels, "receiver"); - if (!Array.isArray(n.matrix) || n.matrix.length !== s.length) - throw new Error("The spill matrix row count does not match its source channel axis."); - const a = [ - ["channel", ...r].map(Wi).join(",") - ]; - return n.matrix.forEach((o, c) => { - if (!Array.isArray(o) || o.length !== r.length) - throw new Error( - `Spill matrix row ${c + 1} does not match the receiver channel axis.` - ); - const d = o.map((m, g) => { - if (typeof m != "number" || !Number.isFinite(m)) - throw new Error( - `Spill coefficient ${s[c]} → ${r[g]} is not finite.` - ); - return Object.is(m, -0) ? "0" : String(m); - }); - a.push([Wi(s[c]), ...d].join(",")); - }), `${a.join(` -`)} -`; -} -function qr(n, s = "installed") { - return `${n.replace(/\.(?:csv|tsv|txt)$/i, "").normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^A-Za-z0-9._-]+/g, "_").replace(/_+/g, "_").replace(/^[._-]+|[._-]+$/g, "").slice(0, 90) || "gatelab"}${s === "working" ? "_working" : ""}_spill_matrix.csv`; -} -function Vr(n) { - return [ - "spill <- as.matrix(read.csv(", - ` "${n.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}",`, - " row.names = 1,", - " check.names = FALSE,", - ' fileEncoding = "UTF-8"', - "))", - 'storage.mode(spill) <- "double"' - ].join(` -`); -} -function Br({ - profileLabel: n, - installedLabel: s, - installedMatrix: r, - workingMatrix: a = null, - pendingEditCount: o = 0, - onClose: c -}) { - const { t: d } = Le(), [m, g] = M.useState("installed"), [f, w] = M.useState(null), k = m === "working" && a ? a : r, v = qr(n, m), S = M.useMemo( - () => Vr(v), - [v] - ), T = () => { - w(null); - try { - const E = Ur(k), P = URL.createObjectURL(new Blob([E], { type: "text/csv;charset=utf-8" })), F = document.createElement("a"); - F.href = P, F.download = v, document.body.appendChild(F), F.click(), F.remove(), setTimeout(() => URL.revokeObjectURL(P), 1e3); - } catch (E) { - w(E instanceof Error ? E.message : String(E)); - } - }, I = async () => { - var E; - if (!((E = navigator.clipboard) != null && E.writeText)) { - w("Clipboard access is unavailable; select the R code below and copy it manually."); - return; - } - try { - await navigator.clipboard.writeText(S), w("R import code copied."); - } catch { - w("Clipboard access was denied; select the R code below and copy it manually."); - } - }, $ = (E) => { - E.key === "Escape" && c(); - }; - return /* @__PURE__ */ e.jsx("div", { className: "gl-modal-backdrop", onKeyDown: $, children: /* @__PURE__ */ e.jsxs( - "div", - { - className: "gl-modal gl-comp-export-modal", - role: "dialog", - "aria-modal": "true", - "aria-labelledby": "comp-export-title", - children: [ - /* @__PURE__ */ e.jsx("div", { className: "gl-modal-title", id: "comp-export-title", children: d("Export spill matrix") }), - /* @__PURE__ */ e.jsx("p", { className: "gl-comp-export-intro", children: d("Coefficients are exported as exact fractions, not the rounded percentages shown in the matrix. Source channels are rows and receiver channels are columns. The CSV can be imported by GateLab or base R.") }), - a && o > 0 && /* @__PURE__ */ e.jsxs("fieldset", { className: "gl-comp-export-versions", children: [ - /* @__PURE__ */ e.jsx("legend", { children: d("Matrix version") }), - /* @__PURE__ */ e.jsxs("label", { children: [ - /* @__PURE__ */ e.jsx( - "input", - { - type: "radio", - name: "compensation-export-version", - value: "installed", - checked: m === "installed", - onChange: () => g("installed") - } - ), - /* @__PURE__ */ e.jsxs("span", { children: [ - /* @__PURE__ */ e.jsx("strong", { children: s }), - /* @__PURE__ */ e.jsx("small", { children: d("Current applied scientific record") }) - ] }) - ] }), - /* @__PURE__ */ e.jsxs("label", { children: [ - /* @__PURE__ */ e.jsx( - "input", - { - type: "radio", - name: "compensation-export-version", - value: "working", - checked: m === "working", - onChange: () => g("working") - } - ), - /* @__PURE__ */ e.jsxs("span", { children: [ - /* @__PURE__ */ e.jsx("strong", { children: d("Working draft") }), - /* @__PURE__ */ e.jsx("small", { children: d("{count} pending edits; not yet applied", { count: o }) }) - ] }) - ] }) - ] }), - /* @__PURE__ */ e.jsxs("dl", { className: "gl-comp-export-summary", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: d("File") }), - /* @__PURE__ */ e.jsx("dd", { children: v }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: d("Dimensions") }), - /* @__PURE__ */ e.jsx("dd", { children: d("{sources} sources × {receivers} receivers", { sources: k.sourceChannels.length, receivers: k.receiverChannels.length }) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: d("Units") }), - /* @__PURE__ */ e.jsx("dd", { children: d("Fractions (2.9% is written as 0.029)") }) - ] }) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-export-r-head", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("strong", { children: d("Import in R") }), - /* @__PURE__ */ e.jsx("span", { children: d("Run after placing the CSV in the R working directory.") }) - ] }), - /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => void I(), children: d("Copy R code") }) - ] }), - /* @__PURE__ */ e.jsx("pre", { className: "gl-comp-export-code", children: /* @__PURE__ */ e.jsx("code", { children: S }) }), - f && /* @__PURE__ */ e.jsx("div", { className: f.includes("copied") ? "gl-comp-status" : "gl-comp-warning", role: "status", children: f }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-modal-actions", children: [ - /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-btn-ghost", onClick: c, children: d("Cancel") }), - /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-btn", onClick: T, children: d("Download CSV") }) - ] }) - ] - } - ) }); -} -function Mn({ - value: n, - onValueChange: s, - scrubStep: r, - className: a = "", - disabled: o, - min: c, - max: d, - step: m, - title: g, - onPointerDown: f, - onPointerMove: w, - onPointerUp: k, - onPointerCancel: v, - onLostPointerCapture: S, - ...T -}) { - const { t: I } = Le(), $ = M.useRef(null), [E, P] = M.useState(!1), F = (N) => { - var A, K, O; - ((A = $.current) == null ? void 0 : A.pointerId) === N.pointerId && ($.current = null, P(!1), (O = (K = N.currentTarget).hasPointerCapture) != null && O.call(K, N.pointerId) && N.currentTarget.releasePointerCapture(N.pointerId)); - }; - return /* @__PURE__ */ e.jsx( - "input", - { - ...T, - type: "number", - className: `gl-scrubbable-number${E ? " is-scrubbing" : ""}${a ? ` ${a}` : ""}`, - value: n, - disabled: o, - min: c, - max: d, - step: m, - title: g ?? I("Type a value, use the arrows, or drag vertically to adjust"), - onChange: (N) => s(N.currentTarget.value), - onPointerDown: (N) => { - var J, Z; - if (f == null || f(N), N.defaultPrevented || o || N.button !== 0) return; - const A = N.currentTarget.getBoundingClientRect(); - if (N.clientX >= A.right - 18) return; - const K = Number(n), O = (r ?? Number(m)) || 0.1; - if (!Number.isFinite(K) || !(O > 0)) return; - const D = String(O), U = D.includes("e-") ? Number(D.split("e-")[1]) : D.includes(".") ? D.split(".")[1].length : 0; - $.current = { - pointerId: N.pointerId, - startY: N.clientY, - startValue: K, - step: O, - decimals: U, - lastSteps: 0 - }, (Z = (J = N.currentTarget).setPointerCapture) == null || Z.call(J, N.pointerId); - }, - onPointerMove: (N) => { - w == null || w(N); - const A = $.current; - if (!A || A.pointerId !== N.pointerId) return; - const K = A.startY - N.clientY; - if (Math.abs(K) < 3) return; - const O = K > 0 ? Math.floor(K / 4) : Math.ceil(K / 4); - if (O === A.lastSteps) return; - let D = A.startValue + O * A.step; - const U = c === void 0 ? Number.NEGATIVE_INFINITY : Number(c), J = d === void 0 ? Number.POSITIVE_INFINITY : Number(d); - Number.isFinite(U) && (D = Math.max(U, D)), Number.isFinite(J) && (D = Math.min(J, D)), $.current = { ...A, lastSteps: O }, P(!0), s(D.toFixed(Math.min(10, A.decimals))), N.preventDefault(); - }, - onPointerUp: (N) => { - k == null || k(N), F(N); - }, - onPointerCancel: (N) => { - v == null || v(N), F(N); - }, - onLostPointerCapture: (N) => { - var A; - S == null || S(N), ((A = $.current) == null ? void 0 : A.pointerId) === N.pointerId && ($.current = null, P(!1)); - } - } - ); -} -const Qt = M.createContext(Yt), ei = M.createContext(0.85), Hi = "", rt = []; -let Lt = !1; -function Gr(n) { - const s = { cancelled: !1, run: n }; - rt.push(s); - const r = () => { - if (Lt) return; - Lt = !0; - const a = () => { - Lt = !1; - let c = rt.shift(); - for (; c != null && c.cancelled; ) c = rt.shift(); - c == null || c.run(), rt.length > 0 && r(); - }, o = window; - typeof o.requestIdleCallback == "function" ? o.requestIdleCallback(a, { timeout: 50 }) : typeof requestAnimationFrame == "function" ? requestAnimationFrame(a) : setTimeout(a, 0); - }; - return r(), () => { - s.cancelled = !0; - }; -} -function ht({ - title: n, - panel: s, - preview: r, - sourceLabel: a, - receiverLabel: o, - minimumSize: c = 210, - maximumSize: d = 420, - densityColorCeiling: m, - densitySmoothing: g, - showZeroPile: f = !0 -}) { - const { t: w } = Le(), k = M.useContext(Qt), v = M.useContext(ei), S = M.useRef(null); - M.useEffect(() => { - const $ = S.current; - if (!$) return; - let E = null, P = 0; - const F = () => { - var U; - E = null; - const K = ((U = $.parentElement) == null ? void 0 : U.clientWidth) ?? 230, O = Math.max(c, Math.min(d, Math.floor(K))); - if (O === P && $.childElementCount > 0) return; - P = O; - const D = Xt(g, O); - dt($, { - title: n, - panel: s, - preview: r, - sourceLabel: a, - receiverLabel: o, - size: O, - densityColorCeiling: m ?? Jt( - r, - 0.95, - D, - k - ), - densitySmoothingRadius: D, - densityColorPower: k, - pointAlpha: v - }); - }, N = () => { - E !== null && cancelAnimationFrame(E), E = requestAnimationFrame(F); - }; - N(); - const A = typeof ResizeObserver > "u" ? null : new ResizeObserver(N); - return A == null || A.observe($.parentElement ?? $), () => { - A == null || A.disconnect(), E !== null && cancelAnimationFrame(E); - }; - }, [m, k, g, d, c, s, v, r, o, a, n]); - const T = ($) => r.eventCount > 0 ? `${($ / r.eventCount * 100).toFixed(1)}%` : "0.0%", I = s.zeroPile.source > 0 || s.zeroPile.receiver > 0 || s.zeroPile.corner > 0; - return /* @__PURE__ */ e.jsxs("figure", { className: "gl-comp-biplot", "aria-label": w("{title} density biplot; {source} on x, {receiver} on y", { - title: n, - source: a, - receiver: o - }), children: [ - /* @__PURE__ */ e.jsx("div", { ref: S, className: "gl-comp-biplot-surface" }), - f && I && /* @__PURE__ */ e.jsx("figcaption", { className: "gl-comp-zero-pile", children: w("Exact zero · source {source} · receiver {receiver} · both {both}", { - source: T(s.zeroPile.source), - receiver: T(s.zeroPile.receiver), - both: T(s.zeroPile.corner) - }) }) - ] }); -} -function Wr({ - title: n, - preview: s, - sourceLabel: r, - receiverLabel: a, - minimumSize: o, - maximumSize: c, - densityColorCeiling: d, - densitySmoothing: m -}) { - const { t: g } = Le(), f = M.useContext(Qt), w = M.useContext(ei), k = M.useRef(null); - return M.useEffect(() => { - const v = k.current; - if (!v) return; - let S = null, T = 0; - const I = () => { - var J; - S = null; - const P = ((J = v.parentElement) == null ? void 0 : J.clientWidth) ?? o, F = Math.max(o, Math.min(c, Math.floor(P))); - if (F === T && v.dataset.cacheReady === "true") return; - T = F, v.dataset.cacheReady = "false"; - const N = Xt(m, F), A = d ?? Jt( - s, - 0.95, - N, - f - ); - dt(v, { - title: n, - panel: s.original, - preview: s, - sourceLabel: r, - receiverLabel: a, - size: F, - densityColorCeiling: A, - densitySmoothingRadius: N, - densityColorPower: f, - pointAlpha: w, - canvasScale: 2 - }); - const K = v.querySelector("canvas"), O = v.querySelector("svg"), D = document.createElement("div"); - dt(D, { - title: n, - panel: s.compensated, - preview: s, - sourceLabel: r, - receiverLabel: a, - size: F, - densityColorCeiling: A, - densitySmoothingRadius: N, - densityColorPower: f, - pointAlpha: w, - canvasScale: 2 - }); - const U = D.querySelector("canvas"); - !K || !U || !O || (K.classList.add("gl-comp-cached-canvas", "is-original"), K.dataset.assayLayer = "original", U.classList.add("gl-comp-cached-canvas", "is-compensated"), U.dataset.assayLayer = "compensated", v.insertBefore(U, O), v.dataset.cacheReady = "true"); - }, $ = () => { - S == null || S(), S = Gr(I); - }; - $(); - const E = typeof ResizeObserver > "u" ? null : new ResizeObserver($); - return E == null || E.observe(v.parentElement ?? v), () => { - E == null || E.disconnect(), S == null || S(); - }; - }, [d, f, m, c, o, w, s, a, r, n]), /* @__PURE__ */ e.jsx( - "figure", - { - className: "gl-comp-biplot", - "aria-label": g("Cached uncompensated and compensated density biplot; {source} on x, {receiver} on y", { - source: r, - receiver: a - }), - children: /* @__PURE__ */ e.jsx( - "div", - { - ref: k, - className: "gl-comp-biplot-surface gl-comp-cached-biplot", - "data-cache-mode": "dual-canvas" - } - ) - } - ); -} -function Yi({ - preview: n, - sourceLabel: s, - receiverLabel: r, - kind: a, - densitySmoothing: o, - compact: c = !1, - compensatedTitle: d = "Compensated" -}) { - const { t: m } = Le(), g = n.eventCount > 0 ? n.original.zeroPile.receiver / n.eventCount * 100 : 0, f = n.eventCount > 0 ? n.compensated.zeroPile.receiver / n.eventCount * 100 : 0, w = f - g; - return /* @__PURE__ */ e.jsxs("div", { className: `gl-comp-biplot-comparison${c ? " is-compact" : ""}`, children: [ - !c && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-biplot-note", children: m("Same {events} events{sampled} · locked axes · off-scale events piled at edges · colour clipped at the 95th percentile of occupied density bins", { - events: n.eventCount.toLocaleString(), - sampled: n.totalEvents > n.eventCount ? m(" sampled from {total}", { total: n.totalEvents.toLocaleString() }) : "" - }) }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-biplot-panels", children: [ - /* @__PURE__ */ e.jsx( - ht, - { - title: m("Original"), - panel: n.original, - preview: n, - sourceLabel: s, - receiverLabel: r, - densitySmoothing: o, - showZeroPile: !c - } - ), - /* @__PURE__ */ e.jsx( - ht, - { - title: d, - panel: n.compensated, - preview: n, - sourceLabel: s, - receiverLabel: r, - densitySmoothing: o, - showZeroPile: !c - } - ) - ] }), - !c && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-diagnostic-note", children: a === "cytof" ? /* @__PURE__ */ e.jsx(e.Fragment, { children: m("Receiver events at exact zero: {original}% → {compensated}% ({delta} percentage points). A rise can be consistent with NNLS over-subtraction, while a residual source-associated rise can be consistent with under-compensation. Neither is a verdict without a suitable negative/control population.", { - original: g.toFixed(1), - compensated: f.toFixed(1), - delta: `${w >= 0 ? "+" : ""}${w.toFixed(1)}` - }) }) : /* @__PURE__ */ e.jsx(e.Fragment, { children: m("Residual tilt can be consistent with under- or over-compensation, but spreading error and biological co-expression can produce similar shapes. Use the matched Original/{comparison} view as review evidence, not an automatic coefficient call.", { - comparison: d - }) }) }), - !c && (n.evidence.status === "ready" ? /* @__PURE__ */ e.jsxs("dl", { className: "gl-comp-pair-evidence", "aria-label": m("Conservative residual evidence"), children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: m("Receiver-negative shift") }), - /* @__PURE__ */ e.jsx("dd", { children: m("{value} MAD", { value: ne(n.evidence.normalizedNegativeShift ?? 0, 3) }) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: m("Robust residual slope") }), - /* @__PURE__ */ e.jsx("dd", { children: ne(n.evidence.residualSlope ?? 0, 4) }) - ] }), - n.evidence.upperTailExcessMad !== null && /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: m("Upper-tail departure") }), - /* @__PURE__ */ e.jsx("dd", { children: m("{value} MAD", { value: ne(n.evidence.upperTailExcessMad, 3) }) }) - ] }), - n.evidence.upperTailSlopeDeltaMad !== null && /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: m("Tail slope change") }), - /* @__PURE__ */ e.jsx("dd", { children: m("{value} MAD", { value: ne(n.evidence.upperTailSlopeDeltaMad, 3) }) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: m("Evidence groups") }), - /* @__PURE__ */ e.jsx("dd", { children: m("{high} source-high · {low} source-low", { - high: n.evidence.sourceHighEvents.toLocaleString(), - low: n.evidence.sourceLowEvents.toLocaleString() - }) }) - ] }) - ] }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-evidence-insufficient", children: m("Residual screening needs distinct source-low/source-high groups and enough receiver-negative events; this pair remains available for visual review.") })) - ] }); -} -function Zr({ - matrixView: n, - sourceChannels: s, - receiverChannels: r, - selectedSourceIndex: a, - selectedReceiverIndex: o, - stagedCoefficients: c, - maximumAbsoluteOffDiagonal: d, - onSelect: m -}) { - const { t: g } = Le(), f = 6, w = 74, k = 44, v = 10, S = r.length * f, T = s.length * f, I = w + S + w, $ = k + T + v, E = M.useMemo(() => { - const F = []; - for (let N = 0; N < n.matrix.length; N++) - for (let A = 0; A < n.matrix[N].length; A++) { - const K = n.sourceAxisKeys[N], O = n.receiverAxisKeys[A], D = `${K}${Hi}${O}`, U = c[D] ?? n.matrix[N][A], J = K === O; - if (!J && (!Number.isFinite(U) || U === 0)) continue; - const Z = d > 0 && Number.isFinite(U) ? Math.min(1, Math.abs(U) / d) : 0, i = Z > 0 ? 0.12 + 0.82 * Math.sqrt(Z) : 0; - F.push({ - sourceIndex: N, - receiverIndex: A, - pairKey: D, - value: U, - diagonal: J, - fill: J ? "#cfd4db" : Number.isFinite(U) ? U < 0 ? `rgba(47,128,237,${i})` : `rgba(211,47,47,${i})` : "#ae3e3e" - }); - } - return F; - }, [n, d, c]), P = (F) => { - const N = F.currentTarget.getBoundingClientRect(); - if (!(N.width > 0) || !(N.height > 0)) return; - const A = (F.clientX - N.left) * I / N.width, K = (F.clientY - N.top) * $ / N.height, O = Math.floor((A - w) / f), D = Math.floor((K - k) / f); - D < 0 || D >= s.length || O < 0 || O >= r.length || n.sourceAxisKeys[D] === n.receiverAxisKeys[O] || m(`${n.sourceAxisKeys[D]}${Hi}${n.receiverAxisKeys[O]}`); - }; - return /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-mini-matrix", "aria-labelledby": "comp-mini-matrix-heading", children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-mini-matrix-head", children: [ - /* @__PURE__ */ e.jsx("strong", { id: "comp-mini-matrix-heading", children: g("Matrix map") }), - /* @__PURE__ */ e.jsx("span", { children: g("Source ↓ · receiver → · click a cell") }) - ] }), - /* @__PURE__ */ e.jsxs( - "svg", - { - width: I, - height: $, - viewBox: `0 0 ${I} ${$}`, - role: "img", - "aria-label": g("Mini compensation matrix with {sources} source rows and {receivers} receiver columns", { - sources: s.length, - receivers: r.length - }), - onPointerDown: P, - children: [ - /* @__PURE__ */ e.jsx("rect", { x: w, y: k, width: S, height: T, fill: "#f8fafc", stroke: "#aeb8c6", strokeWidth: "0.7" }), - r.map((F, N) => /* @__PURE__ */ e.jsx( - "text", - { - x: w + (N + 0.55) * f, - y: k - 3, - transform: `rotate(-58 ${w + (N + 0.55) * f} ${k - 3})`, - textAnchor: "start", - className: N === o ? "is-selected" : void 0, - children: F.pnn - }, - F.key - )), - s.map((F, N) => /* @__PURE__ */ e.jsx( - "text", - { - x: w - 3, - y: k + (N + 0.72) * f, - textAnchor: "end", - className: N === a ? "is-selected" : void 0, - children: F.pnn - }, - F.key - )), - /* @__PURE__ */ e.jsx( - "rect", - { - x: w, - y: k + a * f, - width: S, - height: f, - fill: "rgba(47,128,237,0.08)", - pointerEvents: "none" - } - ), - /* @__PURE__ */ e.jsx( - "rect", - { - x: w + o * f, - y: k, - width: f, - height: T, - fill: "rgba(47,128,237,0.08)", - pointerEvents: "none" - } - ), - E.map((F) => /* @__PURE__ */ e.jsx( - "rect", - { - x: w + F.receiverIndex * f, - y: k + F.sourceIndex * f, - width: f, - height: f, - fill: F.fill, - pointerEvents: "none", - children: /* @__PURE__ */ e.jsx("title", { children: F.diagonal ? g("{channel} · self", { channel: s[F.sourceIndex].combined }) : `${s[F.sourceIndex].combined} → ${r[F.receiverIndex].combined} · ${en(F.value)}` }) - }, - F.pairKey - )), - /* @__PURE__ */ e.jsx( - "rect", - { - x: w + o * f, - y: k + a * f, - width: f, - height: f, - fill: "none", - stroke: "#2f80ed", - strokeWidth: "1.4", - vectorEffect: "non-scaling-stroke", - pointerEvents: "none" - } - ) - ] - } - ) - ] }); -} -function Hr({ - dataset: n, - pair: s, - plotSize: r, - densitySmoothing: a, - flagged: o, - selected: c, - onSelect: d, - onFlag: m -}) { - const { t: g } = Le(), f = M.useRef(null), [w, k] = M.useState(() => typeof IntersectionObserver > "u"); - M.useEffect(() => { - const T = f.current; - if (!T || typeof IntersectionObserver > "u") { - k(!0); - return; - } - const I = new IntersectionObserver( - ($) => k($.some((E) => E.isIntersecting)), - { rootMargin: "450px 0px" } - ); - return I.observe(T), () => I.disconnect(); - }, []); - const v = M.useMemo( - () => w ? ls(n, s.source.key, s.receiver.key) : null, - [n, s.receiver.key, s.source.key, w] - ), S = v != null && v.ready ? v.preview : null; - return /* @__PURE__ */ e.jsxs( - "article", - { - ref: f, - className: `gl-comp-global-tile${c ? " is-selected" : ""}${o ? " is-flagged" : ""}`, - "data-pair-key": s.pairKey, - "data-event-signature": S == null ? void 0 : S.eventSignature, - "data-x-range": S ? `${S.xRange[0]},${S.xRange[1]}` : void 0, - "data-y-range": S ? `${S.yRange[0]},${S.yRange[1]}` : void 0, - style: { width: r, height: r }, - children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-global-tile-head", children: [ - /* @__PURE__ */ e.jsxs( - "button", - { - type: "button", - onClick: d, - title: `${s.source.combined} → ${s.receiver.combined}`, - "aria-label": g("Open details for {source} to {receiver}", { - source: s.source.label, - receiver: s.receiver.label - }), - children: [ - /* @__PURE__ */ e.jsxs("span", { children: [ - s.source.label, - " → ", - s.receiver.label - ] }), - /* @__PURE__ */ e.jsxs("strong", { children: [ - (s.coefficient * 100).toFixed(1), - "%" - ] }) - ] - } - ), - /* @__PURE__ */ e.jsx("label", { title: g("Keep this pair in Flagged"), children: /* @__PURE__ */ e.jsx( - "input", - { - type: "checkbox", - checked: o, - "aria-label": g("Flag global inspector pair {source} to {receiver} for follow-up", { - source: s.source.label, - receiver: s.receiver.label - }), - onChange: (T) => m(T.currentTarget.checked) - } - ) }) - ] }), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-comp-global-plot-button", - onClick: d, - title: g("{source} → {receiver} · {interaction}matrix {coefficient}%", { - source: s.source.combined, - receiver: s.receiver.combined, - interaction: s.interaction && s.interaction !== "other" ? `${s.interaction} · ` : "", - coefficient: (s.coefficient * 100).toFixed(1) - }), - "aria-label": g("Open details for {source} to {receiver}; matrix coefficient {coefficient}%", { - source: s.source.label, - receiver: s.receiver.label, - coefficient: (s.coefficient * 100).toFixed(1) - }), - children: /* @__PURE__ */ e.jsx("div", { className: "gl-comp-global-plot", style: { width: r, height: r }, children: S ? /* @__PURE__ */ e.jsx( - Wr, - { - title: "", - preview: S, - sourceLabel: s.source.label, - receiverLabel: s.receiver.label, - minimumSize: r, - maximumSize: r, - densitySmoothing: a - } - ) : v && !v.ready ? /* @__PURE__ */ e.jsx("span", { children: v.reason }) : /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true" }) }) - } - ) - ] - } - ); -} -function Yr({ - stateKey: n, - header: s, - children: r -}) { - const { t: a } = Le(), [o, c] = me( - `compensation.${n}.globalInspectorLayer`, - "compensated" - ); - return /* @__PURE__ */ e.jsxs( - "section", - { - className: "gl-comp-global-inspector", - "aria-labelledby": "comp-global-inspector-heading", - "data-inspector-layer": o, - children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-global-head", children: [ - s, - /* @__PURE__ */ e.jsxs( - "button", - { - type: "button", - className: "gl-comp-layer-toggle", - "aria-pressed": o === "compensated", - "aria-label": a("Showing {shown} data; click to show {other} data", { - shown: a(o === "original" ? "uncompensated" : "compensated"), - other: a(o === "original" ? "compensated" : "uncompensated") - }), - title: a("Toggle every plot between uncompensated and compensated data without changing its frame"), - onClick: () => c((d) => d === "original" ? "compensated" : "original"), - children: [ - /* @__PURE__ */ e.jsx("span", { className: "gl-comp-layer-toggle-track", "aria-hidden": "true", children: /* @__PURE__ */ e.jsx("i", {}) }), - /* @__PURE__ */ e.jsx("span", { children: a(o === "original" ? "Uncompensated" : "Compensated") }) - ] - } - ) - ] }), - r - ] - } - ); -} -const Xr = { - relevant: "Matrix-linked / relevant", - nonzero: "Non-zero coefficients", - physical: "Physical CyTOF relationships", - flagged: "Flagged for follow-up", - all: "All included pairs" -}, Jr = [ - { id: "evidence", label: "Evidence" }, - { id: "review", label: "Review queue" } -], Oe = "", Xi = 2500, Ji = 400, Qr = 2500, Qi = 15e3, es = [2500, 5e3, 15e3, 5e4], ea = 24, ns = 4, ts = 624, na = Object.freeze({}); -function is(n) { - if (!Number.isFinite(n)) return String(n); - const s = n * 100; - if (s === 0) return "0.0"; - const r = Math.abs(s), a = r >= 1 ? 1 : r >= 0.1 ? 2 : 3; - return s.toFixed(a); -} -function zt(n) { - return n.replace(/(?: · (?:edited|revised))+$/u, ""); -} -function pt(n, s) { - const r = n.index(s), a = r === void 0 ? void 0 : n.channels[r], o = (a == null ? void 0 : a.pnn) ?? s, c = n.labelForKey(s), d = ((a == null ? void 0 : a.label) ?? "").trim() || ((a == null ? void 0 : a.marker) ?? "").trim(), m = d && d !== o ? `${d} (${o})` : o; - return { key: s, pnn: o, label: c, combined: m }; -} -function _t(n, s) { - const r = n.channels.find((a) => a.pnn === s); - return pt(n, (r == null ? void 0 : r.key) ?? s); -} -function ta(n, s) { - return n === "cytof-spillover" && s === "nnls" ? "CyTOF NNLS" : "Flow linear inverse"; -} -function ia(n) { - return n.replaceAll("-", " "); -} -function Ht(n) { - if (n.length === 0) return 0; - n.sort((r, a) => r - a); - const s = Math.floor(n.length / 2); - return n.length % 2 === 0 ? (n[s - 1] + n[s]) / 2 : n[s]; -} -function sa(n) { - return Object.fromEntries(n.scientific.solverSettings.map(({ key: s, value: r }) => [s, r])); -} -function ra(n, s) { - const r = Object.freeze({ ...n.scientific.matrix, matrix: s }), a = sa(n); - return n.scientific.kind === "flow-spillover" ? { - kind: "flow-spillover", - method: "matrix-inverse", - solverVersion: n.scientific.solverVersion, - solverSettings: { - singularTolerance: Number(a.singularTolerance), - conditionWarningThreshold: Number(a.conditionWarningThreshold) - }, - matrix: r - } : { - kind: "cytof-spillover", - method: "nnls", - solverVersion: n.scientific.solverVersion, - solverSettings: { - tolerance: Number(a.tolerance), - kktTolerance: Number(a.kktTolerance), - maxIterations: Number(a.maxIterations), - adaptationVersion: String(a.adaptationVersion) - }, - matrix: r, - includedChannels: n.scientific.includedChannels - }; -} -function ss(n, s, r, a) { - const o = n.scientific.matrix.sourceChannels.indexOf(s), c = n.scientific.matrix.receiverChannels.indexOf(r); - if (o < 0 || c < 0) - throw new Error("The selected coefficient is absent from the installed profile axes."); - return Object.freeze(n.scientific.matrix.matrix.map( - (d, m) => Object.freeze(d.map((g, f) => m === o && f === c ? a : g)) - )); -} -function aa(n, s, r) { - var d; - if (!n) return null; - const a = n.scientific.matrix.sourceChannels.indexOf(s), o = n.scientific.matrix.receiverChannels.indexOf(r); - if (a < 0 || o < 0) return null; - const c = (d = n.scientific.matrix.matrix[a]) == null ? void 0 : d[o]; - return Number.isFinite(c) ? c : null; -} -function rs(n, s, r) { - const a = Math.max(Math.abs(n), Math.abs(s), 1e-3); - return Object.freeze(r === "cytof" ? { lower: 0, upper: Math.max(n + a, a * 2) } : { lower: n - a, upper: n + a }); -} -function oa(n, s) { - const r = (s - n) / 3; - return Object.freeze([n, n + r, n + 2 * r, s]); -} -function la(n, s) { - return n.length === s.length && n.every((r, a) => { - var o; - return r.length === ((o = s[a]) == null ? void 0 : o.length) && r.every((c, d) => c === s[a][d]); - }); -} -function ca(n, s) { - if (n.compensatedLayerStatus().state !== "ready" || s.length === 0 || n.fcs.nEvents === 0) return null; - const a = s.flatMap((k) => { - const v = n.channels.findIndex((S) => S.pnn === k); - return v < 0 ? [] : [v]; - }); - if (a.length === 0) return null; - const o = Math.min(2048, n.fcs.nEvents), c = []; - let d = 0, m = 0, g = 0, f = "", w = -1; - for (const k of a) { - const v = n.originalColumnData(k), S = n.compensatedColumnData(k), T = []; - for (let $ = 0; $ < o; $++) { - const E = o === 1 ? 0 : Math.floor($ * (n.fcs.nEvents - 1) / (o - 1)), P = v[E], F = S[E], N = Math.abs(F - P); - T.push(N), c.push(N), N > Math.max(1e-6, Math.abs(P) * 1e-6) && d++, P < 0 && F === 0 && g++, m = Math.max(m, N); - } - const I = Ht(T); - I > w && (w = I, f = pt(n, n.channels[k].key).combined); - } - return { - previewEvents: o, - comparedValues: c.length, - changedValues: d, - medianAbsoluteDelta: Ht(c), - maxAbsoluteDelta: m, - zeroedNegativeValues: g, - mostChangedChannel: f, - mostChangedChannelMedianDelta: Math.max(0, w) - }; -} -function da(n, s) { - return n.origin.type === "uploaded" ? n.origin.fileName : n.origin.type === "embedded-fcs" ? `${n.origin.fileName} · ${s("embedded FCS")}` : `${n.origin.presetId} · ${s("bundled preset")} ${n.origin.presetVersion}`; -} -function ua(n) { - if (!n || n.kind !== "cytof-spillover") - return { draft: null, error: null }; - const s = { - input: { - sourceChannels: n.sourceChannels, - receiverChannels: n.receiverChannels, - matrix: n.matrix - }, - format: { - delimiter: "csv", - sourceColumnHeader: "source" - } - }, r = Ut( - s.input, - "cytof-spillover" - ); - return r.ok ? { - draft: { - fileName: n.name, - source: "host", - parsed: s, - matrix: r.value, - validationWarnings: r.warnings - }, - error: null - } : { - draft: null, - error: `The SCE spillover matrix is invalid. ${r.errors.map(({ message: a }) => a).join(" ")}` - }; -} -function ha({ - sample: n, - sampleName: s = "sample.fcs", - hostedCompensationMatrix: r = null, - compensationOn: a, - onApplyProfile: o, - existingHostAssays: c = [], - onAdoptExistingAssay: d, - onCancelApply: m, - hasExistingGates: g = !1, - applyStatus: f = null, - installedProfile: w = null, - applyTargetCount: k = 1, - applyTargetEventCount: v, - applyWorkerCount: S, - applyWorkerLimit: T, - onApplyWorkerCountChange: I, - installedBaselineProfile: $ = null, - reviewPopulations: E = [], - reviewPopulationMasks: P = na, - onPreviewCompensationCandidate: F, - onSolveCompensationSweep: N, - onCancelCompensationSweep: A, - onSuspendBackgroundWork: K, - visible: O = !0, - stateKey: D, - densityColorPower: U = Yt, - channelLabelMode: J = "marker", - onDensityColorPowerChange: Z = () => { - } -}) { - var Fi, $i; - const { t: i } = Le(), R = n.compensatedLayerStatus(), ge = R.state === "missing" ? null : R.metadata, _ = (ge == null ? void 0 : ge.runtimeIdentity) === "profile" ? ge : null, j = (w == null ? void 0 : w.profileId) === (_ == null ? void 0 : _.profileId) ? w : null, H = !_ && n.instrument === "flow" ? n.spillover : null, ue = (r == null ? void 0 : r.kind) === "flow-spillover" ? r : null, pn = M.useMemo( - () => ua(r), - [r] - ), [Se, je] = me( - `compensation.${D}.selectedPair`, - null - ), [mt, Te] = M.useState(null), [zn, ni] = me( - `compensation.${D}.openDrawers`, - { evidence: !1, review: !1 } - ), [mn, ti] = me( - "compensation.inspectorWidth", - ts - ), [Me, _n] = me( - `compensation.${D}.workspaceView`, - "matrix" - ), [Fe, Un] = me( - `compensation.${D}.globalPairFilter`, - "relevant" - ), [$e, us] = me( - `compensation.${D}.globalLayout`, - "compact" - ), [hs, ps] = me( - "compensation.globalPlotSize.v5", - 160 - ), [ms, fs] = me( - "compensation.densitySmoothing.v3", - 6 - ), [gs, xs] = me( - "compensation.pointAlpha.v1", - 0.85 - ), [ft, vs] = me( - "compensation.pairPreviewEventLimit.v1", - Qi - ), [kn, ii] = M.useState(""), [An, gt] = M.useState(!1), [xt, si] = M.useState(null), [fn, vt] = me( - `compensation.${D}.reviewPopulation`, - "all" - ), [qn, bs] = me( - `compensation.${D}.flaggedPairs`, - [] - ), [ze, ys] = me( - `compensation.${D}.evidenceMode`, - "biological" - ), [js, ws] = me( - `compensation.${D}.sweepBounds`, - {} - ), [bt, yt] = me( - `compensation.${D}.sweepWorkers`, - 2 - ), [Ee, ri] = M.useState(""), [we, jt] = M.useState(""), [Ns, wt] = M.useState(0), [Y, Vn] = M.useState({}), [Cs, nn] = M.useState({}), [_e, tn] = M.useState({ state: "idle" }), [Ss, Be] = M.useState({}), [Ms, sn] = M.useState({}), [ve, gn] = M.useState(null), [Es, Tn] = M.useState(null), [le, xn] = M.useState(null), [ai, xe] = M.useState(null), [Bn, Nt] = M.useState(""), [ks, oi] = M.useState(!1), [As, li] = M.useState(!1), ke = M.useRef(0), vn = M.useRef(0), [ci, he] = M.useState(null), [di, Ue] = M.useState(!1), [W, Gn] = M.useState( - () => pn.draft - ), [Fn, rn] = M.useState( - () => { - var p; - const t = ((p = pn.draft) == null ? void 0 : p.matrix.receiverChannels) ?? [], l = /* @__PURE__ */ new Map(); - for (const h of n.channels) { - const x = h.pnn.trim().normalize("NFC"); - l.set(x, (l.get(x) ?? 0) + 1); - } - return new Set(t.filter((h) => l.get(h) === 1)); - } - ), [ui, Ge] = M.useState( - () => pn.error - ), [We, bn] = M.useState(!1), [Wn, hi] = M.useState( - () => { - var t; - return ((t = c[0]) == null ? void 0 : t.id) ?? ""; - } - ), [Ct, Zn] = M.useState(!1), [Hn, Ne] = M.useState(null), [Ts, Ze] = M.useState(!1), [Fs, He] = M.useState(null), qe = M.useRef(!1), pi = M.useRef(null), mi = M.useRef(null), yn = M.useRef(null), V = Ts || f !== null, Ye = Math.max(0, Math.floor(k)), $s = Math.max( - 0, - Math.floor(v ?? n.fcs.nEvents) - ), Xe = c.find( - ({ id: t }) => t === Wn - ) ?? c[0] ?? null; - M.useEffect(() => { - var t; - Wn && c.some(({ id: l }) => l === Wn) || (hi(((t = c[0]) == null ? void 0 : t.id) ?? ""), Zn(!1)); - }, [c, Wn]); - const te = f ?? (Hn ? { - phase: "applying", - profileName: Fs ?? (W == null ? void 0 : W.fileName) ?? "Compensation", - fraction: Hn.fraction, - processedEvents: Hn.processedEvents, - totalEvents: Hn.totalEvents - } : null); - M.useEffect(() => { - O || (vn.current++, ke.current++, tn({ state: "idle" }), xn(null), gn(null), K == null || K()); - }, [K, O]); - const St = M.useMemo( - () => n.channels.map(({ pnn: t, columnIndex: l }) => ({ pnn: t, columnIndex: l })), - [n] - ), Ie = M.useMemo(() => { - if (!H) return null; - const t = H.channels.map((h) => { - const x = n.index(h); - return x === void 0 ? null : n.channels[x].pnn; - }); - if (t.some((h) => h === null)) - return { - validation: null, - error: "The embedded matrix could not be mapped back to exact FCS channel identities.", - keyword: void 0 - }; - const l = Ut({ - sourceChannels: t, - receiverChannels: t, - matrix: H.matrix - }, "flow-spillover"), p = ["$SPILLOVER", "$SPILL", "SPILL"].find((h) => typeof n.fcs.keywords[h] == "string"); - return { - validation: l, - error: l.ok ? null : `The embedded compensation matrix cannot be applied or edited. ${l.errors.map(({ message: h }) => h).join(" ")}`, - keyword: p - }; - }, [n, H]), X = fn === "all" ? null : E.find(({ id: t }) => t === fn) ?? null, ce = X ? P[X.id] ?? null : null, re = ce ? (X == null ? void 0 : X.eventCount) ?? 0 : n.fcs.nEvents, Yn = ft === "all" ? "all" : es.includes(Number(ft)) ? Number(ft) : Qi, $n = M.useMemo( - () => dn( - n.fcs.nEvents, - Yn === "all" ? Math.max(1, n.fcs.nEvents) : Yn, - ce - ), - [Yn, re, ce, n] - ), In = M.useMemo( - () => dn(n.fcs.nEvents, 2048, ce), - [ce, n] - ), Mt = M.useMemo( - () => dn( - n.fcs.nEvents, - Qr, - ce - ), - [ce, n] - ); - M.useEffect(() => { - fn !== "all" && !E.some(({ id: t }) => t === fn) && vt("all"); - }, [fn, E, vt]), M.useEffect(() => { - ke.current++, A == null || A(), Be({}), sn({}), gn(null), xn(null), xe(null); - }, [fn, ce, A]); - const ae = M.useMemo(() => W ? ar({ - kind: "cytof-spillover", - matrix: W.matrix, - sampleChannels: St, - includedChannels: Array.from(Fn) - }) : null, [W, Fn, St, J]), u = M.useMemo(() => { - if (H) { - const l = n.spilloverOrigin, p = l.kind === "external" ? l : null; - return { - sourceAxisKeys: H.channels, - receiverAxisKeys: H.channels, - sourceChannels: H.channels.map((h) => pt(n, h)), - receiverChannels: H.channels.map((h) => pt(n, h)), - matrix: H.matrix, - kind: "flow", - title: ue ? "SCE spillover matrix" : p ? `Compensation matrix from ${p.label}` : "Embedded compensation matrix", - subtitle: "Source rows ↓ · Receiver columns → · values are spillover percentages", - coefficientNote: p ? "This FCS carries no spillover matrix of its own; these coefficients came from the imported FlowJo workspace and are applied unchanged." + (p.droppedChannels.length ? ` ${p.droppedChannels.length} of its parameter(s) are not in this file (${p.droppedChannels.join(", ")}) and were left out, which changes the result for the channels they spill into.` : "") : "Applying the embedded matrix leaves its coefficients unchanged." - }; - } - if (!j || !_) return null; - const t = j.scientific.kind === "cytof-spillover" ? Cr(j.scientific.matrix) : j.scientific.matrix; - return t.matrix.length !== t.sourceChannels.length || t.matrix.some((l) => !l || l.length !== t.receiverChannels.length) ? null : { - sourceAxisKeys: t.sourceChannels, - receiverAxisKeys: t.receiverChannels, - sourceChannels: t.sourceChannels.map((l) => _t(n, l)), - receiverChannels: t.receiverChannels.map((l) => _t(n, l)), - matrix: t.matrix, - kind: j.scientific.kind === "cytof-spillover" ? "cytof" : "flow", - title: j.scientific.kind === "cytof-spillover" ? "Uploaded spill matrix" : "Applied compensation matrix", - subtitle: j.scientific.kind === "cytof-spillover" ? i("{sources} source rows ↓ · {receivers} receiver columns → · isotope-mass order", { - sources: t.sourceChannels.length, - receivers: t.receiverChannels.length - }) : "Source rows ↓ · Receiver columns → · exact installed coefficients", - coefficientNote: j.scientific.kind === "cytof-spillover" ? "This is the exact uploaded matrix. The NNLS solve uses its selected, matched channels; original measurements remain stored separately." : "This is the exact installed matrix. Original measurements remain stored separately." - }; - }, [ue, _, j, n, H, i, J]), oe = (u == null ? void 0 : u.sourceChannels) ?? [], de = (u == null ? void 0 : u.receiverChannels) ?? []; - M.useEffect(() => { - yt((t) => Math.max(1, Math.min(ns, Math.round(t) || 1))); - }, [yt]); - const Xn = mt ?? Se, y = M.useMemo(() => { - if (!u || !Xn) return null; - const [t, l] = Xn.split(Oe), p = u.sourceAxisKeys.indexOf(t), h = u.receiverAxisKeys.indexOf(l); - return p < 0 || h < 0 || u.sourceAxisKeys[p] === u.receiverAxisKeys[h] ? null : { - pairKey: Xn, - sourceIndex: p, - receiverIndex: h, - source: oe[p], - receiver: de[h], - value: u.matrix[p][h], - interaction: u.kind === "cytof" ? Cn( - u.sourceAxisKeys[p], - u.receiverAxisKeys[h] - ) : null - }; - }, [Xn, u, de, oe]); - M.useEffect(() => { - if (!y) { - Nt(""); - return; - } - const t = Y[y.pairKey]; - Nt(ne((t ?? y.value) * 100, 6)); - }, [y == null ? void 0 : y.pairKey, y == null ? void 0 : y.value, Y]); - const be = M.useMemo(() => y ? Ot( - n, - y.source.key, - y.receiver.key, - { - eventMask: ce, - fixedEventIndices: $n, - eligibleEventCount: re - } - ) : null, [a, R.state, $n, re, ce, n, y]), Ce = M.useMemo(() => { - if (!u || R.state !== "ready") - return { candidateCount: 0, screenedCount: 0, evaluableCount: 0, items: [] }; - const t = []; - for (let x = 0; x < u.matrix.length; x++) - for (let b = 0; b < u.matrix[x].length; b++) { - const C = u.sourceAxisKeys[x], z = u.receiverAxisKeys[b]; - if (C === z) continue; - const q = u.matrix[x][b]; - if (!Number.isFinite(q)) continue; - const L = u.kind === "cytof" ? Cn(C, z) : null, G = L !== null && L !== "self" && L !== "other"; - q === 0 && !G && ze === "biological" || t.push({ - sourceIndex: x, - receiverIndex: b, - pairKey: `${C}${Oe}${z}`, - source: oe[x], - receiver: de[b], - coefficient: q, - interaction: L, - physicalPrior: G ? 1 : 0 - }); - } - t.sort((x, b) => b.physicalPrior - x.physicalPrior || Math.abs(b.coefficient) - Math.abs(x.coefficient)); - const l = t.slice(0, 240), p = l.flatMap((x) => { - const b = Ot( - n, - x.source.key, - x.receiver.key, - { - eventMask: ce, - fixedEventIndices: In, - eligibleEventCount: re - } - ); - return b.ready ? [{ ...x, evidence: b.preview.evidence }] : []; - }), h = Ir( - p.map(({ coefficient: x, physicalPrior: b, evidence: C }) => ({ coefficient: x, physicalPrior: b, evidence: C })), - u.kind, - ze - ).map(({ index: x, relativePriority: b }) => ({ ...p[x], relativePriority: b })); - return { - candidateCount: t.length, - screenedCount: l.length, - evaluableCount: p.length, - items: h.slice(0, 8) - }; - }, [Ns, ze, R.state, u, de, In, re, ce, n, oe]), ie = M.useMemo(() => new Set( - j ? j.scientific.kind === "flow-spillover" ? j.scientific.matrix.receiverChannels : j.scientific.includedChannels : [] - ), [j]), se = M.useMemo(() => u ? Or( - n, - Array.from(/* @__PURE__ */ new Set([ - ...u.sourceAxisKeys, - ...u.receiverAxisKeys - ])), - { - eventMask: ce, - fixedEventIndices: Mt, - eligibleEventCount: re - } - ) : null, [ - a, - Mt, - R.state, - u, - re, - ce, - n - ]); - M.useEffect(() => { - if (!u || ie.size === 0) return; - const t = ie.has(Ee) ? Ee : u.sourceAxisKeys.find((p) => ie.has(p)) ?? "", l = ie.has(we) && we !== t ? we : u.receiverAxisKeys.find((p) => p !== t && ie.has(p)) ?? ""; - t !== Ee && ri(t), l !== we && jt(l); - }, [ie, we, Ee, u]); - const jn = M.useMemo(() => new Set(qn), [qn]), Et = M.useMemo(() => { - var p; - if (!u) return []; - const t = [], l = ie.size > 0; - for (let h = 0; h < u.sourceAxisKeys.length; h++) { - const x = u.sourceAxisKeys[h]; - if (!(l && !ie.has(x))) - for (let b = 0; b < u.receiverAxisKeys.length; b++) { - const C = u.receiverAxisKeys[b]; - if (x === C || l && !ie.has(C)) continue; - const z = (p = u.matrix[h]) == null ? void 0 : p[b]; - if (!Number.isFinite(z)) continue; - const q = oe[h], L = de[b]; - if (!q || !L || se != null && se.ready && (!se.dataset.channels.has(q.key) || !se.dataset.channels.has(L.key))) continue; - const G = u.kind === "cytof" ? Cn(x, C) : null, ee = G !== null && G !== "self" && G !== "other"; - t.push({ - sourceIndex: h, - receiverIndex: b, - pairKey: `${x}${Oe}${C}`, - source: q, - receiver: L, - coefficient: z, - interaction: G, - physicalPrior: ee ? 1 : 0 - }); - } - } - return t; - }, [se, ie, u, de, oe]), Pe = M.useMemo(() => { - const t = kn.trim().toLocaleLowerCase(); - return Et.filter((l) => { - const p = Math.abs(l.coefficient) > 1e-12, h = l.physicalPrior > 0; - return Fe === "all" || Fe === "relevant" && (p || h) || Fe === "nonzero" && p || Fe === "physical" && h || Fe === "flagged" && jn.has(l.pairKey) ? t ? `${l.source.combined} ${l.receiver.combined}`.toLocaleLowerCase().includes(t) : !0 : !1; - }); - }, [jn, Et, Fe, kn]); - M.useEffect(() => { - var l; - if (!xt || Me !== "global") return; - const t = [...((l = yn.current) == null ? void 0 : l.querySelectorAll(".gl-comp-global-tile")) ?? []].find((p) => p.dataset.pairKey === xt); - t && (t.scrollIntoView({ block: "center", inline: "center" }), si(null)); - }, [An, $e, xt, Pe, Me]); - const kt = M.useMemo(() => { - if ($e === "compact") return []; - const t = /* @__PURE__ */ new Map(); - for (const l of Pe) { - const p = $e === "source" ? l.source : l.receiver, h = t.get(p.key); - h ? h.pairs.push(l) : t.set(p.key, { channel: p, pairs: [l] }); - } - return [...t.values()]; - }, [$e, Pe]), fi = M.useMemo( - () => $e === "compact" ? Pe : kt.flatMap((t) => t.pairs), - [kt, $e, Pe] - ), gi = `${i(Xr[Fe])}${kn.trim() ? i(" · search “{query}”", { query: kn.trim() }) : ""}`, At = Math.max(120, Math.min(220, Math.round(hs) || 120)), Je = Math.max(1, Math.min(10, Math.round(ms) || 6)), Jn = Math.max(0.1, Math.min(1, Number(gs) || 0.85)), Q = M.useMemo(() => !j || !u || R.state !== "ready" ? [] : qn.flatMap((t) => { - const [l, p] = t.split(Oe), h = u.sourceAxisKeys.indexOf(l), x = u.receiverAxisKeys.indexOf(p); - if (h < 0 || x < 0 || l === p || !ie.has(l) || !ie.has(p)) return []; - const b = Ot( - n, - oe[h].key, - de[x].key, - { - eventMask: ce, - fixedEventIndices: In, - eligibleEventCount: re - } - ); - if (!b.ready) return []; - const C = Ce.items.find((z) => z.pairKey === t); - return [{ - sourceIndex: h, - receiverIndex: x, - pairKey: t, - source: oe[h], - receiver: de[x], - coefficient: u.matrix[h][x], - interaction: u.kind === "cytof" ? Cn(l, p) : null, - physicalPrior: u.kind === "cytof" && Cn(l, p) !== "other" ? 1 : 0, - evidence: b.preview.evidence, - relativePriority: (C == null ? void 0 : C.relativePriority) ?? 0 - }]; - }), [qn, ie, R.state, u, j, de, Ce.items, In, re, ce, n, oe]), Ke = Q, xi = M.useMemo(() => { - if (!j) return 0.01; - const t = []; - for (let l = 0; l < j.scientific.matrix.matrix.length; l++) { - const p = j.scientific.matrix.sourceChannels[l]; - for (let h = 0; h < j.scientific.matrix.matrix[l].length; h++) { - if (p === j.scientific.matrix.receiverChannels[h]) continue; - const x = Math.abs(j.scientific.matrix.matrix[l][h]); - Number.isFinite(x) && x > 1e-12 && t.push(x); - } - } - return t.length > 0 ? Ht(t) : 0.01; - }, [j]), Tt = (t, l) => { - const p = js[t]; - if (p) return p; - const h = rs(l, xi, (u == null ? void 0 : u.kind) ?? "flow"); - return { - lowerPercent: ne(h.lower * 100, 5), - upperPercent: ne(h.upper * 100, 5) - }; - }, Pn = (t, l) => { - const p = Tt(t, l), h = Number(p.lowerPercent) / 100, x = Number(p.upperPercent) / 100; - return !Number.isFinite(h) || !Number.isFinite(x) ? { lower: h, upper: x, error: "Enter finite lower and upper sweep bounds." } : (u == null ? void 0 : u.kind) === "cytof" && h < 0 ? { lower: h, upper: x, error: "CyTOF NNLS sweep bounds cannot be negative." } : x > h ? { lower: h, upper: x, error: null } : { lower: h, upper: x, error: "The upper sweep bound must be greater than the lower bound." }; - }, Qn = (t, l, p, h) => { - ws((x) => ({ - ...x, - [t]: { - ...x[t] ?? (() => { - const b = rs(l, xi, (u == null ? void 0 : u.kind) ?? "flow"); - return { - lowerPercent: ne(b.lower * 100, 5), - upperPercent: ne(b.upper * 100, 5) - }; - })(), - [p]: h - } - })), Be((x) => { - if (!(t in x)) return x; - const b = { ...x }; - return delete b[t], b; - }), sn((x) => { - if (!(t in x)) return x; - const b = { ...x }; - return delete b[t], b; - }); - }, Kn = (t, l) => { - bs((p) => l ? p.includes(t) ? p : [...p, t] : p.filter((h) => h !== t)), l ? (je(t), Tn(t)) : (Be((p) => { - if (!(t in p)) return p; - const h = { ...p }; - return delete h[t], h; - }), sn((p) => { - if (!(t in p)) return p; - const h = { ...p }; - return delete h[t], h; - })); - }, Is = () => { - if (!u || !Ee || !we || Ee === we) return; - if (!ie.has(Ee) || !ie.has(we)) { - xe("Both channels must be included in the installed compensation solve."); - return; - } - const t = `${Ee}${Oe}${we}`; - Kn(t, !0), xe(null); - }, Ft = Ke.reduce((t, l) => t + (Pn(l.pairKey, l.coefficient).error ? 1 : 0), 0), wn = M.useMemo(() => { - if (!j) return null; - const t = j.scientific.matrix.matrix.map((l) => Array.from(l)); - for (const [l, p] of Object.entries(Y)) { - const [h, x] = l.split(Oe), b = j.scientific.matrix.sourceChannels.indexOf(h), C = j.scientific.matrix.receiverChannels.indexOf(x); - b >= 0 && C >= 0 && (t[b][C] = p); - } - return Object.freeze(t.map((l) => Object.freeze(l))); - }, [j, Y]); - M.useEffect(() => { - const t = Object.keys(Y).length; - if (!O || t === 0 || !j || j.scientific.kind !== "flow-spillover" || R.state !== "ready" || !wn || !y || !F) { - vn.current++, tn({ state: "idle" }); - return; - } - const l = $n; - if (l.length === 0) { - tn({ - state: "error", - pairKey: y.pairKey, - message: i("The selected review population contains no events.") - }); - return; - } - const p = ++vn.current, h = y.pairKey; - tn((b) => ({ - state: "updating", - pairKey: h, - ...(b.state === "ready" || b.state === "updating") && b.pairKey === h && b.preview ? { preview: b.preview } : {} - })); - const x = window.setTimeout(() => { - F( - j, - l, - wn - ).then((b) => { - if (vn.current !== p) return; - const C = b.sourceChannels.indexOf(y.source.pnn), z = b.sourceChannels.indexOf(y.receiver.pnn); - if (C < 0 || z < 0) - throw new Error(i("The preview result did not contain the selected flow channels.")); - const q = Dt( - n, - y.source.pnn, - y.receiver.pnn, - l, - b.candidateColumns[C], - b.candidateColumns[z], - { totalEvents: re } - ); - if (!q.ready) throw new Error(q.reason); - tn({ - state: "ready", - pairKey: h, - preview: q.preview - }); - }).catch((b) => { - if (vn.current !== p) return; - const C = b instanceof Error ? b.message : String(b); - /cancel|supersed|stale/i.test(C) || tn({ state: "error", pairKey: h, message: C }); - }); - }, 90); - return () => window.clearTimeout(x); - }, [ - R.state, - F, - j, - $n, - re, - n, - n.dataRevision, - n.displayTransformContextKey, - n.layerRevision, - y, - Y, - i, - O, - wn - ]); - const Ps = M.useMemo(() => !u || Object.keys(Y).length === 0 ? null : { - sourceChannels: u.sourceAxisKeys, - receiverChannels: u.receiverAxisKeys, - matrix: u.matrix.map( - (t, l) => t.map((p, h) => { - const x = `${u.sourceAxisKeys[l]}${Oe}${u.receiverAxisKeys[h]}`; - return Y[x] ?? p; - }) - ) - }, [u, Y]), vi = M.useMemo(() => { - if (!u) return []; - const t = []; - for (let l = 0; l < u.matrix.length; l++) - for (let p = 0; p < u.matrix[l].length; p++) { - const h = u.matrix[l][p]; - u.sourceAxisKeys[l] === u.receiverAxisKeys[p] || !Number.isFinite(h) || h <= 1 || t.push(`${oe[l].combined} → ${de[p].combined}`); - } - return t; - }, [u, de, oe]), $t = M.useMemo(() => { - if (!u) return []; - const t = []; - for (let l = 0; l < u.matrix.length; l++) - for (let p = 0; p < u.matrix[l].length; p++) { - const h = u.matrix[l][p], x = u.sourceAxisKeys[l] === u.receiverAxisKeys[p], b = `${oe[l].combined} → ${de[p].combined}`; - Number.isFinite(h) ? x && Math.abs(h - 1) > 1e-8 ? t.push(`${oe[l].combined}: diagonal is ${en(h)}, not 100%`) : !x && h < 0 ? t.push(`${b}: negative coefficient (${en(h)})`) : !x && h > 1 && t.push(`${b}: coefficient above 100%`) : t.push(`${b}: non-finite coefficient (${String(h)})`); - } - return t; - }, [u, de, oe]), bi = M.useMemo( - () => (u == null ? void 0 : u.matrix.some((t) => t.some((l) => !Number.isFinite(l)))) ?? !1, - [u] - ), Ae = M.useMemo( - () => _ && R.state === "ready" ? ca(n, _.includedPnns) : null, - [R.state, _, n] - ), et = M.useMemo(() => { - const t = [...$t]; - return R.state === "stale" && t.push(...R.reasons.map((l) => `Profile unavailable: ${ia(l)}`)), t; - }, [R, $t]), yi = _ ? (j == null ? void 0 : j.name) ?? "Installed compensation profile" : H ? ue ? "SCE spillover matrix" : "Embedded FCS matrix" : "No compatible matrix", Ks = _ ? ta(_.kind, _.method) : H ? "Flow linear inverse" : "Not configured", nt = i(Ks), It = (_ == null ? void 0 : _.includedPnns.length) ?? (H == null ? void 0 : H.channels.length) ?? 0, tt = (j == null ? void 0 : j.name) ?? (_ == null ? void 0 : _.profileId) ?? yi, ji = zt(tt), Rs = ji !== tt || (j == null ? void 0 : j.recordType) === "revision" ? `${ji} · ${i("revised")}` : tt, Os = H !== null && !bi || _ !== null && R.state === "ready", wi = M.useMemo(() => { - if (!u) return 0; - let t = 0; - for (let l = 0; l < u.matrix.length; l++) - for (let p = 0; p < u.matrix[l].length; p++) { - if (u.sourceAxisKeys[l] === u.receiverAxisKeys[p]) continue; - const h = u.matrix[l][p]; - Number.isFinite(h) && (t = Math.max(t, Math.abs(h))); - } - return t; - }, [u]), it = !!((j == null ? void 0 : j.scientific.kind) === "flow-spillover" && R.state === "ready" && u && Math.max(u.sourceAxisKeys.length, u.receiverAxisKeys.length) <= ea), Rn = u ? it ? Math.max(42, Math.min(54, Math.floor(960 / Math.max( - u.sourceAxisKeys.length, - u.receiverAxisKeys.length - )))) : Math.max(13, Math.min(38, Math.floor(760 / Math.max( - u.sourceAxisKeys.length, - u.receiverAxisKeys.length - )))) : 13; - M.useEffect(() => { - Vn({}), nn({}), tn({ state: "idle" }), vn.current++; - }, [j == null ? void 0 : j.profileId]), M.useEffect(() => { - (u == null ? void 0 : u.kind) === "flow" && Fe === "physical" && Un("relevant"); - }, [Fe, u == null ? void 0 : u.kind, Un]); - const Ds = (t) => { - ni((l) => ({ ...l, [t]: !l[t] })); - }, Ni = (t) => { - var h; - const l = ((h = yn.current) == null ? void 0 : h.getBoundingClientRect().width) ?? 1100, p = Math.max(360, Math.min(900, l - 440 - 8)); - return Math.max(360, Math.min(p, Math.round(t))); - }, Ls = (t) => { - var x; - if (t.button !== 0) return; - t.preventDefault(); - const l = t.currentTarget; - (x = l.setPointerCapture) == null || x.call(l, t.pointerId); - const p = (b) => { - var z; - const C = (z = yn.current) == null ? void 0 : z.getBoundingClientRect(); - C && ti(Ni(C.right - b.clientX)); - }, h = () => { - var b; - window.removeEventListener("pointermove", p), window.removeEventListener("pointerup", h), window.removeEventListener("pointercancel", h), (b = l.releasePointerCapture) == null || b.call(l, t.pointerId); - }; - window.addEventListener("pointermove", p), window.addEventListener("pointerup", h), window.addEventListener("pointercancel", h); - }, zs = (t) => { - let l = null; - t.key === "ArrowLeft" ? l = mn + 40 : t.key === "ArrowRight" ? l = mn - 40 : t.key === "Home" && (l = ts), l !== null && (t.preventDefault(), ti(Ni(l))); - }, _s = async (t) => { - var p; - const l = (p = t.currentTarget.files) == null ? void 0 : p[0]; - t.currentTarget.value = "", l && await Si(l); - }, Ci = () => void cr(pi.current, { "text/csv": [".csv", ".tsv", ".txt"] }, "CyTOF spillover matrix").then((t) => { - t != null && t[0] && Si(t[0]); - }), Si = async (t) => { - Ge(null), he(null), Ue(!1), Ne(null), bn(!1); - try { - const l = Nr(await t.text()), p = Ut( - l.input, - "cytof-spillover" - ); - if (!p.ok) - throw new Error(p.errors.map(({ message: b }) => b).join(" ")); - const h = /* @__PURE__ */ new Map(); - for (const { pnn: b } of St) { - const C = b.trim().normalize("NFC"); - h.set(C, (h.get(C) ?? 0) + 1); - } - const x = p.value.receiverChannels.filter( - (b) => h.get(b) === 1 - ); - Gn({ - fileName: t.name, - source: "file", - parsed: l, - matrix: p.value, - validationWarnings: p.warnings - }), rn(new Set(x)); - } catch (l) { - Gn(null), rn(/* @__PURE__ */ new Set()), Ge(l instanceof Error ? l.message : String(l)); - } - }, Us = (t, l) => { - rn((p) => { - const h = new Set(p); - return l ? h.add(t) : h.delete(t), h; - }); - }, Mi = async () => { - var p, h; - if (!W) - throw new Error(i("Choose a CyTOF spillover matrix first.")); - const t = ((h = (p = globalThis.crypto) == null ? void 0 : p.randomUUID) == null ? void 0 : h.call(p)) ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`, l = W.fileName.replace(/\.(?:csv|tsv|txt)$/i, "") || "CyTOF compensation"; - return Ki( - { - kind: "cytof-spillover", - method: "nnls", - solverVersion: mr, - solverSettings: fr, - matrix: W.matrix, - includedChannels: Array.from(Fn) - }, - { - profileId: `cytof-${t}`, - name: l, - createdAt: /* @__PURE__ */ new Date(), - origin: { - type: "uploaded", - fileName: W.fileName, - format: W.parsed.format.delimiter, - sourceColumnHeader: W.parsed.format.sourceColumnHeader - }, - provenance: { - sourceDescription: W.source === "host" ? "CyTOF spillover matrix from metadata(sce)$spillover_matrix" : "User-uploaded CyTOF spillover matrix", - estimationMethod: "Imported; coefficients preserved exactly" - } - } - ); - }, qs = async () => { - if (!(qe.current || V || !W || !(ae != null && ae.canApply) || !o)) { - if (g && !We) { - Ge( - i("Confirm that existing gate memberships will be recomputed in compensated coordinates before applying.") - ); - return; - } - Ge(null), he(null), Ne(null), qe.current = !0, Ze(!0), He(W.fileName); - try { - const t = await Mi(); - await o(t, Ne), he(i("Applied {name} to {channels} channels across {files} checked FCS files. Original measurements remain available.", { - name: t.name, - channels: Fn.size, - files: Ye - })), Gn(null), rn(/* @__PURE__ */ new Set()), bn(!1), Ne(null); - } catch (t) { - const l = t instanceof Error ? t.message : String(t); - /cancel/i.test(l) ? he(i("CyTOF compensation was cancelled; the previous assay was left unchanged.")) : Ge(l); - } finally { - qe.current = !1, Ze(!1), He(null); - } - } - }, Vs = async () => { - if (!(qe.current || V || !W || !(ae != null && ae.canApply) || !Xe || !d || !Ct)) { - if (g && !We) { - Ge( - i("Confirm that existing gate memberships will be recomputed in compensated coordinates before adopting the assay.") - ); - return; - } - Ge(null), he(null), Ne(null), qe.current = !0, Ze(!0), He(Xe.label); - try { - const t = await Mi(); - await d( - t, - Xe, - Ne - ), he(i("Using existing SCE assay {assay} with {matrix}. No assay values were recomputed.", { - assay: Xe.label, - matrix: t.name - })), Gn(null), rn(/* @__PURE__ */ new Set()), bn(!1), Zn(!1), Ne(null); - } catch (t) { - Ge(t instanceof Error ? t.message : String(t)); - } finally { - qe.current = !1, Ze(!1), He(null); - } - } - }, Bs = async () => { - var l, p, h; - if (qe.current || V || !H || !((l = Ie == null ? void 0 : Ie.validation) != null && l.ok) || !o) return; - if (g && !We) { - Ue(!0), he( - i("Confirm that existing gate memberships will be recomputed in compensated coordinates before enabling matrix editing.") - ); - return; - } - const t = (ue == null ? void 0 : ue.name) || `${s.replace(/\.fcs$/i, "") || "Flow"} spillover`; - he(null), Ue(!1), Ne(null), qe.current = !0, Ze(!0), He(t); - try { - const x = ((h = (p = globalThis.crypto) == null ? void 0 : p.randomUUID) == null ? void 0 : h.call(p)) ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`, b = await Ki( - { - kind: "flow-spillover", - method: "matrix-inverse", - solverVersion: ur, - solverSettings: dr, - matrix: Ie.validation.value - }, - { - profileId: `flow-${x}`, - name: t, - createdAt: /* @__PURE__ */ new Date(), - origin: { - ...ue ? { - type: "uploaded", - fileName: ue.name, - format: "csv", - sourceColumnHeader: "source" - } : { - type: "embedded-fcs", - fileName: s, - ...Ie.keyword ? { keyword: Ie.keyword } : {} - } - }, - provenance: { - sourceDescription: ue ? "Flow spillover matrix from metadata(sce)$spillover_matrix" : "Spillover matrix embedded in the source FCS file", - estimationMethod: ue ? "Imported from SCE metadata; coefficients preserved exactly" : "Imported from FCS; coefficients preserved exactly" - } - } - ); - await o(b, Ne), bn(!1), he(i(ue ? "Flow matrix editing is ready. The exact hosted matrix is retained as the baseline, and Original measurements remain available." : "Flow matrix editing is ready. The exact embedded matrix is retained as the baseline, and Original measurements remain available.")); - } catch (x) { - Ue(!0), he(x instanceof Error ? x.message : String(x)); - } finally { - qe.current = !1, Ze(!1), He(null), Ne(null); - } - }, Ei = (t, l) => { - var x, b; - const p = oe[t], h = de[l]; - !u || !p || !h || u.sourceAxisKeys[t] === u.receiverAxisKeys[l] || (je(`${u.sourceAxisKeys[t]}${Oe}${u.receiverAxisKeys[l]}`), (b = (x = mi.current) == null ? void 0 : x.querySelector( - `button[data-source-index="${t}"][data-receiver-index="${l}"]` - )) == null || b.focus()); - }, Gs = (t, l, p) => { - if (!u) return; - const h = u.sourceAxisKeys.length, x = u.receiverAxisKeys.length; - let b = l, C = p; - const z = (L, G) => { - let ee = L + G; - for (; ee >= 0 && ee < x; ) { - if (u.sourceAxisKeys[l] !== u.receiverAxisKeys[ee]) return ee; - ee += G; - } - return L; - }, q = (L, G) => { - let ee = L + G; - for (; ee >= 0 && ee < h; ) { - if (u.sourceAxisKeys[ee] !== u.receiverAxisKeys[p]) return ee; - ee += G; - } - return L; - }; - switch (t.key) { - case "ArrowLeft": - C = z(p, -1); - break; - case "ArrowRight": - C = z(p, 1); - break; - case "ArrowUp": - b = q(l, -1); - break; - case "ArrowDown": - b = q(l, 1); - break; - case "Home": { - C = u.sourceAxisKeys[l] === u.receiverAxisKeys[0] ? 1 : 0; - break; - } - case "End": { - const L = x - 1; - C = u.sourceAxisKeys[l] === u.receiverAxisKeys[L] ? L - 1 : L; - break; - } - default: - return; - } - t.preventDefault(), Ei(b, C); - }, On = (t, l) => { - if (!j || !Number.isFinite(l)) return; - const [p, h] = t.split(Oe), x = j.scientific.matrix.sourceChannels.indexOf(p), b = j.scientific.matrix.receiverChannels.indexOf(h); - if (x < 0 || b < 0) return; - if (j.scientific.kind === "cytof-spillover" && l < 0) { - Ue(!0), he(i("CyTOF NNLS spill coefficients cannot be negative.")); - return; - } - const C = j.scientific.matrix.matrix[x][b]; - Vn((z) => { - const q = { ...z }; - return l === C ? delete q[t] : q[t] = l, q; - }), Ue(!1), he(i("Staged {source} → {receiver} at {value}%. Apply the revised matrix to recompute the assay.", { - source: p, - receiver: h, - value: (l * 100).toFixed(2) - })); - }, ki = (t, l, p, h) => { - const x = p[0]; - if (!x) return null; - const b = x.sourceChannels.indexOf(t.source.pnn), C = x.sourceChannels.indexOf(t.receiver.pnn); - if (b < 0 || C < 0) return null; - const z = Dt( - n, - t.source.pnn, - t.receiver.pnn, - h, - x.currentColumns[b], - x.currentColumns[C], - { totalEvents: re } - ); - if (!z.ready) return null; - const q = [{ - value: t.coefficient, - isCurrent: !0, - preview: z.preview - }]; - return p.forEach((L, G) => { - const ee = L.sourceChannels.indexOf(t.source.pnn), Re = L.sourceChannels.indexOf(t.receiver.pnn); - if (ee < 0 || Re < 0) return; - const ye = Dt( - n, - t.source.pnn, - t.receiver.pnn, - h, - L.candidateColumns[ee], - L.candidateColumns[Re], - { - totalEvents: re, - xRange: z.preview.xRange, - yRange: z.preview.yRange - } - ); - ye.ready && q.push({ - value: l[G], - isCurrent: !1, - preview: ye.preview - }); - }), q.sort((L, G) => L.value - G.value || Number(G.isCurrent) - Number(L.isCurrent)), { pairKey: t.pairKey, values: Object.freeze(q) }; - }, Ws = async (t) => { - if (!j || !u || !N || V || le || ve) return; - const l = Pn(t.pairKey, t.coefficient); - if (l.error) { - xe(l.error); - return; - } - const p = dn( - n.fcs.nEvents, - Ji, - ce - ); - if (p.length === 0) { - xe(i("The selected review population contains no events.")); - return; - } - const h = ++ke.current, x = [l.lower, l.upper]; - gn(t.pairKey), xe(null); - try { - const b = await N( - j, - p, - x.map((z) => ss( - j, - u.sourceAxisKeys[t.sourceIndex], - u.receiverAxisKeys[t.receiverIndex], - z - )), - void 0, - 1 - ); - if (ke.current !== h) return; - const C = ki(t, x, b, p); - if (!C) throw new Error(i("The fast bounds preview could not be built for this pair.")); - sn((z) => ({ ...z, [t.pairKey]: C })); - } catch (b) { - if (ke.current !== h) return; - const C = b instanceof Error ? b.message : String(b); - xe(/cancel/i.test(C) ? i("Fast bounds preview cancelled.") : C); - } finally { - ke.current === h && gn(null); - } - }, Zs = async () => { - var h; - if (!j || !N || Ke.length === 0 || V || le !== null || ve !== null) return; - if (Ft > 0) { - xe(i("Fix the sweep bounds for {count} flagged pairs before running.", { count: Ft })); - return; - } - const t = dn( - n.fcs.nEvents, - Xi, - ce - ); - if (t.length === 0) { - xe(i("The selected review population contains no events.")); - return; - } - const l = ++ke.current, p = Ke.flatMap((x) => { - const b = Pn(x.pairKey, x.coefficient); - return oa(b.lower, b.upper).map((C) => ({ - pair: x, - value: C, - matrix: ss( - j, - u.sourceAxisKeys[x.sourceIndex], - u.receiverAxisKeys[x.receiverIndex], - C - ) - })); - }); - xe(null), Be({}), xn({ completed: 0, total: p.length }); - try { - const x = await N( - j, - t, - p.map(({ matrix: C }) => C), - (C, z) => { - ke.current === l && xn({ completed: C, total: z }); - }, - bt - ); - if (ke.current !== l) return; - if (x.length !== p.length) - throw new Error(i("The compensation worker returned an incomplete coefficient sweep.")); - const b = {}; - for (const C of Ke) { - const z = p.flatMap((L, G) => L.pair.pairKey === C.pairKey ? [G] : []), q = ki( - C, - z.map((L) => p[L].value), - z.map((L) => x[L]), - t - ); - q && (b[C.pairKey] = q); - } - Be(b), Tn(((h = Ke[0]) == null ? void 0 : h.pairKey) ?? null); - } catch (x) { - if (ke.current !== l) return; - const b = x instanceof Error ? x.message : String(x); - xe(/cancel/i.test(b) ? i("Exact coefficient sweep cancelled.") : b); - } finally { - ke.current === l && xn(null); - } - }, Hs = () => { - ke.current++, A == null || A(), xn(null), gn(null), xe(i("Exact coefficient sweep cancelled.")); - }, Ys = async () => { - var l, p; - if (!j || !wn || !o || Object.keys(Y).length === 0) return; - const t = `${zt(j.name)} · edited`; - he(null), Ue(!1), Ze(!0), He(t), Ne(null); - try { - const x = { - profileId: `comp-edit-${((p = (l = globalThis.crypto) == null ? void 0 : l.randomUUID) == null ? void 0 : p.call(l)) ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`}`, - name: t, - createdAt: /* @__PURE__ */ new Date(), - note: `Edited ${Object.keys(Y).length} compensation coefficient${Object.keys(Y).length === 1 ? "" : "s"} in GateLab.` - }, b = ($ == null ? void 0 : $.recordType) === "baseline" && la(wn, $.scientific.matrix.matrix) ? await hr(j, $, x) : await pr( - j, - ra(j, wn), - x - ); - await o(b, Ne), Vn({}), nn({}), Be({}), sn({}), gn(null), xe(null), wt((C) => C + 1), Q.length > 0 && (_n("attention"), je(Q[0].pairKey), Tn(Q[0].pairKey)), he(i("Applied revised matrix for {name}. Original measurements and the complete compensation revision history remain available.{flagged}", { - name: zt(b.name), - flagged: Q.length > 0 ? i( - Q.length === 1 ? " Retained {count} flagged pair for post-correction review." : " Retained {count} flagged pairs for post-correction review.", - { count: Q.length } - ) : "" - })); - } catch (h) { - Ue(!0), he(h instanceof Error ? h.message : String(h)); - } finally { - Ze(!1), He(null), Ne(null); - } - }, Ai = (t) => { - if (Q.length === 0) return; - const l = Q.findIndex(({ pairKey: x }) => x === Se), p = l < 0 ? t > 0 ? 0 : Q.length - 1 : (l + t + Q.length) % Q.length, h = Q[p]; - Te(null), je(h.pairKey), Tn(h.pairKey); - }, Pt = () => /* @__PURE__ */ e.jsx( - "div", - { - className: "gl-comp-inspector-resize", - role: "separator", - "aria-label": i("Resize compensation inspector"), - "aria-orientation": "vertical", - "aria-valuemin": 360, - "aria-valuemax": 900, - "aria-valuenow": mn, - tabIndex: 0, - title: i("Drag to resize the coefficient inspector; use Left/Right arrow keys for fine control"), - onPointerDown: Ls, - onKeyDown: zs, - children: /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true" }) - } - ), Xs = (t) => { - Te(null), je(t), gt(!0), Et.some((l) => l.pairKey === t) && (Pe.some((l) => l.pairKey === t) || (Un("all"), ii("")), si(t)); - }, Kt = (t, l = !1) => { - const p = y ? jn.has(y.pairKey) : !1, h = y ? Q.find(({ pairKey: B }) => B === y.pairKey) ?? null : null, x = y ? Tt(y.pairKey, y.value) : null, b = y ? Pn(y.pairKey, y.value) : null, C = y ? Ms[y.pairKey] : null, z = y ? u.sourceAxisKeys[y.sourceIndex] : "", q = y ? u.receiverAxisKeys[y.receiverIndex] : "", L = y != null && y.interaction && y.interaction !== "self" && y.interaction !== "other" ? 1 : 0, G = y && (be != null && be.ready) ? Gt({ - coefficient: y.value, - physicalPrior: L, - evidence: be.preview.evidence - }, u.kind, ze) : null, ee = y ? aa($, z, q) : null, Re = (y == null ? void 0 : y.value) ?? null, ye = y ? Y[y.pairKey] : void 0, Nn = !!(y && (j == null ? void 0 : j.scientific.kind) === "flow-spillover" && F && Object.keys(Y).length > 0), Ve = _e.state !== "idle" && _e.state !== "error" && _e.pairKey === (y == null ? void 0 : y.pairKey) ? _e.preview : null, an = Ve ?? (be != null && be.ready ? be.preview : null), on = []; - ee !== null && Re !== null && ((j == null ? void 0 : j.recordType) === "revision" || ee !== Re) && on.push({ label: i("Baseline"), value: ee }), Re !== null && on.push({ label: i("Installed"), value: Re }), ye !== void 0 && on.push({ label: i("Staged"), value: ye }); - const ln = Q.findIndex(({ pairKey: B }) => B === Se); - return /* @__PURE__ */ e.jsxs("section", { className: `gl-comp-inspector${l ? " is-global" : ""}`, "aria-labelledby": "comp-selected-heading", children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-panel-head gl-comp-inspector-head", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("h3", { id: "comp-selected-heading", children: i("Selected coefficient") }), - !l && /* @__PURE__ */ e.jsx("span", { children: i(mt ? "Hover preview · click to pin this pair." : Se ? "Pinned pair · hover another cell to compare." : "Select a matrix cell or follow-up pair.") }) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-inspector-actions", children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-flag-navigation", "aria-label": i("Flagged compensation pair navigation"), children: [ - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - "aria-label": i("Previous flagged compensation pair"), - disabled: Q.length === 0, - onClick: () => Ai(-1), - children: "←" - } - ), - /* @__PURE__ */ e.jsx("span", { children: ln >= 0 ? i("{current} / {total} flagged", { current: ln + 1, total: Q.length }) : i("{total} flagged", { total: Q.length }) }), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - "aria-label": i("Next flagged compensation pair"), - disabled: Q.length === 0, - onClick: () => Ai(1), - children: "→" - } - ) - ] }), - t && /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn gl-comp-inspector-close", - "aria-label": i("Close global compensation pair details"), - title: i("Close details and return to the full gallery"), - onClick: t, - children: "×" - } - ) - ] }) - ] }), - y ? /* @__PURE__ */ e.jsxs("div", { className: `gl-comp-pair-detail${l ? " is-global" : ""}`, children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-pair-route", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Source channel") }), - /* @__PURE__ */ e.jsx("strong", { children: y.source.label }), - /* @__PURE__ */ e.jsx("small", { children: y.source.pnn }) - ] }), - /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true", children: "→" }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Receiver") }), - /* @__PURE__ */ e.jsx("strong", { children: y.receiver.label }), - /* @__PURE__ */ e.jsx("small", { children: y.receiver.pnn }) - ] }) - ] }), - G && /* @__PURE__ */ e.jsxs( - "div", - { - className: `gl-comp-evidence-badge is-${G.category}`, - title: i(G.detail), - children: [ - /* @__PURE__ */ e.jsx("strong", { children: i(G.label) }), - /* @__PURE__ */ e.jsx("span", { children: i(G.detail) }) - ] - } - ), - /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-followup-toggle", children: [ - /* @__PURE__ */ e.jsx( - "input", - { - type: "checkbox", - checked: p, - disabled: !j || !ie.has(u.sourceAxisKeys[y.sourceIndex]) || !ie.has(u.receiverAxisKeys[y.receiverIndex]), - onChange: (B) => Kn(y.pairKey, B.currentTarget.checked) - } - ), - /* @__PURE__ */ e.jsx("span", { children: i("Flag for follow-up") }), - /* @__PURE__ */ e.jsx("small", { children: i("Add this pair to the curated Flagged queue.") }) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-coefficient-readout", title: i("Stored fraction: {value}", { value: ne(y.value, 10) }), children: [ - /* @__PURE__ */ e.jsx("span", { children: i(Y[y.pairKey] === void 0 ? "Matrix coefficient" : "Working coefficient") }), - /* @__PURE__ */ e.jsx("strong", { children: Number.isFinite(Y[y.pairKey] ?? y.value) ? `${((Y[y.pairKey] ?? y.value) * 100).toFixed(1)}%` : String(Y[y.pairKey] ?? y.value) }) - ] }), - on.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-coefficient-history", "aria-label": i("Coefficient history"), children: on.map((B, cn) => /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-coefficient-history-step", children: [ - cn > 0 && /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true", children: "→" }), - /* @__PURE__ */ e.jsxs("div", { title: i("Exact fraction: {value}", { value: ne(B.value, 10) }), children: [ - /* @__PURE__ */ e.jsx("small", { children: B.label }), - /* @__PURE__ */ e.jsxs("strong", { children: [ - (B.value * 100).toFixed(1), - "%" - ] }) - ] }) - ] }, `${B.label}:${cn}`)) }), - j && Se === y.pairKey && !mt && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-coefficient-editor", children: [ - /* @__PURE__ */ e.jsxs("label", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Coefficient (%)") }), - /* @__PURE__ */ e.jsx( - Mn, - { - step: "0.1", - value: Bn, - disabled: V, - onValueChange: (B) => { - Nt(B), j.scientific.kind === "flow-spillover" && B.trim() !== "" && Number.isFinite(Number(B)) && On(y.pairKey, Number(B) / 100); - } - } - ) - ] }), - j.scientific.kind === "flow-spillover" ? /* @__PURE__ */ e.jsx("small", { className: "gl-comp-live-edit-hint", children: i("Type, use arrows, or drag ↕ · previews immediately") }) : /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - disabled: V || !Number.isFinite(Number(Bn)) || Bn.trim() === "", - onClick: () => On(y.pairKey, Number(Bn) / 100), - children: i("Stage value") - } - ), - Y[y.pairKey] !== void 0 && /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - disabled: V, - onClick: () => { - On(y.pairKey, y.value), nn((B) => { - const cn = { ...B }; - return delete cn[y.pairKey], cn; - }); - }, - children: i("Reset") - } - ) - ] }), - Nn && /* @__PURE__ */ e.jsxs("div", { className: `gl-comp-candidate-status${l ? " is-compact" : ""}`, "aria-label": i("Flow compensation coefficient preview"), children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("strong", { children: i("Coefficient preview") }), - /* @__PURE__ */ e.jsxs("span", { children: [ - i("Original remains fixed; the right panel shows the complete working matrix."), - l ? i(" The gallery remains installed until Apply.") : "" - ] }) - ] }), - /* @__PURE__ */ e.jsx("em", { children: ye === void 0 ? i("Working matrix") : `${(y.value * 100).toFixed(1)}% → ${(ye * 100).toFixed(1)}%` }), - _e.state === "updating" && _e.pairKey === y.pairKey && /* @__PURE__ */ e.jsx("span", { role: "status", children: i("Updating…") }), - _e.state === "error" && _e.pairKey === y.pairKey && /* @__PURE__ */ e.jsx("span", { className: "is-error", role: "alert", children: i(_e.message) }) - ] }), - y.interaction && y.interaction !== "other" && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-interaction-type", children: [ - i("Physical relationship:"), - " ", - /* @__PURE__ */ e.jsx("strong", { children: y.interaction }) - ] }), - l && (an ? /* @__PURE__ */ e.jsx( - Yi, - { - preview: an, - sourceLabel: y.source.label, - receiverLabel: y.receiver.label, - kind: u.kind, - densitySmoothing: Je, - compact: !0, - compensatedTitle: i(Ve ? "Candidate" : "Compensated") - } - ) : be && !be.ready ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-biplot-unavailable", children: i(be.reason) }) : null), - l && /* @__PURE__ */ e.jsx( - Zr, - { - matrixView: u, - sourceChannels: oe, - receiverChannels: de, - selectedSourceIndex: y.sourceIndex, - selectedReceiverIndex: y.receiverIndex, - stagedCoefficients: Y, - maximumAbsoluteOffDiagonal: wi, - onSelect: Xs - } - ), - !l && (an ? /* @__PURE__ */ e.jsx( - Yi, - { - preview: an, - sourceLabel: y.source.label, - receiverLabel: y.receiver.label, - kind: u.kind, - densitySmoothing: Je, - compensatedTitle: i(Ve ? "Candidate" : "Compensated") - } - ) : be && !be.ready ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-biplot-unavailable", children: i(be.reason) }) : null), - p && h && x && b && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-bounds-tool", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("strong", { children: i("Sweep bounds") }), - /* @__PURE__ */ e.jsx("span", { children: i("Four exact candidates will be interpolated across these endpoints.") }) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-bounds-inputs", children: [ - /* @__PURE__ */ e.jsxs("label", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Lower (%)") }), - /* @__PURE__ */ e.jsx( - Mn, - { - step: "0.1", - value: x.lowerPercent, - disabled: V || le !== null || ve !== null, - onValueChange: (B) => Qn(y.pairKey, y.value, "lowerPercent", B) - } - ) - ] }), - /* @__PURE__ */ e.jsxs("label", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Upper (%)") }), - /* @__PURE__ */ e.jsx( - Mn, - { - step: "0.1", - value: x.upperPercent, - disabled: V || le !== null || ve !== null, - onValueChange: (B) => Qn(y.pairKey, y.value, "upperPercent", B) - } - ) - ] }), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - disabled: V || le !== null || ve !== null || b.error !== null, - onClick: () => void Ws(h), - children: i(ve === y.pairKey ? "Previewing…" : "Preview endpoints") - } - ) - ] }), - b.error ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-bounds-error", children: i(b.error) }) : /* @__PURE__ */ e.jsx("small", { children: i("Fast preview: exact solver on {preview} frozen events. Screening only; the four-option sweep uses up to {sweep} events.", { - preview: Math.min(re, Ji).toLocaleString(), - sweep: Math.min(re, Xi).toLocaleString() - }) }), - C && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-bounds-preview", children: C.values.map((B) => /* @__PURE__ */ e.jsx("div", { className: B.isCurrent ? "is-current" : void 0, children: /* @__PURE__ */ e.jsx( - ht, - { - title: `${B.isCurrent ? `${i("Current")} · ` : ""}${(B.value * 100).toFixed(2)}%`, - panel: B.preview.compensated, - preview: B.preview, - sourceLabel: y.source.label, - receiverLabel: y.receiver.label, - minimumSize: 145, - maximumSize: 220, - densitySmoothing: Je - } - ) }, `${y.pairKey}:bounds:${B.value}:${B.isCurrent}`)) }) - ] }), - /* @__PURE__ */ e.jsx("p", { className: "gl-hint", children: i(u.coefficientNote) }) - ] }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-inspector-empty", children: i("No coefficient selected.") }) - ] }); - }, Ti = (t, l) => /* @__PURE__ */ e.jsx( - Hr, - { - dataset: l, - pair: t, - plotSize: At, - densitySmoothing: Je, - flagged: jn.has(t.pairKey), - selected: Se === t.pairKey, - onSelect: () => { - Te(null), je(t.pairKey), gt(!0); - }, - onFlag: (p) => Kn(t.pairKey, p) - }, - t.pairKey - ), Js = async (t, l) => { - if (!(se != null && se.ready) || !u) - throw new Error("Apply compensation before exporting the Global inspector comparison."); - const p = fi.map((h) => ({ - pairKey: h.pairKey, - sourceLabel: h.source.label, - receiverLabel: h.receiver.label, - coefficient: h.coefficient, - relationship: h.interaction, - buildPreview: () => { - const x = ls( - se.dataset, - h.source.key, - h.receiver.key - ); - if (!x.ready) throw new Error(x.reason); - return x.preview; - } - })); - await Lr(p, { - sampleName: s, - profileName: (j == null ? void 0 : j.name) ?? i(u.title), - populationName: (X == null ? void 0 : X.name) ?? i("All Events"), - filterLabel: gi, - densitySmoothing: Je, - densityColorPower: U, - pointAlpha: Jn - }, t, l); - }; - return O ? /* @__PURE__ */ e.jsx(Qt.Provider, { value: U, children: /* @__PURE__ */ e.jsx(ei.Provider, { value: Jn, children: /* @__PURE__ */ e.jsxs( - "div", - { - className: "gl-tab-panel gl-tab-fill gl-compensation-tab", - children: [ - /* @__PURE__ */ e.jsxs("div", { className: `gl-comp-overview${Me === "global" ? " is-global-scan" : ""}`, children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-overview-title", children: [ - /* @__PURE__ */ e.jsx("h2", { className: "gl-tab-title", children: i("Compensation") }), - !_ && /* @__PURE__ */ e.jsx("span", { className: "gl-comp-method", children: nt }) - ] }), - _ ? /* @__PURE__ */ e.jsxs( - "div", - { - id: "comp-profile-heading", - className: `gl-comp-profile-pill${R.state === "ready" ? " is-ready" : " is-stale"}`, - role: "status", - title: i("{source} · {method} · {count} solve channels · {status} · {assay}", { - source: tt, - method: nt, - count: It, - status: i(R.state === "ready" ? "Ready" : "Unavailable"), - assay: i(a ? "Compensated assay active" : "Original assay active") - }), - children: [ - /* @__PURE__ */ e.jsx("span", { className: `gl-comp-status-dot${R.state === "ready" ? " is-ready" : " is-stale"}`, "aria-hidden": "true" }), - /* @__PURE__ */ e.jsxs("span", { className: "gl-sr-only", children: [ - i("{kind} compensation installed. Installed compensation profile.", { - kind: _.kind === "cytof-spillover" ? "CyTOF" : "Flow" - }), - " " - ] }), - /* @__PURE__ */ e.jsx("strong", { children: Rs }), - /* @__PURE__ */ e.jsx("span", { children: i("{method} · {count} ch · {status}", { - method: nt, - count: It, - status: R.state === "ready" ? i("Ready") : i("Unavailable") - }) }), - /* @__PURE__ */ e.jsx("em", { children: i(a ? "Comp active" : "Original active") }) - ] - } - ) : /* @__PURE__ */ e.jsx( - "span", - { - className: "gl-comp-summary", - "aria-label": i("Compensation summary"), - "data-active-layer": a ? "compensated" : "original", - children: i("{source} · {assay} · {count} channels", { - source: i(yi), - assay: i(a ? "Compensated assay active" : "Original assay active"), - count: It - }) - } - ), - _ && n.instrument === "cytof" && /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn gl-comp-header-replace", - disabled: V, - onClick: Ci, - children: i("Replace matrix…") - } - ), - S !== void 0 && T !== void 0 && I && /* @__PURE__ */ e.jsxs( - "label", - { - className: "gl-comp-worker-control", - title: i("Event-parallel Apply workers. The aggregate memory budget stays fixed; more workers are not always faster."), - children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Apply workers") }), - /* @__PURE__ */ e.jsx( - "select", - { - "aria-label": i("Compensation Apply worker count"), - value: S, - disabled: V, - onChange: (t) => I(Number(t.currentTarget.value)), - children: Array.from({ length: T }, (t, l) => l + 1).map((t) => /* @__PURE__ */ e.jsx("option", { value: t, children: t }, t)) - } - ), - /* @__PURE__ */ e.jsxs("small", { children: [ - "/ ", - T - ] }) - ] - } - ), - /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-review-population", children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Review population") }), - /* @__PURE__ */ e.jsxs( - "select", - { - "aria-label": i("Compensation review population"), - value: (X == null ? void 0 : X.id) ?? "all", - disabled: le !== null || ve !== null, - onChange: (t) => vt(t.currentTarget.value), - children: [ - /* @__PURE__ */ e.jsx("option", { value: "all", children: i("All Events") }), - E.map((t) => /* @__PURE__ */ e.jsx("option", { value: t.id, children: `${"· ".repeat(t.depth)}${t.name} (${t.eventCount.toLocaleString()})` }, t.id)) - ] - } - ), - /* @__PURE__ */ e.jsx("small", { children: i("{count} events · applies to biplots, attention ranking, and sweeps; membership frozen from the current assay", { - count: re.toLocaleString() - }) }) - ] }), - Me !== "global" && /* @__PURE__ */ e.jsxs( - "label", - { - className: "gl-comp-preview-events", - title: i("Controls the frozen event set shown in the selected-pair Original and comparison biplots. Applying compensation still processes every event."), - children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Pair preview") }), - /* @__PURE__ */ e.jsxs( - "select", - { - "aria-label": i("Compensation pair preview event count"), - value: String(Yn), - disabled: V, - onChange: (t) => { - const l = t.currentTarget.value; - vs(l === "all" ? "all" : Number(l)); - }, - children: [ - es.map((t) => /* @__PURE__ */ e.jsx("option", { value: t, children: i("{count} events", { count: t.toLocaleString() }) }, t)), - /* @__PURE__ */ e.jsx("option", { value: "all", children: i("All available") }) - ] - } - ), - /* @__PURE__ */ e.jsx("small", { children: i("Showing {shown} of {total}; Apply always uses all events.", { - shown: $n.length.toLocaleString(), - total: re.toLocaleString() - }) }) - ] - } - ), - Os && /* @__PURE__ */ e.jsx("span", { className: "gl-comp-global-layer-note", children: i("Assay selection in the top bar applies to every tab.") }) - ] }), - n.instrument === "cytof" && /* @__PURE__ */ e.jsx( - "input", - { - ref: pi, - type: "file", - accept: ".csv,.tsv,.txt,text/csv,text/tab-separated-values,text/plain", - className: "gl-sr-only", - "aria-label": i("Choose CyTOF spillover matrix"), - onChange: (t) => void _s(t) - } - ), - ci && /* @__PURE__ */ e.jsx("div", { className: di ? "gl-comp-error" : "gl-comp-status", role: di ? "alert" : "status", children: i(ci) }), - n.instrument === "flow" && H && !_ && /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-flow-enable", "aria-labelledby": "comp-flow-enable-heading", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("strong", { id: "comp-flow-enable-heading", children: i(ue ? "SCE spillover matrix" : "Embedded FCS matrix") }), - /* @__PURE__ */ e.jsx("span", { children: i("Install this exact matrix as the immutable baseline to edit coefficients and preview their effect.") }) - ] }), - g && /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-gate-acknowledgement is-compact", children: [ - /* @__PURE__ */ e.jsx( - "input", - { - type: "checkbox", - checked: We, - disabled: V, - onChange: (t) => bn(t.currentTarget.checked) - } - ), - /* @__PURE__ */ e.jsx("span", { children: i("Recompute existing gate memberships in compensated coordinates.") }) - ] }), - Ie != null && Ie.error ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-error", role: "alert", children: Ie.error }) : V ? /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-flow-enable-progress", role: "status", children: [ - te ? i("Preparing editor… {percent}%", { percent: Math.round(te.fraction * 100) }) : i("Preparing editor…"), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-btn-ghost", - disabled: (te == null ? void 0 : te.phase) === "cancelling", - onClick: m, - children: i((te == null ? void 0 : te.phase) === "cancelling" ? "Cancelling…" : "Cancel") - } - ) - ] }) : /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-btn", - disabled: !o || g && !We, - onClick: () => void Bs(), - children: i("Enable matrix editing") - } - ) - ] }), - n.instrument === "cytof" && (!_ || W) && /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-cytof-import", "aria-labelledby": "comp-cytof-import-heading", children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-panel-head gl-comp-import-head", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("h3", { id: "comp-cytof-import-heading", children: i("CyTOF spillover matrix") }), - /* @__PURE__ */ e.jsx("span", { children: i("Linear counts → non-negative least squares → arcsinh display") }) - ] }), - /* @__PURE__ */ e.jsx("div", { className: "gl-comp-import-actions", children: /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: W ? "gl-btn-ghost" : "gl-btn", - disabled: V, - onClick: Ci, - children: i(W ? "Choose another matrix…" : "Import matrix…") - } - ) }) - ] }), - ui && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-error", role: "alert", children: i(ui) }), - W && ae && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-import-body", children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-import-summary", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("strong", { children: W.fileName }), - /* @__PURE__ */ e.jsx("span", { children: i("{sources} sources × {receivers} receivers", { - sources: W.matrix.sourceChannels.length, - receivers: W.matrix.receiverChannels.length - }) }) - ] }), - /* @__PURE__ */ e.jsxs("dl", { children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Exact matches") }), - /* @__PURE__ */ e.jsx("dd", { children: ae.matchedChannels.length }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Included") }), - /* @__PURE__ */ e.jsx("dd", { children: ae.includedChannels.length }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Not in FCS") }), - /* @__PURE__ */ e.jsx("dd", { children: ae.matrixOnlyChannels.length }) - ] }) - ] }) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-channel-head", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("h4", { children: i("Channels included in NNLS") }), - /* @__PURE__ */ e.jsx("span", { children: i("Exact, case-sensitive $PnN matching; unchecked channels pass through unchanged.") }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - disabled: V, - onClick: () => rn(new Set(ae.matchedChannels)), - children: i("All matched") - } - ), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - disabled: V, - onClick: () => rn(/* @__PURE__ */ new Set()), - children: i("None") - } - ) - ] }) - ] }), - /* @__PURE__ */ e.jsx("div", { className: "gl-comp-channel-grid", children: W.matrix.receiverChannels.map((t) => { - const l = ae.matchedChannels.includes(t); - return /* @__PURE__ */ e.jsxs("label", { className: l ? "" : "is-unavailable", title: l ? t : i("{channel} is not uniquely present in this FCS file", { channel: t }), children: [ - /* @__PURE__ */ e.jsx( - "input", - { - type: "checkbox", - checked: Fn.has(t), - disabled: !l || V, - onChange: (p) => Us(t, p.currentTarget.checked) - } - ), - /* @__PURE__ */ e.jsx("span", { children: _t(n, t).combined }), - !l && /* @__PURE__ */ e.jsx("small", { children: i("not matched") }) - ] }, t); - }) }), - (W.validationWarnings.length > 0 || ae.warnings.length > 0) && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-warning", role: "status", children: /* @__PURE__ */ e.jsx("span", { children: i("{count} review items: {messages}", { - count: W.validationWarnings.length + ae.warnings.length, - messages: [ - ...W.validationWarnings.map(({ message: t }) => t), - ...ae.warnings.map(({ message: t }) => t) - ].map((t) => i(t)).join(" ") - }) }) }), - ae.blockers.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-error", role: "alert", children: ae.blockers.map(({ message: t }) => i(t)).join(" ") }), - g && /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-gate-acknowledgement", children: [ - /* @__PURE__ */ e.jsx( - "input", - { - type: "checkbox", - checked: We, - disabled: V, - onChange: (t) => bn(t.currentTarget.checked) - } - ), - /* @__PURE__ */ e.jsx("span", { children: i("I understand that existing gates are retained, but their memberships will be recomputed using the compensated coordinates.") }) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-apply-row", children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-apply-copy", children: [ - /* @__PURE__ */ e.jsx("span", { children: V ? te ? i("{phase}… {percent}% ({processed} / {total} events)", { - phase: i(te.phase === "cancelling" ? "Cancelling" : te.phase === "preparing" ? "Preparing" : "Applying"), - percent: Math.round(te.fraction * 100), - processed: te.processedEvents.toLocaleString(), - total: te.totalEvents.toLocaleString() - }) : i("Preparing compensation…") : i("The Original assay is retained and can be restored at any time.") }), - /* @__PURE__ */ e.jsx("strong", { className: Ye === 0 ? "is-empty" : void 0, children: Ye === 0 ? i("No FCS files are checked. Select at least one file in Samples.") : i("Applies atomically to {files} checked FCS files · {events} total events", { - files: Ye, - events: $s.toLocaleString() - }) }) - ] }), - V ? /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-btn-ghost", - disabled: (te == null ? void 0 : te.phase) === "cancelling", - onClick: m, - children: i((te == null ? void 0 : te.phase) === "cancelling" ? "Cancelling…" : "Cancel") - } - ) : /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-btn", - disabled: !o || Ye === 0 || !ae.canApply || g && !We, - onClick: () => void qs(), - children: i("Apply NNLS compensation") - } - ) - ] }), - c.length > 0 && d && /* @__PURE__ */ e.jsxs( - "div", - { - className: "gl-comp-adopt-existing", - "aria-labelledby": "comp-adopt-existing-heading", - children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-adopt-copy", children: [ - /* @__PURE__ */ e.jsx("strong", { id: "comp-adopt-existing-heading", children: i("Use an existing SCE assay") }), - /* @__PURE__ */ e.jsx("span", { children: i("Records this matrix against data already computed in R. GateLabR will not recompute or overwrite the selected assay.") }) - ] }), - /* @__PURE__ */ e.jsxs("label", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Existing linear assay") }), - /* @__PURE__ */ e.jsx( - "select", - { - value: (Xe == null ? void 0 : Xe.id) ?? "", - disabled: V, - onChange: (t) => { - hi(t.currentTarget.value), Zn(!1); - }, - children: c.map((t) => /* @__PURE__ */ e.jsx("option", { value: t.id, children: t.label === t.id ? t.id : `${t.label} (${t.id})` }, t.id)) - } - ) - ] }), - /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-adopt-confirm", children: [ - /* @__PURE__ */ e.jsx( - "input", - { - type: "checkbox", - checked: Ct, - disabled: V, - onChange: (t) => Zn(t.currentTarget.checked) - } - ), - /* @__PURE__ */ e.jsx("span", { children: i("I confirm this assay was computed from the selected source assay using this exact matrix and channel set.") }) - ] }), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-btn-ghost", - disabled: V || !Xe || !Ct || Ye === 0 || !ae.canApply || g && !We, - onClick: () => void Vs(), - children: i("Use existing assay — no recomputation") - } - ) - ] - } - ) - ] }) - ] }), - bi && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-error", role: "alert", children: i("The embedded compensation matrix contains non-finite values and cannot be applied.") }), - vi.length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-warning", role: "status", children: [ - /* @__PURE__ */ e.jsx("span", { children: i("{count} off-diagonal coefficients are above 100%. Review the matrix source before applying it.", { - count: vi.length - }) }), - /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => ni((t) => ({ ...t, review: !0 })), children: i("Review details") }) - ] }), - _ && R.state === "stale" && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-warning", role: "status", children: i("This profile cannot be applied to the current sample context. Open the review queue for exact reasons.") }), - u && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-workspace-tabs", role: "tablist", "aria-label": i("Compensation workspace"), children: [ - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - role: "tab", - "aria-selected": Me === "matrix", - className: Me === "matrix" ? "active" : void 0, - onClick: () => { - Te(null), _n("matrix"); - }, - children: i("Matrix") - } - ), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - role: "tab", - "aria-selected": Me === "global", - className: Me === "global" ? "active" : void 0, - onClick: () => { - Te(null), _n("global"); - }, - children: i("Global inspector") - } - ), - /* @__PURE__ */ e.jsxs( - "button", - { - type: "button", - role: "tab", - "aria-selected": Me === "attention", - className: Me === "attention" ? "active" : void 0, - onClick: () => { - Te(null), _n("attention"); - }, - children: [ - i("Flagged"), - Q.length > 0 ? ` (${Q.length})` : "" - ] - } - ), - /* @__PURE__ */ e.jsxs( - "label", - { - className: "gl-comp-density-smoothing", - title: i("Blur radius for every compensation biplot; both assay layers always use the same setting"), - children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Density smooth") }), - /* @__PURE__ */ e.jsx( - "input", - { - type: "range", - min: "1", - max: "10", - step: "1", - value: Je, - "aria-label": i("Compensation biplot density smoothing"), - onChange: (t) => fs(Number(t.currentTarget.value)) - } - ), - /* @__PURE__ */ e.jsx("output", { children: Je }) - ] - } - ), - /* @__PURE__ */ e.jsxs( - "label", - { - className: "gl-comp-point-alpha", - title: i("Point opacity for every compensation biplot"), - children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Point alpha") }), - /* @__PURE__ */ e.jsx( - "input", - { - type: "range", - min: "0.1", - max: "1", - step: "0.05", - value: Jn, - "aria-label": i("Compensation biplot point alpha"), - onChange: (t) => xs(Number(t.currentTarget.value)) - } - ), - /* @__PURE__ */ e.jsx("output", { children: Jn.toFixed(2) }) - ] - } - ), - /* @__PURE__ */ e.jsx( - or, - { - className: "gl-comp-density-colour", - value: U, - onChange: Z - } - ), - Object.keys(Y).length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-staged-actions", children: [ - /* @__PURE__ */ e.jsxs("span", { children: [ - i("{count} pending edits", { count: Object.keys(Y).length }), - (j == null ? void 0 : j.scientific.kind) === "cytof-spillover" ? ` · ${i("{files} checked FCS files", { files: Ye })}` : "" - ] }), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - disabled: V, - onClick: () => { - Vn({}), nn({}), he(null); - }, - children: i("Discard") - } - ), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-btn", - disabled: V || le !== null || ve !== null || !o || (j == null ? void 0 : j.scientific.kind) === "cytof-spillover" && Ye === 0, - onClick: () => void Ys(), - children: i("Apply revised matrix") - } - ) - ] }) - ] }), - u && Me === "matrix" ? /* @__PURE__ */ e.jsxs( - "div", - { - ref: yn, - className: "gl-comp-common-path", - style: { gridTemplateColumns: `minmax(440px, 1fr) 8px ${mn}px` }, - children: [ - /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-matrix-panel", "aria-labelledby": "comp-matrix-heading", children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-panel-head gl-comp-matrix-head", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("h3", { id: "comp-matrix-heading", children: i(u.title) }), - /* @__PURE__ */ e.jsx("span", { children: i(u.subtitle) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-matrix-head-actions", children: [ - it && /* @__PURE__ */ e.jsx("span", { className: "gl-comp-inline-edit-note", children: i("Edit cells directly (%)") }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-matrix-legend", "aria-label": i("Matrix colour key"), children: [ - /* @__PURE__ */ e.jsxs("span", { children: [ - /* @__PURE__ */ e.jsx("i", { className: "is-diagonal", "aria-hidden": "true" }), - i("Diagonal (self)") - ] }), - /* @__PURE__ */ e.jsxs("span", { children: [ - /* @__PURE__ */ e.jsx("i", { className: "is-positive", "aria-hidden": "true" }), - i("Positive spill") - ] }), - /* @__PURE__ */ e.jsxs("span", { children: [ - /* @__PURE__ */ e.jsx("i", { className: "is-negative", "aria-hidden": "true" }), - i("Negative") - ] }) - ] }), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - onClick: () => oi(!0), - children: i("Export CSV…") - } - ) - ] }) - ] }), - /* @__PURE__ */ e.jsx("div", { className: "gl-comp-matrix-scroll", children: /* @__PURE__ */ e.jsxs( - "div", - { - className: `gl-comp-matrix-stage${it ? " is-flow-inline" : ""}`, - style: { - width: 112 + u.receiverAxisKeys.length * Rn - }, - children: [ - /* @__PURE__ */ e.jsx("div", { className: "gl-comp-matrix-axis gl-comp-matrix-receiver-axis", children: i("Receiver channels →") }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-matrix-body", children: [ - /* @__PURE__ */ e.jsx("div", { className: "gl-comp-matrix-axis gl-comp-matrix-source-axis", children: i("Source channels ↓") }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-matrix-labelled", children: [ - /* @__PURE__ */ e.jsx("div", { className: "gl-comp-matrix-corner", "aria-hidden": "true", children: "%" }), - /* @__PURE__ */ e.jsx( - "div", - { - className: "gl-comp-column-labels", - "aria-label": i("Receiver channel labels"), - style: { - gridTemplateColumns: `repeat(${u.receiverAxisKeys.length}, ${Rn}px)` - }, - children: de.map((t, l) => /* @__PURE__ */ e.jsx( - "div", - { - className: (y == null ? void 0 : y.receiverIndex) === l ? "is-selected" : void 0, - title: t.combined, - children: /* @__PURE__ */ e.jsx("span", { children: t.combined }) - }, - u.receiverAxisKeys[l] - )) - } - ), - /* @__PURE__ */ e.jsx( - "div", - { - className: "gl-comp-row-labels", - "aria-label": i("Source channel labels"), - style: { - gridTemplateRows: `repeat(${u.sourceAxisKeys.length}, ${Rn}px)` - }, - children: oe.map((t, l) => /* @__PURE__ */ e.jsx( - "div", - { - className: (y == null ? void 0 : y.sourceIndex) === l ? "is-selected" : void 0, - title: t.combined, - children: t.combined - }, - u.sourceAxisKeys[l] - )) - } - ), - /* @__PURE__ */ e.jsx( - "div", - { - ref: mi, - className: "gl-comp-matrix shows-values", - role: "grid", - "aria-label": i("Compensation matrix; source rows and receiver columns"), - "aria-rowcount": u.sourceAxisKeys.length, - "aria-colcount": u.receiverAxisKeys.length, - style: { - gridTemplateColumns: `repeat(${u.receiverAxisKeys.length}, ${Rn}px)`, - gridTemplateRows: `repeat(${u.sourceAxisKeys.length}, ${Rn}px)` - }, - children: u.matrix.map((t, l) => /* @__PURE__ */ e.jsx( - "div", - { - role: "row", - className: "gl-comp-matrix-row", - "aria-rowindex": l + 1, - children: t.map((p, h) => { - const x = u.sourceAxisKeys[l], b = u.receiverAxisKeys[h], C = `${x}${Oe}${b}`, z = Y[C], q = z ?? p, L = x === b, G = (y == null ? void 0 : y.sourceIndex) === l && y.receiverIndex === h, ee = (y == null ? void 0 : y.sourceIndex) === l, Re = (y == null ? void 0 : y.receiverIndex) === h, ye = oe[l], Nn = de[h], Ve = u.kind === "cytof" ? Cn(x, b) : null, an = lr( - q, - wi, - L - ), on = u.receiverAxisKeys.findIndex((pe) => pe !== x), ln = Se === C, B = Se === null && l === 0 && h === on, cn = Number.isFinite(q) ? q === 0 ? "" : (q * 100).toFixed(1) : String(q), Ii = Ve && Ve !== "other" && Ve !== "self" ? ` · ${Ve}` : "", Qs = Cs[C] ?? is(q); - return it && !L ? /* @__PURE__ */ e.jsx( - Mn, - { - role: "gridcell", - className: `gl-comp-cell gl-comp-cell-input${G ? " selected" : ""}${ln ? " is-pinned" : ""}${z === void 0 ? "" : " is-staged"}${ee ? " is-selected-source" : ""}${Re ? " is-selected-receiver" : ""}`, - min: "0", - step: "0.1", - value: Qs, - disabled: V, - "data-source-index": l, - "data-receiver-index": h, - "aria-colindex": h + 1, - "aria-selected": ln, - "aria-label": i("{source} source to {receiver} receiver coefficient, percent{pending}", { - source: ye.combined, - receiver: Nn.combined, - pending: z === void 0 ? "" : i(", pending edit") - }), - title: i("{source} → {receiver} · type or drag vertically to edit spillover percentage{pending}", { - source: ye.combined, - receiver: Nn.combined, - pending: z === void 0 ? "" : i(" · pending edit") - }), - style: an, - onFocus: () => je(C), - onMouseEnter: () => Te(C), - onMouseLeave: () => Te((pe) => pe === C ? null : pe), - onClick: () => je(C), - onValueChange: (pe) => { - je(C), nn((Dn) => ({ ...Dn, [C]: pe })), pe.trim() !== "" && Number.isFinite(Number(pe)) && On(C, Number(pe) / 100); - }, - onBlur: (pe) => { - const Dn = pe.currentTarget.value; - if (Dn.trim() === "" || !Number.isFinite(Number(Dn))) { - nn((Rt) => { - const Pi = { ...Rt }; - return delete Pi[C], Pi; - }); - return; - } - nn((Rt) => ({ - ...Rt, - [C]: is(Number(Dn) / 100) - })); - } - }, - b - ) : /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - role: "gridcell", - className: `gl-comp-cell${L ? " diagonal" : ""}${G ? " selected" : ""}${ln ? " is-pinned" : ""}${z === void 0 ? "" : " is-staged"}${ee ? " is-selected-source" : ""}${Re ? " is-selected-receiver" : ""}`, - disabled: L, - tabIndex: L ? -1 : G || B ? 0 : -1, - "data-source-index": l, - "data-receiver-index": h, - "data-interaction": Ve ?? void 0, - "aria-colindex": h + 1, - "aria-pressed": L ? void 0 : ln, - "aria-label": L ? i("{channel} diagonal: {value}", { channel: ye.combined, value: en(q) }) : i("{source} source to {receiver} receiver: {value}{pending}{interaction}", { - source: ye.combined, - receiver: Nn.combined, - value: en(q), - pending: z === void 0 ? "" : i(" (pending edit)"), - interaction: Ii - }), - title: L ? `${ye.combined} · self · ${en(q)}` : `${ye.combined} → ${Nn.combined} · ${en(q)}${z === void 0 ? "" : " · pending edit"}${Ii}`, - style: an, - onFocus: () => { - L || je(C); - }, - onMouseEnter: () => { - L || Te(C); - }, - onMouseLeave: () => Te((pe) => pe === C ? null : pe), - onClick: () => je(C), - onKeyDown: (pe) => Gs(pe, l, h), - children: /* @__PURE__ */ e.jsx("span", { children: cn }) - }, - b - ); - }) - }, - u.sourceAxisKeys[l] - )) - } - ) - ] }) - ] }) - ] - } - ) }) - ] }), - Pt(), - Kt() - ] - } - ) : u && Me === "global" ? /* @__PURE__ */ e.jsxs( - "div", - { - ref: yn, - className: `gl-comp-common-path gl-comp-global-path${An ? " has-details" : ""}`, - style: { - gridTemplateColumns: An ? `minmax(440px, 1fr) 8px ${mn}px` : "minmax(0, 1fr)" - }, - children: [ - /* @__PURE__ */ e.jsx( - Yr, - { - stateKey: D, - header: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-global-head-title", children: [ - /* @__PURE__ */ e.jsx("h3", { id: "comp-global-inspector-heading", children: i("Global data inspector") }), - /* @__PURE__ */ e.jsx( - "span", - { - className: "gl-comp-lock-pill", - title: i("The assay flip keeps the same events, axes, transform, density bins, colour scale, and tile geometry."), - children: i("View locked") - } - ) - ] }), - /* @__PURE__ */ e.jsxs( - "select", - { - "aria-label": i("Global compensation pair filter"), - title: i("Choose which channel pairs appear"), - value: Fe, - onChange: (t) => Un(t.currentTarget.value), - children: [ - /* @__PURE__ */ e.jsx("option", { value: "relevant", children: i("Matrix-linked / relevant") }), - /* @__PURE__ */ e.jsx("option", { value: "nonzero", children: i("Non-zero coefficients") }), - u.kind === "cytof" && /* @__PURE__ */ e.jsx("option", { value: "physical", children: i("Physical CyTOF relationships") }), - /* @__PURE__ */ e.jsx("option", { value: "flagged", children: i("Flagged for follow-up") }), - /* @__PURE__ */ e.jsx("option", { value: "all", children: i("All included pairs") }) - ] - } - ), - /* @__PURE__ */ e.jsxs( - "select", - { - className: "gl-comp-global-layout", - "aria-label": i("Global compensation plot layout"), - title: i("Show one compressed gallery or organise channel pairs into labelled rows"), - value: $e, - onChange: (t) => us(t.currentTarget.value), - children: [ - /* @__PURE__ */ e.jsx("option", { value: "compact", children: i("Compact gallery") }), - /* @__PURE__ */ e.jsx("option", { value: "source", children: i("Rows by source") }), - /* @__PURE__ */ e.jsx("option", { value: "receiver", children: i("Rows by receiver") }) - ] - } - ), - /* @__PURE__ */ e.jsx( - "input", - { - className: "gl-comp-global-search", - type: "search", - value: kn, - placeholder: i("Find channel…"), - "aria-label": i("Search global compensation pairs"), - onChange: (t) => ii(t.currentTarget.value) - } - ), - /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-global-size", children: [ - /* @__PURE__ */ e.jsx("span", { className: "gl-sr-only", children: i("Plot size") }), - /* @__PURE__ */ e.jsx( - "input", - { - type: "range", - min: "120", - max: "220", - step: "4", - value: At, - "aria-label": i("Global compensation plot size"), - onChange: (t) => ps(Number(t.currentTarget.value)) - } - ), - /* @__PURE__ */ e.jsx("output", { children: i("{size}px", { size: At }) }) - ] }), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn gl-comp-global-export", - disabled: !(se != null && se.ready) || Pe.length === 0, - title: i("Export the currently filtered pairs as locked Original and Compensated comparison pages"), - onClick: () => li(!0), - children: i("Export…") - } - ), - /* @__PURE__ */ e.jsx( - "span", - { - className: "gl-comp-global-count", - title: i("The Global gallery uses one fixed representative event set so every pair and both assay layers remain directly comparable."), - children: i("{pairs} pairs · {shown} / {total} events · {population}", { - pairs: Pe.length.toLocaleString(), - shown: Mt.length.toLocaleString(), - total: re.toLocaleString(), - population: (X == null ? void 0 : X.name) ?? i("All Events") - }) - } - ) - ] }), - children: se ? se.ready ? Pe.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-global-empty", children: i("No pairs match the current filter. Choose another filter or clear the channel search.") }) : $e === "compact" ? /* @__PURE__ */ e.jsx( - "div", - { - className: "gl-comp-global-gallery", - "data-event-signature": se.dataset.eventSignature, - children: Pe.map((t) => Ti(t, se.dataset)) - } - ) : /* @__PURE__ */ e.jsx( - "div", - { - className: "gl-comp-global-groups", - "data-event-signature": se.dataset.eventSignature, - "data-layout": $e, - children: kt.map((t) => /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-global-group", children: [ - /* @__PURE__ */ e.jsxs("header", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i($e === "source" ? "Source channel" : "Receiver") }), - /* @__PURE__ */ e.jsx("strong", { title: t.channel.combined, children: t.channel.label }), - /* @__PURE__ */ e.jsx("small", { children: t.channel.pnn }), - /* @__PURE__ */ e.jsx("em", { children: i("{count} pairs", { count: t.pairs.length }) }) - ] }), - /* @__PURE__ */ e.jsx("div", { className: "gl-comp-global-group-plots", children: t.pairs.map((l) => Ti(l, se.dataset)) }) - ] }, t.channel.key)) - } - ) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-global-empty", children: i(se.reason) }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-global-empty", children: i("No matrix is available for the global inspector.") }) - } - ), - An && Pt(), - An && Kt(() => gt(!1), !0) - ] - } - ) : u ? /* @__PURE__ */ e.jsxs( - "div", - { - ref: yn, - className: "gl-comp-common-path", - style: { gridTemplateColumns: `minmax(440px, 1fr) 8px ${mn}px` }, - children: [ - /* @__PURE__ */ e.jsxs("section", { className: "gl-comp-attention gl-comp-attention-panel", "aria-labelledby": "comp-attention-heading", children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-attention-head", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("h3", { id: "comp-attention-heading", children: i("Flagged pairs") }), - /* @__PURE__ */ e.jsx("p", { children: i("This is your follow-up queue. Suggestions are a population-scoped evidence screen, not a verdict and not automatically included. Exact sweeps change one coefficient at a time across four user-bounded values using the same frozen events.") }) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-attention-actions", children: [ - /* @__PURE__ */ e.jsxs("label", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Sweep workers") }), - /* @__PURE__ */ e.jsx( - "select", - { - "aria-label": i("Compensation sweep workers"), - value: bt, - disabled: le !== null || ve !== null, - onChange: (t) => yt(Number(t.currentTarget.value)), - children: Array.from({ length: ns }, (t, l) => l + 1).map((t) => /* @__PURE__ */ e.jsx("option", { value: t, children: t }, t)) - } - ) - ] }), - le ? /* @__PURE__ */ e.jsx("button", { type: "button", className: "gl-btn-ghost", onClick: Hs, children: i("Cancel sweep") }) : /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-btn", - disabled: !j || !N || Ke.length === 0 || Ft > 0 || V || ve !== null, - onClick: () => void Zs(), - children: i("Run four-value sweeps ({count})", { count: Ke.length }) - } - ) - ] }) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-attention-scope", children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Suggestions computed for {population} from up to {count} frozen events.", { - population: (X == null ? void 0 : X.name) ?? i("All Events"), - count: Math.min(re, In.length).toLocaleString() - }) }), - /* @__PURE__ */ e.jsxs("label", { className: "gl-comp-evidence-mode", children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Evidence mode") }), - /* @__PURE__ */ e.jsxs( - "select", - { - "aria-label": i("Compensation evidence mode"), - value: ze, - disabled: V || le !== null || ve !== null, - onChange: (t) => { - ys(t.currentTarget.value), wt((l) => l + 1), Be({}), sn({}), xe(null); - }, - children: [ - /* @__PURE__ */ e.jsx("option", { value: "biological", children: i("Biological sample (conservative)") }), - /* @__PURE__ */ e.jsx("option", { value: "control", children: i("Single-stain / control") }) - ] - } - ) - ] }), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - disabled: V || le !== null || ve !== null, - onClick: () => { - wt((t) => t + 1), Be({}), sn({}), xe(null), Ue(!1), he( - i(Q.length === 1 ? "Recomputed compensation suggestions for {population}. {count} flagged pair was retained." : "Recomputed compensation suggestions for {population}. {count} flagged pairs were retained.", { - population: (X == null ? void 0 : X.name) ?? i("All Events"), - count: Q.length - }) - ); - }, - children: i("Recompute suggestions") - } - ), - /* @__PURE__ */ e.jsxs("small", { children: [ - i(ze === "biological" ? "Broad positive association is excluded because co-expression and cell size can mimic spill. High-tail shapes remain control-sensitive review prompts." : "Positive residual association may enter the shortlist only because you declared suitable control data."), - " ", - i("Sweep workers are separate from full-Apply workers.") - ] }) - ] }), - le && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-sweep-progress", role: "status", "aria-live": "polite", children: [ - /* @__PURE__ */ e.jsx("progress", { max: Math.max(1, le.total), value: le.completed }), - /* @__PURE__ */ e.jsx("span", { children: i("{completed} / {total} exact candidate solves · {workers} workers", { - completed: le.completed, - total: le.total, - workers: bt - }) }) - ] }), - ai && /* @__PURE__ */ e.jsx("div", { className: "gl-comp-warning", role: "status", children: i(ai) }), - j ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-manual-followup", role: "group", "aria-label": i("Add compensation pair for follow-up"), children: [ - /* @__PURE__ */ e.jsx("strong", { children: i("Add a pair") }), - /* @__PURE__ */ e.jsxs("label", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Source channel") }), - /* @__PURE__ */ e.jsx( - "select", - { - "aria-label": i("Follow-up source channel"), - value: Ee, - onChange: (t) => { - const l = t.currentTarget.value; - ri(l), we === l && jt(u.receiverAxisKeys.find((p) => p !== l && ie.has(p)) ?? ""); - }, - children: u.sourceAxisKeys.map((t, l) => ie.has(t) ? /* @__PURE__ */ e.jsx("option", { value: t, children: oe[l].combined }, t) : null) - } - ) - ] }), - /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true", children: "→" }), - /* @__PURE__ */ e.jsxs("label", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Receiver") }), - /* @__PURE__ */ e.jsx( - "select", - { - "aria-label": i("Follow-up receiver channel"), - value: we, - onChange: (t) => jt(t.currentTarget.value), - children: u.receiverAxisKeys.map((t, l) => t !== Ee && ie.has(t) ? /* @__PURE__ */ e.jsx("option", { value: t, children: de[l].combined }, t) : null) - } - ) - ] }), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - disabled: !Ee || !we || Ee === we, - onClick: Is, - children: i("Flag for follow-up") - } - ) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-flagged-columns", children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-attention-section", children: [ - /* @__PURE__ */ e.jsx("div", { className: "gl-comp-attention-section-head", children: /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("h4", { children: i("Flagged by you ({count})", { count: Ke.length }) }), - /* @__PURE__ */ e.jsx("span", { children: i("Only these pairs are included when you run sweeps.") }) - ] }) }), - Ke.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-attention-empty", children: i("No pairs are flagged yet. Tick “Flag for follow-up” in the inspector, add a pair above, or accept a suggestion below.") }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-sweep-list", children: Ke.map((t, l) => { - const p = Ss[t.pairKey], h = Es === t.pairKey, x = Pn(t.pairKey, t.coefficient), b = Tt(t.pairKey, t.coefficient); - return /* @__PURE__ */ e.jsxs("article", { className: `gl-comp-sweep-pair${Se === t.pairKey ? " is-selected" : ""}`, children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-sweep-pair-head-row", children: [ - /* @__PURE__ */ e.jsxs( - "button", - { - type: "button", - className: "gl-comp-sweep-pair-head", - "aria-expanded": h, - onClick: () => { - je(t.pairKey), Tn(h ? null : t.pairKey); - }, - children: [ - /* @__PURE__ */ e.jsx("span", { className: "gl-comp-sweep-rank", children: l + 1 }), - /* @__PURE__ */ e.jsxs("span", { children: [ - /* @__PURE__ */ e.jsxs("strong", { children: [ - t.source.label, - " → ", - t.receiver.label - ] }), - /* @__PURE__ */ e.jsxs("small", { children: [ - t.interaction && t.interaction !== "other" ? `${t.interaction} · ` : "", - i("installed {value}%", { value: (t.coefficient * 100).toFixed(1) }) - ] }) - ] }), - /* @__PURE__ */ e.jsx("span", { children: t.evidence.status === "ready" ? i("shift {shift} MAD · slope {slope}", { - shift: ne(t.evidence.normalizedNegativeShift ?? 0, 3), - slope: ne(t.evidence.residualSlope ?? 0, 4) - }) : i("visual review · residual groups insufficient") }), - /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true", children: h ? "▾" : "▸" }) - ] - } - ), - /* @__PURE__ */ e.jsx("label", { className: "gl-comp-followup-list-toggle", title: i("Remove from follow-up queue"), children: /* @__PURE__ */ e.jsx( - "input", - { - type: "checkbox", - checked: !0, - "aria-label": i("Flag {source} to {receiver} for follow-up", { - source: t.source.label, - receiver: t.receiver.label - }), - onChange: (C) => Kn(t.pairKey, C.currentTarget.checked) - } - ) }) - ] }), - h && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-sweep-pair-body", children: [ - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-inline-bounds", children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Four values across") }), - /* @__PURE__ */ e.jsxs("label", { children: [ - i("Lower (%)"), - /* @__PURE__ */ e.jsx(Mn, { step: "0.1", value: b.lowerPercent, disabled: V || le !== null || ve !== null, onValueChange: (C) => Qn(t.pairKey, t.coefficient, "lowerPercent", C) }) - ] }), - /* @__PURE__ */ e.jsx("span", { children: i("to") }), - /* @__PURE__ */ e.jsxs("label", { children: [ - i("Upper (%)"), - /* @__PURE__ */ e.jsx(Mn, { step: "0.1", value: b.upperPercent, disabled: V || le !== null || ve !== null, onValueChange: (C) => Qn(t.pairKey, t.coefficient, "upperPercent", C) }) - ] }), - x.error && /* @__PURE__ */ e.jsx("small", { children: i(x.error) }) - ] }), - p ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-sweep-values", children: p.values.map((C) => /* @__PURE__ */ e.jsxs( - "div", - { - className: `gl-comp-sweep-value${C.isCurrent ? " is-current" : ""}${Y[t.pairKey] === C.value ? " is-staged" : ""}`, - children: [ - /* @__PURE__ */ e.jsx( - ht, - { - title: `${C.isCurrent ? `${i("Current")} · ` : ""}${(C.value * 100).toFixed(2)}%`, - panel: C.preview.compensated, - preview: C.preview, - sourceLabel: t.source.label, - receiverLabel: t.receiver.label, - minimumSize: 150, - maximumSize: 230, - densitySmoothing: Je - } - ), - /* @__PURE__ */ e.jsxs("dl", { children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Shift") }), - /* @__PURE__ */ e.jsx("dd", { children: i("{value} MAD", { value: ne(C.preview.evidence.normalizedNegativeShift ?? 0, 3) }) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Slope") }), - /* @__PURE__ */ e.jsx("dd", { children: ne(C.preview.evidence.residualSlope ?? 0, 4) }) - ] }), - u.kind === "cytof" && /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Receiver zero") }), - /* @__PURE__ */ e.jsxs("dd", { children: [ - (C.preview.compensated.zeroPile.receiver / Math.max(1, C.preview.eventCount) * 100).toFixed(1), - "%" - ] }) - ] }) - ] }), - /* @__PURE__ */ e.jsx( - "button", - { - type: "button", - className: "gl-mini-btn", - disabled: V || C.isCurrent, - onClick: () => On(t.pairKey, C.value), - children: i(C.isCurrent ? "Installed" : Y[t.pairKey] === C.value ? "Staged" : "Use this value") - } - ) - ] - }, - `${t.pairKey}:${C.value}:${C.isCurrent}` - )) }) : /* @__PURE__ */ e.jsx("p", { children: i("Set or fast-preview the endpoints in the inspector, then run the four-value exact sweep. Panels use the same events and locked axes.") }) - ] }) - ] }, t.pairKey); - }) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-attention-section gl-comp-suggestions", children: [ - /* @__PURE__ */ e.jsx("div", { className: "gl-comp-attention-section-head", children: /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsxs("h4", { children: [ - i(ze === "biological" ? "Conservative suggestions" : "Control-data suggestions"), - " (", - Ce.items.length, - ")" - ] }), - /* @__PURE__ */ e.jsx("span", { children: i("{evaluable} evaluable of {screened} screened pairs for {population}. Inspect before flagging.", { - evaluable: Ce.evaluableCount.toLocaleString(), - screened: Ce.screenedCount.toLocaleString(), - population: (X == null ? void 0 : X.name) ?? i("All Events") - }) }) - ] }) }), - Ce.items.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-attention-empty", children: i("No pair met the residual-screen evidence requirements. Manual flagging remains available.") }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-suggestion-list", children: Ce.items.map((t) => { - const l = Gt(t, u.kind, ze); - return /* @__PURE__ */ e.jsxs("article", { className: jn.has(t.pairKey) ? "is-flagged" : void 0, children: [ - /* @__PURE__ */ e.jsxs( - "button", - { - type: "button", - onClick: () => je(t.pairKey), - children: [ - /* @__PURE__ */ e.jsxs("strong", { children: [ - t.source.label, - " → ", - t.receiver.label - ] }), - /* @__PURE__ */ e.jsx("em", { className: `gl-comp-suggestion-badge is-${l.category}`, children: i(l.label) }), - /* @__PURE__ */ e.jsxs("span", { children: [ - t.interaction && t.interaction !== "other" ? `${t.interaction} · ` : "", - i("{coefficient}% · shift {shift} MAD · slope {slope}", { - coefficient: (t.coefficient * 100).toFixed(1), - shift: ne(t.evidence.normalizedNegativeShift ?? 0, 3), - slope: ne(t.evidence.residualSlope ?? 0, 4) - }) - ] }) - ] - } - ), - /* @__PURE__ */ e.jsxs("label", { children: [ - /* @__PURE__ */ e.jsx( - "input", - { - type: "checkbox", - checked: jn.has(t.pairKey), - "aria-label": i("Flag suggested {source} to {receiver} for follow-up", { - source: t.source.label, - receiver: t.receiver.label - }), - onChange: (p) => Kn(t.pairKey, p.currentTarget.checked) - } - ), - /* @__PURE__ */ e.jsx("span", { children: i("Follow up") }) - ] }) - ] }, t.pairKey); - }) }) - ] }) - ] }) - ] }) : /* @__PURE__ */ e.jsx("div", { className: "gl-comp-attention-empty", children: i("Install a profile-derived compensation layer before curating or sweeping pairs. The embedded FCS matrix remains inspectable in the Matrix view.") }) - ] }), - Pt(), - Kt() - ] - } - ) : /* @__PURE__ */ e.jsx("div", { className: "gl-tab-placeholder gl-comp-empty", children: /* @__PURE__ */ e.jsx("p", { children: i(_ ? "The compensated assay is installed, but its numerical profile record is unavailable for matrix inspection." : n.instrument === "cytof" ? "No CyTOF compensation profile is installed for this sample." : "This sample has no compatible embedded compensation matrix or imported profile.") }) }), - (u || _) && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-advanced", role: "group", "aria-label": i("Advanced compensation tools"), children: [ - /* @__PURE__ */ e.jsx("div", { className: "gl-comp-drawer-buttons", children: Jr.map(({ id: t, label: l }) => /* @__PURE__ */ e.jsxs( - "button", - { - type: "button", - id: `comp-drawer-${t}-button`, - className: "gl-comp-drawer-toggle", - "aria-expanded": zn[t], - "aria-controls": `comp-drawer-${t}`, - onClick: () => Ds(t), - children: [ - /* @__PURE__ */ e.jsxs("span", { children: [ - i(l), - t === "review" && et.length > 0 ? ` (${et.length})` : "" - ] }), - /* @__PURE__ */ e.jsx("span", { "aria-hidden": "true", children: zn[t] ? "▾" : "▸" }) - ] - }, - t - )) }), - zn.evidence && /* @__PURE__ */ e.jsxs("section", { id: "comp-drawer-evidence", role: "region", "aria-labelledby": "comp-drawer-evidence-button", className: "gl-comp-drawer-region", children: [ - /* @__PURE__ */ e.jsx("h3", { children: i("Matrix evidence") }), - _ ? j ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ - /* @__PURE__ */ e.jsxs("dl", { className: "gl-comp-evidence-grid", children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Profile ID") }), - /* @__PURE__ */ e.jsx("dd", { children: j.profileId }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Created") }), - /* @__PURE__ */ e.jsx("dd", { children: new Date(j.createdAt).toLocaleString() }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Matrix source") }), - /* @__PURE__ */ e.jsx("dd", { children: da(j, i) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Orientation") }), - /* @__PURE__ */ e.jsx("dd", { children: i("Source rows → receiver columns") }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Imported dimensions") }), - /* @__PURE__ */ e.jsx("dd", { children: i("{sources} sources × {receivers} receivers", { - sources: j.scientific.matrix.sourceChannels.length, - receivers: j.scientific.matrix.receiverChannels.length - }) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Applied solve") }), - /* @__PURE__ */ e.jsx("dd", { children: i("{count} exact $PnN channels · {status}", { - count: _.includedPnns.length, - status: R.state - }) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Matrix hash") }), - /* @__PURE__ */ e.jsxs("dd", { title: j.matrixHash, children: [ - j.matrixHash.slice(0, 19), - "…" - ] }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Profile hash") }), - /* @__PURE__ */ e.jsxs("dd", { title: j.profileHash, children: [ - j.profileHash.slice(0, 19), - "…" - ] }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Provenance") }), - /* @__PURE__ */ e.jsx("dd", { children: i(((Fi = j.provenance) == null ? void 0 : Fi.sourceDescription) ?? "No additional source note supplied") }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Estimation") }), - /* @__PURE__ */ e.jsx("dd", { children: i((($i = j.provenance) == null ? void 0 : $i.estimationMethod) ?? "Imported coefficients preserved exactly") }) - ] }) - ] }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-method-card", "aria-label": i("Installed compensation method"), children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Pipeline") }), - /* @__PURE__ */ e.jsx("strong", { children: i(j.scientific.kind === "cytof-spillover" ? "Original counts → NNLS → Compensated counts → arcsinh display" : "Original values → linear matrix inverse → Compensated values → display transform") }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("span", { children: i("Solver") }), - /* @__PURE__ */ e.jsx("strong", { children: j.scientific.solverVersion }), - /* @__PURE__ */ e.jsx("small", { children: j.scientific.solverSettings.map(({ key: t, value: l }) => `${t}=${String(l)}`).join(" · ") }) - ] }) - ] }), - Ae && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-impact", "aria-label": i("Original versus Compensated preview"), children: [ - /* @__PURE__ */ e.jsx("div", { className: "gl-comp-impact-head", children: /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("h4", { children: i("Original → Compensated impact") }), - /* @__PURE__ */ e.jsx("span", { children: i("Deterministic preview of {events} evenly spaced events across {channels} solve channels", { - events: Ae.previewEvents.toLocaleString(), - channels: _.includedPnns.length - }) }) - ] }) }), - /* @__PURE__ */ e.jsxs("dl", { children: [ - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Values changed") }), - /* @__PURE__ */ e.jsxs("dd", { children: [ - Ae.changedValues.toLocaleString(), - " / ", - Ae.comparedValues.toLocaleString(), - " (", - en(Ae.changedValues / Ae.comparedValues, !1, 4), - ")" - ] }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Median |Δ|") }), - /* @__PURE__ */ e.jsx("dd", { children: ne(Ae.medianAbsoluteDelta, 5) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Maximum |Δ|") }), - /* @__PURE__ */ e.jsx("dd", { children: ne(Ae.maxAbsoluteDelta, 5) }) - ] }), - /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Largest median shift") }), - /* @__PURE__ */ e.jsxs("dd", { title: Ae.mostChangedChannel, children: [ - Ae.mostChangedChannel, - " · ", - ne(Ae.mostChangedChannelMedianDelta, 5) - ] }) - ] }), - _.kind === "cytof-spillover" && /* @__PURE__ */ e.jsxs("div", { children: [ - /* @__PURE__ */ e.jsx("dt", { children: i("Negative → zero") }), - /* @__PURE__ */ e.jsx("dd", { children: i("{count} preview values", { count: Ae.zeroedNegativeValues.toLocaleString() }) }) - ] }) - ] }) - ] }) - ] }) : /* @__PURE__ */ e.jsx("p", { children: i("{profile} · {method} · {count} exact $PnN channel bindings · {status}. The numerical profile record is not available in this live workspace state.", { - profile: _.profileId, - method: nt, - count: _.includedPnns.length, - status: R.state - }) }) : /* @__PURE__ */ e.jsx("p", { children: i("Embedded $SPILLOVER · {channels} matched channels · {warnings} coefficient warnings.", { - channels: H.channels.length, - warnings: $t.length || i("no") - }) }) - ] }), - zn.review && /* @__PURE__ */ e.jsxs("section", { id: "comp-drawer-review", role: "region", "aria-labelledby": "comp-drawer-review-button", className: "gl-comp-drawer-region", children: [ - /* @__PURE__ */ e.jsx("h3", { children: i("Review queue") }), - /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-review-section", children: [ - /* @__PURE__ */ e.jsx("h4", { children: i("Matrix integrity") }), - et.length > 0 ? /* @__PURE__ */ e.jsx("ul", { children: et.map((t) => /* @__PURE__ */ e.jsx("li", { children: i(t) }, t)) }) : /* @__PURE__ */ e.jsx("p", { children: i("No matrix-level items currently require review.") }) - ] }), - R.state === "ready" && u && /* @__PURE__ */ e.jsxs("div", { className: "gl-comp-review-section", children: [ - /* @__PURE__ */ e.jsx("h4", { children: i("Residual-evidence shortlist") }), - /* @__PURE__ */ e.jsx("p", { children: i("Relative ranking of {screened}{candidateSuffix} non-zero or physically plausible pairs. It combines receiver-negative population shift, robust residual slope, upper-tail departure{zeroSuffix}.{modeNote} A high rank is a prompt to inspect, not proof that a coefficient is wrong.", { - screened: Ce.screenedCount.toLocaleString(), - candidateSuffix: Ce.candidateCount > Ce.screenedCount ? i(" of {count}", { count: Ce.candidateCount.toLocaleString() }) : "", - zeroSuffix: u.kind === "cytof" ? i(", and new exact-zero pile") : "", - modeNote: i(ze === "biological" ? " Broad positive association is excluded because biological co-expression and cell size can mimic spill." : " Positive residual association is enabled because control-data mode is active.") - }) }), - Ce.items.length > 0 ? /* @__PURE__ */ e.jsx("div", { className: "gl-comp-review-candidates", children: Ce.items.map((t) => /* @__PURE__ */ e.jsxs( - "button", - { - type: "button", - onClick: () => Ei(t.sourceIndex, t.receiverIndex), - children: [ - /* @__PURE__ */ e.jsxs("span", { children: [ - /* @__PURE__ */ e.jsxs("strong", { children: [ - t.source.label, - " → ", - t.receiver.label - ] }), - /* @__PURE__ */ e.jsxs("small", { children: [ - t.interaction && t.interaction !== "other" ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ - t.interaction, - " · " - ] }) : null, - i("matrix {value}%", { value: (t.coefficient * 100).toFixed(1) }) - ] }) - ] }), - /* @__PURE__ */ e.jsxs("span", { children: [ - i("shift {shift} MAD · slope {slope}", { - shift: ne(t.evidence.normalizedNegativeShift ?? 0, 3), - slope: ne(t.evidence.residualSlope ?? 0, 4) - }), - u.kind === "cytof" ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ - " ", - i("· zero Δ {value} pp", { value: `${t.evidence.receiverZeroDeltaFraction >= 0 ? "+" : ""}${(t.evidence.receiverZeroDeltaFraction * 100).toFixed(1)}` }) - ] }) : null - ] }) - ] - }, - t.pairKey - )) }) : /* @__PURE__ */ e.jsx("p", { children: i("No pair had enough source-high, source-low, and receiver-negative events for this conservative screen. Visual inspection remains available from the matrix.") }) - ] }) - ] }) - ] }), - ks && u && /* @__PURE__ */ e.jsx( - Br, - { - profileLabel: (j == null ? void 0 : j.name) ?? (ue ? "SCE_spillover" : "embedded_FCS"), - installedLabel: i( - j ? "Installed matrix" : ue ? "SCE spillover matrix" : "Embedded FCS matrix" - ), - installedMatrix: { - sourceChannels: u.sourceAxisKeys, - receiverChannels: u.receiverAxisKeys, - matrix: u.matrix - }, - workingMatrix: Ps, - pendingEditCount: Object.keys(Y).length, - onClose: () => oi(!1) - } - ), - As && /* @__PURE__ */ e.jsx( - _r, - { - sampleName: s, - populationName: (X == null ? void 0 : X.name) ?? i("All Events"), - filterLabel: gi, - pairCount: fi.length, - onExport: Js, - onClose: () => li(!1) - } - ) - ] - } - ) }) }) : /* @__PURE__ */ e.jsx( - "div", - { - className: "gl-tab-panel gl-tab-fill gl-compensation-tab", - style: { display: "none" }, - "aria-hidden": "true", - "data-compensation-dormant": "true" - } - ); -} -function pa(n, s) { - const r = n.visible !== !1, a = s.visible !== !1; - return r || a ? !1 : n.sample === s.sample && n.stateKey === s.stateKey; -} -const ga = M.memo(ha, pa); -export { - ga as CompensationTab -}; diff --git a/inst/react-app/LayoutTab-CpH5UPAY.js b/inst/react-app/LayoutTab-CpH5UPAY.js new file mode 100644 index 0000000..2ba3b8f --- /dev/null +++ b/inst/react-app/LayoutTab-CpH5UPAY.js @@ -0,0 +1,13386 @@ +import { a as st, o as Xn, q as ec, s as rc, z as Io, t as nc, w as Gs, x as Ya, y as ac, A as ic, B as Ln, E as Fs, G as oc, H as re, j as E, I as Hr, J as br, K as sc, u as Si, L as lc, M as Ro, N as uc, O as De, P as cc, S as Po, Q as Ca, R as fc, T as dc, U as Oo, V as pc, W as En, X as vc, Y as hc, Z as gc, _ as mc, $ as zo, a0 as xc, a1 as yc, a2 as bc, a3 as Sc, a4 as Cc, a5 as Ec, a6 as Dc, a7 as Ao, a8 as wc, a9 as _c, aa as Mc, l as No, ab as kc, ac as Tc, ad as Ic, ae as Bo } from "./embed-8iuCsEkz.js"; +function Ci(t, e) { + for (var r = t.length, n = 0; n < r; ++n) + if (e(t[n], n)) + return !0; + return !1; +} +function Ls(t, e) { + for (var r = t.length, n = 0; n < r; ++n) + if (e(t[n], n)) + return t[n]; + return null; +} +function Ws(t) { + var e = t; + if (typeof e > "u") { + if (typeof navigator > "u" || !navigator) + return ""; + e = navigator.userAgent || ""; + } + return e.toLowerCase(); +} +function Ei(t, e) { + try { + return new RegExp(t, "g").exec(e); + } catch { + return null; + } +} +function Rc() { + if (typeof navigator > "u" || !navigator || !navigator.userAgentData) + return !1; + var t = navigator.userAgentData, e = t.brands || t.uaList; + return !!(e && e.length); +} +function Pc(t, e) { + var r = Ei("(" + t + ")((?:\\/|\\s|:)([0-9|\\.|_]+))", e); + return r ? r[3] : ""; +} +function Xa(t) { + return t.replace(/_/g, "."); +} +function qr(t, e) { + var r = null, n = "-1"; + return Ci(t, function(a) { + var i = Ei("(" + a.test + ")((?:\\/|\\s|:)([0-9|\\.|_]+))?", e); + return !i || a.brand ? !1 : (r = a, n = i[3] || "-1", a.versionAlias ? n = a.versionAlias : a.versionTest && (n = Pc(a.versionTest.toLowerCase(), e) || n), n = Xa(n), !0); + }), { + preset: r, + version: n + }; +} +function Dn(t, e) { + var r = { + brand: "", + version: "-1" + }; + return Ci(t, function(n) { + var a = Ys(e, n); + return a ? (r.brand = n.id, r.version = n.versionAlias || a.version, r.version !== "-1") : !1; + }), r; +} +function Ys(t, e) { + return Ls(t, function(r) { + var n = r.brand; + return Ei("" + e.test, n.toLowerCase()); + }); +} +var Xs = [{ + test: "phantomjs", + id: "phantomjs" +}, { + test: "whale", + id: "whale" +}, { + test: "edgios|edge|edg", + id: "edge" +}, { + test: "msie|trident|windows phone", + id: "ie", + versionTest: "iemobile|msie|rv" +}, { + test: "miuibrowser", + id: "miui browser" +}, { + test: "samsungbrowser", + id: "samsung internet" +}, { + test: "samsung", + id: "samsung internet", + versionTest: "version" +}, { + test: "chrome|crios", + id: "chrome" +}, { + test: "firefox|fxios", + id: "firefox" +}, { + test: "android", + id: "android browser", + versionTest: "version" +}, { + test: "safari|iphone|ipad|ipod", + id: "safari", + versionTest: "version" +}], Hs = [{ + test: "(?=.*applewebkit/(53[0-7]|5[0-2]|[0-4]))(?=.*\\schrome)", + id: "chrome", + versionTest: "chrome" +}, { + test: "chromium", + id: "chrome" +}, { + test: "whale", + id: "chrome", + versionAlias: "-1", + brand: !0 +}], Ha = [{ + test: "applewebkit", + id: "webkit", + versionTest: "applewebkit|safari" +}], qs = [{ + test: "(?=(iphone|ipad))(?!(.*version))", + id: "webview" +}, { + test: "(?=(android|iphone|ipad))(?=.*(naver|daum|; wv))", + id: "webview" +}, { + // test webview + test: "webview", + id: "webview" +}], Vs = [{ + test: "windows phone", + id: "windows phone" +}, { + test: "windows 2000", + id: "window", + versionAlias: "5.0" +}, { + test: "windows nt", + id: "window" +}, { + test: "win32|windows", + id: "window" +}, { + test: "iphone|ipad|ipod", + id: "ios", + versionTest: "iphone os|cpu os" +}, { + test: "macos|macintel|mac os x", + id: "mac" +}, { + test: "android|linux armv81", + id: "android" +}, { + test: "tizen", + id: "tizen" +}, { + test: "webos|web0s", + id: "webos" +}]; +function $s(t) { + return !!qr(qs, t).preset; +} +function Oc(t) { + var e = Ws(t), r = !!/mobi/g.exec(e), n = { + name: "unknown", + version: "-1", + majorVersion: -1, + webview: $s(e), + chromium: !1, + chromiumVersion: "-1", + webkit: !1, + webkitVersion: "-1" + }, a = { + name: "unknown", + version: "-1", + majorVersion: -1 + }, i = qr(Xs, e), o = i.preset, s = i.version, l = qr(Vs, e), u = l.preset, c = l.version, f = qr(Hs, e); + if (n.chromium = !!f.preset, n.chromiumVersion = f.version, !n.chromium) { + var d = qr(Ha, e); + n.webkit = !!d.preset, n.webkitVersion = d.version; + } + return u && (a.name = u.id, a.version = c, a.majorVersion = parseInt(c, 10)), o && (n.name = o.id, n.version = s, n.webview && a.name === "ios" && n.name !== "safari" && (n.webview = !1)), n.majorVersion = parseInt(n.version, 10), { + browser: n, + os: a, + isMobile: r, + isHints: !1 + }; +} +function zc(t) { + var e = navigator.userAgentData, r = (e.uaList || e.brands).slice(), n = e.mobile || !1, a = r[0], i = (e.platform || navigator.platform).toLowerCase(), o = { + name: a.brand, + version: a.version, + majorVersion: -1, + webkit: !1, + webkitVersion: "-1", + chromium: !1, + chromiumVersion: "-1", + webview: !!Dn(qs, r).brand || $s(Ws()) + }, s = { + name: "unknown", + version: "-1", + majorVersion: -1 + }; + o.webkit = !o.chromium && Ci(Ha, function(d) { + return Ys(r, d); + }); + var l = Dn(Hs, r); + if (o.chromium = !!l.brand, o.chromiumVersion = l.version || "-1", !o.chromium) { + var u = Dn(Ha, r); + o.webkit = !!u.brand, o.webkitVersion = u.version || "-1"; + } + var c = Ls(Vs, function(d) { + return new RegExp("" + d.test, "g").exec(i); + }); + s.name = c ? c.id : ""; + { + var f = Dn(Xs, r); + o.name = f.brand || o.name, o.version = f.brand && t ? t.uaFullVersion : f.version; + } + return o.webkit && (s.name = n ? "ios" : "mac"), s.name === "ios" && o.webview && (o.version = "-1"), s.version = Xa(s.version), o.version = Xa(o.version), s.majorVersion = parseInt(s.version, 10), o.majorVersion = parseInt(o.version, 10), { + browser: o, + os: s, + isMobile: n, + isHints: !0 + }; +} +function Ac(t) { + return Rc() ? zc() : Oc(t); +} +function Nc(t) { + for (var e = [], r = 1; r < arguments.length; r++) + e[r - 1] = arguments[r]; + return e.map(function(n) { + return n.split(" ").map(function(a) { + return a ? "" + t + a : ""; + }).join(" "); + }).join(" "); +} +function Bc(t, e) { + return e.replace(/([^}{]*){/gm, function(r, n) { + return n.replace(/\.([^{,\s\d.]+)/g, "." + t + "$1") + "{"; + }); +} +function qe(t, e) { + return function(r) { + r && (t[e] = r); + }; +} +function Us(t, e, r) { + return function(n) { + n && (t[e][r] = n); + }; +} +function jc(t, e) { + return function(r) { + var n = r.prototype; + t.forEach(function(a) { + e(n, a); + }); + }; +} +function Ks(t, e) { + return e === void 0 && (e = {}), function(r, n) { + t.forEach(function(a) { + var i = e[a] || a; + i in r || (r[i] = function() { + for (var o, s = [], l = 0; l < arguments.length; l++) + s[l] = arguments[l]; + var u = (o = this[n])[a].apply(o, s); + return u === this[n] ? this : u; + }); + }); + }; +} +var Gc = "function", Fc = "object", Lc = "string", Wc = "number", Di = "undefined", Zs = typeof window !== Di, Yc = typeof document !== Di && document, Xc = [{ + open: "(", + close: ")" +}, { + open: '"', + close: '"' +}, { + open: "'", + close: "'" +}, { + open: '\\"', + close: '\\"' +}, { + open: "\\'", + close: "\\'" +}], Ut = 1e-7, wn = { + cm: function(t) { + return t * 96 / 2.54; + }, + mm: function(t) { + return t * 96 / 254; + }, + in: function(t) { + return t * 96; + }, + pt: function(t) { + return t * 96 / 72; + }, + pc: function(t) { + return t * 96 / 6; + }, + "%": function(t, e) { + return t * e / 100; + }, + vw: function(t, e) { + return e === void 0 && (e = window.innerWidth), t / 100 * e; + }, + vh: function(t, e) { + return e === void 0 && (e = window.innerHeight), t / 100 * e; + }, + vmax: function(t, e) { + return e === void 0 && (e = Math.max(window.innerWidth, window.innerHeight)), t / 100 * e; + }, + vmin: function(t, e) { + return e === void 0 && (e = Math.min(window.innerWidth, window.innerHeight)), t / 100 * e; + } +}; +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +function Hc() { + for (var t = 0, e = 0, r = arguments.length; e < r; e++) t += arguments[e].length; + for (var n = Array(t), a = 0, e = 0; e < r; e++) for (var i = arguments[e], o = 0, s = i.length; o < s; o++, a++) n[a] = i[o]; + return n; +} +function Hn(t, e, r, n) { + return (t * n + e * r) / (r + n); +} +function wi(t) { + return typeof t === Di; +} +function pe(t) { + return t && typeof t === Fc; +} +function Yt(t) { + return Array.isArray(t); +} +function be(t) { + return typeof t === Lc; +} +function nn(t) { + return typeof t === Wc; +} +function oa(t) { + return typeof t === Gc; +} +function qc(t, e) { + var r = t === "" || t == " ", n = e === "" || e == " "; + return n && r || t === e; +} +function Js(t, e, r, n, a) { + var i = _i(t, e, r); + return i ? r : Vc(t, e, r + 1, n, a); +} +function _i(t, e, r) { + if (!t.ignore) + return null; + var n = e.slice(Math.max(r - 3, 0), r + 3).join(""); + return new RegExp(t.ignore).exec(n); +} +function Vc(t, e, r, n, a) { + for (var i = function(u) { + var c = e[u].trim(); + if (c === t.close && !_i(t, e, u)) + return { + value: u + }; + var f = u, d = ve(a, function(p) { + var h = p.open; + return h === c; + }); + if (d && (f = Js(d, e, u, n, a)), f === -1) + return o = u, "break"; + u = f, o = u; + }, o, s = r; s < n; ++s) { + var l = i(s); + if (s = o, typeof l == "object") return l.value; + if (l === "break") break; + } + return -1; +} +function Mi(t, e) { + var r = be(e) ? { + separator: e + } : e, n = r.separator, a = n === void 0 ? "," : n, i = r.isSeparateFirst, o = r.isSeparateOnlyOpenClose, s = r.isSeparateOpenClose, l = s === void 0 ? o : s, u = r.openCloseCharacters, c = u === void 0 ? Xc : u, f = c.map(function(_) { + var M = _.open, T = _.close; + return M === T ? M : M + "|" + T; + }).join("|"), d = "(\\s*" + a + "\\s*|" + f + "|\\s+)", p = new RegExp(d, "g"), h = t.split(p).filter(function(_) { + return _ && _ !== "undefined"; + }), g = h.length, x = [], y = []; + function b() { + return y.length ? (x.push(y.join("")), y = [], !0) : !1; + } + for (var C = function(_) { + var M = h[_].trim(), T = _, k = ve(c, function(R) { + var B = R.open; + return B === M; + }), A = ve(c, function(R) { + var B = R.close; + return B === M; + }); + if (k) { + if (T = Js(k, h, _, g, c), T !== -1 && l) + return b() && i || (x.push(h.slice(_, T + 1).join("")), _ = T, i) ? (S = _, "break") : (S = _, "continue"); + } else if (A && !_i(A, h, _)) { + var z = Hc(c); + return z.splice(c.indexOf(A), 1), { + value: Mi(t, { + separator: a, + isSeparateFirst: i, + isSeparateOnlyOpenClose: o, + isSeparateOpenClose: l, + openCloseCharacters: z + }) + }; + } else if (qc(M, a) && !o) + return b(), i ? (S = _, "break") : (S = _, "continue"); + T === -1 && (T = g - 1), y.push(h.slice(_, T + 1).join("")), _ = T, S = _; + }, S, w = 0; w < g; ++w) { + var v = C(w); + if (w = S, typeof v == "object") return v.value; + if (v === "break") break; + } + return y.length && x.push(y.join("")), x; +} +function Ve(t) { + return Mi(t, ""); +} +function ir(t) { + return Mi(t, ","); +} +function Qs(t) { + var e = /([^(]*)\(([\s\S]*)\)([\s\S]*)/g.exec(t); + return !e || e.length < 4 ? {} : { + prefix: e[1], + value: e[2], + suffix: e[3] + }; +} +function or(t) { + var e = /^([^\d|e|\-|\+]*)((?:\d|\.|-|e-|e\+)+)(\S*)$/g.exec(t); + if (!e) + return { + prefix: "", + unit: "", + value: NaN + }; + var r = e[1], n = e[2], a = e[3]; + return { + prefix: r, + unit: a, + value: parseFloat(n) + }; +} +function qa(t) { + return t.replace(/[\s-_]+([^\s-_])/g, function(e, r) { + return r.toUpperCase(); + }); +} +function $c(t, e) { + return t.replace(/([a-z])([A-Z])/g, function(r, n, a) { + return "" + n + e + a.toLowerCase(); + }); +} +function an() { + return Date.now ? Date.now() : (/* @__PURE__ */ new Date()).getTime(); +} +function Ge(t, e, r) { + r === void 0 && (r = -1); + for (var n = t.length, a = 0; a < n; ++a) + if (e(t[a], a, t)) + return a; + return r; +} +function ve(t, e, r) { + var n = Ge(t, e); + return n > -1 ? t[n] : r; +} +var tl = /* @__PURE__ */ (function() { + var t = an(), e = Zs && (window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame); + return e ? e.bind(window) : function(r) { + var n = an(), a = setTimeout(function() { + r(n - t); + }, 1e3 / 60); + return a; + }; +})(), Uc = /* @__PURE__ */ (function() { + var t = Zs && (window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.msCancelAnimationFrame); + return t ? t.bind(window) : function(e) { + clearTimeout(e); + }; +})(); +function Nr(t) { + return Object.keys(t); +} +function Rt(t, e) { + var r = or(t), n = r.value, a = r.unit; + if (pe(e)) { + var i = e[a]; + if (i) { + if (oa(i)) + return i(n); + if (wn[a]) + return wn[a](n, i); + } + } else if (a === "%") + return n * e / 100; + return wn[a] ? wn[a](n) : n; +} +function qn(t, e, r) { + return Math.max(e, Math.min(t, r)); +} +function jo(t, e, r, n) { + return n === void 0 && (n = t[0] / t[1]), [[gt(e[0], Ut), gt(e[0] / n, Ut)], [gt(e[1] * n, Ut), gt(e[1], Ut)]].filter(function(a) { + return a.every(function(i, o) { + var s = e[o], l = gt(s, Ut); + return r ? i <= s || i <= l : i >= s || i >= l; + }); + })[0] || t; +} +function ki(t, e, r, n) { + if (!n) + return t.map(function(p, h) { + return qn(p, e[h], r[h]); + }); + var a = t[0], i = t[1], o = n === !0 ? a / i : n, s = jo(t, e, !1, o), l = s[0], u = s[1], c = jo(t, r, !0, o), f = c[0], d = c[1]; + return a < l || i < u ? (a = l, i = u) : (a > f || i > d) && (a = f, i = d), [a, i]; +} +function Kc(t) { + for (var e = t.length, r = 0, n = e - 1; n >= 0; --n) + r += t[n]; + return r; +} +function Va(t) { + for (var e = t.length, r = 0, n = e - 1; n >= 0; --n) + r += t[n]; + return e ? r / e : 0; +} +function Xt(t, e) { + var r = e[0] - t[0], n = e[1] - t[1], a = Math.atan2(n, r); + return a >= 0 ? a : a + Math.PI * 2; +} +function Zc(t) { + return [0, 1].map(function(e) { + return Va(t.map(function(r) { + return r[e]; + })); + }); +} +function Go(t) { + var e = Zc(t), r = Xt(e, t[0]), n = Xt(e, t[1]); + return r < n && n - r < Math.PI || r > n && n - r < -Math.PI ? 1 : -1; +} +function Re(t, e) { + return Math.sqrt(Math.pow((e ? e[0] : 0) - t[0], 2) + Math.pow((e ? e[1] : 0) - t[1], 2)); +} +function gt(t, e) { + if (!e) + return t; + var r = 1 / e; + return Math.round(t / e) / r; +} +function Fo(t, e) { + return t.forEach(function(r, n) { + t[n] = gt(t[n], e); + }), t; +} +function Jc(t) { + for (var e = [], r = 0; r < t; ++r) + e.push(r); + return e; +} +function Qc(t) { + return t.reduce(function(e, r) { + return e.concat(r); + }, []); +} +function Kt(t, e) { + return t.classList ? t.classList.contains(e) : !!t.className.match(new RegExp("(\\s|^)" + e + "(\\s|$)")); +} +function Ti(t, e) { + t.classList ? t.classList.add(e) : t.className += " " + e; +} +function el(t, e) { + if (t.classList) + t.classList.remove(e); + else { + var r = new RegExp("(\\s|^)" + e + "(\\s|$)"); + t.className = t.className.replace(r, " "); + } +} +function $t(t, e, r, n) { + t.addEventListener(e, r, n); +} +function Wt(t, e, r, n) { + t.removeEventListener(e, r, n); +} +function _e(t) { + return (t == null ? void 0 : t.ownerDocument) || Yc; +} +function Ii(t) { + return _e(t).documentElement; +} +function Ke(t) { + return _e(t).body; +} +function xe(t) { + var e; + return ((e = t == null ? void 0 : t.ownerDocument) === null || e === void 0 ? void 0 : e.defaultView) || window; +} +function rl(t) { + return t && "postMessage" in t && "blur" in t && "self" in t; +} +function on(t) { + return pe(t) && t.nodeName && t.nodeType && "ownerDocument" in t; +} +function tf(t, e, r, n, a, i) { + for (var o = 0; o < a; ++o) { + var s = r + o * a, l = n + o * a; + t[s] += t[l] * i, e[s] += e[l] * i; + } +} +function ef(t, e, r, n, a) { + for (var i = 0; i < a; ++i) { + var o = r + i * a, s = n + i * a, l = t[o], u = e[o]; + t[o] = t[s], t[s] = l, e[o] = e[s], e[s] = u; + } +} +function rf(t, e, r, n, a) { + for (var i = 0; i < n; ++i) { + var o = r + i * n; + t[o] /= a, e[o] /= a; + } +} +function nl(t, e, r) { + for (var n = t.slice(), a = 0; a < r; ++a) + n[a * r + e - 1] = 0, n[(e - 1) * r + a] = 0; + return n[(e - 1) * (r + 1)] = 1, n; +} +function ke(t, e) { + e === void 0 && (e = Math.sqrt(t.length)); + for (var r = t.slice(), n = At(e), a = 0; a < e; ++a) { + var i = e * a + a; + if (!gt(r[i], Ut)) { + for (var o = a + 1; o < e; ++o) + if (r[e * a + o]) { + ef(r, n, a, o, e); + break; + } + } + if (!gt(r[i], Ut)) + return []; + rf(r, n, a, e, r[i]); + for (var o = 0; o < e; ++o) { + var s = o, l = o + a * e, u = r[l]; + !gt(u, Ut) || a === o || tf(r, n, s, a, e, -u); + } + } + return n; +} +function nf(t, e) { + e === void 0 && (e = Math.sqrt(t.length)); + for (var r = [], n = 0; n < e; ++n) + for (var a = 0; a < e; ++a) + r[a * e + n] = t[e * n + a]; + return r; +} +function al(t, e) { + e === void 0 && (e = Math.sqrt(t.length)); + for (var r = [], n = t[e * e - 1], a = 0; a < e - 1; ++a) + r[a] = t[e * (e - 1) + a] / n; + return r[e - 1] = 0, r; +} +function af(t, e) { + for (var r = At(e), n = 0; n < e - 1; ++n) + r[e * (e - 1) + n] = t[n] || 0; + return r; +} +function sr(t, e) { + for (var r = t.slice(), n = t.length; n < e - 1; ++n) + r[n] = 0; + return r[e - 1] = 1, r; +} +function Te(t, e, r) { + if (e === void 0 && (e = Math.sqrt(t.length)), e === r) + return t; + for (var n = At(r), a = Math.min(e, r), i = 0; i < a - 1; ++i) { + for (var o = 0; o < a - 1; ++o) + n[i * r + o] = t[i * e + o]; + n[(i + 1) * r - 1] = t[(i + 1) * e - 1], n[(r - 1) * r + i] = t[(e - 1) * e + i]; + } + return n[r * r - 1] = t[e * e - 1], n; +} +function Vn(t) { + for (var e = [], r = 1; r < arguments.length; r++) + e[r - 1] = arguments[r]; + var n = At(t); + return e.forEach(function(a) { + n = Pt(n, a, t); + }), n; +} +function Pt(t, e, r) { + r === void 0 && (r = Math.sqrt(t.length)); + var n = [], a = t.length / r, i = e.length / a; + if (a) { + if (!i) + return t; + } else return e; + for (var o = 0; o < r; ++o) + for (var s = 0; s < i; ++s) { + n[s * r + o] = 0; + for (var l = 0; l < a; ++l) + n[s * r + o] += t[l * r + o] * e[s * a + l]; + } + return n; +} +function wt(t, e) { + for (var r = Math.min(t.length, e.length), n = t.slice(), a = 0; a < r; ++a) + n[a] = n[a] + e[a]; + return n; +} +function ct(t, e) { + for (var r = Math.min(t.length, e.length), n = t.slice(), a = 0; a < r; ++a) + n[a] = n[a] - e[a]; + return n; +} +function of(t, e) { + return e === void 0 && (e = t.length === 6), e ? [t[0], t[1], 0, t[2], t[3], 0, t[4], t[5], 1] : t; +} +function il(t, e) { + return e === void 0 && (e = t.length === 9), e ? [t[0], t[1], t[3], t[4], t[6], t[7]] : t; +} +function ne(t, e, r) { + r === void 0 && (r = e.length); + var n = Pt(t, e, r), a = n[r - 1]; + return n.map(function(i) { + return i / a; + }); +} +function sf(t, e) { + return Pt(t, [1, 0, 0, 0, 0, Math.cos(e), Math.sin(e), 0, 0, -Math.sin(e), Math.cos(e), 0, 0, 0, 0, 1], 4); +} +function lf(t, e) { + return Pt(t, [Math.cos(e), 0, -Math.sin(e), 0, 0, 1, 0, 0, Math.sin(e), 0, Math.cos(e), 0, 0, 0, 0, 1], 4); +} +function uf(t, e) { + return Pt(t, cn(e, 4)); +} +function _n(t, e) { + var r = e[0], n = r === void 0 ? 1 : r, a = e[1], i = a === void 0 ? 1 : a, o = e[2], s = o === void 0 ? 1 : o; + return Pt(t, [n, 0, 0, 0, 0, i, 0, 0, 0, 0, s, 0, 0, 0, 0, 1], 4); +} +function un(t, e) { + return ne(cn(e, 3), sr(t, 3)); +} +function Ea(t, e) { + var r = e[0], n = r === void 0 ? 0 : r, a = e[1], i = a === void 0 ? 0 : a, o = e[2], s = o === void 0 ? 0 : o; + return Pt(t, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, n, i, s, 1], 4); +} +function $a(t, e) { + return Pt(t, e, 4); +} +function cn(t, e) { + var r = Math.cos(t), n = Math.sin(t), a = At(e); + return a[0] = r, a[1] = n, a[e] = -n, a[e + 1] = r, a; +} +function At(t) { + for (var e = t * t, r = [], n = 0; n < e; ++n) + r[n] = n % (t + 1) ? 0 : 1; + return r; +} +function Ri(t, e) { + for (var r = At(e), n = Math.min(t.length, e - 1), a = 0; a < n; ++a) + r[(e + 1) * a] = t[a]; + return r; +} +function lr(t, e) { + for (var r = At(e), n = Math.min(t.length, e - 1), a = 0; a < n; ++a) + r[e * (e - 1) + a] = t[a]; + return r; +} +function Pi(t, e, r, n, a, i, o, s) { + var l = t[0], u = t[1], c = e[0], f = e[1], d = r[0], p = r[1], h = n[0], g = n[1], x = a[0], y = a[1], b = i[0], C = i[1], S = o[0], w = o[1], v = s[0], _ = s[1], M = [l, 0, c, 0, d, 0, h, 0, u, 0, f, 0, p, 0, g, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, l, 0, c, 0, d, 0, h, 0, u, 0, f, 0, p, 0, g, 0, 1, 0, 1, 0, 1, 0, 1, -x * l, -y * l, -b * c, -C * c, -S * d, -w * d, -v * h, -_ * h, -x * u, -y * u, -b * f, -C * f, -S * p, -w * p, -v * g, -_ * g], T = ke(M, 8); + if (!T.length) + return []; + var k = Pt(T, [x, y, b, C, S, w, v, _], 8); + return k[8] = 1, Te(nf(k), 3, 4); +} +var Ur = function() { + return Ur = Object.assign || function(e) { + for (var r, n = 1, a = arguments.length; n < a; n++) { + r = arguments[n]; + for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]); + } + return e; + }, Ur.apply(this, arguments); +}; +function Oi() { + return [ + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1 + ]; +} +function Tr(t, e) { + return e === void 0 && (e = 0), yr(Ir(t, e)); +} +function Wn(t, e) { + var r = ne(t, [e[0], e[1] || 0, e[2] || 0, 1], 4), n = r[3] || 1; + return [ + r[0] / n, + r[1] / n, + r[2] / n + ]; +} +function cf(t, e) { + e === void 0 && (e = document.body); + for (var r = t, n = Oi(); r; ) { + var a = getComputedStyle(r).transform; + if (n = $a(Tr(a), n), r === e) + break; + r = r.parentElement; + } + return n = ke(n, 4), n[12] = 0, n[13] = 0, n[14] = 0, n; +} +function yr(t) { + var e = Oi(); + return t.forEach(function(r) { + var n = r.matrixFunction, a = r.functionValue; + n && (e = n(e, a)); + }), e; +} +function Ir(t, e) { + e === void 0 && (e = 0); + var r = Yt(t) ? t : Ve(t); + return r.map(function(n) { + var a = Qs(n), i = a.prefix, o = a.value, s = null, l = i, u = ""; + if (i === "translate" || i === "translateX" || i === "translate3d") { + var c = pe(e) ? Ur(Ur({}, e), { "o%": e["%"] }) : { + "%": e, + "o%": e + }, f = ir(o).map(function(R, B) { + return B === 0 && "x%" in c ? c["%"] = e["x%"] : B === 1 && "y%" in c ? c["%"] = e["y%"] : c["%"] = e["o%"], Rt(R, c); + }), d = f[0], p = f[1], h = p === void 0 ? 0 : p, g = f[2], x = g === void 0 ? 0 : g; + s = Ea, u = [d, h, x]; + } else if (i === "translateY") { + var y = pe(e) ? Ur({ "%": e["y%"] }, e) : { + "%": e + }, h = Rt(o, y); + s = Ea, u = [0, h, 0]; + } else if (i === "translateZ") { + var x = parseFloat(o); + s = Ea, u = [0, 0, x]; + } else if (i === "scale" || i === "scale3d") { + var b = ir(o).map(function(R) { + return parseFloat(R); + }), C = b[0], S = b[1], w = S === void 0 ? C : S, v = b[2], _ = v === void 0 ? 1 : v; + s = _n, u = [C, w, _]; + } else if (i === "scaleX") { + var C = parseFloat(o); + s = _n, u = [C, 1, 1]; + } else if (i === "scaleY") { + var w = parseFloat(o); + s = _n, u = [1, w, 1]; + } else if (i === "scaleZ") { + var _ = parseFloat(o); + s = _n, u = [1, 1, _]; + } else if (i === "rotate" || i === "rotateZ" || i === "rotateX" || i === "rotateY") { + var M = or(o), T = M.unit, k = M.value, A = T === "rad" ? k : k * Math.PI / 180; + i === "rotate" || i === "rotateZ" ? (l = "rotateZ", s = uf) : i === "rotateX" ? s = sf : i === "rotateY" && (s = lf), u = A; + } else if (i === "matrix3d") + s = $a, u = ir(o).map(function(R) { + return parseFloat(R); + }); + else if (i === "matrix") { + var z = ir(o).map(function(R) { + return parseFloat(R); + }); + s = $a, u = [ + z[0], + z[1], + 0, + 0, + z[2], + z[3], + 0, + 0, + 0, + 0, + 1, + 0, + z[4], + z[5], + 0, + 1 + ]; + } else + l = ""; + return { + name: i, + functionName: l, + value: o, + matrixFunction: s, + functionValue: u + }; + }); +} +var ff = /* @__PURE__ */ (function() { + function t() { + this.keys = [], this.values = []; + } + var e = t.prototype; + return e.get = function(r) { + return this.values[this.keys.indexOf(r)]; + }, e.set = function(r, n) { + var a = this.keys, i = this.values, o = a.indexOf(r), s = o === -1 ? a.length : o; + a[s] = r, i[s] = n; + }, t; +})(), df = /* @__PURE__ */ (function() { + function t() { + this.object = {}; + } + var e = t.prototype; + return e.get = function(r) { + return this.object[r]; + }, e.set = function(r, n) { + this.object[r] = n; + }, t; +})(), pf = typeof Map == "function", vf = /* @__PURE__ */ (function() { + function t() { + } + var e = t.prototype; + return e.connect = function(r, n) { + this.prev = r, this.next = n, r && (r.next = this), n && (n.prev = this); + }, e.disconnect = function() { + var r = this.prev, n = this.next; + r && (r.next = n), n && (n.prev = r); + }, e.getIndex = function() { + for (var r = this, n = -1; r; ) + r = r.prev, ++n; + return n; + }, t; +})(); +function hf(t, e) { + var r = [], n = []; + return t.forEach(function(a) { + var i = a[0], o = a[1], s = new vf(); + r[i] = s, n[o] = s; + }), r.forEach(function(a, i) { + a.connect(r[i - 1]); + }), t.filter(function(a, i) { + return !e[i]; + }).map(function(a, i) { + var o = a[0], s = a[1]; + if (o === s) + return [0, 0]; + var l = r[o], u = n[s - 1], c = l.getIndex(); + l.disconnect(), u ? l.connect(u, u.next) : l.connect(void 0, r[0]); + var f = l.getIndex(); + return [c, f]; + }); +} +var gf = /* @__PURE__ */ (function() { + function t(r, n, a, i, o, s, l, u) { + this.prevList = r, this.list = n, this.added = a, this.removed = i, this.changed = o, this.maintained = s, this.changedBeforeAdded = l, this.fixed = u; + } + var e = t.prototype; + return Object.defineProperty(e, "ordered", { + get: function() { + return this.cacheOrdered || this.caculateOrdered(), this.cacheOrdered; + }, + enumerable: !0, + configurable: !0 + }), Object.defineProperty(e, "pureChanged", { + get: function() { + return this.cachePureChanged || this.caculateOrdered(), this.cachePureChanged; + }, + enumerable: !0, + configurable: !0 + }), e.caculateOrdered = function() { + var r = hf(this.changedBeforeAdded, this.fixed), n = this.changed, a = []; + this.cacheOrdered = r.filter(function(i, o) { + var s = i[0], l = i[1], u = n[o], c = u[0], f = u[1]; + if (s !== l) + return a.push([c, f]), !0; + }), this.cachePureChanged = a; + }, t; +})(); +function zi(t, e, r) { + var n = pf ? Map : r ? df : ff, a = r || function(b) { + return b; + }, i = [], o = [], s = [], l = t.map(a), u = e.map(a), c = new n(), f = new n(), d = [], p = [], h = {}, g = [], x = 0, y = 0; + return l.forEach(function(b, C) { + c.set(b, C); + }), u.forEach(function(b, C) { + f.set(b, C); + }), l.forEach(function(b, C) { + var S = f.get(b); + typeof S > "u" ? (++y, o.push(C)) : h[S] = y; + }), u.forEach(function(b, C) { + var S = c.get(b); + typeof S > "u" ? (i.push(C), ++x) : (s.push([S, C]), y = h[C] || 0, d.push([S - y, C - x]), p.push(C === S), S !== C && g.push([S, C])); + }), o.reverse(), new gf(t, e, i, o, g, s, d, p); +} +var mf = /* @__PURE__ */ (function() { + function t(r, n) { + r === void 0 && (r = []), this.findKeyCallback = n, this.list = [].slice.call(r); + } + var e = t.prototype; + return e.update = function(r) { + var n = [].slice.call(r), a = zi(this.list, n, this.findKeyCallback); + return this.list = n, a; + }, t; +})(); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +var Ua = function(t, e) { + return Ua = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(r, n) { + r.__proto__ = n; + } || function(r, n) { + for (var a in n) n.hasOwnProperty(a) && (r[a] = n[a]); + }, Ua(t, e); +}; +function xf(t, e) { + Ua(t, e); + function r() { + this.constructor = t; + } + t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r()); +} +var ol = typeof Map == "function" ? void 0 : /* @__PURE__ */ (function() { + var t = 0; + return function(e) { + return e.__DIFF_KEY__ || (e.__DIFF_KEY__ = ++t); + }; +})(), sl = /* @__PURE__ */ (function(t) { + xf(e, t); + function e(r) { + return r === void 0 && (r = []), t.call(this, r, ol) || this; + } + return e; +})(mf); +function Sr(t, e) { + return zi(t, e, ol); +} +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +var Ka = function() { + return Ka = Object.assign || function(e) { + for (var r, n = 1, a = arguments.length; n < a; n++) { + r = arguments[n]; + for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]); + } + return e; + }, Ka.apply(this, arguments); +}; +function yf() { + for (var t = 0, e = 0, r = arguments.length; e < r; e++) t += arguments[e].length; + for (var n = Array(t), a = 0, e = 0; e < r; e++) for (var i = arguments[e], o = 0, s = i.length; o < s; o++, a++) n[a] = i[o]; + return n; +} +var fn = /* @__PURE__ */ (function() { + function t() { + this._events = {}; + } + var e = t.prototype; + return e.on = function(r, n) { + if (pe(r)) + for (var a in r) + this.on(a, r[a]); + else + this._addEvent(r, n, {}); + return this; + }, e.off = function(r, n) { + if (!r) + this._events = {}; + else if (pe(r)) + for (var a in r) + this.off(a); + else if (!n) + this._events[r] = []; + else { + var i = this._events[r]; + if (i) { + var o = Ge(i, function(s) { + return s.listener === n; + }); + o > -1 && i.splice(o, 1); + } + } + return this; + }, e.once = function(r, n) { + var a = this; + return n && this._addEvent(r, n, { + once: !0 + }), new Promise(function(i) { + a._addEvent(r, i, { + once: !0 + }); + }); + }, e.emit = function(r, n) { + var a = this; + n === void 0 && (n = {}); + var i = this._events[r]; + if (!r || !i) + return !0; + var o = !1; + return n.eventType = r, n.stop = function() { + o = !0; + }, n.currentTarget = this, yf(i).forEach(function(s) { + s.listener(n), s.once && a.off(r, s.listener); + }), !o; + }, e.trigger = function(r, n) { + return n === void 0 && (n = {}), this.emit(r, n); + }, e._addEvent = function(r, n, a) { + var i = this._events; + i[r] = i[r] || []; + var o = i[r]; + o.push(Ka({ + listener: n + }, a)); + }, t; +})(); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +var Za = function(t, e) { + return Za = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(r, n) { + r.__proto__ = n; + } || function(r, n) { + for (var a in n) n.hasOwnProperty(a) && (r[a] = n[a]); + }, Za(t, e); +}; +function bf(t, e) { + Za(t, e); + function r() { + this.constructor = t; + } + t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r()); +} +var Cr = function() { + return Cr = Object.assign || function(e) { + for (var r, n = 1, a = arguments.length; n < a; n++) { + r = arguments[n]; + for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]); + } + return e; + }, Cr.apply(this, arguments); +}; +function Sf(t) { + var e = t.container; + return e === document.body ? [e.scrollLeft || document.documentElement.scrollLeft, e.scrollTop || document.documentElement.scrollTop] : [e.scrollLeft, e.scrollTop]; +} +function Lo(t, e) { + return t.addEventListener("scroll", e), function() { + t.removeEventListener("scroll", e); + }; +} +function Mn(t) { + if (t) { + if (be(t)) + return document.querySelector(t); + } else return null; + if (oa(t)) + return t(); + if (t instanceof Element) + return t; + if ("current" in t) + return t.current; + if ("value" in t) + return t.value; +} +var ll = /* @__PURE__ */ (function(t) { + bf(e, t); + function e() { + var n = t !== null && t.apply(this, arguments) || this; + return n._startRect = null, n._startPos = [], n._prevTime = 0, n._timer = 0, n._prevScrollPos = [0, 0], n._isWait = !1, n._flag = !1, n._currentOptions = null, n._lock = !1, n._unregister = null, n._onScroll = function() { + var a = n._currentOptions; + n._lock || !a || n.emit("scrollDrag", { + next: function(i) { + n.checkScroll({ + container: a.container, + inputEvent: i + }); + } + }); + }, n; + } + var r = e.prototype; + return r.dragStart = function(n, a) { + var i = Mn(a.container); + if (!i) { + this._flag = !1; + return; + } + var o = 0, s = 0, l = 0, u = 0; + if (i === document.body) + l = window.innerWidth, u = window.innerHeight; + else { + var c = i.getBoundingClientRect(); + o = c.top, s = c.left, l = c.width, u = c.height; + } + this._flag = !0, this._startPos = [n.clientX, n.clientY], this._startRect = { + top: o, + left: s, + width: l, + height: u + }, this._prevScrollPos = this._getScrollPosition([0, 0], a), this._currentOptions = a, this._registerScrollEvent(a); + }, r.drag = function(n, a) { + if (clearTimeout(this._timer), !!this._flag) { + var i = n.clientX, o = n.clientY, s = a.threshold, l = s === void 0 ? 0 : s, u = this, c = u._startRect, f = u._startPos; + this._currentOptions = a; + var d = [0, 0]; + return c.top > o - l ? (f[1] > c.top || o < f[1]) && (d[1] = -1) : c.top + c.height < o + l && (f[1] < c.top + c.height || o > f[1]) && (d[1] = 1), c.left > i - l ? (f[0] > c.left || i < f[0]) && (d[0] = -1) : c.left + c.width < i + l && (f[0] < c.left + c.width || i > f[0]) && (d[0] = 1), !d[0] && !d[1] ? !1 : this._continueDrag(Cr(Cr({}, a), { + direction: d, + inputEvent: n, + isDrag: !0 + })); + } + }, r.checkScroll = function(n) { + var a = this; + if (this._isWait) + return !1; + var i = n.prevScrollPos, o = i === void 0 ? this._prevScrollPos : i, s = n.direction, l = n.throttleTime, u = l === void 0 ? 0 : l, c = n.inputEvent, f = n.isDrag, d = this._getScrollPosition(s || [0, 0], n), p = d[0] - o[0], h = d[1] - o[1], g = s || [p ? Math.abs(p) / p : 0, h ? Math.abs(h) / h : 0]; + return this._prevScrollPos = d, this._lock = !1, !p && !h ? !1 : (this.emit("move", { + offsetX: g[0] ? p : 0, + offsetY: g[1] ? h : 0, + inputEvent: c + }), u && f && (clearTimeout(this._timer), this._timer = window.setTimeout(function() { + a._continueDrag(n); + }, u)), !0); + }, r.dragEnd = function() { + this._flag = !1, this._lock = !1, clearTimeout(this._timer), this._unregisterScrollEvent(); + }, r._getScrollPosition = function(n, a) { + var i = a.container, o = a.getScrollPosition, s = o === void 0 ? Sf : o; + return s({ + container: Mn(i), + direction: n + }); + }, r._continueDrag = function(n) { + var a = this, i, o = n.container, s = n.direction, l = n.throttleTime, u = n.useScroll, c = n.isDrag, f = n.inputEvent; + if (!(!this._flag || c && this._isWait)) { + var d = an(), p = Math.max(l + this._prevTime - d, 0); + if (p > 0) + return clearTimeout(this._timer), this._timer = window.setTimeout(function() { + a._continueDrag(n); + }, p), !1; + this._prevTime = d; + var h = this._getScrollPosition(s, n); + this._prevScrollPos = h, c && (this._isWait = !0), u || (this._lock = !0); + var g = { + container: Mn(o), + direction: s, + inputEvent: f + }; + return (i = n.requestScroll) === null || i === void 0 || i.call(n, g), this.emit("scroll", g), this._isWait = !1, u || this.checkScroll(Cr(Cr({}, n), { + prevScrollPos: h, + direction: s, + inputEvent: f + })); + } + }, r._registerScrollEvent = function(n) { + this._unregisterScrollEvent(); + var a = n.checkScrollEvent; + if (a) { + var i = a === !0 ? Lo : a, o = Mn(n.container); + a === !0 && (o === document.body || o === document.documentElement) ? this._unregister = Lo(window, this._onScroll) : this._unregister = i(o, this._onScroll); + } + }, r._unregisterScrollEvent = function() { + var n; + (n = this._unregister) === null || n === void 0 || n.call(this), this._unregister = null; + }, e; +})(fn); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +function Cf() { + for (var t = 0, e = 0, r = arguments.length; e < r; e++) t += arguments[e].length; + for (var n = Array(t), a = 0, e = 0; e < r; e++) for (var i = arguments[e], o = 0, s = i.length; o < s; o++, a++) n[a] = i[o]; + return n; +} +function fe(t) { + return gt(t, Ut); +} +function Ef(t, e) { + return t.every(function(r, n) { + return fe(r - e[n]) === 0; + }); +} +function Df(t, e) { + return !fe(t[0] - e[0]) && !fe(t[1] - e[1]); +} +function Kr(t) { + return t.length < 3 ? 0 : Math.abs(Kc(t.map(function(e, r) { + var n = t[r + 1] || t[0]; + return e[0] * n[1] - n[0] * e[1]; + }))) / 2; +} +function Ja(t, e) { + var r = e.width, n = e.height, a = e.left, i = e.top, o = ur(t), s = o.minX, l = o.minY, u = o.maxX, c = o.maxY, f = r / (u - s), d = n / (c - l); + return t.map(function(p) { + return [a + (p[0] - s) * f, i + (p[1] - l) * d]; + }); +} +function ur(t) { + var e = t.map(function(n) { + return n[0]; + }), r = t.map(function(n) { + return n[1]; + }); + return { + minX: Math.min.apply(Math, e), + minY: Math.min.apply(Math, r), + maxX: Math.max.apply(Math, e), + maxY: Math.max.apply(Math, r) + }; +} +function $n(t, e, r) { + var n = t[0], a = t[1], i = ur(e), o = i.minX, s = i.maxX, l = [[o, a], [s, a]], u = Un(l[0], l[1]), c = Qa(e), f = []; + if (c.forEach(function(h) { + var g = Un(h[0], h[1]), x = h[0]; + if (Ef(u, g)) + f.push({ + pos: t, + line: h, + type: "line" + }); + else { + var y = ul(Ai(u, g), [l, h]); + y.forEach(function(b) { + h.some(function(C) { + return Df(C, b); + }) ? f.push({ + pos: b, + line: h, + type: "point" + }) : fe(x[1] - a) !== 0 && f.push({ + pos: b, + line: h, + type: "intersection" + }); + }); + } + }), ve(f, function(h) { + return h[0] === n; + })) + return !0; + var d = 0, p = {}; + return f.forEach(function(h) { + var g = h.pos, x = h.type, y = h.line; + if (!(g[0] > n)) + if (x === "intersection") + ++d; + else { + if (x === "line") + return; + if (x === "point") { + var b = ve(y, function(w) { + return w[1] !== a; + }), C = p[g[0]], S = b[1] > a ? 1 : -1; + C ? C !== S && ++d : p[g[0]] = S; + } + } + }), d % 2 === 1; +} +function Un(t, e) { + var r = t[0], n = t[1], a = e[0], i = e[1], o = a - r, s = i - n; + Math.abs(o) < Ut && (o = 0), Math.abs(s) < Ut && (s = 0); + var l = 0, u = 0, c = 0; + return o ? s ? (l = -s / o, u = 1, c = -l * r - n) : (u = 1, c = -n) : s && (l = -1, c = r), [l, u, c]; +} +function Ai(t, e) { + var r = t[0], n = t[1], a = t[2], i = e[0], o = e[1], s = e[2], l = r === 0 && i === 0, u = n === 0 && o === 0, c = []; + if (l && u) + return []; + if (l) { + var f = -a / n, d = -s / o; + return f !== d ? [] : [[-1 / 0, f], [1 / 0, f]]; + } else if (u) { + var p = -a / r, h = -s / i; + return p !== h ? [] : [[p, -1 / 0], [p, 1 / 0]]; + } else if (r === 0) { + var g = -a / n, x = -(o * g + s) / i; + c = [[x, g]]; + } else if (i === 0) { + var g = -s / o, x = -(n * g + a) / r; + c = [[x, g]]; + } else if (n === 0) { + var x = -a / r, g = -(i * x + s) / o; + c = [[x, g]]; + } else if (o === 0) { + var x = -s / i, g = -(r * x + a) / n; + c = [[x, g]]; + } else { + var x = (n * s - o * a) / (o * r - n * i), g = -(r * x + a) / n; + c = [[x, g]]; + } + return c.map(function(y) { + return [y[0], y[1]]; + }); +} +function ul(t, e) { + var r = e.map(function(f) { + return [0, 1].map(function(d) { + return [Math.min(f[0][d], f[1][d]), Math.max(f[0][d], f[1][d])]; + }); + }), n = []; + if (t.length === 2) { + var a = t[0], i = a[0], o = a[1]; + if (fe(i - t[1][0])) { + if (!fe(o - t[1][1])) { + var u = Math.max.apply(Math, r.map(function(f) { + return f[0][0]; + })), c = Math.min.apply(Math, r.map(function(f) { + return f[0][1]; + })); + if (fe(u - c) > 0) + return []; + n = [[u, o], [c, o]]; + } + } else { + var s = Math.max.apply(Math, r.map(function(f) { + return f[1][0]; + })), l = Math.min.apply(Math, r.map(function(f) { + return f[1][1]; + })); + if (fe(s - l) > 0) + return []; + n = [[i, s], [i, l]]; + } + } + return n.length || (n = t.filter(function(f) { + var d = f[0], p = f[1]; + return r.every(function(h) { + return 0 <= fe(d - h[0][0]) && 0 <= fe(h[0][1] - d) && 0 <= fe(p - h[1][0]) && 0 <= fe(h[1][1] - p); + }); + })), n.map(function(f) { + return [fe(f[0]), fe(f[1])]; + }); +} +function Qa(t) { + return Cf(t.slice(1), [t[0]]).map(function(e, r) { + return [t[r], e]; + }); +} +function wf(t, e) { + var r = t.slice(), n = e.slice(); + Go(r) === -1 && r.reverse(), Go(n) === -1 && n.reverse(); + var a = Qa(r), i = Qa(n), o = a.map(function(c) { + return Un(c[0], c[1]); + }), s = i.map(function(c) { + return Un(c[0], c[1]); + }), l = []; + o.forEach(function(c, f) { + var d = a[f], p = []; + s.forEach(function(h, g) { + var x = Ai(c, h), y = ul(x, [d, i[g]]); + p.push.apply(p, y.map(function(b) { + return { + index1: f, + index2: g, + pos: b, + type: "intersection" + }; + })); + }), p.sort(function(h, g) { + return Re(d[0], h.pos) - Re(d[0], g.pos); + }), l.push.apply(l, p), $n(d[1], n) && l.push({ + index1: f, + index2: -1, + pos: d[1], + type: "inside" + }); + }), i.forEach(function(c, f) { + if ($n(c[1], r)) { + var d = !1, p = Ge(l, function(h) { + var g = h.index2; + return g === f ? (d = !0, !1) : !!d; + }); + p === -1 && (d = !1, p = Ge(l, function(h) { + var g = h.index1, x = h.index2; + return g === -1 && x + 1 === f ? (d = !0, !1) : !!d; + })), p === -1 ? l.push({ + index1: -1, + index2: f, + pos: c[1], + type: "inside" + }) : l.splice(p, 0, { + index1: -1, + index2: f, + pos: c[1], + type: "inside" + }); + } + }); + var u = {}; + return l.filter(function(c) { + var f = c.pos, d = f[0] + "x" + f[1]; + return u[d] ? !1 : (u[d] = !0, !0); + }); +} +function ti(t, e) { + var r = wf(t, e); + return r.map(function(n) { + var a = n.pos; + return a; + }); +} +function _f(t, e) { + var r = ti(t, e); + return Kr(r); +} +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +var ei = function(t, e) { + return ei = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) { + r.__proto__ = n; + } || function(r, n) { + for (var a in n) n.hasOwnProperty(a) && (r[a] = n[a]); + }, ei(t, e); +}; +function Mf(t, e) { + ei(t, e); + function r() { + this.constructor = t; + } + t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r()); +} +var qt = function() { + return qt = Object.assign || function(e) { + for (var r, n = 1, a = arguments.length; n < a; n++) { + r = arguments[n]; + for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]); + } + return e; + }, qt.apply(this, arguments); +}; +function kf(t, e) { + var r = e[0] - t[0], n = e[1] - t[1], a = Math.atan2(n, r); + return a >= 0 ? a : a + Math.PI * 2; +} +function Da(t) { + return kf([ + t[0].clientX, + t[0].clientY + ], [ + t[1].clientX, + t[1].clientY + ]) / Math.PI * 180; +} +function Tf(t) { + return t.touches && t.touches.length >= 2; +} +function kn(t) { + return t ? t.touches ? Rf(t.touches) : [cl(t)] : []; +} +function If(t) { + return t && (t.type.indexOf("mouse") > -1 || "button" in t); +} +function Wo(t, e, r) { + var n = r.length, a = Zr(t, n), i = a.clientX, o = a.clientY, s = a.originalClientX, l = a.originalClientY, u = Zr(e, n), c = u.clientX, f = u.clientY, d = Zr(r, n), p = d.clientX, h = d.clientY, g = i - c, x = o - f, y = i - p, b = o - h; + return { + clientX: s, + clientY: l, + deltaX: g, + deltaY: x, + distX: y, + distY: b + }; +} +function wa(t) { + return Math.sqrt(Math.pow(t[0].clientX - t[1].clientX, 2) + Math.pow(t[0].clientY - t[1].clientY, 2)); +} +function Rf(t) { + for (var e = Math.min(t.length, 2), r = [], n = 0; n < e; ++n) + r.push(cl(t[n])); + return r; +} +function cl(t) { + return { + clientX: t.clientX, + clientY: t.clientY + }; +} +function Zr(t, e) { + e === void 0 && (e = t.length); + for (var r = { + clientX: 0, + clientY: 0, + originalClientX: 0, + originalClientY: 0 + }, n = Math.min(t.length, e), a = 0; a < n; ++a) { + var i = t[a]; + r.originalClientX += "originalClientX" in i ? i.originalClientX : i.clientX, r.originalClientY += "originalClientY" in i ? i.originalClientY : i.clientY, r.clientX += i.clientX, r.clientY += i.clientY; + } + return e ? { + clientX: r.clientX / e, + clientY: r.clientY / e, + originalClientX: r.originalClientX / e, + originalClientY: r.originalClientY / e + } : r; +} +var _a = /* @__PURE__ */ (function() { + function t(e) { + this.prevClients = [], this.startClients = [], this.movement = 0, this.length = 0, this.startClients = e, this.prevClients = e, this.length = e.length; + } + return t.prototype.getAngle = function(e) { + return e === void 0 && (e = this.prevClients), Da(e); + }, t.prototype.getRotation = function(e) { + return e === void 0 && (e = this.prevClients), Da(e) - Da(this.startClients); + }, t.prototype.getPosition = function(e, r) { + e === void 0 && (e = this.prevClients); + var n = Wo(e || this.prevClients, this.prevClients, this.startClients), a = n.deltaX, i = n.deltaY; + return this.movement += Math.sqrt(a * a + i * i), this.prevClients = e, n; + }, t.prototype.getPositions = function(e) { + e === void 0 && (e = this.prevClients); + for (var r = this.prevClients, n = this.startClients, a = Math.min(this.length, r.length), i = [], o = 0; o < a; ++o) + i[o] = Wo([e[o]], [r[o]], [n[o]]); + return i; + }, t.prototype.getMovement = function(e) { + var r = this.movement; + if (!e) + return r; + var n = Zr(e, this.length), a = Zr(this.prevClients, this.length), i = n.clientX - a.clientX, o = n.clientY - a.clientY; + return Math.sqrt(i * i + o * o) + r; + }, t.prototype.getDistance = function(e) { + return e === void 0 && (e = this.prevClients), wa(e); + }, t.prototype.getScale = function(e) { + return e === void 0 && (e = this.prevClients), wa(e) / wa(this.startClients); + }, t.prototype.move = function(e, r) { + this.startClients.forEach(function(n) { + n.clientX -= e, n.clientY -= r; + }), this.prevClients.forEach(function(n) { + n.clientX -= e, n.clientY -= r; + }); + }, t; +})(), Yo = ["textarea", "input"], fl = /* @__PURE__ */ (function(t) { + Mf(e, t); + function e(r, n) { + n === void 0 && (n = {}); + var a = t.call(this) || this; + a.options = {}, a.flag = !1, a.pinchFlag = !1, a.data = {}, a.isDrag = !1, a.isPinch = !1, a.clientStores = [], a.targets = [], a.prevTime = 0, a.doubleFlag = !1, a._useMouse = !1, a._useTouch = !1, a._useDrag = !1, a._dragFlag = !1, a._isTrusted = !1, a._isMouseEvent = !1, a._isSecondaryButton = !1, a._preventMouseEvent = !1, a._prevInputEvent = null, a._isDragAPI = !1, a._isIdle = !0, a._preventMouseEventId = 0, a._window = window, a.onDragStart = function(d, p) { + if (p === void 0 && (p = !0), !(!a.flag && d.cancelable === !1)) { + var h = d.type.indexOf("drag") >= -1; + if (!(a.flag && h)) { + a._isDragAPI = !0; + var g = a.options, x = g.container, y = g.pinchOutside, b = g.preventWheelClick, C = g.preventRightClick, S = g.preventDefault, w = g.checkInput, v = g.dragFocusedInput, _ = g.preventClickEventOnDragStart, M = g.preventClickEventOnDrag, T = g.preventClickEventByCondition, k = a._useTouch, A = !a.flag; + if (a._isSecondaryButton = d.which === 3 || d.button === 2, b && (d.which === 2 || d.button === 1) || C && (d.which === 3 || d.button === 2)) + return a.stop(), !1; + if (A) { + var z = a._window.document.activeElement, R = d.target; + if (R) { + var B = R.tagName.toLowerCase(), N = Yo.indexOf(B) > -1, L = R.isContentEditable; + if (N || L) { + if (w || !v && z === R) + return !1; + if (z && (z === R || L && z.isContentEditable && z.contains(R))) + if (v) + R.blur(); + else + return !1; + } else if ((S || d.type === "touchstart") && z) { + var V = z.tagName.toLowerCase(); + (z.isContentEditable || Yo.indexOf(V) > -1) && z.blur(); + } + (_ || M || T) && $t(a._window, "click", a._onClick, !0); + } + a.clientStores = [new _a(kn(d))], a._isIdle = !1, a.flag = !0, a.isDrag = !1, a._isTrusted = p, a._dragFlag = !0, a._prevInputEvent = d, a.data = {}, a.doubleFlag = an() - a.prevTime < 200, a._isMouseEvent = If(d), !a._isMouseEvent && a._preventMouseEvent && a._allowMouseEvent(); + var G = a._preventMouseEvent || a.emit("dragStart", qt(qt({ data: a.data, datas: a.data, inputEvent: d, isMouseEvent: a._isMouseEvent, isSecondaryButton: a._isSecondaryButton, isTrusted: p, isDouble: a.doubleFlag }, a.getCurrentStore().getPosition()), { preventDefault: function() { + d.preventDefault(); + }, preventDrag: function() { + a._dragFlag = !1; + } })); + G === !1 && a.stop(), a._isMouseEvent && a.flag && S && d.preventDefault(); + } + if (!a.flag) + return !1; + var W = 0; + if (A ? (a._attchDragEvent(), k && y && (W = setTimeout(function() { + $t(x, "touchstart", a.onDragStart, { + passive: !1 + }); + }))) : k && y && Wt(x, "touchstart", a.onDragStart), a.flag && Tf(d)) { + if (clearTimeout(W), A && d.touches.length !== d.changedTouches.length) + return; + a.pinchFlag || a.onPinchStart(d); + } + } + } + }, a.onDrag = function(d, p) { + if (a.flag) { + var h = a.options.preventDefault; + !a._isMouseEvent && h && d.preventDefault(), a._prevInputEvent = d; + var g = kn(d), x = a.moveClients(g, d, !1); + if (a._dragFlag) { + if (a.pinchFlag || x.deltaX || x.deltaY) { + var y = a._preventMouseEvent || a.emit("drag", qt(qt({}, x), { isScroll: !!p, inputEvent: d })); + if (y === !1) { + a.stop(); + return; + } + } + a.pinchFlag && a.onPinch(d, g); + } + a.getCurrentStore().getPosition(g, !0); + } + }, a.onDragEnd = function(d) { + if (a.flag) { + var p = a.options, h = p.pinchOutside, g = p.container, x = p.preventClickEventOnDrag, y = p.preventClickEventOnDragStart, b = p.preventClickEventByCondition, C = a.isDrag; + (x || y || b) && requestAnimationFrame(function() { + a._allowClickEvent(); + }), !b && !y && x && !C && a._allowClickEvent(), a._useTouch && h && Wt(g, "touchstart", a.onDragStart), a.pinchFlag && a.onPinchEnd(d); + var S = d != null && d.touches ? kn(d) : [], w = S.length; + w === 0 || !a.options.keepDragging ? a.flag = !1 : a._addStore(new _a(S)); + var v = a._getPosition(), _ = an(), M = !C && a.doubleFlag; + a._prevInputEvent = null, a.prevTime = C || M ? 0 : _, a.flag || (a._dettachDragEvent(), a._preventMouseEvent || a.emit("dragEnd", qt({ data: a.data, datas: a.data, isDouble: M, isDrag: C, isClick: !C, isMouseEvent: a._isMouseEvent, isSecondaryButton: a._isSecondaryButton, inputEvent: d, isTrusted: a._isTrusted }, v)), a.clientStores = [], a._isMouseEvent || (a._preventMouseEvent = !0, clearTimeout(a._preventMouseEventId), a._preventMouseEventId = setTimeout(function() { + a._preventMouseEvent = !1; + }, 200)), a._isIdle = !0); + } + }, a.onBlur = function() { + a.onDragEnd(); + }, a._allowClickEvent = function() { + Wt(a._window, "click", a._onClick, !0); + }, a._onClick = function(d) { + a._allowClickEvent(), a._allowMouseEvent(); + var p = a.options.preventClickEventByCondition; + p != null && p(d) || (d.stopPropagation(), d.preventDefault()); + }, a._onContextMenu = function(d) { + var p = a.options; + p.preventRightClick ? a.onDragEnd(d) : d.preventDefault(); + }, a._passCallback = function() { + }; + var i = [].concat(r), o = i[0]; + a._window = rl(o) ? o : xe(o), a.options = qt({ checkInput: !1, container: o && !("document" in o) ? xe(o) : o, preventRightClick: !0, preventWheelClick: !0, preventClickEventOnDragStart: !1, preventClickEventOnDrag: !1, preventClickEventByCondition: null, preventDefault: !0, checkWindowBlur: !1, keepDragging: !1, pinchThreshold: 0, events: ["touch", "mouse"] }, n); + var s = a.options, l = s.container, u = s.events, c = s.checkWindowBlur; + if (a._useDrag = u.indexOf("drag") > -1, a._useTouch = u.indexOf("touch") > -1, a._useMouse = u.indexOf("mouse") > -1, a.targets = i, a._useDrag && i.forEach(function(d) { + $t(d, "dragstart", a.onDragStart); + }), a._useMouse && (i.forEach(function(d) { + $t(d, "mousedown", a.onDragStart), $t(d, "mousemove", a._passCallback); + }), $t(l, "contextmenu", a._onContextMenu)), c && $t(xe(), "blur", a.onBlur), a._useTouch) { + var f = { + passive: !1 + }; + i.forEach(function(d) { + $t(d, "touchstart", a.onDragStart, f), $t(d, "touchmove", a._passCallback, f); + }); + } + return a; + } + return e.prototype.stop = function() { + this.isDrag = !1, this.data = {}, this.clientStores = [], this.pinchFlag = !1, this.doubleFlag = !1, this.prevTime = 0, this.flag = !1, this._isIdle = !0, this._allowClickEvent(), this._dettachDragEvent(), this._isDragAPI = !1; + }, e.prototype.getMovement = function(r) { + return this.getCurrentStore().getMovement(r) + this.clientStores.slice(1).reduce(function(n, a) { + return n + a.movement; + }, 0); + }, e.prototype.isDragging = function() { + return this.isDrag; + }, e.prototype.isIdle = function() { + return this._isIdle; + }, e.prototype.isFlag = function() { + return this.flag; + }, e.prototype.isPinchFlag = function() { + return this.pinchFlag; + }, e.prototype.isDoubleFlag = function() { + return this.doubleFlag; + }, e.prototype.isPinching = function() { + return this.isPinch; + }, e.prototype.scrollBy = function(r, n, a, i) { + i === void 0 && (i = !0), this.flag && (this.clientStores[0].move(r, n), i && this.onDrag(a, !0)); + }, e.prototype.move = function(r, n) { + var a = r[0], i = r[1], o = this.getCurrentStore(), s = o.prevClients; + return this.moveClients(s.map(function(l) { + var u = l.clientX, c = l.clientY; + return { + clientX: u + a, + clientY: c + i, + originalClientX: u, + originalClientY: c + }; + }), n, !0); + }, e.prototype.triggerDragStart = function(r) { + this.onDragStart(r, !1); + }, e.prototype.setEventData = function(r) { + var n = this.data; + for (var a in r) + n[a] = r[a]; + return this; + }, e.prototype.setEventDatas = function(r) { + return this.setEventData(r); + }, e.prototype.getCurrentEvent = function(r) { + return r === void 0 && (r = this._prevInputEvent), qt(qt({ data: this.data, datas: this.data }, this._getPosition()), { movement: this.getMovement(), isDrag: this.isDrag, isPinch: this.isPinch, isScroll: !1, inputEvent: r }); + }, e.prototype.getEventData = function() { + return this.data; + }, e.prototype.getEventDatas = function() { + return this.data; + }, e.prototype.unset = function() { + var r = this, n = this.targets, a = this.options.container; + this.off(), Wt(this._window, "blur", this.onBlur), this._useDrag && n.forEach(function(i) { + Wt(i, "dragstart", r.onDragStart); + }), this._useMouse && (n.forEach(function(i) { + Wt(i, "mousedown", r.onDragStart); + }), Wt(a, "contextmenu", this._onContextMenu)), this._useTouch && (n.forEach(function(i) { + Wt(i, "touchstart", r.onDragStart); + }), Wt(a, "touchstart", this.onDragStart)), this._prevInputEvent = null, this._allowClickEvent(), this._dettachDragEvent(); + }, e.prototype.onPinchStart = function(r) { + var n = this, a = this.options.pinchThreshold; + if (!(this.isDrag && this.getMovement() > a)) { + var i = new _a(kn(r)); + this.pinchFlag = !0, this._addStore(i); + var o = this.emit("pinchStart", qt(qt({ data: this.data, datas: this.data, angle: i.getAngle(), touches: this.getCurrentStore().getPositions() }, i.getPosition()), { inputEvent: r, isTrusted: this._isTrusted, preventDefault: function() { + r.preventDefault(); + }, preventDrag: function() { + n._dragFlag = !1; + } })); + o === !1 && (this.pinchFlag = !1); + } + }, e.prototype.onPinch = function(r, n) { + if (!(!this.flag || !this.pinchFlag || n.length < 2)) { + var a = this.getCurrentStore(); + this.isPinch = !0, this.emit("pinch", qt(qt({ data: this.data, datas: this.data, movement: this.getMovement(n), angle: a.getAngle(n), rotation: a.getRotation(n), touches: a.getPositions(n), scale: a.getScale(n), distance: a.getDistance(n) }, a.getPosition(n)), { inputEvent: r, isTrusted: this._isTrusted })); + } + }, e.prototype.onPinchEnd = function(r) { + if (this.pinchFlag) { + var n = this.isPinch; + this.isPinch = !1, this.pinchFlag = !1; + var a = this.getCurrentStore(); + this.emit("pinchEnd", qt(qt({ data: this.data, datas: this.data, isPinch: n, touches: a.getPositions() }, a.getPosition()), { inputEvent: r })); + } + }, e.prototype.getCurrentStore = function() { + return this.clientStores[0]; + }, e.prototype.moveClients = function(r, n, a) { + var i = this._getPosition(r, a), o = this.isDrag; + (i.deltaX || i.deltaY) && (this.isDrag = !0); + var s = !1; + return !o && this.isDrag && (s = !0), qt(qt({ data: this.data, datas: this.data }, i), { movement: this.getMovement(r), isDrag: this.isDrag, isPinch: this.isPinch, isScroll: !1, isMouseEvent: this._isMouseEvent, isSecondaryButton: this._isSecondaryButton, inputEvent: n, isTrusted: this._isTrusted, isFirstDrag: s }); + }, e.prototype._addStore = function(r) { + this.clientStores.splice(0, 0, r); + }, e.prototype._getPosition = function(r, n) { + var a = this.getCurrentStore(), i = a.getPosition(r, n), o = this.clientStores.slice(1).reduce(function(u, c) { + var f = c.getPosition(); + return u.distX += f.distX, u.distY += f.distY, u; + }, i), s = o.distX, l = o.distY; + return qt(qt({}, i), { distX: s, distY: l }); + }, e.prototype._attchDragEvent = function() { + var r = this._window, n = this.options.container, a = { + passive: !1 + }; + this._isDragAPI && ($t(n, "dragover", this.onDrag, a), $t(r, "dragend", this.onDragEnd)), this._useMouse && ($t(n, "mousemove", this.onDrag), $t(r, "mouseup", this.onDragEnd)), this._useTouch && ($t(n, "touchmove", this.onDrag, a), $t(r, "touchend", this.onDragEnd, a), $t(r, "touchcancel", this.onDragEnd, a)); + }, e.prototype._dettachDragEvent = function() { + var r = this._window, n = this.options.container; + this._isDragAPI && (Wt(n, "dragover", this.onDrag), Wt(r, "dragend", this.onDragEnd)), this._useMouse && (Wt(n, "mousemove", this.onDrag), Wt(r, "mouseup", this.onDragEnd)), this._useTouch && (Wt(n, "touchstart", this.onDragStart), Wt(n, "touchmove", this.onDrag), Wt(r, "touchend", this.onDragEnd), Wt(r, "touchcancel", this.onDragEnd)); + }, e.prototype._allowMouseEvent = function() { + this._preventMouseEvent = !1, clearTimeout(this._preventMouseEventId); + }, e; +})(fn); +function Pf(t) { + for (var e = 5381, r = t.length; r; ) + e = e * 33 ^ t.charCodeAt(--r); + return e >>> 0; +} +var Of = Pf; +function zf(t) { + return Of(t).toString(36); +} +function Af(t) { + if (t && t.getRootNode) { + var e = t.getRootNode(); + if (e.nodeType === 11) + return e; + } +} +function Nf(t, e, r) { + return r.original ? e : e.replace(/([^};{\s}][^};{]*|^\s*){/mg, function(n, a) { + var i = a.trim(); + return (i ? ir(i) : [""]).map(function(o) { + var s = o.trim(); + return s.indexOf("@") === 0 ? s : s.indexOf(":global") > -1 ? s.replace(/\:global/g, "") : s.indexOf(":host") > -1 ? "".concat(s.replace(/\:host/g, ".".concat(t))) : s ? ".".concat(t, " ").concat(s) : ".".concat(t); + }).join(", ") + " {"; + }); +} +function Bf(t, e, r, n, a) { + var i = _e(n), o = i.createElement("style"); + return o.setAttribute("type", "text/css"), o.setAttribute("data-styled-id", t), o.setAttribute("data-styled-count", "1"), r.nonce && o.setAttribute("nonce", r.nonce), o.innerHTML = Nf(t, e, r), (a || i.head || i.body).appendChild(o), o; +} +function dl(t) { + var e = "rCS" + zf(t); + return { + className: e, + inject: function(r, n) { + n === void 0 && (n = {}); + var a = Af(r), i = (a || r.ownerDocument || document).querySelector('style[data-styled-id="'.concat(e, '"]')); + if (!i) + i = Bf(e, t, n, r, a); + else { + var o = parseFloat(i.getAttribute("data-styled-count")) || 0; + i.setAttribute("data-styled-count", "".concat(o + 1)); + } + return { + destroy: function() { + var s, l = parseFloat(i.getAttribute("data-styled-count")) || 0; + l <= 1 ? (i.remove ? i.remove() : (s = i.parentNode) === null || s === void 0 || s.removeChild(i), i = null) : i.setAttribute("data-styled-count", "".concat(l - 1)); + } + }; + } + }; +} +var ri = function() { + return ri = Object.assign || function(e) { + for (var r, n = 1, a = arguments.length; n < a; n++) { + r = arguments[n]; + for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]); + } + return e; + }, ri.apply(this, arguments); +}; +function jf(t, e) { + var r = {}; + for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]); + if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var a = 0, n = Object.getOwnPropertySymbols(t); a < n.length; a++) + e.indexOf(n[a]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[a]) && (r[n[a]] = t[n[a]]); + return r; +} +function pl(t, e) { + var r = dl(e), n = r.className; + return st.forwardRef(function(a, i) { + var o = a.className, s = o === void 0 ? "" : o; + a.cspNonce; + var l = jf(a, ["className", "cspNonce"]), u = st.useRef(); + return st.useImperativeHandle(i, function() { + return u.current; + }, []), st.useEffect(function() { + var c = r.inject(u.current, { + nonce: a.cspNonce + }); + return function() { + c.destroy(); + }; + }, []), st.createElement(t, ri({ + ref: u, + "data-styled-id": n, + className: "".concat(s, " ").concat(n) + }, l)); + }); +} +var ni = function(t, e) { + return ni = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) { + r.__proto__ = n; + } || function(r, n) { + for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (r[a] = n[a]); + }, ni(t, e); +}; +function dn(t, e) { + if (typeof e != "function" && e !== null) + throw new TypeError("Class extends value " + String(e) + " is not a constructor or null"); + ni(t, e); + function r() { + this.constructor = t; + } + t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r()); +} +var I = function() { + return I = Object.assign || function(e) { + for (var r, n = 1, a = arguments.length; n < a; n++) { + r = arguments[n]; + for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]); + } + return e; + }, I.apply(this, arguments); +}; +function Gf(t, e) { + var r = {}; + for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]); + if (t != null && typeof Object.getOwnPropertySymbols == "function") + for (var a = 0, n = Object.getOwnPropertySymbols(t); a < n.length; a++) + e.indexOf(n[a]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[a]) && (r[n[a]] = t[n[a]]); + return r; +} +function Ff(t, e, r, n) { + var a = arguments.length, i = a < 3 ? e : n, o; + if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(t, e, r, n); + else for (var s = t.length - 1; s >= 0; s--) (o = t[s]) && (i = (a < 3 ? o(i) : a > 3 ? o(e, r, i) : o(e, r)) || i); + return a > 3 && i && Object.defineProperty(e, r, i), i; +} +function Lf(t) { + var e = typeof Symbol == "function" && Symbol.iterator, r = e && t[e], n = 0; + if (r) return r.call(t); + if (t && typeof t.length == "number") return { + next: function() { + return t && n >= t.length && (t = void 0), { value: t && t[n++], done: !t }; + } + }; + throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined."); +} +function O(t, e) { + var r = typeof Symbol == "function" && t[Symbol.iterator]; + if (!r) return t; + var n = r.call(t), a, i = [], o; + try { + for (; (e === void 0 || e-- > 0) && !(a = n.next()).done; ) i.push(a.value); + } catch (s) { + o = { error: s }; + } finally { + try { + a && !a.done && (r = n.return) && r.call(n); + } finally { + if (o) throw o.error; + } + } + return i; +} +function Z(t, e, r) { + if (arguments.length === 2) for (var n = 0, a = e.length, i; n < a; n++) + (i || !(n in e)) && (i || (i = Array.prototype.slice.call(e, 0, n)), i[n] = e[n]); + return t.concat(i || Array.prototype.slice.call(e)); +} +function pn(t, e) { + return I({ events: [], props: [], name: t }, e); +} +var Wf = ["n", "w", "s", "e"], Ni = ["n", "w", "s", "e", "nw", "ne", "sw", "se"]; +function Yf(t, e) { + return 'data:image/svg+xml;utf8,'); +} +function Xf(t) { + var e = Yf(1, t), r = Math.round(t / 45) * 45 % 180, n = "ns-resize"; + return r === 135 ? n = "nwse-resize" : r === 45 ? n = "nesw-resize" : r === 90 && (n = "ew-resize"), "cursor:".concat(n, ";cursor: url('").concat(e, "') 16 16, ").concat(n, ";"); +} +var Br = Ac(), vl = Br.browser.webkit, hl = vl && (function() { + var t = typeof window > "u" ? { userAgent: "" } : window.navigator, e = /applewebkit\/([^\s]+)/g.exec(t.userAgent.toLowerCase()); + return e ? parseFloat(e[1]) < 605 : !1; +})(), gl = Br.browser.name, ml = parseInt(Br.browser.version, 10), Hf = gl === "chrome", qf = Br.browser.chromium, Vf = parseInt(Br.browser.chromiumVersion, 10) || 0, $f = Hf && ml >= 109 || qf && Vf >= 109, Uf = gl === "firefox", Kf = parseInt(Br.browser.webkitVersion, 10) >= 612 || ml >= 15, Bi = "moveable-", Zf = Ni.map(function(t) { + var e = "", r = "", n = "center", a = "center", i = "calc(var(--moveable-control-padding, 20) * -1px)"; + return t.indexOf("n") > -1 && (e = "top: ".concat(i, ";"), a = "bottom"), t.indexOf("s") > -1 && (e = "top: 0px;", a = "top"), t.indexOf("w") > -1 && (r = "left: ".concat(i, ";"), n = "right"), t.indexOf("e") > -1 && (r = "left: 0px;", n = "left"), '.around-control[data-direction*="'.concat(t, `"] { + `).concat(r).concat(e, ` + transform-origin: `).concat(n, " ").concat(a, `; + }`); +}).join(` +`), Jf = ` +{ +position: absolute; +width: 1px; +height: 1px; +left: 0; +top: 0; +z-index: 3000; +--moveable-color: #4af; +--zoom: 1; +--zoompx: 1px; +--moveable-line-padding: 0; +--moveable-control-padding: 0; +will-change: transform; +outline: 1px solid transparent; +} +.control-box { +z-index: 0; +} +.line, .control { +position: absolute; +left: 0; +top: 0; +will-change: transform; +} +.control { +width: 14px; +height: 14px; +border-radius: 50%; +border: 2px solid #fff; +box-sizing: border-box; +background: #4af; +background: var(--moveable-color); +margin-top: -7px; +margin-left: -7px; +border: 2px solid #fff; +z-index: 10; +} +.around-control { +position: absolute; +will-change: transform; +width: calc(var(--moveable-control-padding, 20) * 1px); +height: calc(var(--moveable-control-padding, 20) * 1px); +left: calc(var(--moveable-control-padding, 20) * -0.5px); +top: calc(var(--moveable-control-padding, 20) * -0.5px); +box-sizing: border-box; +background: transparent; +z-index: 8; +cursor: alias; +transform-origin: center center; +} +`.concat(Zf, ` +.padding { +position: absolute; +top: 0px; +left: 0px; +width: 100px; +height: 100px; +transform-origin: 0 0; +} +.line { +width: 1px; +height: 1px; +background: #4af; +background: var(--moveable-color); +transform-origin: 0px 50%; +} +.line.edge { +z-index: 1; +background: transparent; +} +.line.dashed { +box-sizing: border-box; +background: transparent; +} +.line.dashed.horizontal { +border-top: 1px dashed #4af; +border-top-color: #4af; +border-top-color: var(--moveable-color); +} +.line.dashed.vertical { +border-left: 1px dashed #4af; +border-left-color: #4af; +border-left-color: var(--moveable-color); +} +.line.vertical { +transform: translateX(-50%); +} +.line.horizontal { +transform: translateY(-50%); +} +.line.vertical.bold { +width: 2px; +} +.line.horizontal.bold { +height: 2px; +} + +.control.origin { +border-color: #f55; +background: #fff; +width: 12px; +height: 12px; +margin-top: -6px; +margin-left: -6px; +pointer-events: none; +} +`).concat([0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165].map(function(t) { + return ` +.direction[data-rotation="`.concat(t, '"], :global .view-control-rotation').concat(t, ` { +`).concat(Xf(t), ` +} +`); +}).join(` +`), ` + +.line.direction:before { +content: ""; +position: absolute; +width: 100%; +height: calc(var(--moveable-line-padding, 0) * 1px); +bottom: 0; +left: 0; +} +.group { +z-index: -1; +} +.area { +position: absolute; +} +.area-pieces { +position: absolute; +top: 0; +left: 0; +display: none; +} +.area.avoid, .area.pass { +pointer-events: none; +} +.area.avoid+.area-pieces { +display: block; +} +.area-piece { +position: absolute; +} + +`).concat(hl ? `:global svg *:before { +content:""; +transform-origin: inherit; +}` : "", ` +`), Qf = [ + [0, 1, 2], + [1, 0, 3], + [2, 0, 3], + [3, 1, 2] +], ai = 1e-4, le = 1e-7, Tn = 1e-9, ii = Math.pow(10, 10), Xo = -ii, td = { + n: [0, -1], + e: [1, 0], + s: [0, 1], + w: [-1, 0], + nw: [-1, -1], + ne: [1, -1], + sw: [-1, 1], + se: [1, 1] +}, ji = { + n: [0, 1], + e: [1, 3], + s: [3, 2], + w: [2, 0], + nw: [0], + ne: [1], + sw: [2], + se: [3] +}, xl = { + n: 0, + s: 180, + w: 270, + e: 90, + nw: 315, + ne: 45, + sw: 225, + se: 135 +}, ed = [ + "isMoveableElement", + "updateRect", + "updateTarget", + "destroy", + "dragStart", + "isInside", + "hitTest", + "setState", + "getRect", + "request", + "isDragging", + "getManager", + "forceUpdate", + "waitToChangeTarget", + "updateSelectors", + "getTargets", + "stopDrag", + "getControlBoxElement", + "getMoveables", + "getDragElement" +]; +function vn(t, e, r, n, a, i) { + var o, s; + i === void 0 && (i = "draggable"); + var l = (s = (o = e.gestos[i]) === null || o === void 0 ? void 0 : o.move(r, t.inputEvent)) !== null && s !== void 0 ? s : {}, u = l.originalDatas || l.datas, c = u[i] || (u[i] = {}); + return I(I({}, l), { isPinch: !!n, parentEvent: !0, datas: c, originalDatas: t.originalDatas }); +} +var Rr = /* @__PURE__ */ (function() { + function t(e) { + var r; + e === void 0 && (e = "draggable"), this.ableName = e, this.prevX = 0, this.prevY = 0, this.startX = 0, this.startY = 0, this.isDrag = !1, this.isFlag = !1, this.datas = { + draggable: {} + }, this.datas = (r = {}, r[e] = {}, r); + } + return t.prototype.dragStart = function(e, r) { + this.isDrag = !1, this.isFlag = !1; + var n = r.originalDatas; + return this.datas = n, n[this.ableName] || (n[this.ableName] = {}), I(I({}, this.move(e, r.inputEvent)), { type: "dragstart" }); + }, t.prototype.drag = function(e, r) { + return this.move([ + e[0] - this.prevX, + e[1] - this.prevY + ], r); + }, t.prototype.move = function(e, r) { + var n, a, i = !1; + if (!this.isFlag) + this.prevX = e[0], this.prevY = e[1], this.startX = e[0], this.startY = e[1], n = e[0], a = e[1], this.isFlag = !0; + else { + var o = this.isDrag; + n = this.prevX + e[0], a = this.prevY + e[1], (e[0] || e[1]) && (this.isDrag = !0), !o && this.isDrag && (i = !0); + } + return this.prevX = n, this.prevY = a, { + type: "drag", + clientX: n, + clientY: a, + inputEvent: r, + isFirstDrag: i, + isDrag: this.isDrag, + distX: n - this.startX, + distY: a - this.startY, + deltaX: e[0], + deltaY: e[1], + datas: this.datas[this.ableName], + originalDatas: this.datas, + parentEvent: !0, + parentGesto: this + }; + }, t; +})(); +function kr(t, e, r, n) { + var a = t.length === 16, i = a ? 4 : 3, o = dr(t, r, n, i), s = O(o, 4), l = O(s[0], 2), u = l[0], c = l[1], f = O(s[1], 2), d = f[0], p = f[1], h = O(s[2], 2), g = h[0], x = h[1], y = O(s[3], 2), b = y[0], C = y[1], S = O(Gt(t, e, i), 2), w = S[0], v = S[1], _ = Math.min(u, d, g, b), M = Math.min(c, p, x, C), T = Math.max(u, d, g, b), k = Math.max(c, p, x, C); + u = u - _ || 0, d = d - _ || 0, g = g - _ || 0, b = b - _ || 0, c = c - M || 0, p = p - M || 0, x = x - M || 0, C = C - M || 0, w = w - _ || 0, v = v - M || 0; + var A = t[0], z = t[i + 1], R = oe(A * z); + return { + left: _, + top: M, + right: T, + bottom: k, + origin: [w, v], + pos1: [u, c], + pos2: [d, p], + pos3: [g, x], + pos4: [b, C], + direction: R + }; +} +function yl(t, e) { + var r = e.clientX, n = e.clientY, a = e.datas, i = t.state, o = i.moveableClientRect, s = i.rootMatrix, l = i.is3d, u = i.pos1, c = o.left, f = o.top, d = l ? 4 : 3, p = O(ct(zr(s, [r - c, n - f], d), u), 2), h = p[0], g = p[1], x = O(Oe({ datas: a, distX: h, distY: g }), 2), y = x[0], b = x[1]; + return [y, b]; +} +function fr(t, e) { + var r = e.datas, n = t.state, a = n.allMatrix, i = n.beforeMatrix, o = n.is3d, s = n.left, l = n.top, u = n.origin, c = n.offsetMatrix, f = n.targetMatrix, d = n.transformOrigin, p = o ? 4 : 3; + r.is3d = o, r.matrix = a, r.targetMatrix = f, r.beforeMatrix = i, r.offsetMatrix = c, r.transformOrigin = d, r.inverseMatrix = ke(a, p), r.inverseBeforeMatrix = ke(i, p), r.absoluteOrigin = sr(wt([s, l], u), p), r.startDragBeforeDist = ne(r.inverseBeforeMatrix, r.absoluteOrigin, p), r.startDragDist = ne(r.inverseMatrix, r.absoluteOrigin, p); +} +function rd(t) { + return kr(t.datas.beforeTransform, [50, 50], 100, 100).direction; +} +function sa(t, e, r) { + var n = e.datas, a = e.originalDatas.beforeRenderable, i = n.transformIndex, o = a.nextTransforms, s = o.length, l = a.nextTransformAppendedIndexes, u = -1; + i === -1 ? (r === "translate" ? u = 0 : r === "rotate" && (u = Ge(o, function(p) { + return p.match(/scale\(/g); + })), u === -1 && (u = o.length), n.transformIndex = u) : ve(l, function(p) { + return p.index === i && p.functionName === r; + }) ? u = i : u = i + l.filter(function(p) { + return p.index < i; + }).length; + var c = kp(o, t.state, u), f = c.targetFunction, d = r === "rotate" ? "rotateZ" : r; + n.beforeFunctionTexts = c.beforeFunctionTexts, n.afterFunctionTexts = c.afterFunctionTexts, n.beforeTransform = c.beforeFunctionMatrix, n.beforeTransform2 = c.beforeFunctionMatrix2, n.targetTansform = c.targetFunctionMatrix, n.afterTransform = c.afterFunctionMatrix, n.afterTransform2 = c.afterFunctionMatrix2, n.targetAllTransform = c.allFunctionMatrix, f.functionName === d ? (n.afterFunctionTexts.splice(0, 1), n.isAppendTransform = !1) : s > u && (n.isAppendTransform = !0, a.nextTransformAppendedIndexes = Z(Z([], O(l), !1), [{ + functionName: r, + index: u, + isAppend: !0 + }], !1)); +} +function la(t, e, r) { + return "".concat(t.beforeFunctionTexts.join(" "), " ").concat(t.isAppendTransform ? r : e, " ").concat(t.afterFunctionTexts.join(" ")); +} +function nd(t) { + var e = t.datas, r = t.distX, n = t.distY, a = O(Sl({ datas: e, distX: r, distY: n }), 2), i = a[0], o = a[1], s = bl(e, af([i, o], 4)); + return ne(s, sr([0, 0, 0], 4), 4); +} +function bl(t, e, r) { + var n = t.beforeTransform, a = t.afterTransform, i = t.beforeTransform2, o = t.afterTransform2, s = t.targetAllTransform, l = r ? Pt(s, e, 4) : Pt(e, s, 4), u = Pt(ke(r ? i : n, 4), l, 4), c = Pt(u, ke(r ? o : a, 4), 4); + return c; +} +function Sl(t) { + var e = t.datas, r = t.distX, n = t.distY, a = e.inverseBeforeMatrix, i = e.is3d, o = e.startDragBeforeDist, s = e.absoluteOrigin, l = i ? 4 : 3; + return ct(ne(a, wt(s, [r, n]), l), o); +} +function Oe(t, e) { + var r = t.datas, n = t.distX, a = t.distY, i = r.inverseBeforeMatrix, o = r.inverseMatrix, s = r.is3d, l = r.startDragBeforeDist, u = r.startDragDist, c = r.absoluteOrigin, f = s ? 4 : 3; + return ct(ne(e ? i : o, wt(c, [n, a]), f), e ? l : u); +} +function ad(t, e) { + var r = t.datas, n = t.distX, a = t.distY; + r.beforeMatrix; + var i = r.matrix, o = r.is3d; + r.startDragBeforeDist; + var s = r.startDragDist, l = r.absoluteOrigin, u = o ? 4 : 3; + return ct(ne(i, wt(s, [n, a]), u), l); +} +function id(t, e, r, n, a, i) { + return n === void 0 && (n = e), a === void 0 && (a = r), i === void 0 && (i = [0, 0]), t ? t.map(function(o, s) { + var l = or(o), u = l.value, c = l.unit, f = s ? a : n, d = s ? r : e; + if (o === "%" || isNaN(u)) { + var p = f ? i[s] / f : 0; + return d * p; + } else if (c !== "%") + return u; + return d * u / 100; + }) : i; +} +function Cl(t) { + var e = []; + return t[1] >= 0 && (t[0] >= 0 && e.push(3), t[0] <= 0 && e.push(2)), t[1] <= 0 && (t[0] >= 0 && e.push(1), t[0] <= 0 && e.push(0)), e; +} +function od(t, e) { + return Cl(e).map(function(r) { + return t[r]; + }); +} +function Ma(t, e) { + var r = (e + 1) / 2; + return [ + Hn(t[0][0], t[1][0], r, 1 - r), + Hn(t[0][1], t[1][1], r, 1 - r) + ]; +} +function Qt(t, e) { + var r = Ma([t[0], t[1]], e[0]), n = Ma([t[2], t[3]], e[0]); + return Ma([r, n], e[1]); +} +function sd(t, e, r, n, a, i) { + var o = dr(e, r, n, a), s = Qt(o, i), l = t[0] - s[0], u = t[1] - s[1]; + return [l, u]; +} +function hn(t, e, r, n) { + return Pt(t, Qr(e, n, r), n); +} +function ld(t, e, r, n) { + var a = t.transformOrigin, i = t.offsetMatrix, o = t.is3d, s = o ? 4 : 3, l; + if (be(r)) { + var u = e.beforeTransform, c = e.afterTransform; + n ? l = Te(Tr(r), 4, s) : l = Te(Pt(Pt(u, Tr([r]), 4), c, 4), 4, s); + } else + l = r; + return hn(i, l, a, s); +} +function ud(t, e) { + var r = t.transformOrigin, n = t.offsetMatrix, a = t.is3d, i = t.targetMatrix, o = t.targetAllTransform, s = a ? 4 : 3; + return hn(n, Pt(o || i, Ri(e, s), s), r, s); +} +function ua(t, e) { + var r = jr(e); + return { + setTransform: function(n, a) { + a === void 0 && (a = -1), r.startTransforms = Yt(n) ? n : Ve(n), oi(t, e, a); + }, + setTransformIndex: function(n) { + oi(t, e, n); + } + }; +} +function ca(t, e, r) { + var n = jr(e), a = n.startTransforms; + oi(t, e, Ge(a, function(i) { + return i.indexOf("".concat(r, "(")) === 0; + })); +} +function oi(t, e, r) { + var n = jr(e), a = e.datas; + if (a.transformIndex = r, r !== -1) { + var i = n.startTransforms[r]; + if (i) { + var o = t.state, s = Ir([i], { + "x%": function(l) { + return l / 100 * o.offsetWidth; + }, + "y%": function(l) { + return l / 100 * o.offsetHeight; + } + }); + a.startValue = s[0].functionValue; + } + } +} +function Gi(t, e) { + var r = jr(t); + r.nextTransforms = Ve(e); +} +function jr(t) { + return t.originalDatas.beforeRenderable; +} +function Kn(t) { + var e = t.originalDatas.beforeRenderable; + return e.nextTransforms; +} +function In(t) { + return (Kn(t) || []).join(" "); +} +function Rn(t) { + return jr(t).nextStyle; +} +function El(t, e, r, n, a) { + Gi(a, e); + var i = ie.drag(t, vn(a, t.state, r, n)), o = i ? i.transform : e; + return I(I({ transform: e, drag: i }, se({ + transform: o + }, a)), { afterTransform: o }); +} +function Fi(t, e, r, n, a, i) { + var o = ld(t.state, a, e, i), s = dd(t, r, n, o); + return s; +} +function Dl(t, e, r, n, a, i, o) { + var s = Fi(t, e, r, a, i, o), l = t.state, u = l.left, c = l.top, f = t.props.groupable, d = f ? u : 0, p = f ? c : 0, h = ct(n, s); + return ct(h, [d, p]); +} +function cd(t, e, r, n, a, i, o) { + var s = Dl(t, e, r, n, a, i, o); + return s; +} +function fd(t, e, r) { + return [ + e ? -1 + t[0] / (e / 2) : 0, + r ? -1 + t[1] / (r / 2) : 0 + ]; +} +function dd(t, e, r, n) { + n === void 0 && (n = t.state.allMatrix); + var a = t.state, i = a.width, o = a.height, s = a.is3d, l = s ? 4 : 3, u = [ + i / 2 * (1 + e[0]) + r[0], + o / 2 * (1 + e[1]) + r[1] + ]; + return Gt(n, u, l); +} +function pd(t, e, r) { + var n = r.fixedDirection, a = r.fixedPosition, i = r.fixedOffset; + return Dl(t, "rotate(".concat(e, "deg)"), n, a, i, r); +} +function vd(t, e, r, n, a, i) { + var o = t.props.groupable, s = t.state, l = s.transformOrigin, u = s.offsetMatrix, c = s.is3d, f = s.width, d = s.height, p = s.left, h = s.top, g = i.fixedDirection, x = i.nextTargetMatrix || s.targetMatrix, y = c ? 4 : 3, b = id(a, e, r, f, d, l), C = o ? p : 0, S = o ? h : 0, w = hn(u, x, b, y), v = sd(n, w, e, r, y, g); + return ct(v, [C, S]); +} +function hd(t, e) { + return Qt(Ce(t.state), e); +} +function gd(t, e) { + var r = t.targetGesto, n = t.controlGesto, a; + return r != null && r.isFlag() && (a = r.getEventData()[e]), !a && (n != null && n.isFlag()) && (a = n.getEventData()[e]), a || {}; +} +function md(t) { + if (t && t.getRootNode) { + var e = t.getRootNode(); + if (e.nodeType === 11) + return e; + } +} +function xd(t) { + var e = t("scale"), r = t("rotate"), n = t("translate"), a = []; + return n && n !== "0px" && n !== "none" && a.push("translate(".concat(n.split(/\s+/).join(","), ")")), r && r !== "1" && r !== "none" && a.push("rotate(".concat(r, ")")), e && e !== "1" && e !== "none" && a.push("scale(".concat(e.split(/\s+/).join(","), ")")), a; +} +function wl(t, e, r) { + for (var n = t, a = [], i = Ii(t) || Ke(t), o = !r && t === e || t === i, s = o, l = !1, u = 3, c, f, d, p = !1, h = ln(e, e, !0).offsetParent, g = 1; n && !s; ) { + s = o; + var x = de(n), y = x("position"), b = Ul(n), C = y === "fixed", S = xd(x), w = of(hp(b)), v = void 0, _ = !1, M = !1, T = 0, k = 0, A = 0, z = 0, R = { + hasTransform: !1, + fixedContainer: null + }; + C && (p = !0, R = bp(n), h = R.fixedContainer); + var B = w.length; + !l && (B === 16 || S.length) && (l = !0, u = 4, di(a), d && (d = Te(d, 3, 4))), l && B === 9 && (w = Te(w, 3, 4)); + var N = yp(n, t), L = N.tagName, V = N.hasOffset, G = N.isSVG, W = N.origin, $ = N.targetOrigin, j = N.offset, J = O(j, 2), Q = J[0], H = J[1]; + L === "svg" && !n.ownerSVGElement && d && (a.push({ + type: "target", + target: n, + matrix: Sp(n, u) + }), a.push({ + type: "offset", + target: n, + matrix: At(u) + })); + var tt = parseFloat(x("zoom")) || 1; + if (C) + v = R.fixedContainer, _ = !0; + else { + var U = ln(n, e, !1, !0, x), et = U.offsetZoom; + if (v = U.offsetParent, _ = U.isEnd, M = U.isStatic, g *= et, (U.isCustomElement || et !== 1) && M) + Q -= v.offsetLeft, H -= v.offsetTop; + else if (Uf || $f) { + var lt = U.parentSlotElement; + if (lt) { + for (var ft = v, xt = 0, q = 0; ft && md(ft); ) + xt += ft.offsetLeft, q += ft.offsetTop, ft = ft.offsetParent; + Q -= xt, H -= q; + } + } + } + if (vl && !Kf && V && !G && M && (y === "relative" || y === "static") && (Q -= v.offsetLeft, H -= v.offsetTop, o = o || _), C) + V && R.hasTransform && (A = v.clientLeft, z = v.clientTop); + else if (V && h !== v && (T = v.clientLeft, k = v.clientTop), V && v === i) { + var nt = Kl(n, !1); + Q += nt[0], H += nt[1]; + } + if (a.push({ + type: "target", + target: n, + matrix: Qr(w, u, W) + }), S.length && (a.push({ + type: "offset", + target: n, + matrix: At(u) + }), a.push({ + type: "target", + target: n, + matrix: Qr(Tr(S), u, W) + })), V) { + var Et = n === t, pt = Et ? 0 : n.scrollLeft, vt = Et ? 0 : n.scrollTop; + a.push({ + type: "offset", + target: n, + matrix: lr([ + Q - pt + T - A, + H - vt + k - z + ], u) + }); + } else + a.push({ + type: "offset", + target: n, + origin: W + }); + if (tt !== 1 && a.push({ + type: "zoom", + target: n, + matrix: Qr(Ri([tt, tt], u), u, [0, 0]) + }), d || (d = w), c || (c = W), f || (f = $), s || C) + break; + n = v, o = _, (!r || n === i) && (s = o); + } + return d || (d = At(u)), c || (c = [0, 0]), f || (f = [0, 0]), { + zoom: g, + offsetContainer: h, + matrixes: a, + targetMatrix: d, + transformOrigin: c, + targetOrigin: f, + is3d: l, + hasFixed: p + }; +} +var er = null, rr = null, Er = null; +function Pr(t) { + t ? (window.Map && (er = /* @__PURE__ */ new Map(), rr = /* @__PURE__ */ new Map()), Er = []) : (er = null, Er = null, rr = null); +} +function yd(t) { + var e = rr == null ? void 0 : rr.get(t); + if (e) + return e; + var r = tn(t, !0); + return rr && rr.set(t, r), r; +} +function bd(t, e) { + if (Er) { + var r = ve(Er, function(a) { + return a[0][0] == t && a[0][1] == e; + }); + if (r) + return r[1]; + } + var n = wl(t, e, !0); + return Er && Er.push([[t, e], n]), n; +} +function de(t) { + var e = er == null ? void 0 : er.get(t); + if (!e) { + var r = xe(t).getComputedStyle(t); + if (!er) + return function(i) { + return r[i]; + }; + e = { + style: r, + cached: {} + }, er.set(t, e); + } + var n = e.cached, a = e.style; + return function(i) { + return i in n || (n[i] = a[i]), n[i]; + }; +} +function Me(t, e, r) { + var n = r.originalDatas; + n.groupable = n.groupable || {}; + var a = n.groupable; + a.childDatas = a.childDatas || []; + var i = a.childDatas; + return t.moveables.map(function(o, s) { + return i[s] = i[s] || {}, i[s][e] = i[s][e] || {}, I(I({}, r), { isRequestChild: !0, datas: i[s][e], originalDatas: i[s] }); + }); +} +function ka(t, e, r, n, a, i, o) { + var s = !!r.match(/Start$/g), l = !!r.match(/End$/g), u = a.isPinch, c = a.datas, f = Me(t, e.name, a), d = t.moveables, p = [], h = f.map(function(g, x) { + var y = d[x], b = y.state, C = b.gestos, S = g; + if (s) + S = new Rr(o).dragStart(n, g), p.push(S); + else { + if (C[o] || (C[o] = c.childGestos[x]), !C[o]) + return; + S = vn(g, b, n, u, i, o), p.push(S); + } + var w = e[r](y, I(I({}, S), { parentFlag: !0 })); + return l && (C[o] = null), w; + }); + return s && (c.childGestos = d.map(function(g) { + return g.state.gestos[o]; + })), { + eventParams: h, + childEvents: p + }; +} +function je(t, e, r, n, a, i) { + a === void 0 && (a = function(c, f) { + return f; + }); + var o = !!r.match(/End$/g), s = Me(t, e.name, n), l = t.moveables, u = s.map(function(c, f) { + var d = l[f], p = c; + p = a(d, c); + var h = e[r](d, I(I({}, p), { parentFlag: !0 })); + return o && (d.state.gestos = {}), h; + }); + return u; +} +function Zn(t, e, r, n) { + var a = r.fixedDirection, i = r.fixedPosition, o = n.datas.startPositions || Ce(e.state), s = Qt(o, a), l = O(ne(cn(-t.rotation / 180 * Math.PI, 3), [s[0] - i[0], s[1] - i[1], 1], 3), 2), u = l[0], c = l[1]; + return n.datas.originalX = u, n.datas.originalY = c, n; +} +function _l(t, e, r, n) { + var a = t.getState(), i = a.renderPoses, o = a.rotation, s = a.direction, l = cr(t.props, e).zoom, u = Jr(o / Math.PI * 180), c = {}, f = t.renderState; + f.renderDirectionMap || (f.renderDirectionMap = {}); + var d = f.renderDirectionMap; + r.forEach(function(h) { + var g = h.dir; + c[g] = !0; + }); + var p = oe(s); + return r.map(function(h) { + var g = h.data, x = h.classNames, y = h.dir, b = ji[y]; + if (!b || !c[y]) + return null; + d[y] = !0; + var C = (gt(u, 15) + p * xl[y] + 720) % 180, S = {}; + return Nr(g).forEach(function(w) { + S["data-".concat(w)] = g[w]; + }), n.createElement("div", I({ className: ut.apply(void 0, Z(["control", "direction", y, e], O(x), !1)), "data-rotation": C, "data-direction": y }, S, { key: "direction-".concat(y), style: ea.apply(void 0, Z([o, l], O(b.map(function(w) { + return i[w]; + })), !1)) })); + }); +} +function Ml(t, e, r, n) { + var a = cr(t.props, r), i = a.renderDirections, o = i === void 0 ? e : i, s = a.displayAroundControls; + if (!o) + return []; + var l = o === !0 ? Ni : o; + return Z(Z([], O(s ? Rl(t, n, r, l) : []), !1), O(_l(t, r, l.map(function(u) { + return { + data: {}, + classNames: [], + dir: u + }; + }), n)), !1); +} +function sn(t, e, r, n, a, i) { + for (var o = [], s = 6; s < arguments.length; s++) + o[s - 6] = arguments[s]; + var l = Xt(r, n), u = e ? gt(l / Math.PI * 180, 15) % 180 : -1; + return t.createElement("div", { key: "line-".concat(i), className: ut.apply(void 0, Z(["line", "direction", e ? "edge" : "", e], O(o), !1)), "data-rotation": u, "data-line-key": i, "data-direction": e, style: $r(r, n, a, l) }); +} +function kl(t, e, r, n, a) { + var i = r === !0 ? Wf : r; + return i.map(function(o, s) { + var l = O(ji[o], 2), u = l[0], c = l[1]; + if (c != null) + return sn(t, o, n[u], n[c], a, "".concat(e, "Edge").concat(s), e); + }).filter(Boolean); +} +function Tl(t) { + return function(e, r) { + var n = cr(e.props, t).edge; + return n && (n === !0 || n.length) ? Z(Z([], O(kl(r, t, n, e.getState().renderPoses, e.props.zoom)), !1), O(Sd(e, t, r)), !1) : Il(e, t, r); + }; +} +function Il(t, e, r) { + return Ml(t, Ni, e, r); +} +function Sd(t, e, r) { + return Ml(t, ["nw", "ne", "sw", "se"], e, r); +} +function Rl(t, e, r, n) { + var a = t.renderState; + a.renderDirectionMap || (a.renderDirectionMap = {}); + var i = t.getState(), o = i.renderPoses, s = i.rotation, l = i.direction, u = a.renderDirectionMap, c = t.props.zoom, f = oe(l), d = s / Math.PI * 180; + return (n || Nr(u)).map(function(p) { + var h = ji[p]; + if (!h) + return null; + var g = (gt(d, 15) + f * xl[p] + 720) % 180, x = ["around-control"]; + return r && x.push("direction", r), e.createElement("div", { className: ut.apply(void 0, Z([], O(x), !1)), "data-rotation": g, "data-direction": p, key: "direction-around-".concat(p), style: ea.apply(void 0, Z([s, c], O(h.map(function(y) { + return o[y]; + })), !1)) }); + }); +} +function Li(t, e, r) { + var n = t || {}, a = n.position, i = a === void 0 ? "client" : a, o = n.left, s = o === void 0 ? -1 / 0 : o, l = n.top, u = l === void 0 ? -1 / 0 : l, c = n.right, f = c === void 0 ? 1 / 0 : c, d = n.bottom, p = d === void 0 ? 1 / 0 : d, h = { + position: i, + left: s, + top: u, + right: f, + bottom: p + }; + return { + vertical: Ho(h, e, !0), + horizontal: Ho(h, r, !1) + }; +} +function fa(t, e) { + var r = t.state, n = r.containerClientRect, a = n.clientHeight, i = n.clientWidth, o = n.clientLeft, s = n.clientTop, l = r.snapOffset, u = l.left, c = l.top, f = l.right, d = l.bottom, p = e || t.props.bounds || {}, h = p.position || "client", g = h === "css", x = p.left, y = x === void 0 ? -1 / 0 : x, b = p.top, C = b === void 0 ? -1 / 0 : b, S = p.right, w = S === void 0 ? g ? -1 / 0 : 1 / 0 : S, v = p.bottom, _ = v === void 0 ? g ? -1 / 0 : 1 / 0 : v; + return g && (w = i + f - u - w, _ = a + d - c - _), { + left: y + u - o, + right: w + u - o, + top: C + c - s, + bottom: _ + c - s + }; +} +function Cd(t, e, r) { + var n = fa(t), a = n.left, i = n.top, o = n.right, s = n.bottom, l = O(r, 2), u = l[0], c = l[1], f = O(ct(r, e), 2), d = f[0], p = f[1]; + Y(d) < le && (d = 0), Y(p) < le && (p = 0); + var h = p > 0, g = d > 0, x = { + isBound: !1, + offset: 0, + pos: 0 + }, y = { + isBound: !1, + offset: 0, + pos: 0 + }; + if (d === 0 && p === 0) + return { + vertical: x, + horizontal: y + }; + if (d === 0) + h ? s < c && (y.pos = s, y.offset = c - s) : i > c && (y.pos = i, y.offset = c - i); + else if (p === 0) + g ? o < u && (x.pos = o, x.offset = u - o) : a > u && (x.pos = a, x.offset = u - a); + else { + var b = p / d, C = r[1] - b * u, S = 0, w = 0, v = !1; + g && o <= u ? (S = b * o + C, w = o, v = !0) : !g && u <= a && (S = b * a + C, w = a, v = !0), v && (S < i || S > s) && (v = !1), v || (h && s <= c ? (S = s, w = (S - C) / b, v = !0) : !h && c <= i && (S = i, w = (S - C) / b, v = !0)), v && (x.isBound = !0, x.pos = w, x.offset = u - w, y.isBound = !0, y.pos = S, y.offset = c - S); + } + return { + vertical: x, + horizontal: y + }; +} +function Ho(t, e, r) { + var n = t[r ? "left" : "top"], a = t[r ? "right" : "bottom"], i = Math.min.apply(Math, Z([], O(e), !1)), o = Math.max.apply(Math, Z([], O(e), !1)), s = []; + return n + 1 > i && s.push({ + direction: "start", + isBound: !0, + offset: i - n, + pos: n + }), a - 1 < o && s.push({ + direction: "end", + isBound: !0, + offset: o - a, + pos: a + }), s.length || s.push({ + isBound: !1, + offset: 0, + pos: 0 + }), s.sort(function(l, u) { + return Y(u.offset) - Y(l.offset); + }); +} +function qo(t, e, r) { + var n = r ? t.map(function(a) { + return un(a, r); + }) : t; + return n.some(function(a) { + return a[0] < e.left && Y(a[0] - e.left) > 0.1 || a[0] > e.right && Y(a[0] - e.right) > 0.1 || a[1] < e.top && Y(a[1] - e.top) > 0.1 || a[1] > e.bottom && Y(a[1] - e.bottom) > 0.1; + }); +} +function Ed(t, e, r) { + var n = Se(t), a = Math.sqrt(n * n - e * e) || 0; + return [a, -a].sort(function(i, o) { + return Y(i - t[r ? 0 : 1]) - Y(o - t[r ? 0 : 1]); + }).map(function(i) { + return Xt([0, 0], r ? [i, e] : [e, i]); + }); +} +function Dd(t, e, r, n, a) { + if (!t.props.bounds) + return []; + var i = a * Math.PI / 180, o = fa(t), s = o.left, l = o.top, u = o.right, c = o.bottom, f = s - n[0], d = u - n[0], p = l - n[1], h = c - n[1], g = { + left: f, + top: p, + right: d, + bottom: h + }; + if (!qo(r, g, 0)) + return []; + var x = []; + return [ + [f, 0], + [d, 0], + [p, 1], + [h, 1] + ].forEach(function(y) { + var b = O(y, 2), C = b[0], S = b[1]; + r.forEach(function(w) { + var v = Xt([0, 0], w); + x.push.apply(x, Z([], O(Ed(w, C, S).map(function(_) { + return i + _ - v; + }).filter(function(_) { + return !qo(e, g, _); + }).map(function(_) { + return gt(_ * 180 / Math.PI, le); + })), !1)); + }); + }), x; +} +var wd = ["left", "right", "center"], _d = ["top", "bottom", "middle"], Vo = { + left: "start", + right: "end", + center: "center", + top: "start", + bottom: "end", + middle: "center" +}, $e = { + start: "left", + end: "right", + center: "center" +}, Ue = { + start: "top", + end: "bottom", + center: "middle" +}; +function Dr() { + return { + left: !1, + top: !1, + right: !1, + bottom: !1 + }; +} +function Gr(t, e) { + var r = t.props, n = r.snappable, a = r.bounds, i = r.innerBounds, o = r.verticalGuidelines, s = r.horizontalGuidelines, l = r.snapGridWidth, u = r.snapGridHeight, c = t.state, f = c.guidelines, d = c.enableSnap; + return !n || !d || e && n !== !0 && n.indexOf(e) < 0 ? !1 : !!(l || u || a || i || f && f.length || o && o.length || s && s.length); +} +function Wi(t) { + return t === !1 ? {} : t === !0 || !t ? { left: !0, right: !0, top: !0, bottom: !0 } : t; +} +function Md(t, e) { + var r = Wi(t), n = {}; + for (var a in r) + a in e && r[a] && (n[a] = e[a]); + return n; +} +function Yi(t, e) { + var r = Md(t, e), n = _d.filter(function(i) { + return i in r; + }), a = wd.filter(function(i) { + return i in r; + }); + return { + horizontalNames: n, + verticalNames: a, + horizontal: n.map(function(i) { + return r[i]; + }), + vertical: a.map(function(i) { + return r[i]; + }) + }; +} +function kd(t, e, r) { + var n = Gt(t, [e.clientLeft, e.clientTop], r); + return [ + e.left + n[0], + e.top + n[1] + ]; +} +function Td(t) { + var e = O(t, 2), r = e[0], n = e[1], a = n[0] - r[0], i = n[1] - r[1]; + Math.abs(a) < Ut && (a = 0), Math.abs(i) < Ut && (i = 0); + var o = 0, s = 0, l = 0; + return a ? i ? (o = -i / a, s = 1, l = o * r[0] - r[1]) : (s = 1, l = -r[1]) : (o = -1, l = r[0]), [o, s, l].map(function(u) { + return gt(u, Ut); + }); +} +var Pl = "snapRotationThreshold", Ol = "snapRotationDegrees", zl = "snapHorizontalThreshold", Al = "snapVerticalThreshold"; +function da(t, e, r, n, a, i, o) { + var s; + n === void 0 && (n = []), a === void 0 && (a = []); + var l = t.props, u = ((s = t.state.snapThresholdInfo) === null || s === void 0 ? void 0 : s.multiples) || [1, 1], c = ls(o, l[zl], 5), f = ls(i, l[Al], 5); + return Nl(t.state.guidelines, e, r, n, a, c, f, u); +} +function Nl(t, e, r, n, a, i, o, s) { + return { + vertical: Uo(t, "vertical", e, o * s[0], n), + horizontal: Uo(t, "horizontal", r, i * s[1], a) + }; +} +function Id(t, e, r) { + var n = O(r, 2), a = n[0], i = n[1], o = O(e, 2), s = o[0], l = o[1], u = O(ct(r, e), 2), c = u[0], f = u[1], d = f > 0, p = c > 0; + c = ra(c), f = ra(f); + var h = { + isSnap: !1, + offset: 0, + pos: 0 + }, g = { + isSnap: !1, + offset: 0, + pos: 0 + }; + if (c === 0 && f === 0) + return { + vertical: h, + horizontal: g + }; + var x = da(t, c ? [a] : [], f ? [i] : [], [], [], void 0, void 0), y = x.vertical, b = x.horizontal; + y.posInfos.filter(function(L) { + var V = L.pos; + return p ? V >= s : V <= s; + }), b.posInfos.filter(function(L) { + var V = L.pos; + return d ? V >= l : V <= l; + }), y.isSnap = y.posInfos.length > 0, b.isSnap = b.posInfos.length > 0; + var C = si(y), S = C.isSnap, w = C.guideline, v = si(b), _ = v.isSnap, M = v.guideline, T = _ ? M.pos[1] : 0, k = S ? w.pos[0] : 0; + if (c === 0) + _ && (g.isSnap = !0, g.pos = M.pos[1], g.offset = i - g.pos); + else if (f === 0) + S && (h.isSnap = !0, h.pos = k, h.offset = a - k); + else { + var A = f / c, z = r[1] - A * a, R = 0, B = 0, N = !1; + S ? (B = k, R = A * B + z, N = !0) : _ && (R = T, B = (R - z) / A, N = !0), N && (h.isSnap = !0, h.pos = B, h.offset = a - B, g.isSnap = !0, g.pos = R, g.offset = i - R); + } + return { + vertical: h, + horizontal: g + }; +} +function Xe(t) { + var e = ""; + return t === -1 || t === "top" || t === "left" ? e = "start" : t === 0 || t === "center" || t === "middle" ? e = "center" : (t === 1 || t === "right" || t === "bottom") && (e = "end"), e; +} +function $o(t, e, r, n) { + var a = Yi(t.props.snapDirections, e), i = da(t, a.vertical, a.horizontal, a.verticalNames.map(function(l) { + return Xe(l); + }), a.horizontalNames.map(function(l) { + return Xe(l); + }), r, n), o = Xe(a.horizontalNames[i.horizontal.index]), s = Xe(a.verticalNames[i.vertical.index]); + return { + vertical: I(I({}, i.vertical), { direction: s }), + horizontal: I(I({}, i.horizontal), { direction: o }) + }; +} +function si(t) { + var e = t.isSnap; + if (!e) + return { + isSnap: !1, + offset: 0, + dist: -1, + pos: 0, + guideline: null + }; + var r = t.posInfos[0], n = r.guidelineInfos[0], a = n.offset, i = n.dist, o = n.guideline; + return { + isSnap: e, + offset: a, + dist: i, + pos: r.pos, + guideline: o + }; +} +function Uo(t, e, r, n, a) { + var i, o; + if (a === void 0 && (a = []), !t || !t.length) + return { + isSnap: !1, + index: -1, + direction: "", + posInfos: [] + }; + var s = e === "vertical", l = s ? 0 : 1, u = r.map(function(f, d) { + var p = a[d] || "", h = t.map(function(g) { + var x = g.pos, y = f - x[l]; + return { + offset: y, + dist: Y(y), + guideline: g, + direction: p + }; + }).filter(function(g) { + var x = g.guideline, y = g.dist, b = x.type; + return !(b !== e || y > n); + }).sort(function(g, x) { + return g.dist - x.dist; + }); + return { + pos: f, + index: d, + guidelineInfos: h, + direction: p + }; + }).filter(function(f) { + return f.guidelineInfos.length > 0; + }).sort(function(f, d) { + return f.guidelineInfos[0].dist - d.guidelineInfos[0].dist; + }), c = u.length > 0; + return { + isSnap: c, + index: c ? u[0].index : -1, + direction: (o = (i = u[0]) === null || i === void 0 ? void 0 : i.direction) !== null && o !== void 0 ? o : "", + posInfos: u + }; +} +function Rd(t, e, r, n, a) { + var i = []; + r[0] && r[1] ? i = [ + r, + [-r[0], r[1]], + [r[0], -r[1]] + ] : !r[0] && !r[1] ? [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1] + ].forEach(function(d, p, h) { + var g = h[p + 1] || h[0]; + i.push(d), i.push([ + (d[0] + g[0]) / 2, + (d[1] + g[1]) / 2 + ]); + }) : t.props.keepRatio ? i.push([-1, -1], [-1, 1], [1, -1], [1, 1], r) : (i.push.apply(i, Z([], O(od([ + [-1, -1], + [1, -1], + [-1, -1], + [1, 1] + ], r)), !1)), i.length > 1 && i.push([ + (i[0][0] + i[1][0]) / 2, + (i[0][1] + i[1][1]) / 2 + ])); + var o = i.map(function(d) { + return Qt(e, d); + }), s = o.map(function(d) { + return d[0]; + }), l = o.map(function(d) { + return d[1]; + }), u = da(t, s, l, i.map(function(d) { + return Xe(d[0]); + }), i.map(function(d) { + return Xe(d[1]); + }), n, a), c = Xe(i.map(function(d) { + return d[0]; + })[u.vertical.index]), f = Xe(i.map(function(d) { + return d[1]; + })[u.horizontal.index]); + return { + vertical: I(I({}, u.vertical), { direction: c }), + horizontal: I(I({}, u.horizontal), { direction: f }) + }; +} +function Bl(t, e) { + var r = Y(t.offset), n = Y(e.offset); + return t.isBound && e.isBound ? n - r : t.isBound ? -1 : e.isBound ? 1 : t.isSnap && e.isSnap ? n - r : t.isSnap ? -1 : e.isSnap || r < le ? 1 : n < le ? -1 : r - n; +} +function Jn(t, e) { + return t.slice().sort(function(r, n) { + var a = r.sign[e], i = n.sign[e], o = r.offset[e], s = n.offset[e]; + if (a) { + if (!i) + return -1; + } else return 1; + return Bl({ isBound: r.isBound, isSnap: r.isSnap, offset: o }, { isBound: n.isBound, isSnap: n.isSnap, offset: s }); + })[0]; +} +function Pd(t, e, r) { + var n = []; + if (r) + Y(e[0]) !== 1 || Y(e[1]) !== 1 ? n.push([e, [-1, -1]], [e, [-1, 1]], [e, [1, -1]], [e, [1, 1]]) : n.push([e, [t[0], -t[1]]], [e, [-t[0], t[1]]]), n.push([e, t]); + else if (t[0] && t[1] || !t[0] && !t[1]) { + var a = t[0] ? t : [1, 1]; + [1, -1].forEach(function(o) { + [1, -1].forEach(function(s) { + var l = [o * a[0], s * a[1]]; + e[0] === l[0] && e[1] === l[1] || n.push([e, l]); + }); + }); + } else if (t[0]) { + var i = Y(e[0]) === 1 ? [1] : [1, -1]; + i.forEach(function(o) { + n.push([ + [e[0], -1], + [o * t[0], -1] + ], [ + [e[0], 0], + [o * t[0], 0] + ], [ + [e[0], 1], + [o * t[0], 1] + ]); + }); + } else if (t[1]) { + var i = Y(e[1]) === 1 ? [1] : [1, -1]; + i.forEach(function(s) { + n.push([ + [-1, e[1]], + [-1, s * t[1]] + ], [ + [0, e[1]], + [0, s * t[1]] + ], [ + [1, e[1]], + [1, s * t[1]] + ]); + }); + } + return n; +} +function jl(t, e) { + var r = Va([e[0][0], e[1][0]]), n = Va([e[0][1], e[1][1]]); + return { + vertical: r <= t[0], + horizontal: n <= t[1] + }; +} +function Xi(t, e) { + var r = O(e, 2), n = r[0], a = r[1], i = a[0] - n[0], o = a[1] - n[1]; + Y(i) < le && (i = 0), Y(o) < le && (o = 0); + var s, l; + if (!i) + s = n[0], l = t[0]; + else if (!o) + s = n[1], l = t[1]; + else { + var u = o / i; + s = u * (t[0] - n[0]) + n[1], l = t[1]; + } + return s - l; +} +function Gl(t, e, r, n) { + return n === void 0 && (n = le), t.every(function(a) { + var i = Xi(a, e), o = i <= 0; + return o === r || Y(i) <= n; + }); +} +function Ko(t, e, r, n, a) { + return a === void 0 && (a = 0), n && e - a <= t || !n && t <= r + a ? { + isBound: !0, + offset: n ? e - t : r - t + } : { + isBound: !1, + offset: 0 + }; +} +function Od(t, e) { + var r = e.line, n = e.centerSign, a = e.verticalSign, i = e.horizontalSign, o = e.lineConstants, s = t.props.innerBounds; + if (!s) + return { + isAllBound: !1, + isBound: !1, + isVerticalBound: !1, + isHorizontalBound: !1, + offset: [0, 0] + }; + var l = s.left, u = s.top, c = s.width, f = s.height, d = [[l, u], [l, u + f]], p = [[l, u], [l + c, u]], h = [[l + c, u], [l + c, u + f]], g = [[l, u + f], [l + c, u + f]]; + if (Gl([ + [l, u], + [l + c, u], + [l, u + f], + [l + c, u + f] + ], r, n)) + return { + isAllBound: !1, + isBound: !1, + isVerticalBound: !1, + isHorizontalBound: !1, + offset: [0, 0] + }; + var x = He(r, o, p, a), y = He(r, o, g, a), b = He(r, o, d, i), C = He(r, o, h, i), S = x.isBound && y.isBound, w = x.isBound || y.isBound, v = b.isBound && C.isBound, _ = b.isBound || C.isBound, M = Or(x.offset, y.offset), T = Or(b.offset, C.offset), k = [0, 0], A = !1, z = !1; + return Y(T) < Y(M) ? (k = [M, 0], A = w, z = S) : (k = [0, T], A = _, z = v), { + isAllBound: z, + isVerticalBound: w, + isHorizontalBound: _, + isBound: A, + offset: k + }; +} +function He(t, e, r, n, a, i) { + var o = O(e, 2), s = o[0], l = o[1], u = t[0], c = r[0], f = r[1], d = ra(f[1] - c[1]), p = ra(f[0] - c[0]), h = l, g = s, x = -s / l; + if (p) { + if (!d) { + if (i && !h) + return { + isBound: !1, + offset: 0 + }; + if (g) { + var S = (c[1] - u[1]) / x + u[0]; + return Ko(S, c[0], f[0], n, a); + } else { + var b = c[1] - u[1], C = Y(b) <= (a || 0); + return { + isBound: C, + offset: C ? b : 0 + }; + } + } + } else { + if (i && !g) + return { + isBound: !1, + offset: 0 + }; + if (h) { + var y = x * (c[0] - u[0]) + u[1]; + return Ko(y, c[1], f[1], n, a); + } else { + var b = c[0] - u[0], C = Y(b) <= (a || 0); + return { + isBound: C, + offset: C ? b : 0 + }; + } + } + return { + isBound: !1, + offset: 0 + }; +} +function Fl(t, e, r) { + return e.map(function(n) { + var a = Od(t, n), i = a.isBound, o = a.offset, s = a.isVerticalBound, l = a.isHorizontalBound, u = n.multiple, c = Oe({ + datas: r, + distX: o[0], + distY: o[1] + }).map(function(f, d) { + return f * (u[d] ? 2 / u[d] : 0); + }); + return { + sign: u, + isBound: i, + isVerticalBound: s, + isHorizontalBound: l, + isSnap: !1, + offset: c + }; + }); +} +function zd(t, e, r) { + var n, a = Hi(t, e, [0, 0], !1).map(function(d) { + return I(I({}, d), { multiple: d.multiple.map(function(p) { + return Y(p) * 2; + }) }); + }), i = Fl(t, a, r), o = Jn(i, 0), s = Jn(i, 1), l = 0, u = 0, c = o.isVerticalBound || s.isVerticalBound, f = o.isHorizontalBound || s.isHorizontalBound; + return (c || f) && (n = O(ad({ + datas: r, + distX: -o.offset[0], + distY: -s.offset[1] + }), 2), l = n[0], u = n[1]), { + vertical: { + isBound: c, + offset: l + }, + horizontal: { + isBound: f, + offset: u + } + }; +} +function Ad(t, e) { + var r = [], n = t[0], a = t[1]; + return n && a ? r.push([[0, a * 2], t, [-n, a]], [[n * 2, 0], t, [n, -a]]) : n ? (r.push([[n * 2, 0], [n, 1], [n, -1]]), e && r.push([[0, -1], [n, -1], [-n, -1]], [[0, 1], [n, 1], [-n, 1]])) : a ? (r.push([[0, a * 2], [1, a], [-1, a]]), e && r.push([[-1, 0], [-1, a], [-1, -a]], [[1, 0], [1, a], [1, -a]])) : r.push([[-1, 0], [-1, -1], [-1, 1]], [[1, 0], [1, -1], [1, 1]], [[0, -1], [-1, -1], [1, -1]], [[0, 1], [-1, 1], [1, 1]]), r; +} +function Hi(t, e, r, n) { + var a = t.state, i = a.allMatrix, o = a.is3d, s = dr(i, 100, 100, o ? 4 : 3), l = Qt(s, [0, 0]); + return Ad(r, n).map(function(u) { + var c = O(u, 3), f = c[0], d = c[1], p = c[2], h = [ + Qt(s, d), + Qt(s, p) + ], g = Td(h), x = jl(l, h), y = x.vertical, b = x.horizontal, C = Xi(l, h) <= 0; + return { + multiple: f, + centerSign: C, + verticalSign: y, + horizontalSign: b, + lineConstants: g, + line: [ + Qt(e, d), + Qt(e, p) + ] + }; + }); +} +function Zo(t, e, r, n) { + var a = n ? t.map(function(i) { + return un(i, n); + }) : t; + return [ + [a[0], a[1]], + [a[1], a[3]], + [a[3], a[2]], + [a[2], a[0]] + ].some(function(i) { + var o = Xi(r, i) <= 0; + return !Gl(e, i, o); + }); +} +function Nd(t) { + var e = O(t, 2), r = e[0], n = e[1], a = n[0] - r[0], i = n[1] - r[1]; + if (!a) + return Y(r[0]); + if (!i) + return Y(r[1]); + var o = i / a; + return Y((-o * r[0] + r[1]) / Math.sqrt(Math.pow(o, 2) + 1)); +} +function Bd(t) { + var e = O(t, 2), r = e[0], n = e[1], a = n[0] - r[0], i = n[1] - r[1]; + if (!a) + return [r[0], 0]; + if (!i) + return [0, r[1]]; + var o = i / a, s = -o * r[0] + r[1]; + return [ + -s / (o + 1 / o), + s / (o * o + 1) + ]; +} +function jd(t, e, r, n, a) { + var i = t.props.innerBounds, o = a * Math.PI / 180; + if (!i) + return []; + var s = i.left, l = i.top, u = i.width, c = i.height, f = s - n[0], d = s + u - n[0], p = l - n[1], h = l + c - n[1], g = [ + [f, p], + [d, p], + [f, h], + [d, h] + ], x = Qt(r, [0, 0]); + if (!Zo(r, g, x, 0)) + return []; + var y = [], b = g.map(function(C) { + return [ + Se(C), + Xt([0, 0], C) + ]; + }); + return [ + [r[0], r[1]], + [r[1], r[3]], + [r[3], r[2]], + [r[2], r[0]] + ].forEach(function(C) { + var S = Xt([0, 0], Bd(C)), w = Nd(C); + y.push.apply(y, Z([], O(b.filter(function(v) { + var _ = O(v, 1), M = _[0]; + return M && w <= M; + }).map(function(v) { + var _ = O(v, 2), M = _[0], T = _[1], k = Math.acos(M ? w / M : 0), A = T + k, z = T - k; + return [ + o + A - S, + o + z - S + ]; + }).reduce(function(v, _) { + return v.push.apply(v, Z([], O(_), !1)), v; + }, []).filter(function(v) { + return !Zo(e, g, x, v); + }).map(function(v) { + return gt(v * 180 / Math.PI, le); + })), !1)); + }), y; +} +function Gd(t) { + var e = t.props.innerBounds, r = Dr(); + if (!e) + return { + boundMap: r, + vertical: [], + horizontal: [] + }; + var n = t.getRect(), a = n.pos1, i = n.pos2, o = n.pos3, s = n.pos4, l = [a, i, o, s], u = Qt(l, [0, 0]), c = e.left, f = e.top, d = e.width, p = e.height, h = [[c, f], [c, f + p]], g = [[c, f], [c + d, f]], x = [[c + d, f], [c + d, f + p]], y = [[c, f + p], [c + d, f + p]], b = Hi(t, l, [0, 0], !1), C = [], S = []; + return b.forEach(function(w) { + var v = w.line, _ = w.lineConstants, M = jl(u, v), T = M.horizontal, k = M.vertical, A = He(v, _, g, k, 1, !0), z = He(v, _, y, k, 1, !0), R = He(v, _, h, T, 1, !0), B = He(v, _, x, T, 1, !0); + A.isBound && !r.top && (C.push(f), r.top = !0), z.isBound && !r.bottom && (C.push(f + p), r.bottom = !0), R.isBound && !r.left && (S.push(c), r.left = !0), B.isBound && !r.right && (S.push(c + d), r.right = !0); + }), { + boundMap: r, + horizontal: C, + vertical: S + }; +} +function Fd(t, e, r, n) { + var a = e[0] - t[0], i = e[1] - t[1]; + if (Y(a) < Ut && (a = 0), Y(i) < Ut && (i = 0), !a) + return n ? [0, 0] : [0, r]; + if (!i) + return n ? [r, 0] : [0, 0]; + var o = i / a, s = t[1] - o * t[0]; + if (n) { + var l = o * (e[0] + r) + s; + return [r, l - e[1]]; + } else { + var u = (e[1] + r - s) / o; + return [u - e[0], r]; + } +} +function li(t, e, r, n, a) { + var i = Fd(t, e, r, n); + if (!i) + return { + isOutside: !1, + offset: [0, 0] + }; + var o = Re(t, e), s = Re(i, t), l = Re(i, e), u = s > o || l > o, c = O(Oe({ + datas: a, + distX: i[0], + distY: i[1] + }), 2), f = c[0], d = c[1]; + return { + offset: [f, d], + isOutside: u + }; +} +function Qn(t, e) { + return t.isBound ? t.offset : e.isSnap ? si(e).offset : 0; +} +function Ld(t, e, r, n, a) { + var i = O(e, 2), o = i[0], s = i[1], l = O(r, 2), u = l[0], c = l[1], f = O(n, 2), d = f[0], p = f[1], h = O(a, 2), g = h[0], x = h[1], y = -g, b = -x; + if (t && o && s) { + y = 0, b = 0; + var C = []; + if (u && c ? C.push([0, x], [g, 0]) : u ? C.push([g, 0]) : c ? C.push([0, x]) : d && p ? C.push([0, x], [g, 0]) : d ? C.push([g, 0]) : p && C.push([0, x]), C.length) { + C.sort(function(_, M) { + return Se(ct([o, s], _)) - Se(ct([o, s], M)); + }); + var S = C[0]; + if (S[0] && Y(o) > Ut) + y = -S[0], b = s * Y(o + y) / Y(o) - s; + else if (S[1] && Y(s) > Ut) { + var w = s; + b = -S[1], y = o * Y(s + b) / Y(w) - o; + } + if (t && c && u) + if (Y(y) > Ut && Y(y) < Y(g)) { + var v = Y(g) / Y(y); + y *= v, b *= v; + } else if (Y(b) > Ut && Y(b) < Y(x)) { + var v = Y(x) / Y(b); + y *= v, b *= v; + } else + y = Or(-g, y), b = Or(-x, b); + } + } else + y = o || u ? -g : 0, b = s || c ? -x : 0; + return [y, b]; +} +function Wd(t, e, r, n, a, i) { + if (!Gr(t, "draggable")) + return [ + { + isSnap: !1, + isBound: !1, + offset: 0 + }, + { + isSnap: !1, + isBound: !1, + offset: 0 + } + ]; + var o = $i(i.absolutePoses, [e, r]), s = ye(o), l = s.left, u = s.right, c = s.top, f = s.bottom, d = { + horizontal: o.map(function(B) { + return B[1]; + }), + vertical: o.map(function(B) { + return B[0]; + }) + }, p = Wi(t.props.snapDirections), h = Yi(p, { + left: l, + right: u, + top: c, + bottom: f, + center: (l + u) / 2, + middle: (c + f) / 2 + }), g = pa(t, a, h, d), x = g.vertical, y = g.horizontal, b = zd(t, o, i), C = b.vertical, S = b.horizontal, w = x.isSnap, v = y.isSnap, _ = x.isBound || C.isBound, M = y.isBound || S.isBound, T = Or(x.offset, C.offset), k = Or(y.offset, S.offset), A = O(Ld(n, [e, r], [_, M], [w, v], [T, k]), 2), z = A[0], R = A[1]; + return [ + { + isBound: _, + isSnap: w, + offset: z + }, + { + isBound: M, + isSnap: v, + offset: R + } + ]; +} +function pa(t, e, r, n) { + n === void 0 && (n = r); + var a = Li(fa(t), n.vertical, n.horizontal), i = a.horizontal, o = a.vertical, s = e ? { + horizontal: { isSnap: !1, index: -1 }, + vertical: { isSnap: !1, index: -1 } + } : da(t, r.vertical, r.horizontal, void 0, void 0, void 0, void 0), l = s.horizontal, u = s.vertical, c = Qn(i[0], l), f = Qn(o[0], u), d = Y(c), p = Y(f); + return { + horizontal: { + isBound: i[0].isBound, + isSnap: l.isSnap, + snapIndex: l.index, + offset: c, + dist: d, + bounds: i, + snap: l + }, + vertical: { + isBound: o[0].isBound, + isSnap: u.isSnap, + snapIndex: u.index, + offset: f, + dist: p, + bounds: o, + snap: u + } + }; +} +function Jo(t, e, r, n, a, i, o) { + o === void 0 && (o = [1, 1]); + var s = Li(e, r, n), l = s.horizontal, u = s.vertical, c = Nl(t, r, n, [], [], a, i, o), f = c.horizontal, d = c.vertical, p = Qn(l[0], f), h = Qn(u[0], d), g = Y(p), x = Y(h); + return { + horizontal: { + isBound: l[0].isBound, + isSnap: f.isSnap, + snapIndex: f.index, + offset: p, + dist: g, + bounds: l, + snap: f + }, + vertical: { + isBound: u[0].isBound, + isSnap: d.isSnap, + snapIndex: d.index, + offset: h, + dist: x, + bounds: u, + snap: d + } + }; +} +function Yd(t, e, r, n) { + var a = Xt(t, e) / Math.PI * 180, i = r.vertical, o = i.isBound, s = i.isSnap, l = i.dist, u = r.horizontal, c = u.isBound, f = u.isSnap, d = u.dist, p = a % 180, h = p < 3 || p > 177, g = p > 87 && p < 93; + return d < l && (o || s && !g && (!n || !h)) ? "vertical" : c || f && !h && (!n || !g) ? "horizontal" : ""; +} +function Xd(t, e, r, n, a, i) { + return r.map(function(o) { + var s = O(o, 2), l = s[0], u = s[1], c = Qt(e, l), f = Qt(e, u), d = n ? Hd(t, c, f, a) : pa(t, a, { + vertical: [f[0]], + horizontal: [f[1]] + }), p = d.horizontal, h = p.offset, g = p.isBound, x = p.isSnap, y = d.vertical, b = y.offset, C = y.isBound, S = y.isSnap, w = ct(u, l); + if (!b && !h) + return { + isBound: C || g, + isSnap: S || x, + sign: w, + offset: [0, 0] + }; + var v = Yd(c, f, d, n); + if (!v) + return { + sign: w, + isBound: !1, + isSnap: !1, + offset: [0, 0] + }; + var _ = v === "vertical", M = [0, 0]; + return !n && Y(u[0]) === 1 && Y(u[1]) === 1 && l[0] !== u[0] && l[1] !== u[1] ? M = Oe({ + datas: i, + distX: -b, + distY: -h + }) : M = li(c, f, -(_ ? b : h), _, i).offset, M = M.map(function(T, k) { + return T * (w[k] ? 2 / w[k] : 0); + }), { + sign: w, + isBound: _ ? C : g, + isSnap: _ ? S : x, + offset: M + }; + }); +} +function Qo(t, e) { + return t.isBound ? t.offset : e.isSnap ? e.offset : 0; +} +function Hd(t, e, r, n) { + var a = Cd(t, e, r), i = a.horizontal, o = a.vertical, s = n ? { + horizontal: { isSnap: !1 }, + vertical: { isSnap: !1 } + } : Id(t, e, r), l = s.horizontal, u = s.vertical, c = Qo(i, l), f = Qo(o, u), d = Y(c), p = Y(f); + return { + horizontal: { + isBound: i.isBound, + isSnap: l.isSnap, + offset: c, + dist: d + }, + vertical: { + isBound: o.isBound, + isSnap: u.isSnap, + offset: f, + dist: p + } + }; +} +function qd(t, e, r, n, a) { + var i = [-r[0], -r[1]], o = t.state, s = o.width, l = o.height, u = t.props.bounds, c = 1 / 0, f = 1 / 0; + if (u) { + var d = [ + [r[0], -r[1]], + [-r[0], r[1]] + ], p = u.left, h = p === void 0 ? -1 / 0 : p, g = u.top, x = g === void 0 ? -1 / 0 : g, y = u.right, b = y === void 0 ? 1 / 0 : y, C = u.bottom, S = C === void 0 ? 1 / 0 : C; + d.forEach(function(w) { + var v = w[0] !== i[0], _ = w[1] !== i[1], M = Qt(e, w), T = Xt(n, M) * 360 / Math.PI; + if (_) { + var k = M.slice(); + (Y(T - 360) < 2 || Y(T - 180) < 2) && (k[1] = n[1]); + var A = li(n, k, (n[1] < M[1] ? S : x) - M[1], !1, a), z = O(A.offset, 2), R = z[1], B = A.isOutside; + isNaN(R) || (f = l + (B ? 1 : -1) * Y(R)); + } + if (v) { + var k = M.slice(); + (Y(T - 90) < 2 || Y(T - 270) < 2) && (k[0] = n[0]); + var N = li(n, k, (n[0] < M[0] ? b : h) - M[0], !0, a), L = O(N.offset, 1), V = L[0], G = N.isOutside; + isNaN(V) || (c = s + (G ? 1 : -1) * Y(V)); + } + }); + } + return { + maxWidth: c, + maxHeight: f + }; +} +var ie = { + name: "draggable", + props: [ + "draggable", + "throttleDrag", + "throttleDragRotate", + "hideThrottleDragRotateLine", + "startDragRotate", + "edgeDraggable" + ], + events: [ + "dragStart", + "drag", + "dragEnd", + "dragGroupStart", + "dragGroup", + "dragGroupEnd" + ], + requestStyle: function() { + return ["left", "top", "right", "bottom"]; + }, + requestChildStyle: function() { + return ["left", "top", "right", "bottom"]; + }, + render: function(t, e) { + var r = t.props, n = r.hideThrottleDragRotateLine, a = r.throttleDragRotate, i = r.zoom, o = t.getState(), s = o.dragInfo, l = o.beforeOrigin; + if (n || !a || !s) + return []; + var u = s.dist; + if (!u[0] && !u[1]) + return []; + var c = Se(u), f = Xt(u, [0, 0]); + return [e.createElement("div", { className: ut("line", "horizontal", "dragline", "dashed"), key: "dragRotateGuideline", style: { + width: "".concat(c, "px"), + transform: "translate(".concat(l[0], "px, ").concat(l[1], "px) rotate(").concat(f, "rad) scaleY(").concat(i, ")") + } })]; + }, + dragStart: function(t, e) { + var r = e.datas, n = e.parentEvent, a = e.parentGesto, i = t.state, o = i.gestos, s = i.style; + if (o.draggable) + return !1; + o.draggable = a || t.targetGesto, r.datas = {}, r.left = parseFloat(s.left || "") || 0, r.top = parseFloat(s.top || "") || 0, r.bottom = parseFloat(s.bottom || "") || 0, r.right = parseFloat(s.right || "") || 0, r.startValue = [0, 0], fr(t, e), ca(t, e, "translate"), fp(t, r), r.prevDist = [0, 0], r.prevBeforeDist = [0, 0], r.isDrag = !1, r.deltaOffset = [0, 0]; + var l = bt(t, e, I({ set: function(c) { + r.startValue = c; + } }, ua(t, e))), u = n || rt(t, "onDragStart", l); + return u !== !1 ? (r.isDrag = !0, t.state.dragInfo = { + startRect: t.getRect(), + dist: [0, 0] + }) : (o.draggable = null, r.isPinch = !1), r.isDrag ? l : !1; + }, + drag: function(t, e) { + if (e) { + sa(t, e, "translate"); + var r = e.datas, n = e.parentEvent, a = e.parentFlag, i = e.isPinch, o = e.deltaOffset, s = e.useSnap, l = e.isRequest, u = e.isGroup, c = e.parentThrottleDrag, f = e.distX, d = e.distY, p = r.isDrag, h = r.prevDist, g = r.prevBeforeDist, x = r.startValue; + if (p) { + o && (f += o[0], d += o[1]); + var y = t.props, b = y.parentMoveable, C = u ? 0 : y.throttleDrag || c || 0, S = n ? 0 : y.throttleDragRotate || 0, w = 0, v = !1, _ = !1, M = !1, T = !1; + if (!n && S > 0 && (f || d)) { + var k = y.startDragRotate || 0, A = gt(k + Xt([0, 0], [f, d]) * 180 / Math.PI, S) - k, z = d * Math.abs(Math.cos((A - 90) / 180 * Math.PI)), R = f * Math.abs(Math.cos(A / 180 * Math.PI)), B = Se([R, z]); + w = A * Math.PI / 180, f = B * Math.cos(w), d = B * Math.sin(w); + } + if (!i && !n && !a) { + var N = O(Wd(t, f, d, S, !s && l || o, r), 2), L = N[0], V = N[1]; + v = L.isSnap, _ = L.isBound, M = V.isSnap, T = V.isBound; + var G = L.offset, W = V.offset; + f += G, d += W; + } + var $ = wt(Sl({ datas: r, distX: f, distY: d }), x), j = wt(nd({ datas: r, distX: f, distY: d }), x); + Fo(j, le), Fo($, le), S || (!v && !_ && (j[0] = gt(j[0], C), $[0] = gt($[0], C)), !M && !T && (j[1] = gt(j[1], C), $[1] = gt($[1], C))); + var J = ct($, x), Q = ct(j, x), H = ct(Q, h), tt = ct(J, g); + r.prevDist = Q, r.prevBeforeDist = J, r.passDelta = H, r.passDist = Q; + var U = r.left + J[0], et = r.top + J[1], lt = r.right - J[0], ft = r.bottom - J[1], xt = la(r, "translate(".concat(j[0], "px, ").concat(j[1], "px)"), "translate(".concat(Q[0], "px, ").concat(Q[1], "px)")); + if (Gi(e, xt), t.state.dragInfo.dist = n ? [0, 0] : Q, !(!n && !b && H.every(function(vt) { + return !vt; + }) && tt.some(function(vt) { + return !vt; + }))) { + var q = t.state, nt = q.width, Et = q.height, pt = bt(t, e, I({ transform: xt, dist: Q, delta: H, translate: j, beforeDist: J, beforeDelta: tt, beforeTranslate: $, left: U, top: et, right: lt, bottom: ft, width: nt, height: Et, isPinch: i }, se({ + transform: xt + }, e))); + return !n && rt(t, "onDrag", pt), pt; + } + } + } + }, + dragAfter: function(t, e) { + var r = e.datas, n = r.deltaOffset; + return n[0] || n[1] ? (r.deltaOffset = [0, 0], this.drag(t, I(I({}, e), { deltaOffset: n }))) : !1; + }, + dragEnd: function(t, e) { + var r = e.parentEvent, n = e.datas; + if (t.state.dragInfo = null, !!n.isDrag) { + n.isDrag = !1; + var a = he(t, e, {}); + return !r && rt(t, "onDragEnd", a), a; + } + }, + dragGroupStart: function(t, e) { + var r, n, a = e.datas, i = e.clientX, o = e.clientY, s = this.dragStart(t, e); + if (!s) + return !1; + var l = ka(t, this, "dragStart", [ + i || 0, + o || 0 + ], e, !1, "draggable"), u = l.childEvents, c = l.eventParams, f = I(I({}, s), { targets: t.props.targets, events: c }), d = rt(t, "onDragGroupStart", f); + a.isDrag = d !== !1; + var p = (n = (r = u[0]) === null || r === void 0 ? void 0 : r.datas.startValue) !== null && n !== void 0 ? n : [0, 0]; + return a.throttleOffset = [p[0] % 1, p[1] % 1], a.isDrag ? s : !1; + }, + dragGroup: function(t, e) { + var r = e.datas; + if (r.isDrag) { + var n = this.drag(t, I(I({}, e), { parentThrottleDrag: t.props.throttleDrag })), a = e.datas.passDelta, i = ka(t, this, "drag", a, e, !1, "draggable").eventParams; + if (n) { + var o = I({ targets: t.props.targets, events: i }, n); + return rt(t, "onDragGroup", o), o; + } + } + }, + dragGroupEnd: function(t, e) { + var r = e.isDrag, n = e.datas; + if (n.isDrag) { + this.dragEnd(t, e); + var a = ka(t, this, "dragEnd", [0, 0], e, !1, "draggable").eventParams; + return rt(t, "onDragGroupEnd", he(t, e, { + targets: t.props.targets, + events: a + })), r; + } + }, + /** + * @method Moveable.Draggable#request + * @param {object} [e] - the draggable's request parameter + * @param {number} [e.x] - x position + * @param {number} [e.y] - y position + * @param {number} [e.deltaX] - X number to move + * @param {number} [e.deltaY] - Y number to move + * @return {Moveable.Requester} Moveable Requester + * @example + + * // Instantly Request (requestStart - request - requestEnd) + * // Use Relative Value + * moveable.request("draggable", { deltaX: 10, deltaY: 10 }, true); + * // Use Absolute Value + * moveable.request("draggable", { x: 200, y: 100 }, true); + * + * // requestStart + * const requester = moveable.request("draggable"); + * + * // request + * // Use Relative Value + * requester.request({ deltaX: 10, deltaY: 10 }); + * requester.request({ deltaX: 10, deltaY: 10 }); + * requester.request({ deltaX: 10, deltaY: 10 }); + * // Use Absolute Value + * moveable.request("draggable", { x: 200, y: 100 }); + * moveable.request("draggable", { x: 220, y: 100 }); + * moveable.request("draggable", { x: 240, y: 100 }); + * + * // requestEnd + * requester.requestEnd(); + */ + request: function(t) { + var e = {}, r = t.getRect(), n = 0, a = 0, i = !1; + return { + isControl: !1, + requestStart: function(o) { + return i = o.useSnap, { datas: e, useSnap: i }; + }, + request: function(o) { + return "x" in o ? n = o.x - r.left : "deltaX" in o && (n += o.deltaX), "y" in o ? a = o.y - r.top : "deltaY" in o && (a += o.deltaY), { datas: e, distX: n, distY: a, useSnap: i }; + }, + requestEnd: function() { + return { datas: e, isDrag: !0, useSnap: i }; + } + }; + }, + unset: function(t) { + t.state.gestos.draggable = null, t.state.dragInfo = null; + } +}; +function Ll(t, e) { + var r = Qt(t, e), n = [0, 0]; + return { + fixedPosition: r, + fixedDirection: e, + fixedOffset: n + }; +} +function Vd(t, e) { + var r = t.allMatrix, n = t.is3d, a = t.width, i = t.height, o = n ? 4 : 3, s = [ + a / 2 * (1 + e[0]), + i / 2 * (1 + e[1]) + ], l = Gt(r, s, o), u = [0, 0]; + return { + fixedPosition: l, + fixedDirection: e, + fixedOffset: u + }; +} +function Wl(t, e) { + var r = t.allMatrix, n = t.is3d, a = t.width, i = t.height, o = n ? 4 : 3, s = fd(e, a, i), l = Gt(r, e, o), u = [ + a ? 0 : e[0], + i ? 0 : e[1] + ]; + return { + fixedPosition: l, + fixedDirection: s, + fixedOffset: u + }; +} +var ts = Zi("resizable"), ui = { + name: "resizable", + ableGroup: "size", + canPinch: !0, + props: [ + "resizable", + "throttleResize", + "renderDirections", + "displayAroundControls", + "keepRatio", + "resizeFormat", + "keepRatioFinally", + "edge", + "checkResizableError" + ], + events: [ + "resizeStart", + "beforeResize", + "resize", + "resizeEnd", + "resizeGroupStart", + "beforeResizeGroup", + "resizeGroup", + "resizeGroupEnd" + ], + render: Tl("resizable"), + dragControlCondition: ts, + viewClassName: Ki("resizable"), + dragControlStart: function(t, e) { + var r, n = e.inputEvent, a = e.isPinch, i = e.isGroup, o = e.parentDirection, s = e.parentGesto, l = e.datas, u = e.parentFixedDirection, c = e.parentEvent, f = eu(o, a, n, l), d = t.state, p = d.target, h = d.width, g = d.height, x = d.gestos; + if (!f || !p || x.resizable) + return !1; + x.resizable = s || t.controlGesto, !a && fr(t, e), l.datas = {}, l.direction = f, l.startOffsetWidth = h, l.startOffsetHeight = g, l.prevWidth = 0, l.prevHeight = 0, l.minSize = [0, 0], l.startWidth = d.inlineCSSWidth || d.cssWidth, l.startHeight = d.inlineCSSHeight || d.cssHeight, l.maxSize = [1 / 0, 1 / 0], i || (l.minSize = [ + d.minOffsetWidth, + d.minOffsetHeight + ], l.maxSize = [ + d.maxOffsetWidth, + d.maxOffsetHeight + ]); + var y = t.props.transformOrigin || "% %"; + l.transformOrigin = be(y) ? y.split(" ") : y, l.startOffsetMatrix = d.offsetMatrix, l.startTransformOrigin = d.transformOrigin, l.isWidth = (r = e == null ? void 0 : e.parentIsWidth) !== null && r !== void 0 ? r : !f[0] && !f[1] || f[0] || !f[1]; + function b(T) { + l.ratio = T && isFinite(T) ? T : 0; + } + l.startPositions = Ce(t.state); + function C(T) { + var k = Ll(l.startPositions, T); + l.fixedDirection = k.fixedDirection, l.fixedPosition = k.fixedPosition, l.fixedOffset = k.fixedOffset; + } + function S(T) { + var k = Wl(t.state, T); + l.fixedDirection = k.fixedDirection, l.fixedPosition = k.fixedPosition, l.fixedOffset = k.fixedOffset; + } + function w(T) { + l.minSize = [ + Rt("".concat(T[0]), 0) || 0, + Rt("".concat(T[1]), 0) || 0 + ]; + } + function v(T) { + var k = [ + T[0] || 1 / 0, + T[1] || 1 / 0 + ]; + (!nn(k[0]) || isFinite(k[0])) && (k[0] = Rt("".concat(k[0]), 0) || 1 / 0), (!nn(k[1]) || isFinite(k[1])) && (k[1] = Rt("".concat(k[1]), 0) || 1 / 0), l.maxSize = k; + } + b(h / g), C(u || [-f[0], -f[1]]), l.setFixedDirection = C, l.setFixedPosition = S, l.setMin = w, l.setMax = v; + var _ = bt(t, e, { + direction: f, + startRatio: l.ratio, + set: function(T) { + var k = O(T, 2), A = k[0], z = k[1]; + l.startWidth = A, l.startHeight = z; + }, + setMin: w, + setMax: v, + setRatio: b, + setFixedDirection: C, + setFixedPosition: S, + setOrigin: function(T) { + l.transformOrigin = T; + }, + dragStart: ie.dragStart(t, new Rr().dragStart([0, 0], e)) + }), M = c || rt(t, "onResizeStart", _); + return l.startFixedDirection = l.fixedDirection, l.startFixedPosition = l.fixedPosition, M !== !1 && (l.isResize = !0, t.state.snapRenderInfo = { + request: e.isRequest, + direction: f + }), l.isResize ? _ : !1; + }, + dragControl: function(t, e) { + var r, n = e.datas, a = e.parentFlag, i = e.isPinch, o = e.parentKeepRatio, s = e.dragClient, l = e.parentDist, u = e.useSnap, c = e.isRequest, f = e.isGroup, d = e.parentEvent, p = e.resolveMatrix, h = n.isResize, g = n.transformOrigin, x = n.startWidth, y = n.startHeight, b = n.prevWidth, C = n.prevHeight, S = n.minSize, w = n.maxSize, v = n.ratio, _ = n.startOffsetWidth, M = n.startOffsetHeight, T = n.isWidth; + if (!h) + return; + if (p) { + var k = t.state.is3d, A = n.startOffsetMatrix, z = n.startTransformOrigin, R = k ? 4 : 3, B = Tr(Kn(e)), N = Math.sqrt(B.length); + R !== N && (B = Te(B, N, R)); + var L = hn(A, B, z, R), V = dr(L, _, M, R); + n.startPositions = V, n.nextTargetMatrix = B, n.nextAllMatrix = L; + } + var G = cr(t.props, "resizable"), W = G.resizeFormat, $ = G.throttleResize, j = $ === void 0 ? a ? 0 : 1 : $, J = G.parentMoveable, Q = G.keepRatioFinally, H = n.direction, tt = H, U = 0, et = 0; + !H[0] && !H[1] && (tt = [1, 1]); + var lt = v && (o ?? G.keepRatio) || !1; + function ft() { + var Ft = n.fixedDirection, Ot = su(tt, lt, n, e); + U = Ot.distWidth, et = Ot.distHeight; + var kt = tt[0] - Ft[0] || lt ? Math.max(_ + U, le) : _, Ee = tt[1] - Ft[1] || lt ? Math.max(M + et, le) : M; + return lt && _ && M && (T ? Ee = kt / v : kt = Ee * v), [kt, Ee]; + } + var xt = O(ft(), 2), q = xt[0], nt = xt[1]; + d || (n.setFixedDirection(n.fixedDirection), rt(t, "onBeforeResize", bt(t, e, { + startFixedDirection: n.startFixedDirection, + startFixedPosition: n.startFixedPosition, + setFixedDirection: function(Ft) { + var Ot; + return n.setFixedDirection(Ft), Ot = O(ft(), 2), q = Ot[0], nt = Ot[1], [q, nt]; + }, + setFixedPosition: function(Ft) { + var Ot; + return n.setFixedPosition(Ft), Ot = O(ft(), 2), q = Ot[0], nt = Ot[1], [q, nt]; + }, + boundingWidth: q, + boundingHeight: nt, + setSize: function(Ft) { + var Ot; + Ot = O(Ft, 2), q = Ot[0], nt = Ot[1]; + } + }, !0))); + var Et = s; + s || (!a && i ? Et = hd(t, [0, 0]) : Et = n.fixedPosition); + var pt = [0, 0]; + i || (pt = up(t, q, nt, H, Et, !u && c, n)), l && (!l[0] && (pt[0] = 0), !l[1] && (pt[1] = 0)); + function vt() { + var Ft; + W && (Ft = O(W([q, nt]), 2), q = Ft[0], nt = Ft[1]), q = gt(q, j), nt = gt(nt, j); + } + if (lt) { + tt[0] && tt[1] && pt[0] && pt[1] && (Y(pt[0]) > Y(pt[1]) ? pt[1] = 0 : pt[0] = 0); + var St = !pt[0] && !pt[1]; + St && vt(), tt[0] && !tt[1] || pt[0] && !pt[1] || St && T ? (q += pt[0], nt = q / v) : (!tt[0] && tt[1] || !pt[0] && pt[1] || St && !T) && (nt += pt[1], q = nt * v); + } else + q += pt[0], nt += pt[1], q = Math.max(0, q), nt = Math.max(0, nt); + r = O(ki([q, nt], S, w, lt ? v : !1), 2), q = r[0], nt = r[1], vt(), lt && (f || Q) && (T ? nt = q / v : q = nt * v), U = q - _, et = nt - M; + var _t = [U - b, et - C]; + n.prevWidth = U, n.prevHeight = et; + var Mt = vd(t, q, nt, Et, g, n); + if (!(!J && _t.every(function(Ft) { + return !Ft; + }) && Mt.every(function(Ft) { + return !Ft; + }))) { + var ht = ie.drag(t, vn(e, t.state, Mt, !!i, !1, "draggable")), Dt = ht.transform, Bt = x + U, Zt = y + et, jt = bt(t, e, I({ width: Bt, height: Zt, offsetWidth: Math.round(q), offsetHeight: Math.round(nt), startRatio: v, boundingWidth: q, boundingHeight: nt, direction: H, dist: [U, et], delta: _t, isPinch: !!i, drag: ht }, nu({ + style: { + width: "".concat(Bt, "px"), + height: "".concat(Zt, "px") + }, + transform: Dt + }, ht, e))); + return !d && rt(t, "onResize", jt), jt; + } + }, + dragControlAfter: function(t, e) { + var r = e.datas, n = r.isResize, a = r.startOffsetWidth, i = r.startOffsetHeight, o = r.prevWidth, s = r.prevHeight; + if (!(!n || t.props.checkResizableError === !1)) { + var l = t.state, u = l.width, c = l.height, f = u - (a + o), d = c - (i + s), p = Y(f) > 3, h = Y(d) > 3; + if (p && (r.startWidth += f, r.startOffsetWidth += f, r.prevWidth += f), h && (r.startHeight += d, r.startOffsetHeight += d, r.prevHeight += d), p || h) + return this.dragControl(t, e); + } + }, + dragControlEnd: function(t, e) { + var r = e.datas, n = e.parentEvent; + if (r.isResize) { + r.isResize = !1; + var a = he(t, e, {}); + return !n && rt(t, "onResizeEnd", a), a; + } + }, + dragGroupControlCondition: ts, + dragGroupControlStart: function(t, e) { + var r = e.datas, n = this.dragControlStart(t, I(I({}, e), { isGroup: !0 })); + if (!n) + return !1; + var a = Me(t, "resizable", e), i = r.startOffsetWidth, o = r.startOffsetHeight; + function s() { + var p = r.minSize; + a.forEach(function(h) { + var g = h.datas, x = g.minSize, y = g.startOffsetWidth, b = g.startOffsetHeight, C = i * (y ? x[0] / y : 0), S = o * (b ? x[1] / b : 0); + p[0] = Math.max(p[0], C), p[1] = Math.max(p[1], S); + }); + } + function l() { + var p = r.maxSize; + a.forEach(function(h) { + var g = h.datas, x = g.maxSize, y = g.startOffsetWidth, b = g.startOffsetHeight, C = i * (y ? x[0] / y : 0), S = o * (b ? x[1] / b : 0); + p[0] = Math.min(p[0], C), p[1] = Math.min(p[1], S); + }); + } + var u = je(t, this, "dragControlStart", e, function(p, h) { + return Zn(t, p, r, h); + }); + s(), l(); + var c = function(p) { + n.setFixedDirection(p), u.forEach(function(h, g) { + h.setFixedDirection(p), Zn(t, h.moveable, r, a[g]); + }); + }; + r.setFixedDirection = c; + var f = I(I({}, n), { targets: t.props.targets, events: u.map(function(p) { + return I(I({}, p), { setMin: function(h) { + p.setMin(h), s(); + }, setMax: function(h) { + p.setMax(h), l(); + } }); + }), setFixedDirection: c, setMin: function(p) { + n.setMin(p), s(); + }, setMax: function(p) { + n.setMax(p), l(); + } }), d = rt(t, "onResizeGroupStart", f); + return r.isResize = d !== !1, r.isResize ? n : !1; + }, + dragGroupControl: function(t, e) { + var r = e.datas; + if (r.isResize) { + var n = cr(t.props, "resizable"); + ha(t, "onBeforeResize", function(p) { + rt(t, "onBeforeResizeGroup", bt(t, e, I(I({}, p), { targets: n.targets }), !0)); + }); + var a = this.dragControl(t, I(I({}, e), { isGroup: !0 })); + if (a) { + var i = a.boundingWidth, o = a.boundingHeight, s = a.dist, l = n.keepRatio, u = [ + i / (i - s[0]), + o / (o - s[1]) + ], c = r.fixedPosition, f = je(t, this, "dragControl", e, function(p, h) { + var g = O(ne(cn(t.rotation / 180 * Math.PI, 3), [ + h.datas.originalX * u[0], + h.datas.originalY * u[1], + 1 + ], 3), 2), x = g[0], y = g[1]; + return I(I({}, h), { parentDist: null, parentScale: u, dragClient: wt(c, [x, y]), parentKeepRatio: l }); + }), d = I({ targets: n.targets, events: f }, a); + return rt(t, "onResizeGroup", d), d; + } + } + }, + dragGroupControlEnd: function(t, e) { + var r = e.isDrag, n = e.datas; + if (n.isResize) { + this.dragControlEnd(t, e); + var a = je(t, this, "dragControlEnd", e), i = he(t, e, { + targets: t.props.targets, + events: a + }); + return rt(t, "onResizeGroupEnd", i), r; + } + }, + /** + * @method Moveable.Resizable#request + * @param {Moveable.Resizable.ResizableRequestParam} e - the Resizable's request parameter + * @return {Moveable.Requester} Moveable Requester + * @example + + * // Instantly Request (requestStart - request - requestEnd) + * // Use Relative Value + * moveable.request("resizable", { deltaWidth: 10, deltaHeight: 10 }, true); + * + * // Use Absolute Value + * moveable.request("resizable", { offsetWidth: 100, offsetHeight: 100 }, true); + * + * // requestStart + * const requester = moveable.request("resizable"); + * + * // request + * // Use Relative Value + * requester.request({ deltaWidth: 10, deltaHeight: 10 }); + * requester.request({ deltaWidth: 10, deltaHeight: 10 }); + * requester.request({ deltaWidth: 10, deltaHeight: 10 }); + * + * // Use Absolute Value + * moveable.request("resizable", { offsetWidth: 100, offsetHeight: 100 }); + * moveable.request("resizable", { offsetWidth: 110, offsetHeight: 100 }); + * moveable.request("resizable", { offsetWidth: 120, offsetHeight: 100 }); + * + * // requestEnd + * requester.requestEnd(); + */ + request: function(t) { + var e = {}, r = 0, n = 0, a = !1, i = t.getRect(); + return { + isControl: !0, + requestStart: function(o) { + var s; + return a = o.useSnap, { + datas: e, + parentDirection: o.direction || [1, 1], + parentIsWidth: (s = o == null ? void 0 : o.horizontal) !== null && s !== void 0 ? s : !0, + useSnap: a + }; + }, + request: function(o) { + return "offsetWidth" in o ? r = o.offsetWidth - i.offsetWidth : "deltaWidth" in o && (r += o.deltaWidth), "offsetHeight" in o ? n = o.offsetHeight - i.offsetHeight : "deltaHeight" in o && (n += o.deltaHeight), { + datas: e, + parentDist: [r, n], + parentKeepRatio: o.keepRatio, + useSnap: a + }; + }, + requestEnd: function() { + return { datas: e, isDrag: !0, useSnap: a }; + } + }; + }, + unset: function(t) { + t.state.gestos.resizable = null; + } +}; +function Ta(t, e, r, n, a) { + var i = t.props.groupable, o = t.state, s = o.is3d ? 4 : 3, l = e.origin, u = Gt( + t.state.rootMatrix, + // TO-DO #710 + ct([l[0], l[1]], i ? [0, 0] : [o.left, o.top]), + s + ), c = wt([a.left, a.top], u); + e.startAbsoluteOrigin = c, e.prevDeg = Xt(c, [r, n]) / Math.PI * 180, e.defaultDeg = e.prevDeg, e.prevSnapDeg = 0, e.loop = 0, e.startDist = Re(c, [r, n]); +} +function Yn(t, e, r) { + var n = r.defaultDeg, a = r.prevDeg, i = a % 360, o = Math.floor(a / 360); + i < 0 && (i += 360), i > t && i > 270 && t < 90 ? ++o : i < t && i < 90 && t > 270 && --o; + var s = e * (o * 360 + t - n); + return r.prevDeg = n + s, s; +} +function Ia(t, e, r, n) { + return Yn(Xt(n.startAbsoluteOrigin, [t, e]) / Math.PI * 180, r, n); +} +function Ra(t, e, r, n, a, i) { + var o = t.props.throttleRotate, s = o === void 0 ? 0 : o, l = r.prevSnapDeg, u = 0, c = !1; + if (i) { + var f = lp(t, e, n, a + n); + c = f.isSnap, u = a + f.dist; + } + c || (u = gt(a + n, s)); + var d = u - a; + return r.prevSnapDeg = d, [d - l, d, u]; +} +function Yl(t, e, r) { + var n = O(e, 4), a = n[0], i = n[1], o = n[2], s = n[3]; + if (t === "none") + return []; + if (Yt(t)) + return t.map(function(x) { + return Yl(x, [a, i, o, s], r)[0]; + }); + var l = O((t || "top").split("-"), 2), u = l[0], c = l[1], f = [a, i]; + u === "left" ? f = [o, a] : u === "right" ? f = [i, s] : u === "bottom" && (f = [s, o]); + var d = [ + (f[0][0] + f[1][0]) / 2, + (f[0][1] + f[1][1]) / 2 + ], p = Ql(f, r); + if (c) { + var h = c === "top" || c === "left", g = u === "bottom" || u === "left"; + d = f[h && !g || !h && g ? 0 : 1]; + } + return [[d, p]]; +} +function ci(t, e) { + if (e.isRequest) + return e.requestAble === "rotatable"; + var r = e.inputEvent.target; + if (Kt(r, ut("rotation-control")) || t.props.rotateAroundControls && Kt(r, ut("around-control")) || Kt(r, ut("control")) && Kt(r, ut("rotatable"))) + return !0; + var n = t.props.rotationTarget; + return n ? Ji(n, !0).some(function(a) { + return a ? r === a || r.contains(a) : !1; + }) : !1; +} +var $d = `.rotation { +position: absolute; +height: 40px; +width: 1px; +transform-origin: 50% 100%; +height: calc(40px * var(--zoom)); +top: auto; +left: 0; +bottom: 100%; +will-change: transform; +} +.rotation .rotation-line { +display: block; +width: 100%; +height: 100%; +transform-origin: 50% 50%; +} +.rotation .rotation-control { +border-color: #4af; +border-color: var(--moveable-color); +background:#fff; +cursor: alias; +} +:global .view-rotation-dragging, .rotatable.direction.control { +cursor: alias; +} +.rotatable.direction.control.move { +cursor: move; +} +`, Ud = { + name: "rotatable", + canPinch: !0, + props: [ + "rotatable", + "rotationPosition", + "throttleRotate", + "renderDirections", + "rotationTarget", + "rotateAroundControls", + "edge", + "resolveAblesWithRotatable", + "displayAroundControls" + ], + events: [ + "rotateStart", + "beforeRotate", + "rotate", + "rotateEnd", + "rotateGroupStart", + "beforeRotateGroup", + "rotateGroup", + "rotateGroupEnd" + ], + css: [$d], + viewClassName: function(t) { + return t.isDragging("rotatable") ? ut("view-rotation-dragging") : ""; + }, + render: function(t, e) { + var r = cr(t.props, "rotatable"), n = r.rotatable, a = r.rotationPosition, i = r.zoom, o = r.renderDirections, s = r.rotateAroundControls, l = r.resolveAblesWithRotatable, u = t.getState(), c = u.renderPoses, f = u.direction; + if (!n) + return null; + var d = Yl(a, c, f), p = []; + if (d.forEach(function(y, b) { + var C = O(y, 2), S = C[0], w = C[1]; + p.push(e.createElement( + "div", + { key: "rotation".concat(b), className: ut("rotation"), style: { + // tslint:disable-next-line: max-line-length + transform: "translate(-50%) translate(".concat(S[0], "px, ").concat(S[1], "px) rotate(").concat(w, "rad)") + } }, + e.createElement("div", { className: ut("line rotation-line"), style: { + transform: "scaleX(".concat(i, ")") + } }), + e.createElement("div", { className: ut("control rotation-control"), style: { + transform: "translate(0.5px) scale(".concat(i, ")") + } }) + )); + }), o) { + var h = Nr(l || {}), g = {}; + h.forEach(function(y) { + l[y].forEach(function(b) { + g[b] = y; + }); + }); + var x = []; + Yt(o) && (x = o.map(function(y) { + var b = g[y]; + return { + data: b ? { resolve: b } : {}, + classNames: b ? ["move"] : [], + dir: y + }; + })), p.push.apply(p, Z([], O(_l(t, "rotatable", x, e)), !1)); + } + return s && p.push.apply(p, Z([], O(Rl(t, e)), !1)), p; + }, + dragControlCondition: ci, + dragControlStart: function(t, e) { + var r, n, a = e.datas, i = e.clientX, o = e.clientY, s = e.parentRotate, l = e.parentFlag, u = e.isPinch, c = e.isRequest, f = t.state, d = f.target, p = f.left, h = f.top, g = f.direction, x = f.beforeDirection, y = f.targetTransform, b = f.moveableClientRect, C = f.offsetMatrix, S = f.targetMatrix, w = f.allMatrix, v = f.width, _ = f.height; + if (!c && !d) + return !1; + var M = t.getRect(); + a.rect = M, a.transform = y, a.left = p, a.top = h; + var T = function(tt) { + var U = Wl(t.state, tt); + a.fixedDirection = U.fixedDirection, a.fixedOffset = U.fixedOffset, a.fixedPosition = U.fixedPosition, j && j.setFixedPosition(tt); + }, k = function(tt) { + var U = Vd(t.state, tt); + a.fixedDirection = U.fixedDirection, a.fixedOffset = U.fixedOffset, a.fixedPosition = U.fixedPosition, j && j.setFixedDirection(tt); + }, A = i, z = o; + if (c || u || l) { + var R = s || 0; + a.beforeInfo = { + origin: M.beforeOrigin, + prevDeg: R, + defaultDeg: R, + prevSnapDeg: 0, + startDist: 0 + }, a.afterInfo = I(I({}, a.beforeInfo), { origin: M.origin }), a.absoluteInfo = I(I({}, a.beforeInfo), { origin: M.origin, startValue: R }); + } else { + var B = (n = e.inputEvent) === null || n === void 0 ? void 0 : n.target; + if (B) { + var N = B.getAttribute("data-direction") || "", L = td[N]; + if (L) { + a.isControl = !0, a.isAroundControl = Kt(B, ut("around-control")), a.controlDirection = L; + var V = B.getAttribute("data-resolve"); + V && (a.resolveAble = V); + var G = Dp(f.rootMatrix, f.renderPoses, b); + r = O(Qt(G, L), 2), A = r[0], z = r[1]; + } + } + a.beforeInfo = { origin: M.beforeOrigin }, a.afterInfo = { origin: M.origin }, a.absoluteInfo = { + origin: M.origin, + startValue: M.rotation + }; + var W = T; + T = function(tt) { + var U = f.is3d ? 4 : 3, et = O(wt(al(S, U), tt), 2), lt = et[0], ft = et[1], xt = ne(C, sr([lt, ft], U)), q = ne(w, sr([tt[0], tt[1]], U)); + W(tt); + var nt = f.posDelta; + a.beforeInfo.origin = ct(xt, nt), a.afterInfo.origin = ct(q, nt), a.absoluteInfo.origin = ct(q, nt), Ta(t, a.beforeInfo, A, z, b), Ta(t, a.afterInfo, A, z, b), Ta(t, a.absoluteInfo, A, z, b); + }, k = function(tt) { + var U = Qt([ + [0, 0], + [v, 0], + [0, _], + [v, _] + ], tt); + T(U); + }; + } + a.startClientX = A, a.startClientY = z, a.direction = g, a.beforeDirection = x, a.startValue = 0, a.datas = {}, ca(t, e, "rotate"); + var $ = !1, j = !1; + if (a.isControl && a.resolveAble) { + var J = a.resolveAble; + J === "resizable" && (j = ui.dragControlStart(t, I(I({}, new Rr("resizable").dragStart([0, 0], e)), { parentPosition: a.controlPosition, parentFixedPosition: a.fixedPosition }))); + } + j || ($ = ie.dragStart(t, new Rr().dragStart([0, 0], e))), T(wp(t)); + var Q = bt(t, e, I(I({ set: function(tt) { + a.startValue = tt * Math.PI / 180; + }, setFixedDirection: k, setFixedPosition: T }, ua(t, e)), { dragStart: $, resizeStart: j })), H = rt(t, "onRotateStart", Q); + return a.isRotate = H !== !1, f.snapRenderInfo = { + request: e.isRequest + }, a.isRotate ? Q : !1; + }, + dragControl: function(t, e) { + var r, n, a, i = e.datas, o = e.clientDistX, s = e.clientDistY, l = e.parentRotate, u = e.parentFlag, c = e.isPinch, f = e.groupDelta, d = e.resolveMatrix, p = i.beforeDirection, h = i.beforeInfo, g = i.afterInfo, x = i.absoluteInfo, y = i.isRotate, b = i.startValue, C = i.rect, S = i.startClientX, w = i.startClientY; + if (y) { + sa(t, e, "rotate"); + var v = rd(e), _ = p * v, M = t.props.parentMoveable, T = 0, k, A, z = 0, R, B, N = 0, L, V, G = 180 / Math.PI * b, W = x.startValue, $ = !1, j = S + o, J = w + s; + if (!u && "parentDist" in e) { + var Q = e.parentDist; + k = Q, R = Q, L = Q; + } else c || u ? (k = Yn(l, p, h), R = Yn(l, _, g), L = Yn(l, _, x)) : (k = Ia(j, J, p, h), R = Ia(j, J, _, g), L = Ia(j, J, _, x), $ = !0); + if (A = G + k, B = G + R, V = W + L, rt(t, "onBeforeRotate", bt(t, e, { + beforeRotation: A, + rotation: B, + absoluteRotation: V, + setRotation: function(Et) { + R = Et - G, k = R, L = R; + } + }, !0)), r = O(Ra(t, C, h, k, G, $), 3), T = r[0], k = r[1], A = r[2], n = O(Ra(t, C, g, R, G, $), 3), z = n[0], R = n[1], B = n[2], a = O(Ra(t, C, x, L, W, $), 3), N = a[0], L = a[1], V = a[2], !(!N && !z && !T && !M && !d)) { + var H = la(i, "rotate(".concat(B, "deg)"), "rotate(".concat(R, "deg)")); + d && (i.fixedPosition = Fi(t, i.targetAllTransform, i.fixedDirection, i.fixedOffset, i)); + var tt = pd(t, R, i), U = ct(wt(f || [0, 0], tt), i.prevInverseDist || [0, 0]); + i.prevInverseDist = tt, i.requestValue = null; + var et = El(t, H, U, c, e), lt = et, ft = Re([j, J], x.startAbsoluteOrigin) - x.startDist, xt = void 0; + if (i.resolveAble === "resizable") { + var q = ui.dragControl(t, I(I({}, vn(e, t.state, [e.deltaX, e.deltaY], !!c, !1, "resizable")), { resolveMatrix: !0, parentDistance: ft })); + q && (xt = q, lt = nu(lt, q, e)); + } + var nt = bt(t, e, I(I({ delta: z, dist: R, rotate: B, rotation: B, beforeDist: k, beforeDelta: T, beforeRotate: A, beforeRotation: A, absoluteDist: L, absoluteDelta: N, absoluteRotate: V, absoluteRotation: V, isPinch: !!c, resize: xt }, et), lt)); + return rt(t, "onRotate", nt), nt; + } + } + }, + dragControlEnd: function(t, e) { + var r = e.datas; + if (r.isRotate) { + r.isRotate = !1; + var n = he(t, e, {}); + return rt(t, "onRotateEnd", n), n; + } + }, + dragGroupControlCondition: ci, + dragGroupControlStart: function(t, e) { + var r = e.datas, n = t.state, a = n.left, i = n.top, o = n.beforeOrigin, s = this.dragControlStart(t, e); + if (!s) + return !1; + s.set(r.beforeDirection * t.rotation); + var l = je(t, this, "dragControlStart", e, function(f, d) { + var p = f.state, h = p.left, g = p.top, x = p.beforeOrigin, y = wt(ct([h, g], [a, i]), ct(x, o)); + return d.datas.startGroupClient = y, d.datas.groupClient = y, I(I({}, d), { parentRotate: 0 }); + }), u = I(I({}, s), { targets: t.props.targets, events: l }), c = rt(t, "onRotateGroupStart", u); + return r.isRotate = c !== !1, r.isRotate ? s : !1; + }, + dragGroupControl: function(t, e) { + var r = e.datas; + if (r.isRotate) { + ha(t, "onBeforeRotate", function(u) { + rt(t, "onBeforeRotateGroup", bt(t, e, I(I({}, u), { targets: t.props.targets }), !0)); + }); + var n = this.dragControl(t, e); + if (n) { + var a = r.beforeDirection, i = n.beforeDist, o = i / 180 * Math.PI, s = je(t, this, "dragControl", e, function(u, c) { + var f = c.datas.startGroupClient, d = O(c.datas.groupClient, 2), p = d[0], h = d[1], g = O(un(f, o * a), 2), x = g[0], y = g[1], b = [x - p, y - h]; + return c.datas.groupClient = [x, y], I(I({}, c), { parentRotate: i, groupDelta: b }); + }); + t.rotation = a * n.beforeRotation; + var l = I({ targets: t.props.targets, events: s, set: function(u) { + t.rotation = u; + }, setGroupRotation: function(u) { + t.rotation = u; + } }, n); + return rt(t, "onRotateGroup", l), l; + } + } + }, + dragGroupControlEnd: function(t, e) { + var r = e.isDrag, n = e.datas; + if (n.isRotate) { + this.dragControlEnd(t, e); + var a = je(t, this, "dragControlEnd", e), i = he(t, e, { + targets: t.props.targets, + events: a + }); + return rt(t, "onRotateGroupEnd", i), r; + } + }, + /** + * @method Moveable.Rotatable#request + * @param {object} [e] - the Resizable's request parameter + * @param {number} [e.deltaRotate=0] - delta number of rotation + * @param {number} [e.rotate=0] - absolute number of moveable's rotation + * @return {Moveable.Requester} Moveable Requester + * @example + + * // Instantly Request (requestStart - request - requestEnd) + * moveable.request("rotatable", { deltaRotate: 10 }, true); + * + * * moveable.request("rotatable", { rotate: 10 }, true); + * + * // requestStart + * const requester = moveable.request("rotatable"); + * + * // request + * requester.request({ deltaRotate: 10 }); + * requester.request({ deltaRotate: 10 }); + * requester.request({ deltaRotate: 10 }); + * + * requester.request({ rotate: 10 }); + * requester.request({ rotate: 20 }); + * requester.request({ rotate: 30 }); + * + * // requestEnd + * requester.requestEnd(); + */ + request: function(t) { + var e = {}, r = 0, n = t.getRotation(); + return { + isControl: !0, + requestStart: function() { + return { datas: e }; + }, + request: function(a) { + return "deltaRotate" in a ? r += a.deltaRotate : "rotate" in a && (r = a.rotate - n), { datas: e, parentDist: r }; + }, + requestEnd: function() { + return { datas: e, isDrag: !0 }; + } + }; + } +}; +function Kd(t, e) { + var r, n = t.direction, a = t.classNames, i = t.size, o = t.pos, s = t.zoom, l = t.key, u = n === "horizontal", c = u ? "Y" : "X"; + return e.createElement("div", { + key: l, + className: a.join(" "), + style: (r = {}, r[u ? "width" : "height"] = "".concat(i), r.transform = "translate(".concat(o[0], ", ").concat(o[1], ") translate").concat(c, "(-50%) scale").concat(c, "(").concat(s, ")"), r) + }); +} +function qi(t, e) { + return Kd(I(I({}, t), { classNames: Z([ + ut("line", "guideline", t.direction) + ], O(t.classNames), !1).filter(function(r) { + return r; + }), size: t.size || "".concat(t.sizeValue, "px"), pos: t.pos || t.posValue.map(function(r) { + return "".concat(gt(r, 0.1), "px"); + }) }), e); +} +function es(t, e, r, n, a, i, o, s) { + var l = t.props.zoom; + return r.map(function(u, c) { + var f = u.type, d = u.pos, p = [0, 0]; + return p[o] = n, p[o ? 0 : 1] = -a + d, qi({ + key: "".concat(e, "TargetGuideline").concat(c), + classNames: [ut("target", "bold", f)], + posValue: p, + sizeValue: i, + zoom: l, + direction: e + }, s); + }); +} +function rs(t, e, r, n, a, i) { + var o = t.props, s = o.zoom, l = o.isDisplayInnerSnapDigit, u = e === "horizontal" ? $e : Ue, c = a[u.start], f = a[u.end]; + return r.filter(function(d) { + var p = d.hide, h = d.elementRect; + if (p) + return !1; + if (l && h) { + var g = h.rect; + if (g[u.start] <= c && f <= g[u.end]) + return !1; + } + return !0; + }).map(function(d, p) { + var h = d.pos, g = d.size, x = d.element, y = d.className, b = [ + -n[0] + h[0], + -n[1] + h[1] + ]; + return qi({ + key: "".concat(e, "-default-guideline-").concat(p), + classNames: x ? [ut("bold"), y] : [ut("normal"), y], + direction: e, + posValue: b, + sizeValue: g, + zoom: s + }, i); + }); +} +function Vr(t, e, r, n, a, i, o, s) { + var l, u = t.props, c = u.snapDigit, f = c === void 0 ? 0 : c, d = u.isDisplaySnapDigit, p = d === void 0 ? !0 : d, h = u.snapDistFormat, g = h === void 0 ? function(w, v) { + return w; + } : h, x = u.zoom, y = e === "horizontal" ? "X" : "Y", b = e === "vertical" ? "height" : "width", C = Math.abs(a), S = p ? parseFloat(C.toFixed(f)) : 0; + return s.createElement( + "div", + { key: "".concat(e, "-").concat(r, "-guideline-").concat(n), className: ut("guideline-group", e), style: (l = { + left: "".concat(i[0], "px"), + top: "".concat(i[1], "px") + }, l[b] = "".concat(C, "px"), l) }, + qi({ + direction: e, + classNames: [ut(r), o], + size: "100%", + posValue: [0, 0], + sizeValue: C, + zoom: x + }, s), + s.createElement("div", { className: ut("size-value", "gap"), style: { + transform: "translate".concat(y, "(-50%) scale(").concat(x, ")") + } }, S > 0 ? g(S, e) : "") + ); +} +function Zd(t, e, r, n) { + var a = t === "vertical" ? 0 : 1, i = t === "vertical" ? 1 : 0, o = a ? $e : Ue, s = r[o.start], l = r[o.end]; + return au(e, function(u) { + return u.pos[a]; + }).map(function(u) { + var c = [], f = [], d = []; + return u.forEach(function(p) { + var h, g, x = p.element, y = p.elementRect.rect; + if (y[o.end] < s) + c.push(p); + else if (l < y[o.start]) + f.push(p); + else if (y[o.start] <= s && l <= y[o.end] && n) { + var b = p.pos, C = { element: x, rect: I(I({}, y), (h = {}, h[o.end] = y[o.start], h)) }, S = { element: x, rect: I(I({}, y), (g = {}, g[o.start] = y[o.end], g)) }, w = [0, 0], v = [0, 0]; + w[a] = b[a], w[i] = b[i], v[a] = b[a], v[i] = b[i] + p.size, c.push({ + type: t, + pos: w, + size: 0, + elementRect: C, + direction: "", + elementDirection: "end" + }), f.push({ + type: t, + pos: v, + size: 0, + elementRect: S, + direction: "", + elementDirection: "start" + }); + } + }), c.sort(function(p, h) { + return h.pos[i] - p.pos[i]; + }), f.sort(function(p, h) { + return p.pos[i] - h.pos[i]; + }), { + total: u, + start: c, + end: f, + inner: d + }; + }); +} +function Jd(t, e, r, n, a) { + var i = t.props.isDisplayInnerSnapDigit, o = []; + return ["vertical", "horizontal"].forEach(function(s) { + var l = e.filter(function(x) { + return x.type === s; + }), u = s === "vertical" ? 1 : 0, c = u ? 0 : 1, f = Zd(s, l, n, i), d = u ? Ue : $e, p = u ? $e : Ue, h = n[d.start], g = n[d.end]; + f.forEach(function(x) { + var y = x.total, b = x.start, C = x.end, S = x.inner, w = r[c] + y[0].pos[c] - n[p.start], v = n; + b.forEach(function(_) { + var M = _.elementRect.rect, T = v[d.start] - M[d.end]; + if (T > 0) { + var k = [0, 0]; + k[u] = r[u] + v[d.start] - h - T, k[c] = w, o.push(Vr(t, s, "dashed", o.length, T, k, _.className, a)); + } + v = M; + }), v = n, C.forEach(function(_) { + var M = _.elementRect.rect, T = M[d.start] - v[d.end]; + if (T > 0) { + var k = [0, 0]; + k[u] = r[u] + v[d.end] - h, k[c] = w, o.push(Vr(t, s, "dashed", o.length, T, k, _.className, a)); + } + v = M; + }), S.forEach(function(_) { + var M = _.elementRect.rect, T = h - M[d.start], k = M[d.end] - g, A = [0, 0], z = [0, 0]; + A[u] = r[u] - T, A[c] = w, z[u] = r[u] + g - h, z[c] = w, o.push(Vr(t, s, "dashed", o.length, T, A, _.className, a)), o.push(Vr(t, s, "dashed", o.length, k, z, _.className, a)); + }); + }); + }), o; +} +function Qd(t, e, r, n, a) { + var i = []; + return ["horizontal", "vertical"].forEach(function(o) { + var s = e.filter(function(x) { + return x.type === o; + }).slice(0, 1), l = o === "vertical" ? 0 : 1, u = l ? 0 : 1, c = l ? Ue : $e, f = l ? $e : Ue, d = n[c.start], p = n[c.end], h = n[f.start], g = n[f.end]; + s.forEach(function(x) { + var y = x.gap, b = x.gapRects, C = Math.max.apply(Math, Z([h], O(b.map(function(v) { + var _ = v.rect; + return _[f.start]; + })), !1)), S = Math.min.apply(Math, Z([g], O(b.map(function(v) { + var _ = v.rect; + return _[f.end]; + })), !1)), w = (C + S) / 2; + C === S || w === (h + g) / 2 || b.forEach(function(v) { + var _ = v.rect, M = v.className, T = [r[0], r[1]]; + if (_[c.end] < d) + T[l] += _[c.end] - d; + else if (p < _[c.start]) + T[l] += _[c.start] - d - y; + else + return; + T[u] += w - h, i.push(Vr(t, l ? "vertical" : "horizontal", "gap", i.length, y, T, M, a)); + }); + }); + }), i; +} +function fi(t) { + var e, r, n = t.state, a = n.containerClientRect, i = n.hasFixed, o = a.overflow, s = a.scrollHeight, l = a.scrollWidth, u = a.clientHeight, c = a.clientWidth, f = a.clientLeft, d = a.clientTop, p = t.props, h = p.snapGap, g = h === void 0 ? !0 : h, x = p.verticalGuidelines, y = p.horizontalGuidelines, b = p.snapThreshold, C = b === void 0 ? 5 : b, S = p.maxSnapElementGuidelineDistance, w = S === void 0 ? 1 / 0 : S, v = p.isDisplayGridGuidelines, _ = ye(Ce(t.state)), M = _.top, T = _.left, k = _.bottom, A = _.right, z = { top: M, left: T, bottom: k, right: A, center: (T + A) / 2, middle: (M + k) / 2 }, R = np(t), B = Z([], O(R), !1), N = ((r = (e = n.snapThresholdInfo) === null || e === void 0 ? void 0 : e.multiples) !== null && r !== void 0 ? r : [1, 1]).map(function(W) { + return W * C; + }); + g && B.push.apply(B, Z([], O(tp(t, z, N)), !1)); + var L = I({}, n.snapOffset || { + left: 0, + top: 0, + bottom: 0, + right: 0 + }); + if (B.push.apply(B, Z([], O(rp(t, o ? l : c, o ? s : u, f, d, L, v)), !1)), i) { + var V = a.left, G = a.top; + L.left += V, L.top += G, L.right += V, L.bottom += G; + } + return B.push.apply(B, Z([], O(Hl(y || !1, x || !1, o ? l : c, o ? s : u, f, d, L)), !1)), B = B.filter(function(W) { + var $ = W.element, j = W.elementRect, J = W.type; + if (!$ || !j) + return !0; + var Q = j.rect; + return Xl(z, Q, J, w); + }), B; +} +function tp(t, e, r) { + var n = t.props, a = n.maxSnapElementGuidelineDistance, i = a === void 0 ? 1 / 0 : a, o = n.maxSnapElementGapDistance, s = o === void 0 ? 1 / 0 : o, l = t.state.elementRects, u = []; + return [ + ["vertical", $e, Ue], + ["horizontal", Ue, $e] + ].forEach(function(c) { + var f = O(c, 3), d = f[0], p = f[1], h = f[2], g = e[p.start], x = e[p.end], y = e[p.center], b = e[h.start], C = e[h.end], S = { + left: r[0], + top: r[1] + }; + function w(M) { + var T = M.rect, k = S[p.start]; + return T[p.end] < g + k ? g - T[p.end] : x - k < T[p.start] ? T[p.start] - x : -1; + } + var v = l.filter(function(M) { + var T = M.rect; + return T[h.start] > C || T[h.end] < b ? !1 : w(M) > 0; + }).sort(function(M, T) { + return w(M) - w(T); + }), _ = []; + v.forEach(function(M) { + v.forEach(function(T) { + if (M !== T) { + var k = M.rect, A = T.rect, z = k[h.start], R = k[h.end], B = A[h.start], N = A[h.end]; + z > N || B > R || _.push([M, T]); + } + }); + }), _.forEach(function(M) { + var T = O(M, 2), k = T[0], A = T[1], z = k.rect, R = A.rect, B = z[p.start], N = z[p.end], L = R[p.start], V = R[p.end], G = S[p.start], W = 0, $ = 0, j = !1, J = !1, Q = !1; + if (N <= g && x <= L) { + if (J = !0, W = (L - N - (x - g)) / 2, $ = N + W + (x - g) / 2, Y($ - y) > G) + return; + } else if (N < L && V < g + G) { + if (j = !0, W = L - N, $ = V + W, Y($ - g) > G) + return; + } else if (N < L && x - G < B) { + if (Q = !0, W = L - N, $ = B - W, Y($ - x) > G) + return; + } else + return; + W && Xl(e, R, d, i) && (W > s || u.push({ + type: d, + pos: d === "vertical" ? [$, 0] : [0, $], + element: A.element, + size: 0, + className: A.className, + isStart: j, + isCenter: J, + isEnd: Q, + gap: W, + hide: !0, + gapRects: [k, A], + direction: "", + elementDirection: "" + })); + }); + }), u; +} +function ep(t, e, r, n) { + var a, i, o = t.props, s = t.state, l = o.snapGridAll, u = o.snapGridWidth, c = u === void 0 ? 0 : u, f = o.snapGridHeight, d = f === void 0 ? 0 : f, p = s.snapRenderInfo, h = p && (((a = p.direction) === null || a === void 0 ? void 0 : a[0]) || ((i = p.direction) === null || i === void 0 ? void 0 : i[1])), g = t.moveables; + if (l && g && h && (c || d)) { + if (s.snapThresholdInfo) + return; + s.snapThresholdInfo = { + multiples: [1, 1], + offset: [0, 0] + }; + var x = t.getRect(), y = x.children, b = p.direction; + if (y) { + var C = b.map(function(w, v) { + var _ = v === 0 ? { + snapSize: c, + posName: "left", + sizeName: "width", + clientOffset: n.left - e + } : { + snapSize: d, + posName: "top", + sizeName: "height", + clientOffset: n.top - r + }, M = _.snapSize, T = _.posName, k = _.sizeName, A = _.clientOffset; + if (!M) + return { + dir: w, + multiple: 1, + snapSize: M, + snapOffset: 0 + }; + var z = x[k], R = x[T], B = Qc(y.map(function(j) { + return [ + j[T] - R, + j[k], + z - j[k] - j[T] + R + ]; + })).filter(function(j) { + return j; + }).sort(function(j, J) { + return j - J; + }), N = B[0], L = B.map(function(j) { + return gt(j / N, 0.1) * M; + }), V = 1, G = gt(z / N, 0.1); + for (V = 1; V <= 10 && !L.every(function(j) { + return j * V % 1 === 0; + }); ++V) + ; + var W = (-w + 1) / 2, $ = Hn(R - A, R - A + z, W, 1 - W); + return { + multiple: G * V, + dir: w, + snapSize: M, + snapOffset: Math.round($ / M) + }; + }), S = C.map(function(w) { + return w.multiple || 1; + }); + s.snapThresholdInfo.multiples = S, s.snapThresholdInfo.offset = C.map(function(w) { + return w.snapOffset; + }), C.forEach(function(w, v) { + w.snapSize; + }); + } + } else + s.snapThresholdInfo = null; +} +function rp(t, e, r, n, a, i, o) { + n === void 0 && (n = 0), a === void 0 && (a = 0); + var s = t.props, l = t.state, u = s.snapGridWidth, c = u === void 0 ? 0 : u, f = s.snapGridHeight, d = f === void 0 ? 0 : f, p = [], h = i.left, g = i.top, x = [0, 0]; + ep(t, n, a, i); + var y = l.snapThresholdInfo, b = c, C = d; + if (y && (c *= y.multiples[0] || 1, d *= y.multiples[1] || 1, x = y.offset), d) { + for (var S = function(v) { + p.push({ + type: "horizontal", + pos: [ + h, + gt(x[1] * C + v - a + g, 0.1) + ], + className: ut("grid-guideline"), + size: e, + hide: !o, + direction: "", + grid: !0 + }); + }, w = 0; w <= r * 2; w += d) + S(w); + for (var w = -d; w >= -r; w -= d) + S(w); + } + if (c) { + for (var S = function(_) { + p.push({ + type: "vertical", + pos: [ + gt(x[0] * b + _ - n + h, 0.1), + g + ], + className: ut("grid-guideline"), + size: r, + hide: !o, + direction: "", + grid: !0 + }); + }, w = 0; w <= e * 2; w += c) + S(w); + for (var w = -c; w >= -e; w -= c) + S(w); + } + return p; +} +function Xl(t, e, r, n) { + return r === "horizontal" ? Y(t.right - e.left) <= n || Y(t.left - e.right) <= n || t.left <= e.right && e.left <= t.right : r === "vertical" ? Y(t.bottom - e.top) <= n || Y(t.top - e.bottom) <= n || t.top <= e.bottom && e.top <= t.bottom : !0; +} +function np(t) { + var e = t.state, r = t.props.elementGuidelines, n = r === void 0 ? [] : r; + if (!n.length) + return e.elementRects = [], []; + var a = (e.elementRects || []).filter(function(d) { + return !d.refresh; + }), i = n.map(function(d) { + return pe(d) && "element" in d ? I(I({}, d), { element: Pe(d.element, !0) }) : { + element: Pe(d, !0) + }; + }).filter(function(d) { + return d.element; + }), o = Sr(a.map(function(d) { + return d.element; + }), i.map(function(d) { + return d.element; + })), s = o.maintained, l = o.added, u = []; + s.forEach(function(d) { + var p = O(d, 2), h = p[0], g = p[1]; + u[g] = a[h]; + }), ap(t, l.map(function(d) { + return i[d]; + })).map(function(d, p) { + u[l[p]] = d; + }), e.elementRects = u; + var c = Wi(t.props.elementSnapDirections), f = []; + return u.forEach(function(d) { + var p = d.element, h = d.top, g = h === void 0 ? c.top : h, x = d.left, y = x === void 0 ? c.left : x, b = d.right, C = b === void 0 ? c.right : b, S = d.bottom, w = S === void 0 ? c.bottom : S, v = d.center, _ = v === void 0 ? c.center : v, M = d.middle, T = M === void 0 ? c.middle : M, k = d.className, A = d.rect, z = Yi({ + top: g, + right: C, + left: y, + bottom: w, + center: _, + middle: T + }, A), R = z.horizontal, B = z.vertical, N = z.horizontalNames, L = z.verticalNames, V = A.top, G = A.left, W = A.right - G, $ = A.bottom - V, j = [W, $]; + B.forEach(function(J, Q) { + f.push({ + type: "vertical", + element: p, + pos: [ + gt(J, 0.1), + V + ], + size: $, + sizes: j, + className: k, + elementRect: d, + elementDirection: Vo[L[Q]] || L[Q], + direction: "" + }); + }), R.forEach(function(J, Q) { + f.push({ + type: "horizontal", + element: p, + pos: [ + G, + gt(J, 0.1) + ], + size: W, + sizes: j, + className: k, + elementRect: d, + elementDirection: Vo[N[Q]] || N[Q], + direction: "" + }); + }); + }), f; +} +function ns(t, e) { + return t ? t.map(function(r) { + var n = pe(r) ? r : { pos: r }, a = n.pos; + return nn(a) ? n : I(I({}, n), { pos: Rt(a, e) }); + }) : []; +} +function Hl(t, e, r, n, a, i, o) { + a === void 0 && (a = 0), i === void 0 && (i = 0), o === void 0 && (o = { left: 0, top: 0, right: 0, bottom: 0 }); + var s = [], l = o.left, u = o.top, c = o.bottom, f = o.right, d = r + f - l, p = n + c - u; + return ns(t, p).forEach(function(h) { + s.push({ + type: "horizontal", + pos: [ + l, + gt(h.pos - i + u, 0.1) + ], + size: d, + className: h.className, + direction: "" + }); + }), ns(e, d).forEach(function(h) { + s.push({ + type: "vertical", + pos: [ + gt(h.pos - a + l, 0.1), + u + ], + size: p, + className: h.className, + direction: "" + }); + }), s; +} +function ap(t, e) { + if (!e.length) + return []; + var r = t.props.groupable, n = t.state, a = n.containerClientRect, i = n.rootMatrix, o = n.is3d, s = n.offsetDelta, l = o ? 4 : 3, u = O(kd(i, a, l), 2), c = u[0], f = u[1], d = r ? 0 : s[0], p = r ? 0 : s[1]; + return e.map(function(h) { + var g = h.element.getBoundingClientRect(), x = g.left - c - d, y = g.top - f - p, b = y + g.height, C = x + g.width, S = O(zr(i, [x, y], l), 2), w = S[0], v = S[1], _ = O(zr(i, [C, b], l), 2), M = _[0], T = _[1]; + return I(I({}, h), { rect: { + left: w, + right: M, + top: v, + bottom: T, + center: (w + M) / 2, + middle: (v + T) / 2 + } }); + }); +} +function Pn(t) { + var e = t.state, r = e.container, n = t.props.snapContainer || r; + if (e.snapContainer === n && e.guidelines && e.guidelines.length) + return !1; + var a = e.containerClientRect, i = { + left: 0, + top: 0, + bottom: 0, + right: 0 + }; + if (r !== n) { + var o = Pe(n, !0); + if (o) { + var s = tn(o), l = us(e, [ + s.left - a.left, + s.top - a.top + ]), u = us(e, [ + s.right - a.right, + s.bottom - a.bottom + ]); + i.left = gt(l[0], 1e-5), i.top = gt(l[1], 1e-5), i.right = gt(u[0], 1e-5), i.bottom = gt(u[1], 1e-5); + } + } + return e.snapContainer = n, e.snapOffset = i, e.guidelines = fi(t), e.enableSnap = !0, !0; +} +function ql(t, e, r, n, a, i) { + var o = dr(t, e, r, i ? 4 : 3), s = Qt(o, n); + return $i(o, ct(a, s)); +} +function as(t) { + return t ? t / Y(t) : 0; +} +function ip(t, e, r, n, a, i) { + var o = i.fixedDirection, s = Pd(r, o, n), l = Hi(t, e, r, n), u = Z(Z([], O(Xd(t, e, s, n, a, i)), !1), O(Fl(t, l, i)), !1), c = Jn(u, 0), f = Jn(u, 1); + return { + width: { + isBound: c.isBound, + offset: c.offset[0] + }, + height: { + isBound: f.isBound, + offset: f.offset[1] + } + }; +} +function op(t, e, r, n, a, i, o, s, l) { + var u = Qt(e, o), c = pa(t, s, { + vertical: [u[0]], + horizontal: [u[1]] + }), f = c.horizontal.offset, d = c.vertical.offset; + if (gt(d, ai) || gt(f, ai)) { + var p = O(Oe({ + datas: l, + distX: -d, + distY: -f + }), 2), h = p[0], g = p[1], x = Math.min(a || 1 / 0, r + o[0] * h), y = Math.min(i || 1 / 0, n + o[1] * g); + return [x - r, y - n]; + } + return [0, 0]; +} +function Vl(t, e, r, n, a, i, o, s) { + for (var l = Ce(t.state), u = t.props.keepRatio, c = 0, f = 0, d = 0; d < 2; ++d) { + var p = e(c, f), h = ip(t, p, a, u, o, s), g = h.width, x = h.height, y = g.isBound, b = x.isBound, C = g.offset, S = x.offset; + if (d === 1 && (y || (C = 0), b || (S = 0)), d === 0 && o && !y && !b) + return [0, 0]; + if (u) { + var w = Y(C) * (r ? 1 / r : 1), v = Y(S) * (n ? 1 / n : 1), _ = y && b ? w < v : b || !y && w < v; + _ ? C = r * S / n : S = n * C / r; + } + c += C, f += S; + } + if (!u && a[0] && a[1]) { + var M = qd(t, l, a, i, s), T = M.maxWidth, k = M.maxHeight, A = O(op(t, e(c, f).map(function(B) { + return B.map(function(N) { + return gt(N, ai); + }); + }), r + c, n + f, T, k, a, o, s), 2), C = A[0], S = A[1]; + c += C, f += S; + } + return [c, f]; +} +function Jr(t) { + return t < 0 && (t = t % 360 + 360), t %= 360, t; +} +function sp(t, e) { + e = Jr(e); + var r = Math.floor(t / 360), n = r * 360 + 360 - e, a = r * 360 + e; + return Y(t - n) < Y(t - a) ? n : a; +} +function Pa(t, e) { + t = Jr(t), e = Jr(e); + var r = Jr(t - e); + return Math.min(r, 360 - r); +} +function lp(t, e, r, n) { + var a, i = t.props, o = (a = i[Pl]) !== null && a !== void 0 ? a : 5, s = i[Ol]; + if (Gr(t, "rotatable")) { + var l = e.pos1, u = e.pos2, c = e.pos3, f = e.pos4, d = e.origin, p = r * Math.PI / 180, h = [l, u, c, f].map(function(S) { + return ct(S, d); + }), g = h.map(function(S) { + return un(S, p); + }), x = Z(Z([], O(Dd(t, h, g, d, r)), !1), O(jd(t, h, g, d, r)), !1); + x.sort(function(S, w) { + return Y(S - r) - Y(w - r); + }); + var y = x.length > 0; + if (y) + return { + isSnap: y, + dist: y ? x[0] : r + }; + } + if (s != null && s.length && o) { + var b = s.slice().sort(function(S, w) { + return Pa(S, n) - Pa(w, n); + }), C = b[0]; + if (Pa(C, n) <= o) + return { + isSnap: !0, + dist: r + sp(n, C) - n + }; + } + return { + isSnap: !1, + dist: r + }; +} +function up(t, e, r, n, a, i, o) { + if (!Gr(t, "resizable")) + return [0, 0]; + var s = o.fixedDirection, l = o.nextAllMatrix, u = t.state, c = u.allMatrix, f = u.is3d; + return Vl(t, function(d, p) { + return ql(l || c, e + d, r + p, s, a, f); + }, e, r, n, a, i, o); +} +function cp(t, e, r, n, a) { + if (!Gr(t, "scalable")) + return [0, 0]; + var i = a.startOffsetWidth, o = a.startOffsetHeight, s = a.fixedPosition, l = a.fixedDirection, u = a.is3d, c = Vl(t, function(f, d) { + return ql(ud(a, wt(e, [f / i, d / o])), i, o, l, s, u); + }, i, o, r, s, n, a); + return [c[0] / i, c[1] / o]; +} +function fp(t, e) { + e.absolutePoses = Ce(t.state); +} +function is(t) { + var e = []; + return t.forEach(function(r) { + r.guidelineInfos.forEach(function(n) { + var a = n.guideline; + ve(e, function(i) { + return i.guideline === a; + }) || (a.direction = "", e.push({ guideline: a, posInfo: r })); + }); + }), e.map(function(r) { + var n = r.guideline, a = r.posInfo; + return I(I({}, n), { direction: a.direction }); + }); +} +function os(t, e, r, n, a, i) { + var o = Li(fa(t, i), e, r), s = o.vertical, l = o.horizontal, u = Dr(); + s.forEach(function(h) { + h.isBound && (h.direction === "start" && (u.left = !0), h.direction === "end" && (u.right = !0), n.push({ + type: "bounds", + pos: h.pos + })); + }), l.forEach(function(h) { + h.isBound && (h.direction === "start" && (u.top = !0), h.direction === "end" && (u.bottom = !0), a.push({ + type: "bounds", + pos: h.pos + })); + }); + var c = Gd(t), f = c.boundMap, d = c.vertical, p = c.horizontal; + return d.forEach(function(h) { + Ge(n, function(g) { + var x = g.type, y = g.pos; + return x === "bounds" && y === h; + }) >= 0 || n.push({ + type: "bounds", + pos: h + }); + }), p.forEach(function(h) { + Ge(a, function(g) { + var x = g.type, y = g.pos; + return x === "bounds" && y === h; + }) >= 0 || a.push({ + type: "bounds", + pos: h + }); + }), { + boundMap: u, + innerBoundMap: f + }; +} +var dp = Zi("", ["resizable", "scalable"]), pp = { + name: "snappable", + dragRelation: "strong", + props: [ + "snappable", + "snapContainer", + "snapDirections", + "elementSnapDirections", + "snapGap", + "snapGridWidth", + "snapGridHeight", + "isDisplaySnapDigit", + "isDisplayInnerSnapDigit", + "isDisplayGridGuidelines", + "snapDigit", + "snapThreshold", + "snapRenderThreshold", + "snapGridAll", + Pl, + Ol, + zl, + Al, + "horizontalGuidelines", + "verticalGuidelines", + "elementGuidelines", + "bounds", + "innerBounds", + "snapDistFormat", + "maxSnapElementGuidelineDistance", + "maxSnapElementGapDistance" + ], + events: ["snap", "bound"], + css: [ + `:host { +--bounds-color: #d66; +} +.guideline { +pointer-events: none; +z-index: 2; +} +.guideline.bounds { +background: #d66; +background: var(--bounds-color); +} +.guideline-group { +position: absolute; +top: 0; +left: 0; +} +.guideline-group .size-value { +position: absolute; +color: #f55; +font-size: 12px; +font-size: calc(12px * var(--zoom)); +font-weight: bold; +} +.guideline-group.horizontal .size-value { +transform-origin: 50% 100%; +transform: translateX(-50%); +left: 50%; +bottom: 5px; +bottom: calc(2px + 3px * var(--zoom)); +} +.guideline-group.vertical .size-value { +transform-origin: 0% 50%; +top: 50%; +transform: translateY(-50%); +left: 5px; +left: calc(2px + 3px * var(--zoom)); +} +.guideline.gap { +background: #f55; +} +.size-value.gap { +color: #f55; +} +` + ], + render: function(t, e) { + var r = t.state, n = r.top, a = r.left, i = r.pos1, o = r.pos2, s = r.pos3, l = r.pos4, u = r.snapRenderInfo, c = t.props.snapRenderThreshold, f = c === void 0 ? 1 : c; + if (!u || !u.render || !Gr(t, "")) + return _r(t, "boundMap", Dr(), function(H) { + return JSON.stringify(H); + }), _r(t, "innerBoundMap", Dr(), function(H) { + return JSON.stringify(H); + }), []; + r.guidelines = fi(t); + var d = Math.min(i[0], o[0], s[0], l[0]), p = Math.min(i[1], o[1], s[1], l[1]), h = u.externalPoses || [], g = Ce(t.state), x = [], y = [], b = [], C = [], S = [], w = ye(g), v = w.width, _ = w.height, M = w.top, T = w.left, k = w.bottom, A = w.right, z = { left: T, right: A, top: M, bottom: k, center: (T + A) / 2, middle: (M + k) / 2 }, R = h.length > 0, B = R ? ye(h) : {}; + if (!u.request) { + if (u.direction && S.push(Rd(t, g, u.direction, f, f)), u.snap) { + var N = ye(g); + u.center && (N.middle = (N.top + N.bottom) / 2, N.center = (N.left + N.right) / 2), S.push($o(t, N, f, f)); + } + R && (u.center && (B.middle = (B.top + B.bottom) / 2, B.center = (B.left + B.right) / 2), S.push($o(t, B, f, f))), S.forEach(function(H) { + var tt = H.vertical.posInfos, U = H.horizontal.posInfos; + x.push.apply(x, Z([], O(tt.filter(function(et) { + var lt = et.guidelineInfos; + return lt.some(function(ft) { + var xt = ft.guideline; + return !xt.hide; + }); + }).map(function(et) { + return { + type: "snap", + pos: et.pos + }; + })), !1)), y.push.apply(y, Z([], O(U.filter(function(et) { + var lt = et.guidelineInfos; + return lt.some(function(ft) { + var xt = ft.guideline; + return !xt.hide; + }); + }).map(function(et) { + return { + type: "snap", + pos: et.pos + }; + })), !1)), b.push.apply(b, Z([], O(is(tt)), !1)), C.push.apply(C, Z([], O(is(U)), !1)); + }); + } + var L = os(t, [T, A], [M, k], x, y), V = L.boundMap, G = L.innerBoundMap; + R && os(t, [B.left, B.right], [B.top, B.bottom], x, y, u.externalBounds); + var W = Z(Z([], O(b), !1), O(C), !1), $ = W.filter(function(H) { + return H.element && !H.gapRects; + }), j = W.filter(function(H) { + return H.gapRects; + }).sort(function(H, tt) { + return H.gap - tt.gap; + }); + rt(t, "onSnap", { + guidelines: W.filter(function(H) { + var tt = H.element; + return !tt; + }), + elements: $, + gaps: j + }, !0); + var J = _r(t, "boundMap", V, function(H) { + return JSON.stringify(H); + }, Dr()), Q = _r(t, "innerBoundMap", G, function(H) { + return JSON.stringify(H); + }, Dr()); + return (V === J || G === Q) && rt(t, "onBound", { + bounds: V, + innerBounds: G + }, !0), Z(Z(Z(Z(Z(Z([], O(Jd(t, $, [d, p], z, e)), !1), O(Qd(t, j, [d, p], z, e)), !1), O(rs(t, "horizontal", C, [a, n], z, e)), !1), O(rs(t, "vertical", b, [a, n], z, e)), !1), O(es(t, "horizontal", y, d, n, v, 0, e)), !1), O(es(t, "vertical", x, p, a, _, 1, e)), !1); + }, + dragStart: function(t, e) { + t.state.snapRenderInfo = { + request: e.isRequest, + snap: !0, + center: !0 + }, Pn(t); + }, + drag: function(t) { + var e = t.state; + Pn(t) || (e.guidelines = fi(t)), e.snapRenderInfo && (e.snapRenderInfo.render = !0); + }, + pinchStart: function(t) { + this.unset(t); + }, + dragEnd: function(t) { + this.unset(t); + }, + dragControlCondition: function(t, e) { + if (dp(t, e) || ci(t, e)) + return !0; + if (!e.isRequest && e.inputEvent) + return Kt(e.inputEvent.target, ut("snap-control")); + }, + dragControlStart: function(t) { + t.state.snapRenderInfo = null, Pn(t); + }, + dragControl: function(t) { + this.drag(t); + }, + dragControlEnd: function(t) { + this.unset(t); + }, + dragGroupStart: function(t, e) { + this.dragStart(t, e); + }, + dragGroup: function(t) { + this.drag(t); + }, + dragGroupEnd: function(t) { + this.unset(t); + }, + dragGroupControlStart: function(t) { + t.state.snapRenderInfo = null, Pn(t); + }, + dragGroupControl: function(t) { + this.drag(t); + }, + dragGroupControlEnd: function(t) { + this.unset(t); + }, + unset: function(t) { + var e = t.state; + e.enableSnap = !1, e.guidelines = [], e.snapRenderInfo = null, e.elementRects = []; + } +}; +function vp(t, e) { + return [ + t[0] * e[0], + t[1] * e[1] + ]; +} +function ut() { + for (var t = [], e = 0; e < arguments.length; e++) + t[e] = arguments[e]; + return Nc.apply(void 0, Z([Bi], O(t), !1)); +} +function $l(t) { + t(); +} +function hp(t) { + return !t || t === "none" ? [1, 0, 0, 1, 0, 0] : pe(t) ? t : Tr(t); +} +function Qr(t, e, r) { + return Vn(e, lr(r, e), t, lr(r.map(function(n) { + return -n; + }), e)); +} +function gp(t, e, r) { + if (e === "%") { + var n = Vi(t.ownerSVGElement); + return n[r ? "width" : "height"] / 100; + } + return 1; +} +function mp(t) { + var e = xp(Ui(t, ":before")); + return e.map(function(r, n) { + var a = or(r), i = a.value, o = a.unit; + return i * gp(t, o, n === 0); + }); +} +function ta(t) { + return t ? t.split(" ") : ["0", "0"]; +} +function xp(t) { + return ta(t.transformOrigin); +} +function Ul(t) { + var e = de(t), r = e("transform"); + if (r && r !== "none") + return r; + if ("transform" in t) { + var n = t.transform, a = n.baseVal; + if (!a) + return ""; + var i = a.length; + if (!i) + return ""; + for (var o = [], s = function(u) { + var c = a[u].matrix; + o.push("matrix(".concat(["a", "b", "c", "d", "e", "f"].map(function(f) { + return c[f]; + }).join(", "), ")")); + }, l = 0; l < i; ++l) + s(l); + return o.join(" "); + } + return ""; +} +function ln(t, e, r, n, a) { + var i, o, s = Ii(t) || Ke(t), l = !1, u, c; + if (!t || r) + u = t; + else { + var f = (i = t == null ? void 0 : t.assignedSlot) === null || i === void 0 ? void 0 : i.parentElement, d = t.parentElement; + f ? (l = !0, c = d, u = f) : u = d; + } + for (var p = !1, h = t === e || u === e, g = "relative", x = 1, y = parseFloat(a == null ? void 0 : a("zoom")) || 1, b = a == null ? void 0 : a("position"); u && u !== s; ) { + e === u && (h = !0); + var C = de(u), S = u.tagName.toLowerCase(), w = Ul(u), v = C("willChange"), _ = parseFloat(C("zoom")) || 1; + if (g = C("position"), n && _ !== 1) { + x = _; + break; + } + if ( + // offsetParent is the parentElement if the target's zoom is not 1 and not absolute. + !r && n && y !== 1 && b && b !== "absolute" || S === "svg" || S === "foreignobject" || g !== "static" || w && w !== "none" || v === "transform" + ) + break; + var M = (o = t == null ? void 0 : t.assignedSlot) === null || o === void 0 ? void 0 : o.parentNode, T = u.parentNode; + M && (l = !0, c = T); + var k = T; + if (k && k.nodeType === 11) { + u = k.host, p = !0, g = de(u)("position"); + break; + } + u = k, g = "relative"; + } + return { + offsetZoom: x, + hasSlot: l, + parentSlotElement: c, + isCustomElement: p, + isStatic: g === "static", + isEnd: h || !u || u === s, + offsetParent: u || s + }; +} +function yp(t, e) { + var r, n = t.tagName.toLowerCase(), a = t.offsetLeft, i = t.offsetTop, o = de(t), s = wi(a), l = !s, u, c; + return !l && (n !== "svg" || t.ownerSVGElement) ? (u = hl ? mp(t) : ta(o("transformOrigin")).map(function(f) { + return parseFloat(f); + }), c = u.slice(), l = !0, n === "svg" ? (a = 0, i = 0) : (r = O(Cp(t, u, t === e && e.tagName.toLowerCase() === "g"), 4), a = r[0], i = r[1], u[0] = r[2], u[1] = r[3])) : (u = ta(o("transformOrigin")).map(function(f) { + return parseFloat(f); + }), c = u.slice()), { + tagName: n, + isSVG: s, + hasOffset: l, + offset: [a || 0, i || 0], + origin: u, + targetOrigin: c + }; +} +function Kl(t, e) { + var r = de(t), n = de(Ke(t)), a = n("position"); + if (!e && (!a || a === "static")) + return [0, 0]; + var i = parseInt(n("marginLeft"), 10), o = parseInt(n("marginTop"), 10); + return r("position") === "absolute" && ((r("top") !== "auto" || r("bottom") !== "auto") && (o = 0), (r("left") !== "auto" || r("right") !== "auto") && (i = 0)), [i, o]; +} +function di(t) { + t.forEach(function(e) { + var r = e.matrix; + r && (e.matrix = Te(r, 3, 4)); + }); +} +function bp(t) { + for (var e = t.parentElement, r = !1, n = Ke(t); e; ) { + var a = Ui(e).transform; + if (a && a !== "none") { + r = !0; + break; + } + if (e === n) + break; + e = e.parentElement; + } + return { + fixedContainer: e || n, + hasTransform: r + }; +} +function va(t, e) { + return e === void 0 && (e = t.length > 9), "".concat(e ? "matrix3d" : "matrix", "(").concat(il(t, !e).join(","), ")"); +} +function Vi(t) { + var e = t.clientWidth, r = t.clientHeight; + if (!t) + return { x: 0, y: 0, width: 0, height: 0, clientWidth: e, clientHeight: r }; + var n = t.viewBox, a = n && n.baseVal || { x: 0, y: 0, width: 0, height: 0 }; + return { + x: a.x, + y: a.y, + width: a.width || e, + height: a.height || r, + clientWidth: e, + clientHeight: r + }; +} +function Sp(t, e) { + var r, n = Vi(t), a = n.width, i = n.height, o = n.clientWidth, s = n.clientHeight, l = o / a, u = s / i, c = t.preserveAspectRatio.baseVal, f = c.align, d = c.meetOrSlice, p = [0, 0], h = [l, u], g = [0, 0]; + if (f !== 1) { + var x = (f - 2) % 3, y = Math.floor((f - 2) / 3); + p[0] = a * x / 2, p[1] = i * y / 2; + var b = d === 2 ? Math.max(u, l) : Math.min(l, u); + h[0] = b, h[1] = b, g[0] = (o - a) / 2 * x, g[1] = (s - i) / 2 * y; + } + var C = Ri(h, e); + return r = O(g, 2), C[e * (e - 1)] = r[0], C[e * (e - 1) + 1] = r[1], Qr(C, e, p); +} +function Cp(t, e, r) { + var n = t.tagName.toLowerCase(); + if (!t.getBBox || !r && n === "g") + return [0, 0, 0, 0]; + var a = de(t), i = a("transform-box") === "fill-box", o = t.getBBox(), s = Vi(t.ownerSVGElement), l = o.x, u = o.y; + n === "foreignobject" && !l && !u && (l = parseFloat(t.getAttribute("x")) || 0, u = parseFloat(t.getAttribute("y")) || 0); + var c = l - s.x, f = u - s.y, d = i ? e[0] : e[0] - c, p = i ? e[1] : e[1] - f; + return [c, f, d, p]; +} +function Gt(t, e, r) { + return ne(t, sr(e, r), r); +} +function dr(t, e, r, n) { + return [[0, 0], [e, 0], [0, r], [e, r]].map(function(a) { + return Gt(t, a, n); + }); +} +function ye(t) { + var e = t.map(function(u) { + return u[0]; + }), r = t.map(function(u) { + return u[1]; + }), n = Math.min.apply(Math, Z([], O(e), !1)), a = Math.min.apply(Math, Z([], O(r), !1)), i = Math.max.apply(Math, Z([], O(e), !1)), o = Math.max.apply(Math, Z([], O(r), !1)), s = i - n, l = o - a; + return { + left: n, + top: a, + right: i, + bottom: o, + width: s, + height: l + }; +} +function ss(t, e, r, n) { + var a = dr(t, e, r, n); + return ye(a); +} +function Ep(t, e, r, n, a) { + var i, o = t.target, s = t.origin, l = e.matrix, u = Jl(o), c = u.offsetWidth, f = u.offsetHeight, d = r.getBoundingClientRect(), p = [0, 0]; + r === Ke(r) && (p = Kl(o, !0)); + for (var h = o.getBoundingClientRect(), g = h.left - d.left + r.scrollLeft - (r.clientLeft || 0) + p[0], x = h.top - d.top + r.scrollTop - (r.clientTop || 0) + p[1], y = h.width, b = h.height, C = Vn(n, a, l), S = ss(C, c, f, n), w = S.left, v = S.top, _ = S.width, M = S.height, T = Gt(C, s, n), k = ct(T, [w, v]), A = [ + g + k[0] * y / _, + x + k[1] * b / M + ], z = [0, 0], R = 0; ++R < 10; ) { + var B = ke(a, n); + i = O(ct(Gt(B, A, n), Gt(B, T, n)), 2), z[0] = i[0], z[1] = i[1]; + var N = Vn(n, a, lr(z, n), l), L = ss(N, c, f, n), V = L.left, G = L.top, W = V - g, $ = G - x; + if (Y(W) < 2 && Y($) < 2) + break; + A[0] -= W, A[1] -= $; + } + return z.map(function(j) { + return Math.round(j); + }); +} +function Dp(t, e, r) { + var n = t.length === 16, a = n ? 4 : 3, i = e.map(function(l) { + return Gt(t, l, a); + }), o = r.left, s = r.top; + return i.map(function(l) { + return [l[0] + o, l[1] + s]; + }); +} +function Se(t) { + return Math.sqrt(t[0] * t[0] + t[1] * t[1]); +} +function Zl(t, e) { + return Se([ + e[0] - t[0], + e[1] - t[1] + ]); +} +function $r(t, e, r, n) { + r === void 0 && (r = 1), n === void 0 && (n = Xt(t, e)); + var a = Zl(t, e); + return { + transform: "translateY(-50%) translate(".concat(t[0], "px, ").concat(t[1], "px) rotate(").concat(n, "rad) scaleY(").concat(r, ")"), + width: "".concat(a, "px") + }; +} +function ea(t, e) { + for (var r = [], n = 2; n < arguments.length; n++) + r[n - 2] = arguments[n]; + var a = r.length, i = r.reduce(function(s, l) { + return s + l[0]; + }, 0) / a, o = r.reduce(function(s, l) { + return s + l[1]; + }, 0) / a; + return { + transform: "translateZ(0px) translate(".concat(i, "px, ").concat(o, "px) rotate(").concat(t, "rad) scale(").concat(e, ")") + }; +} +function cr(t, e) { + var r = t[e]; + return pe(r) ? I(I({}, t), r) : t; +} +function Jl(t) { + var e = t && !wi(t.offsetWidth), r = 0, n = 0, a = 0, i = 0, o = 0, s = 0, l = 0, u = 0, c = 0, f = 0, d = 0, p = 0, h = 1 / 0, g = 1 / 0, x = 1 / 0, y = 1 / 0, b = 0, C = 0, S = !1; + if (t) + if (!e && t.ownerSVGElement) { + var w = t.getBBox(); + S = !0, r = w.width, n = w.height, o = r, s = n, l = r, u = n, a = r, i = n; + } else { + var v = de(t), _ = t.style, M = v("boxSizing") === "border-box", T = parseFloat(v("borderLeftWidth")) || 0, k = parseFloat(v("borderRightWidth")) || 0, A = parseFloat(v("borderTopWidth")) || 0, z = parseFloat(v("borderBottomWidth")) || 0, R = parseFloat(v("paddingLeft")) || 0, B = parseFloat(v("paddingRight")) || 0, N = parseFloat(v("paddingTop")) || 0, L = parseFloat(v("paddingBottom")) || 0, V = R + B, G = N + L, W = T + k, $ = A + z, j = V + W, J = G + $, Q = v("position"), H = 0, tt = 0; + if ("clientLeft" in t) { + var U = null; + if (Q === "absolute") { + var et = ln(t, Ke(t)); + U = et.offsetParent; + } else + U = t.parentElement; + if (U) { + var lt = de(U); + H = parseFloat(lt("width")), tt = parseFloat(lt("height")); + } + } + c = Math.max(V, Rt(v("minWidth"), H) || 0), f = Math.max(G, Rt(v("minHeight"), tt) || 0), h = Rt(v("maxWidth"), H), g = Rt(v("maxHeight"), tt), isNaN(h) && (h = 1 / 0), isNaN(g) && (g = 1 / 0), b = Rt(_.width, 0) || 0, C = Rt(_.height, 0) || 0, o = parseFloat(v("width")) || 0, s = parseFloat(v("height")) || 0, l = Y(o - b) < 1 ? qn(c, b || o, h) : o, u = Y(s - C) < 1 ? qn(f, C || s, g) : s, r = l, n = u, a = l, i = u, M ? (x = h, y = g, d = c, p = f, l = r - j, u = n - J) : (x = h + j, y = g + J, d = c + j, p = f + J, r = l + j, n = u + J), a = l + V, i = u + G; + } + return { + svg: S, + offsetWidth: r, + offsetHeight: n, + clientWidth: a, + clientHeight: i, + contentWidth: l, + contentHeight: u, + inlineCSSWidth: b, + inlineCSSHeight: C, + cssWidth: o, + cssHeight: s, + minWidth: c, + minHeight: f, + maxWidth: h, + maxHeight: g, + minOffsetWidth: d, + minOffsetHeight: p, + maxOffsetWidth: x, + maxOffsetHeight: y + }; +} +function Ql(t, e) { + return Xt(e > 0 ? t[0] : t[1], e > 0 ? t[1] : t[0]); +} +function On() { + return { + left: 0, + top: 0, + width: 0, + height: 0, + right: 0, + bottom: 0, + clientLeft: 0, + clientTop: 0, + clientWidth: 0, + clientHeight: 0, + scrollWidth: 0, + scrollHeight: 0 + }; +} +function tu(t, e) { + var r = t === Ke(t) || t === Ii(t), n = { + clientLeft: t.clientLeft, + clientTop: t.clientTop, + clientWidth: t.clientWidth, + clientHeight: t.clientHeight, + scrollWidth: t.scrollWidth, + scrollHeight: t.scrollHeight, + overflow: !1 + }; + return r && (n.clientHeight = Math.max(e.height, n.clientHeight), n.scrollHeight = Math.max(e.height, n.scrollHeight)), n.overflow = de(t)("overflow") !== "visible", I(I({}, e), n); +} +function Oa(t, e, r, n) { + var a = t.left, i = t.right, o = t.top, s = t.bottom, l = e.top, u = e.left, c = { + left: u + a, + top: l + o, + right: u + i, + bottom: l + s, + width: i - a, + height: s - o + }; + return r && n ? tu(r, c) : c; +} +function tn(t, e) { + var r = 0, n = 0, a = 0, i = 0; + if (t) { + var o = t.getBoundingClientRect(); + r = o.left, n = o.top, a = o.width, i = o.height; + } + var s = { + left: r, + top: n, + width: a, + height: i, + right: r + a, + bottom: n + i + }; + return t && e ? tu(t, s) : s; +} +function wp(t) { + var e = t.props, r = e.groupable, n = e.svgOrigin, a = t.getState(), i = a.offsetWidth, o = a.offsetHeight, s = a.svg, l = a.transformOrigin; + return !r && s && n ? Qi(n, i, o) : l; +} +function eu(t, e, r, n) { + var a; + if (t) + a = t; + else if (e) + a = [0, 0]; + else { + var i = r.target; + a = ru(i, n); + } + return a; +} +function ru(t, e) { + if (t) { + var r = t.getAttribute("data-rotation") || "", n = t.getAttribute("data-direction"); + if (e.deg = r, !!n) { + var a = [0, 0]; + return n.indexOf("w") > -1 && (a[0] = -1), n.indexOf("e") > -1 && (a[0] = 1), n.indexOf("n") > -1 && (a[1] = -1), n.indexOf("s") > -1 && (a[1] = 1), a; + } + } +} +function $i(t, e) { + return [ + wt(e, t[0]), + wt(e, t[1]), + wt(e, t[2]), + wt(e, t[3]) + ]; +} +function Ce(t) { + var e = t.left, r = t.top, n = t.pos1, a = t.pos2, i = t.pos3, o = t.pos4; + return $i([n, a, i, o], [e, r]); +} +function pi(t, e) { + t[e ? "controlAbles" : "targetAbles"].forEach(function(r) { + r.unset && r.unset(t); + }); +} +function wr(t, e) { + var r = e ? "controlGesto" : "targetGesto", n = t[r]; + (n == null ? void 0 : n.isIdle()) === !1 && pi(t, e), n == null || n.unset(), t[r] = null; +} +function se(t, e) { + if (e) { + var r = jr(e); + r.nextStyle = I(I({}, r.nextStyle), t); + } + return { + style: t, + cssText: Nr(t).map(function(n) { + return "".concat($c(n, "-"), ": ").concat(t[n], ";"); + }).join("") + }; +} +function nu(t, e, r) { + var n = e.afterTransform || e.transform; + return I(I({}, se(I(I(I({}, t.style), e.style), { transform: n }), r)), { afterTransform: n, transform: t.transform }); +} +function bt(t, e, r, n) { + var a = e.datas; + a.datas || (a.datas = {}); + var i = I(I({}, r), { target: t.state.target, clientX: e.clientX, clientY: e.clientY, inputEvent: e.inputEvent, currentTarget: t, moveable: t, datas: a.datas, isRequest: e.isRequest, isRequestChild: e.isRequestChild, isFirstDrag: !!e.isFirstDrag, isTrusted: e.isTrusted !== !1, stopAble: function() { + a.isEventStart = !1; + }, stopDrag: function() { + var o; + (o = e.stop) === null || o === void 0 || o.call(e); + } }); + return a.isStartEvent ? n || (a.lastEvent = i) : a.isStartEvent = !0, i; +} +function he(t, e, r) { + var n = e.datas, a = "isDrag" in r ? r.isDrag : e.isDrag; + return n.datas || (n.datas = {}), I(I({ isDrag: a }, r), { moveable: t, target: t.state.target, clientX: e.clientX, clientY: e.clientY, inputEvent: e.inputEvent, currentTarget: t, lastEvent: n.lastEvent, isDouble: e.isDouble, datas: n.datas, isFirstDrag: !!e.isFirstDrag }); +} +function ha(t, e, r) { + t._emitter.on(e, r); +} +function rt(t, e, r, n, a) { + return t.triggerEvent(e, r, n, a); +} +function Ui(t, e) { + return xe(t).getComputedStyle(t, e); +} +function zn(t, e, r) { + var n = {}, a = {}; + return t.filter(function(i) { + var o = i.name; + if (n[o] || !e.some(function(s) { + return i[s]; + })) + return !1; + if (!r && i.ableGroup) { + if (a[i.ableGroup]) + return !1; + a[i.ableGroup] = !0; + } + return n[o] = !0, !0; + }); +} +function vi(t, e) { + return t === e || t == null && e == null; +} +function ls() { + for (var t = [], e = 0; e < arguments.length; e++) + t[e] = arguments[e]; + for (var r = t.length - 1, n = 0; n < r; ++n) { + var a = t[n]; + if (!wi(a)) + return a; + } + return t[r]; +} +function au(t, e) { + var r = [], n = []; + return t.forEach(function(a, i) { + var o = e(a, i, t), s = n.indexOf(o), l = r[s] || []; + s === -1 && (n.push(o), r.push(l)), l.push(a); + }), r; +} +function _p(t, e) { + var r = [], n = {}; + return t.forEach(function(a, i) { + var o = e(a, i, t), s = n[o]; + s || (s = [], n[o] = s, r.push(s)), s.push(a); + }), r; +} +function iu(t) { + return t.reduce(function(e, r) { + return e.concat(r); + }, []); +} +function Or() { + for (var t = [], e = 0; e < arguments.length; e++) + t[e] = arguments[e]; + return t.sort(function(r, n) { + return Y(n) - Y(r); + }), t[0]; +} +function zr(t, e, r) { + return ne(ke(t, r), sr(e, r), r); +} +function Mp(t, e) { + var r, n = t.is3d, a = t.rootMatrix, i = n ? 4 : 3; + return r = O(zr(a, [e.distX, e.distY], i), 2), e.distX = r[0], e.distY = r[1], e; +} +function me(t, e, r, n) { + if (!r[0] && !r[1]) + return e; + var a = Gt(t, [as(r[0] || 1), 0], n), i = Gt(t, [0, as(r[1] || 1)], n), o = Gt(t, [ + r[0] / Se(a), + r[1] / Se(i) + ], n); + return wt(e, o); +} +function we(t, e, r) { + return r ? "".concat(t / e * 100, "%") : "".concat(t, "px"); +} +function ra(t) { + return Y(t) <= le ? 0 : t; +} +function Ki(t) { + return function(e) { + if (!e.isDragging(t)) + return ""; + var r = gd(e, t), n = r.deg; + return n ? ut("view-control-rotation".concat(n)) : ""; + }; +} +function Zi(t, e) { + return e === void 0 && (e = [t]), function(r, n) { + if (n.isRequest) + return e.some(function(i) { + return n.requestAble === i; + }) ? n.parentDirection : !1; + var a = n.inputEvent.target; + return Kt(a, ut("direction")) && (!t || Kt(a, ut(t))); + }; +} +function kp(t, e, r) { + var n, a = Ir(t, { + "x%": function(w) { + return w / 100 * e.offsetWidth; + }, + "y%": function(w) { + return w / 100 * e.offsetHeight; + } + }), i = t.slice(0, r < 0 ? void 0 : r), o = t.slice(0, r < 0 ? void 0 : r + 1), s = t[r] || "", l = r < 0 ? [] : t.slice(r), u = r < 0 ? [] : t.slice(r + 1), c = a.slice(0, r < 0 ? void 0 : r), f = a.slice(0, r < 0 ? void 0 : r + 1), d = (n = a[r]) !== null && n !== void 0 ? n : Ir([""])[0], p = r < 0 ? [] : a.slice(r), h = r < 0 ? [] : a.slice(r + 1), g = d ? [d] : [], x = yr(c), y = yr(f), b = yr(p), C = yr(h), S = Pt(x, b, 4); + return { + transforms: t, + beforeFunctionMatrix: x, + beforeFunctionMatrix2: y, + targetFunctionMatrix: yr(g), + afterFunctionMatrix: b, + afterFunctionMatrix2: C, + allFunctionMatrix: S, + beforeFunctions: c, + beforeFunctions2: f, + targetFunction: g[0], + afterFunctions: p, + afterFunctions2: h, + beforeFunctionTexts: i, + beforeFunctionTexts2: o, + targetFunctionText: s, + afterFunctionTexts: l, + afterFunctionTexts2: u + }; +} +function Tp(t) { + return !t || !pe(t) || on(t) ? !1 : Yt(t) || "length" in t; +} +function Pe(t, e) { + return t ? on(t) ? t : be(t) ? e ? document.querySelector(t) : t : oa(t) ? t() : rl(t) ? t : "current" in t ? t.current : t : null; +} +function Ji(t, e) { + if (!t) + return []; + var r = Tp(t) ? [].slice.call(t) : [t]; + return r.reduce(function(n, a) { + return be(a) && e ? Z(Z([], O(n), !1), O([].slice.call(document.querySelectorAll(a))), !1) : (Yt(a) ? n.push(Ji(a, e)) : n.push(Pe(a, e)), n); + }, []); +} +function Ip(t, e, r) { + var n = Xt(t, e) / Math.PI * 180; + return n = r >= 0 ? n : 180 - n, n = n >= 0 ? n : 360 + n, n; +} +function us(t, e) { + var r = t.rootMatrix, n = t.is3d, a = n ? 4 : 3, i = ke(r, a); + return n || (i = Te(i, 3, 4)), i[12] = 0, i[13] = 0, i[14] = 0, Wn(i, e); +} +function ou(t, e, r, n, a) { + var i = O(t, 2), o = i[0], s = i[1], l = 0, u = 0; + if (a && o && s) { + var c = Xt([0, 0], e), f = Xt([0, 0], n), d = Se(e), p = Math.cos(c - f) * d; + if (!n[0]) + u = p, l = u * r; + else if (!n[1]) + l = p, u = l / r; + else { + var h = n[0] * o, g = n[1] * s, x = Math.atan2(h + e[0], g + e[1]), y = Math.atan2(h, g); + x < 0 && (x += Math.PI * 2), y < 0 && (y += Math.PI * 2); + var b = 0; + Y(x - y) < Math.PI / 2 || Y(x - y) > Math.PI / 2 * 3 || (y += Math.PI), b = x - y, b > Math.PI * 2 ? b -= Math.PI * 2 : b > Math.PI ? b = 2 * Math.PI - b : b < -Math.PI && (b = -2 * Math.PI - b); + var C = Se([h + e[0], g + e[1]]) * Math.cos(b); + l = C * Math.sin(y) - h, u = C * Math.cos(y) - g, n[0] < 0 && (l *= -1), n[1] < 0 && (u *= -1); + } + } else + l = n[0] * e[0], u = n[1] * e[1]; + return [l, u]; +} +function su(t, e, r, n) { + var a, i = r.ratio, o = r.startOffsetWidth, s = r.startOffsetHeight, l = 0, u = 0, c = n.distX, f = n.distY, d = n.pinchScale, p = n.parentDistance, h = n.parentDist, g = n.parentScale, x = r.fixedDirection, y = [0, 1].map(function(_) { + return Y(t[_] - x[_]); + }), b = [0, 1].map(function(_) { + var M = y[_]; + return M !== 0 && (M = 2 / M), M; + }); + if (h) + l = h[0], u = h[1], e && (l ? u || (u = l / i) : l = u * i); + else if (nn(d)) + l = (d - 1) * o, u = (d - 1) * s; + else if (g) + l = (g[0] - 1) * o, u = (g[1] - 1) * s; + else if (p) { + var C = o * y[0], S = s * y[1], w = Se([C, S]); + l = p / w * C * b[0], u = p / w * S * b[1]; + } else { + var v = Oe({ datas: r, distX: c, distY: f }); + v = b.map(function(_, M) { + return v[M] * _; + }), a = O(ou([o, s], v, i, t, e), 2), l = a[0], u = a[1]; + } + return { + // direction, + // sizeDirection, + distWidth: l, + distHeight: u + }; +} +function hi(t, e) { + if (e) { + if (t === "left") + return { x: "0%", y: "50%" }; + if (t === "top") + return { x: "50%", y: "50%" }; + if (t === "center") + return { x: "50%", y: "50%" }; + if (t === "right") + return { x: "100%", y: "50%" }; + if (t === "bottom") + return { x: "50%", y: "100%" }; + var r = O(t.split(" "), 2), n = r[0], a = r[1], i = hi(n || ""), o = hi(a || ""), s = I(I({}, i), o), l = { + x: "50%", + y: "50%" + }; + return s.x && (l.x = s.x), s.y && (l.y = s.y), s.value && (s.x && !s.y && (l.y = s.value), !s.x && s.y && (l.x = s.value)), l; + } + return t === "left" ? { x: "0%" } : t === "right" ? { x: "100%" } : t === "top" ? { y: "0%" } : t === "bottom" ? { y: "100%" } : t ? t === "center" ? { value: "50%" } : { value: t } : {}; +} +function Qi(t, e, r) { + var n = hi(t, !0), a = n.x, i = n.y; + return [ + Rt(a, e) || 0, + Rt(i, r) || 0 + ]; +} +function Rp(t, e, r) { + var n = t.map(function(i) { + return ct(i, e); + }), a = n.map(function(i) { + return un(i, r); + }); + return { + prev: n, + next: a, + result: a.map(function(i) { + return wt(i, e); + }) + }; +} +function lu(t, e) { + return t.length === e.length && t.every(function(r, n) { + var a = e[n], i = Yt(r), o = Yt(a); + return i && o ? lu(r, a) : !i && !o ? r === a : !1; + }); +} +function _r(t, e, r, n, a) { + var i = t._store, o = i[e]; + if (!(e in i)) + if (a != null) + i[e] = a, o = a; + else + return i[e] = r, r; + return o === r || n(o) === n(r) ? o : (i[e] = r, r); +} +function oe(t) { + return t >= 0 ? 1 : -1; +} +function Y(t) { + return Math.abs(t); +} +function za(t, e) { + return Jc(t).map(function(r) { + return e(r); + }); +} +function uu(t) { + return nn(t) ? { + top: t, + left: t, + right: t, + bottom: t + } : { + left: t.left || 0, + top: t.top || 0, + right: t.right || 0, + bottom: t.bottom || 0 + }; +} +var Pp = pn("pinchable", { + props: [ + "pinchable" + ], + events: [ + "pinchStart", + "pinch", + "pinchEnd", + "pinchGroupStart", + "pinchGroup", + "pinchGroupEnd" + ], + dragStart: function() { + return !0; + }, + pinchStart: function(t, e) { + var r = e.datas, n = e.targets, a = e.angle, i = e.originalDatas, o = t.props, s = o.pinchable, l = o.ables; + if (!s) + return !1; + var u = "onPinch".concat(n ? "Group" : "", "Start"), c = "drag".concat(n ? "Group" : "", "ControlStart"), f = (s === !0 ? t.controlAbles : l.filter(function(g) { + return s.indexOf(g.name) > -1; + })).filter(function(g) { + return g.canPinch && g[c]; + }), d = bt(t, e, {}); + n && (d.targets = n); + var p = rt(t, u, d); + r.isPinch = p !== !1, r.ables = f; + var h = r.isPinch; + return h ? (f.forEach(function(g) { + if (i[g.name] = i[g.name] || {}, !!g[c]) { + var x = I(I({}, e), { datas: i[g.name], parentRotate: a, isPinch: !0 }); + g[c](t, x); + } + }), t.state.snapRenderInfo = { + request: e.isRequest, + direction: [0, 0] + }, h) : !1; + }, + pinch: function(t, e) { + var r = e.datas, n = e.scale, a = e.distance, i = e.originalDatas, o = e.inputEvent, s = e.targets, l = e.angle; + if (r.isPinch) { + var u = a * (1 - 1 / n), c = bt(t, e, {}); + s && (c.targets = s); + var f = "onPinch".concat(s ? "Group" : ""); + rt(t, f, c); + var d = r.ables, p = "drag".concat(s ? "Group" : "", "Control"); + return d.forEach(function(h) { + h[p] && h[p](t, I(I({}, e), { datas: i[h.name], inputEvent: o, resolveMatrix: !0, pinchScale: n, parentDistance: u, parentRotate: l, isPinch: !0 })); + }), c; + } + }, + pinchEnd: function(t, e) { + var r = e.datas, n = e.isPinch, a = e.inputEvent, i = e.targets, o = e.originalDatas; + if (r.isPinch) { + var s = "onPinch".concat(i ? "Group" : "", "End"), l = he(t, e, { isDrag: n }); + i && (l.targets = i), rt(t, s, l); + var u = r.ables, c = "drag".concat(i ? "Group" : "", "ControlEnd"); + return u.forEach(function(f) { + f[c] && f[c](t, I(I({}, e), { isDrag: n, datas: o[f.name], inputEvent: a, isPinch: !0 })); + }), n; + } + }, + pinchGroupStart: function(t, e) { + return this.pinchStart(t, I(I({}, e), { targets: t.props.targets })); + }, + pinchGroup: function(t, e) { + return this.pinch(t, I(I({}, e), { targets: t.props.targets })); + }, + pinchGroupEnd: function(t, e) { + return this.pinchEnd(t, I(I({}, e), { targets: t.props.targets })); + } +}), cs = Zi("scalable"), Op = { + name: "scalable", + ableGroup: "size", + canPinch: !0, + props: [ + "scalable", + "throttleScale", + "renderDirections", + "keepRatio", + "edge", + "displayAroundControls" + ], + events: [ + "scaleStart", + "beforeScale", + "scale", + "scaleEnd", + "scaleGroupStart", + "beforeScaleGroup", + "scaleGroup", + "scaleGroupEnd" + ], + render: Tl("scalable"), + dragControlCondition: cs, + viewClassName: Ki("scalable"), + dragControlStart: function(t, e) { + var r = e.datas, n = e.isPinch, a = e.inputEvent, i = e.parentDirection, o = eu(i, n, a, r), s = t.state, l = s.width, u = s.height, c = s.targetTransform, f = s.target, d = s.pos1, p = s.pos2, h = s.pos4; + if (!o || !f) + return !1; + n || fr(t, e), r.datas = {}, r.transform = c, r.prevDist = [1, 1], r.direction = o, r.startOffsetWidth = l, r.startOffsetHeight = u, r.startValue = [1, 1]; + var g = !o[0] && !o[1] || o[0] || !o[1]; + ca(t, e, "scale"), r.isWidth = g; + function x(v) { + r.ratio = v && isFinite(v) ? v : 0; + } + r.startPositions = Ce(t.state); + function y(v) { + var _ = Ll(r.startPositions, v); + r.fixedDirection = _.fixedDirection, r.fixedPosition = _.fixedPosition, r.fixedOffset = _.fixedOffset; + } + r.setFixedDirection = y, x(Re(d, p) / Re(p, h)), y([-o[0], -o[1]]); + var b = function(v) { + r.minScaleSize = v; + }, C = function(v) { + r.maxScaleSize = v; + }; + b([-1 / 0, -1 / 0]), C([1 / 0, 1 / 0]); + var S = bt(t, e, I(I({ direction: o, set: function(v) { + r.startValue = v; + }, setRatio: x, setFixedDirection: y, setMinScaleSize: b, setMaxScaleSize: C }, ua(t, e)), { dragStart: ie.dragStart(t, new Rr().dragStart([0, 0], e)) })), w = rt(t, "onScaleStart", S); + return r.startFixedDirection = r.fixedDirection, w !== !1 && (r.isScale = !0, t.state.snapRenderInfo = { + request: e.isRequest, + direction: o + }), r.isScale ? S : !1; + }, + dragControl: function(t, e) { + sa(t, e, "scale"); + var r = e.datas, n = e.parentKeepRatio, a = e.parentFlag, i = e.isPinch, o = e.dragClient, s = e.isRequest, l = e.useSnap, u = e.resolveMatrix, c = r.prevDist, f = r.direction, d = r.startOffsetWidth, p = r.startOffsetHeight, h = r.isScale, g = r.startValue, x = r.isWidth, y = r.ratio; + if (!h) + return !1; + var b = t.props, C = b.throttleScale, S = b.parentMoveable, w = f; + !f[0] && !f[1] && (w = [1, 1]); + var v = y && (n ?? b.keepRatio) || !1, _ = t.state, M = [ + g[0], + g[1] + ]; + function T() { + var q = su(w, v, r, e), nt = q.distWidth, Et = q.distHeight, pt = d ? (d + nt) / d : 1, vt = p ? (p + Et) / p : 1; + g[0] || (M[0] = nt / d), g[1] || (M[1] = Et / p); + var St = (w[0] || v ? pt : 1) * M[0], _t = (w[1] || v ? vt : 1) * M[1]; + return St === 0 && (St = oe(c[0]) * Tn), _t === 0 && (_t = oe(c[1]) * Tn), [St, _t]; + } + var k = T(); + if (!i && t.props.groupable) { + var A = _.snapRenderInfo || {}, z = A.direction; + Yt(z) && (z[0] || z[1]) && (_.snapRenderInfo = { direction: f, request: e.isRequest }); + } + rt(t, "onBeforeScale", bt(t, e, { + scale: k, + setFixedDirection: function(q) { + return r.setFixedDirection(q), k = T(), k; + }, + startFixedDirection: r.startFixedDirection, + setScale: function(q) { + k = q; + } + }, !0)); + var R = [ + k[0] / M[0], + k[1] / M[1] + ], B = o, N = [0, 0], L = oe(R[0] * R[1]), V = !o && !a && i; + if (V || u ? B = Fi(t, r.targetAllTransform, [0, 0], [0, 0], r) : o || (B = r.fixedPosition), i || (N = cp(t, R, f, !l && s, r)), v) { + w[0] && w[1] && N[0] && N[1] && (Math.abs(N[0] * d) > Math.abs(N[1] * p) ? N[1] = 0 : N[0] = 0); + var G = !N[0] && !N[1]; + if (G && (x ? R[0] = gt(R[0] * M[0], C) / M[0] : R[1] = gt(R[1] * M[1], C) / M[1]), w[0] && !w[1] || N[0] && !N[1] || G && x) { + R[0] += N[0]; + var W = d * R[0] * M[0] / y; + R[1] = oe(L * R[0]) * Y(W / p / M[1]); + } else if (!w[0] && w[1] || !N[0] && N[1] || G && !x) { + R[1] += N[1]; + var $ = p * R[1] * M[1] * y; + R[0] = oe(L * R[1]) * Y($ / d / M[0]); + } + } else + R[0] += N[0], R[1] += N[1], N[0] || (R[0] = gt(R[0] * M[0], C) / M[0]), N[1] || (R[1] = gt(R[1] * M[1], C) / M[1]); + R[0] === 0 && (R[0] = oe(c[0]) * Tn), R[1] === 0 && (R[1] = oe(c[1]) * Tn), k = vp(R, [M[0], M[1]]); + var j = [ + d, + p + ], J = [ + d * k[0], + p * k[1] + ]; + J = ki(J, r.minScaleSize, r.maxScaleSize, v ? y : !1), k = za(2, function(q) { + return j[q] ? J[q] / j[q] : J[q]; + }), R = za(2, function(q) { + return k[q] / M[q]; + }); + var Q = za(2, function(q) { + return c[q] ? R[q] / c[q] : R[q]; + }), H = "scale(".concat(R.join(", "), ")"), tt = "scale(".concat(k.join(", "), ")"), U = la(r, tt, H), et = !g[0] || !g[1], lt = cd(t, et ? tt : H, r.fixedDirection, B, r.fixedOffset, r, et), ft = V ? lt : ct(lt, r.prevInverseDist || [0, 0]); + if (r.prevDist = R, r.prevInverseDist = lt, k[0] === c[0] && k[1] === c[1] && ft.every(function(q) { + return !q; + }) && !S && !V) + return !1; + var xt = bt(t, e, I({ offsetWidth: d, offsetHeight: p, direction: f, scale: k, dist: R, delta: Q, isPinch: !!i }, El(t, U, ft, i, e))); + return rt(t, "onScale", xt), xt; + }, + dragControlEnd: function(t, e) { + var r = e.datas; + if (!r.isScale) + return !1; + r.isScale = !1; + var n = he(t, e, {}); + return rt(t, "onScaleEnd", n), n; + }, + dragGroupControlCondition: cs, + dragGroupControlStart: function(t, e) { + var r = e.datas, n = this.dragControlStart(t, e); + if (!n) + return !1; + var a = Me(t, "resizable", e); + r.moveableScale = t.scale; + var i = je(t, this, "dragControlStart", e, function(u, c) { + return Zn(t, u, r, c); + }), o = function(u) { + n.setFixedDirection(u), i.forEach(function(c, f) { + c.setFixedDirection(u), Zn(t, c.moveable, r, a[f]); + }); + }; + r.setFixedDirection = o; + var s = I(I({}, n), { targets: t.props.targets, events: i, setFixedDirection: o }), l = rt(t, "onScaleGroupStart", s); + return r.isScale = l !== !1, r.isScale ? s : !1; + }, + dragGroupControl: function(t, e) { + var r = e.datas; + if (r.isScale) { + ha(t, "onBeforeScale", function(c) { + rt(t, "onBeforeScaleGroup", bt(t, e, I(I({}, c), { targets: t.props.targets }), !0)); + }); + var n = this.dragControl(t, e); + if (n) { + var a = n.dist, i = r.moveableScale; + t.scale = [ + a[0] * i[0], + a[1] * i[1] + ]; + var o = t.props.keepRatio, s = r.fixedPosition, l = je(t, this, "dragControl", e, function(c, f) { + var d = O(ne(cn(t.rotation / 180 * Math.PI, 3), [ + f.datas.originalX * a[0], + f.datas.originalY * a[1], + 1 + ], 3), 2), p = d[0], h = d[1]; + return I(I({}, f), { + parentDist: null, + parentScale: a, + parentKeepRatio: o, + // recalculate child fixed position for parent group's dragging. + dragClient: wt(s, [p, h]) + }); + }), u = I({ targets: t.props.targets, events: l }, n); + return rt(t, "onScaleGroup", u), u; + } + } + }, + dragGroupControlEnd: function(t, e) { + var r = e.isDrag, n = e.datas; + if (n.isScale) { + this.dragControlEnd(t, e); + var a = je(t, this, "dragControlEnd", e), i = he(t, e, { + targets: t.props.targets, + events: a + }); + return rt(t, "onScaleGroupEnd", i), r; + } + }, + /** + * @method Moveable.Scalable#request + * @param {Moveable.Scalable.ScalableRequestParam} e - the Scalable's request parameter + * @return {Moveable.Requester} Moveable Requester + * @example + + * // Instantly Request (requestStart - request - requestEnd) + * moveable.request("scalable", { deltaWidth: 10, deltaHeight: 10 }, true); + * + * // requestStart + * const requester = moveable.request("scalable"); + * + * // request + * requester.request({ deltaWidth: 10, deltaHeight: 10 }); + * requester.request({ deltaWidth: 10, deltaHeight: 10 }); + * requester.request({ deltaWidth: 10, deltaHeight: 10 }); + * + * // requestEnd + * requester.requestEnd(); + */ + request: function() { + var t = {}, e = 0, r = 0, n = !1; + return { + isControl: !0, + requestStart: function(a) { + return n = a.useSnap, { + datas: t, + parentDirection: a.direction || [1, 1], + useSnap: n + }; + }, + request: function(a) { + return e += a.deltaWidth, r += a.deltaHeight, { + datas: t, + parentDist: [e, r], + parentKeepRatio: a.keepRatio, + useSnap: n + }; + }, + requestEnd: function() { + return { datas: t, isDrag: !0, useSnap: n }; + } + }; + } +}; +function Ye(t, e) { + return t.map(function(r, n) { + return Hn(r, e[n], 1, 2); + }); +} +function fs(t, e, r) { + var n = Xt(t, e), a = Xt(t, r), i = a - n; + return i >= 0 ? i : i + 2 * Math.PI; +} +function zp(t, e) { + var r = fs(t[0], t[1], t[2]), n = fs(e[0], e[1], e[2]), a = Math.PI; + return !(r >= a && n <= a || r <= a && n >= a); +} +var Ap = { + name: "warpable", + ableGroup: "size", + props: [ + "warpable", + "renderDirections", + "edge", + "displayAroundControls" + ], + events: [ + "warpStart", + "warp", + "warpEnd" + ], + viewClassName: Ki("warpable"), + render: function(t, e) { + var r = t.props, n = r.resizable, a = r.scalable, i = r.warpable, o = r.zoom; + if (n || a || !i) + return []; + var s = t.state, l = s.pos1, u = s.pos2, c = s.pos3, f = s.pos4, d = Ye(l, u), p = Ye(u, l), h = Ye(l, c), g = Ye(c, l), x = Ye(c, f), y = Ye(f, c), b = Ye(u, f), C = Ye(f, u); + return Z([ + e.createElement("div", { className: ut("line"), key: "middeLine1", style: $r(d, x, o) }), + e.createElement("div", { className: ut("line"), key: "middeLine2", style: $r(p, y, o) }), + e.createElement("div", { className: ut("line"), key: "middeLine3", style: $r(h, b, o) }), + e.createElement("div", { className: ut("line"), key: "middeLine4", style: $r(g, C, o) }) + ], O(Il(t, "warpable", e)), !1); + }, + dragControlCondition: function(t, e) { + if (e.isRequest) + return !1; + var r = e.inputEvent.target; + return Kt(r, ut("direction")) && Kt(r, ut("warpable")); + }, + dragControlStart: function(t, e) { + var r = e.datas, n = e.inputEvent, a = t.props.target, i = n.target, o = ru(i, r); + if (!o || !a) + return !1; + var s = t.state, l = s.transformOrigin, u = s.is3d, c = s.targetTransform, f = s.targetMatrix, d = s.width, p = s.height, h = s.left, g = s.top; + r.datas = {}, r.targetTransform = c, r.warpTargetMatrix = u ? f : Te(f, 3, 4), r.targetInverseMatrix = nl(ke(r.warpTargetMatrix, 4), 3, 4), r.direction = o, r.left = h, r.top = g, r.poses = [ + [0, 0], + [d, 0], + [0, p], + [d, p] + ].map(function(b) { + return ct(b, l); + }), r.nextPoses = r.poses.map(function(b) { + var C = O(b, 2), S = C[0], w = C[1]; + return ne(r.warpTargetMatrix, [S, w, 0, 1], 4); + }), r.startValue = At(4), r.prevMatrix = At(4), r.absolutePoses = Ce(s), r.posIndexes = Cl(o), fr(t, e), ca(t, e, "matrix3d"), s.snapRenderInfo = { + request: e.isRequest, + direction: o + }; + var x = bt(t, e, I({ set: function(b) { + r.startValue = b; + } }, ua(t, e))), y = rt(t, "onWarpStart", x); + return y !== !1 && (r.isWarp = !0), r.isWarp; + }, + dragControl: function(t, e) { + var r = e.datas, n = e.isRequest, a = e.distX, i = e.distY, o = r.targetInverseMatrix, s = r.prevMatrix, l = r.isWarp, u = r.startValue, c = r.poses, f = r.posIndexes, d = r.absolutePoses; + if (!l) + return !1; + if (sa(t, e, "matrix3d"), Gr(t, "warpable")) { + var p = f.map(function(T) { + return d[T]; + }); + p.length > 1 && p.push([ + (p[0][0] + p[1][0]) / 2, + (p[0][1] + p[1][1]) / 2 + ]); + var h = pa(t, n, { + horizontal: p.map(function(T) { + return T[1] + i; + }), + vertical: p.map(function(T) { + return T[0] + a; + }) + }), g = h.horizontal, x = h.vertical; + i -= g.offset, a -= x.offset; + } + var y = Oe({ datas: r, distX: a, distY: i }, !0), b = r.nextPoses.slice(); + if (f.forEach(function(T) { + b[T] = wt(b[T], y); + }), !Qf.every(function(T) { + return zp(T.map(function(k) { + return c[k]; + }), T.map(function(k) { + return b[k]; + })); + })) + return !1; + var C = Pi(c[0], c[2], c[1], c[3], b[0], b[2], b[1], b[3]); + if (!C.length) + return !1; + var S = Pt(o, C, 4), w = bl(r, S, !0), v = Pt(ke(s, 4), w, 4); + r.prevMatrix = w; + var _ = Pt(u, w, 4), M = la(r, "matrix3d(".concat(_.join(", "), ")"), "matrix3d(".concat(w.join(", "), ")")); + return Gi(e, M), rt(t, "onWarp", bt(t, e, I({ delta: v, matrix: _, dist: w, multiply: Pt, transform: M }, se({ + transform: M + }, e)))), !0; + }, + dragControlEnd: function(t, e) { + var r = e.datas, n = e.isDrag; + return r.isWarp ? (r.isWarp = !1, rt(t, "onWarpEnd", he(t, e, {})), n) : !1; + } +}, Np = /* @__PURE__ */ ut("area-pieces"), An = /* @__PURE__ */ ut("area-piece"), cu = /* @__PURE__ */ ut("avoid"), Bp = ut("view-dragging"); +function Aa(t) { + var e = t.areaElement; + if (e) { + var r = t.state, n = r.width, a = r.height; + el(e, cu), e.style.cssText += "left: 0px; top: 0px; width: ".concat(n, "px; height: ").concat(a, "px"); + } +} +function ds(t) { + return t.createElement( + "div", + { key: "area_pieces", className: Np }, + t.createElement("div", { className: An }), + t.createElement("div", { className: An }), + t.createElement("div", { className: An }), + t.createElement("div", { className: An }) + ); +} +var fu = { + name: "dragArea", + props: [ + "dragArea", + "passDragArea" + ], + events: [ + "click", + "clickGroup" + ], + render: function(t, e) { + var r = t.props, n = r.target, a = r.dragArea, i = r.groupable, o = r.passDragArea, s = t.getState(), l = s.width, u = s.height, c = s.renderPoses, f = o ? ut("area", "pass") : ut("area"); + if (i) + return [ + e.createElement("div", { key: "area", ref: qe(t, "areaElement"), className: f }), + ds(e) + ]; + if (!n || !a) + return []; + var d = Pi([0, 0], [l, 0], [0, u], [l, u], c[0], c[1], c[2], c[3]), p = d.length ? va(d, !0) : "none"; + return [ + e.createElement("div", { key: "area", ref: qe(t, "areaElement"), className: f, style: { + top: "0px", + left: "0px", + width: "".concat(l, "px"), + height: "".concat(u, "px"), + transformOrigin: "0 0", + transform: p + } }), + ds(e) + ]; + }, + dragStart: function(t, e) { + var r = e.datas, n = e.clientX, a = e.clientY, i = e.inputEvent; + if (!i) + return !1; + r.isDragArea = !1; + var o = t.areaElement, s = t.state, l = s.moveableClientRect, u = s.renderPoses, c = s.rootMatrix, f = s.is3d, d = l.left, p = l.top, h = ye(u), g = h.left, x = h.top, y = h.width, b = h.height, C = f ? 4 : 3, S = O(zr(c, [n - d, a - p], C), 2), w = S[0], v = S[1]; + w -= g, v -= x; + var _ = [ + { left: g, top: x, width: y, height: v - 10 }, + { left: g, top: x, width: w - 10, height: b }, + { left: g, top: x + v + 10, width: y, height: b - v - 10 }, + { left: g + w + 10, top: x, width: y - w - 10, height: b } + ], M = [].slice.call(o.nextElementSibling.children); + _.forEach(function(T, k) { + M[k].style.cssText = "left: ".concat(T.left, "px;top: ").concat(T.top, "px; width: ").concat(T.width, "px; height: ").concat(T.height, "px;"); + }), Ti(o, cu), s.disableNativeEvent = !0; + }, + drag: function(t, e) { + var r = e.datas, n = e.inputEvent; + if (this.enableNativeEvent(t), !n) + return !1; + r.isDragArea || (r.isDragArea = !0, Aa(t)); + }, + dragEnd: function(t, e) { + this.enableNativeEvent(t); + var r = e.inputEvent, n = e.datas; + if (!r) + return !1; + n.isDragArea || Aa(t); + }, + dragGroupStart: function(t, e) { + return this.dragStart(t, e); + }, + dragGroup: function(t, e) { + return this.drag(t, e); + }, + dragGroupEnd: function(t, e) { + return this.dragEnd(t, e); + }, + unset: function(t) { + Aa(t), t.state.disableNativeEvent = !1; + }, + enableNativeEvent: function(t) { + var e = t.state; + e.disableNativeEvent && tl(function() { + e.disableNativeEvent = !1; + }); + } +}, jp = pn("origin", { + props: ["origin", "svgOrigin"], + render: function(t, e) { + var r = t.props, n = r.zoom, a = r.svgOrigin, i = r.groupable, o = t.getState(), s = o.beforeOrigin, l = o.rotation, u = o.svg, c = o.allMatrix, f = o.is3d, d = o.left, p = o.top, h = o.offsetWidth, g = o.offsetHeight, x; + if (!i && u && a) { + var y = O(Qi(a, h, g), 2), b = y[0], C = y[1], S = f ? 4 : 3, w = Gt(c, [b, C], S); + x = ea(l, n, ct(w, [d, p])); + } else + x = ea(l, n, s); + return [ + e.createElement("div", { className: ut("control", "origin"), style: x, key: "beforeOrigin" }) + ]; + } +}); +function Gp(t) { + var e = t.scrollContainer; + return [ + e.scrollLeft, + e.scrollTop + ]; +} +var Fp = { + name: "scrollable", + canPinch: !0, + props: [ + "scrollable", + "scrollContainer", + "scrollThreshold", + "scrollThrottleTime", + "getScrollPosition", + "scrollOptions" + ], + events: [ + "scroll", + "scrollGroup" + ], + dragRelation: "strong", + dragStart: function(t, e) { + var r = t.props, n = r.scrollContainer, a = n === void 0 ? t.getContainer() : n, i = r.scrollOptions, o = new ll(), s = Pe(a, !0); + e.datas.dragScroll = o, t.state.dragScroll = o; + var l = e.isControl ? "controlGesto" : "targetGesto", u = e.targets; + o.on("scroll", function(c) { + var f = c.container, d = c.direction, p = bt(t, e, { + scrollContainer: f, + direction: d + }), h = u ? "onScrollGroup" : "onScroll"; + u && (p.targets = u), rt(t, h, p); + }).on("move", function(c) { + var f = c.offsetX, d = c.offsetY, p = c.inputEvent; + t[l].scrollBy(f, d, p.inputEvent, !1); + }).on("scrollDrag", function(c) { + var f = c.next; + f(t[l].getCurrentEvent()); + }), o.dragStart(e, I({ container: s }, i)); + }, + checkScroll: function(t, e) { + var r = e.datas.dragScroll; + if (r) { + var n = t.props, a = n.scrollContainer, i = a === void 0 ? t.getContainer() : a, o = n.scrollThreshold, s = o === void 0 ? 0 : o, l = n.scrollThrottleTime, u = l === void 0 ? 0 : l, c = n.getScrollPosition, f = c === void 0 ? Gp : c, d = n.scrollOptions; + return r.drag(e, I({ container: i, threshold: s, throttleTime: u, getScrollPosition: function(p) { + return f({ scrollContainer: p.container, direction: p.direction }); + } }, d)), !0; + } + }, + drag: function(t, e) { + return this.checkScroll(t, e); + }, + dragEnd: function(t, e) { + e.datas.dragScroll.dragEnd(), e.datas.dragScroll = null; + }, + dragControlStart: function(t, e) { + return this.dragStart(t, I(I({}, e), { isControl: !0 })); + }, + dragControl: function(t, e) { + return this.drag(t, e); + }, + dragControlEnd: function(t, e) { + return this.dragEnd(t, e); + }, + dragGroupStart: function(t, e) { + return this.dragStart(t, I(I({}, e), { targets: t.props.targets })); + }, + dragGroup: function(t, e) { + return this.drag(t, I(I({}, e), { targets: t.props.targets })); + }, + dragGroupEnd: function(t, e) { + return this.dragEnd(t, I(I({}, e), { targets: t.props.targets })); + }, + dragGroupControlStart: function(t, e) { + return this.dragStart(t, I(I({}, e), { targets: t.props.targets, isControl: !0 })); + }, + dragGroupControl: function(t, e) { + return this.drag(t, I(I({}, e), { targets: t.props.targets })); + }, + dragGroupControEnd: function(t, e) { + return this.dragEnd(t, I(I({}, e), { targets: t.props.targets })); + }, + unset: function(t) { + var e, r = t.state; + (e = r.dragScroll) === null || e === void 0 || e.dragEnd(), r.dragScroll = null; + } +}, du = { + name: "", + props: [ + "target", + "dragTargetSelf", + "dragTarget", + "dragContainer", + "container", + "warpSelf", + "rootContainer", + "useResizeObserver", + "useMutationObserver", + "zoom", + "dragFocusedInput", + "transformOrigin", + "ables", + "className", + "pinchThreshold", + "pinchOutside", + "triggerAblesSimultaneously", + "checkInput", + "cspNonce", + "translateZ", + "hideDefaultLines", + "props", + "flushSync", + "stopPropagation", + "preventClickEventOnDrag", + "preventClickDefault", + "viewContainer", + "persistData", + "useAccuratePosition", + "firstRenderState", + "linePadding", + "controlPadding", + "preventDefault", + "preventRightClick", + "preventWheelClick", + "requestStyles" + ], + events: [ + "changeTargets" + ] +}, Lp = pn("padding", { + props: ["padding"], + render: function(t, e) { + var r = t.props; + if (r.dragArea) + return []; + var n = uu(r.padding || {}), a = n.left, i = n.top, o = n.right, s = n.bottom, l = t.getState(), u = l.renderPoses, c = l.pos1, f = l.pos2, d = l.pos3, p = l.pos4, h = [c, f, d, p], g = []; + return a > 0 && g.push([0, 2]), i > 0 && g.push([0, 1]), o > 0 && g.push([1, 3]), s > 0 && g.push([2, 3]), g.map(function(x, y) { + var b = O(x, 2), C = b[0], S = b[1], w = h[C], v = h[S], _ = u[C], M = u[S], T = Pi([0, 0], [100, 0], [0, 100], [100, 100], w, v, _, M); + if (T.length) + return e.createElement("div", { key: "padding".concat(y), className: ut("padding"), style: { + transform: va(T, !0) + } }); + }); + } +}), ps = ["nw", "ne", "se", "sw"]; +function Nn(t, e) { + var r = t[0] + t[1], n = r > e ? e / r : 1; + return t[0] *= n, t[1] = e - t[1] * n, t; +} +var Wp = [1, 2, 5, 6], Yp = [0, 3, 4, 7], nr = [1, -1, -1, 1], ar = [1, 1, -1, -1]; +function to(t, e, r, n, a, i, o, s) { + a === void 0 && (a = 0), i === void 0 && (i = 0), o === void 0 && (o = r), s === void 0 && (s = n); + var l = [], u = !1, c = t.filter(function(d) { + return !d.virtual; + }), f = c.map(function(d) { + var p = d.horizontal, h = d.vertical, g = d.pos; + if (h && !u && (u = !0, l.push("/")), u) { + var x = Math.max(0, h === 1 ? g[1] - i : s - g[1]); + return l.push(we(x, n, e)), x; + } else { + var x = Math.max(0, p === 1 ? g[0] - a : o - g[0]); + return l.push(we(x, r, e)), x; + } + }); + return { + radiusPoses: c, + styles: l, + raws: f + }; +} +function pu(t) { + for (var e = [0, 0], r = [0, 0], n = t.length, a = 0; a < n; ++a) { + var i = t[a]; + i.sub && (i.horizontal && (e[1] === 0 && (e[0] = a), e[1] = a - e[0] + 1, r[0] = a + 1), i.vertical && (r[1] === 0 && (r[0] = a), r[1] = a - r[0] + 1)); + } + return { + horizontalRange: e, + verticalRange: r + }; +} +function vu(t, e, r, n, a, i, o) { + var s, l, u, c; + i === void 0 && (i = [0, 0]), o === void 0 && (o = !1); + var f = t.indexOf("/"), d = (f > -1 ? t.slice(0, f) : t).length, p = t.slice(0, d), h = t.slice(d + 1), g = p.length, x = h.length, y = x > 0, b = O(p, 4), C = b[0], S = C === void 0 ? "0px" : C, w = b[1], v = w === void 0 ? S : w, _ = b[2], M = _ === void 0 ? S : _, T = b[3], k = T === void 0 ? v : T, A = O(h, 4), z = A[0], R = z === void 0 ? S : z, B = A[1], N = B === void 0 ? y ? R : v : B, L = A[2], V = L === void 0 ? y ? R : M : L, G = A[3], W = G === void 0 ? y ? N : k : G, $ = [S, v, M, k].map(function(U) { + return Rt(U, e); + }), j = [R, N, V, W].map(function(U) { + return Rt(U, r); + }), J = $.slice(), Q = j.slice(); + s = O(Nn([J[0], J[1]], e), 2), J[0] = s[0], J[1] = s[1], l = O(Nn([J[3], J[2]], e), 2), J[3] = l[0], J[2] = l[1], u = O(Nn([Q[0], Q[3]], r), 2), Q[0] = u[0], Q[3] = u[1], c = O(Nn([Q[1], Q[2]], r), 2), Q[1] = c[0], Q[2] = c[1]; + var H = o ? J : J.slice(0, Math.max(i[0], g)), tt = o ? Q : Q.slice(0, Math.max(i[1], x)); + return Z(Z([], O(H.map(function(U, et) { + var lt = ps[et]; + return { + virtual: et >= g, + horizontal: nr[et], + vertical: 0, + pos: [n + U, a + (ar[et] === -1 ? r : 0)], + sub: !0, + raw: $[et], + direction: lt + }; + })), !1), O(tt.map(function(U, et) { + var lt = ps[et]; + return { + virtual: et >= x, + horizontal: 0, + vertical: ar[et], + pos: [n + (nr[et] === -1 ? e : 0), a + U], + sub: !0, + raw: j[et], + direction: lt + }; + })), !1); +} +function Xp(t, e, r, n, a) { + a === void 0 && (a = e.length); + var i = pu(t.slice(n)), o = i.horizontalRange, s = i.verticalRange, l = r - n, u = 0; + if (l === 0) + u = a; + else if (l > 0 && l < o[1]) + u = o[1] - l; + else if (l >= s[0]) + u = s[0] + s[1] - l; + else + return; + t.splice(r, u), e.splice(r, u); +} +function Hp(t, e, r, n, a, i, o, s, l, u, c) { + u === void 0 && (u = 0), c === void 0 && (c = 0); + var f = pu(t.slice(r)), d = f.horizontalRange, p = f.verticalRange; + if (n > -1) + for (var h = nr[n] === 1 ? i - u : s - i, g = d[1]; g <= n; ++g) { + var x = ar[g] === 1 ? c : l, y = 0; + if (n === g ? y = i : g === 0 ? y = u + h : nr[g] === -1 && (y = s - (e[r][0] - u)), t.splice(r + g, 0, { + horizontal: nr[g], + vertical: 0, + pos: [y, x] + }), e.splice(r + g, 0, [y, x]), g === 0) + break; + } + else if (a > -1) { + var b = ar[a] === 1 ? o - c : l - o; + if (d[1] === 0 && p[1] === 0) { + var C = [ + u + b, + c + ]; + t.push({ + horizontal: nr[0], + vertical: 0, + pos: C + }), e.push(C); + } + for (var S = p[0], g = p[1]; g <= a; ++g) { + var y = nr[g] === 1 ? u : s, x = 0; + if (a === g ? x = o : g === 0 ? x = c + b : ar[g] === 1 ? x = e[r + S][1] : ar[g] === -1 && (x = l - (e[r + S][1] - c)), t.push({ + horizontal: 0, + vertical: ar[g], + pos: [y, x] + }), e.push([y, x]), g === 0) + break; + } + } +} +function qp(t, e) { + e === void 0 && (e = t.map(function(a) { + return a.raw; + })); + var r = t.map(function(a, i) { + return a.horizontal ? e[i] : null; + }).filter(function(a) { + return a != null; + }), n = t.map(function(a, i) { + return a.vertical ? e[i] : null; + }).filter(function(a) { + return a != null; + }); + return { + horizontals: r, + verticals: n + }; +} +var Vp = [ + [0, -1, "n"], + [1, 0, "e"] +], $p = [ + [-1, -1, "nw"], + [0, -1, "n"], + [1, -1, "ne"], + [1, 0, "e"], + [1, 1, "se"], + [0, 1, "s"], + [-1, 1, "sw"], + [-1, 0, "w"] +]; +function eo(t, e, r) { + var n = t.props.clipRelative, a = t.state, i = a.width, o = a.height, s = e, l = s.type, u = s.poses, c = l === "rect", f = l === "circle"; + if (l === "polygon") + return r.map(function(v) { + return "".concat(we(v[0], i, n), " ").concat(we(v[1], o, n)); + }); + if (c || l === "inset") { + var d = r[1][1], p = r[3][0], h = r[7][0], g = r[5][1]; + if (c) + return [ + d, + p, + g, + h + ].map(function(v) { + return "".concat(v, "px"); + }); + var x = [d, i - p, o - g, h].map(function(v, _) { + return we(v, _ % 2 ? i : o, n); + }); + if (r.length > 8) { + var y = O(ct(r[4], r[0]), 2), b = y[0], C = y[1]; + x.push.apply(x, Z(["round"], O(to(u.slice(8).map(function(v, _) { + return I(I({}, v), { pos: r[_] }); + }), n, b, C, h, d, p, g).styles), !1)); + } + return x; + } else if (f || l === "ellipse") { + var S = r[0], w = we(Y(r[1][1] - S[1]), f ? Math.sqrt((i * i + o * o) / 2) : o, n), x = f ? [w] : [we(Y(r[2][0] - S[0]), i, n), w]; + return x.push("at", we(S[0], i, n), we(S[1], o, n)), x; + } +} +function na(t, e, r, n) { + var a = [n, (n + e) / 2, e], i = [t, (t + r) / 2, r]; + return $p.map(function(o) { + var s = O(o, 3), l = s[0], u = s[1], c = s[2], f = a[l + 1], d = i[u + 1]; + return { + vertical: Y(u), + horizontal: Y(l), + direction: c, + pos: [f, d] + }; + }); +} +function hu(t) { + var e = [1 / 0, -1 / 0], r = [1 / 0, -1 / 0]; + return t.forEach(function(n) { + var a = n.pos; + e[0] = Math.min(e[0], a[0]), e[1] = Math.max(e[1], a[0]), r[0] = Math.min(r[0], a[1]), r[1] = Math.max(r[1], a[1]); + }), [ + Y(e[1] - e[0]), + Y(r[1] - r[0]) + ]; +} +function vs(t, e, r, n, a) { + var i, o, s, l, u, c, f, d, p; + if (t) { + var h = a; + if (!h) { + var g = de(t), x = g("clipPath"); + h = x !== "none" ? x : g("clip"); + } + if (!((!h || h === "none" || h === "auto") && (h = n, !h))) { + var y = Qs(h), b = y.prefix, C = b === void 0 ? h : b, S = y.value, w = S === void 0 ? "" : S, v = C === "circle", _ = " "; + if (C === "polygon") { + var M = ir(w || "0% 0%, 100% 0%, 100% 100%, 0% 100%"); + _ = ","; + var T = M.map(function(Bt) { + var Zt = O(Bt.split(" "), 2), jt = Zt[0], Ft = Zt[1]; + return { + vertical: 1, + horizontal: 1, + pos: [ + Rt(jt, e), + Rt(Ft, r) + ] + }; + }), k = ur(T.map(function(Bt) { + return Bt.pos; + })); + return { + type: C, + clipText: h, + poses: T, + splitter: _, + left: k.minX, + right: k.maxX, + top: k.minY, + bottom: k.maxY + }; + } else if (v || C === "ellipse") { + var A = "", z = "", R = 0, B = 0, M = Ve(w); + if (v) { + var N = ""; + i = O(M, 4), o = i[0], N = o === void 0 ? "50%" : o, s = i[2], A = s === void 0 ? "50%" : s, l = i[3], z = l === void 0 ? "50%" : l, R = Rt(N, Math.sqrt((e * e + r * r) / 2)), B = R; + } else { + var L = "", V = ""; + u = O(M, 5), c = u[0], L = c === void 0 ? "50%" : c, f = u[1], V = f === void 0 ? "50%" : f, d = u[3], A = d === void 0 ? "50%" : d, p = u[4], z = p === void 0 ? "50%" : p, R = Rt(L, e), B = Rt(V, r); + } + var G = [ + Rt(A, e), + Rt(z, r) + ], T = Z([ + { + vertical: 1, + horizontal: 1, + pos: G, + direction: "nesw" + } + ], O(Vp.slice(0, v ? 1 : 2).map(function(jt) { + return { + vertical: Y(jt[1]), + horizontal: jt[0], + direction: jt[2], + sub: !0, + pos: [ + G[0] + jt[0] * R, + G[1] + jt[1] * B + ] + }; + })), !1); + return { + type: C, + clipText: h, + radiusX: R, + radiusY: B, + left: G[0] - R, + top: G[1] - B, + right: G[0] + R, + bottom: G[1] + B, + poses: T, + splitter: _ + }; + } else if (C === "inset") { + var M = Ve(w || "0 0 0 0"), W = M.indexOf("round"), $ = (W > -1 ? M.slice(0, W) : M).length, j = M.slice($ + 1), J = O(M.slice(0, $), 4), Q = J[0], H = J[1], tt = H === void 0 ? Q : H, U = J[2], et = U === void 0 ? Q : U, lt = J[3], ft = lt === void 0 ? tt : lt, xt = O([Q, et].map(function(jt) { + return Rt(jt, r); + }), 2), q = xt[0], nt = xt[1], Et = O([ft, tt].map(function(jt) { + return Rt(jt, e); + }), 2), pt = Et[0], vt = Et[1], St = e - vt, _t = r - nt, Mt = vu(j, St - pt, _t - q, pt, q), T = Z(Z([], O(na(q, St, _t, pt)), !1), O(Mt), !1); + return { + type: "inset", + clipText: h, + poses: T, + top: q, + left: pt, + right: St, + bottom: _t, + radius: j, + splitter: _ + }; + } else if (C === "rect") { + var M = ir(w || "0px, ".concat(e, "px, ").concat(r, "px, 0px")); + _ = ","; + var ht = O(M.map(function(kt) { + var Ee = or(kt).value; + return Ee; + }), 4), Dt = ht[0], vt = ht[1], nt = ht[2], pt = ht[3], T = na(Dt, vt, nt, pt); + return { + type: "rect", + clipText: h, + poses: T, + top: Dt, + right: vt, + bottom: nt, + left: pt, + values: M, + splitter: _ + }; + } + } + } +} +function Up(t, e, r, n, a) { + var i = t[e], o = i.direction, s = i.sub, l = t.map(function() { + return [0, 0]; + }), u = o ? o.split("") : []; + if (n && e < 8) { + var c = u.filter(function(R) { + return R === "w" || R === "e"; + }), f = u.filter(function(R) { + return R === "n" || R === "s"; + }), d = c[0], p = f[0]; + l[e] = r; + var h = O(hu(t), 2), g = h[0], x = h[1], y = g && x ? g / x : 0; + if (y && a) { + var b = (e + 4) % 8, C = t[b].pos, S = [0, 0]; + o.indexOf("w") > -1 ? S[0] = -1 : o.indexOf("e") > -1 && (S[0] = 1), o.indexOf("n") > -1 ? S[1] = -1 : o.indexOf("s") > -1 && (S[1] = 1); + var w = ou([g, x], r, y, S, !0), v = g + w[0], _ = x + w[1], M = C[1], T = C[1], k = C[0], A = C[0]; + S[0] === -1 ? k = A - v : S[0] === 1 ? A = k + v : (k = k - v / 2, A = A + v / 2), S[1] === -1 ? M = T - _ : (S[1] === 1 || (M = T - _ / 2), T = M + _); + var z = na(M, A, T, k); + t.forEach(function(R, B) { + l[B][0] = z[B].pos[0] - R.pos[0], l[B][1] = z[B].pos[1] - R.pos[1]; + }); + } else + t.forEach(function(R, B) { + var N = R.direction; + N && (N.indexOf(d) > -1 && (l[B][0] = r[0]), N.indexOf(p) > -1 && (l[B][1] = r[1])); + }), d && (l[1][0] = r[0] / 2, l[5][0] = r[0] / 2), p && (l[3][1] = r[1] / 2, l[7][1] = r[1] / 2); + } else o && !s ? u.forEach(function(R) { + var B = R === "n" || R === "s"; + t.forEach(function(N, L) { + var V = N.direction, G = N.horizontal, W = N.vertical; + !V || V.indexOf(R) === -1 || (l[L] = [ + B || !G ? 0 : r[0], + !B || !W ? 0 : r[1] + ]); + }); + }) : l[e] = r; + return l; +} +function Kp(t, e) { + var r = O(yl(t, e), 2), n = r[0], a = r[1], i = e.datas, o = i.clipPath, s = i.clipIndex, l = o, u = l.type, c = l.poses, f = l.splitter, d = c.map(function(b) { + return b.pos; + }); + if (u === "polygon") + d.splice(s, 0, [n, a]); + else if (u === "inset") { + var p = Wp.indexOf(s), h = Yp.indexOf(s), g = c.length; + if (Hp(c, d, 8, p, h, n, a, d[4][0], d[4][1], d[0][0], d[0][1]), g === c.length) + return; + } else + return; + var x = eo(t, o, d), y = "".concat(u, "(").concat(x.join(f), ")"); + rt(t, "onClip", bt(t, e, I({ clipEventType: "added", clipType: u, poses: d, clipStyles: x, clipStyle: y, distX: 0, distY: 0 }, se({ + clipPath: y + }, e)))); +} +function Zp(t, e) { + var r = e.datas, n = r.clipPath, a = r.clipIndex, i = n, o = i.type, s = i.poses, l = i.splitter, u = s.map(function(p) { + return p.pos; + }), c = u.length; + if (o === "polygon") + s.splice(a, 1), u.splice(a, 1); + else if (o === "inset") { + if (a < 8 || (Xp(s, u, a, 8, c), c === s.length)) + return; + } else + return; + var f = eo(t, n, u), d = "".concat(o, "(").concat(f.join(l), ")"); + rt(t, "onClip", bt(t, e, I({ clipEventType: "removed", clipType: o, poses: u, clipStyles: f, clipStyle: d, distX: 0, distY: 0 }, se({ + clipPath: d + }, e)))); +} +var Jp = { + name: "clippable", + props: [ + "clippable", + "defaultClipPath", + "customClipPath", + "keepRatio", + "clipRelative", + "clipArea", + "dragWithClip", + "clipTargetBounds", + "clipVerticalGuidelines", + "clipHorizontalGuidelines", + "clipSnapThreshold" + ], + events: [ + "clipStart", + "clip", + "clipEnd" + ], + css: [ + `.control.clip-control { +background: #6d6; +cursor: pointer; +} +.control.clip-control.clip-radius { +background: #d66; +} +.line.clip-line { +background: #6e6; +cursor: move; +z-index: 1; +} +.clip-area { +position: absolute; +top: 0; +left: 0; +} +.clip-ellipse { +position: absolute; +cursor: move; +border: 1px solid #6d6; +border: var(--zoompx) solid #6d6; +border-radius: 50%; +transform-origin: 0px 0px; +}`, + `:host { +--bounds-color: #d66; +}`, + `.guideline { +pointer-events: none; +z-index: 2; +}`, + `.line.guideline.bounds { +background: #d66; +background: var(--bounds-color); +}` + ], + render: function(t, e) { + var r = t.props, n = r.customClipPath, a = r.defaultClipPath, i = r.clipArea, o = r.zoom, s = r.groupable, l = t.getState(), u = l.target, c = l.width, f = l.height, d = l.allMatrix, p = l.is3d, h = l.left, g = l.top, x = l.pos1, y = l.pos2, b = l.pos3, C = l.pos4, S = l.clipPathState, w = l.snapBoundInfos, v = l.rotation; + if (!u || s) + return []; + var _ = vs(u, c, f, a || "inset", S || n); + if (!_) + return []; + var M = p ? 4 : 3, T = _.type, k = _.poses, A = k.map(function(vt) { + var St = Gt(d, vt.pos, M); + return [ + St[0] - h, + St[1] - g + ]; + }), z = [], R = [], B = T === "rect", N = T === "inset", L = T === "polygon"; + if (B || N || L) { + var V = N ? A.slice(0, 8) : A; + R = V.map(function(vt, St) { + var _t = St === 0 ? V[V.length - 1] : V[St - 1], Mt = Xt(_t, vt), ht = Zl(_t, vt); + return e.createElement("div", { key: "clipLine".concat(St), className: ut("line", "clip-line", "snap-control"), "data-clip-index": St, style: { + width: "".concat(ht, "px"), + transform: "translate(".concat(_t[0], "px, ").concat(_t[1], "px) rotate(").concat(Mt, "rad) scaleY(").concat(o, ")") + } }); + }); + } + if (z = A.map(function(vt, St) { + return e.createElement("div", { key: "clipControl".concat(St), className: ut("control", "clip-control", "snap-control"), "data-clip-index": St, style: { + transform: "translate(".concat(vt[0], "px, ").concat(vt[1], "px) rotate(").concat(v, "rad) scale(").concat(o, ")") + } }); + }), N && z.push.apply(z, Z([], O(A.slice(8).map(function(vt, St) { + return e.createElement("div", { key: "clipRadiusControl".concat(St), className: ut("control", "clip-control", "clip-radius", "snap-control"), "data-clip-index": 8 + St, style: { + transform: "translate(".concat(vt[0], "px, ").concat(vt[1], "px) rotate(").concat(v, "rad) scale(").concat(o, ")") + } }); + })), !1)), T === "circle" || T === "ellipse") { + var G = _.left, W = _.top, $ = _.radiusX, j = _.radiusY, J = O(ct(Gt(d, [G, W], M), Gt(d, [0, 0], M)), 2), Q = J[0], H = J[1], tt = "none"; + if (!i) { + for (var U = Math.max(10, $ / 5, j / 5), et = [], lt = 0; lt <= U; ++lt) { + var ft = Math.PI * 2 / U * lt; + et.push([ + $ + ($ - o) * Math.cos(ft), + j + (j - o) * Math.sin(ft) + ]); + } + et.push([$, -2]), et.push([-2, -2]), et.push([-2, j * 2 + 2]), et.push([$ * 2 + 2, j * 2 + 2]), et.push([$ * 2 + 2, -2]), et.push([$, -2]), tt = "polygon(".concat(et.map(function(vt) { + return "".concat(vt[0], "px ").concat(vt[1], "px"); + }).join(", "), ")"); + } + z.push(e.createElement("div", { key: "clipEllipse", className: ut("clip-ellipse", "snap-control"), style: { + width: "".concat($ * 2, "px"), + height: "".concat(j * 2, "px"), + clipPath: tt, + transform: "translate(".concat(-h + Q, "px, ").concat(-g + H, "px) ").concat(va(d)) + } })); + } + if (i) { + var xt = ye(Z([x, y, b, C], O(A), !1)), q = xt.width, nt = xt.height, Et = xt.left, pt = xt.top; + if (L || B || N) { + var et = N ? A.slice(0, 8) : A; + z.push(e.createElement("div", { key: "clipArea", className: ut("clip-area", "snap-control"), style: { + width: "".concat(q, "px"), + height: "".concat(nt, "px"), + transform: "translate(".concat(Et, "px, ").concat(pt, "px)"), + clipPath: "polygon(".concat(et.map(function(St) { + return "".concat(St[0] - Et, "px ").concat(St[1] - pt, "px"); + }).join(", "), ")") + } })); + } + } + return w && ["vertical", "horizontal"].forEach(function(vt) { + var St = w[vt], _t = vt === "horizontal"; + St.isSnap && R.push.apply(R, Z([], O(St.snap.posInfos.map(function(Mt, ht) { + var Dt = Mt.pos, Bt = ct(Gt(d, _t ? [0, Dt] : [Dt, 0], M), [h, g]), Zt = ct(Gt(d, _t ? [c, Dt] : [Dt, f], M), [h, g]); + return sn(e, "", Bt, Zt, o, "clip".concat(vt, "snap").concat(ht), "guideline"); + })), !1)), St.isBound && R.push.apply(R, Z([], O(St.bounds.map(function(Mt, ht) { + var Dt = Mt.pos, Bt = ct(Gt(d, _t ? [0, Dt] : [Dt, 0], M), [h, g]), Zt = ct(Gt(d, _t ? [c, Dt] : [Dt, f], M), [h, g]); + return sn(e, "", Bt, Zt, o, "clip".concat(vt, "bounds").concat(ht), "guideline", "bounds", "bold"); + })), !1)); + }), Z(Z([], O(z), !1), O(R), !1); + }, + dragControlCondition: function(t, e) { + return e.inputEvent && (e.inputEvent.target.getAttribute("class") || "").indexOf("clip") > -1; + }, + dragStart: function(t, e) { + var r = t.props, n = r.dragWithClip, a = n === void 0 ? !0 : n; + return a ? !1 : this.dragControlStart(t, e); + }, + drag: function(t, e) { + return this.dragControl(t, I(I({}, e), { isDragTarget: !0 })); + }, + dragEnd: function(t, e) { + return this.dragControlEnd(t, e); + }, + dragControlStart: function(t, e) { + var r = t.state, n = t.props, a = n.defaultClipPath, i = n.customClipPath, o = r.target, s = r.width, l = r.height, u = e.inputEvent ? e.inputEvent.target : null, c = u && u.getAttribute("class") || "", f = e.datas, d = vs(o, s, l, a || "inset", i); + if (!d) + return !1; + var p = d.clipText, h = d.type, g = d.poses, x = rt(t, "onClipStart", bt(t, e, { + clipType: h, + clipStyle: p, + poses: g.map(function(y) { + return y.pos; + }) + })); + return x === !1 ? (f.isClipStart = !1, !1) : (f.isControl = c && c.indexOf("clip-control") > -1, f.isLine = c.indexOf("clip-line") > -1, f.isArea = c.indexOf("clip-area") > -1 || c.indexOf("clip-ellipse") > -1, f.clipIndex = u ? parseInt(u.getAttribute("data-clip-index"), 10) : -1, f.clipPath = d, f.isClipStart = !0, r.clipPathState = p, fr(t, e), !0); + }, + dragControl: function(t, e) { + var r, n, a, i = e.datas, o = e.originalDatas, s = e.isDragTarget; + if (!i.isClipStart) + return !1; + var l = i, u = l.isControl, c = l.isLine, f = l.isArea, d = l.clipIndex, p = l.clipPath; + if (!p) + return !1; + var h = cr(t.props, "clippable"), g = h.keepRatio, x = 0, y = 0, b = o.draggable, C = Oe(e); + s && b ? (r = O(b.prevBeforeDist, 2), x = r[0], y = r[1]) : (n = O(C, 2), x = n[0], y = n[1]); + var S = [x, y], w = t.state, v = w.width, _ = w.height, M = !f && !u && !c, T = p.type, k = p.poses, A = p.splitter, z = k.map(function(Tt) { + return Tt.pos; + }); + M && (x = -x, y = -y); + var R = !u || k[d].direction === "nesw", B = T === "inset" || T === "rect", N = k.map(function() { + return [0, 0]; + }); + if (u && !R) { + var L = k[d], V = L.horizontal, G = L.vertical, W = [ + x * Y(V), + y * Y(G) + ]; + N = Up(k, d, W, B, g); + } else R && (N = z.map(function() { + return [x, y]; + })); + var $ = z.map(function(Tt, ee) { + return wt(Tt, N[ee]); + }), j = Z([], O($), !1); + w.snapBoundInfos = null; + var J = p.type === "circle", Q = p.type === "ellipse"; + if (J || Q) { + var H = ye($), tt = Y(H.bottom - H.top), U = Y(Q ? H.right - H.left : tt), et = $[0][1] + tt, lt = $[0][0] - U, ft = $[0][0] + U; + J && (j.push([ft, H.bottom]), N.push([1, 0])), j.push([H.left, et]), N.push([0, 1]), j.push([lt, H.bottom]), N.push([1, 0]); + } + var xt = Hl((h.clipHorizontalGuidelines || []).map(function(Tt) { + return Rt("".concat(Tt), _); + }), (h.clipVerticalGuidelines || []).map(function(Tt) { + return Rt("".concat(Tt), v); + }), v, _), q = [], nt = []; + if (J || Q) + q = [j[4][0], j[2][0]], nt = [j[1][1], j[3][1]]; + else if (B) { + var Et = [j[0], j[2], j[4], j[6]], pt = [N[0], N[2], N[4], N[6]]; + q = Et.filter(function(Tt, ee) { + return pt[ee][0]; + }).map(function(Tt) { + return Tt[0]; + }), nt = Et.filter(function(Tt, ee) { + return pt[ee][1]; + }).map(function(Tt) { + return Tt[1]; + }); + } else + q = j.filter(function(Tt, ee) { + return N[ee][0]; + }).map(function(Tt) { + return Tt[0]; + }), nt = j.filter(function(Tt, ee) { + return N[ee][1]; + }).map(function(Tt) { + return Tt[1]; + }); + var vt = [0, 0], St = Jo(xt, h.clipTargetBounds && { left: 0, top: 0, right: v, bottom: _ }, q, nt, 5, 5), _t = St.horizontal, Mt = St.vertical, ht = _t.offset, Dt = Mt.offset; + if (_t.isBound && (vt[1] += ht), Mt.isBound && (vt[0] += Dt), (Q || J) && N[0][0] === 0 && N[0][1] === 0) { + var H = ye($), Bt = H.bottom - H.top, Zt = Q ? H.right - H.left : Bt, jt = Mt.isBound ? Y(Dt) : Mt.snapIndex === 0 ? -Dt : Dt, Ft = _t.isBound ? Y(ht) : _t.snapIndex === 0 ? -ht : ht; + Zt -= jt, Bt -= Ft, J && (Bt = Bl(Mt, _t) > 0 ? Bt : Zt, Zt = Bt); + var Ot = j[0]; + j[1][1] = Ot[1] - Bt, j[2][0] = Ot[0] + Zt, j[3][1] = Ot[1] + Bt, j[4][0] = Ot[0] - Zt; + } else if (B && g && u) { + var kt = O(hu(k), 2), Ee = kt[0], Ht = kt[1], ze = Ee && Ht ? Ee / Ht : 0, Ze = k[d], K = Ze.direction || "", dt = j[1][1], et = j[5][1], lt = j[7][0], ft = j[3][0]; + Y(ht) <= Y(Dt) ? ht = oe(ht) * Y(Dt) / ze : Dt = oe(Dt) * Y(ht) * ze, K.indexOf("w") > -1 ? lt -= Dt : K.indexOf("e") > -1 ? ft -= Dt : (lt += Dt / 2, ft -= Dt / 2), K.indexOf("n") > -1 ? dt -= ht : K.indexOf("s") > -1 ? et -= ht : (dt += ht / 2, et -= ht / 2); + var Jt = na(dt, ft, et, lt); + j.forEach(function(Lr, xn) { + var ce; + ce = O(Jt[xn].pos, 2), Lr[0] = ce[0], Lr[1] = ce[1]; + }); + } else + j.forEach(function(Tt, ee) { + var mn = N[ee]; + mn[0] && (Tt[0] -= Dt), mn[1] && (Tt[1] -= ht); + }); + var Je = eo(t, p, $), Ie = "".concat(T, "(").concat(Je.join(A), ")"); + if (w.clipPathState = Ie, J || Q) + q = [j[4][0], j[2][0]], nt = [j[1][1], j[3][1]]; + else if (B) { + var Et = [j[0], j[2], j[4], j[6]]; + q = Et.map(function(ee) { + return ee[0]; + }), nt = Et.map(function(ee) { + return ee[1]; + }); + } else + q = j.map(function(Tt) { + return Tt[0]; + }), nt = j.map(function(Tt) { + return Tt[1]; + }); + if (w.snapBoundInfos = Jo(xt, h.clipTargetBounds && { left: 0, top: 0, right: v, bottom: _ }, q, nt, 1, 1), b) { + var ue = w.is3d, Fr = w.allMatrix, Fe = ue ? 4 : 3, pr = vt; + s && (pr = [ + S[0] + vt[0] - C[0], + S[1] + vt[1] - C[1] + ]), b.deltaOffset = Pt(Fr, [pr[0], pr[1], 0, 0], Fe); + } + return rt(t, "onClip", bt(t, e, I({ clipEventType: "changed", clipType: T, poses: $, clipStyle: Ie, clipStyles: Je, distX: x, distY: y }, se((a = {}, a[T === "rect" ? "clip" : "clipPath"] = Ie, a), e)))), !0; + }, + dragControlEnd: function(t, e) { + this.unset(t); + var r = e.isDrag, n = e.datas, a = e.isDouble, i = n.isLine, o = n.isClipStart, s = n.isControl; + return o ? (rt(t, "onClipEnd", he(t, e, {})), a && (s ? Zp(t, e) : i && Kp(t, e)), a || r) : !1; + }, + unset: function(t) { + t.state.clipPathState = "", t.state.snapBoundInfos = null; + } +}, Qp = { + name: "originDraggable", + props: [ + "originDraggable", + "originRelative" + ], + events: [ + "dragOriginStart", + "dragOrigin", + "dragOriginEnd" + ], + css: [ + `:host[data-able-origindraggable] .control.origin { +pointer-events: auto; +}` + ], + dragControlCondition: function(t, e) { + return e.isRequest ? e.requestAble === "originDraggable" : Kt(e.inputEvent.target, ut("origin")); + }, + dragControlStart: function(t, e) { + var r = e.datas; + fr(t, e); + var n = bt(t, e, { + dragStart: ie.dragStart(t, new Rr().dragStart([0, 0], e)) + }), a = rt(t, "onDragOriginStart", n); + return r.startOrigin = t.state.transformOrigin, r.startTargetOrigin = t.state.targetOrigin, r.prevOrigin = [0, 0], r.isDragOrigin = !0, a === !1 ? (r.isDragOrigin = !1, !1) : n; + }, + dragControl: function(t, e) { + var r = e.datas, n = e.isPinch, a = e.isRequest; + if (!r.isDragOrigin) + return !1; + var i = O(Oe(e), 2), o = i[0], s = i[1], l = t.state, u = l.width, c = l.height, f = l.offsetMatrix, d = l.targetMatrix, p = l.is3d, h = t.props.originRelative, g = h === void 0 ? !0 : h, x = p ? 4 : 3, y = [o, s]; + if (a) { + var b = e.distOrigin; + (b[0] || b[1]) && (y = b); + } + var C = wt(r.startOrigin, y), S = wt(r.startTargetOrigin, y), w = ct(y, r.prevOrigin), v = hn(f, d, C, x), _ = t.getRect(), M = ye(dr(v, u, c, x)), T = [ + _.left - M.left, + _.top - M.top + ]; + r.prevOrigin = y; + var k = [ + we(S[0], u, g), + we(S[1], c, g) + ].join(" "), A = ie.drag(t, vn(e, t.state, T, !!n)), z = bt(t, e, I(I({ width: u, height: c, origin: C, dist: y, delta: w, transformOrigin: k, drag: A }, se({ + transformOrigin: k, + transform: A.transform + }, e)), { afterTransform: A.transform })); + return rt(t, "onDragOrigin", z), z; + }, + dragControlEnd: function(t, e) { + var r = e.datas; + return r.isDragOrigin ? (rt(t, "onDragOriginEnd", he(t, e, {})), !0) : !1; + }, + dragGroupControlCondition: function(t, e) { + return this.dragControlCondition(t, e); + }, + dragGroupControlStart: function(t, e) { + var r = this.dragControlStart(t, e); + return !!r; + }, + dragGroupControl: function(t, e) { + var r = this.dragControl(t, e); + return r ? (t.transformOrigin = r.transformOrigin, !0) : !1; + }, + /** + * @method Moveable.OriginDraggable#request + * @param {object} e - the OriginDraggable's request parameter + * @param {number} [e.x] - x position + * @param {number} [e.y] - y position + * @param {number} [e.deltaX] - x number to move + * @param {number} [e.deltaY] - y number to move + * @param {array} [e.deltaOrigin] - left, top number to move transform-origin + * @param {array} [e.origin] - transform-origin position + * @param {number} [e.isInstant] - Whether to execute the request instantly + * @return {Moveable.Requester} Moveable Requester + * @example + + * // Instantly Request (requestStart - request - requestEnd) + * // Use Relative Value + * moveable.request("originDraggable", { deltaX: 10, deltaY: 10 }, true); + * // Use Absolute Value + * moveable.request("originDraggable", { x: 200, y: 100 }, true); + * // Use Transform Value + * moveable.request("originDraggable", { deltaOrigin: [10, 0] }, true); + * moveable.request("originDraggable", { origin: [100, 0] }, true); + * // requestStart + * const requester = moveable.request("originDraggable"); + * + * // request + * // Use Relative Value + * requester.request({ deltaX: 10, deltaY: 10 }); + * requester.request({ deltaX: 10, deltaY: 10 }); + * requester.request({ deltaX: 10, deltaY: 10 }); + * // Use Absolute Value + * moveable.request("originDraggable", { x: 200, y: 100 }); + * moveable.request("originDraggable", { x: 220, y: 100 }); + * moveable.request("originDraggable", { x: 240, y: 100 }); + * + * // requestEnd + * requester.requestEnd(); + */ + request: function(t) { + var e = {}, r = t.getRect(), n = 0, a = 0, i = r.transformOrigin, o = [0, 0]; + return { + isControl: !0, + requestStart: function() { + return { datas: e }; + }, + request: function(s) { + return "deltaOrigin" in s ? (o[0] += s.deltaOrigin[0], o[1] += s.deltaOrigin[1]) : "origin" in s ? (o[0] = s.origin[0] - i[0], o[1] = s.origin[1] - i[1]) : ("x" in s ? n = s.x - r.left : "deltaX" in s && (n += s.deltaX), "y" in s ? a = s.y - r.top : "deltaY" in s && (a += s.deltaY)), { datas: e, distX: n, distY: a, distOrigin: o }; + }, + requestEnd: function() { + return { datas: e, isDrag: !0 }; + } + }; + } +}; +function tv(t, e, r, n) { + var a = t.filter(function(l) { + var u = l.virtual, c = l.horizontal; + return c && !u; + }).length, i = t.filter(function(l) { + var u = l.virtual, c = l.vertical; + return c && !u; + }).length, o = -1; + if (e === 0 && (a === 0 ? o = 0 : a === 1 && (o = 1)), e === 2 && (a <= 2 ? o = 2 : a <= 3 && (o = 3)), e === 3 && (i === 0 ? o = 4 : i < 4 && (o = 7)), e === 1 && (i <= 1 ? o = 5 : i <= 2 && (o = 6)), !(o === -1 || !t[o].virtual)) { + var s = t[o]; + ev(t, o), o < 4 ? s.pos[0] = r : s.pos[1] = n; + } +} +function ev(t, e) { + e < 4 ? t.slice(0, e + 1).forEach(function(r) { + r.virtual = !1; + }) : (t[0].virtual && (t[0].virtual = !1), t.slice(4, e + 1).forEach(function(r) { + r.virtual = !1; + })); +} +function rv(t, e) { + e < 4 ? t.slice(e, 4).forEach(function(r) { + r.virtual = !0; + }) : t.slice(e).forEach(function(r) { + r.virtual = !0; + }); +} +function hs(t, e, r, n, a) { + n === void 0 && (n = [0, 0]); + var i = []; + return !t || t === "0px" ? i = [] : i = Ve(t), vu(i, e, r, 0, 0, n, a); +} +function gs(t, e, r, n, a) { + var i = t.state, o = i.width, s = i.height, l = to(a, t.props.roundRelative, o, s), u = l.raws, c = l.styles, f = l.radiusPoses, d = qp(f, u), p = d.horizontals, h = d.verticals, g = c.join(" "); + i.borderRadiusState = g; + var x = bt(t, e, I({ horizontals: p, verticals: h, borderRadius: g, width: o, height: s, delta: n, dist: r }, se({ + borderRadius: g + }, e))); + return rt(t, "onRound", x), x; +} +function ms(t) { + var e, r, n = t.getState().style, a = n.borderRadius || ""; + if (!a && t.props.groupable) { + var i = t.moveables[0], o = t.getTargets()[0]; + o && ((i == null ? void 0 : i.props.target) === o ? (a = (r = (e = t.moveables[0]) === null || e === void 0 ? void 0 : e.state.style.borderRadius) !== null && r !== void 0 ? r : "", n.borderRadius = a) : (a = Ui(o).borderRadius, n.borderRadius = a)); + } + return a; +} +var nv = { + name: "roundable", + props: [ + "roundable", + "roundRelative", + "minRoundControls", + "maxRoundControls", + "roundClickable", + "roundPadding", + "isDisplayShadowRoundControls" + ], + events: [ + "roundStart", + "round", + "roundEnd", + "roundGroupStart", + "roundGroup", + "roundGroupEnd" + ], + css: [ + `.control.border-radius { +background: #d66; +cursor: pointer; +z-index: 3; +}`, + `.control.border-radius.vertical { +background: #d6d; +z-index: 2; +}`, + `.control.border-radius.virtual { +opacity: 0.5; +z-index: 1; +}`, + `:host.round-line-clickable .line.direction { +cursor: pointer; +}` + ], + className: function(t) { + var e = t.props.roundClickable; + return e === !0 || e === "line" ? ut("round-line-clickable") : ""; + }, + requestStyle: function() { + return ["borderRadius"]; + }, + requestChildStyle: function() { + return ["borderRadius"]; + }, + render: function(t, e) { + var r = t.getState(), n = r.target, a = r.width, i = r.height, o = r.allMatrix, s = r.is3d, l = r.left, u = r.top, c = r.borderRadiusState, f = t.props, d = f.minRoundControls, p = d === void 0 ? [0, 0] : d, h = f.maxRoundControls, g = h === void 0 ? [4, 4] : h, x = f.zoom, y = f.roundPadding, b = y === void 0 ? 0 : y, C = f.isDisplayShadowRoundControls, S = f.groupable; + if (!n) + return null; + var w = c || ms(t), v = s ? 4 : 3, _ = hs(w, a, i, p, !0); + if (!_) + return null; + var M = 0, T = 0, k = S ? [0, 0] : [l, u]; + return _.map(function(A, z) { + var R = A.horizontal, B = A.vertical, N = A.direction || "", L = Z([], O(A.pos), !1); + T += Math.abs(R), M += Math.abs(B), R && N.indexOf("n") > -1 && (L[1] -= b), B && N.indexOf("w") > -1 && (L[0] -= b), R && N.indexOf("s") > -1 && (L[1] += b), B && N.indexOf("e") > -1 && (L[0] += b); + var V = ct(Gt(o, L, v), k), G = C && C !== "horizontal", W = A.vertical ? M <= g[1] && (G || !A.virtual) : T <= g[0] && (C || !A.virtual); + return e.createElement("div", { key: "borderRadiusControl".concat(z), className: ut("control", "border-radius", A.vertical ? "vertical" : "", A.virtual ? "virtual" : ""), "data-radius-index": z, style: { + display: W ? "block" : "none", + transform: "translate(".concat(V[0], "px, ").concat(V[1], "px) scale(").concat(x, ")") + } }); + }); + }, + dragControlCondition: function(t, e) { + if (!e.inputEvent || e.isRequest) + return !1; + var r = e.inputEvent.target.getAttribute("class") || ""; + return r.indexOf("border-radius") > -1 || r.indexOf("moveable-line") > -1 && r.indexOf("moveable-direction") > -1; + }, + dragGroupControlCondition: function(t, e) { + return this.dragControlCondition(t, e); + }, + dragControlStart: function(t, e) { + var r = e.inputEvent, n = e.datas, a = r.target, i = a.getAttribute("class") || "", o = i.indexOf("border-radius") > -1, s = i.indexOf("moveable-line") > -1 && i.indexOf("moveable-direction") > -1, l = o ? parseInt(a.getAttribute("data-radius-index"), 10) : -1, u = -1; + if (s) { + var c = a.getAttribute("data-line-key") || ""; + c && (u = parseInt(c.replace(/render-line-/g, ""), 10), isNaN(u) && (u = -1)); + } + if (!o && !s) + return !1; + var f = bt(t, e, {}), d = rt(t, "onRoundStart", f); + if (d === !1) + return !1; + n.lineIndex = u, n.controlIndex = l, n.isControl = o, n.isLine = s, fr(t, e); + var p = t.props, h = p.roundRelative, g = p.minRoundControls, x = g === void 0 ? [0, 0] : g, y = t.state, b = y.width, C = y.height; + n.isRound = !0, n.prevDist = [0, 0]; + var S = ms(t), w = hs(S || "", b, C, x, !0) || []; + return n.controlPoses = w, y.borderRadiusState = to(w, h, b, C).styles.join(" "), f; + }, + dragControl: function(t, e) { + var r = e.datas, n = r.controlPoses; + if (!r.isRound || !r.isControl || !n.length) + return !1; + var a = r.controlIndex, i = O(Oe(e), 2), o = i[0], s = i[1], l = [o, s], u = ct(l, r.prevDist), c = t.props.maxRoundControls, f = c === void 0 ? [4, 4] : c, d = t.state, p = d.width, h = d.height, g = n[a], x = g.vertical, y = g.horizontal, b = n.map(function(S) { + var w = S.horizontal, v = S.vertical, _ = [ + w * y * l[0], + v * x * l[1] + ]; + if (w) { + if (f[0] === 1) + return _; + if (f[0] < 4 && w !== y) + return _; + } else { + if (f[1] === 0) + return _[1] = v * y * l[0] / p * h, _; + if (x) { + if (f[1] === 1) + return _; + if (f[1] < 4 && v !== x) + return _; + } + } + return [0, 0]; + }); + b[a] = l; + var C = n.map(function(S, w) { + return I(I({}, S), { pos: wt(S.pos, b[w]) }); + }); + return a < 4 ? C.slice(0, a + 1).forEach(function(S) { + S.virtual = !1; + }) : C.slice(4, a + 1).forEach(function(S) { + S.virtual = !1; + }), r.prevDist = [o, s], gs(t, e, l, u, C); + }, + dragControlEnd: function(t, e) { + var r = t.state; + r.borderRadiusState = ""; + var n = e.datas, a = e.isDouble; + if (!n.isRound) + return !1; + var i = n.isControl, o = n.controlIndex, s = n.isLine, l = n.lineIndex, u = n.controlPoses, c = u.filter(function(y) { + var b = y.virtual; + return b; + }).length, f = t.props.roundClickable, d = f === void 0 ? !0 : f; + if (a && d) { + if (i && (d === !0 || d === "control")) + rv(u, o); + else if (s && (d === !0 || d === "line")) { + var p = O(yl(t, e), 2), h = p[0], g = p[1]; + tv(u, l, h, g); + } + c !== u.filter(function(y) { + var b = y.virtual; + return b; + }).length && gs(t, e, [0, 0], [0, 0], u); + } + var x = he(t, e, {}); + return rt(t, "onRoundEnd", x), r.borderRadiusState = "", x; + }, + dragGroupControlStart: function(t, e) { + var r = this.dragControlStart(t, e); + if (!r) + return !1; + var n = t.moveables, a = t.props.targets, i = Me(t, "roundable", e), o = I({ targets: t.props.targets, events: i.map(function(s, l) { + return I(I({}, s), { target: a[l], moveable: n[l], currentTarget: n[l] }); + }) }, r); + return rt(t, "onRoundGroupStart", o), r; + }, + dragGroupControl: function(t, e) { + var r = this.dragControl(t, e); + if (!r) + return !1; + var n = t.moveables, a = t.props.targets, i = Me(t, "roundable", e), o = I({ targets: t.props.targets, events: i.map(function(s, l) { + return I(I(I({}, s), { target: a[l], moveable: n[l], currentTarget: n[l] }), se({ + borderRadius: r.borderRadius + }, s)); + }) }, r); + return rt(t, "onRoundGroup", o), o; + }, + dragGroupControlEnd: function(t, e) { + var r = t.moveables, n = t.props.targets, a = Me(t, "roundable", e); + ha(t, "onRound", function(s) { + var l = I({ targets: t.props.targets, events: a.map(function(u, c) { + return I(I(I({}, u), { target: n[c], moveable: r[c], currentTarget: r[c] }), se({ + borderRadius: s.borderRadius + }, u)); + }) }, s); + rt(t, "onRoundGroup", l); + }); + var i = this.dragControlEnd(t, e); + if (!i) + return !1; + var o = I({ targets: t.props.targets, events: a.map(function(s, l) { + var u; + return I(I({}, s), { target: n[l], moveable: r[l], currentTarget: r[l], lastEvent: (u = s.datas) === null || u === void 0 ? void 0 : u.lastEvent }); + }) }, i); + return rt(t, "onRoundGroupEnd", o), o; + }, + unset: function(t) { + t.state.borderRadiusState = ""; + } +}; +function av(t, e) { + var r = e ? 4 : 3, n = At(r), a = "matrix".concat(e ? "3d" : "", "(").concat(n.join(","), ")"); + return t === a || t === "matrix(1,0,0,1,0,0)"; +} +var gu = { + isPinch: !0, + name: "beforeRenderable", + props: [], + events: [ + "beforeRenderStart", + "beforeRender", + "beforeRenderEnd", + "beforeRenderGroupStart", + "beforeRenderGroup", + "beforeRenderGroupEnd" + ], + dragRelation: "weak", + setTransform: function(t, e) { + var r = t.state, n = r.is3d, a = r.targetMatrix, i = r.inlineTransform, o = n ? "matrix3d(".concat(a.join(","), ")") : "matrix(".concat(il(a, !0), ")"), s = !i || i === "none" ? o : i; + e.datas.startTransforms = av(s, n) ? [] : Ve(s); + }, + resetStyle: function(t) { + var e = t.datas; + e.nextStyle = {}, e.nextTransforms = t.datas.startTransforms, e.nextTransformAppendedIndexes = []; + }, + fillDragStartParams: function(t, e) { + return bt(t, e, { + setTransform: function(r) { + e.datas.startTransforms = Yt(r) ? r : Ve(r); + }, + isPinch: !!e.isPinch + }); + }, + fillDragParams: function(t, e) { + return bt(t, e, { + isPinch: !!e.isPinch + }); + }, + dragStart: function(t, e) { + this.setTransform(t, e), this.resetStyle(e), rt(t, "onBeforeRenderStart", this.fillDragStartParams(t, e)); + }, + drag: function(t, e) { + e.datas.startTransforms || this.setTransform(t, e), this.resetStyle(e), rt(t, "onBeforeRender", bt(t, e, { + isPinch: !!e.isPinch + })); + }, + dragEnd: function(t, e) { + e.datas.startTransforms || (this.setTransform(t, e), this.resetStyle(e)), rt(t, "onBeforeRenderEnd", bt(t, e, { + isPinch: !!e.isPinch, + isDrag: e.isDrag + })); + }, + dragGroupStart: function(t, e) { + var r = this; + this.dragStart(t, e); + var n = Me(t, "beforeRenderable", e), a = t.moveables, i = n.map(function(o, s) { + var l = a[s]; + return r.setTransform(l, o), r.resetStyle(o), r.fillDragStartParams(l, o); + }); + rt(t, "onBeforeRenderGroupStart", bt(t, e, { + isPinch: !!e.isPinch, + targets: t.props.targets, + setTransform: function() { + }, + events: i + })); + }, + dragGroup: function(t, e) { + var r = this; + this.drag(t, e); + var n = Me(t, "beforeRenderable", e), a = t.moveables, i = n.map(function(o, s) { + var l = a[s]; + return r.resetStyle(o), r.fillDragParams(l, o); + }); + rt(t, "onBeforeRenderGroup", bt(t, e, { + isPinch: !!e.isPinch, + targets: t.props.targets, + events: i + })); + }, + dragGroupEnd: function(t, e) { + this.dragEnd(t, e), rt(t, "onBeforeRenderGroupEnd", bt(t, e, { + isPinch: !!e.isPinch, + isDrag: e.isDrag, + targets: t.props.targets + })); + }, + dragControlStart: function(t, e) { + return this.dragStart(t, e); + }, + dragControl: function(t, e) { + return this.drag(t, e); + }, + dragControlEnd: function(t, e) { + return this.dragEnd(t, e); + }, + dragGroupControlStart: function(t, e) { + return this.dragGroupStart(t, e); + }, + dragGroupControl: function(t, e) { + return this.dragGroup(t, e); + }, + dragGroupControlEnd: function(t, e) { + return this.dragGroupEnd(t, e); + } +}, mu = { + name: "renderable", + props: [], + events: [ + "renderStart", + "render", + "renderEnd", + "renderGroupStart", + "renderGroup", + "renderGroupEnd" + ], + dragRelation: "weak", + dragStart: function(t, e) { + rt(t, "onRenderStart", bt(t, e, { + isPinch: !!e.isPinch + })); + }, + drag: function(t, e) { + rt(t, "onRender", this.fillDragParams(t, e)); + }, + dragAfter: function(t, e) { + return this.drag(t, e); + }, + dragEnd: function(t, e) { + rt(t, "onRenderEnd", this.fillDragEndParams(t, e)); + }, + dragGroupStart: function(t, e) { + rt(t, "onRenderGroupStart", bt(t, e, { + isPinch: !!e.isPinch, + targets: t.props.targets + })); + }, + dragGroup: function(t, e) { + var r = this, n = Me(t, "beforeRenderable", e), a = t.moveables, i = n.map(function(o, s) { + var l = a[s]; + return r.fillDragParams(l, o); + }); + rt(t, "onRenderGroup", bt(t, e, I(I({ isPinch: !!e.isPinch, targets: t.props.targets, transform: In(e), transformObject: {} }, se(Rn(e))), { events: i }))); + }, + dragGroupEnd: function(t, e) { + var r = this, n = Me(t, "beforeRenderable", e), a = t.moveables, i = n.map(function(o, s) { + var l = a[s]; + return r.fillDragEndParams(l, o); + }); + rt(t, "onRenderGroupEnd", bt(t, e, I({ isPinch: !!e.isPinch, isDrag: e.isDrag, targets: t.props.targets, events: i, transformObject: {}, transform: In(e) }, se(Rn(e))))); + }, + dragControlStart: function(t, e) { + return this.dragStart(t, e); + }, + dragControl: function(t, e) { + return this.drag(t, e); + }, + dragControlAfter: function(t, e) { + return this.dragAfter(t, e); + }, + dragControlEnd: function(t, e) { + return this.dragEnd(t, e); + }, + dragGroupControlStart: function(t, e) { + return this.dragGroupStart(t, e); + }, + dragGroupControl: function(t, e) { + return this.dragGroup(t, e); + }, + dragGroupControlEnd: function(t, e) { + return this.dragGroupEnd(t, e); + }, + fillDragParams: function(t, e) { + var r = {}; + return Ir(Kn(e) || []).forEach(function(n) { + r[n.name] = n.functionValue; + }), bt(t, e, I({ isPinch: !!e.isPinch, transformObject: r, transform: In(e) }, se(Rn(e)))); + }, + fillDragEndParams: function(t, e) { + var r = {}; + return Ir(Kn(e) || []).forEach(function(n) { + r[n.name] = n.functionValue; + }), bt(t, e, I({ isPinch: !!e.isPinch, isDrag: e.isDrag, transformObject: r, transform: In(e) }, se(Rn(e)))); + } +}; +function en(t, e, r, n, a, i, o) { + i.clientDistX = i.distX, i.clientDistY = i.distY; + var s = a === "Start", l = a === "End", u = a === "After", c = t.state.target, f = i.isRequest, d = n.indexOf("Control") > -1; + if (!c || s && d && !f && t.areaElement === i.inputEvent.target) + return !1; + var p = Z([], O(e), !1); + if (f) { + var h = i.requestAble; + p.some(function(z) { + return z.name === h; + }) || p.push.apply(p, Z([], O(t.props.ables.filter(function(z) { + return z.name === h; + })), !1)); + } + if (!p.length || p.every(function(z) { + return z.dragRelation; + })) + return !1; + var g = i.inputEvent, x; + l && g && (x = document.elementFromPoint(i.clientX, i.clientY) || g.target); + var y = !1, b = function() { + var z; + y = !0, (z = i.stop) === null || z === void 0 || z.call(i); + }, C = s && (!t.targetGesto || !t.controlGesto || !t.targetGesto.isFlag() || !t.controlGesto.isFlag()); + C && t.updateRect(a, !0, !1); + var S = i.datas, w = d ? "controlGesto" : "targetGesto", v = t[w], _ = function(z, R, B) { + if (!(R in z) || v !== t[w]) + return !1; + var N = z.name, L = S[N] || (S[N] = {}); + if (s && (L.isEventStart = !B || !z[B] || z[B](t, i)), !L.isEventStart) + return !1; + var V = z[R](t, I(I({}, i), { stop: b, datas: L, originalDatas: S, inputTarget: x })); + return t._emitter.off(), s && V === !1 && (L.isEventStart = !1), V; + }; + C && p.forEach(function(z) { + z.unset && z.unset(t); + }), _(gu, "drag".concat(n).concat(a)); + var M = 0, T = 0; + r.forEach(function(z) { + if (y) + return !1; + var R = "".concat(z).concat(n).concat(a), B = "".concat(z).concat(n, "Condition"); + a === "" && !f && Mp(t.state, i); + var N = p.filter(function(G) { + return G[R]; + }); + N = N.filter(function(G, W) { + return G.name && N.indexOf(G) === W; + }); + var L = N.filter(function(G) { + return _(G, R, B); + }), V = L.length; + y && ++M, V && ++T, !y && s && N.length && !V && (M += N.filter(function(G) { + var W = G.name, $ = S[W]; + return $.isEventStart ? G.dragRelation !== "strong" : !1; + }).length ? 1 : 0); + }), (!u || T) && _(mu, "drag".concat(n).concat(a)); + var k = v !== t[w] || M === r.length; + if ((l || y || k) && (t.state.gestos = {}, t.moveables && t.moveables.forEach(function(z) { + z.state.gestos = {}; + }), p.forEach(function(z) { + z.unset && z.unset(t); + })), s && !k && !f && T && t.props.preventDefault && (i == null || i.preventDefault()), t.isUnmounted || k) + return !1; + if (!s && T && !o || l) { + var A = t.props.flushSync || $l; + A(function() { + t.updateRect(l ? a : "", !0, !1), t.forceUpdate(); + }); + } + return !s && !l && !u && T && !o && en(t, e, r, n, a + "After", i), !0; +} +function ro(t, e) { + return function(r, n) { + var a; + n === void 0 && (n = r.inputEvent.target); + var i = n, o = t.areaElement, s = t._dragTarget; + return !s || !e && (!((a = t.controlGesto) === null || a === void 0) && a.isFlag()) ? !1 : i === s || s.contains(i) || i === o || !t.isMoveableElement(i) && !t.controlBox.contains(i) || Kt(i, "moveable-area") || Kt(i, "moveable-padding") || Kt(i, "moveable-edgeDraggable"); + }; +} +function xu(t, e, r) { + var n = t.controlBox, a = [], i = t.props, o = i.dragArea, s = t.state.target, l = i.dragTarget; + a.push(n), (!o || l) && a.push(e), !o && l && s && e !== s && i.dragTargetSelf && a.push(s); + var u = ro(t); + return bu(t, a, "targetAbles", r, { + dragStart: u, + pinchStart: u + }); +} +function yu(t, e) { + var r = t.controlBox, n = []; + n.push(r); + var a = ro(t, !0), i = function(o, s) { + if (s === void 0 && (s = o.inputEvent.target), s === r) + return !0; + var l = a(o, s); + return !l; + }; + return bu(t, n, "controlAbles", e, { + dragStart: i, + pinchStart: i + }); +} +function bu(t, e, r, n, a) { + a === void 0 && (a = {}); + var i = r === "targetAbles", o = t.props, s = o.pinchOutside, l = o.pinchThreshold, u = o.preventClickEventOnDrag, c = o.preventClickDefault, f = o.checkInput, d = o.dragFocusedInput, p = o.preventDefault, h = p === void 0 ? !0 : p, g = o.preventRightClick, x = g === void 0 ? !0 : g, y = o.preventWheelClick, b = y === void 0 ? !0 : y, C = o.dragContainer, S = Pe(C, !0), w = { + preventDefault: h, + preventRightClick: x, + preventWheelClick: b, + container: S || xe(t.getControlBoxElement()), + pinchThreshold: l, + pinchOutside: s, + preventClickEventOnDrag: i ? u : !1, + preventClickEventOnDragStart: i ? c : !1, + preventClickEventByCondition: i ? null : function(M) { + return t.controlBox.contains(M.target); + }, + checkInput: i ? f : !1, + dragFocusedInput: d + }, v = new fl(e, w), _ = n === "Control"; + return ["drag", "pinch"].forEach(function(M) { + ["Start", "", "End"].forEach(function(T) { + v.on("".concat(M).concat(T), function(k) { + var A, z = k.eventType, R = M === "drag" && k.isPinch; + if (a[z] && !a[z](k)) { + k.stop(); + return; + } + if (!R) { + var B = M === "drag" ? [M] : ["drag", M], N = Z([], O(t[r]), !1), L = en(t, N, B, n, T, k); + L ? (t.props.stopPropagation || T === "Start" && _) && ((A = k == null ? void 0 : k.inputEvent) === null || A === void 0 || A.stopPropagation()) : k.stop(); + } + }); + }); + }), v; +} +var iv = /* @__PURE__ */ (function() { + function t(e, r, n) { + var a = this; + this.target = e, this.moveable = r, this.eventName = n, this.ables = [], this._onEvent = function(i) { + var o = a.eventName, s = a.moveable; + s.state.disableNativeEvent || a.ables.forEach(function(l) { + l[o](s, { + inputEvent: i + }); + }); + }, e.addEventListener(n.toLowerCase(), this._onEvent); + } + return t.prototype.setAbles = function(e) { + this.ables = e; + }, t.prototype.destroy = function() { + this.target.removeEventListener(this.eventName.toLowerCase(), this._onEvent), this.target = null, this.moveable = null; + }, t; +})(); +function ov(t, e, r, n) { + var a; + r === void 0 && (r = e); + var i = wl(t, e), o = i.matrixes, s = i.is3d, l = i.targetMatrix, u = i.transformOrigin, c = i.targetOrigin, f = i.offsetContainer, d = i.hasFixed, p = i.zoom, h = bd(f, r), g = h.matrixes, x = h.is3d, y = h.offsetContainer, b = h.zoom, C = n, S = 4, w = t.tagName.toLowerCase() !== "svg" && "ownerSVGElement" in t, v = l, _ = At(S), M = At(S), T = At(S), k = At(S), A = o.length, z = g.map(function(W) { + return I(I({}, W), { matrix: W.matrix ? Z([], O(W.matrix), !1) : void 0 }); + }).reverse(); + o.reverse(), !s && C && (v = Te(v, 3, 4), di(o)), !x && C && di(z), z.forEach(function(W) { + M = Pt(M, W.matrix, S); + }); + var R = r || Ke(t), B = ((a = z[0]) === null || a === void 0 ? void 0 : a.target) || ln(R, R, !0).offsetParent, N = z.slice(1).reduce(function(W, $) { + return Pt(W, $.matrix, S); + }, At(S)); + o.forEach(function(W, $) { + if (A - 2 === $ && (T = _.slice()), A - 1 === $ && (k = _.slice()), !W.matrix) { + var j = o[$ + 1], J = Ep(W, j, B, S, Pt(N, _, S)); + W.matrix = lr(J, S); + } + _ = Pt(_, W.matrix, S); + }); + var L = !w && s; + v || (v = At(L ? 4 : 3)); + var V = va(w && v.length === 16 ? Te(v, 4, 3) : v, L), G = M; + return M = nl(M, S, S), { + hasZoom: p !== 1 || b !== 1, + hasFixed: d, + matrixes: o, + rootMatrix: M, + originalRootMatrix: G, + beforeMatrix: T, + offsetMatrix: k, + allMatrix: _, + targetMatrix: v, + targetTransform: V, + inlineTransform: t.style.transform, + transformOrigin: u, + targetOrigin: c, + is3d: C, + offsetContainer: f, + offsetRootContainer: y + }; +} +function sv(t, e, r, n) { + r === void 0 && (r = e); + var a = 0, i = 0, o = 0, s = {}, l = Jl(t); + if (t && (a = l.offsetWidth, i = l.offsetHeight), t) { + var u = ov(t, e, r, n), c = kr(u.allMatrix, u.transformOrigin, a, i); + s = I(I({}, u), c); + var f = kr(u.allMatrix, [50, 50], 100, 100); + o = Ql([f.pos1, f.pos2], f.direction); + } + var d = 4; + return I(I(I({ hasZoom: !1, width: a, height: i, rotation: o }, l), { originalRootMatrix: At(d), rootMatrix: At(d), beforeMatrix: At(d), offsetMatrix: At(d), allMatrix: At(d), targetMatrix: At(d), targetTransform: "", inlineTransform: "", transformOrigin: [0, 0], targetOrigin: [0, 0], is3d: !0, left: 0, top: 0, right: 0, bottom: 0, origin: [0, 0], pos1: [0, 0], pos2: [0, 0], pos3: [0, 0], pos4: [0, 0], direction: 1, hasFixed: !1, offsetContainer: null, offsetRootContainer: null, matrixes: [] }), s); +} +function gi(t, e, r, n, a, i) { + i === void 0 && (i = []); + var o = 1, s = [0, 0], l = On(), u = On(), c = On(), f = On(), d = [0, 0], p = {}, h = sv(e, r, a, !0); + if (e) { + var g = de(e); + i.forEach(function(z) { + p[z] = g(z); + }); + var x = h.is3d ? 4 : 3, y = kr(h.offsetMatrix, wt(h.transformOrigin, al(h.targetMatrix, x)), h.width, h.height); + o = y.direction, s = wt(y.origin, [y.left - h.left, y.top - h.top]), f = tn(h.offsetRootContainer); + var b = ln(n, n, !0).offsetParent || h.offsetRootContainer; + if (h.hasZoom) { + var C = kr(Pt(h.originalRootMatrix, h.allMatrix), h.transformOrigin, h.width, h.height), S = kr(h.originalRootMatrix, ta(de(b)("transformOrigin")).map(function(z) { + return parseFloat(z); + }), b.offsetWidth, b.offsetHeight); + if (l = Oa(C, f), c = Oa(S, f, b, !0), t) { + var w = C.left, v = C.top; + u = Oa({ + left: w, + top: v, + bottom: v, + right: v + }, f); + } + } else { + l = tn(e), c = yd(b), t && (u = tn(t)); + var _ = c.left, M = c.top, T = c.clientLeft, k = c.clientTop, A = [ + l.left - _, + l.top - M + ]; + d = ct(zr(h.rootMatrix, A, 4), [T + h.left, k + h.top]); + } + } + return I({ targetClientRect: l, containerClientRect: c, moveableClientRect: u, rootContainerClientRect: f, beforeDirection: o, beforeOrigin: s, originalBeforeOrigin: s, target: e, style: p, offsetDelta: d }, h); +} +function xs(t) { + var e = t.pos1, r = t.pos2, n = t.pos3, a = t.pos4; + if (!e || !r || !n || !a) + return null; + var i = ur([e, r, n, a]), o = [i.minX, i.minY], s = ct(t.origin, o); + return e = ct(e, o), r = ct(r, o), n = ct(n, o), a = ct(a, o), I(I({}, t), { + left: t.left, + top: t.top, + posDelta: o, + pos1: e, + pos2: r, + pos3: n, + pos4: a, + origin: s, + beforeOrigin: s, + // originalBeforeOrigin: origin, + isPersisted: !0 + }); +} +var Ar = /* @__PURE__ */ (function(t) { + dn(e, t); + function e() { + var r = t !== null && t.apply(this, arguments) || this; + return r.state = I({ container: null, gestos: {}, renderLines: [ + [[0, 0], [0, 0]], + [[0, 0], [0, 0]], + [[0, 0], [0, 0]], + [[0, 0], [0, 0]] + ], renderPoses: [[0, 0], [0, 0], [0, 0], [0, 0]], disableNativeEvent: !1, posDelta: [0, 0] }, gi(null)), r.renderState = {}, r.enabledAbles = [], r.targetAbles = [], r.controlAbles = [], r.rotation = 0, r.scale = [1, 1], r.isMoveableMounted = !1, r.isUnmounted = !1, r.events = { + mouseEnter: null, + mouseLeave: null + }, r._emitter = new fn(), r._prevOriginalDragTarget = null, r._originalDragTarget = null, r._prevDragTarget = null, r._dragTarget = null, r._prevPropTarget = null, r._propTarget = null, r._prevDragArea = !1, r._isPropTargetChanged = !1, r._hasFirstTarget = !1, r._reiszeObserver = null, r._observerId = 0, r._mutationObserver = null, r._rootContainer = null, r._viewContainer = null, r._viewClassNames = [], r._store = {}, r.checkUpdateRect = function() { + if (!r.isDragging()) { + var n = r.props.parentMoveable; + if (n) { + n.checkUpdateRect(); + return; + } + Uc(r._observerId), r._observerId = tl(function() { + r.isDragging() || r.updateRect(); + }); + } + }, r._onPreventClick = function(n) { + n.stopPropagation(), n.preventDefault(); + }, r; + } + return e.prototype.render = function() { + var r = this.props, n = this.getState(), a = r.parentPosition, i = r.className, o = r.target, s = r.zoom, l = r.cspNonce, u = r.translateZ, c = r.cssStyled, f = r.groupable, d = r.linePadding, p = r.controlPadding; + this._checkUpdateRootContainer(), this.checkUpdate(), this.updateRenderPoses(); + var h = O(a || [0, 0], 2), g = h[0], x = h[1], y = n.left, b = n.top, C = n.target, S = n.direction, w = n.hasFixed, v = n.offsetDelta, _ = r.targets, M = this.isDragging(), T = {}; + this.getEnabledAbles().forEach(function(N) { + T["data-able-".concat(N.name.toLowerCase())] = !0; + }); + var k = this._getAbleClassName(), A = _ && _.length && (C || f) || o || !this._hasFirstTarget && this.state.isPersisted, z = this.controlBox || this.props.firstRenderState || this.props.persistData, R = [y - g, b - x]; + !f && r.useAccuratePosition && (R[0] += v[0], R[1] += v[1]); + var B = { + position: w ? "fixed" : "absolute", + display: A ? "block" : "none", + visibility: z ? "visible" : "hidden", + transform: "translate3d(".concat(R[0], "px, ").concat(R[1], "px, ").concat(u, ")"), + "--zoom": s, + "--zoompx": "".concat(s, "px") + }; + return d && (B["--moveable-line-padding"] = d), p && (B["--moveable-control-padding"] = p), st.createElement( + c, + I({ cspNonce: l, ref: qe(this, "controlBox"), className: "".concat(ut("control-box", S === -1 ? "reverse" : "", M ? "dragging" : ""), " ").concat(k, " ").concat(i) }, T, { onClick: this._onPreventClick, style: B }), + this.renderAbles(), + this._renderLines() + ); + }, e.prototype.componentDidMount = function() { + this.isMoveableMounted = !0, this.isUnmounted = !1; + var r = this.props, n = r.parentMoveable, a = r.container; + this._checkUpdateRootContainer(), this._checkUpdateViewContainer(), this._updateTargets(), this._updateNativeEvents(), this._updateEvents(), this.updateCheckInput(), this._updateObserver(this.props), !a && !n && !this.state.isPersisted && (this.updateRect("", !1, !1), this.forceUpdate()); + }, e.prototype.componentDidUpdate = function(r) { + this._checkUpdateRootContainer(), this._checkUpdateViewContainer(), this._updateNativeEvents(), this._updateTargets(), this._updateEvents(), this.updateCheckInput(), this._updateObserver(r); + }, e.prototype.componentWillUnmount = function() { + var r, n; + this.isMoveableMounted = !1, this.isUnmounted = !0, this._emitter.off(), (r = this._reiszeObserver) === null || r === void 0 || r.disconnect(), (n = this._mutationObserver) === null || n === void 0 || n.disconnect(); + var a = this._viewContainer; + a && this._changeAbleViewClassNames([]), wr(this, !1), wr(this, !0); + var i = this.events; + for (var o in i) { + var s = i[o]; + s && s.destroy(); + } + }, e.prototype.getTargets = function() { + var r = this.props.target; + return r ? [r] : []; + }, e.prototype.getAble = function(r) { + var n = this.props.ables || []; + return ve(n, function(a) { + return a.name === r; + }); + }, e.prototype.getContainer = function() { + var r = this.props, n = r.parentMoveable, a = r.wrapperMoveable, i = r.container; + return i || a && a.getContainer() || n && n.getContainer() || this.controlBox.parentElement; + }, e.prototype.getControlBoxElement = function() { + return this.controlBox; + }, e.prototype.getDragElement = function() { + return this._dragTarget; + }, e.prototype.isMoveableElement = function(r) { + var n; + return r && (((n = r.getAttribute) === null || n === void 0 ? void 0 : n.call(r, "class")) || "").indexOf(Bi) > -1; + }, e.prototype.dragStart = function(r, n) { + n === void 0 && (n = r.target); + var a = this.targetGesto, i = this.controlGesto; + return a && ro(this)({ inputEvent: r }, n) ? a.isFlag() || a.triggerDragStart(r) : i && this.isMoveableElement(n) && (i.isFlag() || i.triggerDragStart(r)), this; + }, e.prototype.hitTest = function(r) { + var n = this.state, a = n.target, i = n.pos1, o = n.pos2, s = n.pos3, l = n.pos4, u = n.targetClientRect; + if (!a) + return 0; + var c; + if (on(r)) { + var f = r.getBoundingClientRect(); + c = { + left: f.left, + top: f.top, + width: f.width, + height: f.height + }; + } else + c = I({ width: 0, height: 0 }, r); + var d = c.left, p = c.top, h = c.width, g = c.height, x = Ja([i, o, l, s], u), y = _f(x, [ + [d, p], + [d + h, p], + [d + h, p + g], + [d, p + g] + ]), b = Kr(x); + return !y || !b ? 0 : Math.min(100, y / b * 100); + }, e.prototype.isInside = function(r, n) { + var a = this.state, i = a.target, o = a.pos1, s = a.pos2, l = a.pos3, u = a.pos4, c = a.targetClientRect; + return i ? $n([r, n], Ja([o, s, u, l], c)) : !1; + }, e.prototype.updateRect = function(r, n, a) { + a === void 0 && (a = !0); + var i = this.props, o = !i.parentPosition && !i.wrapperMoveable; + o && Pr(!0); + var s = i.parentMoveable, l = this.state, u = l.target || i.target, c = this.getContainer(), f = s ? s._rootContainer : this._rootContainer, d = gi(this.controlBox, u, c, c, f || c, this._getRequestStyles()); + if (!u && this._hasFirstTarget && i.persistData) { + var p = xs(i.persistData); + for (var h in p) + d[h] = p[h]; + } + o && Pr(), this.updateState(d, s ? !1 : a); + }, e.prototype.isDragging = function(r) { + var n, a, i = this.targetGesto, o = this.controlGesto; + if (i != null && i.isFlag()) { + if (!r) + return !0; + var s = i.getEventData(); + return !!(!((n = s[r]) === null || n === void 0) && n.isEventStart); + } + if (o != null && o.isFlag()) { + if (!r) + return !0; + var s = o.getEventData(); + return !!(!((a = s[r]) === null || a === void 0) && a.isEventStart); + } + return !1; + }, e.prototype.updateTarget = function(r) { + this.updateRect(r, !0); + }, e.prototype.getRect = function() { + var r = this.state, n = Ce(this.state), a = O(n, 4), i = a[0], o = a[1], s = a[2], l = a[3], u = ye(n), c = r.width, f = r.height, d = u.width, p = u.height, h = u.left, g = u.top, x = [r.left, r.top], y = wt(x, r.origin), b = wt(x, r.beforeOrigin), C = r.transformOrigin; + return { + width: d, + height: p, + left: h, + top: g, + pos1: i, + pos2: o, + pos3: s, + pos4: l, + offsetWidth: c, + offsetHeight: f, + beforeOrigin: b, + origin: y, + transformOrigin: C, + rotation: this.getRotation() + }; + }, e.prototype.getManager = function() { + return this; + }, e.prototype.stopDrag = function(r) { + if (!r || r === "target") { + var n = this.targetGesto; + (n == null ? void 0 : n.isIdle()) === !1 && pi(this, !1), n == null || n.stop(); + } + if (!r || r === "control") { + var n = this.controlGesto; + (n == null ? void 0 : n.isIdle()) === !1 && pi(this, !0), n == null || n.stop(); + } + }, e.prototype.getRotation = function() { + var r = this.state, n = r.pos1, a = r.pos2, i = r.direction; + return Ip(n, a, i); + }, e.prototype.request = function(r, n, a) { + n === void 0 && (n = {}); + var i = this, o = i.props, s = o.parentMoveable || o.wrapperMoveable || i, l = s.props.ables, u = o.groupable, c = ve(l, function(y) { + return y.name === r; + }); + if (this.isDragging() || !c || !c.request) + return { + request: function() { + return this; + }, + requestEnd: function() { + return this; + } + }; + var f = c.request(i), d = a || n.isInstant, p = f.isControl ? "controlAbles" : "targetAbles", h = "".concat(u ? "Group" : "").concat(f.isControl ? "Control" : ""), g = Z([], O(s[p]), !1), x = { + request: function(y) { + return en(i, g, ["drag"], h, "", I(I({}, f.request(y)), { requestAble: r, isRequest: !0 }), d), x; + }, + requestEnd: function() { + return en(i, g, ["drag"], h, "End", I(I({}, f.requestEnd()), { requestAble: r, isRequest: !0 }), d), x; + } + }; + return en(i, g, ["drag"], h, "Start", I(I({}, f.requestStart(n)), { requestAble: r, isRequest: !0 }), d), d ? x.request(n).requestEnd() : x; + }, e.prototype.getMoveables = function() { + return [this]; + }, e.prototype.destroy = function() { + this.componentWillUnmount(); + }, e.prototype.updateRenderPoses = function() { + var r = this.getState(), n = this.props, a = n.padding, i = r.originalBeforeOrigin, o = r.transformOrigin, s = r.allMatrix, l = r.is3d, u = r.pos1, c = r.pos2, f = r.pos3, d = r.pos4, p = r.left, h = r.top, g = r.isPersisted, x = n.zoom || 1; + if (!a && x <= 1) { + r.renderPoses = [ + u, + c, + f, + d + ], r.renderLines = [ + [u, c], + [c, d], + [d, f], + [f, u] + ]; + return; + } + var y = uu(a || {}), b = y.left, C = y.top, S = y.bottom, w = y.right, v = l ? 4 : 3, _ = []; + g ? _ = o : this.controlBox && n.groupable ? _ = i : _ = wt(i, [p, h]); + var M = Vn(v, lr(_.map(function(B) { + return -B; + }), v), s, lr(o, v)), T = me(M, u, [-b, -C], v), k = me(M, c, [w, -C], v), A = me(M, f, [-b, S], v), z = me(M, d, [w, S], v); + r.renderPoses = [ + T, + k, + A, + z + ], r.renderLines = [ + [T, k], + [k, z], + [z, A], + [A, T] + ]; + { + var R = x / 2; + r.renderLines = [ + [ + me(M, u, [-b - R, -C], v), + me(M, c, [w + R, -C], v) + ], + [ + me(M, c, [w, -C - R], v), + me(M, d, [w, S + R], v) + ], + [ + me(M, d, [w + R, S], v), + me(M, f, [-b - R, S], v) + ], + [ + me(M, f, [-b, S + R], v), + me(M, u, [-b, -C - R], v) + ] + ]; + } + }, e.prototype.checkUpdate = function() { + this._isPropTargetChanged = !1; + var r = this.props, n = r.target, a = r.container, i = r.parentMoveable, o = this.state, s = o.target, l = o.container; + if (!(!s && !n)) { + this.updateAbles(); + var u = !vi(s, n), c = u || !vi(l, a); + if (c) { + var f = a || this.controlBox; + f && this.unsetAbles(), this.updateState({ target: n, container: a }), !i && f && this.updateRect("End", !1, !1), this._isPropTargetChanged = u; + } + } + }, e.prototype.waitToChangeTarget = function() { + return new Promise(function() { + }); + }, e.prototype.triggerEvent = function(r, n) { + var a = this.props; + if (this._emitter.trigger(r, n), a.parentMoveable && n.isRequest && !n.isRequestChild) + return a.parentMoveable.triggerEvent(r, n, !0); + var i = a[r]; + return i && i(n); + }, e.prototype.useCSS = function(r, n) { + var a = this.props.customStyledMap, i = r + n; + return a[i] || (a[i] = pl(r, n)), a[i]; + }, e.prototype.getState = function() { + var r, n = this.props; + (n.target || !((r = n.targets) === null || r === void 0) && r.length) && (this._hasFirstTarget = !0); + var a = this.controlBox, i = n.persistData, o = n.firstRenderState; + if (o && !a) + return o; + if (!this._hasFirstTarget && i) { + var s = xs(i); + if (s) + return this.updateState(s, !1), this.state; + } + return this.state.isPersisted = !1, this.state; + }, e.prototype.updateSelectors = function() { + }, e.prototype.unsetAbles = function() { + var r = this; + this.targetAbles.forEach(function(n) { + n.unset && n.unset(r); + }); + }, e.prototype.updateAbles = function(r, n) { + r === void 0 && (r = this.props.ables), n === void 0 && (n = ""); + var a = this.props, i = a.triggerAblesSimultaneously, o = this.getEnabledAbles(r), s = "drag".concat(n, "Start"), l = "pinch".concat(n, "Start"), u = "drag".concat(n, "ControlStart"), c = zn(o, [s, l], i), f = zn(o, [u], i); + this.enabledAbles = o, this.targetAbles = c, this.controlAbles = f; + }, e.prototype.updateState = function(r, n) { + if (n) { + if (this.isUnmounted) + return; + this.setState(r); + } else { + var a = this.state; + for (var i in r) + a[i] = r[i]; + } + }, e.prototype.getEnabledAbles = function(r) { + r === void 0 && (r = this.props.ables); + var n = this.props; + return r.filter(function(a) { + return a && (a.always && n[a.name] !== !1 || n[a.name]); + }); + }, e.prototype.renderAbles = function() { + var r = this, n = this.props, a = n.triggerAblesSimultaneously, i = { + createElement: st.createElement + }; + return this.renderState = {}, _p(iu(zn(this.getEnabledAbles(), ["render"], a).map(function(o) { + var s = o.render; + return s(r, i) || []; + })).filter(function(o) { + return o; + }), function(o) { + var s = o.key; + return s; + }).map(function(o) { + return o[0]; + }); + }, e.prototype.updateCheckInput = function() { + this.targetGesto && (this.targetGesto.options.checkInput = this.props.checkInput); + }, e.prototype._getRequestStyles = function() { + var r = this.getEnabledAbles().reduce(function(n, a) { + var i, o, s = (o = (i = a.requestStyle) === null || i === void 0 ? void 0 : i.call(a)) !== null && o !== void 0 ? o : []; + return Z(Z([], O(n), !1), O(s), !1); + }, Z([], O(this.props.requestStyles || []), !1)); + return r; + }, e.prototype._updateObserver = function(r) { + this._updateResizeObserver(r), this._updateMutationObserver(r); + }, e.prototype._updateEvents = function() { + var r = this.targetAbles.length, n = this.controlAbles.length, a = this._dragTarget, i = !r && this.targetGesto || this._isTargetChanged(!0); + i && (wr(this, !1), this.updateState({ gestos: {} })), n || wr(this, !0), a && r && !this.targetGesto && (this.targetGesto = xu(this, a, "")), !this.controlGesto && n && (this.controlGesto = yu(this, "Control")); + }, e.prototype._updateTargets = function() { + var r = this.props; + this._prevPropTarget = this._propTarget, this._prevDragTarget = this._dragTarget, this._prevOriginalDragTarget = this._originalDragTarget, this._prevDragArea = r.dragArea, this._propTarget = r.target, this._originalDragTarget = r.dragTarget || r.target, this._dragTarget = Pe(this._originalDragTarget, !0); + }, e.prototype._renderLines = function() { + var r = this.props, n = r, a = n.zoom, i = n.hideDefaultLines, o = n.hideChildMoveableDefaultLines, s = n.parentMoveable; + if (i || s && o) + return []; + var l = this.getState(), u = { + createElement: st.createElement + }; + return l.renderLines.map(function(c, f) { + return sn(u, "", c[0], c[1], a, "render-line-".concat(f)); + }); + }, e.prototype._isTargetChanged = function(r) { + var n = this.props, a = n.dragTarget || n.target, i = this._prevOriginalDragTarget, o = this._prevDragArea, s = n.dragArea, l = !s && i !== a, u = (r || s) && o !== s; + return l || u || this._prevPropTarget != this._propTarget; + }, e.prototype._updateNativeEvents = function() { + var r = this, n = this.props, a = n.dragArea ? this.areaElement : this.state.target, i = this.events, o = Nr(i); + if (this._isTargetChanged()) + for (var s in i) { + var l = i[s]; + l && l.destroy(), i[s] = null; + } + if (a) { + var u = this.enabledAbles; + o.forEach(function(c) { + var f = zn(u, [c]), d = f.length > 0, p = i[c]; + if (!d) { + p && (p.destroy(), i[c] = null); + return; + } + p || (p = new iv(a, r, c), i[c] = p), p.setAbles(f); + }); + } + }, e.prototype._checkUpdateRootContainer = function() { + var r = this.props.rootContainer; + !this._rootContainer && r && (this._rootContainer = Pe(r, !0)); + }, e.prototype._checkUpdateViewContainer = function() { + var r = this.props.viewContainer; + !this._viewContainer && r && (this._viewContainer = Pe(r, !0)); + var n = this._viewContainer; + n && this._changeAbleViewClassNames(Z(Z([], O(this._getAbleViewClassNames()), !1), [ + this.isDragging() ? Bp : "" + ], !1)); + }, e.prototype._changeAbleViewClassNames = function(r) { + var n = this._viewContainer, a = au(r.filter(Boolean), function(u) { + return u; + }).map(function(u) { + var c = O(u, 1), f = c[0]; + return f; + }), i = this._viewClassNames, o = zi(i, a), s = o.removed, l = o.added; + s.forEach(function(u) { + el(n, i[u]); + }), l.forEach(function(u) { + Ti(n, a[u]); + }), this._viewClassNames = a; + }, e.prototype._getAbleViewClassNames = function() { + var r = this; + return (this.getEnabledAbles().map(function(n) { + var a; + return ((a = n.viewClassName) === null || a === void 0 ? void 0 : a.call(n, r)) || ""; + }).join(" ") + " ".concat(this._getAbleClassName("-view"))).split(/\s+/g); + }, e.prototype._getAbleClassName = function(r) { + var n = this; + r === void 0 && (r = ""); + var a = this.getEnabledAbles(), i = this.targetGesto, o = this.controlGesto, s = i != null && i.isFlag() ? i.getEventData() : {}, l = o != null && o.isFlag() ? o.getEventData() : {}; + return a.map(function(u) { + var c, f, d, p = u.name, h = ((c = u.className) === null || c === void 0 ? void 0 : c.call(u, n)) || ""; + return (!((f = s[p]) === null || f === void 0) && f.isEventStart || !((d = l[p]) === null || d === void 0) && d.isEventStart) && (h += " ".concat(ut("".concat(p).concat(r, "-dragging")))), h.trim(); + }).filter(Boolean).join(" "); + }, e.prototype._updateResizeObserver = function(r) { + var n, a = this.props, i = a.target, o = xe(this.getControlBoxElement()); + if (!o.ResizeObserver || !i || !a.useResizeObserver) { + (n = this._reiszeObserver) === null || n === void 0 || n.disconnect(); + return; + } + if (!(r.target === i && this._reiszeObserver)) { + var s = new o.ResizeObserver(this.checkUpdateRect); + s.observe(i, { + box: "border-box" + }), this._reiszeObserver = s; + } + }, e.prototype._updateMutationObserver = function(r) { + var n = this, a, i = this.props, o = i.target, s = xe(this.getControlBoxElement()); + if (!s.MutationObserver || !o || !i.useMutationObserver) { + (a = this._mutationObserver) === null || a === void 0 || a.disconnect(); + return; + } + if (!(r.target === o && this._mutationObserver)) { + var l = new s.MutationObserver(function(u) { + var c, f; + try { + for (var d = Lf(u), p = d.next(); !p.done; p = d.next()) { + var h = p.value; + h.type === "attributes" && h.attributeName === "style" && n.checkUpdateRect(); + } + } catch (g) { + c = { error: g }; + } finally { + try { + p && !p.done && (f = d.return) && f.call(d); + } finally { + if (c) throw c.error; + } + } + }); + l.observe(o, { + attributes: !0 + }), this._mutationObserver = l; + } + }, e.defaultProps = { + dragTargetSelf: !1, + target: null, + dragTarget: null, + container: null, + rootContainer: null, + origin: !0, + parentMoveable: null, + wrapperMoveable: null, + isWrapperMounted: !1, + parentPosition: null, + warpSelf: !1, + svgOrigin: "", + dragContainer: null, + useResizeObserver: !1, + useMutationObserver: !1, + preventDefault: !0, + preventRightClick: !0, + preventWheelClick: !0, + linePadding: 0, + controlPadding: 0, + ables: [], + pinchThreshold: 20, + dragArea: !1, + passDragArea: !1, + transformOrigin: "", + className: "", + zoom: 1, + triggerAblesSimultaneously: !1, + padding: {}, + pinchOutside: !0, + checkInput: !1, + dragFocusedInput: !1, + groupable: !1, + hideDefaultLines: !1, + cspNonce: "", + translateZ: 0, + cssStyled: null, + customStyledMap: {}, + props: {}, + stopPropagation: !1, + preventClickDefault: !1, + preventClickEventOnDrag: !0, + flushSync: $l, + firstRenderState: null, + persistData: null, + viewContainer: null, + requestStyles: [], + useAccuratePosition: !1 + }, e; +})(st.PureComponent), no = { + name: "groupable", + props: [ + "defaultGroupRotate", + "useDefaultGroupRotate", + "defaultGroupOrigin", + "groupable", + "groupableProps", + "targetGroups", + "hideChildMoveableDefaultLines" + ], + events: [], + render: function(t, e) { + var r, n = t.props, a = n.targets || [], i = t.getState(), o = i.left, s = i.top, l = i.isPersisted, u = n.zoom || 1, c = t.renderGroupRects, f = ((r = n.persistData) === null || r === void 0 ? void 0 : r.children) || []; + l ? a = f.map(function() { + return null; + }) : f = []; + var d = _r(t, "parentPosition", [o, s], function(h) { + return h.join(","); + }), p = _r(t, "requestStyles", t.getRequestChildStyles(), function(h) { + return h.join(","); + }); + return t.moveables = t.moveables.slice(0, a.length), Z(Z([], O(a.map(function(h, g) { + return e.createElement(Ar, { key: "moveable" + g, ref: Us(t, "moveables", g), target: h, origin: !1, requestStyles: p, cssStyled: n.cssStyled, customStyledMap: n.customStyledMap, useResizeObserver: n.useResizeObserver, useMutationObserver: n.useMutationObserver, hideChildMoveableDefaultLines: n.hideChildMoveableDefaultLines, parentMoveable: t, parentPosition: [o, s], persistData: f[g], zoom: u }); + })), !1), O(iu(c.map(function(h, g) { + var x = h.pos1, y = h.pos2, b = h.pos3, C = h.pos4, S = [x, y, b, C]; + return [ + [0, 1], + [1, 3], + [3, 2], + [2, 0] + ].map(function(w, v) { + var _ = O(w, 2), M = _[0], T = _[1]; + return sn(e, "", ct(S[M], d), ct(S[T], d), u, "group-rect-".concat(g, "-").concat(v)); + }); + }))), !1); + } +}, lv = pn("clickable", { + props: [ + "clickable" + ], + events: [ + "click", + "clickGroup" + ], + always: !0, + dragRelation: "weak", + // eslint-disable-next-line @typescript-eslint/no-unused-vars + dragStart: function() { + }, + dragControlStart: function() { + }, + dragGroupStart: function(t, e) { + e.datas.inputTarget = e.inputEvent && e.inputEvent.target; + }, + dragEnd: function(t, e) { + var r = t.props.target, n = e.inputEvent, a = e.inputTarget, i = t.isMoveableElement(a), o = !i && t.controlBox.contains(a); + if (!(!n || !a || e.isDrag || t.isMoveableElement(a) || o)) { + var s = r.contains(a); + rt(t, "onClick", bt(t, e, { + isDouble: e.isDouble, + inputTarget: a, + isTarget: r === a, + moveableTarget: t.props.target, + containsTarget: s + })); + } + }, + dragGroupEnd: function(t, e) { + var r = e.inputEvent, n = e.inputTarget; + if (!(!r || !n || e.isDrag || t.isMoveableElement(n) || e.datas.inputTarget === n)) { + var a = t.props.targets, i = a.indexOf(n), o = i > -1, s = !1; + i === -1 && (i = Ge(a, function(l) { + return l.contains(n); + }), s = i > -1), rt(t, "onClickGroup", bt(t, e, { + isDouble: e.isDouble, + targets: a, + inputTarget: n, + targetIndex: i, + isTarget: o, + containsTarget: s, + moveableTarget: a[i] + })); + } + }, + dragControlEnd: function(t, e) { + this.dragEnd(t, e); + }, + dragGroupControlEnd: function(t, e) { + this.dragEnd(t, e); + } +}); +function xr(t) { + var e = t.originalDatas.draggable; + return e || (t.originalDatas.draggable = {}, e = t.originalDatas.draggable), I(I({}, t), { datas: e }); +} +var uv = pn("edgeDraggable", { + css: [ + `.edge.edgeDraggable.line { +cursor: move; +}` + ], + render: function(t, e) { + var r = t.props, n = r.edgeDraggable; + return n ? kl(e, "edgeDraggable", n, t.getState().renderPoses, r.zoom) : []; + }, + dragCondition: function(t, e) { + var r, n = t.props, a = (r = e.inputEvent) === null || r === void 0 ? void 0 : r.target; + return !n.edgeDraggable || !a ? !1 : !n.draggable && Kt(a, ut("direction")) && Kt(a, ut("edge")) && Kt(a, ut("edgeDraggable")); + }, + dragStart: function(t, e) { + return ie.dragStart(t, xr(e)); + }, + drag: function(t, e) { + return ie.drag(t, xr(e)); + }, + dragEnd: function(t, e) { + return ie.dragEnd(t, xr(e)); + }, + dragGroupCondition: function(t, e) { + var r, n = t.props, a = (r = e.inputEvent) === null || r === void 0 ? void 0 : r.target; + return !n.edgeDraggable || !a ? !1 : !n.draggable && Kt(a, ut("direction")) && Kt(a, ut("line")); + }, + dragGroupStart: function(t, e) { + return ie.dragGroupStart(t, xr(e)); + }, + dragGroup: function(t, e) { + return ie.dragGroup(t, xr(e)); + }, + dragGroupEnd: function(t, e) { + return ie.dragGroupEnd(t, xr(e)); + }, + unset: function(t) { + return ie.unset(t); + } +}), Su = { + name: "individualGroupable", + props: [ + "individualGroupable", + "individualGroupableProps" + ], + events: [] +}, cv = [ + gu, + du, + pp, + Pp, + ie, + uv, + ui, + Op, + Ap, + Ud, + Fp, + Lp, + jp, + Qp, + Jp, + nv, + no, + Su, + lv, + fu, + mu +]; +function ys(t, e) { + var r = O(t, 3), n = r[0], a = r[1], i = r[2]; + return (n * e[0] + a * e[1] + i) / Math.sqrt(n * n + a * a); +} +function Bn(t, e) { + var r = O(t, 2), n = r[0], a = r[1]; + return -n * e[0] - a * e[1]; +} +function bs(t, e) { + return Math.max.apply(Math, Z([], O(t.map(function(r) { + var n = O(r, 4), a = n[0], i = n[1], o = n[2], s = n[3]; + return Math.max(a[e], i[e], o[e], s[e]); + })), !1)); +} +function Ss(t, e) { + return Math.min.apply(Math, Z([], O(t.map(function(r) { + var n = O(r, 4), a = n[0], i = n[1], o = n[2], s = n[3]; + return Math.min(a[e], i[e], o[e], s[e]); + })), !1)); +} +function fv(t, e) { + var r, n, a, i = [0, 0], o = [0, 0], s = [0, 0], l = [0, 0], u = 0, c = 0; + if (!t.length) + return { + pos1: i, + pos2: o, + pos3: s, + pos4: l, + minX: 0, + minY: 0, + maxX: 0, + maxY: 0, + width: u, + height: c, + rotation: e + }; + var f = gt(e, le); + if (f % 90) { + var d = f / 180 * Math.PI, p = Math.tan(d), h = -1 / p, g = [ii, Xo], x = [[0, 0], [0, 0]], y = [ii, Xo], b = [[0, 0], [0, 0]]; + t.forEach(function(Q) { + Q.forEach(function(H) { + var tt = ys([-p, 1, 0], H), U = ys([-h, 1, 0], H); + g[0] > tt && (x[0] = H, g[0] = tt), g[1] < tt && (x[1] = H, g[1] = tt), y[0] > U && (b[0] = H, y[0] = U), y[1] < U && (b[1] = H, y[1] = U); + }); + }); + var C = O(x, 2), S = C[0], w = C[1], v = O(b, 2), _ = v[0], M = v[1], T = [-p, 1, Bn([-p, 1], S)], k = [-p, 1, Bn([-p, 1], w)], A = [-h, 1, Bn([-h, 1], _)], z = [-h, 1, Bn([-h, 1], M)]; + r = O([ + [T, A], + [T, z], + [k, A], + [k, z] + ].map(function(Q) { + var H = O(Q, 2), tt = H[0], U = H[1]; + return Ai(tt, U)[0]; + }), 4), i = r[0], o = r[1], s = r[2], l = r[3], u = y[1] - y[0], c = g[1] - g[0]; + } else { + var R = Ss(t, 0), B = Ss(t, 1), N = bs(t, 0), L = bs(t, 1); + if (i = [R, B], o = [N, B], s = [R, L], l = [N, L], u = N - R, c = L - B, f % 180) { + var V = [s, i, l, o]; + n = O(V, 4), i = n[0], o = n[1], s = n[2], l = n[3], u = L - B, c = N - R; + } + } + if (f % 360 > 180) { + var V = [l, s, o, i]; + a = O(V, 4), i = a[0], o = a[1], s = a[2], l = a[3]; + } + var G = ur([i, o, s, l]), W = G.minX, $ = G.minY, j = G.maxX, J = G.maxY; + return { + pos1: i, + pos2: o, + pos3: s, + pos4: l, + width: u, + height: c, + minX: W, + minY: $, + maxX: j, + maxY: J, + rotation: e + }; +} +function Cu(t, e) { + var r = e.map(function(n) { + if (Yt(n)) { + var a = Cu(t, n), i = a.length; + return i > 1 ? a : i === 1 ? a[0] : null; + } else { + var o = ve(t, function(s) { + var l = s.manager; + return l.props.target === n; + }); + return o ? (o.finded = !0, o.manager) : null; + } + }).filter(Boolean); + return r.length === 1 && Yt(r[0]) ? r[0] : r; +} +var dv = /* @__PURE__ */ (function(t) { + dn(e, t); + function e() { + var r = t !== null && t.apply(this, arguments) || this; + return r.differ = new sl(), r.moveables = [], r.transformOrigin = "50% 50%", r.renderGroupRects = [], r._targetGroups = [], r._hasFirstTargets = !1, r; + } + return e.prototype.componentDidMount = function() { + t.prototype.componentDidMount.call(this); + }, e.prototype.checkUpdate = function() { + this._isPropTargetChanged = !1, this.updateAbles(); + }, e.prototype.getTargets = function() { + return this.props.targets; + }, e.prototype.updateRect = function(r, n, a) { + var i; + a === void 0 && (a = !0); + var o = this.state; + if (!this.controlBox || o.isPersisted) + return; + Pr(!0), this.moveables.forEach(function(lt) { + lt.updateRect(r, !1, !1); + }); + var s = this.props, l = this.moveables, u = o.target || s.target, c = l.map(function(lt) { + return { finded: !1, manager: lt }; + }), f = this.props.targetGroups || [], d = Cu(c, f), p = s.useDefaultGroupRotate; + d.push.apply(d, Z([], O(c.filter(function(lt) { + var ft = lt.finded; + return !ft; + }).map(function(lt) { + var ft = lt.manager; + return ft; + })), !1)); + var h = [], g = !n || r !== "" && s.updateGroup, x = s.defaultGroupRotate || 0; + if (!this._hasFirstTargets) { + var y = (i = s.persistData) === null || i === void 0 ? void 0 : i.rotation; + y != null && (x = y); + } + function b(lt, ft, xt) { + var q = lt.map(function(Mt) { + if (Yt(Mt)) { + var ht = b(Mt, ft), Dt = [ht.pos1, ht.pos2, ht.pos3, ht.pos4]; + return h.push(ht), { poses: Dt, rotation: ht.rotation }; + } else + return { + poses: Ce(Mt.state), + rotation: Mt.getRotation() + }; + }), nt = q.map(function(Mt) { + var ht = Mt.rotation; + return ht; + }), Et = 0, pt = nt[0], vt = nt.every(function(Mt) { + return Math.abs(pt - Mt) < 0.1; + }); + g ? Et = !p && vt ? pt : x : Et = !p && !xt && vt ? pt : ft; + var St = q.map(function(Mt) { + var ht = Mt.poses; + return ht; + }), _t = fv(St, Et); + return _t; + } + var C = b(d, this.rotation, !0); + g && (this.rotation = C.rotation, this.transformOrigin = s.defaultGroupOrigin || "50% 50%", this.scale = [1, 1]), this._targetGroups = f, this.renderGroupRects = h; + var S = this.transformOrigin, w = this.rotation, v = this.scale, _ = C.width, M = C.height, T = C.minX, k = C.minY, A = Rp([ + [0, 0], + [_, 0], + [0, M], + [_, M] + ], Qi(S, _, M), this.rotation / 180 * Math.PI), z = ur(A.result), R = z.minX, B = z.minY, N = " rotate(".concat(w, "deg)") + " scale(".concat(oe(v[0]), ", ").concat(oe(v[1]), ")"), L = "translate(".concat(-R, "px, ").concat(-B, "px)").concat(N); + this.controlBox.style.transform = "translate3d(".concat(T, "px, ").concat(k, "px, ").concat(this.props.translateZ || 0, ")"), u.style.cssText += "left:0px;top:0px;" + "transform-origin:".concat(S, ";") + "width:".concat(_, "px;height:").concat(M, "px;") + "transform: ".concat(L), o.width = _, o.height = M; + var V = this.getContainer(), G = gi(this.controlBox, u, this.controlBox, this.getContainer(), this._rootContainer || V, []), W = [G.left, G.top], $ = O(Ce(G), 4), j = $[0], J = $[1], Q = $[2], H = $[3], tt = ur([j, J, Q, H]), U = [tt.minX, tt.minY], et = oe(v[0] * v[1]); + G.pos1 = ct(j, U), G.pos2 = ct(J, U), G.pos3 = ct(Q, U), G.pos4 = ct(H, U), G.left = T - G.left + U[0], G.top = k - G.top + U[1], G.origin = ct(wt(W, G.origin), U), G.beforeOrigin = ct(wt(W, G.beforeOrigin), U), G.originalBeforeOrigin = wt(W, G.originalBeforeOrigin), G.transformOrigin = ct(wt(W, G.transformOrigin), U), u.style.transform = "translate(".concat(-R - U[0], "px, ").concat(-B - U[1], "px)") + N, Pr(), this.updateState(I(I({}, G), { posDelta: U, direction: et, beforeDirection: et }), a); + }, e.prototype.getRect = function() { + return I(I({}, t.prototype.getRect.call(this)), { children: this.moveables.map(function(r) { + return r.getRect(); + }) }); + }, e.prototype.triggerEvent = function(r, n, a) { + if (a || r.indexOf("Group") > -1) + return t.prototype.triggerEvent.call(this, r, n); + this._emitter.trigger(r, n); + }, e.prototype.getRequestChildStyles = function() { + var r = this.getEnabledAbles().reduce(function(n, a) { + var i, o, s = (o = (i = a.requestChildStyle) === null || i === void 0 ? void 0 : i.call(a)) !== null && o !== void 0 ? o : []; + return Z(Z([], O(n), !1), O(s), !1); + }, []); + return r; + }, e.prototype.getMoveables = function() { + return Z([], O(this.moveables), !1); + }, e.prototype.updateAbles = function() { + t.prototype.updateAbles.call(this, Z(Z([], O(this.props.ables), !1), [no], !1), "Group"); + }, e.prototype._updateTargets = function() { + t.prototype._updateTargets.call(this), this._originalDragTarget = this.props.dragTarget || this.areaElement, this._dragTarget = Pe(this._originalDragTarget, !0); + }, e.prototype._updateEvents = function() { + var r = this.state, n = this.props, a = this._prevDragTarget, i = n.dragTarget || this.areaElement, o = n.targets, s = this.differ.update(o), l = s.added, u = s.changed, c = s.removed, f = l.length || c.length; + (f || this._prevOriginalDragTarget !== this._originalDragTarget) && (wr(this, !1), wr(this, !0), this.updateState({ gestos: {} })), a !== i && (r.target = null), r.target || (r.target = this.areaElement, this.controlBox.style.display = "block"), r.target && (this.targetGesto || (this.targetGesto = xu(this, this._dragTarget, "Group")), this.controlGesto || (this.controlGesto = yu(this, "GroupControl"))); + var d = !vi(r.container, n.container); + d && (r.container = n.container), (d || f || this.transformOrigin !== (n.defaultGroupOrigin || "50% 50%") || u.length || o.length && !lu(this._targetGroups, n.targetGroups || [])) && (this.updateRect(), this._hasFirstTargets = !0), this._isPropTargetChanged = !!f; + }, e.prototype._updateObserver = function() { + }, e.defaultProps = I(I({}, Ar.defaultProps), { transformOrigin: ["50%", "50%"], groupable: !0, dragArea: !0, keepRatio: !0, targets: [], defaultGroupRotate: 0, defaultGroupOrigin: "50% 50%" }), e; +})(Ar), pv = /* @__PURE__ */ (function(t) { + dn(e, t); + function e() { + var r = t !== null && t.apply(this, arguments) || this; + return r.moveables = [], r; + } + return e.prototype.render = function() { + var r = this, n, a = this.props, i = a.cspNonce, o = a.cssStyled, s = a.persistData, l = a.targets || [], u = l.length, c = this.isUnmounted || !u, f = (n = s == null ? void 0 : s.children) !== null && n !== void 0 ? n : []; + return c && !u && f.length ? l = f.map(function() { + return null; + }) : c || (f = []), st.createElement(o, { cspNonce: i, ref: qe(this, "controlBox"), className: ut("control-box") }, l.map(function(d, p) { + var h, g, x = (g = (h = a.individualGroupableProps) === null || h === void 0 ? void 0 : h.call(a, d, p)) !== null && g !== void 0 ? g : {}; + return st.createElement(Ar, I({ key: "moveable" + p, ref: Us(r, "moveables", p) }, a, x, { target: d, wrapperMoveable: r, isWrapperMounted: r.isMoveableMounted, persistData: f[p] })); + })); + }, e.prototype.componentDidMount = function() { + }, e.prototype.componentDidUpdate = function() { + }, e.prototype.getTargets = function() { + return this.props.targets; + }, e.prototype.updateRect = function(r, n, a) { + a === void 0 && (a = !0), Pr(!0), this.moveables.forEach(function(i) { + i.updateRect(r, n, a); + }), Pr(); + }, e.prototype.getRect = function() { + return I(I({}, t.prototype.getRect.call(this)), { children: this.moveables.map(function(r) { + return r.getRect(); + }) }); + }, e.prototype.request = function(r, n, a) { + n === void 0 && (n = {}); + var i = this.moveables.map(function(l) { + return l.request(r, I(I({}, n), { isInstant: !1 }), !1); + }), o = a || n.isInstant, s = { + request: function(l) { + return i.forEach(function(u) { + return u.request(l); + }), this; + }, + requestEnd: function() { + return i.forEach(function(l) { + return l.requestEnd(); + }), this; + } + }; + return o ? s.request(n).requestEnd() : s; + }, e.prototype.dragStart = function(r, n) { + n === void 0 && (n = r.target); + var a = n, i = ve(this.moveables, function(o) { + var s = o.getTargets()[0], l = o.getControlBoxElement(), u = o.getDragElement(); + return !s || !u ? !1 : u === a || u.contains(a) || u !== s && s === a || s.contains(a) || l === a || l.contains(a); + }); + return i && i.dragStart(r, n), this; + }, e.prototype.hitTest = function() { + return 0; + }, e.prototype.isInside = function() { + return !1; + }, e.prototype.isDragging = function() { + return !1; + }, e.prototype.getDragElement = function() { + return null; + }, e.prototype.getMoveables = function() { + return Z([], O(this.moveables), !1); + }, e.prototype.updateRenderPoses = function() { + }, e.prototype.checkUpdate = function() { + }, e.prototype.triggerEvent = function() { + }, e.prototype.updateAbles = function() { + }, e.prototype._updateEvents = function() { + }, e.prototype._updateObserver = function() { + }, e; +})(Ar); +function Eu(t, e) { + var r = []; + return t.forEach(function(n) { + if (n) { + if (be(n)) { + e[n] && r.push.apply(r, Z([], O(e[n]), !1)); + return; + } + Yt(n) ? r.push.apply(r, Z([], O(Eu(n, e)), !1)) : r.push(n); + } + }), r; +} +function Du(t, e) { + var r = []; + return t.forEach(function(n) { + if (n) { + if (be(n)) { + e[n] && r.push.apply(r, Z([], O(e[n]), !1)); + return; + } + Yt(n) ? r.push(Du(n, e)) : r.push(n); + } + }), r; +} +function wu(t, e) { + return t.length !== e.length || t.some(function(r, n) { + var a = e[n]; + return !r && !a ? !1 : r != a ? Yt(r) && Yt(a) ? wu(r, a) : !0 : !1; + }); +} +var vv = /* @__PURE__ */ (function(t) { + dn(e, t); + function e() { + var r = t !== null && t.apply(this, arguments) || this; + return r.refTargets = [], r.selectorMap = {}, r._differ = new sl(), r._elementTargets = [], r._tmpRefTargets = [], r._tmpSelectorMap = {}, r._onChangeTargets = null, r; + } + return e.makeStyled = function() { + var r = {}, n = this.getTotalAbles(); + n.forEach(function(i) { + var o = i.css; + o && o.forEach(function(s) { + r[s] = !0; + }); + }); + var a = Nr(r).join(` +`); + this.defaultStyled = pl("div", Bc(Bi, Jf + a)); + }, e.getTotalAbles = function() { + return Z([du, no, Su, fu], O(this.defaultAbles), !1); + }, e.prototype.render = function() { + var r, n = this.constructor; + n.defaultStyled || n.makeStyled(); + var a = this.props, i = a.ables, o = a.props, s = Gf(a, ["ables", "props"]), l = O(this._updateRefs(!0), 2), u = l[0], c = l[1], f = Eu(u, c), d = f.length > 1, p = n.getTotalAbles(), h = Z(Z([], O(p), !1), O(i || []), !1), g = I(I(I({}, s), o || {}), { ables: h, cssStyled: n.defaultStyled, customStyledMap: n.customStyledMap }); + this._elementTargets = f; + var x = null, y = this.moveable, b = s.persistData; + if (b != null && b.children && (d = !0), s.individualGroupable) + return st.createElement(pv, I({ key: "individual-group", ref: qe(this, "moveable") }, g, { target: null, targets: f })); + if (d) { + var C = Du(u, c); + if (y && !y.props.groupable && !y.props.individualGroupable) { + var S = y.props.target; + S && f.indexOf(S) > -1 && (x = I({}, y.state)); + } + return st.createElement(dv, I({ key: "group", ref: qe(this, "moveable") }, g, (r = s.groupableProps) !== null && r !== void 0 ? r : {}, { target: null, targets: f, targetGroups: C, firstRenderState: x })); + } else { + var w = f[0]; + if (y && (y.props.groupable || y.props.individualGroupable)) { + var v = y.moveables || [], _ = ve(v, function(M) { + return M.props.target === w; + }); + _ && (x = I({}, _.state)); + } + return st.createElement(Ar, I({ key: "single", ref: qe(this, "moveable") }, g, { target: w, firstRenderState: x })); + } + }, e.prototype.componentDidMount = function() { + this._checkChangeTargets(); + }, e.prototype.componentDidUpdate = function() { + this._checkChangeTargets(); + }, e.prototype.componentWillUnmount = function() { + this.selectorMap = {}, this.refTargets = []; + }, e.prototype.getTargets = function() { + var r, n; + return (n = (r = this.moveable) === null || r === void 0 ? void 0 : r.getTargets()) !== null && n !== void 0 ? n : []; + }, e.prototype.updateSelectors = function() { + this.selectorMap = {}, this._updateRefs(), this.forceUpdate(); + }, e.prototype.waitToChangeTarget = function() { + var r = this, n; + return this._onChangeTargets = function() { + r._onChangeTargets = null, n(); + }, new Promise(function(a) { + n = a; + }); + }, e.prototype.waitToChangeTargets = function() { + return this.waitToChangeTarget(); + }, e.prototype.getManager = function() { + return this.moveable; + }, e.prototype.getMoveables = function() { + return this.moveable.getMoveables(); + }, e.prototype.getDragElement = function() { + return this.moveable.getDragElement(); + }, e.prototype._updateRefs = function(r) { + var n = this.refTargets, a = Ji(this.props.target || this.props.targets), i = typeof document < "u", o = wu(n, a), s = this.selectorMap, l = {}; + return this.refTargets.forEach(function u(c) { + if (be(c)) { + var f = s[c]; + f ? l[c] = s[c] : i && (o = !0, l[c] = [].slice.call(document.querySelectorAll(c))); + } else Yt(c) && c.forEach(u); + }), this._tmpRefTargets = a, this._tmpSelectorMap = l, [ + a, + l, + !r && o + ]; + }, e.prototype._checkChangeTargets = function() { + var r, n, a; + this.refTargets = this._tmpRefTargets, this.selectorMap = this._tmpSelectorMap; + var i = this._differ.update(this._elementTargets), o = i.added, s = i.removed, l = o.length || s.length; + l && ((n = (r = this.props).onChangeTargets) === null || n === void 0 || n.call(r, { + moveable: this.moveable, + targets: this._elementTargets + }), (a = this._onChangeTargets) === null || a === void 0 || a.call(this)); + var u = O(this._updateRefs(), 3), c = u[0], f = u[1], d = u[2]; + this.refTargets = c, this.selectorMap = f, d && this.forceUpdate(); + }, e.defaultAbles = [], e.customStyledMap = {}, e.defaultStyled = null, Ff([ + Ks(ed) + ], e.prototype, "moveable", void 0), e; +})(st.PureComponent), hv = /* @__PURE__ */ (function(t) { + dn(e, t); + function e() { + return t !== null && t.apply(this, arguments) || this; + } + return e.defaultAbles = cv, e; +})(vv), mi = function(t, e) { + return mi = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(r, n) { + r.__proto__ = n; + } || function(r, n) { + for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (r[a] = n[a]); + }, mi(t, e); +}; +function gv(t, e) { + if (typeof e != "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null"); + mi(t, e); + function r() { + this.constructor = t; + } + t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r()); +} +function mv(t, e) { + return e = { + exports: {} + }, t(e, e.exports), e.exports; +} +var gn = mv(function(t, e) { + function r(l) { + if (l && typeof l == "object") { + var u = l.which || l.keyCode || l.charCode; + u && (l = u); + } + if (typeof l == "number") return o[l]; + var c = String(l), f = n[c.toLowerCase()]; + if (f) return f; + var f = a[c.toLowerCase()]; + if (f) return f; + if (c.length === 1) return c.charCodeAt(0); + } + r.isEventKey = function(u, c) { + if (u && typeof u == "object") { + var f = u.which || u.keyCode || u.charCode; + if (f == null) + return !1; + if (typeof c == "string") { + var d = n[c.toLowerCase()]; + if (d) + return d === f; + var d = a[c.toLowerCase()]; + if (d) + return d === f; + } else if (typeof c == "number") + return c === f; + return !1; + } + }, e = t.exports = r; + var n = e.code = e.codes = { + backspace: 8, + tab: 9, + enter: 13, + shift: 16, + ctrl: 17, + alt: 18, + "pause/break": 19, + "caps lock": 20, + esc: 27, + space: 32, + "page up": 33, + "page down": 34, + end: 35, + home: 36, + left: 37, + up: 38, + right: 39, + down: 40, + insert: 45, + delete: 46, + command: 91, + "left command": 91, + "right command": 93, + "numpad *": 106, + "numpad +": 107, + "numpad -": 109, + "numpad .": 110, + "numpad /": 111, + "num lock": 144, + "scroll lock": 145, + "my computer": 182, + "my calculator": 183, + ";": 186, + "=": 187, + ",": 188, + "-": 189, + ".": 190, + "/": 191, + "`": 192, + "[": 219, + "\\": 220, + "]": 221, + "'": 222 + }, a = e.aliases = { + windows: 91, + "⇧": 16, + "⌥": 18, + "⌃": 17, + "⌘": 91, + ctl: 17, + control: 17, + option: 18, + pause: 19, + break: 19, + caps: 20, + return: 13, + escape: 27, + spc: 32, + spacebar: 32, + pgup: 33, + pgdn: 34, + ins: 45, + del: 46, + cmd: 91 + }; + /*! + * Programatically add the following + */ + for (i = 97; i < 123; i++) n[String.fromCharCode(i)] = i - 32; + for (var i = 48; i < 58; i++) n[i - 48] = i; + for (i = 1; i < 13; i++) n["f" + i] = i + 111; + for (i = 0; i < 10; i++) n["numpad " + i] = i + 96; + var o = e.names = e.title = {}; + for (i in n) o[n[i]] = i; + for (var s in a) + n[s] = a[s]; +}); +gn.code; +gn.codes; +gn.aliases; +var xv = gn.names; +gn.title; +var Cs = { + "+": "plus", + "left command": "meta", + "right command": "meta" +}, Es = { + shift: 1, + ctrl: 2, + alt: 3, + meta: 4 +}; +function _u(t, e) { + var r = (xv[t] || e || "").toLowerCase(); + for (var n in Cs) + r = r.replace(n, Cs[n]); + return r.replace(/\s/g, ""); +} +function Mu(t, e) { + e === void 0 && (e = _u(t.keyCode, t.key)); + var r = yv(t); + return r.indexOf(e) === -1 && r.push(e), r.filter(Boolean); +} +function yv(t) { + var e = [t.shiftKey && "shift", t.ctrlKey && "ctrl", t.altKey && "alt", t.metaKey && "meta"]; + return e.filter(Boolean); +} +function Ds(t) { + var e = t.slice(); + return e.sort(function(r, n) { + var a = Es[r] || 5, i = Es[n] || 5; + return a - i; + }), e; +} +var ws, bv = /* @__PURE__ */ (function(t) { + gv(e, t); + function e(n) { + n === void 0 && (n = window); + var a = t.call(this) || this; + return a.container = n, a.ctrlKey = !1, a.altKey = !1, a.shiftKey = !1, a.metaKey = !1, a.clear = function() { + return a.ctrlKey = !1, a.altKey = !1, a.shiftKey = !1, a.metaKey = !1, a; + }, a.keydownEvent = function(i) { + a.triggerEvent("keydown", i); + }, a.keyupEvent = function(i) { + a.triggerEvent("keyup", i); + }, a.blur = function() { + a.clear(), a.trigger("blur"); + }, $t(n, "blur", a.blur), $t(n, "keydown", a.keydownEvent), $t(n, "keyup", a.keyupEvent), a; + } + var r = e.prototype; + return Object.defineProperty(e, "global", { + /** + */ + get: function() { + return ws || (ws = new e()); + }, + enumerable: !1, + configurable: !0 + }), e.setGlobal = function() { + return this.global; + }, r.destroy = function() { + var n = this.container; + this.clear(), this.off(), Wt(n, "blur", this.blur), Wt(n, "keydown", this.keydownEvent), Wt(n, "keyup", this.keyupEvent); + }, r.keydown = function(n, a) { + return this.addEvent("keydown", n, a); + }, r.offKeydown = function(n, a) { + return this.removeEvent("keydown", n, a); + }, r.offKeyup = function(n, a) { + return this.removeEvent("keyup", n, a); + }, r.keyup = function(n, a) { + return this.addEvent("keyup", n, a); + }, r.addEvent = function(n, a, i) { + return Yt(a) ? this.on("".concat(n, ".").concat(Ds(a).join(".")), i) : be(a) ? this.on("".concat(n, ".").concat(a), i) : this.on(n, a), this; + }, r.removeEvent = function(n, a, i) { + return Yt(a) ? this.off("".concat(n, ".").concat(Ds(a).join(".")), i) : be(a) ? this.off("".concat(n, ".").concat(a), i) : this.off(n, a), this; + }, r.triggerEvent = function(n, a) { + this.ctrlKey = a.ctrlKey, this.shiftKey = a.shiftKey, this.altKey = a.altKey, this.metaKey = a.metaKey; + var i = _u(a.keyCode, a.key), o = i === "ctrl" || i === "shift" || i === "meta" || i === "alt", s = { + key: i, + isToggle: o, + inputEvent: a, + keyCode: a.keyCode, + ctrlKey: a.ctrlKey, + altKey: a.altKey, + shiftKey: a.shiftKey, + metaKey: a.metaKey + }; + this.trigger(n, s), this.trigger("".concat(n, ".").concat(i), s); + var l = Mu(a, i); + l.length > 1 && this.trigger("".concat(n, ".").concat(l.join(".")), s); + }, e; +})(fn), xi = function(t, e) { + return xi = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(r, n) { + r.__proto__ = n; + } || function(r, n) { + for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (r[a] = n[a]); + }, xi(t, e); +}; +function ku(t, e) { + if (typeof e != "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null"); + xi(t, e); + function r() { + this.constructor = t; + } + t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r()); +} +var Vt = function() { + return Vt = Object.assign || function(e) { + for (var r, n = 1, a = arguments.length; n < a; n++) { + r = arguments[n]; + for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]); + } + return e; + }, Vt.apply(this, arguments); +}; +function Sv(t, e) { + var r = {}; + for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]); + if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var a = 0, n = Object.getOwnPropertySymbols(t); a < n.length; a++) + e.indexOf(n[a]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[a]) && (r[n[a]] = t[n[a]]); + return r; +} +function Cv(t, e, r, n) { + var a = arguments.length, i = a < 3 ? e : n === null ? n = Object.getOwnPropertyDescriptor(e, r) : n, o; + if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(t, e, r, n); + else for (var s = t.length - 1; s >= 0; s--) (o = t[s]) && (i = (a < 3 ? o(i) : a > 3 ? o(e, r, i) : o(e, r)) || i); + return a > 3 && i && Object.defineProperty(e, r, i), i; +} +function rn(t, e, r) { + for (var n = 0, a = e.length, i; n < a; n++) + (i || !(n in e)) && (i || (i = Array.prototype.slice.call(e, 0, n)), i[n] = e[n]); + return t.concat(i || Array.prototype.slice.call(e)); +} +function Ev(t) { + if ("touches" in t) { + var e = t.touches[0] || t.changedTouches[0]; + return { + clientX: e.clientX, + clientY: e.clientY + }; + } else + return { + clientX: t.clientX, + clientY: t.clientY + }; +} +function Dv(t) { + if (typeof Map > "u") + return t.filter(function(r, n) { + return t.indexOf(r) === n; + }); + var e = /* @__PURE__ */ new Map(); + return t.filter(function(r) { + return e.has(r) ? !1 : (e.set(r, !0), !0); + }); +} +function wv(t, e, r) { + var n = _e(t); + return n.elementFromPoint && n.elementFromPoint(e, r) || null; +} +function Tu(t, e, r) { + var n = t.tag, a = t.children, i = t.attributes, o = t.className, s = t.style, l = e || _e(r).createElement(n); + for (var u in i) + l.setAttribute(u, i[u]); + var c = l.children; + if (a.forEach(function(d, p) { + Tu(d, c[p], l); + }), o && o.split(/\s+/g).forEach(function(d) { + d && !Kt(l, d) && Ti(l, d); + }), s) { + var f = l.style; + for (var u in s) + f[u] = s[u]; + } + return !e && r && r.appendChild(l), l; +} +function _v(t, e) { + for (var r = [], n = 2; n < arguments.length; n++) + r[n - 2] = arguments[n]; + var a = e || {}, i = a.className, o = i === void 0 ? "" : i, s = a.style, l = s === void 0 ? {} : s, u = Sv(a, ["className", "style"]); + return { + tag: t, + className: o, + style: l, + attributes: u, + children: r + }; +} +function Na(t, e, r) { + t !== e && r(t, e); +} +function _s(t, e, r) { + var n; + r === void 0 && (r = t.data.boundArea); + var a = t.distX, i = a === void 0 ? 0 : a, o = t.distY, s = o === void 0 ? 0 : o, l = t.data, u = l.startX, c = l.startY; + if (e > 0) { + var f = Math.sqrt((i * i + s * s) / (1 + e * e)), d = e * f; + i = (i >= 0 ? 1 : -1) * d, s = (s >= 0 ? 1 : -1) * f; + } + var p = Math.abs(i), h = Math.abs(s), g = i < 0 ? u - r.left : r.right - u, x = s < 0 ? c - r.top : r.bottom - c; + n = ki([p, h], [0, 0], [g, x], !!e), p = n[0], h = n[1], i = (i >= 0 ? 1 : -1) * p, s = (s >= 0 ? 1 : -1) * h; + var y = Math.min(0, i), b = Math.min(0, s), C = u + y, S = c + b; + return { + left: C, + top: S, + right: C + p, + bottom: S + h, + width: p, + height: h + }; +} +function jn(t) { + var e = t.getBoundingClientRect(), r = e.left, n = e.top, a = e.width, i = e.height; + return { + pos1: [r, n], + pos2: [r + a, n], + pos3: [r, n + i], + pos4: [r + a, n + i] + }; +} +function Ms(t, e, r) { + var n = Sr(t, e), a = n.list, i = n.prevList, o = n.added, s = n.removed, l = n.maintained; + return rn(rn(rn([], o.map(function(u) { + return a[u]; + }), !0), s.map(function(u) { + return i[u]; + }), !0), r ? l.map(function(u) { + var c = u[1]; + return a[c]; + }) : []); +} +function ks(t) { + for (var e = 0, r = t.length, n = 1; n < r; ++n) + e = Math.max(Re(t[n], t[n - 1]), e); + return e; +} +var Iu = dl(` +:host { + position: fixed; + display: none; + border: 1px solid #4af; + background: rgba(68, 170, 255, 0.5); + pointer-events: none; + will-change: transform; + z-index: 100; +} +`), yi = "selecto-selection ".concat(Iu.className), ao = ["className", "boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "continueSelectWithoutDeselect", "toggleContinueSelect", "toggleContinueSelectWithoutDeselect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio", "getElementRect", "preventDragFromInside", "rootContainer", "dragCondition", "clickBySelectEnd", "checkOverflow", "innerScrollOptions"], Mv = rn([ + // ignore target, container, + "dragContainer", + "cspNonce", + "preventClickEventOnDrag", + "preventClickEventOnDragStart", + "preventRightClick" +], ao), Ru = ["dragStart", "drag", "dragEnd", "selectStart", "select", "selectEnd", "keydown", "keyup", "scroll", "innerScroll"], kv = ["clickTarget", "getSelectableElements", "setSelectedTargets", "getElementPoints", "getSelectedTargets", "findSelectableTargets", "triggerDragStart", "checkScroll", "selectTargetsByPoints", "setSelectedTargetsByPoints"], Tv = /* @__PURE__ */ (function(t) { + ku(e, t); + function e(n) { + n === void 0 && (n = {}); + var a = t.call(this) || this; + a.selectedTargets = [], a.dragScroll = new ll(), a._onDragStart = function(s, l) { + var u = s.data, c = s.clientX, f = s.clientY, d = s.inputEvent, p = a.options, h = p.selectFromInside, g = p.selectByClick, x = p.rootContainer, y = p.boundContainer, b = p.preventDragFromInside, C = b === void 0 ? !0 : b, S = p.clickBySelectEnd, w = p.dragCondition; + if (w && !w(s)) { + s.stop(); + return; + } + u.data = {}; + var v = xe(a.container); + u.innerWidth = v.innerWidth, u.innerHeight = v.innerHeight, a.findSelectableTargets(u), u.startSelectedTargets = a.selectedTargets, u.scaleMatrix = Oi(), u.containerX = 0, u.containerY = 0; + var _ = a.container, M = { + left: -1 / 0, + top: -1 / 0, + right: 1 / 0, + bottom: 1 / 0 + }; + if (x) { + var T = a.container.getBoundingClientRect(); + u.containerX = T.left, u.containerY = T.top, u.scaleMatrix = cf(a.container, x); + } + if (y) { + var k = pe(y) && "element" in y ? Vt({ + left: !0, + top: !0, + bottom: !0, + right: !0 + }, y) : { + element: y, + left: !0, + top: !0, + bottom: !0, + right: !0 + }, A = k.element, z = void 0; + if (A) { + be(A) ? z = _e(_).querySelector(A) : A === !0 ? z = a.container : z = A; + var R = z.getBoundingClientRect(); + k.left && (M.left = R.left), k.top && (M.top = R.top), k.right && (M.right = R.right), k.bottom && (M.bottom = R.bottom); + } + } + u.boundArea = M; + var B = { + left: c, + top: f, + right: c, + bottom: f, + width: 0, + height: 0 + }, N = [], L = g && !S, V = !1; + if (!h || L) { + var G = a._findElement( + l || d.target, + // elementFromPoint(clientX, clientY), + u.selectableTargets + ); + V = !!G, L && (N = G ? [G] : []); + } + var W = !h && V; + if (W && !g) + return s.stop(), !1; + var $ = d.type, j = $ === "mousedown" || $ === "touchstart", J = !s.isClick && j ? a.emit("dragStart", Vt(Vt({}, s), { + data: u.data + })) : !0; + if (!J) + return s.stop(), !1; + if (a.continueSelect ? (N = Ms(a.selectedTargets, N, a.continueSelectWithoutDeselect), u.startPassedTargets = a.selectedTargets) : u.startPassedTargets = [], a._select(N, B, s, !0, W && g && !S && C), u.startX = c, u.startY = f, u.selectFlag = !1, u.preventDragFromInside = !1, d.target) { + var Q = Wn(u.scaleMatrix, [c - u.containerX, f - u.containerY]); + a.target.style.cssText += "position: ".concat(x ? "absolute" : "fixed", ";") + "left:0px;top:0px;" + "transform: translate(".concat(Q[0], "px, ").concat(Q[1], "px)"); + } + if (W && g && !S) + d.preventDefault(), C && (a._selectEnd(u.startSelectedTargets, u.startPassedTargets, B, s, !0), u.preventDragFromInside = !0); + else { + u.selectFlag = !0; + var H = a.options, tt = H.scrollOptions, U = H.innerScrollOptions, et = !1; + if (U) { + for (var lt = s.inputEvent, ft = lt.target, xt = null, q = ft; q && q !== _e(_).body; ) { + var nt = getComputedStyle(q).overflow !== "visible"; + if (nt) { + xt = q; + break; + } + q = q.parentElement; + } + xt && (u.innerScrollOptions = Vt({ + container: xt, + checkScrollEvent: !0 + }, U === !0 ? {} : U), a.dragScroll.dragStart(s, u.innerScrollOptions), et = !0); + } + !et && tt && tt.container && a.dragScroll.dragStart(s, tt), W && g && S && (u.selectFlag = !1, s.preventDrag()); + } + return !0; + }, a._onDrag = function(s) { + if (s.data.selectFlag) { + var l = a.scrollOptions, u = s.data.innerScrollOptions, c = u || (l == null ? void 0 : l.container); + if (c && !s.isScroll && a.dragScroll.drag(s, u || l)) + return; + } + a._checkSelected(s); + }, a._onDragEnd = function(s) { + var l = s.data, u = s.inputEvent, c = _s(s, a.options.ratio), f = l.selectFlag, d = a.container; + if (u && a.emit("dragEnd", Vt(Vt({ + isDouble: !!s.isDouble, + isClick: !!s.isClick, + isDrag: !1, + isSelect: f + }, s), { + data: l.data, + rect: c + })), a.target.style.cssText += "display: none;", f) + l.selectFlag = !1, a.dragScroll.dragEnd(); + else if (a.selectByClick && a.clickBySelectEnd) { + var p = a._findElement((u == null ? void 0 : u.target) || wv(d, s.clientX, s.clientY), l.selectableTargets); + a._select(p ? [p] : [], c, s); + } + l.preventDragFromInside || a._selectEnd(l.startSelectedTargets, l.startPassedTargets, c, s); + }, a._onKeyDown = function(s) { + var l = a.options, u = !1; + if (!a._keydownContinueSelect) { + var c = a._sameCombiKey(s, l.toggleContinueSelect); + a._keydownContinueSelect = c, u || (u = c); + } + if (!a._keydownContinueSelectWithoutDeselection) { + var c = a._sameCombiKey(s, l.toggleContinueSelectWithoutDeselect); + a._keydownContinueSelectWithoutDeselection = c, u || (u = c); + } + u && a.emit("keydown", { + keydownContinueSelect: a._keydownContinueSelect, + keydownContinueSelectWithoutDeselection: a._keydownContinueSelectWithoutDeselection + }); + }, a._onKeyUp = function(s) { + var l = a.options, u = !1; + if (a._keydownContinueSelect) { + var c = a._sameCombiKey(s, l.toggleContinueSelect, !0); + a._keydownContinueSelect = !c, u || (u = c); + } + if (a._keydownContinueSelectWithoutDeselection) { + var c = a._sameCombiKey(s, l.toggleContinueSelectWithoutDeselect, !0); + a._keydownContinueSelectWithoutDeselection = !c, u || (u = c); + } + u && a.emit("keyup", { + keydownContinueSelect: a._keydownContinueSelect, + keydownContinueSelectWithoutDeselection: a._keydownContinueSelectWithoutDeselection + }); + }, a._onBlur = function() { + (a._keydownContinueSelect || a._keydownContinueSelectWithoutDeselection) && (a._keydownContinueSelect = !1, a._keydownContinueSelectWithoutDeselection = !1, a.emit("keyup", { + keydownContinueSelect: a._keydownContinueSelect, + keydownContinueSelectWithoutDeselection: a._keydownContinueSelectWithoutDeselection + })); + }, a._onDocumentSelectStart = function(s) { + var l = _e(a.container); + if (a.gesto.isFlag()) { + var u = a.dragContainer; + u === xe(a.container) && (u = l.documentElement); + var c = on(u) ? [u] : [].slice.call(u), f = s.target; + c.some(function(d) { + if (d === f || d.contains(f)) + return s.preventDefault(), !0; + }); + } + }, a.target = n.portalContainer; + var i = n.container; + a.options = Vt({ + className: "", + portalContainer: null, + container: null, + dragContainer: null, + selectableTargets: [], + selectByClick: !0, + selectFromInside: !0, + clickBySelectEnd: !1, + hitRate: 100, + continueSelect: !1, + continueSelectWithoutDeselect: !1, + toggleContinueSelect: null, + toggleContinueSelectWithoutDeselect: null, + keyContainer: null, + scrollOptions: null, + checkInput: !1, + preventDefault: !1, + boundContainer: !1, + preventDragFromInside: !0, + dragCondition: null, + rootContainer: null, + checkOverflow: !1, + innerScrollOptions: !1, + getElementRect: jn, + cspNonce: "", + ratio: 0 + }, n); + var o = a.options.portalContainer; + return o && (i = o.parentElement), a.container = i || document.body, a.initElement(), a.initDragScroll(), a.setKeyController(), a; + } + var r = e.prototype; + return r.setSelectedTargets = function(n) { + var a = this.selectedTargets, i = Sr(a, n), o = i.added, s = i.removed, l = i.prevList, u = i.list; + return this.selectedTargets = n, { + added: o.map(function(c) { + return u[c]; + }), + removed: s.map(function(c) { + return l[c]; + }), + beforeSelected: a, + selected: n + }; + }, r.setSelectedTargetsByPoints = function(n, a) { + var i = Math.min(n[0], a[0]), o = Math.min(n[1], a[1]), s = Math.max(n[0], a[0]), l = Math.max(n[1], a[1]), u = { + left: i, + top: o, + right: s, + bottom: l, + width: s - i, + height: l - o + }, c = { + ignoreClick: !0 + }; + this.findSelectableTargets(c); + var f = this.hitTest(u, c, !0, null), d = this.setSelectedTargets(f); + return Vt(Vt({}, d), { + rect: u + }); + }, r.selectTargetsByPoints = function(n, a) { + var i = new MouseEvent("mousedown", { + clientX: n[0], + clientY: n[1], + cancelable: !0, + bubbles: !0 + }), o = new MouseEvent("mousemove", { + clientX: a[0], + clientY: a[1], + cancelable: !0, + bubbles: !0 + }), s = new MouseEvent("mousemove", { + clientX: a[0], + clientY: a[1], + cancelable: !0, + bubbles: !0 + }), l = this.gesto, u = l.onDragStart(i); + u !== !1 && (l.onDrag(o), l.onDragEnd(s)); + }, r.getSelectedTargets = function() { + return this.selectedTargets; + }, r.triggerDragStart = function(n) { + return this.gesto.triggerDragStart(n), this; + }, r.destroy = function() { + var n; + this.off(), this.keycon && this.keycon.destroy(), this.gesto.unset(), this.injectResult.destroy(), this.dragScroll.dragEnd(), Wt(document, "selectstart", this._onDocumentSelectStart), this.options.portalContainer || (n = this.target.parentElement) === null || n === void 0 || n.removeChild(this.target), this.keycon = null, this.gesto = null, this.injectResult = null, this.target = null, this.container = null, this.options = null; + }, r.getElementPoints = function(n) { + var a = this.getElementRect || jn, i = a(n), o = [i.pos1, i.pos2, i.pos4, i.pos3]; + if (a !== jn) { + var s = n.getBoundingClientRect(); + return Ja(o, s); + } + return o; + }, r.getSelectableElements = function() { + var n = this.container, a = []; + return this.options.selectableTargets.forEach(function(i) { + if (oa(i)) { + var o = i(); + o && a.push.apply(a, [].slice.call(o)); + } else if (on(i)) + a.push(i); + else if (pe(i)) + a.push(i.value || i.current); + else { + var s = [].slice.call(_e(n).querySelectorAll(i)); + a.push.apply(a, s); + } + }), a; + }, r.checkScroll = function() { + if (this.gesto.isFlag()) { + var n = this.scrollOptions, a = this.gesto.getEventData().innerScrollOptions, i = a || (n == null ? void 0 : n.container); + i && this.dragScroll.checkScroll(Vt({ + inputEvent: this.gesto.getCurrentEvent() + }, a || n)); + } + }, r.findSelectableTargets = function(n) { + var a = this; + n === void 0 && (n = this.gesto.getEventData()); + var i = this.getSelectableElements(), o = i.map(function(f) { + return a.getElementPoints(f); + }); + n.selectableTargets = i, n.selectablePoints = o, n.selectableParentMap = null; + var s = this.options, l = s.checkOverflow || s.innerScrollOptions, u = _e(this.container); + if (l) { + var c = /* @__PURE__ */ new Map(); + n.selectableInnerScrollParentMap = c, n.selectableInnerScrollPathsList = i.map(function(f, d) { + for (var p = f.parentElement, h = [], g = [], x = function() { + var y = c.get(p); + if (!y) { + var b = getComputedStyle(p).overflow !== "visible"; + if (b) { + var C = jn(p); + y = { + parentElement: p, + indexes: [], + points: [C.pos1, C.pos2, C.pos4, C.pos3], + paths: rn([], g) + }, h.push(p), h.forEach(function(S) { + c.set(S, y); + }), h = []; + } + } + y ? (p = y.parentElement, c.get(p).indexes.push(d), g.push(p)) : h.push(p), p = p.parentElement; + }; p && p !== u.body; ) + x(); + return g; + }); + } + return s.checkOverflow || (n.selectableInners = i.map(function() { + return !0; + })), this._refreshGroups(n), i; + }, r.clickTarget = function(n, a) { + var i = Ev(n), o = i.clientX, s = i.clientY, l = { + data: { + selectFlag: !1 + }, + clientX: o, + clientY: s, + inputEvent: n, + isClick: !0, + isTrusted: !1, + stop: function() { + return !1; + } + }; + return this._onDragStart(l, a) && this._onDragEnd(l), this; + }, r.setKeyController = function() { + var n = this.options, a = n.keyContainer, i = n.toggleContinueSelect, o = n.toggleContinueSelectWithoutDeselect; + this.keycon && (this.keycon.destroy(), this.keycon = null), (i || o) && (this.keycon = new bv(a || xe(this.container)), this.keycon.keydown(this._onKeyDown).keyup(this._onKeyUp).on("blur", this._onBlur)); + }, r.setClassName = function(n) { + this.options.className = n, this.target.setAttribute("class", "".concat(yi, " ").concat(n || "")); + }, r.setKeyEvent = function() { + var n = this.options, a = n.toggleContinueSelect, i = n.toggleContinueSelectWithoutDeselect; + !a && !i || this.keycon || this.setKeyController(); + }, r.setKeyContainer = function(n) { + var a = this, i = this.options; + Na(i.keyContainer, n, function() { + i.keyContainer = n, a.setKeyController(); + }); + }, r.getContinueSelect = function() { + var n = this.options, a = n.continueSelect, i = n.toggleContinueSelect; + return !i || !this._keydownContinueSelect ? a : !a; + }, r.getContinueSelectWithoutDeselect = function() { + var n = this.options, a = n.continueSelectWithoutDeselect, i = n.toggleContinueSelectWithoutDeselect; + return !i || !this._keydownContinueSelectWithoutDeselection ? a : !a; + }, r.setToggleContinueSelect = function(n) { + var a = this, i = this.options; + Na(i.toggleContinueSelect, n, function() { + i.toggleContinueSelect = n, a.setKeyEvent(); + }); + }, r.setToggleContinueSelectWithoutDeselect = function(n) { + var a = this, i = this.options; + Na(i.toggleContinueSelectWithoutDeselect, n, function() { + i.toggleContinueSelectWithoutDeselect = n, a.setKeyEvent(); + }); + }, r.setPreventDefault = function(n) { + this.gesto.options.preventDefault = n; + }, r.setCheckInput = function(n) { + this.gesto.options.checkInput = n; + }, r.initElement = function() { + var n = this.options, a = n.dragContainer, i = n.checkInput, o = n.preventDefault, s = n.preventClickEventOnDragStart, l = n.preventClickEventOnDrag, u = n.preventClickEventByCondition, c = n.preventRightClick, f = c === void 0 ? !0 : c, d = n.className, p = this.container; + this.target = Tu(_v("div", { + className: "".concat(yi, " ").concat(d || "") + }), this.target, p); + var h = this.target; + this.dragContainer = typeof a == "string" ? [].slice.call(_e(p).querySelectorAll(a)) : a || this.target.parentNode, this.gesto = new fl(this.dragContainer, { + checkWindowBlur: !0, + container: xe(p), + checkInput: i, + preventDefault: o, + preventClickEventOnDragStart: s, + preventClickEventOnDrag: l, + preventClickEventByCondition: u, + preventRightClick: f + }).on({ + dragStart: this._onDragStart, + drag: this._onDrag, + dragEnd: this._onDragEnd + }), $t(document, "selectstart", this._onDocumentSelectStart), this.injectResult = Iu.inject(h, { + nonce: this.options.cspNonce + }); + }, r.hitTest = function(n, a, i, o) { + var s = this.options, l = s.hitRate, u = s.selectByClick, c = n.left, f = n.top, d = n.right, p = n.bottom, h = a.innerGroups, g = a.innerWidth, x = a.innerHeight, y = o == null ? void 0 : o.clientX, b = o == null ? void 0 : o.clientY, C = a.ignoreClick, S = [[c, f], [d, f], [d, p], [c, p]], w = function(G, W) { + var $ = or(typeof l == "function" ? "".concat(l(W)) : "".concat(l)), j = C ? !1 : $n([y, b], G); + if (!i && u && j) + return !0; + var J = ti(S, G); + if (!J.length) + return !1; + var Q = Kr(J), H = 0; + if (Q === 0 && Kr(G) === 0 ? (H = ks(G), Q = ks(J)) : H = Kr(G), $.unit === "px") + return Q >= $.value; + var tt = qn(Math.round(Q / H * 100), 0, 100); + return tt >= Math.min(100, $.value); + }, v = a.selectableTargets, _ = a.selectablePoints, M = a.selectableInners; + if (!h) + return v.filter(function(G, W) { + return M[W] ? w(_[W], v[W]) : !1; + }); + for (var T = [], k = Math.floor(c / g), A = Math.floor(d / g), z = Math.floor(f / x), R = Math.floor(p / x), B = k; B <= A; ++B) { + var N = h[B]; + if (N) + for (var L = z; L <= R; ++L) { + var V = N[L]; + V && V.forEach(function(G) { + var W = _[G], $ = M[G], j = v[G]; + $ && w(W, j) && T.push(j); + }); + } + } + return Dv(T); + }, r.initDragScroll = function() { + var n = this; + this.dragScroll.on("scrollDrag", function(a) { + var i = a.next; + i(n.gesto.getCurrentEvent()); + }).on("scroll", function(a) { + var i = a.container, o = a.direction, s = n.gesto.getEventData().innerScrollOptions; + s ? n.emit("innerScroll", { + container: i, + direction: o + }) : n.emit("scroll", { + container: i, + direction: o + }); + }).on("move", function(a) { + var i = a.offsetX, o = a.offsetY, s = a.inputEvent, l = n.gesto; + if (!(!l || !l.isFlag())) { + var u = n.gesto.getEventData(), c = u.boundArea; + u.startX -= i, u.startY -= o; + var f = n.gesto.getEventData().innerScrollOptions, d = f == null ? void 0 : f.container, p = !1; + if (d) { + var h = u.selectableInnerScrollParentMap, g = h.get(d); + g && (g.paths.forEach(function(x) { + var y = h.get(x); + y.points.forEach(function(b) { + b[0] -= i, b[1] -= o; + }); + }), g.indexes.forEach(function(x) { + u.selectablePoints[x].forEach(function(y) { + y[0] -= i, y[1] -= o; + }); + }), p = !0); + } + p || u.selectablePoints.forEach(function(x) { + x.forEach(function(y) { + y[0] -= i, y[1] -= o; + }); + }), n._refreshGroups(u), c.left -= i, c.right -= i, c.top -= o, c.bottom -= o, n.gesto.scrollBy(i, o, s.inputEvent), n._checkSelected(n.gesto.getCurrentEvent()); + } + }); + }, r._select = function(n, a, i, o, s) { + s === void 0 && (s = !1); + var l = i.inputEvent, u = i.data, c = this.setSelectedTargets(n), f = Sr(u.startSelectedTargets, n), d = f.added, p = f.removed, h = f.prevList, g = f.list, x = { + startSelected: h, + startAdded: d.map(function(y) { + return g[y]; + }), + startRemoved: p.map(function(y) { + return h[y]; + }) + }; + o && this.emit("selectStart", Vt(Vt(Vt({}, c), x), { + rect: a, + inputEvent: l, + data: u.data, + isTrusted: i.isTrusted, + isDragStartEnd: s + })), (c.added.length || c.removed.length) && this.emit("select", Vt(Vt(Vt({}, c), x), { + rect: a, + inputEvent: l, + data: u.data, + isTrusted: i.isTrusted, + isDragStartEnd: s + })); + }, r._selectEnd = function(n, a, i, o, s) { + s === void 0 && (s = !1); + var l = o.inputEvent, u = o.isDouble, c = o.data, f = l && l.type, d = f === "mousedown" || f === "touchstart", p = Sr(n, this.selectedTargets), h = p.added, g = p.removed, x = p.prevList, y = p.list, b = Sr(a, this.selectedTargets), C = b.added, S = b.removed, w = b.prevList, v = b.list; + this.emit("selectEnd", { + startSelected: n, + beforeSelected: a, + selected: this.selectedTargets, + added: h.map(function(_) { + return y[_]; + }), + removed: g.map(function(_) { + return x[_]; + }), + afterAdded: C.map(function(_) { + return v[_]; + }), + afterRemoved: S.map(function(_) { + return w[_]; + }), + isDragStart: d && s, + isDragStartEnd: d && s, + isClick: !!o.isClick, + isDouble: !!u, + rect: i, + inputEvent: l, + data: c.data, + isTrusted: o.isTrusted + }); + }, r._checkSelected = function(n, a) { + a === void 0 && (a = _s(n, this.options.ratio)); + var i = n.data, o = a.top, s = a.left, l = a.width, u = a.height, c = i.selectFlag, f = i.containerX, d = i.containerY, p = i.scaleMatrix, h = Wn(p, [s - f, o - d]), g = Wn(p, [l, u]), x = []; + if (c) { + this.target.style.cssText += "display: block;left:0px;top:0px;" + "transform: translate(".concat(h[0], "px, ").concat(h[1], "px);") + "width:".concat(g[0], "px;height:").concat(g[1], "px;"); + var y = this.hitTest(a, i, !0, n); + x = Ms(i.startPassedTargets, y, this.continueSelect && this.continueSelectWithoutDeselect); + } + var b = this.emit("drag", Vt(Vt({}, n), { + data: i.data, + isSelect: c, + rect: a + })); + if (b === !1) { + this.target.style.cssText += "display: none;", n.stop(); + return; + } + c && this._select(x, a, n); + }, r._sameCombiKey = function(n, a, i) { + if (!a) + return !1; + var o = Mu(n.inputEvent, n.key), s = [].concat(a), l = Yt(s[0]) ? s : [s]; + if (i) { + var u = n.key; + return l.some(function(c) { + return c.some(function(f) { + return f === u; + }); + }); + } + return l.some(function(c) { + return c.every(function(f) { + return o.indexOf(f) > -1; + }); + }); + }, r._findElement = function(n, a) { + for (var i = n; i && !(a.indexOf(i) > -1); ) + i = i.parentElement; + return i; + }, r._refreshGroups = function(n) { + var a, i = n.innerWidth, o = n.innerHeight, s = n.selectablePoints; + if (this.options.checkOverflow) { + var l = (a = this.gesto.getEventData().innerScrollOptions) === null || a === void 0 ? void 0 : a.container, u = n.selectableInnerScrollParentMap, c = n.selectableInnerScrollPathsList; + n.selectableInners = c.map(function(p, h) { + var g = !1; + return p.every(function(x) { + if (g) + return !0; + if (x === l) + return g = !0, !0; + var y = u.get(x); + if (y) { + var b = s[h], C = y.points, S = ti(b, C); + if (!S.length) + return !1; + } + return !0; + }); + }); + } + if (!i || !o) + n.innerGroups = null; + else { + var f = n.selectablePoints, d = {}; + f.forEach(function(p, h) { + var g = 1 / 0, x = -1 / 0, y = 1 / 0, b = -1 / 0; + p.forEach(function(w) { + var v = Math.floor(w[0] / i), _ = Math.floor(w[1] / o); + g = Math.min(v, g), x = Math.max(v, x), y = Math.min(_, y), b = Math.max(_, b); + }); + for (var C = g; C <= x; ++C) + for (var S = y; S <= b; ++S) + d[C] = d[C] || {}, d[C][S] = d[C][S] || [], d[C][S].push(h); + }), n.innerGroups = d; + } + }, e = Cv([jc(ao, function(n, a) { + var i = { + enumerable: !0, + configurable: !0, + get: function() { + return this.options[a]; + } + }, o = qa("get ".concat(a)); + n[o] ? i.get = function() { + return this[o](); + } : i.get = function() { + return this.options[a]; + }; + var s = qa("set ".concat(a)); + n[s] ? i.set = function(l) { + this[s](l); + } : i.set = function(l) { + this.options[a] = l; + }, Object.defineProperty(n, a, i); + })], e), e; +})(fn), Iv = /* @__PURE__ */ (function(t) { + ku(e, t); + function e() { + return t !== null && t.apply(this, arguments) || this; + } + return e; +})(Tv), bi = function(t, e) { + return bi = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(r, n) { + r.__proto__ = n; + } || function(r, n) { + for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (r[a] = n[a]); + }, bi(t, e); +}; +function Rv(t, e) { + if (typeof e != "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null"); + bi(t, e); + function r() { + this.constructor = t; + } + t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r()); +} +var aa = function() { + return aa = Object.assign || function(e) { + for (var r, n = 1, a = arguments.length; n < a; n++) { + r = arguments[n]; + for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]); + } + return e; + }, aa.apply(this, arguments); +}; +function Pv(t, e, r, n) { + var a = arguments.length, i = a < 3 ? e : n, o; + if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(t, e, r, n); + else for (var s = t.length - 1; s >= 0; s--) (o = t[s]) && (i = (a < 3 ? o(i) : a > 3 ? o(e, r, i) : o(e, r)) || i); + return a > 3 && i && Object.defineProperty(e, r, i), i; +} +var Ts = Ru.map(function(t) { + return qa("on ".concat(t)); +}), Ov = /* @__PURE__ */ (function(t) { + Rv(e, t); + function e() { + return t !== null && t.apply(this, arguments) || this; + } + var r = e.prototype; + return r.render = function() { + return st.createElement("div", { + className: yi, + ref: qe(this, "selectionElement") + }); + }, r.componentDidMount = function() { + var n = this, a = this.props, i = {}; + Mv.forEach(function(o) { + o in a && (i[o] = a[o]); + }), this.selecto = new Iv(aa(aa({}, i), { + portalContainer: this.selectionElement + })), Ru.forEach(function(o, s) { + n.selecto.on(o, function(l) { + var u = n.props, c = u[Ts[s]] && u[Ts[s]](l); + c === !1 && l.stop(); + }); + }); + }, r.componentDidUpdate = function(n) { + var a = this.props, i = this.selecto; + ao.forEach(function(o) { + n[o] !== a[o] && (i[o] = a[o]); + }); + }, r.componentWillUnmount = function() { + this.selecto.destroy(); + }, Pv([Ks(kv)], e.prototype, "selecto", void 0), e; +})(st.PureComponent); +const Be = "http://www.w3.org/2000/svg"; +function Gn(t, e) { + const r = URL.createObjectURL(t), n = document.createElement("a"); + n.href = r, n.download = e, document.body.appendChild(n), n.click(), n.remove(), setTimeout(() => URL.revokeObjectURL(r), 1e3); +} +function Mr(t, e, r, n = { x: 0, y: 0 }) { + const a = t.getBoundingClientRect(); + return { + left: (a.left - e.left) / r - n.x, + top: (a.top - e.top) / r - n.y, + width: a.width / r, + height: a.height / r + }; +} +function Is(t, e, r, n, a, i) { + const o = a * 1.3; + e.forEach((s, l) => { + if (!s) return; + const u = document.createElementNS(Be, "text"); + u.setAttribute("x", String(r)), u.setAttribute("y", String(n + l * o + a * 0.82)), u.setAttribute("font-size", String(a)), u.setAttribute("font-family", i.fontFamily || "Arial, Helvetica, sans-serif"), u.setAttribute("font-weight", i.fontWeight || "400"), u.setAttribute("fill", i.color || "#1e293b"), u.setAttribute("xml:space", "preserve"), u.textContent = s, t.appendChild(u); + }); +} +function Rs(t, e, r, n, a, i) { + const o = Mr(e, r, n, i), s = document.createElementNS(Be, "g"); + s.setAttribute("transform", `translate(${Math.round(o.left)},${Math.round(o.top)})`); + const l = e.querySelector("canvas"); + if (l) { + const c = document.createElementNS(Be, "image"), f = Mr(l, r, n, i); + c.setAttribute("x", "0"), c.setAttribute("y", "0"), c.setAttribute("width", String(Math.round(f.width || o.width))), c.setAttribute("height", String(Math.round(f.height || o.height))), c.setAttribute("href", ic(e, a, Math.round(f.width || o.width)) ?? l.toDataURL("image/png")), s.appendChild(c); + } + const u = e.querySelector("svg"); + if (u) { + const c = u.cloneNode(!0), f = u.clientWidth || Number(u.getAttribute("width")) || o.width, d = f > 0 ? o.width / f : 1; + if (Math.abs(d - 1) > 1e-3) { + const p = document.createElementNS(Be, "g"); + p.setAttribute("transform", `scale(${d})`), p.appendChild(c), s.appendChild(p); + } else s.appendChild(c); + } + t.appendChild(s); +} +function zv(t, e, r) { + const { width: n, height: a } = Ya(e.page), i = Xn(e.page)[r.pageIndex ?? 0] ?? { x: 0, y: 0 }, o = document.createElementNS(Be, "svg"); + o.setAttribute("xmlns", Be), o.setAttribute("width", String(n)), o.setAttribute("height", String(a)), o.setAttribute("viewBox", `0 0 ${n} ${a}`); + const s = document.createElementNS(Be, "rect"); + s.setAttribute("width", "100%"), s.setAttribute("height", "100%"), s.setAttribute("fill", "#ffffff"), o.appendChild(s); + const l = t.getBoundingClientRect(), u = [...t.querySelectorAll(".gl-layout-item")].sort((c, f) => (Number(c.style.zIndex) || 0) - (Number(f.style.zIndex) || 0)); + for (const c of u) { + const f = Mr(c, l, r.zoom, i); + if (f.left >= n || f.top >= a || f.left + f.width <= 0 || f.top + f.height <= 0) continue; + if (c.classList.contains("has-frame")) { + const g = document.createElementNS(Be, "rect"); + g.setAttribute("x", String(Math.round(f.left) + 0.5)), g.setAttribute("y", String(Math.round(f.top) + 0.5)), g.setAttribute("width", String(Math.round(f.width) - 1)), g.setAttribute("height", String(Math.round(f.height) - 1)), g.setAttribute("fill", "none"), g.setAttribute("stroke", "#94a3b8"), o.appendChild(g); + } + const d = c.querySelector(".gl-layout-text-surface"); + if (d) { + const g = d instanceof HTMLTextAreaElement ? d.value : d.textContent ?? "", x = getComputedStyle(d), y = Mr(d, l, r.zoom, i), b = Number(c.dataset.zoom) || 1, C = (parseFloat(x.fontSize) || 14) * b, S = (parseFloat(x.paddingLeft) || 0) * b, w = (parseFloat(x.paddingTop) || 0) * b; + Is(o, g.split(` +`), y.left + S, y.top + w, C, x); + continue; + } + const p = c.querySelector(".gl-layout-plot-host"); + if (!p) continue; + if (p.__miniPlotCfg) { + Rs(o, p, l, r.zoom, r.dpi, i); + continue; + } + const h = p.querySelector(".gl-prop-chart"); + if (h) { + const g = ac(h); + if (g) { + const x = Mr(h, l, r.zoom, i), y = g.width > 0 ? x.width / g.width : 1, b = document.createElementNS(Be, "g"); + b.setAttribute("transform", `translate(${x.left},${x.top}) scale(${y})`), b.appendChild(g.root), o.appendChild(b); + } + continue; + } + p.querySelectorAll(".strategy-context-title, .illustration-row-header").forEach((g) => { + const x = (g.textContent ?? "").trim(); + if (!x) return; + const y = getComputedStyle(g), b = Mr(g, l, r.zoom, i), C = g.offsetWidth > 0 ? b.width / g.offsetWidth : 1; + Is(o, [x], b.left, b.top, (parseFloat(y.fontSize) || 12) * C, y); + }), p.querySelectorAll(".mini-plot-cell").forEach((g) => Rs(o, g, l, r.zoom, r.dpi, i)); + } + return { root: o, width: n, height: a }; +} +function Ps(t) { + return ` +` + new XMLSerializer().serializeToString(t); +} +async function Os(t) { + return new Promise((e, r) => t.toBlob((n) => n ? e(n) : r(new Error("PNG export failed")), "image/png")); +} +function Av(t, e, r) { + return Xn(e.page).map((n, a) => zv(t, e, { dpi: e.page.dpi, zoom: r.zoom, pageIndex: a })); +} +async function Nv(t, e, r) { + const n = e.page.dpi, a = ec(e.name) || "layout"; + if (!t.length) return; + if (r === "svg") { + if (t.length === 1) { + Gn(new Blob([Ps(t[0].root)], { type: "image/svg+xml" }), `${a}.svg`); + return; + } + const c = {}; + t.forEach((f, d) => { + c[`${a}-p${d + 1}.svg`] = rc(Ps(f.root)); + }), Gn(new Blob([Io(c)], { type: "application/zip" }), `${a}.zip`); + return; + } + const i = []; + for (const c of t) i.push(await nc(c, n)); + if (r === "png") { + if (i.length === 1) { + Gn(await Os(i[0]), `${a}.png`); + return; + } + const c = {}; + for (const [f, d] of i.entries()) + c[`${a}-p${f + 1}.png`] = new Uint8Array(await (await Os(d)).arrayBuffer()); + Gn(new Blob([Io(c)], { type: "application/zip" }), `${a}.zip`); + return; + } + const { widthMm: o, heightMm: s } = Gs(e.page), { jsPDF: l } = await import("./jspdf.es.min-8ev2qW9X.js").then((c) => c.j), u = new l({ orientation: o >= s ? "landscape" : "portrait", unit: "mm", format: [o, s] }); + i.forEach((c, f) => { + f > 0 && u.addPage([o, s], o >= s ? "landscape" : "portrait"), u.addImage(c.toDataURL("image/png"), "PNG", 0, 0, o, s); + }), u.save(`${a}.pdf`); +} +const Bv = "", Pu = "{none}", Fn = [ + { id: "auto", label: "What differs across the page", template: Bv }, + { id: "population", label: "Population", template: "{population}" }, + { id: "file", label: "File", template: "{file}" }, + { id: "sample", label: "Sample id", template: "{sample}" }, + { id: "population-file", label: "Population · file", template: "{population} · {file}" }, + { id: "population-plot", label: "Population · plot", template: "{population} · {plot}" }, + { id: "none", label: "No title", template: Pu } +], Ba = "{population}, {file}, {sample}, {x}, {y}, {plot}, {count}, {meta:column}, {popmeta:field}"; +function jv(t, e) { + return [ + { token: "{population}", label: "Population", group: "population" }, + ...e.map((r) => ({ token: `{popmeta:${r}}`, label: r, group: "population" })), + { token: "{file}", label: "File", group: "file" }, + { token: "{sample}", label: "Sample id", group: "file" }, + ...t.map((r) => ({ token: `{meta:${r}}`, label: r, group: "file" })), + { token: "{plot}", label: "Plot", group: "plot" }, + { token: "{x}", label: "X", group: "plot" }, + { token: "{y}", label: "Y", group: "plot" }, + { token: "{count}", label: "Count", group: "plot" } + ]; +} +const ja = [ + { id: "dot", label: "·", value: " · " }, + { id: "space", label: "space", value: " " }, + { id: "comma", label: ",", value: ", " }, + { id: "slash", label: "/", value: " / " }, + { id: "dash", label: "–", value: " – " } +]; +function zs(t, e) { + return t.join(e); +} +function Gv(t) { + const e = t.match(/\{[^}]+\}/g) ?? []; + if (!e.length) return null; + const r = t.split(/\{[^}]+\}/); + if (r[0] !== "" || r[r.length - 1] !== "") return null; + const n = r.slice(1, -1), a = n[0] ?? " · "; + return n.some((i) => i !== a) ? null : { tokens: e, separator: a }; +} +function Fv(t, e, r, n, a) { + return { + population: (r == null ? void 0 : r.name) ?? "", + file: (e == null ? void 0 : e.fileName) ?? (e == null ? void 0 : e.name) ?? "", + sample: (e == null ? void 0 : e.name) ?? (e == null ? void 0 : e.fileName) ?? "", + x: t.xChannel ?? "", + y: t.yChannel ?? "", + ...t.label ? { plot: t.label } : {}, + ...typeof n == "number" ? { count: n } : {}, + ...e != null && e.metadata ? { metadata: e.metadata } : {}, + ...r && (a != null && a[r.id]) ? { populationMetadata: a[r.id] } : {} + }; +} +function ia(t, e) { + return t.trim() === Pu ? "" : t.replace(/\{(population|file|sample|x|y|plot|count|meta:[^}]+|popmeta:[^}]+)\}/g, (n, a) => { + var i, o; + switch (a) { + case "population": + return e.population; + case "file": + return e.file; + case "sample": + return e.sample; + case "x": + return e.x; + case "y": + return e.y; + case "plot": + return e.plot ?? (e.y ? `${e.x} vs ${e.y}` : e.x); + case "count": + return typeof e.count == "number" ? e.count.toLocaleString() : ""; + } + return a.startsWith("meta:") ? ((i = e.metadata) == null ? void 0 : i[a.slice(5)]) ?? "" : a.startsWith("popmeta:") ? ((o = e.populationMetadata) == null ? void 0 : o[a.slice(8)]) ?? "" : n; + }).replace(/(\s*·\s*)+/g, " · ").replace(/^\s*·\s*/, "").replace(/\s*·\s*$/, "").trim(); +} +function Lv(t) { + const e = new Set(t.map((i) => i.sampleId)), r = new Set(t.map((i) => i.populationId)), n = t.some((i) => i.label), a = e.size <= 1 && r.size > 1 ? "{population}" : r.size <= 1 && e.size > 1 ? "{file}" : "{population} · {file}"; + return n ? `${a} · {plot}` : a; +} +function Ou(t) { + return re(t.recipe) && t.recipe.iterated === !0; +} +function As(t, e, r, n) { + return t.replace(/\{(sample|file|group|population|n|N|meta:[^}]+)\}/g, (a, i) => { + var o; + return i === "n" ? String(r) : i === "N" ? String(n) : e ? i === "population" ? e.populationId ? e.name : a : i === "sample" ? e.sampleName ?? e.name : i === "file" ? e.fileName : i === "group" ? e.groupName ?? "" : i.startsWith("meta:") ? ((o = e.metadata) == null ? void 0 : o[i.slice(5).trim()]) ?? "" : a : a; + }); +} +function Ga(t, e, r, n, a, i) { + const o = Ou(t), s = { ...t.recipe }; + let l; + return s.kind === "text" ? s.text = As(s.text, s.readsFrom ? null : e, r, n) : (o && e && e.populationId ? "populationId" in s && (s.populationId = e.populationId) : o && e && "sampleId" in s && s.sampleId !== e.id && (l = s.sampleId, s.sampleId = e.id), s.title && (s.title = As(s.title, e, r, n))), { + ...t, + id: i === 0 && !a.x && !a.y ? t.id : `${t.id}::${i}`, + templateId: t.id, + unitId: o && e ? e.id : void 0, + ...l ? { templateSampleId: l } : {}, + x: t.x + a.x, + y: t.y + a.y, + offset: a, + recipe: s + }; +} +function Wv(t, e) { + if (e) + for (const r of t) { + if (r.recipe.kind !== "text" || !r.recipe.readsFrom) continue; + const n = r.recipe.readsFrom, a = t.find((o) => o.templateId === n && o.offset.x === r.offset.x && o.offset.y === r.offset.y); + if (!a || !re(a.recipe)) continue; + const i = e(a.recipe, a.templateSampleId); + i && (r.recipe = { ...r.recipe, text: ia(r.recipe.text, i) }); + } +} +function Yv(t, e, r) { + const n = Xv(t, e); + for (const a of n) Wv(a.items, r); + return n; +} +function Xv(t, e) { + const r = t.iteration ?? Fs; + if (r.mode === "off" || !e.length) + return [{ index: 0, units: [], items: t.items.map((p) => Ga(p, null, 1, 1, { x: 0, y: 0 }, 0)) }]; + const n = e.length; + if (r.arrangement.kind === "page-per-unit") + return e.map((p, h) => ({ + index: h, + units: [p], + items: t.items.map((g) => Ga(g, p, h + 1, n, { x: 0, y: 0 }, 0)) + })); + const { rows: a, columns: i, order: o, gap: s } = r.arrangement, l = oc(t.items); + if (!l) return [{ index: 0, units: [], items: [] }]; + const u = a * i, c = l.width + s, f = l.height + s, d = []; + for (let p = 0; p < n; p += u) { + const h = e.slice(p, p + u), g = []; + h.forEach((x, y) => { + const b = o === "row-major" ? Math.floor(y / i) : y % a, S = { x: (o === "row-major" ? y % i : Math.floor(y / a)) * c, y: b * f }; + for (const w of t.items) g.push(Ga(w, x, p + y + 1, n, S, y)); + }), d.push({ index: d.length, units: h, items: g }); + } + return d; +} +function Hv(t, e, r, n, a) { + const i = (s) => { + var l; + return { + id: s.id, + name: s.name, + fileName: s.fileName ?? s.name, + groupName: (l = n.find((u) => u.id === a[s.id])) == null ? void 0 : l.name, + metadata: s.metadata + }; + }, o = t.source; + return e.filter((s) => { + var l; + return o.kind === "all" ? !0 : o.kind === "checked" ? r.includes(s.id) : o.kind === "group" ? a[s.id] === o.groupId : (((l = s.metadata) == null ? void 0 : l[o.column]) ?? "") === o.value; + }).map(i); +} +function qv(t, e, r) { + var o; + const n = e.root_population_id, a = ((o = t.populations) == null ? void 0 : o.kind) === "branch" ? t.populations.populationId : null, i = (s) => { + var u, c; + if (!a) return !0; + let l = (u = e.populations[s]) == null ? void 0 : u.parent_id; + for (; l; ) { + if (l === a) return !0; + l = (c = e.populations[l]) == null ? void 0 : c.parent_id; + } + return !1; + }; + return Ln(e.populations, n).filter(({ popId: s }) => s !== n && i(s)).map(({ popId: s }) => { + var l; + return { + id: s, + name: ((l = e.populations[s]) == null ? void 0 : l.name) ?? s, + fileName: r.fileName ?? r.name, + sampleName: r.name, + populationId: s + }; + }); +} +function Vv(t, e) { + return { id: t.templateId, x: e.x - t.offset.x, y: e.y - t.offset.y, width: e.width, height: e.height }; +} +const $v = (t) => [...t].sort((e, r) => e - r); +function Fa(t, e) { + const r = $v(t); + if (!r.length) return NaN; + const n = (r.length - 1) * e, a = Math.floor(n), i = Math.ceil(n); + return r[a] + (r[i] - r[a]) * (n - a); +} +function Uv(t, e) { + const r = e.map((o) => o.value), n = r.length, a = n ? r.reduce((o, s) => o + s, 0) / n : NaN, i = n > 1 ? Math.sqrt(r.reduce((o, s) => o + (s - a) ** 2, 0) / (n - 1)) : 0; + return { + label: t, + points: e, + n, + mean: a, + sd: i, + median: Fa(r, 0.5), + q1: Fa(r, 0.25), + q3: Fa(r, 0.75), + min: n ? Math.min(...r) : NaN, + max: n ? Math.max(...r) : NaN + }; +} +function Kv(t) { + const e = [], r = /* @__PURE__ */ new Map(); + for (const n of t) + r.has(n.group) || (r.set(n.group, []), e.push(n.group)), r.get(n.group).push(n); + return e.map((n) => Uv(n, r.get(n))); +} +function zu(t) { + const e = t.map((a, i) => ({ v: a, i })).sort((a, i) => a.v - i.v), r = new Array(t.length); + let n = 0; + for (let a = 0; a < e.length; ) { + let i = a; + for (; i + 1 < e.length && e[i + 1].v === e[a].v; ) i++; + const o = i - a + 1, s = (a + i) / 2 + 1; + for (let l = a; l <= i; l++) r[e[l].i] = s; + o > 1 && (n += o ** 3 - o), a = i + 1; + } + return { rank: r, ties: n }; +} +function Zv(t) { + const e = Math.abs(t) / Math.SQRT2, r = 1 / (1 + 0.3275911 * e), i = r * (0.254829592 + r * (-0.284496736 + r * (1.421413741 + r * (-1.453152027 + r * 1.061405429)))) * Math.exp(-e * e) / 2; + return t >= 0 ? i : 1 - i; +} +function Jv(t, e) { + if (e <= 0) return 0; + const r = Qv(t); + if (e < t + 1) { + let s = 1 / t, l = s; + for (let u = 1; u < 500 && (l *= e / (t + u), s += l, !(Math.abs(l) < Math.abs(s) * 1e-14)); u++) + ; + return s * Math.exp(-e + t * Math.log(e) - r); + } + let n = e + 1 - t, a = 1 / 1e-300, i = 1 / n, o = i; + for (let s = 1; s < 500; s++) { + const l = -s * (s - t); + n += 2, i = l * i + n, Math.abs(i) < 1e-300 && (i = 1e-300), a = n + l / a, Math.abs(a) < 1e-300 && (a = 1e-300), i = 1 / i; + const u = i * a; + if (o *= u, Math.abs(u - 1) < 1e-14) break; + } + return 1 - Math.exp(-e + t * Math.log(e) - r) * o; +} +function Qv(t) { + const e = [76.18009172947146, -86.50532032941678, 24.01409824083091, -1.231739572450155, 0.001208650973866179, -5395239384953e-18]; + let r = t, n = t, a = r + 5.5; + a -= (r + 0.5) * Math.log(a); + let i = 1.000000000190015; + for (const o of e) i += o / ++n; + return -a + Math.log(2.5066282746310007 * i / r); +} +function th(t, e) { + return t > 0 ? Math.max(0, Math.min(1, 1 - Jv(e / 2, t / 2))) : 1; +} +function eh(t, e) { + if (t.length < 2 || e.length < 2) return null; + const r = t.length, n = e.length, { rank: a, ties: i } = zu([...t, ...e]), s = a.slice(0, r).reduce((p, h) => p + h, 0) - r * (r + 1) / 2, l = r + n, u = r * n / 2, c = Math.sqrt(r * n / 12 * (l + 1 - i / (l * (l - 1)))); + if (!(c > 0)) return { name: "Wilcoxon rank-sum", statistic: s, p: 1, label: "Wilcoxon p = 1" }; + const f = (Math.abs(s - u) - 0.5) / c, d = Math.min(1, 2 * Zv(Math.max(0, f))); + return { name: "Wilcoxon rank-sum", statistic: s, p: d, label: `Wilcoxon ${Au(d)}` }; +} +function rh(t) { + const e = t.filter((c) => c.length > 0); + if (e.length < 2 || e.some((c) => c.length < 2)) return null; + const r = e.flat(), n = r.length, { rank: a, ties: i } = zu(r); + let o = 0, s = 0; + for (const c of e) { + const f = a.slice(o, o + c.length).reduce((d, p) => d + p, 0); + s += f * f / c.length, o += c.length; + } + s = 12 / (n * (n + 1)) * s - 3 * (n + 1); + const l = 1 - i / (n ** 3 - n); + l > 0 && (s /= l); + const u = th(s, e.length - 1); + return { name: "Kruskal–Wallis", statistic: s, p: u, label: `Kruskal–Wallis ${Au(u)}` }; +} +function nh(t) { + const e = t.map((r) => r.points.map((n) => n.value)); + return e.length === 2 ? eh(e[0], e[1]) : e.length > 2 ? rh(e) : null; +} +function Au(t) { + return Number.isFinite(t) ? t < 1e-3 ? "p < 0.001" : `p = ${t < 0.01 ? t.toFixed(3) : t.toFixed(2)}` : "p = ?"; +} +function ah(t, e = 5) { + const r = t.filter((d) => Number.isFinite(d)), n = Math.min(0, ...r), a = Math.max(...r, n + 1e-9), o = (a - n || 1) / e, s = 10 ** Math.floor(Math.log10(o)), l = [1, 2, 2.5, 5, 10].map((d) => d * s).find((d) => d >= o) ?? s * 10, u = Math.floor(n / l) * l, c = Math.ceil((a + l * 0.15) / l) * l, f = []; + for (let d = u; d <= c + l / 2; d += l) f.push(Number(d.toFixed(10))); + return { min: u, max: c, ticks: f }; +} +const Nu = { + percent_of_parent: "% of parent", + percent_of_total: "% of total", + count: "Events", + median: "Median" +}; +function ih(t, e, r, n, a) { + var d, p; + const i = e.find((h) => h.id === t.sampleId) ?? null, o = ((d = i == null ? void 0 : i.tree.populations[t.populationId]) == null ? void 0 : d.name) ?? "the population", s = t.files === "all" ? e : e.filter((h) => n.includes(h.id)), l = [], u = []; + for (const h of s) { + let g = t.populationId; + if (i && i.tree.id !== h.tree.id) { + const b = Hr( + { hierarchyId: i.tree.id, populationId: t.populationId }, + h.tree, + br(a) + ); + if (!b.id) { + u.push(h.name); + continue; + } + g = b.id; + } + let x; + if (t.statistic === "median") { + const b = t.channel ? h.sample.index(t.channel) : void 0, C = h.derived.masks[g]; + if (b === void 0 || !C) x = null; + else { + const S = h.sample.displayColumn(b), w = []; + for (let v = 0; v < S.length; v++) C[v] && Number.isFinite(S[v]) && w.push(S[v]); + x = w.length ? sc(w) : null; + } + } else + x = h.derived.stats[t.statistic === "count" ? "event_count" : t.statistic][g]; + if (typeof x != "number" || !Number.isFinite(x)) continue; + const y = t.groupBy ? ((p = r[h.id]) == null ? void 0 : p[t.groupBy]) ?? "" : h.name; + l.push({ sampleId: h.id, name: h.name, group: y, value: x }); + } + const c = Kv(l), f = t.statistic === "median" ? `Median ${t.channel ?? ""}`.trim() : Nu[t.statistic]; + return { points: l, groups: c, test: t.test && t.groupBy ? nh(c) : null, population: o, axis: f, missing: u }; +} +const La = (t) => Math.abs(t) >= 1e3 ? Math.round(t).toLocaleString() : String(Number(t.toPrecision(3))), oh = (t) => (Math.sin(t * 12.9898) * 43758.5453 % 1 + 1) % 1 * 2 - 1; +function sh({ + data: t, + recipe: e, + style: r, + width: n, + height: a, + title: i +}) { + const o = r.fontTick, s = r.fontAxis, l = r.fontTitle, u = t.groups, c = st.useMemo(() => ah(t.points.map((k) => k.value)), [t.points]), f = 8 + s + 6 + Math.max(...c.ticks.map((k) => La(k).length), 1) * o * 0.6 + 8, d = 8 + (i ? l + 6 : 0) + (t.test ? o + 10 : 0), p = Math.max(0, ...u.map((k) => k.label.length)), h = u.length > 0 && p * o * 0.6 > (n - f - 8) / u.length, g = 8 + (h ? p * o * 0.45 + 10 : o + 8), x = Math.max(20, n - f - 8), y = Math.max(20, a - d - g), b = (k) => d + y - (k - c.min) / (c.max - c.min || 1) * y, C = u.length ? x / u.length : x, S = (k) => f + (k + 0.5) * C, w = Math.min(48, C * 0.6), v = r.pubStyle ? "#000000" : "#334155", _ = r.pubStyle ? "#d4d4d8" : "#93c5fd", M = r.pubStyle ? "#000000" : "#1d4ed8", T = b(Math.max(c.min, 0)); + return /* @__PURE__ */ E.jsx("div", { className: "mini-plot-cell gl-layout-chart", style: { width: n, height: a, position: "relative" }, role: "img", "aria-label": `${i}: ${t.axis} across ${t.points.length} files`, children: /* @__PURE__ */ E.jsxs("svg", { width: n, height: a, viewBox: `0 0 ${n} ${a}`, style: { display: "block", fontFamily: "Arial, Helvetica, sans-serif" }, children: [ + /* @__PURE__ */ E.jsx("rect", { width: n, height: a, fill: "#ffffff" }), + i && /* @__PURE__ */ E.jsx("text", { x: n / 2, y: 8 + l, textAnchor: "middle", fontSize: l, fontWeight: 600, fill: v, children: i }), + !t.points.length && /* @__PURE__ */ E.jsx("text", { x: n / 2, y: a / 2, textAnchor: "middle", fontSize: o, fill: "#64748b", children: t.missing.length ? `${t.population} is not on ${t.missing.length} of the files` : "No files to draw" }), + /* @__PURE__ */ E.jsxs("g", { className: "gl-layout-chart-axis", fontSize: o, fill: v, children: [ + /* @__PURE__ */ E.jsx("line", { x1: f, x2: f, y1: d, y2: d + y, stroke: v }), + c.ticks.map((k) => /* @__PURE__ */ E.jsxs("g", { children: [ + /* @__PURE__ */ E.jsx("line", { x1: f - 4, x2: f, y1: b(k), y2: b(k), stroke: v }), + /* @__PURE__ */ E.jsx("text", { x: f - 6, y: b(k), textAnchor: "end", dominantBaseline: "central", children: La(k) }) + ] }, k)), + /* @__PURE__ */ E.jsx("text", { transform: `translate(${8 + s} ${d + y / 2}) rotate(-90)`, textAnchor: "middle", fontSize: s, children: t.axis }), + /* @__PURE__ */ E.jsx("line", { x1: f, x2: f + x, y1: T, y2: T, stroke: v }) + ] }), + /* @__PURE__ */ E.jsx("g", { className: "gl-layout-chart-groups", children: u.map((k, A) => { + const z = S(A), R = e.showPoints || e.chartType === "dots" ? k.points : []; + return /* @__PURE__ */ E.jsxs("g", { children: [ + e.chartType === "bars" && Number.isFinite(k.mean) && /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsx("rect", { x: z - w / 2, y: Math.min(b(k.mean), T), width: w, height: Math.abs(T - b(k.mean)), fill: _, stroke: v, strokeWidth: 0.8 }), + k.n > 1 && k.sd > 0 && /* @__PURE__ */ E.jsxs("g", { stroke: v, strokeWidth: 1, children: [ + /* @__PURE__ */ E.jsx("line", { x1: z, x2: z, y1: b(k.mean - k.sd), y2: b(k.mean + k.sd) }), + /* @__PURE__ */ E.jsx("line", { x1: z - w / 4, x2: z + w / 4, y1: b(k.mean + k.sd), y2: b(k.mean + k.sd) }), + /* @__PURE__ */ E.jsx("line", { x1: z - w / 4, x2: z + w / 4, y1: b(k.mean - k.sd), y2: b(k.mean - k.sd) }) + ] }) + ] }), + e.chartType === "box" && k.n > 0 && /* @__PURE__ */ E.jsxs("g", { stroke: v, strokeWidth: 1, fill: _, children: [ + /* @__PURE__ */ E.jsx("line", { x1: z, x2: z, y1: b(k.min), y2: b(k.q1) }), + /* @__PURE__ */ E.jsx("line", { x1: z, x2: z, y1: b(k.q3), y2: b(k.max) }), + /* @__PURE__ */ E.jsx("rect", { x: z - w / 2, y: b(k.q3), width: w, height: Math.max(0.5, b(k.q1) - b(k.q3)) }), + /* @__PURE__ */ E.jsx("line", { x1: z - w / 2, x2: z + w / 2, y1: b(k.median), y2: b(k.median), strokeWidth: 2 }) + ] }), + e.chartType === "dots" && k.n > 1 && /* @__PURE__ */ E.jsx("line", { x1: z - w / 2, x2: z + w / 2, y1: b(k.mean), y2: b(k.mean), stroke: v, strokeWidth: 2 }), + R.map((B, N) => /* @__PURE__ */ E.jsx("circle", { cx: z + oh(N + A * 31) * w * 0.3, cy: b(B.value), r: Math.max(2, o * 0.28), fill: M, stroke: "#ffffff", strokeWidth: 0.8, children: /* @__PURE__ */ E.jsx("title", { children: `${B.name}: ${La(B.value)}` }) }, B.sampleId)), + /* @__PURE__ */ E.jsx( + "text", + { + x: z, + y: d + y + 6, + textAnchor: h ? "end" : "middle", + dominantBaseline: "hanging", + fontSize: o, + fill: v, + transform: h ? `rotate(-45 ${z} ${d + y + 6})` : void 0, + children: k.label + } + ) + ] }, k.label || String(A)); + }) }), + t.test && u.length >= 2 && /* @__PURE__ */ E.jsxs("g", { className: "gl-layout-chart-test", fontSize: o, fill: v, children: [ + /* @__PURE__ */ E.jsx("line", { x1: S(0), x2: S(u.length - 1), y1: d - 4, y2: d - 4, stroke: v }), + /* @__PURE__ */ E.jsx("text", { x: (S(0) + S(u.length - 1)) / 2, y: d - 7, textAnchor: "middle", children: t.test.label }) + ] }) + ] }) }); +} +const Wa = (t) => ({ + tick: t.fontTick, + axis_label: t.fontAxis, + gate_label: t.fontGate, + title: t.fontTitle +}), lh = { x: "X (px)", y: "Y (px)", width: "Width (px)", height: "Height (px)" }, Xr = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4], Ns = 10, uh = { index: 0, units: [], items: [] }, ch = {}, Bs = { top: !0, left: !0, bottom: !0, right: !0, center: !0, middle: !0 }, fh = [ + { how: "left", label: "Left", title: "Align the left edges (one item: to the page margin)" }, + { how: "centerX", label: "Centre", title: "Align the horizontal centres (one item: to the page centre)" }, + { how: "right", label: "Right", title: "Align the right edges (one item: to the page margin)" }, + { how: "top", label: "Top", title: "Align the top edges (one item: to the page margin)" }, + { how: "centerY", label: "Middle", title: "Align the vertical centres (one item: to the page centre)" }, + { how: "bottom", label: "Bottom", title: "Align the bottom edges (one item: to the page margin)" } +], dh = [ + { how: "horizontal", label: "Spread ↔", title: "Equal gaps between three or more items, left to right" }, + { how: "vertical", label: "Spread ↕", title: "Equal gaps between three or more items, top to bottom" } +]; +function ph(t) { + return { + x: Math.round(parseFloat(t.style.left) || 0), + y: Math.round(parseFloat(t.style.top) || 0), + width: Math.round(parseFloat(t.style.width) || t.offsetWidth), + height: Math.round(parseFloat(t.style.height) || t.offsetHeight) + }; +} +function vh(t, e, r) { + return e ? r.some((n) => !!n && (t === `${e} · ${n}` || t.startsWith(`${e} · ${n} · `))) : !1; +} +function Ne(t, e, r) { + var o, s, l; + const n = t.recipe; + if (n.kind === "text") return n.text.split(` +`)[0] || "Text"; + if ((o = n.title) != null && o.trim()) return n.title.trim(); + if (n.kind === "figure") return ((l = (s = n.illustration.figure) == null ? void 0 : s.name) == null ? void 0 : l.trim()) || "Figure"; + if (n.kind === "proportions") return n.settings.plotType === "box" ? "Boxplot" : "Composition"; + const a = e.find(({ id: u }) => u === n.sampleId), i = a == null ? void 0 : a.tree.populations[n.populationId]; + return n.kind === "chart" ? `${(i == null ? void 0 : i.name) ?? "Population"} · ${Nu[n.statistic]}` : n.kind === "strategy" ? `${(i == null ? void 0 : i.name) ?? "Population"} strategy` : `${(i == null ? void 0 : i.name) ?? "Population"} · ${(a == null ? void 0 : a.name) ?? "FCS"}`; +} +function hh({ + item: t, + samples: e, + state: r, + globalScales: n, + dataRevision: a, + densityColorPower: i, + style: o, + canvasScale: s, + titleTemplate: l, + describe: u +}) { + var C; + const c = st.useRef(null), f = t.recipe, d = JSON.stringify(o), p = f.kind === "text" ? null : e.find(({ id: S }) => S === f.sampleId) ?? null, h = p ? { ...r, ...p.tree } : r, g = f.kind !== "text" && t.templateSampleId && t.templateSampleId !== f.sampleId ? e.find(({ id: S }) => S === t.templateSampleId) ?? null : null, x = f.kind === "text" || !p ? { id: f.kind === "text" ? "" : f.populationId, missing: !1 } : wc(f.populationId, p.tree, br(r), g == null ? void 0 : g.tree.id), y = x.id, b = x.missing ? ((C = g == null ? void 0 : g.tree.populations[f.kind === "text" ? "" : f.populationId]) == null ? void 0 : C.name) ?? "the population" : null; + return st.useEffect(() => { + const S = c.current; + if (!S || f.kind === "text") return; + const w = window.setTimeout(() => { + var L, V, G; + if (S.innerHTML = "", !p) { + S.textContent = "The referenced file is unavailable or still loading.", S.className = "gl-layout-plot-host is-missing"; + return; + } + const v = h.populations[y]; + if (b || !v) { + S.textContent = b ? `${p.name} has no population corresponding to ${b}.` : "The referenced population is unavailable.", S.className = "gl-layout-plot-host is-missing"; + return; + } + S.className = "gl-layout-plot-host"; + const _ = u({ ...f, populationId: y }), M = (W) => _ ? ia(W, _) : W, T = Math.max(120, t.width - 8), k = Math.max(120, t.height - 8); + if (f.kind === "strategy") { + const W = _c( + p.sample, + h.gates, + h.populations, + h.root_population_id ?? "", + y, + { fullPath: f.fullPath, maxEvents: o.maxEvents } + ), $ = 8, j = 26, J = Math.max(1, W.length); + let Q = 1, H = 0; + for (let U = 1; U <= J; U++) { + const et = Math.ceil(J / U), lt = Math.floor((T - $ * (U - 1)) / U), ft = Math.floor((k - j - $ * (et - 1)) / et), xt = Math.min(lt, ft); + xt > H && (H = xt, Q = U); + } + H = Math.max(100, Math.min(800, H)); + const tt = Mc( + p.sample, + W, + null, + n, + { + gateView: ["forward"], + displayMode: f.displayMode, + maxEvents: o.maxEvents, + nColumns: Q, + plotSize: H, + fitToColumns: !1, + contourThreshold: o.contourThreshold, + pointAlpha: o.pointAlpha, + densityColorPower: i, + pointSize: o.pointSize, + kdeBandwidth: o.kdeBandwidth, + pubStyle: o.pubStyle, + gateLineWidth: o.gateLineWidth, + gateLabelFormat: o.gateLabels, + fontSizes: Wa(o), + contextTitle: M(((L = f.title) == null ? void 0 : L.trim()) || "{population}") + } + ); + S.id = `layout-strategy-${t.id}`; + for (const U of Object.values(tt.plots ?? {})) U.canvas_scale = s; + No().renderStrategyGrid(S.id, tt); + return; + } + const A = Math.max(120, Math.min(T, k)), z = f.kind === "histogram" ? null : f.yChannel, R = kc( + p.sample, + h.gates, + h.gate_order, + h.populations, + p.derived.masks, + p.derived.stats.event_count, + [y], + [f.xChannel], + z, + n, + { + displayMode: f.displayMode, + maxEvents: o.maxEvents, + nColumns: 1, + plotSize: A, + fitToColumns: !1, + contourThreshold: o.contourThreshold, + pointAlpha: o.pointAlpha, + densityColorPower: i, + pointSize: o.pointSize, + kdeBandwidth: o.kdeBandwidth, + colorByPop: !1, + overlayPops: !1, + populationColors: {}, + histLineWidth: o.histLineWidth, + histFill: o.histFill, + histFillAlpha: o.histFillAlpha, + histOverlayMode: "front_opaque", + histLayout: "grid", + ridgeOverlap: 0.7, + ridgeColGap: 8, + ridgeGradient: !1, + pubStyle: o.pubStyle, + gateLineWidth: o.gateLineWidth, + gateLabelFormat: o.gateLabels, + fontSizes: Wa(o), + scaleFontsWithPlot: !0 + } + ), B = `${y}|${f.xChannel}`, N = (V = R.plots) == null ? void 0 : V[B]; + if (!N) { + S.textContent = "No events are available for this FCS/population combination.", S.className = "gl-layout-plot-host is-missing"; + return; + } + No().renderMiniPlot(S, { + ...N, + display_mode: f.displayMode, + plot_size: A, + canvas_scale: s, + contour_threshold: o.contourThreshold, + point_alpha: o.pointAlpha, + density_color_power: i, + point_size: o.pointSize, + kde_bandwidth: o.kdeBandwidth, + hist_line_width: o.histLineWidth, + hist_fill: o.histFill, + hist_fill_alpha: o.histFillAlpha, + hist_overlay_mode: "front_opaque", + title: M(l), + contour_levels: o.contourLevels, + font_sizes: Wa(o), + gate_style: { pub_style: o.pubStyle, line_width: o.gateLineWidth, label_format: o.gateLabels }, + pop_color: "#334155", + gates: ((G = R.gate_overlays) == null ? void 0 : G[B]) ?? [] + }); + }, 80); + return () => window.clearTimeout(w); + }, [ + a, + i, + d, + n, + t.height, + t.id, + t.width, + f, + p, + h.gate_order, + h.gate_version, + h.gates, + h.stored_hierarchies, + h.populations, + h.root_population_id, + y, + b, + s, + l, + u + ]), f.kind === "text" ? /* @__PURE__ */ E.jsx( + "div", + { + className: "gl-layout-text-surface", + style: { fontSize: f.fontSize, fontWeight: f.bold ? 700 : 400 }, + children: f.text + } + ) : /* @__PURE__ */ E.jsx("div", { ref: c, className: "gl-layout-plot-host" }); +} +function gh({ + item: t, + templateText: e, + selected: r, + samples: n, + state: a, + globalScales: i, + dataRevision: o, + densityColorPower: s, + style: l, + titleTemplate: u, + describe: c, + checkedSampleIds: f, + metadataById: d, + files: p, + sources: h, + divisionProfiles: g, + canvasScale: x, + onDelete: y, + onOpenInGating: b, + onTextChange: C, + onTextFocus: S, + onTextEscape: w +}) { + var T; + const { t: v } = Si(), _ = Cc(t), M = _ === 1 ? t : { ...t, width: Math.max(1, Math.round(t.width / _)), height: Math.max(1, Math.round(t.height / _)) }; + return /* @__PURE__ */ E.jsxs( + "article", + { + "data-item-id": t.id, + "data-template-id": t.templateId, + "data-zoom": _ === 1 ? void 0 : _, + className: `gl-layout-item${r ? " is-selected" : ""}${t.showFrame ? " has-frame" : ""}${t.recipe.kind === "text" ? " is-text" : ""}${t.locked ? " is-locked" : ""}`, + style: { + left: t.x, + top: t.y, + width: t.width, + height: t.height, + zIndex: t.z + }, + children: [ + /* @__PURE__ */ E.jsxs("header", { className: "gl-layout-item-head", children: [ + /* @__PURE__ */ E.jsxs("span", { title: Ne(t, n), children: [ + t.locked ? "🔒 " : "", + Ne(t, n) + ] }), + /* @__PURE__ */ E.jsxs("div", { children: [ + re(t.recipe) && /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-layout-item-action", + title: v("Open in Gating"), + onPointerDown: (k) => k.stopPropagation(), + onClick: b, + children: "↗" + } + ), + /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-layout-item-action", + title: v("Remove from layout"), + onPointerDown: (k) => k.stopPropagation(), + onClick: y, + children: "×" + } + ) + ] }) + ] }), + /* @__PURE__ */ E.jsx("div", { className: "gl-layout-item-body", style: _ === 1 ? void 0 : { zoom: _, width: M.width, height: M.height }, children: t.recipe.kind === "text" ? /* @__PURE__ */ E.jsx( + xh, + { + text: t.recipe.text, + templateText: e ?? t.recipe.text, + fontSize: t.recipe.fontSize, + bold: t.recipe.bold, + onCommit: C, + onFocus: S, + onEscape: w + } + ) : t.recipe.kind === "figure" ? /* @__PURE__ */ E.jsx( + Ec, + { + recipe: t.recipe, + files: p, + sources: h, + state: a, + globalScales: i, + width: Math.max(120, M.width - 8), + height: Math.max(80, M.height - 8) + } + ) : t.recipe.kind === "proportions" ? /* @__PURE__ */ E.jsx( + Dc, + { + recipe: t.recipe, + samples: p, + state: a, + metadataById: d, + divisionProfiles: g, + width: Math.max(120, M.width - 8), + height: Math.max(80, M.height - 8), + containerId: `layout-proportions-${t.id}` + } + ) : t.recipe.kind === "chart" ? /* @__PURE__ */ E.jsx("div", { className: "gl-layout-plot-host gl-layout-chart-host", children: /* @__PURE__ */ E.jsx( + sh, + { + data: ih(t.recipe, n, d, f, a), + recipe: t.recipe, + style: l, + width: Math.max(120, M.width - 8), + height: Math.max(80, M.height - 8), + title: ((T = t.recipe.title) == null ? void 0 : T.trim()) || Ne(t, n) + } + ) }) : /* @__PURE__ */ E.jsx( + hh, + { + item: M, + samples: n, + state: a, + globalScales: i, + dataRevision: o, + densityColorPower: s, + style: l, + canvasScale: x, + titleTemplate: u, + describe: c + } + ) }) + ] + } + ); +} +const mh = [ + { key: "pointSize", label: "Point size", step: 0.1 }, + { key: "pointAlpha", label: "Point opacity", step: 0.05 }, + { key: "maxEvents", label: "Events drawn", step: 1e3, integer: !0 }, + { key: "contourThreshold", label: "Contour threshold (%)", step: 0.5 }, + { key: "contourLevels", label: "Contour levels", step: 1, integer: !0 }, + { key: "kdeBandwidth", label: "Smoothing (0 = automatic)", step: 0.1 }, + { key: "gateLineWidth", label: "Gate line width", step: 0.25 }, + { key: "histLineWidth", label: "Histogram line width", step: 0.2 }, + { key: "histFillAlpha", label: "Histogram fill opacity", step: 0.05 }, + { key: "fontTick", label: "Tick font", step: 1 }, + { key: "fontAxis", label: "Axis font", step: 1 }, + { key: "fontTitle", label: "Title font", step: 1 }, + { key: "fontGate", label: "Gate label font", step: 1 } +]; +function js({ + effective: t, + own: e, + onChange: r +}) { + const { t: n } = Si(); + return /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-style-fields", children: [ + mh.map(({ key: a, label: i, step: o, integer: s }) => /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline" + (a in e ? " is-own" : ""), children: [ + n(i), + /* @__PURE__ */ E.jsx( + De, + { + "aria-label": n(i), + value: t[a], + min: zo[a][0], + max: zo[a][1], + step: o, + integer: s, + onCommit: (l) => r({ [a]: l }) + } + ) + ] }, a)), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline" + ("gateLabels" in e ? " is-own" : ""), children: [ + n("Gate labels"), + /* @__PURE__ */ E.jsxs( + "select", + { + "aria-label": n("Gate labels"), + value: t.gateLabels, + onChange: (a) => r({ gateLabels: a.target.value }), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "name-percent", children: n("Name and percentage") }), + /* @__PURE__ */ E.jsx("option", { value: "percent", children: n("Percentage") }), + /* @__PURE__ */ E.jsx("option", { value: "number", children: n("Number only") }), + /* @__PURE__ */ E.jsx("option", { value: "name", children: n("Name only") }), + /* @__PURE__ */ E.jsx("option", { value: "none", children: n("None") }) + ] + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-check" + ("pubStyle" in e ? " is-own" : ""), children: [ + /* @__PURE__ */ E.jsx( + "input", + { + type: "checkbox", + checked: t.pubStyle, + onChange: (a) => r({ pubStyle: a.target.checked }) + } + ), + n("Publication style (black gates and labels)") + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-check" + ("histFill" in e ? " is-own" : ""), children: [ + /* @__PURE__ */ E.jsx( + "input", + { + type: "checkbox", + checked: t.histFill, + onChange: (a) => r({ histFill: a.target.checked }) + } + ), + n("Fill histograms") + ] }) + ] }); +} +function xh({ + text: t, + templateText: e, + fontSize: r, + bold: n, + onCommit: a, + onFocus: i, + onEscape: o +}) { + const [s, l] = st.useState(t), [u, c] = st.useState(!1); + return st.useEffect(() => { + u || l(t); + }, [t, u]), /* @__PURE__ */ E.jsx( + "textarea", + { + className: "gl-layout-text-surface", + "aria-label": "Layout text", + value: s, + style: { fontSize: r, fontWeight: n ? 700 : 400 }, + onChange: (f) => l(f.target.value), + onFocus: () => { + c(!0), l(e), i(); + }, + onBlur: (f) => { + c(!1), s !== e ? a(s, f.currentTarget.scrollHeight) : l(t); + }, + onKeyDown: (f) => { + f.stopPropagation(), f.key === "Escape" && (l(e), f.currentTarget.blur(), o()); + } + } + ); +} +function bh({ + workspace: t, + onChange: e, + samples: r, + checkedSampleIds: n = [], + groups: a = [], + fileGroups: i = {}, + metadataColumns: o = [], + populationMetadata: s, + activeSampleId: l, + activePopulationId: u, + state: c, + globalScales: f, + defaultX: d, + defaultY: p, + illustrationConfig: h, + onOpenInIllustration: g, + plottingSettings: x, + divisionProfiles: y = ch, + onOpenInPlotting: b, + dataRevision: C, + densityColorPower: S, + onOpenInGating: w +}) { + var _o, Mo, ko, To; + const { t: v } = Si(), [_, M] = st.useState([]), [T, k] = st.useState(!0), [A, z] = st.useState(null), [R, B] = st.useState(null), [N, L] = st.useState([]), [V, G] = st.useState([]), W = st.useRef(null), $ = st.useRef(null), [j, J] = st.useState(null), [Q, H] = st.useState(null), [tt, U] = st.useState( + l ?? ((_o = r[0]) == null ? void 0 : _o.id) ?? "" + ), [et, lt] = st.useState("item"), [ft, xt] = st.useState(!1), [q, nt] = st.useState(1), Et = st.useRef(q); + Et.current = q; + const [pt, vt] = st.useState(q); + st.useEffect(() => { + const m = window.setTimeout(() => vt(q), 250); + return () => window.clearTimeout(m); + }, [q]); + const St = Math.min(4, Math.max(1, (typeof window > "u" ? 1 : window.devicePixelRatio || 1) * pt)), [_t, Mt] = st.useState("pdf"), [ht, Dt] = st.useState(!1), Bt = st.useRef(null), Zt = st.useRef(null), jt = (m) => { + var D; + M(m), (D = Bt.current) == null || D.focus({ preventScroll: !0 }); + }, Ft = (m) => jt(m ? [m] : []), Ot = lc( + r, + r.map((m) => m.id), + c, + C + ), kt = Ot.current ? Ot.sources.map((m) => ({ + ...m, + derived: m.gating + })) : [], Ee = st.useMemo( + () => Object.fromEntries(r.map((m) => [m.id, m.metadata])), + [r] + ), Ht = r.length === 0 || Ot.current && Ot.pending === 0, ze = st.useRef([]), Ze = st.useRef([]), K = t.sheets.find(({ id: m }) => m === t.activeSheetId) ?? t.sheets[0], dt = (K == null ? void 0 : K.iteration) ?? Fs, Jt = st.useMemo(() => { + const m = K == null ? void 0 : K.items.find((P) => re(P.recipe) && P.recipe.iterated === !0), D = m && "sampleId" in m.recipe ? m.recipe.sampleId : l; + return kt.find(({ id: P }) => P === D) ?? kt[0] ?? null; + }, [K, kt, l]), Je = st.useMemo( + () => dt.mode === "populations" ? Jt ? qv(dt, Jt.tree, r.find(({ id: m }) => m === Jt.id) ?? Jt) : [] : Hv(dt, r, n, a, i), + [dt, r, n, a, i, Jt] + ), Ie = st.useCallback((m, D) => { + const P = r.find(({ id: yt }) => yt === m.sampleId) ?? null, F = kt.find(({ id: yt }) => yt === m.sampleId) ?? null; + let X = m.populationId; + if (F && D && D !== m.sampleId) { + const yt = kt.find(({ id: Ct }) => Ct === D); + if (yt && yt.tree.id !== F.tree.id) { + const Ct = Hr({ hierarchyId: yt.tree.id, populationId: m.populationId }, F.tree, br(c)); + Ct.id && (X = Ct.id); + } + } + const it = F == null ? void 0 : F.tree.populations[X], ot = F == null ? void 0 : F.derived.stats.event_count[X]; + return Fv( + m.kind === "strategy" ? {} : m, + P ? { name: P.name, fileName: P.fileName ?? P.name, metadata: P.metadata } : null, + it ? { id: X, name: it.name } : null, + typeof ot == "number" ? ot : void 0, + s + ); + }, [r, kt, c, s]), ue = st.useMemo( + () => K ? Yv(K, Je, Ie) : [], + [K, Je, Ie] + ), [Fr, Fe] = st.useState(0), [pr, Tt] = st.useState(!1), [ee, mn] = st.useState(" · "), Lr = st.useMemo( + () => [...new Set(Object.values(s ?? {}).flatMap((m) => Object.keys(m)))].sort(), + [s] + ), xn = st.useMemo(() => jv(o, Lr), [o, Lr]), ce = Math.min(Fr, Math.max(0, ue.length - 1)), ae = ue[ce] ?? uh, io = ((Mo = K == null ? void 0 : K.titleTemplate) == null ? void 0 : Mo.trim()) || Lv( + ae.items.flatMap((m) => re(m.recipe) ? [{ sampleId: m.recipe.sampleId, populationId: m.recipe.populationId, label: m.recipe.kind === "strategy" ? void 0 : m.recipe.label }] : []) + ); + st.useEffect(() => { + Fr !== ce && Fe(ce); + }, [Fr, ce]); + const oo = (m) => m.split("::")[0], Le = [...new Set(_.map(oo))], vr = (K == null ? void 0 : K.items.filter(({ id: m }) => Le.includes(m))) ?? [], at = vr.length === 1 ? vr[0] : null, yn = at ? ae.items.find((m) => m.templateId === at.id) ?? null : null, so = (m, D) => { + var X; + if (!re(m.recipe)) return ""; + const P = ((X = m.recipe.title) == null ? void 0 : X.trim()) ?? ""; + if (!P) return ""; + const F = Ie(m.recipe, D); + return F && vh(P, F.population, [F.file, F.sample]) ? "" : P; + }, Bu = yn && re(yn.recipe) ? ia(io, Ie(yn.recipe, yn.templateSampleId) ?? { population: "", file: "", sample: "", x: "", y: "" }) : "", bn = vr.some((m) => m.locked); + st.useEffect(() => { + _.length && _.some((m) => !ae.items.some((D) => D.id === m)) && M((m) => m.filter((D) => ae.items.some((P) => P.id === D))); + }, [ae, _]), st.useLayoutEffect(() => { + if (!A) return; + const m = [...A.querySelectorAll("[data-item-id]")], D = (X, it) => X.length === it.length && X.every((ot, yt) => ot === it[yt]), P = m.filter((X) => _.includes(X.dataset.itemId ?? "")), F = m.filter((X) => !_.includes(X.dataset.itemId ?? "")); + L((X) => D(X, P) ? X : P), G((X) => D(X, F) ? X : F); + }, [A, _, ae, K == null ? void 0 : K.id]), st.useEffect(() => { + yo(); + }, [K == null ? void 0 : K.id]); + const ga = (m, D = !0) => { + D && (ze.current = [ + En(t), + ...ze.current + ].slice(0, 30), Ze.current = []), e(m); + }, hr = (m) => { + const D = En(t); + m(D), ga(D); + }, zt = (m) => { + hr((D) => { + const P = D.sheets.find(({ id: F }) => F === D.activeSheetId); + P && m(P); + }); + }, ma = st.useRef(null), [ju, xa] = st.useState(null), gr = (m, D) => { + let P = ""; + const F = ma.current; + ma.current = null, zt((X) => { + P = crypto.randomUUID(); + const it = Ao(X, D == null ? void 0 : D.width, D == null ? void 0 : D.height); + F && (it.x = Math.max(0, Math.round(F.x)), it.y = Math.max(0, Math.round(F.y))), X.items.push({ + id: P, + ...it, + recipe: m + }); + }), Ft(P), Vu(P); + }, te = kt.find(({ id: m }) => m === tt) ?? kt[0] ?? null, ya = te && u ? Hr( + { + hierarchyId: c.active_hierarchy_id, + populationId: u + }, + te.tree, + br(c) + ) : null, We = (ya == null ? void 0 : ya.id) ?? (te == null ? void 0 : te.tree.root_population_id) ?? "", Sn = (m) => { + var D, P, F; + if (!te || !We) { + H(v("Check an FCS file and select a population first.")); + return; + } + gr({ + kind: m, + sampleId: te.id, + populationId: We, + ...dt.mode !== "off" ? { iterated: !0 } : {}, + xChannel: te.sample.index(d) !== void 0 ? d : ((D = te.sample.channels[0]) == null ? void 0 : D.key) ?? "", + yChannel: m === "histogram" ? null : te.sample.index(p) !== void 0 ? p : ((P = te.sample.channels[1]) == null ? void 0 : P.key) ?? ((F = te.sample.channels[0]) == null ? void 0 : F.key) ?? null, + displayMode: "pseudocolor" + }); + }, lo = () => { + if (!te || !We) { + H(v("Check an FCS file and select a population first.")); + return; + } + gr( + { + kind: "chart", + sampleId: te.id, + populationId: We, + statistic: "percent_of_parent", + files: "checked", + groupBy: o[0] ?? "", + chartType: "bars", + showPoints: !0, + test: !0 + }, + { width: 320, height: 240 } + ); + }, uo = () => gr({ kind: "text", text: "Text", fontSize: 18 }, { width: 160, height: 32 }), Gu = (m, D) => { + zt((P) => { + const F = P.items.find((X) => X.id === m); + F && (F.recipe = D(F.recipe)); + }); + }, Fu = (m) => { + m.preventDefault(); + const D = m.target.closest("[data-item-id]"); + if (D != null && D.dataset.itemId) { + const it = D.dataset.itemId, ot = K == null ? void 0 : K.items.find(({ id: ge }) => ge === oo(it)); + if (!ot) return; + const yt = _.includes(it); + yt || jt([it]); + const Ct = yt && Le.length > 1 ? Le : [ot.id], mt = Ct.length > 1, Lt = re(ot.recipe), Ae = [ + { label: mt ? v("Duplicate {n} items", { n: Ct.length }) : v("Duplicate"), onClick: () => Yr(Ct) }, + { label: v("Bring to front"), onClick: () => mr(Ct, "front") }, + { label: v("Send to back"), onClick: () => mr(Ct, "back") }, + { label: ot.locked ? v("Unlock") : v("Lock"), onClick: () => ba(Ct, !ot.locked) }, + "separator", + ...dt.mode !== "off" && Lt ? [ + { + label: "iterated" in ot.recipe && ot.recipe.iterated ? v("Stop following the iteration") : v("Follow the iteration"), + onClick: () => Gu(ot.id, (ge) => re(ge) ? { ...ge, iterated: !ge.iterated } : ge) + }, + "separator" + ] : [], + ...Lt ? [{ label: v("Open in Gating"), onClick: () => w(ot.recipe) }] : [], + ...ot.recipe.kind === "figure" && g ? [{ label: v("Edit in Illustration"), onClick: () => g(structuredClone(ot.recipe.illustration)) }] : [], + ...ot.recipe.kind === "proportions" && b ? [{ label: v("Edit in Plotting"), onClick: () => b(structuredClone(ot.recipe.settings)) }] : [], + { label: mt ? v("Remove {n} items", { n: Ct.length }) : v("Remove"), onClick: () => Wr(Ct) } + ]; + xa({ x: m.clientX, y: m.clientY, items: Ae, label: Ne(ot, kt) }); + return; + } + const P = m.currentTarget.getBoundingClientRect(), F = { x: (m.clientX - P.left) / q, y: (m.clientY - P.top) / q }, X = (it) => () => { + ma.current = F, it(); + }; + xa({ + x: m.clientX, + y: m.clientY, + label: v("Page"), + items: [ + { label: v("+ Biplot"), disabled: !Ht, onClick: X(() => Sn("biplot")) }, + { label: v("+ Histogram"), disabled: !Ht, onClick: X(() => Sn("histogram")) }, + { label: v("+ Gating strategy"), disabled: !Ht, onClick: X(po) }, + { label: v("+ Chart"), disabled: !Ht, onClick: X(lo) }, + { label: v("+ Text"), onClick: X(uo) }, + { label: v("+ Illustration figure"), disabled: !Ht || !(h != null && h.figure), onClick: X(co) }, + { label: v("+ Plotting chart"), disabled: !Ht || !x, onClick: X(fo) }, + "separator", + { label: v("Select all"), disabled: !ae.items.length, onClick: () => jt(ae.items.map(({ id: it }) => it)) } + ] + }); + }, co = () => { + if (!(h != null && h.figure)) { + H(v("Make a figure on the Illustration tab first.")); + return; + } + K && gr({ kind: "figure", illustration: structuredClone(h), page: 0 }, vc(h, r, c, K)); + }, fo = () => { + if (!x || !K) return; + const m = x(), D = hc(m, gc(r), c, Ee, y); + if (!D.catLevels.length || !D.perSample.length) { + H(v("Choose files and populations on the Plotting tab first.")); + return; + } + gr({ kind: "proportions", settings: m }, mc(m, D, K)); + }, po = () => { + var P; + if (!te || !We) { + H(v("Check an FCS file and select a population first.")); + return; + } + const m = te.tree.root_population_id ?? "", D = We !== m ? We : ((P = Ln(te.tree.populations, m).filter(({ popId: F }) => F !== m).at(-1)) == null ? void 0 : P.popId) ?? We; + gr( + { + kind: "strategy", + sampleId: te.id, + populationId: D, + fullPath: !0, + displayMode: "pseudocolor", + ...dt.mode !== "off" ? { iterated: !0 } : {} + }, + { width: 600, height: 320 } + ); + }, Lu = () => { + var X, it; + if (!h) { + H(v("Render or configure an Illustration selection first.")); + return; + } + if (!h.figure && h.plotType === "heatmap") { + H( + v("Heatmap layout blocks are planned for the next Layout phase.") + ); + return; + } + const m = new Map(kt.map((ot) => [ot.id, ot])), D = [], P = h.figure; + for (const ot of kt) { + if (P) { + if (!P.sampleIds.includes(ot.id)) continue; + for (const Ct of P.plots) + if (Ct.type !== "heatmap") + for (const mt of Ct.population ? [Ct.population] : ((X = P.samplePopulations) == null ? void 0 : X[ot.id]) ?? P.populations) { + const Lt = Hr( + mt, + ot.tree, + br(c) + ); + Lt.id && Lt.status !== "changed" && D.push({ + sampleId: ot.id, + populationId: Lt.id, + xChannel: Ct.x, + yChannel: Ct.y, + type: Ct.type + }); + } + continue; + } + const yt = h.selectionMode === "matrix" ? ((it = h.selectedPopulationsBySample) == null ? void 0 : it[ot.id]) ?? [] : h.popIds; + for (const Ct of yt) + for (const mt of h.xChannels) + D.push({ sampleId: ot.id, populationId: Ct, xChannel: mt }); + } + const F = D.slice(0, 60); + if (F.length === 0) { + H( + v("The current Illustration selection has no plot combinations.") + ); + return; + } + zt((ot) => { + for (const yt of F) { + if (!m.get(yt.sampleId)) continue; + const mt = yt.type ?? (h.plotType === "histogram" ? "histogram" : "biplot"); + ot.items.push({ + id: crypto.randomUUID(), + ...Ao(ot), + recipe: { + kind: mt, + sampleId: yt.sampleId, + populationId: yt.populationId, + xChannel: yt.xChannel, + yChannel: mt === "histogram" ? null : yt.yChannel ?? h.yChannel, + displayMode: h.displayMode === "dots" ? "scatter" : h.displayMode + } + }); + } + }), H( + D.length > F.length ? v( + "Added the first {count} Illustration plots; refine the selection before adding more.", + { + count: F.length + } + ) : v("Added {count} Illustration plots.", { count: F.length }) + ); + }, It = (m) => { + at && zt((D) => { + const P = D.items.find(({ id: F }) => F === at.id); + P && (P.recipe = m(P.recipe)); + }); + }, Wr = (m) => { + zt((D) => { + D.items = D.items.filter((P) => !m.includes(P.id)); + }), M((D) => D.filter((P) => !m.includes(P))); + }, Yr = (m, D) => { + const P = []; + return zt((F) => { + let X = Math.max(0, ...F.items.map((it) => it.z)); + for (const it of m) { + const ot = F.items.find((mt) => mt.id === it); + if (!ot) continue; + const yt = crypto.randomUUID(); + P.push(yt); + const Ct = (D == null ? void 0 : D[it]) ?? { x: ot.x + 20, y: ot.y + 20, width: ot.width, height: ot.height }; + F.items.push({ ...ot, ...Ct, id: yt, locked: !1, z: ++X, recipe: { ...ot.recipe } }); + } + }), P.length && jt(P), P; + }, Wu = (m, D, P) => { + zt((F) => { + for (const X of F.items) + !m.includes(X.id) || X.locked || (X.x = Math.max(0, X.x + D), X.y = Math.max(0, X.y + P)); + }); + }, mr = (m, D) => { + zt((P) => { + const F = [...P.items].sort((yt, Ct) => yt.z - Ct.z), X = F.filter((yt) => m.includes(yt.id)), it = F.filter((yt) => !m.includes(yt.id)); + (D === "front" ? [...it, ...X] : [...X, ...it]).forEach((yt, Ct) => { + yt.z = Ct; + }); + }); + }, ba = (m, D) => { + zt((P) => { + for (const F of P.items) m.includes(F.id) && (F.locked = D); + }); + }, Yu = (m) => { + zt((D) => Tc(D, Le.filter((P) => { + var F; + return !((F = D.items.find((X) => X.id === P)) != null && F.locked); + }), m)); + }, Xu = (m) => { + zt((D) => Ic(D, Le, m)); + }, Cn = (m, D) => { + const P = {}; + for (const X of m) { + const it = X.dataset.itemId, ot = ae.items.find((mt) => mt.id === it); + if (!ot) continue; + const { id: yt, ...Ct } = Vv(ot, ph(X)); + P[yt] = Ct; + } + const F = Object.keys(P); + if (F.length) { + if (D) { + for (const X of m) { + const it = ae.items.find((ot) => ot.id === X.dataset.itemId); + it && Object.assign(X.style, { left: `${it.x}px`, top: `${it.y}px`, width: `${it.width}px`, height: `${it.height}px` }); + } + Yr(F, P); + return; + } + zt((X) => { + for (const it of X.items) P[it.id] && Object.assign(it, P[it.id]); + }); + } + }, vo = (m) => m.flatMap((D) => { + if (!(D instanceof HTMLElement) || !D.parentElement) return []; + const P = D.cloneNode(!0); + P.classList.add("gl-layout-ghost"), P.classList.remove("is-selected"), P.removeAttribute("data-item-id"), P.setAttribute("aria-hidden", "true"); + const F = D.querySelectorAll("canvas"); + return P.querySelectorAll("canvas").forEach((X, it) => { + var yt; + const ot = F[it]; + ot && (X.width = ot.width, X.height = ot.height, (yt = X.getContext("2d")) == null || yt.drawImage(ot, 0, 0)); + }), D.parentElement.insertBefore(P, D), [P]; + }), ho = (m) => { + if (Array.isArray(m)) for (const D of m) D.remove(); + }, go = (m) => { + m.target.style.left = `${m.left}px`, m.target.style.top = `${m.top}px`; + }, mo = (m) => { + m.target.style.width = `${m.width}px`, m.target.style.height = `${m.height}px`, m.target.style.left = `${m.drag.left}px`, m.target.style.top = `${m.drag.top}px`; + }, Hu = (m) => { + var F; + const D = (F = m.inputEvent) == null ? void 0 : F.target; + if (!D) return; + const P = W.current; + if (P != null && P.isMoveableElement(D)) { + m.stop(); + return; + } + N.some((X) => X === D || X.contains(D)) && (m.stop(), N.length > 1 && (P == null || P.dragStart(m.inputEvent))); + }, qu = (m) => { + var P, F, X; + const D = m.selected.map((it) => it.dataset.itemId ?? "").filter(Boolean); + jt(D), m.isDragStart && ((F = (P = m.inputEvent) == null ? void 0 : P.preventDefault) == null || F.call(P), (X = W.current) == null || X.waitToChangeTarget().then(() => { + var it; + return (it = W.current) == null ? void 0 : it.dragStart(m.inputEvent); + })); + }, Vu = (m) => { + window.requestAnimationFrame(() => { + var D, P, F; + (F = (P = (D = Zt.current) == null ? void 0 : D.querySelector(`[data-item-id="${m}"]`)) == null ? void 0 : P.scrollIntoView) == null || F.call(P, { block: "nearest", inline: "nearest" }); + }); + }, Qe = (m) => { + zt((D) => xc(D, m)); + }, $u = () => zt((m) => yc(m)), Uu = () => zt((m) => bc(m)), xo = (() => { + const m = [], D = []; + if (!K) return { vertical: m, horizontal: D }; + const P = Ya(K.page), F = Ro(K.page.marginMm); + for (const X of Xn(K.page)) + m.push(X.x, X.x + F, X.x + P.width / 2, X.x + P.width - F, X.x + P.width), D.push(X.y, X.y + F, X.y + P.height / 2, X.y + P.height - F, X.y + P.height); + return { vertical: [...new Set(m)], horizontal: [...new Set(D)] }; + })(), yo = () => { + const m = Bt.current; + if (!m || !K) return; + const D = { width: m.clientWidth - 36, height: m.clientHeight - 36 }; + if (D.width <= 0 || D.height <= 0) return; + const P = Math.min(D.width / K.width, D.height / K.height); + nt(Math.max(0.1, Math.min(4, Math.floor(P * 100) / 100))); + }; + st.useEffect(() => { + const m = R; + if (!m) return; + const D = (P) => { + if (!(P.altKey || P.shiftKey || P.ctrlKey)) return; + const F = P.deltaY || P.deltaX; + if (!F) return; + P.preventDefault(); + const X = Et.current, it = Math.max(0.1, Math.min(4, Math.round(X * Math.exp(-F * 25e-4) * 100) / 100)); + if (it === X) return; + Et.current = it, nt(it); + const ot = m.getBoundingClientRect(), yt = P.clientX - ot.left, Ct = P.clientY - ot.top, mt = it / X, Lt = (m.scrollLeft + yt) * mt - yt, Ae = (m.scrollTop + Ct) * mt - Ct; + requestAnimationFrame(() => { + m.scrollLeft = Lt, m.scrollTop = Ae; + }); + }; + return m.addEventListener("wheel", D, { passive: !1 }), () => m.removeEventListener("wheel", D); + }, [R]); + const bo = (m) => { + const D = m > 0 ? Xr.find((P) => P > q + 1e-3) : [...Xr].reverse().find((P) => P < q - 1e-3); + D && nt(D); + }, Ku = () => new Promise((m) => { + window.setTimeout(() => window.requestAnimationFrame(() => window.requestAnimationFrame(() => m())), 450); + }), So = async () => { + const m = Zt.current; + if (!m || !K || ht) return; + Dt(!0); + const D = ce; + try { + const P = []; + for (let F = 0; F < ue.length; F++) + ue.length > 1 && (Fe(F), await Ku()), P.push(...Av(m, K, { zoom: q })); + await Nv(P, K, _t); + } catch (P) { + H(P instanceof Error ? P.message : String(P)); + } finally { + ue.length > 1 && Fe(D), Dt(!1); + } + }, tr = (m) => { + zt((D) => { + var P; + if (m.mode === "off") { + delete D.iteration; + return; + } + if ((((P = D.iteration) == null ? void 0 : P.mode) ?? "off") === "off" && !D.items.some(Ou)) + for (const F of D.items) re(F.recipe) && (F.recipe.iterated = !0); + D.iteration = m; + }), Fe(0); + }, Zu = (m) => [...new Set(r.map((D) => { + var P; + return ((P = D.metadata) == null ? void 0 : P[m]) ?? ""; + }).filter(Boolean))], Ju = dt.source.kind === "group" ? `group:${dt.source.groupId}` : dt.source.kind === "metadata" ? `meta:${dt.source.column}=${dt.source.value}` : dt.source.kind, Qu = (m) => { + if (m === "all") return { kind: "all" }; + if (m.startsWith("group:")) return { kind: "group", groupId: m.slice(6) }; + if (m.startsWith("meta:")) { + const [D, ...P] = m.slice(5).split("="); + return { kind: "metadata", column: D, value: P.join("=") }; + } + return { kind: "checked" }; + }, tc = (m) => { + const D = Sc(m.nativeEvent); + if (D) { + m.preventDefault(), D === "undo" ? Do() : wo(); + return; + } + if (m.target.closest("input, textarea, select")) return; + const P = m.metaKey || m.ctrlKey; + if (m.key === "Escape") { + M([]); + return; + } + if (P && m.key.toLowerCase() === "a") { + m.preventDefault(), jt(((K == null ? void 0 : K.items) ?? []).filter((ot) => !ot.locked).map((ot) => ot.id)); + return; + } + if (!_.length) return; + if (m.key === "Delete" || m.key === "Backspace") { + m.preventDefault(), Wr(Le); + return; + } + if (P && m.key.toLowerCase() === "d") { + m.preventDefault(), Yr(Le); + return; + } + const F = m.shiftKey ? 10 : 1, it = { + ArrowLeft: [-F, 0], + ArrowRight: [F, 0], + ArrowUp: [0, -F], + ArrowDown: [0, F] + }[m.key]; + it && (m.preventDefault(), Wu(Le, it[0], it[1])); + }, Sa = at == null ? void 0 : at.recipe, Nt = Sa && "sampleId" in Sa ? kt.find(({ id: m }) => m === Sa.sampleId) ?? null : null, Co = Nt ? Nt.sample.channels.map((m) => ({ + value: m.key, + label: Nt.sample.channelLabel(Nt.sample.index(m.key) ?? 0) + })) : [], Eo = Nt ? Ln( + Nt.tree.populations, + Nt.tree.root_population_id ?? "" + ) : [], Do = () => { + const m = ze.current.shift(); + m && (Ze.current = [ + En(t), + ...Ze.current + ].slice(0, 30), ga(m, !1)); + }, wo = () => { + const m = Ze.current.shift(); + m && (ze.current = [ + En(t), + ...ze.current + ].slice(0, 30), ga(m, !1)); + }; + return K ? /* @__PURE__ */ E.jsxs( + "div", + { + className: `gl-tab-panel gl-tab-fill gl-layout-tab${ft ? " is-preview" : ""}`, + children: [ + /* @__PURE__ */ E.jsxs( + "div", + { + className: "gl-layout-sheet-tabs", + role: "tablist", + "aria-label": v("Layout sheets"), + children: [ + t.sheets.map((m) => /* @__PURE__ */ E.jsx("div", { className: "gl-layout-sheet-tab-wrap", children: j === m.id ? /* @__PURE__ */ E.jsx( + "input", + { + className: "gl-layout-sheet-rename", + defaultValue: m.name, + autoFocus: !0, + onFocus: (D) => D.currentTarget.select(), + onBlur: (D) => { + const P = D.currentTarget.value.trim(); + P && hr((F) => { + const X = F.sheets.find( + ({ id: it }) => it === m.id + ); + X && (X.name = P); + }), J(null); + }, + onKeyDown: (D) => { + D.key === "Enter" && D.currentTarget.blur(), D.key === "Escape" && J(null); + } + } + ) : /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + role: "tab", + "aria-selected": t.activeSheetId === m.id, + className: `gl-layout-sheet-tab${t.activeSheetId === m.id ? " active" : ""}`, + title: v("Double-click to rename"), + onClick: () => hr((D) => { + D.activeSheetId = m.id; + }), + onDoubleClick: () => J(m.id), + children: m.name + } + ) }, m.id)), + /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-layout-sheet-add", + title: v("New blank layout"), + onClick: () => { + const m = uc( + `Layout ${t.sheets.length + 1}`, + { ...K.page } + ); + hr((D) => { + D.sheets.push(m), D.activeSheetId = m.id; + }), M([]); + }, + children: "+" + } + ) + ] + } + ), + /* @__PURE__ */ E.jsxs( + "div", + { + className: "gl-layout-toolbar", + onMouseDown: (m) => { + m.target.closest("button") && _.length && m.preventDefault(); + }, + children: [ + /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-toolbar-group", children: [ + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: () => Sn("biplot"), disabled: !Ht, title: v(Ht ? "Add a plot of one population on two channels of the chosen file" : "Preparing the files…"), children: v("+ Biplot") }), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: () => Sn("histogram"), disabled: !Ht, title: v(Ht ? "Add a histogram of one population on one channel of the chosen file" : "Preparing the files…"), children: v("+ Histogram") }), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: po, disabled: !Ht, title: v(Ht ? "Add the gating steps that lead to a population, as a strip of plots" : "Preparing the files…"), children: v("+ Gating strategy") }), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: lo, disabled: !Ht, title: v(Ht ? "Add a summary chart: one statistic of a population per file, grouped by a metadata column, with a test between the groups" : "Preparing the files…"), children: v("+ Chart") }), + /* @__PURE__ */ E.jsx( + "button", + { + className: "gl-mini-btn", + type: "button", + title: v("Add a text block; edit it on the page"), + onClick: uo, + children: v("+ Text") + } + ), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: Lu, disabled: !Ht, title: v("Add one plot per file and plot of the Illustration tab's current selection"), children: v("Add Illustration selection") }), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: co, disabled: !Ht, title: v("Add the Illustration tab's current figure as one block, drawn here as it is there"), children: v("+ Illustration figure") }), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: fo, disabled: !Ht || !x, title: v("Add the Plotting tab's current chart as one block, drawn here as it is there"), children: v("+ Plotting chart") }) + ] }), + /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-toolbar-group gl-layout-arrange", role: "group", "aria-label": v("Arrange"), children: [ + fh.map(({ how: m, label: D, title: P }) => /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: () => Yu(m), disabled: !_.length || ft, title: v(P), children: v(D) }, m)), + dh.map(({ how: m, label: D, title: P }) => /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: () => Xu(m), disabled: _.length < 3 || ft, title: v(P), children: v(D) }, m)), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", "aria-pressed": T, onClick: () => k((m) => !m), title: v("Snap moves and resizes to a 10 px grid; edges and centres of other items and the page snap always"), children: v("Snap grid") }) + ] }), + /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-toolbar-group", children: [ + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", "aria-pressed": ft, onClick: () => xt(!ft), title: v("Show the page as it exports, without grid, margins or handles"), children: v(ft ? "Edit layout" : "Preview") }), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", disabled: !ze.current.length, onClick: Do, title: v("Undo the last layout edit (Cmd-Z)"), children: v("Undo") }), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", disabled: !Ze.current.length, onClick: wo, title: v("Redo the undone edit (Shift-Cmd-Z)"), children: v("Redo") }), + /* @__PURE__ */ E.jsx( + "button", + { + className: "gl-mini-btn", + type: "button", + title: v("Copy this sheet, with its page and items, as a new sheet"), + onClick: () => { + const m = { + ...K, + id: crypto.randomUUID(), + page: { ...K.page }, + name: `${K.name} copy`, + items: K.items.map((D) => ({ + ...D, + id: crypto.randomUUID(), + recipe: { ...D.recipe } + })) + }; + hr((D) => { + D.sheets.push(m), D.activeSheetId = m.id; + }), M([]); + }, + children: v("Duplicate sheet") + } + ), + /* @__PURE__ */ E.jsx( + "button", + { + className: "gl-mini-btn", + type: "button", + disabled: t.sheets.length <= 1, + title: v("Remove this sheet; the layout keeps at least one"), + onClick: () => { + hr((m) => { + const D = m.sheets.findIndex( + ({ id: P }) => P === m.activeSheetId + ); + m.sheets.splice(D, 1), m.activeSheetId = m.sheets[Math.max(0, D - 1)].id; + }), M([]); + }, + children: v("Delete sheet") + } + ) + ] }), + /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-toolbar-group gl-layout-zoom-controls", role: "group", "aria-label": v("Zoom"), children: [ + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: yo, title: v("Fit the page to the window"), children: v("Fit") }), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: () => bo(-1), "aria-label": v("Zoom out"), title: v("Zoom out"), disabled: q <= Xr[0], children: "−" }), + /* @__PURE__ */ E.jsxs("span", { className: "gl-layout-zoom-level", "aria-live": "polite", children: [ + Math.round(q * 100), + "%" + ] }), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: () => bo(1), "aria-label": v("Zoom in"), title: v("Zoom in"), disabled: q >= Xr[Xr.length - 1], children: "+" }) + ] }), + (ue.length > 1 || dt.mode !== "off") && /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-toolbar-group gl-layout-pages", role: "group", "aria-label": v("Pages of the iteration"), children: [ + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: () => Fe(Math.max(0, ce - 1)), disabled: ce === 0, "aria-label": v("Previous page"), title: v("Previous page"), children: "◀" }), + /* @__PURE__ */ E.jsxs("span", { className: "gl-layout-page-label", "aria-live": "polite", children: [ + v("Page {n} of {count}", { n: ce + 1, count: Math.max(1, ue.length) }), + ae.units.length > 0 && ` · ${ae.units.map((m) => m.name).join(", ")}` + ] }), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: () => Fe(Math.min(ue.length - 1, ce + 1)), disabled: ce >= ue.length - 1, "aria-label": v("Next page"), title: v("Next page"), children: "▶" }) + ] }), + /* @__PURE__ */ E.jsx("div", { className: "gl-layout-toolbar-group", children: /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: () => void So(), disabled: ht || !K.items.length, title: ue.length > 1 ? v("Write every page of the iteration; the format is chosen under Page") : v("Write this sheet at its page size; the format is chosen under Page"), children: ht ? v("Exporting…") : v("Export {format}", { format: _t.toUpperCase() }) }) }), + /* @__PURE__ */ E.jsx("span", { className: "gl-layout-performance-note", children: v("Plots follow the Gating tab's axes and gates; edit gates there.") }) + ] + } + ), + Q && /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-message", role: "status", children: [ + /* @__PURE__ */ E.jsx("span", { children: Q }), + /* @__PURE__ */ E.jsx("button", { type: "button", title: v("Dismiss"), "aria-label": v("Dismiss"), onClick: () => H(null), children: "×" }) + ] }), + /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-workspace", children: [ + /* @__PURE__ */ E.jsxs("aside", { className: "gl-layout-controls", "aria-label": "Layout controls", children: [ + /* @__PURE__ */ E.jsx("nav", { className: "gl-presentation-tabs", "aria-label": "Layout inspector", children: ["item", "page", "iterate", "style"].map((m) => /* @__PURE__ */ E.jsx( + "button", + { + "aria-pressed": et === m, + title: v(m === "item" ? "The selected item, or the file new plots take" : m === "page" ? "Page size, margins, pages and export" : m === "iterate" ? "Draw the sheet once per file: which files, and pages or tiles" : "How the sheet's plots are drawn: points, contours, histograms, gates and fonts"), + onClick: () => lt(m), + children: v(m === "item" ? "Items" : m === "page" ? "Page" : m === "iterate" ? "Iterate" : "Style") + }, + m + )) }), + et === "item" && /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + "File for new plots", + /* @__PURE__ */ E.jsx( + "select", + { + value: tt, + onChange: (m) => U(m.target.value), + children: r.map((m) => /* @__PURE__ */ E.jsx("option", { value: m.id, children: m.name }, m.id)) + } + ) + ] }), + /* @__PURE__ */ E.jsx("p", { className: "gl-hint", children: "Placed plots keep their own file and hierarchy, independently of the Gating selection." }), + Ot.error && /* @__PURE__ */ E.jsx("p", { role: "alert", children: Ot.error }), + vr.length > 1 && /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-inspector", "aria-label": v("Selected layout items"), children: [ + /* @__PURE__ */ E.jsx("strong", { children: v("{count} items selected", { count: vr.length }) }), + /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-item-actions", children: [ + /* @__PURE__ */ E.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => Yr(_), title: v("Copies of every selected item, 20 px down and right (Cmd-D)"), children: v("Duplicate") }), + /* @__PURE__ */ E.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => mr(_, "front"), title: v("Draw the selected items over every other"), children: v("Bring to front") }), + /* @__PURE__ */ E.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => mr(_, "back"), title: v("Draw the selected items under every other"), children: v("Send to back") }), + /* @__PURE__ */ E.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => ba(_, !bn), title: v("Lock or unlock the selected items"), children: v(bn ? "Unlock" : "Lock") }), + /* @__PURE__ */ E.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => Wr(_), title: v("Remove the selected items (Delete)"), children: v("Remove") }) + ] }), + /* @__PURE__ */ E.jsx("p", { className: "gl-hint", children: v("Align and spread them with the toolbar; drag any of them to move them together.") }) + ] }), + !vr.length && /* @__PURE__ */ E.jsx("p", { className: "gl-hint", children: v("Click an item to select it, drag empty page to select several, Shift-click to add. Drag to move; drag a corner handle or an edge to resize; Option-drag to copy. Delete removes, arrows nudge (Shift: 10 px), Cmd-D duplicates, Cmd-A selects all, Cmd-Z undoes.") }), + at && /* @__PURE__ */ E.jsxs( + "div", + { + className: "gl-layout-inspector", + "aria-label": v("Selected layout item"), + children: [ + /* @__PURE__ */ E.jsx("strong", { children: v("Selected") }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-check", children: [ + /* @__PURE__ */ E.jsx( + "input", + { + type: "checkbox", + checked: at.showFrame === !0, + onChange: (m) => zt((D) => { + const P = D.items.find( + (F) => F.id === at.id + ); + P && (P.showFrame = m.target.checked); + }) + } + ), + "Surrounding frame" + ] }), + /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-item-actions", children: [ + /* @__PURE__ */ E.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => Yr([at.id]), title: v("A copy 20 px down and right (Cmd-D); Option-drag an item to copy it where you drop it"), children: v("Duplicate") }), + /* @__PURE__ */ E.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => mr([at.id], "front"), title: v("Draw this item over every other"), children: v("Bring to front") }), + /* @__PURE__ */ E.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => mr([at.id], "back"), title: v("Draw this item under every other"), children: v("Send to back") }), + /* @__PURE__ */ E.jsx("button", { type: "button", className: "gl-mini-btn", onClick: () => Wr([at.id]), title: v("Remove this item from the page (Delete)"), children: v("Remove") }) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-check", title: v("A locked item keeps its place and size; it can still be selected to unlock it"), children: [ + /* @__PURE__ */ E.jsx( + "input", + { + type: "checkbox", + checked: at.locked === !0, + onChange: (m) => ba([at.id], m.target.checked) + } + ), + v("Locked") + ] }), + /* @__PURE__ */ E.jsx("div", { className: "gl-layout-dimensions", children: ["x", "y", "width", "height"].map((m) => /* @__PURE__ */ E.jsxs("label", { children: [ + lh[m], + /* @__PURE__ */ E.jsx( + De, + { + "aria-label": `Item ${m}`, + min: m === "width" || m === "height" ? cc(at.recipe.kind)[m] : 0, + integer: !0, + value: at[m], + onCommit: (D) => zt((P) => { + const F = P.items.find( + (X) => X.id === at.id + ); + F && (F[m] = D); + }) + } + ) + ] }, m)) }), + at.recipe.kind === "text" ? /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Text"), + /* @__PURE__ */ E.jsx( + "input", + { + value: at.recipe.text, + onChange: (m) => It( + (D) => D.kind === "text" ? { ...D, text: m.target.value } : D + ) + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Reads from"), + /* @__PURE__ */ E.jsxs( + "select", + { + "aria-label": v("Reads from"), + value: at.recipe.readsFrom ?? "", + onChange: (m) => It((D) => { + if (D.kind !== "text") return D; + const P = { ...D }; + return m.target.value ? P.readsFrom = m.target.value : delete P.readsFrom, P; + }), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "", children: v("Nothing: plain text") }), + K.items.filter((m) => re(m.recipe)).map((m) => /* @__PURE__ */ E.jsx("option", { value: m.id, children: Ne(m, kt) }, m.id)) + ] + } + ) + ] }), + at.recipe.readsFrom && /* @__PURE__ */ E.jsx("p", { className: "gl-hint", children: v("The placeholders read that plot: {list}. On an iterated sheet they follow it from tile to tile.", { list: Ba }) }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Font"), + /* @__PURE__ */ E.jsx( + De, + { + min: 8, + max: 72, + integer: !0, + value: at.recipe.fontSize, + onCommit: (m) => It( + (D) => D.kind === "text" ? { ...D, fontSize: m } : D + ) + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-check", children: [ + /* @__PURE__ */ E.jsx( + "input", + { + type: "checkbox", + checked: at.recipe.bold === !0, + onChange: (m) => It((D) => { + if (D.kind !== "text") return D; + const P = { ...D }; + return m.target.checked ? P.bold = !0 : delete P.bold, P; + }) + } + ), + v("Bold") + ] }) + ] }) : at.recipe.kind === "figure" ? /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsx("p", { className: "gl-hint", children: v("An Illustration figure, drawn here as it is there. To change it, edit it on the Illustration tab and put it back with the button below.") }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Figure page"), + /* @__PURE__ */ E.jsx( + De, + { + "aria-label": v("Figure page"), + value: at.recipe.page + 1, + min: 1, + integer: !0, + onCommit: (m) => It((D) => D.kind === "figure" ? { ...D, page: Math.max(0, m - 1) } : D) + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline gl-layout-title-field", children: [ + v("Title"), + /* @__PURE__ */ E.jsx( + "input", + { + placeholder: Ne(at, kt), + value: at.recipe.title ?? "", + onChange: (m) => It((D) => D.kind === "figure" ? { ...D, title: m.target.value } : D) + } + ) + ] }), + g && /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + title: v("Load this figure into the Illustration tab"), + onClick: () => g(structuredClone(at.recipe.illustration)), + children: v("Edit in Illustration") + } + ), + /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: !(h != null && h.figure), + title: v("Take the Illustration tab's current figure in place of this one"), + onClick: () => It( + (m) => m.kind === "figure" && h ? { ...m, illustration: structuredClone(h) } : m + ), + children: v("Replace with the current Illustration figure") + } + ) + ] }) : at.recipe.kind === "proportions" ? /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsx("p", { className: "gl-hint", children: v("A Plotting chart, drawn here as it is there. To change it, edit it on the Plotting tab and put it back with the button below.") }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline gl-layout-title-field", children: [ + v("Title"), + /* @__PURE__ */ E.jsx( + "input", + { + placeholder: Ne(at, kt), + value: at.recipe.title ?? "", + onChange: (m) => It((D) => D.kind === "proportions" ? { ...D, title: m.target.value } : D) + } + ) + ] }), + b && /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + title: v("Load this chart's settings into the Plotting tab"), + onClick: () => b(structuredClone(at.recipe.settings)), + children: v("Edit in Plotting") + } + ), + /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + disabled: !x, + title: v("Take the Plotting tab's current chart in place of this one"), + onClick: () => { + const m = x == null ? void 0 : x(); + m && It((D) => D.kind === "proportions" ? { ...D, settings: m } : D); + }, + children: v("Replace with the current Plotting chart") + } + ) + ] }) : at.recipe.kind === "chart" ? /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Population"), + /* @__PURE__ */ E.jsx( + "select", + { + value: at.recipe.populationId, + onChange: (m) => It((D) => D.kind === "chart" ? { ...D, populationId: m.target.value } : D), + children: Eo.map(({ popId: m, depth: D }) => { + var P; + return /* @__PURE__ */ E.jsxs("option", { value: m, children: [ + " ".repeat(D * 2), + ((P = Nt == null ? void 0 : Nt.tree.populations[m]) == null ? void 0 : P.name) ?? m + ] }, m); + }) + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Statistic"), + /* @__PURE__ */ E.jsxs( + "select", + { + value: at.recipe.statistic, + onChange: (m) => It((D) => { + var X; + if (D.kind !== "chart") return D; + const P = m.target.value, F = P === "median" && !D.channel ? (X = Nt == null ? void 0 : Nt.sample.channels[0]) == null ? void 0 : X.key : D.channel; + return { ...D, statistic: P, ...F ? { channel: F } : {} }; + }), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "percent_of_parent", children: v("% of parent") }), + /* @__PURE__ */ E.jsx("option", { value: "percent_of_total", children: v("% of total") }), + /* @__PURE__ */ E.jsx("option", { value: "count", children: v("Events") }), + /* @__PURE__ */ E.jsx("option", { value: "median", children: v("Median of a channel") }) + ] + } + ) + ] }), + at.recipe.statistic === "median" && /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Channel"), + /* @__PURE__ */ E.jsx( + "select", + { + value: at.recipe.channel ?? "", + onChange: (m) => It((D) => D.kind === "chart" ? { ...D, channel: m.target.value } : D), + children: ((Nt == null ? void 0 : Nt.sample.channels) ?? []).map((m) => /* @__PURE__ */ E.jsx("option", { value: m.key, children: (Nt == null ? void 0 : Nt.sample.labelForKey(m.key)) ?? m.key }, m.key)) + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Files"), + /* @__PURE__ */ E.jsxs( + "select", + { + value: at.recipe.files, + onChange: (m) => It((D) => D.kind === "chart" ? { ...D, files: m.target.value === "all" ? "all" : "checked" } : D), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "checked", children: v("Checked files") }), + /* @__PURE__ */ E.jsx("option", { value: "all", children: v("All files") }) + ] + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Group by"), + /* @__PURE__ */ E.jsxs( + "select", + { + value: at.recipe.groupBy, + onChange: (m) => It((D) => D.kind === "chart" ? { ...D, groupBy: m.target.value } : D), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "", children: v("Each file") }), + o.map((m) => /* @__PURE__ */ E.jsx("option", { value: m, children: m }, m)) + ] + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Chart"), + /* @__PURE__ */ E.jsxs( + "select", + { + value: at.recipe.chartType, + onChange: (m) => It((D) => D.kind === "chart" ? { ...D, chartType: m.target.value } : D), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "bars", children: v("Bars (mean ± SD)") }), + /* @__PURE__ */ E.jsx("option", { value: "dots", children: v("Points with the mean") }), + /* @__PURE__ */ E.jsx("option", { value: "box", children: v("Boxes (median, quartiles)") }) + ] + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-check", children: [ + /* @__PURE__ */ E.jsx( + "input", + { + type: "checkbox", + checked: at.recipe.showPoints, + onChange: (m) => It((D) => D.kind === "chart" ? { ...D, showPoints: m.target.checked } : D) + } + ), + v("Show each file as a point") + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-check", title: v("Wilcoxon rank-sum between two groups, Kruskal–Wallis among more; every group needs two files"), children: [ + /* @__PURE__ */ E.jsx( + "input", + { + type: "checkbox", + checked: at.recipe.test, + onChange: (m) => It((D) => D.kind === "chart" ? { ...D, test: m.target.checked } : D) + } + ), + v("Test between groups") + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline gl-layout-title-field", children: [ + v("Title"), + /* @__PURE__ */ E.jsx( + "input", + { + placeholder: Ne(at, kt), + value: at.recipe.title ?? "", + onChange: (m) => It((D) => D.kind === "chart" ? { ...D, title: m.target.value } : D) + } + ) + ] }) + ] }) : /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("FCS"), + /* @__PURE__ */ E.jsx( + "select", + { + value: at.recipe.sampleId, + onChange: (m) => It((D) => { + if (D.kind === "text" || D.kind === "figure" || D.kind === "proportions") return D; + const P = kt.find( + (X) => X.id === m.target.value + ); + if (!P) return D; + const F = Nt && Hr( + { + hierarchyId: Nt.tree.id, + populationId: D.populationId + }, + P.tree, + br(c) + ); + return { + ...D, + sampleId: P.id, + populationId: (F == null ? void 0 : F.id) ?? P.tree.root_population_id ?? "" + }; + }), + children: kt.map((m) => /* @__PURE__ */ E.jsx("option", { value: m.id, children: m.name }, m.id)) + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Population"), + /* @__PURE__ */ E.jsx( + "select", + { + value: at.recipe.populationId, + onChange: (m) => It( + (D) => D.kind === "text" ? D : { + ...D, + populationId: m.target.value + } + ), + children: Eo.map(({ popId: m, depth: D }) => { + var P; + return /* @__PURE__ */ E.jsxs("option", { value: m, children: [ + " ".repeat(D * 2), + ((P = Nt == null ? void 0 : Nt.tree.populations[m]) == null ? void 0 : P.name) ?? m + ] }, m); + }) + } + ) + ] }), + at.recipe.kind !== "strategy" && /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + "X", + /* @__PURE__ */ E.jsx( + Po, + { + label: v("X channel"), + value: at.recipe.xChannel, + options: Co, + onChange: (m) => It( + (D) => D.kind === "biplot" || D.kind === "histogram" ? { ...D, xChannel: m } : D + ) + } + ) + ] }), + at.recipe.kind === "biplot" && /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + "Y", + /* @__PURE__ */ E.jsx( + Po, + { + label: v("Y channel"), + value: at.recipe.yChannel ?? "", + options: Co, + onChange: (m) => It( + (D) => D.kind === "biplot" ? { ...D, yChannel: m } : D + ) + } + ) + ] }) + ] }), + at.recipe.kind === "strategy" && /* @__PURE__ */ E.jsxs("label", { className: "gl-check", children: [ + /* @__PURE__ */ E.jsx( + "input", + { + type: "checkbox", + checked: at.recipe.fullPath, + onChange: (m) => It( + (D) => D.kind === "strategy" ? { + ...D, + fullPath: m.target.checked + } : D + ) + } + ), + v("Full path from root") + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Display"), + /* @__PURE__ */ E.jsxs( + "select", + { + value: at.recipe.displayMode, + onChange: (m) => It( + (D) => D.kind === "text" ? D : { + ...D, + displayMode: m.target.value + } + ), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "pseudocolor", children: v("Pseudocolor") }), + /* @__PURE__ */ E.jsx("option", { value: "scatter", children: v("Scatter") }), + /* @__PURE__ */ E.jsx("option", { value: "contour", children: v("Contour") }) + ] + } + ) + ] }), + dt.mode !== "off" && /* @__PURE__ */ E.jsxs("label", { className: "gl-check", title: dt.mode === "populations" ? v("Drawn once per population of the iteration, for that population; unticked, it shows its own population on every page") : v("Drawn once per file of the iteration, for that file; unticked, it shows this file on every page"), children: [ + /* @__PURE__ */ E.jsx( + "input", + { + type: "checkbox", + checked: at.recipe.iterated === !0, + onChange: (m) => It( + (D) => D.kind === "text" ? D : { ...D, iterated: m.target.checked } + ) + } + ), + v("Follows the iteration") + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline gl-layout-title-field", title: v("Empty: the sheet's title template, under Style. Placeholders: {list}", { list: Ba }), children: [ + v("Title"), + /* @__PURE__ */ E.jsx( + "input", + { + placeholder: Bu || Ne(at, kt), + value: at.recipe.title ?? "", + onChange: (m) => It( + (D) => D.kind === "text" ? D : { ...D, title: m.target.value } + ) + } + ) + ] }), + /* @__PURE__ */ E.jsxs("details", { className: "gl-layout-item-style", children: [ + /* @__PURE__ */ E.jsxs("summary", { children: [ + v("Style"), + Object.keys(at.recipe.style ?? {}).length > 0 ? ` · ${v("Own style")}` : "" + ] }), + /* @__PURE__ */ E.jsx( + js, + { + effective: Ca(K, at.recipe), + own: at.recipe.style ?? {}, + onChange: (m) => It( + (D) => re(D) ? { ...D, style: Bo({ ...D.style, ...m }) } : D + ) + } + ), + Object.keys(at.recipe.style ?? {}).length > 0 && /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + title: v("Drop this item's own values; it then follows the sheet's style"), + onClick: () => It((m) => { + if (!re(m)) return m; + const { style: D, ...P } = m; + return P; + }), + children: v("Follow the sheet") + } + ) + ] }), + /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + onClick: () => w( + at.recipe + ), + children: v("Open in Gating") + } + ) + ] }) + ] + } + ) + ] }), + et === "page" && /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsx("h3", { children: v("Page") }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Size"), + /* @__PURE__ */ E.jsxs( + "select", + { + value: K.page.preset, + onChange: (m) => Qe(dc(m.target.value, K.page.orientation, K.page)), + children: [ + Object.entries(fc).map(([m, D]) => /* @__PURE__ */ E.jsx("option", { value: m, children: D.label }, m)), + /* @__PURE__ */ E.jsx("option", { value: "custom", children: v("Custom") }) + ] + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Orientation"), + /* @__PURE__ */ E.jsxs( + "select", + { + value: K.page.orientation, + onChange: (m) => Qe({ ...K.page, orientation: m.target.value }), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "portrait", children: v("Portrait") }), + /* @__PURE__ */ E.jsx("option", { value: "landscape", children: v("Landscape") }) + ] + } + ) + ] }), + /* @__PURE__ */ E.jsx("div", { className: "gl-layout-dimensions", children: ["width", "height"].map((m) => /* @__PURE__ */ E.jsxs("label", { children: [ + v(m === "width" ? "Width (mm)" : "Height (mm)"), + /* @__PURE__ */ E.jsx( + De, + { + min: 40, + max: 2e3, + step: 1, + "aria-label": v(m === "width" ? "Width (mm)" : "Height (mm)"), + value: Gs(K.page)[m === "width" ? "widthMm" : "heightMm"], + onCommit: (D) => { + const P = K.page.orientation === "landscape", F = m === "width" == !P ? "widthMm" : "heightMm"; + Qe({ ...K.page, preset: "custom", [F]: D }); + } + } + ) + ] }, m)) }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Margin (mm)"), + /* @__PURE__ */ E.jsx( + De, + { + min: 0, + max: 100, + step: 1, + value: K.page.marginMm, + onCommit: (m) => Qe({ ...K.page, marginMm: m }) + } + ) + ] }), + /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-dimensions", children: [ + /* @__PURE__ */ E.jsxs("label", { children: [ + v("Pages across"), + /* @__PURE__ */ E.jsx(De, { min: 1, max: Oo, step: 1, integer: !0, "aria-label": v("Pages across"), value: K.page.columns, onCommit: (m) => Qe({ ...K.page, columns: m }) }) + ] }), + /* @__PURE__ */ E.jsxs("label", { children: [ + v("Pages down"), + /* @__PURE__ */ E.jsx(De, { min: 1, max: Oo, step: 1, integer: !0, "aria-label": v("Pages down"), value: K.page.rows, onCommit: (m) => Qe({ ...K.page, rows: m }) }) + ] }) + ] }), + /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-item-actions", children: [ + /* @__PURE__ */ E.jsx("button", { type: "button", className: "gl-mini-btn", onClick: $u, disabled: !K.items.length, title: v("Make the page a custom size that holds every item inside the margin, as one page"), children: v("Fit page to content") }), + /* @__PURE__ */ E.jsx("button", { type: "button", className: "gl-mini-btn", onClick: Uu, disabled: !K.items.length, title: v("Scale and centre every item, as one group, to fill the first page inside its margin"), children: v("Fit content to page") }) + ] }), + /* @__PURE__ */ E.jsx("h3", { children: v("Export") }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Format"), + /* @__PURE__ */ E.jsxs("select", { value: _t, onChange: (m) => Mt(m.target.value), children: [ + /* @__PURE__ */ E.jsx("option", { value: "pdf", children: v("PDF · the page at its size") }), + /* @__PURE__ */ E.jsx("option", { value: "svg", children: v("SVG · vector axes, gates and text") }), + /* @__PURE__ */ E.jsx("option", { value: "png", children: v("PNG") }) + ] }) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Resolution (dpi)"), + /* @__PURE__ */ E.jsx( + De, + { + min: 72, + max: 1200, + step: 1, + integer: !0, + value: K.page.dpi, + onCommit: (m) => Qe({ ...K.page, dpi: m }) + } + ) + ] }), + /* @__PURE__ */ E.jsx("button", { className: "gl-mini-btn", type: "button", onClick: () => void So(), disabled: ht || !K.items.length, children: v(ht ? "Exporting…" : "Export sheet") }), + /* @__PURE__ */ E.jsx("p", { className: "gl-hint", children: v("The export is the page at its physical size; a grid of pages is written as one PDF page each, or one SVG or PNG file each in a zip. The data layer is drawn at the resolution above and anything beyond the pages is cut off.") }) + ] }), + et === "iterate" && /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsx("h3", { children: v("Iterate") }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Draw the sheet"), + /* @__PURE__ */ E.jsxs( + "select", + { + value: dt.mode, + onChange: (m) => tr({ ...dt, mode: m.target.value === "files" ? "files" : m.target.value === "populations" ? "populations" : "off" }), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "off", children: v("Once") }), + /* @__PURE__ */ E.jsx("option", { value: "files", children: v("Once per file") }), + /* @__PURE__ */ E.jsx("option", { value: "populations", children: v("Once per population") }) + ] + } + ) + ] }), + dt.mode !== "off" && /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + dt.mode === "populations" && /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Populations"), + /* @__PURE__ */ E.jsxs( + "select", + { + value: ((ko = dt.populations) == null ? void 0 : ko.kind) === "branch" ? dt.populations.populationId : "all", + onChange: (m) => tr({ + ...dt, + populations: m.target.value === "all" ? { kind: "all" } : { kind: "branch", populationId: m.target.value } + }), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "all", children: v("All in the tree") }), + (Jt ? Ln(Jt.tree.populations, Jt.tree.root_population_id ?? "") : []).filter(({ popId: m }) => m !== (Jt == null ? void 0 : Jt.tree.root_population_id)).map(({ popId: m, depth: D }) => { + var P; + return /* @__PURE__ */ E.jsxs("option", { value: m, children: [ + " ".repeat(D * 2), + v("Under {name}", { name: ((P = Jt == null ? void 0 : Jt.tree.populations[m]) == null ? void 0 : P.name) ?? m }) + ] }, m); + }) + ] + } + ) + ] }), + dt.mode === "files" && /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Files"), + /* @__PURE__ */ E.jsxs("select", { value: Ju, onChange: (m) => tr({ ...dt, source: Qu(m.target.value) }), children: [ + /* @__PURE__ */ E.jsx("option", { value: "checked", children: v("Checked files") }), + /* @__PURE__ */ E.jsx("option", { value: "all", children: v("All files") }), + a.map((m) => /* @__PURE__ */ E.jsx("option", { value: `group:${m.id}`, children: v("Group {name}", { name: m.name }) }, m.id)), + o.flatMap( + (m) => Zu(m).map((D) => /* @__PURE__ */ E.jsxs("option", { value: `meta:${m}=${D}`, children: [ + m, + " = ", + D + ] }, `${m}=${D}`)) + ) + ] }) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Arrangement"), + /* @__PURE__ */ E.jsxs( + "select", + { + value: dt.arrangement.kind, + onChange: (m) => tr({ + ...dt, + arrangement: m.target.value === "tiles" ? { kind: "tiles", rows: 2, columns: 2, order: "row-major", gap: 24 } : { kind: "page-per-unit" } + }), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "page-per-unit", children: dt.mode === "populations" ? v("One page per population") : v("One page per file") }), + /* @__PURE__ */ E.jsx("option", { value: "tiles", children: v("Tiles on each page") }) + ] + } + ) + ] }), + dt.arrangement.kind === "tiles" && /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsx("div", { className: "gl-layout-dimensions", children: ["columns", "rows"].map((m) => /* @__PURE__ */ E.jsxs("label", { children: [ + v(m === "columns" ? "Tiles across" : "Tiles down"), + /* @__PURE__ */ E.jsx( + De, + { + min: 1, + max: 12, + step: 1, + integer: !0, + "aria-label": v(m === "columns" ? "Tiles across" : "Tiles down"), + value: dt.arrangement.kind === "tiles" ? dt.arrangement[m] : 1, + onCommit: (D) => { + dt.arrangement.kind === "tiles" && tr({ ...dt, arrangement: { ...dt.arrangement, [m]: D } }); + } + } + ) + ] }, m)) }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Order"), + /* @__PURE__ */ E.jsxs( + "select", + { + value: dt.arrangement.order, + onChange: (m) => dt.arrangement.kind === "tiles" && tr({ ...dt, arrangement: { ...dt.arrangement, order: m.target.value === "column-major" ? "column-major" : "row-major" } }), + children: [ + /* @__PURE__ */ E.jsx("option", { value: "row-major", children: v("Across, then down") }), + /* @__PURE__ */ E.jsx("option", { value: "column-major", children: v("Down, then across") }) + ] + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Gap between tiles (px)"), + /* @__PURE__ */ E.jsx( + De, + { + min: 0, + max: 400, + step: 1, + integer: !0, + value: dt.arrangement.gap, + onCommit: (m) => { + dt.arrangement.kind === "tiles" && tr({ ...dt, arrangement: { ...dt.arrangement, gap: m } }); + } + } + ) + ] }) + ] }), + /* @__PURE__ */ E.jsx("p", { className: "gl-hint", children: dt.mode === "populations" ? v("{units} populations of {of} → {pages} pages. Items marked “Follows the iteration” are drawn for each population; the others repeat. Text and titles may use {population}, {sample}, {file}, {n} and {N}.", { units: Je.length, of: (Jt == null ? void 0 : Jt.name) ?? "the file", pages: Math.max(1, ue.length) }) : v("{files} files → {pages} pages. Items marked “Follows the iteration” are drawn for each file; the others repeat. Text and titles may use {sample}, {file}, {group}, {n}, {N} and {meta:column}; a plot title may also use {population} and {count}.", { files: Je.length, pages: Math.max(1, ue.length) }) }) + ] }) + ] }), + et === "style" && K && /* @__PURE__ */ E.jsxs(E.Fragment, { children: [ + /* @__PURE__ */ E.jsx("h3", { children: v("Style") }), + /* @__PURE__ */ E.jsx("p", { className: "gl-hint", children: v("How this sheet's plots are drawn. A plot or strategy may set its own values under Items; the rest follow the sheet.") }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Plot titles"), + /* @__PURE__ */ E.jsxs( + "select", + { + "aria-label": v("Plot titles"), + value: pr ? "custom" : ((To = Fn.find((m) => m.template === (K.titleTemplate ?? ""))) == null ? void 0 : To.id) ?? "custom", + onChange: (m) => { + const D = Fn.find((P) => P.id === m.target.value); + Tt(!D), zt((P) => { + var F; + D ? D.template ? P.titleTemplate = D.template : delete P.titleTemplate : P.titleTemplate = ((F = P.titleTemplate) == null ? void 0 : F.trim()) || "{population} · {file}"; + }); + }, + children: [ + Fn.map((m) => /* @__PURE__ */ E.jsx("option", { value: m.id, children: v(m.label) }, m.id)), + /* @__PURE__ */ E.jsx("option", { value: "custom", children: v("Custom template…") }) + ] + } + ) + ] }), + (() => { + const m = K.items.filter((D) => so(D)); + return m.length ? /* @__PURE__ */ E.jsxs("p", { className: "gl-hint gl-title-builder-own", children: [ + v("{count} plots keep a title of their own, so the template does not reach them.", { count: m.length }), + " ", + /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + title: v("Drop those plots' own titles so every plot on the sheet follows the template"), + onClick: () => zt((D) => { + for (const P of D.items) re(P.recipe) && delete P.recipe.title; + }), + children: v("Use the template for all") + } + ) + ] }) : null; + })(), + (pr || !Fn.some((m) => m.template === (K.titleTemplate ?? ""))) && (() => { + var Ct; + const m = K.titleTemplate ?? "", D = Gv(m), P = (D == null ? void 0 : D.tokens) ?? [], F = (D == null ? void 0 : D.separator) ?? ee, X = (mt) => { + var Lt; + return ((Lt = xn.find((Ae) => Ae.token === mt)) == null ? void 0 : Lt.label) ?? mt; + }, it = (mt) => zt((Lt) => { + Lt.titleTemplate = zs(mt, F); + }), ot = ae.items.find((mt) => re(mt.recipe)), yt = ot && re(ot.recipe) ? ia(m, Ie(ot.recipe, ot.templateSampleId) ?? { population: "", file: "", sample: "", x: "", y: "" }) : ""; + return /* @__PURE__ */ E.jsxs("div", { className: "gl-title-builder", role: "group", "aria-label": v("Title builder"), children: [ + /* @__PURE__ */ E.jsxs("div", { className: "gl-title-builder-chosen", "aria-label": v("Fields in the title"), children: [ + P.length === 0 && /* @__PURE__ */ E.jsx("span", { className: "gl-hint", children: v(D === null && m ? "Written by hand; choosing a field below starts a built title." : "Choose the fields below, in the order they should read.") }), + P.map((mt, Lt) => /* @__PURE__ */ E.jsxs( + "button", + { + type: "button", + className: "gl-chip active", + "aria-label": v("Remove {field}", { field: X(mt) }), + title: v("Remove {field} from the title", { field: X(mt) }), + onClick: () => it(P.filter((Ae, ge) => ge !== Lt)), + children: [ + X(mt), + " ×" + ] + }, + `${mt}-${Lt}` + )) + ] }), + /* @__PURE__ */ E.jsx("div", { className: "gl-title-builder-fields", "aria-label": v("Fields to add"), children: xn.map((mt) => /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-chip", + "aria-label": v("Add {field}", { field: mt.label }), + title: mt.token, + onClick: () => it([...P, mt.token]), + children: mt.label + }, + mt.token + )) }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline", children: [ + v("Between fields"), + /* @__PURE__ */ E.jsx( + "select", + { + "aria-label": v("Separator"), + value: ((Ct = ja.find((mt) => mt.value === F)) == null ? void 0 : Ct.id) ?? "dot", + onChange: (mt) => { + var Ae; + const Lt = ((Ae = ja.find((ge) => ge.id === mt.target.value)) == null ? void 0 : Ae.value) ?? " · "; + mn(Lt), P.length && zt((ge) => { + ge.titleTemplate = zs(P, Lt); + }); + }, + children: ja.map((mt) => /* @__PURE__ */ E.jsx("option", { value: mt.id, children: v(mt.label) }, mt.id)) + } + ) + ] }), + /* @__PURE__ */ E.jsxs("label", { className: "gl-field-inline gl-layout-title-field", children: [ + v("Template"), + /* @__PURE__ */ E.jsx( + "input", + { + "aria-label": v("Title template"), + value: m, + onChange: (mt) => zt((Lt) => { + Lt.titleTemplate = mt.target.value; + }) + } + ) + ] }), + yt && /* @__PURE__ */ E.jsx("div", { className: "gl-hint gl-title-builder-preview", children: v("First plot reads: {title}", { title: yt }) }) + ] }); + })(), + /* @__PURE__ */ E.jsx("p", { className: "gl-hint", children: v(`What every plot is called unless it has a title of its own under Items. Placeholders: {list}. "What differs across the page" names the population when the page is one file's populations, the file when it is one population's files, both otherwise.`, { list: Ba }) }), + /* @__PURE__ */ E.jsx( + js, + { + effective: Ca(K), + own: K.style ?? {}, + onChange: (m) => zt((D) => { + D.style = Bo({ ...D.style, ...m }); + }) + } + ), + Object.keys(K.style ?? {}).length > 0 && /* @__PURE__ */ E.jsx( + "button", + { + type: "button", + className: "gl-mini-btn", + onClick: () => zt((m) => { + delete m.style; + }), + children: v("Reset to defaults") + } + ) + ] }) + ] }), + /* @__PURE__ */ E.jsx(pc, { menu: ju, onClose: () => xa(null) }), + /* @__PURE__ */ E.jsxs( + "div", + { + ref: (m) => { + Bt.current = m, B(m); + }, + className: "gl-layout-canvas-scroll", + tabIndex: 0, + "aria-label": v("Layout page"), + onKeyDown: tc, + children: [ + !ft && R && /* @__PURE__ */ E.jsx( + Ov, + { + ref: $, + container: R, + dragContainer: R, + selectableTargets: [".gl-layout-item"], + selectByClick: !0, + selectFromInside: !1, + continueSelect: !1, + toggleContinueSelect: ["shift"], + hitRate: 0, + ratio: 0, + dragCondition: (m) => { + var D, P, F; + return !((F = (P = (D = m.inputEvent) == null ? void 0 : D.target) == null ? void 0 : P.closest) != null && F.call(P, "textarea, input, select, button")); + }, + onDragStart: Hu, + onSelectEnd: qu + } + ), + /* @__PURE__ */ E.jsx( + "div", + { + className: "gl-layout-zoom", + style: { width: K.width * q, height: K.height * q }, + children: /* @__PURE__ */ E.jsxs( + "section", + { + ref: (m) => { + Zt.current = m, z(m); + }, + className: "gl-layout-canvas", + "aria-label": K.name, + onContextMenu: Fu, + style: { width: K.width, height: K.height, transform: `scale(${q})` }, + children: [ + Xn(K.page).map((m) => { + const D = Ya(K.page), P = Ro(K.page.marginMm); + return /* @__PURE__ */ E.jsx("div", { className: "gl-layout-page", "aria-hidden": "true", style: { left: m.x, top: m.y, width: D.width, height: D.height }, children: P > 0 && /* @__PURE__ */ E.jsx("div", { className: "gl-layout-page-margin", style: { inset: P } }) }, `${m.row}-${m.column}`); + }), + ae.items.length === 0 && /* @__PURE__ */ E.jsxs("div", { className: "gl-layout-empty", children: [ + /* @__PURE__ */ E.jsx("strong", { children: v("Blank layout") }), + /* @__PURE__ */ E.jsx("span", { children: v( + "Add a plot, gating strategy, text, or the current Illustration selection." + ) }) + ] }), + ae.items.map((m) => /* @__PURE__ */ E.jsx( + gh, + { + item: m, + templateText: (() => { + const D = K.items.find((P) => P.id === m.templateId); + return (D == null ? void 0 : D.recipe.kind) === "text" ? D.recipe.text : void 0; + })(), + selected: _.includes(m.id), + samples: kt, + state: c, + globalScales: f, + dataRevision: C, + densityColorPower: S, + style: Ca(K, m.recipe), + titleTemplate: so(m, m.templateSampleId) || io, + describe: Ie, + checkedSampleIds: n, + metadataById: Ee, + files: r, + sources: Ot.sources, + divisionProfiles: y, + canvasScale: St, + onTextChange: (D, P) => zt((F) => { + const X = F.items.find( + (it) => it.id === m.templateId + ); + (X == null ? void 0 : X.recipe.kind) === "text" && (X.recipe.text = D, P > 0 && (X.height = Math.max(X.height, Math.ceil(P) + 4))); + }), + onDelete: () => Wr([m.templateId]), + onOpenInGating: () => { + re(m.recipe) && w(m.recipe); + }, + onTextFocus: () => { + (!_.includes(m.id) || _.length > 1) && M([m.id]); + }, + onTextEscape: () => { + var D; + return (D = Bt.current) == null ? void 0 : D.focus({ preventScroll: !0 }); + } + }, + m.id + )), + !ft && N.length > 0 && /* @__PURE__ */ E.jsx( + hv, + { + ref: W, + target: N.length === 1 ? N[0] : N, + zoom: 1 / q, + origin: !1, + checkInput: !0, + passDragArea: !0, + draggable: !bn, + resizable: !bn, + snappable: !0, + snapThreshold: 6, + isDisplaySnapDigit: !1, + isDisplayInnerSnapDigit: !1, + snapDirections: Bs, + elementSnapDirections: Bs, + elementGuidelines: V, + verticalGuidelines: xo.vertical, + horizontalGuidelines: xo.horizontal, + snapGridWidth: T ? Ns : 0, + snapGridHeight: T ? Ns : 0, + renderDirections: ["nw", "n", "ne", "w", "e", "sw", "s", "se"], + edge: !0, + onDragStart: (m) => { + var D; + m.datas.alt = !!((D = m.inputEvent) != null && D.altKey), m.datas.alt && (m.datas.ghosts = vo([m.target])); + }, + onDrag: go, + onDragEnd: (m) => { + ho(m.datas.ghosts), m.isDrag && Cn([m.target], !!m.datas.alt); + }, + onDragGroupStart: (m) => { + var D; + m.datas.alt = !!((D = m.inputEvent) != null && D.altKey), m.datas.alt && (m.datas.ghosts = vo(m.targets)); + }, + onDragGroup: (m) => m.events.forEach(go), + onDragGroupEnd: (m) => { + ho(m.datas.ghosts), m.isDrag && Cn(m.targets, !!m.datas.alt); + }, + onResize: mo, + onResizeEnd: (m) => { + m.isDrag && Cn([m.target], !1); + }, + onResizeGroup: (m) => m.events.forEach(mo), + onResizeGroupEnd: (m) => { + m.isDrag && Cn(m.targets, !1); + }, + onClickGroup: (m) => { + var D; + (D = $.current) == null || D.clickTarget(m.inputEvent, m.inputTarget); + } + } + ) + ] + } + ) + } + ) + ] + } + ) + ] }) + ] + } + ) : null; +} +export { + bh as LayoutTab, + vh as isBakedTitle +}; diff --git a/inst/react-app/embed-8iuCsEkz.js b/inst/react-app/embed-8iuCsEkz.js new file mode 100644 index 0000000..0d79ecb --- /dev/null +++ b/inst/react-app/embed-8iuCsEkz.js @@ -0,0 +1,53105 @@ +var Lk = Object.defineProperty; +var Rk = (e, t, n) => t in e ? Lk(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; +var yt = (e, t, n) => Rk(e, typeof t != "symbol" ? t + "" : t, n); +var _$ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function Ok(e) { + return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; +} +var Qg = { exports: {} }, Uf = {}, Zg = { exports: {} }, wn = {}; +/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var c0; +function Dk() { + if (c0) return wn; + c0 = 1; + var e = Symbol.for("react.element"), t = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), r = Symbol.for("react.strict_mode"), a = Symbol.for("react.profiler"), o = Symbol.for("react.provider"), i = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), f = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), h = Symbol.iterator; + function y(Q) { + return Q === null || typeof Q != "object" ? null : (Q = h && Q[h] || Q["@@iterator"], typeof Q == "function" ? Q : null); + } + var _ = { isMounted: function() { + return !1; + }, enqueueForceUpdate: function() { + }, enqueueReplaceState: function() { + }, enqueueSetState: function() { + } }, x = Object.assign, w = {}; + function b(Q, ae, ue) { + this.props = Q, this.context = ae, this.refs = w, this.updater = ue || _; + } + b.prototype.isReactComponent = {}, b.prototype.setState = function(Q, ae) { + if (typeof Q != "object" && typeof Q != "function" && Q != null) throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables."); + this.updater.enqueueSetState(this, Q, ae, "setState"); + }, b.prototype.forceUpdate = function(Q) { + this.updater.enqueueForceUpdate(this, Q, "forceUpdate"); + }; + function v() { + } + v.prototype = b.prototype; + function M(Q, ae, ue) { + this.props = Q, this.context = ae, this.refs = w, this.updater = ue || _; + } + var S = M.prototype = new v(); + S.constructor = M, x(S, b.prototype), S.isPureReactComponent = !0; + var N = Array.isArray, E = Object.prototype.hasOwnProperty, R = { current: null }, P = { key: !0, ref: !0, __self: !0, __source: !0 }; + function A(Q, ae, ue) { + var me, X = {}, xe = null, ye = null; + if (ae != null) for (me in ae.ref !== void 0 && (ye = ae.ref), ae.key !== void 0 && (xe = "" + ae.key), ae) E.call(ae, me) && !P.hasOwnProperty(me) && (X[me] = ae[me]); + var be = arguments.length - 2; + if (be === 1) X.children = ue; + else if (1 < be) { + for (var we = Array(be), je = 0; je < be; je++) we[je] = arguments[je + 2]; + X.children = we; + } + if (Q && Q.defaultProps) for (me in be = Q.defaultProps, be) X[me] === void 0 && (X[me] = be[me]); + return { $$typeof: e, type: Q, key: xe, ref: ye, props: X, _owner: R.current }; + } + function L(Q, ae) { + return { $$typeof: e, type: Q.type, key: ae, ref: Q.ref, props: Q.props, _owner: Q._owner }; + } + function T(Q) { + return typeof Q == "object" && Q !== null && Q.$$typeof === e; + } + function G(Q) { + var ae = { "=": "=0", ":": "=2" }; + return "$" + Q.replace(/[=:]/g, function(ue) { + return ae[ue]; + }); + } + var W = /\/+/g; + function J(Q, ae) { + return typeof Q == "object" && Q !== null && Q.key != null ? G("" + Q.key) : ae.toString(36); + } + function j(Q, ae, ue, me, X) { + var xe = typeof Q; + (xe === "undefined" || xe === "boolean") && (Q = null); + var ye = !1; + if (Q === null) ye = !0; + else switch (xe) { + case "string": + case "number": + ye = !0; + break; + case "object": + switch (Q.$$typeof) { + case e: + case t: + ye = !0; + } + } + if (ye) return ye = Q, X = X(ye), Q = me === "" ? "." + J(ye, 0) : me, N(X) ? (ue = "", Q != null && (ue = Q.replace(W, "$&/") + "/"), j(X, ae, ue, "", function(je) { + return je; + })) : X != null && (T(X) && (X = L(X, ue + (!X.key || ye && ye.key === X.key ? "" : ("" + X.key).replace(W, "$&/") + "/") + Q)), ae.push(X)), 1; + if (ye = 0, me = me === "" ? "." : me + ":", N(Q)) for (var be = 0; be < Q.length; be++) { + xe = Q[be]; + var we = me + J(xe, be); + ye += j(xe, ae, ue, we, X); + } + else if (we = y(Q), typeof we == "function") for (Q = we.call(Q), be = 0; !(xe = Q.next()).done; ) xe = xe.value, we = me + J(xe, be++), ye += j(xe, ae, ue, we, X); + else if (xe === "object") throw ae = String(Q), Error("Objects are not valid as a React child (found: " + (ae === "[object Object]" ? "object with keys {" + Object.keys(Q).join(", ") + "}" : ae) + "). If you meant to render a collection of children, use an array instead."); + return ye; + } + function K(Q, ae, ue) { + if (Q == null) return Q; + var me = [], X = 0; + return j(Q, me, "", "", function(xe) { + return ae.call(ue, xe, X++); + }), me; + } + function Z(Q) { + if (Q._status === -1) { + var ae = Q._result; + ae = ae(), ae.then(function(ue) { + (Q._status === 0 || Q._status === -1) && (Q._status = 1, Q._result = ue); + }, function(ue) { + (Q._status === 0 || Q._status === -1) && (Q._status = 2, Q._result = ue); + }), Q._status === -1 && (Q._status = 0, Q._result = ae); + } + if (Q._status === 1) return Q._result.default; + throw Q._result; + } + var se = { current: null }, le = { transition: null }, ce = { ReactCurrentDispatcher: se, ReactCurrentBatchConfig: le, ReactCurrentOwner: R }; + function fe() { + throw Error("act(...) is not supported in production builds of React."); + } + return wn.Children = { map: K, forEach: function(Q, ae, ue) { + K(Q, function() { + ae.apply(this, arguments); + }, ue); + }, count: function(Q) { + var ae = 0; + return K(Q, function() { + ae++; + }), ae; + }, toArray: function(Q) { + return K(Q, function(ae) { + return ae; + }) || []; + }, only: function(Q) { + if (!T(Q)) throw Error("React.Children.only expected to receive a single React element child."); + return Q; + } }, wn.Component = b, wn.Fragment = n, wn.Profiler = a, wn.PureComponent = M, wn.StrictMode = r, wn.Suspense = d, wn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ce, wn.act = fe, wn.cloneElement = function(Q, ae, ue) { + if (Q == null) throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + Q + "."); + var me = x({}, Q.props), X = Q.key, xe = Q.ref, ye = Q._owner; + if (ae != null) { + if (ae.ref !== void 0 && (xe = ae.ref, ye = R.current), ae.key !== void 0 && (X = "" + ae.key), Q.type && Q.type.defaultProps) var be = Q.type.defaultProps; + for (we in ae) E.call(ae, we) && !P.hasOwnProperty(we) && (me[we] = ae[we] === void 0 && be !== void 0 ? be[we] : ae[we]); + } + var we = arguments.length - 2; + if (we === 1) me.children = ue; + else if (1 < we) { + be = Array(we); + for (var je = 0; je < we; je++) be[je] = arguments[je + 2]; + me.children = be; + } + return { $$typeof: e, type: Q.type, key: X, ref: xe, props: me, _owner: ye }; + }, wn.createContext = function(Q) { + return Q = { $$typeof: i, _currentValue: Q, _currentValue2: Q, _threadCount: 0, Provider: null, Consumer: null, _defaultValue: null, _globalName: null }, Q.Provider = { $$typeof: o, _context: Q }, Q.Consumer = Q; + }, wn.createElement = A, wn.createFactory = function(Q) { + var ae = A.bind(null, Q); + return ae.type = Q, ae; + }, wn.createRef = function() { + return { current: null }; + }, wn.forwardRef = function(Q) { + return { $$typeof: c, render: Q }; + }, wn.isValidElement = T, wn.lazy = function(Q) { + return { $$typeof: p, _payload: { _status: -1, _result: Q }, _init: Z }; + }, wn.memo = function(Q, ae) { + return { $$typeof: f, type: Q, compare: ae === void 0 ? null : ae }; + }, wn.startTransition = function(Q) { + var ae = le.transition; + le.transition = {}; + try { + Q(); + } finally { + le.transition = ae; + } + }, wn.unstable_act = fe, wn.useCallback = function(Q, ae) { + return se.current.useCallback(Q, ae); + }, wn.useContext = function(Q) { + return se.current.useContext(Q); + }, wn.useDebugValue = function() { + }, wn.useDeferredValue = function(Q) { + return se.current.useDeferredValue(Q); + }, wn.useEffect = function(Q, ae) { + return se.current.useEffect(Q, ae); + }, wn.useId = function() { + return se.current.useId(); + }, wn.useImperativeHandle = function(Q, ae, ue) { + return se.current.useImperativeHandle(Q, ae, ue); + }, wn.useInsertionEffect = function(Q, ae) { + return se.current.useInsertionEffect(Q, ae); + }, wn.useLayoutEffect = function(Q, ae) { + return se.current.useLayoutEffect(Q, ae); + }, wn.useMemo = function(Q, ae) { + return se.current.useMemo(Q, ae); + }, wn.useReducer = function(Q, ae, ue) { + return se.current.useReducer(Q, ae, ue); + }, wn.useRef = function(Q) { + return se.current.useRef(Q); + }, wn.useState = function(Q) { + return se.current.useState(Q); + }, wn.useSyncExternalStore = function(Q, ae, ue) { + return se.current.useSyncExternalStore(Q, ae, ue); + }, wn.useTransition = function() { + return se.current.useTransition(); + }, wn.version = "18.3.1", wn; +} +var u0; +function Op() { + return u0 || (u0 = 1, Zg.exports = Dk()), Zg.exports; +} +/** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var d0; +function zk() { + if (d0) return Uf; + d0 = 1; + var e = Op(), t = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, a = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = { key: !0, ref: !0, __self: !0, __source: !0 }; + function i(c, d, f) { + var p, h = {}, y = null, _ = null; + f !== void 0 && (y = "" + f), d.key !== void 0 && (y = "" + d.key), d.ref !== void 0 && (_ = d.ref); + for (p in d) r.call(d, p) && !o.hasOwnProperty(p) && (h[p] = d[p]); + if (c && c.defaultProps) for (p in d = c.defaultProps, d) h[p] === void 0 && (h[p] = d[p]); + return { $$typeof: t, type: c, key: y, ref: _, props: h, _owner: a.current }; + } + return Uf.Fragment = n, Uf.jsx = i, Uf.jsxs = i, Uf; +} +var f0; +function Gk() { + return f0 || (f0 = 1, Qg.exports = zk()), Qg.exports; +} +var u = Gk(), Yh = {}, ey = { exports: {} }, Do = {}, ty = { exports: {} }, ny = {}; +/** + * @license React + * scheduler.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var p0; +function Bk() { + return p0 || (p0 = 1, (function(e) { + function t(le, ce) { + var fe = le.length; + le.push(ce); + e: for (; 0 < fe; ) { + var Q = fe - 1 >>> 1, ae = le[Q]; + if (0 < a(ae, ce)) le[Q] = ce, le[fe] = ae, fe = Q; + else break e; + } + } + function n(le) { + return le.length === 0 ? null : le[0]; + } + function r(le) { + if (le.length === 0) return null; + var ce = le[0], fe = le.pop(); + if (fe !== ce) { + le[0] = fe; + e: for (var Q = 0, ae = le.length, ue = ae >>> 1; Q < ue; ) { + var me = 2 * (Q + 1) - 1, X = le[me], xe = me + 1, ye = le[xe]; + if (0 > a(X, fe)) xe < ae && 0 > a(ye, X) ? (le[Q] = ye, le[xe] = fe, Q = xe) : (le[Q] = X, le[me] = fe, Q = me); + else if (xe < ae && 0 > a(ye, fe)) le[Q] = ye, le[xe] = fe, Q = xe; + else break e; + } + } + return ce; + } + function a(le, ce) { + var fe = le.sortIndex - ce.sortIndex; + return fe !== 0 ? fe : le.id - ce.id; + } + if (typeof performance == "object" && typeof performance.now == "function") { + var o = performance; + e.unstable_now = function() { + return o.now(); + }; + } else { + var i = Date, c = i.now(); + e.unstable_now = function() { + return i.now() - c; + }; + } + var d = [], f = [], p = 1, h = null, y = 3, _ = !1, x = !1, w = !1, b = typeof setTimeout == "function" ? setTimeout : null, v = typeof clearTimeout == "function" ? clearTimeout : null, M = typeof setImmediate < "u" ? setImmediate : null; + typeof navigator < "u" && navigator.scheduling !== void 0 && navigator.scheduling.isInputPending !== void 0 && navigator.scheduling.isInputPending.bind(navigator.scheduling); + function S(le) { + for (var ce = n(f); ce !== null; ) { + if (ce.callback === null) r(f); + else if (ce.startTime <= le) r(f), ce.sortIndex = ce.expirationTime, t(d, ce); + else break; + ce = n(f); + } + } + function N(le) { + if (w = !1, S(le), !x) if (n(d) !== null) x = !0, Z(E); + else { + var ce = n(f); + ce !== null && se(N, ce.startTime - le); + } + } + function E(le, ce) { + x = !1, w && (w = !1, v(A), A = -1), _ = !0; + var fe = y; + try { + for (S(ce), h = n(d); h !== null && (!(h.expirationTime > ce) || le && !G()); ) { + var Q = h.callback; + if (typeof Q == "function") { + h.callback = null, y = h.priorityLevel; + var ae = Q(h.expirationTime <= ce); + ce = e.unstable_now(), typeof ae == "function" ? h.callback = ae : h === n(d) && r(d), S(ce); + } else r(d); + h = n(d); + } + if (h !== null) var ue = !0; + else { + var me = n(f); + me !== null && se(N, me.startTime - ce), ue = !1; + } + return ue; + } finally { + h = null, y = fe, _ = !1; + } + } + var R = !1, P = null, A = -1, L = 5, T = -1; + function G() { + return !(e.unstable_now() - T < L); + } + function W() { + if (P !== null) { + var le = e.unstable_now(); + T = le; + var ce = !0; + try { + ce = P(!0, le); + } finally { + ce ? J() : (R = !1, P = null); + } + } else R = !1; + } + var J; + if (typeof M == "function") J = function() { + M(W); + }; + else if (typeof MessageChannel < "u") { + var j = new MessageChannel(), K = j.port2; + j.port1.onmessage = W, J = function() { + K.postMessage(null); + }; + } else J = function() { + b(W, 0); + }; + function Z(le) { + P = le, R || (R = !0, J()); + } + function se(le, ce) { + A = b(function() { + le(e.unstable_now()); + }, ce); + } + e.unstable_IdlePriority = 5, e.unstable_ImmediatePriority = 1, e.unstable_LowPriority = 4, e.unstable_NormalPriority = 3, e.unstable_Profiling = null, e.unstable_UserBlockingPriority = 2, e.unstable_cancelCallback = function(le) { + le.callback = null; + }, e.unstable_continueExecution = function() { + x || _ || (x = !0, Z(E)); + }, e.unstable_forceFrameRate = function(le) { + 0 > le || 125 < le ? console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported") : L = 0 < le ? Math.floor(1e3 / le) : 5; + }, e.unstable_getCurrentPriorityLevel = function() { + return y; + }, e.unstable_getFirstCallbackNode = function() { + return n(d); + }, e.unstable_next = function(le) { + switch (y) { + case 1: + case 2: + case 3: + var ce = 3; + break; + default: + ce = y; + } + var fe = y; + y = ce; + try { + return le(); + } finally { + y = fe; + } + }, e.unstable_pauseExecution = function() { + }, e.unstable_requestPaint = function() { + }, e.unstable_runWithPriority = function(le, ce) { + switch (le) { + case 1: + case 2: + case 3: + case 4: + case 5: + break; + default: + le = 3; + } + var fe = y; + y = le; + try { + return ce(); + } finally { + y = fe; + } + }, e.unstable_scheduleCallback = function(le, ce, fe) { + var Q = e.unstable_now(); + switch (typeof fe == "object" && fe !== null ? (fe = fe.delay, fe = typeof fe == "number" && 0 < fe ? Q + fe : Q) : fe = Q, le) { + case 1: + var ae = -1; + break; + case 2: + ae = 250; + break; + case 5: + ae = 1073741823; + break; + case 4: + ae = 1e4; + break; + default: + ae = 5e3; + } + return ae = fe + ae, le = { id: p++, callback: ce, priorityLevel: le, startTime: fe, expirationTime: ae, sortIndex: -1 }, fe > Q ? (le.sortIndex = fe, t(f, le), n(d) === null && le === n(f) && (w ? (v(A), A = -1) : w = !0, se(N, fe - Q))) : (le.sortIndex = ae, t(d, le), x || _ || (x = !0, Z(E))), le; + }, e.unstable_shouldYield = G, e.unstable_wrapCallback = function(le) { + var ce = y; + return function() { + var fe = y; + y = ce; + try { + return le.apply(this, arguments); + } finally { + y = fe; + } + }; + }; + })(ny)), ny; +} +var h0; +function qk() { + return h0 || (h0 = 1, ty.exports = Bk()), ty.exports; +} +/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var m0; +function Wk() { + if (m0) return Do; + m0 = 1; + var e = Op(), t = qk(); + function n(s) { + for (var l = "https://reactjs.org/docs/error-decoder.html?invariant=" + s, m = 1; m < arguments.length; m++) l += "&args[]=" + encodeURIComponent(arguments[m]); + return "Minified React error #" + s + "; visit " + l + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings."; + } + var r = /* @__PURE__ */ new Set(), a = {}; + function o(s, l) { + i(s, l), i(s + "Capture", l); + } + function i(s, l) { + for (a[s] = l, s = 0; s < l.length; s++) r.add(l[s]); + } + var c = !(typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u"), d = Object.prototype.hasOwnProperty, f = /^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/, p = {}, h = {}; + function y(s) { + return d.call(h, s) ? !0 : d.call(p, s) ? !1 : f.test(s) ? h[s] = !0 : (p[s] = !0, !1); + } + function _(s, l, m, k) { + if (m !== null && m.type === 0) return !1; + switch (typeof l) { + case "function": + case "symbol": + return !0; + case "boolean": + return k ? !1 : m !== null ? !m.acceptsBooleans : (s = s.toLowerCase().slice(0, 5), s !== "data-" && s !== "aria-"); + default: + return !1; + } + } + function x(s, l, m, k) { + if (l === null || typeof l > "u" || _(s, l, m, k)) return !0; + if (k) return !1; + if (m !== null) switch (m.type) { + case 3: + return !l; + case 4: + return l === !1; + case 5: + return isNaN(l); + case 6: + return isNaN(l) || 1 > l; + } + return !1; + } + function w(s, l, m, k, I, z, ee) { + this.acceptsBooleans = l === 2 || l === 3 || l === 4, this.attributeName = k, this.attributeNamespace = I, this.mustUseProperty = m, this.propertyName = s, this.type = l, this.sanitizeURL = z, this.removeEmptyString = ee; + } + var b = {}; + "children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s) { + b[s] = new w(s, 0, !1, s, null, !1, !1); + }), [["acceptCharset", "accept-charset"], ["className", "class"], ["htmlFor", "for"], ["httpEquiv", "http-equiv"]].forEach(function(s) { + var l = s[0]; + b[l] = new w(l, 1, !1, s[1], null, !1, !1); + }), ["contentEditable", "draggable", "spellCheck", "value"].forEach(function(s) { + b[s] = new w(s, 2, !1, s.toLowerCase(), null, !1, !1); + }), ["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function(s) { + b[s] = new w(s, 2, !1, s, null, !1, !1); + }), "allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(s) { + b[s] = new w(s, 3, !1, s.toLowerCase(), null, !1, !1); + }), ["checked", "multiple", "muted", "selected"].forEach(function(s) { + b[s] = new w(s, 3, !0, s, null, !1, !1); + }), ["capture", "download"].forEach(function(s) { + b[s] = new w(s, 4, !1, s, null, !1, !1); + }), ["cols", "rows", "size", "span"].forEach(function(s) { + b[s] = new w(s, 6, !1, s, null, !1, !1); + }), ["rowSpan", "start"].forEach(function(s) { + b[s] = new w(s, 5, !1, s.toLowerCase(), null, !1, !1); + }); + var v = /[\-:]([a-z])/g; + function M(s) { + return s[1].toUpperCase(); + } + "accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(s) { + var l = s.replace( + v, + M + ); + b[l] = new w(l, 1, !1, s, null, !1, !1); + }), "xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(s) { + var l = s.replace(v, M); + b[l] = new w(l, 1, !1, s, "http://www.w3.org/1999/xlink", !1, !1); + }), ["xml:base", "xml:lang", "xml:space"].forEach(function(s) { + var l = s.replace(v, M); + b[l] = new w(l, 1, !1, s, "http://www.w3.org/XML/1998/namespace", !1, !1); + }), ["tabIndex", "crossOrigin"].forEach(function(s) { + b[s] = new w(s, 1, !1, s.toLowerCase(), null, !1, !1); + }), b.xlinkHref = new w("xlinkHref", 1, !1, "xlink:href", "http://www.w3.org/1999/xlink", !0, !1), ["src", "href", "action", "formAction"].forEach(function(s) { + b[s] = new w(s, 1, !1, s.toLowerCase(), null, !0, !0); + }); + function S(s, l, m, k) { + var I = b.hasOwnProperty(l) ? b[l] : null; + (I !== null ? I.type !== 0 : k || !(2 < l.length) || l[0] !== "o" && l[0] !== "O" || l[1] !== "n" && l[1] !== "N") && (x(l, m, I, k) && (m = null), k || I === null ? y(l) && (m === null ? s.removeAttribute(l) : s.setAttribute(l, "" + m)) : I.mustUseProperty ? s[I.propertyName] = m === null ? I.type === 3 ? !1 : "" : m : (l = I.attributeName, k = I.attributeNamespace, m === null ? s.removeAttribute(l) : (I = I.type, m = I === 3 || I === 4 && m === !0 ? "" : "" + m, k ? s.setAttributeNS(k, l, m) : s.setAttribute(l, m)))); + } + var N = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, E = Symbol.for("react.element"), R = Symbol.for("react.portal"), P = Symbol.for("react.fragment"), A = Symbol.for("react.strict_mode"), L = Symbol.for("react.profiler"), T = Symbol.for("react.provider"), G = Symbol.for("react.context"), W = Symbol.for("react.forward_ref"), J = Symbol.for("react.suspense"), j = Symbol.for("react.suspense_list"), K = Symbol.for("react.memo"), Z = Symbol.for("react.lazy"), se = Symbol.for("react.offscreen"), le = Symbol.iterator; + function ce(s) { + return s === null || typeof s != "object" ? null : (s = le && s[le] || s["@@iterator"], typeof s == "function" ? s : null); + } + var fe = Object.assign, Q; + function ae(s) { + if (Q === void 0) try { + throw Error(); + } catch (m) { + var l = m.stack.trim().match(/\n( *(at )?)/); + Q = l && l[1] || ""; + } + return ` +` + Q + s; + } + var ue = !1; + function me(s, l) { + if (!s || ue) return ""; + ue = !0; + var m = Error.prepareStackTrace; + Error.prepareStackTrace = void 0; + try { + if (l) if (l = function() { + throw Error(); + }, Object.defineProperty(l.prototype, "props", { set: function() { + throw Error(); + } }), typeof Reflect == "object" && Reflect.construct) { + try { + Reflect.construct(l, []); + } catch (Ue) { + var k = Ue; + } + Reflect.construct(s, [], l); + } else { + try { + l.call(); + } catch (Ue) { + k = Ue; + } + s.call(l.prototype); + } + else { + try { + throw Error(); + } catch (Ue) { + k = Ue; + } + s(); + } + } catch (Ue) { + if (Ue && k && typeof Ue.stack == "string") { + for (var I = Ue.stack.split(` +`), z = k.stack.split(` +`), ee = I.length - 1, _e = z.length - 1; 1 <= ee && 0 <= _e && I[ee] !== z[_e]; ) _e--; + for (; 1 <= ee && 0 <= _e; ee--, _e--) if (I[ee] !== z[_e]) { + if (ee !== 1 || _e !== 1) + do + if (ee--, _e--, 0 > _e || I[ee] !== z[_e]) { + var Me = ` +` + I[ee].replace(" at new ", " at "); + return s.displayName && Me.includes("") && (Me = Me.replace("", s.displayName)), Me; + } + while (1 <= ee && 0 <= _e); + break; + } + } + } finally { + ue = !1, Error.prepareStackTrace = m; + } + return (s = s ? s.displayName || s.name : "") ? ae(s) : ""; + } + function X(s) { + switch (s.tag) { + case 5: + return ae(s.type); + case 16: + return ae("Lazy"); + case 13: + return ae("Suspense"); + case 19: + return ae("SuspenseList"); + case 0: + case 2: + case 15: + return s = me(s.type, !1), s; + case 11: + return s = me(s.type.render, !1), s; + case 1: + return s = me(s.type, !0), s; + default: + return ""; + } + } + function xe(s) { + if (s == null) return null; + if (typeof s == "function") return s.displayName || s.name || null; + if (typeof s == "string") return s; + switch (s) { + case P: + return "Fragment"; + case R: + return "Portal"; + case L: + return "Profiler"; + case A: + return "StrictMode"; + case J: + return "Suspense"; + case j: + return "SuspenseList"; + } + if (typeof s == "object") switch (s.$$typeof) { + case G: + return (s.displayName || "Context") + ".Consumer"; + case T: + return (s._context.displayName || "Context") + ".Provider"; + case W: + var l = s.render; + return s = s.displayName, s || (s = l.displayName || l.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s; + case K: + return l = s.displayName || null, l !== null ? l : xe(s.type) || "Memo"; + case Z: + l = s._payload, s = s._init; + try { + return xe(s(l)); + } catch { + } + } + return null; + } + function ye(s) { + var l = s.type; + switch (s.tag) { + case 24: + return "Cache"; + case 9: + return (l.displayName || "Context") + ".Consumer"; + case 10: + return (l._context.displayName || "Context") + ".Provider"; + case 18: + return "DehydratedFragment"; + case 11: + return s = l.render, s = s.displayName || s.name || "", l.displayName || (s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"); + case 7: + return "Fragment"; + case 5: + return l; + case 4: + return "Portal"; + case 3: + return "Root"; + case 6: + return "Text"; + case 16: + return xe(l); + case 8: + return l === A ? "StrictMode" : "Mode"; + case 22: + return "Offscreen"; + case 12: + return "Profiler"; + case 21: + return "Scope"; + case 13: + return "Suspense"; + case 19: + return "SuspenseList"; + case 25: + return "TracingMarker"; + case 1: + case 0: + case 17: + case 2: + case 14: + case 15: + if (typeof l == "function") return l.displayName || l.name || null; + if (typeof l == "string") return l; + } + return null; + } + function be(s) { + switch (typeof s) { + case "boolean": + case "number": + case "string": + case "undefined": + return s; + case "object": + return s; + default: + return ""; + } + } + function we(s) { + var l = s.type; + return (s = s.nodeName) && s.toLowerCase() === "input" && (l === "checkbox" || l === "radio"); + } + function je(s) { + var l = we(s) ? "checked" : "value", m = Object.getOwnPropertyDescriptor(s.constructor.prototype, l), k = "" + s[l]; + if (!s.hasOwnProperty(l) && typeof m < "u" && typeof m.get == "function" && typeof m.set == "function") { + var I = m.get, z = m.set; + return Object.defineProperty(s, l, { configurable: !0, get: function() { + return I.call(this); + }, set: function(ee) { + k = "" + ee, z.call(this, ee); + } }), Object.defineProperty(s, l, { enumerable: m.enumerable }), { getValue: function() { + return k; + }, setValue: function(ee) { + k = "" + ee; + }, stopTracking: function() { + s._valueTracker = null, delete s[l]; + } }; + } + } + function $e(s) { + s._valueTracker || (s._valueTracker = je(s)); + } + function Ve(s) { + if (!s) return !1; + var l = s._valueTracker; + if (!l) return !0; + var m = l.getValue(), k = ""; + return s && (k = we(s) ? s.checked ? "true" : "false" : s.value), s = k, s !== m ? (l.setValue(s), !0) : !1; + } + function Ge(s) { + if (s = s || (typeof document < "u" ? document : void 0), typeof s > "u") return null; + try { + return s.activeElement || s.body; + } catch { + return s.body; + } + } + function ut(s, l) { + var m = l.checked; + return fe({}, l, { defaultChecked: void 0, defaultValue: void 0, value: void 0, checked: m ?? s._wrapperState.initialChecked }); + } + function dt(s, l) { + var m = l.defaultValue == null ? "" : l.defaultValue, k = l.checked != null ? l.checked : l.defaultChecked; + m = be(l.value != null ? l.value : m), s._wrapperState = { initialChecked: k, initialValue: m, controlled: l.type === "checkbox" || l.type === "radio" ? l.checked != null : l.value != null }; + } + function wt(s, l) { + l = l.checked, l != null && S(s, "checked", l, !1); + } + function De(s, l) { + wt(s, l); + var m = be(l.value), k = l.type; + if (m != null) k === "number" ? (m === 0 && s.value === "" || s.value != m) && (s.value = "" + m) : s.value !== "" + m && (s.value = "" + m); + else if (k === "submit" || k === "reset") { + s.removeAttribute("value"); + return; + } + l.hasOwnProperty("value") ? _t(s, l.type, m) : l.hasOwnProperty("defaultValue") && _t(s, l.type, be(l.defaultValue)), l.checked == null && l.defaultChecked != null && (s.defaultChecked = !!l.defaultChecked); + } + function lt(s, l, m) { + if (l.hasOwnProperty("value") || l.hasOwnProperty("defaultValue")) { + var k = l.type; + if (!(k !== "submit" && k !== "reset" || l.value !== void 0 && l.value !== null)) return; + l = "" + s._wrapperState.initialValue, m || l === s.value || (s.value = l), s.defaultValue = l; + } + m = s.name, m !== "" && (s.name = ""), s.defaultChecked = !!s._wrapperState.initialChecked, m !== "" && (s.name = m); + } + function _t(s, l, m) { + (l !== "number" || Ge(s.ownerDocument) !== s) && (m == null ? s.defaultValue = "" + s._wrapperState.initialValue : s.defaultValue !== "" + m && (s.defaultValue = "" + m)); + } + var vt = Array.isArray; + function Mt(s, l, m, k) { + if (s = s.options, l) { + l = {}; + for (var I = 0; I < m.length; I++) l["$" + m[I]] = !0; + for (m = 0; m < s.length; m++) I = l.hasOwnProperty("$" + s[m].value), s[m].selected !== I && (s[m].selected = I), I && k && (s[m].defaultSelected = !0); + } else { + for (m = "" + be(m), l = null, I = 0; I < s.length; I++) { + if (s[I].value === m) { + s[I].selected = !0, k && (s[I].defaultSelected = !0); + return; + } + l !== null || s[I].disabled || (l = s[I]); + } + l !== null && (l.selected = !0); + } + } + function at(s, l) { + if (l.dangerouslySetInnerHTML != null) throw Error(n(91)); + return fe({}, l, { value: void 0, defaultValue: void 0, children: "" + s._wrapperState.initialValue }); + } + function Pt(s, l) { + var m = l.value; + if (m == null) { + if (m = l.children, l = l.defaultValue, m != null) { + if (l != null) throw Error(n(92)); + if (vt(m)) { + if (1 < m.length) throw Error(n(93)); + m = m[0]; + } + l = m; + } + l == null && (l = ""), m = l; + } + s._wrapperState = { initialValue: be(m) }; + } + function Ie(s, l) { + var m = be(l.value), k = be(l.defaultValue); + m != null && (m = "" + m, m !== s.value && (s.value = m), l.defaultValue == null && s.defaultValue !== m && (s.defaultValue = m)), k != null && (s.defaultValue = "" + k); + } + function Qe(s) { + var l = s.textContent; + l === s._wrapperState.initialValue && l !== "" && l !== null && (s.value = l); + } + function Ct(s) { + switch (s) { + case "svg": + return "http://www.w3.org/2000/svg"; + case "math": + return "http://www.w3.org/1998/Math/MathML"; + default: + return "http://www.w3.org/1999/xhtml"; + } + } + function Nt(s, l) { + return s == null || s === "http://www.w3.org/1999/xhtml" ? Ct(l) : s === "http://www.w3.org/2000/svg" && l === "foreignObject" ? "http://www.w3.org/1999/xhtml" : s; + } + var kt, rt = (function(s) { + return typeof MSApp < "u" && MSApp.execUnsafeLocalFunction ? function(l, m, k, I) { + MSApp.execUnsafeLocalFunction(function() { + return s(l, m, k, I); + }); + } : s; + })(function(s, l) { + if (s.namespaceURI !== "http://www.w3.org/2000/svg" || "innerHTML" in s) s.innerHTML = l; + else { + for (kt = kt || document.createElement("div"), kt.innerHTML = "" + l.valueOf().toString() + "", l = kt.firstChild; s.firstChild; ) s.removeChild(s.firstChild); + for (; l.firstChild; ) s.appendChild(l.firstChild); + } + }); + function ht(s, l) { + if (l) { + var m = s.firstChild; + if (m && m === s.lastChild && m.nodeType === 3) { + m.nodeValue = l; + return; + } + } + s.textContent = l; + } + var Fe = { + animationIterationCount: !0, + aspectRatio: !0, + borderImageOutset: !0, + borderImageSlice: !0, + borderImageWidth: !0, + boxFlex: !0, + boxFlexGroup: !0, + boxOrdinalGroup: !0, + columnCount: !0, + columns: !0, + flex: !0, + flexGrow: !0, + flexPositive: !0, + flexShrink: !0, + flexNegative: !0, + flexOrder: !0, + gridArea: !0, + gridRow: !0, + gridRowEnd: !0, + gridRowSpan: !0, + gridRowStart: !0, + gridColumn: !0, + gridColumnEnd: !0, + gridColumnSpan: !0, + gridColumnStart: !0, + fontWeight: !0, + lineClamp: !0, + lineHeight: !0, + opacity: !0, + order: !0, + orphans: !0, + tabSize: !0, + widows: !0, + zIndex: !0, + zoom: !0, + fillOpacity: !0, + floodOpacity: !0, + stopOpacity: !0, + strokeDasharray: !0, + strokeDashoffset: !0, + strokeMiterlimit: !0, + strokeOpacity: !0, + strokeWidth: !0 + }, Ke = ["Webkit", "ms", "Moz", "O"]; + Object.keys(Fe).forEach(function(s) { + Ke.forEach(function(l) { + l = l + s.charAt(0).toUpperCase() + s.substring(1), Fe[l] = Fe[s]; + }); + }); + function it(s, l, m) { + return l == null || typeof l == "boolean" || l === "" ? "" : m || typeof l != "number" || l === 0 || Fe.hasOwnProperty(s) && Fe[s] ? ("" + l).trim() : l + "px"; + } + function $t(s, l) { + s = s.style; + for (var m in l) if (l.hasOwnProperty(m)) { + var k = m.indexOf("--") === 0, I = it(m, l[m], k); + m === "float" && (m = "cssFloat"), k ? s.setProperty(m, I) : s[m] = I; + } + } + var Gt = fe({ menuitem: !0 }, { area: !0, base: !0, br: !0, col: !0, embed: !0, hr: !0, img: !0, input: !0, keygen: !0, link: !0, meta: !0, param: !0, source: !0, track: !0, wbr: !0 }); + function Et(s, l) { + if (l) { + if (Gt[s] && (l.children != null || l.dangerouslySetInnerHTML != null)) throw Error(n(137, s)); + if (l.dangerouslySetInnerHTML != null) { + if (l.children != null) throw Error(n(60)); + if (typeof l.dangerouslySetInnerHTML != "object" || !("__html" in l.dangerouslySetInnerHTML)) throw Error(n(61)); + } + if (l.style != null && typeof l.style != "object") throw Error(n(62)); + } + } + function Fn(s, l) { + if (s.indexOf("-") === -1) return typeof l.is == "string"; + switch (s) { + case "annotation-xml": + case "color-profile": + case "font-face": + case "font-face-src": + case "font-face-uri": + case "font-face-format": + case "font-face-name": + case "missing-glyph": + return !1; + default: + return !0; + } + } + var Ye = null; + function rn(s) { + return s = s.target || s.srcElement || window, s.correspondingUseElement && (s = s.correspondingUseElement), s.nodeType === 3 ? s.parentNode : s; + } + var Dn = null, cn = null, Rt = null; + function Oe(s) { + if (s = On(s)) { + if (typeof Dn != "function") throw Error(n(280)); + var l = s.stateNode; + l && (l = $i(l), Dn(s.stateNode, s.type, l)); + } + } + function At(s) { + cn ? Rt ? Rt.push(s) : Rt = [s] : cn = s; + } + function tn() { + if (cn) { + var s = cn, l = Rt; + if (Rt = cn = null, Oe(s), l) for (s = 0; s < l.length; s++) Oe(l[s]); + } + } + function an(s, l) { + return s(l); + } + function tt() { + } + var Xt = !1; + function Jn(s, l, m) { + if (Xt) return s(l, m); + Xt = !0; + try { + return an(s, l, m); + } finally { + Xt = !1, (cn !== null || Rt !== null) && (tt(), tn()); + } + } + function Qn(s, l) { + var m = s.stateNode; + if (m === null) return null; + var k = $i(m); + if (k === null) return null; + m = k[l]; + e: switch (l) { + case "onClick": + case "onClickCapture": + case "onDoubleClick": + case "onDoubleClickCapture": + case "onMouseDown": + case "onMouseDownCapture": + case "onMouseMove": + case "onMouseMoveCapture": + case "onMouseUp": + case "onMouseUpCapture": + case "onMouseEnter": + (k = !k.disabled) || (s = s.type, k = !(s === "button" || s === "input" || s === "select" || s === "textarea")), s = !k; + break e; + default: + s = !1; + } + if (s) return null; + if (m && typeof m != "function") throw Error(n(231, l, typeof m)); + return m; + } + var nn = !1; + if (c) try { + var Tn = {}; + Object.defineProperty(Tn, "passive", { get: function() { + nn = !0; + } }), window.addEventListener("test", Tn, Tn), window.removeEventListener("test", Tn, Tn); + } catch { + nn = !1; + } + function Nn(s, l, m, k, I, z, ee, _e, Me) { + var Ue = Array.prototype.slice.call(arguments, 3); + try { + l.apply(m, Ue); + } catch (ct) { + this.onError(ct); + } + } + var ea = !1, Yn = null, xa = !1, hr = null, _a = { onError: function(s) { + ea = !0, Yn = s; + } }; + function Wr(s, l, m, k, I, z, ee, _e, Me) { + ea = !1, Yn = null, Nn.apply(_a, arguments); + } + function da(s, l, m, k, I, z, ee, _e, Me) { + if (Wr.apply(this, arguments), ea) { + if (ea) { + var Ue = Yn; + ea = !1, Yn = null; + } else throw Error(n(198)); + xa || (xa = !0, hr = Ue); + } + } + function nr(s) { + var l = s, m = s; + if (s.alternate) for (; l.return; ) l = l.return; + else { + s = l; + do + l = s, (l.flags & 4098) !== 0 && (m = l.return), s = l.return; + while (s); + } + return l.tag === 3 ? m : null; + } + function Jt(s) { + if (s.tag === 13) { + var l = s.memoizedState; + if (l === null && (s = s.alternate, s !== null && (l = s.memoizedState)), l !== null) return l.dehydrated; + } + return null; + } + function dr(s) { + if (nr(s) !== s) throw Error(n(188)); + } + function on(s) { + var l = s.alternate; + if (!l) { + if (l = nr(s), l === null) throw Error(n(188)); + return l !== s ? null : s; + } + for (var m = s, k = l; ; ) { + var I = m.return; + if (I === null) break; + var z = I.alternate; + if (z === null) { + if (k = I.return, k !== null) { + m = k; + continue; + } + break; + } + if (I.child === z.child) { + for (z = I.child; z; ) { + if (z === m) return dr(I), s; + if (z === k) return dr(I), l; + z = z.sibling; + } + throw Error(n(188)); + } + if (m.return !== k.return) m = I, k = z; + else { + for (var ee = !1, _e = I.child; _e; ) { + if (_e === m) { + ee = !0, m = I, k = z; + break; + } + if (_e === k) { + ee = !0, k = I, m = z; + break; + } + _e = _e.sibling; + } + if (!ee) { + for (_e = z.child; _e; ) { + if (_e === m) { + ee = !0, m = z, k = I; + break; + } + if (_e === k) { + ee = !0, k = z, m = I; + break; + } + _e = _e.sibling; + } + if (!ee) throw Error(n(189)); + } + } + if (m.alternate !== k) throw Error(n(190)); + } + if (m.tag !== 3) throw Error(n(188)); + return m.stateNode.current === m ? s : l; + } + function Er(s) { + return s = on(s), s !== null ? rr(s) : null; + } + function rr(s) { + if (s.tag === 5 || s.tag === 6) return s; + for (s = s.child; s !== null; ) { + var l = rr(s); + if (l !== null) return l; + s = s.sibling; + } + return null; + } + var $a = t.unstable_scheduleCallback, Hr = t.unstable_cancelCallback, ki = t.unstable_shouldYield, Ci = t.unstable_requestPaint, xn = t.unstable_now, kn = t.unstable_getCurrentPriorityLevel, co = t.unstable_ImmediatePriority, Va = t.unstable_UserBlockingPriority, La = t.unstable_NormalPriority, So = t.unstable_LowPriority, Ra = t.unstable_IdlePriority, Ur = null, ta = null; + function nt(s) { + if (ta && typeof ta.onCommitFiberRoot == "function") try { + ta.onCommitFiberRoot(Ur, s, void 0, (s.current.flags & 128) === 128); + } catch { + } + } + var gn = Math.clz32 ? Math.clz32 : uo, wa = Math.log, ba = Math.LN2; + function uo(s) { + return s >>>= 0, s === 0 ? 32 : 31 - (wa(s) / ba | 0) | 0; + } + var Y = 64, Te = 4194304; + function qe(s) { + switch (s & -s) { + case 1: + return 1; + case 2: + return 2; + case 4: + return 4; + case 8: + return 8; + case 16: + return 16; + case 32: + return 32; + case 64: + case 128: + case 256: + case 512: + case 1024: + case 2048: + case 4096: + case 8192: + case 16384: + case 32768: + case 65536: + case 131072: + case 262144: + case 524288: + case 1048576: + case 2097152: + return s & 4194240; + case 4194304: + case 8388608: + case 16777216: + case 33554432: + case 67108864: + return s & 130023424; + case 134217728: + return 134217728; + case 268435456: + return 268435456; + case 536870912: + return 536870912; + case 1073741824: + return 1073741824; + default: + return s; + } + } + function et(s, l) { + var m = s.pendingLanes; + if (m === 0) return 0; + var k = 0, I = s.suspendedLanes, z = s.pingedLanes, ee = m & 268435455; + if (ee !== 0) { + var _e = ee & ~I; + _e !== 0 ? k = qe(_e) : (z &= ee, z !== 0 && (k = qe(z))); + } else ee = m & ~I, ee !== 0 ? k = qe(ee) : z !== 0 && (k = qe(z)); + if (k === 0) return 0; + if (l !== 0 && l !== k && (l & I) === 0 && (I = k & -k, z = l & -l, I >= z || I === 16 && (z & 4194240) !== 0)) return l; + if ((k & 4) !== 0 && (k |= m & 16), l = s.entangledLanes, l !== 0) for (s = s.entanglements, l &= k; 0 < l; ) m = 31 - gn(l), I = 1 << m, k |= s[m], l &= ~I; + return k; + } + function $(s, l) { + switch (s) { + case 1: + case 2: + case 4: + return l + 250; + case 8: + case 16: + case 32: + case 64: + case 128: + case 256: + case 512: + case 1024: + case 2048: + case 4096: + case 8192: + case 16384: + case 32768: + case 65536: + case 131072: + case 262144: + case 524288: + case 1048576: + case 2097152: + return l + 5e3; + case 4194304: + case 8388608: + case 16777216: + case 33554432: + case 67108864: + return -1; + case 134217728: + case 268435456: + case 536870912: + case 1073741824: + return -1; + default: + return -1; + } + } + function q(s, l) { + for (var m = s.suspendedLanes, k = s.pingedLanes, I = s.expirationTimes, z = s.pendingLanes; 0 < z; ) { + var ee = 31 - gn(z), _e = 1 << ee, Me = I[ee]; + Me === -1 ? ((_e & m) === 0 || (_e & k) !== 0) && (I[ee] = $(_e, l)) : Me <= l && (s.expiredLanes |= _e), z &= ~_e; + } + } + function te(s) { + return s = s.pendingLanes & -1073741825, s !== 0 ? s : s & 1073741824 ? 1073741824 : 0; + } + function ne() { + var s = Y; + return Y <<= 1, (Y & 4194240) === 0 && (Y = 64), s; + } + function Se(s) { + for (var l = [], m = 0; 31 > m; m++) l.push(s); + return l; + } + function Ee(s, l, m) { + s.pendingLanes |= l, l !== 536870912 && (s.suspendedLanes = 0, s.pingedLanes = 0), s = s.eventTimes, l = 31 - gn(l), s[l] = m; + } + function Ae(s, l) { + var m = s.pendingLanes & ~l; + s.pendingLanes = l, s.suspendedLanes = 0, s.pingedLanes = 0, s.expiredLanes &= l, s.mutableReadLanes &= l, s.entangledLanes &= l, l = s.entanglements; + var k = s.eventTimes; + for (s = s.expirationTimes; 0 < m; ) { + var I = 31 - gn(m), z = 1 << I; + l[I] = 0, k[I] = -1, s[I] = -1, m &= ~z; + } + } + function ft(s, l) { + var m = s.entangledLanes |= l; + for (s = s.entanglements; m; ) { + var k = 31 - gn(m), I = 1 << k; + I & l | s[k] & l && (s[k] |= l), m &= ~I; + } + } + var xt = 0; + function Bt(s) { + return s &= -s, 1 < s ? 4 < s ? (s & 268435455) !== 0 ? 16 : 536870912 : 4 : 1; + } + var Kt, fn, Vr, na, Ar, ra = !1, Ka = [], Oa = null, Mr = null, $n = null, Or = /* @__PURE__ */ new Map(), Vn = /* @__PURE__ */ new Map(), mr = [], wl = "mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" "); + function In(s, l) { + switch (s) { + case "focusin": + case "focusout": + Oa = null; + break; + case "dragenter": + case "dragleave": + Mr = null; + break; + case "mouseover": + case "mouseout": + $n = null; + break; + case "pointerover": + case "pointerout": + Or.delete(l.pointerId); + break; + case "gotpointercapture": + case "lostpointercapture": + Vn.delete(l.pointerId); + } + } + function fa(s, l, m, k, I, z) { + return s === null || s.nativeEvent !== z ? (s = { blockedOn: l, domEventName: m, eventSystemFlags: k, nativeEvent: z, targetContainers: [I] }, l !== null && (l = On(l), l !== null && fn(l)), s) : (s.eventSystemFlags |= k, l = s.targetContainers, I !== null && l.indexOf(I) === -1 && l.push(I), s); + } + function cs(s, l, m, k, I) { + switch (l) { + case "focusin": + return Oa = fa(Oa, s, l, m, k, I), !0; + case "dragenter": + return Mr = fa(Mr, s, l, m, k, I), !0; + case "mouseover": + return $n = fa($n, s, l, m, k, I), !0; + case "pointerover": + var z = I.pointerId; + return Or.set(z, fa(Or.get(z) || null, s, l, m, k, I)), !0; + case "gotpointercapture": + return z = I.pointerId, Vn.set(z, fa(Vn.get(z) || null, s, l, m, k, I)), !0; + } + return !1; + } + function ko(s) { + var l = _n(s.target); + if (l !== null) { + var m = nr(l); + if (m !== null) { + if (l = m.tag, l === 13) { + if (l = Jt(m), l !== null) { + s.blockedOn = l, Ar(s.priority, function() { + Vr(m); + }); + return; + } + } else if (l === 3 && m.stateNode.current.memoizedState.isDehydrated) { + s.blockedOn = m.tag === 3 ? m.stateNode.containerInfo : null; + return; + } + } + } + s.blockedOn = null; + } + function Mi(s) { + if (s.blockedOn !== null) return !1; + for (var l = s.targetContainers; 0 < l.length; ) { + var m = Qa(s.domEventName, s.eventSystemFlags, l[0], s.nativeEvent); + if (m === null) { + m = s.nativeEvent; + var k = new m.constructor(m.type, m); + Ye = k, m.target.dispatchEvent(k), Ye = null; + } else return l = On(m), l !== null && fn(l), s.blockedOn = m, !1; + l.shift(); + } + return !0; + } + function Fs(s, l, m) { + Mi(s) && m.delete(l); + } + function Ln() { + ra = !1, Oa !== null && Mi(Oa) && (Oa = null), Mr !== null && Mi(Mr) && (Mr = null), $n !== null && Mi($n) && ($n = null), Or.forEach(Fs), Vn.forEach(Fs); + } + function Ya(s, l) { + s.blockedOn === l && (s.blockedOn = null, ra || (ra = !0, t.unstable_scheduleCallback(t.unstable_NormalPriority, Ln))); + } + function Xa(s) { + function l(I) { + return Ya(I, s); + } + if (0 < Ka.length) { + Ya(Ka[0], s); + for (var m = 1; m < Ka.length; m++) { + var k = Ka[m]; + k.blockedOn === s && (k.blockedOn = null); + } + } + for (Oa !== null && Ya(Oa, s), Mr !== null && Ya(Mr, s), $n !== null && Ya($n, s), Or.forEach(l), Vn.forEach(l), m = 0; m < mr.length; m++) k = mr[m], k.blockedOn === s && (k.blockedOn = null); + for (; 0 < mr.length && (m = mr[0], m.blockedOn === null); ) ko(m), m.blockedOn === null && mr.shift(); + } + var Ja = N.ReactCurrentBatchConfig, jr = !0; + function Ni(s, l, m, k) { + var I = xt, z = Ja.transition; + Ja.transition = null; + try { + xt = 1, Ei(s, l, m, k); + } finally { + xt = I, Ja.transition = z; + } + } + function qo(s, l, m, k) { + var I = xt, z = Ja.transition; + Ja.transition = null; + try { + xt = 4, Ei(s, l, m, k); + } finally { + xt = I, Ja.transition = z; + } + } + function Ei(s, l, m, k) { + if (jr) { + var I = Qa(s, l, m, k); + if (I === null) wu(s, l, k, Wo, m), In(s, k); + else if (cs(I, s, l, m, k)) k.stopPropagation(); + else if (In(s, k), l & 4 && -1 < wl.indexOf(s)) { + for (; I !== null; ) { + var z = On(I); + if (z !== null && Kt(z), z = Qa(s, l, m, k), z === null && wu(s, l, k, Wo, m), z === I) break; + I = z; + } + I !== null && k.stopPropagation(); + } else wu(s, l, k, null, m); + } + } + var Wo = null; + function Qa(s, l, m, k) { + if (Wo = null, s = rn(k), s = _n(s), s !== null) if (l = nr(s), l === null) s = null; + else if (m = l.tag, m === 13) { + if (s = Jt(l), s !== null) return s; + s = null; + } else if (m === 3) { + if (l.stateNode.current.memoizedState.isDehydrated) return l.tag === 3 ? l.stateNode.containerInfo : null; + s = null; + } else l !== s && (s = null); + return Wo = s, null; + } + function bl(s) { + switch (s) { + case "cancel": + case "click": + case "close": + case "contextmenu": + case "copy": + case "cut": + case "auxclick": + case "dblclick": + case "dragend": + case "dragstart": + case "drop": + case "focusin": + case "focusout": + case "input": + case "invalid": + case "keydown": + case "keypress": + case "keyup": + case "mousedown": + case "mouseup": + case "paste": + case "pause": + case "play": + case "pointercancel": + case "pointerdown": + case "pointerup": + case "ratechange": + case "reset": + case "resize": + case "seeked": + case "submit": + case "touchcancel": + case "touchend": + case "touchstart": + case "volumechange": + case "change": + case "selectionchange": + case "textInput": + case "compositionstart": + case "compositionend": + case "compositionupdate": + case "beforeblur": + case "afterblur": + case "beforeinput": + case "blur": + case "fullscreenchange": + case "focus": + case "hashchange": + case "popstate": + case "select": + case "selectstart": + return 1; + case "drag": + case "dragenter": + case "dragexit": + case "dragleave": + case "dragover": + case "mousemove": + case "mouseout": + case "mouseover": + case "pointermove": + case "pointerout": + case "pointerover": + case "scroll": + case "toggle": + case "touchmove": + case "wheel": + case "mouseenter": + case "mouseleave": + case "pointerenter": + case "pointerleave": + return 4; + case "message": + switch (kn()) { + case co: + return 1; + case Va: + return 4; + case La: + case So: + return 16; + case Ra: + return 536870912; + default: + return 16; + } + default: + return 16; + } + } + var Co = null, si = null, Sl = null; + function $s() { + if (Sl) return Sl; + var s, l = si, m = l.length, k, I = "value" in Co ? Co.value : Co.textContent, z = I.length; + for (s = 0; s < m && l[s] === I[s]; s++) ; + var ee = m - s; + for (k = 1; k <= ee && l[m - k] === I[z - k]; k++) ; + return Sl = I.slice(s, 1 < k ? 1 - k : void 0); + } + function Za(s) { + var l = s.keyCode; + return "charCode" in s ? (s = s.charCode, s === 0 && l === 13 && (s = 13)) : s = l, s === 10 && (s = 13), 32 <= s || s === 13 ? s : 0; + } + function Mo() { + return !0; + } + function Ls() { + return !1; + } + function aa(s) { + function l(m, k, I, z, ee) { + this._reactName = m, this._targetInst = I, this.type = k, this.nativeEvent = z, this.target = ee, this.currentTarget = null; + for (var _e in s) s.hasOwnProperty(_e) && (m = s[_e], this[_e] = m ? m(z) : z[_e]); + return this.isDefaultPrevented = (z.defaultPrevented != null ? z.defaultPrevented : z.returnValue === !1) ? Mo : Ls, this.isPropagationStopped = Ls, this; + } + return fe(l.prototype, { preventDefault: function() { + this.defaultPrevented = !0; + var m = this.nativeEvent; + m && (m.preventDefault ? m.preventDefault() : typeof m.returnValue != "unknown" && (m.returnValue = !1), this.isDefaultPrevented = Mo); + }, stopPropagation: function() { + var m = this.nativeEvent; + m && (m.stopPropagation ? m.stopPropagation() : typeof m.cancelBubble != "unknown" && (m.cancelBubble = !0), this.isPropagationStopped = Mo); + }, persist: function() { + }, isPersistent: Mo }), l; + } + var us = { eventPhase: 0, bubbles: 0, cancelable: 0, timeStamp: function(s) { + return s.timeStamp || Date.now(); + }, defaultPrevented: 0, isTrusted: 0 }, li = aa(us), Rs = fe({}, us, { view: 0, detail: 0 }), sc = aa(Rs), eo, No, fo, ci = fe({}, Rs, { screenX: 0, screenY: 0, clientX: 0, clientY: 0, pageX: 0, pageY: 0, ctrlKey: 0, shiftKey: 0, altKey: 0, metaKey: 0, getModifierState: Uo, button: 0, buttons: 0, relatedTarget: function(s) { + return s.relatedTarget === void 0 ? s.fromElement === s.srcElement ? s.toElement : s.fromElement : s.relatedTarget; + }, movementX: function(s) { + return "movementX" in s ? s.movementX : (s !== fo && (fo && s.type === "mousemove" ? (eo = s.screenX - fo.screenX, No = s.screenY - fo.screenY) : No = eo = 0, fo = s), eo); + }, movementY: function(s) { + return "movementY" in s ? s.movementY : No; + } }), Os = aa(ci), Ds = fe({}, ci, { dataTransfer: 0 }), lc = aa(Ds), pa = fe({}, Rs, { relatedTarget: 0 }), kl = aa(pa), zs = fe({}, us, { animationName: 0, elapsedTime: 0, pseudoElement: 0 }), ds = aa(zs), Ai = fe({}, us, { clipboardData: function(s) { + return "clipboardData" in s ? s.clipboardData : window.clipboardData; + } }), Cl = aa(Ai), oa = fe({}, us, { data: 0 }), Ho = aa(oa), ji = { + Esc: "Escape", + Spacebar: " ", + Left: "ArrowLeft", + Up: "ArrowUp", + Right: "ArrowRight", + Down: "ArrowDown", + Del: "Delete", + Win: "OS", + Menu: "ContextMenu", + Apps: "ContextMenu", + Scroll: "ScrollLock", + MozPrintableKey: "Unidentified" + }, ha = { + 8: "Backspace", + 9: "Tab", + 12: "Clear", + 13: "Enter", + 16: "Shift", + 17: "Control", + 18: "Alt", + 19: "Pause", + 20: "CapsLock", + 27: "Escape", + 32: " ", + 33: "PageUp", + 34: "PageDown", + 35: "End", + 36: "Home", + 37: "ArrowLeft", + 38: "ArrowUp", + 39: "ArrowRight", + 40: "ArrowDown", + 45: "Insert", + 46: "Delete", + 112: "F1", + 113: "F2", + 114: "F3", + 115: "F4", + 116: "F5", + 117: "F6", + 118: "F7", + 119: "F8", + 120: "F9", + 121: "F10", + 122: "F11", + 123: "F12", + 144: "NumLock", + 145: "ScrollLock", + 224: "Meta" + }, ui = { Alt: "altKey", Control: "ctrlKey", Meta: "metaKey", Shift: "shiftKey" }; + function ar(s) { + var l = this.nativeEvent; + return l.getModifierState ? l.getModifierState(s) : (s = ui[s]) ? !!l[s] : !1; + } + function Uo() { + return ar; + } + var Gs = fe({}, Rs, { key: function(s) { + if (s.key) { + var l = ji[s.key] || s.key; + if (l !== "Unidentified") return l; + } + return s.type === "keypress" ? (s = Za(s), s === 13 ? "Enter" : String.fromCharCode(s)) : s.type === "keydown" || s.type === "keyup" ? ha[s.keyCode] || "Unidentified" : ""; + }, code: 0, location: 0, ctrlKey: 0, shiftKey: 0, altKey: 0, metaKey: 0, repeat: 0, locale: 0, getModifierState: Uo, charCode: function(s) { + return s.type === "keypress" ? Za(s) : 0; + }, keyCode: function(s) { + return s.type === "keydown" || s.type === "keyup" ? s.keyCode : 0; + }, which: function(s) { + return s.type === "keypress" ? Za(s) : s.type === "keydown" || s.type === "keyup" ? s.keyCode : 0; + } }), du = aa(Gs), O = fe({}, ci, { pointerId: 0, width: 0, height: 0, pressure: 0, tangentialPressure: 0, tiltX: 0, tiltY: 0, twist: 0, pointerType: 0, isPrimary: 0 }), V = aa(O), re = fe({}, Rs, { touches: 0, targetTouches: 0, changedTouches: 0, altKey: 0, metaKey: 0, ctrlKey: 0, shiftKey: 0, getModifierState: Uo }), ge = aa(re), Be = fe({}, us, { propertyName: 0, elapsedTime: 0, pseudoElement: 0 }), Le = aa(Be), Je = fe({}, ci, { + deltaX: function(s) { + return "deltaX" in s ? s.deltaX : "wheelDeltaX" in s ? -s.wheelDeltaX : 0; + }, + deltaY: function(s) { + return "deltaY" in s ? s.deltaY : "wheelDeltaY" in s ? -s.wheelDeltaY : "wheelDelta" in s ? -s.wheelDelta : 0; + }, + deltaZ: 0, + deltaMode: 0 + }), pt = aa(Je), Yt = [9, 13, 27, 32], sn = c && "CompositionEvent" in window, Dt = null; + c && "documentMode" in document && (Dt = document.documentMode); + var Rn = c && "TextEvent" in window && !Dt, gr = c && (!sn || Dt && 8 < Dt && 11 >= Dt), Da = " ", Pr = !1; + function Eo(s, l) { + switch (s) { + case "keyup": + return Yt.indexOf(l.keyCode) !== -1; + case "keydown": + return l.keyCode !== 229; + case "keypress": + case "mousedown": + case "focusout": + return !0; + default: + return !1; + } + } + function Ml(s) { + return s = s.detail, typeof s == "object" && "data" in s ? s.data : null; + } + var Ao = !1; + function Zd(s, l) { + switch (s) { + case "compositionend": + return Ml(l); + case "keypress": + return l.which !== 32 ? null : (Pr = !0, Da); + case "textInput": + return s = l.data, s === Da && Pr ? null : s; + default: + return null; + } + } + function Up(s, l) { + if (Ao) return s === "compositionend" || !sn && Eo(s, l) ? (s = $s(), Sl = si = Co = null, Ao = !1, s) : null; + switch (s) { + case "paste": + return null; + case "keypress": + if (!(l.ctrlKey || l.altKey || l.metaKey) || l.ctrlKey && l.altKey) { + if (l.char && 1 < l.char.length) return l.char; + if (l.which) return String.fromCharCode(l.which); + } + return null; + case "compositionend": + return gr && l.locale !== "ko" ? null : l.data; + default: + return null; + } + } + var Vp = { color: !0, date: !0, datetime: !0, "datetime-local": !0, email: !0, month: !0, number: !0, password: !0, range: !0, search: !0, tel: !0, text: !0, time: !0, url: !0, week: !0 }; + function en(s) { + var l = s && s.nodeName && s.nodeName.toLowerCase(); + return l === "input" ? !!Vp[s.type] : l === "textarea"; + } + function jo(s, l, m, k) { + At(k), l = Xo(l, "onChange"), 0 < l.length && (m = new li("onChange", "change", null, m, k), s.push({ event: m, listeners: l })); + } + var fs = null, cc = null; + function uc(s) { + _u(s, 0); + } + function fu(s) { + var l = Fi(s); + if (Ve(l)) return s; + } + function Kp(s, l) { + if (s === "change") return l; + } + var ef = !1; + if (c) { + var pu; + if (c) { + var hu = "oninput" in document; + if (!hu) { + var mu = document.createElement("div"); + mu.setAttribute("oninput", "return;"), hu = typeof mu.oninput == "function"; + } + pu = hu; + } else pu = !1; + ef = pu && (!document.documentMode || 9 < document.documentMode); + } + function Nl() { + fs && (fs.detachEvent("onpropertychange", Yp), cc = fs = null); + } + function Yp(s) { + if (s.propertyName === "value" && fu(cc)) { + var l = []; + jo(l, cc, s, rn(s)), Jn(uc, l); + } + } + function ps(s, l, m) { + s === "focusin" ? (Nl(), fs = l, cc = m, fs.attachEvent("onpropertychange", Yp)) : s === "focusout" && Nl(); + } + function Fg(s) { + if (s === "selectionchange" || s === "keyup" || s === "keydown") return fu(cc); + } + function tf(s, l) { + if (s === "click") return fu(l); + } + function Bs(s, l) { + if (s === "input" || s === "change") return fu(l); + } + function $g(s, l) { + return s === l && (s !== 0 || 1 / s === 1 / l) || s !== s && l !== l; + } + var Vo = typeof Object.is == "function" ? Object.is : $g; + function dc(s, l) { + if (Vo(s, l)) return !0; + if (typeof s != "object" || s === null || typeof l != "object" || l === null) return !1; + var m = Object.keys(s), k = Object.keys(l); + if (m.length !== k.length) return !1; + for (k = 0; k < m.length; k++) { + var I = m[k]; + if (!d.call(l, I) || !Vo(s[I], l[I])) return !1; + } + return !0; + } + function Xp(s) { + for (; s && s.firstChild; ) s = s.firstChild; + return s; + } + function Jp(s, l) { + var m = Xp(s); + s = 0; + for (var k; m; ) { + if (m.nodeType === 3) { + if (k = s + m.textContent.length, s <= l && k >= l) return { node: m, offset: l - s }; + s = k; + } + e: { + for (; m; ) { + if (m.nextSibling) { + m = m.nextSibling; + break e; + } + m = m.parentNode; + } + m = void 0; + } + m = Xp(m); + } + } + function fc(s, l) { + return s && l ? s === l ? !0 : s && s.nodeType === 3 ? !1 : l && l.nodeType === 3 ? fc(s, l.parentNode) : "contains" in s ? s.contains(l) : s.compareDocumentPosition ? !!(s.compareDocumentPosition(l) & 16) : !1 : !1; + } + function Qp() { + for (var s = window, l = Ge(); l instanceof s.HTMLIFrameElement; ) { + try { + var m = typeof l.contentWindow.location.href == "string"; + } catch { + m = !1; + } + if (m) s = l.contentWindow; + else break; + l = Ge(s.document); + } + return l; + } + function pc(s) { + var l = s && s.nodeName && s.nodeName.toLowerCase(); + return l && (l === "input" && (s.type === "text" || s.type === "search" || s.type === "tel" || s.type === "url" || s.type === "password") || l === "textarea" || s.contentEditable === "true"); + } + function qs(s) { + var l = Qp(), m = s.focusedElem, k = s.selectionRange; + if (l !== m && m && m.ownerDocument && fc(m.ownerDocument.documentElement, m)) { + if (k !== null && pc(m)) { + if (l = k.start, s = k.end, s === void 0 && (s = l), "selectionStart" in m) m.selectionStart = l, m.selectionEnd = Math.min(s, m.value.length); + else if (s = (l = m.ownerDocument || document) && l.defaultView || window, s.getSelection) { + s = s.getSelection(); + var I = m.textContent.length, z = Math.min(k.start, I); + k = k.end === void 0 ? z : Math.min(k.end, I), !s.extend && z > k && (I = k, k = z, z = I), I = Jp(m, z); + var ee = Jp( + m, + k + ); + I && ee && (s.rangeCount !== 1 || s.anchorNode !== I.node || s.anchorOffset !== I.offset || s.focusNode !== ee.node || s.focusOffset !== ee.offset) && (l = l.createRange(), l.setStart(I.node, I.offset), s.removeAllRanges(), z > k ? (s.addRange(l), s.extend(ee.node, ee.offset)) : (l.setEnd(ee.node, ee.offset), s.addRange(l))); + } + } + for (l = [], s = m; s = s.parentNode; ) s.nodeType === 1 && l.push({ element: s, left: s.scrollLeft, top: s.scrollTop }); + for (typeof m.focus == "function" && m.focus(), m = 0; m < l.length; m++) s = l[m], s.element.scrollLeft = s.left, s.element.scrollTop = s.top; + } + } + var gu = c && "documentMode" in document && 11 >= document.documentMode, po = null, hc = null, ho = null, di = !1; + function Kn(s, l, m) { + var k = m.window === m ? m.document : m.nodeType === 9 ? m : m.ownerDocument; + di || po == null || po !== Ge(k) || (k = po, "selectionStart" in k && pc(k) ? k = { start: k.selectionStart, end: k.selectionEnd } : (k = (k.ownerDocument && k.ownerDocument.defaultView || window).getSelection(), k = { anchorNode: k.anchorNode, anchorOffset: k.anchorOffset, focusNode: k.focusNode, focusOffset: k.focusOffset }), ho && dc(ho, k) || (ho = k, k = Xo(hc, "onSelect"), 0 < k.length && (l = new li("onSelect", "select", null, l, m), s.push({ event: l, listeners: k }), l.target = po))); + } + function fi(s, l) { + var m = {}; + return m[s.toLowerCase()] = l.toLowerCase(), m["Webkit" + s] = "webkit" + l, m["Moz" + s] = "moz" + l, m; + } + var za = { animationend: fi("Animation", "AnimationEnd"), animationiteration: fi("Animation", "AnimationIteration"), animationstart: fi("Animation", "AnimationStart"), transitionend: fi("Transition", "TransitionEnd") }, mc = {}, El = {}; + c && (El = document.createElement("div").style, "AnimationEvent" in window || (delete za.animationend.animation, delete za.animationiteration.animation, delete za.animationstart.animation), "TransitionEvent" in window || delete za.transitionend.transition); + function Al(s) { + if (mc[s]) return mc[s]; + if (!za[s]) return s; + var l = za[s], m; + for (m in l) if (l.hasOwnProperty(m) && m in El) return mc[s] = l[m]; + return s; + } + var Pi = Al("animationend"), Zp = Al("animationiteration"), gc = Al("animationstart"), yu = Al("transitionend"), yc = /* @__PURE__ */ new Map(), eh = "abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" "); + function Sa(s, l) { + yc.set(s, l), o(l, [s]); + } + for (var vu = 0; vu < eh.length; vu++) { + var vc = eh[vu], Lg = vc.toLowerCase(), xu = vc[0].toUpperCase() + vc.slice(1); + Sa(Lg, "on" + xu); + } + Sa(Pi, "onAnimationEnd"), Sa(Zp, "onAnimationIteration"), Sa(gc, "onAnimationStart"), Sa("dblclick", "onDoubleClick"), Sa("focusin", "onFocus"), Sa("focusout", "onBlur"), Sa(yu, "onTransitionEnd"), i("onMouseEnter", ["mouseout", "mouseover"]), i("onMouseLeave", ["mouseout", "mouseover"]), i("onPointerEnter", ["pointerout", "pointerover"]), i("onPointerLeave", ["pointerout", "pointerover"]), o("onChange", "change click focusin focusout input keydown keyup selectionchange".split(" ")), o("onSelect", "focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")), o("onBeforeInput", ["compositionend", "keypress", "textInput", "paste"]), o("onCompositionEnd", "compositionend focusout keydown keypress keyup mousedown".split(" ")), o("onCompositionStart", "compositionstart focusout keydown keypress keyup mousedown".split(" ")), o("onCompositionUpdate", "compositionupdate focusout keydown keypress keyup mousedown".split(" ")); + var xc = "abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "), th = new Set("cancel close invalid load scroll toggle".split(" ").concat(xc)); + function Ko(s, l, m) { + var k = s.type || "unknown-event"; + s.currentTarget = m, da(k, l, void 0, s), s.currentTarget = null; + } + function _u(s, l) { + l = (l & 4) !== 0; + for (var m = 0; m < s.length; m++) { + var k = s[m], I = k.event; + k = k.listeners; + e: { + var z = void 0; + if (l) for (var ee = k.length - 1; 0 <= ee; ee--) { + var _e = k[ee], Me = _e.instance, Ue = _e.currentTarget; + if (_e = _e.listener, Me !== z && I.isPropagationStopped()) break e; + Ko(I, _e, Ue), z = Me; + } + else for (ee = 0; ee < k.length; ee++) { + if (_e = k[ee], Me = _e.instance, Ue = _e.currentTarget, _e = _e.listener, Me !== z && I.isPropagationStopped()) break e; + Ko(I, _e, Ue), z = Me; + } + } + } + if (xa) throw s = hr, xa = !1, hr = null, s; + } + function yn(s, l) { + var m = l[rf]; + m === void 0 && (m = l[rf] = /* @__PURE__ */ new Set()); + var k = s + "__bubble"; + m.has(k) || (nh(l, s, 2, !1), m.add(k)); + } + function yr(s, l, m) { + var k = 0; + l && (k |= 4), nh(m, s, k, l); + } + var Yo = "_reactListening" + Math.random().toString(36).slice(2); + function Ws(s) { + if (!s[Yo]) { + s[Yo] = !0, r.forEach(function(m) { + m !== "selectionchange" && (th.has(m) || yr(m, !1, s), yr(m, !0, s)); + }); + var l = s.nodeType === 9 ? s : s.ownerDocument; + l === null || l[Yo] || (l[Yo] = !0, yr("selectionchange", !1, l)); + } + } + function nh(s, l, m, k) { + switch (bl(l)) { + case 1: + var I = Ni; + break; + case 4: + I = qo; + break; + default: + I = Ei; + } + m = I.bind(null, l, m, s), I = void 0, !nn || l !== "touchstart" && l !== "touchmove" && l !== "wheel" || (I = !0), k ? I !== void 0 ? s.addEventListener(l, m, { capture: !0, passive: I }) : s.addEventListener(l, m, !0) : I !== void 0 ? s.addEventListener(l, m, { passive: I }) : s.addEventListener(l, m, !1); + } + function wu(s, l, m, k, I) { + var z = k; + if ((l & 1) === 0 && (l & 2) === 0 && k !== null) e: for (; ; ) { + if (k === null) return; + var ee = k.tag; + if (ee === 3 || ee === 4) { + var _e = k.stateNode.containerInfo; + if (_e === I || _e.nodeType === 8 && _e.parentNode === I) break; + if (ee === 4) for (ee = k.return; ee !== null; ) { + var Me = ee.tag; + if ((Me === 3 || Me === 4) && (Me = ee.stateNode.containerInfo, Me === I || Me.nodeType === 8 && Me.parentNode === I)) return; + ee = ee.return; + } + for (; _e !== null; ) { + if (ee = _n(_e), ee === null) return; + if (Me = ee.tag, Me === 5 || Me === 6) { + k = z = ee; + continue e; + } + _e = _e.parentNode; + } + } + k = k.return; + } + Jn(function() { + var Ue = z, ct = rn(m), gt = []; + e: { + var st = yc.get(s); + if (st !== void 0) { + var Ft = li, Ot = s; + switch (s) { + case "keypress": + if (Za(m) === 0) break e; + case "keydown": + case "keyup": + Ft = du; + break; + case "focusin": + Ot = "focus", Ft = kl; + break; + case "focusout": + Ot = "blur", Ft = kl; + break; + case "beforeblur": + case "afterblur": + Ft = kl; + break; + case "click": + if (m.button === 2) break e; + case "auxclick": + case "dblclick": + case "mousedown": + case "mousemove": + case "mouseup": + case "mouseout": + case "mouseover": + case "contextmenu": + Ft = Os; + break; + case "drag": + case "dragend": + case "dragenter": + case "dragexit": + case "dragleave": + case "dragover": + case "dragstart": + case "drop": + Ft = lc; + break; + case "touchcancel": + case "touchend": + case "touchmove": + case "touchstart": + Ft = ge; + break; + case Pi: + case Zp: + case gc: + Ft = ds; + break; + case yu: + Ft = Le; + break; + case "scroll": + Ft = sc; + break; + case "wheel": + Ft = pt; + break; + case "copy": + case "cut": + case "paste": + Ft = Cl; + break; + case "gotpointercapture": + case "lostpointercapture": + case "pointercancel": + case "pointerdown": + case "pointermove": + case "pointerout": + case "pointerover": + case "pointerup": + Ft = V; + } + var zt = (l & 4) !== 0, Xr = !zt && s === "scroll", ze = zt ? st !== null ? st + "Capture" : null : st; + zt = []; + for (var Pe = Ue, He; Pe !== null; ) { + He = Pe; + var St = He.stateNode; + if (He.tag === 5 && St !== null && (He = St, ze !== null && (St = Qn(Pe, ze), St != null && zt.push(Gn(Pe, St, He)))), Xr) break; + Pe = Pe.return; + } + 0 < zt.length && (st = new Ft(st, Ot, null, m, ct), gt.push({ event: st, listeners: zt })); + } + } + if ((l & 7) === 0) { + e: { + if (st = s === "mouseover" || s === "pointerover", Ft = s === "mouseout" || s === "pointerout", st && m !== Ye && (Ot = m.relatedTarget || m.fromElement) && (_n(Ot) || Ot[Ga])) break e; + if ((Ft || st) && (st = ct.window === ct ? ct : (st = ct.ownerDocument) ? st.defaultView || st.parentWindow : window, Ft ? (Ot = m.relatedTarget || m.toElement, Ft = Ue, Ot = Ot ? _n(Ot) : null, Ot !== null && (Xr = nr(Ot), Ot !== Xr || Ot.tag !== 5 && Ot.tag !== 6) && (Ot = null)) : (Ft = null, Ot = Ue), Ft !== Ot)) { + if (zt = Os, St = "onMouseLeave", ze = "onMouseEnter", Pe = "mouse", (s === "pointerout" || s === "pointerover") && (zt = V, St = "onPointerLeave", ze = "onPointerEnter", Pe = "pointer"), Xr = Ft == null ? st : Fi(Ft), He = Ot == null ? st : Fi(Ot), st = new zt(St, Pe + "leave", Ft, m, ct), st.target = Xr, st.relatedTarget = He, St = null, _n(ct) === Ue && (zt = new zt(ze, Pe + "enter", Ot, m, ct), zt.target = He, zt.relatedTarget = Xr, St = zt), Xr = St, Ft && Ot) t: { + for (zt = Ft, ze = Ot, Pe = 0, He = zt; He; He = ma(He)) Pe++; + for (He = 0, St = ze; St; St = ma(St)) He++; + for (; 0 < Pe - He; ) zt = ma(zt), Pe--; + for (; 0 < He - Pe; ) ze = ma(ze), He--; + for (; Pe--; ) { + if (zt === ze || ze !== null && zt === ze.alternate) break t; + zt = ma(zt), ze = ma(ze); + } + zt = null; + } + else zt = null; + Ft !== null && hs(gt, st, Ft, zt, !1), Ot !== null && Xr !== null && hs(gt, Xr, Ot, zt, !0); + } + } + e: { + if (st = Ue ? Fi(Ue) : window, Ft = st.nodeName && st.nodeName.toLowerCase(), Ft === "select" || Ft === "input" && st.type === "file") var qt = Kp; + else if (en(st)) if (ef) qt = Bs; + else { + qt = Fg; + var Qt = ps; + } + else (Ft = st.nodeName) && Ft.toLowerCase() === "input" && (st.type === "checkbox" || st.type === "radio") && (qt = tf); + if (qt && (qt = qt(s, Ue))) { + jo(gt, qt, m, ct); + break e; + } + Qt && Qt(s, st, Ue), s === "focusout" && (Qt = st._wrapperState) && Qt.controlled && st.type === "number" && _t(st, "number", st.value); + } + switch (Qt = Ue ? Fi(Ue) : window, s) { + case "focusin": + (en(Qt) || Qt.contentEditable === "true") && (po = Qt, hc = Ue, ho = null); + break; + case "focusout": + ho = hc = po = null; + break; + case "mousedown": + di = !0; + break; + case "contextmenu": + case "mouseup": + case "dragend": + di = !1, Kn(gt, m, ct); + break; + case "selectionchange": + if (gu) break; + case "keydown": + case "keyup": + Kn(gt, m, ct); + } + var Zt; + if (sn) e: { + switch (s) { + case "compositionstart": + var ln = "onCompositionStart"; + break e; + case "compositionend": + ln = "onCompositionEnd"; + break e; + case "compositionupdate": + ln = "onCompositionUpdate"; + break e; + } + ln = void 0; + } + else Ao ? Eo(s, m) && (ln = "onCompositionEnd") : s === "keydown" && m.keyCode === 229 && (ln = "onCompositionStart"); + ln && (gr && m.locale !== "ko" && (Ao || ln !== "onCompositionStart" ? ln === "onCompositionEnd" && Ao && (Zt = $s()) : (Co = ct, si = "value" in Co ? Co.value : Co.textContent, Ao = !0)), Qt = Xo(Ue, ln), 0 < Qt.length && (ln = new Ho(ln, s, null, m, ct), gt.push({ event: ln, listeners: Qt }), Zt ? ln.data = Zt : (Zt = Ml(m), Zt !== null && (ln.data = Zt)))), (Zt = Rn ? Zd(s, m) : Up(s, m)) && (Ue = Xo(Ue, "onBeforeInput"), 0 < Ue.length && (ct = new Ho("onBeforeInput", "beforeinput", null, m, ct), gt.push({ event: ct, listeners: Ue }), ct.data = Zt)); + } + _u(gt, l); + }); + } + function Gn(s, l, m) { + return { instance: s, listener: l, currentTarget: m }; + } + function Xo(s, l) { + for (var m = l + "Capture", k = []; s !== null; ) { + var I = s, z = I.stateNode; + I.tag === 5 && z !== null && (I = z, z = Qn(s, m), z != null && k.unshift(Gn(s, z, I)), z = Qn(s, l), z != null && k.push(Gn(s, z, I))), s = s.return; + } + return k; + } + function ma(s) { + if (s === null) return null; + do + s = s.return; + while (s && s.tag !== 5); + return s || null; + } + function hs(s, l, m, k, I) { + for (var z = l._reactName, ee = []; m !== null && m !== k; ) { + var _e = m, Me = _e.alternate, Ue = _e.stateNode; + if (Me !== null && Me === k) break; + _e.tag === 5 && Ue !== null && (_e = Ue, I ? (Me = Qn(m, z), Me != null && ee.unshift(Gn(m, Me, _e))) : I || (Me = Qn(m, z), Me != null && ee.push(Gn(m, Me, _e)))), m = m.return; + } + ee.length !== 0 && s.push({ event: l, listeners: ee }); + } + var nf = /\r\n?/g, Rg = /\u0000|\uFFFD/g; + function bu(s) { + return (typeof s == "string" ? s : "" + s).replace(nf, ` +`).replace(Rg, ""); + } + function Su(s, l, m) { + if (l = bu(l), bu(s) !== l && m) throw Error(n(425)); + } + function Ti() { + } + var Jo = null, _c = null; + function Ii(s, l) { + return s === "textarea" || s === "noscript" || typeof l.children == "string" || typeof l.children == "number" || typeof l.dangerouslySetInnerHTML == "object" && l.dangerouslySetInnerHTML !== null && l.dangerouslySetInnerHTML.__html != null; + } + var Hs = typeof setTimeout == "function" ? setTimeout : void 0, ku = typeof clearTimeout == "function" ? clearTimeout : void 0, Po = typeof Promise == "function" ? Promise : void 0, ms = typeof queueMicrotask == "function" ? queueMicrotask : typeof Po < "u" ? function(s) { + return Po.resolve(null).then(s).catch(rh); + } : Hs; + function rh(s) { + setTimeout(function() { + throw s; + }); + } + function Qo(s, l) { + var m = l, k = 0; + do { + var I = m.nextSibling; + if (s.removeChild(m), I && I.nodeType === 8) if (m = I.data, m === "/$") { + if (k === 0) { + s.removeChild(I), Xa(l); + return; + } + k--; + } else m !== "$" && m !== "$?" && m !== "$!" || k++; + m = I; + } while (m); + Xa(l); + } + function Zo(s) { + for (; s != null; s = s.nextSibling) { + var l = s.nodeType; + if (l === 1 || l === 3) break; + if (l === 8) { + if (l = s.data, l === "$" || l === "$!" || l === "$?") break; + if (l === "/$") return null; + } + } + return s; + } + function wc(s) { + s = s.previousSibling; + for (var l = 0; s; ) { + if (s.nodeType === 8) { + var m = s.data; + if (m === "$" || m === "$!" || m === "$?") { + if (l === 0) return s; + l--; + } else m === "/$" && l++; + } + s = s.previousSibling; + } + return null; + } + var to = Math.random().toString(36).slice(2), H = "__reactFiber$" + to, It = "__reactProps$" + to, Ga = "__reactContainer$" + to, rf = "__reactEvents$" + to, Og = "__reactListeners$" + to, Tr = "__reactHandles$" + to; + function _n(s) { + var l = s[H]; + if (l) return l; + for (var m = s.parentNode; m; ) { + if (l = m[Ga] || m[H]) { + if (m = l.alternate, l.child !== null || m !== null && m.child !== null) for (s = wc(s); s !== null; ) { + if (m = s[H]) return m; + s = wc(s); + } + return l; + } + s = m, m = s.parentNode; + } + return null; + } + function On(s) { + return s = s[H] || s[Ga], !s || s.tag !== 5 && s.tag !== 6 && s.tag !== 13 && s.tag !== 3 ? null : s; + } + function Fi(s) { + if (s.tag === 5 || s.tag === 6) return s.stateNode; + throw Error(n(33)); + } + function $i(s) { + return s[It] || null; + } + var af = [], To = -1; + function Li(s) { + return { current: s }; + } + function Cn(s) { + 0 > To || (s.current = af[To], af[To] = null, To--); + } + function Zn(s, l) { + To++, af[To] = s.current, s.current = l; + } + var pi = {}, ka = Li(pi), no = Li(!1), Ri = pi; + function Io(s, l) { + var m = s.type.contextTypes; + if (!m) return pi; + var k = s.stateNode; + if (k && k.__reactInternalMemoizedUnmaskedChildContext === l) return k.__reactInternalMemoizedMaskedChildContext; + var I = {}, z; + for (z in m) I[z] = l[z]; + return k && (s = s.stateNode, s.__reactInternalMemoizedUnmaskedChildContext = l, s.__reactInternalMemoizedMaskedChildContext = I), I; + } + function ro(s) { + return s = s.childContextTypes, s != null; + } + function hi() { + Cn(no), Cn(ka); + } + function ah(s, l, m) { + if (ka.current !== pi) throw Error(n(168)); + Zn(ka, l), Zn(no, m); + } + function oh(s, l, m) { + var k = s.stateNode; + if (l = l.childContextTypes, typeof k.getChildContext != "function") return m; + k = k.getChildContext(); + for (var I in k) if (!(I in l)) throw Error(n(108, ye(s) || "Unknown", I)); + return fe({}, m, k); + } + function Cu(s) { + return s = (s = s.stateNode) && s.__reactInternalMemoizedMergedChildContext || pi, Ri = ka.current, Zn(ka, s), Zn(no, no.current), !0; + } + function ih(s, l, m) { + var k = s.stateNode; + if (!k) throw Error(n(169)); + m ? (s = oh(s, l, Ri), k.__reactInternalMemoizedMergedChildContext = s, Cn(no), Cn(ka), Zn(ka, s)) : Cn(no), Zn(no, m); + } + var Ba = null, Us = !1, jl = !1; + function Mu(s) { + Ba === null ? Ba = [s] : Ba.push(s); + } + function sh(s) { + Us = !0, Mu(s); + } + function gs() { + if (!jl && Ba !== null) { + jl = !0; + var s = 0, l = xt; + try { + var m = Ba; + for (xt = 1; s < m.length; s++) { + var k = m[s]; + do + k = k(!0); + while (k !== null); + } + Ba = null, Us = !1; + } catch (I) { + throw Ba !== null && (Ba = Ba.slice(s + 1)), $a(co, gs), I; + } finally { + xt = l, jl = !1; + } + } + return null; + } + var Fo = [], Ca = 0, Nu = null, bc = 0, mo = [], go = 0, ys = null, Tt = 1, Oi = ""; + function Di(s, l) { + Fo[Ca++] = bc, Fo[Ca++] = Nu, Nu = s, bc = l; + } + function Sc(s, l, m) { + mo[go++] = Tt, mo[go++] = Oi, mo[go++] = ys, ys = s; + var k = Tt; + s = Oi; + var I = 32 - gn(k) - 1; + k &= ~(1 << I), m += 1; + var z = 32 - gn(l) + I; + if (30 < z) { + var ee = I - I % 5; + z = (k & (1 << ee) - 1).toString(32), k >>= ee, I -= ee, Tt = 1 << 32 - gn(l) + I | m << I | k, Oi = z + s; + } else Tt = 1 << z | m << I | k, Oi = s; + } + function kc(s) { + s.return !== null && (Di(s, 1), Sc(s, 1, 0)); + } + function Eu(s) { + for (; s === Nu; ) Nu = Fo[--Ca], Fo[Ca] = null, bc = Fo[--Ca], Fo[Ca] = null; + for (; s === ys; ) ys = mo[--go], mo[go] = null, Oi = mo[--go], mo[go] = null, Tt = mo[--go], mo[go] = null; + } + var En = null, er = null, fr = !1, ei = null; + function of(s, l) { + var m = io(5, null, null, 0); + m.elementType = "DELETED", m.stateNode = l, m.return = s, l = s.deletions, l === null ? (s.deletions = [m], s.flags |= 16) : l.push(m); + } + function lh(s, l) { + switch (s.tag) { + case 5: + var m = s.type; + return l = l.nodeType !== 1 || m.toLowerCase() !== l.nodeName.toLowerCase() ? null : l, l !== null ? (s.stateNode = l, En = s, er = Zo(l.firstChild), !0) : !1; + case 6: + return l = s.pendingProps === "" || l.nodeType !== 3 ? null : l, l !== null ? (s.stateNode = l, En = s, er = null, !0) : !1; + case 13: + return l = l.nodeType !== 8 ? null : l, l !== null ? (m = ys !== null ? { id: Tt, overflow: Oi } : null, s.memoizedState = { dehydrated: l, treeContext: m, retryLane: 1073741824 }, m = io(18, null, null, 0), m.stateNode = l, m.return = s, s.child = m, En = s, er = null, !0) : !1; + default: + return !1; + } + } + function Au(s) { + return (s.mode & 1) !== 0 && (s.flags & 128) === 0; + } + function Vs(s) { + if (fr) { + var l = er; + if (l) { + var m = l; + if (!lh(s, l)) { + if (Au(s)) throw Error(n(418)); + l = Zo(m.nextSibling); + var k = En; + l && lh(s, l) ? of(k, m) : (s.flags = s.flags & -4097 | 2, fr = !1, En = s); + } + } else { + if (Au(s)) throw Error(n(418)); + s.flags = s.flags & -4097 | 2, fr = !1, En = s; + } + } + } + function ch(s) { + for (s = s.return; s !== null && s.tag !== 5 && s.tag !== 3 && s.tag !== 13; ) s = s.return; + En = s; + } + function ju(s) { + if (s !== En) return !1; + if (!fr) return ch(s), fr = !0, !1; + var l; + if ((l = s.tag !== 3) && !(l = s.tag !== 5) && (l = s.type, l = l !== "head" && l !== "body" && !Ii(s.type, s.memoizedProps)), l && (l = er)) { + if (Au(s)) throw sf(), Error(n(418)); + for (; l; ) of(s, l), l = Zo(l.nextSibling); + } + if (ch(s), s.tag === 13) { + if (s = s.memoizedState, s = s !== null ? s.dehydrated : null, !s) throw Error(n(317)); + e: { + for (s = s.nextSibling, l = 0; s; ) { + if (s.nodeType === 8) { + var m = s.data; + if (m === "/$") { + if (l === 0) { + er = Zo(s.nextSibling); + break e; + } + l--; + } else m !== "$" && m !== "$!" && m !== "$?" || l++; + } + s = s.nextSibling; + } + er = null; + } + } else er = En ? Zo(s.stateNode.nextSibling) : null; + return !0; + } + function sf() { + for (var s = er; s; ) s = Zo(s.nextSibling); + } + function vs() { + er = En = null, fr = !1; + } + function lf(s) { + ei === null ? ei = [s] : ei.push(s); + } + var uh = N.ReactCurrentBatchConfig; + function Cc(s, l, m) { + if (s = m.ref, s !== null && typeof s != "function" && typeof s != "object") { + if (m._owner) { + if (m = m._owner, m) { + if (m.tag !== 1) throw Error(n(309)); + var k = m.stateNode; + } + if (!k) throw Error(n(147, s)); + var I = k, z = "" + s; + return l !== null && l.ref !== null && typeof l.ref == "function" && l.ref._stringRef === z ? l.ref : (l = function(ee) { + var _e = I.refs; + ee === null ? delete _e[z] : _e[z] = ee; + }, l._stringRef = z, l); + } + if (typeof s != "string") throw Error(n(284)); + if (!m._owner) throw Error(n(290, s)); + } + return s; + } + function Pu(s, l) { + throw s = Object.prototype.toString.call(l), Error(n(31, s === "[object Object]" ? "object with keys {" + Object.keys(l).join(", ") + "}" : s)); + } + function dh(s) { + var l = s._init; + return l(s._payload); + } + function fh(s) { + function l(ze, Pe) { + if (s) { + var He = ze.deletions; + He === null ? (ze.deletions = [Pe], ze.flags |= 16) : He.push(Pe); + } + } + function m(ze, Pe) { + if (!s) return null; + for (; Pe !== null; ) l(ze, Pe), Pe = Pe.sibling; + return null; + } + function k(ze, Pe) { + for (ze = /* @__PURE__ */ new Map(); Pe !== null; ) Pe.key !== null ? ze.set(Pe.key, Pe) : ze.set(Pe.index, Pe), Pe = Pe.sibling; + return ze; + } + function I(ze, Pe) { + return ze = Ms(ze, Pe), ze.index = 0, ze.sibling = null, ze; + } + function z(ze, Pe, He) { + return ze.index = He, s ? (He = ze.alternate, He !== null ? (He = He.index, He < Pe ? (ze.flags |= 2, Pe) : He) : (ze.flags |= 2, Pe)) : (ze.flags |= 1048576, Pe); + } + function ee(ze) { + return s && ze.alternate === null && (ze.flags |= 2), ze; + } + function _e(ze, Pe, He, St) { + return Pe === null || Pe.tag !== 6 ? (Pe = zn(He, ze.mode, St), Pe.return = ze, Pe) : (Pe = I(Pe, He), Pe.return = ze, Pe); + } + function Me(ze, Pe, He, St) { + var qt = He.type; + return qt === P ? ct(ze, Pe, He.props.children, St, He.key) : Pe !== null && (Pe.elementType === qt || typeof qt == "object" && qt !== null && qt.$$typeof === Z && dh(qt) === Pe.type) ? (St = I(Pe, He.props), St.ref = Cc(ze, Pe, He), St.return = ze, St) : (St = Wc(He.type, He.key, He.props, null, ze.mode, St), St.ref = Cc(ze, Pe, He), St.return = ze, St); + } + function Ue(ze, Pe, He, St) { + return Pe === null || Pe.tag !== 4 || Pe.stateNode.containerInfo !== He.containerInfo || Pe.stateNode.implementation !== He.implementation ? (Pe = Nr(He, ze.mode, St), Pe.return = ze, Pe) : (Pe = I(Pe, He.children || []), Pe.return = ze, Pe); + } + function ct(ze, Pe, He, St, qt) { + return Pe === null || Pe.tag !== 7 ? (Pe = Ht(He, ze.mode, St, qt), Pe.return = ze, Pe) : (Pe = I(Pe, He), Pe.return = ze, Pe); + } + function gt(ze, Pe, He) { + if (typeof Pe == "string" && Pe !== "" || typeof Pe == "number") return Pe = zn("" + Pe, ze.mode, He), Pe.return = ze, Pe; + if (typeof Pe == "object" && Pe !== null) { + switch (Pe.$$typeof) { + case E: + return He = Wc(Pe.type, Pe.key, Pe.props, null, ze.mode, He), He.ref = Cc(ze, null, Pe), He.return = ze, He; + case R: + return Pe = Nr(Pe, ze.mode, He), Pe.return = ze, Pe; + case Z: + var St = Pe._init; + return gt(ze, St(Pe._payload), He); + } + if (vt(Pe) || ce(Pe)) return Pe = Ht(Pe, ze.mode, He, null), Pe.return = ze, Pe; + Pu(ze, Pe); + } + return null; + } + function st(ze, Pe, He, St) { + var qt = Pe !== null ? Pe.key : null; + if (typeof He == "string" && He !== "" || typeof He == "number") return qt !== null ? null : _e(ze, Pe, "" + He, St); + if (typeof He == "object" && He !== null) { + switch (He.$$typeof) { + case E: + return He.key === qt ? Me(ze, Pe, He, St) : null; + case R: + return He.key === qt ? Ue(ze, Pe, He, St) : null; + case Z: + return qt = He._init, st( + ze, + Pe, + qt(He._payload), + St + ); + } + if (vt(He) || ce(He)) return qt !== null ? null : ct(ze, Pe, He, St, null); + Pu(ze, He); + } + return null; + } + function Ft(ze, Pe, He, St, qt) { + if (typeof St == "string" && St !== "" || typeof St == "number") return ze = ze.get(He) || null, _e(Pe, ze, "" + St, qt); + if (typeof St == "object" && St !== null) { + switch (St.$$typeof) { + case E: + return ze = ze.get(St.key === null ? He : St.key) || null, Me(Pe, ze, St, qt); + case R: + return ze = ze.get(St.key === null ? He : St.key) || null, Ue(Pe, ze, St, qt); + case Z: + var Qt = St._init; + return Ft(ze, Pe, He, Qt(St._payload), qt); + } + if (vt(St) || ce(St)) return ze = ze.get(He) || null, ct(Pe, ze, St, qt, null); + Pu(Pe, St); + } + return null; + } + function Ot(ze, Pe, He, St) { + for (var qt = null, Qt = null, Zt = Pe, ln = Pe = 0, ja = null; Zt !== null && ln < He.length; ln++) { + Zt.index > ln ? (ja = Zt, Zt = null) : ja = Zt.sibling; + var Wn = st(ze, Zt, He[ln], St); + if (Wn === null) { + Zt === null && (Zt = ja); + break; + } + s && Zt && Wn.alternate === null && l(ze, Zt), Pe = z(Wn, Pe, ln), Qt === null ? qt = Wn : Qt.sibling = Wn, Qt = Wn, Zt = ja; + } + if (ln === He.length) return m(ze, Zt), fr && Di(ze, ln), qt; + if (Zt === null) { + for (; ln < He.length; ln++) Zt = gt(ze, He[ln], St), Zt !== null && (Pe = z(Zt, Pe, ln), Qt === null ? qt = Zt : Qt.sibling = Zt, Qt = Zt); + return fr && Di(ze, ln), qt; + } + for (Zt = k(ze, Zt); ln < He.length; ln++) ja = Ft(Zt, ze, ln, He[ln], St), ja !== null && (s && ja.alternate !== null && Zt.delete(ja.key === null ? ln : ja.key), Pe = z(ja, Pe, ln), Qt === null ? qt = ja : Qt.sibling = ja, Qt = ja); + return s && Zt.forEach(function(Dl) { + return l(ze, Dl); + }), fr && Di(ze, ln), qt; + } + function zt(ze, Pe, He, St) { + var qt = ce(He); + if (typeof qt != "function") throw Error(n(150)); + if (He = qt.call(He), He == null) throw Error(n(151)); + for (var Qt = qt = null, Zt = Pe, ln = Pe = 0, ja = null, Wn = He.next(); Zt !== null && !Wn.done; ln++, Wn = He.next()) { + Zt.index > ln ? (ja = Zt, Zt = null) : ja = Zt.sibling; + var Dl = st(ze, Zt, Wn.value, St); + if (Dl === null) { + Zt === null && (Zt = ja); + break; + } + s && Zt && Dl.alternate === null && l(ze, Zt), Pe = z(Dl, Pe, ln), Qt === null ? qt = Dl : Qt.sibling = Dl, Qt = Dl, Zt = ja; + } + if (Wn.done) return m( + ze, + Zt + ), fr && Di(ze, ln), qt; + if (Zt === null) { + for (; !Wn.done; ln++, Wn = He.next()) Wn = gt(ze, Wn.value, St), Wn !== null && (Pe = z(Wn, Pe, ln), Qt === null ? qt = Wn : Qt.sibling = Wn, Qt = Wn); + return fr && Di(ze, ln), qt; + } + for (Zt = k(ze, Zt); !Wn.done; ln++, Wn = He.next()) Wn = Ft(Zt, ze, ln, Wn.value, St), Wn !== null && (s && Wn.alternate !== null && Zt.delete(Wn.key === null ? ln : Wn.key), Pe = z(Wn, Pe, ln), Qt === null ? qt = Wn : Qt.sibling = Wn, Qt = Wn); + return s && Zt.forEach(function($k) { + return l(ze, $k); + }), fr && Di(ze, ln), qt; + } + function Xr(ze, Pe, He, St) { + if (typeof He == "object" && He !== null && He.type === P && He.key === null && (He = He.props.children), typeof He == "object" && He !== null) { + switch (He.$$typeof) { + case E: + e: { + for (var qt = He.key, Qt = Pe; Qt !== null; ) { + if (Qt.key === qt) { + if (qt = He.type, qt === P) { + if (Qt.tag === 7) { + m(ze, Qt.sibling), Pe = I(Qt, He.props.children), Pe.return = ze, ze = Pe; + break e; + } + } else if (Qt.elementType === qt || typeof qt == "object" && qt !== null && qt.$$typeof === Z && dh(qt) === Qt.type) { + m(ze, Qt.sibling), Pe = I(Qt, He.props), Pe.ref = Cc(ze, Qt, He), Pe.return = ze, ze = Pe; + break e; + } + m(ze, Qt); + break; + } else l(ze, Qt); + Qt = Qt.sibling; + } + He.type === P ? (Pe = Ht(He.props.children, ze.mode, St, He.key), Pe.return = ze, ze = Pe) : (St = Wc(He.type, He.key, He.props, null, ze.mode, St), St.ref = Cc(ze, Pe, He), St.return = ze, ze = St); + } + return ee(ze); + case R: + e: { + for (Qt = He.key; Pe !== null; ) { + if (Pe.key === Qt) if (Pe.tag === 4 && Pe.stateNode.containerInfo === He.containerInfo && Pe.stateNode.implementation === He.implementation) { + m(ze, Pe.sibling), Pe = I(Pe, He.children || []), Pe.return = ze, ze = Pe; + break e; + } else { + m(ze, Pe); + break; + } + else l(ze, Pe); + Pe = Pe.sibling; + } + Pe = Nr(He, ze.mode, St), Pe.return = ze, ze = Pe; + } + return ee(ze); + case Z: + return Qt = He._init, Xr(ze, Pe, Qt(He._payload), St); + } + if (vt(He)) return Ot(ze, Pe, He, St); + if (ce(He)) return zt(ze, Pe, He, St); + Pu(ze, He); + } + return typeof He == "string" && He !== "" || typeof He == "number" ? (He = "" + He, Pe !== null && Pe.tag === 6 ? (m(ze, Pe.sibling), Pe = I(Pe, He), Pe.return = ze, ze = Pe) : (m(ze, Pe), Pe = zn(He, ze.mode, St), Pe.return = ze, ze = Pe), ee(ze)) : m(ze, Pe); + } + return Xr; + } + var Pl = fh(!0), ph = fh(!1), xs = Li(null), Tu = null, Tl = null, cf = null; + function uf() { + cf = Tl = Tu = null; + } + function df(s) { + var l = xs.current; + Cn(xs), s._currentValue = l; + } + function ff(s, l, m) { + for (; s !== null; ) { + var k = s.alternate; + if ((s.childLanes & l) !== l ? (s.childLanes |= l, k !== null && (k.childLanes |= l)) : k !== null && (k.childLanes & l) !== l && (k.childLanes |= l), s === m) break; + s = s.return; + } + } + function Ks(s, l) { + Tu = s, cf = Tl = null, s = s.dependencies, s !== null && s.firstContext !== null && ((s.lanes & l) !== 0 && (ya = !0), s.firstContext = null); + } + function Ir(s) { + var l = s._currentValue; + if (cf !== s) if (s = { context: s, memoizedValue: l, next: null }, Tl === null) { + if (Tu === null) throw Error(n(308)); + Tl = s, Tu.dependencies = { lanes: 0, firstContext: s }; + } else Tl = Tl.next = s; + return l; + } + var Ys = null; + function _s(s) { + Ys === null ? Ys = [s] : Ys.push(s); + } + function hh(s, l, m, k) { + var I = l.interleaved; + return I === null ? (m.next = m, _s(l)) : (m.next = I.next, I.next = m), l.interleaved = m, zi(s, k); + } + function zi(s, l) { + s.lanes |= l; + var m = s.alternate; + for (m !== null && (m.lanes |= l), m = s, s = s.return; s !== null; ) s.childLanes |= l, m = s.alternate, m !== null && (m.childLanes |= l), m = s, s = s.return; + return m.tag === 3 ? m.stateNode : null; + } + var ws = !1; + function pf(s) { + s.updateQueue = { baseState: s.memoizedState, firstBaseUpdate: null, lastBaseUpdate: null, shared: { pending: null, interleaved: null, lanes: 0 }, effects: null }; + } + function mh(s, l) { + s = s.updateQueue, l.updateQueue === s && (l.updateQueue = { baseState: s.baseState, firstBaseUpdate: s.firstBaseUpdate, lastBaseUpdate: s.lastBaseUpdate, shared: s.shared, effects: s.effects }); + } + function $o(s, l) { + return { eventTime: s, lane: l, tag: 0, payload: null, callback: null, next: null }; + } + function Gi(s, l, m) { + var k = s.updateQueue; + if (k === null) return null; + if (k = k.shared, (jn & 2) !== 0) { + var I = k.pending; + return I === null ? l.next = l : (l.next = I.next, I.next = l), k.pending = l, zi(s, m); + } + return I = k.interleaved, I === null ? (l.next = l, _s(k)) : (l.next = I.next, I.next = l), k.interleaved = l, zi(s, m); + } + function Iu(s, l, m) { + if (l = l.updateQueue, l !== null && (l = l.shared, (m & 4194240) !== 0)) { + var k = l.lanes; + k &= s.pendingLanes, m |= k, l.lanes = m, ft(s, m); + } + } + function gh(s, l) { + var m = s.updateQueue, k = s.alternate; + if (k !== null && (k = k.updateQueue, m === k)) { + var I = null, z = null; + if (m = m.firstBaseUpdate, m !== null) { + do { + var ee = { eventTime: m.eventTime, lane: m.lane, tag: m.tag, payload: m.payload, callback: m.callback, next: null }; + z === null ? I = z = ee : z = z.next = ee, m = m.next; + } while (m !== null); + z === null ? I = z = l : z = z.next = l; + } else I = z = l; + m = { baseState: k.baseState, firstBaseUpdate: I, lastBaseUpdate: z, shared: k.shared, effects: k.effects }, s.updateQueue = m; + return; + } + s = m.lastBaseUpdate, s === null ? m.firstBaseUpdate = l : s.next = l, m.lastBaseUpdate = l; + } + function Mc(s, l, m, k) { + var I = s.updateQueue; + ws = !1; + var z = I.firstBaseUpdate, ee = I.lastBaseUpdate, _e = I.shared.pending; + if (_e !== null) { + I.shared.pending = null; + var Me = _e, Ue = Me.next; + Me.next = null, ee === null ? z = Ue : ee.next = Ue, ee = Me; + var ct = s.alternate; + ct !== null && (ct = ct.updateQueue, _e = ct.lastBaseUpdate, _e !== ee && (_e === null ? ct.firstBaseUpdate = Ue : _e.next = Ue, ct.lastBaseUpdate = Me)); + } + if (z !== null) { + var gt = I.baseState; + ee = 0, ct = Ue = Me = null, _e = z; + do { + var st = _e.lane, Ft = _e.eventTime; + if ((k & st) === st) { + ct !== null && (ct = ct.next = { + eventTime: Ft, + lane: 0, + tag: _e.tag, + payload: _e.payload, + callback: _e.callback, + next: null + }); + e: { + var Ot = s, zt = _e; + switch (st = l, Ft = m, zt.tag) { + case 1: + if (Ot = zt.payload, typeof Ot == "function") { + gt = Ot.call(Ft, gt, st); + break e; + } + gt = Ot; + break e; + case 3: + Ot.flags = Ot.flags & -65537 | 128; + case 0: + if (Ot = zt.payload, st = typeof Ot == "function" ? Ot.call(Ft, gt, st) : Ot, st == null) break e; + gt = fe({}, gt, st); + break e; + case 2: + ws = !0; + } + } + _e.callback !== null && _e.lane !== 0 && (s.flags |= 64, st = I.effects, st === null ? I.effects = [_e] : st.push(_e)); + } else Ft = { eventTime: Ft, lane: st, tag: _e.tag, payload: _e.payload, callback: _e.callback, next: null }, ct === null ? (Ue = ct = Ft, Me = gt) : ct = ct.next = Ft, ee |= st; + if (_e = _e.next, _e === null) { + if (_e = I.shared.pending, _e === null) break; + st = _e, _e = st.next, st.next = null, I.lastBaseUpdate = st, I.shared.pending = null; + } + } while (!0); + if (ct === null && (Me = gt), I.baseState = Me, I.firstBaseUpdate = Ue, I.lastBaseUpdate = ct, l = I.shared.interleaved, l !== null) { + I = l; + do + ee |= I.lane, I = I.next; + while (I !== l); + } else z === null && (I.shared.lanes = 0); + Cs |= ee, s.lanes = ee, s.memoizedState = gt; + } + } + function Fu(s, l, m) { + if (s = l.effects, l.effects = null, s !== null) for (l = 0; l < s.length; l++) { + var k = s[l], I = k.callback; + if (I !== null) { + if (k.callback = null, k = m, typeof I != "function") throw Error(n(191, I)); + I.call(k); + } + } + } + var Xs = {}, mi = Li(Xs), Il = Li(Xs), Js = Li(Xs); + function Qs(s) { + if (s === Xs) throw Error(n(174)); + return s; + } + function hf(s, l) { + switch (Zn(Js, l), Zn(Il, s), Zn(mi, Xs), s = l.nodeType, s) { + case 9: + case 11: + l = (l = l.documentElement) ? l.namespaceURI : Nt(null, ""); + break; + default: + s = s === 8 ? l.parentNode : l, l = s.namespaceURI || null, s = s.tagName, l = Nt(l, s); + } + Cn(mi), Zn(mi, l); + } + function Fl() { + Cn(mi), Cn(Il), Cn(Js); + } + function Nc(s) { + Qs(Js.current); + var l = Qs(mi.current), m = Nt(l, s.type); + l !== m && (Zn(Il, s), Zn(mi, m)); + } + function $l(s) { + Il.current === s && (Cn(mi), Cn(Il)); + } + var pr = Li(0); + function $u(s) { + for (var l = s; l !== null; ) { + if (l.tag === 13) { + var m = l.memoizedState; + if (m !== null && (m = m.dehydrated, m === null || m.data === "$?" || m.data === "$!")) return l; + } else if (l.tag === 19 && l.memoizedProps.revealOrder !== void 0) { + if ((l.flags & 128) !== 0) return l; + } else if (l.child !== null) { + l.child.return = l, l = l.child; + continue; + } + if (l === s) break; + for (; l.sibling === null; ) { + if (l.return === null || l.return === s) return null; + l = l.return; + } + l.sibling.return = l.return, l = l.sibling; + } + return null; + } + var Lu = []; + function mf() { + for (var s = 0; s < Lu.length; s++) Lu[s]._workInProgressVersionPrimary = null; + Lu.length = 0; + } + var Ru = N.ReactCurrentDispatcher, gf = N.ReactCurrentBatchConfig, Zs = 0, vr = null, Dr = null, ia = null, Ec = !1, Ac = !1, jc = 0, Dg = 0; + function Ma() { + throw Error(n(321)); + } + function yf(s, l) { + if (l === null) return !1; + for (var m = 0; m < l.length && m < s.length; m++) if (!Vo(s[m], l[m])) return !1; + return !0; + } + function vf(s, l, m, k, I, z) { + if (Zs = z, vr = l, l.memoizedState = null, l.updateQueue = null, l.lanes = 0, Ru.current = s === null || s.memoizedState === null ? jh : Ph, s = m(k, I), Ac) { + z = 0; + do { + if (Ac = !1, jc = 0, 25 <= z) throw Error(n(301)); + z += 1, ia = Dr = null, l.updateQueue = null, Ru.current = Bg, s = m(k, I); + } while (Ac); + } + if (Ru.current = Pc, l = Dr !== null && Dr.next !== null, Zs = 0, ia = Dr = vr = null, Ec = !1, l) throw Error(n(300)); + return s; + } + function xf() { + var s = jc !== 0; + return jc = 0, s; + } + function ga() { + var s = { memoizedState: null, baseState: null, baseQueue: null, queue: null, next: null }; + return ia === null ? vr.memoizedState = ia = s : ia = ia.next = s, ia; + } + function sa() { + if (Dr === null) { + var s = vr.alternate; + s = s !== null ? s.memoizedState : null; + } else s = Dr.next; + var l = ia === null ? vr.memoizedState : ia.next; + if (l !== null) ia = l, Dr = s; + else { + if (s === null) throw Error(n(310)); + Dr = s, s = { memoizedState: Dr.memoizedState, baseState: Dr.baseState, baseQueue: Dr.baseQueue, queue: Dr.queue, next: null }, ia === null ? vr.memoizedState = ia = s : ia = ia.next = s; + } + return ia; + } + function Ll(s, l) { + return typeof l == "function" ? l(s) : l; + } + function el(s) { + var l = sa(), m = l.queue; + if (m === null) throw Error(n(311)); + m.lastRenderedReducer = s; + var k = Dr, I = k.baseQueue, z = m.pending; + if (z !== null) { + if (I !== null) { + var ee = I.next; + I.next = z.next, z.next = ee; + } + k.baseQueue = I = z, m.pending = null; + } + if (I !== null) { + z = I.next, k = k.baseState; + var _e = ee = null, Me = null, Ue = z; + do { + var ct = Ue.lane; + if ((Zs & ct) === ct) Me !== null && (Me = Me.next = { lane: 0, action: Ue.action, hasEagerState: Ue.hasEagerState, eagerState: Ue.eagerState, next: null }), k = Ue.hasEagerState ? Ue.eagerState : s(k, Ue.action); + else { + var gt = { + lane: ct, + action: Ue.action, + hasEagerState: Ue.hasEagerState, + eagerState: Ue.eagerState, + next: null + }; + Me === null ? (_e = Me = gt, ee = k) : Me = Me.next = gt, vr.lanes |= ct, Cs |= ct; + } + Ue = Ue.next; + } while (Ue !== null && Ue !== z); + Me === null ? ee = k : Me.next = _e, Vo(k, l.memoizedState) || (ya = !0), l.memoizedState = k, l.baseState = ee, l.baseQueue = Me, m.lastRenderedState = k; + } + if (s = m.interleaved, s !== null) { + I = s; + do + z = I.lane, vr.lanes |= z, Cs |= z, I = I.next; + while (I !== s); + } else I === null && (m.lanes = 0); + return [l.memoizedState, m.dispatch]; + } + function _f(s) { + var l = sa(), m = l.queue; + if (m === null) throw Error(n(311)); + m.lastRenderedReducer = s; + var k = m.dispatch, I = m.pending, z = l.memoizedState; + if (I !== null) { + m.pending = null; + var ee = I = I.next; + do + z = s(z, ee.action), ee = ee.next; + while (ee !== I); + Vo(z, l.memoizedState) || (ya = !0), l.memoizedState = z, l.baseQueue === null && (l.baseState = z), m.lastRenderedState = z; + } + return [z, k]; + } + function wf() { + } + function bf(s, l) { + var m = vr, k = sa(), I = l(), z = !Vo(k.memoizedState, I); + if (z && (k.memoizedState = I, ya = !0), k = k.queue, Cf(yh.bind(null, m, k, s), [s]), k.getSnapshot !== l || z || ia !== null && ia.memoizedState.tag & 1) { + if (m.flags |= 2048, Bi(9, Rl.bind(null, m, k, I, l), void 0, null), or === null) throw Error(n(349)); + (Zs & 30) !== 0 || Ou(m, l, I); + } + return I; + } + function Ou(s, l, m) { + s.flags |= 16384, s = { getSnapshot: l, value: m }, l = vr.updateQueue, l === null ? (l = { lastEffect: null, stores: null }, vr.updateQueue = l, l.stores = [s]) : (m = l.stores, m === null ? l.stores = [s] : m.push(s)); + } + function Rl(s, l, m, k) { + l.value = m, l.getSnapshot = k, Sf(l) && Du(s); + } + function yh(s, l, m) { + return m(function() { + Sf(l) && Du(s); + }); + } + function Sf(s) { + var l = s.getSnapshot; + s = s.value; + try { + var m = l(); + return !Vo(s, m); + } catch { + return !0; + } + } + function Du(s) { + var l = zi(s, 1); + l !== null && ie(l, s, 1, -1); + } + function zu(s) { + var l = ga(); + return typeof s == "function" && (s = s()), l.memoizedState = l.baseState = s, s = { pending: null, interleaved: null, lanes: 0, dispatch: null, lastRenderedReducer: Ll, lastRenderedState: s }, l.queue = s, s = s.dispatch = Nh.bind(null, vr, s), [l.memoizedState, s]; + } + function Bi(s, l, m, k) { + return s = { tag: s, create: l, destroy: m, deps: k, next: null }, l = vr.updateQueue, l === null ? (l = { lastEffect: null, stores: null }, vr.updateQueue = l, l.lastEffect = s.next = s) : (m = l.lastEffect, m === null ? l.lastEffect = s.next = s : (k = m.next, m.next = s, s.next = k, l.lastEffect = s)), s; + } + function vh() { + return sa().memoizedState; + } + function qa(s, l, m, k) { + var I = ga(); + vr.flags |= s, I.memoizedState = Bi(1 | l, m, void 0, k === void 0 ? null : k); + } + function Gu(s, l, m, k) { + var I = sa(); + k = k === void 0 ? null : k; + var z = void 0; + if (Dr !== null) { + var ee = Dr.memoizedState; + if (z = ee.destroy, k !== null && yf(k, ee.deps)) { + I.memoizedState = Bi(l, m, z, k); + return; + } + } + vr.flags |= s, I.memoizedState = Bi(1 | l, m, z, k); + } + function kf(s, l) { + return qa(8390656, 8, s, l); + } + function Cf(s, l) { + return Gu(2048, 8, s, l); + } + function xh(s, l) { + return Gu(4, 2, s, l); + } + function _h(s, l) { + return Gu(4, 4, s, l); + } + function wh(s, l) { + if (typeof l == "function") return s = s(), l(s), function() { + l(null); + }; + if (l != null) return s = s(), l.current = s, function() { + l.current = null; + }; + } + function bh(s, l, m) { + return m = m != null ? m.concat([s]) : null, Gu(4, 4, wh.bind(null, l, s), m); + } + function Mf() { + } + function Sh(s, l) { + var m = sa(); + l = l === void 0 ? null : l; + var k = m.memoizedState; + return k !== null && l !== null && yf(l, k[1]) ? k[0] : (m.memoizedState = [s, l], s); + } + function kh(s, l) { + var m = sa(); + l = l === void 0 ? null : l; + var k = m.memoizedState; + return k !== null && l !== null && yf(l, k[1]) ? k[0] : (s = s(), m.memoizedState = [s, l], s); + } + function Ch(s, l, m) { + return (Zs & 21) === 0 ? (s.baseState && (s.baseState = !1, ya = !0), s.memoizedState = m) : (Vo(m, l) || (m = ne(), vr.lanes |= m, Cs |= m, s.baseState = !0), l); + } + function zg(s, l) { + var m = xt; + xt = m !== 0 && 4 > m ? m : 4, s(!0); + var k = gf.transition; + gf.transition = {}; + try { + s(!1), l(); + } finally { + xt = m, gf.transition = k; + } + } + function Mh() { + return sa().memoizedState; + } + function Gg(s, l, m) { + var k = oe(s); + if (m = { lane: k, action: m, hasEagerState: !1, eagerState: null, next: null }, Eh(s)) Ah(l, m); + else if (m = hh(s, l, m, k), m !== null) { + var I = U(); + ie(m, s, k, I), tl(m, l, k); + } + } + function Nh(s, l, m) { + var k = oe(s), I = { lane: k, action: m, hasEagerState: !1, eagerState: null, next: null }; + if (Eh(s)) Ah(l, I); + else { + var z = s.alternate; + if (s.lanes === 0 && (z === null || z.lanes === 0) && (z = l.lastRenderedReducer, z !== null)) try { + var ee = l.lastRenderedState, _e = z(ee, m); + if (I.hasEagerState = !0, I.eagerState = _e, Vo(_e, ee)) { + var Me = l.interleaved; + Me === null ? (I.next = I, _s(l)) : (I.next = Me.next, Me.next = I), l.interleaved = I; + return; + } + } catch { + } finally { + } + m = hh(s, l, I, k), m !== null && (I = U(), ie(m, s, k, I), tl(m, l, k)); + } + } + function Eh(s) { + var l = s.alternate; + return s === vr || l !== null && l === vr; + } + function Ah(s, l) { + Ac = Ec = !0; + var m = s.pending; + m === null ? l.next = l : (l.next = m.next, m.next = l), s.pending = l; + } + function tl(s, l, m) { + if ((m & 4194240) !== 0) { + var k = l.lanes; + k &= s.pendingLanes, m |= k, l.lanes = m, ft(s, m); + } + } + var Pc = { readContext: Ir, useCallback: Ma, useContext: Ma, useEffect: Ma, useImperativeHandle: Ma, useInsertionEffect: Ma, useLayoutEffect: Ma, useMemo: Ma, useReducer: Ma, useRef: Ma, useState: Ma, useDebugValue: Ma, useDeferredValue: Ma, useTransition: Ma, useMutableSource: Ma, useSyncExternalStore: Ma, useId: Ma, unstable_isNewReconciler: !1 }, jh = { readContext: Ir, useCallback: function(s, l) { + return ga().memoizedState = [s, l === void 0 ? null : l], s; + }, useContext: Ir, useEffect: kf, useImperativeHandle: function(s, l, m) { + return m = m != null ? m.concat([s]) : null, qa( + 4194308, + 4, + wh.bind(null, l, s), + m + ); + }, useLayoutEffect: function(s, l) { + return qa(4194308, 4, s, l); + }, useInsertionEffect: function(s, l) { + return qa(4, 2, s, l); + }, useMemo: function(s, l) { + var m = ga(); + return l = l === void 0 ? null : l, s = s(), m.memoizedState = [s, l], s; + }, useReducer: function(s, l, m) { + var k = ga(); + return l = m !== void 0 ? m(l) : l, k.memoizedState = k.baseState = l, s = { pending: null, interleaved: null, lanes: 0, dispatch: null, lastRenderedReducer: s, lastRenderedState: l }, k.queue = s, s = s.dispatch = Gg.bind(null, vr, s), [k.memoizedState, s]; + }, useRef: function(s) { + var l = ga(); + return s = { current: s }, l.memoizedState = s; + }, useState: zu, useDebugValue: Mf, useDeferredValue: function(s) { + return ga().memoizedState = s; + }, useTransition: function() { + var s = zu(!1), l = s[0]; + return s = zg.bind(null, s[1]), ga().memoizedState = s, [l, s]; + }, useMutableSource: function() { + }, useSyncExternalStore: function(s, l, m) { + var k = vr, I = ga(); + if (fr) { + if (m === void 0) throw Error(n(407)); + m = m(); + } else { + if (m = l(), or === null) throw Error(n(349)); + (Zs & 30) !== 0 || Ou(k, l, m); + } + I.memoizedState = m; + var z = { value: m, getSnapshot: l }; + return I.queue = z, kf(yh.bind( + null, + k, + z, + s + ), [s]), k.flags |= 2048, Bi(9, Rl.bind(null, k, z, m, l), void 0, null), m; + }, useId: function() { + var s = ga(), l = or.identifierPrefix; + if (fr) { + var m = Oi, k = Tt; + m = (k & ~(1 << 32 - gn(k) - 1)).toString(32) + m, l = ":" + l + "R" + m, m = jc++, 0 < m && (l += "H" + m.toString(32)), l += ":"; + } else m = Dg++, l = ":" + l + "r" + m.toString(32) + ":"; + return s.memoizedState = l; + }, unstable_isNewReconciler: !1 }, Ph = { + readContext: Ir, + useCallback: Sh, + useContext: Ir, + useEffect: Cf, + useImperativeHandle: bh, + useInsertionEffect: xh, + useLayoutEffect: _h, + useMemo: kh, + useReducer: el, + useRef: vh, + useState: function() { + return el(Ll); + }, + useDebugValue: Mf, + useDeferredValue: function(s) { + var l = sa(); + return Ch(l, Dr.memoizedState, s); + }, + useTransition: function() { + var s = el(Ll)[0], l = sa().memoizedState; + return [s, l]; + }, + useMutableSource: wf, + useSyncExternalStore: bf, + useId: Mh, + unstable_isNewReconciler: !1 + }, Bg = { readContext: Ir, useCallback: Sh, useContext: Ir, useEffect: Cf, useImperativeHandle: bh, useInsertionEffect: xh, useLayoutEffect: _h, useMemo: kh, useReducer: _f, useRef: vh, useState: function() { + return _f(Ll); + }, useDebugValue: Mf, useDeferredValue: function(s) { + var l = sa(); + return Dr === null ? l.memoizedState = s : Ch(l, Dr.memoizedState, s); + }, useTransition: function() { + var s = _f(Ll)[0], l = sa().memoizedState; + return [s, l]; + }, useMutableSource: wf, useSyncExternalStore: bf, useId: Mh, unstable_isNewReconciler: !1 }; + function Wa(s, l) { + if (s && s.defaultProps) { + l = fe({}, l), s = s.defaultProps; + for (var m in s) l[m] === void 0 && (l[m] = s[m]); + return l; + } + return l; + } + function Nf(s, l, m, k) { + l = s.memoizedState, m = m(k, l), m = m == null ? l : fe({}, l, m), s.memoizedState = m, s.lanes === 0 && (s.updateQueue.baseState = m); + } + var Bu = { isMounted: function(s) { + return (s = s._reactInternals) ? nr(s) === s : !1; + }, enqueueSetState: function(s, l, m) { + s = s._reactInternals; + var k = U(), I = oe(s), z = $o(k, I); + z.payload = l, m != null && (z.callback = m), l = Gi(s, z, I), l !== null && (ie(l, s, I, k), Iu(l, s, I)); + }, enqueueReplaceState: function(s, l, m) { + s = s._reactInternals; + var k = U(), I = oe(s), z = $o(k, I); + z.tag = 1, z.payload = l, m != null && (z.callback = m), l = Gi(s, z, I), l !== null && (ie(l, s, I, k), Iu(l, s, I)); + }, enqueueForceUpdate: function(s, l) { + s = s._reactInternals; + var m = U(), k = oe(s), I = $o(m, k); + I.tag = 2, l != null && (I.callback = l), l = Gi(s, I, k), l !== null && (ie(l, s, k, m), Iu(l, s, k)); + } }; + function Th(s, l, m, k, I, z, ee) { + return s = s.stateNode, typeof s.shouldComponentUpdate == "function" ? s.shouldComponentUpdate(k, z, ee) : l.prototype && l.prototype.isPureReactComponent ? !dc(m, k) || !dc(I, z) : !0; + } + function Ef(s, l, m) { + var k = !1, I = pi, z = l.contextType; + return typeof z == "object" && z !== null ? z = Ir(z) : (I = ro(l) ? Ri : ka.current, k = l.contextTypes, z = (k = k != null) ? Io(s, I) : pi), l = new l(m, z), s.memoizedState = l.state !== null && l.state !== void 0 ? l.state : null, l.updater = Bu, s.stateNode = l, l._reactInternals = s, k && (s = s.stateNode, s.__reactInternalMemoizedUnmaskedChildContext = I, s.__reactInternalMemoizedMaskedChildContext = z), l; + } + function Af(s, l, m, k) { + s = l.state, typeof l.componentWillReceiveProps == "function" && l.componentWillReceiveProps(m, k), typeof l.UNSAFE_componentWillReceiveProps == "function" && l.UNSAFE_componentWillReceiveProps(m, k), l.state !== s && Bu.enqueueReplaceState(l, l.state, null); + } + function Tc(s, l, m, k) { + var I = s.stateNode; + I.props = m, I.state = s.memoizedState, I.refs = {}, pf(s); + var z = l.contextType; + typeof z == "object" && z !== null ? I.context = Ir(z) : (z = ro(l) ? Ri : ka.current, I.context = Io(s, z)), I.state = s.memoizedState, z = l.getDerivedStateFromProps, typeof z == "function" && (Nf(s, l, z, m), I.state = s.memoizedState), typeof l.getDerivedStateFromProps == "function" || typeof I.getSnapshotBeforeUpdate == "function" || typeof I.UNSAFE_componentWillMount != "function" && typeof I.componentWillMount != "function" || (l = I.state, typeof I.componentWillMount == "function" && I.componentWillMount(), typeof I.UNSAFE_componentWillMount == "function" && I.UNSAFE_componentWillMount(), l !== I.state && Bu.enqueueReplaceState(I, I.state, null), Mc(s, m, I, k), I.state = s.memoizedState), typeof I.componentDidMount == "function" && (s.flags |= 4194308); + } + function nl(s, l) { + try { + var m = "", k = l; + do + m += X(k), k = k.return; + while (k); + var I = m; + } catch (z) { + I = ` +Error generating stack: ` + z.message + ` +` + z.stack; + } + return { value: s, source: l, stack: I, digest: null }; + } + function qu(s, l, m) { + return { value: s, source: null, stack: m ?? null, digest: l ?? null }; + } + function Wu(s, l) { + try { + console.error(l.value); + } catch (m) { + setTimeout(function() { + throw m; + }); + } + } + var qg = typeof WeakMap == "function" ? WeakMap : Map; + function jf(s, l, m) { + m = $o(-1, m), m.tag = 3, m.payload = { element: null }; + var k = l.value; + return m.callback = function() { + zc || (zc = !0, id = k), Wu(s, l); + }, m; + } + function rl(s, l, m) { + m = $o(-1, m), m.tag = 3; + var k = s.type.getDerivedStateFromError; + if (typeof k == "function") { + var I = l.value; + m.payload = function() { + return k(I); + }, m.callback = function() { + Wu(s, l); + }; + } + var z = s.stateNode; + return z !== null && typeof z.componentDidCatch == "function" && (m.callback = function() { + Wu(s, l), typeof k != "function" && (Hi === null ? Hi = /* @__PURE__ */ new Set([this]) : Hi.add(this)); + var ee = l.stack; + this.componentDidCatch(l.value, { componentStack: ee !== null ? ee : "" }); + }), m; + } + function Ih(s, l, m) { + var k = s.pingCache; + if (k === null) { + k = s.pingCache = new qg(); + var I = /* @__PURE__ */ new Set(); + k.set(l, I); + } else I = k.get(l), I === void 0 && (I = /* @__PURE__ */ new Set(), k.set(l, I)); + I.has(m) || (I.add(m), s = sd.bind(null, s, l, m), l.then(s, s)); + } + function Pf(s) { + do { + var l; + if ((l = s.tag === 13) && (l = s.memoizedState, l = l !== null ? l.dehydrated !== null : !0), l) return s; + s = s.return; + } while (s !== null); + return null; + } + function Fh(s, l, m, k, I) { + return (s.mode & 1) === 0 ? (s === l ? s.flags |= 65536 : (s.flags |= 128, m.flags |= 131072, m.flags &= -52805, m.tag === 1 && (m.alternate === null ? m.tag = 17 : (l = $o(-1, 1), l.tag = 2, Gi(m, l, 1))), m.lanes |= 1), s) : (s.flags |= 65536, s.lanes = I, s); + } + var Wg = N.ReactCurrentOwner, ya = !1; + function Ha(s, l, m, k) { + l.child = s === null ? ph(l, null, m, k) : Pl(l, s.child, m, k); + } + function Hu(s, l, m, k, I) { + m = m.render; + var z = l.ref; + return Ks(l, I), k = vf(s, l, m, k, z, I), m = xf(), s !== null && !ya ? (l.updateQueue = s.updateQueue, l.flags &= -2053, s.lanes &= ~I, qi(s, l, I)) : (fr && m && kc(l), l.flags |= 1, Ha(s, l, k, I), l.child); + } + function Tf(s, l, m, k, I) { + if (s === null) { + var z = m.type; + return typeof z == "function" && !Oo(z) && z.defaultProps === void 0 && m.compare === null && m.defaultProps === void 0 ? (l.tag = 15, l.type = z, Uu(s, l, z, k, I)) : (s = Wc(m.type, null, k, l, l.mode, I), s.ref = l.ref, s.return = l, l.child = s); + } + if (z = s.child, (s.lanes & I) === 0) { + var ee = z.memoizedProps; + if (m = m.compare, m = m !== null ? m : dc, m(ee, k) && s.ref === l.ref) return qi(s, l, I); + } + return l.flags |= 1, s = Ms(z, k), s.ref = l.ref, s.return = l, l.child = s; + } + function Uu(s, l, m, k, I) { + if (s !== null) { + var z = s.memoizedProps; + if (dc(z, k) && s.ref === l.ref) if (ya = !1, l.pendingProps = k = z, (s.lanes & I) !== 0) (s.flags & 131072) !== 0 && (ya = !0); + else return l.lanes = s.lanes, qi(s, l, I); + } + return Vu(s, l, m, k, I); + } + function If(s, l, m) { + var k = l.pendingProps, I = k.children, z = s !== null ? s.memoizedState : null; + if (k.mode === "hidden") if ((l.mode & 1) === 0) l.memoizedState = { baseLanes: 0, cachePool: null, transitions: null }, Zn(il, _o), _o |= m; + else { + if ((m & 1073741824) === 0) return s = z !== null ? z.baseLanes | m : m, l.lanes = l.childLanes = 1073741824, l.memoizedState = { baseLanes: s, cachePool: null, transitions: null }, l.updateQueue = null, Zn(il, _o), _o |= s, null; + l.memoizedState = { baseLanes: 0, cachePool: null, transitions: null }, k = z !== null ? z.baseLanes : m, Zn(il, _o), _o |= k; + } + else z !== null ? (k = z.baseLanes | m, l.memoizedState = null) : k = m, Zn(il, _o), _o |= k; + return Ha(s, l, I, m), l.child; + } + function $h(s, l) { + var m = l.ref; + (s === null && m !== null || s !== null && s.ref !== m) && (l.flags |= 512, l.flags |= 2097152); + } + function Vu(s, l, m, k, I) { + var z = ro(m) ? Ri : ka.current; + return z = Io(l, z), Ks(l, I), m = vf(s, l, m, k, z, I), k = xf(), s !== null && !ya ? (l.updateQueue = s.updateQueue, l.flags &= -2053, s.lanes &= ~I, qi(s, l, I)) : (fr && k && kc(l), l.flags |= 1, Ha(s, l, m, I), l.child); + } + function Ku(s, l, m, k, I) { + if (ro(m)) { + var z = !0; + Cu(l); + } else z = !1; + if (Ks(l, I), l.stateNode === null) Ic(s, l), Ef(l, m, k), Tc(l, m, k, I), k = !0; + else if (s === null) { + var ee = l.stateNode, _e = l.memoizedProps; + ee.props = _e; + var Me = ee.context, Ue = m.contextType; + typeof Ue == "object" && Ue !== null ? Ue = Ir(Ue) : (Ue = ro(m) ? Ri : ka.current, Ue = Io(l, Ue)); + var ct = m.getDerivedStateFromProps, gt = typeof ct == "function" || typeof ee.getSnapshotBeforeUpdate == "function"; + gt || typeof ee.UNSAFE_componentWillReceiveProps != "function" && typeof ee.componentWillReceiveProps != "function" || (_e !== k || Me !== Ue) && Af(l, ee, k, Ue), ws = !1; + var st = l.memoizedState; + ee.state = st, Mc(l, k, ee, I), Me = l.memoizedState, _e !== k || st !== Me || no.current || ws ? (typeof ct == "function" && (Nf(l, m, ct, k), Me = l.memoizedState), (_e = ws || Th(l, m, _e, k, st, Me, Ue)) ? (gt || typeof ee.UNSAFE_componentWillMount != "function" && typeof ee.componentWillMount != "function" || (typeof ee.componentWillMount == "function" && ee.componentWillMount(), typeof ee.UNSAFE_componentWillMount == "function" && ee.UNSAFE_componentWillMount()), typeof ee.componentDidMount == "function" && (l.flags |= 4194308)) : (typeof ee.componentDidMount == "function" && (l.flags |= 4194308), l.memoizedProps = k, l.memoizedState = Me), ee.props = k, ee.state = Me, ee.context = Ue, k = _e) : (typeof ee.componentDidMount == "function" && (l.flags |= 4194308), k = !1); + } else { + ee = l.stateNode, mh(s, l), _e = l.memoizedProps, Ue = l.type === l.elementType ? _e : Wa(l.type, _e), ee.props = Ue, gt = l.pendingProps, st = ee.context, Me = m.contextType, typeof Me == "object" && Me !== null ? Me = Ir(Me) : (Me = ro(m) ? Ri : ka.current, Me = Io(l, Me)); + var Ft = m.getDerivedStateFromProps; + (ct = typeof Ft == "function" || typeof ee.getSnapshotBeforeUpdate == "function") || typeof ee.UNSAFE_componentWillReceiveProps != "function" && typeof ee.componentWillReceiveProps != "function" || (_e !== gt || st !== Me) && Af(l, ee, k, Me), ws = !1, st = l.memoizedState, ee.state = st, Mc(l, k, ee, I); + var Ot = l.memoizedState; + _e !== gt || st !== Ot || no.current || ws ? (typeof Ft == "function" && (Nf(l, m, Ft, k), Ot = l.memoizedState), (Ue = ws || Th(l, m, Ue, k, st, Ot, Me) || !1) ? (ct || typeof ee.UNSAFE_componentWillUpdate != "function" && typeof ee.componentWillUpdate != "function" || (typeof ee.componentWillUpdate == "function" && ee.componentWillUpdate(k, Ot, Me), typeof ee.UNSAFE_componentWillUpdate == "function" && ee.UNSAFE_componentWillUpdate(k, Ot, Me)), typeof ee.componentDidUpdate == "function" && (l.flags |= 4), typeof ee.getSnapshotBeforeUpdate == "function" && (l.flags |= 1024)) : (typeof ee.componentDidUpdate != "function" || _e === s.memoizedProps && st === s.memoizedState || (l.flags |= 4), typeof ee.getSnapshotBeforeUpdate != "function" || _e === s.memoizedProps && st === s.memoizedState || (l.flags |= 1024), l.memoizedProps = k, l.memoizedState = Ot), ee.props = k, ee.state = Ot, ee.context = Me, k = Ue) : (typeof ee.componentDidUpdate != "function" || _e === s.memoizedProps && st === s.memoizedState || (l.flags |= 4), typeof ee.getSnapshotBeforeUpdate != "function" || _e === s.memoizedProps && st === s.memoizedState || (l.flags |= 1024), k = !1); + } + return Yu(s, l, m, k, z, I); + } + function Yu(s, l, m, k, I, z) { + $h(s, l); + var ee = (l.flags & 128) !== 0; + if (!k && !ee) return I && ih(l, m, !1), qi(s, l, z); + k = l.stateNode, Wg.current = l; + var _e = ee && typeof m.getDerivedStateFromError != "function" ? null : k.render(); + return l.flags |= 1, s !== null && ee ? (l.child = Pl(l, s.child, null, z), l.child = Pl(l, null, _e, z)) : Ha(s, l, _e, z), l.memoizedState = k.state, I && ih(l, m, !0), l.child; + } + function Ff(s) { + var l = s.stateNode; + l.pendingContext ? ah(s, l.pendingContext, l.pendingContext !== l.context) : l.context && ah(s, l.context, !1), hf(s, l.containerInfo); + } + function $f(s, l, m, k, I) { + return vs(), lf(I), l.flags |= 256, Ha(s, l, m, k), l.child; + } + var Lf = { dehydrated: null, treeContext: null, retryLane: 0 }; + function Rf(s) { + return { baseLanes: s, cachePool: null, transitions: null }; + } + function Lh(s, l, m) { + var k = l.pendingProps, I = pr.current, z = !1, ee = (l.flags & 128) !== 0, _e; + if ((_e = ee) || (_e = s !== null && s.memoizedState === null ? !1 : (I & 2) !== 0), _e ? (z = !0, l.flags &= -129) : (s === null || s.memoizedState !== null) && (I |= 1), Zn(pr, I & 1), s === null) + return Vs(l), s = l.memoizedState, s !== null && (s = s.dehydrated, s !== null) ? ((l.mode & 1) === 0 ? l.lanes = 1 : s.data === "$!" ? l.lanes = 8 : l.lanes = 1073741824, null) : (ee = k.children, s = k.fallback, z ? (k = l.mode, z = l.child, ee = { mode: "hidden", children: ee }, (k & 1) === 0 && z !== null ? (z.childLanes = 0, z.pendingProps = ee) : z = pn(ee, k, 0, null), s = Ht(s, k, m, null), z.return = l, s.return = l, z.sibling = s, l.child = z, l.child.memoizedState = Rf(m), l.memoizedState = Lf, s) : Of(l, ee)); + if (I = s.memoizedState, I !== null && (_e = I.dehydrated, _e !== null)) return Hg(s, l, ee, k, _e, I, m); + if (z) { + z = k.fallback, ee = l.mode, I = s.child, _e = I.sibling; + var Me = { mode: "hidden", children: k.children }; + return (ee & 1) === 0 && l.child !== I ? (k = l.child, k.childLanes = 0, k.pendingProps = Me, l.deletions = null) : (k = Ms(I, Me), k.subtreeFlags = I.subtreeFlags & 14680064), _e !== null ? z = Ms(_e, z) : (z = Ht(z, ee, m, null), z.flags |= 2), z.return = l, k.return = l, k.sibling = z, l.child = k, k = z, z = l.child, ee = s.child.memoizedState, ee = ee === null ? Rf(m) : { baseLanes: ee.baseLanes | m, cachePool: null, transitions: ee.transitions }, z.memoizedState = ee, z.childLanes = s.childLanes & ~m, l.memoizedState = Lf, k; + } + return z = s.child, s = z.sibling, k = Ms(z, { mode: "visible", children: k.children }), (l.mode & 1) === 0 && (k.lanes = m), k.return = l, k.sibling = null, s !== null && (m = l.deletions, m === null ? (l.deletions = [s], l.flags |= 16) : m.push(s)), l.child = k, l.memoizedState = null, k; + } + function Of(s, l) { + return l = pn({ mode: "visible", children: l }, s.mode, 0, null), l.return = s, s.child = l; + } + function Xu(s, l, m, k) { + return k !== null && lf(k), Pl(l, s.child, null, m), s = Of(l, l.pendingProps.children), s.flags |= 2, l.memoizedState = null, s; + } + function Hg(s, l, m, k, I, z, ee) { + if (m) + return l.flags & 256 ? (l.flags &= -257, k = qu(Error(n(422))), Xu(s, l, ee, k)) : l.memoizedState !== null ? (l.child = s.child, l.flags |= 128, null) : (z = k.fallback, I = l.mode, k = pn({ mode: "visible", children: k.children }, I, 0, null), z = Ht(z, I, ee, null), z.flags |= 2, k.return = l, z.return = l, k.sibling = z, l.child = k, (l.mode & 1) !== 0 && Pl(l, s.child, null, ee), l.child.memoizedState = Rf(ee), l.memoizedState = Lf, z); + if ((l.mode & 1) === 0) return Xu(s, l, ee, null); + if (I.data === "$!") { + if (k = I.nextSibling && I.nextSibling.dataset, k) var _e = k.dgst; + return k = _e, z = Error(n(419)), k = qu(z, k, void 0), Xu(s, l, ee, k); + } + if (_e = (ee & s.childLanes) !== 0, ya || _e) { + if (k = or, k !== null) { + switch (ee & -ee) { + case 4: + I = 2; + break; + case 16: + I = 8; + break; + case 64: + case 128: + case 256: + case 512: + case 1024: + case 2048: + case 4096: + case 8192: + case 16384: + case 32768: + case 65536: + case 131072: + case 262144: + case 524288: + case 1048576: + case 2097152: + case 4194304: + case 8388608: + case 16777216: + case 33554432: + case 67108864: + I = 32; + break; + case 536870912: + I = 268435456; + break; + default: + I = 0; + } + I = (I & (k.suspendedLanes | ee)) !== 0 ? 0 : I, I !== 0 && I !== z.retryLane && (z.retryLane = I, zi(s, I), ie(k, s, I, -1)); + } + return Ze(), k = qu(Error(n(421))), Xu(s, l, ee, k); + } + return I.data === "$?" ? (l.flags |= 128, l.child = s.child, l = Gh.bind(null, s), I._reactRetry = l, null) : (s = z.treeContext, er = Zo(I.nextSibling), En = l, fr = !0, ei = null, s !== null && (mo[go++] = Tt, mo[go++] = Oi, mo[go++] = ys, Tt = s.id, Oi = s.overflow, ys = l), l = Of(l, k.children), l.flags |= 4096, l); + } + function Rh(s, l, m) { + s.lanes |= l; + var k = s.alternate; + k !== null && (k.lanes |= l), ff(s.return, l, m); + } + function Ju(s, l, m, k, I) { + var z = s.memoizedState; + z === null ? s.memoizedState = { isBackwards: l, rendering: null, renderingStartTime: 0, last: k, tail: m, tailMode: I } : (z.isBackwards = l, z.rendering = null, z.renderingStartTime = 0, z.last = k, z.tail = m, z.tailMode = I); + } + function Df(s, l, m) { + var k = l.pendingProps, I = k.revealOrder, z = k.tail; + if (Ha(s, l, k.children, m), k = pr.current, (k & 2) !== 0) k = k & 1 | 2, l.flags |= 128; + else { + if (s !== null && (s.flags & 128) !== 0) e: for (s = l.child; s !== null; ) { + if (s.tag === 13) s.memoizedState !== null && Rh(s, m, l); + else if (s.tag === 19) Rh(s, m, l); + else if (s.child !== null) { + s.child.return = s, s = s.child; + continue; + } + if (s === l) break e; + for (; s.sibling === null; ) { + if (s.return === null || s.return === l) break e; + s = s.return; + } + s.sibling.return = s.return, s = s.sibling; + } + k &= 1; + } + if (Zn(pr, k), (l.mode & 1) === 0) l.memoizedState = null; + else switch (I) { + case "forwards": + for (m = l.child, I = null; m !== null; ) s = m.alternate, s !== null && $u(s) === null && (I = m), m = m.sibling; + m = I, m === null ? (I = l.child, l.child = null) : (I = m.sibling, m.sibling = null), Ju(l, !1, I, m, z); + break; + case "backwards": + for (m = null, I = l.child, l.child = null; I !== null; ) { + if (s = I.alternate, s !== null && $u(s) === null) { + l.child = I; + break; + } + s = I.sibling, I.sibling = m, m = I, I = s; + } + Ju(l, !0, m, null, z); + break; + case "together": + Ju(l, !1, null, null, void 0); + break; + default: + l.memoizedState = null; + } + return l.child; + } + function Ic(s, l) { + (l.mode & 1) === 0 && s !== null && (s.alternate = null, l.alternate = null, l.flags |= 2); + } + function qi(s, l, m) { + if (s !== null && (l.dependencies = s.dependencies), Cs |= l.lanes, (m & l.childLanes) === 0) return null; + if (s !== null && l.child !== s.child) throw Error(n(153)); + if (l.child !== null) { + for (s = l.child, m = Ms(s, s.pendingProps), l.child = m, m.return = l; s.sibling !== null; ) s = s.sibling, m = m.sibling = Ms(s, s.pendingProps), m.return = l; + m.sibling = null; + } + return l.child; + } + function Ug(s, l, m) { + switch (l.tag) { + case 3: + Ff(l), vs(); + break; + case 5: + Nc(l); + break; + case 1: + ro(l.type) && Cu(l); + break; + case 4: + hf(l, l.stateNode.containerInfo); + break; + case 10: + var k = l.type._context, I = l.memoizedProps.value; + Zn(xs, k._currentValue), k._currentValue = I; + break; + case 13: + if (k = l.memoizedState, k !== null) + return k.dehydrated !== null ? (Zn(pr, pr.current & 1), l.flags |= 128, null) : (m & l.child.childLanes) !== 0 ? Lh(s, l, m) : (Zn(pr, pr.current & 1), s = qi(s, l, m), s !== null ? s.sibling : null); + Zn(pr, pr.current & 1); + break; + case 19: + if (k = (m & l.childLanes) !== 0, (s.flags & 128) !== 0) { + if (k) return Df(s, l, m); + l.flags |= 128; + } + if (I = l.memoizedState, I !== null && (I.rendering = null, I.tail = null, I.lastEffect = null), Zn(pr, pr.current), k) break; + return null; + case 22: + case 23: + return l.lanes = 0, If(s, l, m); + } + return qi(s, l, m); + } + var Na, Qu, yo, Fc; + Na = function(s, l) { + for (var m = l.child; m !== null; ) { + if (m.tag === 5 || m.tag === 6) s.appendChild(m.stateNode); + else if (m.tag !== 4 && m.child !== null) { + m.child.return = m, m = m.child; + continue; + } + if (m === l) break; + for (; m.sibling === null; ) { + if (m.return === null || m.return === l) return; + m = m.return; + } + m.sibling.return = m.return, m = m.sibling; + } + }, Qu = function() { + }, yo = function(s, l, m, k) { + var I = s.memoizedProps; + if (I !== k) { + s = l.stateNode, Qs(mi.current); + var z = null; + switch (m) { + case "input": + I = ut(s, I), k = ut(s, k), z = []; + break; + case "select": + I = fe({}, I, { value: void 0 }), k = fe({}, k, { value: void 0 }), z = []; + break; + case "textarea": + I = at(s, I), k = at(s, k), z = []; + break; + default: + typeof I.onClick != "function" && typeof k.onClick == "function" && (s.onclick = Ti); + } + Et(m, k); + var ee; + m = null; + for (Ue in I) if (!k.hasOwnProperty(Ue) && I.hasOwnProperty(Ue) && I[Ue] != null) if (Ue === "style") { + var _e = I[Ue]; + for (ee in _e) _e.hasOwnProperty(ee) && (m || (m = {}), m[ee] = ""); + } else Ue !== "dangerouslySetInnerHTML" && Ue !== "children" && Ue !== "suppressContentEditableWarning" && Ue !== "suppressHydrationWarning" && Ue !== "autoFocus" && (a.hasOwnProperty(Ue) ? z || (z = []) : (z = z || []).push(Ue, null)); + for (Ue in k) { + var Me = k[Ue]; + if (_e = I != null ? I[Ue] : void 0, k.hasOwnProperty(Ue) && Me !== _e && (Me != null || _e != null)) if (Ue === "style") if (_e) { + for (ee in _e) !_e.hasOwnProperty(ee) || Me && Me.hasOwnProperty(ee) || (m || (m = {}), m[ee] = ""); + for (ee in Me) Me.hasOwnProperty(ee) && _e[ee] !== Me[ee] && (m || (m = {}), m[ee] = Me[ee]); + } else m || (z || (z = []), z.push( + Ue, + m + )), m = Me; + else Ue === "dangerouslySetInnerHTML" ? (Me = Me ? Me.__html : void 0, _e = _e ? _e.__html : void 0, Me != null && _e !== Me && (z = z || []).push(Ue, Me)) : Ue === "children" ? typeof Me != "string" && typeof Me != "number" || (z = z || []).push(Ue, "" + Me) : Ue !== "suppressContentEditableWarning" && Ue !== "suppressHydrationWarning" && (a.hasOwnProperty(Ue) ? (Me != null && Ue === "onScroll" && yn("scroll", s), z || _e === Me || (z = [])) : (z = z || []).push(Ue, Me)); + } + m && (z = z || []).push("style", m); + var Ue = z; + (l.updateQueue = Ue) && (l.flags |= 4); + } + }, Fc = function(s, l, m, k) { + m !== k && (l.flags |= 4); + }; + function bs(s, l) { + if (!fr) switch (s.tailMode) { + case "hidden": + l = s.tail; + for (var m = null; l !== null; ) l.alternate !== null && (m = l), l = l.sibling; + m === null ? s.tail = null : m.sibling = null; + break; + case "collapsed": + m = s.tail; + for (var k = null; m !== null; ) m.alternate !== null && (k = m), m = m.sibling; + k === null ? l || s.tail === null ? s.tail = null : s.tail.sibling = null : k.sibling = null; + } + } + function Ea(s) { + var l = s.alternate !== null && s.alternate.child === s.child, m = 0, k = 0; + if (l) for (var I = s.child; I !== null; ) m |= I.lanes | I.childLanes, k |= I.subtreeFlags & 14680064, k |= I.flags & 14680064, I.return = s, I = I.sibling; + else for (I = s.child; I !== null; ) m |= I.lanes | I.childLanes, k |= I.subtreeFlags, k |= I.flags, I.return = s, I = I.sibling; + return s.subtreeFlags |= k, s.childLanes = m, l; + } + function Ss(s, l, m) { + var k = l.pendingProps; + switch (Eu(l), l.tag) { + case 2: + case 16: + case 15: + case 0: + case 11: + case 7: + case 8: + case 12: + case 9: + case 14: + return Ea(l), null; + case 1: + return ro(l.type) && hi(), Ea(l), null; + case 3: + return k = l.stateNode, Fl(), Cn(no), Cn(ka), mf(), k.pendingContext && (k.context = k.pendingContext, k.pendingContext = null), (s === null || s.child === null) && (ju(l) ? l.flags |= 4 : s === null || s.memoizedState.isDehydrated && (l.flags & 256) === 0 || (l.flags |= 1024, ei !== null && (ke(ei), ei = null))), Qu(s, l), Ea(l), null; + case 5: + $l(l); + var I = Qs(Js.current); + if (m = l.type, s !== null && l.stateNode != null) yo(s, l, m, k, I), s.ref !== l.ref && (l.flags |= 512, l.flags |= 2097152); + else { + if (!k) { + if (l.stateNode === null) throw Error(n(166)); + return Ea(l), null; + } + if (s = Qs(mi.current), ju(l)) { + k = l.stateNode, m = l.type; + var z = l.memoizedProps; + switch (k[H] = l, k[It] = z, s = (l.mode & 1) !== 0, m) { + case "dialog": + yn("cancel", k), yn("close", k); + break; + case "iframe": + case "object": + case "embed": + yn("load", k); + break; + case "video": + case "audio": + for (I = 0; I < xc.length; I++) yn(xc[I], k); + break; + case "source": + yn("error", k); + break; + case "img": + case "image": + case "link": + yn( + "error", + k + ), yn("load", k); + break; + case "details": + yn("toggle", k); + break; + case "input": + dt(k, z), yn("invalid", k); + break; + case "select": + k._wrapperState = { wasMultiple: !!z.multiple }, yn("invalid", k); + break; + case "textarea": + Pt(k, z), yn("invalid", k); + } + Et(m, z), I = null; + for (var ee in z) if (z.hasOwnProperty(ee)) { + var _e = z[ee]; + ee === "children" ? typeof _e == "string" ? k.textContent !== _e && (z.suppressHydrationWarning !== !0 && Su(k.textContent, _e, s), I = ["children", _e]) : typeof _e == "number" && k.textContent !== "" + _e && (z.suppressHydrationWarning !== !0 && Su( + k.textContent, + _e, + s + ), I = ["children", "" + _e]) : a.hasOwnProperty(ee) && _e != null && ee === "onScroll" && yn("scroll", k); + } + switch (m) { + case "input": + $e(k), lt(k, z, !0); + break; + case "textarea": + $e(k), Qe(k); + break; + case "select": + case "option": + break; + default: + typeof z.onClick == "function" && (k.onclick = Ti); + } + k = I, l.updateQueue = k, k !== null && (l.flags |= 4); + } else { + ee = I.nodeType === 9 ? I : I.ownerDocument, s === "http://www.w3.org/1999/xhtml" && (s = Ct(m)), s === "http://www.w3.org/1999/xhtml" ? m === "script" ? (s = ee.createElement("div"), s.innerHTML = "