@snowcone-app/canvas 0.44.1 → 0.45.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.
- package/dist/{ContextualToolbars-rCZo-KCm.js → ContextualToolbars-5tHC6s0Y.js} +4 -4
- package/dist/{ContextualToolbars-rCZo-KCm.js.map → ContextualToolbars-5tHC6s0Y.js.map} +1 -1
- package/dist/{EditorCanvasImpl-VkjeyOGd.js → EditorCanvasImpl-B4VBKRBA.js} +6 -6
- package/dist/{EditorCanvasImpl-VkjeyOGd.js.map → EditorCanvasImpl-B4VBKRBA.js.map} +1 -1
- package/dist/{ImagePanel-DhOWKvIN.js → ImagePanel-bW3yr6Ac.js} +264 -259
- package/dist/{ImagePanel-DhOWKvIN.js.map → ImagePanel-bW3yr6Ac.js.map} +1 -1
- package/dist/{SnowconeCanvas-COXpmwkS.js → SnowconeCanvas-crxPwbib.js} +441 -439
- package/dist/SnowconeCanvas-crxPwbib.js.map +1 -0
- package/dist/advanced.mjs +9 -9
- package/dist/components/embed/SnowconeCanvas.d.ts +6 -0
- package/dist/components/embed/kernel.d.ts +2 -0
- package/dist/{custom-icons-C4bzABm2.js → custom-icons-DQRp8GhF.js} +2 -2
- package/dist/{custom-icons-C4bzABm2.js.map → custom-icons-DQRp8GhF.js.map} +1 -1
- package/dist/{design-builder-DCHVrEFV.js → design-builder-sH53Og6j.js} +598 -589
- package/dist/design-builder-sH53Og6j.js.map +1 -0
- package/dist/{embed-CamnTsuT.js → embed-CYWbpvu_.js} +6 -6
- package/dist/{embed-CamnTsuT.js.map → embed-CYWbpvu_.js.map} +1 -1
- package/dist/embed.mjs +4 -4
- package/dist/index.mjs +7 -7
- package/dist/{template-fields-CK7Uvvc8.js → template-fields-BaQG0CJY.js} +3 -3
- package/dist/{template-fields-CK7Uvvc8.js.map → template-fields-BaQG0CJY.js.map} +1 -1
- package/dist/testing.mjs +2 -2
- package/dist/{useCommands-BrkGKdXr.js → useCommands-F-b_SwW-.js} +3 -3
- package/dist/{useCommands-BrkGKdXr.js.map → useCommands-F-b_SwW-.js.map} +1 -1
- package/dist/{validation-jgr2OtXC.js → validation-hn5ZX8Po.js} +9 -8
- package/dist/{validation-jgr2OtXC.js.map → validation-hn5ZX8Po.js.map} +1 -1
- package/example/package.json +1 -1
- package/package.json +3 -3
- package/dist/SnowconeCanvas-COXpmwkS.js.map +0 -1
- package/dist/design-builder-DCHVrEFV.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as e, jsxs as c, Fragment as
|
|
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
|
|
4
|
-
import { b as rs, c as as, d as ns, p as Pe } from "./design-builder-
|
|
5
|
-
import { u as os, c as is, a as Fe, D as ls, I as
|
|
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-
|
|
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:
|
|
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
|
-
|
|
25
|
+
u
|
|
26
26
|
),
|
|
27
|
-
ref:
|
|
28
|
-
disabled:
|
|
27
|
+
ref: g,
|
|
28
|
+
disabled: b,
|
|
29
29
|
readOnly: R,
|
|
30
|
-
required:
|
|
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(
|
|
42
|
-
const
|
|
43
|
-
return !
|
|
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:
|
|
46
|
-
const [
|
|
47
|
-
r ||
|
|
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,
|
|
51
|
-
top:
|
|
52
|
-
bottom:
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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)),
|
|
64
|
-
},
|
|
65
|
-
|
|
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),
|
|
67
|
+
m(v), I(!1), z(!1);
|
|
68
68
|
}, C = () => {
|
|
69
69
|
p.current && (clearTimeout(p.current), p.current = null), a.current = setTimeout(() => {
|
|
70
|
-
|
|
70
|
+
g(!0);
|
|
71
71
|
}, 400);
|
|
72
72
|
}, ce = () => {
|
|
73
|
-
a.current && (clearTimeout(a.current), a.current = null),
|
|
74
|
-
},
|
|
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
|
-
|
|
78
|
-
}, P = t.source === "unsplash" ? "Unsplash" : "Pixabay",
|
|
79
|
-
if (!
|
|
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:
|
|
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:
|
|
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 ${
|
|
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(
|
|
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:
|
|
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
|
-
|
|
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(
|
|
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:
|
|
180
|
-
const [
|
|
181
|
-
r ||
|
|
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
|
-
|
|
184
|
+
g(!0);
|
|
185
185
|
}, 400);
|
|
186
186
|
}, A = () => {
|
|
187
|
-
n.current && (clearTimeout(n.current), n.current = null),
|
|
188
|
-
},
|
|
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
|
-
|
|
192
|
-
},
|
|
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"} ${
|
|
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 ${
|
|
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:
|
|
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 ${
|
|
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 ${
|
|
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(
|
|
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:
|
|
241
|
+
onMouseEnter: x,
|
|
242
242
|
onMouseLeave: T,
|
|
243
243
|
children: [
|
|
244
244
|
/* @__PURE__ */ c("div", { className: "sc:mb-1", children: [
|
|
245
|
-
/* @__PURE__ */ e(
|
|
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:
|
|
257
|
+
isOpen: u,
|
|
258
258
|
onToggle: t,
|
|
259
|
-
onImageSelect:
|
|
259
|
+
onImageSelect: b,
|
|
260
260
|
currentImageUrl: R,
|
|
261
|
-
placement:
|
|
261
|
+
placement: f = "bottom",
|
|
262
262
|
busy: z = !1
|
|
263
263
|
}) => {
|
|
264
|
-
const { imageSearch: r, generate:
|
|
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
|
-
...
|
|
269
|
+
...g ? ["ai"] : []
|
|
270
270
|
],
|
|
271
|
-
[r, n,
|
|
272
|
-
), [p, A] = o(""), [
|
|
273
|
-
|
|
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]),
|
|
276
|
-
|
|
277
|
-
}, [
|
|
278
|
-
|
|
279
|
-
}, [
|
|
280
|
-
const se =
|
|
281
|
-
async (s,
|
|
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),
|
|
283
|
+
Z(!0), $(null);
|
|
284
284
|
try {
|
|
285
|
-
const L = await r.search({ query: s, page:
|
|
286
|
-
|
|
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
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
}, [
|
|
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 =
|
|
302
|
-
S || !P || se(p,
|
|
303
|
-
}, [S, P, p,
|
|
304
|
-
|
|
305
|
-
const s =
|
|
306
|
-
if (!s || !
|
|
307
|
-
const
|
|
308
|
-
(
|
|
309
|
-
|
|
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
|
|
320
|
-
|
|
319
|
+
return d.observe(s), () => {
|
|
320
|
+
d.disconnect();
|
|
321
321
|
};
|
|
322
|
-
}, [
|
|
323
|
-
const Ie =
|
|
324
|
-
async (s,
|
|
322
|
+
}, [u, C, P, S, De]);
|
|
323
|
+
const Ie = ge(
|
|
324
|
+
async (s, d) => {
|
|
325
325
|
if (n) {
|
|
326
|
-
U(!0),
|
|
326
|
+
U(!0), pe(null);
|
|
327
327
|
try {
|
|
328
|
-
const { results:
|
|
329
|
-
J(
|
|
330
|
-
const Le = new Set(Q.map((
|
|
331
|
-
return [...Q, ...
|
|
332
|
-
} :
|
|
333
|
-
} catch (
|
|
334
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
}, [
|
|
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 =
|
|
348
|
-
|
|
349
|
-
}, [
|
|
350
|
-
|
|
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 || !
|
|
353
|
-
const
|
|
354
|
-
(
|
|
355
|
-
|
|
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
|
|
364
|
-
|
|
363
|
+
return d.observe(s), () => {
|
|
364
|
+
d.disconnect();
|
|
365
365
|
};
|
|
366
|
-
}, [
|
|
366
|
+
}, [u, C, W, h, Me]);
|
|
367
367
|
const ze = (s) => {
|
|
368
|
-
const
|
|
369
|
-
|
|
368
|
+
const d = s.selectUrl || s.urls.svg || s.urls.png;
|
|
369
|
+
d && (b(d), t(!1));
|
|
370
370
|
}, Te = (s) => {
|
|
371
|
-
var
|
|
371
|
+
var d;
|
|
372
372
|
try {
|
|
373
|
-
Promise.resolve((
|
|
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
|
-
|
|
377
|
+
b(s.urls.regular), t(!1);
|
|
378
378
|
}, qe = (s) => {
|
|
379
|
-
s.preventDefault(),
|
|
379
|
+
s.preventDefault(), x.trim() && (b(x.trim()), t(!1));
|
|
380
380
|
}, Ze = (s) => {
|
|
381
|
-
var
|
|
382
|
-
const
|
|
383
|
-
if (
|
|
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
|
|
387
|
-
const Le = (
|
|
386
|
+
var fe;
|
|
387
|
+
const Le = (fe = Q.target) == null ? void 0 : fe.result;
|
|
388
388
|
T(Le);
|
|
389
|
-
}, L.readAsDataURL(
|
|
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 || !
|
|
396
|
-
|
|
395
|
+
if (!(!m || !x.trim())) {
|
|
396
|
+
w(!0), _(null);
|
|
397
397
|
try {
|
|
398
|
-
const s = await m(
|
|
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
|
-
|
|
403
|
+
w(!1);
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
}, Oe = async (s) => {
|
|
407
|
-
var
|
|
408
|
-
if (s.preventDefault(), !!
|
|
407
|
+
var d, y;
|
|
408
|
+
if (s.preventDefault(), !!g) {
|
|
409
409
|
if (!V.trim()) {
|
|
410
|
-
|
|
410
|
+
ue("Please enter a prompt");
|
|
411
411
|
return;
|
|
412
412
|
}
|
|
413
|
-
ve(!0),
|
|
413
|
+
ve(!0), ue(null), me(null);
|
|
414
414
|
try {
|
|
415
|
-
const Q = (
|
|
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 :
|
|
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
|
-
|
|
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 && (
|
|
431
|
+
F && (b(F), t(!1));
|
|
432
432
|
}, ss = async () => {
|
|
433
433
|
if (!(!m || !F)) {
|
|
434
|
-
|
|
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
|
-
|
|
441
|
+
w(!1);
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
|
-
}, ts = (s,
|
|
445
|
-
const
|
|
446
|
-
return
|
|
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:
|
|
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:
|
|
456
|
-
height:
|
|
457
|
-
width:
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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 &&
|
|
567
|
-
|
|
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:
|
|
577
|
-
gridAutoRows:
|
|
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:
|
|
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:
|
|
591
|
+
gridTemplateColumns: f === "bottom" ? "repeat(auto-fill, minmax(150px, 1fr))" : "repeat(auto-fill, minmax(120px, 1fr))",
|
|
592
592
|
gap: Se
|
|
593
593
|
},
|
|
594
|
-
children:
|
|
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:
|
|
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 &&
|
|
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
|
-
|
|
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:
|
|
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: !
|
|
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
|
-
|
|
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:
|
|
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:
|
|
692
|
+
children: i ? /* @__PURE__ */ c(ie, { children: [
|
|
693
693
|
/* @__PURE__ */ e(
|
|
694
|
-
|
|
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(
|
|
702
|
-
/* @__PURE__ */ e(
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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(
|
|
745
|
-
"aria-label":
|
|
746
|
-
children:
|
|
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
|
-
|
|
752
|
-
|
|
753
|
-
|
|
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:
|
|
762
|
-
gridAutoRows:
|
|
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:
|
|
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:
|
|
776
|
+
gridTemplateColumns: f === "bottom" ? "repeat(auto-fill, minmax(120px, 1fr))" : "repeat(auto-fill, minmax(100px, 1fr))",
|
|
777
777
|
gap: Se
|
|
778
778
|
},
|
|
779
|
-
children:
|
|
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
|
-
|
|
785
|
-
!W && !
|
|
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
|
-
!
|
|
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
|
-
|
|
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(
|
|
819
|
-
/* @__PURE__ */ e(
|
|
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(
|
|
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:
|
|
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:
|
|
854
|
-
/* @__PURE__ */ e(
|
|
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(
|
|
857
|
-
/* @__PURE__ */ e(
|
|
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
|
-
|
|
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(
|
|
884
|
-
const { zoom:
|
|
885
|
-
t.imageUrl =
|
|
886
|
-
const a = m, p = a.transformData.width, A = a.transformData.height,
|
|
887
|
-
|
|
888
|
-
}, t.loadImage(
|
|
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:
|
|
891
|
+
isOpen: u,
|
|
892
892
|
onOpenChange: t,
|
|
893
|
-
onImageAdded:
|
|
893
|
+
onImageAdded: b,
|
|
894
894
|
onImageChanged: R,
|
|
895
|
-
changingElementId:
|
|
895
|
+
changingElementId: f,
|
|
896
896
|
onChangingElementIdChange: z,
|
|
897
897
|
services: r
|
|
898
898
|
}) => {
|
|
899
899
|
var J;
|
|
900
900
|
const {
|
|
901
|
-
elements:
|
|
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:
|
|
908
|
-
} = rs(), { selectedId: T, setSelectedId:
|
|
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
|
|
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
|
|
915
|
-
|
|
914
|
+
const $ = B(g);
|
|
915
|
+
$.current = g;
|
|
916
916
|
const C = B(T);
|
|
917
917
|
C.current = T;
|
|
918
|
-
const [ce,
|
|
919
|
-
async (
|
|
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
|
-
|
|
926
|
-
} catch (
|
|
927
|
-
vs.warn("Image ingest failed; placing the original URL",
|
|
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 =
|
|
933
|
-
let K =
|
|
934
|
-
const W = !ns(a.getActiveArtboard()), Ne = W ? a.placeholderElementIds().filter((
|
|
935
|
-
for (const
|
|
936
|
-
const
|
|
937
|
-
|
|
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 &&
|
|
941
|
-
const
|
|
942
|
-
|
|
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
|
|
946
|
-
if (
|
|
947
|
-
const
|
|
948
|
-
|
|
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(_,
|
|
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(
|
|
956
|
-
for (const O of
|
|
957
|
-
const ee =
|
|
958
|
-
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
|
-
|
|
960
|
+
ne(), j || I(l.id), R && R(l);
|
|
961
961
|
}
|
|
962
|
-
|
|
962
|
+
j && P(null);
|
|
963
963
|
return;
|
|
964
964
|
}
|
|
965
|
-
if (!
|
|
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,
|
|
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:
|
|
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: (
|
|
980
|
-
const
|
|
981
|
-
n((
|
|
979
|
+
onLoadCallback: (i) => {
|
|
980
|
+
const w = i;
|
|
981
|
+
n((N) => N.map((_) => _.id === w.id ? w : _));
|
|
982
982
|
}
|
|
983
983
|
});
|
|
984
|
-
a.addElementToArtboard(xe,
|
|
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
|
-
|
|
994
|
-
|
|
998
|
+
x,
|
|
999
|
+
k,
|
|
995
1000
|
m,
|
|
996
1001
|
n,
|
|
997
|
-
|
|
1002
|
+
I,
|
|
998
1003
|
P,
|
|
999
|
-
|
|
1004
|
+
b,
|
|
1000
1005
|
R
|
|
1001
1006
|
]
|
|
1002
|
-
), v =
|
|
1003
|
-
(
|
|
1004
|
-
t(
|
|
1007
|
+
), v = ge(
|
|
1008
|
+
(h) => {
|
|
1009
|
+
t(h), h || P(null);
|
|
1005
1010
|
},
|
|
1006
1011
|
[t, P]
|
|
1007
|
-
), re =
|
|
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:
|
|
1015
|
+
isOpen: u,
|
|
1011
1016
|
onToggle: v,
|
|
1012
1017
|
onImageSelect: D,
|
|
1013
1018
|
currentImageUrl: re,
|
|
1014
|
-
busy:
|
|
1019
|
+
busy: de
|
|
1015
1020
|
}
|
|
1016
1021
|
);
|
|
1017
|
-
return r ? /* @__PURE__ */ e(
|
|
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-
|
|
1027
|
+
//# sourceMappingURL=ImagePanel-bW3yr6Ac.js.map
|