monowind 0.2.2 → 0.2.3

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
@@ -344,49 +344,54 @@ x("blocks", {
344
344
  var M = /* @__PURE__ */ new WeakMap();
345
345
  function N(e, t) {
346
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}`, e));
347
+ n || M.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, ee(e)));
348
+ }
349
+ function ee(e) {
350
+ if (!globalThis.process?.versions?.node) return e;
351
+ let t = e.id ? `#${e.id}` : "", n = e.classList.length ? `.${Array.from(e.classList).join(".")}` : "";
352
+ return `<${e.tagName.toLowerCase()}${t}${n}>`;
348
353
  }
349
354
  //#endregion
350
355
  //#region src/leaf.ts
351
- var ee = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Set();
352
- function ne(e) {
356
+ var te = /* @__PURE__ */ new Map(), ne = /* @__PURE__ */ new Set();
357
+ function re(e) {
353
358
  let t = e.tag.toLowerCase();
354
359
  if (!t.includes("-")) {
355
360
  console.warn(`[monowind] registerLeafRenderer: "${e.tag}" is not a custom-element tag name (needs a hyphen); ignored.`);
356
361
  return;
357
362
  }
358
- ee.has(t) && console.warn(`[monowind] registerLeafRenderer: replacing existing renderer for <${t}> (last registration wins).`), ee.set(t, {
363
+ te.has(t) && console.warn(`[monowind] registerLeafRenderer: replacing existing renderer for <${t}> (last registration wins).`), te.set(t, {
359
364
  ...e,
360
365
  tag: t
361
- }), ce();
366
+ }), le();
362
367
  }
363
- function re() {
364
- ce();
368
+ function ie() {
369
+ le();
365
370
  }
366
- function ie(e) {
367
- return ee.get(e.toLowerCase());
371
+ function ae(e) {
372
+ return te.get(e.toLowerCase());
368
373
  }
369
- function ae() {
374
+ function oe() {
370
375
  let e = /* @__PURE__ */ new Set();
371
- for (let t of ee.values()) for (let n of t.observedAttributes ?? []) e.add(n.toLowerCase());
376
+ for (let t of te.values()) for (let n of t.observedAttributes ?? []) e.add(n.toLowerCase());
372
377
  return [...e];
373
378
  }
374
- function oe(e) {
375
- return te.add(e), () => te.delete(e);
379
+ function se(e) {
380
+ return ne.add(e), () => ne.delete(e);
376
381
  }
377
- function se(e, t) {
382
+ function ce(e, t) {
378
383
  try {
379
384
  return e.render(t);
380
385
  } catch (n) {
381
386
  return N(t, `<${e.tag}> renderer threw; rendering nothing. ${String(n)}`), null;
382
387
  }
383
388
  }
384
- function ce() {
385
- for (let e of te) e();
389
+ function le() {
390
+ for (let e of ne) e();
386
391
  }
387
392
  //#endregion
388
393
  //#region src/borders.ts
389
- function le(e, t, n) {
394
+ function ue(e, t, n) {
390
395
  let r = e.border;
391
396
  if (r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0) return;
392
397
  let i = Math.max(r.top, r.right, r.bottom, r.left);
@@ -402,11 +407,11 @@ function le(e, t, n) {
402
407
  width: t.width - (i.left ? a : 0) - (i.right ? a : 0),
403
408
  height: t.height - (i.top ? a : 0) - (i.bottom ? a : 0)
404
409
  };
405
- o.width <= 0 || o.height <= 0 || ue(n, e.borderStyle, e.borderColor, o, i, S(e.glyphSet));
410
+ o.width <= 0 || o.height <= 0 || de(n, e.borderStyle, e.borderColor, o, i, S(e.glyphSet));
406
411
  }
407
412
  }
408
- function ue(e, t, n, r, i, a) {
409
- let o = he(t.top, a), s = he(t.right, a), c = he(t.bottom, a), l = he(t.left, a), u = (e, t, n) => n(he(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 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;
410
415
  if (i.top && _ > g && e.push({
411
416
  glyph: o.h,
412
417
  x: g,
@@ -459,13 +464,13 @@ function ue(e, t, n, r, i, a) {
459
464
  color: n.bottom
460
465
  }));
461
466
  }
462
- function de(e, t) {
467
+ function fe(e, t) {
463
468
  return e.style.position !== "static" || (t.style.display === "flex" || t.style.display === "grid") && e.style.zIndex !== null;
464
469
  }
465
- function fe(e) {
470
+ function pe(e) {
466
471
  if (e.children.length <= 1) return e.children;
467
472
  let t = null, n = null, r = null, i = null;
468
- for (let a of e.children) de(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) fe(a, e) ? (a.style.zIndex ?? 0) < 0 ? (t ??= []).push(a) : (i ??= []).push(a) : a.inlineBox ? (r ??= []).push(a) : (n ??= []).push(a);
469
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 : [
470
475
  ...t ?? [],
471
476
  ...n ?? [],
@@ -473,11 +478,11 @@ function fe(e) {
473
478
  ...i ?? []
474
479
  ];
475
480
  }
476
- function pe(e, t, n) {
477
- let r = he(e, n);
481
+ function me(e, t, n) {
482
+ let r = ge(e, n);
478
483
  return t === "h" ? r.h : r.v;
479
484
  }
480
- function me(e, t, n, r, i, a) {
485
+ function he(e, t, n, r, i, a) {
481
486
  let o = (t ? 8 : 0) | (n ? 4 : 0) | (r ? 2 : 0) | !!i;
482
487
  if (a) {
483
488
  let t = w(o), n = t && a[e]?.[t];
@@ -485,8 +490,8 @@ function me(e, t, n, r, i, a) {
485
490
  }
486
491
  return (e === "double" ? E : T)[o];
487
492
  }
488
- function he(e, t) {
489
- let n = (n, r, i, a) => me(e, n, r, i, a, t), r = {
493
+ function ge(e, t) {
494
+ let n = (n, r, i, a) => he(e, n, r, i, a, t), r = {
490
495
  h: n(!1, !1, !0, !0),
491
496
  v: n(!0, !0, !1, !1),
492
497
  tl: n(!1, !0, !1, !0),
@@ -497,24 +502,24 @@ function he(e, t) {
497
502
  return e === "dashed" ? {
498
503
  h: "╌",
499
504
  v: "╎",
500
- ...ge(r),
501
- ..._e(t, e)
505
+ ..._e(r),
506
+ ...ve(t, e)
502
507
  } : e === "dotted" ? {
503
508
  h: "┄",
504
509
  v: "┊",
505
- ...ge(r),
506
- ..._e(t, e)
510
+ ..._e(r),
511
+ ...ve(t, e)
507
512
  } : r;
508
513
  }
509
- function ge(e) {
514
+ function _e(e) {
510
515
  let { h: t, v: n, ...r } = e;
511
516
  return r;
512
517
  }
513
- function _e(e, t) {
518
+ function ve(e, t) {
514
519
  let n = e?.[t], r = {};
515
520
  return n?.h && (r.h = n.h), n?.v && (r.v = n.v), r;
516
521
  }
517
- function ve(e, t, n, r) {
522
+ function ye(e, t, n, r) {
518
523
  let i = e.map((e) => e.spanned ? !1 : n === "between" ? e.beforeOccupied && e.afterOccupied : n !== "around" || e.beforeOccupied || e.afterOccupied), a = [];
519
524
  for (let n = 0; n < e.length; n++) if (a.push({
520
525
  start: e[n].start,
@@ -558,7 +563,7 @@ function ve(e, t, n, r) {
558
563
  end: e.end - r
559
564
  })).filter((e) => e.end > e.start);
560
565
  }
561
- function ye(e) {
566
+ function be(e) {
562
567
  let t = [], n = e.border.left + e.padding.left, r = e.border.top + e.padding.top, i = (e, t) => ({
563
568
  line: t.bandStart + Math.floor((t.bandSize - e.width) / 2),
564
569
  start: t.start,
@@ -567,7 +572,7 @@ function ye(e) {
567
572
  endHalf: t.endHalf === !0
568
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);
569
574
  if (e.ruleX) {
570
- let i = pe(e.ruleX.style, "v", e.glyphs);
575
+ let i = me(e.ruleX.style, "v", e.glyphs);
571
576
  for (let o of a) {
572
577
  for (let a = 0; a < s; a++) for (let s = o.start; s < o.end; s++) u(o.line + a, s) || t.push({
573
578
  glyph: i,
@@ -576,7 +581,7 @@ function ye(e) {
576
581
  length: 1,
577
582
  color: e.ruleX.color
578
583
  });
579
- be(e, t, "x", o.line, o.start, o.end);
584
+ xe(e, t, "x", o.line, o.start, o.end);
580
585
  }
581
586
  }
582
587
  if (e.ruleY) {
@@ -587,7 +592,7 @@ function ye(e) {
587
592
  for (let d = u.start; d < u.end; d++) {
588
593
  let u = l(a, s, d, f), p = l(a, s, d, f + 1);
589
594
  t.push({
590
- glyph: u || p ? me(i ? "double" : "solid", u, p, l(o, c, f, d), l(o, c, f, d + 1), e.glyphs) : pe(e.ruleY.style, "h", e.glyphs),
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),
591
596
  x: n + d,
592
597
  y: r + f,
593
598
  length: 1,
@@ -595,16 +600,16 @@ function ye(e) {
595
600
  });
596
601
  }
597
602
  }
598
- be(e, t, "y", u.line, u.start, u.end);
603
+ xe(e, t, "y", u.line, u.start, u.end);
599
604
  }
600
605
  }
601
606
  return t;
602
607
  }
603
- function be(e, t, n, r, i, a) {
608
+ function xe(e, t, n, r, i, a) {
604
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) => {
605
610
  let d = o.style === "double" && i === "double" ? "double" : "solid";
606
611
  t.push({
607
- glyph: me(d, s, c, l, u, e.glyphs),
612
+ glyph: he(d, s, c, l, u, e.glyphs),
608
613
  x: n,
609
614
  y: r,
610
615
  length: 1,
@@ -622,11 +627,11 @@ function be(e, t, n, r, i, a) {
622
627
  }
623
628
  //#endregion
624
629
  //#region src/pointer.ts
625
- function xe(e, t, n) {
630
+ function Se(e, t, n) {
626
631
  let r = [], i = e, a = e.localRect.x, o = e.localRect.y;
627
632
  for (;;) {
628
633
  let e = null;
629
- for (let r of fe(i)) {
634
+ for (let r of pe(i)) {
630
635
  if (r.tableHidden) continue;
631
636
  let i = a + r.localRect.x, s = o + r.localRect.y;
632
637
  t >= i && t < i + r.localRect.width && n >= s && n < s + r.localRect.height && (e = r);
@@ -639,8 +644,8 @@ function xe(e, t, n) {
639
644
  }), a += e.localRect.x - (e.scroll?.x ?? 0), o += e.localRect.y - (e.scroll?.y ?? 0), i = e;
640
645
  }
641
646
  }
642
- function Se(e, t, n) {
643
- return xe(e, t, n).map((e) => e.node.source);
647
+ function Ce(e, t, n) {
648
+ return Se(e, t, n).map((e) => e.node.source);
644
649
  }
645
650
  //#endregion
646
651
  //#region src/metrics.ts
@@ -650,10 +655,10 @@ function P(e) {
650
655
  function F(e, t) {
651
656
  return t <= 0 ? 0 : P(e / (.25 * t));
652
657
  }
653
- function Ce(e, t) {
658
+ function we(e, t) {
654
659
  return P(t * e / 100);
655
660
  }
656
- function we(e, t) {
661
+ function Te(e, t) {
657
662
  let n = t.getBoundingClientRect(), r = parseFloat(getComputedStyle(e).letterSpacing) || 0, i = t.ownerDocument.createRange();
658
663
  i.selectNodeContents(t);
659
664
  let a = Math.max(0, i.getBoundingClientRect().height - n.height);
@@ -664,56 +669,56 @@ function we(e, t) {
664
669
  inkOverhang: a
665
670
  };
666
671
  }
667
- function Te() {
672
+ function Ee() {
668
673
  return parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
669
674
  }
670
675
  //#endregion
671
676
  //#region src/wrap.ts
672
- function Ee(e, t, n = {}) {
673
- return Ae(e, t, n).map((t) => e.slice(t.start, t.end));
674
- }
675
677
  function De(e, t, n = {}) {
676
- return Ae(e, t, n).length;
678
+ return je(e, t, n).map((t) => e.slice(t.start, t.end));
679
+ }
680
+ function Oe(e, t, n = {}) {
681
+ return je(e, t, n).length;
677
682
  }
678
- function Oe(e, t) {
683
+ function ke(e, t) {
679
684
  return t.endsWith("\n") && e.pop(), e;
680
685
  }
681
- function ke(e) {
686
+ function Ae(e) {
682
687
  let t = [], n = 0;
683
688
  for (let r = 0; r <= e.length; r++) (r === e.length || e[r] === "\n") && (t.push({
684
689
  start: n,
685
690
  end: r
686
691
  }), n = r + 1);
687
- return Oe(t, e);
692
+ return ke(t, e);
688
693
  }
689
- function Ae(e, t, n = {}) {
694
+ function je(e, t, n = {}) {
690
695
  if (!/[^ \t\r\f]/.test(e)) return [];
691
696
  let r = [], i = 0, a = n.firstLineIndent ?? 0;
692
- 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);
693
- return Oe(r, e);
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);
694
699
  }
695
- function je(e, t, n) {
700
+ function Me(e, t, n) {
696
701
  if (!n) return t - e;
697
702
  let r = 0;
698
703
  for (let i = e; i < t; i++) r += n[i] ?? 1;
699
704
  return r;
700
705
  }
701
706
  function I(e, t, n, r = 0) {
702
- return t <= e ? 0 : je(e, t, n) - Math.min(r, Me(t - 1, n));
707
+ return t <= e ? 0 : Me(e, t, n) - Math.min(r, Ne(t - 1, n));
703
708
  }
704
- function Me(e, t) {
709
+ function Ne(e, t) {
705
710
  return t ? (t[e] ?? 1) - 1 : 0;
706
711
  }
707
- function Ne(e, t = {}) {
712
+ function Pe(e, t = {}) {
708
713
  let { advances: n, tracking: r = 0 } = t, i = 0;
709
- for (let t of Le(e, 0, e.length)) for (let a of Fe(e, t.start, t.end)) i = Math.max(i, I(a.start, a.end, n, r));
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));
710
715
  return i;
711
716
  }
712
- function Pe(e, t) {
717
+ function Fe(e, t) {
713
718
  let n = 0;
714
719
  for (let r = 0; r < e.length; r++) e[r] === "" && (t(r, n), n++);
715
720
  }
716
- function Fe(e, t, n) {
721
+ function Ie(e, t, n) {
717
722
  let r = [], i = t;
718
723
  for (let a = t; a < n; a++) {
719
724
  if (e[a] === "") {
@@ -740,14 +745,14 @@ function Fe(e, t, n) {
740
745
  end: n
741
746
  }), r;
742
747
  }
743
- var Ie = /[ \t\r\n\f]/;
744
- function Le(e, t, n) {
748
+ var Le = /[ \t\r\n\f]/;
749
+ function Re(e, t, n) {
745
750
  let r = [], i = t;
746
751
  for (; i < n;) {
747
- for (; i < n && Ie.test(e[i]);) i++;
752
+ for (; i < n && Le.test(e[i]);) i++;
748
753
  if (i >= n) break;
749
754
  let t = i;
750
- for (; i < n && !Ie.test(e[i]);) i++;
755
+ for (; i < n && !Le.test(e[i]);) i++;
751
756
  r.push({
752
757
  start: t,
753
758
  end: i
@@ -755,8 +760,8 @@ function Le(e, t, n) {
755
760
  }
756
761
  return r;
757
762
  }
758
- function Re(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
759
- let s = Le(e, t, n);
763
+ function ze(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
764
+ let s = Re(e, t, n);
760
765
  if (s.length === 0) return [{
761
766
  start: t,
762
767
  end: t
@@ -768,8 +773,8 @@ function Re(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
768
773
  let c = [], l = null, u = 0, d = Math.max(0, o), f = () => r - d;
769
774
  for (let t of s) {
770
775
  let n = !1;
771
- for (let r of Fe(e, t.start, t.end)) {
772
- 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));
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));
773
778
  if (l !== null && s - p <= f()) l.end = t, u = s;
774
779
  else {
775
780
  for (l !== null && (c.push(l), d = 0);;) {
@@ -784,7 +789,7 @@ function Re(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
784
789
  l = {
785
790
  start: e,
786
791
  end: t
787
- }, u = je(e, t, i);
792
+ }, u = Me(e, t, i);
788
793
  }
789
794
  n = !0;
790
795
  }
@@ -793,7 +798,7 @@ function Re(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
793
798
  }
794
799
  //#endregion
795
800
  //#region src/flex.ts
796
- function ze(e, t) {
801
+ function Be(e, t) {
797
802
  let n = e.row.map((e) => e.node.localRect).sort((e, t) => e.x - t.x), r = [];
798
803
  for (let e = 1; e < n.length; e++) {
799
804
  let i = n[e - 1].x + n[e - 1].width - t, a = n[e].x - t;
@@ -804,12 +809,12 @@ function ze(e, t) {
804
809
  }
805
810
  return r;
806
811
  }
807
- function Be(e, t, n, r, i) {
812
+ function Ve(e, t, n, r, i) {
808
813
  if (e.style.ruleBreak !== "intersection") return [{
809
814
  start: 0,
810
815
  end: i
811
816
  }];
812
- let a = [t[n - 1], t[n]].flatMap((e) => ze(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
817
+ let a = [t[n - 1], t[n]].flatMap((e) => Be(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
813
818
  start: e,
814
819
  end: t,
815
820
  spanned: !1,
@@ -817,24 +822,24 @@ function Be(e, t, n, r, i) {
817
822
  afterOccupied: !0
818
823
  }), s = [], c = 0;
819
824
  for (let e of a) e.start > c && s.push(o(c, e.start)), c = Math.max(c, e.end);
820
- return c < i && s.push(o(c, i)), ve(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
825
+ return c < i && s.push(o(c, i)), ye(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
821
826
  }
822
- function Ve(e, t) {
827
+ function He(e, t) {
823
828
  return typeof t != "number" || t <= 0 ? e : e.map((e) => ({
824
829
  ...e,
825
830
  start: e.start + t,
826
831
  end: e.end - t
827
832
  })).filter((e) => e.end > e.start);
828
833
  }
829
- function He(e, t, n, r, i, a, o) {
830
- let s = U(e.style, "x", t), c = U(e.style, "y", n), l = Xe(e).map((e) => {
834
+ function Ue(e, t, n, r, i, a, o) {
835
+ let s = U(e.style, "x", t), c = U(e.style, "y", n), l = Ze(e).map((e) => {
831
836
  let n = G(e.style.margin, t);
832
837
  return {
833
838
  node: e,
834
- base: Ye(e, t, o),
839
+ base: Xe(e, t, o),
835
840
  grow: e.style.flexGrow,
836
841
  shrink: e.style.flexShrink,
837
- min: $e(e, t, o),
842
+ min: et(e, t, o),
838
843
  max: K(e.style.maxWidth, t),
839
844
  margin: n
840
845
  };
@@ -848,7 +853,7 @@ function He(e, t, n, r, i, a, o) {
848
853
  n.length > 0 && u.push(n), e.style.wrapReverse && u.reverse();
849
854
  } else u.push(l);
850
855
  let d = i.left + a.left, f = i.top + a.top, p = u.map((e) => {
851
- 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, H(e.base, e.min, e.max))) : qe(e, a);
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, H(e.base, e.min, e.max))) : Je(e, a);
852
857
  for (let n = 0; n < e.length; n++) V(e[n].node, t, r, 0, 0, "fill", o, { width: u[n] });
853
858
  return {
854
859
  row: e,
@@ -859,7 +864,7 @@ function He(e, t, n, r, i, a, o) {
859
864
  }), m = p.map((e) => e.height), h = c * Math.max(0, p.length - 1), g;
860
865
  if (e.style.flexWrap === "nowrap") r === void 0 ? Number.isFinite(n) && (m[0] = Math.max(n, m[0] ?? 0)) : m[0] = r, g = [0];
861
866
  else {
862
- let t = m.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - h) : 0, i = Ze(e.style);
867
+ let t = m.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - h) : 0, i = Qe(e.style);
863
868
  if (i === "stretch" && r > 0) {
864
869
  let e = R(Array.from({ length: p.length }, () => 1), r);
865
870
  for (let t = 0; t < m.length; t++) m[t] += e[t];
@@ -869,7 +874,7 @@ function He(e, t, n, r, i, a, o) {
869
874
  for (let i = 0; i < p.length; i++) {
870
875
  let { row: a, widths: l, availableForItems: u } = p[i], h = m[i], _ = g[i] + i * c;
871
876
  for (let i = 0; i < a.length; i++) {
872
- 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";
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";
873
878
  if (c === "stretch" && !d && !f && h !== s.localRect.height) {
874
879
  let e = u.top ?? 0, a = u.bottom ?? 0, c = Number.isFinite(n) ? n : void 0, d = H(Math.max(0, h - e - a), K(s.style.minHeight, c) ?? 0, K(s.style.maxHeight, c));
875
880
  if (d === s.localRect.height) continue;
@@ -884,14 +889,14 @@ function He(e, t, n, r, i, a, o) {
884
889
  let e = R(Array.from({ length: b }, () => 1), y), t = 0;
885
890
  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++]);
886
891
  C = L("start", l, 0);
887
- } else C = L(Qe(e.style), l, y);
892
+ } else C = L($e(e.style), l, y);
888
893
  let w = 0;
889
894
  for (let t = 0; t < a.length; t++) {
890
895
  let n = a[t], r = n.node, i = n.margin.left ?? 0, o = n.margin.right ?? 0;
891
896
  w += x[t] + i, r.localRect = {
892
897
  ...r.localRect,
893
898
  x: d + C[t] + t * s + w,
894
- y: f + _ + Ge(r, e.style.alignItems, h, n.margin)
899
+ y: f + _ + Ke(r, e.style.alignItems, h, n.margin)
895
900
  }, w += S[t] + o;
896
901
  }
897
902
  }
@@ -900,7 +905,7 @@ function He(e, t, n, r, i, a, o) {
900
905
  let n = [], r = [];
901
906
  for (let i = 0; i < p.length; i++) {
902
907
  let a = g[i] + i * c;
903
- for (let e of ze(p[i], d)) n.push({
908
+ for (let e of Be(p[i], d)) n.push({
904
909
  bandStart: e.start,
905
910
  bandSize: e.end - e.start,
906
911
  start: a,
@@ -908,19 +913,19 @@ function He(e, t, n, r, i, a, o) {
908
913
  });
909
914
  if (i > 0) {
910
915
  let n = g[i - 1] + (i - 1) * c + m[i - 1];
911
- if (a > n) for (let o of Be(e, p, i, d, t)) r.push({
916
+ if (a > n) for (let o of Ve(e, p, i, d, t)) r.push({
912
917
  bandStart: n,
913
918
  bandSize: a - n,
914
919
  ...o
915
920
  });
916
921
  }
917
922
  }
918
- e.decorationRuns = ye({
923
+ e.decorationRuns = be({
919
924
  glyphs: S(e.style.glyphSet),
920
925
  ruleX: e.style.ruleX,
921
926
  ruleY: e.style.ruleY,
922
- vertical: Ve(n, e.style.ruleInset),
923
- horizontal: Ve(r, e.style.ruleInset),
927
+ vertical: He(n, e.style.ruleInset),
928
+ horizontal: He(r, e.style.ruleInset),
924
929
  contentWidth: t,
925
930
  contentHeight: v,
926
931
  border: i,
@@ -929,9 +934,9 @@ function He(e, t, n, r, i, a, o) {
929
934
  padding: a
930
935
  });
931
936
  }
932
- return Ue(e, i, a, t, v), v;
937
+ return We(e, i, a, t, v), v;
933
938
  }
934
- function Ue(e, t, n, r, i) {
939
+ function We(e, t, n, r, i) {
935
940
  for (let a of e.children) B(a.style) && (a.staticSlot = {
936
941
  kind: "flex",
937
942
  direction: e.style.flexDirection,
@@ -941,11 +946,11 @@ function Ue(e, t, n, r, i) {
941
946
  innerHeight: i
942
947
  });
943
948
  }
944
- function We(e, t, n, r, i, a, o) {
945
- let s = U(e.style, "y", n), c = Xe(e).map((i) => {
946
- let a = G(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = Je(i, e) === "stretch";
949
+ function Ge(e, t, n, r, i, a, o) {
950
+ let s = U(e.style, "y", n), c = Ze(e).map((i) => {
951
+ let a = G(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = Ye(i, e) === "stretch";
947
952
  V(i, s, r && Number.isFinite(n) ? n : void 0, 0, 0, c ? "fill" : "shrink", o);
948
- 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;
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;
949
954
  return {
950
955
  node: i,
951
956
  base: d,
@@ -955,9 +960,9 @@ function We(e, t, n, r, i, a, o) {
955
960
  max: K(i.style.maxHeight, l),
956
961
  margin: a
957
962
  };
958
- }), 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, H(e.base, e.min, e.max)));
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, H(e.base, e.min, e.max)));
959
964
  for (let n = 0; n < c.length; n++) if (g[n] !== c[n].node.localRect.height) {
960
- let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = Je(r.node, e) === "stretch";
965
+ let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = Ye(r.node, e) === "stretch";
961
966
  V(r.node, i, g[n], 0, 0, a ? "fill" : "shrink", o, { height: g[n] });
962
967
  }
963
968
  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;
@@ -965,13 +970,13 @@ function We(e, t, n, r, i, a, o) {
965
970
  let e = R(Array.from({ length: y }, () => 1), v), t = 0;
966
971
  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++]);
967
972
  C = L("start", g, 0);
968
- } else C = L(Qe(e.style), g, v);
973
+ } else C = L($e(e.style), g, v);
969
974
  let w = i.left + a.left, T = i.top + a.top, E = 0;
970
975
  for (let n = 0; n < c.length; n++) {
971
976
  let r = c[n], i = r.node, a = r.margin.top ?? 0, o = r.margin.bottom ?? 0;
972
977
  E += b[n] + a, i.localRect = {
973
978
  ...i.localRect,
974
- x: w + Ke(i, e.style.alignItems, t, r.margin),
979
+ x: w + qe(i, e.style.alignItems, t, r.margin),
975
980
  y: T + C[n] + n * s + E
976
981
  }, E += x[n] + o;
977
982
  }
@@ -987,12 +992,12 @@ function We(e, t, n, r, i, a, o) {
987
992
  end: t
988
993
  });
989
994
  }
990
- e.decorationRuns = ye({
995
+ e.decorationRuns = be({
991
996
  glyphs: S(e.style.glyphSet),
992
997
  ruleX: null,
993
998
  ruleY: e.style.ruleY,
994
999
  vertical: [],
995
- horizontal: Ve(n, e.style.ruleInset),
1000
+ horizontal: He(n, e.style.ruleInset),
996
1001
  contentWidth: t,
997
1002
  contentHeight: O,
998
1003
  border: i,
@@ -1001,13 +1006,13 @@ function We(e, t, n, r, i, a, o) {
1001
1006
  padding: a
1002
1007
  });
1003
1008
  }
1004
- return Ue(e, i, a, t, O), O;
1009
+ return We(e, i, a, t, O), O;
1005
1010
  }
1006
- function Ge(e, t, n, r) {
1011
+ function Ke(e, t, n, r) {
1007
1012
  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;
1008
1013
  return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + z(i, n, e.localRect.height);
1009
1014
  }
1010
- function Ke(e, t, n, r) {
1015
+ function qe(e, t, n, r) {
1011
1016
  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;
1012
1017
  return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + z(i, n, e.localRect.width);
1013
1018
  }
@@ -1029,7 +1034,7 @@ function L(e, t, n) {
1029
1034
  for (let e = 0; e < r; e++) i.push(a), a += t[e];
1030
1035
  return i;
1031
1036
  }
1032
- function qe(e, t) {
1037
+ function Je(e, t) {
1033
1038
  let n = e.length, r = (t, n) => Math.max(0, H(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);
1034
1039
  for (let t = 0; t < n; t++) {
1035
1040
  let n = r(i[t], t);
@@ -1064,36 +1069,36 @@ function R(e, t) {
1064
1069
  }
1065
1070
  return i;
1066
1071
  }
1067
- function Je(e, t) {
1072
+ function Ye(e, t) {
1068
1073
  return e.style.alignSelf === "auto" ? t.style.alignItems : e.style.alignSelf;
1069
1074
  }
1070
1075
  function z(e, t, n) {
1071
1076
  return e === "center" ? Math.max(0, Math.floor((t - n) / 2)) : e === "end" ? Math.max(0, t - n) : 0;
1072
1077
  }
1073
- function Ye(e, t, n) {
1078
+ function Xe(e, t, n) {
1074
1079
  let r = e.style.flexBasis, i = e.style.width;
1075
1080
  return r !== void 0 && r.kind !== "auto" ? q(r, t, e, n) : i !== void 0 && i.kind !== "auto" ? q(i, t, e, n) : J(e, n);
1076
1081
  }
1077
- function Xe(e) {
1082
+ function Ze(e) {
1078
1083
  let t = e.children.filter((e) => !B(e.style)).sort((e, t) => e.style.order - t.style.order);
1079
1084
  return e.style.flexReverse && t.reverse(), t;
1080
1085
  }
1081
- function Ze(e) {
1086
+ function Qe(e) {
1082
1087
  return e.wrapReverse ? e.alignContent === "start" ? "end" : e.alignContent === "end" ? "start" : e.alignContent : e.alignContent;
1083
1088
  }
1084
- function Qe(e) {
1089
+ function $e(e) {
1085
1090
  let t = e.justifyContent === "stretch" ? "start" : e.justifyContent;
1086
1091
  return e.flexReverse ? t === "start" ? "end" : t === "end" ? "start" : t : t;
1087
1092
  }
1088
- function $e(e, t, n) {
1093
+ function et(e, t, n) {
1089
1094
  return e.style.minWidth === "auto" ? e.style.overflow.x === "visible" ? Y(e, n) : 0 : K(e.style.minWidth, t) ?? 0;
1090
1095
  }
1091
1096
  //#endregion
1092
1097
  //#region src/types.ts
1093
- function et(e) {
1098
+ function tt(e) {
1094
1099
  return e === "auto" || e === "scroll";
1095
1100
  }
1096
- function tt(e) {
1101
+ function nt(e) {
1097
1102
  return e.scrollbarWidth === "none" ? {
1098
1103
  right: 0,
1099
1104
  bottom: 0
@@ -1102,7 +1107,7 @@ function tt(e) {
1102
1107
  bottom: e.overflow.x === "scroll" ? e.scrollbarSize.x : 0
1103
1108
  };
1104
1109
  }
1105
- function nt() {
1110
+ function rt() {
1106
1111
  return {
1107
1112
  display: "block",
1108
1113
  flexDirection: "row",
@@ -1121,8 +1126,8 @@ function nt() {
1121
1126
  justifySelf: "auto",
1122
1127
  gridTemplateColumns: { kind: "none" },
1123
1128
  gridTemplateRows: { kind: "none" },
1124
- gridAutoColumns: [it()],
1125
- gridAutoRows: [it()],
1129
+ gridAutoColumns: [at()],
1130
+ gridAutoRows: [at()],
1126
1131
  gridAutoFlow: {
1127
1132
  direction: "row",
1128
1133
  dense: !1
@@ -1138,7 +1143,7 @@ function nt() {
1138
1143
  minHeight: "auto",
1139
1144
  maxWidth: void 0,
1140
1145
  maxHeight: void 0,
1141
- padding: rt(),
1146
+ padding: it(),
1142
1147
  margin: {
1143
1148
  top: 0,
1144
1149
  right: 0,
@@ -1154,7 +1159,7 @@ function nt() {
1154
1159
  },
1155
1160
  gapX: 0,
1156
1161
  gapY: 0,
1157
- border: rt(),
1162
+ border: it(),
1158
1163
  borderStyle: {
1159
1164
  top: "solid",
1160
1165
  right: "solid",
@@ -1220,7 +1225,7 @@ function nt() {
1220
1225
  breakInsideAvoid: !1
1221
1226
  };
1222
1227
  }
1223
- function rt() {
1228
+ function it() {
1224
1229
  return {
1225
1230
  top: 0,
1226
1231
  right: 0,
@@ -1228,7 +1233,7 @@ function rt() {
1228
1233
  left: 0
1229
1234
  };
1230
1235
  }
1231
- function it() {
1236
+ function at() {
1232
1237
  return {
1233
1238
  min: { kind: "auto" },
1234
1239
  max: { kind: "auto" }
@@ -1236,15 +1241,15 @@ function it() {
1236
1241
  }
1237
1242
  //#endregion
1238
1243
  //#region src/grid.ts
1239
- function at(e, t, n, r, i, a) {
1240
- let o = e.style, s = Number.isFinite(n) ? n : void 0, c = e.subgrid?.cols, l = e.subgrid?.rows, u = c ? c.gap : U(o, "x", t), d = l ? l.gap : U(o, "y", s), f = ht(e, t, s, u, d, e.subgrid ? {
1244
+ function ot(e, t, n, r, i, a) {
1245
+ let o = e.style, s = Number.isFinite(n) ? n : void 0, c = e.subgrid?.cols, l = e.subgrid?.rows, u = c ? c.gap : U(o, "x", t), d = l ? l.gap : U(o, "y", s), f = gt(e, t, s, u, d, e.subgrid ? {
1241
1246
  col: e.subgrid.colSpan,
1242
1247
  row: e.subgrid.rowSpan
1243
- } : void 0), { children: p, placed: m, colLines: h, rowLines: g, colTracks: _, rowTracks: v, colCollapsed: y, rowCollapsed: b } = f, x = p.map((e) => G(e.style.margin, t)), C = p.map((e) => e.style.justifySelf === "auto" ? o.justifyItems : e.style.justifySelf), w = p.map(ot), T = c ? ct(c) : jt(_, y, lt(f, w, x, a), t, u, o.justifyContent === "stretch"), E = c ? c.positions : Mt(T, t, o.justifyContent), D = [];
1248
+ } : void 0), { children: p, placed: m, colLines: h, rowLines: g, colTracks: _, rowTracks: v, colCollapsed: y, rowCollapsed: b } = f, x = p.map((e) => G(e.style.margin, t)), C = p.map((e) => e.style.justifySelf === "auto" ? o.justifyItems : e.style.justifySelf), w = p.map(st), T = c ? lt(c) : Mt(_, y, ut(f, w, x, a), t, u, o.justifyContent === "stretch"), E = c ? c.positions : Nt(T, t, o.justifyContent), D = [];
1244
1249
  for (let e = 0; e < p.length; e++) {
1245
- let t = p[e], n = m.items[e], r = Pt(E, T.sizes, n.col.start, n.col.span), i = x[e], o = Math.max(0, r - yt(i)), s = w[e];
1250
+ 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 - bt(i)), s = w[e];
1246
1251
  if (s.cols || s.rows) {
1247
- let e = s.cols ? st(E, T, u, n.col.start, n.col.span, dt(t, "cols", i, r)) : void 0;
1252
+ let e = s.cols ? ct(E, T, u, n.col.start, n.col.span, ft(t, "cols", i, r)) : void 0;
1248
1253
  t.subgrid = {
1249
1254
  colSpan: n.col.span,
1250
1255
  rowSpan: n.row.span,
@@ -1253,12 +1258,12 @@ function at(e, t, n, r, i, a) {
1253
1258
  };
1254
1259
  } else t.subgrid = void 0;
1255
1260
  let c = C[e], l = i.left === null || i.right === null, d = t.style.width !== void 0 && t.style.width.kind !== "auto";
1256
- s.cols ? V(t, r, void 0, 0, 0, "fill", a, { width: o }) : c === "stretch" && !l && !d ? V(t, r, void 0, 0, 0, "fill", a, { width: H(o, t.style.minWidth === "auto" ? t.style.overflow.x === "visible" ? Y(t, a) : 0 : K(t.style.minWidth, r) ?? 0, Wn(t.style.maxWidth, r, t, a)) }) : V(t, o, void 0, 0, 0, "shrink", a), D.push(t.localRect.width);
1261
+ s.cols ? V(t, r, void 0, 0, 0, "fill", a, { width: o }) : c === "stretch" && !l && !d ? V(t, r, void 0, 0, 0, "fill", a, { width: H(o, t.style.minWidth === "auto" ? t.style.overflow.x === "visible" ? Y(t, a) : 0 : K(t.style.minWidth, r) ?? 0, Gn(t.style.maxWidth, r, t, a)) }) : V(t, o, void 0, 0, 0, "shrink", a), D.push(t.localRect.width);
1257
1262
  }
1258
- let O = l ? ct(l) : jt(v, b, ut(f, w, x), s ?? "max-content", d, o.alignContent === "stretch"), k = Nt(O), A = l ? l.positions : Mt(O, s ?? k, o.alignContent), j = r.left + i.left, M = r.top + i.top;
1263
+ let O = l ? lt(l) : Mt(v, b, dt(f, w, x), s ?? "max-content", d, o.alignContent === "stretch"), k = Pt(O), A = l ? l.positions : Nt(O, s ?? k, o.alignContent), j = r.left + i.left, M = r.top + i.top;
1259
1264
  for (let t = 0; t < p.length; t++) {
1260
- let n = p[t], r = m.items[t], i = x[t], o = Pt(E, T.sizes, r.col.start, r.col.span), s = Pt(A, O.sizes, r.row.start, r.row.span), c = Math.max(0, s - bt(i)), l = Je(n, e), u = i.top === null || i.bottom === null, f = n.style.height !== void 0 && n.style.height.kind !== "auto";
1261
- if (w[t].rows) n.subgrid.rows = st(A, O, d, r.row.start, r.row.span, dt(n, "rows", i, o)), V(n, o, s, 0, 0, "fill", a, {
1265
+ 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 - xt(i)), l = Ye(n, e), u = i.top === null || i.bottom === null, f = n.style.height !== void 0 && n.style.height.kind !== "auto";
1266
+ if (w[t].rows) n.subgrid.rows = ct(A, O, d, r.row.start, r.row.span, ft(n, "rows", i, o)), V(n, o, s, 0, 0, "fill", a, {
1262
1267
  width: D[t],
1263
1268
  height: c
1264
1269
  });
@@ -1271,8 +1276,8 @@ function at(e, t, n, r, i, a) {
1271
1276
  } else n.style.height?.kind === "percent" && V(n, o, s, 0, 0, "fill", a, { width: D[t] });
1272
1277
  n.localRect = {
1273
1278
  ...n.localRect,
1274
- x: j + E[r.col.start] + Ft(C[t], i.left, i.right, o, n.localRect.width),
1275
- y: M + A[r.row.start] + Ft(l, i.top, i.bottom, s, n.localRect.height)
1279
+ x: j + E[r.col.start] + It(C[t], i.left, i.right, o, n.localRect.width),
1280
+ y: M + A[r.row.start] + It(l, i.top, i.bottom, s, n.localRect.height)
1276
1281
  };
1277
1282
  }
1278
1283
  let N = Number.isFinite(n) ? Math.max(n, k) : k;
@@ -1289,7 +1294,7 @@ function at(e, t, n, r, i, a) {
1289
1294
  let r = [];
1290
1295
  for (let i = 1; i < e.length; i++) {
1291
1296
  let a = e[i - 1] + t[i - 1], s = e[i] - a;
1292
- if (!(s <= 0)) for (let e of ve(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
1297
+ if (!(s <= 0)) for (let e of ye(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
1293
1298
  bandStart: a,
1294
1299
  bandSize: s,
1295
1300
  ...e
@@ -1297,7 +1302,7 @@ function at(e, t, n, r, i, a) {
1297
1302
  }
1298
1303
  return r;
1299
1304
  }, 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));
1300
- e.decorationRuns = ye({
1305
+ e.decorationRuns = be({
1301
1306
  glyphs: S(o.glyphSet),
1302
1307
  ruleX: o.ruleX,
1303
1308
  ruleY: o.ruleY,
@@ -1325,7 +1330,7 @@ function at(e, t, n, r, i, a) {
1325
1330
  height: N
1326
1331
  };
1327
1332
  for (let n of ee) {
1328
- let r = pt(n.style.gridColumnStart, n.style.gridColumnEnd, h, m.colOrigin, E, T.sizes, -i.left, t + i.right), a = pt(n.style.gridRowStart, n.style.gridRowEnd, g, m.rowOrigin, A, O.sizes, -i.top, N + i.bottom);
1333
+ let r = mt(n.style.gridColumnStart, n.style.gridColumnEnd, h, m.colOrigin, E, T.sizes, -i.left, t + i.right), a = mt(n.style.gridRowStart, n.style.gridRowEnd, g, m.rowOrigin, A, O.sizes, -i.top, N + i.bottom);
1329
1334
  n.staticSlot = {
1330
1335
  kind: "grid",
1331
1336
  area: {
@@ -1340,14 +1345,14 @@ function at(e, t, n, r, i, a) {
1340
1345
  }
1341
1346
  return N;
1342
1347
  }
1343
- function ot(e) {
1348
+ function st(e) {
1344
1349
  let t = e.style.display === "grid";
1345
1350
  return {
1346
1351
  cols: t && e.style.gridTemplateColumns.kind === "subgrid",
1347
1352
  rows: t && e.style.gridTemplateRows.kind === "subgrid"
1348
1353
  };
1349
1354
  }
1350
- function st(e, t, n, r, i, a) {
1355
+ function ct(e, t, n, r, i, a) {
1351
1356
  let o = e[r] + a.start, s = t.sizes.slice(r, r + i);
1352
1357
  return s[0] = Math.max(0, s[0] - a.start), s[i - 1] = Math.max(0, s[i - 1] - a.end), {
1353
1358
  positions: Array.from({ length: i }, (t, n) => n === 0 ? 0 : e[r + n] - o),
@@ -1356,20 +1361,20 @@ function st(e, t, n, r, i, a) {
1356
1361
  gap: n
1357
1362
  };
1358
1363
  }
1359
- function ct(e) {
1364
+ function lt(e) {
1360
1365
  return {
1361
1366
  sizes: e.sizes,
1362
1367
  gapBefore: e.gapBefore,
1363
1368
  limits: e.sizes
1364
1369
  };
1365
1370
  }
1366
- function lt(e, t, n, r) {
1371
+ function ut(e, t, n, r) {
1367
1372
  let i = [];
1368
1373
  return e.children.forEach((a, o) => {
1369
1374
  let s = e.placed.items[o], c = n[o];
1370
1375
  if (t[o].cols) {
1371
- let e = dt(a, "cols", c, 0);
1372
- for (let t of ft(a, "cols", s, e, r)) i.push({
1376
+ let e = ft(a, "cols", c, 0);
1377
+ for (let t of pt(a, "cols", s, e, r)) i.push({
1373
1378
  ...t,
1374
1379
  start: t.start + s.col.start
1375
1380
  });
@@ -1378,24 +1383,24 @@ function lt(e, t, n, r) {
1378
1383
  i.push({
1379
1384
  start: s.col.start,
1380
1385
  span: s.col.span,
1381
- min: xt(a, "min", r) + yt(c),
1382
- max: xt(a, "max", r) + yt(c)
1386
+ min: St(a, "min", r) + bt(c),
1387
+ max: St(a, "max", r) + bt(c)
1383
1388
  });
1384
1389
  }), i;
1385
1390
  }
1386
- function ut(e, t, n) {
1391
+ function dt(e, t, n) {
1387
1392
  let r = [];
1388
1393
  return e.children.forEach((i, a) => {
1389
1394
  let o = e.placed.items[a], s = n[a];
1390
1395
  if (t[a].rows) {
1391
- let e = dt(i, "rows", s, 0);
1392
- for (let t of ft(i, "rows", o, e)) r.push({
1396
+ let e = ft(i, "rows", s, 0);
1397
+ for (let t of pt(i, "rows", o, e)) r.push({
1393
1398
  ...t,
1394
1399
  start: t.start + o.row.start
1395
1400
  });
1396
1401
  return;
1397
1402
  }
1398
- let c = i.localRect.height + bt(s), l = i.style.minHeight === "auto" && i.style.overflow.y !== "visible" ? bt(s) : c;
1403
+ let c = i.localRect.height + xt(s), l = i.style.minHeight === "auto" && i.style.overflow.y !== "visible" ? xt(s) : c;
1399
1404
  r.push({
1400
1405
  start: o.row.start,
1401
1406
  span: o.row.span,
@@ -1404,7 +1409,7 @@ function ut(e, t, n) {
1404
1409
  });
1405
1410
  }), r;
1406
1411
  }
1407
- function dt(e, t, n, r) {
1412
+ function ft(e, t, n, r) {
1408
1413
  let { border: i, padding: a } = e.style;
1409
1414
  return t === "cols" ? {
1410
1415
  start: (n.left ?? 0) + i.left + W(a.left, r),
@@ -1414,15 +1419,15 @@ function dt(e, t, n, r) {
1414
1419
  end: (n.bottom ?? 0) + i.bottom + W(a.bottom, r)
1415
1420
  };
1416
1421
  }
1417
- function ft(e, t, n, r, i) {
1418
- let a = t === "cols" ? n.col.span : n.row.span, o = ht(e, void 0, void 0, 0, 0, {
1422
+ function pt(e, t, n, r, i) {
1423
+ let a = t === "cols" ? n.col.span : n.row.span, o = gt(e, void 0, void 0, 0, 0, {
1419
1424
  col: n.col.span,
1420
1425
  row: n.row.span
1421
1426
  }), s = [];
1422
1427
  if (o.children.forEach((e, n) => {
1423
1428
  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 = G(e.style.margin, 0);
1424
- if (ot(e)[t]) {
1425
- let n = dt(e, t, p, 0), a = ft(e, t, c, {
1429
+ if (st(e)[t]) {
1430
+ let n = ft(e, t, p, 0), a = pt(e, t, c, {
1426
1431
  start: n.start + (u ? r.start : 0),
1427
1432
  end: n.end + (d ? r.end : 0)
1428
1433
  }, i);
@@ -1435,11 +1440,11 @@ function ft(e, t, n, r, i) {
1435
1440
  if (t === "cols") s.push({
1436
1441
  start: l.start,
1437
1442
  span: l.span,
1438
- min: xt(e, "min", i) + yt(p) + f,
1439
- max: xt(e, "max", i) + yt(p) + f
1443
+ min: St(e, "min", i) + bt(p) + f,
1444
+ max: St(e, "max", i) + bt(p) + f
1440
1445
  });
1441
1446
  else {
1442
- let t = e.localRect.height + bt(p) + f;
1447
+ let t = e.localRect.height + xt(p) + f;
1443
1448
  s.push({
1444
1449
  start: l.start,
1445
1450
  span: l.span,
@@ -1458,9 +1463,9 @@ function ft(e, t, n, r, i) {
1458
1463
  }
1459
1464
  return s;
1460
1465
  }
1461
- function pt(e, t, n, r, i, a, o, s) {
1462
- let c = Dt(e, "start", n), l = Dt(t, "end", n);
1463
- c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = Ot(c, t, 1, n) : l !== null && e.kind === "span" && (c = Ot(l, e, -1, n));
1466
+ function mt(e, t, n, r, i, a, o, s) {
1467
+ let c = Ot(e, "start", n), l = Ot(t, "end", n);
1468
+ 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));
1464
1469
  let u = i.length, d = (e) => {
1465
1470
  if (e === null) return;
1466
1471
  let t = e - r;
@@ -1471,22 +1476,22 @@ function pt(e, t, n, r, i, a, o, s) {
1471
1476
  end: h === void 0 ? s : p(h)
1472
1477
  };
1473
1478
  }
1474
- function mt(e, t) {
1479
+ function ht(e, t) {
1475
1480
  let n = t.gridIntrinsic.get(e);
1476
1481
  if (n !== void 0) return n;
1477
- let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = ht(e, void 0, void 0, i, 0, e.subgrid ? {
1482
+ let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = gt(e, void 0, void 0, i, 0, e.subgrid ? {
1478
1483
  col: e.subgrid.colSpan,
1479
1484
  row: e.subgrid.rowSpan
1480
- } : void 0), o = a.children.map(ot), s = a.children.map((e) => G(e.style.margin, 0)), c = jt(a.colTracks, a.colCollapsed, lt(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
1485
+ } : void 0), o = a.children.map(st), s = a.children.map((e) => G(e.style.margin, 0)), c = Mt(a.colTracks, a.colCollapsed, ut(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
1481
1486
  min: c.sizes.reduce((e, t) => e + t, 0) + l,
1482
1487
  max: c.limits.reduce((e, t) => e + t, 0) + l
1483
1488
  };
1484
1489
  return t.gridIntrinsic.set(e, u), u;
1485
1490
  }
1486
- function ht(e, t, n, r, i, a) {
1487
- let o = e.style, s = vt(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? gt(a.col) : St(o.gridTemplateColumns, t, r), d = l ? gt(a.row) : St(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
1491
+ function gt(e, t, n, r, i, a) {
1492
+ let o = e.style, s = yt(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? _t(a.col) : Ct(o.gridTemplateColumns, t, r), d = l ? _t(a.row) : Ct(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
1488
1493
  if (f) {
1489
- c || wt(p, u.lineNames, f.columns, o.gridAutoColumns), l || wt(m, d.lineNames, f.rows, o.gridAutoRows);
1494
+ c || Tt(p, u.lineNames, f.columns, o.gridAutoColumns), l || Tt(m, d.lineNames, f.rows, o.gridAutoRows);
1490
1495
  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`);
1491
1496
  }
1492
1497
  let h = {
@@ -1495,28 +1500,28 @@ function ht(e, t, n, r, i, a) {
1495
1500
  }, g = {
1496
1501
  explicitCount: m.length,
1497
1502
  names: d.lineNames
1498
- }, _ = At(s.map((e) => ({
1499
- col: kt(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1500
- row: kt(e.style.gridRowStart, e.style.gridRowEnd, g)
1503
+ }, _ = jt(s.map((e) => ({
1504
+ col: At(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1505
+ row: At(e.style.gridRowStart, e.style.gridRowEnd, g)
1501
1506
  })), p.length, m.length, o.gridAutoFlow);
1502
- return c && _t(_, "col", p.length), l && _t(_, "row", m.length), {
1507
+ return c && vt(_, "col", p.length), l && vt(_, "row", m.length), {
1503
1508
  children: s,
1504
1509
  placed: _,
1505
1510
  colLines: h,
1506
1511
  rowLines: g,
1507
- colTracks: Tt(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1508
- rowTracks: Tt(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1509
- colCollapsed: Et(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1510
- rowCollapsed: Et(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
1512
+ colTracks: Et(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1513
+ rowTracks: Et(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1514
+ colCollapsed: Dt(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1515
+ rowCollapsed: Dt(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
1511
1516
  };
1512
1517
  }
1513
- function gt(e) {
1518
+ function _t(e) {
1514
1519
  return {
1515
- tracks: Array.from({ length: e }, () => it()),
1520
+ tracks: Array.from({ length: e }, () => at()),
1516
1521
  lineNames: Array.from({ length: e + 1 }, () => [])
1517
1522
  };
1518
1523
  }
1519
- function _t(e, t, n) {
1524
+ function vt(e, t, n) {
1520
1525
  let r = t === "col" ? e.colOrigin : e.rowOrigin;
1521
1526
  for (let i of e.items) {
1522
1527
  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);
@@ -1524,22 +1529,22 @@ function _t(e, t, n) {
1524
1529
  }
1525
1530
  t === "col" ? (e.colOrigin = 0, e.colCount = n) : (e.rowOrigin = 0, e.rowCount = n);
1526
1531
  }
1527
- function vt(e) {
1532
+ function yt(e) {
1528
1533
  return e.children.filter((e) => !B(e.style) && !e.inlineBox).sort((e, t) => e.style.order - t.style.order);
1529
1534
  }
1530
- function yt(e) {
1535
+ function bt(e) {
1531
1536
  return (e.left ?? 0) + (e.right ?? 0);
1532
1537
  }
1533
- function bt(e) {
1538
+ function xt(e) {
1534
1539
  return (e.top ?? 0) + (e.bottom ?? 0);
1535
1540
  }
1536
- function xt(e, t, n) {
1541
+ function St(e, t, n) {
1537
1542
  let r = e.style, i;
1538
1543
  r.width !== void 0 && r.width.kind !== "auto" && r.width.kind !== "percent" && (i = q(r.width, 0, e, n)), i === void 0 && (i = t === "min" ? Y(e, n) : J(e, n));
1539
1544
  let a = typeof r.minWidth == "number" ? r.minWidth : 0, o = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
1540
1545
  return Math.max(0, H(i, a, o));
1541
1546
  }
1542
- function St(e, t, n) {
1547
+ function Ct(e, t, n) {
1543
1548
  if (e.kind !== "tracks") return {
1544
1549
  tracks: [],
1545
1550
  lineNames: [[]]
@@ -1552,7 +1557,7 @@ function St(e, t, n) {
1552
1557
  let { index: i, tracks: a, mode: o } = e.autoRepeat, s = 1;
1553
1558
  if (t !== void 0) {
1554
1559
  let e = a.reduce((e, n) => {
1555
- let r = Ct(n.min, t) ?? Ct(n.max, t) ?? 1;
1560
+ let r = wt(n.min, t) ?? wt(n.max, t) ?? 1;
1556
1561
  return e + Math.max(1, r);
1557
1562
  }, 0);
1558
1563
  s = Math.max(1, Math.floor((t + n) / (e + n * a.length)));
@@ -1580,23 +1585,23 @@ function St(e, t, n) {
1580
1585
  lineNames: d
1581
1586
  };
1582
1587
  }
1583
- function Ct(e, t) {
1588
+ function wt(e, t) {
1584
1589
  if (e.kind === "cells") return e.value;
1585
- if (e.kind === "percent" && t !== void 0) return Ce(e.value, t);
1590
+ if (e.kind === "percent" && t !== void 0) return we(e.value, t);
1586
1591
  if (e.kind === "math") {
1587
1592
  let n = [];
1588
1593
  for (let r of e.args) {
1589
- let e = Ct(r, t);
1594
+ let e = wt(r, t);
1590
1595
  if (e === void 0) return;
1591
1596
  n.push(e);
1592
1597
  }
1593
1598
  return e.fn === "min" ? Math.min(...n) : Math.max(...n);
1594
1599
  }
1595
1600
  }
1596
- function wt(e, t, n, r) {
1601
+ function Tt(e, t, n, r) {
1597
1602
  for (let i = e.length; i < n; i++) e.push(r[(i - e.length) % r.length]), t.push([]);
1598
1603
  }
1599
- function Tt(e, t, n, r) {
1604
+ function Et(e, t, n, r) {
1600
1605
  let i = [];
1601
1606
  for (let a = 0; a < n; a++) {
1602
1607
  let n = a + t;
@@ -1608,7 +1613,7 @@ function Tt(e, t, n, r) {
1608
1613
  }
1609
1614
  return i;
1610
1615
  }
1611
- function Et(e, t, n, r) {
1616
+ function Dt(e, t, n, r) {
1612
1617
  let i = Array.from({ length: n }, () => !1);
1613
1618
  if (!e.autoFit) return i;
1614
1619
  for (let a = e.autoFit.start; a < e.autoFit.end; a++) {
@@ -1617,7 +1622,7 @@ function Et(e, t, n, r) {
1617
1622
  }
1618
1623
  return i;
1619
1624
  }
1620
- function Dt(e, t, n) {
1625
+ function Ot(e, t, n) {
1621
1626
  if (e.kind === "line") return e.value > 0 ? e.value - 1 : n.explicitCount + 1 + e.value;
1622
1627
  if (e.kind !== "name") return null;
1623
1628
  if (e.nth === void 0) {
@@ -1632,14 +1637,14 @@ function Dt(e, t, n) {
1632
1637
  for (let t = i; t >= 0; t--) if (n.names[t].includes(e.name) && ++a === -r) return t;
1633
1638
  return -(-r - a);
1634
1639
  }
1635
- function Ot(e, t, n, r) {
1640
+ function kt(e, t, n, r) {
1636
1641
  if (t.name === void 0) return e + n * t.value;
1637
1642
  let i = t.value, a = e;
1638
1643
  for (; i > 0;) a += n, (!(a >= 0 && a <= r.explicitCount) || r.names[a].includes(t.name)) && i--;
1639
1644
  return a;
1640
1645
  }
1641
- function kt(e, t, n) {
1642
- let r = Dt(e, "start", n), i = Dt(t, "end", n);
1646
+ function At(e, t, n) {
1647
+ let r = Ot(e, "start", n), i = Ot(t, "end", n);
1643
1648
  if (r !== null && i !== null) return r === i ? {
1644
1649
  start: r,
1645
1650
  span: 1
@@ -1649,10 +1654,10 @@ function kt(e, t, n) {
1649
1654
  };
1650
1655
  if (r !== null) return {
1651
1656
  start: r,
1652
- span: (t.kind === "span" ? Ot(r, t, 1, n) : r + 1) - r
1657
+ span: (t.kind === "span" ? kt(r, t, 1, n) : r + 1) - r
1653
1658
  };
1654
1659
  if (i !== null) {
1655
- let t = e.kind === "span" ? Ot(i, e, -1, n) : i - 1;
1660
+ let t = e.kind === "span" ? kt(i, e, -1, n) : i - 1;
1656
1661
  return {
1657
1662
  start: t,
1658
1663
  span: i - t
@@ -1663,7 +1668,7 @@ function kt(e, t, n) {
1663
1668
  span: e.kind === "span" ? e.value : t.kind === "span" ? t.value : 1
1664
1669
  };
1665
1670
  }
1666
- function At(e, t, n, r) {
1671
+ function jt(e, t, n, r) {
1667
1672
  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);
1668
1673
  for (let t = 0; t < e.length; t++) {
1669
1674
  let e = o[t];
@@ -1760,7 +1765,7 @@ function At(e, t, n, r) {
1760
1765
  rowCount: S
1761
1766
  };
1762
1767
  }
1763
- function jt(e, t, n, r, i, a) {
1768
+ function Mt(e, t, n, r, i, a) {
1764
1769
  let o = typeof r == "number" ? r : void 0, s = e.map((e, n) => {
1765
1770
  if (t[n]) return {
1766
1771
  base: 0,
@@ -1770,7 +1775,7 @@ function jt(e, t, n, r, i, a) {
1770
1775
  frFactor: 0,
1771
1776
  collapsed: !0
1772
1777
  };
1773
- let r = Ct(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1778
+ let r = wt(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1774
1779
  if (s.kind === "fr") return {
1775
1780
  base: i,
1776
1781
  limit: null,
@@ -1779,7 +1784,7 @@ function jt(e, t, n, r, i, a) {
1779
1784
  frFactor: s.value,
1780
1785
  collapsed: !1
1781
1786
  };
1782
- let c = Ct(s, o);
1787
+ let c = wt(s, o);
1783
1788
  return c === void 0 ? {
1784
1789
  base: i,
1785
1790
  limit: null,
@@ -1904,65 +1909,65 @@ function jt(e, t, n, r, i, a) {
1904
1909
  limits: s.map((e) => u(e))
1905
1910
  };
1906
1911
  }
1907
- function Mt(e, t, n) {
1908
- let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - Nt(e)), o = L(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1912
+ function Nt(e, t, n) {
1913
+ let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - Pt(e)), o = L(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1909
1914
  for (let e = 0; e < r.length; e++) c += i[e], s.push(o[e] + c);
1910
1915
  return s;
1911
1916
  }
1912
- function Nt(e) {
1917
+ function Pt(e) {
1913
1918
  return e.sizes.reduce((e, t) => e + t, 0) + e.gapBefore.reduce((e, t) => e + t, 0);
1914
1919
  }
1915
- function Pt(e, t, n, r) {
1920
+ function Ft(e, t, n, r) {
1916
1921
  let i = n + r - 1;
1917
1922
  return e[n] === void 0 || e[i] === void 0 ? 0 : e[i] + t[i] - e[n];
1918
1923
  }
1919
- function Ft(e, t, n, r, i) {
1924
+ function It(e, t, n, r, i) {
1920
1925
  let a = t ?? 0, o = n ?? 0, s = r - i;
1921
1926
  return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + z(e, r, i + a + o);
1922
1927
  }
1923
1928
  //#endregion
1924
1929
  //#region src/multicol.ts
1925
- function It(e, t, n) {
1930
+ function Lt(e, t, n) {
1926
1931
  let r = e.columnWidth === null ? null : Math.max(1, Math.floor((t + n) / (e.columnWidth + n)));
1927
1932
  return e.columnCount !== null && r !== null ? Math.max(1, Math.min(e.columnCount, r)) : r === null ? Math.max(1, e.columnCount ?? 1) : r;
1928
1933
  }
1929
- function Lt(e, t, n) {
1930
- let r = It(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r)), a = Math.max(0, t - (r * i + (r - 1) * n));
1934
+ function Rt(e, t, n) {
1935
+ 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));
1931
1936
  return Array.from({ length: r }, (e, t) => i + +(t < a));
1932
1937
  }
1933
- function Rt(e, t) {
1938
+ function zt(e, t) {
1934
1939
  let n = Math.max(typeof e.gapX == "number" ? e.gapX : 0, e.ruleX?.width ?? 0);
1935
1940
  return e.columnCount === null ? Math.max(e.columnWidth ?? 1, t) : e.columnCount * t + (e.columnCount - 1) * n;
1936
1941
  }
1937
- function zt(e, t) {
1942
+ function Bt(e, t) {
1938
1943
  return e === void 0 ? t : t === void 0 ? e : Math.min(e, t);
1939
1944
  }
1940
- function Bt(e, t, n) {
1945
+ function Vt(e, t, n) {
1941
1946
  for (; e < t;) {
1942
1947
  let r = e + t >> 1;
1943
1948
  n(r) ? t = r : e = r + 1;
1944
1949
  }
1945
1950
  return e;
1946
1951
  }
1947
- function Vt(e, t, n) {
1948
- let r = It(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1952
+ function Ht(e, t, n) {
1953
+ let r = Lt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1949
1954
  return {
1950
1955
  count: r,
1951
1956
  width: i,
1952
1957
  leftover: Math.max(0, t - (r * i + (r - 1) * n))
1953
1958
  };
1954
1959
  }
1955
- function Ht(e, t, n) {
1960
+ function Ut(e, t, n) {
1956
1961
  return e === "all" ? !0 : e === "around" ? t || n : t && n;
1957
1962
  }
1958
- function Ut(e, t, n, r) {
1959
- let i = Vn(e, Math.max(1, t.width - e.style.tracking)), { heights: a, textOffsets: o } = Hn(e, i), s = e.style.lineGap, c = Gt(a.map((e) => e + s)), l;
1963
+ function Wt(e, t, n, r) {
1964
+ 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;
1960
1965
  if (e.style.columnFill === "auto" && r !== void 0) l = Math.max(1, r);
1961
1966
  else {
1962
- let e = Bt(c.reduce((e, t) => Math.max(e, t.rows - s), 1), Math.max(1, c.reduce((e, t) => e + t.rows, 0) - s), (e) => Wt(c, s, e).columns <= t.count);
1967
+ 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);
1963
1968
  l = r === void 0 ? e : Math.max(1, Math.min(e, r));
1964
1969
  }
1965
- let u = Wt(c, s, l);
1970
+ let u = Gt(c, s, l);
1966
1971
  return {
1967
1972
  spans: i,
1968
1973
  lineY: u.top,
@@ -1975,7 +1980,7 @@ function Ut(e, t, n, r) {
1975
1980
  columnsUsed: i.length > 0 ? u.columns : 0
1976
1981
  };
1977
1982
  }
1978
- function Wt(e, t, n, r = "truncate") {
1983
+ function Gt(e, t, n, r = "truncate") {
1979
1984
  let i = 0, a = 0, o = 0, s = [], c = [];
1980
1985
  for (let l = 0; l < e.length; l++) {
1981
1986
  let u = e[l], d = r === "glue" || l === 0 || a > 0 ? u.pre : 0;
@@ -1996,7 +2001,7 @@ function Wt(e, t, n, r = "truncate") {
1996
2001
  top: c
1997
2002
  };
1998
2003
  }
1999
- function Gt(e) {
2004
+ function Kt(e) {
2000
2005
  return e.map((e) => ({
2001
2006
  rows: e,
2002
2007
  pre: 0,
@@ -2005,27 +2010,27 @@ function Gt(e) {
2005
2010
  lines: 1
2006
2011
  }));
2007
2012
  }
2008
- var Kt = null;
2009
- function qt() {
2010
- if (Kt !== null) return Kt;
2013
+ var qt = null;
2014
+ function Jt() {
2015
+ if (qt !== null) return qt;
2011
2016
  let e = document.createElement("div");
2012
2017
  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);
2013
2018
  let t = e.getBoundingClientRect().top, n = e.querySelector("span").getBoundingClientRect();
2014
- return e.remove(), Kt = !(n.width > 0 && n.top - t >= 10), Kt;
2019
+ return e.remove(), qt = !(n.width > 0 && n.top - t >= 10), qt;
2015
2020
  }
2016
- function Jt(e, t) {
2017
- 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), {
2021
+ function Yt(e, t) {
2022
+ 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), {
2018
2023
  advances: s,
2019
2024
  tracking: i,
2020
2025
  firstLineIndent: t.firstLineIndent
2021
- }), l = Gt(c.map(() => 1 + a)), u = Wt(l, a, o ?? Bt(1, Math.max(1, c.length * (1 + a) - a), (e) => Wt(l, a, e).columns <= r));
2026
+ }), 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));
2022
2027
  return c.map((t, n) => ({
2023
2028
  text: e.slice(t.start, t.end),
2024
2029
  column: u.column[n],
2025
2030
  top: u.top[n]
2026
2031
  }));
2027
2032
  }
2028
- function Yt(e, t, n, r) {
2033
+ function Xt(e, t, n, r) {
2029
2034
  let i = e.style;
2030
2035
  if (!i.ruleX) return;
2031
2036
  let a = t.columnCount * t.columnWidth + (t.columnCount - 1) * t.gap, o = t.ruleSegments ?? [{
@@ -2035,18 +2040,18 @@ function Yt(e, t, n, r) {
2035
2040
  }], s = [];
2036
2041
  for (let e of o) {
2037
2042
  let n = Math.min(e.columns, t.columnCount);
2038
- for (let r = 0; r < t.columnCount - 1; r++) Ht(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
2043
+ for (let r = 0; r < t.columnCount - 1; r++) Ut(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
2039
2044
  bandStart: (r + 1) * t.columnWidth + r * t.gap,
2040
2045
  bandSize: t.gap,
2041
2046
  start: e.start,
2042
2047
  end: e.end
2043
2048
  });
2044
2049
  }
2045
- e.decorationRuns = ye({
2050
+ e.decorationRuns = be({
2046
2051
  glyphs: S(i.glyphSet),
2047
2052
  ruleX: i.ruleX,
2048
2053
  ruleY: null,
2049
- vertical: Ve(s, i.ruleInset),
2054
+ vertical: He(s, i.ruleInset),
2050
2055
  horizontal: [],
2051
2056
  contentWidth: a,
2052
2057
  contentHeight: t.totalRows,
@@ -2056,12 +2061,12 @@ function Yt(e, t, n, r) {
2056
2061
  padding: r
2057
2062
  });
2058
2063
  }
2059
- function Xt(e, t) {
2064
+ function Zt(e, t) {
2060
2065
  let n = e.style, r = n.padding;
2061
2066
  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;
2062
2067
  }
2063
- function Zt(e, t, n, r, i, a, o) {
2064
- let s = e.style, c = U(s, "x", n), l = Vt(s, n, c);
2068
+ function Qt(e, t, n, r, i, a, o) {
2069
+ let s = e.style, c = U(s, "x", n), l = Ht(s, n, c);
2065
2070
  a.right += l.leftover;
2066
2071
  let u = s.lineGap, d = i.left + a.left, f = i.top + a.top, p = n - l.leftover, m = [[]], h = [];
2067
2072
  for (let e of t) e.style.columnSpan ? (h[m.length - 1] = e, m.push([])) : m[m.length - 1].push(e);
@@ -2071,13 +2076,13 @@ function Zt(e, t, n, r, i, a, o) {
2071
2076
  if (t.length > 0) {
2072
2077
  let i = t.map((e) => ({
2073
2078
  node: e,
2074
- spans: Vn(e, Math.max(1, l.width - e.style.tracking)),
2079
+ spans: Hn(e, Math.max(1, l.width - e.style.tracking)),
2075
2080
  margin: G(e.style.margin, l.width),
2076
2081
  pre: 0,
2077
2082
  post: 0
2078
2083
  })), a = [], o = null, h = null, x = !1;
2079
2084
  for (let e of i) {
2080
- let { node: t, spans: n, margin: r } = e, i = o === null ? r.top ?? 0 : qn(o, r.top ?? 0), s = i;
2085
+ let { node: t, spans: n, margin: r } = e, i = o === null ? r.top ?? 0 : Jn(o, r.top ?? 0), s = i;
2081
2086
  _ === "glue" && h !== null ? (s = 0, h.post = i, a[a.length - 1].post = i) : e.pre = i;
2082
2087
  let c = x || t.style.breakBeforeColumn;
2083
2088
  if (t.style.breakInsideAvoid && n.length > 0) a.push({
@@ -2100,10 +2105,10 @@ function Zt(e, t, n, r, i, a, o) {
2100
2105
  let S;
2101
2106
  if (s.columnFill === "auto" && r !== void 0) S = Math.max(1, r);
2102
2107
  else {
2103
- let e = Bt(1, Math.max(1, Wt(a, u, Infinity, _).maxUsed), (e) => Wt(a, u, e, _).columns <= l.count);
2108
+ let e = Vt(1, Math.max(1, Gt(a, u, Infinity, _).maxUsed), (e) => Gt(a, u, e, _).columns <= l.count);
2104
2109
  S = r === void 0 ? e : Math.max(1, Math.min(e, r));
2105
2110
  }
2106
- let C = Wt(a, u, S, _);
2111
+ let C = Gt(a, u, S, _);
2107
2112
  for (let e = 0, t = 0; e < i.length; e++) {
2108
2113
  let { node: n, spans: r, margin: a, pre: o, post: s } = i[e], u = [], m = [];
2109
2114
  for (let e = 0; e < r.length; e++, t++) u.push(y + C.top[t]), m.push(C.column[t] * (l.width + c));
@@ -2144,7 +2149,7 @@ function Zt(e, t, n, r, i, a, o) {
2144
2149
  if (i) {
2145
2150
  let e = G(i.style.margin, p), t = (e.left ?? 0) + (e.right ?? 0);
2146
2151
  V(i, Math.max(0, p - t), void 0, 0, 0, "fill", o);
2147
- let r = Kn(e, p, i.localRect.width), a = (e.top ?? 0) + n;
2152
+ let r = qn(e, p, i.localRect.width), a = (e.top ?? 0) + n;
2148
2153
  y += a, i.localRect = {
2149
2154
  ...i.localRect,
2150
2155
  x: d + r,
@@ -2183,10 +2188,10 @@ function Zt(e, t, n, r, i, a, o) {
2183
2188
  } : {}
2184
2189
  }, x;
2185
2190
  }
2186
- function Qt(e, t, n, r, i, a, o) {
2187
- let s = e.style, c = zt(n, r), l = e.children.filter((e) => !B(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);
2188
- if (u.length > 0 && u.every((e) => Xt(e, s)) && (u.length === l.length || s.columnFill === "balance" && c === void 0 && (qt() || 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 Zt(e, l, t, c, i, a, o);
2189
- let f = U(s, "x", t), p = Lt(s, t, f), m = p.length, h = [];
2191
+ function $t(e, t, n, r, i, a, o) {
2192
+ let s = e.style, c = Bt(n, r), l = e.children.filter((e) => !B(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);
2193
+ 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);
2194
+ let f = U(s, "x", t), p = Rt(s, t, f), m = p.length, h = [];
2190
2195
  {
2191
2196
  let e = 0;
2192
2197
  for (let t of p) h.push(e), e += t + f;
@@ -2195,7 +2200,7 @@ function Qt(e, t, n, r, i, a, o) {
2195
2200
  let r = 0, i = 0, a = null, s = 0, c = (e) => {
2196
2201
  if (t) for (let t of T) {
2197
2202
  if (t.index !== e) continue;
2198
- let n = a === null ? t.margin.top ?? 0 : qn(a, t.margin.top ?? 0);
2203
+ let n = a === null ? t.margin.top ?? 0 : Jn(a, t.margin.top ?? 0);
2199
2204
  t.child.staticSlot = {
2200
2205
  kind: "block",
2201
2206
  x: y + g(r) + (t.margin.left ?? 0),
@@ -2206,7 +2211,7 @@ function Qt(e, t, n, r, i, a, o) {
2206
2211
  for (let l = 0; l < w.length; l++) {
2207
2212
  let u = w[l];
2208
2213
  c(l);
2209
- let d = a === null ? l === 0 ? u.margin.top ?? 0 : 0 : qn(a, u.margin.top ?? 0), f = u.node.localRect.height;
2214
+ let d = a === null ? l === 0 ? u.margin.top ?? 0 : 0 : Jn(a, u.margin.top ?? 0), f = u.node.localRect.height;
2210
2215
  if (a !== null && (u.breakBefore || i + d + f > e) && (r += 1, i = 0, a = null, d = 0), t) {
2211
2216
  let e = u.node, t = _(r);
2212
2217
  if (t !== v) {
@@ -2215,7 +2220,7 @@ function Qt(e, t, n, r, i, a, o) {
2215
2220
  }
2216
2221
  e.localRect = {
2217
2222
  ...e.localRect,
2218
- x: y + g(r) + Kn(u.margin, t, e.localRect.width),
2223
+ x: y + g(r) + qn(u.margin, t, e.localRect.width),
2219
2224
  y: b + C + i + d
2220
2225
  };
2221
2226
  }
@@ -2238,13 +2243,13 @@ function Qt(e, t, n, r, i, a, o) {
2238
2243
  let e = c === void 0 ? void 0 : Math.max(1, c - C), t = s.columnFill === "auto" && e !== void 0, r;
2239
2244
  if (t) r = e;
2240
2245
  else {
2241
- let t = Bt(1, D(Infinity, !1).maxUsed, (e) => D(e, !1).columns <= m);
2246
+ let t = Vt(1, D(Infinity, !1).maxUsed, (e) => D(e, !1).columns <= m);
2242
2247
  r = e === void 0 ? t : Math.min(t, e);
2243
2248
  }
2244
2249
  let i = D(r, !0), a = t && n !== void 0 ? Math.max(i.maxUsed, r) : i.maxUsed;
2245
2250
  if (s.ruleX) for (let e = 0; e < m - 1; e++) {
2246
2251
  let t = Math.min(i.columns, m);
2247
- Ht(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2252
+ Ut(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2248
2253
  bandStart: h[e] + p[e],
2249
2254
  bandSize: f,
2250
2255
  start: C,
@@ -2267,7 +2272,7 @@ function Qt(e, t, n, r, i, a, o) {
2267
2272
  let e = G(r.style.margin, t), i = (e.left ?? 0) + (e.right ?? 0);
2268
2273
  V(r, Math.max(0, t - i), n, 0, 0, "fill", o), C += e.top ?? 0, r.localRect = {
2269
2274
  ...r.localRect,
2270
- x: y + Kn(e, t, r.localRect.width),
2275
+ x: y + qn(e, t, r.localRect.width),
2271
2276
  y: b + C
2272
2277
  }, C += r.localRect.height + (e.bottom ?? 0);
2273
2278
  continue;
@@ -2279,11 +2284,11 @@ function Qt(e, t, n, r, i, a, o) {
2279
2284
  breakBefore: E || r.style.breakBeforeColumn
2280
2285
  }), E = r.style.breakAfterColumn;
2281
2286
  }
2282
- return O(), s.ruleX && x.length > 0 && (e.decorationRuns = ye({
2287
+ return O(), s.ruleX && x.length > 0 && (e.decorationRuns = be({
2283
2288
  glyphs: S(s.glyphSet),
2284
2289
  ruleX: s.ruleX,
2285
2290
  ruleY: null,
2286
- vertical: Ve(x, s.ruleInset),
2291
+ vertical: He(x, s.ruleInset),
2287
2292
  horizontal: [],
2288
2293
  contentWidth: t,
2289
2294
  contentHeight: C,
@@ -2295,32 +2300,32 @@ function Qt(e, t, n, r, i, a, o) {
2295
2300
  }
2296
2301
  //#endregion
2297
2302
  //#region src/table.ts
2298
- function $t(e, t) {
2303
+ function en(e, t) {
2299
2304
  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).");
2300
2305
  }
2301
- function en(e, t) {
2306
+ function tn(e, t) {
2302
2307
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
2303
2308
  return Number.isNaN(n) ? 1 : t === "colspan" ? Math.min(1e3, Math.max(1, n)) : Math.min(65534, Math.max(0, n));
2304
2309
  }
2305
- function tn(e, t, n) {
2310
+ function nn(e, t, n) {
2306
2311
  let r = (t, r) => {
2307
2312
  let i = t.style.width, a = i && i.kind !== "auto" && i.kind !== "percent" ? q(i, 0, t, n) : void 0, o = i && i.kind === "percent" ? i.value : void 0;
2308
2313
  for (let t = 0; t < r; t++) e.colFixed.push(a), e.colPercent.push(o);
2309
2314
  };
2310
2315
  if (t.style.tableRole === "column") {
2311
- r(t, nn(t.source));
2316
+ r(t, rn(t.source));
2312
2317
  return;
2313
2318
  }
2314
2319
  let i = t.children.filter((e) => e.style.tableRole === "column");
2315
- if (i.length === 0) r(t, nn(t.source));
2316
- else for (let e of i) r(e, nn(e.source));
2317
- for (let n of t.children) n.style.tableRole !== "column" && $t(e, n);
2320
+ if (i.length === 0) r(t, rn(t.source));
2321
+ else for (let e of i) r(e, rn(e.source));
2322
+ for (let n of t.children) n.style.tableRole !== "column" && en(e, n);
2318
2323
  }
2319
- function nn(e) {
2324
+ function rn(e) {
2320
2325
  let t = Number.parseInt(e.getAttribute("span") ?? "", 10);
2321
2326
  return Number.isNaN(t) ? 1 : Math.min(1e3, Math.max(1, t));
2322
2327
  }
2323
- function rn(e, t) {
2328
+ function an(e, t) {
2324
2329
  let n = {
2325
2330
  caption: null,
2326
2331
  rows: [],
@@ -2344,8 +2349,8 @@ function rn(e, t) {
2344
2349
  for (let e of o.children) B(e.style) || (e.style.tableRole === "row" ? t.push({
2345
2350
  row: e,
2346
2351
  group: o
2347
- }) : $t(n, e));
2348
- } else e === "caption" ? n.caption === null ? n.caption = o : $t(n, o) : e === "column" || e === "column-group" ? (tn(n, o, t), n.hidden.push(o)) : $t(n, o);
2352
+ }) : en(n, e));
2353
+ } 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);
2349
2354
  }
2350
2355
  let o = [
2351
2356
  ...r,
@@ -2360,20 +2365,20 @@ function rn(e, t) {
2360
2365
  s = e + 1;
2361
2366
  }
2362
2367
  }
2363
- return an(n), n;
2368
+ return on(n), n;
2364
2369
  }
2365
- function an(e) {
2370
+ function on(e) {
2366
2371
  let t = [];
2367
2372
  for (let n = 0; n < e.rows.length; n++) {
2368
2373
  let r = e.rows[n], i = 0;
2369
2374
  for (let a of r.children) {
2370
2375
  if (B(a.style)) continue;
2371
2376
  if (a.style.tableRole !== "cell") {
2372
- $t(e, a);
2377
+ en(e, a);
2373
2378
  continue;
2374
2379
  }
2375
2380
  for (; (t[i] ?? 0) > n;) i++;
2376
- let o = en(a.source, "colspan"), s = en(a.source, "rowspan"), c = e.groupEnds[n], l = Math.max(1, Math.min(s === 0 ? c - n : s, c - n));
2381
+ 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));
2377
2382
  for (let e = i; e < i + o; e++) t[e] = Math.max(t[e] ?? 0, n + l);
2378
2383
  e.cells.push({
2379
2384
  node: a,
@@ -2387,7 +2392,7 @@ function an(e) {
2387
2392
  }
2388
2393
  e.columnCount = Math.max(t.length, e.colFixed.length);
2389
2394
  }
2390
- function on(e, t, n) {
2395
+ function sn(e, t, n) {
2391
2396
  let r = e.style, i = Y(e, n), a;
2392
2397
  if (t === "min") a = i;
2393
2398
  else {
@@ -2397,11 +2402,11 @@ function on(e, t, n) {
2397
2402
  let o = typeof r.minWidth == "number" ? r.minWidth : 0, s = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
2398
2403
  return Math.max(0, H(a, o, s));
2399
2404
  }
2400
- function sn(e) {
2405
+ function cn(e) {
2401
2406
  let t = e.style.width;
2402
2407
  return t && t.kind === "percent" ? t.value : void 0;
2403
2408
  }
2404
- function cn(e, t, n) {
2409
+ function ln(e, t, n) {
2405
2410
  let r = e.columnCount, i = Array.from({ length: r }, () => 0), a = Array.from({ length: r }, () => 0), o = Array.from({ length: r }, () => void 0);
2406
2411
  for (let t = 0; t < r; t++) e.colFixed[t] !== void 0 && (a[t] = e.colFixed[t]), o[t] = e.colPercent[t];
2407
2412
  let s = [];
@@ -2410,15 +2415,15 @@ function cn(e, t, n) {
2410
2415
  s.push(t);
2411
2416
  continue;
2412
2417
  }
2413
- i[t.col] = Math.max(i[t.col], on(t.node, "min", n)), a[t.col] = Math.max(a[t.col], on(t.node, "max", n));
2414
- let e = sn(t.node);
2418
+ 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));
2419
+ let e = cn(t.node);
2415
2420
  e !== void 0 && (o[t.col] = Math.max(o[t.col] ?? 0, e));
2416
2421
  }
2417
2422
  s.sort((e, t) => e.colSpan - t.colSpan);
2418
2423
  for (let e of s) {
2419
- let r = e.col, o = e.col + e.colSpan, s = hn(t, r, o), c = a.slice(r, o);
2424
+ let r = e.col, o = e.col + e.colSpan, s = gn(t, r, o), c = a.slice(r, o);
2420
2425
  for (let t of ["min", "max"]) {
2421
- let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = on(e.node, t, n) - u;
2426
+ 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;
2422
2427
  if (d <= 0) continue;
2423
2428
  let f = R(c.some((e) => e > 0) ? c : c.map(() => 1), d);
2424
2429
  for (let e = r; e < o; e++) l[e] += f[e - r];
@@ -2431,7 +2436,7 @@ function cn(e, t, n) {
2431
2436
  percent: o
2432
2437
  };
2433
2438
  }
2434
- function ln(e, t) {
2439
+ function un(e, t) {
2435
2440
  let n = e.min.length, r = e.min.slice(), i = [], a = [];
2436
2441
  for (let t = 0; t < n; t++) (e.percent[t] === void 0 ? a : i).push(t);
2437
2442
  if (i.length > 0) {
@@ -2460,7 +2465,7 @@ function ln(e, t) {
2460
2465
  }
2461
2466
  return r;
2462
2467
  }
2463
- function un(e, t, n) {
2468
+ function dn(e, t, n) {
2464
2469
  let r = e.columnCount, i = Array.from({ length: r }, () => void 0);
2465
2470
  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];
2466
2471
  for (let r of e.cells) {
@@ -2480,13 +2485,13 @@ function un(e, t, n) {
2480
2485
  }
2481
2486
  return i.map((e) => e ?? 0);
2482
2487
  }
2483
- var dn = {
2488
+ var fn = {
2484
2489
  double: 3,
2485
2490
  solid: 2,
2486
2491
  dashed: 1,
2487
2492
  dotted: 0
2488
2493
  };
2489
- function fn(e) {
2494
+ function pn(e) {
2490
2495
  for (let { border: t, side: n } of e) if (t?.hidden[n]) return null;
2491
2496
  let t = null;
2492
2497
  for (let { border: n, side: r } of e) {
@@ -2494,7 +2499,7 @@ function fn(e) {
2494
2499
  let e = n.width[r];
2495
2500
  if (e <= 0) continue;
2496
2501
  let i = n.style[r];
2497
- (t === null || e > t.width || e === t.width && dn[i] > dn[t.style]) && (t = {
2502
+ (t === null || e > t.width || e === t.width && fn[i] > fn[t.style]) && (t = {
2498
2503
  width: e,
2499
2504
  style: i,
2500
2505
  color: n.color[r]
@@ -2502,7 +2507,7 @@ function fn(e) {
2502
2507
  }
2503
2508
  return t;
2504
2509
  }
2505
- function pn(e, t) {
2510
+ function mn(e, t) {
2506
2511
  let n = t.columnCount, r = t.rows.length, i = e.style.borderCollapse, a = {
2507
2512
  collapsed: i,
2508
2513
  vLines: Array.from({ length: n + 1 }, () => 0),
@@ -2547,7 +2552,7 @@ function pn(e, t) {
2547
2552
  side: u
2548
2553
  });
2549
2554
  }
2550
- i.push(fn(l));
2555
+ i.push(pn(l));
2551
2556
  }
2552
2557
  a.vSegments.push(i), a.vLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2553
2558
  }
@@ -2586,47 +2591,47 @@ function pn(e, t) {
2586
2591
  }), e === r && l.push({
2587
2592
  border: s,
2588
2593
  side: "bottom"
2589
- }), i.push(fn(l));
2594
+ }), i.push(pn(l));
2590
2595
  }
2591
2596
  a.hSegments.push(i), a.hLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2592
2597
  }
2593
2598
  return a;
2594
2599
  }
2595
- function mn(e, t) {
2600
+ function hn(e, t) {
2596
2601
  return e.collapsed ? e.vLines.reduce((e, t) => e + t, 0) : (t + 1) * e.spacingX;
2597
2602
  }
2598
- function hn(e, t, n) {
2603
+ function gn(e, t, n) {
2599
2604
  if (!e.collapsed) return e.spacingX * (n - t - 1);
2600
2605
  let r = 0;
2601
2606
  for (let i = t + 1; i < n; i++) r += e.vLines[i];
2602
2607
  return r;
2603
2608
  }
2604
- function gn(e, t, n) {
2609
+ function _n(e, t, n) {
2605
2610
  if (!e.collapsed) return e.spacingY * (n - t - 1);
2606
2611
  let r = 0;
2607
2612
  for (let i = t + 1; i < n; i++) r += e.hLines[i];
2608
2613
  return r;
2609
2614
  }
2610
- function _n(e, t) {
2615
+ function vn(e, t) {
2611
2616
  let n = t.tableData.get(e);
2612
2617
  if (n) return n;
2613
- let r = rn(e, t), i = pn(e, r), a = {
2618
+ let r = an(e, t), i = mn(e, r), a = {
2614
2619
  structure: r,
2615
2620
  chrome: i,
2616
- bounds: cn(r, i, t),
2617
- chromeX: mn(i, r.columnCount)
2621
+ bounds: ln(r, i, t),
2622
+ chromeX: hn(i, r.columnCount)
2618
2623
  };
2619
2624
  return t.tableData.set(e, a), a;
2620
2625
  }
2621
- function vn(e, t) {
2622
- let { structure: n, bounds: r, chromeX: i } = _n(e, t), a = r.min.reduce((e, t) => e + t, 0) + i, o = r.max.reduce((e, t) => e + t, 0) + i;
2626
+ function yn(e, t) {
2627
+ 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;
2623
2628
  return n.caption && (a = Math.max(a, Y(n.caption, t)), o = Math.max(o, J(n.caption, t))), {
2624
2629
  min: a,
2625
2630
  max: o
2626
2631
  };
2627
2632
  }
2628
- function yn(e, t, n) {
2629
- let r = e.style, { bounds: i, chromeX: a } = _n(e, n), { min: o, max: s } = vn(e, n), c = r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t) + tt(r).right, l = i.max.reduce((e, t) => e + t, 0), u = 0, d = 0;
2633
+ function bn(e, t, n) {
2634
+ 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 + W(r.padding.left, t) + W(r.padding.right, t) + nt(r).right, l = i.max.reduce((e, t) => e + t, 0), u = 0, d = 0;
2630
2635
  for (let e = 0; e < i.max.length; e++) {
2631
2636
  let t = i.percent[e];
2632
2637
  t === void 0 ? d += i.max[e] : u += t;
@@ -2642,8 +2647,8 @@ function yn(e, t, n) {
2642
2647
  let f = Math.max(l + a, s) + c;
2643
2648
  return Math.max(o + c, Math.min(f, t));
2644
2649
  }
2645
- function bn(e, t, n, r, i, a) {
2646
- let { structure: o, chrome: s, bounds: c } = _n(e, a), l = o.columnCount, u = o.rows.length, d = r.left + i.left, f = r.top + i.top;
2650
+ function xn(e, t, n, r, i, a) {
2651
+ 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;
2647
2652
  for (let e of o.hidden) e.tableHidden = !0, e.localRect = {
2648
2653
  x: 0,
2649
2654
  y: 0,
@@ -2655,16 +2660,16 @@ function bn(e, t, n, r, i, a) {
2655
2660
  bottom: 0,
2656
2661
  left: 0
2657
2662
  }, e.unclampedHeight = 0;
2658
- let p = Math.max(0, t - mn(s, l)), m = e.style, h = m.tableLayout === "fixed" && m.width !== void 0 && m.width.kind !== "auto" ? un(o, p, a) : ln(c, p), g = [], _ = 0;
2663
+ 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;
2659
2664
  for (let e = 0; e < l; e++) _ += s.collapsed ? s.vLines[e] : s.spacingX, g.push(_), _ += h[e];
2660
2665
  let v = _ + (s.collapsed ? s.vLines[l] ?? 0 : s.spacingX), y = 0;
2661
2666
  o.caption && (V(o.caption, t, void 0, d, f, "fill", a), y = o.caption.localRect.height);
2662
2667
  let b = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
2663
2668
  for (let e of o.cells) {
2664
- let t = e.col + e.colSpan, n = h.slice(e.col, t).reduce((e, t) => e + t, 0) + hn(s, e.col, t);
2669
+ let t = e.col + e.colSpan, n = h.slice(e.col, t).reduce((e, t) => e + t, 0) + gn(s, e.col, t);
2665
2670
  x.set(e, n), V(e.node, n, void 0, 0, 0, "fill", a, { width: n }), b.set(e, e.node.localRect.height);
2666
2671
  }
2667
- 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);
2672
+ 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);
2668
2673
  for (let e = 0; e < u; e++) {
2669
2674
  let t = o.rows[e].style.height;
2670
2675
  t !== void 0 && t.kind === "cells" && (E[e] = t.value);
@@ -2677,7 +2682,7 @@ function bn(e, t, n, r, i, a) {
2677
2682
  }
2678
2683
  let O = o.cells.filter((e) => e.rowSpan > 1).sort((e, t) => e.rowSpan - t.rowSpan);
2679
2684
  for (let e of O) {
2680
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + gn(s, e.row, t), r = b.get(e) - n;
2685
+ 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;
2681
2686
  if (r <= 0) continue;
2682
2687
  let i = R(Array.from({ length: e.rowSpan }, () => 1), r);
2683
2688
  for (let n = e.row; n < t; n++) E[n] += i[n - e.row];
@@ -2728,11 +2733,11 @@ function bn(e, t, n, r, i, a) {
2728
2733
  }, t.unclampedHeight = E[e];
2729
2734
  }
2730
2735
  for (let e of o.cells) {
2731
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + gn(s, e.row, t);
2736
+ let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + _n(s, e.row, t);
2732
2737
  e.node.children.some((e) => !B(e.style) && e.style.height?.kind === "percent") && n !== b.get(e) && V(e.node, x.get(e), n, 0, 0, "fill", a, {
2733
2738
  width: x.get(e),
2734
2739
  height: n
2735
- }), xn(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2740
+ }), Sn(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2736
2741
  x: g[e.col],
2737
2742
  y: 0,
2738
2743
  width: e.node.localRect.width,
@@ -2744,9 +2749,9 @@ function bn(e, t, n, r, i, a) {
2744
2749
  x: d,
2745
2750
  y: f
2746
2751
  });
2747
- return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + M), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = Sn(s, o, h, E, g, A, d, f, S(e.style.glyphSet))), e.style.captionSide === "bottom" ? M + y : M;
2752
+ return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + M), 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" ? M + y : M;
2748
2753
  }
2749
- function xn(e, t) {
2754
+ function Sn(e, t) {
2750
2755
  if (t <= 0) return;
2751
2756
  let n = e.style.verticalAlign, r = n === "center" ? Math.floor(t / 2) : n === "end" ? t : 0;
2752
2757
  if (!e.children.some((e) => !B(e.style) && !e.inlineBox)) {
@@ -2755,14 +2760,14 @@ function xn(e, t) {
2755
2760
  }
2756
2761
  if (!(r <= 0)) for (let t of e.children) t.inlineBox || (B(t.style) ? t.staticSlot?.kind === "block" && (t.staticSlot.y += r) : t.localRect.y += r);
2757
2762
  }
2758
- function Sn(e, t, n, r, i, a, o, s, c) {
2763
+ function Cn(e, t, n, r, i, a, o, s, c) {
2759
2764
  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];
2760
2765
  for (let t = 0; t <= l; t++) {
2761
2766
  let n = e.vSegments[t];
2762
2767
  for (let e = 0; e < u; e++) {
2763
2768
  let i = n[e];
2764
2769
  if (!i) continue;
2765
- let l = pe(i.style, "v", c);
2770
+ let l = me(i.style, "v", c);
2766
2771
  for (let n = 0; n < i.width; n++) for (let c = a[e]; c < a[e] + r[e]; c++) d.push({
2767
2772
  glyph: l,
2768
2773
  x: o + f(t) + n,
@@ -2777,7 +2782,7 @@ function Sn(e, t, n, r, i, a, o, s, c) {
2777
2782
  for (let e = 0; e < l; e++) {
2778
2783
  let a = r[e];
2779
2784
  if (!a) continue;
2780
- let l = pe(a.style, "h", c);
2785
+ let l = me(a.style, "h", c);
2781
2786
  for (let r = 0; r < a.width; r++) d.push({
2782
2787
  glyph: l,
2783
2788
  x: o + i[e],
@@ -2796,7 +2801,7 @@ function Sn(e, t, n, r, i, a, o, s, c) {
2796
2801
  m
2797
2802
  ].filter((e) => e !== null);
2798
2803
  if (h.length === 0) continue;
2799
- let g = h.every((e) => e.style === "double") ? "double" : "solid", _ = h.reduce((e, t) => t.width > e.width || t.width === e.width && dn[t.style] > dn[e.style] ? t : e), v = me(g, r !== null, i !== null, a !== null, m !== null, c);
2804
+ 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 = he(g, r !== null, i !== null, a !== null, m !== null, c);
2800
2805
  for (let r = 0; r < e.vLines[t]; r++) for (let i = 0; i < e.hLines[n]; i++) d.push({
2801
2806
  glyph: v,
2802
2807
  x: o + f(t) + r,
@@ -2809,30 +2814,30 @@ function Sn(e, t, n, r, i, a, o, s, c) {
2809
2814
  }
2810
2815
  //#endregion
2811
2816
  //#region src/positioning.ts
2812
- function Cn(e) {
2817
+ function wn(e) {
2813
2818
  return e.position === "absolute" || e.position === "fixed" ? "absolute" : e.position === "relative" || e.position === "sticky" ? "relative" : "static";
2814
2819
  }
2815
- function wn(e, t, n, r, i) {
2820
+ function Tn(e, t, n, r, i) {
2816
2821
  for (let a of e.children) {
2817
- let o = Cn(a.style);
2822
+ let o = wn(a.style);
2818
2823
  if (o === "relative") {
2819
2824
  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;
2820
- a.localRect.x += Tn(a.style.insets.left, a.style.insets.right, t), a.localRect.y += Tn(a.style.insets.top, a.style.insets.bottom, n);
2821
- } else o === "absolute" && Dn(a, e, t, n, r, i);
2822
- wn(a, t + a.localRect.x, n + a.localRect.y, [...r, {
2825
+ 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);
2826
+ } else o === "absolute" && On(a, e, t, n, r, i);
2827
+ Tn(a, t + a.localRect.x, n + a.localRect.y, [...r, {
2823
2828
  node: a,
2824
2829
  absX: t + a.localRect.x,
2825
2830
  absY: n + a.localRect.y
2826
2831
  }], i);
2827
2832
  }
2828
2833
  }
2829
- function Tn(e, t, n) {
2834
+ function En(e, t, n) {
2830
2835
  return e === null ? t === null ? 0 : -W(t, n) : W(e, n);
2831
2836
  }
2832
- function En(e, t) {
2837
+ function Dn(e, t) {
2833
2838
  if (!t) for (let t = e.length - 1; t > 0; t--) {
2834
2839
  let n = e[t];
2835
- if (!Fn(n.node.style)) continue;
2840
+ if (!In(n.node.style)) continue;
2836
2841
  let r = n.node.style.border;
2837
2842
  return {
2838
2843
  x: n.absX + r.left,
@@ -2849,13 +2854,13 @@ function En(e, t) {
2849
2854
  height: n.node.localRect.height
2850
2855
  };
2851
2856
  }
2852
- function Dn(e, t, n, r, i, a) {
2853
- let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && Fn(t.style) ? {
2857
+ function On(e, t, n, r, i, a) {
2858
+ let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && In(t.style) ? {
2854
2859
  x: n + c.area.x,
2855
2860
  y: r + c.area.y,
2856
2861
  width: c.area.width,
2857
2862
  height: c.area.height
2858
- } : En(i, s), u = o.insets.left === null ? null : W(o.insets.left, l.width), d = o.insets.right === null ? null : W(o.insets.right, l.width), f = o.insets.top === null ? null : W(o.insets.top, l.height), p = o.insets.bottom === null ? null : W(o.insets.bottom, l.height), m = G(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 = Wn(o.minWidth, l.width, e, a) ?? 0, S = Wn(o.maxWidth, l.width, e, a), C = {};
2863
+ } : Dn(i, s), u = o.insets.left === null ? null : W(o.insets.left, l.width), d = o.insets.right === null ? null : W(o.insets.right, l.width), f = o.insets.top === null ? null : W(o.insets.top, l.height), p = o.insets.bottom === null ? null : W(o.insets.bottom, l.height), m = G(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 = Gn(o.minWidth, l.width, e, a) ?? 0, S = Gn(o.maxWidth, l.width, e, a), C = {};
2859
2864
  if (!y) C.width = H(q(o.width, l.width, e, a), x, S);
2860
2865
  else if (u !== null && d !== null) C.width = H(Math.max(0, l.width - u - d - h - g), x, S);
2861
2866
  else {
@@ -2867,25 +2872,25 @@ function Dn(e, t, n, r, i, a) {
2867
2872
  if (u !== null && d !== null) {
2868
2873
  let e = Math.max(0, l.width - u - d - w - h - g), t = m.left === null && m.right === null;
2869
2874
  E = l.x + u + h + (t ? Math.floor(e / 2) : m.left === null ? e : 0);
2870
- } else E = u === null ? d === null ? Mn(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2875
+ } else E = u === null ? d === null ? Nn(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2871
2876
  let D;
2872
2877
  if (f !== null && p !== null) {
2873
2878
  let e = Math.max(0, l.height - f - p - T - _ - v), t = m.top === null && m.bottom === null;
2874
2879
  D = l.y + f + _ + (t ? Math.floor(e / 2) : m.top === null ? e : 0);
2875
- } else D = f === null ? p === null ? Nn(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2880
+ } else D = f === null ? p === null ? Pn(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2876
2881
  e.localRect = {
2877
2882
  ...e.localRect,
2878
2883
  x: E - n,
2879
2884
  y: D - r
2880
2885
  };
2881
2886
  }
2882
- function On(e, t, n) {
2887
+ function kn(e, t, n) {
2883
2888
  return L(e, [n], Math.max(0, t - n))[0];
2884
2889
  }
2885
- function kn(e, t, n, r) {
2886
- return z(Je(e, t), n, r);
2890
+ function An(e, t, n, r) {
2891
+ return z(Ye(e, t), n, r);
2887
2892
  }
2888
- function An(e, t, n, r, i) {
2893
+ function jn(e, t, n, r, i) {
2889
2894
  let a = G(e.style.margin, n.innerWidth), [o, s, c, l] = r === "x" ? [
2890
2895
  a.left ?? 0,
2891
2896
  a.right ?? 0,
@@ -2897,9 +2902,9 @@ function An(e, t, n, r, i) {
2897
2902
  n.innerHeight,
2898
2903
  n.direction === "column"
2899
2904
  ], u = i + o + s;
2900
- return (l ? On(Qe(t.style), c, u) : kn(e, t, c, u)) + o;
2905
+ return (l ? kn($e(t.style), c, u) : An(e, t, c, u)) + o;
2901
2906
  }
2902
- function jn(e, t, n, r, i) {
2907
+ function Mn(e, t, n, r, i) {
2903
2908
  let a = G(e.style.margin, n.width), o = e.style.justifySelf === "auto" ? t.style.justifyItems : e.style.justifySelf, [s, c, l, u] = r === "x" ? [
2904
2909
  a.left ?? 0,
2905
2910
  a.right ?? 0,
@@ -2909,37 +2914,37 @@ function jn(e, t, n, r, i) {
2909
2914
  a.top ?? 0,
2910
2915
  a.bottom ?? 0,
2911
2916
  n.height,
2912
- Je(e, t)
2917
+ Ye(e, t)
2913
2918
  ];
2914
2919
  return z(u, l, i + s + c) + s;
2915
2920
  }
2916
- function Mn(e, t, n, r) {
2921
+ function Nn(e, t, n, r) {
2917
2922
  let i = e.staticSlot;
2918
- return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + jn(e, t, i.staticArea, "x", r) : n + i.originX + An(e, t, i, "x", r);
2923
+ 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);
2919
2924
  }
2920
- function Nn(e, t, n, r) {
2925
+ function Pn(e, t, n, r) {
2921
2926
  let i = e.staticSlot;
2922
- return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + jn(e, t, i.staticArea, "y", r) : n + i.originY + An(e, t, i, "y", r);
2927
+ 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);
2923
2928
  }
2924
2929
  //#endregion
2925
2930
  //#region src/layout.ts
2926
- function Pn(e, t) {
2927
- let n = In();
2928
- V(e, t, void 0, 0, 0, "fill", n), wn(e, 0, 0, [{
2931
+ function Fn(e, t) {
2932
+ let n = Ln();
2933
+ V(e, t, void 0, 0, 0, "fill", n), Tn(e, 0, 0, [{
2929
2934
  node: e,
2930
2935
  absX: 0,
2931
2936
  absY: 0
2932
2937
  }], n);
2933
- let r = e.localRect.height, i = Yn(e);
2938
+ let r = e.localRect.height, i = Xn(e);
2934
2939
  return e.localRect.width = Math.max(e.localRect.width, i.x), e.localRect.height = Math.max(r, i.y), { height: r };
2935
2940
  }
2936
2941
  function B(e) {
2937
2942
  return e.position === "absolute" || e.position === "fixed";
2938
2943
  }
2939
- function Fn(e) {
2944
+ function In(e) {
2940
2945
  return e.position !== "static";
2941
2946
  }
2942
- function In() {
2947
+ function Ln() {
2943
2948
  return {
2944
2949
  maxContent: /* @__PURE__ */ new WeakMap(),
2945
2950
  minContent: /* @__PURE__ */ new WeakMap(),
@@ -2950,7 +2955,7 @@ function In() {
2950
2955
  function V(e, t, n, r, i, a, o, s) {
2951
2956
  let c = e.style, l = s?.height;
2952
2957
  delete e.decorationRuns, delete e.multicolGeometry, delete e.multicolFlow, delete e.multicolFlowSpan, delete e.textExtent;
2953
- let u = Wn(c.minWidth, t, e, o) ?? 0, d = Wn(c.maxWidth, t, e, o), f = K(c.minHeight, n) ?? 0, p = K(c.maxHeight, n), m = tt(c);
2958
+ let u = Gn(c.minWidth, t, e, o) ?? 0, d = Gn(c.maxWidth, t, e, o), f = K(c.minHeight, n) ?? 0, p = K(c.maxHeight, n), m = nt(c);
2954
2959
  s?.gutter?.right && (m.right = c.scrollbarSize.y), s?.gutter?.bottom && (m.bottom = c.scrollbarSize.x);
2955
2960
  let h = {
2956
2961
  top: W(c.padding.top, t),
@@ -2959,9 +2964,9 @@ function V(e, t, n, r, i, a, o, s) {
2959
2964
  left: W(c.padding.left, t)
2960
2965
  };
2961
2966
  e.resolvedPadding = h;
2962
- let g = s?.width ?? H(Jn(c, t, a, e, o), u, d), _ = Qn(c, n), v = tr(g, l ?? _ ?? (f > 0 ? f : void 0) ?? Infinity, c.border, h), y = l !== void 0 || _ !== void 0, b = p === void 0 ? void 0 : Math.max(0, p - c.border.top - c.border.bottom - h.top - h.bottom), x = Rn(e), S = (t, n) => {
2967
+ let g = s?.width ?? H(Yn(c, t, a, e, o), u, d), _ = $n(c, n), v = nr(g, l ?? _ ?? (f > 0 ? f : void 0) ?? Infinity, c.border, h), y = l !== void 0 || _ !== void 0, b = p === void 0 ? void 0 : Math.max(0, p - c.border.top - c.border.bottom - h.top - h.bottom), x = zn(e), S = (t, n) => {
2963
2968
  let r = n && Number.isFinite(t) ? t : void 0;
2964
- return x ? Ln(e, v.width, t, r, b, h, o) : c.display === "flex" && c.flexDirection === "row" ? He(e, v.width, t, r, c.border, h, o) : c.display === "flex" ? We(e, v.width, t, n, c.border, h, o) : c.display === "grid" ? at(e, v.width, t, c.border, h, o) : c.display === "table" ? bn(e, v.width, r, c.border, h, o) : c.display === "multicol" ? Qt(e, v.width, r, b, c.border, h, o) : Gn(e, v.width, r, c.border, h, o);
2969
+ return x ? Rn(e, v.width, t, r, b, h, o) : c.display === "flex" && c.flexDirection === "row" ? Ue(e, v.width, t, r, c.border, h, o) : c.display === "flex" ? Ge(e, v.width, t, n, c.border, h, o) : c.display === "grid" ? ot(e, v.width, t, c.border, h, o) : c.display === "table" ? xn(e, v.width, r, c.border, h, o) : c.display === "multicol" ? $t(e, v.width, r, b, c.border, h, o) : Kn(e, v.width, r, c.border, h, o);
2965
2970
  }, C = S(v.height, y);
2966
2971
  !x && (c.display === "flex" || c.display === "grid") && !y && b !== void 0 && C > b && (C = S(b, !0));
2967
2972
  let w = C + c.border.top + c.border.bottom + h.top + h.bottom, T = l ?? _ ?? w;
@@ -2969,20 +2974,20 @@ function V(e, t, n, r, i, a, o, s) {
2969
2974
  let E = H(T, f, p), D = e.multicolGeometry;
2970
2975
  if (D) {
2971
2976
  let t = E - c.border.top - c.border.bottom - h.top - h.bottom;
2972
- t > D.totalRows && (h.bottom += t - D.totalRows), Yt(e, D, c.border, h);
2977
+ t > D.totalRows && (h.bottom += t - D.totalRows), Xt(e, D, c.border, h);
2973
2978
  }
2974
2979
  if (e.localRect = {
2975
2980
  x: r,
2976
2981
  y: i,
2977
2982
  width: g,
2978
2983
  height: E
2979
- }, et(c.overflow.x) || et(c.overflow.y)) {
2980
- let l = Yn(e), u = Math.max(0, l.x - c.border.left - h.left), d = Math.max(0, l.y - c.border.top - h.top), f = Math.max(0, g - c.border.left - c.border.right - h.left - h.right), p = Math.max(0, E - c.border.top - c.border.bottom - h.top - h.bottom);
2984
+ }, tt(c.overflow.x) || tt(c.overflow.y)) {
2985
+ let l = Xn(e), u = Math.max(0, l.x - c.border.left - h.left), d = Math.max(0, l.y - c.border.top - h.top), f = Math.max(0, g - c.border.left - c.border.right - h.left - h.right), p = Math.max(0, E - c.border.top - c.border.bottom - h.top - h.bottom);
2981
2986
  if (e.scrollRange = {
2982
2987
  sizeX: u,
2983
2988
  sizeY: d,
2984
- maxX: et(c.overflow.x) ? Math.max(0, u - f) : 0,
2985
- maxY: et(c.overflow.y) ? Math.max(0, d - p) : 0
2989
+ maxX: tt(c.overflow.x) ? Math.max(0, u - f) : 0,
2990
+ maxY: tt(c.overflow.y) ? Math.max(0, d - p) : 0
2986
2991
  }, !s?.gutter && c.scrollbarWidth !== "none") {
2987
2992
  let l = c.overflow.y === "auto" && e.scrollRange.maxY > 0, u = c.overflow.x === "auto" && e.scrollRange.maxX > 0;
2988
2993
  if (l || u) {
@@ -3002,33 +3007,33 @@ function V(e, t, n, r, i, a, o, s) {
3002
3007
  };
3003
3008
  } else delete e.scrollRange, delete e.scrollGutterCells;
3004
3009
  }
3005
- function Ln(e, t, n, r, i, a, o) {
3010
+ function Rn(e, t, n, r, i, a, o) {
3006
3011
  let s = e.style, c;
3007
3012
  if (e.text) {
3008
3013
  let l = e.children.filter((e) => e.inlineBox);
3009
- Pe(e.text, (n, r) => {
3014
+ Fe(e.text, (n, r) => {
3010
3015
  let i = l[r];
3011
3016
  V(i, t, void 0, 0, 0, "shrink", o), e.advances[n] = Math.max(1, i.localRect.width);
3012
3017
  });
3013
3018
  let u, d;
3014
3019
  if (s.display === "multicol") {
3015
- let n = U(s, "x", t), o = Vt(s, t, n);
3020
+ let n = U(s, "x", t), o = Ht(s, t, n);
3016
3021
  a.right += o.leftover;
3017
- let c = Ut(e, o, n, zt(r, i));
3022
+ let c = Wt(e, o, n, Bt(r, i));
3018
3023
  e.multicolGeometry = c, u = c, d = c.lineX;
3019
- } else u = Bn(e, t);
3024
+ } else u = Vn(e, t);
3020
3025
  if (c = u.totalRows, e.textExtent = {
3021
3026
  width: u.spans.reduce((t, n) => Math.max(t, I(n.start, n.end, e.advances, s.tracking)), 0),
3022
3027
  rows: u.totalRows
3023
- }, zn(e, u, t, n, a), l.length > 0) {
3028
+ }, Bn(e, u, t, n, a), l.length > 0) {
3024
3029
  let t = (e) => u.spans.findIndex((t) => e >= t.start && e < t.end);
3025
- Pe(e.text, (n, r) => {
3030
+ Fe(e.text, (n, r) => {
3026
3031
  let i = t(n);
3027
3032
  if (i === -1) return;
3028
3033
  let o = u.spans[i];
3029
3034
  l[r].localRect = {
3030
3035
  ...l[r].localRect,
3031
- x: s.border.left + a.left + (d?.[i] ?? 0) + je(o.start, n, e.advances),
3036
+ x: s.border.left + a.left + (d?.[i] ?? 0) + Me(o.start, n, e.advances),
3032
3037
  y: s.border.top + a.top + u.lineY[i]
3033
3038
  };
3034
3039
  });
@@ -3045,30 +3050,30 @@ function Ln(e, t, n, r, i, a, o) {
3045
3050
  }
3046
3051
  return c;
3047
3052
  }
3048
- function Rn(e) {
3053
+ function zn(e) {
3049
3054
  return e.children.some((e) => !B(e.style) && !e.inlineBox) ? !1 : e.text !== "" || e.style.display !== "flex" && e.style.display !== "grid";
3050
3055
  }
3051
3056
  function H(e, t, n) {
3052
3057
  return Math.max(t, n === void 0 ? e : Math.min(e, n));
3053
3058
  }
3054
- function zn(e, t, n, r, i) {
3059
+ function Bn(e, t, n, r, i) {
3055
3060
  let a = e.style;
3056
3061
  if (a.display !== "flex" && a.display !== "grid" || t.spans.length === 0) return;
3057
3062
  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);
3058
3063
  if (c > 0) {
3059
- let e = a.display === "grid" ? z(a.justifyItems, n, s) : o ? z(a.alignItems, n, s) : L(Qe(a), [s], c)[0];
3064
+ let e = a.display === "grid" ? z(a.justifyItems, n, s) : o ? z(a.alignItems, n, s) : L($e(a), [s], c)[0];
3060
3065
  e > 0 && (i.left += e, i.right += c - e);
3061
3066
  }
3062
3067
  if (Number.isFinite(r)) {
3063
3068
  let e = Math.max(0, r - t.totalRows);
3064
3069
  if (e > 0) {
3065
- let n = a.display === "grid" || !o ? z(a.alignItems, r, t.totalRows) : L(Qe(a), [t.totalRows], e)[0];
3070
+ let n = a.display === "grid" || !o ? z(a.alignItems, r, t.totalRows) : L($e(a), [t.totalRows], e)[0];
3066
3071
  n > 0 && (i.top += n, i.bottom += e - n);
3067
3072
  }
3068
3073
  }
3069
3074
  }
3070
- function Bn(e, t) {
3071
- let n = Vn(e, t), { heights: r, textOffsets: i } = Hn(e, n), a = [], o = [], s = 0;
3075
+ function Vn(e, t) {
3076
+ let n = Hn(e, t), { heights: r, textOffsets: i } = Un(e, n), a = [], o = [], s = 0;
3072
3077
  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);
3073
3078
  return {
3074
3079
  spans: n,
@@ -3077,14 +3082,14 @@ function Bn(e, t) {
3077
3082
  totalRows: s
3078
3083
  };
3079
3084
  }
3080
- function Vn(e, t) {
3081
- return e.style.whiteSpace === "normal" ? Ae(e.text, t, {
3085
+ function Hn(e, t) {
3086
+ return e.style.whiteSpace === "normal" ? je(e.text, t, {
3082
3087
  advances: e.advances,
3083
3088
  tracking: e.style.tracking,
3084
3089
  firstLineIndent: e.style.textIndent
3085
- }) : ke(e.text);
3090
+ }) : Ae(e.text);
3086
3091
  }
3087
- function Hn(e, t) {
3092
+ function Un(e, t) {
3088
3093
  let n = e.children.filter((e) => e.inlineBox), r = [], i = [], a = 0;
3089
3094
  for (let o of t) {
3090
3095
  let t = 1, s = 0;
@@ -3105,7 +3110,7 @@ function U(e, t, n) {
3105
3110
  return Math.max(r, i?.width ?? 0);
3106
3111
  }
3107
3112
  function W(e, t) {
3108
- return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : Ce(e.percent, t);
3113
+ return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : we(e.percent, t);
3109
3114
  }
3110
3115
  function G(e, t) {
3111
3116
  let n = (e) => e === null ? null : W(e, t);
@@ -3116,16 +3121,16 @@ function G(e, t) {
3116
3121
  left: n(e.left)
3117
3122
  };
3118
3123
  }
3119
- function Un(e) {
3124
+ function Wn(e) {
3120
3125
  return typeof e == "number" ? e : 0;
3121
3126
  }
3122
3127
  function K(e, t) {
3123
- if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : Ce(e.percent, t);
3128
+ if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : we(e.percent, t);
3124
3129
  }
3125
- function Wn(e, t, n, r) {
3130
+ function Gn(e, t, n, r) {
3126
3131
  return e === "min-content" || e === "max-content" || e === "fit-content" ? q({ kind: e }, t, n, r) : K(e, t);
3127
3132
  }
3128
- function Gn(e, t, n, r, i, a) {
3133
+ function Kn(e, t, n, r, i, a) {
3129
3134
  let o = r.left + i.left, s = r.top + i.top, c = s, l = null;
3130
3135
  for (let r of e.children) {
3131
3136
  let e = G(r.style.margin, t), i = e.top ?? 0, s = e.bottom ?? 0, u = e.left ?? 0, d = e.right ?? 0;
@@ -3133,13 +3138,13 @@ function Gn(e, t, n, r, i, a) {
3133
3138
  r.staticSlot = {
3134
3139
  kind: "block",
3135
3140
  x: o + u,
3136
- y: c + (l === null ? i : qn(l, i))
3141
+ y: c + (l === null ? i : Jn(l, i))
3137
3142
  };
3138
3143
  continue;
3139
3144
  }
3140
3145
  V(r, Math.max(0, t - u - d), n, 0, 0, "fill", a);
3141
- let f = Kn(e, t, r.localRect.width);
3142
- c += l === null ? i : qn(l, i), r.localRect = {
3146
+ let f = qn(e, t, r.localRect.width);
3147
+ c += l === null ? i : Jn(l, i), r.localRect = {
3143
3148
  ...r.localRect,
3144
3149
  x: o + f,
3145
3150
  y: c
@@ -3147,30 +3152,30 @@ function Gn(e, t, n, r, i, a) {
3147
3152
  }
3148
3153
  return l !== null && (c += l), c - s;
3149
3154
  }
3150
- function Kn(e, t, n) {
3155
+ function qn(e, t, n) {
3151
3156
  let r = t - n;
3152
3157
  return e.left === null && e.right === null ? Math.floor(r / 2) : e.left === null ? r - (e.right ?? 0) : e.left;
3153
3158
  }
3154
- function qn(e, t) {
3159
+ function Jn(e, t) {
3155
3160
  return e >= 0 && t >= 0 ? Math.max(e, t) : e <= 0 && t <= 0 ? Math.min(e, t) : e + t;
3156
3161
  }
3157
- function Jn(e, t, n, r, i) {
3162
+ function Yn(e, t, n, r, i) {
3158
3163
  let a = e.width;
3159
3164
  if (e.display === "table") {
3160
3165
  if (!r.children.some((e) => !B(e.style) && !e.inlineBox)) return a !== void 0 && a.kind !== "auto" ? q(a, t, r, i) : Math.min(t, J(r, i));
3161
3166
  if (a !== void 0 && a.kind !== "auto") {
3162
3167
  let e = q(a, t, r, i);
3163
- return Math.max(e, Zn(r, t, i));
3168
+ return Math.max(e, Qn(r, t, i));
3164
3169
  }
3165
- return yn(r, t, i);
3170
+ return bn(r, t, i);
3166
3171
  }
3167
3172
  return a !== void 0 && a.kind !== "auto" ? q(a, t, r, i) : n === "shrink" ? Math.min(t, J(r, i)) : t;
3168
3173
  }
3169
- function Yn(e) {
3174
+ function Xn(e) {
3170
3175
  let t = 0, n = 0;
3171
3176
  for (let r of e.children) {
3172
3177
  if (r.style.position === "fixed") continue;
3173
- let e = Xn(r);
3178
+ let e = Zn(r);
3174
3179
  t = Math.max(t, r.localRect.x + e.x), n = Math.max(n, r.localRect.y + e.y);
3175
3180
  }
3176
3181
  if (e.textExtent) {
@@ -3182,30 +3187,30 @@ function Yn(e) {
3182
3187
  y: n
3183
3188
  };
3184
3189
  }
3185
- function Xn(e) {
3190
+ function Zn(e) {
3186
3191
  let { width: t, height: n } = e.localRect, r = e.style.overflow.x !== "visible", i = e.style.overflow.y !== "visible";
3187
3192
  if (r && i) return {
3188
3193
  x: t,
3189
3194
  y: n
3190
3195
  };
3191
- let a = Yn(e);
3196
+ let a = Xn(e);
3192
3197
  return {
3193
3198
  x: r ? t : Math.max(t, a.x),
3194
3199
  y: i ? n : Math.max(n, a.y)
3195
3200
  };
3196
3201
  }
3197
- function Zn(e, t, n) {
3202
+ function Qn(e, t, n) {
3198
3203
  let r = e.style;
3199
- return vn(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t) + tt(r).right;
3204
+ return yn(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t) + nt(r).right;
3200
3205
  }
3201
- function Qn(e, t) {
3206
+ function $n(e, t) {
3202
3207
  if (e.height?.kind === "cells") return e.height.value;
3203
- if (e.height?.kind === "percent" && t != null) return Ce(e.height.value, t);
3208
+ if (e.height?.kind === "percent" && t != null) return we(e.height.value, t);
3204
3209
  }
3205
3210
  function q(e, t, n, r) {
3206
3211
  switch (e.kind) {
3207
3212
  case "cells": return e.value;
3208
- case "percent": return Ce(e.value, t);
3213
+ case "percent": return we(e.value, t);
3209
3214
  case "min-content": return Y(n, r);
3210
3215
  case "max-content": return J(n, r);
3211
3216
  case "fit-content": return Math.min(J(n, r), Math.max(Y(n, r), t));
@@ -3215,42 +3220,42 @@ function q(e, t, n, r) {
3215
3220
  function J(e, t) {
3216
3221
  let n = t.maxContent.get(e);
3217
3222
  if (n !== void 0) return n;
3218
- let r = e.style, i = $n(e, t) + r.border.left + r.border.right + Un(r.padding.left) + Un(r.padding.right) + tt(r).right;
3223
+ let r = e.style, i = er(e, t) + r.border.left + r.border.right + Wn(r.padding.left) + Wn(r.padding.right) + nt(r).right;
3219
3224
  return t.maxContent.set(e, i), i;
3220
3225
  }
3221
- function $n(e, t) {
3226
+ function er(e, t) {
3222
3227
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
3223
- if (n.length === 0) return e.style.display === "multicol" ? Rt(e.style, e.intrinsicWidth) : e.intrinsicWidth;
3224
- if (e.style.display === "grid") return mt(e, t).max;
3225
- if (e.style.display === "table") return vn(e, t).max;
3228
+ if (n.length === 0) return e.style.display === "multicol" ? zt(e.style, e.intrinsicWidth) : e.intrinsicWidth;
3229
+ if (e.style.display === "grid") return ht(e, t).max;
3230
+ if (e.style.display === "table") return yn(e, t).max;
3226
3231
  if (e.style.display === "flex" && e.style.flexDirection === "row") {
3227
- let r = Math.max(Un(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3232
+ let r = Math.max(Wn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3228
3233
  return n.reduce((e, n) => e + J(n, t), 0) + r;
3229
3234
  }
3230
3235
  let r = n.reduce((e, n) => Math.max(e, J(n, t)), 0);
3231
- return e.style.display === "multicol" ? Rt(e.style, r) : r;
3236
+ return e.style.display === "multicol" ? zt(e.style, r) : r;
3232
3237
  }
3233
3238
  function Y(e, t) {
3234
3239
  let n = t.minContent.get(e);
3235
3240
  if (n !== void 0) return n;
3236
- let r = e.style, i = er(e, t) + r.border.left + r.border.right + Un(r.padding.left) + Un(r.padding.right) + tt(r).right;
3241
+ let r = e.style, i = tr(e, t) + r.border.left + r.border.right + Wn(r.padding.left) + Wn(r.padding.right) + nt(r).right;
3237
3242
  return t.minContent.set(e, i), i;
3238
3243
  }
3239
- function er(e, t) {
3244
+ function tr(e, t) {
3240
3245
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
3241
- if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : Ne(e.text, {
3246
+ if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : Pe(e.text, {
3242
3247
  advances: e.advances,
3243
3248
  tracking: e.style.tracking
3244
3249
  });
3245
- if (e.style.display === "grid") return mt(e, t).min;
3246
- if (e.style.display === "table") return vn(e, t).min;
3250
+ if (e.style.display === "grid") return ht(e, t).min;
3251
+ if (e.style.display === "table") return yn(e, t).min;
3247
3252
  if (e.style.display === "flex" && e.style.flexDirection === "row" && e.style.flexWrap === "nowrap") {
3248
- let r = Math.max(Un(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3253
+ let r = Math.max(Wn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3249
3254
  return n.reduce((e, n) => e + Y(n, t), 0) + r;
3250
3255
  }
3251
3256
  return n.reduce((e, n) => Math.max(e, Y(n, t)), 0);
3252
3257
  }
3253
- function tr(e, t, n, r) {
3258
+ function nr(e, t, n, r) {
3254
3259
  return {
3255
3260
  width: Math.max(0, e - n.left - n.right - r.left - r.right),
3256
3261
  height: Math.max(0, t - n.top - n.bottom - r.top - r.bottom)
@@ -3258,38 +3263,38 @@ function tr(e, t, n, r) {
3258
3263
  }
3259
3264
  //#endregion
3260
3265
  //#region src/plain-text.ts
3261
- function nr(e) {
3262
- return cr(e).grid.map((e) => e.join("").trimEnd()).join("\n");
3263
- }
3264
3266
  function rr(e) {
3265
- let { grid: t, paints: n } = cr(e);
3266
- return t.map((e, t) => ir(e, n[t]));
3267
+ return lr(e).grid.map((e) => e.join("").trimEnd()).join("\n");
3268
+ }
3269
+ function ir(e) {
3270
+ let { grid: t, paints: n } = lr(e);
3271
+ return t.map((e, t) => ar(e, n[t]));
3267
3272
  }
3268
- function ir(e, t) {
3273
+ function ar(e, t) {
3269
3274
  let n = e.length;
3270
3275
  for (; n > 0 && e[n - 1] === " " && t[n - 1]?.backgroundColor === void 0;) n--;
3271
3276
  let r = [];
3272
3277
  for (let i = 0; i < n; i++) {
3273
3278
  let n = t[i], a = r[r.length - 1];
3274
- a && ar(a, n) ? a.text += e[i] : r.push({
3279
+ a && or(a, n) ? a.text += e[i] : r.push({
3275
3280
  text: e[i],
3276
3281
  ...n
3277
3282
  });
3278
3283
  }
3279
3284
  return r;
3280
3285
  }
3281
- function ar(e, t) {
3286
+ function or(e, t) {
3282
3287
  return e.color === t?.color && e.backgroundColor === t?.backgroundColor && e.fontWeight === t?.fontWeight && e.fontStyle === t?.fontStyle && e.textDecorationLine === t?.textDecorationLine && e.opacity === t?.opacity;
3283
3288
  }
3284
- function or(e, t) {
3289
+ function sr(e, t) {
3285
3290
  e.color !== void 0 && (t.color = e.color), e.backgroundColor !== void 0 && (t.backgroundColor = e.backgroundColor), e.fontWeight !== void 0 && (t.fontWeight = e.fontWeight), e.fontStyle !== void 0 && (t.fontStyle = e.fontStyle), e.textDecorationLine !== void 0 && (t.textDecoration = e.textDecorationLine), e.opacity !== void 0 && (t.opacity = e.opacity);
3286
3291
  }
3287
- function sr(e) {
3292
+ function cr(e) {
3288
3293
  return e.color === void 0 && e.backgroundColor === void 0 && e.fontWeight === void 0 && e.fontStyle === void 0 && e.textDecorationLine === void 0 && e.opacity === void 0;
3289
3294
  }
3290
- function cr(e) {
3295
+ function lr(e) {
3291
3296
  let t = Math.max(0, e.localRect.width), n = Math.max(0, e.localRect.height), r = Array.from({ length: n }, () => Array.from({ length: t }, () => " ")), i = Array.from({ length: n }, () => Array.from({ length: t }, () => void 0));
3292
- return ur(e, 0, 0, (e, a, o, s) => {
3297
+ return dr(e, 0, 0, (e, a, o, s) => {
3293
3298
  if (e >= 0 && e < t && a >= 0 && a < n) {
3294
3299
  r[a][e] = o;
3295
3300
  let t = i[a][e];
@@ -3303,11 +3308,11 @@ function cr(e) {
3303
3308
  paints: i
3304
3309
  };
3305
3310
  }
3306
- function lr(e) {
3311
+ function ur(e) {
3307
3312
  let t = {};
3308
3313
  return e.color && (t.color = e.color), e.backgroundColor && (t.backgroundColor = e.backgroundColor), e.fontWeight !== "400" && e.fontWeight !== "normal" && e.fontWeight !== "" && (t.fontWeight = e.fontWeight), e.fontStyle !== "normal" && e.fontStyle !== "" && (t.fontStyle = e.fontStyle), e.textDecorationLine !== "none" && e.textDecorationLine !== "" && (t.textDecorationLine = e.textDecorationLine), t;
3309
3314
  }
3310
- function ur(e, t, n, r, i = 1) {
3315
+ function dr(e, t, n, r, i = 1) {
3311
3316
  if (e.tableHidden) return;
3312
3317
  let a = t + e.localRect.x, o = n + e.localRect.y, s = e.style, c = (e) => i >= 1 ? e : {
3313
3318
  ...e,
@@ -3318,7 +3323,7 @@ function ur(e, t, n, r, i = 1) {
3318
3323
  for (let n = 0; n < e.localRect.height; n++) for (let i = 0; i < e.localRect.width; i++) r(a + i, o + n, " ", t);
3319
3324
  }
3320
3325
  let l = [];
3321
- le(s, {
3326
+ ue(s, {
3322
3327
  x: a,
3323
3328
  y: o,
3324
3329
  width: e.localRect.width,
@@ -3340,9 +3345,9 @@ function ur(e, t, n, r, i = 1) {
3340
3345
  };
3341
3346
  }
3342
3347
  if (!e.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed") && e.text) {
3343
- 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 ?? Bn(e, r), l = i ? Math.max(1, i.columnWidth - s.tracking) : r, d = c(lr(s)), f = e.inlineElements?.map((e) => c(lr(e)));
3348
+ 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 ?? Vn(e, r), l = i ? Math.max(1, i.columnWidth - s.tracking) : r, d = c(ur(s)), f = e.inlineElements?.map((e) => c(ur(e)));
3344
3349
  for (let r = 0; r < a.length; r++) {
3345
- let u = a[r], p = n + o[r], m = r === 0 ? s.textIndent : 0, h = s.whiteSpace !== "normal" && s.overflow.x === "clip" ? fr(e.text, u, l - m, e.advances, s) : {
3350
+ let u = a[r], p = n + o[r], m = r === 0 ? s.textIndent : 0, h = s.whiteSpace !== "normal" && s.overflow.x === "clip" ? pr(e.text, u, l - m, e.advances, s) : {
3346
3351
  end: u.end,
3347
3352
  ellipsis: !1
3348
3353
  }, _ = 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;
@@ -3351,17 +3356,17 @@ function ur(e, t, n, r, i = 1) {
3351
3356
  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;
3352
3357
  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);
3353
3358
  }
3354
- b += je(t, t + 1, e.advances);
3359
+ b += Me(t, t + 1, e.advances);
3355
3360
  }
3356
3361
  h.ellipsis && g(b, p, "…", d);
3357
3362
  }
3358
3363
  }
3359
- for (let t of fe(e)) ur(t, m, h, g, i * t.style.opacity);
3364
+ for (let t of pe(e)) dr(t, m, h, g, i * t.style.opacity);
3360
3365
  let _ = e.scrollRange;
3361
3366
  if (_ && d && (d.right > 0 || d.bottom > 0)) {
3362
3367
  let { track: t, thumb: n } = j(S(s.glyphSet)), i = o + s.border.top, l = a + s.border.left, u = o + e.localRect.height - s.border.bottom, f = a + e.localRect.width - s.border.right, p = (e) => c(e ? { color: e } : void 0), m = p(s.scrollbarColor?.track ?? s.color), h = p(s.scrollbarColor?.thumb ?? s.color);
3363
3368
  if (d.right > 0) {
3364
- let a = u - i - d.bottom, { at: o, len: s } = dr(a, _.sizeY, _.maxY, e.scroll?.y ?? 0);
3369
+ let a = u - i - d.bottom, { at: o, len: s } = fr(a, _.sizeY, _.maxY, e.scroll?.y ?? 0);
3365
3370
  for (let e = 0; e < d.right; e++) {
3366
3371
  let c = f - d.right + e;
3367
3372
  for (let e = 0; e < a; e++) {
@@ -3371,7 +3376,7 @@ function ur(e, t, n, r, i = 1) {
3371
3376
  }
3372
3377
  }
3373
3378
  if (d.bottom > 0) {
3374
- let i = f - l - d.right, { at: a, len: o } = dr(i, _.sizeX, _.maxX, e.scroll?.x ?? 0);
3379
+ let i = f - l - d.right, { at: a, len: o } = fr(i, _.sizeX, _.maxX, e.scroll?.x ?? 0);
3375
3380
  for (let e = 0; e < d.bottom; e++) {
3376
3381
  let s = u - d.bottom + e;
3377
3382
  for (let e = 0; e < i; e++) {
@@ -3382,14 +3387,14 @@ function ur(e, t, n, r, i = 1) {
3382
3387
  }
3383
3388
  }
3384
3389
  }
3385
- function dr(e, t, n, r) {
3390
+ function fr(e, t, n, r) {
3386
3391
  let i = t > 0 ? Math.min(1, e / t) : 1, a = Math.max(1, Math.round(i * e));
3387
3392
  return n > 0 && (a = Math.max(1, Math.min(a, e - n))), {
3388
3393
  at: n > 0 ? Math.round(Math.min(r, n) / n * (e - a)) : 0,
3389
3394
  len: a
3390
3395
  };
3391
3396
  }
3392
- function fr(e, t, n, r, i) {
3397
+ function pr(e, t, n, r, i) {
3393
3398
  let { textOverflow: a, tracking: o } = i;
3394
3399
  if (I(t.start, t.end, r, o) <= n) return {
3395
3400
  end: t.end,
@@ -3404,61 +3409,61 @@ function fr(e, t, n, r, i) {
3404
3409
  }
3405
3410
  //#endregion
3406
3411
  //#region src/paint.ts
3407
- var pr = /* @__PURE__ */ new WeakMap(), mr = /* @__PURE__ */ new WeakMap();
3408
- function hr(e) {
3409
- return vr(e, !0) !== null;
3410
- }
3411
- function gr(e, t, n = !1) {
3412
- let r = rr(e), i = Cr(r);
3413
- if (pr.get(t) === i) return !0;
3414
- let a = mr.get(t);
3415
- if (a && _r(t, a.nodes, r)) {
3416
- pr.set(t, i);
3412
+ var mr = /* @__PURE__ */ new WeakMap(), hr = /* @__PURE__ */ new WeakMap();
3413
+ function gr(e) {
3414
+ return yr(e, !0) !== null;
3415
+ }
3416
+ function _r(e, t, n = !1) {
3417
+ let r = ir(e), i = wr(r);
3418
+ if (mr.get(t) === i) return !0;
3419
+ let a = hr.get(t);
3420
+ if (a && vr(t, a.nodes, r)) {
3421
+ mr.set(t, i);
3417
3422
  for (let e = 0; e < r.length; e++) for (let t = 0; t < r[e].length; t++) {
3418
3423
  let n = r[e][t];
3419
- if (sr(n) || ar(n, a.segments[e][t])) continue;
3424
+ if (cr(n) || or(n, a.segments[e][t])) continue;
3420
3425
  let i = a.nodes[e][t];
3421
- i.style.cssText = "", or(n, i.style);
3426
+ i.style.cssText = "", sr(n, i.style);
3422
3427
  }
3423
3428
  return a.segments = r, !0;
3424
3429
  }
3425
- if (n && hr(t)) return !1;
3426
- pr.set(t, i);
3430
+ if (n && gr(t)) return !1;
3431
+ mr.set(t, i);
3427
3432
  let o = document.createDocumentFragment(), s = [];
3428
3433
  for (let e = 0; e < r.length; e++) {
3429
3434
  e > 0 && o.appendChild(document.createTextNode("\n"));
3430
3435
  let t = [];
3431
3436
  for (let n of r[e]) {
3432
- if (sr(n)) {
3437
+ if (cr(n)) {
3433
3438
  let e = document.createTextNode(n.text);
3434
3439
  t.push(e), o.appendChild(e);
3435
3440
  continue;
3436
3441
  }
3437
3442
  let e = document.createElement("span");
3438
- or(n, e.style), e.textContent = n.text, t.push(e), o.appendChild(e);
3443
+ sr(n, e.style), e.textContent = n.text, t.push(e), o.appendChild(e);
3439
3444
  }
3440
3445
  s.push(t);
3441
3446
  }
3442
- mr.set(t, {
3447
+ hr.set(t, {
3443
3448
  nodes: s,
3444
3449
  segments: r
3445
3450
  });
3446
- let c = vr(t, !1);
3447
- return t.replaceChildren(o), c && yr(t, c), !0;
3451
+ let c = yr(t, !1);
3452
+ return t.replaceChildren(o), c && br(t, c), !0;
3448
3453
  }
3449
- function _r(e, t, n) {
3454
+ function vr(e, t, n) {
3450
3455
  if (t.length !== n.length) return !1;
3451
3456
  for (let r = 0; r < n.length; r++) {
3452
3457
  let i = t[r], a = n[r];
3453
3458
  if (i.length !== a.length) return !1;
3454
3459
  for (let t = 0; t < a.length; t++) {
3455
3460
  let n = i[t];
3456
- if (sr(a[t]) !== (n.nodeType === Node.TEXT_NODE) || n.textContent !== a[t].text || n.parentNode !== e) return !1;
3461
+ if (cr(a[t]) !== (n.nodeType === Node.TEXT_NODE) || n.textContent !== a[t].text || n.parentNode !== e) return !1;
3457
3462
  }
3458
3463
  }
3459
3464
  return !0;
3460
3465
  }
3461
- function vr(e, t) {
3466
+ function yr(e, t) {
3462
3467
  try {
3463
3468
  let n = e.ownerDocument.getSelection();
3464
3469
  if (!n) return null;
@@ -3474,7 +3479,7 @@ function vr(e, t) {
3474
3479
  if (!e || e.rangeCount === 0) return null;
3475
3480
  i = e.getRangeAt(0);
3476
3481
  }
3477
- let a = br(e, i.startContainer, i.startOffset), o = br(e, i.endContainer, i.endOffset);
3482
+ let a = xr(e, i.startContainer, i.startOffset), o = xr(e, i.endContainer, i.endOffset);
3478
3483
  return a === null || o === null || a === o && !t ? null : {
3479
3484
  start: a,
3480
3485
  end: o,
@@ -3484,32 +3489,32 @@ function vr(e, t) {
3484
3489
  return null;
3485
3490
  }
3486
3491
  }
3487
- function yr(e, t) {
3492
+ function br(e, t) {
3488
3493
  try {
3489
- let n = xr(e, t.start), r = xr(e, t.end);
3494
+ let n = Sr(e, t.start), r = Sr(e, t.end);
3490
3495
  if (!n || !r) return;
3491
3496
  let i = e.getRootNode().getSelection?.() ?? e.ownerDocument.getSelection();
3492
3497
  t.backward ? i?.setBaseAndExtent(r[0], r[1], n[0], n[1]) : i?.setBaseAndExtent(n[0], n[1], r[0], r[1]);
3493
3498
  } catch {}
3494
3499
  }
3495
- function br(e, t, n) {
3500
+ function xr(e, t, n) {
3496
3501
  if (!e.contains(t)) return null;
3497
3502
  let r = e.ownerDocument.createRange();
3498
3503
  return r.selectNodeContents(e), r.setEnd(t, n), r.toString().length;
3499
3504
  }
3500
- function xr(e, t) {
3505
+ function Sr(e, t) {
3501
3506
  let n = t, r = null;
3502
- for (let t of Sr(e)) {
3507
+ for (let t of Cr(e)) {
3503
3508
  if (n <= t.data.length) return [t, n];
3504
3509
  n -= t.data.length, r = [t, t.data.length];
3505
3510
  }
3506
3511
  return r;
3507
3512
  }
3508
- function* Sr(e) {
3513
+ function* Cr(e) {
3509
3514
  let t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), n = t.nextNode();
3510
3515
  for (; n;) yield n, n = t.nextNode();
3511
3516
  }
3512
- function Cr(e) {
3517
+ function wr(e) {
3513
3518
  let t = [];
3514
3519
  for (let n of e) {
3515
3520
  for (let e of n) t.push(e.text, e.color ?? "", e.backgroundColor ?? "", e.fontWeight ?? "", e.fontStyle ?? "", e.textDecorationLine ?? "", e.opacity ?? "");
@@ -3519,9 +3524,9 @@ function Cr(e) {
3519
3524
  }
3520
3525
  //#endregion
3521
3526
  //#region src/render.ts
3522
- function wr(e) {
3527
+ function Tr(e) {
3523
3528
  let t = /* @__PURE__ */ new Set();
3524
- Tr(e, !0, t);
3529
+ Er(e, !0, t);
3525
3530
  for (let n of Array.from(e.source.querySelectorAll("[data-mw-inline-inset]"))) if (!t.has(n)) {
3526
3531
  n.removeAttribute("data-mw-inline-inset");
3527
3532
  let e = n.style;
@@ -3542,33 +3547,33 @@ function Z(e, t) {
3542
3547
  function Q(e, t, n) {
3543
3548
  e.hasAttribute(t) !== n && (n ? e.setAttribute(t, "") : e.removeAttribute(t));
3544
3549
  }
3545
- function Tr(e, t, n) {
3550
+ function Er(e, t, n) {
3546
3551
  if (e.inlineElements) for (let { element: t, tracking: r, padLeft: i, padRight: a, insets: o } of e.inlineElements) {
3547
3552
  let e = t;
3548
- 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), Er(e, o));
3553
+ 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), Dr(e, o));
3549
3554
  }
3550
- if (t || Or(e), !e.tableHidden) for (let t of fe(e)) {
3555
+ if (t || kr(e), !e.tableHidden) for (let t of pe(e)) {
3551
3556
  let r = t.source;
3552
- t.style.zIndex !== null && de(t, e) && !t.inlineBox ? X(r, "--mw-z", String(t.style.zIndex)) : Z(r, "--mw-z"), Tr(t, !1, n);
3557
+ t.style.zIndex !== null && fe(t, e) && !t.inlineBox ? X(r, "--mw-z", String(t.style.zIndex)) : Z(r, "--mw-z"), Er(t, !1, n);
3553
3558
  }
3554
3559
  }
3555
- function Er(e, t) {
3560
+ function Dr(e, t) {
3556
3561
  Q(e, "data-mw-inline-inset", !0);
3557
3562
  let n = (t, n) => {
3558
3563
  n === null ? Z(e, t) : X(e, t, String(n));
3559
3564
  };
3560
3565
  n("--mw-it", t.top), n("--mw-ir", t.right), n("--mw-ib", t.bottom), n("--mw-il", t.left);
3561
3566
  }
3562
- function Dr(e) {
3567
+ function Or(e) {
3563
3568
  let t = e.style;
3564
3569
  if (t.textAlign !== "center" || !e.text || e.inlineBox || e.children.length > 0) return !1;
3565
- 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 ?? Vn(e, i);
3570
+ 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);
3566
3571
  return o.length !== 0 && o.every((n, r) => {
3567
3572
  let i = r === 0 ? t.textIndent : 0, o = a - i - I(n.start, n.end, e.advances, t.tracking);
3568
3573
  return o > 0 && o % 2 == 1;
3569
3574
  });
3570
3575
  }
3571
- function Or(e) {
3576
+ function kr(e) {
3572
3577
  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;
3573
3578
  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);
3574
3579
  let f = u ?? d;
@@ -3578,28 +3583,28 @@ function Or(e) {
3578
3583
  let { maxX: n, maxY: r } = e.scrollRange;
3579
3584
  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));
3580
3585
  } else Z(t, "--mw-se-x"), Z(t, "--mw-se-y");
3581
- 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", Dr(e)), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
3586
+ 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", Or(e)), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
3582
3587
  }
3583
3588
  //#endregion
3584
3589
  //#region src/style.ts
3585
- function kr(e, t, n) {
3586
- let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = Zr(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
3587
- Kr(e, o, s);
3588
- let c = r.display || Ur[e.tagName] || "", l = Wr[c] ?? "none", u = r.columnCount && r.columnCount !== "auto" ? Math.max(1, Math.floor(Number(r.columnCount) || 1)) : null, d = r.columnWidth && r.columnWidth !== "auto" ? parseFloat(r.columnWidth) : NaN, f = Number.isFinite(d) ? Math.max(1, F(d, t)) : null, p = c === "flex" || c === "inline-flex" ? "flex" : c === "grid" || c === "inline-grid" ? "grid" : c === "table" || c === "inline-table" ? "table" : c === "none" || Hr(e, r) ? "none" : u !== null || f !== null ? "multicol" : "block", m = { kind: "none" }, h = { kind: "none" }, g = [it()], _ = [it()], v = {
3590
+ function Ar(e, t, n) {
3591
+ let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = Qr(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
3592
+ qr(e, o, s);
3593
+ let c = r.display || Wr[e.tagName] || "", l = Gr[c] ?? "none", u = r.columnCount && r.columnCount !== "auto" ? Math.max(1, Math.floor(Number(r.columnCount) || 1)) : null, d = r.columnWidth && r.columnWidth !== "auto" ? parseFloat(r.columnWidth) : NaN, f = Number.isFinite(d) ? Math.max(1, F(d, t)) : null, p = c === "flex" || c === "inline-flex" ? "flex" : c === "grid" || c === "inline-grid" ? "grid" : c === "table" || c === "inline-table" ? "table" : c === "none" || Ur(e, r) ? "none" : u !== null || f !== null ? "multicol" : "block", m = { kind: "none" }, h = { kind: "none" }, g = [at()], _ = [at()], v = {
3589
3594
  direction: "row",
3590
3595
  dense: !1
3591
3596
  }, y = null;
3592
3597
  if (p === "grid") {
3593
- if (a) m = _i(a.get("grid-template-columns")?.toString() ?? "", t), h = _i(a.get("grid-template-rows")?.toString() ?? "", t);
3598
+ if (a) m = vi(a.get("grid-template-columns")?.toString() ?? "", t), h = vi(a.get("grid-template-rows")?.toString() ?? "", t);
3594
3599
  else {
3595
3600
  e.setAttribute("data-mw-degrid", "");
3596
3601
  try {
3597
- m = _i(r.getPropertyValue("grid-template-columns"), t), h = _i(r.getPropertyValue("grid-template-rows"), t);
3602
+ m = vi(r.getPropertyValue("grid-template-columns"), t), h = vi(r.getPropertyValue("grid-template-rows"), t);
3598
3603
  } finally {
3599
3604
  e.removeAttribute("data-mw-degrid");
3600
3605
  }
3601
3606
  }
3602
- g = xi(r.getPropertyValue("grid-auto-columns"), t), _ = xi(r.getPropertyValue("grid-auto-rows"), t), v = Di(r.getPropertyValue("grid-auto-flow")), y = bi(r.getPropertyValue("grid-template-areas"));
3607
+ g = Si(r.getPropertyValue("grid-auto-columns"), t), _ = Si(r.getPropertyValue("grid-auto-rows"), t), v = Oi(r.getPropertyValue("grid-auto-flow")), y = xi(r.getPropertyValue("grid-template-areas"));
3603
3608
  }
3604
3609
  let b = "auto", x = !1, S = 0, C = 0;
3605
3610
  if (p === "table" && (b = r.tableLayout === "fixed" ? "fixed" : "auto", x = r.borderCollapse === "collapse", !x)) {
@@ -3614,71 +3619,71 @@ function kr(e, t, n) {
3614
3619
  borderSpacingX: S,
3615
3620
  borderSpacingY: C,
3616
3621
  captionSide: r.captionSide === "bottom" ? "bottom" : "top",
3617
- verticalAlign: l === "cell" || c.startsWith("inline-") ? Gr(e, r) : "start",
3622
+ verticalAlign: l === "cell" || c.startsWith("inline-") ? Kr(e, r) : "start",
3618
3623
  flexDirection: r.flexDirection.startsWith("column") ? "column" : "row",
3619
3624
  flexReverse: r.flexDirection.endsWith("-reverse"),
3620
3625
  flexWrap: r.flexWrap.startsWith("wrap") ? "wrap" : "nowrap",
3621
3626
  wrapReverse: r.flexWrap === "wrap-reverse",
3622
3627
  flexGrow: Number(r.flexGrow) || 0,
3623
3628
  flexShrink: r.flexShrink === "" ? 1 : Number(r.flexShrink) || 0,
3624
- flexBasis: hi(r.flexBasis, t),
3629
+ flexBasis: gi(r.flexBasis, t),
3625
3630
  order: Number(r.order) || 0,
3626
- justifyContent: Qr(r.justifyContent),
3627
- alignContent: Qr(r.alignContent),
3628
- alignItems: $r(r.alignItems),
3629
- alignSelf: ei(r.alignSelf),
3630
- justifyItems: $r(r.justifyItems),
3631
- justifySelf: ei(r.justifySelf),
3631
+ justifyContent: $r(r.justifyContent),
3632
+ alignContent: $r(r.alignContent),
3633
+ alignItems: ei(r.alignItems),
3634
+ alignSelf: ti(r.alignSelf),
3635
+ justifyItems: ei(r.justifyItems),
3636
+ justifySelf: ti(r.justifySelf),
3632
3637
  gridTemplateColumns: m,
3633
3638
  gridTemplateRows: h,
3634
3639
  gridAutoColumns: g,
3635
3640
  gridAutoRows: _,
3636
3641
  gridAutoFlow: v,
3637
3642
  gridTemplateAreas: y,
3638
- gridColumnStart: Ei(r.getPropertyValue("grid-column-start")),
3639
- gridColumnEnd: Ei(r.getPropertyValue("grid-column-end")),
3640
- gridRowStart: Ei(r.getPropertyValue("grid-row-start")),
3641
- gridRowEnd: Ei(r.getPropertyValue("grid-row-end")),
3642
- width: ui(a, r.width, "width", t, o, s, n),
3643
- height: ui(a, r.height, "height", t, o, s, n),
3644
- minWidth: mi(a, "min-width", r.minWidth, o, "min-w", s, n, t) ?? si(r.minWidth, t) ?? "auto",
3645
- minHeight: mi(a, "min-height", r.minHeight, o, "min-h", s, n, t) ?? si(r.minHeight, t) ?? "auto",
3646
- maxWidth: mi(a, "max-width", r.maxWidth, o, "max-w", s, n, t) ?? si(r.maxWidth, t),
3647
- maxHeight: mi(a, "max-height", r.maxHeight, o, "max-h", s, n, t) ?? si(r.maxHeight, t),
3648
- padding: ki(r, t),
3649
- margin: ti(r, a, o, s, t),
3650
- position: ii(r.position),
3651
- insets: ai(r, a, o, s, t),
3643
+ gridColumnStart: Di(r.getPropertyValue("grid-column-start")),
3644
+ gridColumnEnd: Di(r.getPropertyValue("grid-column-end")),
3645
+ gridRowStart: Di(r.getPropertyValue("grid-row-start")),
3646
+ gridRowEnd: Di(r.getPropertyValue("grid-row-end")),
3647
+ width: di(a, r.width, "width", t, o, s, n),
3648
+ height: di(a, r.height, "height", t, o, s, n),
3649
+ minWidth: hi(a, "min-width", r.minWidth, o, "min-w", s, n, t) ?? ci(r.minWidth, t) ?? "auto",
3650
+ minHeight: hi(a, "min-height", r.minHeight, o, "min-h", s, n, t) ?? ci(r.minHeight, t) ?? "auto",
3651
+ maxWidth: hi(a, "max-width", r.maxWidth, o, "max-w", s, n, t) ?? ci(r.maxWidth, t),
3652
+ maxHeight: hi(a, "max-height", r.maxHeight, o, "max-h", s, n, t) ?? ci(r.maxHeight, t),
3653
+ padding: Ai(r, t),
3654
+ margin: ni(r, a, o, s, t),
3655
+ position: ai(r.position),
3656
+ insets: oi(r, a, o, s, t),
3652
3657
  gapX: $(r.columnGap === "normal" || r.columnGap === "" ? p === "multicol" ? `${i}px` : "0px" : r.columnGap, t),
3653
3658
  gapY: $(r.rowGap === "normal" ? "0px" : r.rowGap, t),
3654
- border: Ai(r),
3659
+ border: ji(r),
3655
3660
  borderStyle: {
3656
- top: oi(r.borderTopStyle),
3657
- right: oi(r.borderRightStyle),
3658
- bottom: oi(r.borderBottomStyle),
3659
- left: oi(r.borderLeftStyle)
3661
+ top: si(r.borderTopStyle),
3662
+ right: si(r.borderRightStyle),
3663
+ bottom: si(r.borderBottomStyle),
3664
+ left: si(r.borderLeftStyle)
3660
3665
  },
3661
- overflow: Vr(r),
3662
- scrollbarWidth: Lr(e, r),
3663
- scrollbarColor: Rr(r.scrollbarColor),
3666
+ overflow: Hr(r),
3667
+ scrollbarWidth: Rr(e, r),
3668
+ scrollbarColor: zr(r.scrollbarColor),
3664
3669
  overscroll: {
3665
3670
  x: (r.overscrollBehaviorX || "auto") === "auto",
3666
3671
  y: (r.overscrollBehaviorY || "auto") === "auto"
3667
3672
  },
3668
3673
  scrollbarSize: {
3669
- x: zr(r.getPropertyValue("--mw-scrollbar-x-size")),
3670
- y: zr(r.getPropertyValue("--mw-scrollbar-y-size"))
3674
+ x: Br(r.getPropertyValue("--mw-scrollbar-x-size")),
3675
+ y: Br(r.getPropertyValue("--mw-scrollbar-y-size"))
3671
3676
  },
3672
3677
  whiteSpace: r.whiteSpace === "pre" ? "pre" : r.whiteSpace === "nowrap" ? "nowrap" : "normal",
3673
3678
  tabSize: Math.max(1, Math.floor(parseFloat(r.tabSize)) || 8),
3674
- lineGap: ri(r.lineHeight, i),
3675
- tracking: ni(r.letterSpacing, i, n?.letterSpacing ?? 0),
3679
+ lineGap: ii(r.lineHeight, i),
3680
+ tracking: ri(r.letterSpacing, i, n?.letterSpacing ?? 0),
3676
3681
  textOverflow: r.textOverflow === "ellipsis" ? "ellipsis" : "clip",
3677
3682
  color: r.color,
3678
3683
  fontWeight: r.fontWeight,
3679
3684
  fontStyle: r.fontStyle,
3680
3685
  textDecorationLine: r.textDecorationLine,
3681
- backgroundColor: Mr(e, r.backgroundColor, r),
3686
+ backgroundColor: Nr(e, r.backgroundColor, r),
3682
3687
  backgroundClear: r.getPropertyValue("--mw-bg-clear").trim() === "1",
3683
3688
  borderColor: {
3684
3689
  top: r.borderTopColor,
@@ -3686,18 +3691,18 @@ function kr(e, t, n) {
3686
3691
  bottom: r.borderBottomColor,
3687
3692
  left: r.borderLeftColor
3688
3693
  },
3689
- textAlignBlocked: Yr(e, r),
3690
- textAlign: Xr(e, r),
3691
- textIndent: li(r, t),
3692
- opacity: ci(r.opacity),
3694
+ textAlignBlocked: Xr(e, r),
3695
+ textAlign: Zr(e, r),
3696
+ textIndent: ui(r, t),
3697
+ opacity: li(r.opacity),
3693
3698
  glyphSet: r.getPropertyValue("--mw-border-glyphs").trim() || null,
3694
3699
  zIndex: r.zIndex === "auto" || r.zIndex === "" ? null : Number(r.zIndex) || 0,
3695
3700
  latticeBorder: null,
3696
- ruleX: p === "flex" || p === "grid" || p === "multicol" ? Jr(r, "x") : null,
3697
- ruleY: p === "flex" || p === "grid" ? Jr(r, "y") : null,
3698
- ruleBreak: qr(r, "--mw-rule-break", ["none", "intersection"], "normal"),
3701
+ ruleX: p === "flex" || p === "grid" || p === "multicol" ? Yr(r, "x") : null,
3702
+ ruleY: p === "flex" || p === "grid" ? Yr(r, "y") : null,
3703
+ ruleBreak: Jr(r, "--mw-rule-break", ["none", "intersection"], "normal"),
3699
3704
  ruleInset: r.getPropertyValue("--mw-rule-inset").trim() === "overlap-join" ? "overlap-join" : Math.max(0, P(parseFloat(r.getPropertyValue("--mw-rule-inset")) || 0)),
3700
- ruleVisibilityItems: qr(r, "--mw-rule-visibility-items", [
3705
+ ruleVisibilityItems: Jr(r, "--mw-rule-visibility-items", [
3701
3706
  "all",
3702
3707
  "around",
3703
3708
  "between"
@@ -3710,9 +3715,9 @@ function kr(e, t, n) {
3710
3715
  breakAfterColumn: r.breakAfter === "column",
3711
3716
  breakInsideAvoid: r.breakInside === "avoid" || r.breakInside === "avoid-column"
3712
3717
  };
3713
- return Ar(w, r), w;
3718
+ return jr(w, r), w;
3714
3719
  }
3715
- function Ar(e, t) {
3720
+ function jr(e, t) {
3716
3721
  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 = {
3717
3722
  width: e.border,
3718
3723
  style: e.borderStyle,
@@ -3723,37 +3728,37 @@ function Ar(e, t) {
3723
3728
  bottom: t.borderBottomStyle === "hidden",
3724
3729
  left: t.borderLeftStyle === "hidden"
3725
3730
  }
3726
- }, e.border = rt(), e.display === "table" && (e.padding = rt()));
3731
+ }, e.border = it(), e.display === "table" && (e.padding = it()));
3727
3732
  }
3728
- function jr(e) {
3733
+ function Mr(e) {
3729
3734
  if (!e) return !0;
3730
3735
  let t = e.trim().toLowerCase();
3731
3736
  return t === "" || t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "currentcolor";
3732
3737
  }
3733
- function Mr(e, t, n) {
3734
- let i = r(e, jr(t) ? "" : t, n);
3738
+ function Nr(e, t, n) {
3739
+ let i = r(e, Mr(t) ? "" : t, n);
3735
3740
  return i === "" ? void 0 : i;
3736
3741
  }
3737
- function Nr(e) {
3742
+ function Pr(e) {
3738
3743
  return e === "hidden" || e === "clip";
3739
3744
  }
3740
- var Pr = /* @__PURE__ */ new WeakMap(), Fr = null;
3741
- function Ir(e) {
3742
- if (Fr !== null) return Fr;
3745
+ var Fr = /* @__PURE__ */ new WeakMap(), Ir = null;
3746
+ function Lr(e) {
3747
+ if (Ir !== null) return Ir;
3743
3748
  if (!e.body) return !0;
3744
3749
  let t = e.createElement("div");
3745
- return t.style.cssText = "position: absolute; width: 0; height: 0; overflow: auto", e.body.appendChild(t), Fr = getComputedStyle(t).scrollbarWidth !== "none", t.remove(), Fr;
3750
+ return t.style.cssText = "position: absolute; width: 0; height: 0; overflow: auto", e.body.appendChild(t), Ir = getComputedStyle(t).scrollbarWidth !== "none", t.remove(), Ir;
3746
3751
  }
3747
- function Lr(e, t) {
3748
- if (!Ir(e.ownerDocument)) return "auto";
3752
+ function Rr(e, t) {
3753
+ if (!Lr(e.ownerDocument)) return "auto";
3749
3754
  if (e.hasAttribute("data-mw-scroll")) {
3750
- let t = Pr.get(e);
3755
+ let t = Fr.get(e);
3751
3756
  if (t !== void 0) return t;
3752
3757
  }
3753
3758
  let n = t.scrollbarWidth === "none" ? "none" : "auto";
3754
- return Pr.set(e, n), n;
3759
+ return Fr.set(e, n), n;
3755
3760
  }
3756
- function Rr(e) {
3761
+ function zr(e) {
3757
3762
  let t = (e ?? "").trim();
3758
3763
  if (!t || t === "auto") return null;
3759
3764
  let n = 0;
@@ -3768,25 +3773,25 @@ function Rr(e) {
3768
3773
  }
3769
3774
  return null;
3770
3775
  }
3771
- function zr(e) {
3772
- return Math.max(1, Math.floor(Number(e) || 1));
3773
- }
3774
3776
  function Br(e) {
3775
- return Nr(e) ? "clip" : e === "auto" || e === "scroll" ? e : "visible";
3777
+ return Math.max(1, Math.floor(Number(e) || 1));
3776
3778
  }
3777
3779
  function Vr(e) {
3778
- let t = Br(e.overflowX || e.overflow), n = Br(e.overflowY || e.overflow);
3780
+ return Pr(e) ? "clip" : e === "auto" || e === "scroll" ? e : "visible";
3781
+ }
3782
+ function Hr(e) {
3783
+ let t = Vr(e.overflowX || e.overflow), n = Vr(e.overflowY || e.overflow);
3779
3784
  return t !== "visible" && n === "visible" && (n = "auto"), n !== "visible" && t === "visible" && (t = "auto"), {
3780
3785
  x: t,
3781
3786
  y: n
3782
3787
  };
3783
3788
  }
3784
- function Hr(e, t) {
3789
+ function Ur(e, t) {
3785
3790
  if (t.position !== "absolute" && t.position !== "fixed") return !1;
3786
3791
  let n = t.clip.replace(/\s/g, "");
3787
- return n === "rect(0px,0px,0px,0px)" || n === "rect(0,0,0,0)" || !ie(e.tagName) && (Nr(t.overflow) || Nr(t.overflowX)) && parseFloat(t.width) <= 1 && parseFloat(t.height) <= 1;
3792
+ return n === "rect(0px,0px,0px,0px)" || n === "rect(0,0,0,0)" || !ae(e.tagName) && (Pr(t.overflow) || Pr(t.overflowX)) && parseFloat(t.width) <= 1 && parseFloat(t.height) <= 1;
3788
3793
  }
3789
- var Ur = {
3794
+ var Wr = {
3790
3795
  TABLE: "table",
3791
3796
  THEAD: "table-header-group",
3792
3797
  TBODY: "table-row-group",
@@ -3797,7 +3802,7 @@ var Ur = {
3797
3802
  CAPTION: "table-caption",
3798
3803
  COL: "table-column",
3799
3804
  COLGROUP: "table-column-group"
3800
- }, Wr = {
3805
+ }, Gr = {
3801
3806
  "table-header-group": "header-group",
3802
3807
  "table-row-group": "row-group",
3803
3808
  "table-footer-group": "footer-group",
@@ -3807,38 +3812,38 @@ var Ur = {
3807
3812
  "table-column": "column",
3808
3813
  "table-column-group": "column-group"
3809
3814
  };
3810
- function Gr(e, t) {
3815
+ function Kr(e, t) {
3811
3816
  let n = t.verticalAlign || e.getAttribute("valign")?.toLowerCase() || (e.tagName === "TD" || e.tagName === "TH" ? "middle" : "baseline");
3812
3817
  return n === "top" ? "start" : n === "middle" ? "center" : n === "bottom" ? "end" : "start";
3813
3818
  }
3814
- function Kr(e, t, n) {
3819
+ function qr(e, t, n) {
3815
3820
  (/(?:^|[\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.");
3816
3821
  }
3817
- function qr(e, t, n, r) {
3822
+ function Jr(e, t, n, r) {
3818
3823
  let i = e.getPropertyValue(t).trim();
3819
3824
  return n.includes(i) ? i : r;
3820
3825
  }
3821
- function Jr(e, t) {
3826
+ function Yr(e, t) {
3822
3827
  let n = P(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
3823
3828
  if (n <= 0) return null;
3824
3829
  let r = e.getPropertyValue(`--mw-rule-${t}-color`).trim();
3825
3830
  return {
3826
3831
  width: n,
3827
- style: oi(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3832
+ style: si(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3828
3833
  color: r && r !== "currentcolor" && r !== "currentColor" ? r : e.color
3829
3834
  };
3830
3835
  }
3831
- function Yr(e, t) {
3836
+ function Xr(e, t) {
3832
3837
  return t.textAlign === "justify" || e.getAttribute("align")?.toLowerCase() === "justify";
3833
3838
  }
3834
- function Xr(e, t) {
3839
+ function Zr(e, t) {
3835
3840
  let n = t.textAlign || e.getAttribute("align")?.toLowerCase() || "";
3836
3841
  return n === "right" || n === "end" ? "end" : n === "center" || n.endsWith("-center") ? "center" : "start";
3837
3842
  }
3838
- function Zr(e) {
3843
+ function Qr(e) {
3839
3844
  return typeof e.computedStyleMap == "function";
3840
3845
  }
3841
- function Qr(e) {
3846
+ function $r(e) {
3842
3847
  switch (e) {
3843
3848
  case "center": return "center";
3844
3849
  case "flex-end":
@@ -3853,7 +3858,7 @@ function Qr(e) {
3853
3858
  default: return "start";
3854
3859
  }
3855
3860
  }
3856
- function $r(e) {
3861
+ function ei(e) {
3857
3862
  switch (e) {
3858
3863
  case "center": return "center";
3859
3864
  case "flex-end":
@@ -3864,10 +3869,10 @@ function $r(e) {
3864
3869
  default: return "start";
3865
3870
  }
3866
3871
  }
3867
- function ei(e) {
3868
- return e === "auto" || e === "" || e === "normal" ? "auto" : $r(e);
3872
+ function ti(e) {
3873
+ return e === "auto" || e === "" || e === "normal" ? "auto" : ei(e);
3869
3874
  }
3870
- function ti(e, t, n, r, i) {
3875
+ function ni(e, t, n, r, i) {
3871
3876
  let a = (a, o, s) => {
3872
3877
  if (t) {
3873
3878
  let e = t.get(a)?.toString().trim();
@@ -3891,16 +3896,16 @@ function ti(e, t, n, r, i) {
3891
3896
  left: a("margin-left", "margin-inline-start", /(?:^|[\s:.[!])(?:m|mx|ml|ms)-auto\b/)
3892
3897
  };
3893
3898
  }
3894
- function ni(e, t, n) {
3899
+ function ri(e, t, n) {
3895
3900
  let r = (e === "normal" ? 0 : parseFloat(e) || 0) - n;
3896
3901
  return r <= 0 ? 0 : Math.floor(r / (.025 * t) + 1e-6);
3897
3902
  }
3898
- function ri(e, t) {
3903
+ function ii(e, t) {
3899
3904
  if (!e || e === "normal" || t <= 0) return 0;
3900
3905
  let n = parseFloat(e);
3901
3906
  return Number.isFinite(n) ? Math.max(0, Math.floor(n / t + 1e-6) - 1) : 0;
3902
3907
  }
3903
- function ii(e) {
3908
+ function ai(e) {
3904
3909
  switch (e) {
3905
3910
  case "relative":
3906
3911
  case "absolute":
@@ -3909,7 +3914,7 @@ function ii(e) {
3909
3914
  default: return "static";
3910
3915
  }
3911
3916
  }
3912
- function ai(e, t, n, r, i) {
3917
+ function oi(e, t, n, r, i) {
3913
3918
  let a = (a, o) => {
3914
3919
  if (t) {
3915
3920
  let e = t.get(a)?.toString().trim();
@@ -3928,7 +3933,7 @@ function ai(e, t, n, r, i) {
3928
3933
  left: a("left", /(?:^|[\s:.[!])-?(?:left|start|inset|inset-x)-/)
3929
3934
  };
3930
3935
  }
3931
- function oi(e) {
3936
+ function si(e) {
3932
3937
  switch (e) {
3933
3938
  case "double": return "double";
3934
3939
  case "dashed": return "dashed";
@@ -3936,7 +3941,7 @@ function oi(e) {
3936
3941
  default: return "solid";
3937
3942
  }
3938
3943
  }
3939
- function si(e, t) {
3944
+ function ci(e, t) {
3940
3945
  if (!e || e === "none" || e === "auto") return;
3941
3946
  if (e === "min-content" || e === "max-content" || e === "fit-content") return e;
3942
3947
  if (e.endsWith("%")) {
@@ -3955,28 +3960,28 @@ function $(e, t) {
3955
3960
  let n = parseFloat(e);
3956
3961
  return Number.isFinite(n) ? F(n, t) : 0;
3957
3962
  }
3958
- function ci(e) {
3963
+ function li(e) {
3959
3964
  let t = parseFloat(e);
3960
3965
  return Number.isFinite(t) ? Math.min(1, Math.max(0, t)) : 1;
3961
3966
  }
3962
- function li(e, t) {
3967
+ function ui(e, t) {
3963
3968
  let n = e.textIndent;
3964
3969
  if (!n || n.endsWith("%")) return 0;
3965
3970
  let r = parseFloat(n);
3966
3971
  return Number.isFinite(r) ? Math.max(0, F(r, t)) : 0;
3967
3972
  }
3968
- function ui(e, t, n, r, i, a, o) {
3969
- let s = di(n === "width" ? a.width : a.height);
3973
+ function di(e, t, n, r, i, a, o) {
3974
+ let s = fi(n === "width" ? a.width : a.height);
3970
3975
  if (s !== null) return {
3971
3976
  kind: "cells",
3972
- value: pi(s, n, o, r)
3977
+ value: mi(s, n, o, r)
3973
3978
  };
3974
- let c = fi(i, n === "width" ? "w" : "h");
3979
+ let c = pi(i, n === "width" ? "w" : "h");
3975
3980
  if (c !== null) {
3976
3981
  let i = parseFloat(e ? String(e.get(n) ?? "") : t), a = Number.isFinite(i) && Math.abs(i - c) <= c * .3;
3977
3982
  if (a || !Number.isFinite(i)) return {
3978
3983
  kind: "cells",
3979
- value: pi(a ? i : c, n, o, r)
3984
+ value: mi(a ? i : c, n, o, r)
3980
3985
  };
3981
3986
  }
3982
3987
  if (e) {
@@ -3984,7 +3989,7 @@ function ui(e, t, n, r, i, a, o) {
3984
3989
  if (t == null) return;
3985
3990
  let i = t.toString().trim();
3986
3991
  if (i === "auto") return { kind: "auto" };
3987
- let a = gi(i);
3992
+ let a = _i(i);
3988
3993
  if (a) return a;
3989
3994
  if (i.endsWith("%")) return {
3990
3995
  kind: "percent",
@@ -3998,16 +4003,16 @@ function ui(e, t, n, r, i, a, o) {
3998
4003
  kind: "cells",
3999
4004
  value: P(parseFloat(i) / .25)
4000
4005
  };
4001
- let s = di(i);
4006
+ let s = fi(i);
4002
4007
  if (s !== null) return {
4003
4008
  kind: "cells",
4004
- value: pi(s, n, o, r)
4009
+ value: mi(s, n, o, r)
4005
4010
  };
4006
4011
  }
4007
4012
  let l = n === "width" ? a.width : a.height;
4008
4013
  if (l) {
4009
4014
  if (l === "auto") return { kind: "auto" };
4010
- let e = gi(l);
4015
+ let e = _i(l);
4011
4016
  if (e) return e;
4012
4017
  if (l.endsWith("%")) return {
4013
4018
  kind: "percent",
@@ -4042,7 +4047,7 @@ function ui(e, t, n, r, i, a, o) {
4042
4047
  kind: "cells",
4043
4048
  value: P(Number(p[1]))
4044
4049
  };
4045
- if (!Oi(i, u) || t === "auto") return { kind: "auto" };
4050
+ if (!ki(i, u) || t === "auto") return { kind: "auto" };
4046
4051
  if (t.endsWith("%")) return {
4047
4052
  kind: "percent",
4048
4053
  value: parseFloat(t)
@@ -4053,7 +4058,7 @@ function ui(e, t, n, r, i, a, o) {
4053
4058
  value: F(m, r)
4054
4059
  };
4055
4060
  }
4056
- function di(e) {
4061
+ function fi(e) {
4057
4062
  let t = /^(-?[\d.]+)((?:[dsl]?v)(?:h|w|min|max)|vi|vb)$/.exec(e.trim());
4058
4063
  if (!t || typeof window > "u") return null;
4059
4064
  let n = parseFloat(t[1]);
@@ -4061,7 +4066,7 @@ function di(e) {
4061
4066
  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;
4062
4067
  return n / 100 * o;
4063
4068
  }
4064
- function fi(e, t) {
4069
+ function pi(e, t) {
4065
4070
  if (typeof window > "u") return null;
4066
4071
  let n = RegExp(`(?:^|[\\s:.[!])${t}-(screen|[dsl]v[hw])(?![\\w-])`).exec(e);
4067
4072
  if (n) {
@@ -4069,23 +4074,23 @@ function fi(e, t) {
4069
4074
  return e === "screen" ? t.includes("h") ? window.innerHeight : window.innerWidth : e.endsWith("h") ? window.innerHeight : window.innerWidth;
4070
4075
  }
4071
4076
  let r = RegExp(`(?:^|[\\s:.[!])${t}-\\[(-?[\\d.]+(?:[dsl]?v(?:h|w|min|max)|vi|vb))\\]`).exec(e);
4072
- return r ? di(r[1]) : null;
4077
+ return r ? fi(r[1]) : null;
4073
4078
  }
4074
- function pi(e, t, n, r) {
4079
+ function mi(e, t, n, r) {
4075
4080
  let i = t === "width" ? n?.width : n?.height;
4076
4081
  return i && i > 0 ? Math.max(0, Math.floor(e / i)) : F(e, r);
4077
4082
  }
4078
- function mi(e, t, n, r, i, a, o, s) {
4079
- let c = t.endsWith("width") ? "width" : "height", l = di(a.getPropertyValue(t)) ?? di(e?.get(t)?.toString().trim() ?? "");
4080
- if (l !== null) return pi(l, c, o, s);
4081
- let u = fi(r, i);
4083
+ function hi(e, t, n, r, i, a, o, s) {
4084
+ let c = t.endsWith("width") ? "width" : "height", l = fi(a.getPropertyValue(t)) ?? fi(e?.get(t)?.toString().trim() ?? "");
4085
+ if (l !== null) return mi(l, c, o, s);
4086
+ let u = pi(r, i);
4082
4087
  if (u === null) return;
4083
4088
  let d = parseFloat(e ? String(e.get(t) ?? "") : n), f = Number.isFinite(d) && Math.abs(d - u) <= u * .3;
4084
- if (!(!f && Number.isFinite(d))) return pi(f ? d : u, c, o, s);
4089
+ if (!(!f && Number.isFinite(d))) return mi(f ? d : u, c, o, s);
4085
4090
  }
4086
- function hi(e, t) {
4091
+ function gi(e, t) {
4087
4092
  if (!e || e === "auto" || e === "content") return;
4088
- let n = gi(e);
4093
+ let n = _i(e);
4089
4094
  if (n) return n;
4090
4095
  if (e.endsWith("%")) {
4091
4096
  let t = parseFloat(e);
@@ -4100,27 +4105,27 @@ function hi(e, t) {
4100
4105
  value: F(r, t)
4101
4106
  } : void 0;
4102
4107
  }
4103
- function gi(e) {
4108
+ function _i(e) {
4104
4109
  if (e === "min-content") return { kind: "min-content" };
4105
4110
  if (e === "max-content") return { kind: "max-content" };
4106
4111
  if (e === "fit-content") return { kind: "fit-content" };
4107
4112
  }
4108
- function _i(e, t) {
4113
+ function vi(e, t) {
4109
4114
  let n = e.trim();
4110
4115
  if (!n || n === "none") return { kind: "none" };
4111
4116
  if (n === "subgrid" || n.startsWith("subgrid ")) return { kind: "subgrid" };
4112
4117
  let r = [], i = [], a = [], o = (e) => {
4113
4118
  i.push(a), a = [], r.push(e);
4114
4119
  }, s;
4115
- for (let e of Ti(n)) {
4116
- let n = yi(e);
4120
+ for (let e of Ei(n)) {
4121
+ let n = bi(e);
4117
4122
  if (n) {
4118
4123
  a.push(...n);
4119
4124
  continue;
4120
4125
  }
4121
4126
  let i = e.match(/^repeat\(\s*([^,]+?)\s*,(.*)\)$/s);
4122
4127
  if (i) {
4123
- let e = vi(i[2].trim(), t);
4128
+ let e = yi(i[2].trim(), t);
4124
4129
  if (e.tracks.length === 0) continue;
4125
4130
  let n = i[1];
4126
4131
  if (n === "auto-fill" || n === "auto-fit") {
@@ -4138,7 +4143,7 @@ function _i(e, t) {
4138
4143
  }
4139
4144
  continue;
4140
4145
  }
4141
- o(Si(e, t));
4146
+ o(Ci(e, t));
4142
4147
  }
4143
4148
  if (i.push(a), r.length === 0 && !s) return { kind: "none" };
4144
4149
  let c = {
@@ -4147,26 +4152,26 @@ function _i(e, t) {
4147
4152
  };
4148
4153
  return i.some((e) => e.length > 0) && (c.lineNames = i), s && (c.autoRepeat = s), c;
4149
4154
  }
4150
- function vi(e, t) {
4155
+ function yi(e, t) {
4151
4156
  let n = [], r = [], i = [];
4152
- for (let a of Ti(e)) {
4153
- let e = yi(a);
4157
+ for (let a of Ei(e)) {
4158
+ let e = bi(a);
4154
4159
  if (e) {
4155
4160
  i.push(...e);
4156
4161
  continue;
4157
4162
  }
4158
- r.push(i), i = [], n.push(Si(a, t));
4163
+ r.push(i), i = [], n.push(Ci(a, t));
4159
4164
  }
4160
4165
  return r.push(i), {
4161
4166
  tracks: n,
4162
4167
  lineNames: r
4163
4168
  };
4164
4169
  }
4165
- function yi(e) {
4170
+ function bi(e) {
4166
4171
  let t = e.match(/^\[(.*)\]$/s);
4167
4172
  return t ? t[1].split(/\s+/).filter((e) => e !== "") : null;
4168
4173
  }
4169
- function bi(e) {
4174
+ function xi(e) {
4170
4175
  let t = [];
4171
4176
  for (let n of e.matchAll(/"([^"]*)"|'([^']*)'/g)) {
4172
4177
  let e = (n[1] ?? n[2] ?? "").trim().split(/\s+/).filter((e) => e !== "");
@@ -4196,23 +4201,23 @@ function bi(e) {
4196
4201
  areas: r
4197
4202
  };
4198
4203
  }
4199
- function xi(e, t) {
4200
- let n = Ti(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => Si(e, t));
4201
- return n.length > 0 ? n : [it()];
4202
- }
4203
4204
  function Si(e, t) {
4205
+ let n = Ei(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => Ci(e, t));
4206
+ return n.length > 0 ? n : [at()];
4207
+ }
4208
+ function Ci(e, t) {
4204
4209
  let n = e.match(/^minmax\((.*)\)$/s);
4205
4210
  if (n) {
4206
- let e = wi(n[1]).map((e) => e.trim());
4211
+ let e = Ti(n[1]).map((e) => e.trim());
4207
4212
  return e.length === 2 ? {
4208
- min: Ci(e[0], t),
4209
- max: Ci(e[1], t)
4213
+ min: wi(e[0], t),
4214
+ max: wi(e[1], t)
4210
4215
  } : {
4211
4216
  min: { kind: "auto" },
4212
4217
  max: { kind: "auto" }
4213
4218
  };
4214
4219
  }
4215
- let r = Ci(e, t);
4220
+ let r = wi(e, t);
4216
4221
  return r.kind === "fr" ? {
4217
4222
  min: { kind: "auto" },
4218
4223
  max: r
@@ -4221,13 +4226,13 @@ function Si(e, t) {
4221
4226
  max: r
4222
4227
  };
4223
4228
  }
4224
- function Ci(e, t) {
4229
+ function wi(e, t) {
4225
4230
  if (e === "auto" || e.startsWith("fit-content")) return { kind: "auto" };
4226
4231
  if (e === "min-content") return { kind: "min-content" };
4227
4232
  if (e === "max-content") return { kind: "max-content" };
4228
4233
  let n = e.match(/^(min|max)\((.*)\)$/s);
4229
4234
  if (n) {
4230
- let e = wi(n[2]).map((e) => Ci(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
4235
+ let e = Ti(n[2]).map((e) => wi(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
4231
4236
  return e.length > 0 && r ? {
4232
4237
  kind: "math",
4233
4238
  fn: n[1],
@@ -4254,7 +4259,7 @@ function Ci(e, t) {
4254
4259
  value: e.endsWith("rem") ? P(r / .25) : F(r, t)
4255
4260
  } : { kind: "auto" };
4256
4261
  }
4257
- function wi(e) {
4262
+ function Ti(e) {
4258
4263
  let t = [], n = 0, r = 0;
4259
4264
  for (let i = 0; i < e.length; i++) {
4260
4265
  let a = e[i];
@@ -4262,7 +4267,7 @@ function wi(e) {
4262
4267
  }
4263
4268
  return t.push(e.slice(r)), t.filter((e) => e.trim() !== "");
4264
4269
  }
4265
- function Ti(e) {
4270
+ function Ei(e) {
4266
4271
  let t = [], n = 0, r = -1;
4267
4272
  for (let i = 0; i < e.length; i++) {
4268
4273
  let a = e[i];
@@ -4270,7 +4275,7 @@ function Ti(e) {
4270
4275
  }
4271
4276
  return r !== -1 && t.push(e.slice(r)), t;
4272
4277
  }
4273
- function Ei(e) {
4278
+ function Di(e) {
4274
4279
  let t = e.trim();
4275
4280
  if (!t || t === "auto") return { kind: "auto" };
4276
4281
  let n = !1, r, i;
@@ -4298,16 +4303,16 @@ function Ei(e) {
4298
4303
  nth: r
4299
4304
  };
4300
4305
  }
4301
- function Di(e) {
4306
+ function Oi(e) {
4302
4307
  return {
4303
4308
  direction: e.includes("column") ? "column" : "row",
4304
4309
  dense: e.includes("dense")
4305
4310
  };
4306
4311
  }
4307
- function Oi(e, t) {
4312
+ function ki(e, t) {
4308
4313
  return (t === "w" ? /(?:^|[\s:.[!])w-/ : /(?:^|[\s:.[!])h-/).test(e);
4309
4314
  }
4310
- function ki(e, t) {
4315
+ function Ai(e, t) {
4311
4316
  return {
4312
4317
  top: $(e.getPropertyValue("padding-top"), t),
4313
4318
  right: $(e.getPropertyValue("padding-right"), t),
@@ -4315,7 +4320,7 @@ function ki(e, t) {
4315
4320
  left: $(e.getPropertyValue("padding-left"), t)
4316
4321
  };
4317
4322
  }
4318
- function Ai(e) {
4323
+ function ji(e) {
4319
4324
  let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : P(parseFloat(e.getPropertyValue(t)) || 0);
4320
4325
  return {
4321
4326
  top: t("border-top-width", "border-top-style"),
@@ -4326,14 +4331,14 @@ function Ai(e) {
4326
4331
  }
4327
4332
  //#endregion
4328
4333
  //#region src/tree.ts
4329
- function ji(e, t, n, r) {
4330
- let i = kr(e, t, n);
4334
+ function Mi(e, t, n, r) {
4335
+ let i = Ar(e, t, n);
4331
4336
  if (i.display === "none") return null;
4332
- let a = ie(e.tagName);
4333
- if (a) return Mi(e, i, a);
4334
- let o = Array.from(e.children), s = o.map(Li), c = e.tagName, l = Ji(c);
4337
+ let a = ae(e.tagName);
4338
+ if (a) return Ni(e, i, a);
4339
+ let o = Array.from(e.children), s = o.map(Ri), c = e.tagName, l = Yi(c);
4335
4340
  if (!s.includes("block") || l) {
4336
- let a = Ri(e, i.tracking, {
4341
+ let a = zi(e, i.tracking, {
4337
4342
  rootFontSizePx: t,
4338
4343
  rootLetterSpacingPx: n?.letterSpacing ?? 0,
4339
4344
  cellMetrics: n,
@@ -4342,12 +4347,12 @@ function ji(e, t, n, r) {
4342
4347
  tabSize: i.tabSize
4343
4348
  }), u = a.chars.join("");
4344
4349
  if (a.boxes.length > 0) {
4345
- let e = In();
4346
- Pe(a.chars, (t, n) => {
4350
+ let e = Ln();
4351
+ Fe(a.chars, (t, n) => {
4347
4352
  a.advances[t] = Math.max(1, J(a.boxes[n], e));
4348
4353
  });
4349
4354
  }
4350
- let d = Ui(u, a.advances, i.tracking);
4355
+ let d = Wi(u, a.advances, i.tracking);
4351
4356
  if (l && d === 0) {
4352
4357
  if (c === "INPUT") d = Number(e.size) || 20;
4353
4358
  else if (c === "TEXTAREA") d = Number(e.cols) || 20;
@@ -4356,9 +4361,9 @@ function ji(e, t, n, r) {
4356
4361
  d = Math.max(1, ...r.map((e) => e.trim().length));
4357
4362
  }
4358
4363
  }
4359
- let f = u.length > 0 ? Wi(u) : 0, p;
4364
+ let f = u.length > 0 ? Gi(u) : 0, p;
4360
4365
  if (c === "TEXTAREA") {
4361
- 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);
4366
+ 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);
4362
4367
  p = l + Math.max(0, l - 1) * i.lineGap;
4363
4368
  } else p = l ? Math.max(1, f) : f;
4364
4369
  let m = /* @__PURE__ */ new Map(), h = [];
@@ -4368,7 +4373,7 @@ function ji(e, t, n, r) {
4368
4373
  let i = o[e], a = m.get(i);
4369
4374
  if (a) g.push(a);
4370
4375
  else if (s[e] === "out-of-flow") {
4371
- let e = ji(i, t, n, r);
4376
+ let e = Mi(i, t, n, r);
4372
4377
  e && g.push(e);
4373
4378
  }
4374
4379
  }
@@ -4387,14 +4392,14 @@ function ji(e, t, n, r) {
4387
4392
  height: p
4388
4393
  },
4389
4394
  unclampedHeight: 0,
4390
- resolvedPadding: rt()
4395
+ resolvedPadding: it()
4391
4396
  };
4392
4397
  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)), _;
4393
4398
  }
4394
4399
  let u = [];
4395
4400
  for (let e = 0; e < o.length; e++) {
4396
4401
  if (s[e] === "none") continue;
4397
- let i = ji(o[e], t, n, r);
4402
+ let i = Mi(o[e], t, n, r);
4398
4403
  i && u.push(i);
4399
4404
  }
4400
4405
  let d = {
@@ -4411,14 +4416,14 @@ function ji(e, t, n, r) {
4411
4416
  height: 0
4412
4417
  },
4413
4418
  unclampedHeight: 0,
4414
- resolvedPadding: rt()
4419
+ resolvedPadding: it()
4415
4420
  };
4416
- return Yi(e, d), d;
4421
+ return Xi(e, d), d;
4417
4422
  }
4418
- function Mi(e, t, n) {
4419
- let r = se(n, e), i = r?.lines ?? [], a = i.join("\n");
4423
+ function Ni(e, t, n) {
4424
+ let r = ce(n, e), i = r?.lines ?? [], a = i.join("\n");
4420
4425
  t.whiteSpace = "pre", (t.width === void 0 || t.width.kind === "auto") && (t.width = { kind: "max-content" });
4421
- let o = Array.from({ length: a.length }, () => 1 + t.tracking), s = Ui(a, o, t.tracking), c = i.length, l = {
4426
+ let o = Array.from({ length: a.length }, () => 1 + t.tracking), s = Wi(a, o, t.tracking), c = i.length, l = {
4422
4427
  source: e,
4423
4428
  style: t,
4424
4429
  children: [],
@@ -4432,7 +4437,7 @@ function Mi(e, t, n) {
4432
4437
  height: c
4433
4438
  },
4434
4439
  unclampedHeight: 0,
4435
- resolvedPadding: rt()
4440
+ resolvedPadding: it()
4436
4441
  };
4437
4442
  t.tracking > 0 && (l.advances = o);
4438
4443
  let u = r?.runs ?? [];
@@ -4460,23 +4465,23 @@ function Mi(e, t, n) {
4460
4465
  }
4461
4466
  return l;
4462
4467
  }
4463
- var Ni = /* @__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("."));
4464
- function Pi(e, t) {
4465
- return t || (Ni.has(e.tagName) ? "inline" : "block");
4466
- }
4468
+ var Pi = /* @__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("."));
4467
4469
  function Fi(e, t) {
4468
- let n = Pi(e, t);
4469
- return n === "inline" || n === "contents";
4470
+ return t || (Pi.has(e.tagName) ? "inline" : "block");
4470
4471
  }
4471
4472
  function Ii(e, t) {
4472
- let n = Pi(e, t);
4473
+ let n = Fi(e, t);
4474
+ return n === "inline" || n === "contents";
4475
+ }
4476
+ function Li(e, t) {
4477
+ let n = Fi(e, t);
4473
4478
  return n.startsWith("inline") && n !== "inline";
4474
4479
  }
4475
- function Li(e) {
4480
+ function Ri(e) {
4476
4481
  let t = getComputedStyle(e);
4477
- return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : ie(e.tagName) ? "block" : Fi(e, t.display) || Ii(e, t.display) ? "inline" : "block";
4482
+ return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : ae(e.tagName) ? "block" : Ii(e, t.display) || Li(e, t.display) ? "inline" : "block";
4478
4483
  }
4479
- function Ri(e, t, n) {
4484
+ function zi(e, t, n) {
4480
4485
  let r = {
4481
4486
  chars: [],
4482
4487
  advances: [],
@@ -4484,15 +4489,15 @@ function Ri(e, t, n) {
4484
4489
  inlineElements: [],
4485
4490
  boxes: []
4486
4491
  };
4487
- return zi(e, t, n, r), n.preserve ? r : Hi(r);
4492
+ return Bi(e, t, n, r), n.preserve ? r : Ui(r);
4488
4493
  }
4489
- function zi(e, t, n, r) {
4494
+ function Bi(e, t, n, r) {
4490
4495
  let i = () => {
4491
4496
  let e = 0;
4492
4497
  for (let t = r.chars.length - 1; t >= 0 && r.chars[t] !== "\n"; t--) e += r.advances[t];
4493
4498
  return e;
4494
4499
  };
4495
- if (!Ji(e.tagName)) {
4500
+ if (!Yi(e.tagName)) {
4496
4501
  for (let a of Array.from(e.childNodes)) if (a.nodeType === Node.TEXT_NODE) {
4497
4502
  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);
4498
4503
  else if (e === " ") {
@@ -4508,24 +4513,24 @@ function zi(e, t, n, r) {
4508
4513
  }
4509
4514
  let t = getComputedStyle(e);
4510
4515
  if (t.display === "none" || t.position === "absolute" || t.position === "fixed") continue;
4511
- if (Ii(e, t.display)) {
4512
- let t = ji(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4516
+ if (Li(e, t.display)) {
4517
+ let t = Mi(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4513
4518
  t && (t.inlineBox = !0, r.chars.push(""), r.advances.push(1), r.boxes.push(t));
4514
4519
  continue;
4515
4520
  }
4516
- if (!Fi(e, t.display)) {
4517
- Gi(e);
4521
+ if (!Ii(e, t.display)) {
4522
+ Ki(e);
4518
4523
  continue;
4519
4524
  }
4520
- let i = ni(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = Bi(t.paddingLeft, n.rootFontSizePx), s = Bi(t.paddingRight, n.rootFontSizePx);
4525
+ let i = ri(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = Vi(t.paddingLeft, n.rootFontSizePx), s = Vi(t.paddingRight, n.rootFontSizePx);
4521
4526
  r.inlineElements.push({
4522
4527
  element: e,
4523
4528
  tracking: i,
4524
4529
  padLeft: o,
4525
4530
  padRight: s,
4526
- insets: t.position === "static" ? null : Vi(t, n.rootFontSizePx),
4531
+ insets: t.position === "static" ? null : Hi(t, n.rootFontSizePx),
4527
4532
  color: t.color,
4528
- backgroundColor: jr(t.backgroundColor) ? void 0 : t.backgroundColor,
4533
+ backgroundColor: Mr(t.backgroundColor) ? void 0 : t.backgroundColor,
4529
4534
  fontWeight: t.fontWeight,
4530
4535
  fontStyle: t.fontStyle,
4531
4536
  textDecorationLine: t.textDecorationLine
@@ -4533,18 +4538,18 @@ function zi(e, t, n, r) {
4533
4538
  let c = r.inlineElements.length - 1;
4534
4539
  for (let e = 0; e < o; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
4535
4540
  let l = r.chars.length;
4536
- zi(e, i, n, r);
4541
+ Bi(e, i, n, r);
4537
4542
  for (let e = l; e < r.chars.length; e++) r.inlineIndex[e] === void 0 && (r.inlineIndex[e] = c);
4538
4543
  for (let e = 0; e < s; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
4539
4544
  }
4540
4545
  }
4541
4546
  }
4542
- function Bi(e, t) {
4547
+ function Vi(e, t) {
4543
4548
  if (!e || e.endsWith("%")) return 0;
4544
4549
  let n = parseFloat(e);
4545
4550
  return Number.isFinite(n) ? Math.max(0, F(n, t)) : 0;
4546
4551
  }
4547
- function Vi(e, t) {
4552
+ function Hi(e, t) {
4548
4553
  let n = (e) => {
4549
4554
  if (!e || e === "auto" || e.endsWith("%")) return null;
4550
4555
  let n = parseFloat(e);
@@ -4557,7 +4562,7 @@ function Vi(e, t) {
4557
4562
  left: n(e.left)
4558
4563
  };
4559
4564
  }
4560
- function Hi(e) {
4565
+ function Ui(e) {
4561
4566
  let t = [], n = [], r = [], i = () => {
4562
4567
  let e = t.length;
4563
4568
  for (; e > 0 && t[e - 1] !== "\n";) e--;
@@ -4582,30 +4587,30 @@ function Hi(e) {
4582
4587
  boxes: e.boxes
4583
4588
  };
4584
4589
  }
4585
- function Ui(e, t, n) {
4590
+ function Wi(e, t, n) {
4586
4591
  let r = 0, i = 0;
4587
4592
  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);
4588
4593
  return r;
4589
4594
  }
4590
- function Wi(e) {
4591
- return ke(e).length;
4592
- }
4593
4595
  function Gi(e) {
4594
- 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.");
4596
+ return Ae(e).length;
4595
4597
  }
4596
4598
  function Ki(e) {
4599
+ 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.");
4600
+ }
4601
+ function qi(e) {
4597
4602
  return Array.from(e.childNodes).some((e) => e.nodeType === Node.TEXT_NODE && /[^ \t\r\n\f]/.test(e.textContent ?? ""));
4598
4603
  }
4599
- 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>).";
4600
- function Ji(e) {
4604
+ var Ji = "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>).";
4605
+ function Yi(e) {
4601
4606
  return e === "INPUT" || e === "SELECT" || e === "TEXTAREA";
4602
4607
  }
4603
- function Yi(e, t) {
4604
- Ki(e) && (t.droppedText = !0, N(e, qi));
4608
+ function Xi(e, t) {
4609
+ qi(e) && (t.droppedText = !0, N(e, Ji));
4605
4610
  }
4606
4611
  //#endregion
4607
4612
  //#region src/element.ts
4608
- var Xi = "\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", Zi = "grid", Qi = [
4613
+ var Zi = "\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", Qi = "grid", $i = [
4609
4614
  "pointerover",
4610
4615
  "pointerleave",
4611
4616
  "pointerdown",
@@ -4617,12 +4622,12 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
4617
4622
  "focusout",
4618
4623
  "input",
4619
4624
  "change"
4620
- ], $i = /^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/, ea = 3e4, ta = 200, na = 3, ra = 4, ia = 8, aa = 160, oa = typeof HTMLElement > "u" ? class {} : HTMLElement, sa = class e extends oa {
4625
+ ], ea = /^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/, ta = 3e4, na = 200, ra = 3, ia = 4, aa = 8, oa = 100, sa = 160, ca = typeof HTMLElement > "u" ? class {} : HTMLElement, la = class e extends ca {
4621
4626
  static observedAttributes = ["select"];
4622
4627
  static #e = /* @__PURE__ */ new Set();
4623
4628
  static #t = null;
4624
4629
  static #n = () => {
4625
- for (let t of e.#e) t.#se();
4630
+ for (let t of e.#e) t.#fe();
4626
4631
  };
4627
4632
  static #r(t) {
4628
4633
  t instanceof HTMLLinkElement && t.rel === "stylesheet" && !t.sheet && t.addEventListener("load", e.#n, { once: !0 });
@@ -4659,7 +4664,8 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
4659
4664
  #y = /* @__PURE__ */ new WeakMap();
4660
4665
  #b = null;
4661
4666
  #x = null;
4662
- #S() {
4667
+ #S = [];
4668
+ #C() {
4663
4669
  this.#u?.observe(this, {
4664
4670
  childList: !0,
4665
4671
  subtree: !0,
@@ -4671,73 +4677,80 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
4671
4677
  "colspan",
4672
4678
  "rowspan",
4673
4679
  "span",
4674
- ...ae()
4680
+ ...oe()
4675
4681
  ]
4676
4682
  });
4677
4683
  }
4678
4684
  constructor() {
4679
- super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = Xi, 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);
4685
+ super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = Zi, 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);
4680
4686
  }
4681
4687
  connectedCallback() {
4682
- this.hasAttribute("select") || this.setAttribute("select", Zi), this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#se()), this.#l.observe(this), this.#l.observe(this.#c), window.addEventListener("resize", this.#re), this.#u = new MutationObserver(() => this.#se()), this.#S(), this.#m = oe(() => {
4683
- this.#S(), this.#se();
4684
- }), this.#h = C(() => this.#se()), document.fonts?.ready.then(this.#ie).catch((e) => {
4688
+ this.hasAttribute("select") || this.setAttribute("select", Qi), 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(() => {
4689
+ this.#C(), this.#fe();
4690
+ }), this.#h = C(() => this.#fe()), document.fonts?.ready.then(this.#le).catch((e) => {
4685
4691
  console.warn("[monowind] document.fonts.ready failed:", e);
4686
- }), document.fonts?.addEventListener("loadingdone", this.#ie);
4687
- for (let e of Qi) this.addEventListener(e, this.#ne);
4688
- this.addEventListener("transitionrun", this.#$), this.addEventListener("transitionend", this.#ee), this.addEventListener("transitioncancel", this.#ee), this.addEventListener("pointermove", this.#U), this.addEventListener("pointerleave", this.#W), this.addEventListener("pointerdown", this.#G), this.addEventListener("scroll", this.#L, {
4692
+ }), document.fonts?.addEventListener("loadingdone", this.#le);
4693
+ for (let e of $i) this.addEventListener(e, this.#se);
4694
+ 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, {
4689
4695
  capture: !0,
4690
4696
  passive: !0
4691
- }), this.addEventListener("scrollend", this.#R, { capture: !0 }), this.addEventListener("wheel", this.#B, { passive: !1 }), window.addEventListener("pointerup", this.#K), window.addEventListener("pointercancel", this.#K), document.addEventListener("scroll", this.#q, {
4697
+ }), 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, {
4692
4698
  capture: !0,
4693
4699
  passive: !0
4694
- }), e.#i(this), this.#se();
4700
+ }), e.#i(this), this.#fe();
4695
4701
  }
4696
4702
  disconnectedCallback() {
4697
- window.removeEventListener("resize", this.#re), 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.#ie);
4698
- for (let e of Qi) this.removeEventListener(e, this.#ne);
4699
- this.removeEventListener("transitionrun", this.#$), this.removeEventListener("transitionend", this.#ee), this.removeEventListener("transitioncancel", this.#ee), this.#X = 0, this.removeEventListener("pointermove", this.#U), this.removeEventListener("pointerleave", this.#W), this.removeEventListener("pointerdown", this.#G), this.removeEventListener("scroll", this.#L, { capture: !0 }), this.removeEventListener("scrollend", this.#R, { capture: !0 }), this.removeEventListener("wheel", this.#B);
4703
+ 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);
4704
+ for (let e of $i) this.removeEventListener(e, this.#se);
4705
+ 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);
4700
4706
  for (let e of this.#v.values()) clearTimeout(e);
4701
- this.#v.clear(), this.#x = null, this.#b = null, window.removeEventListener("pointerup", this.#K), window.removeEventListener("pointercancel", this.#K), document.removeEventListener("scroll", this.#q, { capture: !0 }), this.#O = null, this.#T = null, this.#E = !1, this.#D = !1, this.#J(), e.#a(this);
4707
+ 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);
4702
4708
  }
4703
- #C = /* @__PURE__ */ new Set();
4704
4709
  #w = /* @__PURE__ */ new Set();
4705
- #T = null;
4706
- #E = !1;
4710
+ #T = /* @__PURE__ */ new Set();
4711
+ #E = null;
4707
4712
  #D = !1;
4708
- #O = null;
4709
- #k = NaN;
4713
+ #O = !1;
4714
+ #k = null;
4710
4715
  #A = NaN;
4711
- #j = null;
4712
- static #M = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
4713
- #N() {
4716
+ #j = NaN;
4717
+ #M = null;
4718
+ static #N = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
4719
+ #P() {
4714
4720
  if (this.#g || this.#d) return;
4715
4721
  this.#g = !0;
4716
4722
  let e = !1, t = () => {
4717
4723
  if (e) return;
4718
4724
  e = !0, this.#g = !1;
4719
4725
  let t = this.#f;
4720
- !this.isConnected || !this.#p || !t || (this.#P(t), this.#D = !gr(this.#p, this.#s, this.#E), this.#J());
4726
+ !this.isConnected || !this.#p || !t || (this.#F(t), this.#O = !_r(this.#p, this.#s, this.#D), this.#$());
4721
4727
  };
4722
4728
  requestAnimationFrame(t), setTimeout(t, 50);
4723
4729
  }
4724
- #P(e, t) {
4730
+ #F(e, t) {
4725
4731
  for (let n of this.#_) {
4726
4732
  let r = n.source, { maxX: i, maxY: a } = n.scrollRange, o = t?.get(r);
4727
4733
  n.scroll = o ? {
4728
4734
  x: o.pinX ? i : Math.min(o.x, i),
4729
4735
  y: o.pinY ? a : Math.min(o.y, a)
4730
- } : {
4731
- x: la(r, "x", e.width, i),
4732
- y: la(r, "y", e.height, a)
4733
- };
4736
+ } : this.#I(n, e);
4734
4737
  }
4735
4738
  }
4736
- #F() {
4739
+ #I(e, t) {
4740
+ let n = e.source, { maxX: r, maxY: i } = e.scrollRange, a = e.scroll ?? {
4741
+ x: 0,
4742
+ y: 0
4743
+ };
4744
+ return {
4745
+ x: da(n, "x", t.width, r, a.x),
4746
+ y: da(n, "y", t.height, i, a.y)
4747
+ };
4748
+ }
4749
+ #L() {
4737
4750
  let e = /* @__PURE__ */ new Map(), t = this.#f;
4738
4751
  if (!t) return e;
4739
4752
  for (let n of this.#_) {
4740
- let r = n.source, { maxX: i, maxY: a } = n.scrollRange, o = la(r, "x", t.width, i), s = la(r, "y", t.height, a);
4753
+ let r = n.source, { maxX: i, maxY: a } = n.scrollRange, { x: o, y: s } = this.#I(n, t);
4741
4754
  e.set(r, {
4742
4755
  top: r.scrollTop,
4743
4756
  left: r.scrollLeft,
@@ -4749,56 +4762,56 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
4749
4762
  }
4750
4763
  return e;
4751
4764
  }
4752
- #I(e) {
4765
+ #R(e) {
4753
4766
  for (let t of this.#_) {
4754
4767
  let n = t.source, r = e.get(n);
4755
- r && (n.scrollTop = r.pinY ? n.scrollHeight : r.top, n.scrollLeft = r.pinX ? n.scrollWidth : r.left, n.scrollTop, n.scrollLeft);
4768
+ r && (n.scrollTop, n.scrollLeft, n.scrollTop = r.pinY ? n.scrollHeight : r.top, n.scrollLeft = r.pinX ? n.scrollWidth : r.left);
4756
4769
  }
4757
4770
  }
4758
- #L = (e) => {
4771
+ #z(e, t) {
4772
+ clearTimeout(this.#v.get(e)), this.#v.set(e, setTimeout(() => this.#H(e), t));
4773
+ }
4774
+ #B = (e) => {
4759
4775
  let t = e.target;
4760
- !(t instanceof HTMLElement) || t === this || t.hasAttribute("data-mw-scroll") && (this.#N(), "onscrollend" in window || (clearTimeout(this.#v.get(t)), this.#v.set(t, setTimeout(() => this.#z(t), aa))));
4776
+ !(t instanceof HTMLElement) || t === this || t.hasAttribute("data-mw-scroll") && (this.#P(), !(Date.now() - (this.#y.get(t) ?? 0) < na) && (clearTimeout(this.#v.get(t)), "onscrollend" in window || this.#z(t, sa)));
4761
4777
  };
4762
- #R = (e) => {
4778
+ #V = (e) => {
4763
4779
  let t = e.target;
4764
- !(t instanceof HTMLElement) || t === this || t.hasAttribute("data-mw-scroll") && (Date.now() - (this.#y.get(t) ?? 0) < ta || this.#z(t));
4780
+ !(t instanceof HTMLElement) || t === this || t.hasAttribute("data-mw-scroll") && (Date.now() - (this.#y.get(t) ?? 0) < na || this.#z(t, oa));
4765
4781
  };
4766
- #z(e) {
4782
+ #H(e) {
4767
4783
  if (this.#x?.el === e) return;
4768
- this.#N();
4784
+ this.#P();
4769
4785
  let t = this.#f, n = this.#_.find((t) => t.source === e);
4770
4786
  if (!t || !n) return;
4771
- let r = n.scrollRange, i = (e, t, n, r) => {
4772
- let i = Math.min(Math.max(0, Math.round(e / t)), n);
4773
- return i === n ? r : i * t;
4774
- }, a = i(e.scrollTop, t.height, r.maxY, e.scrollHeight - e.clientHeight), o = i(e.scrollLeft, t.width, r.maxX, e.scrollWidth - e.clientWidth);
4787
+ 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;
4775
4788
  (Math.abs(e.scrollTop - a) > .5 || Math.abs(e.scrollLeft - o) > .5) && e.scrollTo({
4776
4789
  top: a,
4777
4790
  left: o,
4778
4791
  behavior: "instant"
4779
4792
  });
4780
4793
  }
4781
- #B = (e) => {
4794
+ #U = (e) => {
4782
4795
  if (this.getAttribute("select") !== "grid") return;
4783
4796
  let t = this.#p, n = this.#f;
4784
4797
  if (!t || !n || this.#_.length === 0) return;
4785
- let r = e;
4786
- if (!r.cancelable) return;
4787
- let { col: i, row: a } = this.#V(r.clientX, r.clientY, n), o = r.deltaMode === 1 ? n.height : r.deltaMode === 2 ? this.clientHeight : 1, s = r.deltaX * o, c = r.deltaY * o, l = Date.now(), u = Math.abs(s) + Math.abs(c);
4798
+ let r = e, i = r.deltaMode === 1 ? n.height : r.deltaMode === 2 ? this.clientHeight : 1, a = r.deltaX * i, o = r.deltaY * i;
4799
+ if (!r.cancelable && this.#W(a, o)) return;
4800
+ let { col: s, row: c } = this.#K(r.clientX, r.clientY, n), l = Date.now(), u = Math.abs(a) + Math.abs(o);
4788
4801
  if (u === 0) {
4789
- this.#b = null;
4802
+ this.#b = null, r.preventDefault();
4790
4803
  return;
4791
4804
  }
4792
4805
  let d = (e) => {
4793
4806
  let t = e.scrollRange, n = e.source;
4794
- return c !== 0 && t.maxY > 0 && (c > 0 && n.scrollTop < n.scrollHeight - n.clientHeight - .5 || c < 0 && n.scrollTop > .5) || s !== 0 && t.maxX > 0 && (s > 0 && n.scrollLeft < n.scrollWidth - n.clientWidth - .5 || s < 0 && n.scrollLeft > .5);
4795
- }, f = this.#b, p = Math.abs(s) >= Math.abs(c) ? "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 >= ia, _ = f !== null && l - f.at < ta && p === f.axis && (h ? u <= f.mag : !(g && m)), v = null;
4807
+ 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);
4808
+ }, 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) > ra || Math.abs(r.clientY - f.y) > ra), g = f !== null && f.decayed >= aa, _ = f !== null && l - f.at < na && p === f.axis && (h ? u <= f.mag : !(g && m)), v = null;
4796
4809
  if (_) {
4797
4810
  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;
4798
4811
  v = this.#_.find((e) => e.source === f.el) ?? null;
4799
4812
  }
4800
4813
  if (!v) {
4801
- let e = xe(t, i, a);
4814
+ let e = Se(t, s, c);
4802
4815
  for (let t = e.length - 1; t >= 0; t--) {
4803
4816
  let n = e[t].node;
4804
4817
  if (!n.scrollRange) continue;
@@ -4807,12 +4820,12 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
4807
4820
  break;
4808
4821
  }
4809
4822
  let r = n.style.overscroll;
4810
- if (c !== 0 && !r.y || s !== 0 && !r.x) {
4823
+ if (o !== 0 && !r.y || a !== 0 && !r.x) {
4811
4824
  v = n;
4812
4825
  break;
4813
4826
  }
4814
4827
  }
4815
- if (!v && u < ra) {
4828
+ if (!v && u < ia) {
4816
4829
  r.preventDefault();
4817
4830
  return;
4818
4831
  }
@@ -4828,25 +4841,35 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
4828
4841
  }
4829
4842
  if (!v || (r.preventDefault(), !d(v))) return;
4830
4843
  let y = v.source, b = v.scrollRange, x = { behavior: "instant" };
4831
- c !== 0 && b.maxY > 0 && (x.top = c), s !== 0 && b.maxX > 0 && (x.left = s), y.scrollBy(x), this.#y.set(y, l), clearTimeout(this.#v.get(y)), this.#v.set(y, setTimeout(() => this.#z(y), ta));
4844
+ 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, na);
4832
4845
  };
4833
- #V(e, t, n) {
4834
- if (!this.#j) {
4846
+ #W(e, t) {
4847
+ 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);
4848
+ }
4849
+ #G() {
4850
+ let e = this.parentElement;
4851
+ if (!(!e || !this.#l)) {
4852
+ this.#l.observe(e);
4853
+ for (let t of e.children) t !== this && this.#l.observe(t);
4854
+ }
4855
+ }
4856
+ #K(e, t, n) {
4857
+ if (!this.#M) {
4835
4858
  let e = this.#s.getBoundingClientRect();
4836
- this.#j = {
4859
+ this.#M = {
4837
4860
  left: e.left,
4838
4861
  top: e.top
4839
4862
  };
4840
4863
  }
4841
4864
  return {
4842
- col: Math.floor((e - this.#j.left) / n.width),
4843
- row: Math.floor((t - this.#j.top) / n.height)
4865
+ col: Math.floor((e - this.#M.left) / n.width),
4866
+ row: Math.floor((t - this.#M.top) / n.height)
4844
4867
  };
4845
4868
  }
4846
- #H(e, t) {
4869
+ #q(e, t) {
4847
4870
  let n = this.#p, r = this.#f;
4848
4871
  if (!n || !r || this.#_.length === 0) return null;
4849
- let { col: i, row: a } = this.#V(e, t, r), o = xe(n, i, a);
4872
+ let { col: i, row: a } = this.#K(e, t, r), o = Se(n, i, a);
4850
4873
  for (let n = o.length - 1; n >= 0; n--) {
4851
4874
  let { node: s, x: c, y: l } = o[n], u = s.scrollRange;
4852
4875
  if (!u) continue;
@@ -4854,7 +4877,7 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
4854
4877
  if (!f || f.right === 0 && f.bottom === 0) continue;
4855
4878
  let p = s.source, m = l + d.border.top, h = c + d.border.left, g = l + s.localRect.height - d.border.bottom, _ = c + s.localRect.width - d.border.right;
4856
4879
  if (f.right > 0 && u.maxY > 0 && i >= _ - f.right && i < _ && a >= m && a < g) {
4857
- let e = g - m - f.bottom, n = dr(e, u.sizeY, u.maxY, 0).len, i = Math.max(1, (e - n) * r.height);
4880
+ let e = g - m - f.bottom, n = fr(e, u.sizeY, u.maxY, 0).len, i = Math.max(1, (e - n) * r.height);
4858
4881
  return {
4859
4882
  el: p,
4860
4883
  axis: "y",
@@ -4864,7 +4887,7 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
4864
4887
  };
4865
4888
  }
4866
4889
  if (f.bottom > 0 && u.maxX > 0 && a >= g - f.bottom && a < g && i >= h && i < _) {
4867
- let t = _ - h - f.right, n = dr(t, u.sizeX, u.maxX, 0).len, i = Math.max(1, (t - n) * r.width);
4890
+ let t = _ - h - f.right, n = fr(t, u.sizeX, u.maxX, 0).len, i = Math.max(1, (t - n) * r.width);
4868
4891
  return {
4869
4892
  el: p,
4870
4893
  axis: "x",
@@ -4876,68 +4899,68 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
4876
4899
  }
4877
4900
  return null;
4878
4901
  }
4879
- #U = (e) => {
4902
+ #J = (e) => {
4880
4903
  let { clientX: t, clientY: n } = e, r = this.#x;
4881
4904
  if (r) {
4882
4905
  let e = (r.axis === "y" ? n : t) - r.startClient, i = r.startPx + e * r.factor;
4883
4906
  r.axis === "y" ? r.el.scrollTop = i : r.el.scrollLeft = i;
4884
4907
  return;
4885
4908
  }
4886
- this.#O = {
4909
+ this.#k = {
4887
4910
  x: t,
4888
4911
  y: n
4889
4912
  };
4890
4913
  let i = this.#f;
4891
4914
  if (i) {
4892
- let { col: e, row: r } = this.#V(t, n, i);
4893
- if (e === this.#k && r === this.#A) return;
4915
+ let { col: e, row: r } = this.#K(t, n, i);
4916
+ if (e === this.#A && r === this.#j) return;
4894
4917
  }
4895
- this.#J();
4918
+ this.#$();
4896
4919
  };
4897
- #W = () => {
4898
- this.#O = null, this.#J();
4920
+ #Y = () => {
4921
+ this.#k = null, this.#$();
4899
4922
  };
4900
- #G = (e) => {
4923
+ #X = (e) => {
4901
4924
  let t = e;
4902
4925
  if (!t.isPrimary || t.button !== 0) return;
4903
- let n = t.pointerType === "touch" ? null : this.#H(t.clientX, t.clientY);
4926
+ let n = t.pointerType === "touch" ? null : this.#q(t.clientX, t.clientY);
4904
4927
  if (n) {
4905
4928
  this.#x = n, t.preventDefault(), t.isTrusted && this.setPointerCapture(t.pointerId);
4906
4929
  return;
4907
4930
  }
4908
- this.#O = {
4931
+ this.#k = {
4909
4932
  x: t.clientX,
4910
4933
  y: t.clientY
4911
- }, this.#E = !0, this.#J(!0);
4934
+ }, this.#D = !0, this.#$(!0);
4912
4935
  };
4913
- #K = (e) => {
4936
+ #Z = (e) => {
4914
4937
  if (e.isPrimary) {
4915
4938
  if (this.#x) {
4916
- this.#z(this.#x.el), this.#x = null;
4939
+ this.#H(this.#x.el), this.#x = null;
4917
4940
  return;
4918
4941
  }
4919
- !this.#E && !this.#T || (this.#E = !1, this.#T = null, this.#J(), this.#D && this.#se());
4942
+ !this.#D && !this.#E || (this.#D = !1, this.#E = null, this.#$(), this.#O && this.#fe());
4920
4943
  }
4921
4944
  };
4922
- #q = (e) => {
4923
- if (!this.#O) return;
4945
+ #Q = (e) => {
4946
+ if (!this.#k) return;
4924
4947
  let t = e.target;
4925
- t instanceof HTMLElement && t.hasAttribute("data-mw-scroll") || (this.#j = null, this.#J());
4948
+ t instanceof HTMLElement && t.hasAttribute("data-mw-scroll") || (this.#M = null, this.#$());
4926
4949
  };
4927
- #J(t = !1) {
4950
+ #$(t = !1) {
4928
4951
  let n = this.#p, r = this.#f, i = [];
4929
- if (this.#O && n && r && this.isConnected && this.getAttribute("select") === "grid" && (this.#E || e.#M?.matches)) {
4930
- let { col: e, row: t } = this.#V(this.#O.x, this.#O.y, r);
4931
- this.#k = e, this.#A = t, i = Se(n, e, t);
4932
- } else this.#k = NaN, this.#A = NaN;
4952
+ if (this.#k && n && r && this.isConnected && this.getAttribute("select") === "grid" && (this.#D || e.#N?.matches)) {
4953
+ let { col: e, row: t } = this.#K(this.#k.x, this.#k.y, r);
4954
+ this.#A = e, this.#j = t, i = Ce(n, e, t);
4955
+ } else this.#A = NaN, this.#j = NaN;
4933
4956
  let a = i.at(-1) ?? null;
4934
- t && (this.#T = a);
4935
- let o = e.#M?.matches ? i : [], s = this.#T ? i.indexOf(this.#T) : -1, c = s >= 0 ? i.slice(0, s + 1) : [], l = this.#Y("data-mw-hover", this.#C, o);
4936
- l = this.#Y("data-mw-active", this.#w, c) || l;
4957
+ t && (this.#E = a);
4958
+ 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);
4959
+ l = this.#ee("data-mw-active", this.#T, c) || l;
4937
4960
  let u = a ? getComputedStyle(a).cursor : "";
4938
- this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#se();
4961
+ this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#fe();
4939
4962
  }
4940
- #Y(e, t, n) {
4963
+ #ee(e, t, n) {
4941
4964
  let r = !1, i = new Set(n);
4942
4965
  for (let n of t) i.has(n) || (n.removeAttribute(e), r = !0);
4943
4966
  for (let n of i) t.has(n) || (n.setAttribute(e, ""), r = !0);
@@ -4945,51 +4968,51 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
4945
4968
  for (let e of i) t.add(e);
4946
4969
  return r;
4947
4970
  }
4948
- #X = 0;
4949
- #Z = !1;
4950
- #Q = 0;
4951
- #$ = (e) => {
4952
- $i.test(e.propertyName) && (this.#X++, this.#Q = performance.now(), this.#te());
4971
+ #te = 0;
4972
+ #ne = !1;
4973
+ #re = 0;
4974
+ #ie = (e) => {
4975
+ ea.test(e.propertyName) && (this.#te++, this.#re = performance.now(), this.#oe());
4953
4976
  };
4954
- #ee = (e) => {
4955
- $i.test(e.propertyName) && (this.#X = Math.max(0, this.#X - 1));
4977
+ #ae = (e) => {
4978
+ ea.test(e.propertyName) && (this.#te = Math.max(0, this.#te - 1));
4956
4979
  };
4957
- #te() {
4958
- if (this.#Z) return;
4959
- this.#Z = !0;
4980
+ #oe() {
4981
+ if (this.#ne) return;
4982
+ this.#ne = !0;
4960
4983
  let e = () => {
4961
- if (!this.isConnected || this.#X === 0 && !a() || performance.now() - this.#Q > ea) {
4962
- this.#Z = !1, this.#X = 0, this.#se();
4984
+ if (!this.isConnected || this.#te === 0 && !a() || performance.now() - this.#re > ta) {
4985
+ this.#ne = !1, this.#te = 0, this.#fe();
4963
4986
  return;
4964
4987
  }
4965
- this.#oe(), requestAnimationFrame(e);
4988
+ this.#de(), requestAnimationFrame(e);
4966
4989
  };
4967
4990
  requestAnimationFrame(e);
4968
4991
  }
4969
- #ne = (e) => {
4992
+ #se = (e) => {
4970
4993
  if ((e.type === "focusin" || e.type === "focusout") && e.target instanceof HTMLSelectElement) {
4971
- this.#oe();
4994
+ this.#de();
4972
4995
  return;
4973
4996
  }
4974
- this.#se();
4997
+ this.#fe();
4975
4998
  };
4976
4999
  attributeChangedCallback(e, t, n) {
4977
5000
  if (e === "select" && n !== "text" && n !== "grid") {
4978
- n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, this), this.setAttribute("select", Zi);
5001
+ n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, ee(this)), this.setAttribute("select", Qi);
4979
5002
  return;
4980
5003
  }
4981
- e === "select" && this.#J(), this.#se();
5004
+ e === "select" && this.#$(), this.#fe();
4982
5005
  }
4983
5006
  toPlainText() {
4984
- return this.#d && this.#ce(), this.#p ? nr(this.#p) : "";
5007
+ return this.#d && this.#pe(), this.#p ? rr(this.#p) : "";
4985
5008
  }
4986
- #re = () => {
4987
- this.#se();
5009
+ #ce = () => {
5010
+ this.#fe();
4988
5011
  };
4989
- #ie = () => {
4990
- requestAnimationFrame(() => this.#se());
5012
+ #le = () => {
5013
+ requestAnimationFrame(() => this.#fe());
4991
5014
  };
4992
- #ae() {
5015
+ #ue() {
4993
5016
  let e = document.activeElement;
4994
5017
  if (!(e instanceof HTMLSelectElement) || !this.contains(e)) return !1;
4995
5018
  try {
@@ -4998,25 +5021,25 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
4998
5021
  return !1;
4999
5022
  }
5000
5023
  }
5001
- #oe() {
5024
+ #de() {
5002
5025
  try {
5003
- this.#ce();
5026
+ this.#pe();
5004
5027
  } catch (e) {
5005
5028
  console.error("[monowind] layout failed:", e);
5006
5029
  }
5007
5030
  }
5008
- #se() {
5031
+ #fe() {
5009
5032
  this.#d || (this.#d = !0, requestAnimationFrame(() => {
5010
- if (this.#d = !1, this.#ae()) {
5011
- this.#se();
5033
+ if (this.#d = !1, this.#ue()) {
5034
+ this.#fe();
5012
5035
  return;
5013
5036
  }
5014
- this.#oe();
5037
+ this.#de();
5015
5038
  }));
5016
5039
  }
5017
- #ce() {
5040
+ #pe() {
5018
5041
  if (!this.isConnected) return;
5019
- let e = this.#F(), t = /* @__PURE__ */ new Map(), n = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), r = parseFloat(n);
5042
+ let e = this.#L(), t = /* @__PURE__ */ new Map(), n = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), r = parseFloat(n);
5020
5043
  if (Number.isFinite(r) && r > 0) for (let e of this.querySelectorAll("textarea")) {
5021
5044
  let n = getComputedStyle(e), i = e.clientWidth - (parseFloat(n.paddingLeft) || 0) - (parseFloat(n.paddingRight) || 0);
5022
5045
  t.set(e, Math.max(0, Math.round(i / r)));
@@ -5024,23 +5047,23 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
5024
5047
  this.setAttribute("measuring", "");
5025
5048
  try {
5026
5049
  this.#c.parentNode !== this && this.appendChild(this.#c);
5027
- let n = we(this, this.#c), r = this.#f;
5050
+ let n = Te(this, this.#c), r = this.#f;
5028
5051
  (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;
5029
5052
  let i = getComputedStyle(this), a = (parseFloat(i.paddingLeft) || 0) + (parseFloat(i.paddingRight) || 0), o = Math.max(0, Math.floor((this.clientWidth - a) / n.width));
5030
5053
  if (o === 0) return;
5031
- let s = Te(), c = [];
5054
+ let s = Ee(), c = [];
5032
5055
  for (let e of Array.from(this.children)) {
5033
5056
  if (e === this.#c) continue;
5034
- let r = ji(e, s, n, t);
5057
+ let r = Mi(e, s, n, t);
5035
5058
  r && c.push(r);
5036
5059
  }
5037
- if (Ki(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${qi}`, this), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), c.length === 0) {
5060
+ if (qi(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${Ji}`, ee(this)), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), c.length === 0) {
5038
5061
  this.#s.replaceChildren(), this.#p = null, this.setAttribute("data-mw-ready", "");
5039
5062
  return;
5040
5063
  }
5041
5064
  let l = {
5042
5065
  source: this,
5043
- style: nt(),
5066
+ style: rt(),
5044
5067
  children: c,
5045
5068
  text: "",
5046
5069
  intrinsicWidth: 0,
@@ -5052,26 +5075,35 @@ var Xi = "\n<style>\n :host { display: block; position: relative; contain: layo
5052
5075
  height: 0
5053
5076
  },
5054
5077
  unclampedHeight: 0,
5055
- resolvedPadding: rt()
5056
- }, { height: u } = Pn(l, o);
5057
- wr(l), this.#_ = ua(l), this.#P(n, e), this.#D = !gr(l, this.#s, this.#E), this.#p = l;
5078
+ resolvedPadding: it()
5079
+ }, { height: u } = Fn(l, o);
5080
+ Tr(l), this.#_ = pa(l), this.#F(n, e), this.#O = !_r(l, this.#s, this.#D), this.#p = l;
5058
5081
  let d = `${l.localRect.width * n.width}px`, f = `${l.localRect.height * n.height}px`;
5059
5082
  this.#s.style.width !== d && (this.#s.style.width = d), this.#s.style.height !== f && (this.#s.style.height = f);
5060
5083
  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`;
5061
- this.style.height !== m && (this.style.height = m), this.hasAttribute("data-mw-ready") || this.setAttribute("data-mw-ready", "");
5084
+ this.style.height !== m && (this.style.height = m);
5085
+ let h = i.boxSizing === "border-box" ? a + (parseFloat(i.borderLeftWidth) || 0) + (parseFloat(i.borderRightWidth) || 0) : 0, g = `${o * n.width + h}px`;
5086
+ this.style.getPropertyValue("--mw-host-w") !== g && this.style.setProperty("--mw-host-w", g), this.hasAttribute("data-mw-ready") || this.setAttribute("data-mw-ready", "");
5062
5087
  } finally {
5063
- this.setAttribute("settling", ""), this.removeAttribute("measuring"), getComputedStyle(this).transitionProperty, this.removeAttribute("settling"), this.#I(e), this.#u?.takeRecords(), i(this) && (a() ? (this.#Q = performance.now(), this.#te()) : this.#se()), this.#j = null, this.#O && this.#J();
5088
+ 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 = [];
5089
+ let t = document.scrollingElement ?? document.documentElement;
5090
+ for (let e = this.parentElement; e; e = e.parentElement) (e === t || /auto|scroll/.test(getComputedStyle(e).overflow)) && this.#S.push(e);
5091
+ this.#M = null, this.#k && this.#$();
5064
5092
  }
5065
5093
  }
5066
5094
  };
5067
- function ca() {
5068
- typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", sa);
5095
+ function ua() {
5096
+ typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", la);
5097
+ }
5098
+ function da(e, t, n, r, i) {
5099
+ return fa(t === "y" ? e.scrollTop : e.scrollLeft, t === "y" ? e.scrollHeight - e.clientHeight : e.scrollWidth - e.clientWidth, n, r, i);
5069
5100
  }
5070
- function la(e, t, n, r) {
5071
- let i = t === "y" ? e.scrollTop : e.scrollLeft, a = t === "y" ? e.scrollHeight - e.clientHeight : e.scrollWidth - e.clientWidth;
5072
- return r > 0 && i > 0 && i >= a - 1 ? r : Math.min(Math.max(0, Math.floor((i + 1) / n)), r);
5101
+ function fa(e, t, n, r, i) {
5102
+ if (r > 0 && e > 0 && e >= t - 1) return r;
5103
+ let a = e / n - i, o = Math.abs(a) <= .5 ? i : i + Math.sign(a) * Math.round(Math.abs(a));
5104
+ return Math.min(Math.max(0, o), r);
5073
5105
  }
5074
- function ua(e) {
5106
+ function pa(e) {
5075
5107
  let t = [], n = (e) => {
5076
5108
  e.scrollRange && t.push(e);
5077
5109
  for (let t of e.children) n(t);
@@ -5079,6 +5111,6 @@ function ua(e) {
5079
5111
  return n(e), t;
5080
5112
  }
5081
5113
  //#endregion
5082
- export { sa as MonoWindElement, ca as defineMonoWind, re as invalidateLeaves, Jt as multicolLines, x as registerBorderGlyphs, ne as registerLeafRenderer, nr as renderPlainText, Ee as wrapLines };
5114
+ export { la as MonoWindElement, ua as defineMonoWind, ie as invalidateLeaves, Yt as multicolLines, x as registerBorderGlyphs, re as registerLeafRenderer, rr as renderPlainText, De as wrapLines };
5083
5115
 
5084
5116
  //# sourceMappingURL=index.js.map