@chaibuilder/sdk 4.0.0-beta.44 → 4.0.0-beta.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{2SSKDMRQ-BrCeJE2w.js → 2SSKDMRQ-B6pWs8Zk.js} +2 -2
- package/dist/{2SSKDMRQ-BKWkM_6d.cjs → 2SSKDMRQ-B7Va8HeK.cjs} +1 -1
- package/dist/{AP7HFJJL-CskLuLc8.js → AP7HFJJL-CNIRZpP-.js} +1 -1
- package/dist/{AP7HFJJL-vt0XlZqG.cjs → AP7HFJJL-Xv13XYXE.cjs} +1 -1
- package/dist/{IconPicker-BJ6a_dl-.js → IconPicker-CGtjTiWr.js} +1 -1
- package/dist/{WDYDFRGG-BN61b01J.js → WDYDFRGG-5Lwxhw_-.js} +2 -2
- package/dist/{WDYDFRGG-Nw-WmjVB.cjs → WDYDFRGG-zZ8jN8rF.cjs} +1 -1
- package/dist/{actions-registery-CMKfEXxX.js → actions-registery-B1VeX52Y.js} +1565 -1529
- package/dist/{actions-registery-CqhNZFV3.cjs → actions-registery-BQ31lpix.cjs} +19 -19
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.ts +132 -0
- package/dist/actions.js +7 -6
- package/dist/{active-in-another-tab-DHTYNRjQ.cjs → active-in-another-tab-C8FXtXk5.cjs} +1 -1
- package/dist/{active-in-another-tab-CZHN4gdI.js → active-in-another-tab-HtM97aRN.js} +4 -4
- package/dist/{add-new-language-page-DUm56cDk.cjs → add-new-language-page-gbvPI58M.cjs} +1 -1
- package/dist/{add-new-language-page-J0FxQGri.js → add-new-language-page-x88_n8EW.js} +3 -3
- package/dist/{add-new-page-B4dH-sG6.js → add-new-page-BMSePgKl.js} +2 -2
- package/dist/{add-new-page-D0H-HGrE.cjs → add-new-page-CPB4yhqv.cjs} +1 -1
- package/dist/{ai-panel-default-lang-BHzxr8XE.cjs → ai-panel-default-lang-DKGh1pbz.cjs} +2 -2
- package/dist/{ai-panel-default-lang-DrKTSHgh.js → ai-panel-default-lang-Dav6FRUY.js} +10 -10
- package/dist/{ai-panel-other-lang-CMs97ftp.js → ai-panel-other-lang-CdFx2x23.js} +14 -14
- package/dist/{ai-panel-other-lang-B6cRPiU9.cjs → ai-panel-other-lang-DdDn2I8h.cjs} +1 -1
- package/dist/ai-prompt-input-B8SFfk6N.cjs +1 -0
- package/dist/ai-prompt-input-bleYNRnH.js +650 -0
- package/dist/{ai-translation-prompt-Ddum5Ge5.cjs → ai-translation-prompt-DGrNA2Od.cjs} +1 -1
- package/dist/{ai-translation-prompt-BfJry6ZR.js → ai-translation-prompt-DvHdOZ6t.js} +1 -1
- package/dist/{change-password-modal-C4ngPnKd.js → change-password-modal-C9afEHLW.js} +4 -4
- package/dist/{change-password-modal-UTKwQzI4.cjs → change-password-modal-bce5bF3K.cjs} +1 -1
- package/dist/{code-editor-LNL_FEZ0.js → code-editor-BfGHceIq.js} +1 -1
- package/dist/{continue-editing-in-this-client-rjJy4-cq.cjs → continue-editing-in-this-client-4bvChAL-.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-CuBlXJb6.js → continue-editing-in-this-client-BFptv8tA.js} +2 -2
- package/dist/core.js +18 -18
- package/dist/{css-import-modal-ChRsUOVa.js → css-import-modal-CEQccCmc.js} +1 -1
- package/dist/{delete-page-BegGYX7_.js → delete-page-8h4dNP7d.js} +2 -2
- package/dist/{delete-page-BaJ0oesv.cjs → delete-page-BOxoMgyl.cjs} +1 -1
- package/dist/{design-token-usage-Bgphgz_u.js → design-token-usage-CVPBTF21.js} +8 -8
- package/dist/{digital-asset-manager-BPy9RYlx.js → digital-asset-manager-83B0Y6L-.js} +3 -3
- package/dist/{digital-asset-manager-uzOuwVMR.cjs → digital-asset-manager-JtBK07Ob.cjs} +1 -1
- package/dist/{duplicate-page-n6osptll.js → duplicate-page-DIa59iDe.js} +12 -12
- package/dist/{duplicate-page-BofwxP4t.cjs → duplicate-page-DVqC24Rd.cjs} +1 -1
- package/dist/{dynamic-page-selector-6EWhAHX0.js → dynamic-page-selector-C9vYslOg.js} +12 -12
- package/dist/{dynamic-page-selector-CVI1LwdD.cjs → dynamic-page-selector-YRCRqWlz.cjs} +1 -1
- package/dist/{image-editor-D1euq0rl.js → image-editor-CzxSXo-u.js} +1 -1
- package/dist/index-DXBHjFwY.cjs +5 -0
- package/dist/{index-fxuo68Am.js → index-DlTEPwjW.js} +1344 -1289
- package/dist/{index-fThd1uce.js → index-RwAuF_BE.js} +39 -39
- package/dist/{json-diff-viewer-B2Q7bs-U.cjs → json-diff-viewer-Bpsk0toO.cjs} +1 -1
- package/dist/{json-diff-viewer-C0kg3Rss.js → json-diff-viewer-is2P3TOV.js} +6 -6
- package/dist/{lang-panel-MB00AgoJ.cjs → lang-panel-BI5OFsBY.cjs} +1 -1
- package/dist/{lang-panel-DgDlmKaN.js → lang-panel-DwiCJRs9.js} +22 -22
- package/dist/{manage-design-tokens-nTmzLQyq.js → manage-design-tokens-D2Oz-jVp.js} +2 -2
- package/dist/{manage-design-tokens-modal-ayqKkRLc.js → manage-design-tokens-modal-ZR8PuhWC.js} +2 -2
- package/dist/{mark-as-template-BARMivkY.js → mark-as-template-C0Z2P_UF.js} +2 -2
- package/dist/{mark-as-template-CProQdMy.cjs → mark-as-template-muKJE1gk.cjs} +1 -1
- package/dist/{models-D95ZYr_x.js → models-BCu-p_QK.js} +4 -4
- package/dist/{models-5gOsRC56.cjs → models-D0RH2u4C.cjs} +1 -1
- package/dist/{nested-path-selector-content-DxW18z33.js → nested-path-selector-content-Ct80kFX-.js} +1 -1
- package/dist/{no-language-page-content-CB_UK8pU.js → no-language-page-content-BekrmPc5.js} +4 -4
- package/dist/{no-language-page-content-C2Q-PlyR.cjs → no-language-page-content-zn3891M8.cjs} +1 -1
- package/dist/{no-language-page-dialog-DsZDAaRd.js → no-language-page-dialog-dHlAqLlU.js} +2 -2
- package/dist/{no-language-page-dialog-B7SNu92-.cjs → no-language-page-dialog-wEXIlBuQ.cjs} +1 -1
- package/dist/{page-creator-CulX1J10.js → page-creator-6L7ehzhL.js} +4 -4
- package/dist/page-creator-CN2phGn5.cjs +1 -0
- package/dist/{page-lock-DbH7spVl.js → page-lock-C--D8qD7.js} +2 -2
- package/dist/{page-lock-BQr6vqz-.cjs → page-lock-DllloCJE.cjs} +1 -1
- package/dist/{page-locked-dialog-BgaqVH5J.js → page-locked-dialog-BD8LHbdC.js} +15 -15
- package/dist/{page-locked-dialog-B3ZmWOt_.cjs → page-locked-dialog-DzB8p0wl.cjs} +1 -1
- package/dist/{page-manager-new-ydVnl9s6.cjs → page-manager-new-DyjhsvPx.cjs} +1 -1
- package/dist/{page-manager-new-DNBm5H5A.js → page-manager-new-uFcGaZZY.js} +29 -29
- package/dist/{page-manager-search-and-filter-jYP_ub36.js → page-manager-search-and-filter-DK883UmG.js} +26 -26
- package/dist/{page-manager-search-and-filter-BhBT7qY0.cjs → page-manager-search-and-filter-zfR5i_GU.cjs} +1 -1
- package/dist/{page-revisions-content-ZOroDtgV.cjs → page-revisions-content-Bi2ehMnj.cjs} +1 -1
- package/dist/{page-revisions-content-YGYK8pv9.js → page-revisions-content-D3rIJj9X.js} +24 -24
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +2 -0
- package/dist/pages.js +24 -23
- package/dist/{publish-pages-content-Du3LgWM2.cjs → publish-pages-content-BQUHNRCX.cjs} +1 -1
- package/dist/{publish-pages-content-BgdFWGKT.js → publish-pages-content-ByPf4lvE.js} +23 -23
- package/dist/{rte-widget-modal-B7wA8UGi.js → rte-widget-modal-Tj_pS3ql.js} +1 -1
- package/dist/{save-to-lib-hHRxVrjy.js → save-to-lib-CcUqS0s1.js} +62 -62
- package/dist/{save-to-lib-Dxisxuo9.cjs → save-to-lib-Cyeqcelv.cjs} +1 -1
- package/dist/{selected-block-display-5hDghITH.cjs → selected-block-display-Benbb_OW.cjs} +1 -1
- package/dist/{selected-block-display-BNX9ZuNH.js → selected-block-display-C6LxDm0H.js} +11 -11
- package/dist/{seo-panel-CBEV-Nds.js → seo-panel-1U9Q0Ato.js} +25 -25
- package/dist/{seo-panel-C1DEkfcC.cjs → seo-panel-CCuvQpwV.cjs} +1 -1
- package/dist/{shared-json-ld-4o0YbV25.js → shared-json-ld-DbzUITto.js} +46 -46
- package/dist/{shared-json-ld-DuXm_88W.cjs → shared-json-ld-bj77fq_b.cjs} +1 -1
- package/dist/{slug-input-DE-a4dMb.js → slug-input-P-CLfUrw.js} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.d.ts +4 -7
- package/dist/supabase-actions.js +1 -1
- package/dist/{take-over-request-WL-btbiZ.js → take-over-request-Bwj_2nPR.js} +5 -5
- package/dist/{take-over-request-DR4RC8TT.cjs → take-over-request-R3HRgShm.cjs} +1 -1
- package/dist/{translation-warning-modal-Cef9OsyI.js → translation-warning-modal-BdkToZwn.js} +1 -1
- package/dist/{unmark-as-template-Dexn_9W7.cjs → unmark-as-template-BG882c_S.cjs} +1 -1
- package/dist/{unmark-as-template-D-5cQ61Q.js → unmark-as-template-DHDMooLZ.js} +2 -2
- package/dist/{unpublish-page-C-7RnGgj.js → unpublish-page-C4e_gIX8.js} +2 -2
- package/dist/{unpublish-page-C14PYuLT.cjs → unpublish-page-DudJ1znF.cjs} +1 -1
- package/dist/{unpublished-partials-modal-O0E8HViJ.js → unpublished-partials-modal-p_0N6V23.js} +1 -1
- package/dist/{web-preview-DOJ6E273.js → web-preview-BA08d7DN.js} +1 -1
- package/dist/{web-preview-CgKfKkdH.cjs → web-preview-MG0HZxgA.cjs} +1 -1
- package/package.json +1 -1
- package/dist/ai-panel-content-BV5Hzsso.js +0 -62
- package/dist/ai-panel-content-D0ugQDEu.cjs +0 -1
- package/dist/ai-prompt-input-MPIh7805.cjs +0 -1
- package/dist/ai-prompt-input-__vuJNRC.js +0 -652
- package/dist/index-Dh-fEHei.cjs +0 -5
- package/dist/page-creator-CnyQu1Te.cjs +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s, jsxs as t, Fragment as L } from "react/jsx-runtime";
|
|
2
2
|
import { z as h, B as F } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { D as T, e as
|
|
4
|
-
import {
|
|
3
|
+
import { D as T, e as O, f as q, g as z, o as B, p as f, q as H } from "./index-RwAuF_BE.js";
|
|
4
|
+
import { ao as I, ap as M, A as E, aw as R } from "./index-DlTEPwjW.js";
|
|
5
5
|
import { useMutation as U } from "@tanstack/react-query";
|
|
6
6
|
import { Loader2 as W } from "lucide-react";
|
|
7
7
|
import { useState as c, useCallback as S, useEffect as G } from "react";
|
|
@@ -76,11 +76,11 @@ const K = () => {
|
|
|
76
76
|
}
|
|
77
77
|
);
|
|
78
78
|
};
|
|
79
|
-
return /* @__PURE__ */ s(T, { open: a, onOpenChange: l, children: /* @__PURE__ */ s(
|
|
79
|
+
return /* @__PURE__ */ s(T, { open: a, onOpenChange: l, children: /* @__PURE__ */ s(O, { className: "sm:max-w-[425px]", children: w ? /* @__PURE__ */ s("div", { className: "flex h-[340px] items-center justify-center", children: /* @__PURE__ */ s(W, { className: "h-8 w-8 animate-spin text-muted-foreground" }) }) : u ? /* @__PURE__ */ t("div", { className: "flex h-[340px] flex-col items-center justify-center gap-2", children: [
|
|
80
80
|
/* @__PURE__ */ s("div", { className: "rounded-full bg-green-100 p-3", children: /* @__PURE__ */ s("svg", { className: "h-6 w-6 text-green-600", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ s("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }) }),
|
|
81
81
|
/* @__PURE__ */ s("p", { className: "text-lg font-medium", children: e("Password updated successfully") })
|
|
82
82
|
] }) : /* @__PURE__ */ t(L, { children: [
|
|
83
|
-
/* @__PURE__ */ t(
|
|
83
|
+
/* @__PURE__ */ t(q, { children: [
|
|
84
84
|
/* @__PURE__ */ s(z, { children: e("Change Password") }),
|
|
85
85
|
/* @__PURE__ */ s(B, { children: e("Enter your current password and a new password.") })
|
|
86
86
|
] }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),l=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DrzR7vXl.cjs"),u=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),l=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DrzR7vXl.cjs"),u=require("./index-DXBHjFwY.cjs"),A=require("@tanstack/react-query"),F=require("lucide-react"),d=require("react"),k=require("react-i18next"),m=require("zod"),E=()=>{const r=u.useApiUrl(),o=u.useFetch();return A.useMutation({mutationKey:[u.ACTIONS.CHANGE_PASSWORD],mutationFn:async e=>{const t=await o(r,{action:u.ACTIONS.CHANGE_PASSWORD,data:e});return t==null?void 0:t.data}})},L=r=>m.z.object({oldPassword:m.z.string().min(1,r("Current password is required")),newPassword:m.z.string().min(8,r("Password must be at least 8 characters")).max(128,r("Password must be less than 128 characters")).regex(/[A-Z]/,r("Password must contain at least one uppercase letter")).regex(/[a-z]/,r("Password must contain at least one lowercase letter")).regex(/[0-9]/,r("Password must contain at least one number")).regex(/[!@#$%^&*(),.?":{}|<>]/,r("Password must contain at least one special character")),confirmPassword:m.z.string().min(1,r("Confirm password is required"))}).refine(o=>o.newPassword===o.confirmPassword,{message:r("New password and confirm password do not match"),path:["confirmPassword"]}).refine(o=>o.oldPassword!==o.newPassword,{message:r("New password must be different from current password"),path:["newPassword"]}),T=({open:r,onOpenChange:o})=>{const{t:e}=k.useTranslation(),t=u.usePagesProp("currentUser",null),{mutate:q,isPending:h,isSuccess:p,reset:P}=E(),[x,f]=d.useState(""),[j,C]=d.useState(""),[N,v]=d.useState(""),[b,i]=d.useState(null),S=d.useCallback(()=>{f(""),C(""),v(""),i(null),P()},[P]),w=d.useCallback(a=>{o(a),a||S()},[o,S]);d.useEffect(()=>{if(p){const a=setTimeout(()=>{w(!1)},2e3);return()=>clearTimeout(a)}},[p,w]);const D=()=>{var y;i(null);const a={oldPassword:x.trim(),newPassword:j.trim(),confirmPassword:N.trim()},c=L(e).safeParse(a);if(!c.success){i(((y=c.error.issues[0])==null?void 0:y.message)||e("Validation failed"));return}if(!(t!=null&&t.email)){i(e("User email not found"));return}q({email:t.email,oldPassword:c.data.oldPassword,newPassword:c.data.newPassword,confirmPassword:c.data.confirmPassword},{onError:g=>{i((g==null?void 0:g.message)||e("Failed to change password"))}})};return s.jsx(n.Dialog,{open:r,onOpenChange:w,children:s.jsx(n.DialogContent,{className:"sm:max-w-[425px]",children:h?s.jsx("div",{className:"flex h-[340px] items-center justify-center",children:s.jsx(F.Loader2,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):p?s.jsxs("div",{className:"flex h-[340px] flex-col items-center justify-center gap-2",children:[s.jsx("div",{className:"rounded-full bg-green-100 p-3",children:s.jsx("svg",{className:"h-6 w-6 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),s.jsx("p",{className:"text-lg font-medium",children:e("Password updated successfully")})]}):s.jsxs(s.Fragment,{children:[s.jsxs(n.DialogHeader,{children:[s.jsx(n.DialogTitle,{children:e("Change Password")}),s.jsx(n.DialogDescription,{children:e("Enter your current password and a new password.")})]}),s.jsxs("div",{className:"grid gap-4 py-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"old-password",children:e("Current Password")}),s.jsx(l.Input,{id:"old-password",type:"password",value:x,onChange:a=>f(a.target.value),placeholder:e("Enter current password")})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"new-password",children:e("New Password")}),s.jsx(l.Input,{id:"new-password",type:"password",value:j,onChange:a=>C(a.target.value),placeholder:e("Enter new password")})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(n.Label,{htmlFor:"confirm-password",children:e("Confirm Password")}),s.jsx(l.Input,{id:"confirm-password",type:"password",value:N,onChange:a=>v(a.target.value),placeholder:e("Confirm new password")})]}),b&&s.jsx("p",{className:"text-sm text-destructive",children:b})]}),s.jsxs(n.DialogFooter,{children:[s.jsx(l.Button,{variant:"outline",onClick:()=>w(!1),disabled:h,children:e("Cancel")}),s.jsx(l.Button,{onClick:D,disabled:h,children:e("Change Password")})]})]})})})};exports.ChangePasswordModal=T;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as t, jsxs as c } from "react/jsx-runtime";
|
|
2
|
-
import { u as k, a as v, b as T, c as E, d as L, L as N, D as y, e as w, f as D, g as H, T as M } from "./index-
|
|
2
|
+
import { u as k, a as v, b as T, c as E, d as L, L as N, D as y, e as w, f as D, g as H, T as M } from "./index-RwAuF_BE.js";
|
|
3
3
|
import { useThrottledCallback as P } from "@react-hookz/web";
|
|
4
4
|
import { get as B } from "lodash-es";
|
|
5
5
|
import { useState as p, useMemo as I, useCallback as S, useEffect as j } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./register-chai-top-bar-DyW9GPzV.cjs"),s=require("./index-DrzR7vXl.cjs"),a=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./register-chai-top-bar-DyW9GPzV.cjs"),s=require("./index-DrzR7vXl.cjs"),a=require("./index-DXBHjFwY.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const{setPageLockMeta:r}=a.usePageLockMeta(),{t}=l.useTranslation(),c=async()=>{r({})};return e.jsx(a.BlurContainer,{children:e.jsxs(s.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(s.CardHeader,{className:"space-y-1",children:e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(n.CheckCircle,{className:"h-6 w-6 text-green-500"}),t("You can edit the page now")]})}),e.jsx(s.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:t("This page is released by other user you can continue editing now")})}),e.jsx(s.CardFooter,{className:"flex gap-2",children:e.jsxs(i.Button,{variant:"default",onClick:c,className:"flex-1 gap-2",children:[e.jsx(n.Check,{className:"h-4 w-4"}),t("Continue Editing")]})})]})})};exports.default=o;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import { B as r } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import {
|
|
4
|
-
import { b as d, B as h } from "./index-
|
|
3
|
+
import { J as o, K as c, M as i, O as l, Q as m } from "./index-RwAuF_BE.js";
|
|
4
|
+
import { b as d, B as h } from "./index-DlTEPwjW.js";
|
|
5
5
|
import { CheckCircle as u, Check as p } from "lucide-react";
|
|
6
6
|
import { useTranslation as C } from "react-i18next";
|
|
7
7
|
const y = () => {
|
package/dist/core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b6 as s, aZ as r, b5 as i, b7 as o, a_ as t, a$ as l, b0 as C, aX as
|
|
1
|
+
import { b6 as s, aZ as r, b5 as i, b7 as o, a_ as t, a$ as l, b0 as C, aX as g, aK as h, b8 as u, b9 as d, ba as n, b1 as c, b2 as b, aL as B, b3 as k, b4 as S, aM as p, aO as m, bc as T, bb as L, ab as F, ae as A, bd as I, s as M, d as P, ac as f, I as E, r as H, t as x } from "./index-RwAuF_BE.js";
|
|
2
2
|
import { g as v, c as D } from "./common-functions-D2lMFR6K.js";
|
|
3
|
-
import { g as
|
|
4
|
-
import { A as N, C as w, I as K, R as
|
|
3
|
+
import { g as _, g as O } from "./apply-binding-vAuN-TGV.js";
|
|
4
|
+
import { A as N, C as w, I as K, R as X, k as j, o as q, c as z, a as J, b as V, r as W, e as Z, f as $, j as G, m as Q, p as Y, q as aa, v as ea, x as sa, t as ra, d as ia, u as oa, h as ta, g as la, l as Ca, w as ga, n as ha, s as ua, i as da, y as na } from "./register-chai-top-bar-D6GjnauV.js";
|
|
5
5
|
import { useTranslation as ba } from "react-i18next";
|
|
6
6
|
import { default as ka } from "i18next";
|
|
7
7
|
export {
|
|
@@ -14,8 +14,8 @@ export {
|
|
|
14
14
|
t as ChaiBlockPropsEditor,
|
|
15
15
|
l as ChaiBlockStyleEditor,
|
|
16
16
|
C as ChaiBuilderCanvas,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
g as ChaiBuilderEditor,
|
|
18
|
+
h as ChaiDarkModeSwitcher,
|
|
19
19
|
u as ChaiDefaultBlocks,
|
|
20
20
|
d as ChaiDraggableBlock,
|
|
21
21
|
n as ChaiExportCodeModal,
|
|
@@ -27,20 +27,20 @@ export {
|
|
|
27
27
|
p as ChaiUndoRedo,
|
|
28
28
|
K as IfChaiFeatureFlag,
|
|
29
29
|
m as PERMISSIONS,
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
X as RJSF_EXTENSIONS,
|
|
31
|
+
_ as convertHTMLToChaiBlocks,
|
|
32
32
|
T as defaultChaiLibrary,
|
|
33
33
|
v as generateBlockId,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
O as getBlocksFromHTML,
|
|
35
|
+
j as getChaiLibrary,
|
|
36
36
|
L as getClassValueAndUnit,
|
|
37
|
-
|
|
37
|
+
q as getPreImportHTML,
|
|
38
38
|
ka as i18n,
|
|
39
39
|
D as mergeClasses,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
z as registerChaiAddBlockTab,
|
|
41
|
+
J as registerChaiBlockSettingField,
|
|
42
|
+
V as registerChaiBlockSettingTemplate,
|
|
43
|
+
W as registerChaiBlockSettingWidget,
|
|
44
44
|
Z as registerChaiFeatureFlag,
|
|
45
45
|
$ as registerChaiFeatureFlags,
|
|
46
46
|
G as registerChaiLibrary,
|
|
@@ -57,11 +57,11 @@ export {
|
|
|
57
57
|
ta as useChaiFeatureFlag,
|
|
58
58
|
la as useChaiFeatureFlags,
|
|
59
59
|
Ca as useChaiLibraries,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
ga as useChaiSidebarPanels,
|
|
61
|
+
I as useHtmlToBlocks,
|
|
62
|
+
M as useI18nBlocks,
|
|
63
63
|
P as useLanguages,
|
|
64
|
-
|
|
64
|
+
ha as useMediaManagerComponent,
|
|
65
65
|
f as useReplaceBlock,
|
|
66
66
|
E as useSavePage,
|
|
67
67
|
ua as useSaveToLibraryComponent,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as i, jsxs as u } from "react/jsx-runtime";
|
|
2
2
|
import { B as y } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { D as T, e as V, f as N, g as R, o as E, p as D, T as I, q as A } from "./index-
|
|
3
|
+
import { D as T, e as V, f as N, g as R, o as E, p as D, T as I, q as A } from "./index-RwAuF_BE.js";
|
|
4
4
|
import "lodash-es";
|
|
5
5
|
import * as b from "culori";
|
|
6
6
|
import { a as P } from "./fonts-B3UYxuJI.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import { B as L } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { d as k, n as U, D as W, e as g, f as B, g as G, o as R, q as j } from "./index-
|
|
4
|
-
import { c as q, m as F, k as H, e as M, j as Q, n as T, L as $ } from "./index-
|
|
3
|
+
import { d as k, n as U, D as W, e as g, f as B, g as G, o as R, q as j } from "./index-RwAuF_BE.js";
|
|
4
|
+
import { c as q, m as F, k as H, e as M, j as Q, n as T, L as $ } from "./index-DlTEPwjW.js";
|
|
5
5
|
import { isEmpty as z, get as I } from "lodash-es";
|
|
6
6
|
import { useMemo as f } from "react";
|
|
7
7
|
import { useTranslation as J } from "react-i18next";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DrzR7vXl.cjs"),l=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DrzR7vXl.cjs"),l=require("./index-DXBHjFwY.cjs"),C=require("lodash-es"),f=require("react"),g=require("react-i18next"),S=(e,d)=>{const t=d.filter(m=>m.parent===e);if(t.length===0)return 0;let u=t.length;return t.forEach(m=>{u+=S(m.id,d)}),u};function U({page:e,onClose:d}){const{t}=g.useTranslation(),[,u]=l.useSearchParams(),{mutate:m,isPending:P}=l.useDeletePage(),{data:j}=l.usePageTypes(),{data:h=[]}=l.useWebsitePrimaryPages(),{setSelectedLang:E,fallbackLang:L}=n.useLanguages(),[,q]=n.useSidebarActivePanel(),c=!(e!=null&&e.primaryPage),{data:r=[]}=l.useLanguagePages(c?e==null?void 0:e.id:void 0),{data:y}=l.useSiteWideUsage(),v=f.useMemo(()=>C.isEmpty(e==null?void 0:e.slug),[e==null?void 0:e.slug]),w=f.useMemo(()=>{if(!v||!(e!=null&&e.id)||!y)return[];const i=[];return Object.entries(y).forEach(([o,D])=>{D.partialBlocks.includes(e.id)&&!D.isPartial&&i.push({id:o,name:D.name})}),i},[v,e.id,y]),N=f.useMemo(()=>!c||!r?0:r.filter(i=>i.id!==e.id).length,[c,r,e.id]),x=f.useMemo(()=>{if(!(e!=null&&e.id)||!h.length)return 0;let i=S(e.id,h);return c&&r&&r.length>0&&r.forEach(o=>{o.id!==e.id&&(i+=S(o.id,h))}),i},[e.id,h,c,r]),A=()=>{P||m(e,{onSuccess:()=>{e!=null&&e.primaryPage?(window.history.replaceState({},"",`/?page=${e.primaryPage}`),u(new URLSearchParams({page:e.primaryPage}))):(window.history.replaceState({},"","/"),u(new URLSearchParams)),window.dispatchEvent(new PopStateEvent("popstate")),E(L),q("outline"),d()}})},a=j==null?void 0:j.find(i=>i.key===(e==null?void 0:e.pageType));return s.jsx(n.Dialog,{open:!!e,onOpenChange:d,children:s.jsxs(n.DialogContent,{children:[s.jsxs(n.DialogHeader,{children:[s.jsx(n.DialogTitle,{children:t("Confirm Deletion")}),s.jsxs(n.DialogDescription,{className:"py-4 text-slate-500",children:[s.jsxs("div",{children:[t("Are you sure you want to remove")," ",s.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",a!=null&&a.hasSlug?(a==null?void 0:a.name)+"?":t("page?")]}),c&&(N>0||x>0)&&s.jsxs("div",{className:"mt-3 rounded-md bg-red-50 p-3 text-sm",children:[s.jsxs("div",{className:"font-semibold text-red-800",children:[t("Warning: Deleting this primary page will also delete"),":"]}),s.jsxs("ul",{className:"mt-2 list-inside list-disc space-y-1 text-red-700",children:[x>0&&s.jsxs("li",{children:[s.jsx("span",{className:"font-medium",children:x})," ",t(x===1?"nested child page":"nested child pages")]}),N>0&&s.jsx("li",{children:t("All associated language pages")})]})]}),v&&w.length>0&&s.jsxs("div",{className:"mt-3 rounded-md bg-red-50 p-3 text-sm",children:[s.jsxs("div",{className:"font-semibold text-red-800",children:[t("Warning: This partial is currently used in the following pages"),":"]}),s.jsx("ul",{className:"mt-2 list-inside list-disc space-y-1 text-red-700",children:w.map(({id:i,name:o})=>s.jsx("li",{children:s.jsx("span",{className:"font-medium",children:o})},i))})]}),e.lang&&s.jsxs("div",{className:"py-2 text-sm",children:[t("Language"),":"," ",s.jsx("span",{className:"font-medium text-gray-500",children:C.get(l.LANGUAGES,e.lang,e.lang)})]})]})]}),s.jsxs(n.DialogFooter,{children:[s.jsx(b.Button,{variant:"outline",onClick:d,children:t("Cancel")}),s.jsx(b.Button,{variant:"destructive",disabled:P,onClick:A,children:t(P?"Deleting...":"Delete")})]})]})})}exports.default=U;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as c, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { E as
|
|
4
|
-
import { ArrowRightIcon as
|
|
2
|
+
import { ak as I, a as _, a0 as p, d as j, I as C, X as O, Y as z, P as E } from "./index-RwAuF_BE.js";
|
|
3
|
+
import { E as W } from "./register-chai-top-bar-D6GjnauV.js";
|
|
4
|
+
import { ArrowRightIcon as A, FileIcon as F, GlobeIcon as M } from "@radix-ui/react-icons";
|
|
5
5
|
import { noop as R } from "lodash-es";
|
|
6
6
|
import { useMemo as d, useCallback as X } from "react";
|
|
7
7
|
import { useTranslation as Y } from "react-i18next";
|
|
@@ -12,7 +12,7 @@ const b = ({ title: s, items: i, emptyLabel: r, onSelect: t, icon: o }) => /* @_
|
|
|
12
12
|
{
|
|
13
13
|
type: "button",
|
|
14
14
|
onClick: () => t(a.id),
|
|
15
|
-
className:
|
|
15
|
+
className: W(
|
|
16
16
|
"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",
|
|
17
17
|
"hover:border-muted-foreground/20 hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1",
|
|
18
18
|
a.isSelected && "border-primary/40 bg-primary/10 text-primary"
|
|
@@ -37,7 +37,7 @@ const b = ({ title: s, items: i, emptyLabel: r, onSelect: t, icon: o }) => /* @_
|
|
|
37
37
|
label: D(t)
|
|
38
38
|
}));
|
|
39
39
|
}, ee = ({ tokenId: s, tokenName: i, children: r }) => {
|
|
40
|
-
const { t } = Y(), [o] =
|
|
40
|
+
const { t } = Y(), [o] = I(), [a, g] = _(), h = p("pageId", ""), u = p("siteWideUsage", {}), y = d(() => G(o, s), [o, s]), k = d(
|
|
41
41
|
() => y.map((e) => ({
|
|
42
42
|
id: e.id,
|
|
43
43
|
label: e.label,
|
|
@@ -64,7 +64,7 @@ const b = ({ title: s, items: i, emptyLabel: r, onSelect: t, icon: o }) => /* @_
|
|
|
64
64
|
g([e]);
|
|
65
65
|
},
|
|
66
66
|
[g]
|
|
67
|
-
), B = p("gotoPage", R), { selectedLang: T, fallbackLang: L } =
|
|
67
|
+
), B = p("gotoPage", R), { selectedLang: T, fallbackLang: L } = j(), { savePageAsync: w } = C(), x = async (e) => {
|
|
68
68
|
e && (await w(!0), B({ pageId: e, lang: T || L }));
|
|
69
69
|
};
|
|
70
70
|
return /* @__PURE__ */ c(O, { children: [
|
|
@@ -82,7 +82,7 @@ const b = ({ title: s, items: i, emptyLabel: r, onSelect: t, icon: o }) => /* @_
|
|
|
82
82
|
items: k,
|
|
83
83
|
emptyLabel: t("None"),
|
|
84
84
|
onSelect: N,
|
|
85
|
-
icon: /* @__PURE__ */ n(
|
|
85
|
+
icon: /* @__PURE__ */ n(A, { fontSize: 4 })
|
|
86
86
|
}
|
|
87
87
|
),
|
|
88
88
|
/* @__PURE__ */ n(
|
|
@@ -92,7 +92,7 @@ const b = ({ title: s, items: i, emptyLabel: r, onSelect: t, icon: o }) => /* @_
|
|
|
92
92
|
items: v,
|
|
93
93
|
emptyLabel: t("None"),
|
|
94
94
|
onSelect: x,
|
|
95
|
-
icon: /* @__PURE__ */ n(
|
|
95
|
+
icon: /* @__PURE__ */ n(F, { fontSize: 8 })
|
|
96
96
|
}
|
|
97
97
|
),
|
|
98
98
|
/* @__PURE__ */ n(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as r, jsx as e, Fragment as H } from "react/jsx-runtime";
|
|
2
2
|
import { B as p, z as me } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { p as V, T as Fe, aw as _,
|
|
3
|
+
import { p as V, T as Fe, aw as _, z as q, A as P, E as G, D as Ue, e as Le, f as $e, g as Me, o as _e, q as qe, af as Pe } from "./index-RwAuF_BE.js";
|
|
4
4
|
import { f as Ge, c as Oe } from "./image-compression-DPFITwOL.js";
|
|
5
5
|
import { find as Be, merge as Ke, pick as Y, first as Qe, isEmpty as Re } from "lodash-es";
|
|
6
6
|
import { ChevronLeft as ue, ChevronRight as We, Loader as B, AlertCircle as Ve, Copy as he, Pencil as He, Link as Xe, Search as Ze, RefreshCwIcon as Je, Archive as Ye, Film as et, ImageIcon as tt, Edit as it, Trash2 as at, Check as lt, Upload as rt, AlertTriangle as nt } from "lucide-react";
|
|
@@ -10,7 +10,7 @@ import { ErrorBoundary as ot } from "react-error-boundary";
|
|
|
10
10
|
import { useTranslation as ee } from "react-i18next";
|
|
11
11
|
import { toast as A } from "sonner";
|
|
12
12
|
import { useQueryClient as te, useMutation as ie, useQuery as ge } from "@tanstack/react-query";
|
|
13
|
-
import {
|
|
13
|
+
import { ao as K, ap as Q, A as b } from "./index-DlTEPwjW.js";
|
|
14
14
|
import { c as xe } from "./common-functions-D2lMFR6K.js";
|
|
15
15
|
const dt = () => {
|
|
16
16
|
const s = K(), n = te(), h = Q();
|
|
@@ -385,7 +385,7 @@ const xt = ({ assetId: s, onBack: n, onEdit: h, onSave: a, isSaving: c }) => {
|
|
|
385
385
|
] })
|
|
386
386
|
] })
|
|
387
387
|
] });
|
|
388
|
-
}, vt = fe.lazy(() => import("./image-editor-
|
|
388
|
+
}, vt = fe.lazy(() => import("./image-editor-CzxSXo-u.js")), yt = 25 * 1024 * 1024, Nt = ({ isUpdatingAsset: s, allowedTypes: n, uploadAssets: h, isUploadingAsset: a, onUploaded: c }) => {
|
|
389
389
|
const { t: i } = ee(), [l, I] = y(() => {
|
|
390
390
|
const o = localStorage.getItem("chai_optimize_images");
|
|
391
391
|
return o !== null ? o === "true" : !0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("./register-chai-top-bar-DyW9GPzV.cjs"),d=require("./index-DrzR7vXl.cjs"),ee=require("./image-compression-UaU7Bwqe.cjs"),B=require("lodash-es"),f=require("lucide-react"),u=require("react"),ge=require("react-dropzone"),je=require("react-error-boundary"),R=require("react-i18next"),C=require("sonner"),D=require("@tanstack/react-query"),j=require("./index-Dh-fEHei.cjs"),te=require("./common-functions-B3a4xKt_.cjs"),ve=()=>{const r=j.useApiUrl(),a=D.useQueryClient(),x=j.useFetch();return D.useMutation({mutationFn:async i=>{const n=i.map(async l=>x(r,{action:j.ACTIONS.UPLOAD_ASSET,data:l}));return await Promise.all(n)},onSuccess:i=>{var n;if(i!=null&&i.some(s=>s.error))throw new Error(((n=i==null?void 0:i.find(s=>s.error))==null?void 0:n.error)||"Failed to upload asset");{a.invalidateQueries({queryKey:[j.ACTIONS.GET_ASSETS]});const s=i==null?void 0:i.length;C.toast.success(`${s===1?"Asset":s+" Assets"} uploaded successfully`)}},onError:()=>{C.toast.error("Failed to upload asset")}})},ye=()=>{const r=j.useApiUrl(),a=D.useQueryClient(),x=j.useFetch();return D.useMutation({mutationFn:async i=>x(r,{action:j.ACTIONS.DELETE_ASSET,data:{id:i}}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);a.invalidateQueries({queryKey:[j.ACTIONS.GET_ASSETS]}),C.toast.success("Asset deleted successfully")},onError:()=>{C.toast.error("Failed to delete asset")}})},Ne=()=>{const r=j.useApiUrl(),a=D.useQueryClient(),x=j.useFetch();return D.useMutation({mutationFn:async i=>x(r,{action:j.ACTIONS.UPDATE_ASSET,data:i}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);a.invalidateQueries({queryKey:[j.ACTIONS.GET_ASSETS]}),i!=null&&i.id&&a.invalidateQueries({queryKey:[j.ACTIONS.GET_ASSET,i.id]}),C.toast.success("Asset updated successfully")},onError:()=>{C.toast.error("Failed to update asset")}})};function be({currentPage:r,totalPages:a,onPageChange:x,pageRangeDisplayed:i=3,showPageInput:n=!0,className:s=""}){const[l,I]=u.useState(String(r)),b=u.useMemo(()=>{const o=Math.floor(i/2);let m=Math.max(1,r-o),c=Math.min(a,r+o);c-m+1<i&&(m===1?c=Math.min(a,m+i-1):c===a&&(m=Math.max(1,c-i+1)));const p=[];m>1&&(p.push(1),m>2&&p.push("..."));for(let N=m;N<=c;N++)p.push(N);return c<a&&(c<a-1&&p.push("..."),p.push(a)),p},[r,a,i]),y=o=>{o!==r&&o>=1&&o<=a&&(x(o),I(String(o)))},v=()=>{r>1&&y(r-1)},w=()=>{r<a&&y(r+1)},A=()=>{const o=Number(l);!isNaN(o)&&o>=1&&o<=a&&y(o)},S=o=>{o.key==="Enter"&&A()};return a<=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(g.Button,{variant:"outline",size:"sm",onClick:v,disabled:r===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:b.map((o,m)=>{if(o==="...")return e.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${m}`);const c=o,p=c===r;return e.jsx(g.Button,{variant:p?"default":"outline",size:"sm",onClick:()=>y(c),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:c},c)})}),e.jsxs(g.Button,{variant:"outline",size:"sm",onClick:w,disabled:r===a,className:"px-2 py-1 text-sm hover:bg-gray-50",children:["Next",e.jsx(f.ChevronRight,{className:"h-4 w-4"})]})]}),n&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Go to"}),e.jsx(g.Input,{type:"number",min:1,max:a,value:l,onChange:o=>{const m=o.target.value.replace(/[^\d]/g,"");I(m)},onKeyDown:S,className:"h-8 w-16 px-2 py-1"}),e.jsx(g.Button,{variant:"outline",size:"sm",onClick:A,disabled:l===""||Number(l)<1||Number(l)>a,children:"Go"})]})]})}const we=(r={})=>{const a=j.useApiUrl(),x=j.useFetch(),{search:i,page:n=1,limit:s=30}=r;return D.useQuery({queryKey:[j.ACTIONS.GET_ASSETS,i,n,s],queryFn:async()=>{const l=await x(a,{action:j.ACTIONS.GET_ASSETS,data:{search:i,page:n,limit:s}});return l.page=n,l.limit=s,l},staleTime:1/0,retry:1})},Ce=r=>{const a=j.useApiUrl(),x=j.useFetch();return D.useQuery({queryKey:[j.ACTIONS.GET_ASSET,r],queryFn:async()=>r?await x(a,{action:j.ACTIONS.GET_ASSET,data:{id:r}}):null,staleTime:1/0,retry:1})};function Ae(r){const a=isNaN(r)?0:typeof r=="number"?r:parseInt(r);return a?a<1024?`${a.toFixed(2)} B`:a<1024*1024?`${(a/1024).toFixed(2)} KB`:`${(a/(1024*1024)).toFixed(2)} MB`:"0 B"}function J(r){if(!r)return"N/A";const a=new Date(r);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(a)}function Y(r,a){let x=r,i=a==null?void 0:a.description;return(!i||typeof i!="string")&&(i=""),(!x||typeof x!="string")&&(x=""),x!==i}const Se=({assetId:r,onBack:a,onEdit:x,onSave:i,isSaving:n})=>{var o,m;const{t:s}=R.useTranslation(),{data:l,isLoading:I,isError:b}=Ce(r||""),[y,v]=u.useState(""),[w,A]=u.useState(!1);u.useEffect(()=>{const c=new Image;return c.src=(l==null?void 0:l.url)||"",c.onload=()=>A(!0),()=>{c.onload=null}},[l]);const S=async(c,p)=>{try{await navigator.clipboard.writeText(c),C.toast.success(s("{{type}} copied to clipboard",{type:p}))}catch(N){C.toast.error(s("Failed to copy {{type}}",{type:p}),{description:N==null?void 0:N.message})}};return u.useEffect(()=>{l!=null&&l.description&&v(l.description)},[l]),I||!w?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}):b||!(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(b?"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(g.Button,{variant:"outline",onClick:a,children:s("Back to Assets")}),b&&e.jsx(g.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(g.Button,{variant:"outline",size:"sm",onClick:a,disabled:n,children:[e.jsx(f.ChevronLeft,{className:"h-4 w-4"}),s("Back to Assets")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g.Button,{variant:"outline",onClick:a,disabled:n,children:s("Cancel")}),e.jsxs(g.Button,{variant:"outline",onClick:()=>S(l.url,s("Asset URL")),disabled:n,children:[e.jsx(f.Copy,{className:"mr-2 h-4 w-4"}),s("Copy URL")]}),e.jsxs(g.Button,{variant:"default",onClick:()=>x(l),disabled:n,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(d.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:((o=l.metadata)==null?void 0:o.format)||l.type,capitalize:!0},{label:s("Size"),value:Ae(l.size)},{label:s("Dimensions"),value:`${l.width||0} × ${l.height||0}`},{label:s("Created"),value:J(l.createdAt)},{label:s("Updated"),value:J(((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(c=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.Label,{className:"w-1/4 w-max px-2 text-left font-normal text-gray-700",children:c.label}),":",e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+(c.capitalize?" capitalize":""),children:c.value}),c.copyable&&e.jsx(g.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>S(c.value,c.label),children:e.jsx(f.Link,{className:"h-3 w-3"})})]})]},c.label))})]}),l.usedOn&&l.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(d.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((c,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:c.name}),e.jsxs("div",{className:"text-gray-500",children:["(",c.slug,")"]})]},p))})]}),e.jsxs("div",{className:"relative grid gap-3 rounded-md border bg-gray-100 pt-2",children:[e.jsx(d.Label,{className:"w-full text-center",children:s("Description")}),e.jsx(d.Textarea,{id:"description",value:y,placeholder:s("Enter a description for the asset"),onChange:c=>v(c.target.value),rows:3,disabled:n,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(y),disabled:n||!Y(y,l),className:`rounded-md bg-blue-500 px-3 py-0 py-0.5 text-sm text-white ${n||!Y(y,l)?"cursor-not-allowed opacity-50":""}`,children:n?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"mr-2 h-4 w-4 animate-spin"}),s("Saving...")]}):s("Save")})})]})]})]})]})},Te=u.lazy(()=>Promise.resolve().then(()=>require("./image-editor-DQ8mQonU.cjs"))),Ee=25*1024*1024,Ie=({isUpdatingAsset:r,allowedTypes:a,uploadAssets:x,isUploadingAsset:i,onUploaded:n})=>{const{t:s}=R.useTranslation(),[l,I]=u.useState(()=>{const o=localStorage.getItem("chai_optimize_images");return o!==null?o==="true":!0});u.useEffect(()=>{localStorage.setItem("chai_optimize_images",l.toString())},[l]);const b=r||i,y=u.useCallback(async o=>{try{const m=o;if(!m.every(T=>T.type.startsWith("image/")))return C.toast.error(s("Invalid file type. Please upload a valid file.")),Promise.reject(new Error("Invalid file type"));const c=m.map(async T=>{let U=T;return T.type.startsWith("image/")&&l&&(U=await ee.compressImageIfNeeded(T)),new Promise((_,q)=>{const L=new FileReader;L.readAsDataURL(U),L.onload=async()=>{_({file:L.result,folderId:void 0,name:T.name,optimize:l})},L.onerror=()=>q(null)})}),p=await Promise.all(c),N=await x(p);return(N==null?void 0:N.length)===1&&n(N[0]),N}catch(m){return Promise.reject(m)}},[x,l,n,s]),v=o=>{const m=[];let c=0;return o.forEach(p=>{p.size>Ee?c++:m.push(p)}),c>0&&C.toast.error(`${c===1&&o.length===1?s("File"):c+s(c===1?" file":" files")} ${s("exceed the maximum size limit of 10MB.")}`),B.isEmpty(m)?[]:y(m)},{getRootProps:w,getInputProps:A,isDragActive:S}=ge.useDropzone({onDrop:v,accept:{"image/*":a.includes("image")?[]:[]},disabled:r||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 ${b?"pointer-events-none bg-gray-100 opacity-90":"bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,children:e.jsxs("div",{...w(),className:te.cn("flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",b?"items-start":"items-center",S?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...A()}),b?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(r?"Updating file...":"Uploading file...")}),e.jsxs("div",{className:"text-xs font-light text-muted-foreground",children:[s("Please wait while we")," ",s(r?"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:a.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(d.Switch,{checked:l,onCheckedChange:o=>{I(o)},onClick:o=>{o.stopPropagation()},className:"data-[state=checked]:bg-indigo-500"})]}),e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.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(d.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 ke({close:r,onSelect:a,mode:x="image",assetId:i}){const{t:n}=R.useTranslation(),s=!1,l=10,I=u.useMemo(()=>[x],[x]),[b,y]=u.useState(null),[v,w]=u.useState(null),[A,S]=u.useState(null),[o,m]=u.useState({show:!1,file:""}),[c,p]=u.useState(!1),[N,T]=u.useState(i?"details":"grid"),[U,_]=u.useState(""),[q,L]=u.useState(""),[P,Q]=u.useState(1),[K]=u.useState(30),[E,G]=u.useState([]);u.useEffect(()=>{i&&(y(i),T("details"))},[i]),u.useEffect(()=>{const t=setTimeout(()=>{_(q),Q(1)},300);return()=>clearTimeout(t)},[q]);const{data:O,isLoading:$,refetch:se}=we({search:U.toLowerCase().trim(),page:P,limit:K}),F=(O==null?void 0:O.assets)||[],ie=(O==null?void 0:O.total)||0,k=Math.ceil(ie/K);u.useEffect(()=>{$||k<=0||Q(t=>t>k?k:t<1?1:t)},[$,k]);const le=(F==null?void 0:F.length)>0,{mutate:ae}=ye(),{mutateAsync:W,isPending:re}=ve(),{mutateAsync:V,isPending:ne}=Ne(),H=u.useCallback(t=>{const h=Math.min(Math.max(1,t),Math.max(1,k));h!==P&&Q(h)},[k,P]),oe=t=>{L(t.target.value)},ce=u.useCallback(t=>{G(h=>B.find(h,{id:t.id})?[]:[t])},[s]),de=u.useCallback(()=>{G([])},[]),X=t=>{(t==null?void 0:t.length)!==0&&(a(B.pick(B.first(t||E),["id","url","width","height","description"])),r())},ue=async t=>{w(t)},me=async()=>{v&&(S(v==null?void 0:v.id),await ae(v.id,{onSuccess:()=>{S(null),w(null)},onError:()=>{S(null)}}),w(null))},he=t=>{y(t.id),T("details")},xe=async(t,h)=>{try{const M=localStorage.getItem("chai_optimize_images")!=="false";if(h){const z=await W([{file:t,folderId:void 0,name:o.name||"",optimize:M}]);if((z==null?void 0:z.length)>0){const Z=z[0];a({...B.pick(Z,["id","width","height","description"]),url:Z.url})}}else{const z=await V({id:o.id||"",file:t});z&&a({...B.pick(z,["id","width","height","description"]),url:z.url})}m({show:!1,file:""}),r()}catch(M){console.error(n("Error saving edited image:"),M)}},fe=u.useCallback(t=>{G([t])},[]),pe=u.useCallback(t=>{H(t)},[H]);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:n("Digital Asset Manager")}),N==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{maxFileSize:l,allowedTypes:I,uploadAssets:W,isUpdatingAsset:ne,isUploadingAsset:re,onUploaded:fe}),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 ${q.length>0?"text-indigo-800":""}`}),e.jsx(g.Input,{placeholder:n("Search assets..."),onChange:oe,value:q,className:"pl-8"})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[E.length>0?e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[E.length>0&&e.jsx(e.Fragment,{children:e.jsx(g.Button,{variant:"outline",size:"sm",onClick:()=>de(),title:n("Clear selection"),children:n("Clear")})}),e.jsx(g.Button,{size:"sm",onClick:()=>X(E),disabled:E.length===0,children:n("Select Asset")})]})}):null,e.jsx(g.Button,{variant:"ghost",size:"icon",onClick:()=>se(),children:e.jsx(f.RefreshCwIcon,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-[66px]",children:$?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"})]}):!$&&!le?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:n("No assets found")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.length>0?n("No assets found for your search: {{query}}",{query:U}):n("Start uploading assets to get started")}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:F==null?void 0:F.map(t=>e.jsxs("div",{className:te.cn("group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",E.some(h=>h.id===t.id)?"border-blue-500":"hover:border-black/90",A&&(v==null?void 0:v.id)===t.id?"pointer-events-none opacity-50":"",A===t.id?"pointer-events-none opacity-50":""),onClick:()=>ce(t),onDoubleClick:()=>X([t]),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[A===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 ${E.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:ee.formatFileSize((t==null?void 0:t.size)||0)})})]}),!E.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(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx(g.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),he(t)},children:e.jsx(f.ImageIcon,{className:"h-4 w-4"})})}),e.jsx(d.TooltipContent,{children:e.jsx("p",{children:n("View Details")})})]})}),e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx(g.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),navigator.clipboard.writeText(t.url),C.toast.success(n("Asset URL copied to clipboard"))},children:e.jsx(f.Copy,{className:"h-4 w-4"})})}),e.jsx(d.TooltipContent,{children:e.jsx("p",{children:n("Copy URL")})})]})}),e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx(g.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(d.TooltipContent,{children:e.jsx("p",{children:n("Edit Image")})})]})}),e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx(g.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),ue(t)},children:e.jsx(f.Trash2,{className:"h-4 w-4"})})}),e.jsx(d.TooltipContent,{children:e.jsx("p",{children:n("Delete Asset")})})]})})]})}),E.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))})}),k>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t bg-white p-4",children:e.jsx(je.ErrorBoundary,{fallback:e.jsx("div",{className:"text-red-500",children:n("Error loading pagination")}),children:e.jsx(be,{currentPage:P,totalPages:k,onPageChange:pe,pageRangeDisplayed:3,showPageInput:!0})})})]})]}):e.jsx(Se,{assetId:b||i||"",onBack:()=>{T("grid"),y(null)},onEdit:t=>{m({id:t.id,show:!0,file:t.url,name:t.name})},onSave:async t=>{if(b){p(!0);try{const h=F.find(M=>M.id===b);h&&await V(B.merge(h,{description:t}))}finally{p(!1)}}},isSaving:c})]}),o.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(Te,{imageUrl:o.file,onSave:xe,onClose:()=>m({show:!1,file:""}),defaultSavedImageName:o.name,isEditing:!!o.id})}),v&&e.jsx(d.Dialog,{open:!!v,onOpenChange:()=>w(null),children:e.jsxs(d.DialogContent,{children:[e.jsxs(d.DialogHeader,{children:[e.jsx(d.DialogTitle,{children:n("Delete Asset")}),e.jsx(d.DialogDescription,{children:n('Are you sure you want to delete "{{name}}"? This action cannot be undone.',{name:v.name})})]}),e.jsxs(d.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(g.Button,{variant:"outline",onClick:()=>w(null),children:n("Cancel")}),e.jsx(g.Button,{variant:"destructive",onClick:me,children:n("Delete")})]})]})})]})}exports.default=ke;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("./register-chai-top-bar-DyW9GPzV.cjs"),d=require("./index-DrzR7vXl.cjs"),ee=require("./image-compression-UaU7Bwqe.cjs"),B=require("lodash-es"),f=require("lucide-react"),u=require("react"),ge=require("react-dropzone"),je=require("react-error-boundary"),R=require("react-i18next"),C=require("sonner"),D=require("@tanstack/react-query"),j=require("./index-DXBHjFwY.cjs"),te=require("./common-functions-B3a4xKt_.cjs"),ve=()=>{const r=j.useApiUrl(),a=D.useQueryClient(),x=j.useFetch();return D.useMutation({mutationFn:async i=>{const n=i.map(async l=>x(r,{action:j.ACTIONS.UPLOAD_ASSET,data:l}));return await Promise.all(n)},onSuccess:i=>{var n;if(i!=null&&i.some(s=>s.error))throw new Error(((n=i==null?void 0:i.find(s=>s.error))==null?void 0:n.error)||"Failed to upload asset");{a.invalidateQueries({queryKey:[j.ACTIONS.GET_ASSETS]});const s=i==null?void 0:i.length;C.toast.success(`${s===1?"Asset":s+" Assets"} uploaded successfully`)}},onError:()=>{C.toast.error("Failed to upload asset")}})},ye=()=>{const r=j.useApiUrl(),a=D.useQueryClient(),x=j.useFetch();return D.useMutation({mutationFn:async i=>x(r,{action:j.ACTIONS.DELETE_ASSET,data:{id:i}}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);a.invalidateQueries({queryKey:[j.ACTIONS.GET_ASSETS]}),C.toast.success("Asset deleted successfully")},onError:()=>{C.toast.error("Failed to delete asset")}})},Ne=()=>{const r=j.useApiUrl(),a=D.useQueryClient(),x=j.useFetch();return D.useMutation({mutationFn:async i=>x(r,{action:j.ACTIONS.UPDATE_ASSET,data:i}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);a.invalidateQueries({queryKey:[j.ACTIONS.GET_ASSETS]}),i!=null&&i.id&&a.invalidateQueries({queryKey:[j.ACTIONS.GET_ASSET,i.id]}),C.toast.success("Asset updated successfully")},onError:()=>{C.toast.error("Failed to update asset")}})};function be({currentPage:r,totalPages:a,onPageChange:x,pageRangeDisplayed:i=3,showPageInput:n=!0,className:s=""}){const[l,I]=u.useState(String(r)),b=u.useMemo(()=>{const o=Math.floor(i/2);let m=Math.max(1,r-o),c=Math.min(a,r+o);c-m+1<i&&(m===1?c=Math.min(a,m+i-1):c===a&&(m=Math.max(1,c-i+1)));const p=[];m>1&&(p.push(1),m>2&&p.push("..."));for(let N=m;N<=c;N++)p.push(N);return c<a&&(c<a-1&&p.push("..."),p.push(a)),p},[r,a,i]),y=o=>{o!==r&&o>=1&&o<=a&&(x(o),I(String(o)))},v=()=>{r>1&&y(r-1)},w=()=>{r<a&&y(r+1)},A=()=>{const o=Number(l);!isNaN(o)&&o>=1&&o<=a&&y(o)},S=o=>{o.key==="Enter"&&A()};return a<=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(g.Button,{variant:"outline",size:"sm",onClick:v,disabled:r===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:b.map((o,m)=>{if(o==="...")return e.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${m}`);const c=o,p=c===r;return e.jsx(g.Button,{variant:p?"default":"outline",size:"sm",onClick:()=>y(c),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:c},c)})}),e.jsxs(g.Button,{variant:"outline",size:"sm",onClick:w,disabled:r===a,className:"px-2 py-1 text-sm hover:bg-gray-50",children:["Next",e.jsx(f.ChevronRight,{className:"h-4 w-4"})]})]}),n&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Go to"}),e.jsx(g.Input,{type:"number",min:1,max:a,value:l,onChange:o=>{const m=o.target.value.replace(/[^\d]/g,"");I(m)},onKeyDown:S,className:"h-8 w-16 px-2 py-1"}),e.jsx(g.Button,{variant:"outline",size:"sm",onClick:A,disabled:l===""||Number(l)<1||Number(l)>a,children:"Go"})]})]})}const we=(r={})=>{const a=j.useApiUrl(),x=j.useFetch(),{search:i,page:n=1,limit:s=30}=r;return D.useQuery({queryKey:[j.ACTIONS.GET_ASSETS,i,n,s],queryFn:async()=>{const l=await x(a,{action:j.ACTIONS.GET_ASSETS,data:{search:i,page:n,limit:s}});return l.page=n,l.limit=s,l},staleTime:1/0,retry:1})},Ce=r=>{const a=j.useApiUrl(),x=j.useFetch();return D.useQuery({queryKey:[j.ACTIONS.GET_ASSET,r],queryFn:async()=>r?await x(a,{action:j.ACTIONS.GET_ASSET,data:{id:r}}):null,staleTime:1/0,retry:1})};function Ae(r){const a=isNaN(r)?0:typeof r=="number"?r:parseInt(r);return a?a<1024?`${a.toFixed(2)} B`:a<1024*1024?`${(a/1024).toFixed(2)} KB`:`${(a/(1024*1024)).toFixed(2)} MB`:"0 B"}function J(r){if(!r)return"N/A";const a=new Date(r);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(a)}function Y(r,a){let x=r,i=a==null?void 0:a.description;return(!i||typeof i!="string")&&(i=""),(!x||typeof x!="string")&&(x=""),x!==i}const Se=({assetId:r,onBack:a,onEdit:x,onSave:i,isSaving:n})=>{var o,m;const{t:s}=R.useTranslation(),{data:l,isLoading:I,isError:b}=Ce(r||""),[y,v]=u.useState(""),[w,A]=u.useState(!1);u.useEffect(()=>{const c=new Image;return c.src=(l==null?void 0:l.url)||"",c.onload=()=>A(!0),()=>{c.onload=null}},[l]);const S=async(c,p)=>{try{await navigator.clipboard.writeText(c),C.toast.success(s("{{type}} copied to clipboard",{type:p}))}catch(N){C.toast.error(s("Failed to copy {{type}}",{type:p}),{description:N==null?void 0:N.message})}};return u.useEffect(()=>{l!=null&&l.description&&v(l.description)},[l]),I||!w?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}):b||!(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(b?"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(g.Button,{variant:"outline",onClick:a,children:s("Back to Assets")}),b&&e.jsx(g.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(g.Button,{variant:"outline",size:"sm",onClick:a,disabled:n,children:[e.jsx(f.ChevronLeft,{className:"h-4 w-4"}),s("Back to Assets")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g.Button,{variant:"outline",onClick:a,disabled:n,children:s("Cancel")}),e.jsxs(g.Button,{variant:"outline",onClick:()=>S(l.url,s("Asset URL")),disabled:n,children:[e.jsx(f.Copy,{className:"mr-2 h-4 w-4"}),s("Copy URL")]}),e.jsxs(g.Button,{variant:"default",onClick:()=>x(l),disabled:n,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(d.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:((o=l.metadata)==null?void 0:o.format)||l.type,capitalize:!0},{label:s("Size"),value:Ae(l.size)},{label:s("Dimensions"),value:`${l.width||0} × ${l.height||0}`},{label:s("Created"),value:J(l.createdAt)},{label:s("Updated"),value:J(((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(c=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.Label,{className:"w-1/4 w-max px-2 text-left font-normal text-gray-700",children:c.label}),":",e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+(c.capitalize?" capitalize":""),children:c.value}),c.copyable&&e.jsx(g.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>S(c.value,c.label),children:e.jsx(f.Link,{className:"h-3 w-3"})})]})]},c.label))})]}),l.usedOn&&l.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(d.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((c,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:c.name}),e.jsxs("div",{className:"text-gray-500",children:["(",c.slug,")"]})]},p))})]}),e.jsxs("div",{className:"relative grid gap-3 rounded-md border bg-gray-100 pt-2",children:[e.jsx(d.Label,{className:"w-full text-center",children:s("Description")}),e.jsx(d.Textarea,{id:"description",value:y,placeholder:s("Enter a description for the asset"),onChange:c=>v(c.target.value),rows:3,disabled:n,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(y),disabled:n||!Y(y,l),className:`rounded-md bg-blue-500 px-3 py-0 py-0.5 text-sm text-white ${n||!Y(y,l)?"cursor-not-allowed opacity-50":""}`,children:n?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"mr-2 h-4 w-4 animate-spin"}),s("Saving...")]}):s("Save")})})]})]})]})]})},Te=u.lazy(()=>Promise.resolve().then(()=>require("./image-editor-DQ8mQonU.cjs"))),Ee=25*1024*1024,Ie=({isUpdatingAsset:r,allowedTypes:a,uploadAssets:x,isUploadingAsset:i,onUploaded:n})=>{const{t:s}=R.useTranslation(),[l,I]=u.useState(()=>{const o=localStorage.getItem("chai_optimize_images");return o!==null?o==="true":!0});u.useEffect(()=>{localStorage.setItem("chai_optimize_images",l.toString())},[l]);const b=r||i,y=u.useCallback(async o=>{try{const m=o;if(!m.every(T=>T.type.startsWith("image/")))return C.toast.error(s("Invalid file type. Please upload a valid file.")),Promise.reject(new Error("Invalid file type"));const c=m.map(async T=>{let U=T;return T.type.startsWith("image/")&&l&&(U=await ee.compressImageIfNeeded(T)),new Promise((_,q)=>{const L=new FileReader;L.readAsDataURL(U),L.onload=async()=>{_({file:L.result,folderId:void 0,name:T.name,optimize:l})},L.onerror=()=>q(null)})}),p=await Promise.all(c),N=await x(p);return(N==null?void 0:N.length)===1&&n(N[0]),N}catch(m){return Promise.reject(m)}},[x,l,n,s]),v=o=>{const m=[];let c=0;return o.forEach(p=>{p.size>Ee?c++:m.push(p)}),c>0&&C.toast.error(`${c===1&&o.length===1?s("File"):c+s(c===1?" file":" files")} ${s("exceed the maximum size limit of 10MB.")}`),B.isEmpty(m)?[]:y(m)},{getRootProps:w,getInputProps:A,isDragActive:S}=ge.useDropzone({onDrop:v,accept:{"image/*":a.includes("image")?[]:[]},disabled:r||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 ${b?"pointer-events-none bg-gray-100 opacity-90":"bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,children:e.jsxs("div",{...w(),className:te.cn("flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",b?"items-start":"items-center",S?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...A()}),b?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(r?"Updating file...":"Uploading file...")}),e.jsxs("div",{className:"text-xs font-light text-muted-foreground",children:[s("Please wait while we")," ",s(r?"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:a.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(d.Switch,{checked:l,onCheckedChange:o=>{I(o)},onClick:o=>{o.stopPropagation()},className:"data-[state=checked]:bg-indigo-500"})]}),e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.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(d.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 ke({close:r,onSelect:a,mode:x="image",assetId:i}){const{t:n}=R.useTranslation(),s=!1,l=10,I=u.useMemo(()=>[x],[x]),[b,y]=u.useState(null),[v,w]=u.useState(null),[A,S]=u.useState(null),[o,m]=u.useState({show:!1,file:""}),[c,p]=u.useState(!1),[N,T]=u.useState(i?"details":"grid"),[U,_]=u.useState(""),[q,L]=u.useState(""),[P,Q]=u.useState(1),[K]=u.useState(30),[E,G]=u.useState([]);u.useEffect(()=>{i&&(y(i),T("details"))},[i]),u.useEffect(()=>{const t=setTimeout(()=>{_(q),Q(1)},300);return()=>clearTimeout(t)},[q]);const{data:O,isLoading:$,refetch:se}=we({search:U.toLowerCase().trim(),page:P,limit:K}),F=(O==null?void 0:O.assets)||[],ie=(O==null?void 0:O.total)||0,k=Math.ceil(ie/K);u.useEffect(()=>{$||k<=0||Q(t=>t>k?k:t<1?1:t)},[$,k]);const le=(F==null?void 0:F.length)>0,{mutate:ae}=ye(),{mutateAsync:W,isPending:re}=ve(),{mutateAsync:V,isPending:ne}=Ne(),H=u.useCallback(t=>{const h=Math.min(Math.max(1,t),Math.max(1,k));h!==P&&Q(h)},[k,P]),oe=t=>{L(t.target.value)},ce=u.useCallback(t=>{G(h=>B.find(h,{id:t.id})?[]:[t])},[s]),de=u.useCallback(()=>{G([])},[]),X=t=>{(t==null?void 0:t.length)!==0&&(a(B.pick(B.first(t||E),["id","url","width","height","description"])),r())},ue=async t=>{w(t)},me=async()=>{v&&(S(v==null?void 0:v.id),await ae(v.id,{onSuccess:()=>{S(null),w(null)},onError:()=>{S(null)}}),w(null))},he=t=>{y(t.id),T("details")},xe=async(t,h)=>{try{const M=localStorage.getItem("chai_optimize_images")!=="false";if(h){const z=await W([{file:t,folderId:void 0,name:o.name||"",optimize:M}]);if((z==null?void 0:z.length)>0){const Z=z[0];a({...B.pick(Z,["id","width","height","description"]),url:Z.url})}}else{const z=await V({id:o.id||"",file:t});z&&a({...B.pick(z,["id","width","height","description"]),url:z.url})}m({show:!1,file:""}),r()}catch(M){console.error(n("Error saving edited image:"),M)}},fe=u.useCallback(t=>{G([t])},[]),pe=u.useCallback(t=>{H(t)},[H]);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:n("Digital Asset Manager")}),N==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{maxFileSize:l,allowedTypes:I,uploadAssets:W,isUpdatingAsset:ne,isUploadingAsset:re,onUploaded:fe}),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 ${q.length>0?"text-indigo-800":""}`}),e.jsx(g.Input,{placeholder:n("Search assets..."),onChange:oe,value:q,className:"pl-8"})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[E.length>0?e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[E.length>0&&e.jsx(e.Fragment,{children:e.jsx(g.Button,{variant:"outline",size:"sm",onClick:()=>de(),title:n("Clear selection"),children:n("Clear")})}),e.jsx(g.Button,{size:"sm",onClick:()=>X(E),disabled:E.length===0,children:n("Select Asset")})]})}):null,e.jsx(g.Button,{variant:"ghost",size:"icon",onClick:()=>se(),children:e.jsx(f.RefreshCwIcon,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-[66px]",children:$?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"})]}):!$&&!le?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:n("No assets found")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.length>0?n("No assets found for your search: {{query}}",{query:U}):n("Start uploading assets to get started")}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:F==null?void 0:F.map(t=>e.jsxs("div",{className:te.cn("group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",E.some(h=>h.id===t.id)?"border-blue-500":"hover:border-black/90",A&&(v==null?void 0:v.id)===t.id?"pointer-events-none opacity-50":"",A===t.id?"pointer-events-none opacity-50":""),onClick:()=>ce(t),onDoubleClick:()=>X([t]),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[A===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 ${E.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:ee.formatFileSize((t==null?void 0:t.size)||0)})})]}),!E.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(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx(g.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),he(t)},children:e.jsx(f.ImageIcon,{className:"h-4 w-4"})})}),e.jsx(d.TooltipContent,{children:e.jsx("p",{children:n("View Details")})})]})}),e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx(g.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),navigator.clipboard.writeText(t.url),C.toast.success(n("Asset URL copied to clipboard"))},children:e.jsx(f.Copy,{className:"h-4 w-4"})})}),e.jsx(d.TooltipContent,{children:e.jsx("p",{children:n("Copy URL")})})]})}),e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx(g.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(d.TooltipContent,{children:e.jsx("p",{children:n("Edit Image")})})]})}),e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx(g.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),ue(t)},children:e.jsx(f.Trash2,{className:"h-4 w-4"})})}),e.jsx(d.TooltipContent,{children:e.jsx("p",{children:n("Delete Asset")})})]})})]})}),E.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))})}),k>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t bg-white p-4",children:e.jsx(je.ErrorBoundary,{fallback:e.jsx("div",{className:"text-red-500",children:n("Error loading pagination")}),children:e.jsx(be,{currentPage:P,totalPages:k,onPageChange:pe,pageRangeDisplayed:3,showPageInput:!0})})})]})]}):e.jsx(Se,{assetId:b||i||"",onBack:()=>{T("grid"),y(null)},onEdit:t=>{m({id:t.id,show:!0,file:t.url,name:t.name})},onSave:async t=>{if(b){p(!0);try{const h=F.find(M=>M.id===b);h&&await V(B.merge(h,{description:t}))}finally{p(!1)}}},isSaving:c})]}),o.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(Te,{imageUrl:o.file,onSave:xe,onClose:()=>m({show:!1,file:""}),defaultSavedImageName:o.name,isEditing:!!o.id})}),v&&e.jsx(d.Dialog,{open:!!v,onOpenChange:()=>w(null),children:e.jsxs(d.DialogContent,{children:[e.jsxs(d.DialogHeader,{children:[e.jsx(d.DialogTitle,{children:n("Delete Asset")}),e.jsx(d.DialogDescription,{children:n('Are you sure you want to delete "{{name}}"? This action cannot be undone.',{name:v.name})})]}),e.jsxs(d.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(g.Button,{variant:"outline",onClick:()=>w(null),children:n("Cancel")}),e.jsx(g.Button,{variant:"destructive",onClick:me,children:n("Delete")})]})]})})]})}exports.default=ke;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as t, jsxs as a } from "react/jsx-runtime";
|
|
2
2
|
import { z as C, D as A, B as v } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { D as T, e as w, f as q, g as F, o as _, p as D } from "./index-
|
|
4
|
-
import {
|
|
3
|
+
import { D as T, e as w, f as q, g as F, o as _, p as D } from "./index-RwAuF_BE.js";
|
|
4
|
+
import { ao as G, ap as L, A as U, aq as j } from "./index-DlTEPwjW.js";
|
|
5
5
|
import { useQueryClient as $, useMutation as B } from "@tanstack/react-query";
|
|
6
6
|
import { toast as P } from "sonner";
|
|
7
7
|
import { isEmpty as O, initial as M } from "lodash-es";
|
|
8
8
|
import { AlertCircle as Q } from "lucide-react";
|
|
9
9
|
import { useState as p } from "react";
|
|
10
10
|
import { useTranslation as V } from "react-i18next";
|
|
11
|
-
import { S as k } from "./slug-input-
|
|
11
|
+
import { S as k } from "./slug-input-P-CLfUrw.js";
|
|
12
12
|
const z = () => {
|
|
13
|
-
const s = G(),
|
|
13
|
+
const s = G(), c = $(), g = L();
|
|
14
14
|
return B({
|
|
15
15
|
mutationFn: async ({ pageId: e, name: h, slug: r }) => {
|
|
16
16
|
const u = {
|
|
@@ -23,7 +23,7 @@ const z = () => {
|
|
|
23
23
|
});
|
|
24
24
|
},
|
|
25
25
|
onSuccess: () => {
|
|
26
|
-
|
|
26
|
+
c.invalidateQueries({
|
|
27
27
|
queryKey: [U.GET_WEBSITE_PAGES]
|
|
28
28
|
}), P.success("Page duplicated successfully");
|
|
29
29
|
},
|
|
@@ -35,7 +35,7 @@ const z = () => {
|
|
|
35
35
|
});
|
|
36
36
|
}, te = ({
|
|
37
37
|
page: s,
|
|
38
|
-
onClose:
|
|
38
|
+
onClose: c,
|
|
39
39
|
closePanel: g = () => {
|
|
40
40
|
}
|
|
41
41
|
}) => {
|
|
@@ -54,15 +54,15 @@ const z = () => {
|
|
|
54
54
|
name: m
|
|
55
55
|
};
|
|
56
56
|
l || (S.slug = `${y}/${d}`), h(S, {
|
|
57
|
-
onSuccess: (
|
|
58
|
-
f(!1),
|
|
57
|
+
onSuccess: (o) => {
|
|
58
|
+
f(!1), c(), I(o.id, g);
|
|
59
59
|
},
|
|
60
|
-
onError: (
|
|
61
|
-
f(!1),
|
|
60
|
+
onError: (o) => {
|
|
61
|
+
f(!1), o.code === "SLUG_EXISTS" ? i(e("A page with this slug already exists. Please choose a different slug.")) : o.code === "INVALID_SLUG" ? i(e("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens.")) : o.code === "PERMISSION_DENIED" ? i(e("You don't have permission to duplicate this page.")) : i(o.message || e("Failed to duplicate page. Please try again later."));
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
};
|
|
65
|
-
return /* @__PURE__ */ t(T, { open: !!s, onOpenChange:
|
|
65
|
+
return /* @__PURE__ */ t(T, { open: !!s, onOpenChange: c, children: /* @__PURE__ */ a(w, { className: "sm:max-w-[425px]", children: [
|
|
66
66
|
/* @__PURE__ */ a(q, { children: [
|
|
67
67
|
/* @__PURE__ */ t(F, { children: e("Duplicate Page") }),
|
|
68
68
|
/* @__PURE__ */ t(_, { children: e("Create a copy of the page with a new name and slug") })
|
|
@@ -123,7 +123,7 @@ const z = () => {
|
|
|
123
123
|
/* @__PURE__ */ t("span", { className: "text-sm", children: u })
|
|
124
124
|
] }),
|
|
125
125
|
/* @__PURE__ */ a("div", { className: "flex justify-end gap-2", children: [
|
|
126
|
-
/* @__PURE__ */ t(v, { type: "button", variant: "outline", onClick:
|
|
126
|
+
/* @__PURE__ */ t(v, { type: "button", variant: "outline", onClick: c, disabled: r, children: e("Cancel") }),
|
|
127
127
|
/* @__PURE__ */ t(v, { type: "submit", disabled: !m.trim() || !l && !d.trim() || r || N, children: e(r || N ? "Duplicating..." : "Duplicate") })
|
|
128
128
|
] })
|
|
129
129
|
] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("./register-chai-top-bar-DyW9GPzV.cjs"),l=require("./index-DrzR7vXl.cjs"),h=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("./register-chai-top-bar-DyW9GPzV.cjs"),l=require("./index-DrzR7vXl.cjs"),h=require("./index-DXBHjFwY.cjs"),v=require("@tanstack/react-query"),P=require("sonner"),D=require("lodash-es"),C=require("lucide-react"),p=require("react"),T=require("react-i18next"),A=require("./slug-input-BvIplRdd.cjs"),w=()=>{const t=h.useApiUrl(),u=v.useQueryClient(),x=h.useFetch();return v.useMutation({mutationFn:async({pageId:s,name:j,slug:r})=>{const o={pageId:s,name:j};return r&&(o.slug=r),await x(t,{action:"DUPLICATE_PAGE",data:o})},onSuccess:()=>{u.invalidateQueries({queryKey:[h.ACTIONS.GET_WEBSITE_PAGES]}),P.toast.success("Page duplicated successfully")},onError:s=>{P.toast.error("Failed to duplicate page",{description:s.message||"An error occurred while duplicating the page"})}})},F=({page:t,onClose:u,closePanel:x=()=>{}})=>{const{t:s}=T.useTranslation(),{mutate:j,isPending:r}=w(),[o,a]=p.useState(null),[d,I]=p.useState(`${t.name} (Copy)`),b=h.useChangePage(),i=D.isEmpty(t.slug),[m,q]=p.useState(i?"":`${t.slug.split("/").pop()}-copy`),y=i?"":D.initial(t.slug.split("/")).join("/"),[S,f]=p.useState(!1),E=n=>{if(n.preventDefault(),!d.trim()){a(s("Name is required"));return}if(!i&&!m.trim()){a(s("Slug is required"));return}a(null),f(!0);const N={pageId:t.id,name:d};i||(N.slug=`${y}/${m}`),j(N,{onSuccess:c=>{f(!1),u(),b(c.id,x)},onError:c=>{f(!1),c.code==="SLUG_EXISTS"?a(s("A page with this slug already exists. Please choose a different slug.")):c.code==="INVALID_SLUG"?a(s("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens.")):c.code==="PERMISSION_DENIED"?a(s("You don't have permission to duplicate this page.")):a(c.message||s("Failed to duplicate page. Please try again later."))}})};return e.jsx(l.Dialog,{open:!!t,onOpenChange:u,children:e.jsxs(l.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{children:s("Duplicate Page")}),e.jsx(l.DialogDescription,{children:s("Create a copy of the page with a new name and slug")})]}),e.jsxs("div",{className:"mb-4 rounded-md bg-gray-50 p-3",children:[e.jsxs("h3",{className:"mb-1 text-sm font-medium",children:[s("Duplicating:"),":"]}),e.jsxs("div",{className:"flex flex-col gap-1 text-sm text-gray-700",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Name"),":"]})," ",t.name]}),!i&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Slug"),":"]})," ",t.slug]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Type"),":"]})," ",t.pageType]})]})]}),e.jsxs("form",{onSubmit:E,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l.Label,{htmlFor:"name",className:"text-sm",children:s("Name")}),e.jsx(g.Input,{id:"name",value:d,onChange:n=>I(n.target.value),required:!0})]}),!i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(l.Label,{htmlFor:"slug",className:"text-sm",children:s("Slug")}),e.jsx(A.SlugInput,{value:m,onChange:n=>q(n),parentSlug:y,onValidationChange:n=>{a(n?null:s("Invalid slug"))}})]}),o&&e.jsxs(g.Alert,{variant:"destructive",className:"py-2",children:[e.jsx(C.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(g.Button,{type:"button",variant:"outline",onClick:u,disabled:r,children:s("Cancel")}),e.jsx(g.Button,{type:"submit",disabled:!d.trim()||!i&&!m.trim()||r||S,children:s(r||S?"Duplicating...":"Duplicate")})]})]})]})})};exports.default=F;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { jsx as r, jsxs as u } from "react/jsx-runtime";
|
|
2
2
|
import { B as i, z as h } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { d as p,
|
|
4
|
-
import { l as v } from "./index-
|
|
3
|
+
import { d as p, v as m, w as f, x, y as g } from "./index-RwAuF_BE.js";
|
|
4
|
+
import { l as v } from "./index-DlTEPwjW.js";
|
|
5
5
|
import { get as w } from "lodash-es";
|
|
6
6
|
import { ChevronDown as b } from "lucide-react";
|
|
7
7
|
import { useRef as N, useEffect as y } from "react";
|
|
8
8
|
const D = ({
|
|
9
9
|
isDefaultLang: e,
|
|
10
|
-
searchQuery:
|
|
10
|
+
searchQuery: s,
|
|
11
11
|
setSearchQuery: l
|
|
12
12
|
}) => /* @__PURE__ */ r(
|
|
13
13
|
h,
|
|
14
14
|
{
|
|
15
15
|
type: "text",
|
|
16
16
|
autoFocus: !0,
|
|
17
|
-
value: e ?
|
|
17
|
+
value: e ? s : "",
|
|
18
18
|
onChange: (o) => l(o.target.value),
|
|
19
19
|
placeholder: e ? "Search pages..." : "To search select default language",
|
|
20
20
|
disabled: !e,
|
|
@@ -22,12 +22,12 @@ const D = ({
|
|
|
22
22
|
}
|
|
23
23
|
), S = ({
|
|
24
24
|
dynamicPage: e,
|
|
25
|
-
setDynamicPage:
|
|
25
|
+
setDynamicPage: s,
|
|
26
26
|
searchQuery: l,
|
|
27
27
|
setSearchQuery: o,
|
|
28
28
|
dynamicPages: a
|
|
29
29
|
}) => {
|
|
30
|
-
const { selectedLang:
|
|
30
|
+
const { selectedLang: n, fallbackLang: d } = p(), c = (n == null ? void 0 : n.length) === 0;
|
|
31
31
|
return /* @__PURE__ */ u(m, { children: [
|
|
32
32
|
/* @__PURE__ */ r(f, { asChild: !0, children: /* @__PURE__ */ u(
|
|
33
33
|
i,
|
|
@@ -45,8 +45,8 @@ const D = ({
|
|
|
45
45
|
(a == null ? void 0 : a.length) === 0 ? /* @__PURE__ */ r("div", { className: "flex h-24 items-center justify-center text-xs", children: "No pages found" }) : a == null ? void 0 : a.map((t) => /* @__PURE__ */ r(
|
|
46
46
|
g,
|
|
47
47
|
{
|
|
48
|
-
onClick: () =>
|
|
49
|
-
disabled: c ? d !== t.lang :
|
|
48
|
+
onClick: () => s(t),
|
|
49
|
+
disabled: c ? d !== t.lang : n !== t.lang,
|
|
50
50
|
className: `no-scrollbar flex cursor-pointer flex-col justify-start overflow-x-auto whitespace-nowrap ${t.id === (e == null ? void 0 : e.id) ? "bg-blue-50" : "hover:bg-gray-50"}`,
|
|
51
51
|
children: /* @__PURE__ */ r("div", { className: "w-full whitespace-nowrap px-2 py-[2px] text-xs", children: /* @__PURE__ */ u("div", { className: "flex items-center gap-x-2", children: [
|
|
52
52
|
/* @__PURE__ */ r("span", { className: "font-medium", children: t.name }),
|
|
@@ -60,21 +60,21 @@ const D = ({
|
|
|
60
60
|
}, B = () => {
|
|
61
61
|
const {
|
|
62
62
|
dynamicPage: e,
|
|
63
|
-
dynamicPages:
|
|
63
|
+
dynamicPages: s,
|
|
64
64
|
allLangPages: l,
|
|
65
65
|
selectedLang: o,
|
|
66
66
|
searchQuery: a,
|
|
67
|
-
updateDynamicPage:
|
|
67
|
+
updateDynamicPage: n,
|
|
68
68
|
updateSearchQuery: d,
|
|
69
69
|
onChangeLanguage: c
|
|
70
70
|
} = v(), t = N(void 0);
|
|
71
71
|
return y(() => {
|
|
72
72
|
t.current !== o && e && (c(), t.current = o);
|
|
73
|
-
}, [o,
|
|
73
|
+
}, [o, s]), /* @__PURE__ */ r("div", { className: "relative", children: /* @__PURE__ */ r(
|
|
74
74
|
S,
|
|
75
75
|
{
|
|
76
76
|
dynamicPage: e,
|
|
77
|
-
setDynamicPage:
|
|
77
|
+
setDynamicPage: n,
|
|
78
78
|
searchQuery: a,
|
|
79
79
|
setSearchQuery: d,
|
|
80
80
|
dynamicPages: l
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("./register-chai-top-bar-DyW9GPzV.cjs"),c=require("./index-DrzR7vXl.cjs"),h=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("./register-chai-top-bar-DyW9GPzV.cjs"),c=require("./index-DrzR7vXl.cjs"),h=require("./index-DXBHjFwY.cjs"),p=require("lodash-es"),g=require("lucide-react"),d=require("react"),f=({isDefaultLang:r,searchQuery:a,setSearchQuery:l})=>e.jsx(x.Input,{type:"text",autoFocus:!0,value:r?a:"",onChange:t=>l(t.target.value),placeholder:r?"Search pages...":"To search select default language",disabled:!r,onKeyDown:t=>t.stopPropagation()}),m=({dynamicPage:r,setDynamicPage:a,searchQuery:l,setSearchQuery:t,dynamicPages:n})=>{const{selectedLang:o,fallbackLang:i}=c.useLanguages(),u=(o==null?void 0:o.length)===0;return e.jsxs(c.DropdownMenu,{children:[e.jsx(c.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(x.Button,{variant:"ghost",className:"h-max w-max rounded-md border border-[0px] border-gray-200 py-1 pl-4 text-sm hover:bg-gray-100 focus:outline-none focus:ring-0",children:[r?p.get(r,"name"):"Select Page",e.jsx(g.ChevronDown,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(c.DropdownMenuContent,{className:"max-h-[75vh] w-96 divide-y p-0 shadow-xl",children:[e.jsx("div",{className:"bg-gray-50/30 p-1.5",children:e.jsx(f,{isDefaultLang:u,searchQuery:l,setSearchQuery:t})}),(n==null?void 0:n.length)===0?e.jsx("div",{className:"flex h-24 items-center justify-center text-xs",children:"No pages found"}):n==null?void 0:n.map(s=>e.jsx(c.DropdownMenuItem,{onClick:()=>a(s),disabled:u?i!==s.lang:o!==s.lang,className:`no-scrollbar flex cursor-pointer flex-col justify-start overflow-x-auto whitespace-nowrap ${s.id===(r==null?void 0:r.id)?"bg-blue-50":"hover:bg-gray-50"}`,children:e.jsx("div",{className:"w-full whitespace-nowrap px-2 py-[2px] text-xs",children:e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx("span",{className:"truncate rounded-full border border-gray-300 px-2 py-[1px] font-mono text-xs font-medium text-gray-500",children:s.slug})]})})},s.id))]})]})},j=()=>{const{dynamicPage:r,dynamicPages:a,allLangPages:l,selectedLang:t,searchQuery:n,updateDynamicPage:o,updateSearchQuery:i,onChangeLanguage:u}=h.useDynamicPageSelector(),s=d.useRef(void 0);return d.useEffect(()=>{s.current!==t&&r&&(u(),s.current=t)},[t,a]),e.jsx("div",{className:"relative",children:e.jsx(m,{dynamicPage:r,setDynamicPage:o,searchQuery:n,setSearchQuery:i,dynamicPages:l})})};exports.default=j;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as i, jsxs as E } from "react/jsx-runtime";
|
|
2
|
-
import { D as L, e as R } from "./index-
|
|
2
|
+
import { D as L, e as R } from "./index-RwAuF_BE.js";
|
|
3
3
|
import { debounce as S } from "lodash-es";
|
|
4
4
|
import { Save as j, Copy as D, Loader as O } from "lucide-react";
|
|
5
5
|
import { memo as P, useState as m, useEffect as x, useMemo as r, useCallback as b } from "react";
|