react-color-palette-wheel 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,6 +46,12 @@ function App() {
46
46
  }
47
47
  ```
48
48
 
49
+ ## Sandbox
50
+
51
+ https://codesandbox.io/p/sandbox/eloquent-franklin-rh3357
52
+
53
+ ![image](https://github.com/user-attachments/assets/bce02bd5-424d-4fc3-9132-6dd80fed6efb)
54
+
49
55
  ## 🛠️ Build Details
50
56
  * **Formats:** ESM (.es.js) and UMD (.umd.js).
51
57
  * **Size:** ~16kB (Minified + Gzipped).
@@ -1,408 +1,150 @@
1
- import Se, { useState as Re, useRef as Q, useCallback as K, useEffect as le } from "react";
2
- var X = { exports: {} }, $ = {};
3
- var ue;
4
- function Ce() {
5
- if (ue) return $;
6
- ue = 1;
7
- var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
8
- function r(o, a, s) {
9
- var i = null;
10
- if (s !== void 0 && (i = "" + s), a.key !== void 0 && (i = "" + a.key), "key" in a) {
11
- s = {};
12
- for (var d in a)
13
- d !== "key" && (s[d] = a[d]);
14
- } else s = a;
15
- return a = s.ref, {
16
- $$typeof: e,
17
- type: o,
18
- key: i,
19
- ref: a !== void 0 ? a : null,
20
- props: s
21
- };
22
- }
23
- return $.Fragment = t, $.jsx = r, $.jsxs = r, $;
24
- }
25
- var Y = {};
26
- var ce;
27
- function ke() {
28
- return ce || (ce = 1, process.env.NODE_ENV !== "production" && (function() {
29
- function e(n) {
30
- if (n == null) return null;
31
- if (typeof n == "function")
32
- return n.$$typeof === G ? null : n.displayName || n.name || null;
33
- if (typeof n == "string") return n;
34
- switch (n) {
35
- case y:
36
- return "Fragment";
37
- case P:
38
- return "Profiler";
39
- case x:
40
- return "StrictMode";
41
- case V:
42
- return "Suspense";
43
- case q:
44
- return "SuspenseList";
45
- case H:
46
- return "Activity";
47
- }
48
- if (typeof n == "object")
49
- switch (typeof n.tag == "number" && console.error(
50
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
51
- ), n.$$typeof) {
52
- case p:
53
- return "Portal";
54
- case k:
55
- return n.displayName || "Context";
56
- case j:
57
- return (n._context.displayName || "Context") + ".Consumer";
58
- case R:
59
- var u = n.render;
60
- return n = n.displayName, n || (n = u.displayName || u.name || "", n = n !== "" ? "ForwardRef(" + n + ")" : "ForwardRef"), n;
61
- case A:
62
- return u = n.displayName || null, u !== null ? u : e(n.type) || "Memo";
63
- case O:
64
- u = n._payload, n = n._init;
65
- try {
66
- return e(n(u));
67
- } catch {
68
- }
69
- }
70
- return null;
71
- }
72
- function t(n) {
73
- return "" + n;
74
- }
75
- function r(n) {
76
- try {
77
- t(n);
78
- var u = !1;
79
- } catch {
80
- u = !0;
81
- }
82
- if (u) {
83
- u = console;
84
- var b = u.error, g = typeof Symbol == "function" && Symbol.toStringTag && n[Symbol.toStringTag] || n.constructor.name || "Object";
85
- return b.call(
86
- u,
87
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
88
- g
89
- ), t(n);
90
- }
91
- }
92
- function o(n) {
93
- if (n === y) return "<>";
94
- if (typeof n == "object" && n !== null && n.$$typeof === O)
95
- return "<...>";
96
- try {
97
- var u = e(n);
98
- return u ? "<" + u + ">" : "<...>";
99
- } catch {
100
- return "<...>";
101
- }
102
- }
103
- function a() {
104
- var n = F.A;
105
- return n === null ? null : n.getOwner();
106
- }
107
- function s() {
108
- return Error("react-stack-top-frame");
109
- }
110
- function i(n) {
111
- if (D.call(n, "key")) {
112
- var u = Object.getOwnPropertyDescriptor(n, "key").get;
113
- if (u && u.isReactWarning) return !1;
114
- }
115
- return n.key !== void 0;
116
- }
117
- function d(n, u) {
118
- function b() {
119
- ne || (ne = !0, console.error(
120
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
121
- u
122
- ));
123
- }
124
- b.isReactWarning = !0, Object.defineProperty(n, "key", {
125
- get: b,
126
- configurable: !0
127
- });
128
- }
129
- function _() {
130
- var n = e(this.type);
131
- return oe[n] || (oe[n] = !0, console.error(
132
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
133
- )), n = this.props.ref, n !== void 0 ? n : null;
134
- }
135
- function m(n, u, b, g, z, B) {
136
- var v = b.ref;
137
- return n = {
138
- $$typeof: f,
139
- type: n,
140
- key: u,
141
- props: b,
142
- _owner: g
143
- }, (v !== void 0 ? v : null) !== null ? Object.defineProperty(n, "ref", {
144
- enumerable: !1,
145
- get: _
146
- }) : Object.defineProperty(n, "ref", { enumerable: !1, value: null }), n._store = {}, Object.defineProperty(n._store, "validated", {
147
- configurable: !1,
148
- enumerable: !1,
149
- writable: !0,
150
- value: 0
151
- }), Object.defineProperty(n, "_debugInfo", {
152
- configurable: !1,
153
- enumerable: !1,
154
- writable: !0,
155
- value: null
156
- }), Object.defineProperty(n, "_debugStack", {
157
- configurable: !1,
158
- enumerable: !1,
159
- writable: !0,
160
- value: z
161
- }), Object.defineProperty(n, "_debugTask", {
162
- configurable: !1,
163
- enumerable: !1,
164
- writable: !0,
165
- value: B
166
- }), Object.freeze && (Object.freeze(n.props), Object.freeze(n)), n;
167
- }
168
- function h(n, u, b, g, z, B) {
169
- var v = u.children;
170
- if (v !== void 0)
171
- if (g)
172
- if (L(v)) {
173
- for (g = 0; g < v.length; g++)
174
- N(v[g]);
175
- Object.freeze && Object.freeze(v);
176
- } else
177
- console.error(
178
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
179
- );
180
- else N(v);
181
- if (D.call(u, "key")) {
182
- v = e(n);
183
- var I = Object.keys(u).filter(function(we) {
184
- return we !== "key";
185
- });
186
- g = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", ie[v + g] || (I = 0 < I.length ? "{" + I.join(": ..., ") + ": ...}" : "{}", console.error(
187
- `A props object containing a "key" prop is being spread into JSX:
188
- let props = %s;
189
- <%s {...props} />
190
- React keys must be passed directly to JSX without using spread:
191
- let props = %s;
192
- <%s key={someKey} {...props} />`,
193
- g,
194
- v,
195
- I,
196
- v
197
- ), ie[v + g] = !0);
198
- }
199
- if (v = null, b !== void 0 && (r(b), v = "" + b), i(u) && (r(u.key), v = "" + u.key), "key" in u) {
200
- b = {};
201
- for (var Z in u)
202
- Z !== "key" && (b[Z] = u[Z]);
203
- } else b = u;
204
- return v && d(
205
- b,
206
- typeof n == "function" ? n.displayName || n.name || "Unknown" : n
207
- ), m(
208
- n,
209
- v,
210
- b,
211
- a(),
212
- z,
213
- B
214
- );
215
- }
216
- function N(n) {
217
- c(n) ? n._store && (n._store.validated = 1) : typeof n == "object" && n !== null && n.$$typeof === O && (n._payload.status === "fulfilled" ? c(n._payload.value) && n._payload.value._store && (n._payload.value._store.validated = 1) : n._store && (n._store.validated = 1));
218
- }
219
- function c(n) {
220
- return typeof n == "object" && n !== null && n.$$typeof === f;
221
- }
222
- var l = Se, f = /* @__PURE__ */ Symbol.for("react.transitional.element"), p = /* @__PURE__ */ Symbol.for("react.portal"), y = /* @__PURE__ */ Symbol.for("react.fragment"), x = /* @__PURE__ */ Symbol.for("react.strict_mode"), P = /* @__PURE__ */ Symbol.for("react.profiler"), j = /* @__PURE__ */ Symbol.for("react.consumer"), k = /* @__PURE__ */ Symbol.for("react.context"), R = /* @__PURE__ */ Symbol.for("react.forward_ref"), V = /* @__PURE__ */ Symbol.for("react.suspense"), q = /* @__PURE__ */ Symbol.for("react.suspense_list"), A = /* @__PURE__ */ Symbol.for("react.memo"), O = /* @__PURE__ */ Symbol.for("react.lazy"), H = /* @__PURE__ */ Symbol.for("react.activity"), G = /* @__PURE__ */ Symbol.for("react.client.reference"), F = l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, D = Object.prototype.hasOwnProperty, L = Array.isArray, J = console.createTask ? console.createTask : function() {
223
- return null;
224
- };
225
- l = {
226
- react_stack_bottom_frame: function(n) {
227
- return n();
228
- }
229
- };
230
- var ne, oe = {}, ae = l.react_stack_bottom_frame.bind(
231
- l,
232
- s
233
- )(), se = J(o(s)), ie = {};
234
- Y.Fragment = y, Y.jsx = function(n, u, b) {
235
- var g = 1e4 > F.recentlyCreatedOwnerStacks++;
236
- return h(
237
- n,
238
- u,
239
- b,
240
- !1,
241
- g ? Error("react-stack-top-frame") : ae,
242
- g ? J(o(n)) : se
243
- );
244
- }, Y.jsxs = function(n, u, b) {
245
- var g = 1e4 > F.recentlyCreatedOwnerStacks++;
246
- return h(
247
- n,
248
- u,
249
- b,
250
- !0,
251
- g ? Error("react-stack-top-frame") : ae,
252
- g ? J(o(n)) : se
253
- );
254
- };
255
- })()), Y;
256
- }
257
- var fe;
258
- function Te() {
259
- return fe || (fe = 1, process.env.NODE_ENV === "production" ? X.exports = Ce() : X.exports = ke()), X.exports;
260
- }
261
- var M = Te(), Ae = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, T = function(e) {
262
- return typeof e == "string" ? e.length > 0 : typeof e == "number";
263
- }, E = function(e, t, r) {
264
- return t === void 0 && (t = 0), r === void 0 && (r = Math.pow(10, t)), Math.round(r * e) / r + 0;
265
- }, S = function(e, t, r) {
266
- return t === void 0 && (t = 0), r === void 0 && (r = 1), e > r ? r : e > t ? e : t;
267
- }, Ee = function(e) {
268
- return (e = isFinite(e) ? e % 360 : 0) > 0 ? e : e + 360;
269
- }, de = function(e) {
270
- return { r: S(e.r, 0, 255), g: S(e.g, 0, 255), b: S(e.b, 0, 255), a: S(e.a) };
271
- }, ee = function(e) {
272
- return { r: E(e.r), g: E(e.g), b: E(e.b), a: E(e.a, 3) };
273
- }, Me = /^#([0-9a-f]{3,8})$/i, U = function(e) {
274
- var t = e.toString(16);
275
- return t.length < 2 ? "0" + t : t;
276
- }, _e = function(e) {
277
- var t = e.r, r = e.g, o = e.b, a = e.a, s = Math.max(t, r, o), i = s - Math.min(t, r, o), d = i ? s === t ? (r - o) / i : s === r ? 2 + (o - t) / i : 4 + (t - r) / i : 0;
278
- return { h: 60 * (d < 0 ? d + 6 : d), s: s ? i / s * 100 : 0, v: s / 255 * 100, a };
279
- }, Pe = function(e) {
280
- var t = e.h, r = e.s, o = e.v, a = e.a;
281
- t = t / 360 * 6, r /= 100, o /= 100;
282
- var s = Math.floor(t), i = o * (1 - r), d = o * (1 - (t - s) * r), _ = o * (1 - (1 - t + s) * r), m = s % 6;
283
- return { r: 255 * [o, d, i, i, _, o][m], g: 255 * [_, o, o, d, i, i][m], b: 255 * [i, i, _, o, o, d][m], a };
284
- }, pe = function(e) {
285
- return { h: Ee(e.h), s: S(e.s, 0, 100), l: S(e.l, 0, 100), a: S(e.a) };
286
- }, he = function(e) {
287
- return { h: E(e.h), s: E(e.s), l: E(e.l), a: E(e.a, 3) };
288
- }, be = function(e) {
289
- return Pe((r = (t = e).s, { h: t.h, s: (r *= ((o = t.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * r / (o + r) * 100 : 0, v: o + r, a: t.a }));
290
- var t, r, o;
291
- }, W = function(e) {
292
- return { h: (t = _e(e)).h, s: (a = (200 - (r = t.s)) * (o = t.v) / 100) > 0 && a < 200 ? r * o / 100 / (a <= 100 ? a : 200 - a) * 100 : 0, l: a / 2, a: t.a };
293
- var t, r, o, a;
294
- }, Ne = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, je = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Oe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Fe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ge = { string: [[function(e) {
295
- var t = Me.exec(e);
296
- return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ? E(parseInt(e[3] + e[3], 16) / 255, 2) : 1 } : e.length === 6 || e.length === 8 ? { r: parseInt(e.substr(0, 2), 16), g: parseInt(e.substr(2, 2), 16), b: parseInt(e.substr(4, 2), 16), a: e.length === 8 ? E(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
297
- }, "hex"], [function(e) {
298
- var t = Oe.exec(e) || Fe.exec(e);
299
- return t ? t[2] !== t[4] || t[4] !== t[6] ? null : de({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: t[7] === void 0 ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
300
- }, "rgb"], [function(e) {
301
- var t = Ne.exec(e) || je.exec(e);
302
- if (!t) return null;
303
- var r, o, a = pe({ h: (r = t[1], o = t[2], o === void 0 && (o = "deg"), Number(r) * (Ae[o] || 1)), s: Number(t[3]), l: Number(t[4]), a: t[5] === void 0 ? 1 : Number(t[5]) / (t[6] ? 100 : 1) });
304
- return be(a);
305
- }, "hsl"]], object: [[function(e) {
306
- var t = e.r, r = e.g, o = e.b, a = e.a, s = a === void 0 ? 1 : a;
307
- return T(t) && T(r) && T(o) ? de({ r: Number(t), g: Number(r), b: Number(o), a: Number(s) }) : null;
308
- }, "rgb"], [function(e) {
309
- var t = e.h, r = e.s, o = e.l, a = e.a, s = a === void 0 ? 1 : a;
310
- if (!T(t) || !T(r) || !T(o)) return null;
311
- var i = pe({ h: Number(t), s: Number(r), l: Number(o), a: Number(s) });
312
- return be(i);
313
- }, "hsl"], [function(e) {
314
- var t = e.h, r = e.s, o = e.v, a = e.a, s = a === void 0 ? 1 : a;
315
- if (!T(t) || !T(r) || !T(o)) return null;
316
- var i = (function(d) {
317
- return { h: Ee(d.h), s: S(d.s, 0, 100), v: S(d.v, 0, 100), a: S(d.a) };
318
- })({ h: Number(t), s: Number(r), v: Number(o), a: Number(s) });
319
- return Pe(i);
320
- }, "hsv"]] }, ve = function(e, t) {
321
- for (var r = 0; r < t.length; r++) {
322
- var o = t[r][0](e);
323
- if (o) return [o, t[r][1]];
1
+ import { jsx as S, jsxs as rt } from "react/jsx-runtime";
2
+ import { useState as Z, useRef as k, useCallback as A, useEffect as G } from "react";
3
+ var at = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, w = function(t) {
4
+ return typeof t == "string" ? t.length > 0 : typeof t == "number";
5
+ }, d = function(t, n, e) {
6
+ return n === void 0 && (n = 0), e === void 0 && (e = Math.pow(10, n)), Math.round(e * t) / e + 0;
7
+ }, M = function(t, n, e) {
8
+ return n === void 0 && (n = 0), e === void 0 && (e = 1), t > e ? e : t > n ? t : n;
9
+ }, U = function(t) {
10
+ return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
11
+ }, L = function(t) {
12
+ return { r: M(t.r, 0, 255), g: M(t.g, 0, 255), b: M(t.b, 0, 255), a: M(t.a) };
13
+ }, H = function(t) {
14
+ return { r: d(t.r), g: d(t.g), b: d(t.b), a: d(t.a, 3) };
15
+ }, st = /^#([0-9a-f]{3,8})$/i, D = function(t) {
16
+ var n = t.toString(16);
17
+ return n.length < 2 ? "0" + n : n;
18
+ }, tt = function(t) {
19
+ var n = t.r, e = t.g, o = t.b, r = t.a, a = Math.max(n, e, o), s = a - Math.min(n, e, o), f = s ? a === n ? (e - o) / s : a === e ? 2 + (o - n) / s : 4 + (n - e) / s : 0;
20
+ return { h: 60 * (f < 0 ? f + 6 : f), s: a ? s / a * 100 : 0, v: a / 255 * 100, a: r };
21
+ }, nt = function(t) {
22
+ var n = t.h, e = t.s, o = t.v, r = t.a;
23
+ n = n / 360 * 6, e /= 100, o /= 100;
24
+ var a = Math.floor(n), s = o * (1 - e), f = o * (1 - (n - a) * e), m = o * (1 - (1 - n + a) * e), p = a % 6;
25
+ return { r: 255 * [o, f, s, s, m, o][p], g: 255 * [m, o, o, f, s, s][p], b: 255 * [s, s, m, o, o, f][p], a: r };
26
+ }, B = function(t) {
27
+ return { h: U(t.h), s: M(t.s, 0, 100), l: M(t.l, 0, 100), a: M(t.a) };
28
+ }, O = function(t) {
29
+ return { h: d(t.h), s: d(t.s), l: d(t.l), a: d(t.a, 3) };
30
+ }, T = function(t) {
31
+ return nt((e = (n = t).s, { h: n.h, s: (e *= ((o = n.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * e / (o + e) * 100 : 0, v: o + e, a: n.a }));
32
+ var n, e, o;
33
+ }, I = function(t) {
34
+ return { h: (n = tt(t)).h, s: (r = (200 - (e = n.s)) * (o = n.v) / 100) > 0 && r < 200 ? e * o / 100 / (r <= 100 ? r : 200 - r) * 100 : 0, l: r / 2, a: n.a };
35
+ var n, e, o, r;
36
+ }, it = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, lt = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ct = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ut = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, V = { string: [[function(t) {
37
+ var n = st.exec(t);
38
+ return n ? (t = n[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? d(parseInt(t[3] + t[3], 16) / 255, 2) : 1 } : t.length === 6 || t.length === 8 ? { r: parseInt(t.substr(0, 2), 16), g: parseInt(t.substr(2, 2), 16), b: parseInt(t.substr(4, 2), 16), a: t.length === 8 ? d(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
39
+ }, "hex"], [function(t) {
40
+ var n = ct.exec(t) || ut.exec(t);
41
+ return n ? n[2] !== n[4] || n[4] !== n[6] ? null : L({ r: Number(n[1]) / (n[2] ? 100 / 255 : 1), g: Number(n[3]) / (n[4] ? 100 / 255 : 1), b: Number(n[5]) / (n[6] ? 100 / 255 : 1), a: n[7] === void 0 ? 1 : Number(n[7]) / (n[8] ? 100 : 1) }) : null;
42
+ }, "rgb"], [function(t) {
43
+ var n = it.exec(t) || lt.exec(t);
44
+ if (!n) return null;
45
+ var e, o, r = B({ h: (e = n[1], o = n[2], o === void 0 && (o = "deg"), Number(e) * (at[o] || 1)), s: Number(n[3]), l: Number(n[4]), a: n[5] === void 0 ? 1 : Number(n[5]) / (n[6] ? 100 : 1) });
46
+ return T(r);
47
+ }, "hsl"]], object: [[function(t) {
48
+ var n = t.r, e = t.g, o = t.b, r = t.a, a = r === void 0 ? 1 : r;
49
+ return w(n) && w(e) && w(o) ? L({ r: Number(n), g: Number(e), b: Number(o), a: Number(a) }) : null;
50
+ }, "rgb"], [function(t) {
51
+ var n = t.h, e = t.s, o = t.l, r = t.a, a = r === void 0 ? 1 : r;
52
+ if (!w(n) || !w(e) || !w(o)) return null;
53
+ var s = B({ h: Number(n), s: Number(e), l: Number(o), a: Number(a) });
54
+ return T(s);
55
+ }, "hsl"], [function(t) {
56
+ var n = t.h, e = t.s, o = t.v, r = t.a, a = r === void 0 ? 1 : r;
57
+ if (!w(n) || !w(e) || !w(o)) return null;
58
+ var s = (function(f) {
59
+ return { h: U(f.h), s: M(f.s, 0, 100), v: M(f.v, 0, 100), a: M(f.a) };
60
+ })({ h: Number(n), s: Number(e), v: Number(o), a: Number(a) });
61
+ return nt(s);
62
+ }, "hsv"]] }, _ = function(t, n) {
63
+ for (var e = 0; e < n.length; e++) {
64
+ var o = n[e][0](t);
65
+ if (o) return [o, n[e][1]];
324
66
  }
325
67
  return [null, void 0];
326
- }, Ie = function(e) {
327
- return typeof e == "string" ? ve(e.trim(), ge.string) : typeof e == "object" && e !== null ? ve(e, ge.object) : [null, void 0];
328
- }, te = function(e, t) {
329
- var r = W(e);
330
- return { h: r.h, s: S(r.s + 100 * t, 0, 100), l: r.l, a: r.a };
331
- }, re = function(e) {
332
- return (299 * e.r + 587 * e.g + 114 * e.b) / 1e3 / 255;
333
- }, me = function(e, t) {
334
- var r = W(e);
335
- return { h: r.h, s: r.s, l: S(r.l + 100 * t, 0, 100), a: r.a };
336
- }, ye = (function() {
337
- function e(t) {
338
- this.parsed = Ie(t)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
68
+ }, ft = function(t) {
69
+ return typeof t == "string" ? _(t.trim(), V.string) : typeof t == "object" && t !== null ? _(t, V.object) : [null, void 0];
70
+ }, $ = function(t, n) {
71
+ var e = I(t);
72
+ return { h: e.h, s: M(e.s + 100 * n, 0, 100), l: e.l, a: e.a };
73
+ }, j = function(t) {
74
+ return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
75
+ }, J = function(t, n) {
76
+ var e = I(t);
77
+ return { h: e.h, s: e.s, l: M(e.l + 100 * n, 0, 100), a: e.a };
78
+ }, K = (function() {
79
+ function t(n) {
80
+ this.parsed = ft(n)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
339
81
  }
340
- return e.prototype.isValid = function() {
82
+ return t.prototype.isValid = function() {
341
83
  return this.parsed !== null;
342
- }, e.prototype.brightness = function() {
343
- return E(re(this.rgba), 2);
344
- }, e.prototype.isDark = function() {
345
- return re(this.rgba) < 0.5;
346
- }, e.prototype.isLight = function() {
347
- return re(this.rgba) >= 0.5;
348
- }, e.prototype.toHex = function() {
349
- return t = ee(this.rgba), r = t.r, o = t.g, a = t.b, i = (s = t.a) < 1 ? U(E(255 * s)) : "", "#" + U(r) + U(o) + U(a) + i;
350
- var t, r, o, a, s, i;
351
- }, e.prototype.toRgb = function() {
352
- return ee(this.rgba);
353
- }, e.prototype.toRgbString = function() {
354
- return t = ee(this.rgba), r = t.r, o = t.g, a = t.b, (s = t.a) < 1 ? "rgba(" + r + ", " + o + ", " + a + ", " + s + ")" : "rgb(" + r + ", " + o + ", " + a + ")";
355
- var t, r, o, a, s;
356
- }, e.prototype.toHsl = function() {
357
- return he(W(this.rgba));
358
- }, e.prototype.toHslString = function() {
359
- return t = he(W(this.rgba)), r = t.h, o = t.s, a = t.l, (s = t.a) < 1 ? "hsla(" + r + ", " + o + "%, " + a + "%, " + s + ")" : "hsl(" + r + ", " + o + "%, " + a + "%)";
360
- var t, r, o, a, s;
361
- }, e.prototype.toHsv = function() {
362
- return t = _e(this.rgba), { h: E(t.h), s: E(t.s), v: E(t.v), a: E(t.a, 3) };
363
- var t;
364
- }, e.prototype.invert = function() {
365
- return C({ r: 255 - (t = this.rgba).r, g: 255 - t.g, b: 255 - t.b, a: t.a });
366
- var t;
367
- }, e.prototype.saturate = function(t) {
368
- return t === void 0 && (t = 0.1), C(te(this.rgba, t));
369
- }, e.prototype.desaturate = function(t) {
370
- return t === void 0 && (t = 0.1), C(te(this.rgba, -t));
371
- }, e.prototype.grayscale = function() {
372
- return C(te(this.rgba, -1));
373
- }, e.prototype.lighten = function(t) {
374
- return t === void 0 && (t = 0.1), C(me(this.rgba, t));
375
- }, e.prototype.darken = function(t) {
376
- return t === void 0 && (t = 0.1), C(me(this.rgba, -t));
377
- }, e.prototype.rotate = function(t) {
378
- return t === void 0 && (t = 15), this.hue(this.hue() + t);
379
- }, e.prototype.alpha = function(t) {
380
- return typeof t == "number" ? C({ r: (r = this.rgba).r, g: r.g, b: r.b, a: t }) : E(this.rgba.a, 3);
381
- var r;
382
- }, e.prototype.hue = function(t) {
383
- var r = W(this.rgba);
384
- return typeof t == "number" ? C({ h: t, s: r.s, l: r.l, a: r.a }) : E(r.h);
385
- }, e.prototype.isEqual = function(t) {
386
- return this.toHex() === C(t).toHex();
387
- }, e;
388
- })(), C = function(e) {
389
- return e instanceof ye ? e : new ye(e);
84
+ }, t.prototype.brightness = function() {
85
+ return d(j(this.rgba), 2);
86
+ }, t.prototype.isDark = function() {
87
+ return j(this.rgba) < 0.5;
88
+ }, t.prototype.isLight = function() {
89
+ return j(this.rgba) >= 0.5;
90
+ }, t.prototype.toHex = function() {
91
+ return n = H(this.rgba), e = n.r, o = n.g, r = n.b, s = (a = n.a) < 1 ? D(d(255 * a)) : "", "#" + D(e) + D(o) + D(r) + s;
92
+ var n, e, o, r, a, s;
93
+ }, t.prototype.toRgb = function() {
94
+ return H(this.rgba);
95
+ }, t.prototype.toRgbString = function() {
96
+ return n = H(this.rgba), e = n.r, o = n.g, r = n.b, (a = n.a) < 1 ? "rgba(" + e + ", " + o + ", " + r + ", " + a + ")" : "rgb(" + e + ", " + o + ", " + r + ")";
97
+ var n, e, o, r, a;
98
+ }, t.prototype.toHsl = function() {
99
+ return O(I(this.rgba));
100
+ }, t.prototype.toHslString = function() {
101
+ return n = O(I(this.rgba)), e = n.h, o = n.s, r = n.l, (a = n.a) < 1 ? "hsla(" + e + ", " + o + "%, " + r + "%, " + a + ")" : "hsl(" + e + ", " + o + "%, " + r + "%)";
102
+ var n, e, o, r, a;
103
+ }, t.prototype.toHsv = function() {
104
+ return n = tt(this.rgba), { h: d(n.h), s: d(n.s), v: d(n.v), a: d(n.a, 3) };
105
+ var n;
106
+ }, t.prototype.invert = function() {
107
+ return C({ r: 255 - (n = this.rgba).r, g: 255 - n.g, b: 255 - n.b, a: n.a });
108
+ var n;
109
+ }, t.prototype.saturate = function(n) {
110
+ return n === void 0 && (n = 0.1), C($(this.rgba, n));
111
+ }, t.prototype.desaturate = function(n) {
112
+ return n === void 0 && (n = 0.1), C($(this.rgba, -n));
113
+ }, t.prototype.grayscale = function() {
114
+ return C($(this.rgba, -1));
115
+ }, t.prototype.lighten = function(n) {
116
+ return n === void 0 && (n = 0.1), C(J(this.rgba, n));
117
+ }, t.prototype.darken = function(n) {
118
+ return n === void 0 && (n = 0.1), C(J(this.rgba, -n));
119
+ }, t.prototype.rotate = function(n) {
120
+ return n === void 0 && (n = 15), this.hue(this.hue() + n);
121
+ }, t.prototype.alpha = function(n) {
122
+ return typeof n == "number" ? C({ r: (e = this.rgba).r, g: e.g, b: e.b, a: n }) : d(this.rgba.a, 3);
123
+ var e;
124
+ }, t.prototype.hue = function(n) {
125
+ var e = I(this.rgba);
126
+ return typeof n == "number" ? C({ h: n, s: e.s, l: e.l, a: e.a }) : d(e.h);
127
+ }, t.prototype.isEqual = function(n) {
128
+ return this.toHex() === C(n).toHex();
129
+ }, t;
130
+ })(), C = function(t) {
131
+ return t instanceof K ? t : new K(t);
390
132
  };
391
- const De = ({
392
- hexColor: e,
393
- cursorPos: t,
394
- onPointerDown: r,
133
+ const ht = ({
134
+ hexColor: t,
135
+ cursorPos: n,
136
+ onPointerDown: e,
395
137
  onPointerMove: o,
396
- onPointerUp: a
138
+ onPointerUp: r
397
139
  }) => {
398
- const [s, i] = Re(!1), d = (h) => {
399
- i(!0), r(h), h.currentTarget.setPointerCapture(h.pointerId);
400
- }, _ = (h) => {
401
- s && o(h);
140
+ const [a, s] = Z(!1), f = (h) => {
141
+ s(!0), e(h), h.currentTarget.setPointerCapture(h.pointerId);
402
142
  }, m = (h) => {
403
- i(!1), a(h), h.currentTarget.releasePointerCapture(h.pointerId);
143
+ a && o(h);
144
+ }, p = (h) => {
145
+ s(!1), r(h), h.currentTarget.releasePointerCapture(h.pointerId);
404
146
  };
405
- return /* @__PURE__ */ M.jsx(
147
+ return /* @__PURE__ */ S(
406
148
  "div",
407
149
  {
408
150
  style: {
@@ -412,21 +154,21 @@ const De = ({
412
154
  borderRadius: "50%",
413
155
  border: "2px solid white",
414
156
  boxShadow: "0 2px 4px rgba(0,0,0,0.3)",
415
- backgroundColor: e,
157
+ backgroundColor: t,
416
158
  left: "50%",
417
159
  top: "50%",
418
- transform: `translate(calc(-50% + ${t.x}px), calc(-50% + ${t.y}px))`,
160
+ transform: `translate(calc(-50% + ${n.x}px), calc(-50% + ${n.y}px))`,
419
161
  pointerEvents: "auto",
420
- cursor: s ? "grabbing" : "grab",
162
+ cursor: a ? "grabbing" : "grab",
421
163
  willChange: "transform",
422
164
  zIndex: 10
423
165
  },
424
- onPointerDown: d,
425
- onPointerMove: _,
426
- onPointerUp: m
166
+ onPointerDown: f,
167
+ onPointerMove: m,
168
+ onPointerUp: p
427
169
  }
428
170
  );
429
- }, w = {
171
+ }, x = {
430
172
  /** Custom color selection without predefined harmony */
431
173
  Custom: "Custom",
432
174
  /** Colors adjacent to each other on the color wheel */
@@ -443,165 +185,165 @@ const De = ({
443
185
  Square: "Square",
444
186
  /** A combination of complementary and analogous colors */
445
187
  Compound: "Compound"
446
- }, xe = (e, t, r, o) => {
447
- const a = Math.atan2(t, e), s = Math.sqrt(e * e + t * t);
448
- let i = [];
449
- switch (r) {
450
- case w.Analogous:
451
- i = [0, -30, 30, -60, 60];
188
+ }, Q = (t, n, e, o) => {
189
+ const r = Math.atan2(n, t), a = Math.sqrt(t * t + n * n);
190
+ let s = [];
191
+ switch (e) {
192
+ case x.Analogous:
193
+ s = [0, -30, 30, -60, 60];
452
194
  break;
453
- case w.Monochromatic:
454
- i = [0];
195
+ case x.Monochromatic:
196
+ s = [0];
455
197
  break;
456
- case w.Triad:
457
- i = [0, 120, 240];
198
+ case x.Triad:
199
+ s = [0, 120, 240];
458
200
  break;
459
- case w.Complementary:
460
- i = [0, 180];
201
+ case x.Complementary:
202
+ s = [0, 180];
461
203
  break;
462
- case w.SplitComplementary:
463
- i = [0, 150, 210];
204
+ case x.SplitComplementary:
205
+ s = [0, 150, 210];
464
206
  break;
465
- case w.Square:
466
- i = [0, 90, 180, 270];
207
+ case x.Square:
208
+ s = [0, 90, 180, 270];
467
209
  break;
468
- case w.Compound:
469
- i = [0, 180, 30, 210, 60];
210
+ case x.Compound:
211
+ s = [0, 180, 30, 210, 60];
470
212
  break;
471
- case w.Custom:
213
+ case x.Custom:
472
214
  default:
473
215
  return null;
474
216
  }
475
- const d = i.length, _ = 0.25, m = [];
217
+ const f = s.length, m = 0.25, p = [];
476
218
  for (let h = 0; h < o; h++) {
477
- const N = Math.floor(h / d), c = h % d, l = i[c], f = a + l * Math.PI / 180;
478
- let p = s;
479
- r === w.Monochromatic ? (p = s * (1 - h * 0.15), p < 0 && (p = 0)) : (p = s * (1 - N * _), p < 0 && (p = 0)), m.push({
480
- x: Math.cos(f) * p,
481
- y: Math.sin(f) * p
219
+ const R = Math.floor(h / f), l = h % f, i = s[l], c = r + i * Math.PI / 180;
220
+ let u = a;
221
+ e === x.Monochromatic ? (u = a * (1 - h * 0.15), u < 0 && (u = 0)) : (u = a * (1 - R * m), u < 0 && (u = 0)), p.push({
222
+ x: Math.cos(c) * u,
223
+ y: Math.sin(c) * u
482
224
  });
483
225
  }
484
- return m;
485
- }, $e = (e, t) => {
486
- const r = t, o = t, a = e.createConicGradient(Math.PI * 1.5, r, o);
487
- a.addColorStop(0, "#FFFF00"), a.addColorStop(0.19, "#FF0000"), a.addColorStop(0.36, "#FF00FF"), a.addColorStop(0.5, "#0000FF"), a.addColorStop(0.64, "#00FFFF"), a.addColorStop(0.78, "#00FF00"), a.addColorStop(1, "#FFFF00"), e.fillStyle = a, e.beginPath(), e.arc(r, o, t, 0, Math.PI * 2), e.fill();
488
- const s = e.createRadialGradient(r, o, 0, r, o, t);
489
- s.addColorStop(0, "#ffffff"), s.addColorStop(0.2, "rgba(255, 255, 255, 0.8)"), s.addColorStop(0.6, "rgba(255, 255, 255, 0.2)"), s.addColorStop(1, "rgba(255, 255, 255, 0)"), e.fillStyle = s, e.beginPath(), e.arc(r, o, t, 0, Math.PI * 2), e.fill();
490
- }, Ye = (e, t, r) => {
491
- const o = Math.sqrt(e * e + t * t), a = r - 1;
492
- if (o > a) {
493
- const s = a / o;
494
- return { x: e * s, y: t * s };
226
+ return p;
227
+ }, dt = (t, n) => {
228
+ const e = n, o = n, r = t.createConicGradient(Math.PI * 1.5, e, o);
229
+ r.addColorStop(0, "#FFFF00"), r.addColorStop(0.19, "#FF0000"), r.addColorStop(0.36, "#FF00FF"), r.addColorStop(0.5, "#0000FF"), r.addColorStop(0.64, "#00FFFF"), r.addColorStop(0.78, "#00FF00"), r.addColorStop(1, "#FFFF00"), t.fillStyle = r, t.beginPath(), t.arc(e, o, n, 0, Math.PI * 2), t.fill();
230
+ const a = t.createRadialGradient(e, o, 0, e, o, n);
231
+ a.addColorStop(0, "#ffffff"), a.addColorStop(0.2, "rgba(255, 255, 255, 0.8)"), a.addColorStop(0.6, "rgba(255, 255, 255, 0.2)"), a.addColorStop(1, "rgba(255, 255, 255, 0)"), t.fillStyle = a, t.beginPath(), t.arc(e, o, n, 0, Math.PI * 2), t.fill();
232
+ }, pt = (t, n, e) => {
233
+ const o = Math.sqrt(t * t + n * n), r = e - 1;
234
+ if (o > r) {
235
+ const a = r / o;
236
+ return { x: t * a, y: n * a };
495
237
  }
496
- return { x: e, y: t };
497
- }, qe = ({
498
- radius: e = 150,
499
- onChange: t,
500
- quantityOfColors: r = 5,
501
- harmony: o = w.Monochromatic
238
+ return { x: t, y: n };
239
+ }, vt = ({
240
+ radius: t = 150,
241
+ onChange: n,
242
+ quantityOfColors: e = 5,
243
+ harmony: o = x.Monochromatic
502
244
  }) => {
503
- const a = Q(null), s = Q(null), [i, d] = Re([]), _ = Q([]), m = K((c, l) => {
504
- const f = a.current;
505
- if (!f) return "#ffffff";
506
- const p = f.getContext("2d");
507
- if (!p) return "#ffffff";
508
- const y = window.devicePixelRatio || 1, x = c + e, P = l + e, j = Math.floor(x * y), k = Math.floor(P * y), R = p.getImageData(j, k, 1, 1).data;
509
- return C({ r: R[0], g: R[1], b: R[2], a: R[3] / 255 }).toHex();
510
- }, [e]);
511
- le(() => {
512
- const c = a.current;
513
- if (!c) return;
514
- const l = c.getContext("2d", { willReadFrequently: !0 });
245
+ const r = k(null), a = k(null), [s, f] = Z([]), m = k([]), p = A((l, i) => {
246
+ const c = r.current;
247
+ if (!c) return "#ffffff";
248
+ const u = c.getContext("2d");
249
+ if (!u) return "#ffffff";
250
+ const v = window.devicePixelRatio || 1, g = l + t, y = i + t, N = Math.floor(g * v), P = Math.floor(y * v), b = u.getImageData(N, P, 1, 1).data;
251
+ return C({ r: b[0], g: b[1], b: b[2], a: b[3] / 255 }).toHex();
252
+ }, [t]);
253
+ G(() => {
254
+ const l = r.current;
515
255
  if (!l) return;
516
- const f = window.devicePixelRatio || 1, p = e * 2;
517
- c.width = p * f, c.height = p * f, c.style.width = `${p}px`, c.style.height = `${p}px`, l.scale(f, f), $e(l, e);
518
- }, [e]), le(() => {
519
- let c;
520
- if (i.length > 0) {
521
- const l = i[0];
522
- c = xe(l.x, l.y, o, r);
256
+ const i = l.getContext("2d", { willReadFrequently: !0 });
257
+ if (!i) return;
258
+ const c = window.devicePixelRatio || 1, u = t * 2;
259
+ l.width = u * c, l.height = u * c, l.style.width = `${u}px`, l.style.height = `${u}px`, i.scale(c, c), dt(i, t);
260
+ }, [t]), G(() => {
261
+ let l;
262
+ if (s.length > 0) {
263
+ const i = s[0];
264
+ l = Q(i.x, i.y, o, e);
523
265
  }
524
- if (!c) {
525
- const l = e * 0.5;
526
- o !== w.Custom ? c = xe(l, 0, o, r) : c = Array.from({ length: r }).map((p, y) => {
527
- const x = y / r * 2 * Math.PI;
528
- return { x: Math.cos(x) * e * 0.6, y: Math.sin(x) * e * 0.6 };
266
+ if (!l) {
267
+ const i = t * 0.5;
268
+ o !== x.Custom ? l = Q(i, 0, o, e) : l = Array.from({ length: e }).map((u, v) => {
269
+ const g = v / e * 2 * Math.PI;
270
+ return { x: Math.cos(g) * t * 0.6, y: Math.sin(g) * t * 0.6 };
529
271
  });
530
272
  }
531
- if (c) {
532
- const l = c.map((f, p) => ({
533
- id: p,
534
- x: f.x,
535
- y: f.y,
536
- color: m(f.x, f.y)
273
+ if (l) {
274
+ const i = l.map((c, u) => ({
275
+ id: u,
276
+ x: c.x,
277
+ y: c.y,
278
+ color: p(c.x, c.y)
537
279
  }));
538
- if (l.length > 0 && o !== w.Custom) {
539
- const f = Math.atan2(l[0].y, l[0].x), p = Math.sqrt(l[0].x * l[0].x + l[0].y * l[0].y);
540
- _.current = l.map((y) => {
541
- const x = Math.atan2(y.y, y.x), P = Math.sqrt(y.x * y.x + y.y * y.y);
280
+ if (i.length > 0 && o !== x.Custom) {
281
+ const c = Math.atan2(i[0].y, i[0].x), u = Math.sqrt(i[0].x * i[0].x + i[0].y * i[0].y);
282
+ m.current = i.map((v) => {
283
+ const g = Math.atan2(v.y, v.x), y = Math.sqrt(v.x * v.x + v.y * v.y);
542
284
  return {
543
- angleOffset: x - f,
544
- distanceRatio: p > 0 ? P / p : 1
285
+ angleOffset: g - c,
286
+ distanceRatio: u > 0 ? y / u : 1
545
287
  };
546
288
  });
547
289
  }
548
- d(l), t && t(l);
290
+ f(i), n && n(i);
549
291
  }
550
- }, [o, r, m]);
551
- const h = K(
552
- (c, l, f) => {
553
- const p = s.current;
554
- if (!p) return;
555
- const y = p.getBoundingClientRect();
556
- let x = c - y.left - e, P = l - y.top - e;
557
- const j = Ye(x, P, e);
558
- if (x = j.x, P = j.y, o === w.Custom) {
559
- const k = m(x, P), R = [...i];
560
- R[f] = { ...R[f], x, y: P, color: k }, d(R), t && t(R);
292
+ }, [o, e, p]);
293
+ const h = A(
294
+ (l, i, c) => {
295
+ const u = a.current;
296
+ if (!u) return;
297
+ const v = u.getBoundingClientRect();
298
+ let g = l - v.left - t, y = i - v.top - t;
299
+ const N = pt(g, y, t);
300
+ if (g = N.x, y = N.y, o === x.Custom) {
301
+ const P = p(g, y), b = [...s];
302
+ b[c] = { ...b[c], x: g, y, color: P }, f(b), n && n(b);
561
303
  return;
562
304
  }
563
- if (_.current.length > 0 && _.current[f]) {
564
- const k = Math.atan2(P, x), R = _.current[f], V = k - R.angleOffset, q = i.map((A, O) => {
565
- if (O === f)
566
- return { ...A, x, y: P, color: m(x, P) };
567
- const H = Math.sqrt(A.x * A.x + A.y * A.y), G = _.current[O], F = V + G.angleOffset, D = Math.cos(F) * H, L = Math.sin(F) * H;
305
+ if (m.current.length > 0 && m.current[c]) {
306
+ const P = Math.atan2(y, g), b = m.current[c], et = P - b.angleOffset, q = s.map((F, Y) => {
307
+ if (Y === c)
308
+ return { ...F, x: g, y, color: p(g, y) };
309
+ const X = Math.sqrt(F.x * F.x + F.y * F.y), ot = m.current[Y], E = et + ot.angleOffset, W = Math.cos(E) * X, z = Math.sin(E) * X;
568
310
  return {
569
- ...A,
570
- x: D,
571
- y: L,
572
- color: m(D, L)
311
+ ...F,
312
+ x: W,
313
+ y: z,
314
+ color: p(W, z)
573
315
  };
574
316
  });
575
- d(q), t && t(q);
317
+ f(q), n && n(q);
576
318
  } else {
577
- const k = m(x, P), R = [...i];
578
- R[f] = { ...R[f], x, y: P, color: k }, d(R), t && t(R);
319
+ const P = p(g, y), b = [...s];
320
+ b[c] = { ...b[c], x: g, y, color: P }, f(b), n && n(b);
579
321
  }
580
322
  },
581
- [e, m, t, i, o]
582
- ), N = K((c) => ({
583
- onPointerDown: (l) => {
584
- h(l.clientX, l.clientY, c);
323
+ [t, p, n, s, o]
324
+ ), R = A((l) => ({
325
+ onPointerDown: (i) => {
326
+ h(i.clientX, i.clientY, l);
585
327
  },
586
- onPointerMove: (l) => {
587
- h(l.clientX, l.clientY, c);
328
+ onPointerMove: (i) => {
329
+ h(i.clientX, i.clientY, l);
588
330
  },
589
331
  onPointerUp: () => {
590
332
  }
591
333
  }), [h]);
592
- return /* @__PURE__ */ M.jsx("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 20 }, children: /* @__PURE__ */ M.jsxs(
334
+ return /* @__PURE__ */ S("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 20 }, children: /* @__PURE__ */ rt(
593
335
  "div",
594
336
  {
595
- ref: s,
337
+ ref: a,
596
338
  style: {
597
- width: e * 2,
598
- height: e * 2,
339
+ width: t * 2,
340
+ height: t * 2,
599
341
  position: "relative",
600
342
  touchAction: "none"
601
343
  },
602
344
  children: [
603
- /* @__PURE__ */ M.jsx("canvas", { ref: a, style: { borderRadius: "50%", display: "block" } }),
604
- /* @__PURE__ */ M.jsx(
345
+ /* @__PURE__ */ S("canvas", { ref: r, style: { borderRadius: "50%", display: "block" } }),
346
+ /* @__PURE__ */ S(
605
347
  "svg",
606
348
  {
607
349
  style: {
@@ -613,33 +355,33 @@ const De = ({
613
355
  pointerEvents: "none",
614
356
  zIndex: 1
615
357
  },
616
- children: i.map((c) => /* @__PURE__ */ M.jsx(
358
+ children: s.map((l) => /* @__PURE__ */ S(
617
359
  "line",
618
360
  {
619
- x1: e,
620
- y1: e,
621
- x2: e + c.x,
622
- y2: e + c.y,
361
+ x1: t,
362
+ y1: t,
363
+ x2: t + l.x,
364
+ y2: t + l.y,
623
365
  stroke: "white",
624
366
  strokeWidth: "2",
625
367
  style: { filter: "drop-shadow(0px 1px 1px rgba(0,0,0,0.3))" }
626
368
  },
627
- c.id
369
+ l.id
628
370
  ))
629
371
  }
630
372
  ),
631
- i.map((c, l) => {
632
- const f = N(l);
633
- return /* @__PURE__ */ M.jsx(
634
- De,
373
+ s.map((l, i) => {
374
+ const c = R(i);
375
+ return /* @__PURE__ */ S(
376
+ ht,
635
377
  {
636
- cursorPos: { x: c.x, y: c.y },
637
- hexColor: c.color,
638
- onPointerDown: f.onPointerDown,
639
- onPointerMove: f.onPointerMove,
640
- onPointerUp: f.onPointerUp
378
+ cursorPos: { x: l.x, y: l.y },
379
+ hexColor: l.color,
380
+ onPointerDown: c.onPointerDown,
381
+ onPointerMove: c.onPointerMove,
382
+ onPointerUp: c.onPointerUp
641
383
  },
642
- c.id
384
+ l.id
643
385
  );
644
386
  })
645
387
  ]
@@ -647,6 +389,6 @@ const De = ({
647
389
  ) });
648
390
  };
649
391
  export {
650
- qe as ColorWheel,
651
- w as HarmonyType
392
+ vt as ColorWheel,
393
+ x as HarmonyType
652
394
  };
@@ -1,6 +1 @@
1
- (function(A,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],_):(A=typeof globalThis<"u"?globalThis:A||self,_(A.ReactColorPaletteWheel={},A.React))})(this,(function(A,_){"use strict";var X={exports:{}},W={};var ne;function _e(){if(ne)return W;ne=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(o,a,s){var i=null;if(s!==void 0&&(i=""+s),a.key!==void 0&&(i=""+a.key),"key"in a){s={};for(var d in a)d!=="key"&&(s[d]=a[d])}else s=a;return a=s.ref,{$$typeof:e,type:o,key:i,ref:a!==void 0?a:null,props:s}}return W.Fragment=t,W.jsx=r,W.jsxs=r,W}var H={};var oe;function Pe(){return oe||(oe=1,process.env.NODE_ENV!=="production"&&(function(){function e(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===K?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case R:return"Fragment";case w:return"Profiler";case x:return"StrictMode";case Q:return"Suspense";case V:return"SuspenseList";case G:return"Activity"}if(typeof n=="object")switch(typeof n.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),n.$$typeof){case p:return"Portal";case M:return n.displayName||"Context";case F:return(n._context.displayName||"Context")+".Consumer";case E:var u=n.render;return n=n.displayName,n||(n=u.displayName||u.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case N:return u=n.displayName||null,u!==null?u:e(n.type)||"Memo";case I:u=n._payload,n=n._init;try{return e(n(u))}catch{}}return null}function t(n){return""+n}function r(n){try{t(n);var u=!1}catch{u=!0}if(u){u=console;var b=u.error,g=typeof Symbol=="function"&&Symbol.toStringTag&&n[Symbol.toStringTag]||n.constructor.name||"Object";return b.call(u,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",g),t(n)}}function o(n){if(n===R)return"<>";if(typeof n=="object"&&n!==null&&n.$$typeof===I)return"<...>";try{var u=e(n);return u?"<"+u+">":"<...>"}catch{return"<...>"}}function a(){var n=D.A;return n===null?null:n.getOwner()}function s(){return Error("react-stack-top-frame")}function i(n){if(z.call(n,"key")){var u=Object.getOwnPropertyDescriptor(n,"key").get;if(u&&u.isReactWarning)return!1}return n.key!==void 0}function d(n,u){function b(){me||(me=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",u))}b.isReactWarning=!0,Object.defineProperty(n,"key",{get:b,configurable:!0})}function P(){var n=e(this.type);return ye[n]||(ye[n]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),n=this.props.ref,n!==void 0?n:null}function y(n,u,b,g,$,te){var v=b.ref;return n={$$typeof:f,type:n,key:u,props:b,_owner:g},(v!==void 0?v:null)!==null?Object.defineProperty(n,"ref",{enumerable:!1,get:P}):Object.defineProperty(n,"ref",{enumerable:!1,value:null}),n._store={},Object.defineProperty(n._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(n,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(n,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:$}),Object.defineProperty(n,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.freeze&&(Object.freeze(n.props),Object.freeze(n)),n}function h(n,u,b,g,$,te){var v=u.children;if(v!==void 0)if(g)if(J(v)){for(g=0;g<v.length;g++)O(v[g]);Object.freeze&&Object.freeze(v)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else O(v);if(z.call(u,"key")){v=e(n);var Y=Object.keys(u).filter(function(De){return De!=="key"});g=0<Y.length?"{key: someKey, "+Y.join(": ..., ")+": ...}":"{key: someKey}",Ee[v+g]||(Y=0<Y.length?"{"+Y.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
- let props = %s;
3
- <%s {...props} />
4
- React keys must be passed directly to JSX without using spread:
5
- let props = %s;
6
- <%s key={someKey} {...props} />`,g,v,Y,v),Ee[v+g]=!0)}if(v=null,b!==void 0&&(r(b),v=""+b),i(u)&&(r(u.key),v=""+u.key),"key"in u){b={};for(var re in u)re!=="key"&&(b[re]=u[re])}else b=u;return v&&d(b,typeof n=="function"?n.displayName||n.name||"Unknown":n),y(n,v,b,a(),$,te)}function O(n){c(n)?n._store&&(n._store.validated=1):typeof n=="object"&&n!==null&&n.$$typeof===I&&(n._payload.status==="fulfilled"?c(n._payload.value)&&n._payload.value._store&&(n._payload.value._store.validated=1):n._store&&(n._store.validated=1))}function c(n){return typeof n=="object"&&n!==null&&n.$$typeof===f}var l=_,f=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),F=Symbol.for("react.consumer"),M=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),Q=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),G=Symbol.for("react.activity"),K=Symbol.for("react.client.reference"),D=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,J=Array.isArray,ee=console.createTask?console.createTask:function(){return null};l={react_stack_bottom_frame:function(n){return n()}};var me,ye={},Re=l.react_stack_bottom_frame.bind(l,s)(),xe=ee(o(s)),Ee={};H.Fragment=R,H.jsx=function(n,u,b){var g=1e4>D.recentlyCreatedOwnerStacks++;return h(n,u,b,!1,g?Error("react-stack-top-frame"):Re,g?ee(o(n)):xe)},H.jsxs=function(n,u,b){var g=1e4>D.recentlyCreatedOwnerStacks++;return h(n,u,b,!0,g?Error("react-stack-top-frame"):Re,g?ee(o(n)):xe)}})()),H}var ae;function we(){return ae||(ae=1,process.env.NODE_ENV==="production"?X.exports=_e():X.exports=Pe()),X.exports}var j=we(),Se={grad:.9,turn:360,rad:360/(2*Math.PI)},k=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},m=function(e,t,r){return t===void 0&&(t=0),r===void 0&&(r=Math.pow(10,t)),Math.round(r*e)/r+0},C=function(e,t,r){return t===void 0&&(t=0),r===void 0&&(r=1),e>r?r:e>t?e:t},se=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},ie=function(e){return{r:C(e.r,0,255),g:C(e.g,0,255),b:C(e.b,0,255),a:C(e.a)}},q=function(e){return{r:m(e.r),g:m(e.g),b:m(e.b),a:m(e.a,3)}},Ce=/^#([0-9a-f]{3,8})$/i,U=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},le=function(e){var t=e.r,r=e.g,o=e.b,a=e.a,s=Math.max(t,r,o),i=s-Math.min(t,r,o),d=i?s===t?(r-o)/i:s===r?2+(o-t)/i:4+(t-r)/i:0;return{h:60*(d<0?d+6:d),s:s?i/s*100:0,v:s/255*100,a}},ue=function(e){var t=e.h,r=e.s,o=e.v,a=e.a;t=t/360*6,r/=100,o/=100;var s=Math.floor(t),i=o*(1-r),d=o*(1-(t-s)*r),P=o*(1-(1-t+s)*r),y=s%6;return{r:255*[o,d,i,i,P,o][y],g:255*[P,o,o,d,i,i][y],b:255*[i,i,P,o,o,d][y],a}},ce=function(e){return{h:se(e.h),s:C(e.s,0,100),l:C(e.l,0,100),a:C(e.a)}},fe=function(e){return{h:m(e.h),s:m(e.s),l:m(e.l),a:m(e.a,3)}},de=function(e){return ue((r=(t=e).s,{h:t.h,s:(r*=((o=t.l)<50?o:100-o)/100)>0?2*r/(o+r)*100:0,v:o+r,a:t.a}));var t,r,o},L=function(e){return{h:(t=le(e)).h,s:(a=(200-(r=t.s))*(o=t.v)/100)>0&&a<200?r*o/100/(a<=100?a:200-a)*100:0,l:a/2,a:t.a};var t,r,o,a},Te=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ke=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Me=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ae=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,pe={string:[[function(e){var t=Ce.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?m(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?m(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=Me.exec(e)||Ae.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:ie({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=Te.exec(e)||ke.exec(e);if(!t)return null;var r,o,a=ce({h:(r=t[1],o=t[2],o===void 0&&(o="deg"),Number(r)*(Se[o]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return de(a)},"hsl"]],object:[[function(e){var t=e.r,r=e.g,o=e.b,a=e.a,s=a===void 0?1:a;return k(t)&&k(r)&&k(o)?ie({r:Number(t),g:Number(r),b:Number(o),a:Number(s)}):null},"rgb"],[function(e){var t=e.h,r=e.s,o=e.l,a=e.a,s=a===void 0?1:a;if(!k(t)||!k(r)||!k(o))return null;var i=ce({h:Number(t),s:Number(r),l:Number(o),a:Number(s)});return de(i)},"hsl"],[function(e){var t=e.h,r=e.s,o=e.v,a=e.a,s=a===void 0?1:a;if(!k(t)||!k(r)||!k(o))return null;var i=(function(d){return{h:se(d.h),s:C(d.s,0,100),v:C(d.v,0,100),a:C(d.a)}})({h:Number(t),s:Number(r),v:Number(o),a:Number(s)});return ue(i)},"hsv"]]},he=function(e,t){for(var r=0;r<t.length;r++){var o=t[r][0](e);if(o)return[o,t[r][1]]}return[null,void 0]},Ne=function(e){return typeof e=="string"?he(e.trim(),pe.string):typeof e=="object"&&e!==null?he(e,pe.object):[null,void 0]},B=function(e,t){var r=L(e);return{h:r.h,s:C(r.s+100*t,0,100),l:r.l,a:r.a}},Z=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},be=function(e,t){var r=L(e);return{h:r.h,s:r.s,l:C(r.l+100*t,0,100),a:r.a}},ge=(function(){function e(t){this.parsed=Ne(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return m(Z(this.rgba),2)},e.prototype.isDark=function(){return Z(this.rgba)<.5},e.prototype.isLight=function(){return Z(this.rgba)>=.5},e.prototype.toHex=function(){return t=q(this.rgba),r=t.r,o=t.g,a=t.b,i=(s=t.a)<1?U(m(255*s)):"","#"+U(r)+U(o)+U(a)+i;var t,r,o,a,s,i},e.prototype.toRgb=function(){return q(this.rgba)},e.prototype.toRgbString=function(){return t=q(this.rgba),r=t.r,o=t.g,a=t.b,(s=t.a)<1?"rgba("+r+", "+o+", "+a+", "+s+")":"rgb("+r+", "+o+", "+a+")";var t,r,o,a,s},e.prototype.toHsl=function(){return fe(L(this.rgba))},e.prototype.toHslString=function(){return t=fe(L(this.rgba)),r=t.h,o=t.s,a=t.l,(s=t.a)<1?"hsla("+r+", "+o+"%, "+a+"%, "+s+")":"hsl("+r+", "+o+"%, "+a+"%)";var t,r,o,a,s},e.prototype.toHsv=function(){return t=le(this.rgba),{h:m(t.h),s:m(t.s),v:m(t.v),a:m(t.a,3)};var t},e.prototype.invert=function(){return T({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=.1),T(B(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),T(B(this.rgba,-t))},e.prototype.grayscale=function(){return T(B(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),T(be(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),T(be(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?T({r:(r=this.rgba).r,g:r.g,b:r.b,a:t}):m(this.rgba.a,3);var r},e.prototype.hue=function(t){var r=L(this.rgba);return typeof t=="number"?T({h:t,s:r.s,l:r.l,a:r.a}):m(r.h)},e.prototype.isEqual=function(t){return this.toHex()===T(t).toHex()},e})(),T=function(e){return e instanceof ge?e:new ge(e)};const je=({hexColor:e,cursorPos:t,onPointerDown:r,onPointerMove:o,onPointerUp:a})=>{const[s,i]=_.useState(!1),d=h=>{i(!0),r(h),h.currentTarget.setPointerCapture(h.pointerId)},P=h=>{s&&o(h)},y=h=>{i(!1),a(h),h.currentTarget.releasePointerCapture(h.pointerId)};return j.jsx("div",{style:{position:"absolute",width:24,height:24,borderRadius:"50%",border:"2px solid white",boxShadow:"0 2px 4px rgba(0,0,0,0.3)",backgroundColor:e,left:"50%",top:"50%",transform:`translate(calc(-50% + ${t.x}px), calc(-50% + ${t.y}px))`,pointerEvents:"auto",cursor:s?"grabbing":"grab",willChange:"transform",zIndex:10},onPointerDown:d,onPointerMove:P,onPointerUp:y})},S={Custom:"Custom",Analogous:"Analogous",Monochromatic:"Monochromatic",Triad:"Triad",Complementary:"Complementary",SplitComplementary:"SplitComplementary",Square:"Square",Compound:"Compound"},ve=(e,t,r,o)=>{const a=Math.atan2(t,e),s=Math.sqrt(e*e+t*t);let i=[];switch(r){case S.Analogous:i=[0,-30,30,-60,60];break;case S.Monochromatic:i=[0];break;case S.Triad:i=[0,120,240];break;case S.Complementary:i=[0,180];break;case S.SplitComplementary:i=[0,150,210];break;case S.Square:i=[0,90,180,270];break;case S.Compound:i=[0,180,30,210,60];break;case S.Custom:default:return null}const d=i.length,P=.25,y=[];for(let h=0;h<o;h++){const O=Math.floor(h/d),c=h%d,l=i[c],f=a+l*Math.PI/180;let p=s;r===S.Monochromatic?(p=s*(1-h*.15),p<0&&(p=0)):(p=s*(1-O*P),p<0&&(p=0)),y.push({x:Math.cos(f)*p,y:Math.sin(f)*p})}return y},Oe=(e,t)=>{const r=t,o=t,a=e.createConicGradient(Math.PI*1.5,r,o);a.addColorStop(0,"#FFFF00"),a.addColorStop(.19,"#FF0000"),a.addColorStop(.36,"#FF00FF"),a.addColorStop(.5,"#0000FF"),a.addColorStop(.64,"#00FFFF"),a.addColorStop(.78,"#00FF00"),a.addColorStop(1,"#FFFF00"),e.fillStyle=a,e.beginPath(),e.arc(r,o,t,0,Math.PI*2),e.fill();const s=e.createRadialGradient(r,o,0,r,o,t);s.addColorStop(0,"#ffffff"),s.addColorStop(.2,"rgba(255, 255, 255, 0.8)"),s.addColorStop(.6,"rgba(255, 255, 255, 0.2)"),s.addColorStop(1,"rgba(255, 255, 255, 0)"),e.fillStyle=s,e.beginPath(),e.arc(r,o,t,0,Math.PI*2),e.fill()},Fe=(e,t,r)=>{const o=Math.sqrt(e*e+t*t),a=r-1;if(o>a){const s=a/o;return{x:e*s,y:t*s}}return{x:e,y:t}},Ie=({radius:e=150,onChange:t,quantityOfColors:r=5,harmony:o=S.Monochromatic})=>{const a=_.useRef(null),s=_.useRef(null),[i,d]=_.useState([]),P=_.useRef([]),y=_.useCallback((c,l)=>{const f=a.current;if(!f)return"#ffffff";const p=f.getContext("2d");if(!p)return"#ffffff";const R=window.devicePixelRatio||1,x=c+e,w=l+e,F=Math.floor(x*R),M=Math.floor(w*R),E=p.getImageData(F,M,1,1).data;return T({r:E[0],g:E[1],b:E[2],a:E[3]/255}).toHex()},[e]);_.useEffect(()=>{const c=a.current;if(!c)return;const l=c.getContext("2d",{willReadFrequently:!0});if(!l)return;const f=window.devicePixelRatio||1,p=e*2;c.width=p*f,c.height=p*f,c.style.width=`${p}px`,c.style.height=`${p}px`,l.scale(f,f),Oe(l,e)},[e]),_.useEffect(()=>{let c;if(i.length>0){const l=i[0];c=ve(l.x,l.y,o,r)}if(!c){const l=e*.5;o!==S.Custom?c=ve(l,0,o,r):c=Array.from({length:r}).map((p,R)=>{const x=R/r*2*Math.PI;return{x:Math.cos(x)*e*.6,y:Math.sin(x)*e*.6}})}if(c){const l=c.map((f,p)=>({id:p,x:f.x,y:f.y,color:y(f.x,f.y)}));if(l.length>0&&o!==S.Custom){const f=Math.atan2(l[0].y,l[0].x),p=Math.sqrt(l[0].x*l[0].x+l[0].y*l[0].y);P.current=l.map(R=>{const x=Math.atan2(R.y,R.x),w=Math.sqrt(R.x*R.x+R.y*R.y);return{angleOffset:x-f,distanceRatio:p>0?w/p:1}})}d(l),t&&t(l)}},[o,r,y]);const h=_.useCallback((c,l,f)=>{const p=s.current;if(!p)return;const R=p.getBoundingClientRect();let x=c-R.left-e,w=l-R.top-e;const F=Fe(x,w,e);if(x=F.x,w=F.y,o===S.Custom){const M=y(x,w),E=[...i];E[f]={...E[f],x,y:w,color:M},d(E),t&&t(E);return}if(P.current.length>0&&P.current[f]){const M=Math.atan2(w,x),E=P.current[f],Q=M-E.angleOffset,V=i.map((N,I)=>{if(I===f)return{...N,x,y:w,color:y(x,w)};const G=Math.sqrt(N.x*N.x+N.y*N.y),K=P.current[I],D=Q+K.angleOffset,z=Math.cos(D)*G,J=Math.sin(D)*G;return{...N,x:z,y:J,color:y(z,J)}});d(V),t&&t(V)}else{const M=y(x,w),E=[...i];E[f]={...E[f],x,y:w,color:M},d(E),t&&t(E)}},[e,y,t,i,o]),O=_.useCallback(c=>({onPointerDown:l=>{h(l.clientX,l.clientY,c)},onPointerMove:l=>{h(l.clientX,l.clientY,c)},onPointerUp:()=>{}}),[h]);return j.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:20},children:j.jsxs("div",{ref:s,style:{width:e*2,height:e*2,position:"relative",touchAction:"none"},children:[j.jsx("canvas",{ref:a,style:{borderRadius:"50%",display:"block"}}),j.jsx("svg",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1},children:i.map(c=>j.jsx("line",{x1:e,y1:e,x2:e+c.x,y2:e+c.y,stroke:"white",strokeWidth:"2",style:{filter:"drop-shadow(0px 1px 1px rgba(0,0,0,0.3))"}},c.id))}),i.map((c,l)=>{const f=O(l);return j.jsx(je,{cursorPos:{x:c.x,y:c.y},hexColor:c.color,onPointerDown:f.onPointerDown,onPointerMove:f.onPointerMove,onPointerUp:f.onPointerUp},c.id)})]})})};A.ColorWheel=Ie,A.HarmonyType=S,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(S,M){typeof exports=="object"&&typeof module<"u"?M(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],M):(S=typeof globalThis<"u"?globalThis:S||self,M(S.ReactColorPaletteWheel={},S.jsxRuntime,S.React))})(this,(function(S,M,P){"use strict";var tt={grad:.9,turn:360,rad:360/(2*Math.PI)},F=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},d=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},C=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},q=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},W=function(t){return{r:C(t.r,0,255),g:C(t.g,0,255),b:C(t.b,0,255),a:C(t.a)}},A=function(t){return{r:d(t.r),g:d(t.g),b:d(t.b),a:d(t.a,3)}},et=/^#([0-9a-f]{3,8})$/i,k=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Y=function(t){var e=t.r,n=t.g,o=t.b,r=t.a,a=Math.max(e,n,o),s=a-Math.min(e,n,o),f=s?a===e?(n-o)/s:a===n?2+(o-e)/s:4+(e-n)/s:0;return{h:60*(f<0?f+6:f),s:a?s/a*100:0,v:a/255*100,a:r}},E=function(t){var e=t.h,n=t.s,o=t.v,r=t.a;e=e/360*6,n/=100,o/=100;var a=Math.floor(e),s=o*(1-n),f=o*(1-(e-a)*n),m=o*(1-(1-e+a)*n),p=a%6;return{r:255*[o,f,s,s,m,o][p],g:255*[m,o,o,f,s,s][p],b:255*[s,s,m,o,o,f][p],a:r}},T=function(t){return{h:q(t.h),s:C(t.s,0,100),l:C(t.l,0,100),a:C(t.a)}},X=function(t){return{h:d(t.h),s:d(t.s),l:d(t.l),a:d(t.a,3)}},z=function(t){return E((n=(e=t).s,{h:e.h,s:(n*=((o=e.l)<50?o:100-o)/100)>0?2*n/(o+n)*100:0,v:o+n,a:e.a}));var e,n,o},D=function(t){return{h:(e=Y(t)).h,s:(r=(200-(n=e.s))*(o=e.v)/100)>0&&r<200?n*o/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,n,o,r},nt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ot=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,at=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,G={string:[[function(t){var e=et.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?d(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?d(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=rt.exec(t)||at.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:W({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=nt.exec(t)||ot.exec(t);if(!e)return null;var n,o,r=T({h:(n=e[1],o=e[2],o===void 0&&(o="deg"),Number(n)*(tt[o]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return z(r)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,o=t.b,r=t.a,a=r===void 0?1:r;return F(e)&&F(n)&&F(o)?W({r:Number(e),g:Number(n),b:Number(o),a:Number(a)}):null},"rgb"],[function(t){var e=t.h,n=t.s,o=t.l,r=t.a,a=r===void 0?1:r;if(!F(e)||!F(n)||!F(o))return null;var s=T({h:Number(e),s:Number(n),l:Number(o),a:Number(a)});return z(s)},"hsl"],[function(t){var e=t.h,n=t.s,o=t.v,r=t.a,a=r===void 0?1:r;if(!F(e)||!F(n)||!F(o))return null;var s=(function(f){return{h:q(f.h),s:C(f.s,0,100),v:C(f.v,0,100),a:C(f.a)}})({h:Number(e),s:Number(n),v:Number(o),a:Number(a)});return E(s)},"hsv"]]},L=function(t,e){for(var n=0;n<e.length;n++){var o=e[n][0](t);if(o)return[o,e[n][1]]}return[null,void 0]},st=function(t){return typeof t=="string"?L(t.trim(),G.string):typeof t=="object"&&t!==null?L(t,G.object):[null,void 0]},H=function(t,e){var n=D(t);return{h:n.h,s:C(n.s+100*e,0,100),l:n.l,a:n.a}},j=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},O=function(t,e){var n=D(t);return{h:n.h,s:n.s,l:C(n.l+100*e,0,100),a:n.a}},B=(function(){function t(e){this.parsed=st(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return d(j(this.rgba),2)},t.prototype.isDark=function(){return j(this.rgba)<.5},t.prototype.isLight=function(){return j(this.rgba)>=.5},t.prototype.toHex=function(){return e=A(this.rgba),n=e.r,o=e.g,r=e.b,s=(a=e.a)<1?k(d(255*a)):"","#"+k(n)+k(o)+k(r)+s;var e,n,o,r,a,s},t.prototype.toRgb=function(){return A(this.rgba)},t.prototype.toRgbString=function(){return e=A(this.rgba),n=e.r,o=e.g,r=e.b,(a=e.a)<1?"rgba("+n+", "+o+", "+r+", "+a+")":"rgb("+n+", "+o+", "+r+")";var e,n,o,r,a},t.prototype.toHsl=function(){return X(D(this.rgba))},t.prototype.toHslString=function(){return e=X(D(this.rgba)),n=e.h,o=e.s,r=e.l,(a=e.a)<1?"hsla("+n+", "+o+"%, "+r+"%, "+a+")":"hsl("+n+", "+o+"%, "+r+"%)";var e,n,o,r,a},t.prototype.toHsv=function(){return e=Y(this.rgba),{h:d(e.h),s:d(e.s),v:d(e.v),a:d(e.a,3)};var e},t.prototype.invert=function(){return w({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),w(H(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),w(H(this.rgba,-e))},t.prototype.grayscale=function(){return w(H(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),w(O(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),w(O(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?w({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):d(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=D(this.rgba);return typeof e=="number"?w({h:e,s:n.s,l:n.l,a:n.a}):d(n.h)},t.prototype.isEqual=function(e){return this.toHex()===w(e).toHex()},t})(),w=function(t){return t instanceof B?t:new B(t)};const it=({hexColor:t,cursorPos:e,onPointerDown:n,onPointerMove:o,onPointerUp:r})=>{const[a,s]=P.useState(!1),f=h=>{s(!0),n(h),h.currentTarget.setPointerCapture(h.pointerId)},m=h=>{a&&o(h)},p=h=>{s(!1),r(h),h.currentTarget.releasePointerCapture(h.pointerId)};return M.jsx("div",{style:{position:"absolute",width:24,height:24,borderRadius:"50%",border:"2px solid white",boxShadow:"0 2px 4px rgba(0,0,0,0.3)",backgroundColor:t,left:"50%",top:"50%",transform:`translate(calc(-50% + ${e.x}px), calc(-50% + ${e.y}px))`,pointerEvents:"auto",cursor:a?"grabbing":"grab",willChange:"transform",zIndex:10},onPointerDown:f,onPointerMove:m,onPointerUp:p})},v={Custom:"Custom",Analogous:"Analogous",Monochromatic:"Monochromatic",Triad:"Triad",Complementary:"Complementary",SplitComplementary:"SplitComplementary",Square:"Square",Compound:"Compound"},V=(t,e,n,o)=>{const r=Math.atan2(e,t),a=Math.sqrt(t*t+e*e);let s=[];switch(n){case v.Analogous:s=[0,-30,30,-60,60];break;case v.Monochromatic:s=[0];break;case v.Triad:s=[0,120,240];break;case v.Complementary:s=[0,180];break;case v.SplitComplementary:s=[0,150,210];break;case v.Square:s=[0,90,180,270];break;case v.Compound:s=[0,180,30,210,60];break;case v.Custom:default:return null}const f=s.length,m=.25,p=[];for(let h=0;h<o;h++){const $=Math.floor(h/f),l=h%f,i=s[l],u=r+i*Math.PI/180;let c=a;n===v.Monochromatic?(c=a*(1-h*.15),c<0&&(c=0)):(c=a*(1-$*m),c<0&&(c=0)),p.push({x:Math.cos(u)*c,y:Math.sin(u)*c})}return p},lt=(t,e)=>{const n=e,o=e,r=t.createConicGradient(Math.PI*1.5,n,o);r.addColorStop(0,"#FFFF00"),r.addColorStop(.19,"#FF0000"),r.addColorStop(.36,"#FF00FF"),r.addColorStop(.5,"#0000FF"),r.addColorStop(.64,"#00FFFF"),r.addColorStop(.78,"#00FF00"),r.addColorStop(1,"#FFFF00"),t.fillStyle=r,t.beginPath(),t.arc(n,o,e,0,Math.PI*2),t.fill();const a=t.createRadialGradient(n,o,0,n,o,e);a.addColorStop(0,"#ffffff"),a.addColorStop(.2,"rgba(255, 255, 255, 0.8)"),a.addColorStop(.6,"rgba(255, 255, 255, 0.2)"),a.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=a,t.beginPath(),t.arc(n,o,e,0,Math.PI*2),t.fill()},ut=(t,e,n)=>{const o=Math.sqrt(t*t+e*e),r=n-1;if(o>r){const a=r/o;return{x:t*a,y:e*a}}return{x:t,y:e}},ct=({radius:t=150,onChange:e,quantityOfColors:n=5,harmony:o=v.Monochromatic})=>{const r=P.useRef(null),a=P.useRef(null),[s,f]=P.useState([]),m=P.useRef([]),p=P.useCallback((l,i)=>{const u=r.current;if(!u)return"#ffffff";const c=u.getContext("2d");if(!c)return"#ffffff";const y=window.devicePixelRatio||1,g=l+t,x=i+t,R=Math.floor(g*y),I=Math.floor(x*y),b=c.getImageData(R,I,1,1).data;return w({r:b[0],g:b[1],b:b[2],a:b[3]/255}).toHex()},[t]);P.useEffect(()=>{const l=r.current;if(!l)return;const i=l.getContext("2d",{willReadFrequently:!0});if(!i)return;const u=window.devicePixelRatio||1,c=t*2;l.width=c*u,l.height=c*u,l.style.width=`${c}px`,l.style.height=`${c}px`,i.scale(u,u),lt(i,t)},[t]),P.useEffect(()=>{let l;if(s.length>0){const i=s[0];l=V(i.x,i.y,o,n)}if(!l){const i=t*.5;o!==v.Custom?l=V(i,0,o,n):l=Array.from({length:n}).map((c,y)=>{const g=y/n*2*Math.PI;return{x:Math.cos(g)*t*.6,y:Math.sin(g)*t*.6}})}if(l){const i=l.map((u,c)=>({id:c,x:u.x,y:u.y,color:p(u.x,u.y)}));if(i.length>0&&o!==v.Custom){const u=Math.atan2(i[0].y,i[0].x),c=Math.sqrt(i[0].x*i[0].x+i[0].y*i[0].y);m.current=i.map(y=>{const g=Math.atan2(y.y,y.x),x=Math.sqrt(y.x*y.x+y.y*y.y);return{angleOffset:g-u,distanceRatio:c>0?x/c:1}})}f(i),e&&e(i)}},[o,n,p]);const h=P.useCallback((l,i,u)=>{const c=a.current;if(!c)return;const y=c.getBoundingClientRect();let g=l-y.left-t,x=i-y.top-t;const R=ut(g,x,t);if(g=R.x,x=R.y,o===v.Custom){const I=p(g,x),b=[...s];b[u]={...b[u],x:g,y:x,color:I},f(b),e&&e(b);return}if(m.current.length>0&&m.current[u]){const I=Math.atan2(x,g),b=m.current[u],ft=I-b.angleOffset,_=s.map((N,J)=>{if(J===u)return{...N,x:g,y:x,color:p(g,x)};const K=Math.sqrt(N.x*N.x+N.y*N.y),ht=m.current[J],Q=ft+ht.angleOffset,Z=Math.cos(Q)*K,U=Math.sin(Q)*K;return{...N,x:Z,y:U,color:p(Z,U)}});f(_),e&&e(_)}else{const I=p(g,x),b=[...s];b[u]={...b[u],x:g,y:x,color:I},f(b),e&&e(b)}},[t,p,e,s,o]),$=P.useCallback(l=>({onPointerDown:i=>{h(i.clientX,i.clientY,l)},onPointerMove:i=>{h(i.clientX,i.clientY,l)},onPointerUp:()=>{}}),[h]);return M.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:20},children:M.jsxs("div",{ref:a,style:{width:t*2,height:t*2,position:"relative",touchAction:"none"},children:[M.jsx("canvas",{ref:r,style:{borderRadius:"50%",display:"block"}}),M.jsx("svg",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1},children:s.map(l=>M.jsx("line",{x1:t,y1:t,x2:t+l.x,y2:t+l.y,stroke:"white",strokeWidth:"2",style:{filter:"drop-shadow(0px 1px 1px rgba(0,0,0,0.3))"}},l.id))}),s.map((l,i)=>{const u=$(i);return M.jsx(it,{cursorPos:{x:l.x,y:l.y},hexColor:l.color,onPointerDown:u.onPointerDown,onPointerMove:u.onPointerMove,onPointerUp:u.onPointerUp},l.id)})]})})};S.ColorWheel=ct,S.HarmonyType=v,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-color-palette-wheel",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -62,7 +62,7 @@
62
62
  "react-dom": "^19.2.0"
63
63
  },
64
64
  "peerDependencies": {
65
- "react": ">=19.0.0",
66
- "react-dom": ">=19.0.0"
65
+ "react": ">=16.8.0",
66
+ "react-dom": ">=16.8.0"
67
67
  }
68
68
  }