@chaibuilder/sdk 4.0.0-beta.38 → 4.0.0-beta.39
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-BUqDyvkj.js → 2SSKDMRQ-BcWcE20A.js} +2 -2
- package/dist/{2SSKDMRQ-Cmm80_70.cjs → 2SSKDMRQ-CrizdRp9.cjs} +1 -1
- package/dist/{AP7HFJJL-Rixab3nP.js → AP7HFJJL-CTA4QETG.js} +1 -1
- package/dist/{AP7HFJJL-C_bpDijV.cjs → AP7HFJJL-DBZaIXdU.cjs} +1 -1
- package/dist/{WDYDFRGG-Joc-MsHY.js → WDYDFRGG-DXflAYc6.js} +2 -2
- package/dist/{WDYDFRGG-Bcgsloma.cjs → WDYDFRGG-Dq7X-4LG.cjs} +1 -1
- package/dist/{active-in-another-tab-CJp4HNlP.js → active-in-another-tab-Bq_Wa7Kh.js} +1 -1
- package/dist/{active-in-another-tab-CIQzlzBZ.cjs → active-in-another-tab-CS_Xyg9M.cjs} +1 -1
- package/dist/{add-new-language-page-CSXgqNU5.js → add-new-language-page-B8L-hQcH.js} +1 -1
- package/dist/{add-new-language-page-C9UowLOR.cjs → add-new-language-page-DwrzMqcA.cjs} +1 -1
- package/dist/{add-new-page-CmkKdxHb.js → add-new-page-AV_1Z_BE.js} +1 -1
- package/dist/{add-new-page-C-0jOcj3.cjs → add-new-page-BHKNRQyt.cjs} +1 -1
- package/dist/{ai-panel-content-CEjBTXKP.js → ai-panel-content-BrPbjb_D.js} +2 -2
- package/dist/{ai-panel-content-CRLL24Tv.cjs → ai-panel-content-Doozx8LF.cjs} +1 -1
- package/dist/{ai-panel-default-lang-DCkOcBIN.cjs → ai-panel-default-lang-Bi8DGULC.cjs} +1 -1
- package/dist/{ai-panel-default-lang-V2HKlFDJ.js → ai-panel-default-lang-DQf2LA2L.js} +1 -1
- package/dist/{ai-panel-other-lang-Ccap1QP9.cjs → ai-panel-other-lang-DKTFzStW.cjs} +1 -1
- package/dist/{ai-panel-other-lang-BACuqAOo.js → ai-panel-other-lang-UyfYikvT.js} +2 -2
- package/dist/{ai-translation-prompt-CV3Pphg9.js → ai-translation-prompt-CJUenKeN.js} +1 -1
- package/dist/{ai-translation-prompt-BGdITGTs.cjs → ai-translation-prompt-DE5XCMVu.cjs} +1 -1
- package/dist/{change-password-modal-j9tdsI_2.cjs → change-password-modal-7aF0hhk-.cjs} +1 -1
- package/dist/{change-password-modal-BjUNbNkW.js → change-password-modal-CRyy3prg.js} +1 -1
- package/dist/{continue-editing-in-this-client-H3JLxXUK.js → continue-editing-in-this-client-DFvQosVX.js} +1 -1
- package/dist/{continue-editing-in-this-client-272pil3h.cjs → continue-editing-in-this-client-DW7I9Mpe.cjs} +1 -1
- package/dist/{delete-page-D8PgbaSa.js → delete-page-Bjd442Zg.js} +1 -1
- package/dist/{delete-page-Bz9yVuhF.cjs → delete-page-CVwEDtXv.cjs} +1 -1
- package/dist/{digital-asset-manager-BuIBKQrY.js → digital-asset-manager-Bh81gahp.js} +1 -1
- package/dist/{digital-asset-manager-D1DIZyiG.cjs → digital-asset-manager-CmFVa94V.cjs} +1 -1
- package/dist/{duplicate-page-qJiGrwSD.js → duplicate-page-BcjVrWcG.js} +1 -1
- package/dist/{duplicate-page-BSwuz2ak.cjs → duplicate-page-CDlNKgey.cjs} +1 -1
- package/dist/{dynamic-page-selector-C59-N_34.js → dynamic-page-selector-B4nvhjx6.js} +1 -1
- package/dist/{dynamic-page-selector-B945c22e.cjs → dynamic-page-selector-Bqm8905G.cjs} +1 -1
- package/dist/{index-B6QztICX.js → index-By4ZAgM3.js} +18 -18
- package/dist/index-DeEYXKvD.cjs +5 -0
- package/dist/{json-diff-viewer-kPE5IxCR.js → json-diff-viewer-89Jo1RMw.js} +1 -1
- package/dist/{json-diff-viewer-4PFpOzQv.cjs → json-diff-viewer-DmMae-RI.cjs} +1 -1
- package/dist/{lang-panel-B02TlFSc.cjs → lang-panel-CMxkNgMj.cjs} +1 -1
- package/dist/{lang-panel-CjEa8M_P.js → lang-panel-Dwus0Ere.js} +2 -2
- package/dist/{mark-as-template-DvKWMavv.js → mark-as-template-BsrSmjXD.js} +1 -1
- package/dist/{mark-as-template-C5EqDqmm.cjs → mark-as-template-CYam4yZo.cjs} +1 -1
- package/dist/{no-language-page-content-XewglkiB.js → no-language-page-content-Ct9N81tE.js} +1 -1
- package/dist/{no-language-page-content-BV4xcqPt.cjs → no-language-page-content-y0ZHol_q.cjs} +1 -1
- package/dist/{no-language-page-dialog-DW2TmmL1.cjs → no-language-page-dialog--aNToxYL.cjs} +1 -1
- package/dist/{no-language-page-dialog-CSYcONeC.js → no-language-page-dialog-ReXCVTbW.js} +2 -2
- package/dist/{page-creator-DsoCu0o8.js → page-creator-CA016zh5.js} +1 -1
- package/dist/{page-creator-DTpgqMLr.cjs → page-creator-npkwiskB.cjs} +1 -1
- package/dist/{page-lock-sMf1iA9z.cjs → page-lock-a6tjvGFZ.cjs} +1 -1
- package/dist/{page-lock-DN3eOz6T.js → page-lock-u-_c4KNm.js} +2 -2
- package/dist/{page-locked-dialog-DpUcmy3n.cjs → page-locked-dialog-Ba2alb7I.cjs} +1 -1
- package/dist/{page-locked-dialog-Dz8MAwEM.js → page-locked-dialog-BgYhqsTp.js} +1 -1
- package/dist/{page-manager-new-DzQb_sTK.cjs → page-manager-new-D50CT83l.cjs} +1 -1
- package/dist/{page-manager-new-TPjfGU8A.js → page-manager-new-vSAd74ha.js} +2 -2
- package/dist/{page-manager-search-and-filter-BJhl_ZxK.js → page-manager-search-and-filter-BHHMe76x.js} +1 -1
- package/dist/{page-manager-search-and-filter-C8kgR5aV.cjs → page-manager-search-and-filter-C-RUmk2F.cjs} +1 -1
- package/dist/{page-revisions-content-_H3kwIfa.cjs → page-revisions-content-BIVAWoTR.cjs} +1 -1
- package/dist/{page-revisions-content-BRG1nseD.js → page-revisions-content-DltGMooA.js} +2 -2
- package/dist/pages.cjs +1 -1
- package/dist/pages.js +1 -1
- package/dist/{publish-pages-content-CLOtvebk.js → publish-pages-content-D7szOpuc.js} +2 -2
- package/dist/{publish-pages-content-DvbbUJj3.cjs → publish-pages-content-cwvy42Ki.cjs} +1 -1
- package/dist/{save-to-lib-C4HuEFUH.js → save-to-lib-DeiLaQkZ.js} +1 -1
- package/dist/{save-to-lib-rk39Z0EK.cjs → save-to-lib-J_EuJeDc.cjs} +1 -1
- package/dist/{selected-block-display-Cz7nEg_I.cjs → selected-block-display-CNF87vmF.cjs} +1 -1
- package/dist/{selected-block-display-UVPjfycv.js → selected-block-display-QQ9XJDjM.js} +1 -1
- package/dist/{seo-panel-B8I2tcq2.cjs → seo-panel-CZClW8ir.cjs} +1 -1
- package/dist/{seo-panel-DsTInOQg.js → seo-panel-Co1nnRam.js} +1 -1
- package/dist/{shared-json-ld-BCga2JTe.js → shared-json-ld-BoiITtvd.js} +1 -1
- package/dist/{shared-json-ld-DlSg_ICN.cjs → shared-json-ld-D95s9hEi.cjs} +1 -1
- package/dist/{take-over-request-C58OJb7y.js → take-over-request-BEffb4ve.js} +1 -1
- package/dist/{take-over-request-AoVTkMXG.cjs → take-over-request-BMXtQxzX.cjs} +1 -1
- package/dist/{unmark-as-template-ZgV3cNi0.cjs → unmark-as-template-CCm3f8cE.cjs} +1 -1
- package/dist/{unmark-as-template-B9EobxLL.js → unmark-as-template-Zmv7v2cS.js} +1 -1
- package/dist/{unpublish-page-2AJbqM5f.cjs → unpublish-page-8i-1uR98.cjs} +1 -1
- package/dist/{unpublish-page-Cyx4HU4j.js → unpublish-page-BJu004pK.js} +1 -1
- package/dist/{web-preview-DTp6O2zH.js → web-preview-Bg6I0jk7.js} +1 -1
- package/dist/{web-preview-C1Hj1GDt.cjs → web-preview-BpsfCkMt.cjs} +1 -1
- package/package.json +1 -1
- package/dist/index-B3Ozovj5.cjs +0 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c, T as l, P as m, a as v, D as u, Q as i } from "./AP7HFJJL-
|
|
2
|
-
import { t as d, v as f, w as e } from "./index-
|
|
1
|
+
import { c, T as l, P as m, a as v, D as u, Q as i } from "./AP7HFJJL-CTA4QETG.js";
|
|
2
|
+
import { t as d, v as f, w as e } from "./index-By4ZAgM3.js";
|
|
3
3
|
var h = (t) => {
|
|
4
4
|
const [r, o] = c({
|
|
5
5
|
prefix: "TanstackQueryDevtools"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./AP7HFJJL-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./AP7HFJJL-DBZaIXdU.cjs"),t=require("./index-DeEYXKvD.cjs");var s=o=>{const[r,n]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),a=t.getPreferredColorScheme(),l=t.createMemo(()=>{const c=o.theme||r.theme_preference||e.THEME_PREFERENCE;return c!=="system"?c:a()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:o,get children(){return t.createComponent(e.PiPProvider,{localStore:r,setLocalStore:n,get children(){return t.createComponent(e.ThemeContext.Provider,{value:l,get children(){return t.createComponent(e.Devtools,{localStore:r,setLocalStore:n})}})}})}})},u=s;exports.default=u;
|
|
@@ -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
3
|
import { F as i, G as o, H as l, I as c, J as m } from "./index-7OSd9ssH.js";
|
|
4
|
-
import { am as d, a as h, B as u, E as p, P as N } from "./index-
|
|
4
|
+
import { am as d, a as h, B as u, E as p, P as N } from "./index-By4ZAgM3.js";
|
|
5
5
|
import { TableIcon as f, Edit as T } from "lucide-react";
|
|
6
6
|
import { useTranslation as E } from "react-i18next";
|
|
7
7
|
const b = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./register-chai-top-bar-DyW9GPzV.cjs"),t=require("./index-P-2SvZA9.cjs"),s=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./register-chai-top-bar-DyW9GPzV.cjs"),t=require("./index-P-2SvZA9.cjs"),s=require("./index-DeEYXKvD.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const r=s.useSendRealtimeEvent(),{setPageStatus:i}=s.usePageLockStatus(),{t:a}=l.useTranslation();return e.jsx(s.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-xl font-medium",children:[e.jsx(n.TableIcon,{className:"h-6 w-6 text-green-500"}),e.jsx("span",{children:a("Active in Another Tab")})]})}),e.jsx(t.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a("This page is currently being edited in another tab. You can continue editing here, which will close the editor in the other tab.")})}),e.jsx(t.CardFooter,{className:"flex justify-end gap-2",children:e.jsxs(c.Button,{variant:"default",onClick:()=>{r(s.EVENT.CONTINUE_EDITING_IN_THIS_TAB_REQUEST),i(s.PAGE_STATUS.CHECKING)},className:"gap-2",children:[e.jsx(n.Edit,{className:"h-4 w-4"}),a("Continue Editing Here")]})})]})})};exports.default=o;
|
|
@@ -2,7 +2,7 @@ import { jsx as t, jsxs as g, Fragment as hn } from "react/jsx-runtime";
|
|
|
2
2
|
import { z as fn, D as H, B as gn } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
3
|
import { d as mn, n as xn, D as vn, e as pn, f as Sn, g as Nn, o as Fn, p as I, q as wn } from "./index-7OSd9ssH.js";
|
|
4
4
|
import { p as An, r as Cn, S as Dn } from "./slug-input-DcYoeQxL.js";
|
|
5
|
-
import { e as En, f as $n, g as Ln, h as kn, i as Tn, j as Z, k as Un, c as Bn, L as A } from "./index-
|
|
5
|
+
import { e as En, f as $n, g as Ln, h as kn, i as Tn, j as Z, k as Un, c as Bn, L as A } from "./index-By4ZAgM3.js";
|
|
6
6
|
import { filter as Rn, find as Wn, startsWith as In } from "lodash-es";
|
|
7
7
|
import { Loader as qn } from "lucide-react";
|
|
8
8
|
import { useMemo as $, useState as L, useEffect as _ } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),k=require("./register-chai-top-bar-DyW9GPzV.cjs"),N=require("./index-P-2SvZA9.cjs"),Y=require("./slug-input-DHVDl_Dv.cjs"),g=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),k=require("./register-chai-top-bar-DyW9GPzV.cjs"),N=require("./index-P-2SvZA9.cjs"),Y=require("./slug-input-DHVDl_Dv.cjs"),g=require("./index-DeEYXKvD.cjs"),j=require("lodash-es"),ds=require("lucide-react"),v=require("react"),U=require("react-i18next"),Z=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=U.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(N.Label,{htmlFor:"lang",children:s("Language")}),e.jsxs("select",{value:c?"":h,disabled:c||!a.length,onChange:l=>{const x=l.target.value;t(x),!c&&(j.startsWith(u,o==null?void 0:o.name)||u.length===0)&&i(`${o==null?void 0:o.name} - ${g.LANGUAGES[x]}`)},className:"col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("option",{value:"",disabled:!0,children:c?g.LANGUAGES[h]||h:a.length?s("Choose language"):s("All available language page is created.")}),a.map(l=>e.jsx("option",{value:l,children:g.LANGUAGES[l]||l},l))]})]})},_=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=U.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(N.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(k.Input,{id:"name",value:c?h:"",onChange:i=>a(i.target.value),required:!0,placeholder:t(c?"Enter page name":"Choose language to add slug"),disabled:!u||!c})]})},cs=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:S,getSlug:f})=>{const{t:r}=U.useTranslation();return h?null:e.jsxs("div",{className:"space-y-1",children:[a&&u&&e.jsxs("div",{className:"flex items-center space-x-2 pb-1",children:[e.jsx("input",{type:"checkbox",id:"useLanguagePrefix",checked:t,onChange:A=>i(A.target.checked),className:"rounded border-gray-300"}),e.jsxs(N.Label,{htmlFor:"useLanguagePrefix",className:"text-sm font-normal leading-tight",children:["Add language code (",e.jsxs("span",{className:"font-mono text-gray-900",children:["/",u]}),") as slug prefix"]})]}),e.jsx(N.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(k.Alert,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:r("This page will use dynamic slug as defined in primary page")}):e.jsx(Y.SlugInput,{disabled:!u||!l,value:x,onChange:d,placeholder:r(u?o&&t?"Leave empty for home page":"Enter page slug":"Choose language to add slug"),parentSlug:s,onValidationChange:S,fullSlug:f()})]})},H=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:S,isPending:f})=>{const{t:r}=U.useTranslation(),A=f||!h||!a||s.some(m=>(t?m.id!==i:!0)&&m.parent===(o==null?void 0:o.id)&&m.lang===a)||!l&&!(x&&d)&&(!S||!u);return e.jsx(N.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(k.Button,{type:"submit",disabled:A&&!o.dynamic,children:f?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"loader mr-2"}),r(t?"Updating...":"Adding...")]}):r(t?"Update":"Add new language page")}),s.some(m=>(t?m.id!==i:!0)&&m.parent===(o==null?void 0:o.id)&&m.lang===a)&&e.jsx("p",{className:"mt-2 text-xs text-red-500",children:r("A page for this language already exists.")})]}):a&&e.jsx(k.Alert,{variant:"destructive",children:e.jsxs("p",{className:"mx-auto w-5/6 text-center",children:[r("You need to create the")," ",e.jsx("span",{className:"font-medium",children:g.LANGUAGES[a]})," ",r("page in the parent to add here.")]})})})},rs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:S,isHomePage:f,useLanguagePrefix:r,slug:A,isSlugValid:m,isPending:p})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(Z,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(_,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(H,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:S,isHomePage:f,useLanguagePrefix:r,isSlugValid:m,isPending:p})]}),hs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:S,useLanguagePrefix:f,setUseLanguagePrefix:r,isHomePage:A,parentSlug:m,slug:p,setSlug:C,isSlugValid:T,setIsSlugValid:I,getSlug:M,isPending:$,id:q,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(ds.Loader,{className:"animate-spin"})}):d?e.jsx(rs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:q,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:f,slug:p,isSlugValid:T,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(Z,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(_,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(cs,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:S,lang:u,useLanguagePrefix:f,setUseLanguagePrefix:r,isHomePage:A,parentSlug:m,parentHasSelectedLanguagePage:x,slug:p,setSlug:C,isSlugValid:T,setIsSlugValid:I,getSlug:M})]}),e.jsx(H,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:p,edit:a,id:q,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:f,isSlugValid:T,isPending:$})]}),xs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=g.useWebsitePrimaryPages(),s=v.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=v.useState(""),[d,S]=v.useState(""),[f,r]=v.useState(""),[A,m]=v.useState(!0),[p,C]=v.useState(!0),{mutate:T,isPending:I}=g.useCreatePage(),{mutate:M,isPending:$}=g.useUpdatePage(),q=I||$,{data:L,isFetching:b}=g.useWebsiteSetting(),z=g.useFallbackLang(),{data:w,isFetching:y}=g.useLanguagePages(u),{data:F=[],isFetching:P}=g.useLanguagePages(s==null?void 0:s.parent),{data:J=[],isFetching:O}=g.usePageTypes(),{setSelectedLang:ss}=N.useLanguages(),{t:B}=U.useTranslation(),[,es]=g.useSearchParams(),[,ns]=N.useSidebarActivePanel(),ts=b||y||P||O,G=v.useMemo(()=>j.filter(L==null?void 0:L.languages,n=>!j.find(w,{lang:n})),[L,w]),W=v.useMemo(()=>J.find(n=>n.key===(s==null?void 0:s.pageType)),[J,s==null?void 0:s.pageType]),K=!(W!=null&&W.hasSlug),V=(s==null?void 0:s.slug)==="/";v.useEffect(()=>{if(!t&&s&&i&&(S(i),x(`${s.name} - ${g.LANGUAGES[i]}`)),!t||!s)return;const n=w==null?void 0:w.find(is=>is.id===c);if(!n)return;x(n.name),S(n.lang);const E=n.slug||"",{initSlug:R,prefix:us}=Y.parseSlugForEdit(E,s);r(R),C(us)},[t,c,w,s,i]),v.useEffect(()=>{if(i)S(i);else if((G==null?void 0:G.length)===1&&!t){const n=G[0];if(!n||!g.LANGUAGES[n])return;S(n),(!l||l===(s==null?void 0:s.name))&&x(`${s==null?void 0:s.name} - ${g.LANGUAGES[n]}`)}},[i,G,t,l,s]);const{parentSlug:Q,isRootPage:D}=v.useMemo(()=>{if(V||!d)return{parentSlug:void 0,isRootPage:!(s!=null&&s.parent)};if(!(s!=null&&s.parent))return{parentSlug:p?`/${d}`:void 0,isRootPage:!0};const n=F==null?void 0:F.find(E=>E.lang===d);return{parentSlug:n==null?void 0:n.slug,isRootPage:!1}},[s==null?void 0:s.parent,F,p,d,V]),os=v.useMemo(()=>D?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,D]),X=()=>{let n="";return D?n=`/${p?[d,f].filter(Boolean).join("/"):f}`:n=`${Y.removeSlugExtension(Q)}/${f}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},ls=n=>{const E=new URLSearchParams(window.location.search);z&&n===z?E.delete("lang"):E.set("lang",n),es(E),window.dispatchEvent(new PopStateEvent("popstate"))},as=n=>{n.preventDefault();const E={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:K?"":X(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},R=()=>{!t&&d&&(ss(d),ls(d)),ns("outline"),a()};t?M(E,{onSuccess:R}):T(E,{onSuccess:R})};return e.jsx(N.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(N.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(N.DialogHeader,{children:[e.jsx(N.DialogTitle,{children:B(t?"Edit language":"Add new language page")}),e.jsx(N.DialogDescription,{className:"font-light",children:B("Enter the details for the language")})]}),e.jsx(hs,{id:c,pages:o,loading:ts,onSubmit:as,edit:t,lang:d,languages:G,name:l,setLang:S,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:os,isNonSlugPageType:K,isRootPage:D,useLanguagePrefix:p,setUseLanguagePrefix:C,isHomePage:V,parentSlug:Q,slug:f,setSlug:r,isSlugValid:A,setIsSlugValid:m,getSlug:X,isPending:q})]})})};exports.default=xs;
|
|
@@ -2,7 +2,7 @@ import { jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
|
2
2
|
import { D as t, e as c, f as m, g as p, o as h } from "./index-7OSd9ssH.js";
|
|
3
3
|
import { Suspense as f, lazy as D } from "react";
|
|
4
4
|
import { useTranslation as u } from "react-i18next";
|
|
5
|
-
const x = D(() => import("./page-creator-
|
|
5
|
+
const x = D(() => import("./page-creator-CA016zh5.js")), C = ({
|
|
6
6
|
addEditPage: o,
|
|
7
7
|
setAddEditPage: s,
|
|
8
8
|
closePanel: l
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-P-2SvZA9.cjs"),c=require("react"),a=require("react-i18next"),u=c.lazy(()=>Promise.resolve().then(()=>require("./page-creator-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-P-2SvZA9.cjs"),c=require("react"),a=require("react-i18next"),u=c.lazy(()=>Promise.resolve().then(()=>require("./page-creator-npkwiskB.cjs"))),x=({addEditPage:n,setAddEditPage:r,closePanel:l})=>{const{t:o}=a.useTranslation(),t=!!(n!=null&&n.id),i=!!n;return e.jsx(s.Dialog,{open:i,onOpenChange:()=>r(void 0),children:i&&e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{children:[o(t?"Edit":"Add New")," "]}),e.jsx(s.DialogDescription,{children:o(t?"Update your page name":"Enter details to create a new page")})]}),e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(u,{closePanel:l,addEditPage:n,close:()=>r(void 0)})})]})})};exports.default=x;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs as h, Fragment as k, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { B as y } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
3
|
import { d as A } from "./index-7OSd9ssH.js";
|
|
4
|
-
import { s as B, c as F } from "./index-
|
|
4
|
+
import { s as B, c as F } from "./index-By4ZAgM3.js";
|
|
5
5
|
import { Plus as z } from "lucide-react";
|
|
6
6
|
import { useState as l, useEffect as I, Suspense as D, lazy as x } from "react";
|
|
7
7
|
import { useTranslation as R } from "react-i18next";
|
|
8
8
|
import { toast as E } from "sonner";
|
|
9
9
|
import { g as G } from "./models-D95ZYr_x.js";
|
|
10
|
-
const O = x(() => import("./ai-panel-default-lang-
|
|
10
|
+
const O = x(() => import("./ai-panel-default-lang-DQf2LA2L.js")), T = x(() => import("./ai-panel-other-lang-UyfYikvT.js")), Z = () => {
|
|
11
11
|
const { t: r } = R(), [b, a] = l(""), [e, s] = l([]), [i, c] = l(!1), [f, u] = l(null), [w, d] = l(null), [C, L] = l(G().id), { selectedLang: m, fallbackLang: N } = A(), P = B(), [S] = F(), v = S.get("page"), M = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 4, j = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 10;
|
|
12
12
|
I(() => {
|
|
13
13
|
s([]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),L=require("./register-chai-top-bar-DyW9GPzV.cjs"),N=require("./index-P-2SvZA9.cjs"),j=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),L=require("./register-chai-top-bar-DyW9GPzV.cjs"),N=require("./index-P-2SvZA9.cjs"),j=require("./index-DeEYXKvD.cjs"),M=require("lucide-react"),s=require("react"),k=require("react-i18next"),A=require("sonner"),B=require("./models-5gOsRC56.cjs"),R=s.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-default-lang-Bi8DGULC.cjs"))),z=s.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-other-lang-DKTFzStW.cjs"))),F=()=>{const{t:o}=k.useTranslation(),[m,a]=s.useState(""),[t,l]=s.useState([]),[c,i]=s.useState(!1),[u,d]=s.useState(null),[S,f]=s.useState(null),[p,b]=s.useState(B.getDefaultModel().id),{selectedLang:h,fallbackLang:q}=N.useLanguages(),P=j.useBuilderFetch(),[v]=j.useSearchParams(),w=v.get("page"),C=(t==null?void 0:t.filter(n=>n.role==="user").length)>=4,y=(t==null?void 0:t.filter(n=>n.role==="user").length)>=10;s.useEffect(()=>{l([])},[h,w]);const g=()=>{l([]),a(""),f(null),d(null),i(!1)},x={t:o,fetch:P,input:m,messages:t,setInput:a,isLoading:c,handleStop:()=>{u&&(u.abort(),d(null)),i(!1),a(""),f(null),l(n=>{const r=n[n.length-1];return r&&r.role==="assistant"&&r.isReasoning&&r.isStreaming?n.slice(0,-1):n}),A.toast.info(o("Generation stopped"))},handleReset:g,setMessages:l,setIsLoading:i,currentBlock:S,fallbackLang:q,abortController:u,setCurrentBlock:f,setAbortController:d,forceNewConversation:y,suggestNewConversation:C,selectedModel:p,onModelChange:b};return e.jsxs(e.Fragment,{children:[c&&e.jsx("div",{className:"fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent"}),e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:o("Your conversation will not be saved")}),(t==null?void 0:t.length)>0&&e.jsx(L.Button,{variant:"outline",size:"icon",onClick:g,className:"h-6 w-6",disabled:c,children:e.jsx(M.Plus,{})})]}),e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"flex h-full w-full items-center justify-center text-xs",children:"Loading AI Panel"}),children:h?e.jsx(z,{...x,selectedLang:h}):e.jsx(R,{...x})})]})]})};exports.default=F;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),S=require("./index-P-2SvZA9.cjs"),p=require("./selected-block-display-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),S=require("./index-P-2SvZA9.cjs"),p=require("./selected-block-display-CNF87vmF.cjs"),P=require("lucide-react"),j=require("react"),W=require("sonner"),F=require("./models-5gOsRC56.cjs"),L=require("./apply-binding-BuwI_Uf5.cjs"),O=require("@tanstack/react-query"),$=()=>{const{addPredefinedBlock:k}=S.useAddBlock(),N=S.useReplaceBlock(),y=S.useRemoveBlocks(),T=O.useQueryClient(),w=async(r,e)=>{if(!e)return;const s=L.getBlocksFromHTML(e);await k(s,r.parentId,r.position)},B=async(r,e)=>{if(!r.blockId||!e)return;const s=L.getBlocksFromHTML(e);await N(r.blockId,s)},I=async r=>{!r.ids||r.ids.length===0||await y(r.ids)};let d=null;const E=(r,e)=>{const s=document.getElementById("canvas-iframe");if(!s)return null;const u=s==null?void 0:s.contentDocument;if(!u)return null;u.querySelectorAll("[data-stream-canvas]").forEach(n=>n.remove());let o=null;if(r&&r!=="undefined"&&(o=u.querySelector(`[data-block-id="${r}"]`)),o||(o=u.body),!o)return null;if(d=u.createElement("div"),d.setAttribute("data-stream-canvas","true"),e!==void 0&&e>=0&&o.children){const n=Math.min(e,o.children.length);n<o.children.length?o.insertBefore(d,o.children[n]):o.appendChild(d)}else o.appendChild(d);return d},H=r=>{var o;const e=document.getElementById("canvas-iframe");if(!e)return null;const s=e==null?void 0:e.contentDocument;if(!s)return null;s.querySelectorAll("[data-stream-canvas]").forEach(n=>n.remove());const f=s.querySelector(`[data-block-id="${r}"]`);return f?(d=s.createElement("div"),d.setAttribute("data-stream-canvas","true"),(o=f.parentNode)==null||o.insertBefore(d,f.nextSibling),f.style.display="none",d):null},M=r=>{const e=document.getElementById("canvas-iframe");(e==null?void 0:e.contentWindow)&&r.scrollIntoView({behavior:"smooth",block:"end"})},v=(r,e,s)=>{const u=E(e,s);u&&(u.innerHTML=r,M(u))},x=(r,e)=>{const s=H(e);s&&(s.innerHTML=r,M(s))},D=r=>{const e=r.match(/^--ACTION=(.+)--$/);if(!e)return null;let u=e[1].replace(/--/g,"").split("|");const o={type:u[0]};return u.forEach(n=>{const t=n.trim();if(t.startsWith("PARENT=")){const A=t.substring(7);o.parentId=A==="undefined"?void 0:A}else t.startsWith("POS=")?o.position=parseInt(t.substring(4)):t.startsWith("ID=")?o.blockId=t.substring(3):t.startsWith("IDS=")&&(o.ids=t.substring(4).split(",").map(A=>A.trim()))}),o};return j.useCallback(async(r,e)=>{const s=new TextDecoder;let u="",f="",o=!1,n=null;const t={isInAction:!1,currentAction:null,htmlBuffer:"",isCapturingHtml:!1},A=async m=>{const i=m.trim();if(i==="--START--"){o=!0;return}if(o){if(i==="--END--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await C(t.currentAction,t.htmlBuffer),d&&(d.remove(),d=null);return}if(i.startsWith("--THINKING=")){const c=i.substring(11);e(l=>{const h=[...l],g=h[h.length-1];if(g&&g.role==="assistant"&&g.isReasoning)g.content=c,g.isStreaming=!1;else{const b={id:Date.now().toString(),role:"assistant",content:c,isReasoning:!0,isStreaming:!1};h.push(b)}return h});return}if(i.startsWith("--TASK=")){const c=i.substring(7),l=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,h={id:l,role:"assistant",content:c.replace(/--$/,""),isTask:!0,isTaskLoading:!0,isTaskCompleted:!1};n=l,e(g=>[...g,h]);return}if(i.startsWith("--MSG=")){const c=i.substring(6),l={id:Date.now().toString(),role:"assistant",content:c.replace(/--$/g,""),isReasoning:!1,isStreaming:!1};e(h=>[...h,l]);return}if(i.startsWith("--ACTION=")){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await C(t.currentAction,t.htmlBuffer),t.currentAction=D(i),t.htmlBuffer="",t.isInAction=!0;return}if(i==="--ENDACTION--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await C(t.currentAction,t.htmlBuffer),n&&(e(c=>c.map(l=>l.isTask?{...l,isTaskCompleted:!0}:l)),n=null),t.currentAction=null,t.htmlBuffer="",t.isInAction=!1;return}if(i==="--HTML--"){t.isCapturingHtml=!0;return}if(i==="--ENDHTML--"){t.isCapturingHtml=!1;return}if(i.startsWith("--HTML--")&&i.includes("--ENDHTML--")){const c=i.match(/^--HTML--(.+?)--ENDHTML--$/);if(c&&t.currentAction){const l=c[1];t.htmlBuffer+=l,t.currentAction.type==="ADD"?v(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&x(t.htmlBuffer,t.currentAction.blockId)}return}t.isCapturingHtml&&t.currentAction&&(t.htmlBuffer+=m+`
|
|
2
2
|
`,t.currentAction.type==="ADD"?v(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&x(t.htmlBuffer,t.currentAction.blockId))}},C=async(m,i)=>{try{switch(m.type){case"ADD":await w(m,i);break;case"EDIT":await B(m,i);break;case"REMOVE":await I(m);break}e(c=>c.filter(l=>!l.isTask))}catch(c){console.log(c)}};try{for(;;){const{done:m,value:i}=await r.read();if(m)break;const c=s.decode(i,{stream:!0});u+=c,f+=c;const l=f.split(`
|
|
3
3
|
`);f=l.pop()||"";for(const h of l)await A(h)}f&&await A(f),T.invalidateQueries({queryKey:["AI_USAGE"]})}catch(m){console.log(m)}},[y])},V=j.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-BuP52voq.cjs"))),K=({t:k,fetch:N,input:y,messages:T,setInput:w,isLoading:B,setMessages:I,handleStop:d,setIsLoading:E,currentBlock:H,fallbackLang:M,setCurrentBlock:v,setAbortController:x,selectedModel:D=F.getDefaultModel().id,onModelChange:r})=>{const e=S.useSelectedBlock(),[,s]=S.useSelectedBlockIds(),u=S.useBlocksHtmlForAi(),f=$(),o=async(n,t,A,C)=>{var h;if(!n||B)return;v(e);const m=u(e?{blockId:e._id,additionalCoreBlocks:["Icon"]}:{additionalCoreBlocks:["Icon"]});if(e&&!m){W.toast.error(k("Something went wrong. Please try again."));return}const i={id:Date.now().toString(),role:"user",content:p.getUserPrompt({language:M,userInput:t||n,currentHtml:m}),userMessage:n},c={id:(Date.now()+1).toString(),role:"assistant",content:"",isReasoning:!0,isStreaming:!0};I(g=>[...g,i,c]),E(!0);const l=new AbortController;x(l);try{const g={messages:[i].map(q=>({role:q.role,content:q.content})),model:C||D};A&&(g.image=A);const b=await N({body:{action:"ASK_AI",data:g},streamResponse:!0});if(!b.ok)throw new Error(k("Failed to get AI response"));const R=(h=b.body)==null?void 0:h.getReader();if(!R)throw new Error(k("Response body is not readable"));await f(R,I)}catch(g){if(g.name!=="AbortError"){const b={id:(Date.now()+1).toString(),role:"assistant",content:k("Sorry, I encountered an error. Please try again.")};I(R=>[...R,b])}}finally{w(""),E(!1),v(null),x(null)}};return a.jsxs(a.Fragment,{children:[a.jsxs(p.Conversation,{className:"no-scrollbar",children:[a.jsxs(p.ConversationContent,{className:"gap-2 px-0",children:[T.length===0&&a.jsx(p.ConversationEmptyState,{icon:a.jsx(P.Bot,{size:48,className:"text-gray-300"}),title:"Start a conversation",description:k("Start a conversation with the AI assistant to add/edit current page")}),T.map(n=>n.role!=="system"&&a.jsx(j.Fragment,{children:n.isReasoning?a.jsxs(p.Reasoning,{isStreaming:n.isStreaming,defaultOpen:!0,children:[a.jsx(p.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),a.jsx(p.ReasoningContent,{className:"p-0 text-xs",children:n.content})]}):n.isTask&&!n.isTaskCompleted?a.jsx(p.TaskMessage,{content:n.content,isLoading:n.isTaskLoading}):a.jsx(p.Message,{from:n.role,children:a.jsx(p.MessageContent,{className:"p-0",children:n.role==="assistant"?a.jsx(p.MessageResponse,{className:"p-0 text-xs",children:n.content}):a.jsx("div",{className:"p-0 text-xs",children:n.userMessage||n.content})})})},n.id))]}),a.jsx(p.ConversationScrollButton,{})]}),a.jsxs("div",{className:"border-gray-200 pb-2",children:[a.jsx(p.SelectedBlockDisplay,{onRemove:()=>s([]),isLoading:B}),a.jsx(j.Suspense,{fallback:a.jsx("div",{children:"Loading..."}),children:a.jsx(V,{input:y,setInput:w,onSend:o,onStop:d,isLoading:B,selectedLang:"",currentBlock:e||H,disabled:(y==null?void 0:y.length)===0,selectedModel:D,onModelChange:r})})]})]})};exports.default=K;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as C, Fragment as W, jsx as d } from "react/jsx-runtime";
|
|
2
2
|
import { ah as F, ai as P, aj as O, R as $, a as q, ak as V } from "./index-7OSd9ssH.js";
|
|
3
|
-
import { C as j, a as K, b as _, R as G, c as z, d as Q, T as U, M as J, e as X, f as Y, h as Z, S as tt, i as et } from "./selected-block-display-
|
|
3
|
+
import { C as j, a as K, b as _, R as G, c as z, d as Q, T as U, M as J, e as X, f as Y, h as Z, S as tt, i as et } from "./selected-block-display-QQ9XJDjM.js";
|
|
4
4
|
import { Bot as nt } from "lucide-react";
|
|
5
5
|
import { useCallback as rt, Fragment as st, Suspense as ot, lazy as at } from "react";
|
|
6
6
|
import { toast as it } from "sonner";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("./index-P-2SvZA9.cjs"),s=require("./selected-block-display-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("./index-P-2SvZA9.cjs"),s=require("./selected-block-display-CNF87vmF.cjs"),G=require("lucide-react"),o=require("react"),H=require("react-i18next"),Q=require("./models-5gOsRC56.cjs"),X=o.lazy(()=>Promise.resolve().then(()=>require("./ai-translation-prompt-DE5XCMVu.cjs"))),Y=o.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-BuP52voq.cjs"))),Z=({fetch:v,input:a,messages:u,setInput:j,isLoading:c,handleStop:q,setMessages:y,setIsLoading:h,selectedLang:i,currentBlock:A,fallbackLang:P,abortController:x,setAbortController:E,setCurrentBlock:k,selectedModel:S=Q.getDefaultModel().id,onModelChange:M})=>{const{t:n}=H.useTranslation(),O=o.useRef(null),l=d.useSelectedBlock(),[,D]=d.useSelectedBlockIds(),T=d.useI18nBlocks(),I=d.useStreamMultipleBlocksProps(),C=()=>{var t;(t=O.current)==null||t.scrollIntoView({behavior:"smooth"})};o.useEffect(()=>{C()},[u,c]);const f=async(t,m,F)=>{var b;l&&k(l);const p=(t==null?void 0:t.toLowerCase())==="translate",R={id:Date.now().toString(),role:"user",content:s.getTranslationUserPrompt({fallbackLang:P,userInput:m||t,language:i,blocks:p?T():T(i)}),userMessage:m||t||n("Translate the content")},_={id:(Date.now()+1).toString(),role:"assistant",content:"Thinking...",isReasoning:!0,isStreaming:!0};h(!0);const z=new AbortController;E(z),y(w=>[...w,R,_]),h(!0);try{const N=await v({body:{action:"ASK_AI",data:{messages:[R],initiator:p?"TRANSLATE_CONTENT":"UPDATE_CONTENT",model:F||S}},streamResponse:!0});if(!N.ok)throw new Error(n("Failed to get AI response"));const B=(b=N.body)==null?void 0:b.getReader(),U=new TextDecoder;let r="";if(!B)throw new Error(n("Response body is not readable"));for(;;){const{done:K,value:V}=await B.read();if(K)break;const W=U.decode(V,{stream:!0});r+=W,y(g=>(g[g.length-1].content=r,[...g]))}const J=JSON.parse(r==null?void 0:r.replace("```json","").replace("```",""));I(J)}catch{x==null||x.abort()}finally{h(!1),j(""),k(null)}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx(o.Suspense,{fallback:e.jsx("div",{children:n("Loading...")}),children:e.jsx(X,{isLoading:c,selectedBlock:l,selectedLang:i,onClick:f})})}),e.jsx(s.Conversation,{children:e.jsxs(s.ConversationContent,{className:"gap-4 px-0",children:[u.length===0&&e.jsx(s.ConversationEmptyState,{icon:e.jsx(G.Bot,{size:48,className:"text-gray-300"}),title:n("Start a conversation with the AI assistant to translate/edit your content"),description:n("Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language.")}),u.map(t=>t.role!=="system"&&e.jsx(o.Fragment,{children:t.isReasoning?e.jsxs(s.Reasoning,{isStreaming:t.isStreaming,defaultOpen:!0,children:[e.jsx(s.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),e.jsx(s.ReasoningContent,{className:"p-0 text-xs",children:t.content})]}):t.isTask?e.jsx(s.TaskMessage,{content:t.content,isLoading:t.isTaskLoading}):e.jsx(s.Message,{from:t.role,children:e.jsx(s.MessageContent,{className:"p-0",children:t.role==="assistant"?e.jsx(s.MessageResponse,{className:"p-0 text-xs",children:t.content}):e.jsx("div",{className:"p-0 text-xs",children:t.userMessage||t.content})})})},t.id))]})}),e.jsxs("div",{className:"border-gray-200 pb-2",children:[e.jsx(s.SelectedBlockDisplay,{onRemove:()=>D([]),isLoading:c}),e.jsx(o.Suspense,{fallback:e.jsx("div",{children:n("Loading...")}),children:e.jsx(Y,{input:a,setInput:j,onSend:f,onStop:q,isLoading:c,selectedLang:i,currentBlock:l||A,disabled:(a==null?void 0:a.length)===0,selectedModel:S,onModelChange:M})})]})]})};exports.default=Z;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsxs as c, Fragment as $, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { R as G, a as H, U as Q, V as X } from "./index-7OSd9ssH.js";
|
|
3
|
-
import { C as Y, a as Z, b as L, R as ee, c as te, d as ne, T as se, M as oe, e as ae, f as re, S as ie, g as ce } from "./selected-block-display-
|
|
3
|
+
import { C as Y, a as Z, b as L, R as ee, c as te, d as ne, T as se, M as oe, e as ae, f as re, S as ie, g as ce } from "./selected-block-display-QQ9XJDjM.js";
|
|
4
4
|
import { Bot as le } from "lucide-react";
|
|
5
5
|
import { useRef as de, useEffect as ue, Suspense as B, lazy as v, Fragment as he } from "react";
|
|
6
6
|
import { useTranslation as me } from "react-i18next";
|
|
7
7
|
import { g as ge } from "./models-D95ZYr_x.js";
|
|
8
|
-
const fe = v(() => import("./ai-translation-prompt-
|
|
8
|
+
const fe = v(() => import("./ai-translation-prompt-CJUenKeN.js")), pe = v(() => import("./ai-prompt-input-CrRc0Z7y.js")), be = ({
|
|
9
9
|
fetch: A,
|
|
10
10
|
input: o,
|
|
11
11
|
messages: l,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t, jsxs as a } from "react/jsx-runtime";
|
|
2
2
|
import { B as r } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { L as i } from "./index-
|
|
3
|
+
import { L as i } from "./index-By4ZAgM3.js";
|
|
4
4
|
import { ArrowRight as c } from "lucide-react";
|
|
5
5
|
import { useTranslation as m } from "react-i18next";
|
|
6
6
|
const u = ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./register-chai-top-bar-DyW9GPzV.cjs"),i=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./register-chai-top-bar-DyW9GPzV.cjs"),i=require("./index-DeEYXKvD.cjs"),c=require("lucide-react"),o=require("react-i18next"),x=({selectedLang:s,isLoading:n,selectedBlock:a,onClick:l})=>{const{t}=o.useTranslation();return e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx("div",{className:`flex flex-col gap-2 ${n?"pointer-events-none opacity-50":""}`,children:a?e.jsx(r.Button,{variant:"outline",className:"h-auto",onClick:()=>l("TRANSLATE"),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-left text-xs font-thin",children:t("Quick Action:")}),e.jsxs("span",{className:"flex items-center gap-x-2 text-sm font-medium",children:[t("Translate Content")," ",t("to")," ",i.LANGUAGES[s]," ",e.jsx(c.ArrowRight,{className:"h-4 w-4"})]})]})}):null})})};exports.default=x;
|
|
@@ -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-P-2SvZA9.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-P-2SvZA9.cjs"),u=require("./index-DeEYXKvD.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,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
3
|
import { D as T, e as q, f as O, g as z, o as B, p as f, q as H } from "./index-7OSd9ssH.js";
|
|
4
|
-
import { ap as I, aq as M, A as E, ax as R } from "./index-
|
|
4
|
+
import { ap as I, aq as M, A as E, ax as R } from "./index-By4ZAgM3.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";
|
|
@@ -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
3
|
import { F as o, G as c, H as i, I as l, J as m } from "./index-7OSd9ssH.js";
|
|
4
|
-
import { b as d, B as h } from "./index-
|
|
4
|
+
import { b as d, B as h } from "./index-By4ZAgM3.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 = () => {
|
|
@@ -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-P-2SvZA9.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-P-2SvZA9.cjs"),a=require("./index-DeEYXKvD.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 s, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import { B as L } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
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-7OSd9ssH.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-
|
|
4
|
+
import { c as q, m as F, k as H, e as M, j as Q, n as T, L as $ } from "./index-By4ZAgM3.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-P-2SvZA9.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-P-2SvZA9.cjs"),l=require("./index-DeEYXKvD.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;
|
|
@@ -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 { ap as K, aq as Q, A as b } from "./index-
|
|
13
|
+
import { ap as K, aq as Q, A as b } from "./index-By4ZAgM3.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();
|
|
@@ -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-P-2SvZA9.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-B3Ozovj5.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-Cfn290vp.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-P-2SvZA9.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-DeEYXKvD.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-Cfn290vp.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,7 +1,7 @@
|
|
|
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
3
|
import { D as T, e as w, f as q, g as F, o as _, p as D } from "./index-7OSd9ssH.js";
|
|
4
|
-
import { ap as G, aq as L, A as U, ar as j } from "./index-
|
|
4
|
+
import { ap as G, aq as L, A as U, ar as j } from "./index-By4ZAgM3.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";
|
|
@@ -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-P-2SvZA9.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-P-2SvZA9.cjs"),h=require("./index-DeEYXKvD.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-DHVDl_Dv.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,7 +1,7 @@
|
|
|
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
3
|
import { d as p, r as m, s as f, t as x, v as g } from "./index-7OSd9ssH.js";
|
|
4
|
-
import { l as v } from "./index-
|
|
4
|
+
import { l as v } from "./index-By4ZAgM3.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";
|
|
@@ -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-P-2SvZA9.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-P-2SvZA9.cjs"),h=require("./index-DeEYXKvD.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;
|