monowind 0.1.7 → 0.1.8

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
@@ -1,98 +1,313 @@
1
+ //#region src/animate.ts
2
+ var e = /* @__PURE__ */ new WeakMap(), t = [], n = /* @__PURE__ */ new Map();
3
+ function r(r, i, a) {
4
+ let s = e.get(r);
5
+ e.set(r, i);
6
+ let c = n.get(r);
7
+ if (c) {
8
+ if (i !== c.toValue) {
9
+ let e = o(c);
10
+ return n.delete(r), t.push({
11
+ el: r,
12
+ from: e,
13
+ to: i
14
+ }), e;
15
+ }
16
+ let e = o(c);
17
+ return e === c.toValue && n.delete(r), e;
18
+ }
19
+ return s !== void 0 && s !== i && a.transitionDuration.split(",").some((e) => parseFloat(e) > 0) ? (t.push({
20
+ el: r,
21
+ from: s,
22
+ to: i
23
+ }), s) : i;
24
+ }
25
+ function i(e) {
26
+ let r = !1;
27
+ for (let i = t.length - 1; i >= 0; i--) {
28
+ let { el: a, from: o, to: s } = t[i];
29
+ if (!a.isConnected) {
30
+ t.splice(i, 1);
31
+ continue;
32
+ }
33
+ if (!e.contains(a)) continue;
34
+ t.splice(i, 1), r = !0;
35
+ let l = c(getComputedStyle(a), "background-color"), u = f(o), d = f(s);
36
+ !l || !u || !d || n.set(a, {
37
+ from: u,
38
+ to: d,
39
+ toValue: s,
40
+ start: performance.now() + l.delay,
41
+ duration: l.duration,
42
+ easing: l.easing
43
+ });
44
+ }
45
+ return r;
46
+ }
47
+ function a() {
48
+ let e = performance.now();
49
+ for (let [t, r] of n) (!t.isConnected || e >= r.start + r.duration) && n.delete(t);
50
+ return n.size > 0;
51
+ }
52
+ function o(e) {
53
+ let t = (performance.now() - e.start) / e.duration;
54
+ if (t >= 1) return e.toValue;
55
+ let n = t <= 0 ? 0 : e.easing(t);
56
+ return m(p(e.from, e.to, n));
57
+ }
58
+ var s = {
59
+ ease: [
60
+ .25,
61
+ .1,
62
+ .25,
63
+ 1
64
+ ],
65
+ "ease-in": [
66
+ .42,
67
+ 0,
68
+ 1,
69
+ 1
70
+ ],
71
+ "ease-out": [
72
+ 0,
73
+ 0,
74
+ .58,
75
+ 1
76
+ ],
77
+ "ease-in-out": [
78
+ .42,
79
+ 0,
80
+ .58,
81
+ 1
82
+ ]
83
+ };
84
+ function c(e, t) {
85
+ let n = e.transitionProperty.split(",").map((e) => e.trim()), r = -1;
86
+ for (let e = 0; e < n.length; e++) (n[e] === t || n[e] === "all") && (r = e);
87
+ if (r < 0) return null;
88
+ let i = (e) => {
89
+ let t = e.split(",").map((e) => e.trim());
90
+ return t[r % t.length] ?? "";
91
+ }, a = l(i(e.transitionDuration));
92
+ return a <= 0 ? null : {
93
+ duration: a * 1e3,
94
+ delay: l(i(e.transitionDelay)) * 1e3,
95
+ easing: u(i(e.transitionTimingFunction))
96
+ };
97
+ }
98
+ function l(e) {
99
+ let t = parseFloat(e);
100
+ return Number.isFinite(t) ? e.endsWith("ms") ? t / 1e3 : t : 0;
101
+ }
102
+ function u(e) {
103
+ if (e === "linear") return (e) => e;
104
+ let t = s[e];
105
+ if (t) return d(...t);
106
+ let n = e.match(/^cubic-bezier\(([^)]+)\)$/);
107
+ if (n) {
108
+ let [e, t, r, i] = n[1].split(",").map((e) => parseFloat(e));
109
+ if ([
110
+ e,
111
+ t,
112
+ r,
113
+ i
114
+ ].every((e) => Number.isFinite(e))) return d(e, t, r, i);
115
+ }
116
+ return (e) => e;
117
+ }
118
+ function d(e, t, n, r) {
119
+ let i = (e, t, n) => 3 * e * n * (1 - n) * (1 - n) + 3 * t * n * n * (1 - n) + n * n * n;
120
+ return (a) => {
121
+ let o = 0, s = 1;
122
+ for (let t = 0; t < 24; t++) {
123
+ let t = (o + s) / 2;
124
+ i(e, n, t) < a ? o = t : s = t;
125
+ }
126
+ return i(t, r, (o + s) / 2);
127
+ };
128
+ }
129
+ function f(e) {
130
+ if (e === "" || e === "transparent") return {
131
+ r: 0,
132
+ g: 0,
133
+ b: 0,
134
+ a: 0,
135
+ legacy: !0
136
+ };
137
+ let t = e.match(/^rgba?\(([^)]+)\)$/);
138
+ if (t) {
139
+ let e = t[1].split(/[\s,/]+/).map((e) => parseFloat(e));
140
+ return e.length < 3 || e.some((e) => !Number.isFinite(e)) ? null : {
141
+ r: e[0] / 255,
142
+ g: e[1] / 255,
143
+ b: e[2] / 255,
144
+ a: e[3] ?? 1,
145
+ legacy: !0
146
+ };
147
+ }
148
+ if (t = e.match(/^color\(srgb ([^)]+)\)$/), t) {
149
+ let e = t[1].split(/[\s/]+/).map((e) => parseFloat(e));
150
+ return e.length < 3 || e.slice(0, 3).some((e) => !Number.isFinite(e)) ? null : {
151
+ r: e[0],
152
+ g: e[1],
153
+ b: e[2],
154
+ a: e[3] ?? 1,
155
+ legacy: !1
156
+ };
157
+ }
158
+ if (t = e.match(/^okl(ch|ab)\(([^)]+)\)$/), t) {
159
+ let e = t[1] === "ch", n = t[2].replaceAll("none", "0").split(/[\s/]+/).map((e) => parseFloat(e));
160
+ if (n.length < 3 || n.some((e) => !Number.isFinite(e))) return null;
161
+ let [r, i, a] = n;
162
+ return {
163
+ ...v(r, e ? i * Math.cos(a * Math.PI / 180) : i, e ? i * Math.sin(a * Math.PI / 180) : a),
164
+ a: n[3] ?? 1,
165
+ legacy: !1
166
+ };
167
+ }
168
+ return null;
169
+ }
170
+ function p(e, t, n) {
171
+ let r = e.a + (t.a - e.a) * n, i = (i, a) => {
172
+ let o = i * e.a + (a * t.a - i * e.a) * n;
173
+ return r === 0 ? 0 : o / r;
174
+ };
175
+ if (e.legacy && t.legacy) return {
176
+ r: i(e.r, t.r),
177
+ g: i(e.g, t.g),
178
+ b: i(e.b, t.b),
179
+ a: r,
180
+ legacy: !0
181
+ };
182
+ let a = _(e.r, e.g, e.b), o = _(t.r, t.g, t.b);
183
+ return {
184
+ ...v(i(a.l, o.l), i(a.a, o.a), i(a.b, o.b)),
185
+ a: r,
186
+ legacy: !1
187
+ };
188
+ }
189
+ function m(e) {
190
+ let t = (e) => Math.round(Math.min(1, Math.max(0, e)) * 255), n = Math.round(Math.min(1, Math.max(0, e.a)) * 1e3) / 1e3;
191
+ return `rgba(${t(e.r)}, ${t(e.g)}, ${t(e.b)}, ${n})`;
192
+ }
193
+ function h(e) {
194
+ return e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
195
+ }
196
+ function g(e) {
197
+ return e <= .0031308 ? e * 12.92 : 1.055 * e ** (1 / 2.4) - .055;
198
+ }
199
+ function _(e, t, n) {
200
+ let r = h(e), i = h(t), a = h(n), o = Math.cbrt(.4122214708 * r + .5363325363 * i + .0514459929 * a), s = Math.cbrt(.2119034982 * r + .6806995451 * i + .1073969566 * a), c = Math.cbrt(.0883024619 * r + .2817188376 * i + .6299787005 * a);
201
+ return {
202
+ l: .2104542553 * o + .793617785 * s - .0040720468 * c,
203
+ a: 1.9779984951 * o - 2.428592205 * s + .4505937099 * c,
204
+ b: .0259040371 * o + .7827717662 * s - .808675766 * c
205
+ };
206
+ }
207
+ function v(e, t, n) {
208
+ let r = (e + .3963377774 * t + .2158037573 * n) ** 3, i = (e - .1055613458 * t - .0638541728 * n) ** 3, a = (e - .0894841775 * t - 1.291485548 * n) ** 3;
209
+ return {
210
+ r: g(4.0767416621 * r - 3.3077115913 * i + .2309699292 * a),
211
+ g: g(-1.2684380046 * r + 2.6097574011 * i - .3413193965 * a),
212
+ b: g(-.0041960863 * r - .7034186147 * i + 1.707614701 * a)
213
+ };
214
+ }
215
+ //#endregion
1
216
  //#region src/borders.ts
2
- function e(e, n, r) {
3
- let i = e.border;
4
- if (i.top === 0 && i.right === 0 && i.bottom === 0 && i.left === 0) return;
5
- let a = Math.max(i.top, i.right, i.bottom, i.left);
6
- for (let o = 0; o < a; o++) {
7
- let a = {
8
- top: o < i.top,
9
- right: o < i.right,
10
- bottom: o < i.bottom,
11
- left: o < i.left
12
- }, s = {
13
- x: n.x + (a.left ? o : 0),
14
- y: n.y + (a.top ? o : 0),
15
- width: n.width - (a.left ? o : 0) - (a.right ? o : 0),
16
- height: n.height - (a.top ? o : 0) - (a.bottom ? o : 0)
217
+ function y(e, t, n) {
218
+ let r = e.border;
219
+ if (r.top === 0 && r.right === 0 && r.bottom === 0 && r.left === 0) return;
220
+ let i = Math.max(r.top, r.right, r.bottom, r.left);
221
+ for (let a = 0; a < i; a++) {
222
+ let i = {
223
+ top: a < r.top,
224
+ right: a < r.right,
225
+ bottom: a < r.bottom,
226
+ left: a < r.left
227
+ }, o = {
228
+ x: t.x + (i.left ? a : 0),
229
+ y: t.y + (i.top ? a : 0),
230
+ width: t.width - (i.left ? a : 0) - (i.right ? a : 0),
231
+ height: t.height - (i.top ? a : 0) - (i.bottom ? a : 0)
17
232
  };
18
- s.width <= 0 || s.height <= 0 || t(r, e.borderStyle, e.borderColor, s, a);
233
+ o.width <= 0 || o.height <= 0 || b(n, e.borderStyle, e.borderColor, o, i);
19
234
  }
20
235
  }
21
- function t(e, t, n, r, i) {
22
- let a = c(t.top), o = c(t.right), s = c(t.bottom), l = c(t.left), u = (e, t, n) => n(c(e === t ? e : "solid")), { 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;
23
- if (i.top && _ > g && e.push({
236
+ function b(e, t, n, r, i) {
237
+ let a = D(t.top), o = D(t.right), s = D(t.bottom), c = D(t.left), l = (e, t, n) => n(D(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;
238
+ if (i.top && g > h && e.push({
24
239
  glyph: a.h,
25
- x: g,
26
- y: f,
27
- length: _ - g,
240
+ x: h,
241
+ y: d,
242
+ length: g - h,
28
243
  color: n.top
29
- }), i.bottom && m > +!!i.top && _ > g && e.push({
244
+ }), i.bottom && p > +!!i.top && g > h && e.push({
30
245
  glyph: s.h,
31
- x: g,
32
- y: f + m - 1,
33
- length: _ - g,
246
+ x: h,
247
+ y: d + p - 1,
248
+ length: g - h,
34
249
  color: n.bottom
35
- }), i.left) for (let t = v; t < y; t++) e.push({
36
- glyph: l.v,
37
- x: d,
250
+ }), i.left) for (let t = _; t < v; t++) e.push({
251
+ glyph: c.v,
252
+ x: u,
38
253
  y: t,
39
254
  length: 1,
40
255
  color: n.left
41
256
  });
42
- if (i.right && p > +!!i.left) for (let t = v; t < y; t++) e.push({
257
+ if (i.right && f > +!!i.left) for (let t = _; t < v; t++) e.push({
43
258
  glyph: o.v,
44
- x: d + p - 1,
259
+ x: u + f - 1,
45
260
  y: t,
46
261
  length: 1,
47
262
  color: n.right
48
263
  });
49
- h && (i.top && i.left && e.push({
50
- glyph: u(t.top, t.left, (e) => e.tl),
51
- x: d,
52
- y: f,
264
+ m && (i.top && i.left && e.push({
265
+ glyph: l(t.top, t.left, (e) => e.tl),
266
+ x: u,
267
+ y: d,
53
268
  length: 1,
54
269
  color: n.top
55
270
  }), i.top && i.right && e.push({
56
- glyph: u(t.top, t.right, (e) => e.tr),
57
- x: d + p - 1,
58
- y: f,
271
+ glyph: l(t.top, t.right, (e) => e.tr),
272
+ x: u + f - 1,
273
+ y: d,
59
274
  length: 1,
60
275
  color: n.top
61
276
  }), i.bottom && i.left && e.push({
62
- glyph: u(t.bottom, t.left, (e) => e.bl),
63
- x: d,
64
- y: f + m - 1,
277
+ glyph: l(t.bottom, t.left, (e) => e.bl),
278
+ x: u,
279
+ y: d + p - 1,
65
280
  length: 1,
66
281
  color: n.bottom
67
282
  }), i.bottom && i.right && e.push({
68
- glyph: u(t.bottom, t.right, (e) => e.br),
69
- x: d + p - 1,
70
- y: f + m - 1,
283
+ glyph: l(t.bottom, t.right, (e) => e.br),
284
+ x: u + f - 1,
285
+ y: d + p - 1,
71
286
  length: 1,
72
287
  color: n.bottom
73
288
  }));
74
289
  }
75
- function n(e, t) {
290
+ function x(e, t) {
76
291
  return e.style.position !== "static" || t.style.display === "flex" || t.style.display === "grid";
77
292
  }
78
- function r(e) {
293
+ function S(e) {
79
294
  if (e.children.length <= 1) return e.children;
80
- let t = null, r = null, i = null;
81
- for (let a of e.children) n(a, e) ? (i ??= []).push(a) : a.inlineBox ? (r ??= []).push(a) : (t ??= []).push(a);
82
- return i && i.length > 1 && i.sort((e, t) => (e.style.zIndex ?? 0) - (t.style.zIndex ?? 0)), t && !r && !i ? t : !t && r && !i ? r : !t && !r && i ? i : [
295
+ let t = null, n = null, r = null;
296
+ for (let i of e.children) x(i, e) ? (r ??= []).push(i) : i.inlineBox ? (n ??= []).push(i) : (t ??= []).push(i);
297
+ 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 : [
83
298
  ...t ?? [],
84
- ...r ?? [],
85
- ...i ?? []
299
+ ...n ?? [],
300
+ ...r ?? []
86
301
  ];
87
302
  }
88
- function i(e, t) {
89
- let n = c(e);
303
+ function C(e, t) {
304
+ let n = D(e);
90
305
  return t === "h" ? n.h : n.v;
91
306
  }
92
- function a(e, t, n, r, i) {
93
- return (e === "double" ? s : o)[(t ? 8 : 0) | (n ? 4 : 0) | (r ? 2 : 0) | !!i];
307
+ function w(e, t, n, r, i) {
308
+ return (e === "double" ? E : T)[(t ? 8 : 0) | (n ? 4 : 0) | (r ? 2 : 0) | !!i];
94
309
  }
95
- var o = [
310
+ var T = [
96
311
  " ",
97
312
  "─",
98
313
  "─",
@@ -109,7 +324,7 @@ var o = [
109
324
  "├",
110
325
  "┤",
111
326
  "┼"
112
- ], s = [
327
+ ], E = [
113
328
  " ",
114
329
  "═",
115
330
  "═",
@@ -127,8 +342,8 @@ var o = [
127
342
  "╣",
128
343
  "╬"
129
344
  ];
130
- function c(e) {
131
- let t = (t, n, r, i) => a(e, t, n, r, i), n = {
345
+ function D(e) {
346
+ let t = (t, n, r, i) => w(e, t, n, r, i), n = {
132
347
  h: t(!1, !1, !0, !0),
133
348
  v: t(!0, !0, !1, !1),
134
349
  tl: t(!1, !0, !1, !0),
@@ -146,7 +361,7 @@ function c(e) {
146
361
  v: "┊"
147
362
  } : n;
148
363
  }
149
- function l(e, t, n, r) {
364
+ function ee(e, t, n, r) {
150
365
  let i = e.map((e) => e.spanned ? !1 : n === "between" ? e.beforeOccupied && e.afterOccupied : n !== "around" || e.beforeOccupied || e.afterOccupied), a = [];
151
366
  for (let n = 0; n < e.length; n++) if (a.push({
152
367
  start: e[n].start,
@@ -190,80 +405,95 @@ function l(e, t, n, r) {
190
405
  end: e.end - r
191
406
  })).filter((e) => e.end > e.start);
192
407
  }
193
- function u(e) {
194
- let t = [], n = e.border.left + e.padding.left, r = e.border.top + e.padding.top, o = (e, t) => ({
408
+ function O(e) {
409
+ let t = [], n = e.border.left + e.padding.left, r = e.border.top + e.padding.top, i = (e, t) => ({
195
410
  line: t.bandStart + Math.floor((t.bandSize - e.width) / 2),
196
411
  start: t.start,
197
412
  end: t.end,
198
413
  startHalf: t.startHalf === !0,
199
414
  endHalf: t.endHalf === !0
200
- }), s = e.ruleX ? e.vertical.map((t) => o(e.ruleX, t)) : [], c = e.ruleY ? e.horizontal.map((t) => o(e.ruleY, t)) : [], l = e.ruleX?.width ?? 0, u = e.ruleY?.width ?? 0, f = (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)), p = (e, t) => c.some((n) => t >= n.line && t < n.line + u && e >= n.start && e < n.end);
415
+ }), 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);
201
416
  if (e.ruleX) {
202
- let a = i(e.ruleX.style, "v");
203
- for (let i of s) {
204
- for (let o = 0; o < l; o++) for (let s = i.start; s < i.end; s++) p(i.line + o, s) || t.push({
205
- glyph: a,
206
- x: n + i.line + o,
417
+ let i = C(e.ruleX.style, "v");
418
+ for (let o of a) {
419
+ for (let a = 0; a < s; a++) for (let s = o.start; s < o.end; s++) u(o.line + a, s) || t.push({
420
+ glyph: i,
421
+ x: n + o.line + a,
207
422
  y: r + s,
208
423
  length: 1,
209
424
  color: e.ruleX.color
210
425
  });
211
- d(e, t, "x", i.line, i.start, i.end);
426
+ k(e, t, "x", o.line, o.start, o.end);
212
427
  }
213
428
  }
214
429
  if (e.ruleY) {
215
- let o = e.ruleY.style === "double" && e.ruleX?.style === "double";
216
- for (let p of c) {
217
- for (let d = 0; d < u; d++) {
218
- let m = p.line + d;
219
- for (let d = p.start; d < p.end; d++) {
220
- let p = f(s, l, d, m), h = f(s, l, d, m + 1);
430
+ let i = e.ruleY.style === "double" && e.ruleX?.style === "double";
431
+ for (let u of o) {
432
+ for (let d = 0; d < c; d++) {
433
+ let f = u.line + d;
434
+ for (let d = u.start; d < u.end; d++) {
435
+ let u = l(a, s, d, f), p = l(a, s, d, f + 1);
221
436
  t.push({
222
- glyph: p || h ? a(o ? "double" : "solid", p, h, f(c, u, m, d), f(c, u, m, d + 1)) : i(e.ruleY.style, "h"),
437
+ glyph: u || p ? w(i ? "double" : "solid", u, p, l(o, c, f, d), l(o, c, f, d + 1)) : C(e.ruleY.style, "h"),
223
438
  x: n + d,
224
- y: r + m,
439
+ y: r + f,
225
440
  length: 1,
226
441
  color: e.ruleY.color
227
442
  });
228
443
  }
229
444
  }
230
- d(e, t, "y", p.line, p.start, p.end);
445
+ k(e, t, "y", u.line, u.start, u.end);
231
446
  }
232
447
  }
233
448
  return t;
234
449
  }
235
- function d(e, t, n, r, i, o) {
236
- let s = n === "x" ? e.ruleX : e.ruleY, c = e.border.left + e.padding.left, l = e.border.top + e.padding.top, u = c + e.contentWidth + e.padding.right + e.border.right, d = l + e.contentHeight + e.padding.bottom + e.border.bottom, f = (e, n, r, i, o, c, l, u) => {
237
- let d = s.style === "double" && r === "double" ? "double" : "solid";
450
+ function k(e, t, n, r, i, a) {
451
+ 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) => {
452
+ let u = o.style === "double" && r === "double" ? "double" : "solid";
238
453
  t.push({
239
- glyph: a(d, o, c, l, u),
454
+ glyph: w(u, a, s, c, l),
240
455
  x: e,
241
456
  y: n,
242
457
  length: 1,
243
458
  color: i
244
459
  });
245
460
  };
246
- if (n === "x") for (let t = 0; t < s.width; t++) {
461
+ if (n === "x") for (let t = 0; t < o.width; t++) {
462
+ let n = s + r + t;
463
+ i <= 0 && e.padding.top === 0 && e.border.top > 0 && d(n, e.border.top - 1, e.borderStyle.top, e.borderColor.top, !1, !0, !0, !0), a >= e.contentHeight && e.padding.bottom === 0 && e.border.bottom > 0 && d(n, u - e.border.bottom, e.borderStyle.bottom, e.borderColor.bottom, !0, !1, !0, !0);
464
+ }
465
+ else for (let t = 0; t < o.width; t++) {
247
466
  let n = c + r + t;
248
- i <= 0 && e.padding.top === 0 && e.border.top > 0 && f(n, e.border.top - 1, e.borderStyle.top, e.borderColor.top, !1, !0, !0, !0), o >= e.contentHeight && e.padding.bottom === 0 && e.border.bottom > 0 && f(n, d - e.border.bottom, e.borderStyle.bottom, e.borderColor.bottom, !0, !1, !0, !0);
467
+ i <= 0 && e.padding.left === 0 && e.border.left > 0 && d(e.border.left - 1, n, e.borderStyle.left, e.borderColor.left, !0, !0, !1, !0), a >= e.contentWidth && e.padding.right === 0 && e.border.right > 0 && d(l - e.border.right, n, e.borderStyle.right, e.borderColor.right, !0, !0, !0, !1);
249
468
  }
250
- else for (let t = 0; t < s.width; t++) {
251
- let n = l + r + t;
252
- i <= 0 && e.padding.left === 0 && e.border.left > 0 && f(e.border.left - 1, n, e.borderStyle.left, e.borderColor.left, !0, !0, !1, !0), o >= e.contentWidth && e.padding.right === 0 && e.border.right > 0 && f(u - e.border.right, n, e.borderStyle.right, e.borderColor.right, !0, !0, !0, !1);
469
+ }
470
+ //#endregion
471
+ //#region src/pointer.ts
472
+ function A(e, t, n) {
473
+ let r = [], i = e, a = e.localRect.x, o = e.localRect.y;
474
+ for (;;) {
475
+ let e = null;
476
+ for (let r of S(i)) {
477
+ if (r.tableHidden) continue;
478
+ let i = a + r.localRect.x, s = o + r.localRect.y;
479
+ t >= i && t < i + r.localRect.width && n >= s && n < s + r.localRect.height && (e = r);
480
+ }
481
+ if (!e) return r;
482
+ r.push(e.source), a += e.localRect.x, o += e.localRect.y, i = e;
253
483
  }
254
484
  }
255
485
  //#endregion
256
486
  //#region src/metrics.ts
257
- function f(e) {
487
+ function j(e) {
258
488
  return (e >= 0 ? Math.floor(e + .5) : -Math.floor(-e + .5)) || 0;
259
489
  }
260
- function p(e, t) {
261
- return t <= 0 ? 0 : f(e / (.25 * t));
490
+ function M(e, t) {
491
+ return t <= 0 ? 0 : j(e / (.25 * t));
262
492
  }
263
- function m(e, t) {
264
- return f(t * e / 100);
493
+ function N(e, t) {
494
+ return j(t * e / 100);
265
495
  }
266
- function h(e, t) {
496
+ function te(e, t) {
267
497
  let n = t.getBoundingClientRect(), r = parseFloat(getComputedStyle(e).letterSpacing) || 0, i = t.ownerDocument.createRange();
268
498
  i.selectNodeContents(t);
269
499
  let a = Math.max(0, i.getBoundingClientRect().height - n.height);
@@ -274,56 +504,56 @@ function h(e, t) {
274
504
  inkOverhang: a
275
505
  };
276
506
  }
277
- function g() {
507
+ function ne() {
278
508
  return parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
279
509
  }
280
510
  //#endregion
281
511
  //#region src/wrap.ts
282
- function _(e, t, n = {}) {
283
- return x(e, t, n).map((t) => e.slice(t.start, t.end));
512
+ function re(e, t, n = {}) {
513
+ return se(e, t, n).map((t) => e.slice(t.start, t.end));
284
514
  }
285
- function v(e, t, n = {}) {
286
- return x(e, t, n).length;
515
+ function ie(e, t, n = {}) {
516
+ return se(e, t, n).length;
287
517
  }
288
- function y(e, t) {
518
+ function ae(e, t) {
289
519
  return t.endsWith("\n") && e.pop(), e;
290
520
  }
291
- function b(e) {
521
+ function oe(e) {
292
522
  let t = [], n = 0;
293
523
  for (let r = 0; r <= e.length; r++) (r === e.length || e[r] === "\n") && (t.push({
294
524
  start: n,
295
525
  end: r
296
526
  }), n = r + 1);
297
- return y(t, e);
527
+ return ae(t, e);
298
528
  }
299
- function x(e, t, n = {}) {
529
+ function se(e, t, n = {}) {
300
530
  if (!/[^ \t\r\f]/.test(e)) return [];
301
531
  let r = [], i = 0, a = n.firstLineIndent ?? 0;
302
- for (let o = 0; o <= e.length; o++) (o === e.length || e[o] === "\n") && (r.push(...A(e, i, o, t, n, a)), a = 0, i = o + 1);
303
- return y(r, e);
532
+ for (let o = 0; o <= e.length; o++) (o === e.length || e[o] === "\n") && (r.push(...he(e, i, o, t, n, a)), a = 0, i = o + 1);
533
+ return ae(r, e);
304
534
  }
305
- function S(e, t, n) {
535
+ function ce(e, t, n) {
306
536
  if (!n) return t - e;
307
537
  let r = 0;
308
538
  for (let i = e; i < t; i++) r += n[i] ?? 1;
309
539
  return r;
310
540
  }
311
- function C(e, t, n, r = 0) {
312
- return t <= e ? 0 : S(e, t, n) - Math.min(r, w(t - 1, n));
541
+ function P(e, t, n, r = 0) {
542
+ return t <= e ? 0 : ce(e, t, n) - Math.min(r, le(t - 1, n));
313
543
  }
314
- function w(e, t) {
544
+ function le(e, t) {
315
545
  return t ? (t[e] ?? 1) - 1 : 0;
316
546
  }
317
- function T(e, t = {}) {
547
+ function ue(e, t = {}) {
318
548
  let { advances: n, tracking: r = 0 } = t, i = 0;
319
- for (let t of k(e, 0, e.length)) for (let a of D(e, t.start, t.end)) i = Math.max(i, C(a.start, a.end, n, r));
549
+ for (let t of me(e, 0, e.length)) for (let a of fe(e, t.start, t.end)) i = Math.max(i, P(a.start, a.end, n, r));
320
550
  return i;
321
551
  }
322
- function E(e, t) {
552
+ function de(e, t) {
323
553
  let n = 0;
324
554
  for (let r = 0; r < e.length; r++) e[r] === "" && (t(r, n), n++);
325
555
  }
326
- function D(e, t, n) {
556
+ function fe(e, t, n) {
327
557
  let r = [], i = t;
328
558
  for (let a = t; a < n; a++) {
329
559
  if (e[a] === "") {
@@ -350,14 +580,14 @@ function D(e, t, n) {
350
580
  end: n
351
581
  }), r;
352
582
  }
353
- var O = /[ \t\r\n\f]/;
354
- function k(e, t, n) {
583
+ var pe = /[ \t\r\n\f]/;
584
+ function me(e, t, n) {
355
585
  let r = [], i = t;
356
586
  for (; i < n;) {
357
- for (; i < n && O.test(e[i]);) i++;
587
+ for (; i < n && pe.test(e[i]);) i++;
358
588
  if (i >= n) break;
359
589
  let t = i;
360
- for (; i < n && !O.test(e[i]);) i++;
590
+ for (; i < n && !pe.test(e[i]);) i++;
361
591
  r.push({
362
592
  start: t,
363
593
  end: i
@@ -365,8 +595,8 @@ function k(e, t, n) {
365
595
  }
366
596
  return r;
367
597
  }
368
- function A(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
369
- let s = k(e, t, n);
598
+ function he(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
599
+ let s = me(e, t, n);
370
600
  if (s.length === 0) return [{
371
601
  start: t,
372
602
  end: t
@@ -378,13 +608,13 @@ function A(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
378
608
  let c = [], l = null, u = 0, d = Math.max(0, o), f = () => r - d;
379
609
  for (let t of s) {
380
610
  let n = !1;
381
- for (let r of D(e, t.start, t.end)) {
382
- let e = r.start, t = r.end, o = l !== null && !n ? e - 1 : e, s = u + S(o, t, i), p = Math.min(a, w(t - 1, i));
611
+ for (let r of fe(e, t.start, t.end)) {
612
+ let e = r.start, t = r.end, o = l !== null && !n ? e - 1 : e, s = u + ce(o, t, i), p = Math.min(a, le(t - 1, i));
383
613
  if (l !== null && s - p <= f()) l.end = t, u = s;
384
614
  else {
385
615
  for (l !== null && (c.push(l), d = 0);;) {
386
616
  let n = e;
387
- for (; n < t && C(e, n + 1, i, a) <= f();) n++;
617
+ for (; n < t && P(e, n + 1, i, a) <= f();) n++;
388
618
  if (n === t || n === e) break;
389
619
  c.push({
390
620
  start: e,
@@ -394,7 +624,7 @@ function A(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
394
624
  l = {
395
625
  start: e,
396
626
  end: t
397
- }, u = S(e, t, i);
627
+ }, u = ce(e, t, i);
398
628
  }
399
629
  n = !0;
400
630
  }
@@ -403,7 +633,7 @@ function A(e, t, n, r, { advances: i, tracking: a = 0 }, o = 0) {
403
633
  }
404
634
  //#endregion
405
635
  //#region src/flex.ts
406
- function j(e, t) {
636
+ function ge(e, t) {
407
637
  let n = e.row.map((e) => e.node.localRect).sort((e, t) => e.x - t.x), r = [];
408
638
  for (let e = 1; e < n.length; e++) {
409
639
  let i = n[e - 1].x + n[e - 1].width - t, a = n[e].x - t;
@@ -414,12 +644,12 @@ function j(e, t) {
414
644
  }
415
645
  return r;
416
646
  }
417
- function M(e, t, n, r, i) {
647
+ function _e(e, t, n, r, i) {
418
648
  if (e.style.ruleBreak !== "intersection") return [{
419
649
  start: 0,
420
650
  end: i
421
651
  }];
422
- let a = [t[n - 1], t[n]].flatMap((e) => j(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
652
+ let a = [t[n - 1], t[n]].flatMap((e) => ge(e, r)).sort((e, t) => e.start - t.start), o = (e, t) => ({
423
653
  start: e,
424
654
  end: t,
425
655
  spanned: !1,
@@ -427,38 +657,38 @@ function M(e, t, n, r, i) {
427
657
  afterOccupied: !0
428
658
  }), s = [], c = 0;
429
659
  for (let e of a) e.start > c && s.push(o(c, e.start)), c = Math.max(c, e.end);
430
- return c < i && s.push(o(c, i)), l(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
660
+ return c < i && s.push(o(c, i)), ee(s, "intersection", "all", e.style.ruleInset === "overlap-join" ? "overlap-join" : 0);
431
661
  }
432
- function N(e, t) {
662
+ function ve(e, t) {
433
663
  return typeof t != "number" || t <= 0 ? e : e.map((e) => ({
434
664
  ...e,
435
665
  start: e.start + t,
436
666
  end: e.end - t
437
667
  })).filter((e) => e.end > e.start);
438
668
  }
439
- function P(e, t, n, r, i, a, o) {
440
- let s = U(e.style, "x", t), c = U(e.style, "y", n), l = se(e).map((e) => {
669
+ function ye(e, t, n, r, i, a, o) {
670
+ let s = U(e.style, "x", t), c = U(e.style, "y", n), l = De(e).map((e) => {
441
671
  let n = G(e.style.margin, t);
442
672
  return {
443
673
  node: e,
444
- base: oe(e, t, o),
674
+ base: Ee(e, t, o),
445
675
  grow: e.style.flexGrow,
446
676
  shrink: e.style.flexShrink,
447
- min: ue(e, t, o),
677
+ min: Ae(e, t, o),
448
678
  max: K(e.style.maxWidth, t),
449
679
  margin: n
450
680
  };
451
- }), d = [];
681
+ }), u = [];
452
682
  if (e.style.flexWrap === "wrap") {
453
683
  let n = [], r = 0;
454
684
  for (let e of l) {
455
685
  let i = Math.max(0, H(e.base, e.min, e.max)) + (e.margin.left ?? 0) + (e.margin.right ?? 0), a = n.length === 0 ? i : r + s + i;
456
- n.length > 0 && a > t && (d.push(n), n = [], r = 0), n.push(e), r = n.length === 1 ? i : r + s + i;
686
+ n.length > 0 && a > t && (u.push(n), n = [], r = 0), n.push(e), r = n.length === 1 ? i : r + s + i;
457
687
  }
458
- n.length > 0 && d.push(n), e.style.wrapReverse && d.reverse();
459
- } else d.push(l);
460
- let f = i.left + a.left, p = i.top + a.top, m = d.map((e) => {
461
- 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))) : ie(e, a);
688
+ n.length > 0 && u.push(n), e.style.wrapReverse && u.reverse();
689
+ } else u.push(l);
690
+ let d = i.left + a.left, f = i.top + a.top, p = u.map((e) => {
691
+ 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))) : we(e, a);
462
692
  for (let n = 0; n < e.length; n++) V(e[n].node, t, r, 0, 0, "fill", o, { width: u[n] });
463
693
  return {
464
694
  row: e,
@@ -466,26 +696,26 @@ function P(e, t, n, r, i, a, o) {
466
696
  availableForItems: a,
467
697
  height: e.reduce((e, t) => Math.max(e, t.node.localRect.height), 0)
468
698
  };
469
- }), h = m.map((e) => e.height), g = c * Math.max(0, m.length - 1), _;
470
- if (e.style.flexWrap === "nowrap") Number.isFinite(n) && (h[0] = Math.max(n, h[0] ?? 0)), _ = [0];
699
+ }), m = p.map((e) => e.height), h = c * Math.max(0, p.length - 1), g;
700
+ if (e.style.flexWrap === "nowrap") Number.isFinite(n) && (m[0] = Math.max(n, m[0] ?? 0)), g = [0];
471
701
  else {
472
- let t = h.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - g) : 0, i = ce(e.style);
702
+ let t = m.reduce((e, t) => e + t, 0), r = Number.isFinite(n) ? Math.max(0, n - t - h) : 0, i = Oe(e.style);
473
703
  if (i === "stretch" && r > 0) {
474
- let e = I(Array.from({ length: m.length }, () => 1), r);
475
- for (let t = 0; t < h.length; t++) h[t] += e[t];
476
- _ = F("start", h, 0);
477
- } else _ = F(i === "stretch" ? "start" : i, h, r);
704
+ let e = I(Array.from({ length: p.length }, () => 1), r);
705
+ for (let t = 0; t < m.length; t++) m[t] += e[t];
706
+ g = F("start", m, 0);
707
+ } else g = F(i === "stretch" ? "start" : i, m, r);
478
708
  }
479
- for (let i = 0; i < m.length; i++) {
480
- let { row: a, widths: l, availableForItems: u } = m[i], d = h[i], g = _[i] + i * c;
709
+ for (let i = 0; i < p.length; i++) {
710
+ let { row: a, widths: l, availableForItems: u } = p[i], h = m[i], _ = g[i] + i * c;
481
711
  for (let i = 0; i < a.length; i++) {
482
- let s = a[i].node, c = ae(s, e), u = a[i].margin, f = u.top === null || u.bottom === null, p = s.style.height !== void 0 && s.style.height.kind !== "auto";
483
- if (c === "stretch" && !f && !p && d > s.localRect.height) {
484
- let e = u.top ?? 0, a = u.bottom ?? 0, c = Number.isFinite(n) ? n : void 0, f = H(Math.max(0, d - e - a), K(s.style.minHeight, c) ?? 0, K(s.style.maxHeight, c));
485
- if (f === s.localRect.height) continue;
712
+ let s = a[i].node, c = Te(s, e), u = a[i].margin, d = u.top === null || u.bottom === null, f = s.style.height !== void 0 && s.style.height.kind !== "auto";
713
+ if (c === "stretch" && !d && !f && h > s.localRect.height) {
714
+ 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));
715
+ if (d === s.localRect.height) continue;
486
716
  V(s, t, r, 0, 0, "fill", o, {
487
717
  width: l[i],
488
- height: f
718
+ height: d
489
719
  });
490
720
  }
491
721
  }
@@ -494,53 +724,53 @@ function P(e, t, n, r, i, a, o) {
494
724
  let e = I(Array.from({ length: b }, () => 1), y), t = 0;
495
725
  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++]);
496
726
  C = F("start", l, 0);
497
- } else C = F(le(e.style), l, y);
727
+ } else C = F(ke(e.style), l, y);
498
728
  let w = 0;
499
729
  for (let t = 0; t < a.length; t++) {
500
730
  let n = a[t], r = n.node, i = n.margin.left ?? 0, o = n.margin.right ?? 0;
501
731
  w += x[t] + i, r.localRect = {
502
732
  ...r.localRect,
503
- x: f + C[t] + t * s + w,
504
- y: p + g + ne(r, e.style.alignItems, d, n.margin)
733
+ x: d + C[t] + t * s + w,
734
+ y: f + _ + Se(r, e.style.alignItems, h, n.margin)
505
735
  }, w += S[t] + o;
506
736
  }
507
737
  }
508
- let v = h.reduce((e, t) => e + t, 0) + g, y = Number.isFinite(n) ? Math.max(n, v) : v;
738
+ let _ = m.reduce((e, t) => e + t, 0) + h, v = Number.isFinite(n) ? Math.max(n, _) : _;
509
739
  if (e.style.ruleX || e.style.ruleY) {
510
740
  let n = [], r = [];
511
- for (let i = 0; i < m.length; i++) {
512
- let a = _[i] + i * c;
513
- for (let e of j(m[i], f)) n.push({
741
+ for (let i = 0; i < p.length; i++) {
742
+ let a = g[i] + i * c;
743
+ for (let e of ge(p[i], d)) n.push({
514
744
  bandStart: e.start,
515
745
  bandSize: e.end - e.start,
516
746
  start: a,
517
- end: a + h[i]
747
+ end: a + m[i]
518
748
  });
519
749
  if (i > 0) {
520
- let n = _[i - 1] + (i - 1) * c + h[i - 1];
521
- if (a > n) for (let o of M(e, m, i, f, t)) r.push({
750
+ let n = g[i - 1] + (i - 1) * c + m[i - 1];
751
+ if (a > n) for (let o of _e(e, p, i, d, t)) r.push({
522
752
  bandStart: n,
523
753
  bandSize: a - n,
524
754
  ...o
525
755
  });
526
756
  }
527
757
  }
528
- e.decorationRuns = u({
758
+ e.decorationRuns = O({
529
759
  ruleX: e.style.ruleX,
530
760
  ruleY: e.style.ruleY,
531
- vertical: N(n, e.style.ruleInset),
532
- horizontal: N(r, e.style.ruleInset),
761
+ vertical: ve(n, e.style.ruleInset),
762
+ horizontal: ve(r, e.style.ruleInset),
533
763
  contentWidth: t,
534
- contentHeight: y,
764
+ contentHeight: v,
535
765
  border: i,
536
766
  borderStyle: e.style.borderStyle,
537
767
  borderColor: e.style.borderColor,
538
768
  padding: a
539
769
  });
540
770
  }
541
- return ee(e, i, a, t, y), y;
771
+ return be(e, i, a, t, v), v;
542
772
  }
543
- function ee(e, t, n, r, i) {
773
+ function be(e, t, n, r, i) {
544
774
  for (let a of e.children) B(a.style) && (a.staticSlot = {
545
775
  kind: "flex",
546
776
  direction: e.style.flexDirection,
@@ -550,11 +780,11 @@ function ee(e, t, n, r, i) {
550
780
  innerHeight: i
551
781
  });
552
782
  }
553
- function te(e, t, n, r, i, a, o) {
554
- let s = U(e.style, "y", n), c = se(e).map((i) => {
555
- let a = G(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = ae(i, e) === "stretch";
783
+ function xe(e, t, n, r, i, a, o) {
784
+ let s = U(e.style, "y", n), c = De(e).map((i) => {
785
+ let a = G(i.style.margin, t), s = Math.max(0, t - (a.left ?? 0) - (a.right ?? 0)), c = Te(i, e) === "stretch";
556
786
  V(i, s, r && Number.isFinite(n) ? n : void 0, 0, 0, c ? "fill" : "shrink", o);
557
- 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 ? m(u.value, l) : i.unclampedHeight, f = i.style.minHeight === "auto" ? i.style.overflow === "visible" ? i.localRect.height : 0 : void 0;
787
+ 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 ? N(u.value, l) : i.unclampedHeight, f = i.style.minHeight === "auto" ? i.style.overflow === "visible" ? i.localRect.height : 0 : void 0;
558
788
  return {
559
789
  node: i,
560
790
  base: d,
@@ -564,31 +794,31 @@ function te(e, t, n, r, i, a, o) {
564
794
  max: K(i.style.maxHeight, l),
565
795
  margin: a
566
796
  };
567
- }), l = s * Math.max(0, c.length - 1), d = c.reduce((e, t) => e + (t.margin.top ?? 0) + (t.margin.bottom ?? 0), 0), f = Number.isFinite(n), p = c.reduce((e, t) => e + t.base, 0), h = f ? Math.max(0, n - l - d) : p, g = r ? h : Math.max(h, p), _ = c.some((e) => e.margin.top === null || e.margin.bottom === null), v = f && !(f && _ && p <= g) ? ie(c, g) : c.map((e) => Math.max(0, H(e.base, e.min, e.max)));
568
- for (let n = 0; n < c.length; n++) if (v[n] !== c[n].node.localRect.height) {
569
- let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = ae(r.node, e) === "stretch";
570
- V(r.node, i, v[n], 0, 0, a ? "fill" : "shrink", o, { height: v[n] });
571
- }
572
- let y = v.reduce((e, t) => e + t, 0), b = Math.max(0, g - y), x = c.reduce((e, t) => e + +(t.margin.top === null) + +(t.margin.bottom === null), 0), S = Array.from({ length: c.length }, () => 0), C = Array.from({ length: c.length }, () => 0), w;
573
- if (x > 0 && b > 0) {
574
- let e = I(Array.from({ length: x }, () => 1), b), t = 0;
575
- for (let n = 0; n < c.length; n++) c[n].margin.top === null && (S[n] = e[t++]), c[n].margin.bottom === null && (C[n] = e[t++]);
576
- w = F("start", v, 0);
577
- } else w = F(le(e.style), v, b);
578
- let T = i.left + a.left, E = i.top + a.top, D = 0;
797
+ }), 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) ? we(c, m) : c.map((e) => Math.max(0, H(e.base, e.min, e.max)));
798
+ for (let n = 0; n < c.length; n++) if (g[n] !== c[n].node.localRect.height) {
799
+ let r = c[n], i = Math.max(0, t - (r.margin.left ?? 0) - (r.margin.right ?? 0)), a = Te(r.node, e) === "stretch";
800
+ V(r.node, i, g[n], 0, 0, a ? "fill" : "shrink", o, { height: g[n] });
801
+ }
802
+ 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;
803
+ if (y > 0 && v > 0) {
804
+ let e = I(Array.from({ length: y }, () => 1), v), t = 0;
805
+ 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++]);
806
+ S = F("start", g, 0);
807
+ } else S = F(ke(e.style), g, v);
808
+ let C = i.left + a.left, w = i.top + a.top, T = 0;
579
809
  for (let n = 0; n < c.length; n++) {
580
810
  let r = c[n], i = r.node, a = r.margin.top ?? 0, o = r.margin.bottom ?? 0;
581
- D += S[n] + a, i.localRect = {
811
+ T += b[n] + a, i.localRect = {
582
812
  ...i.localRect,
583
- x: T + re(i, e.style.alignItems, t, r.margin),
584
- y: E + w[n] + n * s + D
585
- }, D += C[n] + o;
813
+ x: C + Ce(i, e.style.alignItems, t, r.margin),
814
+ y: w + S[n] + n * s + T
815
+ }, T += x[n] + o;
586
816
  }
587
- let O = y + l + d, k = f ? Math.max(n, O) : O;
817
+ let E = _ + l + u, D = d ? Math.max(n, E) : E;
588
818
  if (e.style.ruleY && c.length > 1) {
589
819
  let n = [], r = c.map((e) => e.node.localRect).slice().sort((e, t) => e.y - t.y);
590
820
  for (let e = 1; e < r.length; e++) {
591
- let i = r[e - 1].y + r[e - 1].height - E, a = r[e].y - E - i;
821
+ let i = r[e - 1].y + r[e - 1].height - w, a = r[e].y - w - i;
592
822
  a > 0 && n.push({
593
823
  bandStart: i,
594
824
  bandSize: a,
@@ -596,26 +826,26 @@ function te(e, t, n, r, i, a, o) {
596
826
  end: t
597
827
  });
598
828
  }
599
- e.decorationRuns = u({
829
+ e.decorationRuns = O({
600
830
  ruleX: null,
601
831
  ruleY: e.style.ruleY,
602
832
  vertical: [],
603
- horizontal: N(n, e.style.ruleInset),
833
+ horizontal: ve(n, e.style.ruleInset),
604
834
  contentWidth: t,
605
- contentHeight: k,
835
+ contentHeight: D,
606
836
  border: i,
607
837
  borderStyle: e.style.borderStyle,
608
838
  borderColor: e.style.borderColor,
609
839
  padding: a
610
840
  });
611
841
  }
612
- return ee(e, i, a, t, k), k;
842
+ return be(e, i, a, t, D), D;
613
843
  }
614
- function ne(e, t, n, r) {
844
+ function Se(e, t, n, r) {
615
845
  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;
616
846
  return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + L(i, n, e.localRect.height);
617
847
  }
618
- function re(e, t, n, r) {
848
+ function Ce(e, t, n, r) {
619
849
  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;
620
850
  return c ? Math.floor(s / 2) : l ? s - o : u ? a : a + L(i, n, e.localRect.width);
621
851
  }
@@ -637,7 +867,7 @@ function F(e, t, n) {
637
867
  for (let e = 0; e < r; e++) i.push(a), a += t[e];
638
868
  return i;
639
869
  }
640
- function ie(e, t) {
870
+ function we(e, t) {
641
871
  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);
642
872
  for (let t = 0; t < n; t++) {
643
873
  let n = r(i[t], t);
@@ -672,33 +902,33 @@ function I(e, t) {
672
902
  }
673
903
  return i;
674
904
  }
675
- function ae(e, t) {
905
+ function Te(e, t) {
676
906
  return e.style.alignSelf === "auto" ? t.style.alignItems : e.style.alignSelf;
677
907
  }
678
908
  function L(e, t, n) {
679
909
  return e === "center" ? Math.max(0, Math.floor((t - n) / 2)) : e === "end" ? Math.max(0, t - n) : 0;
680
910
  }
681
- function oe(e, t, n) {
911
+ function Ee(e, t, n) {
682
912
  let r = e.style.flexBasis, i = e.style.width;
683
913
  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);
684
914
  }
685
- function se(e) {
915
+ function De(e) {
686
916
  let t = e.children.filter((e) => !B(e.style)).sort((e, t) => e.style.order - t.style.order);
687
917
  return e.style.flexReverse && t.reverse(), t;
688
918
  }
689
- function ce(e) {
919
+ function Oe(e) {
690
920
  return e.wrapReverse ? e.alignContent === "start" ? "end" : e.alignContent === "end" ? "start" : e.alignContent : e.alignContent;
691
921
  }
692
- function le(e) {
922
+ function ke(e) {
693
923
  let t = e.justifyContent === "stretch" ? "start" : e.justifyContent;
694
924
  return e.flexReverse ? t === "start" ? "end" : t === "end" ? "start" : t : t;
695
925
  }
696
- function ue(e, t, n) {
926
+ function Ae(e, t, n) {
697
927
  return e.style.minWidth === "auto" ? e.style.overflow === "visible" ? Y(e, n) : 0 : K(e.style.minWidth, t) ?? 0;
698
928
  }
699
929
  //#endregion
700
930
  //#region src/types.ts
701
- function de() {
931
+ function je() {
702
932
  return {
703
933
  display: "block",
704
934
  flexDirection: "row",
@@ -717,8 +947,8 @@ function de() {
717
947
  justifySelf: "auto",
718
948
  gridTemplateColumns: { kind: "none" },
719
949
  gridTemplateRows: { kind: "none" },
720
- gridAutoColumns: [fe()],
721
- gridAutoRows: [fe()],
950
+ gridAutoColumns: [Me()],
951
+ gridAutoRows: [Me()],
722
952
  gridAutoFlow: {
723
953
  direction: "row",
724
954
  dense: !1
@@ -785,6 +1015,7 @@ function de() {
785
1015
  borderSpacingY: 0,
786
1016
  captionSide: "top",
787
1017
  verticalAlign: "start",
1018
+ opacity: 1,
788
1019
  zIndex: null,
789
1020
  latticeBorder: null,
790
1021
  ruleX: null,
@@ -809,7 +1040,7 @@ function R() {
809
1040
  left: 0
810
1041
  };
811
1042
  }
812
- function fe() {
1043
+ function Me() {
813
1044
  return {
814
1045
  min: { kind: "auto" },
815
1046
  max: { kind: "auto" }
@@ -817,15 +1048,15 @@ function fe() {
817
1048
  }
818
1049
  //#endregion
819
1050
  //#region src/grid.ts
820
- function pe(e, t, n, r, i, a) {
821
- let o = e.style, s = Number.isFinite(n) ? n : void 0, c = e.subgrid?.cols, d = e.subgrid?.rows, f = c ? c.gap : U(o, "x", t), p = d ? d.gap : U(o, "y", s), m = Ce(e, t, s, f, p, e.subgrid ? {
1051
+ function Ne(e, t, n, r, i, a) {
1052
+ 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 = Ue(e, t, s, u, d, e.subgrid ? {
822
1053
  col: e.subgrid.colSpan,
823
1054
  row: e.subgrid.rowSpan
824
- } : void 0), { children: h, placed: g, colLines: _, rowLines: v, colTracks: y, rowTracks: b, colCollapsed: x, rowCollapsed: S } = m, C = h.map((e) => G(e.style.margin, t)), w = h.map((e) => e.style.justifySelf === "auto" ? o.justifyItems : e.style.justifySelf), T = h.map(me), E = c ? ge(c) : ze(y, x, _e(m, T, C, a), t, f, o.justifyContent === "stretch"), D = c ? c.positions : Be(E, t, o.justifyContent), O = [];
825
- for (let e = 0; e < h.length; e++) {
826
- let t = h[e], n = g.items[e], r = He(D, E.sizes, n.col.start, n.col.span), i = C[e], o = Math.max(0, r - De(i)), s = T[e];
1055
+ } : 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(Pe), w = c ? Ie(c) : at(_, y, Le(f, C, x, a), t, u, o.justifyContent === "stretch"), T = c ? c.positions : ot(w, t, o.justifyContent), E = [];
1056
+ for (let e = 0; e < p.length; e++) {
1057
+ let t = p[e], n = m.items[e], r = ct(T, w.sizes, n.col.start, n.col.span), i = x[e], o = Math.max(0, r - qe(i)), s = C[e];
827
1058
  if (s.cols || s.rows) {
828
- let e = s.cols ? he(D, E, f, n.col.start, n.col.span, ye(t, "cols", i, r)) : void 0;
1059
+ let e = s.cols ? Fe(T, w, u, n.col.start, n.col.span, ze(t, "cols", i, r)) : void 0;
829
1060
  t.subgrid = {
830
1061
  colSpan: n.col.span,
831
1062
  rowSpan: n.row.span,
@@ -833,84 +1064,84 @@ function pe(e, t, n, r, i, a) {
833
1064
  rows: void 0
834
1065
  };
835
1066
  } else t.subgrid = void 0;
836
- let c = w[e], l = i.left === null || i.right === null, u = t.style.width !== void 0 && t.style.width.kind !== "auto";
837
- s.cols ? V(t, r, void 0, 0, 0, "fill", a, { width: o }) : c === "stretch" && !l && !u ? 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, Xt(t.style.maxWidth, r, t, a)) }) : V(t, o, void 0, 0, 0, "shrink", a), O.push(t.localRect.width);
838
- }
839
- let k = d ? ge(d) : ze(b, S, ve(m, T, C), s ?? "max-content", p, o.alignContent === "stretch"), A = Ve(k), j = d ? d.positions : Be(k, s ?? A, o.alignContent), M = r.left + i.left, N = r.top + i.top;
840
- for (let t = 0; t < h.length; t++) {
841
- let n = h[t], r = g.items[t], i = C[t], o = He(D, E.sizes, r.col.start, r.col.span), s = He(j, k.sizes, r.row.start, r.row.span), c = Math.max(0, s - Oe(i)), l = ae(n, e), u = i.top === null || i.bottom === null, d = n.style.height !== void 0 && n.style.height.kind !== "auto";
842
- if (T[t].rows) n.subgrid.rows = he(j, k, p, r.row.start, r.row.span, ye(n, "rows", i, o)), V(n, o, s, 0, 0, "fill", a, {
843
- width: O[t],
1067
+ let c = S[e], l = i.left === null || i.right === null, d = t.style.width !== void 0 && t.style.width.kind !== "auto";
1068
+ 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, yn(t.style.maxWidth, r, t, a)) }) : V(t, o, void 0, 0, 0, "shrink", a), E.push(t.localRect.width);
1069
+ }
1070
+ let D = l ? Ie(l) : at(v, b, Re(f, C, x), s ?? "max-content", d, o.alignContent === "stretch"), k = st(D), A = l ? l.positions : ot(D, s ?? k, o.alignContent), j = r.left + i.left, M = r.top + i.top;
1071
+ for (let t = 0; t < p.length; t++) {
1072
+ let n = p[t], r = m.items[t], i = x[t], o = ct(T, w.sizes, r.col.start, r.col.span), s = ct(A, D.sizes, r.row.start, r.row.span), c = Math.max(0, s - Je(i)), l = Te(n, e), u = i.top === null || i.bottom === null, f = n.style.height !== void 0 && n.style.height.kind !== "auto";
1073
+ if (C[t].rows) n.subgrid.rows = Fe(A, D, d, r.row.start, r.row.span, ze(n, "rows", i, o)), V(n, o, s, 0, 0, "fill", a, {
1074
+ width: E[t],
844
1075
  height: c
845
1076
  });
846
- else if (l === "stretch" && !u && !d) {
1077
+ else if (l === "stretch" && !u && !f) {
847
1078
  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));
848
1079
  e !== n.localRect.height && V(n, o, s, 0, 0, "fill", a, {
849
- width: O[t],
1080
+ width: E[t],
850
1081
  height: e
851
1082
  });
852
- } else n.style.height?.kind === "percent" && V(n, o, s, 0, 0, "fill", a, { width: O[t] });
1083
+ } else n.style.height?.kind === "percent" && V(n, o, s, 0, 0, "fill", a, { width: E[t] });
853
1084
  n.localRect = {
854
1085
  ...n.localRect,
855
- x: M + D[r.col.start] + Ue(w[t], i.left, i.right, o, n.localRect.width),
856
- y: N + j[r.row.start] + Ue(l, i.top, i.bottom, s, n.localRect.height)
1086
+ x: j + T[r.col.start] + lt(S[t], i.left, i.right, o, n.localRect.width),
1087
+ y: M + A[r.row.start] + lt(l, i.top, i.bottom, s, n.localRect.height)
857
1088
  };
858
1089
  }
859
- let P = Number.isFinite(n) ? Math.max(n, A) : A;
1090
+ let N = Number.isFinite(n) ? Math.max(n, k) : k;
860
1091
  if (o.ruleX || o.ruleY) {
861
- let n = E.sizes.length, a = k.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)), d = Array.from({ length: Math.max(0, a - 1) }, () => Array.from({ length: n }, () => !1));
862
- for (let e of g.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 && (d[r][t] = !0);
863
- let f = (e, t, n, r, i, a) => t.map((t, o) => ({
1092
+ 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));
1093
+ 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);
1094
+ let u = (e, t, n, r, i, a) => t.map((t, o) => ({
864
1095
  start: t,
865
1096
  end: t + n[o],
866
1097
  spanned: r[e]?.[o] ?? !1,
867
1098
  beforeOccupied: i(o),
868
1099
  afterOccupied: a(o)
869
- })), p = (e, t, n) => {
1100
+ })), d = (e, t, n) => {
870
1101
  let r = [];
871
1102
  for (let i = 1; i < e.length; i++) {
872
1103
  let a = e[i - 1] + t[i - 1], s = e[i] - a;
873
- if (!(s <= 0)) for (let e of l(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
1104
+ if (!(s <= 0)) for (let e of ee(n(i - 1), o.ruleBreak, o.ruleVisibilityItems, o.ruleInset)) r.push({
874
1105
  bandStart: a,
875
1106
  bandSize: s,
876
1107
  ...e
877
1108
  });
878
1109
  }
879
1110
  return r;
880
- }, m = p(D, E.sizes, (e) => f(e, j, k.sizes, c, (t) => s[e]?.[t] ?? !1, (t) => s[e + 1]?.[t] ?? !1)), h = p(j, k.sizes, (e) => f(e, D, E.sizes, d, (t) => s[t]?.[e] ?? !1, (t) => s[t]?.[e + 1] ?? !1));
881
- e.decorationRuns = u({
1111
+ }, f = d(T, w.sizes, (e) => u(e, A, D.sizes, c, (t) => s[e]?.[t] ?? !1, (t) => s[e + 1]?.[t] ?? !1)), p = d(A, D.sizes, (e) => u(e, T, w.sizes, l, (t) => s[t]?.[e] ?? !1, (t) => s[t]?.[e + 1] ?? !1));
1112
+ e.decorationRuns = O({
882
1113
  ruleX: o.ruleX,
883
1114
  ruleY: o.ruleY,
884
- vertical: m,
885
- horizontal: h,
1115
+ vertical: f,
1116
+ horizontal: p,
886
1117
  contentWidth: t,
887
- contentHeight: P,
1118
+ contentHeight: N,
888
1119
  border: r,
889
1120
  borderStyle: o.borderStyle,
890
1121
  borderColor: o.borderColor,
891
1122
  padding: i
892
1123
  });
893
1124
  }
894
- let ee = e.children.filter((e) => B(e.style));
895
- if (ee.length > 0) {
1125
+ let te = e.children.filter((e) => B(e.style));
1126
+ if (te.length > 0) {
896
1127
  let e = B(o) ? {
897
1128
  x: r.left,
898
1129
  y: r.top,
899
1130
  width: i.left + t + i.right,
900
- height: i.top + P + i.bottom
1131
+ height: i.top + N + i.bottom
901
1132
  } : {
902
- x: M,
903
- y: N,
1133
+ x: j,
1134
+ y: M,
904
1135
  width: t,
905
- height: P
1136
+ height: N
906
1137
  };
907
- for (let n of ee) {
908
- let r = xe(n.style.gridColumnStart, n.style.gridColumnEnd, _, g.colOrigin, D, E.sizes, -i.left, t + i.right), a = xe(n.style.gridRowStart, n.style.gridRowEnd, v, g.rowOrigin, j, k.sizes, -i.top, P + i.bottom);
1138
+ for (let n of te) {
1139
+ let r = Ve(n.style.gridColumnStart, n.style.gridColumnEnd, h, m.colOrigin, T, w.sizes, -i.left, t + i.right), a = Ve(n.style.gridRowStart, n.style.gridRowEnd, g, m.rowOrigin, A, D.sizes, -i.top, N + i.bottom);
909
1140
  n.staticSlot = {
910
1141
  kind: "grid",
911
1142
  area: {
912
- x: M + r.start,
913
- y: N + a.start,
1143
+ x: j + r.start,
1144
+ y: M + a.start,
914
1145
  width: Math.max(0, r.end - r.start),
915
1146
  height: Math.max(0, a.end - a.start)
916
1147
  },
@@ -918,16 +1149,16 @@ function pe(e, t, n, r, i, a) {
918
1149
  };
919
1150
  }
920
1151
  }
921
- return P;
1152
+ return N;
922
1153
  }
923
- function me(e) {
1154
+ function Pe(e) {
924
1155
  let t = e.style.display === "grid";
925
1156
  return {
926
1157
  cols: t && e.style.gridTemplateColumns.kind === "subgrid",
927
1158
  rows: t && e.style.gridTemplateRows.kind === "subgrid"
928
1159
  };
929
1160
  }
930
- function he(e, t, n, r, i, a) {
1161
+ function Fe(e, t, n, r, i, a) {
931
1162
  let o = e[r] + a.start, s = t.sizes.slice(r, r + i);
932
1163
  return s[0] = Math.max(0, s[0] - a.start), s[i - 1] = Math.max(0, s[i - 1] - a.end), {
933
1164
  positions: Array.from({ length: i }, (t, n) => n === 0 ? 0 : e[r + n] - o),
@@ -936,20 +1167,20 @@ function he(e, t, n, r, i, a) {
936
1167
  gap: n
937
1168
  };
938
1169
  }
939
- function ge(e) {
1170
+ function Ie(e) {
940
1171
  return {
941
1172
  sizes: e.sizes,
942
1173
  gapBefore: e.gapBefore,
943
1174
  limits: e.sizes
944
1175
  };
945
1176
  }
946
- function _e(e, t, n, r) {
1177
+ function Le(e, t, n, r) {
947
1178
  let i = [];
948
1179
  return e.children.forEach((a, o) => {
949
1180
  let s = e.placed.items[o], c = n[o];
950
1181
  if (t[o].cols) {
951
- let e = ye(a, "cols", c, 0);
952
- for (let t of be(a, "cols", s, e, r)) i.push({
1182
+ let e = ze(a, "cols", c, 0);
1183
+ for (let t of Be(a, "cols", s, e, r)) i.push({
953
1184
  ...t,
954
1185
  start: t.start + s.col.start
955
1186
  });
@@ -958,24 +1189,24 @@ function _e(e, t, n, r) {
958
1189
  i.push({
959
1190
  start: s.col.start,
960
1191
  span: s.col.span,
961
- min: ke(a, "min", r) + De(c),
962
- max: ke(a, "max", r) + De(c)
1192
+ min: Ye(a, "min", r) + qe(c),
1193
+ max: Ye(a, "max", r) + qe(c)
963
1194
  });
964
1195
  }), i;
965
1196
  }
966
- function ve(e, t, n) {
1197
+ function Re(e, t, n) {
967
1198
  let r = [];
968
1199
  return e.children.forEach((i, a) => {
969
1200
  let o = e.placed.items[a], s = n[a];
970
1201
  if (t[a].rows) {
971
- let e = ye(i, "rows", s, 0);
972
- for (let t of be(i, "rows", o, e)) r.push({
1202
+ let e = ze(i, "rows", s, 0);
1203
+ for (let t of Be(i, "rows", o, e)) r.push({
973
1204
  ...t,
974
1205
  start: t.start + o.row.start
975
1206
  });
976
1207
  return;
977
1208
  }
978
- let c = i.localRect.height + Oe(s);
1209
+ let c = i.localRect.height + Je(s);
979
1210
  r.push({
980
1211
  start: o.row.start,
981
1212
  span: o.row.span,
@@ -984,7 +1215,7 @@ function ve(e, t, n) {
984
1215
  });
985
1216
  }), r;
986
1217
  }
987
- function ye(e, t, n, r) {
1218
+ function ze(e, t, n, r) {
988
1219
  let { border: i, padding: a } = e.style;
989
1220
  return t === "cols" ? {
990
1221
  start: (n.left ?? 0) + i.left + W(a.left, r),
@@ -994,15 +1225,15 @@ function ye(e, t, n, r) {
994
1225
  end: (n.bottom ?? 0) + i.bottom + W(a.bottom, r)
995
1226
  };
996
1227
  }
997
- function be(e, t, n, r, i) {
998
- let a = t === "cols" ? n.col.span : n.row.span, o = Ce(e, void 0, void 0, 0, 0, {
1228
+ function Be(e, t, n, r, i) {
1229
+ let a = t === "cols" ? n.col.span : n.row.span, o = Ue(e, void 0, void 0, 0, 0, {
999
1230
  col: n.col.span,
1000
1231
  row: n.row.span
1001
1232
  }), s = [];
1002
1233
  if (o.children.forEach((e, n) => {
1003
1234
  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);
1004
- if (me(e)[t]) {
1005
- let n = ye(e, t, p, 0), a = be(e, t, c, {
1235
+ if (Pe(e)[t]) {
1236
+ let n = ze(e, t, p, 0), a = Be(e, t, c, {
1006
1237
  start: n.start + (u ? r.start : 0),
1007
1238
  end: n.end + (d ? r.end : 0)
1008
1239
  }, i);
@@ -1015,11 +1246,11 @@ function be(e, t, n, r, i) {
1015
1246
  if (t === "cols") s.push({
1016
1247
  start: l.start,
1017
1248
  span: l.span,
1018
- min: ke(e, "min", i) + De(p) + f,
1019
- max: ke(e, "max", i) + De(p) + f
1249
+ min: Ye(e, "min", i) + qe(p) + f,
1250
+ max: Ye(e, "max", i) + qe(p) + f
1020
1251
  });
1021
1252
  else {
1022
- let t = e.localRect.height + Oe(p) + f;
1253
+ let t = e.localRect.height + Je(p) + f;
1023
1254
  s.push({
1024
1255
  start: l.start,
1025
1256
  span: l.span,
@@ -1038,9 +1269,9 @@ function be(e, t, n, r, i) {
1038
1269
  }
1039
1270
  return s;
1040
1271
  }
1041
- function xe(e, t, n, r, i, a, o, s) {
1042
- let c = Fe(e, "start", n), l = Fe(t, "end", n);
1043
- c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = Ie(c, t, 1, n) : l !== null && e.kind === "span" && (c = Ie(l, e, -1, n));
1272
+ function Ve(e, t, n, r, i, a, o, s) {
1273
+ let c = tt(e, "start", n), l = tt(t, "end", n);
1274
+ c !== null && l !== null ? c > l ? [c, l] = [l, c] : c === l && (l = null) : c !== null && t.kind === "span" ? l = nt(c, t, 1, n) : l !== null && e.kind === "span" && (c = nt(l, e, -1, n));
1044
1275
  let u = i.length, d = (e) => {
1045
1276
  if (e === null) return;
1046
1277
  let t = e - r;
@@ -1051,22 +1282,22 @@ function xe(e, t, n, r, i, a, o, s) {
1051
1282
  end: h === void 0 ? s : p(h)
1052
1283
  };
1053
1284
  }
1054
- function Se(e, t) {
1285
+ function He(e, t) {
1055
1286
  let n = t.gridIntrinsic.get(e);
1056
1287
  if (n !== void 0) return n;
1057
- let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = Ce(e, void 0, void 0, i, 0, e.subgrid ? {
1288
+ let r = e.style, i = Math.max(typeof r.gapX == "number" ? r.gapX : 0, r.ruleX?.width ?? 0), a = Ue(e, void 0, void 0, i, 0, e.subgrid ? {
1058
1289
  col: e.subgrid.colSpan,
1059
1290
  row: e.subgrid.rowSpan
1060
- } : void 0), o = a.children.map(me), s = a.children.map((e) => G(e.style.margin, 0)), c = ze(a.colTracks, a.colCollapsed, _e(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
1291
+ } : void 0), o = a.children.map(Pe), s = a.children.map((e) => G(e.style.margin, 0)), c = at(a.colTracks, a.colCollapsed, Le(a, o, s, t), "min-content", i, !1), l = c.gapBefore.reduce((e, t) => e + t, 0), u = {
1061
1292
  min: c.sizes.reduce((e, t) => e + t, 0) + l,
1062
1293
  max: c.limits.reduce((e, t) => e + t, 0) + l
1063
1294
  };
1064
1295
  return t.gridIntrinsic.set(e, u), u;
1065
1296
  }
1066
- function Ce(e, t, n, r, i, a) {
1067
- let o = e.style, s = Ee(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? we(a.col) : Ae(o.gridTemplateColumns, t, r), d = l ? we(a.row) : Ae(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
1297
+ function Ue(e, t, n, r, i, a) {
1298
+ let o = e.style, s = Ke(e), c = o.gridTemplateColumns.kind === "subgrid" && a !== void 0, l = o.gridTemplateRows.kind === "subgrid" && a !== void 0, u = c ? We(a.col) : Xe(o.gridTemplateColumns, t, r), d = l ? We(a.row) : Xe(o.gridTemplateRows, n, i), f = o.gridTemplateAreas, p = [...u.tracks], m = [...d.tracks];
1068
1299
  if (f) {
1069
- c || Me(p, u.lineNames, f.columns, o.gridAutoColumns), l || Me(m, d.lineNames, f.rows, o.gridAutoRows);
1300
+ c || Qe(p, u.lineNames, f.columns, o.gridAutoColumns), l || Qe(m, d.lineNames, f.rows, o.gridAutoRows);
1070
1301
  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`);
1071
1302
  }
1072
1303
  let h = {
@@ -1075,28 +1306,28 @@ function Ce(e, t, n, r, i, a) {
1075
1306
  }, g = {
1076
1307
  explicitCount: m.length,
1077
1308
  names: d.lineNames
1078
- }, _ = Re(s.map((e) => ({
1079
- col: Le(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1080
- row: Le(e.style.gridRowStart, e.style.gridRowEnd, g)
1309
+ }, _ = it(s.map((e) => ({
1310
+ col: rt(e.style.gridColumnStart, e.style.gridColumnEnd, h),
1311
+ row: rt(e.style.gridRowStart, e.style.gridRowEnd, g)
1081
1312
  })), p.length, m.length, o.gridAutoFlow);
1082
- return c && Te(_, "col", p.length), l && Te(_, "row", m.length), {
1313
+ return c && Ge(_, "col", p.length), l && Ge(_, "row", m.length), {
1083
1314
  children: s,
1084
1315
  placed: _,
1085
1316
  colLines: h,
1086
1317
  rowLines: g,
1087
- colTracks: Ne(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1088
- rowTracks: Ne(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1089
- colCollapsed: Pe(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1090
- rowCollapsed: Pe(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
1318
+ colTracks: $e(p, _.colOrigin, _.colCount, o.gridAutoColumns),
1319
+ rowTracks: $e(m, _.rowOrigin, _.rowCount, o.gridAutoRows),
1320
+ colCollapsed: et(u, _.colOrigin, _.colCount, _.items.map((e) => e.col)),
1321
+ rowCollapsed: et(d, _.rowOrigin, _.rowCount, _.items.map((e) => e.row))
1091
1322
  };
1092
1323
  }
1093
- function we(e) {
1324
+ function We(e) {
1094
1325
  return {
1095
- tracks: Array.from({ length: e }, () => fe()),
1326
+ tracks: Array.from({ length: e }, () => Me()),
1096
1327
  lineNames: Array.from({ length: e + 1 }, () => [])
1097
1328
  };
1098
1329
  }
1099
- function Te(e, t, n) {
1330
+ function Ge(e, t, n) {
1100
1331
  let r = t === "col" ? e.colOrigin : e.rowOrigin;
1101
1332
  for (let i of e.items) {
1102
1333
  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);
@@ -1104,22 +1335,22 @@ function Te(e, t, n) {
1104
1335
  }
1105
1336
  t === "col" ? (e.colOrigin = 0, e.colCount = n) : (e.rowOrigin = 0, e.rowCount = n);
1106
1337
  }
1107
- function Ee(e) {
1338
+ function Ke(e) {
1108
1339
  return e.children.filter((e) => !B(e.style) && !e.inlineBox).sort((e, t) => e.style.order - t.style.order);
1109
1340
  }
1110
- function De(e) {
1341
+ function qe(e) {
1111
1342
  return (e.left ?? 0) + (e.right ?? 0);
1112
1343
  }
1113
- function Oe(e) {
1344
+ function Je(e) {
1114
1345
  return (e.top ?? 0) + (e.bottom ?? 0);
1115
1346
  }
1116
- function ke(e, t, n) {
1347
+ function Ye(e, t, n) {
1117
1348
  let r = e.style, i;
1118
1349
  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));
1119
1350
  let a = typeof r.minWidth == "number" ? r.minWidth : 0, o = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
1120
1351
  return Math.max(0, H(i, a, o));
1121
1352
  }
1122
- function Ae(e, t, n) {
1353
+ function Xe(e, t, n) {
1123
1354
  if (e.kind !== "tracks") return {
1124
1355
  tracks: [],
1125
1356
  lineNames: [[]]
@@ -1132,7 +1363,7 @@ function Ae(e, t, n) {
1132
1363
  let { index: i, tracks: a, mode: o } = e.autoRepeat, s = 1;
1133
1364
  if (t !== void 0) {
1134
1365
  let e = a.reduce((e, n) => {
1135
- let r = je(n.min, t) ?? je(n.max, t) ?? 1;
1366
+ let r = Ze(n.min, t) ?? Ze(n.max, t) ?? 1;
1136
1367
  return e + Math.max(1, r);
1137
1368
  }, 0);
1138
1369
  s = Math.max(1, Math.floor((t + n) / (e + n * a.length)));
@@ -1160,23 +1391,23 @@ function Ae(e, t, n) {
1160
1391
  lineNames: d
1161
1392
  };
1162
1393
  }
1163
- function je(e, t) {
1394
+ function Ze(e, t) {
1164
1395
  if (e.kind === "cells") return e.value;
1165
- if (e.kind === "percent" && t !== void 0) return m(e.value, t);
1396
+ if (e.kind === "percent" && t !== void 0) return N(e.value, t);
1166
1397
  if (e.kind === "math") {
1167
1398
  let n = [];
1168
1399
  for (let r of e.args) {
1169
- let e = je(r, t);
1400
+ let e = Ze(r, t);
1170
1401
  if (e === void 0) return;
1171
1402
  n.push(e);
1172
1403
  }
1173
1404
  return e.fn === "min" ? Math.min(...n) : Math.max(...n);
1174
1405
  }
1175
1406
  }
1176
- function Me(e, t, n, r) {
1407
+ function Qe(e, t, n, r) {
1177
1408
  for (let i = e.length; i < n; i++) e.push(r[(i - e.length) % r.length]), t.push([]);
1178
1409
  }
1179
- function Ne(e, t, n, r) {
1410
+ function $e(e, t, n, r) {
1180
1411
  let i = [];
1181
1412
  for (let a = 0; a < n; a++) {
1182
1413
  let n = a + t;
@@ -1188,7 +1419,7 @@ function Ne(e, t, n, r) {
1188
1419
  }
1189
1420
  return i;
1190
1421
  }
1191
- function Pe(e, t, n, r) {
1422
+ function et(e, t, n, r) {
1192
1423
  let i = Array.from({ length: n }, () => !1);
1193
1424
  if (!e.autoFit) return i;
1194
1425
  for (let a = e.autoFit.start; a < e.autoFit.end; a++) {
@@ -1197,7 +1428,7 @@ function Pe(e, t, n, r) {
1197
1428
  }
1198
1429
  return i;
1199
1430
  }
1200
- function Fe(e, t, n) {
1431
+ function tt(e, t, n) {
1201
1432
  if (e.kind === "line") return e.value > 0 ? e.value - 1 : n.explicitCount + 1 + e.value;
1202
1433
  if (e.kind !== "name") return null;
1203
1434
  if (e.nth === void 0) {
@@ -1212,14 +1443,14 @@ function Fe(e, t, n) {
1212
1443
  for (let t = i; t >= 0; t--) if (n.names[t].includes(e.name) && ++a === -r) return t;
1213
1444
  return -(-r - a);
1214
1445
  }
1215
- function Ie(e, t, n, r) {
1446
+ function nt(e, t, n, r) {
1216
1447
  if (t.name === void 0) return e + n * t.value;
1217
1448
  let i = t.value, a = e;
1218
1449
  for (; i > 0;) a += n, (!(a >= 0 && a <= r.explicitCount) || r.names[a].includes(t.name)) && i--;
1219
1450
  return a;
1220
1451
  }
1221
- function Le(e, t, n) {
1222
- let r = Fe(e, "start", n), i = Fe(t, "end", n);
1452
+ function rt(e, t, n) {
1453
+ let r = tt(e, "start", n), i = tt(t, "end", n);
1223
1454
  if (r !== null && i !== null) return r === i ? {
1224
1455
  start: r,
1225
1456
  span: 1
@@ -1229,10 +1460,10 @@ function Le(e, t, n) {
1229
1460
  };
1230
1461
  if (r !== null) return {
1231
1462
  start: r,
1232
- span: (t.kind === "span" ? Ie(r, t, 1, n) : r + 1) - r
1463
+ span: (t.kind === "span" ? nt(r, t, 1, n) : r + 1) - r
1233
1464
  };
1234
1465
  if (i !== null) {
1235
- let t = e.kind === "span" ? Ie(i, e, -1, n) : i - 1;
1466
+ let t = e.kind === "span" ? nt(i, e, -1, n) : i - 1;
1236
1467
  return {
1237
1468
  start: t,
1238
1469
  span: i - t
@@ -1243,7 +1474,7 @@ function Le(e, t, n) {
1243
1474
  span: e.kind === "span" ? e.value : t.kind === "span" ? t.value : 1
1244
1475
  };
1245
1476
  }
1246
- function Re(e, t, n, r) {
1477
+ function it(e, t, n, r) {
1247
1478
  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);
1248
1479
  for (let t = 0; t < e.length; t++) {
1249
1480
  let e = o[t];
@@ -1340,7 +1571,7 @@ function Re(e, t, n, r) {
1340
1571
  rowCount: S
1341
1572
  };
1342
1573
  }
1343
- function ze(e, t, n, r, i, a) {
1574
+ function at(e, t, n, r, i, a) {
1344
1575
  let o = typeof r == "number" ? r : void 0, s = e.map((e, n) => {
1345
1576
  if (t[n]) return {
1346
1577
  base: 0,
@@ -1350,7 +1581,7 @@ function ze(e, t, n, r, i, a) {
1350
1581
  frFactor: 0,
1351
1582
  collapsed: !0
1352
1583
  };
1353
- let r = je(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1584
+ let r = Ze(e.min, o), i = r ?? 0, a = r === void 0, s = e.max;
1354
1585
  if (s.kind === "fr") return {
1355
1586
  base: i,
1356
1587
  limit: null,
@@ -1359,7 +1590,7 @@ function ze(e, t, n, r, i, a) {
1359
1590
  frFactor: s.value,
1360
1591
  collapsed: !1
1361
1592
  };
1362
- let c = je(s, o);
1593
+ let c = Ze(s, o);
1363
1594
  return c === void 0 ? {
1364
1595
  base: i,
1365
1596
  limit: null,
@@ -1437,7 +1668,7 @@ function ze(e, t, n, r, i, a) {
1437
1668
  n <= 0 || (t = Math.max(t, (e.max - r) / Math.max(n, 1)));
1438
1669
  }
1439
1670
  for (let n of e) {
1440
- let e = Math.max(n.base, f(n.frFactor * t));
1671
+ let e = Math.max(n.base, j(n.frFactor * t));
1441
1672
  n.limit = e, r === "max-content" && (n.base = e);
1442
1673
  }
1443
1674
  }
@@ -1484,62 +1715,62 @@ function ze(e, t, n, r, i, a) {
1484
1715
  limits: s.map((e) => u(e))
1485
1716
  };
1486
1717
  }
1487
- function Be(e, t, n) {
1488
- let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - Ve(e)), o = F(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1718
+ function ot(e, t, n) {
1719
+ let { sizes: r, gapBefore: i } = e, a = Math.max(0, t - st(e)), o = F(n === "stretch" ? "start" : n, r, a), s = [], c = 0;
1489
1720
  for (let e = 0; e < r.length; e++) c += i[e], s.push(o[e] + c);
1490
1721
  return s;
1491
1722
  }
1492
- function Ve(e) {
1723
+ function st(e) {
1493
1724
  return e.sizes.reduce((e, t) => e + t, 0) + e.gapBefore.reduce((e, t) => e + t, 0);
1494
1725
  }
1495
- function He(e, t, n, r) {
1726
+ function ct(e, t, n, r) {
1496
1727
  let i = n + r - 1;
1497
1728
  return e[n] === void 0 || e[i] === void 0 ? 0 : e[i] + t[i] - e[n];
1498
1729
  }
1499
- function Ue(e, t, n, r, i) {
1730
+ function lt(e, t, n, r, i) {
1500
1731
  let a = t ?? 0, o = n ?? 0, s = r - i;
1501
1732
  return t === null && n === null ? Math.floor(s / 2) : t === null ? s - o : n === null ? a : a + L(e, r, i + a + o);
1502
1733
  }
1503
1734
  //#endregion
1504
1735
  //#region src/multicol.ts
1505
- function We(e, t, n) {
1736
+ function ut(e, t, n) {
1506
1737
  let r = e.columnWidth === null ? null : Math.max(1, Math.floor((t + n) / (e.columnWidth + n)));
1507
1738
  return e.columnCount !== null && r !== null ? Math.max(1, Math.min(e.columnCount, r)) : r === null ? Math.max(1, e.columnCount ?? 1) : r;
1508
1739
  }
1509
- function Ge(e, t, n) {
1510
- let r = We(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r)), a = Math.max(0, t - (r * i + (r - 1) * n));
1740
+ function dt(e, t, n) {
1741
+ let r = ut(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r)), a = Math.max(0, t - (r * i + (r - 1) * n));
1511
1742
  return Array.from({ length: r }, (e, t) => i + +(t < a));
1512
1743
  }
1513
- function Ke(e, t) {
1744
+ function ft(e, t) {
1514
1745
  let n = Math.max(typeof e.gapX == "number" ? e.gapX : 0, e.ruleX?.width ?? 0);
1515
1746
  return e.columnCount === null ? Math.max(e.columnWidth ?? 1, t) : e.columnCount * t + (e.columnCount - 1) * n;
1516
1747
  }
1517
- function qe(e, t) {
1748
+ function pt(e, t) {
1518
1749
  return e === void 0 ? t : t === void 0 ? e : Math.min(e, t);
1519
1750
  }
1520
- function Je(e, t, n) {
1751
+ function mt(e, t, n) {
1521
1752
  for (; e < t;) {
1522
1753
  let r = e + t >> 1;
1523
1754
  n(r) ? t = r : e = r + 1;
1524
1755
  }
1525
1756
  return e;
1526
1757
  }
1527
- function Ye(e, t, n) {
1528
- let r = We(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1758
+ function ht(e, t, n) {
1759
+ let r = ut(e, t, n), i = Math.max(1, Math.floor((t - (r - 1) * n) / r));
1529
1760
  return {
1530
1761
  count: r,
1531
1762
  width: i,
1532
1763
  leftover: Math.max(0, t - (r * i + (r - 1) * n))
1533
1764
  };
1534
1765
  }
1535
- function Xe(e, t, n) {
1766
+ function gt(e, t, n) {
1536
1767
  return e === "all" ? !0 : e === "around" ? t || n : t && n;
1537
1768
  }
1538
- function Ze(e, t, n, r) {
1539
- let i = qt(e, Math.max(1, t.width - e.style.tracking)), { heights: a, textOffsets: o } = Jt(e, i), s = e.style.lineGap, c = Qe(a.map((e) => e + s)), l;
1769
+ function _t(e, t, n, r) {
1770
+ let i = gn(e, Math.max(1, t.width - e.style.tracking)), { heights: a, textOffsets: o } = _n(e, i), s = e.style.lineGap, c = vt(a.map((e) => e + s)), l;
1540
1771
  if (e.style.columnFill === "auto" && r !== void 0) l = Math.max(1, r);
1541
1772
  else {
1542
- let e = Je(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);
1773
+ let e = mt(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);
1543
1774
  l = r === void 0 ? e : Math.max(1, Math.min(e, r));
1544
1775
  }
1545
1776
  let u = z(c, s, l);
@@ -1555,47 +1786,57 @@ function Ze(e, t, n, r) {
1555
1786
  columnsUsed: i.length > 0 ? u.columns : 0
1556
1787
  };
1557
1788
  }
1558
- function z(e, t, n) {
1559
- let r = 0, i = 0, a = 0, o = [], s = [];
1560
- for (let c = 0; c < e.length; c++) {
1561
- let l = e[c], u = c === 0 || i > 0 ? l.pre : 0;
1562
- i > 0 && (l.forced || i + u + l.rows - t > n) && (r += 1, i = 0, u = 0);
1563
- let d = l.rows / l.lines;
1564
- if (l.lines > 1 && l.rows - t > n) {
1565
- for (let e = 0; e < l.lines; e++) i > 0 && i + u + d - t > n && (r += 1, i = 0, u = 0), o.push(r), s.push(i + u), i += u + d, u = 0, a = Math.max(a, i - t);
1789
+ function z(e, t, n, r = "truncate") {
1790
+ let i = 0, a = 0, o = 0, s = [], c = [];
1791
+ for (let l = 0; l < e.length; l++) {
1792
+ let u = e[l], d = r === "glue" || l === 0 || a > 0 ? u.pre : 0;
1793
+ a > 0 && (u.forced || a + d + u.rows + u.post - t > n) && (r === "truncate" && (d = 0), i += 1, a = 0);
1794
+ let f = u.rows / u.lines;
1795
+ if (u.lines > 1 && u.rows - t > n) {
1796
+ for (let e = 0; e < u.lines; e++) a > 0 && a + d + f - t > n && (r === "truncate" && (d = 0), i += 1, a = 0), s.push(i), c.push(a + d), a += d + f, d = 0, o = Math.max(o, a - t);
1797
+ a += u.post, u.post > 0 && (o = Math.max(o, a));
1566
1798
  continue;
1567
1799
  }
1568
- for (let e = 0; e < l.lines; e++) o.push(r), s.push(i + u + e * d);
1569
- i += u + l.rows, a = Math.max(a, i - t);
1800
+ for (let e = 0; e < u.lines; e++) s.push(i), c.push(a + d + e * f);
1801
+ a += d + u.rows + u.post, o = Math.max(o, a - (u.post > 0 ? 0 : t));
1570
1802
  }
1571
1803
  return {
1572
- columns: r + 1,
1573
- maxUsed: a,
1574
- column: o,
1575
- top: s
1804
+ columns: i + 1,
1805
+ maxUsed: o,
1806
+ column: s,
1807
+ top: c
1576
1808
  };
1577
1809
  }
1578
- function Qe(e) {
1810
+ function vt(e) {
1579
1811
  return e.map((e) => ({
1580
1812
  rows: e,
1581
1813
  pre: 0,
1814
+ post: 0,
1582
1815
  forced: !1,
1583
1816
  lines: 1
1584
1817
  }));
1585
1818
  }
1586
- function $e(e, t) {
1587
- 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 = x(e, Math.max(1, n - i), {
1819
+ var yt = null;
1820
+ function bt() {
1821
+ if (yt !== null) return yt;
1822
+ let e = document.createElement("div");
1823
+ 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);
1824
+ let t = e.getBoundingClientRect().top, n = e.querySelector("span").getBoundingClientRect();
1825
+ return e.remove(), yt = !(n.width > 0 && n.top - t >= 10), yt;
1826
+ }
1827
+ function xt(e, t) {
1828
+ 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 = se(e, Math.max(1, n - i), {
1588
1829
  advances: s,
1589
1830
  tracking: i,
1590
1831
  firstLineIndent: t.firstLineIndent
1591
- }), l = Qe(c.map(() => 1 + a)), u = z(l, a, o ?? Je(1, Math.max(1, c.length * (1 + a) - a), (e) => z(l, a, e).columns <= r));
1832
+ }), l = vt(c.map(() => 1 + a)), u = z(l, a, o ?? mt(1, Math.max(1, c.length * (1 + a) - a), (e) => z(l, a, e).columns <= r));
1592
1833
  return c.map((t, n) => ({
1593
1834
  text: e.slice(t.start, t.end),
1594
1835
  column: u.column[n],
1595
1836
  top: u.top[n]
1596
1837
  }));
1597
1838
  }
1598
- function et(e, t, n, r) {
1839
+ function St(e, t, n, r) {
1599
1840
  let i = e.style;
1600
1841
  if (!i.ruleX) return;
1601
1842
  let a = t.columnCount * t.columnWidth + (t.columnCount - 1) * t.gap, o = t.ruleSegments ?? [{
@@ -1605,17 +1846,17 @@ function et(e, t, n, r) {
1605
1846
  }], s = [];
1606
1847
  for (let e of o) {
1607
1848
  let n = Math.min(e.columns, t.columnCount);
1608
- for (let r = 0; r < t.columnCount - 1; r++) Xe(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
1849
+ for (let r = 0; r < t.columnCount - 1; r++) gt(i.ruleVisibilityItems, r < n, r + 1 < n) && s.push({
1609
1850
  bandStart: (r + 1) * t.columnWidth + r * t.gap,
1610
1851
  bandSize: t.gap,
1611
1852
  start: e.start,
1612
1853
  end: e.end
1613
1854
  });
1614
1855
  }
1615
- e.decorationRuns = u({
1856
+ e.decorationRuns = O({
1616
1857
  ruleX: i.ruleX,
1617
1858
  ruleY: null,
1618
- vertical: N(s, i.ruleInset),
1859
+ vertical: ve(s, i.ruleInset),
1619
1860
  horizontal: [],
1620
1861
  contentWidth: a,
1621
1862
  contentHeight: t.totalRows,
@@ -1625,96 +1866,108 @@ function et(e, t, n, r) {
1625
1866
  padding: r
1626
1867
  });
1627
1868
  }
1628
- function tt(e, t) {
1869
+ function Ct(e, t) {
1629
1870
  let n = e.style, r = n.padding;
1630
1871
  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;
1631
1872
  }
1632
- function nt(e, t, n, r, i, a, o) {
1633
- let s = e.style, c = U(s, "x", n), l = Ye(s, n, c);
1873
+ function wt(e, t, n, r, i, a, o) {
1874
+ let s = e.style, c = U(s, "x", n), l = ht(s, n, c);
1634
1875
  a.right += l.leftover;
1635
1876
  let u = s.lineGap, d = i.left + a.left, f = i.top + a.top, p = n - l.leftover, m = [[]], h = [];
1636
1877
  for (let e of t) e.style.columnSpan ? (h[m.length - 1] = e, m.push([])) : m[m.length - 1].push(e);
1637
- let g = m.length > 1, _ = [], v = 0, y = 0;
1878
+ let g = m.length > 1, _ = g ? "glue" : "truncate", v = [], y = 0, b = 0;
1638
1879
  for (let e = 0; e < m.length; e++) {
1639
- let t = m[e];
1880
+ let t = m[e], n = 0;
1640
1881
  if (t.length > 0) {
1641
- let n = t.map((e) => ({
1882
+ let i = t.map((e) => ({
1642
1883
  node: e,
1643
- spans: qt(e, Math.max(1, l.width - e.style.tracking)),
1644
- margin: G(e.style.margin, l.width)
1645
- })), i = [], a = null, o = !1;
1646
- for (let { node: e, spans: t, margin: r } of n) {
1647
- let n = a === null ? r.top ?? 0 : $t(a, r.top ?? 0), s = o || e.style.breakBeforeColumn;
1648
- if (e.style.breakInsideAvoid && t.length > 0) i.push({
1649
- rows: t.length * (1 + u),
1650
- pre: n,
1651
- forced: s,
1652
- lines: t.length
1884
+ spans: gn(e, Math.max(1, l.width - e.style.tracking)),
1885
+ margin: G(e.style.margin, l.width),
1886
+ pre: 0,
1887
+ post: 0
1888
+ })), a = [], o = null, h = null, x = !1;
1889
+ for (let e of i) {
1890
+ let { node: t, spans: n, margin: r } = e, i = o === null ? r.top ?? 0 : Sn(o, r.top ?? 0), s = i;
1891
+ _ === "glue" && h !== null ? (s = 0, h.post = i, a[a.length - 1].post = i) : e.pre = i;
1892
+ let c = x || t.style.breakBeforeColumn;
1893
+ if (t.style.breakInsideAvoid && n.length > 0) a.push({
1894
+ rows: n.length * (1 + u),
1895
+ pre: s,
1896
+ post: 0,
1897
+ forced: c,
1898
+ lines: n.length
1653
1899
  });
1654
- else for (let e = 0; e < t.length; e++) i.push({
1900
+ else for (let e = 0; e < n.length; e++) a.push({
1655
1901
  rows: 1 + u,
1656
- pre: e > 0 ? 0 : n,
1657
- forced: e === 0 && s,
1902
+ pre: e > 0 ? 0 : s,
1903
+ post: 0,
1904
+ forced: e === 0 && c,
1658
1905
  lines: 1
1659
1906
  });
1660
- t.length > 0 && (a = r.bottom ?? 0), o = e.style.breakAfterColumn;
1907
+ n.length > 0 && (o = r.bottom ?? 0, h = e), x = t.style.breakAfterColumn;
1661
1908
  }
1662
- let h;
1663
- if (s.columnFill === "auto" && r !== void 0) h = Math.max(1, r);
1909
+ n = o ?? 0;
1910
+ let S;
1911
+ if (s.columnFill === "auto" && r !== void 0) S = Math.max(1, r);
1664
1912
  else {
1665
- let e = Je(1, Math.max(1, z(i, u, Infinity).maxUsed), (e) => z(i, u, e).columns <= l.count);
1666
- h = r === void 0 ? e : Math.max(1, Math.min(e, r));
1913
+ let e = mt(1, Math.max(1, z(a, u, Infinity, _).maxUsed), (e) => z(a, u, e, _).columns <= l.count);
1914
+ S = r === void 0 ? e : Math.max(1, Math.min(e, r));
1667
1915
  }
1668
- let g = z(i, u, h);
1669
- for (let e = 0, t = 0; e < n.length; e++) {
1670
- let { node: r, spans: i, margin: a } = n[e], o = [], s = [];
1671
- for (let e = 0; e < i.length; e++, t++) o.push(v + g.top[t]), s.push(g.column[t] * (l.width + c));
1672
- delete r.decorationRuns, r.multicolGeometry = {
1673
- spans: i,
1674
- lineY: o,
1675
- textY: o,
1676
- lineX: s,
1677
- totalRows: v + g.maxUsed,
1916
+ let C = z(a, u, S, _);
1917
+ for (let e = 0, t = 0; e < i.length; e++) {
1918
+ let { node: n, spans: r, margin: a, pre: o, post: s } = i[e], u = [], m = [];
1919
+ for (let e = 0; e < r.length; e++, t++) u.push(y + C.top[t]), m.push(C.column[t] * (l.width + c));
1920
+ delete n.decorationRuns, n.multicolGeometry = {
1921
+ spans: r,
1922
+ lineY: u,
1923
+ textY: u,
1924
+ lineX: m,
1925
+ totalRows: y + C.maxUsed,
1678
1926
  columnCount: l.count,
1679
1927
  columnWidth: l.width,
1680
1928
  gap: c,
1681
- columnsUsed: g.columns
1682
- }, r.multicolFlow = a, r.localRect = {
1929
+ columnsUsed: C.columns
1930
+ }, n.multicolFlow = g ? {
1931
+ top: o,
1932
+ right: a.right,
1933
+ bottom: s,
1934
+ left: a.left
1935
+ } : a, n.localRect = {
1683
1936
  x: d,
1684
1937
  y: f,
1685
1938
  width: p,
1686
- height: g.maxUsed
1687
- }, r.resolvedPadding = {
1939
+ height: C.maxUsed
1940
+ }, n.resolvedPadding = {
1688
1941
  top: 0,
1689
1942
  right: 0,
1690
1943
  bottom: 0,
1691
1944
  left: 0
1692
1945
  };
1693
1946
  }
1694
- i.length > 0 && (_.push({
1695
- start: v,
1696
- end: v + g.maxUsed,
1697
- columns: g.columns
1698
- }), y = Math.max(y, g.columns), v += g.maxUsed + (e < m.length - 1 ? u : 0));
1947
+ a.length > 0 && (v.push({
1948
+ start: y,
1949
+ end: y + C.maxUsed,
1950
+ columns: C.columns
1951
+ }), b = Math.max(b, C.columns), y += C.maxUsed + (e < m.length - 1 ? u : 0));
1699
1952
  }
1700
- let n = h[e];
1701
- if (n) {
1702
- let e = G(n.style.margin, p), t = (e.left ?? 0) + (e.right ?? 0);
1703
- V(n, Math.max(0, p - t), void 0, 0, 0, "fill", o);
1704
- let r = Qt(e, p, n.localRect.width);
1705
- v += e.top ?? 0, n.localRect = {
1706
- ...n.localRect,
1953
+ let i = h[e];
1954
+ if (i) {
1955
+ let e = G(i.style.margin, p), t = (e.left ?? 0) + (e.right ?? 0);
1956
+ V(i, Math.max(0, p - t), void 0, 0, 0, "fill", o);
1957
+ let r = xn(e, p, i.localRect.width), a = (e.top ?? 0) + n;
1958
+ y += a, i.localRect = {
1959
+ ...i.localRect,
1707
1960
  x: d + r,
1708
- y: f + v
1709
- }, n.multicolFlowSpan = {
1710
- top: e.top ?? 0,
1961
+ y: f + y
1962
+ }, i.multicolFlowSpan = {
1963
+ top: a,
1711
1964
  right: 0,
1712
1965
  bottom: e.bottom ?? 0,
1713
1966
  left: r
1714
- }, v += n.localRect.height + (e.bottom ?? 0);
1967
+ }, y += i.localRect.height + (e.bottom ?? 0);
1715
1968
  }
1716
1969
  }
1717
- let b = v;
1970
+ let x = y;
1718
1971
  for (let t of e.children) {
1719
1972
  if (!B(t.style)) continue;
1720
1973
  let e = G(t.style.margin, n);
@@ -1729,21 +1982,21 @@ function nt(e, t, n, r, i, a, o) {
1729
1982
  lineY: [],
1730
1983
  textY: [],
1731
1984
  lineX: [],
1732
- totalRows: b,
1985
+ totalRows: x,
1733
1986
  columnCount: l.count,
1734
1987
  columnWidth: l.width,
1735
1988
  gap: c,
1736
- columnsUsed: y,
1989
+ columnsUsed: b,
1737
1990
  ...g ? {
1738
- ruleSegments: _,
1991
+ ruleSegments: v,
1739
1992
  nativeBalance: !0
1740
1993
  } : {}
1741
- }, b;
1994
+ }, x;
1742
1995
  }
1743
- function rt(e, t, n, r, i, a, o) {
1744
- let s = e.style, c = qe(n, r), l = e.children.filter((e) => !B(e.style)), d = l.filter((e) => !e.style.columnSpan);
1745
- if (d.length > 0 && d.every((e) => tt(e, s)) && (d.length === l.length || s.columnFill === "balance" && c === void 0 && d.every((e) => (e.style.margin.top === 0 || e.style.margin.top === null) && (e.style.margin.bottom === 0 || e.style.margin.bottom === null)))) return nt(e, l, t, c, i, a, o);
1746
- let f = U(s, "x", t), p = Ge(s, t, f), m = p.length, h = [];
1996
+ function Tt(e, t, n, r, i, a, o) {
1997
+ let s = e.style, c = pt(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);
1998
+ if (u.length > 0 && u.every((e) => Ct(e, s)) && (u.length === l.length || s.columnFill === "balance" && c === void 0 && (bt() || 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 wt(e, l, t, c, i, a, o);
1999
+ let f = U(s, "x", t), p = dt(s, t, f), m = p.length, h = [];
1747
2000
  {
1748
2001
  let e = 0;
1749
2002
  for (let t of p) h.push(e), e += t + f;
@@ -1752,7 +2005,7 @@ function rt(e, t, n, r, i, a, o) {
1752
2005
  let r = 0, i = 0, a = null, s = 0, c = (e) => {
1753
2006
  if (t) for (let t of w) {
1754
2007
  if (t.index !== e) continue;
1755
- let n = a === null ? t.margin.top ?? 0 : $t(a, t.margin.top ?? 0);
2008
+ let n = a === null ? t.margin.top ?? 0 : Sn(a, t.margin.top ?? 0);
1756
2009
  t.child.staticSlot = {
1757
2010
  kind: "block",
1758
2011
  x: y + g(r) + (t.margin.left ?? 0),
@@ -1763,7 +2016,7 @@ function rt(e, t, n, r, i, a, o) {
1763
2016
  for (let l = 0; l < C.length; l++) {
1764
2017
  let u = C[l];
1765
2018
  c(l);
1766
- let d = a === null ? l === 0 ? u.margin.top ?? 0 : 0 : $t(a, u.margin.top ?? 0), f = u.node.localRect.height;
2019
+ let d = a === null ? l === 0 ? u.margin.top ?? 0 : 0 : Sn(a, u.margin.top ?? 0), f = u.node.localRect.height;
1767
2020
  if (a !== null && (u.breakBefore || i + d + f > e) && (r += 1, i = 0, a = null, d = 0), t) {
1768
2021
  let e = u.node, t = _(r);
1769
2022
  if (t !== v) {
@@ -1772,7 +2025,7 @@ function rt(e, t, n, r, i, a, o) {
1772
2025
  }
1773
2026
  e.localRect = {
1774
2027
  ...e.localRect,
1775
- x: y + g(r) + Qt(u.margin, t, e.localRect.width),
2028
+ x: y + g(r) + xn(u.margin, t, e.localRect.width),
1776
2029
  y: b + S + i + d
1777
2030
  };
1778
2031
  }
@@ -1795,13 +2048,13 @@ function rt(e, t, n, r, i, a, o) {
1795
2048
  let e = c === void 0 ? void 0 : Math.max(1, c - S), t = s.columnFill === "auto" && e !== void 0, r;
1796
2049
  if (t) r = e;
1797
2050
  else {
1798
- let t = Je(1, E(Infinity, !1).maxUsed, (e) => E(e, !1).columns <= m);
2051
+ let t = mt(1, E(Infinity, !1).maxUsed, (e) => E(e, !1).columns <= m);
1799
2052
  r = e === void 0 ? t : Math.min(t, e);
1800
2053
  }
1801
2054
  let i = E(r, !0), a = t && n !== void 0 ? Math.max(i.maxUsed, r) : i.maxUsed;
1802
2055
  if (s.ruleX) for (let e = 0; e < m - 1; e++) {
1803
2056
  let t = Math.min(i.columns, m);
1804
- Xe(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
2057
+ gt(s.ruleVisibilityItems, e < t, e + 1 < t) && x.push({
1805
2058
  bandStart: h[e] + p[e],
1806
2059
  bandSize: f,
1807
2060
  start: S,
@@ -1824,7 +2077,7 @@ function rt(e, t, n, r, i, a, o) {
1824
2077
  let e = G(r.style.margin, t), i = (e.left ?? 0) + (e.right ?? 0);
1825
2078
  V(r, Math.max(0, t - i), n, 0, 0, "fill", o), S += e.top ?? 0, r.localRect = {
1826
2079
  ...r.localRect,
1827
- x: y + Qt(e, t, r.localRect.width),
2080
+ x: y + xn(e, t, r.localRect.width),
1828
2081
  y: b + S
1829
2082
  }, S += r.localRect.height + (e.bottom ?? 0);
1830
2083
  continue;
@@ -1836,10 +2089,10 @@ function rt(e, t, n, r, i, a, o) {
1836
2089
  breakBefore: T || r.style.breakBeforeColumn
1837
2090
  }), T = r.style.breakAfterColumn;
1838
2091
  }
1839
- return D(), s.ruleX && x.length > 0 && (e.decorationRuns = u({
2092
+ return D(), s.ruleX && x.length > 0 && (e.decorationRuns = O({
1840
2093
  ruleX: s.ruleX,
1841
2094
  ruleY: null,
1842
- vertical: N(x, s.ruleInset),
2095
+ vertical: ve(x, s.ruleInset),
1843
2096
  horizontal: [],
1844
2097
  contentWidth: t,
1845
2098
  contentHeight: S,
@@ -1851,39 +2104,39 @@ function rt(e, t, n, r, i, a, o) {
1851
2104
  }
1852
2105
  //#endregion
1853
2106
  //#region src/warn.ts
1854
- var it = /* @__PURE__ */ new WeakMap();
1855
- function at(e, t) {
1856
- let n = it.get(e);
1857
- n || it.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, e));
2107
+ var Et = /* @__PURE__ */ new WeakMap();
2108
+ function Dt(e, t) {
2109
+ let n = Et.get(e);
2110
+ n || Et.set(e, n = /* @__PURE__ */ new Set()), !n.has(t) && (n.add(t), console.warn(`[monowind] ${t}`, e));
1858
2111
  }
1859
2112
  //#endregion
1860
2113
  //#region src/table.ts
1861
- function ot(e, t) {
1862
- e.hidden.push(t), t.style.tableRole !== "column" && t.style.tableRole !== "column-group" && at(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).");
2114
+ function Ot(e, t) {
2115
+ e.hidden.push(t), t.style.tableRole !== "column" && t.style.tableRole !== "column-group" && Dt(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).");
1863
2116
  }
1864
- function st(e, t) {
2117
+ function kt(e, t) {
1865
2118
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
1866
2119
  return Number.isNaN(n) ? 1 : t === "colspan" ? Math.min(1e3, Math.max(1, n)) : Math.min(65534, Math.max(0, n));
1867
2120
  }
1868
- function ct(e, t, n) {
2121
+ function At(e, t, n) {
1869
2122
  let r = (t, r) => {
1870
2123
  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;
1871
2124
  for (let t = 0; t < r; t++) e.colFixed.push(a), e.colPercent.push(o);
1872
2125
  };
1873
2126
  if (t.style.tableRole === "column") {
1874
- r(t, lt(t.source));
2127
+ r(t, jt(t.source));
1875
2128
  return;
1876
2129
  }
1877
2130
  let i = t.children.filter((e) => e.style.tableRole === "column");
1878
- if (i.length === 0) r(t, lt(t.source));
1879
- else for (let e of i) r(e, lt(e.source));
1880
- for (let n of t.children) n.style.tableRole !== "column" && ot(e, n);
2131
+ if (i.length === 0) r(t, jt(t.source));
2132
+ else for (let e of i) r(e, jt(e.source));
2133
+ for (let n of t.children) n.style.tableRole !== "column" && Ot(e, n);
1881
2134
  }
1882
- function lt(e) {
2135
+ function jt(e) {
1883
2136
  let t = Number.parseInt(e.getAttribute("span") ?? "", 10);
1884
2137
  return Number.isNaN(t) ? 1 : Math.min(1e3, Math.max(1, t));
1885
2138
  }
1886
- function ut(e, t) {
2139
+ function Mt(e, t) {
1887
2140
  let n = {
1888
2141
  caption: null,
1889
2142
  rows: [],
@@ -1907,8 +2160,8 @@ function ut(e, t) {
1907
2160
  for (let e of o.children) B(e.style) || (e.style.tableRole === "row" ? t.push({
1908
2161
  row: e,
1909
2162
  group: o
1910
- }) : ot(n, e));
1911
- } else e === "caption" ? n.caption === null ? n.caption = o : ot(n, o) : e === "column" || e === "column-group" ? (ct(n, o, t), n.hidden.push(o)) : ot(n, o);
2163
+ }) : Ot(n, e));
2164
+ } else e === "caption" ? n.caption === null ? n.caption = o : Ot(n, o) : e === "column" || e === "column-group" ? (At(n, o, t), n.hidden.push(o)) : Ot(n, o);
1912
2165
  }
1913
2166
  let o = [
1914
2167
  ...r,
@@ -1923,20 +2176,20 @@ function ut(e, t) {
1923
2176
  s = e + 1;
1924
2177
  }
1925
2178
  }
1926
- return dt(n), n;
2179
+ return Nt(n), n;
1927
2180
  }
1928
- function dt(e) {
2181
+ function Nt(e) {
1929
2182
  let t = [];
1930
2183
  for (let n = 0; n < e.rows.length; n++) {
1931
2184
  let r = e.rows[n], i = 0;
1932
2185
  for (let a of r.children) {
1933
2186
  if (B(a.style)) continue;
1934
2187
  if (a.style.tableRole !== "cell") {
1935
- ot(e, a);
2188
+ Ot(e, a);
1936
2189
  continue;
1937
2190
  }
1938
2191
  for (; (t[i] ?? 0) > n;) i++;
1939
- let o = st(a.source, "colspan"), s = st(a.source, "rowspan"), c = e.groupEnds[n], l = Math.max(1, Math.min(s === 0 ? c - n : s, c - n));
2192
+ let o = kt(a.source, "colspan"), s = kt(a.source, "rowspan"), c = e.groupEnds[n], l = Math.max(1, Math.min(s === 0 ? c - n : s, c - n));
1940
2193
  for (let e = i; e < i + o; e++) t[e] = Math.max(t[e] ?? 0, n + l);
1941
2194
  e.cells.push({
1942
2195
  node: a,
@@ -1950,7 +2203,7 @@ function dt(e) {
1950
2203
  }
1951
2204
  e.columnCount = Math.max(t.length, e.colFixed.length);
1952
2205
  }
1953
- function ft(e, t, n) {
2206
+ function Pt(e, t, n) {
1954
2207
  let r = e.style, i = Y(e, n), a;
1955
2208
  if (t === "min") a = i;
1956
2209
  else {
@@ -1960,11 +2213,11 @@ function ft(e, t, n) {
1960
2213
  let o = typeof r.minWidth == "number" ? r.minWidth : 0, s = typeof r.maxWidth == "number" ? r.maxWidth : void 0;
1961
2214
  return Math.max(0, H(a, o, s));
1962
2215
  }
1963
- function pt(e) {
2216
+ function Ft(e) {
1964
2217
  let t = e.style.width;
1965
2218
  return t && t.kind === "percent" ? t.value : void 0;
1966
2219
  }
1967
- function mt(e, t, n) {
2220
+ function It(e, t, n) {
1968
2221
  let r = e.columnCount, i = Array.from({ length: r }, () => 0), a = Array.from({ length: r }, () => 0), o = Array.from({ length: r }, () => void 0);
1969
2222
  for (let t = 0; t < r; t++) e.colFixed[t] !== void 0 && (a[t] = e.colFixed[t]), o[t] = e.colPercent[t];
1970
2223
  let s = [];
@@ -1973,15 +2226,15 @@ function mt(e, t, n) {
1973
2226
  s.push(t);
1974
2227
  continue;
1975
2228
  }
1976
- i[t.col] = Math.max(i[t.col], ft(t.node, "min", n)), a[t.col] = Math.max(a[t.col], ft(t.node, "max", n));
1977
- let e = pt(t.node);
2229
+ i[t.col] = Math.max(i[t.col], Pt(t.node, "min", n)), a[t.col] = Math.max(a[t.col], Pt(t.node, "max", n));
2230
+ let e = Ft(t.node);
1978
2231
  e !== void 0 && (o[t.col] = Math.max(o[t.col] ?? 0, e));
1979
2232
  }
1980
2233
  s.sort((e, t) => e.colSpan - t.colSpan);
1981
2234
  for (let e of s) {
1982
- let r = e.col, o = e.col + e.colSpan, s = xt(t, r, o), c = a.slice(r, o);
2235
+ let r = e.col, o = e.col + e.colSpan, s = Ut(t, r, o), c = a.slice(r, o);
1983
2236
  for (let t of ["min", "max"]) {
1984
- let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = ft(e.node, t, n) - u;
2237
+ let l = t === "min" ? i : a, u = l.slice(r, o).reduce((e, t) => e + t, 0) + s, d = Pt(e.node, t, n) - u;
1985
2238
  if (d <= 0) continue;
1986
2239
  let f = I(c.some((e) => e > 0) ? c : c.map(() => 1), d);
1987
2240
  for (let e = r; e < o; e++) l[e] += f[e - r];
@@ -1994,7 +2247,7 @@ function mt(e, t, n) {
1994
2247
  percent: o
1995
2248
  };
1996
2249
  }
1997
- function ht(e, t) {
2250
+ function Lt(e, t) {
1998
2251
  let n = e.min.length, r = e.min.slice(), i = [], a = [];
1999
2252
  for (let t = 0; t < n; t++) (e.percent[t] === void 0 ? a : i).push(t);
2000
2253
  if (i.length > 0) {
@@ -2023,7 +2276,7 @@ function ht(e, t) {
2023
2276
  }
2024
2277
  return r;
2025
2278
  }
2026
- function gt(e, t, n) {
2279
+ function Rt(e, t, n) {
2027
2280
  let r = e.columnCount, i = Array.from({ length: r }, () => void 0);
2028
2281
  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];
2029
2282
  for (let r of e.cells) {
@@ -2043,13 +2296,13 @@ function gt(e, t, n) {
2043
2296
  }
2044
2297
  return i.map((e) => e ?? 0);
2045
2298
  }
2046
- var _t = {
2299
+ var zt = {
2047
2300
  double: 3,
2048
2301
  solid: 2,
2049
2302
  dashed: 1,
2050
2303
  dotted: 0
2051
2304
  };
2052
- function vt(e) {
2305
+ function Bt(e) {
2053
2306
  for (let { border: t, side: n } of e) if (t?.hidden[n]) return null;
2054
2307
  let t = null;
2055
2308
  for (let { border: n, side: r } of e) {
@@ -2057,7 +2310,7 @@ function vt(e) {
2057
2310
  let e = n.width[r];
2058
2311
  if (e <= 0) continue;
2059
2312
  let i = n.style[r];
2060
- (t === null || e > t.width || e === t.width && _t[i] > _t[t.style]) && (t = {
2313
+ (t === null || e > t.width || e === t.width && zt[i] > zt[t.style]) && (t = {
2061
2314
  width: e,
2062
2315
  style: i,
2063
2316
  color: n.color[r]
@@ -2065,7 +2318,7 @@ function vt(e) {
2065
2318
  }
2066
2319
  return t;
2067
2320
  }
2068
- function yt(e, t) {
2321
+ function Vt(e, t) {
2069
2322
  let n = t.columnCount, r = t.rows.length, i = e.style.borderCollapse, a = {
2070
2323
  collapsed: i,
2071
2324
  vLines: Array.from({ length: n + 1 }, () => 0),
@@ -2110,7 +2363,7 @@ function yt(e, t) {
2110
2363
  side: u
2111
2364
  });
2112
2365
  }
2113
- i.push(vt(l));
2366
+ i.push(Bt(l));
2114
2367
  }
2115
2368
  a.vSegments.push(i), a.vLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2116
2369
  }
@@ -2149,47 +2402,47 @@ function yt(e, t) {
2149
2402
  }), e === r && l.push({
2150
2403
  border: s,
2151
2404
  side: "bottom"
2152
- }), i.push(vt(l));
2405
+ }), i.push(Bt(l));
2153
2406
  }
2154
2407
  a.hSegments.push(i), a.hLines[e] = i.reduce((e, t) => Math.max(e, t?.width ?? 0), 0);
2155
2408
  }
2156
2409
  return a;
2157
2410
  }
2158
- function bt(e, t) {
2411
+ function Ht(e, t) {
2159
2412
  return e.collapsed ? e.vLines.reduce((e, t) => e + t, 0) : (t + 1) * e.spacingX;
2160
2413
  }
2161
- function xt(e, t, n) {
2414
+ function Ut(e, t, n) {
2162
2415
  if (!e.collapsed) return e.spacingX * (n - t - 1);
2163
2416
  let r = 0;
2164
2417
  for (let i = t + 1; i < n; i++) r += e.vLines[i];
2165
2418
  return r;
2166
2419
  }
2167
- function St(e, t, n) {
2420
+ function Wt(e, t, n) {
2168
2421
  if (!e.collapsed) return e.spacingY * (n - t - 1);
2169
2422
  let r = 0;
2170
2423
  for (let i = t + 1; i < n; i++) r += e.hLines[i];
2171
2424
  return r;
2172
2425
  }
2173
- function Ct(e, t) {
2426
+ function Gt(e, t) {
2174
2427
  let n = t.tableData.get(e);
2175
2428
  if (n) return n;
2176
- let r = ut(e, t), i = yt(e, r), a = {
2429
+ let r = Mt(e, t), i = Vt(e, r), a = {
2177
2430
  structure: r,
2178
2431
  chrome: i,
2179
- bounds: mt(r, i, t),
2180
- chromeX: bt(i, r.columnCount)
2432
+ bounds: It(r, i, t),
2433
+ chromeX: Ht(i, r.columnCount)
2181
2434
  };
2182
2435
  return t.tableData.set(e, a), a;
2183
2436
  }
2184
- function wt(e, t) {
2185
- let { structure: n, bounds: r, chromeX: i } = Ct(e, t), a = r.min.reduce((e, t) => e + t, 0) + i, o = r.max.reduce((e, t) => e + t, 0) + i;
2437
+ function Kt(e, t) {
2438
+ let { structure: n, bounds: r, chromeX: i } = Gt(e, t), a = r.min.reduce((e, t) => e + t, 0) + i, o = r.max.reduce((e, t) => e + t, 0) + i;
2186
2439
  return n.caption && (a = Math.max(a, Y(n.caption, t)), o = Math.max(o, J(n.caption, t))), {
2187
2440
  min: a,
2188
2441
  max: o
2189
2442
  };
2190
2443
  }
2191
- function Tt(e, t, n) {
2192
- let r = e.style, { bounds: i, chromeX: a } = Ct(e, n), { min: o, max: s } = wt(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;
2444
+ function qt(e, t, n) {
2445
+ let r = e.style, { bounds: i, chromeX: a } = Gt(e, n), { min: o, max: s } = Kt(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;
2193
2446
  for (let e = 0; e < i.max.length; e++) {
2194
2447
  let t = i.percent[e];
2195
2448
  t === void 0 ? d += i.max[e] : u += t;
@@ -2205,8 +2458,8 @@ function Tt(e, t, n) {
2205
2458
  let f = Math.max(l + a, s) + c;
2206
2459
  return Math.max(o + c, Math.min(f, t));
2207
2460
  }
2208
- function Et(e, t, n, r, i, a) {
2209
- let { structure: o, chrome: s, bounds: c } = Ct(e, a), l = o.columnCount, u = o.rows.length, d = r.left + i.left, f = r.top + i.top;
2461
+ function Jt(e, t, n, r, i, a) {
2462
+ let { structure: o, chrome: s, bounds: c } = Gt(e, a), l = o.columnCount, u = o.rows.length, d = r.left + i.left, f = r.top + i.top;
2210
2463
  for (let e of o.hidden) e.tableHidden = !0, e.localRect = {
2211
2464
  x: 0,
2212
2465
  y: 0,
@@ -2218,56 +2471,56 @@ function Et(e, t, n, r, i, a) {
2218
2471
  bottom: 0,
2219
2472
  left: 0
2220
2473
  }, e.unclampedHeight = 0;
2221
- let p = Math.max(0, t - bt(s, l)), h = e.style, g = h.tableLayout === "fixed" && h.width !== void 0 && h.width.kind !== "auto" ? gt(o, p, a) : ht(c, p), _ = [], v = 0;
2222
- for (let e = 0; e < l; e++) v += s.collapsed ? s.vLines[e] : s.spacingX, _.push(v), v += g[e];
2223
- let y = v + (s.collapsed ? s.vLines[l] ?? 0 : s.spacingX), b = 0;
2224
- o.caption && (V(o.caption, t, void 0, d, f, "fill", a), b = o.caption.localRect.height);
2225
- let x = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map();
2474
+ let p = Math.max(0, t - Ht(s, l)), m = e.style, h = m.tableLayout === "fixed" && m.width !== void 0 && m.width.kind !== "auto" ? Rt(o, p, a) : Lt(c, p), g = [], _ = 0;
2475
+ for (let e = 0; e < l; e++) _ += s.collapsed ? s.vLines[e] : s.spacingX, g.push(_), _ += h[e];
2476
+ let v = _ + (s.collapsed ? s.vLines[l] ?? 0 : s.spacingX), y = 0;
2477
+ o.caption && (V(o.caption, t, void 0, d, f, "fill", a), y = o.caption.localRect.height);
2478
+ let b = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
2226
2479
  for (let e of o.cells) {
2227
- let t = e.col + e.colSpan, n = g.slice(e.col, t).reduce((e, t) => e + t, 0) + xt(s, e.col, t);
2228
- S.set(e, n), V(e.node, n, void 0, 0, 0, "fill", a, { width: n }), x.set(e, e.node.localRect.height);
2480
+ let t = e.col + e.colSpan, n = h.slice(e.col, t).reduce((e, t) => e + t, 0) + Ut(s, e.col, t);
2481
+ x.set(e, n), V(e.node, n, void 0, 0, 0, "fill", a, { width: n }), b.set(e, e.node.localRect.height);
2229
2482
  }
2230
- 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 - b - C), T = (e) => e !== void 0 && e.kind === "percent" && w !== void 0 ? m(e.value, w) : 0, E = Array.from({ length: u }, () => 0), D = Array.from({ length: u }, () => !1);
2483
+ 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 ? N(e.value, C) : 0, T = Array.from({ length: u }, () => 0), E = Array.from({ length: u }, () => !1);
2231
2484
  for (let e = 0; e < u; e++) {
2232
2485
  let t = o.rows[e].style.height;
2233
- t !== void 0 && t.kind === "cells" && (E[e] = t.value);
2234
- let n = T(t);
2235
- n > 0 && (E[e] = Math.max(E[e], n), D[e] = !0);
2486
+ t !== void 0 && t.kind === "cells" && (T[e] = t.value);
2487
+ let n = w(t);
2488
+ n > 0 && (T[e] = Math.max(T[e], n), E[e] = !0);
2236
2489
  }
2237
2490
  for (let e of o.cells) if (e.rowSpan === 1) {
2238
- let t = T(e.node.style.height);
2239
- t > 0 && (D[e.row] = !0), E[e.row] = Math.max(E[e.row], x.get(e), t);
2491
+ let t = w(e.node.style.height);
2492
+ t > 0 && (E[e.row] = !0), T[e.row] = Math.max(T[e.row], b.get(e), t);
2240
2493
  }
2241
- let O = o.cells.filter((e) => e.rowSpan > 1).sort((e, t) => e.rowSpan - t.rowSpan);
2242
- for (let e of O) {
2243
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + St(s, e.row, t), r = x.get(e) - n;
2494
+ let D = o.cells.filter((e) => e.rowSpan > 1).sort((e, t) => e.rowSpan - t.rowSpan);
2495
+ for (let e of D) {
2496
+ let t = e.row + e.rowSpan, n = T.slice(e.row, t).reduce((e, t) => e + t, 0) + Wt(s, e.row, t), r = b.get(e) - n;
2244
2497
  if (r <= 0) continue;
2245
2498
  let i = I(Array.from({ length: e.rowSpan }, () => 1), r);
2246
- for (let n = e.row; n < t; n++) E[n] += i[n - e.row];
2499
+ for (let n = e.row; n < t; n++) T[n] += i[n - e.row];
2247
2500
  }
2248
2501
  if (n !== void 0 && u > 0) {
2249
- let e = n - b - C - E.reduce((e, t) => e + t, 0);
2502
+ let e = n - y - S - T.reduce((e, t) => e + t, 0);
2250
2503
  if (e > 0) {
2251
2504
  let t = [];
2252
- for (let e = 0; e < u; e++) D[e] || t.push(e);
2505
+ for (let e = 0; e < u; e++) E[e] || t.push(e);
2253
2506
  let n = t.length > 0 ? t : Array.from({ length: u }, (e, t) => t), r = I(n.map(() => 1), e);
2254
- n.forEach((e, t) => E[e] += r[t]);
2507
+ n.forEach((e, t) => T[e] += r[t]);
2255
2508
  }
2256
2509
  }
2257
- let k = o.caption && e.style.captionSide === "top" ? b : 0, A = [], j = k;
2258
- for (let e = 0; e < u; e++) j += s.collapsed ? s.hLines[e] : s.spacingY, A.push(j), j += E[e];
2259
- let M = u > 0 ? j + (s.collapsed ? s.hLines[u] ?? 0 : s.spacingY) : k, N = /* @__PURE__ */ new Map();
2510
+ let ee = o.caption && e.style.captionSide === "top" ? y : 0, O = [], k = ee;
2511
+ for (let e = 0; e < u; e++) k += s.collapsed ? s.hLines[e] : s.spacingY, O.push(k), k += T[e];
2512
+ let A = u > 0 ? k + (s.collapsed ? s.hLines[u] ?? 0 : s.spacingY) : ee, j = /* @__PURE__ */ new Map();
2260
2513
  for (let e = 0; e < u; e++) {
2261
2514
  let t = o.rowGroups[e];
2262
- t && !N.has(t) && N.set(t, A[e]);
2515
+ t && !j.has(t) && j.set(t, O[e]);
2263
2516
  }
2264
- for (let [e, t] of N) {
2517
+ for (let [e, t] of j) {
2265
2518
  let n = t;
2266
- for (let t = 0; t < u; t++) o.rowGroups[t] === e && (n = A[t] + E[t]);
2519
+ for (let t = 0; t < u; t++) o.rowGroups[t] === e && (n = O[t] + T[t]);
2267
2520
  e.localRect = {
2268
2521
  x: d,
2269
2522
  y: f + t,
2270
- width: y,
2523
+ width: v,
2271
2524
  height: n - t
2272
2525
  }, e.resolvedPadding = {
2273
2526
  top: 0,
@@ -2277,26 +2530,26 @@ function Et(e, t, n, r, i, a) {
2277
2530
  }, e.unclampedHeight = n - t;
2278
2531
  }
2279
2532
  for (let e = 0; e < u; e++) {
2280
- let t = o.rows[e], n = o.rowGroups[e], r = n ? N.get(n) : void 0;
2533
+ let t = o.rows[e], n = o.rowGroups[e], r = n ? j.get(n) : void 0;
2281
2534
  t.localRect = {
2282
2535
  x: r === void 0 ? d : 0,
2283
- y: r === void 0 ? f + A[e] : A[e] - r,
2284
- width: y,
2285
- height: E[e]
2536
+ y: r === void 0 ? f + O[e] : O[e] - r,
2537
+ width: v,
2538
+ height: T[e]
2286
2539
  }, t.resolvedPadding = {
2287
2540
  top: 0,
2288
2541
  right: 0,
2289
2542
  bottom: 0,
2290
2543
  left: 0
2291
- }, t.unclampedHeight = E[e];
2544
+ }, t.unclampedHeight = T[e];
2292
2545
  }
2293
2546
  for (let e of o.cells) {
2294
- let t = e.row + e.rowSpan, n = E.slice(e.row, t).reduce((e, t) => e + t, 0) + St(s, e.row, t);
2295
- e.node.children.some((e) => !B(e.style) && e.style.height?.kind === "percent") && n !== x.get(e) && V(e.node, S.get(e), n, 0, 0, "fill", a, {
2296
- width: S.get(e),
2547
+ let t = e.row + e.rowSpan, n = T.slice(e.row, t).reduce((e, t) => e + t, 0) + Wt(s, e.row, t);
2548
+ 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, {
2549
+ width: x.get(e),
2297
2550
  height: n
2298
- }), Dt(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2299
- x: _[e.col],
2551
+ }), Yt(e.node, n - (e.node.naturalContentHeight ?? e.node.localRect.height)), e.node.localRect = {
2552
+ x: g[e.col],
2300
2553
  y: 0,
2301
2554
  width: e.node.localRect.width,
2302
2555
  height: n
@@ -2307,9 +2560,9 @@ function Et(e, t, n, r, i, a) {
2307
2560
  x: d,
2308
2561
  y: f
2309
2562
  });
2310
- return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + M), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = Ot(s, o, g, E, _, A, d, f)), e.style.captionSide === "bottom" ? M + b : M;
2563
+ return o.caption && e.style.captionSide === "bottom" && (o.caption.localRect.y = f + A), s.collapsed && l > 0 && u > 0 && (e.decorationRuns = Xt(s, o, h, T, g, O, d, f)), e.style.captionSide === "bottom" ? A + y : A;
2311
2564
  }
2312
- function Dt(e, t) {
2565
+ function Yt(e, t) {
2313
2566
  if (t <= 0) return;
2314
2567
  let n = e.style.verticalAlign, r = n === "center" ? Math.floor(t / 2) : n === "end" ? t : 0;
2315
2568
  if (!e.children.some((e) => !B(e.style) && !e.inlineBox)) {
@@ -2318,84 +2571,84 @@ function Dt(e, t) {
2318
2571
  }
2319
2572
  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);
2320
2573
  }
2321
- function Ot(e, t, n, r, o, s, c, l) {
2322
- let u = t.columnCount, d = t.rows.length, f = [], p = (t) => t < u ? o[t] - e.vLines[t] : o[u - 1] + n[u - 1], m = (t) => t < d ? s[t] - e.hLines[t] : s[d - 1] + r[d - 1];
2323
- for (let t = 0; t <= u; t++) {
2574
+ function Xt(e, t, n, r, i, a, o, s) {
2575
+ 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];
2576
+ for (let t = 0; t <= c; t++) {
2324
2577
  let n = e.vSegments[t];
2325
- for (let e = 0; e < d; e++) {
2326
- let a = n[e];
2327
- if (!a) continue;
2328
- let o = i(a.style, "v");
2329
- for (let n = 0; n < a.width; n++) for (let i = s[e]; i < s[e] + r[e]; i++) f.push({
2330
- glyph: o,
2331
- x: c + p(t) + n,
2332
- y: l + i,
2578
+ for (let e = 0; e < l; e++) {
2579
+ let i = n[e];
2580
+ if (!i) continue;
2581
+ let c = C(i.style, "v");
2582
+ for (let n = 0; n < i.width; n++) for (let l = a[e]; l < a[e] + r[e]; l++) u.push({
2583
+ glyph: c,
2584
+ x: o + d(t) + n,
2585
+ y: s + l,
2333
2586
  length: 1,
2334
- color: a.color
2587
+ color: i.color
2335
2588
  });
2336
2589
  }
2337
2590
  }
2338
- for (let t = 0; t <= d; t++) {
2591
+ for (let t = 0; t <= l; t++) {
2339
2592
  let r = e.hSegments[t];
2340
- for (let e = 0; e < u; e++) {
2593
+ for (let e = 0; e < c; e++) {
2341
2594
  let a = r[e];
2342
2595
  if (!a) continue;
2343
- let s = i(a.style, "h");
2344
- for (let r = 0; r < a.width; r++) f.push({
2345
- glyph: s,
2346
- x: c + o[e],
2347
- y: l + m(t) + r,
2596
+ let c = C(a.style, "h");
2597
+ for (let r = 0; r < a.width; r++) u.push({
2598
+ glyph: c,
2599
+ x: o + i[e],
2600
+ y: s + f(t) + r,
2348
2601
  length: n[e],
2349
2602
  color: a.color
2350
2603
  });
2351
2604
  }
2352
2605
  }
2353
- for (let t = 0; t <= u; t++) if (!(e.vLines[t] <= 0)) for (let n = 0; n <= d; n++) {
2606
+ for (let t = 0; t <= c; t++) if (!(e.vLines[t] <= 0)) for (let n = 0; n <= l; n++) {
2354
2607
  if (e.hLines[n] <= 0) continue;
2355
- let r = n > 0 ? e.vSegments[t][n - 1] : null, i = n < d ? e.vSegments[t][n] : null, o = t > 0 ? e.hSegments[n][t - 1] : null, s = t < u ? e.hSegments[n][t] : null, h = [
2608
+ 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 = [
2356
2609
  r,
2357
2610
  i,
2358
- o,
2359
- s
2611
+ a,
2612
+ p
2360
2613
  ].filter((e) => e !== null);
2361
- if (h.length === 0) continue;
2362
- let g = h.every((e) => e.style === "double") ? "double" : "solid", _ = h.reduce((e, t) => t.width > e.width || t.width === e.width && _t[t.style] > _t[e.style] ? t : e), v = a(g, r !== null, i !== null, o !== null, s !== null);
2363
- for (let r = 0; r < e.vLines[t]; r++) for (let i = 0; i < e.hLines[n]; i++) f.push({
2364
- glyph: v,
2365
- x: c + p(t) + r,
2366
- y: l + m(n) + i,
2614
+ if (m.length === 0) continue;
2615
+ let h = m.every((e) => e.style === "double") ? "double" : "solid", g = m.reduce((e, t) => t.width > e.width || t.width === e.width && zt[t.style] > zt[e.style] ? t : e), _ = w(h, r !== null, i !== null, a !== null, p !== null);
2616
+ for (let r = 0; r < e.vLines[t]; r++) for (let i = 0; i < e.hLines[n]; i++) u.push({
2617
+ glyph: _,
2618
+ x: o + d(t) + r,
2619
+ y: s + f(n) + i,
2367
2620
  length: 1,
2368
- color: _.color
2621
+ color: g.color
2369
2622
  });
2370
2623
  }
2371
- return f;
2624
+ return u;
2372
2625
  }
2373
2626
  //#endregion
2374
2627
  //#region src/positioning.ts
2375
- function kt(e) {
2628
+ function Zt(e) {
2376
2629
  return e.position === "absolute" || e.position === "fixed" ? "absolute" : e.position === "relative" || e.position === "sticky" ? "relative" : "static";
2377
2630
  }
2378
- function At(e, t, n, r, i) {
2631
+ function Qt(e, t, n, r, i) {
2379
2632
  for (let a of e.children) {
2380
- let o = kt(a.style);
2633
+ let o = Zt(a.style);
2381
2634
  if (o === "relative") {
2382
2635
  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;
2383
- a.localRect.x += jt(a.style.insets.left, a.style.insets.right, t), a.localRect.y += jt(a.style.insets.top, a.style.insets.bottom, n);
2384
- } else o === "absolute" && Nt(a, e, t, n, r, i);
2385
- At(a, t + a.localRect.x, n + a.localRect.y, [...r, {
2636
+ a.localRect.x += $t(a.style.insets.left, a.style.insets.right, t), a.localRect.y += $t(a.style.insets.top, a.style.insets.bottom, n);
2637
+ } else o === "absolute" && tn(a, e, t, n, r, i);
2638
+ Qt(a, t + a.localRect.x, n + a.localRect.y, [...r, {
2386
2639
  node: a,
2387
2640
  absX: t + a.localRect.x,
2388
2641
  absY: n + a.localRect.y
2389
2642
  }], i);
2390
2643
  }
2391
2644
  }
2392
- function jt(e, t, n) {
2645
+ function $t(e, t, n) {
2393
2646
  return e === null ? t === null ? 0 : -W(t, n) : W(e, n);
2394
2647
  }
2395
- function Mt(e, t) {
2648
+ function en(e, t) {
2396
2649
  if (!t) for (let t = e.length - 1; t > 0; t--) {
2397
2650
  let n = e[t];
2398
- if (!Vt(n.node.style)) continue;
2651
+ if (!un(n.node.style)) continue;
2399
2652
  let r = n.node.style.border;
2400
2653
  return {
2401
2654
  x: n.absX + r.left,
@@ -2412,13 +2665,13 @@ function Mt(e, t) {
2412
2665
  height: n.node.localRect.height
2413
2666
  };
2414
2667
  }
2415
- function Nt(e, t, n, r, i, a) {
2416
- let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && Vt(t.style) ? {
2668
+ function tn(e, t, n, r, i, a) {
2669
+ let o = e.style, s = o.position === "fixed", c = e.staticSlot, l = c?.kind === "grid" && !s && un(t.style) ? {
2417
2670
  x: n + c.area.x,
2418
2671
  y: r + c.area.y,
2419
2672
  width: c.area.width,
2420
2673
  height: c.area.height
2421
- } : Mt(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 = Xt(o.minWidth, l.width, e, a) ?? 0, S = Xt(o.maxWidth, l.width, e, a), C = {};
2674
+ } : en(i, s), u = o.insets.left === null ? null : W(o.insets.left, l.width), d = o.insets.right === null ? null : W(o.insets.right, l.width), f = o.insets.top === null ? null : W(o.insets.top, l.height), p = o.insets.bottom === null ? null : W(o.insets.bottom, l.height), m = G(o.margin, l.width), h = m.left ?? 0, g = m.right ?? 0, _ = m.top ?? 0, v = m.bottom ?? 0, y = o.width === void 0 || o.width.kind === "auto", b = o.height === void 0 || o.height.kind === "auto", x = yn(o.minWidth, l.width, e, a) ?? 0, S = yn(o.maxWidth, l.width, e, a), C = {};
2422
2675
  if (!y) C.width = H(q(o.width, l.width, e, a), x, S);
2423
2676
  else if (u !== null && d !== null) C.width = H(Math.max(0, l.width - u - d - h - g), x, S);
2424
2677
  else {
@@ -2430,25 +2683,25 @@ function Nt(e, t, n, r, i, a) {
2430
2683
  if (u !== null && d !== null) {
2431
2684
  let e = Math.max(0, l.width - u - d - w - h - g), t = m.left === null && m.right === null;
2432
2685
  E = l.x + u + h + (t ? Math.floor(e / 2) : m.left === null ? e : 0);
2433
- } else E = u === null ? d === null ? Rt(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2686
+ } else E = u === null ? d === null ? sn(e, t, n, w) : l.x + l.width - d - w - g : l.x + u + h;
2434
2687
  let D;
2435
2688
  if (f !== null && p !== null) {
2436
2689
  let e = Math.max(0, l.height - f - p - T - _ - v), t = m.top === null && m.bottom === null;
2437
2690
  D = l.y + f + _ + (t ? Math.floor(e / 2) : m.top === null ? e : 0);
2438
- } else D = f === null ? p === null ? zt(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2691
+ } else D = f === null ? p === null ? cn(e, t, r, T) : l.y + l.height - p - T - v : l.y + f + _;
2439
2692
  e.localRect = {
2440
2693
  ...e.localRect,
2441
2694
  x: E - n,
2442
2695
  y: D - r
2443
2696
  };
2444
2697
  }
2445
- function Pt(e, t, n) {
2698
+ function nn(e, t, n) {
2446
2699
  return F(e, [n], Math.max(0, t - n))[0];
2447
2700
  }
2448
- function Ft(e, t, n, r) {
2449
- return L(ae(e, t), n, r);
2701
+ function rn(e, t, n, r) {
2702
+ return L(Te(e, t), n, r);
2450
2703
  }
2451
- function It(e, t, n, r, i) {
2704
+ function an(e, t, n, r, i) {
2452
2705
  let a = G(e.style.margin, n.innerWidth), [o, s, c, l] = r === "x" ? [
2453
2706
  a.left ?? 0,
2454
2707
  a.right ?? 0,
@@ -2460,9 +2713,9 @@ function It(e, t, n, r, i) {
2460
2713
  n.innerHeight,
2461
2714
  n.direction === "column"
2462
2715
  ], u = i + o + s;
2463
- return (l ? Pt(le(t.style), c, u) : Ft(e, t, c, u)) + o;
2716
+ return (l ? nn(ke(t.style), c, u) : rn(e, t, c, u)) + o;
2464
2717
  }
2465
- function Lt(e, t, n, r, i) {
2718
+ function on(e, t, n, r, i) {
2466
2719
  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" ? [
2467
2720
  a.left ?? 0,
2468
2721
  a.right ?? 0,
@@ -2472,23 +2725,23 @@ function Lt(e, t, n, r, i) {
2472
2725
  a.top ?? 0,
2473
2726
  a.bottom ?? 0,
2474
2727
  n.height,
2475
- ae(e, t)
2728
+ Te(e, t)
2476
2729
  ];
2477
2730
  return L(u, l, i + s + c) + s;
2478
2731
  }
2479
- function Rt(e, t, n, r) {
2732
+ function sn(e, t, n, r) {
2480
2733
  let i = e.staticSlot;
2481
- return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + Lt(e, t, i.staticArea, "x", r) : n + i.originX + It(e, t, i, "x", r);
2734
+ return i === void 0 ? n : i.kind === "block" ? n + i.x : i.kind === "grid" ? n + i.staticArea.x + on(e, t, i.staticArea, "x", r) : n + i.originX + an(e, t, i, "x", r);
2482
2735
  }
2483
- function zt(e, t, n, r) {
2736
+ function cn(e, t, n, r) {
2484
2737
  let i = e.staticSlot;
2485
- return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + Lt(e, t, i.staticArea, "y", r) : n + i.originY + It(e, t, i, "y", r);
2738
+ return i === void 0 ? n : i.kind === "block" ? n + i.y : i.kind === "grid" ? n + i.staticArea.y + on(e, t, i.staticArea, "y", r) : n + i.originY + an(e, t, i, "y", r);
2486
2739
  }
2487
2740
  //#endregion
2488
2741
  //#region src/layout.ts
2489
- function Bt(e, t) {
2490
- let n = Ht();
2491
- return V(e, t, void 0, 0, 0, "fill", n), At(e, 0, 0, [{
2742
+ function ln(e, t) {
2743
+ let n = dn();
2744
+ return V(e, t, void 0, 0, 0, "fill", n), Qt(e, 0, 0, [{
2492
2745
  node: e,
2493
2746
  absX: 0,
2494
2747
  absY: 0
@@ -2497,10 +2750,10 @@ function Bt(e, t) {
2497
2750
  function B(e) {
2498
2751
  return e.position === "absolute" || e.position === "fixed";
2499
2752
  }
2500
- function Vt(e) {
2753
+ function un(e) {
2501
2754
  return e.position !== "static";
2502
2755
  }
2503
- function Ht() {
2756
+ function dn() {
2504
2757
  return {
2505
2758
  maxContent: /* @__PURE__ */ new WeakMap(),
2506
2759
  minContent: /* @__PURE__ */ new WeakMap(),
@@ -2511,21 +2764,21 @@ function Ht() {
2511
2764
  function V(e, t, n, r, i, a, o, s) {
2512
2765
  let c = e.style, l = s?.height;
2513
2766
  delete e.decorationRuns, delete e.multicolGeometry, delete e.multicolFlow, delete e.multicolFlowSpan;
2514
- let u = Xt(c.minWidth, t, e, o) ?? 0, d = Xt(c.maxWidth, t, e, o), f = K(c.minHeight, n) ?? 0, p = K(c.maxHeight, n), m = {
2767
+ let u = yn(c.minWidth, t, e, o) ?? 0, d = yn(c.maxWidth, t, e, o), f = K(c.minHeight, n) ?? 0, p = K(c.maxHeight, n), m = {
2515
2768
  top: W(c.padding.top, t),
2516
2769
  right: W(c.padding.right, t),
2517
2770
  bottom: W(c.padding.bottom, t),
2518
2771
  left: W(c.padding.left, t)
2519
2772
  };
2520
2773
  e.resolvedPadding = m;
2521
- let h = s?.width ?? H(en(c, t, a, e, o), u, d), g = nn(c, n), _ = on(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;
2522
- x = Wt(e) ? Ut(e, _.width, _.height, y, b, m, o) : c.display === "flex" && c.flexDirection === "row" ? P(e, _.width, _.height, y, c.border, m, o) : c.display === "flex" && c.flexDirection === "column" ? te(e, _.width, _.height, v, c.border, m, o) : c.display === "grid" ? pe(e, _.width, _.height, c.border, m, o) : c.display === "table" ? Et(e, _.width, y, c.border, m, o) : c.display === "multicol" ? rt(e, _.width, y, b, c.border, m, o) : Zt(e, _.width, y, c.border, m, o);
2774
+ let h = s?.width ?? H(Cn(c, t, a, e, o), u, d), g = Tn(c, n), _ = On(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;
2775
+ x = pn(e) ? fn(e, _.width, _.height, y, b, m, o) : c.display === "flex" && c.flexDirection === "row" ? ye(e, _.width, _.height, y, c.border, m, o) : c.display === "flex" && c.flexDirection === "column" ? xe(e, _.width, _.height, v, c.border, m, o) : c.display === "grid" ? Ne(e, _.width, _.height, c.border, m, o) : c.display === "table" ? Jt(e, _.width, y, c.border, m, o) : c.display === "multicol" ? Tt(e, _.width, y, b, c.border, m, o) : bn(e, _.width, y, c.border, m, o);
2523
2776
  let S = x + c.border.top + c.border.bottom + m.top + m.bottom, C = l ?? g ?? S;
2524
2777
  e.unclampedHeight = C, e.naturalContentHeight = S;
2525
2778
  let w = H(C, f, p), T = e.multicolGeometry;
2526
2779
  if (T) {
2527
2780
  let t = w - c.border.top - c.border.bottom - m.top - m.bottom;
2528
- t > T.totalRows && (m.bottom += t - T.totalRows), et(e, T, c.border, m);
2781
+ t > T.totalRows && (m.bottom += t - T.totalRows), St(e, T, c.border, m);
2529
2782
  }
2530
2783
  e.localRect = {
2531
2784
  x: r,
@@ -2534,30 +2787,30 @@ function V(e, t, n, r, i, a, o, s) {
2534
2787
  height: w
2535
2788
  };
2536
2789
  }
2537
- function Ut(e, t, n, r, i, a, o) {
2790
+ function fn(e, t, n, r, i, a, o) {
2538
2791
  let s = e.style, c;
2539
2792
  if (e.text) {
2540
2793
  let l = e.children.filter((e) => e.inlineBox);
2541
- E(e.text, (n, r) => {
2794
+ de(e.text, (n, r) => {
2542
2795
  let i = l[r];
2543
2796
  V(i, t, void 0, 0, 0, "shrink", o), e.advances[n] = Math.max(1, i.localRect.width);
2544
2797
  });
2545
2798
  let u, d;
2546
2799
  if (s.display === "multicol") {
2547
- let n = U(s, "x", t), o = Ye(s, t, n);
2800
+ let n = U(s, "x", t), o = ht(s, t, n);
2548
2801
  a.right += o.leftover;
2549
- let c = Ze(e, o, n, qe(r, i));
2802
+ let c = _t(e, o, n, pt(r, i));
2550
2803
  e.multicolGeometry = c, u = c, d = c.lineX;
2551
- } else u = Kt(e, t);
2552
- if (c = u.totalRows, Gt(e, u, t, n, a), l.length > 0) {
2804
+ } else u = hn(e, t);
2805
+ if (c = u.totalRows, mn(e, u, t, n, a), l.length > 0) {
2553
2806
  let t = (e) => u.spans.findIndex((t) => e >= t.start && e < t.end);
2554
- E(e.text, (n, r) => {
2807
+ de(e.text, (n, r) => {
2555
2808
  let i = t(n);
2556
2809
  if (i === -1) return;
2557
2810
  let o = u.spans[i];
2558
2811
  l[r].localRect = {
2559
2812
  ...l[r].localRect,
2560
- x: s.border.left + a.left + (d?.[i] ?? 0) + S(o.start, n, e.advances),
2813
+ x: s.border.left + a.left + (d?.[i] ?? 0) + ce(o.start, n, e.advances),
2561
2814
  y: s.border.top + a.top + u.lineY[i]
2562
2815
  };
2563
2816
  });
@@ -2574,30 +2827,30 @@ function Ut(e, t, n, r, i, a, o) {
2574
2827
  }
2575
2828
  return c;
2576
2829
  }
2577
- function Wt(e) {
2830
+ function pn(e) {
2578
2831
  return e.children.some((e) => !B(e.style) && !e.inlineBox) ? !1 : e.text !== "" || e.style.display !== "flex" && e.style.display !== "grid";
2579
2832
  }
2580
2833
  function H(e, t, n) {
2581
2834
  return Math.max(t, n === void 0 ? e : Math.min(e, n));
2582
2835
  }
2583
- function Gt(e, t, n, r, i) {
2836
+ function mn(e, t, n, r, i) {
2584
2837
  let a = e.style;
2585
2838
  if (a.display !== "flex" && a.display !== "grid" || t.spans.length === 0) return;
2586
- let o = a.display === "flex" && a.flexDirection === "column", s = t.spans.reduce((t, n) => Math.max(t, C(n.start, n.end, e.advances, a.tracking)), 0), c = Math.max(0, n - s);
2839
+ 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);
2587
2840
  if (c > 0) {
2588
- let e = a.display === "grid" ? L(a.justifyItems, n, s) : o ? L(a.alignItems, n, s) : F(le(a), [s], c)[0];
2841
+ let e = a.display === "grid" ? L(a.justifyItems, n, s) : o ? L(a.alignItems, n, s) : F(ke(a), [s], c)[0];
2589
2842
  e > 0 && (i.left += e, i.right += c - e);
2590
2843
  }
2591
2844
  if (Number.isFinite(r)) {
2592
2845
  let e = Math.max(0, r - t.totalRows);
2593
2846
  if (e > 0) {
2594
- let n = a.display === "grid" || !o ? L(a.alignItems, r, t.totalRows) : F(le(a), [t.totalRows], e)[0];
2847
+ let n = a.display === "grid" || !o ? L(a.alignItems, r, t.totalRows) : F(ke(a), [t.totalRows], e)[0];
2595
2848
  n > 0 && (i.top += n, i.bottom += e - n);
2596
2849
  }
2597
2850
  }
2598
2851
  }
2599
- function Kt(e, t) {
2600
- let n = qt(e, t), { heights: r, textOffsets: i } = Jt(e, n), a = [], o = [], s = 0;
2852
+ function hn(e, t) {
2853
+ let n = gn(e, t), { heights: r, textOffsets: i } = _n(e, n), a = [], o = [], s = 0;
2601
2854
  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);
2602
2855
  return {
2603
2856
  spans: n,
@@ -2606,21 +2859,21 @@ function Kt(e, t) {
2606
2859
  totalRows: s
2607
2860
  };
2608
2861
  }
2609
- function qt(e, t) {
2610
- return e.style.whiteSpace === "normal" ? x(e.text, t, {
2862
+ function gn(e, t) {
2863
+ return e.style.whiteSpace === "normal" ? se(e.text, t, {
2611
2864
  advances: e.advances,
2612
2865
  tracking: e.style.tracking,
2613
2866
  firstLineIndent: e.style.textIndent
2614
- }) : b(e.text);
2867
+ }) : oe(e.text);
2615
2868
  }
2616
- function Jt(e, t) {
2869
+ function _n(e, t) {
2617
2870
  let n = e.children.filter((e) => e.inlineBox), r = [], i = [], a = 0;
2618
2871
  for (let o of t) {
2619
2872
  let t = 1, s = 0;
2620
2873
  for (let r = o.start; r < o.end; r++) {
2621
2874
  if (e.text[r] !== "") continue;
2622
2875
  let i = n[a];
2623
- t = Math.max(t, i.localRect.height), i.style.verticalAlign === "end" ? s = Math.max(s, i.localRect.height - 1) : i.style.verticalAlign === "center" && at(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++;
2876
+ t = Math.max(t, i.localRect.height), i.style.verticalAlign === "end" ? s = Math.max(s, i.localRect.height - 1) : i.style.verticalAlign === "center" && Dt(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++;
2624
2877
  }
2625
2878
  r.push(t), i.push(Math.min(s, t - 1));
2626
2879
  }
@@ -2634,7 +2887,7 @@ function U(e, t, n) {
2634
2887
  return Math.max(r, i?.width ?? 0);
2635
2888
  }
2636
2889
  function W(e, t) {
2637
- return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : m(e.percent, t);
2890
+ return typeof e == "number" ? e : t === void 0 || !Number.isFinite(t) ? 0 : N(e.percent, t);
2638
2891
  }
2639
2892
  function G(e, t) {
2640
2893
  let n = (e) => e === null ? null : W(e, t);
@@ -2645,16 +2898,16 @@ function G(e, t) {
2645
2898
  left: n(e.left)
2646
2899
  };
2647
2900
  }
2648
- function Yt(e) {
2901
+ function vn(e) {
2649
2902
  return typeof e == "number" ? e : 0;
2650
2903
  }
2651
2904
  function K(e, t) {
2652
- if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : m(e.percent, t);
2905
+ if (e !== void 0 && typeof e != "string") return typeof e == "number" ? e : t === void 0 ? void 0 : N(e.percent, t);
2653
2906
  }
2654
- function Xt(e, t, n, r) {
2907
+ function yn(e, t, n, r) {
2655
2908
  return e === "min-content" || e === "max-content" || e === "fit-content" ? q({ kind: e }, t, n, r) : K(e, t);
2656
2909
  }
2657
- function Zt(e, t, n, r, i, a) {
2910
+ function bn(e, t, n, r, i, a) {
2658
2911
  let o = r.left + i.left, s = r.top + i.top, c = s, l = null;
2659
2912
  for (let r of e.children) {
2660
2913
  let e = G(r.style.margin, t), i = e.top ?? 0, s = e.bottom ?? 0, u = e.left ?? 0, d = e.right ?? 0;
@@ -2662,13 +2915,13 @@ function Zt(e, t, n, r, i, a) {
2662
2915
  r.staticSlot = {
2663
2916
  kind: "block",
2664
2917
  x: o + u,
2665
- y: c + (l === null ? i : $t(l, i))
2918
+ y: c + (l === null ? i : Sn(l, i))
2666
2919
  };
2667
2920
  continue;
2668
2921
  }
2669
2922
  V(r, Math.max(0, t - u - d), n, 0, 0, "fill", a);
2670
- let f = Qt(e, t, r.localRect.width);
2671
- c += l === null ? i : $t(l, i), r.localRect = {
2923
+ let f = xn(e, t, r.localRect.width);
2924
+ c += l === null ? i : Sn(l, i), r.localRect = {
2672
2925
  ...r.localRect,
2673
2926
  x: o + f,
2674
2927
  y: c
@@ -2676,37 +2929,37 @@ function Zt(e, t, n, r, i, a) {
2676
2929
  }
2677
2930
  return l !== null && (c += l), c - s;
2678
2931
  }
2679
- function Qt(e, t, n) {
2932
+ function xn(e, t, n) {
2680
2933
  let r = t - n;
2681
2934
  return e.left === null && e.right === null ? Math.floor(r / 2) : e.left === null ? r - (e.right ?? 0) : e.left;
2682
2935
  }
2683
- function $t(e, t) {
2936
+ function Sn(e, t) {
2684
2937
  return e >= 0 && t >= 0 ? Math.max(e, t) : e <= 0 && t <= 0 ? Math.min(e, t) : e + t;
2685
2938
  }
2686
- function en(e, t, n, r, i) {
2939
+ function Cn(e, t, n, r, i) {
2687
2940
  let a = e.width;
2688
2941
  if (e.display === "table") {
2689
2942
  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));
2690
2943
  if (a !== void 0 && a.kind !== "auto") {
2691
2944
  let e = q(a, t, r, i);
2692
- return Math.max(e, tn(r, t, i));
2945
+ return Math.max(e, wn(r, t, i));
2693
2946
  }
2694
- return Tt(r, t, i);
2947
+ return qt(r, t, i);
2695
2948
  }
2696
2949
  return a !== void 0 && a.kind !== "auto" ? q(a, t, r, i) : n === "shrink" ? Math.min(t, J(r, i)) : t;
2697
2950
  }
2698
- function tn(e, t, n) {
2951
+ function wn(e, t, n) {
2699
2952
  let r = e.style;
2700
- return wt(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t);
2953
+ return Kt(e, n).min + r.border.left + r.border.right + W(r.padding.left, t) + W(r.padding.right, t);
2701
2954
  }
2702
- function nn(e, t) {
2955
+ function Tn(e, t) {
2703
2956
  if (e.height?.kind === "cells") return e.height.value;
2704
- if (e.height?.kind === "percent" && t != null) return m(e.height.value, t);
2957
+ if (e.height?.kind === "percent" && t != null) return N(e.height.value, t);
2705
2958
  }
2706
2959
  function q(e, t, n, r) {
2707
2960
  switch (e.kind) {
2708
2961
  case "cells": return e.value;
2709
- case "percent": return m(e.value, t);
2962
+ case "percent": return N(e.value, t);
2710
2963
  case "min-content": return Y(n, r);
2711
2964
  case "max-content": return J(n, r);
2712
2965
  case "fit-content": return Math.min(J(n, r), Math.max(Y(n, r), t));
@@ -2716,42 +2969,42 @@ function q(e, t, n, r) {
2716
2969
  function J(e, t) {
2717
2970
  let n = t.maxContent.get(e);
2718
2971
  if (n !== void 0) return n;
2719
- let r = e.style, i = rn(e, t) + r.border.left + r.border.right + Yt(r.padding.left) + Yt(r.padding.right);
2972
+ let r = e.style, i = En(e, t) + r.border.left + r.border.right + vn(r.padding.left) + vn(r.padding.right);
2720
2973
  return t.maxContent.set(e, i), i;
2721
2974
  }
2722
- function rn(e, t) {
2975
+ function En(e, t) {
2723
2976
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
2724
- if (n.length === 0) return e.style.display === "multicol" ? Ke(e.style, e.intrinsicWidth) : e.intrinsicWidth;
2725
- if (e.style.display === "grid") return Se(e, t).max;
2726
- if (e.style.display === "table") return wt(e, t).max;
2977
+ if (n.length === 0) return e.style.display === "multicol" ? ft(e.style, e.intrinsicWidth) : e.intrinsicWidth;
2978
+ if (e.style.display === "grid") return He(e, t).max;
2979
+ if (e.style.display === "table") return Kt(e, t).max;
2727
2980
  if (e.style.display === "flex" && e.style.flexDirection === "row") {
2728
- let r = Math.max(Yt(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
2981
+ let r = Math.max(vn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
2729
2982
  return n.reduce((e, n) => e + J(n, t), 0) + r;
2730
2983
  }
2731
2984
  let r = n.reduce((e, n) => Math.max(e, J(n, t)), 0);
2732
- return e.style.display === "multicol" ? Ke(e.style, r) : r;
2985
+ return e.style.display === "multicol" ? ft(e.style, r) : r;
2733
2986
  }
2734
2987
  function Y(e, t) {
2735
2988
  let n = t.minContent.get(e);
2736
2989
  if (n !== void 0) return n;
2737
- let r = e.style, i = an(e, t) + r.border.left + r.border.right + Yt(r.padding.left) + Yt(r.padding.right);
2990
+ let r = e.style, i = Dn(e, t) + r.border.left + r.border.right + vn(r.padding.left) + vn(r.padding.right);
2738
2991
  return t.minContent.set(e, i), i;
2739
2992
  }
2740
- function an(e, t) {
2993
+ function Dn(e, t) {
2741
2994
  let n = e.children.filter((e) => !B(e.style) && !e.inlineBox);
2742
- if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : T(e.text, {
2995
+ if (n.length === 0) return !e.text || e.style.whiteSpace !== "normal" ? e.intrinsicWidth : ue(e.text, {
2743
2996
  advances: e.advances,
2744
2997
  tracking: e.style.tracking
2745
2998
  });
2746
- if (e.style.display === "grid") return Se(e, t).min;
2747
- if (e.style.display === "table") return wt(e, t).min;
2999
+ if (e.style.display === "grid") return He(e, t).min;
3000
+ if (e.style.display === "table") return Kt(e, t).min;
2748
3001
  if (e.style.display === "flex" && e.style.flexDirection === "row" && e.style.flexWrap === "nowrap") {
2749
- let r = Math.max(Yt(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
3002
+ let r = Math.max(vn(e.style.gapX), e.style.ruleX?.width ?? 0) * Math.max(0, n.length - 1);
2750
3003
  return n.reduce((e, n) => e + Y(n, t), 0) + r;
2751
3004
  }
2752
3005
  return n.reduce((e, n) => Math.max(e, Y(n, t)), 0);
2753
3006
  }
2754
- function on(e, t, n, r) {
3007
+ function On(e, t, n, r) {
2755
3008
  return {
2756
3009
  width: Math.max(0, e - n.left - n.right - r.left - r.right),
2757
3010
  height: Math.max(0, t - n.top - n.bottom - r.top - r.bottom)
@@ -2759,38 +3012,38 @@ function on(e, t, n, r) {
2759
3012
  }
2760
3013
  //#endregion
2761
3014
  //#region src/plain-text.ts
2762
- function sn(e) {
2763
- return pn(e).grid.map((e) => e.join("").trimEnd()).join("\n");
3015
+ function kn(e) {
3016
+ return Fn(e).grid.map((e) => e.join("").trimEnd()).join("\n");
2764
3017
  }
2765
- function cn(e) {
2766
- let { grid: t, paints: n } = pn(e);
2767
- return t.map((e, t) => ln(e, n[t]));
3018
+ function An(e) {
3019
+ let { grid: t, paints: n } = Fn(e);
3020
+ return t.map((e, t) => jn(e, n[t]));
2768
3021
  }
2769
- function ln(e, t) {
3022
+ function jn(e, t) {
2770
3023
  let n = e.length;
2771
3024
  for (; n > 0 && e[n - 1] === " " && t[n - 1]?.backgroundColor === void 0;) n--;
2772
3025
  let r = [];
2773
3026
  for (let i = 0; i < n; i++) {
2774
3027
  let n = t[i], a = r[r.length - 1];
2775
- a && un(a, n) ? a.text += e[i] : r.push({
3028
+ a && Mn(a, n) ? a.text += e[i] : r.push({
2776
3029
  text: e[i],
2777
3030
  ...n
2778
3031
  });
2779
3032
  }
2780
3033
  return r;
2781
3034
  }
2782
- function un(e, t) {
2783
- return e.color === t?.color && e.backgroundColor === t?.backgroundColor && e.fontWeight === t?.fontWeight && e.fontStyle === t?.fontStyle && e.textDecorationLine === t?.textDecorationLine;
3035
+ function Mn(e, t) {
3036
+ 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;
2784
3037
  }
2785
- function dn(e, t) {
2786
- 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);
3038
+ function Nn(e, t) {
3039
+ 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);
2787
3040
  }
2788
- function fn(e) {
2789
- return e.color === void 0 && e.backgroundColor === void 0 && e.fontWeight === void 0 && e.fontStyle === void 0 && e.textDecorationLine === void 0;
3041
+ function Pn(e) {
3042
+ 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;
2790
3043
  }
2791
- function pn(e) {
3044
+ function Fn(e) {
2792
3045
  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));
2793
- return hn(e, 0, 0, (e, a, o, s) => {
3046
+ return Ln(e, 0, 0, (e, a, o, s) => {
2794
3047
  if (e >= 0 && e < t && a >= 0 && a < n) {
2795
3048
  r[a][e] = o;
2796
3049
  let t = i[a][e];
@@ -2804,59 +3057,62 @@ function pn(e) {
2804
3057
  paints: i
2805
3058
  };
2806
3059
  }
2807
- function mn(e) {
3060
+ function In(e) {
2808
3061
  let t = {};
2809
3062
  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;
2810
3063
  }
2811
- function hn(t, n, i, a) {
2812
- if (t.tableHidden) return;
2813
- let o = n + t.localRect.x, s = i + t.localRect.y, c = t.style;
2814
- if (c.backgroundColor !== void 0 || c.backgroundClear) {
2815
- let e = c.backgroundColor === void 0 ? void 0 : { backgroundColor: c.backgroundColor };
2816
- for (let n = 0; n < t.localRect.height; n++) for (let r = 0; r < t.localRect.width; r++) a(o + r, s + n, " ", e);
3064
+ function Ln(e, t, n, r, i = 1) {
3065
+ if (e.tableHidden) return;
3066
+ let a = t + e.localRect.x, o = n + e.localRect.y, s = e.style, c = (e) => i >= 1 ? e : {
3067
+ ...e,
3068
+ opacity: String(Math.round(i * 1e3) / 1e3)
3069
+ };
3070
+ if (s.backgroundColor !== void 0 || s.backgroundClear) {
3071
+ let t = s.backgroundColor === void 0 ? void 0 : c({ backgroundColor: s.backgroundColor });
3072
+ for (let n = 0; n < e.localRect.height; n++) for (let i = 0; i < e.localRect.width; i++) r(a + i, o + n, " ", t);
2817
3073
  }
2818
3074
  let l = [];
2819
- e(c, {
2820
- x: o,
2821
- y: s,
2822
- width: t.localRect.width,
2823
- height: t.localRect.height
3075
+ y(s, {
3076
+ x: a,
3077
+ y: o,
3078
+ width: e.localRect.width,
3079
+ height: e.localRect.height
2824
3080
  }, l);
2825
3081
  for (let e of l) {
2826
- let t = e.color === void 0 ? void 0 : { color: e.color };
2827
- for (let n = 0; n < e.length; n++) a(e.x + n, e.y, e.glyph, t);
2828
- }
2829
- if (t.decorationRuns) for (let e of t.decorationRuns) {
2830
- let t = e.color === void 0 ? void 0 : { color: e.color };
2831
- for (let n = 0; n < e.length; n++) a(o + e.x + n, s + e.y, e.glyph, t);
2832
- }
2833
- if (!t.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed") && t.text) {
2834
- let e = t.resolvedPadding, n = o + c.border.left + e.left, r = s + c.border.top + e.top, i = t.localRect.width - c.border.left - c.border.right - e.left - e.right, l = t.multicolGeometry, { spans: u, textY: d } = l ?? Kt(t, i), f = l ? Math.max(1, l.columnWidth - c.tracking) : i, p = mn(c), m = t.inlineElements?.map((e) => mn(e));
2835
- for (let e = 0; e < u.length; e++) {
2836
- let i = u[e], o = r + d[e], s = e === 0 ? c.textIndent : 0, h = c.whiteSpace !== "normal" && c.overflow === "clip" ? gn(t.text, i, f - s, t.advances, c) : {
2837
- end: i.end,
3082
+ let t = c(e.color === void 0 ? void 0 : { color: e.color });
3083
+ for (let n = 0; n < e.length; n++) r(e.x + n, e.y, e.glyph, t);
3084
+ }
3085
+ if (e.decorationRuns) for (let t of e.decorationRuns) {
3086
+ let e = c(t.color === void 0 ? void 0 : { color: t.color });
3087
+ for (let n = 0; n < t.length; n++) r(a + t.x + n, o + t.y, t.glyph, e);
3088
+ }
3089
+ if (!e.children.some((e) => !e.inlineBox && e.style.position !== "absolute" && e.style.position !== "fixed") && e.text) {
3090
+ 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 ?? hn(e, l), p = u ? Math.max(1, u.columnWidth - s.tracking) : l, m = c(In(s)), h = e.inlineElements?.map((e) => c(In(e)));
3091
+ for (let t = 0; t < d.length; t++) {
3092
+ let a = d[t], o = i + f[t], l = t === 0 ? s.textIndent : 0, g = s.whiteSpace !== "normal" && s.overflow === "clip" ? Rn(e.text, a, p - l, e.advances, s) : {
3093
+ end: a.end,
2838
3094
  ellipsis: !1
2839
- }, g = C(i.start, i.end, t.advances, c.tracking), _ = Math.max(0, f - s - g), v = c.textAlign === "end" ? _ : c.textAlign === "center" ? Math.floor(_ / 2) : 0, y = n + (l?.lineX[e] ?? 0) + v + s;
2840
- for (let e = i.start; e < h.end; e++) {
2841
- if (t.text[e] !== "") {
2842
- let n = t.charInline?.[e] ?? -1, r = n >= 0 ? t.inlineElements[n] : void 0, i = r?.insets, s = i ? i.left ?? (i.right === null ? 0 : -i.right) : 0, c = i ? i.top ?? (i.bottom === null ? 0 : -i.bottom) : 0;
2843
- t.text[e] === "⁠" ? r?.backgroundColor && a(y + s, o + c, " ", { backgroundColor: r.backgroundColor }) : a(y + s, o + c, t.text[e], r ? m[n] : p);
3095
+ }, _ = 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;
3096
+ for (let t = a.start; t < g.end; t++) {
3097
+ if (e.text[t] !== "") {
3098
+ 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;
3099
+ 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);
2844
3100
  }
2845
- y += S(e, e + 1, t.advances);
3101
+ b += ce(t, t + 1, e.advances);
2846
3102
  }
2847
- h.ellipsis && a(y, o, "…", p);
3103
+ g.ellipsis && r(b, o, "…", m);
2848
3104
  }
2849
3105
  }
2850
- for (let e of r(t)) hn(e, o, s, a);
3106
+ for (let t of S(e)) Ln(t, a, o, r, i * t.style.opacity);
2851
3107
  }
2852
- function gn(e, t, n, r, i) {
3108
+ function Rn(e, t, n, r, i) {
2853
3109
  let { textOverflow: a, tracking: o } = i;
2854
- if (C(t.start, t.end, r, o) <= n) return {
3110
+ if (P(t.start, t.end, r, o) <= n) return {
2855
3111
  end: t.end,
2856
3112
  ellipsis: !1
2857
3113
  };
2858
3114
  let s = a === "ellipsis" ? n - 1 : n, c = t.start;
2859
- for (; c < t.end && C(t.start, c + 1, r, o) <= s;) c++;
3115
+ for (; c < t.end && P(t.start, c + 1, r, o) <= s;) c++;
2860
3116
  return {
2861
3117
  end: c,
2862
3118
  ellipsis: a === "ellipsis" && n > 0
@@ -2864,38 +3120,124 @@ function gn(e, t, n, r, i) {
2864
3120
  }
2865
3121
  //#endregion
2866
3122
  //#region src/paint.ts
2867
- var _n = /* @__PURE__ */ new WeakMap();
2868
- function vn(e, t) {
2869
- let n = cn(e), r = yn(n);
2870
- if (_n.get(t) === r) return;
2871
- _n.set(t, r);
2872
- let i = document.createDocumentFragment();
2873
- for (let e = 0; e < n.length; e++) {
2874
- e > 0 && i.appendChild(document.createTextNode("\n"));
2875
- for (let t of n[e]) {
2876
- if (fn(t)) {
2877
- i.appendChild(document.createTextNode(t.text));
3123
+ var zn = /* @__PURE__ */ new WeakMap(), Bn = /* @__PURE__ */ new WeakMap();
3124
+ function Vn(e) {
3125
+ return Wn(e, !0) !== null;
3126
+ }
3127
+ function Hn(e, t, n = !1) {
3128
+ let r = An(e), i = Yn(r);
3129
+ if (zn.get(t) === i) return !0;
3130
+ let a = Bn.get(t);
3131
+ if (a && Un(t, a.nodes, r)) {
3132
+ zn.set(t, i);
3133
+ for (let e = 0; e < r.length; e++) for (let t = 0; t < r[e].length; t++) {
3134
+ let n = r[e][t];
3135
+ if (Pn(n) || Mn(n, a.segments[e][t])) continue;
3136
+ let i = a.nodes[e][t];
3137
+ i.style.cssText = "", Nn(n, i.style);
3138
+ }
3139
+ return a.segments = r, !0;
3140
+ }
3141
+ if (n && Vn(t)) return !1;
3142
+ zn.set(t, i);
3143
+ let o = document.createDocumentFragment(), s = [];
3144
+ for (let e = 0; e < r.length; e++) {
3145
+ e > 0 && o.appendChild(document.createTextNode("\n"));
3146
+ let t = [];
3147
+ for (let n of r[e]) {
3148
+ if (Pn(n)) {
3149
+ let e = document.createTextNode(n.text);
3150
+ t.push(e), o.appendChild(e);
2878
3151
  continue;
2879
3152
  }
2880
3153
  let e = document.createElement("span");
2881
- dn(t, e.style), e.textContent = t.text, i.appendChild(e);
3154
+ Nn(n, e.style), e.textContent = n.text, t.push(e), o.appendChild(e);
2882
3155
  }
3156
+ s.push(t);
2883
3157
  }
2884
- t.replaceChildren(i);
3158
+ Bn.set(t, {
3159
+ nodes: s,
3160
+ segments: r
3161
+ });
3162
+ let c = Wn(t, !1);
3163
+ return t.replaceChildren(o), c && Gn(t, c), !0;
2885
3164
  }
2886
- function yn(e) {
3165
+ function Un(e, t, n) {
3166
+ if (t.length !== n.length) return !1;
3167
+ for (let r = 0; r < n.length; r++) {
3168
+ let i = t[r], a = n[r];
3169
+ if (i.length !== a.length) return !1;
3170
+ for (let t = 0; t < a.length; t++) {
3171
+ let n = i[t];
3172
+ if (Pn(a[t]) !== (n.nodeType === Node.TEXT_NODE) || n.textContent !== a[t].text || n.parentNode !== e) return !1;
3173
+ }
3174
+ }
3175
+ return !0;
3176
+ }
3177
+ function Wn(e, t) {
3178
+ try {
3179
+ let n = e.ownerDocument.getSelection();
3180
+ if (!n) return null;
3181
+ let r = e.getRootNode();
3182
+ if (!(r instanceof ShadowRoot)) return null;
3183
+ let i;
3184
+ if (n.getComposedRanges) {
3185
+ let e = n.getComposedRanges({ shadowRoots: [r] });
3186
+ if (e.length === 0) return null;
3187
+ i = e[0];
3188
+ } else {
3189
+ let e = r.getSelection?.();
3190
+ if (!e || e.rangeCount === 0) return null;
3191
+ i = e.getRangeAt(0);
3192
+ }
3193
+ let a = Kn(e, i.startContainer, i.startOffset), o = Kn(e, i.endContainer, i.endOffset);
3194
+ return a === null || o === null || a === o && !t ? null : {
3195
+ start: a,
3196
+ end: o,
3197
+ backward: n.direction === "backward"
3198
+ };
3199
+ } catch {
3200
+ return null;
3201
+ }
3202
+ }
3203
+ function Gn(e, t) {
3204
+ try {
3205
+ let n = qn(e, t.start), r = qn(e, t.end);
3206
+ if (!n || !r) return;
3207
+ let i = e.getRootNode().getSelection?.() ?? e.ownerDocument.getSelection();
3208
+ t.backward ? i?.setBaseAndExtent(r[0], r[1], n[0], n[1]) : i?.setBaseAndExtent(n[0], n[1], r[0], r[1]);
3209
+ } catch {}
3210
+ }
3211
+ function Kn(e, t, n) {
3212
+ if (!e.contains(t)) return null;
3213
+ let r = e.ownerDocument.createRange();
3214
+ return r.selectNodeContents(e), r.setEnd(t, n), r.toString().length;
3215
+ }
3216
+ function qn(e, t) {
3217
+ let n = t, r = null;
3218
+ for (let t of Jn(e)) {
3219
+ if (n <= t.data.length) return [t, n];
3220
+ n -= t.data.length, r = [t, t.data.length];
3221
+ }
3222
+ return r;
3223
+ }
3224
+ function* Jn(e) {
3225
+ let t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), n = t.nextNode();
3226
+ for (; n;) yield n, n = t.nextNode();
3227
+ }
3228
+ function Yn(e) {
2887
3229
  let t = [];
2888
3230
  for (let n of e) {
2889
- for (let e of n) t.push(e.text, e.color ?? "", e.backgroundColor ?? "", e.fontWeight ?? "", e.fontStyle ?? "", e.textDecorationLine ?? "");
3231
+ for (let e of n) t.push(e.text, e.color ?? "", e.backgroundColor ?? "", e.fontWeight ?? "", e.fontStyle ?? "", e.textDecorationLine ?? "", e.opacity ?? "");
2890
3232
  t.push("\n");
2891
3233
  }
2892
3234
  return t.join("");
2893
3235
  }
2894
3236
  //#endregion
2895
3237
  //#region src/render.ts
2896
- function bn(e) {
3238
+ function Xn(e) {
2897
3239
  let t = /* @__PURE__ */ new Set();
2898
- xn(e, !0, t);
3240
+ Zn(e, !0, t);
2899
3241
  for (let n of Array.from(e.source.querySelectorAll("[data-mw-inline-inset]"))) if (!t.has(n)) {
2900
3242
  n.removeAttribute("data-mw-inline-inset");
2901
3243
  let e = n.style;
@@ -2916,129 +3258,129 @@ function Z(e, t) {
2916
3258
  function Q(e, t, n) {
2917
3259
  e.hasAttribute(t) !== n && (n ? e.setAttribute(t, "") : e.removeAttribute(t));
2918
3260
  }
2919
- function xn(e, t, i) {
2920
- if (e.inlineElements) for (let { element: t, tracking: n, padLeft: r, padRight: a, insets: o } of e.inlineElements) {
3261
+ function Zn(e, t, n) {
3262
+ if (e.inlineElements) for (let { element: t, tracking: r, padLeft: i, padRight: a, insets: o } of e.inlineElements) {
2921
3263
  let e = t;
2922
- X(e, "--mw-ls", String(n)), r > 0 ? X(e, "--mw-ipl", String(r)) : Z(e, "--mw-ipl"), a > 0 ? X(e, "--mw-ipr", String(a)) : Z(e, "--mw-ipr"), o && (i.add(t), Sn(e, o));
3264
+ 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), Qn(e, o));
2923
3265
  }
2924
- if (t || wn(e), !e.tableHidden) for (let t of r(e)) {
3266
+ if (t || er(e), !e.tableHidden) for (let t of S(e)) {
2925
3267
  let r = t.source;
2926
- t.style.zIndex !== null && n(t, e) && !t.inlineBox ? X(r, "--mw-z", String(t.style.zIndex)) : Z(r, "--mw-z"), xn(t, !1, i);
3268
+ t.style.zIndex !== null && x(t, e) && !t.inlineBox ? X(r, "--mw-z", String(t.style.zIndex)) : Z(r, "--mw-z"), Zn(t, !1, n);
2927
3269
  }
2928
3270
  }
2929
- function Sn(e, t) {
3271
+ function Qn(e, t) {
2930
3272
  Q(e, "data-mw-inline-inset", !0);
2931
3273
  let n = (t, n) => {
2932
3274
  n === null ? Z(e, t) : X(e, t, String(n));
2933
3275
  };
2934
3276
  n("--mw-it", t.top), n("--mw-ir", t.right), n("--mw-ib", t.bottom), n("--mw-il", t.left);
2935
3277
  }
2936
- function Cn(e) {
3278
+ function $n(e) {
2937
3279
  let t = e.style;
2938
3280
  if (t.textAlign !== "center" || !e.text || e.inlineBox || e.children.length > 0) return !1;
2939
- 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 ?? qt(e, i);
3281
+ 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 ?? gn(e, i);
2940
3282
  return o.length !== 0 && o.every((n, r) => {
2941
- let i = r === 0 ? t.textIndent : 0, o = a - i - C(n.start, n.end, e.advances, t.tracking);
3283
+ let i = r === 0 ? t.textIndent : 0, o = a - i - P(n.start, n.end, e.advances, t.tracking);
2942
3284
  return o > 0 && o % 2 == 1;
2943
3285
  });
2944
3286
  }
2945
- function wn(e) {
3287
+ function er(e) {
2946
3288
  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;
2947
3289
  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);
2948
3290
  let f = u ?? d;
2949
3291
  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");
2950
3292
  let p = u || d ? void 0 : e.multicolGeometry;
2951
- 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", Cn(e)), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
3293
+ 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", $n(e)), Q(t, "data-mw-dropped-text", !!e.droppedText), Q(t, "data-mw-table-hidden", !!e.tableHidden);
2952
3294
  }
2953
3295
  //#endregion
2954
3296
  //#region src/style.ts
2955
- function Tn(e, t, n) {
2956
- let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = Rn(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
2957
- Nn(e, o, s);
2958
- let c = r.display || An[e.tagName] || "", l = jn[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, m = Number.isFinite(d) ? Math.max(1, p(d, t)) : null, h = c === "flex" || c === "inline-flex" ? "flex" : c === "grid" || c === "inline-grid" ? "grid" : c === "table" || c === "inline-table" ? "table" : c === "none" || kn(r) ? "none" : u !== null || m !== null ? "multicol" : "block", g = { kind: "none" }, _ = { kind: "none" }, v = [fe()], y = [fe()], b = {
3297
+ function tr(e, t, n) {
3298
+ let r = getComputedStyle(e), i = parseFloat(r.fontSize) || t, a = hr(e) ? e.computedStyleMap() : null, o = e.getAttribute("class") ?? "", s = e.style;
3299
+ ur(e, o, s);
3300
+ let c = r.display || sr[e.tagName] || "", l = cr[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, M(d, t)) : null, p = c === "flex" || c === "inline-flex" ? "flex" : c === "grid" || c === "inline-grid" ? "grid" : c === "table" || c === "inline-table" ? "table" : c === "none" || or(r) ? "none" : u !== null || f !== null ? "multicol" : "block", m = { kind: "none" }, h = { kind: "none" }, g = [Me()], _ = [Me()], v = {
2959
3301
  direction: "row",
2960
3302
  dense: !1
2961
- }, x = null;
2962
- if (h === "grid") {
2963
- if (a) g = rr(a.get("grid-template-columns")?.toString() ?? "", t), _ = rr(a.get("grid-template-rows")?.toString() ?? "", t);
3303
+ }, y = null;
3304
+ if (p === "grid") {
3305
+ if (a) m = Fr(a.get("grid-template-columns")?.toString() ?? "", t), h = Fr(a.get("grid-template-rows")?.toString() ?? "", t);
2964
3306
  else {
2965
3307
  e.setAttribute("data-mw-degrid", "");
2966
3308
  try {
2967
- g = rr(r.getPropertyValue("grid-template-columns"), t), _ = rr(r.getPropertyValue("grid-template-rows"), t);
3309
+ m = Fr(r.getPropertyValue("grid-template-columns"), t), h = Fr(r.getPropertyValue("grid-template-rows"), t);
2968
3310
  } finally {
2969
3311
  e.removeAttribute("data-mw-degrid");
2970
3312
  }
2971
3313
  }
2972
- v = sr(r.getPropertyValue("grid-auto-columns"), t), y = sr(r.getPropertyValue("grid-auto-rows"), t), b = pr(r.getPropertyValue("grid-auto-flow")), x = or(r.getPropertyValue("grid-template-areas"));
3314
+ g = zr(r.getPropertyValue("grid-auto-columns"), t), _ = zr(r.getPropertyValue("grid-auto-rows"), t), v = Gr(r.getPropertyValue("grid-auto-flow")), y = Rr(r.getPropertyValue("grid-template-areas"));
2973
3315
  }
2974
- let S = "auto", C = !1, w = 0, T = 0;
2975
- if (h === "table" && (S = r.tableLayout === "fixed" ? "fixed" : "auto", C = r.borderCollapse === "collapse", !C)) {
3316
+ let b = "auto", x = !1, S = 0, C = 0;
3317
+ if (p === "table" && (b = r.tableLayout === "fixed" ? "fixed" : "auto", x = r.borderCollapse === "collapse", !x)) {
2976
3318
  let e = r.borderSpacing.split(" ");
2977
- w = p(parseFloat(e[0] ?? "") || 0, t), T = p(parseFloat(e[1] ?? e[0] ?? "") || 0, t);
3319
+ S = M(parseFloat(e[0] ?? "") || 0, t), C = M(parseFloat(e[1] ?? e[0] ?? "") || 0, t);
2978
3320
  }
2979
- let E = {
2980
- display: h,
3321
+ let w = {
3322
+ display: p,
2981
3323
  tableRole: l,
2982
- tableLayout: S,
2983
- borderCollapse: C,
2984
- borderSpacingX: w,
2985
- borderSpacingY: T,
3324
+ tableLayout: b,
3325
+ borderCollapse: x,
3326
+ borderSpacingX: S,
3327
+ borderSpacingY: C,
2986
3328
  captionSide: r.captionSide === "bottom" ? "bottom" : "top",
2987
- verticalAlign: l === "cell" || c.startsWith("inline-") ? Mn(e, r) : "start",
3329
+ verticalAlign: l === "cell" || c.startsWith("inline-") ? lr(e, r) : "start",
2988
3330
  flexDirection: r.flexDirection.startsWith("column") ? "column" : "row",
2989
3331
  flexReverse: r.flexDirection.endsWith("-reverse"),
2990
3332
  flexWrap: r.flexWrap.startsWith("wrap") ? "wrap" : "nowrap",
2991
3333
  wrapReverse: r.flexWrap === "wrap-reverse",
2992
3334
  flexGrow: Number(r.flexGrow) || 0,
2993
3335
  flexShrink: r.flexShrink === "" ? 1 : Number(r.flexShrink) || 0,
2994
- flexBasis: tr(r.flexBasis, t),
3336
+ flexBasis: Nr(r.flexBasis, t),
2995
3337
  order: Number(r.order) || 0,
2996
- justifyContent: zn(r.justifyContent),
2997
- alignContent: zn(r.alignContent),
2998
- alignItems: Bn(r.alignItems),
2999
- alignSelf: Vn(r.alignSelf),
3000
- justifyItems: Bn(r.justifyItems),
3001
- justifySelf: Vn(r.justifySelf),
3002
- gridTemplateColumns: g,
3003
- gridTemplateRows: _,
3004
- gridAutoColumns: v,
3005
- gridAutoRows: y,
3006
- gridAutoFlow: b,
3007
- gridTemplateAreas: x,
3008
- gridColumnStart: fr(r.getPropertyValue("grid-column-start")),
3009
- gridColumnEnd: fr(r.getPropertyValue("grid-column-end")),
3010
- gridRowStart: fr(r.getPropertyValue("grid-row-start")),
3011
- gridRowEnd: fr(r.getPropertyValue("grid-row-end")),
3012
- width: Xn(a, r.width, "width", t, o, s, n),
3013
- height: Xn(a, r.height, "height", t, o, s, n),
3014
- minWidth: er(a, "min-width", r.minWidth, o, "min-w", s, n, t) ?? Jn(r.minWidth, t) ?? "auto",
3015
- minHeight: er(a, "min-height", r.minHeight, o, "min-h", s, n, t) ?? Jn(r.minHeight, t) ?? "auto",
3016
- maxWidth: er(a, "max-width", r.maxWidth, o, "max-w", s, n, t) ?? Jn(r.maxWidth, t),
3017
- maxHeight: er(a, "max-height", r.maxHeight, o, "max-h", s, n, t) ?? Jn(r.maxHeight, t),
3018
- padding: hr(r, t),
3019
- margin: Hn(r, a, o, s, t),
3020
- position: Gn(r.position),
3021
- insets: Kn(r, a, o, s, t),
3022
- gapX: $(r.columnGap === "normal" || r.columnGap === "" ? h === "multicol" ? `${i}px` : "0px" : r.columnGap, t),
3338
+ justifyContent: gr(r.justifyContent),
3339
+ alignContent: gr(r.alignContent),
3340
+ alignItems: _r(r.alignItems),
3341
+ alignSelf: vr(r.alignSelf),
3342
+ justifyItems: _r(r.justifyItems),
3343
+ justifySelf: vr(r.justifySelf),
3344
+ gridTemplateColumns: m,
3345
+ gridTemplateRows: h,
3346
+ gridAutoColumns: g,
3347
+ gridAutoRows: _,
3348
+ gridAutoFlow: v,
3349
+ gridTemplateAreas: y,
3350
+ gridColumnStart: Wr(r.getPropertyValue("grid-column-start")),
3351
+ gridColumnEnd: Wr(r.getPropertyValue("grid-column-end")),
3352
+ gridRowStart: Wr(r.getPropertyValue("grid-row-start")),
3353
+ gridRowEnd: Wr(r.getPropertyValue("grid-row-end")),
3354
+ width: Or(a, r.width, "width", t, o, s, n),
3355
+ height: Or(a, r.height, "height", t, o, s, n),
3356
+ minWidth: Mr(a, "min-width", r.minWidth, o, "min-w", s, n, t) ?? Tr(r.minWidth, t) ?? "auto",
3357
+ minHeight: Mr(a, "min-height", r.minHeight, o, "min-h", s, n, t) ?? Tr(r.minHeight, t) ?? "auto",
3358
+ maxWidth: Mr(a, "max-width", r.maxWidth, o, "max-w", s, n, t) ?? Tr(r.maxWidth, t),
3359
+ maxHeight: Mr(a, "max-height", r.maxHeight, o, "max-h", s, n, t) ?? Tr(r.maxHeight, t),
3360
+ padding: qr(r, t),
3361
+ margin: yr(r, a, o, s, t),
3362
+ position: Sr(r.position),
3363
+ insets: Cr(r, a, o, s, t),
3364
+ gapX: $(r.columnGap === "normal" || r.columnGap === "" ? p === "multicol" ? `${i}px` : "0px" : r.columnGap, t),
3023
3365
  gapY: $(r.rowGap === "normal" ? "0px" : r.rowGap, t),
3024
- border: gr(r),
3366
+ border: Jr(r),
3025
3367
  borderStyle: {
3026
- top: qn(r.borderTopStyle),
3027
- right: qn(r.borderRightStyle),
3028
- bottom: qn(r.borderBottomStyle),
3029
- left: qn(r.borderLeftStyle)
3368
+ top: wr(r.borderTopStyle),
3369
+ right: wr(r.borderRightStyle),
3370
+ bottom: wr(r.borderBottomStyle),
3371
+ left: wr(r.borderLeftStyle)
3030
3372
  },
3031
- overflow: On(r.overflow) || On(r.overflowX) || On(r.overflowY) ? "clip" : "visible",
3373
+ overflow: ar(r.overflow) || ar(r.overflowX) || ar(r.overflowY) ? "clip" : "visible",
3032
3374
  whiteSpace: r.whiteSpace === "pre" ? "pre" : r.whiteSpace === "nowrap" ? "nowrap" : "normal",
3033
3375
  tabSize: Math.max(1, Math.floor(parseFloat(r.tabSize)) || 8),
3034
- lineGap: Wn(r.lineHeight, i),
3035
- tracking: Un(r.letterSpacing, i, n?.letterSpacing ?? 0),
3376
+ lineGap: xr(r.lineHeight, i),
3377
+ tracking: br(r.letterSpacing, i, n?.letterSpacing ?? 0),
3036
3378
  textOverflow: r.textOverflow === "ellipsis" ? "ellipsis" : "clip",
3037
3379
  color: r.color,
3038
3380
  fontWeight: r.fontWeight,
3039
3381
  fontStyle: r.fontStyle,
3040
3382
  textDecorationLine: r.textDecorationLine,
3041
- backgroundColor: Dn(r.backgroundColor) ? void 0 : r.backgroundColor,
3383
+ backgroundColor: ir(e, r.backgroundColor, r),
3042
3384
  backgroundClear: r.getPropertyValue("--mw-bg-clear").trim() === "1",
3043
3385
  borderColor: {
3044
3386
  top: r.borderTopColor,
@@ -3046,31 +3388,32 @@ function Tn(e, t, n) {
3046
3388
  bottom: r.borderBottomColor,
3047
3389
  left: r.borderLeftColor
3048
3390
  },
3049
- textAlignBlocked: In(e, r),
3050
- textAlign: Ln(e, r),
3051
- textIndent: Yn(r, t),
3391
+ textAlignBlocked: pr(e, r),
3392
+ textAlign: mr(e, r),
3393
+ textIndent: Dr(r, t),
3394
+ opacity: Er(r.opacity),
3052
3395
  zIndex: r.zIndex === "auto" || r.zIndex === "" ? null : Number(r.zIndex) || 0,
3053
3396
  latticeBorder: null,
3054
- ruleX: h === "flex" || h === "grid" || h === "multicol" ? Fn(r, "x") : null,
3055
- ruleY: h === "flex" || h === "grid" ? Fn(r, "y") : null,
3056
- ruleBreak: Pn(r, "--mw-rule-break", ["none", "intersection"], "normal"),
3057
- ruleInset: r.getPropertyValue("--mw-rule-inset").trim() === "overlap-join" ? "overlap-join" : Math.max(0, f(parseFloat(r.getPropertyValue("--mw-rule-inset")) || 0)),
3058
- ruleVisibilityItems: Pn(r, "--mw-rule-visibility-items", [
3397
+ ruleX: p === "flex" || p === "grid" || p === "multicol" ? fr(r, "x") : null,
3398
+ ruleY: p === "flex" || p === "grid" ? fr(r, "y") : null,
3399
+ ruleBreak: dr(r, "--mw-rule-break", ["none", "intersection"], "normal"),
3400
+ ruleInset: r.getPropertyValue("--mw-rule-inset").trim() === "overlap-join" ? "overlap-join" : Math.max(0, j(parseFloat(r.getPropertyValue("--mw-rule-inset")) || 0)),
3401
+ ruleVisibilityItems: dr(r, "--mw-rule-visibility-items", [
3059
3402
  "all",
3060
3403
  "around",
3061
3404
  "between"
3062
3405
  ], "normal"),
3063
3406
  columnCount: u,
3064
- columnWidth: m,
3407
+ columnWidth: f,
3065
3408
  columnFill: r.columnFill === "auto" ? "auto" : "balance",
3066
3409
  columnSpan: r.columnSpan === "all",
3067
3410
  breakBeforeColumn: r.breakBefore === "column",
3068
3411
  breakAfterColumn: r.breakAfter === "column",
3069
3412
  breakInsideAvoid: r.breakInside === "avoid" || r.breakInside === "avoid-column"
3070
3413
  };
3071
- return En(E, r), E;
3414
+ return nr(w, r), w;
3072
3415
  }
3073
- function En(e, t) {
3416
+ function nr(e, t) {
3074
3417
  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 = {
3075
3418
  width: e.border,
3076
3419
  style: e.borderStyle,
@@ -3083,20 +3426,24 @@ function En(e, t) {
3083
3426
  }
3084
3427
  }, e.border = R(), e.display === "table" && (e.padding = R()));
3085
3428
  }
3086
- function Dn(e) {
3429
+ function rr(e) {
3087
3430
  if (!e) return !0;
3088
3431
  let t = e.trim().toLowerCase();
3089
3432
  return t === "" || t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "currentcolor";
3090
3433
  }
3091
- function On(e) {
3434
+ function ir(e, t, n) {
3435
+ let i = r(e, rr(t) ? "" : t, n);
3436
+ return i === "" ? void 0 : i;
3437
+ }
3438
+ function ar(e) {
3092
3439
  return e === "hidden" || e === "clip";
3093
3440
  }
3094
- function kn(e) {
3441
+ function or(e) {
3095
3442
  if (e.position !== "absolute" && e.position !== "fixed") return !1;
3096
3443
  let t = e.clip.replace(/\s/g, "");
3097
- return t === "rect(0px,0px,0px,0px)" || t === "rect(0,0,0,0)" || (On(e.overflow) || On(e.overflowX)) && parseFloat(e.width) <= 1 && parseFloat(e.height) <= 1;
3444
+ return t === "rect(0px,0px,0px,0px)" || t === "rect(0,0,0,0)" || (ar(e.overflow) || ar(e.overflowX)) && parseFloat(e.width) <= 1 && parseFloat(e.height) <= 1;
3098
3445
  }
3099
- var An = {
3446
+ var sr = {
3100
3447
  TABLE: "table",
3101
3448
  THEAD: "table-header-group",
3102
3449
  TBODY: "table-row-group",
@@ -3107,7 +3454,7 @@ var An = {
3107
3454
  CAPTION: "table-caption",
3108
3455
  COL: "table-column",
3109
3456
  COLGROUP: "table-column-group"
3110
- }, jn = {
3457
+ }, cr = {
3111
3458
  "table-header-group": "header-group",
3112
3459
  "table-row-group": "row-group",
3113
3460
  "table-footer-group": "footer-group",
@@ -3117,38 +3464,38 @@ var An = {
3117
3464
  "table-column": "column",
3118
3465
  "table-column-group": "column-group"
3119
3466
  };
3120
- function Mn(e, t) {
3467
+ function lr(e, t) {
3121
3468
  let n = t.verticalAlign || e.getAttribute("valign")?.toLowerCase() || (e.tagName === "TD" || e.tagName === "TH" ? "middle" : "baseline");
3122
3469
  return n === "top" ? "start" : n === "middle" ? "center" : n === "bottom" ? "end" : "start";
3123
3470
  }
3124
- function Nn(e, t, n) {
3125
- (/(?:^|[\s:.[!])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w-])/.test(t) || /(?:^|[\s:.[!])text-\[(?:(?:length|size):|[\d.])/.test(t) || n.fontSize !== "") && at(e, "font-size inside <mono-wind> is ignored — all text shares the host's cell size. Size the <mono-wind> element itself instead.");
3471
+ function ur(e, t, n) {
3472
+ (/(?:^|[\s:.[!])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w-])/.test(t) || /(?:^|[\s:.[!])text-\[(?:(?:length|size):|[\d.])/.test(t) || n.fontSize !== "") && Dt(e, "font-size inside <mono-wind> is ignored — all text shares the host's cell size. Size the <mono-wind> element itself instead.");
3126
3473
  }
3127
- function Pn(e, t, n, r) {
3474
+ function dr(e, t, n, r) {
3128
3475
  let i = e.getPropertyValue(t).trim();
3129
3476
  return n.includes(i) ? i : r;
3130
3477
  }
3131
- function Fn(e, t) {
3132
- let n = f(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
3478
+ function fr(e, t) {
3479
+ let n = j(parseFloat(e.getPropertyValue(`--mw-rule-${t}-width`)) || 0);
3133
3480
  if (n <= 0) return null;
3134
3481
  let r = e.getPropertyValue(`--mw-rule-${t}-color`).trim();
3135
3482
  return {
3136
3483
  width: n,
3137
- style: qn(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3484
+ style: wr(e.getPropertyValue(`--mw-rule-${t}-style`).trim()),
3138
3485
  color: r && r !== "currentcolor" && r !== "currentColor" ? r : e.color
3139
3486
  };
3140
3487
  }
3141
- function In(e, t) {
3488
+ function pr(e, t) {
3142
3489
  return t.textAlign === "justify" || e.getAttribute("align")?.toLowerCase() === "justify";
3143
3490
  }
3144
- function Ln(e, t) {
3491
+ function mr(e, t) {
3145
3492
  let n = t.textAlign || e.getAttribute("align")?.toLowerCase() || "";
3146
3493
  return n === "right" || n === "end" ? "end" : n === "center" || n.endsWith("-center") ? "center" : "start";
3147
3494
  }
3148
- function Rn(e) {
3495
+ function hr(e) {
3149
3496
  return typeof e.computedStyleMap == "function";
3150
3497
  }
3151
- function zn(e) {
3498
+ function gr(e) {
3152
3499
  switch (e) {
3153
3500
  case "center": return "center";
3154
3501
  case "flex-end":
@@ -3163,7 +3510,7 @@ function zn(e) {
3163
3510
  default: return "start";
3164
3511
  }
3165
3512
  }
3166
- function Bn(e) {
3513
+ function _r(e) {
3167
3514
  switch (e) {
3168
3515
  case "center": return "center";
3169
3516
  case "flex-end":
@@ -3174,10 +3521,10 @@ function Bn(e) {
3174
3521
  default: return "start";
3175
3522
  }
3176
3523
  }
3177
- function Vn(e) {
3178
- return e === "auto" || e === "" || e === "normal" ? "auto" : Bn(e);
3524
+ function vr(e) {
3525
+ return e === "auto" || e === "" || e === "normal" ? "auto" : _r(e);
3179
3526
  }
3180
- function Hn(e, t, n, r, i) {
3527
+ function yr(e, t, n, r, i) {
3181
3528
  let a = (a, o, s) => {
3182
3529
  if (t) {
3183
3530
  let e = t.get(a)?.toString().trim();
@@ -3201,16 +3548,16 @@ function Hn(e, t, n, r, i) {
3201
3548
  left: a("margin-left", "margin-inline-start", /(?:^|[\s:.[!])(?:m|mx|ml|ms)-auto\b/)
3202
3549
  };
3203
3550
  }
3204
- function Un(e, t, n) {
3551
+ function br(e, t, n) {
3205
3552
  let r = (e === "normal" ? 0 : parseFloat(e) || 0) - n;
3206
3553
  return r <= 0 ? 0 : Math.floor(r / (.025 * t) + 1e-6);
3207
3554
  }
3208
- function Wn(e, t) {
3555
+ function xr(e, t) {
3209
3556
  if (!e || e === "normal" || t <= 0) return 0;
3210
3557
  let n = parseFloat(e);
3211
3558
  return Number.isFinite(n) ? Math.max(0, Math.floor(n / t + 1e-6) - 1) : 0;
3212
3559
  }
3213
- function Gn(e) {
3560
+ function Sr(e) {
3214
3561
  switch (e) {
3215
3562
  case "relative":
3216
3563
  case "absolute":
@@ -3219,7 +3566,7 @@ function Gn(e) {
3219
3566
  default: return "static";
3220
3567
  }
3221
3568
  }
3222
- function Kn(e, t, n, r, i) {
3569
+ function Cr(e, t, n, r, i) {
3223
3570
  let a = (a, o) => {
3224
3571
  if (t) {
3225
3572
  let e = t.get(a)?.toString().trim();
@@ -3238,7 +3585,7 @@ function Kn(e, t, n, r, i) {
3238
3585
  left: a("left", /(?:^|[\s:.[!])-?(?:left|start|inset|inset-x)-/)
3239
3586
  };
3240
3587
  }
3241
- function qn(e) {
3588
+ function wr(e) {
3242
3589
  switch (e) {
3243
3590
  case "double": return "double";
3244
3591
  case "dashed": return "dashed";
@@ -3246,7 +3593,7 @@ function qn(e) {
3246
3593
  default: return "solid";
3247
3594
  }
3248
3595
  }
3249
- function Jn(e, t) {
3596
+ function Tr(e, t) {
3250
3597
  if (!e || e === "none" || e === "auto") return;
3251
3598
  if (e === "min-content" || e === "max-content" || e === "fit-content") return e;
3252
3599
  if (e.endsWith("%")) {
@@ -3254,7 +3601,7 @@ function Jn(e, t) {
3254
3601
  return Number.isFinite(t) ? { percent: t } : void 0;
3255
3602
  }
3256
3603
  let n = parseFloat(e);
3257
- return Number.isFinite(n) ? p(n, t) : void 0;
3604
+ return Number.isFinite(n) ? M(n, t) : void 0;
3258
3605
  }
3259
3606
  function $(e, t) {
3260
3607
  if (!e || e === "auto" || e === "none") return 0;
@@ -3263,26 +3610,30 @@ function $(e, t) {
3263
3610
  return Number.isFinite(t) && t !== 0 ? { percent: t } : 0;
3264
3611
  }
3265
3612
  let n = parseFloat(e);
3266
- return Number.isFinite(n) ? p(n, t) : 0;
3613
+ return Number.isFinite(n) ? M(n, t) : 0;
3614
+ }
3615
+ function Er(e) {
3616
+ let t = parseFloat(e);
3617
+ return Number.isFinite(t) ? Math.min(1, Math.max(0, t)) : 1;
3267
3618
  }
3268
- function Yn(e, t) {
3619
+ function Dr(e, t) {
3269
3620
  let n = e.textIndent;
3270
3621
  if (!n || n.endsWith("%")) return 0;
3271
3622
  let r = parseFloat(n);
3272
- return Number.isFinite(r) ? Math.max(0, p(r, t)) : 0;
3623
+ return Number.isFinite(r) ? Math.max(0, M(r, t)) : 0;
3273
3624
  }
3274
- function Xn(e, t, n, r, i, a, o) {
3275
- let s = Zn(n === "width" ? a.width : a.height);
3625
+ function Or(e, t, n, r, i, a, o) {
3626
+ let s = kr(n === "width" ? a.width : a.height);
3276
3627
  if (s !== null) return {
3277
3628
  kind: "cells",
3278
- value: $n(s, n, o, r)
3629
+ value: jr(s, n, o, r)
3279
3630
  };
3280
- let c = Qn(i, n === "width" ? "w" : "h");
3631
+ let c = Ar(i, n === "width" ? "w" : "h");
3281
3632
  if (c !== null) {
3282
3633
  let i = parseFloat(e ? String(e.get(n) ?? "") : t), a = Number.isFinite(i) && Math.abs(i - c) <= c * .3;
3283
3634
  if (a || !Number.isFinite(i)) return {
3284
3635
  kind: "cells",
3285
- value: $n(a ? i : c, n, o, r)
3636
+ value: jr(a ? i : c, n, o, r)
3286
3637
  };
3287
3638
  }
3288
3639
  if (e) {
@@ -3290,7 +3641,7 @@ function Xn(e, t, n, r, i, a, o) {
3290
3641
  if (t == null) return;
3291
3642
  let i = t.toString().trim();
3292
3643
  if (i === "auto") return { kind: "auto" };
3293
- let a = nr(i);
3644
+ let a = Pr(i);
3294
3645
  if (a) return a;
3295
3646
  if (i.endsWith("%")) return {
3296
3647
  kind: "percent",
@@ -3298,22 +3649,22 @@ function Xn(e, t, n, r, i, a, o) {
3298
3649
  };
3299
3650
  if (i.endsWith("px")) return {
3300
3651
  kind: "cells",
3301
- value: p(parseFloat(i), r)
3652
+ value: M(parseFloat(i), r)
3302
3653
  };
3303
3654
  if (i.endsWith("rem")) return {
3304
3655
  kind: "cells",
3305
- value: f(parseFloat(i) / .25)
3656
+ value: j(parseFloat(i) / .25)
3306
3657
  };
3307
- let s = Zn(i);
3658
+ let s = kr(i);
3308
3659
  if (s !== null) return {
3309
3660
  kind: "cells",
3310
- value: $n(s, n, o, r)
3661
+ value: jr(s, n, o, r)
3311
3662
  };
3312
3663
  }
3313
3664
  let l = n === "width" ? a.width : a.height;
3314
3665
  if (l) {
3315
3666
  if (l === "auto") return { kind: "auto" };
3316
- let e = nr(l);
3667
+ let e = Pr(l);
3317
3668
  if (e) return e;
3318
3669
  if (l.endsWith("%")) return {
3319
3670
  kind: "percent",
@@ -3322,7 +3673,7 @@ function Xn(e, t, n, r, i, a, o) {
3322
3673
  let t = parseFloat(l);
3323
3674
  if (Number.isFinite(t)) return {
3324
3675
  kind: "cells",
3325
- value: p(t, r)
3676
+ value: M(t, r)
3326
3677
  };
3327
3678
  }
3328
3679
  let u = n === "width" ? "w" : "h";
@@ -3338,28 +3689,28 @@ function Xn(e, t, n, r, i, a, o) {
3338
3689
  kind: "percent",
3339
3690
  value: 100
3340
3691
  };
3341
- let m = RegExp(`(?:^|[\\s:.[!])${u}-\\[(\\d+(?:\\.\\d+)?)%\\]`).exec(i);
3342
- if (m) return {
3692
+ let f = RegExp(`(?:^|[\\s:.[!])${u}-\\[(\\d+(?:\\.\\d+)?)%\\]`).exec(i);
3693
+ if (f) return {
3343
3694
  kind: "percent",
3344
- value: Number(m[1])
3695
+ value: Number(f[1])
3345
3696
  };
3346
- let h = RegExp(`(?:^|[\\s:.[!])${u}-(\\d+(?:\\.\\d+)?)(?![\\w-/])`).exec(i);
3347
- if (h) return {
3697
+ let p = RegExp(`(?:^|[\\s:.[!])${u}-(\\d+(?:\\.\\d+)?)(?![\\w-/])`).exec(i);
3698
+ if (p) return {
3348
3699
  kind: "cells",
3349
- value: f(Number(h[1]))
3700
+ value: j(Number(p[1]))
3350
3701
  };
3351
- if (!mr(i, u) || t === "auto") return { kind: "auto" };
3702
+ if (!Kr(i, u) || t === "auto") return { kind: "auto" };
3352
3703
  if (t.endsWith("%")) return {
3353
3704
  kind: "percent",
3354
3705
  value: parseFloat(t)
3355
3706
  };
3356
- let g = parseFloat(t);
3357
- if (Number.isFinite(g)) return {
3707
+ let m = parseFloat(t);
3708
+ if (Number.isFinite(m)) return {
3358
3709
  kind: "cells",
3359
- value: p(g, r)
3710
+ value: M(m, r)
3360
3711
  };
3361
3712
  }
3362
- function Zn(e) {
3713
+ function kr(e) {
3363
3714
  let t = /^(-?[\d.]+)((?:[dsl]?v)(?:h|w|min|max)|vi|vb)$/.exec(e.trim());
3364
3715
  if (!t || typeof window > "u") return null;
3365
3716
  let n = parseFloat(t[1]);
@@ -3367,7 +3718,7 @@ function Zn(e) {
3367
3718
  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;
3368
3719
  return n / 100 * o;
3369
3720
  }
3370
- function Qn(e, t) {
3721
+ function Ar(e, t) {
3371
3722
  if (typeof window > "u") return null;
3372
3723
  let n = RegExp(`(?:^|[\\s:.[!])${t}-(screen|[dsl]v[hw])(?![\\w-])`).exec(e);
3373
3724
  if (n) {
@@ -3375,23 +3726,23 @@ function Qn(e, t) {
3375
3726
  return e === "screen" ? t.includes("h") ? window.innerHeight : window.innerWidth : e.endsWith("h") ? window.innerHeight : window.innerWidth;
3376
3727
  }
3377
3728
  let r = RegExp(`(?:^|[\\s:.[!])${t}-\\[(-?[\\d.]+(?:[dsl]?v(?:h|w|min|max)|vi|vb))\\]`).exec(e);
3378
- return r ? Zn(r[1]) : null;
3729
+ return r ? kr(r[1]) : null;
3379
3730
  }
3380
- function $n(e, t, n, r) {
3731
+ function jr(e, t, n, r) {
3381
3732
  let i = t === "width" ? n?.width : n?.height;
3382
- return i && i > 0 ? Math.max(0, Math.floor(e / i)) : p(e, r);
3733
+ return i && i > 0 ? Math.max(0, Math.floor(e / i)) : M(e, r);
3383
3734
  }
3384
- function er(e, t, n, r, i, a, o, s) {
3385
- let c = t.endsWith("width") ? "width" : "height", l = Zn(a.getPropertyValue(t)) ?? Zn(e?.get(t)?.toString().trim() ?? "");
3386
- if (l !== null) return $n(l, c, o, s);
3387
- let u = Qn(r, i);
3735
+ function Mr(e, t, n, r, i, a, o, s) {
3736
+ let c = t.endsWith("width") ? "width" : "height", l = kr(a.getPropertyValue(t)) ?? kr(e?.get(t)?.toString().trim() ?? "");
3737
+ if (l !== null) return jr(l, c, o, s);
3738
+ let u = Ar(r, i);
3388
3739
  if (u === null) return;
3389
3740
  let d = parseFloat(e ? String(e.get(t) ?? "") : n), f = Number.isFinite(d) && Math.abs(d - u) <= u * .3;
3390
- if (!(!f && Number.isFinite(d))) return $n(f ? d : u, c, o, s);
3741
+ if (!(!f && Number.isFinite(d))) return jr(f ? d : u, c, o, s);
3391
3742
  }
3392
- function tr(e, t) {
3743
+ function Nr(e, t) {
3393
3744
  if (!e || e === "auto" || e === "content") return;
3394
- let n = nr(e);
3745
+ let n = Pr(e);
3395
3746
  if (n) return n;
3396
3747
  if (e.endsWith("%")) {
3397
3748
  let t = parseFloat(e);
@@ -3403,30 +3754,30 @@ function tr(e, t) {
3403
3754
  let r = parseFloat(e);
3404
3755
  return Number.isFinite(r) ? {
3405
3756
  kind: "cells",
3406
- value: p(r, t)
3757
+ value: M(r, t)
3407
3758
  } : void 0;
3408
3759
  }
3409
- function nr(e) {
3760
+ function Pr(e) {
3410
3761
  if (e === "min-content") return { kind: "min-content" };
3411
3762
  if (e === "max-content") return { kind: "max-content" };
3412
3763
  if (e === "fit-content") return { kind: "fit-content" };
3413
3764
  }
3414
- function rr(e, t) {
3765
+ function Fr(e, t) {
3415
3766
  let n = e.trim();
3416
3767
  if (!n || n === "none") return { kind: "none" };
3417
3768
  if (n === "subgrid" || n.startsWith("subgrid ")) return { kind: "subgrid" };
3418
3769
  let r = [], i = [], a = [], o = (e) => {
3419
3770
  i.push(a), a = [], r.push(e);
3420
3771
  }, s;
3421
- for (let e of dr(n)) {
3422
- let n = ar(e);
3772
+ for (let e of Ur(n)) {
3773
+ let n = Lr(e);
3423
3774
  if (n) {
3424
3775
  a.push(...n);
3425
3776
  continue;
3426
3777
  }
3427
3778
  let i = e.match(/^repeat\(\s*([^,]+?)\s*,(.*)\)$/s);
3428
3779
  if (i) {
3429
- let e = ir(i[2].trim(), t);
3780
+ let e = Ir(i[2].trim(), t);
3430
3781
  if (e.tracks.length === 0) continue;
3431
3782
  let n = i[1];
3432
3783
  if (n === "auto-fill" || n === "auto-fit") {
@@ -3444,7 +3795,7 @@ function rr(e, t) {
3444
3795
  }
3445
3796
  continue;
3446
3797
  }
3447
- o(cr(e, t));
3798
+ o(Br(e, t));
3448
3799
  }
3449
3800
  if (i.push(a), r.length === 0 && !s) return { kind: "none" };
3450
3801
  let c = {
@@ -3453,26 +3804,26 @@ function rr(e, t) {
3453
3804
  };
3454
3805
  return i.some((e) => e.length > 0) && (c.lineNames = i), s && (c.autoRepeat = s), c;
3455
3806
  }
3456
- function ir(e, t) {
3807
+ function Ir(e, t) {
3457
3808
  let n = [], r = [], i = [];
3458
- for (let a of dr(e)) {
3459
- let e = ar(a);
3809
+ for (let a of Ur(e)) {
3810
+ let e = Lr(a);
3460
3811
  if (e) {
3461
3812
  i.push(...e);
3462
3813
  continue;
3463
3814
  }
3464
- r.push(i), i = [], n.push(cr(a, t));
3815
+ r.push(i), i = [], n.push(Br(a, t));
3465
3816
  }
3466
3817
  return r.push(i), {
3467
3818
  tracks: n,
3468
3819
  lineNames: r
3469
3820
  };
3470
3821
  }
3471
- function ar(e) {
3822
+ function Lr(e) {
3472
3823
  let t = e.match(/^\[(.*)\]$/s);
3473
3824
  return t ? t[1].split(/\s+/).filter((e) => e !== "") : null;
3474
3825
  }
3475
- function or(e) {
3826
+ function Rr(e) {
3476
3827
  let t = [];
3477
3828
  for (let n of e.matchAll(/"([^"]*)"|'([^']*)'/g)) {
3478
3829
  let e = (n[1] ?? n[2] ?? "").trim().split(/\s+/).filter((e) => e !== "");
@@ -3502,23 +3853,23 @@ function or(e) {
3502
3853
  areas: r
3503
3854
  };
3504
3855
  }
3505
- function sr(e, t) {
3506
- let n = dr(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => cr(e, t));
3507
- return n.length > 0 ? n : [fe()];
3856
+ function zr(e, t) {
3857
+ let n = Ur(e.trim()).filter((e) => e !== "" && !e.startsWith("[")).map((e) => Br(e, t));
3858
+ return n.length > 0 ? n : [Me()];
3508
3859
  }
3509
- function cr(e, t) {
3860
+ function Br(e, t) {
3510
3861
  let n = e.match(/^minmax\((.*)\)$/s);
3511
3862
  if (n) {
3512
- let e = ur(n[1]).map((e) => e.trim());
3863
+ let e = Hr(n[1]).map((e) => e.trim());
3513
3864
  return e.length === 2 ? {
3514
- min: lr(e[0], t),
3515
- max: lr(e[1], t)
3865
+ min: Vr(e[0], t),
3866
+ max: Vr(e[1], t)
3516
3867
  } : {
3517
3868
  min: { kind: "auto" },
3518
3869
  max: { kind: "auto" }
3519
3870
  };
3520
3871
  }
3521
- let r = lr(e, t);
3872
+ let r = Vr(e, t);
3522
3873
  return r.kind === "fr" ? {
3523
3874
  min: { kind: "auto" },
3524
3875
  max: r
@@ -3527,13 +3878,13 @@ function cr(e, t) {
3527
3878
  max: r
3528
3879
  };
3529
3880
  }
3530
- function lr(e, t) {
3881
+ function Vr(e, t) {
3531
3882
  if (e === "auto" || e.startsWith("fit-content")) return { kind: "auto" };
3532
3883
  if (e === "min-content") return { kind: "min-content" };
3533
3884
  if (e === "max-content") return { kind: "max-content" };
3534
3885
  let n = e.match(/^(min|max)\((.*)\)$/s);
3535
3886
  if (n) {
3536
- let e = ur(n[2]).map((e) => lr(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
3887
+ let e = Hr(n[2]).map((e) => Vr(e.trim(), t)), r = e.every((e) => e.kind === "cells" || e.kind === "percent" || e.kind === "math");
3537
3888
  return e.length > 0 && r ? {
3538
3889
  kind: "math",
3539
3890
  fn: n[1],
@@ -3557,10 +3908,10 @@ function lr(e, t) {
3557
3908
  let r = parseFloat(e);
3558
3909
  return Number.isFinite(r) ? {
3559
3910
  kind: "cells",
3560
- value: e.endsWith("rem") ? f(r / .25) : p(r, t)
3911
+ value: e.endsWith("rem") ? j(r / .25) : M(r, t)
3561
3912
  } : { kind: "auto" };
3562
3913
  }
3563
- function ur(e) {
3914
+ function Hr(e) {
3564
3915
  let t = [], n = 0, r = 0;
3565
3916
  for (let i = 0; i < e.length; i++) {
3566
3917
  let a = e[i];
@@ -3568,7 +3919,7 @@ function ur(e) {
3568
3919
  }
3569
3920
  return t.push(e.slice(r)), t.filter((e) => e.trim() !== "");
3570
3921
  }
3571
- function dr(e) {
3922
+ function Ur(e) {
3572
3923
  let t = [], n = 0, r = -1;
3573
3924
  for (let i = 0; i < e.length; i++) {
3574
3925
  let a = e[i];
@@ -3576,7 +3927,7 @@ function dr(e) {
3576
3927
  }
3577
3928
  return r !== -1 && t.push(e.slice(r)), t;
3578
3929
  }
3579
- function fr(e) {
3930
+ function Wr(e) {
3580
3931
  let t = e.trim();
3581
3932
  if (!t || t === "auto") return { kind: "auto" };
3582
3933
  let n = !1, r, i;
@@ -3604,16 +3955,16 @@ function fr(e) {
3604
3955
  nth: r
3605
3956
  };
3606
3957
  }
3607
- function pr(e) {
3958
+ function Gr(e) {
3608
3959
  return {
3609
3960
  direction: e.includes("column") ? "column" : "row",
3610
3961
  dense: e.includes("dense")
3611
3962
  };
3612
3963
  }
3613
- function mr(e, t) {
3964
+ function Kr(e, t) {
3614
3965
  return (t === "w" ? /(?:^|[\s:.[!])w-/ : /(?:^|[\s:.[!])h-/).test(e);
3615
3966
  }
3616
- function hr(e, t) {
3967
+ function qr(e, t) {
3617
3968
  return {
3618
3969
  top: $(e.getPropertyValue("padding-top"), t),
3619
3970
  right: $(e.getPropertyValue("padding-right"), t),
@@ -3621,8 +3972,8 @@ function hr(e, t) {
3621
3972
  left: $(e.getPropertyValue("padding-left"), t)
3622
3973
  };
3623
3974
  }
3624
- function gr(e) {
3625
- let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : f(parseFloat(e.getPropertyValue(t)) || 0);
3975
+ function Jr(e) {
3976
+ let t = (t, n) => e.getPropertyValue(n) === "none" ? 0 : j(parseFloat(e.getPropertyValue(t)) || 0);
3626
3977
  return {
3627
3978
  top: t("border-top-width", "border-top-style"),
3628
3979
  right: t("border-right-width", "border-right-style"),
@@ -3632,12 +3983,12 @@ function gr(e) {
3632
3983
  }
3633
3984
  //#endregion
3634
3985
  //#region src/tree.ts
3635
- function _r(e, t, n, r) {
3636
- let i = Tn(e, t, n);
3986
+ function Yr(e, t, n, r) {
3987
+ let i = tr(e, t, n);
3637
3988
  if (i.display === "none") return null;
3638
- let a = Array.from(e.children), o = a.map(Sr), s = e.tagName, c = Nr(s);
3989
+ let a = Array.from(e.children), o = a.map(ei), s = e.tagName, c = di(s);
3639
3990
  if (!o.includes("block") || c) {
3640
- let l = Cr(e, i.tracking, {
3991
+ let l = ti(e, i.tracking, {
3641
3992
  rootFontSizePx: t,
3642
3993
  rootLetterSpacingPx: n?.letterSpacing ?? 0,
3643
3994
  cellMetrics: n,
@@ -3646,12 +3997,12 @@ function _r(e, t, n, r) {
3646
3997
  tabSize: i.tabSize
3647
3998
  }), u = l.chars.join("");
3648
3999
  if (l.boxes.length > 0) {
3649
- let e = Ht();
3650
- E(l.chars, (t, n) => {
4000
+ let e = dn();
4001
+ de(l.chars, (t, n) => {
3651
4002
  l.advances[t] = Math.max(1, J(l.boxes[n], e));
3652
4003
  });
3653
4004
  }
3654
- let d = Or(u, l.advances, i.tracking);
4005
+ let d = oi(u, l.advances, i.tracking);
3655
4006
  if (c && d === 0) {
3656
4007
  if (s === "INPUT") d = Number(e.size) || 20;
3657
4008
  else if (s === "TEXTAREA") d = Number(e.cols) || 20;
@@ -3660,9 +4011,9 @@ function _r(e, t, n, r) {
3660
4011
  d = Math.max(1, ...r.map((e) => e.trim().length));
3661
4012
  }
3662
4013
  }
3663
- let f = u.length > 0 ? kr(u) : 0, p;
4014
+ let f = u.length > 0 ? si(u) : 0, p;
3664
4015
  if (s === "TEXTAREA") {
3665
- let t = e, n = t.value ?? "", a = r?.get(t), o = +!!n.endsWith("\n"), s = a !== void 0 && a > 0 ? v(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);
4016
+ let t = e, n = t.value ?? "", a = r?.get(t), o = +!!n.endsWith("\n"), s = a !== void 0 && a > 0 ? ie(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);
3666
4017
  p = l + Math.max(0, l - 1) * i.lineGap;
3667
4018
  } else p = c ? Math.max(1, f) : f;
3668
4019
  let m = /* @__PURE__ */ new Map(), h = [];
@@ -3672,7 +4023,7 @@ function _r(e, t, n, r) {
3672
4023
  let i = a[e], s = m.get(i);
3673
4024
  if (s) g.push(s);
3674
4025
  else if (o[e] === "out-of-flow") {
3675
- let e = _r(i, t, n, r);
4026
+ let e = Yr(i, t, n, r);
3676
4027
  e && g.push(e);
3677
4028
  }
3678
4029
  }
@@ -3698,7 +4049,7 @@ function _r(e, t, n, r) {
3698
4049
  let l = [];
3699
4050
  for (let e = 0; e < a.length; e++) {
3700
4051
  if (o[e] === "none") continue;
3701
- let i = _r(a[e], t, n, r);
4052
+ let i = Yr(a[e], t, n, r);
3702
4053
  i && l.push(i);
3703
4054
  }
3704
4055
  let u = {
@@ -3717,25 +4068,25 @@ function _r(e, t, n, r) {
3717
4068
  unclampedHeight: 0,
3718
4069
  resolvedPadding: R()
3719
4070
  };
3720
- return Pr(e, u), u;
4071
+ return fi(e, u), u;
3721
4072
  }
3722
- var vr = /* @__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("."));
3723
- function yr(e, t) {
3724
- return t || (vr.has(e.tagName) ? "inline" : "block");
4073
+ var Xr = /* @__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("."));
4074
+ function Zr(e, t) {
4075
+ return t || (Xr.has(e.tagName) ? "inline" : "block");
3725
4076
  }
3726
- function br(e, t) {
3727
- let n = yr(e, t);
4077
+ function Qr(e, t) {
4078
+ let n = Zr(e, t);
3728
4079
  return n === "inline" || n === "contents";
3729
4080
  }
3730
- function xr(e, t) {
3731
- let n = yr(e, t);
4081
+ function $r(e, t) {
4082
+ let n = Zr(e, t);
3732
4083
  return n.startsWith("inline") && n !== "inline";
3733
4084
  }
3734
- function Sr(e) {
4085
+ function ei(e) {
3735
4086
  let t = getComputedStyle(e);
3736
- return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : br(e, t.display) || xr(e, t.display) ? "inline" : "block";
4087
+ return t.display === "none" ? "none" : t.position === "absolute" || t.position === "fixed" ? "out-of-flow" : Qr(e, t.display) || $r(e, t.display) ? "inline" : "block";
3737
4088
  }
3738
- function Cr(e, t, n) {
4089
+ function ti(e, t, n) {
3739
4090
  let r = {
3740
4091
  chars: [],
3741
4092
  advances: [],
@@ -3743,15 +4094,15 @@ function Cr(e, t, n) {
3743
4094
  inlineElements: [],
3744
4095
  boxes: []
3745
4096
  };
3746
- return wr(e, t, n, r), n.preserve ? r : Dr(r);
4097
+ return ni(e, t, n, r), n.preserve ? r : ai(r);
3747
4098
  }
3748
- function wr(e, t, n, r) {
4099
+ function ni(e, t, n, r) {
3749
4100
  let i = () => {
3750
4101
  let e = 0;
3751
4102
  for (let t = r.chars.length - 1; t >= 0 && r.chars[t] !== "\n"; t--) e += r.advances[t];
3752
4103
  return e;
3753
4104
  };
3754
- if (!Nr(e.tagName)) {
4105
+ if (!di(e.tagName)) {
3755
4106
  for (let a of Array.from(e.childNodes)) if (a.nodeType === Node.TEXT_NODE) {
3756
4107
  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);
3757
4108
  else if (e === " ") {
@@ -3767,24 +4118,24 @@ function wr(e, t, n, r) {
3767
4118
  }
3768
4119
  let t = getComputedStyle(e);
3769
4120
  if (t.display === "none" || t.position === "absolute" || t.position === "fixed") continue;
3770
- if (xr(e, t.display)) {
3771
- let t = _r(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
4121
+ if ($r(e, t.display)) {
4122
+ let t = Yr(e, n.rootFontSizePx, n.cellMetrics, n.textareaWidths);
3772
4123
  t && (t.inlineBox = !0, r.chars.push(""), r.advances.push(1), r.boxes.push(t));
3773
4124
  continue;
3774
4125
  }
3775
- if (!br(e, t.display)) {
3776
- Ar(e);
4126
+ if (!Qr(e, t.display)) {
4127
+ ci(e);
3777
4128
  continue;
3778
4129
  }
3779
- let i = Un(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = Tr(t.paddingLeft, n.rootFontSizePx), s = Tr(t.paddingRight, n.rootFontSizePx);
4130
+ let i = br(t.letterSpacing, parseFloat(t.fontSize) || n.rootFontSizePx, n.rootLetterSpacingPx), o = ri(t.paddingLeft, n.rootFontSizePx), s = ri(t.paddingRight, n.rootFontSizePx);
3780
4131
  r.inlineElements.push({
3781
4132
  element: e,
3782
4133
  tracking: i,
3783
4134
  padLeft: o,
3784
4135
  padRight: s,
3785
- insets: t.position === "static" ? null : Er(t, n.rootFontSizePx),
4136
+ insets: t.position === "static" ? null : ii(t, n.rootFontSizePx),
3786
4137
  color: t.color,
3787
- backgroundColor: Dn(t.backgroundColor) ? void 0 : t.backgroundColor,
4138
+ backgroundColor: rr(t.backgroundColor) ? void 0 : t.backgroundColor,
3788
4139
  fontWeight: t.fontWeight,
3789
4140
  fontStyle: t.fontStyle,
3790
4141
  textDecorationLine: t.textDecorationLine
@@ -3792,22 +4143,22 @@ function wr(e, t, n, r) {
3792
4143
  let c = r.inlineElements.length - 1;
3793
4144
  for (let e = 0; e < o; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
3794
4145
  let l = r.chars.length;
3795
- wr(e, i, n, r);
4146
+ ni(e, i, n, r);
3796
4147
  for (let e = l; e < r.chars.length; e++) r.inlineIndex[e] === void 0 && (r.inlineIndex[e] = c);
3797
4148
  for (let e = 0; e < s; e++) r.inlineIndex[r.chars.length] = c, r.chars.push("⁠"), r.advances.push(1);
3798
4149
  }
3799
4150
  }
3800
4151
  }
3801
- function Tr(e, t) {
4152
+ function ri(e, t) {
3802
4153
  if (!e || e.endsWith("%")) return 0;
3803
4154
  let n = parseFloat(e);
3804
- return Number.isFinite(n) ? Math.max(0, p(n, t)) : 0;
4155
+ return Number.isFinite(n) ? Math.max(0, M(n, t)) : 0;
3805
4156
  }
3806
- function Er(e, t) {
4157
+ function ii(e, t) {
3807
4158
  let n = (e) => {
3808
4159
  if (!e || e === "auto" || e.endsWith("%")) return null;
3809
4160
  let n = parseFloat(e);
3810
- return Number.isFinite(n) ? p(n, t) : null;
4161
+ return Number.isFinite(n) ? M(n, t) : null;
3811
4162
  };
3812
4163
  return {
3813
4164
  top: n(e.top),
@@ -3816,7 +4167,7 @@ function Er(e, t) {
3816
4167
  left: n(e.left)
3817
4168
  };
3818
4169
  }
3819
- function Dr(e) {
4170
+ function ai(e) {
3820
4171
  let t = [], n = [], r = [], i = () => {
3821
4172
  let e = t.length;
3822
4173
  for (; e > 0 && t[e - 1] !== "\n";) e--;
@@ -3841,42 +4192,47 @@ function Dr(e) {
3841
4192
  boxes: e.boxes
3842
4193
  };
3843
4194
  }
3844
- function Or(e, t, n) {
4195
+ function oi(e, t, n) {
3845
4196
  let r = 0, i = 0;
3846
- for (let a = 0; a <= e.length; a++) (a === e.length || e[a] === "\n") && (r = Math.max(r, C(i, a, t, n)), i = a + 1);
4197
+ 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);
3847
4198
  return r;
3848
4199
  }
3849
- function kr(e) {
3850
- return b(e).length;
4200
+ function si(e) {
4201
+ return oe(e).length;
3851
4202
  }
3852
- function Ar(e) {
3853
- at(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.");
4203
+ function ci(e) {
4204
+ Dt(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.");
3854
4205
  }
3855
- function jr(e) {
4206
+ function li(e) {
3856
4207
  return Array.from(e.childNodes).some((e) => e.nodeType === Node.TEXT_NODE && /[^ \t\r\n\f]/.test(e.textContent ?? ""));
3857
4208
  }
3858
- var Mr = "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>).";
3859
- function Nr(e) {
4209
+ var ui = "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>).";
4210
+ function di(e) {
3860
4211
  return e === "INPUT" || e === "SELECT" || e === "TEXTAREA";
3861
4212
  }
3862
- function Pr(e, t) {
3863
- jr(e) && (t.droppedText = !0, at(e, Mr));
4213
+ function fi(e, t) {
4214
+ li(e) && (t.droppedText = !0, Dt(e, ui));
3864
4215
  }
3865
4216
  //#endregion
3866
4217
  //#region src/element.ts
3867
- var Fr = "\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", Ir = "grid", Lr = [
4218
+ var pi = "\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", mi = "grid", hi = [
3868
4219
  "pointerover",
3869
4220
  "pointerleave",
4221
+ "pointerdown",
4222
+ "pointerup",
4223
+ "pointercancel",
4224
+ "keydown",
4225
+ "keyup",
3870
4226
  "focusin",
3871
4227
  "focusout",
3872
4228
  "input",
3873
4229
  "change"
3874
- ], Rr = typeof HTMLElement > "u" ? class {} : HTMLElement, zr = class e extends Rr {
4230
+ ], gi = /^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/, _i = 3e4, vi = typeof HTMLElement > "u" ? class {} : HTMLElement, yi = class e extends vi {
3875
4231
  static observedAttributes = ["select"];
3876
4232
  static #e = /* @__PURE__ */ new Set();
3877
4233
  static #t = null;
3878
4234
  static #n = () => {
3879
- for (let t of e.#e) t.#y();
4235
+ for (let t of e.#e) t.#H();
3880
4236
  };
3881
4237
  static #r(t) {
3882
4238
  t instanceof HTMLLinkElement && t.rel === "stylesheet" && !t.sheet && t.addEventListener("load", e.#n, { once: !0 });
@@ -3906,10 +4262,10 @@ var Fr = "\n<style>\n :host { display: block; position: relative; contain: layo
3906
4262
  #f = null;
3907
4263
  #p = null;
3908
4264
  constructor() {
3909
- super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = Fr, 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);
4265
+ super(), this.#o = this.attachShadow({ mode: "open" }), this.#o.innerHTML = pi, 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);
3910
4266
  }
3911
4267
  connectedCallback() {
3912
- this.hasAttribute("select") || this.setAttribute("select", Ir), this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#y()), this.#l.observe(this), this.#l.observe(this.#c), window.addEventListener("resize", this.#h), this.#u = new MutationObserver(() => this.#y()), this.#u.observe(this, {
4268
+ this.hasAttribute("select") || this.setAttribute("select", mi), this.#c.parentNode !== this && this.appendChild(this.#c), this.#l = new ResizeObserver(() => this.#H()), this.#l.observe(this), this.#l.observe(this.#c), window.addEventListener("resize", this.#R), this.#u = new MutationObserver(() => this.#H()), this.#u.observe(this, {
3913
4269
  childList: !0,
3914
4270
  subtree: !0,
3915
4271
  characterData: !0,
@@ -3921,41 +4277,131 @@ var Fr = "\n<style>\n :host { display: block; position: relative; contain: layo
3921
4277
  "rowspan",
3922
4278
  "span"
3923
4279
  ]
3924
- }), document.fonts?.ready.then(this.#g).catch((e) => {
4280
+ }), document.fonts?.ready.then(this.#z).catch((e) => {
3925
4281
  console.warn("[monowind] document.fonts.ready failed:", e);
3926
- }), document.fonts?.addEventListener("loadingdone", this.#g);
3927
- for (let e of Lr) this.addEventListener(e, this.#m);
3928
- e.#i(this), this.#y();
4282
+ }), document.fonts?.addEventListener("loadingdone", this.#z);
4283
+ for (let e of hi) this.addEventListener(e, this.#L);
4284
+ this.addEventListener("transitionrun", this.#P), this.addEventListener("transitionend", this.#F), this.addEventListener("transitioncancel", this.#F), this.addEventListener("pointermove", this.#w), this.addEventListener("pointerleave", this.#T), this.addEventListener("pointerdown", this.#E), window.addEventListener("pointerup", this.#D), window.addEventListener("pointercancel", this.#D), document.addEventListener("scroll", this.#O, {
4285
+ capture: !0,
4286
+ passive: !0
4287
+ }), e.#i(this), this.#H();
3929
4288
  }
3930
4289
  disconnectedCallback() {
3931
- window.removeEventListener("resize", this.#h), this.#l?.disconnect(), this.#u?.disconnect(), this.#l = null, this.#u = null, document.fonts?.removeEventListener("loadingdone", this.#g);
3932
- for (let e of Lr) this.removeEventListener(e, this.#m);
3933
- e.#a(this);
4290
+ window.removeEventListener("resize", this.#R), this.#l?.disconnect(), this.#u?.disconnect(), this.#l = null, this.#u = null, document.fonts?.removeEventListener("loadingdone", this.#z);
4291
+ for (let e of hi) this.removeEventListener(e, this.#L);
4292
+ this.removeEventListener("transitionrun", this.#P), this.removeEventListener("transitionend", this.#F), this.removeEventListener("transitioncancel", this.#F), this.#j = 0, this.removeEventListener("pointermove", this.#w), this.removeEventListener("pointerleave", this.#T), this.removeEventListener("pointerdown", this.#E), window.removeEventListener("pointerup", this.#D), window.removeEventListener("pointercancel", this.#D), document.removeEventListener("scroll", this.#O, { capture: !0 }), this.#y = null, this.#g = null, this.#_ = !1, this.#v = !1, this.#k(), e.#a(this);
4293
+ }
4294
+ #m = /* @__PURE__ */ new Set();
4295
+ #h = /* @__PURE__ */ new Set();
4296
+ #g = null;
4297
+ #_ = !1;
4298
+ #v = !1;
4299
+ #y = null;
4300
+ #b = NaN;
4301
+ #x = NaN;
4302
+ #S = null;
4303
+ static #C = typeof matchMedia > "u" ? null : matchMedia("(hover: hover)");
4304
+ #w = (e) => {
4305
+ let { clientX: t, clientY: n } = e;
4306
+ this.#y = {
4307
+ x: t,
4308
+ y: n
4309
+ };
4310
+ let r = this.#S, i = this.#f;
4311
+ if (r && i) {
4312
+ let e = Math.floor((t - r.left) / i.width), a = Math.floor((n - r.top) / i.height);
4313
+ if (e === this.#b && a === this.#x) return;
4314
+ }
4315
+ this.#k();
4316
+ };
4317
+ #T = () => {
4318
+ this.#y = null, this.#k();
4319
+ };
4320
+ #E = (e) => {
4321
+ let t = e;
4322
+ !t.isPrimary || t.button !== 0 || (this.#y = {
4323
+ x: t.clientX,
4324
+ y: t.clientY
4325
+ }, this.#_ = !0, this.#k(!0));
4326
+ };
4327
+ #D = (e) => {
4328
+ e.isPrimary && (!this.#_ && !this.#g || (this.#_ = !1, this.#g = null, this.#k(), this.#v && this.#H()));
4329
+ };
4330
+ #O = () => {
4331
+ this.#y && (this.#S = null, this.#k());
4332
+ };
4333
+ #k(t = !1) {
4334
+ let n = this.#p, r = this.#f, i = [];
4335
+ if (this.#y && n && r && this.isConnected && this.getAttribute("select") === "grid" && (this.#_ || e.#C?.matches)) {
4336
+ if (!this.#S) {
4337
+ let e = this.#s.getBoundingClientRect();
4338
+ this.#S = {
4339
+ left: e.left,
4340
+ top: e.top
4341
+ };
4342
+ }
4343
+ this.#b = Math.floor((this.#y.x - this.#S.left) / r.width), this.#x = Math.floor((this.#y.y - this.#S.top) / r.height), i = A(n, this.#b, this.#x);
4344
+ } else this.#b = NaN, this.#x = NaN;
4345
+ let a = i.at(-1) ?? null;
4346
+ t && (this.#g = a);
4347
+ let o = e.#C?.matches ? i : [], s = this.#g ? i.indexOf(this.#g) : -1, c = s >= 0 ? i.slice(0, s + 1) : [], l = this.#A("data-mw-hover", this.#m, o);
4348
+ l = this.#A("data-mw-active", this.#h, c) || l;
4349
+ let u = a ? getComputedStyle(a).cursor : "";
4350
+ this.#s.style.cursor = u === "auto" ? "" : u, l && this.isConnected && this.#H();
4351
+ }
4352
+ #A(e, t, n) {
4353
+ let r = !1, i = new Set(n);
4354
+ for (let n of t) i.has(n) || (n.removeAttribute(e), r = !0);
4355
+ for (let n of i) t.has(n) || (n.setAttribute(e, ""), r = !0);
4356
+ t.clear();
4357
+ for (let e of i) t.add(e);
4358
+ return r;
4359
+ }
4360
+ #j = 0;
4361
+ #M = !1;
4362
+ #N = 0;
4363
+ #P = (e) => {
4364
+ gi.test(e.propertyName) && (this.#j++, this.#N = performance.now(), this.#I());
4365
+ };
4366
+ #F = (e) => {
4367
+ gi.test(e.propertyName) && (this.#j = Math.max(0, this.#j - 1));
4368
+ };
4369
+ #I() {
4370
+ if (this.#M) return;
4371
+ this.#M = !0;
4372
+ let e = () => {
4373
+ if (!this.isConnected || this.#j === 0 && !a() || performance.now() - this.#N > _i) {
4374
+ this.#M = !1, this.#j = 0, this.#H();
4375
+ return;
4376
+ }
4377
+ this.#V(), requestAnimationFrame(e);
4378
+ };
4379
+ requestAnimationFrame(e);
3934
4380
  }
3935
- #m = (e) => {
4381
+ #L = (e) => {
3936
4382
  if ((e.type === "focusin" || e.type === "focusout") && e.target instanceof HTMLSelectElement) {
3937
- this.#v();
4383
+ this.#V();
3938
4384
  return;
3939
4385
  }
3940
- this.#y();
4386
+ this.#H();
3941
4387
  };
3942
4388
  attributeChangedCallback(e, t, n) {
3943
4389
  if (e === "select" && n !== "text" && n !== "grid") {
3944
- n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, this), this.setAttribute("select", Ir);
4390
+ n !== null && console.warn(`[monowind] Ignoring unrecognized select="${n}". Expected "grid" (default) or "text".`, this), this.setAttribute("select", mi);
3945
4391
  return;
3946
4392
  }
3947
- this.#y();
4393
+ e === "select" && this.#k(), this.#H();
3948
4394
  }
3949
4395
  toPlainText() {
3950
- return this.#d && this.#b(), this.#p ? sn(this.#p) : "";
4396
+ return this.#d && this.#U(), this.#p ? kn(this.#p) : "";
3951
4397
  }
3952
- #h = () => {
3953
- this.#y();
4398
+ #R = () => {
4399
+ this.#H();
3954
4400
  };
3955
- #g = () => {
3956
- requestAnimationFrame(() => this.#y());
4401
+ #z = () => {
4402
+ requestAnimationFrame(() => this.#H());
3957
4403
  };
3958
- #_() {
4404
+ #B() {
3959
4405
  let e = document.activeElement;
3960
4406
  if (!(e instanceof HTMLSelectElement) || !this.contains(e)) return !1;
3961
4407
  try {
@@ -3964,23 +4410,23 @@ var Fr = "\n<style>\n :host { display: block; position: relative; contain: layo
3964
4410
  return !1;
3965
4411
  }
3966
4412
  }
3967
- #v() {
4413
+ #V() {
3968
4414
  try {
3969
- this.#b();
4415
+ this.#U();
3970
4416
  } catch (e) {
3971
4417
  console.error("[monowind] layout failed:", e);
3972
4418
  }
3973
4419
  }
3974
- #y() {
4420
+ #H() {
3975
4421
  this.#d || (this.#d = !0, requestAnimationFrame(() => {
3976
- if (this.#d = !1, this.#_()) {
3977
- this.#y();
4422
+ if (this.#d = !1, this.#B()) {
4423
+ this.#H();
3978
4424
  return;
3979
4425
  }
3980
- this.#v();
4426
+ this.#V();
3981
4427
  }));
3982
4428
  }
3983
- #b() {
4429
+ #U() {
3984
4430
  if (!this.isConnected) return;
3985
4431
  let e = /* @__PURE__ */ new Map(), t = getComputedStyle(this).getPropertyValue("--mw-cw").trim(), n = parseFloat(t);
3986
4432
  if (Number.isFinite(n) && n > 0) for (let t of this.querySelectorAll("textarea")) {
@@ -3990,23 +4436,23 @@ var Fr = "\n<style>\n :host { display: block; position: relative; contain: layo
3990
4436
  this.setAttribute("measuring", "");
3991
4437
  try {
3992
4438
  this.#c.parentNode !== this && this.appendChild(this.#c);
3993
- let t = h(this, this.#c), n = this.#f;
4439
+ let t = te(this, this.#c), n = this.#f;
3994
4440
  (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;
3995
4441
  let r = getComputedStyle(this), i = (parseFloat(r.paddingLeft) || 0) + (parseFloat(r.paddingRight) || 0), a = Math.max(0, Math.floor((this.clientWidth - i) / t.width));
3996
4442
  if (a === 0) return;
3997
- let o = g(), s = [];
4443
+ let o = ne(), s = [];
3998
4444
  for (let n of Array.from(this.children)) {
3999
4445
  if (n === this.#c) continue;
4000
- let r = _r(n, o, t, e);
4446
+ let r = Yr(n, o, t, e);
4001
4447
  r && s.push(r);
4002
4448
  }
4003
- if (jr(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${Mr}`, this), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), s.length === 0) {
4449
+ if (li(this) ? (this.hasAttribute("data-mw-dropped-text") || console.warn(`[monowind] ${ui}`, this), this.setAttribute("data-mw-dropped-text", "")) : this.removeAttribute("data-mw-dropped-text"), s.length === 0) {
4004
4450
  this.#s.replaceChildren(), this.#p = null, this.setAttribute("data-mw-ready", "");
4005
4451
  return;
4006
4452
  }
4007
4453
  let c = {
4008
4454
  source: this,
4009
- style: de(),
4455
+ style: je(),
4010
4456
  children: s,
4011
4457
  text: "",
4012
4458
  intrinsicWidth: 0,
@@ -4019,19 +4465,19 @@ var Fr = "\n<style>\n :host { display: block; position: relative; contain: layo
4019
4465
  },
4020
4466
  unclampedHeight: 0,
4021
4467
  resolvedPadding: R()
4022
- }, { height: l } = Bt(c, a);
4023
- bn(c), vn(c, this.#s), this.#p = c;
4468
+ }, { height: l } = ln(c, a);
4469
+ Xn(c), this.#v = !Hn(c, this.#s, this.#_), this.#p = c;
4024
4470
  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`;
4025
4471
  this.style.height !== d && (this.style.height = d), this.hasAttribute("data-mw-ready") || this.setAttribute("data-mw-ready", "");
4026
4472
  } finally {
4027
- this.removeAttribute("measuring"), this.#u?.takeRecords();
4473
+ this.setAttribute("settling", ""), this.removeAttribute("measuring"), getComputedStyle(this).transitionProperty, this.removeAttribute("settling"), this.#u?.takeRecords(), i(this) && (a() ? (this.#N = performance.now(), this.#I()) : this.#H()), this.#S = null, this.#y && this.#k();
4028
4474
  }
4029
4475
  }
4030
4476
  };
4031
- function Br() {
4032
- typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", zr);
4477
+ function bi() {
4478
+ typeof customElements > "u" || customElements.get("mono-wind") || customElements.define("mono-wind", yi);
4033
4479
  }
4034
4480
  //#endregion
4035
- export { zr as MonoWindElement, Br as defineMonoWind, $e as multicolLines, sn as renderPlainText, _ as wrapLines };
4481
+ export { yi as MonoWindElement, bi as defineMonoWind, xt as multicolLines, kn as renderPlainText, re as wrapLines };
4036
4482
 
4037
4483
  //# sourceMappingURL=index.js.map