@uva-glass/component-library
Version:
React components UvA
1,290 lines • 65.4 kB
JavaScript
import { w as T, r as Q, i as ge, _ as yt, j as Jt, N as Yt, T as Nt, S as Xt, L as qt } from "./LexicalUtils.prod-Dny9Fu94.js";
import { f as Ve, n as ye, q as Ze, $ as jt, Y as Ce, M as it, T as I, X as Qe, p as Vt, h as xt, i as re, j as Zt, N as Be, k as Tt, c as z, o as Qt, r as be, d as D, a as B, m as Ue, s as Ke, t as Gt, v as en, x as tn, y as nn, F as De, L as on, A as rn, B as Rt, D as ln, H as V, I as sn, K as an, O as cn, P as un, Q as hn, R as dn, S as fn, V as gn, W as fe, g as ne, _ as $e, a0 as mn, b as Ft, a1 as pn, w as Ge, a2 as Cn, U as _n, a3 as Ae, a4 as Sn, a5 as wn, a6 as at, a7 as bn, a8 as ct, z as yn, a9 as ut, l as ht, Z as Re, aa as Nn, C as xn, ab as Tn, ac as Rn } from "./Lexical.prod-CWyHQUEM.js";
import { _ as Fn, M as vn } from "./LexicalClipboard.prod-DbqSWANZ.js";
const et = /^(\d+(?:\.\d+)?)px$/, W = { BOTH: 3, COLUMN: 2, NO_STATUS: 0, ROW: 1 };
class ce extends Ve {
static getType() {
return "tablecell";
}
static clone(e) {
return new ce(e.__headerState, e.__colSpan, e.__width, e.__key);
}
afterCloneFrom(e) {
super.afterCloneFrom(e), this.__rowSpan = e.__rowSpan, this.__backgroundColor = e.__backgroundColor, this.__verticalAlign = e.__verticalAlign;
}
static importDOM() {
return { td: (e) => ({ conversion: dt, priority: 0 }), th: (e) => ({ conversion: dt, priority: 0 }) };
}
static importJSON(e) {
return Y().updateFromJSON(e);
}
updateFromJSON(e) {
return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan || 1).setRowSpan(e.rowSpan || 1).setWidth(e.width || void 0).setBackgroundColor(e.backgroundColor || null).setVerticalAlign(e.verticalAlign || void 0);
}
constructor(e = W.NO_STATUS, t = 1, o, l) {
super(l), this.__colSpan = t, this.__rowSpan = 1, this.__headerState = e, this.__width = o, this.__backgroundColor = null, this.__verticalAlign = void 0;
}
createDOM(e) {
const t = document.createElement(this.getTag());
return this.__width && (t.style.width = `${this.__width}px`), this.__colSpan > 1 && (t.colSpan = this.__colSpan), this.__rowSpan > 1 && (t.rowSpan = this.__rowSpan), this.__backgroundColor !== null && (t.style.backgroundColor = this.__backgroundColor), Je(this.__verticalAlign) && (t.style.verticalAlign = this.__verticalAlign), Q(t, e.theme.tableCell, this.hasHeader() && e.theme.tableCellHeader), t;
}
exportDOM(e) {
const t = super.exportDOM(e);
if (ye(t.element)) {
const o = t.element;
o.setAttribute("data-temporary-table-cell-lexical-key", this.getKey()), o.style.border = "1px solid black", this.__colSpan > 1 && (o.colSpan = this.__colSpan), this.__rowSpan > 1 && (o.rowSpan = this.__rowSpan), o.style.width = `${this.getWidth() || 75}px`, o.style.verticalAlign = this.getVerticalAlign() || "top", o.style.textAlign = "start", this.__backgroundColor === null && this.hasHeader() && (o.style.backgroundColor = "#f2f3f5");
}
return t;
}
exportJSON() {
return { ...super.exportJSON(), ...Je(this.__verticalAlign) && { verticalAlign: this.__verticalAlign }, backgroundColor: this.getBackgroundColor(), colSpan: this.__colSpan, headerState: this.__headerState, rowSpan: this.__rowSpan, width: this.getWidth() };
}
getColSpan() {
return this.getLatest().__colSpan;
}
setColSpan(e) {
const t = this.getWritable();
return t.__colSpan = e, t;
}
getRowSpan() {
return this.getLatest().__rowSpan;
}
setRowSpan(e) {
const t = this.getWritable();
return t.__rowSpan = e, t;
}
getTag() {
return this.hasHeader() ? "th" : "td";
}
setHeaderStyles(e, t = W.BOTH) {
const o = this.getWritable();
return o.__headerState = e & t | o.__headerState & ~t, o;
}
getHeaderStyles() {
return this.getLatest().__headerState;
}
setWidth(e) {
const t = this.getWritable();
return t.__width = e, t;
}
getWidth() {
return this.getLatest().__width;
}
getBackgroundColor() {
return this.getLatest().__backgroundColor;
}
setBackgroundColor(e) {
const t = this.getWritable();
return t.__backgroundColor = e, t;
}
getVerticalAlign() {
return this.getLatest().__verticalAlign;
}
setVerticalAlign(e) {
const t = this.getWritable();
return t.__verticalAlign = e || void 0, t;
}
toggleHeaderStyle(e) {
const t = this.getWritable();
return (t.__headerState & e) === e ? t.__headerState -= e : t.__headerState += e, t;
}
hasHeaderState(e) {
return (this.getHeaderStyles() & e) === e;
}
hasHeader() {
return this.getLatest().__headerState !== W.NO_STATUS;
}
updateDOM(e) {
return e.__headerState !== this.__headerState || e.__width !== this.__width || e.__colSpan !== this.__colSpan || e.__rowSpan !== this.__rowSpan || e.__backgroundColor !== this.__backgroundColor || e.__verticalAlign !== this.__verticalAlign;
}
isShadowRoot() {
return !0;
}
collapseAtStart() {
return !0;
}
canBeEmpty() {
return !1;
}
canIndent() {
return !1;
}
}
function Je(n) {
return n === "middle" || n === "bottom";
}
function dt(n) {
const e = n, t = n.nodeName.toLowerCase();
let o;
et.test(e.style.width) && (o = parseFloat(e.style.width));
const l = Y(t === "th" ? W.ROW : W.NO_STATUS, e.colSpan, o);
l.__rowSpan = e.rowSpan;
const s = e.style.backgroundColor;
s !== "" && (l.__backgroundColor = s);
const r = e.style.verticalAlign;
Je(r) && (l.__verticalAlign = r);
const i = e.style, u = (i && i.textDecoration || "").split(" "), m = i.fontWeight === "700" || i.fontWeight === "bold", h = u.includes("line-through"), p = i.fontStyle === "italic", C = u.includes("underline");
return { after: (a) => {
const c = [];
let f = null;
const d = () => {
if (f) {
const g = f.getFirstChild();
it(g) && f.getChildrenSize() === 1 && g.remove();
}
};
for (const g of a) jt(g) || Ce(g) || it(g) ? (Ce(g) && (m && g.toggleFormat("bold"), h && g.toggleFormat("strikethrough"), p && g.toggleFormat("italic"), C && g.toggleFormat("underline")), f ? f.append(g) : (f = I().append(g), c.push(f))) : (c.push(g), d(), f = null);
return d(), c.length === 0 && c.push(I()), c;
}, node: l };
}
function Y(n = W.NO_STATUS, e = 1, t) {
return Ze(new ce(n, e, t));
}
function w(n) {
return n instanceof ce;
}
const On = Qt();
function b(n, ...e) {
const t = new URL("https://lexical.dev/docs/error"), o = new URLSearchParams();
o.append("code", n);
for (const l of e) o.append("v", l);
throw t.search = o.toString(), Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
}
class Te extends Ve {
static getType() {
return "tablerow";
}
static clone(e) {
return new Te(e.__height, e.__key);
}
static importDOM() {
return { tr: (e) => ({ conversion: Kn, priority: 0 }) };
}
static importJSON(e) {
return xe().updateFromJSON(e);
}
updateFromJSON(e) {
return super.updateFromJSON(e).setHeight(e.height);
}
constructor(e, t) {
super(t), this.__height = e;
}
exportJSON() {
const e = this.getHeight();
return { ...super.exportJSON(), ...e === void 0 ? void 0 : { height: e } };
}
createDOM(e) {
const t = document.createElement("tr");
return this.__height && (t.style.height = `${this.__height}px`), Q(t, e.theme.tableRow), t;
}
extractWithChild(e, t, o) {
return o === "html";
}
isShadowRoot() {
return !0;
}
setHeight(e) {
const t = this.getWritable();
return t.__height = e, t;
}
getHeight() {
return this.getLatest().__height;
}
updateDOM(e) {
return e.__height !== this.__height;
}
canBeEmpty() {
return !1;
}
canIndent() {
return !1;
}
}
function Kn(n) {
const e = n;
let t;
return et.test(e.style.height) && (t = parseFloat(e.style.height)), { after: (o) => yt(o, w), node: xe(t) };
}
function xe(n) {
return Ze(new Te(n));
}
function $(n) {
return n instanceof Te;
}
const tt = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0, An = tt && "documentMode" in document ? document.documentMode : null, ft = tt && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
function En(n, e, t = !0) {
const o = rt();
for (let l = 0; l < n; l++) {
const s = xe();
for (let r = 0; r < e; r++) {
let i = W.NO_STATUS;
typeof t == "object" ? (l === 0 && t.rows && (i |= W.ROW), r === 0 && t.columns && (i |= W.COLUMN)) : t && (l === 0 && (i |= W.ROW), r === 0 && (i |= W.COLUMN));
const u = Y(i), m = I();
m.append(Qe()), u.append(m), s.append(u);
}
o.append(s);
}
return o;
}
function so(n) {
const e = T(n, (t) => w(t));
return w(e) ? e : null;
}
function vt(n) {
const e = T(n, (t) => $(t));
if ($(e)) return e;
throw new Error("Expected table cell to be inside of table row.");
}
function Ot(n) {
const e = T(n, (t) => k(t));
if (k(e)) return e;
throw new Error("Expected table cell to be inside of table.");
}
function io(n) {
const e = vt(n);
return Ot(e).getChildren().findIndex((t) => t.is(e));
}
function ao(n) {
return vt(n).getChildren().findIndex((e) => e.is(n));
}
tt && "InputEvent" in window && !An && new window.InputEvent("input");
const Ye = (n, e) => n === W.BOTH || n === e ? e : W.NO_STATUS;
function kn(n, e = !0) {
const [, , t] = G(n), [o, l] = J(t, n, n), s = o[0].length, { startRow: r } = l;
let i = null;
if (e) {
const u = r + n.__rowSpan - 1, m = o[u], h = xe();
for (let C = 0; C < s; C++) {
const { cell: a, startRow: c } = m[C];
if (c + a.__rowSpan - 1 <= u) {
const f = m[C].cell.__headerState, d = Ye(f, W.COLUMN);
h.append(Y(d).append(I()));
} else a.setRowSpan(a.__rowSpan + 1);
}
const p = t.getChildAtIndex(u);
$(p) || b(256), p.insertAfter(h), i = h;
} else {
const u = r, m = o[u], h = xe();
for (let C = 0; C < s; C++) {
const { cell: a, startRow: c } = m[C];
if (c === u) {
const f = m[C].cell.__headerState, d = Ye(f, W.COLUMN);
h.append(Y(d).append(I()));
} else a.setRowSpan(a.__rowSpan + 1);
}
const p = t.getChildAtIndex(u);
$(p) || b(257), p.insertBefore(h), i = h;
}
return i;
}
function $n(n, e = !0, t = !0) {
const [, , o] = G(n), [l, s] = J(o, n, n), r = l.length, { startColumn: i } = s, u = e ? i + n.__colSpan - 1 : i - 1, m = o.getFirstChild();
$(m) || b(120);
let h = null;
function p(c = W.NO_STATUS) {
const f = Y(c).append(I());
return h === null && (h = f), f;
}
let C = m;
e: for (let c = 0; c < r; c++) {
if (c !== 0) {
const y = C.getNextSibling();
$(y) || b(121), C = y;
}
const f = l[c], d = f[u < 0 ? 0 : u].cell.__headerState, g = Ye(d, W.ROW);
if (u < 0) {
Kt(C, p(g));
continue;
}
const { cell: _, startColumn: S, startRow: N } = f[u];
if (S + _.__colSpan - 1 <= u) {
let y = _, R = N, v = u;
for (; R !== c && y.__rowSpan > 1; ) {
if (v -= _.__colSpan, !(v >= 0)) {
C.append(p(g));
continue e;
}
{
const { cell: M, startRow: O } = f[v];
y = M, R = O;
}
}
y.insertAfter(p(g));
} else _.setColSpan(_.__colSpan + 1);
}
h !== null && t && Mn(h);
const a = o.getColWidths();
if (a) {
const c = [...a], f = u < 0 ? 0 : u, d = c[f];
c.splice(f, 0, d), o.setColWidths(c);
}
return h;
}
function co(n, e) {
const t = n.getChildren();
for (let o = 0; o < t.length; o++) {
const l = t[o];
if ($(l)) {
const s = l.getChildren();
if (e >= s.length || e < 0) throw new Error("Table column target index out of range");
s[e].remove();
}
}
return n;
}
function Mn(n) {
const e = n.getFirstDescendant();
e == null ? n.selectStart() : e.getParentOrThrow().selectStart();
}
function Kt(n, e) {
const t = n.getFirstChild();
t !== null ? t.insertBefore(e) : n.append(e);
}
function Ln(n) {
if (n.length === 0) return null;
const e = Ot(n[0]), [t] = oe(e, null, null);
let o = 1 / 0, l = -1 / 0, s = 1 / 0, r = -1 / 0;
const i = /* @__PURE__ */ new Set();
for (const a of t) for (const c of a) {
if (!c || !c.cell) continue;
const f = c.cell.getKey();
if (!i.has(f) && n.some((d) => d.is(c.cell))) {
i.add(f);
const d = c.startRow, g = c.startColumn, _ = c.cell.__rowSpan || 1, S = c.cell.__colSpan || 1;
o = Math.min(o, d), l = Math.max(l, d + _ - 1), s = Math.min(s, g), r = Math.max(r, g + S - 1);
}
}
if (o === 1 / 0 || s === 1 / 0) return null;
const u = l - o + 1, m = r - s + 1, h = t[o][s];
if (!h.cell) return null;
const p = h.cell;
p.setColSpan(m), p.setRowSpan(u);
const C = /* @__PURE__ */ new Set([p.getKey()]);
for (let a = o; a <= l; a++) for (let c = s; c <= r; c++) {
const f = t[a][c];
if (!f.cell) continue;
const d = f.cell, g = d.getKey();
C.has(g) || (C.add(g), zn(d) || p.append(...d.getChildren()), d.remove());
}
return p.getChildrenSize() === 0 && p.append(I()), p;
}
function zn(n) {
if (n.getChildrenSize() !== 1) return !1;
const e = n.getFirstChildOrThrow();
return !(!Ge(e) || !e.isEmpty());
}
function Wn(n) {
const [e, t, o] = G(n), l = e.__colSpan, s = e.__rowSpan;
if (l === 1 && s === 1) return;
const [r, i] = J(o, e, e), { startColumn: u, startRow: m } = i, h = e.__headerState & W.COLUMN, p = Array.from({ length: l }, (c, f) => {
let d = h;
for (let g = 0; d !== 0 && g < r.length; g++) d &= r[g][f + u].cell.__headerState;
return d;
}), C = e.__headerState & W.ROW, a = Array.from({ length: s }, (c, f) => {
let d = C;
for (let g = 0; d !== 0 && g < r[0].length; g++) d &= r[f + m][g].cell.__headerState;
return d;
});
if (l > 1) {
for (let c = 1; c < l; c++) e.insertAfter(Y(p[c] | a[0]).append(I()));
e.setColSpan(1);
}
if (s > 1) {
let c;
for (let f = 1; f < s; f++) {
const d = m + f, g = r[d];
c = (c || t).getNextSibling(), $(c) || b(125);
let _ = null;
for (let S = 0; S < u; S++) {
const N = g[S], y = N.cell;
N.startRow === d && (_ = y), y.__colSpan > 1 && (S += y.__colSpan - 1);
}
if (_ === null) for (let S = l - 1; S >= 0; S--) Kt(c, Y(p[S] | a[f]).append(I()));
else for (let S = l - 1; S >= 0; S--) _.insertAfter(Y(p[S] | a[f]).append(I()));
}
e.setRowSpan(1);
}
}
function J(n, e, t) {
const [o, l, s] = oe(n, e, t);
return l === null && b(207), s === null && b(208), [o, l, s];
}
function oe(n, e, t) {
const o = [];
let l = null, s = null;
function r(u) {
let m = o[u];
return m === void 0 && (o[u] = m = []), m;
}
const i = n.getChildren();
for (let u = 0; u < i.length; u++) {
const m = i[u];
$(m) || b(209);
const h = r(u);
for (let p = m.getFirstChild(), C = 0; p != null; p = p.getNextSibling()) {
for (w(p) || b(147); h[C] !== void 0; ) C++;
const a = { cell: p, startColumn: C, startRow: u }, { __rowSpan: c, __colSpan: f } = p;
for (let d = 0; d < c && !(u + d >= i.length); d++) {
const g = r(u + d);
for (let _ = 0; _ < f; _++) g[C + _] = a;
}
e !== null && l === null && e.is(p) && (l = a), t !== null && s === null && t.is(p) && (s = a);
}
}
return [o, l, s];
}
function G(n) {
let e;
if (n instanceof ce) e = n;
else if ("__type" in n) {
const l = T(n, w);
w(l) || b(148), e = l;
} else {
const l = T(n.getNode(), w);
w(l) || b(148), e = l;
}
const t = e.getParent();
$(t) || b(149);
const o = t.getParent();
return k(o) || b(210), [e, t, o];
}
function Ee(n, e, t) {
let o, l = Math.min(e.startColumn, t.startColumn), s = Math.min(e.startRow, t.startRow), r = Math.max(e.startColumn + e.cell.__colSpan - 1, t.startColumn + t.cell.__colSpan - 1), i = Math.max(e.startRow + e.cell.__rowSpan - 1, t.startRow + t.cell.__rowSpan - 1);
do {
o = !1;
for (let u = 0; u < n.length; u++) for (let m = 0; m < n[0].length; m++) {
const h = n[u][m];
if (!h) continue;
const p = h.startColumn + h.cell.__colSpan - 1, C = h.startRow + h.cell.__rowSpan - 1, a = h.startColumn <= r && p >= l, c = h.startRow <= i && C >= s;
if (a && c) {
const f = Math.min(l, h.startColumn), d = Math.max(r, p), g = Math.min(s, h.startRow), _ = Math.max(i, C);
f === l && d === r && g === s && _ === i || (l = f, r = d, s = g, i = _, o = !0);
}
}
} while (o);
return { maxColumn: r, maxRow: i, minColumn: l, minRow: s };
}
function gt(n) {
const [e, , t] = G(n), o = t.getChildren(), l = o.length, s = o[0].getChildren().length, r = new Array(l);
for (let i = 0; i < l; i++) r[i] = new Array(s);
for (let i = 0; i < l; i++) {
const u = o[i].getChildren();
let m = 0;
for (let h = 0; h < u.length; h++) {
for (; r[i][m]; ) m++;
const p = u[h], C = p.__rowSpan || 1, a = p.__colSpan || 1;
for (let c = 0; c < C; c++) for (let f = 0; f < a; f++) r[i + c][m + f] = p;
if (e === p) return { colSpan: a, columnIndex: m, rowIndex: i, rowSpan: C };
m += a;
}
}
return null;
}
function mt(n) {
const [[e, t, o, l], [s, r, i, u]] = ["anchor", "focus"].map((m) => {
const h = n[m].getNode(), p = T(h, w);
w(p) || b(238, m, h.getKey(), h.getType());
const C = p.getParent();
$(C) || b(239, m);
const a = C.getParent();
return k(a) || b(240, m), [h, p, C, a];
});
return l.is(u) || b(241), { anchorCell: t, anchorNode: e, anchorRow: o, anchorTable: l, focusCell: r, focusNode: s, focusRow: i, focusTable: u };
}
class Me {
constructor(e, t, o) {
this.anchor = t, this.focus = o, t._selection = this, o._selection = this, this._cachedNodes = null, this.dirty = !1, this.tableKey = e;
}
getStartEndPoints() {
return [this.anchor, this.focus];
}
isValid() {
return this.tableKey !== "root" && this.anchor.key !== "root" && this.anchor.type === "element" && this.focus.key !== "root" && this.focus.type === "element";
}
isBackward() {
return this.focus.isBefore(this.anchor);
}
getCachedNodes() {
return this._cachedNodes;
}
setCachedNodes(e) {
this._cachedNodes = e;
}
is(e) {
return K(e) && this.tableKey === e.tableKey && this.anchor.is(e.anchor) && this.focus.is(e.focus);
}
set(e, t, o) {
this.dirty = this.dirty || e !== this.tableKey || t !== this.anchor.key || o !== this.focus.key, this.tableKey = e, this.anchor.key = t, this.focus.key = o, this._cachedNodes = null;
}
clone() {
return new Me(this.tableKey, Ae(this.anchor.key, this.anchor.offset, this.anchor.type), Ae(this.focus.key, this.focus.offset, this.focus.type));
}
isCollapsed() {
return !1;
}
extract() {
return this.getNodes();
}
insertRawText(e) {
}
insertText() {
}
hasFormat(e) {
let t = 0;
this.getNodes().filter(w).forEach((l) => {
const s = l.getFirstChild();
Ge(s) && (t |= s.getTextFormat());
});
const o = Rn[e];
return !!(t & o);
}
insertNodes(e) {
const t = this.focus.getNode();
D(t) || b(151), xn(t.select(0, t.getChildrenSize())).insertNodes(e);
}
getShape() {
const { anchorCell: e, focusCell: t } = mt(this), o = gt(e);
o === null && b(153);
const l = gt(t);
l === null && b(155);
const s = Math.min(o.columnIndex, l.columnIndex), r = Math.max(o.columnIndex + o.colSpan - 1, l.columnIndex + l.colSpan - 1), i = Math.min(o.rowIndex, l.rowIndex), u = Math.max(o.rowIndex + o.rowSpan - 1, l.rowIndex + l.rowSpan - 1);
return { fromX: Math.min(s, r), fromY: Math.min(i, u), toX: Math.max(s, r), toY: Math.max(i, u) };
}
getNodes() {
if (!this.isValid()) return [];
const e = this._cachedNodes;
if (e !== null) return e;
const { anchorTable: t, anchorCell: o, focusCell: l } = mt(this), s = l.getParents()[1];
if (s !== t) {
if (t.isParentOf(l)) {
const d = s.getParent();
d == null && b(159), this.set(this.tableKey, l.getKey(), d.getKey());
} else {
const d = t.getParent();
d == null && b(158), this.set(this.tableKey, d.getKey(), l.getKey());
}
return this.getNodes();
}
const [r, i, u] = J(t, o, l), { minColumn: m, maxColumn: h, minRow: p, maxRow: C } = Ee(r, i, u), a = /* @__PURE__ */ new Map([[t.getKey(), t]]);
let c = null;
for (let d = p; d <= C; d++) for (let g = m; g <= h; g++) {
const { cell: _ } = r[d][g], S = _.getParent();
$(S) || b(160), S !== c && (a.set(S.getKey(), S), c = S), a.has(_.getKey()) || Pn(_, (N) => {
a.set(N.getKey(), N);
});
}
const f = Array.from(a.values());
return Tn() || (this._cachedNodes = f), f;
}
getTextContent() {
const e = this.getNodes().filter((o) => w(o));
let t = "";
for (let o = 0; o < e.length; o++) {
const l = e[o], s = l.__parent, r = (e[o + 1] || {}).__parent;
t += l.getTextContent() + (r !== s ? `
` : " ");
}
return t;
}
}
function K(n) {
return n instanceof Me;
}
function At() {
const n = Ae("root", 0, "element"), e = Ae("root", 0, "element");
return new Me("root", n, e);
}
function Hn(n, e, t) {
n.getKey(), e.getKey(), t.getKey();
const o = B(), l = K(o) ? o.clone() : At();
return l.set(n.getKey(), e.getKey(), t.getKey()), l;
}
function Pn(n, e) {
const t = [[n]];
for (let o = t.at(-1); o !== void 0 && t.length > 0; o = t.at(-1)) {
const l = o.pop();
l === void 0 ? t.pop() : e(l) !== !1 && D(l) && t.push(l.getChildren());
}
}
function Et(n, e = xt()) {
const t = Ke(n);
k(t) || b(231, n);
const o = ie(t, e.getElementByKey(n));
return o === null && b(232, n), { tableElement: o, tableNode: t };
}
class Bn {
constructor(e, t) {
this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.listenersToRemove = /* @__PURE__ */ new Set(), this.tableNodeKey = t, this.editor = e, this.table = { columns: 0, domRows: [], rows: 0 }, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.isSelecting = !1, this.pointerType = null, this.shouldCheckSelection = !1, this.abortController = new AbortController(), this.listenerOptions = { signal: this.abortController.signal }, this.nextFocus = null, this.trackTable();
}
getTable() {
return this.table;
}
removeListeners() {
this.abortController.abort("removeListeners"), Array.from(this.listenersToRemove).forEach((e) => e()), this.listenersToRemove.clear();
}
$lookup() {
return Et(this.tableNodeKey, this.editor);
}
trackTable() {
const e = new MutationObserver((t) => {
this.editor.getEditorState().read(() => {
let o = !1;
for (let r = 0; r < t.length; r++) {
const i = t[r].target.nodeName;
if (i === "TABLE" || i === "TBODY" || i === "THEAD" || i === "TR") {
o = !0;
break;
}
}
if (!o) return;
const { tableNode: l, tableElement: s } = this.$lookup();
this.table = me(l, s);
}, { editor: this.editor });
});
this.editor.getEditorState().read(() => {
const { tableNode: t, tableElement: o } = this.$lookup();
this.table = me(t, o), e.observe(o, { attributes: !0, childList: !0, subtree: !0 });
}, { editor: this.editor });
}
$clearHighlight() {
const e = this.editor;
this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.$enableHighlightStyle();
const { tableNode: t, tableElement: o } = this.$lookup();
Fe(e, me(t, o), null), B() !== null && (ne(null), e.dispatchCommand(fe, void 0));
}
$enableHighlightStyle() {
const e = this.editor, { tableElement: t } = this.$lookup();
ge(t, e._config.theme.tableSelection), t.classList.remove("disable-selection"), this.hasHijackedSelectionStyles = !1;
}
$disableHighlightStyle() {
const { tableElement: e } = this.$lookup();
Q(e, this.editor._config.theme.tableSelection), this.hasHijackedSelectionStyles = !0;
}
$updateTableTableSelection(e) {
if (e !== null) {
e.tableKey !== this.tableNodeKey && b(233, e.tableKey, this.tableNodeKey);
const t = this.editor;
this.tableSelection = e, this.isHighlightingCells = !0, this.$disableHighlightStyle(), this.updateDOMSelection(), Fe(t, this.table, this.tableSelection);
} else this.$clearHighlight();
}
setShouldCheckSelection() {
this.shouldCheckSelection = !0;
}
getAndClearShouldCheckSelection() {
return !!this.shouldCheckSelection && (this.shouldCheckSelection = !1, !0);
}
setNextFocus(e) {
this.nextFocus = e;
}
getAndClearNextFocus() {
const { nextFocus: e } = this;
return e !== null && (this.nextFocus = null), e;
}
updateDOMSelection() {
if (this.anchorCell !== null && this.focusCell !== null) {
const e = $e(this.editor._window);
e && e.rangeCount > 0 && e.removeAllRanges();
}
}
$setFocusCellForSelection(e, t = !1) {
const o = this.editor, { tableNode: l } = this.$lookup(), s = e.x, r = e.y;
if (this.focusCell = e, this.isHighlightingCells || this.anchorX === s && this.anchorY === r && !t) {
if (s === this.focusX && r === this.focusY) return !1;
} else this.isHighlightingCells = !0, this.$disableHighlightStyle();
if (this.focusX = s, this.focusY = r, this.isHighlightingCells) {
const i = qe(l, e.elem);
if (this.tableSelection != null && this.anchorCellNodeKey != null && i !== null) return this.focusCellNodeKey = i.getKey(), this.tableSelection = Hn(l, this.$getAnchorTableCellOrThrow(), i), ne(this.tableSelection), o.dispatchCommand(fe, void 0), Fe(o, this.table, this.tableSelection), !0;
}
return !1;
}
$getAnchorTableCell() {
return this.anchorCellNodeKey ? Ke(this.anchorCellNodeKey) : null;
}
$getAnchorTableCellOrThrow() {
const e = this.$getAnchorTableCell();
return e === null && b(234), e;
}
$getFocusTableCell() {
return this.focusCellNodeKey ? Ke(this.focusCellNodeKey) : null;
}
$getFocusTableCellOrThrow() {
const e = this.$getFocusTableCell();
return e === null && b(235), e;
}
$setAnchorCellForSelection(e) {
this.isHighlightingCells = !1, this.anchorCell = e, this.anchorX = e.x, this.anchorY = e.y;
const { tableNode: t } = this.$lookup(), o = qe(t, e.elem);
if (o !== null) {
const l = o.getKey();
this.tableSelection = this.tableSelection != null ? this.tableSelection.clone() : At(), this.anchorCellNodeKey = l;
}
}
$formatCells(e) {
const t = B();
K(t) || b(236);
const o = pn(), l = o.anchor, s = o.focus, r = t.getNodes().filter(w);
r.length > 0 || b(237);
const i = r[0].getFirstChild(), u = Ge(i) ? i.getFormatFlags(e, null) : null;
r.forEach((m) => {
l.set(m.getKey(), 0, "element"), s.set(m.getKey(), m.getChildrenSize(), "element"), o.formatText(e, u);
}), ne(t), this.editor.dispatchCommand(fe, void 0);
}
$clearText() {
const { editor: e } = this, t = Ke(this.tableNodeKey);
if (!k(t)) throw new Error("Expected TableNode.");
const o = B();
K(o) || b(253);
const l = o.getNodes().filter(w);
if (l.length === this.table.columns * this.table.rows) {
t.selectPrevious();
const s = t.getParent();
return t.remove(), void (Cn(s) && s.isEmpty() && e.dispatchCommand(Ft, void 0));
}
l.forEach((s) => {
if (D(s)) {
const r = I(), i = Qe();
r.append(i), s.append(r), s.getChildren().forEach((u) => {
u !== r && u.remove();
});
}
}), Fe(e, this.table, null), ne(null), e.dispatchCommand(fe, void 0);
}
}
const Xe = "__lexicalTableSelection", Dn = (n) => !(1 & ~n.buttons);
function de(n) {
return ye(n) && n.nodeName === "TABLE";
}
function ie(n, e) {
if (!e) return e;
const t = de(e) ? e : n.getDOMSlot(e).element;
return t.nodeName !== "TABLE" && b(245, e.nodeName), t;
}
function nt(n) {
return n._window;
}
function Ne(n, e) {
for (let t = e, o = null; t !== null; t = t.getParent()) {
if (n.is(t)) return o;
w(t) && (o = t);
}
return null;
}
const In = [[Gt, "down"], [en, "up"], [tn, "backward"], [nn, "forward"]], Un = [rn, Rt, ln], Jn = [sn, an];
function Yn(n, e, t, o) {
const l = t.getRootElement(), s = nt(t);
l !== null && s !== null || b(246);
const r = new Bn(t, n.getKey()), i = ie(n, e);
(function(a, c) {
pt(a) !== null && b(205), a[Xe] = c;
})(i, r), r.listenersToRemove.add(() => function(a, c) {
pt(a) === c && delete a[Xe];
}(i, r));
const u = (a) => {
if (r.pointerType = a.pointerType, a.button !== 0 || !be(a.target) || !s) return;
const c = ke(a.target);
c !== null && t.update(() => {
const f = Ue();
if (ft && a.shiftKey && Z(f, n) && (z(f) || K(f))) {
const d = f.anchor.getNode(), g = Ne(n, f.anchor.getNode());
g ? (r.$setAnchorCellForSelection(se(r, g)), r.$setFocusCellForSelection(c), te(a)) : (n.isBefore(d) ? n.selectStart() : n.selectEnd()).anchor.set(f.anchor.key, f.anchor.offset, f.anchor.type);
} else r.$setAnchorCellForSelection(c);
}), (() => {
if (r.isSelecting) return;
const f = () => {
r.isSelecting = !1, s.removeEventListener("pointerup", f), s.removeEventListener("pointermove", d);
}, d = (g) => {
if (!Dn(g) && r.isSelecting) return r.isSelecting = !1, s.removeEventListener("pointerup", f), void s.removeEventListener("pointermove", d);
if (!be(g.target)) return;
let _ = null;
const S = !(ft || i.contains(g.target));
if (S) _ = Ct(i, g.target);
else for (const N of document.elementsFromPoint(g.clientX, g.clientY)) if (_ = Ct(i, N), _) break;
!_ || r.focusCell !== null && _.elem === r.focusCell.elem || (r.setNextFocus({ focusCell: _, override: S }), t.dispatchCommand(fe, void 0));
};
r.isSelecting = !0, s.addEventListener("pointerup", f, r.listenerOptions), s.addEventListener("pointermove", d, r.listenerOptions);
})();
};
i.addEventListener("pointerdown", u, r.listenerOptions), r.listenersToRemove.add(() => {
i.removeEventListener("pointerdown", u);
});
const m = (a) => {
a.detail >= 3 && be(a.target) && ke(a.target) !== null && a.preventDefault();
};
i.addEventListener("mousedown", m, r.listenerOptions), r.listenersToRemove.add(() => {
i.removeEventListener("mousedown", m);
});
const h = (a) => {
const c = a.target;
a.button === 0 && be(c) && t.update(() => {
const f = B();
K(f) && f.tableKey === r.tableNodeKey && l.contains(c) && r.$clearHighlight();
});
};
s.addEventListener("pointerdown", h, r.listenerOptions), r.listenersToRemove.add(() => {
s.removeEventListener("pointerdown", h);
});
for (const [a, c] of In) r.listenersToRemove.add(t.registerCommand(a, (f) => Mt(t, f, c, n, r), De));
r.listenersToRemove.add(t.registerCommand(on, (a) => {
const c = B();
if (K(c)) {
const f = Ne(n, c.focus.getNode());
if (f !== null) return te(a), f.selectEnd(), !0;
}
return !1;
}, De));
const p = (a) => () => {
const c = B();
if (!Z(c, n)) return !1;
if (K(c)) return r.$clearText(), !0;
if (z(c)) {
if (!w(Ne(n, c.anchor.getNode()))) return !1;
const f = c.anchor.getNode(), d = c.focus.getNode(), g = n.isParentOf(f), _ = n.isParentOf(d);
if (g && !_ || _ && !g) return r.$clearText(), !0;
const S = T(c.anchor.getNode(), (y) => D(y)), N = S && T(S, (y) => D(y) && w(y.getParent()));
if (!D(N) || !D(S)) return !1;
if (a === Rt && N.getPreviousSibling() === null) return !0;
}
return !1;
};
for (const a of Un) r.listenersToRemove.add(t.registerCommand(a, p(a), V));
const C = (a) => {
const c = B();
if (!K(c) && !z(c)) return !1;
const f = n.isParentOf(c.anchor.getNode());
if (f !== n.isParentOf(c.focus.getNode())) {
const d = f ? "anchor" : "focus", g = f ? "focus" : "anchor", { key: _, offset: S, type: N } = c[g];
return n[c[d].isBefore(c[g]) ? "selectPrevious" : "selectNext"]()[g].set(_, S, N), !1;
}
return !!Z(c, n) && !!K(c) && (a && (a.preventDefault(), a.stopPropagation()), r.$clearText(), !0);
};
for (const a of Jn) r.listenersToRemove.add(t.registerCommand(a, C, V));
return r.listenersToRemove.add(t.registerCommand(cn, (a) => {
const c = B();
if (c) {
if (!K(c) && !z(c)) return !1;
Fn(t, qt(a, ClipboardEvent) ? a : null, vn(c));
const f = C(a);
return z(c) ? (c.removeText(), !0) : f;
}
return !1;
}, V)), r.listenersToRemove.add(t.registerCommand(un, (a) => {
const c = B();
if (!Z(c, n)) return !1;
if (K(c)) return r.$formatCells(a), !0;
if (z(c)) {
const f = T(c.anchor.getNode(), (d) => w(d));
if (!w(f)) return !1;
}
return !1;
}, V)), r.listenersToRemove.add(t.registerCommand(hn, (a) => {
const c = B();
if (!K(c) || !Z(c, n)) return !1;
const f = c.anchor.getNode(), d = c.focus.getNode();
if (!w(f) || !w(d)) return !1;
if (function(O, A) {
if (K(O)) {
const F = O.anchor.getNode(), E = O.focus.getNode();
if (A && F && E) {
const [L] = J(A, F, E);
return F.getKey() === L[0][0].cell.getKey() && E.getKey() === L[L.length - 1].at(-1).cell.getKey();
}
}
return !1;
}(c, n)) return n.setFormat(a), !0;
const [g, _, S] = J(n, f, d), N = Math.max(_.startRow + _.cell.__rowSpan - 1, S.startRow + S.cell.__rowSpan - 1), y = Math.max(_.startColumn + _.cell.__colSpan - 1, S.startColumn + S.cell.__colSpan - 1), R = Math.min(_.startRow, S.startRow), v = Math.min(_.startColumn, S.startColumn), M = /* @__PURE__ */ new Set();
for (let O = R; O <= N; O++) for (let A = v; A <= y; A++) {
const F = g[O][A].cell;
if (M.has(F)) continue;
M.add(F), F.setFormat(a);
const E = F.getChildren();
for (let L = 0; L < E.length; L++) {
const H = E[L];
D(H) && !H.isInline() && H.setFormat(a);
}
}
return !0;
}, V)), r.listenersToRemove.add(t.registerCommand(dn, (a) => {
const c = B();
if (!Z(c, n)) return !1;
if (K(c)) return r.$clearHighlight(), !1;
if (z(c)) {
const f = T(c.anchor.getNode(), (d) => w(d));
if (!w(f)) return !1;
if (typeof a == "string") {
const d = wt(t, c, n);
if (d) return St(d, n, [Qe(a)]), !0;
}
}
return !1;
}, V)), o && r.listenersToRemove.add(t.registerCommand(fn, (a) => {
const c = B();
if (!z(c) || !c.isCollapsed() || !Z(c, n)) return !1;
const f = we(c.anchor.getNode());
return !(f === null || !n.is(pe(f))) && (te(a), function(d, g) {
const _ = g === "next" ? "getNextSibling" : "getPreviousSibling", S = g === "next" ? "getFirstChild" : "getLastChild", N = d[_]();
if (D(N)) return N.selectEnd();
const y = T(d, $);
y === null && b(247);
for (let v = y[_](); $(v); v = v[_]()) {
const M = v[S]();
if (D(M)) return M.selectEnd();
}
const R = T(y, k);
R === null && b(248), g === "next" ? R.selectNext() : R.selectPrevious();
}(f, a.shiftKey ? "previous" : "next"), !0);
}, V)), r.listenersToRemove.add(t.registerCommand(gn, (a) => n.isSelected(), De)), r.listenersToRemove.add(t.registerCommand(Tt, (a) => {
const { nodes: c, selection: f } = a, d = f.getStartEndPoints(), g = K(f), _ = z(f) && T(f.anchor.getNode(), (x) => w(x)) !== null && T(f.focus.getNode(), (x) => w(x)) !== null || g;
if (c.length !== 1 || !k(c[0]) || !_ || d === null) return !1;
const [S, N] = d, [y, R, v] = G(S), M = T(N.getNode(), (x) => w(x));
if (!(w(y) && w(M) && $(R) && k(v))) return !1;
const O = c[0], [A, F, E] = J(v, y, M), [L] = oe(O, null, null), H = A.length, le = H > 0 ? A[0].length : 0;
let X = F.startRow, q = F.startColumn, P = L.length, ue = P > 0 ? L[0].length : 0;
if (g) {
const x = Ee(A, F, E), U = x.maxRow - x.minRow + 1, j = x.maxColumn - x.minColumn + 1;
X = x.minRow, q = x.minColumn, P = Math.min(P, U), ue = Math.min(ue, j);
}
let Le = !1;
const zt = Math.min(H, X + P) - 1, Wt = Math.min(le, q + ue) - 1, lt = /* @__PURE__ */ new Set();
for (let x = X; x <= zt; x++) for (let U = q; U <= Wt; U++) {
const j = A[x][U];
lt.has(j.cell.getKey()) || j.cell.__rowSpan === 1 && j.cell.__colSpan === 1 || (Wn(j.cell), lt.add(j.cell.getKey()), Le = !0);
}
let [_e] = oe(v.getWritable(), null, null);
const Ht = P - H + X;
for (let x = 0; x < Ht; x++)
kn(_e[H - 1][0].cell);
const Pt = ue - le + q;
for (let x = 0; x < Pt; x++)
$n(_e[0][le - 1].cell, !0, !1);
[_e] = oe(v.getWritable(), null, null);
for (let x = X; x < X + P; x++) for (let U = q; U < q + ue; U++) {
const j = x - X, st = U - q, ze = L[j][st];
if (ze.startRow !== j || ze.startColumn !== st) continue;
const Se = ze.cell;
if (Se.__rowSpan !== 1 || Se.__colSpan !== 1) {
const ee = [], Dt = Math.min(x + Se.__rowSpan, X + P) - 1, It = Math.min(U + Se.__colSpan, q + ue) - 1;
for (let He = x; He <= Dt; He++) for (let Pe = U; Pe <= It; Pe++) {
const Ut = _e[He][Pe];
ee.push(Ut.cell);
}
Ln(ee), Le = !0;
}
const { cell: We } = _e[x][U], Bt = We.getChildren();
Se.getChildren().forEach((ee) => {
Ce(ee) && I().append(ee), We.append(ee);
}), Bt.forEach((ee) => ee.remove());
}
if (g && Le) {
const [x] = oe(v.getWritable(), null, null);
x[F.startRow][F.startColumn].cell.selectEnd();
}
return !0;
}, V)), r.listenersToRemove.add(t.registerCommand(fe, () => {
const a = B(), c = Ue(), f = r.getAndClearNextFocus();
if (f !== null) {
const { focusCell: d } = f;
if (K(a) && a.tableKey === r.tableNodeKey) return (d.x !== r.focusX || d.y !== r.focusY) && (r.$setFocusCellForSelection(d), !0);
if (d !== r.anchorCell && Z(a, n)) return r.$setFocusCellForSelection(d), !0;
}
if (r.getAndClearShouldCheckSelection() && z(c) && z(a) && a.isCollapsed()) {
const d = a.anchor.getNode(), g = n.getFirstChild(), _ = we(d);
if (_ !== null && $(g)) {
const S = g.getFirstChild();
if (w(S) && n.is(T(_, (N) => N.is(n) || N.is(S)))) return S.selectStart(), !0;
}
}
if (z(a)) {
const { anchor: d, focus: g } = a, _ = d.getNode(), S = g.getNode(), N = we(_), y = we(S), R = !(!N || !n.is(pe(N))), v = !(!y || !n.is(pe(y))), M = R !== v, O = R && v, A = a.isBackward();
if (M) {
const F = a.clone();
if (v) {
const [E] = J(n, y, y), L = E[0][0].cell, H = E[E.length - 1].at(-1).cell;
F.focus.set(A ? L.getKey() : H.getKey(), A ? L.getChildrenSize() : H.getChildrenSize(), "element");
} else if (R) {
const [E] = J(n, N, N), L = E[0][0].cell, H = E[E.length - 1].at(-1).cell;
F.anchor.set(A ? H.getKey() : L.getKey(), A ? H.getChildrenSize() : 0, "element");
}
ne(F), _t(t, r);
} else if (O && (N.is(y) || (r.$setAnchorCellForSelection(se(r, N)), r.$setFocusCellForSelection(se(r, y), !0)), r.pointerType === "touch" && a.isCollapsed() && z(c) && c.isCollapsed())) {
const F = we(c.anchor.getNode());
F && !F.is(y) && (r.$setAnchorCellForSelection(se(r, F)), r.$setFocusCellForSelection(se(r, y), !0), r.pointerType = null);
}
} else if (a && K(a) && a.is(c) && a.tableKey === n.getKey()) {
const d = $e(s);
if (d && d.anchorNode && d.focusNode) {
const g = re(d.focusNode), _ = g && !n.isParentOf(g), S = re(d.anchorNode), N = S && n.isParentOf(S);
if (_ && N && d.rangeCount > 0) {
const y = mn(d, t);
y && (y.anchor.set(n.getKey(), a.isBackward() ? n.getChildrenSize() : 0, "element"), d.removeAllRanges(), ne(y));
}
}
}
return a && !a.is(c) && (K(a) || K(c)) && r.tableSelection && !r.tableSelection.is(c) ? (K(a) && a.tableKey === r.tableNodeKey ? r.$updateTableTableSelection(a) : !K(a) && K(c) && c.tableKey === r.tableNodeKey && r.$updateTableTableSelection(null), !1) : (r.hasHijackedSelectionStyles && !n.isSelected() ? function(d, g) {
g.$enableHighlightStyle(), ot(g.table, (_) => {
const S = _.elem;
_.highlighted = !1, $t(d, _), S.getAttribute("style") || S.removeAttribute("style");
});
}(t, r) : !r.hasHijackedSelectionStyles && n.isSelected() && _t(t, r), !1);
}, V)), r.listenersToRemove.add(t.registerCommand(Ft, () => {
const a = B();
if (!z(a) || !a.isCollapsed() || !Z(a, n)) return !1;
const c = wt(t, a, n);
return !!c && (St(c, n), !0);
}, V)), r;
}
function pt(n) {
return n[Xe] || null;
}
function ke(n) {
let e = n;
for (; e != null; ) {
const t = e.nodeName;
if (t === "TD" || t === "TH") {
const o = e._cell;
return o === void 0 ? null : o;
}
e = e.parentNode;
}
return null;
}
function Ct(n, e) {
if (!n.contains(e)) return null;
let t = null;
for (let o = e; o != null; o = o.parentNode) {
if (o === n) return t;
const l = o.nodeName;
l !== "TD" && l !== "TH" || (t = o._cell || null);
}
return null;
}
function me(n, e) {
const t = [], o = { columns: 0, domRows: t, rows: 0 };
let l = ie(n, e).querySelector("tr"), s = 0, r = 0;
for (t.length = 0; l != null; ) {
const i = l.nodeName;
if (i === "TD" || i === "TH") {
const h = { elem: l, hasBackgroundColor: l.style.backgroundColor !== "", highlighted: !1, x: s, y: r };
l._cell = h;
let p = t[r];
p === void 0 && (p = t[r] = []), p[s] = h;
} else {
const h = l.firstChild;
if (h != null) {
l = h;
continue;
}
}
const u = l.nextSibling;
if (u != null) {
s++, l = u;
continue;
}
const m = l.parentNode;
if (m != null) {
const h = m.nextSibling;
if (h == null) break;
r++, s = 0, l = h;
}
}
return o.columns = s + 1, o.rows = r + 1, o;
}
function Fe(n, e, t) {
const o = new Set(t ? t.getNodes() : []);
ot(e, (l, s) => {
const r = l.elem;
o.has(s) ? (l.highlighted = !0, kt(n, l)) : (l.highlighted = !1, $t(n, l), r.getAttribute("style") || r.removeAttribute("style"));
});
}
function ot(n, e) {
const { domRows: t } = n;
for (let o = 0; o < t.length; o++) {
const l = t[o];
if (l) for (let s = 0; s < l.length; s++) {
const r = l[s];
if (!r) continue;
const i = re(r.elem);
i !== null && e(r, i, { x: s, y: o });
}
}
}
function _t(n, e) {
e.$disableHighlightStyle(), ot(e.table, (t) => {
t.highlighted = !0, kt(n, t);
});
}
const Xn = (n, e, t, o, l) => {
const s = l === "forward";
switch (l) {
case "backward":
case "forward":
return t !== (s ? n.table.columns - 1 : 0) ? Oe(e.getCellNodeFromCordsOrThrow(t + (s ? 1 : -1), o, n.table), s) : o !== (s ? n.table.rows - 1 : 0) ? Oe(e.getCellNodeFromCordsOrThrow(s ? 0 : n.table.columns - 1, o + (s ? 1 : -1), n.table), s) : s ? e.selectNext() : e.selectPrevious(), !0;
case "up":
return o !== 0 ? Oe(e.getCellNodeFromCordsOrThrow(t, o - 1, n.table), !1) : e.selectPrevious(), !0;
case "down":
return o !== n.table.rows - 1 ? Oe(e.getCellNodeFromCordsOrThrow(t, o + 1, n.table), !0) : e.selectNext(), !0;
default:
return !1;
}
};
function Ie(n, e) {
let t, o;
if (e.startColumn === n.minColumn) t = "minColumn";
else {
if (e.startColumn + e.cell.__colSpan - 1 !== n.maxColumn) return null;
t = "maxColumn";
}
if (e.startRow === n.minRow) o = "minRow";
else {
if (e.startRow + e.cell.__rowSpan - 1 !== n.maxRow) return null;
o = "maxRow";
}
return [t, o];
}
function ve([n, e]) {
return [n === "minColumn" ? "maxColumn" : "minColumn", e === "minRow" ? "maxRow" : "minRow"];
}
function he(n, e, [t, o]) {
const l = e[o], s = n[l];
s === void 0 && b(250, o, String(l));
const r = e[t], i = s[r];
return i === void 0 && b(250, t, String(r)), i;
}
function qn(n, e, t, o, l) {
const s = Ee(e, t, o), r = function(R, v) {
const { minColumn: M, maxColumn: O, minRow: A, maxRow: F } = v;
let E = 1, L = 1, H = 1, le = 1;
const X = R[A], q = R[F];
for (let P = M; P <= O; P++) E = Math.max(E, X[P].cell.__rowSpan), le = Math.max(le, q[P].cell.__rowSpan);
for (let P = A; P <= F; P++) L = Math.max(L, R[P][M].cell.__colSpan), H = Math.max(H, R[P][O].cell.__colSpan);
return { bottomSpan: le, leftSpan: L, rightSpan: H, topSpan: E };
}(e, s), { topSpan: i, leftSpan: u, bottomSpan: m, rightSpan: h } = r, p = function(R, v) {
const M = Ie(R, v);
return M === null && b(249, v.cell.getKey()), M;
}(s, t), [C, a] = ve(p);
let c = s[C], f = s[a];
l === "forward" ? c += C === "maxColumn" ? 1 : u : l === "backward" ? c -= C === "minColumn" ? 1 : h : l === "down" ? f += a === "maxRow" ? 1 : i : l === "up" && (f -= a === "minRow" ? 1 : m);
const d = e[f];
if (d === void 0) return !1;
const g = d[c];
if (g === void 0) return !1;
const [_, S] = function(R, v, M) {
const O = Ee(R, v, M), A = Ie(O, v);
if (A) return [he(R, O, A), he(R, O, ve(A))];
const F = Ie(O, M);
if (F) return [he(R, O, ve(F)), he(R, O, F)];
const E = ["minColumn", "minRow"];
return [he(R, O, E), he(R, O, ve(E))];
}(e, t, g), N = se(n, _.cell), y = se(n, S.cell);
return n.$setAnchorCellForSelection(N), n.$setFocusCellForSelection(y, !0), !0;
}
function Z(n, e) {
if (z(n) || K(n)) {
const t = e.isParentOf(n.anchor.getNode()), o = e.isParentOf(n.focus.getNode());
return t && o;
}
return !1;
}
function Oe(n, e) {
e ? n.selectStart() : n.selectEnd();
}
function kt(n, e) {
const t = e.elem, o = n._config.theme;
w(re(t)) || b(131), Q(t, o.tableCellSelected);
}
function $t(n, e) {
const t = e.elem;
w(re(t)) || b(131);
const o = n._config.theme;
ge(t, o.tableCellSelected);
}
function we(n) {
const e = T(n, w);
return w(e) ? e : null;
}
function pe(n) {
const e = T(n, k);
return k(e) ? e : null;
}
function jn(n, e, t, o, l, s, r) {
const i = Sn(t.focus, l ? "previous" : "next");
if (wn(i)) return !1;
let u = i;
for (const d of at(i).iterNodeCarets("shadowRoot")) {
if (!bn(d) || !D(d.origin)) return !1;
u = d;
}
const m = u.getParentAtCaret();
if (!w(m)) return !1;
const h = m, p = function(d) {
for (const g of at(d).iterNodeCarets("root")) {
const { origin: _ } = g;
if (w(_)) {
if (ct(g)) return yn(_, d.direction);
} else if (!$(_)) break;
}
return null;
}(ut(h, u.direction)), C = T(h, k);
if (!C || !C.is(s)) return !1;
const a = n.getElementByKey(h.getKey()), c = ke(a);
if (!a || !c) return !1;
const f = Vn(n, C);
if (r.table = f, p) if (o === "extend") {
const d = ke(n.getElementByKey(p.origin.getKey()));
if (!d) return !1;
r.$setAnchorCellForSelection(c), r.$setFocusCellForSelection(d, !0);
} else {
const d = ht(p);
Re(t.anchor, d), Re(t.focus, d);
}
else if (o === "extend") r.$setAnchorCellForSelection(c), r.$setFocusCellForSelection(c, !0);
else {
const d = function(g) {
const _ = Nn(g);
return ct(_) ? ht(_) : g;
}(ut(C, i.direction));
Re(t.anchor, d), Re(t.focus, d);
}
return te(e), !0;
}
function Mt(n, e, t, o, l) {
if ((t === "up" || t === "down") && function(r) {
const i = r.getRootElement();
return i ? i.hasAttribute("aria-controls") && i.getAttribute("aria-controls") === "typeahead-menu" : !1;
}(n)) return !1;
const s = B();
if (!Z(s, o)) {
if (z(s)) {
if (t === "backward") {
if (s.focus.offset > 0) return !1;
const r = function(u) {
for (let m = u, h = u; h !== null; m = h, h = h.getParent()) if (D(h)) {
if (h !== m && h.getFirstChild() !== m) return null;
if (!h.isInline()) return h;
}
return null;
}(s.focus.getNode());
if (!r) return !1;
const i = r.getPreviousSibling();
return !!k(i) && (te(e), e.shiftKey ? s.focus.set(i.getParentOrThrow().getKey(), i.getIndexWithinParent(), "element") : i.selectEnd(), !0);
}
if (e.shiftKey && (t === "up" || t === "down")) {
const r = s.focus.getNode();
if (!s.isCollapsed() && (t === "up" && !s.isBackward() || t === "down" && s.isBackward())) {
let i = T(r, (C) => k(C));
if (w(i) && (i = T(i, k)), i !== o || !i) return !1;
const u = t === "down" ? i.getNextSibling() : i.getPreviousSibling();
if (!u) return !1;
let m = 0;
t === "up" && D(u) && (m = u.getChildrenSize());
let h = u;
t === "up" && D(u) && (h = u.getLastChild() || u, m = Ce(h) ? h.getTextContentSize() : 0);
const p = s.clone();
return p.focus.set(h.getKey(), m, Ce(h) ? "text" : "element"), ne(p), te(e), !0;
}
if (_n(r)) {
const i = t === "up" ? s.getNodes()[s.getNodes().length - 1] : s.getNodes()[0];
if (i && Ne(o, i) !== null) {
const u = o.getFirstDescendant(), m = o.getLastDescendant();
if (!u || !m) return !1;
const [h] = G(u), [p] = G(m), C = o.getCordsFromCellNode(h, l.table), a = o.getCordsFromCellNode(p, l.table), c = o.getDOMCellFromCordsOrThrow(C.x, C.y, l.table), f = o.getDOMCellFromCordsOrThrow(a.x, a.y, l.table);
return l.$setAnchorCellForSelection(