@chaibuilder/pages 0.15.5 → 0.15.6

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 (96) hide show
  1. package/dist/{2AITGKQY-D4uLyw6-.cjs → 2AITGKQY-BnzAO102.cjs} +1 -1
  2. package/dist/{2AITGKQY-DYwNjBFe.js → 2AITGKQY-tXLat8E2.js} +2 -2
  3. package/dist/{NCMVHL6D-DVB60g_2.js → NCMVHL6D-BwDANa-N.js} +2 -2
  4. package/dist/{NCMVHL6D-C-L7-X3f.cjs → NCMVHL6D-DooF4Fqf.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-Dp6ML_tn.js → ZDWCUMSJ-DWeYRRkj.js} +1 -1
  6. package/dist/{ZDWCUMSJ-BORULBXb.cjs → ZDWCUMSJ-DiH9kc7o.cjs} +1 -1
  7. package/dist/add-new-language-page-BCUrfgTy.cjs +1 -0
  8. package/dist/add-new-language-page-DZhjVBBf.js +401 -0
  9. package/dist/add-new-page-DWHANcUx.cjs +1 -0
  10. package/dist/add-new-page-DYuuentN.js +31 -0
  11. package/dist/delete-page-1dSWwUBg.js +40 -0
  12. package/dist/delete-page-m-Cuz7rG.cjs +1 -0
  13. package/dist/digital-asset-manager-BWZlrwFf.js +913 -0
  14. package/dist/digital-asset-manager-By_JTIbb.cjs +1 -0
  15. package/dist/duplicate-page-Dzs8ya8l.cjs +1 -0
  16. package/dist/duplicate-page-fUuBTAs7.js +133 -0
  17. package/dist/{dynamic-page-selector-Cz6zWaKo.cjs → dynamic-page-selector-CwhL4z6F.cjs} +1 -1
  18. package/dist/{dynamic-page-selector-8g1-84iW.js → dynamic-page-selector-X2qgdiNQ.js} +1 -1
  19. package/dist/image-editor-CeSSNbFY.js +108 -0
  20. package/dist/image-editor-CnDnY97s.cjs +1 -0
  21. package/dist/index-0cMGDekp.cjs +5 -0
  22. package/dist/{index-zaGKeGBW.js → index-Bk8tPO5R.js} +1168 -1219
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +10 -10
  25. package/dist/{json-diff-viewer-c3ft4c4A.cjs → json-diff-viewer-Cfa9BjZ6.cjs} +1 -1
  26. package/dist/{json-diff-viewer-BF0qFBif.js → json-diff-viewer-Cm84g19X.js} +1 -1
  27. package/dist/lang-panel-CaSKOJ8G.js +225 -0
  28. package/dist/lang-panel-CkSfJqr8.cjs +1 -0
  29. package/dist/mark-as-template-Ci82hbOm.cjs +1 -0
  30. package/dist/mark-as-template-CwsW86Zv.js +153 -0
  31. package/dist/no-language-page-content-CPt4aPy9.cjs +1 -0
  32. package/dist/no-language-page-content-DDz81nqg.js +42 -0
  33. package/dist/{page-creator-CsZpQ7Gy.cjs → page-creator-Cd2LrG4u.cjs} +1 -1
  34. package/dist/{page-creator-Crc5BzeB.js → page-creator-Dr566_Yf.js} +2 -2
  35. package/dist/page-lock-request-Bw_Wye1t.cjs +1 -0
  36. package/dist/page-lock-request-ECxkQMdS.js +75 -0
  37. package/dist/page-locked-by-dialog-AbutJT_V.cjs +1 -0
  38. package/dist/page-locked-by-dialog-CnkVUpjt.js +68 -0
  39. package/dist/page-manager-new-DLMvOata.cjs +1 -0
  40. package/dist/page-manager-new-DkqNLZ5C.js +354 -0
  41. package/dist/page-manager-search-and-filter-B98nz9xS.js +201 -0
  42. package/dist/page-manager-search-and-filter-CfEfWFeo.cjs +1 -0
  43. package/dist/{page-revisions-content-PRgwV04S.js → page-revisions-content-CBQPYFZI.js} +18 -18
  44. package/dist/{page-revisions-content-dSFvGFEO.cjs → page-revisions-content-D12GEp8C.cjs} +1 -1
  45. package/dist/{publish-pages-content-C24iBibw.js → publish-pages-content-BF5yMo_L.js} +6 -6
  46. package/dist/{publish-pages-content-akIgltlm.cjs → publish-pages-content-LNCr9tKv.cjs} +1 -1
  47. package/dist/{save-to-lib-C3H1ZPb-.cjs → save-to-lib-C1B6tWEF.cjs} +1 -1
  48. package/dist/{save-to-lib-DSPvtFSd.js → save-to-lib-SpilaoOL.js} +1 -1
  49. package/dist/{seo-panel-Ce6aTIyt.cjs → seo-panel-DkgkJUT6.cjs} +1 -1
  50. package/dist/{seo-panel-rZ8s88c0.js → seo-panel-sbYoo746.js} +17 -17
  51. package/dist/{shared-json-ld-hCiviuBf.cjs → shared-json-ld-CEUgLAev.cjs} +1 -1
  52. package/dist/{shared-json-ld-DMYOwp6B.js → shared-json-ld-D_YyVPk3.js} +27 -27
  53. package/dist/{slug-input-BN8eQgxP.cjs → slug-input-Cqj9EBju.cjs} +1 -1
  54. package/dist/{slug-input-Dhzaobv6.js → slug-input-Df-BG6xl.js} +1 -1
  55. package/dist/theme-panel-footer-B6leVWSV.js +25 -0
  56. package/dist/theme-panel-footer-Ca1UF5DA.cjs +1 -0
  57. package/dist/unmark-as-template-BOE-nKOb.cjs +1 -0
  58. package/dist/unmark-as-template-Cho9B4RN.js +39 -0
  59. package/dist/unpublish-page-BcxxZ8pr.cjs +1 -0
  60. package/dist/unpublish-page-Dr4qbwUx.js +27 -0
  61. package/dist/{web-preview-BEyjKFDL.js → web-preview-Cq82TNaS.js} +1 -1
  62. package/dist/{web-preview-TTKtpSUi.cjs → web-preview-ued-fdxs.cjs} +1 -1
  63. package/package.json +3 -3
  64. package/dist/add-new-language-page-D4VPifNs.cjs +0 -1
  65. package/dist/add-new-language-page-DENCjC_f.js +0 -390
  66. package/dist/add-new-page-BuK6We-q.cjs +0 -1
  67. package/dist/add-new-page-CD-9ppdS.js +0 -30
  68. package/dist/delete-page-B-TP6nJ7.cjs +0 -1
  69. package/dist/delete-page-CatRlDfx.js +0 -38
  70. package/dist/digital-asset-manager-DL2nAqUC.cjs +0 -1
  71. package/dist/digital-asset-manager-KakxBkBC.js +0 -917
  72. package/dist/duplicate-page-D4Oiy71Q.cjs +0 -1
  73. package/dist/duplicate-page-DEmh0df0.js +0 -120
  74. package/dist/image-editor-D9MPdtxC.js +0 -107
  75. package/dist/image-editor-Da6lrqkL.cjs +0 -1
  76. package/dist/index-Blg1T7nL.cjs +0 -5
  77. package/dist/lang-panel-D1FKTNui.js +0 -218
  78. package/dist/lang-panel-ExS97Zgk.cjs +0 -1
  79. package/dist/mark-as-template-CcnkROAU.cjs +0 -1
  80. package/dist/mark-as-template-v-I05xcZ.js +0 -146
  81. package/dist/no-language-page-content-Bm5CcsUo.js +0 -35
  82. package/dist/no-language-page-content-Ddz2hnYs.cjs +0 -1
  83. package/dist/page-lock-request-Dx6OrOwM.cjs +0 -1
  84. package/dist/page-lock-request-WKfG7Sd3.js +0 -64
  85. package/dist/page-locked-by-dialog-BvdAXZPw.cjs +0 -1
  86. package/dist/page-locked-by-dialog-jy3lYV3l.js +0 -63
  87. package/dist/page-manager-new-CNHlSwfe.js +0 -354
  88. package/dist/page-manager-new-CUlpwqpH.cjs +0 -1
  89. package/dist/page-manager-search-and-filter-CuAn82Db.js +0 -197
  90. package/dist/page-manager-search-and-filter-eFsGtm5W.cjs +0 -1
  91. package/dist/theme-panel-footer-0GrdOHO_.cjs +0 -1
  92. package/dist/theme-panel-footer-BzEy5bsg.js +0 -25
  93. package/dist/unmark-as-template-DXEs6foh.cjs +0 -1
  94. package/dist/unmark-as-template-Dsiyocm9.js +0 -38
  95. package/dist/unpublish-page-c1mqQEa_.cjs +0 -1
  96. package/dist/unpublish-page-yGyz2jiw.js +0 -26
@@ -0,0 +1,913 @@
1
+ import { jsxs as r, jsx as e, Fragment as H } from "react/jsx-runtime";
2
+ import { useTranslation as ee, mergeClasses as me } from "@chaibuilder/sdk";
3
+ import { Button as p, Input as ue, Label as V, Textarea as Fe, TooltipProvider as _, Tooltip as P, TooltipTrigger as q, TooltipContent as G, Dialog as Ue, DialogContent as Le, DialogHeader as $e, DialogTitle as Me, DialogDescription as _e, DialogFooter as Pe, Switch as qe } from "@chaibuilder/sdk/ui";
4
+ import { find as Ge, merge as Oe, pick as Y, first as Be, isEmpty as Ke } from "lodash-es";
5
+ import { ChevronLeft as he, ChevronRight as Qe, Loader as B, AlertCircle as Re, Copy as fe, Pencil as We, Link as Ve, Search as He, RefreshCwIcon as Xe, Archive as Ze, Film as Je, ImageIcon as Ye, Edit as et, Trash2 as tt, Check as it, Upload as lt, AlertTriangle as at } from "lucide-react";
6
+ import pe, { useState as y, useMemo as ge, useEffect as O, useCallback as M, Suspense as rt } from "react";
7
+ import { useDropzone as nt } from "react-dropzone";
8
+ import { aL as K, al as Q, A as b, aM as st } from "./index-Bk8tPO5R.js";
9
+ import { toast as A } from "sonner";
10
+ import { f as ct, c as ot } from "./image-compression-DsZ1oqpb.js";
11
+ import { useQueryClient as te, useMutation as ie, useQuery as xe } from "@tanstack/react-query";
12
+ const dt = () => {
13
+ const s = K(), n = te(), h = Q();
14
+ return ie({
15
+ mutationFn: async (l) => {
16
+ const c = l.map(async (a) => h(s, {
17
+ action: b.UPLOAD_ASSET,
18
+ data: a
19
+ }));
20
+ return await Promise.all(c);
21
+ },
22
+ onSuccess: (l) => {
23
+ var c;
24
+ if (l != null && l.some((i) => i.error))
25
+ throw new Error(((c = l == null ? void 0 : l.find((i) => i.error)) == null ? void 0 : c.error) || "Failed to upload asset");
26
+ {
27
+ n.invalidateQueries({
28
+ queryKey: [b.GET_ASSETS]
29
+ });
30
+ const i = l == null ? void 0 : l.length;
31
+ A.success(`${i === 1 ? "Asset" : i + " Assets"} uploaded successfully`);
32
+ }
33
+ },
34
+ onError: () => {
35
+ A.error("Failed to upload asset");
36
+ }
37
+ });
38
+ }, mt = () => {
39
+ const s = K(), n = te(), h = Q();
40
+ return ie({
41
+ mutationFn: async (l) => h(s, {
42
+ action: b.DELETE_ASSET,
43
+ data: { id: l }
44
+ }),
45
+ onSuccess: (l) => {
46
+ if (l != null && l.error)
47
+ throw new Error(l == null ? void 0 : l.error);
48
+ n.invalidateQueries({
49
+ queryKey: [b.GET_ASSETS]
50
+ }), A.success("Asset deleted successfully");
51
+ },
52
+ onError: () => {
53
+ A.error("Failed to delete asset");
54
+ }
55
+ });
56
+ }, ut = () => {
57
+ const s = K(), n = te(), h = Q();
58
+ return ie({
59
+ mutationFn: async (l) => h(s, {
60
+ action: b.UPDATE_ASSET,
61
+ data: l
62
+ }),
63
+ onSuccess: (l) => {
64
+ if (l != null && l.error)
65
+ throw new Error(l == null ? void 0 : l.error);
66
+ n.invalidateQueries({
67
+ queryKey: [b.GET_ASSETS]
68
+ }), l != null && l.id && n.invalidateQueries({
69
+ queryKey: [b.GET_ASSET, l.id]
70
+ }), A.success("Asset updated successfully");
71
+ },
72
+ onError: () => {
73
+ A.error("Failed to update asset");
74
+ }
75
+ });
76
+ };
77
+ function ht({
78
+ currentPage: s,
79
+ totalPages: n,
80
+ onPageChange: h,
81
+ pageRangeDisplayed: l = 3,
82
+ showPageInput: c = !0,
83
+ className: i = ""
84
+ }) {
85
+ const [a, I] = y(String(s)), N = ge(() => {
86
+ const o = Math.floor(l / 2);
87
+ let m = Math.max(1, s - o), d = Math.min(n, s + o);
88
+ d - m + 1 < l && (m === 1 ? d = Math.min(n, m + l - 1) : d === n && (m = Math.max(1, d - l + 1)));
89
+ const f = [];
90
+ m > 1 && (f.push(1), m > 2 && f.push("..."));
91
+ for (let v = m; v <= d; v++)
92
+ f.push(v);
93
+ return d < n && (d < n - 1 && f.push("..."), f.push(n)), f;
94
+ }, [s, n, l]), x = (o) => {
95
+ o !== s && o >= 1 && o <= n && (h(o), I(String(o)));
96
+ }, g = () => {
97
+ s > 1 && x(s - 1);
98
+ }, w = () => {
99
+ s < n && x(s + 1);
100
+ }, C = () => {
101
+ const o = Number(a);
102
+ !isNaN(o) && o >= 1 && o <= n && x(o);
103
+ }, S = (o) => {
104
+ o.key === "Enter" && C();
105
+ };
106
+ return n <= 1 ? null : /* @__PURE__ */ r("div", { className: `flex flex-wrap items-center justify-center gap-3 ${i}`, children: [
107
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
108
+ /* @__PURE__ */ r(
109
+ p,
110
+ {
111
+ variant: "outline",
112
+ size: "sm",
113
+ onClick: g,
114
+ disabled: s === 1,
115
+ className: "px-2 py-1 text-sm hover:bg-gray-50",
116
+ children: [
117
+ /* @__PURE__ */ e(he, { className: " h-4 w-4" }),
118
+ "Previous"
119
+ ]
120
+ }
121
+ ),
122
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: N.map((o, m) => {
123
+ if (o === "...")
124
+ return /* @__PURE__ */ e("span", { className: "px-2 text-muted-foreground", children: "..." }, `ellipsis-${m}`);
125
+ const d = o, f = d === s;
126
+ return /* @__PURE__ */ e(
127
+ p,
128
+ {
129
+ variant: f ? "default" : "outline",
130
+ size: "sm",
131
+ onClick: () => x(d),
132
+ className: f ? "border-blue-600 bg-blue-600 px-3 py-1 text-sm text-white" : "border px-3 py-1 text-sm hover:bg-gray-50 hover:text-black",
133
+ children: d
134
+ },
135
+ d
136
+ );
137
+ }) }),
138
+ /* @__PURE__ */ r(
139
+ p,
140
+ {
141
+ variant: "outline",
142
+ size: "sm",
143
+ onClick: w,
144
+ disabled: s === n,
145
+ className: "px-2 py-1 text-sm hover:bg-gray-50",
146
+ children: [
147
+ "Next",
148
+ /* @__PURE__ */ e(Qe, { className: " h-4 w-4" })
149
+ ]
150
+ }
151
+ )
152
+ ] }),
153
+ c && /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
154
+ /* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground", children: "Go to" }),
155
+ /* @__PURE__ */ e(
156
+ ue,
157
+ {
158
+ type: "number",
159
+ min: 1,
160
+ max: n,
161
+ value: a,
162
+ onChange: (o) => {
163
+ const m = o.target.value.replace(/[^\d]/g, "");
164
+ I(m);
165
+ },
166
+ onKeyDown: S,
167
+ className: "h-8 w-16 px-2 py-1"
168
+ }
169
+ ),
170
+ /* @__PURE__ */ e(
171
+ p,
172
+ {
173
+ variant: "outline",
174
+ size: "sm",
175
+ onClick: C,
176
+ disabled: a === "" || Number(a) < 1 || Number(a) > n,
177
+ children: "Go"
178
+ }
179
+ )
180
+ ] })
181
+ ] });
182
+ }
183
+ const ft = (s = {}) => {
184
+ const n = K(), h = Q(), { search: l, page: c = 1, limit: i = 30 } = s;
185
+ return xe({
186
+ queryKey: [b.GET_ASSETS, l, c, i],
187
+ queryFn: async () => {
188
+ const a = await h(n, {
189
+ action: b.GET_ASSETS,
190
+ data: {
191
+ search: l,
192
+ page: c,
193
+ limit: i
194
+ }
195
+ });
196
+ return a.page = c, a.limit = i, a;
197
+ },
198
+ staleTime: 1 / 0,
199
+ retry: 1
200
+ });
201
+ }, pt = (s) => {
202
+ const n = K(), h = Q();
203
+ return xe({
204
+ queryKey: [b.GET_ASSET, s],
205
+ queryFn: async () => s ? await h(n, {
206
+ action: b.GET_ASSET,
207
+ data: { id: s }
208
+ }) : null,
209
+ staleTime: 1 / 0,
210
+ retry: 1
211
+ });
212
+ };
213
+ function gt(s) {
214
+ const n = isNaN(s) ? 0 : typeof s == "number" ? s : parseInt(s);
215
+ return n ? n < 1024 ? `${n.toFixed(2)} B` : n < 1024 * 1024 ? `${(n / 1024).toFixed(2)} KB` : `${(n / (1024 * 1024)).toFixed(2)} MB` : "0 B";
216
+ }
217
+ function oe(s) {
218
+ if (!s) return "N/A";
219
+ const n = new Date(s);
220
+ return new Intl.DateTimeFormat("en-US", {
221
+ month: "short",
222
+ day: "numeric",
223
+ year: "numeric",
224
+ hour: "2-digit",
225
+ minute: "2-digit"
226
+ }).format(n);
227
+ }
228
+ function de(s, n) {
229
+ let h = s, l = n == null ? void 0 : n.description;
230
+ return (!l || typeof l != "string") && (l = ""), (!h || typeof h != "string") && (h = ""), h !== l;
231
+ }
232
+ const xt = ({
233
+ assetId: s,
234
+ onBack: n,
235
+ onEdit: h,
236
+ onSave: l,
237
+ isSaving: c
238
+ }) => {
239
+ var o, m;
240
+ const { t: i } = ee(), { data: a, isLoading: I, isError: N } = pt(s || ""), [x, g] = y(""), [w, C] = y(!1);
241
+ O(() => {
242
+ const d = new Image();
243
+ return d.src = (a == null ? void 0 : a.url) || "", d.onload = () => C(!0), () => {
244
+ d.onload = null;
245
+ };
246
+ }, [a]);
247
+ const S = async (d, f) => {
248
+ try {
249
+ await navigator.clipboard.writeText(d), A.success(i("{{type}} copied to clipboard", { type: f }));
250
+ } catch (v) {
251
+ A.error(i("Failed to copy {{type}}", { type: f }), {
252
+ description: v == null ? void 0 : v.message
253
+ });
254
+ }
255
+ };
256
+ return pe.useEffect(() => {
257
+ a != null && a.description && g(a.description);
258
+ }, [a]), I || !w ? /* @__PURE__ */ e("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ e(B, { className: "h-8 w-8 animate-spin" }) }) : N || !(a != null && a.id) ? /* @__PURE__ */ e("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "text-center max-w-md mx-auto p-6", children: [
259
+ /* @__PURE__ */ e("div", { className: "flex justify-center mb-4", children: /* @__PURE__ */ e(Re, { className: "h-12 w-12 text-gray-400" }) }),
260
+ /* @__PURE__ */ e("h3", { className: "text-lg font-medium text-gray-900 mb-2", children: i("No Asset Found") }),
261
+ /* @__PURE__ */ e("p", { className: "text-sm text-gray-500 mb-6", children: i(N ? "There was an error loading the asset. Please try again later." : "The asset you're looking for doesn't exist or has been removed.") }),
262
+ /* @__PURE__ */ r("div", { className: "flex justify-center gap-4", children: [
263
+ /* @__PURE__ */ e(p, { variant: "outline", onClick: n, children: i("Back to Assets") }),
264
+ N && /* @__PURE__ */ e(
265
+ p,
266
+ {
267
+ variant: "default",
268
+ onClick: () => window.location.reload(),
269
+ children: i("Try Again")
270
+ }
271
+ )
272
+ ] })
273
+ ] }) }) : /* @__PURE__ */ r("div", { className: "flex-1 flex flex-col gap-y-4 overflow-hidden", children: [
274
+ /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
275
+ /* @__PURE__ */ r(
276
+ p,
277
+ {
278
+ variant: "outline",
279
+ size: "sm",
280
+ onClick: n,
281
+ disabled: c,
282
+ children: [
283
+ /* @__PURE__ */ e(he, { className: "h-4 w-4" }),
284
+ i("Back to Assets")
285
+ ]
286
+ }
287
+ ),
288
+ /* @__PURE__ */ r("div", { className: "flex gap-2", children: [
289
+ /* @__PURE__ */ e(p, { variant: "outline", onClick: n, disabled: c, children: i("Cancel") }),
290
+ /* @__PURE__ */ r(
291
+ p,
292
+ {
293
+ variant: "outline",
294
+ onClick: () => S(a.url, i("Asset URL")),
295
+ disabled: c,
296
+ children: [
297
+ /* @__PURE__ */ e(fe, { className: "h-4 w-4 mr-2" }),
298
+ i("Copy URL")
299
+ ]
300
+ }
301
+ ),
302
+ /* @__PURE__ */ r(
303
+ p,
304
+ {
305
+ variant: "default",
306
+ onClick: () => h(a),
307
+ disabled: c,
308
+ children: [
309
+ /* @__PURE__ */ e(We, { className: "h-4 w-4" }),
310
+ i("Edit Image")
311
+ ]
312
+ }
313
+ )
314
+ ] })
315
+ ] }),
316
+ /* @__PURE__ */ r("div", { className: "grid grid-cols-2 items-start gap-6 flex-1 overflow-hidden", children: [
317
+ /* @__PURE__ */ e("div", { className: "relative h-[calc(80vh-200px)] w-full flex items-start justify-center", children: /* @__PURE__ */ e(
318
+ "img",
319
+ {
320
+ src: a.url,
321
+ alt: a.name,
322
+ className: "w-full h-full object-contain rounded-lg max-h-max max-w-max"
323
+ }
324
+ ) }),
325
+ /* @__PURE__ */ r("div", { className: "space-y-6", children: [
326
+ /* @__PURE__ */ r("div", { className: "grid gap-3 border rounded-md pt-2 bg-gray-100", children: [
327
+ /* @__PURE__ */ e(V, { className: "w-full text-center", children: i("Details") }),
328
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-2 text-sm border rounded-md p-2 bg-white", children: [
329
+ { label: i("File Name"), value: a.name },
330
+ { label: i("Type"), value: a.type, capitalize: !0 },
331
+ {
332
+ label: i("Format"),
333
+ value: ((o = a.metadata) == null ? void 0 : o.format) || a.type,
334
+ capitalize: !0
335
+ },
336
+ {
337
+ label: i("Size"),
338
+ value: gt(a.size)
339
+ },
340
+ {
341
+ label: i("Dimensions"),
342
+ value: `${a.width || 0} × ${a.height || 0}`
343
+ },
344
+ {
345
+ label: i("Created"),
346
+ value: oe(a.createdAt)
347
+ },
348
+ {
349
+ label: i("Updated"),
350
+ value: oe(
351
+ ((m = a.metadata) == null ? void 0 : m.updatedAt) || (a == null ? void 0 : a.updatedAt) || a.createdAt
352
+ )
353
+ },
354
+ {
355
+ label: i("URL"),
356
+ value: a.url,
357
+ copyable: !0
358
+ }
359
+ ].map((d) => /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
360
+ /* @__PURE__ */ e(V, { className: "w-max text-left px-2 w-1/4 font-normal text-gray-700", children: d.label }),
361
+ ":",
362
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
363
+ /* @__PURE__ */ e(
364
+ "div",
365
+ {
366
+ className: "w-max text-left font-medium text-gray-900" + (d.capitalize ? " capitalize" : ""),
367
+ children: d.value
368
+ }
369
+ ),
370
+ d.copyable && /* @__PURE__ */ e(
371
+ p,
372
+ {
373
+ variant: "ghost",
374
+ size: "icon",
375
+ className: "h-6 w-6",
376
+ onClick: () => S(d.value, d.label),
377
+ children: /* @__PURE__ */ e(Ve, { className: "h-3 w-3" })
378
+ }
379
+ )
380
+ ] })
381
+ ] }, d.label)) })
382
+ ] }),
383
+ a.usedOn && a.usedOn.length > 0 && /* @__PURE__ */ r("div", { className: "grid gap-3", children: [
384
+ /* @__PURE__ */ e(V, { children: i("Used On") }),
385
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-2 text-sm border rounded-md p-2", children: a.usedOn.map((d, f) => /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
386
+ /* @__PURE__ */ e("div", { className: "w-max text-left font-medium text-gray-900", children: d.name }),
387
+ /* @__PURE__ */ r("div", { className: "text-gray-500", children: [
388
+ "(",
389
+ d.slug,
390
+ ")"
391
+ ] })
392
+ ] }, f)) })
393
+ ] }),
394
+ /* @__PURE__ */ r("div", { className: "grid gap-3 border rounded-md pt-2 bg-gray-100 relative", children: [
395
+ /* @__PURE__ */ e(V, { className: "w-full text-center", children: i("Description") }),
396
+ /* @__PURE__ */ e(
397
+ Fe,
398
+ {
399
+ id: "description",
400
+ value: x,
401
+ placeholder: i("Enter a description for the asset"),
402
+ onChange: (d) => g(d.target.value),
403
+ rows: 3,
404
+ disabled: c,
405
+ className: "hover:border-black/40 bg-white"
406
+ }
407
+ ),
408
+ /* @__PURE__ */ e("div", { className: "flex justify-end items-start absolute top-1.5 right-2", children: /* @__PURE__ */ e(
409
+ "button",
410
+ {
411
+ type: "button",
412
+ onClick: () => l(x),
413
+ disabled: c || !de(x, a),
414
+ className: `py-0 bg-blue-500 text-white px-3 py-0.5 rounded-md text-sm ${c || !de(x, a) ? "opacity-50 cursor-not-allowed" : ""}`,
415
+ children: c ? /* @__PURE__ */ r(H, { children: [
416
+ /* @__PURE__ */ e(B, { className: "h-4 w-4 mr-2 animate-spin" }),
417
+ i("Saving...")
418
+ ] }) : i("Save")
419
+ }
420
+ ) })
421
+ ] })
422
+ ] })
423
+ ] })
424
+ ] });
425
+ }, vt = pe.lazy(() => import("./image-editor-CeSSNbFY.js")), yt = 25 * 1024 * 1024, Nt = ({ isUpdatingAsset: s, allowedTypes: n, uploadAssets: h, isUploadingAsset: l, onUploaded: c }) => {
426
+ const { t: i } = ee(), [a, I] = y(() => {
427
+ const o = localStorage.getItem("chai_optimize_images");
428
+ return o !== null ? o === "true" : !0;
429
+ });
430
+ O(() => {
431
+ localStorage.setItem("chai_optimize_images", a.toString());
432
+ }, [a]);
433
+ const N = s || l, x = M(
434
+ async (o) => {
435
+ try {
436
+ const m = o;
437
+ if (!m.every((E) => E.type.startsWith("image/")))
438
+ return A.error(i("Invalid file type. Please upload a valid file.")), Promise.reject(new Error("Invalid file type"));
439
+ const d = m.map(async (E) => {
440
+ let j = E;
441
+ return E.type.startsWith("image/") && (j = await ot(E)), new Promise((X, F) => {
442
+ const U = new FileReader();
443
+ U.readAsDataURL(j), U.onload = async () => {
444
+ X({
445
+ file: U.result,
446
+ folderId: void 0,
447
+ name: E.name,
448
+ optimize: a
449
+ });
450
+ }, U.onerror = () => F(null);
451
+ });
452
+ }), f = await Promise.all(d), v = await h(f);
453
+ return (v == null ? void 0 : v.length) === 1 && c(v[0]), v;
454
+ } catch (m) {
455
+ return Promise.reject(m);
456
+ }
457
+ },
458
+ [h, a, c, i]
459
+ ), g = (o) => {
460
+ const m = [];
461
+ let d = 0;
462
+ return o.forEach((f) => {
463
+ f.size > yt ? d++ : m.push(f);
464
+ }), d > 0 && A.error(
465
+ `${d === 1 && o.length === 1 ? i("File") : d + i(d === 1 ? " file" : " files")} ${i("exceed the maximum size limit of 10MB.")}`
466
+ ), Ke(m) ? [] : x(m);
467
+ }, { getRootProps: w, getInputProps: C, isDragActive: S } = nt({
468
+ onDrop: g,
469
+ accept: {
470
+ "image/*": n.includes("image") ? [] : []
471
+ },
472
+ disabled: s || l,
473
+ multiple: !0
474
+ });
475
+ return /* @__PURE__ */ e(
476
+ "div",
477
+ {
478
+ className: `flex h-[60px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed border-slate-300 p-0 py-2 hover:border-black/50 ${N ? "pointer-events-none bg-gray-100 opacity-90" : "bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,
479
+ children: /* @__PURE__ */ r(
480
+ "div",
481
+ {
482
+ ...w(),
483
+ className: me(
484
+ "flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",
485
+ N ? "items-start" : "items-center",
486
+ S ? "border-primary bg-primary/5" : "border-muted-foreground/20"
487
+ ),
488
+ children: [
489
+ /* @__PURE__ */ e("input", { ...C() }),
490
+ N ? /* @__PURE__ */ e("div", { className: "flex flex-col items-center px-6", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2 leading-tight", children: [
491
+ /* @__PURE__ */ e("div", { className: "flex items-center justify-center rounded-full bg-indigo-100 p-2", children: /* @__PURE__ */ e(B, { className: "h-4 w-4 animate-spin text-indigo-500" }) }),
492
+ /* @__PURE__ */ r("div", { className: "text-left", children: [
493
+ /* @__PURE__ */ e("div", { className: "font-medium", children: i(s ? "Updating file..." : "Uploading file...") }),
494
+ /* @__PURE__ */ r("div", { className: "text-xs font-light text-muted-foreground", children: [
495
+ i("Please wait while we"),
496
+ " ",
497
+ i(s ? "update" : "upload"),
498
+ " ",
499
+ i("your file...")
500
+ ] })
501
+ ] })
502
+ ] }) }) : /* @__PURE__ */ r("div", { className: "flex w-full items-center justify-between px-6", children: [
503
+ /* @__PURE__ */ e("div", { className: "flex flex-col items-center", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-2 leading-tight", children: [
504
+ /* @__PURE__ */ e(
505
+ "div",
506
+ {
507
+ className: "flex items-center justify-center rounded-full border border-indigo-500 bg-indigo-100 p-2",
508
+ children: /* @__PURE__ */ e(lt, { className: "h-4 w-4 text-indigo-500" })
509
+ }
510
+ ),
511
+ /* @__PURE__ */ r("div", { className: "text-left", children: [
512
+ /* @__PURE__ */ r("div", { className: "font-medium", children: [
513
+ i("Drop your file here or"),
514
+ " ",
515
+ /* @__PURE__ */ e("span", { className: "cursor-pointer text-indigo-500 hover:underline", children: i("browse") })
516
+ ] }),
517
+ /* @__PURE__ */ e("div", { className: "text-xs font-light text-muted-foreground", children: /* @__PURE__ */ r("span", { className: "", children: [
518
+ i("Accepted file types:"),
519
+ " ",
520
+ /* @__PURE__ */ e("span", { className: "capitalize text-indigo-400", children: n.join(", ") })
521
+ ] }) })
522
+ ] })
523
+ ] }) }),
524
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
525
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
526
+ /* @__PURE__ */ r("span", { className: "text-xs", children: [
527
+ i("Optimization:"),
528
+ " ",
529
+ " ",
530
+ /* @__PURE__ */ e("span", { className: a ? "text-indigo-600" : "text-gray-400", children: i(a ? "On" : "Off") })
531
+ ] }),
532
+ /* @__PURE__ */ e(
533
+ qe,
534
+ {
535
+ checked: a,
536
+ onCheckedChange: (o) => {
537
+ I(o);
538
+ },
539
+ onClick: (o) => {
540
+ o.stopPropagation();
541
+ },
542
+ className: "data-[state=checked]:bg-indigo-500"
543
+ }
544
+ )
545
+ ] }),
546
+ /* @__PURE__ */ e(_, { children: /* @__PURE__ */ r(P, { children: [
547
+ /* @__PURE__ */ e(q, { asChild: !0, children: /* @__PURE__ */ e(
548
+ "span",
549
+ {
550
+ className: `flex cursor-help items-center text-amber-500 ${a ? "invisible" : ""}`,
551
+ children: /* @__PURE__ */ e(at, { className: "mr-1 h-4 w-4" })
552
+ }
553
+ ) }),
554
+ /* @__PURE__ */ e(G, { side: "top", children: /* @__PURE__ */ e("p", { className: "text-xs text-white", children: i("Warning: Unoptimized images may affect performance and page load times") }) })
555
+ ] }) })
556
+ ] })
557
+ ] })
558
+ ]
559
+ }
560
+ )
561
+ }
562
+ );
563
+ };
564
+ function jt({ close: s, onSelect: n, mode: h = "image", assetId: l }) {
565
+ const { t: c } = ee(), i = !1, a = 10, I = ge(() => [h], [h]), [N, x] = y(null), [g, w] = y(null), [C, S] = y(null), [o, m] = y({ show: !1, file: "" }), [d, f] = y(!1), [v, E] = y(l ? "details" : "grid"), [j, X] = y(""), [F, U] = y(""), [R, Z] = y(1), [le] = y(30), [k, J] = y([]);
566
+ O(() => {
567
+ l && (x(l), E("details"));
568
+ }, [l]), O(() => {
569
+ const t = setTimeout(() => {
570
+ X(F), Z(1);
571
+ }, 300);
572
+ return () => clearTimeout(t);
573
+ }, [F]);
574
+ const {
575
+ data: L,
576
+ isLoading: W,
577
+ refetch: ve
578
+ } = ft({
579
+ search: j.toLowerCase().trim(),
580
+ page: R,
581
+ limit: le
582
+ }), D = (L == null ? void 0 : L.assets) || [], ye = (L == null ? void 0 : L.total) || 0, T = Math.ceil(ye / le);
583
+ O(() => {
584
+ W || T <= 0 || Z((t) => t > T ? T : t < 1 ? 1 : t);
585
+ }, [W, T]);
586
+ const Ne = (D == null ? void 0 : D.length) > 0, { mutate: we } = mt(), { mutateAsync: ae, isPending: be } = dt(), { mutateAsync: re, isPending: Ae } = ut(), ne = M(
587
+ (t) => {
588
+ const u = Math.min(Math.max(1, t), Math.max(1, T));
589
+ u !== R && Z(u);
590
+ },
591
+ [T, R]
592
+ ), Ce = (t) => {
593
+ U(t.target.value);
594
+ }, Se = M(
595
+ (t) => {
596
+ J((u) => Ge(u, { id: t.id }) ? [] : [t]);
597
+ },
598
+ [i]
599
+ ), Ee = M(() => {
600
+ J([]);
601
+ }, []), se = (t) => {
602
+ (t == null ? void 0 : t.length) !== 0 && (n(Y(Be(t || k), ["id", "url", "width", "height", "description"])), s());
603
+ }, ke = async (t) => {
604
+ w(t);
605
+ }, Ie = async () => {
606
+ g && (S(g == null ? void 0 : g.id), await we(g.id, {
607
+ onSuccess: () => {
608
+ S(null), w(null);
609
+ },
610
+ onError: () => {
611
+ S(null);
612
+ }
613
+ }), w(null));
614
+ }, Te = (t) => {
615
+ x(t.id), E("details");
616
+ }, ze = async (t, u) => {
617
+ try {
618
+ const $ = localStorage.getItem("chai_optimize_images") !== "false";
619
+ if (u) {
620
+ const z = await ae([
621
+ {
622
+ file: t,
623
+ folderId: void 0,
624
+ name: o.name || "",
625
+ optimize: $
626
+ }
627
+ ]);
628
+ if ((z == null ? void 0 : z.length) > 0) {
629
+ const ce = z[0];
630
+ n({
631
+ ...Y(ce, ["id", "width", "height", "description"]),
632
+ url: ce.url
633
+ });
634
+ }
635
+ } else {
636
+ const z = await re({
637
+ id: o.id || "",
638
+ file: t
639
+ });
640
+ z && n({
641
+ ...Y(z, ["id", "width", "height", "description"]),
642
+ url: z.url
643
+ });
644
+ }
645
+ m({ show: !1, file: "" }), s();
646
+ } catch ($) {
647
+ console.error(c("Error saving edited image:"), $);
648
+ }
649
+ }, De = M((t) => {
650
+ J([t]);
651
+ }, []), je = M(
652
+ (t) => {
653
+ ne(t);
654
+ },
655
+ [ne]
656
+ );
657
+ return /* @__PURE__ */ r(H, { children: [
658
+ /* @__PURE__ */ r("div", { className: "flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4", children: [
659
+ /* @__PURE__ */ e("h1", { className: "text-lg font-medium", children: c("Digital Asset Manager") }),
660
+ v === "grid" ? /* @__PURE__ */ r(H, { children: [
661
+ /* @__PURE__ */ e(
662
+ Nt,
663
+ {
664
+ maxFileSize: a,
665
+ allowedTypes: I,
666
+ uploadAssets: ae,
667
+ isUpdatingAsset: Ae,
668
+ isUploadingAsset: be,
669
+ onUploaded: De
670
+ }
671
+ ),
672
+ /* @__PURE__ */ r("div", { className: "relative flex flex-1 flex-col gap-y-3 overflow-hidden rounded-lg border p-2", children: [
673
+ /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3", children: [
674
+ /* @__PURE__ */ r("div", { className: "relative w-1/2", children: [
675
+ /* @__PURE__ */ e(
676
+ He,
677
+ {
678
+ strokeWidth: 3,
679
+ className: `absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${F.length > 0 ? "text-indigo-800" : ""}`
680
+ }
681
+ ),
682
+ /* @__PURE__ */ e(
683
+ ue,
684
+ {
685
+ placeholder: c("Search assets..."),
686
+ onChange: Ce,
687
+ value: F,
688
+ className: "pl-8"
689
+ }
690
+ )
691
+ ] }),
692
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-x-2", children: [
693
+ k.length > 0 ? /* @__PURE__ */ e("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
694
+ k.length > 0 && /* @__PURE__ */ e(H, { children: /* @__PURE__ */ e(
695
+ p,
696
+ {
697
+ variant: "outline",
698
+ size: "sm",
699
+ onClick: () => Ee(),
700
+ title: c("Clear selection"),
701
+ children: c("Clear")
702
+ }
703
+ ) }),
704
+ /* @__PURE__ */ e(
705
+ p,
706
+ {
707
+ size: "sm",
708
+ onClick: () => se(k),
709
+ disabled: k.length === 0,
710
+ children: c("Select Asset")
711
+ }
712
+ )
713
+ ] }) }) : null,
714
+ /* @__PURE__ */ e(p, { variant: "ghost", size: "icon", onClick: () => ve(), children: /* @__PURE__ */ e(Xe, { className: "h-4 w-4" }) })
715
+ ] })
716
+ ] }),
717
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto pb-[66px]", children: W ? /* @__PURE__ */ r("div", { className: "columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5", children: [
718
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
719
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
720
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
721
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
722
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
723
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
724
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
725
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
726
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
727
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" })
728
+ ] }) : !W && !Ne ? /* @__PURE__ */ r("div", { className: "flex h-full flex-col items-center justify-center rounded-lg border", children: [
729
+ /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: /* @__PURE__ */ e(Ze, { className: "h-9 w-9 text-indigo-500" }) }),
730
+ /* @__PURE__ */ e("div", { className: "text-lg text-muted-foreground", children: c("No assets found") }),
731
+ /* @__PURE__ */ e("div", { className: "text-sm text-muted-foreground", children: j.length > 0 ? c("No assets found for your search: {{query}}", { query: j }) : c("Start uploading assets to get started") }),
732
+ /* @__PURE__ */ e("br", {})
733
+ ] }) : /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-3 p-1", children: D == null ? void 0 : D.map((t) => /* @__PURE__ */ r(
734
+ "div",
735
+ {
736
+ className: me(
737
+ "group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",
738
+ k.some((u) => u.id === t.id) ? "border-blue-500" : "hover:border-black/90",
739
+ C && (g == null ? void 0 : g.id) === t.id ? "pointer-events-none opacity-50" : "",
740
+ C === t.id ? "pointer-events-none opacity-50" : ""
741
+ ),
742
+ onClick: () => Se(t),
743
+ onDoubleClick: () => se([t]),
744
+ children: [
745
+ /* @__PURE__ */ r("div", { className: "aspect-square relative overflow-hidden", children: [
746
+ C === t.id ? /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ e(B, { className: "h-8 w-8 animate-spin text-white" }) }) : null,
747
+ t.type === "image" ? /* @__PURE__ */ e(
748
+ "img",
749
+ {
750
+ src: `${t.thumbnailUrl || "/placeholder.svg"}?v=${(t == null ? void 0 : t.updatedAt) || t.createdAt}`,
751
+ alt: t.name,
752
+ className: `h-full min-h-[80px] w-full object-contain ${k.some((u) => u.id === t.id) ? "" : "group-hover:blur group-hover:contrast-50"}`
753
+ }
754
+ ) : /* @__PURE__ */ r("div", { className: "flex h-full items-center justify-center", children: [
755
+ /* @__PURE__ */ e(Je, { className: "h-12 w-12 text-muted-foreground" }),
756
+ t.thumbnailUrl && /* @__PURE__ */ e(
757
+ "img",
758
+ {
759
+ src: `${t.thumbnailUrl || "/placeholder.svg"}?v=${(t == null ? void 0 : t.updatedAt) || t.createdAt}`,
760
+ alt: t.name,
761
+ className: "absolute inset-0 h-full w-full object-cover"
762
+ }
763
+ )
764
+ ] })
765
+ ] }),
766
+ /* @__PURE__ */ r("div", { className: "flex items-end justify-between border-t-[1px] border-black/10 bg-white px-2 py-1", children: [
767
+ /* @__PURE__ */ e("div", { className: "truncate text-xs leading-tight", title: t.name, children: t.name }),
768
+ /* @__PURE__ */ e("div", { className: "flex items-center justify-between whitespace-nowrap text-[9px] font-light text-muted-foreground", children: /* @__PURE__ */ e("span", { children: ct((t == null ? void 0 : t.size) || 0) }) })
769
+ ] }),
770
+ !k.some((u) => u.id === t.id) && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100", children: /* @__PURE__ */ r("div", { className: "grid grid-cols-4 gap-2 p-2", children: [
771
+ /* @__PURE__ */ e(_, { children: /* @__PURE__ */ r(P, { children: [
772
+ /* @__PURE__ */ e(q, { asChild: !0, children: /* @__PURE__ */ e(
773
+ p,
774
+ {
775
+ variant: "secondary",
776
+ size: "icon",
777
+ className: "h-8 w-8 rounded-full",
778
+ onClick: (u) => {
779
+ u.stopPropagation(), Te(t);
780
+ },
781
+ children: /* @__PURE__ */ e(Ye, { className: "h-4 w-4" })
782
+ }
783
+ ) }),
784
+ /* @__PURE__ */ e(G, { children: /* @__PURE__ */ e("p", { children: c("View Details") }) })
785
+ ] }) }),
786
+ /* @__PURE__ */ e(_, { children: /* @__PURE__ */ r(P, { children: [
787
+ /* @__PURE__ */ e(q, { asChild: !0, children: /* @__PURE__ */ e(
788
+ p,
789
+ {
790
+ variant: "secondary",
791
+ size: "icon",
792
+ className: "h-8 w-8 rounded-full",
793
+ onClick: (u) => {
794
+ u.stopPropagation(), navigator.clipboard.writeText(t.url), A.success(c("Asset URL copied to clipboard"));
795
+ },
796
+ children: /* @__PURE__ */ e(fe, { className: "h-4 w-4" })
797
+ }
798
+ ) }),
799
+ /* @__PURE__ */ e(G, { children: /* @__PURE__ */ e("p", { children: c("Copy URL") }) })
800
+ ] }) }),
801
+ /* @__PURE__ */ e(_, { children: /* @__PURE__ */ r(P, { children: [
802
+ /* @__PURE__ */ e(q, { asChild: !0, children: /* @__PURE__ */ e(
803
+ p,
804
+ {
805
+ variant: "secondary",
806
+ size: "icon",
807
+ className: "h-8 w-8 rounded-full",
808
+ onClick: (u) => {
809
+ u.stopPropagation(), m({
810
+ id: t.id,
811
+ show: !0,
812
+ file: t.url,
813
+ name: t.name
814
+ });
815
+ },
816
+ children: /* @__PURE__ */ e(et, { className: "h-4 w-4" })
817
+ }
818
+ ) }),
819
+ /* @__PURE__ */ e(G, { children: /* @__PURE__ */ e("p", { children: c("Edit Image") }) })
820
+ ] }) }),
821
+ /* @__PURE__ */ e(_, { children: /* @__PURE__ */ r(P, { children: [
822
+ /* @__PURE__ */ e(q, { asChild: !0, children: /* @__PURE__ */ e(
823
+ p,
824
+ {
825
+ variant: "destructive",
826
+ size: "icon",
827
+ className: "h-8 w-8 rounded-full",
828
+ onClick: (u) => {
829
+ u.stopPropagation(), ke(t);
830
+ },
831
+ children: /* @__PURE__ */ e(tt, { className: "h-4 w-4" })
832
+ }
833
+ ) }),
834
+ /* @__PURE__ */ e(G, { children: /* @__PURE__ */ e("p", { children: c("Delete Asset") }) })
835
+ ] }) })
836
+ ] }) }),
837
+ k.some((u) => u.id === t.id) && /* @__PURE__ */ e("div", { className: "absolute right-1 top-1 h-max rounded-full border border-white bg-blue-500 p-1", children: /* @__PURE__ */ e(it, { className: "h-3 w-3 text-white", strokeWidth: 5 }) })
838
+ ]
839
+ },
840
+ t.id
841
+ )) }) }),
842
+ T > 1 && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 border-t bg-white p-4", children: /* @__PURE__ */ e(st, { fallback: /* @__PURE__ */ e("div", { className: "text-red-500", children: c("Error loading pagination") }), children: /* @__PURE__ */ e(
843
+ ht,
844
+ {
845
+ currentPage: R,
846
+ totalPages: T,
847
+ onPageChange: je,
848
+ pageRangeDisplayed: 3,
849
+ showPageInput: !0
850
+ }
851
+ ) }) })
852
+ ] })
853
+ ] }) : /* @__PURE__ */ e(
854
+ xt,
855
+ {
856
+ assetId: N || l || "",
857
+ onBack: () => {
858
+ E("grid"), x(null);
859
+ },
860
+ onEdit: (t) => {
861
+ m({
862
+ id: t.id,
863
+ show: !0,
864
+ file: t.url,
865
+ name: t.name
866
+ });
867
+ },
868
+ onSave: async (t) => {
869
+ if (N) {
870
+ f(!0);
871
+ try {
872
+ const u = D.find(($) => $.id === N);
873
+ u && await re(Oe(u, { description: t }));
874
+ } finally {
875
+ f(!1);
876
+ }
877
+ }
878
+ },
879
+ isSaving: d
880
+ }
881
+ )
882
+ ] }),
883
+ o.show && /* @__PURE__ */ e(
884
+ rt,
885
+ {
886
+ fallback: /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e(B, { className: "h-8 w-8 animate-spin" }) }),
887
+ children: /* @__PURE__ */ e(
888
+ vt,
889
+ {
890
+ imageUrl: o.file,
891
+ onSave: ze,
892
+ onClose: () => m({ show: !1, file: "" }),
893
+ defaultSavedImageName: o.name,
894
+ isEditing: !!o.id
895
+ }
896
+ )
897
+ }
898
+ ),
899
+ g && /* @__PURE__ */ e(Ue, { open: !!g, onOpenChange: () => w(null), children: /* @__PURE__ */ r(Le, { children: [
900
+ /* @__PURE__ */ r($e, { children: [
901
+ /* @__PURE__ */ e(Me, { children: c("Delete Asset") }),
902
+ /* @__PURE__ */ e(_e, { children: c('Are you sure you want to delete "{{name}}"? This action cannot be undone.', { name: g.name }) })
903
+ ] }),
904
+ /* @__PURE__ */ r(Pe, { className: "gap-2 sm:gap-0", children: [
905
+ /* @__PURE__ */ e(p, { variant: "outline", onClick: () => w(null), children: c("Cancel") }),
906
+ /* @__PURE__ */ e(p, { variant: "destructive", onClick: Ie, children: c("Delete") })
907
+ ] })
908
+ ] }) })
909
+ ] });
910
+ }
911
+ export {
912
+ jt as default
913
+ };