@chaibuilder/sdk 4.0.0-beta.23 → 4.0.0-beta.24
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-DVWVGtU8.cjs → 2SSKDMRQ-C6XmPkPR.cjs} +1 -1
- package/dist/{2SSKDMRQ-SUA5eA2S.js → 2SSKDMRQ-DTcPSOGn.js} +2 -2
- package/dist/{AP7HFJJL-CUN5zddU.cjs → AP7HFJJL-6aBLUYOi.cjs} +1 -1
- package/dist/{AP7HFJJL-Co5bLh3I.js → AP7HFJJL-CVazlaEj.js} +1 -1
- package/dist/{IconPicker-BZvFj3cg.js → IconPicker-CcBoA1K0.js} +1 -1
- package/dist/{IconPicker-Bmz6vXB8.cjs → IconPicker-sbWeQ9M9.cjs} +1 -1
- package/dist/{WDYDFRGG-BpSteEEf.cjs → WDYDFRGG-BtzyRDmj.cjs} +1 -1
- package/dist/{WDYDFRGG-DjCIT9L-.js → WDYDFRGG-CwiYliX0.js} +2 -2
- package/dist/{active-in-another-tab-DfRJcvAz.js → active-in-another-tab-B4O3FEEg.js} +2 -2
- package/dist/{active-in-another-tab-C8-vpt8f.cjs → active-in-another-tab-DRJY0QqU.cjs} +1 -1
- package/dist/{add-new-language-page-jZ7Pg0Fv.js → add-new-language-page-BfYL9jXF.js} +3 -3
- package/dist/{add-new-language-page-B2BEmfil.cjs → add-new-language-page-CKIRTFjr.cjs} +1 -1
- package/dist/{add-new-page-YZF_XF8X.js → add-new-page-DVgxz4fs.js} +2 -2
- package/dist/{add-new-page-DbEBB3w7.cjs → add-new-page-dzN_CD2c.cjs} +1 -1
- package/dist/{ai-panel-content-C8ecaQnv.js → ai-panel-content-D5eFLI_B.js} +3 -3
- package/dist/{ai-panel-content-Bf_ojKwt.cjs → ai-panel-content-Dyw4RHCV.cjs} +1 -1
- package/dist/{ai-panel-default-lang-BC8Gq_jl.js → ai-panel-default-lang-Cj7meZBD.js} +3 -3
- package/dist/{ai-panel-default-lang-DokOmE_Q.cjs → ai-panel-default-lang-DEj9Qx2M.cjs} +2 -2
- package/dist/{ai-panel-other-lang-BJ30SL7z.js → ai-panel-other-lang-Cbi6HKzd.js} +3 -3
- package/dist/{ai-panel-other-lang-Ccx1t8pp.cjs → ai-panel-other-lang-Da2XLEcm.cjs} +1 -1
- package/dist/{ai-prompt-input-SfeB6a2j.js → ai-prompt-input-B6QoqT9B.js} +1 -1
- package/dist/{ai-prompt-input-ED14e6NE.cjs → ai-prompt-input-DXS8gzex.cjs} +1 -1
- package/dist/{ai-translation-prompt-BRRzei71.js → ai-translation-prompt-Dmq_Ahjf.js} +1 -1
- package/dist/{ai-translation-prompt-spS-OC6L.cjs → ai-translation-prompt-Uswft8iz.cjs} +1 -1
- package/dist/{code-editor-CIqswl5j.cjs → code-editor-DbSBrsUA.cjs} +1 -1
- package/dist/{code-editor-CYiIxUKp.js → code-editor-wQWmwFKW.js} +1 -1
- package/dist/{continue-editing-in-this-client-vICoETHN.js → continue-editing-in-this-client-BV0OrgEU.js} +2 -2
- package/dist/{continue-editing-in-this-client-B3CnmiZ2.cjs → continue-editing-in-this-client-Dkkzk8YZ.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -1
- package/dist/{css-import-modal-CHFZPXXQ.cjs → css-import-modal-C3f5sphx.cjs} +1 -1
- package/dist/{css-import-modal-DautOct0.js → css-import-modal-Co_YLkLB.js} +1 -1
- package/dist/{delete-design-token-BmWHk_Ap.js → delete-design-token-CJPAcsWp.js} +1 -1
- package/dist/{delete-design-token-D-wGR5qS.cjs → delete-design-token-zzNmNYLR.cjs} +1 -1
- package/dist/{delete-page-D5mzl-ET.cjs → delete-page-6lInxYM_.cjs} +1 -1
- package/dist/{delete-page-Dlv8srng.js → delete-page-CQTjB7ZZ.js} +2 -2
- package/dist/{design-token-usage-hl29qR_q.js → design-token-usage-BQY6eqzE.js} +1 -1
- package/dist/{design-token-usage-DIszlgJK.cjs → design-token-usage-blwlGuEE.cjs} +1 -1
- package/dist/{digital-asset-manager-v2LfDXwR.cjs → digital-asset-manager-cGUpTcu3.cjs} +1 -1
- package/dist/{digital-asset-manager-o_bNl9qj.js → digital-asset-manager-lPKoJ4FH.js} +3 -3
- package/dist/{duplicate-page-BjqgghN0.js → duplicate-page-Dmgqp93w.js} +3 -3
- package/dist/{duplicate-page-CEuF8dll.cjs → duplicate-page-rYeBMwHR.cjs} +1 -1
- package/dist/{dynamic-page-selector-BWC7kHJ1.js → dynamic-page-selector-CVyA9Zp0.js} +2 -2
- package/dist/{dynamic-page-selector-D4EWs4Qd.cjs → dynamic-page-selector-zqGqpcww.cjs} +1 -1
- package/dist/{get-chai-builder-theme-DDVRJQ6Z.js → get-chai-builder-theme-CfJkQYZc.js} +1 -1
- package/dist/{get-chai-builder-theme-BApShjRz.cjs → get-chai-builder-theme-Dm1z70lQ.cjs} +1 -1
- package/dist/{image-editor-2h5axNuk.cjs → image-editor-Cn1DgrNp.cjs} +1 -1
- package/dist/{image-editor-B1-bjvPd.js → image-editor-mVBb0VD_.js} +1 -1
- package/dist/{index-BJVYKKJq.cjs → index-B5qvHqN5.cjs} +2 -2
- package/dist/{index-DWGTiEak.cjs → index-EFWvSWoi.cjs} +11 -11
- package/dist/{index-BvluH-oT.js → index-GfOB5KV1.js} +20 -20
- package/dist/{index-BN6yEl-H.js → index-lm46VtIP.js} +889 -887
- package/dist/{json-diff-viewer-BjCIlzd7.cjs → json-diff-viewer-BeSMdSd5.cjs} +1 -1
- package/dist/{json-diff-viewer-WX0GIjq-.js → json-diff-viewer-D5yJoFh1.js} +2 -2
- package/dist/{lang-panel-C4x7bcyb.js → lang-panel-7qTejsLm.js} +3 -3
- package/dist/{lang-panel--yfjRDE2.cjs → lang-panel-B-QUotOn.cjs} +1 -1
- package/dist/{manage-design-tokens-CRwsErkx.js → manage-design-tokens-DeH-yNJN.js} +2 -2
- package/dist/{manage-design-tokens-DhdwhzQu.cjs → manage-design-tokens-TeWNZekH.cjs} +1 -1
- package/dist/{mark-as-template-BH0W9p2G.cjs → mark-as-template-Co00KkhA.cjs} +1 -1
- package/dist/{mark-as-template-DpZSFrLK.js → mark-as-template-RkfNETRW.js} +2 -2
- package/dist/{nested-path-selector-content-BDQmZzlf.js → nested-path-selector-content-Dimjyy8J.js} +1 -1
- package/dist/{nested-path-selector-content-CHYz7cdB.cjs → nested-path-selector-content-hBvmT_2A.cjs} +1 -1
- package/dist/{no-language-page-content-D0lcCseQ.js → no-language-page-content-Bk3sTsdM.js} +2 -2
- package/dist/{no-language-page-content-D7btm8zX.cjs → no-language-page-content-CLovr1bL.cjs} +1 -1
- package/dist/{no-language-page-dialog-sYOmLnpY.cjs → no-language-page-dialog-C21Fq-UD.cjs} +1 -1
- package/dist/{no-language-page-dialog-BdW7oXvt.js → no-language-page-dialog-Cx-YOrAd.js} +2 -2
- package/dist/{page-creator-O_QpbMlB.js → page-creator-BBuYY84G.js} +3 -3
- package/dist/{page-creator-B-jBAGZl.cjs → page-creator-BDmospqO.cjs} +1 -1
- package/dist/{page-lock-CmQKpw1U.js → page-lock-BrGWj326.js} +2 -2
- package/dist/{page-lock-BrVqfmVm.cjs → page-lock-DG5IvZaG.cjs} +1 -1
- package/dist/{page-locked-dialog-ChHVSk7X.cjs → page-locked-dialog-DKnQpIMB.cjs} +1 -1
- package/dist/{page-locked-dialog-BjeJOXuN.js → page-locked-dialog-DUktYJzU.js} +2 -2
- package/dist/{page-manager-new-wcsdorbd.js → page-manager-new-BfKYDWs7.js} +3 -3
- package/dist/{page-manager-new-B90zLpRY.cjs → page-manager-new-iYsDkUzG.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-Bb_Zfpsj.cjs → page-manager-search-and-filter-CIspvIW2.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-DY_NsetM.js → page-manager-search-and-filter-DVAGxnlw.js} +2 -2
- package/dist/{page-revisions-content-CVpi-467.cjs → page-revisions-content-B84UtAxm.cjs} +1 -1
- package/dist/{page-revisions-content-5h39VYXj.js → page-revisions-content-DB4mj_Cw.js} +3 -3
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +1 -0
- package/dist/pages.js +1 -1
- package/dist/{plugin-BGlQf0iy.cjs → plugin-BfC_qpW2.cjs} +10 -10
- package/dist/{plugin-C-ht41UZ.js → plugin-DVNaUexn.js} +86 -80
- package/dist/{publish-pages-content-rrfvXks4.js → publish-pages-content-BRKsIr9W.js} +3 -3
- package/dist/{publish-pages-content-BG1GIuIz.cjs → publish-pages-content-ysv37LxZ.cjs} +1 -1
- package/dist/render.cjs +1 -1
- package/dist/render.d.ts +4 -1
- package/dist/render.js +2 -2
- package/dist/{rte-widget-modal-JRoPPuju.cjs → rte-widget-modal-BS040t_9.cjs} +1 -1
- package/dist/{rte-widget-modal-29WtCMJs.js → rte-widget-modal-Dj5BvA-1.js} +1 -1
- package/dist/{save-to-lib-YvzDV5ee.cjs → save-to-lib-ClCCNy6W.cjs} +1 -1
- package/dist/{save-to-lib-Bm7R2K7j.js → save-to-lib-D3kp0ovZ.js} +2 -2
- package/dist/{selected-block-display-BAulh0Nz.js → selected-block-display-BtlTAkei.js} +2 -2
- package/dist/{selected-block-display-bdClAekS.cjs → selected-block-display-BvRoOMt9.cjs} +1 -1
- package/dist/{seo-panel-D9wnaLG-.cjs → seo-panel-CHGdB8_7.cjs} +1 -1
- package/dist/{seo-panel-CT0D3I44.js → seo-panel-C_Cnwj1-.js} +2 -2
- package/dist/{shared-json-ld-ON6LaybZ.cjs → shared-json-ld-DA0wz-k3.cjs} +1 -1
- package/dist/{shared-json-ld-CuhqVL8H.js → shared-json-ld-DPr0Douk.js} +2 -2
- package/dist/{slug-input-DNeh6LBv.js → slug-input-CqhlfgAe.js} +1 -1
- package/dist/{slug-input-CxmcQbTR.cjs → slug-input-DltqfQ3y.cjs} +1 -1
- package/dist/{take-over-request-CrILj_3q.cjs → take-over-request-Bq7OF5Gp.cjs} +1 -1
- package/dist/{take-over-request-BmeR6t3b.js → take-over-request-ByUlm_HK.js} +2 -2
- package/dist/{theme-panel-footer-D4oCAY2G.js → theme-panel-footer-DG7Z5YjD.js} +2 -2
- package/dist/{theme-panel-footer-BMx5lGB4.cjs → theme-panel-footer-XYoM6sn5.cjs} +1 -1
- package/dist/{translation-warning-modal-ChL7oDO1.cjs → translation-warning-modal-DTxxfo0H.cjs} +1 -1
- package/dist/{translation-warning-modal-BNG9m-FC.js → translation-warning-modal-DaBUipEY.js} +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/{unmark-as-template-CEEMIY1A.js → unmark-as-template-BOFHOO0_.js} +2 -2
- package/dist/{unmark-as-template-BYiyJloZ.cjs → unmark-as-template-C9EXTj0X.cjs} +1 -1
- package/dist/{unpublish-page-B0aY1JnO.cjs → unpublish-page-B5rev9W3.cjs} +1 -1
- package/dist/{unpublish-page-Bm20P3TB.js → unpublish-page-KDM7kEEV.js} +2 -2
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{web-preview-BtEn4Vc-.js → web-preview-BDgUTTr8.js} +1 -1
- package/dist/{web-preview-iQgiotU6.cjs → web-preview-CvpevNzM.cjs} +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),o=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),o=require("./index-EFWvSWoi.cjs"),L=require("./register-chai-top-bar-DWTuRU53.cjs"),p=require("@radix-ui/react-icons"),q=require("lodash-es"),d=require("react"),w=require("react-i18next"),x=({title:n,items:a,emptyLabel:r,onSelect:t,icon:i})=>s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n}),a.length>0?s.jsx("div",{className:"space-y-1",children:a.map(l=>s.jsx("button",{type:"button",onClick:()=>t(l.id),className:L.cn("group flex w-full items-center justify-between rounded-md border border-transparent bg-muted/40 px-3 py-1 text-left text-xs transition","hover:border-muted-foreground/20 hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1",l.isSelected&&"border-primary/40 bg-primary/10 text-primary"),children:s.jsxs("span",{className:"flex items-center space-x-2",children:[i&&i,s.jsx("span",{className:"truncate",children:l.label})]})},l.id))}):s.jsx("div",{className:"rounded border border-dashed border-muted px-3 py-1 text-xs text-muted-foreground",children:r})]}),C="#styles:",M=n=>{const r=[typeof n._name=="string"?n._name:void 0,typeof n._type=="string"?n._type:void 0].filter(Boolean).find(t=>t.trim().length>0);return r?r.length>40?`${r.slice(0,37)}...`:r:n._id},_=(n,a)=>{const r=`${a}`;return n.filter(t=>Object.values(t).some(i=>typeof i!="string"||!i.startsWith(C)?!1:i.includes(r))).map(t=>({id:t._id,label:M(t)}))},O=({tokenId:n,tokenName:a,children:r})=>{const{t}=w.useTranslation(),[i]=o.useBlocksStore(),[l,b]=o.useSelectedBlockIds(),g=o.useBuilderProp("pageId",""),m=o.useBuilderProp("siteWideUsage",{}),h=d.useMemo(()=>_(i,n),[i,n]),P=d.useMemo(()=>h.map(e=>({id:e.id,label:e.label,isSelected:l.includes(e.id)})),[h,l]),u=d.useMemo(()=>m?Object.entries(m).reduce((e,[f,c])=>(f===g||!(c!=null&&c.designTokens)||!Object.keys(c.designTokens).some(j=>typeof j!="string"?!1:j===n)||e.push({id:f,name:c.name||f,isPartial:!!c.isPartial}),e),[]):[],[m,a,n,g]),S=d.useMemo(()=>u.filter(e=>!e.isPartial).map(e=>({id:e.id,label:e.name})),[u]),k=d.useMemo(()=>u.filter(e=>e.isPartial).map(e=>({id:e.id,label:e.name})),[u]),v=d.useCallback(e=>{b([e])},[b]),B=o.useBuilderProp("gotoPage",q.noop),{selectedLang:N,fallbackLang:T}=o.useLanguages(),{savePageAsync:I}=o.useSavePage(),y=async e=>{e&&(await I(!0),B({pageId:e,lang:N||T}))};return s.jsxs(o.Popover,{children:[s.jsx(o.PopoverTrigger,{asChild:!0,children:r}),s.jsxs(o.PopoverContent,{side:"bottom",align:"end",className:"w-80 p-0",children:[s.jsxs("div",{className:"space-y-1 px-4 py-3",children:[s.jsx("p",{className:"text-xs font-semibold",children:a}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:t("Usage summary for this design token across your site.")})]}),s.jsxs("div",{className:"no-scrollbar max-h-64 space-y-4 overflow-y-auto px-4 pb-4",children:[s.jsx(x,{title:t("Blocks affected on this page"),items:P,emptyLabel:t("None"),onSelect:v,icon:s.jsx(p.ArrowRightIcon,{fontSize:4})}),s.jsx(x,{title:t("Blocks affected on other pages"),items:S,emptyLabel:t("None"),onSelect:y,icon:s.jsx(p.FileIcon,{fontSize:8})}),s.jsx(x,{title:t("Blocks affected on partial blocks"),items:k,emptyLabel:t("None"),onSelect:y,icon:s.jsx(p.GlobeIcon,{fontSize:8})})]})]})]})};exports.default=O;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("./register-chai-top-bar-DWTuRU53.cjs"),d=require("./index-DWGTiEak.cjs"),ee=require("./image-compression-DZ9WMmyn.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-BJVYKKJq.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-2h5axNuk.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/")&&(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-DWTuRU53.cjs"),d=require("./index-EFWvSWoi.cjs"),ee=require("./image-compression-DZ9WMmyn.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-B5qvHqN5.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-Cn1DgrNp.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/")&&(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,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as r, jsx as e, Fragment as H } from "react/jsx-runtime";
|
|
2
2
|
import { B as p, z as me } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
-
import { q as V, T as Fe, ar as _, x as q, y as P, z as G, D as Ue, e as Le, f as $e, g as Me, p as _e, r as qe, a9 as Pe } from "./index-
|
|
3
|
+
import { q as V, T as Fe, ar as _, x as q, y as P, z as G, D as Ue, e as Le, f as $e, g as Me, p as _e, r as qe, a9 as Pe } from "./index-lm46VtIP.js";
|
|
4
4
|
import { f as Ge, c as Oe } from "./image-compression-DsZ1oqpb.js";
|
|
5
5
|
import { find as Be, merge as Ke, pick as Y, first as Qe, isEmpty as Re } from "lodash-es";
|
|
6
6
|
import { ChevronLeft as ue, ChevronRight as We, Loader as B, AlertCircle as Ve, Copy as he, Pencil as He, Link as Xe, Search as Ze, RefreshCwIcon as Je, Archive as Ye, Film as et, ImageIcon as tt, Edit as it, Trash2 as at, Check as lt, Upload as rt, AlertTriangle as nt } from "lucide-react";
|
|
@@ -10,7 +10,7 @@ import { ErrorBoundary as ot } from "react-error-boundary";
|
|
|
10
10
|
import { useTranslation as ee } from "react-i18next";
|
|
11
11
|
import { toast as A } from "sonner";
|
|
12
12
|
import { useQueryClient as te, useMutation as ie, useQuery as ge } from "@tanstack/react-query";
|
|
13
|
-
import { ar as K, as as Q, A as b } from "./index-
|
|
13
|
+
import { ar as K, as as Q, A as b } from "./index-GfOB5KV1.js";
|
|
14
14
|
import { c as xe } from "./common-functions-D2lMFR6K.js";
|
|
15
15
|
const dt = () => {
|
|
16
16
|
const s = K(), n = te(), h = Q();
|
|
@@ -385,7 +385,7 @@ const xt = ({ assetId: s, onBack: n, onEdit: h, onSave: a, isSaving: c }) => {
|
|
|
385
385
|
] })
|
|
386
386
|
] })
|
|
387
387
|
] });
|
|
388
|
-
}, vt = fe.lazy(() => import("./image-editor-
|
|
388
|
+
}, vt = fe.lazy(() => import("./image-editor-mVBb0VD_.js")), yt = 25 * 1024 * 1024, Nt = ({ isUpdatingAsset: s, allowedTypes: n, uploadAssets: h, isUploadingAsset: a, onUploaded: c }) => {
|
|
389
389
|
const { t: i } = ee(), [l, I] = y(() => {
|
|
390
390
|
const o = localStorage.getItem("chai_optimize_images");
|
|
391
391
|
return o !== null ? o === "true" : !0;
|
|
@@ -1,14 +1,14 @@
|
|
|
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-CX_JkRJn.js";
|
|
3
|
-
import { D as T, e as w, f as q, g as F, p as _, q as D } from "./index-
|
|
4
|
-
import { ar as G, as as L, A as U, at as j } from "./index-
|
|
3
|
+
import { D as T, e as w, f as q, g as F, p as _, q as D } from "./index-lm46VtIP.js";
|
|
4
|
+
import { ar as G, as as L, A as U, at as j } from "./index-GfOB5KV1.js";
|
|
5
5
|
import { useQueryClient as $, useMutation as B } from "@tanstack/react-query";
|
|
6
6
|
import { toast as P } from "sonner";
|
|
7
7
|
import { isEmpty as O, initial as M } from "lodash-es";
|
|
8
8
|
import { AlertCircle as Q } from "lucide-react";
|
|
9
9
|
import { useState as p } from "react";
|
|
10
10
|
import { useTranslation as V } from "react-i18next";
|
|
11
|
-
import { S as k } from "./slug-input-
|
|
11
|
+
import { S as k } from "./slug-input-CqhlfgAe.js";
|
|
12
12
|
const z = () => {
|
|
13
13
|
const s = G(), o = $(), g = L();
|
|
14
14
|
return B({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("./register-chai-top-bar-DWTuRU53.cjs"),l=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("./register-chai-top-bar-DWTuRU53.cjs"),l=require("./index-EFWvSWoi.cjs"),h=require("./index-B5qvHqN5.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-DltqfQ3y.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-CX_JkRJn.js";
|
|
3
|
-
import { d as p, s as m, t as f, v as x, w as g } from "./index-
|
|
4
|
-
import { n as v } from "./index-
|
|
3
|
+
import { d as p, s as m, t as f, v as x, w as g } from "./index-lm46VtIP.js";
|
|
4
|
+
import { n as v } from "./index-GfOB5KV1.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-DWTuRU53.cjs"),c=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("./register-chai-top-bar-DWTuRU53.cjs"),c=require("./index-EFWvSWoi.cjs"),h=require("./index-B5qvHqN5.cjs"),p=require("lodash-es"),g=require("lucide-react"),d=require("react"),f=({isDefaultLang:r,searchQuery:a,setSearchQuery:l})=>e.jsx(x.Input,{type:"text",autoFocus:!0,value:r?a:"",onChange:t=>l(t.target.value),placeholder:r?"Search pages...":"To search select default language",disabled:!r,onKeyDown:t=>t.stopPropagation()}),m=({dynamicPage:r,setDynamicPage:a,searchQuery:l,setSearchQuery:t,dynamicPages:n})=>{const{selectedLang:o,fallbackLang:i}=c.useLanguages(),u=(o==null?void 0:o.length)===0;return e.jsxs(c.DropdownMenu,{children:[e.jsx(c.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(x.Button,{variant:"ghost",className:"h-max w-max rounded-md border border-[0px] border-gray-200 py-1 pl-4 text-sm hover:bg-gray-100 focus:outline-none focus:ring-0",children:[r?p.get(r,"name"):"Select Page",e.jsx(g.ChevronDown,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(c.DropdownMenuContent,{className:"max-h-[75vh] w-96 divide-y p-0 shadow-xl",children:[e.jsx("div",{className:"bg-gray-50/30 p-1.5",children:e.jsx(f,{isDefaultLang:u,searchQuery:l,setSearchQuery:t})}),(n==null?void 0:n.length)===0?e.jsx("div",{className:"flex h-24 items-center justify-center text-xs",children:"No pages found"}):n==null?void 0:n.map(s=>e.jsx(c.DropdownMenuItem,{onClick:()=>a(s),disabled:u?i!==s.lang:o!==s.lang,className:`no-scrollbar flex cursor-pointer flex-col justify-start overflow-x-auto whitespace-nowrap ${s.id===(r==null?void 0:r.id)?"bg-blue-50":"hover:bg-gray-50"}`,children:e.jsx("div",{className:"w-full whitespace-nowrap px-2 py-[2px] text-xs",children:e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx("span",{className:"truncate rounded-full border border-gray-300 px-2 py-[1px] font-mono text-xs font-medium text-gray-500",children:s.slug})]})})},s.id))]})]})},j=()=>{const{dynamicPage:r,dynamicPages:a,allLangPages:l,selectedLang:t,searchQuery:n,updateDynamicPage:o,updateSearchQuery:i,onChangeLanguage:u}=h.useDynamicPageSelector(),s=d.useRef(void 0);return d.useEffect(()=>{s.current!==t&&r&&(u(),s.current=t)},[t,a]),e.jsx("div",{className:"relative",children:e.jsx(m,{dynamicPage:r,setDynamicPage:o,searchQuery:n,setSearchQuery:i,dynamicPages:l})})};exports.default=j;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("./plugin-
|
|
1
|
+
"use strict";const o=require("./plugin-BfC_qpW2.cjs"),e=o.plugin(function({addBase:n,theme:i}){n({"h1,h2,h3,h4,h5,h6":{fontFamily:i("fontFamily.heading")},body:{fontFamily:i("fontFamily.body"),color:i("colors.foreground"),backgroundColor:i("colors.background")}})}),r=(n=o.defaultThemeOptions)=>({container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},...o.getChaiThemeOptions(n)});exports.chaiBuilderPlugin=e;exports.getChaiBuilderTheme=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),b=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),b=require("./index-EFWvSWoi.cjs"),S=require("lodash-es"),c=require("lucide-react"),a=require("react"),T=require("react-filerobot-image-editor"),k=require("react-i18next"),h=a.memo(({imageUrl:l,onSave:u,onClose:m,defaultSavedImageName:y,isEditing:f=!1})=>{const{t:n}=k.useTranslation(),[v,i]=a.useState(!1),[p,I]=a.useState(!0),[w,j]=a.useState(!1);a.useEffect(()=>{const e=new Image;return e.src=l,e.onload=()=>j(!0),()=>{e.onload=null}},[l]),a.useEffect(()=>{const e=t=>{t.key==="Escape"&&p&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[]);const g=a.useMemo(()=>S.debounce(async(e,t=!1)=>{i(!0);const s=e.imageBase64;await u(s,t),I(!1),i(!1)},300),[u]),r=a.useCallback((e,t=!1)=>{g(e,t)},[g]),x=a.useCallback(()=>{I(!1),m()},[m]),d=a.useMemo(()=>({tabsIds:["Adjust","Annotate","Watermark","Finetune","Resize","Filters"],toolsIds:["Rotate"],defaultTabId:"Adjust",defaultToolId:"Rotate"}),[]),C=a.useMemo(()=>({colors:{primary:"#000000",secondary:"#000000",tertiary:"#000000"}}),[]),E=a.useMemo(()=>f?[{label:n("Update this file"),onClick:(e,t)=>t((...s)=>{i(!0),r(s[0],!1)}),icon:c.Save},{label:n("Save as new file"),onClick:(e,t)=>t((...s)=>{i(!0),r(s[0],!0)}),icon:c.Copy}]:[],[f,r,n]);return o.jsx(b.Dialog,{open:!0,onOpenChange:e=>!e&&x(),children:o.jsxs(b.DialogContent,{id:"chai-image-editor-container",className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4 p-0",children:[v&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 text-white",children:o.jsx(c.Loader,{className:"h-4 w-4 animate-spin"})}),p&&w&&o.jsx(T,{theme:C,source:l,onSave:r,onClose:x,Text:{text:n("Add text here")},Rotate:{angle:90,componentType:"slider"},tabsIds:d.tabsIds,defaultTabId:d.defaultTabId,defaultToolId:d.defaultToolId,savingPixelRatio:20,previewPixelRatio:6,defaultSavedImageName:y,moreSaveOptions:E,useZoomPresetsMenu:!0})]})})});h.displayName="ImageEditor";exports.default=h;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as i, jsxs as E } from "react/jsx-runtime";
|
|
2
|
-
import { D as L, e as R } from "./index-
|
|
2
|
+
import { D as L, e as R } from "./index-lm46VtIP.js";
|
|
3
3
|
import { debounce as S } from "lodash-es";
|
|
4
4
|
import { Save as j, Copy as D, Loader as O } from "lucide-react";
|
|
5
5
|
import { memo as P, useState as m, useEffect as x, useMemo as r, useCallback as b } from "react";
|