@chaibuilder/pages 0.4.6-beta.2 → 0.4.6-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{B4MFY5CR-Doi8QlXL.js → B4MFY5CR-B0neOOrT.js} +1 -1
- package/dist/{B4MFY5CR-CgKmoZhy.cjs → B4MFY5CR-D1hD4AZA.cjs} +1 -1
- package/dist/{HO4MOOFI-4Q-h7u6O.cjs → HO4MOOFI-DBRfBGwX.cjs} +1 -1
- package/dist/{HO4MOOFI-CWU4gOCj.js → HO4MOOFI-ZMWaaBGt.js} +2 -2
- package/dist/{HUY7CZI3-CEnI5Lww.cjs → HUY7CZI3-CFg61x0n.cjs} +1 -1
- package/dist/{HUY7CZI3-BuVBFUXg.js → HUY7CZI3-DFWIfsRg.js} +2 -2
- package/dist/asset-metadata-editor-r5vYHUfm.js +108 -0
- package/dist/asset-metadata-editor-zw9u1BB9.cjs +1 -0
- package/dist/{digital-asset-manager-Scnvw98W.js → digital-asset-manager-9X9QSmn9.js} +248 -238
- package/dist/digital-asset-manager-CZp5Gnel.cjs +1 -0
- package/dist/{image-editor-BQ6_F-iv.js → image-editor-CwVua57o.js} +13 -13
- package/dist/{image-editor-BKUmqgv0.cjs → image-editor-D8wu5UNM.cjs} +1 -1
- package/dist/{index-sSI8ulEa.cjs → index-DL1vcgk2.cjs} +1 -1
- package/dist/{index-Ci9oNrDB.js → index-D_vvEddR.js} +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.ts +4 -1
- package/dist/server.js +7 -7
- package/package.json +1 -1
- package/dist/asset-metadata-editor-CEFwXx62.js +0 -91
- package/dist/asset-metadata-editor-YXDey62L.cjs +0 -1
- package/dist/digital-asset-manager-CE2qYOMT.cjs +0 -1
|
@@ -1,260 +1,262 @@
|
|
|
1
|
-
import { jsxs as a, Fragment as
|
|
2
|
-
import W, { useState as
|
|
3
|
-
import { mergeClasses as
|
|
4
|
-
import { Tabs as
|
|
5
|
-
import { debounce as
|
|
6
|
-
import { Search as
|
|
7
|
-
import { useDropzone as
|
|
8
|
-
import { useQueryClient as
|
|
9
|
-
import { toast as
|
|
10
|
-
import { W as z, X as
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
return
|
|
1
|
+
import { jsxs as a, Fragment as B, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import W, { useState as S, useCallback as A, useMemo as re, useRef as oe, Suspense as O } from "react";
|
|
3
|
+
import { mergeClasses as Y } from "@chaibuilder/sdk";
|
|
4
|
+
import { Tabs as ce, TabsList as de, TabsTrigger as $, Button as f, TabsContent as H, Input as ue, Card as me, CardContent as he, Dialog as ge, DialogContent as pe, DialogHeader as fe, DialogTitle as ye, DialogDescription as ve, DialogFooter as xe } from "@chaibuilder/sdk/ui";
|
|
5
|
+
import { debounce as Ne, find as Ae, merge as we } from "lodash-es";
|
|
6
|
+
import { Search as Se, Film as be, ImageIcon as Ce, Edit as Ee, Trash2 as Te, Loader2 as V, Upload as De } from "lucide-react";
|
|
7
|
+
import { useDropzone as Pe } from "react-dropzone";
|
|
8
|
+
import { useQueryClient as Q, useMutation as R, useQuery as Ue } from "@tanstack/react-query";
|
|
9
|
+
import { toast as b } from "sonner";
|
|
10
|
+
import { W as z, X as F, Y as y, Z as ze } from "./index-D_vvEddR.js";
|
|
11
|
+
const Fe = () => {
|
|
12
|
+
const t = z(), r = Q(), o = F();
|
|
13
|
+
return R({
|
|
14
14
|
mutationFn: async ({
|
|
15
|
-
file:
|
|
16
|
-
folderId:
|
|
17
|
-
name:
|
|
18
|
-
}) => o(
|
|
19
|
-
action:
|
|
20
|
-
data: { file:
|
|
15
|
+
file: i,
|
|
16
|
+
folderId: d,
|
|
17
|
+
name: u
|
|
18
|
+
}) => o(t, {
|
|
19
|
+
action: y.UPLOAD_ASSET,
|
|
20
|
+
data: { file: i, folderId: d, name: u }
|
|
21
21
|
}),
|
|
22
22
|
onSuccess: () => {
|
|
23
|
-
|
|
24
|
-
queryKey: [
|
|
25
|
-
}),
|
|
23
|
+
r.invalidateQueries({
|
|
24
|
+
queryKey: [y.GET_ASSETS]
|
|
25
|
+
}), b.success("Asset uploaded successfully");
|
|
26
26
|
},
|
|
27
27
|
onError: () => {
|
|
28
|
-
|
|
28
|
+
b.error("Failed to upload asset");
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
},
|
|
32
|
-
const
|
|
33
|
-
return
|
|
34
|
-
mutationFn: async (
|
|
35
|
-
action:
|
|
36
|
-
data: { id:
|
|
31
|
+
}, Me = () => {
|
|
32
|
+
const t = z(), r = Q(), o = F();
|
|
33
|
+
return R({
|
|
34
|
+
mutationFn: async (i) => o(t, {
|
|
35
|
+
action: y.DELETE_ASSET,
|
|
36
|
+
data: { id: i }
|
|
37
37
|
}),
|
|
38
38
|
onSuccess: () => {
|
|
39
|
-
|
|
40
|
-
queryKey: [
|
|
41
|
-
}),
|
|
39
|
+
r.invalidateQueries({
|
|
40
|
+
queryKey: [y.GET_ASSETS]
|
|
41
|
+
}), b.success("Asset deleted successfully");
|
|
42
42
|
},
|
|
43
43
|
onError: () => {
|
|
44
|
-
|
|
44
|
+
b.error("Failed to delete asset");
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
},
|
|
48
|
-
const
|
|
49
|
-
return
|
|
50
|
-
mutationFn: async (
|
|
51
|
-
action:
|
|
52
|
-
data:
|
|
47
|
+
}, Ie = () => {
|
|
48
|
+
const t = z(), r = Q(), o = F();
|
|
49
|
+
return R({
|
|
50
|
+
mutationFn: async (i) => o(t, {
|
|
51
|
+
action: y.UPDATE_ASSET,
|
|
52
|
+
data: i
|
|
53
53
|
}),
|
|
54
54
|
onSuccess: () => {
|
|
55
|
-
|
|
56
|
-
queryKey: [
|
|
57
|
-
}),
|
|
55
|
+
r.invalidateQueries({
|
|
56
|
+
queryKey: [y.GET_ASSETS]
|
|
57
|
+
}), b.success("Asset updated successfully");
|
|
58
58
|
},
|
|
59
59
|
onError: () => {
|
|
60
|
-
|
|
60
|
+
b.error("Failed to update asset");
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
-
},
|
|
64
|
-
const
|
|
65
|
-
return
|
|
66
|
-
queryKey: [
|
|
67
|
-
queryFn: async (
|
|
68
|
-
action:
|
|
63
|
+
}, ke = (t = {}) => {
|
|
64
|
+
const r = z(), o = F(), { search: i, page: d = 1, limit: u = 10 } = t;
|
|
65
|
+
return Ue({
|
|
66
|
+
queryKey: [ze, y.GET_ASSETS, i, d, u],
|
|
67
|
+
queryFn: async () => (await o(r, {
|
|
68
|
+
action: y.GET_ASSETS,
|
|
69
69
|
data: {
|
|
70
|
-
search:
|
|
71
|
-
page:
|
|
72
|
-
limit:
|
|
70
|
+
search: i,
|
|
71
|
+
page: d,
|
|
72
|
+
limit: u
|
|
73
73
|
}
|
|
74
74
|
})).data,
|
|
75
|
-
initialPageParam: 1,
|
|
76
|
-
getNextPageParam: (t) => ((t == null ? void 0 : t.page) ?? 0) * ((t == null ? void 0 : t.pageSize) ?? 0) < ((t == null ? void 0 : t.total) ?? 0) ? (t.page ?? 0) + 1 : void 0,
|
|
77
|
-
getPreviousPageParam: (t) => (t.page ?? 0) > 1 ? (t.page ?? 0) - 1 : void 0,
|
|
78
75
|
retry: 1
|
|
79
76
|
});
|
|
80
77
|
};
|
|
81
|
-
function
|
|
82
|
-
const [
|
|
78
|
+
function qe() {
|
|
79
|
+
const [r, o] = S([]), [i, d] = S({
|
|
83
80
|
query: "",
|
|
81
|
+
page: 1,
|
|
84
82
|
pageSize: 10
|
|
85
|
-
}),
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
83
|
+
}), u = Ne(() => i.query, 300)(), { data: n, isLoading: C } = ke({
|
|
84
|
+
search: (u == null ? void 0 : u.toLowerCase().trim()) || "",
|
|
85
|
+
page: i.page,
|
|
86
|
+
limit: i.pageSize
|
|
87
|
+
}), v = n ? Math.ceil(n.total / n.pageSize) : 0, c = (n == null ? void 0 : n.page) || 1, g = c < v, m = c > 1, { mutate: E, isPending: M } = Ie(), { mutate: w, isPending: p } = Fe(), { mutate: T, isPending: D } = Me(), x = A(
|
|
88
|
+
(h) => {
|
|
89
|
+
h >= 1 && h <= v && d((N) => ({
|
|
90
|
+
...N,
|
|
91
|
+
page: h
|
|
92
|
+
}));
|
|
93
|
+
},
|
|
94
|
+
[v]
|
|
95
|
+
), I = A(() => {
|
|
96
|
+
g && x(c + 1);
|
|
97
|
+
}, [c, g, x]), k = A(() => {
|
|
98
|
+
m && x(c - 1);
|
|
99
|
+
}, [c, m, x]), q = A((h) => {
|
|
100
|
+
d((N) => ({
|
|
101
|
+
...N,
|
|
102
|
+
query: h,
|
|
103
|
+
page: 1
|
|
104
|
+
// Reset to first page on new search
|
|
100
105
|
}));
|
|
101
|
-
}, []),
|
|
102
|
-
(
|
|
103
|
-
o((
|
|
106
|
+
}, []), P = A(
|
|
107
|
+
(h) => {
|
|
108
|
+
o((N) => Ae(N, { id: h.id }) ? [] : [h]);
|
|
104
109
|
},
|
|
105
110
|
[!1]
|
|
106
|
-
),
|
|
111
|
+
), j = A(() => {
|
|
107
112
|
o([]);
|
|
108
113
|
}, []);
|
|
109
114
|
return {
|
|
110
115
|
// Data
|
|
111
|
-
query: (
|
|
112
|
-
selectedAssets:
|
|
113
|
-
assets:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
query: (i == null ? void 0 : i.query) || "",
|
|
117
|
+
selectedAssets: r,
|
|
118
|
+
assets: (n == null ? void 0 : n.assets) || [],
|
|
119
|
+
currentPage: c,
|
|
120
|
+
totalPages: v,
|
|
121
|
+
hasNextPage: g,
|
|
122
|
+
hasPreviousPage: m,
|
|
116
123
|
// Mutations
|
|
117
|
-
uploadAsset:
|
|
118
|
-
updateAsset:
|
|
119
|
-
deleteAsset:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
uploadAsset: w,
|
|
125
|
+
updateAsset: E,
|
|
126
|
+
deleteAsset: T,
|
|
127
|
+
goToPage: x,
|
|
128
|
+
nextPage: I,
|
|
129
|
+
previousPage: k,
|
|
130
|
+
updateSearchQuery: q,
|
|
131
|
+
clearSelectedAssets: j,
|
|
132
|
+
updateSelectedAssets: P,
|
|
124
133
|
// Loading
|
|
125
|
-
isLoadingAssets:
|
|
126
|
-
isUploadingAsset:
|
|
127
|
-
isUpdatingAsset:
|
|
128
|
-
isDeletingAsset:
|
|
134
|
+
isLoadingAssets: C,
|
|
135
|
+
isUploadingAsset: p,
|
|
136
|
+
isUpdatingAsset: M,
|
|
137
|
+
isDeletingAsset: D
|
|
129
138
|
};
|
|
130
139
|
}
|
|
131
|
-
const
|
|
132
|
-
function
|
|
133
|
-
close:
|
|
134
|
-
onSelect:
|
|
140
|
+
const je = W.lazy(() => import("./asset-metadata-editor-r5vYHUfm.js")), _e = W.lazy(() => import("./image-editor-CwVua57o.js"));
|
|
141
|
+
function Xe({
|
|
142
|
+
close: t,
|
|
143
|
+
onSelect: r,
|
|
135
144
|
mode: o = "image"
|
|
136
145
|
}) {
|
|
137
|
-
const
|
|
146
|
+
const d = re(() => [o], [o]), [u, n] = S("browse"), [C, v] = S(null), [c, g] = S(null), [m, E] = S({ show: !1, file: "" }), {
|
|
138
147
|
// Data
|
|
139
|
-
query:
|
|
140
|
-
assets:
|
|
141
|
-
selectedAssets:
|
|
142
|
-
hasNextPage: A,
|
|
143
|
-
isFetchingNextPage: y,
|
|
148
|
+
query: M,
|
|
149
|
+
assets: w,
|
|
150
|
+
selectedAssets: p,
|
|
144
151
|
// Mutations
|
|
145
|
-
uploadAsset:
|
|
146
|
-
updateAsset:
|
|
147
|
-
deleteAsset:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
updateSelectedAssets: p,
|
|
152
|
+
uploadAsset: T,
|
|
153
|
+
updateAsset: D,
|
|
154
|
+
deleteAsset: x,
|
|
155
|
+
updateSearchQuery: I,
|
|
156
|
+
clearSelectedAssets: k,
|
|
157
|
+
updateSelectedAssets: q,
|
|
152
158
|
// Loading
|
|
153
|
-
isLoadingAssets:
|
|
154
|
-
isUploadingAsset:
|
|
155
|
-
isUpdatingAsset:
|
|
159
|
+
isLoadingAssets: P,
|
|
160
|
+
isUploadingAsset: j,
|
|
161
|
+
isUpdatingAsset: h
|
|
156
162
|
// isDeletingAsset,
|
|
157
|
-
} =
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
};
|
|
164
|
-
return s.addEventListener("scroll", i), () => s.removeEventListener("scroll", i);
|
|
165
|
-
}, [m, E, A, y]);
|
|
166
|
-
const Z = C(
|
|
167
|
-
async (s) => new Promise((i, L) => {
|
|
168
|
-
const K = s[0], F = new FileReader();
|
|
169
|
-
F.readAsDataURL(K), F.onload = async () => {
|
|
170
|
-
const P = await b({
|
|
171
|
-
file: F.result,
|
|
163
|
+
} = qe(), N = oe(null), K = A(
|
|
164
|
+
async (s) => new Promise((l, _) => {
|
|
165
|
+
const G = s[0], U = new FileReader();
|
|
166
|
+
U.readAsDataURL(G), U.onload = async () => {
|
|
167
|
+
const L = await T({
|
|
168
|
+
file: U.result,
|
|
172
169
|
folderId: null,
|
|
173
|
-
name:
|
|
170
|
+
name: G.name
|
|
174
171
|
});
|
|
175
|
-
|
|
176
|
-
},
|
|
172
|
+
n("browse"), l(L);
|
|
173
|
+
}, U.onerror = (L) => _(L);
|
|
177
174
|
}),
|
|
178
|
-
[
|
|
179
|
-
), { getRootProps:
|
|
180
|
-
onDrop:
|
|
175
|
+
[T]
|
|
176
|
+
), { getRootProps: X, getInputProps: Z, isDragActive: J } = Pe({
|
|
177
|
+
onDrop: K,
|
|
181
178
|
accept: {
|
|
182
|
-
"image/*":
|
|
183
|
-
"video/*":
|
|
179
|
+
"image/*": d.includes("image") ? [] : [],
|
|
180
|
+
"video/*": d.includes("video") ? [] : []
|
|
184
181
|
},
|
|
185
182
|
maxSize: 10 * 1024 * 1024
|
|
186
|
-
}),
|
|
187
|
-
|
|
188
|
-
},
|
|
189
|
-
|
|
183
|
+
}), ee = () => {
|
|
184
|
+
r([p[0].url]), t();
|
|
185
|
+
}, se = async (s) => {
|
|
186
|
+
g(s);
|
|
187
|
+
}, ae = async () => {
|
|
188
|
+
c && (await x(c.id), g(null));
|
|
190
189
|
}, te = (s) => {
|
|
191
|
-
|
|
192
|
-
}, le = async (s,
|
|
193
|
-
await
|
|
190
|
+
v(s);
|
|
191
|
+
}, le = async (s, l) => {
|
|
192
|
+
await D(we(s, l)), t();
|
|
194
193
|
}, ie = (s) => {
|
|
195
|
-
|
|
196
|
-
},
|
|
194
|
+
I(s.target.value);
|
|
195
|
+
}, ne = async (s, l) => {
|
|
197
196
|
try {
|
|
198
|
-
|
|
197
|
+
l ? await T({
|
|
199
198
|
file: s,
|
|
200
199
|
folderId: null,
|
|
201
|
-
name:
|
|
202
|
-
}) : await
|
|
203
|
-
|
|
204
|
-
|
|
200
|
+
name: m.name || ""
|
|
201
|
+
}) : await D({
|
|
202
|
+
id: m.id || "",
|
|
203
|
+
file: s
|
|
204
|
+
}), E({ show: !1, file: "" }), n("browse");
|
|
205
|
+
} catch (_) {
|
|
206
|
+
console.error("Error saving edited image:", _);
|
|
205
207
|
}
|
|
206
208
|
};
|
|
207
|
-
return /* @__PURE__ */ a(
|
|
209
|
+
return /* @__PURE__ */ a(B, { children: [
|
|
208
210
|
/* @__PURE__ */ a("div", { className: "min-w-[700px] min-h-[600px] w-[900px] max-w-[900px]", children: [
|
|
209
211
|
/* @__PURE__ */ e("h1", { className: "text-lg font-medium pb-4", children: "Digital Asset Manager" }),
|
|
210
212
|
/* @__PURE__ */ a(
|
|
211
|
-
|
|
213
|
+
ce,
|
|
212
214
|
{
|
|
213
|
-
value:
|
|
214
|
-
onValueChange: (s) =>
|
|
215
|
+
value: u,
|
|
216
|
+
onValueChange: (s) => n(s),
|
|
215
217
|
className: "flex-1 flex flex-col h-full",
|
|
216
218
|
children: [
|
|
217
219
|
/* @__PURE__ */ a("div", { className: "flex justify-between items-center mb-2", children: [
|
|
218
|
-
/* @__PURE__ */ a(
|
|
219
|
-
/* @__PURE__ */ e(
|
|
220
|
-
/* @__PURE__ */ e(
|
|
220
|
+
/* @__PURE__ */ a(de, { children: [
|
|
221
|
+
/* @__PURE__ */ e($, { value: "browse", children: "Browse Assets" }),
|
|
222
|
+
/* @__PURE__ */ e($, { value: "upload", children: "Upload" })
|
|
221
223
|
] }),
|
|
222
224
|
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
223
|
-
|
|
224
|
-
|
|
225
|
+
p.length > 0 && /* @__PURE__ */ e(B, { children: /* @__PURE__ */ e(
|
|
226
|
+
f,
|
|
225
227
|
{
|
|
226
228
|
variant: "outline",
|
|
227
229
|
size: "sm",
|
|
228
|
-
onClick: () =>
|
|
230
|
+
onClick: () => k(),
|
|
229
231
|
title: "Clear selection",
|
|
230
232
|
children: "Clear"
|
|
231
233
|
}
|
|
232
234
|
) }),
|
|
233
235
|
/* @__PURE__ */ e(
|
|
234
|
-
|
|
236
|
+
f,
|
|
235
237
|
{
|
|
236
238
|
size: "sm",
|
|
237
|
-
onClick:
|
|
238
|
-
disabled:
|
|
239
|
+
onClick: ee,
|
|
240
|
+
disabled: p.length === 0,
|
|
239
241
|
children: "Select Asset"
|
|
240
242
|
}
|
|
241
243
|
)
|
|
242
244
|
] })
|
|
243
245
|
] }),
|
|
244
|
-
/* @__PURE__ */ a(
|
|
246
|
+
/* @__PURE__ */ a(H, { value: "browse", className: "flex-1 flex flex-col", children: [
|
|
245
247
|
/* @__PURE__ */ e("div", { className: "flex items-center gap-2 mb-2", children: /* @__PURE__ */ a("div", { className: "relative w-full", children: [
|
|
246
|
-
/* @__PURE__ */ e(
|
|
248
|
+
/* @__PURE__ */ e(Se, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
247
249
|
/* @__PURE__ */ e(
|
|
248
|
-
|
|
250
|
+
ue,
|
|
249
251
|
{
|
|
250
252
|
placeholder: "Search assets...",
|
|
251
|
-
value:
|
|
253
|
+
value: M,
|
|
252
254
|
onChange: ie,
|
|
253
255
|
className: "pl-8"
|
|
254
256
|
}
|
|
255
257
|
)
|
|
256
258
|
] }) }),
|
|
257
|
-
|
|
259
|
+
P && w.length === 0 ? /* @__PURE__ */ a("div", { className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1", children: [
|
|
258
260
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
|
|
259
261
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
|
|
260
262
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
|
|
@@ -265,37 +267,37 @@ function Oe({
|
|
|
265
267
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
|
|
266
268
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
|
|
267
269
|
/* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" })
|
|
268
|
-
] }) :
|
|
270
|
+
] }) : w.length === 0 ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center justify-center h-full text-center p-12 h-[380px]", children: [
|
|
269
271
|
/* @__PURE__ */ a("div", { className: "text-muted-foreground mb-2", children: [
|
|
270
272
|
/* @__PURE__ */ e("h3", { className: "text-gray-800 font-medium", children: "No assets to display" }),
|
|
271
273
|
/* @__PURE__ */ e("p", { className: "text-sm", children: "You haven't uploaded any assets yet. Start by uploading your first asset." })
|
|
272
274
|
] }),
|
|
273
|
-
/* @__PURE__ */ e("div", { className: "flex gap-2 pt-4", children: /* @__PURE__ */ e(
|
|
275
|
+
/* @__PURE__ */ e("div", { className: "flex gap-2 pt-4", children: /* @__PURE__ */ e(f, { size: "lg", onClick: () => n("upload"), children: "Upload Assets" }) })
|
|
274
276
|
] }) : /* @__PURE__ */ a(
|
|
275
277
|
"div",
|
|
276
278
|
{
|
|
277
|
-
ref:
|
|
279
|
+
ref: N,
|
|
278
280
|
className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1",
|
|
279
281
|
children: [
|
|
280
|
-
|
|
281
|
-
|
|
282
|
+
w.map((s) => /* @__PURE__ */ e(
|
|
283
|
+
me,
|
|
282
284
|
{
|
|
283
|
-
className:
|
|
285
|
+
className: Y(
|
|
284
286
|
"cursor-pointer overflow-hidden transition-all",
|
|
285
|
-
|
|
287
|
+
p.some((l) => l.id === s.id) ? "ring-2 ring-primary" : "hover:ring-2 hover:ring-primary/20"
|
|
286
288
|
),
|
|
287
|
-
onClick: () =>
|
|
288
|
-
children: /* @__PURE__ */ a(
|
|
289
|
+
onClick: () => q(s),
|
|
290
|
+
children: /* @__PURE__ */ a(he, { className: "p-0 relative group", children: [
|
|
289
291
|
/* @__PURE__ */ a("div", { className: "aspect-square relative overflow-hidden bg-muted", children: [
|
|
290
292
|
s.type === "image" ? /* @__PURE__ */ e(
|
|
291
293
|
"img",
|
|
292
294
|
{
|
|
293
|
-
src: s.
|
|
295
|
+
src: s.thumbnailUrl || "/placeholder.svg",
|
|
294
296
|
alt: s.name,
|
|
295
297
|
className: "object-cover w-full h-full"
|
|
296
298
|
}
|
|
297
299
|
) : /* @__PURE__ */ a("div", { className: "flex items-center justify-center h-full", children: [
|
|
298
|
-
/* @__PURE__ */ e(
|
|
300
|
+
/* @__PURE__ */ e(be, { className: "h-12 w-12 text-muted-foreground" }),
|
|
299
301
|
s.thumbnailUrl && /* @__PURE__ */ e(
|
|
300
302
|
"img",
|
|
301
303
|
{
|
|
@@ -307,53 +309,53 @@ function Oe({
|
|
|
307
309
|
] }),
|
|
308
310
|
/* @__PURE__ */ a("div", { className: "absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2", children: [
|
|
309
311
|
/* @__PURE__ */ e(
|
|
310
|
-
|
|
312
|
+
f,
|
|
311
313
|
{
|
|
312
314
|
variant: "secondary",
|
|
313
315
|
size: "icon",
|
|
314
316
|
className: "h-8 w-8",
|
|
315
|
-
onClick: (
|
|
316
|
-
|
|
317
|
+
onClick: (l) => {
|
|
318
|
+
l.stopPropagation(), te(s);
|
|
317
319
|
},
|
|
318
|
-
children: /* @__PURE__ */ e(
|
|
320
|
+
children: /* @__PURE__ */ e(Ce, { className: "h-4 w-4" })
|
|
319
321
|
}
|
|
320
322
|
),
|
|
321
323
|
/* @__PURE__ */ e(
|
|
322
|
-
|
|
324
|
+
f,
|
|
323
325
|
{
|
|
324
326
|
variant: "secondary",
|
|
325
327
|
size: "icon",
|
|
326
328
|
className: "h-8 w-8",
|
|
327
|
-
onClick: (
|
|
328
|
-
|
|
329
|
+
onClick: (l) => {
|
|
330
|
+
l.stopPropagation(), E({
|
|
329
331
|
id: s.id,
|
|
330
332
|
show: !0,
|
|
331
333
|
file: s.url,
|
|
332
334
|
name: s.name
|
|
333
335
|
});
|
|
334
336
|
},
|
|
335
|
-
children: /* @__PURE__ */ e(
|
|
337
|
+
children: /* @__PURE__ */ e(Ee, { className: "h-4 w-4" })
|
|
336
338
|
}
|
|
337
339
|
),
|
|
338
340
|
/* @__PURE__ */ e(
|
|
339
|
-
|
|
341
|
+
f,
|
|
340
342
|
{
|
|
341
343
|
variant: "destructive",
|
|
342
344
|
size: "icon",
|
|
343
345
|
className: "h-8 w-8",
|
|
344
|
-
onClick: (
|
|
345
|
-
|
|
346
|
+
onClick: (l) => {
|
|
347
|
+
l.stopPropagation(), se(s);
|
|
346
348
|
},
|
|
347
|
-
children: /* @__PURE__ */ e(
|
|
349
|
+
children: /* @__PURE__ */ e(Te, { className: "h-4 w-4" })
|
|
348
350
|
}
|
|
349
351
|
)
|
|
350
352
|
] }),
|
|
351
|
-
|
|
353
|
+
p.some((l) => l.id === s.id) && /* @__PURE__ */ e("div", { className: "absolute top-2 left-2", children: /* @__PURE__ */ e(
|
|
352
354
|
"input",
|
|
353
355
|
{
|
|
354
356
|
type: "checkbox",
|
|
355
|
-
checked:
|
|
356
|
-
(
|
|
357
|
+
checked: p.some(
|
|
358
|
+
(l) => l.id === s.id
|
|
357
359
|
),
|
|
358
360
|
readOnly: !0,
|
|
359
361
|
className: "rounded-full"
|
|
@@ -370,54 +372,41 @@ function Oe({
|
|
|
370
372
|
}
|
|
371
373
|
),
|
|
372
374
|
/* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground flex items-center justify-between", children: [
|
|
373
|
-
/* @__PURE__ */ e("span", { children:
|
|
374
|
-
/* @__PURE__ */ e("span", { children:
|
|
375
|
+
/* @__PURE__ */ e("span", { children: Le((s == null ? void 0 : s.size) || 0) }),
|
|
376
|
+
/* @__PURE__ */ e("span", { children: Be(s.createdAt) })
|
|
375
377
|
] })
|
|
376
378
|
] })
|
|
377
379
|
] })
|
|
378
380
|
},
|
|
379
381
|
s.id
|
|
380
382
|
)),
|
|
381
|
-
|
|
382
|
-
!m && A && /* @__PURE__ */ e("div", { className: "col-span-full flex justify-center py-4", children: /* @__PURE__ */ a(
|
|
383
|
-
v,
|
|
384
|
-
{
|
|
385
|
-
variant: "outline",
|
|
386
|
-
onClick: () => E(),
|
|
387
|
-
disabled: y,
|
|
388
|
-
className: "flex items-center gap-2",
|
|
389
|
-
children: [
|
|
390
|
-
y ? /* @__PURE__ */ e(_, { className: "h-4 w-4 animate-spin" }) : null,
|
|
391
|
-
"Load More"
|
|
392
|
-
]
|
|
393
|
-
}
|
|
394
|
-
) })
|
|
383
|
+
P && w.length > 0 && /* @__PURE__ */ e("div", { className: "col-span-full flex justify-center py-4", children: /* @__PURE__ */ e(V, { className: "h-6 w-6 animate-spin text-muted-foreground" }) })
|
|
395
384
|
]
|
|
396
385
|
}
|
|
397
386
|
)
|
|
398
387
|
] }),
|
|
399
|
-
/* @__PURE__ */ e(
|
|
388
|
+
/* @__PURE__ */ e(H, { value: "upload", className: "flex-1 ", children: /* @__PURE__ */ a(
|
|
400
389
|
"div",
|
|
401
390
|
{
|
|
402
|
-
...
|
|
403
|
-
className:
|
|
391
|
+
...X(),
|
|
392
|
+
className: Y(
|
|
404
393
|
"border-2 border-dashed rounded-lg h-[380px] flex flex-col items-center justify-center text-center cursor-pointer hover:bg-gray-50",
|
|
405
|
-
|
|
394
|
+
J ? "border-primary bg-primary/5" : "border-muted-foreground/20"
|
|
406
395
|
),
|
|
407
396
|
children: [
|
|
408
|
-
/* @__PURE__ */ e("input", {
|
|
409
|
-
|
|
410
|
-
/* @__PURE__ */ e(
|
|
397
|
+
/* @__PURE__ */ e("input", { ...Z() }),
|
|
398
|
+
h || j ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center", children: [
|
|
399
|
+
/* @__PURE__ */ e(V, { className: "h-12 w-12 text-primary animate-spin mb-4" }),
|
|
411
400
|
/* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Uploading files..." }),
|
|
412
401
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Please wait while your files are being processed." })
|
|
413
|
-
] }) : /* @__PURE__ */ a(
|
|
414
|
-
/* @__PURE__ */ e(
|
|
402
|
+
] }) : /* @__PURE__ */ a(B, { children: [
|
|
403
|
+
/* @__PURE__ */ e(De, { className: "h-12 w-12 text-muted-foreground mb-4" }),
|
|
415
404
|
/* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Drag & drop files here" }),
|
|
416
405
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: "or click to browse your files" }),
|
|
417
406
|
/* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground", children: [
|
|
418
407
|
/* @__PURE__ */ a("p", { children: [
|
|
419
408
|
"Accepted file types: ",
|
|
420
|
-
|
|
409
|
+
d.join(", ")
|
|
421
410
|
] }),
|
|
422
411
|
/* @__PURE__ */ a("p", { children: [
|
|
423
412
|
"Maximum file size: ",
|
|
@@ -433,39 +422,60 @@ function Oe({
|
|
|
433
422
|
}
|
|
434
423
|
)
|
|
435
424
|
] }),
|
|
436
|
-
|
|
437
|
-
|
|
425
|
+
C && /* @__PURE__ */ e(O, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
|
|
426
|
+
je,
|
|
438
427
|
{
|
|
439
|
-
asset:
|
|
440
|
-
onSave: (s) => le(
|
|
428
|
+
asset: C,
|
|
429
|
+
onSave: (s) => le(C, s),
|
|
441
430
|
onCancel: () => {
|
|
442
|
-
|
|
431
|
+
v(null);
|
|
443
432
|
}
|
|
444
433
|
}
|
|
445
434
|
) }),
|
|
446
|
-
|
|
447
|
-
|
|
435
|
+
m.show && /* @__PURE__ */ e(O, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
|
|
436
|
+
_e,
|
|
437
|
+
{
|
|
438
|
+
imageUrl: m.file,
|
|
439
|
+
onSave: ne,
|
|
440
|
+
onClose: () => E({ show: !1, file: "" }),
|
|
441
|
+
defaultSavedImageName: m.name,
|
|
442
|
+
isEditing: !!m.id
|
|
443
|
+
}
|
|
444
|
+
) }),
|
|
445
|
+
c && /* @__PURE__ */ e(
|
|
446
|
+
ge,
|
|
448
447
|
{
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
448
|
+
open: !!c,
|
|
449
|
+
onOpenChange: () => g(null),
|
|
450
|
+
children: /* @__PURE__ */ a(pe, { children: [
|
|
451
|
+
/* @__PURE__ */ a(fe, { children: [
|
|
452
|
+
/* @__PURE__ */ e(ye, { children: "Delete Asset" }),
|
|
453
|
+
/* @__PURE__ */ a(ve, { children: [
|
|
454
|
+
'Are you sure you want to delete "',
|
|
455
|
+
c.name,
|
|
456
|
+
'"? This action cannot be undone.'
|
|
457
|
+
] })
|
|
458
|
+
] }),
|
|
459
|
+
/* @__PURE__ */ a(xe, { className: "gap-2 sm:gap-0", children: [
|
|
460
|
+
/* @__PURE__ */ e(f, { variant: "outline", onClick: () => g(null), children: "Cancel" }),
|
|
461
|
+
/* @__PURE__ */ e(f, { variant: "destructive", onClick: ae, children: "Delete" })
|
|
462
|
+
] })
|
|
463
|
+
] })
|
|
454
464
|
}
|
|
455
|
-
)
|
|
465
|
+
)
|
|
456
466
|
] });
|
|
457
467
|
}
|
|
458
|
-
function
|
|
459
|
-
return
|
|
468
|
+
function Le(t) {
|
|
469
|
+
return t < 1024 ? `${t.toFixed(2)} KB` : `${(t / 1024).toFixed(2)} MB`;
|
|
460
470
|
}
|
|
461
|
-
function
|
|
462
|
-
const
|
|
471
|
+
function Be(t) {
|
|
472
|
+
const r = new Date(t);
|
|
463
473
|
return new Intl.DateTimeFormat("en-US", {
|
|
464
474
|
month: "short",
|
|
465
475
|
day: "numeric",
|
|
466
476
|
year: "numeric"
|
|
467
|
-
}).format(
|
|
477
|
+
}).format(r);
|
|
468
478
|
}
|
|
469
479
|
export {
|
|
470
|
-
|
|
480
|
+
Xe as default
|
|
471
481
|
};
|