@ai-matrx/kit 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +132 -0
  2. package/LICENSE +21 -0
  3. package/README.md +72 -0
  4. package/dist/autosave.cjs +92 -0
  5. package/dist/autosave.cjs.map +1 -0
  6. package/dist/autosave.d.cts +17 -0
  7. package/dist/autosave.d.ts +17 -0
  8. package/dist/autosave.js +72 -0
  9. package/dist/autosave.js.map +1 -0
  10. package/dist/clipboard.cjs +152 -0
  11. package/dist/clipboard.cjs.map +1 -0
  12. package/dist/clipboard.d.cts +17 -0
  13. package/dist/clipboard.d.ts +17 -0
  14. package/dist/clipboard.js +132 -0
  15. package/dist/clipboard.js.map +1 -0
  16. package/dist/color-util.cjs +790 -0
  17. package/dist/color-util.cjs.map +1 -0
  18. package/dist/color-util.d.cts +235 -0
  19. package/dist/color-util.d.ts +235 -0
  20. package/dist/color-util.js +767 -0
  21. package/dist/color-util.js.map +1 -0
  22. package/dist/concurrency.cjs +59 -0
  23. package/dist/concurrency.cjs.map +1 -0
  24. package/dist/concurrency.d.cts +19 -0
  25. package/dist/concurrency.d.ts +19 -0
  26. package/dist/concurrency.js +38 -0
  27. package/dist/concurrency.js.map +1 -0
  28. package/dist/confirm.cjs +344 -0
  29. package/dist/confirm.cjs.map +1 -0
  30. package/dist/confirm.d.cts +132 -0
  31. package/dist/confirm.d.ts +132 -0
  32. package/dist/confirm.js +312 -0
  33. package/dist/confirm.js.map +1 -0
  34. package/dist/delimiter-guard.cjs +172 -0
  35. package/dist/delimiter-guard.cjs.map +1 -0
  36. package/dist/delimiter-guard.d.cts +119 -0
  37. package/dist/delimiter-guard.d.ts +119 -0
  38. package/dist/delimiter-guard.js +151 -0
  39. package/dist/delimiter-guard.js.map +1 -0
  40. package/dist/drafts.cjs +223 -0
  41. package/dist/drafts.cjs.map +1 -0
  42. package/dist/drafts.d.cts +62 -0
  43. package/dist/drafts.d.ts +62 -0
  44. package/dist/drafts.js +201 -0
  45. package/dist/drafts.js.map +1 -0
  46. package/dist/idb-store.cjs +178 -0
  47. package/dist/idb-store.cjs.map +1 -0
  48. package/dist/idb-store.d.cts +111 -0
  49. package/dist/idb-store.d.ts +111 -0
  50. package/dist/idb-store.js +155 -0
  51. package/dist/idb-store.js.map +1 -0
  52. package/dist/idle-scheduler.cjs +268 -0
  53. package/dist/idle-scheduler.cjs.map +1 -0
  54. package/dist/idle-scheduler.d.cts +185 -0
  55. package/dist/idle-scheduler.d.ts +185 -0
  56. package/dist/idle-scheduler.js +246 -0
  57. package/dist/idle-scheduler.js.map +1 -0
  58. package/dist/index.cjs +3113 -0
  59. package/dist/index.cjs.map +1 -0
  60. package/dist/index.d.cts +897 -0
  61. package/dist/index.d.ts +897 -0
  62. package/dist/index.js +3088 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/invalidation.cjs +64 -0
  65. package/dist/invalidation.cjs.map +1 -0
  66. package/dist/invalidation.d.cts +52 -0
  67. package/dist/invalidation.d.ts +52 -0
  68. package/dist/invalidation.js +43 -0
  69. package/dist/invalidation.js.map +1 -0
  70. package/dist/json-format.cjs +319 -0
  71. package/dist/json-format.cjs.map +1 -0
  72. package/dist/json-format.d.cts +148 -0
  73. package/dist/json-format.d.ts +148 -0
  74. package/dist/json-format.js +286 -0
  75. package/dist/json-format.js.map +1 -0
  76. package/dist/latest-request.cjs +36 -0
  77. package/dist/latest-request.cjs.map +1 -0
  78. package/dist/latest-request.d.cts +29 -0
  79. package/dist/latest-request.d.ts +29 -0
  80. package/dist/latest-request.js +16 -0
  81. package/dist/latest-request.js.map +1 -0
  82. package/dist/qr.cjs +109 -0
  83. package/dist/qr.cjs.map +1 -0
  84. package/dist/qr.d.cts +47 -0
  85. package/dist/qr.d.ts +47 -0
  86. package/dist/qr.js +78 -0
  87. package/dist/qr.js.map +1 -0
  88. package/dist/react-tree.cjs +69 -0
  89. package/dist/react-tree.cjs.map +1 -0
  90. package/dist/react-tree.d.cts +38 -0
  91. package/dist/react-tree.d.ts +38 -0
  92. package/dist/react-tree.js +38 -0
  93. package/dist/react-tree.js.map +1 -0
  94. package/dist/search-scoring.cjs +116 -0
  95. package/dist/search-scoring.cjs.map +1 -0
  96. package/dist/search-scoring.d.cts +77 -0
  97. package/dist/search-scoring.d.ts +77 -0
  98. package/dist/search-scoring.js +95 -0
  99. package/dist/search-scoring.js.map +1 -0
  100. package/dist/text-case.cjs +313 -0
  101. package/dist/text-case.cjs.map +1 -0
  102. package/dist/text-case.d.cts +53 -0
  103. package/dist/text-case.d.ts +53 -0
  104. package/dist/text-case.js +292 -0
  105. package/dist/text-case.js.map +1 -0
  106. package/dist/toast.cjs +74 -0
  107. package/dist/toast.cjs.map +1 -0
  108. package/dist/toast.d.cts +92 -0
  109. package/dist/toast.d.ts +92 -0
  110. package/dist/toast.js +54 -0
  111. package/dist/toast.js.map +1 -0
  112. package/dist/url-state.cjs +212 -0
  113. package/dist/url-state.cjs.map +1 -0
  114. package/dist/url-state.d.cts +90 -0
  115. package/dist/url-state.d.ts +90 -0
  116. package/dist/url-state.js +199 -0
  117. package/dist/url-state.js.map +1 -0
  118. package/package.json +286 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/color-util.ts","../src/color-util/lab-delta.ts","../src/color-util/tailwind-colors.ts","../src/color-util/tailwind.ts","../src/color-util/formats.ts","../src/color-util/normalize.ts"],"sourcesContent":["/**\n * @ai-matrx/kit/color-util — the bidirectional Tailwind-token color mapping,\n * plus the pure \"accept anything a human pastes\" input normalizers. Ported\n * from matrx-frontend `utils/color-utils/` (+ its `constants/tailwind-colors`\n * lookup table). Zero runtime dependencies.\n *\n * - token → hex: `getColorFromTailwind(\"slate-500\")` → `\"#64748b\"`, and the\n * fuzzy `formatTailwindColor` (\"skyblue598\" → the sky-600 hex).\n * - color → token: `findNearestTailwindColor(\"#64748b\")` → `\"slate-500\"` —\n * perceptual nearest match (CIEDE2000 over Lab, bit-identical to the\n * colord lab plugin the original used). Also accepts any `{ delta(hex) }`\n * object (e.g. a colord instance) for hosts that already carry colord —\n * structural typing, nothing imported.\n * - `format*` normalizers: messy pasted input → the canonical string for\n * that format, `''` when it does not fit.\n * - `createColorNormalizer({ isValid })` → the original `normalizeColorInput`\n * waterfall; the host injects its color-validity check\n * (`(c) => colord(c).isValid()`).\n *\n * Deliberately NOT ported (host-side, per the split-out law): the one-line\n * colord passthroughs (`isValidColor`, `convertColor`, `getColorInfo`,\n * `getColorString`, `getColorFormats`) — they are `colord(x).*` calls with no\n * algorithm of their own, and packaging them would drag colord in as a\n * runtime dependency of a chartered zero-dependency unit.\n */\nexport {\n findNearestTailwindColor,\n formatTailwindColor,\n getColorFromTailwind,\n} from \"./color-util/tailwind\";\nexport type { ColorDelta } from \"./color-util/tailwind\";\nexport { tailwindColors } from \"./color-util/tailwind-colors\";\nexport type { TailwindColorGroup } from \"./color-util/tailwind-colors\";\nexport {\n formatCmykObject,\n formatCmykString,\n formatHex,\n formatHexWith0x,\n formatHslObject,\n formatHslString,\n formatHsvString,\n formatHwbString,\n formatLabString,\n formatLchString,\n formatRegularCmykString,\n formatRgbObject,\n formatRgbString,\n isDeviceCmyk,\n} from \"./color-util/formats\";\nexport { createColorNormalizer } from \"./color-util/normalize\";\nexport type {\n ColorNormalizerOptions,\n NormalizedColor,\n} from \"./color-util/normalize\";\nexport { parseHexOrRgb, rgbDelta, rgbToLab } from \"./color-util/lab-delta\";\nexport type { Rgb } from \"./color-util/lab-delta\";\n","/**\n * The zero-dependency perceptual-distance engine behind the string input path\n * of `findNearestTailwindColor`.\n *\n * The matrx-frontend original computed distance through colord's lab plugin\n * (`colordInstance.delta(hex)`). This module reproduces that plugin's exact\n * pipeline — sRGB → XYZ(D65) → chromatic adaptation to D50 (colord's\n * matrices, including its channel clamps) → CIE L*a*b* rounded to 2 decimals\n * → CIEDE2000 (colord >= 2.10 formulation) ÷ 100, rounded to 3 decimals and\n * clamped to [0, 1] — so the nearest-token answer is bit-identical to the\n * colord path. The test suite cross-checks this against colord itself (a\n * devDependency only).\n */\n\nexport interface Rgb {\n r: number;\n g: number;\n b: number;\n}\n\ninterface Lab {\n l: number;\n a: number;\n b: number;\n}\n\n/** colord's rounding helper: round to `digits` decimal places. */\nfunction round(value: number, digits = 0): number {\n const factor = Math.pow(10, digits);\n return Math.round(factor * value) / factor + 0;\n}\n\nfunction clamp(value: number, min = 0, max = 1): number {\n return value > max ? max : value > min ? value : min;\n}\n\n/** sRGB channel (0–255) → linear-light (0–1). */\nfunction linearize(channel: number): number {\n const c = channel / 255;\n return c < 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);\n}\n\n// D50 reference white (colord's constants).\nconst WHITE_X = 96.422;\nconst WHITE_Y = 100;\nconst WHITE_Z = 82.521;\n\nconst EPSILON = 216 / 24389;\nconst KAPPA = 24389 / 27;\n\n/** sRGB → XYZ(D65) → Bradford-adapted D50, clamped — colord's exact matrices. */\nfunction rgbToXyz(rgb: Rgb): { x: number; y: number; z: number } {\n const r = linearize(rgb.r);\n const g = linearize(rgb.g);\n const b = linearize(rgb.b);\n const d65 = {\n x: 100 * (0.4124564 * r + 0.3575761 * g + 0.1804375 * b),\n y: 100 * (0.2126729 * r + 0.7151522 * g + 0.072175 * b),\n z: 100 * (0.0193339 * r + 0.119192 * g + 0.9503041 * b),\n };\n const d50 = {\n x: 1.0478112 * d65.x + 0.0228866 * d65.y + -0.050127 * d65.z,\n y: 0.0295424 * d65.x + 0.9904844 * d65.y + -0.0170491 * d65.z,\n z: -0.0092345 * d65.x + 0.0150436 * d65.y + 0.7521316 * d65.z,\n };\n return {\n x: clamp(d50.x, 0, WHITE_X),\n y: clamp(d50.y, 0, WHITE_Y),\n z: clamp(d50.z, 0, WHITE_Z),\n };\n}\n\n/** RGB → CIE L*a*b*, rounded to 2 decimals exactly like colord's `toLab`. */\nexport function rgbToLab(rgb: Rgb): Lab {\n const xyz = rgbToXyz(rgb);\n let x = xyz.x / WHITE_X;\n let y = xyz.y / WHITE_Y;\n let z = xyz.z / WHITE_Z;\n x = x > EPSILON ? Math.cbrt(x) : (KAPPA * x + 16) / 116;\n y = y > EPSILON ? Math.cbrt(y) : (KAPPA * y + 16) / 116;\n z = z > EPSILON ? Math.cbrt(z) : (KAPPA * z + 16) / 116;\n return {\n l: round(116 * y - 16, 2),\n a: round(500 * (x - y), 2),\n b: round(200 * (y - z), 2),\n };\n}\n\n/** CIEDE2000 between two Lab colors — colord's exact formulation. */\nfunction ciede2000(lab1: Lab, lab2: Lab): number {\n const { l: l1, a: a1, b: b1 } = lab1;\n const { l: l2, a: a2, b: b2 } = lab2;\n const toDeg = 180 / Math.PI;\n const toRad = Math.PI / 180;\n\n const c1 = Math.pow(Math.pow(a1, 2) + Math.pow(b1, 2), 0.5);\n const c2 = Math.pow(Math.pow(a2, 2) + Math.pow(b2, 2), 0.5);\n const lBar = (l1 + l2) / 2;\n const cBar7 = Math.pow((c1 + c2) / 2, 7);\n const g = 0.5 * (1 - Math.pow(cBar7 / (cBar7 + Math.pow(25, 7)), 0.5));\n const a1p = a1 * (1 + g);\n const a2p = a2 * (1 + g);\n const c1p = Math.pow(Math.pow(a1p, 2) + Math.pow(b1, 2), 0.5);\n const c2p = Math.pow(Math.pow(a2p, 2) + Math.pow(b2, 2), 0.5);\n const cBarP = (c1p + c2p) / 2;\n let h1p = a1p === 0 && b1 === 0 ? 0 : Math.atan2(b1, a1p) * toDeg;\n let h2p = a2p === 0 && b2 === 0 ? 0 : Math.atan2(b2, a2p) * toDeg;\n if (h1p < 0) h1p += 360;\n if (h2p < 0) h2p += 360;\n\n let dhp = h2p - h1p;\n const hAbs = Math.abs(h2p - h1p);\n if (hAbs > 180 && h2p <= h1p) {\n dhp += 360;\n } else if (hAbs > 180 && h2p > h1p) {\n dhp -= 360;\n }\n let hBarP = h1p + h2p;\n if (hAbs <= 180) {\n hBarP /= 2;\n } else {\n hBarP = (h1p + h2p < 360 ? hBarP + 360 : hBarP - 360) / 2;\n }\n\n const t =\n 1 -\n 0.17 * Math.cos(toRad * (hBarP - 30)) +\n 0.24 * Math.cos(2 * toRad * hBarP) +\n 0.32 * Math.cos(toRad * (3 * hBarP + 6)) -\n 0.2 * Math.cos(toRad * (4 * hBarP - 63));\n const dL = l2 - l1;\n const dCp = c2p - c1p;\n const dHp = 2 * Math.sin((toRad * dhp) / 2) * Math.pow(c1p * c2p, 0.5);\n const sl =\n 1 +\n (0.015 * Math.pow(lBar - 50, 2)) /\n Math.pow(20 + Math.pow(lBar - 50, 2), 0.5);\n const sc = 1 + 0.045 * cBarP;\n const sh = 1 + 0.015 * cBarP * t;\n const dTheta = 30 * Math.exp(-1 * Math.pow((hBarP - 275) / 25, 2));\n // colord >= 2.10 computes the rotation term from the adjusted mean chroma\n // (C'bar^7), the standard CIEDE2000 formulation.\n const cBarP7 = Math.pow(cBarP, 7);\n const rt =\n -2 *\n Math.pow(cBarP7 / (cBarP7 + Math.pow(25, 7)), 0.5) *\n Math.sin(2 * toRad * dTheta);\n\n return Math.pow(\n Math.pow(dL / 1 / sl, 2) +\n Math.pow(dCp / 1 / sc, 2) +\n Math.pow(dHp / 1 / sh, 2) +\n (rt * dCp * dHp) / (1 * sc * 1 * sh),\n 0.5,\n );\n}\n\n/**\n * Perceptual distance between two RGB colors, normalized exactly like\n * colord's `.delta()`: CIEDE2000 / 100, rounded to 3 decimals, clamped [0,1].\n */\nexport function rgbDelta(rgb1: Rgb, rgb2: Rgb): number {\n return clamp(round(ciede2000(rgbToLab(rgb1), rgbToLab(rgb2)) / 100, 3));\n}\n\nconst HEX_RE = /^#?([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\nconst RGB_FN_RE =\n /^rgba?\\(\\s*([+-]?[\\d.]+)\\s*[,\\s]\\s*([+-]?[\\d.]+)\\s*[,\\s]\\s*([+-]?[\\d.]+)(?:\\s*[,/]\\s*[+-]?[\\d.]+%?)?\\s*\\)$/i;\n\n/**\n * Parses the two input shapes this unit is chartered for — hex (`#rgb`,\n * `#rrggbb`, with or without `#`, alpha digits tolerated and ignored) and\n * `rgb()`/`rgba()` strings — into RGB channels. Returns `null` for anything\n * else; this is deliberately NOT a general CSS color parser.\n */\nexport function parseHexOrRgb(input: string): Rgb | null {\n const text = input.trim();\n const hexMatch = text.match(HEX_RE);\n if (hexMatch) {\n const hex = hexMatch[1] as string;\n if (hex.length === 3 || hex.length === 4) {\n return {\n r: parseInt((hex[0] as string) + hex[0], 16),\n g: parseInt((hex[1] as string) + hex[1], 16),\n b: parseInt((hex[2] as string) + hex[2], 16),\n };\n }\n return {\n r: parseInt(hex.slice(0, 2), 16),\n g: parseInt(hex.slice(2, 4), 16),\n b: parseInt(hex.slice(4, 6), 16),\n };\n }\n const rgbMatch = text.match(RGB_FN_RE);\n if (rgbMatch) {\n const r = Number(rgbMatch[1]);\n const g = Number(rgbMatch[2]);\n const b = Number(rgbMatch[3]);\n if ([r, g, b].some((v) => Number.isNaN(v))) return null;\n return { r: clamp(r, 0, 255), g: clamp(g, 0, 255), b: clamp(b, 0, 255) };\n }\n return null;\n}\n","/**\n * The Tailwind CSS default palette lookup table — ported verbatim from\n * matrx-frontend `constants/tailwind-colors.ts` (the data the S14\n * \"tailwind-color-util\" unit does its lookups against). 22 color groups,\n * shades 50–950.\n */\n\nexport interface TailwindColorGroup {\n name: string;\n shades: Record<string, string>;\n}\n\n\nexport const tailwindColors: readonly TailwindColorGroup[] = [\n {\n name: \"Slate\",\n shades: {\n \"50\": \"#f8fafc\",\n \"100\": \"#f1f5f9\",\n \"200\": \"#e2e8f0\",\n \"300\": \"#cbd5e1\",\n \"400\": \"#94a3b8\",\n \"500\": \"#64748b\",\n \"600\": \"#475569\",\n \"700\": \"#334155\",\n \"800\": \"#1e293b\",\n \"900\": \"#0f172a\",\n \"950\": \"#020617\"\n }\n },\n {\n name: \"Gray\",\n shades: {\n \"50\": \"#f9fafb\",\n \"100\": \"#f3f4f6\",\n \"200\": \"#e5e7eb\",\n \"300\": \"#d1d5db\",\n \"400\": \"#9ca3af\",\n \"500\": \"#6b7280\",\n \"600\": \"#4b5563\",\n \"700\": \"#374151\",\n \"800\": \"#1f2937\",\n \"900\": \"#111827\",\n \"950\": \"#030712\"\n }\n },\n {\n name: \"Zinc\",\n shades: {\n \"50\": \"#fafafa\",\n \"100\": \"#f4f4f5\",\n \"200\": \"#e4e4e7\",\n \"300\": \"#d4d4d8\",\n \"400\": \"#a1a1aa\",\n \"500\": \"#71717a\",\n \"600\": \"#52525b\",\n \"700\": \"#3f3f46\",\n \"800\": \"#27272a\",\n \"900\": \"#18181b\",\n \"950\": \"#09090b\"\n }\n },\n {\n name: \"Neutral\",\n shades: {\n \"50\": \"#fafafa\",\n \"100\": \"#f5f5f5\",\n \"200\": \"#e5e5e5\",\n \"300\": \"#d4d4d4\",\n \"400\": \"#a3a3a3\",\n \"500\": \"#737373\",\n \"600\": \"#525252\",\n \"700\": \"#404040\",\n \"800\": \"#262626\",\n \"900\": \"#171717\",\n \"950\": \"#0a0a0a\"\n }\n },\n {\n name: \"Stone\",\n shades: {\n \"50\": \"#fafaf9\",\n \"100\": \"#f5f5f4\",\n \"200\": \"#e7e5e4\",\n \"300\": \"#d6d3d1\",\n \"400\": \"#a8a29e\",\n \"500\": \"#78716c\",\n \"600\": \"#57534e\",\n \"700\": \"#44403c\",\n \"800\": \"#292524\",\n \"900\": \"#1c1917\",\n \"950\": \"#0c0a09\"\n }\n },\n {\n name: \"Red\",\n shades: {\n \"50\": \"#fef2f2\",\n \"100\": \"#fee2e2\",\n \"200\": \"#fecaca\",\n \"300\": \"#fca5a5\",\n \"400\": \"#f87171\",\n \"500\": \"#ef4444\",\n \"600\": \"#dc2626\",\n \"700\": \"#b91c1c\",\n \"800\": \"#991b1b\",\n \"900\": \"#7f1d1d\",\n \"950\": \"#450a0a\"\n }\n },\n {\n name: \"Orange\",\n shades: {\n \"50\": \"#fff7ed\",\n \"100\": \"#ffedd5\",\n \"200\": \"#fed7aa\",\n \"300\": \"#fdba74\",\n \"400\": \"#fb923c\",\n \"500\": \"#f97316\",\n \"600\": \"#ea580c\",\n \"700\": \"#c2410c\",\n \"800\": \"#9a3412\",\n \"900\": \"#7c2d12\",\n \"950\": \"#431407\"\n }\n },\n {\n name: \"Amber\",\n shades: {\n \"50\": \"#fffbeb\",\n \"100\": \"#fef3c7\",\n \"200\": \"#fde68a\",\n \"300\": \"#fcd34d\",\n \"400\": \"#fbbf24\",\n \"500\": \"#f59e0b\",\n \"600\": \"#d97706\",\n \"700\": \"#b45309\",\n \"800\": \"#92400e\",\n \"900\": \"#78350f\",\n \"950\": \"#451a03\"\n }\n },\n {\n name: \"Yellow\",\n shades: {\n \"50\": \"#fefce8\",\n \"100\": \"#fef9c3\",\n \"200\": \"#fef08a\",\n \"300\": \"#fde047\",\n \"400\": \"#facc15\",\n \"500\": \"#eab308\",\n \"600\": \"#ca8a04\",\n \"700\": \"#a16207\",\n \"800\": \"#854d0e\",\n \"900\": \"#713f12\",\n \"950\": \"#422006\"\n }\n },\n {\n name: \"Lime\",\n shades: {\n \"50\": \"#f7fee7\",\n \"100\": \"#ecfccb\",\n \"200\": \"#d9f99d\",\n \"300\": \"#bef264\",\n \"400\": \"#a3e635\",\n \"500\": \"#84cc16\",\n \"600\": \"#65a30d\",\n \"700\": \"#4d7c0f\",\n \"800\": \"#3f6212\",\n \"900\": \"#365314\",\n \"950\": \"#1a2e05\"\n }\n },\n {\n name: \"Green\",\n shades: {\n \"50\": \"#f0fdf4\",\n \"100\": \"#dcfce7\",\n \"200\": \"#bbf7d0\",\n \"300\": \"#86efac\",\n \"400\": \"#4ade80\",\n \"500\": \"#22c55e\",\n \"600\": \"#16a34a\",\n \"700\": \"#15803d\",\n \"800\": \"#166534\",\n \"900\": \"#14532d\",\n \"950\": \"#052e16\"\n }\n },\n {\n name: \"Emerald\",\n shades: {\n \"50\": \"#ecfdf5\",\n \"100\": \"#d1fae5\",\n \"200\": \"#a7f3d0\",\n \"300\": \"#6ee7b7\",\n \"400\": \"#34d399\",\n \"500\": \"#10b981\",\n \"600\": \"#059669\",\n \"700\": \"#047857\",\n \"800\": \"#065f46\",\n \"900\": \"#064e3b\",\n \"950\": \"#022c22\"\n }\n },\n {\n name: \"Teal\",\n shades: {\n \"50\": \"#f0fdfa\",\n \"100\": \"#ccfbf1\",\n \"200\": \"#99f6e4\",\n \"300\": \"#5eead4\",\n \"400\": \"#2dd4bf\",\n \"500\": \"#14b8a6\",\n \"600\": \"#0d9488\",\n \"700\": \"#0f766e\",\n \"800\": \"#115e59\",\n \"900\": \"#134e4a\",\n \"950\": \"#042f2e\"\n }\n },\n {\n name: \"Cyan\",\n shades: {\n \"50\": \"#ecfeff\",\n \"100\": \"#cffafe\",\n \"200\": \"#a5f3fc\",\n \"300\": \"#67e8f9\",\n \"400\": \"#22d3ee\",\n \"500\": \"#06b6d4\",\n \"600\": \"#0891b2\",\n \"700\": \"#0e7490\",\n \"800\": \"#155e75\",\n \"900\": \"#164e63\",\n \"950\": \"#083344\"\n }\n },\n {\n name: \"Sky\",\n shades: {\n \"50\": \"#f0f9ff\",\n \"100\": \"#e0f2fe\",\n \"200\": \"#bae6fd\",\n \"300\": \"#7dd3fc\",\n \"400\": \"#38bdf8\",\n \"500\": \"#0ea5e9\",\n \"600\": \"#0284c7\",\n \"700\": \"#0369a1\",\n \"800\": \"#075985\",\n \"900\": \"#0c4a6e\",\n \"950\": \"#082f49\"\n }\n },\n {\n name: \"Blue\",\n shades: {\n \"50\": \"#eff6ff\",\n \"100\": \"#dbeafe\",\n \"200\": \"#bfdbfe\",\n \"300\": \"#93c5fd\",\n \"400\": \"#60a5fa\",\n \"500\": \"#3b82f6\",\n \"600\": \"#2563eb\",\n \"700\": \"#1d4ed8\",\n \"800\": \"#1e40af\",\n \"900\": \"#1e3a8a\",\n \"950\": \"#172554\"\n }\n },\n {\n name: \"Indigo\",\n shades: {\n \"50\": \"#eef2ff\",\n \"100\": \"#e0e7ff\",\n \"200\": \"#c7d2fe\",\n \"300\": \"#a5b4fc\",\n \"400\": \"#818cf8\",\n \"500\": \"#6366f1\",\n \"600\": \"#4f46e5\",\n \"700\": \"#4338ca\",\n \"800\": \"#3730a3\",\n \"900\": \"#312e81\",\n \"950\": \"#1e1b4b\"\n }\n },\n {\n name: \"Violet\",\n shades: {\n \"50\": \"#f5f3ff\",\n \"100\": \"#ede9fe\",\n \"200\": \"#ddd6fe\",\n \"300\": \"#c4b5fd\",\n \"400\": \"#a78bfa\",\n \"500\": \"#8b5cf6\",\n \"600\": \"#7c3aed\",\n \"700\": \"#6d28d9\",\n \"800\": \"#5b21b6\",\n \"900\": \"#4c1d95\",\n \"950\": \"#2e1065\"\n }\n },\n {\n name: \"Purple\",\n shades: {\n \"50\": \"#faf5ff\",\n \"100\": \"#f3e8ff\",\n \"200\": \"#e9d5ff\",\n \"300\": \"#d8b4fe\",\n \"400\": \"#c084fc\",\n \"500\": \"#a855f7\",\n \"600\": \"#9333ea\",\n \"700\": \"#7e22ce\",\n \"800\": \"#6b21a8\",\n \"900\": \"#581c87\",\n \"950\": \"#3b0764\"\n }\n },\n {\n name: \"Fuchsia\",\n shades: {\n \"50\": \"#fdf4ff\",\n \"100\": \"#fae8ff\",\n \"200\": \"#f5d0fe\",\n \"300\": \"#f0abfc\",\n \"400\": \"#e879f9\",\n \"500\": \"#d946ef\",\n \"600\": \"#c026d3\",\n \"700\": \"#a21caf\",\n \"800\": \"#86198f\",\n \"900\": \"#701a75\",\n \"950\": \"#4a044e\"\n }\n },\n {\n name: \"Pink\",\n shades: {\n \"50\": \"#fdf2f8\",\n \"100\": \"#fce7f3\",\n \"200\": \"#fbcfe8\",\n \"300\": \"#f9a8d4\",\n \"400\": \"#f472b6\",\n \"500\": \"#ec4899\",\n \"600\": \"#db2777\",\n \"700\": \"#be185d\",\n \"800\": \"#9d174d\",\n \"900\": \"#831843\",\n \"950\": \"#500724\"\n }\n },\n {\n name: \"Rose\",\n shades: {\n \"50\": \"#fff1f2\",\n \"100\": \"#ffe4e6\",\n \"200\": \"#fecdd3\",\n \"300\": \"#fda4af\",\n \"400\": \"#fb7185\",\n \"500\": \"#f43f5e\",\n \"600\": \"#e11d48\",\n \"700\": \"#be123c\",\n \"800\": \"#9f1239\",\n \"900\": \"#881337\",\n \"950\": \"#4c0519\"\n }\n }\n] as const;\n","/**\n * The bidirectional Tailwind-token mapping — the heart of the S14 unit,\n * ported from matrx-frontend `utils/color-utils/color-change-util.ts` /\n * `tailwind-color-util.ts`.\n *\n * token → hex: `getColorFromTailwind(\"slate-500\")` → `\"#64748b\"` (plus the\n * fuzzy `formatTailwindColor` for messy user input like `\"skyblue598\"`).\n * color → token: `findNearestTailwindColor` — the verbatim nearest-match\n * scan. The original took a colord instance; the colord coupling is inverted\n * structurally: pass any object with `.delta(hex) => number` (every colord\n * instance with the lab plugin qualifies — no import, no peer), or pass a\n * plain hex / `rgb()` string and the built-in colord-identical CIEDE2000\n * engine (`lab-delta.ts`) computes the distances with zero dependencies.\n */\n\nimport { parseHexOrRgb, rgbDelta } from \"./lab-delta\";\nimport { tailwindColors } from \"./tailwind-colors\";\n\n/**\n * Anything that can measure its perceptual distance to a hex color —\n * structurally satisfied by a colord instance extended with the lab plugin.\n */\nexport interface ColorDelta {\n delta(color: string): number;\n}\n\n/**\n * Function to find the hex value for a given Tailwind color string.\n * @param tailwindColorString - The Tailwind color string (e.g., 'slate-500').\n * @returns The hex value of the corresponding color (e.g., '#64748b'), or an empty string if not found.\n */\nexport function getColorFromTailwind(tailwindColorString: string): string {\n const [colorName, shade] = tailwindColorString.split('-');\n const colorGroup = tailwindColors.find(group => group.name.toLowerCase() === (colorName ?? '').toLowerCase());\n if (colorGroup) {\n const shadeEntry = Object.entries(colorGroup.shades).find(([key]) => key === shade);\n if (shadeEntry) {\n return shadeEntry[1];\n }\n }\n return '';\n}\n\n/**\n * Function to find the nearest Tailwind color for a given input color.\n * @param inputColor - The input color: a hex or `rgb()` string, or any\n * `{ delta(hex) }` measurer (e.g. a colord instance with the lab plugin).\n * @returns The nearest Tailwind color string (e.g., 'slate-500'), or an\n * empty string when a string input cannot be parsed.\n */\nexport function findNearestTailwindColor(inputColor: string | ColorDelta): string {\n let measure: (hexValue: string) => number;\n if (typeof inputColor === \"string\") {\n const rgb = parseHexOrRgb(inputColor);\n if (!rgb) return \"\";\n measure = (hexValue) => {\n const target = parseHexOrRgb(hexValue);\n // The palette is all six-digit hex; unparseable is impossible here.\n return target ? rgbDelta(rgb, target) : Infinity;\n };\n } else {\n measure = (hexValue) => inputColor.delta(hexValue);\n }\n\n let nearestColor = \"\";\n let smallestDistance = Infinity;\n\n tailwindColors.forEach((colorGroup) => {\n Object.entries(colorGroup.shades).forEach(([shade, hexValue]) => {\n const distance = measure(hexValue);\n if (distance < smallestDistance) {\n smallestDistance = distance;\n nearestColor = `${colorGroup.name.toLowerCase()}-${shade}`;\n }\n });\n });\n\n return nearestColor;\n}\n\n/**\n * Utility to format a Tailwind color string.\n * Matches Tailwind color names and returns the closest Tailwind value.\n * Handles cases like \"skyblue600\", \"sky598\", or \"sky-600\".\n * @param tailwindColor - The user-provided Tailwind color string.\n * @returns A properly formatted Tailwind color string.\n */\nexport function formatTailwindColor(tailwindColor: string): string {\n const tailwindColorNames = [\n \"Slate\", \"Gray\", \"Zinc\", \"Neutral\", \"Stone\", \"Red\", \"Orange\", \"Amber\", \"Yellow\", \"Lime\", \"Green\",\n \"Emerald\", \"Teal\", \"Cyan\", \"Blue\", \"Indigo\", \"Violet\",\"Sky\", \"Purple\", \"Fuchsia\", \"Pink\", \"Rose\"\n ];\n\n // Step 1: Try to match the string to extract the numeric part (shade)\n const splitIndex = tailwindColor.search(/\\d/); // Find the index where numbers start\n\n // Case 1: If there is no numeric part, default to shade 500\n if (splitIndex === -1) {\n const colorName = tailwindColorNames.find(color => tailwindColor.toLowerCase().includes(color.toLowerCase()));\n if (colorName) {\n return getColorFromTailwind(`${colorName.toLowerCase()}-500`); // Default to 500 if no shade provided\n }\n }\n\n // Case 2: There is a numeric part, so handle compound names and numeric values\n if (splitIndex > 0) {\n const colorNamePart = tailwindColor.slice(0, splitIndex); // Get color name part\n let shadePart = tailwindColor.slice(splitIndex); // Get shade part\n\n // Step 2: Find all matching color names in the provided color part\n const matchedColors = tailwindColorNames.filter(color => colorNamePart.toLowerCase().includes(color.toLowerCase()));\n\n // Step 3: Sort matches based on appearance in the string (we want the first match in the original string)\n matchedColors.sort((a, b) => colorNamePart.toLowerCase().indexOf(a.toLowerCase()) - colorNamePart.toLowerCase().indexOf(b.toLowerCase()));\n\n // Step 4: Use the first matching color name (if found)\n if (matchedColors.length > 0) {\n const colorName = (matchedColors[0] as string).toLowerCase(); // The first matched color\n\n // Round the shade to the nearest 100 and convert to string\n let shade = Math.round(parseInt(shadePart) / 100) * 100;\n const formattedColor = getColorFromTailwind(`${colorName}-${shade.toString()}`);\n\n // Return the formatted color if found\n if (formattedColor) {\n return formattedColor;\n }\n }\n }\n\n // If no valid format is found, return an empty string\n return '';\n}\n","/**\n * The pure input normalizers — ported verbatim from matrx-frontend\n * `utils/color-utils/color-change-util.ts`. Each takes the messy shape a\n * human pastes (\"61, 135, 204\", \"r:61,g:135,b:204\", \"94% 29% 0% 9%\",\n * \"0x3d87cc\"…) and returns the canonical string for that format, or `''`\n * when the input does not fit — string in, string out, zero dependencies.\n *\n * ONE deliberate divergence from the original: `formatLabString` /\n * `formatLchString` logged every call (input, match, miss) with\n * unconditional `console.log`s — debug spam on a parse path, removed here.\n * Matching/return behavior is unchanged.\n */\n\n/**\n * Utility to format a hex string.\n * Adds the # prefix if missing.\n * @param hex - The user-provided hex color.\n * @returns A properly formatted hex color string.\n */\nexport function formatHex(hex: string): string {\n // Check if the hex is missing the # symbol and add it\n return hex.startsWith('#') ? hex : `#${hex}`;\n}\n\n/**\n * Utility to format an rgb string.\n * Accepts various formats like \"61, 135, 204\" or \"(61, 135, 204)\".\n * @param rgb - The user-provided rgb color.\n * @returns A properly formatted rgb color string.\n */\nexport function formatRgbString(rgb: string): string {\n // Extract numbers from the string\n const rgbValues = rgb.replace(/[^\\d,]/g, '').split(',');\n if (rgbValues.length === 3) {\n return `rgb(${(rgbValues[0] as string).trim()}, ${(rgbValues[1] as string).trim()}, ${(rgbValues[2] as string).trim()})`;\n }\n return ''; // Return an empty string for invalid cases\n}\n\n/**\n * Utility to format an RGB object.\n * Accepts various object-like formats such as '{\"r\":61,\"g\":135,\"b\":204,\"a\":1}', '\"r\":61,\"g\":135,\"b\":204,\"a\":1', or 'r:61,g:135,b:204,a:1'.\n * @param rgbObject - The user-provided RGB object-like string.\n * @returns A properly formatted RGB object.\n */\nexport function formatRgbObject(rgbObject: string): string {\n // Flexible regex to match and capture r, g, b, a values, regardless of quotes, brackets, or missing attributes\n const regex = /[\"']?r[\"']?\\s*[:=]\\s*(\\d+)\\s*[,]\\s*[\"']?g[\"']?\\s*[:=]\\s*(\\d+)\\s*[,]\\s*[\"']?b[\"']?\\s*[:=]\\s*(\\d+)(?:\\s*[,]\\s*[\"']?a[\"']?\\s*[:=]\\s*(\\d+))?/i;\n const match = rgbObject.match(regex);\n\n if (match) {\n const r = match[1], g = match[2], b = match[3], a = match[4] || 1;\n // Return a normalized RGB(A) object string\n return `{\"r\":${r},\"g\":${g},\"b\":${b},\"a\":${a}}`;\n }\n\n // If input is invalid, return an empty string\n return '';\n}\n\n/**\n * Utility to format an HSL object.\n * Accepts various object-like formats such as '{\"h\":199,\"s\":89,\"l\":48,\"a\":1}' or 'h:199,s:89,l:48,a:1'.\n * @param hslObject - The user-provided HSL object-like string.\n * @returns A properly formatted HSL object.\n */\nexport function formatHslObject(hslObject: string): string {\n // Flexible regex to match and capture h, s, l, a values, regardless of quotes, brackets, or missing attributes\n const regex = /[\"']?h[\"']?\\s*[:=]\\s*(\\d+)\\s*,\\s*[\"']?s[\"']?\\s*[:=]\\s*(\\d+)\\s*,\\s*[\"']?l[\"']?\\s*[:=]\\s*(\\d+)(?:\\s*,\\s*[\"']?a[\"']?\\s*[:=]\\s*(\\d+))?/i;\n const match = hslObject.match(regex);\n if (match) {\n const h = match[1], s = match[2], l = match[3], a = match[4] || 1;\n return `{\"h\":${h},\"s\":${s},\"l\":${l},\"a\":${a}}`;\n }\n return ''; // Return empty string for invalid input\n}\n\n/**\n * Utility to format an HSL string.\n * Accepts formats like \"hsl(199, 89%, 48%)\" or \"199, 89%, 48%\".\n * @param hslString - The user-provided HSL string.\n * @returns A properly formatted HSL string.\n */\nexport function formatHslString(hslString: string): string {\n // Extract numbers and percentage values\n const hslValues = hslString.replace(/[^\\d,%]/g, '').split(/\\s*,\\s*/);\n if (hslValues.length === 3) {\n return `hsl(${hslValues[0]}, ${hslValues[1]}%, ${hslValues[2]}%)`;\n }\n return ''; // Return empty string for invalid cases\n}\n\n/**\n * Utility to format an HSV percentage string.\n * Accepts formats like \"94% 29% 0%\" or \"(94% 29% 0%)\".\n * @param hsvString - The user-provided HSV percentage string.\n * @returns A properly formatted HSV string.\n */\nexport function formatHsvString(hsvString: string): string {\n // Remove parentheses and other non-relevant characters, then split based on spaces\n const hsvValues = hsvString.replace(/[^\\d%\\s]/g, '').split(/\\s+/).map(value => parseInt(value.replace('%', ''), 10));\n\n // Check if there are exactly 3 values for HSV (Hue, Saturation, Value)\n if (hsvValues.length === 3 && hsvValues.every(val => !isNaN(val))) {\n return `hsv(${hsvValues[0]}, ${hsvValues[1]}%, ${hsvValues[2]}%)`;\n }\n return ''; // Return empty string for invalid input\n}\n\n/**\n * Utility to format a regular CMYK string.\n * Accepts formats like \"94, 29, 0, 9\" or \"(94, 29, 0, 9)\".\n * @param cmykString - The user-provided CMYK string.\n * @returns A properly formatted CMYK string.\n */\nexport function formatRegularCmykString(cmykString: string): string {\n const cmykValues = cmykString.replace(/[^\\d,]/g, '').split(/\\s*,\\s*/);\n\n if (cmykValues.length === 4 && cmykValues.every(val => !isNaN(Number(val)))) {\n return `cmyk(${cmykValues[0]}, ${cmykValues[1]}, ${cmykValues[2]}, ${cmykValues[3]})`;\n }\n return ''; // Return empty string for invalid input\n}\n\n/**\n * Utility to format a CMYK object.\n * Accepts various object-like formats such as '{\"c\":94,\"m\":29,\"y\":0,\"k\":9,\"a\":1}' or 'c:94,m:29,y:0,k:9,a:1'.\n * @param cmykObject - The user-provided CMYK object-like string.\n * @returns A properly formatted CMYK object.\n */\nexport function formatCmykObject(cmykObject: string): string {\n // Flexible regex to match and capture c, m, y, k, a values, regardless of quotes or brackets\n const regex = /[\"']?c[\"']?\\s*[:=]\\s*(\\d+)\\s*,\\s*[\"']?m[\"']?\\s*[:=]\\s*(\\d+)\\s*,\\s*[\"']?y[\"']?\\s*[:=]\\s*(\\d+)\\s*,\\s*[\"']?k[\"']?\\s*[:=]\\s*(\\d+)(?:\\s*,\\s*[\"']?a[\"']?\\s*[:=]\\s*(\\d+))?/i;\n const match = cmykObject.match(regex);\n\n if (match) {\n const c = match[1], m = match[2], y = match[3], k = match[4], a = match[5] || 1;\n return `{\"c\":${c},\"m\":${m},\"y\":${y},\"k\":${k},\"a\":${a}}`;\n }\n return ''; // Return empty string for invalid input\n}\n\n/**\n * Utility to format a CMYK percentage string.\n * Accepts formats like \"94% 29% 0% 9%\" or \"(94% 29% 0% 9%)\".\n * @param cmykString - The user-provided CMYK percentage string.\n * @returns A properly formatted CMYK string.\n */\nexport function formatCmykString(cmykString: string): string {\n // Remove any parentheses or extra characters, then split based on spaces\n const cmykValues = cmykString.replace(/[^\\d%\\s]/g, '').split(/\\s+/).map(value => parseInt(value.replace('%', ''), 10));\n\n if (cmykValues.length === 4 && cmykValues.every(val => !isNaN(val))) {\n return `device-cmyk(${cmykValues[0]}% ${cmykValues[1]}% ${cmykValues[2]}% ${cmykValues[3]}%)`;\n }\n return ''; // Return empty string for invalid input\n}\n\n/**\n * Utility to detect device-cmyk color strings (\"device-cmyk(94% 29% 0% 9%)\").\n * @param cmykString - The user-provided CMYK string.\n * @returns True when the string is a well-formed device-cmyk expression.\n */\nexport function isDeviceCmyk(cmykString: string): boolean {\n const regex = /device-cmyk\\(\\s*\\d+%\\s+\\d+%\\s+\\d+%\\s+\\d+%\\s*\\)/;\n return regex.test(cmykString);\n}\n\n/**\n * Utility to format an HWB string.\n * Accepts formats like \"hwb(199 24% 20%)\" or \"hwb(199deg 24% 20%)\".\n * @param hwbString - The user-provided HWB string.\n * @returns A properly formatted HWB string.\n */\nexport function formatHwbString(hwbString: string): string {\n // Extract numbers and percentage values from the HWB string\n const hwbValues = hwbString.replace(/[^\\d,%\\s]/g, '').split(/\\s+/);\n if (hwbValues.length === 3) {\n return `hwb(${hwbValues[0]}, ${hwbValues[1]}%, ${hwbValues[2]}%)`;\n }\n return ''; // Return empty string for invalid cases\n}\n\n/**\n * Utility to format a Lab string.\n * Accepts formats like \"lab(55.715 -14.02 -32.329)\" or \"55.715 -14.02 -32.329\".\n * @param labString - The user-provided Lab string.\n * @returns A properly formatted Lab string.\n */\nexport function formatLabString(labString: string): string {\n // Try matching with or without the \"lab(\" prefix\n const match = labString.match(/(?:lab\\()?\\s*(-?\\d+(?:\\.\\d+)?)\\s+(-?\\d+(?:\\.\\d+)?)\\s+(-?\\d+(?:\\.\\d+)?)\\s*\\)?/i);\n\n if (match) {\n const [, l, a, b] = match;\n return `lab(${l} ${a} ${b})`;\n }\n\n return ''; // Return empty string for invalid cases\n}\n\n/**\n * Utility to format an LCH string.\n * Accepts formats like \"lch(55.715 35.17 246.6)\" or \"55.715 35.17 246.6\".\n * @param lchString - The user-provided LCH string.\n * @returns A properly formatted LCH string.\n */\nexport function formatLchString(lchString: string): string {\n // Try matching with or without the \"lch(\" prefix\n const match = lchString.match(/(?:lch\\()?\\s*(-?\\d+(?:\\.\\d+)?)\\s+(-?\\d+(?:\\.\\d+)?)\\s+(-?\\d+(?:\\.\\d+)?)\\s*\\)?/i);\n\n if (match) {\n const [, l, c, h] = match;\n return `lch(${l} ${c} ${h})`;\n }\n\n return ''; // Return empty string for invalid cases\n}\n\n/**\n * Utility to format a hex string with 0x prefix.\n * Converts \"0x3d87cc\" to \"#3d87cc\".\n * @param hex - The user-provided hex color with 0x prefix.\n * @returns A properly formatted hex color string.\n */\nexport function formatHexWith0x(hex: string): string {\n if (hex.startsWith('0x')) {\n return `#${hex.slice(2)}`;\n }\n return ''; // Return empty string for invalid cases\n}\n","/**\n * The \"accept anything a human pastes\" waterfall — ported from matrx-frontend\n * `color-change-util.ts` `normalizeColorInput`, with the colord coupling\n * inverted: the original gated several tiers on `colord(input).isValid()`;\n * here the host injects that validity check (`createColorNormalizer({\n * isValid })` — pass `(c) => colord(c).isValid()` or any equivalent). The\n * tier ORDER, the tiers that skip validation, and the returned\n * `{ value, type }` shapes are verbatim.\n *\n * Deliberate divergence (same class as formats.ts): the original logged every\n * tier hit/miss with unconditional `console.log`s — removed.\n */\n\nimport {\n formatCmykObject,\n formatCmykString,\n formatHex,\n formatHexWith0x,\n formatHslObject,\n formatHslString,\n formatHsvString,\n formatHwbString,\n formatLabString,\n formatLchString,\n formatRegularCmykString,\n formatRgbObject,\n formatRgbString,\n isDeviceCmyk,\n} from \"./formats\";\nimport { formatTailwindColor } from \"./tailwind\";\n\nexport interface NormalizedColor {\n value: string;\n type: string;\n}\n\nexport interface ColorNormalizerOptions {\n /**\n * \"Can this string be parsed as a color?\" — the host's color engine\n * (e.g. `(c) => colord(c).isValid()`).\n */\n isValid: (color: string) => boolean;\n}\n\n/**\n * Builds `normalizeColorInput`: tries the format conversions in the original\n * fixed order until one produces a valid (or structurally well-formed) color,\n * returning `{ value, type }`, or `null` when nothing fits.\n */\nexport function createColorNormalizer({ isValid }: ColorNormalizerOptions) {\n return function normalizeColorInput(colorInput: string): NormalizedColor | null {\n // Try standard validation first\n if (isValid(colorInput)) {\n return { value: colorInput, type: 'standard' };\n }\n\n // Check for 'device-cmyk' manually\n if (isDeviceCmyk(colorInput)) {\n return { value: colorInput, type: 'device-cmyk' };\n }\n\n // Try hex conversion\n const hex = formatHex(colorInput);\n if (isValid(hex)) {\n return { value: hex, type: 'hex' };\n }\n\n // Try RGB string conversion\n const rgbString = formatRgbString(colorInput);\n if (isValid(rgbString)) {\n return { value: rgbString, type: 'rgb' };\n }\n\n // Try RGB object conversion (skip isValid for this)\n const rgbObject = formatRgbObject(colorInput);\n if (rgbObject !== '') {\n return { value: rgbObject, type: 'rgb-object' };\n }\n\n // Try HSL object conversion (skip isValid for this)\n const hslObject = formatHslObject(colorInput);\n if (hslObject !== '') {\n return { value: hslObject, type: 'hsl-object' };\n }\n\n // Try HSL string conversion\n const hslString = formatHslString(colorInput);\n if (isValid(hslString)) {\n return { value: hslString, type: 'hsl' };\n }\n\n // Try HSV string conversion\n const hsvString = formatHsvString(colorInput);\n if (isValid(hsvString)) {\n return { value: hsvString, type: 'hsv' };\n }\n\n // Try Tailwind color conversion\n const tailwindColor = formatTailwindColor(colorInput);\n if (tailwindColor !== '') {\n return { value: tailwindColor, type: 'tailwind' };\n }\n\n // Try regular CMYK string conversion (skip isValid for this)\n const regularCmykString = formatRegularCmykString(colorInput);\n if (regularCmykString !== '') {\n return { value: regularCmykString, type: 'cmyk' };\n }\n\n // Try CMYK object conversion (skip isValid for this)\n const cmykObject = formatCmykObject(colorInput);\n if (cmykObject !== '') {\n return { value: cmykObject, type: 'cmyk-object' };\n }\n\n // Try CMYK percentage string conversion (for device-cmyk)\n const cmykString = formatCmykString(colorInput);\n if (isValid(cmykString)) {\n return { value: cmykString, type: 'cmyk-percentage' };\n }\n\n // Try HWB string conversion\n const hwbString = formatHwbString(colorInput);\n if (isValid(hwbString)) {\n return { value: hwbString, type: 'hwb' };\n }\n\n // Try Lab string conversion (skip isValid for this)\n const labString = formatLabString(colorInput);\n if (labString !== '') {\n return { value: labString, type: 'lab' };\n }\n\n // Try LCH string conversion (skip isValid for this)\n const lchString = formatLchString(colorInput);\n if (lchString !== '') {\n return { value: lchString, type: 'lch' };\n }\n\n // Try hex with 0x conversion\n const hexWith0x = formatHexWith0x(colorInput);\n if (isValid(hexWith0x)) {\n return { value: hexWith0x, type: 'hex-0x' };\n }\n\n // If all else fails, return null\n return null;\n };\n}\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AU;AAC5C,QAAI,cAAc,IAAI;AAClB,aAAO,EAAE,OAAO,WAAW,MAAM,MAAM;AAAA,IAC3C;AAGA,UAAM,YAAY,gBAAgB,UAAU;AAC5C,QAAI,cAAc,IAAI;AAClB,aAAO,EAAE,OAAO,WAAW,MAAM,MAAM;AAAA,IAC3C;AAGA,UAAM,YAAY,gBAAgB,UAAU;AAC5C,QAAI,QAAQ,SAAS,GAAG;AACpB,aAAO,EAAE,OAAO,WAAW,MAAM,SAAS;AAAA,IAC9C;AAGA,WAAO;AAAA,EACX;AACJ;","names":[]}
@@ -0,0 +1,235 @@
1
+ /**
2
+ * The bidirectional Tailwind-token mapping — the heart of the S14 unit,
3
+ * ported from matrx-frontend `utils/color-utils/color-change-util.ts` /
4
+ * `tailwind-color-util.ts`.
5
+ *
6
+ * token → hex: `getColorFromTailwind("slate-500")` → `"#64748b"` (plus the
7
+ * fuzzy `formatTailwindColor` for messy user input like `"skyblue598"`).
8
+ * color → token: `findNearestTailwindColor` — the verbatim nearest-match
9
+ * scan. The original took a colord instance; the colord coupling is inverted
10
+ * structurally: pass any object with `.delta(hex) => number` (every colord
11
+ * instance with the lab plugin qualifies — no import, no peer), or pass a
12
+ * plain hex / `rgb()` string and the built-in colord-identical CIEDE2000
13
+ * engine (`lab-delta.ts`) computes the distances with zero dependencies.
14
+ */
15
+ /**
16
+ * Anything that can measure its perceptual distance to a hex color —
17
+ * structurally satisfied by a colord instance extended with the lab plugin.
18
+ */
19
+ interface ColorDelta {
20
+ delta(color: string): number;
21
+ }
22
+ /**
23
+ * Function to find the hex value for a given Tailwind color string.
24
+ * @param tailwindColorString - The Tailwind color string (e.g., 'slate-500').
25
+ * @returns The hex value of the corresponding color (e.g., '#64748b'), or an empty string if not found.
26
+ */
27
+ declare function getColorFromTailwind(tailwindColorString: string): string;
28
+ /**
29
+ * Function to find the nearest Tailwind color for a given input color.
30
+ * @param inputColor - The input color: a hex or `rgb()` string, or any
31
+ * `{ delta(hex) }` measurer (e.g. a colord instance with the lab plugin).
32
+ * @returns The nearest Tailwind color string (e.g., 'slate-500'), or an
33
+ * empty string when a string input cannot be parsed.
34
+ */
35
+ declare function findNearestTailwindColor(inputColor: string | ColorDelta): string;
36
+ /**
37
+ * Utility to format a Tailwind color string.
38
+ * Matches Tailwind color names and returns the closest Tailwind value.
39
+ * Handles cases like "skyblue600", "sky598", or "sky-600".
40
+ * @param tailwindColor - The user-provided Tailwind color string.
41
+ * @returns A properly formatted Tailwind color string.
42
+ */
43
+ declare function formatTailwindColor(tailwindColor: string): string;
44
+
45
+ /**
46
+ * The Tailwind CSS default palette lookup table — ported verbatim from
47
+ * matrx-frontend `constants/tailwind-colors.ts` (the data the S14
48
+ * "tailwind-color-util" unit does its lookups against). 22 color groups,
49
+ * shades 50–950.
50
+ */
51
+ interface TailwindColorGroup {
52
+ name: string;
53
+ shades: Record<string, string>;
54
+ }
55
+ declare const tailwindColors: readonly TailwindColorGroup[];
56
+
57
+ /**
58
+ * The pure input normalizers — ported verbatim from matrx-frontend
59
+ * `utils/color-utils/color-change-util.ts`. Each takes the messy shape a
60
+ * human pastes ("61, 135, 204", "r:61,g:135,b:204", "94% 29% 0% 9%",
61
+ * "0x3d87cc"…) and returns the canonical string for that format, or `''`
62
+ * when the input does not fit — string in, string out, zero dependencies.
63
+ *
64
+ * ONE deliberate divergence from the original: `formatLabString` /
65
+ * `formatLchString` logged every call (input, match, miss) with
66
+ * unconditional `console.log`s — debug spam on a parse path, removed here.
67
+ * Matching/return behavior is unchanged.
68
+ */
69
+ /**
70
+ * Utility to format a hex string.
71
+ * Adds the # prefix if missing.
72
+ * @param hex - The user-provided hex color.
73
+ * @returns A properly formatted hex color string.
74
+ */
75
+ declare function formatHex(hex: string): string;
76
+ /**
77
+ * Utility to format an rgb string.
78
+ * Accepts various formats like "61, 135, 204" or "(61, 135, 204)".
79
+ * @param rgb - The user-provided rgb color.
80
+ * @returns A properly formatted rgb color string.
81
+ */
82
+ declare function formatRgbString(rgb: string): string;
83
+ /**
84
+ * Utility to format an RGB object.
85
+ * Accepts various object-like formats such as '{"r":61,"g":135,"b":204,"a":1}', '"r":61,"g":135,"b":204,"a":1', or 'r:61,g:135,b:204,a:1'.
86
+ * @param rgbObject - The user-provided RGB object-like string.
87
+ * @returns A properly formatted RGB object.
88
+ */
89
+ declare function formatRgbObject(rgbObject: string): string;
90
+ /**
91
+ * Utility to format an HSL object.
92
+ * Accepts various object-like formats such as '{"h":199,"s":89,"l":48,"a":1}' or 'h:199,s:89,l:48,a:1'.
93
+ * @param hslObject - The user-provided HSL object-like string.
94
+ * @returns A properly formatted HSL object.
95
+ */
96
+ declare function formatHslObject(hslObject: string): string;
97
+ /**
98
+ * Utility to format an HSL string.
99
+ * Accepts formats like "hsl(199, 89%, 48%)" or "199, 89%, 48%".
100
+ * @param hslString - The user-provided HSL string.
101
+ * @returns A properly formatted HSL string.
102
+ */
103
+ declare function formatHslString(hslString: string): string;
104
+ /**
105
+ * Utility to format an HSV percentage string.
106
+ * Accepts formats like "94% 29% 0%" or "(94% 29% 0%)".
107
+ * @param hsvString - The user-provided HSV percentage string.
108
+ * @returns A properly formatted HSV string.
109
+ */
110
+ declare function formatHsvString(hsvString: string): string;
111
+ /**
112
+ * Utility to format a regular CMYK string.
113
+ * Accepts formats like "94, 29, 0, 9" or "(94, 29, 0, 9)".
114
+ * @param cmykString - The user-provided CMYK string.
115
+ * @returns A properly formatted CMYK string.
116
+ */
117
+ declare function formatRegularCmykString(cmykString: string): string;
118
+ /**
119
+ * Utility to format a CMYK object.
120
+ * Accepts various object-like formats such as '{"c":94,"m":29,"y":0,"k":9,"a":1}' or 'c:94,m:29,y:0,k:9,a:1'.
121
+ * @param cmykObject - The user-provided CMYK object-like string.
122
+ * @returns A properly formatted CMYK object.
123
+ */
124
+ declare function formatCmykObject(cmykObject: string): string;
125
+ /**
126
+ * Utility to format a CMYK percentage string.
127
+ * Accepts formats like "94% 29% 0% 9%" or "(94% 29% 0% 9%)".
128
+ * @param cmykString - The user-provided CMYK percentage string.
129
+ * @returns A properly formatted CMYK string.
130
+ */
131
+ declare function formatCmykString(cmykString: string): string;
132
+ /**
133
+ * Utility to detect device-cmyk color strings ("device-cmyk(94% 29% 0% 9%)").
134
+ * @param cmykString - The user-provided CMYK string.
135
+ * @returns True when the string is a well-formed device-cmyk expression.
136
+ */
137
+ declare function isDeviceCmyk(cmykString: string): boolean;
138
+ /**
139
+ * Utility to format an HWB string.
140
+ * Accepts formats like "hwb(199 24% 20%)" or "hwb(199deg 24% 20%)".
141
+ * @param hwbString - The user-provided HWB string.
142
+ * @returns A properly formatted HWB string.
143
+ */
144
+ declare function formatHwbString(hwbString: string): string;
145
+ /**
146
+ * Utility to format a Lab string.
147
+ * Accepts formats like "lab(55.715 -14.02 -32.329)" or "55.715 -14.02 -32.329".
148
+ * @param labString - The user-provided Lab string.
149
+ * @returns A properly formatted Lab string.
150
+ */
151
+ declare function formatLabString(labString: string): string;
152
+ /**
153
+ * Utility to format an LCH string.
154
+ * Accepts formats like "lch(55.715 35.17 246.6)" or "55.715 35.17 246.6".
155
+ * @param lchString - The user-provided LCH string.
156
+ * @returns A properly formatted LCH string.
157
+ */
158
+ declare function formatLchString(lchString: string): string;
159
+ /**
160
+ * Utility to format a hex string with 0x prefix.
161
+ * Converts "0x3d87cc" to "#3d87cc".
162
+ * @param hex - The user-provided hex color with 0x prefix.
163
+ * @returns A properly formatted hex color string.
164
+ */
165
+ declare function formatHexWith0x(hex: string): string;
166
+
167
+ /**
168
+ * The "accept anything a human pastes" waterfall — ported from matrx-frontend
169
+ * `color-change-util.ts` `normalizeColorInput`, with the colord coupling
170
+ * inverted: the original gated several tiers on `colord(input).isValid()`;
171
+ * here the host injects that validity check (`createColorNormalizer({
172
+ * isValid })` — pass `(c) => colord(c).isValid()` or any equivalent). The
173
+ * tier ORDER, the tiers that skip validation, and the returned
174
+ * `{ value, type }` shapes are verbatim.
175
+ *
176
+ * Deliberate divergence (same class as formats.ts): the original logged every
177
+ * tier hit/miss with unconditional `console.log`s — removed.
178
+ */
179
+ interface NormalizedColor {
180
+ value: string;
181
+ type: string;
182
+ }
183
+ interface ColorNormalizerOptions {
184
+ /**
185
+ * "Can this string be parsed as a color?" — the host's color engine
186
+ * (e.g. `(c) => colord(c).isValid()`).
187
+ */
188
+ isValid: (color: string) => boolean;
189
+ }
190
+ /**
191
+ * Builds `normalizeColorInput`: tries the format conversions in the original
192
+ * fixed order until one produces a valid (or structurally well-formed) color,
193
+ * returning `{ value, type }`, or `null` when nothing fits.
194
+ */
195
+ declare function createColorNormalizer({ isValid }: ColorNormalizerOptions): (colorInput: string) => NormalizedColor | null;
196
+
197
+ /**
198
+ * The zero-dependency perceptual-distance engine behind the string input path
199
+ * of `findNearestTailwindColor`.
200
+ *
201
+ * The matrx-frontend original computed distance through colord's lab plugin
202
+ * (`colordInstance.delta(hex)`). This module reproduces that plugin's exact
203
+ * pipeline — sRGB → XYZ(D65) → chromatic adaptation to D50 (colord's
204
+ * matrices, including its channel clamps) → CIE L*a*b* rounded to 2 decimals
205
+ * → CIEDE2000 (colord >= 2.10 formulation) ÷ 100, rounded to 3 decimals and
206
+ * clamped to [0, 1] — so the nearest-token answer is bit-identical to the
207
+ * colord path. The test suite cross-checks this against colord itself (a
208
+ * devDependency only).
209
+ */
210
+ interface Rgb {
211
+ r: number;
212
+ g: number;
213
+ b: number;
214
+ }
215
+ interface Lab {
216
+ l: number;
217
+ a: number;
218
+ b: number;
219
+ }
220
+ /** RGB → CIE L*a*b*, rounded to 2 decimals exactly like colord's `toLab`. */
221
+ declare function rgbToLab(rgb: Rgb): Lab;
222
+ /**
223
+ * Perceptual distance between two RGB colors, normalized exactly like
224
+ * colord's `.delta()`: CIEDE2000 / 100, rounded to 3 decimals, clamped [0,1].
225
+ */
226
+ declare function rgbDelta(rgb1: Rgb, rgb2: Rgb): number;
227
+ /**
228
+ * Parses the two input shapes this unit is chartered for — hex (`#rgb`,
229
+ * `#rrggbb`, with or without `#`, alpha digits tolerated and ignored) and
230
+ * `rgb()`/`rgba()` strings — into RGB channels. Returns `null` for anything
231
+ * else; this is deliberately NOT a general CSS color parser.
232
+ */
233
+ declare function parseHexOrRgb(input: string): Rgb | null;
234
+
235
+ export { type ColorDelta, type ColorNormalizerOptions, type NormalizedColor, type Rgb, type TailwindColorGroup, createColorNormalizer, findNearestTailwindColor, formatCmykObject, formatCmykString, formatHex, formatHexWith0x, formatHslObject, formatHslString, formatHsvString, formatHwbString, formatLabString, formatLchString, formatRegularCmykString, formatRgbObject, formatRgbString, formatTailwindColor, getColorFromTailwind, isDeviceCmyk, parseHexOrRgb, rgbDelta, rgbToLab, tailwindColors };
@@ -0,0 +1,235 @@
1
+ /**
2
+ * The bidirectional Tailwind-token mapping — the heart of the S14 unit,
3
+ * ported from matrx-frontend `utils/color-utils/color-change-util.ts` /
4
+ * `tailwind-color-util.ts`.
5
+ *
6
+ * token → hex: `getColorFromTailwind("slate-500")` → `"#64748b"` (plus the
7
+ * fuzzy `formatTailwindColor` for messy user input like `"skyblue598"`).
8
+ * color → token: `findNearestTailwindColor` — the verbatim nearest-match
9
+ * scan. The original took a colord instance; the colord coupling is inverted
10
+ * structurally: pass any object with `.delta(hex) => number` (every colord
11
+ * instance with the lab plugin qualifies — no import, no peer), or pass a
12
+ * plain hex / `rgb()` string and the built-in colord-identical CIEDE2000
13
+ * engine (`lab-delta.ts`) computes the distances with zero dependencies.
14
+ */
15
+ /**
16
+ * Anything that can measure its perceptual distance to a hex color —
17
+ * structurally satisfied by a colord instance extended with the lab plugin.
18
+ */
19
+ interface ColorDelta {
20
+ delta(color: string): number;
21
+ }
22
+ /**
23
+ * Function to find the hex value for a given Tailwind color string.
24
+ * @param tailwindColorString - The Tailwind color string (e.g., 'slate-500').
25
+ * @returns The hex value of the corresponding color (e.g., '#64748b'), or an empty string if not found.
26
+ */
27
+ declare function getColorFromTailwind(tailwindColorString: string): string;
28
+ /**
29
+ * Function to find the nearest Tailwind color for a given input color.
30
+ * @param inputColor - The input color: a hex or `rgb()` string, or any
31
+ * `{ delta(hex) }` measurer (e.g. a colord instance with the lab plugin).
32
+ * @returns The nearest Tailwind color string (e.g., 'slate-500'), or an
33
+ * empty string when a string input cannot be parsed.
34
+ */
35
+ declare function findNearestTailwindColor(inputColor: string | ColorDelta): string;
36
+ /**
37
+ * Utility to format a Tailwind color string.
38
+ * Matches Tailwind color names and returns the closest Tailwind value.
39
+ * Handles cases like "skyblue600", "sky598", or "sky-600".
40
+ * @param tailwindColor - The user-provided Tailwind color string.
41
+ * @returns A properly formatted Tailwind color string.
42
+ */
43
+ declare function formatTailwindColor(tailwindColor: string): string;
44
+
45
+ /**
46
+ * The Tailwind CSS default palette lookup table — ported verbatim from
47
+ * matrx-frontend `constants/tailwind-colors.ts` (the data the S14
48
+ * "tailwind-color-util" unit does its lookups against). 22 color groups,
49
+ * shades 50–950.
50
+ */
51
+ interface TailwindColorGroup {
52
+ name: string;
53
+ shades: Record<string, string>;
54
+ }
55
+ declare const tailwindColors: readonly TailwindColorGroup[];
56
+
57
+ /**
58
+ * The pure input normalizers — ported verbatim from matrx-frontend
59
+ * `utils/color-utils/color-change-util.ts`. Each takes the messy shape a
60
+ * human pastes ("61, 135, 204", "r:61,g:135,b:204", "94% 29% 0% 9%",
61
+ * "0x3d87cc"…) and returns the canonical string for that format, or `''`
62
+ * when the input does not fit — string in, string out, zero dependencies.
63
+ *
64
+ * ONE deliberate divergence from the original: `formatLabString` /
65
+ * `formatLchString` logged every call (input, match, miss) with
66
+ * unconditional `console.log`s — debug spam on a parse path, removed here.
67
+ * Matching/return behavior is unchanged.
68
+ */
69
+ /**
70
+ * Utility to format a hex string.
71
+ * Adds the # prefix if missing.
72
+ * @param hex - The user-provided hex color.
73
+ * @returns A properly formatted hex color string.
74
+ */
75
+ declare function formatHex(hex: string): string;
76
+ /**
77
+ * Utility to format an rgb string.
78
+ * Accepts various formats like "61, 135, 204" or "(61, 135, 204)".
79
+ * @param rgb - The user-provided rgb color.
80
+ * @returns A properly formatted rgb color string.
81
+ */
82
+ declare function formatRgbString(rgb: string): string;
83
+ /**
84
+ * Utility to format an RGB object.
85
+ * Accepts various object-like formats such as '{"r":61,"g":135,"b":204,"a":1}', '"r":61,"g":135,"b":204,"a":1', or 'r:61,g:135,b:204,a:1'.
86
+ * @param rgbObject - The user-provided RGB object-like string.
87
+ * @returns A properly formatted RGB object.
88
+ */
89
+ declare function formatRgbObject(rgbObject: string): string;
90
+ /**
91
+ * Utility to format an HSL object.
92
+ * Accepts various object-like formats such as '{"h":199,"s":89,"l":48,"a":1}' or 'h:199,s:89,l:48,a:1'.
93
+ * @param hslObject - The user-provided HSL object-like string.
94
+ * @returns A properly formatted HSL object.
95
+ */
96
+ declare function formatHslObject(hslObject: string): string;
97
+ /**
98
+ * Utility to format an HSL string.
99
+ * Accepts formats like "hsl(199, 89%, 48%)" or "199, 89%, 48%".
100
+ * @param hslString - The user-provided HSL string.
101
+ * @returns A properly formatted HSL string.
102
+ */
103
+ declare function formatHslString(hslString: string): string;
104
+ /**
105
+ * Utility to format an HSV percentage string.
106
+ * Accepts formats like "94% 29% 0%" or "(94% 29% 0%)".
107
+ * @param hsvString - The user-provided HSV percentage string.
108
+ * @returns A properly formatted HSV string.
109
+ */
110
+ declare function formatHsvString(hsvString: string): string;
111
+ /**
112
+ * Utility to format a regular CMYK string.
113
+ * Accepts formats like "94, 29, 0, 9" or "(94, 29, 0, 9)".
114
+ * @param cmykString - The user-provided CMYK string.
115
+ * @returns A properly formatted CMYK string.
116
+ */
117
+ declare function formatRegularCmykString(cmykString: string): string;
118
+ /**
119
+ * Utility to format a CMYK object.
120
+ * Accepts various object-like formats such as '{"c":94,"m":29,"y":0,"k":9,"a":1}' or 'c:94,m:29,y:0,k:9,a:1'.
121
+ * @param cmykObject - The user-provided CMYK object-like string.
122
+ * @returns A properly formatted CMYK object.
123
+ */
124
+ declare function formatCmykObject(cmykObject: string): string;
125
+ /**
126
+ * Utility to format a CMYK percentage string.
127
+ * Accepts formats like "94% 29% 0% 9%" or "(94% 29% 0% 9%)".
128
+ * @param cmykString - The user-provided CMYK percentage string.
129
+ * @returns A properly formatted CMYK string.
130
+ */
131
+ declare function formatCmykString(cmykString: string): string;
132
+ /**
133
+ * Utility to detect device-cmyk color strings ("device-cmyk(94% 29% 0% 9%)").
134
+ * @param cmykString - The user-provided CMYK string.
135
+ * @returns True when the string is a well-formed device-cmyk expression.
136
+ */
137
+ declare function isDeviceCmyk(cmykString: string): boolean;
138
+ /**
139
+ * Utility to format an HWB string.
140
+ * Accepts formats like "hwb(199 24% 20%)" or "hwb(199deg 24% 20%)".
141
+ * @param hwbString - The user-provided HWB string.
142
+ * @returns A properly formatted HWB string.
143
+ */
144
+ declare function formatHwbString(hwbString: string): string;
145
+ /**
146
+ * Utility to format a Lab string.
147
+ * Accepts formats like "lab(55.715 -14.02 -32.329)" or "55.715 -14.02 -32.329".
148
+ * @param labString - The user-provided Lab string.
149
+ * @returns A properly formatted Lab string.
150
+ */
151
+ declare function formatLabString(labString: string): string;
152
+ /**
153
+ * Utility to format an LCH string.
154
+ * Accepts formats like "lch(55.715 35.17 246.6)" or "55.715 35.17 246.6".
155
+ * @param lchString - The user-provided LCH string.
156
+ * @returns A properly formatted LCH string.
157
+ */
158
+ declare function formatLchString(lchString: string): string;
159
+ /**
160
+ * Utility to format a hex string with 0x prefix.
161
+ * Converts "0x3d87cc" to "#3d87cc".
162
+ * @param hex - The user-provided hex color with 0x prefix.
163
+ * @returns A properly formatted hex color string.
164
+ */
165
+ declare function formatHexWith0x(hex: string): string;
166
+
167
+ /**
168
+ * The "accept anything a human pastes" waterfall — ported from matrx-frontend
169
+ * `color-change-util.ts` `normalizeColorInput`, with the colord coupling
170
+ * inverted: the original gated several tiers on `colord(input).isValid()`;
171
+ * here the host injects that validity check (`createColorNormalizer({
172
+ * isValid })` — pass `(c) => colord(c).isValid()` or any equivalent). The
173
+ * tier ORDER, the tiers that skip validation, and the returned
174
+ * `{ value, type }` shapes are verbatim.
175
+ *
176
+ * Deliberate divergence (same class as formats.ts): the original logged every
177
+ * tier hit/miss with unconditional `console.log`s — removed.
178
+ */
179
+ interface NormalizedColor {
180
+ value: string;
181
+ type: string;
182
+ }
183
+ interface ColorNormalizerOptions {
184
+ /**
185
+ * "Can this string be parsed as a color?" — the host's color engine
186
+ * (e.g. `(c) => colord(c).isValid()`).
187
+ */
188
+ isValid: (color: string) => boolean;
189
+ }
190
+ /**
191
+ * Builds `normalizeColorInput`: tries the format conversions in the original
192
+ * fixed order until one produces a valid (or structurally well-formed) color,
193
+ * returning `{ value, type }`, or `null` when nothing fits.
194
+ */
195
+ declare function createColorNormalizer({ isValid }: ColorNormalizerOptions): (colorInput: string) => NormalizedColor | null;
196
+
197
+ /**
198
+ * The zero-dependency perceptual-distance engine behind the string input path
199
+ * of `findNearestTailwindColor`.
200
+ *
201
+ * The matrx-frontend original computed distance through colord's lab plugin
202
+ * (`colordInstance.delta(hex)`). This module reproduces that plugin's exact
203
+ * pipeline — sRGB → XYZ(D65) → chromatic adaptation to D50 (colord's
204
+ * matrices, including its channel clamps) → CIE L*a*b* rounded to 2 decimals
205
+ * → CIEDE2000 (colord >= 2.10 formulation) ÷ 100, rounded to 3 decimals and
206
+ * clamped to [0, 1] — so the nearest-token answer is bit-identical to the
207
+ * colord path. The test suite cross-checks this against colord itself (a
208
+ * devDependency only).
209
+ */
210
+ interface Rgb {
211
+ r: number;
212
+ g: number;
213
+ b: number;
214
+ }
215
+ interface Lab {
216
+ l: number;
217
+ a: number;
218
+ b: number;
219
+ }
220
+ /** RGB → CIE L*a*b*, rounded to 2 decimals exactly like colord's `toLab`. */
221
+ declare function rgbToLab(rgb: Rgb): Lab;
222
+ /**
223
+ * Perceptual distance between two RGB colors, normalized exactly like
224
+ * colord's `.delta()`: CIEDE2000 / 100, rounded to 3 decimals, clamped [0,1].
225
+ */
226
+ declare function rgbDelta(rgb1: Rgb, rgb2: Rgb): number;
227
+ /**
228
+ * Parses the two input shapes this unit is chartered for — hex (`#rgb`,
229
+ * `#rrggbb`, with or without `#`, alpha digits tolerated and ignored) and
230
+ * `rgb()`/`rgba()` strings — into RGB channels. Returns `null` for anything
231
+ * else; this is deliberately NOT a general CSS color parser.
232
+ */
233
+ declare function parseHexOrRgb(input: string): Rgb | null;
234
+
235
+ export { type ColorDelta, type ColorNormalizerOptions, type NormalizedColor, type Rgb, type TailwindColorGroup, createColorNormalizer, findNearestTailwindColor, formatCmykObject, formatCmykString, formatHex, formatHexWith0x, formatHslObject, formatHslString, formatHsvString, formatHwbString, formatLabString, formatLchString, formatRegularCmykString, formatRgbObject, formatRgbString, formatTailwindColor, getColorFromTailwind, isDeviceCmyk, parseHexOrRgb, rgbDelta, rgbToLab, tailwindColors };