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