@chaibuilder/sdk 3.2.8 → 4.0.0-beta.2
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/README.md +25 -20
- package/dist/2SSKDMRQ-C4VFVd-q.cjs +1 -0
- package/dist/2SSKDMRQ-DSnzF_1o.js +42 -0
- package/dist/AP7HFJJL-B7YYCY9q.cjs +1228 -0
- package/dist/AP7HFJJL-Cxwj01Aq.js +9214 -0
- package/dist/IconPicker-C9-ieDWm.cjs +1 -0
- package/dist/IconPicker-RqVvq6G2.js +59 -0
- package/dist/WDYDFRGG-C7aSUcjs.js +33 -0
- package/dist/WDYDFRGG-b3T2SQbz.cjs +1 -0
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
- package/dist/actions-registery-CZ1w0NKa.js +15545 -0
- package/dist/actions-registery-YnFmU21O.cjs +418 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.ts +3202 -0
- package/dist/actions.js +216 -0
- package/dist/active-in-another-tab-Clng6zpY.cjs +1 -0
- package/dist/active-in-another-tab-wb8qolB8.js +34 -0
- package/dist/add-new-language-page-C4BuMTaN.cjs +1 -0
- package/dist/add-new-language-page-D7NDABl1.js +401 -0
- package/dist/add-new-page-B4hc0B-g.js +31 -0
- package/dist/add-new-page-BNfwKjRd.cjs +1 -0
- package/dist/ai-panel-content-BnbURb7j.js +61 -0
- package/dist/ai-panel-content-DPy2jgKw.cjs +1 -0
- package/dist/ai-panel-default-lang-3tCHzab5.cjs +3 -0
- package/dist/ai-panel-default-lang-oVk4TDeb.js +341 -0
- package/dist/ai-panel-other-lang-BBHCCSen.cjs +1 -0
- package/dist/ai-panel-other-lang-DmQ3QMDD.js +162 -0
- package/dist/ai-prompt-input-DaTyfib-.js +655 -0
- package/dist/ai-prompt-input-b5ty81RB.cjs +1 -0
- package/dist/ai-translation-prompt-DJPe2O-n.js +28 -0
- package/dist/ai-translation-prompt-c0Q3zkT2.cjs +1 -0
- package/dist/{apply-binding-DLaiD20q.js → apply-binding-6iwlED02.js} +156 -166
- package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
- package/dist/{code-display-DuH-UOhl.js → code-display-BzBq5xSn.js} +1 -1
- package/dist/code-display-Q3_sK_Ta.cjs +1 -0
- package/dist/code-editor-BQZi6-FB.cjs +1 -0
- package/dist/code-editor-DWWnphW9.js +50 -0
- package/dist/continue-editing-in-this-client-BllU94XG.js +24 -0
- package/dist/continue-editing-in-this-client-D9HyD4GP.cjs +1 -0
- package/dist/core-BoRDjj4h.cjs +1 -0
- package/dist/core-yvI6kCyw.js +56 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +2 -393
- package/dist/core.js +37 -105
- package/dist/css-import-modal-BSMGKA2T.cjs +13 -0
- package/dist/{css-import-modal-CFB2YjDT.js → css-import-modal-D72a-16X.js} +39 -38
- package/dist/{delete-design-token-BjMakV-b.js → delete-design-token-Cd1ZDtqT.js} +3 -3
- package/dist/delete-design-token-D_TLlO3I.cjs +1 -0
- package/dist/delete-page-ByQwBupJ.cjs +1 -0
- package/dist/delete-page-DC8pzvWW.js +70 -0
- package/dist/design-token-usage-BqZeR1sT.cjs +1 -0
- package/dist/design-token-usage-DE4XCDdn.js +113 -0
- package/dist/digital-asset-manager-BYLKFEYi.cjs +1 -0
- package/dist/digital-asset-manager-C_gL_0YY.js +876 -0
- package/dist/duplicate-page-BoVhko2q.js +133 -0
- package/dist/duplicate-page-vdvwLQLo.cjs +1 -0
- package/dist/dynamic-page-selector-CSndg2-y.js +85 -0
- package/dist/dynamic-page-selector-DdnbCuQZ.cjs +1 -0
- package/dist/fonts-B-Xt29pe.cjs +1 -0
- package/dist/fonts-DRly3Wzd.js +78 -0
- package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
- package/dist/get-chai-builder-theme-BYtp20KD.js +24 -0
- package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/image-editor-DTspjj_c.cjs +1 -0
- package/dist/image-editor-oypq8asR.js +108 -0
- package/dist/index-B-rSiAp_.cjs +1 -0
- package/dist/index-BDnwJqMw.js +4732 -0
- package/dist/index-CbwxUFy_.cjs +5 -0
- package/dist/index-CnSjWE1P.cjs +160 -0
- package/dist/index-Dxfyt4d4.js +39 -0
- package/dist/index-S8ibZk9Q.js +19069 -0
- package/dist/json-diff-viewer-B5dr-Y_L.js +258 -0
- package/dist/json-diff-viewer-XX1pgabt.cjs +8 -0
- package/dist/lang-panel-BPxex-M2.cjs +1 -0
- package/dist/lang-panel-Cn83SRzd.js +215 -0
- package/dist/manage-design-tokens-ConiyuPr.cjs +1 -0
- package/dist/{manage-design-tokens-DUoMdCBl.js → manage-design-tokens-lP4HLS0P.js} +31 -32
- package/dist/mark-as-template-DYRxre1f.cjs +1 -0
- package/dist/mark-as-template-jncsjfHm.js +156 -0
- package/dist/models-5gOsRC56.cjs +1 -0
- package/dist/models-D95ZYr_x.js +70 -0
- package/dist/nested-path-selector-content-B-8LqhXI.js +87 -0
- package/dist/nested-path-selector-content-BYtLi7mC.cjs +1 -0
- package/dist/no-language-page-content-DAbLq0gX.cjs +1 -0
- package/dist/no-language-page-content-D_zd9Rb0.js +42 -0
- package/dist/no-language-page-dialog-C5Ps6YYL.js +10 -0
- package/dist/no-language-page-dialog-fXmbQO7L.cjs +1 -0
- package/dist/page-creator-VWIB2VAs.cjs +1 -0
- package/dist/page-creator-wCMtlE6Z.js +795 -0
- package/dist/page-lock-BPCxfv9J.js +30 -0
- package/dist/page-lock-DweiYy1w.cjs +1 -0
- package/dist/page-locked-dialog-BlbgvaG2.cjs +1 -0
- package/dist/page-locked-dialog-ByGl18_m.js +133 -0
- package/dist/page-manager-new-BWFE-S-O.js +394 -0
- package/dist/page-manager-new-D0lGfNnS.cjs +1 -0
- package/dist/page-manager-search-and-filter-DpGMoOII.cjs +1 -0
- package/dist/page-manager-search-and-filter-kNJFWJ86.js +201 -0
- package/dist/page-revisions-content-DYxXZqmh.cjs +1 -0
- package/dist/page-revisions-content-Ulr8slUN.js +445 -0
- package/dist/pages.cjs +1 -0
- package/dist/pages.d.ts +492 -0
- package/dist/pages.js +27 -0
- package/dist/{plugin-BOcGV_IY.js → plugin-3ZKK6RXm.js} +30 -44
- package/dist/plugin-C6rgJDNQ.cjs +22 -0
- package/dist/publish-pages-content-BTPzt_m4.js +178 -0
- package/dist/publish-pages-content-D6g8GAsd.cjs +1 -0
- package/dist/register-partial-type-BjtdfKHE.js +36 -0
- package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +12 -9
- package/dist/render.js +97 -99
- package/dist/rte-widget-modal-DrMzWWjw.cjs +1 -0
- package/dist/rte-widget-modal-Rk_NW3KU.js +38 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +306 -7
- package/dist/runtime.js +44 -1
- package/dist/save-to-lib-BK3uTFss.js +422 -0
- package/dist/save-to-lib-DHHUO12i.cjs +1 -0
- package/dist/sdk.css +1 -1
- package/dist/selected-block-display-CU3TwIMA.js +319 -0
- package/dist/selected-block-display-DSFhddPj.cjs +16 -0
- package/dist/seo-panel-Dl0IDV09.cjs +2 -0
- package/dist/seo-panel-jbzxFioc.js +798 -0
- package/dist/shared-json-ld-BL_dv3_q.js +565 -0
- package/dist/shared-json-ld-DPNkqDC1.cjs +1 -0
- package/dist/slug-input-1qwKkXhA.js +86 -0
- package/dist/slug-input-YVLjtTI3.cjs +1 -0
- package/dist/supabase-actions.cjs +1 -0
- package/dist/supabase-actions.d.ts +284 -0
- package/dist/supabase-actions.js +524 -0
- package/dist/take-over-request-DKvKi3mM.js +63 -0
- package/dist/take-over-request-DvMIg_cZ.cjs +1 -0
- package/dist/theme-panel-footer-BMOaPLWc.cjs +1 -0
- package/dist/theme-panel-footer-DbMDLYGI.js +25 -0
- package/dist/translation-warning-modal-9wTwIy_9.js +26 -0
- package/dist/translation-warning-modal-DjTwz75c.cjs +1 -0
- package/dist/unmark-as-template-CdqIJJER.cjs +1 -0
- package/dist/unmark-as-template-Dulvf7Zw.js +39 -0
- package/dist/unpublish-page-BwSVBf0_.cjs +1 -0
- package/dist/unpublish-page-Degu5Cy9.js +27 -0
- package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
- package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
- package/dist/utils.cjs +1 -0
- package/dist/{tailwind.d.ts → utils.d.ts} +4 -7
- package/dist/utils.js +7 -0
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.d.ts +0 -6
- package/dist/web-blocks.js +48 -47
- package/dist/web-preview-DXE4Jnf5.js +73 -0
- package/dist/web-preview-YzKxyXft.cjs +1 -0
- package/package.json +159 -89
- package/dist/IconPicker-6JSublJp.js +0 -64
- package/dist/IconPicker-DpQQDK_Q.cjs +0 -1
- package/dist/apply-binding-Bn1KC8uC.cjs +0 -1
- package/dist/code-display-Dw1tAwiJ.cjs +0 -1
- package/dist/code-editor-cnBzYLxk.cjs +0 -1
- package/dist/code-editor-vpbOSO05.js +0 -59
- package/dist/css-import-modal-bGWZSlqv.cjs +0 -13
- package/dist/delete-design-token-Bzxspf8D.cjs +0 -1
- package/dist/design-token-usage-BDArZ38H.js +0 -120
- package/dist/design-token-usage-CCv4XltM.cjs +0 -1
- package/dist/get-chai-builder-theme-B1tr_NJB.cjs +0 -1
- package/dist/get-chai-builder-theme-BarMkcGH.js +0 -12
- package/dist/index-CuANr9iH.cjs +0 -160
- package/dist/index-DvdOXKUE.js +0 -18338
- package/dist/manage-design-tokens-DpC46NAy.cjs +0 -1
- package/dist/mockServiceWorker.js +0 -349
- package/dist/plugin-CSgw-f78.cjs +0 -22
- package/dist/rte-widget-modal-CXbmmhcb.js +0 -41
- package/dist/rte-widget-modal-DDjf0xui.cjs +0 -1
- package/dist/tailwind.cjs +0 -1
- package/dist/tailwind.js +0 -8
- package/dist/tooltip-Ba1-8jmj.cjs +0 -1
- package/dist/tooltip-DUosa-uC.js +0 -1067
- package/dist/ui.cjs +0 -1
- package/dist/ui.d.ts +0 -415
- package/dist/ui.js +0 -129
- package/dist/vite.svg +0 -1
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { jsx as i, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { jsx as i, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { D as T, d as V, e as N, f as R, p as E, B as y, L as D, T as I, q as A } from "./index-S8ibZk9Q.js";
|
|
3
|
+
import "lodash-es";
|
|
4
4
|
import * as b from "culori";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
5
|
+
import { a as L } from "./fonts-DRly3Wzd.js";
|
|
6
|
+
import * as x from "react";
|
|
7
|
+
import { useTranslation as P } from "react-i18next";
|
|
8
|
+
const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", H = (o) => `hsl(${d(o.h)} ${d(o.s * 100)}% ${d(o.l * 100)}%)`, M = (o, e = "hsl", s = "4") => {
|
|
8
9
|
try {
|
|
9
10
|
const r = b.parse(o);
|
|
10
11
|
if (!r) throw new Error("Invalid color input");
|
|
11
12
|
switch (e) {
|
|
12
13
|
case "hsl": {
|
|
13
14
|
const t = b.converter("hsl")(r);
|
|
14
|
-
return s === "4" ?
|
|
15
|
+
return s === "4" ? H(t) : `${d(t.h)} ${d(t.s * 100)}% ${d(t.l * 100)}%`;
|
|
15
16
|
}
|
|
16
17
|
case "rgb":
|
|
17
18
|
return b.formatRgb(r);
|
|
@@ -40,13 +41,13 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
40
41
|
const s = w(o);
|
|
41
42
|
if (!s.isValid)
|
|
42
43
|
return console.warn("CSS validation failed:", s.error), $();
|
|
43
|
-
const r = v(o, ":root"), t = v(o, ".dark"), l =
|
|
44
|
+
const r = v(o, ":root"), t = v(o, ".dark"), l = f(r, "--font-sans") || f(r, "--font-family") || f(r, "--font-heading") || f(r, "--font-body"), n = B(l);
|
|
44
45
|
e.fontFamily = {
|
|
45
46
|
heading: n,
|
|
46
47
|
body: n
|
|
47
48
|
};
|
|
48
|
-
const
|
|
49
|
-
e.borderRadius =
|
|
49
|
+
const m = f(r, "--radius") || f(r, "--border-radius") || "0.5rem";
|
|
50
|
+
e.borderRadius = q(m), [
|
|
50
51
|
"background",
|
|
51
52
|
"foreground",
|
|
52
53
|
"primary",
|
|
@@ -67,7 +68,7 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
67
68
|
"popover",
|
|
68
69
|
"popover-foreground"
|
|
69
70
|
].forEach((a) => {
|
|
70
|
-
const p =
|
|
71
|
+
const p = f(r, `--${a}`), g = f(t, `--${a}`);
|
|
71
72
|
if (p || g) {
|
|
72
73
|
const c = p ? k(p) : "#000000", C = g ? k(g) : c;
|
|
73
74
|
e.colors[a] = [c, C];
|
|
@@ -81,7 +82,7 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
81
82
|
var r, t;
|
|
82
83
|
const s = new RegExp(`${F(e)}\\s*{([^}]+)}`);
|
|
83
84
|
return ((t = (r = o.match(s)) == null ? void 0 : r[1]) == null ? void 0 : t.trim()) || null;
|
|
84
|
-
},
|
|
85
|
+
}, f = (o, e) => {
|
|
85
86
|
var t;
|
|
86
87
|
if (!o) return null;
|
|
87
88
|
const s = new RegExp(`${F(e)}\\s*:\\s*([^;]+)`), r = o.match(s);
|
|
@@ -102,8 +103,8 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
102
103
|
return S(e) || "#000000";
|
|
103
104
|
const s = e.match(/^(\d+\.?\d*)\s+(\d+\.?\d*)%\s+(\d+\.?\d*)%$/);
|
|
104
105
|
if (s) {
|
|
105
|
-
const [r, t, l
|
|
106
|
-
return S(
|
|
106
|
+
const [, r, t, l] = s, n = `hsl(${r} ${t}% ${l}%)`;
|
|
107
|
+
return S(n) || "#000000";
|
|
107
108
|
}
|
|
108
109
|
if (/^[\d.]+[\s,]+[\d.]+[\s,]+[\d.]+(?:[\s,/]+[\d.]+)?$/.test(e)) {
|
|
109
110
|
const r = e.split(/[\s,]+/).filter(Boolean);
|
|
@@ -117,7 +118,7 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
117
118
|
return console.warn("Failed to process color:", o, e), "#000000";
|
|
118
119
|
}
|
|
119
120
|
}, B = (o) => {
|
|
120
|
-
const e =
|
|
121
|
+
const e = L();
|
|
121
122
|
if (!o)
|
|
122
123
|
return "ui-sans-serif, system-ui, sans-serif";
|
|
123
124
|
try {
|
|
@@ -126,9 +127,7 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
126
127
|
} catch (s) {
|
|
127
128
|
return console.warn("Error processing font family:", o, s), "ui-sans-serif, system-ui, sans-serif";
|
|
128
129
|
}
|
|
129
|
-
},
|
|
130
|
-
if (!o)
|
|
131
|
-
return "8px";
|
|
130
|
+
}, q = (o) => {
|
|
132
131
|
try {
|
|
133
132
|
const e = o.trim();
|
|
134
133
|
if (e.endsWith("px"))
|
|
@@ -175,7 +174,7 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
175
174
|
popover: ["#ffffff", "#0f172a"],
|
|
176
175
|
"popover-foreground": ["#000000", "#f8fafc"]
|
|
177
176
|
}
|
|
178
|
-
}), F = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
177
|
+
}), F = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), W = (o) => ["background", "foreground", "primary", "primary-foreground"].every(
|
|
179
178
|
(r) => o.colors[r] && Array.isArray(o.colors[r]) && o.colors[r].length >= 2
|
|
180
179
|
) && !!o.fontFamily.heading && !!o.fontFamily.body && !!o.borderRadius, w = (o) => {
|
|
181
180
|
if (!o || typeof o != "string")
|
|
@@ -203,7 +202,7 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
203
202
|
} catch (s) {
|
|
204
203
|
return console.error("CSS validation error:", s), { isValid: !1, error: "Failed to parse CSS. Please check your syntax." };
|
|
205
204
|
}
|
|
206
|
-
},
|
|
205
|
+
}, _ = `:root {
|
|
207
206
|
--background: 0 0% 100%;
|
|
208
207
|
--foreground: oklch(0.52 0.13 144.17);
|
|
209
208
|
--primary: #3e2723;
|
|
@@ -215,8 +214,8 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
215
214
|
--foreground: hsl(37.50 36.36% 95.69%);
|
|
216
215
|
--primary: rgb(46, 125, 50);
|
|
217
216
|
--primary-foreground: #ffffff;
|
|
218
|
-
}`,
|
|
219
|
-
const [r, t] = x.useState(""), [l, n] = x.useState(null), [
|
|
217
|
+
}`, J = ({ open: o, onOpenChange: e, onImport: s }) => {
|
|
218
|
+
const [r, t] = x.useState(""), [l, n] = x.useState(null), [m, h] = x.useState(!1), { t: a } = P(), p = async () => {
|
|
220
219
|
h(!0), n(null);
|
|
221
220
|
try {
|
|
222
221
|
const c = w(r);
|
|
@@ -227,9 +226,11 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
227
226
|
return;
|
|
228
227
|
}
|
|
229
228
|
const C = z(r);
|
|
230
|
-
if (!
|
|
229
|
+
if (!W(C)) {
|
|
231
230
|
n(
|
|
232
|
-
a(
|
|
231
|
+
a(
|
|
232
|
+
"The CSS doesn't contain enough theme information. Please ensure it includes at least background, foreground, primary, and primary-foreground colors."
|
|
233
|
+
)
|
|
233
234
|
), setTimeout(() => {
|
|
234
235
|
n(null);
|
|
235
236
|
}, 5e3), h(!1);
|
|
@@ -246,14 +247,14 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
246
247
|
}, g = () => {
|
|
247
248
|
t(""), n(null), e(!1);
|
|
248
249
|
};
|
|
249
|
-
return /* @__PURE__ */ i(
|
|
250
|
-
/* @__PURE__ */
|
|
250
|
+
return /* @__PURE__ */ i(T, { open: o, onOpenChange: e, children: /* @__PURE__ */ u(V, { className: "flex max-h-[80vh] max-w-2xl flex-col", children: [
|
|
251
|
+
/* @__PURE__ */ u(N, { children: [
|
|
251
252
|
/* @__PURE__ */ i(R, { children: a("Import CSS Theme") }),
|
|
252
|
-
/* @__PURE__ */
|
|
253
|
+
/* @__PURE__ */ u(E, { className: "space-y-2", children: [
|
|
253
254
|
/* @__PURE__ */ i("p", { children: a(
|
|
254
255
|
"Paste your CSS variables to import a custom theme. The CSS should contain :root and .dark blocks with CSS custom properties."
|
|
255
256
|
) }),
|
|
256
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ u("div", { className: "flex items-center", children: [
|
|
257
258
|
/* @__PURE__ */ i("p", { className: "font-bold", children: "Get theme resources:" }),
|
|
258
259
|
/* @__PURE__ */ i(y, { variant: "link", size: "sm", onClick: () => window.open("https://tweakcn.com/", "_blank"), children: "TweakCN" }),
|
|
259
260
|
/* @__PURE__ */ i(
|
|
@@ -277,29 +278,29 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
277
278
|
] })
|
|
278
279
|
] })
|
|
279
280
|
] }),
|
|
280
|
-
/* @__PURE__ */
|
|
281
|
-
/* @__PURE__ */
|
|
282
|
-
/* @__PURE__ */ i(
|
|
281
|
+
/* @__PURE__ */ u("div", { className: "flex-1 space-y-4 overflow-hidden", children: [
|
|
282
|
+
/* @__PURE__ */ u("div", { className: "space-y-2", children: [
|
|
283
|
+
/* @__PURE__ */ i(D, { htmlFor: "css-input", children: a("CSS Variables") }),
|
|
283
284
|
/* @__PURE__ */ i(
|
|
284
|
-
|
|
285
|
+
I,
|
|
285
286
|
{
|
|
286
287
|
id: "css-input",
|
|
287
|
-
placeholder:
|
|
288
|
+
placeholder: _,
|
|
288
289
|
value: r,
|
|
289
290
|
onChange: (c) => t(c.target.value),
|
|
290
291
|
className: "min-h-[300px] resize-none font-mono text-sm",
|
|
291
|
-
disabled:
|
|
292
|
+
disabled: m
|
|
292
293
|
}
|
|
293
294
|
)
|
|
294
295
|
] }),
|
|
295
296
|
l && /* @__PURE__ */ i("div", { className: "rounded-md border border-red-200 bg-red-50 p-3", children: /* @__PURE__ */ i("p", { className: "text-sm text-red-600", children: l }) })
|
|
296
297
|
] }),
|
|
297
|
-
/* @__PURE__ */
|
|
298
|
-
/* @__PURE__ */ i(y, { variant: "outline", onClick: g, disabled:
|
|
299
|
-
/* @__PURE__ */ i(y, { onClick: p, disabled: !r.trim() ||
|
|
298
|
+
/* @__PURE__ */ u(A, { className: "gap-2", children: [
|
|
299
|
+
/* @__PURE__ */ i(y, { variant: "outline", onClick: g, disabled: m, children: a("Cancel") }),
|
|
300
|
+
/* @__PURE__ */ i(y, { onClick: p, disabled: !r.trim() || m, children: a(m ? "Importing..." : "Import Theme") })
|
|
300
301
|
] })
|
|
301
302
|
] }) });
|
|
302
303
|
};
|
|
303
304
|
export {
|
|
304
|
-
|
|
305
|
+
J as CssImportModal
|
|
305
306
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as e, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useTranslation as
|
|
2
|
+
import { G as i, H as n, J as c, K as d, M as m, O as h, Q as g, R as u, U as x } from "./index-S8ibZk9Q.js";
|
|
3
|
+
import { useTranslation as D } from "react-i18next";
|
|
4
4
|
const N = ({ tokenName: l, tokenValue: s, onDelete: a, children: o }) => {
|
|
5
|
-
const { t: r } =
|
|
5
|
+
const { t: r } = D();
|
|
6
6
|
return /* @__PURE__ */ e(i, { children: [
|
|
7
7
|
/* @__PURE__ */ t(n, { asChild: !0, children: o }),
|
|
8
8
|
/* @__PURE__ */ e(c, { className: "max-w-md", children: [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-CnSjWE1P.cjs"),i=require("react-i18next"),a=({tokenName:r,tokenValue:l,onDelete:n,children:o})=>{const{t:s}=i.useTranslation();return e.jsxs(t.AlertDialog,{children:[e.jsx(t.AlertDialogTrigger,{asChild:!0,children:o}),e.jsxs(t.AlertDialogContent,{className:"max-w-md",children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsxs(t.AlertDialogTitle,{className:"text-base",children:[s("Delete"),' "',r,'"?']}),e.jsx(t.AlertDialogDescription,{asChild:!0,children:e.jsxs("div",{className:"space-y-3 pt-1 text-sm",children:[e.jsx("p",{className:"text-muted-foreground",children:s("This action cannot be undone. This will permanently remove the design token from your project.")}),e.jsxs("div",{className:"rounded-md border bg-muted/50 p-3",children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:s("Token classes")}),e.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:l})]})]})})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{className:"h-7 text-xs",children:s("Cancel")}),e.jsx(t.AlertDialogAction,{onClick:n,className:"h-7 bg-destructive text-xs text-destructive-foreground hover:bg-destructive/90",children:s("Delete")})]})]})]})};exports.default=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("./index-CnSjWE1P.cjs"),o=require("./index-CbwxUFy_.cjs"),L=require("lodash-es"),D=require("react"),N=require("react-i18next"),f=(e,r)=>{const n=r.filter(u=>u.parent===e);if(n.length===0)return 0;let a=n.length;return n.forEach(u=>{a+=f(u.id,r)}),a};function A({page:e,onClose:r}){const{t:n}=N.useTranslation(),[,a]=o.useSearchParams(),{mutate:u,isPending:x}=o.useDeletePage(),{data:P}=o.usePageTypes(),{data:h=[]}=o.useWebsitePages(),{setSelectedLang:v,fallbackLang:S}=s.useLanguages(),[,w]=s.useSidebarActivePanel(),l=!(e!=null&&e.primaryPage),{data:i=[]}=o.useLanguagePages(l?e==null?void 0:e.id:void 0),j=D.useMemo(()=>!l||!i?0:i.filter(d=>d.id!==(e==null?void 0:e.id)).length,[l,i,e==null?void 0:e.id]),m=D.useMemo(()=>{if(!(e!=null&&e.id)||!h.length)return 0;let d=f(e.id,h);return l&&i&&i.length>0&&i.forEach(y=>{y.id!==e.id&&(d+=f(y.id,h))}),d},[e==null?void 0:e.id,h,l,i]),C=()=>{x||u(e,{onSuccess:()=>{e!=null&&e.primaryPage?(window.history.replaceState({},"",`/?page=${e.primaryPage}`),a(new URLSearchParams({page:e.primaryPage}))):(window.history.replaceState({},"","/"),a(new URLSearchParams)),window.dispatchEvent(new PopStateEvent("popstate")),v(S),w("outline"),r()}})},c=P==null?void 0:P.find(d=>d.key===(e==null?void 0:e.pageType));return t.jsx(s.Dialog,{open:!!e,onOpenChange:r,children:t.jsxs(s.DialogContent,{children:[t.jsxs(s.DialogHeader,{children:[t.jsx(s.DialogTitle,{children:n("Confirm Deletion")}),t.jsxs(s.DialogDescription,{className:"py-4 text-slate-500",children:[t.jsxs("div",{children:[n("Are you sure you want to remove")," ",t.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",c!=null&&c.hasSlug?(c==null?void 0:c.name)+"?":n("page?")]}),l&&(j>0||m>0)&&t.jsxs("div",{className:"mt-3 rounded-md bg-red-50 p-3 text-sm",children:[t.jsxs("div",{className:"font-semibold text-red-800",children:[n("Warning: Deleting this primary page will also delete"),":"]}),t.jsxs("ul",{className:"mt-2 list-inside list-disc space-y-1 text-red-700",children:[m>0&&t.jsxs("li",{children:[t.jsx("span",{className:"font-medium",children:m})," ",n(m===1?"nested child page":"nested child pages")]}),j>0&&t.jsx("li",{children:n("All associated language pages")})]})]}),e.lang&&t.jsxs("div",{className:"py-2 text-sm",children:[n("Language"),":"," ",t.jsx("span",{className:"font-medium text-gray-500",children:L.get(o.LANGUAGES,e.lang,e.lang)})]})]})]}),t.jsxs(s.DialogFooter,{children:[t.jsx(s.Button,{variant:"outline",onClick:r,children:n("Cancel")}),t.jsx(s.Button,{variant:"destructive",disabled:x,onClick:C,children:n(x?"Deleting...":"Delete")})]})]})})}exports.default=A;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as i, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import { n as N, o as A, D as E, d as b, e as k, f as U, p as B, q as G, B as v } from "./index-S8ibZk9Q.js";
|
|
3
|
+
import { c as R, o as W, m as q, g as F, l as H, L as M } from "./index-BDnwJqMw.js";
|
|
4
|
+
import { get as Q } from "lodash-es";
|
|
5
|
+
import { useMemo as w } from "react";
|
|
6
|
+
import { useTranslation as $ } from "react-i18next";
|
|
7
|
+
const P = (e, r) => {
|
|
8
|
+
const t = r.filter((c) => c.parent === e);
|
|
9
|
+
if (t.length === 0) return 0;
|
|
10
|
+
let d = t.length;
|
|
11
|
+
return t.forEach((c) => {
|
|
12
|
+
d += P(c.id, r);
|
|
13
|
+
}), d;
|
|
14
|
+
};
|
|
15
|
+
function X({ page: e, onClose: r }) {
|
|
16
|
+
const { t } = $(), [, d] = R(), { mutate: c, isPending: h } = W(), { data: f } = q(), { data: m = [] } = F(), { setSelectedLang: S, fallbackLang: x } = N(), [, L] = A(), l = !(e != null && e.primaryPage), { data: s = [] } = H(l ? e == null ? void 0 : e.id : void 0), D = w(() => !l || !s ? 0 : s.filter((o) => o.id !== (e == null ? void 0 : e.id)).length, [l, s, e == null ? void 0 : e.id]), u = w(() => {
|
|
17
|
+
if (!(e != null && e.id) || !m.length) return 0;
|
|
18
|
+
let o = P(e.id, m);
|
|
19
|
+
return l && s && s.length > 0 && s.forEach((y) => {
|
|
20
|
+
y.id !== e.id && (o += P(y.id, m));
|
|
21
|
+
}), o;
|
|
22
|
+
}, [e == null ? void 0 : e.id, m, l, s]), C = () => {
|
|
23
|
+
h || c(e, {
|
|
24
|
+
onSuccess: () => {
|
|
25
|
+
e != null && e.primaryPage ? (window.history.replaceState({}, "", `/?page=${e.primaryPage}`), d(new URLSearchParams({ page: e.primaryPage }))) : (window.history.replaceState({}, "", "/"), d(new URLSearchParams())), window.dispatchEvent(new PopStateEvent("popstate")), S(x), L("outline"), r();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}, a = f == null ? void 0 : f.find((o) => o.key === (e == null ? void 0 : e.pageType));
|
|
29
|
+
return /* @__PURE__ */ i(E, { open: !!e, onOpenChange: r, children: /* @__PURE__ */ n(b, { children: [
|
|
30
|
+
/* @__PURE__ */ n(k, { children: [
|
|
31
|
+
/* @__PURE__ */ i(U, { children: t("Confirm Deletion") }),
|
|
32
|
+
/* @__PURE__ */ n(B, { className: "py-4 text-slate-500", children: [
|
|
33
|
+
/* @__PURE__ */ n("div", { children: [
|
|
34
|
+
t("Are you sure you want to remove"),
|
|
35
|
+
" ",
|
|
36
|
+
/* @__PURE__ */ i("b", { children: (e == null ? void 0 : e.name) ?? (e == null ? void 0 : e.slug) }),
|
|
37
|
+
" ",
|
|
38
|
+
a != null && a.hasSlug ? (a == null ? void 0 : a.name) + "?" : t("page?")
|
|
39
|
+
] }),
|
|
40
|
+
l && (D > 0 || u > 0) && /* @__PURE__ */ n("div", { className: "mt-3 rounded-md bg-red-50 p-3 text-sm", children: [
|
|
41
|
+
/* @__PURE__ */ n("div", { className: "font-semibold text-red-800", children: [
|
|
42
|
+
t("Warning: Deleting this primary page will also delete"),
|
|
43
|
+
":"
|
|
44
|
+
] }),
|
|
45
|
+
/* @__PURE__ */ n("ul", { className: "mt-2 list-inside list-disc space-y-1 text-red-700", children: [
|
|
46
|
+
u > 0 && /* @__PURE__ */ n("li", { children: [
|
|
47
|
+
/* @__PURE__ */ i("span", { className: "font-medium", children: u }),
|
|
48
|
+
" ",
|
|
49
|
+
t(u === 1 ? "nested child page" : "nested child pages")
|
|
50
|
+
] }),
|
|
51
|
+
D > 0 && /* @__PURE__ */ i("li", { children: t("All associated language pages") })
|
|
52
|
+
] })
|
|
53
|
+
] }),
|
|
54
|
+
e.lang && /* @__PURE__ */ n("div", { className: "py-2 text-sm", children: [
|
|
55
|
+
t("Language"),
|
|
56
|
+
":",
|
|
57
|
+
" ",
|
|
58
|
+
/* @__PURE__ */ i("span", { className: "font-medium text-gray-500", children: Q(M, e.lang, e.lang) })
|
|
59
|
+
] })
|
|
60
|
+
] })
|
|
61
|
+
] }),
|
|
62
|
+
/* @__PURE__ */ n(G, { children: [
|
|
63
|
+
/* @__PURE__ */ i(v, { variant: "outline", onClick: r, children: t("Cancel") }),
|
|
64
|
+
/* @__PURE__ */ i(v, { variant: "destructive", disabled: h, onClick: C, children: t(h ? "Deleting..." : "Delete") })
|
|
65
|
+
] })
|
|
66
|
+
] }) });
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
X as default
|
|
70
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),r=require("./index-CnSjWE1P.cjs"),p=require("@radix-ui/react-icons"),L=require("lodash-es"),d=require("react"),w=require("react-i18next"),x=({title:n,items:l,emptyLabel:o,onSelect:t,icon:i})=>s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n}),l.length>0?s.jsx("div",{className:"space-y-1",children:l.map(a=>s.jsx("button",{type:"button",onClick:()=>t(a.id),className:r.cn("group flex w-full items-center justify-between rounded-md border border-transparent bg-muted/40 px-3 py-1 text-left text-xs transition","hover:border-muted-foreground/20 hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1",a.isSelected&&"border-primary/40 bg-primary/10 text-primary"),children:s.jsxs("span",{className:"flex items-center space-x-2",children:[i&&i,s.jsx("span",{className:"truncate",children:a.label})]})},a.id))}):s.jsx("div",{className:"rounded border border-dashed border-muted px-3 py-1 text-xs text-muted-foreground",children:o})]}),M="#styles:",_=n=>{const o=[typeof n._name=="string"?n._name:void 0,typeof n._type=="string"?n._type:void 0].filter(Boolean).find(t=>t.trim().length>0);return o?o.length>40?`${o.slice(0,37)}...`:o:n._id},q=(n,l)=>{const o=`${l}`;return n.filter(t=>Object.values(t).some(i=>typeof i!="string"||!i.startsWith(M)?!1:i.includes(o))).map(t=>({id:t._id,label:_(t)}))},C=({tokenId:n,tokenName:l,children:o})=>{const{t}=w.useTranslation(),[i]=r.useBlocksStore(),[a,b]=r.useSelectedBlockIds(),g=r.useBuilderProp("pageId"),m=r.useBuilderProp("siteWideUsage"),h=d.useMemo(()=>q(i,n),[i,n]),P=d.useMemo(()=>h.map(e=>({id:e.id,label:e.label,isSelected:a.includes(e.id)})),[h,a]),u=d.useMemo(()=>m?Object.entries(m).reduce((e,[f,c])=>(f===g||!(c!=null&&c.designTokens)||!Object.keys(c.designTokens).some(j=>typeof j!="string"?!1:j===n)||e.push({id:f,name:c.name||f,isPartial:!!c.isPartial}),e),[]):[],[m,l,n,g]),S=d.useMemo(()=>u.filter(e=>!e.isPartial).map(e=>({id:e.id,label:e.name})),[u]),k=d.useMemo(()=>u.filter(e=>e.isPartial).map(e=>({id:e.id,label:e.name})),[u]),v=d.useCallback(e=>{b([e])},[b]),B=r.useBuilderProp("gotoPage",L.noop),{selectedLang:N,fallbackLang:T}=r.useLanguages(),{savePageAsync:I}=r.useSavePage(),y=async e=>{e&&(await I(!0),B({pageId:e,lang:N||T}))};return s.jsxs(r.Popover,{children:[s.jsx(r.PopoverTrigger,{asChild:!0,children:o}),s.jsxs(r.PopoverContent,{side:"bottom",align:"end",className:"w-80 p-0",children:[s.jsxs("div",{className:"space-y-1 px-4 py-3",children:[s.jsx("p",{className:"text-xs font-semibold",children:l}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:t("Usage summary for this design token across your site.")})]}),s.jsxs("div",{className:"no-scrollbar max-h-64 space-y-4 overflow-y-auto px-4 pb-4",children:[s.jsx(x,{title:t("Blocks affected on this page"),items:P,emptyLabel:t("None"),onSelect:v,icon:s.jsx(p.ArrowRightIcon,{fontSize:4})}),s.jsx(x,{title:t("Blocks affected on other pages"),items:S,emptyLabel:t("None"),onSelect:y,icon:s.jsx(p.FileIcon,{fontSize:8})}),s.jsx(x,{title:t("Blocks affected on partial blocks"),items:k,emptyLabel:t("None"),onSelect:y,icon:s.jsx(p.GlobeIcon,{fontSize:8})})]})]})]})};exports.default=C;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsxs as c, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { ag as _, ah as j, a as C, ai as p, n as I, V as O, a9 as z, aa as W, P as A } from "./index-S8ibZk9Q.js";
|
|
3
|
+
import { ArrowRightIcon as E, FileIcon as F, GlobeIcon as M } from "@radix-ui/react-icons";
|
|
4
|
+
import { noop as R } from "lodash-es";
|
|
5
|
+
import { useMemo as d, useCallback as $ } from "react";
|
|
6
|
+
import { useTranslation as D } from "react-i18next";
|
|
7
|
+
const b = ({ title: s, items: a, emptyLabel: r, onSelect: t, icon: o }) => /* @__PURE__ */ c("div", { className: "space-y-2", children: [
|
|
8
|
+
/* @__PURE__ */ n("p", { className: "text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: s }),
|
|
9
|
+
a.length > 0 ? /* @__PURE__ */ n("div", { className: "space-y-1", children: a.map((i) => /* @__PURE__ */ n(
|
|
10
|
+
"button",
|
|
11
|
+
{
|
|
12
|
+
type: "button",
|
|
13
|
+
onClick: () => t(i.id),
|
|
14
|
+
className: _(
|
|
15
|
+
"group flex w-full items-center justify-between rounded-md border border-transparent bg-muted/40 px-3 py-1 text-left text-xs transition",
|
|
16
|
+
"hover:border-muted-foreground/20 hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1",
|
|
17
|
+
i.isSelected && "border-primary/40 bg-primary/10 text-primary"
|
|
18
|
+
),
|
|
19
|
+
children: /* @__PURE__ */ c("span", { className: "flex items-center space-x-2", children: [
|
|
20
|
+
o && o,
|
|
21
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: i.label })
|
|
22
|
+
] })
|
|
23
|
+
},
|
|
24
|
+
i.id
|
|
25
|
+
)) }) : /* @__PURE__ */ n("div", { className: "rounded border border-dashed border-muted px-3 py-1 text-xs text-muted-foreground", children: r })
|
|
26
|
+
] }), G = "#styles:", V = (s) => {
|
|
27
|
+
const r = [
|
|
28
|
+
typeof s._name == "string" ? s._name : void 0,
|
|
29
|
+
typeof s._type == "string" ? s._type : void 0
|
|
30
|
+
].filter(Boolean).find((t) => t.trim().length > 0);
|
|
31
|
+
return r ? r.length > 40 ? `${r.slice(0, 37)}...` : r : s._id;
|
|
32
|
+
}, X = (s, a) => {
|
|
33
|
+
const r = `${a}`;
|
|
34
|
+
return s.filter((t) => Object.values(t).some((o) => typeof o != "string" || !o.startsWith(G) ? !1 : o.includes(r))).map((t) => ({
|
|
35
|
+
id: t._id,
|
|
36
|
+
label: V(t)
|
|
37
|
+
}));
|
|
38
|
+
}, K = ({ tokenId: s, tokenName: a, children: r }) => {
|
|
39
|
+
const { t } = D(), [o] = j(), [i, g] = C(), h = p("pageId"), u = p("siteWideUsage"), y = d(() => X(o, s), [o, s]), k = d(
|
|
40
|
+
() => y.map((e) => ({
|
|
41
|
+
id: e.id,
|
|
42
|
+
label: e.label,
|
|
43
|
+
isSelected: i.includes(e.id)
|
|
44
|
+
})),
|
|
45
|
+
[y, i]
|
|
46
|
+
), m = d(() => u ? Object.entries(u).reduce(
|
|
47
|
+
(e, [f, l]) => (f === h || !(l != null && l.designTokens) || !Object.keys(l.designTokens).some((P) => typeof P != "string" ? !1 : P === s) || e.push({ id: f, name: l.name || f, isPartial: !!l.isPartial }), e),
|
|
48
|
+
[]
|
|
49
|
+
) : [], [u, a, s, h]), v = d(
|
|
50
|
+
() => m.filter((e) => !e.isPartial).map((e) => ({
|
|
51
|
+
id: e.id,
|
|
52
|
+
label: e.name
|
|
53
|
+
})),
|
|
54
|
+
[m]
|
|
55
|
+
), S = d(
|
|
56
|
+
() => m.filter((e) => e.isPartial).map((e) => ({
|
|
57
|
+
id: e.id,
|
|
58
|
+
label: e.name
|
|
59
|
+
})),
|
|
60
|
+
[m]
|
|
61
|
+
), N = $(
|
|
62
|
+
(e) => {
|
|
63
|
+
g([e]);
|
|
64
|
+
},
|
|
65
|
+
[g]
|
|
66
|
+
), B = p("gotoPage", R), { selectedLang: T, fallbackLang: L } = I(), { savePageAsync: w } = O(), x = async (e) => {
|
|
67
|
+
e && (await w(!0), B({ pageId: e, lang: T || L }));
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ c(z, { children: [
|
|
70
|
+
/* @__PURE__ */ n(W, { asChild: !0, children: r }),
|
|
71
|
+
/* @__PURE__ */ c(A, { side: "bottom", align: "end", className: "w-80 p-0", children: [
|
|
72
|
+
/* @__PURE__ */ c("div", { className: "space-y-1 px-4 py-3", children: [
|
|
73
|
+
/* @__PURE__ */ n("p", { className: "text-xs font-semibold", children: a }),
|
|
74
|
+
/* @__PURE__ */ n("p", { className: "text-[11px] text-muted-foreground", children: t("Usage summary for this design token across your site.") })
|
|
75
|
+
] }),
|
|
76
|
+
/* @__PURE__ */ c("div", { className: "no-scrollbar max-h-64 space-y-4 overflow-y-auto px-4 pb-4", children: [
|
|
77
|
+
/* @__PURE__ */ n(
|
|
78
|
+
b,
|
|
79
|
+
{
|
|
80
|
+
title: t("Blocks affected on this page"),
|
|
81
|
+
items: k,
|
|
82
|
+
emptyLabel: t("None"),
|
|
83
|
+
onSelect: N,
|
|
84
|
+
icon: /* @__PURE__ */ n(E, { fontSize: 4 })
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ n(
|
|
88
|
+
b,
|
|
89
|
+
{
|
|
90
|
+
title: t("Blocks affected on other pages"),
|
|
91
|
+
items: v,
|
|
92
|
+
emptyLabel: t("None"),
|
|
93
|
+
onSelect: x,
|
|
94
|
+
icon: /* @__PURE__ */ n(F, { fontSize: 8 })
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
/* @__PURE__ */ n(
|
|
98
|
+
b,
|
|
99
|
+
{
|
|
100
|
+
title: t("Blocks affected on partial blocks"),
|
|
101
|
+
items: S,
|
|
102
|
+
emptyLabel: t("None"),
|
|
103
|
+
onSelect: x,
|
|
104
|
+
icon: /* @__PURE__ */ n(M, { fontSize: 8 })
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
] })
|
|
108
|
+
] })
|
|
109
|
+
] });
|
|
110
|
+
};
|
|
111
|
+
export {
|
|
112
|
+
K as default
|
|
113
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-CnSjWE1P.cjs"),Y=require("./image-compression-DZ9WMmyn.cjs"),F=require("lodash-es"),f=require("lucide-react"),u=require("react"),pe=require("react-dropzone"),ge=require("react-error-boundary"),G=require("react-i18next"),w=require("sonner"),z=require("@tanstack/react-query"),g=require("./index-CbwxUFy_.cjs"),ee=require("./common-functions-B3a4xKt_.cjs"),je=()=>{const n=g.useApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>{const o=i.map(async l=>x(n,{action:g.ACTIONS.UPLOAD_ASSET,data:l}));return await Promise.all(o)},onSuccess:i=>{var o;if(i!=null&&i.some(s=>s.error))throw new Error(((o=i==null?void 0:i.find(s=>s.error))==null?void 0:o.error)||"Failed to upload asset");{r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]});const s=i==null?void 0:i.length;w.toast.success(`${s===1?"Asset":s+" Assets"} uploaded successfully`)}},onError:()=>{w.toast.error("Failed to upload asset")}})},ve=()=>{const n=g.useApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.DELETE_ASSET,data:{id:i}}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),w.toast.success("Asset deleted successfully")},onError:()=>{w.toast.error("Failed to delete asset")}})},ye=()=>{const n=g.useApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.UPDATE_ASSET,data:i}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),i!=null&&i.id&&r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSET,i.id]}),w.toast.success("Asset updated successfully")},onError:()=>{w.toast.error("Failed to update asset")}})};function Ne({currentPage:n,totalPages:r,onPageChange:x,pageRangeDisplayed:i=3,showPageInput:o=!0,className:s=""}){const[l,E]=u.useState(String(n)),N=u.useMemo(()=>{const c=Math.floor(i/2);let m=Math.max(1,n-c),d=Math.min(r,n+c);d-m+1<i&&(m===1?d=Math.min(r,m+i-1):d===r&&(m=Math.max(1,d-i+1)));const p=[];m>1&&(p.push(1),m>2&&p.push("..."));for(let y=m;y<=d;y++)p.push(y);return d<r&&(d<r-1&&p.push("..."),p.push(r)),p},[n,r,i]),v=c=>{c!==n&&c>=1&&c<=r&&(x(c),E(String(c)))},j=()=>{n>1&&v(n-1)},b=()=>{n<r&&v(n+1)},C=()=>{const c=Number(l);!isNaN(c)&&c>=1&&c<=r&&v(c)},A=c=>{c.key==="Enter"&&C()};return r<=1?null:e.jsxs("div",{className:`flex flex-wrap items-center justify-center gap-3 ${s}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:j,disabled:n===1,className:"px-2 py-1 text-sm hover:bg-gray-50",children:[e.jsx(f.ChevronLeft,{className:"h-4 w-4"}),"Previous"]}),e.jsx("div",{className:"flex items-center gap-2",children:N.map((c,m)=>{if(c==="...")return e.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${m}`);const d=c,p=d===n;return e.jsx(a.Button,{variant:p?"default":"outline",size:"sm",onClick:()=>v(d),className:p?"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",children:d},d)})}),e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:b,disabled:n===r,className:"px-2 py-1 text-sm hover:bg-gray-50",children:["Next",e.jsx(f.ChevronRight,{className:"h-4 w-4"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Go to"}),e.jsx(a.Input,{type:"number",min:1,max:r,value:l,onChange:c=>{const m=c.target.value.replace(/[^\d]/g,"");E(m)},onKeyDown:A,className:"h-8 w-16 px-2 py-1"}),e.jsx(a.Button,{variant:"outline",size:"sm",onClick:C,disabled:l===""||Number(l)<1||Number(l)>r,children:"Go"})]})]})}const be=(n={})=>{const r=g.useApiUrl(),x=g.useFetch(),{search:i,page:o=1,limit:s=30}=n;return z.useQuery({queryKey:[g.ACTIONS.GET_ASSETS,i,o,s],queryFn:async()=>{const l=await x(r,{action:g.ACTIONS.GET_ASSETS,data:{search:i,page:o,limit:s}});return l.page=o,l.limit=s,l},staleTime:1/0,retry:1})},we=n=>{const r=g.useApiUrl(),x=g.useFetch();return z.useQuery({queryKey:[g.ACTIONS.GET_ASSET,n],queryFn:async()=>n?await x(r,{action:g.ACTIONS.GET_ASSET,data:{id:n}}):null,staleTime:1/0,retry:1})};function Ce(n){const r=isNaN(n)?0:typeof n=="number"?n:parseInt(n);return r?r<1024?`${r.toFixed(2)} B`:r<1024*1024?`${(r/1024).toFixed(2)} KB`:`${(r/(1024*1024)).toFixed(2)} MB`:"0 B"}function Z(n){if(!n)return"N/A";const r=new Date(n);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function J(n,r){let x=n,i=r==null?void 0:r.description;return(!i||typeof i!="string")&&(i=""),(!x||typeof x!="string")&&(x=""),x!==i}const Ae=({assetId:n,onBack:r,onEdit:x,onSave:i,isSaving:o})=>{var c,m;const{t:s}=G.useTranslation(),{data:l,isLoading:E,isError:N}=we(n||""),[v,j]=u.useState(""),[b,C]=u.useState(!1);u.useEffect(()=>{const d=new Image;return d.src=(l==null?void 0:l.url)||"",d.onload=()=>C(!0),()=>{d.onload=null}},[l]);const A=async(d,p)=>{try{await navigator.clipboard.writeText(d),w.toast.success(s("{{type}} copied to clipboard",{type:p}))}catch(y){w.toast.error(s("Failed to copy {{type}}",{type:p}),{description:y==null?void 0:y.message})}};return u.useEffect(()=>{l!=null&&l.description&&j(l.description)},[l]),E||!b?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}):N||!(l!=null&&l.id)?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"mx-auto max-w-md p-6 text-center",children:[e.jsx("div",{className:"mb-4 flex justify-center",children:e.jsx(f.AlertCircle,{className:"h-12 w-12 text-gray-400"})}),e.jsx("h3",{className:"mb-2 text-lg font-medium text-gray-900",children:s("No Asset Found")}),e.jsx("p",{className:"mb-6 text-sm text-gray-500",children:s(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.")}),e.jsxs("div",{className:"flex justify-center gap-4",children:[e.jsx(a.Button,{variant:"outline",onClick:r,children:s("Back to Assets")}),N&&e.jsx(a.Button,{variant:"default",onClick:()=>window.location.reload(),children:s("Try Again")})]})]})}):e.jsxs("div",{className:"flex flex-1 flex-col gap-y-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:r,disabled:o,children:[e.jsx(f.ChevronLeft,{className:"h-4 w-4"}),s("Back to Assets")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a.Button,{variant:"outline",onClick:r,disabled:o,children:s("Cancel")}),e.jsxs(a.Button,{variant:"outline",onClick:()=>A(l.url,s("Asset URL")),disabled:o,children:[e.jsx(f.Copy,{className:"mr-2 h-4 w-4"}),s("Copy URL")]}),e.jsxs(a.Button,{variant:"default",onClick:()=>x(l),disabled:o,children:[e.jsx(f.Pencil,{className:"h-4 w-4"}),s("Edit Image")]})]})]}),e.jsxs("div",{className:"grid flex-1 grid-cols-2 items-start gap-6 overflow-hidden",children:[e.jsx("div",{className:"relative flex h-[calc(80vh-200px)] w-full items-start justify-center",children:e.jsx("img",{src:l.url,alt:l.name,className:"h-full max-h-max w-full max-w-max rounded-lg object-contain"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-3 rounded-md border bg-gray-100 pt-2",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Details")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 rounded-md border bg-white p-2 text-sm",children:[{label:s("File Name"),value:l.name},{label:s("Type"),value:l.type,capitalize:!0},{label:s("Format"),value:((c=l.metadata)==null?void 0:c.format)||l.type,capitalize:!0},{label:s("Size"),value:Ce(l.size)},{label:s("Dimensions"),value:`${l.width||0} × ${l.height||0}`},{label:s("Created"),value:Z(l.createdAt)},{label:s("Updated"),value:Z(((m=l.metadata)==null?void 0:m.updatedAt)||(l==null?void 0:l.updatedAt)||l.createdAt)},{label:s("URL"),value:l.url,copyable:!0}].map(d=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Label,{className:"w-1/4 w-max px-2 text-left font-normal text-gray-700",children:d.label}),":",e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+(d.capitalize?" capitalize":""),children:d.value}),d.copyable&&e.jsx(a.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A(d.value,d.label),children:e.jsx(f.Link,{className:"h-3 w-3"})})]})]},d.label))})]}),l.usedOn&&l.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(a.Label,{children:s("Used On")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 rounded-md border p-2 text-sm",children:l.usedOn.map((d,p)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900",children:d.name}),e.jsxs("div",{className:"text-gray-500",children:["(",d.slug,")"]})]},p))})]}),e.jsxs("div",{className:"relative grid gap-3 rounded-md border bg-gray-100 pt-2",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Description")}),e.jsx(a.Textarea,{id:"description",value:v,placeholder:s("Enter a description for the asset"),onChange:d=>j(d.target.value),rows:3,disabled:o,className:"bg-white hover:border-black/40"}),e.jsx("div",{className:"absolute right-2 top-1.5 flex items-start justify-end",children:e.jsx("button",{type:"button",onClick:()=>i(v),disabled:o||!J(v,l),className:`rounded-md bg-blue-500 px-3 py-0 py-0.5 text-sm text-white ${o||!J(v,l)?"cursor-not-allowed opacity-50":""}`,children:o?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"mr-2 h-4 w-4 animate-spin"}),s("Saving...")]}):s("Save")})})]})]})]})]})},Se=u.lazy(()=>Promise.resolve().then(()=>require("./image-editor-DTspjj_c.cjs"))),Te=25*1024*1024,Ee=({isUpdatingAsset:n,allowedTypes:r,uploadAssets:x,isUploadingAsset:i,onUploaded:o})=>{const{t:s}=G.useTranslation(),[l,E]=u.useState(()=>{const c=localStorage.getItem("chai_optimize_images");return c!==null?c==="true":!0});u.useEffect(()=>{localStorage.setItem("chai_optimize_images",l.toString())},[l]);const N=n||i,v=u.useCallback(async c=>{try{const m=c;if(!m.every(S=>S.type.startsWith("image/")))return w.toast.error(s("Invalid file type. Please upload a valid file.")),Promise.reject(new Error("Invalid file type"));const d=m.map(async S=>{let U=S;return S.type.startsWith("image/")&&(U=await Y.compressImageIfNeeded(S)),new Promise(($,B)=>{const q=new FileReader;q.readAsDataURL(U),q.onload=async()=>{$({file:q.result,folderId:void 0,name:S.name,optimize:l})},q.onerror=()=>B(null)})}),p=await Promise.all(d),y=await x(p);return(y==null?void 0:y.length)===1&&o(y[0]),y}catch(m){return Promise.reject(m)}},[x,l,o,s]),j=c=>{const m=[];let d=0;return c.forEach(p=>{p.size>Te?d++:m.push(p)}),d>0&&w.toast.error(`${d===1&&c.length===1?s("File"):d+s(d===1?" file":" files")} ${s("exceed the maximum size limit of 10MB.")}`),F.isEmpty(m)?[]:v(m)},{getRootProps:b,getInputProps:C,isDragActive:A}=pe.useDropzone({onDrop:j,accept:{"image/*":r.includes("image")?[]:[]},disabled:n||i,multiple:!0});return e.jsx("div",{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"}`,children:e.jsxs("div",{...b(),className:ee.cn("flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",N?"items-start":"items-center",A?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...C()}),N?e.jsx("div",{className:"flex flex-col items-center px-6",children:e.jsxs("div",{className:"flex items-center justify-center gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full bg-indigo-100 p-2",children:e.jsx(f.Loader,{className:"h-4 w-4 animate-spin text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:s(n?"Updating file...":"Uploading file...")}),e.jsxs("div",{className:"text-xs font-light text-muted-foreground",children:[s("Please wait while we")," ",s(n?"update":"upload")," ",s("your file...")]})]})]})}):e.jsxs("div",{className:"flex w-full items-center justify-between px-6",children:[e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"flex items-center justify-between gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full border border-indigo-500 bg-indigo-100 p-2",children:e.jsx(f.Upload,{className:"h-4 w-4 text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"font-medium",children:[s("Drop your file here or")," ",e.jsx("span",{className:"cursor-pointer text-indigo-500 hover:underline",children:s("browse")})]}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:e.jsxs("span",{className:"",children:[s("Accepted file types:")," ",e.jsx("span",{className:"capitalize text-indigo-400",children:r.join(", ")})]})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs",children:[s("Optimization:")," ",e.jsx("span",{className:l?"text-indigo-600":"text-gray-400",children:s(l?"On":"Off")})]}),e.jsx(a.Switch,{checked:l,onCheckedChange:c=>{E(c)},onClick:c=>{c.stopPropagation()},className:"data-[state=checked]:bg-indigo-500"})]}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:`flex cursor-help items-center text-amber-500 ${l?"invisible":""}`,children:e.jsx(f.AlertTriangle,{className:"mr-1 h-4 w-4"})})}),e.jsx(a.TooltipContent,{side:"top",children:e.jsx("p",{className:"text-xs text-white",children:s("Warning: Unoptimized images may affect performance and page load times")})})]})})]})]})]})})};function Ie({close:n,onSelect:r,mode:x="image",assetId:i}){const{t:o}=G.useTranslation(),s=!1,l=10,E=u.useMemo(()=>[x],[x]),[N,v]=u.useState(null),[j,b]=u.useState(null),[C,A]=u.useState(null),[c,m]=u.useState({show:!1,file:""}),[d,p]=u.useState(!1),[y,S]=u.useState(i?"details":"grid"),[U,$]=u.useState(""),[B,q]=u.useState(""),[M,_]=u.useState(1),[R]=u.useState(30),[T,Q]=u.useState([]);u.useEffect(()=>{i&&(v(i),S("details"))},[i]),u.useEffect(()=>{const t=setTimeout(()=>{$(B),_(1)},300);return()=>clearTimeout(t)},[B]);const{data:L,isLoading:P,refetch:te}=be({search:U.toLowerCase().trim(),page:M,limit:R}),D=(L==null?void 0:L.assets)||[],se=(L==null?void 0:L.total)||0,I=Math.ceil(se/R);u.useEffect(()=>{P||I<=0||_(t=>t>I?I:t<1?1:t)},[P,I]);const ie=(D==null?void 0:D.length)>0,{mutate:le}=ve(),{mutateAsync:K,isPending:ae}=je(),{mutateAsync:W,isPending:re}=ye(),V=u.useCallback(t=>{const h=Math.min(Math.max(1,t),Math.max(1,I));h!==M&&_(h)},[I,M]),ne=t=>{q(t.target.value)},oe=u.useCallback(t=>{Q(h=>F.find(h,{id:t.id})?[]:[t])},[s]),ce=u.useCallback(()=>{Q([])},[]),H=t=>{(t==null?void 0:t.length)!==0&&(r(F.pick(F.first(t||T),["id","url","width","height","description"])),n())},de=async t=>{b(t)},ue=async()=>{j&&(A(j==null?void 0:j.id),await le(j.id,{onSuccess:()=>{A(null),b(null)},onError:()=>{A(null)}}),b(null))},me=t=>{v(t.id),S("details")},he=async(t,h)=>{try{const O=localStorage.getItem("chai_optimize_images")!=="false";if(h){const k=await K([{file:t,folderId:void 0,name:c.name||"",optimize:O}]);if((k==null?void 0:k.length)>0){const X=k[0];r({...F.pick(X,["id","width","height","description"]),url:X.url})}}else{const k=await W({id:c.id||"",file:t});k&&r({...F.pick(k,["id","width","height","description"]),url:k.url})}m({show:!1,file:""}),n()}catch(O){console.error(o("Error saving edited image:"),O)}},xe=u.useCallback(t=>{Q([t])},[]),fe=u.useCallback(t=>{V(t)},[V]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4",children:[e.jsx("h1",{className:"text-lg font-medium",children:o("Digital Asset Manager")}),y==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{maxFileSize:l,allowedTypes:E,uploadAssets:K,isUpdatingAsset:re,isUploadingAsset:ae,onUploaded:xe}),e.jsxs("div",{className:"relative flex flex-1 flex-col gap-y-3 overflow-hidden rounded-lg border p-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"relative w-1/2",children:[e.jsx(f.Search,{strokeWidth:3,className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${B.length>0?"text-indigo-800":""}`}),e.jsx(a.Input,{placeholder:o("Search assets..."),onChange:ne,value:B,className:"pl-8"})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[T.length>0?e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&e.jsx(e.Fragment,{children:e.jsx(a.Button,{variant:"outline",size:"sm",onClick:()=>ce(),title:o("Clear selection"),children:o("Clear")})}),e.jsx(a.Button,{size:"sm",onClick:()=>H(T),disabled:T.length===0,children:o("Select Asset")})]})}):null,e.jsx(a.Button,{variant:"ghost",size:"icon",onClick:()=>te(),children:e.jsx(f.RefreshCwIcon,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-[66px]",children:P?e.jsxs("div",{className:"columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5",children:[e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"})]}):!P&&!ie?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center rounded-lg border",children:[e.jsx("div",{className:"text-muted-foreground",children:e.jsx(f.Archive,{className:"h-9 w-9 text-indigo-500"})}),e.jsx("div",{className:"text-lg text-muted-foreground",children:o("No assets found")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.length>0?o("No assets found for your search: {{query}}",{query:U}):o("Start uploading assets to get started")}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:D==null?void 0:D.map(t=>e.jsxs("div",{className:ee.cn("group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",T.some(h=>h.id===t.id)?"border-blue-500":"hover:border-black/90",C&&(j==null?void 0:j.id)===t.id?"pointer-events-none opacity-50":"",C===t.id?"pointer-events-none opacity-50":""),onClick:()=>oe(t),onDoubleClick:()=>H([t]),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[C===t.id?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin text-white"})}):null,t.type==="image"?e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:`h-full min-h-[80px] w-full object-contain ${T.some(h=>h.id===t.id)?"":"group-hover:blur group-hover:contrast-50"}`}):e.jsxs("div",{className:"flex h-full items-center justify-center",children:[e.jsx(f.Film,{className:"h-12 w-12 text-muted-foreground"}),t.thumbnailUrl&&e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:"absolute inset-0 h-full w-full object-cover"})]})]}),e.jsxs("div",{className:"flex items-end justify-between border-t-[1px] border-black/10 bg-white px-2 py-1",children:[e.jsx("div",{className:"truncate text-xs leading-tight",title:t.name,children:t.name}),e.jsx("div",{className:"flex items-center justify-between whitespace-nowrap text-[9px] font-light text-muted-foreground",children:e.jsx("span",{children:Y.formatFileSize((t==null?void 0:t.size)||0)})})]}),!T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",children:e.jsxs("div",{className:"grid grid-cols-4 gap-2 p-2",children:[e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),me(t)},children:e.jsx(f.ImageIcon,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("View Details")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),navigator.clipboard.writeText(t.url),w.toast.success(o("Asset URL copied to clipboard"))},children:e.jsx(f.Copy,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Copy URL")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),m({id:t.id,show:!0,file:t.url,name:t.name})},children:e.jsx(f.Edit,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Edit Image")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),de(t)},children:e.jsx(f.Trash2,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Delete Asset")})})]})})]})}),T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute right-1 top-1 h-max rounded-full border border-white bg-blue-500 p-1",children:e.jsx(f.Check,{className:"h-3 w-3 text-white",strokeWidth:5})})]},t.id))})}),I>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t bg-white p-4",children:e.jsx(ge.ErrorBoundary,{fallback:e.jsx("div",{className:"text-red-500",children:o("Error loading pagination")}),children:e.jsx(Ne,{currentPage:M,totalPages:I,onPageChange:fe,pageRangeDisplayed:3,showPageInput:!0})})})]})]}):e.jsx(Ae,{assetId:N||i||"",onBack:()=>{S("grid"),v(null)},onEdit:t=>{m({id:t.id,show:!0,file:t.url,name:t.name})},onSave:async t=>{if(N){p(!0);try{const h=D.find(O=>O.id===N);h&&await W(F.merge(h,{description:t}))}finally{p(!1)}}},isSaving:d})]}),c.show&&e.jsx(u.Suspense,{fallback:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}),children:e.jsx(Se,{imageUrl:c.file,onSave:he,onClose:()=>m({show:!1,file:""}),defaultSavedImageName:c.name,isEditing:!!c.id})}),j&&e.jsx(a.Dialog,{open:!!j,onOpenChange:()=>b(null),children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:o("Delete Asset")}),e.jsx(a.DialogDescription,{children:o('Are you sure you want to delete "{{name}}"? This action cannot be undone.',{name:j.name})})]}),e.jsxs(a.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(a.Button,{variant:"outline",onClick:()=>b(null),children:o("Cancel")}),e.jsx(a.Button,{variant:"destructive",onClick:ue,children:o("Delete")})]})]})})]})}exports.default=Ie;
|