monowind 0.1.10 → 0.2.1

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
@@ -213,53 +213,169 @@ function v(e, t, n) {
213
213
  };
214
214
  }
215
215
  //#endregion
216
+ //#region src/glyphs.ts
217
+ var y = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Set();
218
+ function x(e, t) {
219
+ let n = e.toLowerCase().trim();
220
+ y.has(n) && console.warn(`[monowind] registerBorderGlyphs: replacing "${n}" (last registration wins).`), y.set(n, t);
221
+ for (let e of b) e();
222
+ }
223
+ function S(e) {
224
+ if (e) return y.get(e.toLowerCase().trim());
225
+ }
226
+ function C(e) {
227
+ return b.add(e), () => b.delete(e);
228
+ }
229
+ function w(e) {
230
+ switch (e) {
231
+ case 1:
232
+ case 2:
233
+ case 3: return "h";
234
+ case 4:
235
+ case 8:
236
+ case 12: return "v";
237
+ case 5: return "tl";
238
+ case 6: return "tr";
239
+ case 9: return "bl";
240
+ case 10: return "br";
241
+ case 7: return "teeDown";
242
+ case 11: return "teeUp";
243
+ case 13: return "teeRight";
244
+ case 14: return "teeLeft";
245
+ case 15: return "cross";
246
+ default: return null;
247
+ }
248
+ }
249
+ var T = [
250
+ " ",
251
+ "─",
252
+ "─",
253
+ "─",
254
+ "│",
255
+ "┌",
256
+ "┐",
257
+ "┬",
258
+ "│",
259
+ "└",
260
+ "┘",
261
+ "┴",
262
+ "│",
263
+ "├",
264
+ "┤",
265
+ "┼"
266
+ ], E = [
267
+ " ",
268
+ "═",
269
+ "═",
270
+ "═",
271
+ "║",
272
+ "╔",
273
+ "╗",
274
+ "╦",
275
+ "║",
276
+ "╚",
277
+ "╝",
278
+ "╩",
279
+ "║",
280
+ "╠",
281
+ "╣",
282
+ "╬"
283
+ ];
284
+ function D(e) {
285
+ let t = {};
286
+ for (let n = 1; n < 16; n++) {
287
+ let r = w(n);
288
+ r && !(r in t) && (t[r] = e[n]);
289
+ }
290
+ return t;
291
+ }
292
+ var O = (e) => D(Array(16).fill(e));
293
+ x("default", {}), x("rounded", { solid: {
294
+ tl: "╭",
295
+ tr: "╮",
296
+ bl: "╰",
297
+ br: "╯"
298
+ } });
299
+ var k = {
300
+ ...O("+"),
301
+ h: "-",
302
+ v: "|"
303
+ };
304
+ x("ascii", {
305
+ solid: k,
306
+ double: {
307
+ ...k,
308
+ h: "="
309
+ },
310
+ dashed: k,
311
+ dotted: {
312
+ ...k,
313
+ h: ".",
314
+ v: ":"
315
+ }
316
+ });
317
+ var A = D(T);
318
+ x("single", {
319
+ double: A,
320
+ dashed: A,
321
+ dotted: A
322
+ }), x("cp437", {
323
+ dashed: A,
324
+ dotted: A
325
+ }), x("blocks", {
326
+ solid: O("█"),
327
+ double: O("█"),
328
+ dashed: O("▒"),
329
+ dotted: O("░")
330
+ });
331
+ //#endregion
216
332
  //#region src/warn.ts
217
- var y = /* @__PURE__ */ new WeakMap();
218
- function b(e, t) {
219
- let n = y.get(e);
220
- n || y.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, e));
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));
221
337
  }
222
338
  //#endregion
223
339
  //#region src/leaf.ts
224
- var x = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Set();
225
- function C(e) {
340
+ var N = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Set();
341
+ function te(e) {
226
342
  let t = e.tag.toLowerCase();
227
343
  if (!t.includes("-")) {
228
344
  console.warn(`[monowind] registerLeafRenderer: "${e.tag}" is not a custom-element tag name (needs a hyphen); ignored.`);
229
345
  return;
230
346
  }
231
- x.has(t) && console.warn(`[monowind] registerLeafRenderer: replacing existing renderer for <${t}> (last registration wins).`), x.set(t, {
347
+ N.has(t) && console.warn(`[monowind] registerLeafRenderer: replacing existing renderer for <${t}> (last registration wins).`), N.set(t, {
232
348
  ...e,
233
349
  tag: t
234
- }), O();
350
+ }), se();
235
351
  }
236
- function w() {
237
- O();
352
+ function ne() {
353
+ se();
238
354
  }
239
- function T(e) {
240
- return x.get(e.toLowerCase());
355
+ function re(e) {
356
+ return N.get(e.toLowerCase());
241
357
  }
242
- function E() {
358
+ function ie() {
243
359
  let e = /* @__PURE__ */ new Set();
244
- for (let t of x.values()) for (let n of t.observedAttributes ?? []) e.add(n.toLowerCase());
360
+ for (let t of N.values()) for (let n of t.observedAttributes ?? []) e.add(n.toLowerCase());
245
361
  return [...e];
246
362
  }
247
- function D(e) {
248
- return S.add(e), () => S.delete(e);
363
+ function ae(e) {
364
+ return ee.add(e), () => ee.delete(e);
249
365
  }
250
- function ee(e, t) {
366
+ function oe(e, t) {
251
367
  try {
252
368
  return e.render(t);
253
369
  } catch (n) {
254
- return b(t, `<${e.tag}> renderer threw; rendering nothing. ${String(n)}`), null;
370
+ return M(t, `<${e.tag}> renderer threw; rendering nothing. ${String(n)}`), null;
255
371
  }
256
372
  }
257
- function O() {
258
- for (let e of S) e();
373
+ function se() {
374
+ for (let e of ee) e();
259
375
  }
260
376
  //#endregion
261
377
  //#region src/borders.ts
262
- function k(e, t, n) {
378
+ function ce(e, t, n) {
263
379
  let r = e.border;
264
380
  if (r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0) return;
265
381
  let i = Math.max(r.top, r.right, r.bottom, r.left);
@@ -275,138 +391,118 @@ function k(e, t, n) {
275
391
  width: t.width - (i.left ? a : 0) - (i.right ? a : 0),
276
392
  height: t.height - (i.top ? a : 0) - (i.bottom ? a : 0)
277
393
  };
278
- o.width <= 0 || o.height <= 0 || A(n, e.borderStyle, e.borderColor, o, i);
394
+ o.width <= 0 || o.height <= 0 || le(n, e.borderStyle, e.borderColor, o, i, S(e.glyphSet));
279
395
  }
280
396
  }
281
- function A(e, t, n, r, i) {
282
- let a = oe(t.top), o = oe(t.right), s = oe(t.bottom), c = oe(t.left), l = (e, t, n) => n(oe(e === t ? e : "solid")), { x: u, y: d, width: f, height: p } = r, m = f >= 2 && p >= 2, h = u + +!!i.left, g = u + f - +!!i.right, _ = d + +!!i.top, v = d + p - +!!i.bottom;
283
- if (i.top && g > h && e.push({
284
- glyph: a.h,
285
- x: h,
286
- y: d,
287
- length: g - h,
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;
399
+ if (i.top && _ > g && e.push({
400
+ glyph: o.h,
401
+ x: g,
402
+ y: f,
403
+ length: _ - g,
288
404
  color: n.top
289
- }), i.bottom && p > +!!i.top && g > h && e.push({
290
- glyph: s.h,
291
- x: h,
292
- y: d + p - 1,
293
- length: g - h,
405
+ }), i.bottom && m > +!!i.top && _ > g && e.push({
406
+ glyph: c.h,
407
+ x: g,
408
+ y: f + m - 1,
409
+ length: _ - g,
294
410
  color: n.bottom
295
- }), i.left) for (let t = _; t < v; t++) e.push({
296
- glyph: c.v,
297
- x: u,
411
+ }), i.left) for (let t = v; t < y; t++) e.push({
412
+ glyph: l.v,
413
+ x: d,
298
414
  y: t,
299
415
  length: 1,
300
416
  color: n.left
301
417
  });
302
- if (i.right && f > +!!i.left) for (let t = _; t < v; t++) e.push({
303
- glyph: o.v,
304
- x: u + f - 1,
418
+ if (i.right && p > +!!i.left) for (let t = v; t < y; t++) e.push({
419
+ glyph: s.v,
420
+ x: d + p - 1,
305
421
  y: t,
306
422
  length: 1,
307
423
  color: n.right
308
424
  });
309
- m && (i.top && i.left && e.push({
310
- glyph: l(t.top, t.left, (e) => e.tl),
311
- x: u,
312
- y: d,
425
+ h && (i.top && i.left && e.push({
426
+ glyph: u(t.top, t.left, (e) => e.tl),
427
+ x: d,
428
+ y: f,
313
429
  length: 1,
314
430
  color: n.top
315
431
  }), i.top && i.right && e.push({
316
- glyph: l(t.top, t.right, (e) => e.tr),
317
- x: u + f - 1,
318
- y: d,
432
+ glyph: u(t.top, t.right, (e) => e.tr),
433
+ x: d + p - 1,
434
+ y: f,
319
435
  length: 1,
320
436
  color: n.top
321
437
  }), i.bottom && i.left && e.push({
322
- glyph: l(t.bottom, t.left, (e) => e.bl),
323
- x: u,
324
- y: d + p - 1,
438
+ glyph: u(t.bottom, t.left, (e) => e.bl),
439
+ x: d,
440
+ y: f + m - 1,
325
441
  length: 1,
326
442
  color: n.bottom
327
443
  }), i.bottom && i.right && e.push({
328
- glyph: l(t.bottom, t.right, (e) => e.br),
329
- x: u + f - 1,
330
- y: d + p - 1,
444
+ glyph: u(t.bottom, t.right, (e) => e.br),
445
+ x: d + p - 1,
446
+ y: f + m - 1,
331
447
  length: 1,
332
448
  color: n.bottom
333
449
  }));
334
450
  }
335
- function j(e, t) {
451
+ function ue(e, t) {
336
452
  return e.style.position !== "static" || t.style.display === "flex" || t.style.display === "grid";
337
453
  }
338
- function te(e) {
454
+ function de(e) {
339
455
  if (e.children.length <= 1) return e.children;
340
456
  let t = null, n = null, r = null;
341
- for (let i of e.children) j(i, e) ? (r ??= []).push(i) : i.inlineBox ? (n ??= []).push(i) : (t ??= []).push(i);
457
+ for (let i of e.children) ue(i, e) ? (r ??= []).push(i) : i.inlineBox ? (n ??= []).push(i) : (t ??= []).push(i);
342
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 : [
343
459
  ...t ?? [],
344
460
  ...n ?? [],
345
461
  ...r ?? []
346
462
  ];
347
463
  }
348
- function ne(e, t) {
349
- let n = oe(e);
350
- return t === "h" ? n.h : n.v;
351
- }
352
- function re(e, t, n, r, i) {
353
- return (e === "double" ? ae : ie)[(t ? 8 : 0) | (n ? 4 : 0) | (r ? 2 : 0) | !!i];
354
- }
355
- var ie = [
356
- " ",
357
- "─",
358
- "",
359
- "─",
360
- "│",
361
- "┌",
362
- "┐",
363
- "┬",
364
- "│",
365
- "└",
366
- "┘",
367
- "┴",
368
- "│",
369
- "├",
370
- "┤",
371
- "┼"
372
- ], ae = [
373
- " ",
374
- "═",
375
- "═",
376
- "═",
377
- "║",
378
- "╔",
379
- "╗",
380
- "╦",
381
- "║",
382
- "╚",
383
- "╝",
384
- "╩",
385
- "║",
386
- "╠",
387
- "╣",
388
- "╬"
389
- ];
390
- function oe(e) {
391
- let t = (t, n, r, i) => re(e, t, n, r, i), n = {
392
- h: t(!1, !1, !0, !0),
393
- v: t(!0, !0, !1, !1),
394
- tl: t(!1, !0, !1, !0),
395
- tr: t(!1, !0, !0, !1),
396
- bl: t(!0, !1, !1, !0),
397
- br: t(!0, !1, !0, !1)
464
+ function fe(e, t, n) {
465
+ let r = me(e, n);
466
+ return t === "h" ? r.h : r.v;
467
+ }
468
+ function pe(e, t, n, r, i, a) {
469
+ let o = (t ? 8 : 0) | (n ? 4 : 0) | (r ? 2 : 0) | !!i;
470
+ if (a) {
471
+ let t = w(o), n = t && a[e]?.[t];
472
+ if (n) return n;
473
+ }
474
+ return (e === "double" ? E : T)[o];
475
+ }
476
+ function me(e, t) {
477
+ let n = (n, r, i, a) => pe(e, n, r, i, a, t), r = {
478
+ h: n(!1, !1, !0, !0),
479
+ v: n(!0, !0, !1, !1),
480
+ tl: n(!1, !0, !1, !0),
481
+ tr: n(!1, !0, !0, !1),
482
+ bl: n(!0, !1, !1, !0),
483
+ br: n(!0, !1, !0, !1)
398
484
  };
399
485
  return e === "dashed" ? {
400
- ...n,
401
486
  h: "╌",
402
- v: "╎"
487
+ v: "╎",
488
+ ...he(r),
489
+ ...ge(t, e)
403
490
  } : e === "dotted" ? {
404
- ...n,
405
491
  h: "┄",
406
- v: "┊"
407
- } : n;
492
+ v: "┊",
493
+ ...he(r),
494
+ ...ge(t, e)
495
+ } : r;
496
+ }
497
+ function he(e) {
498
+ let { h: t, v: n, ...r } = e;
499
+ return r;
408
500
  }
409
- function se(e, t, n, r) {
501
+ function ge(e, t) {
502
+ let n = e?.[t], r = {};
503
+ return n?.h && (r.h = n.h), n?.v && (r.v = n.v), r;
504
+ }
505
+ function _e(e, t, n, r) {
410
506
  let i = e.map((e) => e.spanned ? !1 : n === "between" ? e.beforeOccupied && e.afterOccupied : n !== "around" || e.beforeOccupied || e.afterOccupied), a = [];
411
507
  for (let n = 0; n < e.length; n++) if (a.push({
412
508
  start: e[n].start,
@@ -450,7 +546,7 @@ function se(e, t, n, r) {
450
546
  end: e.end - r
451
547
  })).filter((e) => e.end > e.start);
452
548
  }
453
- function ce(e) {
549
+ function ve(e) {
454
550
  let t = [], n = e.border.left + e.padding.left, r = e.border.top + e.padding.top, i = (e, t) => ({
455
551
  line: t.bandStart + Math.floor((t.bandSize - e.width) / 2),
456
552
  start: t.start,
@@ -459,7 +555,7 @@ function ce(e) {
459
555
  endHalf: t.endHalf === !0
460
556
  }), 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);
461
557
  if (e.ruleX) {
462
- let i = ne(e.ruleX.style, "v");
558
+ let i = fe(e.ruleX.style, "v", e.glyphs);
463
559
  for (let o of a) {
464
560
  for (let a = 0; a < s; a++) for (let s = o.start; s < o.end; s++) u(o.line + a, s) || t.push({
465
561
  glyph: i,
@@ -468,7 +564,7 @@ function ce(e) {
468
564
  length: 1,
469
565
  color: e.ruleX.color
470
566
  });
471
- le(e, t, "x", o.line, o.start, o.end);
567
+ ye(e, t, "x", o.line, o.start, o.end);
472
568
  }
473
569
  }
474
570
  if (e.ruleY) {
@@ -479,7 +575,7 @@ function ce(e) {
479
575
  for (let d = u.start; d < u.end; d++) {
480
576
  let u = l(a, s, d, f), p = l(a, s, d, f + 1);
481
577
  t.push({
482
- glyph: u || p ? re(i ? "double" : "solid", u, p, l(o, c, f, d), l(o, c, f, d + 1)) : ne(e.ruleY.style, "h"),
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),
483
579
  x: n + d,
484
580
  y: r + f,
485
581
  length: 1,
@@ -487,20 +583,20 @@ function ce(e) {
487
583
  });
488
584
  }
489
585
  }
490
- le(e, t, "y", u.line, u.start, u.end);
586
+ ye(e, t, "y", u.line, u.start, u.end);
491
587
  }
492
588
  }
493
589
  return t;
494
590
  }
495
- function le(e, t, n, r, i, a) {
496
- 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 = (e, n, r, i, a, s, c, l) => {
497
- let u = o.style === "double" && r === "double" ? "double" : "solid";
591
+ function ye(e, t, n, r, i, a) {
592
+ 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
+ let d = o.style === "double" && i === "double" ? "double" : "solid";
498
594
  t.push({
499
- glyph: re(u, a, s, c, l),
500
- x: e,
501
- y: n,
595
+ glyph: pe(d, s, c, l, u, e.glyphs),
596
+ x: n,
597
+ y: r,
502
598
  length: 1,
503
- color: i
599
+ color: a
504
600
  });
505
601
  };
506
602
  if (n === "x") for (let t = 0; t < o.width; t++) {
@@ -514,11 +610,11 @@ function le(e, t, n, r, i, a) {
514
610
  }
515
611
  //#endregion
516
612
  //#region src/pointer.ts
517
- function ue(e, t, n) {
613
+ function be(e, t, n) {
518
614
  let r = [], i = e, a = e.localRect.x, o = e.localRect.y;
519
615
  for (;;) {
520
616
  let e = null;
521
- for (let r of te(i)) {
617
+ for (let r of de(i)) {
522
618
  if (r.tableHidden) continue;
523
619
  let i = a + r.localRect.x, s = o + r.localRect.y;
524
620
  t >= i && t < i + r.localRect.width && n >= s && n < s + r.localRect.height && (e = r);
@@ -529,16 +625,16 @@ function ue(e, t, n) {
529
625
  }
530
626
  //#endregion
531
627
  //#region src/metrics.ts
532
- function M(e) {
628
+ function P(e) {
533
629
  return (e >= 0 ? Math.floor(e + .5) : -Math.floor(-e + .5)) || 0;
534
630
  }
535
- function N(e, t) {
536
- return t <= 0 ? 0 : M(e / (.25 * t));
631
+ function F(e, t) {
632
+ return t <= 0 ? 0 : P(e / (.25 * t));
537
633
  }
538
- function de(e, t) {
539
- return M(t * e / 100);
634
+ function xe(e, t) {
635
+ return P(t * e / 100);
540
636
  }
541
- function fe(e, t) {
637
+ function Se(e, t) {
542
638
  let n = t.getBoundingClientRect(), r = parseFloat(getComputedStyle(e).letterSpacing) || 0, i = t.ownerDocument.createRange();
543
639
  i.selectNodeContents(t);
544
640
  let a = Math.max(0, i.getBoundingClientRect().height - n.height);
@@ -549,56 +645,56 @@ function fe(e, t) {
549
645
  inkOverhang: a
550
646
  };
551
647
  }
552
- function pe() {
648
+ function Ce() {
553
649
  return parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
554
650
  }
555
651
  //#endregion
556
652
  //#region src/wrap.ts
557
- function me(e, t, n = {}) {
558
- return ve(e, t, n).map((t) => e.slice(t.start, t.end));
653
+ function we(e, t, n = {}) {
654
+ return Oe(e, t, n).map((t) => e.slice(t.start, t.end));
559
655
  }
560
- function he(e, t, n = {}) {
561
- return ve(e, t, n).length;
656
+ function Te(e, t, n = {}) {
657
+ return Oe(e, t, n).length;
562
658
  }
563
- function ge(e, t) {
659
+ function Ee(e, t) {
564
660
  return t.endsWith("\n") && e.pop(), e;
565
661
  }
566
- function _e(e) {
662
+ function De(e) {
567
663
  let t = [], n = 0;
568
664
  for (let r = 0; r <= e.length; r++) (r === e.length || e[r] === "\n") && (t.push({
569
665
  start: n,
570
666
  end: r
571
667
  }), n = r + 1);
572
- return ge(t, e);
668
+ return Ee(t, e);
573
669
  }
574
- function ve(e, t, n = {}) {
670
+ function Oe(e, t, n = {}) {
575
671
  if (!/[^ \t\r\f]/.test(e)) return [];
576
672
  let r = [], i = 0, a = n.firstLineIndent ?? 0;
577
- for (let o = 0; o <= e.length; o++) (o === e.length || e[o] === "\n") && (r.push(...Ee(e, i, o, t, n, a)), a = 0, i = o + 1);
578
- return ge(r, e);
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);
579
675
  }
580
- function ye(e, t, n) {
676
+ function ke(e, t, n) {
581
677
  if (!n) return t - e;
582
678
  let r = 0;
583
679
  for (let i = e; i < t; i++) r += n[i] ?? 1;
584
680
  return r;
585
681
  }
586
- function P(e, t, n, r = 0) {
587
- return t <= e ? 0 : ye(e, t, n) - Math.min(r, be(t - 1, n));
682
+ function I(e, t, n, r = 0) {
683
+ return t <= e ? 0 : ke(e, t, n) - Math.min(r, Ae(t - 1, n));
588
684
  }
589
- function be(e, t) {
685
+ function Ae(e, t) {
590
686
  return t ? (t[e] ?? 1) - 1 : 0;
591
687
  }
592
- function xe(e, t = {}) {
688
+ function je(e, t = {}) {
593
689
  let { advances: n, tracking: r = 0 } = t, i = 0;
594
- for (let t of Te(e, 0, e.length)) for (let a of Ce(e, t.start, t.end)) i = Math.max(i, P(a.start, a.end, n, r));
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));
595
691
  return i;
596
692
  }
597
- function Se(e, t) {
693
+ function Me(e, t) {
598
694
  let n = 0;
599
695
  for (let r = 0; r < e.length; r++) e[r] === "" && (t(r, n), n++);
600
696
  }
601
- function Ce(e, t, n) {
697
+ function Ne(e, t, n) {
602
698
  let r = [], i = t;
603
699
  for (let a = t; a < n; a++) {
604
700
  if (e[a] === "") {
@@ -625,14 +721,14 @@ function Ce(e, t, n) {
625
721
  end: n
626
722
  }), r;
627
723
  }
628
- var we = /[ \t\r\n\f]/;
629
- function Te(e, t, n) {
724
+ var Pe = /[ \t\r\n\f]/;
725
+ function Fe(e, t, n) {
630
726
  let r = [], i = t;
631
727
  for (; i < n;) {
632
- for (; i < n && we.test(e[i]);) i++;
728
+ for (; i < n && Pe.test(e[i]);) i++;
633
729
  if (i >= n) break;
634
730
  let t = i;
635
- for (; i < n && !we.test(e[i]);) i++;
731
+ for (; i < n && !Pe.test(e[i]);) i++;
636
732
  r.push({
637
733
  start: t,
638
734
  end: i
@@ -640,8 +736,8 @@ function Te(e, t, n) {
640
736
  }
641
737
  return r;
642
738
  }
643
- function Ee(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
644
- let s = Te(e, t, n);
739
+ function Ie(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
740
+ let s = Fe(e, t, n);
645
741
  if (s.length === 0) return [{
646
742
  start: t,
647
743
  end: t
@@ -653,13 +749,13 @@ function Ee(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
653
749
  let c = [], l = null, u = 0, d = Math.max(0, o), f = () => r - d;
654
750
  for (let t of s) {
655
751
  let n = !1;
656
- for (let r of Ce(e, t.start, t.end)) {
657
- let e = r.start, t = r.end, o = l !== null && !n ? e - 1 : e, s = u + ye(o, t, i), p = Math.min(a, be(t - 1, i));
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));
658
754
  if (l !== null && s - p <= f()) l.end = t, u = s;
659
755
  else {
660
756
  for (l !== null && (c.push(l), d = 0);;) {
661
757
  let n = e;
662
- for (; n < t && P(e, n + 1, i, a) <= f();) n++;
758
+ for (; n < t && I(e, n + 1, i, a) <= f();) n++;
663
759
  if (n === t || n === e) break;
664
760
  c.push({
665
761
  start: e,
@@ -669,7 +765,7 @@ function Ee(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
669
765
  l = {
670
766
  start: e,
671
767
  end: t
672
- }, u = ye(e, t, i);
768
+ }, u = ke(e, t, i);
673
769
  }
674
770
  n = !0;
675
771
  }
@@ -678,7 +774,7 @@ function Ee(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
678
774
  }
679
775
  //#endregion
680
776
  //#region src/flex.ts
681
- function De(e, t) {
777
+ function Le(e, t) {
682
778
  let n = e.row.map((e) => e.node.localRect).sort((e, t) => e.x - t.x), r = [];
683
779
  for (let e = 1; e < n.length; e++) {
684
780
  let i = n[e - 1].x + n[e - 1].width - t, a = n[e].x - t;
@@ -689,12 +785,12 @@ function De(e, t) {
689
785
  }
690
786
  return r;
691
787
  }
692
- function Oe(e, t, n, r, i) {
788
+ function Re(e, t, n, r, i) {
693
789
  if (e.style.ruleBreak !== "intersection") return [{
694
790
  start: 0,
695
791
  end: i
696
792
  }];
697
- let a = [t[n - 1], t[n]].flatMap((e) => De(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
793
+ let a = [t[n - 1], t[n]].flatMap((e) => Le(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
698
794
  start: e,
699
795
  end: t,
700
796
  spanned: !1,
@@ -702,24 +798,24 @@ function Oe(e, t, n, r, i) {
702
798
  afterOccupied: !0
703
799
  }), s = [], c = 0;
704
800
  for (let e of a) e.start > c && s.push(o(c, e.start)), c = Math.max(c, e.end);
705
- return c < i && s.push(o(c, i)), se(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
801
+ return c < i && s.push(o(c, i)), _e(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
706
802
  }
707
- function ke(e, t) {
803
+ function ze(e, t) {
708
804
  return typeof t != "number" || t <= 0 ? e : e.map((e) => ({
709
805
  ...e,
710
806
  start: e.start + t,
711
807
  end: e.end - t
712
808
  })).filter((e) => e.end > e.start);
713
809
  }
714
- function Ae(e, t, n, r, i, a, o) {
715
- let s = U(e.style, "x", t), c = U(e.style, "y", n), l = Re(e).map((e) => {
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) => {
716
812
  let n = G(e.style.margin, t);
717
813
  return {
718
814
  node: e,
719
- base: Le(e, t, o),
815
+ base: Je(e, t, o),
720
816
  grow: e.style.flexGrow,
721
817
  shrink: e.style.flexShrink,
722
- min: Ve(e, t, o),
818
+ min: Qe(e, t, o),
723
819
  max: K(e.style.maxWidth, t),
724
820
  margin: n
725
821
  };
@@ -733,7 +829,7 @@ function Ae(e, t, n, r, i, a, o) {
733
829
  n.length > 0 && u.push(n), e.style.wrapReverse && u.reverse();
734
830
  } else u.push(l);
735
831
  let d = i.left + a.left, f = i.top + a.top, p = u.map((e) => {
736
- 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))) : Fe(e, a);
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);
737
833
  for (let n = 0; n < e.length; n++) V(e[n].node, t, r, 0, 0, "fill", o, { width: u[n] });
738
834
  return {
739
835
  row: e,
@@ -744,17 +840,17 @@ function Ae(e, t, n, r, i, a, o) {
744
840
  }), m = p.map((e) => e.height), h = c * Math.max(0, p.length - 1), g;
745
841
  if (e.style.flexWrap === "nowrap") Number.isFinite(n) && (m[0] = Math.max(n, m[0] ?? 0)), g = [0];
746
842
  else {
747
- let t = m.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - h) : 0, i = ze(e.style);
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);
748
844
  if (i === "stretch" && r > 0) {
749
- let e = I(Array.from({ length: p.length }, () => 1), r);
845
+ let e = R(Array.from({ length: p.length }, () => 1), r);
750
846
  for (let t = 0; t < m.length; t++) m[t] += e[t];
751
- g = F("start", m, 0);
752
- } else g = F(i === "stretch" ? "start" : i, m, r);
847
+ g = L("start", m, 0);
848
+ } else g = L(i === "stretch" ? "start" : i, m, r);
753
849
  }
754
850
  for (let i = 0; i < p.length; i++) {
755
851
  let { row: a, widths: l, availableForItems: u } = p[i], h = m[i], _ = g[i] + i * c;
756
852
  for (let i = 0; i < a.length; i++) {
757
- let s = a[i].node, c = Ie(s, e), u = a[i].margin, d = u.top === null || u.bottom === null, f = s.style.height !== void 0 && s.style.height.kind !== "auto";
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";
758
854
  if (c === "stretch" && !d && !f && h > s.localRect.height) {
759
855
  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));
760
856
  if (d === s.localRect.height) continue;
@@ -766,17 +862,17 @@ function Ae(e, t, n, r, i, a, o) {
766
862
  }
767
863
  let v = l.reduce((e, t) => e + t, 0), y = Math.max(0, u - v), b = a.reduce((e, t) => e + +(t.margin.left === null) + +(t.margin.right === null), 0), x = Array.from({ length: a.length }, () => 0), S = Array.from({ length: a.length }, () => 0), C;
768
864
  if (b > 0 && y > 0) {
769
- let e = I(Array.from({ length: b }, () => 1), y), t = 0;
865
+ let e = R(Array.from({ length: b }, () => 1), y), t = 0;
770
866
  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++]);
771
- C = F("start", l, 0);
772
- } else C = F(Be(e.style), l, y);
867
+ C = L("start", l, 0);
868
+ } else C = L(Ze(e.style), l, y);
773
869
  let w = 0;
774
870
  for (let t = 0; t < a.length; t++) {
775
871
  let n = a[t], r = n.node, i = n.margin.left ?? 0, o = n.margin.right ?? 0;
776
872
  w += x[t] + i, r.localRect = {
777
873
  ...r.localRect,
778
874
  x: d + C[t] + t * s + w,
779
- y: f + _ + Ne(r, e.style.alignItems, h, n.margin)
875
+ y: f + _ + Ue(r, e.style.alignItems, h, n.margin)
780
876
  }, w += S[t] + o;
781
877
  }
782
878
  }
@@ -785,7 +881,7 @@ function Ae(e, t, n, r, i, a, o) {
785
881
  let n = [], r = [];
786
882
  for (let i = 0; i < p.length; i++) {
787
883
  let a = g[i] + i * c;
788
- for (let e of De(p[i], d)) n.push({
884
+ for (let e of Le(p[i], d)) n.push({
789
885
  bandStart: e.start,
790
886
  bandSize: e.end - e.start,
791
887
  start: a,
@@ -793,18 +889,19 @@ function Ae(e, t, n, r, i, a, o) {
793
889
  });
794
890
  if (i > 0) {
795
891
  let n = g[i - 1] + (i - 1) * c + m[i - 1];
796
- if (a > n) for (let o of Oe(e, p, i, d, t)) r.push({
892
+ if (a > n) for (let o of Re(e, p, i, d, t)) r.push({
797
893
  bandStart: n,
798
894
  bandSize: a - n,
799
895
  ...o
800
896
  });
801
897
  }
802
898
  }
803
- e.decorationRuns = ce({
899
+ e.decorationRuns = ve({
900
+ glyphs: S(e.style.glyphSet),
804
901
  ruleX: e.style.ruleX,
805
902
  ruleY: e.style.ruleY,
806
- vertical: ke(n, e.style.ruleInset),
807
- horizontal: ke(r, e.style.ruleInset),
903
+ vertical: ze(n, e.style.ruleInset),
904
+ horizontal: ze(r, e.style.ruleInset),
808
905
  contentWidth: t,
809
906
  contentHeight: v,
810
907
  border: i,
@@ -813,9 +910,9 @@ function Ae(e, t, n, r, i, a, o) {
813
910
  padding: a
814
911
  });
815
912
  }
816
- return je(e, i, a, t, v), v;
913
+ return Ve(e, i, a, t, v), v;
817
914
  }
818
- function je(e, t, n, r, i) {
915
+ function Ve(e, t, n, r, i) {
819
916
  for (let a of e.children) B(a.style) && (a.staticSlot = {
820
917
  kind: "flex",
821
918
  direction: e.style.flexDirection,
@@ -825,11 +922,11 @@ function je(e, t, n, r, i) {
825
922
  innerHeight: i
826
923
  });
827
924
  }
828
- function Me(e, t, n, r, i, a, o) {
829
- let s = U(e.style, "y", n), c = Re(e).map((i) => {
830
- let a = G(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = Ie(i, e) === "stretch";
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";
831
928
  V(i, s, r && Number.isFinite(n) ? n : void 0, 0, 0, c ? "fill" : "shrink", o);
832
- 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 ? de(u.value, l) : i.unclampedHeight, f = i.style.minHeight === "auto" ? i.style.overflow === "visible" ? i.localRect.height : 0 : void 0;
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;
833
930
  return {
834
931
  node: i,
835
932
  base: d,
@@ -839,31 +936,31 @@ function Me(e, t, n, r, i, a, o) {
839
936
  max: K(i.style.maxHeight, l),
840
937
  margin: a
841
938
  };
842
- }), 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) ? Fe(c, m) : c.map((e) => Math.max(0, H(e.base, e.min, e.max)));
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)));
843
940
  for (let n = 0; n < c.length; n++) if (g[n] !== c[n].node.localRect.height) {
844
- let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = Ie(r.node, e) === "stretch";
941
+ let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = Ke(r.node, e) === "stretch";
845
942
  V(r.node, i, g[n], 0, 0, a ? "fill" : "shrink", o, { height: g[n] });
846
943
  }
847
- 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), S;
944
+ 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;
848
945
  if (y > 0 && v > 0) {
849
- let e = I(Array.from({ length: y }, () => 1), v), t = 0;
946
+ let e = R(Array.from({ length: y }, () => 1), v), t = 0;
850
947
  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++]);
851
- S = F("start", g, 0);
852
- } else S = F(Be(e.style), g, v);
853
- let C = i.left + a.left, w = i.top + a.top, T = 0;
948
+ C = L("start", g, 0);
949
+ } else C = L(Ze(e.style), g, v);
950
+ let w = i.left + a.left, T = i.top + a.top, E = 0;
854
951
  for (let n = 0; n < c.length; n++) {
855
952
  let r = c[n], i = r.node, a = r.margin.top ?? 0, o = r.margin.bottom ?? 0;
856
- T += b[n] + a, i.localRect = {
953
+ E += b[n] + a, i.localRect = {
857
954
  ...i.localRect,
858
- x: C + Pe(i, e.style.alignItems, t, r.margin),
859
- y: w + S[n] + n * s + T
860
- }, T += x[n] + o;
955
+ x: w + We(i, e.style.alignItems, t, r.margin),
956
+ y: T + C[n] + n * s + E
957
+ }, E += x[n] + o;
861
958
  }
862
- let E = _ + l + u, D = d ? Math.max(n, E) : E;
959
+ let D = _ + l + u, O = d ? Math.max(n, D) : D;
863
960
  if (e.style.ruleY && c.length > 1) {
864
961
  let n = [], r = c.map((e) => e.node.localRect).slice().sort((e, t) => e.y - t.y);
865
962
  for (let e = 1; e < r.length; e++) {
866
- let i = r[e - 1].y + r[e - 1].height - w, a = r[e].y - w - i;
963
+ let i = r[e - 1].y + r[e - 1].height - T, a = r[e].y - T - i;
867
964
  a > 0 && n.push({
868
965
  bandStart: i,
869
966
  bandSize: a,
@@ -871,30 +968,31 @@ function Me(e, t, n, r, i, a, o) {
871
968
  end: t
872
969
  });
873
970
  }
874
- e.decorationRuns = ce({
971
+ e.decorationRuns = ve({
972
+ glyphs: S(e.style.glyphSet),
875
973
  ruleX: null,
876
974
  ruleY: e.style.ruleY,
877
975
  vertical: [],
878
- horizontal: ke(n, e.style.ruleInset),
976
+ horizontal: ze(n, e.style.ruleInset),
879
977
  contentWidth: t,
880
- contentHeight: D,
978
+ contentHeight: O,
881
979
  border: i,
882
980
  borderStyle: e.style.borderStyle,
883
981
  borderColor: e.style.borderColor,
884
982
  padding: a
885
983
  });
886
984
  }
887
- return je(e, i, a, t, D), D;
985
+ return Ve(e, i, a, t, O), O;
888
986
  }
889
- function Ne(e, t, n, r) {
987
+ function Ue(e, t, n, r) {
890
988
  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;
891
- return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + L(i, n, e.localRect.height);
989
+ return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + qe(i, n, e.localRect.height);
892
990
  }
893
- function Pe(e, t, n, r) {
991
+ function We(e, t, n, r) {
894
992
  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;
895
- return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + L(i, n, e.localRect.width);
993
+ return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + qe(i, n, e.localRect.width);
896
994
  }
897
- function F(e, t, n) {
995
+ function L(e, t, n) {
898
996
  let r = t.length;
899
997
  if (r === 0) return [];
900
998
  let i = [], a = 0;
@@ -904,7 +1002,7 @@ function F(e, t, n) {
904
1002
  return i;
905
1003
  }
906
1004
  if ((e === "space-around" || e === "space-evenly") && n > 0) {
907
- let o = I(Array.from({ length: r + 1 }, (t, n) => e === "space-evenly" || n === 0 || n === r ? 1 : 2), n);
1005
+ let o = R(Array.from({ length: r + 1 }, (t, n) => e === "space-evenly" || n === 0 || n === r ? 1 : 2), n);
908
1006
  for (let e = 0; e < r; e++) a += o[e], i.push(a), a += t[e];
909
1007
  return i;
910
1008
  }
@@ -912,7 +1010,7 @@ function F(e, t, n) {
912
1010
  for (let e = 0; e < r; e++) i.push(a), a += t[e];
913
1011
  return i;
914
1012
  }
915
- function Fe(e, t) {
1013
+ function Ge(e, t) {
916
1014
  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);
917
1015
  for (let t = 0; t < n; t++) {
918
1016
  let n = r(i[t], t);
@@ -922,7 +1020,7 @@ function Fe(e, t) {
922
1020
  let c = [];
923
1021
  for (let e = 0; e < n; e++) s[e] || c.push(e);
924
1022
  if (c.length === 0) break;
925
- let l = o.reduce((e, t, n) => s[n] ? e + t : e, 0), u = c.reduce((e, t) => e + i[t], 0), d = t - l - u, f = a ? Math.max(0, d) : Math.max(0, -d), p = I(c.map((t) => a ? e[t].grow : i[t] * e[t].shrink), f), m = c.map((e, t) => i[e] + (a ? p[t] : -p[t])), h = c.map((e, t) => r(m[t], e)), g = h.reduce((e, t, n) => e + (t - m[n]), 0);
1023
+ let l = o.reduce((e, t, n) => s[n] ? e + t : e, 0), u = c.reduce((e, t) => e + i[t], 0), d = t - l - u, f = a ? Math.max(0, d) : Math.max(0, -d), p = R(c.map((t) => a ? e[t].grow : i[t] * e[t].shrink), f), m = c.map((e, t) => i[e] + (a ? p[t] : -p[t])), h = c.map((e, t) => r(m[t], e)), g = h.reduce((e, t, n) => e + (t - m[n]), 0);
926
1024
  if (g === 0) {
927
1025
  for (let e = 0; e < c.length; e++) o[c[e]] = h[e];
928
1026
  break;
@@ -934,7 +1032,7 @@ function Fe(e, t) {
934
1032
  }
935
1033
  return o;
936
1034
  }
937
- function I(e, t) {
1035
+ function R(e, t) {
938
1036
  let n = e.reduce((e, t) => e + t, 0);
939
1037
  if (n === 0 || t <= 0) return e.map(() => 0);
940
1038
  let r = e.map((e) => e / n * t), i = r.map(Math.floor), a = t - i.reduce((e, t) => e + t, 0);
@@ -947,33 +1045,33 @@ function I(e, t) {
947
1045
  }
948
1046
  return i;
949
1047
  }
950
- function Ie(e, t) {
1048
+ function Ke(e, t) {
951
1049
  return e.style.alignSelf === "auto" ? t.style.alignItems : e.style.alignSelf;
952
1050
  }
953
- function L(e, t, n) {
1051
+ function qe(e, t, n) {
954
1052
  return e === "center" ? Math.max(0, Math.floor((t - n) / 2)) : e === "end" ? Math.max(0, t - n) : 0;
955
1053
  }
956
- function Le(e, t, n) {
1054
+ function Je(e, t, n) {
957
1055
  let r = e.style.flexBasis, i = e.style.width;
958
1056
  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);
959
1057
  }
960
- function Re(e) {
1058
+ function Ye(e) {
961
1059
  let t = e.children.filter((e) => !B(e.style)).sort((e, t) => e.style.order - t.style.order);
962
1060
  return e.style.flexReverse && t.reverse(), t;
963
1061
  }
964
- function ze(e) {
1062
+ function Xe(e) {
965
1063
  return e.wrapReverse ? e.alignContent === "start" ? "end" : e.alignContent === "end" ? "start" : e.alignContent : e.alignContent;
966
1064
  }
967
- function Be(e) {
1065
+ function Ze(e) {
968
1066
  let t = e.justifyContent === "stretch" ? "start" : e.justifyContent;
969
1067
  return e.flexReverse ? t === "start" ? "end" : t === "end" ? "start" : t : t;
970
1068
  }
971
- function Ve(e, t, n) {
1069
+ function Qe(e, t, n) {
972
1070
  return e.style.minWidth === "auto" ? e.style.overflow === "visible" ? Y(e, n) : 0 : K(e.style.minWidth, t) ?? 0;
973
1071
  }
974
1072
  //#endregion
975
1073
  //#region src/types.ts
976
- function He() {
1074
+ function $e() {
977
1075
  return {
978
1076
  display: "block",
979
1077
  flexDirection: "row",
@@ -992,8 +1090,8 @@ function He() {
992
1090
  justifySelf: "auto",
993
1091
  gridTemplateColumns: { kind: "none" },
994
1092
  gridTemplateRows: { kind: "none" },
995
- gridAutoColumns: [Ue()],
996
- gridAutoRows: [Ue()],
1093
+ gridAutoColumns: [et()],
1094
+ gridAutoRows: [et()],
997
1095
  gridAutoFlow: {
998
1096
  direction: "row",
999
1097
  dense: !1
@@ -1009,7 +1107,7 @@ function He() {
1009
1107
  minHeight: "auto",
1010
1108
  maxWidth: void 0,
1011
1109
  maxHeight: void 0,
1012
- padding: R(),
1110
+ padding: z(),
1013
1111
  margin: {
1014
1112
  top: 0,
1015
1113
  right: 0,
@@ -1025,7 +1123,7 @@ function He() {
1025
1123
  },
1026
1124
  gapX: 0,
1027
1125
  gapY: 0,
1028
- border: R(),
1126
+ border: z(),
1029
1127
  borderStyle: {
1030
1128
  top: "solid",
1031
1129
  right: "solid",
@@ -1060,6 +1158,7 @@ function He() {
1060
1158
  borderSpacingY: 0,
1061
1159
  captionSide: "top",
1062
1160
  verticalAlign: "start",
1161
+ glyphSet: null,
1063
1162
  opacity: 1,
1064
1163
  zIndex: null,
1065
1164
  latticeBorder: null,
@@ -1077,7 +1176,7 @@ function He() {
1077
1176
  breakInsideAvoid: !1
1078
1177
  };
1079
1178
  }
1080
- function R() {
1179
+ function z() {
1081
1180
  return {
1082
1181
  top: 0,
1083
1182
  right: 0,
@@ -1085,7 +1184,7 @@ function R() {
1085
1184
  left: 0
1086
1185
  };
1087
1186
  }
1088
- function Ue() {
1187
+ function et() {
1089
1188
  return {
1090
1189
  min: { kind: "auto" },
1091
1190
  max: { kind: "auto" }
@@ -1093,15 +1192,15 @@ function Ue() {
1093
1192
  }
1094
1193
  //#endregion
1095
1194
  //#region src/grid.ts
1096
- function We(e, t, n, r, i, a) {
1097
- 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 = et(e, t, s, u, d, e.subgrid ? {
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 ? {
1098
1197
  col: e.subgrid.colSpan,
1099
1198
  row: e.subgrid.rowSpan
1100
- } : 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)), S = p.map((e) => e.style.justifySelf === "auto" ? o.justifyItems : e.style.justifySelf), C = p.map(Ge), w = c ? qe(c) : gt(_, y, Je(f, C, x, a), t, u, o.justifyContent === "stretch"), T = c ? c.positions : _t(w, t, o.justifyContent), E = [];
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 = [];
1101
1200
  for (let e = 0; e < p.length; e++) {
1102
- let t = p[e], n = m.items[e], r = yt(T, w.sizes, n.col.start, n.col.span), i = x[e], o = Math.max(0, r - it(i)), s = C[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];
1103
1202
  if (s.cols || s.rows) {
1104
- let e = s.cols ? Ke(T, w, u, n.col.start, n.col.span, Xe(t, "cols", i, r)) : void 0;
1203
+ let e = s.cols ? rt(E, T, u, n.col.start, n.col.span, st(t, "cols", i, r)) : void 0;
1105
1204
  t.subgrid = {
1106
1205
  colSpan: n.col.span,
1107
1206
  rowSpan: n.row.span,
@@ -1109,32 +1208,32 @@ function We(e, t, n, r, i, a) {
1109
1208
  rows: void 0
1110
1209
  };
1111
1210
  } else t.subgrid = void 0;
1112
- let c = S[e], l = i.left === null || i.right === null, d = t.style.width !== void 0 && t.style.width.kind !== "auto";
1113
- 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, On(t.style.maxWidth, r, t, a)) }) : V(t, o, void 0, 0, 0, "shrink", a), E.push(t.localRect.width);
1211
+ 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);
1114
1213
  }
1115
- let D = l ? qe(l) : gt(v, b, Ye(f, C, x), s ?? "max-content", d, o.alignContent === "stretch"), ee = vt(D), O = l ? l.positions : _t(D, s ?? ee, o.alignContent), k = r.left + i.left, A = r.top + i.top;
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;
1116
1215
  for (let t = 0; t < p.length; t++) {
1117
- let n = p[t], r = m.items[t], i = x[t], o = yt(T, w.sizes, r.col.start, r.col.span), s = yt(O, D.sizes, r.row.start, r.row.span), c = Math.max(0, s - at(i)), l = Ie(n, e), u = i.top === null || i.bottom === null, f = n.style.height !== void 0 && n.style.height.kind !== "auto";
1118
- if (C[t].rows) n.subgrid.rows = Ke(O, D, d, r.row.start, r.row.span, Xe(n, "rows", i, o)), V(n, o, s, 0, 0, "fill", a, {
1119
- width: E[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, {
1218
+ width: D[t],
1120
1219
  height: c
1121
1220
  });
1122
1221
  else if (l === "stretch" && !u && !f) {
1123
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));
1124
1223
  e !== n.localRect.height && V(n, o, s, 0, 0, "fill", a, {
1125
- width: E[t],
1224
+ width: D[t],
1126
1225
  height: e
1127
1226
  });
1128
- } else n.style.height?.kind === "percent" && V(n, o, s, 0, 0, "fill", a, { width: E[t] });
1227
+ } else n.style.height?.kind === "percent" && V(n, o, s, 0, 0, "fill", a, { width: D[t] });
1129
1228
  n.localRect = {
1130
1229
  ...n.localRect,
1131
- x: k + T[r.col.start] + bt(S[t], i.left, i.right, o, n.localRect.width),
1132
- y: A + O[r.row.start] + bt(l, i.top, i.bottom, s, n.localRect.height)
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)
1133
1232
  };
1134
1233
  }
1135
- let j = Number.isFinite(n) ? Math.max(n, ee) : ee;
1234
+ let N = Number.isFinite(n) ? Math.max(n, k) : k;
1136
1235
  if (o.ruleX || o.ruleY) {
1137
- let n = w.sizes.length, a = D.sizes.length, s = Array.from({ length: n }, () => Array.from({ length: a }, () => !1)), c = Array.from({ length: Math.max(0, n - 1) }, () => Array.from({ length: a }, () => !1)), l = Array.from({ length: Math.max(0, a - 1) }, () => Array.from({ length: n }, () => !1));
1236
+ let n = T.sizes.length, a = O.sizes.length, s = Array.from({ length: n }, () => Array.from({ length: a }, () => !1)), c = Array.from({ length: Math.max(0, n - 1) }, () => Array.from({ length: a }, () => !1)), l = Array.from({ length: Math.max(0, a - 1) }, () => Array.from({ length: n }, () => !1));
1138
1237
  for (let e of m.items) for (let t = e.col.start; t < e.col.start + e.col.span && t < n; t++) for (let r = e.row.start; r < e.row.start + e.row.span && r < a; r++) s[t][r] = !0, t + 1 < e.col.start + e.col.span && t < n - 1 && (c[t][r] = !0), r + 1 < e.row.start + e.row.span && r < a - 1 && (l[r][t] = !0);
1139
1238
  let u = (e, t, n, r, i, a) => t.map((t, o) => ({
1140
1239
  start: t,
@@ -1146,47 +1245,48 @@ function We(e, t, n, r, i, a) {
1146
1245
  let r = [];
1147
1246
  for (let i = 1; i < e.length; i++) {
1148
1247
  let a = e[i - 1] + t[i - 1], s = e[i] - a;
1149
- if (!(s <= 0)) for (let e of se(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
1248
+ if (!(s <= 0)) for (let e of _e(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
1150
1249
  bandStart: a,
1151
1250
  bandSize: s,
1152
1251
  ...e
1153
1252
  });
1154
1253
  }
1155
1254
  return r;
1156
- }, f = d(T, w.sizes, (e) => u(e, O, D.sizes, c, (t) => s[e]?.[t] ?? !1, (t) => s[e + 1]?.[t] ?? !1)), p = d(O, D.sizes, (e) => u(e, T, w.sizes, l, (t) => s[t]?.[e] ?? !1, (t) => s[t]?.[e + 1] ?? !1));
1157
- e.decorationRuns = ce({
1255
+ }, 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({
1257
+ glyphs: S(o.glyphSet),
1158
1258
  ruleX: o.ruleX,
1159
1259
  ruleY: o.ruleY,
1160
1260
  vertical: f,
1161
1261
  horizontal: p,
1162
1262
  contentWidth: t,
1163
- contentHeight: j,
1263
+ contentHeight: N,
1164
1264
  border: r,
1165
1265
  borderStyle: o.borderStyle,
1166
1266
  borderColor: o.borderColor,
1167
1267
  padding: i
1168
1268
  });
1169
1269
  }
1170
- let te = e.children.filter((e) => B(e.style));
1171
- if (te.length > 0) {
1270
+ let ee = e.children.filter((e) => B(e.style));
1271
+ if (ee.length > 0) {
1172
1272
  let e = B(o) ? {
1173
1273
  x: r.left,
1174
1274
  y: r.top,
1175
1275
  width: i.left + t + i.right,
1176
- height: i.top + j + i.bottom
1276
+ height: i.top + N + i.bottom
1177
1277
  } : {
1178
- x: k,
1179
- y: A,
1278
+ x: j,
1279
+ y: M,
1180
1280
  width: t,
1181
- height: j
1281
+ height: N
1182
1282
  };
1183
- for (let n of te) {
1184
- let r = Qe(n.style.gridColumnStart, n.style.gridColumnEnd, h, m.colOrigin, T, w.sizes, -i.left, t + i.right), a = Qe(n.style.gridRowStart, n.style.gridRowEnd, g, m.rowOrigin, O, D.sizes, -i.top, j + i.bottom);
1283
+ 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);
1185
1285
  n.staticSlot = {
1186
1286
  kind: "grid",
1187
1287
  area: {
1188
- x: k + r.start,
1189
- y: A + a.start,
1288
+ x: j + r.start,
1289
+ y: M + a.start,
1190
1290
  width: Math.max(0, r.end - r.start),
1191
1291
  height: Math.max(0, a.end - a.start)
1192
1292
  },
@@ -1194,16 +1294,16 @@ function We(e, t, n, r, i, a) {
1194
1294
  };
1195
1295
  }
1196
1296
  }
1197
- return j;
1297
+ return N;
1198
1298
  }
1199
- function Ge(e) {
1299
+ function nt(e) {
1200
1300
  let t = e.style.display === "grid";
1201
1301
  return {
1202
1302
  cols: t && e.style.gridTemplateColumns.kind === "subgrid",
1203
1303
  rows: t && e.style.gridTemplateRows.kind === "subgrid"
1204
1304
  };
1205
1305
  }
1206
- function Ke(e, t, n, r, i, a) {
1306
+ function rt(e, t, n, r, i, a) {
1207
1307
  let o = e[r] + a.start, s = t.sizes.slice(r, r + i);
1208
1308
  return s[0] = Math.max(0, s[0] - a.start), s[i - 1] = Math.max(0, s[i - 1] - a.end), {
1209
1309
  positions: Array.from({ length: i }, (t, n) => n === 0 ? 0 : e[r + n] - o),
@@ -1212,20 +1312,20 @@ function Ke(e, t, n, r, i, a) {
1212
1312
  gap: n
1213
1313
  };
1214
1314
  }
1215
- function qe(e) {
1315
+ function it(e) {
1216
1316
  return {
1217
1317
  sizes: e.sizes,
1218
1318
  gapBefore: e.gapBefore,
1219
1319
  limits: e.sizes
1220
1320
  };
1221
1321
  }
1222
- function Je(e, t, n, r) {
1322
+ function at(e, t, n, r) {
1223
1323
  let i = [];
1224
1324
  return e.children.forEach((a, o) => {
1225
1325
  let s = e.placed.items[o], c = n[o];
1226
1326
  if (t[o].cols) {
1227
- let e = Xe(a, "cols", c, 0);
1228
- for (let t of Ze(a, "cols", s, e, r)) i.push({
1327
+ let e = st(a, "cols", c, 0);
1328
+ for (let t of ct(a, "cols", s, e, r)) i.push({
1229
1329
  ...t,
1230
1330
  start: t.start + s.col.start
1231
1331
  });
@@ -1234,24 +1334,24 @@ function Je(e, t, n, r) {
1234
1334
  i.push({
1235
1335
  start: s.col.start,
1236
1336
  span: s.col.span,
1237
- min: ot(a, "min", r) + it(c),
1238
- max: ot(a, "max", r) + it(c)
1337
+ min: _t(a, "min", r) + ht(c),
1338
+ max: _t(a, "max", r) + ht(c)
1239
1339
  });
1240
1340
  }), i;
1241
1341
  }
1242
- function Ye(e, t, n) {
1342
+ function ot(e, t, n) {
1243
1343
  let r = [];
1244
1344
  return e.children.forEach((i, a) => {
1245
1345
  let o = e.placed.items[a], s = n[a];
1246
1346
  if (t[a].rows) {
1247
- let e = Xe(i, "rows", s, 0);
1248
- for (let t of Ze(i, "rows", o, e)) r.push({
1347
+ let e = st(i, "rows", s, 0);
1348
+ for (let t of ct(i, "rows", o, e)) r.push({
1249
1349
  ...t,
1250
1350
  start: t.start + o.row.start
1251
1351
  });
1252
1352
  return;
1253
1353
  }
1254
- let c = i.localRect.height + at(s);
1354
+ let c = i.localRect.height + gt(s);
1255
1355
  r.push({
1256
1356
  start: o.row.start,
1257
1357
  span: o.row.span,
@@ -1260,7 +1360,7 @@ function Ye(e, t, n) {
1260
1360
  });
1261
1361
  }), r;
1262
1362
  }
1263
- function Xe(e, t, n, r) {
1363
+ function st(e, t, n, r) {
1264
1364
  let { border: i, padding: a } = e.style;
1265
1365
  return t === "cols" ? {
1266
1366
  start: (n.left ?? 0) + i.left + W(a.left, r),
@@ -1270,15 +1370,15 @@ function Xe(e, t, n, r) {
1270
1370
  end: (n.bottom ?? 0) + i.bottom + W(a.bottom, r)
1271
1371
  };
1272
1372
  }
1273
- function Ze(e, t, n, r, i) {
1274
- let a = t === "cols" ? n.col.span : n.row.span, o = et(e, void 0, void 0, 0, 0, {
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, {
1275
1375
  col: n.col.span,
1276
1376
  row: n.row.span
1277
1377
  }), s = [];
1278
1378
  if (o.children.forEach((e, n) => {
1279
1379
  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);
1280
- if (Ge(e)[t]) {
1281
- let n = Xe(e, t, p, 0), a = Ze(e, t, c, {
1380
+ if (nt(e)[t]) {
1381
+ let n = st(e, t, p, 0), a = ct(e, t, c, {
1282
1382
  start: n.start + (u ? r.start : 0),
1283
1383
  end: n.end + (d ? r.end : 0)
1284
1384
  }, i);
@@ -1291,11 +1391,11 @@ function Ze(e, t, n, r, i) {
1291
1391
  if (t === "cols") s.push({
1292
1392
  start: l.start,
1293
1393
  span: l.span,
1294
- min: ot(e, "min", i) + it(p) + f,
1295
- max: ot(e, "max", i) + it(p) + f
1394
+ min: _t(e, "min", i) + ht(p) + f,
1395
+ max: _t(e, "max", i) + ht(p) + f
1296
1396
  });
1297
1397
  else {
1298
- let t = e.localRect.height + at(p) + f;
1398
+ let t = e.localRect.height + gt(p) + f;
1299
1399
  s.push({
1300
1400
  start: l.start,
1301
1401
  span: l.span,
@@ -1314,9 +1414,9 @@ function Ze(e, t, n, r, i) {
1314
1414
  }
1315
1415
  return s;
1316
1416
  }
1317
- function Qe(e, t, n, r, i, a, o, s) {
1318
- let c = ft(e, "start", n), l = ft(t, "end", n);
1319
- c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = pt(c, t, 1, n) : l !== null && e.kind === "span" && (c = pt(l, e, -1, n));
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));
1320
1420
  let u = i.length, d = (e) => {
1321
1421
  if (e === null) return;
1322
1422
  let t = e - r;
@@ -1327,22 +1427,22 @@ function Qe(e, t, n, r, i, a, o, s) {
1327
1427
  end: h === void 0 ? s : p(h)
1328
1428
  };
1329
1429
  }
1330
- function $e(e, t) {
1430
+ function ut(e, t) {
1331
1431
  let n = t.gridIntrinsic.get(e);
1332
1432
  if (n !== void 0) return n;
1333
- let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = et(e, void 0, void 0, i, 0, e.subgrid ? {
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 ? {
1334
1434
  col: e.subgrid.colSpan,
1335
1435
  row: e.subgrid.rowSpan
1336
- } : void 0), o = a.children.map(Ge), s = a.children.map((e) => G(e.style.margin, 0)), c = gt(a.colTracks, a.colCollapsed, Je(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
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 = {
1337
1437
  min: c.sizes.reduce((e, t) => e + t, 0) + l,
1338
1438
  max: c.limits.reduce((e, t) => e + t, 0) + l
1339
1439
  };
1340
1440
  return t.gridIntrinsic.set(e, u), u;
1341
1441
  }
1342
- function et(e, t, n, r, i, a) {
1343
- let o = e.style, s = rt(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? tt(a.col) : st(o.gridTemplateColumns, t, r), d = l ? tt(a.row) : st(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
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];
1344
1444
  if (f) {
1345
- c || lt(p, u.lineNames, f.columns, o.gridAutoColumns), l || lt(m, d.lineNames, f.rows, o.gridAutoRows);
1445
+ c || bt(p, u.lineNames, f.columns, o.gridAutoColumns), l || bt(m, d.lineNames, f.rows, o.gridAutoRows);
1346
1446
  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`);
1347
1447
  }
1348
1448
  let h = {
@@ -1351,28 +1451,28 @@ function et(e, t, n, r, i, a) {
1351
1451
  }, g = {
1352
1452
  explicitCount: m.length,
1353
1453
  names: d.lineNames
1354
- }, _ = ht(s.map((e) => ({
1355
- col: mt(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1356
- row: mt(e.style.gridRowStart, e.style.gridRowEnd, g)
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)
1357
1457
  })), p.length, m.length, o.gridAutoFlow);
1358
- return c && nt(_, "col", p.length), l && nt(_, "row", m.length), {
1458
+ return c && pt(_, "col", p.length), l && pt(_, "row", m.length), {
1359
1459
  children: s,
1360
1460
  placed: _,
1361
1461
  colLines: h,
1362
1462
  rowLines: g,
1363
- colTracks: ut(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1364
- rowTracks: ut(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1365
- colCollapsed: dt(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1366
- rowCollapsed: dt(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
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))
1367
1467
  };
1368
1468
  }
1369
- function tt(e) {
1469
+ function ft(e) {
1370
1470
  return {
1371
- tracks: Array.from({ length: e }, () => Ue()),
1471
+ tracks: Array.from({ length: e }, () => et()),
1372
1472
  lineNames: Array.from({ length: e + 1 }, () => [])
1373
1473
  };
1374
1474
  }
1375
- function nt(e, t, n) {
1475
+ function pt(e, t, n) {
1376
1476
  let r = t === "col" ? e.colOrigin : e.rowOrigin;
1377
1477
  for (let i of e.items) {
1378
1478
  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);
@@ -1380,22 +1480,22 @@ function nt(e, t, n) {
1380
1480
  }
1381
1481
  t === "col" ? (e.colOrigin = 0, e.colCount = n) : (e.rowOrigin = 0, e.rowCount = n);
1382
1482
  }
1383
- function rt(e) {
1483
+ function mt(e) {
1384
1484
  return e.children.filter((e) => !B(e.style) && !e.inlineBox).sort((e, t) => e.style.order - t.style.order);
1385
1485
  }
1386
- function it(e) {
1486
+ function ht(e) {
1387
1487
  return (e.left ?? 0) + (e.right ?? 0);
1388
1488
  }
1389
- function at(e) {
1489
+ function gt(e) {
1390
1490
  return (e.top ?? 0) + (e.bottom ?? 0);
1391
1491
  }
1392
- function ot(e, t, n) {
1492
+ function _t(e, t, n) {
1393
1493
  let r = e.style, i;
1394
1494
  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));
1395
1495
  let a = typeof r.minWidth == "number" ? r.minWidth : 0, o = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
1396
1496
  return Math.max(0, H(i, a, o));
1397
1497
  }
1398
- function st(e, t, n) {
1498
+ function vt(e, t, n) {
1399
1499
  if (e.kind !== "tracks") return {
1400
1500
  tracks: [],
1401
1501
  lineNames: [[]]
@@ -1408,7 +1508,7 @@ function st(e, t, n) {
1408
1508
  let { index: i, tracks: a, mode: o } = e.autoRepeat, s = 1;
1409
1509
  if (t !== void 0) {
1410
1510
  let e = a.reduce((e, n) => {
1411
- let r = ct(n.min, t) ?? ct(n.max, t) ?? 1;
1511
+ let r = yt(n.min, t) ?? yt(n.max, t) ?? 1;
1412
1512
  return e + Math.max(1, r);
1413
1513
  }, 0);
1414
1514
  s = Math.max(1, Math.floor((t + n) / (e + n * a.length)));
@@ -1436,23 +1536,23 @@ function st(e, t, n) {
1436
1536
  lineNames: d
1437
1537
  };
1438
1538
  }
1439
- function ct(e, t) {
1539
+ function yt(e, t) {
1440
1540
  if (e.kind === "cells") return e.value;
1441
- if (e.kind === "percent" && t !== void 0) return de(e.value, t);
1541
+ if (e.kind === "percent" && t !== void 0) return xe(e.value, t);
1442
1542
  if (e.kind === "math") {
1443
1543
  let n = [];
1444
1544
  for (let r of e.args) {
1445
- let e = ct(r, t);
1545
+ let e = yt(r, t);
1446
1546
  if (e === void 0) return;
1447
1547
  n.push(e);
1448
1548
  }
1449
1549
  return e.fn === "min" ? Math.min(...n) : Math.max(...n);
1450
1550
  }
1451
1551
  }
1452
- function lt(e, t, n, r) {
1552
+ function bt(e, t, n, r) {
1453
1553
  for (let i = e.length; i < n; i++) e.push(r[(i - e.length) % r.length]), t.push([]);
1454
1554
  }
1455
- function ut(e, t, n, r) {
1555
+ function xt(e, t, n, r) {
1456
1556
  let i = [];
1457
1557
  for (let a = 0; a < n; a++) {
1458
1558
  let n = a + t;
@@ -1464,7 +1564,7 @@ function ut(e, t, n, r) {
1464
1564
  }
1465
1565
  return i;
1466
1566
  }
1467
- function dt(e, t, n, r) {
1567
+ function St(e, t, n, r) {
1468
1568
  let i = Array.from({ length: n }, () => !1);
1469
1569
  if (!e.autoFit) return i;
1470
1570
  for (let a = e.autoFit.start; a < e.autoFit.end; a++) {
@@ -1473,7 +1573,7 @@ function dt(e, t, n, r) {
1473
1573
  }
1474
1574
  return i;
1475
1575
  }
1476
- function ft(e, t, n) {
1576
+ function Ct(e, t, n) {
1477
1577
  if (e.kind === "line") return e.value > 0 ? e.value - 1 : n.explicitCount + 1 + e.value;
1478
1578
  if (e.kind !== "name") return null;
1479
1579
  if (e.nth === void 0) {
@@ -1488,14 +1588,14 @@ function ft(e, t, n) {
1488
1588
  for (let t = i; t >= 0; t--) if (n.names[t].includes(e.name) && ++a === -r) return t;
1489
1589
  return -(-r - a);
1490
1590
  }
1491
- function pt(e, t, n, r) {
1591
+ function wt(e, t, n, r) {
1492
1592
  if (t.name === void 0) return e + n * t.value;
1493
1593
  let i = t.value, a = e;
1494
1594
  for (; i > 0;) a += n, (!(a >= 0 && a <= r.explicitCount) || r.names[a].includes(t.name)) && i--;
1495
1595
  return a;
1496
1596
  }
1497
- function mt(e, t, n) {
1498
- let r = ft(e, "start", n), i = ft(t, "end", n);
1597
+ function Tt(e, t, n) {
1598
+ let r = Ct(e, "start", n), i = Ct(t, "end", n);
1499
1599
  if (r !== null && i !== null) return r === i ? {
1500
1600
  start: r,
1501
1601
  span: 1
@@ -1505,10 +1605,10 @@ function mt(e, t, n) {
1505
1605
  };
1506
1606
  if (r !== null) return {
1507
1607
  start: r,
1508
- span: (t.kind === "span" ? pt(r, t, 1, n) : r + 1) - r
1608
+ span: (t.kind === "span" ? wt(r, t, 1, n) : r + 1) - r
1509
1609
  };
1510
1610
  if (i !== null) {
1511
- let t = e.kind === "span" ? pt(i, e, -1, n) : i - 1;
1611
+ let t = e.kind === "span" ? wt(i, e, -1, n) : i - 1;
1512
1612
  return {
1513
1613
  start: t,
1514
1614
  span: i - t
@@ -1519,7 +1619,7 @@ function mt(e, t, n) {
1519
1619
  span: e.kind === "span" ? e.value : t.kind === "span" ? t.value : 1
1520
1620
  };
1521
1621
  }
1522
- function ht(e, t, n, r) {
1622
+ function Et(e, t, n, r) {
1523
1623
  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);
1524
1624
  for (let t = 0; t < e.length; t++) {
1525
1625
  let e = o[t];
@@ -1616,7 +1716,7 @@ function ht(e, t, n, r) {
1616
1716
  rowCount: S
1617
1717
  };
1618
1718
  }
1619
- function gt(e, t, n, r, i, a) {
1719
+ function Dt(e, t, n, r, i, a) {
1620
1720
  let o = typeof r == "number" ? r : void 0, s = e.map((e, n) => {
1621
1721
  if (t[n]) return {
1622
1722
  base: 0,
@@ -1626,7 +1726,7 @@ function gt(e, t, n, r, i, a) {
1626
1726
  frFactor: 0,
1627
1727
  collapsed: !0
1628
1728
  };
1629
- let r = ct(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1729
+ let r = yt(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1630
1730
  if (s.kind === "fr") return {
1631
1731
  base: i,
1632
1732
  limit: null,
@@ -1635,7 +1735,7 @@ function gt(e, t, n, r, i, a) {
1635
1735
  frFactor: s.value,
1636
1736
  collapsed: !1
1637
1737
  };
1638
- let c = ct(s, o);
1738
+ let c = yt(s, o);
1639
1739
  return c === void 0 ? {
1640
1740
  base: i,
1641
1741
  limit: null,
@@ -1669,7 +1769,7 @@ function gt(e, t, n, r, i, a) {
1669
1769
  if (n.length === 0) continue;
1670
1770
  let i = t.reduce((e, t) => e + t.base, 0) + r, a = e.min - i;
1671
1771
  if (a > 0) {
1672
- let e = n.reduce((e, t) => e + t.frFactor, 0), t = I(n.map((t) => e > 0 ? t.frFactor : 1), a);
1772
+ let e = n.reduce((e, t) => e + t.frFactor, 0), t = R(n.map((t) => e > 0 ? t.frFactor : 1), a);
1673
1773
  n.forEach((e, n) => {
1674
1774
  e.base += t[n];
1675
1775
  });
@@ -1680,7 +1780,7 @@ function gt(e, t, n, r, i, a) {
1680
1780
  if (i.length > 0) {
1681
1781
  let n = t.reduce((e, t) => e + t.base, 0) + r, a = e.min - n;
1682
1782
  if (a > 0) {
1683
- let e = I(i.map(() => 1), a);
1783
+ let e = R(i.map(() => 1), a);
1684
1784
  i.forEach((t, n) => {
1685
1785
  t.base += e[n];
1686
1786
  });
@@ -1691,7 +1791,7 @@ function gt(e, t, n, r, i, a) {
1691
1791
  if (e.length === 0) continue;
1692
1792
  let a = i - (t.reduce((e, t) => e + u(t), 0) + r);
1693
1793
  if (a > 0) {
1694
- let t = I(e.map(() => 1), a);
1794
+ let t = R(e.map(() => 1), a);
1695
1795
  e.forEach((e, n) => {
1696
1796
  e.limit = u(e) + t[n];
1697
1797
  });
@@ -1713,7 +1813,7 @@ function gt(e, t, n, r, i, a) {
1713
1813
  n <= 0 || (t = Math.max(t, (e.max - r) / Math.max(n, 1)));
1714
1814
  }
1715
1815
  for (let n of e) {
1716
- let e = Math.max(n.base, M(n.frFactor * t));
1816
+ let e = Math.max(n.base, P(n.frFactor * t));
1717
1817
  n.limit = e, r === "max-content" && (n.base = e);
1718
1818
  }
1719
1819
  }
@@ -1723,7 +1823,7 @@ function gt(e, t, n, r, i, a) {
1723
1823
  for (; !(t <= 0);) {
1724
1824
  let e = s.filter((e) => !e.collapsed && e.limitKind !== "fr" && e.base < u(e));
1725
1825
  if (e.length === 0) break;
1726
- let n = I(e.map(() => 1), t), r = 0;
1826
+ let n = R(e.map(() => 1), t), r = 0;
1727
1827
  if (e.forEach((e, t) => {
1728
1828
  let i = Math.min(n[t], u(e) - e.base);
1729
1829
  e.base += i, r += i;
@@ -1733,7 +1833,7 @@ function gt(e, t, n, r, i, a) {
1733
1833
  if (n.length > 0) {
1734
1834
  let t = Math.max(0, o - e - s.reduce((e, t) => e + (t.limitKind === "fr" ? 0 : t.base), 0)), r = n, i = t, a = n.reduce((e, t) => e + t.frFactor, 0);
1735
1835
  for (a < 1 && (i = Math.floor(i * a));;) {
1736
- let e = I(r.map((e) => e.frFactor), i), t = r.filter((t, n) => e[n] < t.base);
1836
+ let e = R(r.map((e) => e.frFactor), i), t = r.filter((t, n) => e[n] < t.base);
1737
1837
  if (t.length === 0) {
1738
1838
  r.forEach((t, n) => {
1739
1839
  t.base = Math.max(t.base, e[n]);
@@ -1747,7 +1847,7 @@ function gt(e, t, n, r, i, a) {
1747
1847
  if (a) {
1748
1848
  let t = o - e - s.reduce((e, t) => e + t.base, 0), n = s.filter((e) => !e.collapsed && e.limitKind === "intrinsic-max");
1749
1849
  if (t > 0 && n.length > 0) {
1750
- let e = I(n.map(() => 1), t);
1850
+ let e = R(n.map(() => 1), t);
1751
1851
  n.forEach((t, n) => {
1752
1852
  t.base += e[n];
1753
1853
  });
@@ -1760,65 +1860,65 @@ function gt(e, t, n, r, i, a) {
1760
1860
  limits: s.map((e) => u(e))
1761
1861
  };
1762
1862
  }
1763
- function _t(e, t, n) {
1764
- let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - vt(e)), o = F(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
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;
1765
1865
  for (let e = 0; e < r.length; e++) c += i[e], s.push(o[e] + c);
1766
1866
  return s;
1767
1867
  }
1768
- function vt(e) {
1868
+ function kt(e) {
1769
1869
  return e.sizes.reduce((e, t) => e + t, 0) + e.gapBefore.reduce((e, t) => e + t, 0);
1770
1870
  }
1771
- function yt(e, t, n, r) {
1871
+ function At(e, t, n, r) {
1772
1872
  let i = n + r - 1;
1773
1873
  return e[n] === void 0 || e[i] === void 0 ? 0 : e[i] + t[i] - e[n];
1774
1874
  }
1775
- function bt(e, t, n, r, i) {
1875
+ function jt(e, t, n, r, i) {
1776
1876
  let a = t ?? 0, o = n ?? 0, s = r - i;
1777
- return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + L(e, r, i + a + o);
1877
+ return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + qe(e, r, i + a + o);
1778
1878
  }
1779
1879
  //#endregion
1780
1880
  //#region src/multicol.ts
1781
- function xt(e, t, n) {
1881
+ function Mt(e, t, n) {
1782
1882
  let r = e.columnWidth === null ? null : Math.max(1, Math.floor((t + n) / (e.columnWidth + n)));
1783
1883
  return e.columnCount !== null && r !== null ? Math.max(1, Math.min(e.columnCount, r)) : r === null ? Math.max(1, e.columnCount ?? 1) : r;
1784
1884
  }
1785
- function St(e, t, n) {
1786
- let r = xt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r)), a = Math.max(0, t - (r * i + (r - 1) * n));
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));
1787
1887
  return Array.from({ length: r }, (e, t) => i + +(t < a));
1788
1888
  }
1789
- function Ct(e, t) {
1889
+ function Pt(e, t) {
1790
1890
  let n = Math.max(typeof e.gapX == "number" ? e.gapX : 0, e.ruleX?.width ?? 0);
1791
1891
  return e.columnCount === null ? Math.max(e.columnWidth ?? 1, t) : e.columnCount * t + (e.columnCount - 1) * n;
1792
1892
  }
1793
- function wt(e, t) {
1893
+ function Ft(e, t) {
1794
1894
  return e === void 0 ? t : t === void 0 ? e : Math.min(e, t);
1795
1895
  }
1796
- function Tt(e, t, n) {
1896
+ function It(e, t, n) {
1797
1897
  for (; e < t;) {
1798
1898
  let r = e + t >> 1;
1799
1899
  n(r) ? t = r : e = r + 1;
1800
1900
  }
1801
1901
  return e;
1802
1902
  }
1803
- function Et(e, t, n) {
1804
- let r = xt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1903
+ function Lt(e, t, n) {
1904
+ let r = Mt(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1805
1905
  return {
1806
1906
  count: r,
1807
1907
  width: i,
1808
1908
  leftover: Math.max(0, t - (r * i + (r - 1) * n))
1809
1909
  };
1810
1910
  }
1811
- function Dt(e, t, n) {
1911
+ function Rt(e, t, n) {
1812
1912
  return e === "all" ? !0 : e === "around" ? t || n : t && n;
1813
1913
  }
1814
- function Ot(e, t, n, r) {
1815
- let i = Tn(e, Math.max(1, t.width - e.style.tracking)), { heights: a, textOffsets: o } = En(e, i), s = e.style.lineGap, c = kt(a.map((e) => e + s)), l;
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;
1816
1916
  if (e.style.columnFill === "auto" && r !== void 0) l = Math.max(1, r);
1817
1917
  else {
1818
- let e = Tt(c.reduce((e, t) => Math.max(e, t.rows - s), 1), Math.max(1, c.reduce((e, t) => e + t.rows, 0) - s), (e) => z(c, s, e).columns <= t.count);
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);
1819
1919
  l = r === void 0 ? e : Math.max(1, Math.min(e, r));
1820
1920
  }
1821
- let u = z(c, s, l);
1921
+ let u = Bt(c, s, l);
1822
1922
  return {
1823
1923
  spans: i,
1824
1924
  lineY: u.top,
@@ -1831,7 +1931,7 @@ function Ot(e, t, n, r) {
1831
1931
  columnsUsed: i.length > 0 ? u.columns : 0
1832
1932
  };
1833
1933
  }
1834
- function z(e, t, n, r = "truncate") {
1934
+ function Bt(e, t, n, r = "truncate") {
1835
1935
  let i = 0, a = 0, o = 0, s = [], c = [];
1836
1936
  for (let l = 0; l < e.length; l++) {
1837
1937
  let u = e[l], d = r === "glue" || l === 0 || a > 0 ? u.pre : 0;
@@ -1852,7 +1952,7 @@ function z(e, t, n, r = "truncate") {
1852
1952
  top: c
1853
1953
  };
1854
1954
  }
1855
- function kt(e) {
1955
+ function Vt(e) {
1856
1956
  return e.map((e) => ({
1857
1957
  rows: e,
1858
1958
  pre: 0,
@@ -1861,27 +1961,27 @@ function kt(e) {
1861
1961
  lines: 1
1862
1962
  }));
1863
1963
  }
1864
- var At = null;
1865
- function jt() {
1866
- if (At !== null) return At;
1964
+ var Ht = null;
1965
+ function Ut() {
1966
+ if (Ht !== null) return Ht;
1867
1967
  let e = document.createElement("div");
1868
1968
  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);
1869
1969
  let t = e.getBoundingClientRect().top, n = e.querySelector("span").getBoundingClientRect();
1870
- return e.remove(), At = !(n.width > 0 && n.top - t >= 10), At;
1970
+ return e.remove(), Ht = !(n.width > 0 && n.top - t >= 10), Ht;
1871
1971
  }
1872
- function Mt(e, t) {
1873
- 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 = ve(e, Math.max(1, n - i), {
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), {
1874
1974
  advances: s,
1875
1975
  tracking: i,
1876
1976
  firstLineIndent: t.firstLineIndent
1877
- }), l = kt(c.map(() => 1 + a)), u = z(l, a, o ?? Tt(1, Math.max(1, c.length * (1 + a) - a), (e) => z(l, a, e).columns <= r));
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));
1878
1978
  return c.map((t, n) => ({
1879
1979
  text: e.slice(t.start, t.end),
1880
1980
  column: u.column[n],
1881
1981
  top: u.top[n]
1882
1982
  }));
1883
1983
  }
1884
- function Nt(e, t, n, r) {
1984
+ function Gt(e, t, n, r) {
1885
1985
  let i = e.style;
1886
1986
  if (!i.ruleX) return;
1887
1987
  let a = t.columnCount * t.columnWidth + (t.columnCount - 1) * t.gap, o = t.ruleSegments ?? [{
@@ -1891,17 +1991,18 @@ function Nt(e, t, n, r) {
1891
1991
  }], s = [];
1892
1992
  for (let e of o) {
1893
1993
  let n = Math.min(e.columns, t.columnCount);
1894
- for (let r = 0; r < t.columnCount - 1; r++) Dt(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
1994
+ for (let r = 0; r < t.columnCount - 1; r++) Rt(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
1895
1995
  bandStart: (r + 1) * t.columnWidth + r * t.gap,
1896
1996
  bandSize: t.gap,
1897
1997
  start: e.start,
1898
1998
  end: e.end
1899
1999
  });
1900
2000
  }
1901
- e.decorationRuns = ce({
2001
+ e.decorationRuns = ve({
2002
+ glyphs: S(i.glyphSet),
1902
2003
  ruleX: i.ruleX,
1903
2004
  ruleY: null,
1904
- vertical: ke(s, i.ruleInset),
2005
+ vertical: ze(s, i.ruleInset),
1905
2006
  horizontal: [],
1906
2007
  contentWidth: a,
1907
2008
  contentHeight: t.totalRows,
@@ -1911,12 +2012,12 @@ function Nt(e, t, n, r) {
1911
2012
  padding: r
1912
2013
  });
1913
2014
  }
1914
- function Pt(e, t) {
2015
+ function Kt(e, t) {
1915
2016
  let n = e.style, r = n.padding;
1916
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;
1917
2018
  }
1918
- function Ft(e, t, n, r, i, a, o) {
1919
- let s = e.style, c = U(s, "x", n), l = Et(s, n, c);
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);
1920
2021
  a.right += l.leftover;
1921
2022
  let u = s.lineGap, d = i.left + a.left, f = i.top + a.top, p = n - l.leftover, m = [[]], h = [];
1922
2023
  for (let e of t) e.style.columnSpan ? (h[m.length - 1] = e, m.push([])) : m[m.length - 1].push(e);
@@ -1926,13 +2027,13 @@ function Ft(e, t, n, r, i, a, o) {
1926
2027
  if (t.length > 0) {
1927
2028
  let i = t.map((e) => ({
1928
2029
  node: e,
1929
- spans: Tn(e, Math.max(1, l.width - e.style.tracking)),
2030
+ spans: Ln(e, Math.max(1, l.width - e.style.tracking)),
1930
2031
  margin: G(e.style.margin, l.width),
1931
2032
  pre: 0,
1932
2033
  post: 0
1933
2034
  })), a = [], o = null, h = null, x = !1;
1934
2035
  for (let e of i) {
1935
- let { node: t, spans: n, margin: r } = e, i = o === null ? r.top ?? 0 : jn(o, r.top ?? 0), s = i;
2036
+ let { node: t, spans: n, margin: r } = e, i = o === null ? r.top ?? 0 : Un(o, r.top ?? 0), s = i;
1936
2037
  _ === "glue" && h !== null ? (s = 0, h.post = i, a[a.length - 1].post = i) : e.pre = i;
1937
2038
  let c = x || t.style.breakBeforeColumn;
1938
2039
  if (t.style.breakInsideAvoid && n.length > 0) a.push({
@@ -1955,10 +2056,10 @@ function Ft(e, t, n, r, i, a, o) {
1955
2056
  let S;
1956
2057
  if (s.columnFill === "auto" && r !== void 0) S = Math.max(1, r);
1957
2058
  else {
1958
- let e = Tt(1, Math.max(1, z(a, u, Infinity, _).maxUsed), (e) => z(a, u, e, _).columns <= l.count);
2059
+ let e = It(1, Math.max(1, Bt(a, u, Infinity, _).maxUsed), (e) => Bt(a, u, e, _).columns <= l.count);
1959
2060
  S = r === void 0 ? e : Math.max(1, Math.min(e, r));
1960
2061
  }
1961
- let C = z(a, u, S, _);
2062
+ let C = Bt(a, u, S, _);
1962
2063
  for (let e = 0, t = 0; e < i.length; e++) {
1963
2064
  let { node: n, spans: r, margin: a, pre: o, post: s } = i[e], u = [], m = [];
1964
2065
  for (let e = 0; e < r.length; e++, t++) u.push(y + C.top[t]), m.push(C.column[t] * (l.width + c));
@@ -1999,7 +2100,7 @@ function Ft(e, t, n, r, i, a, o) {
1999
2100
  if (i) {
2000
2101
  let e = G(i.style.margin, p), t = (e.left ?? 0) + (e.right ?? 0);
2001
2102
  V(i, Math.max(0, p - t), void 0, 0, 0, "fill", o);
2002
- let r = An(e, p, i.localRect.width), a = (e.top ?? 0) + n;
2103
+ let r = Hn(e, p, i.localRect.width), a = (e.top ?? 0) + n;
2003
2104
  y += a, i.localRect = {
2004
2105
  ...i.localRect,
2005
2106
  x: d + r,
@@ -2038,30 +2139,30 @@ function Ft(e, t, n, r, i, a, o) {
2038
2139
  } : {}
2039
2140
  }, x;
2040
2141
  }
2041
- function It(e, t, n, r, i, a, o) {
2042
- let s = e.style, c = wt(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);
2043
- if (u.length > 0 && u.every((e) => Pt(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 Ft(e, l, t, c, i, a, o);
2044
- let f = U(s, "x", t), p = St(s, t, f), m = p.length, h = [];
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 = [];
2045
2146
  {
2046
2147
  let e = 0;
2047
2148
  for (let t of p) h.push(e), e += t + f;
2048
2149
  }
2049
- let g = (e) => e < m ? h[e] : h[m - 1] + (e - m + 1) * (p[m - 1] + f), _ = (e) => p[Math.min(e, m - 1)], v = p[m - 1], y = i.left + a.left, b = i.top + a.top, x = [], S = 0, C = [], w = [], T = !1, E = (e, t) => {
2150
+ let g = (e) => e < m ? h[e] : h[m - 1] + (e - m + 1) * (p[m - 1] + f), _ = (e) => p[Math.min(e, m - 1)], v = p[m - 1], y = i.left + a.left, b = i.top + a.top, x = [], C = 0, w = [], T = [], E = !1, D = (e, t) => {
2050
2151
  let r = 0, i = 0, a = null, s = 0, c = (e) => {
2051
- if (t) for (let t of w) {
2152
+ if (t) for (let t of T) {
2052
2153
  if (t.index !== e) continue;
2053
- let n = a === null ? t.margin.top ?? 0 : jn(a, t.margin.top ?? 0);
2154
+ let n = a === null ? t.margin.top ?? 0 : Un(a, t.margin.top ?? 0);
2054
2155
  t.child.staticSlot = {
2055
2156
  kind: "block",
2056
2157
  x: y + g(r) + (t.margin.left ?? 0),
2057
- y: b + S + i + n
2158
+ y: b + C + i + n
2058
2159
  };
2059
2160
  }
2060
2161
  };
2061
- for (let l = 0; l < C.length; l++) {
2062
- let u = C[l];
2162
+ for (let l = 0; l < w.length; l++) {
2163
+ let u = w[l];
2063
2164
  c(l);
2064
- let d = a === null ? l === 0 ? u.margin.top ?? 0 : 0 : jn(a, u.margin.top ?? 0), f = u.node.localRect.height;
2165
+ let d = a === null ? l === 0 ? u.margin.top ?? 0 : 0 : Un(a, u.margin.top ?? 0), f = u.node.localRect.height;
2065
2166
  if (a !== null && (u.breakBefore || i + d + f > e) && (r += 1, i = 0, a = null, d = 0), t) {
2066
2167
  let e = u.node, t = _(r);
2067
2168
  if (t !== v) {
@@ -2070,111 +2171,112 @@ function It(e, t, n, r, i, a, o) {
2070
2171
  }
2071
2172
  e.localRect = {
2072
2173
  ...e.localRect,
2073
- x: y + g(r) + An(u.margin, t, e.localRect.width),
2074
- y: b + S + i + d
2174
+ x: y + g(r) + Hn(u.margin, t, e.localRect.width),
2175
+ y: b + C + i + d
2075
2176
  };
2076
2177
  }
2077
2178
  i += d + u.node.localRect.height, s = Math.max(s, i), a = u.margin.bottom ?? 0;
2078
2179
  }
2079
- return c(C.length), {
2180
+ return c(w.length), {
2080
2181
  columns: r + 1,
2081
2182
  maxUsed: s
2082
2183
  };
2083
- }, D = () => {
2084
- if (C.length === 0) {
2085
- for (let e of w) e.child.staticSlot = {
2184
+ }, O = () => {
2185
+ if (w.length === 0) {
2186
+ for (let e of T) e.child.staticSlot = {
2086
2187
  kind: "block",
2087
2188
  x: y + (e.margin.left ?? 0),
2088
- y: b + S + (e.margin.top ?? 0)
2189
+ y: b + C + (e.margin.top ?? 0)
2089
2190
  };
2090
- w = [];
2191
+ T = [];
2091
2192
  return;
2092
2193
  }
2093
- let e = c === void 0 ? void 0 : Math.max(1, c - S), t = s.columnFill === "auto" && e !== void 0, r;
2194
+ let e = c === void 0 ? void 0 : Math.max(1, c - C), t = s.columnFill === "auto" && e !== void 0, r;
2094
2195
  if (t) r = e;
2095
2196
  else {
2096
- let t = Tt(1, E(Infinity, !1).maxUsed, (e) => E(e, !1).columns <= m);
2197
+ let t = It(1, D(Infinity, !1).maxUsed, (e) => D(e, !1).columns <= m);
2097
2198
  r = e === void 0 ? t : Math.min(t, e);
2098
2199
  }
2099
- let i = E(r, !0), a = t && n !== void 0 ? Math.max(i.maxUsed, r) : i.maxUsed;
2200
+ let i = D(r, !0), a = t && n !== void 0 ? Math.max(i.maxUsed, r) : i.maxUsed;
2100
2201
  if (s.ruleX) for (let e = 0; e < m - 1; e++) {
2101
2202
  let t = Math.min(i.columns, m);
2102
- Dt(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2203
+ Rt(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2103
2204
  bandStart: h[e] + p[e],
2104
2205
  bandSize: f,
2105
- start: S,
2106
- end: S + a
2206
+ start: C,
2207
+ end: C + a
2107
2208
  });
2108
2209
  }
2109
- S += a, C = [], w = [];
2210
+ C += a, w = [], T = [];
2110
2211
  };
2111
2212
  for (let r of e.children) {
2112
2213
  if (B(r.style)) {
2113
- w.push({
2214
+ T.push({
2114
2215
  child: r,
2115
2216
  margin: G(r.style.margin, t),
2116
- index: C.length
2217
+ index: w.length
2117
2218
  });
2118
2219
  continue;
2119
2220
  }
2120
2221
  if (r.style.columnSpan) {
2121
- D(), T = !1;
2222
+ O(), E = !1;
2122
2223
  let e = G(r.style.margin, t), i = (e.left ?? 0) + (e.right ?? 0);
2123
- V(r, Math.max(0, t - i), n, 0, 0, "fill", o), S += e.top ?? 0, r.localRect = {
2224
+ V(r, Math.max(0, t - i), n, 0, 0, "fill", o), C += e.top ?? 0, r.localRect = {
2124
2225
  ...r.localRect,
2125
- x: y + An(e, t, r.localRect.width),
2126
- y: b + S
2127
- }, S += r.localRect.height + (e.bottom ?? 0);
2226
+ x: y + Hn(e, t, r.localRect.width),
2227
+ y: b + C
2228
+ }, C += r.localRect.height + (e.bottom ?? 0);
2128
2229
  continue;
2129
2230
  }
2130
2231
  let e = G(r.style.margin, v), i = (e.left ?? 0) + (e.right ?? 0);
2131
- V(r, Math.max(0, v - i), n, 0, 0, "fill", o), C.push({
2232
+ V(r, Math.max(0, v - i), n, 0, 0, "fill", o), w.push({
2132
2233
  node: r,
2133
2234
  margin: e,
2134
- breakBefore: T || r.style.breakBeforeColumn
2135
- }), T = r.style.breakAfterColumn;
2235
+ breakBefore: E || r.style.breakBeforeColumn
2236
+ }), E = r.style.breakAfterColumn;
2136
2237
  }
2137
- return D(), s.ruleX && x.length > 0 && (e.decorationRuns = ce({
2238
+ return O(), s.ruleX && x.length > 0 && (e.decorationRuns = ve({
2239
+ glyphs: S(s.glyphSet),
2138
2240
  ruleX: s.ruleX,
2139
2241
  ruleY: null,
2140
- vertical: ke(x, s.ruleInset),
2242
+ vertical: ze(x, s.ruleInset),
2141
2243
  horizontal: [],
2142
2244
  contentWidth: t,
2143
- contentHeight: S,
2245
+ contentHeight: C,
2144
2246
  border: i,
2145
2247
  borderStyle: s.borderStyle,
2146
2248
  borderColor: s.borderColor,
2147
2249
  padding: a
2148
- })), S;
2250
+ })), C;
2149
2251
  }
2150
2252
  //#endregion
2151
2253
  //#region src/table.ts
2152
- function Lt(e, t) {
2153
- e.hidden.push(t), t.style.tableRole !== "column" && t.style.tableRole !== "column-group" && b(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).");
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).");
2154
2256
  }
2155
- function Rt(e, t) {
2257
+ function Xt(e, t) {
2156
2258
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
2157
2259
  return Number.isNaN(n) ? 1 : t === "colspan" ? Math.min(1e3, Math.max(1, n)) : Math.min(65534, Math.max(0, n));
2158
2260
  }
2159
- function zt(e, t, n) {
2261
+ function Zt(e, t, n) {
2160
2262
  let r = (t, r) => {
2161
2263
  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;
2162
2264
  for (let t = 0; t < r; t++) e.colFixed.push(a), e.colPercent.push(o);
2163
2265
  };
2164
2266
  if (t.style.tableRole === "column") {
2165
- r(t, Bt(t.source));
2267
+ r(t, Qt(t.source));
2166
2268
  return;
2167
2269
  }
2168
2270
  let i = t.children.filter((e) => e.style.tableRole === "column");
2169
- if (i.length === 0) r(t, Bt(t.source));
2170
- else for (let e of i) r(e, Bt(e.source));
2171
- for (let n of t.children) n.style.tableRole !== "column" && Lt(e, n);
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);
2172
2274
  }
2173
- function Bt(e) {
2275
+ function Qt(e) {
2174
2276
  let t = Number.parseInt(e.getAttribute("span") ?? "", 10);
2175
2277
  return Number.isNaN(t) ? 1 : Math.min(1e3, Math.max(1, t));
2176
2278
  }
2177
- function Vt(e, t) {
2279
+ function $t(e, t) {
2178
2280
  let n = {
2179
2281
  caption: null,
2180
2282
  rows: [],
@@ -2198,8 +2300,8 @@ function Vt(e, t) {
2198
2300
  for (let e of o.children) B(e.style) || (e.style.tableRole === "row" ? t.push({
2199
2301
  row: e,
2200
2302
  group: o
2201
- }) : Lt(n, e));
2202
- } else e === "caption" ? n.caption === null ? n.caption = o : Lt(n, o) : e === "column" || e === "column-group" ? (zt(n, o, t), n.hidden.push(o)) : Lt(n, 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);
2203
2305
  }
2204
2306
  let o = [
2205
2307
  ...r,
@@ -2214,20 +2316,20 @@ function Vt(e, t) {
2214
2316
  s = e + 1;
2215
2317
  }
2216
2318
  }
2217
- return Ht(n), n;
2319
+ return en(n), n;
2218
2320
  }
2219
- function Ht(e) {
2321
+ function en(e) {
2220
2322
  let t = [];
2221
2323
  for (let n = 0; n < e.rows.length; n++) {
2222
2324
  let r = e.rows[n], i = 0;
2223
2325
  for (let a of r.children) {
2224
2326
  if (B(a.style)) continue;
2225
2327
  if (a.style.tableRole !== "cell") {
2226
- Lt(e, a);
2328
+ Yt(e, a);
2227
2329
  continue;
2228
2330
  }
2229
2331
  for (; (t[i] ?? 0) > n;) i++;
2230
- let o = Rt(a.source, "colspan"), s = Rt(a.source, "rowspan"), c = e.groupEnds[n], l = Math.max(1, Math.min(s === 0 ? c - n : s, c - n));
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));
2231
2333
  for (let e = i; e < i + o; e++) t[e] = Math.max(t[e] ?? 0, n + l);
2232
2334
  e.cells.push({
2233
2335
  node: a,
@@ -2241,7 +2343,7 @@ function Ht(e) {
2241
2343
  }
2242
2344
  e.columnCount = Math.max(t.length, e.colFixed.length);
2243
2345
  }
2244
- function Ut(e, t, n) {
2346
+ function tn(e, t, n) {
2245
2347
  let r = e.style, i = Y(e, n), a;
2246
2348
  if (t === "min") a = i;
2247
2349
  else {
@@ -2251,11 +2353,11 @@ function Ut(e, t, n) {
2251
2353
  let o = typeof r.minWidth == "number" ? r.minWidth : 0, s = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
2252
2354
  return Math.max(0, H(a, o, s));
2253
2355
  }
2254
- function Wt(e) {
2356
+ function nn(e) {
2255
2357
  let t = e.style.width;
2256
2358
  return t && t.kind === "percent" ? t.value : void 0;
2257
2359
  }
2258
- function Gt(e, t, n) {
2360
+ function rn(e, t, n) {
2259
2361
  let r = e.columnCount, i = Array.from({ length: r }, () => 0), a = Array.from({ length: r }, () => 0), o = Array.from({ length: r }, () => void 0);
2260
2362
  for (let t = 0; t < r; t++) e.colFixed[t] !== void 0 && (a[t] = e.colFixed[t]), o[t] = e.colPercent[t];
2261
2363
  let s = [];
@@ -2264,17 +2366,17 @@ function Gt(e, t, n) {
2264
2366
  s.push(t);
2265
2367
  continue;
2266
2368
  }
2267
- i[t.col] = Math.max(i[t.col], Ut(t.node, "min", n)), a[t.col] = Math.max(a[t.col], Ut(t.node, "max", n));
2268
- let e = Wt(t.node);
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);
2269
2371
  e !== void 0 && (o[t.col] = Math.max(o[t.col] ?? 0, e));
2270
2372
  }
2271
2373
  s.sort((e, t) => e.colSpan - t.colSpan);
2272
2374
  for (let e of s) {
2273
- let r = e.col, o = e.col + e.colSpan, s = Qt(t, r, o), c = a.slice(r, o);
2375
+ let r = e.col, o = e.col + e.colSpan, s = dn(t, r, o), c = a.slice(r, o);
2274
2376
  for (let t of ["min", "max"]) {
2275
- let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = Ut(e.node, t, n) - u;
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;
2276
2378
  if (d <= 0) continue;
2277
- let f = I(c.some((e) => e > 0) ? c : c.map(() => 1), d);
2379
+ let f = R(c.some((e) => e > 0) ? c : c.map(() => 1), d);
2278
2380
  for (let e = r; e < o; e++) l[e] += f[e - r];
2279
2381
  }
2280
2382
  }
@@ -2285,7 +2387,7 @@ function Gt(e, t, n) {
2285
2387
  percent: o
2286
2388
  };
2287
2389
  }
2288
- function Kt(e, t) {
2390
+ function an(e, t) {
2289
2391
  let n = e.min.length, r = e.min.slice(), i = [], a = [];
2290
2392
  for (let t = 0; t < n; t++) (e.percent[t] === void 0 ? a : i).push(t);
2291
2393
  if (i.length > 0) {
@@ -2296,32 +2398,32 @@ function Kt(e, t) {
2296
2398
  }
2297
2399
  let s = a.reduce((t, n) => t + e.min[n], 0), c = i.reduce((e, t) => e + r[t], 0) - (t - s);
2298
2400
  if (c > 0) {
2299
- let t = i.map((t) => r[t] - e.min[t]), n = I(t, Math.min(c, t.reduce((e, t) => e + t, 0)));
2401
+ let t = i.map((t) => r[t] - e.min[t]), n = R(t, Math.min(c, t.reduce((e, t) => e + t, 0)));
2300
2402
  i.forEach((e, t) => r[e] -= n[t]);
2301
2403
  }
2302
2404
  }
2303
2405
  let o = t - r.reduce((e, t) => e + t, 0);
2304
2406
  if (o > 0 && a.length > 0) {
2305
- let t = a.map((t) => e.max[t] - e.min[t]), n = t.reduce((e, t) => e + t, 0), i = I(t, Math.min(o, n));
2407
+ let t = a.map((t) => e.max[t] - e.min[t]), n = t.reduce((e, t) => e + t, 0), i = R(t, Math.min(o, n));
2306
2408
  a.forEach((e, t) => r[e] += i[t]), o -= Math.min(o, n);
2307
2409
  }
2308
2410
  if (o > 0) {
2309
2411
  let t = a.length > 0 ? a : i;
2310
2412
  if (t.length > 0) {
2311
- let n = t.map((t) => e.max[t]), i = I(n.some((e) => e > 0) ? n : n.map(() => 1), o);
2413
+ let n = t.map((t) => e.max[t]), i = R(n.some((e) => e > 0) ? n : n.map(() => 1), o);
2312
2414
  t.forEach((e, t) => r[e] += i[t]);
2313
2415
  }
2314
2416
  }
2315
2417
  return r;
2316
2418
  }
2317
- function qt(e, t, n) {
2419
+ function on(e, t, n) {
2318
2420
  let r = e.columnCount, i = Array.from({ length: r }, () => void 0);
2319
2421
  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];
2320
2422
  for (let r of e.cells) {
2321
2423
  if (r.row !== 0) continue;
2322
2424
  let e = r.node.style, a;
2323
2425
  if (e.width && e.width.kind === "percent" ? a = Math.max(0, Math.round(t * e.width.value / 100)) : e.width && e.width.kind !== "auto" && (a = q(e.width, 0, r.node, n)), a === void 0) continue;
2324
- let o = I(Array.from({ length: r.colSpan }, () => 1), a);
2426
+ let o = R(Array.from({ length: r.colSpan }, () => 1), a);
2325
2427
  for (let e = 0; e < r.colSpan; e++) {
2326
2428
  let t = r.col + e;
2327
2429
  i[t] === void 0 && (i[t] = o[e]);
@@ -2329,18 +2431,18 @@ function qt(e, t, n) {
2329
2431
  }
2330
2432
  let a = i.reduce((e, t) => e + (t ?? 0), 0), o = i.filter((e) => e === void 0).length;
2331
2433
  if (o > 0) {
2332
- let e = I(Array.from({ length: o }, () => 1), Math.max(0, t - a)), n = 0;
2434
+ let e = R(Array.from({ length: o }, () => 1), Math.max(0, t - a)), n = 0;
2333
2435
  for (let t = 0; t < r; t++) i[t] === void 0 && (i[t] = e[n++]);
2334
2436
  }
2335
2437
  return i.map((e) => e ?? 0);
2336
2438
  }
2337
- var Jt = {
2439
+ var sn = {
2338
2440
  double: 3,
2339
2441
  solid: 2,
2340
2442
  dashed: 1,
2341
2443
  dotted: 0
2342
2444
  };
2343
- function Yt(e) {
2445
+ function cn(e) {
2344
2446
  for (let { border: t, side: n } of e) if (t?.hidden[n]) return null;
2345
2447
  let t = null;
2346
2448
  for (let { border: n, side: r } of e) {
@@ -2348,7 +2450,7 @@ function Yt(e) {
2348
2450
  let e = n.width[r];
2349
2451
  if (e <= 0) continue;
2350
2452
  let i = n.style[r];
2351
- (t === null || e > t.width || e === t.width && Jt[i] > Jt[t.style]) && (t = {
2453
+ (t === null || e > t.width || e === t.width && sn[i] > sn[t.style]) && (t = {
2352
2454
  width: e,
2353
2455
  style: i,
2354
2456
  color: n.color[r]
@@ -2356,7 +2458,7 @@ function Yt(e) {
2356
2458
  }
2357
2459
  return t;
2358
2460
  }
2359
- function Xt(e, t) {
2461
+ function ln(e, t) {
2360
2462
  let n = t.columnCount, r = t.rows.length, i = e.style.borderCollapse, a = {
2361
2463
  collapsed: i,
2362
2464
  vLines: Array.from({ length: n + 1 }, () => 0),
@@ -2401,7 +2503,7 @@ function Xt(e, t) {
2401
2503
  side: u
2402
2504
  });
2403
2505
  }
2404
- i.push(Yt(l));
2506
+ i.push(cn(l));
2405
2507
  }
2406
2508
  a.vSegments.push(i), a.vLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2407
2509
  }
@@ -2440,47 +2542,47 @@ function Xt(e, t) {
2440
2542
  }), e === r && l.push({
2441
2543
  border: s,
2442
2544
  side: "bottom"
2443
- }), i.push(Yt(l));
2545
+ }), i.push(cn(l));
2444
2546
  }
2445
2547
  a.hSegments.push(i), a.hLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2446
2548
  }
2447
2549
  return a;
2448
2550
  }
2449
- function Zt(e, t) {
2551
+ function un(e, t) {
2450
2552
  return e.collapsed ? e.vLines.reduce((e, t) => e + t, 0) : (t + 1) * e.spacingX;
2451
2553
  }
2452
- function Qt(e, t, n) {
2554
+ function dn(e, t, n) {
2453
2555
  if (!e.collapsed) return e.spacingX * (n - t - 1);
2454
2556
  let r = 0;
2455
2557
  for (let i = t + 1; i < n; i++) r += e.vLines[i];
2456
2558
  return r;
2457
2559
  }
2458
- function $t(e, t, n) {
2560
+ function fn(e, t, n) {
2459
2561
  if (!e.collapsed) return e.spacingY * (n - t - 1);
2460
2562
  let r = 0;
2461
2563
  for (let i = t + 1; i < n; i++) r += e.hLines[i];
2462
2564
  return r;
2463
2565
  }
2464
- function en(e, t) {
2566
+ function pn(e, t) {
2465
2567
  let n = t.tableData.get(e);
2466
2568
  if (n) return n;
2467
- let r = Vt(e, t), i = Xt(e, r), a = {
2569
+ let r = $t(e, t), i = ln(e, r), a = {
2468
2570
  structure: r,
2469
2571
  chrome: i,
2470
- bounds: Gt(r, i, t),
2471
- chromeX: Zt(i, r.columnCount)
2572
+ bounds: rn(r, i, t),
2573
+ chromeX: un(i, r.columnCount)
2472
2574
  };
2473
2575
  return t.tableData.set(e, a), a;
2474
2576
  }
2475
- function tn(e, t) {
2476
- let { structure: n, bounds: r, chromeX: i } = en(e, t), a = r.min.reduce((e, t) => e + t, 0) + i, o = r.max.reduce((e, t) => e + t, 0) + i;
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;
2477
2579
  return n.caption && (a = Math.max(a, Y(n.caption, t)), o = Math.max(o, J(n.caption, t))), {
2478
2580
  min: a,
2479
2581
  max: o
2480
2582
  };
2481
2583
  }
2482
- function nn(e, t, n) {
2483
- let r = e.style, { bounds: i, chromeX: a } = en(e, n), { min: o, max: s } = tn(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;
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;
2484
2586
  for (let e = 0; e < i.max.length; e++) {
2485
2587
  let t = i.percent[e];
2486
2588
  t === void 0 ? d += i.max[e] : u += t;
@@ -2496,8 +2598,8 @@ function nn(e, t, n) {
2496
2598
  let f = Math.max(l + a, s) + c;
2497
2599
  return Math.max(o + c, Math.min(f, t));
2498
2600
  }
2499
- function rn(e, t, n, r, i, a) {
2500
- let { structure: o, chrome: s, bounds: c } = en(e, a), l = o.columnCount, u = o.rows.length, d = r.left + i.left, f = r.top + i.top;
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;
2501
2603
  for (let e of o.hidden) e.tableHidden = !0, e.localRect = {
2502
2604
  x: 0,
2503
2605
  y: 0,
@@ -2509,52 +2611,52 @@ function rn(e, t, n, r, i, a) {
2509
2611
  bottom: 0,
2510
2612
  left: 0
2511
2613
  }, e.unclampedHeight = 0;
2512
- let p = Math.max(0, t - Zt(s, l)), m = e.style, h = m.tableLayout === "fixed" && m.width !== void 0 && m.width.kind !== "auto" ? qt(o, p, a) : Kt(c, p), g = [], _ = 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;
2513
2615
  for (let e = 0; e < l; e++) _ += s.collapsed ? s.vLines[e] : s.spacingX, g.push(_), _ += h[e];
2514
2616
  let v = _ + (s.collapsed ? s.vLines[l] ?? 0 : s.spacingX), y = 0;
2515
2617
  o.caption && (V(o.caption, t, void 0, d, f, "fill", a), y = o.caption.localRect.height);
2516
2618
  let b = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
2517
2619
  for (let e of o.cells) {
2518
- let t = e.col + e.colSpan, n = h.slice(e.col, t).reduce((e, t) => e + t, 0) + Qt(s, e.col, t);
2620
+ let t = e.col + e.colSpan, n = h.slice(e.col, t).reduce((e, t) => e + t, 0) + dn(s, e.col, t);
2519
2621
  x.set(e, n), V(e.node, n, void 0, 0, 0, "fill", a, { width: n }), b.set(e, e.node.localRect.height);
2520
2622
  }
2521
- let S = s.collapsed ? s.hLines.reduce((e, t) => e + t, 0) : (u + 1) * s.spacingY, C = n === void 0 ? void 0 : Math.max(0, n - y - S), w = (e) => e !== void 0 && e.kind === "percent" && C !== void 0 ? de(e.value, C) : 0, T = Array.from({ length: u }, () => 0), E = Array.from({ length: u }, () => !1);
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);
2522
2624
  for (let e = 0; e < u; e++) {
2523
2625
  let t = o.rows[e].style.height;
2524
- t !== void 0 && t.kind === "cells" && (T[e] = t.value);
2525
- let n = w(t);
2526
- n > 0 && (T[e] = Math.max(T[e], n), E[e] = !0);
2626
+ t !== void 0 && t.kind === "cells" && (E[e] = t.value);
2627
+ let n = T(t);
2628
+ n > 0 && (E[e] = Math.max(E[e], n), D[e] = !0);
2527
2629
  }
2528
2630
  for (let e of o.cells) if (e.rowSpan === 1) {
2529
- let t = w(e.node.style.height);
2530
- t > 0 && (E[e.row] = !0), T[e.row] = Math.max(T[e.row], b.get(e), t);
2631
+ let t = T(e.node.style.height);
2632
+ t > 0 && (D[e.row] = !0), E[e.row] = Math.max(E[e.row], b.get(e), t);
2531
2633
  }
2532
- let D = o.cells.filter((e) => e.rowSpan > 1).sort((e, t) => e.rowSpan - t.rowSpan);
2533
- for (let e of D) {
2534
- let t = e.row + e.rowSpan, n = T.slice(e.row, t).reduce((e, t) => e + t, 0) + $t(s, e.row, t), r = b.get(e) - n;
2634
+ let O = o.cells.filter((e) => e.rowSpan > 1).sort((e, t) => e.rowSpan - t.rowSpan);
2635
+ 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;
2535
2637
  if (r <= 0) continue;
2536
- let i = I(Array.from({ length: e.rowSpan }, () => 1), r);
2537
- for (let n = e.row; n < t; n++) T[n] += i[n - e.row];
2638
+ let i = R(Array.from({ length: e.rowSpan }, () => 1), r);
2639
+ for (let n = e.row; n < t; n++) E[n] += i[n - e.row];
2538
2640
  }
2539
2641
  if (n !== void 0 && u > 0) {
2540
- let e = n - y - S - T.reduce((e, t) => e + t, 0);
2642
+ let e = n - y - C - E.reduce((e, t) => e + t, 0);
2541
2643
  if (e > 0) {
2542
2644
  let t = [];
2543
- for (let e = 0; e < u; e++) E[e] || t.push(e);
2544
- let n = t.length > 0 ? t : Array.from({ length: u }, (e, t) => t), r = I(n.map(() => 1), e);
2545
- n.forEach((e, t) => T[e] += r[t]);
2645
+ for (let e = 0; e < u; e++) D[e] || t.push(e);
2646
+ let n = t.length > 0 ? t : Array.from({ length: u }, (e, t) => t), r = R(n.map(() => 1), e);
2647
+ n.forEach((e, t) => E[e] += r[t]);
2546
2648
  }
2547
2649
  }
2548
- let ee = o.caption && e.style.captionSide === "top" ? y : 0, O = [], k = ee;
2549
- for (let e = 0; e < u; e++) k += s.collapsed ? s.hLines[e] : s.spacingY, O.push(k), k += T[e];
2550
- let A = u > 0 ? k + (s.collapsed ? s.hLines[u] ?? 0 : s.spacingY) : ee, j = /* @__PURE__ */ new Map();
2650
+ let k = o.caption && e.style.captionSide === "top" ? y : 0, A = [], j = k;
2651
+ for (let e = 0; e < u; e++) j += s.collapsed ? s.hLines[e] : s.spacingY, A.push(j), j += E[e];
2652
+ let M = u > 0 ? j + (s.collapsed ? s.hLines[u] ?? 0 : s.spacingY) : k, N = /* @__PURE__ */ new Map();
2551
2653
  for (let e = 0; e < u; e++) {
2552
2654
  let t = o.rowGroups[e];
2553
- t && !j.has(t) && j.set(t, O[e]);
2655
+ t && !N.has(t) && N.set(t, A[e]);
2554
2656
  }
2555
- for (let [e, t] of j) {
2657
+ for (let [e, t] of N) {
2556
2658
  let n = t;
2557
- for (let t = 0; t < u; t++) o.rowGroups[t] === e && (n = O[t] + T[t]);
2659
+ for (let t = 0; t < u; t++) o.rowGroups[t] === e && (n = A[t] + E[t]);
2558
2660
  e.localRect = {
2559
2661
  x: d,
2560
2662
  y: f + t,
@@ -2568,25 +2670,25 @@ function rn(e, t, n, r, i, a) {
2568
2670
  }, e.unclampedHeight = n - t;
2569
2671
  }
2570
2672
  for (let e = 0; e < u; e++) {
2571
- let t = o.rows[e], n = o.rowGroups[e], r = n ? j.get(n) : void 0;
2673
+ let t = o.rows[e], n = o.rowGroups[e], r = n ? N.get(n) : void 0;
2572
2674
  t.localRect = {
2573
2675
  x: r === void 0 ? d : 0,
2574
- y: r === void 0 ? f + O[e] : O[e] - r,
2676
+ y: r === void 0 ? f + A[e] : A[e] - r,
2575
2677
  width: v,
2576
- height: T[e]
2678
+ height: E[e]
2577
2679
  }, t.resolvedPadding = {
2578
2680
  top: 0,
2579
2681
  right: 0,
2580
2682
  bottom: 0,
2581
2683
  left: 0
2582
- }, t.unclampedHeight = T[e];
2684
+ }, t.unclampedHeight = E[e];
2583
2685
  }
2584
2686
  for (let e of o.cells) {
2585
- let t = e.row + e.rowSpan, n = T.slice(e.row, t).reduce((e, t) => e + t, 0) + $t(s, e.row, t);
2687
+ let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + fn(s, e.row, t);
2586
2688
  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, {
2587
2689
  width: x.get(e),
2588
2690
  height: n
2589
- }), an(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2691
+ }), _n(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2590
2692
  x: g[e.col],
2591
2693
  y: 0,
2592
2694
  width: e.node.localRect.width,
@@ -2598,9 +2700,9 @@ function rn(e, t, n, r, i, a) {
2598
2700
  x: d,
2599
2701
  y: f
2600
2702
  });
2601
- return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + A), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = on(s, o, h, T, g, O, d, f)), e.style.captionSide === "bottom" ? A + y : A;
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;
2602
2704
  }
2603
- function an(e, t) {
2705
+ function _n(e, t) {
2604
2706
  if (t <= 0) return;
2605
2707
  let n = e.style.verticalAlign, r = n === "center" ? Math.floor(t / 2) : n === "end" ? t : 0;
2606
2708
  if (!e.children.some((e) => !B(e.style) && !e.inlineBox)) {
@@ -2609,84 +2711,84 @@ function an(e, t) {
2609
2711
  }
2610
2712
  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);
2611
2713
  }
2612
- function on(e, t, n, r, i, a, o, s) {
2613
- let c = t.columnCount, l = t.rows.length, u = [], d = (t) => t < c ? i[t] - e.vLines[t] : i[c - 1] + n[c - 1], f = (t) => t < l ? a[t] - e.hLines[t] : a[l - 1] + r[l - 1];
2614
- for (let t = 0; t <= c; t++) {
2714
+ function vn(e, t, n, r, i, a, o, s, c) {
2715
+ 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
+ for (let t = 0; t <= l; t++) {
2615
2717
  let n = e.vSegments[t];
2616
- for (let e = 0; e < l; e++) {
2718
+ for (let e = 0; e < u; e++) {
2617
2719
  let i = n[e];
2618
2720
  if (!i) continue;
2619
- let c = ne(i.style, "v");
2620
- for (let n = 0; n < i.width; n++) for (let l = a[e]; l < a[e] + r[e]; l++) u.push({
2621
- glyph: c,
2622
- x: o + d(t) + n,
2623
- y: s + l,
2721
+ let l = fe(i.style, "v", c);
2722
+ for (let n = 0; n < i.width; n++) for (let c = a[e]; c < a[e] + r[e]; c++) d.push({
2723
+ glyph: l,
2724
+ x: o + f(t) + n,
2725
+ y: s + c,
2624
2726
  length: 1,
2625
2727
  color: i.color
2626
2728
  });
2627
2729
  }
2628
2730
  }
2629
- for (let t = 0; t <= l; t++) {
2731
+ for (let t = 0; t <= u; t++) {
2630
2732
  let r = e.hSegments[t];
2631
- for (let e = 0; e < c; e++) {
2733
+ for (let e = 0; e < l; e++) {
2632
2734
  let a = r[e];
2633
2735
  if (!a) continue;
2634
- let c = ne(a.style, "h");
2635
- for (let r = 0; r < a.width; r++) u.push({
2636
- glyph: c,
2736
+ let l = fe(a.style, "h", c);
2737
+ for (let r = 0; r < a.width; r++) d.push({
2738
+ glyph: l,
2637
2739
  x: o + i[e],
2638
- y: s + f(t) + r,
2740
+ y: s + p(t) + r,
2639
2741
  length: n[e],
2640
2742
  color: a.color
2641
2743
  });
2642
2744
  }
2643
2745
  }
2644
- for (let t = 0; t <= c; t++) if (!(e.vLines[t] <= 0)) for (let n = 0; n <= l; n++) {
2746
+ for (let t = 0; t <= l; t++) if (!(e.vLines[t] <= 0)) for (let n = 0; n <= u; n++) {
2645
2747
  if (e.hLines[n] <= 0) continue;
2646
- let r = n > 0 ? e.vSegments[t][n - 1] : null, i = n < l ? e.vSegments[t][n] : null, a = t > 0 ? e.hSegments[n][t - 1] : null, p = t < c ? e.hSegments[n][t] : null, m = [
2748
+ let r = n > 0 ? e.vSegments[t][n - 1] : null, i = n < u ? e.vSegments[t][n] : null, a = t > 0 ? e.hSegments[n][t - 1] : null, m = t < l ? e.hSegments[n][t] : null, h = [
2647
2749
  r,
2648
2750
  i,
2649
2751
  a,
2650
- p
2752
+ m
2651
2753
  ].filter((e) => e !== null);
2652
- if (m.length === 0) continue;
2653
- let h = m.every((e) => e.style === "double") ? "double" : "solid", g = m.reduce((e, t) => t.width > e.width || t.width === e.width && Jt[t.style] > Jt[e.style] ? t : e), _ = re(h, r !== null, i !== null, a !== null, p !== null);
2654
- for (let r = 0; r < e.vLines[t]; r++) for (let i = 0; i < e.hLines[n]; i++) u.push({
2655
- glyph: _,
2656
- x: o + d(t) + r,
2657
- y: s + f(n) + i,
2754
+ 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);
2756
+ for (let r = 0; r < e.vLines[t]; r++) for (let i = 0; i < e.hLines[n]; i++) d.push({
2757
+ glyph: v,
2758
+ x: o + f(t) + r,
2759
+ y: s + p(n) + i,
2658
2760
  length: 1,
2659
- color: g.color
2761
+ color: _.color
2660
2762
  });
2661
2763
  }
2662
- return u;
2764
+ return d;
2663
2765
  }
2664
2766
  //#endregion
2665
2767
  //#region src/positioning.ts
2666
- function sn(e) {
2768
+ function yn(e) {
2667
2769
  return e.position === "absolute" || e.position === "fixed" ? "absolute" : e.position === "relative" || e.position === "sticky" ? "relative" : "static";
2668
2770
  }
2669
- function cn(e, t, n, r, i) {
2771
+ function bn(e, t, n, r, i) {
2670
2772
  for (let a of e.children) {
2671
- let o = sn(a.style);
2773
+ let o = yn(a.style);
2672
2774
  if (o === "relative") {
2673
2775
  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;
2674
- a.localRect.x += ln(a.style.insets.left, a.style.insets.right, t), a.localRect.y += ln(a.style.insets.top, a.style.insets.bottom, n);
2675
- } else o === "absolute" && dn(a, e, t, n, r, i);
2676
- cn(a, t + a.localRect.x, n + a.localRect.y, [...r, {
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, {
2677
2779
  node: a,
2678
2780
  absX: t + a.localRect.x,
2679
2781
  absY: n + a.localRect.y
2680
2782
  }], i);
2681
2783
  }
2682
2784
  }
2683
- function ln(e, t, n) {
2785
+ function xn(e, t, n) {
2684
2786
  return e === null ? t === null ? 0 : -W(t, n) : W(e, n);
2685
2787
  }
2686
- function un(e, t) {
2788
+ function Sn(e, t) {
2687
2789
  if (!t) for (let t = e.length - 1; t > 0; t--) {
2688
2790
  let n = e[t];
2689
- if (!yn(n.node.style)) continue;
2791
+ if (!jn(n.node.style)) continue;
2690
2792
  let r = n.node.style.border;
2691
2793
  return {
2692
2794
  x: n.absX + r.left,
@@ -2703,13 +2805,13 @@ function un(e, t) {
2703
2805
  height: n.node.localRect.height
2704
2806
  };
2705
2807
  }
2706
- function dn(e, t, n, r, i, a) {
2707
- let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && yn(t.style) ? {
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) ? {
2708
2810
  x: n + c.area.x,
2709
2811
  y: r + c.area.y,
2710
2812
  width: c.area.width,
2711
2813
  height: c.area.height
2712
- } : un(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 = On(o.minWidth, l.width, e, a) ?? 0, S = On(o.maxWidth, l.width, e, a), C = {};
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 = {};
2713
2815
  if (!y) C.width = H(q(o.width, l.width, e, a), x, S);
2714
2816
  else if (u !== null && d !== null) C.width = H(Math.max(0, l.width - u - d - h - g), x, S);
2715
2817
  else {
@@ -2721,25 +2823,25 @@ function dn(e, t, n, r, i, a) {
2721
2823
  if (u !== null && d !== null) {
2722
2824
  let e = Math.max(0, l.width - u - d - w - h - g), t = m.left === null && m.right === null;
2723
2825
  E = l.x + u + h + (t ? Math.floor(e / 2) : m.left === null ? e : 0);
2724
- } else E = u === null ? d === null ? gn(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2826
+ } else E = u === null ? d === null ? On(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2725
2827
  let D;
2726
2828
  if (f !== null && p !== null) {
2727
2829
  let e = Math.max(0, l.height - f - p - T - _ - v), t = m.top === null && m.bottom === null;
2728
2830
  D = l.y + f + _ + (t ? Math.floor(e / 2) : m.top === null ? e : 0);
2729
- } else D = f === null ? p === null ? _n(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2831
+ } else D = f === null ? p === null ? kn(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2730
2832
  e.localRect = {
2731
2833
  ...e.localRect,
2732
2834
  x: E - n,
2733
2835
  y: D - r
2734
2836
  };
2735
2837
  }
2736
- function fn(e, t, n) {
2737
- return F(e, [n], Math.max(0, t - n))[0];
2838
+ function wn(e, t, n) {
2839
+ return L(e, [n], Math.max(0, t - n))[0];
2738
2840
  }
2739
- function pn(e, t, n, r) {
2740
- return L(Ie(e, t), n, r);
2841
+ function Tn(e, t, n, r) {
2842
+ return qe(Ke(e, t), n, r);
2741
2843
  }
2742
- function mn(e, t, n, r, i) {
2844
+ function En(e, t, n, r, i) {
2743
2845
  let a = G(e.style.margin, n.innerWidth), [o, s, c, l] = r === "x" ? [
2744
2846
  a.left ?? 0,
2745
2847
  a.right ?? 0,
@@ -2751,9 +2853,9 @@ function mn(e, t, n, r, i) {
2751
2853
  n.innerHeight,
2752
2854
  n.direction === "column"
2753
2855
  ], u = i + o + s;
2754
- return (l ? fn(Be(t.style), c, u) : pn(e, t, c, u)) + o;
2856
+ return (l ? wn(Ze(t.style), c, u) : Tn(e, t, c, u)) + o;
2755
2857
  }
2756
- function hn(e, t, n, r, i) {
2858
+ function Dn(e, t, n, r, i) {
2757
2859
  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" ? [
2758
2860
  a.left ?? 0,
2759
2861
  a.right ?? 0,
@@ -2763,23 +2865,23 @@ function hn(e, t, n, r, i) {
2763
2865
  a.top ?? 0,
2764
2866
  a.bottom ?? 0,
2765
2867
  n.height,
2766
- Ie(e, t)
2868
+ Ke(e, t)
2767
2869
  ];
2768
- return L(u, l, i + s + c) + s;
2870
+ return qe(u, l, i + s + c) + s;
2769
2871
  }
2770
- function gn(e, t, n, r) {
2872
+ function On(e, t, n, r) {
2771
2873
  let i = e.staticSlot;
2772
- return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + hn(e, t, i.staticArea, "x", r) : n + i.originX + mn(e, t, i, "x", r);
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);
2773
2875
  }
2774
- function _n(e, t, n, r) {
2876
+ function kn(e, t, n, r) {
2775
2877
  let i = e.staticSlot;
2776
- return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + hn(e, t, i.staticArea, "y", r) : n + i.originY + mn(e, t, i, "y", r);
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);
2777
2879
  }
2778
2880
  //#endregion
2779
2881
  //#region src/layout.ts
2780
- function vn(e, t) {
2781
- let n = bn();
2782
- return V(e, t, void 0, 0, 0, "fill", n), cn(e, 0, 0, [{
2882
+ function An(e, t) {
2883
+ let n = Mn();
2884
+ return V(e, t, void 0, 0, 0, "fill", n), bn(e, 0, 0, [{
2783
2885
  node: e,
2784
2886
  absX: 0,
2785
2887
  absY: 0
@@ -2788,10 +2890,10 @@ function vn(e, t) {
2788
2890
  function B(e) {
2789
2891
  return e.position === "absolute" || e.position === "fixed";
2790
2892
  }
2791
- function yn(e) {
2893
+ function jn(e) {
2792
2894
  return e.position !== "static";
2793
2895
  }
2794
- function bn() {
2896
+ function Mn() {
2795
2897
  return {
2796
2898
  maxContent: /* @__PURE__ */ new WeakMap(),
2797
2899
  minContent: /* @__PURE__ */ new WeakMap(),
@@ -2802,21 +2904,21 @@ function bn() {
2802
2904
  function V(e, t, n, r, i, a, o, s) {
2803
2905
  let c = e.style, l = s?.height;
2804
2906
  delete e.decorationRuns, delete e.multicolGeometry, delete e.multicolFlow, delete e.multicolFlowSpan;
2805
- let u = On(c.minWidth, t, e, o) ?? 0, d = On(c.maxWidth, t, e, o), f = K(c.minHeight, n) ?? 0, p = K(c.maxHeight, n), m = {
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 = {
2806
2908
  top: W(c.padding.top, t),
2807
2909
  right: W(c.padding.right, t),
2808
2910
  bottom: W(c.padding.bottom, t),
2809
2911
  left: W(c.padding.left, t)
2810
2912
  };
2811
2913
  e.resolvedPadding = m;
2812
- let h = s?.width ?? H(Mn(c, t, a, e, o), u, d), g = Pn(c, n), _ = Ln(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;
2813
- x = Sn(e) ? xn(e, _.width, _.height, y, b, m, o) : c.display === "flex" && c.flexDirection === "row" ? Ae(e, _.width, _.height, y, c.border, m, o) : c.display === "flex" && c.flexDirection === "column" ? Me(e, _.width, _.height, v, c.border, m, o) : c.display === "grid" ? We(e, _.width, _.height, c.border, m, o) : c.display === "table" ? rn(e, _.width, y, c.border, m, o) : c.display === "multicol" ? It(e, _.width, y, b, c.border, m, o) : kn(e, _.width, y, c.border, m, o);
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);
2814
2916
  let S = x + c.border.top + c.border.bottom + m.top + m.bottom, C = l ?? g ?? S;
2815
2917
  e.unclampedHeight = C, e.naturalContentHeight = S;
2816
2918
  let w = H(C, f, p), T = e.multicolGeometry;
2817
2919
  if (T) {
2818
2920
  let t = w - c.border.top - c.border.bottom - m.top - m.bottom;
2819
- t > T.totalRows && (m.bottom += t - T.totalRows), Nt(e, T, c.border, m);
2921
+ t > T.totalRows && (m.bottom += t - T.totalRows), Gt(e, T, c.border, m);
2820
2922
  }
2821
2923
  e.localRect = {
2822
2924
  x: r,
@@ -2825,30 +2927,30 @@ function V(e, t, n, r, i, a, o, s) {
2825
2927
  height: w
2826
2928
  };
2827
2929
  }
2828
- function xn(e, t, n, r, i, a, o) {
2930
+ function Nn(e, t, n, r, i, a, o) {
2829
2931
  let s = e.style, c;
2830
2932
  if (e.text) {
2831
2933
  let l = e.children.filter((e) => e.inlineBox);
2832
- Se(e.text, (n, r) => {
2934
+ Me(e.text, (n, r) => {
2833
2935
  let i = l[r];
2834
2936
  V(i, t, void 0, 0, 0, "shrink", o), e.advances[n] = Math.max(1, i.localRect.width);
2835
2937
  });
2836
2938
  let u, d;
2837
2939
  if (s.display === "multicol") {
2838
- let n = U(s, "x", t), o = Et(s, t, n);
2940
+ let n = U(s, "x", t), o = Lt(s, t, n);
2839
2941
  a.right += o.leftover;
2840
- let c = Ot(e, o, n, wt(r, i));
2942
+ let c = zt(e, o, n, Ft(r, i));
2841
2943
  e.multicolGeometry = c, u = c, d = c.lineX;
2842
- } else u = wn(e, t);
2843
- if (c = u.totalRows, Cn(e, u, t, n, a), l.length > 0) {
2944
+ } else u = In(e, t);
2945
+ if (c = u.totalRows, Fn(e, u, t, n, a), l.length > 0) {
2844
2946
  let t = (e) => u.spans.findIndex((t) => e >= t.start && e < t.end);
2845
- Se(e.text, (n, r) => {
2947
+ Me(e.text, (n, r) => {
2846
2948
  let i = t(n);
2847
2949
  if (i === -1) return;
2848
2950
  let o = u.spans[i];
2849
2951
  l[r].localRect = {
2850
2952
  ...l[r].localRect,
2851
- x: s.border.left + a.left + (d?.[i] ?? 0) + ye(o.start, n, e.advances),
2953
+ x: s.border.left + a.left + (d?.[i] ?? 0) + ke(o.start, n, e.advances),
2852
2954
  y: s.border.top + a.top + u.lineY[i]
2853
2955
  };
2854
2956
  });
@@ -2865,30 +2967,30 @@ function xn(e, t, n, r, i, a, o) {
2865
2967
  }
2866
2968
  return c;
2867
2969
  }
2868
- function Sn(e) {
2970
+ function Pn(e) {
2869
2971
  return e.children.some((e) => !B(e.style) && !e.inlineBox) ? !1 : e.text !== "" || e.style.display !== "flex" && e.style.display !== "grid";
2870
2972
  }
2871
2973
  function H(e, t, n) {
2872
2974
  return Math.max(t, n === void 0 ? e : Math.min(e, n));
2873
2975
  }
2874
- function Cn(e, t, n, r, i) {
2976
+ function Fn(e, t, n, r, i) {
2875
2977
  let a = e.style;
2876
2978
  if (a.display !== "flex" && a.display !== "grid" || t.spans.length === 0) return;
2877
- let o = a.display === "flex" && a.flexDirection === "column", s = t.spans.reduce((t, n) => Math.max(t, P(n.start, n.end, e.advances, a.tracking)), 0), c = Math.max(0, n - s);
2979
+ 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);
2878
2980
  if (c > 0) {
2879
- let e = a.display === "grid" ? L(a.justifyItems, n, s) : o ? L(a.alignItems, n, s) : F(Be(a), [s], 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];
2880
2982
  e > 0 && (i.left += e, i.right += c - e);
2881
2983
  }
2882
2984
  if (Number.isFinite(r)) {
2883
2985
  let e = Math.max(0, r - t.totalRows);
2884
2986
  if (e > 0) {
2885
- let n = a.display === "grid" || !o ? L(a.alignItems, r, t.totalRows) : F(Be(a), [t.totalRows], e)[0];
2987
+ let n = a.display === "grid" || !o ? qe(a.alignItems, r, t.totalRows) : L(Ze(a), [t.totalRows], e)[0];
2886
2988
  n > 0 && (i.top += n, i.bottom += e - n);
2887
2989
  }
2888
2990
  }
2889
2991
  }
2890
- function wn(e, t) {
2891
- let n = Tn(e, t), { heights: r, textOffsets: i } = En(e, n), a = [], o = [], s = 0;
2992
+ function In(e, t) {
2993
+ let n = Ln(e, t), { heights: r, textOffsets: i } = Rn(e, n), a = [], o = [], s = 0;
2892
2994
  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);
2893
2995
  return {
2894
2996
  spans: n,
@@ -2897,21 +2999,21 @@ function wn(e, t) {
2897
2999
  totalRows: s
2898
3000
  };
2899
3001
  }
2900
- function Tn(e, t) {
2901
- return e.style.whiteSpace === "normal" ? ve(e.text, t, {
3002
+ function Ln(e, t) {
3003
+ return e.style.whiteSpace === "normal" ? Oe(e.text, t, {
2902
3004
  advances: e.advances,
2903
3005
  tracking: e.style.tracking,
2904
3006
  firstLineIndent: e.style.textIndent
2905
- }) : _e(e.text);
3007
+ }) : De(e.text);
2906
3008
  }
2907
- function En(e, t) {
3009
+ function Rn(e, t) {
2908
3010
  let n = e.children.filter((e) => e.inlineBox), r = [], i = [], a = 0;
2909
3011
  for (let o of t) {
2910
3012
  let t = 1, s = 0;
2911
3013
  for (let r = o.start; r < o.end; r++) {
2912
3014
  if (e.text[r] !== "") continue;
2913
3015
  let i = n[a];
2914
- t = Math.max(t, i.localRect.height), i.style.verticalAlign === "end" ? s = Math.max(s, i.localRect.height - 1) : i.style.verticalAlign === "center" && b(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++;
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++;
2915
3017
  }
2916
3018
  r.push(t), i.push(Math.min(s, t - 1));
2917
3019
  }
@@ -2925,7 +3027,7 @@ function U(e, t, n) {
2925
3027
  return Math.max(r, i?.width ?? 0);
2926
3028
  }
2927
3029
  function W(e, t) {
2928
- return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : de(e.percent, t);
3030
+ return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : xe(e.percent, t);
2929
3031
  }
2930
3032
  function G(e, t) {
2931
3033
  let n = (e) => e === null ? null : W(e, t);
@@ -2936,16 +3038,16 @@ function G(e, t) {
2936
3038
  left: n(e.left)
2937
3039
  };
2938
3040
  }
2939
- function Dn(e) {
3041
+ function zn(e) {
2940
3042
  return typeof e == "number" ? e : 0;
2941
3043
  }
2942
3044
  function K(e, t) {
2943
- if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : de(e.percent, t);
3045
+ if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : xe(e.percent, t);
2944
3046
  }
2945
- function On(e, t, n, r) {
3047
+ function Bn(e, t, n, r) {
2946
3048
  return e === "min-content" || e === "max-content" || e === "fit-content" ? q({ kind: e }, t, n, r) : K(e, t);
2947
3049
  }
2948
- function kn(e, t, n, r, i, a) {
3050
+ function Vn(e, t, n, r, i, a) {
2949
3051
  let o = r.left + i.left, s = r.top + i.top, c = s, l = null;
2950
3052
  for (let r of e.children) {
2951
3053
  let e = G(r.style.margin, t), i = e.top ?? 0, s = e.bottom ?? 0, u = e.left ?? 0, d = e.right ?? 0;
@@ -2953,13 +3055,13 @@ function kn(e, t, n, r, i, a) {
2953
3055
  r.staticSlot = {
2954
3056
  kind: "block",
2955
3057
  x: o + u,
2956
- y: c + (l === null ? i : jn(l, i))
3058
+ y: c + (l === null ? i : Un(l, i))
2957
3059
  };
2958
3060
  continue;
2959
3061
  }
2960
3062
  V(r, Math.max(0, t - u - d), n, 0, 0, "fill", a);
2961
- let f = An(e, t, r.localRect.width);
2962
- c += l === null ? i : jn(l, i), r.localRect = {
3063
+ let f = Hn(e, t, r.localRect.width);
3064
+ c += l === null ? i : Un(l, i), r.localRect = {
2963
3065
  ...r.localRect,
2964
3066
  x: o + f,
2965
3067
  y: c
@@ -2967,37 +3069,37 @@ function kn(e, t, n, r, i, a) {
2967
3069
  }
2968
3070
  return l !== null && (c += l), c - s;
2969
3071
  }
2970
- function An(e, t, n) {
3072
+ function Hn(e, t, n) {
2971
3073
  let r = t - n;
2972
3074
  return e.left === null && e.right === null ? Math.floor(r / 2) : e.left === null ? r - (e.right ?? 0) : e.left;
2973
3075
  }
2974
- function jn(e, t) {
3076
+ function Un(e, t) {
2975
3077
  return e >= 0 && t >= 0 ? Math.max(e, t) : e <= 0 && t <= 0 ? Math.min(e, t) : e + t;
2976
3078
  }
2977
- function Mn(e, t, n, r, i) {
3079
+ function Wn(e, t, n, r, i) {
2978
3080
  let a = e.width;
2979
3081
  if (e.display === "table") {
2980
3082
  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));
2981
3083
  if (a !== void 0 && a.kind !== "auto") {
2982
3084
  let e = q(a, t, r, i);
2983
- return Math.max(e, Nn(r, t, i));
3085
+ return Math.max(e, Gn(r, t, i));
2984
3086
  }
2985
- return nn(r, t, i);
3087
+ return hn(r, t, i);
2986
3088
  }
2987
3089
  return a !== void 0 && a.kind !== "auto" ? q(a, t, r, i) : n === "shrink" ? Math.min(t, J(r, i)) : t;
2988
3090
  }
2989
- function Nn(e, t, n) {
3091
+ function Gn(e, t, n) {
2990
3092
  let r = e.style;
2991
- return tn(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t);
3093
+ return mn(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t);
2992
3094
  }
2993
- function Pn(e, t) {
3095
+ function Kn(e, t) {
2994
3096
  if (e.height?.kind === "cells") return e.height.value;
2995
- if (e.height?.kind === "percent" && t != null) return de(e.height.value, t);
3097
+ if (e.height?.kind === "percent" && t != null) return xe(e.height.value, t);
2996
3098
  }
2997
3099
  function q(e, t, n, r) {
2998
3100
  switch (e.kind) {
2999
3101
  case "cells": return e.value;
3000
- case "percent": return de(e.value, t);
3102
+ case "percent": return xe(e.value, t);
3001
3103
  case "min-content": return Y(n, r);
3002
3104
  case "max-content": return J(n, r);
3003
3105
  case "fit-content": return Math.min(J(n, r), Math.max(Y(n, r), t));
@@ -3007,42 +3109,42 @@ function q(e, t, n, r) {
3007
3109
  function J(e, t) {
3008
3110
  let n = t.maxContent.get(e);
3009
3111
  if (n !== void 0) return n;
3010
- let r = e.style, i = Fn(e, t) + r.border.left + r.border.right + Dn(r.padding.left) + Dn(r.padding.right);
3112
+ let r = e.style, i = qn(e, t) + r.border.left + r.border.right + zn(r.padding.left) + zn(r.padding.right);
3011
3113
  return t.maxContent.set(e, i), i;
3012
3114
  }
3013
- function Fn(e, t) {
3115
+ function qn(e, t) {
3014
3116
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
3015
- if (n.length === 0) return e.style.display === "multicol" ? Ct(e.style, e.intrinsicWidth) : e.intrinsicWidth;
3016
- if (e.style.display === "grid") return $e(e, t).max;
3017
- if (e.style.display === "table") return tn(e, t).max;
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;
3018
3120
  if (e.style.display === "flex" && e.style.flexDirection === "row") {
3019
- let r = Math.max(Dn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3121
+ let r = Math.max(zn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3020
3122
  return n.reduce((e, n) => e + J(n, t), 0) + r;
3021
3123
  }
3022
3124
  let r = n.reduce((e, n) => Math.max(e, J(n, t)), 0);
3023
- return e.style.display === "multicol" ? Ct(e.style, r) : r;
3125
+ return e.style.display === "multicol" ? Pt(e.style, r) : r;
3024
3126
  }
3025
3127
  function Y(e, t) {
3026
3128
  let n = t.minContent.get(e);
3027
3129
  if (n !== void 0) return n;
3028
- let r = e.style, i = In(e, t) + r.border.left + r.border.right + Dn(r.padding.left) + Dn(r.padding.right);
3130
+ let r = e.style, i = Jn(e, t) + r.border.left + r.border.right + zn(r.padding.left) + zn(r.padding.right);
3029
3131
  return t.minContent.set(e, i), i;
3030
3132
  }
3031
- function In(e, t) {
3133
+ function Jn(e, t) {
3032
3134
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
3033
- if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : xe(e.text, {
3135
+ if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : je(e.text, {
3034
3136
  advances: e.advances,
3035
3137
  tracking: e.style.tracking
3036
3138
  });
3037
- if (e.style.display === "grid") return $e(e, t).min;
3038
- if (e.style.display === "table") return tn(e, t).min;
3139
+ if (e.style.display === "grid") return ut(e, t).min;
3140
+ if (e.style.display === "table") return mn(e, t).min;
3039
3141
  if (e.style.display === "flex" && e.style.flexDirection === "row" && e.style.flexWrap === "nowrap") {
3040
- let r = Math.max(Dn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3142
+ let r = Math.max(zn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3041
3143
  return n.reduce((e, n) => e + Y(n, t), 0) + r;
3042
3144
  }
3043
3145
  return n.reduce((e, n) => Math.max(e, Y(n, t)), 0);
3044
3146
  }
3045
- function Ln(e, t, n, r) {
3147
+ function Yn(e, t, n, r) {
3046
3148
  return {
3047
3149
  width: Math.max(0, e - n.left - n.right - r.left - r.right),
3048
3150
  height: Math.max(0, t - n.top - n.bottom - r.top - r.bottom)
@@ -3050,38 +3152,38 @@ function Ln(e, t, n, r) {
3050
3152
  }
3051
3153
  //#endregion
3052
3154
  //#region src/plain-text.ts
3053
- function Rn(e) {
3054
- return Wn(e).grid.map((e) => e.join("").trimEnd()).join("\n");
3155
+ function Xn(e) {
3156
+ return nr(e).grid.map((e) => e.join("").trimEnd()).join("\n");
3055
3157
  }
3056
- function zn(e) {
3057
- let { grid: t, paints: n } = Wn(e);
3058
- return t.map((e, t) => Bn(e, n[t]));
3158
+ function Zn(e) {
3159
+ let { grid: t, paints: n } = nr(e);
3160
+ return t.map((e, t) => Qn(e, n[t]));
3059
3161
  }
3060
- function Bn(e, t) {
3162
+ function Qn(e, t) {
3061
3163
  let n = e.length;
3062
3164
  for (; n > 0 && e[n - 1] === " " && t[n - 1]?.backgroundColor === void 0;) n--;
3063
3165
  let r = [];
3064
3166
  for (let i = 0; i < n; i++) {
3065
3167
  let n = t[i], a = r[r.length - 1];
3066
- a && Vn(a, n) ? a.text += e[i] : r.push({
3168
+ a && $n(a, n) ? a.text += e[i] : r.push({
3067
3169
  text: e[i],
3068
3170
  ...n
3069
3171
  });
3070
3172
  }
3071
3173
  return r;
3072
3174
  }
3073
- function Vn(e, t) {
3175
+ function $n(e, t) {
3074
3176
  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;
3075
3177
  }
3076
- function Hn(e, t) {
3178
+ function er(e, t) {
3077
3179
  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);
3078
3180
  }
3079
- function Un(e) {
3181
+ function tr(e) {
3080
3182
  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;
3081
3183
  }
3082
- function Wn(e) {
3184
+ function nr(e) {
3083
3185
  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));
3084
- return Kn(e, 0, 0, (e, a, o, s) => {
3186
+ return ir(e, 0, 0, (e, a, o, s) => {
3085
3187
  if (e >= 0 && e < t && a >= 0 && a < n) {
3086
3188
  r[a][e] = o;
3087
3189
  let t = i[a][e];
@@ -3095,11 +3197,11 @@ function Wn(e) {
3095
3197
  paints: i
3096
3198
  };
3097
3199
  }
3098
- function Gn(e) {
3200
+ function rr(e) {
3099
3201
  let t = {};
3100
3202
  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;
3101
3203
  }
3102
- function Kn(e, t, n, r, i = 1) {
3204
+ function ir(e, t, n, r, i = 1) {
3103
3205
  if (e.tableHidden) return;
3104
3206
  let a = t + e.localRect.x, o = n + e.localRect.y, s = e.style, c = (e) => i >= 1 ? e : {
3105
3207
  ...e,
@@ -3110,7 +3212,7 @@ function Kn(e, t, n, r, i = 1) {
3110
3212
  for (let n = 0; n < e.localRect.height; n++) for (let i = 0; i < e.localRect.width; i++) r(a + i, o + n, " ", t);
3111
3213
  }
3112
3214
  let l = [];
3113
- k(s, {
3215
+ ce(s, {
3114
3216
  x: a,
3115
3217
  y: o,
3116
3218
  width: e.localRect.width,
@@ -3125,32 +3227,32 @@ function Kn(e, t, n, r, i = 1) {
3125
3227
  for (let n = 0; n < t.length; n++) r(a + t.x + n, o + t.y, t.glyph, e);
3126
3228
  }
3127
3229
  if (!e.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed") && e.text) {
3128
- 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 ?? wn(e, l), p = u ? Math.max(1, u.columnWidth - s.tracking) : l, m = c(Gn(s)), h = e.inlineElements?.map((e) => c(Gn(e)));
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)));
3129
3231
  for (let t = 0; t < d.length; t++) {
3130
- let a = d[t], o = i + f[t], l = t === 0 ? s.textIndent : 0, g = s.whiteSpace !== "normal" && s.overflow === "clip" ? qn(e.text, a, p - l, e.advances, s) : {
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) : {
3131
3233
  end: a.end,
3132
3234
  ellipsis: !1
3133
- }, _ = P(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;
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;
3134
3236
  for (let t = a.start; t < g.end; t++) {
3135
3237
  if (e.text[t] !== "") {
3136
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;
3137
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);
3138
3240
  }
3139
- b += ye(t, t + 1, e.advances);
3241
+ b += ke(t, t + 1, e.advances);
3140
3242
  }
3141
3243
  g.ellipsis && r(b, o, "…", m);
3142
3244
  }
3143
3245
  }
3144
- for (let t of te(e)) Kn(t, a, o, r, i * t.style.opacity);
3246
+ for (let t of de(e)) ir(t, a, o, r, i * t.style.opacity);
3145
3247
  }
3146
- function qn(e, t, n, r, i) {
3248
+ function ar(e, t, n, r, i) {
3147
3249
  let { textOverflow: a, tracking: o } = i;
3148
- if (P(t.start, t.end, r, o) <= n) return {
3250
+ if (I(t.start, t.end, r, o) <= n) return {
3149
3251
  end: t.end,
3150
3252
  ellipsis: !1
3151
3253
  };
3152
3254
  let s = a === "ellipsis" ? n - 1 : n, c = t.start;
3153
- for (; c < t.end && P(t.start, c + 1, r, o) <= s;) c++;
3255
+ for (; c < t.end && I(t.start, c + 1, r, o) <= s;) c++;
3154
3256
  return {
3155
3257
  end: c,
3156
3258
  ellipsis: a === "ellipsis" && n > 0
@@ -3158,61 +3260,61 @@ function qn(e, t, n, r, i) {
3158
3260
  }
3159
3261
  //#endregion
3160
3262
  //#region src/paint.ts
3161
- var Jn = /* @__PURE__ */ new WeakMap(), Yn = /* @__PURE__ */ new WeakMap();
3162
- function Xn(e) {
3163
- return $n(e, !0) !== null;
3164
- }
3165
- function Zn(e, t, n = !1) {
3166
- let r = zn(e), i = ir(r);
3167
- if (Jn.get(t) === i) return !0;
3168
- let a = Yn.get(t);
3169
- if (a && Qn(t, a.nodes, r)) {
3170
- Jn.set(t, i);
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);
3171
3273
  for (let e = 0; e < r.length; e++) for (let t = 0; t < r[e].length; t++) {
3172
3274
  let n = r[e][t];
3173
- if (Un(n) || Vn(n, a.segments[e][t])) continue;
3275
+ if (tr(n) || $n(n, a.segments[e][t])) continue;
3174
3276
  let i = a.nodes[e][t];
3175
- i.style.cssText = "", Hn(n, i.style);
3277
+ i.style.cssText = "", er(n, i.style);
3176
3278
  }
3177
3279
  return a.segments = r, !0;
3178
3280
  }
3179
- if (n && Xn(t)) return !1;
3180
- Jn.set(t, i);
3281
+ if (n && cr(t)) return !1;
3282
+ or.set(t, i);
3181
3283
  let o = document.createDocumentFragment(), s = [];
3182
3284
  for (let e = 0; e < r.length; e++) {
3183
3285
  e > 0 && o.appendChild(document.createTextNode("\n"));
3184
3286
  let t = [];
3185
3287
  for (let n of r[e]) {
3186
- if (Un(n)) {
3288
+ if (tr(n)) {
3187
3289
  let e = document.createTextNode(n.text);
3188
3290
  t.push(e), o.appendChild(e);
3189
3291
  continue;
3190
3292
  }
3191
3293
  let e = document.createElement("span");
3192
- Hn(n, e.style), e.textContent = n.text, t.push(e), o.appendChild(e);
3294
+ er(n, e.style), e.textContent = n.text, t.push(e), o.appendChild(e);
3193
3295
  }
3194
3296
  s.push(t);
3195
3297
  }
3196
- Yn.set(t, {
3298
+ sr.set(t, {
3197
3299
  nodes: s,
3198
3300
  segments: r
3199
3301
  });
3200
- let c = $n(t, !1);
3201
- return t.replaceChildren(o), c && er(t, c), !0;
3302
+ let c = dr(t, !1);
3303
+ return t.replaceChildren(o), c && fr(t, c), !0;
3202
3304
  }
3203
- function Qn(e, t, n) {
3305
+ function ur(e, t, n) {
3204
3306
  if (t.length !== n.length) return !1;
3205
3307
  for (let r = 0; r < n.length; r++) {
3206
3308
  let i = t[r], a = n[r];
3207
3309
  if (i.length !== a.length) return !1;
3208
3310
  for (let t = 0; t < a.length; t++) {
3209
3311
  let n = i[t];
3210
- if (Un(a[t]) !== (n.nodeType === Node.TEXT_NODE) || n.textContent !== a[t].text || n.parentNode !== e) return !1;
3312
+ if (tr(a[t]) !== (n.nodeType === Node.TEXT_NODE) || n.textContent !== a[t].text || n.parentNode !== e) return !1;
3211
3313
  }
3212
3314
  }
3213
3315
  return !0;
3214
3316
  }
3215
- function $n(e, t) {
3317
+ function dr(e, t) {
3216
3318
  try {
3217
3319
  let n = e.ownerDocument.getSelection();
3218
3320
  if (!n) return null;
@@ -3228,7 +3330,7 @@ function $n(e, t) {
3228
3330
  if (!e || e.rangeCount === 0) return null;
3229
3331
  i = e.getRangeAt(0);
3230
3332
  }
3231
- let a = tr(e, i.startContainer, i.startOffset), o = tr(e, i.endContainer, i.endOffset);
3333
+ let a = pr(e, i.startContainer, i.startOffset), o = pr(e, i.endContainer, i.endOffset);
3232
3334
  return a === null || o === null || a === o && !t ? null : {
3233
3335
  start: a,
3234
3336
  end: o,
@@ -3238,32 +3340,32 @@ function $n(e, t) {
3238
3340
  return null;
3239
3341
  }
3240
3342
  }
3241
- function er(e, t) {
3343
+ function fr(e, t) {
3242
3344
  try {
3243
- let n = nr(e, t.start), r = nr(e, t.end);
3345
+ let n = mr(e, t.start), r = mr(e, t.end);
3244
3346
  if (!n || !r) return;
3245
3347
  let i = e.getRootNode().getSelection?.() ?? e.ownerDocument.getSelection();
3246
3348
  t.backward ? i?.setBaseAndExtent(r[0], r[1], n[0], n[1]) : i?.setBaseAndExtent(n[0], n[1], r[0], r[1]);
3247
3349
  } catch {}
3248
3350
  }
3249
- function tr(e, t, n) {
3351
+ function pr(e, t, n) {
3250
3352
  if (!e.contains(t)) return null;
3251
3353
  let r = e.ownerDocument.createRange();
3252
3354
  return r.selectNodeContents(e), r.setEnd(t, n), r.toString().length;
3253
3355
  }
3254
- function nr(e, t) {
3356
+ function mr(e, t) {
3255
3357
  let n = t, r = null;
3256
- for (let t of rr(e)) {
3358
+ for (let t of hr(e)) {
3257
3359
  if (n <= t.data.length) return [t, n];
3258
3360
  n -= t.data.length, r = [t, t.data.length];
3259
3361
  }
3260
3362
  return r;
3261
3363
  }
3262
- function* rr(e) {
3364
+ function* hr(e) {
3263
3365
  let t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), n = t.nextNode();
3264
3366
  for (; n;) yield n, n = t.nextNode();
3265
3367
  }
3266
- function ir(e) {
3368
+ function gr(e) {
3267
3369
  let t = [];
3268
3370
  for (let n of e) {
3269
3371
  for (let e of n) t.push(e.text, e.color ?? "", e.backgroundColor ?? "", e.fontWeight ?? "", e.fontStyle ?? "", e.textDecorationLine ?? "", e.opacity ?? "");
@@ -3273,9 +3375,9 @@ function ir(e) {
3273
3375
  }
3274
3376
  //#endregion
3275
3377
  //#region src/render.ts
3276
- function ar(e) {
3378
+ function _r(e) {
3277
3379
  let t = /* @__PURE__ */ new Set();
3278
- or(e, !0, t);
3380
+ vr(e, !0, t);
3279
3381
  for (let n of Array.from(e.source.querySelectorAll("[data-mw-inline-inset]"))) if (!t.has(n)) {
3280
3382
  n.removeAttribute("data-mw-inline-inset");
3281
3383
  let e = n.style;
@@ -3296,65 +3398,65 @@ function Z(e, t) {
3296
3398
  function Q(e, t, n) {
3297
3399
  e.hasAttribute(t) !== n && (n ? e.setAttribute(t, "") : e.removeAttribute(t));
3298
3400
  }
3299
- function or(e, t, n) {
3401
+ function vr(e, t, n) {
3300
3402
  if (e.inlineElements) for (let { element: t, tracking: r, padLeft: i, padRight: a, insets: o } of e.inlineElements) {
3301
3403
  let e = t;
3302
- 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), sr(e, o));
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));
3303
3405
  }
3304
- if (t || lr(e), !e.tableHidden) for (let t of te(e)) {
3406
+ if (t || xr(e), !e.tableHidden) for (let t of de(e)) {
3305
3407
  let r = t.source;
3306
- t.style.zIndex !== null && j(t, e) && !t.inlineBox ? X(r, "--mw-z", String(t.style.zIndex)) : Z(r, "--mw-z"), or(t, !1, n);
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);
3307
3409
  }
3308
3410
  }
3309
- function sr(e, t) {
3411
+ function yr(e, t) {
3310
3412
  Q(e, "data-mw-inline-inset", !0);
3311
3413
  let n = (t, n) => {
3312
3414
  n === null ? Z(e, t) : X(e, t, String(n));
3313
3415
  };
3314
3416
  n("--mw-it", t.top), n("--mw-ir", t.right), n("--mw-ib", t.bottom), n("--mw-il", t.left);
3315
3417
  }
3316
- function cr(e) {
3418
+ function br(e) {
3317
3419
  let t = e.style;
3318
3420
  if (t.textAlign !== "center" || !e.text || e.inlineBox || e.children.length > 0) return !1;
3319
- 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 ?? Tn(e, i);
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);
3320
3422
  return o.length !== 0 && o.every((n, r) => {
3321
- let i = r === 0 ? t.textIndent : 0, o = a - i - P(n.start, n.end, e.advances, t.tracking);
3423
+ let i = r === 0 ? t.textIndent : 0, o = a - i - I(n.start, n.end, e.advances, t.tracking);
3322
3424
  return o > 0 && o % 2 == 1;
3323
3425
  });
3324
3426
  }
3325
- function lr(e) {
3427
+ function xr(e) {
3326
3428
  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;
3327
3429
  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);
3328
3430
  let f = u ?? d;
3329
3431
  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");
3330
3432
  let p = u || d ? void 0 : e.multicolGeometry;
3331
- 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", cr(e)), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
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);
3332
3434
  }
3333
3435
  //#endregion
3334
3436
  //#region src/style.ts
3335
- function ur(e, t, n) {
3336
- let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = wr(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
3337
- yr(e, o, s);
3338
- let c = r.display || gr[e.tagName] || "", l = _r[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, N(d, t)) : null, p = c === "flex" || c === "inline-flex" ? "flex" : c === "grid" || c === "inline-grid" ? "grid" : c === "table" || c === "inline-table" ? "table" : c === "none" || hr(r) ? "none" : u !== null || f !== null ? "multicol" : "block", m = { kind: "none" }, h = { kind: "none" }, g = [Ue()], _ = [Ue()], v = {
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 = {
3339
3441
  direction: "row",
3340
3442
  dense: !1
3341
3443
  }, y = null;
3342
3444
  if (p === "grid") {
3343
- if (a) m = Wr(a.get("grid-template-columns")?.toString() ?? "", t), h = Wr(a.get("grid-template-rows")?.toString() ?? "", t);
3445
+ if (a) m = ni(a.get("grid-template-columns")?.toString() ?? "", t), h = ni(a.get("grid-template-rows")?.toString() ?? "", t);
3344
3446
  else {
3345
3447
  e.setAttribute("data-mw-degrid", "");
3346
3448
  try {
3347
- m = Wr(r.getPropertyValue("grid-template-columns"), t), h = Wr(r.getPropertyValue("grid-template-rows"), t);
3449
+ m = ni(r.getPropertyValue("grid-template-columns"), t), h = ni(r.getPropertyValue("grid-template-rows"), t);
3348
3450
  } finally {
3349
3451
  e.removeAttribute("data-mw-degrid");
3350
3452
  }
3351
3453
  }
3352
- g = Jr(r.getPropertyValue("grid-auto-columns"), t), _ = Jr(r.getPropertyValue("grid-auto-rows"), t), v = ei(r.getPropertyValue("grid-auto-flow")), y = qr(r.getPropertyValue("grid-template-areas"));
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"));
3353
3455
  }
3354
3456
  let b = "auto", x = !1, S = 0, C = 0;
3355
3457
  if (p === "table" && (b = r.tableLayout === "fixed" ? "fixed" : "auto", x = r.borderCollapse === "collapse", !x)) {
3356
3458
  let e = r.borderSpacing.split(" ");
3357
- S = N(parseFloat(e[0] ?? "") || 0, t), C = N(parseFloat(e[1] ?? e[0] ?? "") || 0, t);
3459
+ S = F(parseFloat(e[0] ?? "") || 0, t), C = F(parseFloat(e[1] ?? e[0] ?? "") || 0, t);
3358
3460
  }
3359
3461
  let w = {
3360
3462
  display: p,
@@ -3364,61 +3466,61 @@ function ur(e, t, n) {
3364
3466
  borderSpacingX: S,
3365
3467
  borderSpacingY: C,
3366
3468
  captionSide: r.captionSide === "bottom" ? "bottom" : "top",
3367
- verticalAlign: l === "cell" || c.startsWith("inline-") ? vr(e, r) : "start",
3469
+ verticalAlign: l === "cell" || c.startsWith("inline-") ? Ar(e, r) : "start",
3368
3470
  flexDirection: r.flexDirection.startsWith("column") ? "column" : "row",
3369
3471
  flexReverse: r.flexDirection.endsWith("-reverse"),
3370
3472
  flexWrap: r.flexWrap.startsWith("wrap") ? "wrap" : "nowrap",
3371
3473
  wrapReverse: r.flexWrap === "wrap-reverse",
3372
3474
  flexGrow: Number(r.flexGrow) || 0,
3373
3475
  flexShrink: r.flexShrink === "" ? 1 : Number(r.flexShrink) || 0,
3374
- flexBasis: Hr(r.flexBasis, t),
3476
+ flexBasis: ei(r.flexBasis, t),
3375
3477
  order: Number(r.order) || 0,
3376
- justifyContent: Tr(r.justifyContent),
3377
- alignContent: Tr(r.alignContent),
3378
- alignItems: Er(r.alignItems),
3379
- alignSelf: Dr(r.alignSelf),
3380
- justifyItems: Er(r.justifyItems),
3381
- justifySelf: Dr(r.justifySelf),
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),
3382
3484
  gridTemplateColumns: m,
3383
3485
  gridTemplateRows: h,
3384
3486
  gridAutoColumns: g,
3385
3487
  gridAutoRows: _,
3386
3488
  gridAutoFlow: v,
3387
3489
  gridTemplateAreas: y,
3388
- gridColumnStart: $r(r.getPropertyValue("grid-column-start")),
3389
- gridColumnEnd: $r(r.getPropertyValue("grid-column-end")),
3390
- gridRowStart: $r(r.getPropertyValue("grid-row-start")),
3391
- gridRowEnd: $r(r.getPropertyValue("grid-row-end")),
3392
- width: Lr(a, r.width, "width", t, o, s, n),
3393
- height: Lr(a, r.height, "height", t, o, s, n),
3394
- minWidth: Vr(a, "min-width", r.minWidth, o, "min-w", s, n, t) ?? Pr(r.minWidth, t) ?? "auto",
3395
- minHeight: Vr(a, "min-height", r.minHeight, o, "min-h", s, n, t) ?? Pr(r.minHeight, t) ?? "auto",
3396
- maxWidth: Vr(a, "max-width", r.maxWidth, o, "max-w", s, n, t) ?? Pr(r.maxWidth, t),
3397
- maxHeight: Vr(a, "max-height", r.maxHeight, o, "max-h", s, n, t) ?? Pr(r.maxHeight, t),
3398
- padding: ni(r, t),
3399
- margin: Or(r, a, o, s, t),
3400
- position: jr(r.position),
3401
- insets: Mr(r, a, o, s, t),
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),
3402
3504
  gapX: $(r.columnGap === "normal" || r.columnGap === "" ? p === "multicol" ? `${i}px` : "0px" : r.columnGap, t),
3403
3505
  gapY: $(r.rowGap === "normal" ? "0px" : r.rowGap, t),
3404
- border: ri(r),
3506
+ border: hi(r),
3405
3507
  borderStyle: {
3406
- top: Nr(r.borderTopStyle),
3407
- right: Nr(r.borderRightStyle),
3408
- bottom: Nr(r.borderBottomStyle),
3409
- left: Nr(r.borderLeftStyle)
3508
+ top: Gr(r.borderTopStyle),
3509
+ right: Gr(r.borderRightStyle),
3510
+ bottom: Gr(r.borderBottomStyle),
3511
+ left: Gr(r.borderLeftStyle)
3410
3512
  },
3411
- overflow: mr(r.overflow) || mr(r.overflowX) || mr(r.overflowY) ? "clip" : "visible",
3513
+ overflow: Er(r.overflow) || Er(r.overflowX) || Er(r.overflowY) ? "clip" : "visible",
3412
3514
  whiteSpace: r.whiteSpace === "pre" ? "pre" : r.whiteSpace === "nowrap" ? "nowrap" : "normal",
3413
3515
  tabSize: Math.max(1, Math.floor(parseFloat(r.tabSize)) || 8),
3414
- lineGap: Ar(r.lineHeight, i),
3415
- tracking: kr(r.letterSpacing, i, n?.letterSpacing ?? 0),
3516
+ lineGap: Hr(r.lineHeight, i),
3517
+ tracking: Vr(r.letterSpacing, i, n?.letterSpacing ?? 0),
3416
3518
  textOverflow: r.textOverflow === "ellipsis" ? "ellipsis" : "clip",
3417
3519
  color: r.color,
3418
3520
  fontWeight: r.fontWeight,
3419
3521
  fontStyle: r.fontStyle,
3420
3522
  textDecorationLine: r.textDecorationLine,
3421
- backgroundColor: pr(e, r.backgroundColor, r),
3523
+ backgroundColor: Tr(e, r.backgroundColor, r),
3422
3524
  backgroundClear: r.getPropertyValue("--mw-bg-clear").trim() === "1",
3423
3525
  borderColor: {
3424
3526
  top: r.borderTopColor,
@@ -3426,17 +3528,18 @@ function ur(e, t, n) {
3426
3528
  bottom: r.borderBottomColor,
3427
3529
  left: r.borderLeftColor
3428
3530
  },
3429
- textAlignBlocked: Sr(e, r),
3430
- textAlign: Cr(e, r),
3431
- textIndent: Ir(r, t),
3432
- opacity: Fr(r.opacity),
3531
+ textAlignBlocked: Pr(e, r),
3532
+ textAlign: Fr(e, r),
3533
+ textIndent: Jr(r, t),
3534
+ opacity: qr(r.opacity),
3535
+ glyphSet: r.getPropertyValue("--mw-border-glyphs").trim() || null,
3433
3536
  zIndex: r.zIndex === "auto" || r.zIndex === "" ? null : Number(r.zIndex) || 0,
3434
3537
  latticeBorder: null,
3435
- ruleX: p === "flex" || p === "grid" || p === "multicol" ? xr(r, "x") : null,
3436
- ruleY: p === "flex" || p === "grid" ? xr(r, "y") : null,
3437
- ruleBreak: br(r, "--mw-rule-break", ["none", "intersection"], "normal"),
3438
- ruleInset: r.getPropertyValue("--mw-rule-inset").trim() === "overlap-join" ? "overlap-join" : Math.max(0, M(parseFloat(r.getPropertyValue("--mw-rule-inset")) || 0)),
3439
- ruleVisibilityItems: br(r, "--mw-rule-visibility-items", [
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"),
3541
+ 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", [
3440
3543
  "all",
3441
3544
  "around",
3442
3545
  "between"
@@ -3449,9 +3552,9 @@ function ur(e, t, n) {
3449
3552
  breakAfterColumn: r.breakAfter === "column",
3450
3553
  breakInsideAvoid: r.breakInside === "avoid" || r.breakInside === "avoid-column"
3451
3554
  };
3452
- return dr(w, r), w;
3555
+ return Cr(w, r), w;
3453
3556
  }
3454
- function dr(e, t) {
3557
+ function Cr(e, t) {
3455
3558
  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 = {
3456
3559
  width: e.border,
3457
3560
  style: e.borderStyle,
@@ -3462,26 +3565,26 @@ function dr(e, t) {
3462
3565
  bottom: t.borderBottomStyle === "hidden",
3463
3566
  left: t.borderLeftStyle === "hidden"
3464
3567
  }
3465
- }, e.border = R(), e.display === "table" && (e.padding = R()));
3568
+ }, e.border = z(), e.display === "table" && (e.padding = z()));
3466
3569
  }
3467
- function fr(e) {
3570
+ function wr(e) {
3468
3571
  if (!e) return !0;
3469
3572
  let t = e.trim().toLowerCase();
3470
3573
  return t === "" || t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "currentcolor";
3471
3574
  }
3472
- function pr(e, t, n) {
3473
- let i = r(e, fr(t) ? "" : t, n);
3575
+ function Tr(e, t, n) {
3576
+ let i = r(e, wr(t) ? "" : t, n);
3474
3577
  return i === "" ? void 0 : i;
3475
3578
  }
3476
- function mr(e) {
3579
+ function Er(e) {
3477
3580
  return e === "hidden" || e === "clip";
3478
3581
  }
3479
- function hr(e) {
3582
+ function Dr(e) {
3480
3583
  if (e.position !== "absolute" && e.position !== "fixed") return !1;
3481
3584
  let t = e.clip.replace(/\s/g, "");
3482
- return t === "rect(0px,0px,0px,0px)" || t === "rect(0,0,0,0)" || (mr(e.overflow) || mr(e.overflowX)) && parseFloat(e.width) <= 1 && parseFloat(e.height) <= 1;
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;
3483
3586
  }
3484
- var gr = {
3587
+ var Or = {
3485
3588
  TABLE: "table",
3486
3589
  THEAD: "table-header-group",
3487
3590
  TBODY: "table-row-group",
@@ -3492,7 +3595,7 @@ var gr = {
3492
3595
  CAPTION: "table-caption",
3493
3596
  COL: "table-column",
3494
3597
  COLGROUP: "table-column-group"
3495
- }, _r = {
3598
+ }, kr = {
3496
3599
  "table-header-group": "header-group",
3497
3600
  "table-row-group": "row-group",
3498
3601
  "table-footer-group": "footer-group",
@@ -3502,38 +3605,38 @@ var gr = {
3502
3605
  "table-column": "column",
3503
3606
  "table-column-group": "column-group"
3504
3607
  };
3505
- function vr(e, t) {
3608
+ function Ar(e, t) {
3506
3609
  let n = t.verticalAlign || e.getAttribute("valign")?.toLowerCase() || (e.tagName === "TD" || e.tagName === "TH" ? "middle" : "baseline");
3507
3610
  return n === "top" ? "start" : n === "middle" ? "center" : n === "bottom" ? "end" : "start";
3508
3611
  }
3509
- function yr(e, t, n) {
3510
- (/(?:^|[\s:.[!])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w-])/.test(t) || /(?:^|[\s:.[!])text-\[(?:(?:length|size):|[\d.])/.test(t) || n.fontSize !== "") && b(e, "font-size inside <mono-wind> is ignored — all text shares the host's cell size. Size the <mono-wind> element itself instead.");
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.");
3511
3614
  }
3512
- function br(e, t, n, r) {
3615
+ function Mr(e, t, n, r) {
3513
3616
  let i = e.getPropertyValue(t).trim();
3514
3617
  return n.includes(i) ? i : r;
3515
3618
  }
3516
- function xr(e, t) {
3517
- let n = M(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
3619
+ function Nr(e, t) {
3620
+ let n = P(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
3518
3621
  if (n <= 0) return null;
3519
3622
  let r = e.getPropertyValue(`--mw-rule-${t}-color`).trim();
3520
3623
  return {
3521
3624
  width: n,
3522
- style: Nr(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3625
+ style: Gr(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3523
3626
  color: r && r !== "currentcolor" && r !== "currentColor" ? r : e.color
3524
3627
  };
3525
3628
  }
3526
- function Sr(e, t) {
3629
+ function Pr(e, t) {
3527
3630
  return t.textAlign === "justify" || e.getAttribute("align")?.toLowerCase() === "justify";
3528
3631
  }
3529
- function Cr(e, t) {
3632
+ function Fr(e, t) {
3530
3633
  let n = t.textAlign || e.getAttribute("align")?.toLowerCase() || "";
3531
3634
  return n === "right" || n === "end" ? "end" : n === "center" || n.endsWith("-center") ? "center" : "start";
3532
3635
  }
3533
- function wr(e) {
3636
+ function Ir(e) {
3534
3637
  return typeof e.computedStyleMap == "function";
3535
3638
  }
3536
- function Tr(e) {
3639
+ function Lr(e) {
3537
3640
  switch (e) {
3538
3641
  case "center": return "center";
3539
3642
  case "flex-end":
@@ -3548,7 +3651,7 @@ function Tr(e) {
3548
3651
  default: return "start";
3549
3652
  }
3550
3653
  }
3551
- function Er(e) {
3654
+ function Rr(e) {
3552
3655
  switch (e) {
3553
3656
  case "center": return "center";
3554
3657
  case "flex-end":
@@ -3559,10 +3662,10 @@ function Er(e) {
3559
3662
  default: return "start";
3560
3663
  }
3561
3664
  }
3562
- function Dr(e) {
3563
- return e === "auto" || e === "" || e === "normal" ? "auto" : Er(e);
3665
+ function zr(e) {
3666
+ return e === "auto" || e === "" || e === "normal" ? "auto" : Rr(e);
3564
3667
  }
3565
- function Or(e, t, n, r, i) {
3668
+ function Br(e, t, n, r, i) {
3566
3669
  let a = (a, o, s) => {
3567
3670
  if (t) {
3568
3671
  let e = t.get(a)?.toString().trim();
@@ -3586,16 +3689,16 @@ function Or(e, t, n, r, i) {
3586
3689
  left: a("margin-left", "margin-inline-start", /(?:^|[\s:.[!])(?:m|mx|ml|ms)-auto\b/)
3587
3690
  };
3588
3691
  }
3589
- function kr(e, t, n) {
3692
+ function Vr(e, t, n) {
3590
3693
  let r = (e === "normal" ? 0 : parseFloat(e) || 0) - n;
3591
3694
  return r <= 0 ? 0 : Math.floor(r / (.025 * t) + 1e-6);
3592
3695
  }
3593
- function Ar(e, t) {
3696
+ function Hr(e, t) {
3594
3697
  if (!e || e === "normal" || t <= 0) return 0;
3595
3698
  let n = parseFloat(e);
3596
3699
  return Number.isFinite(n) ? Math.max(0, Math.floor(n / t + 1e-6) - 1) : 0;
3597
3700
  }
3598
- function jr(e) {
3701
+ function Ur(e) {
3599
3702
  switch (e) {
3600
3703
  case "relative":
3601
3704
  case "absolute":
@@ -3604,7 +3707,7 @@ function jr(e) {
3604
3707
  default: return "static";
3605
3708
  }
3606
3709
  }
3607
- function Mr(e, t, n, r, i) {
3710
+ function Wr(e, t, n, r, i) {
3608
3711
  let a = (a, o) => {
3609
3712
  if (t) {
3610
3713
  let e = t.get(a)?.toString().trim();
@@ -3623,7 +3726,7 @@ function Mr(e, t, n, r, i) {
3623
3726
  left: a("left", /(?:^|[\s:.[!])-?(?:left|start|inset|inset-x)-/)
3624
3727
  };
3625
3728
  }
3626
- function Nr(e) {
3729
+ function Gr(e) {
3627
3730
  switch (e) {
3628
3731
  case "double": return "double";
3629
3732
  case "dashed": return "dashed";
@@ -3631,7 +3734,7 @@ function Nr(e) {
3631
3734
  default: return "solid";
3632
3735
  }
3633
3736
  }
3634
- function Pr(e, t) {
3737
+ function Kr(e, t) {
3635
3738
  if (!e || e === "none" || e === "auto") return;
3636
3739
  if (e === "min-content" || e === "max-content" || e === "fit-content") return e;
3637
3740
  if (e.endsWith("%")) {
@@ -3639,7 +3742,7 @@ function Pr(e, t) {
3639
3742
  return Number.isFinite(t) ? { percent: t } : void 0;
3640
3743
  }
3641
3744
  let n = parseFloat(e);
3642
- return Number.isFinite(n) ? N(n, t) : void 0;
3745
+ return Number.isFinite(n) ? F(n, t) : void 0;
3643
3746
  }
3644
3747
  function $(e, t) {
3645
3748
  if (!e || e === "auto" || e === "none") return 0;
@@ -3648,30 +3751,30 @@ function $(e, t) {
3648
3751
  return Number.isFinite(t) && t !== 0 ? { percent: t } : 0;
3649
3752
  }
3650
3753
  let n = parseFloat(e);
3651
- return Number.isFinite(n) ? N(n, t) : 0;
3754
+ return Number.isFinite(n) ? F(n, t) : 0;
3652
3755
  }
3653
- function Fr(e) {
3756
+ function qr(e) {
3654
3757
  let t = parseFloat(e);
3655
3758
  return Number.isFinite(t) ? Math.min(1, Math.max(0, t)) : 1;
3656
3759
  }
3657
- function Ir(e, t) {
3760
+ function Jr(e, t) {
3658
3761
  let n = e.textIndent;
3659
3762
  if (!n || n.endsWith("%")) return 0;
3660
3763
  let r = parseFloat(n);
3661
- return Number.isFinite(r) ? Math.max(0, N(r, t)) : 0;
3764
+ return Number.isFinite(r) ? Math.max(0, F(r, t)) : 0;
3662
3765
  }
3663
- function Lr(e, t, n, r, i, a, o) {
3664
- let s = Rr(n === "width" ? a.width : a.height);
3766
+ function Yr(e, t, n, r, i, a, o) {
3767
+ let s = Xr(n === "width" ? a.width : a.height);
3665
3768
  if (s !== null) return {
3666
3769
  kind: "cells",
3667
- value: Br(s, n, o, r)
3770
+ value: Qr(s, n, o, r)
3668
3771
  };
3669
- let c = zr(i, n === "width" ? "w" : "h");
3772
+ let c = Zr(i, n === "width" ? "w" : "h");
3670
3773
  if (c !== null) {
3671
3774
  let i = parseFloat(e ? String(e.get(n) ?? "") : t), a = Number.isFinite(i) && Math.abs(i - c) <= c * .3;
3672
3775
  if (a || !Number.isFinite(i)) return {
3673
3776
  kind: "cells",
3674
- value: Br(a ? i : c, n, o, r)
3777
+ value: Qr(a ? i : c, n, o, r)
3675
3778
  };
3676
3779
  }
3677
3780
  if (e) {
@@ -3679,7 +3782,7 @@ function Lr(e, t, n, r, i, a, o) {
3679
3782
  if (t == null) return;
3680
3783
  let i = t.toString().trim();
3681
3784
  if (i === "auto") return { kind: "auto" };
3682
- let a = Ur(i);
3785
+ let a = ti(i);
3683
3786
  if (a) return a;
3684
3787
  if (i.endsWith("%")) return {
3685
3788
  kind: "percent",
@@ -3687,22 +3790,22 @@ function Lr(e, t, n, r, i, a, o) {
3687
3790
  };
3688
3791
  if (i.endsWith("px")) return {
3689
3792
  kind: "cells",
3690
- value: N(parseFloat(i), r)
3793
+ value: F(parseFloat(i), r)
3691
3794
  };
3692
3795
  if (i.endsWith("rem")) return {
3693
3796
  kind: "cells",
3694
- value: M(parseFloat(i) / .25)
3797
+ value: P(parseFloat(i) / .25)
3695
3798
  };
3696
- let s = Rr(i);
3799
+ let s = Xr(i);
3697
3800
  if (s !== null) return {
3698
3801
  kind: "cells",
3699
- value: Br(s, n, o, r)
3802
+ value: Qr(s, n, o, r)
3700
3803
  };
3701
3804
  }
3702
3805
  let l = n === "width" ? a.width : a.height;
3703
3806
  if (l) {
3704
3807
  if (l === "auto") return { kind: "auto" };
3705
- let e = Ur(l);
3808
+ let e = ti(l);
3706
3809
  if (e) return e;
3707
3810
  if (l.endsWith("%")) return {
3708
3811
  kind: "percent",
@@ -3711,7 +3814,7 @@ function Lr(e, t, n, r, i, a, o) {
3711
3814
  let t = parseFloat(l);
3712
3815
  if (Number.isFinite(t)) return {
3713
3816
  kind: "cells",
3714
- value: N(t, r)
3817
+ value: F(t, r)
3715
3818
  };
3716
3819
  }
3717
3820
  let u = n === "width" ? "w" : "h";
@@ -3735,9 +3838,9 @@ function Lr(e, t, n, r, i, a, o) {
3735
3838
  let p = RegExp(`(?:^|[\\s:.[!])${u}-(\\d+(?:\\.\\d+)?)(?![\\w-/])`).exec(i);
3736
3839
  if (p) return {
3737
3840
  kind: "cells",
3738
- value: M(Number(p[1]))
3841
+ value: P(Number(p[1]))
3739
3842
  };
3740
- if (!ti(i, u) || t === "auto") return { kind: "auto" };
3843
+ if (!pi(i, u) || t === "auto") return { kind: "auto" };
3741
3844
  if (t.endsWith("%")) return {
3742
3845
  kind: "percent",
3743
3846
  value: parseFloat(t)
@@ -3745,10 +3848,10 @@ function Lr(e, t, n, r, i, a, o) {
3745
3848
  let m = parseFloat(t);
3746
3849
  if (Number.isFinite(m)) return {
3747
3850
  kind: "cells",
3748
- value: N(m, r)
3851
+ value: F(m, r)
3749
3852
  };
3750
3853
  }
3751
- function Rr(e) {
3854
+ function Xr(e) {
3752
3855
  let t = /^(-?[\d.]+)((?:[dsl]?v)(?:h|w|min|max)|vi|vb)$/.exec(e.trim());
3753
3856
  if (!t || typeof window > "u") return null;
3754
3857
  let n = parseFloat(t[1]);
@@ -3756,7 +3859,7 @@ function Rr(e) {
3756
3859
  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;
3757
3860
  return n / 100 * o;
3758
3861
  }
3759
- function zr(e, t) {
3862
+ function Zr(e, t) {
3760
3863
  if (typeof window > "u") return null;
3761
3864
  let n = RegExp(`(?:^|[\\s:.[!])${t}-(screen|[dsl]v[hw])(?![\\w-])`).exec(e);
3762
3865
  if (n) {
@@ -3764,23 +3867,23 @@ function zr(e, t) {
3764
3867
  return e === "screen" ? t.includes("h") ? window.innerHeight : window.innerWidth : e.endsWith("h") ? window.innerHeight : window.innerWidth;
3765
3868
  }
3766
3869
  let r = RegExp(`(?:^|[\\s:.[!])${t}-\\[(-?[\\d.]+(?:[dsl]?v(?:h|w|min|max)|vi|vb))\\]`).exec(e);
3767
- return r ? Rr(r[1]) : null;
3870
+ return r ? Xr(r[1]) : null;
3768
3871
  }
3769
- function Br(e, t, n, r) {
3872
+ function Qr(e, t, n, r) {
3770
3873
  let i = t === "width" ? n?.width : n?.height;
3771
- return i && i > 0 ? Math.max(0, Math.floor(e / i)) : N(e, r);
3874
+ return i && i > 0 ? Math.max(0, Math.floor(e / i)) : F(e, r);
3772
3875
  }
3773
- function Vr(e, t, n, r, i, a, o, s) {
3774
- let c = t.endsWith("width") ? "width" : "height", l = Rr(a.getPropertyValue(t)) ?? Rr(e?.get(t)?.toString().trim() ?? "");
3775
- if (l !== null) return Br(l, c, o, s);
3776
- let u = zr(r, i);
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);
3777
3880
  if (u === null) return;
3778
3881
  let d = parseFloat(e ? String(e.get(t) ?? "") : n), f = Number.isFinite(d) && Math.abs(d - u) <= u * .3;
3779
- if (!(!f && Number.isFinite(d))) return Br(f ? d : u, c, o, s);
3882
+ if (!(!f && Number.isFinite(d))) return Qr(f ? d : u, c, o, s);
3780
3883
  }
3781
- function Hr(e, t) {
3884
+ function ei(e, t) {
3782
3885
  if (!e || e === "auto" || e === "content") return;
3783
- let n = Ur(e);
3886
+ let n = ti(e);
3784
3887
  if (n) return n;
3785
3888
  if (e.endsWith("%")) {
3786
3889
  let t = parseFloat(e);
@@ -3792,30 +3895,30 @@ function Hr(e, t) {
3792
3895
  let r = parseFloat(e);
3793
3896
  return Number.isFinite(r) ? {
3794
3897
  kind: "cells",
3795
- value: N(r, t)
3898
+ value: F(r, t)
3796
3899
  } : void 0;
3797
3900
  }
3798
- function Ur(e) {
3901
+ function ti(e) {
3799
3902
  if (e === "min-content") return { kind: "min-content" };
3800
3903
  if (e === "max-content") return { kind: "max-content" };
3801
3904
  if (e === "fit-content") return { kind: "fit-content" };
3802
3905
  }
3803
- function Wr(e, t) {
3906
+ function ni(e, t) {
3804
3907
  let n = e.trim();
3805
3908
  if (!n || n === "none") return { kind: "none" };
3806
3909
  if (n === "subgrid" || n.startsWith("subgrid ")) return { kind: "subgrid" };
3807
3910
  let r = [], i = [], a = [], o = (e) => {
3808
3911
  i.push(a), a = [], r.push(e);
3809
3912
  }, s;
3810
- for (let e of Qr(n)) {
3811
- let n = Kr(e);
3913
+ for (let e of ui(n)) {
3914
+ let n = ii(e);
3812
3915
  if (n) {
3813
3916
  a.push(...n);
3814
3917
  continue;
3815
3918
  }
3816
3919
  let i = e.match(/^repeat\(\s*([^,]+?)\s*,(.*)\)$/s);
3817
3920
  if (i) {
3818
- let e = Gr(i[2].trim(), t);
3921
+ let e = ri(i[2].trim(), t);
3819
3922
  if (e.tracks.length === 0) continue;
3820
3923
  let n = i[1];
3821
3924
  if (n === "auto-fill" || n === "auto-fit") {
@@ -3833,7 +3936,7 @@ function Wr(e, t) {
3833
3936
  }
3834
3937
  continue;
3835
3938
  }
3836
- o(Yr(e, t));
3939
+ o(si(e, t));
3837
3940
  }
3838
3941
  if (i.push(a), r.length === 0 && !s) return { kind: "none" };
3839
3942
  let c = {
@@ -3842,26 +3945,26 @@ function Wr(e, t) {
3842
3945
  };
3843
3946
  return i.some((e) => e.length > 0) && (c.lineNames = i), s && (c.autoRepeat = s), c;
3844
3947
  }
3845
- function Gr(e, t) {
3948
+ function ri(e, t) {
3846
3949
  let n = [], r = [], i = [];
3847
- for (let a of Qr(e)) {
3848
- let e = Kr(a);
3950
+ for (let a of ui(e)) {
3951
+ let e = ii(a);
3849
3952
  if (e) {
3850
3953
  i.push(...e);
3851
3954
  continue;
3852
3955
  }
3853
- r.push(i), i = [], n.push(Yr(a, t));
3956
+ r.push(i), i = [], n.push(si(a, t));
3854
3957
  }
3855
3958
  return r.push(i), {
3856
3959
  tracks: n,
3857
3960
  lineNames: r
3858
3961
  };
3859
3962
  }
3860
- function Kr(e) {
3963
+ function ii(e) {
3861
3964
  let t = e.match(/^\[(.*)\]$/s);
3862
3965
  return t ? t[1].split(/\s+/).filter((e) => e !== "") : null;
3863
3966
  }
3864
- function qr(e) {
3967
+ function ai(e) {
3865
3968
  let t = [];
3866
3969
  for (let n of e.matchAll(/"([^"]*)"|'([^']*)'/g)) {
3867
3970
  let e = (n[1] ?? n[2] ?? "").trim().split(/\s+/).filter((e) => e !== "");
@@ -3891,23 +3994,23 @@ function qr(e) {
3891
3994
  areas: r
3892
3995
  };
3893
3996
  }
3894
- function Jr(e, t) {
3895
- let n = Qr(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => Yr(e, t));
3896
- return n.length > 0 ? n : [Ue()];
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()];
3897
4000
  }
3898
- function Yr(e, t) {
4001
+ function si(e, t) {
3899
4002
  let n = e.match(/^minmax\((.*)\)$/s);
3900
4003
  if (n) {
3901
- let e = Zr(n[1]).map((e) => e.trim());
4004
+ let e = li(n[1]).map((e) => e.trim());
3902
4005
  return e.length === 2 ? {
3903
- min: Xr(e[0], t),
3904
- max: Xr(e[1], t)
4006
+ min: ci(e[0], t),
4007
+ max: ci(e[1], t)
3905
4008
  } : {
3906
4009
  min: { kind: "auto" },
3907
4010
  max: { kind: "auto" }
3908
4011
  };
3909
4012
  }
3910
- let r = Xr(e, t);
4013
+ let r = ci(e, t);
3911
4014
  return r.kind === "fr" ? {
3912
4015
  min: { kind: "auto" },
3913
4016
  max: r
@@ -3916,13 +4019,13 @@ function Yr(e, t) {
3916
4019
  max: r
3917
4020
  };
3918
4021
  }
3919
- function Xr(e, t) {
4022
+ function ci(e, t) {
3920
4023
  if (e === "auto" || e.startsWith("fit-content")) return { kind: "auto" };
3921
4024
  if (e === "min-content") return { kind: "min-content" };
3922
4025
  if (e === "max-content") return { kind: "max-content" };
3923
4026
  let n = e.match(/^(min|max)\((.*)\)$/s);
3924
4027
  if (n) {
3925
- let e = Zr(n[2]).map((e) => Xr(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
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");
3926
4029
  return e.length > 0 && r ? {
3927
4030
  kind: "math",
3928
4031
  fn: n[1],
@@ -3946,10 +4049,10 @@ function Xr(e, t) {
3946
4049
  let r = parseFloat(e);
3947
4050
  return Number.isFinite(r) ? {
3948
4051
  kind: "cells",
3949
- value: e.endsWith("rem") ? M(r / .25) : N(r, t)
4052
+ value: e.endsWith("rem") ? P(r / .25) : F(r, t)
3950
4053
  } : { kind: "auto" };
3951
4054
  }
3952
- function Zr(e) {
4055
+ function li(e) {
3953
4056
  let t = [], n = 0, r = 0;
3954
4057
  for (let i = 0; i < e.length; i++) {
3955
4058
  let a = e[i];
@@ -3957,7 +4060,7 @@ function Zr(e) {
3957
4060
  }
3958
4061
  return t.push(e.slice(r)), t.filter((e) => e.trim() !== "");
3959
4062
  }
3960
- function Qr(e) {
4063
+ function ui(e) {
3961
4064
  let t = [], n = 0, r = -1;
3962
4065
  for (let i = 0; i < e.length; i++) {
3963
4066
  let a = e[i];
@@ -3965,7 +4068,7 @@ function Qr(e) {
3965
4068
  }
3966
4069
  return r !== -1 && t.push(e.slice(r)), t;
3967
4070
  }
3968
- function $r(e) {
4071
+ function di(e) {
3969
4072
  let t = e.trim();
3970
4073
  if (!t || t === "auto") return { kind: "auto" };
3971
4074
  let n = !1, r, i;
@@ -3993,16 +4096,16 @@ function $r(e) {
3993
4096
  nth: r
3994
4097
  };
3995
4098
  }
3996
- function ei(e) {
4099
+ function fi(e) {
3997
4100
  return {
3998
4101
  direction: e.includes("column") ? "column" : "row",
3999
4102
  dense: e.includes("dense")
4000
4103
  };
4001
4104
  }
4002
- function ti(e, t) {
4105
+ function pi(e, t) {
4003
4106
  return (t === "w" ? /(?:^|[\s:.[!])w-/ : /(?:^|[\s:.[!])h-/).test(e);
4004
4107
  }
4005
- function ni(e, t) {
4108
+ function mi(e, t) {
4006
4109
  return {
4007
4110
  top: $(e.getPropertyValue("padding-top"), t),
4008
4111
  right: $(e.getPropertyValue("padding-right"), t),
@@ -4010,8 +4113,8 @@ function ni(e, t) {
4010
4113
  left: $(e.getPropertyValue("padding-left"), t)
4011
4114
  };
4012
4115
  }
4013
- function ri(e) {
4014
- let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : M(parseFloat(e.getPropertyValue(t)) || 0);
4116
+ function hi(e) {
4117
+ let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : P(parseFloat(e.getPropertyValue(t)) || 0);
4015
4118
  return {
4016
4119
  top: t("border-top-width", "border-top-style"),
4017
4120
  right: t("border-right-width", "border-right-style"),
@@ -4021,14 +4124,14 @@ function ri(e) {
4021
4124
  }
4022
4125
  //#endregion
4023
4126
  //#region src/tree.ts
4024
- function ii(e, t, n, r) {
4025
- let i = ur(e, t, n);
4127
+ function gi(e, t, n, r) {
4128
+ let i = Sr(e, t, n);
4026
4129
  if (i.display === "none") return null;
4027
- let a = T(e.tagName);
4028
- if (a) return ai(e, i, a);
4029
- let o = Array.from(e.children), s = o.map(ui), c = e.tagName, l = xi(c);
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);
4030
4133
  if (!s.includes("block") || l) {
4031
- let a = di(e, i.tracking, {
4134
+ let a = Ci(e, i.tracking, {
4032
4135
  rootFontSizePx: t,
4033
4136
  rootLetterSpacingPx: n?.letterSpacing ?? 0,
4034
4137
  cellMetrics: n,
@@ -4037,12 +4140,12 @@ function ii(e, t, n, r) {
4037
4140
  tabSize: i.tabSize
4038
4141
  }), u = a.chars.join("");
4039
4142
  if (a.boxes.length > 0) {
4040
- let e = bn();
4041
- Se(a.chars, (t, n) => {
4143
+ let e = Mn();
4144
+ Me(a.chars, (t, n) => {
4042
4145
  a.advances[t] = Math.max(1, J(a.boxes[n], e));
4043
4146
  });
4044
4147
  }
4045
- let d = gi(u, a.advances, i.tracking);
4148
+ let d = Oi(u, a.advances, i.tracking);
4046
4149
  if (l && d === 0) {
4047
4150
  if (c === "INPUT") d = Number(e.size) || 20;
4048
4151
  else if (c === "TEXTAREA") d = Number(e.cols) || 20;
@@ -4051,9 +4154,9 @@ function ii(e, t, n, r) {
4051
4154
  d = Math.max(1, ...r.map((e) => e.trim().length));
4052
4155
  }
4053
4156
  }
4054
- let f = u.length > 0 ? _i(u) : 0, p;
4157
+ let f = u.length > 0 ? ki(u) : 0, p;
4055
4158
  if (c === "TEXTAREA") {
4056
- let t = e, n = t.value ?? "", a = r?.get(t), o = +!!n.endsWith("\n"), s = a !== void 0 && a > 0 ? he(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);
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);
4057
4160
  p = l + Math.max(0, l - 1) * i.lineGap;
4058
4161
  } else p = l ? Math.max(1, f) : f;
4059
4162
  let m = /* @__PURE__ */ new Map(), h = [];
@@ -4063,7 +4166,7 @@ function ii(e, t, n, r) {
4063
4166
  let i = o[e], a = m.get(i);
4064
4167
  if (a) g.push(a);
4065
4168
  else if (s[e] === "out-of-flow") {
4066
- let e = ii(i, t, n, r);
4169
+ let e = gi(i, t, n, r);
4067
4170
  e && g.push(e);
4068
4171
  }
4069
4172
  }
@@ -4082,14 +4185,14 @@ function ii(e, t, n, r) {
4082
4185
  height: p
4083
4186
  },
4084
4187
  unclampedHeight: 0,
4085
- resolvedPadding: R()
4188
+ resolvedPadding: z()
4086
4189
  };
4087
4190
  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)), _;
4088
4191
  }
4089
4192
  let u = [];
4090
4193
  for (let e = 0; e < o.length; e++) {
4091
4194
  if (s[e] === "none") continue;
4092
- let i = ii(o[e], t, n, r);
4195
+ let i = gi(o[e], t, n, r);
4093
4196
  i && u.push(i);
4094
4197
  }
4095
4198
  let d = {
@@ -4106,34 +4209,36 @@ function ii(e, t, n, r) {
4106
4209
  height: 0
4107
4210
  },
4108
4211
  unclampedHeight: 0,
4109
- resolvedPadding: R()
4212
+ resolvedPadding: z()
4110
4213
  };
4111
- return Si(e, d), d;
4214
+ return Pi(e, d), d;
4112
4215
  }
4113
- function ai(e, t, n) {
4114
- let r = ee(n, e), i = r?.lines ?? [], a = i.join("\n");
4216
+ function _i(e, t, n) {
4217
+ let r = oe(n, e), i = r?.lines ?? [], a = i.join("\n");
4115
4218
  t.whiteSpace = "pre", (t.width === void 0 || t.width.kind === "auto") && (t.width = { kind: "max-content" });
4116
- let o = gi(a, Array.from({ length: a.length }, () => 1), t.tracking), s = i.length, c = {
4219
+ let o = Array.from({ length: a.length }, () => 1 + t.tracking), s = Oi(a, o, t.tracking), c = i.length, l = {
4117
4220
  source: e,
4118
4221
  style: t,
4119
4222
  children: [],
4120
4223
  text: a,
4121
- intrinsicWidth: o,
4122
- intrinsicHeight: s,
4224
+ intrinsicWidth: s,
4225
+ intrinsicHeight: c,
4123
4226
  localRect: {
4124
4227
  x: 0,
4125
4228
  y: 0,
4126
- width: o,
4127
- height: s
4229
+ width: s,
4230
+ height: c
4128
4231
  },
4129
4232
  unclampedHeight: 0,
4130
- resolvedPadding: R()
4131
- }, l = r?.runs ?? [];
4132
- if (l.length > 0 && a.length > 0) {
4233
+ resolvedPadding: z()
4234
+ };
4235
+ t.tracking > 0 && (l.advances = o);
4236
+ let u = r?.runs ?? [];
4237
+ if (u.length > 0 && a.length > 0) {
4133
4238
  let t = [0];
4134
4239
  for (let e of i) t.push(t[t.length - 1] + e.length + 1);
4135
4240
  let n = Array.from({ length: a.length }, () => -1);
4136
- c.inlineElements = l.map((t) => ({
4241
+ l.inlineElements = u.map((t) => ({
4137
4242
  element: e,
4138
4243
  tracking: 0,
4139
4244
  padLeft: 0,
@@ -4144,32 +4249,32 @@ function ai(e, t, n) {
4144
4249
  fontWeight: t.paint.fontWeight ?? "",
4145
4250
  fontStyle: t.paint.fontStyle ?? "",
4146
4251
  textDecorationLine: t.paint.textDecorationLine ?? ""
4147
- })), l.forEach((e, r) => {
4252
+ })), u.forEach((e, r) => {
4148
4253
  let a = i[e.line];
4149
4254
  if (a === void 0) return;
4150
4255
  let o = Math.max(0, e.start), s = Math.min(a.length, e.end);
4151
4256
  for (let i = o; i < s; i++) n[t[e.line] + i] = r;
4152
- }), c.charInline = n;
4257
+ }), l.charInline = n;
4153
4258
  }
4154
- return c;
4259
+ return l;
4155
4260
  }
4156
- var oi = /* @__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("."));
4157
- function si(e, t) {
4158
- return t || (oi.has(e.tagName) ? "inline" : "block");
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");
4159
4264
  }
4160
- function ci(e, t) {
4161
- let n = si(e, t);
4265
+ function bi(e, t) {
4266
+ let n = yi(e, t);
4162
4267
  return n === "inline" || n === "contents";
4163
4268
  }
4164
- function li(e, t) {
4165
- let n = si(e, t);
4269
+ function xi(e, t) {
4270
+ let n = yi(e, t);
4166
4271
  return n.startsWith("inline") && n !== "inline";
4167
4272
  }
4168
- function ui(e) {
4273
+ function Si(e) {
4169
4274
  let t = getComputedStyle(e);
4170
- return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : T(e.tagName) ? "block" : ci(e, t.display) || li(e, t.display) ? "inline" : "block";
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";
4171
4276
  }
4172
- function di(e, t, n) {
4277
+ function Ci(e, t, n) {
4173
4278
  let r = {
4174
4279
  chars: [],
4175
4280
  advances: [],
@@ -4177,15 +4282,15 @@ function di(e, t, n) {
4177
4282
  inlineElements: [],
4178
4283
  boxes: []
4179
4284
  };
4180
- return fi(e, t, n, r), n.preserve ? r : hi(r);
4285
+ return wi(e, t, n, r), n.preserve ? r : Di(r);
4181
4286
  }
4182
- function fi(e, t, n, r) {
4287
+ function wi(e, t, n, r) {
4183
4288
  let i = () => {
4184
4289
  let e = 0;
4185
4290
  for (let t = r.chars.length - 1; t >= 0 && r.chars[t] !== "\n"; t--) e += r.advances[t];
4186
4291
  return e;
4187
4292
  };
4188
- if (!xi(e.tagName)) {
4293
+ if (!Ni(e.tagName)) {
4189
4294
  for (let a of Array.from(e.childNodes)) if (a.nodeType === Node.TEXT_NODE) {
4190
4295
  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);
4191
4296
  else if (e === " ") {
@@ -4201,24 +4306,24 @@ function fi(e, t, n, r) {
4201
4306
  }
4202
4307
  let t = getComputedStyle(e);
4203
4308
  if (t.display === "none" || t.position === "absolute" || t.position === "fixed") continue;
4204
- if (li(e, t.display)) {
4205
- let t = ii(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4309
+ if (xi(e, t.display)) {
4310
+ let t = gi(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4206
4311
  t && (t.inlineBox = !0, r.chars.push(""), r.advances.push(1), r.boxes.push(t));
4207
4312
  continue;
4208
4313
  }
4209
- if (!ci(e, t.display)) {
4210
- vi(e);
4314
+ if (!bi(e, t.display)) {
4315
+ Ai(e);
4211
4316
  continue;
4212
4317
  }
4213
- let i = kr(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = pi(t.paddingLeft, n.rootFontSizePx), s = pi(t.paddingRight, n.rootFontSizePx);
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);
4214
4319
  r.inlineElements.push({
4215
4320
  element: e,
4216
4321
  tracking: i,
4217
4322
  padLeft: o,
4218
4323
  padRight: s,
4219
- insets: t.position === "static" ? null : mi(t, n.rootFontSizePx),
4324
+ insets: t.position === "static" ? null : Ei(t, n.rootFontSizePx),
4220
4325
  color: t.color,
4221
- backgroundColor: fr(t.backgroundColor) ? void 0 : t.backgroundColor,
4326
+ backgroundColor: wr(t.backgroundColor) ? void 0 : t.backgroundColor,
4222
4327
  fontWeight: t.fontWeight,
4223
4328
  fontStyle: t.fontStyle,
4224
4329
  textDecorationLine: t.textDecorationLine
@@ -4226,22 +4331,22 @@ function fi(e, t, n, r) {
4226
4331
  let c = r.inlineElements.length - 1;
4227
4332
  for (let e = 0; e < o; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
4228
4333
  let l = r.chars.length;
4229
- fi(e, i, n, r);
4334
+ wi(e, i, n, r);
4230
4335
  for (let e = l; e < r.chars.length; e++) r.inlineIndex[e] === void 0 && (r.inlineIndex[e] = c);
4231
4336
  for (let e = 0; e < s; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
4232
4337
  }
4233
4338
  }
4234
4339
  }
4235
- function pi(e, t) {
4340
+ function Ti(e, t) {
4236
4341
  if (!e || e.endsWith("%")) return 0;
4237
4342
  let n = parseFloat(e);
4238
- return Number.isFinite(n) ? Math.max(0, N(n, t)) : 0;
4343
+ return Number.isFinite(n) ? Math.max(0, F(n, t)) : 0;
4239
4344
  }
4240
- function mi(e, t) {
4345
+ function Ei(e, t) {
4241
4346
  let n = (e) => {
4242
4347
  if (!e || e === "auto" || e.endsWith("%")) return null;
4243
4348
  let n = parseFloat(e);
4244
- return Number.isFinite(n) ? N(n, t) : null;
4349
+ return Number.isFinite(n) ? F(n, t) : null;
4245
4350
  };
4246
4351
  return {
4247
4352
  top: n(e.top),
@@ -4250,7 +4355,7 @@ function mi(e, t) {
4250
4355
  left: n(e.left)
4251
4356
  };
4252
4357
  }
4253
- function hi(e) {
4358
+ function Di(e) {
4254
4359
  let t = [], n = [], r = [], i = () => {
4255
4360
  let e = t.length;
4256
4361
  for (; e > 0 && t[e - 1] !== "\n";) e--;
@@ -4275,30 +4380,30 @@ function hi(e) {
4275
4380
  boxes: e.boxes
4276
4381
  };
4277
4382
  }
4278
- function gi(e, t, n) {
4383
+ function Oi(e, t, n) {
4279
4384
  let r = 0, i = 0;
4280
- for (let a = 0; a <= e.length; a++) (a === e.length || e[a] === "\n") && (r = Math.max(r, P(i, a, t, n)), i = a + 1);
4385
+ 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);
4281
4386
  return r;
4282
4387
  }
4283
- function _i(e) {
4284
- return _e(e).length;
4388
+ function ki(e) {
4389
+ return De(e).length;
4285
4390
  }
4286
- function vi(e) {
4287
- b(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.");
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.");
4288
4393
  }
4289
- function yi(e) {
4394
+ function ji(e) {
4290
4395
  return Array.from(e.childNodes).some((e) => e.nodeType === Node.TEXT_NODE && /[^ \t\r\n\f]/.test(e.textContent ?? ""));
4291
4396
  }
4292
- var bi = "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>).";
4293
- function xi(e) {
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) {
4294
4399
  return e === "INPUT" || e === "SELECT" || e === "TEXTAREA";
4295
4400
  }
4296
- function Si(e, t) {
4297
- yi(e) && (t.droppedText = !0, b(e, bi));
4401
+ function Pi(e, t) {
4402
+ ji(e) && (t.droppedText = !0, M(e, Mi));
4298
4403
  }
4299
4404
  //#endregion
4300
4405
  //#region src/element.ts
4301
- var Ci = "\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 /* Full invert on selection (TUI-native, matches focus-visible).\n * Both fields spelled out — setting only color makes some engines\n * drop the OS default background. */\n ::selection { color: 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", wi = "grid", Ti = [
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 = [
4302
4407
  "pointerover",
4303
4408
  "pointerleave",
4304
4409
  "pointerdown",
@@ -4310,12 +4415,12 @@ var Ci = "\n<style>\n :host { display: block; position: relative; contain: layo
4310
4415
  "focusout",
4311
4416
  "input",
4312
4417
  "change"
4313
- ], Ei = /^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/, Di = 3e4, Oi = typeof HTMLElement > "u" ? class {} : HTMLElement, ki = class e extends Oi {
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 {
4314
4419
  static observedAttributes = ["select"];
4315
4420
  static #e = /* @__PURE__ */ new Set();
4316
4421
  static #t = null;
4317
4422
  static #n = () => {
4318
- for (let t of e.#e) t.#W();
4423
+ for (let t of e.#e) t.#G();
4319
4424
  };
4320
4425
  static #r(t) {
4321
4426
  t instanceof HTMLLinkElement && t.rel === "stylesheet" && !t.sheet && t.addEventListener("load", e.#n, { once: !0 });
@@ -4345,7 +4450,8 @@ var Ci = "\n<style>\n :host { display: block; position: relative; contain: layo
4345
4450
  #f = null;
4346
4451
  #p = null;
4347
4452
  #m = null;
4348
- #h() {
4453
+ #h = null;
4454
+ #g() {
4349
4455
  this.#u?.observe(this, {
4350
4456
  childList: !0,
4351
4457
  subtree: !0,
@@ -4357,89 +4463,89 @@ var Ci = "\n<style>\n :host { display: block; position: relative; contain: layo
4357
4463
  "colspan",
4358
4464
  "rowspan",
4359
4465
  "span",
4360
- ...E()
4466
+ ...ie()
4361
4467
  ]
4362
4468
  });
4363
4469
  }
4364
4470
  constructor() {
4365
- super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = Ci, 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);
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);
4366
4472
  }
4367
4473
  connectedCallback() {
4368
- this.hasAttribute("select") || this.setAttribute("select", wi), this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#W()), this.#l.observe(this), this.#l.observe(this.#c), window.addEventListener("resize", this.#B), this.#u = new MutationObserver(() => this.#W()), this.#h(), this.#m = D(() => {
4369
- this.#h(), this.#W();
4370
- }), document.fonts?.ready.then(this.#V).catch((e) => {
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) => {
4371
4477
  console.warn("[monowind] document.fonts.ready failed:", e);
4372
- }), document.fonts?.addEventListener("loadingdone", this.#V);
4373
- for (let e of Ti) this.addEventListener(e, this.#z);
4374
- this.addEventListener("transitionrun", this.#I), this.addEventListener("transitionend", this.#L), this.addEventListener("transitioncancel", this.#L), this.addEventListener("pointermove", this.#E), this.addEventListener("pointerleave", this.#D), this.addEventListener("pointerdown", this.#O), window.addEventListener("pointerup", this.#k), window.addEventListener("pointercancel", this.#k), document.addEventListener("scroll", this.#A, {
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, {
4375
4481
  capture: !0,
4376
4482
  passive: !0
4377
- }), e.#i(this), this.#W();
4483
+ }), e.#i(this), this.#G();
4378
4484
  }
4379
4485
  disconnectedCallback() {
4380
- window.removeEventListener("resize", this.#B), this.#l?.disconnect(), this.#u?.disconnect(), this.#l = null, this.#u = null, this.#m?.(), this.#m = null, document.fonts?.removeEventListener("loadingdone", this.#V);
4381
- for (let e of Ti) this.removeEventListener(e, this.#z);
4382
- this.removeEventListener("transitionrun", this.#I), this.removeEventListener("transitionend", this.#L), this.removeEventListener("transitioncancel", this.#L), this.#N = 0, this.removeEventListener("pointermove", this.#E), this.removeEventListener("pointerleave", this.#D), this.removeEventListener("pointerdown", this.#O), window.removeEventListener("pointerup", this.#k), window.removeEventListener("pointercancel", this.#k), document.removeEventListener("scroll", this.#A, { capture: !0 }), this.#x = null, this.#v = null, this.#y = !1, this.#b = !1, this.#j(), e.#a(this);
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);
4383
4489
  }
4384
- #g = /* @__PURE__ */ new Set();
4385
4490
  #_ = /* @__PURE__ */ new Set();
4386
- #v = null;
4387
- #y = !1;
4491
+ #v = /* @__PURE__ */ new Set();
4492
+ #y = null;
4388
4493
  #b = !1;
4389
- #x = null;
4390
- #S = NaN;
4494
+ #x = !1;
4495
+ #S = null;
4391
4496
  #C = NaN;
4392
- #w = null;
4393
- static #T = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
4394
- #E = (e) => {
4497
+ #w = NaN;
4498
+ #T = null;
4499
+ static #E = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
4500
+ #D = (e) => {
4395
4501
  let { clientX: t, clientY: n } = e;
4396
- this.#x = {
4502
+ this.#S = {
4397
4503
  x: t,
4398
4504
  y: n
4399
4505
  };
4400
- let r = this.#w, i = this.#f;
4506
+ let r = this.#T, i = this.#f;
4401
4507
  if (r && i) {
4402
4508
  let e = Math.floor((t - r.left) / i.width), a = Math.floor((n - r.top) / i.height);
4403
- if (e === this.#S && a === this.#C) return;
4509
+ if (e === this.#C && a === this.#w) return;
4404
4510
  }
4405
- this.#j();
4511
+ this.#M();
4406
4512
  };
4407
- #D = () => {
4408
- this.#x = null, this.#j();
4513
+ #O = () => {
4514
+ this.#S = null, this.#M();
4409
4515
  };
4410
- #O = (e) => {
4516
+ #k = (e) => {
4411
4517
  let t = e;
4412
- !t.isPrimary || t.button !== 0 || (this.#x = {
4518
+ !t.isPrimary || t.button !== 0 || (this.#S = {
4413
4519
  x: t.clientX,
4414
4520
  y: t.clientY
4415
- }, this.#y = !0, this.#j(!0));
4521
+ }, this.#b = !0, this.#M(!0));
4416
4522
  };
4417
- #k = (e) => {
4418
- e.isPrimary && (!this.#y && !this.#v || (this.#y = !1, this.#v = null, this.#j(), this.#b && this.#W()));
4523
+ #A = (e) => {
4524
+ e.isPrimary && (!this.#b && !this.#y || (this.#b = !1, this.#y = null, this.#M(), this.#x && this.#G()));
4419
4525
  };
4420
- #A = () => {
4421
- this.#x && (this.#w = null, this.#j());
4526
+ #j = () => {
4527
+ this.#S && (this.#T = null, this.#M());
4422
4528
  };
4423
- #j(t = !1) {
4529
+ #M(t = !1) {
4424
4530
  let n = this.#p, r = this.#f, i = [];
4425
- if (this.#x && n && r && this.isConnected && this.getAttribute("select") === "grid" && (this.#y || e.#T?.matches)) {
4426
- if (!this.#w) {
4531
+ if (this.#S && n && r && this.isConnected && this.getAttribute("select") === "grid" && (this.#b || e.#E?.matches)) {
4532
+ if (!this.#T) {
4427
4533
  let e = this.#s.getBoundingClientRect();
4428
- this.#w = {
4534
+ this.#T = {
4429
4535
  left: e.left,
4430
4536
  top: e.top
4431
4537
  };
4432
4538
  }
4433
- this.#S = Math.floor((this.#x.x - this.#w.left) / r.width), this.#C = Math.floor((this.#x.y - this.#w.top) / r.height), i = ue(n, this.#S, this.#C);
4434
- } else this.#S = NaN, this.#C = NaN;
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;
4435
4541
  let a = i.at(-1) ?? null;
4436
- t && (this.#v = a);
4437
- let o = e.#T?.matches ? i : [], s = this.#v ? i.indexOf(this.#v) : -1, c = s >= 0 ? i.slice(0, s + 1) : [], l = this.#M("data-mw-hover", this.#g, o);
4438
- l = this.#M("data-mw-active", this.#_, c) || l;
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;
4439
4545
  let u = a ? getComputedStyle(a).cursor : "";
4440
- this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#W();
4546
+ this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#G();
4441
4547
  }
4442
- #M(e, t, n) {
4548
+ #N(e, t, n) {
4443
4549
  let r = !1, i = new Set(n);
4444
4550
  for (let n of t) i.has(n) || (n.removeAttribute(e), r = !0);
4445
4551
  for (let n of i) t.has(n) || (n.setAttribute(e, ""), r = !0);
@@ -4447,51 +4553,51 @@ var Ci = "\n<style>\n :host { display: block; position: relative; contain: layo
4447
4553
  for (let e of i) t.add(e);
4448
4554
  return r;
4449
4555
  }
4450
- #N = 0;
4451
- #P = !1;
4452
- #F = 0;
4453
- #I = (e) => {
4454
- Ei.test(e.propertyName) && (this.#N++, this.#F = performance.now(), this.#R());
4455
- };
4556
+ #P = 0;
4557
+ #F = !1;
4558
+ #I = 0;
4456
4559
  #L = (e) => {
4457
- Ei.test(e.propertyName) && (this.#N = Math.max(0, this.#N - 1));
4560
+ Ri.test(e.propertyName) && (this.#P++, this.#I = performance.now(), this.#z());
4458
4561
  };
4459
- #R() {
4460
- if (this.#P) return;
4461
- this.#P = !0;
4562
+ #R = (e) => {
4563
+ Ri.test(e.propertyName) && (this.#P = Math.max(0, this.#P - 1));
4564
+ };
4565
+ #z() {
4566
+ if (this.#F) return;
4567
+ this.#F = !0;
4462
4568
  let e = () => {
4463
- if (!this.isConnected || this.#N === 0 && !a() || performance.now() - this.#F > Di) {
4464
- this.#P = !1, this.#N = 0, this.#W();
4569
+ if (!this.isConnected || this.#P === 0 && !a() || performance.now() - this.#I > zi) {
4570
+ this.#F = !1, this.#P = 0, this.#G();
4465
4571
  return;
4466
4572
  }
4467
- this.#U(), requestAnimationFrame(e);
4573
+ this.#W(), requestAnimationFrame(e);
4468
4574
  };
4469
4575
  requestAnimationFrame(e);
4470
4576
  }
4471
- #z = (e) => {
4577
+ #B = (e) => {
4472
4578
  if ((e.type === "focusin" || e.type === "focusout") && e.target instanceof HTMLSelectElement) {
4473
- this.#U();
4579
+ this.#W();
4474
4580
  return;
4475
4581
  }
4476
- this.#W();
4582
+ this.#G();
4477
4583
  };
4478
4584
  attributeChangedCallback(e, t, n) {
4479
4585
  if (e === "select" && n !== "text" && n !== "grid") {
4480
- n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, this), this.setAttribute("select", wi);
4586
+ n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, this), this.setAttribute("select", Ii);
4481
4587
  return;
4482
4588
  }
4483
- e === "select" && this.#j(), this.#W();
4589
+ e === "select" && this.#M(), this.#G();
4484
4590
  }
4485
4591
  toPlainText() {
4486
- return this.#d && this.#G(), this.#p ? Rn(this.#p) : "";
4592
+ return this.#d && this.#K(), this.#p ? Xn(this.#p) : "";
4487
4593
  }
4488
- #B = () => {
4489
- this.#W();
4490
- };
4491
4594
  #V = () => {
4492
- requestAnimationFrame(() => this.#W());
4595
+ this.#G();
4596
+ };
4597
+ #H = () => {
4598
+ requestAnimationFrame(() => this.#G());
4493
4599
  };
4494
- #H() {
4600
+ #U() {
4495
4601
  let e = document.activeElement;
4496
4602
  if (!(e instanceof HTMLSelectElement) || !this.contains(e)) return !1;
4497
4603
  try {
@@ -4500,23 +4606,23 @@ var Ci = "\n<style>\n :host { display: block; position: relative; contain: layo
4500
4606
  return !1;
4501
4607
  }
4502
4608
  }
4503
- #U() {
4609
+ #W() {
4504
4610
  try {
4505
- this.#G();
4611
+ this.#K();
4506
4612
  } catch (e) {
4507
4613
  console.error("[monowind] layout failed:", e);
4508
4614
  }
4509
4615
  }
4510
- #W() {
4616
+ #G() {
4511
4617
  this.#d || (this.#d = !0, requestAnimationFrame(() => {
4512
- if (this.#d = !1, this.#H()) {
4513
- this.#W();
4618
+ if (this.#d = !1, this.#U()) {
4619
+ this.#G();
4514
4620
  return;
4515
4621
  }
4516
- this.#U();
4622
+ this.#W();
4517
4623
  }));
4518
4624
  }
4519
- #G() {
4625
+ #K() {
4520
4626
  if (!this.isConnected) return;
4521
4627
  let e = /* @__PURE__ */ new Map(), t = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), n = parseFloat(t);
4522
4628
  if (Number.isFinite(n) && n > 0) for (let t of this.querySelectorAll("textarea")) {
@@ -4526,23 +4632,23 @@ var Ci = "\n<style>\n :host { display: block; position: relative; contain: layo
4526
4632
  this.setAttribute("measuring", "");
4527
4633
  try {
4528
4634
  this.#c.parentNode !== this && this.appendChild(this.#c);
4529
- let t = fe(this, this.#c), n = this.#f;
4635
+ let t = Se(this, this.#c), n = this.#f;
4530
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;
4531
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));
4532
4638
  if (a === 0) return;
4533
- let o = pe(), s = [];
4639
+ let o = Ce(), s = [];
4534
4640
  for (let n of Array.from(this.children)) {
4535
4641
  if (n === this.#c) continue;
4536
- let r = ii(n, o, t, e);
4642
+ let r = gi(n, o, t, e);
4537
4643
  r && s.push(r);
4538
4644
  }
4539
- if (yi(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${bi}`, this), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), s.length === 0) {
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) {
4540
4646
  this.#s.replaceChildren(), this.#p = null, this.setAttribute("data-mw-ready", "");
4541
4647
  return;
4542
4648
  }
4543
4649
  let c = {
4544
4650
  source: this,
4545
- style: He(),
4651
+ style: $e(),
4546
4652
  children: s,
4547
4653
  text: "",
4548
4654
  intrinsicWidth: 0,
@@ -4554,20 +4660,20 @@ var Ci = "\n<style>\n :host { display: block; position: relative; contain: layo
4554
4660
  height: 0
4555
4661
  },
4556
4662
  unclampedHeight: 0,
4557
- resolvedPadding: R()
4558
- }, { height: l } = vn(c, a);
4559
- ar(c), this.#b = !Zn(c, this.#s, this.#y), this.#p = c;
4663
+ resolvedPadding: z()
4664
+ }, { height: l } = An(c, a);
4665
+ _r(c), this.#x = !lr(c, this.#s, this.#b), this.#p = c;
4560
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`;
4561
4667
  this.style.height !== d && (this.style.height = d), this.hasAttribute("data-mw-ready") || this.setAttribute("data-mw-ready", "");
4562
4668
  } finally {
4563
- this.setAttribute("settling", ""), this.removeAttribute("measuring"), getComputedStyle(this).transitionProperty, this.removeAttribute("settling"), this.#u?.takeRecords(), i(this) && (a() ? (this.#F = performance.now(), this.#R()) : this.#W()), this.#w = null, this.#x && this.#j();
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();
4564
4670
  }
4565
4671
  }
4566
4672
  };
4567
- function Ai() {
4568
- typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", ki);
4673
+ function Hi() {
4674
+ typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", Vi);
4569
4675
  }
4570
4676
  //#endregion
4571
- export { ki as MonoWindElement, Ai as defineMonoWind, w as invalidateLeaves, Mt as multicolLines, C as registerLeafRenderer, Rn as renderPlainText, me as wrapLines };
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 };
4572
4678
 
4573
4679
  //# sourceMappingURL=index.js.map