@chaibuilder/pages 0.15.14 → 0.15.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/{2AITGKQY-BGvx_OEz.cjs → 2AITGKQY-CuxhppUA.cjs} +1 -1
  2. package/dist/{2AITGKQY-CCad8XK8.js → 2AITGKQY-JdTvsit7.js} +2 -2
  3. package/dist/{NCMVHL6D-Iv9ufIUy.js → NCMVHL6D-CTrkJrNW.js} +2 -2
  4. package/dist/{NCMVHL6D-C_u5lHQe.cjs → NCMVHL6D-rzEn9a-Z.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-DT4dg62a.js → ZDWCUMSJ-DIAJ5hj-.js} +1 -1
  6. package/dist/{ZDWCUMSJ-BqZPKNlU.cjs → ZDWCUMSJ-DZa1ZX5H.cjs} +1 -1
  7. package/dist/{add-new-language-page-CfH8Ernl.js → add-new-language-page-3fFJlIi4.js} +2 -2
  8. package/dist/{add-new-language-page-DlQjzp--.cjs → add-new-language-page-DPbVVRnt.cjs} +1 -1
  9. package/dist/{add-new-page-DX1aQA56.js → add-new-page-C-DdGfOJ.js} +1 -1
  10. package/dist/{add-new-page-DH-nv7ae.cjs → add-new-page-CgsPADOI.cjs} +1 -1
  11. package/dist/{delete-page-DE-nabXs.js → delete-page-X6KE9Snl.js} +1 -1
  12. package/dist/{delete-page-WPGzECyJ.cjs → delete-page-ftu1i43t.cjs} +1 -1
  13. package/dist/{digital-asset-manager-DtWIJGhf.js → digital-asset-manager-CWneIIcn.js} +1 -1
  14. package/dist/{digital-asset-manager-CGLE6VEW.cjs → digital-asset-manager-zEPka3BT.cjs} +1 -1
  15. package/dist/{duplicate-page-C1r3iBDY.js → duplicate-page-Bwp0RTTE.js} +2 -2
  16. package/dist/{duplicate-page-CByLwz0z.cjs → duplicate-page-D-2tkgsd.cjs} +1 -1
  17. package/dist/{dynamic-page-selector-GwGV0Q6Z.cjs → dynamic-page-selector-DDyEyh7e.cjs} +1 -1
  18. package/dist/{dynamic-page-selector-Bk8_xgFx.js → dynamic-page-selector-Vl0aOeHK.js} +1 -1
  19. package/dist/{index-Djepisz3.js → index-DHfaX2M6.js} +1179 -1213
  20. package/dist/index-DOlBrCPx.cjs +5 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.ts +12 -8
  23. package/dist/index.js +19 -18
  24. package/dist/{json-diff-viewer-zKpzQFxw.js → json-diff-viewer-BCtaXLmG.js} +1 -1
  25. package/dist/{json-diff-viewer-BUhKwjf9.cjs → json-diff-viewer-CM1kUeoR.cjs} +1 -1
  26. package/dist/{lang-panel-CtpuO-KH.js → lang-panel-CaOkz8d3.js} +2 -2
  27. package/dist/{lang-panel-BYF6aLAt.cjs → lang-panel-DNQEDZ5D.cjs} +1 -1
  28. package/dist/{mark-as-template-wRAGJGtp.cjs → mark-as-template-CD1bYgow.cjs} +1 -1
  29. package/dist/{mark-as-template-0kikl0oL.js → mark-as-template-XIeQkqPw.js} +1 -1
  30. package/dist/{no-language-page-content-DX9WXKXs.cjs → no-language-page-content-BHacGf6H.cjs} +1 -1
  31. package/dist/{no-language-page-content-B1M_x_U7.js → no-language-page-content-CtN5VB9K.js} +1 -1
  32. package/dist/{page-creator-DuN5JD41.cjs → page-creator-C7j6rkr2.cjs} +1 -1
  33. package/dist/{page-creator-BDJ6iDX9.js → page-creator-Ci3yqsDv.js} +2 -2
  34. package/dist/{page-lock-request-Bc_vwJhy.js → page-lock-request-01G9AeVF.js} +1 -1
  35. package/dist/{page-lock-request-PRQo0DDm.cjs → page-lock-request-BNS3-biN.cjs} +1 -1
  36. package/dist/{page-locked-by-dialog-DiKNpVwH.js → page-locked-by-dialog-BQV9X0UF.js} +1 -1
  37. package/dist/{page-locked-by-dialog-Dk0G2l7a.cjs → page-locked-by-dialog-Cei-v0MT.cjs} +1 -1
  38. package/dist/{page-manager-new-CUHqC9Og.js → page-manager-new-DE_2H_ow.js} +2 -2
  39. package/dist/{page-manager-new-KBhn93Yd.cjs → page-manager-new-XGKr4mup.cjs} +1 -1
  40. package/dist/{page-manager-search-and-filter-CJ4AK1_7.js → page-manager-search-and-filter-B8zCpxug.js} +1 -1
  41. package/dist/{page-manager-search-and-filter-Ck5_TfNx.cjs → page-manager-search-and-filter-BDw2AYXn.cjs} +1 -1
  42. package/dist/{page-revisions-content-Cw2cumYS.cjs → page-revisions-content-BIdaOcUx.cjs} +1 -1
  43. package/dist/{page-revisions-content-q1Ch2-IQ.js → page-revisions-content-mih9gx3J.js} +2 -2
  44. package/dist/{publish-pages-content-B8Uuw29Q.cjs → publish-pages-content-1knN5SPM.cjs} +1 -1
  45. package/dist/{publish-pages-content-DEHD8qkl.js → publish-pages-content-jYi-Q1Vl.js} +2 -2
  46. package/dist/{save-to-lib-B83ZH4XX.cjs → save-to-lib-B56XAto8.cjs} +1 -1
  47. package/dist/{save-to-lib-QEOpf_Bd.js → save-to-lib-CpFEdU_R.js} +1 -1
  48. package/dist/{seo-panel-DEQfOfZs.js → seo-panel-D3bp2i90.js} +1 -1
  49. package/dist/{seo-panel-DvDEatlO.cjs → seo-panel-DRb3uTUp.cjs} +1 -1
  50. package/dist/{shared-json-ld-Cyv9JitF.js → shared-json-ld-C4Kjka5m.js} +1 -1
  51. package/dist/{shared-json-ld-D5F8RuF2.cjs → shared-json-ld-pNjN-zzY.cjs} +1 -1
  52. package/dist/{slug-input-3vWL9FPC.cjs → slug-input-BeepGXWz.cjs} +1 -1
  53. package/dist/{slug-input-D4e2anEs.js → slug-input-CKIckRno.js} +1 -1
  54. package/dist/{theme-panel-footer-4dbLfEph.cjs → theme-panel-footer-B0NRCfkL.cjs} +1 -1
  55. package/dist/{theme-panel-footer-D3Gub87c.js → theme-panel-footer-DscF7mar.js} +1 -1
  56. package/dist/{unmark-as-template-Dkc7zLZr.cjs → unmark-as-template-9-wHwCPl.cjs} +1 -1
  57. package/dist/{unmark-as-template-BENGNo7g.js → unmark-as-template-Dezq0GEM.js} +1 -1
  58. package/dist/{unpublish-page-D5tWKVLY.js → unpublish-page-COPOrCk_.js} +1 -1
  59. package/dist/{unpublish-page-Cui0tgvd.cjs → unpublish-page-DU3jKAJ5.cjs} +1 -1
  60. package/dist/{web-preview-CcPTcMio.cjs → web-preview-DBBTePPU.cjs} +1 -1
  61. package/dist/{web-preview-CHNZZcqH.js → web-preview-sSS97N-o.js} +1 -1
  62. package/package.json +1 -1
  63. package/dist/index-BELYt0c9.cjs +0 -5
@@ -0,0 +1,5 @@
1
+ "use strict";var $n=Object.defineProperty;var ms=e=>{throw TypeError(e)};var Wn=(e,t,s)=>t in e?$n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var he=(e,t,s)=>Wn(e,typeof t!="symbol"?t+"":t,s),Es=(e,t,s)=>t.has(e)||ms("Cannot "+s);var _=(e,t,s)=>(Es(e,t,"read from private field"),s?s.call(e):t.get(e)),M=(e,t,s)=>t.has(e)?ms("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),G=(e,t,s,n)=>(Es(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);const o=require("react/jsx-runtime"),p=require("lodash-es"),h=require("react"),V=require("jotai"),P=require("@tanstack/react-query"),w=require("@chaibuilder/sdk"),F=require("sonner"),m=require("@chaibuilder/sdk/ui"),v=require("lucide-react"),Ls=require("@chaibuilder/runtime"),Yn=require("@chaibuilder/sdk/web-blocks");function Jn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const z=Jn(h),y={GET_GLOBAL_JSONLD_ITEMS:"GET_GLOBAL_JSONLD_ITEMS",GENERATE_SEO_FIELD:"GENERATE_SEO_FIELD",UPDATE_PAGE_METADATA:"UPDATE_PAGE_METADATA",GET_BLOCK_ASYNC_PROPS:"GET_BLOCK_ASYNC_PROPS",ASK_AI:"ASK_AI",GET_DRAFT_PAGE:"GET_DRAFT_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",DUPLICATE_PAGE:"DUPLICATE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_SETTINGS:"UPDATE_WEBSITE_SETTINGS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_DRAFT_SETTINGS:"GET_WEBSITE_DRAFT_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA",GET_PAGE_REVISIONS:"GET_PAGE_REVISIONS",DELETE_PAGE_REVISION:"DELETE_PAGE_REVISION",RESTORE_PAGE_REVISION:"RESTORE_PAGE_REVISION",GET_REVISION_DATA:"GET_REVISION_DATA",GET_PAGE_DATA:"GET_PAGE_DATA",GET_COMPARE_DATA:"GET_COMPARE_DATA",GET_ROLE_AND_PERMISSIONS:"GET_ROLE_AND_PERMISSIONS",UPSERT_LIBRARY_ITEM:"UPSERT_LIBRARY_ITEM",GET_LIBRARIES:"GET_LIBRARIES",GET_LIBRARY_ITEM:"GET_LIBRARY_ITEM",GET_LIBRARY_ITEMS:"GET_LIBRARY_ITEMS",DELETE_LIBRARY_ITEM:"DELETE_LIBRARY_ITEM",MARK_AS_TEMPLATE:"MARK_AS_TEMPLATE",UNMARK_AS_TEMPLATE:"UNMARK_AS_TEMPLATE",GET_TEMPLATES_BY_TYPE:"GET_TEMPLATES_BY_TYPE",GET_DYNAMIC_PAGES:"GET_DYNAMIC_PAGES",GET_APP_SHARED_JSONLD:"GET_APP_SHARED_JSONLD",UPDATE_APP_SHARED_JSONLD:"UPDATE_APP_SHARED_JSONLD",ADD_GLOBAL_SCHEMA:"ADD_GLOBAL_SCHEMA",UPDATE_GLOBAL_SCHEMA:"UPDATE_GLOBAL_SCHEMA",DELETE_GLOBAL_SCHEMA:"DELETE_GLOBAL_SCHEMA",TOGGLE_PAGE_GLOBAL_SCHEMA:"TOGGLE_PAGE_GLOBAL_SCHEMA",APPLY_SCHEMA_TO_ALL_PAGES:"APPLY_SCHEMA_TO_ALL_PAGES",REMOVE_SCHEMA_FROM_ALL_PAGES:"REMOVE_SCHEMA_FROM_ALL_PAGES",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},Xn=V.atom({}),jt=()=>V.useAtom(Xn),se=(e,t)=>{const[s]=jt();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},k=()=>se("apiUrl","/chai/api"),js=()=>se("usersApiUrl","/chai/users"),Zn=()=>se("assetsApiUrl","/chai/assets"),er=()=>se("websocket",null),tr=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),sr=()=>{const e=j(),t=k();return h.useCallback(async({body:s,headers:n={},url:r=t})=>e(r,s,n),[e])},j=()=>{const e=se("onLogout"),t=se("getAccessToken"),s=k();return h.useCallback(async(n=s,r,a={})=>{const i=await t();if(!i)return console.error("No auth token found"),null;try{const l=p.get(r,"action","").toLowerCase(),c=await tr(n+(l?`?action=${l}`:""),r,{...a,Authorization:`Bearer ${i}`});if(c.status===401)return console.log("401 Response",c),e(),window.location.reload(),null;if(!c.ok){const u=await c.json();throw console.error(`API Error (${c.status}):`,u),{status:c.status,statusText:c.statusText,...u,message:u.error||u.message||`Server error: ${c.status}`}}return await c.json()}catch(l){throw console.error("API request failed:",r,l),l}},[e,t])};function ee(){const[e,t]=h.useState(new URLSearchParams(window.location.search));return h.useEffect(()=>{const s=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[]),[e,t]}const pe=e=>{const t=k(),[s]=ee(),n=e??s.get("page"),r=j();return P.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,n],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!n)return null;const a=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:n}});return p.reverse(p.sortBy(a,"primaryPage"))},enabled:!!n})},ye=()=>{const e=k(),t=j();return P.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:5*60*1e3,placeholderData:{languages:[],theme:{fontFamily:"",borderRadius:"",colors:{}},appKey:"",fallbackLang:""},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},ts=e=>{const{fallbackLang:t}=w.useLanguages(),{data:s}=ye(),{data:n,isFetching:r}=pe(),a=h.useMemo(()=>{const i={[t]:!0};return p.each(p.get(s,"languages"),l=>{const c=p.find(n,{lang:l});i[l]=!!c}),i},[t,n,s]);return r||p.isEmpty(e)||e&&a[e]};class ks{constructor(t,s,n,r){he(this,"channelId");he(this,"websocket");he(this,"channel",null);he(this,"userId",null);he(this,"clientId",null);he(this,"pageId",null);he(this,"callback");var a,i,l,c,u,f;this.userId=n,this.websocket=t,this.clientId=this.getClientId(),this.channelId=`WEBSITE:${s}`,this.callback=r,this.channel=this.websocket.channel(this.channelId,{config:{presence:{key:this.clientId}}}),(f=(u=(c=(l=(i=(a=this.channel)==null?void 0:a.on("presence",{event:"sync"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:i.on("presence",{event:"leave"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:l.on("presence",{event:"join"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:c.on("broadcast",{event:"TAKE_OVER_REQUESTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUESTED",d)))==null?void 0:u.on("broadcast",{event:"TAKE_OVER_REQUEST_ACCEPTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUEST_ACCEPTED",d)))==null||f.on("broadcast",{event:"TAKE_OVER_REQUEST_REJECTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUEST_REJECTED",d)).subscribe()}getClientId(){return crypto.randomUUID()}getOnlineUsers({pageId:t,userId:s}){var a;const n=(a=this.channel)==null?void 0:a.presenceState();let r=Object.values(n||{}).map(i=>i[0]).filter(Boolean);return t?r=r.filter(i=>i.pageId===t):s&&(r=r.filter(i=>i.userId===s)),r.sort((i,l)=>i.onlineAt-l.onlineAt)}getPageOwner(){const t=this.getOnlineUsers({pageId:this.pageId});return t.length>0?t[0]:null}getPageUserMapping(){const t=this.getOnlineUsers({}),s=p.groupBy(t,"pageId"),n={};return Object.keys(s).forEach(r=>{var i;const a=(i=p.minBy(s[r],"onlineAt"))==null?void 0:i.userId;a!==this.userId&&(n[r]=a)}),n}onReceiveEvent(t,s){if(!this.pageId)return;const n=this.getPageOwner();if(!n||n.clientId===this.clientId?this.callback("USER_JOINED",{isActiveInOtherTab:!1}):this.callback("PAGE_LOCKED",{isActiveInOtherTab:(n==null?void 0:n.userId)===this.userId&&(n==null?void 0:n.clientId)!==this.clientId}),s.targetClientId===this.clientId)switch(t){case"TAKE_OVER_REQUESTED":this.callback("TAKE_OVER_REQUESTED",{requestedBy:s==null?void 0:s.userId,requestingClientId:s==null?void 0:s.senderClientId,isRequestedFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_ACCEPTED":this.channel.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:n?n.onlineAt-10:+new Date}),this.callback("TAKE_OVER_REQUEST_ACCEPTED",{isTakingOverFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_REJECTED":this.callback("TAKE_OVER_REQUEST_REJECTED");break}}async joinPage(t){var s;this.pageId=t,(s=this.channel)==null||s.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:+new Date})}async leavePage(){var t;this.channel&&((t=this.channel)==null||t.untrack())}async sendEvent(t,s){var n,r;if(this.channel){const a={pageId:this.pageId,userId:this.userId,senderClientId:this.clientId};t==="TAKE_OVER_REQUESTED"?a.targetClientId=(n=this.getPageOwner())==null?void 0:n.clientId:(t==="TAKE_OVER_REQUEST_ACCEPTED"||t==="TAKE_OVER_REQUEST_REJECTED")&&(a.targetClientId=s==null?void 0:s.requestingClientId),await((r=this.channel)==null?void 0:r.send({event:t,payload:a,type:"broadcast"}))}}}const nr=V.atom(null),Ds=()=>V.useAtom(nr),ss=()=>{const[e]=Ds();return(e==null?void 0:e.slug)||""};function rr(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const ar=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=w.useLanguages(),{data:r}=X(),a=r==null?void 0:r.pageType,i=k(),l=j(),{data:c,isFetching:u}=P.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:60*60*1e3,placeholderData:[],queryFn:async()=>await l(i,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),f=h.useMemo(()=>s===""?c.filter(d=>d.lang===""||d.lang===n):c.filter(d=>d.lang===s),[s,n,c]);return{allLangPages:c,data:f,isFetching:u}},Os=()=>{const{selectedLang:e,fallbackLang:t}=w.useLanguages(),[s,n]=Ds(),[r,a]=h.useState(""),i=rr(r,500),{allLangPages:l,data:c,isFetching:u}=ar({query:i}),f=h.useCallback(E=>n(E),[n]),d=h.useCallback(E=>a(E),[a]),g=h.useCallback(()=>{if(!s)return;const E=!(s!=null&&s.primaryPage),S=e.length===0,x=E?s==null?void 0:s.id:s==null?void 0:s.primaryPage,T=l.filter(C=>(C==null?void 0:C.primaryPage)===x||C.id===x).find(C=>S?C.lang===e||C.lang===t:C.lang===e);n(T||s)},[s,e,l,n,t]);return{isFetching:u,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:f,updateSearchQuery:d,onChangeLanguage:g}},ir=V.atom({lastSaved:void 0}),kt=()=>V.useAtom(ir),X=()=>{const[e]=ee(),t=e.get("page"),{data:s,isFetching:n}=pe();return{data:h.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},ue=()=>{const[e]=ee(),t=e.get("lang")??"",{data:s,isFetching:n}=pe();return{data:h.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},or=V.atom({}),lr=()=>V.useAtom(or),cr=()=>{const{data:e}=ue(),t=ss(),s=se("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},gt=()=>{const e=se("currentUser"),t=se("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},Gs=e=>{const t=js(),s=j();return P.useQuery({queryKey:[y.GET_CHAI_USER,e],queryFn:async()=>{const r=await s(t,{action:y.GET_CHAI_USER,data:{userId:e}});return{...r,name:r.name||r.email}},enabled:!p.isEmpty(e),staleTime:"static"})},ur=V.atom({status:"checking",requestedBy:"",isTakeOverRequested:!1,requestingClientId:"",isActiveInOtherTab:!1}),dr=V.atom(""),fr=V.atom(null),ns=V.atom({}),hr=()=>V.useAtom(ns),Ae=()=>{const[e]=ee(),t=e.get("page"),[s,n]=V.useAtom(ur),[r,a]=V.useAtom(fr),[i,l]=V.useAtom(dr),[c]=V.useAtom(ns);return{pageLock:s,pageToUser:c,lockingStatus:i,realtimeInstance:r,setPageLock:n,setLockingStatus:l,setRealtimeInstance:a,realtimePageLockEnabled:!!r,currentEditor:c[t||""],isLocked:t&&s.status==="locked"}},gr=()=>{const e=er(),{data:t}=X(),{user:s}=gt(),n=t==null?void 0:t.id,{data:r}=ye(),{pageLock:a,setPageLock:i,setLockingStatus:l,realtimeInstance:c,setRealtimeInstance:u}=Ae(),[,f]=V.useAtom(ns),d=h.useRef(!1),g=h.useRef(a),E=h.useRef(!1);return h.useEffect(()=>{if(s!=null&&s.id&&e&&!c&&(r!=null&&r.appKey)&&!E.current){E.current=!0;const S=async(A,T)=>{var C,N;switch(A){case"UPDATE_ONLINE_USERS":f((T==null?void 0:T.pageToUser)||{});break;case"PAGE_LOCKED":i({...g==null?void 0:g.current,requestedBy:"",status:"locked",isActiveInOtherTab:T==null?void 0:T.isActiveInOtherTab});break;case"USER_JOINED":if(((C=g==null?void 0:g.current)==null?void 0:C.status)==="editing")return;((N=g==null?void 0:g.current)==null?void 0:N.status)==="locked"&&l("can_edit_now"),i({...g==null?void 0:g.current,requestedBy:"",status:"editing",isActiveInOtherTab:T==null?void 0:T.isActiveInOtherTab});break;case"TAKE_OVER_REQUESTED":i({...g==null?void 0:g.current,requestingClientId:T==null?void 0:T.requestingClientId,requestedBy:T!=null&&T.isRequestedFromAnotherTab?"ANOTHER_TAB":T==null?void 0:T.requestedBy});break;case"TAKE_OVER_REQUEST_ACCEPTED":T!=null&&T.isTakingOverFromAnotherTab||(l("take_over_request_accepted"),F.toast.success("Your Page Take Over Request Accepted",{position:"top-center"})),i({...g==null?void 0:g.current,status:"editing",requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break;case"TAKE_OVER_REQUEST_REJECTED":l("take_over_request_rejected"),i({...g==null?void 0:g.current,requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break}},x=new ks(e,r==null?void 0:r.appKey,s==null?void 0:s.id,S);u(x)}},[u,e,r==null?void 0:r.appKey]),h.useEffect(()=>{g.current=a},[a]),h.useEffect(()=>{if(!(!c||!n||!(s!=null&&s.id)||d.current))return d.current=!0,c==null||c.joinPage(n),()=>{c&&d.current&&(d.current=!1,g.current={requestedBy:"",status:"checking",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1},l(""),i(g.current),c==null||c.leavePage())}},[n,c]),a==null?void 0:a.status},Rs=()=>{const{data:e}=X(),{user:t}=gt(),s=e==null?void 0:e.id,{pageLock:n,setPageLock:r,realtimeInstance:a}=Ae(),{savePageAsync:i}=w.useSavePage(),l=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(r({...n,isTakeOverRequested:!0}),a==null||a.sendEvent("TAKE_OVER_REQUESTED"))},[a,s,t==null?void 0:t.id,r,n]),c=h.useCallback(async()=>{!a||!s||!(t!=null&&t.id)||(await i(),a==null||a.sendEvent("TAKE_OVER_REQUEST_ACCEPTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({requestedBy:"",status:"locked",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,i,n]),u=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(a==null||a.sendEvent("TAKE_OVER_REQUEST_REJECTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({...n,requestedBy:"",status:"editing",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,n]);return{pageLock:n,acceptTakeOver:c,rejectTakeOver:u,requestTakeOver:l}},mr=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-BHacGf6H.cjs"))),Er=h.lazy(()=>Promise.resolve().then(()=>require("./page-locked-by-dialog-Cei-v0MT.cjs"))),Ut=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-request-BNS3-biN.cjs"))),pr=({isFetchingPage:e})=>{const{pageLock:t,requestTakeOver:s}=Rs(),{currentEditor:n,lockingStatus:r,setLockingStatus:a,realtimePageLockEnabled:i}=Ae(),{data:l,isFetching:c}=Gs(n),[u]=ee(),f=u.get("page"),[d]=kt(),g=P.useQueryClient(),E=h.useCallback(()=>{s()},[s]);return!f||e||!i||(t==null?void 0:t.status)==="checking"?null:t!=null&&t.requestedBy?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:"",onContinue:()=>{s()}})}):(t==null?void 0:t.status)!=="locked"?r==="take_over_request_accepted"||r==="can_edit_now"?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:r,onContinue:()=>{g.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),a("")}})}):null:t!=null&&t.isActiveInOtherTab?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:"page_is_active_in_other_tab",onContinue:s})}):o.jsx(h.Suspense,{children:o.jsx(Er,{...l,isFetchingUserInfo:c,name:(l==null?void 0:l.name)||"Unknown User",email:(l==null?void 0:l.email)||"",lastSaved:(d==null?void 0:d.lastSaved)||"",onTakeOver:E,realtimePageLockEnabled:i,isRequestRejected:r==="take_over_request_rejected"})})},yr=()=>{const[e]=ee(),t=e.get("lang");return ts(t)?null:o.jsx(h.Suspense,{children:o.jsx(mr,{})})},Ve={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"};function rs(e,t,s=!1){const n=e.toString()?`?${e.toString()}`:"/";s?window.history.replaceState(null,"",n):window.history.pushState({},"",n),t(e),window.dispatchEvent(new PopStateEvent("popstate"))}const Dt=V.atom(null),Ot=()=>{const{data:e}=ye();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},as=()=>{const e=j(),t=k();return P.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},Ar=e=>{const t=j(),s=k(),n=Ot();return P.useQuery({queryKey:[y.GET_WEBSITE_PAGES,e,n],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(n===e)return{};const r=await t(s,{action:y.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})},Tr=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-XGKr4mup.cjs"))),Ms=({children:e})=>{const{t}=w.useTranslation(),[s,n]=ee(),r=s.get("page"),{data:a,isFetching:i}=X(),{data:l,isFetching:c}=as(),[u,f]=h.useState(!1),[d,g]=h.useState(!0),{savePage:E}=w.useSavePage(),S=!!r&&!p.isEmpty(a),x=h.useMemo(()=>{if(!l||c)return!1;const N=l.find(R=>R.slug==="/");return N==null?void 0:N.id},[l,c]);h.useEffect(()=>{if(c||!x||l.some(K=>K.id===r))return;const R=new URLSearchParams({page:x});rs(R,n),!c&&l&&g(!1)},[r,c,l,x,n]);const A=!d&&!r,T=!d&&!i&&p.isEmpty(a),C=u||A||T;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex items-center gap-x-1",children:o.jsx("div",{className:"relative",children:o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,onClick:()=>{E(),f(!0)},children:e||o.jsx(m.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:o.jsx(v.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),o.jsx(m.TooltipContent,{side:"right",children:o.jsx("p",{children:t("Open pages manager")})})]})})}),o.jsx(m.Sheet,{open:C,onOpenChange:N=>!N&&S&&f(!1),children:o.jsxs(m.SheetContent,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[50vh] !max-w-[800px] border-border p-0 ${S?"":"sheet-hide-close-btn"}`,children:[o.jsxs(m.SheetHeader,{className:"mb-3 px-4 pt-4",children:[o.jsxs(m.SheetTitle,{className:"flex items-center gap-2 text-sm font-semibold",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:o.jsx(v.Folder,{className:"h-4 w-4"})}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold",children:t("Pages")}),o.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:t("Manage your site structure")})]})]}),o.jsx(m.SheetDescription,{className:"sr-only",children:t("Manage your site structure")})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:C&&o.jsx(h.Suspense,{children:o.jsx(Tr,{close:()=>f(!1)})})})]})})]})},Sr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-DPbVVRnt.cjs"))),Pr=()=>{const e=se("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},Bs=({showAdd:e=!0,variant:t="ghost"})=>{const{fallbackLang:s,languages:n,selectedLang:r,setSelectedLang:a}=w.useLanguages(),i=p.isEmpty(r)?s:r,[,l]=ee(),{isLocked:c}=Ae();h.useEffect(()=>{const A=new URLSearchParams(window.location.search),T=A.get("lang");T&&(n.includes(T)?a(T):(A.delete("lang"),l(A),a("")))},[n,l,a]);const[,u]=V.useAtom(Dt),{data:f}=X(),{data:d}=ye(),{data:g}=pe(),E=h.useMemo(()=>{const A=p.compact(p.map(p.get(d,"languages"),T=>{const C=p.find(g,{lang:T});return{key:T,value:p.get(Ve,T,T),isLangPageAdded:!!C}})).filter(Boolean);return[{key:s,value:p.get(Ve,s),isLangPageAdded:!0},...A]},[s,g,d]),S=A=>{if(document.querySelector('[data-panel-id="seo"]')){const C=new CustomEvent("seo-language-switch-check",{detail:{fromLang:i,toLang:A,switchHandler:()=>x(A)}});window.dispatchEvent(C);return}x(A)},x=A=>{a(A);const T=new URLSearchParams(window.location.search);A===s?T.delete("lang"):T.set("lang",A),rs(T,l)};return p.isEmpty(n)?null:c?o.jsxs(m.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[o.jsx(v.Languages,{className:"h-4 w-4"}),p.get(Ve,i,i),o.jsx(v.ChevronDown,{className:"h-4 w-4"})]}):o.jsx(o.Fragment,{children:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:o.jsxs(m.Button,{disabled:!!c,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[o.jsx(v.Languages,{className:"h-4 w-4"}),p.get(Ve,i,i),o.jsx(v.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(m.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(E.filter(A=>A.isLangPageAdded),A=>o.jsxs(m.DropdownMenuItem,{className:w.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",A.key===i&&"!bg-gray-200 text-gray-700"),onClick:()=>S(A.key),children:[o.jsx("div",{className:"text-slate-600",children:A.value}),A.key===s&&o.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[o.jsx(v.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},A.value)),e&&!p.isEmpty(E.filter(A=>!A.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(m.Separator,{}),o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:()=>{f&&u({edit:!1,primaryPage:f.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(v.Plus,{className:"mr-1 h-3 w-3"})," Add Langauge"]})]})]})]})})};function xr(){const[e,t]=V.useAtom(Dt);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(Pr,{}),o.jsx(Ms,{}),e&&o.jsx(h.Suspense,{children:o.jsx(Sr,{isOpen:!0,id:e==null?void 0:e.id,edit:!!(e!=null&&e.id),primaryPage:e==null?void 0:e.primaryPage,preselectedLang:e==null?void 0:e.preselectedLang,onClose:()=>t(null)})})]})}function _r(){return o.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>o.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsx(m.Skeleton,{className:"h-4 w-3/4"}),o.jsx(m.Skeleton,{className:"h-3 w-1/2"}),o.jsx(m.Skeleton,{className:"mt-1 h-5 w-20"})]}),o.jsx(m.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const vr=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-BIdaOcUx.cjs")));function wr(){const[e,t]=z.useState(!1);return o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:0,children:[o.jsxs(m.Sheet,{open:e,onOpenChange:t,children:[o.jsx(m.SheetTrigger,{asChild:!0,children:o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs(m.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[o.jsx(v.History,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"View revision history"})]}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})})}),o.jsx(m.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&o.jsx(h.Suspense,{fallback:o.jsx(_r,{}),children:o.jsx(vr,{isOpen:e})})})]}),o.jsx(m.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const Tt=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=w.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},br={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},de=()=>{const e=k(),t=j();return P.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Us=e=>{const{data:t}=de();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},Cr=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async({pageType:s,query:n})=>{try{return t(e,{action:y.SEARCH_PAGES,data:{pageType:s,query:Array.isArray(n)&&n.length>0?n[0]:n}})||[]}catch(r){return console.error(r),[]}}})},Ir=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=de();return P.useMutation({mutationFn:async r=>await s(e,{action:y.CREATE_PAGE,data:r}),onSuccess:(r,a)=>{var l;a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+((l=p.find(n,{key:a.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";F.toast.success(i)},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to add new ${i!=null&&i.hasSlug?"page":i.name}.`,{description:p.get(br,r.message,r.message)})}})},Nr=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=ue(),{data:r}=de();return P.useMutation({mutationFn:async a=>await s(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,i)=>{(n==null?void 0:n.id)===(i==null?void 0:i.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),i&&(i!=null&&i.primaryPage||i!=null&&i.seo)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const l=p.find(r,{key:i.pageType});F.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},Lr=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=de();return P.useMutation({mutationFn:async r=>s(e,{action:y.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{if(r.code==="PAGE_LOCKED"){F.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to delete ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},jr=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=de();return P.useMutation({mutationFn:async r=>s(e,{action:y.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=p.find(n,{key:a.pageType});F.toast.success(i!=null&&i.hasSlug?"Page unpublished successfully.":"New "+i.name+" added successfully.")},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to take offline ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},is=()=>{const e=k(),t=j(),s=P.useQueryClient(),{data:n}=X(),{savePageAsync:r}=w.useSavePage();return P.useMutation({mutationFn:async({ids:a})=>(await r(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:a}})),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_CHANGES]}),s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,n==null?void 0:n.id]})},onError:a=>{console.log("##",a),F.toast.error("Failed to publish pages.")}})},kr=()=>{const e=k(),t=j(),s=P.useQueryClient();return P.useMutation({mutationFn:async n=>{var r;return t(e,{action:y.MARK_AS_TEMPLATE,data:{id:(r=n.page)==null?void 0:r.id,name:n.name,description:n.description,pageType:n.pageType,previewImage:n.previewImage}})},onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page marked as template successfully.")},onError:()=>{F.toast.error("Failed to mark page as template.")}})},Dr=()=>{const e=k(),t=j(),s=P.useQueryClient();return P.useMutation({mutationFn:async n=>t(e,{action:y.UNMARK_AS_TEMPLATE,data:{id:n==null?void 0:n.id}}),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page unmarked as template successfully.")},onError:()=>{F.toast.error("Failed to unmark page as template.")}})},Or=()=>{const e=k(),t=j(),s=P.useQueryClient();return P.useMutation({mutationFn:async({id:n,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:n,slug:r}}),onSuccess:(n,{primaryPage:r})=>{F.toast.success("Slug changed successfully."),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{F.toast.error("Failed to change slug")}})},Gr=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-1knN5SPM.cjs")));function Rr({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=is();return o.jsx(m.Dialog,{open:e,onOpenChange:n?()=>{}:t,children:e&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:o.jsx(Gr,{onClose:t,isPending:n,publishPage:s})})})}const te={...w.PERMISSIONS,ADD_PAGE:"add_page",EDIT_PAGE:"edit_page",EDIT_SLUG:"edit_slug",DELETE_PAGE:"delete_page",CHANGE_PAGE_TYPE:"change_page_type",PUBLISH_PAGE:"publish_page",UNPUBLISH_PAGE:"unpublish_page",MARK_AS_TEMPLATE:"mark_as_template",UNMARK_AS_TEMPLATE:"unmark_as_template",ADD_PARTIAL:"add_partial",EDIT_PARTIAL:"edit_partial",DELETE_PARTIAL:"delete_partial",PUBLISH_PARTIAL:"publish_partial",UNPUBLISH_PARTIAL:"unpublish_partial",EDIT_SEO:"edit_seo",RESTORE_REVISION:"restore_revision",DELETE_REVISION:"delete_revision",PUBLISH_THEME:"publish_theme",EDIT_SETTINGS:"edit_settings",ADD_LIBRARY_BLOCK:"create_library_block",ADD_LIBRARY_TEMPLATE:"add_library_template",EDIT_LIBRARY_BLOCK:"edit_library_block",EDIT_LIBRARY_TEMPLATE:"edit_library_template",DELETE_LIBRARY_BLOCK:"delete_library_block",DELETE_LIBRARY_TEMPLATE:"delete_library_template",ADD_MEDIA:"add_media",EDIT_MEDIA:"edit_media",DELETE_MEDIA:"delete_media"},Mr={particleCount:350,spread:120,origin:{y:.6},angle:90},Br={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Ur=async()=>{const{default:e}=await Promise.resolve().then(()=>require("./confetti.module-BuUnQuWk.cjs"));return e},St=e=>{let t=Br[e];t||(t={});const s={...Mr,...t};Ur().then(n=>n(s))};function Gt({children:e,content:t,side:s="bottom",delayDuration:n=700,showTooltip:r=!0}){return r?o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:n,children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:e}),o.jsx(m.TooltipContent,{side:s,sideOffset:10,children:o.jsx("p",{children:t})})]})}):e}const Fr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-DU3jKAJ5.cjs"))),qr=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-Kctu12rQ.cjs"))),Kr=()=>{const{t:e}=w.useTranslation(),{selectedLang:t,fallbackLang:s}=w.useLanguages(),n=se("getPreviewUrl",async g=>g),[r,a]=h.useState(""),{data:i}=X(),{data:l}=pe(),{data:c}=de(),u=h.useMemo(()=>{var g;return(g=l==null?void 0:l.find(E=>(E==null?void 0:E.lang)===t))==null?void 0:g.slug},[t,l]),f=h.useCallback(g=>{var E;return(E=p.find(c,{key:g}))==null?void 0:E.hasSlug},[c]),d=t===s?"":t;return h.useEffect(()=>{(async()=>{if(typeof n=="function"){const g=!f(i==null?void 0:i.pageType),E=await n(g?`${d!==""?d+"/":""}${i==null?void 0:i.id}`:u||"");a(E)}else a("")})()},[n,u,i==null?void 0:i.pageType,f,i==null?void 0:i.id,d]),o.jsx(o.Fragment,{children:o.jsx(Gt,{content:e("Open preview in new tab"),delayDuration:0,children:o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:o.jsx(m.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(v.Play,{className:"h-4 w-4"})})})})})},Qr=()=>{const{t:e}=w.useTranslation(),[t,s]=w.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Gt,{content:e("Theme"),delayDuration:0,children:o.jsx(m.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>s(t==="theme"?"block":"theme"),children:o.jsx(v.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},Vr=()=>{const{t:e}=w.useTranslation(),[t,s]=h.useState(!1),{isLocked:n}=Ae(),{savePageAsync:r,saveState:a}=w.useSavePage();h.useEffect(()=>{const f=d=>{a==="UNSAVED"&&(d.preventDefault(),d.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",f),()=>{window.removeEventListener("beforeunload",f)}},[a]);const i=h.useCallback(async()=>{t||(s(!0),await r(),s(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:u}=h.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:o.jsx(v.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:o.jsx(v.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:o.jsx(v.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return n?null:o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:i,className:`${c} w-24 max-w-24`,children:[l," ",u]})},Hr=()=>{const{t:e}=w.useTranslation(),{selectedLang:t}=w.useLanguages(),{data:s}=ue(),{data:n}=pe(),[r,a]=h.useState(!1),[i,l]=h.useState(!1),[c,u]=h.useState(null),{savePageAsync:f}=w.useSavePage(),[d,g]=h.useState(!1),{data:E}=X(),{mutate:S,isPending:x}=is(),{needTranslations:A}=w.useSavePage(),T=A(),{buttonText:C,buttonClassName:N,isPublished:R}=h.useMemo(()=>{const I=E&&(E==null?void 0:E.online);return{buttonClassName:I?"hover:bg-green-600 bg-green-500":"",isPublished:I,buttonText:e(I?"Published":"Publish")}},[E,e]),K=async()=>{if(T){g(!0);return}O()},O=()=>{const I=[s==null?void 0:s.id,s==null?void 0:s.primaryPage];S({ids:p.compact(I)},{onSuccess:()=>St("TOP_RIGHT")})},ie=()=>{g(!1),O()},oe=async()=>{g(!1),await f()},q=h.useMemo(()=>p.map(n??[],"id"),[n]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(m.Button,{size:"sm",onClick:K,disabled:x||!(E!=null&&E.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${N}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[o.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${i?"-translate-y-10":""}`,children:R?o.jsx(v.Send,{className:"h-4 w-4"}):o.jsx(v.Rocket,{className:"h-4 w-4"})}),o.jsx("span",{className:`absolute inset-0 left-3 flex items-center transition-transform duration-300 ease-in-out ${i?"":"translate-y-10"}`,children:R?o.jsx(v.Rocket,{className:"h-4 w-4"}):o.jsx(v.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:C}),t?`(${p.upperCase(t)})`:""]}),o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",disabled:x||!(E!=null&&E.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${N}`,children:o.jsx(v.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(m.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(m.DropdownMenuItem,{disabled:x,className:"cursor-pointer text-xs",onClick:()=>S({ids:q},{onSuccess:()=>St("TOP_RIGHT")}),children:[e("Publish")," with translation pages"]}),!R&&o.jsxs(m.DropdownMenuItem,{disabled:x,className:"cursor-pointer text-xs",onClick:()=>S({ids:[E==null?void 0:E.id]},{onSuccess:()=>St("TOP_RIGHT")}),children:[e("Publish")," page"]}),o.jsxs(m.DropdownMenuItem,{onClick:()=>a(!0),className:"cursor-pointer text-xs",children:[e("Open")," publish menu"]}),R&&o.jsxs(m.DropdownMenuItem,{onClick:()=>u(s),className:"cursor-pointer text-xs",children:[e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]})]})]})]}),o.jsx(Rr,{showModal:r,onClose:()=>a(!1)}),c&&o.jsx(h.Suspense,{children:o.jsx(Fr,{page:c,onClose:()=>u(null)})}),d&&o.jsx(h.Suspense,{children:o.jsx(qr,{isOpen:d,onClose:oe,onContinue:ie,isPending:x})})]})};function zr(){const{isLocked:e}=Ae(),[t]=ee(),s=t.get("lang"),n=ts(s);return e||!n?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsx(wr,{}),o.jsx(Tt,{permission:te.EDIT_THEME,children:o.jsx(Qr,{})}),o.jsx(Kr,{}),o.jsx(Tt,{permission:te.SAVE_PAGE,children:o.jsx(Vr,{})}),o.jsx(Tt,{permission:te.PUBLISH_PAGE,children:o.jsx(Hr,{})})]})}const Fs=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{t:u}=w.useTranslation(),{hasPermission:f}=w.usePermissions(),{data:d}=de(),g=h.useMemo(()=>p.find(d,{key:e.pageType}),[d,e.pageType]),E=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),S=h.useMemo(()=>!!(g!=null&&g.hasSlug),[g==null?void 0:g.hasSlug]);return!f(te.EDIT_PAGE)&&!f(te.DELETE_PAGE)&&!f(te.UNPUBLISH_PAGE)||!e?null:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,onClick:A=>A.stopPropagation(),children:l}),o.jsxs(m.DropdownMenuContent,{align:"center",className:"text-sm",children:[f(te.ADD_PAGE)&&!c&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),t(e)},children:[o.jsx(v.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),f(te.EDIT_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),s({...e,global:!(g!=null&&g.hasSlug)})},children:[o.jsx(v.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&f(te.UNPUBLISH_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),n(e)},children:[o.jsx(v.Power,{className:"size-3"}),u("Unpublish")]}),f(te.DELETE_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),r(e)},children:[o.jsx(v.Trash,{className:"size-3"}),u("Delete")]}),f(te.MARK_AS_TEMPLATE)&&S&&!c&&o.jsx(o.Fragment,{children:E?o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),i(e)},children:[o.jsx(v.SquareLibrary,{className:"size-3"}),u("Unmark as template")]}):o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),a(e)},children:[o.jsx(v.SquareLibrary,{className:"size-3"}),u("Mark as template")]})})]})]})},$r=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-CgsPADOI.cjs"))),Wr=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-ftu1i43t.cjs"))),Yr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-D-2tkgsd.cjs"))),Jr=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-CD1bYgow.cjs"))),Xr=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-9-wHwCPl.cjs"))),Zr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-DU3jKAJ5.cjs"))),ea=()=>{const[e,t]=h.useState(null),[s,n]=h.useState(null),[r,a]=h.useState(null),[i,l]=h.useState(null),[c,u]=h.useState(null),[f,d]=h.useState(null),{data:g,isFetching:E}=ue(),{selectedLang:S,fallbackLang:x}=w.useLanguages(),{data:A}=pe(),T=A==null?void 0:A.find(O=>O.lang===S),{isLocked:C}=Ae(),N=!(g!=null&&g.slug),[,R]=V.useAtom(Dt);if(!g)return null;const K=O=>{S.length>0&&S!==x?R({edit:!0,id:O==null?void 0:O.id,primaryPage:O==null?void 0:O.primaryPage}):d(O)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between rounded px-[2px] transition-colors duration-200",children:[o.jsx(Ms,{children:o.jsx(m.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:E?o.jsx(v.Loader,{className:"h-4 w-4 animate-spin text-slate-400"}):o.jsxs("span",{className:"flex w-full cursor-pointer items-end overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-xs font-medium",children:[N?o.jsx(v.Hash,{className:"mr-1 h-4 w-4"}):o.jsx(v.File,{className:"mr-1 h-4 w-4"}),p.get(T||g,"name")??""]})})}),C?o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:o.jsx(v.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx(Fs,{page:g,setDuplicatePage:O=>u(O),setAddEditPage:O=>K(O),setUnpublishPage:O=>n(O),setDeletePage:O=>t(O),setMarkAsTemplate:O=>a(O),setUnmarkAsTemplate:O=>l(O),isLanguagePage:S.length>0&&S!==x,children:o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(v.MoreHorizontal,{className:"h-4 w-4"})})})]}),f&&o.jsx(h.Suspense,{children:o.jsx($r,{closePanel:()=>d(null),editPage:()=>{},addEditPage:f,setAddEditPage:d})}),e&&o.jsx(h.Suspense,{children:o.jsx(Wr,{page:e,onClose:()=>t(null)})}),s&&o.jsx(h.Suspense,{children:o.jsx(Zr,{page:s,onClose:()=>n(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx(Jr,{page:r,onClose:()=>a(null)})}),i&&o.jsx(h.Suspense,{children:o.jsx(Xr,{page:i,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(Yr,{page:c,onClose:()=>u(null),closePanel:()=>d(null)})})]})},os=({children:e,className:t=""})=>o.jsx("div",{className:w.mergeClasses("fixed bottom-0 left-0 right-0 top-[50px] z-[20] flex w-screen flex-col items-center justify-center bg-black/40 transition-all",t),children:e}),ta=({hasDynamicPage:e})=>o.jsx(os,{children:o.jsxs("div",{className:"flex min-w-[300px] max-w-[400px] flex-col items-center justify-center rounded-lg border bg-white p-4 shadow-lg",children:[o.jsx("h1",{className:"text-lg font-medium",children:e?"Select a page":"No pages found"}),o.jsx("p",{className:"pt-2 text-center text-sm font-light text-gray-600",children:e?"Please select a page from the list in the top header. This will enable you to edit the page.":"Please add a new page"})]})}),sa=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-DDyEyh7e.cjs"))),na=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=Os(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(ta,{hasDynamicPage:n}),o.jsx(h.Suspense,{children:o.jsx(sa,{})})]})},ra=()=>{const{data:e,isFetching:t}=ue(),{data:s,isFetching:n}=X(),r=p.get(s,"dynamic",!1),a=ss(),i=w.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,u=cr(),f=t||n,g=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return o.jsxs("div",{className:"relative flex items-center gap-x-1",children:[o.jsx("div",{className:w.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",f&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(ea,{})}),o.jsxs("div",{className:w.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800"+(c?" pr-2":""),f&&"max-w-0 overflow-hidden opacity-0"),children:[o.jsx(Bs,{}),o.jsxs("div",{className:"flex w-full items-center overflow-hidden",children:[o.jsx("div",{className:`w-full max-w-[200px] overflow-hidden overflow-ellipsis whitespace-nowrap pl-1 text-xs ${c?"italic text-gray-400":"font-mono text-gray-500"}`,children:g==="/"?o.jsxs("span",{className:"text-gray-900",children:["/",o.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):g}),!c&&o.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:o.jsx("div",{className:"ml-2 mr-px flex-shrink-0 rounded-sm p-1.5 text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",children:o.jsx(v.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&i&&o.jsx(na,{})]})},aa=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(xr,{}),o.jsx(ra,{}),o.jsx(zr,{})]}),qs=()=>{const e=P.useQueryClient(),{data:t}=P.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},ia=()=>{const e=k(),{aiContext:t}=qs(),s=j();return h.useCallback(async(n,r,a,i)=>s(e,{action:y.ASK_AI,data:{type:n,prompt:r,blocks:a,context:t,lang:i}}),[e,t,s])},oa=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=Ls.getDefaultBlockProps(s._type);return{...n,...p.pick(s,[...p.keys(n),"_type","_id","_name","_parent","_bindings"]),...p.pickBy(s,(r,a)=>p.endsWith(a,"_attrs")),...s}}return s}),la=e=>{const t=Ls.useRegisteredChaiBlocks();return h.useMemo(()=>{if(!e||p.isEmpty(e))return{blocks:[]};const s=p.filter(e,n=>!p.includes(n==null?void 0:n._type,"@chai/"));return{blocks:oa(t,s)}},[e,t])},ca=()=>{const[e]=ee(),t=e.get("page"),s=k(),{setAiContext:n}=qs(),[,r]=kt(),[,a]=lr(),[,i]=w.useIsPageLoaded(),l=j();return P.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{i(!1);const c=await l(s,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),u=c.blocks??[],f=p.find(u,{_type:"@chai/ai-context"});return n(p.get(f,"_value","")||""),r(d=>({...d,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),u},enabled:!!t})},Ks=()=>{const{data:e}=X(),{data:t}=ue(),s=k(),n=j(),r=Ot(),a=ss();return P.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>n(s,{action:y.GET_BUILDER_PAGE_DATA,data:{pageType:e==null?void 0:e.pageType,lang:(t==null?void 0:t.lang)||r,dynamic:e==null?void 0:e.dynamic,pageProps:{slug:(t==null?void 0:t.slug)+a,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:r,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id,metadata:e.metadata||{}}}}),enabled:!!(e!=null&&e.pageType)&&!!t.id})},Qs=()=>{const e=k(),t=P.useQueryClient(),s=j();return P.useMutation({mutationFn:async n=>s(e,{action:y.UPDATE_WEBSITE_SETTINGS,data:n}),onSuccess:(n,r)=>{var a;t.invalidateQueries({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS]}),(a=r==null?void 0:r.settings)!=null&&a.theme||F.toast.success("Website settings updated successfully.")},onError:n=>{F.toast.error("Failed to update website settings",{description:n.message})}})},ua=()=>{const e=k(),t=P.useQueryClient(),s=j(),{selectedLang:n}=w.useLanguages();return P.useMutation({mutationFn:async r=>s(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema added successfully.")},onError:r=>{F.toast.error("Failed to add schema",{description:r.message})}})},da=()=>{const e=k(),t=P.useQueryClient(),s=j(),{selectedLang:n}=w.useLanguages();return P.useMutation({mutationFn:async r=>s(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema updated successfully.")},onError:r=>{F.toast.error("Failed to update schema",{description:r.message})}})},fa=()=>{const e=k(),t=P.useQueryClient(),s=j();return P.useMutation({mutationFn:async n=>s(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema deleted successfully.")},onError:n=>{F.toast.error("Failed to delete schema",{description:n.message})}})},ha=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async s=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:s}),onError:s=>{F.toast.error("Failed to toggle schema",{description:s.message})}})},ga=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async s=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema applied to ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to apply schema to all pages",{description:s.message})}})},ma=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async s=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema removed from ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to remove schema from all pages",{description:s.message})}})},ps={async getUILibraryBlock(e,t,s){const n=await t(s,{action:"GET_LIBRARY_ITEM",data:{id:e.id}}),r=p.get(n,"html",""),a=p.get(n,"blocks",[]);return p.isArray(a)?a:w.getBlocksFromHTML(r)},async getUILibraryBlocks(e,t,s){try{return(await t(s,{action:"GET_LIBRARY_ITEMS",data:{id:e.id}})).map(r=>({...r}))}catch(n){return console.error(n),[]}}},Ea=()=>{const e=k(),t=j();return P.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{w.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>ps.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>ps.getUILibraryBlock(a,t,e)})}),n}})},Vs=()=>{const e=js(),t=j(),{user:s}=gt(),n=s==null?void 0:s.id;return P.useQuery({queryKey:[y.GET_ROLE_AND_PERMISSIONS,n],queryFn:()=>t(e,{action:y.GET_ROLE_AND_PERMISSIONS,data:{userId:n}}),enabled:!!n,staleTime:1/0})},pa=()=>{const e=k(),t=j(),[,s]=kt();return{onSave:async({page:r,blocks:a,needTranslations:i})=>{try{const l=await t(e,{action:"UPDATE_PAGE",data:{id:r,blocks:a,needTranslations:i}});return l.code==="PAGE_LOCKED"?!0:(s(c=>({...c,lastSaved:new Date().toISOString()})),l)}catch(l){return console.error(l),new Error("Failed to save blocks")}}}},ya=()=>{const{data:e}=as(),t=k(),s=j();return{getPartialBlocks:h.useCallback(async()=>{const n={};for(const r of e??[])p.isEmpty(r==null?void 0:r.slug)&&(n[r.id]={type:r.pageType,name:p.startCase(r.name??r.slug),description:""});return n},[e]),getPartialBlockBlocks:h.useCallback(async n=>{if(!n)return[];try{const r=await s(t,{action:"GET_DRAFT_PAGE",data:{id:n,draft:!0,editor:!1}});return p.filter(r.blocks,a=>p.has(a,"_id"))}catch(r){return console.error(r),[]}},[s,t])}},Aa=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-DNQEDZ5D.cjs"))),Ta=({isActive:e,show:t})=>{const{data:s}=ye();return!p.has(s,"languages")||!p.get(s,"languages",[]).length?null:o.jsx(m.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:o.jsx(v.LanguagesIcon,{className:"h-4 w-4"})})},Hs="lang",Sa={id:Hs,label:"Languages",position:"top",panel:Aa,button:Ta,view:"modal",width:400},Pa=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-DRb3uTUp.cjs"))),zs="seo",xa=({isActive:e,show:t})=>{const{data:s}=X(),n=Us(s==null?void 0:s.pageType);return!p.has(n,"hasSlug")||!n.hasSlug?null:o.jsx(m.Button,{size:"icon",className:"my-1 p-0",onClick:t,variant:e?"default":"ghost",children:o.jsxs("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M7 8h-3a1 1 0 0 0 -1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-3"}),o.jsx("path",{d:"M14 16h-4v-8h4"}),o.jsx("path",{d:"M11 12h2"}),o.jsx("path",{d:"M17 8m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]})})},_a={id:zs,label:"SEO",panel:Pa,button:xa,position:"top",width:600,view:"modal"},$s="user-info",va=()=>{const{t:e}=w.useTranslation(),{user:t,logout:s}=gt(),n=se("onLogout",p.noop);return t?o.jsxs(m.HoverCard,{children:[o.jsx(m.HoverCardTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"ghost",className:"text-sm font-medium",children:o.jsx(v.User,{className:"h-4 w-4"})})}),o.jsxs(m.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[o.jsx("div",{className:"text-sm font-medium",children:t.name??t.email}),o.jsx("div",{className:"text-xs text-muted-foreground",children:t.email}),o.jsxs(m.AlertDialog,{children:[o.jsx(m.AlertDialogTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),o.jsxs(m.AlertDialogContent,{children:[o.jsxs(m.AlertDialogHeader,{children:[o.jsx(m.AlertDialogTitle,{children:e("Are you sure you want to logout?")}),o.jsx(m.AlertDialogDescription,{children:e("You will be redirected to the login page.")})]}),o.jsxs(m.AlertDialogFooter,{children:[o.jsx(m.AlertDialogCancel,{children:e("Cancel")}),o.jsx(m.AlertDialogAction,{onClick:()=>{s(),p.isFunction(n)&&n()},children:e("Logout")})]})]})]})]})]}):null},wa={id:$s,label:"User Info",button:va,position:"bottom"},ba=()=>{w.registerChaiSidebarPanel(zs,_a),w.registerChaiSidebarPanel(Hs,Sa),w.registerChaiSidebarPanel($s,wa)};var b={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return ys(this.context.count)},getNextContextId(){return ys(this.context.count++)}};function ys(e){const t=String(e),s=t.length-1;return b.context.id+(s?String.fromCharCode(96+s):"")+t}function He(e){b.context=e}var Ws=!1,Ca=(e,t)=>e===t,_t=Symbol("solid-proxy"),Ys=typeof Proxy=="function",ls=Symbol("solid-track"),vt={equals:Ca},Js=an,fe=1,wt=2,Xs={owned:null,cleanups:null,context:null,owner:null},Ft={},D=null,qt=null,Ia=null,B=null,J=null,ce=null,Rt=0;function ge(e,t){const s=B,n=D,r=e.length===0,a=t===void 0?n:t,i=r?Xs:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>Y(()=>Je(i)));D=i,B=null;try{return ae(l,!0)}finally{B=s,D=n}}function Q(e,t){t=t?Object.assign({},vt,t):vt;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),rn(s,r));return[nn.bind(s),n]}function Zs(e,t,s){const n=Mt(e,t,!0,fe);Qe(n)}function me(e,t,s){const n=Mt(e,t,!1,fe);Qe(n)}function cs(e,t,s){Js=qa;const n=Mt(e,t,!1,fe);(!s||!s.render)&&(n.user=!0),ce?ce.push(n):Qe(n)}function $(e,t,s){s=s?Object.assign({},vt,s):vt;const n=Mt(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,Qe(n),nn.bind(n)}function Na(e){return e&&typeof e=="object"&&"then"in e}function La(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=Ft,c=null,u=!1,f="initialValue"in a,d=typeof n=="function"&&$(n);const g=new Set,[E,S]=(a.storage||Q)(a.initialValue),[x,A]=Q(void 0),[T,C]=Q(void 0,{equals:!1}),[N,R]=Q(f?"ready":"unresolved");b.context&&(c=b.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function K(I,L,W,H){return i===I&&(i=null,H!==void 0&&(f=!0),(I===l||L===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(H,{value:L})),l=Ft,O(L,W)),L}function O(I,L){ae(()=>{L===void 0&&S(()=>I),R(L!==void 0?"errored":f?"ready":"unresolved"),A(L);for(const W of g.keys())W.decrement();g.clear()},!1)}function ie(){const I=Ba,L=E(),W=x();if(W!==void 0&&!i)throw W;return B&&B.user,L}function oe(I=!0){if(I!==!1&&u)return;u=!1;const L=d?d():n;if(L==null||L===!1){K(i,Y(E));return}let W;const H=l!==Ft?l:Y(()=>{try{return r(L,{value:E(),refetching:I})}catch(ne){W=ne}});if(W!==void 0){K(i,void 0,Pt(W),L);return}else if(!Na(H))return K(i,H,void 0,L),H;return i=H,"v"in H?(H.s===1?K(i,H.v,void 0,L):K(i,void 0,Pt(H.v),L),H):(u=!0,queueMicrotask(()=>u=!1),ae(()=>{R(f?"refreshing":"pending"),C()},!1),H.then(ne=>K(H,ne,void 0,L),ne=>K(H,void 0,Pt(ne),L)))}Object.defineProperties(ie,{state:{get:()=>N()},error:{get:()=>x()},loading:{get(){const I=N();return I==="pending"||I==="refreshing"}},latest:{get(){if(!f)return ie();const I=x();if(I&&!i)throw I;return E()}}});let q=D;return d?Zs(()=>(q=D,oe(!1))):oe(!1),[ie,{refetch:I=>tn(q,()=>oe(I)),mutate:S}]}function ja(e){return ae(e,!1)}function Y(e){if(B===null)return e();const t=B;B=null;try{return e()}finally{B=t}}function ka(e,t,s){const n=Array.isArray(e);let r,a=s&&s.defer;return i=>{let l;if(n){l=Array(e.length);for(let u=0;u<e.length;u++)l[u]=e[u]()}else l=e();if(a)return a=!1,i;const c=Y(()=>t(l,r,i));return r=l,c}}function en(e){cs(()=>Y(e))}function qe(e){return D===null||(D.cleanups===null?D.cleanups=[e]:D.cleanups.push(e)),e}function As(){return D}function tn(e,t){const s=D,n=B;D=e,B=null;try{return ae(t,!0)}catch(r){us(r)}finally{D=s,B=n}}function Da(e){const t=B,s=D;return Promise.resolve().then(()=>{B=t,D=s;let n;return ae(e,!1),B=D=null,n?n.done:void 0})}var[Oa,Ko]=Q(!1);function Ga(){return[Oa,Da]}function Ra(e,t){const s=Symbol("context");return{id:s,Provider:Ka(s),defaultValue:e}}function Ma(e){let t;return D&&D.context&&(t=D.context[e.id])!==void 0?t:e.defaultValue}function sn(e){const t=$(e),s=$(()=>Ht(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var Ba;function nn(){if(this.sources&&this.state)if(this.state===fe)Qe(this);else{const e=J;J=null,ae(()=>Ct(this),!1),J=e}if(B){const e=this.observers?this.observers.length:0;B.sources?(B.sources.push(this),B.sourceSlots.push(e)):(B.sources=[this],B.sourceSlots=[e]),this.observers?(this.observers.push(B),this.observerSlots.push(B.sources.length-1)):(this.observers=[B],this.observerSlots=[B.sources.length-1])}return this.value}function rn(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&ae(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],i=qt&&qt.running;i&&qt.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?J.push(a):ce.push(a),a.observers&&on(a)),i||(a.state=fe)}if(J.length>1e6)throw J=[],new Error},!1)),t}function Qe(e){if(!e.fn)return;Je(e);const t=Rt;Ua(e,e.value,t)}function Ua(e,t,s){let n;const r=D,a=B;B=D=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=fe,e.owned&&e.owned.forEach(Je),e.owned=null),e.updatedAt=s+1,us(i)}finally{B=a,D=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?rn(e,n):e.value=n,e.updatedAt=s)}function Mt(e,t,s,n=fe,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:D,context:D?D.context:null,pure:s};return D===null||D!==Xs&&(D.owned?D.owned.push(a):D.owned=[a]),a}function bt(e){if(e.state===0)return;if(e.state===wt)return Ct(e);if(e.suspense&&Y(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Rt);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===fe)Qe(e);else if(e.state===wt){const n=J;J=null,ae(()=>Ct(e,t[0]),!1),J=n}}function ae(e,t){if(J)return e();let s=!1;t||(J=[]),ce?s=!0:ce=[],Rt++;try{const n=e();return Fa(s),n}catch(n){s||(ce=null),J=null,us(n)}}function Fa(e){if(J&&(an(J),J=null),e)return;const t=ce;ce=null,t.length&&ae(()=>Js(t),!1)}function an(e){for(let t=0;t<e.length;t++)bt(e[t])}function qa(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:bt(n)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,s));return}He()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],s+=b.effects.length,delete b.effects),t=0;t<s;t++)bt(e[t])}function Ct(e,t){e.state=0;for(let s=0;s<e.sources.length;s+=1){const n=e.sources[s];if(n.sources){const r=n.state;r===fe?n!==t&&(!n.updatedAt||n.updatedAt<Rt)&&bt(n):r===wt&&Ct(n,t)}}}function on(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=wt,s.pure?J.push(s):ce.push(s),s.observers&&on(s))}}function Je(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),r=s.observers;if(r&&r.length){const a=r.pop(),i=s.observerSlots.pop();n<r.length&&(a.sourceSlots[i]=n,r[n]=a,s.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)Je(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)Je(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Pt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function us(e,t=D){throw Pt(e)}function Ht(e){if(typeof e=="function"&&!e.length)return Ht(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Ht(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Ka(e,t){return function(n){let r;return me(()=>r=Y(()=>(D.context={...D.context,[e]:n.value},sn(()=>n.children))),void 0),r}}var zt=Symbol("fallback");function It(e){for(let t=0;t<e.length;t++)e[t]()}function Qa(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return qe(()=>It(a)),()=>{let c=e()||[],u=c.length,f,d;return c[ls],Y(()=>{let E,S,x,A,T,C,N,R,K;if(u===0)i!==0&&(It(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[zt],r[0]=ge(O=>(a[0]=O,s.fallback())),i=1);else if(i===0){for(r=new Array(u),d=0;d<u;d++)n[d]=c[d],r[d]=ge(g);i=u}else{for(x=new Array(u),A=new Array(u),l&&(T=new Array(u)),C=0,N=Math.min(i,u);C<N&&n[C]===c[C];C++);for(N=i-1,R=u-1;N>=C&&R>=C&&n[N]===c[R];N--,R--)x[R]=r[N],A[R]=a[N],l&&(T[R]=l[N]);for(E=new Map,S=new Array(R+1),d=R;d>=C;d--)K=c[d],f=E.get(K),S[d]=f===void 0?-1:f,E.set(K,d);for(f=C;f<=N;f++)K=n[f],d=E.get(K),d!==void 0&&d!==-1?(x[d]=r[f],A[d]=a[f],l&&(T[d]=l[f]),d=S[d],E.set(K,d)):a[f]();for(d=C;d<u;d++)d in x?(r[d]=x[d],a[d]=A[d],l&&(l[d]=T[d],l[d](d))):r[d]=ge(g);r=r.slice(0,i=u),n=c.slice(0)}return r});function g(E){if(a[d]=E,l){const[S,x]=Q(d);return l[d]=x,t(c[d],S)}return t(c[d])}}}function Va(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return qe(()=>It(a)),()=>{const u=e()||[],f=u.length;return u[ls],Y(()=>{if(f===0)return l!==0&&(It(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[zt],r[0]=ge(g=>(a[0]=g,s.fallback())),l=1),r;for(n[0]===zt&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<f;c++)c<n.length&&n[c]!==u[c]?i[c](()=>u[c]):c>=n.length&&(r[c]=ge(d));for(;c<n.length;c++)a[c]();return l=i.length=a.length=f,n=u.slice(0),r=r.slice(0,l)});function d(g){a[c]=g;const[E,S]=Q(u[c]);return i[c]=S,t(E,c)}}}function ds(e,t){return Y(()=>e(t||{}))}function pt(){return!0}var $t={get(e,t,s){return t===_t?s:e.get(t)},has(e,t){return t===_t?!0:e.has(t)},set:pt,deleteProperty:pt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:pt,deleteProperty:pt}},ownKeys(e){return e.keys()}};function Kt(e){return(e=typeof e=="function"?e():e)?e:{}}function Ha(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function fs(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&_t in l,e[i]=typeof l=="function"?(t=!0,$(l)):l}if(Ys&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=Kt(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in Kt(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(Kt(e[l])));return[...new Set(i)]}},$t);const s={},n=Object.create(null);for(let i=e.length-1;i>=0;i--){const l=e[i];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let u=c.length-1;u>=0;u--){const f=c[u];if(f==="__proto__"||f==="constructor")continue;const d=Object.getOwnPropertyDescriptor(l,f);if(!n[f])n[f]=d.get?{enumerable:!0,configurable:!0,get:Ha.bind(s[f]=[d.get.bind(l)])}:d.value!==void 0?d:void 0;else{const g=s[f];g&&(d.get?g.push(d.get.bind(l)):d.value!==void 0&&g.push(()=>d.value))}}}const r={},a=Object.keys(n);for(let i=a.length-1;i>=0;i--){const l=a[i],c=n[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function ln(e,...t){if(Ys&&_t in e){const r=new Set(t.length>1?t.flat():t[0]),a=t.map(i=>new Proxy({get(l){return i.includes(l)?e[l]:void 0},has(l){return i.includes(l)&&l in e},keys(){return i.filter(l=>l in e)}},$t));return a.push(new Proxy({get(i){return r.has(i)?void 0:e[i]},has(i){return r.has(i)?!1:i in e},keys(){return Object.keys(e).filter(i=>!r.has(i))}},$t)),a}const s={},n=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),i=!a.get&&!a.set&&a.enumerable&&a.writable&&a.configurable;let l=!1,c=0;for(const u of t)u.includes(r)&&(l=!0,i?n[c][r]=a.value:Object.defineProperty(n[c],r,a)),++c;l||(i?s[r]=a.value:Object.defineProperty(s,r,a))}return[...n,s]}function cn(e){let t,s;const n=r=>{const a=b.context;if(a){const[l,c]=Q();b.count||(b.count=0),b.count++,(s||(s=e())).then(u=>{!b.done&&He(a),b.count--,c(()=>u.default),He()}),t=l}else if(!t){const[l]=La(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return $(()=>(i=t())?Y(()=>{if(!a||b.done)return i(r);const l=b.context;He(a);const c=i(r);return He(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var za=0;function $a(){return b.context?b.getNextContextId():`cl-${za++}`}var un=e=>`Stale read from <${e}>.`;function Wa(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Qa(()=>e.each,e.children,t||void 0))}function Ya(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Va(()=>e.each,e.children,t||void 0))}function Ja(e){const t=e.keyed,s=$(()=>e.when,void 0,void 0),n=t?s:$(s,void 0,{equals:(r,a)=>!r==!a});return $(()=>{const r=n();if(r){const a=e.children;return typeof a=="function"&&a.length>0?Y(()=>a(t?r:()=>{if(!Y(n))throw un("Show");return s()})):a}return e.fallback},void 0,void 0)}function Xa(e){const t=sn(()=>e.children),s=$(()=>{const n=t(),r=Array.isArray(n)?n:[n];let a=()=>{};for(let i=0;i<r.length;i++){const l=i,c=r[i],u=a,f=$(()=>u()?void 0:c.when,void 0,void 0),d=c.keyed?f:$(f,void 0,{equals:(g,E)=>!g==!E});a=()=>u()||(d()?[l,f,c]:void 0)}return a});return $(()=>{const n=s()();if(!n)return e.fallback;const[r,a,i]=n,l=i.children;return typeof l=="function"&&l.length>0?Y(()=>l(i.keyed?a():()=>{var u;if(((u=Y(s)())==null?void 0:u[0])!==r)throw un("Match");return a()})):l},void 0,void 0)}function Za(e){return e}var ei=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],ti=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...ei]),si=new Set(["innerHTML","textContent","innerText","children"]),ni=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),ri=Object.assign(Object.create(null),{class:"className",novalidate:{$:"noValidate",FORM:1},formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function ai(e,t){const s=ri[e];return typeof s=="object"?s[t]?s.$:void 0:s}var ii=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),oi=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),li={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},ci=e=>$(()=>e());function ui(e,t,s){let n=s.length,r=t.length,a=n,i=0,l=0,c=t[r-1].nextSibling,u=null;for(;i<r||l<a;){if(t[i]===s[l]){i++,l++;continue}for(;t[r-1]===s[a-1];)r--,a--;if(r===i){const f=a<n?l?s[l-1].nextSibling:s[a-l]:c;for(;l<a;)e.insertBefore(s[l++],f)}else if(a===l)for(;i<r;)(!u||!u.has(t[i]))&&t[i].remove(),i++;else if(t[i]===s[a-1]&&s[l]===t[r-1]){const f=t[--r].nextSibling;e.insertBefore(s[l++],t[i++].nextSibling),e.insertBefore(s[--a],f),t[r]=s[a]}else{if(!u){u=new Map;let d=l;for(;d<a;)u.set(s[d],d++)}const f=u.get(t[i]);if(f!=null)if(l<f&&f<a){let d=i,g=1,E;for(;++d<r&&d<a&&!((E=u.get(t[d]))==null||E!==f+g);)g++;if(g>f-l){const S=t[i];for(;l<f;)e.insertBefore(s[l++],S)}else e.replaceChild(s[l++],t[i++])}else i++;else t[i++].remove()}}}var We="_$DX_DELEGATE";function dn(e,t,s,n={}){let r;return ge(a=>{r=a,t===document?e():Lt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function di(e,t,s,n){let r;const a=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},i=()=>(r||(r=a())).cloneNode(!0);return i.cloneNode=i,i}function fn(e,t=window.document){const s=t[We]||(t[We]=new Set);for(let n=0,r=e.length;n<r;n++){const a=e[n];s.has(a)||(s.add(a),t.addEventListener(a,pn))}}function fi(e=window.document){if(e[We]){for(let t of e[We].keys())e.removeEventListener(t,pn);delete e[We]}}function Nt(e,t,s){xe(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function hi(e,t,s,n){xe(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function gi(e,t,s){xe(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function hn(e,t){xe(e)||(t==null?e.removeAttribute("class"):e.className=t)}function gn(e,t,s,n){if(n)Array.isArray(s)?(e[`$$${t}`]=s[0],e[`$$${t}Data`]=s[1]):e[`$$${t}`]=s;else if(Array.isArray(s)){const r=s[0];e.addEventListener(t,s[0]=a=>r.call(e,s[1],a))}else e.addEventListener(t,s,typeof s!="function"&&s)}function mi(e,t,s={}){const n=Object.keys(t||{}),r=Object.keys(s);let a,i;for(a=0,i=r.length;a<i;a++){const l=r[a];!l||l==="undefined"||t[l]||(Ts(e,l,!1),delete s[l])}for(a=0,i=n.length;a<i;a++){const l=n[a],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(Ts(e,l,!0),s[l]=c)}return s}function Ei(e,t,s){if(!t)return s?Nt(e,"style"):t;const n=e.style;if(typeof t=="string")return n.cssText=t;typeof s=="string"&&(n.cssText=s=void 0),s||(s={}),t||(t={});let r,a;for(a in s)t[a]==null&&n.removeProperty(a),delete s[a];for(a in t)r=t[a],r!==s[a]&&(n.setProperty(a,r),s[a]=r);return s}function mn(e,t={},s,n){const r={};return n||me(()=>r.children=Xe(e,t.children,r.children)),me(()=>typeof t.ref=="function"&&En(t.ref,e)),me(()=>pi(e,t,s,!0,r,!0)),r}function En(e,t,s){return Y(()=>e(t,s))}function Lt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return Xe(e,t,n,s);me(r=>Xe(e,t(),r,s),n)}function pi(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Ss(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Ss(e,i,l,r[i],s,a,t)}}function yi(e){let t,s;return!xe()||!(t=b.registry.get(s=Ti()))?e():(b.completed&&b.completed.add(t),b.registry.delete(s),t)}function xe(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function Ai(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Ts(e,t,s){const n=t.trim().split(/\s+/);for(let r=0,a=n.length;r<a;r++)e.classList.toggle(n[r],s)}function Ss(e,t,s,n,r,a,i){let l,c,u,f,d;if(t==="style")return Ei(e,s,n);if(t==="classList")return mi(e,s,n);if(s===n)return n;if(t==="ref")a||s(e);else if(t.slice(0,3)==="on:"){const g=t.slice(3);n&&e.removeEventListener(g,n,typeof n!="function"&&n),s&&e.addEventListener(g,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const g=t.slice(10);n&&e.removeEventListener(g,n,!0),s&&e.addEventListener(g,s,!0)}else if(t.slice(0,2)==="on"){const g=t.slice(2).toLowerCase(),E=ii.has(g);if(!E&&n){const S=Array.isArray(n)?n[0]:n;e.removeEventListener(g,S)}(E||s)&&(gn(e,g,s,E),E&&fn([g]))}else if(t.slice(0,5)==="attr:")Nt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")gi(e,t.slice(5),s);else if((d=t.slice(0,5)==="prop:")||(u=si.has(t))||!r&&((f=ai(t,e.tagName))||(c=ti.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(d)t=t.slice(5),c=!0;else if(xe(e))return s;t==="class"||t==="className"?hn(e,s):l&&!c&&!u?e[Ai(t)]=s:e[f||t]=s}else{const g=r&&t.indexOf(":")>-1&&li[t.split(":")[0]];g?hi(e,g,t,s):Nt(e,ni[t]||t,s)}return s}function pn(e){if(b.registry&&b.events&&b.events.find(([c,u])=>u===e))return;let t=e.target;const s=`$$${e.type}`,n=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),i=()=>{const c=t[s];if(c&&!t.disabled){const u=t[`${s}Data`];if(u!==void 0?c.call(t,u,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},l=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),b.registry&&!b.done&&(b.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let u=0;u<c.length-2&&(t=c[u],!!i());u++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function Xe(e,t,s,n,r){const a=xe(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let u=0;u<s.length;u++){const f=s[u];f.nodeType===8&&f.data.slice(0,2)==="!$"?f.remove():c.push(f)}s=c}for(;typeof s=="function";)s=s();if(t===s)return s;const i=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,i==="string"||i==="number"){if(a||i==="number"&&(t=t.toString(),t===s))return s;if(l){let c=s[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),s=ve(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||i==="boolean"){if(a)return s;s=ve(e,s,n)}else{if(i==="function")return me(()=>{let c=t();for(;typeof c=="function";)c=c();s=Xe(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],u=s&&Array.isArray(s);if(Wt(c,t,s,r))return me(()=>s=Xe(e,c,s,n,!0)),()=>s;if(a){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let f=c[0];if(f.parentNode!==e)return s;const d=[f];for(;(f=f.nextSibling)!==n;)d.push(f);return s=d}if(c.length===0){if(s=ve(e,s,n),l)return s}else u?s.length===0?Ps(e,c,n):ui(e,s,c):(s&&ve(e),Ps(e,c));s=c}else if(t.nodeType){if(a&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=ve(e,s,n,t);ve(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function Wt(e,t,s,n){let r=!1;for(let a=0,i=t.length;a<i;a++){let l=t[a],c=s&&s[e.length],u;if(!(l==null||l===!0||l===!1))if((u=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=Wt(e,l,c)||r;else if(u==="function")if(n){for(;typeof l=="function";)l=l();r=Wt(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const f=String(l);c&&c.nodeType===3&&c.data===f?e.push(c):e.push(document.createTextNode(f))}}return r}function Ps(e,t,s=null){for(let n=0,r=t.length;n<r;n++)e.insertBefore(t[n],s)}function ve(e,t,s,n){if(s===void 0)return e.textContent="";const r=n||document.createTextNode("");if(t.length){let a=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(r!==l){const c=l.parentNode===e;!a&&!i?c?e.replaceChild(r,l):e.insertBefore(r,s):c&&l.remove()}else a=!0}}else e.insertBefore(r,s);return[r]}function Ti(){return b.getNextContextId()}var Si="http://www.w3.org/2000/svg";function yn(e,t=!1){return t?document.createElementNS(Si,e):document.createElement(e)}function Pi(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=As();let a,i=!!b.context;return cs(()=>{i&&(As().user=i=!1),a||(a=tn(r,()=>$(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,u]=Q(!1),f=()=>u(!0);ge(d=>Lt(l,()=>c()?d():a(),null)),qe(f)}else{const c=yn(e.isSVG?"g":"div",e.isSVG),u=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Lt(u,a),l.appendChild(c),e.ref&&e.ref(c),qe(()=>l.removeChild(c))}},void 0,{render:!i}),s}function xi(e,t){const s=$(e);return $(()=>{const n=s();switch(typeof n){case"function":return Y(()=>n(t));case"string":const r=oi.has(n),a=b.context?yi():yn(n,r);return mn(a,t,r),a}})}function _i(e){const[,t]=ln(e,["component"]);return xi(()=>e.component,t)}var vi=class{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}},An=class{constructor(e){this.generateIdentifier=e,this.kv=new vi}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}},wi=class extends An{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t=="object"?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}};function bi(e){if("values"in Object)return Object.values(e);const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t}function Ci(e,t){const s=bi(e);if("find"in s)return s.find(t);const n=s;for(let r=0;r<n.length;r++){const a=n[r];if(t(a))return a}}function Ke(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function xt(e,t){return e.indexOf(t)!==-1}function xs(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var Ii=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Ci(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Ni=e=>Object.prototype.toString.call(e).slice(8,-1),Tn=e=>typeof e>"u",Li=e=>e===null,Ze=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Yt=e=>Ze(e)&&Object.keys(e).length===0,Ee=e=>Array.isArray(e),ji=e=>typeof e=="string",ki=e=>typeof e=="number"&&!isNaN(e),Di=e=>typeof e=="boolean",Oi=e=>e instanceof RegExp,et=e=>e instanceof Map,tt=e=>e instanceof Set,Sn=e=>Ni(e)==="Symbol",Gi=e=>e instanceof Date&&!isNaN(e.valueOf()),Ri=e=>e instanceof Error,_s=e=>typeof e=="number"&&isNaN(e),Mi=e=>Di(e)||Li(e)||Tn(e)||ki(e)||ji(e)||Sn(e),Bi=e=>typeof e=="bigint",Ui=e=>e===1/0||e===-1/0,Fi=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),qi=e=>e instanceof URL,Pn=e=>e.replace(/\./g,"\\."),Qt=e=>e.map(String).map(Pn).join("."),Ye=e=>{const t=[];let s="";for(let r=0;r<e.length;r++){let a=e.charAt(r);if(a==="\\"&&e.charAt(r+1)==="."){s+=".",r++;continue}if(a==="."){t.push(s),s="";continue}s+=a}const n=s;return t.push(n),t};function re(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var xn=[re(Tn,"undefined",()=>null,()=>{}),re(Bi,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),re(Gi,"Date",e=>e.toISOString(),e=>new Date(e)),re(Ri,"Error",(e,t)=>{const s={name:e.name,message:e.message};return t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s},(e,t)=>{const s=new Error(e.message);return s.name=e.name,s.stack=e.stack,t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s}),re(Oi,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),re(tt,"set",e=>[...e.values()],e=>new Set(e)),re(et,"map",e=>[...e.entries()],e=>new Map(e)),re(e=>_s(e)||Ui(e),"number",e=>_s(e)?"NaN":e>0?"Infinity":"-Infinity",Number),re(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),re(qi,"URL",e=>e.toString(),e=>new URL(e))];function Bt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var _n=Bt((e,t)=>Sn(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,s)=>{const n=s.symbolRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),Ki=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),vn=Bt(Fi,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=Ki[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function wn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var bn=Bt(wn,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const s=t.classRegistry.getAllowedProps(e.constructor);if(!s)return{...e};const n={};return s.forEach(r=>{n[r]=e[r]}),n},(e,t,s)=>{const n=s.classRegistry.getValue(t[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),e)}),Cn=Bt((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,s)=>{const n=s.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),Qi=[bn,_n,Cn,vn],vs=(e,t)=>{const s=xs(Qi,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=xs(xn,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},In={};xn.forEach(e=>{In[e.annotation]=e});var Vi=(e,t,s)=>{if(Ee(t))switch(t[0]){case"symbol":return _n.untransform(e,t,s);case"class":return bn.untransform(e,t,s);case"custom":return Cn.untransform(e,t,s);case"typed-array":return vn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=In[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},we=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const s=e.keys();for(;t>0;)s.next(),t--;return s.next().value};function Nn(e){if(xt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(xt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(xt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var Hi=(e,t)=>{Nn(t);for(let s=0;s<t.length;s++){const n=t[s];if(tt(e))e=we(e,+n);else if(et(e)){const r=+n,a=+t[++s]==0?"key":"value",i=we(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},Jt=(e,t,s)=>{if(Nn(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(Ee(n)){const l=+i;n=n[l]}else if(Ze(n))n=n[i];else if(tt(n)){const l=+i;n=we(n,l)}else if(et(n)){if(a===t.length-2)break;const c=+i,u=+t[++a]==0?"key":"value",f=we(n,c);switch(u){case"key":n=f;break;case"value":n=n.get(f);break}}}const r=t[t.length-1];if(Ee(n)?n[+r]=s(n[+r]):Ze(n)&&(n[r]=s(n[r])),tt(n)){const a=we(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(et(n)){const a=+t[t.length-2],i=we(n,a);switch(+r==0?"key":"value"){case"key":{const c=s(i);n.set(c,n.get(i)),c!==i&&n.delete(i);break}case"value":{n.set(i,s(n.get(i)));break}}}return e};function Xt(e,t,s=[]){if(!e)return;if(!Ee(e)){Ke(e,(a,i)=>Xt(a,t,[...s,...Ye(i)]));return}const[n,r]=e;r&&Ke(r,(a,i)=>{Xt(a,t,[...s,...Ye(i)])}),t(n,s)}function zi(e,t,s){return Xt(t,(n,r)=>{e=Jt(e,r,a=>Vi(a,n,s))}),e}function $i(e,t){function s(n,r){const a=Hi(e,Ye(r));n.map(Ye).forEach(i=>{e=Jt(e,i,()=>a)})}if(Ee(t)){const[n,r]=t;n.forEach(a=>{e=Jt(e,Ye(a),()=>e)}),r&&Ke(r,s)}else Ke(t,s);return e}var Wi=(e,t)=>Ze(e)||Ee(e)||et(e)||tt(e)||wn(e,t);function Yi(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function Ji(e,t){const s={};let n;return e.forEach(r=>{if(r.length<=1)return;t||(r=r.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...i]=r;a.length===0?n=i.map(Qt):s[Qt(a)]=i.map(Qt)}),n?Yt(s)?[n]:[n,s]:Yt(s)?void 0:s}var Ln=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=Mi(e);if(!l){Yi(e,r,t);const E=i.get(e);if(E)return n?{transformedValue:null}:E}if(!Wi(e,s)){const E=vs(e,s),S=E?{transformedValue:E.value,annotations:[E.type]}:{transformedValue:e};return l||i.set(e,S),S}if(xt(a,e))return{transformedValue:null};const c=vs(e,s),u=(c==null?void 0:c.value)??e,f=Ee(u)?[]:{},d={};Ke(u,(E,S)=>{if(S==="__proto__"||S==="constructor"||S==="prototype")throw new Error(`Detected property ${S}. This is a prototype pollution risk, please remove it from your object.`);const x=Ln(E,t,s,n,[...r,S],[...a,e],i);f[S]=x.transformedValue,Ee(x.annotations)?d[S]=x.annotations:Ze(x.annotations)&&Ke(x.annotations,(A,T)=>{d[Pn(S)+"."+T]=A})});const g=Yt(d)?{transformedValue:f,annotations:c?[c.type]:void 0}:{transformedValue:f,annotations:c?[c.type,d]:d};return l||i.set(e,g),g};function jn(e){return Object.prototype.toString.call(e).slice(8,-1)}function ws(e){return jn(e)==="Array"}function Xi(e){if(jn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function Zi(e,t,s,n,r){const a={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=s),r&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function Zt(e,t={}){if(ws(e))return e.map(r=>Zt(r,t));if(!Xi(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(ws(t.props)&&!t.props.includes(a))return r;const i=e[a],l=Zt(i,t);return Zi(r,a,l,e,t.nonenumerable),r},{})}var U=class{constructor({dedupe:e=!1}={}){this.classRegistry=new wi,this.symbolRegistry=new An(t=>t.description??""),this.customTransformerRegistry=new Ii,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=Ln(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=Ji(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=Zt(t);return s!=null&&s.values&&(n=zi(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=$i(n,s.referentialEqualities)),n}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};U.defaultInstance=new U;U.serialize=U.defaultInstance.serialize.bind(U.defaultInstance);U.deserialize=U.defaultInstance.deserialize.bind(U.defaultInstance);U.stringify=U.defaultInstance.stringify.bind(U.defaultInstance);U.parse=U.defaultInstance.parse.bind(U.defaultInstance);U.registerClass=U.defaultInstance.registerClass.bind(U.defaultInstance);U.registerSymbol=U.defaultInstance.registerSymbol.bind(U.defaultInstance);U.registerCustom=U.defaultInstance.registerCustom.bind(U.defaultInstance);U.allowErrorProps=U.defaultInstance.allowErrorProps.bind(U.defaultInstance);var kn=U.serialize,eo=U.stringify;function to(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function so(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function no({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function ro({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function ao(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var io=(e,t=!1)=>{const{json:s}=kn(e);return JSON.stringify(s,null,t?2:void 0)},yt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,oo=(e,t)=>e.queryHash.localeCompare(t.queryHash),Dn=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,lo=(e,t)=>yt(e)===yt(t)?Dn(e,t):yt(e)>yt(t)?1:-1,co={status:lo,"query hash":oo,"last updated":Dn},At=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,On=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,uo=(e,t)=>At(e)===At(t)?On(e,t):At(e)>At(t)?1:-1,fo={status:uo,"last updated":On},ho=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),go=()=>{const[e,t]=Q("dark");return en(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)");t(s.matches?"dark":"light");const n=r=>{t(r.matches?"dark":"light")};s.addEventListener("change",n),qe(()=>s.removeEventListener("change",n))}),e},ze=(e,t,s)=>{if(t.length===0)return s;if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.set(t[0],s),n;const[r,...a]=t;return n.set(r,ze(n.get(r),a,s)),n}if(e instanceof Set){const n=ze(Array.from(e),t,s);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=ze(n[r],a,s),n}if(e instanceof Object){const n={...e};if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=ze(n[r],a,s),n}return e},$e=(e,t)=>{if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.delete(t[0]),s;const[n,...r]=t;return s.set(n,$e(s.get(n),r)),s}if(e instanceof Set){const s=$e(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((a,i)=>i.toString()!==t[0]);const[n,...r]=t;return s[n]=$e(s[n],r),s}if(e instanceof Object){const s={...e};if(t.length===1)return delete s[t[0]],s;const[n,...r]=t;return s[n]=$e(s[n],r),s}return e},Gn=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const n=document.createElement("style"),r=document.createTextNode("");n.appendChild(r),n.id="_goober",n.setAttribute("nonce",e),t?t.appendChild(n):document.head.appendChild(n)},be,st,nt,rt,Se,at,Ce,Ie,Ne,Le,je,it,ke,ot,Is,mo=(Is=class{constructor(e){M(this,be);M(this,st);M(this,nt);M(this,rt);M(this,Se,!1);M(this,at);M(this,Ce);M(this,Ie);M(this,Ne);M(this,Le);M(this,je);M(this,it);M(this,ke);M(this,ot);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:u,shadowDOMTarget:f,hideDisabledQueries:d}=e;G(this,be,Q(t)),G(this,nt,s),G(this,rt,n),G(this,st,r),G(this,at,u),G(this,Ce,f),G(this,Ie,Q(a)),G(this,Ne,Q(i)),G(this,Le,Q(l)),G(this,je,Q(c)),G(this,it,Q(d))}setButtonPosition(e){_(this,Ie)[1](e)}setPosition(e){_(this,Ne)[1](e)}setInitialIsOpen(e){_(this,Le)[1](e)}setErrorTypes(e){_(this,je)[1](e)}setClient(e){_(this,be)[1](e)}mount(e){if(_(this,Se))throw new Error("Devtools is already mounted");const t=dn(()=>{const s=this,[n]=_(this,Ie),[r]=_(this,Ne),[a]=_(this,Le),[i]=_(this,je),[l]=_(this,it),[c]=_(this,be);let u;return _(this,ke)?u=_(this,ke):(u=cn(()=>Promise.resolve().then(()=>require("./NCMVHL6D-rzEn9a-Z.cjs"))),G(this,ke,u)),Gn(_(this,at),_(this,Ce)),ds(u,fs({get queryFlavor(){return _(s,nt)},get version(){return _(s,rt)},get onlineManager(){return _(s,st)},get shadowDOMTarget(){return _(s,Ce)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()}}))},e);G(this,Se,!0),G(this,ot,t)}unmount(){var e;if(!_(this,Se))throw new Error("Devtools is not mounted");(e=_(this,ot))==null||e.call(this),G(this,Se,!1)}},be=new WeakMap,st=new WeakMap,nt=new WeakMap,rt=new WeakMap,Se=new WeakMap,at=new WeakMap,Ce=new WeakMap,Ie=new WeakMap,Ne=new WeakMap,Le=new WeakMap,je=new WeakMap,it=new WeakMap,ke=new WeakMap,ot=new WeakMap,Is),De,lt,ct,ut,Pe,dt,Oe,Ge,Re,Me,Be,ft,Ue,Fe,ht,Ns,Eo=(Ns=class{constructor(e){M(this,De);M(this,lt);M(this,ct);M(this,ut);M(this,Pe,!1);M(this,dt);M(this,Oe);M(this,Ge);M(this,Re);M(this,Me);M(this,Be);M(this,ft);M(this,Ue);M(this,Fe);M(this,ht);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:u,shadowDOMTarget:f,onClose:d,hideDisabledQueries:g}=e;G(this,De,Q(t)),G(this,ct,s),G(this,ut,n),G(this,lt,r),G(this,dt,u),G(this,Oe,f),G(this,Ge,Q(a)),G(this,Re,Q(i)),G(this,Me,Q(l)),G(this,Be,Q(c)),G(this,ft,Q(g)),G(this,Ue,Q(d))}setButtonPosition(e){_(this,Ge)[1](e)}setPosition(e){_(this,Re)[1](e)}setInitialIsOpen(e){_(this,Me)[1](e)}setErrorTypes(e){_(this,Be)[1](e)}setClient(e){_(this,De)[1](e)}setOnClose(e){_(this,Ue)[1](()=>e)}mount(e){if(_(this,Pe))throw new Error("Devtools is already mounted");const t=dn(()=>{const s=this,[n]=_(this,Ge),[r]=_(this,Re),[a]=_(this,Me),[i]=_(this,Be),[l]=_(this,ft),[c]=_(this,De),[u]=_(this,Ue);let f;return _(this,Fe)?f=_(this,Fe):(f=cn(()=>Promise.resolve().then(()=>require("./2AITGKQY-CuxhppUA.cjs"))),G(this,Fe,f)),Gn(_(this,dt),_(this,Oe)),ds(f,fs({get queryFlavor(){return _(s,ct)},get version(){return _(s,ut)},get onlineManager(){return _(s,lt)},get shadowDOMTarget(){return _(s,Oe)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get onClose(){return u()}}))},e);G(this,Pe,!0),G(this,ht,t)}unmount(){var e;if(!_(this,Pe))throw new Error("Devtools is not mounted");(e=_(this,ht))==null||e.call(this),G(this,Pe,!1)}},De=new WeakMap,lt=new WeakMap,ct=new WeakMap,ut=new WeakMap,Pe=new WeakMap,dt=new WeakMap,Oe=new WeakMap,Ge=new WeakMap,Re=new WeakMap,Me=new WeakMap,Be=new WeakMap,ft=new WeakMap,Ue=new WeakMap,Fe=new WeakMap,ht=new WeakMap,Ns);function po(e){const t=P.useQueryClient(e.client),s=z.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:u}=e,[f]=z.useState(new mo({client:t,queryFlavor:"React Query",version:"5",onlineManager:P.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:u}));return z.useEffect(()=>{f.setClient(t)},[t,f]),z.useEffect(()=>{n&&f.setButtonPosition(n)},[n,f]),z.useEffect(()=>{r&&f.setPosition(r)},[r,f]),z.useEffect(()=>{f.setInitialIsOpen(a||!1)},[a,f]),z.useEffect(()=>{f.setErrorTypes(i||[])},[i,f]),z.useEffect(()=>(s.current&&f.mount(s.current),()=>{f.unmount()}),[f]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function yo(e){const t=P.useQueryClient(e.client),s=z.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i}=e,[l]=z.useState(new Eo({client:t,queryFlavor:"React Query",version:"5",onlineManager:P.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:n,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:i}));return z.useEffect(()=>{l.setClient(t)},[t,l]),z.useEffect(()=>{l.setOnClose(e.onClose??(()=>{}))},[e.onClose,l]),z.useEffect(()=>{l.setErrorTypes(n||[])},[n,l]),z.useEffect(()=>(s.current&&l.mount(s.current),()=>{l.unmount()}),[l]),o.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:s})}var bs=process.env.NODE_ENV!=="development"?function(){return null}:po;process.env.NODE_ENV;const Rn=V.atom(""),Ao=()=>{w.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),w.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},To=()=>{const e=k(),t=j();return P.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},So=()=>{const{data:e}=X(),{data:t}=ue(),{data:s}=ye(),n=k(),r=j(),a=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]);return P.useMutation({mutationFn:async({block:i})=>r(n,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:i,lang:(t==null?void 0:t.lang)||a,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:a,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id}}})})},Mn=()=>{const[,e]=ee();return h.useCallback((t,s)=>{const r=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});r&&a.set("lang",r),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),s==null||s()},[e])},Bn=()=>{const e=Mn();return h.useCallback(({pageId:t})=>{e(t)},[e])},Po=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-zEPka3BT.cjs"))),xo=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-B56XAto8.cjs"))),_o=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-B0NRCfkL.cjs"))),vo=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-DBBTePPU.cjs")));Ao();Yn.loadWebBlocks();w.registerChaiTopBar(aa);ba();w.registerChaiMediaManager(Po);w.registerChaiSaveToLibrary(xo);const wo={role:"",permissions:null},Cs=e=>{const{data:t}=Ea();gr();const s=Ot(),{data:n=wo,isFetching:r}=Vs(),{data:a,isFetching:i}=de(),{data:l,isFetching:c}=To(),{data:u,isFetching:f}=ye(),d=r||i||c||f,[g]=ee(),E=g.get("page"),{data:S}=X(),{data:x,isFetching:A}=ca(),{blocks:T}=la(x),{lockingStatus:C,pageLock:N}=Ae(),{data:R,isFetching:K}=Ks(),O=ia(),{onSave:ie}=pa(),{mutateAsync:oe}=So(),{getPartialBlocks:q,getPartialBlockBlocks:I}=ya(),{mutateAsync:L}=Cr(),{mutateAsync:W}=Qs(),H=Bn(),[ne,mt]=h.useState(!1),le=h.useRef([]),_e=h.useMemo(()=>p.get(u,"theme",{})||{},[u]),Te=p.isEmpty(C)&&(N==null?void 0:N.status)==="editing",qn=(N==null?void 0:N.status)==="checking",hs=A||qn||K;le.current=T;const[Kn]=V.useAtom(Rn);h.useEffect(()=>{const Z=()=>{document.hidden?mt(!0):mt(!1)};return window.addEventListener("visibilitychange",Z),()=>window.removeEventListener("visibilitychange",Z)},[]);const Qn=h.useMemo(()=>{const Z={};return n&&(Z.permissions=p.get(n,"permissions",null),Z.role=p.get(n,"role","user")),Z},[n]),Vn=h.useMemo(()=>t==null?void 0:t.some(Z=>Z.isSiteLibrary),[t]),Hn=h.useCallback(async(Z,Et)=>await L({pageType:Z,query:Et}),[L]);return o.jsxs(o.Fragment,{children:[hs&&o.jsx(os,{className:d?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(v.Loader,{className:`animate-spin text-primary ${d?"h-6 w-6":"h-5 w-5"}`})}),Kn&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:o.jsx(v.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(vo,{})}),o.jsx(w.ChaiBuilderEditor,{_tempProps:{librarySite:Vn},gotoPage:H,collections:l??[],getBlockAsyncProps:oe,pageExternalData:R,themePresets:e.themePresets??[],pageId:S==null?void 0:S.id,loading:A,fallbackLang:s,languages:(u==null?void 0:u.languages)||[],brandingOptions:(u==null?void 0:u.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!ne&&Te&&(e.autoSave??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:I,getPartialBlocks:q,blocks:A?[]:T,theme:p.cloneDeep(_e),pageTypes:a,searchPageTypeItems:Hn,askAiCallBack:O,onSave:async({blocks:Z,theme:Et,needTranslations:zn})=>{if(!E)return!0;le.current=Z;const gs=[...Z];return await ie({page:E,blocks:gs,needTranslations:zn}),le.current=gs,p.isEqual(Et,_e)||await W({settings:{theme:Et}}),!0},themePanelComponent:_o,...Qn}),o.jsxs("div",{children:[o.jsx(pr,{isFetchingPage:hs}),o.jsx(yr,{})]})]})},bo=new P.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),Co=e=>{const[,t]=jt(),[s,n]=h.useState(!1);return h.useEffect(()=>(t(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","websocket","getLoggedInUser","features","currentUser"])),setTimeout(()=>{n(!0)},200),()=>{n(!1),t({})}),[e,t]),s?p.get(e,"hasReactQueryProvider",!1)===!0?o.jsxs(o.Fragment,{children:[o.jsx(Cs,{...e}),o.jsx(bs,{})]}):o.jsxs(P.QueryClientProvider,{client:bo,children:[o.jsx(Cs,{...e}),o.jsx(bs,{})]}):o.jsx("div",{})},Io=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-D_iF9Sm3.cjs")));function Un({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=z.useState(!1);return o.jsxs(m.Popover,{open:r,onOpenChange:a,children:[o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsx(m.PopoverTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,disabled:n,children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:o.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),o.jsx(m.TooltipContent,{children:"Add field"})]}),r&&o.jsx(z.Suspense,{children:o.jsx(Io,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const No=()=>{const{savePageAsync:e}=w.useSavePage(),t=P.useQueryClient();return h.useCallback(async()=>{await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t])},Lo=()=>{const e=P.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},jo=()=>{const e=k(),t=j(),{data:s}=ue(),n=P.useQueryClient();return P.useMutation({mutationFn:async r=>{if(!(s!=null&&s.id))throw new Error("No active page found");return await t(`${e}`,{action:y.UPDATE_PAGE_METADATA,data:{id:s.id,metadata:r}})},onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]}),n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})},ko=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-zEPka3BT.cjs"))),Do=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:i}=w.useTranslation(),[l,c]=h.useState(!1),u=()=>{a||c(!0)},f=()=>{c(!1)},d=S=>{const x=Array.isArray(S)?S[0]:S;x!=null&&x.url&&s(p.pick(x,["url","id"])),c(!1)},g=()=>{s({url:"",id:""})},E=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return o.jsxs("div",{className:`w-full ${n}`,children:[t?o.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[E?o.jsx("div",{className:"flex h-12 items-center bg-gray-100 px-4",children:o.jsx("p",{className:"text-xs text-gray-500",children:t})}):o.jsx("img",{onClick:u,src:t,alt:i("Selected image"),className:"h-auto max-h-[100px] w-full bg-gray-100 object-contain"}),o.jsxs("div",{className:"absolute right-2 top-2 flex gap-2",children:[o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:g,disabled:a,children:E?o.jsx(v.X,{className:"h-4 w-4"}):o.jsx(v.Trash2,{className:"h-4 w-4"})}),!E&&o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:u,disabled:a,children:o.jsx(v.ImageIcon,{className:"h-4 w-4"})})]})]}):o.jsx("div",{className:`flex cursor-pointer items-center justify-center rounded-md border border-dashed p-6 ${a?"cursor-not-allowed opacity-50":"hover:border-gray-400"}`,onClick:u,children:o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx(v.ImageIcon,{className:"h-10 w-10 text-gray-400"}),o.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),o.jsx(m.Dialog,{open:l,onOpenChange:c,children:o.jsxs(m.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[o.jsxs(m.DialogHeader,{className:"hidden border-b px-4 py-2",children:[o.jsx(m.DialogTitle,{children:i("Select Image")}),o.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:f,children:o.jsx(v.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(h.Suspense,{children:o.jsx(ko,{close:f,onSelect:d,mode:"image",assetId:e})})})]})})]})},Oo=h.createContext(null),Vt={didCatch:!1,error:null};class Fn extends h.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Vt}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var s,n,r=arguments.length,a=new Array(r),i=0;i<r;i++)a[i]=arguments[i];(s=(n=this.props).onReset)===null||s===void 0||s.call(n,{args:a,reason:"imperative-api"}),this.setState(Vt)}}componentDidCatch(t,s){var n,r;(n=(r=this.props).onError)===null||n===void 0||n.call(r,t,s)}componentDidUpdate(t,s){const{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&s.error!==null&&Go(t.resetKeys,r)){var a,i;(a=(i=this.props).onReset)===null||a===void 0||a.call(i,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(Vt)}}render(){const{children:t,fallbackRender:s,FallbackComponent:n,fallback:r}=this.props,{didCatch:a,error:i}=this.state;let l=t;if(a){const c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof s=="function")l=s(c);else if(n)l=h.createElement(n,c);else if(r!==void 0)l=r;else throw i}return h.createElement(Oo.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},l)}}function Go(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((s,n)=>!Object.is(s,t[n]))}const Ro=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),es=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};try{return{isValid:!0,parsed:JSON.parse(e),error:null,placeholders:[]}}catch{}const t=/{{([^{}]+)}}/g,s=[];let n=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],i=r.index,l=`"__placeholder_${s.length}__"`;s.push({original:a,replaced:l,position:i}),n=n.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(n),error:null,placeholders:s}}catch(a){const i=a,l=i.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let u,f;if(c!==void 0){const d=n.substring(0,c).split(`
2
+ `);u=d.length,f=d[d.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:u,column:f,position:c}}}},Mo=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(Ro(i),"g");n=n.replace(l,r)}),n},Bo=(e,t)=>{if(!e)return"";let s=JSON.stringify(e,null,2);const n=/{{([^{}]+)}}/g;let r;for(;(r=n.exec(s))!==null;){const a=r[1],i=p.get(t,a,null);s=s.replace(r[0],i)}return s},Uo=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-pNjN-zzY.cjs"))),Fo=({value:e,onChange:t,disabled:s=!1,readOnly:n=!1,placeholder:r="Enter JSON",rows:a=6,id:i="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:u,copyJsonLDFromDefaultPage:f})=>{const[d,g]=h.useState("edit"),[E,S]=h.useState(null),[x,A]=h.useState(""),T=h.useRef(null),[C]=jt(),N=i==="jsonLD"&&p.get(C,"features.sharedJsonLD",!1),R=i==="jsonLD"&&!u&&!!f;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const K=q=>{if(n)return;const I=q.target.value;t(I)},O=q=>{if(q.key==="Tab"){q.preventDefault();const I=q.currentTarget,L=I.selectionStart,W=I.selectionEnd;if(L!==W){const ne=e.substring(L,W).split(`
3
+ `);if(q.shiftKey){const le=ne.map(Te=>Te.startsWith(" ")?Te.substring(2):Te).join(`
4
+ `),_e=e.substring(0,L)+le+e.substring(W);t(_e),setTimeout(()=>{I.selectionStart=L,I.selectionEnd=L+le.length},0)}else{const le=ne.map(Te=>` ${Te}`).join(`
5
+ `),_e=e.substring(0,L)+le+e.substring(W);t(_e),setTimeout(()=>{I.selectionStart=L,I.selectionEnd=L+le.length},0)}}else{const H=e.substring(0,L)+" "+e.substring(W);t(H),setTimeout(()=>{I.selectionStart=I.selectionEnd=L+2},0)}}};h.useEffect(()=>{const q=es(e);if(q.isValid)if(S(null),q.parsed){const I=Bo(q.parsed,l);A(I)}else A("");else S(q.error),A("")},[e,l]);const ie=()=>{const q=es(e);if(q.isValid&&q.parsed){const I=Mo(q.parsed,q.placeholders);t(I)}},oe=()=>{E!=null&&E.position&&T.current&&(T.current.focus(),T.current.setSelectionRange(E.position,E.position+1))};return o.jsx(Fn,{fallback:o.jsx("div",{children:"Some error"}),children:o.jsx("div",{className:"space-y-2",children:o.jsxs(m.Tabs,{value:d,onValueChange:g,className:"w-full",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs(m.TabsList,{className:"w-max",children:[o.jsxs(m.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[o.jsx(v.Code,{className:"h-4 w-4"}),o.jsx("span",{children:"Edit"})]}),o.jsxs(m.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||E!==null||R,children:[o.jsx(v.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),N&&o.jsxs(m.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||E!==null,children:[o.jsx(v.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),R?null:d==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(Un,{dataType:"value",data:l??{},onSelect:q=>c&&c(q,i)})})]}),o.jsxs(m.TabsContent,{value:"edit",className:"relative mt-0",children:[!R&&d==="edit"&&o.jsx(Gt,{content:"Format JSON",side:"right",showTooltip:!s&&!E,children:o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",onClick:ie,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||E!==null,children:o.jsx(v.FileCode2,{})})}),R?o.jsx("div",{className:"flex h-40 items-center justify-center rounded-md bg-black/20",children:o.jsxs("div",{className:"flex max-w-[400px] flex-col items-center gap-2 rounded-md bg-white p-4 shadow-lg",children:[o.jsx("div",{className:"max-w-xl text-center text-xs text-gray-500",children:"JSON-LD for is not added for selected language. JSON LD will be used from default language."}),o.jsxs(m.Button,{type:"button",variant:"default",size:"sm",onClick:f,children:[o.jsx(v.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(m.Textarea,{ref:T,id:i,name:i,className:`rounded-md border border-input text-xs ${E?"border-red-500":""}`,onChange:K,onKeyDown:O,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),E&&o.jsxs(m.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(v.AlertTriangle,{className:"h-4 w-4"}),o.jsxs(m.AlertDescription,{className:"flex flex-col",children:[o.jsx("span",{className:"font-medium",children:"Invalid JSON"}),o.jsx("span",{className:"text-sm",children:E.message}),E.line&&E.column&&o.jsxs("span",{className:"text-sm",children:["Error at line ",E.line,", column ",E.column]}),o.jsx(m.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:oe,children:"Show position"})]})]})]}),o.jsxs(m.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(m.Textarea,{rows:a,value:x,readOnly:!0,className:"cursor-default bg-muted font-mono text-sm"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This is how the JSON will look after placeholder substitution."})]}),N&&o.jsx(m.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(Uo,{})})})]})})})};if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=ls;exports.ACTIONS=y;exports.BlurContainer=os;exports.ChaiBuilderPages=Co;exports.ChaiBuilderPagesRealtime=ks;exports.Dynamic=_i;exports.ErrorBoundary=Fn;exports.For=Wa;exports.ImagePicker=Do;exports.Index=Ya;exports.LANGUAGES=Ve;exports.LanguageSwitcher=Bs;exports.Match=Za;exports.NestedPathSelector=Un;exports.PAGES_PERMISSIONS=te;exports.PageActionsDropdown=Fs;exports.PermissionChecker=Tt;exports.Portal=Pi;exports.Show=Ja;exports.SmartJsonInput=Fo;exports.Switch=Xa;exports.Tooltip=Gt;exports.addEventListener=gn;exports.addNewLangAtom=Dt;exports.batch=ja;exports.className=hn;exports.clearDelegatedEvents=fi;exports.convertRemToPixels=ho;exports.createComponent=ds;exports.createComputed=Zs;exports.createContext=Ra;exports.createEffect=cs;exports.createMemo=$;exports.createRenderEffect=me;exports.createRoot=ge;exports.createSignal=Q;exports.createUniqueId=$a;exports.delegateEvents=fn;exports.deleteNestedDataByPath=$e;exports.displayValue=io;exports.getMutationStatusColor=ro;exports.getPreferredColorScheme=go;exports.getQueryStatusColor=no;exports.getQueryStatusColorByLabel=ao;exports.getQueryStatusLabel=to;exports.getSidedProp=so;exports.insert=Lt;exports.memo=ci;exports.mergeProps=fs;exports.mutationSortFns=fo;exports.navigateToPage=rs;exports.on=ka;exports.onCleanup=qe;exports.onMount=en;exports.parseJSONWithPlaceholders=es;exports.previewUrlAtom=Rn;exports.serialize=kn;exports.setAttribute=Nt;exports.sortFns=co;exports.splitProps=ln;exports.spread=mn;exports.stringify=eo;exports.template=di;exports.throwConfetti=St;exports.untrack=Y;exports.updateNestedDataByPath=ze;exports.use=En;exports.useActivePage=ue;exports.useAddGlobalSchema=ua;exports.useApiUrl=k;exports.useApplySchemaToAllPages=ga;exports.useAssetsApiUrl=Zn;exports.useBuilderFetch=sr;exports.useBuilderPageData=Ks;exports.useChaiAuth=gt;exports.useChaiUserInfo=Gs;exports.useChangePage=Mn;exports.useChangeSlug=Or;exports.useClearAll=Lo;exports.useContext=Ma;exports.useCreatePage=Ir;exports.useCurrentPage=X;exports.useDeleteGlobalSchema=fa;exports.useDeletePage=Lr;exports.useDynamicPageSelector=Os;exports.useFallbackLang=Ot;exports.useFetch=j;exports.useGotoPage=Bn;exports.useIsLanguagePageCreated=ts;exports.useLanguagePages=pe;exports.useMarkAsTemplate=kr;exports.usePageEditInfo=kt;exports.usePageLockRequestTakeOver=Rs;exports.usePageType=Us;exports.usePageTypes=de;exports.usePageUserMapping=hr;exports.usePagesProps=jt;exports.usePublishPages=is;exports.useReloadPage=No;exports.useRemoveSchemaFromAllPages=ma;exports.useSearchParams=ee;exports.useTogglePageGlobalSchema=ha;exports.useTransition=Ga;exports.useUnmarkAsTemplate=Dr;exports.useUnpublishPage=jr;exports.useUpdateActivePageMetadata=jo;exports.useUpdateGlobalSchema=da;exports.useUpdatePage=Nr;exports.useUpdateWebsiteSettings=Qs;exports.useUserRoleAndPermissions=Vs;exports.useWebsiteLanguagePages=Ar;exports.useWebsitePages=as;exports.useWebsiteSetting=ye;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-BELYt0c9.cjs"),s=require("@chaibuilder/sdk");exports.ChaiBuilderPagesRealtime=e.ChaiBuilderPagesRealtime;exports.ChaiJsonInput=e.SmartJsonInput;exports.ImagePicker=e.ImagePicker;exports.LanguageSwitcher=e.LanguageSwitcher;exports.NestedPathSelector=e.NestedPathSelector;exports.PermissionChecker=e.PermissionChecker;exports.default=e.ChaiBuilderPages;exports.useActivePage=e.useActivePage;exports.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useCurrentPage;exports.useChaiFetch=e.useChaiFetch;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useClearAll=e.useClearAll;exports.useFallbackLang=e.useFallbackLang;exports.useFetch=e.useFetch;exports.useGotoPage=e.useGotoPage;exports.useLanguagePages=e.useLanguagePages;exports.usePageTypes=e.usePageTypes;exports.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;Object.keys(s).forEach(a=>{a!=="default"&&!Object.prototype.hasOwnProperty.call(exports,a)&&Object.defineProperty(exports,a,{enumerable:!0,get:()=>s[a]})});
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-DOlBrCPx.cjs"),s=require("@chaibuilder/sdk");exports.ChaiBuilderPagesRealtime=e.ChaiBuilderPagesRealtime;exports.ChaiJsonInput=e.SmartJsonInput;exports.ImagePicker=e.ImagePicker;exports.LanguageSwitcher=e.LanguageSwitcher;exports.NestedPathSelector=e.NestedPathSelector;exports.PermissionChecker=e.PermissionChecker;exports.default=e.ChaiBuilderPages;exports.useActivePage=e.useActivePage;exports.useApiUrl=e.useApiUrl;exports.useBuilderFetch=e.useBuilderFetch;exports.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useCurrentPage;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useClearAll=e.useClearAll;exports.useFallbackLang=e.useFallbackLang;exports.useFetch=e.useFetch;exports.useGotoPage=e.useGotoPage;exports.useLanguagePages=e.useLanguagePages;exports.usePageTypes=e.usePageTypes;exports.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;Object.keys(s).forEach(a=>{a!=="default"&&!Object.prototype.hasOwnProperty.call(exports,a)&&Object.defineProperty(exports,a,{enumerable:!0,get:()=>s[a]})});
package/dist/index.d.ts CHANGED
@@ -133,6 +133,17 @@ export declare const useActivePage: () => {
133
133
  isFetching: boolean;
134
134
  };
135
135
 
136
+ export declare const useApiUrl: () => string;
137
+
138
+ export declare const useBuilderFetch: () => ({ body, headers, url, }: {
139
+ body: {
140
+ action: string;
141
+ data?: any;
142
+ };
143
+ headers?: Record<string, string>;
144
+ url?: string;
145
+ }) => Promise<any>;
146
+
136
147
  export declare const useBuilderPageData: () => UseQueryResult<any, Error>;
137
148
 
138
149
  export declare const useChaiAuth: () => {
@@ -146,13 +157,6 @@ export declare const useChaiCurrentPage: () => {
146
157
  isFetching: boolean;
147
158
  };
148
159
 
149
- export declare const useChaiFetch: () => ({ url, method, body, headers, }: {
150
- method?: "GET" | "POST" | "PUT" | "DELETE";
151
- url: string;
152
- body?: any;
153
- headers?: Record<string, string>;
154
- }) => Promise<any>;
155
-
156
160
  export declare const useChaiUserInfo: (currentEditor: string) => UseQueryResult< {
157
161
  name: string;
158
162
  id: string;
@@ -164,7 +168,7 @@ export declare const useClearAll: () => () => void;
164
168
 
165
169
  export declare const useFallbackLang: () => string;
166
170
 
167
- export declare const useFetch: () => (url: string, body: {
171
+ export declare const useFetch: () => (url: string | undefined, body: {
168
172
  action: string;
169
173
  data?: any;
170
174
  }, headers?: Record<string, string>) => Promise<any>;
package/dist/index.js CHANGED
@@ -1,28 +1,29 @@
1
- import { aW as s, aw as u, aK as t, aI as i, aJ as g, aq as r, aN as P, aO as h, aF as l, aT as o, ap as n, aV as c, ai as C, aP as d, f as m, al as p, aQ as f, g as b, h as A, aR as F, aS as I, aU as S, b as U, e as k } from "./index-Djepisz3.js";
1
+ import { aW as s, aw as u, aK as t, aI as i, aJ as r, aq as g, aN as P, aO as l, ak as h, aV as o, aF as n, aT as c, ap as d, ai as C, aP as p, f as m, al as f, aQ as A, g as U, h as b, aR as k, aS as F, aU as I, b as S, e as B } from "./index-DHfaX2M6.js";
2
2
  export * from "@chaibuilder/sdk";
3
3
  export {
4
4
  s as ChaiBuilderPagesRealtime,
5
5
  u as ChaiJsonInput,
6
6
  t as ImagePicker,
7
7
  i as LanguageSwitcher,
8
- g as NestedPathSelector,
9
- r as PermissionChecker,
8
+ r as NestedPathSelector,
9
+ g as PermissionChecker,
10
10
  P as default,
11
- h as useActivePage,
12
- l as useBuilderPageData,
13
- o as useChaiAuth,
14
- n as useChaiCurrentPage,
15
- c as useChaiFetch,
11
+ l as useActivePage,
12
+ h as useApiUrl,
13
+ o as useBuilderFetch,
14
+ n as useBuilderPageData,
15
+ c as useChaiAuth,
16
+ d as useChaiCurrentPage,
16
17
  C as useChaiUserInfo,
17
- d as useClearAll,
18
+ p as useClearAll,
18
19
  m as useFallbackLang,
19
- p as useFetch,
20
- f as useGotoPage,
21
- b as useLanguagePages,
22
- A as usePageTypes,
23
- F as useReloadPage,
24
- I as useUpdateActivePageMetadata,
25
- S as useUserPermissions,
26
- U as useWebsitePages,
27
- k as useWebsiteSetting
20
+ f as useFetch,
21
+ A as useGotoPage,
22
+ U as useLanguagePages,
23
+ b as usePageTypes,
24
+ k as useReloadPage,
25
+ F as useUpdateActivePageMetadata,
26
+ I as useUserPermissions,
27
+ S as useWebsitePages,
28
+ B as useWebsiteSetting
28
29
  };
@@ -5,7 +5,7 @@ import { startsWith as T, replace as W, isString as X, trim as Y, isArray as Z,
5
5
  import { FileJson as F, Loader as ne, Check as B, Copy as H } from "lucide-react";
6
6
  import { useState as D, useMemo as A } from "react";
7
7
  import { parseDiff as se, Diff as le, Hunk as ae } from "react-diff-view";
8
- import { ak as ie, al as oe, A as ce, ai as de } from "./index-Djepisz3.js";
8
+ import { ak as ie, al as oe, A as ce, ai as de } from "./index-DHfaX2M6.js";
9
9
  import { useQuery as fe } from "@tanstack/react-query";
10
10
  function me(t, n) {
11
11
  const o = ie(), s = oe(), u = T(t.uid, "draft:") || T(n.uid, "live:");
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk/ui"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-BELYt0c9.cjs"),B=require("@tanstack/react-query");function H(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return B.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=u=>u==="draft"||u==="live"?u:"revision",s=u=>p.replace(u.uid,`${u.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:f?0:1/0})}const K=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",f=t.label==="draft";return e.jsxs("span",{className:`flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":f?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":f?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:f?"Currently editing":"Published by"}),!f&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),e.jsx("div",{className:"text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},L=({version:t})=>e.jsx(K,{version:t});function V(t,r,o="data.json"){const n=JSON.stringify(t,null,2),f=JSON.stringify(r,null,2),l=n.split(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk/ui"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-DOlBrCPx.cjs"),B=require("@tanstack/react-query");function H(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return B.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=u=>u==="draft"||u==="live"?u:"revision",s=u=>p.replace(u.uid,`${u.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:f?0:1/0})}const K=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",f=t.label==="draft";return e.jsxs("span",{className:`flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":f?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":f?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:f?"Currently editing":"Published by"}),!f&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),e.jsx("div",{className:"text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},L=({version:t})=>e.jsx(K,{version:t});function V(t,r,o="data.json"){const n=JSON.stringify(t,null,2),f=JSON.stringify(r,null,2),l=n.split(`
2
2
  `),s=f.split(`
3
3
  `);let d=`--- a/${o}
4
4
  `;d+=`+++ b/${o}
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
2
- import { an as j, h as T, L as I, ao as F, g as H, ap as O, e as W, aq as f, ar as o } from "./index-Djepisz3.js";
2
+ import { an as j, h as T, L as I, ao as F, g as H, ap as O, e as W, aq as f, ar as o } from "./index-DHfaX2M6.js";
3
3
  import { useTranslation as G, useLanguages as q } from "@chaibuilder/sdk";
4
4
  import { Dialog as B, DialogContent as R, DialogHeader as J, DialogTitle as K, DialogDescription as Q, Alert as V, Label as X, Input as Y, DialogFooter as Z, Button as A, DropdownMenu as ee, DropdownMenuTrigger as se, DropdownMenuContent as ne, DropdownMenuItem as w } from "@chaibuilder/sdk/ui";
5
5
  import { find as z, startsWith as E, isEqual as ae, filter as le, get as D, map as te, isEmpty as ie } from "lodash-es";
@@ -90,7 +90,7 @@ const fe = ({
90
90
  ) })
91
91
  ] })
92
92
  ] }) });
93
- }, Ne = U(() => import("./delete-page-DE-nabXs.js")), ye = U(() => import("./unpublish-page-D5tWKVLY.js")), Pe = () => {
93
+ }, Ne = U(() => import("./delete-page-X6KE9Snl.js")), ye = U(() => import("./unpublish-page-COPOrCk_.js")), Pe = () => {
94
94
  const { t: n } = G(), [, g] = pe(F), { selectedLang: t, fallbackLang: i, setSelectedLang: v } = q(), { data: N, isFetching: y } = H(), { data: l } = O(), { data: r } = T(), x = he(() => {
95
95
  const a = r == null ? void 0 : r.find((h) => h.key === (l == null ? void 0 : l.pageType));
96
96
  return l != null && l.dynamic ? a == null ? void 0 : a.dynamicSlug : "";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-BELYt0c9.cjs"),C=require("@chaibuilder/sdk"),i=require("@chaibuilder/sdk/ui"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),k=require("sonner"),G=require("jotai"),L=({page:s,onClose:S})=>{const{t:a}=C.useTranslation(),[o,E]=c.useState(s.slug||""),{mutate:N,isPending:y}=n.useChangeSlug(),{data:l}=n.usePageTypes(),d=r.find(l,{key:s==null?void 0:s.pageType}),f=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(p=>o===`/${p}`||r.startsWith(o,`/${p}/`))){k.toast.error(a("Error"),{description:a("Slugs cannot start with a language code for primary page")});return}N({...s,slug:o},{onSuccess:S})},m=(s==null?void 0:s.lang)||"";return e.jsx(i.Dialog,{open:!!s,onOpenChange:S,children:e.jsxs(i.DialogContent,{children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:a("Change Slug")}),e.jsx(i.DialogDescription,{className:"text-xs",children:e.jsxs(i.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),a("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm ",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[a("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[a("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(i.Label,{htmlFor:"slug",className:"text-right",children:[a("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[a("Slug should start with")," /",m]})]}),e.jsx(i.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&E(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:a("Slug must start with /"),placeholder:a("Enter page slug")})]})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{type:"submit",disabled:y||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:a(y?"Changing...":"Change Slug")})})]})]})})},M=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-WPGzECyJ.cjs"))),T=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-Cui0tgvd.cjs"))),_=()=>{const{t:s}=C.useTranslation(),[,S]=G.useAtom(n.addNewLangAtom),{selectedLang:a,fallbackLang:o,setSelectedLang:E}=C.useLanguages(),{data:N,isFetching:y}=n.useLanguagePages(),{data:l}=n.useCurrentPage(),{data:d}=n.usePageTypes(),f=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(l==null?void 0:l.pageType));return l!=null&&l.dynamic?t==null?void 0:t.dynamicSlug:""},[d,l==null?void 0:l.pageType,l==null?void 0:l.dynamic]),[m,h]=c.useState(null),[x,P]=c.useState(null),[p,A]=c.useState(null),{data:b}=n.useWebsiteSetting(),I=r.filter(r.get(b,"languages")||["en"],t=>!r.find(N,{lang:t})&&t!==r.get(b,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:y?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(N,t=>{const g=t.lang,v=t.slug,w=!t.primaryPage,D=g===a;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${D?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>E(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,w?o:g,g)]}),e.jsxs("div",{children:[v&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:f?`${v}/${f}`:v})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),w?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(i.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),S({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),P(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(i.Button,{variant:"default",size:"sm",disabled:r.isEmpty(I),onClick:()=>{S({primaryPage:l==null?void 0:l.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(M,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(T,{page:x,onClose:()=>P(null)})}),p&&e.jsx(c.Suspense,{children:e.jsx(L,{page:p,onClose:()=>A(null)})})]})};exports.default=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-DOlBrCPx.cjs"),C=require("@chaibuilder/sdk"),i=require("@chaibuilder/sdk/ui"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),k=require("sonner"),G=require("jotai"),L=({page:s,onClose:S})=>{const{t:a}=C.useTranslation(),[o,E]=c.useState(s.slug||""),{mutate:N,isPending:y}=n.useChangeSlug(),{data:l}=n.usePageTypes(),d=r.find(l,{key:s==null?void 0:s.pageType}),f=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(p=>o===`/${p}`||r.startsWith(o,`/${p}/`))){k.toast.error(a("Error"),{description:a("Slugs cannot start with a language code for primary page")});return}N({...s,slug:o},{onSuccess:S})},m=(s==null?void 0:s.lang)||"";return e.jsx(i.Dialog,{open:!!s,onOpenChange:S,children:e.jsxs(i.DialogContent,{children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:a("Change Slug")}),e.jsx(i.DialogDescription,{className:"text-xs",children:e.jsxs(i.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),a("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm ",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[a("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[a("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(i.Label,{htmlFor:"slug",className:"text-right",children:[a("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[a("Slug should start with")," /",m]})]}),e.jsx(i.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&E(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:a("Slug must start with /"),placeholder:a("Enter page slug")})]})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{type:"submit",disabled:y||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:a(y?"Changing...":"Change Slug")})})]})]})})},M=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-ftu1i43t.cjs"))),T=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-DU3jKAJ5.cjs"))),_=()=>{const{t:s}=C.useTranslation(),[,S]=G.useAtom(n.addNewLangAtom),{selectedLang:a,fallbackLang:o,setSelectedLang:E}=C.useLanguages(),{data:N,isFetching:y}=n.useLanguagePages(),{data:l}=n.useCurrentPage(),{data:d}=n.usePageTypes(),f=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(l==null?void 0:l.pageType));return l!=null&&l.dynamic?t==null?void 0:t.dynamicSlug:""},[d,l==null?void 0:l.pageType,l==null?void 0:l.dynamic]),[m,h]=c.useState(null),[x,P]=c.useState(null),[p,A]=c.useState(null),{data:b}=n.useWebsiteSetting(),I=r.filter(r.get(b,"languages")||["en"],t=>!r.find(N,{lang:t})&&t!==r.get(b,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:y?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(N,t=>{const g=t.lang,v=t.slug,w=!t.primaryPage,D=g===a;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${D?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>E(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,w?o:g,g)]}),e.jsxs("div",{children:[v&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:f?`${v}/${f}`:v})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),w?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(i.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),S({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),P(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(i.Button,{variant:"default",size:"sm",disabled:r.isEmpty(I),onClick:()=>{S({primaryPage:l==null?void 0:l.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(M,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(T,{page:x,onClose:()=>P(null)})}),p&&e.jsx(c.Suspense,{children:e.jsx(L,{page:p,onClose:()=>A(null)})})]})};exports.default=_;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./index-BELYt0c9.cjs"),M=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),y=require("lodash-es"),d=require("lucide-react"),l=require("react"),w=require("sonner"),q=1*1024*1024,A=({page:r,onClose:m})=>{const{t:s}=M.useTranslation(),[g,u]=l.useState(!1),[f,k]=l.useState(""),[c,j]=l.useState(""),[N,p]=l.useState(!1),i=l.useRef(null),T=b.useMarkAsTemplate(),{data:x}=b.usePageTypes(),h=x==null?void 0:x.find(t=>t.key===r.pageType),C=(h==null?void 0:h.name)||y.startCase(r.pageType),I=l.useCallback(t=>{var v;const o=(v=t.target.files)==null?void 0:v[0];if(o){if(o.size>q){w.toast.error(s("File too large"),{description:`${s("Maximum file size is 1MB. Selected file is")} ${(o.size/1024).toFixed(2)}KB.`}),i.current&&(i.current.value="");return}try{p(!0);const n=new FileReader;n.onloadend=()=>{j(n.result),p(!1)},n.readAsDataURL(o)}catch(n){console.error("Error reading file:",n),p(!1),w.toast.error(s("Failed to process image"),{description:n instanceof Error?n.message:s("Unknown error")})}}},[s]),D=()=>{j(""),i.current&&(i.current.value="")},F=()=>{var t;(t=i.current)==null||t.click()},S=()=>{u(!0),T.mutate({page:r,name:r.name,description:f.trim()||void 0,pageType:r.pageType,...c?{previewImage:c}:{}},{onSuccess:()=>{u(!1),m()},onError:()=>{u(!1)}})};return e.jsx(a.Dialog,{open:!0,onOpenChange:m,children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Mark as template")}),e.jsxs(a.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:[s("Are you sure you want to mark this page as a template?"),e.jsx("br",{}),s("Templates can be used to create new pages with the same content.")]})]}),e.jsxs("div",{className:"mb-4 space-y-4 text-xs",children:[e.jsxs("div",{className:"space-y-3 rounded border bg-slate-50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.Tag,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Page Name"),":"]}),e.jsx("span",{className:"font-semibold",children:y.startCase(r.name)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.File,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Type"),":"]}),e.jsx("span",{className:"font-semibold",children:C})]})]}),e.jsxs("div",{children:[e.jsx(a.Label,{htmlFor:"description",className:"text-xs font-medium",children:s("Description (Optional)")}),e.jsx(a.Textarea,{id:"description",placeholder:s("Describe this template's purpose"),className:"mt-1 h-24 resize-none text-xs",value:f,onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"previewImage",className:"text-xs font-medium",children:s("Preview Image (Optional)")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Input,{type:"file",id:"previewImage",ref:i,onChange:I,accept:"image/*",className:"hidden"}),e.jsx(a.Button,{type:"button",variant:"outline",onClick:F,disabled:N,className:"w-full",children:N?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),s("Uploading...")]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(d.ImageIcon,{className:"h-4 w-4"}),s("Select image")]})}),c&&e.jsx(a.Button,{type:"button",variant:"outline",size:"icon",onClick:D,children:e.jsx(d.X,{className:"h-4 w-4"})})]}),c&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-md border",children:e.jsx("img",{src:c,alt:s("Preview"),className:"h-full max-h-[200px] w-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("max 1mb")})]})]})]}),e.jsxs(a.DialogFooter,{className:g?"pointer-events-none opacity-75":"",children:[e.jsx(a.Button,{variant:"outline",onClick:t=>{t.stopPropagation(),m()},children:s("Cancel")}),e.jsx(a.Button,{variant:"default",disabled:g,onClick:S,children:s("Mark as template")})]})]})})};exports.default=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./index-DOlBrCPx.cjs"),M=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),y=require("lodash-es"),d=require("lucide-react"),l=require("react"),w=require("sonner"),q=1*1024*1024,A=({page:r,onClose:m})=>{const{t:s}=M.useTranslation(),[g,u]=l.useState(!1),[f,k]=l.useState(""),[c,j]=l.useState(""),[N,p]=l.useState(!1),i=l.useRef(null),T=b.useMarkAsTemplate(),{data:x}=b.usePageTypes(),h=x==null?void 0:x.find(t=>t.key===r.pageType),C=(h==null?void 0:h.name)||y.startCase(r.pageType),I=l.useCallback(t=>{var v;const o=(v=t.target.files)==null?void 0:v[0];if(o){if(o.size>q){w.toast.error(s("File too large"),{description:`${s("Maximum file size is 1MB. Selected file is")} ${(o.size/1024).toFixed(2)}KB.`}),i.current&&(i.current.value="");return}try{p(!0);const n=new FileReader;n.onloadend=()=>{j(n.result),p(!1)},n.readAsDataURL(o)}catch(n){console.error("Error reading file:",n),p(!1),w.toast.error(s("Failed to process image"),{description:n instanceof Error?n.message:s("Unknown error")})}}},[s]),D=()=>{j(""),i.current&&(i.current.value="")},F=()=>{var t;(t=i.current)==null||t.click()},S=()=>{u(!0),T.mutate({page:r,name:r.name,description:f.trim()||void 0,pageType:r.pageType,...c?{previewImage:c}:{}},{onSuccess:()=>{u(!1),m()},onError:()=>{u(!1)}})};return e.jsx(a.Dialog,{open:!0,onOpenChange:m,children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Mark as template")}),e.jsxs(a.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:[s("Are you sure you want to mark this page as a template?"),e.jsx("br",{}),s("Templates can be used to create new pages with the same content.")]})]}),e.jsxs("div",{className:"mb-4 space-y-4 text-xs",children:[e.jsxs("div",{className:"space-y-3 rounded border bg-slate-50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.Tag,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Page Name"),":"]}),e.jsx("span",{className:"font-semibold",children:y.startCase(r.name)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.File,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Type"),":"]}),e.jsx("span",{className:"font-semibold",children:C})]})]}),e.jsxs("div",{children:[e.jsx(a.Label,{htmlFor:"description",className:"text-xs font-medium",children:s("Description (Optional)")}),e.jsx(a.Textarea,{id:"description",placeholder:s("Describe this template's purpose"),className:"mt-1 h-24 resize-none text-xs",value:f,onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"previewImage",className:"text-xs font-medium",children:s("Preview Image (Optional)")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Input,{type:"file",id:"previewImage",ref:i,onChange:I,accept:"image/*",className:"hidden"}),e.jsx(a.Button,{type:"button",variant:"outline",onClick:F,disabled:N,className:"w-full",children:N?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),s("Uploading...")]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(d.ImageIcon,{className:"h-4 w-4"}),s("Select image")]})}),c&&e.jsx(a.Button,{type:"button",variant:"outline",size:"icon",onClick:D,children:e.jsx(d.X,{className:"h-4 w-4"})})]}),c&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-md border",children:e.jsx("img",{src:c,alt:s("Preview"),className:"h-full max-h-[200px] w-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("max 1mb")})]})]})]}),e.jsxs(a.DialogFooter,{className:g?"pointer-events-none opacity-75":"",children:[e.jsx(a.Button,{variant:"outline",onClick:t=>{t.stopPropagation(),m()},children:s("Cancel")}),e.jsx(a.Button,{variant:"default",disabled:g,onClick:S,children:s("Mark as template")})]})]})})};exports.default=A;
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
- import { n as P, h as z } from "./index-Djepisz3.js";
2
+ import { n as P, h as z } from "./index-DHfaX2M6.js";
3
3
  import { useTranslation as E } from "@chaibuilder/sdk";
4
4
  import { Dialog as L, DialogContent as S, DialogHeader as U, DialogTitle as B, DialogDescription as R, Label as w, Textarea as j, Input as O, Button as c, DialogFooter as X } from "@chaibuilder/sdk/ui";
5
5
  import { startCase as y } from "lodash-es";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-BELYt0c9.cjs"),i=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),w=require("lodash-es"),x=require("lucide-react"),P=()=>{const{t:a}=i.useTranslation(),[l,g]=n.useSearchParams(),c=l.get("lang"),u=n.useIsLanguagePageCreated(c),{setSelectedLang:d}=i.useLanguages(),h=()=>{const r=new URLSearchParams(window.location.search);r.delete("lang");const o=r.toString(),m=`${window.location.pathname}${o?`?${o}`:""}`;window.history.pushState({},"",m),g(r),d(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(u)return null;const s=w.get(n.LANGUAGES,c);return e.jsx(n.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-2xl",children:[e.jsx(x.LockIcon,{className:"h-6 w-6 text-yellow-500"}),a("Page missing for"),' "',s,'" ',a("language"),"."]})}),e.jsx(t.CardContent,{className:"grid gap-4",children:e.jsxs("div",{children:[a("Page is not available in the"),' "',s,'" ',a("language. Either create the page in the"),' "',s,'"',a("language or switch to the base language.")]})}),e.jsx(t.CardFooter,{children:e.jsx(t.Button,{onClick:h,className:"w-full",variant:"destructive",children:a("Switch to default language")})})]})})};exports.default=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-DOlBrCPx.cjs"),i=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),w=require("lodash-es"),x=require("lucide-react"),P=()=>{const{t:a}=i.useTranslation(),[l,g]=n.useSearchParams(),c=l.get("lang"),u=n.useIsLanguagePageCreated(c),{setSelectedLang:d}=i.useLanguages(),h=()=>{const r=new URLSearchParams(window.location.search);r.delete("lang");const o=r.toString(),m=`${window.location.pathname}${o?`?${o}`:""}`;window.history.pushState({},"",m),g(r),d(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(u)return null;const s=w.get(n.LANGUAGES,c);return e.jsx(n.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-2xl",children:[e.jsx(x.LockIcon,{className:"h-6 w-6 text-yellow-500"}),a("Page missing for"),' "',s,'" ',a("language"),"."]})}),e.jsx(t.CardContent,{className:"grid gap-4",children:e.jsxs("div",{children:[a("Page is not available in the"),' "',s,'" ',a("language. Either create the page in the"),' "',s,'"',a("language or switch to the base language.")]})}),e.jsx(t.CardFooter,{children:e.jsx(t.Button,{onClick:h,className:"w-full",variant:"destructive",children:a("Switch to default language")})})]})})};exports.default=P;
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as s } from "react/jsx-runtime";
2
- import { i as h, j as u, L as w, B as p } from "./index-Djepisz3.js";
2
+ import { i as h, j as u, L as w, B as p } from "./index-DHfaX2M6.js";
3
3
  import { useTranslation as f, useLanguages as P } from "@chaibuilder/sdk";
4
4
  import { Card as C, CardHeader as S, CardTitle as L, CardContent as x, CardFooter as N, Button as v } from "@chaibuilder/sdk/ui";
5
5
  import { get as B } from "lodash-es";