monowind 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -327,7 +327,7 @@ x("single", {
327
327
  dashed: A,
328
328
  dotted: A
329
329
  });
330
- function j(e) {
330
+ function ee(e) {
331
331
  return {
332
332
  track: e?.solid?.scrollTrack ?? "░",
333
333
  thumb: e?.solid?.scrollThumb ?? "█"
@@ -341,57 +341,57 @@ x("blocks", {
341
341
  });
342
342
  //#endregion
343
343
  //#region src/warn.ts
344
- var M = /* @__PURE__ */ new WeakMap();
345
- function N(e, t) {
346
- let n = M.get(e);
347
- n || M.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, ee(e)));
344
+ var j = /* @__PURE__ */ new WeakMap();
345
+ function M(e, t) {
346
+ let n = j.get(e);
347
+ n || j.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, te(e)));
348
348
  }
349
- function ee(e) {
349
+ function te(e) {
350
350
  if (!globalThis.process?.versions?.node) return e;
351
351
  let t = e.id ? `#${e.id}` : "", n = e.classList.length ? `.${Array.from(e.classList).join(".")}` : "";
352
352
  return `<${e.tagName.toLowerCase()}${t}${n}>`;
353
353
  }
354
354
  //#endregion
355
355
  //#region src/leaf.ts
356
- var te = /* @__PURE__ */ new Map(), ne = /* @__PURE__ */ new Set();
357
- function re(e) {
356
+ var ne = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Set();
357
+ function ie(e) {
358
358
  let t = e.tag.toLowerCase();
359
359
  if (!t.includes("-")) {
360
360
  console.warn(`[monowind] registerLeafRenderer: "${e.tag}" is not a custom-element tag name (needs a hyphen); ignored.`);
361
361
  return;
362
362
  }
363
- te.has(t) && console.warn(`[monowind] registerLeafRenderer: replacing existing renderer for <${t}> (last registration wins).`), te.set(t, {
363
+ ne.has(t) && console.warn(`[monowind] registerLeafRenderer: replacing existing renderer for <${t}> (last registration wins).`), ne.set(t, {
364
364
  ...e,
365
365
  tag: t
366
- }), le();
366
+ }), ue();
367
367
  }
368
- function ie() {
369
- le();
368
+ function ae() {
369
+ ue();
370
370
  }
371
- function ae(e) {
372
- return te.get(e.toLowerCase());
371
+ function oe(e) {
372
+ return ne.get(e.toLowerCase());
373
373
  }
374
- function oe() {
374
+ function se() {
375
375
  let e = /* @__PURE__ */ new Set();
376
- for (let t of te.values()) for (let n of t.observedAttributes ?? []) e.add(n.toLowerCase());
376
+ for (let t of ne.values()) for (let n of t.observedAttributes ?? []) e.add(n.toLowerCase());
377
377
  return [...e];
378
378
  }
379
- function se(e) {
380
- return ne.add(e), () => ne.delete(e);
379
+ function ce(e) {
380
+ return re.add(e), () => re.delete(e);
381
381
  }
382
- function ce(e, t) {
382
+ function le(e, t) {
383
383
  try {
384
384
  return e.render(t);
385
385
  } catch (n) {
386
- return N(t, `<${e.tag}> renderer threw; rendering nothing. ${String(n)}`), null;
386
+ return M(t, `<${e.tag}> renderer threw; rendering nothing. ${String(n)}`), null;
387
387
  }
388
388
  }
389
- function le() {
390
- for (let e of ne) e();
389
+ function ue() {
390
+ for (let e of re) e();
391
391
  }
392
392
  //#endregion
393
393
  //#region src/borders.ts
394
- function ue(e, t, n) {
394
+ function de(e, t, n) {
395
395
  let r = e.border;
396
396
  if (r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0) return;
397
397
  let i = Math.max(r.top, r.right, r.bottom, r.left);
@@ -407,11 +407,11 @@ function ue(e, t, n) {
407
407
  width: t.width - (i.left ? a : 0) - (i.right ? a : 0),
408
408
  height: t.height - (i.top ? a : 0) - (i.bottom ? a : 0)
409
409
  };
410
- o.width <= 0 || o.height <= 0 || de(n, e.borderStyle, e.borderColor, o, i, S(e.glyphSet));
410
+ o.width <= 0 || o.height <= 0 || fe(n, e.borderStyle, e.borderColor, o, i, S(e.glyphSet));
411
411
  }
412
412
  }
413
- function de(e, t, n, r, i, a) {
414
- let o = ge(t.top, a), s = ge(t.right, a), c = ge(t.bottom, a), l = ge(t.left, a), u = (e, t, n) => n(ge(e === t ? e : "solid", a)), { x: d, y: f, width: p, height: m } = r, h = p >= 2 && m >= 2, g = d + +!!i.left, _ = d + p - +!!i.right, v = f + +!!i.top, y = f + m - +!!i.bottom;
413
+ function fe(e, t, n, r, i, a) {
414
+ let o = _e(t.top, a), s = _e(t.right, a), c = _e(t.bottom, a), l = _e(t.left, a), u = (e, t, n) => n(_e(e === t ? e : "solid", a)), { x: d, y: f, width: p, height: m } = r, h = p >= 2 && m >= 2, g = d + +!!i.left, _ = d + p - +!!i.right, v = f + +!!i.top, y = f + m - +!!i.bottom;
415
415
  if (i.top && _ > g && e.push({
416
416
  glyph: o.h,
417
417
  x: g,
@@ -464,13 +464,13 @@ function de(e, t, n, r, i, a) {
464
464
  color: n.bottom
465
465
  }));
466
466
  }
467
- function fe(e, t) {
467
+ function pe(e, t) {
468
468
  return e.style.position !== "static" || (t.style.display === "flex" || t.style.display === "grid") && e.style.zIndex !== null;
469
469
  }
470
- function pe(e) {
470
+ function me(e) {
471
471
  if (e.children.length <= 1) return e.children;
472
472
  let t = null, n = null, r = null, i = null;
473
- for (let a of e.children) fe(a, e) ? (a.style.zIndex ?? 0) < 0 ? (t ??= []).push(a) : (i ??= []).push(a) : a.inlineBox ? (r ??= []).push(a) : (n ??= []).push(a);
473
+ for (let a of e.children) pe(a, e) ? (a.style.zIndex ?? 0) < 0 ? (t ??= []).push(a) : (i ??= []).push(a) : a.inlineBox ? (r ??= []).push(a) : (n ??= []).push(a);
474
474
  return t && t.length > 1 && t.sort((e, t) => (e.style.zIndex ?? 0) - (t.style.zIndex ?? 0)), i && i.length > 1 && i.sort((e, t) => (e.style.zIndex ?? 0) - (t.style.zIndex ?? 0)), !t && n && !r && !i ? n : !t && !n && r && !i ? r : !t && !n && !r && i ? i : [
475
475
  ...t ?? [],
476
476
  ...n ?? [],
@@ -478,11 +478,11 @@ function pe(e) {
478
478
  ...i ?? []
479
479
  ];
480
480
  }
481
- function me(e, t, n) {
482
- let r = ge(e, n);
481
+ function he(e, t, n) {
482
+ let r = _e(e, n);
483
483
  return t === "h" ? r.h : r.v;
484
484
  }
485
- function he(e, t, n, r, i, a) {
485
+ function ge(e, t, n, r, i, a) {
486
486
  let o = (t ? 8 : 0) | (n ? 4 : 0) | (r ? 2 : 0) | !!i;
487
487
  if (a) {
488
488
  let t = w(o), n = t && a[e]?.[t];
@@ -490,8 +490,8 @@ function he(e, t, n, r, i, a) {
490
490
  }
491
491
  return (e === "double" ? E : T)[o];
492
492
  }
493
- function ge(e, t) {
494
- let n = (n, r, i, a) => he(e, n, r, i, a, t), r = {
493
+ function _e(e, t) {
494
+ let n = (n, r, i, a) => ge(e, n, r, i, a, t), r = {
495
495
  h: n(!1, !1, !0, !0),
496
496
  v: n(!0, !0, !1, !1),
497
497
  tl: n(!1, !0, !1, !0),
@@ -502,24 +502,24 @@ function ge(e, t) {
502
502
  return e === "dashed" ? {
503
503
  h: "╌",
504
504
  v: "╎",
505
- ..._e(r),
506
- ...ve(t, e)
505
+ ...ve(r),
506
+ ...ye(t, e)
507
507
  } : e === "dotted" ? {
508
508
  h: "┄",
509
509
  v: "┊",
510
- ..._e(r),
511
- ...ve(t, e)
510
+ ...ve(r),
511
+ ...ye(t, e)
512
512
  } : r;
513
513
  }
514
- function _e(e) {
514
+ function ve(e) {
515
515
  let { h: t, v: n, ...r } = e;
516
516
  return r;
517
517
  }
518
- function ve(e, t) {
518
+ function ye(e, t) {
519
519
  let n = e?.[t], r = {};
520
520
  return n?.h && (r.h = n.h), n?.v && (r.v = n.v), r;
521
521
  }
522
- function ye(e, t, n, r) {
522
+ function be(e, t, n, r) {
523
523
  let i = e.map((e) => e.spanned ? !1 : n === "between" ? e.beforeOccupied && e.afterOccupied : n !== "around" || e.beforeOccupied || e.afterOccupied), a = [];
524
524
  for (let n = 0; n < e.length; n++) if (a.push({
525
525
  start: e[n].start,
@@ -563,7 +563,7 @@ function ye(e, t, n, r) {
563
563
  end: e.end - r
564
564
  })).filter((e) => e.end > e.start);
565
565
  }
566
- function be(e) {
566
+ function xe(e) {
567
567
  let t = [], n = e.border.left + e.padding.left, r = e.border.top + e.padding.top, i = (e, t) => ({
568
568
  line: t.bandStart + Math.floor((t.bandSize - e.width) / 2),
569
569
  start: t.start,
@@ -572,7 +572,7 @@ function be(e) {
572
572
  endHalf: t.endHalf === !0
573
573
  }), a = e.ruleX ? e.vertical.map((t) => i(e.ruleX, t)) : [], o = e.ruleY ? e.horizontal.map((t) => i(e.ruleY, t)) : [], s = e.ruleX?.width ?? 0, c = e.ruleY?.width ?? 0, l = (e, t, n, r) => e.some((e) => n >= e.line && n < e.line + t && (e.start < r && e.end > r || e.end === r && !e.endHalf || e.start === r && !e.startHalf)), u = (e, t) => o.some((n) => t >= n.line && t < n.line + c && e >= n.start && e < n.end);
574
574
  if (e.ruleX) {
575
- let i = me(e.ruleX.style, "v", e.glyphs);
575
+ let i = he(e.ruleX.style, "v", e.glyphs);
576
576
  for (let o of a) {
577
577
  for (let a = 0; a < s; a++) for (let s = o.start; s < o.end; s++) u(o.line + a, s) || t.push({
578
578
  glyph: i,
@@ -581,7 +581,7 @@ function be(e) {
581
581
  length: 1,
582
582
  color: e.ruleX.color
583
583
  });
584
- xe(e, t, "x", o.line, o.start, o.end);
584
+ Se(e, t, "x", o.line, o.start, o.end);
585
585
  }
586
586
  }
587
587
  if (e.ruleY) {
@@ -592,7 +592,7 @@ function be(e) {
592
592
  for (let d = u.start; d < u.end; d++) {
593
593
  let u = l(a, s, d, f), p = l(a, s, d, f + 1);
594
594
  t.push({
595
- glyph: u || p ? he(i ? "double" : "solid", u, p, l(o, c, f, d), l(o, c, f, d + 1), e.glyphs) : me(e.ruleY.style, "h", e.glyphs),
595
+ glyph: u || p ? ge(i ? "double" : "solid", u, p, l(o, c, f, d), l(o, c, f, d + 1), e.glyphs) : he(e.ruleY.style, "h", e.glyphs),
596
596
  x: n + d,
597
597
  y: r + f,
598
598
  length: 1,
@@ -600,16 +600,16 @@ function be(e) {
600
600
  });
601
601
  }
602
602
  }
603
- xe(e, t, "y", u.line, u.start, u.end);
603
+ Se(e, t, "y", u.line, u.start, u.end);
604
604
  }
605
605
  }
606
606
  return t;
607
607
  }
608
- function xe(e, t, n, r, i, a) {
608
+ function Se(e, t, n, r, i, a) {
609
609
  let o = n === "x" ? e.ruleX : e.ruleY, s = e.border.left + e.padding.left, c = e.border.top + e.padding.top, l = s + e.contentWidth + e.padding.right + e.border.right, u = c + e.contentHeight + e.padding.bottom + e.border.bottom, d = (n, r, i, a, s, c, l, u) => {
610
610
  let d = o.style === "double" && i === "double" ? "double" : "solid";
611
611
  t.push({
612
- glyph: he(d, s, c, l, u, e.glyphs),
612
+ glyph: ge(d, s, c, l, u, e.glyphs),
613
613
  x: n,
614
614
  y: r,
615
615
  length: 1,
@@ -626,39 +626,17 @@ function xe(e, t, n, r, i, a) {
626
626
  }
627
627
  }
628
628
  //#endregion
629
- //#region src/pointer.ts
630
- function Se(e, t, n) {
631
- let r = [], i = e, a = e.localRect.x, o = e.localRect.y;
632
- for (;;) {
633
- let e = null;
634
- for (let r of pe(i)) {
635
- if (r.tableHidden) continue;
636
- let i = a + r.localRect.x, s = o + r.localRect.y;
637
- t >= i && t < i + r.localRect.width && n >= s && n < s + r.localRect.height && (e = r);
638
- }
639
- if (!e) return r;
640
- r.push({
641
- node: e,
642
- x: a + e.localRect.x,
643
- y: o + e.localRect.y
644
- }), a += e.localRect.x - (e.scroll?.x ?? 0), o += e.localRect.y - (e.scroll?.y ?? 0), i = e;
645
- }
646
- }
647
- function Ce(e, t, n) {
648
- return Se(e, t, n).map((e) => e.node.source);
649
- }
650
- //#endregion
651
629
  //#region src/metrics.ts
652
- function P(e) {
630
+ function N(e) {
653
631
  return (e >= 0 ? Math.floor(e + .5) : -Math.floor(-e + .5)) || 0;
654
632
  }
655
- function F(e, t) {
656
- return t <= 0 ? 0 : P(e / (.25 * t));
633
+ function P(e, t) {
634
+ return t <= 0 ? 0 : N(e / (.25 * t));
657
635
  }
658
- function we(e, t) {
659
- return P(t * e / 100);
636
+ function Ce(e, t) {
637
+ return N(t * e / 100);
660
638
  }
661
- function Te(e, t) {
639
+ function we(e, t) {
662
640
  let n = t.getBoundingClientRect(), r = parseFloat(getComputedStyle(e).letterSpacing) || 0, i = t.ownerDocument.createRange();
663
641
  i.selectNodeContents(t);
664
642
  let a = Math.max(0, i.getBoundingClientRect().height - n.height);
@@ -669,56 +647,56 @@ function Te(e, t) {
669
647
  inkOverhang: a
670
648
  };
671
649
  }
672
- function Ee() {
650
+ function Te() {
673
651
  return parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
674
652
  }
675
653
  //#endregion
676
654
  //#region src/wrap.ts
677
- function De(e, t, n = {}) {
678
- return je(e, t, n).map((t) => e.slice(t.start, t.end));
655
+ function Ee(e, t, n = {}) {
656
+ return Ae(e, t, n).map((t) => e.slice(t.start, t.end));
679
657
  }
680
- function Oe(e, t, n = {}) {
681
- return je(e, t, n).length;
658
+ function De(e, t, n = {}) {
659
+ return Ae(e, t, n).length;
682
660
  }
683
- function ke(e, t) {
661
+ function Oe(e, t) {
684
662
  return t.endsWith("\n") && e.pop(), e;
685
663
  }
686
- function Ae(e) {
664
+ function ke(e) {
687
665
  let t = [], n = 0;
688
666
  for (let r = 0; r <= e.length; r++) (r === e.length || e[r] === "\n") && (t.push({
689
667
  start: n,
690
668
  end: r
691
669
  }), n = r + 1);
692
- return ke(t, e);
670
+ return Oe(t, e);
693
671
  }
694
- function je(e, t, n = {}) {
672
+ function Ae(e, t, n = {}) {
695
673
  if (!/[^ \t\r\f]/.test(e)) return [];
696
674
  let r = [], i = 0, a = n.firstLineIndent ?? 0;
697
- for (let o = 0; o <= e.length; o++) (o === e.length || e[o] === "\n") && (r.push(...ze(e, i, o, t, n, a)), a = 0, i = o + 1);
698
- return ke(r, e);
675
+ for (let o = 0; o <= e.length; o++) (o === e.length || e[o] === "\n") && (r.push(...Re(e, i, o, t, n, a)), a = 0, i = o + 1);
676
+ return Oe(r, e);
699
677
  }
700
- function Me(e, t, n) {
678
+ function je(e, t, n) {
701
679
  if (!n) return t - e;
702
680
  let r = 0;
703
681
  for (let i = e; i < t; i++) r += n[i] ?? 1;
704
682
  return r;
705
683
  }
706
- function I(e, t, n, r = 0) {
707
- return t <= e ? 0 : Me(e, t, n) - Math.min(r, Ne(t - 1, n));
684
+ function F(e, t, n, r = 0) {
685
+ return t <= e ? 0 : je(e, t, n) - Math.min(r, Me(t - 1, n));
708
686
  }
709
- function Ne(e, t) {
687
+ function Me(e, t) {
710
688
  return t ? (t[e] ?? 1) - 1 : 0;
711
689
  }
712
- function Pe(e, t = {}) {
690
+ function Ne(e, t = {}) {
713
691
  let { advances: n, tracking: r = 0 } = t, i = 0;
714
- for (let t of Re(e, 0, e.length)) for (let a of Ie(e, t.start, t.end)) i = Math.max(i, I(a.start, a.end, n, r));
692
+ for (let t of Le(e, 0, e.length)) for (let a of Fe(e, t.start, t.end)) i = Math.max(i, F(a.start, a.end, n, r));
715
693
  return i;
716
694
  }
717
- function Fe(e, t) {
695
+ function Pe(e, t) {
718
696
  let n = 0;
719
697
  for (let r = 0; r < e.length; r++) e[r] === "" && (t(r, n), n++);
720
698
  }
721
- function Ie(e, t, n) {
699
+ function Fe(e, t, n) {
722
700
  let r = [], i = t;
723
701
  for (let a = t; a < n; a++) {
724
702
  if (e[a] === "") {
@@ -745,14 +723,14 @@ function Ie(e, t, n) {
745
723
  end: n
746
724
  }), r;
747
725
  }
748
- var Le = /[ \t\r\n\f]/;
749
- function Re(e, t, n) {
726
+ var Ie = /[ \t\r\n\f]/;
727
+ function Le(e, t, n) {
750
728
  let r = [], i = t;
751
729
  for (; i < n;) {
752
- for (; i < n && Le.test(e[i]);) i++;
730
+ for (; i < n && Ie.test(e[i]);) i++;
753
731
  if (i >= n) break;
754
732
  let t = i;
755
- for (; i < n && !Le.test(e[i]);) i++;
733
+ for (; i < n && !Ie.test(e[i]);) i++;
756
734
  r.push({
757
735
  start: t,
758
736
  end: i
@@ -760,8 +738,8 @@ function Re(e, t, n) {
760
738
  }
761
739
  return r;
762
740
  }
763
- function ze(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
764
- let s = Re(e, t, n);
741
+ function Re(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
742
+ let s = Le(e, t, n);
765
743
  if (s.length === 0) return [{
766
744
  start: t,
767
745
  end: t
@@ -773,13 +751,13 @@ function ze(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
773
751
  let c = [], l = null, u = 0, d = Math.max(0, o), f = () => r - d;
774
752
  for (let t of s) {
775
753
  let n = !1;
776
- for (let r of Ie(e, t.start, t.end)) {
777
- let e = r.start, t = r.end, o = l !== null && !n ? e - 1 : e, s = u + Me(o, t, i), p = Math.min(a, Ne(t - 1, i));
754
+ for (let r of Fe(e, t.start, t.end)) {
755
+ let e = r.start, t = r.end, o = l !== null && !n ? e - 1 : e, s = u + je(o, t, i), p = Math.min(a, Me(t - 1, i));
778
756
  if (l !== null && s - p <= f()) l.end = t, u = s;
779
757
  else {
780
758
  for (l !== null && (c.push(l), d = 0);;) {
781
759
  let n = e;
782
- for (; n < t && I(e, n + 1, i, a) <= f();) n++;
760
+ for (; n < t && F(e, n + 1, i, a) <= f();) n++;
783
761
  if (n === t || n === e) break;
784
762
  c.push({
785
763
  start: e,
@@ -789,7 +767,7 @@ function ze(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
789
767
  l = {
790
768
  start: e,
791
769
  end: t
792
- }, u = Me(e, t, i);
770
+ }, u = je(e, t, i);
793
771
  }
794
772
  n = !0;
795
773
  }
@@ -798,7 +776,7 @@ function ze(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
798
776
  }
799
777
  //#endregion
800
778
  //#region src/flex.ts
801
- function Be(e, t) {
779
+ function ze(e, t) {
802
780
  let n = e.row.map((e) => e.node.localRect).sort((e, t) => e.x - t.x), r = [];
803
781
  for (let e = 1; e < n.length; e++) {
804
782
  let i = n[e - 1].x + n[e - 1].width - t, a = n[e].x - t;
@@ -809,12 +787,12 @@ function Be(e, t) {
809
787
  }
810
788
  return r;
811
789
  }
812
- function Ve(e, t, n, r, i) {
790
+ function Be(e, t, n, r, i) {
813
791
  if (e.style.ruleBreak !== "intersection") return [{
814
792
  start: 0,
815
793
  end: i
816
794
  }];
817
- let a = [t[n - 1], t[n]].flatMap((e) => Be(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
795
+ let a = [t[n - 1], t[n]].flatMap((e) => ze(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
818
796
  start: e,
819
797
  end: t,
820
798
  spanned: !1,
@@ -822,25 +800,25 @@ function Ve(e, t, n, r, i) {
822
800
  afterOccupied: !0
823
801
  }), s = [], c = 0;
824
802
  for (let e of a) e.start > c && s.push(o(c, e.start)), c = Math.max(c, e.end);
825
- return c < i && s.push(o(c, i)), ye(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
803
+ return c < i && s.push(o(c, i)), be(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
826
804
  }
827
- function He(e, t) {
805
+ function Ve(e, t) {
828
806
  return typeof t != "number" || t <= 0 ? e : e.map((e) => ({
829
807
  ...e,
830
808
  start: e.start + t,
831
809
  end: e.end - t
832
810
  })).filter((e) => e.end > e.start);
833
811
  }
834
- function Ue(e, t, n, r, i, a, o) {
835
- let s = H(e.style, "x", t), c = H(e.style, "y", n), l = Qe(e).map((e) => {
836
- let n = W(e.style.margin, t);
812
+ function He(e, t, n, r, i, a, o) {
813
+ let s = Wn(e.style, "x", t), c = Wn(e.style, "y", n), l = Ze(e).map((e) => {
814
+ let n = U(e.style.margin, t);
837
815
  return {
838
816
  node: e,
839
- base: Ze(e, t, o),
817
+ base: Xe(e, t, o),
840
818
  grow: e.style.flexGrow,
841
819
  shrink: e.style.flexShrink,
842
- min: tt(e, t, o),
843
- max: G(e.style.maxWidth, t),
820
+ min: et(e, t, o),
821
+ max: W(e.style.maxWidth, t),
844
822
  margin: n
845
823
  };
846
824
  }), u = [];
@@ -853,7 +831,7 @@ function Ue(e, t, n, r, i, a, o) {
853
831
  n.length > 0 && u.push(n), e.style.wrapReverse && u.reverse();
854
832
  } else u.push(l);
855
833
  let d = i.left + a.left, f = i.top + a.top, p = u.map((e) => {
856
- let n = s * Math.max(0, e.length - 1), i = e.reduce((e, t) => e + (t.margin.left ?? 0) + (t.margin.right ?? 0), 0), a = Math.max(0, t - n - i), c = e.some((e) => e.margin.left === null || e.margin.right === null), l = e.reduce((e, t) => e + t.base, 0), u = c && l <= a ? e.map((e) => Math.max(0, V(e.base, e.min, e.max))) : Je(e, a);
834
+ let n = s * Math.max(0, e.length - 1), i = e.reduce((e, t) => e + (t.margin.left ?? 0) + (t.margin.right ?? 0), 0), a = Math.max(0, t - n - i), c = e.some((e) => e.margin.left === null || e.margin.right === null), l = e.reduce((e, t) => e + t.base, 0), u = c && l <= a ? e.map((e) => Math.max(0, V(e.base, e.min, e.max))) : qe(e, a);
857
835
  for (let n = 0; n < e.length; n++) B(e[n].node, t, r, 0, 0, "fill", o, { width: u[n] });
858
836
  return {
859
837
  row: e,
@@ -864,19 +842,19 @@ function Ue(e, t, n, r, i, a, o) {
864
842
  }), m = p.map((e) => e.height), h = c * Math.max(0, p.length - 1), g;
865
843
  if (e.style.flexWrap === "nowrap") r === void 0 ? Number.isFinite(n) && (m[0] = Math.max(n, m[0] ?? 0)) : m[0] = r, g = [0];
866
844
  else {
867
- let t = m.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - h) : 0, i = $e(e.style);
845
+ let t = m.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - h) : 0, i = Qe(e.style);
868
846
  if (i === "stretch" && r > 0) {
869
- let e = R(Array.from({ length: p.length }, () => 1), r);
847
+ let e = L(Array.from({ length: p.length }, () => 1), r);
870
848
  for (let t = 0; t < m.length; t++) m[t] += e[t];
871
- g = L("start", m, 0);
872
- } else g = L(i === "stretch" ? "start" : i, m, r);
849
+ g = I("start", m, 0);
850
+ } else g = I(i === "stretch" ? "start" : i, m, r);
873
851
  }
874
852
  for (let i = 0; i < p.length; i++) {
875
853
  let { row: a, widths: l, availableForItems: u } = p[i], h = m[i], _ = g[i] + i * c;
876
854
  for (let i = 0; i < a.length; i++) {
877
- let s = a[i].node, c = Ye(s, e), u = a[i].margin, d = u.top === null || u.bottom === null, f = s.style.height !== void 0 && s.style.height.kind !== "auto";
855
+ let s = a[i].node, c = Je(s, e), u = a[i].margin, d = u.top === null || u.bottom === null, f = s.style.height !== void 0 && s.style.height.kind !== "auto";
878
856
  if (c === "stretch" && !d && !f && h !== s.localRect.height) {
879
- let e = u.top ?? 0, a = u.bottom ?? 0, c = Number.isFinite(n) ? n : void 0, d = V(Math.max(0, h - e - a), G(s.style.minHeight, c) ?? 0, G(s.style.maxHeight, c));
857
+ let e = u.top ?? 0, a = u.bottom ?? 0, c = Number.isFinite(n) ? n : void 0, d = V(Math.max(0, h - e - a), W(s.style.minHeight, c) ?? 0, W(s.style.maxHeight, c));
880
858
  if (d === s.localRect.height) continue;
881
859
  B(s, t, r, 0, 0, "fill", o, {
882
860
  width: l[i],
@@ -886,17 +864,17 @@ function Ue(e, t, n, r, i, a, o) {
886
864
  }
887
865
  let v = l.reduce((e, t) => e + t, 0), y = Math.max(0, u - v), b = a.reduce((e, t) => e + +(t.margin.left === null) + +(t.margin.right === null), 0), x = Array.from({ length: a.length }, () => 0), S = Array.from({ length: a.length }, () => 0), C;
888
866
  if (b > 0 && y > 0) {
889
- let e = R(Array.from({ length: b }, () => 1), y), t = 0;
867
+ let e = L(Array.from({ length: b }, () => 1), y), t = 0;
890
868
  for (let n = 0; n < a.length; n++) a[n].margin.left === null && (x[n] = e[t++]), a[n].margin.right === null && (S[n] = e[t++]);
891
- C = L("start", l, 0);
892
- } else C = L(et(e.style), l, y);
869
+ C = I("start", l, 0);
870
+ } else C = I($e(e.style), l, y);
893
871
  let w = 0;
894
872
  for (let t = 0; t < a.length; t++) {
895
873
  let n = a[t], r = n.node, i = n.margin.left ?? 0, o = n.margin.right ?? 0;
896
874
  w += x[t] + i, r.localRect = {
897
875
  ...r.localRect,
898
876
  x: d + C[t] + t * s + w,
899
- y: f + _ + Ke(r, e.style.alignItems, h, n.margin)
877
+ y: f + _ + Ge(r, e.style.alignItems, h, n.margin)
900
878
  }, w += S[t] + o;
901
879
  }
902
880
  }
@@ -905,7 +883,7 @@ function Ue(e, t, n, r, i, a, o) {
905
883
  let n = [], r = [];
906
884
  for (let i = 0; i < p.length; i++) {
907
885
  let a = g[i] + i * c;
908
- for (let e of Be(p[i], d)) n.push({
886
+ for (let e of ze(p[i], d)) n.push({
909
887
  bandStart: e.start,
910
888
  bandSize: e.end - e.start,
911
889
  start: a,
@@ -913,19 +891,19 @@ function Ue(e, t, n, r, i, a, o) {
913
891
  });
914
892
  if (i > 0) {
915
893
  let n = g[i - 1] + (i - 1) * c + m[i - 1];
916
- if (a > n) for (let o of Ve(e, p, i, d, t)) r.push({
894
+ if (a > n) for (let o of Be(e, p, i, d, t)) r.push({
917
895
  bandStart: n,
918
896
  bandSize: a - n,
919
897
  ...o
920
898
  });
921
899
  }
922
900
  }
923
- e.decorationRuns = be({
901
+ e.decorationRuns = xe({
924
902
  glyphs: S(e.style.glyphSet),
925
903
  ruleX: e.style.ruleX,
926
904
  ruleY: e.style.ruleY,
927
- vertical: He(n, e.style.ruleInset),
928
- horizontal: He(r, e.style.ruleInset),
905
+ vertical: Ve(n, e.style.ruleInset),
906
+ horizontal: Ve(r, e.style.ruleInset),
929
907
  contentWidth: t,
930
908
  contentHeight: v,
931
909
  border: i,
@@ -934,9 +912,9 @@ function Ue(e, t, n, r, i, a, o) {
934
912
  padding: a
935
913
  });
936
914
  }
937
- return We(e, i, a, t, v), v;
915
+ return Ue(e, i, a, t, v), v;
938
916
  }
939
- function We(e, t, n, r, i) {
917
+ function Ue(e, t, n, r, i) {
940
918
  for (let a of e.children) z(a.style) && (a.staticSlot = {
941
919
  kind: "flex",
942
920
  direction: e.style.flexDirection,
@@ -946,37 +924,37 @@ function We(e, t, n, r, i) {
946
924
  innerHeight: i
947
925
  });
948
926
  }
949
- function Ge(e, t, n, r, i, a, o) {
950
- let s = H(e.style, "y", n), c = Qe(e).map((i) => {
951
- let a = W(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = Ye(i, e) === "stretch";
927
+ function We(e, t, n, r, i, a, o) {
928
+ let s = Wn(e.style, "y", n), c = Ze(e).map((i) => {
929
+ let a = U(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = Je(i, e) === "stretch";
952
930
  B(i, s, r && Number.isFinite(n) ? n : void 0, 0, 0, c ? "fill" : "shrink", o);
953
- let l = Number.isFinite(n) ? n : void 0, u = i.style.flexBasis, d = u === void 0 || u.kind === "auto" ? i.unclampedHeight : u.kind === "cells" ? u.value : u.kind === "percent" && l !== void 0 ? we(u.value, l) : i.unclampedHeight, f = i.style.minHeight === "auto" ? i.style.overflow.y === "visible" ? i.localRect.height : 0 : void 0;
931
+ let l = Number.isFinite(n) ? n : void 0, u = i.style.flexBasis, d = u === void 0 || u.kind === "auto" ? i.unclampedHeight : u.kind === "cells" ? u.value : u.kind === "percent" && l !== void 0 ? Ce(u.value, l) : i.unclampedHeight, f = i.style.minHeight === "auto" ? i.style.overflow.y === "visible" ? i.localRect.height : 0 : void 0;
954
932
  return {
955
933
  node: i,
956
934
  base: d,
957
935
  grow: i.style.flexGrow,
958
936
  shrink: i.style.flexShrink,
959
- min: f ?? G(i.style.minHeight, l) ?? 0,
960
- max: G(i.style.maxHeight, l),
937
+ min: f ?? W(i.style.minHeight, l) ?? 0,
938
+ max: W(i.style.maxHeight, l),
961
939
  margin: a
962
940
  };
963
- }), l = s * Math.max(0, c.length - 1), u = c.reduce((e, t) => e + (t.margin.top ?? 0) + (t.margin.bottom ?? 0), 0), d = Number.isFinite(n), f = c.reduce((e, t) => e + t.base, 0), p = d ? Math.max(0, n - l - u) : f, m = r ? p : Math.max(p, f), h = c.some((e) => e.margin.top === null || e.margin.bottom === null), g = d && !(d && h && f <= m) ? Je(c, m) : c.map((e) => Math.max(0, V(e.base, e.min, e.max)));
941
+ }), l = s * Math.max(0, c.length - 1), u = c.reduce((e, t) => e + (t.margin.top ?? 0) + (t.margin.bottom ?? 0), 0), d = Number.isFinite(n), f = c.reduce((e, t) => e + t.base, 0), p = d ? Math.max(0, n - l - u) : f, m = r ? p : Math.max(p, f), h = c.some((e) => e.margin.top === null || e.margin.bottom === null), g = d && !(d && h && f <= m) ? qe(c, m) : c.map((e) => Math.max(0, V(e.base, e.min, e.max)));
964
942
  for (let n = 0; n < c.length; n++) if (g[n] !== c[n].node.localRect.height) {
965
- let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = Ye(r.node, e) === "stretch";
943
+ let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = Je(r.node, e) === "stretch";
966
944
  B(r.node, i, g[n], 0, 0, a ? "fill" : "shrink", o, { height: g[n] });
967
945
  }
968
946
  let _ = g.reduce((e, t) => e + t, 0), v = Math.max(0, m - _), y = c.reduce((e, t) => e + +(t.margin.top === null) + +(t.margin.bottom === null), 0), b = Array.from({ length: c.length }, () => 0), x = Array.from({ length: c.length }, () => 0), C;
969
947
  if (y > 0 && v > 0) {
970
- let e = R(Array.from({ length: y }, () => 1), v), t = 0;
948
+ let e = L(Array.from({ length: y }, () => 1), v), t = 0;
971
949
  for (let n = 0; n < c.length; n++) c[n].margin.top === null && (b[n] = e[t++]), c[n].margin.bottom === null && (x[n] = e[t++]);
972
- C = L("start", g, 0);
973
- } else C = L(et(e.style), g, v);
950
+ C = I("start", g, 0);
951
+ } else C = I($e(e.style), g, v);
974
952
  let w = i.left + a.left, T = i.top + a.top, E = 0;
975
953
  for (let n = 0; n < c.length; n++) {
976
954
  let r = c[n], i = r.node, a = r.margin.top ?? 0, o = r.margin.bottom ?? 0;
977
955
  E += b[n] + a, i.localRect = {
978
956
  ...i.localRect,
979
- x: w + qe(i, e.style.alignItems, t, r.margin),
957
+ x: w + Ke(i, e.style.alignItems, t, r.margin),
980
958
  y: T + C[n] + n * s + E
981
959
  }, E += x[n] + o;
982
960
  }
@@ -992,12 +970,12 @@ function Ge(e, t, n, r, i, a, o) {
992
970
  end: t
993
971
  });
994
972
  }
995
- e.decorationRuns = be({
973
+ e.decorationRuns = xe({
996
974
  glyphs: S(e.style.glyphSet),
997
975
  ruleX: null,
998
976
  ruleY: e.style.ruleY,
999
977
  vertical: [],
1000
- horizontal: He(n, e.style.ruleInset),
978
+ horizontal: Ve(n, e.style.ruleInset),
1001
979
  contentWidth: t,
1002
980
  contentHeight: O,
1003
981
  border: i,
@@ -1006,17 +984,17 @@ function Ge(e, t, n, r, i, a, o) {
1006
984
  padding: a
1007
985
  });
1008
986
  }
1009
- return We(e, i, a, t, O), O;
987
+ return Ue(e, i, a, t, O), O;
1010
988
  }
1011
- function Ke(e, t, n, r) {
989
+ function Ge(e, t, n, r) {
1012
990
  let i = e.style.alignSelf === "auto" ? t : e.style.alignSelf, a = r.top ?? 0, o = r.bottom ?? 0, s = n - e.localRect.height, c = r.top === null && r.bottom === null, l = r.top === null && r.bottom !== null, u = r.bottom === null && r.top !== null;
1013
- return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + Xe(i, n, e.localRect.height);
991
+ return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + Ye(i, n, e.localRect.height);
1014
992
  }
1015
- function qe(e, t, n, r) {
993
+ function Ke(e, t, n, r) {
1016
994
  let i = e.style.alignSelf === "auto" ? t : e.style.alignSelf, a = r.left ?? 0, o = r.right ?? 0, s = n - e.localRect.width, c = r.left === null && r.right === null, l = r.left === null && r.right !== null, u = r.right === null && r.left !== null;
1017
- return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + Xe(i, n, e.localRect.width);
995
+ return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + Ye(i, n, e.localRect.width);
1018
996
  }
1019
- function L(e, t, n) {
997
+ function I(e, t, n) {
1020
998
  let r = t.length;
1021
999
  if (r === 0) return [];
1022
1000
  let i = [], a = 0;
@@ -1026,7 +1004,7 @@ function L(e, t, n) {
1026
1004
  return i;
1027
1005
  }
1028
1006
  if ((e === "space-around" || e === "space-evenly") && n > 0) {
1029
- let o = R(Array.from({ length: r + 1 }, (t, n) => e === "space-evenly" || n === 0 || n === r ? 1 : 2), n);
1007
+ let o = L(Array.from({ length: r + 1 }, (t, n) => e === "space-evenly" || n === 0 || n === r ? 1 : 2), n);
1030
1008
  for (let e = 0; e < r; e++) a += o[e], i.push(a), a += t[e];
1031
1009
  return i;
1032
1010
  }
@@ -1034,7 +1012,7 @@ function L(e, t, n) {
1034
1012
  for (let e = 0; e < r; e++) i.push(a), a += t[e];
1035
1013
  return i;
1036
1014
  }
1037
- function Je(e, t) {
1015
+ function qe(e, t) {
1038
1016
  let n = e.length, r = (t, n) => Math.max(0, V(t, e[n].min ?? 0, e[n].max)), i = e.map((e) => e.base), a = t >= i.reduce((e, t, n) => e + r(t, n), 0), o = Array.from({ length: n }, () => 0), s = Array.from({ length: n }, () => !1);
1039
1017
  for (let t = 0; t < n; t++) {
1040
1018
  let n = r(i[t], t);
@@ -1044,7 +1022,7 @@ function Je(e, t) {
1044
1022
  let c = [];
1045
1023
  for (let e = 0; e < n; e++) s[e] || c.push(e);
1046
1024
  if (c.length === 0) break;
1047
- let l = o.reduce((e, t, n) => s[n] ? e + t : e, 0), u = c.reduce((e, t) => e + i[t], 0), d = t - l - u, f = a ? Math.max(0, d) : Math.max(0, -d), p = R(c.map((t) => a ? e[t].grow : i[t] * e[t].shrink), f), m = c.map((e, t) => i[e] + (a ? p[t] : -p[t])), h = c.map((e, t) => r(m[t], e)), g = h.reduce((e, t, n) => e + (t - m[n]), 0);
1025
+ let l = o.reduce((e, t, n) => s[n] ? e + t : e, 0), u = c.reduce((e, t) => e + i[t], 0), d = t - l - u, f = a ? Math.max(0, d) : Math.max(0, -d), p = L(c.map((t) => a ? e[t].grow : i[t] * e[t].shrink), f), m = c.map((e, t) => i[e] + (a ? p[t] : -p[t])), h = c.map((e, t) => r(m[t], e)), g = h.reduce((e, t, n) => e + (t - m[n]), 0);
1048
1026
  if (g === 0) {
1049
1027
  for (let e = 0; e < c.length; e++) o[c[e]] = h[e];
1050
1028
  break;
@@ -1056,7 +1034,7 @@ function Je(e, t) {
1056
1034
  }
1057
1035
  return o;
1058
1036
  }
1059
- function R(e, t) {
1037
+ function L(e, t) {
1060
1038
  let n = e.reduce((e, t) => e + t, 0);
1061
1039
  if (n === 0 || t <= 0) return e.map(() => 0);
1062
1040
  let r = e.map((e) => e / n * t), i = r.map(Math.floor), a = t - i.reduce((e, t) => e + t, 0);
@@ -1069,35 +1047,38 @@ function R(e, t) {
1069
1047
  }
1070
1048
  return i;
1071
1049
  }
1072
- function Ye(e, t) {
1050
+ function Je(e, t) {
1073
1051
  return e.style.alignSelf === "auto" ? t.style.alignItems : e.style.alignSelf;
1074
1052
  }
1075
- function Xe(e, t, n) {
1053
+ function Ye(e, t, n) {
1076
1054
  return e === "center" ? Math.max(0, Math.floor((t - n) / 2)) : e === "end" ? Math.max(0, t - n) : 0;
1077
1055
  }
1078
- function Ze(e, t, n) {
1056
+ function Xe(e, t, n) {
1079
1057
  let r = e.style.flexBasis, i = e.style.width;
1080
- return r !== void 0 && r.kind !== "auto" ? K(r, t, e, n) : i !== void 0 && i.kind !== "auto" ? K(i, t, e, n) : q(e, n);
1058
+ return r !== void 0 && r.kind !== "auto" ? G(r, t, e, n) : i !== void 0 && i.kind !== "auto" ? G(i, t, e, n) : K(e, n);
1081
1059
  }
1082
- function Qe(e) {
1060
+ function Ze(e) {
1083
1061
  let t = e.children.filter((e) => !z(e.style)).sort((e, t) => e.style.order - t.style.order);
1084
1062
  return e.style.flexReverse && t.reverse(), t;
1085
1063
  }
1086
- function $e(e) {
1064
+ function Qe(e) {
1087
1065
  return e.wrapReverse ? e.alignContent === "start" ? "end" : e.alignContent === "end" ? "start" : e.alignContent : e.alignContent;
1088
1066
  }
1089
- function et(e) {
1067
+ function $e(e) {
1090
1068
  let t = e.justifyContent === "stretch" ? "start" : e.justifyContent;
1091
1069
  return e.flexReverse ? t === "start" ? "end" : t === "end" ? "start" : t : t;
1092
1070
  }
1093
- function tt(e, t, n) {
1094
- return e.style.minWidth === "auto" ? e.style.overflow.x === "visible" ? Y(e, n) : 0 : G(e.style.minWidth, t) ?? 0;
1071
+ function et(e, t, n) {
1072
+ return e.style.minWidth === "auto" ? e.style.overflow.x === "visible" ? J(e, n) : 0 : W(e.style.minWidth, t) ?? 0;
1095
1073
  }
1096
1074
  //#endregion
1097
1075
  //#region src/types.ts
1098
- function nt(e) {
1076
+ function tt(e) {
1099
1077
  return e === "auto" || e === "scroll";
1100
1078
  }
1079
+ function nt(e) {
1080
+ return e.children.filter((e) => e.inlineBox);
1081
+ }
1101
1082
  function rt(e) {
1102
1083
  return {
1103
1084
  right: e.scrollbarSize.y + e.scrollbarInset.x,
@@ -1134,8 +1115,8 @@ function at() {
1134
1115
  justifySelf: "auto",
1135
1116
  gridTemplateColumns: { kind: "none" },
1136
1117
  gridTemplateRows: { kind: "none" },
1137
- gridAutoColumns: [st()],
1138
- gridAutoRows: [st()],
1118
+ gridAutoColumns: [ot()],
1119
+ gridAutoRows: [ot()],
1139
1120
  gridAutoFlow: {
1140
1121
  direction: "row",
1141
1122
  dense: !1
@@ -1151,7 +1132,7 @@ function at() {
1151
1132
  minHeight: "auto",
1152
1133
  maxWidth: void 0,
1153
1134
  maxHeight: void 0,
1154
- padding: ot(),
1135
+ padding: R(),
1155
1136
  margin: {
1156
1137
  top: 0,
1157
1138
  right: 0,
@@ -1167,7 +1148,7 @@ function at() {
1167
1148
  },
1168
1149
  gapX: 0,
1169
1150
  gapY: 0,
1170
- border: ot(),
1151
+ border: R(),
1171
1152
  borderStyle: {
1172
1153
  top: "solid",
1173
1154
  right: "solid",
@@ -1237,7 +1218,7 @@ function at() {
1237
1218
  breakInsideAvoid: !1
1238
1219
  };
1239
1220
  }
1240
- function ot() {
1221
+ function R() {
1241
1222
  return {
1242
1223
  top: 0,
1243
1224
  right: 0,
@@ -1245,7 +1226,7 @@ function ot() {
1245
1226
  left: 0
1246
1227
  };
1247
1228
  }
1248
- function st() {
1229
+ function ot() {
1249
1230
  return {
1250
1231
  min: { kind: "auto" },
1251
1232
  max: { kind: "auto" }
@@ -1253,15 +1234,15 @@ function st() {
1253
1234
  }
1254
1235
  //#endregion
1255
1236
  //#region src/grid.ts
1256
- function ct(e, t, n, r, i, a) {
1257
- let o = e.style, s = Number.isFinite(n) ? n : void 0, c = e.subgrid?.cols, l = e.subgrid?.rows, u = c ? c.gap : H(o, "x", t), d = l ? l.gap : H(o, "y", s), f = vt(e, t, s, u, d, e.subgrid ? {
1237
+ function st(e, t, n, r, i, a) {
1238
+ let o = e.style, s = Number.isFinite(n) ? n : void 0, c = e.subgrid?.cols, l = e.subgrid?.rows, u = c ? c.gap : Wn(o, "x", t), d = l ? l.gap : Wn(o, "y", s), f = _t(e, t, s, u, d, e.subgrid ? {
1258
1239
  col: e.subgrid.colSpan,
1259
1240
  row: e.subgrid.rowSpan
1260
- } : void 0), { children: p, placed: m, colLines: h, rowLines: g, colTracks: _, rowTracks: v, colCollapsed: y, rowCollapsed: b } = f, x = p.map((e) => W(e.style.margin, t)), C = p.map((e) => e.style.justifySelf === "auto" ? o.justifyItems : e.style.justifySelf), w = p.map(lt), T = c ? dt(c) : Nt(_, y, ft(f, w, x, a), t, u, o.justifyContent === "stretch"), E = c ? c.positions : Pt(T, t, o.justifyContent), D = [];
1241
+ } : void 0), { children: p, placed: m, colLines: h, rowLines: g, colTracks: _, rowTracks: v, colCollapsed: y, rowCollapsed: b } = f, x = p.map((e) => U(e.style.margin, t)), C = p.map((e) => e.style.justifySelf === "auto" ? o.justifyItems : e.style.justifySelf), w = p.map(ct), T = c ? ut(c) : Mt(_, y, dt(f, w, x, a), t, u, o.justifyContent === "stretch"), E = c ? c.positions : Nt(T, t, o.justifyContent), D = [];
1261
1242
  for (let e = 0; e < p.length; e++) {
1262
- let t = p[e], n = m.items[e], r = It(E, T.sizes, n.col.start, n.col.span), i = x[e], o = Math.max(0, r - St(i)), s = w[e];
1243
+ let t = p[e], n = m.items[e], r = Ft(E, T.sizes, n.col.start, n.col.span), i = x[e], o = Math.max(0, r - xt(i)), s = w[e];
1263
1244
  if (s.cols || s.rows) {
1264
- let e = s.cols ? ut(E, T, u, n.col.start, n.col.span, mt(t, "cols", i, r)) : void 0;
1245
+ let e = s.cols ? lt(E, T, u, n.col.start, n.col.span, pt(t, "cols", i, r)) : void 0;
1265
1246
  t.subgrid = {
1266
1247
  colSpan: n.col.span,
1267
1248
  rowSpan: n.row.span,
@@ -1270,17 +1251,17 @@ function ct(e, t, n, r, i, a) {
1270
1251
  };
1271
1252
  } else t.subgrid = void 0;
1272
1253
  let c = C[e], l = i.left === null || i.right === null, d = t.style.width !== void 0 && t.style.width.kind !== "auto";
1273
- s.cols ? B(t, r, void 0, 0, 0, "fill", a, { width: o }) : c === "stretch" && !l && !d ? B(t, r, void 0, 0, 0, "fill", a, { width: V(o, t.style.minWidth === "auto" ? t.style.overflow.x === "visible" ? Y(t, a) : 0 : G(t.style.minWidth, r) ?? 0, Kn(t.style.maxWidth, r, t, a)) }) : B(t, o, void 0, 0, 0, "shrink", a), D.push(t.localRect.width);
1254
+ s.cols ? B(t, r, void 0, 0, 0, "fill", a, { width: o }) : c === "stretch" && !l && !d ? B(t, r, void 0, 0, 0, "fill", a, { width: V(o, t.style.minWidth === "auto" ? t.style.overflow.x === "visible" ? J(t, a) : 0 : W(t.style.minWidth, r) ?? 0, Kn(t.style.maxWidth, r, t, a)) }) : B(t, o, void 0, 0, 0, "shrink", a), D.push(t.localRect.width);
1274
1255
  }
1275
- let O = l ? dt(l) : Nt(v, b, pt(f, w, x), s ?? "max-content", d, o.alignContent === "stretch"), k = Ft(O), A = l ? l.positions : Pt(O, s ?? k, o.alignContent), j = r.left + i.left, M = r.top + i.top;
1256
+ let O = l ? ut(l) : Mt(v, b, ft(f, w, x), s ?? "max-content", d, o.alignContent === "stretch"), k = Pt(O), A = l ? l.positions : Nt(O, s ?? k, o.alignContent), ee = r.left + i.left, j = r.top + i.top;
1276
1257
  for (let t = 0; t < p.length; t++) {
1277
- let n = p[t], r = m.items[t], i = x[t], o = It(E, T.sizes, r.col.start, r.col.span), s = It(A, O.sizes, r.row.start, r.row.span), c = Math.max(0, s - Ct(i)), l = Ye(n, e), u = i.top === null || i.bottom === null, f = n.style.height !== void 0 && n.style.height.kind !== "auto";
1278
- if (w[t].rows) n.subgrid.rows = ut(A, O, d, r.row.start, r.row.span, mt(n, "rows", i, o)), B(n, o, s, 0, 0, "fill", a, {
1258
+ let n = p[t], r = m.items[t], i = x[t], o = Ft(E, T.sizes, r.col.start, r.col.span), s = Ft(A, O.sizes, r.row.start, r.row.span), c = Math.max(0, s - St(i)), l = Je(n, e), u = i.top === null || i.bottom === null, f = n.style.height !== void 0 && n.style.height.kind !== "auto";
1259
+ if (w[t].rows) n.subgrid.rows = lt(A, O, d, r.row.start, r.row.span, pt(n, "rows", i, o)), B(n, o, s, 0, 0, "fill", a, {
1279
1260
  width: D[t],
1280
1261
  height: c
1281
1262
  });
1282
1263
  else if (l === "stretch" && !u && !f) {
1283
- let e = V(c, n.style.minHeight === "auto" ? n.style.overflow.y === "visible" ? n.localRect.height : 0 : G(n.style.minHeight, s) ?? 0, G(n.style.maxHeight, s));
1264
+ let e = V(c, n.style.minHeight === "auto" ? n.style.overflow.y === "visible" ? n.localRect.height : 0 : W(n.style.minHeight, s) ?? 0, W(n.style.maxHeight, s));
1284
1265
  e !== n.localRect.height && B(n, o, s, 0, 0, "fill", a, {
1285
1266
  width: D[t],
1286
1267
  height: e
@@ -1288,11 +1269,11 @@ function ct(e, t, n, r, i, a) {
1288
1269
  } else n.style.height?.kind === "percent" && B(n, o, s, 0, 0, "fill", a, { width: D[t] });
1289
1270
  n.localRect = {
1290
1271
  ...n.localRect,
1291
- x: j + E[r.col.start] + Lt(C[t], i.left, i.right, o, n.localRect.width),
1292
- y: M + A[r.row.start] + Lt(l, i.top, i.bottom, s, n.localRect.height)
1272
+ x: ee + E[r.col.start] + It(C[t], i.left, i.right, o, n.localRect.width),
1273
+ y: j + A[r.row.start] + It(l, i.top, i.bottom, s, n.localRect.height)
1293
1274
  };
1294
1275
  }
1295
- let N = Number.isFinite(n) ? Math.max(n, k) : k;
1276
+ let M = Number.isFinite(n) ? Math.max(n, k) : k;
1296
1277
  if (o.ruleX || o.ruleY) {
1297
1278
  let n = T.sizes.length, a = O.sizes.length, s = Array.from({ length: n }, () => Array.from({ length: a }, () => !1)), c = Array.from({ length: Math.max(0, n - 1) }, () => Array.from({ length: a }, () => !1)), l = Array.from({ length: Math.max(0, a - 1) }, () => Array.from({ length: n }, () => !1));
1298
1279
  for (let e of m.items) for (let t = e.col.start; t < e.col.start + e.col.span && t < n; t++) for (let r = e.row.start; r < e.row.start + e.row.span && r < a; r++) s[t][r] = !0, t + 1 < e.col.start + e.col.span && t < n - 1 && (c[t][r] = !0), r + 1 < e.row.start + e.row.span && r < a - 1 && (l[r][t] = !0);
@@ -1306,7 +1287,7 @@ function ct(e, t, n, r, i, a) {
1306
1287
  let r = [];
1307
1288
  for (let i = 1; i < e.length; i++) {
1308
1289
  let a = e[i - 1] + t[i - 1], s = e[i] - a;
1309
- if (!(s <= 0)) for (let e of ye(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
1290
+ if (!(s <= 0)) for (let e of be(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
1310
1291
  bandStart: a,
1311
1292
  bandSize: s,
1312
1293
  ...e
@@ -1314,40 +1295,40 @@ function ct(e, t, n, r, i, a) {
1314
1295
  }
1315
1296
  return r;
1316
1297
  }, f = d(E, T.sizes, (e) => u(e, A, O.sizes, c, (t) => s[e]?.[t] ?? !1, (t) => s[e + 1]?.[t] ?? !1)), p = d(A, O.sizes, (e) => u(e, E, T.sizes, l, (t) => s[t]?.[e] ?? !1, (t) => s[t]?.[e + 1] ?? !1));
1317
- e.decorationRuns = be({
1298
+ e.decorationRuns = xe({
1318
1299
  glyphs: S(o.glyphSet),
1319
1300
  ruleX: o.ruleX,
1320
1301
  ruleY: o.ruleY,
1321
1302
  vertical: f,
1322
1303
  horizontal: p,
1323
1304
  contentWidth: t,
1324
- contentHeight: N,
1305
+ contentHeight: M,
1325
1306
  border: r,
1326
1307
  borderStyle: o.borderStyle,
1327
1308
  borderColor: o.borderColor,
1328
1309
  padding: i
1329
1310
  });
1330
1311
  }
1331
- let ee = e.children.filter((e) => z(e.style));
1332
- if (ee.length > 0) {
1312
+ let te = e.children.filter((e) => z(e.style));
1313
+ if (te.length > 0) {
1333
1314
  let e = z(o) ? {
1334
1315
  x: r.left,
1335
1316
  y: r.top,
1336
1317
  width: i.left + t + i.right,
1337
- height: i.top + N + i.bottom
1318
+ height: i.top + M + i.bottom
1338
1319
  } : {
1339
- x: j,
1340
- y: M,
1320
+ x: ee,
1321
+ y: j,
1341
1322
  width: t,
1342
- height: N
1323
+ height: M
1343
1324
  };
1344
- for (let n of ee) {
1345
- let r = gt(n.style.gridColumnStart, n.style.gridColumnEnd, h, m.colOrigin, E, T.sizes, -i.left, t + i.right), a = gt(n.style.gridRowStart, n.style.gridRowEnd, g, m.rowOrigin, A, O.sizes, -i.top, N + i.bottom);
1325
+ for (let n of te) {
1326
+ let r = ht(n.style.gridColumnStart, n.style.gridColumnEnd, h, m.colOrigin, E, T.sizes, -i.left, t + i.right), a = ht(n.style.gridRowStart, n.style.gridRowEnd, g, m.rowOrigin, A, O.sizes, -i.top, M + i.bottom);
1346
1327
  n.staticSlot = {
1347
1328
  kind: "grid",
1348
1329
  area: {
1349
- x: j + r.start,
1350
- y: M + a.start,
1330
+ x: ee + r.start,
1331
+ y: j + a.start,
1351
1332
  width: Math.max(0, r.end - r.start),
1352
1333
  height: Math.max(0, a.end - a.start)
1353
1334
  },
@@ -1355,16 +1336,16 @@ function ct(e, t, n, r, i, a) {
1355
1336
  };
1356
1337
  }
1357
1338
  }
1358
- return N;
1339
+ return M;
1359
1340
  }
1360
- function lt(e) {
1341
+ function ct(e) {
1361
1342
  let t = e.style.display === "grid";
1362
1343
  return {
1363
1344
  cols: t && e.style.gridTemplateColumns.kind === "subgrid",
1364
1345
  rows: t && e.style.gridTemplateRows.kind === "subgrid"
1365
1346
  };
1366
1347
  }
1367
- function ut(e, t, n, r, i, a) {
1348
+ function lt(e, t, n, r, i, a) {
1368
1349
  let o = e[r] + a.start, s = t.sizes.slice(r, r + i);
1369
1350
  return s[0] = Math.max(0, s[0] - a.start), s[i - 1] = Math.max(0, s[i - 1] - a.end), {
1370
1351
  positions: Array.from({ length: i }, (t, n) => n === 0 ? 0 : e[r + n] - o),
@@ -1373,20 +1354,20 @@ function ut(e, t, n, r, i, a) {
1373
1354
  gap: n
1374
1355
  };
1375
1356
  }
1376
- function dt(e) {
1357
+ function ut(e) {
1377
1358
  return {
1378
1359
  sizes: e.sizes,
1379
1360
  gapBefore: e.gapBefore,
1380
1361
  limits: e.sizes
1381
1362
  };
1382
1363
  }
1383
- function ft(e, t, n, r) {
1364
+ function dt(e, t, n, r) {
1384
1365
  let i = [];
1385
1366
  return e.children.forEach((a, o) => {
1386
1367
  let s = e.placed.items[o], c = n[o];
1387
1368
  if (t[o].cols) {
1388
- let e = mt(a, "cols", c, 0);
1389
- for (let t of ht(a, "cols", s, e, r)) i.push({
1369
+ let e = pt(a, "cols", c, 0);
1370
+ for (let t of mt(a, "cols", s, e, r)) i.push({
1390
1371
  ...t,
1391
1372
  start: t.start + s.col.start
1392
1373
  });
@@ -1395,24 +1376,24 @@ function ft(e, t, n, r) {
1395
1376
  i.push({
1396
1377
  start: s.col.start,
1397
1378
  span: s.col.span,
1398
- min: J(a, "min", r) + St(c),
1399
- max: J(a, "max", r) + St(c)
1379
+ min: q(a, "min", r) + xt(c),
1380
+ max: q(a, "max", r) + xt(c)
1400
1381
  });
1401
1382
  }), i;
1402
1383
  }
1403
- function pt(e, t, n) {
1384
+ function ft(e, t, n) {
1404
1385
  let r = [];
1405
1386
  return e.children.forEach((i, a) => {
1406
1387
  let o = e.placed.items[a], s = n[a];
1407
1388
  if (t[a].rows) {
1408
- let e = mt(i, "rows", s, 0);
1409
- for (let t of ht(i, "rows", o, e)) r.push({
1389
+ let e = pt(i, "rows", s, 0);
1390
+ for (let t of mt(i, "rows", o, e)) r.push({
1410
1391
  ...t,
1411
1392
  start: t.start + o.row.start
1412
1393
  });
1413
1394
  return;
1414
1395
  }
1415
- let c = i.localRect.height + Ct(s), l = i.style.minHeight === "auto" && i.style.overflow.y !== "visible" ? Ct(s) : c;
1396
+ let c = i.localRect.height + St(s), l = i.style.minHeight === "auto" && i.style.overflow.y !== "visible" ? St(s) : c;
1416
1397
  r.push({
1417
1398
  start: o.row.start,
1418
1399
  span: o.row.span,
@@ -1421,25 +1402,25 @@ function pt(e, t, n) {
1421
1402
  });
1422
1403
  }), r;
1423
1404
  }
1424
- function mt(e, t, n, r) {
1405
+ function pt(e, t, n, r) {
1425
1406
  let { border: i, padding: a } = e.style;
1426
1407
  return t === "cols" ? {
1427
- start: (n.left ?? 0) + i.left + U(a.left, r),
1428
- end: (n.right ?? 0) + i.right + U(a.right, r)
1408
+ start: (n.left ?? 0) + i.left + H(a.left, r),
1409
+ end: (n.right ?? 0) + i.right + H(a.right, r)
1429
1410
  } : {
1430
- start: (n.top ?? 0) + i.top + U(a.top, r),
1431
- end: (n.bottom ?? 0) + i.bottom + U(a.bottom, r)
1411
+ start: (n.top ?? 0) + i.top + H(a.top, r),
1412
+ end: (n.bottom ?? 0) + i.bottom + H(a.bottom, r)
1432
1413
  };
1433
1414
  }
1434
- function ht(e, t, n, r, i) {
1435
- let a = t === "cols" ? n.col.span : n.row.span, o = vt(e, void 0, void 0, 0, 0, {
1415
+ function mt(e, t, n, r, i) {
1416
+ let a = t === "cols" ? n.col.span : n.row.span, o = _t(e, void 0, void 0, 0, 0, {
1436
1417
  col: n.col.span,
1437
1418
  row: n.row.span
1438
1419
  }), s = [];
1439
1420
  if (o.children.forEach((e, n) => {
1440
- let c = o.placed.items[n], l = t === "cols" ? c.col : c.row, u = l.start === 0, d = l.start + l.span === a, f = (u ? r.start : 0) + (d ? r.end : 0), p = W(e.style.margin, 0);
1441
- if (lt(e)[t]) {
1442
- let n = mt(e, t, p, 0), a = ht(e, t, c, {
1421
+ let c = o.placed.items[n], l = t === "cols" ? c.col : c.row, u = l.start === 0, d = l.start + l.span === a, f = (u ? r.start : 0) + (d ? r.end : 0), p = U(e.style.margin, 0);
1422
+ if (ct(e)[t]) {
1423
+ let n = pt(e, t, p, 0), a = mt(e, t, c, {
1443
1424
  start: n.start + (u ? r.start : 0),
1444
1425
  end: n.end + (d ? r.end : 0)
1445
1426
  }, i);
@@ -1452,11 +1433,11 @@ function ht(e, t, n, r, i) {
1452
1433
  if (t === "cols") s.push({
1453
1434
  start: l.start,
1454
1435
  span: l.span,
1455
- min: J(e, "min", i) + St(p) + f,
1456
- max: J(e, "max", i) + St(p) + f
1436
+ min: q(e, "min", i) + xt(p) + f,
1437
+ max: q(e, "max", i) + xt(p) + f
1457
1438
  });
1458
1439
  else {
1459
- let t = e.localRect.height + Ct(p) + f;
1440
+ let t = e.localRect.height + St(p) + f;
1460
1441
  s.push({
1461
1442
  start: l.start,
1462
1443
  span: l.span,
@@ -1475,9 +1456,9 @@ function ht(e, t, n, r, i) {
1475
1456
  }
1476
1457
  return s;
1477
1458
  }
1478
- function gt(e, t, n, r, i, a, o, s) {
1479
- let c = kt(e, "start", n), l = kt(t, "end", n);
1480
- c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = At(c, t, 1, n) : l !== null && e.kind === "span" && (c = At(l, e, -1, n));
1459
+ function ht(e, t, n, r, i, a, o, s) {
1460
+ let c = Ot(e, "start", n), l = Ot(t, "end", n);
1461
+ c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = kt(c, t, 1, n) : l !== null && e.kind === "span" && (c = kt(l, e, -1, n));
1481
1462
  let u = i.length, d = (e) => {
1482
1463
  if (e === null) return;
1483
1464
  let t = e - r;
@@ -1488,22 +1469,22 @@ function gt(e, t, n, r, i, a, o, s) {
1488
1469
  end: h === void 0 ? s : p(h)
1489
1470
  };
1490
1471
  }
1491
- function _t(e, t) {
1472
+ function gt(e, t) {
1492
1473
  let n = t.gridIntrinsic.get(e);
1493
1474
  if (n !== void 0) return n;
1494
- let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = vt(e, void 0, void 0, i, 0, e.subgrid ? {
1475
+ let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = _t(e, void 0, void 0, i, 0, e.subgrid ? {
1495
1476
  col: e.subgrid.colSpan,
1496
1477
  row: e.subgrid.rowSpan
1497
- } : void 0), o = a.children.map(lt), s = a.children.map((e) => W(e.style.margin, 0)), c = Nt(a.colTracks, a.colCollapsed, ft(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
1478
+ } : void 0), o = a.children.map(ct), s = a.children.map((e) => U(e.style.margin, 0)), c = Mt(a.colTracks, a.colCollapsed, dt(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
1498
1479
  min: c.sizes.reduce((e, t) => e + t, 0) + l,
1499
1480
  max: c.limits.reduce((e, t) => e + t, 0) + l
1500
1481
  };
1501
1482
  return t.gridIntrinsic.set(e, u), u;
1502
1483
  }
1503
- function vt(e, t, n, r, i, a) {
1504
- let o = e.style, s = xt(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? yt(a.col) : wt(o.gridTemplateColumns, t, r), d = l ? yt(a.row) : wt(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
1484
+ function _t(e, t, n, r, i, a) {
1485
+ let o = e.style, s = bt(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? vt(a.col) : Ct(o.gridTemplateColumns, t, r), d = l ? vt(a.row) : Ct(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
1505
1486
  if (f) {
1506
- c || Et(p, u.lineNames, f.columns, o.gridAutoColumns), l || Et(m, d.lineNames, f.rows, o.gridAutoRows);
1487
+ c || Tt(p, u.lineNames, f.columns, o.gridAutoColumns), l || Tt(m, d.lineNames, f.rows, o.gridAutoRows);
1507
1488
  for (let [e, t] of f.areas) u.lineNames[Math.min(t.colStart, p.length)].push(`${e}-start`), u.lineNames[Math.min(t.colEnd, p.length)].push(`${e}-end`), d.lineNames[Math.min(t.rowStart, m.length)].push(`${e}-start`), d.lineNames[Math.min(t.rowEnd, m.length)].push(`${e}-end`);
1508
1489
  }
1509
1490
  let h = {
@@ -1512,28 +1493,28 @@ function vt(e, t, n, r, i, a) {
1512
1493
  }, g = {
1513
1494
  explicitCount: m.length,
1514
1495
  names: d.lineNames
1515
- }, _ = Mt(s.map((e) => ({
1516
- col: jt(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1517
- row: jt(e.style.gridRowStart, e.style.gridRowEnd, g)
1496
+ }, _ = jt(s.map((e) => ({
1497
+ col: At(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1498
+ row: At(e.style.gridRowStart, e.style.gridRowEnd, g)
1518
1499
  })), p.length, m.length, o.gridAutoFlow);
1519
- return c && bt(_, "col", p.length), l && bt(_, "row", m.length), {
1500
+ return c && yt(_, "col", p.length), l && yt(_, "row", m.length), {
1520
1501
  children: s,
1521
1502
  placed: _,
1522
1503
  colLines: h,
1523
1504
  rowLines: g,
1524
- colTracks: Dt(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1525
- rowTracks: Dt(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1526
- colCollapsed: Ot(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1527
- rowCollapsed: Ot(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
1505
+ colTracks: Et(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1506
+ rowTracks: Et(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1507
+ colCollapsed: Dt(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1508
+ rowCollapsed: Dt(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
1528
1509
  };
1529
1510
  }
1530
- function yt(e) {
1511
+ function vt(e) {
1531
1512
  return {
1532
- tracks: Array.from({ length: e }, () => st()),
1513
+ tracks: Array.from({ length: e }, () => ot()),
1533
1514
  lineNames: Array.from({ length: e + 1 }, () => [])
1534
1515
  };
1535
1516
  }
1536
- function bt(e, t, n) {
1517
+ function yt(e, t, n) {
1537
1518
  let r = t === "col" ? e.colOrigin : e.rowOrigin;
1538
1519
  for (let i of e.items) {
1539
1520
  let e = i[t], a = Math.min(Math.max(e.start + r, 0), n - 1), o = Math.min(Math.max(e.start + r + e.span, a + 1), n);
@@ -1541,16 +1522,16 @@ function bt(e, t, n) {
1541
1522
  }
1542
1523
  t === "col" ? (e.colOrigin = 0, e.colCount = n) : (e.rowOrigin = 0, e.rowCount = n);
1543
1524
  }
1544
- function xt(e) {
1525
+ function bt(e) {
1545
1526
  return e.children.filter((e) => !z(e.style) && !e.inlineBox).sort((e, t) => e.style.order - t.style.order);
1546
1527
  }
1547
- function St(e) {
1528
+ function xt(e) {
1548
1529
  return (e.left ?? 0) + (e.right ?? 0);
1549
1530
  }
1550
- function Ct(e) {
1531
+ function St(e) {
1551
1532
  return (e.top ?? 0) + (e.bottom ?? 0);
1552
1533
  }
1553
- function wt(e, t, n) {
1534
+ function Ct(e, t, n) {
1554
1535
  if (e.kind !== "tracks") return {
1555
1536
  tracks: [],
1556
1537
  lineNames: [[]]
@@ -1563,7 +1544,7 @@ function wt(e, t, n) {
1563
1544
  let { index: i, tracks: a, mode: o } = e.autoRepeat, s = 1;
1564
1545
  if (t !== void 0) {
1565
1546
  let e = a.reduce((e, n) => {
1566
- let r = Tt(n.min, t) ?? Tt(n.max, t) ?? 1;
1547
+ let r = wt(n.min, t) ?? wt(n.max, t) ?? 1;
1567
1548
  return e + Math.max(1, r);
1568
1549
  }, 0);
1569
1550
  s = Math.max(1, Math.floor((t + n) / (e + n * a.length)));
@@ -1591,23 +1572,23 @@ function wt(e, t, n) {
1591
1572
  lineNames: d
1592
1573
  };
1593
1574
  }
1594
- function Tt(e, t) {
1575
+ function wt(e, t) {
1595
1576
  if (e.kind === "cells") return e.value;
1596
- if (e.kind === "percent" && t !== void 0) return we(e.value, t);
1577
+ if (e.kind === "percent" && t !== void 0) return Ce(e.value, t);
1597
1578
  if (e.kind === "math") {
1598
1579
  let n = [];
1599
1580
  for (let r of e.args) {
1600
- let e = Tt(r, t);
1581
+ let e = wt(r, t);
1601
1582
  if (e === void 0) return;
1602
1583
  n.push(e);
1603
1584
  }
1604
1585
  return e.fn === "min" ? Math.min(...n) : Math.max(...n);
1605
1586
  }
1606
1587
  }
1607
- function Et(e, t, n, r) {
1588
+ function Tt(e, t, n, r) {
1608
1589
  for (let i = e.length; i < n; i++) e.push(r[(i - e.length) % r.length]), t.push([]);
1609
1590
  }
1610
- function Dt(e, t, n, r) {
1591
+ function Et(e, t, n, r) {
1611
1592
  let i = [];
1612
1593
  for (let a = 0; a < n; a++) {
1613
1594
  let n = a + t;
@@ -1619,7 +1600,7 @@ function Dt(e, t, n, r) {
1619
1600
  }
1620
1601
  return i;
1621
1602
  }
1622
- function Ot(e, t, n, r) {
1603
+ function Dt(e, t, n, r) {
1623
1604
  let i = Array.from({ length: n }, () => !1);
1624
1605
  if (!e.autoFit) return i;
1625
1606
  for (let a = e.autoFit.start; a < e.autoFit.end; a++) {
@@ -1628,7 +1609,7 @@ function Ot(e, t, n, r) {
1628
1609
  }
1629
1610
  return i;
1630
1611
  }
1631
- function kt(e, t, n) {
1612
+ function Ot(e, t, n) {
1632
1613
  if (e.kind === "line") return e.value > 0 ? e.value - 1 : n.explicitCount + 1 + e.value;
1633
1614
  if (e.kind !== "name") return null;
1634
1615
  if (e.nth === void 0) {
@@ -1643,14 +1624,14 @@ function kt(e, t, n) {
1643
1624
  for (let t = i; t >= 0; t--) if (n.names[t].includes(e.name) && ++a === -r) return t;
1644
1625
  return -(-r - a);
1645
1626
  }
1646
- function At(e, t, n, r) {
1627
+ function kt(e, t, n, r) {
1647
1628
  if (t.name === void 0) return e + n * t.value;
1648
1629
  let i = t.value, a = e;
1649
1630
  for (; i > 0;) a += n, (!(a >= 0 && a <= r.explicitCount) || r.names[a].includes(t.name)) && i--;
1650
1631
  return a;
1651
1632
  }
1652
- function jt(e, t, n) {
1653
- let r = kt(e, "start", n), i = kt(t, "end", n);
1633
+ function At(e, t, n) {
1634
+ let r = Ot(e, "start", n), i = Ot(t, "end", n);
1654
1635
  if (r !== null && i !== null) return r === i ? {
1655
1636
  start: r,
1656
1637
  span: 1
@@ -1660,10 +1641,10 @@ function jt(e, t, n) {
1660
1641
  };
1661
1642
  if (r !== null) return {
1662
1643
  start: r,
1663
- span: (t.kind === "span" ? At(r, t, 1, n) : r + 1) - r
1644
+ span: (t.kind === "span" ? kt(r, t, 1, n) : r + 1) - r
1664
1645
  };
1665
1646
  if (i !== null) {
1666
- let t = e.kind === "span" ? At(i, e, -1, n) : i - 1;
1647
+ let t = e.kind === "span" ? kt(i, e, -1, n) : i - 1;
1667
1648
  return {
1668
1649
  start: t,
1669
1650
  span: i - t
@@ -1674,7 +1655,7 @@ function jt(e, t, n) {
1674
1655
  span: e.kind === "span" ? e.value : t.kind === "span" ? t.value : 1
1675
1656
  };
1676
1657
  }
1677
- function Mt(e, t, n, r) {
1658
+ function jt(e, t, n, r) {
1678
1659
  let i = r.direction === "row", a = e.map((e) => i ? e.row : e.col), o = e.map((e) => i ? e.col : e.row), s = i ? t : n, c = i ? n : t, l = 0, u = Math.max(s, 1);
1679
1660
  for (let t = 0; t < e.length; t++) {
1680
1661
  let e = o[t];
@@ -1771,7 +1752,7 @@ function Mt(e, t, n, r) {
1771
1752
  rowCount: S
1772
1753
  };
1773
1754
  }
1774
- function Nt(e, t, n, r, i, a) {
1755
+ function Mt(e, t, n, r, i, a) {
1775
1756
  let o = typeof r == "number" ? r : void 0, s = e.map((e, n) => {
1776
1757
  if (t[n]) return {
1777
1758
  base: 0,
@@ -1781,7 +1762,7 @@ function Nt(e, t, n, r, i, a) {
1781
1762
  frFactor: 0,
1782
1763
  collapsed: !0
1783
1764
  };
1784
- let r = Tt(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1765
+ let r = wt(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1785
1766
  if (s.kind === "fr") return {
1786
1767
  base: i,
1787
1768
  limit: null,
@@ -1790,7 +1771,7 @@ function Nt(e, t, n, r, i, a) {
1790
1771
  frFactor: s.value,
1791
1772
  collapsed: !1
1792
1773
  };
1793
- let c = Tt(s, o);
1774
+ let c = wt(s, o);
1794
1775
  return c === void 0 ? {
1795
1776
  base: i,
1796
1777
  limit: null,
@@ -1824,7 +1805,7 @@ function Nt(e, t, n, r, i, a) {
1824
1805
  if (n.length === 0) continue;
1825
1806
  let i = t.reduce((e, t) => e + t.base, 0) + r, a = e.min - i;
1826
1807
  if (a > 0) {
1827
- let e = n.reduce((e, t) => e + t.frFactor, 0), t = R(n.map((t) => e > 0 ? t.frFactor : 1), a);
1808
+ let e = n.reduce((e, t) => e + t.frFactor, 0), t = L(n.map((t) => e > 0 ? t.frFactor : 1), a);
1828
1809
  n.forEach((e, n) => {
1829
1810
  e.base += t[n];
1830
1811
  });
@@ -1835,7 +1816,7 @@ function Nt(e, t, n, r, i, a) {
1835
1816
  if (i.length > 0) {
1836
1817
  let n = t.reduce((e, t) => e + t.base, 0) + r, a = e.min - n;
1837
1818
  if (a > 0) {
1838
- let e = R(i.map(() => 1), a);
1819
+ let e = L(i.map(() => 1), a);
1839
1820
  i.forEach((t, n) => {
1840
1821
  t.base += e[n];
1841
1822
  });
@@ -1846,7 +1827,7 @@ function Nt(e, t, n, r, i, a) {
1846
1827
  if (e.length === 0) continue;
1847
1828
  let a = i - (t.reduce((e, t) => e + u(t), 0) + r);
1848
1829
  if (a > 0) {
1849
- let t = R(e.map(() => 1), a);
1830
+ let t = L(e.map(() => 1), a);
1850
1831
  e.forEach((e, n) => {
1851
1832
  e.limit = u(e) + t[n];
1852
1833
  });
@@ -1868,7 +1849,7 @@ function Nt(e, t, n, r, i, a) {
1868
1849
  n <= 0 || (t = Math.max(t, (e.max - r) / Math.max(n, 1)));
1869
1850
  }
1870
1851
  for (let n of e) {
1871
- let e = Math.max(n.base, P(n.frFactor * t));
1852
+ let e = Math.max(n.base, N(n.frFactor * t));
1872
1853
  n.limit = e, r === "max-content" && (n.base = e);
1873
1854
  }
1874
1855
  }
@@ -1878,7 +1859,7 @@ function Nt(e, t, n, r, i, a) {
1878
1859
  for (; !(t <= 0);) {
1879
1860
  let e = s.filter((e) => !e.collapsed && e.limitKind !== "fr" && e.base < u(e));
1880
1861
  if (e.length === 0) break;
1881
- let n = R(e.map(() => 1), t), r = 0;
1862
+ let n = L(e.map(() => 1), t), r = 0;
1882
1863
  if (e.forEach((e, t) => {
1883
1864
  let i = Math.min(n[t], u(e) - e.base);
1884
1865
  e.base += i, r += i;
@@ -1888,7 +1869,7 @@ function Nt(e, t, n, r, i, a) {
1888
1869
  if (n.length > 0) {
1889
1870
  let t = Math.max(0, o - e - s.reduce((e, t) => e + (t.limitKind === "fr" ? 0 : t.base), 0)), r = n, i = t, a = n.reduce((e, t) => e + t.frFactor, 0);
1890
1871
  for (a < 1 && (i = Math.floor(i * a));;) {
1891
- let e = R(r.map((e) => e.frFactor), i), t = r.filter((t, n) => e[n] < t.base);
1872
+ let e = L(r.map((e) => e.frFactor), i), t = r.filter((t, n) => e[n] < t.base);
1892
1873
  if (t.length === 0) {
1893
1874
  r.forEach((t, n) => {
1894
1875
  t.base = Math.max(t.base, e[n]);
@@ -1902,7 +1883,7 @@ function Nt(e, t, n, r, i, a) {
1902
1883
  if (a) {
1903
1884
  let t = o - e - s.reduce((e, t) => e + t.base, 0), n = s.filter((e) => !e.collapsed && e.limitKind === "intrinsic-max");
1904
1885
  if (t > 0 && n.length > 0) {
1905
- let e = R(n.map(() => 1), t);
1886
+ let e = L(n.map(() => 1), t);
1906
1887
  n.forEach((t, n) => {
1907
1888
  t.base += e[n];
1908
1889
  });
@@ -1915,65 +1896,65 @@ function Nt(e, t, n, r, i, a) {
1915
1896
  limits: s.map((e) => u(e))
1916
1897
  };
1917
1898
  }
1918
- function Pt(e, t, n) {
1919
- let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - Ft(e)), o = L(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1899
+ function Nt(e, t, n) {
1900
+ let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - Pt(e)), o = I(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1920
1901
  for (let e = 0; e < r.length; e++) c += i[e], s.push(o[e] + c);
1921
1902
  return s;
1922
1903
  }
1923
- function Ft(e) {
1904
+ function Pt(e) {
1924
1905
  return e.sizes.reduce((e, t) => e + t, 0) + e.gapBefore.reduce((e, t) => e + t, 0);
1925
1906
  }
1926
- function It(e, t, n, r) {
1907
+ function Ft(e, t, n, r) {
1927
1908
  let i = n + r - 1;
1928
1909
  return e[n] === void 0 || e[i] === void 0 ? 0 : e[i] + t[i] - e[n];
1929
1910
  }
1930
- function Lt(e, t, n, r, i) {
1911
+ function It(e, t, n, r, i) {
1931
1912
  let a = t ?? 0, o = n ?? 0, s = r - i;
1932
- return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + Xe(e, r, i + a + o);
1913
+ return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + Ye(e, r, i + a + o);
1933
1914
  }
1934
1915
  //#endregion
1935
1916
  //#region src/multicol.ts
1936
- function Rt(e, t, n) {
1917
+ function Lt(e, t, n) {
1937
1918
  let r = e.columnWidth === null ? null : Math.max(1, Math.floor((t + n) / (e.columnWidth + n)));
1938
1919
  return e.columnCount !== null && r !== null ? Math.max(1, Math.min(e.columnCount, r)) : r === null ? Math.max(1, e.columnCount ?? 1) : r;
1939
1920
  }
1940
- function zt(e, t, n) {
1941
- let r = Rt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r)), a = Math.max(0, t - (r * i + (r - 1) * n));
1921
+ function Rt(e, t, n) {
1922
+ let r = Lt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r)), a = Math.max(0, t - (r * i + (r - 1) * n));
1942
1923
  return Array.from({ length: r }, (e, t) => i + +(t < a));
1943
1924
  }
1944
- function Bt(e, t) {
1925
+ function zt(e, t) {
1945
1926
  let n = Math.max(typeof e.gapX == "number" ? e.gapX : 0, e.ruleX?.width ?? 0);
1946
1927
  return e.columnCount === null ? Math.max(e.columnWidth ?? 1, t) : e.columnCount * t + (e.columnCount - 1) * n;
1947
1928
  }
1948
- function Vt(e, t) {
1929
+ function Bt(e, t) {
1949
1930
  return e === void 0 ? t : t === void 0 ? e : Math.min(e, t);
1950
1931
  }
1951
- function Ht(e, t, n) {
1932
+ function Vt(e, t, n) {
1952
1933
  for (; e < t;) {
1953
1934
  let r = e + t >> 1;
1954
1935
  n(r) ? t = r : e = r + 1;
1955
1936
  }
1956
1937
  return e;
1957
1938
  }
1958
- function Ut(e, t, n) {
1959
- let r = Rt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1939
+ function Ht(e, t, n) {
1940
+ let r = Lt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1960
1941
  return {
1961
1942
  count: r,
1962
1943
  width: i,
1963
1944
  leftover: Math.max(0, t - (r * i + (r - 1) * n))
1964
1945
  };
1965
1946
  }
1966
- function Wt(e, t, n) {
1947
+ function Ut(e, t, n) {
1967
1948
  return e === "all" ? !0 : e === "around" ? t || n : t && n;
1968
1949
  }
1969
- function Gt(e, t, n, r) {
1970
- let i = Un(e, Math.max(1, t.width - e.style.tracking)), { heights: a, textOffsets: o } = Wn(e, i), s = e.style.lineGap, c = qt(a.map((e) => e + s)), l;
1950
+ function Wt(e, t, n, r) {
1951
+ let i = Hn(e, Math.max(1, t.width - e.style.tracking)), { heights: a, textOffsets: o } = Un(e, i), s = e.style.lineGap, c = Kt(a.map((e) => e + s)), l;
1971
1952
  if (e.style.columnFill === "auto" && r !== void 0) l = Math.max(1, r);
1972
1953
  else {
1973
- let e = Ht(c.reduce((e, t) => Math.max(e, t.rows - s), 1), Math.max(1, c.reduce((e, t) => e + t.rows, 0) - s), (e) => Kt(c, s, e).columns <= t.count);
1954
+ let e = Vt(c.reduce((e, t) => Math.max(e, t.rows - s), 1), Math.max(1, c.reduce((e, t) => e + t.rows, 0) - s), (e) => Gt(c, s, e).columns <= t.count);
1974
1955
  l = r === void 0 ? e : Math.max(1, Math.min(e, r));
1975
1956
  }
1976
- let u = Kt(c, s, l);
1957
+ let u = Gt(c, s, l);
1977
1958
  return {
1978
1959
  spans: i,
1979
1960
  lineY: u.top,
@@ -1986,7 +1967,7 @@ function Gt(e, t, n, r) {
1986
1967
  columnsUsed: i.length > 0 ? u.columns : 0
1987
1968
  };
1988
1969
  }
1989
- function Kt(e, t, n, r = "truncate") {
1970
+ function Gt(e, t, n, r = "truncate") {
1990
1971
  let i = 0, a = 0, o = 0, s = [], c = [];
1991
1972
  for (let l = 0; l < e.length; l++) {
1992
1973
  let u = e[l], d = r === "glue" || l === 0 || a > 0 ? u.pre : 0;
@@ -2007,7 +1988,7 @@ function Kt(e, t, n, r = "truncate") {
2007
1988
  top: c
2008
1989
  };
2009
1990
  }
2010
- function qt(e) {
1991
+ function Kt(e) {
2011
1992
  return e.map((e) => ({
2012
1993
  rows: e,
2013
1994
  pre: 0,
@@ -2016,27 +1997,27 @@ function qt(e) {
2016
1997
  lines: 1
2017
1998
  }));
2018
1999
  }
2019
- var Jt = null;
2020
- function Yt() {
2021
- if (Jt !== null) return Jt;
2000
+ var qt = null;
2001
+ function Jt() {
2002
+ if (qt !== null) return qt;
2022
2003
  let e = document.createElement("div");
2023
2004
  e.style.cssText = "position:absolute;left:-9999px;visibility:hidden;columns:2;column-gap:0;column-fill:balance;width:200px;font:10px/20px monospace;orphans:1;widows:1", e.innerHTML = "<div style=\"margin:0;padding:0 0 20px 0\">aaaaaa aaaaaa aaaaaa</div><div style=\"margin:0\"><span>bbbbbb</span> bbbbbb</div>", document.body.appendChild(e);
2024
2005
  let t = e.getBoundingClientRect().top, n = e.querySelector("span").getBoundingClientRect();
2025
- return e.remove(), Jt = !(n.width > 0 && n.top - t >= 10), Jt;
2006
+ return e.remove(), qt = !(n.width > 0 && n.top - t >= 10), qt;
2026
2007
  }
2027
- function Xt(e, t) {
2028
- let { columnWidth: n, columnCount: r, tracking: i = 0, lineGap: a = 0, restrictingHeight: o } = t, s = i > 0 ? Array.from(e, () => 1 + i) : void 0, c = je(e, Math.max(1, n - i), {
2008
+ function Yt(e, t) {
2009
+ let { columnWidth: n, columnCount: r, tracking: i = 0, lineGap: a = 0, restrictingHeight: o } = t, s = i > 0 ? Array.from(e, () => 1 + i) : void 0, c = Ae(e, Math.max(1, n - i), {
2029
2010
  advances: s,
2030
2011
  tracking: i,
2031
2012
  firstLineIndent: t.firstLineIndent
2032
- }), l = qt(c.map(() => 1 + a)), u = Kt(l, a, o ?? Ht(1, Math.max(1, c.length * (1 + a) - a), (e) => Kt(l, a, e).columns <= r));
2013
+ }), l = Kt(c.map(() => 1 + a)), u = Gt(l, a, o ?? Vt(1, Math.max(1, c.length * (1 + a) - a), (e) => Gt(l, a, e).columns <= r));
2033
2014
  return c.map((t, n) => ({
2034
2015
  text: e.slice(t.start, t.end),
2035
2016
  column: u.column[n],
2036
2017
  top: u.top[n]
2037
2018
  }));
2038
2019
  }
2039
- function Zt(e, t, n, r) {
2020
+ function Xt(e, t, n, r) {
2040
2021
  let i = e.style;
2041
2022
  if (!i.ruleX) return;
2042
2023
  let a = t.columnCount * t.columnWidth + (t.columnCount - 1) * t.gap, o = t.ruleSegments ?? [{
@@ -2046,18 +2027,18 @@ function Zt(e, t, n, r) {
2046
2027
  }], s = [];
2047
2028
  for (let e of o) {
2048
2029
  let n = Math.min(e.columns, t.columnCount);
2049
- for (let r = 0; r < t.columnCount - 1; r++) Wt(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
2030
+ for (let r = 0; r < t.columnCount - 1; r++) Ut(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
2050
2031
  bandStart: (r + 1) * t.columnWidth + r * t.gap,
2051
2032
  bandSize: t.gap,
2052
2033
  start: e.start,
2053
2034
  end: e.end
2054
2035
  });
2055
2036
  }
2056
- e.decorationRuns = be({
2037
+ e.decorationRuns = xe({
2057
2038
  glyphs: S(i.glyphSet),
2058
2039
  ruleX: i.ruleX,
2059
2040
  ruleY: null,
2060
- vertical: He(s, i.ruleInset),
2041
+ vertical: Ve(s, i.ruleInset),
2061
2042
  horizontal: [],
2062
2043
  contentWidth: a,
2063
2044
  contentHeight: t.totalRows,
@@ -2067,12 +2048,12 @@ function Zt(e, t, n, r) {
2067
2048
  padding: r
2068
2049
  });
2069
2050
  }
2070
- function Qt(e, t) {
2051
+ function Zt(e, t) {
2071
2052
  let n = e.style, r = n.padding;
2072
2053
  return e.text !== "" && e.children.length === 0 && n.display === "block" && n.position === "static" && !n.columnSpan && n.whiteSpace === "normal" && n.lineGap === t.lineGap && n.border.top === 0 && n.border.right === 0 && n.border.bottom === 0 && n.border.left === 0 && r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0 && n.backgroundColor === void 0 && !n.backgroundClear && n.overflow.x === "visible" && n.overflow.y === "visible" && (n.width === void 0 || n.width.kind === "auto") && (n.height === void 0 || n.height.kind === "auto") && (n.minWidth === "auto" || n.minWidth === 0 || n.minWidth === void 0) && (n.minHeight === "auto" || n.minHeight === 0 || n.minHeight === void 0) && n.maxWidth === void 0 && n.maxHeight === void 0;
2073
2054
  }
2074
- function $t(e, t, n, r, i, a, o) {
2075
- let s = e.style, c = H(s, "x", n), l = Ut(s, n, c);
2055
+ function Qt(e, t, n, r, i, a, o) {
2056
+ let s = e.style, c = Wn(s, "x", n), l = Ht(s, n, c);
2076
2057
  a.right += l.leftover;
2077
2058
  let u = s.lineGap, d = i.left + a.left, f = i.top + a.top, p = n - l.leftover, m = [[]], h = [];
2078
2059
  for (let e of t) e.style.columnSpan ? (h[m.length - 1] = e, m.push([])) : m[m.length - 1].push(e);
@@ -2082,8 +2063,8 @@ function $t(e, t, n, r, i, a, o) {
2082
2063
  if (t.length > 0) {
2083
2064
  let i = t.map((e) => ({
2084
2065
  node: e,
2085
- spans: Un(e, Math.max(1, l.width - e.style.tracking)),
2086
- margin: W(e.style.margin, l.width),
2066
+ spans: Hn(e, Math.max(1, l.width - e.style.tracking)),
2067
+ margin: U(e.style.margin, l.width),
2087
2068
  pre: 0,
2088
2069
  post: 0
2089
2070
  })), a = [], o = null, h = null, x = !1;
@@ -2111,10 +2092,10 @@ function $t(e, t, n, r, i, a, o) {
2111
2092
  let S;
2112
2093
  if (s.columnFill === "auto" && r !== void 0) S = Math.max(1, r);
2113
2094
  else {
2114
- let e = Ht(1, Math.max(1, Kt(a, u, Infinity, _).maxUsed), (e) => Kt(a, u, e, _).columns <= l.count);
2095
+ let e = Vt(1, Math.max(1, Gt(a, u, Infinity, _).maxUsed), (e) => Gt(a, u, e, _).columns <= l.count);
2115
2096
  S = r === void 0 ? e : Math.max(1, Math.min(e, r));
2116
2097
  }
2117
- let C = Kt(a, u, S, _);
2098
+ let C = Gt(a, u, S, _);
2118
2099
  for (let e = 0, t = 0; e < i.length; e++) {
2119
2100
  let { node: n, spans: r, margin: a, pre: o, post: s } = i[e], u = [], m = [];
2120
2101
  for (let e = 0; e < r.length; e++, t++) u.push(y + C.top[t]), m.push(C.column[t] * (l.width + c));
@@ -2153,7 +2134,7 @@ function $t(e, t, n, r, i, a, o) {
2153
2134
  }
2154
2135
  let i = h[e];
2155
2136
  if (i) {
2156
- let e = W(i.style.margin, p), t = (e.left ?? 0) + (e.right ?? 0);
2137
+ let e = U(i.style.margin, p), t = (e.left ?? 0) + (e.right ?? 0);
2157
2138
  B(i, Math.max(0, p - t), void 0, 0, 0, "fill", o);
2158
2139
  let r = Jn(e, p, i.localRect.width), a = (e.top ?? 0) + n;
2159
2140
  y += a, i.localRect = {
@@ -2171,7 +2152,7 @@ function $t(e, t, n, r, i, a, o) {
2171
2152
  let x = y;
2172
2153
  for (let t of e.children) {
2173
2154
  if (!z(t.style)) continue;
2174
- let e = W(t.style.margin, n);
2155
+ let e = U(t.style.margin, n);
2175
2156
  t.staticSlot = {
2176
2157
  kind: "block",
2177
2158
  x: d + (e.left ?? 0),
@@ -2194,10 +2175,10 @@ function $t(e, t, n, r, i, a, o) {
2194
2175
  } : {}
2195
2176
  }, x;
2196
2177
  }
2197
- function en(e, t, n, r, i, a, o) {
2198
- let s = e.style, c = Vt(n, r), l = e.children.filter((e) => !z(e.style)), u = l.filter((e) => !e.style.columnSpan), d = l.reduce((e, t, n) => !t.style.columnSpan && (n === 0 || l[n - 1].style.columnSpan) ? e + 1 : e, 0);
2199
- if (u.length > 0 && u.every((e) => Qt(e, s)) && (u.length === l.length || s.columnFill === "balance" && c === void 0 && (Yt() || d <= 1 && u.every((e) => (e.style.margin.top === 0 || e.style.margin.top === null) && (e.style.margin.bottom === 0 || e.style.margin.bottom === null))))) return $t(e, l, t, c, i, a, o);
2200
- let f = H(s, "x", t), p = zt(s, t, f), m = p.length, h = [];
2178
+ function $t(e, t, n, r, i, a, o) {
2179
+ let s = e.style, c = Bt(n, r), l = e.children.filter((e) => !z(e.style)), u = l.filter((e) => !e.style.columnSpan), d = l.reduce((e, t, n) => !t.style.columnSpan && (n === 0 || l[n - 1].style.columnSpan) ? e + 1 : e, 0);
2180
+ if (u.length > 0 && u.every((e) => Zt(e, s)) && (u.length === l.length || s.columnFill === "balance" && c === void 0 && (Jt() || d <= 1 && u.every((e) => (e.style.margin.top === 0 || e.style.margin.top === null) && (e.style.margin.bottom === 0 || e.style.margin.bottom === null))))) return Qt(e, l, t, c, i, a, o);
2181
+ let f = Wn(s, "x", t), p = Rt(s, t, f), m = p.length, h = [];
2201
2182
  {
2202
2183
  let e = 0;
2203
2184
  for (let t of p) h.push(e), e += t + f;
@@ -2249,13 +2230,13 @@ function en(e, t, n, r, i, a, o) {
2249
2230
  let e = c === void 0 ? void 0 : Math.max(1, c - C), t = s.columnFill === "auto" && e !== void 0, r;
2250
2231
  if (t) r = e;
2251
2232
  else {
2252
- let t = Ht(1, D(Infinity, !1).maxUsed, (e) => D(e, !1).columns <= m);
2233
+ let t = Vt(1, D(Infinity, !1).maxUsed, (e) => D(e, !1).columns <= m);
2253
2234
  r = e === void 0 ? t : Math.min(t, e);
2254
2235
  }
2255
2236
  let i = D(r, !0), a = t && n !== void 0 ? Math.max(i.maxUsed, r) : i.maxUsed;
2256
2237
  if (s.ruleX) for (let e = 0; e < m - 1; e++) {
2257
2238
  let t = Math.min(i.columns, m);
2258
- Wt(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2239
+ Ut(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2259
2240
  bandStart: h[e] + p[e],
2260
2241
  bandSize: f,
2261
2242
  start: C,
@@ -2268,14 +2249,14 @@ function en(e, t, n, r, i, a, o) {
2268
2249
  if (z(r.style)) {
2269
2250
  T.push({
2270
2251
  child: r,
2271
- margin: W(r.style.margin, t),
2252
+ margin: U(r.style.margin, t),
2272
2253
  index: w.length
2273
2254
  });
2274
2255
  continue;
2275
2256
  }
2276
2257
  if (r.style.columnSpan) {
2277
2258
  O(), E = !1;
2278
- let e = W(r.style.margin, t), i = (e.left ?? 0) + (e.right ?? 0);
2259
+ let e = U(r.style.margin, t), i = (e.left ?? 0) + (e.right ?? 0);
2279
2260
  B(r, Math.max(0, t - i), n, 0, 0, "fill", o), C += e.top ?? 0, r.localRect = {
2280
2261
  ...r.localRect,
2281
2262
  x: y + Jn(e, t, r.localRect.width),
@@ -2283,18 +2264,18 @@ function en(e, t, n, r, i, a, o) {
2283
2264
  }, C += r.localRect.height + (e.bottom ?? 0);
2284
2265
  continue;
2285
2266
  }
2286
- let e = W(r.style.margin, v), i = (e.left ?? 0) + (e.right ?? 0);
2267
+ let e = U(r.style.margin, v), i = (e.left ?? 0) + (e.right ?? 0);
2287
2268
  B(r, Math.max(0, v - i), n, 0, 0, "fill", o), w.push({
2288
2269
  node: r,
2289
2270
  margin: e,
2290
2271
  breakBefore: E || r.style.breakBeforeColumn
2291
2272
  }), E = r.style.breakAfterColumn;
2292
2273
  }
2293
- return O(), s.ruleX && x.length > 0 && (e.decorationRuns = be({
2274
+ return O(), s.ruleX && x.length > 0 && (e.decorationRuns = xe({
2294
2275
  glyphs: S(s.glyphSet),
2295
2276
  ruleX: s.ruleX,
2296
2277
  ruleY: null,
2297
- vertical: He(x, s.ruleInset),
2278
+ vertical: Ve(x, s.ruleInset),
2298
2279
  horizontal: [],
2299
2280
  contentWidth: t,
2300
2281
  contentHeight: C,
@@ -2306,32 +2287,32 @@ function en(e, t, n, r, i, a, o) {
2306
2287
  }
2307
2288
  //#endregion
2308
2289
  //#region src/table.ts
2309
- function tn(e, t) {
2310
- e.hidden.push(t), t.style.tableRole !== "column" && t.style.tableRole !== "column-group" && N(t.source, "Table content outside the expected structure (rows in tables, cells in rows) can't be laid out and was hidden — no anonymous table boxes (specs/table.md).");
2290
+ function en(e, t) {
2291
+ e.hidden.push(t), t.style.tableRole !== "column" && t.style.tableRole !== "column-group" && M(t.source, "Table content outside the expected structure (rows in tables, cells in rows) can't be laid out and was hidden — no anonymous table boxes (specs/table.md).");
2311
2292
  }
2312
- function nn(e, t) {
2293
+ function tn(e, t) {
2313
2294
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
2314
2295
  return Number.isNaN(n) ? 1 : t === "colspan" ? Math.min(1e3, Math.max(1, n)) : Math.min(65534, Math.max(0, n));
2315
2296
  }
2316
- function rn(e, t, n) {
2297
+ function nn(e, t, n) {
2317
2298
  let r = (t, r) => {
2318
- let i = t.style.width, a = i && i.kind !== "auto" && i.kind !== "percent" ? K(i, 0, t, n) : void 0, o = i && i.kind === "percent" ? i.value : void 0;
2299
+ let i = t.style.width, a = i && i.kind !== "auto" && i.kind !== "percent" ? G(i, 0, t, n) : void 0, o = i && i.kind === "percent" ? i.value : void 0;
2319
2300
  for (let t = 0; t < r; t++) e.colFixed.push(a), e.colPercent.push(o);
2320
2301
  };
2321
2302
  if (t.style.tableRole === "column") {
2322
- r(t, an(t.source));
2303
+ r(t, rn(t.source));
2323
2304
  return;
2324
2305
  }
2325
2306
  let i = t.children.filter((e) => e.style.tableRole === "column");
2326
- if (i.length === 0) r(t, an(t.source));
2327
- else for (let e of i) r(e, an(e.source));
2328
- for (let n of t.children) n.style.tableRole !== "column" && tn(e, n);
2307
+ if (i.length === 0) r(t, rn(t.source));
2308
+ else for (let e of i) r(e, rn(e.source));
2309
+ for (let n of t.children) n.style.tableRole !== "column" && en(e, n);
2329
2310
  }
2330
- function an(e) {
2311
+ function rn(e) {
2331
2312
  let t = Number.parseInt(e.getAttribute("span") ?? "", 10);
2332
2313
  return Number.isNaN(t) ? 1 : Math.min(1e3, Math.max(1, t));
2333
2314
  }
2334
- function on(e, t) {
2315
+ function an(e, t) {
2335
2316
  let n = {
2336
2317
  caption: null,
2337
2318
  rows: [],
@@ -2355,8 +2336,8 @@ function on(e, t) {
2355
2336
  for (let e of o.children) z(e.style) || (e.style.tableRole === "row" ? t.push({
2356
2337
  row: e,
2357
2338
  group: o
2358
- }) : tn(n, e));
2359
- } else e === "caption" ? n.caption === null ? n.caption = o : tn(n, o) : e === "column" || e === "column-group" ? (rn(n, o, t), n.hidden.push(o)) : tn(n, o);
2339
+ }) : en(n, e));
2340
+ } else e === "caption" ? n.caption === null ? n.caption = o : en(n, o) : e === "column" || e === "column-group" ? (nn(n, o, t), n.hidden.push(o)) : en(n, o);
2360
2341
  }
2361
2342
  let o = [
2362
2343
  ...r,
@@ -2371,20 +2352,20 @@ function on(e, t) {
2371
2352
  s = e + 1;
2372
2353
  }
2373
2354
  }
2374
- return sn(n), n;
2355
+ return on(n), n;
2375
2356
  }
2376
- function sn(e) {
2357
+ function on(e) {
2377
2358
  let t = [];
2378
2359
  for (let n = 0; n < e.rows.length; n++) {
2379
2360
  let r = e.rows[n], i = 0;
2380
2361
  for (let a of r.children) {
2381
2362
  if (z(a.style)) continue;
2382
2363
  if (a.style.tableRole !== "cell") {
2383
- tn(e, a);
2364
+ en(e, a);
2384
2365
  continue;
2385
2366
  }
2386
2367
  for (; (t[i] ?? 0) > n;) i++;
2387
- let o = nn(a.source, "colspan"), s = nn(a.source, "rowspan"), c = e.groupEnds[n], l = Math.max(1, Math.min(s === 0 ? c - n : s, c - n));
2368
+ let o = tn(a.source, "colspan"), s = tn(a.source, "rowspan"), c = e.groupEnds[n], l = Math.max(1, Math.min(s === 0 ? c - n : s, c - n));
2388
2369
  for (let e = i; e < i + o; e++) t[e] = Math.max(t[e] ?? 0, n + l);
2389
2370
  e.cells.push({
2390
2371
  node: a,
@@ -2398,21 +2379,21 @@ function sn(e) {
2398
2379
  }
2399
2380
  e.columnCount = Math.max(t.length, e.colFixed.length);
2400
2381
  }
2401
- function cn(e, t, n) {
2402
- let r = e.style, i = Y(e, n), a;
2382
+ function sn(e, t, n) {
2383
+ let r = e.style, i = J(e, n), a;
2403
2384
  if (t === "min") a = i;
2404
2385
  else {
2405
- let t = r.width !== void 0 && r.width.kind !== "auto" && r.width.kind !== "percent" ? K(r.width, 0, e, n) : void 0;
2406
- a = t === void 0 ? q(e, n) : Math.max(i, t);
2386
+ let t = r.width !== void 0 && r.width.kind !== "auto" && r.width.kind !== "percent" ? G(r.width, 0, e, n) : void 0;
2387
+ a = t === void 0 ? K(e, n) : Math.max(i, t);
2407
2388
  }
2408
2389
  let o = typeof r.minWidth == "number" ? r.minWidth : 0, s = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
2409
2390
  return Math.max(0, V(a, o, s));
2410
2391
  }
2411
- function ln(e) {
2392
+ function cn(e) {
2412
2393
  let t = e.style.width;
2413
2394
  return t && t.kind === "percent" ? t.value : void 0;
2414
2395
  }
2415
- function un(e, t, n) {
2396
+ function ln(e, t, n) {
2416
2397
  let r = e.columnCount, i = Array.from({ length: r }, () => 0), a = Array.from({ length: r }, () => 0), o = Array.from({ length: r }, () => void 0);
2417
2398
  for (let t = 0; t < r; t++) e.colFixed[t] !== void 0 && (a[t] = e.colFixed[t]), o[t] = e.colPercent[t];
2418
2399
  let s = [];
@@ -2421,17 +2402,17 @@ function un(e, t, n) {
2421
2402
  s.push(t);
2422
2403
  continue;
2423
2404
  }
2424
- i[t.col] = Math.max(i[t.col], cn(t.node, "min", n)), a[t.col] = Math.max(a[t.col], cn(t.node, "max", n));
2425
- let e = ln(t.node);
2405
+ i[t.col] = Math.max(i[t.col], sn(t.node, "min", n)), a[t.col] = Math.max(a[t.col], sn(t.node, "max", n));
2406
+ let e = cn(t.node);
2426
2407
  e !== void 0 && (o[t.col] = Math.max(o[t.col] ?? 0, e));
2427
2408
  }
2428
2409
  s.sort((e, t) => e.colSpan - t.colSpan);
2429
2410
  for (let e of s) {
2430
- let r = e.col, o = e.col + e.colSpan, s = _n(t, r, o), c = a.slice(r, o);
2411
+ let r = e.col, o = e.col + e.colSpan, s = gn(t, r, o), c = a.slice(r, o);
2431
2412
  for (let t of ["min", "max"]) {
2432
- let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = cn(e.node, t, n) - u;
2413
+ let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = sn(e.node, t, n) - u;
2433
2414
  if (d <= 0) continue;
2434
- let f = R(c.some((e) => e > 0) ? c : c.map(() => 1), d);
2415
+ let f = L(c.some((e) => e > 0) ? c : c.map(() => 1), d);
2435
2416
  for (let e = r; e < o; e++) l[e] += f[e - r];
2436
2417
  }
2437
2418
  }
@@ -2442,7 +2423,7 @@ function un(e, t, n) {
2442
2423
  percent: o
2443
2424
  };
2444
2425
  }
2445
- function dn(e, t) {
2426
+ function un(e, t) {
2446
2427
  let n = e.min.length, r = e.min.slice(), i = [], a = [];
2447
2428
  for (let t = 0; t < n; t++) (e.percent[t] === void 0 ? a : i).push(t);
2448
2429
  if (i.length > 0) {
@@ -2453,32 +2434,32 @@ function dn(e, t) {
2453
2434
  }
2454
2435
  let s = a.reduce((t, n) => t + e.min[n], 0), c = i.reduce((e, t) => e + r[t], 0) - (t - s);
2455
2436
  if (c > 0) {
2456
- let t = i.map((t) => r[t] - e.min[t]), n = R(t, Math.min(c, t.reduce((e, t) => e + t, 0)));
2437
+ let t = i.map((t) => r[t] - e.min[t]), n = L(t, Math.min(c, t.reduce((e, t) => e + t, 0)));
2457
2438
  i.forEach((e, t) => r[e] -= n[t]);
2458
2439
  }
2459
2440
  }
2460
2441
  let o = t - r.reduce((e, t) => e + t, 0);
2461
2442
  if (o > 0 && a.length > 0) {
2462
- let t = a.map((t) => e.max[t] - e.min[t]), n = t.reduce((e, t) => e + t, 0), i = R(t, Math.min(o, n));
2443
+ let t = a.map((t) => e.max[t] - e.min[t]), n = t.reduce((e, t) => e + t, 0), i = L(t, Math.min(o, n));
2463
2444
  a.forEach((e, t) => r[e] += i[t]), o -= Math.min(o, n);
2464
2445
  }
2465
2446
  if (o > 0) {
2466
2447
  let t = a.length > 0 ? a : i;
2467
2448
  if (t.length > 0) {
2468
- let n = t.map((t) => e.max[t]), i = R(n.some((e) => e > 0) ? n : n.map(() => 1), o);
2449
+ let n = t.map((t) => e.max[t]), i = L(n.some((e) => e > 0) ? n : n.map(() => 1), o);
2469
2450
  t.forEach((e, t) => r[e] += i[t]);
2470
2451
  }
2471
2452
  }
2472
2453
  return r;
2473
2454
  }
2474
- function fn(e, t, n) {
2455
+ function dn(e, t, n) {
2475
2456
  let r = e.columnCount, i = Array.from({ length: r }, () => void 0);
2476
2457
  for (let n = 0; n < r; n++) e.colFixed[n] === void 0 ? e.colPercent[n] !== void 0 && (i[n] = Math.max(0, Math.round(t * e.colPercent[n] / 100))) : i[n] = e.colFixed[n];
2477
2458
  for (let r of e.cells) {
2478
2459
  if (r.row !== 0) continue;
2479
2460
  let e = r.node.style, a;
2480
- if (e.width && e.width.kind === "percent" ? a = Math.max(0, Math.round(t * e.width.value / 100)) : e.width && e.width.kind !== "auto" && (a = K(e.width, 0, r.node, n)), a === void 0) continue;
2481
- let o = R(Array.from({ length: r.colSpan }, () => 1), a);
2461
+ if (e.width && e.width.kind === "percent" ? a = Math.max(0, Math.round(t * e.width.value / 100)) : e.width && e.width.kind !== "auto" && (a = G(e.width, 0, r.node, n)), a === void 0) continue;
2462
+ let o = L(Array.from({ length: r.colSpan }, () => 1), a);
2482
2463
  for (let e = 0; e < r.colSpan; e++) {
2483
2464
  let t = r.col + e;
2484
2465
  i[t] === void 0 && (i[t] = o[e]);
@@ -2486,18 +2467,18 @@ function fn(e, t, n) {
2486
2467
  }
2487
2468
  let a = i.reduce((e, t) => e + (t ?? 0), 0), o = i.filter((e) => e === void 0).length;
2488
2469
  if (o > 0) {
2489
- let e = R(Array.from({ length: o }, () => 1), Math.max(0, t - a)), n = 0;
2470
+ let e = L(Array.from({ length: o }, () => 1), Math.max(0, t - a)), n = 0;
2490
2471
  for (let t = 0; t < r; t++) i[t] === void 0 && (i[t] = e[n++]);
2491
2472
  }
2492
2473
  return i.map((e) => e ?? 0);
2493
2474
  }
2494
- var pn = {
2475
+ var fn = {
2495
2476
  double: 3,
2496
2477
  solid: 2,
2497
2478
  dashed: 1,
2498
2479
  dotted: 0
2499
2480
  };
2500
- function mn(e) {
2481
+ function pn(e) {
2501
2482
  for (let { border: t, side: n } of e) if (t?.hidden[n]) return null;
2502
2483
  let t = null;
2503
2484
  for (let { border: n, side: r } of e) {
@@ -2505,7 +2486,7 @@ function mn(e) {
2505
2486
  let e = n.width[r];
2506
2487
  if (e <= 0) continue;
2507
2488
  let i = n.style[r];
2508
- (t === null || e > t.width || e === t.width && pn[i] > pn[t.style]) && (t = {
2489
+ (t === null || e > t.width || e === t.width && fn[i] > fn[t.style]) && (t = {
2509
2490
  width: e,
2510
2491
  style: i,
2511
2492
  color: n.color[r]
@@ -2513,7 +2494,7 @@ function mn(e) {
2513
2494
  }
2514
2495
  return t;
2515
2496
  }
2516
- function hn(e, t) {
2497
+ function mn(e, t) {
2517
2498
  let n = t.columnCount, r = t.rows.length, i = e.style.borderCollapse, a = {
2518
2499
  collapsed: i,
2519
2500
  vLines: Array.from({ length: n + 1 }, () => 0),
@@ -2558,7 +2539,7 @@ function hn(e, t) {
2558
2539
  side: u
2559
2540
  });
2560
2541
  }
2561
- i.push(mn(l));
2542
+ i.push(pn(l));
2562
2543
  }
2563
2544
  a.vSegments.push(i), a.vLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2564
2545
  }
@@ -2597,47 +2578,47 @@ function hn(e, t) {
2597
2578
  }), e === r && l.push({
2598
2579
  border: s,
2599
2580
  side: "bottom"
2600
- }), i.push(mn(l));
2581
+ }), i.push(pn(l));
2601
2582
  }
2602
2583
  a.hSegments.push(i), a.hLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2603
2584
  }
2604
2585
  return a;
2605
2586
  }
2606
- function gn(e, t) {
2587
+ function hn(e, t) {
2607
2588
  return e.collapsed ? e.vLines.reduce((e, t) => e + t, 0) : (t + 1) * e.spacingX;
2608
2589
  }
2609
- function _n(e, t, n) {
2590
+ function gn(e, t, n) {
2610
2591
  if (!e.collapsed) return e.spacingX * (n - t - 1);
2611
2592
  let r = 0;
2612
2593
  for (let i = t + 1; i < n; i++) r += e.vLines[i];
2613
2594
  return r;
2614
2595
  }
2615
- function vn(e, t, n) {
2596
+ function _n(e, t, n) {
2616
2597
  if (!e.collapsed) return e.spacingY * (n - t - 1);
2617
2598
  let r = 0;
2618
2599
  for (let i = t + 1; i < n; i++) r += e.hLines[i];
2619
2600
  return r;
2620
2601
  }
2621
- function yn(e, t) {
2602
+ function vn(e, t) {
2622
2603
  let n = t.tableData.get(e);
2623
2604
  if (n) return n;
2624
- let r = on(e, t), i = hn(e, r), a = {
2605
+ let r = an(e, t), i = mn(e, r), a = {
2625
2606
  structure: r,
2626
2607
  chrome: i,
2627
- bounds: un(r, i, t),
2628
- chromeX: gn(i, r.columnCount)
2608
+ bounds: ln(r, i, t),
2609
+ chromeX: hn(i, r.columnCount)
2629
2610
  };
2630
2611
  return t.tableData.set(e, a), a;
2631
2612
  }
2632
- function bn(e, t) {
2633
- let { structure: n, bounds: r, chromeX: i } = yn(e, t), a = r.min.reduce((e, t) => e + t, 0) + i, o = r.max.reduce((e, t) => e + t, 0) + i;
2634
- return n.caption && (a = Math.max(a, Y(n.caption, t)), o = Math.max(o, q(n.caption, t))), {
2613
+ function yn(e, t) {
2614
+ let { structure: n, bounds: r, chromeX: i } = vn(e, t), a = r.min.reduce((e, t) => e + t, 0) + i, o = r.max.reduce((e, t) => e + t, 0) + i;
2615
+ return n.caption && (a = Math.max(a, J(n.caption, t)), o = Math.max(o, K(n.caption, t))), {
2635
2616
  min: a,
2636
2617
  max: o
2637
2618
  };
2638
2619
  }
2639
- function xn(e, t, n) {
2640
- let r = e.style, { bounds: i, chromeX: a } = yn(e, n), { min: o, max: s } = bn(e, n), c = r.border.left + r.border.right + U(r.padding.left, t) + U(r.padding.right, t) + it(r).right, l = i.max.reduce((e, t) => e + t, 0), u = 0, d = 0;
2620
+ function bn(e, t, n) {
2621
+ let r = e.style, { bounds: i, chromeX: a } = vn(e, n), { min: o, max: s } = yn(e, n), c = r.border.left + r.border.right + H(r.padding.left, t) + H(r.padding.right, t) + it(r).right, l = i.max.reduce((e, t) => e + t, 0), u = 0, d = 0;
2641
2622
  for (let e = 0; e < i.max.length; e++) {
2642
2623
  let t = i.percent[e];
2643
2624
  t === void 0 ? d += i.max[e] : u += t;
@@ -2653,8 +2634,8 @@ function xn(e, t, n) {
2653
2634
  let f = Math.max(l + a, s) + c;
2654
2635
  return Math.max(o + c, Math.min(f, t));
2655
2636
  }
2656
- function Sn(e, t, n, r, i, a) {
2657
- let { structure: o, chrome: s, bounds: c } = yn(e, a), l = o.columnCount, u = o.rows.length, d = r.left + i.left, f = r.top + i.top;
2637
+ function xn(e, t, n, r, i, a) {
2638
+ let { structure: o, chrome: s, bounds: c } = vn(e, a), l = o.columnCount, u = o.rows.length, d = r.left + i.left, f = r.top + i.top;
2658
2639
  for (let e of o.hidden) e.tableHidden = !0, e.localRect = {
2659
2640
  x: 0,
2660
2641
  y: 0,
@@ -2666,16 +2647,16 @@ function Sn(e, t, n, r, i, a) {
2666
2647
  bottom: 0,
2667
2648
  left: 0
2668
2649
  }, e.unclampedHeight = 0;
2669
- let p = Math.max(0, t - gn(s, l)), m = e.style, h = m.tableLayout === "fixed" && m.width !== void 0 && m.width.kind !== "auto" ? fn(o, p, a) : dn(c, p), g = [], _ = 0;
2650
+ let p = Math.max(0, t - hn(s, l)), m = e.style, h = m.tableLayout === "fixed" && m.width !== void 0 && m.width.kind !== "auto" ? dn(o, p, a) : un(c, p), g = [], _ = 0;
2670
2651
  for (let e = 0; e < l; e++) _ += s.collapsed ? s.vLines[e] : s.spacingX, g.push(_), _ += h[e];
2671
2652
  let v = _ + (s.collapsed ? s.vLines[l] ?? 0 : s.spacingX), y = 0;
2672
2653
  o.caption && (B(o.caption, t, void 0, d, f, "fill", a), y = o.caption.localRect.height);
2673
2654
  let b = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
2674
2655
  for (let e of o.cells) {
2675
- let t = e.col + e.colSpan, n = h.slice(e.col, t).reduce((e, t) => e + t, 0) + _n(s, e.col, t);
2656
+ let t = e.col + e.colSpan, n = h.slice(e.col, t).reduce((e, t) => e + t, 0) + gn(s, e.col, t);
2676
2657
  x.set(e, n), B(e.node, n, void 0, 0, 0, "fill", a, { width: n }), b.set(e, e.node.localRect.height);
2677
2658
  }
2678
- let C = s.collapsed ? s.hLines.reduce((e, t) => e + t, 0) : (u + 1) * s.spacingY, w = n === void 0 ? void 0 : Math.max(0, n - y - C), T = (e) => e !== void 0 && e.kind === "percent" && w !== void 0 ? we(e.value, w) : 0, E = Array.from({ length: u }, () => 0), D = Array.from({ length: u }, () => !1);
2659
+ let C = s.collapsed ? s.hLines.reduce((e, t) => e + t, 0) : (u + 1) * s.spacingY, w = n === void 0 ? void 0 : Math.max(0, n - y - C), T = (e) => e !== void 0 && e.kind === "percent" && w !== void 0 ? Ce(e.value, w) : 0, E = Array.from({ length: u }, () => 0), D = Array.from({ length: u }, () => !1);
2679
2660
  for (let e = 0; e < u; e++) {
2680
2661
  let t = o.rows[e].style.height;
2681
2662
  t !== void 0 && t.kind === "cells" && (E[e] = t.value);
@@ -2688,9 +2669,9 @@ function Sn(e, t, n, r, i, a) {
2688
2669
  }
2689
2670
  let O = o.cells.filter((e) => e.rowSpan > 1).sort((e, t) => e.rowSpan - t.rowSpan);
2690
2671
  for (let e of O) {
2691
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + vn(s, e.row, t), r = b.get(e) - n;
2672
+ let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + _n(s, e.row, t), r = b.get(e) - n;
2692
2673
  if (r <= 0) continue;
2693
- let i = R(Array.from({ length: e.rowSpan }, () => 1), r);
2674
+ let i = L(Array.from({ length: e.rowSpan }, () => 1), r);
2694
2675
  for (let n = e.row; n < t; n++) E[n] += i[n - e.row];
2695
2676
  }
2696
2677
  if (n !== void 0 && u > 0) {
@@ -2698,18 +2679,18 @@ function Sn(e, t, n, r, i, a) {
2698
2679
  if (e > 0) {
2699
2680
  let t = [];
2700
2681
  for (let e = 0; e < u; e++) D[e] || t.push(e);
2701
- let n = t.length > 0 ? t : Array.from({ length: u }, (e, t) => t), r = R(n.map(() => 1), e);
2682
+ let n = t.length > 0 ? t : Array.from({ length: u }, (e, t) => t), r = L(n.map(() => 1), e);
2702
2683
  n.forEach((e, t) => E[e] += r[t]);
2703
2684
  }
2704
2685
  }
2705
- let k = o.caption && e.style.captionSide === "top" ? y : 0, A = [], j = k;
2706
- for (let e = 0; e < u; e++) j += s.collapsed ? s.hLines[e] : s.spacingY, A.push(j), j += E[e];
2707
- let M = u > 0 ? j + (s.collapsed ? s.hLines[u] ?? 0 : s.spacingY) : k, N = /* @__PURE__ */ new Map();
2686
+ let k = o.caption && e.style.captionSide === "top" ? y : 0, A = [], ee = k;
2687
+ for (let e = 0; e < u; e++) ee += s.collapsed ? s.hLines[e] : s.spacingY, A.push(ee), ee += E[e];
2688
+ let j = u > 0 ? ee + (s.collapsed ? s.hLines[u] ?? 0 : s.spacingY) : k, M = /* @__PURE__ */ new Map();
2708
2689
  for (let e = 0; e < u; e++) {
2709
2690
  let t = o.rowGroups[e];
2710
- t && !N.has(t) && N.set(t, A[e]);
2691
+ t && !M.has(t) && M.set(t, A[e]);
2711
2692
  }
2712
- for (let [e, t] of N) {
2693
+ for (let [e, t] of M) {
2713
2694
  let n = t;
2714
2695
  for (let t = 0; t < u; t++) o.rowGroups[t] === e && (n = A[t] + E[t]);
2715
2696
  e.localRect = {
@@ -2725,7 +2706,7 @@ function Sn(e, t, n, r, i, a) {
2725
2706
  }, e.unclampedHeight = n - t;
2726
2707
  }
2727
2708
  for (let e = 0; e < u; e++) {
2728
- let t = o.rows[e], n = o.rowGroups[e], r = n ? N.get(n) : void 0;
2709
+ let t = o.rows[e], n = o.rowGroups[e], r = n ? M.get(n) : void 0;
2729
2710
  t.localRect = {
2730
2711
  x: r === void 0 ? d : 0,
2731
2712
  y: r === void 0 ? f + A[e] : A[e] - r,
@@ -2739,11 +2720,11 @@ function Sn(e, t, n, r, i, a) {
2739
2720
  }, t.unclampedHeight = E[e];
2740
2721
  }
2741
2722
  for (let e of o.cells) {
2742
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + vn(s, e.row, t);
2723
+ let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + _n(s, e.row, t);
2743
2724
  e.node.children.some((e) => !z(e.style) && e.style.height?.kind === "percent") && n !== b.get(e) && B(e.node, x.get(e), n, 0, 0, "fill", a, {
2744
2725
  width: x.get(e),
2745
2726
  height: n
2746
- }), Cn(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2727
+ }), Sn(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2747
2728
  x: g[e.col],
2748
2729
  y: 0,
2749
2730
  width: e.node.localRect.width,
@@ -2755,9 +2736,9 @@ function Sn(e, t, n, r, i, a) {
2755
2736
  x: d,
2756
2737
  y: f
2757
2738
  });
2758
- return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + M), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = wn(s, o, h, E, g, A, d, f, S(e.style.glyphSet))), e.style.captionSide === "bottom" ? M + y : M;
2739
+ return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + j), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = Cn(s, o, h, E, g, A, d, f, S(e.style.glyphSet))), e.style.captionSide === "bottom" ? j + y : j;
2759
2740
  }
2760
- function Cn(e, t) {
2741
+ function Sn(e, t) {
2761
2742
  if (t <= 0) return;
2762
2743
  let n = e.style.verticalAlign, r = n === "center" ? Math.floor(t / 2) : n === "end" ? t : 0;
2763
2744
  if (!e.children.some((e) => !z(e.style) && !e.inlineBox)) {
@@ -2766,14 +2747,14 @@ function Cn(e, t) {
2766
2747
  }
2767
2748
  if (!(r <= 0)) for (let t of e.children) t.inlineBox || (z(t.style) ? t.staticSlot?.kind === "block" && (t.staticSlot.y += r) : t.localRect.y += r);
2768
2749
  }
2769
- function wn(e, t, n, r, i, a, o, s, c) {
2750
+ function Cn(e, t, n, r, i, a, o, s, c) {
2770
2751
  let l = t.columnCount, u = t.rows.length, d = [], f = (t) => t < l ? i[t] - e.vLines[t] : i[l - 1] + n[l - 1], p = (t) => t < u ? a[t] - e.hLines[t] : a[u - 1] + r[u - 1];
2771
2752
  for (let t = 0; t <= l; t++) {
2772
2753
  let n = e.vSegments[t];
2773
2754
  for (let e = 0; e < u; e++) {
2774
2755
  let i = n[e];
2775
2756
  if (!i) continue;
2776
- let l = me(i.style, "v", c);
2757
+ let l = he(i.style, "v", c);
2777
2758
  for (let n = 0; n < i.width; n++) for (let c = a[e]; c < a[e] + r[e]; c++) d.push({
2778
2759
  glyph: l,
2779
2760
  x: o + f(t) + n,
@@ -2788,7 +2769,7 @@ function wn(e, t, n, r, i, a, o, s, c) {
2788
2769
  for (let e = 0; e < l; e++) {
2789
2770
  let a = r[e];
2790
2771
  if (!a) continue;
2791
- let l = me(a.style, "h", c);
2772
+ let l = he(a.style, "h", c);
2792
2773
  for (let r = 0; r < a.width; r++) d.push({
2793
2774
  glyph: l,
2794
2775
  x: o + i[e],
@@ -2807,7 +2788,7 @@ function wn(e, t, n, r, i, a, o, s, c) {
2807
2788
  m
2808
2789
  ].filter((e) => e !== null);
2809
2790
  if (h.length === 0) continue;
2810
- let g = h.every((e) => e.style === "double") ? "double" : "solid", _ = h.reduce((e, t) => t.width > e.width || t.width === e.width && pn[t.style] > pn[e.style] ? t : e), v = he(g, r !== null, i !== null, a !== null, m !== null, c);
2791
+ let g = h.every((e) => e.style === "double") ? "double" : "solid", _ = h.reduce((e, t) => t.width > e.width || t.width === e.width && fn[t.style] > fn[e.style] ? t : e), v = ge(g, r !== null, i !== null, a !== null, m !== null, c);
2811
2792
  for (let r = 0; r < e.vLines[t]; r++) for (let i = 0; i < e.hLines[n]; i++) d.push({
2812
2793
  glyph: v,
2813
2794
  x: o + f(t) + r,
@@ -2820,30 +2801,30 @@ function wn(e, t, n, r, i, a, o, s, c) {
2820
2801
  }
2821
2802
  //#endregion
2822
2803
  //#region src/positioning.ts
2823
- function Tn(e) {
2804
+ function wn(e) {
2824
2805
  return e.position === "absolute" || e.position === "fixed" ? "absolute" : e.position === "relative" || e.position === "sticky" ? "relative" : "static";
2825
2806
  }
2826
- function En(e, t, n, r, i) {
2807
+ function Tn(e, t, n, r, i) {
2827
2808
  for (let a of e.children) {
2828
- let o = Tn(a.style);
2809
+ let o = wn(a.style);
2829
2810
  if (o === "relative") {
2830
2811
  let t = e.localRect.width - e.style.border.left - e.style.border.right - e.resolvedPadding.left - e.resolvedPadding.right, n = e.localRect.height - e.style.border.top - e.style.border.bottom - e.resolvedPadding.top - e.resolvedPadding.bottom;
2831
- a.localRect.x += Dn(a.style.insets.left, a.style.insets.right, t), a.localRect.y += Dn(a.style.insets.top, a.style.insets.bottom, n);
2832
- } else o === "absolute" && kn(a, e, t, n, r, i);
2833
- En(a, t + a.localRect.x, n + a.localRect.y, [...r, {
2812
+ a.localRect.x += En(a.style.insets.left, a.style.insets.right, t), a.localRect.y += En(a.style.insets.top, a.style.insets.bottom, n);
2813
+ } else o === "absolute" && On(a, e, t, n, r, i);
2814
+ Tn(a, t + a.localRect.x, n + a.localRect.y, [...r, {
2834
2815
  node: a,
2835
2816
  absX: t + a.localRect.x,
2836
2817
  absY: n + a.localRect.y
2837
2818
  }], i);
2838
2819
  }
2839
2820
  }
2840
- function Dn(e, t, n) {
2841
- return e === null ? t === null ? 0 : -U(t, n) : U(e, n);
2821
+ function En(e, t, n) {
2822
+ return e === null ? t === null ? 0 : -H(t, n) : H(e, n);
2842
2823
  }
2843
- function On(e, t) {
2824
+ function Dn(e, t) {
2844
2825
  if (!t) for (let t = e.length - 1; t > 0; t--) {
2845
2826
  let n = e[t];
2846
- if (!Ln(n.node.style)) continue;
2827
+ if (!In(n.node.style)) continue;
2847
2828
  let r = n.node.style.border;
2848
2829
  return {
2849
2830
  x: n.absX + r.left,
@@ -2860,44 +2841,44 @@ function On(e, t) {
2860
2841
  height: n.node.localRect.height
2861
2842
  };
2862
2843
  }
2863
- function kn(e, t, n, r, i, a) {
2864
- let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && Ln(t.style) ? {
2844
+ function On(e, t, n, r, i, a) {
2845
+ let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && In(t.style) ? {
2865
2846
  x: n + c.area.x,
2866
2847
  y: r + c.area.y,
2867
2848
  width: c.area.width,
2868
2849
  height: c.area.height
2869
- } : On(i, s), u = o.insets.left === null ? null : U(o.insets.left, l.width), d = o.insets.right === null ? null : U(o.insets.right, l.width), f = o.insets.top === null ? null : U(o.insets.top, l.height), p = o.insets.bottom === null ? null : U(o.insets.bottom, l.height), m = W(o.margin, l.width), h = m.left ?? 0, g = m.right ?? 0, _ = m.top ?? 0, v = m.bottom ?? 0, y = o.width === void 0 || o.width.kind === "auto", b = o.height === void 0 || o.height.kind === "auto", x = Kn(o.minWidth, l.width, e, a) ?? 0, S = Kn(o.maxWidth, l.width, e, a), C = {};
2870
- if (!y) C.width = V(K(o.width, l.width, e, a), x, S);
2850
+ } : Dn(i, s), u = o.insets.left === null ? null : H(o.insets.left, l.width), d = o.insets.right === null ? null : H(o.insets.right, l.width), f = o.insets.top === null ? null : H(o.insets.top, l.height), p = o.insets.bottom === null ? null : H(o.insets.bottom, l.height), m = U(o.margin, l.width), h = m.left ?? 0, g = m.right ?? 0, _ = m.top ?? 0, v = m.bottom ?? 0, y = o.width === void 0 || o.width.kind === "auto", b = o.height === void 0 || o.height.kind === "auto", x = Kn(o.minWidth, l.width, e, a) ?? 0, S = Kn(o.maxWidth, l.width, e, a), C = {};
2851
+ if (!y) C.width = V(G(o.width, l.width, e, a), x, S);
2871
2852
  else if (u !== null && d !== null) C.width = V(Math.max(0, l.width - u - d - h - g), x, S);
2872
2853
  else {
2873
2854
  let t = Math.max(0, l.width - (u ?? 0) - (d ?? 0) - h - g);
2874
- C.width = V(Math.min(q(e, a), Math.max(Y(e, a), t)), x, S);
2855
+ C.width = V(Math.min(K(e, a), Math.max(J(e, a), t)), x, S);
2875
2856
  }
2876
- f !== null && p !== null && b && (C.height = V(Math.max(0, l.height - f - p - _ - v), G(o.minHeight, l.height) ?? 0, G(o.maxHeight, l.height))), B(e, l.width, l.height, 0, 0, "shrink", a, C);
2857
+ f !== null && p !== null && b && (C.height = V(Math.max(0, l.height - f - p - _ - v), W(o.minHeight, l.height) ?? 0, W(o.maxHeight, l.height))), B(e, l.width, l.height, 0, 0, "shrink", a, C);
2877
2858
  let w = e.localRect.width, T = e.localRect.height, E;
2878
2859
  if (u !== null && d !== null) {
2879
2860
  let e = Math.max(0, l.width - u - d - w - h - g), t = m.left === null && m.right === null;
2880
2861
  E = l.x + u + h + (t ? Math.floor(e / 2) : m.left === null ? e : 0);
2881
- } else E = u === null ? d === null ? Pn(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2862
+ } else E = u === null ? d === null ? Nn(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2882
2863
  let D;
2883
2864
  if (f !== null && p !== null) {
2884
2865
  let e = Math.max(0, l.height - f - p - T - _ - v), t = m.top === null && m.bottom === null;
2885
2866
  D = l.y + f + _ + (t ? Math.floor(e / 2) : m.top === null ? e : 0);
2886
- } else D = f === null ? p === null ? Fn(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2867
+ } else D = f === null ? p === null ? Pn(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2887
2868
  e.localRect = {
2888
2869
  ...e.localRect,
2889
2870
  x: E - n,
2890
2871
  y: D - r
2891
2872
  };
2892
2873
  }
2893
- function An(e, t, n) {
2894
- return L(e, [n], Math.max(0, t - n))[0];
2874
+ function kn(e, t, n) {
2875
+ return I(e, [n], Math.max(0, t - n))[0];
2895
2876
  }
2896
- function jn(e, t, n, r) {
2897
- return Xe(Ye(e, t), n, r);
2877
+ function An(e, t, n, r) {
2878
+ return Ye(Je(e, t), n, r);
2898
2879
  }
2899
- function Mn(e, t, n, r, i) {
2900
- let a = W(e.style.margin, n.innerWidth), [o, s, c, l] = r === "x" ? [
2880
+ function jn(e, t, n, r, i) {
2881
+ let a = U(e.style.margin, n.innerWidth), [o, s, c, l] = r === "x" ? [
2901
2882
  a.left ?? 0,
2902
2883
  a.right ?? 0,
2903
2884
  n.innerWidth,
@@ -2908,10 +2889,10 @@ function Mn(e, t, n, r, i) {
2908
2889
  n.innerHeight,
2909
2890
  n.direction === "column"
2910
2891
  ], u = i + o + s;
2911
- return (l ? An(et(t.style), c, u) : jn(e, t, c, u)) + o;
2892
+ return (l ? kn($e(t.style), c, u) : An(e, t, c, u)) + o;
2912
2893
  }
2913
- function Nn(e, t, n, r, i) {
2914
- let a = W(e.style.margin, n.width), o = e.style.justifySelf === "auto" ? t.style.justifyItems : e.style.justifySelf, [s, c, l, u] = r === "x" ? [
2894
+ function Mn(e, t, n, r, i) {
2895
+ let a = U(e.style.margin, n.width), o = e.style.justifySelf === "auto" ? t.style.justifyItems : e.style.justifySelf, [s, c, l, u] = r === "x" ? [
2915
2896
  a.left ?? 0,
2916
2897
  a.right ?? 0,
2917
2898
  n.width,
@@ -2920,23 +2901,23 @@ function Nn(e, t, n, r, i) {
2920
2901
  a.top ?? 0,
2921
2902
  a.bottom ?? 0,
2922
2903
  n.height,
2923
- Ye(e, t)
2904
+ Je(e, t)
2924
2905
  ];
2925
- return Xe(u, l, i + s + c) + s;
2906
+ return Ye(u, l, i + s + c) + s;
2926
2907
  }
2927
- function Pn(e, t, n, r) {
2908
+ function Nn(e, t, n, r) {
2928
2909
  let i = e.staticSlot;
2929
- return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + Nn(e, t, i.staticArea, "x", r) : n + i.originX + Mn(e, t, i, "x", r);
2910
+ return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + Mn(e, t, i.staticArea, "x", r) : n + i.originX + jn(e, t, i, "x", r);
2930
2911
  }
2931
- function Fn(e, t, n, r) {
2912
+ function Pn(e, t, n, r) {
2932
2913
  let i = e.staticSlot;
2933
- return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + Nn(e, t, i.staticArea, "y", r) : n + i.originY + Mn(e, t, i, "y", r);
2914
+ return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + Mn(e, t, i.staticArea, "y", r) : n + i.originY + jn(e, t, i, "y", r);
2934
2915
  }
2935
2916
  //#endregion
2936
2917
  //#region src/layout.ts
2937
- function In(e, t) {
2938
- let n = Rn();
2939
- B(e, t, void 0, 0, 0, "fill", n), En(e, 0, 0, [{
2918
+ function Fn(e, t) {
2919
+ let n = Ln();
2920
+ B(e, t, void 0, 0, 0, "fill", n), Tn(e, 0, 0, [{
2940
2921
  node: e,
2941
2922
  absX: 0,
2942
2923
  absY: 0
@@ -2947,10 +2928,10 @@ function In(e, t) {
2947
2928
  function z(e) {
2948
2929
  return e.position === "absolute" || e.position === "fixed";
2949
2930
  }
2950
- function Ln(e) {
2931
+ function In(e) {
2951
2932
  return e.position !== "static";
2952
2933
  }
2953
- function Rn() {
2934
+ function Ln() {
2954
2935
  return {
2955
2936
  maxContent: /* @__PURE__ */ new WeakMap(),
2956
2937
  minContent: /* @__PURE__ */ new WeakMap(),
@@ -2961,18 +2942,18 @@ function Rn() {
2961
2942
  function B(e, t, n, r, i, a, o, s) {
2962
2943
  let c = e.style, l = s?.height;
2963
2944
  delete e.decorationRuns, delete e.multicolGeometry, delete e.multicolFlow, delete e.multicolFlowSpan, delete e.textExtent;
2964
- let u = Kn(c.minWidth, t, e, o) ?? 0, d = Kn(c.maxWidth, t, e, o), f = G(c.minHeight, n) ?? 0, p = G(c.maxHeight, n), m = it(c), h = rt(c);
2945
+ let u = Kn(c.minWidth, t, e, o) ?? 0, d = Kn(c.maxWidth, t, e, o), f = W(c.minHeight, n) ?? 0, p = W(c.maxHeight, n), m = it(c), h = rt(c);
2965
2946
  s?.gutter?.right && (m.right = h.right), s?.gutter?.bottom && (m.bottom = h.bottom);
2966
2947
  let g = {
2967
- top: U(c.padding.top, t),
2968
- right: U(c.padding.right, t) + m.right,
2969
- bottom: U(c.padding.bottom, t) + m.bottom,
2970
- left: U(c.padding.left, t)
2948
+ top: H(c.padding.top, t),
2949
+ right: H(c.padding.right, t) + m.right,
2950
+ bottom: H(c.padding.bottom, t) + m.bottom,
2951
+ left: H(c.padding.left, t)
2971
2952
  };
2972
2953
  e.resolvedPadding = g;
2973
- let _ = s?.width ?? V(Xn(c, t, a, e, o), u, d), v = er(c, n), y = rr(_, l ?? v ?? (f > 0 ? f : void 0) ?? Infinity, c.border, g), b = l !== void 0 || v !== void 0, x = p === void 0 ? void 0 : Math.max(0, p - c.border.top - c.border.bottom - g.top - g.bottom), S = Bn(e), C = (t, n) => {
2954
+ let _ = s?.width ?? V(Xn(c, t, a, e, o), u, d), v = er(c, n), y = rr(_, l ?? v ?? (f > 0 ? f : void 0) ?? Infinity, c.border, g), b = l !== void 0 || v !== void 0, x = p === void 0 ? void 0 : Math.max(0, p - c.border.top - c.border.bottom - g.top - g.bottom), S = zn(e), C = (t, n) => {
2974
2955
  let r = n && Number.isFinite(t) ? t : void 0;
2975
- return S ? zn(e, y.width, t, r, x, g, o) : c.display === "flex" && c.flexDirection === "row" ? Ue(e, y.width, t, r, c.border, g, o) : c.display === "flex" ? Ge(e, y.width, t, n, c.border, g, o) : c.display === "grid" ? ct(e, y.width, t, c.border, g, o) : c.display === "table" ? Sn(e, y.width, r, c.border, g, o) : c.display === "multicol" ? en(e, y.width, r, x, c.border, g, o) : qn(e, y.width, r, c.border, g, o);
2956
+ return S ? Rn(e, y.width, t, r, x, g, o) : c.display === "flex" && c.flexDirection === "row" ? He(e, y.width, t, r, c.border, g, o) : c.display === "flex" ? We(e, y.width, t, n, c.border, g, o) : c.display === "grid" ? st(e, y.width, t, c.border, g, o) : c.display === "table" ? xn(e, y.width, r, c.border, g, o) : c.display === "multicol" ? $t(e, y.width, r, x, c.border, g, o) : qn(e, y.width, r, c.border, g, o);
2976
2957
  }, w = C(y.height, b);
2977
2958
  if (!S && (c.display === "flex" || c.display === "grid") && !b && p !== void 0) {
2978
2959
  let e = c.border.top + c.border.bottom + g.top + g.bottom, t = V(w + e, f, p) - e;
@@ -2983,28 +2964,31 @@ function B(e, t, n, r, i, a, o, s) {
2983
2964
  let D = V(E, f, p), O = e.multicolGeometry;
2984
2965
  if (O) {
2985
2966
  let t = D - c.border.top - c.border.bottom - g.top - g.bottom;
2986
- t > O.totalRows && (g.bottom += t - O.totalRows), Zt(e, O, c.border, g);
2967
+ t > O.totalRows && (g.bottom += t - O.totalRows), Xt(e, O, c.border, g);
2987
2968
  }
2988
2969
  if (e.localRect = {
2989
2970
  x: r,
2990
2971
  y: i,
2991
2972
  width: _,
2992
2973
  height: D
2993
- }, nt(c.overflow.x) || nt(c.overflow.y)) {
2974
+ }, tt(c.overflow.x) || tt(c.overflow.y)) {
2994
2975
  let l = Zn(e), u = Math.max(0, l.x - c.border.left - g.left), d = Math.max(0, l.y - c.border.top - g.top), f = Math.max(0, _ - c.border.left - c.border.right - g.left - g.right), p = Math.max(0, D - c.border.top - c.border.bottom - g.top - g.bottom);
2995
2976
  if (e.scrollRange = {
2996
2977
  sizeX: u,
2997
2978
  sizeY: d,
2998
- maxX: nt(c.overflow.x) ? Math.max(0, u - f) : 0,
2999
- maxY: nt(c.overflow.y) ? Math.max(0, d - p) : 0
3000
- }, !s?.gutter && c.scrollbarWidth !== "none") {
3001
- let l = c.overflow.y === "auto" && e.scrollRange.maxY > 0, u = c.overflow.x === "auto" && e.scrollRange.maxX > 0;
3002
- if (l || u) {
2979
+ maxX: tt(c.overflow.x) ? Math.max(0, u - f) : 0,
2980
+ maxY: tt(c.overflow.y) ? Math.max(0, d - p) : 0
2981
+ }, c.scrollbarWidth !== "none") {
2982
+ let l = s?.gutter ?? {
2983
+ right: !1,
2984
+ bottom: !1
2985
+ }, u = l.right || c.overflow.y === "auto" && e.scrollRange.maxY > 0, d = l.bottom || c.overflow.x === "auto" && e.scrollRange.maxX > 0;
2986
+ if (u !== l.right || d !== l.bottom) {
3003
2987
  B(e, t, n, r, i, a, o, {
3004
2988
  ...s,
3005
2989
  gutter: {
3006
- right: l,
3007
- bottom: u
2990
+ right: u,
2991
+ bottom: d
3008
2992
  }
3009
2993
  });
3010
2994
  return;
@@ -3016,33 +3000,33 @@ function B(e, t, n, r, i, a, o, s) {
3016
3000
  };
3017
3001
  } else delete e.scrollRange, delete e.scrollGutterCells;
3018
3002
  }
3019
- function zn(e, t, n, r, i, a, o) {
3003
+ function Rn(e, t, n, r, i, a, o) {
3020
3004
  let s = e.style, c;
3021
3005
  if (e.text) {
3022
- let l = e.children.filter((e) => e.inlineBox);
3023
- Fe(e.text, (n, r) => {
3006
+ let l = nt(e);
3007
+ Pe(e.text, (n, r) => {
3024
3008
  let i = l[r];
3025
3009
  B(i, t, void 0, 0, 0, "shrink", o), e.advances[n] = Math.max(1, i.localRect.width);
3026
3010
  });
3027
3011
  let u, d;
3028
3012
  if (s.display === "multicol") {
3029
- let n = H(s, "x", t), o = Ut(s, t, n);
3013
+ let n = Wn(s, "x", t), o = Ht(s, t, n);
3030
3014
  a.right += o.leftover;
3031
- let c = Gt(e, o, n, Vt(r, i));
3015
+ let c = Wt(e, o, n, Bt(r, i));
3032
3016
  e.multicolGeometry = c, u = c, d = c.lineX;
3033
- } else u = Hn(e, t);
3017
+ } else u = Vn(e, t);
3034
3018
  if (c = u.totalRows, e.textExtent = {
3035
- width: u.spans.reduce((t, n) => Math.max(t, I(n.start, n.end, e.advances, s.tracking)), 0),
3019
+ width: u.spans.reduce((t, n) => Math.max(t, F(n.start, n.end, e.advances, s.tracking)), 0),
3036
3020
  rows: u.totalRows
3037
- }, Vn(e, u, t, n, a), l.length > 0) {
3021
+ }, Bn(e, u, t, n, a), l.length > 0) {
3038
3022
  let t = (e) => u.spans.findIndex((t) => e >= t.start && e < t.end);
3039
- Fe(e.text, (n, r) => {
3023
+ Pe(e.text, (n, r) => {
3040
3024
  let i = t(n);
3041
3025
  if (i === -1) return;
3042
3026
  let o = u.spans[i];
3043
3027
  l[r].localRect = {
3044
3028
  ...l[r].localRect,
3045
- x: s.border.left + a.left + (d?.[i] ?? 0) + Me(o.start, n, e.advances),
3029
+ x: s.border.left + a.left + (d?.[i] ?? 0) + je(o.start, n, e.advances),
3046
3030
  y: s.border.top + a.top + u.lineY[i]
3047
3031
  };
3048
3032
  });
@@ -3050,7 +3034,7 @@ function zn(e, t, n, r, i, a, o) {
3050
3034
  } else c = e.intrinsicHeight;
3051
3035
  for (let n of e.children) {
3052
3036
  if (n.inlineBox) continue;
3053
- let e = W(n.style.margin, t);
3037
+ let e = U(n.style.margin, t);
3054
3038
  n.staticSlot = {
3055
3039
  kind: "block",
3056
3040
  x: s.border.left + a.left + (e.left ?? 0),
@@ -3059,30 +3043,30 @@ function zn(e, t, n, r, i, a, o) {
3059
3043
  }
3060
3044
  return c;
3061
3045
  }
3062
- function Bn(e) {
3046
+ function zn(e) {
3063
3047
  return e.children.some((e) => !z(e.style) && !e.inlineBox) ? !1 : e.text !== "" || e.style.display !== "flex" && e.style.display !== "grid";
3064
3048
  }
3065
3049
  function V(e, t, n) {
3066
3050
  return Math.max(t, n === void 0 ? e : Math.min(e, n));
3067
3051
  }
3068
- function Vn(e, t, n, r, i) {
3052
+ function Bn(e, t, n, r, i) {
3069
3053
  let a = e.style;
3070
3054
  if (a.display !== "flex" && a.display !== "grid" || t.spans.length === 0) return;
3071
- let o = a.display === "flex" && a.flexDirection === "column", s = t.spans.reduce((t, n) => Math.max(t, I(n.start, n.end, e.advances, a.tracking)), 0), c = Math.max(0, n - s);
3055
+ let o = a.display === "flex" && a.flexDirection === "column", s = t.spans.reduce((t, n) => Math.max(t, F(n.start, n.end, e.advances, a.tracking)), 0), c = Math.max(0, n - s);
3072
3056
  if (c > 0) {
3073
- let e = a.display === "grid" ? Xe(a.justifyItems, n, s) : o ? Xe(a.alignItems, n, s) : L(et(a), [s], c)[0];
3057
+ let e = a.display === "grid" ? Ye(a.justifyItems, n, s) : o ? Ye(a.alignItems, n, s) : I($e(a), [s], c)[0];
3074
3058
  e > 0 && (i.left += e, i.right += c - e);
3075
3059
  }
3076
3060
  if (Number.isFinite(r)) {
3077
3061
  let e = Math.max(0, r - t.totalRows);
3078
3062
  if (e > 0) {
3079
- let n = a.display === "grid" || !o ? Xe(a.alignItems, r, t.totalRows) : L(et(a), [t.totalRows], e)[0];
3063
+ let n = a.display === "grid" || !o ? Ye(a.alignItems, r, t.totalRows) : I($e(a), [t.totalRows], e)[0];
3080
3064
  n > 0 && (i.top += n, i.bottom += e - n);
3081
3065
  }
3082
3066
  }
3083
3067
  }
3084
- function Hn(e, t) {
3085
- let n = Un(e, t), { heights: r, textOffsets: i } = Wn(e, n), a = [], o = [], s = 0;
3068
+ function Vn(e, t) {
3069
+ let n = Hn(e, t), { heights: r, textOffsets: i } = Un(e, n), a = [], o = [], s = 0;
3086
3070
  for (let t = 0; t < n.length; t++) a.push(s), o.push(s + i[t]), s += r[t] + (t < n.length - 1 ? e.style.lineGap : 0);
3087
3071
  return {
3088
3072
  spans: n,
@@ -3091,21 +3075,21 @@ function Hn(e, t) {
3091
3075
  totalRows: s
3092
3076
  };
3093
3077
  }
3094
- function Un(e, t) {
3095
- return e.style.whiteSpace === "normal" ? je(e.text, t, {
3078
+ function Hn(e, t) {
3079
+ return e.style.whiteSpace === "normal" ? Ae(e.text, t, {
3096
3080
  advances: e.advances,
3097
3081
  tracking: e.style.tracking,
3098
3082
  firstLineIndent: e.style.textIndent
3099
- }) : Ae(e.text);
3083
+ }) : ke(e.text);
3100
3084
  }
3101
- function Wn(e, t) {
3102
- let n = e.children.filter((e) => e.inlineBox), r = [], i = [], a = 0;
3085
+ function Un(e, t) {
3086
+ let n = nt(e), r = [], i = [], a = 0;
3103
3087
  for (let o of t) {
3104
3088
  let t = 1, s = 0;
3105
3089
  for (let r = o.start; r < o.end; r++) {
3106
3090
  if (e.text[r] !== "") continue;
3107
3091
  let i = n[a];
3108
- t = Math.max(t, i.localRect.height), i.style.verticalAlign === "end" ? s = Math.max(s, i.localRect.height - 1) : i.style.verticalAlign === "center" && N(i.source, "vertical-align: middle on an inline box can't land on whole rows and behaves as top. Use align-top or align-bottom."), a++;
3092
+ t = Math.max(t, i.localRect.height), i.style.verticalAlign === "end" ? s = Math.max(s, i.localRect.height - 1) : i.style.verticalAlign === "center" && M(i.source, "vertical-align: middle on an inline box can't land on whole rows and behaves as top. Use align-top or align-bottom."), a++;
3109
3093
  }
3110
3094
  r.push(t), i.push(Math.min(s, t - 1));
3111
3095
  }
@@ -3114,15 +3098,15 @@ function Wn(e, t) {
3114
3098
  textOffsets: i
3115
3099
  };
3116
3100
  }
3117
- function H(e, t, n) {
3118
- let r = U(t === "x" ? e.gapX : e.gapY, n), i = t === "x" ? e.ruleX : e.ruleY;
3101
+ function Wn(e, t, n) {
3102
+ let r = H(t === "x" ? e.gapX : e.gapY, n), i = t === "x" ? e.ruleX : e.ruleY;
3119
3103
  return Math.max(r, i?.width ?? 0);
3120
3104
  }
3121
- function U(e, t) {
3122
- return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : we(e.percent, t);
3105
+ function H(e, t) {
3106
+ return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : Ce(e.percent, t);
3123
3107
  }
3124
- function W(e, t) {
3125
- let n = (e) => e === null ? null : U(e, t);
3108
+ function U(e, t) {
3109
+ let n = (e) => e === null ? null : H(e, t);
3126
3110
  return {
3127
3111
  top: n(e.top),
3128
3112
  right: n(e.right),
@@ -3133,16 +3117,16 @@ function W(e, t) {
3133
3117
  function Gn(e) {
3134
3118
  return typeof e == "number" ? e : 0;
3135
3119
  }
3136
- function G(e, t) {
3137
- if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : we(e.percent, t);
3120
+ function W(e, t) {
3121
+ if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : Ce(e.percent, t);
3138
3122
  }
3139
3123
  function Kn(e, t, n, r) {
3140
- return e === "min-content" || e === "max-content" || e === "fit-content" ? K({ kind: e }, t, n, r) : G(e, t);
3124
+ return e === "min-content" || e === "max-content" || e === "fit-content" ? G({ kind: e }, t, n, r) : W(e, t);
3141
3125
  }
3142
3126
  function qn(e, t, n, r, i, a) {
3143
3127
  let o = r.left + i.left, s = r.top + i.top, c = s, l = null;
3144
3128
  for (let r of e.children) {
3145
- let e = W(r.style.margin, t), i = e.top ?? 0, s = e.bottom ?? 0, u = e.left ?? 0, d = e.right ?? 0;
3129
+ let e = U(r.style.margin, t), i = e.top ?? 0, s = e.bottom ?? 0, u = e.left ?? 0, d = e.right ?? 0;
3146
3130
  if (z(r.style)) {
3147
3131
  r.staticSlot = {
3148
3132
  kind: "block",
@@ -3171,14 +3155,14 @@ function Yn(e, t) {
3171
3155
  function Xn(e, t, n, r, i) {
3172
3156
  let a = e.width;
3173
3157
  if (e.display === "table") {
3174
- if (!r.children.some((e) => !z(e.style) && !e.inlineBox)) return a !== void 0 && a.kind !== "auto" ? K(a, t, r, i) : Math.min(t, q(r, i));
3158
+ if (!r.children.some((e) => !z(e.style) && !e.inlineBox)) return a !== void 0 && a.kind !== "auto" ? G(a, t, r, i) : Math.min(t, K(r, i));
3175
3159
  if (a !== void 0 && a.kind !== "auto") {
3176
- let e = K(a, t, r, i);
3160
+ let e = G(a, t, r, i);
3177
3161
  return Math.max(e, $n(r, t, i));
3178
3162
  }
3179
- return xn(r, t, i);
3163
+ return bn(r, t, i);
3180
3164
  }
3181
- return a !== void 0 && a.kind !== "auto" ? K(a, t, r, i) : n === "shrink" ? Math.min(t, q(r, i)) : t;
3165
+ return a !== void 0 && a.kind !== "auto" ? G(a, t, r, i) : n === "shrink" ? Math.min(t, K(r, i)) : t;
3182
3166
  }
3183
3167
  function Zn(e) {
3184
3168
  let t = 0, n = 0;
@@ -3210,23 +3194,23 @@ function Qn(e) {
3210
3194
  }
3211
3195
  function $n(e, t, n) {
3212
3196
  let r = e.style;
3213
- return bn(e, n).min + r.border.left + r.border.right + U(r.padding.left, t) + U(r.padding.right, t) + it(r).right;
3197
+ return yn(e, n).min + r.border.left + r.border.right + H(r.padding.left, t) + H(r.padding.right, t) + it(r).right;
3214
3198
  }
3215
3199
  function er(e, t) {
3216
3200
  if (e.height?.kind === "cells") return e.height.value;
3217
- if (e.height?.kind === "percent" && t != null) return we(e.height.value, t);
3201
+ if (e.height?.kind === "percent" && t != null) return Ce(e.height.value, t);
3218
3202
  }
3219
- function K(e, t, n, r) {
3203
+ function G(e, t, n, r) {
3220
3204
  switch (e.kind) {
3221
3205
  case "cells": return e.value;
3222
- case "percent": return we(e.value, t);
3223
- case "min-content": return Y(n, r);
3224
- case "max-content": return q(n, r);
3225
- case "fit-content": return Math.min(q(n, r), Math.max(Y(n, r), t));
3226
- case "auto": return q(n, r);
3206
+ case "percent": return Ce(e.value, t);
3207
+ case "min-content": return J(n, r);
3208
+ case "max-content": return K(n, r);
3209
+ case "fit-content": return Math.min(K(n, r), Math.max(J(n, r), t));
3210
+ case "auto": return K(n, r);
3227
3211
  }
3228
3212
  }
3229
- function q(e, t) {
3213
+ function K(e, t) {
3230
3214
  let n = t.maxContent.get(e);
3231
3215
  if (n !== void 0) return n;
3232
3216
  let r = e.style, i = tr(e, t) + r.border.left + r.border.right + Gn(r.padding.left) + Gn(r.padding.right) + it(r).right;
@@ -3234,23 +3218,23 @@ function q(e, t) {
3234
3218
  }
3235
3219
  function tr(e, t) {
3236
3220
  let n = e.children.filter((e) => !z(e.style) && !e.inlineBox);
3237
- if (n.length === 0) return e.style.display === "multicol" ? Bt(e.style, e.intrinsicWidth) : e.intrinsicWidth;
3238
- if (e.style.display === "grid") return _t(e, t).max;
3239
- if (e.style.display === "table") return bn(e, t).max;
3221
+ if (n.length === 0) return e.style.display === "multicol" ? zt(e.style, e.intrinsicWidth) : e.intrinsicWidth;
3222
+ if (e.style.display === "grid") return gt(e, t).max;
3223
+ if (e.style.display === "table") return yn(e, t).max;
3240
3224
  if (e.style.display === "flex" && e.style.flexDirection === "row") {
3241
3225
  let r = Math.max(Gn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3242
- return n.reduce((e, n) => e + J(n, "max", t), 0) + r;
3226
+ return n.reduce((e, n) => e + q(n, "max", t), 0) + r;
3243
3227
  }
3244
- let r = n.reduce((e, n) => Math.max(e, J(n, "max", t)), 0);
3245
- return e.style.display === "multicol" ? Bt(e.style, r) : r;
3228
+ let r = n.reduce((e, n) => Math.max(e, q(n, "max", t)), 0);
3229
+ return e.style.display === "multicol" ? zt(e.style, r) : r;
3246
3230
  }
3247
- function J(e, t, n) {
3231
+ function q(e, t, n) {
3248
3232
  let r = e.style, i;
3249
- r.width !== void 0 && r.width.kind !== "auto" && r.width.kind !== "percent" && (i = K(r.width, 0, e, n)), i === void 0 && (i = t === "min" ? Y(e, n) : q(e, n));
3233
+ r.width !== void 0 && r.width.kind !== "auto" && r.width.kind !== "percent" && (i = G(r.width, 0, e, n)), i === void 0 && (i = t === "min" ? J(e, n) : K(e, n));
3250
3234
  let a = typeof r.minWidth == "number" ? r.minWidth : 0, o = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
3251
3235
  return Math.max(0, V(i, a, o));
3252
3236
  }
3253
- function Y(e, t) {
3237
+ function J(e, t) {
3254
3238
  let n = t.minContent.get(e);
3255
3239
  if (n !== void 0) return n;
3256
3240
  let r = e.style, i = nr(e, t) + r.border.left + r.border.right + Gn(r.padding.left) + Gn(r.padding.right) + it(r).right;
@@ -3258,17 +3242,17 @@ function Y(e, t) {
3258
3242
  }
3259
3243
  function nr(e, t) {
3260
3244
  let n = e.children.filter((e) => !z(e.style) && !e.inlineBox);
3261
- if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : Pe(e.text, {
3245
+ if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : Ne(e.text, {
3262
3246
  advances: e.advances,
3263
3247
  tracking: e.style.tracking
3264
3248
  });
3265
- if (e.style.display === "grid") return _t(e, t).min;
3266
- if (e.style.display === "table") return bn(e, t).min;
3249
+ if (e.style.display === "grid") return gt(e, t).min;
3250
+ if (e.style.display === "table") return yn(e, t).min;
3267
3251
  if (e.style.display === "flex" && e.style.flexDirection === "row" && e.style.flexWrap === "nowrap") {
3268
3252
  let r = Math.max(Gn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3269
- return n.reduce((e, n) => e + J(n, "min", t), 0) + r;
3253
+ return n.reduce((e, n) => e + q(n, "min", t), 0) + r;
3270
3254
  }
3271
- return n.reduce((e, n) => Math.max(e, J(n, "min", t)), 0);
3255
+ return n.reduce((e, n) => Math.max(e, q(n, "min", t)), 0);
3272
3256
  }
3273
3257
  function rr(e, t, n, r) {
3274
3258
  return {
@@ -3338,7 +3322,7 @@ function fr(e, t, n, r, i = 1) {
3338
3322
  for (let n = 0; n < e.localRect.height; n++) for (let i = 0; i < e.localRect.width; i++) r(a + i, o + n, " ", t);
3339
3323
  }
3340
3324
  let l = [];
3341
- ue(s, {
3325
+ de(s, {
3342
3326
  x: a,
3343
3327
  y: o,
3344
3328
  width: e.localRect.width,
@@ -3352,43 +3336,33 @@ function fr(e, t, n, r, i = 1) {
3352
3336
  let e = c(t.color === void 0 ? void 0 : { color: t.color });
3353
3337
  for (let n = 0; n < t.length; n++) r(a + t.x + n, o + t.y, t.glyph, e);
3354
3338
  }
3355
- let u = e.resolvedPadding, d = e.scrollGutterCells, f = s.overflow.x !== "visible", p = s.overflow.y !== "visible", m = a - (e.scroll?.x ?? 0), h = o - (e.scroll?.y ?? 0), g = r;
3356
- if (f || p) {
3357
- let t = a + s.border.left, n = o + s.border.top, i = a + e.localRect.width - s.border.right - (d?.right ?? 0), c = o + e.localRect.height - s.border.bottom - (d?.bottom ?? 0);
3358
- g = (e, a, o, s) => {
3359
- f && (e < t || e >= i) || p && (a < n || a >= c) || r(e, a, o, s);
3339
+ let u = e.scrollGutterCells, d = s.overflow.x !== "visible", f = s.overflow.y !== "visible", p = a - (e.scroll?.x ?? 0), m = o - (e.scroll?.y ?? 0), h = r;
3340
+ if (d || f) {
3341
+ let t = a + s.border.left, n = o + s.border.top, i = a + e.localRect.width - s.border.right - (u?.right ?? 0), c = o + e.localRect.height - s.border.bottom - (u?.bottom ?? 0);
3342
+ h = (e, a, o, s) => {
3343
+ d && (e < t || e >= i) || f && (a < n || a >= c) || r(e, a, o, s);
3360
3344
  };
3361
3345
  }
3362
3346
  if (!e.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed") && e.text) {
3363
- let t = m + s.border.left + u.left, n = h + s.border.top + u.top, r = e.localRect.width - s.border.left - s.border.right - u.left - u.right, i = e.multicolGeometry, { spans: a, textY: o } = i ?? Hn(e, r), l = i ? Math.max(1, i.columnWidth - s.tracking) : r, d = c(dr(s)), f = e.inlineElements?.map((e) => c(dr(e)));
3364
- for (let r = 0; r < a.length; r++) {
3365
- let u = a[r], p = n + o[r], m = r === 0 ? s.textIndent : 0, h = s.whiteSpace !== "normal" && s.overflow.x === "clip" ? hr(e.text, u, l - m, e.advances, s) : {
3366
- end: u.end,
3367
- ellipsis: !1
3368
- }, _ = I(u.start, u.end, e.advances, s.tracking), v = Math.max(0, l - m - _), y = s.textAlign === "end" ? v : s.textAlign === "center" ? Math.floor(v / 2) : 0, b = t + (i?.lineX[r] ?? 0) + y + m;
3369
- for (let t = u.start; t < h.end; t++) {
3370
- if (e.text[t] !== "") {
3371
- let n = e.charInline?.[t] ?? -1, r = n >= 0 ? e.inlineElements[n] : void 0, i = r?.insets, a = i ? i.left ?? (i.right === null ? 0 : -i.right) : 0, o = i ? i.top ?? (i.bottom === null ? 0 : -i.bottom) : 0;
3372
- e.text[t] === "⁠" ? r?.backgroundColor && g(b + a, p + o, " ", c({ backgroundColor: r.backgroundColor })) : g(b + a, p + o, e.text[t], r ? f[n] : d);
3373
- }
3374
- b += Me(t, t + 1, e.advances);
3375
- }
3376
- h.ellipsis && g(b, p, "…", d);
3377
- }
3378
- }
3379
- for (let t of pe(e)) fr(t, m, h, g, i * t.style.opacity);
3380
- let _ = e.scrollRange;
3381
- if (_ && d && (d.right > 0 || d.bottom > 0)) {
3382
- let { track: t, thumb: n } = j(S(s.glyphSet)), i = (e) => c(e ? { color: e } : void 0), l = i(s.scrollbarColor?.track ?? s.color), u = i(s.scrollbarColor?.thumb ?? s.color), d = pr(e, a, o);
3347
+ let t = c(dr(s)), n = e.inlineElements?.map((e) => c(dr(e)));
3348
+ pr(e, p, m, (r, i, a) => {
3349
+ let o = e.charInline?.[r] ?? -1, s = o >= 0 ? e.inlineElements[o] : void 0;
3350
+ e.text[r] === "⁠" ? s?.backgroundColor && h(i, a, " ", c({ backgroundColor: s.backgroundColor })) : h(i, a, e.text[r], s ? n[o] : t);
3351
+ }, (e, n) => h(e, n, "…", t));
3352
+ }
3353
+ for (let t of me(e)) fr(t, p, m, h, i * t.style.opacity);
3354
+ let g = e.scrollRange;
3355
+ if (g && u && (u.right > 0 || u.bottom > 0)) {
3356
+ let { track: t, thumb: n } = ee(S(s.glyphSet)), i = (e) => c(e ? { color: e } : void 0), l = i(s.scrollbarColor?.track ?? s.color), u = i(s.scrollbarColor?.thumb ?? s.color), d = gr(e, a, o);
3383
3357
  if (d.y) {
3384
- let { col: i, row: a, thick: o, len: s } = d.y, { at: c, len: f } = mr(s, _.sizeY, _.maxY, e.scroll?.y ?? 0);
3358
+ let { col: i, row: a, thick: o, len: s } = d.y, { at: c, len: f } = _r(s, g.sizeY, g.maxY, e.scroll?.y ?? 0);
3385
3359
  for (let e = 0; e < o; e++) for (let o = 0; o < s; o++) {
3386
3360
  let s = o >= c && o < c + f;
3387
3361
  r(i + e, a + o, s ? n : t, s ? u : l);
3388
3362
  }
3389
3363
  }
3390
3364
  if (d.x) {
3391
- let { col: i, row: a, thick: o, len: s } = d.x, { at: c, len: f } = mr(s, _.sizeX, _.maxX, e.scroll?.x ?? 0);
3365
+ let { col: i, row: a, thick: o, len: s } = d.x, { at: c, len: f } = _r(s, g.sizeX, g.maxX, e.scroll?.x ?? 0);
3392
3366
  for (let e = 0; e < o; e++) for (let o = 0; o < s; o++) {
3393
3367
  let s = o >= c && o < c + f;
3394
3368
  r(i + o, a + e, s ? n : t, s ? u : l);
@@ -3396,7 +3370,42 @@ function fr(e, t, n, r, i = 1) {
3396
3370
  }
3397
3371
  }
3398
3372
  }
3399
- function pr(e, t, n) {
3373
+ function pr(e, t, n, r, i) {
3374
+ let a = e.style, o = e.resolvedPadding, s = t + a.border.left + o.left, c = n + a.border.top + o.top, l = e.localRect.width - a.border.left - a.border.right - o.left - o.right, u = e.multicolGeometry, { spans: d, textY: f } = u ?? Vn(e, l), p = u ? Math.max(1, u.columnWidth - a.tracking) : l;
3375
+ for (let t = 0; t < d.length; t++) {
3376
+ let n = d[t], o = c + f[t], l = t === 0 ? a.textIndent : 0, m = a.whiteSpace !== "normal" && a.overflow.x === "clip" ? vr(e.text, n, p - l, e.advances, a) : {
3377
+ end: n.end,
3378
+ ellipsis: !1
3379
+ }, h = F(n.start, n.end, e.advances, a.tracking), g = Math.max(0, p - l - h), _ = a.textAlign === "end" ? g : a.textAlign === "center" ? Math.floor(g / 2) : 0, v = s + (u?.lineX[t] ?? 0) + _ + l;
3380
+ for (let t = n.start; t < m.end; t++) {
3381
+ let n = je(t, t + 1, e.advances);
3382
+ if (e.text[t] !== "") {
3383
+ let i = e.inlineElements?.[e.charInline?.[t] ?? -1]?.insets, a = i ? i.left ?? (i.right === null ? 0 : -i.right) : 0, s = i ? i.top ?? (i.bottom === null ? 0 : -i.bottom) : 0;
3384
+ r(t, v + a, o + s, n);
3385
+ }
3386
+ v += n;
3387
+ }
3388
+ m.ellipsis && i?.(v, o);
3389
+ }
3390
+ }
3391
+ function mr(e, t, n, r, i) {
3392
+ let a = e.multicolGeometry;
3393
+ if (!a) return !1;
3394
+ let o = e.style, s = e.resolvedPadding, c = r - (t + o.border.left + s.left), l = i - (n + o.border.top + s.top), { lineX: u, lineY: d } = a;
3395
+ for (let e = 0; e < d.length; e++) {
3396
+ if (c < u[e] || c >= u[e] + a.columnWidth) continue;
3397
+ let t = (e + 1 < d.length && u[e + 1] === u[e] ? d[e + 1] : void 0) ?? d[e] + 1 + o.lineGap;
3398
+ if (l >= d[e] && l < t) return !0;
3399
+ }
3400
+ return !1;
3401
+ }
3402
+ function hr(e, t, n, r, i) {
3403
+ let a = null;
3404
+ return pr(e, t - (e.scroll?.x ?? 0), n - (e.scroll?.y ?? 0), (e, t, n, o) => {
3405
+ a === null && n === i && r >= t && r < t + o && (a = e);
3406
+ }), a;
3407
+ }
3408
+ function gr(e, t, n) {
3400
3409
  let r = e.scrollGutterCells;
3401
3410
  if (!r) return {};
3402
3411
  let { border: i, scrollbarSize: a, scrollbarInset: o } = e.style, s = n + i.top, c = t + i.left, l = n + e.localRect.height - i.bottom, u = t + e.localRect.width - i.right, d = r.bottom > 0 ? l - r.bottom : l - o.y, f = r.right > 0 ? u - r.right : u - o.x, p = {};
@@ -3412,38 +3421,214 @@ function pr(e, t, n) {
3412
3421
  len: Math.max(0, f - c - o.x)
3413
3422
  }), p;
3414
3423
  }
3415
- function mr(e, t, n, r) {
3424
+ function _r(e, t, n, r) {
3416
3425
  let i = t > 0 ? Math.min(1, e / t) : 1, a = Math.max(1, Math.round(i * e));
3417
3426
  return n > 0 && (a = Math.max(1, Math.min(a, e - n))), {
3418
3427
  at: n > 0 ? Math.round(Math.min(r, n) / n * (e - a)) : 0,
3419
3428
  len: a
3420
3429
  };
3421
3430
  }
3422
- function hr(e, t, n, r, i) {
3431
+ function vr(e, t, n, r, i) {
3423
3432
  let { textOverflow: a, tracking: o } = i;
3424
- if (I(t.start, t.end, r, o) <= n) return {
3433
+ if (F(t.start, t.end, r, o) <= n) return {
3425
3434
  end: t.end,
3426
3435
  ellipsis: !1
3427
3436
  };
3428
3437
  let s = a === "ellipsis" ? n - 1 : n, c = t.start;
3429
- for (; c < t.end && I(t.start, c + 1, r, o) <= s;) c++;
3438
+ for (; c < t.end && F(t.start, c + 1, r, o) <= s;) c++;
3430
3439
  return {
3431
3440
  end: c,
3432
3441
  ellipsis: a === "ellipsis" && n > 0
3433
3442
  };
3434
3443
  }
3435
3444
  //#endregion
3445
+ //#region src/pointer.ts
3446
+ function yr(e, t, n) {
3447
+ let r = [], i = e, a = e.localRect.x, o = e.localRect.y;
3448
+ for (;;) {
3449
+ let e = null;
3450
+ for (let r of me(i)) {
3451
+ if (r.tableHidden) continue;
3452
+ let i = a + r.localRect.x, s = o + r.localRect.y;
3453
+ (r.multicolFlow ? mr(r, i, s, t, n) : t >= i && t < i + r.localRect.width && n >= s && n < s + r.localRect.height) && (e = r);
3454
+ }
3455
+ if (!e) return r;
3456
+ r.push({
3457
+ node: e,
3458
+ x: a + e.localRect.x,
3459
+ y: o + e.localRect.y
3460
+ }), a += e.localRect.x - (e.scroll?.x ?? 0), o += e.localRect.y - (e.scroll?.y ?? 0), i = e;
3461
+ }
3462
+ }
3463
+ function br(e, t, n) {
3464
+ return yr(e, t, n).map((e) => e.node.source);
3465
+ }
3466
+ //#endregion
3467
+ //#region src/selection.ts
3468
+ function xr(e, t, n, r) {
3469
+ let i = e.ownerDocument, a = i.createRange();
3470
+ a.setStart(e, t), a.collapse(!0);
3471
+ let o = i.createRange();
3472
+ return o.setStart(n, r), o.collapse(!0), a.compareBoundaryPoints(a.START_TO_START, o);
3473
+ }
3474
+ function Sr(e, t, n) {
3475
+ let r = nt(e).findIndex((e) => e.source.contains(t));
3476
+ if (r >= 0) {
3477
+ let t = -1;
3478
+ for (let n = 0; n <= r; n++) t = e.text.indexOf("", t + 1);
3479
+ if (t >= 0) return t;
3480
+ }
3481
+ let i = e.charSource ?? [], a = 0, o = i.length;
3482
+ for (; a < o;) {
3483
+ let e = a + o >> 1, r = i[e];
3484
+ xr(r.node, r.offset, t, n) <= 0 ? a = e + 1 : o = e;
3485
+ }
3486
+ if (a === 0) return 0;
3487
+ let s = i[a - 1];
3488
+ return t === s.node && n < s.offset + s.length ? s.index + (n - s.offset) : s.index + s.length;
3489
+ }
3490
+ function Cr(e, t) {
3491
+ let n = e.charSource ?? [], r = 0, i = n.length;
3492
+ for (; r < i;) {
3493
+ let e = r + i >> 1;
3494
+ n[e].index <= t ? r = e + 1 : i = e;
3495
+ }
3496
+ let a = n[r - 1];
3497
+ if (!a) return null;
3498
+ let o = t - a.index;
3499
+ return o <= a.length ? {
3500
+ node: a.node,
3501
+ offset: a.offset + o
3502
+ } : null;
3503
+ }
3504
+ function wr(e) {
3505
+ try {
3506
+ let t = e.ownerDocument.getSelection();
3507
+ if (!t) return null;
3508
+ if (t.getComposedRanges) return t.getComposedRanges({ shadowRoots: [e] })[0] ?? null;
3509
+ let n = e.getSelection?.();
3510
+ return !n || n.rangeCount === 0 ? null : n.getRangeAt(0);
3511
+ } catch {
3512
+ return null;
3513
+ }
3514
+ }
3515
+ function Tr(e, t, n) {
3516
+ let { startContainer: r, endContainer: i } = n;
3517
+ return t.contains(r) && t.contains(i) ? "grid" : e.contains(r) && e.contains(i) ? "light" : "outside";
3518
+ }
3519
+ function Er(e, t) {
3520
+ let n = e.source.ownerDocument.createRange();
3521
+ n.setStart(t.startContainer, t.startOffset), n.setEnd(t.endContainer, t.endOffset);
3522
+ let r = [];
3523
+ return Dr(e, n, r), Pr(r);
3524
+ }
3525
+ function Dr(e, t, n) {
3526
+ if (e.tableHidden || !t.intersectsNode(e.source)) return;
3527
+ let r = jr(e);
3528
+ if (r && n.push({ breaks: r }), e.style.tableRole === "row") Or(e, t, n);
3529
+ else if (e.style.display === "table") {
3530
+ let r = Ar(e);
3531
+ for (let r of e.children) r.style.tableRole === "row" || kr(r) || Dr(r, t, n);
3532
+ let i = !1;
3533
+ for (let e of r) t.intersectsNode(e.source) && (i && n.push({ text: "\n" }), Dr(e, t, n), i = !0);
3534
+ } else {
3535
+ Mr(e) && n.push({ text: Nr(e, t) });
3536
+ for (let r of e.children) r.inlineBox || Dr(r, t, n);
3537
+ }
3538
+ r && n.push({ breaks: r });
3539
+ }
3540
+ function Or(e, t, n) {
3541
+ let r = !1;
3542
+ for (let i of e.children) i.style.tableRole !== "cell" || i.tableHidden || t.intersectsNode(i.source) && (r && n.push({ text: " " }), Dr(i, t, n), r = !0);
3543
+ }
3544
+ function kr(e) {
3545
+ let t = e.style.tableRole;
3546
+ return t === "header-group" || t === "row-group" || t === "footer-group";
3547
+ }
3548
+ function Ar(e) {
3549
+ let t = [];
3550
+ for (let n of e.children) if (n.style.tableRole === "row") t.push(n);
3551
+ else if (kr(n)) for (let e of n.children) e.style.tableRole === "row" && t.push(e);
3552
+ return t;
3553
+ }
3554
+ function jr(e) {
3555
+ if (e.inlineBox) return 0;
3556
+ let t = e.style.tableRole;
3557
+ return t === "row" || t === "cell" || kr(e) || t === "column" || t === "column-group" ? 0 : e.source.tagName === "P" ? 2 : 1;
3558
+ }
3559
+ function Mr(e) {
3560
+ return e.text.length !== 0 && !e.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed");
3561
+ }
3562
+ function Nr(e, t) {
3563
+ let { text: n } = e, r = 0, i = n.length;
3564
+ e.charSource && (e.source.contains(t.startContainer) && (r = Sr(e, t.startContainer, t.startOffset)), e.source.contains(t.endContainer) && (i = Sr(e, t.endContainer, t.endOffset)));
3565
+ let a = n.slice(r, i);
3566
+ i === n.length && a.endsWith("\n") && (a = a.slice(0, -1));
3567
+ let o = nt(e), s = n.slice(0, r).split("").length - 1;
3568
+ return a = a.replaceAll("", () => {
3569
+ let e = o[s++];
3570
+ if (!e || !t.intersectsNode(e.source)) return "";
3571
+ let n = [];
3572
+ return Dr(e, t, n), Pr(n);
3573
+ }), a.replaceAll("⁠", "");
3574
+ }
3575
+ function Pr(e) {
3576
+ let t = "", n = 0;
3577
+ for (let r of e) {
3578
+ if ("breaks" in r) {
3579
+ n = Math.max(n, r.breaks);
3580
+ continue;
3581
+ }
3582
+ r.text.length !== 0 && (t.length > 0 && n > 0 && (t += "\n".repeat(n)), n = 0, t += r.text);
3583
+ }
3584
+ return t;
3585
+ }
3586
+ var Fr = /* @__PURE__ */ new Map();
3587
+ function Ir(e, t) {
3588
+ let { text: n } = e;
3589
+ if (t < 0 || t >= n.length || Lr(n[t])) return null;
3590
+ let r = t;
3591
+ for (; r > 0 && !Lr(n[r - 1]);) r--;
3592
+ let i = t;
3593
+ for (; i < n.length && !Lr(n[i]);) i++;
3594
+ let a = Rr(e.source.closest?.("[lang]")?.getAttribute("lang") ?? "");
3595
+ if (!a) return null;
3596
+ for (let e of a.segment(n.slice(r, i))) {
3597
+ let n = r + e.index, i = n + e.segment.length;
3598
+ if (t >= n && t < i) return {
3599
+ start: n,
3600
+ end: i
3601
+ };
3602
+ }
3603
+ return null;
3604
+ }
3605
+ function Lr(e) {
3606
+ return e === "\n" || e === "" || e === "⁠";
3607
+ }
3608
+ function Rr(e) {
3609
+ let t = Fr.get(e);
3610
+ return t === void 0 && (t = zr(e) ?? zr(""), Fr.set(e, t)), t;
3611
+ }
3612
+ function zr(e) {
3613
+ if (typeof Intl.Segmenter != "function") return null;
3614
+ try {
3615
+ return new Intl.Segmenter(e || void 0, { granularity: "word" });
3616
+ } catch {
3617
+ return null;
3618
+ }
3619
+ }
3620
+ //#endregion
3436
3621
  //#region src/paint.ts
3437
- var gr = /* @__PURE__ */ new WeakMap(), _r = /* @__PURE__ */ new WeakMap();
3438
- function vr(e) {
3439
- return xr(e, !0) !== null;
3440
- }
3441
- function yr(e, t, n = !1) {
3442
- let r = ar(e), i = Er(r);
3443
- if (gr.get(t) === i) return !0;
3444
- let a = _r.get(t);
3445
- if (a && br(t, a.nodes, r)) {
3446
- gr.set(t, i);
3622
+ var Br = /* @__PURE__ */ new WeakMap(), Vr = /* @__PURE__ */ new WeakMap();
3623
+ function Hr(e) {
3624
+ return Gr(e, !0) !== null;
3625
+ }
3626
+ function Ur(e, t, n = !1) {
3627
+ let r = ar(e), i = Xr(r);
3628
+ if (Br.get(t) === i) return !0;
3629
+ let a = Vr.get(t);
3630
+ if (a && Wr(t, a.nodes, r)) {
3631
+ Br.set(t, i);
3447
3632
  for (let e = 0; e < r.length; e++) for (let t = 0; t < r[e].length; t++) {
3448
3633
  let n = r[e][t];
3449
3634
  if (lr(n) || sr(n, a.segments[e][t])) continue;
@@ -3452,8 +3637,8 @@ function yr(e, t, n = !1) {
3452
3637
  }
3453
3638
  return a.segments = r, !0;
3454
3639
  }
3455
- if (n && vr(t)) return !1;
3456
- gr.set(t, i);
3640
+ if (n && Hr(t)) return !1;
3641
+ Br.set(t, i);
3457
3642
  let o = document.createDocumentFragment(), s = [];
3458
3643
  for (let e = 0; e < r.length; e++) {
3459
3644
  e > 0 && o.appendChild(document.createTextNode("\n"));
@@ -3469,14 +3654,14 @@ function yr(e, t, n = !1) {
3469
3654
  }
3470
3655
  s.push(t);
3471
3656
  }
3472
- _r.set(t, {
3657
+ Vr.set(t, {
3473
3658
  nodes: s,
3474
3659
  segments: r
3475
3660
  });
3476
- let c = xr(t, !1);
3477
- return t.replaceChildren(o), c && Sr(t, c), !0;
3661
+ let c = Gr(t, !1);
3662
+ return t.replaceChildren(o), c && Kr(t, c), !0;
3478
3663
  }
3479
- function br(e, t, n) {
3664
+ function Wr(e, t, n) {
3480
3665
  if (t.length !== n.length) return !1;
3481
3666
  for (let r = 0; r < n.length; r++) {
3482
3667
  let i = t[r], a = n[r];
@@ -3488,23 +3673,15 @@ function br(e, t, n) {
3488
3673
  }
3489
3674
  return !0;
3490
3675
  }
3491
- function xr(e, t) {
3676
+ function Gr(e, t) {
3492
3677
  try {
3493
3678
  let n = e.ownerDocument.getSelection();
3494
3679
  if (!n) return null;
3495
3680
  let r = e.getRootNode();
3496
3681
  if (!(r instanceof ShadowRoot)) return null;
3497
- let i;
3498
- if (n.getComposedRanges) {
3499
- let e = n.getComposedRanges({ shadowRoots: [r] });
3500
- if (e.length === 0) return null;
3501
- i = e[0];
3502
- } else {
3503
- let e = r.getSelection?.();
3504
- if (!e || e.rangeCount === 0) return null;
3505
- i = e.getRangeAt(0);
3506
- }
3507
- let a = Cr(e, i.startContainer, i.startOffset), o = Cr(e, i.endContainer, i.endOffset);
3682
+ let i = wr(r);
3683
+ if (!i) return null;
3684
+ let a = qr(e, i.startContainer, i.startOffset), o = qr(e, i.endContainer, i.endOffset);
3508
3685
  return a === null || o === null || a === o && !t ? null : {
3509
3686
  start: a,
3510
3687
  end: o,
@@ -3514,32 +3691,32 @@ function xr(e, t) {
3514
3691
  return null;
3515
3692
  }
3516
3693
  }
3517
- function Sr(e, t) {
3694
+ function Kr(e, t) {
3518
3695
  try {
3519
- let n = wr(e, t.start), r = wr(e, t.end);
3696
+ let n = Jr(e, t.start), r = Jr(e, t.end);
3520
3697
  if (!n || !r) return;
3521
3698
  let i = e.getRootNode().getSelection?.() ?? e.ownerDocument.getSelection();
3522
3699
  t.backward ? i?.setBaseAndExtent(r[0], r[1], n[0], n[1]) : i?.setBaseAndExtent(n[0], n[1], r[0], r[1]);
3523
3700
  } catch {}
3524
3701
  }
3525
- function Cr(e, t, n) {
3702
+ function qr(e, t, n) {
3526
3703
  if (!e.contains(t)) return null;
3527
3704
  let r = e.ownerDocument.createRange();
3528
3705
  return r.selectNodeContents(e), r.setEnd(t, n), r.toString().length;
3529
3706
  }
3530
- function wr(e, t) {
3707
+ function Jr(e, t) {
3531
3708
  let n = t, r = null;
3532
- for (let t of Tr(e)) {
3709
+ for (let t of Yr(e)) {
3533
3710
  if (n <= t.data.length) return [t, n];
3534
3711
  n -= t.data.length, r = [t, t.data.length];
3535
3712
  }
3536
3713
  return r;
3537
3714
  }
3538
- function* Tr(e) {
3715
+ function* Yr(e) {
3539
3716
  let t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), n = t.nextNode();
3540
3717
  for (; n;) yield n, n = t.nextNode();
3541
3718
  }
3542
- function Er(e) {
3719
+ function Xr(e) {
3543
3720
  let t = [];
3544
3721
  for (let n of e) {
3545
3722
  for (let e of n) t.push(e.text, e.color ?? "", e.backgroundColor ?? "", e.fontWeight ?? "", e.fontStyle ?? "", e.textDecorationLine ?? "", e.opacity ?? "");
@@ -3549,9 +3726,9 @@ function Er(e) {
3549
3726
  }
3550
3727
  //#endregion
3551
3728
  //#region src/render.ts
3552
- function Dr(e) {
3729
+ function Zr(e) {
3553
3730
  let t = /* @__PURE__ */ new Set();
3554
- Or(e, !0, t);
3731
+ Qr(e, !0, t);
3555
3732
  for (let n of Array.from(e.source.querySelectorAll("[data-mw-inline-inset]"))) if (!t.has(n)) {
3556
3733
  n.removeAttribute("data-mw-inline-inset");
3557
3734
  let e = n.style;
@@ -3563,78 +3740,78 @@ function Dr(e) {
3563
3740
  ]) e.removeProperty(t);
3564
3741
  }
3565
3742
  }
3566
- function X(e, t, n) {
3743
+ function Y(e, t, n) {
3567
3744
  e.style.getPropertyValue(t) !== n && e.style.setProperty(t, n);
3568
3745
  }
3569
- function Z(e, t) {
3746
+ function X(e, t) {
3570
3747
  e.style.getPropertyValue(t) !== "" && e.style.removeProperty(t);
3571
3748
  }
3572
- function Q(e, t, n) {
3749
+ function Z(e, t, n) {
3573
3750
  e.hasAttribute(t) !== n && (n ? e.setAttribute(t, "") : e.removeAttribute(t));
3574
3751
  }
3575
- function Or(e, t, n) {
3752
+ function Qr(e, t, n) {
3576
3753
  if (e.inlineElements) for (let { element: t, tracking: r, padLeft: i, padRight: a, insets: o } of e.inlineElements) {
3577
3754
  let e = t;
3578
- X(e, "--mw-ls", String(r)), i > 0 ? X(e, "--mw-ipl", String(i)) : Z(e, "--mw-ipl"), a > 0 ? X(e, "--mw-ipr", String(a)) : Z(e, "--mw-ipr"), o && (n.add(t), kr(e, o));
3755
+ Y(e, "--mw-ls", String(r)), i > 0 ? Y(e, "--mw-ipl", String(i)) : X(e, "--mw-ipl"), a > 0 ? Y(e, "--mw-ipr", String(a)) : X(e, "--mw-ipr"), o && (n.add(t), $r(e, o));
3579
3756
  }
3580
- if (t || jr(e), !e.tableHidden) for (let t of pe(e)) {
3757
+ if (t || ti(e), !e.tableHidden) for (let t of me(e)) {
3581
3758
  let r = t.source;
3582
- t.style.zIndex !== null && fe(t, e) && !t.inlineBox ? X(r, "--mw-z", String(t.style.zIndex)) : Z(r, "--mw-z"), Or(t, !1, n);
3759
+ t.style.zIndex !== null && pe(t, e) && !t.inlineBox ? Y(r, "--mw-z", String(t.style.zIndex)) : X(r, "--mw-z"), Qr(t, !1, n);
3583
3760
  }
3584
3761
  }
3585
- function kr(e, t) {
3586
- Q(e, "data-mw-inline-inset", !0);
3762
+ function $r(e, t) {
3763
+ Z(e, "data-mw-inline-inset", !0);
3587
3764
  let n = (t, n) => {
3588
- n === null ? Z(e, t) : X(e, t, String(n));
3765
+ n === null ? X(e, t) : Y(e, t, String(n));
3589
3766
  };
3590
3767
  n("--mw-it", t.top), n("--mw-ir", t.right), n("--mw-ib", t.bottom), n("--mw-il", t.left);
3591
3768
  }
3592
- function Ar(e) {
3769
+ function ei(e) {
3593
3770
  let t = e.style;
3594
3771
  if (t.textAlign !== "center" || !e.text || e.inlineBox || e.children.length > 0) return !1;
3595
- let n = e.multicolGeometry, r = e.resolvedPadding, i = e.localRect.width - t.border.left - t.border.right - r.left - r.right, a = n ? Math.max(1, n.columnWidth - t.tracking) : i, o = n?.spans ?? Un(e, i);
3772
+ let n = e.multicolGeometry, r = e.resolvedPadding, i = e.localRect.width - t.border.left - t.border.right - r.left - r.right, a = n ? Math.max(1, n.columnWidth - t.tracking) : i, o = n?.spans ?? Hn(e, i);
3596
3773
  return o.length !== 0 && o.every((n, r) => {
3597
- let i = r === 0 ? t.textIndent : 0, o = a - i - I(n.start, n.end, e.advances, t.tracking);
3774
+ let i = r === 0 ? t.textIndent : 0, o = a - i - F(n.start, n.end, e.advances, t.tracking);
3598
3775
  return o > 0 && o % 2 == 1;
3599
3776
  });
3600
3777
  }
3601
- function jr(e) {
3778
+ function ti(e) {
3602
3779
  let t = e.source, n = e.localRect, r = e.resolvedPadding, { border: i, textAlignBlocked: a, overflow: o, whiteSpace: s, tracking: c, lineGap: l } = e.style, u = e.multicolFlow, d = e.multicolFlowSpan;
3603
- Q(t, "data-mw-laid-out", !e.inlineBox && !u && !d), Q(t, "data-mw-inline-box", !!e.inlineBox), Q(t, "data-mw-multicol-flow", !!u), Q(t, "data-mw-multicol-flow-span", !!d);
3780
+ Z(t, "data-mw-laid-out", !e.inlineBox && !u && !d), Z(t, "data-mw-inline-box", !!e.inlineBox), Z(t, "data-mw-multicol-flow", !!u), Z(t, "data-mw-multicol-flow-span", !!d);
3604
3781
  let f = u ?? d;
3605
- f ? (X(t, "--mw-mt", String(f.top ?? 0)), X(t, "--mw-mr", String(f.right ?? 0)), X(t, "--mw-mb", String(f.bottom ?? 0)), X(t, "--mw-ml", String(f.left ?? 0))) : (Z(t, "--mw-mt"), Z(t, "--mw-mr"), Z(t, "--mw-mb"), Z(t, "--mw-ml")), Q(t, "data-mw-vbottom", !!e.inlineBox && e.style.verticalAlign === "end"), X(t, "--mw-ls", String(c)), X(t, "--mw-lh", String(l + 1)), X(t, "--mw-lhs", String(-l / 2)), Q(t, "data-mw-nowrap", s !== "normal");
3782
+ f ? (Y(t, "--mw-mt", String(f.top ?? 0)), Y(t, "--mw-mr", String(f.right ?? 0)), Y(t, "--mw-mb", String(f.bottom ?? 0)), Y(t, "--mw-ml", String(f.left ?? 0))) : (X(t, "--mw-mt"), X(t, "--mw-mr"), X(t, "--mw-mb"), X(t, "--mw-ml")), Z(t, "data-mw-vbottom", !!e.inlineBox && e.style.verticalAlign === "end"), Y(t, "--mw-ls", String(c)), Y(t, "--mw-lh", String(l + 1)), Y(t, "--mw-lhs", String(-l / 2)), Z(t, "data-mw-nowrap", s !== "normal");
3606
3783
  let p = u || d ? void 0 : e.multicolGeometry;
3607
- if (Q(t, "data-mw-multicol", !!p), Q(t, "data-mw-multicol-balance", !!p?.nativeBalance), p ? (X(t, "--mw-colc", String(p.columnCount)), X(t, "--mw-colg", String(p.gap))) : (Z(t, "--mw-colc"), Z(t, "--mw-colg")), Q(t, "data-mw-pre", s === "pre"), X(t, "--mw-x", String(n.x)), X(t, "--mw-y", String(n.y)), X(t, "--mw-w", String(n.width)), X(t, "--mw-h", String(n.height)), Q(t, "data-mw-clip", o.x === "clip" || o.y === "clip"), Q(t, "data-mw-scroll", e.scrollRange !== void 0), e.scrollRange) {
3784
+ if (Z(t, "data-mw-multicol", !!p), Z(t, "data-mw-multicol-balance", !!p?.nativeBalance), p ? (Y(t, "--mw-colc", String(p.columnCount)), Y(t, "--mw-colg", String(p.gap))) : (X(t, "--mw-colc"), X(t, "--mw-colg")), Z(t, "data-mw-pre", s === "pre"), Y(t, "--mw-x", String(n.x)), Y(t, "--mw-y", String(n.y)), Y(t, "--mw-w", String(n.width)), Y(t, "--mw-h", String(n.height)), Z(t, "data-mw-clip", o.x === "clip" || o.y === "clip"), Z(t, "data-mw-scroll", e.scrollRange !== void 0), e.scrollRange) {
3608
3785
  let { maxX: n, maxY: r } = e.scrollRange;
3609
- X(t, "--mw-se-x", String(n > 0 ? n + e.localRect.width : 1)), X(t, "--mw-se-y", String(r > 0 ? r + e.localRect.height : 1));
3610
- } else Z(t, "--mw-se-x"), Z(t, "--mw-se-y");
3611
- X(t, "--mw-pt", String(r.top)), X(t, "--mw-pr", String(r.right)), X(t, "--mw-pb", String(r.bottom)), X(t, "--mw-pl", String(r.left)), X(t, "--mw-bt", String(i.top)), X(t, "--mw-br", String(i.right)), X(t, "--mw-bb", String(i.bottom)), X(t, "--mw-bl", String(i.left)), X(t, "--mw-ti", String(e.style.textIndent)), Q(t, "data-mw-text-align-blocked", a), Q(t, "data-mw-center-nudge", Ar(e)), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
3786
+ Y(t, "--mw-se-x", String(n > 0 ? n + e.localRect.width : 1)), Y(t, "--mw-se-y", String(r > 0 ? r + e.localRect.height : 1));
3787
+ } else X(t, "--mw-se-x"), X(t, "--mw-se-y");
3788
+ Y(t, "--mw-pt", String(r.top)), Y(t, "--mw-pr", String(r.right)), Y(t, "--mw-pb", String(r.bottom)), Y(t, "--mw-pl", String(r.left)), Y(t, "--mw-bt", String(i.top)), Y(t, "--mw-br", String(i.right)), Y(t, "--mw-bb", String(i.bottom)), Y(t, "--mw-bl", String(i.left)), Y(t, "--mw-ti", String(e.style.textIndent)), Z(t, "data-mw-text-align-blocked", a), Z(t, "data-mw-center-nudge", ei(e)), Z(t, "data-mw-dropped-text", !!e.droppedText), Z(t, "data-mw-table-hidden", !!e.tableHidden);
3612
3789
  }
3613
3790
  //#endregion
3614
3791
  //#region src/style.ts
3615
- function Mr(e, t, n) {
3616
- let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = ei(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
3617
- Yr(e, o, s);
3618
- let c = (e, r, i) => _i(a, e, r, o, i, s, n, t) ?? yi(a, e, r, o, i, s, n, t) ?? ui(r, t), l = r.display || Kr[e.tagName] || "", u = qr[l] ?? "none", d = r.columnCount && r.columnCount !== "auto" ? Math.max(1, Math.floor(Number(r.columnCount) || 1)) : null, f = r.columnWidth && r.columnWidth !== "auto" ? parseFloat(r.columnWidth) : NaN, p = Number.isFinite(f) ? Math.max(1, F(f, t)) : null, m = l === "flex" || l === "inline-flex" ? "flex" : l === "grid" || l === "inline-grid" ? "grid" : l === "table" || l === "inline-table" ? "table" : l === "none" || Gr(e, r) ? "none" : d !== null || p !== null ? "multicol" : "block", h = { kind: "none" }, g = { kind: "none" }, _ = [st()], v = [st()], y = {
3792
+ function ni(e, t, n) {
3793
+ let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = wi(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
3794
+ yi(e, o, s);
3795
+ let c = (e, r, i) => Vi(a, e, r, o, i, s, n, t) ?? Ui(a, e, r, o, i, s, n, t) ?? Pi(r, t), l = r.display || gi[e.tagName] || "", u = _i[l] ?? "none", d = r.columnCount && r.columnCount !== "auto" ? Math.max(1, Math.floor(Number(r.columnCount) || 1)) : null, f = r.columnWidth && r.columnWidth !== "auto" ? parseFloat(r.columnWidth) : NaN, p = Number.isFinite(f) ? Math.max(1, P(f, t)) : null, m = l === "flex" || l === "inline-flex" ? "flex" : l === "grid" || l === "inline-grid" ? "grid" : l === "table" || l === "inline-table" ? "table" : l === "none" || hi(e, r) ? "none" : d !== null || p !== null ? "multicol" : "block", h = { kind: "none" }, g = { kind: "none" }, _ = [ot()], v = [ot()], y = {
3619
3796
  direction: "row",
3620
3797
  dense: !1
3621
3798
  }, b = null;
3622
3799
  if (m === "grid") {
3623
- if (a) h = Si(a.get("grid-template-columns")?.toString() ?? "", t), g = Si(a.get("grid-template-rows")?.toString() ?? "", t);
3800
+ if (a) h = Ki(a.get("grid-template-columns")?.toString() ?? "", t), g = Ki(a.get("grid-template-rows")?.toString() ?? "", t);
3624
3801
  else {
3625
3802
  e.setAttribute("data-mw-degrid", "");
3626
3803
  try {
3627
- h = Si(r.getPropertyValue("grid-template-columns"), t), g = Si(r.getPropertyValue("grid-template-rows"), t);
3804
+ h = Ki(r.getPropertyValue("grid-template-columns"), t), g = Ki(r.getPropertyValue("grid-template-rows"), t);
3628
3805
  } finally {
3629
3806
  e.removeAttribute("data-mw-degrid");
3630
3807
  }
3631
3808
  }
3632
- _ = Ei(r.getPropertyValue("grid-auto-columns"), t), v = Ei(r.getPropertyValue("grid-auto-rows"), t), y = Mi(r.getPropertyValue("grid-auto-flow")), b = Ti(r.getPropertyValue("grid-template-areas"));
3809
+ _ = Xi(r.getPropertyValue("grid-auto-columns"), t), v = Xi(r.getPropertyValue("grid-auto-rows"), t), y = na(r.getPropertyValue("grid-auto-flow")), b = Yi(r.getPropertyValue("grid-template-areas"));
3633
3810
  }
3634
3811
  let x = "auto", S = !1, C = 0, w = 0;
3635
3812
  if (m === "table" && (x = r.tableLayout === "fixed" ? "fixed" : "auto", S = r.borderCollapse === "collapse", !S)) {
3636
3813
  let e = r.borderSpacing.split(" ");
3637
- C = F(parseFloat(e[0] ?? "") || 0, t), w = F(parseFloat(e[1] ?? e[0] ?? "") || 0, t);
3814
+ C = P(parseFloat(e[0] ?? "") || 0, t), w = P(parseFloat(e[1] ?? e[0] ?? "") || 0, t);
3638
3815
  }
3639
3816
  let T = {
3640
3817
  display: m,
@@ -3644,75 +3821,75 @@ function Mr(e, t, n) {
3644
3821
  borderSpacingX: C,
3645
3822
  borderSpacingY: w,
3646
3823
  captionSide: r.captionSide === "bottom" ? "bottom" : "top",
3647
- verticalAlign: u === "cell" || l.startsWith("inline-") ? Jr(e, r) : "start",
3824
+ verticalAlign: u === "cell" || l.startsWith("inline-") ? vi(e, r) : "start",
3648
3825
  flexDirection: r.flexDirection.startsWith("column") ? "column" : "row",
3649
3826
  flexReverse: r.flexDirection.endsWith("-reverse"),
3650
3827
  flexWrap: r.flexWrap.startsWith("wrap") ? "wrap" : "nowrap",
3651
3828
  wrapReverse: r.flexWrap === "wrap-reverse",
3652
3829
  flexGrow: Number(r.flexGrow) || 0,
3653
3830
  flexShrink: r.flexShrink === "" ? 1 : Number(r.flexShrink) || 0,
3654
- flexBasis: bi(r.flexBasis, t),
3831
+ flexBasis: Wi(r.flexBasis, t),
3655
3832
  order: Number(r.order) || 0,
3656
- justifyContent: ti(r.justifyContent),
3657
- alignContent: ti(r.alignContent),
3658
- alignItems: ni(r.alignItems),
3659
- alignSelf: ri(r.alignSelf),
3660
- justifyItems: ni(r.justifyItems),
3661
- justifySelf: ri(r.justifySelf),
3833
+ justifyContent: Ti(r.justifyContent),
3834
+ alignContent: Ti(r.alignContent),
3835
+ alignItems: Ei(r.alignItems),
3836
+ alignSelf: Di(r.alignSelf),
3837
+ justifyItems: Ei(r.justifyItems),
3838
+ justifySelf: Di(r.justifySelf),
3662
3839
  gridTemplateColumns: h,
3663
3840
  gridTemplateRows: g,
3664
3841
  gridAutoColumns: _,
3665
3842
  gridAutoRows: v,
3666
3843
  gridAutoFlow: y,
3667
3844
  gridTemplateAreas: b,
3668
- gridColumnStart: ji(r.getPropertyValue("grid-column-start")),
3669
- gridColumnEnd: ji(r.getPropertyValue("grid-column-end")),
3670
- gridRowStart: ji(r.getPropertyValue("grid-row-start")),
3671
- gridRowEnd: ji(r.getPropertyValue("grid-row-end")),
3672
- width: pi(a, r.width, "width", t, o, s, n),
3673
- height: pi(a, r.height, "height", t, o, s, n),
3845
+ gridColumnStart: ta(r.getPropertyValue("grid-column-start")),
3846
+ gridColumnEnd: ta(r.getPropertyValue("grid-column-end")),
3847
+ gridRowStart: ta(r.getPropertyValue("grid-row-start")),
3848
+ gridRowEnd: ta(r.getPropertyValue("grid-row-end")),
3849
+ width: Li(a, r.width, "width", t, o, s, n),
3850
+ height: Li(a, r.height, "height", t, o, s, n),
3674
3851
  minWidth: c("min-width", r.minWidth, "min-w") ?? "auto",
3675
3852
  minHeight: c("min-height", r.minHeight, "min-h") ?? "auto",
3676
3853
  maxWidth: c("max-width", r.maxWidth, "max-w"),
3677
3854
  maxHeight: c("max-height", r.maxHeight, "max-h"),
3678
- padding: Pi(r, t),
3679
- margin: ii(r, a, o, s, t),
3680
- position: si(r.position),
3681
- insets: ci(r, a, o, s, t),
3682
- gapX: $(r.columnGap === "normal" || r.columnGap === "" ? m === "multicol" ? `${i}px` : "0px" : r.columnGap, t),
3683
- gapY: $(r.rowGap === "normal" ? "0px" : r.rowGap, t),
3684
- border: Fi(r),
3855
+ padding: ia(r, t),
3856
+ margin: Oi(r, a, o, s, t),
3857
+ position: ji(r.position),
3858
+ insets: Mi(r, a, o, s, t),
3859
+ gapX: Q(r.columnGap === "normal" || r.columnGap === "" ? m === "multicol" ? `${i}px` : "0px" : r.columnGap, t),
3860
+ gapY: Q(r.rowGap === "normal" ? "0px" : r.rowGap, t),
3861
+ border: aa(r),
3685
3862
  borderStyle: {
3686
- top: li(r.borderTopStyle),
3687
- right: li(r.borderRightStyle),
3688
- bottom: li(r.borderBottomStyle),
3689
- left: li(r.borderLeftStyle)
3863
+ top: Ni(r.borderTopStyle),
3864
+ right: Ni(r.borderRightStyle),
3865
+ bottom: Ni(r.borderBottomStyle),
3866
+ left: Ni(r.borderLeftStyle)
3690
3867
  },
3691
- overflow: Wr(r),
3692
- scrollbarWidth: Br(e, r),
3693
- scrollbarColor: Vr(r.scrollbarColor),
3868
+ overflow: mi(r),
3869
+ scrollbarWidth: ui(e, r),
3870
+ scrollbarColor: di(r.scrollbarColor),
3694
3871
  overscroll: {
3695
3872
  x: (r.overscrollBehaviorX || "auto") === "auto",
3696
3873
  y: (r.overscrollBehaviorY || "auto") === "auto"
3697
3874
  },
3698
3875
  scrollbarSize: {
3699
- x: Hr(r.getPropertyValue("--mw-scrollbar-size-x")),
3700
- y: Hr(r.getPropertyValue("--mw-scrollbar-size-y"))
3876
+ x: fi(r.getPropertyValue("--mw-scrollbar-size-x")),
3877
+ y: fi(r.getPropertyValue("--mw-scrollbar-size-y"))
3701
3878
  },
3702
3879
  scrollbarInset: {
3703
- x: Hr(r.getPropertyValue("--mw-scrollbar-inset-x"), 0),
3704
- y: Hr(r.getPropertyValue("--mw-scrollbar-inset-y"), 0)
3880
+ x: fi(r.getPropertyValue("--mw-scrollbar-inset-x"), 0),
3881
+ y: fi(r.getPropertyValue("--mw-scrollbar-inset-y"), 0)
3705
3882
  },
3706
3883
  whiteSpace: r.whiteSpace === "pre" ? "pre" : r.whiteSpace === "nowrap" ? "nowrap" : "normal",
3707
3884
  tabSize: Math.max(1, Math.floor(parseFloat(r.tabSize)) || 8),
3708
- lineGap: oi(r.lineHeight, i),
3709
- tracking: ai(r.letterSpacing, i, n?.letterSpacing ?? 0),
3885
+ lineGap: Ai(r.lineHeight, i),
3886
+ tracking: ki(r.letterSpacing, i, n?.letterSpacing ?? 0),
3710
3887
  textOverflow: r.textOverflow === "ellipsis" ? "ellipsis" : "clip",
3711
3888
  color: r.color,
3712
3889
  fontWeight: r.fontWeight,
3713
3890
  fontStyle: r.fontStyle,
3714
3891
  textDecorationLine: r.textDecorationLine,
3715
- backgroundColor: Fr(e, r.backgroundColor, r),
3892
+ backgroundColor: ai(e, r.backgroundColor, r),
3716
3893
  backgroundClear: r.getPropertyValue("--mw-bg-clear").trim() === "1",
3717
3894
  borderColor: {
3718
3895
  top: r.borderTopColor,
@@ -3720,18 +3897,18 @@ function Mr(e, t, n) {
3720
3897
  bottom: r.borderBottomColor,
3721
3898
  left: r.borderLeftColor
3722
3899
  },
3723
- textAlignBlocked: Qr(e, r),
3724
- textAlign: $r(e, r),
3725
- textIndent: fi(r, t),
3726
- opacity: di(r.opacity),
3900
+ textAlignBlocked: Si(e, r),
3901
+ textAlign: Ci(e, r),
3902
+ textIndent: Ii(r, t),
3903
+ opacity: Fi(r.opacity),
3727
3904
  glyphSet: r.getPropertyValue("--mw-border-glyphs").trim() || null,
3728
3905
  zIndex: r.zIndex === "auto" || r.zIndex === "" ? null : Number(r.zIndex) || 0,
3729
3906
  latticeBorder: null,
3730
- ruleX: m === "flex" || m === "grid" || m === "multicol" ? Zr(r, "x") : null,
3731
- ruleY: m === "flex" || m === "grid" ? Zr(r, "y") : null,
3732
- ruleBreak: Xr(r, "--mw-rule-break", ["none", "intersection"], "normal"),
3733
- ruleInset: r.getPropertyValue("--mw-rule-inset").trim() === "overlap-join" ? "overlap-join" : Math.max(0, P(parseFloat(r.getPropertyValue("--mw-rule-inset")) || 0)),
3734
- ruleVisibilityItems: Xr(r, "--mw-rule-visibility-items", [
3907
+ ruleX: m === "flex" || m === "grid" || m === "multicol" ? xi(r, "x") : null,
3908
+ ruleY: m === "flex" || m === "grid" ? xi(r, "y") : null,
3909
+ ruleBreak: bi(r, "--mw-rule-break", ["none", "intersection"], "normal"),
3910
+ ruleInset: r.getPropertyValue("--mw-rule-inset").trim() === "overlap-join" ? "overlap-join" : Math.max(0, N(parseFloat(r.getPropertyValue("--mw-rule-inset")) || 0)),
3911
+ ruleVisibilityItems: bi(r, "--mw-rule-visibility-items", [
3735
3912
  "all",
3736
3913
  "around",
3737
3914
  "between"
@@ -3744,9 +3921,9 @@ function Mr(e, t, n) {
3744
3921
  breakAfterColumn: r.breakAfter === "column",
3745
3922
  breakInsideAvoid: r.breakInside === "avoid" || r.breakInside === "avoid-column"
3746
3923
  };
3747
- return Nr(T, r), T;
3924
+ return ri(T, r), T;
3748
3925
  }
3749
- function Nr(e, t) {
3926
+ function ri(e, t) {
3750
3927
  t.borderCollapse === "collapse" && (e.display === "table" || e.tableRole === "cell" || e.tableRole === "row" || e.tableRole === "row-group" || e.tableRole === "header-group" || e.tableRole === "footer-group") && (e.latticeBorder = {
3751
3928
  width: e.border,
3752
3929
  style: e.borderStyle,
@@ -3757,37 +3934,37 @@ function Nr(e, t) {
3757
3934
  bottom: t.borderBottomStyle === "hidden",
3758
3935
  left: t.borderLeftStyle === "hidden"
3759
3936
  }
3760
- }, e.border = ot(), e.display === "table" && (e.padding = ot()));
3937
+ }, e.border = R(), e.display === "table" && (e.padding = R()));
3761
3938
  }
3762
- function Pr(e) {
3939
+ function ii(e) {
3763
3940
  if (!e) return !0;
3764
3941
  let t = e.trim().toLowerCase();
3765
3942
  return t === "" || t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "currentcolor";
3766
3943
  }
3767
- function Fr(e, t, n) {
3768
- let i = r(e, Pr(t) ? "" : t, n);
3944
+ function ai(e, t, n) {
3945
+ let i = r(e, ii(t) ? "" : t, n);
3769
3946
  return i === "" ? void 0 : i;
3770
3947
  }
3771
- function Ir(e) {
3948
+ function oi(e) {
3772
3949
  return e === "hidden" || e === "clip";
3773
3950
  }
3774
- var Lr = /* @__PURE__ */ new WeakMap(), Rr = null;
3775
- function zr(e) {
3776
- if (Rr !== null) return Rr;
3951
+ var si = /* @__PURE__ */ new WeakMap(), ci = null;
3952
+ function li(e) {
3953
+ if (ci !== null) return ci;
3777
3954
  if (!e.body) return !0;
3778
3955
  let t = e.createElement("div");
3779
- return t.style.cssText = "position: absolute; width: 0; height: 0; overflow: auto", e.body.appendChild(t), Rr = getComputedStyle(t).scrollbarWidth !== "none", t.remove(), Rr;
3956
+ return t.style.cssText = "position: absolute; width: 0; height: 0; overflow: auto", e.body.appendChild(t), ci = getComputedStyle(t).scrollbarWidth !== "none", t.remove(), ci;
3780
3957
  }
3781
- function Br(e, t) {
3782
- if (!zr(e.ownerDocument)) return "auto";
3958
+ function ui(e, t) {
3959
+ if (!li(e.ownerDocument)) return "auto";
3783
3960
  if (e.hasAttribute("data-mw-scroll")) {
3784
- let t = Lr.get(e);
3961
+ let t = si.get(e);
3785
3962
  if (t !== void 0) return t;
3786
3963
  }
3787
3964
  let n = t.scrollbarWidth === "none" ? "none" : "auto";
3788
- return Lr.set(e, n), n;
3965
+ return si.set(e, n), n;
3789
3966
  }
3790
- function Vr(e) {
3967
+ function di(e) {
3791
3968
  let t = (e ?? "").trim();
3792
3969
  if (!t || t === "auto") return null;
3793
3970
  let n = 0;
@@ -3802,25 +3979,25 @@ function Vr(e) {
3802
3979
  }
3803
3980
  return null;
3804
3981
  }
3805
- function Hr(e, t = 1) {
3982
+ function fi(e, t = 1) {
3806
3983
  return Math.max(t, Math.floor(Number(e) || t));
3807
3984
  }
3808
- function Ur(e) {
3809
- return Ir(e) ? "clip" : e === "auto" || e === "scroll" ? e : "visible";
3985
+ function pi(e) {
3986
+ return oi(e) ? "clip" : e === "auto" || e === "scroll" ? e : "visible";
3810
3987
  }
3811
- function Wr(e) {
3812
- let t = Ur(e.overflowX || e.overflow), n = Ur(e.overflowY || e.overflow);
3988
+ function mi(e) {
3989
+ let t = pi(e.overflowX || e.overflow), n = pi(e.overflowY || e.overflow);
3813
3990
  return t !== "visible" && n === "visible" && (n = "auto"), n !== "visible" && t === "visible" && (t = "auto"), {
3814
3991
  x: t,
3815
3992
  y: n
3816
3993
  };
3817
3994
  }
3818
- function Gr(e, t) {
3995
+ function hi(e, t) {
3819
3996
  if (t.position !== "absolute" && t.position !== "fixed") return !1;
3820
3997
  let n = t.clip.replace(/\s/g, "");
3821
- return n === "rect(0px,0px,0px,0px)" || n === "rect(0,0,0,0)" || !ae(e.tagName) && (Ir(t.overflow) || Ir(t.overflowX)) && parseFloat(t.width) <= 1 && parseFloat(t.height) <= 1;
3998
+ return n === "rect(0px,0px,0px,0px)" || n === "rect(0,0,0,0)" || !oe(e.tagName) && (oi(t.overflow) || oi(t.overflowX)) && parseFloat(t.width) <= 1 && parseFloat(t.height) <= 1;
3822
3999
  }
3823
- var Kr = {
4000
+ var gi = {
3824
4001
  TABLE: "table",
3825
4002
  THEAD: "table-header-group",
3826
4003
  TBODY: "table-row-group",
@@ -3831,7 +4008,7 @@ var Kr = {
3831
4008
  CAPTION: "table-caption",
3832
4009
  COL: "table-column",
3833
4010
  COLGROUP: "table-column-group"
3834
- }, qr = {
4011
+ }, _i = {
3835
4012
  "table-header-group": "header-group",
3836
4013
  "table-row-group": "row-group",
3837
4014
  "table-footer-group": "footer-group",
@@ -3841,38 +4018,38 @@ var Kr = {
3841
4018
  "table-column": "column",
3842
4019
  "table-column-group": "column-group"
3843
4020
  };
3844
- function Jr(e, t) {
4021
+ function vi(e, t) {
3845
4022
  let n = t.verticalAlign || e.getAttribute("valign")?.toLowerCase() || (e.tagName === "TD" || e.tagName === "TH" ? "middle" : "baseline");
3846
4023
  return n === "top" ? "start" : n === "middle" ? "center" : n === "bottom" ? "end" : "start";
3847
4024
  }
3848
- function Yr(e, t, n) {
3849
- (/(?:^|[\s:.[!])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w-])/.test(t) || /(?:^|[\s:.[!])text-\[(?:(?:length|size):|[\d.])/.test(t) || n.fontSize !== "") && N(e, "font-size inside <mono-wind> is ignored — all text shares the host's cell size. Size the <mono-wind> element itself instead.");
4025
+ function yi(e, t, n) {
4026
+ (/(?:^|[\s:.[!])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w-])/.test(t) || /(?:^|[\s:.[!])text-\[(?:(?:length|size):|[\d.])/.test(t) || n.fontSize !== "") && M(e, "font-size inside <mono-wind> is ignored — all text shares the host's cell size. Size the <mono-wind> element itself instead.");
3850
4027
  }
3851
- function Xr(e, t, n, r) {
4028
+ function bi(e, t, n, r) {
3852
4029
  let i = e.getPropertyValue(t).trim();
3853
4030
  return n.includes(i) ? i : r;
3854
4031
  }
3855
- function Zr(e, t) {
3856
- let n = P(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
4032
+ function xi(e, t) {
4033
+ let n = N(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
3857
4034
  if (n <= 0) return null;
3858
4035
  let r = e.getPropertyValue(`--mw-rule-${t}-color`).trim();
3859
4036
  return {
3860
4037
  width: n,
3861
- style: li(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
4038
+ style: Ni(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3862
4039
  color: r && r !== "currentcolor" && r !== "currentColor" ? r : e.color
3863
4040
  };
3864
4041
  }
3865
- function Qr(e, t) {
4042
+ function Si(e, t) {
3866
4043
  return t.textAlign === "justify" || e.getAttribute("align")?.toLowerCase() === "justify";
3867
4044
  }
3868
- function $r(e, t) {
4045
+ function Ci(e, t) {
3869
4046
  let n = t.textAlign || e.getAttribute("align")?.toLowerCase() || "";
3870
4047
  return n === "right" || n === "end" ? "end" : n === "center" || n.endsWith("-center") ? "center" : "start";
3871
4048
  }
3872
- function ei(e) {
4049
+ function wi(e) {
3873
4050
  return typeof e.computedStyleMap == "function";
3874
4051
  }
3875
- function ti(e) {
4052
+ function Ti(e) {
3876
4053
  switch (e) {
3877
4054
  case "center": return "center";
3878
4055
  case "flex-end":
@@ -3887,7 +4064,7 @@ function ti(e) {
3887
4064
  default: return "start";
3888
4065
  }
3889
4066
  }
3890
- function ni(e) {
4067
+ function Ei(e) {
3891
4068
  switch (e) {
3892
4069
  case "center": return "center";
3893
4070
  case "flex-end":
@@ -3898,10 +4075,10 @@ function ni(e) {
3898
4075
  default: return "start";
3899
4076
  }
3900
4077
  }
3901
- function ri(e) {
3902
- return e === "auto" || e === "" || e === "normal" ? "auto" : ni(e);
4078
+ function Di(e) {
4079
+ return e === "auto" || e === "" || e === "normal" ? "auto" : Ei(e);
3903
4080
  }
3904
- function ii(e, t, n, r, i) {
4081
+ function Oi(e, t, n, r, i) {
3905
4082
  let a = (a, o, s) => {
3906
4083
  if (t) {
3907
4084
  let e = t.get(a)?.toString().trim();
@@ -3913,10 +4090,10 @@ function ii(e, t, n, r, i) {
3913
4090
  } else if (s.test(n) || r.getPropertyValue(a) === "auto") return null;
3914
4091
  let c = e.getPropertyValue(a);
3915
4092
  if (c === "auto") return null;
3916
- let l = $(c, i);
4093
+ let l = Q(c, i);
3917
4094
  if (l !== 0) return l;
3918
4095
  let u = e.getPropertyValue(o);
3919
- return u === "auto" ? null : $(u, i);
4096
+ return u === "auto" ? null : Q(u, i);
3920
4097
  };
3921
4098
  return {
3922
4099
  top: a("margin-top", "margin-block-start", /(?:^|[\s:.[!])(?:m|my|mt)-auto\b/),
@@ -3925,16 +4102,16 @@ function ii(e, t, n, r, i) {
3925
4102
  left: a("margin-left", "margin-inline-start", /(?:^|[\s:.[!])(?:m|mx|ml|ms)-auto\b/)
3926
4103
  };
3927
4104
  }
3928
- function ai(e, t, n) {
4105
+ function ki(e, t, n) {
3929
4106
  let r = (e === "normal" ? 0 : parseFloat(e) || 0) - n;
3930
4107
  return r <= 0 ? 0 : Math.floor(r / (.025 * t) + 1e-6);
3931
4108
  }
3932
- function oi(e, t) {
4109
+ function Ai(e, t) {
3933
4110
  if (!e || e === "normal" || t <= 0) return 0;
3934
4111
  let n = parseFloat(e);
3935
4112
  return Number.isFinite(n) ? Math.max(0, Math.floor(n / t + 1e-6) - 1) : 0;
3936
4113
  }
3937
- function si(e) {
4114
+ function ji(e) {
3938
4115
  switch (e) {
3939
4116
  case "relative":
3940
4117
  case "absolute":
@@ -3943,17 +4120,17 @@ function si(e) {
3943
4120
  default: return "static";
3944
4121
  }
3945
4122
  }
3946
- function ci(e, t, n, r, i) {
4123
+ function Mi(e, t, n, r, i) {
3947
4124
  let a = (a, o) => {
3948
4125
  if (t) {
3949
4126
  let e = t.get(a)?.toString().trim();
3950
- return !e || e === "auto" ? null : $(e, i);
4127
+ return !e || e === "auto" ? null : Q(e, i);
3951
4128
  }
3952
4129
  let s = r[a];
3953
- if (s) return s === "auto" ? null : $(s, i);
4130
+ if (s) return s === "auto" ? null : Q(s, i);
3954
4131
  if (!o.test(n)) return null;
3955
4132
  let c = e.getPropertyValue(a);
3956
- return !c || c === "auto" ? null : $(c, i);
4133
+ return !c || c === "auto" ? null : Q(c, i);
3957
4134
  };
3958
4135
  return {
3959
4136
  top: a("top", /(?:^|[\s:.[!])-?(?:top|inset|inset-y)-/),
@@ -3962,7 +4139,7 @@ function ci(e, t, n, r, i) {
3962
4139
  left: a("left", /(?:^|[\s:.[!])-?(?:left|start|inset|inset-x)-/)
3963
4140
  };
3964
4141
  }
3965
- function li(e) {
4142
+ function Ni(e) {
3966
4143
  switch (e) {
3967
4144
  case "double": return "double";
3968
4145
  case "dashed": return "dashed";
@@ -3970,7 +4147,7 @@ function li(e) {
3970
4147
  default: return "solid";
3971
4148
  }
3972
4149
  }
3973
- function ui(e, t) {
4150
+ function Pi(e, t) {
3974
4151
  if (!e || e === "none" || e === "auto") return;
3975
4152
  if (e === "min-content" || e === "max-content" || e === "fit-content") return e;
3976
4153
  if (e.endsWith("%")) {
@@ -3978,44 +4155,44 @@ function ui(e, t) {
3978
4155
  return Number.isFinite(t) ? { percent: t } : void 0;
3979
4156
  }
3980
4157
  let n = parseFloat(e);
3981
- return Number.isFinite(n) ? F(n, t) : void 0;
4158
+ return Number.isFinite(n) ? P(n, t) : void 0;
3982
4159
  }
3983
- function $(e, t) {
4160
+ function Q(e, t) {
3984
4161
  if (!e || e === "auto" || e === "none") return 0;
3985
4162
  if (e.endsWith("%")) {
3986
4163
  let t = parseFloat(e);
3987
4164
  return Number.isFinite(t) && t !== 0 ? { percent: t } : 0;
3988
4165
  }
3989
4166
  let n = parseFloat(e);
3990
- return Number.isFinite(n) ? F(n, t) : 0;
4167
+ return Number.isFinite(n) ? P(n, t) : 0;
3991
4168
  }
3992
- function di(e) {
4169
+ function Fi(e) {
3993
4170
  let t = parseFloat(e);
3994
4171
  return Number.isFinite(t) ? Math.min(1, Math.max(0, t)) : 1;
3995
4172
  }
3996
- function fi(e, t) {
4173
+ function Ii(e, t) {
3997
4174
  let n = e.textIndent;
3998
4175
  if (!n || n.endsWith("%")) return 0;
3999
4176
  let r = parseFloat(n);
4000
- return Number.isFinite(r) ? Math.max(0, F(r, t)) : 0;
4177
+ return Number.isFinite(r) ? Math.max(0, P(r, t)) : 0;
4001
4178
  }
4002
- function pi(e, t, n, r, i, a, o) {
4003
- let s = mi(n === "width" ? a.width : a.height);
4179
+ function Li(e, t, n, r, i, a, o) {
4180
+ let s = Ri(n === "width" ? a.width : a.height);
4004
4181
  if (s !== null) return {
4005
4182
  kind: "cells",
4006
- value: gi(s, n, o, r)
4183
+ value: Bi(s, n, o, r)
4007
4184
  };
4008
- let c = _i(e, n, t, i, n === "width" ? "w" : "h", a, o, r);
4185
+ let c = Vi(e, n, t, i, n === "width" ? "w" : "h", a, o, r);
4009
4186
  if (c !== void 0) return {
4010
4187
  kind: "cells",
4011
4188
  value: c
4012
4189
  };
4013
- let l = hi(i, n === "width" ? "w" : "h");
4190
+ let l = zi(i, n === "width" ? "w" : "h");
4014
4191
  if (l !== null) {
4015
4192
  let i = parseFloat(e ? String(e.get(n) ?? "") : t), a = Number.isFinite(i) && Math.abs(i - l) <= l * .3;
4016
4193
  if (a || !Number.isFinite(i)) return {
4017
4194
  kind: "cells",
4018
- value: gi(a ? i : l, n, o, r)
4195
+ value: Bi(a ? i : l, n, o, r)
4019
4196
  };
4020
4197
  }
4021
4198
  if (e) {
@@ -4023,7 +4200,7 @@ function pi(e, t, n, r, i, a, o) {
4023
4200
  if (t == null) return;
4024
4201
  let i = t.toString().trim();
4025
4202
  if (i === "auto") return { kind: "auto" };
4026
- let a = xi(i);
4203
+ let a = Gi(i);
4027
4204
  if (a) return a;
4028
4205
  if (i.endsWith("%")) return {
4029
4206
  kind: "percent",
@@ -4031,22 +4208,22 @@ function pi(e, t, n, r, i, a, o) {
4031
4208
  };
4032
4209
  if (i.endsWith("px")) return {
4033
4210
  kind: "cells",
4034
- value: F(parseFloat(i), r)
4211
+ value: P(parseFloat(i), r)
4035
4212
  };
4036
4213
  if (i.endsWith("rem")) return {
4037
4214
  kind: "cells",
4038
- value: P(parseFloat(i) / .25)
4215
+ value: N(parseFloat(i) / .25)
4039
4216
  };
4040
- let s = mi(i);
4217
+ let s = Ri(i);
4041
4218
  if (s !== null) return {
4042
4219
  kind: "cells",
4043
- value: gi(s, n, o, r)
4220
+ value: Bi(s, n, o, r)
4044
4221
  };
4045
4222
  }
4046
4223
  let u = n === "width" ? a.width : a.height;
4047
4224
  if (u) {
4048
4225
  if (u === "auto") return { kind: "auto" };
4049
- let e = xi(u);
4226
+ let e = Gi(u);
4050
4227
  if (e) return e;
4051
4228
  if (u.endsWith("%")) return {
4052
4229
  kind: "percent",
@@ -4055,7 +4232,7 @@ function pi(e, t, n, r, i, a, o) {
4055
4232
  let t = parseFloat(u);
4056
4233
  if (Number.isFinite(t)) return {
4057
4234
  kind: "cells",
4058
- value: F(t, r)
4235
+ value: P(t, r)
4059
4236
  };
4060
4237
  }
4061
4238
  let d = n === "width" ? "w" : "h";
@@ -4079,9 +4256,9 @@ function pi(e, t, n, r, i, a, o) {
4079
4256
  let m = RegExp(`(?:^|[\\s:.[!])${d}-(\\d+(?:\\.\\d+)?)(?![\\w-/])`).exec(i);
4080
4257
  if (m) return {
4081
4258
  kind: "cells",
4082
- value: P(Number(m[1]))
4259
+ value: N(Number(m[1]))
4083
4260
  };
4084
- if (!Ni(i, d) || t === "auto") return { kind: "auto" };
4261
+ if (!ra(i, d) || t === "auto") return { kind: "auto" };
4085
4262
  if (t.endsWith("%")) return {
4086
4263
  kind: "percent",
4087
4264
  value: parseFloat(t)
@@ -4089,10 +4266,10 @@ function pi(e, t, n, r, i, a, o) {
4089
4266
  let h = parseFloat(t);
4090
4267
  if (Number.isFinite(h)) return {
4091
4268
  kind: "cells",
4092
- value: F(h, r)
4269
+ value: P(h, r)
4093
4270
  };
4094
4271
  }
4095
- function mi(e) {
4272
+ function Ri(e) {
4096
4273
  let t = /^(-?[\d.]+)((?:[dsl]?v)(?:h|w|min|max)|vi|vb)$/.exec(e.trim());
4097
4274
  if (!t || typeof window > "u") return null;
4098
4275
  let n = parseFloat(t[1]);
@@ -4100,7 +4277,7 @@ function mi(e) {
4100
4277
  let r = t[2], i = window.innerHeight, a = window.innerWidth, o = r.endsWith("h") ? i : r.endsWith("min") ? Math.min(a, i) : r.endsWith("max") ? Math.max(a, i) : r === "vb" ? i : a;
4101
4278
  return n / 100 * o;
4102
4279
  }
4103
- function hi(e, t) {
4280
+ function zi(e, t) {
4104
4281
  if (typeof window > "u") return null;
4105
4282
  let n = RegExp(`(?:^|[\\s:.[!])${t}-(screen|[dsl]v[hw])(?![\\w-])`).exec(e);
4106
4283
  if (n) {
@@ -4108,25 +4285,25 @@ function hi(e, t) {
4108
4285
  return e === "screen" ? t.includes("h") ? window.innerHeight : window.innerWidth : e.endsWith("h") ? window.innerHeight : window.innerWidth;
4109
4286
  }
4110
4287
  let r = RegExp(`(?:^|[\\s:.[!])${t}-\\[(-?[\\d.]+(?:[dsl]?v(?:h|w|min|max)|vi|vb))\\]`).exec(e);
4111
- return r ? mi(r[1]) : null;
4288
+ return r ? Ri(r[1]) : null;
4112
4289
  }
4113
- function gi(e, t, n, r) {
4290
+ function Bi(e, t, n, r) {
4114
4291
  let i = t === "width" ? n?.width : n?.height;
4115
- return i && i > 0 ? Math.max(0, Math.floor(e / i)) : F(e, r);
4292
+ return i && i > 0 ? Math.max(0, Math.floor(e / i)) : P(e, r);
4116
4293
  }
4117
- function _i(e, t, n, r, i, a, o, s) {
4294
+ function Vi(e, t, n, r, i, a, o, s) {
4118
4295
  let c = t.endsWith("width") ? "width" : "height", l = a.getPropertyValue(t).trim(), u = l.startsWith("calc(");
4119
4296
  if (!u && !r.includes("-[calc(")) return;
4120
4297
  let d = RegExp(`(?:^|[\\s:.[!])${i}-\\[(calc\\([^\\]]*\\))\\]`).exec(r), f = u ? l : d?.[1]?.replaceAll("_", " ");
4121
4298
  if (!f) return;
4122
- let p = vi(f, c, o, s);
4299
+ let p = Hi(f, c, o, s);
4123
4300
  if (!p || p.unitless) return;
4124
- let m = Math.max(0, P(p.cells));
4301
+ let m = Math.max(0, N(p.cells));
4125
4302
  if (u) return m;
4126
4303
  let h = (e ? String(e.get(t) ?? "") : n).trim(), g = parseFloat(h);
4127
4304
  return (Number.isFinite(g) ? Math.abs(g - p.px) <= Math.abs(p.px) * .3 : h === "") ? m : void 0;
4128
4305
  }
4129
- function vi(e, t, n, r) {
4306
+ function Hi(e, t, n, r) {
4130
4307
  let i = e.match(/--spacing\(\s*-?[\d.]+\s*\)|calc|[\d.]+[a-z%]*|[()+\-*/]/g);
4131
4308
  if (!i || i.join("").replace(/\s+/g, "") !== e.replace(/\s+/g, "")) return null;
4132
4309
  let a = 0, o = () => i[a], s = () => i[a++], c = (e, t) => ({
@@ -4150,8 +4327,8 @@ function vi(e, t, n, r) {
4150
4327
  };
4151
4328
  if (s === "px") return c(o / (r / 4), o);
4152
4329
  if (s === "rem") return c(o * 4, o * r);
4153
- let l = mi(e);
4154
- return l === null ? null : c(gi(l, t, n, r), l);
4330
+ let l = Ri(e);
4331
+ return l === null ? null : c(Bi(l, t, n, r), l);
4155
4332
  }, u = (e, t, n) => {
4156
4333
  if (e === "+" || e === "-") {
4157
4334
  if (t.unitless !== n.unitless) return null;
@@ -4208,17 +4385,17 @@ function vi(e, t, n, r) {
4208
4385
  }, h = m();
4209
4386
  return a === i.length ? h : null;
4210
4387
  }
4211
- function yi(e, t, n, r, i, a, o, s) {
4212
- let c = t.endsWith("width") ? "width" : "height", l = mi(a.getPropertyValue(t)) ?? mi(e?.get(t)?.toString().trim() ?? "");
4213
- if (l !== null) return gi(l, c, o, s);
4214
- let u = hi(r, i);
4388
+ function Ui(e, t, n, r, i, a, o, s) {
4389
+ let c = t.endsWith("width") ? "width" : "height", l = Ri(a.getPropertyValue(t)) ?? Ri(e?.get(t)?.toString().trim() ?? "");
4390
+ if (l !== null) return Bi(l, c, o, s);
4391
+ let u = zi(r, i);
4215
4392
  if (u === null) return;
4216
4393
  let d = (e ? String(e.get(t) ?? "") : n).trim(), f = parseFloat(d), p = Number.isFinite(f) && Math.abs(f - u) <= u * .3;
4217
- if (p || d === "") return gi(p ? f : u, c, o, s);
4394
+ if (p || d === "") return Bi(p ? f : u, c, o, s);
4218
4395
  }
4219
- function bi(e, t) {
4396
+ function Wi(e, t) {
4220
4397
  if (!e || e === "auto" || e === "content") return;
4221
- let n = xi(e);
4398
+ let n = Gi(e);
4222
4399
  if (n) return n;
4223
4400
  if (e.endsWith("%")) {
4224
4401
  let t = parseFloat(e);
@@ -4230,30 +4407,30 @@ function bi(e, t) {
4230
4407
  let r = parseFloat(e);
4231
4408
  return Number.isFinite(r) ? {
4232
4409
  kind: "cells",
4233
- value: F(r, t)
4410
+ value: P(r, t)
4234
4411
  } : void 0;
4235
4412
  }
4236
- function xi(e) {
4413
+ function Gi(e) {
4237
4414
  if (e === "min-content") return { kind: "min-content" };
4238
4415
  if (e === "max-content") return { kind: "max-content" };
4239
4416
  if (e === "fit-content") return { kind: "fit-content" };
4240
4417
  }
4241
- function Si(e, t) {
4418
+ function Ki(e, t) {
4242
4419
  let n = e.trim();
4243
4420
  if (!n || n === "none") return { kind: "none" };
4244
4421
  if (n === "subgrid" || n.startsWith("subgrid ")) return { kind: "subgrid" };
4245
4422
  let r = [], i = [], a = [], o = (e) => {
4246
4423
  i.push(a), a = [], r.push(e);
4247
4424
  }, s;
4248
- for (let e of Ai(n)) {
4249
- let n = wi(e);
4425
+ for (let e of ea(n)) {
4426
+ let n = Ji(e);
4250
4427
  if (n) {
4251
4428
  a.push(...n);
4252
4429
  continue;
4253
4430
  }
4254
4431
  let i = e.match(/^repeat\(\s*([^,]+?)\s*,(.*)\)$/s);
4255
4432
  if (i) {
4256
- let e = Ci(i[2].trim(), t);
4433
+ let e = qi(i[2].trim(), t);
4257
4434
  if (e.tracks.length === 0) continue;
4258
4435
  let n = i[1];
4259
4436
  if (n === "auto-fill" || n === "auto-fit") {
@@ -4271,7 +4448,7 @@ function Si(e, t) {
4271
4448
  }
4272
4449
  continue;
4273
4450
  }
4274
- o(Di(e, t));
4451
+ o(Zi(e, t));
4275
4452
  }
4276
4453
  if (i.push(a), r.length === 0 && !s) return { kind: "none" };
4277
4454
  let c = {
@@ -4280,26 +4457,26 @@ function Si(e, t) {
4280
4457
  };
4281
4458
  return i.some((e) => e.length > 0) && (c.lineNames = i), s && (c.autoRepeat = s), c;
4282
4459
  }
4283
- function Ci(e, t) {
4460
+ function qi(e, t) {
4284
4461
  let n = [], r = [], i = [];
4285
- for (let a of Ai(e)) {
4286
- let e = wi(a);
4462
+ for (let a of ea(e)) {
4463
+ let e = Ji(a);
4287
4464
  if (e) {
4288
4465
  i.push(...e);
4289
4466
  continue;
4290
4467
  }
4291
- r.push(i), i = [], n.push(Di(a, t));
4468
+ r.push(i), i = [], n.push(Zi(a, t));
4292
4469
  }
4293
4470
  return r.push(i), {
4294
4471
  tracks: n,
4295
4472
  lineNames: r
4296
4473
  };
4297
4474
  }
4298
- function wi(e) {
4475
+ function Ji(e) {
4299
4476
  let t = e.match(/^\[(.*)\]$/s);
4300
4477
  return t ? t[1].split(/\s+/).filter((e) => e !== "") : null;
4301
4478
  }
4302
- function Ti(e) {
4479
+ function Yi(e) {
4303
4480
  let t = [];
4304
4481
  for (let n of e.matchAll(/"([^"]*)"|'([^']*)'/g)) {
4305
4482
  let e = (n[1] ?? n[2] ?? "").trim().split(/\s+/).filter((e) => e !== "");
@@ -4329,23 +4506,23 @@ function Ti(e) {
4329
4506
  areas: r
4330
4507
  };
4331
4508
  }
4332
- function Ei(e, t) {
4333
- let n = Ai(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => Di(e, t));
4334
- return n.length > 0 ? n : [st()];
4509
+ function Xi(e, t) {
4510
+ let n = ea(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => Zi(e, t));
4511
+ return n.length > 0 ? n : [ot()];
4335
4512
  }
4336
- function Di(e, t) {
4513
+ function Zi(e, t) {
4337
4514
  let n = e.match(/^minmax\((.*)\)$/s);
4338
4515
  if (n) {
4339
- let e = ki(n[1]).map((e) => e.trim());
4516
+ let e = $i(n[1]).map((e) => e.trim());
4340
4517
  return e.length === 2 ? {
4341
- min: Oi(e[0], t),
4342
- max: Oi(e[1], t)
4518
+ min: Qi(e[0], t),
4519
+ max: Qi(e[1], t)
4343
4520
  } : {
4344
4521
  min: { kind: "auto" },
4345
4522
  max: { kind: "auto" }
4346
4523
  };
4347
4524
  }
4348
- let r = Oi(e, t);
4525
+ let r = Qi(e, t);
4349
4526
  return r.kind === "fr" ? {
4350
4527
  min: { kind: "auto" },
4351
4528
  max: r
@@ -4354,13 +4531,13 @@ function Di(e, t) {
4354
4531
  max: r
4355
4532
  };
4356
4533
  }
4357
- function Oi(e, t) {
4534
+ function Qi(e, t) {
4358
4535
  if (e === "auto" || e.startsWith("fit-content")) return { kind: "auto" };
4359
4536
  if (e === "min-content") return { kind: "min-content" };
4360
4537
  if (e === "max-content") return { kind: "max-content" };
4361
4538
  let n = e.match(/^(min|max)\((.*)\)$/s);
4362
4539
  if (n) {
4363
- let e = ki(n[2]).map((e) => Oi(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
4540
+ let e = $i(n[2]).map((e) => Qi(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
4364
4541
  return e.length > 0 && r ? {
4365
4542
  kind: "math",
4366
4543
  fn: n[1],
@@ -4384,10 +4561,10 @@ function Oi(e, t) {
4384
4561
  let r = parseFloat(e);
4385
4562
  return Number.isFinite(r) ? {
4386
4563
  kind: "cells",
4387
- value: e.endsWith("rem") ? P(r / .25) : F(r, t)
4564
+ value: e.endsWith("rem") ? N(r / .25) : P(r, t)
4388
4565
  } : { kind: "auto" };
4389
4566
  }
4390
- function ki(e) {
4567
+ function $i(e) {
4391
4568
  let t = [], n = 0, r = 0;
4392
4569
  for (let i = 0; i < e.length; i++) {
4393
4570
  let a = e[i];
@@ -4395,7 +4572,7 @@ function ki(e) {
4395
4572
  }
4396
4573
  return t.push(e.slice(r)), t.filter((e) => e.trim() !== "");
4397
4574
  }
4398
- function Ai(e) {
4575
+ function ea(e) {
4399
4576
  let t = [], n = 0, r = -1;
4400
4577
  for (let i = 0; i < e.length; i++) {
4401
4578
  let a = e[i];
@@ -4403,7 +4580,7 @@ function Ai(e) {
4403
4580
  }
4404
4581
  return r !== -1 && t.push(e.slice(r)), t;
4405
4582
  }
4406
- function ji(e) {
4583
+ function ta(e) {
4407
4584
  let t = e.trim();
4408
4585
  if (!t || t === "auto") return { kind: "auto" };
4409
4586
  let n = !1, r, i;
@@ -4431,25 +4608,25 @@ function ji(e) {
4431
4608
  nth: r
4432
4609
  };
4433
4610
  }
4434
- function Mi(e) {
4611
+ function na(e) {
4435
4612
  return {
4436
4613
  direction: e.includes("column") ? "column" : "row",
4437
4614
  dense: e.includes("dense")
4438
4615
  };
4439
4616
  }
4440
- function Ni(e, t) {
4617
+ function ra(e, t) {
4441
4618
  return (t === "w" ? /(?:^|[\s:.[!])w-/ : /(?:^|[\s:.[!])h-/).test(e);
4442
4619
  }
4443
- function Pi(e, t) {
4620
+ function ia(e, t) {
4444
4621
  return {
4445
- top: $(e.getPropertyValue("padding-top"), t),
4446
- right: $(e.getPropertyValue("padding-right"), t),
4447
- bottom: $(e.getPropertyValue("padding-bottom"), t),
4448
- left: $(e.getPropertyValue("padding-left"), t)
4622
+ top: Q(e.getPropertyValue("padding-top"), t),
4623
+ right: Q(e.getPropertyValue("padding-right"), t),
4624
+ bottom: Q(e.getPropertyValue("padding-bottom"), t),
4625
+ left: Q(e.getPropertyValue("padding-left"), t)
4449
4626
  };
4450
4627
  }
4451
- function Fi(e) {
4452
- let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : P(parseFloat(e.getPropertyValue(t)) || 0);
4628
+ function aa(e) {
4629
+ let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : N(parseFloat(e.getPropertyValue(t)) || 0);
4453
4630
  return {
4454
4631
  top: t("border-top-width", "border-top-style"),
4455
4632
  right: t("border-right-width", "border-right-style"),
@@ -4459,14 +4636,14 @@ function Fi(e) {
4459
4636
  }
4460
4637
  //#endregion
4461
4638
  //#region src/tree.ts
4462
- function Ii(e, t, n, r) {
4463
- let i = Mr(e, t, n);
4639
+ function oa(e, t, n, r) {
4640
+ let i = ni(e, t, n);
4464
4641
  if (i.display === "none") return null;
4465
- let a = ae(e.tagName);
4466
- if (a) return Li(e, i, a);
4467
- let o = Array.from(e.children), s = o.map(Hi), c = e.tagName, l = $i(c);
4642
+ let a = oe(e.tagName);
4643
+ if (a) return sa(e, i, a);
4644
+ let o = Array.from(e.children), s = o.map(fa), c = e.tagName, l = wa(c);
4468
4645
  if (!s.includes("block") || l) {
4469
- let a = Ui(e, i.tracking, {
4646
+ let a = pa(e, i.tracking, {
4470
4647
  rootFontSizePx: t,
4471
4648
  rootLetterSpacingPx: n?.letterSpacing ?? 0,
4472
4649
  cellMetrics: n,
@@ -4475,12 +4652,12 @@ function Ii(e, t, n, r) {
4475
4652
  tabSize: i.tabSize
4476
4653
  }), u = a.chars.join("");
4477
4654
  if (a.boxes.length > 0) {
4478
- let e = Rn();
4479
- Fe(a.chars, (t, n) => {
4480
- a.advances[t] = Math.max(1, q(a.boxes[n], e));
4655
+ let e = Ln();
4656
+ Pe(a.chars, (t, n) => {
4657
+ a.advances[t] = Math.max(1, K(a.boxes[n], e));
4481
4658
  });
4482
4659
  }
4483
- let d = Ji(u, a.advances, i.tracking);
4660
+ let d = ya(u, a.advances, i.tracking);
4484
4661
  if (l && d === 0) {
4485
4662
  if (c === "INPUT") d = Number(e.size) || 20;
4486
4663
  else if (c === "TEXTAREA") d = Number(e.cols) || 20;
@@ -4489,9 +4666,9 @@ function Ii(e, t, n, r) {
4489
4666
  d = Math.max(1, ...r.map((e) => e.trim().length));
4490
4667
  }
4491
4668
  }
4492
- let f = u.length > 0 ? Yi(u) : 0, p;
4669
+ let f = u.length > 0 ? ba(u) : 0, p;
4493
4670
  if (c === "TEXTAREA") {
4494
- let t = e, n = t.value ?? "", a = r?.get(t), o = +!!n.endsWith("\n"), s = a !== void 0 && a > 0 ? Oe(n, a) + o : n === "" ? 0 : n.split(/\r\n?|\n/).length, c = getComputedStyle(e).getPropertyValue("field-sizing") === "content" ? 1 : Number(t.rows) || 2, l = Math.max(c, s);
4671
+ let t = e, n = t.value ?? "", a = r?.get(t), o = +!!n.endsWith("\n"), s = a !== void 0 && a > 0 ? De(n, a) + o : n === "" ? 0 : n.split(/\r\n?|\n/).length, c = getComputedStyle(e).getPropertyValue("field-sizing") === "content" ? 1 : Number(t.rows) || 2, l = Math.max(c, s);
4495
4672
  p = l + Math.max(0, l - 1) * i.lineGap;
4496
4673
  } else p = l ? Math.max(1, f) : f;
4497
4674
  let m = /* @__PURE__ */ new Map(), h = [];
@@ -4501,11 +4678,11 @@ function Ii(e, t, n, r) {
4501
4678
  let i = o[e], a = m.get(i);
4502
4679
  if (a) g.push(a);
4503
4680
  else if (s[e] === "out-of-flow") {
4504
- let e = Ii(i, t, n, r);
4681
+ let e = oa(i, t, n, r);
4505
4682
  e && g.push(e);
4506
4683
  }
4507
4684
  }
4508
- g.push(...h);
4685
+ h.length > 0 && (g.push(...h), g.sort((e, t) => e.source.compareDocumentPosition(t.source) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1));
4509
4686
  let _ = {
4510
4687
  source: e,
4511
4688
  style: i,
@@ -4520,14 +4697,16 @@ function Ii(e, t, n, r) {
4520
4697
  height: p
4521
4698
  },
4522
4699
  unclampedHeight: 0,
4523
- resolvedPadding: ot()
4700
+ resolvedPadding: R()
4524
4701
  };
4525
- return (a.advances.some((e) => e !== 1) || a.boxes.length > 0) && (_.advances = a.advances), a.inlineElements.length > 0 && (_.inlineElements = a.inlineElements, _.charInline = a.chars.map((e, t) => a.inlineIndex[t] ?? -1)), _;
4702
+ (a.advances.some((e) => e !== 1) || a.boxes.length > 0) && (_.advances = a.advances), a.inlineElements.length > 0 && (_.inlineElements = a.inlineElements, _.charInline = a.chars.map((e, t) => a.inlineIndex[t] ?? -1));
4703
+ let v = va(a);
4704
+ return v.length > 0 && (_.charSource = v), _;
4526
4705
  }
4527
4706
  let u = [];
4528
4707
  for (let e = 0; e < o.length; e++) {
4529
4708
  if (s[e] === "none") continue;
4530
- let i = Ii(o[e], t, n, r);
4709
+ let i = oa(o[e], t, n, r);
4531
4710
  i && u.push(i);
4532
4711
  }
4533
4712
  let d = {
@@ -4544,14 +4723,14 @@ function Ii(e, t, n, r) {
4544
4723
  height: 0
4545
4724
  },
4546
4725
  unclampedHeight: 0,
4547
- resolvedPadding: ot()
4726
+ resolvedPadding: R()
4548
4727
  };
4549
- return ea(e, d), d;
4728
+ return Ta(e, d), d;
4550
4729
  }
4551
- function Li(e, t, n) {
4552
- let r = ce(n, e), i = r?.lines ?? [], a = i.join("\n");
4730
+ function sa(e, t, n) {
4731
+ let r = le(n, e), i = r?.lines ?? [], a = i.join("\n");
4553
4732
  t.whiteSpace = "pre", (t.width === void 0 || t.width.kind === "auto") && (t.width = { kind: "max-content" });
4554
- let o = Array.from({ length: a.length }, () => 1 + t.tracking), s = Ji(a, o, t.tracking), c = i.length, l = {
4733
+ let o = Array.from({ length: a.length }, () => 1 + t.tracking), s = ya(a, o, t.tracking), c = i.length, l = {
4555
4734
  source: e,
4556
4735
  style: t,
4557
4736
  children: [],
@@ -4565,7 +4744,7 @@ function Li(e, t, n) {
4565
4744
  height: c
4566
4745
  },
4567
4746
  unclampedHeight: 0,
4568
- resolvedPadding: ot()
4747
+ resolvedPadding: R()
4569
4748
  };
4570
4749
  t.tracking > 0 && (l.advances = o);
4571
4750
  let u = r?.runs ?? [];
@@ -4593,95 +4772,111 @@ function Li(e, t, n) {
4593
4772
  }
4594
4773
  return l;
4595
4774
  }
4596
- var Ri = /* @__PURE__ */ new Set(/* @__PURE__ */ "A.ABBR.B.BDI.BDO.BR.CITE.CODE.DATA.DFN.EM.I.KBD.MARK.Q.S.SAMP.SMALL.SPAN.STRONG.SUB.SUP.TIME.U.VAR.WBR".split("."));
4597
- function zi(e, t) {
4598
- return t || (Ri.has(e.tagName) ? "inline" : "block");
4775
+ var ca = /* @__PURE__ */ new Set(/* @__PURE__ */ "A.ABBR.B.BDI.BDO.BR.CITE.CODE.DATA.DFN.EM.I.KBD.MARK.Q.S.SAMP.SMALL.SPAN.STRONG.SUB.SUP.TIME.U.VAR.WBR".split("."));
4776
+ function la(e, t) {
4777
+ return t || (ca.has(e.tagName) ? "inline" : "block");
4599
4778
  }
4600
- function Bi(e, t) {
4601
- let n = zi(e, t);
4779
+ function ua(e, t) {
4780
+ let n = la(e, t);
4602
4781
  return n === "inline" || n === "contents";
4603
4782
  }
4604
- function Vi(e, t) {
4605
- let n = zi(e, t);
4783
+ function da(e, t) {
4784
+ let n = la(e, t);
4606
4785
  return n.startsWith("inline") && n !== "inline";
4607
4786
  }
4608
- function Hi(e) {
4787
+ function fa(e) {
4609
4788
  let t = getComputedStyle(e);
4610
- return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : ae(e.tagName) ? "block" : Bi(e, t.display) || Vi(e, t.display) ? "inline" : "block";
4789
+ return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : oe(e.tagName) ? "block" : ua(e, t.display) || da(e, t.display) ? "inline" : "block";
4611
4790
  }
4612
- function Ui(e, t, n) {
4791
+ function pa(e, t, n) {
4613
4792
  let r = {
4614
4793
  chars: [],
4615
4794
  advances: [],
4795
+ sourceNode: [],
4796
+ sourceOffset: [],
4616
4797
  inlineIndex: [],
4617
4798
  inlineElements: [],
4618
4799
  boxes: []
4619
4800
  };
4620
- return Wi(e, t, n, r), n.preserve ? r : qi(r);
4801
+ return ma(e, t, n, r), n.preserve ? r : _a(r);
4621
4802
  }
4622
- function Wi(e, t, n, r) {
4803
+ function ma(e, t, n, r) {
4623
4804
  let i = () => {
4624
4805
  let e = 0;
4625
4806
  for (let t = r.chars.length - 1; t >= 0 && r.chars[t] !== "\n"; t--) e += r.advances[t];
4626
4807
  return e;
4627
4808
  };
4628
- if (!$i(e.tagName)) {
4809
+ if (!wa(e.tagName)) {
4629
4810
  for (let a of Array.from(e.childNodes)) if (a.nodeType === Node.TEXT_NODE) {
4630
- if (n.preserve) for (let e of (a.textContent ?? "").replace(/\r\n?/g, "\n")) if (e === "\n") r.chars.push("\n"), r.advances.push(0);
4631
- else if (e === " ") {
4632
- let e = (Math.floor(i() / n.tabSize) + 1) * n.tabSize;
4633
- for (let t = i(); t < e; t++) r.chars.push(" "), r.advances.push(1);
4634
- } else r.chars.push(e), r.advances.push(1 + t);
4635
- else for (let e of (a.textContent ?? "").replace(/[ \t\r\n\f]+/g, " ")) r.chars.push(e), r.advances.push(1 + t);
4811
+ if (n.preserve) {
4812
+ let e = a.textContent ?? "", o = 0;
4813
+ for (let s of e) {
4814
+ let c = o;
4815
+ if (o += s.length, s === "\r") {
4816
+ if (e[o] === "\n") continue;
4817
+ $(r, "\n", 0, a, c);
4818
+ } else if (s === "\n") $(r, "\n", 0, a, c);
4819
+ else if (s === " ") {
4820
+ let e = (Math.floor(i() / n.tabSize) + 1) * n.tabSize;
4821
+ for (let t = i(); t < e; t++) $(r, " ", 1, a, c);
4822
+ } else $(r, s, 1 + t, a, c);
4823
+ }
4824
+ } else {
4825
+ let e = 0, n = !1;
4826
+ for (let i of a.textContent ?? "") {
4827
+ let o = i === " " || i === " " || i === "\r" || i === "\n" || i === "\f";
4828
+ o ? n || $(r, " ", 1 + t, a, e) : $(r, i, 1 + t, a, e), n = o, e += i.length;
4829
+ }
4830
+ }
4636
4831
  } else if (a.nodeType === Node.ELEMENT_NODE) {
4637
4832
  let e = a;
4638
4833
  if (e.tagName === "BR") {
4639
- r.chars.push("\n"), r.advances.push(0);
4834
+ $(r, "\n", 0, null, -1);
4640
4835
  continue;
4641
4836
  }
4642
4837
  let t = getComputedStyle(e);
4643
4838
  if (t.display === "none" || t.position === "absolute" || t.position === "fixed") continue;
4644
- if (Vi(e, t.display)) {
4645
- let t = Ii(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4646
- t && (t.inlineBox = !0, r.chars.push(""), r.advances.push(1), r.boxes.push(t));
4839
+ if (da(e, t.display)) {
4840
+ let t = oa(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4841
+ t && (t.inlineBox = !0, $(r, "", 1, null, -1), r.boxes.push(t));
4647
4842
  continue;
4648
4843
  }
4649
- if (!Bi(e, t.display)) {
4650
- Xi(e);
4844
+ if (!ua(e, t.display)) {
4845
+ xa(e);
4651
4846
  continue;
4652
4847
  }
4653
- let i = ai(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = Gi(t.paddingLeft, n.rootFontSizePx), s = Gi(t.paddingRight, n.rootFontSizePx);
4848
+ let i = ki(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = ha(t.paddingLeft, n.rootFontSizePx), s = ha(t.paddingRight, n.rootFontSizePx);
4654
4849
  r.inlineElements.push({
4655
4850
  element: e,
4656
4851
  tracking: i,
4657
4852
  padLeft: o,
4658
4853
  padRight: s,
4659
- insets: t.position === "static" ? null : Ki(t, n.rootFontSizePx),
4854
+ insets: t.position === "static" ? null : ga(t, n.rootFontSizePx),
4660
4855
  color: t.color,
4661
- backgroundColor: Pr(t.backgroundColor) ? void 0 : t.backgroundColor,
4856
+ backgroundColor: ii(t.backgroundColor) ? void 0 : t.backgroundColor,
4662
4857
  fontWeight: t.fontWeight,
4663
4858
  fontStyle: t.fontStyle,
4664
4859
  textDecorationLine: t.textDecorationLine
4665
4860
  });
4666
4861
  let c = r.inlineElements.length - 1;
4667
- for (let e = 0; e < o; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
4862
+ for (let e = 0; e < o; e++) r.inlineIndex[r.chars.length] = c, $(r, "⁠", 1, null, -1);
4668
4863
  let l = r.chars.length;
4669
- Wi(e, i, n, r);
4864
+ ma(e, i, n, r);
4670
4865
  for (let e = l; e < r.chars.length; e++) r.inlineIndex[e] === void 0 && (r.inlineIndex[e] = c);
4671
- for (let e = 0; e < s; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
4866
+ for (let e = 0; e < s; e++) r.inlineIndex[r.chars.length] = c, $(r, "⁠", 1, null, -1);
4672
4867
  }
4673
4868
  }
4674
4869
  }
4675
- function Gi(e, t) {
4870
+ function ha(e, t) {
4676
4871
  if (!e || e.endsWith("%")) return 0;
4677
4872
  let n = parseFloat(e);
4678
- return Number.isFinite(n) ? Math.max(0, F(n, t)) : 0;
4873
+ return Number.isFinite(n) ? Math.max(0, P(n, t)) : 0;
4679
4874
  }
4680
- function Ki(e, t) {
4875
+ function ga(e, t) {
4681
4876
  let n = (e) => {
4682
4877
  if (!e || e === "auto" || e.endsWith("%")) return null;
4683
4878
  let n = parseFloat(e);
4684
- return Number.isFinite(n) ? F(n, t) : null;
4879
+ return Number.isFinite(n) ? P(n, t) : null;
4685
4880
  };
4686
4881
  return {
4687
4882
  top: n(e.top),
@@ -4690,55 +4885,73 @@ function Ki(e, t) {
4690
4885
  left: n(e.left)
4691
4886
  };
4692
4887
  }
4693
- function qi(e) {
4694
- let t = [], n = [], r = [], i = () => {
4888
+ function _a(e) {
4889
+ let t = [], n = [], r = [], i = [], a = [], o = () => {
4695
4890
  let e = t.length;
4696
4891
  for (; e > 0 && t[e - 1] !== "\n";) e--;
4697
4892
  return e;
4698
- }, a = () => {
4699
- for (; t.length > i() && t[t.length - 1] === " ";) t.pop(), n.pop(), r.pop();
4893
+ }, s = () => {
4894
+ for (; t.length > o() && t[t.length - 1] === " ";) t.pop(), n.pop(), r.pop(), i.pop(), a.pop();
4700
4895
  };
4701
- for (let i = 0; i < e.chars.length; i++) {
4702
- let o = e.chars[i];
4703
- if (o === " ") {
4896
+ for (let o = 0; o < e.chars.length; o++) {
4897
+ let c = e.chars[o];
4898
+ if (c === " ") {
4704
4899
  let e = t.length - 1;
4705
4900
  for (; e >= 0 && t[e] === "⁠";) e--;
4706
4901
  if (e < 0 || t[e] === "\n" || t[e] === " ") continue;
4707
- } else o === "\n" && a();
4708
- t.push(o), n.push(e.advances[i]), r.push(e.inlineIndex[i] ?? -1);
4902
+ } else c === "\n" && s();
4903
+ t.push(c), n.push(e.advances[o]), r.push(e.sourceNode[o] ?? null), i.push(e.sourceOffset[o] ?? -1), a.push(e.inlineIndex[o] ?? -1);
4709
4904
  }
4710
- return a(), {
4905
+ return s(), {
4711
4906
  chars: t,
4712
4907
  advances: n,
4713
- inlineIndex: r,
4908
+ sourceNode: r,
4909
+ sourceOffset: i,
4910
+ inlineIndex: a,
4714
4911
  inlineElements: e.inlineElements,
4715
4912
  boxes: e.boxes
4716
4913
  };
4717
4914
  }
4718
- function Ji(e, t, n) {
4915
+ function $(e, t, n, r, i) {
4916
+ e.chars.push(t), e.advances.push(n), e.sourceNode.push(r), e.sourceOffset.push(i);
4917
+ }
4918
+ function va(e) {
4919
+ let t = [], n = 0;
4920
+ for (let r = 0; r < e.chars.length; r++) {
4921
+ let i = e.chars[r], a = e.sourceNode[r], o = e.sourceOffset[r], s = t[t.length - 1];
4922
+ a && (s && s.node === a && s.offset + s.length === o ? s.length += i.length : t.push({
4923
+ index: n,
4924
+ length: i.length,
4925
+ node: a,
4926
+ offset: o
4927
+ })), n += i.length;
4928
+ }
4929
+ return t;
4930
+ }
4931
+ function ya(e, t, n) {
4719
4932
  let r = 0, i = 0;
4720
- for (let a = 0; a <= e.length; a++) (a === e.length || e[a] === "\n") && (r = Math.max(r, I(i, a, t, n)), i = a + 1);
4933
+ for (let a = 0; a <= e.length; a++) (a === e.length || e[a] === "\n") && (r = Math.max(r, F(i, a, t, n)), i = a + 1);
4721
4934
  return r;
4722
4935
  }
4723
- function Yi(e) {
4724
- return Ae(e).length;
4936
+ function ba(e) {
4937
+ return ke(e).length;
4725
4938
  }
4726
- function Xi(e) {
4727
- N(e, "A block-level element nested inside a text run can't be laid out and was skipped. Give it its own place in the layout instead.");
4939
+ function xa(e) {
4940
+ M(e, "A block-level element nested inside a text run can't be laid out and was skipped. Give it its own place in the layout instead.");
4728
4941
  }
4729
- function Zi(e) {
4942
+ function Sa(e) {
4730
4943
  return Array.from(e.childNodes).some((e) => e.nodeType === Node.TEXT_NODE && /[^ \t\r\n\f]/.test(e.textContent ?? ""));
4731
4944
  }
4732
- var Qi = "Direct text next to block-level children can't be laid out and was hidden. Wrap each text segment in its own element (e.g. a <div>).";
4733
- function $i(e) {
4945
+ var Ca = "Direct text next to block-level children can't be laid out and was hidden. Wrap each text segment in its own element (e.g. a <div>).";
4946
+ function wa(e) {
4734
4947
  return e === "INPUT" || e === "SELECT" || e === "TEXTAREA";
4735
4948
  }
4736
- function ea(e, t) {
4737
- Zi(e) && (t.droppedText = !0, N(e, Qi));
4949
+ function Ta(e, t) {
4950
+ Sa(e) && (t.droppedText = !0, M(e, Ca));
4738
4951
  }
4739
4952
  //#endregion
4740
4953
  //#region src/element.ts
4741
- var ta = "\n<style>\n :host { display: block; position: relative; contain: layout style; }\n #viewport { position: relative; width: 100%; height: 100%; background: inherit; }\n /* When the host hides its own dropped direct text (visibility, see\n * styles.css), the render layer must not sink with it. Scoped to that\n * state so an authored 'invisible' on the host stays intact. */\n :host([data-mw-dropped-text]) #viewport { visibility: visible; }\n /* The unified grid: one <pre> with same-paint-run spans, cell-precise\n * (one monospace character = one cell). In select=\"grid\" (the\n * default, reflected onto the attribute — see DEFAULT_SELECT) the\n * grid catches drags for native selection of the ASCII; interactive\n * elements opt back into pointer-events via styles.css so clicks\n * still work. In select=\"text\" the grid is inert to events and drag\n * selects the light DOM natively. */\n /* Sized by the engine's ink extent (element.ts), not the host box:\n * visible overflow paints past the host (specs/cell-model.md\n * \"Overflow\"), and the host's background follows it there — the\n * host is the canvas, as the root element's background covers a\n * document's overflow — inherited through #viewport, the shadow\n * parent. (A translucent host background paints repeatedly inside\n * the box.) */\n #grid { position: absolute; top: 0; left: 0; margin: 0; background: inherit; font: inherit; line-height: inherit; letter-spacing: inherit; white-space: pre; pointer-events: none; user-select: none; -webkit-user-select: none; }\n :host([select=\"grid\"]) #grid { pointer-events: auto; user-select: text; -webkit-user-select: text; }\n :host([select=\"grid\"]) slot { pointer-events: none; user-select: none; -webkit-user-select: none; }\n /* Selection invert — mirror of the canonical rule in styles.css\n * (which explains the field choices); update together. */\n ::selection { color: var(--mw-bg, canvas); text-shadow: 0 0 0 var(--mw-bg, canvas); background: var(--mw-fg, canvastext); }\n</style>\n<div id=\"viewport\">\n <pre id=\"grid\" aria-hidden=\"true\"></pre>\n <slot></slot>\n</div>\n", na = "grid", ra = [
4954
+ var Ea = "\n<style>\n :host { display: block; position: relative; contain: layout style; }\n #viewport { position: relative; width: 100%; height: 100%; background: inherit; }\n /* When the host hides its own dropped direct text (visibility, see\n * styles.css), the render layer must not sink with it. Scoped to that\n * state so an authored 'invisible' on the host stays intact. */\n :host([data-mw-dropped-text]) #viewport { visibility: visible; }\n /* The unified grid: one <pre> with same-paint-run spans, cell-precise\n * (one monospace character = one cell). In select=\"grid\" (the\n * default, reflected onto the attribute — see DEFAULT_SELECT) the\n * grid catches drags for native selection of the ASCII; interactive\n * elements opt back into pointer-events via styles.css so clicks\n * still work. In select=\"text\" the grid is inert to events and drag\n * selects the light DOM natively. */\n /* Sized by the engine's ink extent (element.ts), not the host box:\n * visible overflow paints past the host (specs/cell-model.md\n * \"Overflow\"), and the host's background follows it there — the\n * host is the canvas, as the root element's background covers a\n * document's overflow — inherited through #viewport, the shadow\n * parent. (A translucent host background paints repeatedly inside\n * the box.) */\n #grid { position: absolute; top: 0; left: 0; margin: 0; background: inherit; font: inherit; line-height: inherit; letter-spacing: inherit; white-space: pre; pointer-events: none; user-select: none; -webkit-user-select: none; }\n :host([select=\"grid\"]) #grid { pointer-events: auto; user-select: text; -webkit-user-select: text; }\n :host([select=\"grid\"]) slot { pointer-events: none; user-select: none; -webkit-user-select: none; }\n /* A live semantic selection (specs/semantic-selection.md) lifts the\n * lock so the element selection copies; pointer events stay off. */\n :host([select=\"grid\"][data-mw-semantic-selection]) slot { user-select: text; -webkit-user-select: text; }\n /* Selection invert — mirror of the canonical rule in styles.css\n * (which explains the field choices); update together. */\n ::selection { color: var(--mw-bg, canvas); text-shadow: 0 0 0 var(--mw-bg, canvas); background: var(--mw-fg, canvastext); }\n</style>\n<div id=\"viewport\">\n <pre id=\"grid\" aria-hidden=\"true\"></pre>\n <slot></slot>\n</div>\n", Da = "grid", Oa = "data-mw-semantic-selection", ka = [
4742
4955
  "pointerover",
4743
4956
  "pointerleave",
4744
4957
  "pointerdown",
@@ -4750,12 +4963,12 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
4750
4963
  "focusout",
4751
4964
  "input",
4752
4965
  "change"
4753
- ], ia = /^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/, aa = 3e4, oa = 200, sa = 3, ca = 4, la = 8, ua = 100, da = 160, fa = typeof HTMLElement > "u" ? class {} : HTMLElement, pa = class e extends fa {
4966
+ ], Aa = /^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/, ja = 3e4, Ma = 200, Na = 3, Pa = 4, Fa = 8, Ia = 100, La = 160, Ra = typeof HTMLElement > "u" ? class {} : HTMLElement, za = class e extends Ra {
4754
4967
  static observedAttributes = ["select"];
4755
4968
  static #e = /* @__PURE__ */ new Set();
4756
4969
  static #t = null;
4757
4970
  static #n = () => {
4758
- for (let t of e.#e) t.#fe();
4971
+ for (let t of e.#e) t.#Ce();
4759
4972
  };
4760
4973
  static #r(t) {
4761
4974
  t instanceof HTMLLinkElement && t.rel === "stylesheet" && !t.sheet && t.addEventListener("load", e.#n, { once: !0 });
@@ -4792,8 +5005,10 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
4792
5005
  #y = /* @__PURE__ */ new WeakMap();
4793
5006
  #b = null;
4794
5007
  #x = null;
4795
- #S = [];
4796
- #C() {
5008
+ #S = "";
5009
+ #C = null;
5010
+ #w = [];
5011
+ #T() {
4797
5012
  this.#u?.observe(this, {
4798
5013
  childList: !0,
4799
5014
  subtree: !0,
@@ -4805,80 +5020,80 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
4805
5020
  "colspan",
4806
5021
  "rowspan",
4807
5022
  "span",
4808
- ...oe()
5023
+ ...se()
4809
5024
  ]
4810
5025
  });
4811
5026
  }
4812
5027
  constructor() {
4813
- super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = ta, this.#s = this.#o.getElementById("grid"), this.#c = document.createElement("span"), this.#c.setAttribute("aria-hidden", "true"), this.#c.setAttribute("data-mw-probe", ""), this.#c.style.cssText = "position:absolute!important;top:0!important;left:0!important;visibility:hidden!important;pointer-events:none!important;user-select:none!important;white-space:pre!important;overflow-wrap:normal!important;padding:0!important;margin:0!important;border:0!important;", this.#c.textContent = "M".repeat(100);
5028
+ super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = Ea, this.#s = this.#o.getElementById("grid"), this.#c = document.createElement("span"), this.#c.setAttribute("aria-hidden", "true"), this.#c.setAttribute("data-mw-probe", ""), this.#c.style.cssText = "position:absolute!important;top:0!important;left:0!important;visibility:hidden!important;pointer-events:none!important;user-select:none!important;white-space:pre!important;overflow-wrap:normal!important;padding:0!important;margin:0!important;border:0!important;", this.#c.textContent = "M".repeat(100);
4814
5029
  }
4815
5030
  connectedCallback() {
4816
- this.hasAttribute("select") || this.setAttribute("select", na), this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#fe()), this.#l.observe(this), this.#G(), this.#l.observe(this.#c), window.addEventListener("resize", this.#ce), this.#u = new MutationObserver(() => this.#fe()), this.#C(), this.#m = se(() => {
4817
- this.#C(), this.#fe();
4818
- }), this.#h = C(() => this.#fe()), document.fonts?.ready.then(this.#le).catch((e) => {
5031
+ this.hasAttribute("select") || this.setAttribute("select", Da), this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#Ce()), this.#l.observe(this), this.#q(), this.#l.observe(this.#c), window.addEventListener("resize", this.#ye), this.#u = new MutationObserver(() => this.#Ce()), this.#T(), this.#m = ce(() => {
5032
+ this.#T(), this.#Ce();
5033
+ }), this.#h = C(() => this.#Ce()), document.fonts?.ready.then(this.#be).catch((e) => {
4819
5034
  console.warn("[monowind] document.fonts.ready failed:", e);
4820
- }), document.fonts?.addEventListener("loadingdone", this.#le);
4821
- for (let e of ra) this.addEventListener(e, this.#se);
4822
- this.addEventListener("transitionrun", this.#ie), this.addEventListener("transitionend", this.#ae), this.addEventListener("transitioncancel", this.#ae), this.addEventListener("pointermove", this.#J), this.addEventListener("pointerleave", this.#Y), this.addEventListener("pointerdown", this.#X), this.addEventListener("scroll", this.#B, {
5035
+ }), document.fonts?.addEventListener("loadingdone", this.#be);
5036
+ for (let e of ka) this.addEventListener(e, this.#ve);
5037
+ this.addEventListener("transitionrun", this.#he), this.addEventListener("transitionend", this.#ge), this.addEventListener("transitioncancel", this.#ge), this.addEventListener("pointermove", this.#X), this.addEventListener("pointerleave", this.#oe), this.addEventListener("pointerdown", this.#se), this.addEventListener("scroll", this.#H, {
4823
5038
  capture: !0,
4824
5039
  passive: !0
4825
- }), this.addEventListener("scrollend", this.#V, { capture: !0 }), this.addEventListener("wheel", this.#U, { passive: !1 }), window.addEventListener("pointerup", this.#Z), window.addEventListener("pointercancel", this.#Z), document.addEventListener("scroll", this.#Q, {
5040
+ }), this.addEventListener("scrollend", this.#U, { capture: !0 }), this.addEventListener("wheel", this.#G, { passive: !1 }), this.addEventListener("copy", this.#Z), this.addEventListener("mousedown", this.#Q), document.addEventListener("selectionchange", this.#ae), window.addEventListener("pointerup", this.#ce), window.addEventListener("pointercancel", this.#ce), document.addEventListener("scroll", this.#le, {
4826
5041
  capture: !0,
4827
5042
  passive: !0
4828
- }), e.#i(this), this.#fe();
5043
+ }), e.#i(this), this.#Ce();
4829
5044
  }
4830
5045
  disconnectedCallback() {
4831
- window.removeEventListener("resize", this.#ce), this.#l?.disconnect(), this.#u?.disconnect(), this.#l = null, this.#u = null, this.#m?.(), this.#m = null, this.#h?.(), this.#h = null, document.fonts?.removeEventListener("loadingdone", this.#le);
4832
- for (let e of ra) this.removeEventListener(e, this.#se);
4833
- this.removeEventListener("transitionrun", this.#ie), this.removeEventListener("transitionend", this.#ae), this.removeEventListener("transitioncancel", this.#ae), this.#te = 0, this.removeEventListener("pointermove", this.#J), this.removeEventListener("pointerleave", this.#Y), this.removeEventListener("pointerdown", this.#X), this.removeEventListener("scroll", this.#B, { capture: !0 }), this.removeEventListener("scrollend", this.#V, { capture: !0 }), this.removeEventListener("wheel", this.#U);
5046
+ window.removeEventListener("resize", this.#ye), this.#l?.disconnect(), this.#u?.disconnect(), this.#l = null, this.#u = null, this.#m?.(), this.#m = null, this.#h?.(), this.#h = null, document.fonts?.removeEventListener("loadingdone", this.#be);
5047
+ for (let e of ka) this.removeEventListener(e, this.#ve);
5048
+ this.removeEventListener("transitionrun", this.#he), this.removeEventListener("transitionend", this.#ge), this.removeEventListener("transitioncancel", this.#ge), this.#fe = 0, this.removeEventListener("pointermove", this.#X), this.removeEventListener("pointerleave", this.#oe), this.removeEventListener("pointerdown", this.#se), this.removeEventListener("scroll", this.#H, { capture: !0 }), this.removeEventListener("scrollend", this.#U, { capture: !0 }), this.removeEventListener("wheel", this.#G), this.removeEventListener("copy", this.#Z), this.removeEventListener("mousedown", this.#Q), document.removeEventListener("selectionchange", this.#ae);
4834
5049
  for (let e of this.#v.values()) clearTimeout(e);
4835
- this.#v.clear(), this.#x = null, this.#b = null, window.removeEventListener("pointerup", this.#Z), window.removeEventListener("pointercancel", this.#Z), document.removeEventListener("scroll", this.#Q, { capture: !0 }), this.#k = null, this.#E = null, this.#D = !1, this.#O = !1, this.#$(), e.#a(this);
4836
- }
4837
- #w = /* @__PURE__ */ new Set();
4838
- #T = /* @__PURE__ */ new Set();
4839
- #E = null;
4840
- #D = !1;
4841
- #O = !1;
4842
- #k = null;
4843
- #A = NaN;
4844
- #j = NaN;
4845
- #M = null;
4846
- static #N = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
4847
- #P() {
5050
+ this.#v.clear(), this.#x = null, this.#b = null, window.removeEventListener("pointerup", this.#ce), window.removeEventListener("pointercancel", this.#ce), document.removeEventListener("scroll", this.#le, { capture: !0 }), this.#j = null, this.#O = null, this.#k = !1, this.#A = !1, this.#ue(), e.#a(this);
5051
+ }
5052
+ #E = /* @__PURE__ */ new Set();
5053
+ #D = /* @__PURE__ */ new Set();
5054
+ #O = null;
5055
+ #k = !1;
5056
+ #A = !1;
5057
+ #j = null;
5058
+ #M = NaN;
5059
+ #N = NaN;
5060
+ #P = null;
5061
+ static #F = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
5062
+ #I() {
4848
5063
  if (this.#g || this.#d) return;
4849
5064
  this.#g = !0;
4850
5065
  let e = !1, t = () => {
4851
5066
  if (e) return;
4852
5067
  e = !0, this.#g = !1;
4853
5068
  let t = this.#f;
4854
- this.isConnected && this.#p && t && (this.#F(t), this.#O = !yr(this.#p, this.#s, this.#D), this.#$());
5069
+ this.isConnected && this.#p && t && (this.#L(t), this.#A = !Ur(this.#p, this.#s, this.#k), this.#ue());
4855
5070
  };
4856
5071
  requestAnimationFrame(t), setTimeout(t, 50);
4857
5072
  }
4858
- #F(e, t) {
5073
+ #L(e, t) {
4859
5074
  for (let n of this.#_) {
4860
5075
  let r = n.source, { maxX: i, maxY: a } = n.scrollRange, o = t?.get(r);
4861
5076
  n.scroll = o ? {
4862
5077
  x: o.pinX ? i : Math.min(o.x, i),
4863
5078
  y: o.pinY ? a : Math.min(o.y, a)
4864
- } : this.#I(n, e);
5079
+ } : this.#R(n, e);
4865
5080
  }
4866
5081
  }
4867
- #I(e, t) {
5082
+ #R(e, t) {
4868
5083
  let n = e.source, { maxX: r, maxY: i } = e.scrollRange, a = e.scroll ?? {
4869
5084
  x: 0,
4870
5085
  y: 0
4871
5086
  };
4872
5087
  return {
4873
- x: ha(n, "x", t.width, r, a.x),
4874
- y: ha(n, "y", t.height, i, a.y)
5088
+ x: Va(n, "x", t.width, r, a.x),
5089
+ y: Va(n, "y", t.height, i, a.y)
4875
5090
  };
4876
5091
  }
4877
- #L() {
5092
+ #z() {
4878
5093
  let e = /* @__PURE__ */ new Map(), t = this.#f;
4879
5094
  if (!t) return e;
4880
5095
  for (let n of this.#_) {
4881
- let r = n.source, { maxX: i, maxY: a } = n.scrollRange, { x: o, y: s } = this.#I(n, t);
5096
+ let r = n.source, { maxX: i, maxY: a } = n.scrollRange, { x: o, y: s } = this.#R(n, t);
4882
5097
  e.set(r, {
4883
5098
  top: r.scrollTop,
4884
5099
  left: r.scrollLeft,
@@ -4890,42 +5105,42 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
4890
5105
  }
4891
5106
  return e;
4892
5107
  }
4893
- #R(e) {
5108
+ #B(e) {
4894
5109
  for (let t of this.#_) {
4895
5110
  let n = t.source, r = e.get(n);
4896
5111
  r && (n.scrollTop, n.scrollLeft, n.scrollTop = r.pinY ? n.scrollHeight : r.top, n.scrollLeft = r.pinX ? n.scrollWidth : r.left);
4897
5112
  }
4898
5113
  }
4899
- #z(e, t) {
4900
- clearTimeout(this.#v.get(e)), this.#v.set(e, setTimeout(() => this.#H(e), t));
5114
+ #V(e, t) {
5115
+ clearTimeout(this.#v.get(e)), this.#v.set(e, setTimeout(() => this.#W(e), t));
4901
5116
  }
4902
- #B = (e) => {
5117
+ #H = (e) => {
4903
5118
  let t = e.target;
4904
- t instanceof HTMLElement && t !== this && t.hasAttribute("data-mw-scroll") && (this.#P(), !(Date.now() - (this.#y.get(t) ?? 0) < oa) && (clearTimeout(this.#v.get(t)), "onscrollend" in window || this.#z(t, da)));
5119
+ t instanceof HTMLElement && t !== this && t.hasAttribute("data-mw-scroll") && (this.#I(), !(Date.now() - (this.#y.get(t) ?? 0) < Ma) && (clearTimeout(this.#v.get(t)), "onscrollend" in window || this.#V(t, La)));
4905
5120
  };
4906
- #V = (e) => {
5121
+ #U = (e) => {
4907
5122
  let t = e.target;
4908
- t instanceof HTMLElement && t !== this && t.hasAttribute("data-mw-scroll") && (Date.now() - (this.#y.get(t) ?? 0) < oa || this.#z(t, ua));
5123
+ t instanceof HTMLElement && t !== this && t.hasAttribute("data-mw-scroll") && (Date.now() - (this.#y.get(t) ?? 0) < Ma || this.#V(t, Ia));
4909
5124
  };
4910
- #H(e) {
5125
+ #W(e) {
4911
5126
  if (this.#x?.el === e) return;
4912
- this.#P();
5127
+ this.#I();
4913
5128
  let t = this.#f, n = this.#_.find((t) => t.source === e);
4914
5129
  if (!t || !n) return;
4915
- let r = n.scrollRange, i = n.scroll ?? this.#I(n, t), a = i.y === r.maxY ? e.scrollHeight - e.clientHeight : i.y * t.height, o = i.x === r.maxX ? e.scrollWidth - e.clientWidth : i.x * t.width;
5130
+ let r = n.scrollRange, i = n.scroll ?? this.#R(n, t), a = i.y === r.maxY ? e.scrollHeight - e.clientHeight : i.y * t.height, o = i.x === r.maxX ? e.scrollWidth - e.clientWidth : i.x * t.width;
4916
5131
  (Math.abs(e.scrollTop - a) > .5 || Math.abs(e.scrollLeft - o) > .5) && e.scrollTo({
4917
5132
  top: a,
4918
5133
  left: o,
4919
5134
  behavior: "instant"
4920
5135
  });
4921
5136
  }
4922
- #U = (e) => {
5137
+ #G = (e) => {
4923
5138
  if (this.getAttribute("select") !== "grid") return;
4924
5139
  let t = this.#p, n = this.#f;
4925
5140
  if (!t || !n || this.#_.length === 0) return;
4926
5141
  let r = e, i = r.deltaMode === 1 ? n.height : r.deltaMode === 2 ? this.clientHeight : 1, a = r.deltaX * i, o = r.deltaY * i;
4927
- if (!r.cancelable && this.#W(a, o)) return;
4928
- let { col: s, row: c } = this.#K(r.clientX, r.clientY, n), l = Date.now(), u = Math.abs(a) + Math.abs(o);
5142
+ if (!r.cancelable && this.#K(a, o)) return;
5143
+ let { col: s, row: c } = this.#J(r.clientX, r.clientY, n), l = Date.now(), u = Math.abs(a) + Math.abs(o);
4929
5144
  if (u === 0) {
4930
5145
  this.#b = null, r.preventDefault();
4931
5146
  return;
@@ -4933,13 +5148,13 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
4933
5148
  let d = (e) => {
4934
5149
  let t = e.scrollRange, n = e.source;
4935
5150
  return o !== 0 && t.maxY > 0 && (o > 0 && n.scrollTop < n.scrollHeight - n.clientHeight - .5 || o < 0 && n.scrollTop > .5) || a !== 0 && t.maxX > 0 && (a > 0 && n.scrollLeft < n.scrollWidth - n.clientWidth - .5 || a < 0 && n.scrollLeft > .5);
4936
- }, f = this.#b, p = Math.abs(a) >= Math.abs(o) ? "x" : "y", m = f !== null && u > f.mag * 1.25 + 1, h = f !== null && (Math.abs(r.clientX - f.x) > sa || Math.abs(r.clientY - f.y) > sa), g = f !== null && f.decayed >= la, _ = f !== null && l - f.at < oa && p === f.axis && (h ? u <= f.mag : !(g && m)), v = null;
5151
+ }, f = this.#b, p = Math.abs(a) >= Math.abs(o) ? "x" : "y", m = f !== null && u > f.mag * 1.25 + 1, h = f !== null && (Math.abs(r.clientX - f.x) > Na || Math.abs(r.clientY - f.y) > Na), g = f !== null && f.decayed >= Fa, _ = f !== null && l - f.at < Ma && p === f.axis && (h ? u <= f.mag : !(g && m)), v = null;
4937
5152
  if (_) {
4938
5153
  if (f.decayed = u <= f.mag && u >= f.mag * .5 ? f.decayed + 1 : g ? f.decayed : 0, f.mag = u, f.at = l, !f.el) return;
4939
5154
  v = this.#_.find((e) => e.source === f.el) ?? null;
4940
5155
  }
4941
5156
  if (!v) {
4942
- let e = Se(t, s, c);
5157
+ let e = yr(t, s, c);
4943
5158
  for (let t = e.length - 1; t >= 0; t--) {
4944
5159
  let n = e[t].node;
4945
5160
  if (!n.scrollRange) continue;
@@ -4953,7 +5168,7 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
4953
5168
  break;
4954
5169
  }
4955
5170
  }
4956
- if (!v && u < ca) {
5171
+ if (!v && u < Pa) {
4957
5172
  r.preventDefault();
4958
5173
  return;
4959
5174
  }
@@ -4969,41 +5184,41 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
4969
5184
  }
4970
5185
  if (!v || (r.preventDefault(), !d(v))) return;
4971
5186
  let y = v.source, b = v.scrollRange, x = { behavior: "instant" };
4972
- o !== 0 && b.maxY > 0 && (x.top = o), a !== 0 && b.maxX > 0 && (x.left = a), y.scrollBy(x), this.#y.set(y, l), this.#z(y, oa);
5187
+ o !== 0 && b.maxY > 0 && (x.top = o), a !== 0 && b.maxX > 0 && (x.left = a), y.scrollBy(x), this.#y.set(y, l), this.#V(y, Ma);
4973
5188
  };
4974
- #W(e, t) {
4975
- return this.#S.some((n) => t > 0 && n.scrollTop < n.scrollHeight - n.clientHeight - .5 || t < 0 && n.scrollTop > .5 || e > 0 && n.scrollLeft < n.scrollWidth - n.clientWidth - .5 || e < 0 && n.scrollLeft > .5);
5189
+ #K(e, t) {
5190
+ return this.#w.some((n) => t > 0 && n.scrollTop < n.scrollHeight - n.clientHeight - .5 || t < 0 && n.scrollTop > .5 || e > 0 && n.scrollLeft < n.scrollWidth - n.clientWidth - .5 || e < 0 && n.scrollLeft > .5);
4976
5191
  }
4977
- #G() {
5192
+ #q() {
4978
5193
  let e = this.parentElement;
4979
5194
  if (e && this.#l) {
4980
5195
  this.#l.observe(e);
4981
5196
  for (let t of e.children) t !== this && this.#l.observe(t);
4982
5197
  }
4983
5198
  }
4984
- #K(e, t, n) {
4985
- if (!this.#M) {
5199
+ #J(e, t, n) {
5200
+ if (!this.#P) {
4986
5201
  let e = this.#s.getBoundingClientRect();
4987
- this.#M = {
5202
+ this.#P = {
4988
5203
  left: e.left,
4989
5204
  top: e.top
4990
5205
  };
4991
5206
  }
4992
5207
  return {
4993
- col: Math.floor((e - this.#M.left) / n.width),
4994
- row: Math.floor((t - this.#M.top) / n.height)
5208
+ col: Math.floor((e - this.#P.left) / n.width),
5209
+ row: Math.floor((t - this.#P.top) / n.height)
4995
5210
  };
4996
5211
  }
4997
- #q(e, t) {
5212
+ #Y(e, t) {
4998
5213
  let n = this.#p, r = this.#f;
4999
5214
  if (!n || !r || this.#_.length === 0) return null;
5000
- let { col: i, row: a } = this.#K(e, t, r), o = Se(n, i, a);
5215
+ let { col: i, row: a } = this.#J(e, t, r), o = yr(n, i, a);
5001
5216
  for (let n = o.length - 1; n >= 0; n--) {
5002
5217
  let { node: s, x: c, y: l } = o[n], u = s.scrollRange;
5003
5218
  if (!u) continue;
5004
- let d = s.source, { y: f, x: p } = pr(s, c, l);
5219
+ let d = s.source, { y: f, x: p } = gr(s, c, l);
5005
5220
  if (f && u.maxY > 0 && i >= f.col && i < f.col + f.thick && a >= f.row && a < f.row + f.len) {
5006
- let e = mr(f.len, u.sizeY, u.maxY, 0).len, n = Math.max(1, (f.len - e) * r.height);
5221
+ let e = _r(f.len, u.sizeY, u.maxY, 0).len, n = Math.max(1, (f.len - e) * r.height);
5007
5222
  return {
5008
5223
  el: d,
5009
5224
  axis: "y",
@@ -5013,7 +5228,7 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
5013
5228
  };
5014
5229
  }
5015
5230
  if (p && u.maxX > 0 && a >= p.row && a < p.row + p.thick && i >= p.col && i < p.col + p.len) {
5016
- let t = mr(p.len, u.sizeX, u.maxX, 0).len, n = Math.max(1, (p.len - t) * r.width);
5231
+ let t = _r(p.len, u.sizeX, u.maxX, 0).len, n = Math.max(1, (p.len - t) * r.width);
5017
5232
  return {
5018
5233
  el: d,
5019
5234
  axis: "x",
@@ -5025,69 +5240,182 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
5025
5240
  }
5026
5241
  return null;
5027
5242
  }
5028
- #J = (e) => {
5029
- if (_a(e)) return;
5243
+ #X = (e) => {
5244
+ if (Ua(e)) return;
5030
5245
  let { clientX: t, clientY: n } = e, r = this.#x;
5031
5246
  if (r) {
5032
5247
  let e = (r.axis === "y" ? n : t) - r.startClient, i = r.startPx + e * r.factor;
5033
5248
  r.axis === "y" ? r.el.scrollTop = i : r.el.scrollLeft = i;
5034
5249
  return;
5035
5250
  }
5036
- this.#k = {
5251
+ let i = this.#C;
5252
+ i && e.buttons & 1 && this.#$(i, t, n), this.#j = {
5037
5253
  x: t,
5038
5254
  y: n
5039
5255
  };
5040
- let i = this.#f;
5041
- if (i) {
5042
- let { col: e, row: r } = this.#K(t, n, i);
5043
- if (e === this.#A && r === this.#j) return;
5256
+ let a = this.#f;
5257
+ if (a) {
5258
+ let { col: e, row: r } = this.#J(t, n, a);
5259
+ if (e === this.#M && r === this.#N) return;
5044
5260
  }
5045
- this.#$();
5261
+ this.#ue();
5046
5262
  };
5047
- #Y = () => {
5048
- this.#k = null, this.#$();
5263
+ #Z = (e) => {
5264
+ let { clipboardData: t } = e, n = this.#p, r = this.#ie();
5265
+ t && n && r && (t.setData("text/plain", Er(n, r)), e.preventDefault());
5049
5266
  };
5050
- #X = (e) => {
5267
+ #Q = (e) => {
5268
+ let t = e;
5269
+ if (t.button !== 0 || this.getAttribute("select") !== "grid" || !t.composedPath().includes(this.#s)) return;
5270
+ if (t.detail <= 1) {
5271
+ t.detail === 1 && this.removeAttribute(Oa);
5272
+ return;
5273
+ }
5274
+ if (this.#S !== "mouse" && this.#S !== "pen") return;
5275
+ t.preventDefault();
5276
+ let n = document.activeElement;
5277
+ n instanceof HTMLElement && n !== document.body && this.contains(n) && n.blur();
5278
+ let r = t.detail === 2 ? "word" : "paragraph", i = document.getSelection(), a = this.#p, o = this.#f;
5279
+ if (!i || !a || !o) return;
5280
+ let { col: s, row: c } = this.#J(t.clientX, t.clientY, o), l = this.#te(s, c, r);
5281
+ if (!l) {
5282
+ i.removeAllRanges(), this.#C = null;
5283
+ return;
5284
+ }
5285
+ this.#re(l);
5286
+ let u = t.shiftKey && i.anchorNode && this.#ie() ? Ga({
5287
+ node: i.anchorNode,
5288
+ offset: i.anchorOffset
5289
+ }) : l;
5290
+ this.#ee(i, u, l), this.#C = {
5291
+ unit: r,
5292
+ anchor: u
5293
+ };
5294
+ };
5295
+ #$(e, t, n) {
5296
+ let r = this.#f, i = document.getSelection();
5297
+ if (!r || !i) return;
5298
+ let { col: a, row: o } = this.#J(t, n, r), s = this.#te(a, o, e.unit);
5299
+ s && this.#ee(i, e.anchor, s);
5300
+ }
5301
+ #ee(e, t, n) {
5302
+ if (qa(t, n)) {
5303
+ Ka(e, n.start, n.end);
5304
+ return;
5305
+ }
5306
+ let r = this.#ne(t), i = this.#ne(n);
5307
+ xr(r.start.node, r.start.offset, i.start.node, i.start.offset) <= 0 ? Ka(e, r.start, i.end) : Ka(e, r.end, i.start);
5308
+ }
5309
+ #te(e, t, n) {
5310
+ let r = this.#p;
5311
+ if (!r) return null;
5312
+ let i = yr(r, e, t);
5313
+ for (let r = i.length - 1; r >= 0; r--) {
5314
+ let { node: a, x: o, y: s } = i[r];
5315
+ if (!Mr(a)) continue;
5316
+ let c = oe(a.source.tagName)?.selectionTarget?.(a.source);
5317
+ if (n === "word" && !c) {
5318
+ let n = hr(a, o, s, e, t);
5319
+ if (n === null) return null;
5320
+ let r = Ir(a, n), i = r && Cr(a, r.start), c = r && Cr(a, r.end);
5321
+ if (i && c) return {
5322
+ start: i,
5323
+ end: c
5324
+ };
5325
+ }
5326
+ let l = c ?? a.source;
5327
+ return {
5328
+ start: {
5329
+ node: l,
5330
+ offset: 0
5331
+ },
5332
+ end: {
5333
+ node: l,
5334
+ offset: l.childNodes.length
5335
+ }
5336
+ };
5337
+ }
5338
+ return null;
5339
+ }
5340
+ #ne(e) {
5341
+ let t = e.start.node.getRootNode();
5342
+ if (!(t instanceof ShadowRoot) || t === this.#s.getRootNode()) return e;
5343
+ let n = t.host, r = n.parentNode;
5344
+ if (!r) return e;
5345
+ let i = Array.prototype.indexOf.call(r.childNodes, n), a = n.previousSibling, o = n.nextSibling;
5346
+ return {
5347
+ start: Wa(a) ? {
5348
+ node: a,
5349
+ offset: a instanceof Text ? a.length : a.childNodes.length
5350
+ } : {
5351
+ node: r,
5352
+ offset: i
5353
+ },
5354
+ end: Wa(o) ? {
5355
+ node: o,
5356
+ offset: 0
5357
+ } : {
5358
+ node: r,
5359
+ offset: i + 1
5360
+ }
5361
+ };
5362
+ }
5363
+ #re(e) {
5364
+ this.setAttribute(Oa, "");
5365
+ let t = e.start.node, n = t instanceof Element ? t : t.parentElement;
5366
+ n && getComputedStyle(n).userSelect;
5367
+ }
5368
+ #ie() {
5369
+ let e = wr(this.#s.getRootNode());
5370
+ return !e || Tr(this, this.#s, e) !== "light" || e.startContainer === e.endContainer && e.startOffset === e.endOffset ? null : e;
5371
+ }
5372
+ #ae = () => {
5373
+ this.hasAttribute(Oa) && (this.#ie() || this.removeAttribute(Oa));
5374
+ };
5375
+ #oe = () => {
5376
+ this.#j = null, this.#ue();
5377
+ };
5378
+ #se = (e) => {
5051
5379
  let t = e;
5052
- if (!t.isPrimary || t.button !== 0 || _a(t)) return;
5053
- let n = this.#q(t.clientX, t.clientY);
5380
+ if (!t.isPrimary || t.button !== 0 || (this.#S = t.pointerType, Ua(t))) return;
5381
+ let n = this.#Y(t.clientX, t.clientY);
5054
5382
  if (n) {
5055
5383
  this.#x = n, t.preventDefault(), t.isTrusted && this.setPointerCapture(t.pointerId);
5056
5384
  return;
5057
5385
  }
5058
- this.#k = {
5386
+ this.#j = {
5059
5387
  x: t.clientX,
5060
5388
  y: t.clientY
5061
- }, this.#D = !0, this.#$(!0);
5389
+ }, this.#k = !0, this.#ue(!0);
5062
5390
  };
5063
- #Z = (e) => {
5391
+ #ce = (e) => {
5064
5392
  if (e.isPrimary) {
5065
- if (this.#x) {
5066
- this.#H(this.#x.el), this.#x = null;
5393
+ if (this.#C = null, this.#x) {
5394
+ this.#W(this.#x.el), this.#x = null;
5067
5395
  return;
5068
5396
  }
5069
- (this.#D || this.#E) && (this.#D = !1, this.#E = null, this.#$(), this.#O && this.#fe());
5397
+ (this.#k || this.#O) && (this.#k = !1, this.#O = null, this.#ue(), this.#A && this.#Ce());
5070
5398
  }
5071
5399
  };
5072
- #Q = (e) => {
5073
- if (!this.#k) return;
5400
+ #le = (e) => {
5401
+ if (!this.#j) return;
5074
5402
  let t = e.target;
5075
- t instanceof HTMLElement && t.hasAttribute("data-mw-scroll") || (this.#M = null, this.#$());
5403
+ t instanceof HTMLElement && t.hasAttribute("data-mw-scroll") || (this.#P = null, this.#ue());
5076
5404
  };
5077
- #$(t = !1) {
5405
+ #ue(t = !1) {
5078
5406
  let n = this.#p, r = this.#f, i = [];
5079
- if (this.#k && n && r && this.isConnected && this.getAttribute("select") === "grid" && (this.#D || e.#N?.matches)) {
5080
- let { col: e, row: t } = this.#K(this.#k.x, this.#k.y, r);
5081
- this.#A = e, this.#j = t, i = Ce(n, e, t);
5082
- } else this.#A = NaN, this.#j = NaN;
5407
+ if (this.#j && n && r && this.isConnected && this.getAttribute("select") === "grid" && (this.#k || e.#F?.matches)) {
5408
+ let { col: e, row: t } = this.#J(this.#j.x, this.#j.y, r);
5409
+ this.#M = e, this.#N = t, i = br(n, e, t);
5410
+ } else this.#M = NaN, this.#N = NaN;
5083
5411
  let a = i.at(-1) ?? null;
5084
- t && (this.#E = a);
5085
- let o = e.#N?.matches ? i : [], s = this.#E ? i.indexOf(this.#E) : -1, c = s >= 0 ? i.slice(0, s + 1) : [], l = this.#ee("data-mw-hover", this.#w, o);
5086
- l = this.#ee("data-mw-active", this.#T, c) || l;
5412
+ t && (this.#O = a);
5413
+ let o = e.#F?.matches ? i : [], s = this.#O ? i.indexOf(this.#O) : -1, c = s >= 0 ? i.slice(0, s + 1) : [], l = this.#de("data-mw-hover", this.#E, o);
5414
+ l = this.#de("data-mw-active", this.#D, c) || l;
5087
5415
  let u = a ? getComputedStyle(a).cursor : "";
5088
- this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#fe();
5416
+ this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#Ce();
5089
5417
  }
5090
- #ee(e, t, n) {
5418
+ #de(e, t, n) {
5091
5419
  let r = !1, i = new Set(n);
5092
5420
  for (let n of t) i.has(n) || (n.removeAttribute(e), r = !0);
5093
5421
  for (let n of i) t.has(n) || (n.setAttribute(e, ""), r = !0);
@@ -5095,53 +5423,53 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
5095
5423
  for (let e of i) t.add(e);
5096
5424
  return r;
5097
5425
  }
5098
- #te = 0;
5099
- #ne = !1;
5100
- #re = 0;
5101
- #ie = (e) => {
5102
- ia.test(e.propertyName) && (this.#te++, this.#re = performance.now(), this.#oe());
5426
+ #fe = 0;
5427
+ #pe = !1;
5428
+ #me = 0;
5429
+ #he = (e) => {
5430
+ Aa.test(e.propertyName) && (this.#fe++, this.#me = performance.now(), this.#_e());
5103
5431
  };
5104
- #ae = (e) => {
5105
- ia.test(e.propertyName) && (this.#te = Math.max(0, this.#te - 1));
5432
+ #ge = (e) => {
5433
+ Aa.test(e.propertyName) && (this.#fe = Math.max(0, this.#fe - 1));
5106
5434
  };
5107
- #oe() {
5108
- if (this.#ne) return;
5109
- this.#ne = !0;
5435
+ #_e() {
5436
+ if (this.#pe) return;
5437
+ this.#pe = !0;
5110
5438
  let e = () => {
5111
- if (!this.isConnected || this.#te === 0 && !a() || performance.now() - this.#re > aa) {
5112
- this.#ne = !1, this.#te = 0, this.#fe();
5439
+ if (!this.isConnected || this.#fe === 0 && !a() || performance.now() - this.#me > ja) {
5440
+ this.#pe = !1, this.#fe = 0, this.#Ce();
5113
5441
  return;
5114
5442
  }
5115
- this.#de(), requestAnimationFrame(e);
5443
+ this.#Se(), requestAnimationFrame(e);
5116
5444
  };
5117
5445
  requestAnimationFrame(e);
5118
5446
  }
5119
- #se = (e) => {
5120
- if (!_a(e)) {
5447
+ #ve = (e) => {
5448
+ if (!Ua(e)) {
5121
5449
  if ((e.type === "focusin" || e.type === "focusout") && e.target instanceof HTMLSelectElement) {
5122
- this.#de();
5450
+ this.#Se();
5123
5451
  return;
5124
5452
  }
5125
- this.#fe();
5453
+ this.#Ce();
5126
5454
  }
5127
5455
  };
5128
5456
  attributeChangedCallback(e, t, n) {
5129
5457
  if (e === "select" && n !== "text" && n !== "grid") {
5130
- n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, ee(this)), this.setAttribute("select", na);
5458
+ n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, te(this)), this.setAttribute("select", Da);
5131
5459
  return;
5132
5460
  }
5133
- e === "select" && this.#$(), this.#fe();
5461
+ e === "select" && this.#ue(), this.#Ce();
5134
5462
  }
5135
5463
  toPlainText() {
5136
- return this.#d && this.#pe(), this.#p ? ir(this.#p) : "";
5464
+ return this.#d && this.#we(), this.#p ? ir(this.#p) : "";
5137
5465
  }
5138
- #ce = () => {
5139
- this.#fe();
5466
+ #ye = () => {
5467
+ this.#Ce();
5140
5468
  };
5141
- #le = () => {
5142
- requestAnimationFrame(() => this.#fe());
5469
+ #be = () => {
5470
+ requestAnimationFrame(() => this.#Ce());
5143
5471
  };
5144
- #ue() {
5472
+ #xe() {
5145
5473
  let e = document.activeElement;
5146
5474
  if (!(e instanceof HTMLSelectElement) || !this.contains(e)) return !1;
5147
5475
  try {
@@ -5150,25 +5478,25 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
5150
5478
  return !1;
5151
5479
  }
5152
5480
  }
5153
- #de() {
5481
+ #Se() {
5154
5482
  try {
5155
- this.#pe();
5483
+ this.#we();
5156
5484
  } catch (e) {
5157
5485
  console.error("[monowind] layout failed:", e);
5158
5486
  }
5159
5487
  }
5160
- #fe() {
5488
+ #Ce() {
5161
5489
  this.#d || (this.#d = !0, requestAnimationFrame(() => {
5162
- if (this.#d = !1, this.#ue()) {
5163
- this.#fe();
5490
+ if (this.#d = !1, this.#xe()) {
5491
+ this.#Ce();
5164
5492
  return;
5165
5493
  }
5166
- this.#de();
5494
+ this.#Se();
5167
5495
  }));
5168
5496
  }
5169
- #pe() {
5497
+ #we() {
5170
5498
  if (!this.isConnected) return;
5171
- let e = this.#L(), t = /* @__PURE__ */ new Map(), n = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), r = parseFloat(n);
5499
+ let e = this.#z(), t = /* @__PURE__ */ new Map(), n = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), r = parseFloat(n);
5172
5500
  if (Number.isFinite(r) && r > 0) for (let e of this.querySelectorAll("textarea")) {
5173
5501
  let n = getComputedStyle(e), i = e.clientWidth - (parseFloat(n.paddingLeft) || 0) - (parseFloat(n.paddingRight) || 0);
5174
5502
  t.set(e, Math.max(0, Math.round(i / r)));
@@ -5176,17 +5504,17 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
5176
5504
  this.setAttribute("measuring", "");
5177
5505
  try {
5178
5506
  this.#c.parentNode !== this && this.appendChild(this.#c);
5179
- let n = Te(this, this.#c), r = this.#f;
5507
+ let n = we(this, this.#c), r = this.#f;
5180
5508
  (r === null || r.width !== n.width || r.height !== n.height || r.letterSpacing !== n.letterSpacing || r.inkOverhang !== n.inkOverhang) && (this.style.setProperty("--mw-cw", `${n.width}px`), this.style.setProperty("--mw-ch", `${n.height}px`), this.style.setProperty("--mw-rls", `${n.letterSpacing}px`), this.style.setProperty("--mw-ink", `${n.inkOverhang ?? 0}px`)), this.#f = n;
5181
5509
  let i = getComputedStyle(this), a = (parseFloat(i.paddingLeft) || 0) + (parseFloat(i.paddingRight) || 0), o = Math.max(0, Math.floor((this.clientWidth - a) / n.width));
5182
5510
  if (o === 0) return;
5183
- let s = Ee(), c = [];
5511
+ let s = Te(), c = [];
5184
5512
  for (let e of Array.from(this.children)) {
5185
5513
  if (e === this.#c) continue;
5186
- let r = Ii(e, s, n, t);
5514
+ let r = oa(e, s, n, t);
5187
5515
  r && c.push(r);
5188
5516
  }
5189
- if (Zi(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${Qi}`, ee(this)), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), c.length === 0) {
5517
+ if (Sa(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${Ca}`, te(this)), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), c.length === 0) {
5190
5518
  this.#s.replaceChildren(), this.#p = null, this.setAttribute("data-mw-ready", "");
5191
5519
  return;
5192
5520
  }
@@ -5204,9 +5532,9 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
5204
5532
  height: 0
5205
5533
  },
5206
5534
  unclampedHeight: 0,
5207
- resolvedPadding: ot()
5208
- }, { height: u } = In(l, o);
5209
- Dr(l), this.#_ = va(l), this.#F(n, e), this.#O = !yr(l, this.#s, this.#D), this.#p = l;
5535
+ resolvedPadding: R()
5536
+ }, { height: u } = Fn(l, o);
5537
+ Zr(l), this.#_ = Ja(l), this.#L(n, e), this.#A = !Ur(l, this.#s, this.#k), this.#p = l;
5210
5538
  let d = `${l.localRect.width * n.width}px`, f = `${l.localRect.height * n.height}px`;
5211
5539
  this.#s.style.width !== d && (this.#s.style.width = d), this.#s.style.height !== f && (this.#s.style.height = f);
5212
5540
  let p = i.boxSizing === "border-box" ? (parseFloat(i.paddingTop) || 0) + (parseFloat(i.paddingBottom) || 0) + (parseFloat(i.borderTopWidth) || 0) + (parseFloat(i.borderBottomWidth) || 0) : 0, m = `${u * n.height + p}px`;
@@ -5214,28 +5542,43 @@ var ta = "\n<style>\n :host { display: block; position: relative; contain: layo
5214
5542
  let h = i.boxSizing === "border-box" ? a + (parseFloat(i.borderLeftWidth) || 0) + (parseFloat(i.borderRightWidth) || 0) : 0, g = `${o * n.width + h}px`;
5215
5543
  this.style.getPropertyValue("--mw-host-w") !== g && this.style.setProperty("--mw-host-w", g), this.hasAttribute("data-mw-ready") || this.setAttribute("data-mw-ready", "");
5216
5544
  } finally {
5217
- this.setAttribute("settling", ""), this.removeAttribute("measuring"), getComputedStyle(this).transitionProperty, this.removeAttribute("settling"), this.#R(e), this.#u?.takeRecords(), i(this) && (a() ? (this.#re = performance.now(), this.#oe()) : this.#fe()), this.#G(), this.#S = [];
5545
+ this.setAttribute("settling", ""), this.removeAttribute("measuring"), getComputedStyle(this).transitionProperty, this.removeAttribute("settling"), this.#B(e), this.#u?.takeRecords(), i(this) && (a() ? (this.#me = performance.now(), this.#_e()) : this.#Ce()), this.#q(), this.#w = [];
5218
5546
  let t = document.scrollingElement ?? document.documentElement;
5219
- for (let e = this.parentElement; e; e = e.parentElement) (e === t || /auto|scroll/.test(getComputedStyle(e).overflow)) && this.#S.push(e);
5220
- this.#M = null, this.#k && this.#$();
5547
+ for (let e = this.parentElement; e; e = e.parentElement) (e === t || /auto|scroll/.test(getComputedStyle(e).overflow)) && this.#w.push(e);
5548
+ this.#P = null, this.#j && this.#ue();
5221
5549
  }
5222
5550
  }
5223
5551
  };
5224
- function ma() {
5225
- typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", pa);
5552
+ function Ba() {
5553
+ typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", za);
5226
5554
  }
5227
- function ha(e, t, n, r, i) {
5228
- return ga(t === "y" ? e.scrollTop : e.scrollLeft, t === "y" ? e.scrollHeight - e.clientHeight : e.scrollWidth - e.clientWidth, n, r, i);
5555
+ function Va(e, t, n, r, i) {
5556
+ return Ha(t === "y" ? e.scrollTop : e.scrollLeft, t === "y" ? e.scrollHeight - e.clientHeight : e.scrollWidth - e.clientWidth, n, r, i);
5229
5557
  }
5230
- function ga(e, t, n, r, i) {
5558
+ function Ha(e, t, n, r, i) {
5231
5559
  if (r > 0 && e > 0 && e >= t - 1) return r;
5232
5560
  let a = e / n - i, o = Math.abs(a) <= .5 ? i : i + Math.sign(a) * Math.round(Math.abs(a));
5233
5561
  return Math.min(Math.max(0, o), r);
5234
5562
  }
5235
- function _a(e) {
5563
+ function Ua(e) {
5236
5564
  return e instanceof PointerEvent && e.pointerType === "touch" && e.type !== "pointerup";
5237
5565
  }
5238
- function va(e) {
5566
+ function Wa(e) {
5567
+ return e !== null && !(e instanceof Element && e.shadowRoot);
5568
+ }
5569
+ function Ga(e) {
5570
+ return {
5571
+ start: e,
5572
+ end: e
5573
+ };
5574
+ }
5575
+ function Ka(e, t, n) {
5576
+ e.setBaseAndExtent(t.node, t.offset, n.node, n.offset);
5577
+ }
5578
+ function qa(e, t) {
5579
+ return e.start.node === t.start.node && e.start.offset === t.start.offset && e.end.node === t.end.node && e.end.offset === t.end.offset;
5580
+ }
5581
+ function Ja(e) {
5239
5582
  let t = [], n = (e) => {
5240
5583
  e.scrollRange && t.push(e);
5241
5584
  for (let t of e.children) n(t);
@@ -5243,6 +5586,6 @@ function va(e) {
5243
5586
  return n(e), t;
5244
5587
  }
5245
5588
  //#endregion
5246
- export { pa as MonoWindElement, ma as defineMonoWind, ie as invalidateLeaves, Xt as multicolLines, x as registerBorderGlyphs, re as registerLeafRenderer, ir as renderPlainText, De as wrapLines };
5589
+ export { za as MonoWindElement, Ba as defineMonoWind, ae as invalidateLeaves, Yt as multicolLines, x as registerBorderGlyphs, ie as registerLeafRenderer, ir as renderPlainText, Ee as wrapLines };
5247
5590
 
5248
5591
  //# sourceMappingURL=index.js.map