customizable-gradient-picker 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +604 -0
  3. package/dist/components/alpha-input/alpha-input.style.d.ts +8 -0
  4. package/dist/components/alpha-input/helpers.d.ts +3 -0
  5. package/dist/components/alpha-input/index.d.ts +28 -0
  6. package/dist/components/alpha-slider/index.d.ts +11 -0
  7. package/dist/components/angle-input/index.d.ts +22 -0
  8. package/dist/components/color-square/index.d.ts +9 -0
  9. package/dist/components/delete-stop/index.d.ts +10 -0
  10. package/dist/components/eye-dropper/index.d.ts +11 -0
  11. package/dist/components/gradient-formats/const.d.ts +3 -0
  12. package/dist/components/gradient-formats/index.d.ts +19 -0
  13. package/dist/components/gradient-preview/index.d.ts +4 -0
  14. package/dist/components/gradient-slider/const.d.ts +1 -0
  15. package/dist/components/gradient-slider/helpers.d.ts +28 -0
  16. package/dist/components/gradient-slider/index.d.ts +11 -0
  17. package/dist/components/gradient-string/index.d.ts +13 -0
  18. package/dist/components/hex-input/helpers.d.ts +1 -0
  19. package/dist/components/hex-input/index.d.ts +14 -0
  20. package/dist/components/hex-preview/index.d.ts +4 -0
  21. package/dist/components/hue-slider/const.d.ts +1 -0
  22. package/dist/components/hue-slider/index.d.ts +10 -0
  23. package/dist/components/index.d.ts +16 -0
  24. package/dist/components/render-icon.d.ts +2 -0
  25. package/dist/components/rgba-input/const.d.ts +2 -0
  26. package/dist/components/rgba-input/helpers.d.ts +5 -0
  27. package/dist/components/rgba-input/index.d.ts +28 -0
  28. package/dist/components/rgba-preview/index.d.ts +4 -0
  29. package/dist/components/stop-position/helpers.d.ts +6 -0
  30. package/dist/components/stop-position/index.d.ts +33 -0
  31. package/dist/const.d.ts +2 -0
  32. package/dist/context/color-provider.d.ts +8 -0
  33. package/dist/context/color.d.ts +5 -0
  34. package/dist/context/compose.d.ts +30 -0
  35. package/dist/context/gradient-provider.d.ts +15 -0
  36. package/dist/context/gradient.d.ts +12 -0
  37. package/dist/context/index.d.ts +7 -0
  38. package/dist/context/stops-provider.d.ts +15 -0
  39. package/dist/context/stops.d.ts +12 -0
  40. package/dist/helpers/color.d.ts +46 -0
  41. package/dist/helpers/function.d.ts +8 -0
  42. package/dist/helpers/gradient.d.ts +19 -0
  43. package/dist/helpers/index.d.ts +6 -0
  44. package/dist/helpers/number.d.ts +1 -0
  45. package/dist/helpers/string.d.ts +2 -0
  46. package/dist/helpers/styles.d.ts +1 -0
  47. package/dist/hooks/gradient/helpers.d.ts +9 -0
  48. package/dist/hooks/gradient/index.d.ts +4 -0
  49. package/dist/hooks/gradient/types.d.ts +53 -0
  50. package/dist/hooks/index.d.ts +1 -0
  51. package/dist/icons/angle-icon.d.ts +2 -0
  52. package/dist/icons/bin-icon.d.ts +2 -0
  53. package/dist/icons/chevron-icon.d.ts +2 -0
  54. package/dist/icons/clipboard-icon.d.ts +2 -0
  55. package/dist/icons/conic-gradient-icon.d.ts +2 -0
  56. package/dist/icons/dropper-icon.d.ts +2 -0
  57. package/dist/icons/index.d.ts +8 -0
  58. package/dist/icons/linear-gradient-icon.d.ts +2 -0
  59. package/dist/icons/radial-gradient-icon.d.ts +2 -0
  60. package/dist/index.d.ts +22 -0
  61. package/dist/index.js +2886 -0
  62. package/dist/store/context.d.ts +7 -0
  63. package/dist/store/hooks.d.ts +2 -0
  64. package/dist/store/index.d.ts +4 -0
  65. package/dist/store/store.d.ts +8 -0
  66. package/dist/store/types.d.ts +40 -0
  67. package/dist/types.d.ts +37 -0
  68. package/package.json +78 -0
package/dist/index.js ADDED
@@ -0,0 +1,2886 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".gp-color-square-wrapper{position:relative;overflow:hidden;border-radius:12px;aspect-ratio:1 / 1;height:auto;width:100%}.gp-color-square-thumb{position:absolute;transform:translate(-50%,-50%);pointer-events:none;touch-action:none;min-height:14px;min-width:14px;border-radius:9999px;border:2px solid white;cursor:pointer;box-shadow:0 0 2px #0009}.gp-hue-slider-wrapper{position:relative;height:20px;width:100%;border-radius:9999px;display:flex;justify-content:center;align-items:center}.gp-hue-slider-thumb{position:absolute;top:50%;transform:translate(-50%,-50%);box-sizing:border-box;width:24px;height:24px;border-radius:9999px;border:4px solid white;shadow:0 0 2px rgba(0,0,0,.6);cursor:ew-resize}.gp-hue-slider-canvas{border-radius:inherit}.gp-delete-stop-button{background-color:transparent;border:none;cursor:pointer;padding-inline:0px;padding-block:0px;line-height:0}.gp-delete-stop-button:disabled{cursor:not-allowed}.gp-delete-stop-button:disabled .gp-delete-stop-icon{color:gray}.gp-delete-stop-icon{width:16px;height:16px;color:#fff}.gp-eye-dropper-button{background-color:transparent;border:none;border-radius:4px;cursor:pointer;box-sizing:border-box;padding-block:0px;padding-inline:0px;padding:4px;margin:0;line-height:0;display:flex;justify-content:center;align-items:center;transition:background-color .2s ease-in-out}.gp-eye-dropper-button.gp-eye-dropper-active{background-color:#007acc}.gp-eye-dropper-icon{width:16px;height:16px;color:#fff}.gp-stop-position-wrapper{display:flex;align-items:center;justify-content:center;gap:8px;box-sizing:border-box;padding:8px;border-radius:8px;background-color:#ffffff4d}.gp-stop-position-label{color:#fff;font-size:12px}.gp-stop-position-input-wrapper{display:flex;align-items:center;justify-content:center;gap:0px;box-sizing:border-box;cursor:text;font-size:12px}.gp-stop-position-input{field-sizing:content;background-color:transparent;border:none;padding:0;line-height:0;color:#fff;font-size:inherit;outline:none}.gp-stop-position-input:is(:focus,:focus-visible){outline:none}.gp-stop-position-suffix{line-height:0;color:#fff;font-size:inherit}.gp-stop-position-icon{width:14px;color:#fff}.gp-stop-position-steppers{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;margin-left:4px}.gp-stop-position-stepper-button{background-color:transparent;border:none;padding-inline:0;padding-block:0;line-height:0;cursor:pointer}.gp-stop-position-stepper-decrement{transform:rotate(180deg)}.gp-stop-position-stepper-button svg{width:8px;color:#fff}.gp-alpha-slider-wrapper{position:relative;height:20px;width:100%;border-radius:9999px;display:flex;justify-content:center;align-items:center}.gp-alpha-slider-thumb{position:absolute;top:50%;transform:translate(-50%,-50%);box-sizing:border-box;box-shadow:0 0 2px #0009;background-color:#fff;height:24px;width:24px;border-radius:9999px;border:4px solid white;cursor:pointer}.gp-alpha-slider-thumb-inner{width:100%;height:100%;cursor:pointer;border-radius:9999px}.gp-alpha-slider-canvas{border-radius:inherit}.gp-alpha-input-wrapper{display:flex;justify-content:center;align-items:center;gap:8px;box-sizing:border-box;padding:8px;border-radius:8px;cursor:text;background-color:#ffffff4d}.gp-alpha-input-field{background-color:transparent;color:#fff;font-size:12px;field-sizing:content;border:none;padding-inline:0;padding-block:0;line-height:0;outline:none}.gp-alpha-input-suffix{color:#fff;font-size:12px;line-height:0}.gp-alpha-input-steppers{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px}.gp-alpha-input-stepper-button{background-color:transparent;border:none;padding-inline:0;padding-block:0;line-height:0;cursor:pointer}.gp-alpha-input-stepper-decrement{transform:rotate(180deg)}.gp-alpha-input-stepper-button svg{width:8px;color:#fff}.gp-angle-input-wrapper{display:flex;align-items:center;justify-content:center;gap:8px;box-sizing:border-box;padding:8px;border-radius:8px;background-color:#ffffff4d}.gp-angle-input-icon{width:14px;color:#fff}.gp-angle-input-input-wrapper{display:flex;gap:1px;width:54px;box-sizing:border-box;cursor:text}.gp-angle-input-field{font-size:12px;font-family:Sora,sans-serif;font-weight:400;color:#fff;field-sizing:content;border:none;background-color:transparent;padding-inline:0;padding-block:0;line-height:0;outline:none}.gp-angle-input-field:is(:focus,:focus-visible){outline:none}.gp-angle-input-degree{line-height:.75;color:#fff}.gp-angle-input-steppers{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px}.gp-angle-input-stepper-button{background-color:transparent;border:none;padding-inline:0;padding-block:0;line-height:0;cursor:pointer}.gp-angle-input-stepper-decrement{transform:rotate(180deg)}.gp-angle-input-stepper-button svg{width:8px;color:#fff}.gp-gradient-slider-wrapper{position:relative;height:20px;width:100%;border-radius:9999px;border:1px solid white}.gp-gradient-slider-gradient{position:absolute;inset:0;border-radius:9999px}.gp-gradient-slider-stop{transition:border-width .2s ease-in-out;aspect-ratio:1 / 1;height:24px;cursor:pointer;box-sizing:border-box;border-radius:9999px;border:4px solid white;position:absolute;top:50%;transform:translate(-50%,-50%)}.gp-gradient-slider-stop-inner{width:100%;height:100%;border-radius:9999px}.gp-gradient-slider-stop.gp-gradient-slider-stop-active{border:8px solid white}.gp-gradient-slider-canvas{position:absolute;inset:0;pointer-events:none;border-radius:inherit}.gp-gradient-formats-wrapper{display:flex;justify-content:center;align-items:center;gap:8px}.gp-gradient-formats-button{background-color:transparent;border:none;border-radius:4px;line-height:0;cursor:pointer;box-sizing:border-box;padding-block:0px;padding-inline:0px;padding:4px;margin:0;display:flex;justify-content:center;align-items:center;transition:background-color .2s ease-in-out}.gp-gradient-formats-button.gp-gradient-formats-button-active{background-color:#007acc}.gp-gradient-formats-icon{width:16px;height:16px;color:#fff;transition:color .2s ease-in-out}.gp-gradient-preview-wrapper{width:100%;height:40px;border-radius:12px;border:1px solid var(--light-grey)}.gp-gradient-string-wrapper{width:100%;box-sizing:border-box;padding:8px;border:1px solid var(--light-grey);border-radius:12px;background-color:#fff;display:flex;align-items:center;justify-content:center;gap:8px}.gp-gradient-string-text{font-size:12px;font-family:Sora,sans-serif;font-weight:400;color:#000;-webkit-user-select:all;user-select:all}.gp-gradient-string-copy-button{background-color:transparent;border:none;padding-inline:0;padding-block:0;cursor:pointer}.gp-gradient-string-copy-icon{width:14px;color:var(--light-grey)}.gp-hex-input-wrapper{display:flex;justify-content:center;align-items:center;box-sizing:border-box;padding:8px;border-radius:8px;cursor:text;background-color:#ffffff4d}.gp-hex-input-prefix{color:#fff;font-size:12px}.gp-hex-input-field{background-color:transparent;color:#fff;font-size:12px;field-sizing:content;border:none;padding-inline:0;padding-block:0;line-height:0;outline:none}.gp-hex-input-field:is(:focus,:focus-visible){outline:none}.gp-hex-input-copy-button{background-color:transparent;border:none;line-height:0;padding-inline:0;padding-block:0;margin-left:16px;cursor:pointer}.gp-hex-input-copy-icon{width:12px;color:#fff}.gp-hex-preview{width:32px;height:32px;border-radius:8px;flex-shrink:0}.gp-rgba-input-wrapper{display:flex;justify-content:center;align-items:center;gap:12px;box-sizing:border-box;padding:8px;border-radius:8px;cursor:text;background-color:#ffffff4d}.gp-rgba-input-field-wrapper{display:flex;align-items:center;gap:4px;cursor:text}.gp-rgba-input-field{background-color:transparent;color:#fff;font-size:12px;field-sizing:content;border:none;padding-inline:0;padding-block:0;line-height:0;outline:none}.gp-rgba-input-steppers{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px}.gp-rgba-input-stepper-button{background-color:transparent;border:none;padding-inline:0;padding-block:0;line-height:0;cursor:pointer}.gp-rgba-input-stepper-decrement{transform:rotate(180deg)}.gp-rgba-input-stepper-button svg{width:8px;color:#fff}.gp-rgba-preview{width:32px;height:32px;border-radius:8px;flex-shrink:0}:root{--grey: #a7b1c8;--light-grey: #d2d2e0}._wrapper_dqprj_11{width:240px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px}._map-item_dqprj_31{width:100%}")),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
2
+ import ue, { useRef as F, useState as st, useEffect as W, useMemo as nt, useCallback as et, useSyncExternalStore as te, useContext as pe, createContext as de, memo as ee, Fragment as ge } from "react";
3
+ var Tt = { exports: {} }, Pt = {};
4
+ var Xt;
5
+ function fe() {
6
+ if (Xt) return Pt;
7
+ Xt = 1;
8
+ var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), e = /* @__PURE__ */ Symbol.for("react.fragment");
9
+ function r(n, o, s) {
10
+ var a = null;
11
+ if (s !== void 0 && (a = "" + s), o.key !== void 0 && (a = "" + o.key), "key" in o) {
12
+ s = {};
13
+ for (var h in o)
14
+ h !== "key" && (s[h] = o[h]);
15
+ } else s = o;
16
+ return o = s.ref, {
17
+ $$typeof: t,
18
+ type: n,
19
+ key: a,
20
+ ref: o !== void 0 ? o : null,
21
+ props: s
22
+ };
23
+ }
24
+ return Pt.Fragment = e, Pt.jsx = r, Pt.jsxs = r, Pt;
25
+ }
26
+ var At = {};
27
+ var Yt;
28
+ function he() {
29
+ return Yt || (Yt = 1, process.env.NODE_ENV !== "production" && (function() {
30
+ function t(l) {
31
+ if (l == null) return null;
32
+ if (typeof l == "function")
33
+ return l.$$typeof === I ? null : l.displayName || l.name || null;
34
+ if (typeof l == "string") return l;
35
+ switch (l) {
36
+ case O:
37
+ return "Fragment";
38
+ case k:
39
+ return "Profiler";
40
+ case D:
41
+ return "StrictMode";
42
+ case R:
43
+ return "Suspense";
44
+ case H:
45
+ return "SuspenseList";
46
+ case M:
47
+ return "Activity";
48
+ }
49
+ if (typeof l == "object")
50
+ switch (typeof l.tag == "number" && console.error(
51
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
52
+ ), l.$$typeof) {
53
+ case d:
54
+ return "Portal";
55
+ case A:
56
+ return l.displayName || "Context";
57
+ case E:
58
+ return (l._context.displayName || "Context") + ".Consumer";
59
+ case f:
60
+ var V = l.render;
61
+ return l = l.displayName, l || (l = V.displayName || V.name || "", l = l !== "" ? "ForwardRef(" + l + ")" : "ForwardRef"), l;
62
+ case m:
63
+ return V = l.displayName || null, V !== null ? V : t(l.type) || "Memo";
64
+ case b:
65
+ V = l._payload, l = l._init;
66
+ try {
67
+ return t(l(V));
68
+ } catch {
69
+ }
70
+ }
71
+ return null;
72
+ }
73
+ function e(l) {
74
+ return "" + l;
75
+ }
76
+ function r(l) {
77
+ try {
78
+ e(l);
79
+ var V = !1;
80
+ } catch {
81
+ V = !0;
82
+ }
83
+ if (V) {
84
+ V = console;
85
+ var K = V.error, tt = typeof Symbol == "function" && Symbol.toStringTag && l[Symbol.toStringTag] || l.constructor.name || "Object";
86
+ return K.call(
87
+ V,
88
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
+ tt
90
+ ), e(l);
91
+ }
92
+ }
93
+ function n(l) {
94
+ if (l === O) return "<>";
95
+ if (typeof l == "object" && l !== null && l.$$typeof === b)
96
+ return "<...>";
97
+ try {
98
+ var V = t(l);
99
+ return V ? "<" + V + ">" : "<...>";
100
+ } catch {
101
+ return "<...>";
102
+ }
103
+ }
104
+ function o() {
105
+ var l = Z.A;
106
+ return l === null ? null : l.getOwner();
107
+ }
108
+ function s() {
109
+ return Error("react-stack-top-frame");
110
+ }
111
+ function a(l) {
112
+ if (P.call(l, "key")) {
113
+ var V = Object.getOwnPropertyDescriptor(l, "key").get;
114
+ if (V && V.isReactWarning) return !1;
115
+ }
116
+ return l.key !== void 0;
117
+ }
118
+ function h(l, V) {
119
+ function K() {
120
+ B || (B = !0, console.error(
121
+ "%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)",
122
+ V
123
+ ));
124
+ }
125
+ K.isReactWarning = !0, Object.defineProperty(l, "key", {
126
+ get: K,
127
+ configurable: !0
128
+ });
129
+ }
130
+ function p() {
131
+ var l = t(this.type);
132
+ return q[l] || (q[l] = !0, console.error(
133
+ "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."
134
+ )), l = this.props.ref, l !== void 0 ? l : null;
135
+ }
136
+ function i(l, V, K, tt, ht, g) {
137
+ var S = K.ref;
138
+ return l = {
139
+ $$typeof: j,
140
+ type: l,
141
+ key: V,
142
+ props: K,
143
+ _owner: tt
144
+ }, (S !== void 0 ? S : null) !== null ? Object.defineProperty(l, "ref", {
145
+ enumerable: !1,
146
+ get: p
147
+ }) : Object.defineProperty(l, "ref", { enumerable: !1, value: null }), l._store = {}, Object.defineProperty(l._store, "validated", {
148
+ configurable: !1,
149
+ enumerable: !1,
150
+ writable: !0,
151
+ value: 0
152
+ }), Object.defineProperty(l, "_debugInfo", {
153
+ configurable: !1,
154
+ enumerable: !1,
155
+ writable: !0,
156
+ value: null
157
+ }), Object.defineProperty(l, "_debugStack", {
158
+ configurable: !1,
159
+ enumerable: !1,
160
+ writable: !0,
161
+ value: ht
162
+ }), Object.defineProperty(l, "_debugTask", {
163
+ configurable: !1,
164
+ enumerable: !1,
165
+ writable: !0,
166
+ value: g
167
+ }), Object.freeze && (Object.freeze(l.props), Object.freeze(l)), l;
168
+ }
169
+ function v(l, V, K, tt, ht, g) {
170
+ var S = V.children;
171
+ if (S !== void 0)
172
+ if (tt)
173
+ if (L(S)) {
174
+ for (tt = 0; tt < S.length; tt++)
175
+ $(S[tt]);
176
+ Object.freeze && Object.freeze(S);
177
+ } else
178
+ console.error(
179
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
180
+ );
181
+ else $(S);
182
+ if (P.call(V, "key")) {
183
+ S = t(l);
184
+ var N = Object.keys(V).filter(function(c) {
185
+ return c !== "key";
186
+ });
187
+ tt = 0 < N.length ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}", ot[S + tt] || (N = 0 < N.length ? "{" + N.join(": ..., ") + ": ...}" : "{}", console.error(
188
+ `A props object containing a "key" prop is being spread into JSX:
189
+ let props = %s;
190
+ <%s {...props} />
191
+ React keys must be passed directly to JSX without using spread:
192
+ let props = %s;
193
+ <%s key={someKey} {...props} />`,
194
+ tt,
195
+ S,
196
+ N,
197
+ S
198
+ ), ot[S + tt] = !0);
199
+ }
200
+ if (S = null, K !== void 0 && (r(K), S = "" + K), a(V) && (r(V.key), S = "" + V.key), "key" in V) {
201
+ K = {};
202
+ for (var U in V)
203
+ U !== "key" && (K[U] = V[U]);
204
+ } else K = V;
205
+ return S && h(
206
+ K,
207
+ typeof l == "function" ? l.displayName || l.name || "Unknown" : l
208
+ ), i(
209
+ l,
210
+ S,
211
+ K,
212
+ o(),
213
+ ht,
214
+ g
215
+ );
216
+ }
217
+ function $(l) {
218
+ y(l) ? l._store && (l._store.validated = 1) : typeof l == "object" && l !== null && l.$$typeof === b && (l._payload.status === "fulfilled" ? y(l._payload.value) && l._payload.value._store && (l._payload.value._store.validated = 1) : l._store && (l._store.validated = 1));
219
+ }
220
+ function y(l) {
221
+ return typeof l == "object" && l !== null && l.$$typeof === j;
222
+ }
223
+ var w = ue, j = /* @__PURE__ */ Symbol.for("react.transitional.element"), d = /* @__PURE__ */ Symbol.for("react.portal"), O = /* @__PURE__ */ Symbol.for("react.fragment"), D = /* @__PURE__ */ Symbol.for("react.strict_mode"), k = /* @__PURE__ */ Symbol.for("react.profiler"), E = /* @__PURE__ */ Symbol.for("react.consumer"), A = /* @__PURE__ */ Symbol.for("react.context"), f = /* @__PURE__ */ Symbol.for("react.forward_ref"), R = /* @__PURE__ */ Symbol.for("react.suspense"), H = /* @__PURE__ */ Symbol.for("react.suspense_list"), m = /* @__PURE__ */ Symbol.for("react.memo"), b = /* @__PURE__ */ Symbol.for("react.lazy"), M = /* @__PURE__ */ Symbol.for("react.activity"), I = /* @__PURE__ */ Symbol.for("react.client.reference"), Z = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, P = Object.prototype.hasOwnProperty, L = Array.isArray, G = console.createTask ? console.createTask : function() {
224
+ return null;
225
+ };
226
+ w = {
227
+ react_stack_bottom_frame: function(l) {
228
+ return l();
229
+ }
230
+ };
231
+ var B, q = {}, Y = w.react_stack_bottom_frame.bind(
232
+ w,
233
+ s
234
+ )(), Q = G(n(s)), ot = {};
235
+ At.Fragment = O, At.jsx = function(l, V, K) {
236
+ var tt = 1e4 > Z.recentlyCreatedOwnerStacks++;
237
+ return v(
238
+ l,
239
+ V,
240
+ K,
241
+ !1,
242
+ tt ? Error("react-stack-top-frame") : Y,
243
+ tt ? G(n(l)) : Q
244
+ );
245
+ }, At.jsxs = function(l, V, K) {
246
+ var tt = 1e4 > Z.recentlyCreatedOwnerStacks++;
247
+ return v(
248
+ l,
249
+ V,
250
+ K,
251
+ !0,
252
+ tt ? Error("react-stack-top-frame") : Y,
253
+ tt ? G(n(l)) : Q
254
+ );
255
+ };
256
+ })()), At;
257
+ }
258
+ var Zt;
259
+ function me() {
260
+ return Zt || (Zt = 1, process.env.NODE_ENV === "production" ? Tt.exports = fe() : Tt.exports = he()), Tt.exports;
261
+ }
262
+ var u = me();
263
+ const yt = (t) => Math.max(0, Math.min(1, t)), vt = (t, e, r) => {
264
+ const n = (t % 360 + 360) % 360, o = r * e, s = o * (1 - Math.abs(n / 60 % 2 - 1)), a = r - o;
265
+ let h = 0, p = 0, i = 0;
266
+ n < 60 ? [h, p, i] = [o, s, 0] : n < 120 ? [h, p, i] = [s, o, 0] : n < 180 ? [h, p, i] = [0, o, s] : n < 240 ? [h, p, i] = [0, s, o] : n < 300 ? [h, p, i] = [s, 0, o] : [h, p, i] = [o, 0, s];
267
+ const v = Math.round((h + a) * 255), $ = Math.round((p + a) * 255), y = Math.round((i + a) * 255);
268
+ return { r: v, g: $, b: y };
269
+ }, wt = (t, e, r) => {
270
+ const n = t / 255, o = e / 255, s = r / 255, a = Math.max(n, o, s), h = Math.min(n, o, s), p = a - h;
271
+ let i = 0;
272
+ const v = a, $ = a === 0 ? 0 : p / a;
273
+ return p !== 0 && (a === n ? i = (o - s) / p + (o < s ? 6 : 0) : a === o ? i = (s - n) / p + 2 : i = (n - o) / p + 4, i *= 60), { h: i, s: $, v };
274
+ }, ne = (t) => {
275
+ const e = t.trim().replace(/^#/, "");
276
+ return e.length === 3 ? `#${e[0]}${e[0]}${e[1]}${e[1]}${e[2]}${e[2]}`.toLowerCase() : e.length === 6 ? `#${e}`.toLowerCase() : "#000000";
277
+ }, be = (t, e, r) => {
278
+ const n = (o) => o.toString(16).padStart(2, "0");
279
+ return `#${n(t)}${n(e)}${n(r)}`.toLowerCase();
280
+ }, dt = (t) => {
281
+ const e = typeof t == "number" ? t : Number(t);
282
+ return ((Number.isFinite(e) ? e : 0) % 360 + 360) % 360;
283
+ }, Rt = (t) => Math.max(0, Math.min(255, Math.round(t))), it = (t, e, r, n) => {
284
+ const o = yt(n);
285
+ return `rgba(${Rt(t)}, ${Rt(e)}, ${Rt(r)}, ${o})`;
286
+ }, J = (t) => {
287
+ const e = t.trim().match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/i);
288
+ return e ? {
289
+ r: Rt(Number(e[1])),
290
+ g: Rt(Number(e[2])),
291
+ b: Rt(Number(e[3])),
292
+ a: yt(Number(e[4]))
293
+ } : null;
294
+ }, Ft = (t) => {
295
+ const e = J(t);
296
+ return e ? wt(e.r, e.g, e.b).h : 0;
297
+ }, xe = (t, e) => {
298
+ const n = J(t) ?? { r: 0, g: 0, b: 0, a: 1 }, o = wt(n.r, n.g, n.b), s = vt(e, o.s, o.v);
299
+ return it(s.r, s.g, s.b, n.a);
300
+ }, Ce = (t, e, r) => {
301
+ const n = t / 255, o = e / 255, s = r / 255, a = Math.max(n, o, s), h = Math.min(n, o, s), p = a - h;
302
+ if (p === 0) return 0;
303
+ let i;
304
+ return a === n ? i = (o - s) / p + (o < s ? 6 : 0) : a === o ? i = (s - n) / p + 2 : i = (n - o) / p + 4, i * 60 % 360;
305
+ }, Se = (t) => {
306
+ const e = J(t);
307
+ return e ? yt(e.a) : 1;
308
+ }, ve = 24, St = ve / 2, qt = (t, e, r) => Math.max(e, Math.min(r, t)), we = (t, e) => {
309
+ const n = (qt(t - e.left, St, e.width - St) - St) / Math.max(1, e.width - 2 * St);
310
+ return qt(n, 0, 1);
311
+ }, Re = (t, e) => St + qt(t, 0, 1) * Math.max(1, e - 2 * St), Ie = (t) => {
312
+ if (!t) return null;
313
+ let e = t.trim();
314
+ if (e.startsWith("#") && (e = e.slice(1)), e.length === 8 && (e = e.slice(0, 6)), e.length !== 6 || !/^[0-9a-fA-F]{6}$/.test(e)) return null;
315
+ const r = parseInt(e.slice(0, 2), 16), n = parseInt(e.slice(2, 4), 16), o = parseInt(e.slice(4, 6), 16);
316
+ return { r, g: n, b: o };
317
+ }, It = (t) => {
318
+ const e = J(t);
319
+ return e ? be(e.r, e.g, e.b) : null;
320
+ }, ye = (t) => {
321
+ if (!t) return null;
322
+ let e = t.trim();
323
+ if (e.startsWith("#") && (e = e.slice(1)), !(e.length === 6 || e.length === 8) || !/^[0-9a-fA-F]+$/.test(e)) return null;
324
+ const r = parseInt(e.slice(0, 2), 16), n = parseInt(e.slice(2, 4), 16), o = parseInt(e.slice(4, 6), 16), s = e.length === 8 ? Math.round(parseInt(e.slice(6, 8), 16) / 255 * 1e3) / 1e3 : 1;
325
+ return { r, g: n, b: o, a: s };
326
+ }, je = (t, e, r) => t === e && e === r, Et = (t) => {
327
+ const e = ye(t);
328
+ return e ? it(e.r, e.g, e.b, e.a) : null;
329
+ }, Pe = (t) => {
330
+ const e = J(t);
331
+ if (!e) return null;
332
+ const r = (o) => o.toString(16).padStart(2, "0"), n = Math.round(yt(e.a) * 255);
333
+ return `#${r(e.r)}${r(e.g)}${r(e.b)}${r(n)}`.toLowerCase();
334
+ }, $t = (t, e) => {
335
+ if (!t || !e) return !1;
336
+ if (t === e) return !0;
337
+ const r = J(t), n = J(e);
338
+ return !r || !n ? !1 : r.r === n.r && r.g === n.g && r.b === n.b && Math.abs(r.a - n.a) < 1e-4;
339
+ }, ct = (t, e, r) => Math.max(e, Math.min(r, t));
340
+ function C(...t) {
341
+ return t.flat().filter(Boolean).join(" ");
342
+ }
343
+ const zt = 359.999, re = {
344
+ stop1: {
345
+ position: 15,
346
+ color: "rgba(255, 126, 95, 1)",
347
+ id: "stop1"
348
+ },
349
+ stop2: {
350
+ position: 85,
351
+ color: "rgba(254, 180, 123, 1)",
352
+ id: "stop2"
353
+ }
354
+ }, Nt = /* @__PURE__ */ new Map(), oe = (t, e = 500, r = "default") => {
355
+ const n = Nt.get(r);
356
+ if (n && (clearTimeout(n), Nt.delete(r)), e <= 0) {
357
+ t();
358
+ return;
359
+ }
360
+ const o = setTimeout(() => {
361
+ t(), Nt.delete(r);
362
+ }, e);
363
+ Nt.set(r, o);
364
+ }, Ae = (t) => {
365
+ const e = t ? Wt(t) : null, r = e?.stops ?? re, n = se({
366
+ gradient: t ?? "",
367
+ onGradientChange: () => {
368
+ },
369
+ updateDelay: 0,
370
+ initialStops: r
371
+ });
372
+ if (e) {
373
+ const o = Object.keys(e.stops)[0] ?? null;
374
+ n.setState((s) => {
375
+ const h = (o ? e.stops[o] : null)?.color ?? "rgba(0, 0, 0, 1)", p = Gt(h, Ft(h)), i = p === 0 && Ft(h) > 300 ? zt : p;
376
+ let v = s.angle;
377
+ if (e.format === "linear-gradient" && e.prefix) {
378
+ const $ = e.prefix.match(/^(\d+(?:\.\d+)?)deg$/i);
379
+ $ && (v = parseFloat($[1]));
380
+ }
381
+ return {
382
+ ...s,
383
+ format: e.format,
384
+ angle: v,
385
+ prefixes: {
386
+ ...s.prefixes,
387
+ [e.format]: e.prefix || s.prefixes[e.format]
388
+ },
389
+ stops: e.stops,
390
+ stopsOrder: Object.keys(e.stops),
391
+ activeStopId: o,
392
+ rgba: h,
393
+ hue: i
394
+ };
395
+ });
396
+ }
397
+ return n;
398
+ }, lt = (t, e, r) => Math.max(e, Math.min(r, t)), Me = (t) => {
399
+ const e = [];
400
+ let r = "", n = 0;
401
+ for (let o = 0; o < t.length; o++) {
402
+ const s = t[o];
403
+ s === "(" && n++, s === ")" && (n = Math.max(0, n - 1)), s === "," && n === 0 ? (e.push(r.trim()), r = "") : r += s;
404
+ }
405
+ return r.trim() && e.push(r.trim()), e;
406
+ }, ke = (t) => {
407
+ const e = t.trim().match(/^(#[0-9a-fA-F]{3,8})\s*(?:([0-9]*\.?[0-9]+)%\s*)?$/);
408
+ if (!e) return null;
409
+ const r = ne(e[1]), n = parseInt(r.slice(1, 3), 16), o = parseInt(r.slice(3, 5), 16), s = parseInt(r.slice(5, 7), 16), a = r.length === 9 ? lt(parseInt(r.slice(7, 9), 16) / 255, 0, 1) : 1, h = it(n, o, s, a), p = e[2] != null ? lt(Number(e[2]), 0, 100) : void 0;
410
+ return { color: h, position: p };
411
+ }, $e = (t) => {
412
+ const e = t.trim().match(
413
+ /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*(?:([0-9]*\.?[0-9]+)%\s*)?$/i
414
+ );
415
+ if (!e) return null;
416
+ const r = lt(Number(e[1]), 0, 255), n = lt(Number(e[2]), 0, 255), o = lt(Number(e[3]), 0, 255), s = e[4] != null ? lt(Number(e[4]), 0, 100) : void 0;
417
+ return { color: it(r, n, o, 1), position: s };
418
+ }, Oe = (t) => {
419
+ const e = t.trim().match(
420
+ /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([0-9]*\.?[0-9]+)\s*\)\s*(?:([0-9]*\.?[0-9]+)%\s*)?$/i
421
+ );
422
+ if (!e) return null;
423
+ const r = lt(Number(e[1]), 0, 255), n = lt(Number(e[2]), 0, 255), o = lt(Number(e[3]), 0, 255), s = lt(Number(e[4]), 0, 1), a = e[5] != null ? lt(Number(e[5]), 0, 100) : void 0;
424
+ return { color: it(r, n, o, s), position: a };
425
+ }, Ee = (t) => {
426
+ const e = {};
427
+ return t.forEach((r, n) => {
428
+ const o = `stop${n + 1}`;
429
+ e[o] = { id: o, position: r.position, color: r.color };
430
+ }), e;
431
+ }, Te = (t) => /^\s*linear-gradient\(/i.test(t) ? "linear-gradient" : /^\s*radial-gradient\(/i.test(t) ? "radial-gradient" : /^\s*conic-gradient\(/i.test(t) ? "conic-gradient" : null, Wt = (t) => {
432
+ if (!t) return null;
433
+ const e = Te(t);
434
+ if (!e) return null;
435
+ const r = t.match(/^[a-z-]+-gradient\((.*)\)\s*$/i);
436
+ if (!r) return null;
437
+ const n = r[1].trim(), o = Me(n), s = (y) => /#|rgba?\(/i.test(y), a = o.findIndex(s);
438
+ if (a === -1) return null;
439
+ const h = o.slice(0, a).join(", ").trim(), p = o.slice(a), i = [];
440
+ for (const y of p) {
441
+ const w = Oe(y);
442
+ if (w) {
443
+ i.push({ color: w.color, position: w.position ?? NaN });
444
+ continue;
445
+ }
446
+ const j = $e(y);
447
+ if (j) {
448
+ i.push({ color: j.color, position: j.position ?? NaN });
449
+ continue;
450
+ }
451
+ const d = ke(y);
452
+ d && i.push({ color: d.color, position: d.position ?? NaN });
453
+ }
454
+ if (i.length === 0) return null;
455
+ const v = i.some((y) => Number.isFinite(y.position)), $ = i.length;
456
+ return v ? i.forEach((y, w) => {
457
+ Number.isFinite(y.position) || (w === 0 ? y.position = 0 : w === $ - 1 ? y.position = 100 : y.position = w / ($ - 1) * 100);
458
+ }) : i.forEach((y, w) => y.position = $ === 1 ? 50 : w / ($ - 1) * 100), i.forEach((y) => y.position = lt(y.position, 0, 100)), i.sort((y, w) => y.position - w.position), { format: e, prefix: h, stops: Ee(i) };
459
+ }, Ne = (t, e) => {
460
+ const r = t.slice().sort((o, s) => o.position - s.position).map((o) => `${o.color} ${lt(o.position, 0, 100)}%`).join(", ");
461
+ if (e.format === "linear-gradient")
462
+ return `linear-gradient(${Number.isFinite(e.angle) ? e.angle : 90}deg, ${r})`;
463
+ if (e.format === "radial-gradient") {
464
+ const o = (e.prefix ?? "").trim();
465
+ return o ? `radial-gradient(${o}, ${r})` : `radial-gradient(${r})`;
466
+ }
467
+ const n = (e.prefix ?? "").trim();
468
+ return n ? `conic-gradient(${n}, ${r})` : `conic-gradient(${r})`;
469
+ }, Gt = (t, e) => {
470
+ const r = J(t);
471
+ return !r || r.r === r.g && r.g === r.b ? e : wt(r.r, r.g, r.b).h;
472
+ }, pt = (t, e, r) => Math.max(e, Math.min(r, t)), Ot = (t) => Object.values(t ?? {}).slice().sort((r, n) => r.position - n.position).map((r) => r.id), De = (t) => /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t.trim()), _e = (t) => /^rgba\(/i.test(t.trim()), bt = (t) => {
473
+ const e = (t ?? "").trim();
474
+ return _e(e) ? e : De(e) ? Et(e) ?? "rgba(0, 0, 0, 1)" : "rgba(0, 0, 0, 1)";
475
+ }, Le = (t) => {
476
+ let e = 0;
477
+ for (const r of t) {
478
+ const n = r.match(/^stop(\d+)$/i);
479
+ n && (e = Math.max(e, Number(n[1])));
480
+ }
481
+ return `stop${e + 1}`;
482
+ }, Vt = (t) => Object.values(t).slice().sort((e, r) => e.position - r.position).map((e) => e.id), Mn = (t) => {
483
+ const e = t.match(/linear-gradient\(\s*(-?\d+(?:\.\d+)?)deg\s*,/i);
484
+ if (!e) return null;
485
+ const r = Number(e[1]);
486
+ return Number.isFinite(r) ? r : null;
487
+ }, He = (t) => {
488
+ const e = (t.stopsOrder.length ? t.stopsOrder : Object.keys(t.stops)).map((r) => t.stops[r]).filter(Boolean).sort((r, n) => r.position - n.position).map((r) => `${r.color} ${r.position}%`).join(", ");
489
+ if (!e) return "";
490
+ switch (t.format) {
491
+ case "linear-gradient":
492
+ return `linear-gradient(${t.angle}deg, ${e})`;
493
+ case "radial-gradient":
494
+ return `radial-gradient(${e})`;
495
+ case "conic-gradient":
496
+ return `conic-gradient(from ${t.angle}deg, ${e})`;
497
+ default:
498
+ return "";
499
+ }
500
+ }, xt = (t, e, r) => {
501
+ const n = F(null), o = F(!1), s = () => {
502
+ const a = e(t.getState());
503
+ if (!o.current)
504
+ return o.current = !0, n.current = a, a;
505
+ const h = n.current;
506
+ return Object.is(h, a) ? h : (n.current = a, a);
507
+ };
508
+ return te(t.subscribe, s, s);
509
+ }, kn = (t, e) => {
510
+ const n = F(Ae(t)).current, [o, s] = st(t ?? ""), a = xt(n, (c) => c.rgba), h = xt(n, (c) => c.angle), p = xt(n, (c) => c.format), i = xt(n, (c) => c.stops), v = xt(n, (c) => c.stopsOrder), $ = xt(n, (c) => c.activeStopId), w = !!xt(n, (c) => c.draggingStopId), [j, d] = st([]), [O, D] = st([]);
511
+ W(() => {
512
+ n.setOnGradientChange && n.setOnGradientChange((c) => {
513
+ s(c), e?.(c);
514
+ });
515
+ }, [n, e]);
516
+ const k = F(!1);
517
+ W(() => {
518
+ k.current || t && (k.current = !0, s(t), n.setGradient?.(t));
519
+ }, [t, n]);
520
+ const E = nt(() => $ ? i?.[$]?.position ?? 0 : 0, [$, i]), f = nt(() => J(a), [a])?.a ?? 1, R = nt(() => {
521
+ const c = J(a);
522
+ return c ? ((c.a < 1 ? Pe(a) : It(a)) ?? "#000000").replace("#", "").toUpperCase() : "000000";
523
+ }, [a]), [H, m] = st(R), b = F(R);
524
+ W(() => {
525
+ R !== b.current && (m(R), b.current = R);
526
+ }, [R]);
527
+ const M = a, I = nt(() => (v?.length ? v : Object.keys(i ?? {})).map((x) => i?.[x]).filter(Boolean).map((x) => {
528
+ const T = bt(String(x.color ?? "rgba(0, 0, 0, 1)")), _ = J(T) ?? { r: 0, g: 0, b: 0, a: 1 }, z = (It(T) ?? "#000000").replace("#", "").toUpperCase();
529
+ return {
530
+ id: x.id,
531
+ position: Number(x.position ?? 0),
532
+ rgbaString: T,
533
+ rgba: { r: _.r, g: _.g, b: _.b, a: _.a },
534
+ hex: z,
535
+ opacity: _.a
536
+ };
537
+ }), [i, v]), Z = et(
538
+ (c) => {
539
+ const x = n.getState().stops[c];
540
+ x && (n.setActiveStopId(c), n.setActiveStopColor(x.color ?? "rgba(0, 0, 0, 1)"));
541
+ },
542
+ [n]
543
+ ), P = et(
544
+ (c, x) => {
545
+ const T = bt(x);
546
+ if (n.getState().activeStopId === c) {
547
+ n.setActiveStopColor(T);
548
+ return;
549
+ }
550
+ n.setStops((z) => {
551
+ const rt = z[c];
552
+ return rt ? { ...z, [c]: { ...rt, color: T } } : z;
553
+ });
554
+ },
555
+ [n]
556
+ ), L = et(
557
+ (c, x) => {
558
+ const T = Math.max(0, Math.min(100, x));
559
+ n.setStops((_) => {
560
+ const z = _[c];
561
+ return z ? { ..._, [c]: { ...z, position: T } } : _;
562
+ }), n.setStopsOrder(Vt(n.getState().stops));
563
+ },
564
+ [n]
565
+ ), G = et(
566
+ (c, x) => {
567
+ const T = Math.max(0, Math.min(100, c)), _ = bt(x), z = Le(Object.keys(n.getState().stops ?? {}));
568
+ n.setStops((rt) => ({
569
+ ...rt,
570
+ [z]: { id: z, position: T, color: _ }
571
+ })), n.setStopsOrder(Vt(n.getState().stops)), n.setActiveStopId(z), n.setActiveStopColor(_);
572
+ },
573
+ [n]
574
+ ), B = et(
575
+ (c) => {
576
+ const x = n.getState();
577
+ if (Object.keys(x.stops ?? {}).length <= 2 || !x.stops[c]) return;
578
+ n.setStops((rt) => {
579
+ const jt = { ...rt };
580
+ return delete jt[c], jt;
581
+ });
582
+ const _ = n.getState().stops, z = Vt(_);
583
+ if (n.setStopsOrder(z), n.getState().activeStopId === c) {
584
+ const rt = z[0] ?? null;
585
+ if (n.setActiveStopId(rt), rt) {
586
+ const jt = _[rt];
587
+ jt && n.setActiveStopColor(jt.color ?? "rgba(0, 0, 0, 1)");
588
+ }
589
+ }
590
+ },
591
+ [n]
592
+ ), q = et(
593
+ (c) => {
594
+ const x = c.replace(/\s+/g, "").replace(/^#/, "").slice(0, 8);
595
+ if (m(x), !/^[0-9a-fA-F]*$/.test(x) || !(x.length === 3 || x.length === 4 || x.length === 6 || x.length === 8)) return;
596
+ const _ = x.length === 3 || x.length === 4 ? `#${x.split("").map((rt) => rt + rt).join("")}`.toLowerCase() : `#${x}`.toLowerCase(), z = Et(_);
597
+ z && n.setActiveStopColor(z);
598
+ },
599
+ [n]
600
+ ), Y = et(
601
+ (c) => {
602
+ const x = Math.max(0, Math.min(1, c)), T = J(n.getState().rgba);
603
+ T && n.setActiveStopColor(it(T.r, T.g, T.b, x));
604
+ },
605
+ [n]
606
+ ), Q = et(
607
+ (c) => {
608
+ const x = J(n.getState().rgba);
609
+ x && n.setActiveStopColor(it(c, x.g, x.b, x.a));
610
+ },
611
+ [n]
612
+ ), ot = et(
613
+ (c) => {
614
+ const x = J(n.getState().rgba);
615
+ x && n.setActiveStopColor(it(x.r, c, x.b, x.a));
616
+ },
617
+ [n]
618
+ ), l = et(
619
+ (c) => {
620
+ const x = J(n.getState().rgba);
621
+ x && n.setActiveStopColor(it(x.r, x.g, c, x.a));
622
+ },
623
+ [n]
624
+ ), V = et((c) => Y(c), [Y]), K = et((c) => n.setAngle(c), [n]), tt = et((c) => n.setFormat(c), [n]), ht = et((c) => {
625
+ const x = bt(c);
626
+ d((T) => T.includes(x) ? T : [x, ...T]);
627
+ }, []), g = et((c) => {
628
+ const x = bt(c);
629
+ d((T) => T.filter((_) => _ !== x));
630
+ }, []), S = et((c) => {
631
+ const x = bt(c);
632
+ D((T) => [x, ...T.filter((z) => z !== x)].slice(0, 24));
633
+ }, []), N = et((c) => {
634
+ const x = bt(c);
635
+ D((T) => T.filter((_) => _ !== x));
636
+ }, []), U = et(
637
+ (c, x, T) => {
638
+ const _ = (T ?? "").trim();
639
+ if (c === x) return _;
640
+ if (c === "hex" && x === "rgba") {
641
+ const z = _.startsWith("#") ? _ : `#${_}`, rt = ne(z);
642
+ return Et(rt) ?? "rgba(0, 0, 0, 1)";
643
+ }
644
+ return c === "rgba" && x === "hex" ? (It(_) ?? "#000000").replace("#", "").toUpperCase() : _;
645
+ },
646
+ []
647
+ );
648
+ return {
649
+ store: n,
650
+ stops: I,
651
+ activeStopId: $,
652
+ activeStopPosition: E,
653
+ angle: h,
654
+ format: p,
655
+ isDragging: w,
656
+ recentlyUsedColors: O,
657
+ libraryColors: j,
658
+ hex: H,
659
+ rgba: M,
660
+ rgbaString: a,
661
+ gradientString: o,
662
+ opacity: f,
663
+ setR: Q,
664
+ setG: ot,
665
+ setB: l,
666
+ setA: V,
667
+ setHex: q,
668
+ setAngle: K,
669
+ setFormat: tt,
670
+ setOpacity: Y,
671
+ setStopColor: P,
672
+ setActiveStop: Z,
673
+ setStopPosition: L,
674
+ setLibraryColors: d,
675
+ setRecentlyUsedColors: D,
676
+ addStop: G,
677
+ addColorToLibrary: ht,
678
+ addColorToRecentlyUsed: S,
679
+ removeStop: B,
680
+ removeColorFromLibrary: g,
681
+ removeColorFromRecentlyUsed: N,
682
+ convertColor: U
683
+ };
684
+ }, Fe = {
685
+ "linear-gradient": "",
686
+ "radial-gradient": "circle at center",
687
+ "conic-gradient": "from 90deg at 50% 50%"
688
+ }, Ge = (t) => Math.max(0, Math.min(1, t)), Ct = (t) => {
689
+ const e = J(t);
690
+ if (!e) return t.trim();
691
+ const r = Math.round(Ge(e.a) * 1e3) / 1e3;
692
+ return it(e.r, e.g, e.b, r);
693
+ }, Ve = (t) => ({
694
+ rgba: "rgba(0, 0, 0, 1)",
695
+ hue: 0,
696
+ format: "linear-gradient",
697
+ prefixes: Fe,
698
+ angle: 90,
699
+ gradient: t.gradient,
700
+ updateDelay: t.updateDelay,
701
+ onGradientChange: t.onGradientChange,
702
+ activeStopId: Object.keys(t.initialStops)[0] ?? null,
703
+ stops: t.initialStops,
704
+ stopsOrder: Object.keys(t.initialStops),
705
+ draggingStopId: null,
706
+ draftPosition: null
707
+ }), se = (t) => {
708
+ let e = Ve(t);
709
+ const r = /* @__PURE__ */ new Set(), n = () => {
710
+ for (const m of r) m();
711
+ }, o = (m) => {
712
+ const b = m(e);
713
+ b !== e && (e = b, n());
714
+ }, s = () => e, a = (m) => (r.add(m), () => {
715
+ r.delete(m);
716
+ }), h = (m) => {
717
+ const b = Ct(m);
718
+ o((M) => M.rgba === b ? M : { ...M, rgba: b });
719
+ }, p = (m) => {
720
+ const b = dt(m);
721
+ o((M) => M.hue === b ? M : { ...M, hue: b });
722
+ }, i = (m) => {
723
+ let b = !1;
724
+ o((M) => M.format === m ? M : (b = !0, { ...M, format: m })), b && D();
725
+ }, v = (m) => {
726
+ o((b) => b.prefixes === m ? b : { ...b, prefixes: m });
727
+ }, $ = (m) => {
728
+ let b = !1;
729
+ o((M) => M.angle === m ? M : (b = !0, { ...M, angle: m })), b && D();
730
+ }, y = (m) => {
731
+ o((b) => b.gradient === m ? b : { ...b, gradient: m });
732
+ }, w = (m) => {
733
+ o(
734
+ (b) => b.updateDelay === m ? b : { ...b, updateDelay: m }
735
+ );
736
+ }, j = (m) => {
737
+ o(
738
+ (b) => b.onGradientChange === m ? b : { ...b, onGradientChange: m }
739
+ );
740
+ }, d = (m) => {
741
+ o((b) => b.activeStopId === m ? b : { ...b, activeStopId: m });
742
+ }, O = (m) => {
743
+ let b = !1;
744
+ o((M) => {
745
+ const I = m(M.stops);
746
+ return I === M.stops ? M : (b = !0, { ...M, stops: I });
747
+ }), b && D();
748
+ }, D = () => {
749
+ const m = He(e);
750
+ e.gradient !== m && (e = { ...e, gradient: m }, n(), e.onGradientChange(m));
751
+ };
752
+ return {
753
+ getState: s,
754
+ setState: o,
755
+ subscribe: a,
756
+ setRgba: h,
757
+ setHue: p,
758
+ setFormat: i,
759
+ setPrefixes: v,
760
+ setAngle: $,
761
+ setGradient: y,
762
+ setUpdateDelay: w,
763
+ setOnGradientChange: j,
764
+ setActiveStopId: d,
765
+ setStops: O,
766
+ setStopsOrder: (m) => {
767
+ let b = !1;
768
+ o((M) => M.stopsOrder === m ? M : (b = !0, { ...M, stopsOrder: m })), b && D();
769
+ },
770
+ setDraggingStopId: (m) => {
771
+ o(
772
+ (b) => b.draggingStopId === m ? b : { ...b, draggingStopId: m }
773
+ );
774
+ },
775
+ setDraftPosition: (m) => {
776
+ o(
777
+ (b) => b.draftPosition === m ? b : { ...b, draftPosition: m }
778
+ );
779
+ },
780
+ recomputeGradient: D,
781
+ setActiveStopColor: (m) => {
782
+ let b = !1;
783
+ const M = Ct(m);
784
+ o((I) => {
785
+ const Z = Gt(M, I.hue), P = I.activeStopId;
786
+ if (!P || !I.stops[P])
787
+ return I.rgba === M && I.hue === Z ? I : (b = !0, { ...I, rgba: M, hue: Z });
788
+ const L = I.stops[P], B = Ct(L.color) === M, q = I.rgba === M, Y = I.hue === Z;
789
+ return B && q && Y ? I : (b = !0, {
790
+ ...I,
791
+ rgba: q ? I.rgba : M,
792
+ hue: Y ? I.hue : Z,
793
+ stops: B ? I.stops : { ...I.stops, [P]: { ...L, color: M } }
794
+ });
795
+ }), b && D();
796
+ },
797
+ setHueForActiveStop: (m) => {
798
+ const b = dt(m);
799
+ let M = !1;
800
+ o((I) => {
801
+ const Z = Ct(xe(I.rgba, b)), P = I.activeStopId;
802
+ if (!P || !I.stops[P])
803
+ return I.hue === b && I.rgba === Z ? I : (M = !0, { ...I, hue: b, rgba: Z });
804
+ const L = I.stops[P], B = Ct(L.color) === Z, q = I.rgba === Z, Y = I.hue === b;
805
+ if (B && q && Y) return I;
806
+ M = !0;
807
+ const Q = B ? I.stops : { ...I.stops, [P]: { ...L, color: Z } };
808
+ return {
809
+ ...I,
810
+ hue: Y ? I.hue : b,
811
+ rgba: q ? I.rgba : Z,
812
+ stops: Q
813
+ };
814
+ }), M && D();
815
+ },
816
+ setSvForActiveStop: (m, b) => {
817
+ let M = !1;
818
+ o((I) => {
819
+ const Z = J(I.rgba) ?? { a: 1 }, P = vt(I.hue, m, b), L = Ct(it(P.r, P.g, P.b, Z.a)), G = I.activeStopId;
820
+ if (!G || !I.stops[G])
821
+ return I.rgba === L ? I : (M = !0, { ...I, rgba: L });
822
+ const B = I.stops[G], Y = Ct(B.color) === L, Q = I.rgba === L;
823
+ return Y && Q ? I : (M = !0, {
824
+ ...I,
825
+ rgba: Q ? I.rgba : L,
826
+ stops: Y ? I.stops : { ...I.stops, [G]: { ...B, color: L } }
827
+ });
828
+ }), M && D();
829
+ }
830
+ };
831
+ }, ie = de(null), Ue = (t) => /* @__PURE__ */ u.jsx(ie.Provider, { value: t.store, children: t.children }), ut = () => {
832
+ const t = pe(ie);
833
+ if (!t)
834
+ throw new Error("[GradientPicker] Missing GradientPickerStoreProvider");
835
+ return t;
836
+ }, X = (t, e) => {
837
+ const r = ut(), n = F(null), o = F(!1), s = () => {
838
+ const a = t(r.getState());
839
+ if (!o.current)
840
+ return o.current = !0, n.current = a, a;
841
+ const h = n.current;
842
+ return (e ? e(h, a) : Object.is(h, a)) ? h : (n.current = a, a);
843
+ };
844
+ return te(r.subscribe, s, s);
845
+ }, Be = ({ classNames: t }) => {
846
+ const e = ut(), r = X((P) => P.rgba), n = X((P) => P.hue), o = F(null), s = F(null), a = F(null), h = F(r), p = F(n), i = F(null), v = F(null), $ = X((P) => P.activeStopId);
847
+ h.current = r, p.current = n;
848
+ const [y, w] = st({ w: 0, h: 0 }), [j, d] = st(null), [O, D] = st(() => {
849
+ const P = J(r) ?? { r: 0, g: 0, b: 0 }, L = wt(P.r, P.g, P.b);
850
+ return {
851
+ s: ct(L.s, 0, 1),
852
+ v: ct(L.v, 0, 1)
853
+ };
854
+ });
855
+ W(() => {
856
+ v.current !== $ && (v.current = $, i.current = null);
857
+ }, [$]), W(() => {
858
+ if (j) return;
859
+ const P = J(r) == null ? r.trim() : it(
860
+ (J(r) ?? { r: 0 }).r,
861
+ (J(r) ?? { g: 0 }).g,
862
+ (J(r) ?? { b: 0 }).b,
863
+ Math.round(
864
+ ((J(r) ?? { a: 1 }).a ?? 1) * 1e3
865
+ ) / 1e3
866
+ );
867
+ if (i.current === P)
868
+ return;
869
+ const L = J(r) ?? { r: 0, g: 0, b: 0 }, G = wt(L.r, L.g, L.b);
870
+ D((B) => {
871
+ if (je(L.r, L.g, L.b)) {
872
+ const Y = { s: B.s, v: ct(G.v, 0, 1) };
873
+ return B.s === Y.s && B.v === Y.v ? B : Y;
874
+ }
875
+ const q = {
876
+ s: ct(G.s, 0, 1),
877
+ v: ct(G.v, 0, 1)
878
+ };
879
+ return B.s === q.s && B.v === q.v ? B : q;
880
+ });
881
+ }, [r, j]), W(() => {
882
+ const P = o.current;
883
+ if (!P) return;
884
+ const L = new ResizeObserver((G) => {
885
+ const B = G[0]?.contentRect;
886
+ if (!B) return;
887
+ const q = Math.floor(B.width), Y = Math.floor(B.height);
888
+ q <= 0 || Y <= 0 || w((Q) => Q.w === q && Q.h === Y ? Q : { w: q, h: Y });
889
+ });
890
+ return L.observe(P), () => L.disconnect();
891
+ }, []), W(() => {
892
+ const { w: P, h: L } = y;
893
+ if (!P || !L) return;
894
+ const G = s.current;
895
+ if (!G) return;
896
+ const B = window.devicePixelRatio || 1;
897
+ G.width = Math.round(P * B), G.height = Math.round(L * B), G.style.width = `${P}px`, G.style.height = `${L}px`;
898
+ const q = G.getContext("2d");
899
+ if (!q) return;
900
+ q.setTransform(B, 0, 0, B, 0, 0), q.clearRect(0, 0, P, L);
901
+ const Y = dt(n), Q = vt(Y, 1, 1);
902
+ q.fillStyle = `rgb(${Q.r}, ${Q.g}, ${Q.b})`, q.fillRect(0, 0, P, L);
903
+ const ot = q.createLinearGradient(0, 0, P, 0);
904
+ ot.addColorStop(0, "rgba(255,255,255,1)"), ot.addColorStop(1, "rgba(255,255,255,0)"), q.fillStyle = ot, q.fillRect(0, 0, P, L);
905
+ const l = q.createLinearGradient(0, 0, 0, L);
906
+ l.addColorStop(0, "rgba(0,0,0,0)"), l.addColorStop(1, "rgba(0,0,0,1)"), q.fillStyle = l, q.fillRect(0, 0, P, L);
907
+ }, [y.w, y.h, n]);
908
+ const { thumbLeft: k, thumbTop: E, thumbColor: A } = nt(() => {
909
+ const P = J(r) ?? { r: 0, g: 0, b: 0, a: 1 }, L = wt(P.r, P.g, P.b), G = L.s === 0 ? dt(n) : dt(L.h), B = ct(j ? j.s : O.s, 0, 1), q = ct(j ? j.v : O.v, 0, 1), Y = y.w || 1, Q = y.h || 1, ot = B * Y, l = (1 - q) * Q, V = vt(G, B, q), K = it(V.r, V.g, V.b, P.a);
910
+ return { thumbLeft: ot, thumbTop: l, thumbColor: K };
911
+ }, [r, n, y.w, y.h, j, O]), f = F(null), R = F(null);
912
+ W(() => () => {
913
+ f.current != null && cancelAnimationFrame(f.current);
914
+ }, []);
915
+ const H = et(
916
+ (P, L) => {
917
+ const G = J(h.current) ?? { a: 1 }, B = vt(dt(p.current), P, L), q = it(B.r, B.g, B.b, G.a);
918
+ i.current = q, e.setSvForActiveStop(P, L);
919
+ },
920
+ [e]
921
+ ), m = et(
922
+ (P, L) => {
923
+ R.current = { s: P, v: L }, f.current == null && (f.current = requestAnimationFrame(() => {
924
+ f.current = null;
925
+ const G = R.current;
926
+ R.current = null, G && H(G.s, G.v);
927
+ }));
928
+ },
929
+ [H]
930
+ ), b = (P, L) => {
931
+ const G = o.current?.getBoundingClientRect();
932
+ if (!G) return;
933
+ const B = ct(P - G.left, 0, G.width), q = ct(L - G.top, 0, G.height), Y = ct(B / Math.max(1, G.width), 0, 1), Q = ct(1 - q / Math.max(1, G.height), 0, 1), ot = { s: Y, v: Q };
934
+ d(ot), D(ot), m(Y, Q);
935
+ }, M = (P) => {
936
+ P.currentTarget.setPointerCapture(P.pointerId), b(P.clientX, P.clientY);
937
+ }, I = (P) => {
938
+ (P.buttons & 1) === 1 && b(P.clientX, P.clientY);
939
+ }, Z = () => {
940
+ d(null);
941
+ };
942
+ return /* @__PURE__ */ u.jsxs(
943
+ "section",
944
+ {
945
+ id: "color-square-wrapper",
946
+ ref: (P) => {
947
+ o.current = P;
948
+ },
949
+ className: C(t?.wrapper, "gp-color-square-wrapper"),
950
+ onPointerDown: M,
951
+ onPointerMove: I,
952
+ onPointerUp: Z,
953
+ onPointerCancel: Z,
954
+ onLostPointerCapture: Z,
955
+ role: "application",
956
+ tabIndex: 0,
957
+ "aria-label": "Color picker",
958
+ "aria-disabled": !$,
959
+ "data-scope": "gradient-picker",
960
+ "data-slot": "root",
961
+ "data-dragging": j ? "true" : void 0,
962
+ "data-active": $ ? "true" : void 0,
963
+ "data-hue": dt(n),
964
+ "data-sat": O.s,
965
+ "data-val": O.v,
966
+ children: [
967
+ /* @__PURE__ */ u.jsx(
968
+ "canvas",
969
+ {
970
+ id: "color-square-canvas",
971
+ ref: (P) => {
972
+ s.current = P;
973
+ },
974
+ className: C(t?.canvas, "gp-color-square-canvas"),
975
+ "aria-hidden": "true",
976
+ "data-slot": "canvas"
977
+ }
978
+ ),
979
+ /* @__PURE__ */ u.jsx(
980
+ "div",
981
+ {
982
+ id: "color-square-thumb",
983
+ ref: (P) => {
984
+ a.current = P;
985
+ },
986
+ className: C(t?.thumb, "gp-color-square-thumb"),
987
+ style: {
988
+ left: `${k}px`,
989
+ top: `${E}px`,
990
+ backgroundColor: A
991
+ },
992
+ "aria-hidden": "true",
993
+ "data-slot": "thumb",
994
+ "data-dragging": j ? "true" : void 0
995
+ }
996
+ )
997
+ ]
998
+ }
999
+ );
1000
+ }, qe = ({ classNames: t }) => {
1001
+ const e = ut(), r = X((f) => f.rgba), n = X((f) => f.hue), o = F(null), s = F(null), a = F(null), [h, p] = st({ w: 0, h: 0 }), [i, v] = st(12);
1002
+ W(() => {
1003
+ const f = s.current;
1004
+ if (!f) return;
1005
+ const R = new ResizeObserver((H) => {
1006
+ const m = H[0]?.contentRect;
1007
+ if (!m) return;
1008
+ const b = Math.floor(m.width), M = Math.floor(m.height);
1009
+ if (b <= 0 || M <= 0) return;
1010
+ p(
1011
+ (Z) => Z.w === b && Z.h === M ? Z : { w: b, h: M }
1012
+ );
1013
+ const I = a.current?.getBoundingClientRect();
1014
+ I?.width && v(Math.max(0, I.width / 2));
1015
+ });
1016
+ return R.observe(f), () => R.disconnect();
1017
+ }, []), W(() => {
1018
+ const { w: f, h: R } = h;
1019
+ if (!f || !R) return;
1020
+ const H = o.current;
1021
+ if (!H) return;
1022
+ const m = window.devicePixelRatio || 1;
1023
+ H.width = Math.round(f * m), H.height = Math.round(R * m), H.style.width = `${f}px`, H.style.height = `${R}px`;
1024
+ const b = H.getContext("2d");
1025
+ if (!b) return;
1026
+ b.setTransform(m, 0, 0, m, 0, 0), b.clearRect(0, 0, f, R);
1027
+ const M = b.createLinearGradient(0, 0, f, 0);
1028
+ M.addColorStop(0, "rgb(255, 0, 0)"), M.addColorStop(1 / 6, "rgb(255, 255, 0)"), M.addColorStop(2 / 6, "rgb(0, 255, 0)"), M.addColorStop(3 / 6, "rgb(0, 255, 255)"), M.addColorStop(4 / 6, "rgb(0, 0, 255)"), M.addColorStop(5 / 6, "rgb(255, 0, 255)"), M.addColorStop(1, "rgb(255, 0, 0)"), b.fillStyle = M, b.fillRect(0, 0, f, R);
1029
+ }, [h.w, h.h]);
1030
+ const $ = nt(() => {
1031
+ const f = dt(n) / 360, R = h.w || 1;
1032
+ return i + ct(f, 0, 1) * Math.max(1, R - 2 * i);
1033
+ }, [n, h.w, i]), y = nt(() => {
1034
+ const f = J(r)?.a ?? 1, R = vt(n, 1, 1);
1035
+ return it(R.r, R.g, R.b, f);
1036
+ }, [n, r]), w = nt(
1037
+ () => ({ left: $, backgroundColor: y }),
1038
+ [$, y]
1039
+ ), j = F(null), d = F(null), O = (f) => {
1040
+ const R = dt(f);
1041
+ e.setHueForActiveStop(R);
1042
+ }, D = (f) => {
1043
+ d.current = f, j.current == null && (j.current = requestAnimationFrame(() => {
1044
+ j.current = null;
1045
+ const R = d.current;
1046
+ d.current = null, R != null && O(R);
1047
+ }));
1048
+ };
1049
+ W(() => () => {
1050
+ j.current != null && cancelAnimationFrame(j.current);
1051
+ }, []);
1052
+ const k = (f) => {
1053
+ const R = s.current?.getBoundingClientRect();
1054
+ if (!R) return;
1055
+ const m = (ct(
1056
+ f - R.left,
1057
+ i,
1058
+ R.width - i
1059
+ ) - i) / Math.max(1, R.width - 2 * i), b = Math.min(m * 360, zt);
1060
+ D(b);
1061
+ }, E = (f) => {
1062
+ f.currentTarget.setPointerCapture(f.pointerId), k(f.clientX);
1063
+ }, A = (f) => {
1064
+ (f.buttons & 1) === 1 && k(f.clientX);
1065
+ };
1066
+ return /* @__PURE__ */ u.jsxs(
1067
+ "section",
1068
+ {
1069
+ className: C(t?.wrapper, "gp-hue-slider-wrapper"),
1070
+ ref: s,
1071
+ onPointerDown: E,
1072
+ onPointerMove: A,
1073
+ role: "slider",
1074
+ tabIndex: 0,
1075
+ "aria-label": "Hue",
1076
+ "aria-valuemin": 0,
1077
+ "aria-valuemax": 360,
1078
+ "aria-valuenow": dt(n),
1079
+ "data-scope": "gradient-picker",
1080
+ "data-slot": "hue-slider",
1081
+ "data-value": dt(n),
1082
+ children: [
1083
+ /* @__PURE__ */ u.jsx(
1084
+ "canvas",
1085
+ {
1086
+ ref: o,
1087
+ className: C(t?.canvas, "gp-hue-slider-canvas"),
1088
+ "aria-hidden": "true",
1089
+ "data-slot": "canvas"
1090
+ }
1091
+ ),
1092
+ /* @__PURE__ */ u.jsx(
1093
+ "div",
1094
+ {
1095
+ ref: a,
1096
+ className: C(t?.thumb, "gp-hue-slider-thumb"),
1097
+ style: w,
1098
+ "aria-hidden": "true",
1099
+ "data-slot": "thumb",
1100
+ "data-value": dt(n)
1101
+ }
1102
+ )
1103
+ ]
1104
+ }
1105
+ );
1106
+ }, ze = (t) => /* @__PURE__ */ u.jsx(
1107
+ "svg",
1108
+ {
1109
+ viewBox: "0 0 16 16",
1110
+ fill: "currentColor",
1111
+ xmlns: "http://www.w3.org/2000/svg",
1112
+ ...t,
1113
+ children: /* @__PURE__ */ u.jsx(
1114
+ "path",
1115
+ {
1116
+ fillRule: "evenodd",
1117
+ clipRule: "evenodd",
1118
+ d: "M7 0C6.81434 9.91486e-05 6.63237 0.0518831 6.47447 0.149552C6.31658 0.247222 6.18899 0.386919 6.106 0.553L5.382 2H2C1.73478 2 1.48043 2.10536 1.29289 2.29289C1.10536 2.48043 1 2.73478 1 3C1 3.26522 1.10536 3.51957 1.29289 3.70711C1.48043 3.89464 1.73478 4 2 4V14C2 14.5304 2.21071 15.0391 2.58579 15.4142C2.96086 15.7893 3.46957 16 4 16H12C12.5304 16 13.0391 15.7893 13.4142 15.4142C13.7893 15.0391 14 14.5304 14 14V4C14.2652 4 14.5196 3.89464 14.7071 3.70711C14.8946 3.51957 15 3.26522 15 3C15 2.73478 14.8946 2.48043 14.7071 2.29289C14.5196 2.10536 14.2652 2 14 2H10.618L9.894 0.553C9.81101 0.386919 9.68342 0.247222 9.52553 0.149552C9.36763 0.0518831 9.18566 9.91486e-05 9 0H7ZM5 6C5 5.73478 5.10536 5.48043 5.29289 5.29289C5.48043 5.10536 5.73478 5 6 5C6.26522 5 6.51957 5.10536 6.70711 5.29289C6.89464 5.48043 7 5.73478 7 6V12C7 12.2652 6.89464 12.5196 6.70711 12.7071C6.51957 12.8946 6.26522 13 6 13C5.73478 13 5.48043 12.8946 5.29289 12.7071C5.10536 12.5196 5 12.2652 5 12V6ZM10 5C9.73478 5 9.48043 5.10536 9.29289 5.29289C9.10536 5.48043 9 5.73478 9 6V12C9 12.2652 9.10536 12.5196 9.29289 12.7071C9.48043 12.8946 9.73478 13 10 13C10.2652 13 10.5196 12.8946 10.7071 12.7071C10.8946 12.5196 11 12.2652 11 12V6C11 5.73478 10.8946 5.48043 10.7071 5.29289C10.5196 5.10536 10.2652 5 10 5Z",
1119
+ fill: "currentColor"
1120
+ }
1121
+ )
1122
+ }
1123
+ ), We = (t) => /* @__PURE__ */ u.jsx("svg", { viewBox: "0 0 16 17", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...t, children: /* @__PURE__ */ u.jsx(
1124
+ "path",
1125
+ {
1126
+ d: "M0.999999 13.6299L0.999999 13.2351L7.32333 1.40025C7.39117 1.27874 7.48954 1.17768 7.60842 1.10736C7.72729 1.03705 7.86242 1 8 1C8.13758 1 8.27271 1.03705 8.39158 1.10736C8.51046 1.17768 8.60883 1.27874 8.67667 1.40025L15 13.2343L15 13.6291C15 14.9389 11.8656 16 8 16C4.13444 16 0.999999 14.9389 0.999999 13.6299Z",
1127
+ stroke: "currentColor",
1128
+ strokeWidth: "2",
1129
+ strokeLinecap: "round",
1130
+ strokeLinejoin: "round"
1131
+ }
1132
+ ) }), Xe = (t) => /* @__PURE__ */ u.jsx(
1133
+ "svg",
1134
+ {
1135
+ viewBox: "0 0 14 4",
1136
+ fill: "currentColor",
1137
+ xmlns: "http://www.w3.org/2000/svg",
1138
+ ...t,
1139
+ children: /* @__PURE__ */ u.jsx(
1140
+ "path",
1141
+ {
1142
+ d: "M12.25 0C11.529 0 10.92 0.434 10.647 1.05H8.603C8.33 0.434 7.721 0 7 0C6.279 0 5.67 0.434 5.397 1.05H3.353C3.08 0.434 2.471 0 1.75 0C1.28587 0 0.840752 0.184374 0.512563 0.512563C0.184374 0.840752 0 1.28587 0 1.75C0 2.21413 0.184374 2.65925 0.512563 2.98744C0.840752 3.31563 1.28587 3.5 1.75 3.5C2.471 3.5 3.08 3.066 3.353 2.45H5.397C5.67 3.066 6.279 3.5 7 3.5C7.721 3.5 8.33 3.066 8.603 2.45H10.647C10.92 3.066 11.529 3.5 12.25 3.5C12.7141 3.5 13.1592 3.31563 13.4874 2.98744C13.8156 2.65925 14 2.21413 14 1.75C14 1.28587 13.8156 0.840752 13.4874 0.512563C13.1592 0.184374 12.7141 0 12.25 0Z",
1143
+ fill: "currentColor"
1144
+ }
1145
+ )
1146
+ }
1147
+ ), Ye = (t) => /* @__PURE__ */ u.jsx(
1148
+ "svg",
1149
+ {
1150
+ viewBox: "0 0 14 14",
1151
+ fill: "currentColor",
1152
+ xmlns: "http://www.w3.org/2000/svg",
1153
+ ...t,
1154
+ children: /* @__PURE__ */ u.jsx(
1155
+ "path",
1156
+ {
1157
+ fillRule: "evenodd",
1158
+ clipRule: "evenodd",
1159
+ d: "M1.50244 7C1.50209 6.04541 1.75028 5.10718 2.2226 4.27763C2.69491 3.44808 3.37507 2.75579 4.19615 2.26889C5.01723 1.782 5.95093 1.51727 6.90538 1.50075C7.85982 1.48424 8.80212 1.71651 9.63955 2.17471C9.7261 2.22582 9.82203 2.25901 9.92165 2.2723C10.0213 2.28558 10.1226 2.27871 10.2195 2.25207C10.3164 2.22544 10.407 2.17959 10.4858 2.11725C10.5646 2.05492 10.6301 1.97736 10.6784 1.88921C10.7267 1.80105 10.7567 1.70409 10.7668 1.60408C10.7768 1.50408 10.7667 1.40308 10.7369 1.30708C10.7071 1.21108 10.6583 1.12205 10.5935 1.04528C10.5286 0.968506 10.449 0.905559 10.3593 0.86018C9.03193 0.133212 7.50466 -0.143828 6.00652 0.070608C4.50839 0.285044 3.12016 0.979398 2.05002 2.04953C0.979886 3.11967 0.285532 4.5079 0.0710963 6.00604C-0.14334 7.50417 0.1337 9.03144 0.860668 10.3588C0.959634 10.5264 1.11989 10.6489 1.30755 10.7005C1.49522 10.7521 1.69559 10.7287 1.8663 10.6352C2.03701 10.5417 2.16468 10.3855 2.22233 10.1996C2.27997 10.0137 2.26307 9.81272 2.1752 9.63906C1.73317 8.82972 1.50182 7.92219 1.50244 7ZM13.1403 3.64119C13.0949 3.55151 13.032 3.47187 12.9552 3.40701C12.8784 3.34214 12.7894 3.29338 12.6934 3.26361C12.5974 3.23384 12.4964 3.22367 12.3964 3.23372C12.2964 3.24377 12.1994 3.27382 12.1113 3.32209C12.0231 3.37035 11.9456 3.43586 11.8832 3.5147C11.8209 3.59354 11.7751 3.6841 11.7484 3.78102C11.7218 3.87793 11.7149 3.97921 11.7282 4.07883C11.7415 4.17846 11.7747 4.27439 11.8258 4.36094C12.3971 5.40388 12.6148 6.60394 12.4464 7.78111C12.2779 8.95828 11.7323 10.0491 10.8915 10.89C10.0506 11.7308 8.95977 12.2764 7.7826 12.4449C6.60543 12.6133 5.40537 12.3956 4.36242 11.8243C4.18797 11.7286 3.98265 11.7061 3.79162 11.7618C3.60059 11.8174 3.4395 11.9467 3.34379 12.1212C3.24808 12.2956 3.22559 12.501 3.28127 12.692C3.33695 12.883 3.46623 13.0441 3.64068 13.1398C4.96805 13.8668 6.49532 14.1438 7.99345 13.9294C9.49159 13.715 10.8798 13.0206 11.95 11.9505C13.0201 10.8803 13.7144 9.4921 13.9289 7.99397C14.1433 6.49583 13.8663 4.96856 13.1393 3.64119M8.49996 7C8.49996 7.39768 8.34198 7.77908 8.06077 8.06028C7.77957 8.34149 7.39817 8.49947 7.00049 8.49947C6.6028 8.49947 6.22141 8.34149 5.9402 8.06028C5.659 7.77908 5.50102 7.39768 5.50102 7C5.50102 6.60232 5.659 6.22092 5.9402 5.93972C6.22141 5.65851 6.6028 5.50053 7.00049 5.50053C7.39817 5.50053 7.77957 5.65851 8.06077 5.93972C8.34198 6.22092 8.49996 6.60232 8.49996 7ZM9.99942 7C9.99942 7.79537 9.68347 8.55816 9.12106 9.12057C8.55865 9.68298 7.79586 9.99894 7.00049 9.99894C6.20512 9.99894 5.44233 9.68298 4.87992 9.12057C4.31751 8.55816 4.00155 7.79537 4.00155 7C4.00155 6.20463 4.31751 5.44184 4.87992 4.87943C5.44233 4.31702 6.20512 4.00106 7.00049 4.00106C7.79586 4.00106 8.55865 4.31702 9.12106 4.87943C9.68347 5.44184 9.99942 6.20463 9.99942 7Z",
1160
+ fill: "currentColor"
1161
+ }
1162
+ )
1163
+ }
1164
+ ), Ze = (t) => /* @__PURE__ */ u.jsx(
1165
+ "svg",
1166
+ {
1167
+ viewBox: "0 0 16 16",
1168
+ fill: "currentColor",
1169
+ xmlns: "http://www.w3.org/2000/svg",
1170
+ ...t,
1171
+ children: /* @__PURE__ */ u.jsx(
1172
+ "path",
1173
+ {
1174
+ d: "M10.6751 0.912497L7.50321 4.0875L7.20946 3.79375C6.81883 3.40312 6.18446 3.40312 5.79383 3.79375C5.40321 4.18437 5.40321 4.81875 5.79383 5.20937L10.7938 10.2094C11.1845 10.6 11.8188 10.6 12.2095 10.2094C12.6001 9.81875 12.6001 9.18437 12.2095 8.79375L11.9157 8.5L15.0876 5.325C16.3063 4.10625 16.3063 2.13125 15.0876 0.915622C13.8688 -0.300003 11.8938 -0.303128 10.6782 0.915622L10.6751 0.912497ZM1.73133 10.1031C1.26258 10.5719 1.00008 11.2094 1.00008 11.8719V13.1969L0.168834 14.4437C-0.0967908 14.8406 -0.0436659 15.3687 0.293834 15.7062C0.631334 16.0437 1.15946 16.0969 1.55633 15.8312L2.80321 15H4.12821C4.79071 15 5.42821 14.7375 5.89696 14.2687L9.66883 10.4969L8.25321 9.08125L4.48133 12.8531C4.38758 12.9469 4.25946 13 4.12821 13H3.00008V11.8719C3.00008 11.7406 3.05321 11.6125 3.14696 11.5187L6.91883 7.74687L5.50321 6.33125L1.73133 10.1031Z",
1175
+ fill: "currentColor"
1176
+ }
1177
+ )
1178
+ }
1179
+ ), Je = (t) => /* @__PURE__ */ u.jsx(
1180
+ "svg",
1181
+ {
1182
+ viewBox: "0 0 14 14",
1183
+ fill: "currentColor",
1184
+ xmlns: "http://www.w3.org/2000/svg",
1185
+ ...t,
1186
+ children: /* @__PURE__ */ u.jsx(
1187
+ "path",
1188
+ {
1189
+ fillRule: "evenodd",
1190
+ clipRule: "evenodd",
1191
+ d: "M10.7801 2.44148C10.9126 2.27899 10.9847 2.06408 10.9813 1.84202C10.9778 1.61996 10.8991 1.40809 10.7617 1.25105C10.6243 1.09401 10.4389 1.00405 10.2446 1.00013C10.0503 0.996216 9.86225 1.07864 9.72007 1.23005L5.18007 6.41633L5.15707 6.44262L0.220073 12.0872C0.115317 12.2071 0.0439922 12.3597 0.0151078 12.5259C-0.0137766 12.6921 0.00107474 12.8643 0.0577861 13.0208C0.114497 13.1773 0.210525 13.3112 0.333741 13.4054C0.456956 13.4995 0.601833 13.5499 0.750073 13.55H13.2501C13.449 13.55 13.6398 13.4597 13.7804 13.299C13.9211 13.1383 14.0001 12.9202 14.0001 12.6929C14.0001 12.4656 13.9211 12.2476 13.7804 12.0868C13.6398 11.9261 13.449 11.8358 13.2501 11.8358H8.46407C8.31508 10.0847 7.71316 8.42403 6.73507 7.06548L10.7801 2.44148ZM5.66807 8.2849L2.56107 11.8358H6.95507C6.818 10.54 6.37289 9.31191 5.66807 8.2849Z",
1192
+ fill: "currentColor",
1193
+ strokeWidth: 0.25,
1194
+ stroke: "currentColor"
1195
+ }
1196
+ )
1197
+ }
1198
+ ), mt = (t) => /* @__PURE__ */ u.jsx("svg", { viewBox: "0 0 22 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...t, children: /* @__PURE__ */ u.jsx(
1199
+ "path",
1200
+ {
1201
+ d: "M11 0.5C11.4157 0.500587 11.8245 0.608121 12.1865 0.8125C12.5032 0.991321 12.7752 1.23882 12.9824 1.53613L13.0664 1.66699L21.1816 15.2109C21.3902 15.575 21.5002 15.9876 21.501 16.4072C21.5016 16.8293 21.3914 17.244 21.1816 17.6104C20.9718 17.9768 20.6693 18.282 20.3047 18.4951C19.9403 18.708 19.5265 18.8222 19.1045 18.8252H2.8877C2.46522 18.8206 2.0514 18.7049 1.6875 18.4902C1.32346 18.2754 1.02182 17.9684 0.813477 17.6006C0.605278 17.2329 0.497088 16.8171 0.5 16.3945C0.50292 15.9719 0.616688 15.5572 0.830078 15.1924L0.829102 15.1914L8.93652 1.66211C9.1514 1.30717 9.45388 1.01313 9.81543 0.80957C10.1317 0.631497 10.4838 0.527885 10.8447 0.504883L11 0.5Z",
1202
+ fill: "currentColor",
1203
+ stroke: "currentColor"
1204
+ }
1205
+ ) }), ae = (t) => /* @__PURE__ */ u.jsx("svg", { viewBox: "0 0 12 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...t, children: /* @__PURE__ */ u.jsx(
1206
+ "path",
1207
+ {
1208
+ d: "M8.75 2H10C11.1031 2 12 2.89687 12 4V14C12 15.1031 11.1031 16 10 16H2C0.896875 16 0 15.1031 0 14V4C0 2.89687 0.896875 2 2 2H3.25H3.55C3.78125 0.859375 4.79063 0 6 0C7.20937 0 8.21875 0.859375 8.45 2H8.75ZM2 3.5C1.725 3.5 1.5 3.725 1.5 4V14C1.5 14.275 1.725 14.5 2 14.5H10C10.275 14.5 10.5 14.275 10.5 14V4C10.5 3.725 10.275 3.5 10 3.5H9.5V4.25C9.5 4.66563 9.16562 5 8.75 5H6H3.25C2.83437 5 2.5 4.66563 2.5 4.25V3.5H2ZM6 3.25C6.19891 3.25 6.38968 3.17098 6.53033 3.03033C6.67098 2.88968 6.75 2.69891 6.75 2.5C6.75 2.30109 6.67098 2.11032 6.53033 1.96967C6.38968 1.82902 6.19891 1.75 6 1.75C5.80109 1.75 5.61032 1.82902 5.46967 1.96967C5.32902 2.11032 5.25 2.30109 5.25 2.5C5.25 2.69891 5.32902 2.88968 5.46967 3.03033C5.61032 3.17098 5.80109 3.25 6 3.25Z",
1209
+ fill: "currentColor"
1210
+ }
1211
+ ) }), Ke = ({ icon: t, classNames: e }) => {
1212
+ const r = ut(), n = X((i) => i.activeStopId), o = X((i) => i.stops), s = X((i) => i.stopsOrder), a = Object.keys(o ?? {}).length > 2, h = typeof t == "function" ? (() => {
1213
+ const i = t;
1214
+ return /* @__PURE__ */ u.jsx(i, { className: C(e?.icon, "gs-delete-stop-icon") });
1215
+ })() : t ?? null, p = () => {
1216
+ const i = n;
1217
+ if (!i) return;
1218
+ const v = o ?? {}, $ = Object.keys(v);
1219
+ if ($.length <= 2) return;
1220
+ const y = (s?.length ? s : $).filter(
1221
+ (k) => !!v[k]
1222
+ ), w = y.indexOf(i);
1223
+ if (w === -1) return;
1224
+ const j = y[w + 1] ?? y[w - 1] ?? null;
1225
+ if (!j) return;
1226
+ const d = { ...v };
1227
+ delete d[i];
1228
+ const O = y.filter((k) => k !== i);
1229
+ r.setStops(() => d), r.setStopsOrder(O), r.setActiveStopId(j);
1230
+ const D = d[j]?.color;
1231
+ D && r.setActiveStopColor(D);
1232
+ };
1233
+ return /* @__PURE__ */ u.jsx(
1234
+ "button",
1235
+ {
1236
+ type: "button",
1237
+ disabled: !a,
1238
+ className: C("gp-delete-stop-button", e?.button),
1239
+ onClick: p,
1240
+ "aria-label": "Delete color stop",
1241
+ "data-scope": "gradient-picker",
1242
+ "data-slot": "delete-stop-button",
1243
+ "data-active": n ? "true" : void 0,
1244
+ "data-disabled": a ? void 0 : "true",
1245
+ children: h ?? /* @__PURE__ */ u.jsx(ze, { className: C("gp-delete-stop-icon", e?.icon) })
1246
+ }
1247
+ );
1248
+ }, Qe = ({ classNames: t, icon: e }) => {
1249
+ const r = ut(), n = X((p) => p.activeStopId), [o, s] = st(!1), a = async () => {
1250
+ if (s(!0), "EyeDropper" in window)
1251
+ try {
1252
+ const p = new window.EyeDropper(), { sRGBHex: i } = await p.open(), v = Ie(i);
1253
+ if (v && n) {
1254
+ const $ = Ce(v.r, v.g, v.b), y = `rgba(${v.r}, ${v.g}, ${v.b}, 1)`;
1255
+ r.setState((w) => {
1256
+ const j = w.activeStopId;
1257
+ return !j || !w.stops[j] ? { ...w, rgba: y, hue: $ } : {
1258
+ ...w,
1259
+ rgba: y,
1260
+ hue: $,
1261
+ stops: { ...w.stops, [j]: { ...w.stops[j], color: y } }
1262
+ };
1263
+ });
1264
+ }
1265
+ s(!1);
1266
+ } catch (p) {
1267
+ console.warn("EyeDropper canceled or failed", p), s(!1);
1268
+ }
1269
+ else
1270
+ console.warn("EyeDropper API is not supported in this browser."), s(!1);
1271
+ }, h = typeof e == "function" ? (() => {
1272
+ const p = e;
1273
+ return /* @__PURE__ */ u.jsx(p, { className: C(t?.icon, "gp-eye-dropper-icon") });
1274
+ })() : e ?? null;
1275
+ return /* @__PURE__ */ u.jsx(
1276
+ "button",
1277
+ {
1278
+ type: "button",
1279
+ className: C(
1280
+ o && t?.active,
1281
+ o && "gp-eye-dropper-active",
1282
+ "gp-eye-dropper-button"
1283
+ ),
1284
+ onClick: a,
1285
+ disabled: !n,
1286
+ "aria-label": "Pick color from screen",
1287
+ "aria-pressed": o,
1288
+ "data-scope": "gradient-picker",
1289
+ "data-slot": "eye-dropper-button",
1290
+ "data-active": o ? "true" : void 0,
1291
+ "data-disabled": n ? void 0 : "true",
1292
+ children: h ?? /* @__PURE__ */ u.jsx(Ze, { className: C(t?.icon, "gp-eye-dropper-icon") })
1293
+ }
1294
+ );
1295
+ }, at = 4, tn = 24, ft = tn / 2, en = () => `stop_${Math.random().toString(36).slice(2, 9)}_${Date.now().toString(36)}`, ce = (t, e, r = 4) => {
1296
+ const n = e.slice().sort((s, a) => s.position - a.position);
1297
+ let o = t;
1298
+ for (let s = 0; s < n.length; s++)
1299
+ Math.abs(n[s].position - o) < r && (o = pt(n[s].position + r, 0, 100));
1300
+ return o;
1301
+ }, nn = (t, e) => {
1302
+ const r = pt(t, 0, 100) / 100;
1303
+ return ft + r * Math.max(1, e - 2 * ft);
1304
+ }, Mt = (t, e, r) => {
1305
+ const n = Object.values(r).filter((a) => a.id !== e).slice().sort((a, h) => a.position - h.position);
1306
+ let o = null, s = null;
1307
+ for (let a = 0; a < n.length; a++)
1308
+ if (n[a].position < t && (o = n[a]), n[a].position > t) {
1309
+ s = n[a];
1310
+ break;
1311
+ }
1312
+ return { left: o, right: s };
1313
+ }, kt = (t, e, r) => {
1314
+ let n = t;
1315
+ return e && (n = Math.max(n, e.position + at)), r && (n = Math.min(n, r.position - at)), Math.max(0, Math.min(100, n));
1316
+ }, Ut = (t, e, r, n, o) => {
1317
+ let s = Math.max(0, Math.min(100, t));
1318
+ const a = n == null ? 0 : t - n, { left: h, right: p } = Mt(s, e, r);
1319
+ if (o) {
1320
+ const i = r[o.neighborId] ?? null;
1321
+ if (!i)
1322
+ o = null;
1323
+ else if (o.dir === 1)
1324
+ if (t <= i.position - at)
1325
+ o = null;
1326
+ else if (t < i.position + at) {
1327
+ s = i.position - at;
1328
+ const v = Mt(s, e, r);
1329
+ return s = kt(s, v.left, v.right), { pos: s, block: o };
1330
+ } else
1331
+ o = null;
1332
+ else if (t >= i.position + at)
1333
+ o = null;
1334
+ else if (t > i.position - at) {
1335
+ s = i.position + at;
1336
+ const v = Mt(s, e, r);
1337
+ return s = kt(s, v.left, v.right), { pos: s, block: o };
1338
+ } else
1339
+ o = null;
1340
+ }
1341
+ if (a > 0 && p && t >= p.position - at && t < p.position + at) {
1342
+ o = { neighborId: p.id, dir: 1 }, s = p.position - at;
1343
+ const i = Mt(s, e, r);
1344
+ return s = kt(s, i.left, i.right), { pos: s, block: o };
1345
+ }
1346
+ if (a < 0 && h && t <= h.position + at && t > h.position - at) {
1347
+ o = { neighborId: h.id, dir: -1 }, s = h.position + at;
1348
+ const i = Mt(s, e, r);
1349
+ return s = kt(s, i.left, i.right), { pos: s, block: o };
1350
+ }
1351
+ return s = kt(s, h, p), { pos: s, block: o };
1352
+ }, rn = (t) => ({
1353
+ backgroundColor: t.color
1354
+ }), on = (t = [], e = []) => {
1355
+ if (t === e) return !0;
1356
+ if (t.length !== e.length) return !1;
1357
+ for (let r = 0; r < t.length; r++) if (t[r] !== e[r]) return !1;
1358
+ return !0;
1359
+ }, Dt = (t) => t.trim().replace(/\s+/g, " ").replace(/\s*,\s*/g, ", "), sn = (t, e) => {
1360
+ const r = Object.values(t ?? {}).map((o) => ({ position: Number(o.position), color: String(o.color ?? "") })).sort((o, s) => o.position - s.position), n = Object.values(e ?? {}).map((o) => ({ position: Number(o.position), color: String(o.color ?? "") })).sort((o, s) => o.position - s.position);
1361
+ if (r.length !== n.length) return !1;
1362
+ for (let o = 0; o < r.length; o++) {
1363
+ const s = r[o].position, a = n[o].position;
1364
+ if (!Number.isFinite(s) || !Number.isFinite(a) || Math.abs(s - a) > 1e-6 || r[o].color !== n[o].color) return !1;
1365
+ }
1366
+ return !0;
1367
+ }, an = (t, e, r) => {
1368
+ const n = pt(t, 0, 100);
1369
+ return e.some((a) => Math.abs((a.position ?? 0) - 100) < 1e-4) ? Math.min(n, 100 - r) : e.some((a) => Math.abs((a.position ?? 0) - 0) < 1e-4) ? Math.max(n, r) : ce(n, e, r);
1370
+ }, cn = (t) => {
1371
+ const e = Object.entries(t).map(([r, n]) => [r, n.position]);
1372
+ return e.sort((r, n) => r[0] < n[0] ? -1 : r[0] > n[0] ? 1 : 0), e.map((r) => `${r[0]}:${Math.round(r[1] * 1e3)}`).join("|");
1373
+ }, gt = (t, e, r) => {
1374
+ if (t === null) return null;
1375
+ if (!t) return e;
1376
+ if (typeof t == "function") {
1377
+ const n = t;
1378
+ return /* @__PURE__ */ u.jsx(n, { className: r });
1379
+ }
1380
+ return t;
1381
+ }, ln = ({
1382
+ classNames: t,
1383
+ label: e,
1384
+ suffix: r = "%",
1385
+ icons: n,
1386
+ hideLabel: o,
1387
+ hideSuffix: s,
1388
+ hideSteppers: a
1389
+ }) => {
1390
+ const h = ut(), p = F(null), i = X(
1391
+ (E) => {
1392
+ const A = E.activeStopId, f = A && E.stops[A] ? E.stops[A].position : null, R = cn(E.stops);
1393
+ return {
1394
+ activeStopId: A,
1395
+ activePosition: f,
1396
+ draggingStopId: E.draggingStopId,
1397
+ draftPosition: E.draftPosition,
1398
+ positionsSignature: R
1399
+ };
1400
+ },
1401
+ (E, A) => E.activeStopId === A.activeStopId && E.activePosition === A.activePosition && E.draggingStopId === A.draggingStopId && E.draftPosition === A.draftPosition && E.positionsSignature === A.positionsSignature
1402
+ ), v = nt(() => i.activeStopId ? i.draggingStopId === i.activeStopId && i.draftPosition != null ? i.draftPosition : i.activePosition ?? 0 : 0, [i.activeStopId, i.draggingStopId, i.draftPosition, i.activePosition]), $ = gt(n?.base, null, C(t?.baseIcon)), y = gt(
1403
+ n?.increment,
1404
+ /* @__PURE__ */ u.jsx(
1405
+ mt,
1406
+ {
1407
+ className: C(t?.steppers?.increment?.icon, "gp-stop-position-icon"),
1408
+ "aria-hidden": "true",
1409
+ focusable: "false"
1410
+ }
1411
+ ),
1412
+ C(t?.steppers?.increment?.icon, "gp-stop-position-icon")
1413
+ ), w = gt(
1414
+ n?.decrement,
1415
+ /* @__PURE__ */ u.jsx(
1416
+ mt,
1417
+ {
1418
+ className: C(t?.steppers?.decrement?.icon, "gp-stop-position-icon"),
1419
+ "aria-hidden": "true",
1420
+ focusable: "false"
1421
+ }
1422
+ ),
1423
+ C(t?.steppers?.decrement?.icon, "gp-stop-position-icon")
1424
+ ), j = et(
1425
+ (E) => {
1426
+ const A = i.activeStopId;
1427
+ if (!A) return;
1428
+ const f = h.getState().stops;
1429
+ if (!f[A]) return;
1430
+ const H = Object.values(f).filter((I) => I.id !== A), m = an(E, H, 4);
1431
+ h.setStops((I) => I[A] ? { ...I, [A]: { ...I[A], position: m } } : I);
1432
+ const b = h.getState().stops, M = Ot(b);
1433
+ M.length && h.setStopsOrder(M), h.setDraftPosition(null);
1434
+ },
1435
+ [i.activeStopId, h]
1436
+ ), d = (E) => {
1437
+ const A = Number(E.target.value);
1438
+ Number.isNaN(A) || j(pt(A, 0, 100));
1439
+ }, O = (E) => (A) => {
1440
+ A.preventDefault(), j(pt(v + E, 0, 100));
1441
+ }, D = (E) => {
1442
+ if (E.key !== "ArrowUp" && E.key !== "ArrowDown") return;
1443
+ E.preventDefault();
1444
+ const A = E.shiftKey ? 10 : 1, f = E.key === "ArrowUp" ? 1 : -1;
1445
+ j(pt(v + f * A, 0, 100));
1446
+ }, k = () => {
1447
+ p.current && p.current.focus();
1448
+ };
1449
+ return i.activeStopId ? /* @__PURE__ */ u.jsxs(
1450
+ "section",
1451
+ {
1452
+ className: C(t?.wrapper, "gp-stop-position-wrapper"),
1453
+ onClick: k,
1454
+ "data-scope": "gradient-picker",
1455
+ "data-part": "stop-position",
1456
+ "data-value": v,
1457
+ children: [
1458
+ !o && /* @__PURE__ */ u.jsx(
1459
+ "p",
1460
+ {
1461
+ className: C(t?.label, "gp-stop-position-label"),
1462
+ "data-part": "label",
1463
+ children: e ?? "Position"
1464
+ }
1465
+ ),
1466
+ /* @__PURE__ */ u.jsxs(
1467
+ "div",
1468
+ {
1469
+ className: C(t?.inputWrapper, "gp-stop-position-input-wrapper"),
1470
+ "data-part": "input-wrapper",
1471
+ children: [
1472
+ $,
1473
+ /* @__PURE__ */ u.jsx(
1474
+ "input",
1475
+ {
1476
+ type: "text",
1477
+ inputMode: "decimal",
1478
+ ref: p,
1479
+ value: Math.round(v * 1e3) / 1e3,
1480
+ className: C(t?.input, "gp-stop-position-input"),
1481
+ onChange: d,
1482
+ onKeyDown: D,
1483
+ role: "spinbutton",
1484
+ "aria-label": e ?? "Position",
1485
+ "aria-valuemin": 0,
1486
+ "aria-valuemax": 100,
1487
+ "aria-valuenow": v,
1488
+ "data-part": "input",
1489
+ "data-value": v
1490
+ }
1491
+ ),
1492
+ !s && /* @__PURE__ */ u.jsx(
1493
+ "span",
1494
+ {
1495
+ className: C(t?.suffix, "gp-stop-position-suffix"),
1496
+ "aria-hidden": "true",
1497
+ "data-part": "suffix",
1498
+ children: r
1499
+ }
1500
+ ),
1501
+ !a && /* @__PURE__ */ u.jsxs(
1502
+ "div",
1503
+ {
1504
+ className: C(
1505
+ t?.steppers?.wrapper,
1506
+ "gp-stop-position-steppers"
1507
+ ),
1508
+ "aria-hidden": "true",
1509
+ "data-part": "steppers",
1510
+ children: [
1511
+ /* @__PURE__ */ u.jsx(
1512
+ "button",
1513
+ {
1514
+ type: "button",
1515
+ className: C(
1516
+ t?.steppers?.increment?.button,
1517
+ "gp-stop-position-stepper-button"
1518
+ ),
1519
+ onClick: O(1),
1520
+ "aria-label": "Increase position",
1521
+ "data-part": "increment-button",
1522
+ children: y
1523
+ }
1524
+ ),
1525
+ /* @__PURE__ */ u.jsx(
1526
+ "button",
1527
+ {
1528
+ type: "button",
1529
+ className: C(
1530
+ t?.steppers?.decrement?.button,
1531
+ "gp-stop-position-stepper-button",
1532
+ "gp-stop-position-stepper-decrement"
1533
+ ),
1534
+ onClick: O(-1),
1535
+ "aria-label": "Decrease position",
1536
+ "data-part": "decrement-button",
1537
+ children: w
1538
+ }
1539
+ )
1540
+ ]
1541
+ }
1542
+ )
1543
+ ]
1544
+ }
1545
+ )
1546
+ ]
1547
+ }
1548
+ ) : null;
1549
+ }, un = ({ classNames: t }) => {
1550
+ const e = ut(), r = X((k) => k.rgba), n = F(null), o = F(null), [s, a] = st({ w: 0, h: 0 });
1551
+ W(() => {
1552
+ const k = o.current;
1553
+ if (!k) return;
1554
+ const E = new ResizeObserver((A) => {
1555
+ const f = A[0]?.contentRect;
1556
+ if (!f) return;
1557
+ const R = Math.floor(f.width), H = Math.floor(f.height);
1558
+ R <= 0 || H <= 0 || a((m) => m.w === R && m.h === H ? m : { w: R, h: H });
1559
+ });
1560
+ return E.observe(k), () => E.disconnect();
1561
+ }, []), W(() => {
1562
+ const { w: k, h: E } = s;
1563
+ if (!k || !E) return;
1564
+ const A = n.current;
1565
+ if (!A) return;
1566
+ const f = window.devicePixelRatio || 1;
1567
+ A.width = Math.round(k * f), A.height = Math.round(E * f), A.style.width = `${k}px`, A.style.height = `${E}px`;
1568
+ const R = A.getContext("2d");
1569
+ if (!R) return;
1570
+ R.setTransform(f, 0, 0, f, 0, 0), R.clearRect(0, 0, k, E);
1571
+ const H = 6;
1572
+ for (let M = 0; M < E; M += H)
1573
+ for (let I = 0; I < k; I += H) {
1574
+ const Z = (Math.floor(I / H) + Math.floor(M / H) & 1) === 1;
1575
+ R.fillStyle = Z ? "#bdbdbd" : "#ffffff", R.fillRect(I, M, H, H);
1576
+ }
1577
+ const m = J(r) ?? { r: 0, g: 0, b: 0 }, b = R.createLinearGradient(0, 0, k, 0);
1578
+ b.addColorStop(0, `rgba(${m.r}, ${m.g}, ${m.b}, 0)`), b.addColorStop(1, `rgba(${m.r}, ${m.g}, ${m.b}, 1)`), R.fillStyle = b, R.fillRect(0, 0, k, E);
1579
+ }, [s.w, s.h, r]);
1580
+ const h = yt(Se(r)), p = nt(
1581
+ () => Re(h, s.w),
1582
+ [h, s.w]
1583
+ ), i = nt(() => ({ left: p }), [p]), v = nt(() => ({ backgroundColor: r }), [r]), $ = F(null), y = F(null), w = (k) => {
1584
+ const E = yt(k), A = J(r) ?? { r: 0, g: 0, b: 0 }, f = it(A.r, A.g, A.b, E);
1585
+ e.setActiveStopColor(f);
1586
+ }, j = (k) => {
1587
+ y.current = k, $.current == null && ($.current = requestAnimationFrame(() => {
1588
+ $.current = null;
1589
+ const E = y.current;
1590
+ y.current = null, E != null && w(E);
1591
+ }));
1592
+ };
1593
+ W(() => () => {
1594
+ $.current != null && cancelAnimationFrame($.current);
1595
+ }, []);
1596
+ const d = (k) => {
1597
+ const E = o.current?.getBoundingClientRect();
1598
+ E && j(we(k, E));
1599
+ }, O = (k) => {
1600
+ k.currentTarget.setPointerCapture(k.pointerId), d(k.clientX);
1601
+ }, D = (k) => {
1602
+ (k.buttons & 1) === 1 && d(k.clientX);
1603
+ };
1604
+ return /* @__PURE__ */ u.jsxs(
1605
+ "section",
1606
+ {
1607
+ ref: o,
1608
+ className: C("gp-alpha-slider-wrapper", t?.wrapper),
1609
+ onPointerDown: O,
1610
+ onPointerMove: D,
1611
+ role: "slider",
1612
+ tabIndex: 0,
1613
+ "aria-label": "Opacity",
1614
+ "aria-orientation": "horizontal",
1615
+ "aria-valuemin": 0,
1616
+ "aria-valuemax": 1,
1617
+ "aria-valuenow": h,
1618
+ "data-scope": "gradient-picker",
1619
+ "data-slot": "root",
1620
+ "data-value": h,
1621
+ children: [
1622
+ /* @__PURE__ */ u.jsx(
1623
+ "canvas",
1624
+ {
1625
+ ref: n,
1626
+ className: C("gp-alpha-slider-canvas", t?.canvas),
1627
+ "aria-hidden": "true",
1628
+ "data-slot": "canvas"
1629
+ }
1630
+ ),
1631
+ /* @__PURE__ */ u.jsx(
1632
+ "div",
1633
+ {
1634
+ className: C("gp-alpha-slider-track", t?.track),
1635
+ "aria-hidden": "true",
1636
+ "data-slot": "track"
1637
+ }
1638
+ ),
1639
+ /* @__PURE__ */ u.jsx(
1640
+ "div",
1641
+ {
1642
+ className: C("gp-alpha-slider-thumb", t?.thumb),
1643
+ style: i,
1644
+ "aria-hidden": "true",
1645
+ "data-slot": "thumb",
1646
+ "data-value": h,
1647
+ children: /* @__PURE__ */ u.jsx(
1648
+ "div",
1649
+ {
1650
+ className: C("gp-alpha-slider-thumb-inner", t?.thumbInner),
1651
+ style: v,
1652
+ "aria-hidden": "true",
1653
+ "data-slot": "thumb-inner"
1654
+ }
1655
+ )
1656
+ }
1657
+ )
1658
+ ]
1659
+ }
1660
+ );
1661
+ }, _t = (t) => Math.max(0, Math.min(100, Math.round(t))), pn = (t) => {
1662
+ const r = t.match(
1663
+ /^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*([01]?\.?\d+))?\s*\)$/i
1664
+ )?.[1], n = r == null || r === "" ? 1 : Number(r);
1665
+ return Number.isNaN(n) ? 1 : Math.max(0, Math.min(1, n));
1666
+ }, dn = (t, e) => {
1667
+ const r = t.match(
1668
+ /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([01]?\.?\d+))?\s*\)$/i
1669
+ );
1670
+ if (!r) return t;
1671
+ const n = r[1], o = r[2], s = r[3], a = Math.max(0, Math.min(1, e));
1672
+ return `rgba(${n}, ${o}, ${s}, ${a})`;
1673
+ }, gn = ({
1674
+ classNames: t,
1675
+ updateDelay: e = 0,
1676
+ suffix: r = "%",
1677
+ icons: n
1678
+ }) => {
1679
+ const o = ut(), s = X((f) => f.rgba), a = "alpha-input", h = "alpha-input-suffix", p = F("gradient-picker:alphaInput"), [i, v] = st(100), $ = F(null), y = F(s);
1680
+ W(() => {
1681
+ y.current = s;
1682
+ const f = pn(s), R = _t(f * 100);
1683
+ v((H) => H === R ? H : R);
1684
+ }, [s]);
1685
+ const w = i >= 100, j = i <= 0, d = nt(
1686
+ () => ({
1687
+ increment: gt(
1688
+ n?.increment,
1689
+ /* @__PURE__ */ u.jsx(
1690
+ mt,
1691
+ {
1692
+ className: C(
1693
+ t?.input?.steppers?.increment?.icon,
1694
+ "alpha-input-icon",
1695
+ "alpha-increment-icon"
1696
+ ),
1697
+ "aria-hidden": "true",
1698
+ focusable: "false"
1699
+ }
1700
+ ),
1701
+ C(
1702
+ t?.input?.steppers?.increment?.icon,
1703
+ "alpha-input-icon",
1704
+ "alpha-increment-icon"
1705
+ )
1706
+ ),
1707
+ decrement: gt(
1708
+ n?.decrement,
1709
+ /* @__PURE__ */ u.jsx(
1710
+ mt,
1711
+ {
1712
+ className: C(
1713
+ t?.input?.steppers?.decrement?.icon,
1714
+ "alpha-input-icon",
1715
+ "alpha-decrement-icon"
1716
+ ),
1717
+ "aria-hidden": "true",
1718
+ focusable: "false"
1719
+ }
1720
+ ),
1721
+ C(
1722
+ t?.input?.steppers?.decrement?.icon,
1723
+ "alpha-input-icon",
1724
+ "alpha-decrement-icon"
1725
+ )
1726
+ )
1727
+ }),
1728
+ [
1729
+ n?.increment,
1730
+ n?.decrement,
1731
+ t?.input?.steppers?.increment?.icon,
1732
+ t?.input?.steppers?.decrement?.icon
1733
+ ]
1734
+ ), O = (f) => {
1735
+ const R = _t(f);
1736
+ v(R);
1737
+ const H = dn(y.current, R / 100);
1738
+ oe(
1739
+ () => {
1740
+ o.setActiveStopColor(H);
1741
+ },
1742
+ e,
1743
+ p.current
1744
+ );
1745
+ }, D = (f) => {
1746
+ const R = Number(f.target.value);
1747
+ Number.isNaN(R) || R < 0 || R > 100 || O(R);
1748
+ }, k = (f) => (R) => {
1749
+ R.preventDefault(), R.stopPropagation();
1750
+ const H = i;
1751
+ if (f === "increment" && H >= 100 || f === "decrement" && H <= 0) return;
1752
+ const m = _t(H + (f === "increment" ? 1 : -1));
1753
+ m !== H && (O(m), $.current?.select());
1754
+ }, E = (f) => {
1755
+ if (f.key !== "ArrowUp" && f.key !== "ArrowDown") return;
1756
+ f.preventDefault(), f.stopPropagation();
1757
+ const R = f.shiftKey ? 10 : 1, H = f.key === "ArrowUp" ? 1 : -1, m = _t(i + H * R);
1758
+ m !== i && (O(m), $.current?.select());
1759
+ }, A = () => {
1760
+ $.current?.select();
1761
+ };
1762
+ return /* @__PURE__ */ u.jsxs(
1763
+ "div",
1764
+ {
1765
+ className: C(t?.wrapper, "gp-alpha-input-wrapper"),
1766
+ onClick: A,
1767
+ "data-slot": "alpha-input",
1768
+ children: [
1769
+ /* @__PURE__ */ u.jsx(
1770
+ "input",
1771
+ {
1772
+ id: a,
1773
+ ref: $,
1774
+ type: "text",
1775
+ inputMode: "numeric",
1776
+ value: i,
1777
+ className: C(t?.input?.field, "gp-alpha-input-field"),
1778
+ onChange: D,
1779
+ onKeyDown: E,
1780
+ role: "spinbutton",
1781
+ "aria-label": "Alpha",
1782
+ "aria-describedby": h,
1783
+ "aria-valuemin": 0,
1784
+ "aria-valuemax": 100,
1785
+ "aria-valuenow": i,
1786
+ "data-slot": "alpha-input-field"
1787
+ }
1788
+ ),
1789
+ /* @__PURE__ */ u.jsx(
1790
+ "span",
1791
+ {
1792
+ id: h,
1793
+ className: C(t?.suffix, "gp-alpha-input-suffix"),
1794
+ "aria-hidden": "true",
1795
+ "data-slot": "alpha-input-suffix",
1796
+ children: r
1797
+ }
1798
+ ),
1799
+ /* @__PURE__ */ u.jsxs(
1800
+ "div",
1801
+ {
1802
+ className: C(
1803
+ t?.input?.steppers?.wrapper,
1804
+ "gp-alpha-input-steppers"
1805
+ ),
1806
+ "data-slot": "alpha-input-steppers",
1807
+ children: [
1808
+ /* @__PURE__ */ u.jsx(
1809
+ "button",
1810
+ {
1811
+ type: "button",
1812
+ className: C(
1813
+ t?.input?.steppers?.increment?.button,
1814
+ "gp-alpha-input-stepper-button",
1815
+ "gp-alpha-input-stepper-increment"
1816
+ ),
1817
+ onClick: k("increment"),
1818
+ disabled: w,
1819
+ "aria-label": "Increase alpha",
1820
+ "aria-controls": a,
1821
+ "data-slot": "alpha-input-stepper-increment",
1822
+ "data-action": "increment",
1823
+ children: d.increment
1824
+ }
1825
+ ),
1826
+ /* @__PURE__ */ u.jsx(
1827
+ "button",
1828
+ {
1829
+ type: "button",
1830
+ className: C(
1831
+ t?.input?.steppers?.decrement?.button,
1832
+ "gp-alpha-input-stepper-button",
1833
+ "gp-alpha-input-stepper-decrement"
1834
+ ),
1835
+ onClick: k("decrement"),
1836
+ disabled: j,
1837
+ "aria-label": "Decrease alpha",
1838
+ "aria-controls": a,
1839
+ "data-slot": "alpha-input-stepper-decrement",
1840
+ "data-action": "decrement",
1841
+ children: d.decrement
1842
+ }
1843
+ )
1844
+ ]
1845
+ }
1846
+ )
1847
+ ]
1848
+ }
1849
+ );
1850
+ }, fn = ({ classNames: t, icons: e }) => {
1851
+ const r = ut(), n = X((A) => A.angle), o = X((A) => A.format), s = F(null), a = "gp-angle-input-field", h = "gp-angle-input-degree", p = "gp-angle-input-steppers", i = n ?? 90, v = !1, $ = !1, y = gt(
1852
+ e?.angle,
1853
+ /* @__PURE__ */ u.jsx(
1854
+ Je,
1855
+ {
1856
+ className: C(t?.icon, "gp-angle-input-icon"),
1857
+ "aria-hidden": "true",
1858
+ focusable: "false"
1859
+ }
1860
+ ),
1861
+ C(t?.icon, "gp-angle-input-icon")
1862
+ ), w = gt(
1863
+ e?.increment,
1864
+ /* @__PURE__ */ u.jsx(
1865
+ mt,
1866
+ {
1867
+ className: C(
1868
+ t?.incrementIcon,
1869
+ "gp-angle-input-icon",
1870
+ "gp-angle-increment-icon"
1871
+ ),
1872
+ "aria-hidden": "true",
1873
+ focusable: "false"
1874
+ }
1875
+ ),
1876
+ C(t?.incrementIcon, "gp-angle-input-icon", "gp-angle-increment-icon")
1877
+ ), j = gt(
1878
+ e?.decrement,
1879
+ /* @__PURE__ */ u.jsx(
1880
+ mt,
1881
+ {
1882
+ className: C(
1883
+ t?.decrementIcon,
1884
+ "gp-angle-input-icon",
1885
+ "gp-angle-decrement-icon"
1886
+ ),
1887
+ "aria-hidden": "true",
1888
+ focusable: "false"
1889
+ }
1890
+ ),
1891
+ C(t?.decrementIcon, "gp-angle-input-icon", "gp-angle-decrement-icon")
1892
+ ), d = et(() => {
1893
+ r.setAngle(((n ?? 0) + 1) % 360);
1894
+ }, [n, r]), O = et(() => {
1895
+ r.setAngle(((n ?? 0) - 1 + 360) % 360);
1896
+ }, [n, r]), D = (A) => {
1897
+ A.key === "ArrowUp" ? (A.preventDefault(), d()) : A.key === "ArrowDown" && (A.preventDefault(), O());
1898
+ }, k = (A) => {
1899
+ const f = Number(A.target.value);
1900
+ if (!Number.isNaN(f)) {
1901
+ if (f > 360) {
1902
+ r.setAngle(360);
1903
+ return;
1904
+ }
1905
+ if (f < 0) {
1906
+ r.setAngle(0);
1907
+ return;
1908
+ }
1909
+ r.setAngle(f);
1910
+ }
1911
+ }, E = () => {
1912
+ s.current?.focus();
1913
+ };
1914
+ return o !== "linear-gradient" ? null : /* @__PURE__ */ u.jsxs(
1915
+ "section",
1916
+ {
1917
+ id: "gp-angle-input-wrapper",
1918
+ className: C(t?.wrapper, "gp-angle-input-wrapper"),
1919
+ "data-scope": "gradient-picker",
1920
+ "data-slot": "root",
1921
+ "data-format": o,
1922
+ "data-value": i,
1923
+ children: [
1924
+ y,
1925
+ /* @__PURE__ */ u.jsxs(
1926
+ "div",
1927
+ {
1928
+ id: "gp-angle-input-input-wrapper",
1929
+ className: C(t?.inputWrapper, "gp-angle-input-input-wrapper"),
1930
+ onClick: E,
1931
+ "data-slot": "input-wrapper",
1932
+ children: [
1933
+ /* @__PURE__ */ u.jsx(
1934
+ "input",
1935
+ {
1936
+ id: a,
1937
+ value: i,
1938
+ ref: s,
1939
+ className: C(t?.input, "gp-angle-input-field"),
1940
+ onChange: k,
1941
+ onKeyDown: D,
1942
+ inputMode: "numeric",
1943
+ role: "spinbutton",
1944
+ "aria-label": "Angle",
1945
+ "aria-valuemin": 0,
1946
+ "aria-valuemax": 360,
1947
+ "aria-valuenow": i,
1948
+ "data-slot": "input",
1949
+ "data-value": i
1950
+ }
1951
+ ),
1952
+ /* @__PURE__ */ u.jsx(
1953
+ "span",
1954
+ {
1955
+ id: h,
1956
+ className: C(t?.degree, "gp-angle-input-degree"),
1957
+ "aria-hidden": "true",
1958
+ "data-slot": "degree",
1959
+ children: "°"
1960
+ }
1961
+ )
1962
+ ]
1963
+ }
1964
+ ),
1965
+ (e?.decrement !== null || e?.increment !== null) && /* @__PURE__ */ u.jsxs(
1966
+ "div",
1967
+ {
1968
+ id: p,
1969
+ className: C(t?.steppers, "gp-angle-input-steppers"),
1970
+ "aria-hidden": "true",
1971
+ "data-slot": "steppers",
1972
+ children: [
1973
+ e?.increment !== null && /* @__PURE__ */ u.jsx(
1974
+ "button",
1975
+ {
1976
+ id: "gp-angle-input-stepper-increment",
1977
+ type: "button",
1978
+ className: C(
1979
+ t?.incrementButton,
1980
+ "gp-angle-input-stepper-button",
1981
+ "gp-angle-input-stepper-increment"
1982
+ ),
1983
+ onClick: d,
1984
+ disabled: v,
1985
+ "aria-label": "Increase angle",
1986
+ "data-slot": "increment-button",
1987
+ "data-disabled": void 0,
1988
+ children: w
1989
+ }
1990
+ ),
1991
+ e?.decrement !== null && /* @__PURE__ */ u.jsx(
1992
+ "button",
1993
+ {
1994
+ id: "gp-angle-input-stepper-decrement",
1995
+ type: "button",
1996
+ className: C(
1997
+ t?.decrementButton,
1998
+ "gp-angle-input-stepper-button",
1999
+ "gp-angle-input-stepper-decrement"
2000
+ ),
2001
+ onClick: O,
2002
+ disabled: $,
2003
+ "aria-label": "Decrease angle",
2004
+ "data-slot": "decrement-button",
2005
+ "data-disabled": void 0,
2006
+ children: j
2007
+ }
2008
+ )
2009
+ ]
2010
+ }
2011
+ )
2012
+ ]
2013
+ }
2014
+ );
2015
+ }, hn = ee(({ classNames: t }) => {
2016
+ const e = ut(), r = X((g) => g.gradient), n = X((g) => g.activeStopId), o = X((g) => g.angle), s = X((g) => g.stops), a = X((g) => g.stopsOrder), h = X((g) => g.format), p = X((g) => g.prefixes), i = X((g) => g.draftPosition), v = X((g) => g.draggingStopId), $ = X((g) => g.rgba), y = X((g) => g.updateDelay), w = r, j = nt(() => Dt(w ?? ""), [w]), [d, O] = st({ w: 0, h: 0 }), D = F(null), k = F(null), E = F(!0), A = F(null), f = F(null), R = F(0), H = F(null), m = F(null), b = F(null), M = F({}), I = F(null);
2017
+ W(() => {
2018
+ M.current = s ?? {};
2019
+ }, [s]), W(() => {
2020
+ I.current = n ?? null;
2021
+ }, [n]);
2022
+ const Z = F(
2023
+ `gradient-picker:onChange:${Math.random().toString(36).slice(2)}`
2024
+ ), P = F(e.getState().onGradientChange);
2025
+ W(() => (P.current = e.getState().onGradientChange, e.subscribe(() => {
2026
+ P.current = e.getState().onGradientChange;
2027
+ })), [e]);
2028
+ const L = nt(() => Object.values(s ?? {}).slice().sort((g, S) => g.position - S.position), [s]), G = nt(() => {
2029
+ const g = v, S = i;
2030
+ return !g || S == null ? L : L.map((N) => N.id === g ? { ...N, position: S } : N).slice().sort((N, U) => (N.position ?? 0) - (U.position ?? 0));
2031
+ }, [L, v, i]);
2032
+ W(() => {
2033
+ H.current = i ?? null;
2034
+ }, [i]), W(() => {
2035
+ if (!a) return;
2036
+ const g = Ot(s);
2037
+ on(a ?? [], g) || e.setStopsOrder(g);
2038
+ }, [s, a]), W(() => {
2039
+ if (!j || e.getState().draggingStopId) return;
2040
+ if (b.current && Dt(b.current) === j) {
2041
+ m.current = j;
2042
+ return;
2043
+ }
2044
+ if (m.current === j) return;
2045
+ const g = Wt(j);
2046
+ if (!g) {
2047
+ m.current = j;
2048
+ return;
2049
+ }
2050
+ const S = M.current ?? {}, N = g.stops ?? {};
2051
+ if (sn(S, N)) {
2052
+ m.current = j, h && h !== g.format && e.setFormat(g.format);
2053
+ const T = p?.[g.format] ?? "", _ = g.prefix ?? T;
2054
+ _ !== T && e.setPrefixes({ ...p, [g.format]: _ });
2055
+ return;
2056
+ }
2057
+ m.current = j;
2058
+ const U = Ot(N), c = I.current, x = (c && N[c] ? c : Object.keys(N)[0]) ?? null;
2059
+ e.setState((T) => {
2060
+ const _ = x ? N[x]?.color ?? "rgba(0, 0, 0, 1)" : T.rgba, z = x ? Gt(_, T.hue) : T.hue;
2061
+ return {
2062
+ ...T,
2063
+ stops: N,
2064
+ stopsOrder: U,
2065
+ activeStopId: x,
2066
+ rgba: _,
2067
+ hue: z,
2068
+ format: g.format,
2069
+ prefixes: {
2070
+ ...T.prefixes,
2071
+ [g.format]: g.prefix ?? T.prefixes[g.format]
2072
+ }
2073
+ };
2074
+ });
2075
+ }, [j, v, e]), W(() => {
2076
+ if (E.current) {
2077
+ E.current = !1;
2078
+ return;
2079
+ }
2080
+ const g = h ?? "linear-gradient", S = p?.[g] ?? "", N = Ne(
2081
+ G.map((x) => ({ position: x.position ?? 0, color: x.color })),
2082
+ { format: g, angle: o ?? 90, prefix: S }
2083
+ ), U = Dt(N);
2084
+ (b.current ? Dt(b.current) : null) !== U && (b.current = N, oe(
2085
+ () => P.current(N),
2086
+ y ?? 0,
2087
+ Z.current
2088
+ ), e.setGradient(N));
2089
+ }, [G, y, h, p, o]), W(() => {
2090
+ const g = D.current;
2091
+ if (!g) return;
2092
+ const S = new ResizeObserver((N) => {
2093
+ const U = N[0]?.contentRect;
2094
+ if (!U) return;
2095
+ const c = Math.floor(U.width), x = Math.floor(U.height);
2096
+ c <= 0 || x <= 0 || O((T) => T.w === c && T.h === x ? T : { w: c, h: x });
2097
+ });
2098
+ return S.observe(g), () => S.disconnect();
2099
+ }, []), W(() => {
2100
+ const { w: g, h: S } = d;
2101
+ if (!g || !S) return;
2102
+ const N = k.current;
2103
+ if (!N) return;
2104
+ const U = window.devicePixelRatio || 1;
2105
+ N.width = Math.round(g * U), N.height = Math.round(S * U), N.style.width = `${g}px`, N.style.height = `${S}px`;
2106
+ const c = N.getContext("2d");
2107
+ if (!c) return;
2108
+ c.setTransform(U, 0, 0, U, 0, 0), c.clearRect(0, 0, g, S);
2109
+ const x = 8;
2110
+ for (let _ = 0; _ < S; _ += x)
2111
+ for (let z = 0; z < g; z += x) {
2112
+ const rt = (Math.floor(z / x) + Math.floor(_ / x) & 1) === 1;
2113
+ c.fillStyle = rt ? "rgba(0,0,0,0.12)" : "rgba(255,255,255,0.12)", c.fillRect(z, _, x, x);
2114
+ }
2115
+ const T = c.createLinearGradient(0, 0, g, 0);
2116
+ if (G.length === 0)
2117
+ T.addColorStop(0, "rgba(0,0,0,0)"), T.addColorStop(1, "rgba(0,0,0,0)");
2118
+ else if (G.length === 1) {
2119
+ const _ = G[0];
2120
+ T.addColorStop(0, _.color), T.addColorStop(1, _.color);
2121
+ } else
2122
+ for (const _ of G) {
2123
+ const z = pt(_.position ?? 0, 0, 100) / 100;
2124
+ T.addColorStop(z, _.color);
2125
+ }
2126
+ c.fillStyle = T, c.fillRect(0, 0, g, S);
2127
+ }, [d.w, d.h, G]);
2128
+ const B = (g) => {
2129
+ const S = D.current?.getBoundingClientRect();
2130
+ if (!S) return 0;
2131
+ const N = g - R.current, c = (pt(N - S.left, ft, S.width - ft) - ft) / Math.max(1, S.width - 2 * ft);
2132
+ return pt(c * 100, 0, 100);
2133
+ }, q = (g) => (S) => {
2134
+ const N = s[g];
2135
+ if (!N) return;
2136
+ e.setActiveStopId(N.id), e.setActiveStopColor(N.color ?? "rgba(0, 0, 0, 1)"), e.setDraggingStopId(g);
2137
+ const U = S.currentTarget.getBoundingClientRect(), c = U.left + U.width / 2;
2138
+ R.current = S.clientX - c;
2139
+ const x = B(S.clientX), T = Ut(x, g, s, A.current, f.current);
2140
+ A.current = x, f.current = T.block, H.current = T.pos, e.setDraftPosition(T.pos), S.currentTarget.setPointerCapture(S.pointerId);
2141
+ }, Y = (g) => {
2142
+ const S = e.getState().draggingStopId;
2143
+ if (!S) return;
2144
+ const N = B(g.clientX), U = Ut(N, S, s, A.current, f.current);
2145
+ A.current = N, f.current = U.block;
2146
+ const c = Math.round(U.pos * 1e3) / 1e3;
2147
+ H.current !== c && (H.current = c, e.setDraftPosition(c));
2148
+ }, Q = () => {
2149
+ H.current = null, A.current = null, f.current = null, R.current = 0;
2150
+ }, ot = () => {
2151
+ const g = e.getState(), S = g.draggingStopId, N = H.current ?? g.draftPosition;
2152
+ if (Q(), !S || N == null) {
2153
+ e.setState(
2154
+ (c) => c.draggingStopId === null && c.draftPosition === null ? c : { ...c, draggingStopId: null, draftPosition: null }
2155
+ );
2156
+ return;
2157
+ }
2158
+ const U = Math.round(pt(N, 0, 100) * 1e3) / 1e3;
2159
+ e.setState((c) => {
2160
+ const x = c.stops[S];
2161
+ if (!x) return { ...c, draggingStopId: null, draftPosition: null };
2162
+ const T = {
2163
+ ...c.stops,
2164
+ [S]: { ...x, position: U }
2165
+ }, _ = Ot(T);
2166
+ return {
2167
+ ...c,
2168
+ stops: T,
2169
+ stopsOrder: _,
2170
+ draggingStopId: null,
2171
+ draftPosition: null
2172
+ };
2173
+ }), e.recomputeGradient();
2174
+ }, l = () => {
2175
+ ot();
2176
+ }, V = (g) => {
2177
+ const S = D.current?.getBoundingClientRect();
2178
+ if (!S) return 0;
2179
+ const U = (pt(g - S.left, ft, S.width - ft) - ft) / Math.max(1, S.width - 2 * ft);
2180
+ return pt(U * 100, 0, 100);
2181
+ }, K = (g) => {
2182
+ if (g.target.closest(".gp-gradient-slider-stop") || (g.buttons & 1) !== 1) return;
2183
+ const N = V(g.clientX), U = en(), c = ce(N, Object.values(s), 4), x = { id: U, position: c, color: $ };
2184
+ e.setState((T) => {
2185
+ const _ = { ...T.stops, [U]: x }, z = Ot(_);
2186
+ return { ...T, stops: _, stopsOrder: z, activeStopId: U };
2187
+ }), e.setActiveStopColor($), e.recomputeGradient(), e.setDraggingStopId(U), R.current = 0, A.current = c, f.current = null, H.current = c, e.setDraftPosition(c), g.currentTarget.setPointerCapture(g.pointerId);
2188
+ }, tt = (g) => () => {
2189
+ if (n === g) return;
2190
+ const S = s[g];
2191
+ S && (e.setActiveStopId(S.id), e.setActiveStopColor(S.color ?? "rgba(0, 0, 0, 1)"));
2192
+ }, ht = nt(() => {
2193
+ const g = s ?? {}, S = a ?? [], N = S.map((c) => g[c]).filter(Boolean), U = Object.values(g).filter((c) => !S.includes(c.id));
2194
+ return [...N, ...U];
2195
+ }, [s, a, L]);
2196
+ return W(() => {
2197
+ if (!v) return;
2198
+ const g = (N) => {
2199
+ const U = e.getState().draggingStopId;
2200
+ if (!U) return;
2201
+ const c = B(N.clientX), x = e.getState().stops, T = Ut(
2202
+ c,
2203
+ U,
2204
+ x,
2205
+ A.current,
2206
+ f.current
2207
+ );
2208
+ A.current = c, f.current = T.block;
2209
+ const _ = Math.round(T.pos * 1e3) / 1e3;
2210
+ H.current !== _ && (H.current = _, e.setDraftPosition(_));
2211
+ }, S = () => {
2212
+ ot();
2213
+ };
2214
+ return window.addEventListener("pointermove", g), window.addEventListener("pointerup", S), window.addEventListener("pointercancel", S), () => {
2215
+ window.removeEventListener("pointermove", g), window.removeEventListener("pointerup", S), window.removeEventListener("pointercancel", S);
2216
+ };
2217
+ }, [v, e]), /* @__PURE__ */ u.jsxs(
2218
+ "section",
2219
+ {
2220
+ className: C(t?.wrapper, "gp-gradient-slider-wrapper"),
2221
+ ref: D,
2222
+ onPointerDown: K,
2223
+ onPointerMove: Y,
2224
+ onPointerUp: l,
2225
+ onPointerCancel: l,
2226
+ role: "group",
2227
+ "aria-label": "Gradient stops",
2228
+ "data-scope": "gradient-picker",
2229
+ "data-slot": "gradient-slider",
2230
+ "data-format": h,
2231
+ "data-angle": o,
2232
+ "data-value": j,
2233
+ children: [
2234
+ /* @__PURE__ */ u.jsx(
2235
+ "canvas",
2236
+ {
2237
+ ref: k,
2238
+ className: C("gp-gradient-slider-canvas"),
2239
+ "aria-hidden": "true",
2240
+ "data-slot": "canvas"
2241
+ }
2242
+ ),
2243
+ ht.map((g, S) => {
2244
+ const N = n === g.id, U = v === g.id, c = U && i != null ? i : g.position, x = nn(c ?? 0, d.w);
2245
+ return /* @__PURE__ */ u.jsx(
2246
+ "div",
2247
+ {
2248
+ className: C(
2249
+ "gp-gradient-slider-stop",
2250
+ t?.stops?.[S] ?? t?.stop,
2251
+ N && "gp-gradient-slider-stop-active",
2252
+ `gp-gradient-slider-stop-${S + 1}`
2253
+ ),
2254
+ style: { left: `${x}px` },
2255
+ onPointerDown: q(g.id),
2256
+ onClick: tt(g.id),
2257
+ role: "button",
2258
+ tabIndex: 0,
2259
+ "aria-label": `Stop at ${Math.round((c ?? 0) * 10) / 10}%`,
2260
+ "aria-pressed": N,
2261
+ "data-slot": "stop",
2262
+ "data-stop-id": g.id,
2263
+ "data-selected": N ? "true" : void 0,
2264
+ "data-dragging": U ? "true" : void 0,
2265
+ "data-position": c ?? 0,
2266
+ children: /* @__PURE__ */ u.jsx(
2267
+ "div",
2268
+ {
2269
+ className: C(
2270
+ "gp-gradient-slider-stop-inner",
2271
+ `gp-gradient-slider-stop-inner-${S}`
2272
+ ),
2273
+ style: rn({
2274
+ ...g,
2275
+ position: c ?? g.position
2276
+ }),
2277
+ "aria-hidden": "true",
2278
+ "data-slot": "stop-inner",
2279
+ "data-color": g.color,
2280
+ "data-position": c ?? 0
2281
+ }
2282
+ )
2283
+ },
2284
+ g.id
2285
+ );
2286
+ })
2287
+ ]
2288
+ }
2289
+ );
2290
+ }), Jt = {
2291
+ "conic-gradient": We,
2292
+ "linear-gradient": Xe,
2293
+ "radial-gradient": Ye
2294
+ }, mn = ({
2295
+ allowedFormats: t,
2296
+ icons: e,
2297
+ classNames: r
2298
+ }) => {
2299
+ const n = ut(), o = X((p) => p.format), s = X((p) => p.prefixes), a = nt(() => !t || t.length === 0 ? Jt : Object.fromEntries(
2300
+ Object.entries(Jt).filter(
2301
+ ([p]) => t.includes(p)
2302
+ )
2303
+ ), [t]), h = (p) => () => {
2304
+ if (n.setFormat(p), p === "linear-gradient") {
2305
+ n.setPrefixes({ ...s, "linear-gradient": "" });
2306
+ return;
2307
+ }
2308
+ if (p === "radial-gradient") {
2309
+ s?.["radial-gradient"] || n.setPrefixes({ ...s, "radial-gradient": "circle at center" });
2310
+ return;
2311
+ }
2312
+ p === "conic-gradient" && (s?.["conic-gradient"] || n.setPrefixes({ ...s, "conic-gradient": "from 90deg at 50% 50%" }));
2313
+ };
2314
+ return /* @__PURE__ */ u.jsx(
2315
+ "div",
2316
+ {
2317
+ className: C(r?.wrapper, "gp-gradient-formats-wrapper"),
2318
+ role: "tablist",
2319
+ "aria-label": "Gradient formats",
2320
+ "data-scope": "gradient-picker",
2321
+ "data-slot": "gradient-formats",
2322
+ children: Object.entries(a).map(([p, i]) => {
2323
+ const v = p, $ = e?.[v];
2324
+ let y;
2325
+ if ($ == null)
2326
+ y = typeof i == "function" ? /* @__PURE__ */ u.jsx(
2327
+ i,
2328
+ {
2329
+ className: C(
2330
+ r?.button?.icon,
2331
+ r?.buttons?.[v]?.icon,
2332
+ "gp-gradient-formats-icon"
2333
+ ),
2334
+ "aria-hidden": "true"
2335
+ }
2336
+ ) : null;
2337
+ else if (typeof $ == "function") {
2338
+ const j = $;
2339
+ y = /* @__PURE__ */ u.jsx(
2340
+ j,
2341
+ {
2342
+ className: C(
2343
+ r?.button?.icon,
2344
+ r?.buttons?.[v]?.icon,
2345
+ "gp-gradient-formats-icon"
2346
+ ),
2347
+ "aria-hidden": "true"
2348
+ }
2349
+ );
2350
+ } else
2351
+ y = $;
2352
+ const w = o === p;
2353
+ return /* @__PURE__ */ u.jsx(
2354
+ "button",
2355
+ {
2356
+ type: "button",
2357
+ onClick: h(v),
2358
+ className: C(
2359
+ r?.button?.base,
2360
+ w && r?.button?.activeBase,
2361
+ r?.buttons?.[v]?.base,
2362
+ w && r?.buttons?.[v]?.activeBase,
2363
+ "gp-gradient-formats-button",
2364
+ `gp-gradient-formats-button-${p}`,
2365
+ w && "gp-gradient-formats-button-active"
2366
+ ),
2367
+ role: "tab",
2368
+ "aria-selected": w,
2369
+ "aria-label": `${p.replace("-", " ")} format`,
2370
+ tabIndex: w ? 0 : -1,
2371
+ "data-slot": "button",
2372
+ "data-format": p,
2373
+ "data-active": w ? "true" : void 0,
2374
+ "data-value": p,
2375
+ "data-prefix": s?.[v] ?? "",
2376
+ children: y
2377
+ },
2378
+ p
2379
+ );
2380
+ })
2381
+ }
2382
+ );
2383
+ }, bn = ({ className: t }) => {
2384
+ const e = X((r) => r.gradient);
2385
+ return /* @__PURE__ */ u.jsx(
2386
+ "section",
2387
+ {
2388
+ className: C(t, "gp-gradient-preview-wrapper"),
2389
+ style: { background: e },
2390
+ role: "img",
2391
+ "aria-label": "Gradient preview",
2392
+ "data-scope": "gradient-picker",
2393
+ "data-slot": "gradient-preview",
2394
+ "data-value": e
2395
+ }
2396
+ );
2397
+ }, xn = ee(
2398
+ ({ classNames: t, icon: e, onCopyClick: r }) => {
2399
+ const n = X((a) => a.gradient), o = gt(
2400
+ e,
2401
+ /* @__PURE__ */ u.jsx(ae, { className: C(t?.copyIcon, "gp-gradient-string-copy-icon") }),
2402
+ C(t?.copyIcon, "gp-gradient-string-copy-icon")
2403
+ ), s = () => {
2404
+ navigator.clipboard.writeText(n), r?.();
2405
+ };
2406
+ return /* @__PURE__ */ u.jsxs(
2407
+ "div",
2408
+ {
2409
+ className: C(t?.wrapper, "gp-gradient-string-wrapper"),
2410
+ "data-scope": "gradient-picker",
2411
+ "data-slot": "gradient-string",
2412
+ "data-value": n,
2413
+ children: [
2414
+ /* @__PURE__ */ u.jsx(
2415
+ "p",
2416
+ {
2417
+ className: C(t?.text, "gp-gradient-string-text"),
2418
+ "data-slot": "text",
2419
+ children: n
2420
+ }
2421
+ ),
2422
+ /* @__PURE__ */ u.jsx(
2423
+ "button",
2424
+ {
2425
+ className: C(t?.copyButton, "gp-gradient-string-copy-button"),
2426
+ onClick: s,
2427
+ type: "button",
2428
+ "aria-label": "Copy gradient string",
2429
+ "data-slot": "copy-button",
2430
+ children: o
2431
+ }
2432
+ )
2433
+ ]
2434
+ }
2435
+ );
2436
+ }
2437
+ ), Lt = /^(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, Cn = ({ classNames: t, copyIcon: e, onCopyClick: r }) => {
2438
+ const n = ut(), o = X((d) => d.rgba), s = gt(
2439
+ e,
2440
+ /* @__PURE__ */ u.jsx(ae, { className: C(t?.copy?.icon, "gp-hex-input-copy-icon") }),
2441
+ C(t?.copy?.icon, "gp-hex-input-copy-icon")
2442
+ ), [a, h] = st(
2443
+ It(o)?.replace("#", "") || ""
2444
+ ), [p, i] = st(
2445
+ () => Lt.test(a)
2446
+ ), v = F(null), $ = F(a);
2447
+ W(() => {
2448
+ $.current = a;
2449
+ }, [a]), W(() => {
2450
+ const d = $.current;
2451
+ if (Lt.test(d)) {
2452
+ const D = Et(d);
2453
+ if (D && $t(D, o)) return;
2454
+ }
2455
+ const O = It(o)?.replace("#", "") || "";
2456
+ h(O), i(Lt.test(O));
2457
+ }, [o]);
2458
+ const y = (d) => {
2459
+ const O = d.target.value.replace(/[^0-9a-fA-F]/g, "").slice(0, 6);
2460
+ h(O);
2461
+ const D = Lt.test(O);
2462
+ if (i(D), !D) return;
2463
+ const k = Et(O);
2464
+ k && n.setActiveStopColor(k);
2465
+ }, w = () => {
2466
+ navigator.clipboard.writeText(a), r?.();
2467
+ }, j = () => {
2468
+ v.current?.select();
2469
+ };
2470
+ return /* @__PURE__ */ u.jsxs(
2471
+ "div",
2472
+ {
2473
+ className: C(t?.wrapper, "gp-hex-input-wrapper"),
2474
+ onClick: j,
2475
+ "data-scope": "gradient-picker",
2476
+ "data-slot": "hex-input",
2477
+ "data-invalid": p ? void 0 : "true",
2478
+ "data-value": a,
2479
+ children: [
2480
+ /* @__PURE__ */ u.jsx(
2481
+ "p",
2482
+ {
2483
+ className: C(t?.prefix, "gp-hex-input-prefix"),
2484
+ "aria-hidden": "true",
2485
+ "data-slot": "prefix",
2486
+ children: "#"
2487
+ }
2488
+ ),
2489
+ /* @__PURE__ */ u.jsx(
2490
+ "input",
2491
+ {
2492
+ className: C(
2493
+ t?.input,
2494
+ "gp-hex-input-field",
2495
+ !p && a.length > 0 && "gp-hex-input-field--invalid"
2496
+ ),
2497
+ ref: v,
2498
+ "aria-label": "Hex color",
2499
+ "aria-invalid": !p,
2500
+ type: "text",
2501
+ placeholder: "000000",
2502
+ value: a,
2503
+ onChange: y,
2504
+ "data-slot": "input"
2505
+ }
2506
+ ),
2507
+ /* @__PURE__ */ u.jsx(
2508
+ "button",
2509
+ {
2510
+ onClick: w,
2511
+ className: C(t?.copy?.button, "gp-hex-input-copy-button"),
2512
+ type: "button",
2513
+ "aria-label": "Copy hex color",
2514
+ "data-slot": "copy-button",
2515
+ children: s
2516
+ }
2517
+ )
2518
+ ]
2519
+ }
2520
+ );
2521
+ }, Sn = ({ className: t }) => {
2522
+ const e = X((n) => n.rgba), r = It(e) || "";
2523
+ return /* @__PURE__ */ u.jsx(
2524
+ "div",
2525
+ {
2526
+ className: C(t, "gp-hex-preview"),
2527
+ style: { backgroundColor: r },
2528
+ role: "img",
2529
+ "aria-label": "Hex color preview",
2530
+ "data-scope": "gradient-picker",
2531
+ "data-slot": "hex-preview",
2532
+ "data-value": r
2533
+ }
2534
+ );
2535
+ }, Kt = ["r", "g", "b", "a"], Ht = (t, e) => {
2536
+ const r = t.match(
2537
+ /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d*\.?\d+))?\s*\)/
2538
+ );
2539
+ if (!r) return 0;
2540
+ const n = parseInt(r[1], 10), o = parseInt(r[2], 10), s = parseInt(r[3], 10), a = r[4] !== void 0 ? Math.round(parseFloat(r[4]) * 255) : 255;
2541
+ switch (e) {
2542
+ case "r":
2543
+ return n;
2544
+ case "g":
2545
+ return o;
2546
+ case "b":
2547
+ return s;
2548
+ case "a":
2549
+ return a;
2550
+ default:
2551
+ return 0;
2552
+ }
2553
+ }, le = (t) => ({
2554
+ r: Ht(t, "r"),
2555
+ g: Ht(t, "g"),
2556
+ b: Ht(t, "b"),
2557
+ a: Ht(t, "a")
2558
+ }), Bt = (t, e) => {
2559
+ const r = le(t);
2560
+ return (n) => {
2561
+ const o = { ...r, [e]: n }, s = e === "a" ? n / 255 : o.a / 255;
2562
+ return `rgba(${o.r}, ${o.g}, ${o.b}, ${s})`;
2563
+ };
2564
+ }, vn = (t, e) => t.r === e.r && t.g === e.g && t.b === e.b && t.a === e.a, wn = ({ classNames: t, icons: e }) => {
2565
+ const r = ut(), n = X((d) => d.rgba), [o, s] = st({
2566
+ r: 0,
2567
+ g: 0,
2568
+ b: 0,
2569
+ a: 255
2570
+ }), a = F({
2571
+ r: null,
2572
+ g: null,
2573
+ b: null,
2574
+ a: null
2575
+ }), h = F(n), p = F(""), i = nt(() => Kt.reduce(
2576
+ (d, O) => {
2577
+ const D = C(
2578
+ t?.inputs?.[O]?.steppers?.increment?.icon,
2579
+ "gp-rgba-increment-icon",
2580
+ `gp-rgba-${O}-increment-icon`
2581
+ ), k = C(
2582
+ t?.inputs?.[O]?.steppers?.decrement?.icon,
2583
+ "gp-rgba-decrement-icon",
2584
+ `gp-rgba-${O}-decrement-icon`
2585
+ );
2586
+ return {
2587
+ ...d,
2588
+ [O]: {
2589
+ increment: gt(
2590
+ e?.increment,
2591
+ /* @__PURE__ */ u.jsx(
2592
+ mt,
2593
+ {
2594
+ id: `rgba-input-${O}-increment-icon`,
2595
+ className: D
2596
+ }
2597
+ ),
2598
+ D
2599
+ ),
2600
+ decrement: gt(
2601
+ e?.decrement,
2602
+ /* @__PURE__ */ u.jsx(
2603
+ mt,
2604
+ {
2605
+ id: `rgba-input-${O}-decrement-icon`,
2606
+ className: k
2607
+ }
2608
+ ),
2609
+ k
2610
+ )
2611
+ }
2612
+ };
2613
+ },
2614
+ {}
2615
+ ), [e?.increment, e?.decrement, t?.inputs]);
2616
+ W(() => {
2617
+ h.current = n;
2618
+ }, [n]), W(() => {
2619
+ if (p.current && $t(p.current, n))
2620
+ return;
2621
+ p.current = n;
2622
+ const d = le(n);
2623
+ s((O) => vn(O, d) ? O : d);
2624
+ }, [n]);
2625
+ const v = (d) => Math.max(0, Math.min(255, Math.round(d))), $ = (d) => (O) => {
2626
+ const D = Number(O.target.value);
2627
+ if (Number.isNaN(D)) return;
2628
+ const k = Bt(n, d)(v(D));
2629
+ $t(k, n) || r.setActiveStopColor(k);
2630
+ }, y = (d, O) => (D) => {
2631
+ D.preventDefault(), D.stopPropagation();
2632
+ const k = o[d];
2633
+ if (O === "increment" && k >= 255 || O === "decrement" && k <= 0) return;
2634
+ const A = v(k + (O === "increment" ? 1 : -1)), f = Bt(n, d)(A);
2635
+ h.current = f, !$t(f, n) && r.setActiveStopColor(f);
2636
+ }, w = (d) => (O) => {
2637
+ if (O.key !== "ArrowUp" && O.key !== "ArrowDown") return;
2638
+ O.preventDefault(), O.stopPropagation();
2639
+ const D = O.shiftKey ? 10 : 1, k = O.key === "ArrowUp" ? 1 : -1, E = o[d], A = v(E + k * D);
2640
+ if (A === E) return;
2641
+ const f = Bt(n, d)(A);
2642
+ $t(f, n) || (r.setActiveStopColor(f), a.current[d]?.select());
2643
+ }, j = (d) => () => {
2644
+ a.current[d]?.select();
2645
+ };
2646
+ return /* @__PURE__ */ u.jsx(
2647
+ "section",
2648
+ {
2649
+ className: C(t?.wrapper, "gp-rgba-input-wrapper"),
2650
+ "data-scope": "gradient-picker",
2651
+ "data-slot": "rgba-input",
2652
+ children: Kt.map((d) => /* @__PURE__ */ u.jsxs(
2653
+ "div",
2654
+ {
2655
+ className: C(
2656
+ t?.input?.wrapper,
2657
+ "gp-rgba-input-field-wrapper",
2658
+ `gp-rgba-input-field-${d}-wrapper`
2659
+ ),
2660
+ onClick: j(d),
2661
+ "data-slot": "field-wrapper",
2662
+ "data-channel": d,
2663
+ children: [
2664
+ /* @__PURE__ */ u.jsx(
2665
+ "input",
2666
+ {
2667
+ ref: (O) => {
2668
+ a.current[d] = O;
2669
+ },
2670
+ className: C(
2671
+ t?.input?.field,
2672
+ t?.inputs?.[d]?.field,
2673
+ "gp-rgba-input-field",
2674
+ `gp-rgba-input-${d}-field`
2675
+ ),
2676
+ value: o[d],
2677
+ inputMode: "numeric",
2678
+ onChange: $(d),
2679
+ onKeyDown: w(d),
2680
+ role: "spinbutton",
2681
+ "aria-label": `${d.toUpperCase()} channel`,
2682
+ "aria-valuemin": 0,
2683
+ "aria-valuemax": 255,
2684
+ "aria-valuenow": o[d],
2685
+ "data-slot": "input",
2686
+ "data-channel": d,
2687
+ "data-value": o[d]
2688
+ }
2689
+ ),
2690
+ /* @__PURE__ */ u.jsxs(
2691
+ "div",
2692
+ {
2693
+ className: C(
2694
+ t?.inputs?.[d]?.steppers?.wrapper,
2695
+ "gp-rgba-input-steppers"
2696
+ ),
2697
+ "aria-hidden": "true",
2698
+ "data-slot": "steppers",
2699
+ "data-channel": d,
2700
+ children: [
2701
+ /* @__PURE__ */ u.jsx(
2702
+ "button",
2703
+ {
2704
+ type: "button",
2705
+ className: C(
2706
+ t?.inputs?.[d]?.steppers?.increment?.button,
2707
+ "gp-rgba-input-stepper-button",
2708
+ "gp-rgba-input-stepper-increment",
2709
+ `gp-rgba-input-stepper-increment-${d}`
2710
+ ),
2711
+ onClick: y(d, "increment"),
2712
+ "aria-label": `Increase ${d.toUpperCase()}`,
2713
+ "data-slot": "increment-button",
2714
+ "data-channel": d,
2715
+ children: i[d].increment
2716
+ }
2717
+ ),
2718
+ /* @__PURE__ */ u.jsx(
2719
+ "button",
2720
+ {
2721
+ type: "button",
2722
+ className: C(
2723
+ t?.inputs?.[d]?.steppers?.decrement?.button,
2724
+ "gp-rgba-input-stepper-button",
2725
+ "gp-rgba-input-stepper-decrement",
2726
+ `gp-rgba-input-stepper-decrement-${d}`
2727
+ ),
2728
+ onClick: y(d, "decrement"),
2729
+ "aria-label": `Decrease ${d.toUpperCase()}`,
2730
+ "data-slot": "decrement-button",
2731
+ "data-channel": d,
2732
+ children: i[d].decrement
2733
+ }
2734
+ )
2735
+ ]
2736
+ }
2737
+ )
2738
+ ]
2739
+ },
2740
+ d
2741
+ ))
2742
+ }
2743
+ );
2744
+ }, Rn = ({ className: t }) => {
2745
+ const e = X((r) => r.rgba);
2746
+ return /* @__PURE__ */ u.jsx(
2747
+ "div",
2748
+ {
2749
+ className: C("gp-rgba-preview", t),
2750
+ style: { backgroundColor: e },
2751
+ role: "img",
2752
+ "aria-label": "RGBA color preview",
2753
+ "data-scope": "gradient-picker",
2754
+ "data-slot": "rgba-preview",
2755
+ "data-value": e
2756
+ }
2757
+ );
2758
+ }, In = "_wrapper_dqprj_11", Qt = {
2759
+ wrapper: In,
2760
+ "map-item": "_map-item_dqprj_31"
2761
+ }, yn = {
2762
+ "linear-gradient": "",
2763
+ "radial-gradient": "circle at center",
2764
+ "conic-gradient": "from 90deg at 50% 50%"
2765
+ }, jn = process.env.NODE_ENV !== "production", Pn = (t, e) => {
2766
+ if (jn && t && e)
2767
+ throw new Error("[GradientPicker] Use either `grid` or `children`, not both.");
2768
+ }, $n = (t) => {
2769
+ const {
2770
+ gradient: e,
2771
+ onChange: r,
2772
+ updateDelay: n = 0,
2773
+ childrenProps: o,
2774
+ wrapperClassName: s,
2775
+ store: a
2776
+ } = t;
2777
+ Pn("grid" in t, "children" in t);
2778
+ const h = F(null);
2779
+ !a && !h.current && (h.current = se({
2780
+ gradient: e,
2781
+ onGradientChange: r,
2782
+ updateDelay: n,
2783
+ initialStops: re
2784
+ }));
2785
+ const p = a ?? h.current;
2786
+ W(() => p.setGradient(e), [e, p]), W(() => p.setOnGradientChange(r), [r, p]), W(() => p.setUpdateDelay(n), [n, p]);
2787
+ const i = F(!1);
2788
+ W(() => {
2789
+ i.current = !1;
2790
+ }, [p]), W(() => {
2791
+ if (i.current) return;
2792
+ i.current = !0;
2793
+ const w = Wt(e);
2794
+ if (!w) return;
2795
+ const j = Object.keys(w.stops)[0] ?? null;
2796
+ p.setState((d) => {
2797
+ const D = (j ? w.stops[j] : null)?.color ?? "rgba(0, 0, 0, 1)", k = Gt(D, Ft(D)), E = k === 0 && Ft(D) > 300 ? zt : k;
2798
+ return {
2799
+ ...d,
2800
+ format: w.format,
2801
+ prefixes: {
2802
+ ...d.prefixes,
2803
+ [w.format]: w.prefix || d.prefixes[w.format] || yn[w.format]
2804
+ },
2805
+ stops: w.stops,
2806
+ stopsOrder: Object.keys(w.stops),
2807
+ activeStopId: j,
2808
+ rgba: D,
2809
+ hue: E
2810
+ };
2811
+ });
2812
+ }, [e, p]);
2813
+ const v = nt(
2814
+ () => ({
2815
+ "alpha-slider": /* @__PURE__ */ u.jsx(un, { ...o?.alphaSlider }),
2816
+ "alpha-input": /* @__PURE__ */ u.jsx(gn, { ...o?.alphaInput }),
2817
+ "color-square": /* @__PURE__ */ u.jsx(Be, { ...o?.colorSquare }),
2818
+ "gradient-slider": /* @__PURE__ */ u.jsx(hn, { classNames: o?.gradientSlider?.classNames }),
2819
+ "hue-slider": /* @__PURE__ */ u.jsx(qe, { ...o?.hueSlider }),
2820
+ "stop-delete": /* @__PURE__ */ u.jsx(Ke, { ...o?.deleteStop }),
2821
+ "gradient-formats": /* @__PURE__ */ u.jsx(mn, { ...o?.gradientFormats }),
2822
+ "eye-dropper": /* @__PURE__ */ u.jsx(Qe, { ...o?.eyeDropper }),
2823
+ "angle-input": /* @__PURE__ */ u.jsx(fn, { ...o?.angleInput }),
2824
+ "gradient-preview": /* @__PURE__ */ u.jsx(bn, { ...o?.gradientPreview }),
2825
+ "stop-position": /* @__PURE__ */ u.jsx(ln, { ...o?.stopPosition }),
2826
+ "gradient-string": /* @__PURE__ */ u.jsx(xn, { ...o?.gradientString }),
2827
+ "hex-input": /* @__PURE__ */ u.jsx(Cn, { ...o?.hexInput }),
2828
+ "hex-preview": /* @__PURE__ */ u.jsx(Sn, { ...o?.hexPreview }),
2829
+ "rgba-input": /* @__PURE__ */ u.jsx(wn, { ...o?.rgbaInput }),
2830
+ "rgba-preview": /* @__PURE__ */ u.jsx(Rn, { ...o?.rgbaPreview })
2831
+ }),
2832
+ [o]
2833
+ ), $ = (w, j) => typeof w == "string" ? /* @__PURE__ */ u.jsx(ge, { children: v[w] }, j) : /* @__PURE__ */ u.jsx("div", { className: C(w.className, Qt["map-item"]), children: w.children.map((d, O) => $(d, `${j.toString()}-${O}`)) }, j), y = nt(() => "grid" in t ? t.grid?.map((w, j) => $(w, j)) : t.children, [t.grid, t.children, v]);
2834
+ return /* @__PURE__ */ u.jsx(Ue, { store: p, children: /* @__PURE__ */ u.jsx("section", { className: C(Qt.wrapper, s), children: y }) });
2835
+ };
2836
+ export {
2837
+ gn as AlphaInput,
2838
+ un as AlphaSlider,
2839
+ fn as AngleInput,
2840
+ Kt as CHANNELS,
2841
+ Be as ColorSquare,
2842
+ Ke as DeleteStop,
2843
+ Qe as EyeDropper,
2844
+ Jt as GRADIENT_FORMATS,
2845
+ $n as GradientPicker,
2846
+ bn as GradientPreview,
2847
+ hn as GradientSlider,
2848
+ xn as GradientString,
2849
+ Lt as HEX_VALID_RE,
2850
+ zt as HUE_MAX,
2851
+ Cn as HexInput,
2852
+ Sn as HexPreview,
2853
+ qe as HueSlider,
2854
+ at as MIN_GAP,
2855
+ mn as PickGradientFormats,
2856
+ ft as R,
2857
+ wn as RgbaInput,
2858
+ Rn as RgbaPreview,
2859
+ tn as STOP_SIZE,
2860
+ ln as StopPosition,
2861
+ Ut as applyJump,
2862
+ He as buildGradientString,
2863
+ vn as channelsEqual,
2864
+ _t as clampPercent,
2865
+ bt as coerceToRgba,
2866
+ an as enforceGapWithEdge,
2867
+ Vt as ensureOrder,
2868
+ Ht as getChannelFromRgba,
2869
+ le as getChannelsFromRgba,
2870
+ rn as getStopInnerStyle,
2871
+ De as isHex,
2872
+ _e as isRgba,
2873
+ nn as leftPxFromPercent,
2874
+ en as makeId,
2875
+ cn as makePositionsSignature,
2876
+ Le as nextStopId,
2877
+ Dt as normalizeGradientString,
2878
+ pn as parseAlphaFromRgba,
2879
+ Mn as parseLinearAngle,
2880
+ on as sameIds,
2881
+ dn as setAlphaInRgba,
2882
+ ce as stopGap,
2883
+ sn as stopsEquivalentIgnoringIds,
2884
+ Bt as updateRgbaChannel,
2885
+ kn as useGradient
2886
+ };