@variance-authority/presentation 0.1.0

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/LICENSE +21 -0
  3. package/README.md +319 -0
  4. package/dist/alignment.d.ts +9 -0
  5. package/dist/alignment.js +100 -0
  6. package/dist/alignment.js.map +1 -0
  7. package/dist/analyze.d.ts +20 -0
  8. package/dist/analyze.js +132 -0
  9. package/dist/analyze.js.map +1 -0
  10. package/dist/browser-agent-entry.d.ts +2 -0
  11. package/dist/browser-agent-entry.js +8 -0
  12. package/dist/browser-agent-entry.js.map +1 -0
  13. package/dist/browser-agent.bundle.js +3587 -0
  14. package/dist/browser-agent.d.ts +37 -0
  15. package/dist/browser-agent.js +130 -0
  16. package/dist/browser-agent.js.map +1 -0
  17. package/dist/bundle.d.ts +3 -0
  18. package/dist/bundle.js +20 -0
  19. package/dist/bundle.js.map +1 -0
  20. package/dist/compare.d.ts +4 -0
  21. package/dist/compare.js +49 -0
  22. package/dist/compare.js.map +1 -0
  23. package/dist/findings.d.ts +5 -0
  24. package/dist/findings.js +285 -0
  25. package/dist/findings.js.map +1 -0
  26. package/dist/focus.d.ts +17 -0
  27. package/dist/focus.js +84 -0
  28. package/dist/focus.js.map +1 -0
  29. package/dist/graph.d.ts +11 -0
  30. package/dist/graph.js +145 -0
  31. package/dist/graph.js.map +1 -0
  32. package/dist/hierarchy.d.ts +4 -0
  33. package/dist/hierarchy.js +171 -0
  34. package/dist/hierarchy.js.map +1 -0
  35. package/dist/index.d.ts +12 -0
  36. package/dist/index.js +8 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/math.d.ts +24 -0
  39. package/dist/math.js +124 -0
  40. package/dist/math.js.map +1 -0
  41. package/dist/measure.d.ts +15 -0
  42. package/dist/measure.js +216 -0
  43. package/dist/measure.js.map +1 -0
  44. package/dist/model.d.ts +346 -0
  45. package/dist/model.js +2 -0
  46. package/dist/model.js.map +1 -0
  47. package/dist/paint.d.ts +12 -0
  48. package/dist/paint.js +192 -0
  49. package/dist/paint.js.map +1 -0
  50. package/dist/patterns.d.ts +10 -0
  51. package/dist/patterns.js +148 -0
  52. package/dist/patterns.js.map +1 -0
  53. package/dist/playwright.d.ts +27 -0
  54. package/dist/playwright.js +108 -0
  55. package/dist/playwright.js.map +1 -0
  56. package/dist/report.d.ts +17 -0
  57. package/dist/report.js +126 -0
  58. package/dist/report.js.map +1 -0
  59. package/dist/spacing.d.ts +4 -0
  60. package/dist/spacing.js +112 -0
  61. package/dist/spacing.js.map +1 -0
  62. package/dist/telemetry.d.ts +4 -0
  63. package/dist/telemetry.js +73 -0
  64. package/dist/telemetry.js.map +1 -0
  65. package/mark.svg +30 -0
  66. package/package.json +62 -0
  67. package/skills/variance-presentation/SKILL.md +463 -0
@@ -0,0 +1,3587 @@
1
+ "use strict";
2
+ (() => {
3
+ // packages/core/dist/format/canonical.js
4
+ function canonicalize(value) {
5
+ if (value === null)
6
+ return "null";
7
+ switch (typeof value) {
8
+ case "boolean":
9
+ return value ? "true" : "false";
10
+ case "number":
11
+ return canonicalNumber(value);
12
+ case "string":
13
+ return JSON.stringify(value);
14
+ }
15
+ if (Array.isArray(value)) {
16
+ return `[${value.map((item) => canonicalize(item)).join(",")}]`;
17
+ }
18
+ const record2 = value;
19
+ const parts = [];
20
+ for (const key of Object.keys(record2).sort()) {
21
+ const member = record2[key];
22
+ if (member === void 0)
23
+ continue;
24
+ parts.push(`${JSON.stringify(key)}:${canonicalize(member)}`);
25
+ }
26
+ return `{${parts.join(",")}}`;
27
+ }
28
+ function canonicalNumber(value) {
29
+ if (!Number.isFinite(value)) {
30
+ throw new RangeError(`canonical serialization requires a finite number, received ${value}`);
31
+ }
32
+ if (Object.is(value, -0))
33
+ return "0";
34
+ return String(value);
35
+ }
36
+
37
+ // packages/core/dist/format/sha256.js
38
+ var K = new Uint32Array([
39
+ 1116352408,
40
+ 1899447441,
41
+ 3049323471,
42
+ 3921009573,
43
+ 961987163,
44
+ 1508970993,
45
+ 2453635748,
46
+ 2870763221,
47
+ 3624381080,
48
+ 310598401,
49
+ 607225278,
50
+ 1426881987,
51
+ 1925078388,
52
+ 2162078206,
53
+ 2614888103,
54
+ 3248222580,
55
+ 3835390401,
56
+ 4022224774,
57
+ 264347078,
58
+ 604807628,
59
+ 770255983,
60
+ 1249150122,
61
+ 1555081692,
62
+ 1996064986,
63
+ 2554220882,
64
+ 2821834349,
65
+ 2952996808,
66
+ 3210313671,
67
+ 3336571891,
68
+ 3584528711,
69
+ 113926993,
70
+ 338241895,
71
+ 666307205,
72
+ 773529912,
73
+ 1294757372,
74
+ 1396182291,
75
+ 1695183700,
76
+ 1986661051,
77
+ 2177026350,
78
+ 2456956037,
79
+ 2730485921,
80
+ 2820302411,
81
+ 3259730800,
82
+ 3345764771,
83
+ 3516065817,
84
+ 3600352804,
85
+ 4094571909,
86
+ 275423344,
87
+ 430227734,
88
+ 506948616,
89
+ 659060556,
90
+ 883997877,
91
+ 958139571,
92
+ 1322822218,
93
+ 1537002063,
94
+ 1747873779,
95
+ 1955562222,
96
+ 2024104815,
97
+ 2227730452,
98
+ 2361852424,
99
+ 2428436474,
100
+ 2756734187,
101
+ 3204031479,
102
+ 3329325298
103
+ ]);
104
+ var INITIAL = new Uint32Array([
105
+ 1779033703,
106
+ 3144134277,
107
+ 1013904242,
108
+ 2773480762,
109
+ 1359893119,
110
+ 2600822924,
111
+ 528734635,
112
+ 1541459225
113
+ ]);
114
+ function sha256Hex(input) {
115
+ return sha256HexBytes(utf8Bytes(input));
116
+ }
117
+ function sha256HexBytes(bytes) {
118
+ const state = new Uint32Array(INITIAL);
119
+ const bitLength = bytes.length * 8;
120
+ const paddedLength = Math.ceil((bytes.length + 9) / 64) * 64;
121
+ const padded = new Uint8Array(paddedLength);
122
+ padded.set(bytes);
123
+ padded[bytes.length] = 128;
124
+ const view = new DataView(padded.buffer);
125
+ view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296), false);
126
+ view.setUint32(paddedLength - 4, bitLength >>> 0, false);
127
+ const w = new Uint32Array(64);
128
+ for (let offset = 0; offset < paddedLength; offset += 64) {
129
+ for (let i = 0; i < 16; i += 1) {
130
+ w[i] = view.getUint32(offset + i * 4, false);
131
+ }
132
+ for (let i = 16; i < 64; i += 1) {
133
+ const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ w[i - 15] >>> 3;
134
+ const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ w[i - 2] >>> 10;
135
+ w[i] = w[i - 16] + s0 + w[i - 7] + s1 >>> 0;
136
+ }
137
+ let [a, b, c, d, e, f, g, h] = state;
138
+ for (let i = 0; i < 64; i += 1) {
139
+ const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
140
+ const ch = e & f ^ ~e & g;
141
+ const temp1 = h + S1 + ch + K[i] + w[i] >>> 0;
142
+ const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
143
+ const maj = a & b ^ a & c ^ b & c;
144
+ const temp2 = S0 + maj >>> 0;
145
+ h = g;
146
+ g = f;
147
+ f = e;
148
+ e = d + temp1 >>> 0;
149
+ d = c;
150
+ c = b;
151
+ b = a;
152
+ a = temp1 + temp2 >>> 0;
153
+ }
154
+ state[0] = state[0] + a >>> 0;
155
+ state[1] = state[1] + b >>> 0;
156
+ state[2] = state[2] + c >>> 0;
157
+ state[3] = state[3] + d >>> 0;
158
+ state[4] = state[4] + e >>> 0;
159
+ state[5] = state[5] + f >>> 0;
160
+ state[6] = state[6] + g >>> 0;
161
+ state[7] = state[7] + h >>> 0;
162
+ }
163
+ let hex = "";
164
+ for (const word of state) {
165
+ hex += word.toString(16).padStart(8, "0");
166
+ }
167
+ return hex;
168
+ }
169
+ function rotr(value, bits) {
170
+ return (value >>> bits | value << 32 - bits) >>> 0;
171
+ }
172
+ function utf8Bytes(input) {
173
+ const bytes = [];
174
+ for (let i = 0; i < input.length; i += 1) {
175
+ let code = input.charCodeAt(i);
176
+ if (code >= 55296 && code <= 56319) {
177
+ const next = input.charCodeAt(i + 1);
178
+ if (next >= 56320 && next <= 57343) {
179
+ code = 65536 + (code - 55296 << 10) + (next - 56320);
180
+ i += 1;
181
+ } else {
182
+ code = 65533;
183
+ }
184
+ } else if (code >= 56320 && code <= 57343) {
185
+ code = 65533;
186
+ }
187
+ if (code < 128) {
188
+ bytes.push(code);
189
+ } else if (code < 2048) {
190
+ bytes.push(192 | code >> 6, 128 | code & 63);
191
+ } else if (code < 65536) {
192
+ bytes.push(224 | code >> 12, 128 | code >> 6 & 63, 128 | code & 63);
193
+ } else {
194
+ bytes.push(240 | code >> 18, 128 | code >> 12 & 63, 128 | code >> 6 & 63, 128 | code & 63);
195
+ }
196
+ }
197
+ return Uint8Array.from(bytes);
198
+ }
199
+
200
+ // packages/core/dist/format/hash.js
201
+ var PREFIX = "v1";
202
+ var HEX_LENGTH = 32;
203
+ function digestString(input) {
204
+ return `${PREFIX}:${sha256Hex(input).slice(0, HEX_LENGTH)}`;
205
+ }
206
+ function digestValue(value) {
207
+ return digestString(canonicalize(value));
208
+ }
209
+
210
+ // packages/core/dist/format/profile.js
211
+ var JSDOM_PROFILE = {
212
+ id: "jsdom",
213
+ ariaTree: true,
214
+ declaredStyle: true,
215
+ computedStyle: false,
216
+ layout: false,
217
+ raster: false
218
+ };
219
+ var CHROMIUM_PROFILE = {
220
+ id: "chromium",
221
+ ariaTree: true,
222
+ declaredStyle: true,
223
+ computedStyle: true,
224
+ layout: true,
225
+ raster: true
226
+ };
227
+ function tierOfProfile(profile) {
228
+ if (profile.layout || profile.computedStyle)
229
+ return "layout";
230
+ if (profile.declaredStyle || profile.ariaTree)
231
+ return "semantic";
232
+ return "reachability";
233
+ }
234
+
235
+ // packages/core/dist/format/tier.js
236
+ var TIER_ORDER = {
237
+ reachability: 0,
238
+ semantic: 1,
239
+ layout: 2,
240
+ raster: 3
241
+ };
242
+ function tierReaches(available, needs) {
243
+ return TIER_ORDER[needs] <= TIER_ORDER[available];
244
+ }
245
+
246
+ // packages/core/dist/format/stabilize.js
247
+ var holdAnimations = {
248
+ id: "hold-animations",
249
+ trick: "hold",
250
+ needs: "layout",
251
+ governs: "animations",
252
+ because: "animations settled by the browser: finite fast-forwarded, infinite reset",
253
+ screenshot: { animations: "disabled" }
254
+ };
255
+ var pinAnimations = {
256
+ id: "pin-animations",
257
+ trick: "hold",
258
+ needs: "layout",
259
+ governs: "animations",
260
+ because: "animations pinned at their first frame, which is not where a user sees them",
261
+ css: "*,*::before,*::after{animation-play-state:paused !important;animation-delay:-0.0001s !important;transition-duration:0s !important;transition-delay:0s !important;scroll-behavior:auto !important}"
262
+ };
263
+ var hideCaret = {
264
+ id: "hide-caret",
265
+ trick: "support",
266
+ // A caret paints and does not lay out, so a tier that never rasterizes cannot
267
+ // see it and must not pay to hide it.
268
+ needs: "raster",
269
+ governs: "caret",
270
+ because: "text caret hidden, because it blinks on its own schedule",
271
+ screenshot: { caret: "hide" }
272
+ };
273
+ var hideScrollbars = {
274
+ id: "hide-scrollbars",
275
+ trick: "support",
276
+ needs: "layout",
277
+ governs: "scrollbars",
278
+ because: "scrollbars hidden, removing a platform and preference difference \u2014 and their width",
279
+ css: "*{scrollbar-width:none !important}\n*::-webkit-scrollbar{display:none !important}"
280
+ };
281
+ var hidePresentationalImages = {
282
+ id: "hide-presentational-images",
283
+ trick: "support",
284
+ // `layout` rather than `raster`, and the difference is whether it runs at all.
285
+ // A raster-tier trick is filtered out of every *collection* — `tierOfProfile`
286
+ // never returns `raster` — so it would only reach a page through a renderer
287
+ // option, which is not where an operator configures their suite. A collection
288
+ // sheet is in force when the document is serialized, so hiding it here is what
289
+ // makes the pixels absent from the render.
290
+ needs: "layout",
291
+ governs: "presentational-images",
292
+ because: "images the page marked decorative hidden, keeping their boxes \u2014 real changes inside them are not reported",
293
+ css: 'img[role="presentation"],img[alt=""],[role="presentation"] img,[role="none"] img{visibility:hidden !important}'
294
+ };
295
+ var waitForFonts = {
296
+ id: "wait-for-fonts",
297
+ trick: "wait",
298
+ needs: "layout",
299
+ governs: "fonts",
300
+ because: "waited for web fonts, whose advances change every metric on the page",
301
+ // Written without a module-scope helper on purpose: a settle closure is
302
+ // shipped to a page as source text, so anything it names by identifier is a
303
+ // `ReferenceError` on the far side. Types are erased and therefore free.
304
+ settle: async (target) => {
305
+ await target.evaluate(async () => {
306
+ const view = globalThis;
307
+ await view.document.fonts?.ready;
308
+ });
309
+ }
310
+ };
311
+ var waitForImages = {
312
+ id: "wait-for-images",
313
+ trick: "wait",
314
+ needs: "layout",
315
+ governs: "images",
316
+ because: "waited for images to decode, since their intrinsic size participates in layout, and asked for the ones the browser had deferred",
317
+ settle: async (target) => {
318
+ await target.evaluate(async () => {
319
+ const view = globalThis;
320
+ const pending = Array.from(view.document.images).filter((image) => !image.complete);
321
+ const arrived = Promise.all(pending.map((image) => new Promise((resolve) => {
322
+ image.addEventListener("load", () => resolve(), { once: true });
323
+ image.addEventListener("error", () => resolve(), { once: true });
324
+ })));
325
+ const asServed = pending.map((image) => image.loading);
326
+ for (const image of pending)
327
+ image.loading = "eager";
328
+ let timer;
329
+ const expired = new Promise((_, reject) => {
330
+ timer = view.setTimeout(() => {
331
+ const stuck = pending.filter((image) => !image.complete);
332
+ reject(new Error(`${stuck.length} image(s) had not loaded after 15000ms, and neither answered nor failed: ${stuck.map((image) => image.currentSrc || image.src).join(", ")}`));
333
+ }, 15e3);
334
+ });
335
+ try {
336
+ await Promise.race([arrived, expired]);
337
+ } finally {
338
+ view.clearTimeout(timer);
339
+ for (let index = 0; index < pending.length; index += 1) {
340
+ pending[index].loading = asServed[index];
341
+ }
342
+ }
343
+ });
344
+ }
345
+ };
346
+ var INTERVENTIONS = [
347
+ holdAnimations,
348
+ pinAnimations,
349
+ hideCaret,
350
+ hideScrollbars,
351
+ hidePresentationalImages,
352
+ waitForFonts,
353
+ waitForImages
354
+ ];
355
+ var LAYOUT_RECIPE = [holdAnimations, hideScrollbars, waitForFonts, waitForImages];
356
+ var RASTER_RECIPE = [...LAYOUT_RECIPE, hideCaret];
357
+ var COLLECT_RECIPE = [
358
+ pinAnimations,
359
+ hideScrollbars,
360
+ waitForFonts,
361
+ waitForImages
362
+ ];
363
+ function interventionById(id) {
364
+ return INTERVENTIONS.find((intervention) => intervention.id === id);
365
+ }
366
+ function recipeOf(ids) {
367
+ return ids.map((id) => {
368
+ const intervention = interventionById(id);
369
+ if (intervention === void 0) {
370
+ throw new Error(`no stabilization trick is called \`${id}\`; this build knows ` + INTERVENTIONS.map((known) => `\`${known.id}\``).join(", "));
371
+ }
372
+ return intervention;
373
+ });
374
+ }
375
+ function forTier(recipe, tier) {
376
+ return recipe.filter((intervention) => tierReaches(tier, intervention.needs));
377
+ }
378
+ function recipeCss(recipe) {
379
+ return recipe.map((intervention) => intervention.css).filter((css) => css !== void 0).join("\n");
380
+ }
381
+ async function settleRecipe(recipe, target) {
382
+ for (const intervention of recipe) {
383
+ if (intervention.settle !== void 0)
384
+ await intervention.settle(target);
385
+ }
386
+ }
387
+ function recipeDigest(recipe) {
388
+ return digestValue(recipe.map((intervention) => intervention.id).sort());
389
+ }
390
+
391
+ // packages/core/dist/format/provenance.js
392
+ var JSX_SOURCE = Symbol.for("@variance-authority/jsx-source");
393
+
394
+ // packages/core/dist/rules/ruleset.js
395
+ var STYLE_ALLOWLIST = [
396
+ // Box model and formatting context
397
+ "display",
398
+ "position",
399
+ "top",
400
+ "right",
401
+ "bottom",
402
+ "left",
403
+ "float",
404
+ "clear",
405
+ "width",
406
+ "height",
407
+ "min-width",
408
+ "min-height",
409
+ "max-width",
410
+ "max-height",
411
+ "margin-top",
412
+ "margin-right",
413
+ "margin-bottom",
414
+ "margin-left",
415
+ "padding-top",
416
+ "padding-right",
417
+ "padding-bottom",
418
+ "padding-left",
419
+ "box-sizing",
420
+ "overflow-x",
421
+ "overflow-y",
422
+ "z-index",
423
+ "aspect-ratio",
424
+ // Flex and grid
425
+ "flex-direction",
426
+ "flex-wrap",
427
+ "flex-grow",
428
+ "flex-shrink",
429
+ "flex-basis",
430
+ "justify-content",
431
+ "align-items",
432
+ "align-self",
433
+ "align-content",
434
+ "order",
435
+ "grid-template-columns",
436
+ "grid-template-rows",
437
+ "grid-template-areas",
438
+ "grid-auto-columns",
439
+ "grid-auto-rows",
440
+ "grid-auto-flow",
441
+ "grid-column-start",
442
+ "grid-column-end",
443
+ "grid-row-start",
444
+ "grid-row-end",
445
+ "row-gap",
446
+ "column-gap",
447
+ // Typography
448
+ "font-family",
449
+ "font-size",
450
+ "font-weight",
451
+ "font-style",
452
+ "font-variant",
453
+ "font-stretch",
454
+ "line-height",
455
+ "letter-spacing",
456
+ "word-spacing",
457
+ "text-align",
458
+ "text-indent",
459
+ "text-transform",
460
+ "text-overflow",
461
+ "text-decoration-line",
462
+ "text-decoration-color",
463
+ "text-decoration-style",
464
+ "text-decoration-thickness",
465
+ "white-space",
466
+ "word-break",
467
+ "overflow-wrap",
468
+ "vertical-align",
469
+ "writing-mode",
470
+ "direction",
471
+ // Paint
472
+ "color",
473
+ "opacity",
474
+ "background-color",
475
+ "background-image",
476
+ // Native-control painting. `accent-color` restyles checkboxes and radios,
477
+ // which is exactly the kind of property the rest of this list misses: it
478
+ // describes what the *engine* paints rather than what the author declares
479
+ // about a box. See the note below.
480
+ "accent-color",
481
+ "-webkit-text-stroke-width",
482
+ "background-position",
483
+ "background-size",
484
+ "background-repeat",
485
+ "background-clip",
486
+ "background-origin",
487
+ "border-top-width",
488
+ "border-right-width",
489
+ "border-bottom-width",
490
+ "border-left-width",
491
+ "border-top-style",
492
+ "border-right-style",
493
+ "border-bottom-style",
494
+ "border-left-style",
495
+ "border-top-color",
496
+ "border-right-color",
497
+ "border-bottom-color",
498
+ "border-left-color",
499
+ "border-top-left-radius",
500
+ "border-top-right-radius",
501
+ "border-bottom-right-radius",
502
+ "border-bottom-left-radius",
503
+ "outline-width",
504
+ "outline-style",
505
+ "outline-color",
506
+ "outline-offset",
507
+ "box-shadow",
508
+ "text-shadow",
509
+ "filter",
510
+ "backdrop-filter",
511
+ "mix-blend-mode",
512
+ // Visibility and geometry transforms
513
+ "visibility",
514
+ "content-visibility",
515
+ "transform",
516
+ "transform-origin",
517
+ "object-fit",
518
+ "object-position",
519
+ // Tables
520
+ "table-layout",
521
+ "border-collapse",
522
+ "border-spacing",
523
+ "caption-side"
524
+ ];
525
+ var ALLOWED = new Set(STYLE_ALLOWLIST);
526
+ function isAllowedProperty(property) {
527
+ return ALLOWED.has(property);
528
+ }
529
+ function isCustomProperty(property) {
530
+ return property.startsWith("--");
531
+ }
532
+ function admits(property) {
533
+ return isCustomProperty(property) || isAllowedProperty(property);
534
+ }
535
+ var ATTRIBUTE_ALLOWLIST = [
536
+ "type",
537
+ "value",
538
+ "checked",
539
+ "disabled",
540
+ "readonly",
541
+ "required",
542
+ "multiple",
543
+ "placeholder",
544
+ "name",
545
+ "href",
546
+ "target",
547
+ "rel",
548
+ "src",
549
+ "alt",
550
+ "title",
551
+ "for",
552
+ "form",
553
+ "list",
554
+ "headers",
555
+ "colspan",
556
+ "rowspan",
557
+ "scope",
558
+ "lang",
559
+ "dir",
560
+ "hidden",
561
+ "open",
562
+ "selected",
563
+ "download",
564
+ "min",
565
+ "max",
566
+ "step",
567
+ "pattern",
568
+ "maxlength",
569
+ "minlength",
570
+ "autocomplete",
571
+ "role",
572
+ "tabindex",
573
+ "draggable",
574
+ "contenteditable",
575
+ "width",
576
+ "height",
577
+ "loading",
578
+ "decoding",
579
+ "srcset",
580
+ "sizes",
581
+ "poster",
582
+ "controls"
583
+ ];
584
+ var ATTRIBUTES = new Set(ATTRIBUTE_ALLOWLIST);
585
+ var ID_REFERENCE_ATTRIBUTES = [
586
+ "id",
587
+ "for",
588
+ "form",
589
+ "list",
590
+ "headers",
591
+ "aria-labelledby",
592
+ "aria-describedby",
593
+ "aria-controls",
594
+ "aria-owns",
595
+ "aria-activedescendant",
596
+ "aria-details",
597
+ "aria-errormessage",
598
+ "aria-flowto"
599
+ ];
600
+ var ID_REFERENCE_LIST_ATTRIBUTES = [
601
+ "headers",
602
+ "aria-labelledby",
603
+ "aria-describedby",
604
+ "aria-controls",
605
+ "aria-owns",
606
+ "aria-flowto"
607
+ ];
608
+
609
+ // packages/core/dist/rules/normalize/alias.js
610
+ var ID_LIST_ATTRIBUTES = new Set(ID_REFERENCE_LIST_ATTRIBUTES);
611
+ var ID_REFERENCE = new Set(ID_REFERENCE_ATTRIBUTES);
612
+
613
+ // packages/core/dist/rules/normalize/color.js
614
+ var NAMED = {
615
+ transparent: [0, 0, 0, 0],
616
+ aliceblue: [240, 248, 255, 1],
617
+ antiquewhite: [250, 235, 215, 1],
618
+ aqua: [0, 255, 255, 1],
619
+ aquamarine: [127, 255, 212, 1],
620
+ azure: [240, 255, 255, 1],
621
+ beige: [245, 245, 220, 1],
622
+ bisque: [255, 228, 196, 1],
623
+ black: [0, 0, 0, 1],
624
+ blanchedalmond: [255, 235, 205, 1],
625
+ blue: [0, 0, 255, 1],
626
+ blueviolet: [138, 43, 226, 1],
627
+ brown: [165, 42, 42, 1],
628
+ burlywood: [222, 184, 135, 1],
629
+ cadetblue: [95, 158, 160, 1],
630
+ chartreuse: [127, 255, 0, 1],
631
+ chocolate: [210, 105, 30, 1],
632
+ coral: [255, 127, 80, 1],
633
+ cornflowerblue: [100, 149, 237, 1],
634
+ cornsilk: [255, 248, 220, 1],
635
+ crimson: [220, 20, 60, 1],
636
+ cyan: [0, 255, 255, 1],
637
+ darkblue: [0, 0, 139, 1],
638
+ darkcyan: [0, 139, 139, 1],
639
+ darkgoldenrod: [184, 134, 11, 1],
640
+ darkgray: [169, 169, 169, 1],
641
+ darkgreen: [0, 100, 0, 1],
642
+ darkgrey: [169, 169, 169, 1],
643
+ darkkhaki: [189, 183, 107, 1],
644
+ darkmagenta: [139, 0, 139, 1],
645
+ darkolivegreen: [85, 107, 47, 1],
646
+ darkorange: [255, 140, 0, 1],
647
+ darkorchid: [153, 50, 204, 1],
648
+ darkred: [139, 0, 0, 1],
649
+ darksalmon: [233, 150, 122, 1],
650
+ darkseagreen: [143, 188, 143, 1],
651
+ darkslateblue: [72, 61, 139, 1],
652
+ darkslategray: [47, 79, 79, 1],
653
+ darkslategrey: [47, 79, 79, 1],
654
+ darkturquoise: [0, 206, 209, 1],
655
+ darkviolet: [148, 0, 211, 1],
656
+ deeppink: [255, 20, 147, 1],
657
+ deepskyblue: [0, 191, 255, 1],
658
+ dimgray: [105, 105, 105, 1],
659
+ dimgrey: [105, 105, 105, 1],
660
+ dodgerblue: [30, 144, 255, 1],
661
+ firebrick: [178, 34, 34, 1],
662
+ floralwhite: [255, 250, 240, 1],
663
+ forestgreen: [34, 139, 34, 1],
664
+ fuchsia: [255, 0, 255, 1],
665
+ gainsboro: [220, 220, 220, 1],
666
+ ghostwhite: [248, 248, 255, 1],
667
+ gold: [255, 215, 0, 1],
668
+ goldenrod: [218, 165, 32, 1],
669
+ gray: [128, 128, 128, 1],
670
+ green: [0, 128, 0, 1],
671
+ greenyellow: [173, 255, 47, 1],
672
+ grey: [128, 128, 128, 1],
673
+ honeydew: [240, 255, 240, 1],
674
+ hotpink: [255, 105, 180, 1],
675
+ indianred: [205, 92, 92, 1],
676
+ indigo: [75, 0, 130, 1],
677
+ ivory: [255, 255, 240, 1],
678
+ khaki: [240, 230, 140, 1],
679
+ lavender: [230, 230, 250, 1],
680
+ lavenderblush: [255, 240, 245, 1],
681
+ lawngreen: [124, 252, 0, 1],
682
+ lemonchiffon: [255, 250, 205, 1],
683
+ lightblue: [173, 216, 230, 1],
684
+ lightcoral: [240, 128, 128, 1],
685
+ lightcyan: [224, 255, 255, 1],
686
+ lightgoldenrodyellow: [250, 250, 210, 1],
687
+ lightgray: [211, 211, 211, 1],
688
+ lightgreen: [144, 238, 144, 1],
689
+ lightgrey: [211, 211, 211, 1],
690
+ lightpink: [255, 182, 193, 1],
691
+ lightsalmon: [255, 160, 122, 1],
692
+ lightseagreen: [32, 178, 170, 1],
693
+ lightskyblue: [135, 206, 250, 1],
694
+ lightslategray: [119, 136, 153, 1],
695
+ lightslategrey: [119, 136, 153, 1],
696
+ lightsteelblue: [176, 196, 222, 1],
697
+ lightyellow: [255, 255, 224, 1],
698
+ lime: [0, 255, 0, 1],
699
+ limegreen: [50, 205, 50, 1],
700
+ linen: [250, 240, 230, 1],
701
+ magenta: [255, 0, 255, 1],
702
+ maroon: [128, 0, 0, 1],
703
+ mediumaquamarine: [102, 205, 170, 1],
704
+ mediumblue: [0, 0, 205, 1],
705
+ mediumorchid: [186, 85, 211, 1],
706
+ mediumpurple: [147, 112, 219, 1],
707
+ mediumseagreen: [60, 179, 113, 1],
708
+ mediumslateblue: [123, 104, 238, 1],
709
+ mediumspringgreen: [0, 250, 154, 1],
710
+ mediumturquoise: [72, 209, 204, 1],
711
+ mediumvioletred: [199, 21, 133, 1],
712
+ midnightblue: [25, 25, 112, 1],
713
+ mintcream: [245, 255, 250, 1],
714
+ mistyrose: [255, 228, 225, 1],
715
+ moccasin: [255, 228, 181, 1],
716
+ navajowhite: [255, 222, 173, 1],
717
+ navy: [0, 0, 128, 1],
718
+ oldlace: [253, 245, 230, 1],
719
+ olive: [128, 128, 0, 1],
720
+ olivedrab: [107, 142, 35, 1],
721
+ orange: [255, 165, 0, 1],
722
+ orangered: [255, 69, 0, 1],
723
+ orchid: [218, 112, 214, 1],
724
+ palegoldenrod: [238, 232, 170, 1],
725
+ palegreen: [152, 251, 152, 1],
726
+ paleturquoise: [175, 238, 238, 1],
727
+ palevioletred: [219, 112, 147, 1],
728
+ papayawhip: [255, 239, 213, 1],
729
+ peachpuff: [255, 218, 185, 1],
730
+ peru: [205, 133, 63, 1],
731
+ pink: [255, 192, 203, 1],
732
+ plum: [221, 160, 221, 1],
733
+ powderblue: [176, 224, 230, 1],
734
+ purple: [128, 0, 128, 1],
735
+ rebeccapurple: [102, 51, 153, 1],
736
+ red: [255, 0, 0, 1],
737
+ rosybrown: [188, 143, 143, 1],
738
+ royalblue: [65, 105, 225, 1],
739
+ saddlebrown: [139, 69, 19, 1],
740
+ salmon: [250, 128, 114, 1],
741
+ sandybrown: [244, 164, 96, 1],
742
+ seagreen: [46, 139, 87, 1],
743
+ seashell: [255, 245, 238, 1],
744
+ sienna: [160, 82, 45, 1],
745
+ silver: [192, 192, 192, 1],
746
+ skyblue: [135, 206, 235, 1],
747
+ slateblue: [106, 90, 205, 1],
748
+ slategray: [112, 128, 144, 1],
749
+ slategrey: [112, 128, 144, 1],
750
+ snow: [255, 250, 250, 1],
751
+ springgreen: [0, 255, 127, 1],
752
+ steelblue: [70, 130, 180, 1],
753
+ tan: [210, 180, 140, 1],
754
+ teal: [0, 128, 128, 1],
755
+ thistle: [216, 191, 216, 1],
756
+ tomato: [255, 99, 71, 1],
757
+ turquoise: [64, 224, 208, 1],
758
+ violet: [238, 130, 238, 1],
759
+ wheat: [245, 222, 179, 1],
760
+ white: [255, 255, 255, 1],
761
+ whitesmoke: [245, 245, 245, 1],
762
+ yellow: [255, 255, 0, 1],
763
+ yellowgreen: [154, 205, 50, 1]
764
+ };
765
+ function parseColor(input) {
766
+ const value = input.trim().toLowerCase();
767
+ const named = NAMED[value];
768
+ if (named)
769
+ return named;
770
+ if (value.startsWith("#"))
771
+ return parseHex(value);
772
+ if (value.startsWith("rgb"))
773
+ return parseRgbFunction(value);
774
+ if (value.startsWith("hsl"))
775
+ return parseHslFunction(value);
776
+ return null;
777
+ }
778
+ function formatColor([r, g, b, a]) {
779
+ const channels = `${clampChannel(r)} ${clampChannel(g)} ${clampChannel(b)}`;
780
+ const alpha = Math.round(clamp(a, 0, 1) * 1e3) / 1e3;
781
+ return `rgb(${channels} / ${alpha})`;
782
+ }
783
+ function canonicalizeColor(input) {
784
+ const parsed = parseColor(input);
785
+ return parsed ? formatColor(parsed) : collapseWhitespace(input);
786
+ }
787
+ function isColorProperty(property) {
788
+ return property === "color" || property.endsWith("-color") || property === "background-color" || property === "caret-color";
789
+ }
790
+ function parseHex(value) {
791
+ const hex = value.slice(1);
792
+ const expand = (c) => Number.parseInt(c + c, 16);
793
+ const pair2 = (i) => Number.parseInt(hex.slice(i, i + 2), 16);
794
+ switch (hex.length) {
795
+ case 3:
796
+ return [expand(hex[0]), expand(hex[1]), expand(hex[2]), 1];
797
+ case 4:
798
+ return [expand(hex[0]), expand(hex[1]), expand(hex[2]), expand(hex[3]) / 255];
799
+ case 6:
800
+ return [pair2(0), pair2(2), pair2(4), 1];
801
+ case 8:
802
+ return [pair2(0), pair2(2), pair2(4), pair2(6) / 255];
803
+ default:
804
+ return null;
805
+ }
806
+ }
807
+ function parseRgbFunction(value) {
808
+ const args = functionArguments(value);
809
+ if (!args || args.length < 3)
810
+ return null;
811
+ const channel = (raw) => raw.endsWith("%") ? Number.parseFloat(raw) / 100 * 255 : Number.parseFloat(raw);
812
+ const r = channel(args[0]);
813
+ const g = channel(args[1]);
814
+ const b = channel(args[2]);
815
+ const a = args.length > 3 ? parseAlpha(args[3]) : 1;
816
+ return [r, g, b, a].some(Number.isNaN) ? null : [Math.round(r), Math.round(g), Math.round(b), a];
817
+ }
818
+ function parseHslFunction(value) {
819
+ const args = functionArguments(value);
820
+ if (!args || args.length < 3)
821
+ return null;
822
+ const h = (Number.parseFloat(args[0]) % 360 + 360) % 360;
823
+ const s = Number.parseFloat(args[1]) / 100;
824
+ const l = Number.parseFloat(args[2]) / 100;
825
+ const a = args.length > 3 ? parseAlpha(args[3]) : 1;
826
+ if ([h, s, l, a].some(Number.isNaN))
827
+ return null;
828
+ const c = (1 - Math.abs(2 * l - 1)) * s;
829
+ const x = c * (1 - Math.abs(h / 60 % 2 - 1));
830
+ const m = l - c / 2;
831
+ const sextant = Math.floor(h / 60) % 6;
832
+ const rgb = [
833
+ [c, x, 0],
834
+ [x, c, 0],
835
+ [0, c, x],
836
+ [0, x, c],
837
+ [x, 0, c],
838
+ [c, 0, x]
839
+ ];
840
+ const [r, g, b] = rgb[sextant];
841
+ return [Math.round((r + m) * 255), Math.round((g + m) * 255), Math.round((b + m) * 255), a];
842
+ }
843
+ function parseAlpha(raw) {
844
+ return raw.endsWith("%") ? Number.parseFloat(raw) / 100 : Number.parseFloat(raw);
845
+ }
846
+ function functionArguments(value) {
847
+ const open = value.indexOf("(");
848
+ const close = value.lastIndexOf(")");
849
+ if (open < 0 || close < open)
850
+ return null;
851
+ return value.slice(open + 1, close).split(/[\s,/]+/).filter((part) => part.length > 0);
852
+ }
853
+ function clampChannel(value) {
854
+ return Math.round(clamp(value, 0, 255));
855
+ }
856
+ function clamp(value, min, max) {
857
+ return value < min ? min : value > max ? max : value;
858
+ }
859
+ function collapseWhitespace(value) {
860
+ return value.trim().replace(/\s+/g, " ");
861
+ }
862
+
863
+ // packages/core/dist/rules/normalize/value.js
864
+ var ABSOLUTE_LENGTHS = {
865
+ px: 1,
866
+ pt: 96 / 72,
867
+ pc: 16,
868
+ in: 96,
869
+ cm: 96 / 2.54,
870
+ mm: 96 / 25.4,
871
+ q: 96 / 101.6
872
+ };
873
+ var ANGLES = {
874
+ deg: 1,
875
+ grad: 0.9,
876
+ rad: 180 / Math.PI,
877
+ turn: 360
878
+ };
879
+ var RELATIVE_UNITS = [
880
+ "em",
881
+ "rem",
882
+ "ex",
883
+ "ch",
884
+ "cap",
885
+ "ic",
886
+ "lh",
887
+ "rlh",
888
+ "vw",
889
+ "vh",
890
+ "vmin",
891
+ "vmax",
892
+ "vi",
893
+ "vb",
894
+ "svw",
895
+ "svh",
896
+ "lvw",
897
+ "lvh",
898
+ "dvw",
899
+ "dvh",
900
+ "%"
901
+ ];
902
+ var LENGTH_PRECISION = 4;
903
+ function canonicalizeValue(property, value) {
904
+ if (isColorProperty(property))
905
+ return canonicalizeColor(value);
906
+ return canonicalizeTokens(value);
907
+ }
908
+ function canonicalizeTokens(value) {
909
+ const out = [];
910
+ let index = 0;
911
+ const input = value.trim();
912
+ while (index < input.length) {
913
+ const char = input[index];
914
+ if (/\s/.test(char)) {
915
+ if (out.length > 0 && out[out.length - 1] !== " ")
916
+ out.push(" ");
917
+ index += 1;
918
+ continue;
919
+ }
920
+ if (char === '"' || char === "'") {
921
+ const end = closingQuote(input, index);
922
+ out.push(input.slice(index, end + 1));
923
+ index = end + 1;
924
+ continue;
925
+ }
926
+ if (input.slice(index).toLowerCase().startsWith("url(")) {
927
+ const end = matchingParen(input, index + 3);
928
+ out.push(`url${input.slice(index + 3, end + 1)}`);
929
+ index = end + 1;
930
+ continue;
931
+ }
932
+ const numeric = /^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?([a-z%]*)/i.exec(input.slice(index));
933
+ if (numeric && numeric[0].length > 0) {
934
+ out.push(canonicalizeDimension(numeric[0]));
935
+ index += numeric[0].length;
936
+ continue;
937
+ }
938
+ const identifier = /^[a-z_-][\w-]*/i.exec(input.slice(index));
939
+ if (identifier) {
940
+ out.push(identifier[0].toLowerCase());
941
+ index += identifier[0].length;
942
+ continue;
943
+ }
944
+ if (char === "," && out[out.length - 1] === " ")
945
+ out.pop();
946
+ out.push(char);
947
+ index += 1;
948
+ }
949
+ return out.join("").trim();
950
+ }
951
+ function canonicalizeDimension(token) {
952
+ const match = /^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)([a-z%]*)$/i.exec(token);
953
+ if (!match)
954
+ return token.toLowerCase();
955
+ const magnitude = Number.parseFloat(match[1]);
956
+ const unit = match[2].toLowerCase();
957
+ if (!Number.isFinite(magnitude))
958
+ return token.toLowerCase();
959
+ if (magnitude === 0 && (unit === "" || unit in ABSOLUTE_LENGTHS || isRelativeUnit(unit))) {
960
+ return "0";
961
+ }
962
+ const lengthFactor = ABSOLUTE_LENGTHS[unit];
963
+ if (lengthFactor !== void 0)
964
+ return `${round(magnitude * lengthFactor)}px`;
965
+ const angleFactor = ANGLES[unit];
966
+ if (angleFactor !== void 0)
967
+ return `${round(magnitude * angleFactor)}deg`;
968
+ return `${round(magnitude)}${unit}`;
969
+ }
970
+ function isRelativeUnit(unit) {
971
+ return RELATIVE_UNITS.includes(unit.toLowerCase());
972
+ }
973
+ function round(value) {
974
+ const factor = 10 ** LENGTH_PRECISION;
975
+ const rounded = Math.round(value * factor) / factor;
976
+ return Object.is(rounded, -0) ? 0 : rounded;
977
+ }
978
+ function closingQuote(input, start) {
979
+ const quote = input[start];
980
+ for (let i = start + 1; i < input.length; i += 1) {
981
+ if (input[i] === "\\") {
982
+ i += 1;
983
+ continue;
984
+ }
985
+ if (input[i] === quote)
986
+ return i;
987
+ }
988
+ return input.length - 1;
989
+ }
990
+ function matchingParen(input, openIndex) {
991
+ let depth = 0;
992
+ for (let i = openIndex; i < input.length; i += 1) {
993
+ if (input[i] === "(")
994
+ depth += 1;
995
+ else if (input[i] === ")") {
996
+ depth -= 1;
997
+ if (depth === 0)
998
+ return i;
999
+ }
1000
+ }
1001
+ return input.length - 1;
1002
+ }
1003
+
1004
+ // packages/core/dist/rules/normalize/shorthand.js
1005
+ var SHORTHAND_PROPERTIES = [
1006
+ "margin",
1007
+ "padding",
1008
+ "inset",
1009
+ "gap",
1010
+ "overflow",
1011
+ "border",
1012
+ "border-width",
1013
+ "border-style",
1014
+ "border-color",
1015
+ "border-radius",
1016
+ "border-top",
1017
+ "border-right",
1018
+ "border-bottom",
1019
+ "border-left",
1020
+ "outline",
1021
+ "flex",
1022
+ "flex-flow",
1023
+ "place-items",
1024
+ "place-content",
1025
+ "place-self",
1026
+ "grid-row",
1027
+ "grid-column",
1028
+ "grid-area",
1029
+ "text-decoration",
1030
+ "background",
1031
+ "font"
1032
+ ];
1033
+ var SIDES = ["top", "right", "bottom", "left"];
1034
+ var CORNERS = [
1035
+ "border-top-left-radius",
1036
+ "border-top-right-radius",
1037
+ "border-bottom-right-radius",
1038
+ "border-bottom-left-radius"
1039
+ ];
1040
+ var LINE_STYLES = /* @__PURE__ */ new Set([
1041
+ "none",
1042
+ "hidden",
1043
+ "dotted",
1044
+ "dashed",
1045
+ "solid",
1046
+ "double",
1047
+ "groove",
1048
+ "ridge",
1049
+ "inset",
1050
+ "outset"
1051
+ ]);
1052
+ var LINE_WIDTHS = /* @__PURE__ */ new Set(["thin", "medium", "thick"]);
1053
+ function expandDeclaration(property, value) {
1054
+ const expand = EXPANDERS[property];
1055
+ if (!expand)
1056
+ return { declarations: [{ property, value }], confident: true };
1057
+ const expanded = expand(value.trim());
1058
+ return expanded ?? { declarations: [{ property, value }], confident: false };
1059
+ }
1060
+ var EXPANDERS = {
1061
+ margin: (v) => box(v, (side) => `margin-${side}`),
1062
+ padding: (v) => box(v, (side) => `padding-${side}`),
1063
+ inset: (v) => box(v, (side) => side),
1064
+ "border-width": (v) => box(v, (side) => `border-${side}-width`),
1065
+ "border-style": (v) => box(v, (side) => `border-${side}-style`),
1066
+ "border-color": (v) => box(v, (side) => `border-${side}-color`),
1067
+ "scroll-margin": (v) => box(v, (side) => `scroll-margin-${side}`),
1068
+ "scroll-padding": (v) => box(v, (side) => `scroll-padding-${side}`),
1069
+ gap: (v) => pair(v, "row-gap", "column-gap"),
1070
+ overflow: (v) => pair(v, "overflow-x", "overflow-y"),
1071
+ "place-items": (v) => pair(v, "align-items", "justify-items"),
1072
+ "place-content": (v) => pair(v, "align-content", "justify-content"),
1073
+ "place-self": (v) => pair(v, "align-self", "justify-self"),
1074
+ "grid-row": (v) => slash(v, "grid-row-start", "grid-row-end"),
1075
+ "grid-column": (v) => slash(v, "grid-column-start", "grid-column-end"),
1076
+ "border-radius": expandBorderRadius,
1077
+ border: (v) => expandBorderSides(v, SIDES),
1078
+ "border-top": (v) => expandBorderSides(v, ["top"]),
1079
+ "border-right": (v) => expandBorderSides(v, ["right"]),
1080
+ "border-bottom": (v) => expandBorderSides(v, ["bottom"]),
1081
+ "border-left": (v) => expandBorderSides(v, ["left"]),
1082
+ outline: expandOutline,
1083
+ flex: expandFlex,
1084
+ "flex-flow": expandFlexFlow,
1085
+ "text-decoration": expandTextDecoration,
1086
+ // `background` and `font` are the two shorthands whose grammars are genuinely
1087
+ // ambiguous to decompose (a bare `<length>` in `background` may be a position
1088
+ // or a size; `font` interleaves four optional keyword slots before a required
1089
+ // size). Both are declared unexpandable rather than guessed at — see the
1090
+ // safety rule above. Under a profile with computed style the engine has
1091
+ // already resolved them into longhands, so this only affects the declared-only
1092
+ // tier, where an un-normalized value is a correct description of what is known.
1093
+ background: () => null,
1094
+ font: () => null
1095
+ };
1096
+ function box(value, name) {
1097
+ const parts = topLevelParts(value);
1098
+ if (parts.length === 0 || parts.length > 4)
1099
+ return null;
1100
+ if (parts.some(isGlobalKeywordAmbiguity))
1101
+ return null;
1102
+ const [a, b = a, c = a, d = b] = parts;
1103
+ const resolved = [a, b, c, d];
1104
+ return {
1105
+ declarations: SIDES.map((side, index) => ({
1106
+ property: name(side),
1107
+ value: resolved[index]
1108
+ })),
1109
+ confident: true
1110
+ };
1111
+ }
1112
+ function pair(value, first, second) {
1113
+ const parts = topLevelParts(value);
1114
+ if (parts.length === 0 || parts.length > 2)
1115
+ return null;
1116
+ const a = parts[0];
1117
+ const b = parts[1] ?? a;
1118
+ return {
1119
+ declarations: [
1120
+ { property: first, value: a },
1121
+ { property: second, value: b }
1122
+ ],
1123
+ confident: true
1124
+ };
1125
+ }
1126
+ function slash(value, start, end) {
1127
+ const parts = value.split("/").map((part) => part.trim());
1128
+ if (parts.length > 2)
1129
+ return null;
1130
+ const a = parts[0];
1131
+ if (parts.length === 1) {
1132
+ if (/^-?[a-z_]/i.test(a) && !/^(auto|span)\b/i.test(a))
1133
+ return null;
1134
+ return {
1135
+ declarations: [
1136
+ { property: start, value: a },
1137
+ { property: end, value: "auto" }
1138
+ ],
1139
+ confident: true
1140
+ };
1141
+ }
1142
+ return {
1143
+ declarations: [
1144
+ { property: start, value: a },
1145
+ { property: end, value: parts[1] }
1146
+ ],
1147
+ confident: true
1148
+ };
1149
+ }
1150
+ function expandBorderRadius(value) {
1151
+ const [horizontal, vertical] = value.split("/").map((part) => part.trim());
1152
+ const h = cornerValues(horizontal ?? "");
1153
+ if (!h)
1154
+ return null;
1155
+ if (vertical === void 0) {
1156
+ return {
1157
+ declarations: CORNERS.map((property, index) => ({ property, value: h[index] })),
1158
+ confident: true
1159
+ };
1160
+ }
1161
+ const v = cornerValues(vertical);
1162
+ if (!v)
1163
+ return null;
1164
+ return {
1165
+ declarations: CORNERS.map((property, index) => ({
1166
+ property,
1167
+ value: `${h[index]} ${v[index]}`
1168
+ })),
1169
+ confident: true
1170
+ };
1171
+ }
1172
+ function cornerValues(value) {
1173
+ const parts = topLevelParts(value);
1174
+ if (parts.length === 0 || parts.length > 4)
1175
+ return null;
1176
+ const [a, b = a, c = a, d = b] = parts;
1177
+ return [a, b, c, d];
1178
+ }
1179
+ function expandBorderSides(value, sides) {
1180
+ const parsed = classifyLineComponents(value);
1181
+ if (!parsed)
1182
+ return null;
1183
+ const declarations = sides.flatMap((side) => [
1184
+ { property: `border-${side}-width`, value: parsed.width },
1185
+ { property: `border-${side}-style`, value: parsed.style },
1186
+ { property: `border-${side}-color`, value: parsed.color }
1187
+ ]);
1188
+ return { declarations, confident: true };
1189
+ }
1190
+ function expandOutline(value) {
1191
+ const parsed = classifyLineComponents(value);
1192
+ if (!parsed)
1193
+ return null;
1194
+ return {
1195
+ declarations: [
1196
+ { property: "outline-width", value: parsed.width },
1197
+ { property: "outline-style", value: parsed.style },
1198
+ { property: "outline-color", value: parsed.color }
1199
+ ],
1200
+ confident: true
1201
+ };
1202
+ }
1203
+ function classifyLineComponents(value) {
1204
+ const parts = topLevelParts(value);
1205
+ if (parts.length === 0 || parts.length > 3)
1206
+ return null;
1207
+ let width;
1208
+ let style;
1209
+ let color;
1210
+ for (const part of parts) {
1211
+ const lower = part.toLowerCase();
1212
+ if (LINE_STYLES.has(lower)) {
1213
+ if (style !== void 0)
1214
+ return null;
1215
+ style = lower;
1216
+ } else if (LINE_WIDTHS.has(lower) || isLength(part)) {
1217
+ if (width !== void 0)
1218
+ return null;
1219
+ width = part;
1220
+ } else if (lower === "currentcolor" || parseColor(part) !== null || part.startsWith("var(")) {
1221
+ if (color !== void 0)
1222
+ return null;
1223
+ color = part;
1224
+ } else {
1225
+ return null;
1226
+ }
1227
+ }
1228
+ return {
1229
+ width: width ?? "medium",
1230
+ style: style ?? "none",
1231
+ color: color ?? "currentcolor"
1232
+ };
1233
+ }
1234
+ function expandFlex(value) {
1235
+ const lower = value.toLowerCase().trim();
1236
+ const keyword = {
1237
+ none: ["0", "0", "auto"],
1238
+ auto: ["1", "1", "auto"],
1239
+ initial: ["0", "1", "auto"]
1240
+ };
1241
+ const preset = keyword[lower];
1242
+ const [grow, shrink, basis] = preset ?? classifyFlexParts(topLevelParts(value)) ?? [];
1243
+ if (grow === void 0 || shrink === void 0 || basis === void 0)
1244
+ return null;
1245
+ return {
1246
+ declarations: [
1247
+ { property: "flex-grow", value: grow },
1248
+ { property: "flex-shrink", value: shrink },
1249
+ { property: "flex-basis", value: basis }
1250
+ ],
1251
+ confident: true
1252
+ };
1253
+ }
1254
+ function classifyFlexParts(parts) {
1255
+ if (parts.length === 1) {
1256
+ const only = parts[0];
1257
+ if (isBareNumber(only))
1258
+ return [only, "1", "0%"];
1259
+ if (isLength(only) || only === "auto" || only === "content")
1260
+ return ["1", "1", only];
1261
+ return null;
1262
+ }
1263
+ if (parts.length === 2) {
1264
+ const [first, second] = parts;
1265
+ if (!isBareNumber(first))
1266
+ return null;
1267
+ if (isBareNumber(second))
1268
+ return [first, second, "0%"];
1269
+ return [first, "1", second];
1270
+ }
1271
+ if (parts.length === 3) {
1272
+ const [grow, shrink, basis] = parts;
1273
+ if (!isBareNumber(grow) || !isBareNumber(shrink))
1274
+ return null;
1275
+ return [grow, shrink, basis];
1276
+ }
1277
+ return null;
1278
+ }
1279
+ function expandFlexFlow(value) {
1280
+ const parts = topLevelParts(value);
1281
+ if (parts.length === 0 || parts.length > 2)
1282
+ return null;
1283
+ const wraps = /* @__PURE__ */ new Set(["nowrap", "wrap", "wrap-reverse"]);
1284
+ const directions = /* @__PURE__ */ new Set(["row", "row-reverse", "column", "column-reverse"]);
1285
+ let direction;
1286
+ let wrap;
1287
+ for (const part of parts) {
1288
+ const lower = part.toLowerCase();
1289
+ if (directions.has(lower)) {
1290
+ if (direction !== void 0)
1291
+ return null;
1292
+ direction = lower;
1293
+ } else if (wraps.has(lower)) {
1294
+ if (wrap !== void 0)
1295
+ return null;
1296
+ wrap = lower;
1297
+ } else {
1298
+ return null;
1299
+ }
1300
+ }
1301
+ return {
1302
+ declarations: [
1303
+ { property: "flex-direction", value: direction ?? "row" },
1304
+ { property: "flex-wrap", value: wrap ?? "nowrap" }
1305
+ ],
1306
+ confident: true
1307
+ };
1308
+ }
1309
+ function expandTextDecoration(value) {
1310
+ const parts = topLevelParts(value);
1311
+ if (parts.length === 0 || parts.length > 4)
1312
+ return null;
1313
+ const lines = /* @__PURE__ */ new Set(["none", "underline", "overline", "line-through", "blink"]);
1314
+ const styles = /* @__PURE__ */ new Set(["solid", "double", "dotted", "dashed", "wavy"]);
1315
+ const lineParts = [];
1316
+ let style;
1317
+ let color;
1318
+ let thickness;
1319
+ for (const part of parts) {
1320
+ const lower = part.toLowerCase();
1321
+ if (lines.has(lower))
1322
+ lineParts.push(lower);
1323
+ else if (styles.has(lower)) {
1324
+ if (style !== void 0)
1325
+ return null;
1326
+ style = lower;
1327
+ } else if (lower === "auto" || lower === "from-font" || isLength(part)) {
1328
+ if (thickness !== void 0)
1329
+ return null;
1330
+ thickness = part;
1331
+ } else if (lower === "currentcolor" || parseColor(part) !== null || part.startsWith("var(")) {
1332
+ if (color !== void 0)
1333
+ return null;
1334
+ color = part;
1335
+ } else {
1336
+ return null;
1337
+ }
1338
+ }
1339
+ return {
1340
+ declarations: [
1341
+ { property: "text-decoration-line", value: lineParts.length > 0 ? lineParts.join(" ") : "none" },
1342
+ { property: "text-decoration-style", value: style ?? "solid" },
1343
+ { property: "text-decoration-color", value: color ?? "currentcolor" },
1344
+ { property: "text-decoration-thickness", value: thickness ?? "auto" }
1345
+ ],
1346
+ confident: true
1347
+ };
1348
+ }
1349
+ function topLevelParts(value) {
1350
+ const parts = [];
1351
+ let depth = 0;
1352
+ let current = "";
1353
+ for (const char of value.trim()) {
1354
+ if (char === "(")
1355
+ depth += 1;
1356
+ else if (char === ")")
1357
+ depth -= 1;
1358
+ if (depth === 0 && /\s/.test(char)) {
1359
+ if (current.length > 0)
1360
+ parts.push(current);
1361
+ current = "";
1362
+ continue;
1363
+ }
1364
+ current += char;
1365
+ }
1366
+ if (current.length > 0)
1367
+ parts.push(current);
1368
+ return parts;
1369
+ }
1370
+ function isGlobalKeywordAmbiguity(part) {
1371
+ const lower = part.toLowerCase();
1372
+ return lower === "inherit" || lower === "initial" || lower === "unset" || lower === "revert" || lower === "revert-layer";
1373
+ }
1374
+ function isLength(part) {
1375
+ return /^[+-]?(\d+\.?\d*|\.\d+)([a-z]+|%)?$/i.test(part) || part.toLowerCase().startsWith("calc(");
1376
+ }
1377
+ function isBareNumber(part) {
1378
+ return /^[+-]?(\d+\.?\d*|\.\d+)$/.test(part);
1379
+ }
1380
+
1381
+ // packages/core/dist/rules/normalize/cascade.js
1382
+ var INHERITED_PROPERTIES = [
1383
+ "color",
1384
+ "font-family",
1385
+ "font-size",
1386
+ "font-weight",
1387
+ "font-style",
1388
+ "font-variant",
1389
+ "font-stretch",
1390
+ "line-height",
1391
+ "letter-spacing",
1392
+ "word-spacing",
1393
+ "text-align",
1394
+ "text-indent",
1395
+ "text-transform",
1396
+ "white-space",
1397
+ "word-break",
1398
+ "overflow-wrap",
1399
+ "visibility",
1400
+ "direction",
1401
+ "writing-mode",
1402
+ "caption-side",
1403
+ "border-collapse",
1404
+ "border-spacing"
1405
+ ];
1406
+ var INHERITED = new Set(INHERITED_PROPERTIES);
1407
+ var EMPTY_CONTEXT = { inherited: {}, customProperties: {} };
1408
+ function resolveStyle(input) {
1409
+ const candidates = collectCandidates(input);
1410
+ const winners = /* @__PURE__ */ new Map();
1411
+ for (const candidate of candidates) {
1412
+ const incumbent = winners.get(candidate.property);
1413
+ if (incumbent === void 0 || wins(candidate, incumbent)) {
1414
+ winners.set(candidate.property, candidate);
1415
+ }
1416
+ }
1417
+ const customProperties = { ...input.context.customProperties };
1418
+ for (const [property, candidate] of winners) {
1419
+ if (isCustomProperty(property))
1420
+ customProperties[property] = candidate.value.trim();
1421
+ }
1422
+ const style = {};
1423
+ const tokens = {};
1424
+ const origins = {};
1425
+ for (const [property, value] of Object.entries(input.context.inherited)) {
1426
+ style[property] = value;
1427
+ const token = input.context.inheritedTokens?.[property];
1428
+ if (token !== void 0) {
1429
+ const resolved = customProperties[token];
1430
+ tokens[token] = resolved === void 0 ? value : tokenValue(property, resolved, customProperties);
1431
+ }
1432
+ }
1433
+ for (const [property, candidate] of winners) {
1434
+ if (isCustomProperty(property))
1435
+ continue;
1436
+ const resolution = resolveVariables(candidate.value, customProperties);
1437
+ style[property] = canonicalizeValue(property, resolution.value);
1438
+ for (const name of resolution.used) {
1439
+ const resolved = customProperties[name];
1440
+ if (resolved !== void 0)
1441
+ tokens[name] = tokenValue(property, resolved, customProperties);
1442
+ }
1443
+ origins[property] = {
1444
+ sheet: candidate.sheet,
1445
+ selector: candidate.selector,
1446
+ ...candidate.source ? { source: candidate.source } : {},
1447
+ ...resolution.used[0] !== void 0 ? { tokenName: resolution.used[0] } : {}
1448
+ };
1449
+ }
1450
+ if (input.computedStyle) {
1451
+ for (const [property, value] of Object.entries(input.computedStyle)) {
1452
+ if (!admits(property) || isCustomProperty(property))
1453
+ continue;
1454
+ style[property] = canonicalizeValue(property, value);
1455
+ }
1456
+ }
1457
+ const propertyTokens = {};
1458
+ for (const property of Object.keys(style)) {
1459
+ const own = origins[property];
1460
+ const token = own !== void 0 ? own.tokenName : input.context.inheritedTokens?.[property];
1461
+ if (token !== void 0)
1462
+ propertyTokens[property] = token;
1463
+ }
1464
+ const childInherited = {};
1465
+ const childInheritedTokens = {};
1466
+ for (const [property, value] of Object.entries(style)) {
1467
+ if (!INHERITED.has(property))
1468
+ continue;
1469
+ childInherited[property] = value;
1470
+ const token = propertyTokens[property];
1471
+ if (token !== void 0)
1472
+ childInheritedTokens[property] = token;
1473
+ }
1474
+ return {
1475
+ style,
1476
+ tokens,
1477
+ origins,
1478
+ propertyTokens,
1479
+ childContext: {
1480
+ inherited: childInherited,
1481
+ customProperties,
1482
+ inheritedTokens: childInheritedTokens
1483
+ }
1484
+ };
1485
+ }
1486
+ function collectCandidates(input) {
1487
+ const candidates = [];
1488
+ for (const rule of input.matchedRules) {
1489
+ for (const declaration2 of rule.declarations) {
1490
+ for (const admitted of admitDeclaration(declaration2)) {
1491
+ candidates.push({
1492
+ ...admitted,
1493
+ inline: false,
1494
+ specificity: specificityRank(rule.specificity),
1495
+ order: rule.order,
1496
+ sheet: rule.sheet,
1497
+ selector: rule.selector,
1498
+ ...rule.source ? { source: rule.source } : {}
1499
+ });
1500
+ }
1501
+ }
1502
+ }
1503
+ for (const [property, value] of Object.entries(input.inlineStyle ?? {})) {
1504
+ const important = value.trimEnd().toLowerCase().endsWith("!important");
1505
+ const bare = important ? value.replace(/!\s*important\s*$/i, "").trim() : value;
1506
+ for (const admitted of admitDeclaration({ property, value: bare, important })) {
1507
+ candidates.push({
1508
+ ...admitted,
1509
+ inline: true,
1510
+ specificity: 0,
1511
+ order: Number.MAX_SAFE_INTEGER,
1512
+ sheet: "inline",
1513
+ selector: "[style]"
1514
+ });
1515
+ }
1516
+ }
1517
+ return candidates;
1518
+ }
1519
+ function admitDeclaration(declaration2) {
1520
+ const property = declaration2.property.trim().toLowerCase();
1521
+ if (isCustomProperty(declaration2.property)) {
1522
+ return [{
1523
+ property: declaration2.property.trim(),
1524
+ value: declaration2.value,
1525
+ important: declaration2.important
1526
+ }];
1527
+ }
1528
+ const expansion = expandDeclaration(property, declaration2.value);
1529
+ if (!expansion.confident) {
1530
+ return [{ property, value: declaration2.value, important: declaration2.important }];
1531
+ }
1532
+ return expansion.declarations.filter((entry) => admits(entry.property)).map((entry) => ({
1533
+ property: entry.property,
1534
+ value: entry.value,
1535
+ important: declaration2.important
1536
+ }));
1537
+ }
1538
+ function wins(candidate, incumbent) {
1539
+ if (candidate.important !== incumbent.important)
1540
+ return candidate.important;
1541
+ if (candidate.inline !== incumbent.inline)
1542
+ return candidate.inline;
1543
+ if (candidate.specificity !== incumbent.specificity) {
1544
+ return candidate.specificity > incumbent.specificity;
1545
+ }
1546
+ return candidate.order >= incumbent.order;
1547
+ }
1548
+ function specificityRank(specificity) {
1549
+ return specificity[0] * 1e6 + specificity[1] * 1e3 + specificity[2];
1550
+ }
1551
+ function tokenValue(property, declared, customProperties) {
1552
+ return canonicalizeValue(property, resolveVariables(declared, customProperties).value);
1553
+ }
1554
+ function resolveVariables(value, customProperties, depth = 0) {
1555
+ if (!value.includes("var(") || depth > 16)
1556
+ return { value, used: [] };
1557
+ const used = [];
1558
+ let result = "";
1559
+ let index = 0;
1560
+ while (index < value.length) {
1561
+ const start = value.indexOf("var(", index);
1562
+ if (start < 0) {
1563
+ result += value.slice(index);
1564
+ break;
1565
+ }
1566
+ result += value.slice(index, start);
1567
+ const end = matchingParen2(value, start + 3);
1568
+ const inner = value.slice(start + 4, end);
1569
+ const comma = topLevelComma(inner);
1570
+ const name = (comma < 0 ? inner : inner.slice(0, comma)).trim();
1571
+ const fallback = comma < 0 ? void 0 : inner.slice(comma + 1).trim();
1572
+ if (!used.includes(name))
1573
+ used.push(name);
1574
+ const declared = customProperties[name];
1575
+ const substituted = declared ?? fallback ?? "";
1576
+ const nested = resolveVariables(substituted, customProperties, depth + 1);
1577
+ result += nested.value;
1578
+ for (const nestedName of nested.used) {
1579
+ if (!used.includes(nestedName))
1580
+ used.push(nestedName);
1581
+ }
1582
+ index = end + 1;
1583
+ }
1584
+ return { value: result, used };
1585
+ }
1586
+ function matchingParen2(input, openIndex) {
1587
+ let depth = 0;
1588
+ for (let i = openIndex; i < input.length; i += 1) {
1589
+ if (input[i] === "(")
1590
+ depth += 1;
1591
+ else if (input[i] === ")") {
1592
+ depth -= 1;
1593
+ if (depth === 0)
1594
+ return i;
1595
+ }
1596
+ }
1597
+ return input.length;
1598
+ }
1599
+ function topLevelComma(input) {
1600
+ let depth = 0;
1601
+ for (let i = 0; i < input.length; i += 1) {
1602
+ const char = input[i];
1603
+ if (char === "(")
1604
+ depth += 1;
1605
+ else if (char === ")")
1606
+ depth -= 1;
1607
+ else if (char === "," && depth === 0)
1608
+ return i;
1609
+ }
1610
+ return -1;
1611
+ }
1612
+
1613
+ // packages/core/dist/compare/impact.js
1614
+ var LAYOUT = [
1615
+ "display",
1616
+ "position",
1617
+ "top",
1618
+ "right",
1619
+ "bottom",
1620
+ "left",
1621
+ "float",
1622
+ "clear",
1623
+ "width",
1624
+ "height",
1625
+ "min-width",
1626
+ "min-height",
1627
+ "max-width",
1628
+ "max-height",
1629
+ "margin-top",
1630
+ "margin-right",
1631
+ "margin-bottom",
1632
+ "margin-left",
1633
+ "padding-top",
1634
+ "padding-right",
1635
+ "padding-bottom",
1636
+ "padding-left",
1637
+ "box-sizing",
1638
+ "overflow-x",
1639
+ "overflow-y",
1640
+ "aspect-ratio",
1641
+ "flex-direction",
1642
+ "flex-wrap",
1643
+ "flex-grow",
1644
+ "flex-shrink",
1645
+ "flex-basis",
1646
+ "justify-content",
1647
+ "align-items",
1648
+ "align-self",
1649
+ "align-content",
1650
+ "order",
1651
+ "grid-template-columns",
1652
+ "grid-template-rows",
1653
+ "grid-template-areas",
1654
+ "grid-auto-columns",
1655
+ "grid-auto-rows",
1656
+ "grid-auto-flow",
1657
+ "grid-column-start",
1658
+ "grid-column-end",
1659
+ "grid-row-start",
1660
+ "grid-row-end",
1661
+ "row-gap",
1662
+ "column-gap",
1663
+ "font-family",
1664
+ "font-size",
1665
+ "font-weight",
1666
+ "font-style",
1667
+ "font-stretch",
1668
+ "font-variant",
1669
+ "line-height",
1670
+ "letter-spacing",
1671
+ "word-spacing",
1672
+ "text-align",
1673
+ "text-indent",
1674
+ "text-transform",
1675
+ "white-space",
1676
+ "word-break",
1677
+ "overflow-wrap",
1678
+ "text-overflow",
1679
+ "vertical-align",
1680
+ "writing-mode",
1681
+ "direction",
1682
+ // Border *width* occupies space; border colour does not. The style longhand
1683
+ // belongs here too, because `none` collapses the border to zero width whatever
1684
+ // the declared width says.
1685
+ "border-top-width",
1686
+ "border-right-width",
1687
+ "border-bottom-width",
1688
+ "border-left-width",
1689
+ "border-top-style",
1690
+ "border-right-style",
1691
+ "border-bottom-style",
1692
+ "border-left-style",
1693
+ "table-layout",
1694
+ "border-collapse",
1695
+ "border-spacing",
1696
+ "caption-side",
1697
+ "content-visibility"
1698
+ ];
1699
+ var PAINT = [
1700
+ "color",
1701
+ "background-color",
1702
+ "background-image",
1703
+ "background-position",
1704
+ "background-size",
1705
+ "background-repeat",
1706
+ "background-clip",
1707
+ "background-origin",
1708
+ "border-top-color",
1709
+ "border-right-color",
1710
+ "border-bottom-color",
1711
+ "border-left-color",
1712
+ "border-top-left-radius",
1713
+ "border-top-right-radius",
1714
+ "border-bottom-right-radius",
1715
+ "border-bottom-left-radius",
1716
+ "box-shadow",
1717
+ "text-shadow",
1718
+ "text-decoration-line",
1719
+ "text-decoration-color",
1720
+ "text-decoration-style",
1721
+ "text-decoration-thickness",
1722
+ "object-fit",
1723
+ "object-position",
1724
+ // `outline` is painted outside the box and never affects layout — that is the
1725
+ // whole reason it exists as a separate property from `border`.
1726
+ "outline-width",
1727
+ "outline-style",
1728
+ "outline-color",
1729
+ "outline-offset",
1730
+ // `visibility: hidden` still occupies its space, unlike `display: none`.
1731
+ "visibility"
1732
+ ];
1733
+ var COMPOSITE = [
1734
+ "transform",
1735
+ "transform-origin",
1736
+ "opacity",
1737
+ "filter",
1738
+ "backdrop-filter",
1739
+ "mix-blend-mode",
1740
+ "z-index"
1741
+ ];
1742
+ var IMPACTS = new Map([
1743
+ ...LAYOUT.map((property) => [property, "layout"]),
1744
+ ...PAINT.map((property) => [property, "paint"]),
1745
+ ...COMPOSITE.map((property) => [property, "composite"])
1746
+ ]);
1747
+
1748
+ // packages/core/dist/attribute/source-map.js
1749
+ var DIGITS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1750
+ var VALUE_OF = new Int8Array(128).fill(-1);
1751
+ for (let i = 0; i < DIGITS.length; i += 1)
1752
+ VALUE_OF[DIGITS.charCodeAt(i)] = i;
1753
+
1754
+ // packages/core/dist/attribute/call-site.js
1755
+ var URL_OF = globalThis.URL;
1756
+
1757
+ // packages/core/dist/attribute/instances.js
1758
+ var REFERENCE = new Set(ID_REFERENCE_ATTRIBUTES);
1759
+ var REFERENCE_LIST = new Set(ID_REFERENCE_LIST_ATTRIBUTES);
1760
+
1761
+ // packages/dom/dist/aria.js
1762
+ var IMPLICIT_ROLES = {
1763
+ article: "article",
1764
+ aside: "complementary",
1765
+ button: "button",
1766
+ datalist: "listbox",
1767
+ dd: "definition",
1768
+ details: "group",
1769
+ dialog: "dialog",
1770
+ dt: "term",
1771
+ fieldset: "group",
1772
+ figure: "figure",
1773
+ form: "form",
1774
+ h1: "heading",
1775
+ h2: "heading",
1776
+ h3: "heading",
1777
+ h4: "heading",
1778
+ h5: "heading",
1779
+ h6: "heading",
1780
+ hr: "separator",
1781
+ main: "main",
1782
+ math: "math",
1783
+ menu: "list",
1784
+ meter: "meter",
1785
+ nav: "navigation",
1786
+ ol: "list",
1787
+ optgroup: "group",
1788
+ option: "option",
1789
+ output: "status",
1790
+ p: "paragraph",
1791
+ progress: "progressbar",
1792
+ search: "search",
1793
+ summary: "button",
1794
+ table: "table",
1795
+ tbody: "rowgroup",
1796
+ textarea: "textbox",
1797
+ tfoot: "rowgroup",
1798
+ thead: "rowgroup",
1799
+ tr: "row",
1800
+ ul: "list",
1801
+ caption: "caption",
1802
+ legend: "legend",
1803
+ img: "img"
1804
+ };
1805
+ var INPUT_ROLES = {
1806
+ button: "button",
1807
+ checkbox: "checkbox",
1808
+ email: "textbox",
1809
+ image: "button",
1810
+ number: "spinbutton",
1811
+ radio: "radio",
1812
+ range: "slider",
1813
+ reset: "button",
1814
+ search: "searchbox",
1815
+ submit: "button",
1816
+ tel: "textbox",
1817
+ text: "textbox",
1818
+ url: "textbox"
1819
+ };
1820
+ function ariaOf(element) {
1821
+ const description = accessibleDescription(element);
1822
+ return {
1823
+ role: roleOf(element),
1824
+ name: accessibleName(element),
1825
+ ...description !== null ? { description } : {},
1826
+ state: stateOf(element)
1827
+ };
1828
+ }
1829
+ function roleOf(element) {
1830
+ const explicit = element.getAttribute("role");
1831
+ if (explicit) {
1832
+ const first = explicit.trim().split(/\s+/)[0];
1833
+ if (first)
1834
+ return first;
1835
+ }
1836
+ const tag = element.tagName.toLowerCase();
1837
+ if (tag === "input") {
1838
+ const type = (element.getAttribute("type") ?? "text").toLowerCase();
1839
+ if (type === "text" && element.hasAttribute("list"))
1840
+ return "combobox";
1841
+ return INPUT_ROLES[type] ?? null;
1842
+ }
1843
+ if (tag === "a" || tag === "area") {
1844
+ return element.hasAttribute("href") ? "link" : null;
1845
+ }
1846
+ if (tag === "select") {
1847
+ const multiple = element.hasAttribute("multiple");
1848
+ const size = Number.parseInt(element.getAttribute("size") ?? "1", 10);
1849
+ return multiple || size > 1 ? "listbox" : "combobox";
1850
+ }
1851
+ if (tag === "td" || tag === "th") {
1852
+ return tag === "th" ? "columnheader" : "cell";
1853
+ }
1854
+ if (tag === "header" || tag === "footer") {
1855
+ return element.closest("article, aside, main, nav, section") === null ? tag === "header" ? "banner" : "contentinfo" : null;
1856
+ }
1857
+ if (tag === "section") {
1858
+ return explicitName(element) === null ? null : "region";
1859
+ }
1860
+ if (tag === "img") {
1861
+ return element.getAttribute("alt") === "" ? "presentation" : "img";
1862
+ }
1863
+ return IMPLICIT_ROLES[tag] ?? null;
1864
+ }
1865
+ function accessibleName(element) {
1866
+ const explicit = explicitName(element);
1867
+ if (explicit !== null)
1868
+ return explicit;
1869
+ const tag = element.tagName.toLowerCase();
1870
+ if (tag === "input" || tag === "select" || tag === "textarea") {
1871
+ const native = nativeLabelFor(element);
1872
+ if (native)
1873
+ return native;
1874
+ const placeholder = element.getAttribute("placeholder");
1875
+ if (placeholder && placeholder.trim().length > 0)
1876
+ return normalize2(placeholder);
1877
+ const type = (element.getAttribute("type") ?? "").toLowerCase();
1878
+ if (type === "submit" || type === "button" || type === "reset") {
1879
+ const value = element.getAttribute("value");
1880
+ if (value)
1881
+ return normalize2(value);
1882
+ }
1883
+ return null;
1884
+ }
1885
+ if (tag === "img" || tag === "area") {
1886
+ const alt = element.getAttribute("alt");
1887
+ return alt === null ? null : alt === "" ? null : normalize2(alt);
1888
+ }
1889
+ const role = roleOf(element);
1890
+ if (role !== null && NAME_FROM_CONTENT.has(role)) {
1891
+ const text = visibleText(element);
1892
+ if (text.trim().length > 0)
1893
+ return normalize2(text);
1894
+ }
1895
+ const title = element.getAttribute("title");
1896
+ return title && title.trim().length > 0 ? normalize2(title) : null;
1897
+ }
1898
+ function explicitName(element) {
1899
+ const labelledBy = element.getAttribute("aria-labelledby");
1900
+ if (labelledBy) {
1901
+ const parts = labelledBy.trim().split(/\s+/).map((id) => element.ownerDocument.getElementById(id)?.textContent?.trim() ?? "").filter((part) => part.length > 0);
1902
+ if (parts.length > 0)
1903
+ return normalize2(parts.join(" "));
1904
+ }
1905
+ const label = element.getAttribute("aria-label");
1906
+ return label && label.trim().length > 0 ? normalize2(label) : null;
1907
+ }
1908
+ function visibleText(element) {
1909
+ let text = "";
1910
+ for (const child of element.childNodes) {
1911
+ if (child.nodeType === 3) {
1912
+ text += child.nodeValue ?? "";
1913
+ continue;
1914
+ }
1915
+ if (child.nodeType !== 1)
1916
+ continue;
1917
+ const node = child;
1918
+ if (node.getAttribute("aria-hidden") === "true" || node.hasAttribute("hidden"))
1919
+ continue;
1920
+ text += visibleText(node);
1921
+ }
1922
+ return text;
1923
+ }
1924
+ function accessibleDescription(element) {
1925
+ const describedBy = element.getAttribute("aria-describedby");
1926
+ if (describedBy) {
1927
+ const parts = describedBy.trim().split(/\s+/).map((id) => element.ownerDocument.getElementById(id)?.textContent?.trim() ?? "").filter((part) => part.length > 0);
1928
+ return parts.length > 0 ? normalize2(parts.join(" ")) : null;
1929
+ }
1930
+ const title = element.getAttribute("title");
1931
+ if (!title || title.trim().length === 0)
1932
+ return null;
1933
+ return accessibleName(element) === normalize2(title) ? null : normalize2(title);
1934
+ }
1935
+ var NAME_FROM_CONTENT = /* @__PURE__ */ new Set([
1936
+ "button",
1937
+ "cell",
1938
+ "checkbox",
1939
+ "columnheader",
1940
+ "gridcell",
1941
+ "heading",
1942
+ "link",
1943
+ "menuitem",
1944
+ "menuitemcheckbox",
1945
+ "menuitemradio",
1946
+ "option",
1947
+ "radio",
1948
+ "row",
1949
+ "rowheader",
1950
+ "switch",
1951
+ "tab",
1952
+ "tooltip",
1953
+ "treeitem",
1954
+ "term",
1955
+ "definition",
1956
+ "caption",
1957
+ "legend"
1958
+ ]);
1959
+ function nativeLabelFor(element) {
1960
+ const id = element.getAttribute("id");
1961
+ if (id) {
1962
+ const escaped = cssEscape(id);
1963
+ const label = element.ownerDocument.querySelector(`label[for="${escaped}"]`);
1964
+ const text2 = label?.textContent?.trim();
1965
+ if (text2)
1966
+ return normalize2(text2);
1967
+ }
1968
+ const wrapping = element.closest("label");
1969
+ const text = wrapping?.textContent?.trim();
1970
+ return text ? normalize2(text) : null;
1971
+ }
1972
+ function stateOf(element) {
1973
+ const state = {};
1974
+ const ariaStates = [
1975
+ "checked",
1976
+ "disabled",
1977
+ "expanded",
1978
+ "selected",
1979
+ "pressed",
1980
+ "current",
1981
+ "invalid",
1982
+ "required",
1983
+ "readonly",
1984
+ "hidden",
1985
+ "busy",
1986
+ "live",
1987
+ "modal",
1988
+ "multiselectable",
1989
+ "sort",
1990
+ "level",
1991
+ "valuenow",
1992
+ "valuemin",
1993
+ "valuemax",
1994
+ "valuetext",
1995
+ "haspopup",
1996
+ "setsize",
1997
+ "posinset",
1998
+ "placeholder",
1999
+ "orientation"
2000
+ ];
2001
+ for (const name of ariaStates) {
2002
+ const value = element.getAttribute(`aria-${name}`);
2003
+ if (value !== null)
2004
+ state[name] = coerce(value);
2005
+ }
2006
+ const nativeBooleans = ["disabled", "checked", "readonly", "required", "hidden", "open"];
2007
+ for (const name of nativeBooleans) {
2008
+ if (element.hasAttribute(name))
2009
+ state[name] = true;
2010
+ }
2011
+ if (element instanceof element.ownerDocument.defaultView.HTMLInputElement) {
2012
+ const input = element;
2013
+ if (input.type === "checkbox" || input.type === "radio")
2014
+ state["checked"] = input.checked;
2015
+ }
2016
+ const tag = element.tagName.toLowerCase();
2017
+ if (/^h[1-6]$/.test(tag) && state["level"] === void 0) {
2018
+ state["level"] = Number.parseInt(tag.slice(1), 10);
2019
+ }
2020
+ return state;
2021
+ }
2022
+ function coerce(value) {
2023
+ if (value === "true")
2024
+ return true;
2025
+ if (value === "false")
2026
+ return false;
2027
+ if (value !== "" && !Number.isNaN(Number(value)))
2028
+ return Number(value);
2029
+ return value;
2030
+ }
2031
+ function normalize2(text) {
2032
+ return text.replace(/\s+/g, " ").trim();
2033
+ }
2034
+ function cssEscape(value) {
2035
+ return value.replace(/["\\]/g, "\\$&");
2036
+ }
2037
+
2038
+ // packages/dom/dist/ignore.js
2039
+ var IGNORE_ATTRIBUTE = "data-variance-ignore";
2040
+ var MARKED_RULE = "marked";
2041
+ function resolveIgnores(root, options = {}) {
2042
+ const marks = /* @__PURE__ */ new Map();
2043
+ const unmatched = [];
2044
+ const mark = (element, rule) => {
2045
+ const existing = marks.get(element);
2046
+ if (existing === void 0) {
2047
+ marks.set(element, [rule]);
2048
+ return;
2049
+ }
2050
+ if (!existing.includes(rule))
2051
+ existing.push(rule);
2052
+ };
2053
+ for (const selector of options.selectors ?? []) {
2054
+ let found = 0;
2055
+ try {
2056
+ if (root.matches(selector.select)) {
2057
+ mark(root, selector.id);
2058
+ found += 1;
2059
+ }
2060
+ for (const element of root.querySelectorAll(selector.select)) {
2061
+ mark(element, selector.id);
2062
+ found += 1;
2063
+ }
2064
+ } catch {
2065
+ }
2066
+ if (found === 0)
2067
+ unmatched.push(selector);
2068
+ }
2069
+ if (options.markers !== false) {
2070
+ const marked = [
2071
+ ...root.hasAttribute(IGNORE_ATTRIBUTE) ? [root] : [],
2072
+ ...root.querySelectorAll(`[${IGNORE_ATTRIBUTE}]`)
2073
+ ];
2074
+ for (const element of marked) {
2075
+ const value = element.getAttribute(IGNORE_ATTRIBUTE)?.trim();
2076
+ mark(element, value === void 0 || value === "" ? MARKED_RULE : value);
2077
+ }
2078
+ }
2079
+ return { marks, unmatched };
2080
+ }
2081
+
2082
+ // packages/dom/dist/media.js
2083
+ var CERTAIN_MATCH = { matches: true, uncertain: false };
2084
+ function evaluateMedia(query, environment) {
2085
+ const normalized = query.trim().toLowerCase();
2086
+ if (normalized.length === 0 || normalized === "all")
2087
+ return CERTAIN_MATCH;
2088
+ let uncertain = false;
2089
+ for (const branch of splitTopLevel(normalized, ",")) {
2090
+ const result = evaluateBranch(branch, environment);
2091
+ if (result.matches)
2092
+ return { matches: true, uncertain: result.uncertain };
2093
+ uncertain = uncertain || result.uncertain;
2094
+ }
2095
+ return { matches: false, uncertain };
2096
+ }
2097
+ function evaluateSupports(condition, environment) {
2098
+ const probe = environment?.supports;
2099
+ if (!probe)
2100
+ return { matches: true, uncertain: true };
2101
+ const answer = probe(condition);
2102
+ return answer === null ? { matches: true, uncertain: true } : { matches: answer, uncertain: false };
2103
+ }
2104
+ function evaluateBranch(branch, environment) {
2105
+ let uncertain = false;
2106
+ let negated = false;
2107
+ let rest = branch.trim();
2108
+ if (rest.startsWith("not ")) {
2109
+ negated = true;
2110
+ rest = rest.slice(4).trim();
2111
+ } else if (rest.startsWith("only ")) {
2112
+ rest = rest.slice(5).trim();
2113
+ }
2114
+ let matches = true;
2115
+ for (const term of splitTopLevel(rest, " and ")) {
2116
+ const trimmed = term.trim();
2117
+ if (trimmed.length === 0)
2118
+ continue;
2119
+ if (!trimmed.startsWith("(")) {
2120
+ if (trimmed === "screen" || trimmed === "all")
2121
+ continue;
2122
+ if (trimmed === "print" || trimmed === "speech") {
2123
+ matches = false;
2124
+ continue;
2125
+ }
2126
+ uncertain = true;
2127
+ continue;
2128
+ }
2129
+ const feature = evaluateFeature(trimmed.replace(/^\(|\)$/g, ""), environment);
2130
+ if (feature.uncertain)
2131
+ uncertain = true;
2132
+ if (!feature.matches)
2133
+ matches = false;
2134
+ }
2135
+ return { matches: negated ? !matches : matches, uncertain };
2136
+ }
2137
+ function evaluateFeature(feature, environment) {
2138
+ const colon = feature.indexOf(":");
2139
+ if (colon < 0) {
2140
+ return { matches: true, uncertain: true };
2141
+ }
2142
+ const name = feature.slice(0, colon).trim();
2143
+ const value = feature.slice(colon + 1).trim();
2144
+ switch (name) {
2145
+ case "width":
2146
+ return exact(environment.width, value);
2147
+ case "min-width":
2148
+ return atLeast(environment.width, value);
2149
+ case "max-width":
2150
+ return atMost(environment.width, value);
2151
+ case "height":
2152
+ return exact(environment.height, value);
2153
+ case "min-height":
2154
+ return atLeast(environment.height, value);
2155
+ case "max-height":
2156
+ return atMost(environment.height, value);
2157
+ case "min-resolution":
2158
+ return atLeast(environment.deviceScaleFactor * 96, value);
2159
+ case "max-resolution":
2160
+ return atMost(environment.deviceScaleFactor * 96, value);
2161
+ case "prefers-color-scheme":
2162
+ return { matches: value === environment.colorScheme, uncertain: false };
2163
+ case "orientation":
2164
+ return {
2165
+ matches: value === (environment.width >= environment.height ? "landscape" : "portrait"),
2166
+ uncertain: false
2167
+ };
2168
+ default: {
2169
+ const declared = environment.features?.[name];
2170
+ if (declared !== void 0)
2171
+ return { matches: declared === value, uncertain: false };
2172
+ return { matches: true, uncertain: true };
2173
+ }
2174
+ }
2175
+ }
2176
+ function toPixels(value) {
2177
+ const match = /^([+-]?(?:\d+\.?\d*|\.\d+))(px|em|rem|dppx|dpi|x)?$/.exec(value);
2178
+ if (!match)
2179
+ return null;
2180
+ const magnitude = Number.parseFloat(match[1]);
2181
+ switch (match[2]) {
2182
+ case void 0:
2183
+ case "px":
2184
+ return magnitude;
2185
+ // Media-query `em`/`rem` are relative to the *initial* font size, which is
2186
+ // 16px and not affected by page styles — so this conversion is exact.
2187
+ case "em":
2188
+ case "rem":
2189
+ return magnitude * 16;
2190
+ case "dpi":
2191
+ return magnitude;
2192
+ case "dppx":
2193
+ case "x":
2194
+ return magnitude * 96;
2195
+ default:
2196
+ return null;
2197
+ }
2198
+ }
2199
+ function exact(actual, value) {
2200
+ const target = toPixels(value);
2201
+ return target === null ? { matches: true, uncertain: true } : { matches: actual === target, uncertain: false };
2202
+ }
2203
+ function atLeast(actual, value) {
2204
+ const target = toPixels(value);
2205
+ return target === null ? { matches: true, uncertain: true } : { matches: actual >= target, uncertain: false };
2206
+ }
2207
+ function atMost(actual, value) {
2208
+ const target = toPixels(value);
2209
+ return target === null ? { matches: true, uncertain: true } : { matches: actual <= target, uncertain: false };
2210
+ }
2211
+ function splitTopLevel(input, separator) {
2212
+ const parts = [];
2213
+ let depth = 0;
2214
+ let current = "";
2215
+ let index = 0;
2216
+ while (index < input.length) {
2217
+ const char = input[index];
2218
+ if (char === "(")
2219
+ depth += 1;
2220
+ else if (char === ")")
2221
+ depth -= 1;
2222
+ if (depth === 0 && input.startsWith(separator, index)) {
2223
+ parts.push(current);
2224
+ current = "";
2225
+ index += separator.length;
2226
+ continue;
2227
+ }
2228
+ current += char;
2229
+ index += 1;
2230
+ }
2231
+ parts.push(current);
2232
+ return parts;
2233
+ }
2234
+
2235
+ // packages/dom/dist/specificity.js
2236
+ var ARGUMENT_SPECIFICITY = /* @__PURE__ */ new Set(["is", "not", "has", "matches", "-webkit-any", "-moz-any"]);
2237
+ function specificityOf(selector) {
2238
+ let ids = 0;
2239
+ let classes = 0;
2240
+ let types = 0;
2241
+ let index = 0;
2242
+ const input = selector.trim();
2243
+ while (index < input.length) {
2244
+ const char = input[index];
2245
+ if (char === "#") {
2246
+ ids += 1;
2247
+ index += 1 + consumeIdentifier(input, index + 1);
2248
+ continue;
2249
+ }
2250
+ if (char === ".") {
2251
+ classes += 1;
2252
+ index += 1 + consumeIdentifier(input, index + 1);
2253
+ continue;
2254
+ }
2255
+ if (char === "[") {
2256
+ classes += 1;
2257
+ index = skipTo(input, index, "]") + 1;
2258
+ continue;
2259
+ }
2260
+ if (char === ":") {
2261
+ const doubled = input[index + 1] === ":";
2262
+ const nameStart = index + (doubled ? 2 : 1);
2263
+ const nameLength = consumeIdentifier(input, nameStart);
2264
+ const name = input.slice(nameStart, nameStart + nameLength).toLowerCase();
2265
+ let cursor = nameStart + nameLength;
2266
+ if (input[cursor] === "(") {
2267
+ const close = matchingParen3(input, cursor);
2268
+ const argument = input.slice(cursor + 1, close);
2269
+ cursor = close + 1;
2270
+ if (ARGUMENT_SPECIFICITY.has(name)) {
2271
+ const [argIds, argClasses, argTypes] = mostSpecific(argument);
2272
+ ids += argIds;
2273
+ classes += argClasses;
2274
+ types += argTypes;
2275
+ } else if (name !== "where") {
2276
+ classes += 1;
2277
+ }
2278
+ } else if (doubled || PSEUDO_ELEMENTS.has(name)) {
2279
+ types += 1;
2280
+ } else {
2281
+ classes += 1;
2282
+ }
2283
+ index = cursor;
2284
+ continue;
2285
+ }
2286
+ if (/[a-z*|_-]/i.test(char)) {
2287
+ const length = consumeIdentifier(input, index) || 1;
2288
+ if (char !== "*")
2289
+ types += 1;
2290
+ index += length;
2291
+ continue;
2292
+ }
2293
+ index += 1;
2294
+ }
2295
+ return [ids, classes, types];
2296
+ }
2297
+ function mostSpecific(selectorList) {
2298
+ let best = [0, 0, 0];
2299
+ for (const branch of splitSelectorList(selectorList)) {
2300
+ const candidate = specificityOf(branch);
2301
+ if (compareSpecificity(candidate, best) > 0)
2302
+ best = candidate;
2303
+ }
2304
+ return best;
2305
+ }
2306
+ function compareSpecificity(a, b) {
2307
+ return a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
2308
+ }
2309
+ function splitSelectorList(selectorList) {
2310
+ const branches = [];
2311
+ let depth = 0;
2312
+ let quote = null;
2313
+ let current = "";
2314
+ for (let i = 0; i < selectorList.length; i += 1) {
2315
+ const char = selectorList[i];
2316
+ if (quote !== null) {
2317
+ current += char;
2318
+ if (char === quote && selectorList[i - 1] !== "\\")
2319
+ quote = null;
2320
+ continue;
2321
+ }
2322
+ if (char === '"' || char === "'") {
2323
+ quote = char;
2324
+ current += char;
2325
+ continue;
2326
+ }
2327
+ if (char === "(" || char === "[")
2328
+ depth += 1;
2329
+ else if (char === ")" || char === "]")
2330
+ depth -= 1;
2331
+ if (char === "," && depth === 0) {
2332
+ if (current.trim().length > 0)
2333
+ branches.push(current.trim());
2334
+ current = "";
2335
+ continue;
2336
+ }
2337
+ current += char;
2338
+ }
2339
+ if (current.trim().length > 0)
2340
+ branches.push(current.trim());
2341
+ return branches;
2342
+ }
2343
+ var PSEUDO_ELEMENTS = /* @__PURE__ */ new Set([
2344
+ "before",
2345
+ "after",
2346
+ "first-line",
2347
+ "first-letter",
2348
+ "selection",
2349
+ "backdrop",
2350
+ "placeholder",
2351
+ "marker",
2352
+ "file-selector-button"
2353
+ ]);
2354
+ function consumeIdentifier(input, start) {
2355
+ let length = 0;
2356
+ while (start + length < input.length) {
2357
+ const char = input[start + length];
2358
+ if (char === "\\") {
2359
+ length += 2;
2360
+ continue;
2361
+ }
2362
+ if (/[A-Za-z0-9_-]/.test(char) || char.charCodeAt(0) > 127) {
2363
+ length += 1;
2364
+ continue;
2365
+ }
2366
+ break;
2367
+ }
2368
+ return length;
2369
+ }
2370
+ function skipTo(input, start, terminator) {
2371
+ for (let i = start + 1; i < input.length; i += 1) {
2372
+ if (input[i] === terminator)
2373
+ return i;
2374
+ }
2375
+ return input.length - 1;
2376
+ }
2377
+ function matchingParen3(input, openIndex) {
2378
+ let depth = 0;
2379
+ for (let i = openIndex; i < input.length; i += 1) {
2380
+ if (input[i] === "(")
2381
+ depth += 1;
2382
+ else if (input[i] === ")") {
2383
+ depth -= 1;
2384
+ if (depth === 0)
2385
+ return i;
2386
+ }
2387
+ }
2388
+ return input.length - 1;
2389
+ }
2390
+
2391
+ // packages/dom/dist/dom-list.js
2392
+ function items(collection) {
2393
+ if (!collection)
2394
+ return [];
2395
+ const result = [];
2396
+ for (let index = 0; index < collection.length; index += 1) {
2397
+ const value = typeof collection.item === "function" ? collection.item(index) : collection[index];
2398
+ if (value !== null && value !== void 0)
2399
+ result.push(value);
2400
+ }
2401
+ return result;
2402
+ }
2403
+ function propertyNames(style) {
2404
+ if (!style)
2405
+ return [];
2406
+ const names = [];
2407
+ for (let index = 0; index < style.length; index += 1) {
2408
+ const name = typeof style.item === "function" ? style.item(index) : style[index];
2409
+ if (name)
2410
+ names.push(name);
2411
+ }
2412
+ return names;
2413
+ }
2414
+ function elements(collection) {
2415
+ if (!collection)
2416
+ return [];
2417
+ const result = [];
2418
+ for (let index = 0; index < collection.length; index += 1) {
2419
+ const element = typeof collection.item === "function" ? collection.item(index) : collection[index];
2420
+ if (element)
2421
+ result.push(element);
2422
+ }
2423
+ return result;
2424
+ }
2425
+ function attributesOf(element) {
2426
+ const attributes = {};
2427
+ const map = element.attributes;
2428
+ for (let index = 0; index < map.length; index += 1) {
2429
+ const attribute2 = typeof map.item === "function" ? map.item(index) : map[index];
2430
+ if (attribute2)
2431
+ attributes[attribute2.name] = attribute2.value;
2432
+ }
2433
+ return attributes;
2434
+ }
2435
+ function childNodesOf(node) {
2436
+ const children = [];
2437
+ const list = node.childNodes;
2438
+ for (let index = 0; index < list.length; index += 1) {
2439
+ const child = typeof list.item === "function" ? list.item(index) : list[index];
2440
+ if (child)
2441
+ children.push(child);
2442
+ }
2443
+ return children;
2444
+ }
2445
+ function classNamesOf(element) {
2446
+ const value = element.getAttribute("class");
2447
+ if (!value)
2448
+ return [];
2449
+ return value.trim().split(/\s+/).filter((name) => name.length > 0);
2450
+ }
2451
+
2452
+ // packages/dom/dist/selector-parts.js
2453
+ function ancestorPortion(selector) {
2454
+ let depth = 0;
2455
+ let lastBreak = -1;
2456
+ for (let index = 0; index < selector.length; index += 1) {
2457
+ const char = selector[index];
2458
+ if (char === "(" || char === "[")
2459
+ depth += 1;
2460
+ else if (char === ")" || char === "]")
2461
+ depth -= 1;
2462
+ else if (depth === 0 && (char === " " || char === ">" || char === "+" || char === "~")) {
2463
+ lastBreak = index;
2464
+ }
2465
+ }
2466
+ return lastBreak < 0 ? null : selector.slice(0, lastBreak);
2467
+ }
2468
+ function lastCompound(selector) {
2469
+ let depth = 0;
2470
+ let start = 0;
2471
+ for (let i = 0; i < selector.length; i += 1) {
2472
+ const char = selector[i];
2473
+ if (char === "(" || char === "[")
2474
+ depth += 1;
2475
+ else if (char === ")" || char === "]")
2476
+ depth -= 1;
2477
+ else if (depth === 0 && (char === " " || char === ">" || char === "+" || char === "~")) {
2478
+ start = i + 1;
2479
+ }
2480
+ }
2481
+ return selector.slice(start).trim();
2482
+ }
2483
+
2484
+ // packages/dom/dist/profile.js
2485
+ function detectProfile(view) {
2486
+ if (!view)
2487
+ return JSDOM_PROFILE;
2488
+ const probe = view.document.createElement("div");
2489
+ probe.style.cssText = "position:absolute;width:100px;height:100px;";
2490
+ view.document.body?.appendChild(probe);
2491
+ const measured = probe.getBoundingClientRect().width;
2492
+ probe.remove();
2493
+ return measured > 0 ? CHROMIUM_PROFILE : JSDOM_PROFILE;
2494
+ }
2495
+
2496
+ // packages/dom/dist/stabilize.js
2497
+ var STABILIZE_ATTRIBUTE = "data-va-stabilize";
2498
+ async function stabilizeForObservation(document2, options = {}) {
2499
+ const view = document2.defaultView;
2500
+ const profile = options.profile ?? detectProfile(view);
2501
+ const recipe = forTier(options.recipe ?? COLLECT_RECIPE, tierOfProfile(profile));
2502
+ if (recipe.length === 0) {
2503
+ return { ids: [], digest: void 0, release: () => void 0 };
2504
+ }
2505
+ const css = recipeCss(recipe);
2506
+ const style = existingSheet(document2) ?? insertSheet(document2);
2507
+ const already = style.textContent === css;
2508
+ if (!already)
2509
+ style.textContent = css;
2510
+ await settleRecipe(recipe, localTarget());
2511
+ if (!already)
2512
+ await settleFrames(view);
2513
+ return {
2514
+ ids: recipe.map((intervention) => intervention.id),
2515
+ digest: recipeDigest(recipe),
2516
+ release: () => style.remove()
2517
+ };
2518
+ function localTarget() {
2519
+ return { evaluate: async (fn) => await fn() };
2520
+ }
2521
+ }
2522
+ function existingSheet(document2) {
2523
+ return document2.querySelector(`style[${STABILIZE_ATTRIBUTE}]`);
2524
+ }
2525
+ function insertSheet(document2) {
2526
+ const style = document2.createElement("style");
2527
+ style.setAttribute(STABILIZE_ATTRIBUTE, "");
2528
+ (document2.head ?? document2.documentElement).append(style);
2529
+ return style;
2530
+ }
2531
+ async function settleFrames(view) {
2532
+ if (view === null || typeof view.requestAnimationFrame !== "function")
2533
+ return;
2534
+ await new Promise((resolve) => {
2535
+ view.requestAnimationFrame(() => {
2536
+ view.requestAnimationFrame(() => resolve());
2537
+ });
2538
+ });
2539
+ }
2540
+
2541
+ // packages/dom/dist/css-index.js
2542
+ function conditionKey(environment) {
2543
+ const features = Object.entries(environment.features ?? {}).map(([name, value]) => `${name}=${value}`).sort();
2544
+ return [
2545
+ `width=${environment.width}`,
2546
+ `height=${environment.height}`,
2547
+ `scale=${environment.deviceScaleFactor}`,
2548
+ `scheme=${environment.colorScheme}`,
2549
+ `features=${features.join(",")}`,
2550
+ `supports=${environment.supports ? "probed" : "assumed"}`
2551
+ ].join(" ");
2552
+ }
2553
+ function isStabilizationSheet(sheet) {
2554
+ const owner = sheet.ownerNode;
2555
+ return owner?.hasAttribute?.(STABILIZE_ATTRIBUTE) === true;
2556
+ }
2557
+ function indexStyleSheets(document2, environment) {
2558
+ const byKey = /* @__PURE__ */ new Map();
2559
+ const universal = [];
2560
+ const diagnostics = [];
2561
+ const evaluatedConditions = {};
2562
+ let order = 0;
2563
+ let totalRules = 0;
2564
+ const sheets = items(document2.styleSheets).filter(isStyleSheet).filter((sheet) => !isStabilizationSheet(sheet));
2565
+ for (const adopted of adoptedSheets(document2))
2566
+ sheets.push(adopted);
2567
+ for (const [index, sheet] of sheets.entries()) {
2568
+ const name = sheetName(sheet, index);
2569
+ let rules;
2570
+ try {
2571
+ rules = sheet.cssRules;
2572
+ } catch {
2573
+ diagnostics.push({
2574
+ severity: "warn",
2575
+ code: "unreadable-stylesheet",
2576
+ message: `stylesheet "${name}" is cross-origin; its rules were not collected`
2577
+ });
2578
+ continue;
2579
+ }
2580
+ walk(rules, name, false);
2581
+ }
2582
+ return {
2583
+ byKey,
2584
+ universal,
2585
+ diagnostics,
2586
+ totalRules,
2587
+ evaluatedConditions,
2588
+ conditions: conditionKey(environment)
2589
+ };
2590
+ function walk(rules, sheet, uncertain) {
2591
+ for (const rule of items(rules)) {
2592
+ if (isGroupingRule(rule)) {
2593
+ const condition = conditionOf(rule, environment);
2594
+ const prelude = preludeOf(rule);
2595
+ if (prelude !== null && dependsOnOmittedInput(prelude)) {
2596
+ evaluatedConditions[prelude] = condition.matches;
2597
+ }
2598
+ if (!condition.matches)
2599
+ continue;
2600
+ walk(rule.cssRules, sheet, uncertain || condition.uncertain);
2601
+ continue;
2602
+ }
2603
+ if (!isStyleRule(rule))
2604
+ continue;
2605
+ totalRules += 1;
2606
+ const declarations = declarationsOf(rule.style);
2607
+ if (declarations.length === 0)
2608
+ continue;
2609
+ for (const branch of splitSelectorList(rule.selectorText)) {
2610
+ const indexed = {
2611
+ sheet,
2612
+ selector: rule.selectorText,
2613
+ branch,
2614
+ specificity: specificityOf(branch),
2615
+ order: order += 1,
2616
+ declarations,
2617
+ key: rightmostKey(branch),
2618
+ uncertain
2619
+ };
2620
+ if (indexed.key === "*")
2621
+ universal.push(indexed);
2622
+ else {
2623
+ const bucket = byKey.get(indexed.key);
2624
+ if (bucket)
2625
+ bucket.push(indexed);
2626
+ else
2627
+ byKey.set(indexed.key, [indexed]);
2628
+ }
2629
+ }
2630
+ }
2631
+ }
2632
+ }
2633
+ function rightmostKey(selector) {
2634
+ const compound = lastCompound(selector);
2635
+ const id = /#([\w-]+)/.exec(compound);
2636
+ if (id)
2637
+ return `#${id[1]}`;
2638
+ const className = /\.((?:\\.|[\w-])+)/.exec(compound);
2639
+ if (className)
2640
+ return `.${className[1].replace(/\\/g, "")}`;
2641
+ const tag = /^([a-z][\w-]*)/i.exec(compound);
2642
+ if (tag && !compound.startsWith(":"))
2643
+ return tag[1].toLowerCase();
2644
+ if (compound.startsWith("["))
2645
+ return "[attr]";
2646
+ return "*";
2647
+ }
2648
+ function declarationsOf(style) {
2649
+ const declarations = [];
2650
+ let pending = false;
2651
+ for (const property of propertyNames(style)) {
2652
+ const value = style.getPropertyValue(property);
2653
+ if (value === "") {
2654
+ pending = true;
2655
+ continue;
2656
+ }
2657
+ declarations.push(declaration(property, value, style));
2658
+ }
2659
+ if (!pending)
2660
+ return declarations;
2661
+ for (const shorthand of SHORTHAND_PROPERTIES) {
2662
+ const value = style.getPropertyValue(shorthand);
2663
+ if (value === "" || !value.includes("var("))
2664
+ continue;
2665
+ declarations.push(declaration(shorthand, value, style));
2666
+ }
2667
+ return declarations;
2668
+ }
2669
+ function declaration(property, value, style) {
2670
+ const references = [...value.matchAll(/var\(\s*(--[\w-]+)/g)].map((match) => match[1]);
2671
+ return {
2672
+ property,
2673
+ value,
2674
+ important: style.getPropertyPriority(property) === "important",
2675
+ ...references.length > 0 ? { references } : {}
2676
+ };
2677
+ }
2678
+ function conditionOf(rule, environment) {
2679
+ const type = rule.constructor.name;
2680
+ if (type === "CSSMediaRule" || "media" in rule) {
2681
+ const media = rule.media;
2682
+ return evaluateMedia(media?.mediaText ?? "", environment);
2683
+ }
2684
+ if (type === "CSSSupportsRule" || "conditionText" in rule) {
2685
+ return evaluateSupports(rule.conditionText ?? "", environment);
2686
+ }
2687
+ return { matches: true, uncertain: true };
2688
+ }
2689
+ function dependsOnOmittedInput(prelude) {
2690
+ return /\b(min-|max-)?resolution\b|-webkit-device-pixel-ratio/i.test(prelude);
2691
+ }
2692
+ function preludeOf(rule) {
2693
+ const media = rule.media?.mediaText;
2694
+ if (media)
2695
+ return `@media ${media}`;
2696
+ const supports = rule.conditionText;
2697
+ if (supports)
2698
+ return `@supports ${supports}`;
2699
+ return null;
2700
+ }
2701
+ function isStyleSheet(sheet) {
2702
+ return "cssRules" in sheet;
2703
+ }
2704
+ function isStyleRule(rule) {
2705
+ return "selectorText" in rule && "style" in rule;
2706
+ }
2707
+ function isGroupingRule(rule) {
2708
+ return "cssRules" in rule && !("selectorText" in rule);
2709
+ }
2710
+ function adoptedSheets(document2) {
2711
+ const adopted = document2.adoptedStyleSheets;
2712
+ return adopted ? [...adopted] : [];
2713
+ }
2714
+ function sheetName(sheet, index) {
2715
+ if (sheet.href)
2716
+ return sheet.href;
2717
+ const owner = sheet.ownerNode;
2718
+ const id = owner?.getAttribute?.("id");
2719
+ if (id)
2720
+ return `<style#${id}>`;
2721
+ return `<style:${index}>`;
2722
+ }
2723
+
2724
+ // packages/dom/dist/css-match.js
2725
+ function matchRulesFor(element, index) {
2726
+ const candidates = [...index.universal];
2727
+ const id = element.getAttribute("id");
2728
+ if (id)
2729
+ candidates.push(...index.byKey.get(`#${id}`) ?? []);
2730
+ for (const className of classNamesOf(element)) {
2731
+ candidates.push(...index.byKey.get(`.${className}`) ?? []);
2732
+ }
2733
+ candidates.push(...index.byKey.get(element.tagName.toLowerCase()) ?? []);
2734
+ candidates.push(...index.byKey.get("[attr]") ?? []);
2735
+ const matched = [];
2736
+ const couplings = /* @__PURE__ */ new Set();
2737
+ for (const candidate of candidates) {
2738
+ if (safeMatches(element, candidate.branch)) {
2739
+ matched.push({
2740
+ sheet: candidate.sheet,
2741
+ selector: candidate.branch,
2742
+ specificity: candidate.specificity,
2743
+ order: candidate.order,
2744
+ declarations: candidate.declarations
2745
+ });
2746
+ continue;
2747
+ }
2748
+ for (const key of latentCouplings(element, candidate.branch))
2749
+ couplings.add(key);
2750
+ }
2751
+ return { matched: matched.sort((a, b) => a.order - b.order), couplings: [...couplings] };
2752
+ }
2753
+ function latentCouplings(element, selector) {
2754
+ const ancestor = ancestorPortion(selector);
2755
+ if (ancestor === null)
2756
+ return [];
2757
+ const own = lastCompound(selector);
2758
+ if (own.length === 0 || !safeMatches(element, own))
2759
+ return [];
2760
+ const keys = [];
2761
+ const lower = ancestor.toLowerCase();
2762
+ if (/(^|[\s>+~])(html|:root)\b/.test(lower) && /[.[]/.test(lower)) {
2763
+ keys.push("root-attr:class");
2764
+ for (const match of ancestor.matchAll(/\[([\w-]+)/g))
2765
+ keys.push(`root-attr:${match[1]}`);
2766
+ }
2767
+ if (/(^|[\s>+~])body\b/.test(lower) && /[.[]/.test(lower)) {
2768
+ keys.push("body-attr:class");
2769
+ for (const match of ancestor.matchAll(/\[([\w-]+)/g))
2770
+ keys.push(`body-attr:${match[1]}`);
2771
+ }
2772
+ return keys;
2773
+ }
2774
+ function safeMatches(element, selector) {
2775
+ try {
2776
+ return element.matches(selector);
2777
+ } catch {
2778
+ return true;
2779
+ }
2780
+ }
2781
+
2782
+ // packages/dom/dist/inherit.js
2783
+ function inheritedSeed(root, profile, view, index) {
2784
+ if (!root.parentElement)
2785
+ return {};
2786
+ if (profile.computedStyle && view) {
2787
+ const parent = view.getComputedStyle(root.parentElement);
2788
+ const seed = {};
2789
+ for (const property of INHERITABLE) {
2790
+ const value = parent.getPropertyValue(property);
2791
+ if (value)
2792
+ seed[property] = value;
2793
+ }
2794
+ for (const property of propertyNames(parent)) {
2795
+ if (property.startsWith("--"))
2796
+ seed[property] = parent.getPropertyValue(property);
2797
+ }
2798
+ return seed;
2799
+ }
2800
+ return declaredAncestorSeed(root, index);
2801
+ }
2802
+ function declaredAncestorSeed(root, index) {
2803
+ const chain = [];
2804
+ for (let node = root.parentElement; node; node = node.parentElement)
2805
+ chain.unshift(node);
2806
+ let context = EMPTY_CONTEXT;
2807
+ for (const ancestor of chain) {
2808
+ const inline = ancestor.style;
2809
+ const inlineStyle = {};
2810
+ for (const property of propertyNames(inline)) {
2811
+ inlineStyle[property] = inline.getPropertyValue(property);
2812
+ }
2813
+ context = resolveStyle({
2814
+ matchedRules: matchRulesFor(ancestor, index).matched,
2815
+ ...Object.keys(inlineStyle).length > 0 ? { inlineStyle } : {},
2816
+ context
2817
+ }).childContext;
2818
+ }
2819
+ return { ...context.inherited, ...context.customProperties };
2820
+ }
2821
+ var INHERITABLE = [
2822
+ "color",
2823
+ "font-family",
2824
+ "font-size",
2825
+ "font-weight",
2826
+ "font-style",
2827
+ "font-variant",
2828
+ "font-stretch",
2829
+ "line-height",
2830
+ "letter-spacing",
2831
+ "word-spacing",
2832
+ "text-align",
2833
+ "text-indent",
2834
+ "text-transform",
2835
+ "white-space",
2836
+ "word-break",
2837
+ "overflow-wrap",
2838
+ "visibility",
2839
+ "direction",
2840
+ "writing-mode",
2841
+ "caption-side",
2842
+ "border-collapse",
2843
+ "border-spacing"
2844
+ ];
2845
+
2846
+ // packages/dom/dist/collect.js
2847
+ function conditionsFor(document2, viewport, features) {
2848
+ const supports = supportsProbe(document2.defaultView);
2849
+ return {
2850
+ width: viewport.width,
2851
+ height: viewport.height,
2852
+ deviceScaleFactor: viewport.deviceScaleFactor,
2853
+ colorScheme: viewport.colorScheme,
2854
+ ...features ? { features } : {},
2855
+ ...supports ? { supports } : {}
2856
+ };
2857
+ }
2858
+ function collect(root, options) {
2859
+ const document2 = root.ownerDocument;
2860
+ const view = document2.defaultView;
2861
+ const profile = options.profile ?? detectProfile(view);
2862
+ const conditions = conditionsFor(document2, options.viewport, options.features);
2863
+ const index = options.index ? sameEnvironment(options.index, conditions) : indexStyleSheets(document2, conditions);
2864
+ const diagnostics = [...index.diagnostics];
2865
+ if (options.fonts === void 0) {
2866
+ diagnostics.push({
2867
+ severity: "warn",
2868
+ code: "unverified-fonts",
2869
+ message: "no font content hashes supplied; the environment key cannot detect a font substitution, which changes metrics and therefore geometry without changing code"
2870
+ });
2871
+ }
2872
+ const ignores = resolveIgnores(root, options.ignore ? { selectors: options.ignore } : {});
2873
+ for (const selector of ignores.unmatched) {
2874
+ diagnostics.push({
2875
+ severity: "warn",
2876
+ code: "ignore-unmatched",
2877
+ message: `ignore rule "${selector.id}" selector \`${selector.select}\` matched nothing in this subject; if it matches nothing anywhere, it is a hole in the suite that absorbs nothing`
2878
+ });
2879
+ }
2880
+ const portalRoots = options.portalsOf?.(root) ?? [];
2881
+ const couplings = /* @__PURE__ */ new Set();
2882
+ if (options.portalsOf === void 0) {
2883
+ diagnostics.push({
2884
+ severity: "warn",
2885
+ code: "portals-not-resolved",
2886
+ message: "no portal provider supplied; content rendered through createPortal is outside this capture, and a subject that portals will report unchanged when that content changes"
2887
+ });
2888
+ }
2889
+ const capture = {
2890
+ captureVersion: 1,
2891
+ subject: options.subject,
2892
+ profile,
2893
+ environment: {
2894
+ profile: profile.id,
2895
+ engine: options.engine,
2896
+ viewport: options.viewport,
2897
+ fonts: options.fonts ?? [],
2898
+ // Caller-declared features *and* the conditions actually resolved while
2899
+ // flattening. The second half is what lets the semantic key drop
2900
+ // `deviceScaleFactor` safely: a resolution-gated rule that resolves
2901
+ // differently on two machines splits the key through its outcome.
2902
+ conditions: { ...options.features, ...index.evaluatedConditions },
2903
+ assets: options.assets ?? {},
2904
+ ...options.stabilization !== void 0 ? { stabilization: options.stabilization } : {}
2905
+ },
2906
+ root: captureNode(root, profile, index, view, options, couplings, ignores.marks),
2907
+ inheritedSeed: inheritedSeed(root, profile, view, index),
2908
+ ...couplings.size > 0 ? { couplings: [...couplings].sort() } : {},
2909
+ ...portalRoots.length > 0 ? {
2910
+ portals: portalRoots.map((host) => captureNode(host, profile, index, view, options, couplings, ignores.marks))
2911
+ } : {},
2912
+ diagnostics
2913
+ };
2914
+ return capture;
2915
+ }
2916
+ function sameEnvironment(index, conditions) {
2917
+ const wanted = conditionKey(conditions);
2918
+ if (index.conditions === wanted)
2919
+ return index;
2920
+ throw new Error(`the supplied style index was built for a different condition environment (index: ${index.conditions}; capture: ${wanted}). Conditional groups are erased during indexing, so reusing it would flatten @media and @supports against one environment while keying the capture to another \u2014 two different rule sets sharing one baseline. Build an index per environment with indexStyleSheets(document, conditionsFor(document, viewport)).`);
2921
+ }
2922
+ function captureNode(element, profile, index, view, options, couplingSink, marks) {
2923
+ const attributes = attributesOf(element);
2924
+ const inline = element.style;
2925
+ const inlineStyle = {};
2926
+ for (const property of propertyNames(inline)) {
2927
+ inlineStyle[property] = inline.getPropertyValue(property);
2928
+ }
2929
+ const provenance = options.provenanceOf?.(element);
2930
+ const wiring = options.wiringOf?.(element);
2931
+ const holding = options.holdingOf?.(element);
2932
+ const ignoredBy = marks.get(element);
2933
+ const { matched, couplings } = matchRulesFor(element, index);
2934
+ for (const coupling of couplings)
2935
+ couplingSink.add(coupling);
2936
+ const children = [];
2937
+ for (const child of childNodesOf(element)) {
2938
+ if (child.nodeType === 1) {
2939
+ children.push(captureNode(child, profile, index, view, options, couplingSink, marks));
2940
+ continue;
2941
+ }
2942
+ if (child.nodeType === 3) {
2943
+ children.push(textNode(child.nodeValue ?? "", provenance));
2944
+ }
2945
+ }
2946
+ const shadow = element.shadowRoot;
2947
+ const shadowChildren = [];
2948
+ if (shadow) {
2949
+ for (const child of elements(shadow.children)) {
2950
+ shadowChildren.push(captureNode(child, profile, index, view, options, couplingSink, marks));
2951
+ }
2952
+ }
2953
+ return {
2954
+ tag: element.tagName.toLowerCase(),
2955
+ attributes,
2956
+ aria: ariaOf(element),
2957
+ matchedRules: matched,
2958
+ ...Object.keys(inlineStyle).length > 0 ? { inlineStyle } : {},
2959
+ ...profile.computedStyle && view ? { computedStyle: computedStyleOf(element, view) } : {},
2960
+ ...profile.layout ? { rect: rectOf(element) } : {},
2961
+ ...provenance ? { provenance } : {},
2962
+ ...wiring ? { wiring } : {},
2963
+ ...holding ? { holding } : {},
2964
+ children,
2965
+ ...shadowChildren.length > 0 ? { shadowChildren } : {},
2966
+ // Marked here and nowhere else. Only the element that matched carries the
2967
+ // rule; containment is a question about paths, which `core` answers without
2968
+ // a DOM — so a deep subtree costs one mark rather than one per node.
2969
+ ...ignoredBy ? { ignoredBy } : {}
2970
+ };
2971
+ }
2972
+ function textNode(text, provenance) {
2973
+ return {
2974
+ tag: "#text",
2975
+ attributes: {},
2976
+ matchedRules: [],
2977
+ text,
2978
+ ...provenance ? { provenance } : {},
2979
+ children: []
2980
+ };
2981
+ }
2982
+ function computedStyleOf(element, view) {
2983
+ const computed = view.getComputedStyle(element);
2984
+ const style = {};
2985
+ for (const property of propertyNames(computed)) {
2986
+ if (!admits(property))
2987
+ continue;
2988
+ style[property] = computed.getPropertyValue(property);
2989
+ }
2990
+ return style;
2991
+ }
2992
+ function rectOf(element) {
2993
+ const rect = element.getBoundingClientRect();
2994
+ const round2 = (value) => Math.round(value * 100) / 100;
2995
+ return {
2996
+ x: round2(rect.x),
2997
+ y: round2(rect.y),
2998
+ width: round2(rect.width),
2999
+ height: round2(rect.height)
3000
+ };
3001
+ }
3002
+ function supportsProbe(view) {
3003
+ const css = view?.CSS;
3004
+ if (!css || typeof css.supports !== "function")
3005
+ return null;
3006
+ return (condition) => {
3007
+ try {
3008
+ return css.supports(condition);
3009
+ } catch {
3010
+ return null;
3011
+ }
3012
+ };
3013
+ }
3014
+
3015
+ // packages/react/dist/fiber.js
3016
+ var FiberTag = {
3017
+ FunctionComponent: 0,
3018
+ ClassComponent: 1,
3019
+ /**
3020
+ * Removed in React 19; a hole in the numbering there rather than a reuse.
3021
+ * In React ≤18 it is the mount-time tag of a component whose return value has
3022
+ * not been observed yet, and it is rewritten to 0 or 1 before commit — so it
3023
+ * should never be seen by a post-commit walk. Recognised anyway: costs
3024
+ * nothing, and covers a concurrent read mid-render.
3025
+ */
3026
+ IndeterminateComponent: 2,
3027
+ HostRoot: 3,
3028
+ HostPortal: 4,
3029
+ HostComponent: 5,
3030
+ HostText: 6,
3031
+ Fragment: 7,
3032
+ Mode: 8,
3033
+ ContextConsumer: 9,
3034
+ ContextProvider: 10,
3035
+ ForwardRef: 11,
3036
+ Profiler: 12,
3037
+ SuspenseComponent: 13,
3038
+ /** `memo(X)` where X is *not* a plain function: an extra wrapper fiber. */
3039
+ MemoComponent: 14,
3040
+ /** `memo(fn)` where fn is a plain function: the component fiber itself. */
3041
+ SimpleMemoComponent: 15,
3042
+ LazyComponent: 16,
3043
+ IncompleteClassComponent: 17,
3044
+ DehydratedFragment: 18,
3045
+ SuspenseListComponent: 19,
3046
+ ScopeComponent: 21,
3047
+ OffscreenComponent: 22,
3048
+ LegacyHiddenComponent: 23,
3049
+ CacheComponent: 24,
3050
+ TracingMarkerComponent: 25,
3051
+ HostHoistable: 26,
3052
+ HostSingleton: 27,
3053
+ IncompleteFunctionComponent: 28,
3054
+ Throw: 29
3055
+ };
3056
+ var COMPOSITE_TAGS = /* @__PURE__ */ new Set([
3057
+ FiberTag.FunctionComponent,
3058
+ FiberTag.ClassComponent,
3059
+ FiberTag.IndeterminateComponent,
3060
+ FiberTag.ForwardRef,
3061
+ FiberTag.SimpleMemoComponent,
3062
+ FiberTag.IncompleteClassComponent,
3063
+ FiberTag.IncompleteFunctionComponent
3064
+ ]);
3065
+ function isOwnerFrame(fiber) {
3066
+ return COMPOSITE_TAGS.has(fiber.tag);
3067
+ }
3068
+ var MAX_FIBER_DEPTH = 1e4;
3069
+ var FIBER_KEY_PREFIXES = ["__reactFiber$", "__reactInternalInstance$"];
3070
+ var CONTAINER_KEY_PREFIX = "__reactContainer$";
3071
+ var cachedFiberKey = null;
3072
+ function scanForKey(node, prefixes) {
3073
+ for (const key of Object.keys(node)) {
3074
+ for (const prefix of prefixes) {
3075
+ if (key.startsWith(prefix))
3076
+ return key;
3077
+ }
3078
+ }
3079
+ return null;
3080
+ }
3081
+ function rawFiber(node) {
3082
+ if (cachedFiberKey !== null) {
3083
+ const hit = node[cachedFiberKey];
3084
+ if (hit)
3085
+ return hit;
3086
+ }
3087
+ const key = scanForKey(node, FIBER_KEY_PREFIXES);
3088
+ if (key === null)
3089
+ return null;
3090
+ cachedFiberKey = key;
3091
+ return node[key] ?? null;
3092
+ }
3093
+ function currentFiber(fiber) {
3094
+ const root = rootOf(fiber);
3095
+ if (root === null)
3096
+ return null;
3097
+ const fiberRoot = root.stateNode;
3098
+ if (!fiberRoot || !fiberRoot.current)
3099
+ return fiber;
3100
+ if (fiberRoot.current === root)
3101
+ return fiber;
3102
+ return fiber.alternate ?? fiber;
3103
+ }
3104
+ function rootOf(fiber) {
3105
+ let node = fiber;
3106
+ for (let depth = 0; depth < MAX_FIBER_DEPTH; depth += 1) {
3107
+ if (node.return === null)
3108
+ return node.tag === FiberTag.HostRoot ? node : null;
3109
+ node = node.return;
3110
+ }
3111
+ return null;
3112
+ }
3113
+ function findFiber(node) {
3114
+ const raw = rawFiber(node);
3115
+ if (raw === null)
3116
+ return null;
3117
+ return currentFiber(raw);
3118
+ }
3119
+ function hasFiber(node) {
3120
+ return rawFiber(node) !== null;
3121
+ }
3122
+ function findReactContainers(scope) {
3123
+ const found = [];
3124
+ const all = scope.querySelectorAll("*");
3125
+ for (let index = 0; index < all.length; index += 1) {
3126
+ const element = all[index];
3127
+ if (element && scanForKey(element, [CONTAINER_KEY_PREFIX]) !== null) {
3128
+ found.push(element);
3129
+ }
3130
+ }
3131
+ return found;
3132
+ }
3133
+
3134
+ // packages/react/dist/names.js
3135
+ var ANONYMOUS = "Anonymous";
3136
+ var MAX_UNWRAP_DEPTH = 10;
3137
+ var MEMO = "react.memo";
3138
+ var FORWARD_REF = "react.forward_ref";
3139
+ var LAZY = "react.lazy";
3140
+ function nameOf(type, depth) {
3141
+ if (depth > MAX_UNWRAP_DEPTH)
3142
+ return null;
3143
+ if (type === null || type === void 0)
3144
+ return null;
3145
+ if (typeof type === "string")
3146
+ return type;
3147
+ if (typeof type === "function") {
3148
+ const fn = type;
3149
+ if (typeof fn.displayName === "string" && fn.displayName !== "")
3150
+ return fn.displayName;
3151
+ if (typeof fn.name === "string" && fn.name !== "")
3152
+ return fn.name;
3153
+ return null;
3154
+ }
3155
+ if (typeof type !== "object")
3156
+ return null;
3157
+ const wrapper = type;
3158
+ if (typeof wrapper.displayName === "string" && wrapper.displayName !== "") {
3159
+ return wrapper.displayName;
3160
+ }
3161
+ const brand = typeof wrapper.$$typeof === "symbol" ? wrapper.$$typeof.description ?? "" : "";
3162
+ switch (brand) {
3163
+ case MEMO:
3164
+ return nameOf(wrapper.type, depth + 1);
3165
+ case FORWARD_REF:
3166
+ return nameOf(wrapper.render, depth + 1);
3167
+ case LAZY:
3168
+ return nameOf(wrapper._payload?._result, depth + 1);
3169
+ default:
3170
+ return null;
3171
+ }
3172
+ }
3173
+ function fiberComponentName(fiber) {
3174
+ return nameOf(fiber.elementType, 0) ?? nameOf(fiber.type, 0) ?? ANONYMOUS;
3175
+ }
3176
+ function debugOwnerName(owner) {
3177
+ if (!owner)
3178
+ return null;
3179
+ if (typeof owner.tag === "number") {
3180
+ const fiber = owner;
3181
+ return nameOf(fiber.elementType, 0) ?? nameOf(fiber.type, 0);
3182
+ }
3183
+ const info = owner;
3184
+ return typeof info.name === "string" && info.name !== "" ? info.name : null;
3185
+ }
3186
+
3187
+ // packages/react/dist/resolve.js
3188
+ var NO_FIBER = Object.freeze({
3189
+ status: "no-fiber",
3190
+ reason: "no-client-fiber"
3191
+ });
3192
+ var UNMOUNTED = Object.freeze({
3193
+ status: "no-fiber",
3194
+ reason: "unmounted"
3195
+ });
3196
+
3197
+ // packages/react/dist/portal.js
3198
+ var HOST_TAGS = /* @__PURE__ */ new Set([
3199
+ FiberTag.HostComponent,
3200
+ FiberTag.HostHoistable,
3201
+ FiberTag.HostSingleton
3202
+ ]);
3203
+ function portalContentOf(root) {
3204
+ const fiber = subtreeFiber(root);
3205
+ if (!fiber)
3206
+ return [];
3207
+ const found = [];
3208
+ collectPortals(fiber.child, found, /* @__PURE__ */ new Set());
3209
+ return found;
3210
+ }
3211
+ function subtreeFiber(root) {
3212
+ const own = findFiber(root);
3213
+ if (own)
3214
+ return own;
3215
+ const descendants = root.querySelectorAll("*");
3216
+ for (let index = 0; index < descendants.length; index += 1) {
3217
+ const element = descendants[index];
3218
+ if (!element)
3219
+ continue;
3220
+ const fiber = findFiber(element);
3221
+ if (!fiber)
3222
+ continue;
3223
+ return currentFiber(topOf(fiber)) ?? topOf(fiber);
3224
+ }
3225
+ return null;
3226
+ }
3227
+ function topOf(fiber) {
3228
+ let node = fiber;
3229
+ for (let depth = 0; depth < 1e4 && node.return; depth += 1) {
3230
+ node = node.return;
3231
+ }
3232
+ return node;
3233
+ }
3234
+ function collectPortals(start, found, seen) {
3235
+ let fiber = start;
3236
+ while (fiber) {
3237
+ if (fiber.tag === FiberTag.HostPortal) {
3238
+ collectPortalHosts(fiber.child, found, seen);
3239
+ fiber = fiber.sibling;
3240
+ continue;
3241
+ }
3242
+ if (fiber.child)
3243
+ collectPortals(fiber.child, found, seen);
3244
+ fiber = fiber.sibling;
3245
+ }
3246
+ }
3247
+ function collectPortalHosts(start, found, seen) {
3248
+ let fiber = start;
3249
+ while (fiber) {
3250
+ if (HOST_TAGS.has(fiber.tag)) {
3251
+ const element = fiber.stateNode;
3252
+ if (isElement(element) && !seen.has(element)) {
3253
+ seen.add(element);
3254
+ found.push(element);
3255
+ }
3256
+ if (fiber.child)
3257
+ collectPortals(fiber.child, found, seen);
3258
+ fiber = fiber.sibling;
3259
+ continue;
3260
+ }
3261
+ if (fiber.tag === FiberTag.HostPortal) {
3262
+ collectPortalHosts(fiber.child, found, seen);
3263
+ fiber = fiber.sibling;
3264
+ continue;
3265
+ }
3266
+ if (fiber.child)
3267
+ collectPortalHosts(fiber.child, found, seen);
3268
+ fiber = fiber.sibling;
3269
+ }
3270
+ }
3271
+ function isElement(value) {
3272
+ return typeof value === "object" && value !== null && value.nodeType === 1;
3273
+ }
3274
+
3275
+ // packages/react/dist/suspense.js
3276
+ var MAX_WALK_DEPTH = 1e4;
3277
+ var MAX_FIBERS = 5e5;
3278
+ var CONTAINER_KEY_PREFIX2 = "__reactContainer$";
3279
+ function boundariesUnder(node) {
3280
+ let own = null;
3281
+ try {
3282
+ if (hasFiber(node))
3283
+ own = findFiber(node);
3284
+ } catch {
3285
+ return null;
3286
+ }
3287
+ if (own !== null) {
3288
+ const found2 = [];
3289
+ collectFrom(own, found2);
3290
+ return found2;
3291
+ }
3292
+ const scope = node;
3293
+ if (typeof scope.querySelectorAll !== "function")
3294
+ return null;
3295
+ const roots = [];
3296
+ if (node.nodeType === 1) {
3297
+ const here = containerFiber(node);
3298
+ if (here !== null)
3299
+ roots.push(here);
3300
+ }
3301
+ for (const container of findReactContainers(node)) {
3302
+ const fiber = containerFiber(container);
3303
+ if (fiber !== null)
3304
+ roots.push(fiber);
3305
+ }
3306
+ if (roots.length === 0)
3307
+ return null;
3308
+ const found = [];
3309
+ for (const root of roots)
3310
+ collectFrom(root, found);
3311
+ return found;
3312
+ }
3313
+ function containerFiber(element) {
3314
+ const record2 = element;
3315
+ for (const key of Object.keys(record2)) {
3316
+ if (!key.startsWith(CONTAINER_KEY_PREFIX2))
3317
+ continue;
3318
+ const fiber = record2[key];
3319
+ if (!fiber)
3320
+ return null;
3321
+ try {
3322
+ return currentFiber(fiber);
3323
+ } catch {
3324
+ return null;
3325
+ }
3326
+ }
3327
+ return null;
3328
+ }
3329
+ function collectFrom(root, into) {
3330
+ const stack = [{ fiber: root, boundaries: 0 }];
3331
+ let visited = 0;
3332
+ while (stack.length > 0) {
3333
+ const entry = stack.pop();
3334
+ if (!entry)
3335
+ break;
3336
+ if ((visited += 1) > MAX_FIBERS)
3337
+ return;
3338
+ const { fiber } = entry;
3339
+ let { boundaries: boundaries2 } = entry;
3340
+ if (fiber.tag === FiberTag.SuspenseComponent) {
3341
+ into.push(describe(fiber, boundaries2));
3342
+ boundaries2 += 1;
3343
+ }
3344
+ if (fiber.sibling && fiber !== root) {
3345
+ stack.push({ fiber: fiber.sibling, boundaries: entry.boundaries });
3346
+ }
3347
+ if (fiber.child)
3348
+ stack.push({ fiber: fiber.child, boundaries: boundaries2 });
3349
+ }
3350
+ }
3351
+ function describe(fiber, depth) {
3352
+ const state = stateOf2(fiber);
3353
+ const createdBy = debugOwnerName(fiber._debugOwner);
3354
+ const boundary = { state, owners: ownersAbove(fiber), depth };
3355
+ if (createdBy !== null)
3356
+ boundary.createdBy = createdBy;
3357
+ if (fiber.key !== null)
3358
+ boundary.key = fiber.key;
3359
+ return boundary;
3360
+ }
3361
+ function stateOf2(fiber) {
3362
+ const state = fiber.memoizedState;
3363
+ if (state === null || state === void 0)
3364
+ return "resolved";
3365
+ if (typeof state !== "object")
3366
+ return "resolved";
3367
+ return state.dehydrated != null ? "dehydrated" : "pending";
3368
+ }
3369
+ function ownersAbove(fiber) {
3370
+ const names = [];
3371
+ let node = fiber.return;
3372
+ for (let depth = 0; node !== null && depth < MAX_WALK_DEPTH; depth += 1) {
3373
+ if (node.tag === FiberTag.HostRoot)
3374
+ break;
3375
+ if (isOwnerFrame(node))
3376
+ names.push(fiberComponentName(node));
3377
+ node = node.return;
3378
+ }
3379
+ return names;
3380
+ }
3381
+
3382
+ // packages/react/dist/arrival.js
3383
+ var DEFAULT_SUSPENSE_TIMEOUT_MS = 5e3;
3384
+ var DEFAULT_POLL_MS = 16;
3385
+ var DEFAULT_CONFIRMATIONS = 2;
3386
+ async function awaitSuspense(node, options = {}) {
3387
+ const timeoutMs = options.timeoutMs ?? DEFAULT_SUSPENSE_TIMEOUT_MS;
3388
+ const pollMs = Math.max(1, options.pollMs ?? DEFAULT_POLL_MS);
3389
+ const confirmations = Math.max(1, options.confirmations ?? DEFAULT_CONFIRMATIONS);
3390
+ const started = now();
3391
+ let clean = 0;
3392
+ for (; ; ) {
3393
+ const boundaries2 = boundariesUnder(node);
3394
+ if (boundaries2 === null) {
3395
+ return { outcome: "unobserved", waitedMs: now() - started, boundaries: 0, pending: [] };
3396
+ }
3397
+ const waiting = boundaries2.filter((boundary) => boundary.state !== "resolved");
3398
+ const waitedMs = now() - started;
3399
+ if (waiting.length === 0) {
3400
+ clean += 1;
3401
+ if (boundaries2.length === 0 || clean >= confirmations) {
3402
+ return { outcome: "settled", waitedMs, boundaries: boundaries2.length, pending: [] };
3403
+ }
3404
+ } else {
3405
+ clean = 0;
3406
+ }
3407
+ if (waitedMs >= timeoutMs) {
3408
+ return {
3409
+ outcome: waiting.length === 0 ? "settled" : "pending",
3410
+ waitedMs,
3411
+ boundaries: boundaries2.length,
3412
+ pending: waiting
3413
+ };
3414
+ }
3415
+ await sleep(pollMs);
3416
+ }
3417
+ }
3418
+ function now() {
3419
+ const clock = globalThis.performance;
3420
+ return clock && typeof clock.now === "function" ? clock.now() : Date.now();
3421
+ }
3422
+ function sleep(ms) {
3423
+ return new Promise((resolve) => {
3424
+ setTimeout(resolve, ms);
3425
+ });
3426
+ }
3427
+
3428
+ // packages/react/dist/wiring.js
3429
+ var HOST_TAGS2 = /* @__PURE__ */ new Set([
3430
+ FiberTag.HostRoot,
3431
+ FiberTag.HostComponent,
3432
+ FiberTag.HostText,
3433
+ FiberTag.HostPortal,
3434
+ FiberTag.HostHoistable,
3435
+ FiberTag.HostSingleton
3436
+ ]);
3437
+
3438
+ // packages/react/dist/holding.js
3439
+ var ABSENT = Symbol("absent");
3440
+
3441
+ // packages/react/dist/identity.js
3442
+ var HOST_TAGS3 = /* @__PURE__ */ new Set([
3443
+ FiberTag.HostRoot,
3444
+ FiberTag.HostComponent,
3445
+ FiberTag.HostText,
3446
+ FiberTag.HostPortal,
3447
+ FiberTag.HostHoistable,
3448
+ FiberTag.HostSingleton
3449
+ ]);
3450
+
3451
+ // packages/presentation/dist/browser-agent.js
3452
+ var PRESENTATION_AGENT = "__variance_authority_presentation__";
3453
+ var PRESENTATION_AGENT_VERSION = "presentation@0";
3454
+ var PRESENTATION_ROOT_ATTRIBUTE = "data-variance-authority-presentation-root";
3455
+ var PRESENTATION_OVERLAY_ATTRIBUTE = "data-variance-authority-presentation-overlay";
3456
+ var sequence = 0;
3457
+ async function acquirePresentation(root, request) {
3458
+ clearPresentationPaint();
3459
+ await awaitSuspense(root, request.suspense ?? {});
3460
+ const portalRoots = portalContentOf(root);
3461
+ const held = await stabilizeForObservation(root.ownerDocument, {
3462
+ recipe: request.stabilize === void 0 ? presentationRecipe([root, ...portalRoots]) : recipeOf(request.stabilize)
3463
+ });
3464
+ const capture = collect(root, {
3465
+ subject: request.subject,
3466
+ viewport: request.viewport,
3467
+ engine: request.engine,
3468
+ portalsOf: () => portalRoots,
3469
+ ...request.fonts === void 0 ? {} : { fonts: request.fonts },
3470
+ ...held.digest === void 0 ? {} : { stabilization: held.digest }
3471
+ });
3472
+ const current = ++sequence;
3473
+ const portals = portalRoots.map((portal, index) => {
3474
+ const previous = portal.getAttribute(PRESENTATION_ROOT_ATTRIBUTE);
3475
+ const marker = `${current}-${index}`;
3476
+ portal.setAttribute(PRESENTATION_ROOT_ATTRIBUTE, marker);
3477
+ return { marker, ...previous === null ? {} : { previous } };
3478
+ });
3479
+ return JSON.stringify({
3480
+ capture,
3481
+ stabilization: {
3482
+ ids: held.ids,
3483
+ ...held.digest === void 0 ? {} : { digest: held.digest }
3484
+ },
3485
+ portals
3486
+ });
3487
+ }
3488
+ function presentationRecipe(roots) {
3489
+ const waitForSubjectImages = {
3490
+ id: "wait-for-subject-images",
3491
+ trick: "wait",
3492
+ needs: "layout",
3493
+ governs: "images",
3494
+ because: "waited only for images inside the presentation subject and its portals",
3495
+ settle: async () => {
3496
+ const images = roots.flatMap((root) => [
3497
+ ...root.tagName.toLowerCase() === "img" ? [root] : [],
3498
+ ...Array.from(root.querySelectorAll("img"))
3499
+ ]);
3500
+ await Promise.all(images.filter((image) => !image.complete).map((image) => new Promise((resolve) => {
3501
+ image.addEventListener("load", () => resolve(), { once: true });
3502
+ image.addEventListener("error", () => resolve(), { once: true });
3503
+ })));
3504
+ }
3505
+ };
3506
+ return [
3507
+ ...COLLECT_RECIPE.filter((intervention) => intervention.id !== "wait-for-images"),
3508
+ waitForSubjectImages
3509
+ ];
3510
+ }
3511
+ function paintPresentation(instructions, layers) {
3512
+ clearPresentationPaint();
3513
+ const selected = layers === void 0 ? void 0 : new Set(layers);
3514
+ const visible = instructions.filter((instruction) => selected?.has(instruction.layer) ?? true);
3515
+ if (visible.length === 0)
3516
+ return 0;
3517
+ const document2 = globalThis.document;
3518
+ const namespace = "http://www.w3.org/2000/svg";
3519
+ const svg = document2.createElementNS(namespace, "svg");
3520
+ svg.setAttribute(PRESENTATION_OVERLAY_ATTRIBUTE, "");
3521
+ svg.setAttribute("aria-hidden", "true");
3522
+ svg.setAttribute("width", String(Math.max(document2.documentElement.scrollWidth, innerWidth)));
3523
+ svg.setAttribute("height", String(Math.max(document2.documentElement.scrollHeight, innerHeight)));
3524
+ Object.assign(svg.style, {
3525
+ position: "absolute",
3526
+ left: "0",
3527
+ top: "0",
3528
+ pointerEvents: "none",
3529
+ overflow: "visible",
3530
+ zIndex: "2147483647"
3531
+ });
3532
+ for (const instruction of visible) {
3533
+ const group = document2.createElementNS(namespace, "g");
3534
+ group.setAttribute("data-layer", instruction.layer);
3535
+ group.setAttribute("data-measurement", instruction.id);
3536
+ if (instruction.shape === "rect" && instruction.rect !== void 0) {
3537
+ const rectangle = document2.createElementNS(namespace, "rect");
3538
+ rectangle.setAttribute("x", String(instruction.rect.x + scrollX));
3539
+ rectangle.setAttribute("y", String(instruction.rect.y + scrollY));
3540
+ rectangle.setAttribute("width", String(instruction.rect.width));
3541
+ rectangle.setAttribute("height", String(instruction.rect.height));
3542
+ rectangle.setAttribute("fill", "none");
3543
+ rectangle.setAttribute("stroke", instruction.color);
3544
+ rectangle.setAttribute("stroke-width", instruction.layer === "findings" ? "3" : "1");
3545
+ rectangle.setAttribute("stroke-dasharray", instruction.layer === "semantic" ? "3 2" : "none");
3546
+ group.append(rectangle);
3547
+ group.append(paintLabel(instruction.label, instruction.rect.x + scrollX + 2, instruction.rect.y + scrollY + 11));
3548
+ } else if (instruction.shape === "line" && instruction.line !== void 0) {
3549
+ const line = document2.createElementNS(namespace, "line");
3550
+ line.setAttribute("x1", String(instruction.line.x1 + scrollX));
3551
+ line.setAttribute("y1", String(instruction.line.y1 + scrollY));
3552
+ line.setAttribute("x2", String(instruction.line.x2 + scrollX));
3553
+ line.setAttribute("y2", String(instruction.line.y2 + scrollY));
3554
+ line.setAttribute("stroke", instruction.color);
3555
+ group.append(line);
3556
+ group.append(paintLabel(instruction.label, (instruction.line.x1 + instruction.line.x2) / 2 + scrollX, (instruction.line.y1 + instruction.line.y2) / 2 + scrollY));
3557
+ }
3558
+ svg.append(group);
3559
+ }
3560
+ document2.documentElement.append(svg);
3561
+ return visible.length;
3562
+ }
3563
+ function clearPresentationPaint() {
3564
+ globalThis.document?.querySelector(`[${PRESENTATION_OVERLAY_ATTRIBUTE}]`)?.remove();
3565
+ }
3566
+ function paintLabel(text, x, y) {
3567
+ const value = document.createElementNS("http://www.w3.org/2000/svg", "text");
3568
+ value.setAttribute("x", String(x));
3569
+ value.setAttribute("y", String(y));
3570
+ value.setAttribute("fill", "#111");
3571
+ value.setAttribute("stroke", "#fff");
3572
+ value.setAttribute("stroke-width", "3");
3573
+ value.setAttribute("paint-order", "stroke");
3574
+ value.setAttribute("font-family", "ui-monospace, monospace");
3575
+ value.setAttribute("font-size", "10");
3576
+ value.textContent = text;
3577
+ return value;
3578
+ }
3579
+
3580
+ // packages/presentation/dist/browser-agent-entry.js
3581
+ globalThis[PRESENTATION_AGENT] = {
3582
+ acquire: acquirePresentation,
3583
+ paint: paintPresentation,
3584
+ clear: clearPresentationPaint,
3585
+ version: PRESENTATION_AGENT_VERSION
3586
+ };
3587
+ })();