@fluixi/utils 1.0.0-alpha.82 → 1.0.0-alpha.84

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 (129) hide show
  1. package/dist/index.cjs +2858 -1
  2. package/dist/index.mjs +2838 -1
  3. package/dist/lib/array/advanced.cjs +2227 -1
  4. package/dist/lib/array/advanced.mjs +2204 -1
  5. package/dist/lib/array/array.cjs +57 -1
  6. package/dist/lib/array/array.mjs +36 -1
  7. package/dist/lib/array/index.cjs +2344 -1
  8. package/dist/lib/array/index.mjs +2322 -1
  9. package/dist/lib/array/utils.cjs +103 -1
  10. package/dist/lib/array/utils.mjs +82 -1
  11. package/dist/lib/color/color.cjs +2190 -1
  12. package/dist/lib/color/color.mjs +2167 -1
  13. package/dist/lib/color/constants.cjs +380 -1
  14. package/dist/lib/color/constants.mjs +359 -1
  15. package/dist/lib/color/conversions.cjs +629 -1
  16. package/dist/lib/color/conversions.mjs +608 -1
  17. package/dist/lib/color/helpers.cjs +2534 -1
  18. package/dist/lib/color/helpers.mjs +2511 -1
  19. package/dist/lib/color/index.cjs +2641 -1
  20. package/dist/lib/color/index.mjs +2619 -1
  21. package/dist/lib/color/types.cjs +18 -1
  22. package/dist/lib/color/utils.cjs +962 -1
  23. package/dist/lib/color/utils.mjs +939 -1
  24. package/dist/lib/compare/comparators.cjs +171 -1
  25. package/dist/lib/compare/comparators.mjs +150 -1
  26. package/dist/lib/compare/index.cjs +172 -1
  27. package/dist/lib/compare/index.mjs +152 -1
  28. package/dist/lib/crypto/hash.cjs +83 -1
  29. package/dist/lib/crypto/hash.mjs +62 -1
  30. package/dist/lib/crypto/index.cjs +85 -1
  31. package/dist/lib/crypto/index.mjs +62 -1
  32. package/dist/lib/dom/events.cjs +40 -1
  33. package/dist/lib/dom/events.mjs +19 -1
  34. package/dist/lib/dom/index.cjs +78 -1
  35. package/dist/lib/dom/index.mjs +56 -1
  36. package/dist/lib/dom/utils.cjs +57 -1
  37. package/dist/lib/dom/utils.mjs +36 -1
  38. package/dist/lib/functions/functions.cjs +366 -1
  39. package/dist/lib/functions/functions.mjs +345 -1
  40. package/dist/lib/functions/index.cjs +369 -1
  41. package/dist/lib/functions/index.mjs +347 -1
  42. package/dist/lib/functions/types.cjs +18 -1
  43. package/dist/lib/helpers.cjs +78 -1
  44. package/dist/lib/helpers.mjs +59 -1
  45. package/dist/lib/index.cjs +2857 -1
  46. package/dist/lib/index.mjs +2836 -1
  47. package/dist/lib/maths/constants.cjs +70 -1
  48. package/dist/lib/maths/constants.mjs +50 -1
  49. package/dist/lib/maths/fn/advanced.cjs +231 -1
  50. package/dist/lib/maths/fn/advanced.mjs +208 -1
  51. package/dist/lib/maths/fn/basic.cjs +212 -1
  52. package/dist/lib/maths/fn/basic.mjs +191 -1
  53. package/dist/lib/maths/fn/complex.cjs +268 -1
  54. package/dist/lib/maths/fn/complex.mjs +247 -1
  55. package/dist/lib/maths/fn/index.cjs +877 -1
  56. package/dist/lib/maths/fn/index.mjs +855 -1
  57. package/dist/lib/maths/fn/trigo.cjs +179 -1
  58. package/dist/lib/maths/fn/trigo.mjs +156 -1
  59. package/dist/lib/maths/fn/vector.cjs +728 -1
  60. package/dist/lib/maths/fn/vector.mjs +707 -1
  61. package/dist/lib/maths/formatter.cjs +61 -1
  62. package/dist/lib/maths/formatter.mjs +40 -1
  63. package/dist/lib/maths/guards.cjs +164 -1
  64. package/dist/lib/maths/guards.mjs +144 -1
  65. package/dist/lib/maths/index.cjs +1152 -1
  66. package/dist/lib/maths/index.mjs +1130 -1
  67. package/dist/lib/maths/parser.cjs +75 -1
  68. package/dist/lib/maths/parser.mjs +54 -1
  69. package/dist/lib/maths/random.cjs +49 -1
  70. package/dist/lib/maths/random.mjs +28 -1
  71. package/dist/lib/maths/types/advanced.cjs +18 -1
  72. package/dist/lib/maths/types/basic.cjs +18 -1
  73. package/dist/lib/maths/types/index.cjs +19 -1
  74. package/dist/lib/maths/types/index.mjs +1 -0
  75. package/dist/lib/maths/types/negative.cjs +18 -1
  76. package/dist/lib/maths/types/operations.cjs +18 -1
  77. package/dist/lib/object/clone.cjs +88 -1
  78. package/dist/lib/object/clone.mjs +65 -1
  79. package/dist/lib/object/diff.cjs +573 -1
  80. package/dist/lib/object/diff.mjs +550 -1
  81. package/dist/lib/object/getter-setter.cjs +2351 -1
  82. package/dist/lib/object/getter-setter.mjs +2330 -1
  83. package/dist/lib/object/index.cjs +3956 -6
  84. package/dist/lib/object/index.mjs +3936 -6
  85. package/dist/lib/object/merge.cjs +1029 -1
  86. package/dist/lib/object/merge.mjs +1006 -1
  87. package/dist/lib/object/object.cjs +280 -1
  88. package/dist/lib/object/object.mjs +257 -1
  89. package/dist/lib/object/omit.cjs +2022 -1
  90. package/dist/lib/object/omit.mjs +1999 -1
  91. package/dist/lib/object/reconcile.cjs +126 -1
  92. package/dist/lib/object/reconcile.mjs +105 -1
  93. package/dist/lib/object/selector.cjs +303 -1
  94. package/dist/lib/object/selector.mjs +282 -1
  95. package/dist/lib/object/sort.cjs +209 -1
  96. package/dist/lib/object/sort.mjs +186 -1
  97. package/dist/lib/object/transform.cjs +2211 -1
  98. package/dist/lib/object/transform.mjs +2190 -1
  99. package/dist/lib/object/types.cjs +18 -1
  100. package/dist/lib/object/utils.cjs +326 -6
  101. package/dist/lib/object/utils.mjs +305 -6
  102. package/dist/lib/primitive/boolean/boolean.cjs +407 -1
  103. package/dist/lib/primitive/boolean/boolean.mjs +386 -1
  104. package/dist/lib/primitive/boolean/index.cjs +382 -1
  105. package/dist/lib/primitive/boolean/index.mjs +359 -1
  106. package/dist/lib/primitive/boolean/types.cjs +18 -1
  107. package/dist/lib/primitive/date/date.cjs +1126 -1
  108. package/dist/lib/primitive/date/date.mjs +1105 -1
  109. package/dist/lib/primitive/date/index.cjs +1128 -1
  110. package/dist/lib/primitive/date/index.mjs +1105 -1
  111. package/dist/lib/primitive/date/types.cjs +18 -1
  112. package/dist/lib/primitive/index.cjs +2338 -5
  113. package/dist/lib/primitive/index.mjs +2316 -5
  114. package/dist/lib/primitive/string/index.cjs +875 -5
  115. package/dist/lib/primitive/string/index.mjs +852 -5
  116. package/dist/lib/primitive/string/parser-2.cjs +543 -8
  117. package/dist/lib/primitive/string/parser-2.mjs +522 -8
  118. package/dist/lib/primitive/string/parser.cjs +236 -3
  119. package/dist/lib/primitive/string/parser.mjs +215 -3
  120. package/dist/lib/primitive/string/string.cjs +926 -5
  121. package/dist/lib/primitive/string/string.mjs +903 -5
  122. package/dist/lib/primitive/string/types.cjs +18 -1
  123. package/dist/lib/primitive/types.cjs +18 -1
  124. package/dist/lib/url/index.cjs +327 -1
  125. package/dist/lib/url/index.mjs +304 -1
  126. package/dist/lib/url/parser.cjs +325 -1
  127. package/dist/lib/url/parser.mjs +304 -1
  128. package/dist/lib/url/types.cjs +18 -1
  129. package/package.json +5 -5
@@ -1 +1,2167 @@
1
- var j={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",transparent:"transparent",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",zinc:"#71717a",stone:"#78716c",neutral:"#737373",slate:"#64748b",gray50:"#f9fafb",gray100:"#f3f4f6",gray200:"#e5e7eb",gray300:"#d1d5db",gray400:"#9ca3af",gray500:"#6b7280",gray600:"#4b5563",gray700:"#374151",gray800:"#1f2937",gray900:"#111827",gray950:"#030712",red50:"#fef2f2",red100:"#fee2e2",red200:"#fecaca",red300:"#fca5a5",red400:"#f87171",red500:"#ef4444",red600:"#dc2626",red700:"#b91c1c",red800:"#991b1b",red900:"#7f1d1d",red950:"#450a0a",orange50:"#fff7ed",orange100:"#ffedd5",orange200:"#fed7aa",orange300:"#fdba74",orange400:"#fb923c",orange500:"#f97316",orange600:"#ea580c",orange700:"#c2410c",orange800:"#9a3412",orange900:"#7c2d12",orange950:"#431407",amber50:"#fffbeb",amber100:"#fef3c7",amber200:"#fde68a",amber300:"#fcd34d",amber400:"#fbbf24",amber500:"#f59e0b",amber600:"#d97706",amber700:"#b45309",amber800:"#92400e",amber900:"#78350f",amber950:"#451a03",yellow50:"#fefce8",yellow100:"#fef9c3",yellow200:"#fef08a",yellow300:"#fde047",yellow400:"#facc15",yellow500:"#eab308",yellow600:"#ca8a04",yellow700:"#a16207",yellow800:"#854d0e",yellow900:"#713f12",yellow950:"#422006",lime50:"#f7fee7",lime100:"#ecfccb",lime200:"#d9f99d",lime300:"#bef264",lime400:"#a3e635",lime500:"#84cc16",lime600:"#65a30d",lime700:"#4d7c0f",lime800:"#3f6212",lime900:"#365314",lime950:"#1a2e05",green50:"#f0fdf4",green100:"#dcfce7",green200:"#bbf7d0",green300:"#86efac",green400:"#4ade80",green500:"#22c55e",green600:"#16a34a",green700:"#15803d",green800:"#166534",green900:"#14532d",green950:"#052e16",emerald50:"#ecfdf5",emerald100:"#d1fae5",emerald200:"#a7f3d0",emerald300:"#6ee7b7",emerald400:"#34d399",emerald500:"#10b981",emerald600:"#059669",emerald700:"#047857",emerald800:"#065f46",emerald900:"#064e3b",emerald950:"#022c22",teal50:"#f0fdfa",teal100:"#ccfbf1",teal200:"#99f6e4",teal300:"#5eead4",teal400:"#2dd4bf",teal500:"#14b8a6",teal600:"#0d9488",teal700:"#0f766e",teal800:"#115e59",teal900:"#134e4a",teal950:"#042f2e",cyan50:"#ecfeff",cyan100:"#cffafe",cyan200:"#a5f3fc",cyan300:"#67e8f9",cyan400:"#22d3ee",cyan500:"#06b6d4",cyan600:"#0891b2",cyan700:"#0e7490",cyan800:"#155e75",cyan900:"#164e63",cyan950:"#083344",sky50:"#f0f9ff",sky100:"#e0f2fe",sky200:"#bae6fd",sky300:"#7dd3fc",sky400:"#38bdf8",sky500:"#0ea5e9",sky600:"#0284c7",sky700:"#0369a1",sky800:"#075985",sky900:"#0c4a6e",sky950:"#082f49",blue50:"#eff6ff",blue100:"#dbeafe",blue200:"#bfdbfe",blue300:"#93c5fd",blue400:"#60a5fa",blue500:"#3b82f6",blue600:"#2563eb",blue700:"#1d4ed8",blue800:"#1e40af",blue900:"#1e3a8a",blue950:"#172554",indigo50:"#eef2ff",indigo100:"#e0e7ff",indigo200:"#c7d2fe",indigo300:"#a5b4fc",indigo400:"#818cf8",indigo500:"#6366f1",indigo600:"#4f46e5",indigo700:"#4338ca",indigo800:"#3730a3",indigo900:"#312e81",indigo950:"#1e1b4b",violet50:"#f5f3ff",violet100:"#ede9fe",violet200:"#ddd6fe",violet300:"#c4b5fd",violet400:"#a78bfa",violet500:"#8b5cf6",violet600:"#7c3aed",violet700:"#6d28d9",violet800:"#5b21b6",violet900:"#4c1d95",violet950:"#2e1065",purple50:"#faf5ff",purple100:"#f3e8ff",purple200:"#e9d5ff",purple300:"#d8b4fe",purple400:"#c084fc",purple500:"#a855f7",purple600:"#9333ea",purple700:"#7e22ce",purple800:"#6b21a8",purple900:"#581c87",purple950:"#3b0764",fuchsia50:"#fdf4ff",fuchsia100:"#fae8ff",fuchsia200:"#f5d0fe",fuchsia300:"#f0abfc",fuchsia400:"#e879f9",fuchsia500:"#d946ef",fuchsia600:"#c026d3",fuchsia700:"#a21caf",fuchsia800:"#86198f",fuchsia900:"#701a75",fuchsia950:"#4a044e",pink50:"#fdf2f8",pink100:"#fce7f3",pink200:"#fbcfe8",pink300:"#f9a8d4",pink400:"#f472b6",pink500:"#ec4899",pink600:"#db2777",pink700:"#be185d",pink800:"#9d174d",pink900:"#831843",pink950:"#500724",rose50:"#fff1f2",rose100:"#ffe4e6",rose200:"#fecdd3",rose300:"#fda4af",rose400:"#fb7185",rose500:"#f43f5e",rose600:"#e11d48",rose700:"#be123c",rose800:"#9f1239",rose900:"#881337",rose950:"#4c0519"};var P={LEGACY_RGB:/^rgb\(\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*,\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*,\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*\)$/i,MODERN_RGB:/^rgb\(\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s+(\d{1,3}|\.\d+|\d+\.\d+%?)\s+(\d{1,3}|\.\d+|\d+\.\d+%?)\s*\)$/i,LEGACY_RGBA:/^rgba\(\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*,\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*,\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*,\s*(0|1|0?\.\d+|\d{1,3}%?|\.\d+%?)\s*\)$/i,MODERN_RGBA:/^rgba?\(\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s+(\d{1,3}|\.\d+|\d+\.\d+%?)\s+(\d{1,3}|\.\d+|\d+\.\d+%?)\s*\/\s*(0|1|0?\.\d+|\d{1,3}%?|\.\d+%?)\s*\)$/i,COMPREHENSIVE:/^rgba?\(\s*((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\)))\s*(?:[,\s]\s*((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\))))?\s*(?:[,\s]\s*((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\))))?\s*(?:(?:\s*[,\s]?\s*\/?\s*|\s*\/\s*)((?:0|1|0?\.\d+|\.\d+|\d{1,3}%?|var\([^)]+\))))?\s*\)$/i,STRICT_RGB:/^rgb\(\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*,\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*,\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*\)$/i,STRICT_RGBA:/^rgba\(\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*,\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*,\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*,\s*((?:0|1|0?\.\d+|\.\d+|\d{1,2}(?:\.\d+)?%|100%|var\([^)]+\)))\s*\)$/i,MODERN_RGB_ALPHA:/^rgba?\(\s*((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\)))\s+((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\)))\s+((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\)))\s*(?:\/\s*((?:0|1|0?\.\d+|\.\d+|\d{1,3}%?|var\([^)]+\))))?\s*\)$/i},T=e=>{let t=e.trim().toLowerCase();if(!t||t.includes("var("))return null;let r=l=>{if(!l)return null;let c=l.trim();if(!c||c.includes("var("))return null;if(c.endsWith("%")){let b=parseFloat(c);if(isNaN(b))return null;let f=Math.max(0,Math.min(100,b));return Math.round(f*255/100)}let u=parseFloat(c);return isNaN(u)?null:Math.round(Math.max(0,Math.min(255,u)))},o=l=>{if(!l)return 1;let c=l.trim();if(!c||c.includes("var("))return 1;if(c.endsWith("%")){let b=parseFloat(c);return isNaN(b)?1:Math.max(0,Math.min(100,b))/100}let u=parseFloat(c);return isNaN(u)?1:Math.max(0,Math.min(1,u))},a=/^rgba?\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*([^,]+)\s*(?:,\s*([^\)]+))?\s*\)$/,n=t.match(a);if(n){let l=r(n[1]),c=r(n[2]),u=r(n[3]),b=o(n[4]);if(l!==null&&c!==null&&u!==null)return[l,c,u,b]}let i=/^rgba?\(\s*([^\s\/]+)\s+([^\s\/]+)\s+([^\s\/]+)\s*(?:\/\s*([^\)]+))?\s*\)$/;if(n=t.match(i),n){let l=r(n[1]),c=r(n[2]),u=r(n[3]),b=o(n[4]);if(l!==null&&c!==null&&u!==null)return[l,c,u,b]}let s=/^rgb\(\s*([^\s,]+)\s+([^\s,]+)\s+([^\s,]+)\s*\)$/;if(n=t.match(s),n){let l=r(n[1]),c=r(n[2]),u=r(n[3]);if(l!==null&&c!==null&&u!==null)return[l,c,u,1]}return null},F={HEX:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/,RGB:P.COMPREHENSIVE,HSL:/^hsla?\(\s*(\d+(?:\.\d+)?)(?:deg|rad|grad|turn)?\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,OKLCH:/^oklch\(\s*(\d+(?:\.\d+)?%?)\s+(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)(?:\s+[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,OKLAB:/^oklab\(\s*(\d+(?:\.\d+)?%?)\s+([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)(?:\s+[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,HSV:/^hsv\(\s*(\d+(?:\.\d+)?)(?:deg|rad|grad|turn)?\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,CMYK:/^cmyk\(\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,COLOR_FUNCTION:/^color\(\s*([a-z]+)\s+((?:\d+(?:\.\d+)?%?\s+)*\d+(?:\.\d+)?%?)(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,LAB:/^lab\(\s*(\d+(?:\.\d+)?%?)\s+([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,LCH:/^lch\(\s*(\d+(?:\.\d+)?%?)\s+(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i};var h=e=>{if(!e||typeof e!="string")return null;let t=e.trim().toLowerCase();if(!t)return null;if(t==="transparent")return[0,0,0,0];let r=t;if(j[r])return h(j[r]);let o=T(t);if(o)return o;let a=t.match(F.HEX);if(a){let s=a[1];(s.length===3||s.length===4)&&(s=s.split("").map(f=>f+f).join(""));let l=parseInt(s.substring(0,2),16),c=parseInt(s.substring(2,4),16),u=parseInt(s.substring(4,6),16),b=s.length===8?parseInt(s.substring(6,8),16)/255:1;if(!isNaN(l)&&!isNaN(c)&&!isNaN(u)&&!isNaN(b))return[l,c,u,b]}let n=t.match(F.HSL);if(n){let s=parseFloat(n[1]),l=parseFloat(n[2])/100,c=parseFloat(n[3])/100,u=n[4]?B(n[4]):1;if(!isNaN(s)&&!isNaN(l)&&!isNaN(c)&&!isNaN(u))return at(s,l,c,u)}let i=t.match(F.OKLCH);if(i){let s=B(i[1]),l=parseFloat(i[2]),c=parseFloat(i[3]),u=i[4]?B(i[4]):1;if(!isNaN(s)&&!isNaN(l)&&!isNaN(c)&&!isNaN(u))return Ct(s,l,c,u)}return null},at=(e,t,r,o=1)=>{e=e%360,e<0&&(e+=360);let a=(1-Math.abs(2*r-1))*t,n=a*(1-Math.abs(e/60%2-1)),i=r-a/2,s=0,l=0,c=0;return e>=0&&e<60?[s,l,c]=[a,n,0]:e>=60&&e<120?[s,l,c]=[n,a,0]:e>=120&&e<180?[s,l,c]=[0,a,n]:e>=180&&e<240?[s,l,c]=[0,n,a]:e>=240&&e<300?[s,l,c]=[n,0,a]:e>=300&&e<360&&([s,l,c]=[a,0,n]),[Math.round((s+i)*255),Math.round((l+i)*255),Math.round((c+i)*255),o]},Ct=(e,t,r,o=1)=>{let a=r%360,n=Math.min(100,t*100),i=e*100;return at(a,n/100,i/100,o)},q=(e,t,r,o=1)=>(s=>typeof s=="string"&&s.includes("var("))(o)||typeof o=="number"&&o!==1?`rgba(${e} ${t} ${r} / ${o})`:`rgb(${e} ${t} ${r})`,G=e=>{let t=Math.round(e).toString(16);return t.length===1?`0${t}`:t},B=e=>e.endsWith("%")?parseFloat(e)/100:parseFloat(e),D=e=>{if(e.toLowerCase()in j)return!0;if(e.toLowerCase().trim().startsWith("rgb"))return T(e)!==null;let{RGB:t,...r}=F;return Object.values(r).some(o=>o.test(e))},K=(e,t,r,o=1)=>{let a=`#${G(e)}${G(t)}${G(r)}`;return o<1?`${a}${G(Math.round(o*255))}`:a},H=(e,t,r,o=1)=>{let a=e/255,n=t/255,i=r/255,s=Math.max(a,n,i),l=Math.min(a,n,i),c=0,u=0,b=(s+l)/2;if(s!==l){let d=s-l;switch(u=b>.5?d/(2-s-l):d/(s+l),s){case a:c=(n-i)/d+(n<i?6:0);break;case n:c=(i-a)/d+2;break;case i:c=(a-n)/d+4;break}c/=6}c=Math.round(c*360),u=Math.round(u*100);let f=Math.round(b*100);return o===1?`hsl(${c}, ${u}%, ${f}%)`:`hsla(${c}, ${u}%, ${f}%, ${o})`},it=(e,t,r,o=1)=>{let a=e/255,n=t/255,i=r/255,s=Math.max(a,n,i),l=Math.min(a,n,i),c=s-l,u=0;if(c!==0){switch(s){case a:u=(n-i)/c+(n<i?6:0);break;case n:u=(i-a)/c+2;break;case i:u=(a-n)/c+4;break}u/=6}let b=s===0?0:c/s,f=s;u=Math.round(u*360);let d=Math.round(b*100),g=Math.round(f*100);return o===1?`hsv(${u}, ${d}%, ${g}%)`:`hsva(${u}, ${d}%, ${g}%, ${o})`},lt=(e,t,r,o=1)=>{if(e===0&&t===0&&r===0)return"cmyk(0%, 0%, 0%, 100%)";let a=e/255,n=t/255,i=r/255,s=1-Math.max(a,n,i),l=(1-a-s)/(1-s),c=(1-n-s)/(1-s),u=(1-i-s)/(1-s),b=Math.round(l*100),f=Math.round(c*100),d=Math.round(u*100),g=Math.round(s*100);return`cmyk(${b}%, ${f}%, ${d}%, ${g}%)`},R=(e,t,r)=>{let[o,a,n]=[e,t,r].map(i=>(i=i/255,i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)));return .2126*o+.7152*a+.0722*n},ct=(e,t)=>{let r=h(e),o=h(t);if(!r||!o)return 1;let a=R(r[0],r[1],r[2]),n=R(o[0],o[1],o[2]),i=Math.max(a,n),s=Math.min(a,n);return(i+.05)/(s+.05)},U=(e,t)=>{let r=h(e);if(!r)return e;let[o,a,n,i]=r;t.alpha!==void 0&&(i=Math.max(0,Math.min(1,t.alpha)));let s=0,l=0,c=0;if(t.lightness!==void 0||t.saturation!==void 0||t.hue!==void 0){let u=o/255,b=a/255,f=n/255,d=Math.max(u,b,f),g=Math.min(u,b,f);if(c=(d+g)/2,d!==g){let w=d-g;switch(l=c>.5?w/(2-d-g):w/(d+g),d){case u:s=(b-f)/w+(b<f?6:0);break;case b:s=(f-u)/w+2;break;case f:s=(u-b)/w+4;break}s/=6}s*=360,l*=100,c*=100,t.hue!==void 0&&(s=(s+t.hue)%360,s<0&&(s+=360)),t.saturation!==void 0&&(l=Math.max(0,Math.min(100,l+t.saturation))),t.lightness!==void 0&&(c=Math.max(0,Math.min(100,c+t.lightness)));let p=s/360,Z=l/100,A=c/100,y=(1-Math.abs(2*A-1))*Z,k=y*(1-Math.abs(p*6%2-1)),C=A-y/2,m=0,M=0,x=0;p<1/6?[m,M,x]=[y,k,0]:p<2/6?[m,M,x]=[k,y,0]:p<3/6?[m,M,x]=[0,y,k]:p<4/6?[m,M,x]=[0,k,y]:p<5/6?[m,M,x]=[k,0,y]:[m,M,x]=[y,0,k],o=Math.round((m+C)*255),a=Math.round((M+C)*255),n=Math.round((x+C)*255)}if(t.contrast!==void 0){let u=t.contrast/100*2.55,b=(o+a+n)/3;o=Math.round(b+(o-b)*(1+u)),a=Math.round(b+(a-b)*(1+u)),n=Math.round(b+(n-b)*(1+u)),o=Math.max(0,Math.min(255,o)),a=Math.max(0,Math.min(255,a)),n=Math.max(0,Math.min(255,n))}return K(o,a,n,i)},ut=e=>{let{color:t,with:r="transparent",percentage:o=50,colorSpace:a="srgb"}=e,n=h(t),i=h(r);if(!n||!i)return t;let s=o/100,[l,c,u,b]=n,[f,d,g,p]=i;switch(e.opacity!==void 0&&(b=typeof e.opacity=="number"?e.opacity:B(e.opacity)),e.withOpacity!==void 0&&(p=typeof e.withOpacity=="number"?e.withOpacity:B(e.withOpacity)),a){case"srgb":default:let Z=Math.round(l+(f-l)*s),A=Math.round(c+(d-c)*s),y=Math.round(u+(g-u)*s),k=b+(p-b)*s;return K(Z,A,y,k);case"hsl":let C=h(H(l,c,u,b)),m=h(H(f,d,g,p));if(!C||!m)return t;let M=(C[0]+(m[0]-C[0])*s)%360,x=C[1]+(m[1]-C[1])*s,w=C[2]+(m[2]-C[2])*s;return`hsl(${M}, ${x}%, ${w}%)`}},bt=(e,t={})=>{let r=h(e);if(!r)return{};let o=t.shades||10,a=t.lightnessFactor||.1,n=t.saturationFactor||.05,i={};for(let s=0;s<o;s++){let l=s/(o-1),c=(l-.5)*2*a*100,u=U(e,{lightness:c,saturation:(l-.5)*2*n*100}),b=s===0?"50":`${s*100}`;i[b]=u}if(t.includeComplementary){let s=h(H(r[0],r[1],r[2]));if(s){let l=s[0];l=(l+180)%360,i.complementary=`hsl(${l}, ${s[1]}%, ${s[2]}%)`}}if(t.includeAnalogous){let s=h(H(r[0],r[1],r[2]));if(s){let l=s[0];i.analogous1=`hsl(${(l-30+360)%360}, ${s[1]}%, ${s[2]}%)`,i.analogous2=`hsl(${(l+30)%360}, ${s[1]}%, ${s[2]}%)`}}if(t.includeTriadic){let s=h(H(r[0],r[1],r[2]));if(s){let l=s[0];i.triadic1=`hsl(${(l+120)%360}, ${s[1]}%, ${s[2]}%)`,i.triadic2=`hsl(${(l+240)%360}, ${s[1]}%, ${s[2]}%)`}}return i},ft=(e,t={})=>{let{lightColor:r="#ffffff",darkColor:o="#000000",targetRatio:a=4.5,fallbackColor:n="#000000"}=t,i=h(e);if(!i)return n;let s=R(i[0],i[1],i[2]),l=R(...h(r).slice(0,3)),c=R(...h(o).slice(0,3)),u=(Math.max(s,l)+.05)/(Math.min(s,l)+.05),b=(Math.max(s,c)+.05)/(Math.min(s,c)+.05);return u>=a&&b>=a?u>b?r:o:u>=a?r:b>=a?o:u>b?r:o};var $={x:.95047,y:1,z:1.08883},v=.008856,O=903.3;function L(e,t,r){return Math.max(t,Math.min(r,e))}function pt(e,t=2){let r=Math.pow(10,t);return Math.round(e*r)/r}function J(e){let t=e.r/255,r=e.g/255,o=e.b/255,a=Math.max(t,r,o),n=Math.min(t,r,o),i=a-n,s=0,l=0,c=(a+n)/2;if(i!==0)switch(l=c>.5?i/(2-a-n):i/(a+n),a){case t:s=((r-o)/i+(r<o?6:0))/6;break;case r:s=((o-t)/i+2)/6;break;case o:s=((t-r)/i+4)/6;break}return{h:s*360,s:l*100,l:c*100,a:e.a}}function z(e){let t=e.r/255,r=e.g/255,o=e.b/255,a=Math.max(t,r,o),n=Math.min(t,r,o),i=a-n,s=0,l=a===0?0:i/a,c=a;if(i!==0)switch(a){case t:s=((r-o)/i+(r<o?6:0))/6;break;case r:s=((o-t)/i+2)/6;break;case o:s=((t-r)/i+4)/6;break}return{h:s*360,s:l*100,v:c*100,a:e.a}}function V(e){let t=z(e),r=(100-t.s)*t.v/100,o=100-t.v;return{h:t.h,w:r,b:o,a:e.a}}function Q(e){let t=e.r/255,r=e.g/255,o=e.b/255,a=1-Math.max(t,r,o),n=a===1?0:(1-t-a)/(1-a),i=a===1?0:(1-r-a)/(1-a),s=a===1?0:(1-o-a)/(1-a);return{c:n*100,m:i*100,y:s*100,k:a*100,a:e.a}}function _(e){let t=e.r/255,r=e.g/255,o=e.b/255;t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;let a=t*.4124564+r*.3575761+o*.1804375,n=t*.2126729+r*.7151522+o*.072175,i=t*.0193339+r*.119192+o*.9503041;return{x:a*100,y:n*100,z:i*100,alpha:e.a}}function N(e){let t=_(e);return yt(t)}function Y(e){let t=N(e);return xt(t)}function S(e){let t=e.r/255,r=e.g/255,o=e.b/255,a=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,i=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92,s=.4122214708*a+.5363325363*n+.0514459929*i,l=.2119034982*a+.6806995451*n+.1073969566*i,c=.0883024619*a+.2817188376*n+.6299787005*i,u=Math.cbrt(s),b=Math.cbrt(l),f=Math.cbrt(c);return{l:.2104542553*u+.793617785*b-.0040720468*f,a:1.9779984951*u-2.428592205*b+.4505937099*f,b:.0259040371*u+.7827717662*b-.808675766*f,alpha:e.a}}function E(e){let t=S(e);return Ht(t)}function tt(e){let t=e.h/360,r=e.s/100,o=e.l/100,a,n,i;if(r===0)a=n=i=o;else{let s=(u,b,f)=>(f<0&&(f+=1),f>1&&(f-=1),f<.16666666666666666?u+(b-u)*6*f:f<.5?b:f<.6666666666666666?u+(b-u)*(.6666666666666666-f)*6:u),l=o<.5?o*(1+r):o+r-o*r,c=2*o-l;a=s(c,l,t+1/3),n=s(c,l,t),i=s(c,l,t-1/3)}return{r:Math.round(a*255),g:Math.round(n*255),b:Math.round(i*255),a:e.a}}function X(e){let t=e.h/360,r=e.s/100,o=e.v/100,a=Math.floor(t*6),n=t*6-a,i=o*(1-r),s=o*(1-n*r),l=o*(1-(1-n)*r),c,u,b;switch(a%6){case 0:c=o,u=l,b=i;break;case 1:c=s,u=o,b=i;break;case 2:c=i,u=o,b=l;break;case 3:c=i,u=s,b=o;break;case 4:c=l,u=i,b=o;break;default:c=o,u=i,b=s;break}return{r:Math.round(c*255),g:Math.round(u*255),b:Math.round(b*255),a:e.a}}function et(e){let t=e.h,r=e.w/100,o=e.b/100,a=r+o;a>1&&(r/=a,o/=a);let n=1-o,i=n===0?0:1-r/n;return X({h:t,s:i*100,v:n*100,a:e.a})}function rt(e){let t=e.c/100,r=e.m/100,o=e.y/100,a=e.k/100,n=255*(1-t)*(1-a),i=255*(1-r)*(1-a),s=255*(1-o)*(1-a);return{r:Math.round(n),g:Math.round(i),b:Math.round(s),a:e.a}}function W(e){let t=e.x/100,r=e.y/100,o=e.z/100,a=t*3.2404542+r*-1.5371385+o*-.4985314,n=t*-.969266+r*1.8760108+o*.041556,i=t*.0556434+r*-.2040259+o*1.0572252;return a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:12.92*a,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:12.92*i,{r:Math.round(L(a*255,0,255)),g:Math.round(L(n*255,0,255)),b:Math.round(L(i*255,0,255)),a:e.alpha||1}}function yt(e){let t=e.x/$.x/100,r=e.y/$.y/100,o=e.z/$.z/100,a=t>v?Math.cbrt(t):(O*t+16)/116,n=r>v?Math.cbrt(r):(O*r+16)/116,i=o>v?Math.cbrt(o):(O*o+16)/116,s=116*n-16,l=500*(a-n),c=200*(n-i);return{l:L(s,0,100),a:l,b:c,alpha:e.alpha}}function Mt(e){let t=(e.l+16)/116,r=e.a/500+t,o=t-e.b/200,a=r*r*r>v?r*r*r:(116*r-16)/O,n=e.l>O*v?Math.pow((e.l+16)/116,3):e.l/O,i=o*o*o>v?o*o*o:(116*o-16)/O;return{x:a*$.x*100,y:n*$.y*100,z:i*$.z*100,alpha:e.alpha}}function I(e){let t=Mt(e);return W(t)}function xt(e){let t=Math.sqrt(e.a*e.a+e.b*e.b),r=Math.atan2(e.b,e.a)*180/Math.PI;return r<0&&(r+=360),{l:e.l,c:t,h:r,alpha:e.alpha}}function kt(e){let t=e.h*Math.PI/180,r=e.c*Math.cos(t),o=e.c*Math.sin(t);return{l:e.l,a:r,b:o,alpha:e.alpha}}function nt(e){let t=kt(e);return I(t)}function wt(e){let t=e.l+.3963377774*e.a+.2158037573*e.b,r=e.l-.1055613458*e.a-.0638541728*e.b,o=e.l-.0894841775*e.a-1.291485548*e.b,a=t*t*t,n=r*r*r,i=o*o*o,s=4.0767416621*a-3.3077115913*n+.2309699292*i,l=-1.2684380046*a+2.6097574011*n-.3413193965*i,c=-.0041960863*a-.7034186147*n+1.707614701*i;return s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:12.92*s,l=l>.0031308?1.055*Math.pow(l,1/2.4)-.055:12.92*l,c=c>.0031308?1.055*Math.pow(c,1/2.4)-.055:12.92*c,{r:Math.round(L(s*255,0,255)),g:Math.round(L(l*255,0,255)),b:Math.round(L(c*255,0,255)),a:e.alpha}}function Ht(e){let t=Math.sqrt(e.a*e.a+e.b*e.b),r=Math.atan2(e.b,e.a)*180/Math.PI;return r<0&&(r+=360),{l:e.l,c:t,h:r,alpha:e.alpha}}function Rt(e){let t=e.h*Math.PI/180,r=e.c*Math.cos(t),o=e.c*Math.sin(t);return{l:e.l,a:r,b:o,alpha:e.alpha}}function st(e){let t=Rt(e);return wt(t)}function Ot(e){if("r"in e&&"g"in e&&"b"in e)return e;if("h"in e&&"s"in e&&"l"in e)return tt(e);if("h"in e&&"s"in e&&"v"in e)return X(e);if("h"in e&&"w"in e&&"b"in e)return et(e);if("c"in e&&"m"in e&&"y"in e&&"k"in e)return rt(e);if("x"in e&&"y"in e&&"z"in e)return W(e);if("l"in e&&"a"in e&&"b"in e&&!("c"in e)&&!("h"in e))return I(e);if("l"in e&&"c"in e&&"h"in e){let t=e;return t.l<=1?st(e):nt(t)}throw new Error("Unknown color format")}function dt(e,t,r={}){let{round:o=!0,precision:a=2,preserveAlpha:n=!0}=r,i=Ot(e),s;switch(t.toLowerCase()){case"rgb":s=i;break;case"hsl":s=J(i);break;case"hsv":s=z(i);break;case"hwb":s=V(i);break;case"cmyk":s=Q(i);break;case"xyz":s=_(i);break;case"lab":s=N(i);break;case"lch":s=Y(i);break;case"oklab":s=S(i);break;case"oklch":s=E(i);break;default:s=i}return o&&s&&Object.keys(s).forEach(l=>{typeof s[l]=="number"&&l!=="a"&&l!=="alpha"&&(s[l]=pt(s[l],a))}),n||(delete s.a,delete s.alpha),s}function ht(e,t){let r={rgb:["hsl","hsv","hwb","cmyk","xyz","lab","lch","oklab","oklch"],hsl:["rgb","hsv","hwb"],hsv:["rgb","hsl","hwb"],hwb:["rgb","hsl","hsv"],cmyk:["rgb","hsl","hsv"],xyz:["rgb","lab"],lab:["rgb","xyz","lch"],lch:["rgb","lab","xyz"],oklab:["rgb","oklch"],oklch:["rgb","oklab"]};return e=e.toLowerCase(),t=t.toLowerCase(),e===t?[e]:r[e]?.includes(t)?[e,t]:r[e]?.includes("rgb")&&r.rgb?.includes(t)?[e,"rgb",t]:["lab","lch"].includes(e)&&["lab","lch"].includes(t)&&e!==t?[e,"xyz",t]:["oklab","oklch"].includes(e)&&["oklab","oklch"].includes(t)&&e!==t?[e,"oklab",t]:r[e]&&r.rgb?.includes(t)?[e,"rgb",t]:null}function ot(){return["rgb","hsl","hsv","hwb","cmyk","xyz","lab","lch","oklab","oklch"]}function gt(e){return ot().includes(e.toLowerCase())}var mt=class e{constructor(t="#000000"){this._r=0;this._g=0;this._b=0;this._a=1;this.set(t)}static parseRgbString(t){return T(t)}static isRgbFormat(t){return Object.values(P).some(r=>r.test(t.trim()))}static getRgbPatternMatch(t){let r=t.trim();for(let[o,a]of Object.entries(P))if(a.test(r))return o;return null}static toModernRgbSyntax(t,r,o,a){let n=[t,r,o];return a!==void 0&&a!==1?`rgb(${n.join(" ")} / ${a})`:`rgb(${n.join(" ")})`}static toLegacyRgbSyntax(t,r,o,a){let n=[t,r,o];return a!==void 0&&a!==1?`rgba(${n.join(", ")}, ${a})`:`rgb(${n.join(", ")})`}static normalizeRgbString(t,r="modern"){let o=T(t);if(!o)return null;let[a,n,i,s]=o;return r==="modern"?this.toModernRgbSyntax(a,n,i,s):this.toLegacyRgbSyntax(a,n,i,s)}set(t){if(typeof t=="string"){let r=h(t);r&&([this._r,this._g,this._b,this._a]=r)}else if(Array.isArray(t))[this._r=0,this._g=0,this._b=0,this._a=1]=t;else if(t instanceof e)[this._r,this._g,this._b,this._a]=[t._r,t._g,t._b,t._a];else if(typeof t=="object")return this.setFromObject(t);return this._clamp(),this}_clamp(){this._r=Math.max(0,Math.min(255,Math.round(this._r))),this._g=Math.max(0,Math.min(255,Math.round(this._g))),this._b=Math.max(0,Math.min(255,Math.round(this._b))),this._a=Math.max(0,Math.min(1,this._a))}get r(){return this._r}set r(t){this._r=t,this._clamp()}get g(){return this._g}set g(t){this._g=t,this._clamp()}get b(){return this._b}set b(t){this._b=t,this._clamp()}get a(){return this._a}set a(t){this._a=t,this._clamp()}get rgb(){return[this._r,this._g,this._b]}get rgba(){return[this._r,this._g,this._b,this._a]}toHex(){return K(this._r,this._g,this._b,this._a)}toRgb(){return q(this._r,this._g,this._b)}toRgba(){return q(this._r,this._g,this._b,this._a)}getRgbObject(){return{r:this._r,g:this._g,b:this._b,a:this._a}}toHsl(){return H(this._r,this._g,this._b,this._a)}getHslObject(){return J(this.getRgbObject())}toHsv(){return it(this._r,this._g,this._b,this._a)}getHsvObject(){return z(this.getRgbObject())}toHwb(){let t=V(this.getRgbObject()),r=this._a<1?` / ${Math.round(this._a*100)/100}`:"";return`hwb(${Math.round(t.h)} ${Math.round(t.w)}% ${Math.round(t.b)}%${r})`}getHwbObject(){return V(this.getRgbObject())}toCmyk(){return lt(this._r,this._g,this._b,this._a)}getCmykObject(){return Q(this.getRgbObject())}toXyz(){let t=_(this.getRgbObject()),r=this._a<1?` / ${Math.round(this._a*100)/100}`:"";return`color(xyz ${t.x.toFixed(4)} ${t.y.toFixed(4)} ${t.z.toFixed(4)}${r})`}getXyzObject(){return _(this.getRgbObject())}toLab(){let t=N(this.getRgbObject()),r=this._a<1?` / ${Math.round(this._a*100)/100}`:"";return`lab(${t.l.toFixed(2)}% ${t.a.toFixed(2)} ${t.b.toFixed(2)}${r})`}getLabObject(){return N(this.getRgbObject())}toLch(){let t=Y(this.getRgbObject()),r=this._a<1?` / ${Math.round(this._a*100)/100}`:"";return`lch(${t.l.toFixed(2)}% ${t.c.toFixed(2)} ${t.h.toFixed(2)}${r})`}getLchObject(){return Y(this.getRgbObject())}toOklab(){let t=S(this.getRgbObject()),r=this._a<1?` / ${Math.round(this._a*100)/100}`:"";return`oklab(${t.l.toFixed(4)} ${t.a.toFixed(4)} ${t.b.toFixed(4)}${r})`}getOklabObject(){return S(this.getRgbObject())}toOklch(){let t=E(this.getRgbObject()),r=this._a<1?` / ${Math.round(this._a*100)/100}`:"";return`oklch(${t.l.toFixed(4)} ${t.c.toFixed(4)} ${t.h.toFixed(2)}${r})`}getOklchObject(){return E(this.getRgbObject())}adjust(t){let r=U(this.toHex(),t);return this.set(r),this}lighten(t){return this.adjust({lightness:t})}darken(t){return this.adjust({lightness:-t})}saturate(t){return this.adjust({saturation:t})}desaturate(t){return this.adjust({saturation:-t})}rotate(t){return this.adjust({hue:t})}alpha(t){return this._a=Math.max(0,Math.min(1,t)),this}mix(t,r=50,o="srgb"){let a=ut({color:this.toHex(),with:t,percentage:r,colorSpace:o});return this.set(a),this}getContrastColor(t={}){let r=ft(this.toHex(),t);return new e(r)}getLuminance(){return R(this._r,this._g,this._b)}getContrastRatio(t){let r=t instanceof e?t.toHex():t;return ct(this.toHex(),r)}getPalette(t={}){return bt(this.toHex(),t)}clone(){return new e(this.rgba)}toString(t="hex"){switch(t){case"hex":return this.toHex();case"rgb":return this.toRgb();case"rgba":return this.toRgba();case"hsl":return this.toHsl();case"hsla":return this.toHsl();case"hsv":return this.toHsv();case"hsva":return this.toHsv();case"hwb":return this.toHwb();case"cmyk":return this.toCmyk();case"xyz":return this.toXyz();case"lab":return this.toLab();case"lch":return this.toLch();case"oklab":return this.toOklab();case"oklch":return this.toOklch();default:return this.toHex()}}convertTo(t,r={}){return dt(this.getRgbObject(),t,r)}setFromObject(t){let r;if("r"in t&&"g"in t&&"b"in t)r=t;else if("h"in t&&"s"in t&&"l"in t)r=tt(t);else if("h"in t&&"s"in t&&"v"in t)r=X(t);else if("h"in t&&"w"in t&&"b"in t)r=et(t);else if("c"in t&&"m"in t&&"y"in t&&"k"in t)r=rt(t);else if("x"in t&&"y"in t&&"z"in t)r=W(t);else if("l"in t&&"a"in t&&"b"in t)r=I(t);else if("l"in t&&"c"in t&&"h"in t){let o=t;r=o.l<=1?st(t):nt(o)}else throw new Error("Unknown color format");return this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a??1,this._clamp(),this}getHarmony(t={}){let{type:r="complementary",count:o=5,angleOffset:a=30}=t,n=this.getHslObject(),i=[];switch(r){case"complementary":i.push(new e({h:(n.h+180)%360,s:n.s,l:n.l,a:n.a}));break;case"analogous":i.push(new e({h:(n.h-a+360)%360,s:n.s,l:n.l,a:n.a}),new e({h:(n.h+a)%360,s:n.s,l:n.l,a:n.a}));break;case"triadic":i.push(new e({h:(n.h+120)%360,s:n.s,l:n.l,a:n.a}),new e({h:(n.h+240)%360,s:n.s,l:n.l,a:n.a}));break;case"tetradic":i.push(new e({h:(n.h+90)%360,s:n.s,l:n.l,a:n.a}),new e({h:(n.h+180)%360,s:n.s,l:n.l,a:n.a}),new e({h:(n.h+270)%360,s:n.s,l:n.l,a:n.a}));break;case"split-complementary":i.push(new e({h:(n.h+150)%360,s:n.s,l:n.l,a:n.a}),new e({h:(n.h+210)%360,s:n.s,l:n.l,a:n.a}));break;case"square":i.push(new e({h:(n.h+90)%360,s:n.s,l:n.l,a:n.a}),new e({h:(n.h+180)%360,s:n.s,l:n.l,a:n.a}),new e({h:(n.h+270)%360,s:n.s,l:n.l,a:n.a}));break;case"monochromatic":let s=100/(o+1);for(let l=1;l<=o;l++)i.push(new e({h:n.h,s:n.s,l:Math.max(0,Math.min(100,s*l)),a:n.a}));break}return i}static getSupportedFormats(){return ot()}static isValidFormat(t){return gt(t)}static getConversionPath(t,r){return ht(t,r)}isValid(){return D(this.toHex())}static fromString(t){return D(t)?new e(t):null}static random(){let t=Math.floor(Math.random()*256),r=Math.floor(Math.random()*256),o=Math.floor(Math.random()*256);return new e([t,r,o,1])}static get transparent(){return new e("transparent")}static get white(){return new e("#ffffff")}static get black(){return new e("#000000")}static get red(){return new e("#ff0000")}static get green(){return new e("#00ff00")}static get blue(){return new e("#0000ff")}static get yellow(){return new e("#ffff00")}static get cyan(){return new e("#00ffff")}static get magenta(){return new e("#ff00ff")}static get gray(){return new e("#808080")}static get lightGray(){return new e("#d3d3d3")}static get darkGray(){return new e("#a9a9a9")}static get orange(){return new e("#ffa500")}static get purple(){return new e("#800080")}static get pink(){return new e("#ffc0cb")}static get brown(){return new e("#a52a2a")}static get teal(){return new e("#008080")}static get lime(){return new e("#00ff00")}static get indigo(){return new e("#4b0082")}static get violet(){return new e("#ee82ee")}};export{mt as Color};
1
+ // src/lib/color/constants.ts
2
+ var NAMED_COLORS = {
3
+ // Basic colors
4
+ aliceblue: "#f0f8ff",
5
+ antiquewhite: "#faebd7",
6
+ aqua: "#00ffff",
7
+ aquamarine: "#7fffd4",
8
+ azure: "#f0ffff",
9
+ beige: "#f5f5dc",
10
+ bisque: "#ffe4c4",
11
+ black: "#000000",
12
+ blanchedalmond: "#ffebcd",
13
+ blue: "#0000ff",
14
+ blueviolet: "#8a2be2",
15
+ brown: "#a52a2a",
16
+ burlywood: "#deb887",
17
+ cadetblue: "#5f9ea0",
18
+ chartreuse: "#7fff00",
19
+ chocolate: "#d2691e",
20
+ coral: "#ff7f50",
21
+ cornflowerblue: "#6495ed",
22
+ cornsilk: "#fff8dc",
23
+ crimson: "#dc143c",
24
+ cyan: "#00ffff",
25
+ darkblue: "#00008b",
26
+ darkcyan: "#008b8b",
27
+ darkgoldenrod: "#b8860b",
28
+ darkgray: "#a9a9a9",
29
+ darkgreen: "#006400",
30
+ darkgrey: "#a9a9a9",
31
+ darkkhaki: "#bdb76b",
32
+ darkmagenta: "#8b008b",
33
+ darkolivegreen: "#556b2f",
34
+ darkorange: "#ff8c00",
35
+ darkorchid: "#9932cc",
36
+ darkred: "#8b0000",
37
+ darksalmon: "#e9967a",
38
+ darkseagreen: "#8fbc8f",
39
+ darkslateblue: "#483d8b",
40
+ darkslategray: "#2f4f4f",
41
+ darkslategrey: "#2f4f4f",
42
+ darkturquoise: "#00ced1",
43
+ darkviolet: "#9400d3",
44
+ deeppink: "#ff1493",
45
+ deepskyblue: "#00bfff",
46
+ dimgray: "#696969",
47
+ dimgrey: "#696969",
48
+ dodgerblue: "#1e90ff",
49
+ firebrick: "#b22222",
50
+ floralwhite: "#fffaf0",
51
+ forestgreen: "#228b22",
52
+ fuchsia: "#ff00ff",
53
+ gainsboro: "#dcdcdc",
54
+ ghostwhite: "#f8f8ff",
55
+ gold: "#ffd700",
56
+ goldenrod: "#daa520",
57
+ gray: "#808080",
58
+ green: "#008000",
59
+ greenyellow: "#adff2f",
60
+ grey: "#808080",
61
+ honeydew: "#f0fff0",
62
+ hotpink: "#ff69b4",
63
+ indianred: "#cd5c5c",
64
+ indigo: "#4b0082",
65
+ ivory: "#fffff0",
66
+ khaki: "#f0e68c",
67
+ lavender: "#e6e6fa",
68
+ lavenderblush: "#fff0f5",
69
+ lawngreen: "#7cfc00",
70
+ lemonchiffon: "#fffacd",
71
+ lightblue: "#add8e6",
72
+ lightcoral: "#f08080",
73
+ lightcyan: "#e0ffff",
74
+ lightgoldenrodyellow: "#fafad2",
75
+ lightgray: "#d3d3d3",
76
+ lightgreen: "#90ee90",
77
+ lightgrey: "#d3d3d3",
78
+ lightpink: "#ffb6c1",
79
+ lightsalmon: "#ffa07a",
80
+ lightseagreen: "#20b2aa",
81
+ lightskyblue: "#87cefa",
82
+ lightslategray: "#778899",
83
+ lightslategrey: "#778899",
84
+ lightsteelblue: "#b0c4de",
85
+ lightyellow: "#ffffe0",
86
+ lime: "#00ff00",
87
+ limegreen: "#32cd32",
88
+ linen: "#faf0e6",
89
+ magenta: "#ff00ff",
90
+ maroon: "#800000",
91
+ mediumaquamarine: "#66cdaa",
92
+ mediumblue: "#0000cd",
93
+ mediumorchid: "#ba55d3",
94
+ mediumpurple: "#9370db",
95
+ mediumseagreen: "#3cb371",
96
+ mediumslateblue: "#7b68ee",
97
+ mediumspringgreen: "#00fa9a",
98
+ mediumturquoise: "#48d1cc",
99
+ mediumvioletred: "#c71585",
100
+ midnightblue: "#191970",
101
+ mintcream: "#f5fffa",
102
+ mistyrose: "#ffe4e1",
103
+ moccasin: "#ffe4b5",
104
+ navajowhite: "#ffdead",
105
+ navy: "#000080",
106
+ oldlace: "#fdf5e6",
107
+ olive: "#808000",
108
+ olivedrab: "#6b8e23",
109
+ orange: "#ffa500",
110
+ orangered: "#ff4500",
111
+ orchid: "#da70d6",
112
+ palegoldenrod: "#eee8aa",
113
+ palegreen: "#98fb98",
114
+ paleturquoise: "#afeeee",
115
+ palevioletred: "#db7093",
116
+ papayawhip: "#ffefd5",
117
+ peachpuff: "#ffdab9",
118
+ peru: "#cd853f",
119
+ pink: "#ffc0cb",
120
+ plum: "#dda0dd",
121
+ powderblue: "#b0e0e6",
122
+ purple: "#800080",
123
+ rebeccapurple: "#663399",
124
+ red: "#ff0000",
125
+ rosybrown: "#bc8f8f",
126
+ royalblue: "#4169e1",
127
+ saddlebrown: "#8b4513",
128
+ salmon: "#fa8072",
129
+ sandybrown: "#f4a460",
130
+ seagreen: "#2e8b57",
131
+ seashell: "#fff5ee",
132
+ sienna: "#a0522d",
133
+ silver: "#c0c0c0",
134
+ skyblue: "#87ceeb",
135
+ slateblue: "#6a5acd",
136
+ slategray: "#708090",
137
+ slategrey: "#708090",
138
+ snow: "#fffafa",
139
+ springgreen: "#00ff7f",
140
+ steelblue: "#4682b4",
141
+ tan: "#d2b48c",
142
+ teal: "#008080",
143
+ thistle: "#d8bfd8",
144
+ tomato: "#ff6347",
145
+ transparent: "transparent",
146
+ turquoise: "#40e0d0",
147
+ violet: "#ee82ee",
148
+ wheat: "#f5deb3",
149
+ white: "#ffffff",
150
+ whitesmoke: "#f5f5f5",
151
+ yellow: "#ffff00",
152
+ yellowgreen: "#9acd32",
153
+ // Additional modern colors
154
+ zinc: "#71717a",
155
+ stone: "#78716c",
156
+ neutral: "#737373",
157
+ slate: "#64748b",
158
+ gray50: "#f9fafb",
159
+ gray100: "#f3f4f6",
160
+ gray200: "#e5e7eb",
161
+ gray300: "#d1d5db",
162
+ gray400: "#9ca3af",
163
+ gray500: "#6b7280",
164
+ gray600: "#4b5563",
165
+ gray700: "#374151",
166
+ gray800: "#1f2937",
167
+ gray900: "#111827",
168
+ gray950: "#030712",
169
+ red50: "#fef2f2",
170
+ red100: "#fee2e2",
171
+ red200: "#fecaca",
172
+ red300: "#fca5a5",
173
+ red400: "#f87171",
174
+ red500: "#ef4444",
175
+ red600: "#dc2626",
176
+ red700: "#b91c1c",
177
+ red800: "#991b1b",
178
+ red900: "#7f1d1d",
179
+ red950: "#450a0a",
180
+ orange50: "#fff7ed",
181
+ orange100: "#ffedd5",
182
+ orange200: "#fed7aa",
183
+ orange300: "#fdba74",
184
+ orange400: "#fb923c",
185
+ orange500: "#f97316",
186
+ orange600: "#ea580c",
187
+ orange700: "#c2410c",
188
+ orange800: "#9a3412",
189
+ orange900: "#7c2d12",
190
+ orange950: "#431407",
191
+ amber50: "#fffbeb",
192
+ amber100: "#fef3c7",
193
+ amber200: "#fde68a",
194
+ amber300: "#fcd34d",
195
+ amber400: "#fbbf24",
196
+ amber500: "#f59e0b",
197
+ amber600: "#d97706",
198
+ amber700: "#b45309",
199
+ amber800: "#92400e",
200
+ amber900: "#78350f",
201
+ amber950: "#451a03",
202
+ yellow50: "#fefce8",
203
+ yellow100: "#fef9c3",
204
+ yellow200: "#fef08a",
205
+ yellow300: "#fde047",
206
+ yellow400: "#facc15",
207
+ yellow500: "#eab308",
208
+ yellow600: "#ca8a04",
209
+ yellow700: "#a16207",
210
+ yellow800: "#854d0e",
211
+ yellow900: "#713f12",
212
+ yellow950: "#422006",
213
+ lime50: "#f7fee7",
214
+ lime100: "#ecfccb",
215
+ lime200: "#d9f99d",
216
+ lime300: "#bef264",
217
+ lime400: "#a3e635",
218
+ lime500: "#84cc16",
219
+ lime600: "#65a30d",
220
+ lime700: "#4d7c0f",
221
+ lime800: "#3f6212",
222
+ lime900: "#365314",
223
+ lime950: "#1a2e05",
224
+ green50: "#f0fdf4",
225
+ green100: "#dcfce7",
226
+ green200: "#bbf7d0",
227
+ green300: "#86efac",
228
+ green400: "#4ade80",
229
+ green500: "#22c55e",
230
+ green600: "#16a34a",
231
+ green700: "#15803d",
232
+ green800: "#166534",
233
+ green900: "#14532d",
234
+ green950: "#052e16",
235
+ emerald50: "#ecfdf5",
236
+ emerald100: "#d1fae5",
237
+ emerald200: "#a7f3d0",
238
+ emerald300: "#6ee7b7",
239
+ emerald400: "#34d399",
240
+ emerald500: "#10b981",
241
+ emerald600: "#059669",
242
+ emerald700: "#047857",
243
+ emerald800: "#065f46",
244
+ emerald900: "#064e3b",
245
+ emerald950: "#022c22",
246
+ teal50: "#f0fdfa",
247
+ teal100: "#ccfbf1",
248
+ teal200: "#99f6e4",
249
+ teal300: "#5eead4",
250
+ teal400: "#2dd4bf",
251
+ teal500: "#14b8a6",
252
+ teal600: "#0d9488",
253
+ teal700: "#0f766e",
254
+ teal800: "#115e59",
255
+ teal900: "#134e4a",
256
+ teal950: "#042f2e",
257
+ cyan50: "#ecfeff",
258
+ cyan100: "#cffafe",
259
+ cyan200: "#a5f3fc",
260
+ cyan300: "#67e8f9",
261
+ cyan400: "#22d3ee",
262
+ cyan500: "#06b6d4",
263
+ cyan600: "#0891b2",
264
+ cyan700: "#0e7490",
265
+ cyan800: "#155e75",
266
+ cyan900: "#164e63",
267
+ cyan950: "#083344",
268
+ sky50: "#f0f9ff",
269
+ sky100: "#e0f2fe",
270
+ sky200: "#bae6fd",
271
+ sky300: "#7dd3fc",
272
+ sky400: "#38bdf8",
273
+ sky500: "#0ea5e9",
274
+ sky600: "#0284c7",
275
+ sky700: "#0369a1",
276
+ sky800: "#075985",
277
+ sky900: "#0c4a6e",
278
+ sky950: "#082f49",
279
+ blue50: "#eff6ff",
280
+ blue100: "#dbeafe",
281
+ blue200: "#bfdbfe",
282
+ blue300: "#93c5fd",
283
+ blue400: "#60a5fa",
284
+ blue500: "#3b82f6",
285
+ blue600: "#2563eb",
286
+ blue700: "#1d4ed8",
287
+ blue800: "#1e40af",
288
+ blue900: "#1e3a8a",
289
+ blue950: "#172554",
290
+ indigo50: "#eef2ff",
291
+ indigo100: "#e0e7ff",
292
+ indigo200: "#c7d2fe",
293
+ indigo300: "#a5b4fc",
294
+ indigo400: "#818cf8",
295
+ indigo500: "#6366f1",
296
+ indigo600: "#4f46e5",
297
+ indigo700: "#4338ca",
298
+ indigo800: "#3730a3",
299
+ indigo900: "#312e81",
300
+ indigo950: "#1e1b4b",
301
+ violet50: "#f5f3ff",
302
+ violet100: "#ede9fe",
303
+ violet200: "#ddd6fe",
304
+ violet300: "#c4b5fd",
305
+ violet400: "#a78bfa",
306
+ violet500: "#8b5cf6",
307
+ violet600: "#7c3aed",
308
+ violet700: "#6d28d9",
309
+ violet800: "#5b21b6",
310
+ violet900: "#4c1d95",
311
+ violet950: "#2e1065",
312
+ purple50: "#faf5ff",
313
+ purple100: "#f3e8ff",
314
+ purple200: "#e9d5ff",
315
+ purple300: "#d8b4fe",
316
+ purple400: "#c084fc",
317
+ purple500: "#a855f7",
318
+ purple600: "#9333ea",
319
+ purple700: "#7e22ce",
320
+ purple800: "#6b21a8",
321
+ purple900: "#581c87",
322
+ purple950: "#3b0764",
323
+ fuchsia50: "#fdf4ff",
324
+ fuchsia100: "#fae8ff",
325
+ fuchsia200: "#f5d0fe",
326
+ fuchsia300: "#f0abfc",
327
+ fuchsia400: "#e879f9",
328
+ fuchsia500: "#d946ef",
329
+ fuchsia600: "#c026d3",
330
+ fuchsia700: "#a21caf",
331
+ fuchsia800: "#86198f",
332
+ fuchsia900: "#701a75",
333
+ fuchsia950: "#4a044e",
334
+ pink50: "#fdf2f8",
335
+ pink100: "#fce7f3",
336
+ pink200: "#fbcfe8",
337
+ pink300: "#f9a8d4",
338
+ pink400: "#f472b6",
339
+ pink500: "#ec4899",
340
+ pink600: "#db2777",
341
+ pink700: "#be185d",
342
+ pink800: "#9d174d",
343
+ pink900: "#831843",
344
+ pink950: "#500724",
345
+ rose50: "#fff1f2",
346
+ rose100: "#ffe4e6",
347
+ rose200: "#fecdd3",
348
+ rose300: "#fda4af",
349
+ rose400: "#fb7185",
350
+ rose500: "#f43f5e",
351
+ rose600: "#e11d48",
352
+ rose700: "#be123c",
353
+ rose800: "#9f1239",
354
+ rose900: "#881337",
355
+ rose950: "#4c0519"
356
+ };
357
+
358
+ // src/lib/color/utils.ts
359
+ var RGB_PATTERNS = {
360
+ /**
361
+ * Matches legacy comma-separated RGB
362
+ * @example rgb(255, 0, 0)
363
+ */
364
+ LEGACY_RGB: /^rgb\(\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*,\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*,\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*\)$/i,
365
+ /**
366
+ * Matches modern space-separated RGB
367
+ * @example rgb(255 0 0)
368
+ */
369
+ MODERN_RGB: /^rgb\(\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s+(\d{1,3}|\.\d+|\d+\.\d+%?)\s+(\d{1,3}|\.\d+|\d+\.\d+%?)\s*\)$/i,
370
+ /**
371
+ * Matches legacy comma-separated RGBA
372
+ * @example rgba(255, 0, 0, 0.5)
373
+ * @example rgba(255, 0, 0, 50%)
374
+ */
375
+ LEGACY_RGBA: /^rgba\(\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*,\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*,\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s*,\s*(0|1|0?\.\d+|\d{1,3}%?|\.\d+%?)\s*\)$/i,
376
+ /**
377
+ * Matches modern space-separated RGBA with slash
378
+ * @example rgb(255 0 0 / 0.5)
379
+ * @example rgb(255 0 0 / 50%)
380
+ * @example rgba(255 0 0 / 0.5)
381
+ */
382
+ MODERN_RGBA: /^rgba?\(\s*(\d{1,3}|\.\d+|\d+\.\d+%?)\s+(\d{1,3}|\.\d+|\d+\.\d+%?)\s+(\d{1,3}|\.\d+|\d+\.\d+%?)\s*\/\s*(0|1|0?\.\d+|\d{1,3}%?|\.\d+%?)\s*\)$/i,
383
+ /**
384
+ * Combined pattern that matches all RGB/RGBA variations
385
+ * Supports:
386
+ * - Legacy comma-separated: rgb(255, 0, 0), rgba(255, 0, 0, 0.5)
387
+ * - Modern space-separated: rgb(255 0 0), rgb(255 0 0 / 0.5)
388
+ * - Mixed separators: rgb(255,0,0), rgb(255 0 0)
389
+ * - Percentages: rgb(100% 0% 0%), rgb(100% 0% 0% / 50%)
390
+ * - Decimal numbers: rgb(255.5 0 0), rgba(255, 0, 0, 0.5)
391
+ * - CSS variables: rgb(var(--red) var(--green) var(--blue))
392
+ */
393
+ COMPREHENSIVE: /^rgba?\(\s*((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\)))\s*(?:[,\s]\s*((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\))))?\s*(?:[,\s]\s*((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\))))?\s*(?:(?:\s*[,\s]?\s*\/?\s*|\s*\/\s*)((?:0|1|0?\.\d+|\.\d+|\d{1,3}%?|var\([^)]+\))))?\s*\)$/i,
394
+ /**
395
+ * Strict RGB pattern with validation
396
+ * Matches integers (0-255) or percentages (0-100%)
397
+ */
398
+ STRICT_RGB: /^rgb\(\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*,\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*,\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*\)$/i,
399
+ /**
400
+ * Strict RGBA pattern with validation
401
+ */
402
+ STRICT_RGBA: /^rgba\(\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*,\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*,\s*((?:\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]|\d{1,2}(?:\.\d+)?%|100%|\.\d+%?|var\([^)]+\)))\s*,\s*((?:0|1|0?\.\d+|\.\d+|\d{1,2}(?:\.\d+)?%|100%|var\([^)]+\)))\s*\)$/i,
403
+ /**
404
+ * Modern RGB with optional alpha
405
+ */
406
+ MODERN_RGB_ALPHA: /^rgba?\(\s*((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\)))\s+((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\)))\s+((?:\d{1,3}(?:\.\d+)?%?|\.\d+%?|var\([^)]+\)))\s*(?:\/\s*((?:0|1|0?\.\d+|\.\d+|\d{1,3}%?|var\([^)]+\))))?\s*\)$/i
407
+ };
408
+ var parseRgbaColor = (colorString) => {
409
+ const str = colorString.trim().toLowerCase();
410
+ if (!str || str.includes("var(")) {
411
+ return null;
412
+ }
413
+ const parseComponent = (component) => {
414
+ if (!component) return null;
415
+ const trimmed = component.trim();
416
+ if (!trimmed || trimmed.includes("var(")) return null;
417
+ if (trimmed.endsWith("%")) {
418
+ const percent = parseFloat(trimmed);
419
+ if (isNaN(percent)) return null;
420
+ const clamped = Math.max(0, Math.min(100, percent));
421
+ return Math.round(clamped * 255 / 100);
422
+ }
423
+ const num = parseFloat(trimmed);
424
+ if (isNaN(num)) return null;
425
+ return Math.round(Math.max(0, Math.min(255, num)));
426
+ };
427
+ const parseAlpha = (alpha) => {
428
+ if (!alpha) return 1;
429
+ const trimmed = alpha.trim();
430
+ if (!trimmed || trimmed.includes("var(")) return 1;
431
+ if (trimmed.endsWith("%")) {
432
+ const percent = parseFloat(trimmed);
433
+ if (isNaN(percent)) return 1;
434
+ return Math.max(0, Math.min(100, percent)) / 100;
435
+ }
436
+ const num = parseFloat(trimmed);
437
+ if (isNaN(num)) return 1;
438
+ return Math.max(0, Math.min(1, num));
439
+ };
440
+ const legacyCommaPattern = /^rgba?\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*([^,]+)\s*(?:,\s*([^\)]+))?\s*\)$/;
441
+ let match = str.match(legacyCommaPattern);
442
+ if (match) {
443
+ const r = parseComponent(match[1]);
444
+ const g = parseComponent(match[2]);
445
+ const b = parseComponent(match[3]);
446
+ const a = parseAlpha(match[4]);
447
+ if (r !== null && g !== null && b !== null) {
448
+ return [r, g, b, a];
449
+ }
450
+ }
451
+ const modernSlashPattern = /^rgba?\(\s*([^\s\/]+)\s+([^\s\/]+)\s+([^\s\/]+)\s*(?:\/\s*([^\)]+))?\s*\)$/;
452
+ match = str.match(modernSlashPattern);
453
+ if (match) {
454
+ const r = parseComponent(match[1]);
455
+ const g = parseComponent(match[2]);
456
+ const b = parseComponent(match[3]);
457
+ const a = parseAlpha(match[4]);
458
+ if (r !== null && g !== null && b !== null) {
459
+ return [r, g, b, a];
460
+ }
461
+ }
462
+ const modernSpacePattern = /^rgb\(\s*([^\s,]+)\s+([^\s,]+)\s+([^\s,]+)\s*\)$/;
463
+ match = str.match(modernSpacePattern);
464
+ if (match) {
465
+ const r = parseComponent(match[1]);
466
+ const g = parseComponent(match[2]);
467
+ const b = parseComponent(match[3]);
468
+ if (r !== null && g !== null && b !== null) {
469
+ return [r, g, b, 1];
470
+ }
471
+ }
472
+ return null;
473
+ };
474
+ var COLOR_PATTERNS = {
475
+ // Hex patterns (unchanged)
476
+ HEX: /^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/,
477
+ // RGB patterns (enhanced)
478
+ RGB: RGB_PATTERNS.COMPREHENSIVE,
479
+ // HSL patterns (supports both hsl and hsla)
480
+ HSL: /^hsla?\(\s*(\d+(?:\.\d+)?)(?:deg|rad|grad|turn)?\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,
481
+ // OKLCH pattern
482
+ OKLCH: /^oklch\(\s*(\d+(?:\.\d+)?%?)\s+(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)(?:\s+[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,
483
+ // OKLAB pattern
484
+ OKLAB: /^oklab\(\s*(\d+(?:\.\d+)?%?)\s+([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)(?:\s+[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,
485
+ // HSV pattern
486
+ HSV: /^hsv\(\s*(\d+(?:\.\d+)?)(?:deg|rad|grad|turn)?\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,
487
+ // CMYK pattern
488
+ CMYK: /^cmyk\(\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,
489
+ // CSS color() function
490
+ COLOR_FUNCTION: /^color\(\s*([a-z]+)\s+((?:\d+(?:\.\d+)?%?\s+)*\d+(?:\.\d+)?%?)(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,
491
+ // Lab color
492
+ LAB: /^lab\(\s*(\d+(?:\.\d+)?%?)\s+([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i,
493
+ // LCH color
494
+ LCH: /^lch\(\s*(\d+(?:\.\d+)?%?)\s+(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)(?:\s*[,\s/]\s*(\d*\.?\d+%?))?\s*\)$/i
495
+ };
496
+ var parseColor = (color) => {
497
+ if (!color || typeof color !== "string") {
498
+ return null;
499
+ }
500
+ const str = color.trim().toLowerCase();
501
+ if (!str) {
502
+ return null;
503
+ }
504
+ if (str === "transparent") {
505
+ return [0, 0, 0, 0];
506
+ }
507
+ const namedColor = str;
508
+ if (NAMED_COLORS[namedColor]) {
509
+ return parseColor(NAMED_COLORS[namedColor]);
510
+ }
511
+ const rgba = parseRgbaColor(str);
512
+ if (rgba) {
513
+ return rgba;
514
+ }
515
+ const hexMatch = str.match(COLOR_PATTERNS.HEX);
516
+ if (hexMatch) {
517
+ let hex = hexMatch[1];
518
+ if (hex.length === 3 || hex.length === 4) {
519
+ hex = hex.split("").map((c) => c + c).join("");
520
+ }
521
+ const r = parseInt(hex.substring(0, 2), 16);
522
+ const g = parseInt(hex.substring(2, 4), 16);
523
+ const b = parseInt(hex.substring(4, 6), 16);
524
+ const a = hex.length === 8 ? parseInt(hex.substring(6, 8), 16) / 255 : 1;
525
+ if (!isNaN(r) && !isNaN(g) && !isNaN(b) && !isNaN(a)) {
526
+ return [r, g, b, a];
527
+ }
528
+ }
529
+ const hslMatch = str.match(COLOR_PATTERNS.HSL);
530
+ if (hslMatch) {
531
+ const h = parseFloat(hslMatch[1]);
532
+ const s = parseFloat(hslMatch[2]) / 100;
533
+ const l = parseFloat(hslMatch[3]) / 100;
534
+ const a = hslMatch[4] ? parsePercentage(hslMatch[4]) : 1;
535
+ if (!isNaN(h) && !isNaN(s) && !isNaN(l) && !isNaN(a)) {
536
+ return hslToRgb(h, s, l, a);
537
+ }
538
+ }
539
+ const oklchMatch = str.match(COLOR_PATTERNS.OKLCH);
540
+ if (oklchMatch) {
541
+ const L = parsePercentage(oklchMatch[1]);
542
+ const C = parseFloat(oklchMatch[2]);
543
+ const H = parseFloat(oklchMatch[3]);
544
+ const a = oklchMatch[4] ? parsePercentage(oklchMatch[4]) : 1;
545
+ if (!isNaN(L) && !isNaN(C) && !isNaN(H) && !isNaN(a)) {
546
+ return oklchToRgb(L, C, H, a);
547
+ }
548
+ }
549
+ return null;
550
+ };
551
+ var hslToRgb = (h, s, l, a = 1) => {
552
+ h = h % 360;
553
+ if (h < 0) h += 360;
554
+ const c = (1 - Math.abs(2 * l - 1)) * s;
555
+ const x = c * (1 - Math.abs(h / 60 % 2 - 1));
556
+ const m = l - c / 2;
557
+ let r = 0, g = 0, b = 0;
558
+ if (h >= 0 && h < 60) {
559
+ [r, g, b] = [c, x, 0];
560
+ } else if (h >= 60 && h < 120) {
561
+ [r, g, b] = [x, c, 0];
562
+ } else if (h >= 120 && h < 180) {
563
+ [r, g, b] = [0, c, x];
564
+ } else if (h >= 180 && h < 240) {
565
+ [r, g, b] = [0, x, c];
566
+ } else if (h >= 240 && h < 300) {
567
+ [r, g, b] = [x, 0, c];
568
+ } else if (h >= 300 && h < 360) {
569
+ [r, g, b] = [c, 0, x];
570
+ }
571
+ return [
572
+ Math.round((r + m) * 255),
573
+ Math.round((g + m) * 255),
574
+ Math.round((b + m) * 255),
575
+ a
576
+ ];
577
+ };
578
+ var oklchToRgb = (L, C, H, a = 1) => {
579
+ const hue = H % 360;
580
+ const saturation = Math.min(100, C * 100);
581
+ const lightness = L * 100;
582
+ return hslToRgb(hue, saturation / 100, lightness / 100, a);
583
+ };
584
+ var formatRgba = (r, g, b, a = 1) => {
585
+ const isVariable = (value) => typeof value === "string" && value.includes("var(");
586
+ const isAlphaVariable = isVariable(a);
587
+ const hasAlpha = isAlphaVariable || typeof a === "number" && a !== 1;
588
+ if (hasAlpha) {
589
+ return `rgba(${r} ${g} ${b} / ${a})`;
590
+ }
591
+ return `rgb(${r} ${g} ${b})`;
592
+ };
593
+ var numToHex = (value) => {
594
+ const hex = Math.round(value).toString(16);
595
+ return hex.length === 1 ? `0${hex}` : hex;
596
+ };
597
+ var parsePercentage = (value) => {
598
+ if (value.endsWith("%")) {
599
+ return parseFloat(value) / 100;
600
+ }
601
+ return parseFloat(value);
602
+ };
603
+ var isValidColor = (color) => {
604
+ if (color.toLowerCase() in NAMED_COLORS) {
605
+ return true;
606
+ }
607
+ if (color.toLowerCase().trim().startsWith("rgb")) {
608
+ return parseRgbaColor(color) !== null;
609
+ }
610
+ const { RGB, ...otherPatterns } = COLOR_PATTERNS;
611
+ return Object.values(otherPatterns).some((pattern) => pattern.test(color));
612
+ };
613
+ var rgbaToHex = (r, g, b, a = 1) => {
614
+ const hex = `#${numToHex(r)}${numToHex(g)}${numToHex(b)}`;
615
+ return a < 1 ? `${hex}${numToHex(Math.round(a * 255))}` : hex;
616
+ };
617
+ var rgbaToHsl = (r, g, b, a = 1) => {
618
+ const rNorm = r / 255;
619
+ const gNorm = g / 255;
620
+ const bNorm = b / 255;
621
+ const max = Math.max(rNorm, gNorm, bNorm);
622
+ const min = Math.min(rNorm, gNorm, bNorm);
623
+ let h = 0;
624
+ let s = 0;
625
+ const l = (max + min) / 2;
626
+ if (max !== min) {
627
+ const d = max - min;
628
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
629
+ switch (max) {
630
+ case rNorm:
631
+ h = (gNorm - bNorm) / d + (gNorm < bNorm ? 6 : 0);
632
+ break;
633
+ case gNorm:
634
+ h = (bNorm - rNorm) / d + 2;
635
+ break;
636
+ case bNorm:
637
+ h = (rNorm - gNorm) / d + 4;
638
+ break;
639
+ }
640
+ h /= 6;
641
+ }
642
+ h = Math.round(h * 360);
643
+ s = Math.round(s * 100);
644
+ const lPercent = Math.round(l * 100);
645
+ if (a === 1) {
646
+ return `hsl(${h}, ${s}%, ${lPercent}%)`;
647
+ }
648
+ return `hsla(${h}, ${s}%, ${lPercent}%, ${a})`;
649
+ };
650
+ var rgbaToHsv = (r, g, b, a = 1) => {
651
+ const rNorm = r / 255;
652
+ const gNorm = g / 255;
653
+ const bNorm = b / 255;
654
+ const max = Math.max(rNorm, gNorm, bNorm);
655
+ const min = Math.min(rNorm, gNorm, bNorm);
656
+ const d = max - min;
657
+ let h = 0;
658
+ if (d !== 0) {
659
+ switch (max) {
660
+ case rNorm:
661
+ h = (gNorm - bNorm) / d + (gNorm < bNorm ? 6 : 0);
662
+ break;
663
+ case gNorm:
664
+ h = (bNorm - rNorm) / d + 2;
665
+ break;
666
+ case bNorm:
667
+ h = (rNorm - gNorm) / d + 4;
668
+ break;
669
+ }
670
+ h /= 6;
671
+ }
672
+ const s = max === 0 ? 0 : d / max;
673
+ const v = max;
674
+ h = Math.round(h * 360);
675
+ const sPercent = Math.round(s * 100);
676
+ const vPercent = Math.round(v * 100);
677
+ if (a === 1) {
678
+ return `hsv(${h}, ${sPercent}%, ${vPercent}%)`;
679
+ }
680
+ return `hsva(${h}, ${sPercent}%, ${vPercent}%, ${a})`;
681
+ };
682
+ var rgbaToCmyk = (r, g, b, a = 1) => {
683
+ if (r === 0 && g === 0 && b === 0) {
684
+ return `cmyk(0%, 0%, 0%, 100%)`;
685
+ }
686
+ const rNorm = r / 255;
687
+ const gNorm = g / 255;
688
+ const bNorm = b / 255;
689
+ const k = 1 - Math.max(rNorm, gNorm, bNorm);
690
+ const c = (1 - rNorm - k) / (1 - k);
691
+ const m = (1 - gNorm - k) / (1 - k);
692
+ const y = (1 - bNorm - k) / (1 - k);
693
+ const cPercent = Math.round(c * 100);
694
+ const mPercent = Math.round(m * 100);
695
+ const yPercent = Math.round(y * 100);
696
+ const kPercent = Math.round(k * 100);
697
+ return `cmyk(${cPercent}%, ${mPercent}%, ${yPercent}%, ${kPercent}%)`;
698
+ };
699
+ var calculateLuminance = (r, g, b) => {
700
+ const [rs, gs, bs] = [r, g, b].map((c) => {
701
+ c = c / 255;
702
+ return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
703
+ });
704
+ return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
705
+ };
706
+ var calculateContrastRatio = (color1, color2) => {
707
+ const rgb1 = parseColor(color1);
708
+ const rgb2 = parseColor(color2);
709
+ if (!rgb1 || !rgb2) {
710
+ return 1;
711
+ }
712
+ const l1 = calculateLuminance(rgb1[0], rgb1[1], rgb1[2]);
713
+ const l2 = calculateLuminance(rgb2[0], rgb2[1], rgb2[2]);
714
+ const lighter = Math.max(l1, l2);
715
+ const darker = Math.min(l1, l2);
716
+ return (lighter + 0.05) / (darker + 0.05);
717
+ };
718
+ var adjustColor = (color, options) => {
719
+ const rgb = parseColor(color);
720
+ if (!rgb) return color;
721
+ let [r, g, b, a] = rgb;
722
+ if (options.alpha !== void 0) {
723
+ a = Math.max(0, Math.min(1, options.alpha));
724
+ }
725
+ let h = 0, s = 0, l = 0;
726
+ if (options.lightness !== void 0 || options.saturation !== void 0 || options.hue !== void 0) {
727
+ const rNorm = r / 255;
728
+ const gNorm = g / 255;
729
+ const bNorm = b / 255;
730
+ const max = Math.max(rNorm, gNorm, bNorm);
731
+ const min = Math.min(rNorm, gNorm, bNorm);
732
+ l = (max + min) / 2;
733
+ if (max !== min) {
734
+ const d = max - min;
735
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
736
+ switch (max) {
737
+ case rNorm:
738
+ h = (gNorm - bNorm) / d + (gNorm < bNorm ? 6 : 0);
739
+ break;
740
+ case gNorm:
741
+ h = (bNorm - rNorm) / d + 2;
742
+ break;
743
+ case bNorm:
744
+ h = (rNorm - gNorm) / d + 4;
745
+ break;
746
+ }
747
+ h /= 6;
748
+ }
749
+ h *= 360;
750
+ s *= 100;
751
+ l *= 100;
752
+ if (options.hue !== void 0) {
753
+ h = (h + options.hue) % 360;
754
+ if (h < 0) h += 360;
755
+ }
756
+ if (options.saturation !== void 0) {
757
+ s = Math.max(0, Math.min(100, s + options.saturation));
758
+ }
759
+ if (options.lightness !== void 0) {
760
+ l = Math.max(0, Math.min(100, l + options.lightness));
761
+ }
762
+ const hNorm = h / 360;
763
+ const sNorm = s / 100;
764
+ const lNorm = l / 100;
765
+ const chroma = (1 - Math.abs(2 * lNorm - 1)) * sNorm;
766
+ const x = chroma * (1 - Math.abs(hNorm * 6 % 2 - 1));
767
+ const m = lNorm - chroma / 2;
768
+ let rNorm2 = 0, gNorm2 = 0, bNorm2 = 0;
769
+ if (hNorm < 1 / 6) {
770
+ [rNorm2, gNorm2, bNorm2] = [chroma, x, 0];
771
+ } else if (hNorm < 2 / 6) {
772
+ [rNorm2, gNorm2, bNorm2] = [x, chroma, 0];
773
+ } else if (hNorm < 3 / 6) {
774
+ [rNorm2, gNorm2, bNorm2] = [0, chroma, x];
775
+ } else if (hNorm < 4 / 6) {
776
+ [rNorm2, gNorm2, bNorm2] = [0, x, chroma];
777
+ } else if (hNorm < 5 / 6) {
778
+ [rNorm2, gNorm2, bNorm2] = [x, 0, chroma];
779
+ } else {
780
+ [rNorm2, gNorm2, bNorm2] = [chroma, 0, x];
781
+ }
782
+ r = Math.round((rNorm2 + m) * 255);
783
+ g = Math.round((gNorm2 + m) * 255);
784
+ b = Math.round((bNorm2 + m) * 255);
785
+ }
786
+ if (options.contrast !== void 0) {
787
+ const factor = options.contrast / 100 * 2.55;
788
+ const avg = (r + g + b) / 3;
789
+ r = Math.round(avg + (r - avg) * (1 + factor));
790
+ g = Math.round(avg + (g - avg) * (1 + factor));
791
+ b = Math.round(avg + (b - avg) * (1 + factor));
792
+ r = Math.max(0, Math.min(255, r));
793
+ g = Math.max(0, Math.min(255, g));
794
+ b = Math.max(0, Math.min(255, b));
795
+ }
796
+ return rgbaToHex(r, g, b, a);
797
+ };
798
+ var mixColors = (options) => {
799
+ const {
800
+ color,
801
+ with: mixColor = "transparent",
802
+ percentage = 50,
803
+ colorSpace = "srgb"
804
+ } = options;
805
+ const rgb1 = parseColor(color);
806
+ const rgb2 = parseColor(mixColor);
807
+ if (!rgb1 || !rgb2) {
808
+ return color;
809
+ }
810
+ const factor = percentage / 100;
811
+ let [r1, g1, b1, a1] = rgb1;
812
+ let [r2, g2, b2, a2] = rgb2;
813
+ if (options.opacity !== void 0) {
814
+ a1 = typeof options.opacity === "number" ? options.opacity : parsePercentage(options.opacity);
815
+ }
816
+ if (options.withOpacity !== void 0) {
817
+ a2 = typeof options.withOpacity === "number" ? options.withOpacity : parsePercentage(options.withOpacity);
818
+ }
819
+ switch (colorSpace) {
820
+ case "srgb":
821
+ default:
822
+ const r = Math.round(r1 + (r2 - r1) * factor);
823
+ const g = Math.round(g1 + (g2 - g1) * factor);
824
+ const b = Math.round(b1 + (b2 - b1) * factor);
825
+ const a = a1 + (a2 - a1) * factor;
826
+ return rgbaToHex(r, g, b, a);
827
+ case "hsl":
828
+ const hsl1 = parseColor(rgbaToHsl(r1, g1, b1, a1));
829
+ const hsl2 = parseColor(rgbaToHsl(r2, g2, b2, a2));
830
+ if (!hsl1 || !hsl2) {
831
+ return color;
832
+ }
833
+ const h = (hsl1[0] + (hsl2[0] - hsl1[0]) * factor) % 360;
834
+ const s = hsl1[1] + (hsl2[1] - hsl1[1]) * factor;
835
+ const l = hsl1[2] + (hsl2[2] - hsl1[2]) * factor;
836
+ return `hsl(${h}, ${s}%, ${l}%)`;
837
+ }
838
+ };
839
+ var generatePalette = (baseColor, options = {}) => {
840
+ const rgb = parseColor(baseColor);
841
+ if (!rgb) return {};
842
+ const shades = options.shades || 10;
843
+ const lightnessFactor = options.lightnessFactor || 0.1;
844
+ const saturationFactor = options.saturationFactor || 0.05;
845
+ const palette = {};
846
+ for (let i = 0; i < shades; i++) {
847
+ const position = i / (shades - 1);
848
+ const lightnessAdjustment = (position - 0.5) * 2 * lightnessFactor * 100;
849
+ const shadeColor = adjustColor(baseColor, {
850
+ lightness: lightnessAdjustment,
851
+ saturation: (position - 0.5) * 2 * saturationFactor * 100
852
+ });
853
+ const key = i === 0 ? "50" : `${i * 100}`;
854
+ palette[key] = shadeColor;
855
+ }
856
+ if (options.includeComplementary) {
857
+ const hsl = parseColor(rgbaToHsl(rgb[0], rgb[1], rgb[2]));
858
+ if (hsl) {
859
+ let h = hsl[0];
860
+ h = (h + 180) % 360;
861
+ palette.complementary = `hsl(${h}, ${hsl[1]}%, ${hsl[2]}%)`;
862
+ }
863
+ }
864
+ if (options.includeAnalogous) {
865
+ const hsl = parseColor(rgbaToHsl(rgb[0], rgb[1], rgb[2]));
866
+ if (hsl) {
867
+ let h = hsl[0];
868
+ palette.analogous1 = `hsl(${(h - 30 + 360) % 360}, ${hsl[1]}%, ${hsl[2]}%)`;
869
+ palette.analogous2 = `hsl(${(h + 30) % 360}, ${hsl[1]}%, ${hsl[2]}%)`;
870
+ }
871
+ }
872
+ if (options.includeTriadic) {
873
+ const hsl = parseColor(rgbaToHsl(rgb[0], rgb[1], rgb[2]));
874
+ if (hsl) {
875
+ let h = hsl[0];
876
+ palette.triadic1 = `hsl(${(h + 120) % 360}, ${hsl[1]}%, ${hsl[2]}%)`;
877
+ palette.triadic2 = `hsl(${(h + 240) % 360}, ${hsl[1]}%, ${hsl[2]}%)`;
878
+ }
879
+ }
880
+ return palette;
881
+ };
882
+ var createContrastColor = (color, options = {}) => {
883
+ const {
884
+ lightColor = "#ffffff",
885
+ darkColor = "#000000",
886
+ targetRatio = 4.5,
887
+ fallbackColor = "#000000"
888
+ } = options;
889
+ const rgb = parseColor(color);
890
+ if (!rgb) return fallbackColor;
891
+ const luminance = calculateLuminance(rgb[0], rgb[1], rgb[2]);
892
+ const lightLuminance = calculateLuminance(
893
+ ...parseColor(lightColor).slice(0, 3)
894
+ );
895
+ const darkLuminance = calculateLuminance(
896
+ ...parseColor(darkColor).slice(0, 3)
897
+ );
898
+ const lightContrast = (Math.max(luminance, lightLuminance) + 0.05) / (Math.min(luminance, lightLuminance) + 0.05);
899
+ const darkContrast = (Math.max(luminance, darkLuminance) + 0.05) / (Math.min(luminance, darkLuminance) + 0.05);
900
+ if (lightContrast >= targetRatio && darkContrast >= targetRatio) {
901
+ return lightContrast > darkContrast ? lightColor : darkColor;
902
+ } else if (lightContrast >= targetRatio) {
903
+ return lightColor;
904
+ } else if (darkContrast >= targetRatio) {
905
+ return darkColor;
906
+ }
907
+ return lightContrast > darkContrast ? lightColor : darkColor;
908
+ };
909
+
910
+ // src/lib/color/conversions.ts
911
+ var D65_WHITE = { x: 0.95047, y: 1, z: 1.08883 };
912
+ var EPSILON = 8856e-6;
913
+ var KAPPA = 903.3;
914
+ function clamp(value, min, max) {
915
+ return Math.max(min, Math.min(max, value));
916
+ }
917
+ function roundToPrecision(value, precision = 2) {
918
+ const multiplier = Math.pow(10, precision);
919
+ return Math.round(value * multiplier) / multiplier;
920
+ }
921
+ function rgbToHsl(rgb) {
922
+ const r = rgb.r / 255;
923
+ const g = rgb.g / 255;
924
+ const b = rgb.b / 255;
925
+ const max = Math.max(r, g, b);
926
+ const min = Math.min(r, g, b);
927
+ const delta = max - min;
928
+ let h = 0;
929
+ let s = 0;
930
+ const l = (max + min) / 2;
931
+ if (delta !== 0) {
932
+ s = l > 0.5 ? delta / (2 - max - min) : delta / (max + min);
933
+ switch (max) {
934
+ case r:
935
+ h = ((g - b) / delta + (g < b ? 6 : 0)) / 6;
936
+ break;
937
+ case g:
938
+ h = ((b - r) / delta + 2) / 6;
939
+ break;
940
+ case b:
941
+ h = ((r - g) / delta + 4) / 6;
942
+ break;
943
+ }
944
+ }
945
+ return {
946
+ h: h * 360,
947
+ s: s * 100,
948
+ l: l * 100,
949
+ a: rgb.a
950
+ };
951
+ }
952
+ function rgbToHsv(rgb) {
953
+ const r = rgb.r / 255;
954
+ const g = rgb.g / 255;
955
+ const b = rgb.b / 255;
956
+ const max = Math.max(r, g, b);
957
+ const min = Math.min(r, g, b);
958
+ const delta = max - min;
959
+ let h = 0;
960
+ const s = max === 0 ? 0 : delta / max;
961
+ const v = max;
962
+ if (delta !== 0) {
963
+ switch (max) {
964
+ case r:
965
+ h = ((g - b) / delta + (g < b ? 6 : 0)) / 6;
966
+ break;
967
+ case g:
968
+ h = ((b - r) / delta + 2) / 6;
969
+ break;
970
+ case b:
971
+ h = ((r - g) / delta + 4) / 6;
972
+ break;
973
+ }
974
+ }
975
+ return {
976
+ h: h * 360,
977
+ s: s * 100,
978
+ v: v * 100,
979
+ a: rgb.a
980
+ };
981
+ }
982
+ function rgbToHwb(rgb) {
983
+ const hsv = rgbToHsv(rgb);
984
+ const w = (100 - hsv.s) * hsv.v / 100;
985
+ const b = 100 - hsv.v;
986
+ return {
987
+ h: hsv.h,
988
+ w,
989
+ b,
990
+ a: rgb.a
991
+ };
992
+ }
993
+ function rgbToCmyk(rgb) {
994
+ const r = rgb.r / 255;
995
+ const g = rgb.g / 255;
996
+ const b = rgb.b / 255;
997
+ const k = 1 - Math.max(r, g, b);
998
+ const c = k === 1 ? 0 : (1 - r - k) / (1 - k);
999
+ const m = k === 1 ? 0 : (1 - g - k) / (1 - k);
1000
+ const y = k === 1 ? 0 : (1 - b - k) / (1 - k);
1001
+ return {
1002
+ c: c * 100,
1003
+ m: m * 100,
1004
+ y: y * 100,
1005
+ k: k * 100,
1006
+ a: rgb.a
1007
+ };
1008
+ }
1009
+ function rgbToXyz(rgb) {
1010
+ let r = rgb.r / 255;
1011
+ let g = rgb.g / 255;
1012
+ let b = rgb.b / 255;
1013
+ r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
1014
+ g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
1015
+ b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
1016
+ const x = r * 0.4124564 + g * 0.3575761 + b * 0.1804375;
1017
+ const y = r * 0.2126729 + g * 0.7151522 + b * 0.072175;
1018
+ const z = r * 0.0193339 + g * 0.119192 + b * 0.9503041;
1019
+ return {
1020
+ x: x * 100,
1021
+ y: y * 100,
1022
+ z: z * 100,
1023
+ alpha: rgb.a
1024
+ };
1025
+ }
1026
+ function rgbToLab(rgb) {
1027
+ const xyz = rgbToXyz(rgb);
1028
+ return xyzToLab(xyz);
1029
+ }
1030
+ function rgbToLch(rgb) {
1031
+ const lab = rgbToLab(rgb);
1032
+ return labToLch(lab);
1033
+ }
1034
+ function rgbToOklab(rgb) {
1035
+ const r = rgb.r / 255;
1036
+ const g = rgb.g / 255;
1037
+ const b = rgb.b / 255;
1038
+ const lr = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
1039
+ const lg = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
1040
+ const lb = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
1041
+ const l = 0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb;
1042
+ const m = 0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb;
1043
+ const s = 0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb;
1044
+ const l_ = Math.cbrt(l);
1045
+ const m_ = Math.cbrt(m);
1046
+ const s_ = Math.cbrt(s);
1047
+ return {
1048
+ l: 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_,
1049
+ a: 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_,
1050
+ b: 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_,
1051
+ alpha: rgb.a
1052
+ };
1053
+ }
1054
+ function rgbToOklch(rgb) {
1055
+ const oklab = rgbToOklab(rgb);
1056
+ return oklabToOklch(oklab);
1057
+ }
1058
+ function hslToRgb2(hsl) {
1059
+ const h = hsl.h / 360;
1060
+ const s = hsl.s / 100;
1061
+ const l = hsl.l / 100;
1062
+ let r, g, b;
1063
+ if (s === 0) {
1064
+ r = g = b = l;
1065
+ } else {
1066
+ const hue2rgb = (p2, q2, t) => {
1067
+ if (t < 0) t += 1;
1068
+ if (t > 1) t -= 1;
1069
+ if (t < 1 / 6) return p2 + (q2 - p2) * 6 * t;
1070
+ if (t < 1 / 2) return q2;
1071
+ if (t < 2 / 3) return p2 + (q2 - p2) * (2 / 3 - t) * 6;
1072
+ return p2;
1073
+ };
1074
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
1075
+ const p = 2 * l - q;
1076
+ r = hue2rgb(p, q, h + 1 / 3);
1077
+ g = hue2rgb(p, q, h);
1078
+ b = hue2rgb(p, q, h - 1 / 3);
1079
+ }
1080
+ return {
1081
+ r: Math.round(r * 255),
1082
+ g: Math.round(g * 255),
1083
+ b: Math.round(b * 255),
1084
+ a: hsl.a
1085
+ };
1086
+ }
1087
+ function hsvToRgb(hsv) {
1088
+ const h = hsv.h / 360;
1089
+ const s = hsv.s / 100;
1090
+ const v = hsv.v / 100;
1091
+ const i = Math.floor(h * 6);
1092
+ const f = h * 6 - i;
1093
+ const p = v * (1 - s);
1094
+ const q = v * (1 - f * s);
1095
+ const t = v * (1 - (1 - f) * s);
1096
+ let r, g, b;
1097
+ switch (i % 6) {
1098
+ case 0:
1099
+ r = v;
1100
+ g = t;
1101
+ b = p;
1102
+ break;
1103
+ case 1:
1104
+ r = q;
1105
+ g = v;
1106
+ b = p;
1107
+ break;
1108
+ case 2:
1109
+ r = p;
1110
+ g = v;
1111
+ b = t;
1112
+ break;
1113
+ case 3:
1114
+ r = p;
1115
+ g = q;
1116
+ b = v;
1117
+ break;
1118
+ case 4:
1119
+ r = t;
1120
+ g = p;
1121
+ b = v;
1122
+ break;
1123
+ case 5:
1124
+ default:
1125
+ r = v;
1126
+ g = p;
1127
+ b = q;
1128
+ break;
1129
+ }
1130
+ return {
1131
+ r: Math.round(r * 255),
1132
+ g: Math.round(g * 255),
1133
+ b: Math.round(b * 255),
1134
+ a: hsv.a
1135
+ };
1136
+ }
1137
+ function hwbToRgb(hwb) {
1138
+ const h = hwb.h;
1139
+ let w = hwb.w / 100;
1140
+ let b = hwb.b / 100;
1141
+ const sum = w + b;
1142
+ if (sum > 1) {
1143
+ w /= sum;
1144
+ b /= sum;
1145
+ }
1146
+ const v = 1 - b;
1147
+ const s = v === 0 ? 0 : 1 - w / v;
1148
+ return hsvToRgb({ h, s: s * 100, v: v * 100, a: hwb.a });
1149
+ }
1150
+ function cmykToRgb(cmyk) {
1151
+ const c = cmyk.c / 100;
1152
+ const m = cmyk.m / 100;
1153
+ const y = cmyk.y / 100;
1154
+ const k = cmyk.k / 100;
1155
+ const r = 255 * (1 - c) * (1 - k);
1156
+ const g = 255 * (1 - m) * (1 - k);
1157
+ const b = 255 * (1 - y) * (1 - k);
1158
+ return {
1159
+ r: Math.round(r),
1160
+ g: Math.round(g),
1161
+ b: Math.round(b),
1162
+ a: cmyk.a
1163
+ };
1164
+ }
1165
+ function xyzToRgb(xyz) {
1166
+ const x = xyz.x / 100;
1167
+ const y = xyz.y / 100;
1168
+ const z = xyz.z / 100;
1169
+ let r = x * 3.2404542 + y * -1.5371385 + z * -0.4985314;
1170
+ let g = x * -0.969266 + y * 1.8760108 + z * 0.041556;
1171
+ let b = x * 0.0556434 + y * -0.2040259 + z * 1.0572252;
1172
+ r = r > 31308e-7 ? 1.055 * Math.pow(r, 1 / 2.4) - 0.055 : 12.92 * r;
1173
+ g = g > 31308e-7 ? 1.055 * Math.pow(g, 1 / 2.4) - 0.055 : 12.92 * g;
1174
+ b = b > 31308e-7 ? 1.055 * Math.pow(b, 1 / 2.4) - 0.055 : 12.92 * b;
1175
+ return {
1176
+ r: Math.round(clamp(r * 255, 0, 255)),
1177
+ g: Math.round(clamp(g * 255, 0, 255)),
1178
+ b: Math.round(clamp(b * 255, 0, 255)),
1179
+ a: xyz.alpha || 1
1180
+ };
1181
+ }
1182
+ function xyzToLab(xyz) {
1183
+ const xr = xyz.x / D65_WHITE.x / 100;
1184
+ const yr = xyz.y / D65_WHITE.y / 100;
1185
+ const zr = xyz.z / D65_WHITE.z / 100;
1186
+ const fx = xr > EPSILON ? Math.cbrt(xr) : (KAPPA * xr + 16) / 116;
1187
+ const fy = yr > EPSILON ? Math.cbrt(yr) : (KAPPA * yr + 16) / 116;
1188
+ const fz = zr > EPSILON ? Math.cbrt(zr) : (KAPPA * zr + 16) / 116;
1189
+ const l = 116 * fy - 16;
1190
+ const a = 500 * (fx - fy);
1191
+ const b = 200 * (fy - fz);
1192
+ return {
1193
+ l: clamp(l, 0, 100),
1194
+ a,
1195
+ b,
1196
+ alpha: xyz.alpha
1197
+ };
1198
+ }
1199
+ function labToXyz(lab) {
1200
+ const fy = (lab.l + 16) / 116;
1201
+ const fx = lab.a / 500 + fy;
1202
+ const fz = fy - lab.b / 200;
1203
+ const xr = fx * fx * fx > EPSILON ? fx * fx * fx : (116 * fx - 16) / KAPPA;
1204
+ const yr = lab.l > KAPPA * EPSILON ? Math.pow((lab.l + 16) / 116, 3) : lab.l / KAPPA;
1205
+ const zr = fz * fz * fz > EPSILON ? fz * fz * fz : (116 * fz - 16) / KAPPA;
1206
+ return {
1207
+ x: xr * D65_WHITE.x * 100,
1208
+ y: yr * D65_WHITE.y * 100,
1209
+ z: zr * D65_WHITE.z * 100,
1210
+ alpha: lab.alpha
1211
+ };
1212
+ }
1213
+ function labToRgb(lab) {
1214
+ const xyz = labToXyz(lab);
1215
+ return xyzToRgb(xyz);
1216
+ }
1217
+ function labToLch(lab) {
1218
+ const c = Math.sqrt(lab.a * lab.a + lab.b * lab.b);
1219
+ let h = Math.atan2(lab.b, lab.a) * 180 / Math.PI;
1220
+ if (h < 0) {
1221
+ h += 360;
1222
+ }
1223
+ return {
1224
+ l: lab.l,
1225
+ c,
1226
+ h,
1227
+ alpha: lab.alpha
1228
+ };
1229
+ }
1230
+ function lchToLab(lch) {
1231
+ const h = lch.h * Math.PI / 180;
1232
+ const a = lch.c * Math.cos(h);
1233
+ const b = lch.c * Math.sin(h);
1234
+ return {
1235
+ l: lch.l,
1236
+ a,
1237
+ b,
1238
+ alpha: lch.alpha
1239
+ };
1240
+ }
1241
+ function lchToRgb(lch) {
1242
+ const lab = lchToLab(lch);
1243
+ return labToRgb(lab);
1244
+ }
1245
+ function oklabToRgb(oklab) {
1246
+ const l_ = oklab.l + 0.3963377774 * oklab.a + 0.2158037573 * oklab.b;
1247
+ const m_ = oklab.l - 0.1055613458 * oklab.a - 0.0638541728 * oklab.b;
1248
+ const s_ = oklab.l - 0.0894841775 * oklab.a - 1.291485548 * oklab.b;
1249
+ const l = l_ * l_ * l_;
1250
+ const m = m_ * m_ * m_;
1251
+ const s = s_ * s_ * s_;
1252
+ let lr = 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s;
1253
+ let lg = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s;
1254
+ let lb = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;
1255
+ lr = lr > 31308e-7 ? 1.055 * Math.pow(lr, 1 / 2.4) - 0.055 : 12.92 * lr;
1256
+ lg = lg > 31308e-7 ? 1.055 * Math.pow(lg, 1 / 2.4) - 0.055 : 12.92 * lg;
1257
+ lb = lb > 31308e-7 ? 1.055 * Math.pow(lb, 1 / 2.4) - 0.055 : 12.92 * lb;
1258
+ return {
1259
+ r: Math.round(clamp(lr * 255, 0, 255)),
1260
+ g: Math.round(clamp(lg * 255, 0, 255)),
1261
+ b: Math.round(clamp(lb * 255, 0, 255)),
1262
+ a: oklab.alpha
1263
+ };
1264
+ }
1265
+ function oklabToOklch(oklab) {
1266
+ const c = Math.sqrt(oklab.a * oklab.a + oklab.b * oklab.b);
1267
+ let h = Math.atan2(oklab.b, oklab.a) * 180 / Math.PI;
1268
+ if (h < 0) {
1269
+ h += 360;
1270
+ }
1271
+ return {
1272
+ l: oklab.l,
1273
+ c,
1274
+ h,
1275
+ alpha: oklab.alpha
1276
+ };
1277
+ }
1278
+ function oklchToOklab(oklch) {
1279
+ const h = oklch.h * Math.PI / 180;
1280
+ const a = oklch.c * Math.cos(h);
1281
+ const b = oklch.c * Math.sin(h);
1282
+ return {
1283
+ l: oklch.l,
1284
+ a,
1285
+ b,
1286
+ alpha: oklch.alpha
1287
+ };
1288
+ }
1289
+ function oklchToRgb2(oklch) {
1290
+ const oklab = oklchToOklab(oklch);
1291
+ return oklabToRgb(oklab);
1292
+ }
1293
+ function anyToRgb(color) {
1294
+ if ("r" in color && "g" in color && "b" in color) {
1295
+ return color;
1296
+ }
1297
+ if ("h" in color && "s" in color && "l" in color) {
1298
+ return hslToRgb2(color);
1299
+ }
1300
+ if ("h" in color && "s" in color && "v" in color) {
1301
+ return hsvToRgb(color);
1302
+ }
1303
+ if ("h" in color && "w" in color && "b" in color) {
1304
+ return hwbToRgb(color);
1305
+ }
1306
+ if ("c" in color && "m" in color && "y" in color && "k" in color) {
1307
+ return cmykToRgb(color);
1308
+ }
1309
+ if ("x" in color && "y" in color && "z" in color) {
1310
+ return xyzToRgb(color);
1311
+ }
1312
+ if ("l" in color && "a" in color && "b" in color && !("c" in color) && !("h" in color)) {
1313
+ return labToRgb(color);
1314
+ }
1315
+ if ("l" in color && "c" in color && "h" in color) {
1316
+ const lchColor = color;
1317
+ if (lchColor.l <= 1) {
1318
+ return oklchToRgb2(color);
1319
+ }
1320
+ return lchToRgb(lchColor);
1321
+ }
1322
+ throw new Error("Unknown color format");
1323
+ }
1324
+ function convertColor(color, targetFormat, options = {}) {
1325
+ const { round = true, precision = 2, preserveAlpha = true } = options;
1326
+ const rgb = anyToRgb(color);
1327
+ let result;
1328
+ switch (targetFormat.toLowerCase()) {
1329
+ case "rgb":
1330
+ result = rgb;
1331
+ break;
1332
+ case "hsl":
1333
+ result = rgbToHsl(rgb);
1334
+ break;
1335
+ case "hsv":
1336
+ result = rgbToHsv(rgb);
1337
+ break;
1338
+ case "hwb":
1339
+ result = rgbToHwb(rgb);
1340
+ break;
1341
+ case "cmyk":
1342
+ result = rgbToCmyk(rgb);
1343
+ break;
1344
+ case "xyz":
1345
+ result = rgbToXyz(rgb);
1346
+ break;
1347
+ case "lab":
1348
+ result = rgbToLab(rgb);
1349
+ break;
1350
+ case "lch":
1351
+ result = rgbToLch(rgb);
1352
+ break;
1353
+ case "oklab":
1354
+ result = rgbToOklab(rgb);
1355
+ break;
1356
+ case "oklch":
1357
+ result = rgbToOklch(rgb);
1358
+ break;
1359
+ default:
1360
+ result = rgb;
1361
+ }
1362
+ if (round && result) {
1363
+ Object.keys(result).forEach((key) => {
1364
+ if (typeof result[key] === "number" && key !== "a" && key !== "alpha") {
1365
+ result[key] = roundToPrecision(result[key], precision);
1366
+ }
1367
+ });
1368
+ }
1369
+ if (!preserveAlpha) {
1370
+ delete result.a;
1371
+ delete result.alpha;
1372
+ }
1373
+ return result;
1374
+ }
1375
+ function getConversionPath(from, to) {
1376
+ const directConversions = {
1377
+ rgb: ["hsl", "hsv", "hwb", "cmyk", "xyz", "lab", "lch", "oklab", "oklch"],
1378
+ hsl: ["rgb", "hsv", "hwb"],
1379
+ hsv: ["rgb", "hsl", "hwb"],
1380
+ hwb: ["rgb", "hsl", "hsv"],
1381
+ cmyk: ["rgb", "hsl", "hsv"],
1382
+ xyz: ["rgb", "lab"],
1383
+ lab: ["rgb", "xyz", "lch"],
1384
+ lch: ["rgb", "lab", "xyz"],
1385
+ oklab: ["rgb", "oklch"],
1386
+ oklch: ["rgb", "oklab"]
1387
+ };
1388
+ from = from.toLowerCase();
1389
+ to = to.toLowerCase();
1390
+ if (from === to) {
1391
+ return [from];
1392
+ }
1393
+ if (directConversions[from]?.includes(to)) {
1394
+ return [from, to];
1395
+ }
1396
+ if (directConversions[from]?.includes("rgb") && directConversions["rgb"]?.includes(to)) {
1397
+ return [from, "rgb", to];
1398
+ }
1399
+ if (["lab", "lch"].includes(from) && ["lab", "lch"].includes(to) && from !== to) {
1400
+ return [from, "xyz", to];
1401
+ }
1402
+ if (["oklab", "oklch"].includes(from) && ["oklab", "oklch"].includes(to) && from !== to) {
1403
+ return [from, "oklab", to];
1404
+ }
1405
+ if (directConversions[from] && directConversions["rgb"]?.includes(to)) {
1406
+ return [from, "rgb", to];
1407
+ }
1408
+ return null;
1409
+ }
1410
+ function getSupportedFormats() {
1411
+ return [
1412
+ "rgb",
1413
+ "hsl",
1414
+ "hsv",
1415
+ "hwb",
1416
+ "cmyk",
1417
+ "xyz",
1418
+ "lab",
1419
+ "lch",
1420
+ "oklab",
1421
+ "oklch"
1422
+ ];
1423
+ }
1424
+ function isValidFormat(format) {
1425
+ return getSupportedFormats().includes(format.toLowerCase());
1426
+ }
1427
+
1428
+ // src/lib/color/color.ts
1429
+ var Color = class _Color {
1430
+ /**
1431
+ * Creates a new Color instance
1432
+ * @param color - Color representation (string, array, object, or another Color)
1433
+ */
1434
+ constructor(color = "#000000") {
1435
+ this._r = 0;
1436
+ this._g = 0;
1437
+ this._b = 0;
1438
+ this._a = 1;
1439
+ this.set(color);
1440
+ }
1441
+ /**
1442
+ * Parse any RGB/RGBA format
1443
+ */
1444
+ static parseRgbString(colorString) {
1445
+ return parseRgbaColor(colorString);
1446
+ }
1447
+ /**
1448
+ * Check if string matches any RGB pattern
1449
+ */
1450
+ static isRgbFormat(colorString) {
1451
+ return Object.values(RGB_PATTERNS).some(
1452
+ (pattern) => pattern.test(colorString.trim())
1453
+ );
1454
+ }
1455
+ /**
1456
+ * Get the specific RGB pattern that matches
1457
+ */
1458
+ static getRgbPatternMatch(colorString) {
1459
+ const str = colorString.trim();
1460
+ for (const [name, pattern] of Object.entries(RGB_PATTERNS)) {
1461
+ if (pattern.test(str)) {
1462
+ return name;
1463
+ }
1464
+ }
1465
+ return null;
1466
+ }
1467
+ /**
1468
+ * Convert RGB values to modern CSS syntax
1469
+ */
1470
+ static toModernRgbSyntax(r, g, b, a) {
1471
+ const components = [r, g, b];
1472
+ if (a !== void 0 && a !== 1) {
1473
+ return `rgb(${components.join(" ")} / ${a})`;
1474
+ }
1475
+ return `rgb(${components.join(" ")})`;
1476
+ }
1477
+ /**
1478
+ * Convert RGB values to legacy syntax
1479
+ */
1480
+ static toLegacyRgbSyntax(r, g, b, a) {
1481
+ const components = [r, g, b];
1482
+ if (a !== void 0 && a !== 1) {
1483
+ return `rgba(${components.join(", ")}, ${a})`;
1484
+ }
1485
+ return `rgb(${components.join(", ")})`;
1486
+ }
1487
+ /**
1488
+ * Normalize RGB string to a consistent format
1489
+ */
1490
+ static normalizeRgbString(colorString, format = "modern") {
1491
+ const rgba = parseRgbaColor(colorString);
1492
+ if (!rgba) return null;
1493
+ const [r, g, b, a] = rgba;
1494
+ if (format === "modern") {
1495
+ return this.toModernRgbSyntax(r, g, b, a);
1496
+ } else {
1497
+ return this.toLegacyRgbSyntax(r, g, b, a);
1498
+ }
1499
+ }
1500
+ /**
1501
+ * Sets the color from any representation
1502
+ * @param color - Color representation
1503
+ * @returns This Color instance for chaining
1504
+ */
1505
+ set(color) {
1506
+ if (typeof color === "string") {
1507
+ const rgb = parseColor(color);
1508
+ if (rgb) {
1509
+ [this._r, this._g, this._b, this._a] = rgb;
1510
+ }
1511
+ } else if (Array.isArray(color)) {
1512
+ [this._r = 0, this._g = 0, this._b = 0, this._a = 1] = color;
1513
+ } else if (color instanceof _Color) {
1514
+ [this._r, this._g, this._b, this._a] = [
1515
+ color._r,
1516
+ color._g,
1517
+ color._b,
1518
+ color._a
1519
+ ];
1520
+ } else if (typeof color === "object") {
1521
+ return this.setFromObject(color);
1522
+ }
1523
+ this._clamp();
1524
+ return this;
1525
+ }
1526
+ /**
1527
+ * Clamps color values to valid ranges
1528
+ * @private
1529
+ */
1530
+ _clamp() {
1531
+ this._r = Math.max(0, Math.min(255, Math.round(this._r)));
1532
+ this._g = Math.max(0, Math.min(255, Math.round(this._g)));
1533
+ this._b = Math.max(0, Math.min(255, Math.round(this._b)));
1534
+ this._a = Math.max(0, Math.min(1, this._a));
1535
+ }
1536
+ /**
1537
+ * Gets the red component
1538
+ */
1539
+ get r() {
1540
+ return this._r;
1541
+ }
1542
+ /**
1543
+ * Sets the red component
1544
+ */
1545
+ set r(value) {
1546
+ this._r = value;
1547
+ this._clamp();
1548
+ }
1549
+ /**
1550
+ * Gets the green component
1551
+ */
1552
+ get g() {
1553
+ return this._g;
1554
+ }
1555
+ /**
1556
+ * Sets the green component
1557
+ */
1558
+ set g(value) {
1559
+ this._g = value;
1560
+ this._clamp();
1561
+ }
1562
+ /**
1563
+ * Gets the blue component
1564
+ */
1565
+ get b() {
1566
+ return this._b;
1567
+ }
1568
+ /**
1569
+ * Sets the blue component
1570
+ */
1571
+ set b(value) {
1572
+ this._b = value;
1573
+ this._clamp();
1574
+ }
1575
+ /**
1576
+ * Gets the alpha component
1577
+ */
1578
+ get a() {
1579
+ return this._a;
1580
+ }
1581
+ /**
1582
+ * Sets the alpha component
1583
+ */
1584
+ set a(value) {
1585
+ this._a = value;
1586
+ this._clamp();
1587
+ }
1588
+ /**
1589
+ * Gets the RGB array
1590
+ */
1591
+ get rgb() {
1592
+ return [this._r, this._g, this._b];
1593
+ }
1594
+ /**
1595
+ * Gets the RGBA array
1596
+ */
1597
+ get rgba() {
1598
+ return [this._r, this._g, this._b, this._a];
1599
+ }
1600
+ /**
1601
+ * Converts to hex string
1602
+ * @returns Hex color string
1603
+ */
1604
+ toHex() {
1605
+ return rgbaToHex(this._r, this._g, this._b, this._a);
1606
+ }
1607
+ /**
1608
+ * Converts to RGB string
1609
+ * @returns RGB color string
1610
+ */
1611
+ toRgb() {
1612
+ return formatRgba(this._r, this._g, this._b);
1613
+ }
1614
+ /**
1615
+ * Converts to RGBA string
1616
+ * @returns RGBA color string
1617
+ */
1618
+ toRgba() {
1619
+ return formatRgba(this._r, this._g, this._b, this._a);
1620
+ }
1621
+ /**
1622
+ * Gets RGB object
1623
+ * @returns RGB color object
1624
+ */
1625
+ getRgbObject() {
1626
+ return { r: this._r, g: this._g, b: this._b, a: this._a };
1627
+ }
1628
+ /**
1629
+ * Converts to HSL string
1630
+ * @returns HSL/HSLA color string
1631
+ */
1632
+ toHsl() {
1633
+ return rgbaToHsl(this._r, this._g, this._b, this._a);
1634
+ }
1635
+ /**
1636
+ * Gets HSL object
1637
+ * @returns HSL color object
1638
+ */
1639
+ getHslObject() {
1640
+ return rgbToHsl(this.getRgbObject());
1641
+ }
1642
+ /**
1643
+ * Converts to HSV string
1644
+ * @returns HSV/HSVA color string
1645
+ */
1646
+ toHsv() {
1647
+ return rgbaToHsv(this._r, this._g, this._b, this._a);
1648
+ }
1649
+ /**
1650
+ * Gets HSV object
1651
+ * @returns HSV color object
1652
+ */
1653
+ getHsvObject() {
1654
+ return rgbToHsv(this.getRgbObject());
1655
+ }
1656
+ /**
1657
+ * Converts to HWB string
1658
+ * @returns HWB color string
1659
+ */
1660
+ toHwb() {
1661
+ const hwb = rgbToHwb(this.getRgbObject());
1662
+ const alphaStr = this._a < 1 ? ` / ${Math.round(this._a * 100) / 100}` : "";
1663
+ return `hwb(${Math.round(hwb.h)} ${Math.round(hwb.w)}% ${Math.round(
1664
+ hwb.b
1665
+ )}%${alphaStr})`;
1666
+ }
1667
+ /**
1668
+ * Gets HWB object
1669
+ * @returns HWB color object
1670
+ */
1671
+ getHwbObject() {
1672
+ return rgbToHwb(this.getRgbObject());
1673
+ }
1674
+ /**
1675
+ * Converts to CMYK string
1676
+ * @returns CMYK color string
1677
+ */
1678
+ toCmyk() {
1679
+ return rgbaToCmyk(this._r, this._g, this._b, this._a);
1680
+ }
1681
+ /**
1682
+ * Gets CMYK object
1683
+ * @returns CMYK color object
1684
+ */
1685
+ getCmykObject() {
1686
+ return rgbToCmyk(this.getRgbObject());
1687
+ }
1688
+ /**
1689
+ * Converts to XYZ string
1690
+ * @returns XYZ color string
1691
+ */
1692
+ toXyz() {
1693
+ const xyz = rgbToXyz(this.getRgbObject());
1694
+ const alphaStr = this._a < 1 ? ` / ${Math.round(this._a * 100) / 100}` : "";
1695
+ return `color(xyz ${xyz.x.toFixed(4)} ${xyz.y.toFixed(4)} ${xyz.z.toFixed(
1696
+ 4
1697
+ )}${alphaStr})`;
1698
+ }
1699
+ /**
1700
+ * Gets XYZ object
1701
+ * @returns XYZ color object
1702
+ */
1703
+ getXyzObject() {
1704
+ return rgbToXyz(this.getRgbObject());
1705
+ }
1706
+ /**
1707
+ * Converts to LAB string
1708
+ * @returns LAB color string
1709
+ */
1710
+ toLab() {
1711
+ const lab = rgbToLab(this.getRgbObject());
1712
+ const alphaStr = this._a < 1 ? ` / ${Math.round(this._a * 100) / 100}` : "";
1713
+ return `lab(${lab.l.toFixed(2)}% ${lab.a.toFixed(2)} ${lab.b.toFixed(
1714
+ 2
1715
+ )}${alphaStr})`;
1716
+ }
1717
+ /**
1718
+ * Gets LAB object
1719
+ * @returns LAB color object
1720
+ */
1721
+ getLabObject() {
1722
+ return rgbToLab(this.getRgbObject());
1723
+ }
1724
+ /**
1725
+ * Converts to LCH string
1726
+ * @returns LCH color string
1727
+ */
1728
+ toLch() {
1729
+ const lch = rgbToLch(this.getRgbObject());
1730
+ const alphaStr = this._a < 1 ? ` / ${Math.round(this._a * 100) / 100}` : "";
1731
+ return `lch(${lch.l.toFixed(2)}% ${lch.c.toFixed(2)} ${lch.h.toFixed(
1732
+ 2
1733
+ )}${alphaStr})`;
1734
+ }
1735
+ /**
1736
+ * Gets LCH object
1737
+ * @returns LCH color object
1738
+ */
1739
+ getLchObject() {
1740
+ return rgbToLch(this.getRgbObject());
1741
+ }
1742
+ /**
1743
+ * Converts to OKLAB string
1744
+ * @returns OKLAB color string
1745
+ */
1746
+ toOklab() {
1747
+ const oklab = rgbToOklab(this.getRgbObject());
1748
+ const alphaStr = this._a < 1 ? ` / ${Math.round(this._a * 100) / 100}` : "";
1749
+ return `oklab(${oklab.l.toFixed(4)} ${oklab.a.toFixed(4)} ${oklab.b.toFixed(
1750
+ 4
1751
+ )}${alphaStr})`;
1752
+ }
1753
+ /**
1754
+ * Gets OKLAB object
1755
+ * @returns OKLAB color object
1756
+ */
1757
+ getOklabObject() {
1758
+ return rgbToOklab(this.getRgbObject());
1759
+ }
1760
+ /**
1761
+ * Converts to OKLCH string
1762
+ * @returns OKLCH color string
1763
+ */
1764
+ toOklch() {
1765
+ const oklch = rgbToOklch(this.getRgbObject());
1766
+ const alphaStr = this._a < 1 ? ` / ${Math.round(this._a * 100) / 100}` : "";
1767
+ return `oklch(${oklch.l.toFixed(4)} ${oklch.c.toFixed(4)} ${oklch.h.toFixed(
1768
+ 2
1769
+ )}${alphaStr})`;
1770
+ }
1771
+ /**
1772
+ * Gets OKLCH object
1773
+ * @returns OKLCH color object
1774
+ */
1775
+ getOklchObject() {
1776
+ return rgbToOklch(this.getRgbObject());
1777
+ }
1778
+ /**
1779
+ * Adjusts the color
1780
+ * @param options - Adjustment options
1781
+ * @returns This Color instance for chaining
1782
+ */
1783
+ adjust(options) {
1784
+ const adjusted = adjustColor(this.toHex(), options);
1785
+ this.set(adjusted);
1786
+ return this;
1787
+ }
1788
+ /**
1789
+ * Lightens the color
1790
+ * @param amount - Lighten amount (0-100)
1791
+ * @returns This Color instance for chaining
1792
+ */
1793
+ lighten(amount) {
1794
+ return this.adjust({ lightness: amount });
1795
+ }
1796
+ /**
1797
+ * Darkens the color
1798
+ * @param amount - Darken amount (0-100)
1799
+ * @returns This Color instance for chaining
1800
+ */
1801
+ darken(amount) {
1802
+ return this.adjust({ lightness: -amount });
1803
+ }
1804
+ /**
1805
+ * Saturates the color
1806
+ * @param amount - Saturate amount (0-100)
1807
+ * @returns This Color instance for chaining
1808
+ */
1809
+ saturate(amount) {
1810
+ return this.adjust({ saturation: amount });
1811
+ }
1812
+ /**
1813
+ * Desaturates the color
1814
+ * @param amount - Desaturate amount (0-100)
1815
+ * @returns This Color instance for chaining
1816
+ */
1817
+ desaturate(amount) {
1818
+ return this.adjust({ saturation: -amount });
1819
+ }
1820
+ /**
1821
+ * Rotates the hue
1822
+ * @param degrees - Hue rotation in degrees
1823
+ * @returns This Color instance for chaining
1824
+ */
1825
+ rotate(degrees) {
1826
+ return this.adjust({ hue: degrees });
1827
+ }
1828
+ /**
1829
+ * Sets the alpha value
1830
+ * @param alpha - Alpha value (0-1)
1831
+ * @returns This Color instance for chaining
1832
+ */
1833
+ alpha(alpha) {
1834
+ this._a = Math.max(0, Math.min(1, alpha));
1835
+ return this;
1836
+ }
1837
+ /**
1838
+ * Mixes with another color
1839
+ * @param color - Color to mix with
1840
+ * @param percentage - Mix percentage (0-100)
1841
+ * @param colorSpace - Color space for mixing
1842
+ * @returns This Color instance for chaining
1843
+ */
1844
+ mix(color, percentage = 50, colorSpace = "srgb") {
1845
+ const mixed = mixColors({
1846
+ color: this.toHex(),
1847
+ with: color,
1848
+ percentage,
1849
+ colorSpace
1850
+ });
1851
+ this.set(mixed);
1852
+ return this;
1853
+ }
1854
+ /**
1855
+ * Gets the contrasting color
1856
+ * @param options - Contrast options
1857
+ * @returns Contrasting Color instance
1858
+ */
1859
+ getContrastColor(options = {}) {
1860
+ const contrast = createContrastColor(this.toHex(), options);
1861
+ return new _Color(contrast);
1862
+ }
1863
+ /**
1864
+ * Gets the relative luminance
1865
+ * @returns Relative luminance (0-1)
1866
+ */
1867
+ getLuminance() {
1868
+ return calculateLuminance(this._r, this._g, this._b);
1869
+ }
1870
+ /**
1871
+ * Calculates contrast ratio with another color
1872
+ * @param color - Color to compare with
1873
+ * @returns Contrast ratio (1-21)
1874
+ */
1875
+ getContrastRatio(color) {
1876
+ const otherColor = color instanceof _Color ? color.toHex() : color;
1877
+ return calculateContrastRatio(this.toHex(), otherColor);
1878
+ }
1879
+ /**
1880
+ * Generates a palette from this color
1881
+ * @param options - Palette options
1882
+ * @returns Object with color shades
1883
+ */
1884
+ getPalette(options = {}) {
1885
+ return generatePalette(this.toHex(), options);
1886
+ }
1887
+ /**
1888
+ * Clones the color
1889
+ * @returns New Color instance with same values
1890
+ */
1891
+ clone() {
1892
+ return new _Color(this.rgba);
1893
+ }
1894
+ /**
1895
+ * Converts to string in specified format
1896
+ * @param format - Output format
1897
+ * @returns Color string
1898
+ */
1899
+ toString(format = "hex") {
1900
+ switch (format) {
1901
+ case "hex":
1902
+ return this.toHex();
1903
+ case "rgb":
1904
+ return this.toRgb();
1905
+ case "rgba":
1906
+ return this.toRgba();
1907
+ case "hsl":
1908
+ return this.toHsl();
1909
+ case "hsla":
1910
+ return this.toHsl();
1911
+ case "hsv":
1912
+ return this.toHsv();
1913
+ case "hsva":
1914
+ return this.toHsv();
1915
+ case "hwb":
1916
+ return this.toHwb();
1917
+ case "cmyk":
1918
+ return this.toCmyk();
1919
+ case "xyz":
1920
+ return this.toXyz();
1921
+ case "lab":
1922
+ return this.toLab();
1923
+ case "lch":
1924
+ return this.toLch();
1925
+ case "oklab":
1926
+ return this.toOklab();
1927
+ case "oklch":
1928
+ return this.toOklch();
1929
+ default:
1930
+ return this.toHex();
1931
+ }
1932
+ }
1933
+ /**
1934
+ * Convert to any format with options
1935
+ * @param format - Target format
1936
+ * @param options - Conversion options
1937
+ * @returns Converted color object
1938
+ */
1939
+ convertTo(format, options = {}) {
1940
+ return convertColor(this.getRgbObject(), format, options);
1941
+ }
1942
+ /**
1943
+ * Set color from any color space object
1944
+ * @param color - Color object in any supported format
1945
+ * @returns This Color instance for chaining
1946
+ */
1947
+ setFromObject(color) {
1948
+ let rgb;
1949
+ if ("r" in color && "g" in color && "b" in color) {
1950
+ rgb = color;
1951
+ } else if ("h" in color && "s" in color && "l" in color) {
1952
+ rgb = hslToRgb2(color);
1953
+ } else if ("h" in color && "s" in color && "v" in color) {
1954
+ rgb = hsvToRgb(color);
1955
+ } else if ("h" in color && "w" in color && "b" in color) {
1956
+ rgb = hwbToRgb(color);
1957
+ } else if ("c" in color && "m" in color && "y" in color && "k" in color) {
1958
+ rgb = cmykToRgb(color);
1959
+ } else if ("x" in color && "y" in color && "z" in color) {
1960
+ rgb = xyzToRgb(color);
1961
+ } else if ("l" in color && "a" in color && "b" in color) {
1962
+ rgb = labToRgb(color);
1963
+ } else if ("l" in color && "c" in color && "h" in color) {
1964
+ const lchColor = color;
1965
+ rgb = lchColor.l <= 1 ? oklchToRgb2(color) : lchToRgb(lchColor);
1966
+ } else {
1967
+ throw new Error("Unknown color format");
1968
+ }
1969
+ this._r = rgb.r;
1970
+ this._g = rgb.g;
1971
+ this._b = rgb.b;
1972
+ this._a = rgb.a ?? 1;
1973
+ this._clamp();
1974
+ return this;
1975
+ }
1976
+ /**
1977
+ * Get color harmony colors
1978
+ * @param options - Harmony options
1979
+ * @returns Array of Color instances
1980
+ */
1981
+ getHarmony(options = {}) {
1982
+ const { type = "complementary", count = 5, angleOffset = 30 } = options;
1983
+ const hsl = this.getHslObject();
1984
+ const colors = [];
1985
+ switch (type) {
1986
+ case "complementary":
1987
+ colors.push(
1988
+ new _Color({ h: (hsl.h + 180) % 360, s: hsl.s, l: hsl.l, a: hsl.a })
1989
+ );
1990
+ break;
1991
+ case "analogous":
1992
+ colors.push(
1993
+ new _Color({
1994
+ h: (hsl.h - angleOffset + 360) % 360,
1995
+ s: hsl.s,
1996
+ l: hsl.l,
1997
+ a: hsl.a
1998
+ }),
1999
+ new _Color({
2000
+ h: (hsl.h + angleOffset) % 360,
2001
+ s: hsl.s,
2002
+ l: hsl.l,
2003
+ a: hsl.a
2004
+ })
2005
+ );
2006
+ break;
2007
+ case "triadic":
2008
+ colors.push(
2009
+ new _Color({ h: (hsl.h + 120) % 360, s: hsl.s, l: hsl.l, a: hsl.a }),
2010
+ new _Color({ h: (hsl.h + 240) % 360, s: hsl.s, l: hsl.l, a: hsl.a })
2011
+ );
2012
+ break;
2013
+ case "tetradic":
2014
+ colors.push(
2015
+ new _Color({ h: (hsl.h + 90) % 360, s: hsl.s, l: hsl.l, a: hsl.a }),
2016
+ new _Color({ h: (hsl.h + 180) % 360, s: hsl.s, l: hsl.l, a: hsl.a }),
2017
+ new _Color({ h: (hsl.h + 270) % 360, s: hsl.s, l: hsl.l, a: hsl.a })
2018
+ );
2019
+ break;
2020
+ case "split-complementary":
2021
+ colors.push(
2022
+ new _Color({ h: (hsl.h + 150) % 360, s: hsl.s, l: hsl.l, a: hsl.a }),
2023
+ new _Color({ h: (hsl.h + 210) % 360, s: hsl.s, l: hsl.l, a: hsl.a })
2024
+ );
2025
+ break;
2026
+ case "square":
2027
+ colors.push(
2028
+ new _Color({ h: (hsl.h + 90) % 360, s: hsl.s, l: hsl.l, a: hsl.a }),
2029
+ new _Color({ h: (hsl.h + 180) % 360, s: hsl.s, l: hsl.l, a: hsl.a }),
2030
+ new _Color({ h: (hsl.h + 270) % 360, s: hsl.s, l: hsl.l, a: hsl.a })
2031
+ );
2032
+ break;
2033
+ case "monochromatic":
2034
+ const step = 100 / (count + 1);
2035
+ for (let i = 1; i <= count; i++) {
2036
+ colors.push(
2037
+ new _Color({
2038
+ h: hsl.h,
2039
+ s: hsl.s,
2040
+ l: Math.max(0, Math.min(100, step * i)),
2041
+ a: hsl.a
2042
+ })
2043
+ );
2044
+ }
2045
+ break;
2046
+ }
2047
+ return colors;
2048
+ }
2049
+ /**
2050
+ * Get supported color formats
2051
+ * @returns Array of supported format names
2052
+ */
2053
+ static getSupportedFormats() {
2054
+ return getSupportedFormats();
2055
+ }
2056
+ /**
2057
+ * Check if format is valid
2058
+ * @param format - Format to check
2059
+ * @returns True if format is supported
2060
+ */
2061
+ static isValidFormat(format) {
2062
+ return isValidFormat(format);
2063
+ }
2064
+ /**
2065
+ * Get conversion path between formats
2066
+ * @param from - Source format
2067
+ * @param to - Target format
2068
+ * @returns Array of formats in conversion path
2069
+ */
2070
+ static getConversionPath(from, to) {
2071
+ return getConversionPath(from, to);
2072
+ }
2073
+ /**
2074
+ * Checks if the color is valid
2075
+ * @returns True if color is valid
2076
+ */
2077
+ isValid() {
2078
+ return isValidColor(this.toHex());
2079
+ }
2080
+ /**
2081
+ * Creates a Color instance from string
2082
+ * @param color - Color string
2083
+ * @returns Color instance or null if invalid
2084
+ */
2085
+ static fromString(color) {
2086
+ if (!isValidColor(color)) {
2087
+ return null;
2088
+ }
2089
+ return new _Color(color);
2090
+ }
2091
+ /**
2092
+ * Creates a random Color
2093
+ * @returns Random Color instance
2094
+ */
2095
+ static random() {
2096
+ const r = Math.floor(Math.random() * 256);
2097
+ const g = Math.floor(Math.random() * 256);
2098
+ const b = Math.floor(Math.random() * 256);
2099
+ return new _Color([r, g, b, 1]);
2100
+ }
2101
+ /**
2102
+ * Predefined colors
2103
+ */
2104
+ static get transparent() {
2105
+ return new _Color("transparent");
2106
+ }
2107
+ static get white() {
2108
+ return new _Color("#ffffff");
2109
+ }
2110
+ static get black() {
2111
+ return new _Color("#000000");
2112
+ }
2113
+ static get red() {
2114
+ return new _Color("#ff0000");
2115
+ }
2116
+ static get green() {
2117
+ return new _Color("#00ff00");
2118
+ }
2119
+ static get blue() {
2120
+ return new _Color("#0000ff");
2121
+ }
2122
+ static get yellow() {
2123
+ return new _Color("#ffff00");
2124
+ }
2125
+ static get cyan() {
2126
+ return new _Color("#00ffff");
2127
+ }
2128
+ static get magenta() {
2129
+ return new _Color("#ff00ff");
2130
+ }
2131
+ static get gray() {
2132
+ return new _Color("#808080");
2133
+ }
2134
+ static get lightGray() {
2135
+ return new _Color("#d3d3d3");
2136
+ }
2137
+ static get darkGray() {
2138
+ return new _Color("#a9a9a9");
2139
+ }
2140
+ static get orange() {
2141
+ return new _Color("#ffa500");
2142
+ }
2143
+ static get purple() {
2144
+ return new _Color("#800080");
2145
+ }
2146
+ static get pink() {
2147
+ return new _Color("#ffc0cb");
2148
+ }
2149
+ static get brown() {
2150
+ return new _Color("#a52a2a");
2151
+ }
2152
+ static get teal() {
2153
+ return new _Color("#008080");
2154
+ }
2155
+ static get lime() {
2156
+ return new _Color("#00ff00");
2157
+ }
2158
+ static get indigo() {
2159
+ return new _Color("#4b0082");
2160
+ }
2161
+ static get violet() {
2162
+ return new _Color("#ee82ee");
2163
+ }
2164
+ };
2165
+ export {
2166
+ Color
2167
+ };