rafters 0.0.64 → 0.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +692 -1027
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -735,10 +735,10 @@ function jsonStringifyReplacer(_, value) {
735
735
  return value;
736
736
  }
737
737
  function cached(getter) {
738
- const set4 = false;
738
+ const set3 = false;
739
739
  return {
740
740
  get value() {
741
- if (!set4) {
741
+ if (!set3) {
742
742
  const value = getter();
743
743
  Object.defineProperty(this, "value", { value });
744
744
  return value;
@@ -747,8 +747,8 @@ function cached(getter) {
747
747
  }
748
748
  };
749
749
  }
750
- function nullish(input2) {
751
- return input2 === null || input2 === void 0;
750
+ function nullish(input) {
751
+ return input === null || input === void 0;
752
752
  }
753
753
  function cleanRegex(source) {
754
754
  const start = source.startsWith("^") ? 1 : 0;
@@ -1203,29 +1203,29 @@ function finalizeIssue(iss, ctx, config2) {
1203
1203
  }
1204
1204
  return full;
1205
1205
  }
1206
- function getSizableOrigin(input2) {
1207
- if (input2 instanceof Set)
1206
+ function getSizableOrigin(input) {
1207
+ if (input instanceof Set)
1208
1208
  return "set";
1209
- if (input2 instanceof Map)
1209
+ if (input instanceof Map)
1210
1210
  return "map";
1211
- if (input2 instanceof File)
1211
+ if (input instanceof File)
1212
1212
  return "file";
1213
1213
  return "unknown";
1214
1214
  }
1215
- function getLengthableOrigin(input2) {
1216
- if (Array.isArray(input2))
1215
+ function getLengthableOrigin(input) {
1216
+ if (Array.isArray(input))
1217
1217
  return "array";
1218
- if (typeof input2 === "string")
1218
+ if (typeof input === "string")
1219
1219
  return "string";
1220
1220
  return "unknown";
1221
1221
  }
1222
1222
  function issue(...args) {
1223
- const [iss, input2, inst] = args;
1223
+ const [iss, input, inst] = args;
1224
1224
  if (typeof iss === "string") {
1225
1225
  return {
1226
1226
  message: iss,
1227
1227
  code: "custom",
1228
- input: input2,
1228
+ input,
1229
1229
  inst
1230
1230
  };
1231
1231
  }
@@ -1759,23 +1759,23 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
1759
1759
  bag.pattern = integer;
1760
1760
  });
1761
1761
  inst._zod.check = (payload) => {
1762
- const input2 = payload.value;
1762
+ const input = payload.value;
1763
1763
  if (isInt) {
1764
- if (!Number.isInteger(input2)) {
1764
+ if (!Number.isInteger(input)) {
1765
1765
  payload.issues.push({
1766
1766
  expected: origin,
1767
1767
  format: def.format,
1768
1768
  code: "invalid_type",
1769
1769
  continue: false,
1770
- input: input2,
1770
+ input,
1771
1771
  inst
1772
1772
  });
1773
1773
  return;
1774
1774
  }
1775
- if (!Number.isSafeInteger(input2)) {
1776
- if (input2 > 0) {
1775
+ if (!Number.isSafeInteger(input)) {
1776
+ if (input > 0) {
1777
1777
  payload.issues.push({
1778
- input: input2,
1778
+ input,
1779
1779
  code: "too_big",
1780
1780
  maximum: Number.MAX_SAFE_INTEGER,
1781
1781
  note: "Integers must be within the safe integer range.",
@@ -1785,7 +1785,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
1785
1785
  });
1786
1786
  } else {
1787
1787
  payload.issues.push({
1788
- input: input2,
1788
+ input,
1789
1789
  code: "too_small",
1790
1790
  minimum: Number.MIN_SAFE_INTEGER,
1791
1791
  note: "Integers must be within the safe integer range.",
@@ -1797,10 +1797,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
1797
1797
  return;
1798
1798
  }
1799
1799
  }
1800
- if (input2 < minimum) {
1800
+ if (input < minimum) {
1801
1801
  payload.issues.push({
1802
1802
  origin: "number",
1803
- input: input2,
1803
+ input,
1804
1804
  code: "too_small",
1805
1805
  minimum,
1806
1806
  inclusive: true,
@@ -1808,10 +1808,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
1808
1808
  continue: !def.abort
1809
1809
  });
1810
1810
  }
1811
- if (input2 > maximum) {
1811
+ if (input > maximum) {
1812
1812
  payload.issues.push({
1813
1813
  origin: "number",
1814
- input: input2,
1814
+ input,
1815
1815
  code: "too_big",
1816
1816
  maximum,
1817
1817
  inst
@@ -1829,11 +1829,11 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
1829
1829
  bag.maximum = maximum;
1830
1830
  });
1831
1831
  inst._zod.check = (payload) => {
1832
- const input2 = payload.value;
1833
- if (input2 < minimum) {
1832
+ const input = payload.value;
1833
+ if (input < minimum) {
1834
1834
  payload.issues.push({
1835
1835
  origin: "bigint",
1836
- input: input2,
1836
+ input,
1837
1837
  code: "too_small",
1838
1838
  minimum,
1839
1839
  inclusive: true,
@@ -1841,10 +1841,10 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
1841
1841
  continue: !def.abort
1842
1842
  });
1843
1843
  }
1844
- if (input2 > maximum) {
1844
+ if (input > maximum) {
1845
1845
  payload.issues.push({
1846
1846
  origin: "bigint",
1847
- input: input2,
1847
+ input,
1848
1848
  code: "too_big",
1849
1849
  maximum,
1850
1850
  inst
@@ -1865,16 +1865,16 @@ var $ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, d
1865
1865
  inst2._zod.bag.maximum = def.maximum;
1866
1866
  });
1867
1867
  inst._zod.check = (payload) => {
1868
- const input2 = payload.value;
1869
- const size = input2.size;
1868
+ const input = payload.value;
1869
+ const size = input.size;
1870
1870
  if (size <= def.maximum)
1871
1871
  return;
1872
1872
  payload.issues.push({
1873
- origin: getSizableOrigin(input2),
1873
+ origin: getSizableOrigin(input),
1874
1874
  code: "too_big",
1875
1875
  maximum: def.maximum,
1876
1876
  inclusive: true,
1877
- input: input2,
1877
+ input,
1878
1878
  inst,
1879
1879
  continue: !def.abort
1880
1880
  });
@@ -1893,16 +1893,16 @@ var $ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, d
1893
1893
  inst2._zod.bag.minimum = def.minimum;
1894
1894
  });
1895
1895
  inst._zod.check = (payload) => {
1896
- const input2 = payload.value;
1897
- const size = input2.size;
1896
+ const input = payload.value;
1897
+ const size = input.size;
1898
1898
  if (size >= def.minimum)
1899
1899
  return;
1900
1900
  payload.issues.push({
1901
- origin: getSizableOrigin(input2),
1901
+ origin: getSizableOrigin(input),
1902
1902
  code: "too_small",
1903
1903
  minimum: def.minimum,
1904
1904
  inclusive: true,
1905
- input: input2,
1905
+ input,
1906
1906
  inst,
1907
1907
  continue: !def.abort
1908
1908
  });
@@ -1922,13 +1922,13 @@ var $ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (i
1922
1922
  bag.size = def.size;
1923
1923
  });
1924
1924
  inst._zod.check = (payload) => {
1925
- const input2 = payload.value;
1926
- const size = input2.size;
1925
+ const input = payload.value;
1926
+ const size = input.size;
1927
1927
  if (size === def.size)
1928
1928
  return;
1929
1929
  const tooBig = size > def.size;
1930
1930
  payload.issues.push({
1931
- origin: getSizableOrigin(input2),
1931
+ origin: getSizableOrigin(input),
1932
1932
  ...tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
1933
1933
  inclusive: true,
1934
1934
  exact: true,
@@ -1951,17 +1951,17 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
1951
1951
  inst2._zod.bag.maximum = def.maximum;
1952
1952
  });
1953
1953
  inst._zod.check = (payload) => {
1954
- const input2 = payload.value;
1955
- const length = input2.length;
1954
+ const input = payload.value;
1955
+ const length = input.length;
1956
1956
  if (length <= def.maximum)
1957
1957
  return;
1958
- const origin = getLengthableOrigin(input2);
1958
+ const origin = getLengthableOrigin(input);
1959
1959
  payload.issues.push({
1960
1960
  origin,
1961
1961
  code: "too_big",
1962
1962
  maximum: def.maximum,
1963
1963
  inclusive: true,
1964
- input: input2,
1964
+ input,
1965
1965
  inst,
1966
1966
  continue: !def.abort
1967
1967
  });
@@ -1980,17 +1980,17 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
1980
1980
  inst2._zod.bag.minimum = def.minimum;
1981
1981
  });
1982
1982
  inst._zod.check = (payload) => {
1983
- const input2 = payload.value;
1984
- const length = input2.length;
1983
+ const input = payload.value;
1984
+ const length = input.length;
1985
1985
  if (length >= def.minimum)
1986
1986
  return;
1987
- const origin = getLengthableOrigin(input2);
1987
+ const origin = getLengthableOrigin(input);
1988
1988
  payload.issues.push({
1989
1989
  origin,
1990
1990
  code: "too_small",
1991
1991
  minimum: def.minimum,
1992
1992
  inclusive: true,
1993
- input: input2,
1993
+ input,
1994
1994
  inst,
1995
1995
  continue: !def.abort
1996
1996
  });
@@ -2010,11 +2010,11 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
2010
2010
  bag.length = def.length;
2011
2011
  });
2012
2012
  inst._zod.check = (payload) => {
2013
- const input2 = payload.value;
2014
- const length = input2.length;
2013
+ const input = payload.value;
2014
+ const length = input.length;
2015
2015
  if (length === def.length)
2016
2016
  return;
2017
- const origin = getLengthableOrigin(input2);
2017
+ const origin = getLengthableOrigin(input);
2018
2018
  const tooBig = length > def.length;
2019
2019
  payload.issues.push({
2020
2020
  origin,
@@ -2673,15 +2673,15 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
2673
2673
  payload.value = Number(payload.value);
2674
2674
  } catch (_) {
2675
2675
  }
2676
- const input2 = payload.value;
2677
- if (typeof input2 === "number" && !Number.isNaN(input2) && Number.isFinite(input2)) {
2676
+ const input = payload.value;
2677
+ if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
2678
2678
  return payload;
2679
2679
  }
2680
- const received = typeof input2 === "number" ? Number.isNaN(input2) ? "NaN" : !Number.isFinite(input2) ? "Infinity" : void 0 : void 0;
2680
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
2681
2681
  payload.issues.push({
2682
2682
  expected: "number",
2683
2683
  code: "invalid_type",
2684
- input: input2,
2684
+ input,
2685
2685
  inst,
2686
2686
  ...received ? { received } : {}
2687
2687
  });
@@ -2701,13 +2701,13 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
2701
2701
  payload.value = Boolean(payload.value);
2702
2702
  } catch (_) {
2703
2703
  }
2704
- const input2 = payload.value;
2705
- if (typeof input2 === "boolean")
2704
+ const input = payload.value;
2705
+ if (typeof input === "boolean")
2706
2706
  return payload;
2707
2707
  payload.issues.push({
2708
2708
  expected: "boolean",
2709
2709
  code: "invalid_type",
2710
- input: input2,
2710
+ input,
2711
2711
  inst
2712
2712
  });
2713
2713
  return payload;
@@ -2740,13 +2740,13 @@ var $ZodBigIntFormat = /* @__PURE__ */ $constructor("$ZodBigInt", (inst, def) =>
2740
2740
  var $ZodSymbol = /* @__PURE__ */ $constructor("$ZodSymbol", (inst, def) => {
2741
2741
  $ZodType.init(inst, def);
2742
2742
  inst._zod.parse = (payload, _ctx) => {
2743
- const input2 = payload.value;
2744
- if (typeof input2 === "symbol")
2743
+ const input = payload.value;
2744
+ if (typeof input === "symbol")
2745
2745
  return payload;
2746
2746
  payload.issues.push({
2747
2747
  expected: "symbol",
2748
2748
  code: "invalid_type",
2749
- input: input2,
2749
+ input,
2750
2750
  inst
2751
2751
  });
2752
2752
  return payload;
@@ -2759,13 +2759,13 @@ var $ZodUndefined = /* @__PURE__ */ $constructor("$ZodUndefined", (inst, def) =>
2759
2759
  inst._zod.optin = "optional";
2760
2760
  inst._zod.optout = "optional";
2761
2761
  inst._zod.parse = (payload, _ctx) => {
2762
- const input2 = payload.value;
2763
- if (typeof input2 === "undefined")
2762
+ const input = payload.value;
2763
+ if (typeof input === "undefined")
2764
2764
  return payload;
2765
2765
  payload.issues.push({
2766
2766
  expected: "undefined",
2767
2767
  code: "invalid_type",
2768
- input: input2,
2768
+ input,
2769
2769
  inst
2770
2770
  });
2771
2771
  return payload;
@@ -2776,13 +2776,13 @@ var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
2776
2776
  inst._zod.pattern = _null;
2777
2777
  inst._zod.values = /* @__PURE__ */ new Set([null]);
2778
2778
  inst._zod.parse = (payload, _ctx) => {
2779
- const input2 = payload.value;
2780
- if (input2 === null)
2779
+ const input = payload.value;
2780
+ if (input === null)
2781
2781
  return payload;
2782
2782
  payload.issues.push({
2783
2783
  expected: "null",
2784
2784
  code: "invalid_type",
2785
- input: input2,
2785
+ input,
2786
2786
  inst
2787
2787
  });
2788
2788
  return payload;
@@ -2811,13 +2811,13 @@ var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
2811
2811
  var $ZodVoid = /* @__PURE__ */ $constructor("$ZodVoid", (inst, def) => {
2812
2812
  $ZodType.init(inst, def);
2813
2813
  inst._zod.parse = (payload, _ctx) => {
2814
- const input2 = payload.value;
2815
- if (typeof input2 === "undefined")
2814
+ const input = payload.value;
2815
+ if (typeof input === "undefined")
2816
2816
  return payload;
2817
2817
  payload.issues.push({
2818
2818
  expected: "void",
2819
2819
  code: "invalid_type",
2820
- input: input2,
2820
+ input,
2821
2821
  inst
2822
2822
  });
2823
2823
  return payload;
@@ -2832,15 +2832,15 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
2832
2832
  } catch (_err) {
2833
2833
  }
2834
2834
  }
2835
- const input2 = payload.value;
2836
- const isDate = input2 instanceof Date;
2837
- const isValidDate = isDate && !Number.isNaN(input2.getTime());
2835
+ const input = payload.value;
2836
+ const isDate = input instanceof Date;
2837
+ const isValidDate = isDate && !Number.isNaN(input.getTime());
2838
2838
  if (isValidDate)
2839
2839
  return payload;
2840
2840
  payload.issues.push({
2841
2841
  expected: "date",
2842
2842
  code: "invalid_type",
2843
- input: input2,
2843
+ input,
2844
2844
  ...isDate ? { received: "Invalid Date" } : {},
2845
2845
  inst
2846
2846
  });
@@ -2856,20 +2856,20 @@ function handleArrayResult(result, final, index) {
2856
2856
  var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
2857
2857
  $ZodType.init(inst, def);
2858
2858
  inst._zod.parse = (payload, ctx) => {
2859
- const input2 = payload.value;
2860
- if (!Array.isArray(input2)) {
2859
+ const input = payload.value;
2860
+ if (!Array.isArray(input)) {
2861
2861
  payload.issues.push({
2862
2862
  expected: "array",
2863
2863
  code: "invalid_type",
2864
- input: input2,
2864
+ input,
2865
2865
  inst
2866
2866
  });
2867
2867
  return payload;
2868
2868
  }
2869
- payload.value = Array(input2.length);
2869
+ payload.value = Array(input.length);
2870
2870
  const proms = [];
2871
- for (let i = 0; i < input2.length; i++) {
2872
- const item = input2[i];
2871
+ for (let i = 0; i < input.length; i++) {
2872
+ const item = input[i];
2873
2873
  const result = def.element._zod.run({
2874
2874
  value: item,
2875
2875
  issues: []
@@ -2886,12 +2886,12 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
2886
2886
  return payload;
2887
2887
  };
2888
2888
  });
2889
- function handlePropertyResult(result, final, key, input2) {
2889
+ function handlePropertyResult(result, final, key, input) {
2890
2890
  if (result.issues.length) {
2891
2891
  final.issues.push(...prefixIssues(key, result.issues));
2892
2892
  }
2893
2893
  if (result.value === void 0) {
2894
- if (key in input2) {
2894
+ if (key in input) {
2895
2895
  final.value[key] = void 0;
2896
2896
  }
2897
2897
  } else {
@@ -2914,30 +2914,30 @@ function normalizeDef(def) {
2914
2914
  optionalKeys: new Set(okeys)
2915
2915
  };
2916
2916
  }
2917
- function handleCatchall(proms, input2, payload, ctx, def, inst) {
2917
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
2918
2918
  const unrecognized = [];
2919
2919
  const keySet = def.keySet;
2920
2920
  const _catchall = def.catchall._zod;
2921
2921
  const t = _catchall.def.type;
2922
- for (const key of Object.keys(input2)) {
2922
+ for (const key of Object.keys(input)) {
2923
2923
  if (keySet.has(key))
2924
2924
  continue;
2925
2925
  if (t === "never") {
2926
2926
  unrecognized.push(key);
2927
2927
  continue;
2928
2928
  }
2929
- const r = _catchall.run({ value: input2[key], issues: [] }, ctx);
2929
+ const r = _catchall.run({ value: input[key], issues: [] }, ctx);
2930
2930
  if (r instanceof Promise) {
2931
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2)));
2931
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
2932
2932
  } else {
2933
- handlePropertyResult(r, payload, key, input2);
2933
+ handlePropertyResult(r, payload, key, input);
2934
2934
  }
2935
2935
  }
2936
2936
  if (unrecognized.length) {
2937
2937
  payload.issues.push({
2938
2938
  code: "unrecognized_keys",
2939
2939
  keys: unrecognized,
2940
- input: input2,
2940
+ input,
2941
2941
  inst
2942
2942
  });
2943
2943
  }
@@ -2981,12 +2981,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
2981
2981
  let value;
2982
2982
  inst._zod.parse = (payload, ctx) => {
2983
2983
  value ?? (value = _normalized.value);
2984
- const input2 = payload.value;
2985
- if (!isObject2(input2)) {
2984
+ const input = payload.value;
2985
+ if (!isObject2(input)) {
2986
2986
  payload.issues.push({
2987
2987
  expected: "object",
2988
2988
  code: "invalid_type",
2989
- input: input2,
2989
+ input,
2990
2990
  inst
2991
2991
  });
2992
2992
  return payload;
@@ -2996,17 +2996,17 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
2996
2996
  const shape = value.shape;
2997
2997
  for (const key of value.keys) {
2998
2998
  const el = shape[key];
2999
- const r = el._zod.run({ value: input2[key], issues: [] }, ctx);
2999
+ const r = el._zod.run({ value: input[key], issues: [] }, ctx);
3000
3000
  if (r instanceof Promise) {
3001
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2)));
3001
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
3002
3002
  } else {
3003
- handlePropertyResult(r, payload, key, input2);
3003
+ handlePropertyResult(r, payload, key, input);
3004
3004
  }
3005
3005
  }
3006
3006
  if (!catchall) {
3007
3007
  return proms.length ? Promise.all(proms).then(() => payload) : payload;
3008
3008
  }
3009
- return handleCatchall(proms, input2, payload, ctx, _normalized.value, inst);
3009
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
3010
3010
  };
3011
3011
  });
3012
3012
  var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
@@ -3064,12 +3064,12 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3064
3064
  let value;
3065
3065
  inst._zod.parse = (payload, ctx) => {
3066
3066
  value ?? (value = _normalized.value);
3067
- const input2 = payload.value;
3068
- if (!isObject2(input2)) {
3067
+ const input = payload.value;
3068
+ if (!isObject2(input)) {
3069
3069
  payload.issues.push({
3070
3070
  expected: "object",
3071
3071
  code: "invalid_type",
3072
- input: input2,
3072
+ input,
3073
3073
  inst
3074
3074
  });
3075
3075
  return payload;
@@ -3080,7 +3080,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3080
3080
  payload = fastpass(payload, ctx);
3081
3081
  if (!catchall)
3082
3082
  return payload;
3083
- return handleCatchall([], input2, payload, ctx, value, inst);
3083
+ return handleCatchall([], input, payload, ctx, value, inst);
3084
3084
  }
3085
3085
  return superParse(payload, ctx);
3086
3086
  };
@@ -3187,17 +3187,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
3187
3187
  return map2;
3188
3188
  });
3189
3189
  inst._zod.parse = (payload, ctx) => {
3190
- const input2 = payload.value;
3191
- if (!isObject(input2)) {
3190
+ const input = payload.value;
3191
+ if (!isObject(input)) {
3192
3192
  payload.issues.push({
3193
3193
  code: "invalid_type",
3194
3194
  expected: "object",
3195
- input: input2,
3195
+ input,
3196
3196
  inst
3197
3197
  });
3198
3198
  return payload;
3199
3199
  }
3200
- const opt = disc.value.get(input2?.[def.discriminator]);
3200
+ const opt = disc.value.get(input?.[def.discriminator]);
3201
3201
  if (opt) {
3202
3202
  return opt._zod.run(payload, ctx);
3203
3203
  }
@@ -3209,7 +3209,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
3209
3209
  errors: [],
3210
3210
  note: "No matching discriminator",
3211
3211
  discriminator: def.discriminator,
3212
- input: input2,
3212
+ input,
3213
3213
  path: [def.discriminator],
3214
3214
  inst
3215
3215
  });
@@ -3219,9 +3219,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
3219
3219
  var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
3220
3220
  $ZodType.init(inst, def);
3221
3221
  inst._zod.parse = (payload, ctx) => {
3222
- const input2 = payload.value;
3223
- const left = def.left._zod.run({ value: input2, issues: [] }, ctx);
3224
- const right = def.right._zod.run({ value: input2, issues: [] }, ctx);
3222
+ const input = payload.value;
3223
+ const left = def.left._zod.run({ value: input, issues: [] }, ctx);
3224
+ const right = def.right._zod.run({ value: input, issues: [] }, ctx);
3225
3225
  const async = left instanceof Promise || right instanceof Promise;
3226
3226
  if (async) {
3227
3227
  return Promise.all([left, right]).then(([left2, right2]) => {
@@ -3296,10 +3296,10 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
3296
3296
  const items = def.items;
3297
3297
  const optStart = items.length - [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
3298
3298
  inst._zod.parse = (payload, ctx) => {
3299
- const input2 = payload.value;
3300
- if (!Array.isArray(input2)) {
3299
+ const input = payload.value;
3300
+ if (!Array.isArray(input)) {
3301
3301
  payload.issues.push({
3302
- input: input2,
3302
+ input,
3303
3303
  inst,
3304
3304
  expected: "tuple",
3305
3305
  code: "invalid_type"
@@ -3309,12 +3309,12 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
3309
3309
  payload.value = [];
3310
3310
  const proms = [];
3311
3311
  if (!def.rest) {
3312
- const tooBig = input2.length > items.length;
3313
- const tooSmall = input2.length < optStart - 1;
3312
+ const tooBig = input.length > items.length;
3313
+ const tooSmall = input.length < optStart - 1;
3314
3314
  if (tooBig || tooSmall) {
3315
3315
  payload.issues.push({
3316
3316
  ...tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length },
3317
- input: input2,
3317
+ input,
3318
3318
  inst,
3319
3319
  origin: "array"
3320
3320
  });
@@ -3324,12 +3324,12 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
3324
3324
  let i = -1;
3325
3325
  for (const item of items) {
3326
3326
  i++;
3327
- if (i >= input2.length) {
3327
+ if (i >= input.length) {
3328
3328
  if (i >= optStart)
3329
3329
  continue;
3330
3330
  }
3331
3331
  const result = item._zod.run({
3332
- value: input2[i],
3332
+ value: input[i],
3333
3333
  issues: []
3334
3334
  }, ctx);
3335
3335
  if (result instanceof Promise) {
@@ -3339,7 +3339,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
3339
3339
  }
3340
3340
  }
3341
3341
  if (def.rest) {
3342
- const rest = input2.slice(items.length);
3342
+ const rest = input.slice(items.length);
3343
3343
  for (const el of rest) {
3344
3344
  i++;
3345
3345
  const result = def.rest._zod.run({
@@ -3367,12 +3367,12 @@ function handleTupleResult(result, final, index) {
3367
3367
  var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
3368
3368
  $ZodType.init(inst, def);
3369
3369
  inst._zod.parse = (payload, ctx) => {
3370
- const input2 = payload.value;
3371
- if (!isPlainObject(input2)) {
3370
+ const input = payload.value;
3371
+ if (!isPlainObject(input)) {
3372
3372
  payload.issues.push({
3373
3373
  expected: "record",
3374
3374
  code: "invalid_type",
3375
- input: input2,
3375
+ input,
3376
3376
  inst
3377
3377
  });
3378
3378
  return payload;
@@ -3383,7 +3383,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
3383
3383
  payload.value = {};
3384
3384
  for (const key of values) {
3385
3385
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
3386
- const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
3386
+ const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
3387
3387
  if (result instanceof Promise) {
3388
3388
  proms.push(result.then((result2) => {
3389
3389
  if (result2.issues.length) {
@@ -3400,7 +3400,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
3400
3400
  }
3401
3401
  }
3402
3402
  let unrecognized;
3403
- for (const key in input2) {
3403
+ for (const key in input) {
3404
3404
  if (!values.has(key)) {
3405
3405
  unrecognized = unrecognized ?? [];
3406
3406
  unrecognized.push(key);
@@ -3409,14 +3409,14 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
3409
3409
  if (unrecognized && unrecognized.length > 0) {
3410
3410
  payload.issues.push({
3411
3411
  code: "unrecognized_keys",
3412
- input: input2,
3412
+ input,
3413
3413
  inst,
3414
3414
  keys: unrecognized
3415
3415
  });
3416
3416
  }
3417
3417
  } else {
3418
3418
  payload.value = {};
3419
- for (const key of Reflect.ownKeys(input2)) {
3419
+ for (const key of Reflect.ownKeys(input)) {
3420
3420
  if (key === "__proto__")
3421
3421
  continue;
3422
3422
  const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
@@ -3435,7 +3435,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
3435
3435
  payload.value[keyResult.value] = keyResult.value;
3436
3436
  continue;
3437
3437
  }
3438
- const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
3438
+ const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
3439
3439
  if (result instanceof Promise) {
3440
3440
  proms.push(result.then((result2) => {
3441
3441
  if (result2.issues.length) {
@@ -3460,27 +3460,27 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
3460
3460
  var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
3461
3461
  $ZodType.init(inst, def);
3462
3462
  inst._zod.parse = (payload, ctx) => {
3463
- const input2 = payload.value;
3464
- if (!(input2 instanceof Map)) {
3463
+ const input = payload.value;
3464
+ if (!(input instanceof Map)) {
3465
3465
  payload.issues.push({
3466
3466
  expected: "map",
3467
3467
  code: "invalid_type",
3468
- input: input2,
3468
+ input,
3469
3469
  inst
3470
3470
  });
3471
3471
  return payload;
3472
3472
  }
3473
3473
  const proms = [];
3474
3474
  payload.value = /* @__PURE__ */ new Map();
3475
- for (const [key, value] of input2) {
3475
+ for (const [key, value] of input) {
3476
3476
  const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
3477
3477
  const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx);
3478
3478
  if (keyResult instanceof Promise || valueResult instanceof Promise) {
3479
3479
  proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
3480
- handleMapResult(keyResult2, valueResult2, payload, key, input2, inst, ctx);
3480
+ handleMapResult(keyResult2, valueResult2, payload, key, input, inst, ctx);
3481
3481
  }));
3482
3482
  } else {
3483
- handleMapResult(keyResult, valueResult, payload, key, input2, inst, ctx);
3483
+ handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
3484
3484
  }
3485
3485
  }
3486
3486
  if (proms.length)
@@ -3488,7 +3488,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
3488
3488
  return payload;
3489
3489
  };
3490
3490
  });
3491
- function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx) {
3491
+ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
3492
3492
  if (keyResult.issues.length) {
3493
3493
  if (propertyKeyTypes.has(typeof key)) {
3494
3494
  final.issues.push(...prefixIssues(key, keyResult.issues));
@@ -3496,7 +3496,7 @@ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx)
3496
3496
  final.issues.push({
3497
3497
  code: "invalid_key",
3498
3498
  origin: "map",
3499
- input: input2,
3499
+ input,
3500
3500
  inst,
3501
3501
  issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
3502
3502
  });
@@ -3509,7 +3509,7 @@ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx)
3509
3509
  final.issues.push({
3510
3510
  origin: "map",
3511
3511
  code: "invalid_element",
3512
- input: input2,
3512
+ input,
3513
3513
  inst,
3514
3514
  key,
3515
3515
  issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
@@ -3521,10 +3521,10 @@ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx)
3521
3521
  var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
3522
3522
  $ZodType.init(inst, def);
3523
3523
  inst._zod.parse = (payload, ctx) => {
3524
- const input2 = payload.value;
3525
- if (!(input2 instanceof Set)) {
3524
+ const input = payload.value;
3525
+ if (!(input instanceof Set)) {
3526
3526
  payload.issues.push({
3527
- input: input2,
3527
+ input,
3528
3528
  inst,
3529
3529
  expected: "set",
3530
3530
  code: "invalid_type"
@@ -3533,7 +3533,7 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
3533
3533
  }
3534
3534
  const proms = [];
3535
3535
  payload.value = /* @__PURE__ */ new Set();
3536
- for (const item of input2) {
3536
+ for (const item of input) {
3537
3537
  const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
3538
3538
  if (result instanceof Promise) {
3539
3539
  proms.push(result.then((result2) => handleSetResult(result2, payload)));
@@ -3558,14 +3558,14 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
3558
3558
  inst._zod.values = valuesSet;
3559
3559
  inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
3560
3560
  inst._zod.parse = (payload, _ctx) => {
3561
- const input2 = payload.value;
3562
- if (valuesSet.has(input2)) {
3561
+ const input = payload.value;
3562
+ if (valuesSet.has(input)) {
3563
3563
  return payload;
3564
3564
  }
3565
3565
  payload.issues.push({
3566
3566
  code: "invalid_value",
3567
3567
  values,
3568
- input: input2,
3568
+ input,
3569
3569
  inst
3570
3570
  });
3571
3571
  return payload;
@@ -3579,14 +3579,14 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
3579
3579
  inst._zod.values = new Set(def.values);
3580
3580
  inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
3581
3581
  inst._zod.parse = (payload, _ctx) => {
3582
- const input2 = payload.value;
3583
- if (inst._zod.values.has(input2)) {
3582
+ const input = payload.value;
3583
+ if (inst._zod.values.has(input)) {
3584
3584
  return payload;
3585
3585
  }
3586
3586
  payload.issues.push({
3587
3587
  code: "invalid_value",
3588
3588
  values: def.values,
3589
- input: input2,
3589
+ input,
3590
3590
  inst
3591
3591
  });
3592
3592
  return payload;
@@ -3595,13 +3595,13 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
3595
3595
  var $ZodFile = /* @__PURE__ */ $constructor("$ZodFile", (inst, def) => {
3596
3596
  $ZodType.init(inst, def);
3597
3597
  inst._zod.parse = (payload, _ctx) => {
3598
- const input2 = payload.value;
3599
- if (input2 instanceof File)
3598
+ const input = payload.value;
3599
+ if (input instanceof File)
3600
3600
  return payload;
3601
3601
  payload.issues.push({
3602
3602
  expected: "file",
3603
3603
  code: "invalid_type",
3604
- input: input2,
3604
+ input,
3605
3605
  inst
3606
3606
  });
3607
3607
  return payload;
@@ -3628,8 +3628,8 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
3628
3628
  return payload;
3629
3629
  };
3630
3630
  });
3631
- function handleOptionalResult(result, input2) {
3632
- if (result.issues.length && input2 === void 0) {
3631
+ function handleOptionalResult(result, input) {
3632
+ if (result.issues.length && input === void 0) {
3633
3633
  return { issues: [], value: void 0 };
3634
3634
  }
3635
3635
  return result;
@@ -4057,20 +4057,20 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
4057
4057
  return payload;
4058
4058
  };
4059
4059
  inst._zod.check = (payload) => {
4060
- const input2 = payload.value;
4061
- const r = def.fn(input2);
4060
+ const input = payload.value;
4061
+ const r = def.fn(input);
4062
4062
  if (r instanceof Promise) {
4063
- return r.then((r2) => handleRefineResult(r2, payload, input2, inst));
4063
+ return r.then((r2) => handleRefineResult(r2, payload, input, inst));
4064
4064
  }
4065
- handleRefineResult(r, payload, input2, inst);
4065
+ handleRefineResult(r, payload, input, inst);
4066
4066
  return;
4067
4067
  };
4068
4068
  });
4069
- function handleRefineResult(result, payload, input2, inst) {
4069
+ function handleRefineResult(result, payload, input, inst) {
4070
4070
  if (!result) {
4071
4071
  const _iss = {
4072
4072
  code: "custom",
4073
- input: input2,
4073
+ input,
4074
4074
  inst,
4075
4075
  // incorporates params.error into issue reporting
4076
4076
  path: [...inst._zod.def.path ?? []],
@@ -10385,16 +10385,16 @@ function _overwrite(tx) {
10385
10385
  });
10386
10386
  }
10387
10387
  function _normalize(form) {
10388
- return _overwrite((input2) => input2.normalize(form));
10388
+ return _overwrite((input) => input.normalize(form));
10389
10389
  }
10390
10390
  function _trim() {
10391
- return _overwrite((input2) => input2.trim());
10391
+ return _overwrite((input) => input.trim());
10392
10392
  }
10393
10393
  function _toLowerCase() {
10394
- return _overwrite((input2) => input2.toLowerCase());
10394
+ return _overwrite((input) => input.toLowerCase());
10395
10395
  }
10396
10396
  function _toUpperCase() {
10397
- return _overwrite((input2) => input2.toUpperCase());
10397
+ return _overwrite((input) => input.toUpperCase());
10398
10398
  }
10399
10399
  function _array(Class2, element, params) {
10400
10400
  return new Class2({
@@ -10636,8 +10636,8 @@ function _stringbool(Classes, _params) {
10636
10636
  type: "pipe",
10637
10637
  in: stringSchema,
10638
10638
  out: booleanSchema,
10639
- transform: ((input2, payload) => {
10640
- let data = input2;
10639
+ transform: ((input, payload) => {
10640
+ let data = input;
10641
10641
  if (params.case !== "sensitive")
10642
10642
  data = data.toLowerCase();
10643
10643
  if (truthySet.has(data)) {
@@ -10656,8 +10656,8 @@ function _stringbool(Classes, _params) {
10656
10656
  return {};
10657
10657
  }
10658
10658
  }),
10659
- reverseTransform: ((input2, _payload) => {
10660
- if (input2 === true) {
10659
+ reverseTransform: ((input, _payload) => {
10660
+ if (input === true) {
10661
10661
  return truthyArray[0] || "true";
10662
10662
  } else {
10663
10663
  return falsyArray[0] || "false";
@@ -11368,21 +11368,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11368
11368
  }
11369
11369
  }
11370
11370
  };
11371
- function toJSONSchema(input2, _params) {
11372
- if (input2 instanceof $ZodRegistry) {
11371
+ function toJSONSchema(input, _params) {
11372
+ if (input instanceof $ZodRegistry) {
11373
11373
  const gen2 = new JSONSchemaGenerator(_params);
11374
11374
  const defs = {};
11375
- for (const entry of input2._idmap.entries()) {
11375
+ for (const entry of input._idmap.entries()) {
11376
11376
  const [_, schema] = entry;
11377
11377
  gen2.process(schema);
11378
11378
  }
11379
11379
  const schemas = {};
11380
11380
  const external = {
11381
- registry: input2,
11381
+ registry: input,
11382
11382
  uri: _params?.uri,
11383
11383
  defs
11384
11384
  };
11385
- for (const entry of input2._idmap.entries()) {
11385
+ for (const entry of input._idmap.entries()) {
11386
11386
  const [key, schema] = entry;
11387
11387
  schemas[key] = gen2.emit(schema, {
11388
11388
  ..._params,
@@ -11398,8 +11398,8 @@ function toJSONSchema(input2, _params) {
11398
11398
  return { schemas };
11399
11399
  }
11400
11400
  const gen = new JSONSchemaGenerator(_params);
11401
- gen.process(input2);
11402
- return gen.emit(input2, _params);
11401
+ gen.process(input);
11402
+ return gen.emit(input, _params);
11403
11403
  }
11404
11404
  function isTransforming(_schema, _ctx) {
11405
11405
  const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
@@ -18278,6 +18278,39 @@ function generateAccessibilityMetadata(scale2) {
18278
18278
  }
18279
18279
  return metadata;
18280
18280
  }
18281
+ var CONTRAST_WHITE = { l: 1, c: 0, h: 0, alpha: 1 };
18282
+ var CONTRAST_BLACK = { l: 0, c: 0, h: 0, alpha: 1 };
18283
+ var WCAG_AA_NORMAL = 4.5;
18284
+ var WCAG_AAA_NORMAL = 7;
18285
+ function assembleWcagAccessibility(scale2, reference) {
18286
+ const meta = generateAccessibilityMetadata([...scale2]);
18287
+ const onWhiteRatio = calculateWCAGContrast(reference, CONTRAST_WHITE);
18288
+ const onBlackRatio = calculateWCAGContrast(reference, CONTRAST_BLACK);
18289
+ return {
18290
+ wcagAA: meta.wcagAA,
18291
+ wcagAAA: meta.wcagAAA,
18292
+ onWhite: {
18293
+ wcagAA: onWhiteRatio >= WCAG_AA_NORMAL,
18294
+ wcagAAA: onWhiteRatio >= WCAG_AAA_NORMAL,
18295
+ contrastRatio: onWhiteRatio,
18296
+ aa: meta.onWhite.aa,
18297
+ aaa: meta.onWhite.aaa
18298
+ },
18299
+ onBlack: {
18300
+ wcagAA: onBlackRatio >= WCAG_AA_NORMAL,
18301
+ wcagAAA: onBlackRatio >= WCAG_AAA_NORMAL,
18302
+ contrastRatio: onBlackRatio,
18303
+ aa: meta.onBlack.aa,
18304
+ aaa: meta.onBlack.aaa
18305
+ }
18306
+ };
18307
+ }
18308
+ function rebakeAccessibility(value) {
18309
+ if (!("scale" in value) || !Array.isArray(value.scale)) return value;
18310
+ const reference = value.scale[5] ?? value.scale[0];
18311
+ if (!reference) return value;
18312
+ return { ...value, accessibility: assembleWcagAccessibility(value.scale, reference) };
18313
+ }
18281
18314
 
18282
18315
  // ../color-utils/src/analysis.ts
18283
18316
  function isLightColor(color) {
@@ -18394,94 +18427,6 @@ function generateHarmony(baseColor) {
18394
18427
  monochromatic
18395
18428
  };
18396
18429
  }
18397
- function generateSemanticColorSuggestions(baseColor) {
18398
- const danger = [
18399
- roundOKLCH({
18400
- l: Math.max(0.55, Math.min(0.7, baseColor.l + 0.1)),
18401
- c: Math.min(0.25, baseColor.c * 1.2),
18402
- h: 15,
18403
- alpha: 1
18404
- }),
18405
- roundOKLCH({
18406
- l: Math.max(0.6, Math.min(0.75, baseColor.l + 0.15)),
18407
- c: Math.min(0.22, baseColor.c * 1.1),
18408
- h: 25,
18409
- alpha: 1
18410
- }),
18411
- roundOKLCH({
18412
- l: Math.max(0.5, Math.min(0.65, baseColor.l + 0.05)),
18413
- c: Math.min(0.23, baseColor.c * 1.15),
18414
- h: 5,
18415
- alpha: 1
18416
- })
18417
- ];
18418
- const success2 = [
18419
- roundOKLCH({
18420
- l: Math.max(0.6, Math.min(0.75, baseColor.l + 0.15)),
18421
- c: Math.min(0.2, baseColor.c * 0.9),
18422
- h: 135,
18423
- alpha: 1
18424
- }),
18425
- roundOKLCH({
18426
- l: Math.max(0.55, Math.min(0.7, baseColor.l + 0.1)),
18427
- c: Math.min(0.22, baseColor.c * 1),
18428
- h: 145,
18429
- alpha: 1
18430
- }),
18431
- roundOKLCH({
18432
- l: Math.max(0.65, Math.min(0.8, baseColor.l + 0.2)),
18433
- c: Math.min(0.24, baseColor.c * 1.1),
18434
- h: 125,
18435
- alpha: 1
18436
- })
18437
- ];
18438
- const warning = [
18439
- roundOKLCH({
18440
- l: Math.max(0.7, Math.min(0.8, baseColor.l + 0.15)),
18441
- c: Math.min(0.2, baseColor.c * 0.95),
18442
- h: 45,
18443
- alpha: 1
18444
- }),
18445
- roundOKLCH({
18446
- l: Math.max(0.75, Math.min(0.85, baseColor.l + 0.2)),
18447
- c: Math.min(0.18, baseColor.c * 0.9),
18448
- h: 55,
18449
- alpha: 1
18450
- }),
18451
- roundOKLCH({
18452
- l: Math.max(0.72, Math.min(0.82, baseColor.l + 0.17)),
18453
- c: Math.min(0.19, baseColor.c * 0.92),
18454
- h: 35,
18455
- alpha: 1
18456
- })
18457
- ];
18458
- const info = [
18459
- roundOKLCH({
18460
- l: Math.max(0.6, Math.min(0.75, baseColor.l + 0.1)),
18461
- c: Math.min(0.2, baseColor.c * 0.9),
18462
- h: 220,
18463
- alpha: 1
18464
- }),
18465
- roundOKLCH({
18466
- l: Math.max(0.55, Math.min(0.7, baseColor.l + 0.05)),
18467
- c: Math.min(0.22, baseColor.c * 1),
18468
- h: 230,
18469
- alpha: 1
18470
- }),
18471
- roundOKLCH({
18472
- l: Math.max(0.5, Math.min(0.65, baseColor.l)),
18473
- c: Math.min(0.25, baseColor.c * 1.1),
18474
- h: 240,
18475
- alpha: 1
18476
- })
18477
- ];
18478
- return {
18479
- danger: danger.map(clampColor),
18480
- success: success2.map(clampColor),
18481
- warning: warning.map(clampColor),
18482
- info: info.map(clampColor)
18483
- };
18484
- }
18485
18430
  function validateScaleGeneration(baseColor) {
18486
18431
  const l = baseColor.l;
18487
18432
  if (l > 0.85) {
@@ -21213,44 +21158,256 @@ var POSITION_TO_INDEX = SCALE_POSITIONS.reduce(
21213
21158
  },
21214
21159
  {}
21215
21160
  );
21216
- var MIN_WCAG_PAIR_DISTANCE = 3;
21217
- function findBestWcagPair(sourceIndex, pairs, wantHigher) {
21218
- let best;
21219
- let bestDistance = -1;
21161
+
21162
+ // ../color-utils/src/semantic.ts
21163
+ var SemanticSelectionError = class extends Error {
21164
+ constructor(familyName, message) {
21165
+ super(`semantic selection: family "${familyName}" ${message}`);
21166
+ this.familyName = familyName;
21167
+ this.name = "SemanticSelectionError";
21168
+ }
21169
+ };
21170
+ var STATE_USES = ["hover", "active", "focus", "disabled"];
21171
+ var STATE_RANK_STEP = {
21172
+ hover: (rank, _l, s) => rank + s,
21173
+ active: (rank, _l, s) => rank + 2 * s,
21174
+ focus: (rank, _l, s) => rank + s,
21175
+ disabled: (_rank, ladder) => closestRankTo(ladder, 5)
21176
+ };
21177
+ function partnerForBase(pairs, base) {
21178
+ if (!pairs) return void 0;
21179
+ for (const [p1, p2] of pairs) {
21180
+ if (p1 === base) return p2;
21181
+ if (p2 === base) return p1;
21182
+ }
21183
+ return void 0;
21184
+ }
21185
+ function nearestPartner(pairs, base) {
21186
+ if (!pairs || pairs.length === 0) return void 0;
21187
+ const anchors = /* @__PURE__ */ new Set();
21188
+ for (const pair of pairs) {
21189
+ for (const position of pair) anchors.add(position);
21190
+ }
21191
+ let nearest = -1;
21192
+ let bestDistance = Number.POSITIVE_INFINITY;
21193
+ for (const anchor of anchors) {
21194
+ const distance2 = Math.abs(anchor - base);
21195
+ if (distance2 < bestDistance) {
21196
+ bestDistance = distance2;
21197
+ nearest = anchor;
21198
+ }
21199
+ }
21200
+ return nearest === -1 ? void 0 : partnerForBase(pairs, nearest);
21201
+ }
21202
+ function collectLadder(pairs) {
21203
+ const positions = /* @__PURE__ */ new Set();
21220
21204
  for (const pair of pairs) {
21221
- if (!pair || pair.length < 2) continue;
21222
- const [a2, b2] = pair;
21223
- if (a2 === void 0 || b2 === void 0) continue;
21224
- let partner;
21225
- if (a2 === sourceIndex) partner = b2;
21226
- else if (b2 === sourceIndex) partner = a2;
21227
- else continue;
21228
- if (wantHigher && partner <= sourceIndex) continue;
21229
- if (!wantHigher && partner >= sourceIndex) continue;
21230
- const distance2 = Math.abs(partner - sourceIndex);
21231
- if (distance2 > bestDistance) {
21205
+ for (const position of pair) positions.add(position);
21206
+ }
21207
+ return Array.from(positions).sort((a2, b2) => a2 - b2);
21208
+ }
21209
+ function closestRankTo(ladder, target) {
21210
+ let bestRank = 0;
21211
+ let bestDistance = Number.POSITIVE_INFINITY;
21212
+ for (let rank = 0; rank < ladder.length; rank++) {
21213
+ const position = ladder[rank];
21214
+ if (position === void 0) continue;
21215
+ const distance2 = Math.abs(position - target);
21216
+ if (distance2 < bestDistance) {
21232
21217
  bestDistance = distance2;
21233
- best = partner;
21218
+ bestRank = rank;
21234
21219
  }
21235
21220
  }
21236
- return best;
21221
+ return bestRank;
21237
21222
  }
21238
- function findDarkCounterpartIndex(lightIndex, colorValue) {
21239
- const aaaPairs = colorValue.accessibility?.wcagAAA?.normal ?? [];
21240
- const aaPairs = colorValue.accessibility?.wcagAA?.normal ?? [];
21241
- if (aaaPairs.length === 0 && aaPairs.length === 0) {
21242
- throw new Error(
21243
- `No WCAG accessibility data available for dark mode counterpart of index ${lightIndex}. ColorValue must include accessibility.wcagAAA or wcagAA pair matrices.`
21244
- );
21223
+ function requirePosition(index, familyName) {
21224
+ const position = SCALE_POSITIONS[index];
21225
+ if (!position) {
21226
+ throw new SemanticSelectionError(familyName, `produced invalid scale index ${index}`);
21245
21227
  }
21246
- const wantHigher = lightIndex <= 5;
21247
- for (const pairs of [aaaPairs, aaPairs]) {
21248
- const match = findBestWcagPair(lightIndex, pairs, wantHigher);
21249
- if (match !== void 0 && Math.abs(match - lightIndex) >= MIN_WCAG_PAIR_DISTANCE) {
21250
- return match;
21228
+ return position;
21229
+ }
21230
+ function requireIndex(position, familyName) {
21231
+ const index = POSITION_TO_INDEX[position];
21232
+ if (index === void 0) {
21233
+ throw new SemanticSelectionError(familyName, `has no scale position "${position}"`);
21234
+ }
21235
+ return index;
21236
+ }
21237
+ var STATUS_ROLE_ANCHORS = {
21238
+ // band is the recognizability range a variant may never leave;
21239
+ // [min > max] means the band wraps through 0 (destructive: 330..360..30).
21240
+ destructive: { hue: 25, l: 0.55, cCap: 0.2, cScale: 1, band: [330, 30] },
21241
+ success: { hue: 145, l: 0.55, cCap: 0.18, cScale: 0.9, band: [120, 160] },
21242
+ warning: { hue: 85, l: 0.75, cCap: 0.18, cScale: 0.9, band: [60, 110] },
21243
+ info: { hue: 230, l: 0.58, cCap: 0.15, cScale: 0.85, band: [200, 250] }
21244
+ };
21245
+ function statusAnchor(role, seed) {
21246
+ const spec = STATUS_ROLE_ANCHORS[role];
21247
+ return roundOKLCH({
21248
+ l: spec.l,
21249
+ c: Math.min(spec.cCap, seed.c * spec.cScale),
21250
+ h: spec.hue,
21251
+ alpha: seed.alpha ?? 1
21252
+ });
21253
+ }
21254
+ function clampHueToBand(hue, band) {
21255
+ const h = (hue % 360 + 360) % 360;
21256
+ const [min, max2] = band;
21257
+ if (min <= max2) return Math.max(min, Math.min(max2, h));
21258
+ if (h >= min || h <= max2) return h;
21259
+ const toMin = Math.abs(h - min);
21260
+ const toMax = Math.abs(h - max2);
21261
+ return toMin < toMax ? min : max2;
21262
+ }
21263
+ var VARIANT_OFFSETS = [
21264
+ { dh: 0, dl: 0 },
21265
+ { dh: 10, dl: 0.05 },
21266
+ { dh: -10, dl: -0.05 }
21267
+ ];
21268
+ function generateSemanticColorSuggestions(baseColor) {
21269
+ const roles = {};
21270
+ for (const role of Object.keys(STATUS_ROLE_ANCHORS)) {
21271
+ const anchor = statusAnchor(role, baseColor);
21272
+ const { band } = STATUS_ROLE_ANCHORS[role];
21273
+ roles[role] = VARIANT_OFFSETS.map(({ dh, dl }) => {
21274
+ const raw = roundOKLCH({
21275
+ l: Math.max(0, Math.min(1, anchor.l + dl)),
21276
+ c: anchor.c,
21277
+ h: clampHueToBand(anchor.h + dh, band),
21278
+ alpha: anchor.alpha ?? 1
21279
+ });
21280
+ return roundOKLCH(toNearestGamut(raw).color);
21281
+ });
21282
+ }
21283
+ return { ...roles, danger: roles.destructive };
21284
+ }
21285
+ function semanticFor(family, options) {
21286
+ const familyName = options?.name ?? family.name;
21287
+ const refs = family;
21288
+ const aaaPairs = family.accessibility?.wcagAAA?.normal;
21289
+ const aaPairs = family.accessibility?.wcagAA?.normal;
21290
+ function foregroundPair(from, level) {
21291
+ const auto = refs.foregroundReferences?.auto;
21292
+ if (auto) {
21293
+ return {
21294
+ from: { family: familyName, position: from },
21295
+ to: { family: auto.family, position: auto.position },
21296
+ standard: level,
21297
+ tier: "reference"
21298
+ };
21299
+ }
21300
+ const base = requireIndex(from, familyName);
21301
+ const exactAAA = partnerForBase(aaaPairs, base);
21302
+ const aaa = exactAAA ?? nearestPartner(aaaPairs, base);
21303
+ const exactAA = partnerForBase(aaPairs, base);
21304
+ const aa = exactAA ?? nearestPartner(aaPairs, base);
21305
+ const partner = level === "AAA" ? aaa ?? aa : aa;
21306
+ if (partner === void 0) {
21307
+ throw new SemanticSelectionError(
21308
+ familyName,
21309
+ `has no WCAG pair partner for position ${from} (accessibility metadata required)`
21310
+ );
21311
+ }
21312
+ const fromAAA = level === "AAA" && aaa !== void 0;
21313
+ return {
21314
+ from: { family: familyName, position: from },
21315
+ to: { family: familyName, position: requirePosition(partner, familyName) },
21316
+ standard: fromAAA ? "AAA" : "AA",
21317
+ tier: (fromAAA ? exactAAA : exactAA) !== void 0 ? "pair-exact" : "pair-nearest"
21318
+ };
21319
+ }
21320
+ function statePair(use, from, dark) {
21321
+ const precomputed = refs.stateReferences?.[use];
21322
+ if (precomputed) {
21323
+ return {
21324
+ from: { family: familyName, position: from },
21325
+ to: { family: precomputed.family, position: String(precomputed.position) },
21326
+ standard: "AAA",
21327
+ tier: "reference"
21328
+ };
21329
+ }
21330
+ if (!aaaPairs || aaaPairs.length === 0) {
21331
+ throw new SemanticSelectionError(
21332
+ familyName,
21333
+ "has no accessibility.wcagAAA.normal ladder (color generator must emit accessibility metadata)"
21334
+ );
21335
+ }
21336
+ const base = requireIndex(from, familyName);
21337
+ const ladder = collectLadder(aaaPairs);
21338
+ const baseRank = closestRankTo(ladder, base);
21339
+ const sign = dark ? -1 : 1;
21340
+ const targetRank = STATE_RANK_STEP[use](baseRank, ladder, sign);
21341
+ const clampedRank = Math.max(0, Math.min(ladder.length - 1, targetRank));
21342
+ const targetIndex = ladder[clampedRank];
21343
+ if (targetIndex === void 0) {
21344
+ throw new SemanticSelectionError(familyName, `ladder lookup failed at rank ${clampedRank}`);
21251
21345
  }
21346
+ return {
21347
+ from: { family: familyName, position: from },
21348
+ to: { family: familyName, position: requirePosition(targetIndex, familyName) },
21349
+ standard: "AAA",
21350
+ tier: "ladder"
21351
+ };
21352
+ }
21353
+ function invert(pair) {
21354
+ if (pair.to.family !== familyName && pair.tier !== "reference") {
21355
+ throw new SemanticSelectionError(
21356
+ familyName,
21357
+ `cannot invert a pair whose legs belong to "${pair.from.family}"/"${pair.to.family}"`
21358
+ );
21359
+ }
21360
+ const fromTarget = 10 - requireIndex(pair.from.position, familyName);
21361
+ const toIndex = POSITION_TO_INDEX[pair.to.position];
21362
+ const toTarget = toIndex === void 0 ? void 0 : 10 - toIndex;
21363
+ for (const [pairs, standard] of [
21364
+ [aaaPairs, "AAA"],
21365
+ [aaPairs, "AA"]
21366
+ ]) {
21367
+ if (!pairs || pairs.length === 0) continue;
21368
+ let best = null;
21369
+ for (const [p1, p2] of pairs) {
21370
+ if (p1 === void 0 || p2 === void 0) continue;
21371
+ for (const [a2, b2] of [
21372
+ [p1, p2],
21373
+ [p2, p1]
21374
+ ]) {
21375
+ const fromDist = Math.abs(a2 - fromTarget);
21376
+ const toDist = toTarget === void 0 ? 0 : Math.abs(b2 - toTarget);
21377
+ const better = best === null || fromDist < best.fromDist || fromDist === best.fromDist && toDist < best.toDist || fromDist === best.fromDist && toDist === best.toDist && a2 < best.from;
21378
+ if (better) best = { from: a2, to: b2, fromDist, toDist };
21379
+ }
21380
+ }
21381
+ if (best) {
21382
+ return {
21383
+ from: { family: familyName, position: requirePosition(best.from, familyName) },
21384
+ to: { family: familyName, position: requirePosition(best.to, familyName) },
21385
+ standard,
21386
+ tier: best.fromDist === 0 && best.toDist === 0 ? "pair-exact" : "pair-nearest"
21387
+ };
21388
+ }
21389
+ }
21390
+ const toFallback = toTarget === void 0 ? fromTarget : toTarget;
21391
+ return {
21392
+ from: { family: familyName, position: requirePosition(fromTarget, familyName) },
21393
+ to: { family: familyName, position: requirePosition(toFallback, familyName) },
21394
+ standard: "none",
21395
+ tier: "inversion"
21396
+ };
21252
21397
  }
21253
- return Math.max(0, Math.min(10, 10 - lightIndex));
21398
+ return {
21399
+ pair(request) {
21400
+ const level = request.level ?? "AAA";
21401
+ if (request.use === "foreground") return foregroundPair(request.from, level);
21402
+ return statePair(request.use, request.from, request.dark);
21403
+ },
21404
+ states(from, dark) {
21405
+ const out = {};
21406
+ for (const use of STATE_USES) out[use] = statePair(use, from, dark);
21407
+ return out;
21408
+ },
21409
+ invert
21410
+ };
21254
21411
  }
21255
21412
 
21256
21413
  // ../color-utils/src/builder.ts
@@ -21262,9 +21419,7 @@ function buildColorValue(oklch2, options = {}) {
21262
21419
  (v) => v !== void 0
21263
21420
  );
21264
21421
  const harmony = generateHarmony(oklch2);
21265
- const accessibilityMeta = generateAccessibilityMetadata(scale2);
21266
- const contrastOnWhite = calculateWCAGContrast(oklch2, WHITE);
21267
- const contrastOnBlack = calculateWCAGContrast(oklch2, BLACK);
21422
+ const wcagAccessibility = assembleWcagAccessibility(scale2, oklch2);
21268
21423
  const apcaOnWhite = calculateAPCAContrast(oklch2, WHITE);
21269
21424
  const apcaOnBlack = calculateAPCAContrast(oklch2, BLACK);
21270
21425
  const temperature = getColorTemperature(oklch2);
@@ -21293,22 +21448,7 @@ function buildColorValue(oklch2, options = {}) {
21293
21448
  },
21294
21449
  // Accessibility
21295
21450
  accessibility: {
21296
- wcagAA: accessibilityMeta.wcagAA,
21297
- wcagAAA: accessibilityMeta.wcagAAA,
21298
- onWhite: {
21299
- wcagAA: contrastOnWhite >= 4.5,
21300
- wcagAAA: contrastOnWhite >= 7,
21301
- contrastRatio: contrastOnWhite,
21302
- aa: accessibilityMeta.onWhite.aa,
21303
- aaa: accessibilityMeta.onWhite.aaa
21304
- },
21305
- onBlack: {
21306
- wcagAA: contrastOnBlack >= 4.5,
21307
- wcagAAA: contrastOnBlack >= 7,
21308
- contrastRatio: contrastOnBlack,
21309
- aa: accessibilityMeta.onBlack.aa,
21310
- aaa: accessibilityMeta.onBlack.aaa
21311
- },
21451
+ ...wcagAccessibility,
21312
21452
  apca: {
21313
21453
  onWhite: apcaOnWhite,
21314
21454
  onBlack: apcaOnBlack,
@@ -21375,6 +21515,10 @@ var ComponentCategorySchema = external_exports.object({
21375
21515
  description: external_exports.string().optional()
21376
21516
  });
21377
21517
 
21518
+ // ../shared/src/fill-signature.ts
21519
+ var RESERVED_FILL_SEGMENTS = ["to", "via", "from"];
21520
+ var SEPARATOR = `-${RESERVED_FILL_SEGMENTS[0]}-`;
21521
+
21378
21522
  // ../shared/src/types.ts
21379
21523
  var COMPUTED = Symbol.for(
21380
21524
  "rafters.computed"
@@ -21603,12 +21747,22 @@ var PerceptualWeightSchema = external_exports.object({
21603
21747
  density: external_exports.enum(["light", "medium", "heavy"]),
21604
21748
  balancingRecommendation: external_exports.string()
21605
21749
  });
21606
- var SemanticColorSuggestionsSchema = external_exports.object({
21607
- danger: external_exports.array(OKLCHSchema),
21608
- success: external_exports.array(OKLCHSchema),
21609
- warning: external_exports.array(OKLCHSchema),
21610
- info: external_exports.array(OKLCHSchema)
21611
- });
21750
+ var SemanticColorSuggestionsSchema = external_exports.preprocess(
21751
+ (raw) => {
21752
+ if (raw && typeof raw === "object" && !("destructive" in raw) && "danger" in raw) {
21753
+ return { ...raw, destructive: raw.danger };
21754
+ }
21755
+ return raw;
21756
+ },
21757
+ external_exports.object({
21758
+ destructive: external_exports.array(OKLCHSchema),
21759
+ success: external_exports.array(OKLCHSchema),
21760
+ warning: external_exports.array(OKLCHSchema),
21761
+ info: external_exports.array(OKLCHSchema),
21762
+ /** @deprecated mirror of `destructive`; dies when apps/api leaves the repo */
21763
+ danger: external_exports.array(OKLCHSchema).optional()
21764
+ })
21765
+ );
21612
21766
  var ColorValueSchema = external_exports.object({
21613
21767
  name: external_exports.string(),
21614
21768
  // the fancy name from color-utils, IE ocean-blue
@@ -22250,10 +22404,8 @@ function groupTokens(tokens) {
22250
22404
  depth: [],
22251
22405
  motion: [],
22252
22406
  breakpoint: [],
22253
- elevation: [],
22254
22407
  focus: [],
22255
22408
  "typography-composite": [],
22256
- fill: [],
22257
22409
  other: []
22258
22410
  };
22259
22411
  for (const token of tokens) {
@@ -22285,18 +22437,12 @@ function groupTokens(tokens) {
22285
22437
  case "breakpoint":
22286
22438
  groups.breakpoint.push(token);
22287
22439
  break;
22288
- case "elevation":
22289
- groups.elevation.push(token);
22290
- break;
22291
22440
  case "focus":
22292
22441
  groups.focus.push(token);
22293
22442
  break;
22294
22443
  case "typography-composite":
22295
22444
  groups["typography-composite"].push(token);
22296
22445
  break;
22297
- case "fill":
22298
- groups.fill.push(token);
22299
- break;
22300
22446
  default:
22301
22447
  groups.other.push(token);
22302
22448
  }
@@ -22449,14 +22595,6 @@ function generateThemeBlock(groups) {
22449
22595
  }
22450
22596
  lines.push("");
22451
22597
  }
22452
- if (groups.elevation.length > 0) {
22453
- for (const token of groups.elevation) {
22454
- const value = tokenValueToCSS(token);
22455
- if (value === null) continue;
22456
- lines.push(` --${token.name}: ${value};`);
22457
- }
22458
- lines.push("");
22459
- }
22460
22598
  if (groups.focus.length > 0) {
22461
22599
  for (const token of groups.focus) {
22462
22600
  const value = tokenValueToCSS(token);
@@ -22465,13 +22603,6 @@ function generateThemeBlock(groups) {
22465
22603
  }
22466
22604
  lines.push("");
22467
22605
  }
22468
- if (groups.fill.length > 0) {
22469
- for (const token of groups.fill) {
22470
- const value = typeof token.value === "string" ? token.value : JSON.stringify(token.value);
22471
- lines.push(` --${token.name}: ${value};`);
22472
- }
22473
- lines.push("");
22474
- }
22475
22606
  if (groups.other.length > 0) {
22476
22607
  for (const token of groups.other) {
22477
22608
  const value = tokenValueToCSS(token);
@@ -22586,6 +22717,17 @@ function generateAnimationTokens(motionTokens) {
22586
22717
  }
22587
22718
  return lines.join("\n");
22588
22719
  }
22720
+ function generateDepthUtilities(depthTokens) {
22721
+ if (depthTokens.length === 0) return "";
22722
+ const lines = ["/* Depth (z-index) utilities -- words over numbers */"];
22723
+ for (const token of depthTokens) {
22724
+ if (typeof token.value !== "string" || !/^-?\d+$/.test(token.value)) continue;
22725
+ lines.push(`@utility z-${token.name} {`);
22726
+ lines.push(` z-index: var(--${token.name});`);
22727
+ lines.push("}");
22728
+ }
22729
+ return lines.join("\n");
22730
+ }
22589
22731
  function generateTypographyCompositeUtilities(compositeTokens) {
22590
22732
  if (compositeTokens.length === 0) {
22591
22733
  return "";
@@ -22703,6 +22845,11 @@ function tokensToTailwind(tokens, options = {}, typographyOverrides = []) {
22703
22845
  sections.push("");
22704
22846
  sections.push(typographyUtilities);
22705
22847
  }
22848
+ const depthUtilities = generateDepthUtilities(groups.depth);
22849
+ if (depthUtilities) {
22850
+ sections.push("");
22851
+ sections.push(depthUtilities);
22852
+ }
22706
22853
  const overrideCSS = generateTypographyOverrideCSS(typographyOverrides);
22707
22854
  if (overrideCSS) {
22708
22855
  sections.push("");
@@ -22805,14 +22952,6 @@ function generateVarsRootBlock(groups) {
22805
22952
  }
22806
22953
  lines.push("");
22807
22954
  }
22808
- if (groups.elevation.length > 0) {
22809
- for (const token of groups.elevation) {
22810
- const value = tokenValueToCSS(token);
22811
- if (value === null) continue;
22812
- lines.push(` --rafters-${token.name}: ${value};`);
22813
- }
22814
- lines.push("");
22815
- }
22816
22955
  if (groups.focus.length > 0) {
22817
22956
  for (const token of groups.focus) {
22818
22957
  const value = tokenValueToCSS(token);
@@ -22821,13 +22960,6 @@ function generateVarsRootBlock(groups) {
22821
22960
  }
22822
22961
  lines.push("");
22823
22962
  }
22824
- if (groups.fill.length > 0) {
22825
- for (const token of groups.fill) {
22826
- const value = typeof token.value === "string" ? token.value : JSON.stringify(token.value);
22827
- lines.push(` --rafters-${token.name}: ${value};`);
22828
- }
22829
- lines.push("");
22830
- }
22831
22963
  if (groups.other.length > 0) {
22832
22964
  for (const token of groups.other) {
22833
22965
  const value = tokenValueToCSS(token);
@@ -23143,15 +23275,6 @@ var DEPTH_LEVELS = [
23143
23275
  "tooltip",
23144
23276
  "overlay"
23145
23277
  ];
23146
- var ELEVATION_LEVELS = [
23147
- "surface",
23148
- "raised",
23149
- "overlay",
23150
- "sticky",
23151
- "modal",
23152
- "popover",
23153
- "tooltip"
23154
- ];
23155
23278
  var MOTION_DURATION_SCALE = ["instant", "fast", "normal", "slow", "slower"];
23156
23279
  var EASING_CURVES = [
23157
23280
  "linear",
@@ -23426,8 +23549,8 @@ function generateColorTokens(_config, colorScales) {
23426
23549
  }
23427
23550
  var WHITE2 = { l: 1, c: 0, h: 0, alpha: 1 };
23428
23551
  var BLACK2 = { l: 0, c: 0, h: 0, alpha: 1 };
23429
- var WCAG_AA_NORMAL = 4.5;
23430
- var WCAG_AAA_NORMAL = 7;
23552
+ var WCAG_AA_NORMAL2 = 4.5;
23553
+ var WCAG_AAA_NORMAL2 = 7;
23431
23554
  var FAMILY_REFERENCE_INDEX = 5;
23432
23555
  function buildColorAccessibility(scale2) {
23433
23556
  const meta = generateAccessibilityMetadata(scale2);
@@ -23441,15 +23564,15 @@ function buildColorAccessibility(scale2) {
23441
23564
  wcagAA: meta.wcagAA,
23442
23565
  wcagAAA: meta.wcagAAA,
23443
23566
  onWhite: {
23444
- wcagAA: onWhiteRatio >= WCAG_AA_NORMAL,
23445
- wcagAAA: onWhiteRatio >= WCAG_AAA_NORMAL,
23567
+ wcagAA: onWhiteRatio >= WCAG_AA_NORMAL2,
23568
+ wcagAAA: onWhiteRatio >= WCAG_AAA_NORMAL2,
23446
23569
  contrastRatio: onWhiteRatio,
23447
23570
  aa: meta.onWhite.aa,
23448
23571
  aaa: meta.onWhite.aaa
23449
23572
  },
23450
23573
  onBlack: {
23451
- wcagAA: onBlackRatio >= WCAG_AA_NORMAL,
23452
- wcagAAA: onBlackRatio >= WCAG_AAA_NORMAL,
23574
+ wcagAA: onBlackRatio >= WCAG_AA_NORMAL2,
23575
+ wcagAAA: onBlackRatio >= WCAG_AAA_NORMAL2,
23453
23576
  contrastRatio: onBlackRatio,
23454
23577
  aa: meta.onBlack.aa,
23455
23578
  aaa: meta.onBlack.aaa
@@ -23584,7 +23707,9 @@ var DEFAULT_DEPTH_DEFINITIONS = {
23584
23707
  stackingContext: false
23585
23708
  },
23586
23709
  dropdown: {
23587
- value: 10,
23710
+ // The shadcn menu-content band (z-50): menu content must beat sticky
23711
+ // chrome and survive opening inside a dialog; DOM order breaks ties.
23712
+ value: 50,
23588
23713
  meaning: "Dropdown menus and select options",
23589
23714
  contexts: ["dropdowns", "select-menus", "autocomplete"],
23590
23715
  stackingContext: true
@@ -23626,7 +23751,9 @@ var DEFAULT_DEPTH_DEFINITIONS = {
23626
23751
  stackingContext: true
23627
23752
  },
23628
23753
  overlay: {
23629
- value: 70,
23754
+ // Backdrops dim BEHIND the modal they serve: below modal (40), above
23755
+ // fixed chrome (30) so the dim still covers sticky/fixed elements.
23756
+ value: 35,
23630
23757
  meaning: "Overlay backdrops - screen-dimming layers behind modals",
23631
23758
  contexts: ["modal-backdrop", "drawer-backdrop", "sheet-backdrop"],
23632
23759
  stackingContext: true
@@ -23728,109 +23855,6 @@ var DEFAULT_SHADOW_DEFINITIONS = {
23728
23855
  contexts: ["critical-modals", "overlays", "drawer-panels"]
23729
23856
  }
23730
23857
  };
23731
- var DEFAULT_FILL_DEFINITIONS = {
23732
- surface: {
23733
- color: "neutral-900",
23734
- foreground: "neutral-100",
23735
- meaning: "Primary content surface",
23736
- contexts: ["surface"]
23737
- },
23738
- panel: {
23739
- color: "neutral-800",
23740
- opacity: 0.95,
23741
- foreground: "neutral-100",
23742
- meaning: "Elevated panel",
23743
- contexts: ["surface"]
23744
- },
23745
- overlay: {
23746
- color: "neutral-950",
23747
- opacity: 0.8,
23748
- backdropBlur: "sm",
23749
- foreground: "neutral-50",
23750
- meaning: "Modal backdrop",
23751
- contexts: ["surface"]
23752
- },
23753
- glass: {
23754
- color: "neutral-900",
23755
- opacity: 0.6,
23756
- backdropBlur: "md",
23757
- foreground: "neutral-100",
23758
- meaning: "Glass morphism",
23759
- contexts: ["surface"]
23760
- },
23761
- primary: {
23762
- color: "primary",
23763
- foreground: "primary-foreground",
23764
- meaning: "Primary brand surface",
23765
- contexts: ["surface", "text"]
23766
- },
23767
- muted: {
23768
- color: "muted",
23769
- foreground: "muted-foreground",
23770
- meaning: "Subdued surface for secondary content",
23771
- contexts: ["surface"]
23772
- },
23773
- hero: {
23774
- gradient: {
23775
- direction: "to-b",
23776
- stops: [{ color: "primary" }, { color: "primary", opacity: 0 }]
23777
- },
23778
- foreground: "primary-foreground",
23779
- meaning: "Hero fade gradient",
23780
- contexts: ["surface", "text"]
23781
- }
23782
- };
23783
- var DEFAULT_ELEVATION_DEFINITIONS = {
23784
- surface: {
23785
- depth: "depth-base",
23786
- shadow: "shadow-none",
23787
- meaning: "Surface level - flat, in-flow elements",
23788
- contexts: ["page-content", "inline-elements", "flat-cards"],
23789
- useCase: "Default level for content that doesn't need elevation"
23790
- },
23791
- raised: {
23792
- depth: "depth-base",
23793
- shadow: "shadow-sm",
23794
- meaning: "Slightly raised - subtle depth without z-index change",
23795
- contexts: ["cards", "panels", "list-items"],
23796
- useCase: "Cards and containers that need subtle visual separation"
23797
- },
23798
- overlay: {
23799
- depth: "depth-dropdown",
23800
- shadow: "shadow",
23801
- meaning: "Overlay level - dropdowns and menus",
23802
- contexts: ["dropdowns", "select-menus", "autocomplete", "context-menus"],
23803
- useCase: "Elements that appear over content but aren't blocking"
23804
- },
23805
- sticky: {
23806
- depth: "depth-sticky",
23807
- shadow: "shadow-md",
23808
- meaning: "Sticky level - persistent navigation",
23809
- contexts: ["sticky-header", "sticky-sidebar", "floating-nav"],
23810
- useCase: "Elements that stick to viewport edges during scroll"
23811
- },
23812
- modal: {
23813
- depth: "depth-modal",
23814
- shadow: "shadow-lg",
23815
- meaning: "Modal level - blocking dialogs",
23816
- contexts: ["modals", "dialogs", "sheets", "drawers"],
23817
- useCase: "Elements that block interaction with content below"
23818
- },
23819
- popover: {
23820
- depth: "depth-popover",
23821
- shadow: "shadow-xl",
23822
- meaning: "Popover level - above modals",
23823
- contexts: ["popovers", "nested-dialogs", "command-palette"],
23824
- useCase: "Elements that can appear above modals (rare)"
23825
- },
23826
- tooltip: {
23827
- depth: "depth-tooltip",
23828
- shadow: "shadow-lg",
23829
- meaning: "Tooltip level - highest common UI",
23830
- contexts: ["tooltips", "toast-notifications", "snackbars"],
23831
- useCase: "Transient information that appears above everything"
23832
- }
23833
- };
23834
23858
  var DEFAULT_DURATION_DEFINITIONS = {
23835
23859
  instant: {
23836
23860
  step: "instant",
@@ -24308,7 +24332,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
24308
24332
  // Card surfaces
24309
24333
  card: {
24310
24334
  light: { family: "neutral", position: "50" },
24311
- dark: { family: "neutral", position: "950" },
24335
+ dark: { family: "neutral", position: "700" },
24312
24336
  meaning: "Card and contained surface background",
24313
24337
  contexts: ["cards", "modals", "dialogs", "panels"],
24314
24338
  do: ["Use for elevated surfaces"],
@@ -24324,7 +24348,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
24324
24348
  },
24325
24349
  "card-hover": {
24326
24350
  light: { family: "neutral", position: "100" },
24327
- dark: { family: "neutral", position: "900" },
24351
+ dark: { family: "neutral", position: "600" },
24328
24352
  meaning: "Card hover state background",
24329
24353
  contexts: ["card-hover"],
24330
24354
  do: ["Use for card hover states"],
@@ -24332,16 +24356,48 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
24332
24356
  },
24333
24357
  "card-border": {
24334
24358
  light: { family: "neutral", position: "200" },
24335
- dark: { family: "neutral", position: "800" },
24359
+ dark: { family: "neutral", position: "500" },
24336
24360
  meaning: "Card border color",
24337
24361
  contexts: ["card-borders"],
24338
24362
  do: ["Use for card borders"],
24339
24363
  never: ["Use for dividers within cards"]
24340
24364
  },
24365
+ panel: {
24366
+ light: { family: "neutral", position: "100" },
24367
+ dark: { family: "neutral", position: "800" },
24368
+ meaning: "Elevated panel surface -- one level above the page",
24369
+ contexts: ["panels", "toolbars", "headers", "docks"],
24370
+ do: ["Use for persistent elevated chrome", "Pair with panel-foreground"],
24371
+ never: ["Use for page-level backgrounds", "Stack directly on card without a border"]
24372
+ },
24373
+ "panel-foreground": {
24374
+ light: { family: "neutral", position: "950" },
24375
+ dark: { family: "neutral", position: "50" },
24376
+ meaning: "Text and icons on panel surfaces",
24377
+ contexts: ["panel-text"],
24378
+ do: ["Use on panel backgrounds"],
24379
+ never: ["Use on page background"]
24380
+ },
24381
+ "panel-hover": {
24382
+ light: { family: "neutral", position: "200" },
24383
+ dark: { family: "neutral", position: "700" },
24384
+ meaning: "Panel surface hover state",
24385
+ contexts: ["panel-interaction"],
24386
+ do: ["Use for hoverable panel regions"],
24387
+ never: ["Use as a resting surface"]
24388
+ },
24389
+ "panel-border": {
24390
+ light: { family: "neutral", position: "200" },
24391
+ dark: { family: "neutral", position: "600" },
24392
+ meaning: "Borders separating panel from surrounding surfaces",
24393
+ contexts: ["panel-edges"],
24394
+ do: ["Use to delimit panels"],
24395
+ never: ["Use as text color"]
24396
+ },
24341
24397
  // Popover surfaces
24342
24398
  popover: {
24343
24399
  light: { family: "neutral", position: "50" },
24344
- dark: { family: "neutral", position: "950" },
24400
+ dark: { family: "neutral", position: "700" },
24345
24401
  meaning: "Popover and dropdown background",
24346
24402
  contexts: ["dropdowns", "tooltips", "menus"],
24347
24403
  do: ["Use for floating elements"],
@@ -25456,7 +25512,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
25456
25512
  // ============================================================================
25457
25513
  sidebar: {
25458
25514
  light: { family: "neutral", position: "50" },
25459
- dark: { family: "neutral", position: "950" },
25515
+ dark: { family: "neutral", position: "900" },
25460
25516
  meaning: "Sidebar background",
25461
25517
  contexts: ["navigation-sidebar", "side-panels"],
25462
25518
  do: ["Use for sidebar backgrounds"],
@@ -25544,7 +25600,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
25544
25600
  },
25545
25601
  "sidebar-item": {
25546
25602
  light: { family: "neutral", position: "50" },
25547
- dark: { family: "neutral", position: "950" },
25603
+ dark: { family: "neutral", position: "900" },
25548
25604
  meaning: "Sidebar item background",
25549
25605
  contexts: ["sidebar-items"],
25550
25606
  do: ["Use for sidebar item backgrounds"],
@@ -25627,7 +25683,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
25627
25683
  // ============================================================================
25628
25684
  nav: {
25629
25685
  light: { family: "neutral", position: "50" },
25630
- dark: { family: "neutral", position: "950" },
25686
+ dark: { family: "neutral", position: "900" },
25631
25687
  meaning: "Navigation background",
25632
25688
  contexts: ["navbars", "breadcrumbs", "tabs"],
25633
25689
  do: ["Use for navigation backgrounds"],
@@ -25726,7 +25782,7 @@ var DEFAULT_SEMANTIC_COLOR_MAPPINGS = {
25726
25782
  },
25727
25783
  "table-header": {
25728
25784
  light: { family: "neutral", position: "100" },
25729
- dark: { family: "neutral", position: "900" },
25785
+ dark: { family: "neutral", position: "800" },
25730
25786
  meaning: "Table header background",
25731
25787
  contexts: ["table-headers"],
25732
25788
  do: ["Use for table header backgrounds"],
@@ -26061,187 +26117,6 @@ function generateDepthTokens(_config, depthDefs) {
26061
26117
  };
26062
26118
  }
26063
26119
 
26064
- // ../design-tokens/src/generators/elevation.ts
26065
- function generateElevationTokens(_config, elevationDefs) {
26066
- const tokens = [];
26067
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
26068
- for (const level of ELEVATION_LEVELS) {
26069
- const def = elevationDefs[level];
26070
- if (!def) continue;
26071
- const scaleIndex = ELEVATION_LEVELS.indexOf(level);
26072
- tokens.push({
26073
- name: `elevation-${level}`,
26074
- value: JSON.stringify({
26075
- depth: `var(--${def.depth})`,
26076
- shadow: `var(--${def.shadow})`
26077
- }),
26078
- category: "elevation",
26079
- namespace: "elevation",
26080
- semanticMeaning: def.meaning,
26081
- usageContext: def.contexts,
26082
- scalePosition: scaleIndex,
26083
- elevationLevel: level,
26084
- shadowToken: def.shadow,
26085
- dependsOn: [def.depth, def.shadow],
26086
- description: `${def.useCase}. Combines ${def.depth} with ${def.shadow}.`,
26087
- generatedAt: timestamp,
26088
- containerQueryAware: false,
26089
- userOverride: null,
26090
- usagePatterns: {
26091
- do: [
26092
- `Use for ${def.contexts.slice(0, 2).join(", ")}`,
26093
- "Apply both z-index and shadow together"
26094
- ],
26095
- never: [
26096
- "Mix elevation levels within same component",
26097
- "Use without considering stacking context"
26098
- ]
26099
- }
26100
- });
26101
- tokens.push({
26102
- name: `elevation-${level}-z`,
26103
- value: `var(--${def.depth})`,
26104
- category: "elevation",
26105
- namespace: "elevation",
26106
- semanticMeaning: `Z-index component of ${level} elevation`,
26107
- dependsOn: [def.depth],
26108
- description: `Z-index for ${level} elevation level.`,
26109
- generatedAt: timestamp,
26110
- containerQueryAware: false,
26111
- userOverride: null
26112
- });
26113
- tokens.push({
26114
- name: `elevation-${level}-shadow`,
26115
- value: `var(--${def.shadow})`,
26116
- category: "elevation",
26117
- namespace: "elevation",
26118
- semanticMeaning: `Shadow component of ${level} elevation`,
26119
- dependsOn: [def.shadow],
26120
- description: `Shadow for ${level} elevation level.`,
26121
- generatedAt: timestamp,
26122
- containerQueryAware: false,
26123
- userOverride: null
26124
- });
26125
- }
26126
- tokens.push({
26127
- name: "elevation-scale",
26128
- value: JSON.stringify({
26129
- levels: Object.fromEntries(
26130
- Object.entries(elevationDefs).map(([k, v]) => [k, { depth: v.depth, shadow: v.shadow }])
26131
- ),
26132
- note: "Each elevation level pairs z-index with appropriate shadow"
26133
- }),
26134
- category: "elevation",
26135
- namespace: "elevation",
26136
- semanticMeaning: "Elevation scale reference",
26137
- description: "Complete elevation scale showing depth/shadow pairings.",
26138
- generatedAt: timestamp,
26139
- containerQueryAware: false,
26140
- userOverride: null
26141
- });
26142
- return {
26143
- namespace: "elevation",
26144
- tokens
26145
- };
26146
- }
26147
-
26148
- // ../design-tokens/src/generators/fill.ts
26149
- function validateFillDef(name, def) {
26150
- if (!def.color && !def.gradient) {
26151
- return `Fill "${name}" must have either a color or gradient field`;
26152
- }
26153
- if (def.gradient) {
26154
- if (!def.gradient.stops || def.gradient.stops.length < 2) {
26155
- return `Fill "${name}" gradient must have at least 2 stops`;
26156
- }
26157
- }
26158
- if (def.opacity !== void 0 && (def.opacity < 0 || def.opacity > 1)) {
26159
- return `Fill "${name}" opacity must be between 0 and 1`;
26160
- }
26161
- const validBlurSizes = ["sm", "md", "lg", "xl", "2xl", "3xl"];
26162
- if (def.backdropBlur && !validBlurSizes.includes(def.backdropBlur)) {
26163
- return `Fill "${name}" backdropBlur must be one of: ${validBlurSizes.join(", ")}`;
26164
- }
26165
- return null;
26166
- }
26167
- function serializeFillValue(def) {
26168
- const parts = {};
26169
- if (def.color) parts.color = def.color;
26170
- if (def.opacity !== void 0) parts.opacity = def.opacity;
26171
- if (def.foreground) parts.foreground = def.foreground;
26172
- if (def.backdropBlur) parts.backdropBlur = def.backdropBlur;
26173
- if (def.gradient) parts.gradient = def.gradient;
26174
- return JSON.stringify(parts);
26175
- }
26176
- function generateFillTokens(_config, fillDefinitions) {
26177
- const tokens = [];
26178
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
26179
- const fillNames = Object.keys(fillDefinitions);
26180
- for (const [name, def] of Object.entries(fillDefinitions)) {
26181
- const error47 = validateFillDef(name, def);
26182
- if (error47) {
26183
- throw new Error(error47);
26184
- }
26185
- const dependsOn = [];
26186
- if (def.color) {
26187
- dependsOn.push(def.color);
26188
- }
26189
- if (def.foreground) {
26190
- dependsOn.push(def.foreground);
26191
- }
26192
- if (def.gradient) {
26193
- for (const stop of def.gradient.stops) {
26194
- dependsOn.push(stop.color);
26195
- }
26196
- }
26197
- tokens.push({
26198
- name: `fill-${name}`,
26199
- value: serializeFillValue(def),
26200
- category: "fill",
26201
- namespace: "fill",
26202
- semanticMeaning: def.meaning,
26203
- usageContext: def.contexts,
26204
- dependsOn: dependsOn.length > 0 ? dependsOn : void 0,
26205
- description: buildDescription(name, def),
26206
- generatedAt: timestamp,
26207
- containerQueryAware: true,
26208
- scalePosition: fillNames.indexOf(name),
26209
- userOverride: null,
26210
- usagePatterns: {
26211
- do: [
26212
- `Use fill="${name}" on surface components (Container, Card) for ${def.meaning.toLowerCase()}`,
26213
- ...def.gradient ? [`Use color="${name}" on Typography for gradient text effect`] : []
26214
- ],
26215
- never: [
26216
- "Do not use raw bg-* classes when a fill token exists for the purpose",
26217
- "Do not hardcode opacity values -- use the fill token instead"
26218
- ]
26219
- }
26220
- });
26221
- }
26222
- return {
26223
- namespace: "fill",
26224
- tokens
26225
- };
26226
- }
26227
- function buildDescription(name, def) {
26228
- const parts = [`Fill token "${name}"`];
26229
- if (def.color && def.opacity !== void 0 && def.opacity < 1) {
26230
- parts.push(`-- ${def.color} at ${Math.round(def.opacity * 100)}% opacity`);
26231
- } else if (def.color) {
26232
- parts.push(`-- solid ${def.color}`);
26233
- }
26234
- if (def.backdropBlur) {
26235
- parts.push(`with backdrop-blur-${def.backdropBlur}`);
26236
- }
26237
- if (def.gradient) {
26238
- const stops = def.gradient.stops.map((s) => s.color).join(" to ");
26239
- parts.push(`-- gradient ${def.gradient.direction}: ${stops}`);
26240
- }
26241
- parts.push(`(${def.meaning})`);
26242
- return parts.join(" ");
26243
- }
26244
-
26245
26120
  // ../design-tokens/src/generators/focus.ts
26246
26121
  function pxToRem(px) {
26247
26122
  const rem = Math.round(px / 16 * 1e3) / 1e3;
@@ -27297,19 +27172,6 @@ function generateRadiusTokens(config2, radiusDefs) {
27297
27172
  }
27298
27173
 
27299
27174
  // ../design-tokens/src/generators/semantic.ts
27300
- var POSITION_TO_INDEX2 = {
27301
- "50": 0,
27302
- "100": 1,
27303
- "200": 2,
27304
- "300": 3,
27305
- "400": 4,
27306
- "500": 5,
27307
- "600": 6,
27308
- "700": 7,
27309
- "800": 8,
27310
- "900": 9,
27311
- "950": 10
27312
- };
27313
27175
  var FOREGROUND_SUFFIXES = ["-foreground", "-text", "-contrast"];
27314
27176
  var STATE_SUFFIXES = ["-hover", "-active", "-focus", "-disabled"];
27315
27177
  function toColorRef(mapping) {
@@ -27339,7 +27201,7 @@ function deriveDerivation(name, lightRef, knownTokens) {
27339
27201
  }
27340
27202
  }
27341
27203
  }
27342
- const scalePosition = POSITION_TO_INDEX2[lightRef.position];
27204
+ const scalePosition = POSITION_TO_INDEX[lightRef.position];
27343
27205
  if (scalePosition === void 0) {
27344
27206
  throw new Error(
27345
27207
  `semantic generator: token "${name}" has unknown scale position "${lightRef.position}"`
@@ -27376,13 +27238,20 @@ function derivationParent(derivation, suffix = "") {
27376
27238
  return `${derivation.against}${suffix}`;
27377
27239
  }
27378
27240
  }
27379
- function deriveDarkBinding(derivation) {
27241
+ function deriveDarkBinding(derivation, parentName, darkRef) {
27380
27242
  switch (derivation.kind) {
27381
- case "scale":
27243
+ case "scale": {
27244
+ const scalePosition = POSITION_TO_INDEX[darkRef.position];
27245
+ if (scalePosition === void 0) {
27246
+ throw new Error(
27247
+ `semantic generator: invalid designed dark position "${darkRef.position}" for ${parentName}`
27248
+ );
27249
+ }
27382
27250
  return {
27383
- plugin: "invert",
27384
- input: { familyName: derivation.family, basePosition: derivation.scalePosition }
27251
+ plugin: "scale",
27252
+ input: { familyName: darkRef.family, scalePosition }
27385
27253
  };
27254
+ }
27386
27255
  case "state":
27387
27256
  return {
27388
27257
  plugin: "state",
@@ -27406,7 +27275,7 @@ function generateSemanticTokens(_config) {
27406
27275
  const binding = derivationToBinding(derivation);
27407
27276
  const parent = derivationParent(derivation);
27408
27277
  const darkName = `${name}--dark`;
27409
- const darkBinding = deriveDarkBinding(derivation);
27278
+ const darkBinding = deriveDarkBinding(derivation, name, darkRef);
27410
27279
  const darkParent = derivationParent(derivation, "--dark");
27411
27280
  const dependsOn = [parent, darkName];
27412
27281
  tokens.push({
@@ -28094,14 +27963,6 @@ function createGeneratorDefs(colorPaletteBases) {
28094
27963
  DEFAULT_DELAY_DEFINITIONS
28095
27964
  )
28096
27965
  },
28097
- {
28098
- name: "fill",
28099
- generate: (_config) => generateFillTokens(_config, DEFAULT_FILL_DEFINITIONS)
28100
- },
28101
- {
28102
- name: "elevation",
28103
- generate: (config2) => generateElevationTokens(config2, DEFAULT_ELEVATION_DEFINITIONS)
28104
- },
28105
27966
  {
28106
27967
  name: "focus",
28107
27968
  generate: (config2) => generateFocusTokens(config2, DEFAULT_FOCUS_CONFIGS)
@@ -28202,15 +28063,15 @@ var TokenGraph = class {
28202
28063
  ...extras?.binding ? { binding: extras.binding } : {}
28203
28064
  });
28204
28065
  }
28205
- bind(name, pluginName, input2) {
28066
+ bind(name, pluginName, input) {
28206
28067
  const plugin = this.requirePlugin(pluginName);
28207
- plugin.inputSchema.parse(input2);
28208
- const directDeps = plugin.dependsOn(input2);
28068
+ plugin.inputSchema.parse(input);
28069
+ const directDeps = plugin.dependsOn(input);
28209
28070
  this.assertNoCycle(name, directDeps);
28210
28071
  this.takeSnapshot();
28211
- const value = plugin.transform(input2, (n2) => this.get(n2));
28072
+ const value = plugin.transform(input, (n2) => this.get(n2));
28212
28073
  plugin.outputSchema.parse(value);
28213
- this.nodes.set(name, { name, value, binding: { plugin: pluginName, input: input2 } });
28074
+ this.nodes.set(name, { name, value, binding: { plugin: pluginName, input } });
28214
28075
  this.cascadeFrom(name);
28215
28076
  }
28216
28077
  get(name) {
@@ -28755,11 +28616,11 @@ var TokenRegistry = class {
28755
28616
  }
28756
28617
  this.graph.set(name, value, options);
28757
28618
  }
28758
- bind(name, pluginName, input2) {
28619
+ bind(name, pluginName, input) {
28759
28620
  if (!this.metadata.has(name)) {
28760
28621
  throw new UnknownTokenError(name);
28761
28622
  }
28762
- this.graph.bind(name, pluginName, input2);
28623
+ this.graph.bind(name, pluginName, input);
28763
28624
  }
28764
28625
  get(name) {
28765
28626
  const node = this.graph.node(name);
@@ -28883,22 +28744,38 @@ function readEnvelopes(dir) {
28883
28744
  // ../design-tokens/src/plugin.ts
28884
28745
  function resolveFamily(familyName, get3) {
28885
28746
  let resolved = get3(familyName);
28886
- let resolvedName = familyName;
28747
+ let name = familyName;
28887
28748
  if (resolved && typeof resolved === "object" && "family" in resolved && "position" in resolved) {
28888
- resolvedName = resolved.family;
28889
- resolved = get3(resolvedName);
28749
+ name = resolved.family;
28750
+ resolved = get3(name);
28890
28751
  }
28891
- const family = resolved;
28892
- if (!family) return null;
28893
- return { family, resolvedName };
28752
+ if (!resolved || typeof resolved !== "object" || !("scale" in resolved)) return null;
28753
+ return { family: resolved, familyName: name };
28754
+ }
28755
+ function resolveParent(tokenName, get3) {
28756
+ const raw = get3(tokenName);
28757
+ if (!raw || typeof raw !== "object" || !("family" in raw) || !("position" in raw)) return null;
28758
+ const ref = raw;
28759
+ const positionIndex = POSITION_TO_INDEX[ref.position];
28760
+ if (positionIndex === void 0) return null;
28761
+ const result = resolveFamily(ref.family, get3);
28762
+ if (!result) return null;
28763
+ return { ref, positionIndex, ...result };
28764
+ }
28765
+ function requireSemanticParent(tokenName, get3, pluginName) {
28766
+ const resolved = resolveParent(tokenName, get3);
28767
+ if (!resolved) {
28768
+ throw new Error(`${pluginName} plugin: "${tokenName}" could not resolve`);
28769
+ }
28770
+ return { sem: semanticFor(resolved.family, { name: resolved.familyName }), resolved };
28894
28771
  }
28895
28772
  function definePlugin(spec) {
28896
28773
  return {
28897
28774
  name: spec.name,
28898
28775
  inputSchema: spec.inputSchema,
28899
28776
  outputSchema: spec.outputSchema,
28900
- dependsOn: (input2) => spec.dependsOn(input2),
28901
- transform: (input2, get3) => spec.transform(input2, get3)
28777
+ dependsOn: (input) => spec.dependsOn(input),
28778
+ transform: (input, get3) => spec.transform(input, get3)
28902
28779
  };
28903
28780
  }
28904
28781
 
@@ -28911,11 +28788,11 @@ var calcPlugin = definePlugin({
28911
28788
  name: "calc",
28912
28789
  inputSchema: CalcInputSchema,
28913
28790
  outputSchema: external_exports.string(),
28914
- dependsOn: (input2) => input2.tokens,
28915
- transform: (input2, get3) => {
28916
- let expression = input2.expression;
28791
+ dependsOn: (input) => input.tokens,
28792
+ transform: (input, get3) => {
28793
+ let expression = input.expression;
28917
28794
  let detectedUnit = "";
28918
- for (const tokenName of input2.tokens) {
28795
+ for (const tokenName of input.tokens) {
28919
28796
  const tokenValue = get3(tokenName);
28920
28797
  if (typeof tokenValue !== "string") {
28921
28798
  throw new Error(`calc plugin: token "${tokenName}" value is not a string`);
@@ -28944,132 +28821,32 @@ var ContrastInputSchema = external_exports.object({
28944
28821
  against: external_exports.string(),
28945
28822
  level: external_exports.enum(["AA", "AAA"]).default("AAA")
28946
28823
  });
28947
- function partnerForBase(pairs, basePosition) {
28948
- if (!pairs) return void 0;
28949
- for (const [p1, p2] of pairs) {
28950
- if (p1 === basePosition) return p2;
28951
- if (p2 === basePosition) return p1;
28952
- }
28953
- return void 0;
28954
- }
28955
- function nearestPartner(pairs, basePosition) {
28956
- if (!pairs || pairs.length === 0) return void 0;
28957
- const anchors = /* @__PURE__ */ new Set();
28958
- for (const pair of pairs) {
28959
- for (const position of pair) anchors.add(position);
28960
- }
28961
- if (anchors.size === 0) return void 0;
28962
- let nearest = -1;
28963
- let bestDistance = Number.POSITIVE_INFINITY;
28964
- for (const anchor of anchors) {
28965
- const distance2 = Math.abs(anchor - basePosition);
28966
- if (distance2 < bestDistance) {
28967
- bestDistance = distance2;
28968
- nearest = anchor;
28969
- }
28970
- }
28971
- if (nearest === -1) return void 0;
28972
- return partnerForBase(pairs, nearest);
28973
- }
28974
- function requireScalePosition(index, label) {
28975
- const position = SCALE_POSITIONS[index];
28976
- if (!position) {
28977
- throw new Error(`contrast plugin: invalid scale index ${index} (${label})`);
28978
- }
28979
- return position;
28980
- }
28981
- function isPositionString(value) {
28982
- return typeof value === "string";
28983
- }
28984
- function resolveBasePosition(position) {
28985
- const map2 = {
28986
- "50": 0,
28987
- "100": 1,
28988
- "200": 2,
28989
- "300": 3,
28990
- "400": 4,
28991
- "500": 5,
28992
- "600": 6,
28993
- "700": 7,
28994
- "800": 8,
28995
- "900": 9,
28996
- "950": 10
28997
- };
28998
- const index = map2[position];
28999
- if (index === void 0) {
29000
- throw new Error(`contrast plugin: unknown scale position "${position}"`);
29001
- }
29002
- return index;
29003
- }
29004
28824
  var contrastPlugin = definePlugin({
29005
28825
  name: "contrast",
29006
28826
  inputSchema: ContrastInputSchema,
29007
28827
  outputSchema: ColorReferenceSchema,
29008
- dependsOn: (input2) => [input2.against],
29009
- transform: (input2, get3) => {
29010
- const parent = get3(input2.against);
29011
- if (!parent || typeof parent !== "object" || !("family" in parent) || !("position" in parent)) {
29012
- throw new Error(
29013
- `contrast plugin: parent token "${input2.against}" did not resolve to a ColorReference`
29014
- );
29015
- }
29016
- const parentRef = parent;
29017
- if (!isPositionString(parentRef.position)) {
29018
- throw new Error(
29019
- `contrast plugin: parent token "${input2.against}" position is not a scale string`
29020
- );
29021
- }
29022
- const basePosition = resolveBasePosition(parentRef.position);
29023
- const family = get3(parentRef.family);
29024
- if (!family) {
29025
- throw new Error(
29026
- `contrast plugin: family "${parentRef.family}" (from "${input2.against}") not in registry`
29027
- );
29028
- }
29029
- if (family.foregroundReferences?.auto) {
29030
- const ref = family.foregroundReferences.auto;
29031
- return { family: ref.family, position: ref.position };
29032
- }
29033
- if (family.accessibility) {
29034
- const aaaPartner = partnerForBase(family.accessibility.wcagAAA?.normal, basePosition) ?? nearestPartner(family.accessibility.wcagAAA?.normal, basePosition);
29035
- const aaPartner = partnerForBase(family.accessibility.wcagAA?.normal, basePosition) ?? nearestPartner(family.accessibility.wcagAA?.normal, basePosition);
29036
- const partner = input2.level === "AAA" ? aaaPartner ?? aaPartner : aaPartner;
29037
- if (partner !== void 0) {
29038
- return {
29039
- family: parentRef.family,
29040
- position: requireScalePosition(partner, `${parentRef.family} pair`)
29041
- };
29042
- }
29043
- }
29044
- throw new Error(
29045
- `contrast plugin: family "${parentRef.family}" has no foregroundReferences and no accessibility WCAG pair partner for position ${parentRef.position} (against ${input2.against})`
29046
- );
28828
+ dependsOn: (input) => [input.against],
28829
+ transform: (input, get3) => {
28830
+ const { sem, resolved } = requireSemanticParent(input.against, get3, "contrast");
28831
+ const pair = sem.pair({ use: "foreground", from: resolved.ref.position, level: input.level });
28832
+ return { family: pair.to.family, position: pair.to.position };
29047
28833
  }
29048
28834
  });
29049
28835
 
29050
28836
  // ../design-tokens/src/plugins/invert.ts
29051
28837
  var InvertInputSchema = external_exports.object({
29052
- familyName: external_exports.string(),
29053
- basePosition: external_exports.number().int().min(0).max(10)
28838
+ fromToken: external_exports.string()
29054
28839
  });
29055
28840
  var invertPlugin = definePlugin({
29056
28841
  name: "invert",
29057
28842
  inputSchema: InvertInputSchema,
29058
28843
  outputSchema: ColorReferenceSchema,
29059
- dependsOn: (input2) => [input2.familyName],
29060
- transform: (input2, get3) => {
29061
- const result = resolveFamily(input2.familyName, get3);
29062
- if (!result) {
29063
- throw new Error(`invert plugin: family "${input2.familyName}" not found in registry`);
29064
- }
29065
- const darkIndex = findDarkCounterpartIndex(input2.basePosition, result.family);
29066
- const darkPosition = SCALE_POSITIONS[darkIndex];
29067
- if (!darkPosition) {
29068
- throw new Error(
29069
- `invert plugin: invalid dark index ${darkIndex} for base position ${input2.basePosition}`
29070
- );
29071
- }
29072
- return { family: result.resolvedName, position: darkPosition };
28844
+ dependsOn: (input) => [input.fromToken],
28845
+ transform: (input, get3) => {
28846
+ const { sem, resolved } = requireSemanticParent(input.fromToken, get3, "invert");
28847
+ const lightPair = sem.pair({ use: "foreground", from: resolved.ref.position });
28848
+ const darkPair = sem.invert(lightPair);
28849
+ return { family: resolved.familyName, position: darkPair.from.position };
29073
28850
  }
29074
28851
  });
29075
28852
 
@@ -29082,17 +28859,17 @@ var scalePlugin = definePlugin({
29082
28859
  name: "scale",
29083
28860
  inputSchema: ScaleInputSchema,
29084
28861
  outputSchema: ColorReferenceSchema,
29085
- dependsOn: (input2) => [input2.familyName],
29086
- transform: (input2, get3) => {
29087
- const result = resolveFamily(input2.familyName, get3);
28862
+ dependsOn: (input) => [input.familyName],
28863
+ transform: (input, get3) => {
28864
+ const result = resolveFamily(input.familyName, get3);
29088
28865
  if (!result) {
29089
- throw new Error(`scale plugin: family "${input2.familyName}" not found in registry`);
28866
+ throw new Error(`scale plugin: family "${input.familyName}" not found in registry`);
29090
28867
  }
29091
- const position = SCALE_POSITIONS[input2.scalePosition];
28868
+ const position = SCALE_POSITIONS[input.scalePosition];
29092
28869
  if (position === void 0) {
29093
- throw new Error(`scale plugin: invalid position index ${input2.scalePosition}`);
28870
+ throw new Error(`scale plugin: invalid position index ${input.scalePosition}`);
29094
28871
  }
29095
- return { family: result.resolvedName, position };
28872
+ return { family: result.familyName, position };
29096
28873
  }
29097
28874
  });
29098
28875
 
@@ -29102,115 +28879,16 @@ var StateInputSchema = external_exports.object({
29102
28879
  from: external_exports.string(),
29103
28880
  stateType: StateTypeSchema
29104
28881
  });
29105
- var POSITION_TO_INDEX3 = {
29106
- "50": 0,
29107
- "100": 1,
29108
- "200": 2,
29109
- "300": 3,
29110
- "400": 4,
29111
- "500": 5,
29112
- "600": 6,
29113
- "700": 7,
29114
- "800": 8,
29115
- "900": 9,
29116
- "950": 10
29117
- };
29118
- var STEP_BY_STATE = {
29119
- hover: (rank) => rank + 1,
29120
- active: (rank) => rank + 2,
29121
- focus: (rank) => rank + 1,
29122
- disabled: (_rank, ladder) => closestRankToMidpoint(ladder)
29123
- };
29124
- function closestRankToMidpoint(ladder) {
29125
- let bestRank = 0;
29126
- let bestDistance = Number.POSITIVE_INFINITY;
29127
- for (let r = 0; r < ladder.length; r++) {
29128
- const position = ladder[r];
29129
- if (position === void 0) continue;
29130
- const distance2 = Math.abs(position - 5);
29131
- if (distance2 < bestDistance) {
29132
- bestDistance = distance2;
29133
- bestRank = r;
29134
- }
29135
- }
29136
- return bestRank;
29137
- }
29138
- function nearestRankOnLadder(ladder, position) {
29139
- let bestRank = 0;
29140
- let bestDistance = Number.POSITIVE_INFINITY;
29141
- for (let r = 0; r < ladder.length; r++) {
29142
- const candidate = ladder[r];
29143
- if (candidate === void 0) continue;
29144
- const distance2 = Math.abs(candidate - position);
29145
- if (distance2 < bestDistance) {
29146
- bestDistance = distance2;
29147
- bestRank = r;
29148
- }
29149
- }
29150
- return bestRank;
29151
- }
29152
- function collectLadder(pairs) {
29153
- const positions = /* @__PURE__ */ new Set();
29154
- for (const pair of pairs) {
29155
- for (const position of pair) positions.add(position);
29156
- }
29157
- return Array.from(positions).sort((a2, b2) => a2 - b2);
29158
- }
29159
28882
  var statePlugin = definePlugin({
29160
28883
  name: "state",
29161
28884
  inputSchema: StateInputSchema,
29162
28885
  outputSchema: ColorReferenceSchema,
29163
- dependsOn: (input2) => [input2.from],
29164
- transform: (input2, get3) => {
29165
- const parent = get3(input2.from);
29166
- if (!parent || typeof parent !== "object" || !("family" in parent) || !("position" in parent)) {
29167
- throw new Error(
29168
- `state plugin: parent token "${input2.from}" did not resolve to a ColorReference`
29169
- );
29170
- }
29171
- const parentRef = parent;
29172
- if (typeof parentRef.position !== "string") {
29173
- throw new Error(`state plugin: parent token "${input2.from}" position is not a scale string`);
29174
- }
29175
- const basePosition = POSITION_TO_INDEX3[parentRef.position];
29176
- if (basePosition === void 0) {
29177
- throw new Error(
29178
- `state plugin: parent token "${input2.from}" position "${parentRef.position}" is not a known scale step`
29179
- );
29180
- }
29181
- const family = get3(parentRef.family);
29182
- if (!family) {
29183
- throw new Error(
29184
- `state plugin: family "${parentRef.family}" (from "${input2.from}") not in registry`
29185
- );
29186
- }
29187
- const precomputed = family.stateReferences?.[input2.stateType];
29188
- if (precomputed) {
29189
- return { family: precomputed.family, position: String(precomputed.position) };
29190
- }
29191
- const pairs = family.accessibility?.wcagAAA?.normal;
29192
- if (!pairs || pairs.length === 0) {
29193
- throw new Error(
29194
- `state plugin: family "${parentRef.family}" has no accessibility.wcagAAA.normal ladder (color generator must emit accessibility metadata)`
29195
- );
29196
- }
29197
- const ladder = collectLadder(pairs);
29198
- const baseRank = nearestRankOnLadder(ladder, basePosition);
29199
- const targetRank = STEP_BY_STATE[input2.stateType](baseRank, ladder);
29200
- const clampedRank = Math.max(0, Math.min(ladder.length - 1, targetRank));
29201
- const targetIndex = ladder[clampedRank];
29202
- if (targetIndex === void 0) {
29203
- throw new Error(
29204
- `state plugin: ladder lookup failed for rank ${clampedRank} on family "${parentRef.family}"`
29205
- );
29206
- }
29207
- const position = SCALE_POSITIONS[targetIndex];
29208
- if (!position) {
29209
- throw new Error(
29210
- `state plugin: invalid scale index ${targetIndex} for family "${parentRef.family}"`
29211
- );
29212
- }
29213
- return { family: parentRef.family, position };
28886
+ dependsOn: (input) => [input.from],
28887
+ transform: (input, get3) => {
28888
+ const dark = input.from.includes("--dark");
28889
+ const { sem, resolved } = requireSemanticParent(input.from, get3, "state");
28890
+ const pair = sem.pair({ use: input.stateType, from: resolved.ref.position, dark });
28891
+ return { family: pair.to.family, position: pair.to.position };
29214
28892
  }
29215
28893
  });
29216
28894
 
@@ -29221,12 +28899,86 @@ async function backupCss(cssPath) {
29221
28899
  await copyFile(cssPath, backupPath);
29222
28900
  return backupPath;
29223
28901
  }
28902
+ function cleanSourceCssBlocks(content) {
28903
+ function parseBlocks(src) {
28904
+ const blocks = [];
28905
+ let depth = 0;
28906
+ const headerStack = [];
28907
+ let segmentStart = 0;
28908
+ for (let i = 0; i < src.length; i++) {
28909
+ const ch = src.charAt(i);
28910
+ if (ch === "{") {
28911
+ headerStack.push(segmentStart);
28912
+ depth++;
28913
+ if (depth >= 1) {
28914
+ blocks.push({
28915
+ headerStart: segmentStart,
28916
+ bodyStart: i + 1,
28917
+ end: -1,
28918
+ header: src.slice(segmentStart, i).trim()
28919
+ });
28920
+ }
28921
+ segmentStart = i + 1;
28922
+ } else if (ch === "}") {
28923
+ depth--;
28924
+ const open = blocks.slice().reverse().find((b2) => b2.end === -1);
28925
+ if (open) open.end = i + 1;
28926
+ headerStack.pop();
28927
+ segmentStart = i + 1;
28928
+ } else if (ch === ";") {
28929
+ segmentStart = i + 1;
28930
+ }
28931
+ }
28932
+ return blocks.filter((b2) => b2.end !== -1);
28933
+ }
28934
+ function isContentEmpty(body) {
28935
+ return body.replace(/\/\*[\s\S]*?\*\//g, "").trim().length === 0;
28936
+ }
28937
+ let out = content;
28938
+ for (let pass = 0; pass < 10; pass++) {
28939
+ const blocks = parseBlocks(out);
28940
+ let edited = false;
28941
+ for (const block of blocks.sort((a2, b2) => b2.headerStart - a2.headerStart)) {
28942
+ const header = block.header;
28943
+ if (/^@theme\s+inline$/.test(header)) {
28944
+ out = out.slice(0, block.headerStart) + out.slice(block.end);
28945
+ edited = true;
28946
+ break;
28947
+ }
28948
+ if (header === ":root" || /(^|,)\s*:root\s*$/.test(header)) {
28949
+ const body = out.slice(block.bodyStart, block.end - 1);
28950
+ const cleanedBody = body.replace(/--[\w-]+\s*:[^;{}]*;?/g, "");
28951
+ if (isContentEmpty(cleanedBody)) {
28952
+ out = out.slice(0, block.headerStart) + out.slice(block.end);
28953
+ edited = true;
28954
+ break;
28955
+ }
28956
+ if (cleanedBody !== body) {
28957
+ out = out.slice(0, block.bodyStart) + cleanedBody + out.slice(block.end - 1);
28958
+ edited = true;
28959
+ break;
28960
+ }
28961
+ continue;
28962
+ }
28963
+ if (header.startsWith("@media") || header.startsWith("@supports")) {
28964
+ const body = out.slice(block.bodyStart, block.end - 1);
28965
+ if (isContentEmpty(body)) {
28966
+ out = out.slice(0, block.headerStart) + out.slice(block.end);
28967
+ edited = true;
28968
+ break;
28969
+ }
28970
+ }
28971
+ }
28972
+ if (!edited) break;
28973
+ }
28974
+ return out.replace(/[ \t]+$/gm, "").replace(/\n{3,}/g, "\n\n");
28975
+ }
29224
28976
  async function stripImportedDeclarations(cwd, cssPath, importedNames) {
29225
28977
  if (importedNames.length === 0) return;
29226
28978
  const fullPath = join7(cwd, cssPath);
29227
28979
  const content = await readFile4(fullPath, "utf-8");
29228
28980
  const pattern = new RegExp(importedNames.map((n2) => `^\\s*--${n2}[^;]*;\\s*$`).join("|"), "gm");
29229
- const cleaned = content.replace(pattern, "");
28981
+ const cleaned = cleanSourceCssBlocks(content.replace(pattern, ""));
29230
28982
  const collapsed = cleaned.replace(/\n{3,}/g, "\n\n");
29231
28983
  await writeFile2(fullPath, collapsed);
29232
28984
  }
@@ -29408,6 +29160,8 @@ async function regenerateFromExisting(cwd, paths, shadcn, isAgentMode2, framewor
29408
29160
  existingConfig.compositesPath = frameworkPaths.composites;
29409
29161
  existingConfig.rulesPath = frameworkPaths.rules;
29410
29162
  }
29163
+ await rm(join7(paths.tokens, "elevation.rafters.json"), { force: true });
29164
+ await rm(join7(paths.tokens, "fill.rafters.json"), { force: true });
29411
29165
  const registry2 = loadRegistryFromDir(paths.tokens, REGISTRY_PLUGINS);
29412
29166
  if (registry2.size() === 0) {
29413
29167
  throw new Error("No tokens found. Cannot regenerate without existing tokens.");
@@ -30728,97 +30482,9 @@ async function mcp(options) {
30728
30482
  await startMcpServer(workspaces, defaultWorkspace);
30729
30483
  }
30730
30484
 
30731
- // src/commands/set.ts
30485
+ // src/commands/studio.ts
30732
30486
  import { existsSync as existsSync7 } from "fs";
30733
30487
  import { resolve as resolve5 } from "path";
30734
- import { input } from "@inquirer/prompts";
30735
- var TokenValueSchema = external_exports.union([external_exports.string(), ColorValueSchema, ColorReferenceSchema]);
30736
- async function set3(name, value, options) {
30737
- setAgentMode(options.agent ?? false);
30738
- const dir = resolve5(options.raftersDir ?? ".rafters/tokens");
30739
- if (!existsSync7(dir)) {
30740
- throw new Error(`tokens directory not found: ${dir}`);
30741
- }
30742
- let reason = options.reason;
30743
- if (!reason) {
30744
- if (isAgentMode()) {
30745
- throw new Error("rafters set requires --reason in agent mode");
30746
- }
30747
- reason = await input({
30748
- message: "Reason for this change (recorded with userOverride):",
30749
- validate: (v) => v.trim().length > 0 ? true : "A reason is required"
30750
- });
30751
- }
30752
- const parsedValue = bakeAccessibility(parseValue(value));
30753
- const registry2 = loadRegistryFromDir(dir, [
30754
- scalePlugin,
30755
- contrastPlugin,
30756
- invertPlugin,
30757
- statePlugin
30758
- ]);
30759
- if (!registry2.has(name)) {
30760
- throw new Error(`token "${name}" not found in ${dir}`);
30761
- }
30762
- const previous = registry2.get(name)?.value;
30763
- registry2.set(name, parsedValue, { reason });
30764
- saveRegistryToDir(dir, registry2);
30765
- log({
30766
- event: "token.set",
30767
- name,
30768
- previous,
30769
- next: parsedValue,
30770
- reason
30771
- });
30772
- }
30773
- var WHITE3 = { l: 1, c: 0, h: 0, alpha: 1 };
30774
- var BLACK3 = { l: 0, c: 0, h: 0, alpha: 1 };
30775
- var WCAG_AA_NORMAL2 = 4.5;
30776
- var WCAG_AAA_NORMAL2 = 7;
30777
- function bakeAccessibility(value) {
30778
- if (typeof value !== "object" || value === null) return value;
30779
- if (!("scale" in value) || !Array.isArray(value.scale)) return value;
30780
- const colorValue = value;
30781
- const meta = generateAccessibilityMetadata(colorValue.scale);
30782
- const reference = colorValue.scale[5] ?? colorValue.scale[0];
30783
- if (!reference) return value;
30784
- const onWhiteRatio = calculateWCAGContrast(reference, WHITE3);
30785
- const onBlackRatio = calculateWCAGContrast(reference, BLACK3);
30786
- const accessibility = {
30787
- wcagAA: meta.wcagAA,
30788
- wcagAAA: meta.wcagAAA,
30789
- onWhite: {
30790
- wcagAA: onWhiteRatio >= WCAG_AA_NORMAL2,
30791
- wcagAAA: onWhiteRatio >= WCAG_AAA_NORMAL2,
30792
- contrastRatio: onWhiteRatio,
30793
- aa: meta.onWhite.aa,
30794
- aaa: meta.onWhite.aaa
30795
- },
30796
- onBlack: {
30797
- wcagAA: onBlackRatio >= WCAG_AA_NORMAL2,
30798
- wcagAAA: onBlackRatio >= WCAG_AAA_NORMAL2,
30799
- contrastRatio: onBlackRatio,
30800
- aa: meta.onBlack.aa,
30801
- aaa: meta.onBlack.aaa
30802
- }
30803
- };
30804
- return { ...colorValue, accessibility };
30805
- }
30806
- function parseValue(raw) {
30807
- const trimmed = raw.trim();
30808
- if (trimmed.startsWith("{")) {
30809
- try {
30810
- const parsed = JSON.parse(trimmed);
30811
- const result = TokenValueSchema.safeParse(parsed);
30812
- if (result.success) return result.data;
30813
- } catch {
30814
- }
30815
- }
30816
- return raw;
30817
- }
30818
-
30819
- // src/commands/studio.ts
30820
- import { existsSync as existsSync8 } from "fs";
30821
- import { resolve as resolve6 } from "path";
30822
30488
 
30823
30489
  // ../studio/src/api/vite-plugin.ts
30824
30490
  import { writeFile as writeFile3 } from "fs/promises";
@@ -30968,7 +30634,7 @@ function getNamespacePatchSchema(namespace) {
30968
30634
  }
30969
30635
  var MAX_BODY_SIZE = 1024 * 1024;
30970
30636
  function readJsonBody(req) {
30971
- return new Promise((resolve7, reject) => {
30637
+ return new Promise((resolve6, reject) => {
30972
30638
  let body = "";
30973
30639
  let size = 0;
30974
30640
  req.on("data", (chunk) => {
@@ -30981,7 +30647,7 @@ function readJsonBody(req) {
30981
30647
  });
30982
30648
  req.on("end", () => {
30983
30649
  try {
30984
- resolve7(body ? JSON.parse(body) : {});
30650
+ resolve6(body ? JSON.parse(body) : {});
30985
30651
  } catch {
30986
30652
  reject(new Error("Invalid JSON body"));
30987
30653
  }
@@ -31108,6 +30774,9 @@ async function handlePostToken(req, res, name, registry2) {
31108
30774
  ...existingToken,
31109
30775
  ...patchResult.data
31110
30776
  };
30777
+ if (mergedToken.value && typeof mergedToken.value === "object" && "scale" in mergedToken.value) {
30778
+ mergedToken.value = rebakeAccessibility(mergedToken.value);
30779
+ }
31111
30780
  const tokenResult = TokenSchema.safeParse(mergedToken);
31112
30781
  if (!tokenResult.success) {
31113
30782
  res.statusCode = 400;
@@ -31446,7 +31115,7 @@ import { createServer } from "vite";
31446
31115
  async function studio() {
31447
31116
  const cwd = process.cwd();
31448
31117
  const paths = getRaftersPaths(cwd);
31449
- if (!existsSync8(paths.root)) {
31118
+ if (!existsSync7(paths.root)) {
31450
31119
  console.error('No .rafters/ directory found. Run "rafters init" first.');
31451
31120
  process.exit(1);
31452
31121
  }
@@ -31463,7 +31132,7 @@ async function studio() {
31463
31132
  },
31464
31133
  resolve: {
31465
31134
  alias: {
31466
- "@rafters-output": resolve6(cwd, ".rafters", "output")
31135
+ "@rafters-output": resolve5(cwd, ".rafters", "output")
31467
31136
  }
31468
31137
  }
31469
31138
  });
@@ -31480,10 +31149,6 @@ program.command("init").description("Initialize .rafters/ with default tokens an
31480
31149
  ).option("--agent", "Output JSON for machine consumption").action(withErrorHandler(init));
31481
31150
  program.command("add").description("Add rafters components to the project").argument("[components...]", "Component names to add").option("--list", "List available components").option("--overwrite", "Overwrite existing component files").option("--update", "Re-fetch named components from registry").option("--update-all", "Re-fetch all installed components from registry").option("--registry-url <url>", "Custom registry URL").option("--agent", "Output JSON for machine consumption").action(withErrorHandler(add));
31482
31151
  program.command("mcp").description("Start MCP server for AI agent access (stdio)").option("--project-root <path>", "Explicit project root (skips .rafters/ discovery)").action(mcp);
31483
- program.command("set").description("Set a token value. Records userOverride and cascades to dependents.").argument("<name>", "Token name").argument("<value>", "New value (string, or JSON for ColorValue/ColorReference)").option(
31484
- "--reason <text>",
31485
- "Reason for the change (recorded with userOverride; prompted if missing in non-agent mode)"
31486
- ).option("--rafters-dir <path>", "Directory of .rafters.json files", ".rafters/tokens").option("--agent", "Output JSON for machine consumption").action(withErrorHandler(set3));
31487
31152
  program.command("studio").description("Open Studio UI for visual token editing").action(studio);
31488
31153
  program.parse();
31489
31154
  /*! Bundled license information: