praxis-kit 1.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.
@@ -0,0 +1,1922 @@
1
+ // ../../adapters/vue/src/create-contract-component.ts
2
+ import { computed, defineComponent as defineComponent2 } from "vue";
3
+
4
+ // ../shared/src/guards/children/component-id.ts
5
+ var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol("praxis.component-default-tag");
6
+
7
+ // ../../adapters/vue/src/apply-display-name.ts
8
+ function applyDisplayName(component, name) {
9
+ Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
10
+ }
11
+
12
+ // ../../lib/adapter-utils/src/apply-filter.ts
13
+ function applyFilter(props, filterProps, variantKeys) {
14
+ const out = {};
15
+ for (const k in props) {
16
+ if (!Object.hasOwn(props, k)) continue;
17
+ if (filterProps(k, variantKeys)) continue;
18
+ out[k] = props[k];
19
+ }
20
+ return out;
21
+ }
22
+
23
+ // ../core/dist/chunk-US6MPMDF.js
24
+ function makeResolveTag(defaultTag) {
25
+ return function tag(as) {
26
+ return as ?? defaultTag;
27
+ };
28
+ }
29
+ function assertNever(value) {
30
+ throw new Error(`Unexpected value: ${String(value)}`);
31
+ }
32
+ function r(e) {
33
+ var t, f, n = "";
34
+ if ("string" == typeof e || "number" == typeof e) n += e;
35
+ else if ("object" == typeof e) if (Array.isArray(e)) {
36
+ var o = e.length;
37
+ for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
38
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
39
+ return n;
40
+ }
41
+ function clsx() {
42
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
43
+ return n;
44
+ }
45
+ function cn(...inputs) {
46
+ return clsx(...inputs);
47
+ }
48
+ function mergeProps(defaultProps, props) {
49
+ return {
50
+ ...defaultProps ?? {},
51
+ ...props
52
+ };
53
+ }
54
+ function isNull(value) {
55
+ return value === null;
56
+ }
57
+ function isObject(value) {
58
+ return !isNull(value) && typeof value === "object";
59
+ }
60
+ function isString(value) {
61
+ return typeof value === "string";
62
+ }
63
+ function isNumber(value) {
64
+ return typeof value === "number";
65
+ }
66
+ var EMPTY_VARIANT_KEYS = /* @__PURE__ */ new Set();
67
+ function composeNormalizers(normalizers, fn) {
68
+ if (!normalizers?.length) return fn;
69
+ return ((props) => {
70
+ const patched = normalizers.reduce(
71
+ (acc, normalizer) => ({ ...acc, ...normalizer(acc) }),
72
+ props
73
+ );
74
+ return fn ? fn(patched) : patched;
75
+ });
76
+ }
77
+ function whenDefined(key, value) {
78
+ return value === void 0 ? {} : { [key]: value };
79
+ }
80
+ function resolveFactoryOptions(options = {}) {
81
+ const { styling, enforcement } = options;
82
+ const composedNormalizeFn = composeNormalizers(enforcement?.props, options.normalize);
83
+ const variantKeys = styling?.variants === void 0 ? EMPTY_VARIANT_KEYS : new Set(Object.keys(styling.variants));
84
+ return Object.freeze({
85
+ defaultTag: options.tag ?? "div",
86
+ strict: enforcement?.strict ?? false,
87
+ variantKeys,
88
+ ...whenDefined("displayName", options.name),
89
+ ...whenDefined("defaultProps", options.defaults),
90
+ ...whenDefined("baseClassName", styling?.base),
91
+ ...whenDefined("tagMap", styling?.tags),
92
+ ...whenDefined("presetMap", styling?.presets),
93
+ ...whenDefined("variants", styling?.variants),
94
+ ...whenDefined("defaultVariants", styling?.defaults),
95
+ ...whenDefined("compoundVariants", styling?.compounds),
96
+ ...whenDefined("normalizeFn", composedNormalizeFn),
97
+ ...whenDefined("ariaRules", enforcement?.aria),
98
+ ...whenDefined("childRules", enforcement?.children),
99
+ ...whenDefined("allowedAs", enforcement?.allowedAs),
100
+ ...whenDefined("precomputedClasses", styling?.precomputedClasses)
101
+ });
102
+ }
103
+ function report(strict, message) {
104
+ if (strict === false) return;
105
+ const mode = strict === true ? "throw" : strict;
106
+ if (mode === "throw") throw new Error(message);
107
+ console.warn(message);
108
+ }
109
+ function validateFactoryOptions(resolved) {
110
+ const { strict } = resolved;
111
+ if (strict === false) return;
112
+ const name = resolved.displayName ?? "Component";
113
+ const { variants } = resolved;
114
+ const checkSelection = (label2, selection) => {
115
+ const record = selection;
116
+ for (const dim in record) {
117
+ const value = record[dim];
118
+ if (value === void 0 || value === null) continue;
119
+ if (!variants || !Object.hasOwn(variants, dim)) {
120
+ report(strict, `${name}: ${label2} references unknown variant "${dim}".`);
121
+ continue;
122
+ }
123
+ const states = variants[dim];
124
+ const stateKey = String(value);
125
+ if (!Object.hasOwn(states, stateKey)) {
126
+ report(
127
+ strict,
128
+ `${name}: ${label2} sets "${dim}" to unknown value "${stateKey}" (valid: ${Object.keys(states).join(", ")}).`
129
+ );
130
+ }
131
+ }
132
+ };
133
+ const { presetMap } = resolved;
134
+ if (presetMap) {
135
+ for (const presetKey in presetMap) {
136
+ checkSelection(`preset "${presetKey}"`, presetMap[presetKey]);
137
+ }
138
+ }
139
+ if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
140
+ }
141
+ var warned = /* @__PURE__ */ new Set();
142
+ var pendingAsyncWarns = /* @__PURE__ */ new Set();
143
+ var asyncWarnScheduled = false;
144
+ function flushAsyncWarns() {
145
+ asyncWarnScheduled = false;
146
+ const messages = [...pendingAsyncWarns];
147
+ pendingAsyncWarns.clear();
148
+ for (const msg of messages) {
149
+ console.warn(msg);
150
+ }
151
+ }
152
+ function report2(strict, message) {
153
+ if (!strict) return;
154
+ const mode = strict === true ? "throw" : strict;
155
+ if (mode === "throw") throw new Error(message);
156
+ if (mode === "async-warn") {
157
+ if (pendingAsyncWarns.has(message)) return;
158
+ pendingAsyncWarns.add(message);
159
+ if (!asyncWarnScheduled) {
160
+ asyncWarnScheduled = true;
161
+ queueMicrotask(flushAsyncWarns);
162
+ }
163
+ return;
164
+ }
165
+ if (warned.has(message)) return;
166
+ warned.add(message);
167
+ console.warn(message);
168
+ }
169
+ function label(name) {
170
+ return name ? `[${name}]` : "[createContractComponent]";
171
+ }
172
+ function validateRenderProps(options, props, presetKey) {
173
+ const { strict, presetMap, variants, displayName } = options;
174
+ if (!strict) return;
175
+ const tag = label(displayName);
176
+ if (presetKey !== void 0 && (!presetMap || !Object.hasOwn(presetMap, presetKey))) {
177
+ report2(strict, `${tag} Unknown presetKey "${presetKey}" \u2014 no preset with that name exists.`);
178
+ }
179
+ if (variants) {
180
+ for (const key in variants) {
181
+ if (!Object.hasOwn(props, key)) continue;
182
+ const value = props[key];
183
+ if (value === void 0 || value === null) continue;
184
+ const dim = variants[key];
185
+ if (dim && !Object.hasOwn(dim, String(value))) {
186
+ report2(
187
+ strict,
188
+ `${tag} Variant "${key}=${String(value)}" is not a defined value for the "${key}" dimension.`
189
+ );
190
+ }
191
+ }
192
+ }
193
+ }
194
+ function panic(message) {
195
+ throw new Error(message);
196
+ }
197
+ function describe(value) {
198
+ if (value === null) return "null";
199
+ if (Array.isArray(value)) return "array";
200
+ return typeof value;
201
+ }
202
+ function assertPluginShape(result) {
203
+ if (result === null || typeof result !== "object")
204
+ panic(
205
+ `[praxis-kit] Plugin factory must return an object with a 'pipeline' function. Got: ${result === null ? "null" : typeof result}.`
206
+ );
207
+ const plugin = result;
208
+ if (typeof plugin.pipeline !== "function")
209
+ panic(
210
+ `[praxis-kit] Plugin factory return value is missing a 'pipeline' function. Got pipeline: ${typeof plugin.pipeline}.`
211
+ );
212
+ }
213
+ function guardPipeline(pipeline) {
214
+ if (process.env.NODE_ENV === "production") return pipeline;
215
+ return function guardedPipeline(tag, props, className, variantKey) {
216
+ const result = pipeline(tag, props, className, variantKey);
217
+ if (typeof result !== "string")
218
+ panic(`[praxis-kit] Plugin pipeline must return a string. Got: ${describe(result)}.`);
219
+ return result;
220
+ };
221
+ }
222
+ var NOOP_CLASS_PIPELINE = (_tag, _props, className) => Array.isArray(className) ? className.join(" ") : className ?? "";
223
+ function resolveClassPipeline(options, resolved, strict, capabilities) {
224
+ const factory = options.styling?.plugin;
225
+ if (!factory) {
226
+ const createClassPipeline2 = capabilities?.createClassPipeline;
227
+ const classPipeline2 = createClassPipeline2 ? createClassPipeline2(resolved) : NOOP_CLASS_PIPELINE;
228
+ return { pluginResult: void 0, classPipeline: classPipeline2 };
229
+ }
230
+ const pluginResult = factory(resolved, strict);
231
+ assertPluginShape(pluginResult);
232
+ const classPipeline = guardPipeline(pluginResult.pipeline);
233
+ return { pluginResult, classPipeline };
234
+ }
235
+ function createRuntimeMethods(resolved, classPipeline, engine) {
236
+ return {
237
+ resolveTag: makeResolveTag(resolved.defaultTag),
238
+ resolveProps(props) {
239
+ return mergeProps(resolved.defaultProps, props);
240
+ },
241
+ resolveClasses(tag, props, className, variantKey) {
242
+ if (process.env.NODE_ENV !== "production") {
243
+ validateRenderProps(resolved, props, variantKey);
244
+ }
245
+ return classPipeline(tag, props, className, variantKey);
246
+ },
247
+ resolveAria(tag, props) {
248
+ if (!engine) return { props };
249
+ const result = engine.validate(tag, props);
250
+ return { props: result.props };
251
+ }
252
+ };
253
+ }
254
+ function createRuntimeObject(methods, resolved, pluginResult) {
255
+ return pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
256
+ }
257
+ function createPolymorphic(options = {}, capabilities) {
258
+ const resolved = resolveFactoryOptions(options);
259
+ if (process.env.NODE_ENV !== "production") validateFactoryOptions(resolved);
260
+ const { pluginResult, classPipeline } = resolveClassPipeline(
261
+ options,
262
+ resolved,
263
+ resolved.strict,
264
+ capabilities
265
+ );
266
+ const engine = options.enforcement !== void 0 && capabilities?.AriaEngine ? new capabilities.AriaEngine(
267
+ resolved.strict,
268
+ resolved.ariaRules?.length ? { rules: resolved.ariaRules } : void 0
269
+ ) : null;
270
+ const methods = createRuntimeMethods(resolved, classPipeline, engine);
271
+ return createRuntimeObject(
272
+ methods,
273
+ resolved,
274
+ pluginResult
275
+ );
276
+ }
277
+ var KNOWN_ARIA_ROLES = [
278
+ "alert",
279
+ "alertdialog",
280
+ "application",
281
+ "article",
282
+ "banner",
283
+ "blockquote",
284
+ "button",
285
+ "caption",
286
+ "cell",
287
+ "checkbox",
288
+ "code",
289
+ "columnheader",
290
+ "combobox",
291
+ "complementary",
292
+ "contentinfo",
293
+ "definition",
294
+ "deletion",
295
+ "dialog",
296
+ "document",
297
+ "emphasis",
298
+ "feed",
299
+ "figure",
300
+ "form",
301
+ "generic",
302
+ "grid",
303
+ "gridcell",
304
+ "group",
305
+ "heading",
306
+ "img",
307
+ "insertion",
308
+ "link",
309
+ "list",
310
+ "listbox",
311
+ "listitem",
312
+ "log",
313
+ "main",
314
+ "marquee",
315
+ "math",
316
+ "menu",
317
+ "menubar",
318
+ "menuitem",
319
+ "menuitemcheckbox",
320
+ "menuitemradio",
321
+ "meter",
322
+ "navigation",
323
+ "none",
324
+ "note",
325
+ "option",
326
+ "paragraph",
327
+ "presentation",
328
+ "progressbar",
329
+ "radio",
330
+ "radiogroup",
331
+ "region",
332
+ "row",
333
+ "rowgroup",
334
+ "rowheader",
335
+ "scrollbar",
336
+ "search",
337
+ "searchbox",
338
+ "separator",
339
+ "slider",
340
+ "spinbutton",
341
+ "status",
342
+ "strong",
343
+ "subscript",
344
+ "superscript",
345
+ "switch",
346
+ "tab",
347
+ "table",
348
+ "tablist",
349
+ "tabpanel",
350
+ "term",
351
+ "textbox",
352
+ "time",
353
+ "timer",
354
+ "toolbar",
355
+ "tooltip",
356
+ "tree",
357
+ "treegrid",
358
+ "treeitem"
359
+ ];
360
+ var KNOWN_ARIA_ROLES_SET = new Set(KNOWN_ARIA_ROLES);
361
+ var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
362
+ "aria-atomic",
363
+ "aria-busy",
364
+ "aria-controls",
365
+ "aria-current",
366
+ "aria-describedby",
367
+ "aria-details",
368
+ "aria-disabled",
369
+ "aria-errormessage",
370
+ "aria-flowto",
371
+ "aria-hidden",
372
+ "aria-keyshortcuts",
373
+ "aria-label",
374
+ "aria-labelledby",
375
+ "aria-live",
376
+ "aria-owns",
377
+ "aria-relevant",
378
+ "aria-roledescription"
379
+ ]);
380
+ var IMPLICIT_ROLE_RECORD = {
381
+ article: "article",
382
+ aside: "complementary",
383
+ footer: "contentinfo",
384
+ header: "banner",
385
+ main: "main",
386
+ nav: "navigation",
387
+ button: "button",
388
+ a: "link",
389
+ select: "listbox",
390
+ h1: "heading",
391
+ h2: "heading",
392
+ h3: "heading",
393
+ h4: "heading",
394
+ h5: "heading",
395
+ h6: "heading",
396
+ ul: "list",
397
+ ol: "list",
398
+ li: "listitem",
399
+ table: "table",
400
+ tr: "row",
401
+ td: "cell",
402
+ th: "columnheader"
403
+ };
404
+ var STRONG_ROLES = [
405
+ "main",
406
+ "navigation",
407
+ "complementary",
408
+ "contentinfo",
409
+ "banner"
410
+ ];
411
+ var STANDALONE_ROLES = ["article"];
412
+ var STRONG_ROLES_SET = new Set(STRONG_ROLES);
413
+ var STANDALONE_ROLES_SET = new Set(STANDALONE_ROLES);
414
+ var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
415
+ [
416
+ "aria-activedescendant",
417
+ /* @__PURE__ */ new Set([
418
+ "application",
419
+ "combobox",
420
+ "grid",
421
+ "group",
422
+ "listbox",
423
+ "menu",
424
+ "menubar",
425
+ "radiogroup",
426
+ "spinbutton",
427
+ "tablist",
428
+ "toolbar",
429
+ "textbox",
430
+ "tree",
431
+ "treegrid"
432
+ ])
433
+ ],
434
+ ["aria-autocomplete", /* @__PURE__ */ new Set(["combobox", "searchbox", "textbox"])],
435
+ [
436
+ "aria-checked",
437
+ /* @__PURE__ */ new Set(["checkbox", "menuitemcheckbox", "option", "radio", "switch", "treeitem"])
438
+ ],
439
+ ["aria-colcount", /* @__PURE__ */ new Set(["grid", "table", "treegrid"])],
440
+ ["aria-colindex", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "row", "rowheader"])],
441
+ ["aria-colspan", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "rowheader"])],
442
+ [
443
+ "aria-expanded",
444
+ /* @__PURE__ */ new Set([
445
+ "button",
446
+ "combobox",
447
+ "gridcell",
448
+ "listbox",
449
+ "menuitem",
450
+ "menuitemcheckbox",
451
+ "menuitemradio",
452
+ "row",
453
+ "rowheader",
454
+ "tab",
455
+ "treeitem"
456
+ ])
457
+ ],
458
+ [
459
+ "aria-haspopup",
460
+ /* @__PURE__ */ new Set([
461
+ "button",
462
+ "combobox",
463
+ "gridcell",
464
+ "listbox",
465
+ "menuitem",
466
+ "menuitemcheckbox",
467
+ "menuitemradio",
468
+ "tab",
469
+ "treeitem"
470
+ ])
471
+ ],
472
+ ["aria-level", /* @__PURE__ */ new Set(["heading", "listitem", "row", "treeitem"])],
473
+ ["aria-modal", /* @__PURE__ */ new Set(["alertdialog", "dialog"])],
474
+ ["aria-multiline", /* @__PURE__ */ new Set(["textbox"])],
475
+ ["aria-multiselectable", /* @__PURE__ */ new Set(["grid", "listbox", "tablist", "tree", "treegrid"])],
476
+ [
477
+ "aria-orientation",
478
+ /* @__PURE__ */ new Set(["scrollbar", "select", "separator", "slider", "tablist", "toolbar", "tree"])
479
+ ],
480
+ ["aria-placeholder", /* @__PURE__ */ new Set(["searchbox", "textbox"])],
481
+ [
482
+ "aria-posinset",
483
+ /* @__PURE__ */ new Set([
484
+ "article",
485
+ "listitem",
486
+ "menuitem",
487
+ "menuitemcheckbox",
488
+ "menuitemradio",
489
+ "option",
490
+ "radio",
491
+ "row",
492
+ "tab"
493
+ ])
494
+ ],
495
+ ["aria-pressed", /* @__PURE__ */ new Set(["button"])],
496
+ [
497
+ "aria-readonly",
498
+ /* @__PURE__ */ new Set([
499
+ "combobox",
500
+ "grid",
501
+ "gridcell",
502
+ "listbox",
503
+ "radiogroup",
504
+ "slider",
505
+ "spinbutton",
506
+ "textbox",
507
+ "tree",
508
+ "treegrid"
509
+ ])
510
+ ],
511
+ [
512
+ "aria-required",
513
+ /* @__PURE__ */ new Set([
514
+ "combobox",
515
+ "gridcell",
516
+ "listbox",
517
+ "radiogroup",
518
+ "spinbutton",
519
+ "textbox",
520
+ "tree",
521
+ "treegrid"
522
+ ])
523
+ ],
524
+ ["aria-rowcount", /* @__PURE__ */ new Set(["grid", "table", "treegrid"])],
525
+ ["aria-rowindex", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "row", "rowheader"])],
526
+ ["aria-rowspan", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "rowheader"])],
527
+ [
528
+ "aria-selected",
529
+ /* @__PURE__ */ new Set(["columnheader", "gridcell", "option", "row", "rowheader", "tab", "treeitem"])
530
+ ],
531
+ [
532
+ "aria-setsize",
533
+ /* @__PURE__ */ new Set([
534
+ "article",
535
+ "listitem",
536
+ "menuitem",
537
+ "menuitemcheckbox",
538
+ "menuitemradio",
539
+ "option",
540
+ "radio",
541
+ "row",
542
+ "tab"
543
+ ])
544
+ ],
545
+ ["aria-sort", /* @__PURE__ */ new Set(["columnheader", "rowheader"])],
546
+ [
547
+ "aria-valuemax",
548
+ /* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
549
+ ],
550
+ [
551
+ "aria-valuemin",
552
+ /* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
553
+ ],
554
+ [
555
+ "aria-valuenow",
556
+ /* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
557
+ ],
558
+ [
559
+ "aria-valuetext",
560
+ /* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
561
+ ]
562
+ ]);
563
+ function isUndefined(value) {
564
+ return value === void 0;
565
+ }
566
+ function isGlobalAriaAttribute(attr) {
567
+ return GLOBAL_ARIA_ATTRIBUTES.has(attr);
568
+ }
569
+ function isAriaAttributeValidForRole(attr, role) {
570
+ const allowedRoles = ROLE_RESTRICTED_ATTRIBUTES.get(attr);
571
+ if (isUndefined(allowedRoles)) return true;
572
+ if (isUndefined(role)) return false;
573
+ return allowedRoles.has(role);
574
+ }
575
+ function isStrongImplicitRole(tag) {
576
+ if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
577
+ return STRONG_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
578
+ }
579
+ function isStandaloneTag(tag) {
580
+ if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
581
+ return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
582
+ }
583
+ function isKnownAriaRole(value) {
584
+ return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
585
+ }
586
+
587
+ // ../core/dist/chunk-7YNORQXK.js
588
+ var COMPONENT_DEFAULT_TAG2 = /* @__PURE__ */ Symbol("praxis.component-default-tag");
589
+ function resolveChildTag(child) {
590
+ if (!isObject(child) || !("type" in child)) return void 0;
591
+ const t = child.type;
592
+ if (isString(t)) return t;
593
+ if (isObject(t) && COMPONENT_DEFAULT_TAG2 in t) {
594
+ const defaultTag = t[COMPONENT_DEFAULT_TAG2];
595
+ if (!isString(defaultTag)) return void 0;
596
+ const props = child.props;
597
+ const as = isObject(props) && "as" in props ? props.as : void 0;
598
+ return isString(as) ? as : defaultTag;
599
+ }
600
+ return void 0;
601
+ }
602
+ function isTag(...tags) {
603
+ const set = new Set(tags);
604
+ return (child) => {
605
+ const tag = resolveChildTag(child);
606
+ return tag !== void 0 && set.has(tag);
607
+ };
608
+ }
609
+ function isOpenContent(...blockedTags) {
610
+ const set = new Set(blockedTags);
611
+ return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set.has(child.type));
612
+ }
613
+ var METADATA_TAGS = ["script", "template"];
614
+ var metadataMatch = isTag(...METADATA_TAGS);
615
+ function metadata(name = "metadata") {
616
+ return { name, match: metadataMatch };
617
+ }
618
+ function firstOptional(name, tag) {
619
+ return { name, match: isTag(tag), cardinality: { max: 1 }, position: "first" };
620
+ }
621
+ function contract(children) {
622
+ return { strict: "warn", children };
623
+ }
624
+ function ariaContract(aria) {
625
+ return { strict: "warn", aria };
626
+ }
627
+ function firstChildContract(name, tag) {
628
+ return contract([firstOptional(name, tag), { name: "content", match: isOpenContent(tag) }]);
629
+ }
630
+ var VOID_TAGS = [
631
+ "area",
632
+ "base",
633
+ "br",
634
+ "col",
635
+ "embed",
636
+ "hr",
637
+ "img",
638
+ "input",
639
+ "link",
640
+ "meta",
641
+ "param",
642
+ "source",
643
+ "track",
644
+ "wbr"
645
+ ];
646
+ var TEXT_ONLY_TAGS = ["option", "script", "style", "textarea", "title"];
647
+ var LANDMARK_TAGS = ["article", "aside", "footer", "header", "main", "nav"];
648
+ var listContract = contract([{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }]);
649
+ var tableContract = contract([
650
+ firstOptional("caption", "caption"),
651
+ { name: "colgroup", match: isTag("colgroup") },
652
+ { name: "thead", match: isTag("thead"), cardinality: { max: 1 } },
653
+ { name: "tbody", match: isTag("tbody") },
654
+ { name: "tfoot", match: isTag("tfoot"), cardinality: { max: 1 } },
655
+ { name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
656
+ ]);
657
+ var tableBodyContract = contract([
658
+ { name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
659
+ ]);
660
+ var tableRowContract = contract([
661
+ { name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
662
+ ]);
663
+ var colgroupContract = contract([{ name: "column", match: isTag("col", "template") }]);
664
+ var dlContract = contract([
665
+ { name: "term", match: isTag("dt") },
666
+ { name: "description", match: isTag("dd") },
667
+ { name: "group", match: isTag("div") },
668
+ metadata()
669
+ ]);
670
+ var selectContract = contract([
671
+ { name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
672
+ ]);
673
+ var optgroupContract = contract([
674
+ { name: "option", match: isTag("option", ...METADATA_TAGS) }
675
+ ]);
676
+ var datalistContract = contract([
677
+ { name: "option", match: isTag("option", ...METADATA_TAGS) }
678
+ ]);
679
+ var pictureContract = contract([
680
+ { name: "source", match: isTag("source", ...METADATA_TAGS) },
681
+ { name: "image", match: isTag("img"), cardinality: { min: 1, max: 1 }, position: "last" }
682
+ ]);
683
+ var figureContract = contract([
684
+ { name: "caption", match: isTag("figcaption"), cardinality: { max: 1 } },
685
+ { name: "content", match: isOpenContent("figcaption") }
686
+ ]);
687
+ var detailsContract = firstChildContract("summary", "summary");
688
+ var fieldsetContract = firstChildContract("legend", "legend");
689
+ var mediaContract = contract([
690
+ { name: "source", match: isTag("source") },
691
+ { name: "track", match: isTag("track") },
692
+ metadata(),
693
+ { name: "content", match: isOpenContent("source", "track", ...METADATA_TAGS) }
694
+ ]);
695
+ var headContract = contract([
696
+ {
697
+ name: "metadata",
698
+ match: isTag("base", "link", "meta", "noscript", "script", "style", "template", "title")
699
+ }
700
+ ]);
701
+ var htmlContract = contract([
702
+ { name: "head", match: isTag("head"), cardinality: { min: 1, max: 1 }, position: "first" },
703
+ { name: "body", match: isTag("body"), cardinality: { min: 1, max: 1 } }
704
+ ]);
705
+ var voidContract = contract([]);
706
+ var textOnlyContract = contract([
707
+ {
708
+ name: "text",
709
+ match: (child) => isString(child) || isNumber(child)
710
+ }
711
+ ]);
712
+ var LANDMARK_TAG_SET = new Set(LANDMARK_TAGS);
713
+ var removeLandmarkRoleOverride = {
714
+ kind: "removeRole",
715
+ apply: ({ props }) => {
716
+ if (!("role" in props)) return { applied: false, next: props };
717
+ const { role: _r, ...rest } = props;
718
+ return { applied: true, next: rest, previous: props };
719
+ }
720
+ };
721
+ function landmarkRoleRule({ tag, props, implicitRole }) {
722
+ if (!LANDMARK_TAG_SET.has(tag) || !implicitRole) return [];
723
+ const role = props.role;
724
+ if (!role || role === implicitRole) return [];
725
+ return [
726
+ {
727
+ valid: false,
728
+ fixable: true,
729
+ severity: "error",
730
+ fix: removeLandmarkRoleOverride,
731
+ message: `<${tag}> has a fixed landmark role="${implicitRole}". role="${role}" overrides it and confuses assistive technology. The override has been removed.`
732
+ }
733
+ ];
734
+ }
735
+ var landmarkContract = ariaContract([landmarkRoleRule]);
736
+ var CONTRACT_GROUPS = [
737
+ [VOID_TAGS, voidContract],
738
+ [TEXT_ONLY_TAGS, textOnlyContract],
739
+ [LANDMARK_TAGS, landmarkContract],
740
+ [["ul", "ol", "menu"], listContract],
741
+ [["audio", "video"], mediaContract],
742
+ [["thead", "tbody", "tfoot"], tableBodyContract]
743
+ ];
744
+ function contractMap(groups) {
745
+ return Object.fromEntries(
746
+ groups.flatMap(([tags, enforcement]) => tags.map((tag) => [tag, enforcement]))
747
+ );
748
+ }
749
+ var htmlContracts = {
750
+ ...contractMap(CONTRACT_GROUPS),
751
+ table: tableContract,
752
+ tr: tableRowContract,
753
+ colgroup: colgroupContract,
754
+ dl: dlContract,
755
+ select: selectContract,
756
+ optgroup: optgroupContract,
757
+ datalist: datalistContract,
758
+ picture: pictureContract,
759
+ figure: figureContract,
760
+ details: detailsContract,
761
+ fieldset: fieldsetContract,
762
+ head: headContract,
763
+ html: htmlContract
764
+ };
765
+ var IMPLICIT_ROLE_RECORD2 = {
766
+ article: "article",
767
+ aside: "complementary",
768
+ footer: "contentinfo",
769
+ header: "banner",
770
+ main: "main",
771
+ nav: "navigation",
772
+ button: "button",
773
+ a: "link",
774
+ select: "listbox",
775
+ h1: "heading",
776
+ h2: "heading",
777
+ h3: "heading",
778
+ h4: "heading",
779
+ h5: "heading",
780
+ h6: "heading",
781
+ ul: "list",
782
+ ol: "list",
783
+ li: "listitem",
784
+ table: "table",
785
+ tr: "row",
786
+ td: "cell",
787
+ th: "columnheader"
788
+ };
789
+ function getImplicitRole(tag) {
790
+ if (tag in IMPLICIT_ROLE_RECORD2) return IMPLICIT_ROLE_RECORD2[tag];
791
+ return void 0;
792
+ }
793
+ var pendingAsyncWarns2 = /* @__PURE__ */ new Set();
794
+ var asyncWarnScheduled2 = false;
795
+ function flushAsyncWarns2() {
796
+ asyncWarnScheduled2 = false;
797
+ const messages = [...pendingAsyncWarns2];
798
+ pendingAsyncWarns2.clear();
799
+ for (const msg of messages) {
800
+ console.warn(msg);
801
+ }
802
+ }
803
+ function scheduleAsyncWarn(message) {
804
+ if (pendingAsyncWarns2.has(message)) return;
805
+ pendingAsyncWarns2.add(message);
806
+ if (!asyncWarnScheduled2) {
807
+ asyncWarnScheduled2 = true;
808
+ queueMicrotask(flushAsyncWarns2);
809
+ }
810
+ }
811
+ var StrictBase = class {
812
+ strict;
813
+ constructor(strict) {
814
+ this.strict = strict;
815
+ }
816
+ violate(message) {
817
+ if (this.strict === true || this.strict === "throw") {
818
+ throw new Error(message);
819
+ }
820
+ this.warn(message);
821
+ }
822
+ // Always caps at console.warn — never throws. ARIA 'warning' violations route here
823
+ // so they surface even in strict='throw' mode without aborting a render.
824
+ warn(message) {
825
+ if (!this.strict) return;
826
+ if (this.strict === "async-warn") {
827
+ scheduleAsyncWarn(message);
828
+ return;
829
+ }
830
+ console.warn(message);
831
+ }
832
+ invariant(condition, message) {
833
+ if (!condition) {
834
+ this.violate(message);
835
+ }
836
+ }
837
+ };
838
+ function isNull2(value) {
839
+ return value === null;
840
+ }
841
+ var VALID = [{ valid: true }];
842
+ function isIntrinsicTag(tag) {
843
+ return isString(tag);
844
+ }
845
+ function omitProp(obj, key) {
846
+ const { [key]: _, ...rest } = obj;
847
+ return rest;
848
+ }
849
+ var AriaPolicyEngine = class _AriaPolicyEngine extends StrictBase {
850
+ #extraRules;
851
+ #planCache = /* @__PURE__ */ new Map();
852
+ static #MAX_CACHE = 100;
853
+ // Memoized AriaFix objects keyed by attribute name — the ARIA attribute set is
854
+ // finite so this Map is bounded and avoids recreating closures on every cache miss.
855
+ static #removeAttributeFixCache = /* @__PURE__ */ new Map();
856
+ constructor(strict = "warn", options) {
857
+ super(strict);
858
+ this.#extraRules = options?.rules ?? [];
859
+ }
860
+ static #normalizeEmptyRole(tag, props) {
861
+ if (props.role !== "") return { normalized: false };
862
+ return {
863
+ normalized: true,
864
+ result: {
865
+ props: omitProp(props, "role"),
866
+ violations: [
867
+ {
868
+ message: `<${tag}> has an explicit empty role="". Omit the attribute instead.`,
869
+ tag,
870
+ role: "",
871
+ attribute: void 0,
872
+ severity: "warning",
873
+ phase: "evaluate"
874
+ }
875
+ ]
876
+ }
877
+ };
878
+ }
879
+ static #deriveContext(tag, props) {
880
+ if (!isIntrinsicTag(tag)) return { proceed: false, result: { props, violations: [] } };
881
+ const implicitRole = getImplicitRole(tag);
882
+ const hasExplicitLiveRole = !implicitRole && _AriaPolicyEngine.#LIVE_REGION_ROLES.has(props.role ?? "");
883
+ if (!implicitRole && !hasExplicitLiveRole)
884
+ return { proceed: false, result: { props, violations: [] } };
885
+ const normalized = _AriaPolicyEngine.#normalizeEmptyRole(tag, props);
886
+ if (normalized.normalized) return { proceed: false, result: normalized.result };
887
+ const effectiveRole = props.role ?? implicitRole;
888
+ return {
889
+ proceed: true,
890
+ tag,
891
+ implicitRole,
892
+ effectiveRole,
893
+ context: { tag, props, implicitRole, effectiveRole }
894
+ };
895
+ }
896
+ static #runRules(rules, context) {
897
+ const violations = [];
898
+ const fixes = [];
899
+ for (const rule of rules) {
900
+ for (const result of rule(context)) {
901
+ if (!result.valid) {
902
+ violations.push({
903
+ message: result.message ?? `Invalid role "${context.props.role}" on <${context.tag}>`,
904
+ tag: context.tag,
905
+ role: context.props.role,
906
+ attribute: result.attribute,
907
+ severity: result.severity,
908
+ phase: "evaluate"
909
+ });
910
+ if (result.fixable) fixes.push(result.fix);
911
+ }
912
+ }
913
+ }
914
+ return { violations, fixes };
915
+ }
916
+ static #getRules(context) {
917
+ return _AriaPolicyEngine.#hasRole(context.props) ? _AriaPolicyEngine.#pipeline : [_AriaPolicyEngine.#checkInvalidAriaAttributes];
918
+ }
919
+ static evaluate(tag, props) {
920
+ const derived = _AriaPolicyEngine.#deriveContext(tag, props);
921
+ if (!derived.proceed) return derived.result;
922
+ const { tag: narrowedTag, implicitRole, context } = derived;
923
+ const { violations, fixes } = _AriaPolicyEngine.#runRules(
924
+ _AriaPolicyEngine.#getRules(context),
925
+ context
926
+ );
927
+ const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole, props, fixes);
928
+ return { props: next, violations };
929
+ }
930
+ static #evaluateWithRules(tag, props, extraRules) {
931
+ const derived = _AriaPolicyEngine.#deriveContext(tag, props);
932
+ if (!derived.proceed) return derived.result;
933
+ const { tag: narrowedTag, implicitRole, context } = derived;
934
+ const { violations, fixes } = _AriaPolicyEngine.#runRules(
935
+ [..._AriaPolicyEngine.#getRules(context), ...extraRules],
936
+ context
937
+ );
938
+ const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole, props, fixes);
939
+ return { props: next, violations };
940
+ }
941
+ report(violations) {
942
+ for (const v of violations) {
943
+ if (v.severity === "error") this.violate(v.message);
944
+ else this.warn(v.message);
945
+ }
946
+ }
947
+ // Cache key covers only the aria-relevant subset of props (tag + role + aria-* attrs).
948
+ // Non-aria props (className, onClick, etc.) do not affect ARIA decisions and are excluded
949
+ // so cache hits survive re-renders that only change non-aria props.
950
+ // Note: #extraRules are NOT included in the key — each engine instance has its own Map,
951
+ // so two engines with different rules never share cache entries. If caching ever becomes
952
+ // static/shared, rule identity would need to be folded into the key.
953
+ static #createPlanKey(tag, props) {
954
+ if (!isIntrinsicTag(tag)) return null;
955
+ const parts = [tag];
956
+ if (typeof props.role === "string") parts.push(`role:${props.role}`);
957
+ const ariaEntries = [];
958
+ for (const k in props) {
959
+ if (!Object.hasOwn(props, k) || !k.startsWith("aria-")) continue;
960
+ const v = props[k];
961
+ if (!isString(v) && !isNumber(v) && typeof v !== "boolean") continue;
962
+ ariaEntries.push(`${k}:${String(v)}`);
963
+ }
964
+ if (ariaEntries.length > 0) parts.push(...ariaEntries.sort());
965
+ return parts.join("|");
966
+ }
967
+ static #computePlan(inputProps, resultProps) {
968
+ const removals = /* @__PURE__ */ new Set();
969
+ const updates = {};
970
+ for (const key in inputProps) {
971
+ if (Object.hasOwn(inputProps, key) && !(key in resultProps)) removals.add(key);
972
+ }
973
+ for (const key in resultProps) {
974
+ if (!Object.hasOwn(resultProps, key)) continue;
975
+ const resultVal = resultProps[key];
976
+ if (inputProps[key] !== resultVal) updates[key] = resultVal;
977
+ }
978
+ return { removals, updates };
979
+ }
980
+ static #applyPlan(props, removals, updates) {
981
+ const hasRemovals = removals.size > 0;
982
+ const hasUpdates = Object.keys(updates).length > 0;
983
+ if (!hasRemovals && !hasUpdates) return props;
984
+ const next = {};
985
+ for (const k in props) {
986
+ if (Object.hasOwn(props, k) && !removals.has(k)) next[k] = props[k];
987
+ }
988
+ Object.assign(next, updates);
989
+ return next;
990
+ }
991
+ validate(tag, props) {
992
+ const key = _AriaPolicyEngine.#createPlanKey(tag, props);
993
+ if (!isNull2(key)) {
994
+ const cached = this.#planCache.get(key);
995
+ if (cached !== void 0) {
996
+ this.#planCache.delete(key);
997
+ this.#planCache.set(key, cached);
998
+ if (cached.violations.length > 0) this.report(cached.violations);
999
+ return {
1000
+ props: _AriaPolicyEngine.#applyPlan(props, cached.removals, cached.updates),
1001
+ violations: cached.violations
1002
+ };
1003
+ }
1004
+ }
1005
+ const result = this.#extraRules.length ? _AriaPolicyEngine.#evaluateWithRules(tag, props, this.#extraRules) : _AriaPolicyEngine.evaluate(tag, props);
1006
+ if (result.violations.length > 0) this.report(result.violations);
1007
+ if (!isNull2(key)) {
1008
+ const { removals, updates } = _AriaPolicyEngine.#computePlan(
1009
+ props,
1010
+ result.props
1011
+ );
1012
+ const plan = { removals, updates, violations: result.violations };
1013
+ this.#planCache.set(key, plan);
1014
+ if (this.#planCache.size > _AriaPolicyEngine.#MAX_CACHE) {
1015
+ const lru = this.#planCache.keys().next().value;
1016
+ if (lru !== void 0) this.#planCache.delete(lru);
1017
+ }
1018
+ }
1019
+ return result;
1020
+ }
1021
+ static #hasRole(props) {
1022
+ return isString(props.role) && props.role.length > 0;
1023
+ }
1024
+ static #applyFixes(tag, implicitRole, props, fixes) {
1025
+ if (fixes.length === 0) return props;
1026
+ const sorted = [...fixes].sort((a, b) => (a.priority ?? Infinity) - (b.priority ?? Infinity));
1027
+ let next = props;
1028
+ for (const { apply } of sorted) {
1029
+ const effectiveRole = next.role ?? implicitRole;
1030
+ const fixContext = { tag, implicitRole, effectiveRole, props: next };
1031
+ const fixResult = apply(fixContext);
1032
+ if (fixResult.applied) next = fixResult.next;
1033
+ }
1034
+ return next;
1035
+ }
1036
+ static #removeRole = {
1037
+ kind: "removeRole",
1038
+ apply: ({ props }) => {
1039
+ if (!("role" in props)) return { applied: false, next: props };
1040
+ return { applied: true, next: omitProp(props, "role"), previous: props };
1041
+ }
1042
+ };
1043
+ static #makeRemoveAttributeFix(attr) {
1044
+ const cached = _AriaPolicyEngine.#removeAttributeFixCache.get(attr);
1045
+ if (cached) return cached;
1046
+ const fix = {
1047
+ kind: `removeAttribute:${attr}`,
1048
+ apply: ({ props }) => {
1049
+ if (!(attr in props)) return { applied: false, next: props };
1050
+ return { applied: true, next: omitProp(props, attr), previous: props };
1051
+ }
1052
+ };
1053
+ _AriaPolicyEngine.#removeAttributeFixCache.set(attr, fix);
1054
+ return fix;
1055
+ }
1056
+ // Snapshot diagnostic model: all rules evaluate against the same (tag, props, implicitRole) snapshot.
1057
+ static #pipeline = [
1058
+ _AriaPolicyEngine.#checkInvalidRoleOverride,
1059
+ _AriaPolicyEngine.#checkRedundantRole,
1060
+ _AriaPolicyEngine.#checkStandaloneRegion,
1061
+ _AriaPolicyEngine.#checkInvalidAriaAttributes,
1062
+ _AriaPolicyEngine.#checkMissingLiveRegion,
1063
+ _AriaPolicyEngine.#checkMissingAtomic,
1064
+ _AriaPolicyEngine.#checkInvalidAriaRelevant
1065
+ ];
1066
+ static #checkInvalidRoleOverride({
1067
+ tag,
1068
+ props,
1069
+ implicitRole
1070
+ }) {
1071
+ const role = props.role;
1072
+ if (!implicitRole || !role || role === implicitRole) return VALID;
1073
+ if (isStrongImplicitRole(tag) && role === "region") {
1074
+ return [
1075
+ {
1076
+ valid: false,
1077
+ fixable: true,
1078
+ severity: "error",
1079
+ fix: _AriaPolicyEngine.#removeRole,
1080
+ message: `<${tag}> should not override its implicit role="${implicitRole}" with role="${role}".`
1081
+ }
1082
+ ];
1083
+ }
1084
+ return VALID;
1085
+ }
1086
+ static #checkRedundantRole({ tag, props, implicitRole }) {
1087
+ const role = props.role;
1088
+ if (!implicitRole || !role || role !== implicitRole) return VALID;
1089
+ return [
1090
+ {
1091
+ valid: false,
1092
+ fixable: true,
1093
+ severity: "warning",
1094
+ fix: _AriaPolicyEngine.#removeRole,
1095
+ message: `<${tag}> already has implicit role="${implicitRole}". Avoid redundant role assignment.`
1096
+ }
1097
+ ];
1098
+ }
1099
+ static #checkStandaloneRegion({ tag, props, implicitRole }) {
1100
+ const role = props.role;
1101
+ if (role !== "region") return VALID;
1102
+ if (!isStandaloneTag(tag)) return VALID;
1103
+ return [
1104
+ {
1105
+ valid: false,
1106
+ fixable: true,
1107
+ severity: "error",
1108
+ fix: _AriaPolicyEngine.#removeRole,
1109
+ message: `<${tag}> is a self-contained element with implicit role="${implicitRole}". Assigning role="region" has been removed.`
1110
+ }
1111
+ ];
1112
+ }
1113
+ static #checkInvalidAriaAttributes({
1114
+ tag,
1115
+ props,
1116
+ effectiveRole
1117
+ }) {
1118
+ const results = [];
1119
+ for (const key in props) {
1120
+ if (!Object.hasOwn(props, key)) continue;
1121
+ if (!key.startsWith("aria-")) continue;
1122
+ if (isGlobalAriaAttribute(key)) continue;
1123
+ if (isAriaAttributeValidForRole(key, effectiveRole)) continue;
1124
+ results.push({
1125
+ valid: false,
1126
+ severity: "warning",
1127
+ fixable: true,
1128
+ attribute: key,
1129
+ message: `"${key}" is not valid on role="${effectiveRole ?? tag}". It will be removed.`,
1130
+ fix: _AriaPolicyEngine.#makeRemoveAttributeFix(key)
1131
+ });
1132
+ }
1133
+ return results;
1134
+ }
1135
+ // WAI-ARIA live region roles and their implied aria-live politeness values.
1136
+ static #LIVE_REGION_ROLES = /* @__PURE__ */ new Map([
1137
+ ["alert", "assertive"],
1138
+ ["status", "polite"],
1139
+ ["log", "polite"],
1140
+ ["timer", "off"]
1141
+ ]);
1142
+ static #checkMissingLiveRegion({ effectiveRole, props }) {
1143
+ if (!effectiveRole) return VALID;
1144
+ const impliedLive = _AriaPolicyEngine.#LIVE_REGION_ROLES.get(effectiveRole);
1145
+ if (!impliedLive) return VALID;
1146
+ if ("aria-live" in props) return VALID;
1147
+ const injectLive = {
1148
+ kind: `injectLive:${effectiveRole}`,
1149
+ apply: (ctx) => ({
1150
+ applied: true,
1151
+ next: { ...ctx.props, "aria-live": impliedLive },
1152
+ previous: ctx.props
1153
+ })
1154
+ };
1155
+ return [
1156
+ {
1157
+ valid: false,
1158
+ fixable: true,
1159
+ severity: "warning",
1160
+ fix: injectLive,
1161
+ message: `role="${effectiveRole}" implies aria-live="${impliedLive}" but it is missing. It has been injected.`
1162
+ }
1163
+ ];
1164
+ }
1165
+ static #checkMissingAtomic({ effectiveRole, props }) {
1166
+ if (!effectiveRole || !_AriaPolicyEngine.#LIVE_REGION_ROLES.has(effectiveRole)) return VALID;
1167
+ if ("aria-atomic" in props) return VALID;
1168
+ return [
1169
+ {
1170
+ valid: false,
1171
+ fixable: false,
1172
+ severity: "warning",
1173
+ message: `role="${effectiveRole}" is a live region. Consider setting aria-atomic="true" if the full region should be announced as a unit, or aria-atomic="false" if only changed nodes should be read.`
1174
+ }
1175
+ ];
1176
+ }
1177
+ static #VALID_RELEVANT_TOKENS = /* @__PURE__ */ new Set(["additions", "removals", "text", "all"]);
1178
+ // Custom fix rules passed via `options.rules` must be pure functions of (tag, props) — the cache
1179
+ // replays stored fixes against new prop objects, so fixes that close over external state will
1180
+ // produce inconsistent results on cache hits.
1181
+ static #normalizeRelevantAllFix = {
1182
+ kind: "normalizeRelevantAll",
1183
+ apply: ({ props: p }) => ({
1184
+ applied: true,
1185
+ next: { ...p, "aria-relevant": "all" },
1186
+ previous: p
1187
+ })
1188
+ };
1189
+ static #checkInvalidAriaRelevant({ props }) {
1190
+ const relevant = props["aria-relevant"];
1191
+ if (relevant === void 0) return VALID;
1192
+ if (typeof relevant !== "string") return VALID;
1193
+ const tokens = relevant.trim().split(/\s+/);
1194
+ const invalid = tokens.filter((t) => !_AriaPolicyEngine.#VALID_RELEVANT_TOKENS.has(t));
1195
+ if (invalid.length > 0) {
1196
+ return [
1197
+ {
1198
+ valid: false,
1199
+ fixable: true,
1200
+ severity: "warning",
1201
+ attribute: "aria-relevant",
1202
+ message: `aria-relevant contains invalid token(s): ${invalid.map((t) => `"${t}"`).join(", ")}. Valid tokens are: additions, removals, text, all.`,
1203
+ fix: _AriaPolicyEngine.#makeRemoveAttributeFix("aria-relevant")
1204
+ }
1205
+ ];
1206
+ }
1207
+ if (tokens.includes("all") && tokens.length > 1) {
1208
+ return [
1209
+ {
1210
+ valid: false,
1211
+ fixable: true,
1212
+ severity: "warning",
1213
+ attribute: "aria-relevant",
1214
+ message: `aria-relevant includes "all" alongside other tokens. "all" supersedes additions, removals, and text \u2014 use aria-relevant="all" alone.`,
1215
+ fix: _AriaPolicyEngine.#normalizeRelevantAllFix
1216
+ }
1217
+ ];
1218
+ }
1219
+ return VALID;
1220
+ }
1221
+ };
1222
+ function getTypeName(value) {
1223
+ if (value === null) return "null";
1224
+ if (value === void 0) return "undefined";
1225
+ const primitive = typeof value;
1226
+ if (primitive !== "object") {
1227
+ return primitive;
1228
+ }
1229
+ const name = value.constructor?.name;
1230
+ return typeof name === "string" && name !== "Object" ? name : "object";
1231
+ }
1232
+ var MatchValidationErrorBuilder = class {
1233
+ #prefix;
1234
+ constructor(ctx = "") {
1235
+ this.#prefix = ctx ? `${ctx}:
1236
+ ` : "";
1237
+ }
1238
+ #template(typeName, index, prefix = "", suffix = "") {
1239
+ const leadingStr = prefix ? `${prefix} ` : "";
1240
+ const followingStr = suffix ? ` ${suffix}` : "";
1241
+ return `${leadingStr}child "${typeName}" at index ${index}${followingStr}.`;
1242
+ }
1243
+ unexpectedChild(typeName, index) {
1244
+ return this.#template(typeName, index, "unexpected");
1245
+ }
1246
+ multipleMatches(typeName, index, ruleNames) {
1247
+ const quoted = ruleNames.map((n) => `"${n}"`);
1248
+ return this.#template(
1249
+ typeName,
1250
+ index,
1251
+ "",
1252
+ `matches multiple child rules: ${quoted.join(" and ")}`
1253
+ );
1254
+ }
1255
+ #format(errors) {
1256
+ return this.#prefix + errors.join("\n");
1257
+ }
1258
+ toError(errors) {
1259
+ if (errors.length === 0) {
1260
+ return new Error(this.#prefix + "Unknown validation error.");
1261
+ }
1262
+ return new Error(this.#format(errors));
1263
+ }
1264
+ };
1265
+ function normalizeCardinality(input, impliesSingleton) {
1266
+ const min = input?.min ?? 0;
1267
+ const max = input?.max ?? (impliesSingleton ? 1 : Infinity);
1268
+ if (min === 0 && max === Infinity) {
1269
+ return { kind: "unbounded" };
1270
+ }
1271
+ if (min > max) {
1272
+ throw new RangeError(`normalizeChildRule: min (${min}) cannot exceed max (${max})`);
1273
+ }
1274
+ return {
1275
+ kind: "bounded",
1276
+ min,
1277
+ max
1278
+ };
1279
+ }
1280
+ function normalizeChildRule(rule) {
1281
+ const position = rule.position ?? "any";
1282
+ const impliesSingleton = position === "first" || position === "last";
1283
+ return {
1284
+ ...rule,
1285
+ position,
1286
+ cardinality: normalizeCardinality(rule.cardinality, impliesSingleton)
1287
+ };
1288
+ }
1289
+ function getChildType(child) {
1290
+ if (!isObject(child) || !("type" in child)) return void 0;
1291
+ return child.type;
1292
+ }
1293
+ function buildPartialIndex(rules) {
1294
+ const typeIndex = /* @__PURE__ */ new Map();
1295
+ const duplicateTypes = /* @__PURE__ */ new Set();
1296
+ const untypedIndices = [];
1297
+ for (let ri = 0; ri < rules.length; ri++) {
1298
+ const t = rules[ri].type;
1299
+ if (t === void 0) {
1300
+ untypedIndices.push(ri);
1301
+ } else if (typeIndex.has(t)) {
1302
+ duplicateTypes.add(t);
1303
+ } else {
1304
+ typeIndex.set(t, ri);
1305
+ }
1306
+ }
1307
+ if (duplicateTypes.size > 0) {
1308
+ for (const t of duplicateTypes) typeIndex.delete(t);
1309
+ for (let ri = 0; ri < rules.length; ri++) {
1310
+ if (duplicateTypes.has(rules[ri].type)) untypedIndices.push(ri);
1311
+ }
1312
+ }
1313
+ return { typeIndex, untypedIndices };
1314
+ }
1315
+ var RuleMatcher = class {
1316
+ #rules;
1317
+ #typeIndex;
1318
+ #untypedIndices;
1319
+ constructor(rules) {
1320
+ this.#rules = rules;
1321
+ const { typeIndex, untypedIndices } = buildPartialIndex(rules);
1322
+ this.#typeIndex = typeIndex;
1323
+ this.#untypedIndices = untypedIndices;
1324
+ }
1325
+ match(children) {
1326
+ const forward = /* @__PURE__ */ new Map();
1327
+ const reverse = /* @__PURE__ */ new Map();
1328
+ const unexpectedIndices = /* @__PURE__ */ new Set();
1329
+ const ambiguousIndices = /* @__PURE__ */ new Set();
1330
+ for (let ri = 0; ri < this.#rules.length; ri++) {
1331
+ reverse.set(ri, /* @__PURE__ */ new Set());
1332
+ }
1333
+ for (const [ci, child] of children.entries()) {
1334
+ const t = getChildType(child);
1335
+ if (t !== void 0) {
1336
+ const ri = this.#typeIndex.get(t);
1337
+ if (ri !== void 0) {
1338
+ let childEntry = forward.get(ci);
1339
+ if (!childEntry) {
1340
+ childEntry = /* @__PURE__ */ new Set();
1341
+ forward.set(ci, childEntry);
1342
+ }
1343
+ childEntry.add(ri);
1344
+ reverse.get(ri).add(ci);
1345
+ }
1346
+ }
1347
+ for (const ri of this.#untypedIndices) {
1348
+ if (!this.#rules[ri].match(child)) continue;
1349
+ let childEntry = forward.get(ci);
1350
+ if (!childEntry) {
1351
+ childEntry = /* @__PURE__ */ new Set();
1352
+ forward.set(ci, childEntry);
1353
+ }
1354
+ childEntry.add(ri);
1355
+ reverse.get(ri).add(ci);
1356
+ }
1357
+ const entry = forward.get(ci);
1358
+ if (!entry) {
1359
+ unexpectedIndices.add(ci);
1360
+ } else if (entry.size > 1) {
1361
+ ambiguousIndices.add(ci);
1362
+ }
1363
+ }
1364
+ return { matrix: { childToRules: { forward, reverse } }, unexpectedIndices, ambiguousIndices };
1365
+ }
1366
+ };
1367
+ var RuleValidator = class _RuleValidator extends StrictBase {
1368
+ #context;
1369
+ constructor(context, strict) {
1370
+ super(strict);
1371
+ this.#context = context;
1372
+ }
1373
+ validate(rules, matrix, childCount) {
1374
+ const firstIndex = 0;
1375
+ const lastIndex = childCount - 1;
1376
+ for (const [ri, rule] of rules.entries()) {
1377
+ const matches = matrix.childToRules.reverse.get(ri);
1378
+ const matchCount = matches.size;
1379
+ this.#validateCardinality(rule, matchCount);
1380
+ if (matchCount === 0) continue;
1381
+ this.#validatePositions(rule, matches, firstIndex, lastIndex);
1382
+ }
1383
+ }
1384
+ #validateCardinality(rule, matchCount) {
1385
+ const { cardinality, name } = rule;
1386
+ if (cardinality.kind !== "bounded") {
1387
+ return;
1388
+ }
1389
+ const { min, max } = cardinality;
1390
+ if (matchCount < min) {
1391
+ this.violate(`${this.#context}: "${name}" requires at least ${min}.`);
1392
+ return;
1393
+ }
1394
+ if (matchCount > max) {
1395
+ this.violate(`${this.#context}: "${name}" allows at most ${max}.`);
1396
+ }
1397
+ }
1398
+ #validatePositions(rule, matches, firstIndex, lastIndex) {
1399
+ const { name, position } = rule;
1400
+ for (const index of matches) {
1401
+ if (_RuleValidator.#isValidPosition(index, position, firstIndex, lastIndex)) {
1402
+ continue;
1403
+ }
1404
+ this.violate(`${this.#context}: "${name}" must be ${position}, got index ${index}`);
1405
+ }
1406
+ }
1407
+ static #isValidPosition(matchIndex, position, firstIndex, lastIndex) {
1408
+ switch (position) {
1409
+ case "first":
1410
+ return matchIndex === firstIndex;
1411
+ case "last":
1412
+ return matchIndex === lastIndex;
1413
+ case "any":
1414
+ return true;
1415
+ default:
1416
+ return assertNever(position);
1417
+ }
1418
+ }
1419
+ };
1420
+ var ChildrenEvaluator = class extends StrictBase {
1421
+ #rules;
1422
+ #ruleNames;
1423
+ #matcher;
1424
+ #ruleValidator;
1425
+ #matchBuilder;
1426
+ constructor(rules, strict = "warn", context = "Component") {
1427
+ super(strict);
1428
+ this.#rules = rules.map((r2) => normalizeChildRule(r2));
1429
+ this.#ruleNames = this.#rules.map((r2) => r2.name);
1430
+ for (const rule of this.#rules) {
1431
+ const { name, position, cardinality } = rule;
1432
+ if ((position === "first" || position === "last") && (cardinality.kind === "unbounded" || cardinality.max > 1)) {
1433
+ throw new RangeError(
1434
+ `ChildrenEvaluator [${context}]: rule "${name}" sets position="${position}" with an unbound or >1 max. position="first|last" implies max=1.`
1435
+ );
1436
+ }
1437
+ }
1438
+ this.#matcher = new RuleMatcher(this.#rules);
1439
+ this.#ruleValidator = new RuleValidator(context, strict);
1440
+ this.#matchBuilder = new MatchValidationErrorBuilder(context);
1441
+ }
1442
+ evaluate(children) {
1443
+ if (!this.strict) return;
1444
+ const { matrix, unexpectedIndices, ambiguousIndices } = this.#matcher.match(children);
1445
+ this.#ruleValidator.validate(this.#rules, matrix, children.length);
1446
+ if (unexpectedIndices.size === 0 && ambiguousIndices.size === 0) return;
1447
+ const errors = [];
1448
+ const violating = [...unexpectedIndices, ...ambiguousIndices].sort((a, b) => a - b);
1449
+ for (const ci of violating) {
1450
+ const typeName = getTypeName(children[ci]);
1451
+ if (unexpectedIndices.has(ci)) {
1452
+ errors.push(this.#matchBuilder.unexpectedChild(typeName, ci));
1453
+ } else {
1454
+ const matches = matrix.childToRules.forward.get(ci);
1455
+ const names = [...matches].map((ri) => this.#ruleNames[ri] ?? `#${ri}`);
1456
+ errors.push(this.#matchBuilder.multipleMatches(typeName, ci, names));
1457
+ }
1458
+ }
1459
+ this.invariant(errors.length === 0, this.#matchBuilder.toError(errors).message);
1460
+ }
1461
+ };
1462
+ var disabledProps = ({
1463
+ disabled,
1464
+ "aria-disabled": ariaDisabled,
1465
+ "data-disabled": dataDisabled
1466
+ }) => {
1467
+ if (!disabled) return {};
1468
+ return {
1469
+ ...ariaDisabled === void 0 && { "aria-disabled": "true" },
1470
+ ...dataDisabled === void 0 && { "data-disabled": "" }
1471
+ };
1472
+ };
1473
+ var invalidProps = ({
1474
+ invalid,
1475
+ "aria-invalid": ariaInvalid,
1476
+ "data-invalid": dataInvalid
1477
+ }) => {
1478
+ if (!invalid) return {};
1479
+ return {
1480
+ ...ariaInvalid === void 0 && { "aria-invalid": "true" },
1481
+ ...dataInvalid === void 0 && { "data-invalid": "" }
1482
+ };
1483
+ };
1484
+
1485
+ // ../core/dist/chunk-RHOMAG5Q.js
1486
+ var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
1487
+ var cx = clsx;
1488
+ var cva = (base, config) => (props) => {
1489
+ var _config_compoundVariants;
1490
+ if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
1491
+ const { variants, defaultVariants } = config;
1492
+ const getVariantClassNames = Object.keys(variants).map((variant) => {
1493
+ const variantProp = props === null || props === void 0 ? void 0 : props[variant];
1494
+ const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
1495
+ if (variantProp === null) return null;
1496
+ const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
1497
+ return variants[variant][variantKey];
1498
+ });
1499
+ const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
1500
+ let [key, value] = param;
1501
+ if (value === void 0) {
1502
+ return acc;
1503
+ }
1504
+ acc[key] = value;
1505
+ return acc;
1506
+ }, {});
1507
+ const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
1508
+ let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
1509
+ return Object.entries(compoundVariantOptions).every((param2) => {
1510
+ let [key, value] = param2;
1511
+ return Array.isArray(value) ? value.includes({
1512
+ ...defaultVariants,
1513
+ ...propsWithoutUndefined
1514
+ }[key]) : {
1515
+ ...defaultVariants,
1516
+ ...propsWithoutUndefined
1517
+ }[key] === value;
1518
+ }) ? [
1519
+ ...acc,
1520
+ cvClass,
1521
+ cvClassName
1522
+ ] : acc;
1523
+ }, []);
1524
+ return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
1525
+ };
1526
+ function cva2(base, config) {
1527
+ const fn = cva(base, config);
1528
+ return (props) => cn(fn(props));
1529
+ }
1530
+ var StaticClassResolver = class {
1531
+ #baseClass;
1532
+ #cache = /* @__PURE__ */ new Map();
1533
+ #resolveTag;
1534
+ constructor(baseClass, tagMap) {
1535
+ this.#baseClass = Array.isArray(baseClass) ? baseClass.join(" ") : baseClass;
1536
+ this.#resolveTag = tagMap ? (tag) => {
1537
+ const extra = tagMap[tag];
1538
+ if (!extra) return this.#baseClass;
1539
+ const extraStr = Array.isArray(extra) ? extra.join(" ") : extra;
1540
+ return `${this.#baseClass} ${extraStr}`;
1541
+ } : () => this.#baseClass;
1542
+ }
1543
+ resolve(tag, skipTagMap = false) {
1544
+ if (typeof tag !== "string" || skipTagMap) return this.#baseClass;
1545
+ const cached = this.#cache.get(tag);
1546
+ if (cached !== void 0) {
1547
+ this.#cache.delete(tag);
1548
+ this.#cache.set(tag, cached);
1549
+ return cached;
1550
+ }
1551
+ const result = this.#resolveTag(tag);
1552
+ this.#cache.set(tag, result);
1553
+ if (this.#cache.size > 200) {
1554
+ const lru = this.#cache.keys().next().value;
1555
+ if (lru !== void 0) this.#cache.delete(lru);
1556
+ }
1557
+ return result;
1558
+ }
1559
+ };
1560
+ var VariantClassResolver = class _VariantClassResolver {
1561
+ #cvaFn;
1562
+ #presetMap;
1563
+ #variantKeys;
1564
+ #precomputedClasses;
1565
+ #cache = /* @__PURE__ */ new Map();
1566
+ constructor(cvaFn, presetMap, variantKeys, precomputedClasses) {
1567
+ this.#cvaFn = cvaFn ?? null;
1568
+ this.#presetMap = Object.freeze(presetMap ?? {});
1569
+ this.#variantKeys = variantKeys ?? null;
1570
+ this.#precomputedClasses = precomputedClasses ?? null;
1571
+ }
1572
+ resolve({ props, variantKey }) {
1573
+ const normalizedKey = variantKey ?? "__none__";
1574
+ const cacheKey = this.#createCacheKey(props, normalizedKey);
1575
+ if (this.#precomputedClasses !== null) {
1576
+ const precomputed = this.#precomputedClasses[cacheKey];
1577
+ if (precomputed !== void 0) return precomputed;
1578
+ }
1579
+ const cached = this.#cache.get(cacheKey);
1580
+ if (cached !== void 0) {
1581
+ this.#cache.delete(cacheKey);
1582
+ this.#cache.set(cacheKey, cached);
1583
+ return cached;
1584
+ }
1585
+ const result = this.#compute(props, variantKey);
1586
+ this.#cache.set(cacheKey, result);
1587
+ if (this.#cache.size > 1e3) {
1588
+ const lru = this.#cache.keys().next().value;
1589
+ if (lru !== void 0) this.#cache.delete(lru);
1590
+ }
1591
+ return result;
1592
+ }
1593
+ #compute(props, variantKey) {
1594
+ if (!this.#cvaFn) return "";
1595
+ if (!variantKey) return this.#cvaFn(props);
1596
+ const preset = this.#presetMap[variantKey];
1597
+ if (!preset) return this.#cvaFn(props);
1598
+ return this.#cvaFn({ ...preset, ...props });
1599
+ }
1600
+ // When variantKeys is provided, only those keys are included in the cache key — non-variant
1601
+ // props (className, id, etc.) produce identical CVA output and must not fragment the cache.
1602
+ // Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
1603
+ // String is built incrementally to avoid a parts[] array allocation on every render.
1604
+ #createCacheKey(props, variantKey) {
1605
+ if (this.#variantKeys !== null) {
1606
+ let key2 = variantKey;
1607
+ for (const k of this.#variantKeys) {
1608
+ if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
1609
+ }
1610
+ return key2;
1611
+ }
1612
+ let key = variantKey;
1613
+ for (const k of Object.keys(props).sort()) {
1614
+ key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
1615
+ }
1616
+ return key;
1617
+ }
1618
+ static #serializeValue(value) {
1619
+ if (value === void 0) return "u";
1620
+ if (value === null) return "n";
1621
+ if (typeof value === "boolean") return `b:${value}`;
1622
+ if (typeof value === "string") return `s:${value}`;
1623
+ return `x:${String(value)}`;
1624
+ }
1625
+ };
1626
+ function createClassPipeline(resolved) {
1627
+ const baseClass = resolved.baseClassName ?? "";
1628
+ const cvaFn = resolved.variants ? cva2("", {
1629
+ variants: resolved.variants,
1630
+ defaultVariants: resolved.defaultVariants,
1631
+ compoundVariants: resolved.compoundVariants
1632
+ }) : null;
1633
+ const variantKeys = resolved.variants ? new Set(Object.keys(resolved.variants)) : void 0;
1634
+ const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
1635
+ const variantResolver = new VariantClassResolver(
1636
+ cvaFn,
1637
+ resolved.presetMap,
1638
+ variantKeys,
1639
+ resolved.precomputedClasses
1640
+ );
1641
+ return function resolveClasses(tag, props, className, variantKey) {
1642
+ const staticClasses = staticResolver.resolve(tag, variantKey !== void 0);
1643
+ const variantClasses = variantResolver.resolve({ props, variantKey });
1644
+ if (!className)
1645
+ return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
1646
+ return cn(staticClasses, variantClasses, className);
1647
+ };
1648
+ }
1649
+
1650
+ // ../core/dist/index.js
1651
+ var FULL_CAPABILITIES = { createClassPipeline, AriaEngine: AriaPolicyEngine };
1652
+ function createPolymorphic2(options = {}) {
1653
+ return createPolymorphic(options, FULL_CAPABILITIES);
1654
+ }
1655
+
1656
+ // ../../lib/adapter-utils/src/build-core-runtime.ts
1657
+ var EMPTY_SET = /* @__PURE__ */ new Set();
1658
+ function buildCoreRuntime(normalized) {
1659
+ const runtime = createPolymorphic2(normalized);
1660
+ const ownedKeys = "classPlugin" in runtime ? runtime.classPlugin.ownedKeys ?? EMPTY_SET : EMPTY_SET;
1661
+ return { runtime, ownedKeys };
1662
+ }
1663
+
1664
+ // ../../lib/adapter-utils/src/build-engines.ts
1665
+ function buildEngines(strict, childRules, context) {
1666
+ return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, strict, context) } : {};
1667
+ }
1668
+
1669
+ // ../../lib/adapter-utils/src/compose-filter.ts
1670
+ function composeFilter(ownedKeys, filterProps) {
1671
+ const defaultFilter = (key, variantKeys) => variantKeys.has(key) || ownedKeys.has(key);
1672
+ if (!filterProps) {
1673
+ return defaultFilter;
1674
+ }
1675
+ return (key, variantKeys) => defaultFilter(key, variantKeys) || filterProps(key, variantKeys);
1676
+ }
1677
+
1678
+ // ../../lib/adapter-utils/src/resolve-adapter-common-options.ts
1679
+ function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultStrict = "throw") {
1680
+ return {
1681
+ name: options.name ?? defaultName,
1682
+ strict: options.enforcement?.strict ?? defaultStrict
1683
+ };
1684
+ }
1685
+
1686
+ // ../../lib/adapter-utils/src/slot-validator.ts
1687
+ var SlotValidator = class extends StrictBase {
1688
+ #name;
1689
+ #elementTerm;
1690
+ constructor(name, strict, elementTerm) {
1691
+ super(strict);
1692
+ this.#name = name;
1693
+ this.#elementTerm = elementTerm;
1694
+ }
1695
+ assertExclusive() {
1696
+ this.violate(`${this.#name}: "as" and "asChild" are mutually exclusive`);
1697
+ }
1698
+ warnDiscardedChildren(count) {
1699
+ const suffix = count === 1 ? "" : "ren";
1700
+ this.warn(
1701
+ `${this.#name}: asChild discarded ${count} non-element child${suffix} \u2014 only ${this.#elementTerm}s are valid asChild children.`
1702
+ );
1703
+ }
1704
+ assertSingleChild(count) {
1705
+ const msg = count === 0 ? `${this.#name}: asChild requires a ${this.#elementTerm} child` : `${this.#name}: asChild requires exactly one ${this.#elementTerm} child, got ${count}`;
1706
+ this.violate(msg);
1707
+ }
1708
+ };
1709
+
1710
+ // ../../adapters/vue/src/slot/invariant.ts
1711
+ function panic2(message) {
1712
+ throw new Error(message);
1713
+ }
1714
+ function invariant(condition, message) {
1715
+ if (!condition) panic2(message);
1716
+ }
1717
+
1718
+ // ../../adapters/vue/src/slot/slot-validator.ts
1719
+ var SlotValidator2 = class extends SlotValidator {
1720
+ constructor(name, strict) {
1721
+ super(name, strict, "VNode");
1722
+ }
1723
+ };
1724
+
1725
+ // ../../adapters/vue/src/slot/Slottable.ts
1726
+ import { defineComponent, h, Fragment } from "vue";
1727
+ var Slottable = defineComponent({
1728
+ name: "Slottable",
1729
+ setup(_, { slots }) {
1730
+ return () => h(Fragment, null, slots.default?.());
1731
+ }
1732
+ });
1733
+
1734
+ // ../../adapters/vue/src/slot/extractSlottable.ts
1735
+ import { h as h2, Fragment as Fragment2 } from "vue";
1736
+ function isSlottableVNode(vnode) {
1737
+ return vnode.type === Slottable;
1738
+ }
1739
+ function extractSlottable(children) {
1740
+ const slottables = children.filter(isSlottableVNode);
1741
+ invariant(slottables.length <= 1, "Slot: multiple Slottable children are not allowed");
1742
+ if (slottables.length === 0) return null;
1743
+ const [slottable] = slottables;
1744
+ invariant(slottable !== void 0, "Slottable element is undefined");
1745
+ const slots = slottable.children;
1746
+ const defaultChildren = slots?.default?.() ?? [];
1747
+ invariant(
1748
+ defaultChildren.length === 1,
1749
+ `Slottable expects exactly one VNode child, received ${defaultChildren.length}`
1750
+ );
1751
+ const child = defaultChildren[0];
1752
+ invariant(child !== void 0, "Slottable child is undefined");
1753
+ const index = children.indexOf(slottable);
1754
+ return {
1755
+ child,
1756
+ rebuild(merged) {
1757
+ const out = children.map((node, i) => i === index ? merged : node);
1758
+ return h2(Fragment2, null, out);
1759
+ }
1760
+ };
1761
+ }
1762
+
1763
+ // ../../adapters/vue/src/build-runtime.ts
1764
+ function normalizeOptions(options) {
1765
+ return { ...options, ...resolveAdapterCommonOptions(options) };
1766
+ }
1767
+ function buildRuntime(options) {
1768
+ const normalized = normalizeOptions(options);
1769
+ const { runtime, ownedKeys } = buildCoreRuntime(normalized);
1770
+ const slotValidator = new SlotValidator2(normalized.name, normalized.strict);
1771
+ const { childrenEvaluator } = buildEngines(
1772
+ normalized.strict,
1773
+ normalized.enforcement?.children,
1774
+ normalized.name
1775
+ );
1776
+ const filterProps = composeFilter(ownedKeys, normalized.filterProps);
1777
+ return {
1778
+ runtime,
1779
+ slotValidator,
1780
+ filterProps,
1781
+ ...childrenEvaluator !== void 0 && { childrenEvaluator }
1782
+ };
1783
+ }
1784
+
1785
+ // ../../adapters/vue/src/render.ts
1786
+ import { cloneVNode, h as h3 } from "vue";
1787
+
1788
+ // ../../adapters/vue/src/normalize-children.ts
1789
+ import { isVNode } from "vue";
1790
+ function normalizeChildren(slots) {
1791
+ const raw = slots.default?.() ?? [];
1792
+ const vnodes = raw.filter(isVNode);
1793
+ return { vnodes, discarded: raw.length - vnodes.length };
1794
+ }
1795
+
1796
+ // ../../adapters/vue/src/render.ts
1797
+ function buildDirectives(as, asChild) {
1798
+ return {
1799
+ ...as !== void 0 && { as },
1800
+ ...asChild !== void 0 && { asChild }
1801
+ };
1802
+ }
1803
+ function resolveRenderState(runtime, attrs, filterProps) {
1804
+ const { as, asChild, class: className, variantKey, ...rest } = attrs;
1805
+ const tag = runtime.resolveTag(as);
1806
+ const mergedProps = runtime.resolveProps(rest);
1807
+ const normalizedProps = runtime.options.normalizeFn ? runtime.options.normalizeFn(mergedProps) : mergedProps;
1808
+ const resolvedClass = runtime.resolveClasses(
1809
+ tag,
1810
+ normalizedProps,
1811
+ typeof className === "string" ? className : void 0,
1812
+ typeof variantKey === "string" ? variantKey : void 0
1813
+ );
1814
+ const filteredProps = applyFilter(normalizedProps, filterProps, runtime.options.variantKeys);
1815
+ return {
1816
+ tag,
1817
+ directives: buildDirectives(as, asChild),
1818
+ className: resolvedClass,
1819
+ props: filteredProps
1820
+ };
1821
+ }
1822
+ function validateSlotDirectives(directives, validator) {
1823
+ const { as, asChild } = directives;
1824
+ if (!asChild) return false;
1825
+ if (as !== void 0) {
1826
+ validator.assertExclusive();
1827
+ return false;
1828
+ }
1829
+ return true;
1830
+ }
1831
+ function tryRenderAsChild(state, children, discarded, validator) {
1832
+ if (!validateSlotDirectives(state.directives, validator)) return null;
1833
+ if (discarded > 0) validator.warnDiscardedChildren(discarded);
1834
+ const extraction = extractSlottable(children);
1835
+ if (extraction) {
1836
+ const merged = cloneVNode(extraction.child, { ...state.props, class: state.className });
1837
+ return extraction.rebuild(merged);
1838
+ }
1839
+ if (children.length === 1) {
1840
+ const child = children[0];
1841
+ if (child === void 0) return null;
1842
+ return cloneVNode(child, { ...state.props, class: state.className });
1843
+ }
1844
+ validator.assertSingleChild(children.length);
1845
+ return null;
1846
+ }
1847
+ var MULTI_WORD_EVENT_RE = /^on[A-Z][a-z]+[A-Z]/;
1848
+ function normalizeEventKeys(props) {
1849
+ const out = {};
1850
+ for (const k in props) {
1851
+ out[MULTI_WORD_EVENT_RE.test(k) ? "on" + k.slice(2).toLowerCase() : k] = props[k];
1852
+ }
1853
+ return out;
1854
+ }
1855
+ function buildDomProps(runtime, props, className, tag) {
1856
+ const { role, ...rest } = normalizeEventKeys(props);
1857
+ const base = {
1858
+ ...rest,
1859
+ class: className,
1860
+ ...isKnownAriaRole(role) && { role }
1861
+ };
1862
+ if (typeof tag !== "string") return base;
1863
+ const validated = runtime.resolveAria(tag, base);
1864
+ const {
1865
+ className: _className,
1866
+ ref: _ref,
1867
+ children: _children,
1868
+ ...validatedRest
1869
+ } = validated.props;
1870
+ return { ...validatedRest, class: className };
1871
+ }
1872
+ function render({
1873
+ runtime,
1874
+ attrs,
1875
+ slots,
1876
+ filterProps,
1877
+ slotValidator,
1878
+ childrenEvaluator,
1879
+ resolvedState
1880
+ }) {
1881
+ const state = resolvedState ?? resolveRenderState(runtime, attrs, filterProps);
1882
+ const { vnodes: children, discarded } = normalizeChildren(slots);
1883
+ if (process.env.NODE_ENV !== "production") childrenEvaluator?.evaluate(children);
1884
+ const slotResult = tryRenderAsChild(state, children, discarded, slotValidator);
1885
+ if (slotResult !== null) return slotResult;
1886
+ const domProps = buildDomProps(runtime, state.props, state.className, state.tag);
1887
+ return h3(state.tag, domProps, slots.default ? { default: slots.default } : void 0);
1888
+ }
1889
+
1890
+ // ../../adapters/vue/src/create-contract-component.ts
1891
+ function createContractComponent(options) {
1892
+ const bundle = buildRuntime(options);
1893
+ const Component = defineComponent2({
1894
+ name: options.name ?? "PolymorphicComponent",
1895
+ // Without inheritAttrs: false Vue would double-bind attrs onto the root element
1896
+ // before our render pipeline has a chance to filter, transform, and re-apply them.
1897
+ inheritAttrs: false,
1898
+ setup(_, { attrs, slots }) {
1899
+ const resolvedState = computed(
1900
+ () => resolveRenderState(bundle.runtime, attrs, bundle.filterProps)
1901
+ );
1902
+ return () => render({ ...bundle, attrs, slots, resolvedState: resolvedState.value });
1903
+ }
1904
+ });
1905
+ applyDisplayName(Component, options.name);
1906
+ if (typeof bundle.runtime.options.defaultTag === "string") {
1907
+ Object.assign(Component, { [COMPONENT_DEFAULT_TAG]: bundle.runtime.options.defaultTag });
1908
+ }
1909
+ return Component;
1910
+ }
1911
+
1912
+ // ../../adapters/vue/src/define-contract-component.ts
1913
+ function defineContractComponent(options) {
1914
+ return (factory) => factory(options);
1915
+ }
1916
+ export {
1917
+ Slottable,
1918
+ createContractComponent,
1919
+ defineContractComponent,
1920
+ disabledProps,
1921
+ invalidProps
1922
+ };