praxis-kit 4.0.1 → 4.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.
@@ -1,14 +1,16 @@
1
- // ../../lib/adapter-utils/src/define-component.ts
1
+ // ../../lib/adapter-utils/src/runtime/define-component.ts
2
2
  function defineContractComponent(options) {
3
3
  return (factory) => factory(options);
4
4
  }
5
5
 
6
- // ../../lib/adapter-utils/src/invariant.ts
7
- function panic(message) {
8
- throw new Error(message);
6
+ // ../../lib/primitive/src/guards/foundational/is-defined.ts
7
+ function isUndefined(value) {
8
+ return value === void 0;
9
9
  }
10
- function invariant(condition, message) {
11
- if (!condition) panic(message);
10
+
11
+ // ../../lib/primitive/src/guards/foundational/is-null.ts
12
+ function isNull(value) {
13
+ return value === null;
12
14
  }
13
15
 
14
16
  // ../../lib/primitive/src/utils/is-object.ts
@@ -36,197 +38,6 @@ function isPlainObject(value) {
36
38
  return proto === Object.prototype || proto === null;
37
39
  }
38
40
 
39
- // ../../lib/primitive/src/utils/assert-never.ts
40
- function assertNever(value) {
41
- throw new Error(`Unexpected value: ${String(value)}`);
42
- }
43
-
44
- // ../../lib/primitive/src/utils/iterate.ts
45
- function find(iterable, callback) {
46
- for (const value of iterable) {
47
- const result = callback(value);
48
- if (result != null) {
49
- return result;
50
- }
51
- }
52
- return null;
53
- }
54
- function some(iterable, predicate) {
55
- for (const value of iterable) {
56
- if (predicate(value)) return true;
57
- }
58
- return false;
59
- }
60
- function every(iterable, predicate) {
61
- let index = 0;
62
- for (const value of iterable) {
63
- if (!predicate(value, index++)) {
64
- return false;
65
- }
66
- }
67
- return true;
68
- }
69
- function* filter(iterable, predicate) {
70
- let index = 0;
71
- for (const value of iterable) {
72
- if (predicate(value, index++)) {
73
- yield value;
74
- }
75
- }
76
- }
77
- function* map(iterable, callback) {
78
- let index = 0;
79
- for (const value of iterable) {
80
- yield callback(value, index++);
81
- }
82
- }
83
- function forEach(iterable, callback) {
84
- let index = 0;
85
- for (const value of iterable) {
86
- callback(value, index++);
87
- }
88
- }
89
- function reduce(iterable, initial, callback) {
90
- let accumulator = initial;
91
- let index = 0;
92
- for (const value of iterable) {
93
- accumulator = callback(accumulator, value, index++);
94
- }
95
- return accumulator;
96
- }
97
- function collect(iterable, callback) {
98
- const result = {};
99
- let index = 0;
100
- for (const value of iterable) {
101
- const entry = callback(value, index++);
102
- if (entry === null) {
103
- return null;
104
- }
105
- result[entry[0]] = entry[1];
106
- }
107
- return result;
108
- }
109
- function findLast(value, callback) {
110
- for (let index = value.length - 1; index >= 0; index--) {
111
- const result = callback(value[index], index);
112
- if (result != null) {
113
- return result;
114
- }
115
- }
116
- return null;
117
- }
118
- function* items(collection) {
119
- for (let i = 0; i < collection.length; i++) {
120
- const item = collection.item(i);
121
- if (item !== null) {
122
- yield item;
123
- }
124
- }
125
- }
126
- function nodeList(list) {
127
- return {
128
- *[Symbol.iterator]() {
129
- for (let i = 0; i < list.length; i++) {
130
- const node = list.item(i);
131
- if (node !== null) {
132
- yield node;
133
- }
134
- }
135
- }
136
- };
137
- }
138
- function mapEntries(m) {
139
- return m.entries();
140
- }
141
- function set(s) {
142
- return s.values();
143
- }
144
- function hasOwn(object, key) {
145
- return Object.hasOwn(object, key);
146
- }
147
- function* entries(object) {
148
- for (const key in object) {
149
- if (!hasOwn(object, key)) continue;
150
- yield [key, object[key]];
151
- }
152
- }
153
- function* keys(object) {
154
- for (const [key] of entries(object)) {
155
- yield key;
156
- }
157
- }
158
- function* values(object) {
159
- for (const [, value] of entries(object)) {
160
- yield value;
161
- }
162
- }
163
- function mapValues(object, callback) {
164
- const result = {};
165
- for (const [key, value] of entries(object)) {
166
- result[key] = callback(value, key);
167
- }
168
- return result;
169
- }
170
- function forEachEntry(object, callback) {
171
- for (const [key, value] of entries(object)) {
172
- callback(key, value);
173
- }
174
- }
175
- function forEachKey(object, callback) {
176
- for (const key of keys(object)) {
177
- callback(key);
178
- }
179
- }
180
- function forEachValue(object, callback) {
181
- for (const value of values(object)) {
182
- callback(value);
183
- }
184
- }
185
- function forEachSet(s, callback) {
186
- for (const value of s) {
187
- callback(value);
188
- }
189
- }
190
- var iterate = Object.freeze({
191
- entries,
192
- filter,
193
- find,
194
- findLast,
195
- forEach,
196
- forEachEntry,
197
- forEachKey,
198
- forEachSet,
199
- forEachValue,
200
- items,
201
- keys,
202
- map,
203
- mapEntries,
204
- mapValues,
205
- nodeList,
206
- reduce,
207
- collect,
208
- set,
209
- some,
210
- every,
211
- values
212
- });
213
-
214
- // ../../lib/primitive/src/utils/merge-refs.ts
215
- function mergeRefsCore(...refs) {
216
- const active = refs.filter((r) => r != null);
217
- if (active.length === 0) return null;
218
- if (active.length === 1) return active[0];
219
- return (value) => {
220
- iterate.forEach(active, (ref) => {
221
- if (typeof ref === "function") {
222
- ref(value);
223
- } else {
224
- ref.current = value;
225
- }
226
- });
227
- };
228
- }
229
-
230
41
  // ../../lib/primitive/src/constants/aria/global-aria-attributes.ts
231
42
  var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
232
43
  "aria-atomic",
@@ -249,7 +60,7 @@ var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
249
60
  ]);
250
61
 
251
62
  // ../../lib/primitive/src/constants/aria/implicit-role-record.ts
252
- var IMPLICIT_ROLE_RECORD = {
63
+ var IMPLICIT_ROLE_RECORD = Object.freeze({
253
64
  // Landmarks
254
65
  article: "article",
255
66
  aside: "complementary",
@@ -285,8 +96,8 @@ var IMPLICIT_ROLE_RECORD = {
285
96
  meter: "meter",
286
97
  output: "status",
287
98
  progress: "progressbar"
288
- };
289
- var INPUT_TYPE_ROLE_MAP = {
99
+ });
100
+ var INPUT_TYPE_ROLE_MAP = Object.freeze({
290
101
  checkbox: "checkbox",
291
102
  radio: "radio",
292
103
  range: "slider",
@@ -300,18 +111,106 @@ var INPUT_TYPE_ROLE_MAP = {
300
111
  submit: "button",
301
112
  reset: "button",
302
113
  image: "button"
303
- };
304
- var STRONG_ROLES = [
114
+ });
115
+ var STRONG_ROLES = Object.freeze([
305
116
  "main",
306
117
  "navigation",
307
118
  "complementary",
308
119
  "contentinfo",
309
120
  "banner"
310
- ];
311
- var STANDALONE_ROLES = ["article"];
121
+ ]);
122
+ var STANDALONE_ROLES = Object.freeze([
123
+ "article"
124
+ ]);
312
125
  var STRONG_ROLES_SET = new Set(STRONG_ROLES);
313
126
  var STANDALONE_ROLES_SET = new Set(STANDALONE_ROLES);
314
127
 
128
+ // ../../lib/primitive/src/constants/aria/known-aria-roles.ts
129
+ var KNOWN_ARIA_ROLES = Object.freeze([
130
+ "alert",
131
+ "alertdialog",
132
+ "application",
133
+ "article",
134
+ "banner",
135
+ "blockquote",
136
+ "button",
137
+ "caption",
138
+ "cell",
139
+ "checkbox",
140
+ "code",
141
+ "columnheader",
142
+ "combobox",
143
+ "complementary",
144
+ "contentinfo",
145
+ "definition",
146
+ "deletion",
147
+ "dialog",
148
+ "document",
149
+ "emphasis",
150
+ "feed",
151
+ "figure",
152
+ "form",
153
+ "generic",
154
+ "grid",
155
+ "gridcell",
156
+ "group",
157
+ "heading",
158
+ "img",
159
+ "insertion",
160
+ "link",
161
+ "list",
162
+ "listbox",
163
+ "listitem",
164
+ "log",
165
+ "main",
166
+ "marquee",
167
+ "math",
168
+ "menu",
169
+ "menubar",
170
+ "menuitem",
171
+ "menuitemcheckbox",
172
+ "menuitemradio",
173
+ "meter",
174
+ "navigation",
175
+ "none",
176
+ "note",
177
+ "option",
178
+ "paragraph",
179
+ "presentation",
180
+ "progressbar",
181
+ "radio",
182
+ "radiogroup",
183
+ "region",
184
+ "row",
185
+ "rowgroup",
186
+ "rowheader",
187
+ "scrollbar",
188
+ "search",
189
+ "searchbox",
190
+ "separator",
191
+ "slider",
192
+ "spinbutton",
193
+ "status",
194
+ "strong",
195
+ "subscript",
196
+ "superscript",
197
+ "switch",
198
+ "tab",
199
+ "table",
200
+ "tablist",
201
+ "tabpanel",
202
+ "term",
203
+ "textbox",
204
+ "time",
205
+ "timer",
206
+ "toolbar",
207
+ "tooltip",
208
+ "tree",
209
+ "treegrid",
210
+ "treeitem"
211
+ ]);
212
+ var KNOWN_ARIA_ROLES_SET = new Set(KNOWN_ARIA_ROLES);
213
+
315
214
  // ../../lib/primitive/src/constants/aria/role-restricted-attributes.ts
316
215
  var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
317
216
  [
@@ -463,19 +362,6 @@ var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
463
362
  ]
464
363
  ]);
465
364
 
466
- // ../../lib/primitive/src/constants/primitive/slot-name.ts
467
- var SLOT_NAME = "Slot";
468
-
469
- // ../../lib/primitive/src/guards/foundational/is-defined.ts
470
- function isUndefined(value) {
471
- return value === void 0;
472
- }
473
-
474
- // ../../lib/primitive/src/guards/foundational/is-null.ts
475
- function isNull(value) {
476
- return value === null;
477
- }
478
-
479
365
  // ../../lib/primitive/src/guards/aria/is-aria-attribute.ts
480
366
  function isGlobalAriaAttribute(attr) {
481
367
  return GLOBAL_ARIA_ATTRIBUTES.has(attr);
@@ -487,6 +373,9 @@ function isAriaAttributeValidForRole(attr, role) {
487
373
  return allowedRoles.has(role);
488
374
  }
489
375
 
376
+ // ../../lib/primitive/src/constants/primitive/slot-name.ts
377
+ var SLOT_NAME = "Slot";
378
+
490
379
  // ../../lib/primitive/src/guards/aria/is-aria-role.ts
491
380
  function isStrongImplicitRole(tag) {
492
381
  if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
@@ -497,17 +386,245 @@ function isStandaloneTag(tag) {
497
386
  return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
498
387
  }
499
388
  function getInputImplicitRole(type) {
500
- if (type == null || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
389
+ if (!isString(type) || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
501
390
  return INPUT_TYPE_ROLE_MAP[type];
502
391
  }
503
392
  function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
504
- const isNamed = typeof ariaLabel === "string" || typeof ariaLabelledBy === "string";
393
+ const isNamed = isString(ariaLabel) || isString(ariaLabelledBy);
505
394
  if (!isNamed) return void 0;
506
395
  if (tag === "section") return "region";
507
396
  if (tag === "form") return "form";
508
397
  return void 0;
509
398
  }
510
399
 
400
+ // ../../lib/primitive/src/guards/aria/is-known-aria-role.ts
401
+ function isKnownAriaRole(value) {
402
+ return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
403
+ }
404
+
405
+ // ../../lib/contract/src/aria/aria-role-policy.ts
406
+ function getImplicitRole(tag, props) {
407
+ if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
408
+ if (tag === "input") return getInputImplicitRole(props?.type);
409
+ if (tag === "img") return props?.alt === "" ? "none" : "img";
410
+ if (tag === "section" || tag === "form") {
411
+ return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
412
+ }
413
+ return void 0;
414
+ }
415
+
416
+ // ../../lib/primitive/src/tag/resolve-tag.ts
417
+ function makeResolveTag(defaultTag) {
418
+ return function tag(as) {
419
+ return as ?? defaultTag;
420
+ };
421
+ }
422
+
423
+ // ../../lib/primitive/src/utils/assert-never.ts
424
+ function assertNever(value) {
425
+ throw new Error(`Unexpected value: ${String(value)}`);
426
+ }
427
+
428
+ // ../../lib/primitive/src/utils/cn.ts
429
+ import { clsx } from "clsx";
430
+ function cn(...inputs) {
431
+ return clsx(...inputs);
432
+ }
433
+
434
+ // ../../lib/primitive/src/utils/iterate.ts
435
+ function find(iterable, callback) {
436
+ for (const value of iterable) {
437
+ const result = callback(value);
438
+ if (result != null) {
439
+ return result;
440
+ }
441
+ }
442
+ return null;
443
+ }
444
+ function some(iterable, predicate) {
445
+ for (const value of iterable) {
446
+ if (predicate(value)) return true;
447
+ }
448
+ return false;
449
+ }
450
+ function every(iterable, predicate) {
451
+ let index = 0;
452
+ for (const value of iterable) {
453
+ if (!predicate(value, index++)) {
454
+ return false;
455
+ }
456
+ }
457
+ return true;
458
+ }
459
+ function* filter(iterable, predicate) {
460
+ let index = 0;
461
+ for (const value of iterable) {
462
+ if (predicate(value, index++)) {
463
+ yield value;
464
+ }
465
+ }
466
+ }
467
+ function* map(iterable, callback) {
468
+ let index = 0;
469
+ for (const value of iterable) {
470
+ yield callback(value, index++);
471
+ }
472
+ }
473
+ function forEach(iterable, callback) {
474
+ let index = 0;
475
+ for (const value of iterable) {
476
+ callback(value, index++);
477
+ }
478
+ }
479
+ function reduce(iterable, initial, callback) {
480
+ let accumulator = initial;
481
+ let index = 0;
482
+ for (const value of iterable) {
483
+ accumulator = callback(accumulator, value, index++);
484
+ }
485
+ return accumulator;
486
+ }
487
+ function collect(iterable, callback) {
488
+ const result = {};
489
+ let index = 0;
490
+ for (const value of iterable) {
491
+ const entry = callback(value, index++);
492
+ if (entry === null) {
493
+ return null;
494
+ }
495
+ result[entry[0]] = entry[1];
496
+ }
497
+ return result;
498
+ }
499
+ function findLast(value, callback) {
500
+ for (let index = value.length - 1; index >= 0; index--) {
501
+ const result = callback(value[index], index);
502
+ if (result != null) {
503
+ return result;
504
+ }
505
+ }
506
+ return null;
507
+ }
508
+ function* items(collection) {
509
+ for (let i = 0; i < collection.length; i++) {
510
+ const item = collection.item(i);
511
+ if (item !== null) {
512
+ yield item;
513
+ }
514
+ }
515
+ }
516
+ function nodeList(list) {
517
+ return {
518
+ *[Symbol.iterator]() {
519
+ for (let i = 0; i < list.length; i++) {
520
+ const node = list.item(i);
521
+ if (node !== null) {
522
+ yield node;
523
+ }
524
+ }
525
+ }
526
+ };
527
+ }
528
+ function mapEntries(m) {
529
+ return m.entries();
530
+ }
531
+ function set(s) {
532
+ return s.values();
533
+ }
534
+ function hasOwn(object, key) {
535
+ return Object.hasOwn(object, key);
536
+ }
537
+ function* entries(object) {
538
+ for (const key in object) {
539
+ if (!hasOwn(object, key)) continue;
540
+ yield [key, object[key]];
541
+ }
542
+ }
543
+ function* keys(object) {
544
+ for (const [key] of entries(object)) {
545
+ yield key;
546
+ }
547
+ }
548
+ function* values(object) {
549
+ for (const [, value] of entries(object)) {
550
+ yield value;
551
+ }
552
+ }
553
+ function mapValues(object, callback) {
554
+ const result = {};
555
+ for (const [key, value] of entries(object)) {
556
+ result[key] = callback(value, key);
557
+ }
558
+ return result;
559
+ }
560
+ function forEachEntry(object, callback) {
561
+ for (const [key, value] of entries(object)) {
562
+ callback(key, value);
563
+ }
564
+ }
565
+ function forEachKey(object, callback) {
566
+ for (const key of keys(object)) {
567
+ callback(key);
568
+ }
569
+ }
570
+ function forEachValue(object, callback) {
571
+ for (const value of values(object)) {
572
+ callback(value);
573
+ }
574
+ }
575
+ function forEachSet(s, callback) {
576
+ for (const value of s) {
577
+ callback(value);
578
+ }
579
+ }
580
+ var iterate = Object.freeze({
581
+ entries,
582
+ filter,
583
+ find,
584
+ findLast,
585
+ forEach,
586
+ forEachEntry,
587
+ forEachKey,
588
+ forEachSet,
589
+ forEachValue,
590
+ items,
591
+ keys,
592
+ map,
593
+ mapEntries,
594
+ mapValues,
595
+ nodeList,
596
+ reduce,
597
+ collect,
598
+ set,
599
+ some,
600
+ every,
601
+ values
602
+ });
603
+
604
+ // ../../lib/primitive/src/utils/merge-refs.ts
605
+ function mergeRefsCore(...refs) {
606
+ const active = refs.filter((r) => r != null);
607
+ if (active.length === 0) return null;
608
+ if (active.length === 1) return active[0];
609
+ return (value) => {
610
+ iterate.forEach(active, (ref) => {
611
+ if (typeof ref === "function") {
612
+ ref(value);
613
+ } else {
614
+ ref.current = value;
615
+ }
616
+ });
617
+ };
618
+ }
619
+
620
+ // ../../lib/primitive/src/utils/merge-props.ts
621
+ function mergeProps(defaultProps, props) {
622
+ return {
623
+ ...defaultProps ?? {},
624
+ ...props
625
+ };
626
+ }
627
+
511
628
  // ../../lib/primitive/src/guards/children/component-id.ts
512
629
  var COMPONENT_ID = /* @__PURE__ */ Symbol.for("praxis.component-id");
513
630
  var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
@@ -545,17 +662,6 @@ function isTag(...args) {
545
662
  return tag !== void 0 && set2.has(tag);
546
663
  }
547
664
 
548
- // ../../lib/contract/src/aria/aria-role-policy.ts
549
- function getImplicitRole(tag, props) {
550
- if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
551
- if (tag === "input") return getInputImplicitRole(props?.type);
552
- if (tag === "img") return props?.alt === "" ? "none" : "img";
553
- if (tag === "section" || tag === "form") {
554
- return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
555
- }
556
- return void 0;
557
- }
558
-
559
665
  // ../../lib/contract/src/strict/invariant-base.ts
560
666
  var InvariantBase = class {
561
667
  diagnostics;
@@ -578,159 +684,21 @@ var InvariantBase = class {
578
684
  }
579
685
  };
580
686
 
581
- // ../../lib/diagnostics/src/category.ts
582
- var DiagnosticCategory = /* @__PURE__ */ ((DiagnosticCategory2) => {
583
- DiagnosticCategory2[DiagnosticCategory2["Contract"] = 0] = "Contract";
584
- DiagnosticCategory2[DiagnosticCategory2["HTML"] = 1] = "HTML";
585
- DiagnosticCategory2[DiagnosticCategory2["ARIA"] = 2] = "ARIA";
586
- DiagnosticCategory2[DiagnosticCategory2["Composition"] = 3] = "Composition";
587
- DiagnosticCategory2[DiagnosticCategory2["Rendering"] = 4] = "Rendering";
588
- DiagnosticCategory2[DiagnosticCategory2["Accessibility"] = 5] = "Accessibility";
589
- DiagnosticCategory2[DiagnosticCategory2["Performance"] = 6] = "Performance";
590
- DiagnosticCategory2[DiagnosticCategory2["Internal"] = 7] = "Internal";
591
- DiagnosticCategory2[DiagnosticCategory2["Deprecation"] = 8] = "Deprecation";
592
- DiagnosticCategory2[DiagnosticCategory2["Lint"] = 9] = "Lint";
593
- return DiagnosticCategory2;
594
- })(DiagnosticCategory || {});
595
-
596
- // ../../lib/diagnostics/src/error.ts
597
- var PraxisError = class extends Error {
598
- diagnostic;
599
- constructor(diagnostic) {
600
- super(diagnostic.message);
601
- this.name = "PraxisError";
602
- this.diagnostic = diagnostic;
603
- }
604
- };
605
-
606
- // ../../lib/diagnostics/src/severity.ts
607
- var Severity = /* @__PURE__ */ ((Severity2) => {
608
- Severity2[Severity2["Debug"] = 0] = "Debug";
609
- Severity2[Severity2["Info"] = 1] = "Info";
610
- Severity2[Severity2["Warning"] = 2] = "Warning";
611
- Severity2[Severity2["Error"] = 3] = "Error";
612
- Severity2[Severity2["Fatal"] = 4] = "Fatal";
613
- return Severity2;
614
- })(Severity || {});
615
-
616
- // ../../lib/diagnostics/src/policy.ts
617
- var DefaultPolicy = class {
618
- reportThreshold;
619
- throwThreshold;
620
- constructor({
621
- reportThreshold = 1 /* Info */,
622
- throwThreshold = 4 /* Fatal */
623
- } = {}) {
624
- this.reportThreshold = reportThreshold;
625
- this.throwThreshold = throwThreshold;
626
- }
627
- resolve(diagnostic) {
628
- if (diagnostic.severity >= this.throwThreshold) return 2 /* Throw */;
629
- if (diagnostic.severity >= this.reportThreshold) return 1 /* Report */;
630
- return 0 /* Ignore */;
631
- }
632
- };
633
-
634
- // ../../lib/diagnostics/src/diagnostics.ts
635
- var Diagnostics = class {
636
- reporter;
637
- policy;
638
- // Pre-computed at construction time: true if Warning-level diagnostics are not ignored.
639
- active;
640
- constructor(reporter, policy = new DefaultPolicy()) {
641
- this.reporter = reporter;
642
- this.policy = policy;
643
- this.active = policy.resolve({ severity: 2 /* Warning */ }) !== 0 /* Ignore */;
644
- }
645
- report(diagnostic) {
646
- const enforcement = this.policy.resolve(diagnostic);
647
- if (enforcement === 0 /* Ignore */) return diagnostic;
648
- if (enforcement === 2 /* Throw */) throw new PraxisError(diagnostic);
649
- this.reporter.report(diagnostic);
650
- return diagnostic;
651
- }
652
- warn(input) {
653
- return this.report({ ...input, severity: 2 /* Warning */ });
654
- }
655
- error(input) {
656
- return this.report({ ...input, severity: 3 /* Error */ });
657
- }
658
- info(input) {
659
- return this.report({ ...input, severity: 1 /* Info */ });
660
- }
661
- };
662
-
663
- // ../../lib/diagnostics/src/formatter.ts
664
- function formatDiagnostic(diagnostic) {
665
- const level = Severity[diagnostic.severity];
666
- const category = DiagnosticCategory[diagnostic.category];
667
- const prefix = category !== void 0 ? `[${category}] ` : "";
668
- return `${level} ${diagnostic.code}: ${prefix}${diagnostic.message}`;
669
- }
670
-
671
- // ../../lib/diagnostics/src/console-reporter.ts
672
- var ConsoleReporter = class {
673
- report(diagnostic) {
674
- const message = formatDiagnostic(diagnostic);
675
- switch (diagnostic.severity) {
676
- case 0 /* Debug */:
677
- console.debug(message);
678
- break;
679
- case 1 /* Info */:
680
- console.info(message);
681
- break;
682
- case 2 /* Warning */:
683
- console.warn(message);
684
- break;
685
- case 3 /* Error */:
686
- case 4 /* Fatal */:
687
- console.error(message);
688
- break;
689
- }
690
- }
691
- };
692
-
693
- // ../../lib/diagnostics/src/null-reporter.ts
694
- var nullReporter = {
695
- report() {
696
- }
697
- };
698
-
699
- // ../../lib/diagnostics/src/presets.ts
700
- var ignoreAllPolicy = {
701
- resolve(_) {
702
- return 0 /* Ignore */;
703
- }
704
- };
705
- var warnOnlyReporter = {
706
- report(diagnostic) {
707
- console.warn(formatDiagnostic(diagnostic));
708
- }
709
- };
710
- var silentDiagnostics = new Diagnostics(nullReporter, ignoreAllPolicy);
711
- var warnDiagnostics = new Diagnostics(
712
- warnOnlyReporter,
713
- new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 4 /* Fatal */ })
714
- );
715
- var throwDiagnostics = new Diagnostics(
716
- new ConsoleReporter(),
717
- new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 3 /* Error */ })
718
- );
719
-
720
687
  // ../../lib/contract/src/diagnostics/aria.ts
688
+ import { DiagnosticCategory, DiagnosticCode } from "./_shared/diagnostics.js";
721
689
  var AriaDiagnostics = {
722
690
  /** Generic bridge for violations produced by external AriaRule functions. */
723
691
  fromViolation(v) {
724
692
  return {
725
- code: "ARIA2002" /* AriaViolation */,
726
- category: 2 /* ARIA */,
693
+ code: DiagnosticCode.AriaViolation,
694
+ category: DiagnosticCategory.ARIA,
727
695
  message: v.message
728
696
  };
729
697
  },
730
698
  attributeInvalid(key, role) {
731
699
  return {
732
- code: "ARIA2003" /* AriaAttributeInvalid */,
733
- category: 2 /* ARIA */,
700
+ code: DiagnosticCode.AriaAttributeInvalid,
701
+ category: DiagnosticCategory.ARIA,
734
702
  message: `"${key}" is not valid on role="${role}". It will be removed.`,
735
703
  rationale: "Invalid ARIA attributes are ignored by assistive technology and may trigger accessibility-tree warnings in browser devtools.",
736
704
  suggestions: [
@@ -743,8 +711,8 @@ var AriaDiagnostics = {
743
711
  },
744
712
  missingLiveRegion(role, impliedLive) {
745
713
  return {
746
- code: "ARIA2004" /* AriaMissingLiveRegion */,
747
- category: 2 /* ARIA */,
714
+ code: DiagnosticCode.AriaMissingLiveRegion,
715
+ category: DiagnosticCategory.ARIA,
748
716
  message: `role="${role}" implies aria-live="${impliedLive}" but it is missing. It has been injected.`,
749
717
  rationale: "Live-region roles announce dynamic content changes to screen readers. Without aria-live the politeness level is unspecified and announcements may be silent.",
750
718
  suggestions: [
@@ -758,8 +726,8 @@ var AriaDiagnostics = {
758
726
  },
759
727
  missingAtomic(role) {
760
728
  return {
761
- code: "ARIA2005" /* AriaMissingAtomic */,
762
- category: 2 /* ARIA */,
729
+ code: DiagnosticCode.AriaMissingAtomic,
730
+ category: DiagnosticCategory.ARIA,
763
731
  message: `role="${role}" 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.`,
764
732
  rationale: "aria-atomic controls whether assistive technology announces the entire live region or only the changed nodes. Omitting it leaves the behaviour browser-defined."
765
733
  };
@@ -767,8 +735,8 @@ var AriaDiagnostics = {
767
735
  relevantInvalidTokens(invalid) {
768
736
  const quoted = invalid.map((t) => `"${t}"`).join(", ");
769
737
  return {
770
- code: "ARIA2006" /* AriaRelevantInvalidToken */,
771
- category: 2 /* ARIA */,
738
+ code: DiagnosticCode.AriaRelevantInvalidToken,
739
+ category: DiagnosticCategory.ARIA,
772
740
  message: `aria-relevant contains invalid token(s): ${quoted}. Valid tokens are: additions, removals, text, all.`,
773
741
  rationale: "aria-relevant accepts a space-separated list of change types. Unrecognised tokens are silently ignored by assistive technology, making the attribute ineffective.",
774
742
  suggestions: [
@@ -781,8 +749,8 @@ var AriaDiagnostics = {
781
749
  },
782
750
  relevantSuperseded() {
783
751
  return {
784
- code: "ARIA2007" /* AriaRelevantSuperseded */,
785
- category: 2 /* ARIA */,
752
+ code: DiagnosticCode.AriaRelevantSuperseded,
753
+ category: DiagnosticCategory.ARIA,
786
754
  message: 'aria-relevant includes "all" alongside other tokens. "all" supersedes additions, removals, and text \u2014 use aria-relevant="all" alone.',
787
755
  rationale: '"all" is equivalent to "additions removals text". Combining it with other tokens is redundant and may confuse readers of the markup.',
788
756
  suggestions: [
@@ -795,8 +763,8 @@ var AriaDiagnostics = {
795
763
  },
796
764
  missingAccessibleName(tag) {
797
765
  return {
798
- code: "ARIA2009" /* AriaMissingAccessibleName */,
799
- category: 2 /* ARIA */,
766
+ code: DiagnosticCode.AriaMissingAccessibleName,
767
+ category: DiagnosticCategory.ARIA,
800
768
  message: `<${tag}> has no accessible name. Add aria-label or aria-labelledby.`,
801
769
  rationale: "Elements with a landmark or interactive role must have an accessible name so that assistive technology can identify them when presenting the page outline.",
802
770
  suggestions: [
@@ -813,8 +781,8 @@ var AriaDiagnostics = {
813
781
  },
814
782
  attributeOnPresentational(attr, tag) {
815
783
  return {
816
- code: "ARIA2010" /* AriaAttributeOnPresentational */,
817
- category: 2 /* ARIA */,
784
+ code: DiagnosticCode.AriaAttributeOnPresentational,
785
+ category: DiagnosticCategory.ARIA,
818
786
  message: `"${attr}" is not allowed on a presentational <${tag}>. Presentational elements are invisible to assistive technology.`,
819
787
  rationale: 'role="none" and role="presentation" (including <img alt="">) remove an element from the accessibility tree. ARIA attributes on such elements are ignored by assistive technology.',
820
788
  suggestions: [
@@ -827,8 +795,8 @@ var AriaDiagnostics = {
827
795
  },
828
796
  ariaHiddenOnFocusable(tag) {
829
797
  return {
830
- code: "ARIA2011" /* AriaHiddenOnFocusable */,
831
- category: 2 /* ARIA */,
798
+ code: DiagnosticCode.AriaHiddenOnFocusable,
799
+ category: DiagnosticCategory.ARIA,
832
800
  message: `aria-hidden="true" must not be used on focusable <${tag}> elements. Screen reader users who navigate by keyboard will encounter the element but receive no information about it.`,
833
801
  rationale: 'aria-hidden removes an element from the accessibility tree while leaving it keyboard-reachable. This creates a "ghost" \u2014 a focusable element assistive technology cannot describe.',
834
802
  suggestions: [
@@ -846,8 +814,8 @@ var AriaDiagnostics = {
846
814
  invalidAttributeValue(attr, value, expected) {
847
815
  const got = value === null ? "null" : value === void 0 ? "undefined" : typeof value === "string" ? `"${value}"` : String(value);
848
816
  return {
849
- code: "ARIA2013" /* AriaInvalidAttributeValue */,
850
- category: 2 /* ARIA */,
817
+ code: DiagnosticCode.AriaInvalidAttributeValue,
818
+ category: DiagnosticCategory.ARIA,
851
819
  message: `"${attr}" has an invalid value (${got}). Expected: ${expected}.`,
852
820
  rationale: "ARIA attributes with invalid values are silently ignored by assistive technology, making the markup semantically inert.",
853
821
  suggestions: [
@@ -860,8 +828,8 @@ var AriaDiagnostics = {
860
828
  },
861
829
  redundantAriaLevel(tag, level) {
862
830
  return {
863
- code: "ARIA2014" /* AriaRedundantLevelAttribute */,
864
- category: 2 /* ARIA */,
831
+ code: DiagnosticCode.AriaRedundantLevelAttribute,
832
+ category: DiagnosticCategory.ARIA,
865
833
  message: `aria-level="${level}" is redundant on <${tag}>: the element already has an implicit heading level of ${level}. Remove the attribute.`,
866
834
  rationale: 'Restating the implicit aria-level adds noise without semantic value. Use aria-level only to override the native heading level (e.g. aria-level="3" on <h2>).',
867
835
  suggestions: [
@@ -874,8 +842,8 @@ var AriaDiagnostics = {
874
842
  },
875
843
  requiredProperty(attr, role) {
876
844
  return {
877
- code: "ARIA2012" /* AriaRequiredProperty */,
878
- category: 2 /* ARIA */,
845
+ code: DiagnosticCode.AriaRequiredProperty,
846
+ category: DiagnosticCategory.ARIA,
879
847
  message: `"${attr}" is required for role="${role}" but is missing.`,
880
848
  rationale: `WAI-ARIA 1.2 specifies required states and properties for certain roles. Without "${attr}", assistive technology cannot correctly communicate the element's state to users.`,
881
849
  suggestions: [
@@ -888,8 +856,8 @@ var AriaDiagnostics = {
888
856
  },
889
857
  invalidRole(role, tag) {
890
858
  return {
891
- code: "ARIA2008" /* AriaInvalidRole */,
892
- category: 2 /* ARIA */,
859
+ code: DiagnosticCode.AriaInvalidRole,
860
+ category: DiagnosticCategory.ARIA,
893
861
  message: `Invalid role "${role ?? ""}" on <${tag}>.`,
894
862
  rationale: "An unrecognised or misapplied ARIA role is ignored by assistive technology and may degrade the accessibility of the element."
895
863
  };
@@ -897,11 +865,12 @@ var AriaDiagnostics = {
897
865
  };
898
866
 
899
867
  // ../../lib/contract/src/diagnostics/contract.ts
868
+ import { DiagnosticCategory as DiagnosticCategory2, DiagnosticCode as DiagnosticCode2 } from "./_shared/diagnostics.js";
900
869
  var ContractDiagnostics = {
901
870
  unexpectedChild(typeName, index, context) {
902
871
  return {
903
- code: "COMP1004" /* UnexpectedChild */,
904
- category: 0 /* Contract */,
872
+ code: DiagnosticCode2.UnexpectedChild,
873
+ category: DiagnosticCategory2.Contract,
905
874
  component: context,
906
875
  message: `${context}: unexpected child "${typeName}" at index ${index}.`
907
876
  };
@@ -909,69 +878,69 @@ var ContractDiagnostics = {
909
878
  ambiguousChild(typeName, index, ruleNames, context) {
910
879
  const quoted = ruleNames.map((n) => `"${n}"`).join(" and ");
911
880
  return {
912
- code: "COMP1005" /* AmbiguousChild */,
913
- category: 0 /* Contract */,
881
+ code: DiagnosticCode2.AmbiguousChild,
882
+ category: DiagnosticCategory2.Contract,
914
883
  component: context,
915
884
  message: `${context}: child "${typeName}" at index ${index} matches multiple child rules: ${quoted}.`
916
885
  };
917
886
  },
918
887
  cardinalityMin(ruleName, min, context) {
919
888
  return {
920
- code: "COMP1006" /* CardinalityMin */,
921
- category: 0 /* Contract */,
889
+ code: DiagnosticCode2.CardinalityMin,
890
+ category: DiagnosticCategory2.Contract,
922
891
  component: context,
923
892
  message: `${context}: "${ruleName}" requires at least ${min}.`
924
893
  };
925
894
  },
926
895
  cardinalityMax(ruleName, max, context) {
927
896
  return {
928
- code: "COMP1007" /* CardinalityMax */,
929
- category: 0 /* Contract */,
897
+ code: DiagnosticCode2.CardinalityMax,
898
+ category: DiagnosticCategory2.Contract,
930
899
  component: context,
931
900
  message: `${context}: "${ruleName}" allows at most ${max}.`
932
901
  };
933
902
  },
934
903
  positionViolation(ruleName, position, index, context) {
935
904
  return {
936
- code: "COMP1008" /* PositionViolation */,
937
- category: 0 /* Contract */,
905
+ code: DiagnosticCode2.PositionViolation,
906
+ category: DiagnosticCategory2.Contract,
938
907
  component: context,
939
908
  message: `${context}: "${ruleName}" must be ${position}, got index ${index}`
940
909
  };
941
910
  },
942
- unknownVariantDim(component, label, dim) {
911
+ unknownVariantDim(component, label2, dim) {
943
912
  return {
944
- code: "COMP1010" /* ContractUnknownVariantDim */,
945
- category: 0 /* Contract */,
946
- message: `${component}: ${label} references unknown variant "${dim}".`
913
+ code: DiagnosticCode2.ContractUnknownVariantDim,
914
+ category: DiagnosticCategory2.Contract,
915
+ message: `${component}: ${label2} references unknown variant "${dim}".`
947
916
  };
948
917
  },
949
- unknownVariantValue(component, label, dim, value, valid) {
918
+ unknownVariantValue(component, label2, dim, value, valid) {
950
919
  return {
951
- code: "COMP1011" /* ContractUnknownVariantValue */,
952
- category: 0 /* Contract */,
953
- message: `${component}: ${label} sets "${dim}" to unknown value "${value}" (valid: ${valid.join(", ")}).`
920
+ code: DiagnosticCode2.ContractUnknownVariantValue,
921
+ category: DiagnosticCategory2.Contract,
922
+ message: `${component}: ${label2} sets "${dim}" to unknown value "${value}" (valid: ${valid.join(", ")}).`
954
923
  };
955
924
  },
956
925
  unknownRecipeKey(component, key) {
957
926
  return {
958
- code: "COMP1012" /* ContractUnknownRecipeKey */,
959
- category: 0 /* Contract */,
927
+ code: DiagnosticCode2.ContractUnknownRecipeKey,
928
+ category: DiagnosticCategory2.Contract,
960
929
  message: `${component} Unknown recipeKey "${key}" \u2014 no preset with that name exists.`
961
930
  };
962
931
  },
963
932
  invalidVariantValue(component, key, value) {
964
933
  return {
965
- code: "COMP1013" /* ContractInvalidVariantValue */,
966
- category: 0 /* Contract */,
934
+ code: DiagnosticCode2.ContractInvalidVariantValue,
935
+ category: DiagnosticCategory2.Contract,
967
936
  message: `${component} Variant "${key}=${value}" is not a defined value for the "${key}" dimension.`
968
937
  };
969
938
  },
970
939
  allowedAsViolation(tag, allowedAs, component) {
971
940
  const allowed = allowedAs.map((t) => `"${String(t)}"`).join(", ");
972
941
  return {
973
- code: "COMP1009" /* AllowedAsViolation */,
974
- category: 0 /* Contract */,
942
+ code: DiagnosticCode2.AllowedAsViolation,
943
+ category: DiagnosticCategory2.Contract,
975
944
  component,
976
945
  message: `<${component}>: "as" prop received "${tag}" but only [${allowed}] are allowed.`
977
946
  };
@@ -979,73 +948,75 @@ var ContractDiagnostics = {
979
948
  };
980
949
 
981
950
  // ../../lib/contract/src/diagnostics/html.ts
951
+ import { DiagnosticCategory as DiagnosticCategory3, DiagnosticCode as DiagnosticCode3 } from "./_shared/diagnostics.js";
982
952
  var HtmlDiagnostics = {
983
953
  emptyRole(tag) {
984
954
  return {
985
- code: "HTML3002" /* HtmlEmptyRole */,
986
- category: 1 /* HTML */,
955
+ code: DiagnosticCode3.HtmlEmptyRole,
956
+ category: DiagnosticCategory3.HTML,
987
957
  message: `<${tag}> has an explicit empty role="". Omit the attribute instead.`
988
958
  };
989
959
  },
990
960
  implicitRoleRedundant(tag, implicitRole) {
991
961
  return {
992
- code: "HTML3003" /* HtmlImplicitRoleRedundant */,
993
- category: 1 /* HTML */,
962
+ code: DiagnosticCode3.HtmlImplicitRoleRedundant,
963
+ category: DiagnosticCategory3.HTML,
994
964
  message: `<${tag}> already has implicit role="${implicitRole}". Avoid redundant role assignment.`
995
965
  };
996
966
  },
997
967
  implicitRoleOverride(tag, implicitRole, role) {
998
968
  return {
999
- code: "HTML3004" /* HtmlImplicitRoleOverride */,
1000
- category: 1 /* HTML */,
969
+ code: DiagnosticCode3.HtmlImplicitRoleOverride,
970
+ category: DiagnosticCategory3.HTML,
1001
971
  message: `<${tag}> should not override its implicit role="${implicitRole}" with role="${role}".`
1002
972
  };
1003
973
  },
1004
974
  standaloneRegionOverride(tag, implicitRole) {
1005
975
  return {
1006
- code: "HTML3005" /* HtmlStandaloneRegionOverride */,
1007
- category: 1 /* HTML */,
976
+ code: DiagnosticCode3.HtmlStandaloneRegionOverride,
977
+ category: DiagnosticCategory3.HTML,
1008
978
  message: `<${tag}> is a self-contained element with implicit role="${implicitRole}". Assigning role="region" has been removed.`
1009
979
  };
1010
980
  },
1011
981
  landmarkRoleOverride(tag, implicitRole, role) {
1012
982
  return {
1013
- code: "HTML3006" /* HtmlLandmarkRoleOverride */,
1014
- category: 1 /* HTML */,
983
+ code: DiagnosticCode3.HtmlLandmarkRoleOverride,
984
+ category: DiagnosticCategory3.HTML,
1015
985
  message: `<${tag}> has a fixed landmark role="${implicitRole}". role="${role}" overrides it and confuses assistive technology. The override has been removed.`
1016
986
  };
1017
987
  },
1018
988
  invalidChild(child, parent, allowed) {
1019
989
  return {
1020
- code: "HTML3007" /* HtmlInvalidChild */,
1021
- category: 1 /* HTML */,
990
+ code: DiagnosticCode3.HtmlInvalidChild,
991
+ category: DiagnosticCategory3.HTML,
1022
992
  message: `<${child}> is not a valid direct child of <${parent}>. Allowed: ${allowed}.`
1023
993
  };
1024
994
  }
1025
995
  };
1026
996
 
1027
997
  // ../../lib/contract/src/diagnostics/slot.ts
998
+ import { DiagnosticCategory as DiagnosticCategory4, DiagnosticCode as DiagnosticCode4 } from "./_shared/diagnostics.js";
1028
999
  var SlotDiagnostics = {
1029
1000
  exclusive(name) {
1030
1001
  return {
1031
- code: "SLOT1001" /* SlotExclusive */,
1032
- category: 0 /* Contract */,
1002
+ code: DiagnosticCode4.SlotExclusive,
1003
+ category: DiagnosticCategory4.Contract,
1033
1004
  component: name,
1034
1005
  message: `${name}: "as" and "asChild" are mutually exclusive`
1035
1006
  };
1036
1007
  },
1037
1008
  singleChildRequired(name, elementTerm) {
1038
1009
  return {
1039
- code: "SLOT1002" /* SlotSingleChild */,
1040
- category: 0 /* Contract */,
1010
+ code: DiagnosticCode4.SlotSingleChild,
1011
+ category: DiagnosticCategory4.Contract,
1041
1012
  component: name,
1042
1013
  message: `${name}: asChild requires a ${elementTerm} child`
1043
1014
  };
1044
1015
  },
1045
1016
  singleChildExceeded(name, elementTerm, count) {
1046
1017
  return {
1047
- code: "SLOT1002" /* SlotSingleChild */,
1048
- category: 0 /* Contract */,
1018
+ code: DiagnosticCode4.SlotSingleChild,
1019
+ category: DiagnosticCategory4.Contract,
1049
1020
  component: name,
1050
1021
  message: `${name}: asChild requires exactly one ${elementTerm} child, got ${count}`
1051
1022
  };
@@ -1053,16 +1024,16 @@ var SlotDiagnostics = {
1053
1024
  discardedChildren(name, elementTerm, count) {
1054
1025
  const suffix = count === 1 ? "" : "ren";
1055
1026
  return {
1056
- code: "SLOT1003" /* SlotDiscardedChildren */,
1057
- category: 0 /* Contract */,
1027
+ code: DiagnosticCode4.SlotDiscardedChildren,
1028
+ category: DiagnosticCategory4.Contract,
1058
1029
  component: name,
1059
1030
  message: `${name}: asChild discarded ${count} non-element child${suffix} \u2014 only ${elementTerm}s are valid asChild children.`
1060
1031
  };
1061
1032
  },
1062
1033
  renderFnRequired(name, received) {
1063
1034
  return {
1064
- code: "SLOT1004" /* SlotRenderFn */,
1065
- category: 0 /* Contract */,
1035
+ code: DiagnosticCode4.SlotRenderFn,
1036
+ category: DiagnosticCategory4.Contract,
1066
1037
  component: name,
1067
1038
  message: `${name}: asChild requires a render function as children, got ${received}`
1068
1039
  };
@@ -1746,7 +1717,7 @@ function getTypeName(value) {
1746
1717
  return primitive;
1747
1718
  }
1748
1719
  const name = value.constructor?.name;
1749
- return typeof name === "string" && name !== "Object" ? name : "object";
1720
+ return isString(name) && name !== "Object" ? name : "object";
1750
1721
  }
1751
1722
 
1752
1723
  // ../../lib/contract/src/children/normalize-child-rule.ts
@@ -1997,6 +1968,9 @@ var readonlyProps = ({
1997
1968
  };
1998
1969
  };
1999
1970
 
1971
+ // ../core/src/html/evaluators.ts
1972
+ import { warnDiagnostics as warnDiagnostics2 } from "./_shared/diagnostics.js";
1973
+
2000
1974
  // ../core/src/html/aria-rules.ts
2001
1975
  var LANDMARK_TAG_SET = /* @__PURE__ */ new Set(["article", "aside", "footer", "header", "main", "nav"]);
2002
1976
  var removeLandmarkRoleOverride = {
@@ -2037,8 +2011,10 @@ function landmarkNameAdvisory(ctx) {
2037
2011
  if (!ctx.implicitRole || !NAMED_LANDMARK_TAGS.has(ctx.tag)) return [];
2038
2012
  return requireAccessibleName(ctx);
2039
2013
  }
2014
+ var HTML_ARIA_RULES = [landmarkRoleRule, landmarkNameAdvisory];
2040
2015
 
2041
2016
  // ../core/src/html/contracts.ts
2017
+ import { warnDiagnostics } from "./_shared/diagnostics.js";
2042
2018
  function isOpenContent(...blockedTags) {
2043
2019
  const set2 = new Set(blockedTags);
2044
2020
  return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set2.has(child.type));
@@ -2183,7 +2159,7 @@ var htmlContracts = {
2183
2159
  };
2184
2160
 
2185
2161
  // ../core/src/html/evaluators.ts
2186
- var htmlDiagnostics = warnDiagnostics;
2162
+ var htmlDiagnostics = warnDiagnostics2;
2187
2163
  function buildEvaluatorMap() {
2188
2164
  const map2 = /* @__PURE__ */ new Map();
2189
2165
  iterate.forEachEntry(htmlContracts, (tag, { children }) => {
@@ -2211,37 +2187,396 @@ function getHtmlPropNormalizers(tag) {
2211
2187
  return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
2212
2188
  }
2213
2189
 
2214
- // ../../lib/styling/src/variant-pass/compile-variant-lookup.ts
2215
- function buildPrecomputedKey(props) {
2216
- return Object.entries(props).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}:${v}`).join("|");
2217
- }
2190
+ // ../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.mjs
2191
+ import { clsx as clsx2 } from "clsx";
2192
+ var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
2193
+ var cx = clsx2;
2194
+ var cva = (base, config) => (props) => {
2195
+ var _config_compoundVariants;
2196
+ 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);
2197
+ const { variants, defaultVariants } = config;
2198
+ const getVariantClassNames = Object.keys(variants).map((variant) => {
2199
+ const variantProp = props === null || props === void 0 ? void 0 : props[variant];
2200
+ const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
2201
+ if (variantProp === null) return null;
2202
+ const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
2203
+ return variants[variant][variantKey];
2204
+ });
2205
+ const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
2206
+ let [key, value] = param;
2207
+ if (value === void 0) {
2208
+ return acc;
2209
+ }
2210
+ acc[key] = value;
2211
+ return acc;
2212
+ }, {});
2213
+ 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) => {
2214
+ let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
2215
+ return Object.entries(compoundVariantOptions).every((param2) => {
2216
+ let [key, value] = param2;
2217
+ return Array.isArray(value) ? value.includes({
2218
+ ...defaultVariants,
2219
+ ...propsWithoutUndefined
2220
+ }[key]) : {
2221
+ ...defaultVariants,
2222
+ ...propsWithoutUndefined
2223
+ }[key] === value;
2224
+ }) ? [
2225
+ ...acc,
2226
+ cvClass,
2227
+ cvClassName
2228
+ ] : acc;
2229
+ }, []);
2230
+ return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
2231
+ };
2218
2232
 
2219
- // ../../lib/styling/src/variant-pass/variant-pass.ts
2220
- function createVariantPass(activeProps, config) {
2221
- return {
2222
- name: "variant",
2223
- execute() {
2224
- const preset = typeof activeProps["preset"] === "string" ? activeProps["preset"] : void 0;
2225
- const presetDefaults = preset !== void 0 && config.presets?.[preset] !== void 0 ? config.presets[preset] : {};
2226
- const resolved = {
2227
- ...config.defaults,
2228
- ...presetDefaults,
2229
- ...activeProps
2230
- };
2231
- const classes = [];
2232
- iterate.forEachEntry(config.variants, (key, valueMap) => {
2233
- const active = resolved[key];
2234
- if (typeof active === "string") {
2235
- const cls = valueMap[active];
2236
- if (cls !== void 0) classes.push(cls);
2237
- }
2233
+ // ../../lib/styling/src/cva.ts
2234
+ function cva2(base, config) {
2235
+ const fn = cva(base, config);
2236
+ return (props) => cn(fn(props));
2237
+ }
2238
+
2239
+ // ../../lib/styling/src/static-class-resolver.ts
2240
+ var StaticClassResolver = class {
2241
+ #baseClass;
2242
+ #cache = /* @__PURE__ */ new Map();
2243
+ #resolveTag;
2244
+ constructor(baseClass, tagMap) {
2245
+ this.#baseClass = Array.isArray(baseClass) ? baseClass.join(" ") : baseClass;
2246
+ this.#resolveTag = tagMap ? (tag) => {
2247
+ const extra = tagMap[tag];
2248
+ if (!extra) return this.#baseClass;
2249
+ const extraStr = Array.isArray(extra) ? extra.join(" ") : extra;
2250
+ return `${this.#baseClass} ${extraStr}`;
2251
+ } : () => this.#baseClass;
2252
+ }
2253
+ resolve(tag, skipTagMap = false) {
2254
+ if (typeof tag !== "string" || skipTagMap) return this.#baseClass;
2255
+ const cached = this.#cache.get(tag);
2256
+ if (cached !== void 0) {
2257
+ this.#cache.delete(tag);
2258
+ this.#cache.set(tag, cached);
2259
+ return cached;
2260
+ }
2261
+ const result = this.#resolveTag(tag);
2262
+ this.#cache.set(tag, result);
2263
+ if (this.#cache.size > 200) {
2264
+ const lru = this.#cache.keys().next().value;
2265
+ if (lru !== void 0) this.#cache.delete(lru);
2266
+ }
2267
+ return result;
2268
+ }
2269
+ };
2270
+
2271
+ // ../../lib/styling/src/variant-class-resolver.ts
2272
+ var VariantClassResolver = class _VariantClassResolver {
2273
+ #cvaFn;
2274
+ #recipeMap;
2275
+ #variantKeys;
2276
+ #precomputedClasses;
2277
+ #cache = /* @__PURE__ */ new Map();
2278
+ constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
2279
+ this.#cvaFn = cvaFn ?? null;
2280
+ this.#recipeMap = Object.freeze(recipeMap ?? {});
2281
+ this.#variantKeys = variantKeys ?? null;
2282
+ this.#precomputedClasses = precomputedClasses ?? null;
2283
+ }
2284
+ resolve({ props, recipe }) {
2285
+ const normalizedKey = recipe ?? "__none__";
2286
+ const cacheKey = this.#createCacheKey(props, normalizedKey);
2287
+ if (this.#precomputedClasses !== null) {
2288
+ const precomputed = this.#precomputedClasses[cacheKey];
2289
+ if (precomputed !== void 0) return precomputed;
2290
+ }
2291
+ const cached = this.#cache.get(cacheKey);
2292
+ if (cached !== void 0) {
2293
+ this.#cache.delete(cacheKey);
2294
+ this.#cache.set(cacheKey, cached);
2295
+ return cached;
2296
+ }
2297
+ const result = this.#compute(props, recipe);
2298
+ this.#cache.set(cacheKey, result);
2299
+ if (this.#cache.size > 1e3) {
2300
+ const lru = this.#cache.keys().next().value;
2301
+ if (lru !== void 0) this.#cache.delete(lru);
2302
+ }
2303
+ return result;
2304
+ }
2305
+ #compute(props, recipe) {
2306
+ if (!this.#cvaFn) return "";
2307
+ if (!recipe) return this.#cvaFn(props);
2308
+ const preset = this.#recipeMap[recipe];
2309
+ if (!preset) return this.#cvaFn(props);
2310
+ return this.#cvaFn({ ...preset, ...props });
2311
+ }
2312
+ // When variantKeys is provided, only those keys are included in the cache key — non-variant
2313
+ // props (className, id, etc.) produce identical CVA output and must not fragment the cache.
2314
+ // Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
2315
+ // String is built incrementally to avoid a parts[] array allocation on every render.
2316
+ #createCacheKey(props, recipe) {
2317
+ if (this.#variantKeys !== null) {
2318
+ let key2 = recipe;
2319
+ iterate.forEachSet(this.#variantKeys, (k) => {
2320
+ if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
2238
2321
  });
2239
- return { context: { classes } };
2322
+ return key2;
2323
+ }
2324
+ let key = recipe;
2325
+ iterate.forEach(Object.keys(props).sort(), (k) => {
2326
+ key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
2327
+ });
2328
+ return key;
2329
+ }
2330
+ static #serializeValue(value) {
2331
+ if (value === void 0) return "u";
2332
+ if (value === null) return "n";
2333
+ if (typeof value === "boolean") return `b:${value}`;
2334
+ if (typeof value === "string") return `s:${value}`;
2335
+ return `x:${String(value)}`;
2336
+ }
2337
+ };
2338
+
2339
+ // ../../lib/styling/src/create-class-pipeline.ts
2340
+ function createClassPipeline(resolved) {
2341
+ const baseClass = resolved.baseClassName ?? "";
2342
+ const cvaFn = resolved.variants ? cva2("", {
2343
+ variants: resolved.variants,
2344
+ defaultVariants: resolved.defaultVariants,
2345
+ compoundVariants: resolved.compoundVariants
2346
+ }) : null;
2347
+ const variantKeys = resolved.variants ? new Set(Object.keys(resolved.variants)) : void 0;
2348
+ const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
2349
+ const variantResolver = new VariantClassResolver(
2350
+ cvaFn,
2351
+ resolved.recipeMap,
2352
+ variantKeys,
2353
+ resolved.precomputedClasses
2354
+ );
2355
+ return function resolveClasses(tag, props, className, recipe) {
2356
+ const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
2357
+ const variantClasses = variantResolver.resolve({ props, recipe });
2358
+ if (!className)
2359
+ return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
2360
+ return cn(staticClasses, variantClasses, className);
2361
+ };
2362
+ }
2363
+
2364
+ // ../../lib/pipeline-kit/src/factory/define-pipeline.ts
2365
+ function definePipeline(factory) {
2366
+ const cache = /* @__PURE__ */ new WeakMap();
2367
+ return (resolved) => {
2368
+ let pipeline = cache.get(resolved);
2369
+ if (!pipeline) {
2370
+ pipeline = factory(resolved);
2371
+ cache.set(resolved, pipeline);
2372
+ }
2373
+ return pipeline;
2374
+ };
2375
+ }
2376
+
2377
+ // ../core/src/options/resolve-factory-options.ts
2378
+ import { silentDiagnostics } from "./_shared/diagnostics.js";
2379
+ var EMPTY_VARIANT_KEYS = /* @__PURE__ */ new Set();
2380
+ function composeNormalizers(normalizers, fn) {
2381
+ if (!normalizers?.length) return fn;
2382
+ return ((props) => {
2383
+ const patched = normalizers.reduce(
2384
+ (acc, normalizer) => ({ ...acc, ...normalizer(acc) }),
2385
+ props
2386
+ );
2387
+ return fn ? fn(patched) : patched;
2388
+ });
2389
+ }
2390
+ function whenDefined(key, value) {
2391
+ return value === void 0 ? {} : { [key]: value };
2392
+ }
2393
+ function resolveFactoryOptions(options = {}) {
2394
+ const { styling, enforcement } = options;
2395
+ const composedNormalizeFn = composeNormalizers(enforcement?.props, options.normalize);
2396
+ const variantKeys = styling?.variants === void 0 ? EMPTY_VARIANT_KEYS : new Set(Object.keys(styling.variants));
2397
+ return Object.freeze({
2398
+ defaultTag: options.tag ?? "div",
2399
+ diagnostics: enforcement?.diagnostics ?? silentDiagnostics,
2400
+ variantKeys,
2401
+ ...whenDefined("displayName", options.name),
2402
+ ...whenDefined("defaultProps", options.defaults),
2403
+ ...whenDefined("baseClassName", styling?.base),
2404
+ ...whenDefined("tagMap", styling?.tags),
2405
+ ...whenDefined("recipeMap", styling?.presets),
2406
+ ...whenDefined("variants", styling?.variants),
2407
+ ...whenDefined("defaultVariants", styling?.defaults),
2408
+ ...whenDefined("compoundVariants", styling?.compounds),
2409
+ ...whenDefined("normalizeFn", composedNormalizeFn),
2410
+ ...whenDefined("ariaRules", enforcement?.aria),
2411
+ ...whenDefined("childRules", enforcement?.children),
2412
+ ...whenDefined("allowedAs", enforcement?.allowedAs),
2413
+ ...whenDefined("precomputedClasses", styling?.precomputedClasses)
2414
+ });
2415
+ }
2416
+
2417
+ // ../core/src/options/validate-factory-options.ts
2418
+ function validateFactoryOptions(resolved, diagnostics) {
2419
+ if (!diagnostics.active) return;
2420
+ const name = resolved.displayName ?? "Component";
2421
+ const { variants } = resolved;
2422
+ const checkSelection = (label2, selection) => {
2423
+ iterate.forEachEntry(selection, (dim, value) => {
2424
+ if (value === void 0 || value === null) return;
2425
+ if (!variants || !Object.hasOwn(variants, dim)) {
2426
+ diagnostics.error(ContractDiagnostics.unknownVariantDim(name, label2, dim));
2427
+ return;
2428
+ }
2429
+ const states = variants[dim];
2430
+ const stateKey = String(value);
2431
+ if (!Object.hasOwn(states, stateKey)) {
2432
+ diagnostics.error(
2433
+ ContractDiagnostics.unknownVariantValue(name, label2, dim, stateKey, Object.keys(states))
2434
+ );
2435
+ }
2436
+ });
2437
+ };
2438
+ const { recipeMap } = resolved;
2439
+ if (recipeMap) {
2440
+ iterate.forEachEntry(recipeMap, (recipeKey, selection) => {
2441
+ checkSelection(`preset "${recipeKey}"`, selection);
2442
+ });
2443
+ }
2444
+ if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
2445
+ }
2446
+
2447
+ // ../core/src/options/validate-render-props.ts
2448
+ function label(name) {
2449
+ return name ? `[${name}]` : "[createContractComponent]";
2450
+ }
2451
+ function validateRenderProps(diagnostics, options, props, recipeKey) {
2452
+ const { recipeMap, variants, displayName } = options;
2453
+ const tag = label(displayName);
2454
+ if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
2455
+ diagnostics.error(ContractDiagnostics.unknownRecipeKey(tag, recipeKey));
2456
+ }
2457
+ if (variants) {
2458
+ iterate.forEachKey(variants, (key) => {
2459
+ if (!Object.hasOwn(props, key)) return;
2460
+ const value = props[key];
2461
+ if (value === void 0 || value === null) return;
2462
+ const dim = variants[key];
2463
+ if (dim && !Object.hasOwn(dim, String(value))) {
2464
+ diagnostics.error(ContractDiagnostics.invalidVariantValue(tag, key, String(value)));
2465
+ }
2466
+ });
2467
+ }
2468
+ }
2469
+
2470
+ // ../core/src/factory/plugin-invariants.ts
2471
+ import { throwDiagnostics } from "./_shared/diagnostics.js";
2472
+
2473
+ // ../core/src/factory/plugin-diagnostics.ts
2474
+ import { DiagnosticCategory as DiagnosticCategory5, DiagnosticCode as DiagnosticCode5 } from "./_shared/diagnostics.js";
2475
+ var PluginDiagnostics = {
2476
+ invalidShape(received) {
2477
+ const got = received === null ? "null" : typeof received;
2478
+ return {
2479
+ code: DiagnosticCode5.PluginInvalidShape,
2480
+ category: DiagnosticCategory5.Internal,
2481
+ message: `[praxis-kit] Plugin factory must return an object with a 'pipeline' function. Got: ${got}.`
2482
+ };
2483
+ },
2484
+ pipelineReturnType(received) {
2485
+ const got = received === null ? "null" : Array.isArray(received) ? "array" : typeof received;
2486
+ return {
2487
+ code: DiagnosticCode5.PluginPipelineReturnType,
2488
+ category: DiagnosticCategory5.Internal,
2489
+ message: `[praxis-kit] Plugin pipeline must return a string. Got: ${got}.`
2490
+ };
2491
+ }
2492
+ };
2493
+
2494
+ // ../core/src/factory/plugin-invariants.ts
2495
+ function assertPluginShape(result) {
2496
+ if (result === null || typeof result !== "object")
2497
+ throwDiagnostics.error(PluginDiagnostics.invalidShape(result));
2498
+ const plugin = result;
2499
+ if (typeof plugin.pipeline !== "function")
2500
+ throwDiagnostics.error(PluginDiagnostics.invalidShape(result));
2501
+ }
2502
+ function guardPipeline(pipeline) {
2503
+ if (process.env.NODE_ENV === "production") return pipeline;
2504
+ return function guardedPipeline(tag, props, className, recipe) {
2505
+ const result = pipeline(tag, props, className, recipe);
2506
+ if (typeof result !== "string")
2507
+ throwDiagnostics.error(PluginDiagnostics.pipelineReturnType(result));
2508
+ return result;
2509
+ };
2510
+ }
2511
+
2512
+ // ../core/src/factory/create-polymorphic2.ts
2513
+ var createTagPipeline = (resolved) => makeResolveTag(resolved.defaultTag);
2514
+ var createPropsPipeline = (resolved) => (props) => mergeProps(resolved.defaultProps, props);
2515
+ var createHtmlPropNormalizersPipeline = () => getHtmlPropNormalizers;
2516
+ var createHtmlChildrenEvaluatorPipeline = () => getHtmlChildrenEvaluator;
2517
+ var createStylingClassPipeline = (resolved) => createClassPipeline(resolved);
2518
+ function resolveAriaRules(resolved) {
2519
+ return [.../* @__PURE__ */ new Set([...HTML_ARIA_RULES, ...resolved.ariaRules ?? []])];
2520
+ }
2521
+ var createAriaPipeline = (resolved) => {
2522
+ const rules = resolveAriaRules(resolved);
2523
+ const engine = new AriaPolicyEngine(resolved.diagnostics, rules.length ? { rules } : void 0);
2524
+ return (tag, props) => engine.validate(tag, props);
2525
+ };
2526
+ var memoizedTagPipeline = definePipeline(createTagPipeline);
2527
+ var memoizedPropsPipeline = definePipeline(createPropsPipeline);
2528
+ var memoizedHtmlPropNormalizersPipeline = definePipeline(createHtmlPropNormalizersPipeline);
2529
+ var memoizedHtmlChildrenEvaluatorPipeline = definePipeline(createHtmlChildrenEvaluatorPipeline);
2530
+ var memoizedClassPipeline = definePipeline(createStylingClassPipeline);
2531
+ var memoizedAriaPipeline = definePipeline(createAriaPipeline);
2532
+ function resolveAriaPassthrough(_tag, props) {
2533
+ return { props };
2534
+ }
2535
+ function resolveClassPlugin(factory, resolved, diagnostics) {
2536
+ if (!factory) return { pluginResult: void 0, classPipeline: memoizedClassPipeline(resolved) };
2537
+ const pluginResult = factory(resolved, diagnostics);
2538
+ assertPluginShape(pluginResult);
2539
+ return { pluginResult, classPipeline: guardPipeline(pluginResult.pipeline) };
2540
+ }
2541
+ function createPolymorphic2(options = {}) {
2542
+ const baseResolved = resolveFactoryOptions(options);
2543
+ const anyBaseResolved = baseResolved;
2544
+ const resolved = Object.freeze({
2545
+ ...baseResolved,
2546
+ htmlPropNormalizersFn: memoizedHtmlPropNormalizersPipeline(anyBaseResolved),
2547
+ htmlChildrenEvaluatorFn: memoizedHtmlChildrenEvaluatorPipeline(anyBaseResolved)
2548
+ });
2549
+ const anyResolved = resolved;
2550
+ if (process.env.NODE_ENV !== "production") {
2551
+ validateFactoryOptions(resolved, resolved.diagnostics);
2552
+ }
2553
+ const { pluginResult, classPipeline } = resolveClassPlugin(
2554
+ options.styling?.plugin,
2555
+ anyResolved,
2556
+ resolved.diagnostics
2557
+ );
2558
+ const resolveTag2 = memoizedTagPipeline(anyResolved);
2559
+ const resolveProps = memoizedPropsPipeline(anyResolved);
2560
+ const resolveAriaFn = options.enforcement !== void 0 ? memoizedAriaPipeline(anyResolved) : resolveAriaPassthrough;
2561
+ const methods = {
2562
+ resolveTag: resolveTag2,
2563
+ resolveProps,
2564
+ resolveClasses(tag, props, className, recipe) {
2565
+ if (process.env.NODE_ENV !== "production") {
2566
+ validateRenderProps(resolved.diagnostics, resolved, props, recipe);
2567
+ }
2568
+ return classPipeline(tag, props, className, recipe);
2569
+ },
2570
+ resolveAria(tag, props) {
2571
+ return resolveAriaFn(tag, props);
2240
2572
  }
2241
2573
  };
2574
+ const runtimeObject = pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
2575
+ return runtimeObject;
2242
2576
  }
2243
2577
 
2244
2578
  // ../core/src/resolver/resolver.ts
2579
+ import { silentDiagnostics as silentDiagnostics2 } from "./_shared/diagnostics.js";
2245
2580
  function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
2246
2581
  if (allowedAs.includes(tag)) return;
2247
2582
  if (!diagnostics) return;
@@ -2249,27 +2584,57 @@ function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
2249
2584
  diagnostics.error(ContractDiagnostics.allowedAsViolation(String(tag), allowedAs, component));
2250
2585
  }
2251
2586
 
2252
- // ../../lib/adapter-utils/src/apply-prop-normalizers.ts
2253
- function applyPropNormalizers(tag, props, additional) {
2254
- const normalizers = [...getHtmlPropNormalizers(tag) ?? [], ...additional ?? []];
2255
- if (normalizers.length === 0) return props;
2256
- return normalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), props);
2587
+ // ../../lib/adapter-utils/src/runtime/build-core-runtime.ts
2588
+ var EMPTY_SET = /* @__PURE__ */ new Set();
2589
+ function buildCoreRuntime(normalized) {
2590
+ const runtime = createPolymorphic2(normalized);
2591
+ const ownedKeys = "classPlugin" in runtime ? runtime.classPlugin.ownedKeys ?? EMPTY_SET : EMPTY_SET;
2592
+ return { runtime, ownedKeys };
2257
2593
  }
2258
2594
 
2259
- // ../../lib/adapter-utils/src/build-engines.ts
2595
+ // ../../lib/adapter-utils/src/runtime/build-engines.ts
2260
2596
  function buildEngines(diagnostics, childRules, context) {
2261
2597
  return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, diagnostics, context) } : {};
2262
2598
  }
2263
2599
 
2264
- // ../../lib/adapter-utils/src/resolve-adapter-common-options.ts
2265
- function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics) {
2600
+ // ../../lib/adapter-utils/src/runtime/resolve-adapter-common-options.ts
2601
+ import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics3 } from "./_shared/diagnostics.js";
2602
+ function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics2) {
2266
2603
  return {
2267
2604
  name: options.name ?? defaultName,
2268
2605
  diagnostics: options.enforcement?.diagnostics ?? defaultDiagnostics
2269
2606
  };
2270
2607
  }
2271
2608
 
2272
- // ../../lib/adapter-utils/src/slot-validator.ts
2609
+ // ../../lib/adapter-utils/src/invariant.ts
2610
+ function panic(message) {
2611
+ throw new Error(message);
2612
+ }
2613
+ function invariant(condition, message) {
2614
+ if (!condition) panic(message);
2615
+ }
2616
+
2617
+ // ../../lib/adapter-utils/src/props/apply-filter.ts
2618
+ function applyFilter(props, filterProps, variantKeys) {
2619
+ const out = {};
2620
+ iterate.forEachEntry(props, (k) => {
2621
+ if (!Object.hasOwn(props, k)) return;
2622
+ if (filterProps(k, variantKeys)) return;
2623
+ out[k] = props[k];
2624
+ });
2625
+ return out;
2626
+ }
2627
+
2628
+ // ../../lib/adapter-utils/src/props/compose-filter.ts
2629
+ function composeFilter(ownedKeys, filterProps) {
2630
+ const defaultFilter = (key, variantKeys) => variantKeys.has(key) || ownedKeys.has(key);
2631
+ if (!filterProps) {
2632
+ return defaultFilter;
2633
+ }
2634
+ return (key, variantKeys) => defaultFilter(key, variantKeys) || filterProps(key, variantKeys);
2635
+ }
2636
+
2637
+ // ../../lib/adapter-utils/src/slot/slot-validator.ts
2273
2638
  var SlotValidator = class extends InvariantBase {
2274
2639
  #name;
2275
2640
  #elementTerm;
@@ -2292,18 +2657,18 @@ var SlotValidator = class extends InvariantBase {
2292
2657
  };
2293
2658
 
2294
2659
  // ../../lib/adapter-utils/src/slot/policies.ts
2295
- import { clsx } from "clsx";
2660
+ import { clsx as clsx3 } from "clsx";
2296
2661
  function chainHandlers(childHandler, slotHandler) {
2297
2662
  return (...args) => {
2298
2663
  childHandler(...args);
2299
2664
  const event = args[0];
2300
- if (!(typeof event === "object" && event !== null && "defaultPrevented" in event && event.defaultPrevented)) {
2665
+ if (!(isObject(event) && "defaultPrevented" in event && event.defaultPrevented)) {
2301
2666
  slotHandler(...args);
2302
2667
  }
2303
2668
  };
2304
2669
  }
2305
2670
  function mergeClassNames(slot, child) {
2306
- return clsx(slot, child);
2671
+ return clsx3(slot, child);
2307
2672
  }
2308
2673
  function mergeStyles(slot, child) {
2309
2674
  if (!isPlainObject(slot) || !isPlainObject(child)) return child;
@@ -2335,209 +2700,6 @@ function applyMergePolicy(key, slotVal, childVal) {
2335
2700
  return policyHandlers[classifyProp(key, slotVal, childVal)](slotVal, childVal);
2336
2701
  }
2337
2702
 
2338
- // ../../lib/adapter-utils/src/build-definition.ts
2339
- function buildDefinition(name, tag) {
2340
- return {
2341
- identity: {
2342
- id: name,
2343
- name,
2344
- tag
2345
- },
2346
- capabilities: {},
2347
- metadata: {},
2348
- diagnostics: []
2349
- };
2350
- }
2351
-
2352
- // ../../lib/adapter-utils/src/build-variant-config.ts
2353
- function flattenClassName(cls) {
2354
- return Array.isArray(cls) ? cls.join(" ") : cls;
2355
- }
2356
- function mapVariantRecord(source, mapper) {
2357
- return iterate.mapValues(
2358
- source,
2359
- (inner) => iterate.mapValues(inner, mapper)
2360
- );
2361
- }
2362
- function buildVariantConfig(variants, presets, defaults, compounds) {
2363
- return {
2364
- variants: mapVariantRecord(variants ?? {}, flattenClassName),
2365
- ...presets !== void 0 && Object.keys(presets).length > 0 && { presets },
2366
- ...defaults !== void 0 && Object.keys(defaults).length > 0 && { defaults },
2367
- ...compounds !== void 0 && compounds.length > 0 && {
2368
- compounds
2369
- }
2370
- };
2371
- }
2372
-
2373
- // ../../runtime/core/src/apply-attributes.ts
2374
- function applyAttributes(nodeId, incoming, decoration, removedKeys) {
2375
- const existing = decoration[nodeId] ?? {};
2376
- const next = { ...existing.attributes };
2377
- if (removedKeys !== void 0) {
2378
- iterate.forEachSet(removedKeys, (key) => {
2379
- delete next[key];
2380
- });
2381
- }
2382
- Object.assign(next, incoming);
2383
- const { attributes: _dropped, ...rest } = existing;
2384
- const nextDecoration = Object.keys(next).length > 0 ? { ...rest, attributes: next } : rest;
2385
- return { ...decoration, [nodeId]: nextDecoration };
2386
- }
2387
-
2388
- // ../../runtime/core/src/get-active-props.ts
2389
- function getActiveProps(nodeId, decoration) {
2390
- const dec = decoration[nodeId];
2391
- return { ...dec?.attributes ?? {}, ...dec?.variants ?? {} };
2392
- }
2393
-
2394
- // ../../runtime/core/src/render-component.ts
2395
- function renderComponent(definition, tree, render, backend) {
2396
- return backend.render({ definition, tree, render });
2397
- }
2398
-
2399
- // ../../runtime/core/src/build-tree-context.ts
2400
- function buildNode(input, slotAssignments, seenIds, diagnostics) {
2401
- if (seenIds.has(input.id)) {
2402
- diagnostics.push({
2403
- code: "duplicate-node-id",
2404
- message: `Duplicate node id "${input.id}"`,
2405
- severity: "error"
2406
- });
2407
- } else {
2408
- seenIds.add(input.id);
2409
- }
2410
- if (input.slot !== void 0) {
2411
- slotAssignments.set(input.id, input.slot);
2412
- }
2413
- const children = Object.freeze(
2414
- (input.children ?? []).map((child) => buildNode(child, slotAssignments, seenIds, diagnostics))
2415
- );
2416
- if (input.kind === "native") {
2417
- return Object.freeze({ kind: "native", id: input.id, tag: input.tag, children });
2418
- }
2419
- return Object.freeze({ kind: "component", id: input.id, children });
2420
- }
2421
- function buildTreeContext(root) {
2422
- const slotAssignments = /* @__PURE__ */ new Map();
2423
- const diagnostics = [];
2424
- const rootNode = buildNode(root, slotAssignments, /* @__PURE__ */ new Set(), diagnostics);
2425
- return Object.freeze({ root: rootNode, slotAssignments, diagnostics });
2426
- }
2427
-
2428
- // ../../runtime/core/src/build-render-context.ts
2429
- function buildRenderContext(decoration = {}) {
2430
- return { decoration: new Map(Object.entries(decoration)) };
2431
- }
2432
-
2433
- // ../../lib/adapter-utils/src/resolve-compounds.ts
2434
- function matchesCompound(active, compound) {
2435
- const { class: _, ...conditions } = compound;
2436
- return Object.entries(conditions).every(([key, expected]) => {
2437
- const actual = active[key];
2438
- return Array.isArray(expected) ? expected.includes(actual) : actual === expected;
2439
- });
2440
- }
2441
- function resolveCompounds(active, compounds) {
2442
- if (!compounds?.length) return [];
2443
- const out = [];
2444
- iterate.forEach(compounds, (compound) => {
2445
- if (matchesCompound(active, compound)) {
2446
- out.push(flattenClassName(compound.class));
2447
- }
2448
- });
2449
- return out;
2450
- }
2451
-
2452
- // ../../lib/adapter-utils/src/resolve-classes.ts
2453
- function resolveClasses(decoration, variantConfig, variantDefaults, recipe, compounds, variantLookup) {
2454
- const active = getActiveProps("root", decoration);
2455
- if (variantLookup !== void 0 && recipe === void 0) {
2456
- const activeVariants = {};
2457
- iterate.forEachKey(variantConfig.variants, (key) => {
2458
- const value = active[key];
2459
- if (typeof value === "string") activeVariants[key] = value;
2460
- });
2461
- const lookupKey = buildPrecomputedKey(activeVariants);
2462
- const precomputedValue = variantLookup[lookupKey];
2463
- if (precomputedValue !== void 0) {
2464
- return {
2465
- variantClasses: precomputedValue !== "" ? [precomputedValue] : [],
2466
- compoundClasses: []
2467
- };
2468
- }
2469
- }
2470
- const passInput = recipe !== void 0 ? { ...active, preset: recipe } : active;
2471
- const { context } = createVariantPass(passInput, variantConfig).execute({ classes: [] });
2472
- const variantClasses = context.classes;
2473
- const presetOverrides = recipe !== void 0 ? variantConfig.presets?.[recipe] ?? {} : {};
2474
- const resolvedValues = {
2475
- ...variantDefaults,
2476
- ...presetOverrides,
2477
- ...active
2478
- };
2479
- const compoundClasses = resolveCompounds(resolvedValues, compounds);
2480
- return { variantClasses, compoundClasses };
2481
- }
2482
-
2483
- // ../../lib/adapter-utils/src/build-pipeline.ts
2484
- function buildStylePipeline(variants, presets, defaults, compounds, variantLookup) {
2485
- if (variants === void 0 && compounds === void 0 && presets === void 0 && variantLookup === void 0) {
2486
- return void 0;
2487
- }
2488
- const variantConfig = buildVariantConfig(variants, presets, defaults, compounds);
2489
- return {
2490
- execute(decoration, recipe) {
2491
- return resolveClasses(decoration, variantConfig, defaults, recipe, compounds, variantLookup);
2492
- }
2493
- };
2494
- }
2495
-
2496
- // ../../lib/adapter-utils/src/join-classes.ts
2497
- function joinClasses(...classes) {
2498
- return classes.filter(Boolean).join(" ");
2499
- }
2500
-
2501
- // ../../lib/adapter-utils/src/decoration-utils.ts
2502
- function withAttributes(dec, attributes) {
2503
- const { attributes: _a, ...rest } = dec;
2504
- return attributes !== void 0 ? { ...rest, attributes } : rest;
2505
- }
2506
-
2507
- // ../../lib/adapter-utils/src/apply-aria.ts
2508
- function applyAria(decoration, tag, ariaEngine) {
2509
- if (ariaEngine === void 0) return decoration;
2510
- const dec = decoration["root"];
2511
- if (dec?.attributes === void 0) return decoration;
2512
- const result = ariaEngine.validate(tag, dec.attributes);
2513
- const cleaned = result.props;
2514
- return {
2515
- ...decoration,
2516
- root: withAttributes(dec, Object.keys(cleaned).length > 0 ? cleaned : void 0)
2517
- };
2518
- }
2519
-
2520
- // ../../lib/adapter-utils/src/apply-filter-props.ts
2521
- function applyFilterProps(decoration, filterFn, variantKeys) {
2522
- if (filterFn === void 0) return decoration;
2523
- const dec = decoration["root"];
2524
- if (dec?.attributes === void 0) return decoration;
2525
- const kept = Object.fromEntries(
2526
- Object.entries(dec.attributes).filter(([k]) => !filterFn(k, variantKeys))
2527
- );
2528
- return {
2529
- ...decoration,
2530
- root: withAttributes(dec, Object.keys(kept).length > 0 ? kept : void 0)
2531
- };
2532
- }
2533
-
2534
- // ../../lib/adapter-utils/src/apply-ref.ts
2535
- function applyRef(decoration, ref) {
2536
- if (ref == null) return decoration;
2537
- const existing = decoration["root"] ?? {};
2538
- return { ...decoration, root: { ...existing, ref } };
2539
- }
2540
-
2541
2703
  // ../../adapters/react/src/shared/merge-refs.ts
2542
2704
  function mergeRefs(...refs) {
2543
2705
  return mergeRefsCore(...refs);
@@ -2550,25 +2712,52 @@ function Slottable({ children }) {
2550
2712
  return /* @__PURE__ */ jsx(Fragment, { children });
2551
2713
  }
2552
2714
 
2715
+ // ../../adapters/react/src/shared/slot/predicates.ts
2716
+ import { isValidElement } from "react";
2717
+ function isSlottableElement(value) {
2718
+ return isValidElement(value) && value.type === Slottable;
2719
+ }
2720
+
2721
+ // ../../adapters/react/src/shared/slot/compose-refs.ts
2722
+ function isReactWarningGetter(getter) {
2723
+ return isFunction(getter) && "isReactWarning" in getter;
2724
+ }
2725
+ function hasWarningGetter(obj, key) {
2726
+ return isPlainObject(obj) && isReactWarningGetter(Object.getOwnPropertyDescriptor(obj, key)?.get);
2727
+ }
2728
+ function getElementRef(element) {
2729
+ const el = element;
2730
+ return isPlainObject(el) ? el.ref ?? null : null;
2731
+ }
2732
+ function getPropsRef(element) {
2733
+ const props = element.props;
2734
+ return isPlainObject(props) ? props.ref ?? null : null;
2735
+ }
2736
+
2553
2737
  // ../../adapters/react/src/shared/slot/clone.ts
2554
2738
  import { cloneElement } from "react";
2555
2739
  function cloneWithProps(child, props, ref) {
2556
2740
  return cloneElement(child, ref !== null ? { ...props, ref } : props);
2557
2741
  }
2558
2742
 
2743
+ // ../../adapters/react/src/shared/slot/make-clone-slot-child.ts
2744
+ import { Fragment as Fragment2 } from "react";
2745
+ function makeCloneSlotChild(getChildRef) {
2746
+ return function cloneSlotChild({ child, slotProps, ref }) {
2747
+ const childProps = child.props;
2748
+ const isFragment = child.type === Fragment2;
2749
+ const childRef = isFragment ? null : getChildRef(child);
2750
+ const mergedRef = isFragment ? null : mergeRefs(ref, childRef);
2751
+ const merged = mergeSlotProps(slotProps, childProps);
2752
+ return cloneWithProps(child, merged, mergedRef);
2753
+ };
2754
+ }
2755
+
2559
2756
  // ../../adapters/react/src/shared/slot/applySlot.ts
2560
2757
  import { isValidElement as isValidElement3 } from "react";
2561
2758
 
2562
2759
  // ../../adapters/react/src/shared/slot/extractSlottable.ts
2563
- import { createElement, Fragment as Fragment2, isValidElement as isValidElement2 } from "react";
2564
-
2565
- // ../../adapters/react/src/shared/slot/predicates.ts
2566
- import { isValidElement } from "react";
2567
- function isSlottableElement(value) {
2568
- return isValidElement(value) && value.type === Slottable;
2569
- }
2570
-
2571
- // ../../adapters/react/src/shared/slot/extractSlottable.ts
2760
+ import { createElement, Fragment as Fragment3, isValidElement as isValidElement2 } from "react";
2572
2761
  function extractSlottable(children) {
2573
2762
  const childrenArray = Array.isArray(children) ? children : [children];
2574
2763
  const slottables = childrenArray.filter(isSlottableElement);
@@ -2588,14 +2777,14 @@ function extractSlottable(children) {
2588
2777
  "Slottable expects exactly one React element child, received text content"
2589
2778
  );
2590
2779
  invariant(isValidElement2(child), "Slottable expects exactly one React element child");
2591
- invariant(child.type !== Fragment2, "Slottable child cannot be a Fragment");
2780
+ invariant(child.type !== Fragment3, "Slottable child cannot be a Fragment");
2592
2781
  const index = childrenArray.indexOf(slottable);
2593
2782
  return {
2594
2783
  child,
2595
2784
  // Fragment wrapper: Slot owns no DOM node; ref composition happens only on the merge target.
2596
2785
  rebuild(merged) {
2597
2786
  const out = childrenArray.map((node, i) => i === index ? merged : node);
2598
- return createElement(Fragment2, null, ...out);
2787
+ return createElement(Fragment3, null, ...out);
2599
2788
  }
2600
2789
  };
2601
2790
  }
@@ -2611,16 +2800,6 @@ function applySlot(children, slotProps, ref, cloneSlotChild) {
2611
2800
  return cloneSlotChild({ child: children, slotProps, ref });
2612
2801
  }
2613
2802
 
2614
- // ../../adapters/react/src/shared/slot/make-render-as-child.ts
2615
- import { isValidElement as isValidElement4 } from "react";
2616
- function makeRenderAsChild(cloneSlotChild) {
2617
- return function renderAsChild(children, className, ref) {
2618
- if (!isValidElement4(children)) throw new Error("asChild requires a React element child");
2619
- const slotProps = className ? { className } : {};
2620
- return cloneSlotChild({ child: children, slotProps, ref: ref ?? null });
2621
- };
2622
- }
2623
-
2624
2803
  // ../../adapters/react/src/shared/apply-display-name.ts
2625
2804
  function applyDisplayName(component, name) {
2626
2805
  const displayName = name ?? "PolymorphicComponent";
@@ -2630,148 +2809,170 @@ function applyDisplayName(component, name) {
2630
2809
  });
2631
2810
  }
2632
2811
 
2633
- // ../../adapters/react/src/backend/extract-decoration.ts
2634
- function isStyleValue(v) {
2635
- return isString(v) || isNumber(v);
2636
- }
2637
- function isAttributeValue(v) {
2638
- return isString(v) || isNumber(v) || typeof v === "boolean";
2812
+ // ../../adapters/react/src/shared/render.ts
2813
+ import { createElement as createElement2 } from "react";
2814
+ import { jsx as jsx2 } from "react/jsx-runtime";
2815
+ function buildRenderState(tag, directives, props, className, children) {
2816
+ const state = { tag, directives, props, className };
2817
+ if (children !== void 0) state.children = children;
2818
+ return state;
2639
2819
  }
2640
- function assignIfNotEmpty(target, key, value) {
2641
- if (Object.keys(value).length > 0) {
2642
- target[key] = value;
2820
+ function prepareRenderState(runtime, props, filterProps) {
2821
+ const { as, asChild, render: _render, children, className, recipe, ...rest } = props;
2822
+ const tag = runtime.resolveTag(as);
2823
+ if (runtime.options.allowedAs !== void 0 && as !== void 0) {
2824
+ enforceAllowedAs(
2825
+ tag,
2826
+ runtime.options.allowedAs,
2827
+ runtime.options.diagnostics,
2828
+ runtime.options.displayName
2829
+ );
2643
2830
  }
2831
+ const mergedProps = runtime.resolveProps(rest);
2832
+ const htmlNormalizers = runtime.options.htmlPropNormalizersFn?.(tag);
2833
+ const baseProps = htmlNormalizers?.length ? htmlNormalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), mergedProps) : mergedProps;
2834
+ const normalizedProps = runtime.options.normalizeFn ? runtime.options.normalizeFn(baseProps) : baseProps;
2835
+ const resolvedClass = runtime.resolveClasses(tag, normalizedProps, className, recipe);
2836
+ const filteredProps = applyFilter(normalizedProps, filterProps, runtime.options.variantKeys);
2837
+ const directives = {
2838
+ ...as !== void 0 && { as },
2839
+ ...asChild !== void 0 && { asChild }
2840
+ };
2841
+ return buildRenderState(tag, directives, filteredProps, resolvedClass, children);
2644
2842
  }
2645
- function extractStyles(value, styles) {
2646
- if (!isObject(value)) return false;
2647
- iterate.forEachEntry(value, (k, v) => {
2648
- if (isStyleValue(v)) {
2649
- styles[k] = v;
2650
- }
2651
- });
2652
- return true;
2843
+ function warnDiscardedChildren(originalChildren, normalizedChildren, validator) {
2844
+ if (!Array.isArray(originalChildren)) return;
2845
+ const discarded = originalChildren.length - normalizedChildren.length;
2846
+ if (discarded > 0) validator.warnDiscardedChildren(discarded);
2847
+ }
2848
+ function isSingleElementArray(arr) {
2849
+ return arr.length === 1;
2653
2850
  }
2654
- function extractListener(key, value, listeners) {
2655
- if (!key.startsWith("on") || !isFunction(value)) {
2851
+ function resolveSlotChildren(children, normalized, validator) {
2852
+ warnDiscardedChildren(children, normalized, validator);
2853
+ if (isSingleElementArray(normalized)) {
2854
+ return normalized[0];
2855
+ }
2856
+ if (normalized.length > 1 && normalized.some(isSlottableElement)) {
2857
+ return normalized;
2858
+ }
2859
+ validator.assertSingleChild(normalized.length);
2860
+ return null;
2861
+ }
2862
+ function validateSlotDirectives(directives, validator) {
2863
+ const { as, asChild } = directives;
2864
+ if (!asChild) return false;
2865
+ if (as !== void 0) {
2866
+ validator.assertExclusive();
2656
2867
  return false;
2657
2868
  }
2658
- listeners[key] = value;
2659
2869
  return true;
2660
2870
  }
2661
- function extractAttributeOrVariant(key, value, attributes, variants, variantKeys) {
2662
- if (variantKeys?.has(key)) {
2663
- variants[key] = value;
2664
- } else {
2665
- attributes[key] = value;
2666
- }
2667
- }
2668
- function extractDecoration(props, variantKeys) {
2669
- const attributes = {};
2670
- const styles = {};
2671
- const listeners = {};
2672
- const variants = {};
2673
- const dec = {};
2674
- iterate.forEachEntry(props, (key, value) => {
2675
- if (key === "children" || key === "slot" || key === "ref") return;
2676
- if (key === "style" && extractStyles(value, styles)) return;
2677
- if (extractListener(key, value, listeners)) return;
2678
- if (isAttributeValue(value)) {
2679
- extractAttributeOrVariant(key, value, attributes, variants, variantKeys);
2680
- }
2871
+ function resolveSlotRender(state, getNormalized, validator) {
2872
+ if (!validateSlotDirectives(state.directives, validator)) return null;
2873
+ const child = resolveSlotChildren(state.children, getNormalized(), validator);
2874
+ if (child === null) return null;
2875
+ return { child };
2876
+ }
2877
+ function renderResolvedSlot(slotComponent, state, resolved, ref) {
2878
+ return jsx2(slotComponent, {
2879
+ ...state.props,
2880
+ className: state.className,
2881
+ ref,
2882
+ children: resolved.child
2681
2883
  });
2682
- assignIfNotEmpty(dec, "attributes", attributes);
2683
- assignIfNotEmpty(dec, "styles", styles);
2684
- assignIfNotEmpty(dec, "listeners", listeners);
2685
- assignIfNotEmpty(dec, "variants", variants);
2686
- const ref = props.ref;
2687
- if (ref !== void 0) {
2688
- dec.ref = ref;
2689
- }
2690
- return dec;
2691
2884
  }
2692
-
2693
- // ../../adapters/react/src/current/helpers/render-normally.ts
2694
- import { cloneElement as cloneElement2 } from "react";
2695
-
2696
- // ../../adapters/react/src/backend/react-backend.ts
2697
- import React from "react";
2698
-
2699
- // ../../adapters/react/src/backend/build-props.ts
2700
- function buildPropsFromDecoration(id, decoration) {
2885
+ function tryRenderAsChild(state, ref, slotComponent, getNormalized, validator) {
2886
+ const resolved = resolveSlotRender(state, getNormalized, validator);
2887
+ if (resolved === null) return null;
2888
+ return renderResolvedSlot(slotComponent, state, resolved, ref);
2889
+ }
2890
+ function buildElementProps(props, className, ref, children) {
2891
+ const { role, ...rest } = props;
2701
2892
  return {
2702
- key: id,
2703
- ...decoration?.attributes,
2704
- ...decoration?.styles !== void 0 ? { style: decoration.styles } : {},
2705
- ...decoration?.listeners,
2706
- ...decoration?.ref !== void 0 ? { ref: decoration.ref } : {}
2893
+ ...rest,
2894
+ className,
2895
+ ref,
2896
+ ...children !== void 0 && { children },
2897
+ ...isKnownAriaRole(role) && { role }
2707
2898
  };
2708
2899
  }
2709
-
2710
- // ../../adapters/react/src/backend/react-backend.ts
2711
- function renderNode(node, render) {
2712
- const children = node.children.map((child) => renderNode(child, render));
2713
- if (node.kind === "component") {
2714
- return React.createElement(React.Fragment, { key: node.id }, ...children);
2715
- }
2716
- const decoration = render.decoration.get(node.id);
2717
- const props = buildPropsFromDecoration(node.id, decoration);
2718
- return React.createElement(node.tag, props, ...children);
2719
- }
2720
- var reactBackend = {
2721
- render(context) {
2722
- return renderNode(context.tree.root, context.render);
2723
- }
2724
- };
2725
-
2726
- // ../../adapters/react/src/current/helpers/render-normally.ts
2727
- function renderNormally(definition, tag, decoration, children) {
2728
- const treeCtx = buildTreeContext({ kind: "native", tag, id: "root", children: [] });
2729
- const rendered = renderComponent(
2730
- definition,
2731
- treeCtx,
2732
- buildRenderContext(decoration),
2733
- reactBackend
2900
+ function renderIntrinsic(state, ref, runtime) {
2901
+ const elementProps = buildElementProps(state.props, state.className, ref, state.children);
2902
+ const domProps = typeof state.tag === "string" ? runtime.resolveAria(state.tag, elementProps).props : elementProps;
2903
+ return createElement2(state.tag, domProps);
2904
+ }
2905
+ function render({
2906
+ runtime,
2907
+ props,
2908
+ ref,
2909
+ slotComponent,
2910
+ normalizeChildren,
2911
+ filterProps,
2912
+ slotValidator,
2913
+ childrenEvaluator
2914
+ }) {
2915
+ const state = prepareRenderState(runtime, props, filterProps);
2916
+ let cached;
2917
+ const getNormalizedChildren = () => cached ??= normalizeChildren(state.children);
2918
+ if (process.env.NODE_ENV !== "production") {
2919
+ childrenEvaluator?.evaluate(getNormalizedChildren());
2920
+ runtime.options.htmlChildrenEvaluatorFn?.(state.tag)?.evaluate(getNormalizedChildren());
2921
+ }
2922
+ if (typeof props.render === "function") {
2923
+ return props.render({ ...state.props, className: state.className, ref });
2924
+ }
2925
+ const slotResult = tryRenderAsChild(
2926
+ state,
2927
+ ref,
2928
+ slotComponent,
2929
+ getNormalizedChildren,
2930
+ slotValidator
2734
2931
  );
2735
- return children === void 0 ? rendered : cloneElement2(rendered, {}, children);
2932
+ return slotResult ?? renderIntrinsic(state, ref, runtime);
2736
2933
  }
2737
2934
 
2738
- // ../../adapters/react/src/current/helpers/render-with-callback.ts
2739
- function renderWithCallback(render, domProps, className, ref) {
2740
- const props = { ...domProps };
2741
- if (className) props.className = className;
2742
- if (ref !== void 0) props.ref = ref;
2743
- return render(props);
2935
+ // ../../adapters/react/src/shared/build-runtime.ts
2936
+ function normalizeOptions(options, defaultSlotComponent) {
2937
+ return {
2938
+ ...options,
2939
+ ...resolveAdapterCommonOptions(options),
2940
+ slotComponent: options.slotComponent ?? defaultSlotComponent
2941
+ };
2942
+ }
2943
+ function buildRuntime(options, defaultSlotComponent, normalizeChildren) {
2944
+ const normalized = normalizeOptions(options, defaultSlotComponent);
2945
+ const { runtime, ownedKeys } = buildCoreRuntime(normalized);
2946
+ const { childrenEvaluator } = buildEngines(
2947
+ normalized.diagnostics,
2948
+ normalized.enforcement?.children,
2949
+ normalized.name
2950
+ );
2951
+ const filterProps = composeFilter(ownedKeys, normalized.filterProps);
2952
+ const slotValidator = new SlotValidator(normalized.name, normalized.diagnostics, "React element");
2953
+ return {
2954
+ runtime,
2955
+ filterProps,
2956
+ slotValidator,
2957
+ slotComponent: normalized.slotComponent,
2958
+ normalizeChildren,
2959
+ ...childrenEvaluator !== void 0 && { childrenEvaluator }
2960
+ };
2744
2961
  }
2745
2962
 
2746
2963
  export {
2747
- isFunction,
2748
- isPlainObject,
2964
+ defineContractComponent,
2965
+ isString,
2749
2966
  SLOT_NAME,
2750
2967
  COMPONENT_DEFAULT_TAG,
2751
- AriaPolicyEngine,
2752
- getHtmlChildrenEvaluator,
2753
- enforceAllowedAs,
2754
- applyPropNormalizers,
2755
- defineContractComponent,
2756
- buildEngines,
2757
- resolveAdapterCommonOptions,
2758
- SlotValidator,
2759
- mergeSlotProps,
2760
- buildDefinition,
2761
- flattenClassName,
2762
- applyAttributes,
2763
- buildStylePipeline,
2764
- joinClasses,
2765
- applyAria,
2766
- applyFilterProps,
2767
- applyRef,
2768
2968
  mergeRefs,
2769
2969
  applyDisplayName,
2770
- cloneWithProps,
2771
2970
  Slottable,
2971
+ hasWarningGetter,
2972
+ getElementRef,
2973
+ getPropsRef,
2974
+ makeCloneSlotChild,
2772
2975
  applySlot,
2773
- makeRenderAsChild,
2774
- extractDecoration,
2775
- renderNormally,
2776
- renderWithCallback
2976
+ render,
2977
+ buildRuntime
2777
2978
  };