clava 0.6.3 → 0.7.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.
package/dist/index.js CHANGED
@@ -256,6 +256,9 @@ function formatCreationStack(frame) {
256
256
  }
257
257
  function isInternalCreationFrame(line) {
258
258
  if (line.includes("captureCreationFrame")) return true;
259
+ if (line.startsWith("at buildRecipe ")) return true;
260
+ if (line.startsWith("at buildRecipe(")) return true;
261
+ if (line.startsWith("buildRecipe@")) return true;
259
262
  if (line.startsWith("at cv ")) return true;
260
263
  if (line.startsWith("at cv(")) return true;
261
264
  if (line.startsWith("cv@")) return true;
@@ -307,7 +310,7 @@ function warnRefineLimit({ creationFrame, unstableChanges }) {
307
310
  }
308
311
  if (creationFrame) {
309
312
  const creationStack = formatCreationStack(creationFrame);
310
- if (creationStack) message += `\nComponent created at:\n${creationStack}`;
313
+ if (creationStack) message += `\nRecipe created at:\n${creationStack}`;
311
314
  }
312
315
  console.warn(message);
313
316
  }
@@ -315,6 +318,32 @@ function warnRefineLimit({ creationFrame, unstableChanges }) {
315
318
  //#region src/index.ts
316
319
  const META_KEY = "__meta";
317
320
  const EMPTY_DEFAULTS = {};
321
+ function deduplicateExtensions(extensions, seen = /* @__PURE__ */ new Set()) {
322
+ if (extensions.length === 0) return extensions;
323
+ const result = [];
324
+ let changed = false;
325
+ for (const meta of extensions) {
326
+ const identity = getOwn(meta, "identity") ?? meta;
327
+ if (seen.has(identity)) {
328
+ changed = true;
329
+ continue;
330
+ }
331
+ seen.add(identity);
332
+ const inheritedExtensions = getOwn(meta, "extends");
333
+ const rebuild = getOwn(meta, "rebuild");
334
+ if (!inheritedExtensions || !rebuild) {
335
+ result.push(meta);
336
+ continue;
337
+ }
338
+ const children = deduplicateExtensions(inheritedExtensions, seen);
339
+ if (children === inheritedExtensions) result.push(meta);
340
+ else {
341
+ result.push(rebuild(children));
342
+ changed = true;
343
+ }
344
+ }
345
+ return changed ? result : extensions;
346
+ }
318
347
  const MAX_REFINE_RUNS = 50;
319
348
  function areVariantsEqual(a, b) {
320
349
  let ownKeyDifference = 0;
@@ -373,7 +402,7 @@ function getVariantValueKey(value) {
373
402
  if (typeof value === "boolean") return String(value);
374
403
  }
375
404
  const EMPTY_KEYS = [];
376
- function isComponentKeySource(source) {
405
+ function isRecipeKeySource(source) {
377
406
  if (!source) return false;
378
407
  if (typeof source !== "object" && typeof source !== "function") return false;
379
408
  const typed = source;
@@ -381,10 +410,10 @@ function isComponentKeySource(source) {
381
410
  if (!Array.isArray(typed.propKeys)) return false;
382
411
  return Array.isArray(typed.variantKeys);
383
412
  }
384
- function splitPropsImpl(selfKeys, selfIsComponent, props, sources) {
413
+ function splitPropsImpl(selfKeys, selfIsRecipe, props, sources) {
385
414
  const sourcesLength = sources.length;
386
415
  const results = [];
387
- let stylingClaimed = selfIsComponent;
416
+ let stylingClaimed = selfIsRecipe;
388
417
  const selfResult = {};
389
418
  const selfKeysLength = selfKeys.length;
390
419
  for (let i = 0; i < selfKeysLength; i++) {
@@ -396,11 +425,11 @@ function splitPropsImpl(selfKeys, selfIsComponent, props, sources) {
396
425
  for (let s = 0; s < sourcesLength; s++) {
397
426
  const source = sources[s];
398
427
  const sourceResult = {};
399
- let sourceIsComponent = false;
428
+ let sourceIsRecipe = false;
400
429
  let effectiveKeys;
401
430
  if (Array.isArray(source)) effectiveKeys = source;
402
- else if (isComponentKeySource(source)) {
403
- sourceIsComponent = true;
431
+ else if (isRecipeKeySource(source)) {
432
+ sourceIsRecipe = true;
404
433
  effectiveKeys = stylingClaimed ? source.variantKeys : source.propKeys;
405
434
  } else effectiveKeys = EMPTY_KEYS;
406
435
  const effectiveKeysLength = effectiveKeys.length;
@@ -410,7 +439,7 @@ function splitPropsImpl(selfKeys, selfIsComponent, props, sources) {
410
439
  }
411
440
  results.push(sourceResult);
412
441
  effectiveKeyArrays.push(effectiveKeys);
413
- if (sourceIsComponent && !stylingClaimed) stylingClaimed = true;
442
+ if (sourceIsRecipe && !stylingClaimed) stylingClaimed = true;
414
443
  }
415
444
  const rest = {};
416
445
  const propKeys = Object.keys(props);
@@ -432,7 +461,7 @@ function splitPropsImpl(selfKeys, selfIsComponent, props, sources) {
432
461
  }
433
462
  const splitProps = ((props, source1, ...sources) => {
434
463
  if (Array.isArray(source1)) return splitPropsImpl(source1, false, props, sources);
435
- if (isComponentKeySource(source1)) return splitPropsImpl(source1.propKeys, true, props, sources);
464
+ if (isRecipeKeySource(source1)) return splitPropsImpl(source1.propKeys, true, props, sources);
436
465
  return splitPropsImpl(EMPTY_KEYS, false, props, sources);
437
466
  });
438
467
  function buildPrebuiltVariant(variantDef) {
@@ -462,21 +491,17 @@ function buildPrebuiltVariant(variantDef) {
462
491
  function create(params = {}) {
463
492
  const transformClass = getOwn(params, "transformClass") ?? identityClass;
464
493
  const cx = (...classes) => transformClass(clsx(classes));
465
- const cv = (config = {}) => {
494
+ const buildRecipe = (config = {}) => {
466
495
  const extend = getOwn(config, "extend");
467
- const hasExtend = !!extend && extend.length > 0;
468
496
  const variants = getOwn(config, "variants");
469
497
  const refine = getOwn(config, "refine");
470
498
  const baseStyle = getOwn(config, "style");
471
499
  const hasBaseStyle = !!baseStyle;
472
- const baseClass = getOwn(config, "class");
500
+ const baseClassValue = getOwn(config, "class");
473
501
  const variantKeySet = /* @__PURE__ */ new Set();
474
- const staticDefaults = {};
475
- const extMetas = [];
476
- const extBaseClassesArr = [];
477
- const extIsolated = [];
478
- let hasIsolatedExt = false;
479
- if (hasExtend) for (const ext of extend) {
502
+ const inheritedComputedDefaultKeys = /* @__PURE__ */ new Set();
503
+ const originalExtMetas = [];
504
+ if (extend) for (const ext of extend) {
480
505
  const extKeys = ext.variantKeys;
481
506
  for (let i = 0; i < extKeys.length; i++) {
482
507
  const key = extKeys[i];
@@ -485,16 +510,11 @@ function create(params = {}) {
485
510
  }
486
511
  const meta = ext[META_KEY];
487
512
  if (!meta) continue;
488
- extMetas.push(meta);
489
- Object.assign(staticDefaults, meta.staticDefaults);
490
- const isolated = meta.transformClass !== transformClass;
491
- extIsolated.push(isolated);
492
- if (isolated) {
493
- hasIsolatedExt = true;
494
- extBaseClassesArr.push(meta.transformClass(meta.baseClass));
495
- } else extBaseClassesArr.push(meta.baseClass);
513
+ originalExtMetas.push(meta);
514
+ for (const key of meta.computedDefaultKeys) inheritedComputedDefaultKeys.add(key);
496
515
  }
497
- const extCount = extMetas.length;
516
+ const initialExtensions = originalExtMetas.length > 1 ? deduplicateExtensions(originalExtMetas) : originalExtMetas;
517
+ const ownStaticDefaults = {};
498
518
  const disabledVariantKeys = /* @__PURE__ */ new Set();
499
519
  let disabledValuesBuilder = null;
500
520
  const variantEntryNames = [];
@@ -522,7 +542,7 @@ function create(params = {}) {
522
542
  disabledValuesBuilder ??= {};
523
543
  disabledValuesBuilder[name] = prebuiltVariant.disabledValues;
524
544
  }
525
- if (prebuiltVariant.values?.has("false") && !hasOwn(staticDefaults, name)) staticDefaults[name] = false;
545
+ if (prebuiltVariant.values?.has("false") && !initialExtensions.some((meta) => hasOwn(meta.staticDefaults, name))) ownStaticDefaults[name] = false;
526
546
  }
527
547
  const variantKeys = Array.from(variantKeySet);
528
548
  const variantKeysLength = variantKeys.length;
@@ -546,557 +566,578 @@ function create(params = {}) {
546
566
  if (typeof value === "function") {
547
567
  computedDefaultNames.push(name);
548
568
  computedDefaultFns.push(value);
549
- continue;
550
- }
551
- if (value === void 0) {
552
- delete staticDefaults[name];
553
- continue;
554
- }
555
- staticDefaults[name] = value;
569
+ } else ownStaticDefaults[name] = value;
556
570
  }
557
571
  const computedDefaultCount = computedDefaultNames.length;
558
- if (hasAnyDisabled) for (const key in staticDefaults) {
559
- if (!hasOwn(staticDefaults, key)) continue;
560
- if (disabledVariantKeys.has(key)) {
561
- delete staticDefaults[key];
562
- continue;
572
+ const baseClass = clsx(baseClassValue);
573
+ const identity = {};
574
+ const creationFrame = (!!refine || computedDefaultCount > 0 || initialExtensions.some((meta) => meta.resolveRefine)) && process.env.NODE_ENV !== "production" ? captureCreationFrame(cv) : void 0;
575
+ const build = (extMetas) => {
576
+ const hasExtend = extMetas.length > 0;
577
+ const extCount = extMetas.length;
578
+ const staticDefaults = {};
579
+ const extBaseClassesArr = [];
580
+ const extIsolated = [];
581
+ let hasIsolatedExt = false;
582
+ for (const meta of extMetas) {
583
+ Object.assign(staticDefaults, meta.staticDefaults);
584
+ const isolated = meta.transformClass !== transformClass;
585
+ extIsolated.push(isolated);
586
+ if (isolated) {
587
+ hasIsolatedExt = true;
588
+ extBaseClassesArr.push(meta.transformClass(meta.baseClass));
589
+ } else extBaseClassesArr.push(meta.baseClass);
563
590
  }
564
- if (disabledVariantValues) {
565
- const value = staticDefaults[key];
566
- const valueKey = getVariantValueKey(value);
567
- if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) delete staticDefaults[key];
591
+ for (const name in ownStaticDefaults) {
592
+ if (!hasOwn(ownStaticDefaults, name)) continue;
593
+ const value = ownStaticDefaults[name];
594
+ if (value === void 0) delete staticDefaults[name];
595
+ else staticDefaults[name] = value;
568
596
  }
569
- }
570
- const inheritedComputedDefaultKeys = /* @__PURE__ */ new Set();
571
- for (let i = 0; i < extCount; i++) {
572
- const keys = extMetas[i].computedDefaultKeys;
573
- for (const key of keys) inheritedComputedDefaultKeys.add(key);
574
- }
575
- const extMetasWithRefine = [];
576
- for (let i = 0; i < extCount; i++) {
577
- const meta = extMetas[i];
578
- if (meta.resolveRefine) extMetasWithRefine.push(meta);
579
- }
580
- const extMetasWithRefineCount = extMetasWithRefine.length;
581
- const canProtectVariants = !!refine || extMetasWithRefineCount > 0;
582
- const needsUserVariantProps = computedDefaultCount > 0 || inheritedComputedDefaultKeys.size > 0;
583
- const creationFrame = (!!refine || computedDefaultCount > 0 || extMetasWithRefineCount > 0) && process.env.NODE_ENV !== "production" ? captureCreationFrame(cv) : void 0;
584
- const functionVariantKeys = /* @__PURE__ */ new Set();
585
- for (let i = 0; i < extCount; i++) {
586
- const fnKeys = extMetas[i].functionVariantKeys;
587
- for (const k of fnKeys) {
588
- if (disabledVariantKeys.has(k)) continue;
589
- functionVariantKeys.add(k);
597
+ if (hasAnyDisabled) for (const key in staticDefaults) {
598
+ if (!hasOwn(staticDefaults, key)) continue;
599
+ if (disabledVariantKeys.has(key)) {
600
+ delete staticDefaults[key];
601
+ continue;
602
+ }
603
+ if (disabledVariantValues) {
604
+ const valueKey = getVariantValueKey(staticDefaults[key]);
605
+ if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) delete staticDefaults[key];
606
+ }
590
607
  }
591
- }
592
- for (let i = 0; i < functionVariantCount; i++) functionVariantKeys.add(functionVariantNames[i]);
593
- for (let i = 0; i < variantEntryCount; i++) functionVariantKeys.delete(variantEntryNames[i]);
594
- const computedDefaultKeys = new Set(inheritedComputedDefaultKeys);
595
- for (let i = 0; i < computedDefaultCount; i++) computedDefaultKeys.add(computedDefaultNames[i]);
596
- let staticExtSkipKeys = null;
597
- if (hasDisabledVariantKeys || functionVariantCount > 0) {
598
- staticExtSkipKeys = /* @__PURE__ */ new Set();
599
- for (const k of disabledVariantKeys) staticExtSkipKeys.add(k);
600
- for (let i = 0; i < functionVariantCount; i++) staticExtSkipKeys.add(functionVariantNames[i]);
601
- }
602
- if (variantEntryCount > 0 && extCount > 0) for (let i = 0; i < variantEntryCount; i++) {
603
- const name = variantEntryNames[i];
604
- for (let j = 0; j < extCount; j++) if (extMetas[j].functionVariantKeys.has(name)) {
605
- staticExtSkipKeys ??= /* @__PURE__ */ new Set();
606
- staticExtSkipKeys.add(name);
607
- break;
608
+ const extMetasWithRefine = [];
609
+ for (let i = 0; i < extCount; i++) {
610
+ const meta = extMetas[i];
611
+ if (meta.resolveRefine) extMetasWithRefine.push(meta);
608
612
  }
609
- }
610
- const staticExtSkipValues = disabledVariantValues;
611
- function filterDisabledInto(input, out) {
612
- for (const key in input) {
613
- if (!hasOwn(input, key)) continue;
614
- if (disabledVariantKeys.has(key)) continue;
615
- const value = input[key];
616
- if (disabledVariantValues) {
617
- const valueKey = getVariantValueKey(value);
618
- if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) continue;
613
+ const extMetasWithRefineCount = extMetasWithRefine.length;
614
+ const canProtectVariants = !!refine || extMetasWithRefineCount > 0;
615
+ const needsUserVariantProps = computedDefaultCount > 0 || inheritedComputedDefaultKeys.size > 0;
616
+ const functionVariantKeys = /* @__PURE__ */ new Set();
617
+ for (let i = 0; i < extCount; i++) {
618
+ const fnKeys = extMetas[i].functionVariantKeys;
619
+ for (const k of fnKeys) {
620
+ if (disabledVariantKeys.has(k)) continue;
621
+ functionVariantKeys.add(k);
619
622
  }
620
- out[key] = value;
621
623
  }
622
- }
623
- const isOwnDisabledValue = (key, value) => {
624
- if (disabledVariantKeys.has(key)) return true;
625
- if (disabledVariantValues) {
626
- const valueKey = getVariantValueKey(value);
627
- if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) return true;
624
+ for (let i = 0; i < functionVariantCount; i++) functionVariantKeys.add(functionVariantNames[i]);
625
+ for (let i = 0; i < variantEntryCount; i++) functionVariantKeys.delete(variantEntryNames[i]);
626
+ const computedDefaultKeys = new Set(inheritedComputedDefaultKeys);
627
+ for (let i = 0; i < computedDefaultCount; i++) computedDefaultKeys.add(computedDefaultNames[i]);
628
+ let staticExtSkipKeys = null;
629
+ if (hasDisabledVariantKeys || functionVariantCount > 0) {
630
+ staticExtSkipKeys = /* @__PURE__ */ new Set();
631
+ for (const k of disabledVariantKeys) staticExtSkipKeys.add(k);
632
+ for (let i = 0; i < functionVariantCount; i++) staticExtSkipKeys.add(functionVariantNames[i]);
628
633
  }
629
- return false;
630
- };
631
- const filterOwnDisabledVariants = (input, fallback) => {
632
- if (!hasAnyDisabled) return input;
633
- let hasOwnDisabledValue = false;
634
- for (const key in input) {
635
- if (!hasOwn(input, key)) continue;
636
- const value = input[key];
637
- if (isOwnDisabledValue(key, value)) {
638
- hasOwnDisabledValue = true;
634
+ if (variantEntryCount > 0 && extCount > 0) for (let i = 0; i < variantEntryCount; i++) {
635
+ const name = variantEntryNames[i];
636
+ for (let j = 0; j < extCount; j++) if (extMetas[j].functionVariantKeys.has(name)) {
637
+ staticExtSkipKeys ??= /* @__PURE__ */ new Set();
638
+ staticExtSkipKeys.add(name);
639
639
  break;
640
640
  }
641
641
  }
642
- if (!hasOwnDisabledValue) return input;
643
- const filtered = {};
644
- for (const key in input) {
645
- if (!hasOwn(input, key)) continue;
646
- const value = input[key];
647
- if (!isOwnDisabledValue(key, value)) {
648
- filtered[key] = value;
649
- continue;
642
+ const staticExtSkipValues = disabledVariantValues;
643
+ function filterDisabledInto(input, out) {
644
+ for (const key in input) {
645
+ if (!hasOwn(input, key)) continue;
646
+ if (disabledVariantKeys.has(key)) continue;
647
+ const value = input[key];
648
+ if (disabledVariantValues) {
649
+ const valueKey = getVariantValueKey(value);
650
+ if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) continue;
651
+ }
652
+ out[key] = value;
650
653
  }
651
- const fallbackValue = getOwn(fallback, key);
652
- if (fallbackValue !== void 0 && !isOwnDisabledValue(key, fallbackValue)) filtered[key] = fallbackValue;
653
- }
654
- return filtered;
655
- };
656
- function resolveVariantsHot(propsVariants) {
657
- const defaults = Object.assign({}, staticDefaults);
658
- for (let i = 0; i < variantKeysLength; i++) {
659
- const k = variantKeys[i];
660
- if (!hasOwn(propsVariants, k)) continue;
661
- const v = propsVariants[k];
662
- if (v === void 0) continue;
663
- defaults[k] = v;
664
654
  }
665
- if (!hasAnyDisabled) return defaults;
666
- const result = {};
667
- filterDisabledInto(defaults, result);
668
- return result;
669
- }
670
- const runComputedDefaults = (resolved, defaultResolved, userVariantProps, filterOwnVariants, protection) => {
671
- const protectedVariants = protection?.variants;
672
- let ownVariants = filterOwnVariants ? null : resolved;
673
- const getOwnVariants = () => {
674
- if (ownVariants) return ownVariants;
675
- const filteredVariants = {};
676
- for (let i = 0; i < variantKeysLength; i++) {
677
- const key = variantKeys[i];
678
- if (hasOwn(resolved, key)) filteredVariants[key] = resolved[key];
655
+ const isOwnDisabledValue = (key, value) => {
656
+ if (disabledVariantKeys.has(key)) return true;
657
+ if (disabledVariantValues) {
658
+ const valueKey = getVariantValueKey(value);
659
+ if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) return true;
679
660
  }
680
- ownVariants = filteredVariants;
681
- return filteredVariants;
682
- };
683
- let updatedVariants = null;
684
- const ensureUpdated = () => {
685
- if (updatedVariants) return updatedVariants;
686
- const updated = Object.assign({}, resolved);
687
- updatedVariants = updated;
688
- return updated;
661
+ return false;
689
662
  };
690
- for (let i = 0; i < computedDefaultCount; i++) {
691
- const key = computedDefaultNames[i];
692
- if (hasOwn(userVariantProps, key)) {
693
- if (userVariantProps[key] !== void 0) continue;
663
+ const filterOwnDisabledVariants = (input, fallback) => {
664
+ if (!hasAnyDisabled) return input;
665
+ let hasOwnDisabledValue = false;
666
+ for (const key in input) {
667
+ if (!hasOwn(input, key)) continue;
668
+ const value = input[key];
669
+ if (isOwnDisabledValue(key, value)) {
670
+ hasOwnDisabledValue = true;
671
+ break;
672
+ }
694
673
  }
695
- if (protectedVariants && hasOwn(protectedVariants, key)) continue;
696
- const variantSnapshot = getOwnVariants();
697
- const defaultValue = inheritedComputedDefaultKeys.has(key) ? getOwn(variantSnapshot, key) : getOwn(defaultResolved, key);
698
- const value = computedDefaultFns[i](defaultValue, variantSnapshot);
699
- if (hasAnyDisabled) {
700
- if (disabledVariantKeys.has(key)) continue;
701
- if (disabledVariantValues) {
702
- const valueKey = getVariantValueKey(value);
703
- if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) continue;
674
+ if (!hasOwnDisabledValue) return input;
675
+ const filtered = {};
676
+ for (const key in input) {
677
+ if (!hasOwn(input, key)) continue;
678
+ const value = input[key];
679
+ if (!isOwnDisabledValue(key, value)) {
680
+ filtered[key] = value;
681
+ continue;
704
682
  }
683
+ const fallbackValue = getOwn(fallback, key);
684
+ if (fallbackValue !== void 0 && !isOwnDisabledValue(key, fallbackValue)) filtered[key] = fallbackValue;
705
685
  }
706
- if (value === void 0) {
707
- if (!hasOwn(variantSnapshot, key)) continue;
708
- delete ensureUpdated()[key];
709
- continue;
686
+ return filtered;
687
+ };
688
+ function resolveVariantsHot(propsVariants) {
689
+ const defaults = Object.assign({}, staticDefaults);
690
+ for (let i = 0; i < variantKeysLength; i++) {
691
+ const k = variantKeys[i];
692
+ if (!hasOwn(propsVariants, k)) continue;
693
+ const v = propsVariants[k];
694
+ if (v === void 0) continue;
695
+ defaults[k] = v;
710
696
  }
711
- if (Object.is(getOwn(variantSnapshot, key), value)) continue;
712
- ensureUpdated()[key] = value;
697
+ if (!hasAnyDisabled) return defaults;
698
+ const result = {};
699
+ filterDisabledInto(defaults, result);
700
+ return result;
713
701
  }
714
- return updatedVariants ?? resolved;
715
- };
716
- const runRefineContext = (resolved, filterOwnVariants, collectOutput, applyVariantUpdates, protection) => {
717
- let workingResolved = resolved;
718
- let cClasses = null;
719
- let cStyle = null;
720
- if (refine) {
721
- let ownVariants = resolved;
722
- if (filterOwnVariants) {
702
+ const runComputedDefaults = (resolved, defaultResolved, userVariantProps, filterOwnVariants, protection) => {
703
+ const protectedVariants = protection?.variants;
704
+ let ownVariants = filterOwnVariants ? null : resolved;
705
+ const getOwnVariants = () => {
706
+ if (ownVariants) return ownVariants;
723
707
  const filteredVariants = {};
724
708
  for (let i = 0; i < variantKeysLength; i++) {
725
- const k = variantKeys[i];
726
- if (hasOwn(resolved, k)) filteredVariants[k] = resolved[k];
709
+ const key = variantKeys[i];
710
+ if (hasOwn(resolved, key)) filteredVariants[key] = resolved[key];
727
711
  }
728
712
  ownVariants = filteredVariants;
713
+ return filteredVariants;
714
+ };
715
+ let updatedVariants = null;
716
+ const ensureUpdated = () => {
717
+ if (updatedVariants) return updatedVariants;
718
+ const updated = Object.assign({}, resolved);
719
+ updatedVariants = updated;
720
+ return updated;
721
+ };
722
+ for (let i = 0; i < computedDefaultCount; i++) {
723
+ const key = computedDefaultNames[i];
724
+ if (hasOwn(userVariantProps, key)) {
725
+ if (userVariantProps[key] !== void 0) continue;
726
+ }
727
+ if (protectedVariants && hasOwn(protectedVariants, key)) continue;
728
+ const variantSnapshot = getOwnVariants();
729
+ const defaultValue = inheritedComputedDefaultKeys.has(key) ? getOwn(variantSnapshot, key) : getOwn(defaultResolved, key);
730
+ const value = computedDefaultFns[i](defaultValue, variantSnapshot);
731
+ if (hasAnyDisabled) {
732
+ if (disabledVariantKeys.has(key)) continue;
733
+ if (disabledVariantValues) {
734
+ const valueKey = getVariantValueKey(value);
735
+ if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) continue;
736
+ }
737
+ }
738
+ if (value === void 0) {
739
+ if (!hasOwn(variantSnapshot, key)) continue;
740
+ delete ensureUpdated()[key];
741
+ continue;
742
+ }
743
+ if (Object.is(getOwn(variantSnapshot, key), value)) continue;
744
+ ensureUpdated()[key] = value;
729
745
  }
730
- let assignedVariants = null;
731
- let localCClasses = null;
732
- let localCStyle = null;
733
- const result = refine({
734
- variants: ownVariants,
735
- setVariants: (newVariants) => {
736
- if (!applyVariantUpdates) return;
737
- for (const key in newVariants) {
738
- if (!hasOwn(newVariants, key)) continue;
739
- if (disabledVariantKeys.has(key)) continue;
740
- const value = newVariants[key];
741
- if (disabledVariantValues) {
742
- const valueKey = getVariantValueKey(value);
743
- if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) continue;
744
- }
745
- if (protection) {
746
- const protectedVariants = protection.variants ??= {};
747
- protectedVariants[key] = value;
746
+ return updatedVariants ?? resolved;
747
+ };
748
+ const runRefineContext = (resolved, filterOwnVariants, collectOutput, applyVariantUpdates, protection) => {
749
+ let workingResolved = resolved;
750
+ let cClasses = null;
751
+ let cStyle = null;
752
+ if (refine) {
753
+ let ownVariants = resolved;
754
+ if (filterOwnVariants) {
755
+ const filteredVariants = {};
756
+ for (let i = 0; i < variantKeysLength; i++) {
757
+ const k = variantKeys[i];
758
+ if (hasOwn(resolved, k)) filteredVariants[k] = resolved[k];
759
+ }
760
+ ownVariants = filteredVariants;
761
+ }
762
+ let assignedVariants = null;
763
+ let localCClasses = null;
764
+ let localCStyle = null;
765
+ const result = refine({
766
+ variants: ownVariants,
767
+ setVariants: (newVariants) => {
768
+ if (!applyVariantUpdates) return;
769
+ for (const key in newVariants) {
770
+ if (!hasOwn(newVariants, key)) continue;
771
+ if (disabledVariantKeys.has(key)) continue;
772
+ const value = newVariants[key];
773
+ if (disabledVariantValues) {
774
+ const valueKey = getVariantValueKey(value);
775
+ if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) continue;
776
+ }
777
+ if (protection) {
778
+ const protectedVariants = protection.variants ??= {};
779
+ protectedVariants[key] = value;
780
+ }
781
+ const current = assignedVariants && hasOwn(assignedVariants, key) ? assignedVariants[key] : getOwn(ownVariants, key);
782
+ if (Object.is(current, value)) continue;
783
+ assignedVariants ??= {};
784
+ assignedVariants[key] = value;
748
785
  }
749
- const current = assignedVariants && hasOwn(assignedVariants, key) ? assignedVariants[key] : getOwn(ownVariants, key);
750
- if (Object.is(current, value)) continue;
751
- assignedVariants ??= {};
752
- assignedVariants[key] = value;
786
+ },
787
+ addClass: (className) => {
788
+ if (!collectOutput) return;
789
+ localCClasses ??= [];
790
+ localCClasses.push(className);
791
+ },
792
+ addStyle: (newStyle) => {
793
+ if (!collectOutput) return;
794
+ localCStyle ??= {};
795
+ Object.assign(localCStyle, newStyle);
796
+ }
797
+ });
798
+ if (collectOutput && result != null) {
799
+ const r = extractClassAndStylePrebuilt(result);
800
+ if (r.class != null) {
801
+ localCClasses ??= [];
802
+ localCClasses.push(r.class);
803
+ }
804
+ if (r.style) {
805
+ localCStyle ??= {};
806
+ Object.assign(localCStyle, r.style);
753
807
  }
754
- },
755
- addClass: (className) => {
756
- if (!collectOutput) return;
757
- localCClasses ??= [];
758
- localCClasses.push(className);
759
- },
760
- addStyle: (newStyle) => {
761
- if (!collectOutput) return;
762
- localCStyle ??= {};
763
- Object.assign(localCStyle, newStyle);
764
808
  }
765
- });
766
- if (collectOutput && result != null) {
767
- const r = extractClassAndStylePrebuilt(result);
768
- if (r.class != null) {
769
- localCClasses ??= [];
770
- localCClasses.push(r.class);
809
+ cClasses = localCClasses;
810
+ cStyle = localCStyle;
811
+ if (assignedVariants) workingResolved = Object.assign({}, workingResolved, assignedVariants);
812
+ }
813
+ return {
814
+ workingResolved,
815
+ classes: cClasses,
816
+ style: cStyle
817
+ };
818
+ };
819
+ const computeOnce = (resolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut, protection, defaultResolved = resolved, renderOnly = false) => {
820
+ let workingResolved = resolved;
821
+ let cClasses = null;
822
+ let cStyle = null;
823
+ if (hasExtend) {
824
+ let extSkipKeys;
825
+ if (skipKeys === null) extSkipKeys = staticExtSkipKeys;
826
+ else if (staticExtSkipKeys === null) extSkipKeys = skipKeys;
827
+ else {
828
+ extSkipKeys = new Set(skipKeys);
829
+ for (const k of staticExtSkipKeys) extSkipKeys.add(k);
830
+ }
831
+ let extSkipVals;
832
+ if (skipValues === null) extSkipVals = staticExtSkipValues;
833
+ else if (staticExtSkipValues === null) extSkipVals = skipValues;
834
+ else {
835
+ extSkipVals = {};
836
+ for (const k in skipValues) {
837
+ if (!hasOwn(skipValues, k)) continue;
838
+ extSkipVals[k] = skipValues[k];
839
+ }
840
+ for (const k in staticExtSkipValues) {
841
+ if (!hasOwn(staticExtSkipValues, k)) continue;
842
+ const values = staticExtSkipValues[k];
843
+ const existing = getOwn(extSkipVals, k);
844
+ if (existing) {
845
+ const merged = new Set(existing);
846
+ for (const v of values) merged.add(v);
847
+ extSkipVals[k] = merged;
848
+ } else extSkipVals[k] = values;
849
+ }
771
850
  }
772
- if (r.style) {
773
- localCStyle ??= {};
774
- Object.assign(localCStyle, r.style);
851
+ for (let i = 0; i < extCount; i++) {
852
+ if (hasIsolatedExt && extIsolated[i]) {
853
+ const extClasses = [];
854
+ workingResolved = extMetas[i].compute(workingResolved, userVariantProps, extSkipKeys, extSkipVals, extClasses, styleOut, protection, defaultResolved, renderOnly);
855
+ if (extClasses.length > 0) {
856
+ const joined = clsx(extClasses);
857
+ if (joined.length > 0) classesOut.push(extMetas[i].transformClass(joined));
858
+ }
859
+ } else workingResolved = extMetas[i].compute(workingResolved, userVariantProps, extSkipKeys, extSkipVals, classesOut, styleOut, protection, defaultResolved, renderOnly);
860
+ workingResolved = filterOwnDisabledVariants(workingResolved, defaultResolved);
775
861
  }
776
862
  }
777
- cClasses = localCClasses;
778
- cStyle = localCStyle;
779
- if (assignedVariants) workingResolved = Object.assign({}, workingResolved, assignedVariants);
780
- }
781
- return {
782
- workingResolved,
783
- classes: cClasses,
784
- style: cStyle
785
- };
786
- };
787
- const computeOnce = (resolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut, protection, defaultResolved = resolved, renderOnly = false) => {
788
- let workingResolved = resolved;
789
- let cClasses = null;
790
- let cStyle = null;
791
- if (hasExtend) {
792
- let extSkipKeys;
793
- if (skipKeys === null) extSkipKeys = staticExtSkipKeys;
794
- else if (staticExtSkipKeys === null) extSkipKeys = skipKeys;
795
- else {
796
- extSkipKeys = new Set(skipKeys);
797
- for (const k of staticExtSkipKeys) extSkipKeys.add(k);
863
+ if (!renderOnly && computedDefaultCount > 0) workingResolved = runComputedDefaults(workingResolved, defaultResolved, userVariantProps, true, protection);
864
+ if (refine) {
865
+ const refineResult = runRefineContext(workingResolved, true, true, !renderOnly, protection);
866
+ workingResolved = refineResult.workingResolved;
867
+ cClasses = refineResult.classes;
868
+ cStyle = refineResult.style;
869
+ }
870
+ if (hasBaseStyle) Object.assign(styleOut, baseStyle);
871
+ const ownSkipKeys = skipKeys;
872
+ const ownSkipValues = skipValues;
873
+ for (let i = 0; i < variantEntryCount; i++) {
874
+ const variantName = variantEntryNames[i];
875
+ if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;
876
+ const selectedValue = workingResolved[variantName];
877
+ if (selectedValue === void 0) continue;
878
+ if (!hasOwn(workingResolved, variantName)) continue;
879
+ const selectedKey = getVariantValueKey(selectedValue);
880
+ const variant = variantEntryDefs[i];
881
+ if (variant.disabledValues && selectedKey != null && variant.disabledValues.has(selectedKey)) continue;
882
+ if (ownSkipValues && selectedKey != null && getOwn(ownSkipValues, variantName)?.has(selectedKey)) continue;
883
+ let value;
884
+ if (variant.values) {
885
+ if (selectedKey == null) continue;
886
+ value = variant.values.get(selectedKey);
887
+ } else if (selectedValue === true) value = variant.shorthand;
888
+ if (!value) continue;
889
+ if (value.class != null) classesOut.push(value.class);
890
+ if (value.style) Object.assign(styleOut, value.style);
891
+ }
892
+ for (let i = 0; i < functionVariantCount; i++) {
893
+ const variantName = functionVariantNames[i];
894
+ if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;
895
+ const selectedValue = workingResolved[variantName];
896
+ if (selectedValue === void 0) continue;
897
+ if (!hasOwn(workingResolved, variantName)) continue;
898
+ const selectedKey = getVariantValueKey(selectedValue);
899
+ if (ownSkipValues && selectedKey != null && getOwn(ownSkipValues, variantName)?.has(selectedKey)) continue;
900
+ const fn = functionVariantFns[i];
901
+ const computedResult = fn(selectedValue);
902
+ if (computedResult == null) continue;
903
+ const r = extractClassAndStylePrebuilt(computedResult);
904
+ if (r.class != null) classesOut.push(r.class);
905
+ if (r.style) Object.assign(styleOut, r.style);
798
906
  }
799
- let extSkipVals;
800
- if (skipValues === null) extSkipVals = staticExtSkipValues;
801
- else if (staticExtSkipValues === null) extSkipVals = skipValues;
802
- else {
803
- extSkipVals = {};
804
- for (const k in skipValues) {
805
- if (!hasOwn(skipValues, k)) continue;
806
- extSkipVals[k] = skipValues[k];
907
+ if (cClasses) for (let i = 0; i < cClasses.length; i++) classesOut.push(cClasses[i]);
908
+ if (cStyle) Object.assign(styleOut, cStyle);
909
+ return workingResolved;
910
+ };
911
+ const compute = !refine && computedDefaultCount === 0 && extMetasWithRefineCount === 0 ? computeOnce : (resolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut) => {
912
+ let remaining = MAX_REFINE_RUNS;
913
+ const protection = canProtectVariants ? { variants: null } : null;
914
+ const incomingDefaultResolved = resolved;
915
+ let workingResolved = resolved;
916
+ let unstableChanges = null;
917
+ let lastClasses = [];
918
+ let lastStyle = {};
919
+ let isFirstRun = true;
920
+ while (remaining > 0) {
921
+ remaining -= 1;
922
+ const useDirectOutput = isFirstRun;
923
+ const classCount = classesOut.length;
924
+ const nextClasses = useDirectOutput ? classesOut : [];
925
+ const nextStyle = useDirectOutput ? styleOut : {};
926
+ const defaultResolved = mergeProtectedIntoBase(incomingDefaultResolved, protection);
927
+ const nextResolved = computeOnce(workingResolved, userVariantProps, skipKeys, skipValues, nextClasses, nextStyle, protection, defaultResolved);
928
+ if (nextResolved === workingResolved || areVariantsEqual(workingResolved, nextResolved)) {
929
+ if (nextResolved !== workingResolved) {
930
+ if (useDirectOutput) {
931
+ classesOut.length = classCount;
932
+ for (const key in styleOut) if (hasOwn(styleOut, key)) Reflect.deleteProperty(styleOut, key);
933
+ }
934
+ computeOnce(nextResolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut, protection, defaultResolved, true);
935
+ } else if (!useDirectOutput) {
936
+ for (let i = 0; i < nextClasses.length; i++) classesOut.push(nextClasses[i]);
937
+ Object.assign(styleOut, nextStyle);
938
+ }
939
+ return nextResolved;
940
+ }
941
+ if (remaining < 10 && process.env.NODE_ENV !== "production") {
942
+ if (!unstableChanges) unstableChanges = /* @__PURE__ */ new Map();
943
+ accumulateUnstableVariantChanges(unstableChanges, workingResolved, nextResolved);
807
944
  }
808
- for (const k in staticExtSkipValues) {
809
- if (!hasOwn(staticExtSkipValues, k)) continue;
810
- const values = staticExtSkipValues[k];
811
- const existing = getOwn(extSkipVals, k);
812
- if (existing) {
813
- const merged = new Set(existing);
814
- for (const v of values) merged.add(v);
815
- extSkipVals[k] = merged;
816
- } else extSkipVals[k] = values;
945
+ if (useDirectOutput) {
946
+ classesOut.length = classCount;
947
+ for (const key in styleOut) if (hasOwn(styleOut, key)) Reflect.deleteProperty(styleOut, key);
948
+ } else {
949
+ lastClasses = nextClasses;
950
+ lastStyle = nextStyle;
817
951
  }
952
+ workingResolved = nextResolved;
953
+ isFirstRun = false;
818
954
  }
819
- for (let i = 0; i < extCount; i++) {
820
- if (hasIsolatedExt && extIsolated[i]) {
821
- const extClasses = [];
822
- workingResolved = extMetas[i].compute(workingResolved, userVariantProps, extSkipKeys, extSkipVals, extClasses, styleOut, protection, defaultResolved, renderOnly);
823
- if (extClasses.length > 0) {
824
- const joined = clsx(extClasses);
825
- if (joined.length > 0) classesOut.push(extMetas[i].transformClass(joined));
826
- }
827
- } else workingResolved = extMetas[i].compute(workingResolved, userVariantProps, extSkipKeys, extSkipVals, classesOut, styleOut, protection, defaultResolved, renderOnly);
955
+ if (process.env.NODE_ENV !== "production") warnRefineLimit({
956
+ creationFrame,
957
+ unstableChanges
958
+ });
959
+ for (let i = 0; i < lastClasses.length; i++) classesOut.push(lastClasses[i]);
960
+ Object.assign(styleOut, lastStyle);
961
+ return workingResolved;
962
+ };
963
+ const resolveRefineOnce = (resolved, userVariantProps, filterOwnVariants = true, protection, defaultResolved = resolved) => {
964
+ let workingResolved = resolved;
965
+ for (let i = 0; i < extMetasWithRefineCount; i++) {
966
+ const resolveRefine = extMetasWithRefine[i].resolveRefine;
967
+ if (!resolveRefine) continue;
968
+ workingResolved = resolveRefine(workingResolved, userVariantProps, true, protection, defaultResolved);
828
969
  workingResolved = filterOwnDisabledVariants(workingResolved, defaultResolved);
829
970
  }
830
- }
831
- if (!renderOnly && computedDefaultCount > 0) workingResolved = runComputedDefaults(workingResolved, defaultResolved, userVariantProps, true, protection);
832
- if (refine) {
833
- const refineResult = runRefineContext(workingResolved, true, true, !renderOnly, protection);
834
- workingResolved = refineResult.workingResolved;
835
- cClasses = refineResult.classes;
836
- cStyle = refineResult.style;
837
- }
838
- if (hasBaseStyle) Object.assign(styleOut, baseStyle);
839
- const ownSkipKeys = skipKeys;
840
- const ownSkipValues = skipValues;
841
- for (let i = 0; i < variantEntryCount; i++) {
842
- const variantName = variantEntryNames[i];
843
- if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;
844
- const selectedValue = workingResolved[variantName];
845
- if (selectedValue === void 0) continue;
846
- if (!hasOwn(workingResolved, variantName)) continue;
847
- const selectedKey = getVariantValueKey(selectedValue);
848
- const variant = variantEntryDefs[i];
849
- if (variant.disabledValues && selectedKey != null && variant.disabledValues.has(selectedKey)) continue;
850
- if (ownSkipValues && selectedKey != null && getOwn(ownSkipValues, variantName)?.has(selectedKey)) continue;
851
- let value;
852
- if (variant.values) {
853
- if (selectedKey == null) continue;
854
- value = variant.values.get(selectedKey);
855
- } else if (selectedValue === true) value = variant.shorthand;
856
- if (!value) continue;
857
- if (value.class != null) classesOut.push(value.class);
858
- if (value.style) Object.assign(styleOut, value.style);
859
- }
860
- for (let i = 0; i < functionVariantCount; i++) {
861
- const variantName = functionVariantNames[i];
862
- if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;
863
- const selectedValue = workingResolved[variantName];
864
- if (selectedValue === void 0) continue;
865
- if (!hasOwn(workingResolved, variantName)) continue;
866
- const selectedKey = getVariantValueKey(selectedValue);
867
- if (ownSkipValues && selectedKey != null && getOwn(ownSkipValues, variantName)?.has(selectedKey)) continue;
868
- const fn = functionVariantFns[i];
869
- const computedResult = fn(selectedValue);
870
- if (computedResult == null) continue;
871
- const r = extractClassAndStylePrebuilt(computedResult);
872
- if (r.class != null) classesOut.push(r.class);
873
- if (r.style) Object.assign(styleOut, r.style);
874
- }
875
- if (cClasses) for (let i = 0; i < cClasses.length; i++) classesOut.push(cClasses[i]);
876
- if (cStyle) Object.assign(styleOut, cStyle);
877
- return workingResolved;
878
- };
879
- const compute = !refine && computedDefaultCount === 0 && extMetasWithRefineCount === 0 ? computeOnce : (resolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut) => {
880
- let remaining = MAX_REFINE_RUNS;
881
- const protection = canProtectVariants ? { variants: null } : null;
882
- const incomingDefaultResolved = resolved;
883
- let workingResolved = resolved;
884
- let unstableChanges = null;
885
- let lastClasses = [];
886
- let lastStyle = {};
887
- let isFirstRun = true;
888
- while (remaining > 0) {
889
- remaining -= 1;
890
- const useDirectOutput = isFirstRun;
891
- const classCount = classesOut.length;
892
- const nextClasses = useDirectOutput ? classesOut : [];
893
- const nextStyle = useDirectOutput ? styleOut : {};
894
- const defaultResolved = mergeProtectedIntoBase(incomingDefaultResolved, protection);
895
- const nextResolved = computeOnce(workingResolved, userVariantProps, skipKeys, skipValues, nextClasses, nextStyle, protection, defaultResolved);
896
- if (nextResolved === workingResolved || areVariantsEqual(workingResolved, nextResolved)) {
897
- if (nextResolved !== workingResolved) {
898
- if (useDirectOutput) {
899
- classesOut.length = classCount;
900
- for (const key in styleOut) if (hasOwn(styleOut, key)) Reflect.deleteProperty(styleOut, key);
901
- }
902
- computeOnce(nextResolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut, protection, defaultResolved, true);
903
- } else if (!useDirectOutput) {
904
- for (let i = 0; i < nextClasses.length; i++) classesOut.push(nextClasses[i]);
905
- Object.assign(styleOut, nextStyle);
971
+ if (computedDefaultCount > 0) workingResolved = runComputedDefaults(workingResolved, defaultResolved, userVariantProps, filterOwnVariants, protection);
972
+ if (refine) workingResolved = runRefineContext(workingResolved, filterOwnVariants, false, true, protection).workingResolved;
973
+ return workingResolved;
974
+ };
975
+ const resolveRefine = refine || computedDefaultCount > 0 || extMetasWithRefineCount > 0 ? (resolved, userVariantProps, filterOwnVariants = true) => {
976
+ let remaining = MAX_REFINE_RUNS;
977
+ const protection = canProtectVariants ? { variants: null } : null;
978
+ const incomingDefaultResolved = resolved;
979
+ let workingResolved = resolved;
980
+ let unstableChanges = null;
981
+ while (remaining > 0) {
982
+ remaining -= 1;
983
+ const defaultResolved = mergeProtectedIntoBase(incomingDefaultResolved, protection);
984
+ const nextResolved = resolveRefineOnce(workingResolved, userVariantProps, filterOwnVariants, protection, defaultResolved);
985
+ if (nextResolved === workingResolved || areVariantsEqual(workingResolved, nextResolved)) return nextResolved;
986
+ if (remaining < 10 && process.env.NODE_ENV !== "production") {
987
+ if (!unstableChanges) unstableChanges = /* @__PURE__ */ new Map();
988
+ accumulateUnstableVariantChanges(unstableChanges, workingResolved, nextResolved);
906
989
  }
907
- return nextResolved;
908
- }
909
- if (remaining < 10 && process.env.NODE_ENV !== "production") {
910
- if (!unstableChanges) unstableChanges = /* @__PURE__ */ new Map();
911
- accumulateUnstableVariantChanges(unstableChanges, workingResolved, nextResolved);
990
+ workingResolved = nextResolved;
912
991
  }
913
- if (useDirectOutput) {
914
- classesOut.length = classCount;
915
- for (const key in styleOut) if (hasOwn(styleOut, key)) Reflect.deleteProperty(styleOut, key);
992
+ if (process.env.NODE_ENV !== "production") warnRefineLimit({
993
+ creationFrame,
994
+ unstableChanges
995
+ });
996
+ return workingResolved;
997
+ } : null;
998
+ const computeResult = (props = EMPTY_DEFAULTS) => {
999
+ const propsRecord = props;
1000
+ let resolved = {};
1001
+ Object.assign(resolved, staticDefaults);
1002
+ let userVariantProps;
1003
+ if (needsUserVariantProps) {
1004
+ const variantProps = {};
1005
+ for (let i = 0; i < variantKeysLength; i++) {
1006
+ const key = variantKeys[i];
1007
+ if (!hasOwn(propsRecord, key)) continue;
1008
+ const value = propsRecord[key];
1009
+ variantProps[key] = value;
1010
+ if (value === void 0) continue;
1011
+ resolved[key] = value;
1012
+ }
1013
+ userVariantProps = variantProps;
916
1014
  } else {
917
- lastClasses = nextClasses;
918
- lastStyle = nextStyle;
919
- }
920
- workingResolved = nextResolved;
921
- isFirstRun = false;
922
- }
923
- if (process.env.NODE_ENV !== "production") warnRefineLimit({
924
- creationFrame,
925
- unstableChanges
926
- });
927
- for (let i = 0; i < lastClasses.length; i++) classesOut.push(lastClasses[i]);
928
- Object.assign(styleOut, lastStyle);
929
- return workingResolved;
930
- };
931
- const resolveRefineOnce = (resolved, userVariantProps, filterOwnVariants = true, protection, defaultResolved = resolved) => {
932
- let workingResolved = resolved;
933
- for (let i = 0; i < extMetasWithRefineCount; i++) {
934
- const resolveRefine = extMetasWithRefine[i].resolveRefine;
935
- if (!resolveRefine) continue;
936
- workingResolved = resolveRefine(workingResolved, userVariantProps, true, protection, defaultResolved);
937
- workingResolved = filterOwnDisabledVariants(workingResolved, defaultResolved);
938
- }
939
- if (computedDefaultCount > 0) workingResolved = runComputedDefaults(workingResolved, defaultResolved, userVariantProps, filterOwnVariants, protection);
940
- if (refine) workingResolved = runRefineContext(workingResolved, filterOwnVariants, false, true, protection).workingResolved;
941
- return workingResolved;
942
- };
943
- const resolveRefine = refine || computedDefaultCount > 0 || extMetasWithRefineCount > 0 ? (resolved, userVariantProps, filterOwnVariants = true) => {
944
- let remaining = MAX_REFINE_RUNS;
945
- const protection = canProtectVariants ? { variants: null } : null;
946
- const incomingDefaultResolved = resolved;
947
- let workingResolved = resolved;
948
- let unstableChanges = null;
949
- while (remaining > 0) {
950
- remaining -= 1;
951
- const defaultResolved = mergeProtectedIntoBase(incomingDefaultResolved, protection);
952
- const nextResolved = resolveRefineOnce(workingResolved, userVariantProps, filterOwnVariants, protection, defaultResolved);
953
- if (nextResolved === workingResolved || areVariantsEqual(workingResolved, nextResolved)) return nextResolved;
954
- if (remaining < 10 && process.env.NODE_ENV !== "production") {
955
- if (!unstableChanges) unstableChanges = /* @__PURE__ */ new Map();
956
- accumulateUnstableVariantChanges(unstableChanges, workingResolved, nextResolved);
1015
+ for (let i = 0; i < variantKeysLength; i++) {
1016
+ const key = variantKeys[i];
1017
+ if (!hasOwn(propsRecord, key)) continue;
1018
+ const v = propsRecord[key];
1019
+ if (v === void 0) continue;
1020
+ resolved[key] = v;
1021
+ }
1022
+ userVariantProps = propsRecord;
957
1023
  }
958
- workingResolved = nextResolved;
959
- }
960
- if (process.env.NODE_ENV !== "production") warnRefineLimit({
961
- creationFrame,
962
- unstableChanges
963
- });
964
- return workingResolved;
965
- } : null;
966
- const computeResult = (props = EMPTY_DEFAULTS) => {
967
- const propsRecord = props;
968
- let resolved = {};
969
- Object.assign(resolved, staticDefaults);
970
- let userVariantProps;
971
- if (needsUserVariantProps) {
972
- const variantProps = {};
973
- for (let i = 0; i < variantKeysLength; i++) {
974
- const key = variantKeys[i];
975
- if (!hasOwn(propsRecord, key)) continue;
976
- const value = propsRecord[key];
977
- variantProps[key] = value;
978
- if (value === void 0) continue;
979
- resolved[key] = value;
1024
+ if (hasAnyDisabled) {
1025
+ const filtered = {};
1026
+ filterDisabledInto(resolved, filtered);
1027
+ resolved = filtered;
980
1028
  }
981
- userVariantProps = variantProps;
982
- } else {
983
- for (let i = 0; i < variantKeysLength; i++) {
984
- const key = variantKeys[i];
985
- if (!hasOwn(propsRecord, key)) continue;
986
- const v = propsRecord[key];
987
- if (v === void 0) continue;
988
- resolved[key] = v;
1029
+ const allClasses = [computedBaseClass];
1030
+ const style = {};
1031
+ compute(resolved, userVariantProps, null, null, allClasses, style);
1032
+ if (hasOwn(propsRecord, "class")) allClasses.push(propsRecord.class);
1033
+ if (hasOwn(propsRecord, "className")) allClasses.push(propsRecord.className);
1034
+ const psv = propsRecord.style;
1035
+ if (psv != null && hasOwn(propsRecord, "style")) {
1036
+ if (typeof psv === "string") {
1037
+ if (psv.length > 0) htmlStyleToStyleValue(psv, style);
1038
+ } else if (typeof psv === "object") htmlObjStyleToStyleValue(psv, style);
989
1039
  }
990
- userVariantProps = propsRecord;
991
- }
992
- if (hasAnyDisabled) {
993
- const filtered = {};
994
- filterDisabledInto(resolved, filtered);
995
- resolved = filtered;
996
- }
997
- const allClasses = [computedBaseClass];
998
- const style = {};
999
- compute(resolved, userVariantProps, null, null, allClasses, style);
1000
- if (hasOwn(propsRecord, "class")) allClasses.push(propsRecord.class);
1001
- if (hasOwn(propsRecord, "className")) allClasses.push(propsRecord.className);
1002
- const psv = propsRecord.style;
1003
- if (psv != null && hasOwn(propsRecord, "style")) {
1004
- if (typeof psv === "string") {
1005
- if (psv.length > 0) htmlStyleToStyleValue(psv, style);
1006
- } else if (typeof psv === "object") htmlObjStyleToStyleValue(psv, style);
1007
- }
1008
- return {
1009
- className: transformClass(clsx(allClasses)),
1010
- style
1040
+ return {
1041
+ className: transformClass(clsx(allClasses)),
1042
+ style
1043
+ };
1011
1044
  };
1012
- };
1013
- const getVariants = (variants) => {
1014
- const variantsRecord = variants ?? EMPTY_DEFAULTS;
1015
- let variantProps = variantsRecord;
1016
- if (variants && extMetasWithRefineCount > 0) {
1017
- variantProps = {};
1018
- for (let i = 0; i < variantKeysLength; i++) {
1019
- const key = variantKeys[i];
1020
- if (hasOwn(variantsRecord, key)) variantProps[key] = variantsRecord[key];
1045
+ const getVariants = (variants) => {
1046
+ const variantsRecord = variants ?? EMPTY_DEFAULTS;
1047
+ let variantProps = variantsRecord;
1048
+ if (variants && extMetasWithRefineCount > 0) {
1049
+ variantProps = {};
1050
+ for (let i = 0; i < variantKeysLength; i++) {
1051
+ const key = variantKeys[i];
1052
+ if (hasOwn(variantsRecord, key)) variantProps[key] = variantsRecord[key];
1053
+ }
1021
1054
  }
1022
- }
1023
- let resolvedVariants = resolveVariantsHot(variantProps);
1024
- if (resolveRefine) resolvedVariants = resolveRefine(resolvedVariants, variantProps, false);
1025
- return resolvedVariants;
1026
- };
1027
- const computedBaseClass = hasExtend ? clsx(extBaseClassesArr, baseClass) : clsx(baseClass);
1028
- const classFn = (props = {}) => {
1029
- return computeResult(props).className;
1030
- };
1031
- const meta = {
1032
- baseClass: computedBaseClass,
1033
- staticDefaults,
1034
- compute: computeOnce,
1035
- resolveRefine: resolveRefine ? resolveRefineOnce : null,
1036
- transformClass,
1037
- functionVariantKeys,
1038
- computedDefaultKeys
1039
- };
1040
- const initComponent = (c, propKeys, style) => {
1041
- c.class = classFn;
1042
- c.style = style;
1043
- c.getVariants = getVariants;
1044
- c.variantKeys = variantKeys;
1045
- c.propKeys = propKeys;
1046
- c[META_KEY] = meta;
1047
- return c;
1048
- };
1049
- const defaultComponent = ((props = {}) => {
1050
- const { className, style } = computeResult(props);
1051
- return {
1052
- class: className,
1053
- style
1055
+ let resolvedVariants = resolveVariantsHot(variantProps);
1056
+ if (resolveRefine) resolvedVariants = resolveRefine(resolvedVariants, variantProps, false);
1057
+ return resolvedVariants;
1054
1058
  };
1055
- });
1056
- initComponent(defaultComponent, inputPropsKeys, (props = {}) => {
1057
- return computeResult(props).style;
1058
- });
1059
- const jsxComponent = ((props = {}) => {
1060
- const { className, style } = computeResult(props);
1061
- return {
1062
- className,
1063
- style
1059
+ const computedBaseClass = hasExtend ? clsx(extBaseClassesArr, baseClass) : baseClass;
1060
+ const classFn = (props = {}) => {
1061
+ return computeResult(props).className;
1064
1062
  };
1065
- });
1066
- initComponent(jsxComponent, [
1067
- "className",
1068
- "style",
1069
- ...variantKeys
1070
- ], (props = {}) => computeResult(props).style);
1071
- const htmlComponent = ((props = {}) => {
1072
- const { className, style } = computeResult(props);
1073
- return {
1074
- class: className,
1075
- style: styleValueToHTMLStyle(style)
1063
+ const meta = {
1064
+ identity,
1065
+ extends: extMetas,
1066
+ rebuild: (extensions) => build(extensions).meta,
1067
+ baseClass: computedBaseClass,
1068
+ staticDefaults,
1069
+ compute: computeOnce,
1070
+ resolveRefine: resolveRefine ? resolveRefineOnce : null,
1071
+ transformClass,
1072
+ functionVariantKeys,
1073
+ computedDefaultKeys
1076
1074
  };
1077
- });
1078
- initComponent(htmlComponent, [
1079
- "class",
1080
- "style",
1081
- ...variantKeys
1082
- ], (props = {}) => styleValueToHTMLStyle(computeResult(props).style));
1083
- const htmlObjComponent = ((props = {}) => {
1084
- const { className, style } = computeResult(props);
1075
+ const initRecipe = (recipe, propKeys, style) => {
1076
+ recipe.class = classFn;
1077
+ recipe.style = style;
1078
+ recipe.getVariants = getVariants;
1079
+ recipe.variantKeys = variantKeys;
1080
+ recipe.propKeys = propKeys;
1081
+ recipe[META_KEY] = meta;
1082
+ return recipe;
1083
+ };
1084
+ const defaultRecipe = ((props = {}) => {
1085
+ const { className, style } = computeResult(props);
1086
+ return {
1087
+ class: className,
1088
+ style
1089
+ };
1090
+ });
1091
+ initRecipe(defaultRecipe, inputPropsKeys, (props = {}) => {
1092
+ return computeResult(props).style;
1093
+ });
1094
+ const jsxRecipe = ((props = {}) => {
1095
+ const { className, style } = computeResult(props);
1096
+ return {
1097
+ className,
1098
+ style
1099
+ };
1100
+ });
1101
+ initRecipe(jsxRecipe, [
1102
+ "className",
1103
+ "style",
1104
+ ...variantKeys
1105
+ ], (props = {}) => computeResult(props).style);
1106
+ const htmlRecipe = ((props = {}) => {
1107
+ const { className, style } = computeResult(props);
1108
+ return {
1109
+ class: className,
1110
+ style: styleValueToHTMLStyle(style)
1111
+ };
1112
+ });
1113
+ initRecipe(htmlRecipe, [
1114
+ "class",
1115
+ "style",
1116
+ ...variantKeys
1117
+ ], (props = {}) => styleValueToHTMLStyle(computeResult(props).style));
1118
+ const htmlObjRecipe = ((props = {}) => {
1119
+ const { className, style } = computeResult(props);
1120
+ return {
1121
+ class: className,
1122
+ style: styleValueToHTMLObjStyle(style)
1123
+ };
1124
+ });
1125
+ initRecipe(htmlObjRecipe, [
1126
+ "class",
1127
+ "style",
1128
+ ...variantKeys
1129
+ ], (props = {}) => styleValueToHTMLObjStyle(computeResult(props).style));
1130
+ defaultRecipe.jsx = jsxRecipe;
1131
+ defaultRecipe.html = htmlRecipe;
1132
+ defaultRecipe.htmlObj = htmlObjRecipe;
1085
1133
  return {
1086
- class: className,
1087
- style: styleValueToHTMLObjStyle(style)
1134
+ recipe: defaultRecipe,
1135
+ meta
1088
1136
  };
1089
- });
1090
- initComponent(htmlObjComponent, [
1091
- "class",
1092
- "style",
1093
- ...variantKeys
1094
- ], (props = {}) => styleValueToHTMLObjStyle(computeResult(props).style));
1095
- defaultComponent.jsx = jsxComponent;
1096
- defaultComponent.html = htmlComponent;
1097
- defaultComponent.htmlObj = htmlObjComponent;
1098
- return defaultComponent;
1137
+ };
1138
+ return build(initialExtensions);
1099
1139
  };
1140
+ const cv = (config = {}) => buildRecipe(config).recipe;
1100
1141
  return {
1101
1142
  cv,
1102
1143
  cx