monowind 0.2.1 → 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
@@ -289,7 +289,7 @@ function D(e) {
289
289
  }
290
290
  return t;
291
291
  }
292
- var O = (e) => D(Array(16).fill(e));
292
+ var O = (e) => D(Array.from({ length: 16 }, () => e));
293
293
  x("default", {}), x("rounded", { solid: {
294
294
  tl: "╭",
295
295
  tr: "╮",
@@ -302,7 +302,11 @@ var k = {
302
302
  v: "|"
303
303
  };
304
304
  x("ascii", {
305
- solid: k,
305
+ solid: {
306
+ ...k,
307
+ scrollTrack: "|",
308
+ scrollThumb: "#"
309
+ },
306
310
  double: {
307
311
  ...k,
308
312
  h: "="
@@ -322,7 +326,14 @@ x("single", {
322
326
  }), x("cp437", {
323
327
  dashed: A,
324
328
  dotted: A
325
- }), x("blocks", {
329
+ });
330
+ function j(e) {
331
+ return {
332
+ track: e?.solid?.scrollTrack ?? "░",
333
+ thumb: e?.solid?.scrollThumb ?? "█"
334
+ };
335
+ }
336
+ x("blocks", {
326
337
  solid: O("█"),
327
338
  double: O("█"),
328
339
  dashed: O("▒"),
@@ -330,52 +341,57 @@ x("single", {
330
341
  });
331
342
  //#endregion
332
343
  //#region src/warn.ts
333
- var j = /* @__PURE__ */ new WeakMap();
334
- function M(e, t) {
335
- let n = j.get(e);
336
- n || j.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, e));
344
+ var M = /* @__PURE__ */ new WeakMap();
345
+ function N(e, t) {
346
+ let n = M.get(e);
347
+ n || M.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, ee(e)));
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}>`;
337
353
  }
338
354
  //#endregion
339
355
  //#region src/leaf.ts
340
- var N = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Set();
341
- function te(e) {
356
+ var te = /* @__PURE__ */ new Map(), ne = /* @__PURE__ */ new Set();
357
+ function re(e) {
342
358
  let t = e.tag.toLowerCase();
343
359
  if (!t.includes("-")) {
344
360
  console.warn(`[monowind] registerLeafRenderer: "${e.tag}" is not a custom-element tag name (needs a hyphen); ignored.`);
345
361
  return;
346
362
  }
347
- N.has(t) && console.warn(`[monowind] registerLeafRenderer: replacing existing renderer for <${t}> (last registration wins).`), N.set(t, {
363
+ te.has(t) && console.warn(`[monowind] registerLeafRenderer: replacing existing renderer for <${t}> (last registration wins).`), te.set(t, {
348
364
  ...e,
349
365
  tag: t
350
- }), se();
366
+ }), le();
351
367
  }
352
- function ne() {
353
- se();
368
+ function ie() {
369
+ le();
354
370
  }
355
- function re(e) {
356
- return N.get(e.toLowerCase());
371
+ function ae(e) {
372
+ return te.get(e.toLowerCase());
357
373
  }
358
- function ie() {
374
+ function oe() {
359
375
  let e = /* @__PURE__ */ new Set();
360
- for (let t of N.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());
361
377
  return [...e];
362
378
  }
363
- function ae(e) {
364
- return ee.add(e), () => ee.delete(e);
379
+ function se(e) {
380
+ return ne.add(e), () => ne.delete(e);
365
381
  }
366
- function oe(e, t) {
382
+ function ce(e, t) {
367
383
  try {
368
384
  return e.render(t);
369
385
  } catch (n) {
370
- return M(t, `<${e.tag}> renderer threw; rendering nothing. ${String(n)}`), null;
386
+ return N(t, `<${e.tag}> renderer threw; rendering nothing. ${String(n)}`), null;
371
387
  }
372
388
  }
373
- function se() {
374
- for (let e of ee) e();
389
+ function le() {
390
+ for (let e of ne) e();
375
391
  }
376
392
  //#endregion
377
393
  //#region src/borders.ts
378
- function ce(e, t, n) {
394
+ function ue(e, t, n) {
379
395
  let r = e.border;
380
396
  if (r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0) return;
381
397
  let i = Math.max(r.top, r.right, r.bottom, r.left);
@@ -391,11 +407,11 @@ function ce(e, t, n) {
391
407
  width: t.width - (i.left ? a : 0) - (i.right ? a : 0),
392
408
  height: t.height - (i.top ? a : 0) - (i.bottom ? a : 0)
393
409
  };
394
- o.width <= 0 || o.height <= 0 || le(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));
395
411
  }
396
412
  }
397
- function le(e, t, n, r, i, a) {
398
- let o = me(t.top, a), s = me(t.right, a), c = me(t.bottom, a), l = me(t.left, a), u = (e, t, n) => n(me(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;
399
415
  if (i.top && _ > g && e.push({
400
416
  glyph: o.h,
401
417
  x: g,
@@ -448,24 +464,25 @@ function le(e, t, n, r, i, a) {
448
464
  color: n.bottom
449
465
  }));
450
466
  }
451
- function ue(e, t) {
452
- return e.style.position !== "static" || t.style.display === "flex" || t.style.display === "grid";
467
+ function fe(e, t) {
468
+ return e.style.position !== "static" || (t.style.display === "flex" || t.style.display === "grid") && e.style.zIndex !== null;
453
469
  }
454
- function de(e) {
470
+ function pe(e) {
455
471
  if (e.children.length <= 1) return e.children;
456
- let t = null, n = null, r = null;
457
- for (let i of e.children) ue(i, e) ? (r ??= []).push(i) : i.inlineBox ? (n ??= []).push(i) : (t ??= []).push(i);
458
- return r && r.length > 1 && r.sort((e, t) => (e.style.zIndex ?? 0) - (t.style.zIndex ?? 0)), t && !n && !r ? t : !t && n && !r ? n : !t && !n && r ? r : [
472
+ let t = null, n = null, r = null, i = null;
473
+ for (let a of e.children) fe(a, e) ? (a.style.zIndex ?? 0) < 0 ? (t ??= []).push(a) : (i ??= []).push(a) : a.inlineBox ? (r ??= []).push(a) : (n ??= []).push(a);
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 : [
459
475
  ...t ?? [],
460
476
  ...n ?? [],
461
- ...r ?? []
477
+ ...r ?? [],
478
+ ...i ?? []
462
479
  ];
463
480
  }
464
- function fe(e, t, n) {
465
- let r = me(e, n);
481
+ function me(e, t, n) {
482
+ let r = ge(e, n);
466
483
  return t === "h" ? r.h : r.v;
467
484
  }
468
- function pe(e, t, n, r, i, a) {
485
+ function he(e, t, n, r, i, a) {
469
486
  let o = (t ? 8 : 0) | (n ? 4 : 0) | (r ? 2 : 0) | !!i;
470
487
  if (a) {
471
488
  let t = w(o), n = t && a[e]?.[t];
@@ -473,8 +490,8 @@ function pe(e, t, n, r, i, a) {
473
490
  }
474
491
  return (e === "double" ? E : T)[o];
475
492
  }
476
- function me(e, t) {
477
- let n = (n, r, i, a) => pe(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 = {
478
495
  h: n(!1, !1, !0, !0),
479
496
  v: n(!0, !0, !1, !1),
480
497
  tl: n(!1, !0, !1, !0),
@@ -485,24 +502,24 @@ function me(e, t) {
485
502
  return e === "dashed" ? {
486
503
  h: "╌",
487
504
  v: "╎",
488
- ...he(r),
489
- ...ge(t, e)
505
+ ..._e(r),
506
+ ...ve(t, e)
490
507
  } : e === "dotted" ? {
491
508
  h: "┄",
492
509
  v: "┊",
493
- ...he(r),
494
- ...ge(t, e)
510
+ ..._e(r),
511
+ ...ve(t, e)
495
512
  } : r;
496
513
  }
497
- function he(e) {
514
+ function _e(e) {
498
515
  let { h: t, v: n, ...r } = e;
499
516
  return r;
500
517
  }
501
- function ge(e, t) {
518
+ function ve(e, t) {
502
519
  let n = e?.[t], r = {};
503
520
  return n?.h && (r.h = n.h), n?.v && (r.v = n.v), r;
504
521
  }
505
- function _e(e, t, n, r) {
522
+ function ye(e, t, n, r) {
506
523
  let i = e.map((e) => e.spanned ? !1 : n === "between" ? e.beforeOccupied && e.afterOccupied : n !== "around" || e.beforeOccupied || e.afterOccupied), a = [];
507
524
  for (let n = 0; n < e.length; n++) if (a.push({
508
525
  start: e[n].start,
@@ -546,7 +563,7 @@ function _e(e, t, n, r) {
546
563
  end: e.end - r
547
564
  })).filter((e) => e.end > e.start);
548
565
  }
549
- function ve(e) {
566
+ function be(e) {
550
567
  let t = [], n = e.border.left + e.padding.left, r = e.border.top + e.padding.top, i = (e, t) => ({
551
568
  line: t.bandStart + Math.floor((t.bandSize - e.width) / 2),
552
569
  start: t.start,
@@ -555,7 +572,7 @@ function ve(e) {
555
572
  endHalf: t.endHalf === !0
556
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);
557
574
  if (e.ruleX) {
558
- let i = fe(e.ruleX.style, "v", e.glyphs);
575
+ let i = me(e.ruleX.style, "v", e.glyphs);
559
576
  for (let o of a) {
560
577
  for (let a = 0; a < s; a++) for (let s = o.start; s < o.end; s++) u(o.line + a, s) || t.push({
561
578
  glyph: i,
@@ -564,7 +581,7 @@ function ve(e) {
564
581
  length: 1,
565
582
  color: e.ruleX.color
566
583
  });
567
- ye(e, t, "x", o.line, o.start, o.end);
584
+ xe(e, t, "x", o.line, o.start, o.end);
568
585
  }
569
586
  }
570
587
  if (e.ruleY) {
@@ -575,7 +592,7 @@ function ve(e) {
575
592
  for (let d = u.start; d < u.end; d++) {
576
593
  let u = l(a, s, d, f), p = l(a, s, d, f + 1);
577
594
  t.push({
578
- glyph: u || p ? pe(i ? "double" : "solid", u, p, l(o, c, f, d), l(o, c, f, d + 1), e.glyphs) : fe(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),
579
596
  x: n + d,
580
597
  y: r + f,
581
598
  length: 1,
@@ -583,16 +600,16 @@ function ve(e) {
583
600
  });
584
601
  }
585
602
  }
586
- ye(e, t, "y", u.line, u.start, u.end);
603
+ xe(e, t, "y", u.line, u.start, u.end);
587
604
  }
588
605
  }
589
606
  return t;
590
607
  }
591
- function ye(e, t, n, r, i, a) {
608
+ function xe(e, t, n, r, i, a) {
592
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) => {
593
610
  let d = o.style === "double" && i === "double" ? "double" : "solid";
594
611
  t.push({
595
- glyph: pe(d, s, c, l, u, e.glyphs),
612
+ glyph: he(d, s, c, l, u, e.glyphs),
596
613
  x: n,
597
614
  y: r,
598
615
  length: 1,
@@ -610,19 +627,26 @@ function ye(e, t, n, r, i, a) {
610
627
  }
611
628
  //#endregion
612
629
  //#region src/pointer.ts
613
- function be(e, t, n) {
630
+ function Se(e, t, n) {
614
631
  let r = [], i = e, a = e.localRect.x, o = e.localRect.y;
615
632
  for (;;) {
616
633
  let e = null;
617
- for (let r of de(i)) {
634
+ for (let r of pe(i)) {
618
635
  if (r.tableHidden) continue;
619
636
  let i = a + r.localRect.x, s = o + r.localRect.y;
620
637
  t >= i && t < i + r.localRect.width && n >= s && n < s + r.localRect.height && (e = r);
621
638
  }
622
639
  if (!e) return r;
623
- r.push(e.source), a += e.localRect.x, o += e.localRect.y, i = e;
640
+ r.push({
641
+ node: e,
642
+ x: a + e.localRect.x,
643
+ y: o + e.localRect.y
644
+ }), a += e.localRect.x - (e.scroll?.x ?? 0), o += e.localRect.y - (e.scroll?.y ?? 0), i = e;
624
645
  }
625
646
  }
647
+ function Ce(e, t, n) {
648
+ return Se(e, t, n).map((e) => e.node.source);
649
+ }
626
650
  //#endregion
627
651
  //#region src/metrics.ts
628
652
  function P(e) {
@@ -631,10 +655,10 @@ function P(e) {
631
655
  function F(e, t) {
632
656
  return t <= 0 ? 0 : P(e / (.25 * t));
633
657
  }
634
- function xe(e, t) {
658
+ function we(e, t) {
635
659
  return P(t * e / 100);
636
660
  }
637
- function Se(e, t) {
661
+ function Te(e, t) {
638
662
  let n = t.getBoundingClientRect(), r = parseFloat(getComputedStyle(e).letterSpacing) || 0, i = t.ownerDocument.createRange();
639
663
  i.selectNodeContents(t);
640
664
  let a = Math.max(0, i.getBoundingClientRect().height - n.height);
@@ -645,56 +669,56 @@ function Se(e, t) {
645
669
  inkOverhang: a
646
670
  };
647
671
  }
648
- function Ce() {
672
+ function Ee() {
649
673
  return parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
650
674
  }
651
675
  //#endregion
652
676
  //#region src/wrap.ts
653
- function we(e, t, n = {}) {
654
- return Oe(e, t, n).map((t) => e.slice(t.start, t.end));
677
+ function De(e, t, n = {}) {
678
+ return je(e, t, n).map((t) => e.slice(t.start, t.end));
655
679
  }
656
- function Te(e, t, n = {}) {
657
- return Oe(e, t, n).length;
680
+ function Oe(e, t, n = {}) {
681
+ return je(e, t, n).length;
658
682
  }
659
- function Ee(e, t) {
683
+ function ke(e, t) {
660
684
  return t.endsWith("\n") && e.pop(), e;
661
685
  }
662
- function De(e) {
686
+ function Ae(e) {
663
687
  let t = [], n = 0;
664
688
  for (let r = 0; r <= e.length; r++) (r === e.length || e[r] === "\n") && (t.push({
665
689
  start: n,
666
690
  end: r
667
691
  }), n = r + 1);
668
- return Ee(t, e);
692
+ return ke(t, e);
669
693
  }
670
- function Oe(e, t, n = {}) {
694
+ function je(e, t, n = {}) {
671
695
  if (!/[^ \t\r\f]/.test(e)) return [];
672
696
  let r = [], i = 0, a = n.firstLineIndent ?? 0;
673
- for (let o = 0; o <= e.length; o++) (o === e.length || e[o] === "\n") && (r.push(...Ie(e, i, o, t, n, a)), a = 0, i = o + 1);
674
- return Ee(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);
675
699
  }
676
- function ke(e, t, n) {
700
+ function Me(e, t, n) {
677
701
  if (!n) return t - e;
678
702
  let r = 0;
679
703
  for (let i = e; i < t; i++) r += n[i] ?? 1;
680
704
  return r;
681
705
  }
682
706
  function I(e, t, n, r = 0) {
683
- return t <= e ? 0 : ke(e, t, n) - Math.min(r, Ae(t - 1, n));
707
+ return t <= e ? 0 : Me(e, t, n) - Math.min(r, Ne(t - 1, n));
684
708
  }
685
- function Ae(e, t) {
709
+ function Ne(e, t) {
686
710
  return t ? (t[e] ?? 1) - 1 : 0;
687
711
  }
688
- function je(e, t = {}) {
712
+ function Pe(e, t = {}) {
689
713
  let { advances: n, tracking: r = 0 } = t, i = 0;
690
- for (let t of Fe(e, 0, e.length)) for (let a of Ne(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));
691
715
  return i;
692
716
  }
693
- function Me(e, t) {
717
+ function Fe(e, t) {
694
718
  let n = 0;
695
719
  for (let r = 0; r < e.length; r++) e[r] === "" && (t(r, n), n++);
696
720
  }
697
- function Ne(e, t, n) {
721
+ function Ie(e, t, n) {
698
722
  let r = [], i = t;
699
723
  for (let a = t; a < n; a++) {
700
724
  if (e[a] === "") {
@@ -721,14 +745,14 @@ function Ne(e, t, n) {
721
745
  end: n
722
746
  }), r;
723
747
  }
724
- var Pe = /[ \t\r\n\f]/;
725
- function Fe(e, t, n) {
748
+ var Le = /[ \t\r\n\f]/;
749
+ function Re(e, t, n) {
726
750
  let r = [], i = t;
727
751
  for (; i < n;) {
728
- for (; i < n && Pe.test(e[i]);) i++;
752
+ for (; i < n && Le.test(e[i]);) i++;
729
753
  if (i >= n) break;
730
754
  let t = i;
731
- for (; i < n && !Pe.test(e[i]);) i++;
755
+ for (; i < n && !Le.test(e[i]);) i++;
732
756
  r.push({
733
757
  start: t,
734
758
  end: i
@@ -736,8 +760,8 @@ function Fe(e, t, n) {
736
760
  }
737
761
  return r;
738
762
  }
739
- function Ie(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
740
- let s = Fe(e, t, n);
763
+ function ze(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
764
+ let s = Re(e, t, n);
741
765
  if (s.length === 0) return [{
742
766
  start: t,
743
767
  end: t
@@ -749,8 +773,8 @@ function Ie(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
749
773
  let c = [], l = null, u = 0, d = Math.max(0, o), f = () => r - d;
750
774
  for (let t of s) {
751
775
  let n = !1;
752
- for (let r of Ne(e, t.start, t.end)) {
753
- let e = r.start, t = r.end, o = l !== null && !n ? e - 1 : e, s = u + ke(o, t, i), p = Math.min(a, Ae(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));
754
778
  if (l !== null && s - p <= f()) l.end = t, u = s;
755
779
  else {
756
780
  for (l !== null && (c.push(l), d = 0);;) {
@@ -765,7 +789,7 @@ function Ie(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
765
789
  l = {
766
790
  start: e,
767
791
  end: t
768
- }, u = ke(e, t, i);
792
+ }, u = Me(e, t, i);
769
793
  }
770
794
  n = !0;
771
795
  }
@@ -774,7 +798,7 @@ function Ie(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
774
798
  }
775
799
  //#endregion
776
800
  //#region src/flex.ts
777
- function Le(e, t) {
801
+ function Be(e, t) {
778
802
  let n = e.row.map((e) => e.node.localRect).sort((e, t) => e.x - t.x), r = [];
779
803
  for (let e = 1; e < n.length; e++) {
780
804
  let i = n[e - 1].x + n[e - 1].width - t, a = n[e].x - t;
@@ -785,12 +809,12 @@ function Le(e, t) {
785
809
  }
786
810
  return r;
787
811
  }
788
- function Re(e, t, n, r, i) {
812
+ function Ve(e, t, n, r, i) {
789
813
  if (e.style.ruleBreak !== "intersection") return [{
790
814
  start: 0,
791
815
  end: i
792
816
  }];
793
- let a = [t[n - 1], t[n]].flatMap((e) => Le(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) => ({
794
818
  start: e,
795
819
  end: t,
796
820
  spanned: !1,
@@ -798,24 +822,24 @@ function Re(e, t, n, r, i) {
798
822
  afterOccupied: !0
799
823
  }), s = [], c = 0;
800
824
  for (let e of a) e.start > c && s.push(o(c, e.start)), c = Math.max(c, e.end);
801
- return c < i && s.push(o(c, i)), _e(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);
802
826
  }
803
- function ze(e, t) {
827
+ function He(e, t) {
804
828
  return typeof t != "number" || t <= 0 ? e : e.map((e) => ({
805
829
  ...e,
806
830
  start: e.start + t,
807
831
  end: e.end - t
808
832
  })).filter((e) => e.end > e.start);
809
833
  }
810
- function Be(e, t, n, r, i, a, o) {
811
- let s = U(e.style, "x", t), c = U(e.style, "y", n), l = Ye(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) => {
812
836
  let n = G(e.style.margin, t);
813
837
  return {
814
838
  node: e,
815
- base: Je(e, t, o),
839
+ base: Xe(e, t, o),
816
840
  grow: e.style.flexGrow,
817
841
  shrink: e.style.flexShrink,
818
- min: Qe(e, t, o),
842
+ min: et(e, t, o),
819
843
  max: K(e.style.maxWidth, t),
820
844
  margin: n
821
845
  };
@@ -829,7 +853,7 @@ function Be(e, t, n, r, i, a, o) {
829
853
  n.length > 0 && u.push(n), e.style.wrapReverse && u.reverse();
830
854
  } else u.push(l);
831
855
  let d = i.left + a.left, f = i.top + a.top, p = u.map((e) => {
832
- 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))) : Ge(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);
833
857
  for (let n = 0; n < e.length; n++) V(e[n].node, t, r, 0, 0, "fill", o, { width: u[n] });
834
858
  return {
835
859
  row: e,
@@ -838,9 +862,9 @@ function Be(e, t, n, r, i, a, o) {
838
862
  height: e.reduce((e, t) => Math.max(e, t.node.localRect.height), 0)
839
863
  };
840
864
  }), m = p.map((e) => e.height), h = c * Math.max(0, p.length - 1), g;
841
- if (e.style.flexWrap === "nowrap") Number.isFinite(n) && (m[0] = Math.max(n, m[0] ?? 0)), g = [0];
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];
842
866
  else {
843
- let t = m.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - h) : 0, i = Xe(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);
844
868
  if (i === "stretch" && r > 0) {
845
869
  let e = R(Array.from({ length: p.length }, () => 1), r);
846
870
  for (let t = 0; t < m.length; t++) m[t] += e[t];
@@ -850,8 +874,8 @@ function Be(e, t, n, r, i, a, o) {
850
874
  for (let i = 0; i < p.length; i++) {
851
875
  let { row: a, widths: l, availableForItems: u } = p[i], h = m[i], _ = g[i] + i * c;
852
876
  for (let i = 0; i < a.length; i++) {
853
- let s = a[i].node, c = Ke(s, e), u = a[i].margin, d = u.top === null || u.bottom === null, f = s.style.height !== void 0 && s.style.height.kind !== "auto";
854
- if (c === "stretch" && !d && !f && h > s.localRect.height) {
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";
878
+ if (c === "stretch" && !d && !f && h !== s.localRect.height) {
855
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));
856
880
  if (d === s.localRect.height) continue;
857
881
  V(s, t, r, 0, 0, "fill", o, {
@@ -865,14 +889,14 @@ function Be(e, t, n, r, i, a, o) {
865
889
  let e = R(Array.from({ length: b }, () => 1), y), t = 0;
866
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++]);
867
891
  C = L("start", l, 0);
868
- } else C = L(Ze(e.style), l, y);
892
+ } else C = L($e(e.style), l, y);
869
893
  let w = 0;
870
894
  for (let t = 0; t < a.length; t++) {
871
895
  let n = a[t], r = n.node, i = n.margin.left ?? 0, o = n.margin.right ?? 0;
872
896
  w += x[t] + i, r.localRect = {
873
897
  ...r.localRect,
874
898
  x: d + C[t] + t * s + w,
875
- y: f + _ + Ue(r, e.style.alignItems, h, n.margin)
899
+ y: f + _ + Ke(r, e.style.alignItems, h, n.margin)
876
900
  }, w += S[t] + o;
877
901
  }
878
902
  }
@@ -881,7 +905,7 @@ function Be(e, t, n, r, i, a, o) {
881
905
  let n = [], r = [];
882
906
  for (let i = 0; i < p.length; i++) {
883
907
  let a = g[i] + i * c;
884
- for (let e of Le(p[i], d)) n.push({
908
+ for (let e of Be(p[i], d)) n.push({
885
909
  bandStart: e.start,
886
910
  bandSize: e.end - e.start,
887
911
  start: a,
@@ -889,19 +913,19 @@ function Be(e, t, n, r, i, a, o) {
889
913
  });
890
914
  if (i > 0) {
891
915
  let n = g[i - 1] + (i - 1) * c + m[i - 1];
892
- if (a > n) for (let o of Re(e, p, i, d, t)) r.push({
916
+ if (a > n) for (let o of Ve(e, p, i, d, t)) r.push({
893
917
  bandStart: n,
894
918
  bandSize: a - n,
895
919
  ...o
896
920
  });
897
921
  }
898
922
  }
899
- e.decorationRuns = ve({
923
+ e.decorationRuns = be({
900
924
  glyphs: S(e.style.glyphSet),
901
925
  ruleX: e.style.ruleX,
902
926
  ruleY: e.style.ruleY,
903
- vertical: ze(n, e.style.ruleInset),
904
- horizontal: ze(r, e.style.ruleInset),
927
+ vertical: He(n, e.style.ruleInset),
928
+ horizontal: He(r, e.style.ruleInset),
905
929
  contentWidth: t,
906
930
  contentHeight: v,
907
931
  border: i,
@@ -910,9 +934,9 @@ function Be(e, t, n, r, i, a, o) {
910
934
  padding: a
911
935
  });
912
936
  }
913
- return Ve(e, i, a, t, v), v;
937
+ return We(e, i, a, t, v), v;
914
938
  }
915
- function Ve(e, t, n, r, i) {
939
+ function We(e, t, n, r, i) {
916
940
  for (let a of e.children) B(a.style) && (a.staticSlot = {
917
941
  kind: "flex",
918
942
  direction: e.style.flexDirection,
@@ -922,11 +946,11 @@ function Ve(e, t, n, r, i) {
922
946
  innerHeight: i
923
947
  });
924
948
  }
925
- function He(e, t, n, r, i, a, o) {
926
- let s = U(e.style, "y", n), c = Ye(e).map((i) => {
927
- let a = G(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = Ke(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";
928
952
  V(i, s, r && Number.isFinite(n) ? n : void 0, 0, 0, c ? "fill" : "shrink", o);
929
- 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 ? xe(u.value, l) : i.unclampedHeight, f = i.style.minHeight === "auto" ? i.style.overflow === "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;
930
954
  return {
931
955
  node: i,
932
956
  base: d,
@@ -936,9 +960,9 @@ function He(e, t, n, r, i, a, o) {
936
960
  max: K(i.style.maxHeight, l),
937
961
  margin: a
938
962
  };
939
- }), 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) ? Ge(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)));
940
964
  for (let n = 0; n < c.length; n++) if (g[n] !== c[n].node.localRect.height) {
941
- let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = Ke(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";
942
966
  V(r.node, i, g[n], 0, 0, a ? "fill" : "shrink", o, { height: g[n] });
943
967
  }
944
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;
@@ -946,13 +970,13 @@ function He(e, t, n, r, i, a, o) {
946
970
  let e = R(Array.from({ length: y }, () => 1), v), t = 0;
947
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++]);
948
972
  C = L("start", g, 0);
949
- } else C = L(Ze(e.style), g, v);
973
+ } else C = L($e(e.style), g, v);
950
974
  let w = i.left + a.left, T = i.top + a.top, E = 0;
951
975
  for (let n = 0; n < c.length; n++) {
952
976
  let r = c[n], i = r.node, a = r.margin.top ?? 0, o = r.margin.bottom ?? 0;
953
977
  E += b[n] + a, i.localRect = {
954
978
  ...i.localRect,
955
- x: w + We(i, e.style.alignItems, t, r.margin),
979
+ x: w + qe(i, e.style.alignItems, t, r.margin),
956
980
  y: T + C[n] + n * s + E
957
981
  }, E += x[n] + o;
958
982
  }
@@ -968,12 +992,12 @@ function He(e, t, n, r, i, a, o) {
968
992
  end: t
969
993
  });
970
994
  }
971
- e.decorationRuns = ve({
995
+ e.decorationRuns = be({
972
996
  glyphs: S(e.style.glyphSet),
973
997
  ruleX: null,
974
998
  ruleY: e.style.ruleY,
975
999
  vertical: [],
976
- horizontal: ze(n, e.style.ruleInset),
1000
+ horizontal: He(n, e.style.ruleInset),
977
1001
  contentWidth: t,
978
1002
  contentHeight: O,
979
1003
  border: i,
@@ -982,15 +1006,15 @@ function He(e, t, n, r, i, a, o) {
982
1006
  padding: a
983
1007
  });
984
1008
  }
985
- return Ve(e, i, a, t, O), O;
1009
+ return We(e, i, a, t, O), O;
986
1010
  }
987
- function Ue(e, t, n, r) {
1011
+ function Ke(e, t, n, r) {
988
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;
989
- return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + qe(i, n, e.localRect.height);
1013
+ return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + z(i, n, e.localRect.height);
990
1014
  }
991
- function We(e, t, n, r) {
1015
+ function qe(e, t, n, r) {
992
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;
993
- return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + qe(i, n, e.localRect.width);
1017
+ return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + z(i, n, e.localRect.width);
994
1018
  }
995
1019
  function L(e, t, n) {
996
1020
  let r = t.length;
@@ -1010,7 +1034,7 @@ function L(e, t, n) {
1010
1034
  for (let e = 0; e < r; e++) i.push(a), a += t[e];
1011
1035
  return i;
1012
1036
  }
1013
- function Ge(e, t) {
1037
+ function Je(e, t) {
1014
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);
1015
1039
  for (let t = 0; t < n; t++) {
1016
1040
  let n = r(i[t], t);
@@ -1045,33 +1069,45 @@ function R(e, t) {
1045
1069
  }
1046
1070
  return i;
1047
1071
  }
1048
- function Ke(e, t) {
1072
+ function Ye(e, t) {
1049
1073
  return e.style.alignSelf === "auto" ? t.style.alignItems : e.style.alignSelf;
1050
1074
  }
1051
- function qe(e, t, n) {
1075
+ function z(e, t, n) {
1052
1076
  return e === "center" ? Math.max(0, Math.floor((t - n) / 2)) : e === "end" ? Math.max(0, t - n) : 0;
1053
1077
  }
1054
- function Je(e, t, n) {
1078
+ function Xe(e, t, n) {
1055
1079
  let r = e.style.flexBasis, i = e.style.width;
1056
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);
1057
1081
  }
1058
- function Ye(e) {
1082
+ function Ze(e) {
1059
1083
  let t = e.children.filter((e) => !B(e.style)).sort((e, t) => e.style.order - t.style.order);
1060
1084
  return e.style.flexReverse && t.reverse(), t;
1061
1085
  }
1062
- function Xe(e) {
1086
+ function Qe(e) {
1063
1087
  return e.wrapReverse ? e.alignContent === "start" ? "end" : e.alignContent === "end" ? "start" : e.alignContent : e.alignContent;
1064
1088
  }
1065
- function Ze(e) {
1089
+ function $e(e) {
1066
1090
  let t = e.justifyContent === "stretch" ? "start" : e.justifyContent;
1067
1091
  return e.flexReverse ? t === "start" ? "end" : t === "end" ? "start" : t : t;
1068
1092
  }
1069
- function Qe(e, t, n) {
1070
- return e.style.minWidth === "auto" ? e.style.overflow === "visible" ? Y(e, n) : 0 : K(e.style.minWidth, t) ?? 0;
1093
+ function et(e, t, n) {
1094
+ return e.style.minWidth === "auto" ? e.style.overflow.x === "visible" ? Y(e, n) : 0 : K(e.style.minWidth, t) ?? 0;
1071
1095
  }
1072
1096
  //#endregion
1073
1097
  //#region src/types.ts
1074
- function $e() {
1098
+ function tt(e) {
1099
+ return e === "auto" || e === "scroll";
1100
+ }
1101
+ function nt(e) {
1102
+ return e.scrollbarWidth === "none" ? {
1103
+ right: 0,
1104
+ bottom: 0
1105
+ } : {
1106
+ right: e.overflow.y === "scroll" ? e.scrollbarSize.y : 0,
1107
+ bottom: e.overflow.x === "scroll" ? e.scrollbarSize.x : 0
1108
+ };
1109
+ }
1110
+ function rt() {
1075
1111
  return {
1076
1112
  display: "block",
1077
1113
  flexDirection: "row",
@@ -1090,8 +1126,8 @@ function $e() {
1090
1126
  justifySelf: "auto",
1091
1127
  gridTemplateColumns: { kind: "none" },
1092
1128
  gridTemplateRows: { kind: "none" },
1093
- gridAutoColumns: [et()],
1094
- gridAutoRows: [et()],
1129
+ gridAutoColumns: [at()],
1130
+ gridAutoRows: [at()],
1095
1131
  gridAutoFlow: {
1096
1132
  direction: "row",
1097
1133
  dense: !1
@@ -1107,7 +1143,7 @@ function $e() {
1107
1143
  minHeight: "auto",
1108
1144
  maxWidth: void 0,
1109
1145
  maxHeight: void 0,
1110
- padding: z(),
1146
+ padding: it(),
1111
1147
  margin: {
1112
1148
  top: 0,
1113
1149
  right: 0,
@@ -1123,14 +1159,27 @@ function $e() {
1123
1159
  },
1124
1160
  gapX: 0,
1125
1161
  gapY: 0,
1126
- border: z(),
1162
+ border: it(),
1127
1163
  borderStyle: {
1128
1164
  top: "solid",
1129
1165
  right: "solid",
1130
1166
  bottom: "solid",
1131
1167
  left: "solid"
1132
1168
  },
1133
- overflow: "visible",
1169
+ overflow: {
1170
+ x: "visible",
1171
+ y: "visible"
1172
+ },
1173
+ scrollbarWidth: "auto",
1174
+ scrollbarSize: {
1175
+ x: 1,
1176
+ y: 1
1177
+ },
1178
+ overscroll: {
1179
+ x: !0,
1180
+ y: !0
1181
+ },
1182
+ scrollbarColor: null,
1134
1183
  whiteSpace: "normal",
1135
1184
  tabSize: 8,
1136
1185
  lineGap: 0,
@@ -1176,7 +1225,7 @@ function $e() {
1176
1225
  breakInsideAvoid: !1
1177
1226
  };
1178
1227
  }
1179
- function z() {
1228
+ function it() {
1180
1229
  return {
1181
1230
  top: 0,
1182
1231
  right: 0,
@@ -1184,7 +1233,7 @@ function z() {
1184
1233
  left: 0
1185
1234
  };
1186
1235
  }
1187
- function et() {
1236
+ function at() {
1188
1237
  return {
1189
1238
  min: { kind: "auto" },
1190
1239
  max: { kind: "auto" }
@@ -1192,15 +1241,15 @@ function et() {
1192
1241
  }
1193
1242
  //#endregion
1194
1243
  //#region src/grid.ts
1195
- function tt(e, t, n, r, i, a) {
1196
- 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 = dt(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 ? {
1197
1246
  col: e.subgrid.colSpan,
1198
1247
  row: e.subgrid.rowSpan
1199
- } : 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(nt), T = c ? it(c) : Dt(_, y, at(f, w, x, a), t, u, o.justifyContent === "stretch"), E = c ? c.positions : Ot(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 = [];
1200
1249
  for (let e = 0; e < p.length; e++) {
1201
- let t = p[e], n = m.items[e], r = At(E, T.sizes, n.col.start, n.col.span), i = x[e], o = Math.max(0, r - ht(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];
1202
1251
  if (s.cols || s.rows) {
1203
- let e = s.cols ? rt(E, T, u, n.col.start, n.col.span, st(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;
1204
1253
  t.subgrid = {
1205
1254
  colSpan: n.col.span,
1206
1255
  rowSpan: n.row.span,
@@ -1209,17 +1258,17 @@ function tt(e, t, n, r, i, a) {
1209
1258
  };
1210
1259
  } else t.subgrid = void 0;
1211
1260
  let c = C[e], l = i.left === null || i.right === null, d = t.style.width !== void 0 && t.style.width.kind !== "auto";
1212
- 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 === "visible" ? Y(t, a) : 0 : K(t.style.minWidth, r) ?? 0, Bn(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);
1213
1262
  }
1214
- let O = l ? it(l) : Dt(v, b, ot(f, w, x), s ?? "max-content", d, o.alignContent === "stretch"), k = kt(O), A = l ? l.positions : Ot(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;
1215
1264
  for (let t = 0; t < p.length; t++) {
1216
- let n = p[t], r = m.items[t], i = x[t], o = At(E, T.sizes, r.col.start, r.col.span), s = At(A, O.sizes, r.row.start, r.row.span), c = Math.max(0, s - gt(i)), l = Ke(n, e), u = i.top === null || i.bottom === null, f = n.style.height !== void 0 && n.style.height.kind !== "auto";
1217
- if (w[t].rows) n.subgrid.rows = rt(A, O, d, r.row.start, r.row.span, st(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, {
1218
1267
  width: D[t],
1219
1268
  height: c
1220
1269
  });
1221
1270
  else if (l === "stretch" && !u && !f) {
1222
- let e = H(c, n.style.minHeight === "auto" ? n.style.overflow === "visible" ? n.localRect.height : 0 : K(n.style.minHeight, s) ?? 0, K(n.style.maxHeight, s));
1271
+ let e = H(c, n.style.minHeight === "auto" ? n.style.overflow.y === "visible" ? n.localRect.height : 0 : K(n.style.minHeight, s) ?? 0, K(n.style.maxHeight, s));
1223
1272
  e !== n.localRect.height && V(n, o, s, 0, 0, "fill", a, {
1224
1273
  width: D[t],
1225
1274
  height: e
@@ -1227,8 +1276,8 @@ function tt(e, t, n, r, i, a) {
1227
1276
  } else n.style.height?.kind === "percent" && V(n, o, s, 0, 0, "fill", a, { width: D[t] });
1228
1277
  n.localRect = {
1229
1278
  ...n.localRect,
1230
- x: j + E[r.col.start] + jt(C[t], i.left, i.right, o, n.localRect.width),
1231
- y: M + A[r.row.start] + jt(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)
1232
1281
  };
1233
1282
  }
1234
1283
  let N = Number.isFinite(n) ? Math.max(n, k) : k;
@@ -1245,7 +1294,7 @@ function tt(e, t, n, r, i, a) {
1245
1294
  let r = [];
1246
1295
  for (let i = 1; i < e.length; i++) {
1247
1296
  let a = e[i - 1] + t[i - 1], s = e[i] - a;
1248
- if (!(s <= 0)) for (let e of _e(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({
1249
1298
  bandStart: a,
1250
1299
  bandSize: s,
1251
1300
  ...e
@@ -1253,7 +1302,7 @@ function tt(e, t, n, r, i, a) {
1253
1302
  }
1254
1303
  return r;
1255
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));
1256
- e.decorationRuns = ve({
1305
+ e.decorationRuns = be({
1257
1306
  glyphs: S(o.glyphSet),
1258
1307
  ruleX: o.ruleX,
1259
1308
  ruleY: o.ruleY,
@@ -1281,7 +1330,7 @@ function tt(e, t, n, r, i, a) {
1281
1330
  height: N
1282
1331
  };
1283
1332
  for (let n of ee) {
1284
- let r = lt(n.style.gridColumnStart, n.style.gridColumnEnd, h, m.colOrigin, E, T.sizes, -i.left, t + i.right), a = lt(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);
1285
1334
  n.staticSlot = {
1286
1335
  kind: "grid",
1287
1336
  area: {
@@ -1296,14 +1345,14 @@ function tt(e, t, n, r, i, a) {
1296
1345
  }
1297
1346
  return N;
1298
1347
  }
1299
- function nt(e) {
1348
+ function st(e) {
1300
1349
  let t = e.style.display === "grid";
1301
1350
  return {
1302
1351
  cols: t && e.style.gridTemplateColumns.kind === "subgrid",
1303
1352
  rows: t && e.style.gridTemplateRows.kind === "subgrid"
1304
1353
  };
1305
1354
  }
1306
- function rt(e, t, n, r, i, a) {
1355
+ function ct(e, t, n, r, i, a) {
1307
1356
  let o = e[r] + a.start, s = t.sizes.slice(r, r + i);
1308
1357
  return s[0] = Math.max(0, s[0] - a.start), s[i - 1] = Math.max(0, s[i - 1] - a.end), {
1309
1358
  positions: Array.from({ length: i }, (t, n) => n === 0 ? 0 : e[r + n] - o),
@@ -1312,20 +1361,20 @@ function rt(e, t, n, r, i, a) {
1312
1361
  gap: n
1313
1362
  };
1314
1363
  }
1315
- function it(e) {
1364
+ function lt(e) {
1316
1365
  return {
1317
1366
  sizes: e.sizes,
1318
1367
  gapBefore: e.gapBefore,
1319
1368
  limits: e.sizes
1320
1369
  };
1321
1370
  }
1322
- function at(e, t, n, r) {
1371
+ function ut(e, t, n, r) {
1323
1372
  let i = [];
1324
1373
  return e.children.forEach((a, o) => {
1325
1374
  let s = e.placed.items[o], c = n[o];
1326
1375
  if (t[o].cols) {
1327
- let e = st(a, "cols", c, 0);
1328
- for (let t of ct(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({
1329
1378
  ...t,
1330
1379
  start: t.start + s.col.start
1331
1380
  });
@@ -1334,33 +1383,33 @@ function at(e, t, n, r) {
1334
1383
  i.push({
1335
1384
  start: s.col.start,
1336
1385
  span: s.col.span,
1337
- min: _t(a, "min", r) + ht(c),
1338
- max: _t(a, "max", r) + ht(c)
1386
+ min: St(a, "min", r) + bt(c),
1387
+ max: St(a, "max", r) + bt(c)
1339
1388
  });
1340
1389
  }), i;
1341
1390
  }
1342
- function ot(e, t, n) {
1391
+ function dt(e, t, n) {
1343
1392
  let r = [];
1344
1393
  return e.children.forEach((i, a) => {
1345
1394
  let o = e.placed.items[a], s = n[a];
1346
1395
  if (t[a].rows) {
1347
- let e = st(i, "rows", s, 0);
1348
- for (let t of ct(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({
1349
1398
  ...t,
1350
1399
  start: t.start + o.row.start
1351
1400
  });
1352
1401
  return;
1353
1402
  }
1354
- let c = i.localRect.height + gt(s);
1403
+ let c = i.localRect.height + xt(s), l = i.style.minHeight === "auto" && i.style.overflow.y !== "visible" ? xt(s) : c;
1355
1404
  r.push({
1356
1405
  start: o.row.start,
1357
1406
  span: o.row.span,
1358
- min: c,
1407
+ min: l,
1359
1408
  max: c
1360
1409
  });
1361
1410
  }), r;
1362
1411
  }
1363
- function st(e, t, n, r) {
1412
+ function ft(e, t, n, r) {
1364
1413
  let { border: i, padding: a } = e.style;
1365
1414
  return t === "cols" ? {
1366
1415
  start: (n.left ?? 0) + i.left + W(a.left, r),
@@ -1370,15 +1419,15 @@ function st(e, t, n, r) {
1370
1419
  end: (n.bottom ?? 0) + i.bottom + W(a.bottom, r)
1371
1420
  };
1372
1421
  }
1373
- function ct(e, t, n, r, i) {
1374
- let a = t === "cols" ? n.col.span : n.row.span, o = dt(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, {
1375
1424
  col: n.col.span,
1376
1425
  row: n.row.span
1377
1426
  }), s = [];
1378
1427
  if (o.children.forEach((e, n) => {
1379
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);
1380
- if (nt(e)[t]) {
1381
- let n = st(e, t, p, 0), a = ct(e, t, c, {
1429
+ if (st(e)[t]) {
1430
+ let n = ft(e, t, p, 0), a = pt(e, t, c, {
1382
1431
  start: n.start + (u ? r.start : 0),
1383
1432
  end: n.end + (d ? r.end : 0)
1384
1433
  }, i);
@@ -1391,11 +1440,11 @@ function ct(e, t, n, r, i) {
1391
1440
  if (t === "cols") s.push({
1392
1441
  start: l.start,
1393
1442
  span: l.span,
1394
- min: _t(e, "min", i) + ht(p) + f,
1395
- max: _t(e, "max", i) + ht(p) + f
1443
+ min: St(e, "min", i) + bt(p) + f,
1444
+ max: St(e, "max", i) + bt(p) + f
1396
1445
  });
1397
1446
  else {
1398
- let t = e.localRect.height + gt(p) + f;
1447
+ let t = e.localRect.height + xt(p) + f;
1399
1448
  s.push({
1400
1449
  start: l.start,
1401
1450
  span: l.span,
@@ -1414,9 +1463,9 @@ function ct(e, t, n, r, i) {
1414
1463
  }
1415
1464
  return s;
1416
1465
  }
1417
- function lt(e, t, n, r, i, a, o, s) {
1418
- let c = Ct(e, "start", n), l = Ct(t, "end", n);
1419
- c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = wt(c, t, 1, n) : l !== null && e.kind === "span" && (c = wt(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));
1420
1469
  let u = i.length, d = (e) => {
1421
1470
  if (e === null) return;
1422
1471
  let t = e - r;
@@ -1427,22 +1476,22 @@ function lt(e, t, n, r, i, a, o, s) {
1427
1476
  end: h === void 0 ? s : p(h)
1428
1477
  };
1429
1478
  }
1430
- function ut(e, t) {
1479
+ function ht(e, t) {
1431
1480
  let n = t.gridIntrinsic.get(e);
1432
1481
  if (n !== void 0) return n;
1433
- let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = dt(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 ? {
1434
1483
  col: e.subgrid.colSpan,
1435
1484
  row: e.subgrid.rowSpan
1436
- } : void 0), o = a.children.map(nt), s = a.children.map((e) => G(e.style.margin, 0)), c = Dt(a.colTracks, a.colCollapsed, at(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 = {
1437
1486
  min: c.sizes.reduce((e, t) => e + t, 0) + l,
1438
1487
  max: c.limits.reduce((e, t) => e + t, 0) + l
1439
1488
  };
1440
1489
  return t.gridIntrinsic.set(e, u), u;
1441
1490
  }
1442
- function dt(e, t, n, r, i, a) {
1443
- let o = e.style, s = mt(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? ft(a.col) : vt(o.gridTemplateColumns, t, r), d = l ? ft(a.row) : vt(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];
1444
1493
  if (f) {
1445
- c || bt(p, u.lineNames, f.columns, o.gridAutoColumns), l || bt(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);
1446
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`);
1447
1496
  }
1448
1497
  let h = {
@@ -1451,28 +1500,28 @@ function dt(e, t, n, r, i, a) {
1451
1500
  }, g = {
1452
1501
  explicitCount: m.length,
1453
1502
  names: d.lineNames
1454
- }, _ = Et(s.map((e) => ({
1455
- col: Tt(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1456
- row: Tt(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)
1457
1506
  })), p.length, m.length, o.gridAutoFlow);
1458
- return c && pt(_, "col", p.length), l && pt(_, "row", m.length), {
1507
+ return c && vt(_, "col", p.length), l && vt(_, "row", m.length), {
1459
1508
  children: s,
1460
1509
  placed: _,
1461
1510
  colLines: h,
1462
1511
  rowLines: g,
1463
- colTracks: xt(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1464
- rowTracks: xt(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1465
- colCollapsed: St(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1466
- rowCollapsed: St(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))
1467
1516
  };
1468
1517
  }
1469
- function ft(e) {
1518
+ function _t(e) {
1470
1519
  return {
1471
- tracks: Array.from({ length: e }, () => et()),
1520
+ tracks: Array.from({ length: e }, () => at()),
1472
1521
  lineNames: Array.from({ length: e + 1 }, () => [])
1473
1522
  };
1474
1523
  }
1475
- function pt(e, t, n) {
1524
+ function vt(e, t, n) {
1476
1525
  let r = t === "col" ? e.colOrigin : e.rowOrigin;
1477
1526
  for (let i of e.items) {
1478
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);
@@ -1480,22 +1529,22 @@ function pt(e, t, n) {
1480
1529
  }
1481
1530
  t === "col" ? (e.colOrigin = 0, e.colCount = n) : (e.rowOrigin = 0, e.rowCount = n);
1482
1531
  }
1483
- function mt(e) {
1532
+ function yt(e) {
1484
1533
  return e.children.filter((e) => !B(e.style) && !e.inlineBox).sort((e, t) => e.style.order - t.style.order);
1485
1534
  }
1486
- function ht(e) {
1535
+ function bt(e) {
1487
1536
  return (e.left ?? 0) + (e.right ?? 0);
1488
1537
  }
1489
- function gt(e) {
1538
+ function xt(e) {
1490
1539
  return (e.top ?? 0) + (e.bottom ?? 0);
1491
1540
  }
1492
- function _t(e, t, n) {
1541
+ function St(e, t, n) {
1493
1542
  let r = e.style, i;
1494
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));
1495
1544
  let a = typeof r.minWidth == "number" ? r.minWidth : 0, o = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
1496
1545
  return Math.max(0, H(i, a, o));
1497
1546
  }
1498
- function vt(e, t, n) {
1547
+ function Ct(e, t, n) {
1499
1548
  if (e.kind !== "tracks") return {
1500
1549
  tracks: [],
1501
1550
  lineNames: [[]]
@@ -1508,7 +1557,7 @@ function vt(e, t, n) {
1508
1557
  let { index: i, tracks: a, mode: o } = e.autoRepeat, s = 1;
1509
1558
  if (t !== void 0) {
1510
1559
  let e = a.reduce((e, n) => {
1511
- let r = yt(n.min, t) ?? yt(n.max, t) ?? 1;
1560
+ let r = wt(n.min, t) ?? wt(n.max, t) ?? 1;
1512
1561
  return e + Math.max(1, r);
1513
1562
  }, 0);
1514
1563
  s = Math.max(1, Math.floor((t + n) / (e + n * a.length)));
@@ -1536,23 +1585,23 @@ function vt(e, t, n) {
1536
1585
  lineNames: d
1537
1586
  };
1538
1587
  }
1539
- function yt(e, t) {
1588
+ function wt(e, t) {
1540
1589
  if (e.kind === "cells") return e.value;
1541
- if (e.kind === "percent" && t !== void 0) return xe(e.value, t);
1590
+ if (e.kind === "percent" && t !== void 0) return we(e.value, t);
1542
1591
  if (e.kind === "math") {
1543
1592
  let n = [];
1544
1593
  for (let r of e.args) {
1545
- let e = yt(r, t);
1594
+ let e = wt(r, t);
1546
1595
  if (e === void 0) return;
1547
1596
  n.push(e);
1548
1597
  }
1549
1598
  return e.fn === "min" ? Math.min(...n) : Math.max(...n);
1550
1599
  }
1551
1600
  }
1552
- function bt(e, t, n, r) {
1601
+ function Tt(e, t, n, r) {
1553
1602
  for (let i = e.length; i < n; i++) e.push(r[(i - e.length) % r.length]), t.push([]);
1554
1603
  }
1555
- function xt(e, t, n, r) {
1604
+ function Et(e, t, n, r) {
1556
1605
  let i = [];
1557
1606
  for (let a = 0; a < n; a++) {
1558
1607
  let n = a + t;
@@ -1564,7 +1613,7 @@ function xt(e, t, n, r) {
1564
1613
  }
1565
1614
  return i;
1566
1615
  }
1567
- function St(e, t, n, r) {
1616
+ function Dt(e, t, n, r) {
1568
1617
  let i = Array.from({ length: n }, () => !1);
1569
1618
  if (!e.autoFit) return i;
1570
1619
  for (let a = e.autoFit.start; a < e.autoFit.end; a++) {
@@ -1573,7 +1622,7 @@ function St(e, t, n, r) {
1573
1622
  }
1574
1623
  return i;
1575
1624
  }
1576
- function Ct(e, t, n) {
1625
+ function Ot(e, t, n) {
1577
1626
  if (e.kind === "line") return e.value > 0 ? e.value - 1 : n.explicitCount + 1 + e.value;
1578
1627
  if (e.kind !== "name") return null;
1579
1628
  if (e.nth === void 0) {
@@ -1588,14 +1637,14 @@ function Ct(e, t, n) {
1588
1637
  for (let t = i; t >= 0; t--) if (n.names[t].includes(e.name) && ++a === -r) return t;
1589
1638
  return -(-r - a);
1590
1639
  }
1591
- function wt(e, t, n, r) {
1640
+ function kt(e, t, n, r) {
1592
1641
  if (t.name === void 0) return e + n * t.value;
1593
1642
  let i = t.value, a = e;
1594
1643
  for (; i > 0;) a += n, (!(a >= 0 && a <= r.explicitCount) || r.names[a].includes(t.name)) && i--;
1595
1644
  return a;
1596
1645
  }
1597
- function Tt(e, t, n) {
1598
- let r = Ct(e, "start", n), i = Ct(t, "end", n);
1646
+ function At(e, t, n) {
1647
+ let r = Ot(e, "start", n), i = Ot(t, "end", n);
1599
1648
  if (r !== null && i !== null) return r === i ? {
1600
1649
  start: r,
1601
1650
  span: 1
@@ -1605,10 +1654,10 @@ function Tt(e, t, n) {
1605
1654
  };
1606
1655
  if (r !== null) return {
1607
1656
  start: r,
1608
- span: (t.kind === "span" ? wt(r, t, 1, n) : r + 1) - r
1657
+ span: (t.kind === "span" ? kt(r, t, 1, n) : r + 1) - r
1609
1658
  };
1610
1659
  if (i !== null) {
1611
- let t = e.kind === "span" ? wt(i, e, -1, n) : i - 1;
1660
+ let t = e.kind === "span" ? kt(i, e, -1, n) : i - 1;
1612
1661
  return {
1613
1662
  start: t,
1614
1663
  span: i - t
@@ -1619,7 +1668,7 @@ function Tt(e, t, n) {
1619
1668
  span: e.kind === "span" ? e.value : t.kind === "span" ? t.value : 1
1620
1669
  };
1621
1670
  }
1622
- function Et(e, t, n, r) {
1671
+ function jt(e, t, n, r) {
1623
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);
1624
1673
  for (let t = 0; t < e.length; t++) {
1625
1674
  let e = o[t];
@@ -1716,7 +1765,7 @@ function Et(e, t, n, r) {
1716
1765
  rowCount: S
1717
1766
  };
1718
1767
  }
1719
- function Dt(e, t, n, r, i, a) {
1768
+ function Mt(e, t, n, r, i, a) {
1720
1769
  let o = typeof r == "number" ? r : void 0, s = e.map((e, n) => {
1721
1770
  if (t[n]) return {
1722
1771
  base: 0,
@@ -1726,7 +1775,7 @@ function Dt(e, t, n, r, i, a) {
1726
1775
  frFactor: 0,
1727
1776
  collapsed: !0
1728
1777
  };
1729
- let r = yt(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;
1730
1779
  if (s.kind === "fr") return {
1731
1780
  base: i,
1732
1781
  limit: null,
@@ -1735,7 +1784,7 @@ function Dt(e, t, n, r, i, a) {
1735
1784
  frFactor: s.value,
1736
1785
  collapsed: !1
1737
1786
  };
1738
- let c = yt(s, o);
1787
+ let c = wt(s, o);
1739
1788
  return c === void 0 ? {
1740
1789
  base: i,
1741
1790
  limit: null,
@@ -1860,65 +1909,65 @@ function Dt(e, t, n, r, i, a) {
1860
1909
  limits: s.map((e) => u(e))
1861
1910
  };
1862
1911
  }
1863
- function Ot(e, t, n) {
1864
- let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - kt(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;
1865
1914
  for (let e = 0; e < r.length; e++) c += i[e], s.push(o[e] + c);
1866
1915
  return s;
1867
1916
  }
1868
- function kt(e) {
1917
+ function Pt(e) {
1869
1918
  return e.sizes.reduce((e, t) => e + t, 0) + e.gapBefore.reduce((e, t) => e + t, 0);
1870
1919
  }
1871
- function At(e, t, n, r) {
1920
+ function Ft(e, t, n, r) {
1872
1921
  let i = n + r - 1;
1873
1922
  return e[n] === void 0 || e[i] === void 0 ? 0 : e[i] + t[i] - e[n];
1874
1923
  }
1875
- function jt(e, t, n, r, i) {
1924
+ function It(e, t, n, r, i) {
1876
1925
  let a = t ?? 0, o = n ?? 0, s = r - i;
1877
- return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + qe(e, r, i + a + o);
1926
+ return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + z(e, r, i + a + o);
1878
1927
  }
1879
1928
  //#endregion
1880
1929
  //#region src/multicol.ts
1881
- function Mt(e, t, n) {
1930
+ function Lt(e, t, n) {
1882
1931
  let r = e.columnWidth === null ? null : Math.max(1, Math.floor((t + n) / (e.columnWidth + n)));
1883
1932
  return e.columnCount !== null && r !== null ? Math.max(1, Math.min(e.columnCount, r)) : r === null ? Math.max(1, e.columnCount ?? 1) : r;
1884
1933
  }
1885
- function Nt(e, t, n) {
1886
- let r = Mt(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));
1887
1936
  return Array.from({ length: r }, (e, t) => i + +(t < a));
1888
1937
  }
1889
- function Pt(e, t) {
1938
+ function zt(e, t) {
1890
1939
  let n = Math.max(typeof e.gapX == "number" ? e.gapX : 0, e.ruleX?.width ?? 0);
1891
1940
  return e.columnCount === null ? Math.max(e.columnWidth ?? 1, t) : e.columnCount * t + (e.columnCount - 1) * n;
1892
1941
  }
1893
- function Ft(e, t) {
1942
+ function Bt(e, t) {
1894
1943
  return e === void 0 ? t : t === void 0 ? e : Math.min(e, t);
1895
1944
  }
1896
- function It(e, t, n) {
1945
+ function Vt(e, t, n) {
1897
1946
  for (; e < t;) {
1898
1947
  let r = e + t >> 1;
1899
1948
  n(r) ? t = r : e = r + 1;
1900
1949
  }
1901
1950
  return e;
1902
1951
  }
1903
- function Lt(e, t, n) {
1904
- let r = Mt(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));
1905
1954
  return {
1906
1955
  count: r,
1907
1956
  width: i,
1908
1957
  leftover: Math.max(0, t - (r * i + (r - 1) * n))
1909
1958
  };
1910
1959
  }
1911
- function Rt(e, t, n) {
1960
+ function Ut(e, t, n) {
1912
1961
  return e === "all" ? !0 : e === "around" ? t || n : t && n;
1913
1962
  }
1914
- function zt(e, t, n, r) {
1915
- let i = Ln(e, Math.max(1, t.width - e.style.tracking)), { heights: a, textOffsets: o } = Rn(e, i), s = e.style.lineGap, c = Vt(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;
1916
1965
  if (e.style.columnFill === "auto" && r !== void 0) l = Math.max(1, r);
1917
1966
  else {
1918
- let e = It(c.reduce((e, t) => Math.max(e, t.rows - s), 1), Math.max(1, c.reduce((e, t) => e + t.rows, 0) - s), (e) => Bt(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);
1919
1968
  l = r === void 0 ? e : Math.max(1, Math.min(e, r));
1920
1969
  }
1921
- let u = Bt(c, s, l);
1970
+ let u = Gt(c, s, l);
1922
1971
  return {
1923
1972
  spans: i,
1924
1973
  lineY: u.top,
@@ -1931,7 +1980,7 @@ function zt(e, t, n, r) {
1931
1980
  columnsUsed: i.length > 0 ? u.columns : 0
1932
1981
  };
1933
1982
  }
1934
- function Bt(e, t, n, r = "truncate") {
1983
+ function Gt(e, t, n, r = "truncate") {
1935
1984
  let i = 0, a = 0, o = 0, s = [], c = [];
1936
1985
  for (let l = 0; l < e.length; l++) {
1937
1986
  let u = e[l], d = r === "glue" || l === 0 || a > 0 ? u.pre : 0;
@@ -1952,7 +2001,7 @@ function Bt(e, t, n, r = "truncate") {
1952
2001
  top: c
1953
2002
  };
1954
2003
  }
1955
- function Vt(e) {
2004
+ function Kt(e) {
1956
2005
  return e.map((e) => ({
1957
2006
  rows: e,
1958
2007
  pre: 0,
@@ -1961,27 +2010,27 @@ function Vt(e) {
1961
2010
  lines: 1
1962
2011
  }));
1963
2012
  }
1964
- var Ht = null;
1965
- function Ut() {
1966
- if (Ht !== null) return Ht;
2013
+ var qt = null;
2014
+ function Jt() {
2015
+ if (qt !== null) return qt;
1967
2016
  let e = document.createElement("div");
1968
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);
1969
2018
  let t = e.getBoundingClientRect().top, n = e.querySelector("span").getBoundingClientRect();
1970
- return e.remove(), Ht = !(n.width > 0 && n.top - t >= 10), Ht;
2019
+ return e.remove(), qt = !(n.width > 0 && n.top - t >= 10), qt;
1971
2020
  }
1972
- function Wt(e, t) {
1973
- 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 = Oe(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), {
1974
2023
  advances: s,
1975
2024
  tracking: i,
1976
2025
  firstLineIndent: t.firstLineIndent
1977
- }), l = Vt(c.map(() => 1 + a)), u = Bt(l, a, o ?? It(1, Math.max(1, c.length * (1 + a) - a), (e) => Bt(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));
1978
2027
  return c.map((t, n) => ({
1979
2028
  text: e.slice(t.start, t.end),
1980
2029
  column: u.column[n],
1981
2030
  top: u.top[n]
1982
2031
  }));
1983
2032
  }
1984
- function Gt(e, t, n, r) {
2033
+ function Xt(e, t, n, r) {
1985
2034
  let i = e.style;
1986
2035
  if (!i.ruleX) return;
1987
2036
  let a = t.columnCount * t.columnWidth + (t.columnCount - 1) * t.gap, o = t.ruleSegments ?? [{
@@ -1991,18 +2040,18 @@ function Gt(e, t, n, r) {
1991
2040
  }], s = [];
1992
2041
  for (let e of o) {
1993
2042
  let n = Math.min(e.columns, t.columnCount);
1994
- for (let r = 0; r < t.columnCount - 1; r++) Rt(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({
1995
2044
  bandStart: (r + 1) * t.columnWidth + r * t.gap,
1996
2045
  bandSize: t.gap,
1997
2046
  start: e.start,
1998
2047
  end: e.end
1999
2048
  });
2000
2049
  }
2001
- e.decorationRuns = ve({
2050
+ e.decorationRuns = be({
2002
2051
  glyphs: S(i.glyphSet),
2003
2052
  ruleX: i.ruleX,
2004
2053
  ruleY: null,
2005
- vertical: ze(s, i.ruleInset),
2054
+ vertical: He(s, i.ruleInset),
2006
2055
  horizontal: [],
2007
2056
  contentWidth: a,
2008
2057
  contentHeight: t.totalRows,
@@ -2012,12 +2061,12 @@ function Gt(e, t, n, r) {
2012
2061
  padding: r
2013
2062
  });
2014
2063
  }
2015
- function Kt(e, t) {
2064
+ function Zt(e, t) {
2016
2065
  let n = e.style, r = n.padding;
2017
- 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.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;
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;
2018
2067
  }
2019
- function qt(e, t, n, r, i, a, o) {
2020
- let s = e.style, c = U(s, "x", n), l = Lt(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);
2021
2070
  a.right += l.leftover;
2022
2071
  let u = s.lineGap, d = i.left + a.left, f = i.top + a.top, p = n - l.leftover, m = [[]], h = [];
2023
2072
  for (let e of t) e.style.columnSpan ? (h[m.length - 1] = e, m.push([])) : m[m.length - 1].push(e);
@@ -2027,13 +2076,13 @@ function qt(e, t, n, r, i, a, o) {
2027
2076
  if (t.length > 0) {
2028
2077
  let i = t.map((e) => ({
2029
2078
  node: e,
2030
- spans: Ln(e, Math.max(1, l.width - e.style.tracking)),
2079
+ spans: Hn(e, Math.max(1, l.width - e.style.tracking)),
2031
2080
  margin: G(e.style.margin, l.width),
2032
2081
  pre: 0,
2033
2082
  post: 0
2034
2083
  })), a = [], o = null, h = null, x = !1;
2035
2084
  for (let e of i) {
2036
- let { node: t, spans: n, margin: r } = e, i = o === null ? r.top ?? 0 : Un(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;
2037
2086
  _ === "glue" && h !== null ? (s = 0, h.post = i, a[a.length - 1].post = i) : e.pre = i;
2038
2087
  let c = x || t.style.breakBeforeColumn;
2039
2088
  if (t.style.breakInsideAvoid && n.length > 0) a.push({
@@ -2056,10 +2105,10 @@ function qt(e, t, n, r, i, a, o) {
2056
2105
  let S;
2057
2106
  if (s.columnFill === "auto" && r !== void 0) S = Math.max(1, r);
2058
2107
  else {
2059
- let e = It(1, Math.max(1, Bt(a, u, Infinity, _).maxUsed), (e) => Bt(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);
2060
2109
  S = r === void 0 ? e : Math.max(1, Math.min(e, r));
2061
2110
  }
2062
- let C = Bt(a, u, S, _);
2111
+ let C = Gt(a, u, S, _);
2063
2112
  for (let e = 0, t = 0; e < i.length; e++) {
2064
2113
  let { node: n, spans: r, margin: a, pre: o, post: s } = i[e], u = [], m = [];
2065
2114
  for (let e = 0; e < r.length; e++, t++) u.push(y + C.top[t]), m.push(C.column[t] * (l.width + c));
@@ -2100,7 +2149,7 @@ function qt(e, t, n, r, i, a, o) {
2100
2149
  if (i) {
2101
2150
  let e = G(i.style.margin, p), t = (e.left ?? 0) + (e.right ?? 0);
2102
2151
  V(i, Math.max(0, p - t), void 0, 0, 0, "fill", o);
2103
- let r = Hn(e, p, i.localRect.width), a = (e.top ?? 0) + n;
2152
+ let r = qn(e, p, i.localRect.width), a = (e.top ?? 0) + n;
2104
2153
  y += a, i.localRect = {
2105
2154
  ...i.localRect,
2106
2155
  x: d + r,
@@ -2139,10 +2188,10 @@ function qt(e, t, n, r, i, a, o) {
2139
2188
  } : {}
2140
2189
  }, x;
2141
2190
  }
2142
- function Jt(e, t, n, r, i, a, o) {
2143
- let s = e.style, c = Ft(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);
2144
- if (u.length > 0 && u.every((e) => Kt(e, s)) && (u.length === l.length || s.columnFill === "balance" && c === void 0 && (Ut() || 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);
2145
- let f = U(s, "x", t), p = Nt(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 = [];
2146
2195
  {
2147
2196
  let e = 0;
2148
2197
  for (let t of p) h.push(e), e += t + f;
@@ -2151,7 +2200,7 @@ function Jt(e, t, n, r, i, a, o) {
2151
2200
  let r = 0, i = 0, a = null, s = 0, c = (e) => {
2152
2201
  if (t) for (let t of T) {
2153
2202
  if (t.index !== e) continue;
2154
- let n = a === null ? t.margin.top ?? 0 : Un(a, t.margin.top ?? 0);
2203
+ let n = a === null ? t.margin.top ?? 0 : Jn(a, t.margin.top ?? 0);
2155
2204
  t.child.staticSlot = {
2156
2205
  kind: "block",
2157
2206
  x: y + g(r) + (t.margin.left ?? 0),
@@ -2162,7 +2211,7 @@ function Jt(e, t, n, r, i, a, o) {
2162
2211
  for (let l = 0; l < w.length; l++) {
2163
2212
  let u = w[l];
2164
2213
  c(l);
2165
- let d = a === null ? l === 0 ? u.margin.top ?? 0 : 0 : Un(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;
2166
2215
  if (a !== null && (u.breakBefore || i + d + f > e) && (r += 1, i = 0, a = null, d = 0), t) {
2167
2216
  let e = u.node, t = _(r);
2168
2217
  if (t !== v) {
@@ -2171,7 +2220,7 @@ function Jt(e, t, n, r, i, a, o) {
2171
2220
  }
2172
2221
  e.localRect = {
2173
2222
  ...e.localRect,
2174
- x: y + g(r) + Hn(u.margin, t, e.localRect.width),
2223
+ x: y + g(r) + qn(u.margin, t, e.localRect.width),
2175
2224
  y: b + C + i + d
2176
2225
  };
2177
2226
  }
@@ -2194,13 +2243,13 @@ function Jt(e, t, n, r, i, a, o) {
2194
2243
  let e = c === void 0 ? void 0 : Math.max(1, c - C), t = s.columnFill === "auto" && e !== void 0, r;
2195
2244
  if (t) r = e;
2196
2245
  else {
2197
- let t = It(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);
2198
2247
  r = e === void 0 ? t : Math.min(t, e);
2199
2248
  }
2200
2249
  let i = D(r, !0), a = t && n !== void 0 ? Math.max(i.maxUsed, r) : i.maxUsed;
2201
2250
  if (s.ruleX) for (let e = 0; e < m - 1; e++) {
2202
2251
  let t = Math.min(i.columns, m);
2203
- Rt(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2252
+ Ut(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2204
2253
  bandStart: h[e] + p[e],
2205
2254
  bandSize: f,
2206
2255
  start: C,
@@ -2223,7 +2272,7 @@ function Jt(e, t, n, r, i, a, o) {
2223
2272
  let e = G(r.style.margin, t), i = (e.left ?? 0) + (e.right ?? 0);
2224
2273
  V(r, Math.max(0, t - i), n, 0, 0, "fill", o), C += e.top ?? 0, r.localRect = {
2225
2274
  ...r.localRect,
2226
- x: y + Hn(e, t, r.localRect.width),
2275
+ x: y + qn(e, t, r.localRect.width),
2227
2276
  y: b + C
2228
2277
  }, C += r.localRect.height + (e.bottom ?? 0);
2229
2278
  continue;
@@ -2235,11 +2284,11 @@ function Jt(e, t, n, r, i, a, o) {
2235
2284
  breakBefore: E || r.style.breakBeforeColumn
2236
2285
  }), E = r.style.breakAfterColumn;
2237
2286
  }
2238
- return O(), s.ruleX && x.length > 0 && (e.decorationRuns = ve({
2287
+ return O(), s.ruleX && x.length > 0 && (e.decorationRuns = be({
2239
2288
  glyphs: S(s.glyphSet),
2240
2289
  ruleX: s.ruleX,
2241
2290
  ruleY: null,
2242
- vertical: ze(x, s.ruleInset),
2291
+ vertical: He(x, s.ruleInset),
2243
2292
  horizontal: [],
2244
2293
  contentWidth: t,
2245
2294
  contentHeight: C,
@@ -2251,32 +2300,32 @@ function Jt(e, t, n, r, i, a, o) {
2251
2300
  }
2252
2301
  //#endregion
2253
2302
  //#region src/table.ts
2254
- function Yt(e, t) {
2255
- e.hidden.push(t), t.style.tableRole !== "column" && t.style.tableRole !== "column-group" && M(t.source, "Table content outside the expected structure (rows in tables, cells in rows) can't be laid out and was hidden — no anonymous table boxes (specs/table.md).");
2303
+ function en(e, t) {
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).");
2256
2305
  }
2257
- function Xt(e, t) {
2306
+ function tn(e, t) {
2258
2307
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
2259
2308
  return Number.isNaN(n) ? 1 : t === "colspan" ? Math.min(1e3, Math.max(1, n)) : Math.min(65534, Math.max(0, n));
2260
2309
  }
2261
- function Zt(e, t, n) {
2310
+ function nn(e, t, n) {
2262
2311
  let r = (t, r) => {
2263
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;
2264
2313
  for (let t = 0; t < r; t++) e.colFixed.push(a), e.colPercent.push(o);
2265
2314
  };
2266
2315
  if (t.style.tableRole === "column") {
2267
- r(t, Qt(t.source));
2316
+ r(t, rn(t.source));
2268
2317
  return;
2269
2318
  }
2270
2319
  let i = t.children.filter((e) => e.style.tableRole === "column");
2271
- if (i.length === 0) r(t, Qt(t.source));
2272
- else for (let e of i) r(e, Qt(e.source));
2273
- for (let n of t.children) n.style.tableRole !== "column" && Yt(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);
2274
2323
  }
2275
- function Qt(e) {
2324
+ function rn(e) {
2276
2325
  let t = Number.parseInt(e.getAttribute("span") ?? "", 10);
2277
2326
  return Number.isNaN(t) ? 1 : Math.min(1e3, Math.max(1, t));
2278
2327
  }
2279
- function $t(e, t) {
2328
+ function an(e, t) {
2280
2329
  let n = {
2281
2330
  caption: null,
2282
2331
  rows: [],
@@ -2300,8 +2349,8 @@ function $t(e, t) {
2300
2349
  for (let e of o.children) B(e.style) || (e.style.tableRole === "row" ? t.push({
2301
2350
  row: e,
2302
2351
  group: o
2303
- }) : Yt(n, e));
2304
- } else e === "caption" ? n.caption === null ? n.caption = o : Yt(n, o) : e === "column" || e === "column-group" ? (Zt(n, o, t), n.hidden.push(o)) : Yt(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);
2305
2354
  }
2306
2355
  let o = [
2307
2356
  ...r,
@@ -2316,20 +2365,20 @@ function $t(e, t) {
2316
2365
  s = e + 1;
2317
2366
  }
2318
2367
  }
2319
- return en(n), n;
2368
+ return on(n), n;
2320
2369
  }
2321
- function en(e) {
2370
+ function on(e) {
2322
2371
  let t = [];
2323
2372
  for (let n = 0; n < e.rows.length; n++) {
2324
2373
  let r = e.rows[n], i = 0;
2325
2374
  for (let a of r.children) {
2326
2375
  if (B(a.style)) continue;
2327
2376
  if (a.style.tableRole !== "cell") {
2328
- Yt(e, a);
2377
+ en(e, a);
2329
2378
  continue;
2330
2379
  }
2331
2380
  for (; (t[i] ?? 0) > n;) i++;
2332
- let o = Xt(a.source, "colspan"), s = Xt(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));
2333
2382
  for (let e = i; e < i + o; e++) t[e] = Math.max(t[e] ?? 0, n + l);
2334
2383
  e.cells.push({
2335
2384
  node: a,
@@ -2343,7 +2392,7 @@ function en(e) {
2343
2392
  }
2344
2393
  e.columnCount = Math.max(t.length, e.colFixed.length);
2345
2394
  }
2346
- function tn(e, t, n) {
2395
+ function sn(e, t, n) {
2347
2396
  let r = e.style, i = Y(e, n), a;
2348
2397
  if (t === "min") a = i;
2349
2398
  else {
@@ -2353,11 +2402,11 @@ function tn(e, t, n) {
2353
2402
  let o = typeof r.minWidth == "number" ? r.minWidth : 0, s = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
2354
2403
  return Math.max(0, H(a, o, s));
2355
2404
  }
2356
- function nn(e) {
2405
+ function cn(e) {
2357
2406
  let t = e.style.width;
2358
2407
  return t && t.kind === "percent" ? t.value : void 0;
2359
2408
  }
2360
- function rn(e, t, n) {
2409
+ function ln(e, t, n) {
2361
2410
  let r = e.columnCount, i = Array.from({ length: r }, () => 0), a = Array.from({ length: r }, () => 0), o = Array.from({ length: r }, () => void 0);
2362
2411
  for (let t = 0; t < r; t++) e.colFixed[t] !== void 0 && (a[t] = e.colFixed[t]), o[t] = e.colPercent[t];
2363
2412
  let s = [];
@@ -2366,15 +2415,15 @@ function rn(e, t, n) {
2366
2415
  s.push(t);
2367
2416
  continue;
2368
2417
  }
2369
- i[t.col] = Math.max(i[t.col], tn(t.node, "min", n)), a[t.col] = Math.max(a[t.col], tn(t.node, "max", n));
2370
- let e = nn(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);
2371
2420
  e !== void 0 && (o[t.col] = Math.max(o[t.col] ?? 0, e));
2372
2421
  }
2373
2422
  s.sort((e, t) => e.colSpan - t.colSpan);
2374
2423
  for (let e of s) {
2375
- let r = e.col, o = e.col + e.colSpan, s = dn(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);
2376
2425
  for (let t of ["min", "max"]) {
2377
- let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = tn(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;
2378
2427
  if (d <= 0) continue;
2379
2428
  let f = R(c.some((e) => e > 0) ? c : c.map(() => 1), d);
2380
2429
  for (let e = r; e < o; e++) l[e] += f[e - r];
@@ -2387,7 +2436,7 @@ function rn(e, t, n) {
2387
2436
  percent: o
2388
2437
  };
2389
2438
  }
2390
- function an(e, t) {
2439
+ function un(e, t) {
2391
2440
  let n = e.min.length, r = e.min.slice(), i = [], a = [];
2392
2441
  for (let t = 0; t < n; t++) (e.percent[t] === void 0 ? a : i).push(t);
2393
2442
  if (i.length > 0) {
@@ -2416,7 +2465,7 @@ function an(e, t) {
2416
2465
  }
2417
2466
  return r;
2418
2467
  }
2419
- function on(e, t, n) {
2468
+ function dn(e, t, n) {
2420
2469
  let r = e.columnCount, i = Array.from({ length: r }, () => void 0);
2421
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];
2422
2471
  for (let r of e.cells) {
@@ -2436,13 +2485,13 @@ function on(e, t, n) {
2436
2485
  }
2437
2486
  return i.map((e) => e ?? 0);
2438
2487
  }
2439
- var sn = {
2488
+ var fn = {
2440
2489
  double: 3,
2441
2490
  solid: 2,
2442
2491
  dashed: 1,
2443
2492
  dotted: 0
2444
2493
  };
2445
- function cn(e) {
2494
+ function pn(e) {
2446
2495
  for (let { border: t, side: n } of e) if (t?.hidden[n]) return null;
2447
2496
  let t = null;
2448
2497
  for (let { border: n, side: r } of e) {
@@ -2450,7 +2499,7 @@ function cn(e) {
2450
2499
  let e = n.width[r];
2451
2500
  if (e <= 0) continue;
2452
2501
  let i = n.style[r];
2453
- (t === null || e > t.width || e === t.width && sn[i] > sn[t.style]) && (t = {
2502
+ (t === null || e > t.width || e === t.width && fn[i] > fn[t.style]) && (t = {
2454
2503
  width: e,
2455
2504
  style: i,
2456
2505
  color: n.color[r]
@@ -2458,7 +2507,7 @@ function cn(e) {
2458
2507
  }
2459
2508
  return t;
2460
2509
  }
2461
- function ln(e, t) {
2510
+ function mn(e, t) {
2462
2511
  let n = t.columnCount, r = t.rows.length, i = e.style.borderCollapse, a = {
2463
2512
  collapsed: i,
2464
2513
  vLines: Array.from({ length: n + 1 }, () => 0),
@@ -2503,7 +2552,7 @@ function ln(e, t) {
2503
2552
  side: u
2504
2553
  });
2505
2554
  }
2506
- i.push(cn(l));
2555
+ i.push(pn(l));
2507
2556
  }
2508
2557
  a.vSegments.push(i), a.vLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2509
2558
  }
@@ -2542,47 +2591,47 @@ function ln(e, t) {
2542
2591
  }), e === r && l.push({
2543
2592
  border: s,
2544
2593
  side: "bottom"
2545
- }), i.push(cn(l));
2594
+ }), i.push(pn(l));
2546
2595
  }
2547
2596
  a.hSegments.push(i), a.hLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2548
2597
  }
2549
2598
  return a;
2550
2599
  }
2551
- function un(e, t) {
2600
+ function hn(e, t) {
2552
2601
  return e.collapsed ? e.vLines.reduce((e, t) => e + t, 0) : (t + 1) * e.spacingX;
2553
2602
  }
2554
- function dn(e, t, n) {
2603
+ function gn(e, t, n) {
2555
2604
  if (!e.collapsed) return e.spacingX * (n - t - 1);
2556
2605
  let r = 0;
2557
2606
  for (let i = t + 1; i < n; i++) r += e.vLines[i];
2558
2607
  return r;
2559
2608
  }
2560
- function fn(e, t, n) {
2609
+ function _n(e, t, n) {
2561
2610
  if (!e.collapsed) return e.spacingY * (n - t - 1);
2562
2611
  let r = 0;
2563
2612
  for (let i = t + 1; i < n; i++) r += e.hLines[i];
2564
2613
  return r;
2565
2614
  }
2566
- function pn(e, t) {
2615
+ function vn(e, t) {
2567
2616
  let n = t.tableData.get(e);
2568
2617
  if (n) return n;
2569
- let r = $t(e, t), i = ln(e, r), a = {
2618
+ let r = an(e, t), i = mn(e, r), a = {
2570
2619
  structure: r,
2571
2620
  chrome: i,
2572
- bounds: rn(r, i, t),
2573
- chromeX: un(i, r.columnCount)
2621
+ bounds: ln(r, i, t),
2622
+ chromeX: hn(i, r.columnCount)
2574
2623
  };
2575
2624
  return t.tableData.set(e, a), a;
2576
2625
  }
2577
- function mn(e, t) {
2578
- let { structure: n, bounds: r, chromeX: i } = pn(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;
2579
2628
  return n.caption && (a = Math.max(a, Y(n.caption, t)), o = Math.max(o, J(n.caption, t))), {
2580
2629
  min: a,
2581
2630
  max: o
2582
2631
  };
2583
2632
  }
2584
- function hn(e, t, n) {
2585
- let r = e.style, { bounds: i, chromeX: a } = pn(e, n), { min: o, max: s } = mn(e, n), c = r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t), 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;
2586
2635
  for (let e = 0; e < i.max.length; e++) {
2587
2636
  let t = i.percent[e];
2588
2637
  t === void 0 ? d += i.max[e] : u += t;
@@ -2598,8 +2647,8 @@ function hn(e, t, n) {
2598
2647
  let f = Math.max(l + a, s) + c;
2599
2648
  return Math.max(o + c, Math.min(f, t));
2600
2649
  }
2601
- function gn(e, t, n, r, i, a) {
2602
- let { structure: o, chrome: s, bounds: c } = pn(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;
2603
2652
  for (let e of o.hidden) e.tableHidden = !0, e.localRect = {
2604
2653
  x: 0,
2605
2654
  y: 0,
@@ -2611,16 +2660,16 @@ function gn(e, t, n, r, i, a) {
2611
2660
  bottom: 0,
2612
2661
  left: 0
2613
2662
  }, e.unclampedHeight = 0;
2614
- let p = Math.max(0, t - un(s, l)), m = e.style, h = m.tableLayout === "fixed" && m.width !== void 0 && m.width.kind !== "auto" ? on(o, p, a) : an(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;
2615
2664
  for (let e = 0; e < l; e++) _ += s.collapsed ? s.vLines[e] : s.spacingX, g.push(_), _ += h[e];
2616
2665
  let v = _ + (s.collapsed ? s.vLines[l] ?? 0 : s.spacingX), y = 0;
2617
2666
  o.caption && (V(o.caption, t, void 0, d, f, "fill", a), y = o.caption.localRect.height);
2618
2667
  let b = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
2619
2668
  for (let e of o.cells) {
2620
- let t = e.col + e.colSpan, n = h.slice(e.col, t).reduce((e, t) => e + t, 0) + dn(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);
2621
2670
  x.set(e, n), V(e.node, n, void 0, 0, 0, "fill", a, { width: n }), b.set(e, e.node.localRect.height);
2622
2671
  }
2623
- 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 ? xe(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);
2624
2673
  for (let e = 0; e < u; e++) {
2625
2674
  let t = o.rows[e].style.height;
2626
2675
  t !== void 0 && t.kind === "cells" && (E[e] = t.value);
@@ -2633,7 +2682,7 @@ function gn(e, t, n, r, i, a) {
2633
2682
  }
2634
2683
  let O = o.cells.filter((e) => e.rowSpan > 1).sort((e, t) => e.rowSpan - t.rowSpan);
2635
2684
  for (let e of O) {
2636
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + fn(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;
2637
2686
  if (r <= 0) continue;
2638
2687
  let i = R(Array.from({ length: e.rowSpan }, () => 1), r);
2639
2688
  for (let n = e.row; n < t; n++) E[n] += i[n - e.row];
@@ -2684,11 +2733,11 @@ function gn(e, t, n, r, i, a) {
2684
2733
  }, t.unclampedHeight = E[e];
2685
2734
  }
2686
2735
  for (let e of o.cells) {
2687
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + fn(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);
2688
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, {
2689
2738
  width: x.get(e),
2690
2739
  height: n
2691
- }), _n(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 = {
2692
2741
  x: g[e.col],
2693
2742
  y: 0,
2694
2743
  width: e.node.localRect.width,
@@ -2700,9 +2749,9 @@ function gn(e, t, n, r, i, a) {
2700
2749
  x: d,
2701
2750
  y: f
2702
2751
  });
2703
- return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + M), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = vn(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;
2704
2753
  }
2705
- function _n(e, t) {
2754
+ function Sn(e, t) {
2706
2755
  if (t <= 0) return;
2707
2756
  let n = e.style.verticalAlign, r = n === "center" ? Math.floor(t / 2) : n === "end" ? t : 0;
2708
2757
  if (!e.children.some((e) => !B(e.style) && !e.inlineBox)) {
@@ -2711,14 +2760,14 @@ function _n(e, t) {
2711
2760
  }
2712
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);
2713
2762
  }
2714
- function vn(e, t, n, r, i, a, o, s, c) {
2763
+ function Cn(e, t, n, r, i, a, o, s, c) {
2715
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];
2716
2765
  for (let t = 0; t <= l; t++) {
2717
2766
  let n = e.vSegments[t];
2718
2767
  for (let e = 0; e < u; e++) {
2719
2768
  let i = n[e];
2720
2769
  if (!i) continue;
2721
- let l = fe(i.style, "v", c);
2770
+ let l = me(i.style, "v", c);
2722
2771
  for (let n = 0; n < i.width; n++) for (let c = a[e]; c < a[e] + r[e]; c++) d.push({
2723
2772
  glyph: l,
2724
2773
  x: o + f(t) + n,
@@ -2733,7 +2782,7 @@ function vn(e, t, n, r, i, a, o, s, c) {
2733
2782
  for (let e = 0; e < l; e++) {
2734
2783
  let a = r[e];
2735
2784
  if (!a) continue;
2736
- let l = fe(a.style, "h", c);
2785
+ let l = me(a.style, "h", c);
2737
2786
  for (let r = 0; r < a.width; r++) d.push({
2738
2787
  glyph: l,
2739
2788
  x: o + i[e],
@@ -2752,7 +2801,7 @@ function vn(e, t, n, r, i, a, o, s, c) {
2752
2801
  m
2753
2802
  ].filter((e) => e !== null);
2754
2803
  if (h.length === 0) continue;
2755
- let g = h.every((e) => e.style === "double") ? "double" : "solid", _ = h.reduce((e, t) => t.width > e.width || t.width === e.width && sn[t.style] > sn[e.style] ? t : e), v = pe(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);
2756
2805
  for (let r = 0; r < e.vLines[t]; r++) for (let i = 0; i < e.hLines[n]; i++) d.push({
2757
2806
  glyph: v,
2758
2807
  x: o + f(t) + r,
@@ -2765,30 +2814,30 @@ function vn(e, t, n, r, i, a, o, s, c) {
2765
2814
  }
2766
2815
  //#endregion
2767
2816
  //#region src/positioning.ts
2768
- function yn(e) {
2817
+ function wn(e) {
2769
2818
  return e.position === "absolute" || e.position === "fixed" ? "absolute" : e.position === "relative" || e.position === "sticky" ? "relative" : "static";
2770
2819
  }
2771
- function bn(e, t, n, r, i) {
2820
+ function Tn(e, t, n, r, i) {
2772
2821
  for (let a of e.children) {
2773
- let o = yn(a.style);
2822
+ let o = wn(a.style);
2774
2823
  if (o === "relative") {
2775
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;
2776
- a.localRect.x += xn(a.style.insets.left, a.style.insets.right, t), a.localRect.y += xn(a.style.insets.top, a.style.insets.bottom, n);
2777
- } else o === "absolute" && Cn(a, e, t, n, r, i);
2778
- bn(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, {
2779
2828
  node: a,
2780
2829
  absX: t + a.localRect.x,
2781
2830
  absY: n + a.localRect.y
2782
2831
  }], i);
2783
2832
  }
2784
2833
  }
2785
- function xn(e, t, n) {
2834
+ function En(e, t, n) {
2786
2835
  return e === null ? t === null ? 0 : -W(t, n) : W(e, n);
2787
2836
  }
2788
- function Sn(e, t) {
2837
+ function Dn(e, t) {
2789
2838
  if (!t) for (let t = e.length - 1; t > 0; t--) {
2790
2839
  let n = e[t];
2791
- if (!jn(n.node.style)) continue;
2840
+ if (!In(n.node.style)) continue;
2792
2841
  let r = n.node.style.border;
2793
2842
  return {
2794
2843
  x: n.absX + r.left,
@@ -2805,13 +2854,13 @@ function Sn(e, t) {
2805
2854
  height: n.node.localRect.height
2806
2855
  };
2807
2856
  }
2808
- function Cn(e, t, n, r, i, a) {
2809
- let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && jn(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) ? {
2810
2859
  x: n + c.area.x,
2811
2860
  y: r + c.area.y,
2812
2861
  width: c.area.width,
2813
2862
  height: c.area.height
2814
- } : Sn(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 = Bn(o.minWidth, l.width, e, a) ?? 0, S = Bn(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 = {};
2815
2864
  if (!y) C.width = H(q(o.width, l.width, e, a), x, S);
2816
2865
  else if (u !== null && d !== null) C.width = H(Math.max(0, l.width - u - d - h - g), x, S);
2817
2866
  else {
@@ -2823,25 +2872,25 @@ function Cn(e, t, n, r, i, a) {
2823
2872
  if (u !== null && d !== null) {
2824
2873
  let e = Math.max(0, l.width - u - d - w - h - g), t = m.left === null && m.right === null;
2825
2874
  E = l.x + u + h + (t ? Math.floor(e / 2) : m.left === null ? e : 0);
2826
- } else E = u === null ? d === null ? On(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;
2827
2876
  let D;
2828
2877
  if (f !== null && p !== null) {
2829
2878
  let e = Math.max(0, l.height - f - p - T - _ - v), t = m.top === null && m.bottom === null;
2830
2879
  D = l.y + f + _ + (t ? Math.floor(e / 2) : m.top === null ? e : 0);
2831
- } else D = f === null ? p === null ? kn(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 + _;
2832
2881
  e.localRect = {
2833
2882
  ...e.localRect,
2834
2883
  x: E - n,
2835
2884
  y: D - r
2836
2885
  };
2837
2886
  }
2838
- function wn(e, t, n) {
2887
+ function kn(e, t, n) {
2839
2888
  return L(e, [n], Math.max(0, t - n))[0];
2840
2889
  }
2841
- function Tn(e, t, n, r) {
2842
- return qe(Ke(e, t), n, r);
2890
+ function An(e, t, n, r) {
2891
+ return z(Ye(e, t), n, r);
2843
2892
  }
2844
- function En(e, t, n, r, i) {
2893
+ function jn(e, t, n, r, i) {
2845
2894
  let a = G(e.style.margin, n.innerWidth), [o, s, c, l] = r === "x" ? [
2846
2895
  a.left ?? 0,
2847
2896
  a.right ?? 0,
@@ -2853,9 +2902,9 @@ function En(e, t, n, r, i) {
2853
2902
  n.innerHeight,
2854
2903
  n.direction === "column"
2855
2904
  ], u = i + o + s;
2856
- return (l ? wn(Ze(t.style), c, u) : Tn(e, t, c, u)) + o;
2905
+ return (l ? kn($e(t.style), c, u) : An(e, t, c, u)) + o;
2857
2906
  }
2858
- function Dn(e, t, n, r, i) {
2907
+ function Mn(e, t, n, r, i) {
2859
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" ? [
2860
2909
  a.left ?? 0,
2861
2910
  a.right ?? 0,
@@ -2865,35 +2914,37 @@ function Dn(e, t, n, r, i) {
2865
2914
  a.top ?? 0,
2866
2915
  a.bottom ?? 0,
2867
2916
  n.height,
2868
- Ke(e, t)
2917
+ Ye(e, t)
2869
2918
  ];
2870
- return qe(u, l, i + s + c) + s;
2919
+ return z(u, l, i + s + c) + s;
2871
2920
  }
2872
- function On(e, t, n, r) {
2921
+ function Nn(e, t, n, r) {
2873
2922
  let i = e.staticSlot;
2874
- return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + Dn(e, t, i.staticArea, "x", r) : n + i.originX + En(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);
2875
2924
  }
2876
- function kn(e, t, n, r) {
2925
+ function Pn(e, t, n, r) {
2877
2926
  let i = e.staticSlot;
2878
- return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + Dn(e, t, i.staticArea, "y", r) : n + i.originY + En(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);
2879
2928
  }
2880
2929
  //#endregion
2881
2930
  //#region src/layout.ts
2882
- function An(e, t) {
2883
- let n = Mn();
2884
- return V(e, t, void 0, 0, 0, "fill", n), bn(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, [{
2885
2934
  node: e,
2886
2935
  absX: 0,
2887
2936
  absY: 0
2888
- }], n), { height: e.localRect.height };
2937
+ }], n);
2938
+ let r = e.localRect.height, i = Xn(e);
2939
+ return e.localRect.width = Math.max(e.localRect.width, i.x), e.localRect.height = Math.max(r, i.y), { height: r };
2889
2940
  }
2890
2941
  function B(e) {
2891
2942
  return e.position === "absolute" || e.position === "fixed";
2892
2943
  }
2893
- function jn(e) {
2944
+ function In(e) {
2894
2945
  return e.position !== "static";
2895
2946
  }
2896
- function Mn() {
2947
+ function Ln() {
2897
2948
  return {
2898
2949
  maxContent: /* @__PURE__ */ new WeakMap(),
2899
2950
  minContent: /* @__PURE__ */ new WeakMap(),
@@ -2903,54 +2954,86 @@ function Mn() {
2903
2954
  }
2904
2955
  function V(e, t, n, r, i, a, o, s) {
2905
2956
  let c = e.style, l = s?.height;
2906
- delete e.decorationRuns, delete e.multicolGeometry, delete e.multicolFlow, delete e.multicolFlowSpan;
2907
- let u = Bn(c.minWidth, t, e, o) ?? 0, d = Bn(c.maxWidth, t, e, o), f = K(c.minHeight, n) ?? 0, p = K(c.maxHeight, n), m = {
2957
+ delete e.decorationRuns, delete e.multicolGeometry, delete e.multicolFlow, delete e.multicolFlowSpan, delete e.textExtent;
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);
2959
+ s?.gutter?.right && (m.right = c.scrollbarSize.y), s?.gutter?.bottom && (m.bottom = c.scrollbarSize.x);
2960
+ let h = {
2908
2961
  top: W(c.padding.top, t),
2909
- right: W(c.padding.right, t),
2910
- bottom: W(c.padding.bottom, t),
2962
+ right: W(c.padding.right, t) + m.right,
2963
+ bottom: W(c.padding.bottom, t) + m.bottom,
2911
2964
  left: W(c.padding.left, t)
2912
2965
  };
2913
- e.resolvedPadding = m;
2914
- let h = s?.width ?? H(Wn(c, t, a, e, o), u, d), g = Kn(c, n), _ = Yn(h, l ?? g ?? (f > 0 ? f : void 0) ?? Infinity, c.border, m), v = l !== void 0 || g !== void 0, y = v && Number.isFinite(_.height) ? _.height : void 0, b = p === void 0 ? void 0 : Math.max(0, p - c.border.top - c.border.bottom - m.top - m.bottom), x;
2915
- x = Pn(e) ? Nn(e, _.width, _.height, y, b, m, o) : c.display === "flex" && c.flexDirection === "row" ? Be(e, _.width, _.height, y, c.border, m, o) : c.display === "flex" && c.flexDirection === "column" ? He(e, _.width, _.height, v, c.border, m, o) : c.display === "grid" ? tt(e, _.width, _.height, c.border, m, o) : c.display === "table" ? gn(e, _.width, y, c.border, m, o) : c.display === "multicol" ? Jt(e, _.width, y, b, c.border, m, o) : Vn(e, _.width, y, c.border, m, o);
2916
- let S = x + c.border.top + c.border.bottom + m.top + m.bottom, C = l ?? g ?? S;
2917
- e.unclampedHeight = C, e.naturalContentHeight = S;
2918
- let w = H(C, f, p), T = e.multicolGeometry;
2919
- if (T) {
2920
- let t = w - c.border.top - c.border.bottom - m.top - m.bottom;
2921
- t > T.totalRows && (m.bottom += t - T.totalRows), Gt(e, T, c.border, m);
2922
- }
2923
- e.localRect = {
2966
+ e.resolvedPadding = h;
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) => {
2968
+ let r = n && Number.isFinite(t) ? t : void 0;
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);
2970
+ }, C = S(v.height, y);
2971
+ !x && (c.display === "flex" || c.display === "grid") && !y && b !== void 0 && C > b && (C = S(b, !0));
2972
+ let w = C + c.border.top + c.border.bottom + h.top + h.bottom, T = l ?? _ ?? w;
2973
+ e.unclampedHeight = T, e.naturalContentHeight = w;
2974
+ let E = H(T, f, p), D = e.multicolGeometry;
2975
+ if (D) {
2976
+ let t = E - c.border.top - c.border.bottom - h.top - h.bottom;
2977
+ t > D.totalRows && (h.bottom += t - D.totalRows), Xt(e, D, c.border, h);
2978
+ }
2979
+ if (e.localRect = {
2924
2980
  x: r,
2925
2981
  y: i,
2926
- width: h,
2927
- height: w
2928
- };
2982
+ width: g,
2983
+ height: E
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);
2986
+ if (e.scrollRange = {
2987
+ sizeX: u,
2988
+ sizeY: d,
2989
+ maxX: tt(c.overflow.x) ? Math.max(0, u - f) : 0,
2990
+ maxY: tt(c.overflow.y) ? Math.max(0, d - p) : 0
2991
+ }, !s?.gutter && c.scrollbarWidth !== "none") {
2992
+ let l = c.overflow.y === "auto" && e.scrollRange.maxY > 0, u = c.overflow.x === "auto" && e.scrollRange.maxX > 0;
2993
+ if (l || u) {
2994
+ V(e, t, n, r, i, a, o, {
2995
+ ...s,
2996
+ gutter: {
2997
+ right: l,
2998
+ bottom: u
2999
+ }
3000
+ });
3001
+ return;
3002
+ }
3003
+ }
3004
+ e.scrollGutterCells = {
3005
+ right: m.right,
3006
+ bottom: m.bottom
3007
+ };
3008
+ } else delete e.scrollRange, delete e.scrollGutterCells;
2929
3009
  }
2930
- function Nn(e, t, n, r, i, a, o) {
3010
+ function Rn(e, t, n, r, i, a, o) {
2931
3011
  let s = e.style, c;
2932
3012
  if (e.text) {
2933
3013
  let l = e.children.filter((e) => e.inlineBox);
2934
- Me(e.text, (n, r) => {
3014
+ Fe(e.text, (n, r) => {
2935
3015
  let i = l[r];
2936
3016
  V(i, t, void 0, 0, 0, "shrink", o), e.advances[n] = Math.max(1, i.localRect.width);
2937
3017
  });
2938
3018
  let u, d;
2939
3019
  if (s.display === "multicol") {
2940
- let n = U(s, "x", t), o = Lt(s, t, n);
3020
+ let n = U(s, "x", t), o = Ht(s, t, n);
2941
3021
  a.right += o.leftover;
2942
- let c = zt(e, o, n, Ft(r, i));
3022
+ let c = Wt(e, o, n, Bt(r, i));
2943
3023
  e.multicolGeometry = c, u = c, d = c.lineX;
2944
- } else u = In(e, t);
2945
- if (c = u.totalRows, Fn(e, u, t, n, a), l.length > 0) {
3024
+ } else u = Vn(e, t);
3025
+ if (c = u.totalRows, e.textExtent = {
3026
+ width: u.spans.reduce((t, n) => Math.max(t, I(n.start, n.end, e.advances, s.tracking)), 0),
3027
+ rows: u.totalRows
3028
+ }, Bn(e, u, t, n, a), l.length > 0) {
2946
3029
  let t = (e) => u.spans.findIndex((t) => e >= t.start && e < t.end);
2947
- Me(e.text, (n, r) => {
3030
+ Fe(e.text, (n, r) => {
2948
3031
  let i = t(n);
2949
3032
  if (i === -1) return;
2950
3033
  let o = u.spans[i];
2951
3034
  l[r].localRect = {
2952
3035
  ...l[r].localRect,
2953
- x: s.border.left + a.left + (d?.[i] ?? 0) + ke(o.start, n, e.advances),
3036
+ x: s.border.left + a.left + (d?.[i] ?? 0) + Me(o.start, n, e.advances),
2954
3037
  y: s.border.top + a.top + u.lineY[i]
2955
3038
  };
2956
3039
  });
@@ -2967,30 +3050,30 @@ function Nn(e, t, n, r, i, a, o) {
2967
3050
  }
2968
3051
  return c;
2969
3052
  }
2970
- function Pn(e) {
3053
+ function zn(e) {
2971
3054
  return e.children.some((e) => !B(e.style) && !e.inlineBox) ? !1 : e.text !== "" || e.style.display !== "flex" && e.style.display !== "grid";
2972
3055
  }
2973
3056
  function H(e, t, n) {
2974
3057
  return Math.max(t, n === void 0 ? e : Math.min(e, n));
2975
3058
  }
2976
- function Fn(e, t, n, r, i) {
3059
+ function Bn(e, t, n, r, i) {
2977
3060
  let a = e.style;
2978
3061
  if (a.display !== "flex" && a.display !== "grid" || t.spans.length === 0) return;
2979
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);
2980
3063
  if (c > 0) {
2981
- let e = a.display === "grid" ? qe(a.justifyItems, n, s) : o ? qe(a.alignItems, n, s) : L(Ze(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];
2982
3065
  e > 0 && (i.left += e, i.right += c - e);
2983
3066
  }
2984
3067
  if (Number.isFinite(r)) {
2985
3068
  let e = Math.max(0, r - t.totalRows);
2986
3069
  if (e > 0) {
2987
- let n = a.display === "grid" || !o ? qe(a.alignItems, r, t.totalRows) : L(Ze(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];
2988
3071
  n > 0 && (i.top += n, i.bottom += e - n);
2989
3072
  }
2990
3073
  }
2991
3074
  }
2992
- function In(e, t) {
2993
- let n = Ln(e, t), { heights: r, textOffsets: i } = Rn(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;
2994
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);
2995
3078
  return {
2996
3079
  spans: n,
@@ -2999,21 +3082,21 @@ function In(e, t) {
2999
3082
  totalRows: s
3000
3083
  };
3001
3084
  }
3002
- function Ln(e, t) {
3003
- return e.style.whiteSpace === "normal" ? Oe(e.text, t, {
3085
+ function Hn(e, t) {
3086
+ return e.style.whiteSpace === "normal" ? je(e.text, t, {
3004
3087
  advances: e.advances,
3005
3088
  tracking: e.style.tracking,
3006
3089
  firstLineIndent: e.style.textIndent
3007
- }) : De(e.text);
3090
+ }) : Ae(e.text);
3008
3091
  }
3009
- function Rn(e, t) {
3092
+ function Un(e, t) {
3010
3093
  let n = e.children.filter((e) => e.inlineBox), r = [], i = [], a = 0;
3011
3094
  for (let o of t) {
3012
3095
  let t = 1, s = 0;
3013
3096
  for (let r = o.start; r < o.end; r++) {
3014
3097
  if (e.text[r] !== "") continue;
3015
3098
  let i = n[a];
3016
- t = Math.max(t, i.localRect.height), i.style.verticalAlign === "end" ? s = Math.max(s, i.localRect.height - 1) : i.style.verticalAlign === "center" && M(i.source, "vertical-align: middle on an inline box can't land on whole rows and behaves as top. Use align-top or align-bottom."), a++;
3099
+ t = Math.max(t, i.localRect.height), i.style.verticalAlign === "end" ? s = Math.max(s, i.localRect.height - 1) : i.style.verticalAlign === "center" && N(i.source, "vertical-align: middle on an inline box can't land on whole rows and behaves as top. Use align-top or align-bottom."), a++;
3017
3100
  }
3018
3101
  r.push(t), i.push(Math.min(s, t - 1));
3019
3102
  }
@@ -3027,7 +3110,7 @@ function U(e, t, n) {
3027
3110
  return Math.max(r, i?.width ?? 0);
3028
3111
  }
3029
3112
  function W(e, t) {
3030
- return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : xe(e.percent, t);
3113
+ return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : we(e.percent, t);
3031
3114
  }
3032
3115
  function G(e, t) {
3033
3116
  let n = (e) => e === null ? null : W(e, t);
@@ -3038,16 +3121,16 @@ function G(e, t) {
3038
3121
  left: n(e.left)
3039
3122
  };
3040
3123
  }
3041
- function zn(e) {
3124
+ function Wn(e) {
3042
3125
  return typeof e == "number" ? e : 0;
3043
3126
  }
3044
3127
  function K(e, t) {
3045
- if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : xe(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);
3046
3129
  }
3047
- function Bn(e, t, n, r) {
3130
+ function Gn(e, t, n, r) {
3048
3131
  return e === "min-content" || e === "max-content" || e === "fit-content" ? q({ kind: e }, t, n, r) : K(e, t);
3049
3132
  }
3050
- function Vn(e, t, n, r, i, a) {
3133
+ function Kn(e, t, n, r, i, a) {
3051
3134
  let o = r.left + i.left, s = r.top + i.top, c = s, l = null;
3052
3135
  for (let r of e.children) {
3053
3136
  let e = G(r.style.margin, t), i = e.top ?? 0, s = e.bottom ?? 0, u = e.left ?? 0, d = e.right ?? 0;
@@ -3055,13 +3138,13 @@ function Vn(e, t, n, r, i, a) {
3055
3138
  r.staticSlot = {
3056
3139
  kind: "block",
3057
3140
  x: o + u,
3058
- y: c + (l === null ? i : Un(l, i))
3141
+ y: c + (l === null ? i : Jn(l, i))
3059
3142
  };
3060
3143
  continue;
3061
3144
  }
3062
3145
  V(r, Math.max(0, t - u - d), n, 0, 0, "fill", a);
3063
- let f = Hn(e, t, r.localRect.width);
3064
- c += l === null ? i : Un(l, i), r.localRect = {
3146
+ let f = qn(e, t, r.localRect.width);
3147
+ c += l === null ? i : Jn(l, i), r.localRect = {
3065
3148
  ...r.localRect,
3066
3149
  x: o + f,
3067
3150
  y: c
@@ -3069,37 +3152,65 @@ function Vn(e, t, n, r, i, a) {
3069
3152
  }
3070
3153
  return l !== null && (c += l), c - s;
3071
3154
  }
3072
- function Hn(e, t, n) {
3155
+ function qn(e, t, n) {
3073
3156
  let r = t - n;
3074
3157
  return e.left === null && e.right === null ? Math.floor(r / 2) : e.left === null ? r - (e.right ?? 0) : e.left;
3075
3158
  }
3076
- function Un(e, t) {
3159
+ function Jn(e, t) {
3077
3160
  return e >= 0 && t >= 0 ? Math.max(e, t) : e <= 0 && t <= 0 ? Math.min(e, t) : e + t;
3078
3161
  }
3079
- function Wn(e, t, n, r, i) {
3162
+ function Yn(e, t, n, r, i) {
3080
3163
  let a = e.width;
3081
3164
  if (e.display === "table") {
3082
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));
3083
3166
  if (a !== void 0 && a.kind !== "auto") {
3084
3167
  let e = q(a, t, r, i);
3085
- return Math.max(e, Gn(r, t, i));
3168
+ return Math.max(e, Qn(r, t, i));
3086
3169
  }
3087
- return hn(r, t, i);
3170
+ return bn(r, t, i);
3088
3171
  }
3089
3172
  return a !== void 0 && a.kind !== "auto" ? q(a, t, r, i) : n === "shrink" ? Math.min(t, J(r, i)) : t;
3090
3173
  }
3091
- function Gn(e, t, n) {
3174
+ function Xn(e) {
3175
+ let t = 0, n = 0;
3176
+ for (let r of e.children) {
3177
+ if (r.style.position === "fixed") continue;
3178
+ let e = Zn(r);
3179
+ t = Math.max(t, r.localRect.x + e.x), n = Math.max(n, r.localRect.y + e.y);
3180
+ }
3181
+ if (e.textExtent) {
3182
+ let { border: r } = e.style, i = e.resolvedPadding;
3183
+ t = Math.max(t, r.left + i.left + e.textExtent.width), n = Math.max(n, r.top + i.top + e.textExtent.rows);
3184
+ }
3185
+ return {
3186
+ x: t,
3187
+ y: n
3188
+ };
3189
+ }
3190
+ function Zn(e) {
3191
+ let { width: t, height: n } = e.localRect, r = e.style.overflow.x !== "visible", i = e.style.overflow.y !== "visible";
3192
+ if (r && i) return {
3193
+ x: t,
3194
+ y: n
3195
+ };
3196
+ let a = Xn(e);
3197
+ return {
3198
+ x: r ? t : Math.max(t, a.x),
3199
+ y: i ? n : Math.max(n, a.y)
3200
+ };
3201
+ }
3202
+ function Qn(e, t, n) {
3092
3203
  let r = e.style;
3093
- return mn(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t);
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;
3094
3205
  }
3095
- function Kn(e, t) {
3206
+ function $n(e, t) {
3096
3207
  if (e.height?.kind === "cells") return e.height.value;
3097
- if (e.height?.kind === "percent" && t != null) return xe(e.height.value, t);
3208
+ if (e.height?.kind === "percent" && t != null) return we(e.height.value, t);
3098
3209
  }
3099
3210
  function q(e, t, n, r) {
3100
3211
  switch (e.kind) {
3101
3212
  case "cells": return e.value;
3102
- case "percent": return xe(e.value, t);
3213
+ case "percent": return we(e.value, t);
3103
3214
  case "min-content": return Y(n, r);
3104
3215
  case "max-content": return J(n, r);
3105
3216
  case "fit-content": return Math.min(J(n, r), Math.max(Y(n, r), t));
@@ -3109,42 +3220,42 @@ function q(e, t, n, r) {
3109
3220
  function J(e, t) {
3110
3221
  let n = t.maxContent.get(e);
3111
3222
  if (n !== void 0) return n;
3112
- let r = e.style, i = qn(e, t) + r.border.left + r.border.right + zn(r.padding.left) + zn(r.padding.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;
3113
3224
  return t.maxContent.set(e, i), i;
3114
3225
  }
3115
- function qn(e, t) {
3226
+ function er(e, t) {
3116
3227
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
3117
- if (n.length === 0) return e.style.display === "multicol" ? Pt(e.style, e.intrinsicWidth) : e.intrinsicWidth;
3118
- if (e.style.display === "grid") return ut(e, t).max;
3119
- if (e.style.display === "table") return mn(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;
3120
3231
  if (e.style.display === "flex" && e.style.flexDirection === "row") {
3121
- let r = Math.max(zn(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);
3122
3233
  return n.reduce((e, n) => e + J(n, t), 0) + r;
3123
3234
  }
3124
3235
  let r = n.reduce((e, n) => Math.max(e, J(n, t)), 0);
3125
- return e.style.display === "multicol" ? Pt(e.style, r) : r;
3236
+ return e.style.display === "multicol" ? zt(e.style, r) : r;
3126
3237
  }
3127
3238
  function Y(e, t) {
3128
3239
  let n = t.minContent.get(e);
3129
3240
  if (n !== void 0) return n;
3130
- let r = e.style, i = Jn(e, t) + r.border.left + r.border.right + zn(r.padding.left) + zn(r.padding.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;
3131
3242
  return t.minContent.set(e, i), i;
3132
3243
  }
3133
- function Jn(e, t) {
3244
+ function tr(e, t) {
3134
3245
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
3135
- if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : je(e.text, {
3246
+ if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : Pe(e.text, {
3136
3247
  advances: e.advances,
3137
3248
  tracking: e.style.tracking
3138
3249
  });
3139
- if (e.style.display === "grid") return ut(e, t).min;
3140
- if (e.style.display === "table") return mn(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;
3141
3252
  if (e.style.display === "flex" && e.style.flexDirection === "row" && e.style.flexWrap === "nowrap") {
3142
- let r = Math.max(zn(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);
3143
3254
  return n.reduce((e, n) => e + Y(n, t), 0) + r;
3144
3255
  }
3145
3256
  return n.reduce((e, n) => Math.max(e, Y(n, t)), 0);
3146
3257
  }
3147
- function Yn(e, t, n, r) {
3258
+ function nr(e, t, n, r) {
3148
3259
  return {
3149
3260
  width: Math.max(0, e - n.left - n.right - r.left - r.right),
3150
3261
  height: Math.max(0, t - n.top - n.bottom - r.top - r.bottom)
@@ -3152,38 +3263,38 @@ function Yn(e, t, n, r) {
3152
3263
  }
3153
3264
  //#endregion
3154
3265
  //#region src/plain-text.ts
3155
- function Xn(e) {
3156
- return nr(e).grid.map((e) => e.join("").trimEnd()).join("\n");
3266
+ function rr(e) {
3267
+ return lr(e).grid.map((e) => e.join("").trimEnd()).join("\n");
3157
3268
  }
3158
- function Zn(e) {
3159
- let { grid: t, paints: n } = nr(e);
3160
- return t.map((e, t) => Qn(e, n[t]));
3269
+ function ir(e) {
3270
+ let { grid: t, paints: n } = lr(e);
3271
+ return t.map((e, t) => ar(e, n[t]));
3161
3272
  }
3162
- function Qn(e, t) {
3273
+ function ar(e, t) {
3163
3274
  let n = e.length;
3164
3275
  for (; n > 0 && e[n - 1] === " " && t[n - 1]?.backgroundColor === void 0;) n--;
3165
3276
  let r = [];
3166
3277
  for (let i = 0; i < n; i++) {
3167
3278
  let n = t[i], a = r[r.length - 1];
3168
- a && $n(a, n) ? a.text += e[i] : r.push({
3279
+ a && or(a, n) ? a.text += e[i] : r.push({
3169
3280
  text: e[i],
3170
3281
  ...n
3171
3282
  });
3172
3283
  }
3173
3284
  return r;
3174
3285
  }
3175
- function $n(e, t) {
3286
+ function or(e, t) {
3176
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;
3177
3288
  }
3178
- function er(e, t) {
3289
+ function sr(e, t) {
3179
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);
3180
3291
  }
3181
- function tr(e) {
3292
+ function cr(e) {
3182
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;
3183
3294
  }
3184
- function nr(e) {
3295
+ function lr(e) {
3185
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));
3186
- return ir(e, 0, 0, (e, a, o, s) => {
3297
+ return dr(e, 0, 0, (e, a, o, s) => {
3187
3298
  if (e >= 0 && e < t && a >= 0 && a < n) {
3188
3299
  r[a][e] = o;
3189
3300
  let t = i[a][e];
@@ -3197,22 +3308,22 @@ function nr(e) {
3197
3308
  paints: i
3198
3309
  };
3199
3310
  }
3200
- function rr(e) {
3311
+ function ur(e) {
3201
3312
  let t = {};
3202
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;
3203
3314
  }
3204
- function ir(e, t, n, r, i = 1) {
3315
+ function dr(e, t, n, r, i = 1) {
3205
3316
  if (e.tableHidden) return;
3206
3317
  let a = t + e.localRect.x, o = n + e.localRect.y, s = e.style, c = (e) => i >= 1 ? e : {
3207
3318
  ...e,
3208
3319
  opacity: String(Math.round(i * 1e3) / 1e3)
3209
3320
  };
3210
3321
  if (s.backgroundColor !== void 0 || s.backgroundClear) {
3211
- let t = s.backgroundColor === void 0 ? void 0 : c({ backgroundColor: s.backgroundColor });
3322
+ let t = s.backgroundColor === void 0 ? { backgroundColor: void 0 } : c({ backgroundColor: s.backgroundColor });
3212
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);
3213
3324
  }
3214
3325
  let l = [];
3215
- ce(s, {
3326
+ ue(s, {
3216
3327
  x: a,
3217
3328
  y: o,
3218
3329
  width: e.localRect.width,
@@ -3226,26 +3337,64 @@ function ir(e, t, n, r, i = 1) {
3226
3337
  let e = c(t.color === void 0 ? void 0 : { color: t.color });
3227
3338
  for (let n = 0; n < t.length; n++) r(a + t.x + n, o + t.y, t.glyph, e);
3228
3339
  }
3340
+ let u = e.resolvedPadding, d = e.scrollGutterCells, f = s.overflow.x !== "visible", p = s.overflow.y !== "visible", m = a - (e.scroll?.x ?? 0), h = o - (e.scroll?.y ?? 0), g = r;
3341
+ if (f || p) {
3342
+ let t = a + s.border.left, n = o + s.border.top, i = a + e.localRect.width - s.border.right - (d?.right ?? 0), c = o + e.localRect.height - s.border.bottom - (d?.bottom ?? 0);
3343
+ g = (e, a, o, s) => {
3344
+ f && (e < t || e >= i) || p && (a < n || a >= c) || r(e, a, o, s);
3345
+ };
3346
+ }
3229
3347
  if (!e.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed") && e.text) {
3230
- let t = e.resolvedPadding, n = a + s.border.left + t.left, i = o + s.border.top + t.top, l = e.localRect.width - s.border.left - s.border.right - t.left - t.right, u = e.multicolGeometry, { spans: d, textY: f } = u ?? In(e, l), p = u ? Math.max(1, u.columnWidth - s.tracking) : l, m = c(rr(s)), h = e.inlineElements?.map((e) => c(rr(e)));
3231
- for (let t = 0; t < d.length; t++) {
3232
- let a = d[t], o = i + f[t], l = t === 0 ? s.textIndent : 0, g = s.whiteSpace !== "normal" && s.overflow === "clip" ? ar(e.text, a, p - l, e.advances, s) : {
3233
- end: a.end,
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)));
3349
+ for (let r = 0; r < a.length; r++) {
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) : {
3351
+ end: u.end,
3234
3352
  ellipsis: !1
3235
- }, _ = I(a.start, a.end, e.advances, s.tracking), v = Math.max(0, p - l - _), y = s.textAlign === "end" ? v : s.textAlign === "center" ? Math.floor(v / 2) : 0, b = n + (u?.lineX[t] ?? 0) + y + l;
3236
- for (let t = a.start; t < g.end; t++) {
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;
3354
+ for (let t = u.start; t < h.end; t++) {
3237
3355
  if (e.text[t] !== "") {
3238
- let n = e.charInline?.[t] ?? -1, i = n >= 0 ? e.inlineElements[n] : void 0, a = i?.insets, s = a ? a.left ?? (a.right === null ? 0 : -a.right) : 0, l = a ? a.top ?? (a.bottom === null ? 0 : -a.bottom) : 0;
3239
- e.text[t] === "⁠" ? i?.backgroundColor && r(b + s, o + l, " ", c({ backgroundColor: i.backgroundColor })) : r(b + s, o + l, e.text[t], i ? h[n] : m);
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;
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);
3358
+ }
3359
+ b += Me(t, t + 1, e.advances);
3360
+ }
3361
+ h.ellipsis && g(b, p, "…", d);
3362
+ }
3363
+ }
3364
+ for (let t of pe(e)) dr(t, m, h, g, i * t.style.opacity);
3365
+ let _ = e.scrollRange;
3366
+ if (_ && d && (d.right > 0 || d.bottom > 0)) {
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);
3368
+ if (d.right > 0) {
3369
+ let a = u - i - d.bottom, { at: o, len: s } = fr(a, _.sizeY, _.maxY, e.scroll?.y ?? 0);
3370
+ for (let e = 0; e < d.right; e++) {
3371
+ let c = f - d.right + e;
3372
+ for (let e = 0; e < a; e++) {
3373
+ let a = e >= o && e < o + s;
3374
+ r(c, i + e, a ? n : t, a ? h : m);
3375
+ }
3376
+ }
3377
+ }
3378
+ if (d.bottom > 0) {
3379
+ let i = f - l - d.right, { at: a, len: o } = fr(i, _.sizeX, _.maxX, e.scroll?.x ?? 0);
3380
+ for (let e = 0; e < d.bottom; e++) {
3381
+ let s = u - d.bottom + e;
3382
+ for (let e = 0; e < i; e++) {
3383
+ let i = e >= a && e < a + o;
3384
+ r(l + e, s, i ? n : t, i ? h : m);
3240
3385
  }
3241
- b += ke(t, t + 1, e.advances);
3242
3386
  }
3243
- g.ellipsis && r(b, o, "…", m);
3244
3387
  }
3245
3388
  }
3246
- for (let t of de(e)) ir(t, a, o, r, i * t.style.opacity);
3247
3389
  }
3248
- function ar(e, t, n, r, i) {
3390
+ function fr(e, t, n, r) {
3391
+ let i = t > 0 ? Math.min(1, e / t) : 1, a = Math.max(1, Math.round(i * e));
3392
+ return n > 0 && (a = Math.max(1, Math.min(a, e - n))), {
3393
+ at: n > 0 ? Math.round(Math.min(r, n) / n * (e - a)) : 0,
3394
+ len: a
3395
+ };
3396
+ }
3397
+ function pr(e, t, n, r, i) {
3249
3398
  let { textOverflow: a, tracking: o } = i;
3250
3399
  if (I(t.start, t.end, r, o) <= n) return {
3251
3400
  end: t.end,
@@ -3260,61 +3409,61 @@ function ar(e, t, n, r, i) {
3260
3409
  }
3261
3410
  //#endregion
3262
3411
  //#region src/paint.ts
3263
- var or = /* @__PURE__ */ new WeakMap(), sr = /* @__PURE__ */ new WeakMap();
3264
- function cr(e) {
3265
- return dr(e, !0) !== null;
3266
- }
3267
- function lr(e, t, n = !1) {
3268
- let r = Zn(e), i = gr(r);
3269
- if (or.get(t) === i) return !0;
3270
- let a = sr.get(t);
3271
- if (a && ur(t, a.nodes, r)) {
3272
- or.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);
3273
3422
  for (let e = 0; e < r.length; e++) for (let t = 0; t < r[e].length; t++) {
3274
3423
  let n = r[e][t];
3275
- if (tr(n) || $n(n, a.segments[e][t])) continue;
3424
+ if (cr(n) || or(n, a.segments[e][t])) continue;
3276
3425
  let i = a.nodes[e][t];
3277
- i.style.cssText = "", er(n, i.style);
3426
+ i.style.cssText = "", sr(n, i.style);
3278
3427
  }
3279
3428
  return a.segments = r, !0;
3280
3429
  }
3281
- if (n && cr(t)) return !1;
3282
- or.set(t, i);
3430
+ if (n && gr(t)) return !1;
3431
+ mr.set(t, i);
3283
3432
  let o = document.createDocumentFragment(), s = [];
3284
3433
  for (let e = 0; e < r.length; e++) {
3285
3434
  e > 0 && o.appendChild(document.createTextNode("\n"));
3286
3435
  let t = [];
3287
3436
  for (let n of r[e]) {
3288
- if (tr(n)) {
3437
+ if (cr(n)) {
3289
3438
  let e = document.createTextNode(n.text);
3290
3439
  t.push(e), o.appendChild(e);
3291
3440
  continue;
3292
3441
  }
3293
3442
  let e = document.createElement("span");
3294
- er(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);
3295
3444
  }
3296
3445
  s.push(t);
3297
3446
  }
3298
- sr.set(t, {
3447
+ hr.set(t, {
3299
3448
  nodes: s,
3300
3449
  segments: r
3301
3450
  });
3302
- let c = dr(t, !1);
3303
- return t.replaceChildren(o), c && fr(t, c), !0;
3451
+ let c = yr(t, !1);
3452
+ return t.replaceChildren(o), c && br(t, c), !0;
3304
3453
  }
3305
- function ur(e, t, n) {
3454
+ function vr(e, t, n) {
3306
3455
  if (t.length !== n.length) return !1;
3307
3456
  for (let r = 0; r < n.length; r++) {
3308
3457
  let i = t[r], a = n[r];
3309
3458
  if (i.length !== a.length) return !1;
3310
3459
  for (let t = 0; t < a.length; t++) {
3311
3460
  let n = i[t];
3312
- if (tr(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;
3313
3462
  }
3314
3463
  }
3315
3464
  return !0;
3316
3465
  }
3317
- function dr(e, t) {
3466
+ function yr(e, t) {
3318
3467
  try {
3319
3468
  let n = e.ownerDocument.getSelection();
3320
3469
  if (!n) return null;
@@ -3330,7 +3479,7 @@ function dr(e, t) {
3330
3479
  if (!e || e.rangeCount === 0) return null;
3331
3480
  i = e.getRangeAt(0);
3332
3481
  }
3333
- let a = pr(e, i.startContainer, i.startOffset), o = pr(e, i.endContainer, i.endOffset);
3482
+ let a = xr(e, i.startContainer, i.startOffset), o = xr(e, i.endContainer, i.endOffset);
3334
3483
  return a === null || o === null || a === o && !t ? null : {
3335
3484
  start: a,
3336
3485
  end: o,
@@ -3340,32 +3489,32 @@ function dr(e, t) {
3340
3489
  return null;
3341
3490
  }
3342
3491
  }
3343
- function fr(e, t) {
3492
+ function br(e, t) {
3344
3493
  try {
3345
- let n = mr(e, t.start), r = mr(e, t.end);
3494
+ let n = Sr(e, t.start), r = Sr(e, t.end);
3346
3495
  if (!n || !r) return;
3347
3496
  let i = e.getRootNode().getSelection?.() ?? e.ownerDocument.getSelection();
3348
3497
  t.backward ? i?.setBaseAndExtent(r[0], r[1], n[0], n[1]) : i?.setBaseAndExtent(n[0], n[1], r[0], r[1]);
3349
3498
  } catch {}
3350
3499
  }
3351
- function pr(e, t, n) {
3500
+ function xr(e, t, n) {
3352
3501
  if (!e.contains(t)) return null;
3353
3502
  let r = e.ownerDocument.createRange();
3354
3503
  return r.selectNodeContents(e), r.setEnd(t, n), r.toString().length;
3355
3504
  }
3356
- function mr(e, t) {
3505
+ function Sr(e, t) {
3357
3506
  let n = t, r = null;
3358
- for (let t of hr(e)) {
3507
+ for (let t of Cr(e)) {
3359
3508
  if (n <= t.data.length) return [t, n];
3360
3509
  n -= t.data.length, r = [t, t.data.length];
3361
3510
  }
3362
3511
  return r;
3363
3512
  }
3364
- function* hr(e) {
3513
+ function* Cr(e) {
3365
3514
  let t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), n = t.nextNode();
3366
3515
  for (; n;) yield n, n = t.nextNode();
3367
3516
  }
3368
- function gr(e) {
3517
+ function wr(e) {
3369
3518
  let t = [];
3370
3519
  for (let n of e) {
3371
3520
  for (let e of n) t.push(e.text, e.color ?? "", e.backgroundColor ?? "", e.fontWeight ?? "", e.fontStyle ?? "", e.textDecorationLine ?? "", e.opacity ?? "");
@@ -3375,9 +3524,9 @@ function gr(e) {
3375
3524
  }
3376
3525
  //#endregion
3377
3526
  //#region src/render.ts
3378
- function _r(e) {
3527
+ function Tr(e) {
3379
3528
  let t = /* @__PURE__ */ new Set();
3380
- vr(e, !0, t);
3529
+ Er(e, !0, t);
3381
3530
  for (let n of Array.from(e.source.querySelectorAll("[data-mw-inline-inset]"))) if (!t.has(n)) {
3382
3531
  n.removeAttribute("data-mw-inline-inset");
3383
3532
  let e = n.style;
@@ -3398,60 +3547,64 @@ function Z(e, t) {
3398
3547
  function Q(e, t, n) {
3399
3548
  e.hasAttribute(t) !== n && (n ? e.setAttribute(t, "") : e.removeAttribute(t));
3400
3549
  }
3401
- function vr(e, t, n) {
3550
+ function Er(e, t, n) {
3402
3551
  if (e.inlineElements) for (let { element: t, tracking: r, padLeft: i, padRight: a, insets: o } of e.inlineElements) {
3403
3552
  let e = t;
3404
- 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), yr(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));
3405
3554
  }
3406
- if (t || xr(e), !e.tableHidden) for (let t of de(e)) {
3555
+ if (t || kr(e), !e.tableHidden) for (let t of pe(e)) {
3407
3556
  let r = t.source;
3408
- t.style.zIndex !== null && ue(t, e) && !t.inlineBox ? X(r, "--mw-z", String(t.style.zIndex)) : Z(r, "--mw-z"), vr(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);
3409
3558
  }
3410
3559
  }
3411
- function yr(e, t) {
3560
+ function Dr(e, t) {
3412
3561
  Q(e, "data-mw-inline-inset", !0);
3413
3562
  let n = (t, n) => {
3414
3563
  n === null ? Z(e, t) : X(e, t, String(n));
3415
3564
  };
3416
3565
  n("--mw-it", t.top), n("--mw-ir", t.right), n("--mw-ib", t.bottom), n("--mw-il", t.left);
3417
3566
  }
3418
- function br(e) {
3567
+ function Or(e) {
3419
3568
  let t = e.style;
3420
3569
  if (t.textAlign !== "center" || !e.text || e.inlineBox || e.children.length > 0) return !1;
3421
- 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 ?? Ln(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);
3422
3571
  return o.length !== 0 && o.every((n, r) => {
3423
3572
  let i = r === 0 ? t.textIndent : 0, o = a - i - I(n.start, n.end, e.advances, t.tracking);
3424
3573
  return o > 0 && o % 2 == 1;
3425
3574
  });
3426
3575
  }
3427
- function xr(e) {
3576
+ function kr(e) {
3428
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;
3429
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);
3430
3579
  let f = u ?? d;
3431
3580
  f ? (X(t, "--mw-mt", String(f.top ?? 0)), X(t, "--mw-mr", String(f.right ?? 0)), X(t, "--mw-mb", String(f.bottom ?? 0)), X(t, "--mw-ml", String(f.left ?? 0))) : (Z(t, "--mw-mt"), Z(t, "--mw-mr"), Z(t, "--mw-mb"), Z(t, "--mw-ml")), Q(t, "data-mw-vbottom", !!e.inlineBox && e.style.verticalAlign === "end"), X(t, "--mw-ls", String(c)), X(t, "--mw-lh", String(l + 1)), X(t, "--mw-lhs", String(-l / 2)), Q(t, "data-mw-nowrap", s !== "normal");
3432
3581
  let p = u || d ? void 0 : e.multicolGeometry;
3433
- Q(t, "data-mw-multicol", !!p), Q(t, "data-mw-multicol-balance", !!p?.nativeBalance), p ? (X(t, "--mw-colc", String(p.columnCount)), X(t, "--mw-colg", String(p.gap))) : (Z(t, "--mw-colc"), Z(t, "--mw-colg")), Q(t, "data-mw-pre", s === "pre"), X(t, "--mw-x", String(n.x)), X(t, "--mw-y", String(n.y)), X(t, "--mw-w", String(n.width)), X(t, "--mw-h", String(n.height)), Q(t, "data-mw-clip", o === "clip"), 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", br(e)), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
3582
+ if (Q(t, "data-mw-multicol", !!p), Q(t, "data-mw-multicol-balance", !!p?.nativeBalance), p ? (X(t, "--mw-colc", String(p.columnCount)), X(t, "--mw-colg", String(p.gap))) : (Z(t, "--mw-colc"), Z(t, "--mw-colg")), Q(t, "data-mw-pre", s === "pre"), X(t, "--mw-x", String(n.x)), X(t, "--mw-y", String(n.y)), X(t, "--mw-w", String(n.width)), X(t, "--mw-h", String(n.height)), Q(t, "data-mw-clip", o.x === "clip" || o.y === "clip"), Q(t, "data-mw-scroll", e.scrollRange !== void 0), e.scrollRange) {
3583
+ let { maxX: n, maxY: r } = e.scrollRange;
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));
3585
+ } else Z(t, "--mw-se-x"), Z(t, "--mw-se-y");
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);
3434
3587
  }
3435
3588
  //#endregion
3436
3589
  //#region src/style.ts
3437
- function Sr(e, t, n) {
3438
- let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = Ir(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
3439
- jr(e, o, s);
3440
- let c = r.display || Or[e.tagName] || "", l = kr[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" || Dr(r) ? "none" : u !== null || f !== null ? "multicol" : "block", m = { kind: "none" }, h = { kind: "none" }, g = [et()], _ = [et()], 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 = {
3441
3594
  direction: "row",
3442
3595
  dense: !1
3443
3596
  }, y = null;
3444
3597
  if (p === "grid") {
3445
- if (a) m = ni(a.get("grid-template-columns")?.toString() ?? "", t), h = ni(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);
3446
3599
  else {
3447
3600
  e.setAttribute("data-mw-degrid", "");
3448
3601
  try {
3449
- m = ni(r.getPropertyValue("grid-template-columns"), t), h = ni(r.getPropertyValue("grid-template-rows"), t);
3602
+ m = vi(r.getPropertyValue("grid-template-columns"), t), h = vi(r.getPropertyValue("grid-template-rows"), t);
3450
3603
  } finally {
3451
3604
  e.removeAttribute("data-mw-degrid");
3452
3605
  }
3453
3606
  }
3454
- g = oi(r.getPropertyValue("grid-auto-columns"), t), _ = oi(r.getPropertyValue("grid-auto-rows"), t), v = fi(r.getPropertyValue("grid-auto-flow")), y = ai(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"));
3455
3608
  }
3456
3609
  let b = "auto", x = !1, S = 0, C = 0;
3457
3610
  if (p === "table" && (b = r.tableLayout === "fixed" ? "fixed" : "auto", x = r.borderCollapse === "collapse", !x)) {
@@ -3466,61 +3619,71 @@ function Sr(e, t, n) {
3466
3619
  borderSpacingX: S,
3467
3620
  borderSpacingY: C,
3468
3621
  captionSide: r.captionSide === "bottom" ? "bottom" : "top",
3469
- verticalAlign: l === "cell" || c.startsWith("inline-") ? Ar(e, r) : "start",
3622
+ verticalAlign: l === "cell" || c.startsWith("inline-") ? Kr(e, r) : "start",
3470
3623
  flexDirection: r.flexDirection.startsWith("column") ? "column" : "row",
3471
3624
  flexReverse: r.flexDirection.endsWith("-reverse"),
3472
3625
  flexWrap: r.flexWrap.startsWith("wrap") ? "wrap" : "nowrap",
3473
3626
  wrapReverse: r.flexWrap === "wrap-reverse",
3474
3627
  flexGrow: Number(r.flexGrow) || 0,
3475
3628
  flexShrink: r.flexShrink === "" ? 1 : Number(r.flexShrink) || 0,
3476
- flexBasis: ei(r.flexBasis, t),
3629
+ flexBasis: gi(r.flexBasis, t),
3477
3630
  order: Number(r.order) || 0,
3478
- justifyContent: Lr(r.justifyContent),
3479
- alignContent: Lr(r.alignContent),
3480
- alignItems: Rr(r.alignItems),
3481
- alignSelf: zr(r.alignSelf),
3482
- justifyItems: Rr(r.justifyItems),
3483
- justifySelf: zr(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),
3484
3637
  gridTemplateColumns: m,
3485
3638
  gridTemplateRows: h,
3486
3639
  gridAutoColumns: g,
3487
3640
  gridAutoRows: _,
3488
3641
  gridAutoFlow: v,
3489
3642
  gridTemplateAreas: y,
3490
- gridColumnStart: di(r.getPropertyValue("grid-column-start")),
3491
- gridColumnEnd: di(r.getPropertyValue("grid-column-end")),
3492
- gridRowStart: di(r.getPropertyValue("grid-row-start")),
3493
- gridRowEnd: di(r.getPropertyValue("grid-row-end")),
3494
- width: Yr(a, r.width, "width", t, o, s, n),
3495
- height: Yr(a, r.height, "height", t, o, s, n),
3496
- minWidth: $r(a, "min-width", r.minWidth, o, "min-w", s, n, t) ?? Kr(r.minWidth, t) ?? "auto",
3497
- minHeight: $r(a, "min-height", r.minHeight, o, "min-h", s, n, t) ?? Kr(r.minHeight, t) ?? "auto",
3498
- maxWidth: $r(a, "max-width", r.maxWidth, o, "max-w", s, n, t) ?? Kr(r.maxWidth, t),
3499
- maxHeight: $r(a, "max-height", r.maxHeight, o, "max-h", s, n, t) ?? Kr(r.maxHeight, t),
3500
- padding: mi(r, t),
3501
- margin: Br(r, a, o, s, t),
3502
- position: Ur(r.position),
3503
- insets: Wr(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),
3504
3657
  gapX: $(r.columnGap === "normal" || r.columnGap === "" ? p === "multicol" ? `${i}px` : "0px" : r.columnGap, t),
3505
3658
  gapY: $(r.rowGap === "normal" ? "0px" : r.rowGap, t),
3506
- border: hi(r),
3659
+ border: ji(r),
3507
3660
  borderStyle: {
3508
- top: Gr(r.borderTopStyle),
3509
- right: Gr(r.borderRightStyle),
3510
- bottom: Gr(r.borderBottomStyle),
3511
- left: Gr(r.borderLeftStyle)
3661
+ top: si(r.borderTopStyle),
3662
+ right: si(r.borderRightStyle),
3663
+ bottom: si(r.borderBottomStyle),
3664
+ left: si(r.borderLeftStyle)
3665
+ },
3666
+ overflow: Hr(r),
3667
+ scrollbarWidth: Rr(e, r),
3668
+ scrollbarColor: zr(r.scrollbarColor),
3669
+ overscroll: {
3670
+ x: (r.overscrollBehaviorX || "auto") === "auto",
3671
+ y: (r.overscrollBehaviorY || "auto") === "auto"
3672
+ },
3673
+ scrollbarSize: {
3674
+ x: Br(r.getPropertyValue("--mw-scrollbar-x-size")),
3675
+ y: Br(r.getPropertyValue("--mw-scrollbar-y-size"))
3512
3676
  },
3513
- overflow: Er(r.overflow) || Er(r.overflowX) || Er(r.overflowY) ? "clip" : "visible",
3514
3677
  whiteSpace: r.whiteSpace === "pre" ? "pre" : r.whiteSpace === "nowrap" ? "nowrap" : "normal",
3515
3678
  tabSize: Math.max(1, Math.floor(parseFloat(r.tabSize)) || 8),
3516
- lineGap: Hr(r.lineHeight, i),
3517
- tracking: Vr(r.letterSpacing, i, n?.letterSpacing ?? 0),
3679
+ lineGap: ii(r.lineHeight, i),
3680
+ tracking: ri(r.letterSpacing, i, n?.letterSpacing ?? 0),
3518
3681
  textOverflow: r.textOverflow === "ellipsis" ? "ellipsis" : "clip",
3519
3682
  color: r.color,
3520
3683
  fontWeight: r.fontWeight,
3521
3684
  fontStyle: r.fontStyle,
3522
3685
  textDecorationLine: r.textDecorationLine,
3523
- backgroundColor: Tr(e, r.backgroundColor, r),
3686
+ backgroundColor: Nr(e, r.backgroundColor, r),
3524
3687
  backgroundClear: r.getPropertyValue("--mw-bg-clear").trim() === "1",
3525
3688
  borderColor: {
3526
3689
  top: r.borderTopColor,
@@ -3528,18 +3691,18 @@ function Sr(e, t, n) {
3528
3691
  bottom: r.borderBottomColor,
3529
3692
  left: r.borderLeftColor
3530
3693
  },
3531
- textAlignBlocked: Pr(e, r),
3532
- textAlign: Fr(e, r),
3533
- textIndent: Jr(r, t),
3534
- opacity: qr(r.opacity),
3694
+ textAlignBlocked: Xr(e, r),
3695
+ textAlign: Zr(e, r),
3696
+ textIndent: ui(r, t),
3697
+ opacity: li(r.opacity),
3535
3698
  glyphSet: r.getPropertyValue("--mw-border-glyphs").trim() || null,
3536
3699
  zIndex: r.zIndex === "auto" || r.zIndex === "" ? null : Number(r.zIndex) || 0,
3537
3700
  latticeBorder: null,
3538
- ruleX: p === "flex" || p === "grid" || p === "multicol" ? Nr(r, "x") : null,
3539
- ruleY: p === "flex" || p === "grid" ? Nr(r, "y") : null,
3540
- ruleBreak: Mr(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"),
3541
3704
  ruleInset: r.getPropertyValue("--mw-rule-inset").trim() === "overlap-join" ? "overlap-join" : Math.max(0, P(parseFloat(r.getPropertyValue("--mw-rule-inset")) || 0)),
3542
- ruleVisibilityItems: Mr(r, "--mw-rule-visibility-items", [
3705
+ ruleVisibilityItems: Jr(r, "--mw-rule-visibility-items", [
3543
3706
  "all",
3544
3707
  "around",
3545
3708
  "between"
@@ -3552,9 +3715,9 @@ function Sr(e, t, n) {
3552
3715
  breakAfterColumn: r.breakAfter === "column",
3553
3716
  breakInsideAvoid: r.breakInside === "avoid" || r.breakInside === "avoid-column"
3554
3717
  };
3555
- return Cr(w, r), w;
3718
+ return jr(w, r), w;
3556
3719
  }
3557
- function Cr(e, t) {
3720
+ function jr(e, t) {
3558
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 = {
3559
3722
  width: e.border,
3560
3723
  style: e.borderStyle,
@@ -3565,26 +3728,70 @@ function Cr(e, t) {
3565
3728
  bottom: t.borderBottomStyle === "hidden",
3566
3729
  left: t.borderLeftStyle === "hidden"
3567
3730
  }
3568
- }, e.border = z(), e.display === "table" && (e.padding = z()));
3731
+ }, e.border = it(), e.display === "table" && (e.padding = it()));
3569
3732
  }
3570
- function wr(e) {
3733
+ function Mr(e) {
3571
3734
  if (!e) return !0;
3572
3735
  let t = e.trim().toLowerCase();
3573
3736
  return t === "" || t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "currentcolor";
3574
3737
  }
3575
- function Tr(e, t, n) {
3576
- let i = r(e, wr(t) ? "" : t, n);
3738
+ function Nr(e, t, n) {
3739
+ let i = r(e, Mr(t) ? "" : t, n);
3577
3740
  return i === "" ? void 0 : i;
3578
3741
  }
3579
- function Er(e) {
3742
+ function Pr(e) {
3580
3743
  return e === "hidden" || e === "clip";
3581
3744
  }
3582
- function Dr(e) {
3583
- if (e.position !== "absolute" && e.position !== "fixed") return !1;
3584
- let t = e.clip.replace(/\s/g, "");
3585
- return t === "rect(0px,0px,0px,0px)" || t === "rect(0,0,0,0)" || (Er(e.overflow) || Er(e.overflowX)) && parseFloat(e.width) <= 1 && parseFloat(e.height) <= 1;
3745
+ var Fr = /* @__PURE__ */ new WeakMap(), Ir = null;
3746
+ function Lr(e) {
3747
+ if (Ir !== null) return Ir;
3748
+ if (!e.body) return !0;
3749
+ let t = e.createElement("div");
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;
3586
3751
  }
3587
- var Or = {
3752
+ function Rr(e, t) {
3753
+ if (!Lr(e.ownerDocument)) return "auto";
3754
+ if (e.hasAttribute("data-mw-scroll")) {
3755
+ let t = Fr.get(e);
3756
+ if (t !== void 0) return t;
3757
+ }
3758
+ let n = t.scrollbarWidth === "none" ? "none" : "auto";
3759
+ return Fr.set(e, n), n;
3760
+ }
3761
+ function zr(e) {
3762
+ let t = (e ?? "").trim();
3763
+ if (!t || t === "auto") return null;
3764
+ let n = 0;
3765
+ for (let e = 0; e < t.length; e++) {
3766
+ let r = t[e];
3767
+ if (r === "(") n++;
3768
+ else if (r === ")") n--;
3769
+ else if (r === " " && n === 0) return {
3770
+ thumb: t.slice(0, e),
3771
+ track: t.slice(e + 1).trim()
3772
+ };
3773
+ }
3774
+ return null;
3775
+ }
3776
+ function Br(e) {
3777
+ return Math.max(1, Math.floor(Number(e) || 1));
3778
+ }
3779
+ function Vr(e) {
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);
3784
+ return t !== "visible" && n === "visible" && (n = "auto"), n !== "visible" && t === "visible" && (t = "auto"), {
3785
+ x: t,
3786
+ y: n
3787
+ };
3788
+ }
3789
+ function Ur(e, t) {
3790
+ if (t.position !== "absolute" && t.position !== "fixed") return !1;
3791
+ let n = t.clip.replace(/\s/g, "");
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;
3793
+ }
3794
+ var Wr = {
3588
3795
  TABLE: "table",
3589
3796
  THEAD: "table-header-group",
3590
3797
  TBODY: "table-row-group",
@@ -3595,7 +3802,7 @@ var Or = {
3595
3802
  CAPTION: "table-caption",
3596
3803
  COL: "table-column",
3597
3804
  COLGROUP: "table-column-group"
3598
- }, kr = {
3805
+ }, Gr = {
3599
3806
  "table-header-group": "header-group",
3600
3807
  "table-row-group": "row-group",
3601
3808
  "table-footer-group": "footer-group",
@@ -3605,38 +3812,38 @@ var Or = {
3605
3812
  "table-column": "column",
3606
3813
  "table-column-group": "column-group"
3607
3814
  };
3608
- function Ar(e, t) {
3815
+ function Kr(e, t) {
3609
3816
  let n = t.verticalAlign || e.getAttribute("valign")?.toLowerCase() || (e.tagName === "TD" || e.tagName === "TH" ? "middle" : "baseline");
3610
3817
  return n === "top" ? "start" : n === "middle" ? "center" : n === "bottom" ? "end" : "start";
3611
3818
  }
3612
- function jr(e, t, n) {
3613
- (/(?:^|[\s:.[!])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w-])/.test(t) || /(?:^|[\s:.[!])text-\[(?:(?:length|size):|[\d.])/.test(t) || n.fontSize !== "") && M(e, "font-size inside <mono-wind> is ignored — all text shares the host's cell size. Size the <mono-wind> element itself instead.");
3819
+ function qr(e, t, n) {
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.");
3614
3821
  }
3615
- function Mr(e, t, n, r) {
3822
+ function Jr(e, t, n, r) {
3616
3823
  let i = e.getPropertyValue(t).trim();
3617
3824
  return n.includes(i) ? i : r;
3618
3825
  }
3619
- function Nr(e, t) {
3826
+ function Yr(e, t) {
3620
3827
  let n = P(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
3621
3828
  if (n <= 0) return null;
3622
3829
  let r = e.getPropertyValue(`--mw-rule-${t}-color`).trim();
3623
3830
  return {
3624
3831
  width: n,
3625
- style: Gr(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3832
+ style: si(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3626
3833
  color: r && r !== "currentcolor" && r !== "currentColor" ? r : e.color
3627
3834
  };
3628
3835
  }
3629
- function Pr(e, t) {
3836
+ function Xr(e, t) {
3630
3837
  return t.textAlign === "justify" || e.getAttribute("align")?.toLowerCase() === "justify";
3631
3838
  }
3632
- function Fr(e, t) {
3839
+ function Zr(e, t) {
3633
3840
  let n = t.textAlign || e.getAttribute("align")?.toLowerCase() || "";
3634
3841
  return n === "right" || n === "end" ? "end" : n === "center" || n.endsWith("-center") ? "center" : "start";
3635
3842
  }
3636
- function Ir(e) {
3843
+ function Qr(e) {
3637
3844
  return typeof e.computedStyleMap == "function";
3638
3845
  }
3639
- function Lr(e) {
3846
+ function $r(e) {
3640
3847
  switch (e) {
3641
3848
  case "center": return "center";
3642
3849
  case "flex-end":
@@ -3651,7 +3858,7 @@ function Lr(e) {
3651
3858
  default: return "start";
3652
3859
  }
3653
3860
  }
3654
- function Rr(e) {
3861
+ function ei(e) {
3655
3862
  switch (e) {
3656
3863
  case "center": return "center";
3657
3864
  case "flex-end":
@@ -3662,10 +3869,10 @@ function Rr(e) {
3662
3869
  default: return "start";
3663
3870
  }
3664
3871
  }
3665
- function zr(e) {
3666
- return e === "auto" || e === "" || e === "normal" ? "auto" : Rr(e);
3872
+ function ti(e) {
3873
+ return e === "auto" || e === "" || e === "normal" ? "auto" : ei(e);
3667
3874
  }
3668
- function Br(e, t, n, r, i) {
3875
+ function ni(e, t, n, r, i) {
3669
3876
  let a = (a, o, s) => {
3670
3877
  if (t) {
3671
3878
  let e = t.get(a)?.toString().trim();
@@ -3689,16 +3896,16 @@ function Br(e, t, n, r, i) {
3689
3896
  left: a("margin-left", "margin-inline-start", /(?:^|[\s:.[!])(?:m|mx|ml|ms)-auto\b/)
3690
3897
  };
3691
3898
  }
3692
- function Vr(e, t, n) {
3899
+ function ri(e, t, n) {
3693
3900
  let r = (e === "normal" ? 0 : parseFloat(e) || 0) - n;
3694
3901
  return r <= 0 ? 0 : Math.floor(r / (.025 * t) + 1e-6);
3695
3902
  }
3696
- function Hr(e, t) {
3903
+ function ii(e, t) {
3697
3904
  if (!e || e === "normal" || t <= 0) return 0;
3698
3905
  let n = parseFloat(e);
3699
3906
  return Number.isFinite(n) ? Math.max(0, Math.floor(n / t + 1e-6) - 1) : 0;
3700
3907
  }
3701
- function Ur(e) {
3908
+ function ai(e) {
3702
3909
  switch (e) {
3703
3910
  case "relative":
3704
3911
  case "absolute":
@@ -3707,7 +3914,7 @@ function Ur(e) {
3707
3914
  default: return "static";
3708
3915
  }
3709
3916
  }
3710
- function Wr(e, t, n, r, i) {
3917
+ function oi(e, t, n, r, i) {
3711
3918
  let a = (a, o) => {
3712
3919
  if (t) {
3713
3920
  let e = t.get(a)?.toString().trim();
@@ -3726,7 +3933,7 @@ function Wr(e, t, n, r, i) {
3726
3933
  left: a("left", /(?:^|[\s:.[!])-?(?:left|start|inset|inset-x)-/)
3727
3934
  };
3728
3935
  }
3729
- function Gr(e) {
3936
+ function si(e) {
3730
3937
  switch (e) {
3731
3938
  case "double": return "double";
3732
3939
  case "dashed": return "dashed";
@@ -3734,7 +3941,7 @@ function Gr(e) {
3734
3941
  default: return "solid";
3735
3942
  }
3736
3943
  }
3737
- function Kr(e, t) {
3944
+ function ci(e, t) {
3738
3945
  if (!e || e === "none" || e === "auto") return;
3739
3946
  if (e === "min-content" || e === "max-content" || e === "fit-content") return e;
3740
3947
  if (e.endsWith("%")) {
@@ -3753,28 +3960,28 @@ function $(e, t) {
3753
3960
  let n = parseFloat(e);
3754
3961
  return Number.isFinite(n) ? F(n, t) : 0;
3755
3962
  }
3756
- function qr(e) {
3963
+ function li(e) {
3757
3964
  let t = parseFloat(e);
3758
3965
  return Number.isFinite(t) ? Math.min(1, Math.max(0, t)) : 1;
3759
3966
  }
3760
- function Jr(e, t) {
3967
+ function ui(e, t) {
3761
3968
  let n = e.textIndent;
3762
3969
  if (!n || n.endsWith("%")) return 0;
3763
3970
  let r = parseFloat(n);
3764
3971
  return Number.isFinite(r) ? Math.max(0, F(r, t)) : 0;
3765
3972
  }
3766
- function Yr(e, t, n, r, i, a, o) {
3767
- let s = Xr(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);
3768
3975
  if (s !== null) return {
3769
3976
  kind: "cells",
3770
- value: Qr(s, n, o, r)
3977
+ value: mi(s, n, o, r)
3771
3978
  };
3772
- let c = Zr(i, n === "width" ? "w" : "h");
3979
+ let c = pi(i, n === "width" ? "w" : "h");
3773
3980
  if (c !== null) {
3774
3981
  let i = parseFloat(e ? String(e.get(n) ?? "") : t), a = Number.isFinite(i) && Math.abs(i - c) <= c * .3;
3775
3982
  if (a || !Number.isFinite(i)) return {
3776
3983
  kind: "cells",
3777
- value: Qr(a ? i : c, n, o, r)
3984
+ value: mi(a ? i : c, n, o, r)
3778
3985
  };
3779
3986
  }
3780
3987
  if (e) {
@@ -3782,7 +3989,7 @@ function Yr(e, t, n, r, i, a, o) {
3782
3989
  if (t == null) return;
3783
3990
  let i = t.toString().trim();
3784
3991
  if (i === "auto") return { kind: "auto" };
3785
- let a = ti(i);
3992
+ let a = _i(i);
3786
3993
  if (a) return a;
3787
3994
  if (i.endsWith("%")) return {
3788
3995
  kind: "percent",
@@ -3796,16 +4003,16 @@ function Yr(e, t, n, r, i, a, o) {
3796
4003
  kind: "cells",
3797
4004
  value: P(parseFloat(i) / .25)
3798
4005
  };
3799
- let s = Xr(i);
4006
+ let s = fi(i);
3800
4007
  if (s !== null) return {
3801
4008
  kind: "cells",
3802
- value: Qr(s, n, o, r)
4009
+ value: mi(s, n, o, r)
3803
4010
  };
3804
4011
  }
3805
4012
  let l = n === "width" ? a.width : a.height;
3806
4013
  if (l) {
3807
4014
  if (l === "auto") return { kind: "auto" };
3808
- let e = ti(l);
4015
+ let e = _i(l);
3809
4016
  if (e) return e;
3810
4017
  if (l.endsWith("%")) return {
3811
4018
  kind: "percent",
@@ -3840,7 +4047,7 @@ function Yr(e, t, n, r, i, a, o) {
3840
4047
  kind: "cells",
3841
4048
  value: P(Number(p[1]))
3842
4049
  };
3843
- if (!pi(i, u) || t === "auto") return { kind: "auto" };
4050
+ if (!ki(i, u) || t === "auto") return { kind: "auto" };
3844
4051
  if (t.endsWith("%")) return {
3845
4052
  kind: "percent",
3846
4053
  value: parseFloat(t)
@@ -3851,7 +4058,7 @@ function Yr(e, t, n, r, i, a, o) {
3851
4058
  value: F(m, r)
3852
4059
  };
3853
4060
  }
3854
- function Xr(e) {
4061
+ function fi(e) {
3855
4062
  let t = /^(-?[\d.]+)((?:[dsl]?v)(?:h|w|min|max)|vi|vb)$/.exec(e.trim());
3856
4063
  if (!t || typeof window > "u") return null;
3857
4064
  let n = parseFloat(t[1]);
@@ -3859,7 +4066,7 @@ function Xr(e) {
3859
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;
3860
4067
  return n / 100 * o;
3861
4068
  }
3862
- function Zr(e, t) {
4069
+ function pi(e, t) {
3863
4070
  if (typeof window > "u") return null;
3864
4071
  let n = RegExp(`(?:^|[\\s:.[!])${t}-(screen|[dsl]v[hw])(?![\\w-])`).exec(e);
3865
4072
  if (n) {
@@ -3867,23 +4074,23 @@ function Zr(e, t) {
3867
4074
  return e === "screen" ? t.includes("h") ? window.innerHeight : window.innerWidth : e.endsWith("h") ? window.innerHeight : window.innerWidth;
3868
4075
  }
3869
4076
  let r = RegExp(`(?:^|[\\s:.[!])${t}-\\[(-?[\\d.]+(?:[dsl]?v(?:h|w|min|max)|vi|vb))\\]`).exec(e);
3870
- return r ? Xr(r[1]) : null;
4077
+ return r ? fi(r[1]) : null;
3871
4078
  }
3872
- function Qr(e, t, n, r) {
4079
+ function mi(e, t, n, r) {
3873
4080
  let i = t === "width" ? n?.width : n?.height;
3874
4081
  return i && i > 0 ? Math.max(0, Math.floor(e / i)) : F(e, r);
3875
4082
  }
3876
- function $r(e, t, n, r, i, a, o, s) {
3877
- let c = t.endsWith("width") ? "width" : "height", l = Xr(a.getPropertyValue(t)) ?? Xr(e?.get(t)?.toString().trim() ?? "");
3878
- if (l !== null) return Qr(l, c, o, s);
3879
- let u = Zr(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);
3880
4087
  if (u === null) return;
3881
4088
  let d = parseFloat(e ? String(e.get(t) ?? "") : n), f = Number.isFinite(d) && Math.abs(d - u) <= u * .3;
3882
- if (!(!f && Number.isFinite(d))) return Qr(f ? d : u, c, o, s);
4089
+ if (!(!f && Number.isFinite(d))) return mi(f ? d : u, c, o, s);
3883
4090
  }
3884
- function ei(e, t) {
4091
+ function gi(e, t) {
3885
4092
  if (!e || e === "auto" || e === "content") return;
3886
- let n = ti(e);
4093
+ let n = _i(e);
3887
4094
  if (n) return n;
3888
4095
  if (e.endsWith("%")) {
3889
4096
  let t = parseFloat(e);
@@ -3898,27 +4105,27 @@ function ei(e, t) {
3898
4105
  value: F(r, t)
3899
4106
  } : void 0;
3900
4107
  }
3901
- function ti(e) {
4108
+ function _i(e) {
3902
4109
  if (e === "min-content") return { kind: "min-content" };
3903
4110
  if (e === "max-content") return { kind: "max-content" };
3904
4111
  if (e === "fit-content") return { kind: "fit-content" };
3905
4112
  }
3906
- function ni(e, t) {
4113
+ function vi(e, t) {
3907
4114
  let n = e.trim();
3908
4115
  if (!n || n === "none") return { kind: "none" };
3909
4116
  if (n === "subgrid" || n.startsWith("subgrid ")) return { kind: "subgrid" };
3910
4117
  let r = [], i = [], a = [], o = (e) => {
3911
4118
  i.push(a), a = [], r.push(e);
3912
4119
  }, s;
3913
- for (let e of ui(n)) {
3914
- let n = ii(e);
4120
+ for (let e of Ei(n)) {
4121
+ let n = bi(e);
3915
4122
  if (n) {
3916
4123
  a.push(...n);
3917
4124
  continue;
3918
4125
  }
3919
4126
  let i = e.match(/^repeat\(\s*([^,]+?)\s*,(.*)\)$/s);
3920
4127
  if (i) {
3921
- let e = ri(i[2].trim(), t);
4128
+ let e = yi(i[2].trim(), t);
3922
4129
  if (e.tracks.length === 0) continue;
3923
4130
  let n = i[1];
3924
4131
  if (n === "auto-fill" || n === "auto-fit") {
@@ -3936,7 +4143,7 @@ function ni(e, t) {
3936
4143
  }
3937
4144
  continue;
3938
4145
  }
3939
- o(si(e, t));
4146
+ o(Ci(e, t));
3940
4147
  }
3941
4148
  if (i.push(a), r.length === 0 && !s) return { kind: "none" };
3942
4149
  let c = {
@@ -3945,26 +4152,26 @@ function ni(e, t) {
3945
4152
  };
3946
4153
  return i.some((e) => e.length > 0) && (c.lineNames = i), s && (c.autoRepeat = s), c;
3947
4154
  }
3948
- function ri(e, t) {
4155
+ function yi(e, t) {
3949
4156
  let n = [], r = [], i = [];
3950
- for (let a of ui(e)) {
3951
- let e = ii(a);
4157
+ for (let a of Ei(e)) {
4158
+ let e = bi(a);
3952
4159
  if (e) {
3953
4160
  i.push(...e);
3954
4161
  continue;
3955
4162
  }
3956
- r.push(i), i = [], n.push(si(a, t));
4163
+ r.push(i), i = [], n.push(Ci(a, t));
3957
4164
  }
3958
4165
  return r.push(i), {
3959
4166
  tracks: n,
3960
4167
  lineNames: r
3961
4168
  };
3962
4169
  }
3963
- function ii(e) {
4170
+ function bi(e) {
3964
4171
  let t = e.match(/^\[(.*)\]$/s);
3965
4172
  return t ? t[1].split(/\s+/).filter((e) => e !== "") : null;
3966
4173
  }
3967
- function ai(e) {
4174
+ function xi(e) {
3968
4175
  let t = [];
3969
4176
  for (let n of e.matchAll(/"([^"]*)"|'([^']*)'/g)) {
3970
4177
  let e = (n[1] ?? n[2] ?? "").trim().split(/\s+/).filter((e) => e !== "");
@@ -3994,23 +4201,23 @@ function ai(e) {
3994
4201
  areas: r
3995
4202
  };
3996
4203
  }
3997
- function oi(e, t) {
3998
- let n = ui(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => si(e, t));
3999
- return n.length > 0 ? n : [et()];
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()];
4000
4207
  }
4001
- function si(e, t) {
4208
+ function Ci(e, t) {
4002
4209
  let n = e.match(/^minmax\((.*)\)$/s);
4003
4210
  if (n) {
4004
- let e = li(n[1]).map((e) => e.trim());
4211
+ let e = Ti(n[1]).map((e) => e.trim());
4005
4212
  return e.length === 2 ? {
4006
- min: ci(e[0], t),
4007
- max: ci(e[1], t)
4213
+ min: wi(e[0], t),
4214
+ max: wi(e[1], t)
4008
4215
  } : {
4009
4216
  min: { kind: "auto" },
4010
4217
  max: { kind: "auto" }
4011
4218
  };
4012
4219
  }
4013
- let r = ci(e, t);
4220
+ let r = wi(e, t);
4014
4221
  return r.kind === "fr" ? {
4015
4222
  min: { kind: "auto" },
4016
4223
  max: r
@@ -4019,13 +4226,13 @@ function si(e, t) {
4019
4226
  max: r
4020
4227
  };
4021
4228
  }
4022
- function ci(e, t) {
4229
+ function wi(e, t) {
4023
4230
  if (e === "auto" || e.startsWith("fit-content")) return { kind: "auto" };
4024
4231
  if (e === "min-content") return { kind: "min-content" };
4025
4232
  if (e === "max-content") return { kind: "max-content" };
4026
4233
  let n = e.match(/^(min|max)\((.*)\)$/s);
4027
4234
  if (n) {
4028
- let e = li(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");
4029
4236
  return e.length > 0 && r ? {
4030
4237
  kind: "math",
4031
4238
  fn: n[1],
@@ -4052,7 +4259,7 @@ function ci(e, t) {
4052
4259
  value: e.endsWith("rem") ? P(r / .25) : F(r, t)
4053
4260
  } : { kind: "auto" };
4054
4261
  }
4055
- function li(e) {
4262
+ function Ti(e) {
4056
4263
  let t = [], n = 0, r = 0;
4057
4264
  for (let i = 0; i < e.length; i++) {
4058
4265
  let a = e[i];
@@ -4060,7 +4267,7 @@ function li(e) {
4060
4267
  }
4061
4268
  return t.push(e.slice(r)), t.filter((e) => e.trim() !== "");
4062
4269
  }
4063
- function ui(e) {
4270
+ function Ei(e) {
4064
4271
  let t = [], n = 0, r = -1;
4065
4272
  for (let i = 0; i < e.length; i++) {
4066
4273
  let a = e[i];
@@ -4068,7 +4275,7 @@ function ui(e) {
4068
4275
  }
4069
4276
  return r !== -1 && t.push(e.slice(r)), t;
4070
4277
  }
4071
- function di(e) {
4278
+ function Di(e) {
4072
4279
  let t = e.trim();
4073
4280
  if (!t || t === "auto") return { kind: "auto" };
4074
4281
  let n = !1, r, i;
@@ -4096,16 +4303,16 @@ function di(e) {
4096
4303
  nth: r
4097
4304
  };
4098
4305
  }
4099
- function fi(e) {
4306
+ function Oi(e) {
4100
4307
  return {
4101
4308
  direction: e.includes("column") ? "column" : "row",
4102
4309
  dense: e.includes("dense")
4103
4310
  };
4104
4311
  }
4105
- function pi(e, t) {
4312
+ function ki(e, t) {
4106
4313
  return (t === "w" ? /(?:^|[\s:.[!])w-/ : /(?:^|[\s:.[!])h-/).test(e);
4107
4314
  }
4108
- function mi(e, t) {
4315
+ function Ai(e, t) {
4109
4316
  return {
4110
4317
  top: $(e.getPropertyValue("padding-top"), t),
4111
4318
  right: $(e.getPropertyValue("padding-right"), t),
@@ -4113,7 +4320,7 @@ function mi(e, t) {
4113
4320
  left: $(e.getPropertyValue("padding-left"), t)
4114
4321
  };
4115
4322
  }
4116
- function hi(e) {
4323
+ function ji(e) {
4117
4324
  let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : P(parseFloat(e.getPropertyValue(t)) || 0);
4118
4325
  return {
4119
4326
  top: t("border-top-width", "border-top-style"),
@@ -4124,14 +4331,14 @@ function hi(e) {
4124
4331
  }
4125
4332
  //#endregion
4126
4333
  //#region src/tree.ts
4127
- function gi(e, t, n, r) {
4128
- let i = Sr(e, t, n);
4334
+ function Mi(e, t, n, r) {
4335
+ let i = Ar(e, t, n);
4129
4336
  if (i.display === "none") return null;
4130
- let a = re(e.tagName);
4131
- if (a) return _i(e, i, a);
4132
- let o = Array.from(e.children), s = o.map(Si), c = e.tagName, l = Ni(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);
4133
4340
  if (!s.includes("block") || l) {
4134
- let a = Ci(e, i.tracking, {
4341
+ let a = zi(e, i.tracking, {
4135
4342
  rootFontSizePx: t,
4136
4343
  rootLetterSpacingPx: n?.letterSpacing ?? 0,
4137
4344
  cellMetrics: n,
@@ -4140,12 +4347,12 @@ function gi(e, t, n, r) {
4140
4347
  tabSize: i.tabSize
4141
4348
  }), u = a.chars.join("");
4142
4349
  if (a.boxes.length > 0) {
4143
- let e = Mn();
4144
- Me(a.chars, (t, n) => {
4350
+ let e = Ln();
4351
+ Fe(a.chars, (t, n) => {
4145
4352
  a.advances[t] = Math.max(1, J(a.boxes[n], e));
4146
4353
  });
4147
4354
  }
4148
- let d = Oi(u, a.advances, i.tracking);
4355
+ let d = Wi(u, a.advances, i.tracking);
4149
4356
  if (l && d === 0) {
4150
4357
  if (c === "INPUT") d = Number(e.size) || 20;
4151
4358
  else if (c === "TEXTAREA") d = Number(e.cols) || 20;
@@ -4154,9 +4361,9 @@ function gi(e, t, n, r) {
4154
4361
  d = Math.max(1, ...r.map((e) => e.trim().length));
4155
4362
  }
4156
4363
  }
4157
- let f = u.length > 0 ? ki(u) : 0, p;
4364
+ let f = u.length > 0 ? Gi(u) : 0, p;
4158
4365
  if (c === "TEXTAREA") {
4159
- let t = e, n = t.value ?? "", a = r?.get(t), o = +!!n.endsWith("\n"), s = a !== void 0 && a > 0 ? Te(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);
4160
4367
  p = l + Math.max(0, l - 1) * i.lineGap;
4161
4368
  } else p = l ? Math.max(1, f) : f;
4162
4369
  let m = /* @__PURE__ */ new Map(), h = [];
@@ -4166,7 +4373,7 @@ function gi(e, t, n, r) {
4166
4373
  let i = o[e], a = m.get(i);
4167
4374
  if (a) g.push(a);
4168
4375
  else if (s[e] === "out-of-flow") {
4169
- let e = gi(i, t, n, r);
4376
+ let e = Mi(i, t, n, r);
4170
4377
  e && g.push(e);
4171
4378
  }
4172
4379
  }
@@ -4185,14 +4392,14 @@ function gi(e, t, n, r) {
4185
4392
  height: p
4186
4393
  },
4187
4394
  unclampedHeight: 0,
4188
- resolvedPadding: z()
4395
+ resolvedPadding: it()
4189
4396
  };
4190
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)), _;
4191
4398
  }
4192
4399
  let u = [];
4193
4400
  for (let e = 0; e < o.length; e++) {
4194
4401
  if (s[e] === "none") continue;
4195
- let i = gi(o[e], t, n, r);
4402
+ let i = Mi(o[e], t, n, r);
4196
4403
  i && u.push(i);
4197
4404
  }
4198
4405
  let d = {
@@ -4209,14 +4416,14 @@ function gi(e, t, n, r) {
4209
4416
  height: 0
4210
4417
  },
4211
4418
  unclampedHeight: 0,
4212
- resolvedPadding: z()
4419
+ resolvedPadding: it()
4213
4420
  };
4214
- return Pi(e, d), d;
4421
+ return Xi(e, d), d;
4215
4422
  }
4216
- function _i(e, t, n) {
4217
- let r = oe(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");
4218
4425
  t.whiteSpace = "pre", (t.width === void 0 || t.width.kind === "auto") && (t.width = { kind: "max-content" });
4219
- let o = Array.from({ length: a.length }, () => 1 + t.tracking), s = Oi(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 = {
4220
4427
  source: e,
4221
4428
  style: t,
4222
4429
  children: [],
@@ -4230,7 +4437,7 @@ function _i(e, t, n) {
4230
4437
  height: c
4231
4438
  },
4232
4439
  unclampedHeight: 0,
4233
- resolvedPadding: z()
4440
+ resolvedPadding: it()
4234
4441
  };
4235
4442
  t.tracking > 0 && (l.advances = o);
4236
4443
  let u = r?.runs ?? [];
@@ -4258,23 +4465,23 @@ function _i(e, t, n) {
4258
4465
  }
4259
4466
  return l;
4260
4467
  }
4261
- var vi = /* @__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("."));
4262
- function yi(e, t) {
4263
- return t || (vi.has(e.tagName) ? "inline" : "block");
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("."));
4469
+ function Fi(e, t) {
4470
+ return t || (Pi.has(e.tagName) ? "inline" : "block");
4264
4471
  }
4265
- function bi(e, t) {
4266
- let n = yi(e, t);
4472
+ function Ii(e, t) {
4473
+ let n = Fi(e, t);
4267
4474
  return n === "inline" || n === "contents";
4268
4475
  }
4269
- function xi(e, t) {
4270
- let n = yi(e, t);
4476
+ function Li(e, t) {
4477
+ let n = Fi(e, t);
4271
4478
  return n.startsWith("inline") && n !== "inline";
4272
4479
  }
4273
- function Si(e) {
4480
+ function Ri(e) {
4274
4481
  let t = getComputedStyle(e);
4275
- return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : re(e.tagName) ? "block" : bi(e, t.display) || xi(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";
4276
4483
  }
4277
- function Ci(e, t, n) {
4484
+ function zi(e, t, n) {
4278
4485
  let r = {
4279
4486
  chars: [],
4280
4487
  advances: [],
@@ -4282,15 +4489,15 @@ function Ci(e, t, n) {
4282
4489
  inlineElements: [],
4283
4490
  boxes: []
4284
4491
  };
4285
- return wi(e, t, n, r), n.preserve ? r : Di(r);
4492
+ return Bi(e, t, n, r), n.preserve ? r : Ui(r);
4286
4493
  }
4287
- function wi(e, t, n, r) {
4494
+ function Bi(e, t, n, r) {
4288
4495
  let i = () => {
4289
4496
  let e = 0;
4290
4497
  for (let t = r.chars.length - 1; t >= 0 && r.chars[t] !== "\n"; t--) e += r.advances[t];
4291
4498
  return e;
4292
4499
  };
4293
- if (!Ni(e.tagName)) {
4500
+ if (!Yi(e.tagName)) {
4294
4501
  for (let a of Array.from(e.childNodes)) if (a.nodeType === Node.TEXT_NODE) {
4295
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);
4296
4503
  else if (e === " ") {
@@ -4306,24 +4513,24 @@ function wi(e, t, n, r) {
4306
4513
  }
4307
4514
  let t = getComputedStyle(e);
4308
4515
  if (t.display === "none" || t.position === "absolute" || t.position === "fixed") continue;
4309
- if (xi(e, t.display)) {
4310
- let t = gi(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4516
+ if (Li(e, t.display)) {
4517
+ let t = Mi(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4311
4518
  t && (t.inlineBox = !0, r.chars.push(""), r.advances.push(1), r.boxes.push(t));
4312
4519
  continue;
4313
4520
  }
4314
- if (!bi(e, t.display)) {
4315
- Ai(e);
4521
+ if (!Ii(e, t.display)) {
4522
+ Ki(e);
4316
4523
  continue;
4317
4524
  }
4318
- let i = Vr(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = Ti(t.paddingLeft, n.rootFontSizePx), s = Ti(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);
4319
4526
  r.inlineElements.push({
4320
4527
  element: e,
4321
4528
  tracking: i,
4322
4529
  padLeft: o,
4323
4530
  padRight: s,
4324
- insets: t.position === "static" ? null : Ei(t, n.rootFontSizePx),
4531
+ insets: t.position === "static" ? null : Hi(t, n.rootFontSizePx),
4325
4532
  color: t.color,
4326
- backgroundColor: wr(t.backgroundColor) ? void 0 : t.backgroundColor,
4533
+ backgroundColor: Mr(t.backgroundColor) ? void 0 : t.backgroundColor,
4327
4534
  fontWeight: t.fontWeight,
4328
4535
  fontStyle: t.fontStyle,
4329
4536
  textDecorationLine: t.textDecorationLine
@@ -4331,18 +4538,18 @@ function wi(e, t, n, r) {
4331
4538
  let c = r.inlineElements.length - 1;
4332
4539
  for (let e = 0; e < o; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
4333
4540
  let l = r.chars.length;
4334
- wi(e, i, n, r);
4541
+ Bi(e, i, n, r);
4335
4542
  for (let e = l; e < r.chars.length; e++) r.inlineIndex[e] === void 0 && (r.inlineIndex[e] = c);
4336
4543
  for (let e = 0; e < s; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
4337
4544
  }
4338
4545
  }
4339
4546
  }
4340
- function Ti(e, t) {
4547
+ function Vi(e, t) {
4341
4548
  if (!e || e.endsWith("%")) return 0;
4342
4549
  let n = parseFloat(e);
4343
4550
  return Number.isFinite(n) ? Math.max(0, F(n, t)) : 0;
4344
4551
  }
4345
- function Ei(e, t) {
4552
+ function Hi(e, t) {
4346
4553
  let n = (e) => {
4347
4554
  if (!e || e === "auto" || e.endsWith("%")) return null;
4348
4555
  let n = parseFloat(e);
@@ -4355,7 +4562,7 @@ function Ei(e, t) {
4355
4562
  left: n(e.left)
4356
4563
  };
4357
4564
  }
4358
- function Di(e) {
4565
+ function Ui(e) {
4359
4566
  let t = [], n = [], r = [], i = () => {
4360
4567
  let e = t.length;
4361
4568
  for (; e > 0 && t[e - 1] !== "\n";) e--;
@@ -4380,30 +4587,30 @@ function Di(e) {
4380
4587
  boxes: e.boxes
4381
4588
  };
4382
4589
  }
4383
- function Oi(e, t, n) {
4590
+ function Wi(e, t, n) {
4384
4591
  let r = 0, i = 0;
4385
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);
4386
4593
  return r;
4387
4594
  }
4388
- function ki(e) {
4389
- return De(e).length;
4595
+ function Gi(e) {
4596
+ return Ae(e).length;
4390
4597
  }
4391
- function Ai(e) {
4392
- M(e, "A block-level element nested inside a text run can't be laid out and was skipped. Give it its own place in the layout instead.");
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.");
4393
4600
  }
4394
- function ji(e) {
4601
+ function qi(e) {
4395
4602
  return Array.from(e.childNodes).some((e) => e.nodeType === Node.TEXT_NODE && /[^ \t\r\n\f]/.test(e.textContent ?? ""));
4396
4603
  }
4397
- var Mi = "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>).";
4398
- function Ni(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) {
4399
4606
  return e === "INPUT" || e === "SELECT" || e === "TEXTAREA";
4400
4607
  }
4401
- function Pi(e, t) {
4402
- ji(e) && (t.droppedText = !0, M(e, Mi));
4608
+ function Xi(e, t) {
4609
+ qi(e) && (t.droppedText = !0, N(e, Ji));
4403
4610
  }
4404
4611
  //#endregion
4405
4612
  //#region src/element.ts
4406
- var Fi = "\n<style>\n :host { display: block; position: relative; contain: layout style; }\n #viewport { position: relative; width: 100%; height: 100%; }\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 #grid { position: absolute; inset: 0; margin: 0; 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", Ii = "grid", Li = [
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 = [
4407
4614
  "pointerover",
4408
4615
  "pointerleave",
4409
4616
  "pointerdown",
@@ -4415,12 +4622,12 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4415
4622
  "focusout",
4416
4623
  "input",
4417
4624
  "change"
4418
- ], Ri = /^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/, zi = 3e4, Bi = typeof HTMLElement > "u" ? class {} : HTMLElement, Vi = class e extends Bi {
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 {
4419
4626
  static observedAttributes = ["select"];
4420
4627
  static #e = /* @__PURE__ */ new Set();
4421
4628
  static #t = null;
4422
4629
  static #n = () => {
4423
- for (let t of e.#e) t.#G();
4630
+ for (let t of e.#e) t.#fe();
4424
4631
  };
4425
4632
  static #r(t) {
4426
4633
  t instanceof HTMLLinkElement && t.rel === "stylesheet" && !t.sheet && t.addEventListener("load", e.#n, { once: !0 });
@@ -4451,7 +4658,14 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4451
4658
  #p = null;
4452
4659
  #m = null;
4453
4660
  #h = null;
4454
- #g() {
4661
+ #g = !1;
4662
+ #_ = [];
4663
+ #v = /* @__PURE__ */ new Map();
4664
+ #y = /* @__PURE__ */ new WeakMap();
4665
+ #b = null;
4666
+ #x = null;
4667
+ #S = [];
4668
+ #C() {
4455
4669
  this.#u?.observe(this, {
4456
4670
  childList: !0,
4457
4671
  subtree: !0,
@@ -4463,89 +4677,290 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4463
4677
  "colspan",
4464
4678
  "rowspan",
4465
4679
  "span",
4466
- ...ie()
4680
+ ...oe()
4467
4681
  ]
4468
4682
  });
4469
4683
  }
4470
4684
  constructor() {
4471
- super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = Fi, 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);
4472
4686
  }
4473
4687
  connectedCallback() {
4474
- this.hasAttribute("select") || this.setAttribute("select", Ii), this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#G()), this.#l.observe(this), this.#l.observe(this.#c), window.addEventListener("resize", this.#V), this.#u = new MutationObserver(() => this.#G()), this.#g(), this.#m = ae(() => {
4475
- this.#g(), this.#G();
4476
- }), this.#h = C(() => this.#G()), document.fonts?.ready.then(this.#H).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) => {
4477
4691
  console.warn("[monowind] document.fonts.ready failed:", e);
4478
- }), document.fonts?.addEventListener("loadingdone", this.#H);
4479
- for (let e of Li) this.addEventListener(e, this.#B);
4480
- this.addEventListener("transitionrun", this.#L), this.addEventListener("transitionend", this.#R), this.addEventListener("transitioncancel", this.#R), this.addEventListener("pointermove", this.#D), this.addEventListener("pointerleave", this.#O), this.addEventListener("pointerdown", this.#k), window.addEventListener("pointerup", this.#A), window.addEventListener("pointercancel", this.#A), document.addEventListener("scroll", this.#j, {
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, {
4695
+ capture: !0,
4696
+ passive: !0
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, {
4481
4698
  capture: !0,
4482
4699
  passive: !0
4483
- }), e.#i(this), this.#G();
4700
+ }), e.#i(this), this.#fe();
4484
4701
  }
4485
4702
  disconnectedCallback() {
4486
- window.removeEventListener("resize", this.#V), 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.#H);
4487
- for (let e of Li) this.removeEventListener(e, this.#B);
4488
- this.removeEventListener("transitionrun", this.#L), this.removeEventListener("transitionend", this.#R), this.removeEventListener("transitioncancel", this.#R), this.#P = 0, this.removeEventListener("pointermove", this.#D), this.removeEventListener("pointerleave", this.#O), this.removeEventListener("pointerdown", this.#k), window.removeEventListener("pointerup", this.#A), window.removeEventListener("pointercancel", this.#A), document.removeEventListener("scroll", this.#j, { capture: !0 }), this.#S = null, this.#y = null, this.#b = !1, this.#x = !1, this.#M(), e.#a(this);
4489
- }
4490
- #_ = /* @__PURE__ */ new Set();
4491
- #v = /* @__PURE__ */ new Set();
4492
- #y = null;
4493
- #b = !1;
4494
- #x = !1;
4495
- #S = null;
4496
- #C = NaN;
4497
- #w = NaN;
4498
- #T = null;
4499
- static #E = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
4500
- #D = (e) => {
4501
- let { clientX: t, clientY: n } = e;
4502
- this.#S = {
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);
4706
+ for (let e of this.#v.values()) clearTimeout(e);
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);
4708
+ }
4709
+ #w = /* @__PURE__ */ new Set();
4710
+ #T = /* @__PURE__ */ new Set();
4711
+ #E = null;
4712
+ #D = !1;
4713
+ #O = !1;
4714
+ #k = null;
4715
+ #A = NaN;
4716
+ #j = NaN;
4717
+ #M = null;
4718
+ static #N = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
4719
+ #P() {
4720
+ if (this.#g || this.#d) return;
4721
+ this.#g = !0;
4722
+ let e = !1, t = () => {
4723
+ if (e) return;
4724
+ e = !0, this.#g = !1;
4725
+ let t = this.#f;
4726
+ !this.isConnected || !this.#p || !t || (this.#F(t), this.#O = !_r(this.#p, this.#s, this.#D), this.#$());
4727
+ };
4728
+ requestAnimationFrame(t), setTimeout(t, 50);
4729
+ }
4730
+ #F(e, t) {
4731
+ for (let n of this.#_) {
4732
+ let r = n.source, { maxX: i, maxY: a } = n.scrollRange, o = t?.get(r);
4733
+ n.scroll = o ? {
4734
+ x: o.pinX ? i : Math.min(o.x, i),
4735
+ y: o.pinY ? a : Math.min(o.y, a)
4736
+ } : this.#I(n, e);
4737
+ }
4738
+ }
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() {
4750
+ let e = /* @__PURE__ */ new Map(), t = this.#f;
4751
+ if (!t) return e;
4752
+ for (let n of this.#_) {
4753
+ let r = n.source, { maxX: i, maxY: a } = n.scrollRange, { x: o, y: s } = this.#I(n, t);
4754
+ e.set(r, {
4755
+ top: r.scrollTop,
4756
+ left: r.scrollLeft,
4757
+ x: o,
4758
+ y: s,
4759
+ pinX: i > 0 && o >= i,
4760
+ pinY: a > 0 && s >= a
4761
+ });
4762
+ }
4763
+ return e;
4764
+ }
4765
+ #R(e) {
4766
+ for (let t of this.#_) {
4767
+ let n = t.source, r = e.get(n);
4768
+ r && (n.scrollTop, n.scrollLeft, n.scrollTop = r.pinY ? n.scrollHeight : r.top, n.scrollLeft = r.pinX ? n.scrollWidth : r.left);
4769
+ }
4770
+ }
4771
+ #z(e, t) {
4772
+ clearTimeout(this.#v.get(e)), this.#v.set(e, setTimeout(() => this.#H(e), t));
4773
+ }
4774
+ #B = (e) => {
4775
+ let t = e.target;
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)));
4777
+ };
4778
+ #V = (e) => {
4779
+ let t = e.target;
4780
+ !(t instanceof HTMLElement) || t === this || t.hasAttribute("data-mw-scroll") && (Date.now() - (this.#y.get(t) ?? 0) < na || this.#z(t, oa));
4781
+ };
4782
+ #H(e) {
4783
+ if (this.#x?.el === e) return;
4784
+ this.#P();
4785
+ let t = this.#f, n = this.#_.find((t) => t.source === e);
4786
+ if (!t || !n) return;
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;
4788
+ (Math.abs(e.scrollTop - a) > .5 || Math.abs(e.scrollLeft - o) > .5) && e.scrollTo({
4789
+ top: a,
4790
+ left: o,
4791
+ behavior: "instant"
4792
+ });
4793
+ }
4794
+ #U = (e) => {
4795
+ if (this.getAttribute("select") !== "grid") return;
4796
+ let t = this.#p, n = this.#f;
4797
+ if (!t || !n || this.#_.length === 0) return;
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);
4801
+ if (u === 0) {
4802
+ this.#b = null, r.preventDefault();
4803
+ return;
4804
+ }
4805
+ let d = (e) => {
4806
+ let t = e.scrollRange, n = e.source;
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;
4809
+ if (_) {
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;
4811
+ v = this.#_.find((e) => e.source === f.el) ?? null;
4812
+ }
4813
+ if (!v) {
4814
+ let e = Se(t, s, c);
4815
+ for (let t = e.length - 1; t >= 0; t--) {
4816
+ let n = e[t].node;
4817
+ if (!n.scrollRange) continue;
4818
+ if (d(n)) {
4819
+ v = n;
4820
+ break;
4821
+ }
4822
+ let r = n.style.overscroll;
4823
+ if (o !== 0 && !r.y || a !== 0 && !r.x) {
4824
+ v = n;
4825
+ break;
4826
+ }
4827
+ }
4828
+ if (!v && u < ia) {
4829
+ r.preventDefault();
4830
+ return;
4831
+ }
4832
+ this.#b = {
4833
+ el: v ? v.source : null,
4834
+ x: r.clientX,
4835
+ y: r.clientY,
4836
+ axis: p,
4837
+ at: l,
4838
+ mag: u,
4839
+ decayed: 0
4840
+ };
4841
+ }
4842
+ if (!v || (r.preventDefault(), !d(v))) return;
4843
+ let y = v.source, b = v.scrollRange, x = { behavior: "instant" };
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);
4845
+ };
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) {
4858
+ let e = this.#s.getBoundingClientRect();
4859
+ this.#M = {
4860
+ left: e.left,
4861
+ top: e.top
4862
+ };
4863
+ }
4864
+ return {
4865
+ col: Math.floor((e - this.#M.left) / n.width),
4866
+ row: Math.floor((t - this.#M.top) / n.height)
4867
+ };
4868
+ }
4869
+ #q(e, t) {
4870
+ let n = this.#p, r = this.#f;
4871
+ if (!n || !r || this.#_.length === 0) return null;
4872
+ let { col: i, row: a } = this.#K(e, t, r), o = Se(n, i, a);
4873
+ for (let n = o.length - 1; n >= 0; n--) {
4874
+ let { node: s, x: c, y: l } = o[n], u = s.scrollRange;
4875
+ if (!u) continue;
4876
+ let d = s.style, f = s.scrollGutterCells;
4877
+ if (!f || f.right === 0 && f.bottom === 0) continue;
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;
4879
+ if (f.right > 0 && u.maxY > 0 && i >= _ - f.right && i < _ && a >= m && a < g) {
4880
+ let e = g - m - f.bottom, n = fr(e, u.sizeY, u.maxY, 0).len, i = Math.max(1, (e - n) * r.height);
4881
+ return {
4882
+ el: p,
4883
+ axis: "y",
4884
+ startClient: t,
4885
+ startPx: p.scrollTop,
4886
+ factor: u.maxY * r.height / i
4887
+ };
4888
+ }
4889
+ if (f.bottom > 0 && u.maxX > 0 && a >= g - f.bottom && a < g && i >= h && i < _) {
4890
+ let t = _ - h - f.right, n = fr(t, u.sizeX, u.maxX, 0).len, i = Math.max(1, (t - n) * r.width);
4891
+ return {
4892
+ el: p,
4893
+ axis: "x",
4894
+ startClient: e,
4895
+ startPx: p.scrollLeft,
4896
+ factor: u.maxX * r.width / i
4897
+ };
4898
+ }
4899
+ }
4900
+ return null;
4901
+ }
4902
+ #J = (e) => {
4903
+ let { clientX: t, clientY: n } = e, r = this.#x;
4904
+ if (r) {
4905
+ let e = (r.axis === "y" ? n : t) - r.startClient, i = r.startPx + e * r.factor;
4906
+ r.axis === "y" ? r.el.scrollTop = i : r.el.scrollLeft = i;
4907
+ return;
4908
+ }
4909
+ this.#k = {
4503
4910
  x: t,
4504
4911
  y: n
4505
4912
  };
4506
- let r = this.#T, i = this.#f;
4507
- if (r && i) {
4508
- let e = Math.floor((t - r.left) / i.width), a = Math.floor((n - r.top) / i.height);
4509
- if (e === this.#C && a === this.#w) return;
4913
+ let i = this.#f;
4914
+ if (i) {
4915
+ let { col: e, row: r } = this.#K(t, n, i);
4916
+ if (e === this.#A && r === this.#j) return;
4510
4917
  }
4511
- this.#M();
4918
+ this.#$();
4512
4919
  };
4513
- #O = () => {
4514
- this.#S = null, this.#M();
4920
+ #Y = () => {
4921
+ this.#k = null, this.#$();
4515
4922
  };
4516
- #k = (e) => {
4923
+ #X = (e) => {
4517
4924
  let t = e;
4518
- !t.isPrimary || t.button !== 0 || (this.#S = {
4925
+ if (!t.isPrimary || t.button !== 0) return;
4926
+ let n = t.pointerType === "touch" ? null : this.#q(t.clientX, t.clientY);
4927
+ if (n) {
4928
+ this.#x = n, t.preventDefault(), t.isTrusted && this.setPointerCapture(t.pointerId);
4929
+ return;
4930
+ }
4931
+ this.#k = {
4519
4932
  x: t.clientX,
4520
4933
  y: t.clientY
4521
- }, this.#b = !0, this.#M(!0));
4934
+ }, this.#D = !0, this.#$(!0);
4522
4935
  };
4523
- #A = (e) => {
4524
- e.isPrimary && (!this.#b && !this.#y || (this.#b = !1, this.#y = null, this.#M(), this.#x && this.#G()));
4936
+ #Z = (e) => {
4937
+ if (e.isPrimary) {
4938
+ if (this.#x) {
4939
+ this.#H(this.#x.el), this.#x = null;
4940
+ return;
4941
+ }
4942
+ !this.#D && !this.#E || (this.#D = !1, this.#E = null, this.#$(), this.#O && this.#fe());
4943
+ }
4525
4944
  };
4526
- #j = () => {
4527
- this.#S && (this.#T = null, this.#M());
4945
+ #Q = (e) => {
4946
+ if (!this.#k) return;
4947
+ let t = e.target;
4948
+ t instanceof HTMLElement && t.hasAttribute("data-mw-scroll") || (this.#M = null, this.#$());
4528
4949
  };
4529
- #M(t = !1) {
4950
+ #$(t = !1) {
4530
4951
  let n = this.#p, r = this.#f, i = [];
4531
- if (this.#S && n && r && this.isConnected && this.getAttribute("select") === "grid" && (this.#b || e.#E?.matches)) {
4532
- if (!this.#T) {
4533
- let e = this.#s.getBoundingClientRect();
4534
- this.#T = {
4535
- left: e.left,
4536
- top: e.top
4537
- };
4538
- }
4539
- this.#C = Math.floor((this.#S.x - this.#T.left) / r.width), this.#w = Math.floor((this.#S.y - this.#T.top) / r.height), i = be(n, this.#C, this.#w);
4540
- } else this.#C = NaN, this.#w = 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;
4541
4956
  let a = i.at(-1) ?? null;
4542
- t && (this.#y = a);
4543
- let o = e.#E?.matches ? i : [], s = this.#y ? i.indexOf(this.#y) : -1, c = s >= 0 ? i.slice(0, s + 1) : [], l = this.#N("data-mw-hover", this.#_, o);
4544
- l = this.#N("data-mw-active", this.#v, 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;
4545
4960
  let u = a ? getComputedStyle(a).cursor : "";
4546
- this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#G();
4961
+ this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#fe();
4547
4962
  }
4548
- #N(e, t, n) {
4963
+ #ee(e, t, n) {
4549
4964
  let r = !1, i = new Set(n);
4550
4965
  for (let n of t) i.has(n) || (n.removeAttribute(e), r = !0);
4551
4966
  for (let n of i) t.has(n) || (n.setAttribute(e, ""), r = !0);
@@ -4553,51 +4968,51 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4553
4968
  for (let e of i) t.add(e);
4554
4969
  return r;
4555
4970
  }
4556
- #P = 0;
4557
- #F = !1;
4558
- #I = 0;
4559
- #L = (e) => {
4560
- Ri.test(e.propertyName) && (this.#P++, this.#I = performance.now(), this.#z());
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());
4561
4976
  };
4562
- #R = (e) => {
4563
- Ri.test(e.propertyName) && (this.#P = Math.max(0, this.#P - 1));
4977
+ #ae = (e) => {
4978
+ ea.test(e.propertyName) && (this.#te = Math.max(0, this.#te - 1));
4564
4979
  };
4565
- #z() {
4566
- if (this.#F) return;
4567
- this.#F = !0;
4980
+ #oe() {
4981
+ if (this.#ne) return;
4982
+ this.#ne = !0;
4568
4983
  let e = () => {
4569
- if (!this.isConnected || this.#P === 0 && !a() || performance.now() - this.#I > zi) {
4570
- this.#F = !1, this.#P = 0, this.#G();
4984
+ if (!this.isConnected || this.#te === 0 && !a() || performance.now() - this.#re > ta) {
4985
+ this.#ne = !1, this.#te = 0, this.#fe();
4571
4986
  return;
4572
4987
  }
4573
- this.#W(), requestAnimationFrame(e);
4988
+ this.#de(), requestAnimationFrame(e);
4574
4989
  };
4575
4990
  requestAnimationFrame(e);
4576
4991
  }
4577
- #B = (e) => {
4992
+ #se = (e) => {
4578
4993
  if ((e.type === "focusin" || e.type === "focusout") && e.target instanceof HTMLSelectElement) {
4579
- this.#W();
4994
+ this.#de();
4580
4995
  return;
4581
4996
  }
4582
- this.#G();
4997
+ this.#fe();
4583
4998
  };
4584
4999
  attributeChangedCallback(e, t, n) {
4585
5000
  if (e === "select" && n !== "text" && n !== "grid") {
4586
- n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, this), this.setAttribute("select", Ii);
5001
+ n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, ee(this)), this.setAttribute("select", Qi);
4587
5002
  return;
4588
5003
  }
4589
- e === "select" && this.#M(), this.#G();
5004
+ e === "select" && this.#$(), this.#fe();
4590
5005
  }
4591
5006
  toPlainText() {
4592
- return this.#d && this.#K(), this.#p ? Xn(this.#p) : "";
5007
+ return this.#d && this.#pe(), this.#p ? rr(this.#p) : "";
4593
5008
  }
4594
- #V = () => {
4595
- this.#G();
5009
+ #ce = () => {
5010
+ this.#fe();
4596
5011
  };
4597
- #H = () => {
4598
- requestAnimationFrame(() => this.#G());
5012
+ #le = () => {
5013
+ requestAnimationFrame(() => this.#fe());
4599
5014
  };
4600
- #U() {
5015
+ #ue() {
4601
5016
  let e = document.activeElement;
4602
5017
  if (!(e instanceof HTMLSelectElement) || !this.contains(e)) return !1;
4603
5018
  try {
@@ -4606,50 +5021,50 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4606
5021
  return !1;
4607
5022
  }
4608
5023
  }
4609
- #W() {
5024
+ #de() {
4610
5025
  try {
4611
- this.#K();
5026
+ this.#pe();
4612
5027
  } catch (e) {
4613
5028
  console.error("[monowind] layout failed:", e);
4614
5029
  }
4615
5030
  }
4616
- #G() {
5031
+ #fe() {
4617
5032
  this.#d || (this.#d = !0, requestAnimationFrame(() => {
4618
- if (this.#d = !1, this.#U()) {
4619
- this.#G();
5033
+ if (this.#d = !1, this.#ue()) {
5034
+ this.#fe();
4620
5035
  return;
4621
5036
  }
4622
- this.#W();
5037
+ this.#de();
4623
5038
  }));
4624
5039
  }
4625
- #K() {
5040
+ #pe() {
4626
5041
  if (!this.isConnected) return;
4627
- let e = /* @__PURE__ */ new Map(), t = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), n = parseFloat(t);
4628
- if (Number.isFinite(n) && n > 0) for (let t of this.querySelectorAll("textarea")) {
4629
- let r = getComputedStyle(t), i = t.clientWidth - (parseFloat(r.paddingLeft) || 0) - (parseFloat(r.paddingRight) || 0);
4630
- e.set(t, Math.max(0, Math.round(i / n)));
5042
+ let e = this.#L(), t = /* @__PURE__ */ new Map(), n = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), r = parseFloat(n);
5043
+ if (Number.isFinite(r) && r > 0) for (let e of this.querySelectorAll("textarea")) {
5044
+ let n = getComputedStyle(e), i = e.clientWidth - (parseFloat(n.paddingLeft) || 0) - (parseFloat(n.paddingRight) || 0);
5045
+ t.set(e, Math.max(0, Math.round(i / r)));
4631
5046
  }
4632
5047
  this.setAttribute("measuring", "");
4633
5048
  try {
4634
5049
  this.#c.parentNode !== this && this.appendChild(this.#c);
4635
- let t = Se(this, this.#c), n = this.#f;
4636
- (n === null || n.width !== t.width || n.height !== t.height || n.letterSpacing !== t.letterSpacing || n.inkOverhang !== t.inkOverhang) && (this.style.setProperty("--mw-cw", `${t.width}px`), this.style.setProperty("--mw-ch", `${t.height}px`), this.style.setProperty("--mw-rls", `${t.letterSpacing}px`), this.style.setProperty("--mw-ink", `${t.inkOverhang ?? 0}px`)), this.#f = t;
4637
- let r = getComputedStyle(this), i = (parseFloat(r.paddingLeft) || 0) + (parseFloat(r.paddingRight) || 0), a = Math.max(0, Math.floor((this.clientWidth - i) / t.width));
4638
- if (a === 0) return;
4639
- let o = Ce(), s = [];
4640
- for (let n of Array.from(this.children)) {
4641
- if (n === this.#c) continue;
4642
- let r = gi(n, o, t, e);
4643
- r && s.push(r);
5050
+ let n = Te(this, this.#c), r = this.#f;
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;
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));
5053
+ if (o === 0) return;
5054
+ let s = Ee(), c = [];
5055
+ for (let e of Array.from(this.children)) {
5056
+ if (e === this.#c) continue;
5057
+ let r = Mi(e, s, n, t);
5058
+ r && c.push(r);
4644
5059
  }
4645
- if (ji(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${Mi}`, this), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), s.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) {
4646
5061
  this.#s.replaceChildren(), this.#p = null, this.setAttribute("data-mw-ready", "");
4647
5062
  return;
4648
5063
  }
4649
- let c = {
5064
+ let l = {
4650
5065
  source: this,
4651
- style: $e(),
4652
- children: s,
5066
+ style: rt(),
5067
+ children: c,
4653
5068
  text: "",
4654
5069
  intrinsicWidth: 0,
4655
5070
  intrinsicHeight: 0,
@@ -4660,20 +5075,42 @@ var Fi = "\n<style>\n :host { display: block; position: relative; contain: layo
4660
5075
  height: 0
4661
5076
  },
4662
5077
  unclampedHeight: 0,
4663
- resolvedPadding: z()
4664
- }, { height: l } = An(c, a);
4665
- _r(c), this.#x = !lr(c, this.#s, this.#b), this.#p = c;
4666
- let u = r.boxSizing === "border-box" ? (parseFloat(r.paddingTop) || 0) + (parseFloat(r.paddingBottom) || 0) + (parseFloat(r.borderTopWidth) || 0) + (parseFloat(r.borderBottomWidth) || 0) : 0, d = `${l * t.height + u}px`;
4667
- this.style.height !== d && (this.style.height = d), this.hasAttribute("data-mw-ready") || this.setAttribute("data-mw-ready", "");
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;
5081
+ let d = `${l.localRect.width * n.width}px`, f = `${l.localRect.height * n.height}px`;
5082
+ this.#s.style.width !== d && (this.#s.style.width = d), this.#s.style.height !== f && (this.#s.style.height = f);
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`;
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", "");
4668
5087
  } finally {
4669
- this.setAttribute("settling", ""), this.removeAttribute("measuring"), getComputedStyle(this).transitionProperty, this.removeAttribute("settling"), this.#u?.takeRecords(), i(this) && (a() ? (this.#I = performance.now(), this.#z()) : this.#G()), this.#T = null, this.#S && this.#M();
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.#$();
4670
5092
  }
4671
5093
  }
4672
5094
  };
4673
- function Hi() {
4674
- typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", Vi);
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);
5100
+ }
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);
5105
+ }
5106
+ function pa(e) {
5107
+ let t = [], n = (e) => {
5108
+ e.scrollRange && t.push(e);
5109
+ for (let t of e.children) n(t);
5110
+ };
5111
+ return n(e), t;
4675
5112
  }
4676
5113
  //#endregion
4677
- export { Vi as MonoWindElement, Hi as defineMonoWind, ne as invalidateLeaves, Wt as multicolLines, x as registerBorderGlyphs, te as registerLeafRenderer, Xn as renderPlainText, we 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 };
4678
5115
 
4679
5116
  //# sourceMappingURL=index.js.map