@snowcone-app/canvas 0.44.2 → 0.46.1

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 (34) hide show
  1. package/ERROR_CONTRACT.md +1 -1
  2. package/dist/{ContextualToolbars-rCZo-KCm.js → ContextualToolbars-5tHC6s0Y.js} +4 -4
  3. package/dist/{ContextualToolbars-rCZo-KCm.js.map → ContextualToolbars-5tHC6s0Y.js.map} +1 -1
  4. package/dist/{EditorCanvasImpl-Dcati77U.js → EditorCanvasImpl-Cd_umlTI.js} +6 -6
  5. package/dist/{EditorCanvasImpl-Dcati77U.js.map → EditorCanvasImpl-Cd_umlTI.js.map} +1 -1
  6. package/dist/{ImagePanel-DhOWKvIN.js → ImagePanel-bW3yr6Ac.js} +264 -259
  7. package/dist/{ImagePanel-DhOWKvIN.js.map → ImagePanel-bW3yr6Ac.js.map} +1 -1
  8. package/dist/{SnowconeCanvas-DjszZvte.js → SnowconeCanvas-crxPwbib.js} +441 -439
  9. package/dist/SnowconeCanvas-crxPwbib.js.map +1 -0
  10. package/dist/advanced.mjs +9 -9
  11. package/dist/components/editor/EditorPreview.d.ts +19 -8
  12. package/dist/components/editor/index.d.ts +1 -1
  13. package/dist/components/embed/SnowconeCanvas.d.ts +6 -0
  14. package/dist/components/embed/kernel.d.ts +2 -0
  15. package/dist/{custom-icons-C4bzABm2.js → custom-icons-DQRp8GhF.js} +2 -2
  16. package/dist/{custom-icons-C4bzABm2.js.map → custom-icons-DQRp8GhF.js.map} +1 -1
  17. package/dist/{design-builder-DCHVrEFV.js → design-builder-sH53Og6j.js} +598 -589
  18. package/dist/design-builder-sH53Og6j.js.map +1 -0
  19. package/dist/{embed-DNWM7gZL.js → embed-DvN5BVmQ.js} +669 -657
  20. package/dist/embed-DvN5BVmQ.js.map +1 -0
  21. package/dist/embed.mjs +4 -4
  22. package/dist/index.mjs +7 -7
  23. package/dist/{template-fields-CK7Uvvc8.js → template-fields-BaQG0CJY.js} +3 -3
  24. package/dist/{template-fields-CK7Uvvc8.js.map → template-fields-BaQG0CJY.js.map} +1 -1
  25. package/dist/testing.mjs +2 -2
  26. package/dist/{useCommands-BrkGKdXr.js → useCommands-F-b_SwW-.js} +3 -3
  27. package/dist/{useCommands-BrkGKdXr.js.map → useCommands-F-b_SwW-.js.map} +1 -1
  28. package/dist/{validation-CaBO9Iw-.js → validation-hn5ZX8Po.js} +8 -8
  29. package/dist/{validation-CaBO9Iw-.js.map → validation-hn5ZX8Po.js.map} +1 -1
  30. package/example/package.json +1 -1
  31. package/package.json +4 -3
  32. package/dist/SnowconeCanvas-DjszZvte.js.map +0 -1
  33. package/dist/design-builder-DCHVrEFV.js.map +0 -1
  34. package/dist/embed-DNWM7gZL.js.map +0 -1
@@ -1,13 +1,13 @@
1
- import { jsx as e, jsxs as c, Fragment as oe } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as c, Fragment as ie } from "react/jsx-runtime";
2
2
  import * as cs from "react";
3
- import Ge, { useMemo as _e, useState as o, useRef as B, useEffect as ne, useCallback as he } from "react";
4
- import { b as rs, c as as, d as ns, p as Pe } from "./design-builder-DCHVrEFV.js";
5
- import { u as os, c as is, a as Fe, D as ls, I as k, i as fe, B as q, b as ds, d as ms, C as us } from "./useCommands-BrkGKdXr.js";
3
+ import Ge, { useMemo as _e, useState as o, useRef as B, useEffect as oe, useCallback as ge } from "react";
4
+ import { b as rs, c as as, d as ns, p as Pe } from "./design-builder-sH53Og6j.js";
5
+ import { u as os, c as is, a as Fe, D as ls, I as E, i as he, B as q, b as ds, d as us, C as ms } from "./useCommands-F-b_SwW-.js";
6
6
  import { c as Ye, I as fs } from "./FontAnalyzer-Ds3Wdba7.js";
7
- import { T as M, S as Ve, a as ke, I as Ae, L as Ee } from "./custom-icons-C4bzABm2.js";
7
+ import { T as M, S as Ve, a as ke, I as Ae, L as Ee } from "./custom-icons-DQRp8GhF.js";
8
8
  import { i as Ue } from "./guards-DwYEoqcn.js";
9
9
  const Xe = cs.forwardRef(
10
- ({ className: d, isInvalid: t, disabled: x, readOnly: R, required: u, variant: z, ...r }, h) => {
10
+ ({ className: u, isInvalid: t, disabled: b, readOnly: R, required: f, variant: z, ...r }, g) => {
11
11
  const n = os(), m = z ?? (n.variant === "default" ? "filled" : "default");
12
12
  return /* @__PURE__ */ e(
13
13
  "textarea",
@@ -22,12 +22,12 @@ const Xe = cs.forwardRef(
22
22
  m === "default" && "sc:bg-field sc:shadow-soft sc:dark:shadow-none",
23
23
  m === "filled" && "sc:bg-[var(--color-field-on-surface)]",
24
24
  t && "sc:ring-2 sc:ring-danger sc:focus-visible:ring-danger",
25
- d
25
+ u
26
26
  ),
27
- ref: h,
28
- disabled: x,
27
+ ref: g,
28
+ disabled: b,
29
29
  readOnly: R,
30
- required: u,
30
+ required: f,
31
31
  "aria-invalid": t,
32
32
  ...r
33
33
  }
@@ -38,45 +38,45 @@ Xe.displayName = "Textarea";
38
38
  const We = Xe;
39
39
  We.displayName = "TextArea";
40
40
  const we = Ye("ImageBrowser"), hs = "Image search is temporarily unavailable.", Be = "Image generation is temporarily unavailable.", gs = "Vector search is temporarily unavailable.", $e = "Background removal is temporarily unavailable.";
41
- function ps(d, t) {
42
- const x = d instanceof Error ? d.message : "";
43
- return !x || /VITE_|NEXT_PUBLIC_|\.env/i.test(x) ? t : x;
41
+ function ps(u, t) {
42
+ const b = u instanceof Error ? u.message : "";
43
+ return !b || /VITE_|NEXT_PUBLIC_|\.env/i.test(b) ? t : b;
44
44
  }
45
- const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint" }, je = Ge.memo(function({ image: t, onImageSelect: x, fixedHeight: R = !1 }) {
46
- const [u, z] = o(!1), [r, h] = o(!1), [n, m] = o("top"), a = B(null), p = B(null), A = B(null), b = B(!0), [T, N] = o(!1), y = B(null), S = () => {
47
- r || x(t);
45
+ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint" }, je = Ge.memo(function({ image: t, onImageSelect: b, fixedHeight: R = !1 }) {
46
+ const [f, z] = o(!1), [r, g] = o(!1), [n, m] = o("top"), a = B(null), p = B(null), A = B(null), x = B(!0), [T, I] = o(!1), k = B(null), S = () => {
47
+ r || b(t);
48
48
  }, Z = (D) => {
49
49
  if (!A.current) return "top";
50
- const v = A.current.getBoundingClientRect(), re = D.clientX - v.left, j = D.clientY - v.top, J = v.width, f = v.height, U = {
51
- top: j,
52
- bottom: f - j,
50
+ const v = A.current.getBoundingClientRect(), re = D.clientX - v.left, H = D.clientY - v.top, J = v.width, h = v.height, U = {
51
+ top: H,
52
+ bottom: h - H,
53
53
  left: re,
54
54
  right: J - re
55
55
  }, X = Math.min(U.top, U.bottom, U.left, U.right);
56
56
  return X === U.top ? "top" : X === U.bottom ? "bottom" : X === U.left ? "left" : "right";
57
57
  }, te = (D) => {
58
58
  const v = Z(D);
59
- y.current && (cancelAnimationFrame(y.current), y.current = null), v !== n ? (N(!0), m(v), y.current = requestAnimationFrame(() => {
60
- y.current = requestAnimationFrame(() => {
61
- N(!1), z(!0), y.current = null;
59
+ k.current && (cancelAnimationFrame(k.current), k.current = null), v !== n ? (I(!0), m(v), k.current = requestAnimationFrame(() => {
60
+ k.current = requestAnimationFrame(() => {
61
+ I(!1), z(!0), k.current = null;
62
62
  });
63
- })) : (m(v), z(!0)), b.current = !1;
64
- }, H = (D) => {
65
- y.current && (cancelAnimationFrame(y.current), y.current = null);
63
+ })) : (m(v), z(!0)), x.current = !1;
64
+ }, $ = (D) => {
65
+ k.current && (cancelAnimationFrame(k.current), k.current = null);
66
66
  const v = Z(D);
67
- m(v), N(!1), z(!1);
67
+ m(v), I(!1), z(!1);
68
68
  }, C = () => {
69
69
  p.current && (clearTimeout(p.current), p.current = null), a.current = setTimeout(() => {
70
- h(!0);
70
+ g(!0);
71
71
  }, 400);
72
72
  }, ce = () => {
73
- a.current && (clearTimeout(a.current), a.current = null), h(!1);
74
- }, ie = () => {
73
+ a.current && (clearTimeout(a.current), a.current = null), g(!1);
74
+ }, le = () => {
75
75
  a.current && (clearTimeout(a.current), a.current = null), p.current && (clearTimeout(p.current), p.current = null);
76
- }, $ = () => {
77
- h(!1);
78
- }, P = t.source === "unsplash" ? "Unsplash" : "Pixabay", le = u || r, Y = () => {
79
- if (!u) return "none";
76
+ }, j = () => {
77
+ g(!1);
78
+ }, P = t.source === "unsplash" ? "Unsplash" : "Pixabay", de = f || r, Y = () => {
79
+ if (!f) return "none";
80
80
  switch (n) {
81
81
  case "top":
82
82
  return `scale(${1.12}) translateY(5%)`;
@@ -96,7 +96,7 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
96
96
  ref: A,
97
97
  onClick: S,
98
98
  onMouseEnter: te,
99
- onMouseLeave: H,
99
+ onMouseLeave: $,
100
100
  className: `sc:group sc:relative sc:cursor-pointer sc:overflow-hidden ${R ? "sc:h-full sc:rounded-xs" : "sc:break-inside-avoid sc:rounded-lg"}`,
101
101
  children: [
102
102
  /* @__PURE__ */ e(
@@ -107,30 +107,30 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
107
107
  className: `sc:duration-500 sc:ease-out ${T ? "sc:transition-none" : "sc:transition-transform"} ${R ? "sc:h-full sc:w-full sc:object-cover" : "sc:w-full sc:object-cover"}`,
108
108
  style: {
109
109
  transform: Y(),
110
- filter: u ? "brightness(1.04)" : void 0
110
+ filter: f ? "brightness(1.04)" : void 0
111
111
  }
112
112
  }
113
113
  ),
114
114
  /* @__PURE__ */ e("div", { className: "sc:absolute sc:top-2 sc:right-2 sc:z-10", children: /* @__PURE__ */ e(
115
115
  "button",
116
116
  {
117
- className: `sc:relative sc:flex sc:h-6 sc:w-6 sc:items-center sc:justify-center sc:rounded-full sc:bg-black/50 sc:transition-all sc:duration-300 sc:ease-in-out sc:hover:scale-110 ${le ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
117
+ className: `sc:relative sc:flex sc:h-6 sc:w-6 sc:items-center sc:justify-center sc:rounded-full sc:bg-black/50 sc:transition-all sc:duration-300 sc:ease-in-out sc:hover:scale-110 ${de ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
118
118
  "aria-label": "Image info",
119
119
  onMouseEnter: C,
120
120
  onMouseLeave: ce,
121
- children: /* @__PURE__ */ e(k, { icon: "lucide:aperture", className: "sc:size-4 sc:text-white/80" })
121
+ children: /* @__PURE__ */ e(E, { icon: "lucide:aperture", className: "sc:size-4 sc:text-white/80" })
122
122
  }
123
123
  ) }),
124
124
  /* @__PURE__ */ e(
125
125
  "div",
126
126
  {
127
127
  className: `sc:absolute sc:inset-x-0 sc:bottom-0 sc:z-0 sc:bg-linear-to-t sc:from-black/80 sc:via-black/60 sc:to-transparent sc:px-3 sc:py-3 sc:pt-8 sc:transition-transform sc:duration-300 sc:ease-out ${r ? "sc:translate-y-0" : "sc:translate-y-full"}`,
128
- onMouseEnter: ie,
129
- onMouseLeave: $,
128
+ onMouseEnter: le,
129
+ onMouseLeave: j,
130
130
  children: /* @__PURE__ */ c("div", { className: "sc:flex sc:flex-col sc:gap-1", children: [
131
131
  /* @__PURE__ */ c("div", { className: "sc:flex sc:items-center sc:gap-2", children: [
132
132
  /* @__PURE__ */ e(
133
- k,
133
+ E,
134
134
  {
135
135
  icon: t.source === "unsplash" ? "simple-icons:unsplash" : "simple-icons:pixabay",
136
136
  className: "sc:size-3 sc:text-white/80"
@@ -152,7 +152,7 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
152
152
  children: t.attribution.name
153
153
  }
154
154
  ) : t.attribution.name,
155
- t.attribution.sourceUrl && /* @__PURE__ */ c(oe, { children: [
155
+ t.attribution.sourceUrl && /* @__PURE__ */ c(ie, { children: [
156
156
  " ",
157
157
  /* @__PURE__ */ e("span", { className: "sc:font-normal sc:text-white/60", children: "on" }),
158
158
  " ",
@@ -176,27 +176,27 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
176
176
  ]
177
177
  }
178
178
  );
179
- }), He = Ge.memo(function({ vector: t, onVectorSelect: x, fixedHeight: R = !1 }) {
180
- const [u, z] = o(!1), [r, h] = o(!1), n = B(null), m = B(null), a = () => {
181
- r || x(t);
179
+ }), He = Ge.memo(function({ vector: t, onVectorSelect: b, fixedHeight: R = !1 }) {
180
+ const [f, z] = o(!1), [r, g] = o(!1), n = B(null), m = B(null), a = () => {
181
+ r || b(t);
182
182
  }, p = () => {
183
183
  m.current && (clearTimeout(m.current), m.current = null), n.current = setTimeout(() => {
184
- h(!0);
184
+ g(!0);
185
185
  }, 400);
186
186
  }, A = () => {
187
- n.current && (clearTimeout(n.current), n.current = null), h(!1);
188
- }, b = () => {
187
+ n.current && (clearTimeout(n.current), n.current = null), g(!1);
188
+ }, x = () => {
189
189
  n.current && (clearTimeout(n.current), n.current = null), m.current && (clearTimeout(m.current), m.current = null);
190
190
  }, T = () => {
191
- h(!1);
192
- }, N = u || r;
191
+ g(!1);
192
+ }, I = f || r;
193
193
  return /* @__PURE__ */ c(
194
194
  "div",
195
195
  {
196
196
  onClick: a,
197
197
  onMouseEnter: () => z(!0),
198
198
  onMouseLeave: () => z(!1),
199
- className: `sc:group sc:relative sc:cursor-pointer sc:overflow-hidden sc:bg-white/10 sc:transition-all sc:duration-300 ${R ? "sc:h-full sc:rounded-xs" : "sc:break-inside-avoid sc:rounded-lg"} ${u ? "sc:scale-105 sc:bg-white/20" : ""}`,
199
+ className: `sc:group sc:relative sc:cursor-pointer sc:overflow-hidden sc:bg-white/10 sc:transition-all sc:duration-300 ${R ? "sc:h-full sc:rounded-xs" : "sc:break-inside-avoid sc:rounded-lg"} ${f ? "sc:scale-105 sc:bg-white/20" : ""}`,
200
200
  children: [
201
201
  /* @__PURE__ */ e(
202
202
  "div",
@@ -207,9 +207,9 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
207
207
  {
208
208
  src: t.urls.preview,
209
209
  alt: t.term,
210
- className: `sc:max-h-full sc:max-w-full sc:object-contain sc:transition-all sc:duration-300 ${u ? "sc:scale-110" : "sc:scale-100"}`,
210
+ className: `sc:max-h-full sc:max-w-full sc:object-contain sc:transition-all sc:duration-300 ${f ? "sc:scale-110" : "sc:scale-100"}`,
211
211
  style: {
212
- filter: u ? "brightness(1.1)" : void 0
212
+ filter: f ? "brightness(1.1)" : void 0
213
213
  }
214
214
  }
215
215
  )
@@ -219,18 +219,18 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
219
219
  !t.urls.svg && /* @__PURE__ */ e(
220
220
  "span",
221
221
  {
222
- className: `sc:rounded-xs sc:bg-amber-500/90 sc:px-1.5 sc:py-0.5 sc:text-[10px] sc:font-semibold sc:uppercase sc:tracking-wide sc:text-white sc:shadow-sm sc:transition-all sc:duration-300 sc:ease-in-out ${N ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
222
+ className: `sc:rounded-xs sc:bg-amber-500/90 sc:px-1.5 sc:py-0.5 sc:text-[10px] sc:font-semibold sc:uppercase sc:tracking-wide sc:text-white sc:shadow-sm sc:transition-all sc:duration-300 sc:ease-in-out ${I ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
223
223
  children: "PNG"
224
224
  }
225
225
  ),
226
226
  /* @__PURE__ */ e(
227
227
  "button",
228
228
  {
229
- className: `sc:relative sc:flex sc:h-6 sc:w-6 sc:items-center sc:justify-center sc:rounded-full sc:bg-black/50 sc:transition-all sc:duration-300 sc:ease-in-out sc:hover:scale-110 ${N ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
229
+ className: `sc:relative sc:flex sc:h-6 sc:w-6 sc:items-center sc:justify-center sc:rounded-full sc:bg-black/50 sc:transition-all sc:duration-300 sc:ease-in-out sc:hover:scale-110 ${I ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
230
230
  "aria-label": "Vector info",
231
231
  onMouseEnter: p,
232
232
  onMouseLeave: A,
233
- children: /* @__PURE__ */ e(k, { icon: "lucide:aperture", className: "sc:size-4 sc:text-white/80" })
233
+ children: /* @__PURE__ */ e(E, { icon: "lucide:aperture", className: "sc:size-4 sc:text-white/80" })
234
234
  }
235
235
  )
236
236
  ] }),
@@ -238,11 +238,11 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
238
238
  "div",
239
239
  {
240
240
  className: `sc:absolute sc:inset-x-0 sc:bottom-0 sc:z-0 sc:bg-linear-to-t sc:from-black/80 sc:via-black/60 sc:to-transparent sc:px-3 sc:py-3 sc:pt-8 sc:transition-transform sc:duration-300 sc:ease-out ${r ? "sc:translate-y-0" : "sc:translate-y-full"}`,
241
- onMouseEnter: b,
241
+ onMouseEnter: x,
242
242
  onMouseLeave: T,
243
243
  children: [
244
244
  /* @__PURE__ */ c("div", { className: "sc:mb-1", children: [
245
- /* @__PURE__ */ e(k, { icon: "mdi:cube-outline", className: "sc:mr-2 sc:inline-block sc:size-3 sc:text-white/80" }),
245
+ /* @__PURE__ */ e(E, { icon: "mdi:cube-outline", className: "sc:mr-2 sc:inline-block sc:size-3 sc:text-white/80" }),
246
246
  /* @__PURE__ */ e("span", { className: "sc:text-xs sc:font-medium sc:text-white/80", children: "Noun Project" })
247
247
  ] }),
248
248
  /* @__PURE__ */ e("div", { className: "sc:text-xs sc:text-white/60", children: "Icon by" }),
@@ -254,38 +254,38 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
254
254
  }
255
255
  );
256
256
  }), bs = ({
257
- isOpen: d,
257
+ isOpen: u,
258
258
  onToggle: t,
259
- onImageSelect: x,
259
+ onImageSelect: b,
260
260
  currentImageUrl: R,
261
- placement: u = "bottom",
261
+ placement: f = "bottom",
262
262
  busy: z = !1
263
263
  }) => {
264
- const { imageSearch: r, generate: h, vectors: n, removeBackground: m } = Fe(), a = _e(
264
+ const { imageSearch: r, generate: g, vectors: n, removeBackground: m } = Fe(), a = _e(
265
265
  () => [
266
266
  ...r ? ["search"] : [],
267
267
  "url",
268
268
  ...n ? ["vector"] : [],
269
- ...h ? ["ai"] : []
269
+ ...g ? ["ai"] : []
270
270
  ],
271
- [r, n, h]
272
- ), [p, A] = o(""), [b, T] = o(""), [N, y] = o([]), [S, Z] = o(!1), [te, H] = o(null), [C, ce] = o(a[0]), [ie, $] = o(1), [P, le] = o(!0), [Y, D] = o("masonry"), [v, re] = o(""), [j, J] = o([]), [f, U] = o(!1), [X, ge] = o(null), [K, pe] = o(null), [W, Ne] = o(!0), [ae, xe] = o("grid"), [V, Ce] = o(""), [be, ve] = o(!1), [G, de] = o(null), [F, me] = o(null), [g, E] = o(!1), [I, _] = o(null), i = B(null), O = B(null), ee = B(null);
273
- ne(() => {
271
+ [r, n, g]
272
+ ), [p, A] = o(""), [x, T] = o(""), [I, k] = o([]), [S, Z] = o(!1), [te, $] = o(null), [C, ce] = o(a[0]), [le, j] = o(1), [P, de] = o(!0), [Y, D] = o("masonry"), [v, re] = o(""), [H, J] = o([]), [h, U] = o(!1), [X, pe] = o(null), [K, ae] = o(null), [W, Ne] = o(!0), [ne, xe] = o("grid"), [V, Ce] = o(""), [be, ve] = o(!1), [G, ue] = o(null), [F, me] = o(null), [i, w] = o(!1), [N, _] = o(null), l = B(null), O = B(null), ee = B(null);
273
+ oe(() => {
274
274
  a.includes(C) || ce(a[0]);
275
- }, [a, C]), ne(() => {
276
- d && R && (T(R), ce("url"));
277
- }, [d, R]), ne(() => {
278
- d || (A(""), T(""), y([]), H(null), $(1), le(!0), re(""), J([]), ge(null), pe(null), Ne(!0));
279
- }, [d]);
280
- const se = he(
281
- async (s, l, w) => {
275
+ }, [a, C]), oe(() => {
276
+ u && R && (T(R), ce("url"));
277
+ }, [u, R]), oe(() => {
278
+ u || (A(""), T(""), k([]), $(null), j(1), de(!0), re(""), J([]), pe(null), ae(null), Ne(!0));
279
+ }, [u]);
280
+ const se = ge(
281
+ async (s, d, y) => {
282
282
  if (r) {
283
- Z(!0), H(null);
283
+ Z(!0), $(null);
284
284
  try {
285
- const L = await r.search({ query: s, page: l, perPage: 30 });
286
- y((Q) => w ? [...Q, ...L.results] : L.results), $(L.page), le(L.hasMore);
285
+ const L = await r.search({ query: s, page: d, perPage: 30 });
286
+ k((Q) => y ? [...Q, ...L.results] : L.results), j(L.page), de(L.hasMore);
287
287
  } catch (L) {
288
- H(hs), we.error("Error searching images:", L);
288
+ $(hs), we.error("Error searching images:", L);
289
289
  } finally {
290
290
  Z(!1);
291
291
  }
@@ -293,20 +293,20 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
293
293
  },
294
294
  [r]
295
295
  );
296
- ne(() => {
297
- d && !p && C === "search" && N.length === 0 && r && se("", 1, !1);
298
- }, [d, C, r]);
296
+ oe(() => {
297
+ u && !p && C === "search" && I.length === 0 && r && se("", 1, !1);
298
+ }, [u, C, r]);
299
299
  const ye = (s) => {
300
300
  s.preventDefault(), se(p, 1, !1);
301
- }, De = he(() => {
302
- S || !P || se(p, ie + 1, !0);
303
- }, [S, P, p, ie, se]);
304
- ne(() => {
305
- const s = i.current;
306
- if (!s || !d || C !== "search") return;
307
- const l = new IntersectionObserver(
308
- (w) => {
309
- w[0].isIntersecting && P && !S && De();
301
+ }, De = ge(() => {
302
+ S || !P || se(p, le + 1, !0);
303
+ }, [S, P, p, le, se]);
304
+ oe(() => {
305
+ const s = l.current;
306
+ if (!s || !u || C !== "search") return;
307
+ const d = new IntersectionObserver(
308
+ (y) => {
309
+ y[0].isIntersecting && P && !S && De();
310
310
  },
311
311
  {
312
312
  root: null,
@@ -316,22 +316,22 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
316
316
  threshold: 0
317
317
  }
318
318
  );
319
- return l.observe(s), () => {
320
- l.disconnect();
319
+ return d.observe(s), () => {
320
+ d.disconnect();
321
321
  };
322
- }, [d, C, P, S, De]);
323
- const Ie = he(
324
- async (s, l) => {
322
+ }, [u, C, P, S, De]);
323
+ const Ie = ge(
324
+ async (s, d) => {
325
325
  if (n) {
326
- U(!0), ge(null);
326
+ U(!0), pe(null);
327
327
  try {
328
- const { results: w, nextPage: L } = await n.search({ query: s, nextPage: l ?? null });
329
- J(l ? (Q) => {
330
- const Le = new Set(Q.map((ue) => ue.id));
331
- return [...Q, ...w.filter((ue) => !Le.has(ue.id))];
332
- } : w), pe(L), Ne(L !== null);
333
- } catch (w) {
334
- ge(gs), we.error("Error searching vectors:", w);
328
+ const { results: y, nextPage: L } = await n.search({ query: s, nextPage: d ?? null });
329
+ J(d ? (Q) => {
330
+ const Le = new Set(Q.map((fe) => fe.id));
331
+ return [...Q, ...y.filter((fe) => !Le.has(fe.id))];
332
+ } : y), ae(L), Ne(L !== null);
333
+ } catch (y) {
334
+ pe(gs), we.error("Error searching vectors:", y);
335
335
  } finally {
336
336
  U(!1);
337
337
  }
@@ -339,20 +339,20 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
339
339
  },
340
340
  [n]
341
341
  );
342
- ne(() => {
343
- d && !v && C === "vector" && j.length === 0 && n && Ie("");
344
- }, [d, C, n]);
342
+ oe(() => {
343
+ u && !v && C === "vector" && H.length === 0 && n && Ie("");
344
+ }, [u, C, n]);
345
345
  const Qe = (s) => {
346
346
  s.preventDefault(), Ie(v);
347
- }, Me = he(() => {
348
- f || !W || !K || Ie(v, K);
349
- }, [f, W, K, v, Ie]);
350
- ne(() => {
347
+ }, Me = ge(() => {
348
+ h || !W || !K || Ie(v, K);
349
+ }, [h, W, K, v, Ie]);
350
+ oe(() => {
351
351
  const s = O.current;
352
- if (!s || !d || C !== "vector") return;
353
- const l = new IntersectionObserver(
354
- (w) => {
355
- w[0].isIntersecting && W && !f && Me();
352
+ if (!s || !u || C !== "vector") return;
353
+ const d = new IntersectionObserver(
354
+ (y) => {
355
+ y[0].isIntersecting && W && !h && Me();
356
356
  },
357
357
  {
358
358
  root: null,
@@ -360,101 +360,101 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
360
360
  threshold: 0
361
361
  }
362
362
  );
363
- return l.observe(s), () => {
364
- l.disconnect();
363
+ return d.observe(s), () => {
364
+ d.disconnect();
365
365
  };
366
- }, [d, C, W, f, Me]);
366
+ }, [u, C, W, h, Me]);
367
367
  const ze = (s) => {
368
- const l = s.selectUrl || s.urls.svg || s.urls.png;
369
- l && (x(l), t(!1));
368
+ const d = s.selectUrl || s.urls.svg || s.urls.png;
369
+ d && (b(d), t(!1));
370
370
  }, Te = (s) => {
371
- var l;
371
+ var d;
372
372
  try {
373
- Promise.resolve((l = r == null ? void 0 : r.trackSelect) == null ? void 0 : l.call(r, s)).catch(() => {
373
+ Promise.resolve((d = r == null ? void 0 : r.trackSelect) == null ? void 0 : d.call(r, s)).catch(() => {
374
374
  });
375
375
  } catch {
376
376
  }
377
- x(s.urls.regular), t(!1);
377
+ b(s.urls.regular), t(!1);
378
378
  }, qe = (s) => {
379
- s.preventDefault(), b.trim() && (x(b.trim()), t(!1));
379
+ s.preventDefault(), x.trim() && (b(x.trim()), t(!1));
380
380
  }, Ze = (s) => {
381
- var w;
382
- const l = (w = s.target.files) == null ? void 0 : w[0];
383
- if (l && l.type.startsWith("image/")) {
381
+ var y;
382
+ const d = (y = s.target.files) == null ? void 0 : y[0];
383
+ if (d && d.type.startsWith("image/")) {
384
384
  const L = new FileReader();
385
385
  L.onload = (Q) => {
386
- var ue;
387
- const Le = (ue = Q.target) == null ? void 0 : ue.result;
386
+ var fe;
387
+ const Le = (fe = Q.target) == null ? void 0 : fe.result;
388
388
  T(Le);
389
- }, L.readAsDataURL(l);
389
+ }, L.readAsDataURL(d);
390
390
  }
391
391
  }, Je = () => {
392
392
  var s;
393
393
  (s = ee.current) == null || s.click();
394
394
  }, Ke = async () => {
395
- if (!(!m || !b.trim())) {
396
- E(!0), _(null);
395
+ if (!(!m || !x.trim())) {
396
+ w(!0), _(null);
397
397
  try {
398
- const s = await m(b);
398
+ const s = await m(x);
399
399
  T(s);
400
400
  } catch (s) {
401
401
  _($e), we.error("Error removing background:", s);
402
402
  } finally {
403
- E(!1);
403
+ w(!1);
404
404
  }
405
405
  }
406
406
  }, Oe = async (s) => {
407
- var l, w;
408
- if (s.preventDefault(), !!h) {
407
+ var d, y;
408
+ if (s.preventDefault(), !!g) {
409
409
  if (!V.trim()) {
410
- de("Please enter a prompt");
410
+ ue("Please enter a prompt");
411
411
  return;
412
412
  }
413
- ve(!0), de(null), me(null);
413
+ ve(!0), ue(null), me(null);
414
414
  try {
415
- const Q = (w = (l = (await h.generate({
415
+ const Q = (y = (d = (await g.generate({
416
416
  prompt: V,
417
417
  width: 1024,
418
418
  height: 1024,
419
419
  numberResults: 1
420
- })).images) == null ? void 0 : l[0]) == null ? void 0 : w.imageUrl;
420
+ })).images) == null ? void 0 : d[0]) == null ? void 0 : y.imageUrl;
421
421
  if (!Q)
422
422
  throw new Error(Be);
423
423
  me(Q);
424
424
  } catch (L) {
425
- de(ps(L, Be)), we.error("Error generating AI image:", L);
425
+ ue(ps(L, Be)), we.error("Error generating AI image:", L);
426
426
  } finally {
427
427
  ve(!1);
428
428
  }
429
429
  }
430
430
  }, es = () => {
431
- F && (x(F), t(!1));
431
+ F && (b(F), t(!1));
432
432
  }, ss = async () => {
433
433
  if (!(!m || !F)) {
434
- E(!0), _(null);
434
+ w(!0), _(null);
435
435
  try {
436
436
  const s = await m(F);
437
437
  me(s);
438
438
  } catch (s) {
439
439
  _($e), we.error("Error removing background:", s);
440
440
  } finally {
441
- E(!1);
441
+ w(!1);
442
442
  }
443
443
  }
444
- }, ts = (s, l) => {
445
- const w = s.width / s.height;
446
- return l % 12 === 0 && w > 0.8 && w < 1.2 ? "sc:col-span-2 sc:row-span-2" : w < 0.75 ? "sc:row-span-2" : w > 1.5 ? "sc:col-span-2" : "";
444
+ }, ts = (s, d) => {
445
+ const y = s.width / s.height;
446
+ return d % 12 === 0 && y > 0.8 && y < 1.2 ? "sc:col-span-2 sc:row-span-2" : y < 0.75 ? "sc:row-span-2" : y > 1.5 ? "sc:col-span-2" : "";
447
447
  };
448
448
  return /* @__PURE__ */ c(
449
449
  ls,
450
450
  {
451
- isOpen: d,
451
+ isOpen: u,
452
452
  onClose: () => t(!1),
453
453
  title: "Image Browser",
454
454
  description: "Browse images or enter a custom image URL",
455
- placement: u,
456
- height: u === "bottom" ? "90vh" : void 0,
457
- width: u !== "bottom" ? "500px" : void 0,
455
+ placement: f,
456
+ height: f === "bottom" ? "90vh" : void 0,
457
+ width: f !== "bottom" ? "500px" : void 0,
458
458
  hideHandle: !0,
459
459
  hideVisibleTitle: !0,
460
460
  showCloseButton: !1,
@@ -493,7 +493,7 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
493
493
  className: "sc:h-11 sc:w-14 sc:px-0 sc:md:h-9 sc:md:w-11",
494
494
  "data-testid": "image-tab-search",
495
495
  children: [
496
- /* @__PURE__ */ e(k, { icon: fe.image, className: "sc:size-6" }),
496
+ /* @__PURE__ */ e(E, { icon: he.image, className: "sc:size-6" }),
497
497
  /* @__PURE__ */ e(M.Indicator, {})
498
498
  ]
499
499
  }
@@ -505,7 +505,7 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
505
505
  className: "sc:h-11 sc:w-14 sc:px-0 sc:md:h-9 sc:md:w-11",
506
506
  "data-testid": "image-tab-url",
507
507
  children: [
508
- /* @__PURE__ */ e(k, { icon: fe.link, className: "sc:size-6" }),
508
+ /* @__PURE__ */ e(E, { icon: he.link, className: "sc:size-6" }),
509
509
  /* @__PURE__ */ e(M.Indicator, {})
510
510
  ]
511
511
  }
@@ -517,12 +517,12 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
517
517
  className: "sc:h-11 sc:w-14 sc:px-0 sc:md:h-9 sc:md:w-11",
518
518
  "data-testid": "image-tab-vector",
519
519
  children: [
520
- /* @__PURE__ */ e(k, { icon: "fa6-solid:icons", className: "sc:size-5" }),
520
+ /* @__PURE__ */ e(E, { icon: "fa6-solid:icons", className: "sc:size-5" }),
521
521
  /* @__PURE__ */ e(M.Indicator, {})
522
522
  ]
523
523
  }
524
524
  ),
525
- h && /* @__PURE__ */ c(
525
+ g && /* @__PURE__ */ c(
526
526
  M.Tab,
527
527
  {
528
528
  id: "ai",
@@ -550,7 +550,7 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
550
550
  "data-testid": "image-search-input"
551
551
  }
552
552
  ) }),
553
- /* @__PURE__ */ e(q, { type: "submit", size: "icon", variant: "secondary", disabled: S, "aria-label": "Search", children: /* @__PURE__ */ e(k, { icon: fe.search, className: "sc:size-5" }) }),
553
+ /* @__PURE__ */ e(q, { type: "submit", size: "icon", variant: "secondary", disabled: S, "aria-label": "Search", children: /* @__PURE__ */ e(E, { icon: he.search, className: "sc:size-5" }) }),
554
554
  /* @__PURE__ */ e(
555
555
  q,
556
556
  {
@@ -558,13 +558,13 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
558
558
  variant: "secondary",
559
559
  onClick: () => D(Y === "grid" ? "masonry" : "grid"),
560
560
  "aria-label": Y === "grid" ? "Switch to masonry view" : "Switch to grid view",
561
- children: Y === "grid" ? /* @__PURE__ */ e(k, { icon: "lucide:layout-grid", className: "sc:size-5" }) : /* @__PURE__ */ e(k, { icon: fe.grip, className: "sc:size-5" })
561
+ children: Y === "grid" ? /* @__PURE__ */ e(E, { icon: "lucide:layout-grid", className: "sc:size-5" }) : /* @__PURE__ */ e(E, { icon: he.grip, className: "sc:size-5" })
562
562
  }
563
563
  )
564
564
  ] }),
565
565
  te && /* @__PURE__ */ e("div", { className: "sc:border-danger sc:bg-danger/10 sc:text-danger sc:mx-6 sc:mb-3 sc:rounded-2xl sc:border-2 sc:px-4 sc:py-3 sc:text-sm", children: te }),
566
- S && N.length === 0 && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:px-6 sc:py-8 sc:text-center sc:text-sm", children: "Loading images..." }),
567
- N.length > 0 && /* @__PURE__ */ c("div", { className: "sc:mx-6 sc:overflow-hidden sc:rounded-t-2xl", children: [
566
+ S && I.length === 0 && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:px-6 sc:py-8 sc:text-center sc:text-sm", children: "Loading images..." }),
567
+ I.length > 0 && /* @__PURE__ */ c("div", { className: "sc:mx-6 sc:overflow-hidden sc:rounded-t-2xl", children: [
568
568
  Y === "masonry" ? (
569
569
  /* CSS Grid Masonry (Dense) */
570
570
  /* @__PURE__ */ e(
@@ -573,11 +573,11 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
573
573
  className: "sc:grid sc:grid-flow-dense sc:pb-4",
574
574
  style: {
575
575
  display: "grid",
576
- gridTemplateColumns: u === "bottom" ? "repeat(auto-fill, minmax(200px, 1fr))" : "repeat(3, 1fr)",
577
- gridAutoRows: u === "bottom" ? "200px" : "120px",
576
+ gridTemplateColumns: f === "bottom" ? "repeat(auto-fill, minmax(200px, 1fr))" : "repeat(3, 1fr)",
577
+ gridAutoRows: f === "bottom" ? "200px" : "120px",
578
578
  gap: xs
579
579
  },
580
- children: N.map((s, l) => /* @__PURE__ */ e("div", { className: ts(s, l), style: Re, children: /* @__PURE__ */ e(je, { image: s, onImageSelect: Te, fixedHeight: !0 }) }, s.id))
580
+ children: I.map((s, d) => /* @__PURE__ */ e("div", { className: ts(s, d), style: Re, children: /* @__PURE__ */ e(je, { image: s, onImageSelect: Te, fixedHeight: !0 }) }, s.id))
581
581
  }
582
582
  )
583
583
  ) : (
@@ -588,18 +588,18 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
588
588
  className: "sc:pb-4",
589
589
  style: {
590
590
  display: "grid",
591
- gridTemplateColumns: u === "bottom" ? "repeat(auto-fill, minmax(150px, 1fr))" : "repeat(auto-fill, minmax(120px, 1fr))",
591
+ gridTemplateColumns: f === "bottom" ? "repeat(auto-fill, minmax(150px, 1fr))" : "repeat(auto-fill, minmax(120px, 1fr))",
592
592
  gap: Se
593
593
  },
594
- children: N.map((s) => /* @__PURE__ */ e("div", { style: { aspectRatio: "1 / 1", ...Re }, children: /* @__PURE__ */ e(je, { image: s, onImageSelect: Te, fixedHeight: !0 }) }, s.id))
594
+ children: I.map((s) => /* @__PURE__ */ e("div", { style: { aspectRatio: "1 / 1", ...Re }, children: /* @__PURE__ */ e(je, { image: s, onImageSelect: Te, fixedHeight: !0 }) }, s.id))
595
595
  }
596
596
  )
597
597
  ),
598
- P && /* @__PURE__ */ e("div", { ref: i, className: "sc:h-px" }),
598
+ P && /* @__PURE__ */ e("div", { ref: l, className: "sc:h-px" }),
599
599
  S && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:py-4 sc:text-center sc:text-sm", children: "Loading more..." }),
600
600
  !P && !S && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:py-6 sc:text-center sc:text-sm", children: "No more images" })
601
601
  ] }),
602
- !S && N.length === 0 && p && /* @__PURE__ */ c("div", { className: "sc:text-muted sc:px-6 sc:py-12 sc:text-center sc:text-sm", children: [
602
+ !S && I.length === 0 && p && /* @__PURE__ */ c("div", { className: "sc:text-muted sc:px-6 sc:py-12 sc:text-center sc:text-sm", children: [
603
603
  'No images found for "',
604
604
  p,
605
605
  '"'
@@ -625,7 +625,7 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
625
625
  "data-testid": "image-upload-btn",
626
626
  children: [
627
627
  /* @__PURE__ */ e(
628
- k,
628
+ E,
629
629
  {
630
630
  icon: "lucide:upload-cloud",
631
631
  className: "sc:size-10 sc:text-foreground/60"
@@ -656,7 +656,7 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
656
656
  {
657
657
  type: "url",
658
658
  placeholder: "https://example.com/image.jpg",
659
- value: b,
659
+ value: x,
660
660
  onChange: (s) => T(s.target.value),
661
661
  variant: "subtle",
662
662
  "data-testid": "image-url-input"
@@ -668,7 +668,7 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
668
668
  {
669
669
  type: "submit",
670
670
  variant: "default",
671
- disabled: !b.trim(),
671
+ disabled: !x.trim(),
672
672
  className: "sc:w-full",
673
673
  "data-testid": "image-url-submit-btn",
674
674
  children: "Use This Image"
@@ -677,39 +677,39 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
677
677
  ]
678
678
  }
679
679
  ),
680
- b.trim() && /* @__PURE__ */ c("div", { className: "sc:flex sc:flex-col sc:gap-3 sc:rounded-2xl sc:border sc:border-divider sc:bg-muted/30 sc:p-4", children: [
680
+ x.trim() && /* @__PURE__ */ c("div", { className: "sc:flex sc:flex-col sc:gap-3 sc:rounded-2xl sc:border sc:border-divider sc:bg-muted/30 sc:p-4", children: [
681
681
  /* @__PURE__ */ c("div", { className: "sc:flex sc:items-center sc:justify-between sc:gap-3", children: [
682
682
  /* @__PURE__ */ e("span", { className: "sc:text-xs sc:font-medium sc:uppercase sc:tracking-wider sc:text-muted-foreground", children: "Preview" }),
683
683
  m && /* @__PURE__ */ e(
684
684
  q,
685
685
  {
686
686
  onClick: Ke,
687
- disabled: g || !b.trim(),
687
+ disabled: i || !x.trim(),
688
688
  variant: "secondary",
689
689
  size: "sm",
690
690
  className: "sc:gap-2",
691
691
  "data-testid": "remove-background-btn",
692
- children: g ? /* @__PURE__ */ c(oe, { children: [
692
+ children: i ? /* @__PURE__ */ c(ie, { children: [
693
693
  /* @__PURE__ */ e(
694
- k,
694
+ E,
695
695
  {
696
696
  icon: "eos-icons:loading",
697
697
  className: "sc:size-4 sc:animate-spin"
698
698
  }
699
699
  ),
700
700
  "Removing…"
701
- ] }) : /* @__PURE__ */ c(oe, { children: [
702
- /* @__PURE__ */ e(k, { icon: "mdi:image-remove", className: "sc:size-4" }),
701
+ ] }) : /* @__PURE__ */ c(ie, { children: [
702
+ /* @__PURE__ */ e(E, { icon: "mdi:image-remove", className: "sc:size-4" }),
703
703
  "Remove BG"
704
704
  ] })
705
705
  }
706
706
  )
707
707
  ] }),
708
- I && /* @__PURE__ */ e("div", { className: "sc:rounded-lg sc:border sc:border-danger sc:bg-danger/10 sc:px-3 sc:py-2 sc:text-xs sc:text-danger", children: I }),
708
+ N && /* @__PURE__ */ e("div", { className: "sc:rounded-lg sc:border sc:border-danger sc:bg-danger/10 sc:px-3 sc:py-2 sc:text-xs sc:text-danger", children: N }),
709
709
  /* @__PURE__ */ e(
710
710
  "img",
711
711
  {
712
- src: b,
712
+ src: x,
713
713
  alt: "Preview",
714
714
  className: "sc:max-h-[280px] sc:w-full sc:rounded-lg sc:object-contain",
715
715
  onError: (s) => {
@@ -735,22 +735,22 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
735
735
  "data-testid": "vector-search-input"
736
736
  }
737
737
  ) }),
738
- /* @__PURE__ */ e(q, { type: "submit", size: "icon", variant: "secondary", disabled: f, "aria-label": "Search", children: /* @__PURE__ */ e(k, { icon: fe.search, className: "sc:size-5" }) }),
738
+ /* @__PURE__ */ e(q, { type: "submit", size: "icon", variant: "secondary", disabled: h, "aria-label": "Search", children: /* @__PURE__ */ e(E, { icon: he.search, className: "sc:size-5" }) }),
739
739
  /* @__PURE__ */ e(
740
740
  q,
741
741
  {
742
742
  size: "icon",
743
743
  variant: "secondary",
744
- onClick: () => xe(ae === "grid" ? "masonry" : "grid"),
745
- "aria-label": ae === "grid" ? "Switch to masonry view" : "Switch to grid view",
746
- children: ae === "grid" ? /* @__PURE__ */ e(k, { icon: "lucide:layout-grid", className: "sc:size-5" }) : /* @__PURE__ */ e(k, { icon: fe.grip, className: "sc:size-5" })
744
+ onClick: () => xe(ne === "grid" ? "masonry" : "grid"),
745
+ "aria-label": ne === "grid" ? "Switch to masonry view" : "Switch to grid view",
746
+ children: ne === "grid" ? /* @__PURE__ */ e(E, { icon: "lucide:layout-grid", className: "sc:size-5" }) : /* @__PURE__ */ e(E, { icon: he.grip, className: "sc:size-5" })
747
747
  }
748
748
  )
749
749
  ] }),
750
750
  X && /* @__PURE__ */ e("div", { className: "sc:border-danger sc:bg-danger/10 sc:text-danger sc:mx-6 sc:mb-3 sc:rounded-2xl sc:border-2 sc:px-4 sc:py-3 sc:text-sm", children: X }),
751
- f && j.length === 0 && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:px-6 sc:py-8 sc:text-center sc:text-sm", children: "Loading vectors..." }),
752
- j.length > 0 && /* @__PURE__ */ c("div", { className: "sc:mx-6 sc:overflow-hidden sc:rounded-t-2xl", children: [
753
- ae === "masonry" ? (
751
+ h && H.length === 0 && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:px-6 sc:py-8 sc:text-center sc:text-sm", children: "Loading vectors..." }),
752
+ H.length > 0 && /* @__PURE__ */ c("div", { className: "sc:mx-6 sc:overflow-hidden sc:rounded-t-2xl", children: [
753
+ ne === "masonry" ? (
754
754
  /* CSS Grid Masonry */
755
755
  /* @__PURE__ */ e(
756
756
  "div",
@@ -758,11 +758,11 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
758
758
  className: "sc:grid sc:grid-flow-dense sc:pb-4",
759
759
  style: {
760
760
  display: "grid",
761
- gridTemplateColumns: u === "bottom" ? "repeat(auto-fill, minmax(150px, 1fr))" : "repeat(3, 1fr)",
762
- gridAutoRows: u === "bottom" ? "150px" : "120px",
761
+ gridTemplateColumns: f === "bottom" ? "repeat(auto-fill, minmax(150px, 1fr))" : "repeat(3, 1fr)",
762
+ gridAutoRows: f === "bottom" ? "150px" : "120px",
763
763
  gap: Se
764
764
  },
765
- children: j.map((s) => /* @__PURE__ */ e("div", { style: Re, children: /* @__PURE__ */ e(He, { vector: s, onVectorSelect: ze, fixedHeight: !0 }) }, s.id))
765
+ children: H.map((s) => /* @__PURE__ */ e("div", { style: Re, children: /* @__PURE__ */ e(He, { vector: s, onVectorSelect: ze, fixedHeight: !0 }) }, s.id))
766
766
  }
767
767
  )
768
768
  ) : (
@@ -773,24 +773,24 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
773
773
  className: "sc:pb-4",
774
774
  style: {
775
775
  display: "grid",
776
- gridTemplateColumns: u === "bottom" ? "repeat(auto-fill, minmax(120px, 1fr))" : "repeat(auto-fill, minmax(100px, 1fr))",
776
+ gridTemplateColumns: f === "bottom" ? "repeat(auto-fill, minmax(120px, 1fr))" : "repeat(auto-fill, minmax(100px, 1fr))",
777
777
  gap: Se
778
778
  },
779
- children: j.map((s) => /* @__PURE__ */ e("div", { style: { aspectRatio: "1 / 1", ...Re }, children: /* @__PURE__ */ e(He, { vector: s, onVectorSelect: ze, fixedHeight: !0 }) }, s.id))
779
+ children: H.map((s) => /* @__PURE__ */ e("div", { style: { aspectRatio: "1 / 1", ...Re }, children: /* @__PURE__ */ e(He, { vector: s, onVectorSelect: ze, fixedHeight: !0 }) }, s.id))
780
780
  }
781
781
  )
782
782
  ),
783
783
  W && /* @__PURE__ */ e("div", { ref: O, className: "sc:h-px" }),
784
- f && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:py-4 sc:text-center sc:text-sm", children: "Loading more..." }),
785
- !W && !f && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:py-6 sc:text-center sc:text-sm", children: "No more vectors" })
784
+ h && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:py-4 sc:text-center sc:text-sm", children: "Loading more..." }),
785
+ !W && !h && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:py-6 sc:text-center sc:text-sm", children: "No more vectors" })
786
786
  ] }),
787
- !f && j.length === 0 && v && /* @__PURE__ */ c("div", { className: "sc:text-muted sc:px-6 sc:py-12 sc:text-center sc:text-sm", children: [
787
+ !h && H.length === 0 && v && /* @__PURE__ */ c("div", { className: "sc:text-muted sc:px-6 sc:py-12 sc:text-center sc:text-sm", children: [
788
788
  'No vectors found for "',
789
789
  v,
790
790
  '"'
791
791
  ] })
792
792
  ] }),
793
- h && /* @__PURE__ */ c(M.Panel, { id: "ai", className: "sc:flex sc:flex-col sc:gap-6 sc:p-6", children: [
793
+ g && /* @__PURE__ */ c(M.Panel, { id: "ai", className: "sc:flex sc:flex-col sc:gap-6 sc:p-6", children: [
794
794
  /* @__PURE__ */ c("form", { onSubmit: Oe, className: "sc:flex sc:flex-col sc:gap-6", children: [
795
795
  /* @__PURE__ */ c(ke, { children: [
796
796
  /* @__PURE__ */ e(Ee, { children: "Prompt" }),
@@ -815,10 +815,10 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
815
815
  disabled: !V.trim() || be,
816
816
  className: "sc:w-full",
817
817
  "data-testid": "ai-generate-btn",
818
- children: be ? /* @__PURE__ */ c(oe, { children: [
819
- /* @__PURE__ */ e(k, { icon: "eos-icons:loading", className: "sc:size-5 sc:animate-spin" }),
818
+ children: be ? /* @__PURE__ */ c(ie, { children: [
819
+ /* @__PURE__ */ e(E, { icon: "eos-icons:loading", className: "sc:size-5 sc:animate-spin" }),
820
820
  "Generating..."
821
- ] }) : /* @__PURE__ */ c(oe, { children: [
821
+ ] }) : /* @__PURE__ */ c(ie, { children: [
822
822
  /* @__PURE__ */ e(Ve, { size: 24 }),
823
823
  "Generate Image"
824
824
  ] })
@@ -845,21 +845,21 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
845
845
  q,
846
846
  {
847
847
  onClick: ss,
848
- disabled: g || !F,
848
+ disabled: i || !F,
849
849
  variant: "secondary",
850
850
  size: "sm",
851
851
  className: "sc:w-full sc:gap-2",
852
852
  "data-testid": "ai-remove-background-btn",
853
- children: g ? /* @__PURE__ */ c(oe, { children: [
854
- /* @__PURE__ */ e(k, { icon: "eos-icons:loading", className: "sc:size-4 sc:animate-spin" }),
853
+ children: i ? /* @__PURE__ */ c(ie, { children: [
854
+ /* @__PURE__ */ e(E, { icon: "eos-icons:loading", className: "sc:size-4 sc:animate-spin" }),
855
855
  "Removing..."
856
- ] }) : /* @__PURE__ */ c(oe, { children: [
857
- /* @__PURE__ */ e(k, { icon: "mdi:image-remove", className: "sc:size-4" }),
856
+ ] }) : /* @__PURE__ */ c(ie, { children: [
857
+ /* @__PURE__ */ e(E, { icon: "mdi:image-remove", className: "sc:size-4" }),
858
858
  "Remove Background"
859
859
  ] })
860
860
  }
861
861
  ),
862
- I && /* @__PURE__ */ e("div", { className: "sc:border-danger sc:bg-danger/10 sc:text-danger sc:rounded-xl sc:border-2 sc:px-3 sc:py-2 sc:text-xs", children: I }),
862
+ N && /* @__PURE__ */ e("div", { className: "sc:border-danger sc:bg-danger/10 sc:text-danger sc:rounded-xl sc:border-2 sc:px-3 sc:py-2 sc:text-xs", children: N }),
863
863
  /* @__PURE__ */ e(
864
864
  q,
865
865
  {
@@ -880,143 +880,148 @@ const xs = "1px", Se = "1px", Re = { contentVisibility: "auto", contain: "paint"
880
880
  }
881
881
  );
882
882
  }, vs = Ye("ImagePanel");
883
- function ws(d, t, x, R) {
884
- const { zoom: u, setElements: z, executeElementUpdate: r } = R, h = d.transformData.width || 300 / u, n = d.transformData.height || 300 / u;
885
- t.imageUrl = x, t.transformData.cropX = 0, t.transformData.cropY = 0, t.transformData.cropWidth = 1, t.transformData.cropHeight = 1, t.transformData.flipHorizontal = !1, t.transformData.flipVertical = !1, t.transformData.borderRadius = 0, t.imageLoaded = !1, t.imageElement = null, t.isCropping = !1, t.preserveDimensions = !1, t.transformData.width = h, t.transformData.height = n, t.onLoadCallback = (m) => {
886
- const a = m, p = a.transformData.width, A = a.transformData.height, b = Math.min(h / p, n / A, 1);
887
- b < 1 && (a.transformData.width = p * b, a.transformData.height = A * b), z((T) => T.map((N) => N.id === a.id ? a : N));
888
- }, t.loadImage(x), r(d, t);
883
+ function ws(u, t, b, R) {
884
+ const { zoom: f, setElements: z, executeElementUpdate: r } = R, g = u.transformData.width || 300 / f, n = u.transformData.height || 300 / f;
885
+ t.imageUrl = b, t.transformData.cropX = 0, t.transformData.cropY = 0, t.transformData.cropWidth = 1, t.transformData.cropHeight = 1, t.transformData.flipHorizontal = !1, t.transformData.flipVertical = !1, t.transformData.borderRadius = 0, t.imageLoaded = !1, t.imageElement = null, t.isCropping = !1, t.preserveDimensions = !1, t.transformData.width = g, t.transformData.height = n, t.onLoadCallback = (m) => {
886
+ const a = m, p = a.transformData.width, A = a.transformData.height, x = Math.min(g / p, n / A, 1);
887
+ x < 1 && (a.transformData.width = p * x, a.transformData.height = A * x), z((T) => T.map((I) => I.id === a.id ? a : I));
888
+ }, t.loadImage(b), r(u, t);
889
889
  }
890
890
  const Ls = ({
891
- isOpen: d,
891
+ isOpen: u,
892
892
  onOpenChange: t,
893
- onImageAdded: x,
893
+ onImageAdded: b,
894
894
  onImageChanged: R,
895
- changingElementId: u,
895
+ changingElementId: f,
896
896
  onChangingElementIdChange: z,
897
897
  services: r
898
898
  }) => {
899
899
  var J;
900
900
  const {
901
- elements: h,
901
+ elements: g,
902
902
  setElements: n,
903
903
  canvasEditorRef: m,
904
904
  artboardManager: a,
905
905
  executeAddElement: p,
906
906
  executeElementUpdate: A,
907
- executeRemoveElement: b
908
- } = rs(), { selectedId: T, setSelectedId: N } = as(), { activeArtboardId: y } = ds(), S = Fe(), Z = _e(() => {
907
+ executeRemoveElement: x
908
+ } = rs(), { selectedId: T, setSelectedId: I } = as(), { activeArtboardId: k } = ds(), S = Fe(), Z = _e(() => {
909
909
  if (S.ingestImage) return S.ingestImage;
910
910
  if (r != null && r.ingestImage) return r.ingestImage;
911
- if (r != null && r.ingestImageUrl) return ms(r.ingestImageUrl);
911
+ if (r != null && r.ingestImageUrl) return us(r.ingestImageUrl);
912
912
  }, [S.ingestImage, r == null ? void 0 : r.ingestImage, r == null ? void 0 : r.ingestImageUrl]), te = B(Z);
913
913
  te.current = Z;
914
- const H = B(h);
915
- H.current = h;
914
+ const $ = B(g);
915
+ $.current = g;
916
916
  const C = B(T);
917
917
  C.current = T;
918
- const [ce, ie] = o(null), $ = u ?? ce, P = z ?? ie, [le, Y] = o(!1), D = he(
919
- async (f) => {
918
+ const [ce, le] = o(null), j = f ?? ce, P = z ?? le, [de, Y] = o(!1), D = ge(
919
+ async (h) => {
920
920
  var F, me;
921
921
  const U = te.current;
922
922
  if (U) {
923
923
  Y(!0);
924
924
  try {
925
- f = await U(f);
926
- } catch (g) {
927
- vs.warn("Image ingest failed; placing the original URL", g);
925
+ h = await U(h);
926
+ } catch (i) {
927
+ vs.warn("Image ingest failed; placing the original URL", i);
928
928
  } finally {
929
929
  Y(!1);
930
930
  }
931
931
  }
932
- const X = H.current, ge = C.current;
933
- let K = $, pe = [];
934
- const W = !ns(a.getActiveArtboard()), Ne = W ? a.placeholderElementIds().filter((g) => g !== $) : [], ae = () => {
935
- for (const g of Ne) {
936
- const E = H.current.find((I) => I.id === g);
937
- E && b(E);
932
+ const X = $.current, pe = C.current;
933
+ let K = j, ae = [];
934
+ const W = !ns(a.getActiveArtboard()), Ne = W ? a.placeholderElementIds().filter((i) => i !== j) : [], ne = () => {
935
+ for (const i of Ne) {
936
+ const w = $.current.find((N) => N.id === i);
937
+ w && x(w);
938
938
  }
939
939
  };
940
- if (!K && y && !W) {
941
- const g = a.placeholderOnlyElementIds(y), E = g ? X.find((I) => g.includes(I.id) && Ue(I)) : void 0;
942
- g && E && (K = E.id, pe = g.filter((I) => I !== E.id));
940
+ if (!K && k && !W) {
941
+ const i = a.placeholderOnlyElementIds(k), w = i ? X.find((N) => i.includes(N.id) && Ue(N)) : void 0;
942
+ i && w ? (K = w.id, ae = i.filter((N) => N !== w.id)) : i && (ae = i);
943
943
  }
944
944
  if (K) {
945
- const g = X.find((E) => E.id === K);
946
- if (g && Ue(g)) {
947
- const E = a.getArtboardForElement(g.id) ?? a.getActiveArtboard(), I = await Pe(E, f), _ = H.current.find((O) => O.id === g.id) ?? g, i = _.clone();
948
- I ? (i.imageUrl = f, i.transformData.cropX = 0, i.transformData.cropY = 0, i.transformData.cropWidth = 1, i.transformData.cropHeight = 1, i.transformData.flipHorizontal = !1, i.transformData.flipVertical = !1, i.transformData.borderRadius = 0, i.imageLoaded = !1, i.imageElement = null, i.isCropping = !1, i.preserveDimensions = !0, i.rotation = 0, i.x = I.x, i.y = I.y, i.transformData.width = I.width, i.transformData.height = I.height, i.onLoadCallback = (O) => {
945
+ const i = X.find((w) => w.id === K);
946
+ if (i && Ue(i)) {
947
+ const w = a.getArtboardForElement(i.id) ?? a.getActiveArtboard(), N = await Pe(w, h), _ = $.current.find((O) => O.id === i.id) ?? i, l = _.clone();
948
+ N ? (l.imageUrl = h, l.transformData.cropX = 0, l.transformData.cropY = 0, l.transformData.cropWidth = 1, l.transformData.cropHeight = 1, l.transformData.flipHorizontal = !1, l.transformData.flipVertical = !1, l.transformData.borderRadius = 0, l.imageLoaded = !1, l.imageElement = null, l.isCropping = !1, l.preserveDimensions = !0, l.rotation = 0, l.x = N.x, l.y = N.y, l.transformData.width = N.width, l.transformData.height = N.height, l.onLoadCallback = (O) => {
949
949
  const ee = O;
950
950
  n((se) => se.map((ye) => ye.id === ee.id ? ee : ye));
951
- }, A(_, i), i.loadImage(f)) : ws(_, i, f, {
951
+ }, A(_, l), l.loadImage(h)) : ws(_, l, h, {
952
952
  zoom: ((F = m.current) == null ? void 0 : F.getZoom()) || 1,
953
953
  setElements: n,
954
954
  executeElementUpdate: A
955
- }), a.unmarkPlaceholder(i.id);
956
- for (const O of pe) {
957
- const ee = H.current.find((se) => se.id === O);
958
- ee && b(ee);
955
+ }), a.unmarkPlaceholder(l.id);
956
+ for (const O of ae) {
957
+ const ee = $.current.find((se) => se.id === O);
958
+ ee && x(ee);
959
959
  }
960
- ae(), $ || N(i.id), R && R(i);
960
+ ne(), j || I(l.id), R && R(l);
961
961
  }
962
- $ && P(null);
962
+ j && P(null);
963
963
  return;
964
964
  }
965
- if (!y) {
965
+ if (!k) {
966
966
  alert("Please create or select an artboard first");
967
967
  return;
968
968
  }
969
- const xe = `element-${Date.now()}`, V = a.getActiveArtboard(), Ce = V ? V.x + V.width / 2 : window.innerWidth / 2, be = V ? V.y + V.height / 2 : window.innerHeight / 2, ve = ((me = m.current) == null ? void 0 : me.getZoom()) || 1, G = await Pe(V, f), de = new fs({
969
+ const xe = `element-${Date.now()}`, V = a.getActiveArtboard(), Ce = V ? V.x + V.width / 2 : window.innerWidth / 2, be = V ? V.y + V.height / 2 : window.innerHeight / 2, ve = ((me = m.current) == null ? void 0 : me.getZoom()) || 1, G = await Pe(V, h), ue = new fs({
970
970
  id: xe,
971
971
  x: G ? G.x : Ce,
972
972
  y: G ? G.y : be,
973
- imageUrl: f,
973
+ imageUrl: h,
974
974
  ...G ? { preserveDimensions: !0 } : {},
975
975
  transformData: G ? { width: G.width, height: G.height } : {
976
976
  width: 300 / ve,
977
977
  height: 300 / ve
978
978
  },
979
- onLoadCallback: (g) => {
980
- const E = g;
981
- n((I) => I.map((_) => _.id === E.id ? E : _));
979
+ onLoadCallback: (i) => {
980
+ const w = i;
981
+ n((N) => N.map((_) => _.id === w.id ? w : _));
982
982
  }
983
983
  });
984
- a.addElementToArtboard(xe, y), p(de, y, ge || void 0), ae(), N(xe), x && x(de);
984
+ a.addElementToArtboard(xe, k), p(ue, k, pe || void 0), ne();
985
+ for (const i of ae) {
986
+ const w = $.current.find((N) => N.id === i);
987
+ w && x(w);
988
+ }
989
+ I(xe), b && b(ue);
985
990
  },
986
991
  [
987
- $,
992
+ j,
988
993
  // Note: elements and selectedId are accessed via refs (elementsRef, selectedIdRef)
989
994
  // to prevent callback recreation on every context update
990
995
  a,
991
996
  p,
992
997
  A,
993
- b,
994
- y,
998
+ x,
999
+ k,
995
1000
  m,
996
1001
  n,
997
- N,
1002
+ I,
998
1003
  P,
999
- x,
1004
+ b,
1000
1005
  R
1001
1006
  ]
1002
- ), v = he(
1003
- (f) => {
1004
- t(f), f || P(null);
1007
+ ), v = ge(
1008
+ (h) => {
1009
+ t(h), h || P(null);
1005
1010
  },
1006
1011
  [t, P]
1007
- ), re = $ ? (J = h.find((f) => f.id === $)) == null ? void 0 : J.imageUrl : void 0, j = /* @__PURE__ */ e(
1012
+ ), re = j ? (J = g.find((h) => h.id === j)) == null ? void 0 : J.imageUrl : void 0, H = /* @__PURE__ */ e(
1008
1013
  bs,
1009
1014
  {
1010
- isOpen: d,
1015
+ isOpen: u,
1011
1016
  onToggle: v,
1012
1017
  onImageSelect: D,
1013
1018
  currentImageUrl: re,
1014
- busy: le
1019
+ busy: de
1015
1020
  }
1016
1021
  );
1017
- return r ? /* @__PURE__ */ e(us, { services: r, children: j }) : j;
1022
+ return r ? /* @__PURE__ */ e(ms, { services: r, children: H }) : H;
1018
1023
  };
1019
1024
  export {
1020
1025
  Ls as ImagePanel
1021
1026
  };
1022
- //# sourceMappingURL=ImagePanel-DhOWKvIN.js.map
1027
+ //# sourceMappingURL=ImagePanel-bW3yr6Ac.js.map