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