@chaibuilder/pages 0.15.0 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/{2AITGKQY-CpxlNmec.cjs → 2AITGKQY-C2afI3G9.cjs} +1 -1
  2. package/dist/{2AITGKQY-gEvxLMa5.js → 2AITGKQY-CpTgZa1B.js} +2 -2
  3. package/dist/{NCMVHL6D-sV6MElOb.cjs → NCMVHL6D-BdBKMEGN.cjs} +1 -1
  4. package/dist/{NCMVHL6D-DpycZ17L.js → NCMVHL6D-fVqsZOVq.js} +2 -2
  5. package/dist/{ZDWCUMSJ-BbzwbqTE.js → ZDWCUMSJ-CTb4F48A.js} +1 -1
  6. package/dist/{ZDWCUMSJ-BPT9OZay.cjs → ZDWCUMSJ-DHGlUoWR.cjs} +1 -1
  7. package/dist/{add-new-language-page-B4_z4O8a.cjs → add-new-language-page-CY2hL7A-.cjs} +1 -1
  8. package/dist/{add-new-language-page-C8LIaHl6.js → add-new-language-page-DY0789ha.js} +2 -2
  9. package/dist/{add-new-page-JY6dRnC4.js → add-new-page-C6fGkJF9.js} +1 -1
  10. package/dist/{add-new-page-CQRr6Z8g.cjs → add-new-page-DnVeU4g6.cjs} +1 -1
  11. package/dist/{delete-page-z88W-Ikh.cjs → delete-page-DZi2DCAb.cjs} +1 -1
  12. package/dist/{delete-page-Dfa2vyQB.js → delete-page-hLDHKzbl.js} +1 -1
  13. package/dist/digital-asset-manager-Cj5r9niq.cjs +1 -0
  14. package/dist/digital-asset-manager-CpoNKOFK.js +1001 -0
  15. package/dist/{duplicate-page-Welcro7Y.cjs → duplicate-page-CTH0REkv.cjs} +1 -1
  16. package/dist/{duplicate-page-B0urG1pP.js → duplicate-page-sdO4hRfo.js} +14 -14
  17. package/dist/{dynamic-page-selector-CyhZ0SRO.js → dynamic-page-selector-EfxbLRp-.js} +1 -1
  18. package/dist/{dynamic-page-selector-Dn_j_r-h.cjs → dynamic-page-selector-Ki3lEtRJ.cjs} +1 -1
  19. package/dist/image-editor-CRJ0cNde.cjs +1 -0
  20. package/dist/image-editor-DR1FYokM.js +111 -0
  21. package/dist/{index-BSEA_u0X.js → index-CdUDr4JM.js} +1446 -1368
  22. package/dist/index-vjYir4bk.cjs +5 -0
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +10 -10
  25. package/dist/{json-diff-viewer-DVlb4YWD.js → json-diff-viewer-BQSgrzoZ.js} +1 -1
  26. package/dist/{json-diff-viewer-BIJ4iNWb.cjs → json-diff-viewer-DthVeQzc.cjs} +1 -1
  27. package/dist/{lang-panel-D0IN38gF.js → lang-panel-DJGvZmRK.js} +29 -29
  28. package/dist/{lang-panel-l6Teik-4.cjs → lang-panel-DTDqVZGv.cjs} +1 -1
  29. package/dist/{mark-as-template-DBPJ1gIK.cjs → mark-as-template-BNbkAkrD.cjs} +1 -1
  30. package/dist/{mark-as-template-B22EANHN.js → mark-as-template-C3669ENB.js} +1 -1
  31. package/dist/{no-language-page-content-DNNu8wd0.js → no-language-page-content-DMdFjwWT.js} +1 -1
  32. package/dist/{no-language-page-content-BUHXqSKG.cjs → no-language-page-content-DY-A9YbI.cjs} +1 -1
  33. package/dist/{page-creator-BPgx7zdJ.js → page-creator-B_X6PI1J.js} +2 -2
  34. package/dist/{page-creator-DbN3Nvq6.cjs → page-creator-BcoyQ5mT.cjs} +1 -1
  35. package/dist/{page-lock-request-BFkpw5VN.cjs → page-lock-request-Cl0GyiJp.cjs} +1 -1
  36. package/dist/{page-lock-request-Br9S1AsA.js → page-lock-request-DJVlDGsX.js} +10 -10
  37. package/dist/{page-locked-by-dialog-2h8cv1tO.cjs → page-locked-by-dialog-CZvpeWVu.cjs} +1 -1
  38. package/dist/{page-locked-by-dialog-DyLcMu33.js → page-locked-by-dialog-DY_jVajL.js} +1 -1
  39. package/dist/{page-manager-new-B2oBm4pU.js → page-manager-new-BKr1R3Yu.js} +37 -37
  40. package/dist/{page-manager-new-CAj6WV-C.cjs → page-manager-new-v2nHss3Q.cjs} +1 -1
  41. package/dist/{page-manager-search-and-filter-CWMXLTqE.cjs → page-manager-search-and-filter-CibEmd6Z.cjs} +1 -1
  42. package/dist/{page-manager-search-and-filter-WQYVXUAt.js → page-manager-search-and-filter-DLrJ5bRM.js} +1 -1
  43. package/dist/{page-revisions-content-AMH8AxBU.cjs → page-revisions-content-Bv1b1HsS.cjs} +1 -1
  44. package/dist/{page-revisions-content-DM-ngq3R.js → page-revisions-content-C4hAdUVX.js} +17 -17
  45. package/dist/{publish-pages-content-Dast4sG6.js → publish-pages-content-B-8X8FzF.js} +2 -2
  46. package/dist/{publish-pages-content-Dkv0Lok8.cjs → publish-pages-content-Krawy2bg.cjs} +1 -1
  47. package/dist/{save-to-lib-B5k0MVbW.js → save-to-lib-BV_uNHn3.js} +12 -12
  48. package/dist/{save-to-lib-DWtmtrUj.cjs → save-to-lib-CiX1h4Po.cjs} +1 -1
  49. package/dist/{seo-panel-D75jQH_j.js → seo-panel-BHqhAOiz.js} +34 -34
  50. package/dist/{seo-panel-dBvEEfi9.cjs → seo-panel-CpjeH5Yl.cjs} +1 -1
  51. package/dist/shared-json-ld-BfkvfAZY.js +650 -0
  52. package/dist/shared-json-ld-C-fV8erH.cjs +1 -0
  53. package/dist/{slug-input-BEegJ8bv.js → slug-input-Dz9A1ksl.js} +1 -1
  54. package/dist/{slug-input-BITq28nI.cjs → slug-input-ssMiXYTG.cjs} +1 -1
  55. package/dist/{theme-panel-footer-zLXS6SHh.js → theme-panel-footer-DZSU9bNX.js} +1 -1
  56. package/dist/{theme-panel-footer-DcASH9l1.cjs → theme-panel-footer-Rmw520a9.cjs} +1 -1
  57. package/dist/{unmark-as-template-DXFRY_pc.js → unmark-as-template-D8o31xMH.js} +1 -1
  58. package/dist/{unmark-as-template-ChmjL4-w.cjs → unmark-as-template-D_Td5Aeb.cjs} +1 -1
  59. package/dist/{unpublish-page-BxN0deJK.cjs → unpublish-page-Bca-dVic.cjs} +1 -1
  60. package/dist/{unpublish-page-DMteaCpR.js → unpublish-page-D9XisIu8.js} +1 -1
  61. package/dist/{web-preview-DM11qhOe.cjs → web-preview-BddtAY2w.cjs} +1 -1
  62. package/dist/{web-preview-BDTdFQ2h.js → web-preview-Dn1aCs5v.js} +1 -1
  63. package/package.json +1 -1
  64. package/dist/digital-asset-manager-Zh-mlMF5.cjs +0 -1
  65. package/dist/digital-asset-manager-hqMwBWhb.js +0 -976
  66. package/dist/image-editor-BWLJT1mr.cjs +0 -1
  67. package/dist/image-editor-CzFST20j.js +0 -104
  68. package/dist/index-MlpQJHWW.cjs +0 -5
  69. package/dist/shared-json-ld-BvWyXBz_.cjs +0 -1
  70. package/dist/shared-json-ld-ZtwsYt9H.js +0 -337
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),I=require("@chaibuilder/sdk/ui"),S=require("lodash-es"),p=require("lucide-react"),t=require("react"),R=require("react-filerobot-image-editor"),b=t.memo(({imageUrl:n,onSave:r,onClose:d,defaultSavedImageName:g,isEditing:c=!1})=>{const[x,u]=t.useState(!0),[h,v]=t.useState(!1);t.useEffect(()=>{const e=new Image;return e.src=n,e.onload=()=>v(!0),()=>{e.onload=null}},[n]);const m=t.useMemo(()=>S.debounce(async(e,a=!1)=>{const o=e.imageBase64;await r(o,a),u(!1)},300),[r]),s=t.useCallback((e,a=!1)=>{m(e,a)},[m]),f=t.useCallback(()=>{u(!1),d()},[d]),l=t.useMemo(()=>({tabsIds:["Adjust","Annotate","Watermark","Finetune","Resize","Filters"],toolsIds:["Rotate"],defaultTabId:"Adjust",defaultToolId:"Rotate"}),[]),y=t.useMemo(()=>({colors:{primary:"#000000",secondary:"#000000",tertiary:"#000000"}}),[]),C=t.useMemo(()=>c?[{label:"Update this file",onClick:(e,a)=>a((...o)=>{s(o[0],!1)}),icon:p.Save},{label:"Save as new file",onClick:(e,a)=>a((...o)=>{s(o[0],!0)}),icon:p.Copy}]:[],[c,s]);return i.jsx(I.Dialog,{open:!0,onOpenChange:e=>!e&&f(),children:i.jsx(I.DialogContent,{id:"chai-image-editor-container",className:"max-w-[1232px] max-h-[1232px] w-[80vw] h-[80vh] space-y-4 flex flex-col p-0",children:x&&h&&i.jsx(R,{theme:y,source:n,onSave:s,onClose:f,Text:{text:"Add text here"},Rotate:{angle:90,componentType:"slider"},tabsIds:l.tabsIds,defaultTabId:l.defaultTabId,defaultToolId:l.defaultToolId,savingPixelRatio:2,previewPixelRatio:1,defaultSavedImageName:g,moreSaveOptions:C,useZoomPresetsMenu:!0,closeAfterSave:!0})})})});b.displayName="ImageEditor";exports.default=b;
@@ -1,104 +0,0 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { Dialog as y, DialogContent as T } from "@chaibuilder/sdk/ui";
3
- import { debounce as w } from "lodash-es";
4
- import { Save as S, Copy as R } from "lucide-react";
5
- import { memo as A, useState as p, useEffect as E, useMemo as s, useCallback as I } from "react";
6
- import O from "react-filerobot-image-editor";
7
- const k = A(
8
- ({ imageUrl: n, onSave: d, onClose: i, defaultSavedImageName: g, isEditing: m = !1 }) => {
9
- const [b, c] = p(!0), [h, x] = p(!1);
10
- E(() => {
11
- const e = new Image();
12
- return e.src = n, e.onload = () => x(!0), () => {
13
- e.onload = null;
14
- };
15
- }, [n]);
16
- const f = s(
17
- () => w(async (e, t = !1) => {
18
- const o = e.imageBase64;
19
- await d(o, t), c(!1);
20
- }, 300),
21
- [d]
22
- ), a = I(
23
- (e, t = !1) => {
24
- f(e, t);
25
- },
26
- [f]
27
- ), u = I(() => {
28
- c(!1), i();
29
- }, [i]), l = s(
30
- () => ({
31
- tabsIds: [
32
- "Adjust",
33
- "Annotate",
34
- "Watermark",
35
- "Finetune",
36
- "Resize",
37
- "Filters"
38
- ],
39
- toolsIds: ["Rotate"],
40
- defaultTabId: "Adjust",
41
- defaultToolId: "Rotate"
42
- }),
43
- []
44
- ), v = s(
45
- () => ({
46
- colors: {
47
- primary: "#000000",
48
- secondary: "#000000",
49
- tertiary: "#000000"
50
- }
51
- }),
52
- []
53
- ), C = s(
54
- () => m ? [
55
- {
56
- label: "Update this file",
57
- onClick: (e, t) => t((...o) => {
58
- a(o[0], !1);
59
- }),
60
- icon: S
61
- },
62
- {
63
- label: "Save as new file",
64
- onClick: (e, t) => t((...o) => {
65
- a(o[0], !0);
66
- }),
67
- icon: R
68
- }
69
- ] : [],
70
- [m, a]
71
- );
72
- return /* @__PURE__ */ r(y, { open: !0, onOpenChange: (e) => !e && u(), children: /* @__PURE__ */ r(
73
- T,
74
- {
75
- id: "chai-image-editor-container",
76
- className: "max-w-[1232px] max-h-[1232px] w-[80vw] h-[80vh] space-y-4 flex flex-col p-0",
77
- children: b && h && /* @__PURE__ */ r(
78
- O,
79
- {
80
- theme: v,
81
- source: n,
82
- onSave: a,
83
- onClose: u,
84
- Text: { text: "Add text here" },
85
- Rotate: { angle: 90, componentType: "slider" },
86
- tabsIds: l.tabsIds,
87
- defaultTabId: l.defaultTabId,
88
- defaultToolId: l.defaultToolId,
89
- savingPixelRatio: 2,
90
- previewPixelRatio: 1,
91
- defaultSavedImageName: g,
92
- moreSaveOptions: C,
93
- useZoomPresetsMenu: !0,
94
- closeAfterSave: !0
95
- }
96
- )
97
- }
98
- ) });
99
- }
100
- );
101
- k.displayName = "ImageEditor";
102
- export {
103
- k as default
104
- };
@@ -1,5 +0,0 @@
1
- "use strict";var Hn=Object.defineProperty;var ms=e=>{throw TypeError(e)};var Qn=(e,t,s)=>t in e?Hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var ge=(e,t,s)=>Qn(e,typeof t!="symbol"?t+"":t,s),Es=(e,t,s)=>t.has(e)||ms("Cannot "+s);var x=(e,t,s)=>(Es(e,t,"read from private field"),s?s.call(e):t.get(e)),G=(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),j=(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"),K=require("jotai"),w=require("@tanstack/react-query"),I=require("@chaibuilder/sdk"),$=require("sonner"),m=require("@chaibuilder/sdk/ui"),v=require("lucide-react"),Ls=require("@chaibuilder/runtime"),zn=require("@chaibuilder/sdk/web-blocks");function $n(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 Q=$n(h),y={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",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},Wn=K.atom({}),jt=()=>K.useAtom(Wn),ee=(e,t)=>{const[s]=jt();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},B=()=>ee("apiUrl","/chai/api"),ks=()=>ee("usersApiUrl","/chai/users"),Yn=()=>ee("assetsApiUrl","/chai/assets"),Jn=()=>ee("websocket",null),Xn=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),R=()=>{const e=ee("onLogout"),t=ee("getAccessToken");return h.useCallback(async(s,n,r={})=>{const i=await t();if(!i)return console.error("No auth token found"),null;try{const a=p.get(n,"action","").toLowerCase(),l=await Xn(s+(a?`?action=${a}`:""),n,{...r,Authorization:`Bearer ${i}`});if(l.status===401)return console.log("401 Response",l),e(),window.location.reload(),null;if(!l.ok){const c=await l.json();throw console.error(`API Error (${l.status}):`,c),{status:l.status,statusText:l.statusText,...c,message:c.error||c.message||`Server error: ${l.status}`}}return await l.json()}catch(a){throw console.error("API request failed:",n,a),a}},[e,t])};function te(){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 ye=e=>{const t=B(),[s]=te(),n=e??s.get("page"),r=R();return w.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,n],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!n)return null;const i=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:n}});return p.reverse(p.sortBy(i,"primaryPage"))},enabled:!!n})},Ae=()=>{const e=B(),t=R();return w.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}=I.useLanguages(),{data:s}=Ae(),{data:n,isFetching:r}=ye(),i=h.useMemo(()=>{const a={[t]:!0};return p.each(p.get(s,"languages"),l=>{const c=p.find(n,{lang:l});a[l]=!!c}),a},[t,n,s]);return r||p.isEmpty(e)||e&&i[e]};class js{constructor(t,s,n,r){ge(this,"channelId");ge(this,"websocket");ge(this,"channel",null);ge(this,"userId",null);ge(this,"clientId",null);ge(this,"pageId",null);ge(this,"callback");var i,a,l,c,d,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=(d=(c=(l=(a=(i=this.channel)==null?void 0:i.on("presence",{event:"sync"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:a.on("presence",{event:"leave"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:l.on("presence",{event:"join"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:c.on("broadcast",{event:"TAKE_OVER_REQUESTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUESTED",u)))==null?void 0:d.on("broadcast",{event:"TAKE_OVER_REQUEST_ACCEPTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUEST_ACCEPTED",u)))==null||f.on("broadcast",{event:"TAKE_OVER_REQUEST_REJECTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUEST_REJECTED",u)).subscribe()}getClientId(){return crypto.randomUUID()}getOnlineUsers({pageId:t,userId:s}){var i;const n=(i=this.channel)==null?void 0:i.presenceState();let r=Object.values(n||{}).map(a=>a[0]).filter(Boolean);return t?r=r.filter(a=>a.pageId===t):s&&(r=r.filter(a=>a.userId===s)),r.sort((a,l)=>a.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 a;const i=(a=p.minBy(s[r],"onlineAt"))==null?void 0:a.userId;i!==this.userId&&(n[r]=i)}),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 i={pageId:this.pageId,userId:this.userId,senderClientId:this.clientId};t==="TAKE_OVER_REQUESTED"?i.targetClientId=(n=this.getPageOwner())==null?void 0:n.clientId:(t==="TAKE_OVER_REQUEST_ACCEPTED"||t==="TAKE_OVER_REQUEST_REJECTED")&&(i.targetClientId=s==null?void 0:s.requestingClientId),await((r=this.channel)==null?void 0:r.send({event:t,payload:i,type:"broadcast"}))}}}const Zn=K.atom(null),Ds=()=>K.useAtom(Zn),ss=()=>{const[e]=Ds();return(e==null?void 0:e.slug)||""};function er(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const tr=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=I.useLanguages(),{data:r}=Z(),i=r==null?void 0:r.pageType,a=B(),l=R(),{data:c,isFetching:d}=w.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,i,t],staleTime:60*60*1e3,placeholderData:[],queryFn:async()=>await l(a,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:i,uuid:t}})||[],enabled:!!i}),f=h.useMemo(()=>s===""?c.filter(u=>u.lang===""||u.lang===n):c.filter(u=>u.lang===s),[s,n,c]);return{allLangPages:c,data:f,isFetching:d}},Gs=()=>{const{selectedLang:e,fallbackLang:t}=I.useLanguages(),[s,n]=Ds(),[r,i]=h.useState(""),a=er(r,500),{allLangPages:l,data:c,isFetching:d}=tr({query:a}),f=h.useCallback(E=>n(E),[n]),u=h.useCallback(E=>i(E),[i]),g=h.useCallback(()=>{if(!s)return;const E=!(s!=null&&s.primaryPage),S=e.length===0,T=E?s==null?void 0:s.id:s==null?void 0:s.primaryPage,A=l.filter(_=>(_==null?void 0:_.primaryPage)===T||_.id===T).find(_=>S?_.lang===e||_.lang===t:_.lang===e);n(A||s)},[s,e,l,n,t]);return{isFetching:d,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:f,updateSearchQuery:u,onChangeLanguage:g}},sr=K.atom({lastSaved:void 0}),Dt=()=>K.useAtom(sr),Z=()=>{const[e]=te(),t=e.get("page"),{data:s,isFetching:n}=ye();return{data:h.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},ue=()=>{const[e]=te(),t=e.get("lang")??"",{data:s,isFetching:n}=ye();return{data:h.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},nr=K.atom({}),rr=()=>K.useAtom(nr),ir=()=>{const{data:e}=ue(),t=ss(),s=ee("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},Ve=()=>{const e=ee("currentUser"),t=ee("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},Os=e=>{const t=ks(),s=R();return w.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"})},ar=K.atom({status:"checking",requestedBy:"",isTakeOverRequested:!1,requestingClientId:"",isActiveInOtherTab:!1}),or=K.atom(""),lr=K.atom(null),ns=K.atom({}),cr=()=>K.useAtom(ns),Se=()=>{const[e]=te(),t=e.get("page"),[s,n]=K.useAtom(ar),[r,i]=K.useAtom(lr),[a,l]=K.useAtom(or),[c]=K.useAtom(ns);return{pageLock:s,pageToUser:c,lockingStatus:a,realtimeInstance:r,setPageLock:n,setLockingStatus:l,setRealtimeInstance:i,realtimePageLockEnabled:!!r,currentEditor:c[t||""],isLocked:t&&s.status==="locked"}},ur=()=>{const e=Jn(),{data:t}=Z(),{user:s}=Ve(),n=t==null?void 0:t.id,{data:r}=Ae(),{pageLock:i,setPageLock:a,setLockingStatus:l,realtimeInstance:c,setRealtimeInstance:d}=Se(),[,f]=K.useAtom(ns),u=h.useRef(!1),g=h.useRef(i),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(P,A)=>{var _,k;switch(P){case"UPDATE_ONLINE_USERS":f((A==null?void 0:A.pageToUser)||{});break;case"PAGE_LOCKED":a({...g==null?void 0:g.current,requestedBy:"",status:"locked",isActiveInOtherTab:A==null?void 0:A.isActiveInOtherTab});break;case"USER_JOINED":if(((_=g==null?void 0:g.current)==null?void 0:_.status)==="editing")return;((k=g==null?void 0:g.current)==null?void 0:k.status)==="locked"&&l("can_edit_now"),a({...g==null?void 0:g.current,requestedBy:"",status:"editing",isActiveInOtherTab:A==null?void 0:A.isActiveInOtherTab});break;case"TAKE_OVER_REQUESTED":a({...g==null?void 0:g.current,requestingClientId:A==null?void 0:A.requestingClientId,requestedBy:A!=null&&A.isRequestedFromAnotherTab?"ANOTHER_TAB":A==null?void 0:A.requestedBy});break;case"TAKE_OVER_REQUEST_ACCEPTED":A!=null&&A.isTakingOverFromAnotherTab||(l("take_over_request_accepted"),$.toast.success("Your Page Take Over Request Accepted",{position:"top-center"})),a({...g==null?void 0:g.current,status:"editing",requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break;case"TAKE_OVER_REQUEST_REJECTED":l("take_over_request_rejected"),a({...g==null?void 0:g.current,requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break}},T=new js(e,r==null?void 0:r.appKey,s==null?void 0:s.id,S);d(T)}},[d,e,r==null?void 0:r.appKey]),h.useEffect(()=>{g.current=i},[i]),h.useEffect(()=>{if(!(!c||!n||!(s!=null&&s.id)||u.current))return u.current=!0,c==null||c.joinPage(n),()=>{c&&u.current&&(u.current=!1,g.current={requestedBy:"",status:"checking",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1},l(""),a(g.current),c==null||c.leavePage())}},[n,c]),i==null?void 0:i.status},Rs=()=>{const{data:e}=Z(),{user:t}=Ve(),s=e==null?void 0:e.id,{pageLock:n,setPageLock:r,realtimeInstance:i}=Se(),{savePageAsync:a}=I.useSavePage(),l=h.useCallback(()=>{!i||!s||!(t!=null&&t.id)||(r({...n,isTakeOverRequested:!0}),i==null||i.sendEvent("TAKE_OVER_REQUESTED"))},[i,s,t==null?void 0:t.id,r,n]),c=h.useCallback(async()=>{!i||!s||!(t!=null&&t.id)||(await a(),i==null||i.sendEvent("TAKE_OVER_REQUEST_ACCEPTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({requestedBy:"",status:"locked",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,i,t==null?void 0:t.id,r,a,n]),d=h.useCallback(()=>{!i||!s||!(t!=null&&t.id)||(i==null||i.sendEvent("TAKE_OVER_REQUEST_REJECTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({...n,requestedBy:"",status:"editing",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,i,t==null?void 0:t.id,r,n]);return{pageLock:n,acceptTakeOver:c,rejectTakeOver:d,requestTakeOver:l}},dr=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-BUHXqSKG.cjs"))),fr=h.lazy(()=>Promise.resolve().then(()=>require("./page-locked-by-dialog-2h8cv1tO.cjs"))),qt=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-request-BFkpw5VN.cjs"))),hr=({isFetchingPage:e})=>{const{pageLock:t,requestTakeOver:s}=Rs(),{currentEditor:n,lockingStatus:r,setLockingStatus:i,realtimePageLockEnabled:a}=Se(),{data:l,isFetching:c}=Os(n),[d]=te(),f=d.get("page"),[u]=Dt(),g=w.useQueryClient(),E=h.useCallback(()=>{s()},[s]);return!f||e||!a||(t==null?void 0:t.status)==="checking"?null:t!=null&&t.requestedBy?o.jsx(h.Suspense,{children:o.jsx(qt,{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(qt,{lockingStatus:r,onContinue:()=>{g.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),i("")}})}):null:t!=null&&t.isActiveInOtherTab?o.jsx(h.Suspense,{children:o.jsx(qt,{lockingStatus:"page_is_active_in_other_tab",onContinue:s})}):o.jsx(h.Suspense,{children:o.jsx(fr,{...l,isFetchingUserInfo:c,name:(l==null?void 0:l.name)||"Unknown User",email:(l==null?void 0:l.email)||"",lastSaved:(u==null?void 0:u.lastSaved)||"",onTakeOver:E,realtimePageLockEnabled:a,isRequestRejected:r==="take_over_request_rejected"})})},gr=()=>{const[e]=te(),t=e.get("lang");return ts(t)?null:o.jsx(h.Suspense,{children:o.jsx(dr,{})})},$e={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 Gt=K.atom(null),Ot=()=>{const{data:e}=Ae();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},is=()=>{const e=R(),t=B();return w.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},mr=e=>{const t=R(),s=B(),n=Ot();return w.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,i=>({...i,lang:e})),"primaryPage")},placeholderData:r=>r||{}})},Er=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-CAj6WV-C.cjs"))),Us=({children:e})=>{const[t,s]=te(),n=t.get("page"),{data:r,isFetching:i}=Z(),{data:a,isFetching:l}=is(),[c,d]=h.useState(!1),[f,u]=h.useState(!0),{savePage:g}=I.useSavePage(),E=!!n&&!p.isEmpty(r),S=h.useMemo(()=>{if(!a||l)return!1;const _=a.find(k=>k.slug==="/");return _==null?void 0:_.id},[a,l]);h.useEffect(()=>{if(l||!S||a.some(q=>q.id===n))return;const k=new URLSearchParams({page:S});rs(k,s),!l&&a&&u(!1)},[n,l,a,S,s]);const T=!f&&!n,P=!f&&!i&&p.isEmpty(r),A=c||T||P;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:()=>{g(),d(!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:"Open pages manager"})})]})})}),o.jsx(m.Sheet,{open:A,onOpenChange:_=>!_&&E&&d(!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 ${E?"":"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:"Pages"}),o.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:"Manage your site structure"})]})]}),o.jsx(m.SheetDescription,{className:"sr-only",children:"Manage your site structure"})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:A&&o.jsx(h.Suspense,{children:o.jsx(Er,{close:()=>d(!1)})})})]})})]})},pr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-B4_z4O8a.cjs"))),yr=()=>{const e=ee("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},Ms=({showAdd:e=!0,variant:t="ghost"})=>{const{fallbackLang:s,languages:n,selectedLang:r,setSelectedLang:i}=I.useLanguages(),a=p.isEmpty(r)?s:r,[,l]=te(),{isLocked:c}=Se();h.useEffect(()=>{const P=new URLSearchParams(window.location.search),A=P.get("lang");A&&(n.includes(A)?i(A):(P.delete("lang"),l(P),i("")))},[n,l,i]);const[,d]=K.useAtom(Gt),{data:f}=Z(),{data:u}=Ae(),{data:g}=ye(),E=h.useMemo(()=>{const P=p.compact(p.map(p.get(u,"languages"),A=>{const _=p.find(g,{lang:A});return{key:A,value:p.get($e,A,A),isLangPageAdded:!!_}})).filter(Boolean);return[{key:s,value:p.get($e,s),isLangPageAdded:!0},...P]},[s,g,u]),S=P=>{if(document.querySelector('[data-panel-id="seo"]')){const _=new CustomEvent("seo-language-switch-check",{detail:{fromLang:a,toLang:P,switchHandler:()=>T(P)}});window.dispatchEvent(_);return}T(P)},T=P=>{i(P);const A=new URLSearchParams(window.location.search);P===s?A.delete("lang"):A.set("lang",P),rs(A,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($e,a,a),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($e,a,a),o.jsx(v.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(m.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(E.filter(P=>P.isLangPageAdded),P=>o.jsxs(m.DropdownMenuItem,{className:I.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",P.key===a&&"!bg-gray-200 text-gray-700"),onClick:()=>S(P.key),children:[o.jsx("div",{className:"text-slate-600",children:P.value}),P.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"]})]},P.value)),e&&!p.isEmpty(E.filter(P=>!P.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(m.Separator,{}),o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:()=>{f&&d({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 Ar(){const[e,t]=K.useAtom(Gt);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(yr,{}),o.jsx(Us,{}),e&&o.jsx(h.Suspense,{children:o.jsx(pr,{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 Sr(){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 Tr=Q.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-AMH8AxBU.cjs")));function Pr(){const[e,t]=Q.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(Sr,{}),children:o.jsx(Tr,{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}=I.usePermissions();return e&&!r(e)||t&&!t.some(i=>r(i))?n:s},Y={TOGGLE_PREVIEW:"Toggle Preview",OPEN_PREVIEW_IN_NEW_TAB:"Open preview in new tab",THEME:"Theme",SAVEDRAFT:"Save draft",SAVING:"Saving",SAVED:"Saved",PUBLISHED:"Published",PUBLISH:"Publish",UNPUBLISH:"Unpublish",WEBSITEDATA:"Website data",OPEN:"Open",EDIT_LANGUAGE:"Edit language",ADD_NEW_LANGUAGE:"Add new language page",ENTER_LANGUAGE_DETAILS:"Enter the details for the language",LANGUAGE:"Language",PAGE_NAME:"Page Name",SLUG:"Slug",UPDATE:"Update",UPDATING:"Updating...",ADDING:"Adding...",CHOOSE_LANGUAGE:"Choose language",ALL_AVAILABLE_LANGUAGE_PAGE:"All available language page is created.",TO_UPDATE_SLUG:"To update slug use 'Change slug' action",SLUG_SHOULD_START_WITH:" (Slug should start with /{lang})",CHOOSE_LANGUAGE_TO_ADD_SLUG:"Choose language to add slug",ENTER_PAGE_SLUG:"Enter page slug",ENTER_PAGE_NAME:"Enter page name",DELETE:"Delete",CHANGE_SLUG:"Change slug",PRIMARY:"Primary",SLUG_MUST_START_WITH:"Slug must start with /",EDIT:"Edit",UNPUBLISH_MSG:"Are you sure you want to unpublish",MARK_AS_TEMPLATE:"Mark as template",UNMARK_AS_TEMPLATE:"Unmark as template",PAGE_ADD_SUCCESS:"New page added successfully.",GLOBAL_BLOCK_ADD_SUCCESS:"New global block added successfully.",SEO_SETTINGS_UPDATE_SUCCESS:"SEO Settings updated successfully.",PAGE_UPDATE_SUCCESS:"Page updated successfully.",GLOBAL_BLOCK_UPDATE_SUCCESS:"Global block updated successfully.",PAGE_DELETE_SUCCESS:"Page deleted successfully.",GLOBAL_BLOCK_DELETE_SUCCESS:"Global block deleted successfully.",PAGE_UNPUBLISH_SUCCESS:"Page unpublished successfully.",GLOBAL_BLOCK_UNPUBLISH_SUCCESS:"Global block unpublished successfully.",PAGE_PUBLISH_SUCCESS:"Page published successfully.",GLOBAL_BLOCK_PUBLISH_SUCCESS:"Global block published successfully.",PAGES_PUBLISH_SUCCESS:"Your changes have been published successfully.",SLUG_CHANGE_SUCCESS:"Slug changed successfully."},_r={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},de=()=>{const e=B(),t=R();return w.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Bs=e=>{const{data:t}=de();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},xr=()=>{const e=B(),t=R();return w.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),[]}}})},wr=()=>{const e=B(),t=w.useQueryClient(),s=R(),{data:n}=de();return w.useMutation({mutationFn:async r=>await s(e,{action:y.CREATE_PAGE,data:r}),onSuccess:(r,i)=>{var l;i&&(i!=null&&i.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES,i==null?void 0:i.lang]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const a=i.template?`Page created from "${i.template.name}" template`:i.hasSlug===!1?"New "+((l=p.find(n,{key:i.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";$.toast.success(a)},onError:(r,i)=>{const a=p.find(n,{key:i.pageType});$.toast.error(`Failed to add new ${a!=null&&a.hasSlug?"page":a.name}.`,{description:p.get(_r,r.message,r.message)})}})},vr=()=>{const e=B(),t=w.useQueryClient(),s=R(),{data:n}=ue(),{data:r}=de();return w.useMutation({mutationFn:async i=>await s(e,{action:y.UPDATE_PAGE,data:i}),onSuccess:(i,a)=>{(n==null?void 0:n.id)===(a==null?void 0:a.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),a&&(a!=null&&a.primaryPage||a!=null&&a.seo)?(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:(i,a)=>{const l=p.find(r,{key:a.pageType});$.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:i.message})}})},br=()=>{const e=B(),t=w.useQueryClient(),s=R(),{data:n}=de();return w.useMutation({mutationFn:async r=>s(e,{action:y.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,i)=>{if(r.code==="PAGE_LOCKED"){$.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}i&&(i!=null&&i.primaryPage)?(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:(r,i)=>{const a=p.find(n,{key:i.pageType});$.toast.error(`Failed to delete ${a!=null&&a.hasSlug?"page":a.name}.`,{description:r.message})}})},Cr=()=>{const e=B(),t=w.useQueryClient(),s=R(),{data:n}=de();return w.useMutation({mutationFn:async r=>s(e,{action:y.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,i)=>{i&&(i!=null&&i.primaryPage)?t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const a=p.find(n,{key:i.pageType});$.toast.success(a!=null&&a.hasSlug?Y.PAGE_UNPUBLISH_SUCCESS:"New "+a.name+" added successfully.")},onError:(r,i)=>{const a=p.find(n,{key:i.pageType});$.toast.error(`Failed to take offline ${a!=null&&a.hasSlug?"page":a.name}.`,{description:r.message})}})},as=()=>{const e=B(),t=R(),s=w.useQueryClient(),{data:n}=Z(),{savePageAsync:r}=I.useSavePage();return w.useMutation({mutationFn:async({ids:i})=>(await r(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:i}})),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:i=>{console.log("##",i),$.toast.error("Failed to publish pages.")}})},Ir=()=>{const e=B(),t=R(),s=w.useQueryClient();return w.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]}),$.toast.success("Page marked as template successfully.")},onError:()=>{$.toast.error("Failed to mark page as template.")}})},Nr=()=>{const e=B(),t=R(),s=w.useQueryClient();return w.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]}),$.toast.success("Page unmarked as template successfully.")},onError:()=>{$.toast.error("Failed to unmark page as template.")}})},Lr=()=>{const e=B(),t=R(),s=w.useQueryClient();return w.useMutation({mutationFn:async({id:n,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:n,slug:r}}),onSuccess:(n,{primaryPage:r})=>{$.toast.success(Y.SLUG_CHANGE_SUCCESS),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{$.toast.error("Failed to change slug")}})},kr=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-Dkv0Lok8.cjs")));function jr({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=as();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(kr,{onClose:t,isPending:n,publishPage:s})})})}const se={...I.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"},Dr={particleCount:350,spread:120,origin:{y:.6},angle:90},Gr={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Or=async()=>{const{default:e}=await Promise.resolve().then(()=>require("./confetti.module-BuUnQuWk.cjs"));return e},Pt=e=>{let t=Gr[e];t||(t={});const s={...Dr,...t};Or().then(n=>n(s))};function Rt({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 Rr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BxN0deJK.cjs"))),Ur=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-Kctu12rQ.cjs"))),Mr=()=>{const{selectedLang:e,fallbackLang:t}=I.useLanguages(),s=ee("getPreviewUrl",async u=>u),[n,r]=h.useState(""),{data:i}=Z(),{data:a}=ye(),{data:l}=de(),c=h.useMemo(()=>{var u;return(u=a==null?void 0:a.find(g=>(g==null?void 0:g.lang)===e))==null?void 0:u.slug},[e,a]),d=h.useCallback(u=>{var g;return(g=p.find(l,{key:u}))==null?void 0:g.hasSlug},[l]),f=e===t?"":e;return h.useEffect(()=>{(async()=>{if(typeof s=="function"){const u=!d(i==null?void 0:i.pageType),g=await s(u?`${f!==""?f+"/":""}${i==null?void 0:i.id}`:c||"");r(g)}else r("")})()},[s,c,i==null?void 0:i.pageType,d,i==null?void 0:i.id,f]),o.jsx(o.Fragment,{children:o.jsx(Rt,{content:Y.OPEN_PREVIEW_IN_NEW_TAB,delayDuration:0,children:o.jsx("a",{href:n,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"})})})})})},Br=()=>{const[e,t]=I.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Rt,{content:Y.THEME,delayDuration:0,children:o.jsx(m.Button,{variant:e==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>t(e==="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"})]})},qr=()=>{const[e,t]=h.useState(!1),{isLocked:s}=Se(),{savePageAsync:n,saveState:r}=I.useSavePage();h.useEffect(()=>{const d=f=>{r==="UNSAVED"&&(f.preventDefault(),f.returnValue=!1)};return r==="UNSAVED"&&window.addEventListener("beforeunload",d),()=>{window.removeEventListener("beforeunload",d)}},[r]);const i=h.useCallback(async()=>{e||(t(!0),await n(),t(!1))},[n,e]),{buttonIcon:a,buttonClass:l,tooltipContent:c}=h.useMemo(()=>{switch(r){case"UNSAVED":return{tooltipContent:Y.SAVEDRAFT,buttonIcon:o.jsx(v.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:Y.SAVING,buttonIcon:o.jsx(v.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:Y.SAVED,buttonIcon:o.jsx(v.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[r]);return s?null:o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:i,className:`${l} w-24 max-w-24`,children:[a," ",c]})},Fr=()=>{const{selectedLang:e}=I.useLanguages(),{data:t}=ue(),{data:s}=ye(),[n,r]=h.useState(!1),[i,a]=h.useState(!1),[l,c]=h.useState(null),{savePageAsync:d}=I.useSavePage(),[f,u]=h.useState(!1),{data:g}=Z(),{mutate:E,isPending:S}=as(),{needTranslations:T}=I.useSavePage(),P=T(),{buttonText:A,buttonClassName:_,isPublished:k}=h.useMemo(()=>{const O=g&&(g==null?void 0:g.online);return{buttonClassName:O?"hover:bg-green-600 bg-green-500":"",isPublished:O,buttonText:O?Y.PUBLISHED:Y.PUBLISH}},[g]),q=async()=>{if(P){u(!0);return}V()},V=()=>{const O=[t==null?void 0:t.id,t==null?void 0:t.primaryPage];E({ids:p.compact(O)},{onSuccess:()=>Pt("TOP_RIGHT")})},D=()=>{u(!1),V()},oe=async()=>{u(!1),await d()},le=h.useMemo(()=>p.map(s??[],"id"),[s]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(m.Button,{size:"sm",onClick:q,disabled:S||!(g!=null&&g.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${_}`,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[o.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${i?"-translate-y-10":""}`,children:k?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:k?o.jsx(v.Rocket,{className:"h-4 w-4"}):o.jsx(v.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:A}),e?`(${p.upperCase(e)})`:""]}),o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",disabled:S||!(g!=null&&g.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${_}`,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:S,className:"cursor-pointer text-xs",onClick:()=>E({ids:le},{onSuccess:()=>Pt("TOP_RIGHT")}),children:[Y.PUBLISH," with translation pages"]}),!k&&o.jsxs(m.DropdownMenuItem,{disabled:S,className:"cursor-pointer text-xs",onClick:()=>E({ids:[g==null?void 0:g.id]},{onSuccess:()=>Pt("TOP_RIGHT")}),children:[Y.PUBLISH," page"]}),o.jsxs(m.DropdownMenuItem,{onClick:()=>r(!0),className:"cursor-pointer text-xs",children:[Y.OPEN," publish menu"]}),k&&o.jsxs(m.DropdownMenuItem,{onClick:()=>c(t),className:"cursor-pointer text-xs",children:[Y.UNPUBLISH," page ",e?`(${p.upperCase(e)})`:""]})]})]})]}),o.jsx(jr,{showModal:n,onClose:()=>r(!1)}),l&&o.jsx(h.Suspense,{children:o.jsx(Rr,{page:l,onClose:()=>c(null)})}),f&&o.jsx(h.Suspense,{children:o.jsx(Ur,{isOpen:f,onClose:oe,onContinue:D,isPending:S})})]})};function Kr(){const{isLocked:e}=Se(),[t]=te(),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(Pr,{}),o.jsx(Tt,{permission:se.EDIT_THEME,children:o.jsx(Br,{})}),o.jsx(Mr,{}),o.jsx(Tt,{permission:se.SAVE_PAGE,children:o.jsx(qr,{})}),o.jsx(Tt,{permission:se.PUBLISH_PAGE,children:o.jsx(Fr,{})})]})}const qs=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:i,setUnmarkAsTemplate:a,children:l,isLanguagePage:c})=>{const{hasPermission:d}=I.usePermissions(),{data:f}=de(),u=h.useMemo(()=>p.find(f,{key:e.pageType}),[f,e.pageType]),g=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),E=h.useMemo(()=>!!(u!=null&&u.hasSlug),[u==null?void 0:u.hasSlug]);return!d(se.EDIT_PAGE)&&!d(se.DELETE_PAGE)&&!d(se.UNPUBLISH_PAGE)||!e?null:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,onClick:T=>T.stopPropagation(),children:l}),o.jsxs(m.DropdownMenuContent,{align:"center",className:"text-sm",children:[d(se.ADD_PAGE)&&!c&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:T=>{T.stopPropagation(),t(e)},children:[o.jsx(v.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),d(se.EDIT_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:T=>{T.stopPropagation(),s({...e,global:!(u!=null&&u.hasSlug)})},children:[o.jsx(v.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&d(se.UNPUBLISH_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:T=>{T.stopPropagation(),n(e)},children:[o.jsx(v.Power,{className:"size-3"}),Y.UNPUBLISH]}),d(se.DELETE_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:T=>{T.stopPropagation(),r(e)},children:[o.jsx(v.Trash,{className:"size-3"}),Y.DELETE]}),d(se.MARK_AS_TEMPLATE)&&E&&!c&&o.jsx(o.Fragment,{children:g?o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:T=>{T.stopPropagation(),a(e)},children:[o.jsx(v.SquareLibrary,{className:"size-3"}),Y.UNMARK_AS_TEMPLATE]}):o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:T=>{T.stopPropagation(),i(e)},children:[o.jsx(v.SquareLibrary,{className:"size-3"}),Y.MARK_AS_TEMPLATE]})})]})]})},Vr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-CQRr6Z8g.cjs"))),Hr=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-z88W-Ikh.cjs"))),Qr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-Welcro7Y.cjs"))),zr=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DBPJ1gIK.cjs"))),$r=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-ChmjL4-w.cjs"))),Wr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BxN0deJK.cjs"))),Yr=()=>{const[e,t]=h.useState(null),[s,n]=h.useState(null),[r,i]=h.useState(null),[a,l]=h.useState(null),[c,d]=h.useState(null),[f,u]=h.useState(null),{data:g,isFetching:E}=ue(),{selectedLang:S,fallbackLang:T}=I.useLanguages(),{data:P}=ye(),A=P==null?void 0:P.find(D=>D.lang===S),{isLocked:_}=Se(),k=!(g!=null&&g.slug),[,q]=K.useAtom(Gt);if(!g)return null;const V=D=>{S.length>0&&S!==T?q({edit:!0,id:D==null?void 0:D.id,primaryPage:D==null?void 0:D.primaryPage}):u(D)};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(Us,{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:[k?o.jsx(v.Globe,{className:"mr-1 h-4 w-4"}):o.jsx(v.File,{className:"mr-1 h-4 w-4"}),p.get(A||g,"name")??""]})})}),_?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(qs,{page:g,setDuplicatePage:D=>d(D),setAddEditPage:D=>V(D),setUnpublishPage:D=>n(D),setDeletePage:D=>t(D),setMarkAsTemplate:D=>i(D),setUnmarkAsTemplate:D=>l(D),isLanguagePage:S.length>0&&S!==T,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(Vr,{closePanel:()=>u(null),editPage:()=>{},addEditPage:f,setAddEditPage:u})}),e&&o.jsx(h.Suspense,{children:o.jsx(Hr,{page:e,onClose:()=>t(null)})}),s&&o.jsx(h.Suspense,{children:o.jsx(Wr,{page:s,onClose:()=>n(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx(zr,{page:r,onClose:()=>i(null)})}),a&&o.jsx(h.Suspense,{children:o.jsx($r,{page:a,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(Qr,{page:c,onClose:()=>d(null),closePanel:()=>u(null)})})]})},os=({children:e,className:t=""})=>o.jsx("div",{className:I.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}),Jr=({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"})]})}),Xr=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-Dn_j_r-h.cjs"))),Zr=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=Gs(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(Jr,{hasDynamicPage:n}),o.jsx(h.Suspense,{children:o.jsx(Xr,{})})]})},ei=()=>{const{data:e,isFetching:t}=ue(),{data:s,isFetching:n}=Z(),r=p.get(s,"dynamic",!1),i=ss(),a=I.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,d=ir(),f=t||n,g=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${i}`).replace(window.location.host,"");return o.jsxs("div",{className:"relative flex items-center gap-x-1",children:[o.jsx("div",{className:I.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(Yr,{})}),o.jsxs("div",{className:I.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(Ms,{}),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:d,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&&a&&o.jsx(Zr,{})]})},ti=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(Ar,{}),o.jsx(ei,{}),o.jsx(Kr,{})]}),Fs=()=>{const e=w.useQueryClient(),{data:t}=w.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},si=()=>{const e=B(),{aiContext:t}=Fs(),s=R();return h.useCallback(async(n,r,i,a)=>s(e,{action:y.ASK_AI,data:{type:n,prompt:r,blocks:i,context:t,lang:a}}),[e,t,s])},ni=(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,i)=>p.endsWith(i,"_attrs")),...s}}return s}),ri=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:ni(t,s)}},[e,t])},ii=()=>{const[e]=te(),t=e.get("page"),s=B(),{setAiContext:n}=Fs(),[,r]=Dt(),[,i]=rr(),[,a]=I.useIsPageLoaded(),l=R();return w.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{a(!1);const c=await l(s,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),d=c.blocks??[],f=p.find(d,{_type:"@chai/ai-context"});return n(p.get(f,"_value","")||""),r(u=>({...u,lastSaved:c.lastSaved})),i(p.get(c,"metadata",{})),setTimeout(()=>a(!0),500),d},enabled:!!t})},Ks=()=>{const{data:e}=Z(),{data:t}=ue(),s=B(),n=R(),r=Ot(),i=ss();return w.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,i],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)+i,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})},Vs=()=>{const e=B(),t=w.useQueryClient(),s=R();return w.useMutation({mutationFn:async n=>s(e,{action:y.UPDATE_WEBSITE_SETTINGS,data:n}),onSuccess:(n,r)=>{var i;t.invalidateQueries({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS]}),(i=r==null?void 0:r.settings)!=null&&i.theme||$.toast.success("Website settings updated successfully.")},onError:n=>{$.toast.error("Failed to update website settings",{description:n.message})}})},ai=()=>{const e=B(),t=w.useQueryClient(),s=R();return w.useMutation({mutationFn:async n=>s(e,{action:y.UPDATE_APP_SHARED_JSONLD,data:JSON.stringify(n)}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_APP_SHARED_JSONLD]}),$.toast.success("Shared JSON-LD updated successfully.")},onError:n=>{$.toast.error("Failed to update shared JSON-LD",{description:n.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",""),i=p.get(n,"blocks",[]);return p.isArray(i)?i:I.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),[]}}},oi=()=>{const e=B(),t=R();return w.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{I.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:i=>ps.getUILibraryBlocks(i,t,e),getBlock:({block:i})=>ps.getUILibraryBlock(i,t,e)})}),n}})},Hs=()=>{const e=ks(),t=R(),{user:s}=Ve(),n=s==null?void 0:s.id;return w.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})},li=()=>{const e=B(),t=R(),[,s]=Dt();return{onSave:async({page:r,blocks:i,needTranslations:a})=>{try{const l=await t(e,{action:"UPDATE_PAGE",data:{id:r,blocks:i,needTranslations:a}});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")}}}},ci=()=>{const{data:e}=is(),t=B(),s=R();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,i=>p.has(i,"_id"))}catch(r){return console.error(r),[]}},[s,t])}},ui=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-l6Teik-4.cjs"))),di=({isActive:e,show:t})=>{const{data:s}=Ae();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"})})},Qs="lang",fi={id:Qs,label:"Languages",position:"top",panel:ui,button:di,view:"modal",width:400},hi=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-dBvEEfi9.cjs"))),zs="seo",gi=({isActive:e,show:t})=>{const{data:s}=Z(),n=Bs(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"})]})})},mi={id:zs,label:"SEO",panel:hi,button:gi,position:"top",width:600,view:"modal"},$s="user-info",Ei=()=>{const{user:e,logout:t}=Ve(),s=ee("onLogout",p.noop);return e?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:e.name??e.email}),o.jsx("div",{className:"text-xs text-muted-foreground",children:e.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:"Logout"})}),o.jsxs(m.AlertDialogContent,{children:[o.jsxs(m.AlertDialogHeader,{children:[o.jsx(m.AlertDialogTitle,{children:"Are you sure you want to logout?"}),o.jsx(m.AlertDialogDescription,{children:"You will be redirected to the login page."})]}),o.jsxs(m.AlertDialogFooter,{children:[o.jsx(m.AlertDialogCancel,{children:"Cancel"}),o.jsx(m.AlertDialogAction,{onClick:()=>{t(),p.isFunction(s)&&s()},children:"Logout"})]})]})]})]})]}):null},pi={id:$s,label:"User Info",button:Ei,position:"bottom"},yi=()=>{I.registerChaiSidebarPanel(zs,mi),I.registerChaiSidebarPanel(Qs,fi),I.registerChaiSidebarPanel($s,pi)};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 We(e){b.context=e}var Ws=!1,Ai=(e,t)=>e===t,wt=Symbol("solid-proxy"),Ys=typeof Proxy=="function",ls=Symbol("solid-track"),vt={equals:Ai},Js=an,fe=1,bt=2,Xs={owned:null,cleanups:null,context:null,owner:null},Ft={},L=null,Kt=null,Si=null,U=null,X=null,ce=null,Ut=0;function me(e,t){const s=U,n=L,r=e.length===0,i=t===void 0?n:t,a=r?Xs:{owned:null,cleanups:null,context:i?i.context:null,owner:i},l=r?e:()=>e(()=>J(()=>et(a)));L=a,U=null;try{return ae(l,!0)}finally{U=s,L=n}}function F(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);He(n)}function Ee(e,t,s){const n=Mt(e,t,!1,fe);He(n)}function cs(e,t,s){Js=ji;const n=Mt(e,t,!1,fe);(!s||!s.render)&&(n.user=!0),ce?ce.push(n):He(n)}function z(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,He(n),nn.bind(n)}function Ti(e){return e&&typeof e=="object"&&"then"in e}function Pi(e,t,s){let n,r,i;n=!0,r=e,i={};let a=null,l=Ft,c=null,d=!1,f="initialValue"in i,u=typeof n=="function"&&z(n);const g=new Set,[E,S]=(i.storage||F)(i.initialValue),[T,P]=F(void 0),[A,_]=F(void 0,{equals:!1}),[k,q]=F(f?"ready":"unresolved");b.context&&(c=b.getNextContextId(),i.ssrLoadFrom==="initial"?l=i.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function V(C,N,W,H){return a===C&&(a=null,H!==void 0&&(f=!0),(C===l||N===l)&&i.onHydrated&&queueMicrotask(()=>i.onHydrated(H,{value:N})),l=Ft,D(N,W)),N}function D(C,N){ae(()=>{N===void 0&&S(()=>C),q(N!==void 0?"errored":f?"ready":"unresolved"),P(N);for(const W of g.keys())W.decrement();g.clear()},!1)}function oe(){const C=Ni,N=E(),W=T();if(W!==void 0&&!a)throw W;return U&&U.user,N}function le(C=!0){if(C!==!1&&d)return;d=!1;const N=u?u():n;if(N==null||N===!1){V(a,J(E));return}let W;const H=l!==Ft?l:J(()=>{try{return r(N,{value:E(),refetching:C})}catch(ne){W=ne}});if(W!==void 0){V(a,void 0,_t(W),N);return}else if(!Ti(H))return V(a,H,void 0,N),H;return a=H,"v"in H?(H.s===1?V(a,H.v,void 0,N):V(a,void 0,_t(H.v),N),H):(d=!0,queueMicrotask(()=>d=!1),ae(()=>{q(f?"refreshing":"pending"),_()},!1),H.then(ne=>V(H,ne,void 0,N),ne=>V(H,void 0,_t(ne),N)))}Object.defineProperties(oe,{state:{get:()=>k()},error:{get:()=>T()},loading:{get(){const C=k();return C==="pending"||C==="refreshing"}},latest:{get(){if(!f)return oe();const C=T();if(C&&!a)throw C;return E()}}});let O=L;return u?Zs(()=>(O=L,le(!1))):le(!1),[oe,{refetch:C=>tn(O,()=>le(C)),mutate:S}]}function _i(e){return ae(e,!1)}function J(e){if(U===null)return e();const t=U;U=null;try{return e()}finally{U=t}}function xi(e,t,s){const n=Array.isArray(e);let r,i=s&&s.defer;return a=>{let l;if(n){l=Array(e.length);for(let d=0;d<e.length;d++)l[d]=e[d]()}else l=e();if(i)return i=!1,a;const c=J(()=>t(l,r,a));return r=l,c}}function en(e){cs(()=>J(e))}function Fe(e){return L===null||(L.cleanups===null?L.cleanups=[e]:L.cleanups.push(e)),e}function As(){return L}function tn(e,t){const s=L,n=U;L=e,U=null;try{return ae(t,!0)}catch(r){us(r)}finally{L=s,U=n}}function wi(e){const t=U,s=L;return Promise.resolve().then(()=>{U=t,L=s;let n;return ae(e,!1),U=L=null,n?n.done:void 0})}var[vi,Do]=F(!1);function bi(){return[vi,wi]}function Ci(e,t){const s=Symbol("context");return{id:s,Provider:Di(s),defaultValue:e}}function Ii(e){let t;return L&&L.context&&(t=L.context[e.id])!==void 0?t:e.defaultValue}function sn(e){const t=z(e),s=z(()=>Qt(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var Ni;function nn(){if(this.sources&&this.state)if(this.state===fe)He(this);else{const e=X;X=null,ae(()=>It(this),!1),X=e}if(U){const e=this.observers?this.observers.length:0;U.sources?(U.sources.push(this),U.sourceSlots.push(e)):(U.sources=[this],U.sourceSlots=[e]),this.observers?(this.observers.push(U),this.observerSlots.push(U.sources.length-1)):(this.observers=[U],this.observerSlots=[U.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 i=e.observers[r],a=Kt&&Kt.running;a&&Kt.disposed.has(i),(a?!i.tState:!i.state)&&(i.pure?X.push(i):ce.push(i),i.observers&&on(i)),a||(i.state=fe)}if(X.length>1e6)throw X=[],new Error},!1)),t}function He(e){if(!e.fn)return;et(e);const t=Ut;Li(e,e.value,t)}function Li(e,t,s){let n;const r=L,i=U;U=L=e;try{n=e.fn(t)}catch(a){return e.pure&&(e.state=fe,e.owned&&e.owned.forEach(et),e.owned=null),e.updatedAt=s+1,us(a)}finally{U=i,L=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 i={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:L,context:L?L.context:null,pure:s};return L===null||L!==Xs&&(L.owned?L.owned.push(i):L.owned=[i]),i}function Ct(e){if(e.state===0)return;if(e.state===bt)return It(e);if(e.suspense&&J(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Ut);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===fe)He(e);else if(e.state===bt){const n=X;X=null,ae(()=>It(e,t[0]),!1),X=n}}function ae(e,t){if(X)return e();let s=!1;t||(X=[]),ce?s=!0:ce=[],Ut++;try{const n=e();return ki(s),n}catch(n){s||(ce=null),X=null,us(n)}}function ki(e){if(X&&(an(X),X=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++)Ct(e[t])}function ji(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:Ct(n)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,s));return}We()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],s+=b.effects.length,delete b.effects),t=0;t<s;t++)Ct(e[t])}function It(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<Ut)&&Ct(n):r===bt&&It(n,t)}}}function on(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=bt,s.pure?X.push(s):ce.push(s),s.observers&&on(s))}}function et(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 i=r.pop(),a=s.observerSlots.pop();n<r.length&&(i.sourceSlots[a]=n,r[n]=i,s.observerSlots[n]=a)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)et(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)et(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 _t(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function us(e,t=L){throw _t(e)}function Qt(e){if(typeof e=="function"&&!e.length)return Qt(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Qt(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Di(e,t){return function(n){let r;return Ee(()=>r=J(()=>(L.context={...L.context,[e]:n.value},sn(()=>n.children))),void 0),r}}var zt=Symbol("fallback");function Nt(e){for(let t=0;t<e.length;t++)e[t]()}function Gi(e,t,s={}){let n=[],r=[],i=[],a=0,l=t.length>1?[]:null;return Fe(()=>Nt(i)),()=>{let c=e()||[],d=c.length,f,u;return c[ls],J(()=>{let E,S,T,P,A,_,k,q,V;if(d===0)a!==0&&(Nt(i),i=[],n=[],r=[],a=0,l&&(l=[])),s.fallback&&(n=[zt],r[0]=me(D=>(i[0]=D,s.fallback())),a=1);else if(a===0){for(r=new Array(d),u=0;u<d;u++)n[u]=c[u],r[u]=me(g);a=d}else{for(T=new Array(d),P=new Array(d),l&&(A=new Array(d)),_=0,k=Math.min(a,d);_<k&&n[_]===c[_];_++);for(k=a-1,q=d-1;k>=_&&q>=_&&n[k]===c[q];k--,q--)T[q]=r[k],P[q]=i[k],l&&(A[q]=l[k]);for(E=new Map,S=new Array(q+1),u=q;u>=_;u--)V=c[u],f=E.get(V),S[u]=f===void 0?-1:f,E.set(V,u);for(f=_;f<=k;f++)V=n[f],u=E.get(V),u!==void 0&&u!==-1?(T[u]=r[f],P[u]=i[f],l&&(A[u]=l[f]),u=S[u],E.set(V,u)):i[f]();for(u=_;u<d;u++)u in T?(r[u]=T[u],i[u]=P[u],l&&(l[u]=A[u],l[u](u))):r[u]=me(g);r=r.slice(0,a=d),n=c.slice(0)}return r});function g(E){if(i[u]=E,l){const[S,T]=F(u);return l[u]=T,t(c[u],S)}return t(c[u])}}}function Oi(e,t,s={}){let n=[],r=[],i=[],a=[],l=0,c;return Fe(()=>Nt(i)),()=>{const d=e()||[],f=d.length;return d[ls],J(()=>{if(f===0)return l!==0&&(Nt(i),i=[],n=[],r=[],l=0,a=[]),s.fallback&&(n=[zt],r[0]=me(g=>(i[0]=g,s.fallback())),l=1),r;for(n[0]===zt&&(i[0](),i=[],n=[],r=[],l=0),c=0;c<f;c++)c<n.length&&n[c]!==d[c]?a[c](()=>d[c]):c>=n.length&&(r[c]=me(u));for(;c<n.length;c++)i[c]();return l=a.length=i.length=f,n=d.slice(0),r=r.slice(0,l)});function u(g){i[c]=g;const[E,S]=F(d[c]);return a[c]=S,t(E,c)}}}function ds(e,t){return J(()=>e(t||{}))}function yt(){return!0}var $t={get(e,t,s){return t===wt?s:e.get(t)},has(e,t){return t===wt?!0:e.has(t)},set:yt,deleteProperty:yt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:yt,deleteProperty:yt}},ownKeys(e){return e.keys()}};function Vt(e){return(e=typeof e=="function"?e():e)?e:{}}function Ri(){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 a=0;a<e.length;a++){const l=e[a];t=t||!!l&&wt in l,e[a]=typeof l=="function"?(t=!0,z(l)):l}if(Ys&&t)return new Proxy({get(a){for(let l=e.length-1;l>=0;l--){const c=Vt(e[l])[a];if(c!==void 0)return c}},has(a){for(let l=e.length-1;l>=0;l--)if(a in Vt(e[l]))return!0;return!1},keys(){const a=[];for(let l=0;l<e.length;l++)a.push(...Object.keys(Vt(e[l])));return[...new Set(a)]}},$t);const s={},n=Object.create(null);for(let a=e.length-1;a>=0;a--){const l=e[a];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let d=c.length-1;d>=0;d--){const f=c[d];if(f==="__proto__"||f==="constructor")continue;const u=Object.getOwnPropertyDescriptor(l,f);if(!n[f])n[f]=u.get?{enumerable:!0,configurable:!0,get:Ri.bind(s[f]=[u.get.bind(l)])}:u.value!==void 0?u:void 0;else{const g=s[f];g&&(u.get?g.push(u.get.bind(l)):u.value!==void 0&&g.push(()=>u.value))}}}const r={},i=Object.keys(n);for(let a=i.length-1;a>=0;a--){const l=i[a],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&&wt in e){const r=new Set(t.length>1?t.flat():t[0]),i=t.map(a=>new Proxy({get(l){return a.includes(l)?e[l]:void 0},has(l){return a.includes(l)&&l in e},keys(){return a.filter(l=>l in e)}},$t));return i.push(new Proxy({get(a){return r.has(a)?void 0:e[a]},has(a){return r.has(a)?!1:a in e},keys(){return Object.keys(e).filter(a=>!r.has(a))}},$t)),i}const s={},n=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const i=Object.getOwnPropertyDescriptor(e,r),a=!i.get&&!i.set&&i.enumerable&&i.writable&&i.configurable;let l=!1,c=0;for(const d of t)d.includes(r)&&(l=!0,a?n[c][r]=i.value:Object.defineProperty(n[c],r,i)),++c;l||(a?s[r]=i.value:Object.defineProperty(s,r,i))}return[...n,s]}function cn(e){let t,s;const n=r=>{const i=b.context;if(i){const[l,c]=F();b.count||(b.count=0),b.count++,(s||(s=e())).then(d=>{!b.done&&We(i),b.count--,c(()=>d.default),We()}),t=l}else if(!t){const[l]=Pi(()=>(s||(s=e())).then(c=>c.default));t=l}let a;return z(()=>(a=t())?J(()=>{if(!i||b.done)return a(r);const l=b.context;We(i);const c=a(r);return We(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var Ui=0;function Mi(){return b.context?b.getNextContextId():`cl-${Ui++}`}var un=e=>`Stale read from <${e}>.`;function Bi(e){const t="fallback"in e&&{fallback:()=>e.fallback};return z(Gi(()=>e.each,e.children,t||void 0))}function qi(e){const t="fallback"in e&&{fallback:()=>e.fallback};return z(Oi(()=>e.each,e.children,t||void 0))}function Fi(e){const t=e.keyed,s=z(()=>e.when,void 0,void 0),n=t?s:z(s,void 0,{equals:(r,i)=>!r==!i});return z(()=>{const r=n();if(r){const i=e.children;return typeof i=="function"&&i.length>0?J(()=>i(t?r:()=>{if(!J(n))throw un("Show");return s()})):i}return e.fallback},void 0,void 0)}function Ki(e){const t=sn(()=>e.children),s=z(()=>{const n=t(),r=Array.isArray(n)?n:[n];let i=()=>{};for(let a=0;a<r.length;a++){const l=a,c=r[a],d=i,f=z(()=>d()?void 0:c.when,void 0,void 0),u=c.keyed?f:z(f,void 0,{equals:(g,E)=>!g==!E});i=()=>d()||(u()?[l,f,c]:void 0)}return i});return z(()=>{const n=s()();if(!n)return e.fallback;const[r,i,a]=n,l=a.children;return typeof l=="function"&&l.length>0?J(()=>l(a.keyed?i():()=>{var d;if(((d=J(s)())==null?void 0:d[0])!==r)throw un("Match");return i()})):l},void 0,void 0)}function Vi(e){return e}var Hi=["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"],Qi=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...Hi]),zi=new Set(["innerHTML","textContent","innerText","children"]),$i=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),Wi=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 Yi(e,t){const s=Wi[e];return typeof s=="object"?s[t]?s.$:void 0:s}var Ji=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),Xi=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"]),Zi={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},ea=e=>z(()=>e());function ta(e,t,s){let n=s.length,r=t.length,i=n,a=0,l=0,c=t[r-1].nextSibling,d=null;for(;a<r||l<i;){if(t[a]===s[l]){a++,l++;continue}for(;t[r-1]===s[i-1];)r--,i--;if(r===a){const f=i<n?l?s[l-1].nextSibling:s[i-l]:c;for(;l<i;)e.insertBefore(s[l++],f)}else if(i===l)for(;a<r;)(!d||!d.has(t[a]))&&t[a].remove(),a++;else if(t[a]===s[i-1]&&s[l]===t[r-1]){const f=t[--r].nextSibling;e.insertBefore(s[l++],t[a++].nextSibling),e.insertBefore(s[--i],f),t[r]=s[i]}else{if(!d){d=new Map;let u=l;for(;u<i;)d.set(s[u],u++)}const f=d.get(t[a]);if(f!=null)if(l<f&&f<i){let u=a,g=1,E;for(;++u<r&&u<i&&!((E=d.get(t[u]))==null||E!==f+g);)g++;if(g>f-l){const S=t[a];for(;l<f;)e.insertBefore(s[l++],S)}else e.replaceChild(s[l++],t[a++])}else a++;else t[a++].remove()}}}var Xe="_$DX_DELEGATE";function dn(e,t,s,n={}){let r;return me(i=>{r=i,t===document?e():kt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function sa(e,t,s,n){let r;const i=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},a=()=>(r||(r=i())).cloneNode(!0);return a.cloneNode=a,a}function fn(e,t=window.document){const s=t[Xe]||(t[Xe]=new Set);for(let n=0,r=e.length;n<r;n++){const i=e[n];s.has(i)||(s.add(i),t.addEventListener(i,pn))}}function na(e=window.document){if(e[Xe]){for(let t of e[Xe].keys())e.removeEventListener(t,pn);delete e[Xe]}}function Lt(e,t,s){xe(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function ra(e,t,s,n){xe(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function ia(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]=i=>r.call(e,s[1],i))}else e.addEventListener(t,s,typeof s!="function"&&s)}function aa(e,t,s={}){const n=Object.keys(t||{}),r=Object.keys(s);let i,a;for(i=0,a=r.length;i<a;i++){const l=r[i];!l||l==="undefined"||t[l]||(Ss(e,l,!1),delete s[l])}for(i=0,a=n.length;i<a;i++){const l=n[i],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(Ss(e,l,!0),s[l]=c)}return s}function oa(e,t,s){if(!t)return s?Lt(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,i;for(i in s)t[i]==null&&n.removeProperty(i),delete s[i];for(i in t)r=t[i],r!==s[i]&&(n.setProperty(i,r),s[i]=r);return s}function mn(e,t={},s,n){const r={};return n||Ee(()=>r.children=tt(e,t.children,r.children)),Ee(()=>typeof t.ref=="function"&&En(t.ref,e)),Ee(()=>la(e,t,s,!0,r,!0)),r}function En(e,t,s){return J(()=>e(t,s))}function kt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return tt(e,t,n,s);Ee(r=>tt(e,t(),r,s),n)}function la(e,t,s,n,r={},i=!1){t||(t={});for(const a in r)if(!(a in t)){if(a==="children")continue;r[a]=Ts(e,a,null,r[a],s,i,t)}for(const a in t){if(a==="children")continue;const l=t[a];r[a]=Ts(e,a,l,r[a],s,i,t)}}function ca(e){let t,s;return!xe()||!(t=b.registry.get(s=da()))?e():(b.completed&&b.completed.add(t),b.registry.delete(s),t)}function xe(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function ua(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Ss(e,t,s){const n=t.trim().split(/\s+/);for(let r=0,i=n.length;r<i;r++)e.classList.toggle(n[r],s)}function Ts(e,t,s,n,r,i,a){let l,c,d,f,u;if(t==="style")return oa(e,s,n);if(t==="classList")return aa(e,s,n);if(s===n)return n;if(t==="ref")i||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=Ji.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:")Lt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")ia(e,t.slice(5),s);else if((u=t.slice(0,5)==="prop:")||(d=zi.has(t))||!r&&((f=Yi(t,e.tagName))||(c=Qi.has(t)))||(l=e.nodeName.includes("-")||"is"in a)){if(u)t=t.slice(5),c=!0;else if(xe(e))return s;t==="class"||t==="className"?hn(e,s):l&&!c&&!d?e[ua(t)]=s:e[f||t]=s}else{const g=r&&t.indexOf(":")>-1&&Zi[t.split(":")[0]];g?ra(e,g,t,s):Lt(e,$i[t]||t,s)}return s}function pn(e){if(b.registry&&b.events&&b.events.find(([c,d])=>d===e))return;let t=e.target;const s=`$$${e.type}`,n=e.target,r=e.currentTarget,i=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),a=()=>{const c=t[s];if(c&&!t.disabled){const d=t[`${s}Data`];if(d!==void 0?c.call(t,d,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&i(t.host),!0},l=()=>{for(;a()&&(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();i(c[0]);for(let d=0;d<c.length-2&&(t=c[d],!!a());d++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();i(n)}function tt(e,t,s,n,r){const i=xe(e);if(i){!s&&(s=[...e.childNodes]);let c=[];for(let d=0;d<s.length;d++){const f=s[d];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 a=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,a==="string"||a==="number"){if(i||a==="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=we(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||a==="boolean"){if(i)return s;s=we(e,s,n)}else{if(a==="function")return Ee(()=>{let c=t();for(;typeof c=="function";)c=c();s=tt(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],d=s&&Array.isArray(s);if(Wt(c,t,s,r))return Ee(()=>s=tt(e,c,s,n,!0)),()=>s;if(i){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let f=c[0];if(f.parentNode!==e)return s;const u=[f];for(;(f=f.nextSibling)!==n;)u.push(f);return s=u}if(c.length===0){if(s=we(e,s,n),l)return s}else d?s.length===0?Ps(e,c,n):ta(e,s,c):(s&&we(e),Ps(e,c));s=c}else if(t.nodeType){if(i&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=we(e,s,n,t);we(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 i=0,a=t.length;i<a;i++){let l=t[i],c=s&&s[e.length],d;if(!(l==null||l===!0||l===!1))if((d=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=Wt(e,l,c)||r;else if(d==="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 we(e,t,s,n){if(s===void 0)return e.textContent="";const r=n||document.createTextNode("");if(t.length){let i=!1;for(let a=t.length-1;a>=0;a--){const l=t[a];if(r!==l){const c=l.parentNode===e;!i&&!a?c?e.replaceChild(r,l):e.insertBefore(r,s):c&&l.remove()}else i=!0}}else e.insertBefore(r,s);return[r]}function da(){return b.getNextContextId()}var fa="http://www.w3.org/2000/svg";function yn(e,t=!1){return t?document.createElementNS(fa,e):document.createElement(e)}function ha(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=As();let i,a=!!b.context;return cs(()=>{a&&(As().user=a=!1),i||(i=tn(r,()=>z(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,d]=F(!1),f=()=>d(!0);me(u=>kt(l,()=>c()?u():i(),null)),Fe(f)}else{const c=yn(e.isSVG?"g":"div",e.isSVG),d=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),kt(d,i),l.appendChild(c),e.ref&&e.ref(c),Fe(()=>l.removeChild(c))}},void 0,{render:!a}),s}function ga(e,t){const s=z(e);return z(()=>{const n=s();switch(typeof n){case"function":return J(()=>n(t));case"string":const r=Xi.has(n),i=b.context?ca():yn(n,r);return mn(i,t,r),i}})}function ma(e){const[,t]=ln(e,["component"]);return ga(()=>e.component,t)}var Ea=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 Ea}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)}},pa=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 ya(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 Aa(e,t){const s=ya(e);if("find"in s)return s.find(t);const n=s;for(let r=0;r<n.length;r++){const i=n[r];if(t(i))return i}}function Ke(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function xt(e,t){return e.indexOf(t)!==-1}function _s(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var Sa=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Aa(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Ta=e=>Object.prototype.toString.call(e).slice(8,-1),Sn=e=>typeof e>"u",Pa=e=>e===null,st=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Yt=e=>st(e)&&Object.keys(e).length===0,pe=e=>Array.isArray(e),_a=e=>typeof e=="string",xa=e=>typeof e=="number"&&!isNaN(e),wa=e=>typeof e=="boolean",va=e=>e instanceof RegExp,nt=e=>e instanceof Map,rt=e=>e instanceof Set,Tn=e=>Ta(e)==="Symbol",ba=e=>e instanceof Date&&!isNaN(e.valueOf()),Ca=e=>e instanceof Error,xs=e=>typeof e=="number"&&isNaN(e),Ia=e=>wa(e)||Pa(e)||Sn(e)||xa(e)||_a(e)||Tn(e),Na=e=>typeof e=="bigint",La=e=>e===1/0||e===-1/0,ka=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),ja=e=>e instanceof URL,Pn=e=>e.replace(/\./g,"\\."),Ht=e=>e.map(String).map(Pn).join("."),Ze=e=>{const t=[];let s="";for(let r=0;r<e.length;r++){let i=e.charAt(r);if(i==="\\"&&e.charAt(r+1)==="."){s+=".",r++;continue}if(i==="."){t.push(s),s="";continue}s+=i}const n=s;return t.push(n),t};function ie(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var _n=[ie(Sn,"undefined",()=>null,()=>{}),ie(Na,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),ie(ba,"Date",e=>e.toISOString(),e=>new Date(e)),ie(Ca,"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}),ie(va,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),ie(rt,"set",e=>[...e.values()],e=>new Set(e)),ie(nt,"map",e=>[...e.entries()],e=>new Map(e)),ie(e=>xs(e)||La(e),"number",e=>xs(e)?"NaN":e>0?"Infinity":"-Infinity",Number),ie(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),ie(ja,"URL",e=>e.toString(),e=>new URL(e))];function Bt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var xn=Bt((e,t)=>Tn(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}),Da=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),wn=Bt(ka,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=Da[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function vn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var bn=Bt(vn,(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)}),Ga=[bn,xn,Cn,wn],ws=(e,t)=>{const s=_s(Ga,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=_s(_n,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},In={};_n.forEach(e=>{In[e.annotation]=e});var Oa=(e,t,s)=>{if(pe(t))switch(t[0]){case"symbol":return xn.untransform(e,t,s);case"class":return bn.untransform(e,t,s);case"custom":return Cn.untransform(e,t,s);case"typed-array":return wn.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)}},ve=(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 Ra=(e,t)=>{Nn(t);for(let s=0;s<t.length;s++){const n=t[s];if(rt(e))e=ve(e,+n);else if(nt(e)){const r=+n,i=+t[++s]==0?"key":"value",a=ve(e,r);switch(i){case"key":e=a;break;case"value":e=e.get(a);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 i=0;i<t.length-1;i++){const a=t[i];if(pe(n)){const l=+a;n=n[l]}else if(st(n))n=n[a];else if(rt(n)){const l=+a;n=ve(n,l)}else if(nt(n)){if(i===t.length-2)break;const c=+a,d=+t[++i]==0?"key":"value",f=ve(n,c);switch(d){case"key":n=f;break;case"value":n=n.get(f);break}}}const r=t[t.length-1];if(pe(n)?n[+r]=s(n[+r]):st(n)&&(n[r]=s(n[r])),rt(n)){const i=ve(n,+r),a=s(i);i!==a&&(n.delete(i),n.add(a))}if(nt(n)){const i=+t[t.length-2],a=ve(n,i);switch(+r==0?"key":"value"){case"key":{const c=s(a);n.set(c,n.get(a)),c!==a&&n.delete(a);break}case"value":{n.set(a,s(n.get(a)));break}}}return e};function Xt(e,t,s=[]){if(!e)return;if(!pe(e)){Ke(e,(i,a)=>Xt(i,t,[...s,...Ze(a)]));return}const[n,r]=e;r&&Ke(r,(i,a)=>{Xt(i,t,[...s,...Ze(a)])}),t(n,s)}function Ua(e,t,s){return Xt(t,(n,r)=>{e=Jt(e,r,i=>Oa(i,n,s))}),e}function Ma(e,t){function s(n,r){const i=Ra(e,Ze(r));n.map(Ze).forEach(a=>{e=Jt(e,a,()=>i)})}if(pe(t)){const[n,r]=t;n.forEach(i=>{e=Jt(e,Ze(i),()=>e)}),r&&Ke(r,s)}else Ke(t,s);return e}var Ba=(e,t)=>st(e)||pe(e)||nt(e)||rt(e)||vn(e,t);function qa(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function Fa(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[i,...a]=r;i.length===0?n=a.map(Ht):s[Ht(i)]=a.map(Ht)}),n?Yt(s)?[n]:[n,s]:Yt(s)?void 0:s}var Ln=(e,t,s,n,r=[],i=[],a=new Map)=>{const l=Ia(e);if(!l){qa(e,r,t);const E=a.get(e);if(E)return n?{transformedValue:null}:E}if(!Ba(e,s)){const E=ws(e,s),S=E?{transformedValue:E.value,annotations:[E.type]}:{transformedValue:e};return l||a.set(e,S),S}if(xt(i,e))return{transformedValue:null};const c=ws(e,s),d=(c==null?void 0:c.value)??e,f=pe(d)?[]:{},u={};Ke(d,(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 T=Ln(E,t,s,n,[...r,S],[...i,e],a);f[S]=T.transformedValue,pe(T.annotations)?u[S]=T.annotations:st(T.annotations)&&Ke(T.annotations,(P,A)=>{u[Pn(S)+"."+A]=P})});const g=Yt(u)?{transformedValue:f,annotations:c?[c.type]:void 0}:{transformedValue:f,annotations:c?[c.type,u]:u};return l||a.set(e,g),g};function kn(e){return Object.prototype.toString.call(e).slice(8,-1)}function vs(e){return kn(e)==="Array"}function Ka(e){if(kn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function Va(e,t,s,n,r){const i={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";i==="enumerable"&&(e[t]=s),r&&i==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function Zt(e,t={}){if(vs(e))return e.map(r=>Zt(r,t));if(!Ka(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,i)=>{if(vs(t.props)&&!t.props.includes(i))return r;const a=e[i],l=Zt(a,t);return Va(r,i,l,e,t.nonenumerable),r},{})}var M=class{constructor({dedupe:e=!1}={}){this.classRegistry=new pa,this.symbolRegistry=new An(t=>t.description??""),this.customTransformerRegistry=new Sa,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=Fa(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=Ua(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=Ma(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)}};M.defaultInstance=new M;M.serialize=M.defaultInstance.serialize.bind(M.defaultInstance);M.deserialize=M.defaultInstance.deserialize.bind(M.defaultInstance);M.stringify=M.defaultInstance.stringify.bind(M.defaultInstance);M.parse=M.defaultInstance.parse.bind(M.defaultInstance);M.registerClass=M.defaultInstance.registerClass.bind(M.defaultInstance);M.registerSymbol=M.defaultInstance.registerSymbol.bind(M.defaultInstance);M.registerCustom=M.defaultInstance.registerCustom.bind(M.defaultInstance);M.allowErrorProps=M.defaultInstance.allowErrorProps.bind(M.defaultInstance);var jn=M.serialize,Ha=M.stringify;function Qa(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function za(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function $a({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function Wa({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function Ya(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var Ja=(e,t=!1)=>{const{json:s}=jn(e);return JSON.stringify(s,null,t?2:void 0)},At=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,Xa=(e,t)=>e.queryHash.localeCompare(t.queryHash),Dn=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,Za=(e,t)=>At(e)===At(t)?Dn(e,t):At(e)>At(t)?1:-1,eo={status:Za,"query hash":Xa,"last updated":Dn},St=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,Gn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,to=(e,t)=>St(e)===St(t)?Gn(e,t):St(e)>St(t)?1:-1,so={status:to,"last updated":Gn},no=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),ro=()=>{const[e,t]=F("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),Fe(()=>s.removeEventListener("change",n))}),e},Ye=(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,...i]=t;return n.set(r,Ye(n.get(r),i,s)),n}if(e instanceof Set){const n=Ye(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,...i]=t;return n[r]=Ye(n[r],i,s),n}if(e instanceof Object){const n={...e};if(t.length===1)return n[t[0]]=s,n;const[r,...i]=t;return n[r]=Ye(n[r],i,s),n}return e},Je=(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,Je(s.get(n),r)),s}if(e instanceof Set){const s=Je(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((i,a)=>a.toString()!==t[0]);const[n,...r]=t;return s[n]=Je(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]=Je(s[n],r),s}return e},On=(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,it,at,ot,Pe,lt,Ce,Ie,Ne,Le,ke,ct,je,ut,Is,io=(Is=class{constructor(e){G(this,be);G(this,it);G(this,at);G(this,ot);G(this,Pe,!1);G(this,lt);G(this,Ce);G(this,Ie);G(this,Ne);G(this,Le);G(this,ke);G(this,ct);G(this,je);G(this,ut);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:i,position:a,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:f,hideDisabledQueries:u}=e;j(this,be,F(t)),j(this,at,s),j(this,ot,n),j(this,it,r),j(this,lt,d),j(this,Ce,f),j(this,Ie,F(i)),j(this,Ne,F(a)),j(this,Le,F(l)),j(this,ke,F(c)),j(this,ct,F(u))}setButtonPosition(e){x(this,Ie)[1](e)}setPosition(e){x(this,Ne)[1](e)}setInitialIsOpen(e){x(this,Le)[1](e)}setErrorTypes(e){x(this,ke)[1](e)}setClient(e){x(this,be)[1](e)}mount(e){if(x(this,Pe))throw new Error("Devtools is already mounted");const t=dn(()=>{const s=this,[n]=x(this,Ie),[r]=x(this,Ne),[i]=x(this,Le),[a]=x(this,ke),[l]=x(this,ct),[c]=x(this,be);let d;return x(this,je)?d=x(this,je):(d=cn(()=>Promise.resolve().then(()=>require("./NCMVHL6D-sV6MElOb.cjs"))),j(this,je,d)),On(x(this,lt),x(this,Ce)),ds(d,fs({get queryFlavor(){return x(s,at)},get version(){return x(s,ot)},get onlineManager(){return x(s,it)},get shadowDOMTarget(){return x(s,Ce)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return i()},get errorTypes(){return a()},get hideDisabledQueries(){return l()}}))},e);j(this,Pe,!0),j(this,ut,t)}unmount(){var e;if(!x(this,Pe))throw new Error("Devtools is not mounted");(e=x(this,ut))==null||e.call(this),j(this,Pe,!1)}},be=new WeakMap,it=new WeakMap,at=new WeakMap,ot=new WeakMap,Pe=new WeakMap,lt=new WeakMap,Ce=new WeakMap,Ie=new WeakMap,Ne=new WeakMap,Le=new WeakMap,ke=new WeakMap,ct=new WeakMap,je=new WeakMap,ut=new WeakMap,Is),De,dt,ft,ht,_e,gt,Ge,Oe,Re,Ue,Me,mt,Be,qe,Et,Ns,ao=(Ns=class{constructor(e){G(this,De);G(this,dt);G(this,ft);G(this,ht);G(this,_e,!1);G(this,gt);G(this,Ge);G(this,Oe);G(this,Re);G(this,Ue);G(this,Me);G(this,mt);G(this,Be);G(this,qe);G(this,Et);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:i,position:a,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:f,onClose:u,hideDisabledQueries:g}=e;j(this,De,F(t)),j(this,ft,s),j(this,ht,n),j(this,dt,r),j(this,gt,d),j(this,Ge,f),j(this,Oe,F(i)),j(this,Re,F(a)),j(this,Ue,F(l)),j(this,Me,F(c)),j(this,mt,F(g)),j(this,Be,F(u))}setButtonPosition(e){x(this,Oe)[1](e)}setPosition(e){x(this,Re)[1](e)}setInitialIsOpen(e){x(this,Ue)[1](e)}setErrorTypes(e){x(this,Me)[1](e)}setClient(e){x(this,De)[1](e)}setOnClose(e){x(this,Be)[1](()=>e)}mount(e){if(x(this,_e))throw new Error("Devtools is already mounted");const t=dn(()=>{const s=this,[n]=x(this,Oe),[r]=x(this,Re),[i]=x(this,Ue),[a]=x(this,Me),[l]=x(this,mt),[c]=x(this,De),[d]=x(this,Be);let f;return x(this,qe)?f=x(this,qe):(f=cn(()=>Promise.resolve().then(()=>require("./2AITGKQY-CpxlNmec.cjs"))),j(this,qe,f)),On(x(this,gt),x(this,Ge)),ds(f,fs({get queryFlavor(){return x(s,ft)},get version(){return x(s,ht)},get onlineManager(){return x(s,dt)},get shadowDOMTarget(){return x(s,Ge)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return i()},get errorTypes(){return a()},get hideDisabledQueries(){return l()},get onClose(){return d()}}))},e);j(this,_e,!0),j(this,Et,t)}unmount(){var e;if(!x(this,_e))throw new Error("Devtools is not mounted");(e=x(this,Et))==null||e.call(this),j(this,_e,!1)}},De=new WeakMap,dt=new WeakMap,ft=new WeakMap,ht=new WeakMap,_e=new WeakMap,gt=new WeakMap,Ge=new WeakMap,Oe=new WeakMap,Re=new WeakMap,Ue=new WeakMap,Me=new WeakMap,mt=new WeakMap,Be=new WeakMap,qe=new WeakMap,Et=new WeakMap,Ns);function oo(e){const t=w.useQueryClient(e.client),s=Q.useRef(null),{buttonPosition:n,position:r,initialIsOpen:i,errorTypes:a,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}=e,[f]=Q.useState(new io({client:t,queryFlavor:"React Query",version:"5",onlineManager:w.onlineManager,buttonPosition:n,position:r,initialIsOpen:i,errorTypes:a,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}));return Q.useEffect(()=>{f.setClient(t)},[t,f]),Q.useEffect(()=>{n&&f.setButtonPosition(n)},[n,f]),Q.useEffect(()=>{r&&f.setPosition(r)},[r,f]),Q.useEffect(()=>{f.setInitialIsOpen(i||!1)},[i,f]),Q.useEffect(()=>{f.setErrorTypes(a||[])},[a,f]),Q.useEffect(()=>(s.current&&f.mount(s.current),()=>{f.unmount()}),[f]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function lo(e){const t=w.useQueryClient(e.client),s=Q.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:i,hideDisabledQueries:a}=e,[l]=Q.useState(new ao({client:t,queryFlavor:"React Query",version:"5",onlineManager:w.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:n,styleNonce:r,shadowDOMTarget:i,onClose:e.onClose,hideDisabledQueries:a}));return Q.useEffect(()=>{l.setClient(t)},[t,l]),Q.useEffect(()=>{l.setOnClose(e.onClose??(()=>{}))},[e.onClose,l]),Q.useEffect(()=>{l.setErrorTypes(n||[])},[n,l]),Q.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}:oo;process.env.NODE_ENV;const Rn=K.atom(""),co=()=>{I.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),I.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},uo=()=>{const e=B(),t=R();return w.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},fo=()=>{const{data:e}=Z(),{data:t}=ue(),{data:s}=Ae(),n=B(),r=R(),i=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]);return w.useMutation({mutationFn:async({block:a})=>r(n,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:a,lang:(t==null?void 0:t.lang)||i,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:i,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}}})})},Un=()=>{const[,e]=te();return h.useCallback((t,s)=>{const r=new URLSearchParams(window.location.search).get("lang"),i=new URLSearchParams({page:t});r&&i.set("lang",r),window.history.pushState({},"",`?${i.toString()}`),e(i),window.dispatchEvent(new PopStateEvent("popstate")),s==null||s()},[e])},Mn=()=>{const e=Un();return h.useCallback(({pageId:t})=>{e(t)},[e])},ho=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-Zh-mlMF5.cjs"))),go=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-DWtmtrUj.cjs"))),mo=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-DcASH9l1.cjs"))),Eo=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-DM11qhOe.cjs")));co();zn.loadWebBlocks();I.registerChaiTopBar(ti);yi();I.registerChaiMediaManager(ho);I.registerChaiSaveToLibrary(go);const po={role:"",permissions:null},Cs=e=>{oi(),ur();const t=Ot(),{data:s=po,isFetching:n}=Hs(),{data:r,isFetching:i}=de(),{data:a,isFetching:l}=uo(),{data:c,isFetching:d}=Ae(),f=n||i||l||d,[u]=te(),g=u.get("page"),{data:E}=Z(),{data:S,isFetching:T}=ii(),{blocks:P}=ri(S),{lockingStatus:A,pageLock:_}=Se(),{data:k,isFetching:q}=Ks(),V=si(),{onSave:D}=li(),{mutateAsync:oe}=fo(),{getPartialBlocks:le,getPartialBlockBlocks:O}=ci(),{mutateAsync:C}=xr(),{mutateAsync:N}=Vs(),W=Mn(),[H,ne]=h.useState(!1),Qe=h.useRef([]),he=h.useMemo(()=>p.get(c,"theme",{})||{},[c]),ze=p.isEmpty(A)&&(_==null?void 0:_.status)==="editing",Te=(_==null?void 0:_.status)==="checking",hs=T||Te||q;Qe.current=P;const[qn]=K.useAtom(Rn);h.useEffect(()=>{const re=()=>{document.hidden?ne(!0):ne(!1)};return window.addEventListener("visibilitychange",re),()=>window.removeEventListener("visibilitychange",re)},[]);const Fn=h.useMemo(()=>{const re={};return s&&(re.permissions=p.get(s,"permissions",null),re.role=p.get(s,"role","user")),re},[s]),Kn=h.useCallback(async(re,pt)=>await C({pageType:re,query:pt}),[C]);return o.jsxs(o.Fragment,{children:[hs&&o.jsx(os,{className:f?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(v.Loader,{className:`animate-spin text-primary ${f?"h-6 w-6":"h-5 w-5"}`})}),qn&&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(Eo,{})}),o.jsx(I.ChaiBuilderEditor,{gotoPage:W,collections:a??[],getBlockAsyncProps:oe,pageExternalData:k,themePresets:e.themePresets??[],pageId:E==null?void 0:E.id,loading:T,fallbackLang:t,languages:(c==null?void 0:c.languages)||[],brandingOptions:(c==null?void 0:c.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!H&&ze&&(e.autoSave??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:O,getPartialBlocks:le,blocks:T?[]:P,theme:p.cloneDeep(he),pageTypes:r,searchPageTypeItems:Kn,askAiCallBack:V,onSave:async({blocks:re,theme:pt,needTranslations:Vn})=>{if(!g)return!0;Qe.current=re;const gs=[...re];return await D({page:g,blocks:gs,needTranslations:Vn}),Qe.current=gs,p.isEqual(pt,he)||await N({settings:{theme:pt}}),!0},themePanelComponent:mo,...Fn}),o.jsxs("div",{children:[o.jsx(hr,{isFetchingPage:hs}),o.jsx(gr,{})]})]})},yo=new w.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),Ao=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(w.QueryClientProvider,{client:yo,children:[o.jsx(Cs,{...e}),o.jsx(bs,{})]}):o.jsx("div",{})},So=Q.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-D_iF9Sm3.cjs")));function Bn({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,i]=Q.useState(!1);return o.jsxs(m.Popover,{open:r,onOpenChange:i,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(Q.Suspense,{children:o.jsx(So,{data:e,onSelect:t,dataType:s,open:r,setOpen:i})})]})}const To=()=>{const{savePageAsync:e}=I.useSavePage(),t=w.useQueryClient();return h.useCallback(async()=>{await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t])},Po=()=>{const e=w.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},_o=()=>{const e=B(),t=R(),{data:s}=ue(),n=w.useQueryClient();return w.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")}})},xo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-Zh-mlMF5.cjs"))),wo=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:i=!1})=>{const[a,l]=h.useState(!1),c=()=>{i||l(!0)},d=()=>{l(!1)},f=E=>{const S=Array.isArray(E)?E[0]:E;S!=null&&S.url&&s(p.pick(S,["url","id"])),l(!1)},u=()=>{s({url:"",id:""})},g=(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:[g?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:c,src:t,alt:"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:u,disabled:i,children:g?o.jsx(v.X,{className:"h-4 w-4"}):o.jsx(v.Trash2,{className:"h-4 w-4"})}),!g&&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:c,disabled:i,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 ${i?"cursor-not-allowed opacity-50":"hover:border-gray-400"}`,onClick:c,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:a,onOpenChange:l,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:"Select Image"}),o.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:d,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(xo,{close:d,onSelect:f,mode:"image",assetId:e})})})]})})]})},vo=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 i=r[0],a=r.index,l=`"__placeholder_${s.length}__"`;s.push({original:i,replaced:l,position:a}),n=n.replace(i,l)}try{return{isValid:!0,parsed:JSON.parse(n),error:null,placeholders:s}}catch(i){const a=i,l=a.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let d,f;if(c!==void 0){const u=n.substring(0,c).split(`
2
- `);d=u.length,f=u[u.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:a.message,line:d,column:f,position:c}}}},bo=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},i)=>{const a=`"__placeholder_${i}__"`,l=new RegExp(vo(a),"g");n=n.replace(l,r)}),n},Co=(e,t)=>{if(!e)return"";let s=JSON.stringify(e,null,2);const n=/{{([^{}]+)}}/g;let r;for(;(r=n.exec(s))!==null;){const i=r[1],a=p.get(t,i,null);s=s.replace(r[0],a)}return s},Io=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-BvWyXBz_.cjs"))),No=({value:e,onChange:t,disabled:s=!1,readOnly:n=!1,placeholder:r="Enter JSON",rows:i=6,id:a="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:d,copyJsonLDFromDefaultPage:f})=>{const[u,g]=h.useState("edit"),[E,S]=h.useState(null),[T,P]=h.useState(""),A=h.useRef(null),[_]=jt(),k=a==="jsonLD"&&p.get(_,"features.sharedJsonLD",!1),q=a==="jsonLD"&&!d&&!!f;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const V=O=>{if(n)return;const C=O.target.value;t(C)},D=O=>{if(O.key==="Tab"){O.preventDefault();const C=O.currentTarget,N=C.selectionStart,W=C.selectionEnd;if(N!==W){const ne=e.substring(N,W).split(`
3
- `);if(O.shiftKey){const he=ne.map(Te=>Te.startsWith(" ")?Te.substring(2):Te).join(`
4
- `),ze=e.substring(0,N)+he+e.substring(W);t(ze),setTimeout(()=>{C.selectionStart=N,C.selectionEnd=N+he.length},0)}else{const he=ne.map(Te=>` ${Te}`).join(`
5
- `),ze=e.substring(0,N)+he+e.substring(W);t(ze),setTimeout(()=>{C.selectionStart=N,C.selectionEnd=N+he.length},0)}}else{const H=e.substring(0,N)+" "+e.substring(W);t(H),setTimeout(()=>{C.selectionStart=C.selectionEnd=N+2},0)}}};h.useEffect(()=>{const O=es(e);if(O.isValid)if(S(null),O.parsed){const C=Co(O.parsed,l);P(C)}else P("");else S(O.error),P("")},[e,l]);const oe=()=>{const O=es(e);if(O.isValid&&O.parsed){const C=bo(O.parsed,O.placeholders);t(C)}},le=()=>{E!=null&&E.position&&A.current&&(A.current.focus(),A.current.setSelectionRange(E.position,E.position+1))};return o.jsx("div",{className:"space-y-2",children:o.jsxs(m.Tabs,{value:u,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||q,children:[o.jsx(v.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),k&&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"})]})]}),q?null:u==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(Bn,{dataType:"value",data:l??{},onSelect:O=>c&&c(O,a)})})]}),o.jsxs(m.TabsContent,{value:"edit",className:"relative mt-0",children:[!q&&u==="edit"&&o.jsx(Rt,{content:"Format JSON",side:"right",showTooltip:!s&&!E,children:o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",onClick:oe,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||E!==null,children:o.jsx(v.FileCode2,{})})}),q?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:A,id:a,name:a,className:`rounded-md border border-input text-xs ${E?"border-red-500":""}`,onChange:V,onKeyDown:D,value:e,placeholder:r,rows:i,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:le,children:"Show position"})]})]})]}),o.jsxs(m.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(m.Textarea,{rows:i,value:T,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."})]}),k&&o.jsx(m.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(Io,{})})})]})})},Lo=()=>{const e=ee("getAccessToken");return{getAccessToken:h.useCallback(async()=>{try{return await e()}catch{return""}},[e])}},ko=()=>{const{logout:e}=Ve(),{getAccessToken:t}=Lo();return h.useCallback(async({url:s,method:n="GET",body:r={},headers:i={}})=>{const a=await t();if(!a)throw new Error("No auth token");if(!s)throw new Error("URL is required");try{const l=await fetch(s,{method:n,headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`,...i},body:JSON.stringify(r)});if(l.status===401)return console.log("Session expired",l),await e(),window.location.reload(),null;if(l.status===400)throw new Error((await l.json()).error);return await l.json()}catch(l){throw console.log("Something went wrong",l),l}},[e,t])};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.CONTENT=Y;exports.ChaiBuilderPages=Ao;exports.ChaiBuilderPagesRealtime=js;exports.Dynamic=ma;exports.For=Bi;exports.ImagePicker=wo;exports.Index=qi;exports.LANGUAGES=$e;exports.LanguageSwitcher=Ms;exports.Match=Vi;exports.NestedPathSelector=Bn;exports.PAGES_PERMISSIONS=se;exports.PageActionsDropdown=qs;exports.PermissionChecker=Tt;exports.Portal=ha;exports.Show=Fi;exports.SmartJsonInput=No;exports.Switch=Ki;exports.Tooltip=Rt;exports.addEventListener=gn;exports.addNewLangAtom=Gt;exports.batch=_i;exports.className=hn;exports.clearDelegatedEvents=na;exports.convertRemToPixels=no;exports.createComponent=ds;exports.createComputed=Zs;exports.createContext=Ci;exports.createEffect=cs;exports.createMemo=z;exports.createRenderEffect=Ee;exports.createRoot=me;exports.createSignal=F;exports.createUniqueId=Mi;exports.delegateEvents=fn;exports.deleteNestedDataByPath=Je;exports.displayValue=Ja;exports.getMutationStatusColor=Wa;exports.getPreferredColorScheme=ro;exports.getQueryStatusColor=$a;exports.getQueryStatusColorByLabel=Ya;exports.getQueryStatusLabel=Qa;exports.getSidedProp=za;exports.insert=kt;exports.memo=ea;exports.mergeProps=fs;exports.mutationSortFns=so;exports.navigateToPage=rs;exports.on=xi;exports.onCleanup=Fe;exports.onMount=en;exports.parseJSONWithPlaceholders=es;exports.previewUrlAtom=Rn;exports.serialize=jn;exports.setAttribute=Lt;exports.sortFns=eo;exports.splitProps=ln;exports.spread=mn;exports.stringify=Ha;exports.template=sa;exports.throwConfetti=Pt;exports.untrack=J;exports.updateNestedDataByPath=Ye;exports.use=En;exports.useActivePage=ue;exports.useApiUrl=B;exports.useAssetsApiUrl=Yn;exports.useBuilderPageData=Ks;exports.useChaiAuth=Ve;exports.useChaiFetch=ko;exports.useChaiUserInfo=Os;exports.useChangePage=Un;exports.useChangeSlug=Lr;exports.useClearAll=Po;exports.useContext=Ii;exports.useCreatePage=wr;exports.useCurrentPage=Z;exports.useDeletePage=br;exports.useDynamicPageSelector=Gs;exports.useFallbackLang=Ot;exports.useFetch=R;exports.useGotoPage=Mn;exports.useIsLanguagePageCreated=ts;exports.useLanguagePages=ye;exports.useMarkAsTemplate=Ir;exports.usePageEditInfo=Dt;exports.usePageLockRequestTakeOver=Rs;exports.usePageType=Bs;exports.usePageTypes=de;exports.usePageUserMapping=cr;exports.usePagesProps=jt;exports.usePublishPages=as;exports.useReloadPage=To;exports.useSearchParams=te;exports.useTransition=bi;exports.useUnmarkAsTemplate=Nr;exports.useUnpublishPage=Cr;exports.useUpdateActivePageMetadata=_o;exports.useUpdateAppSharedJsonLD=ai;exports.useUpdatePage=vr;exports.useUpdateWebsiteSettings=Vs;exports.useUserRoleAndPermissions=Hs;exports.useWebsiteLanguagePages=mr;exports.useWebsitePages=is;exports.useWebsiteSetting=Ae;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),T=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),w=require("lodash-es"),m=require("lucide-react"),p=require("react"),L=require("sonner"),u=require("./index-MlpQJHWW.cjs"),J=require("@tanstack/react-query"),S=()=>{const n=u.useApiUrl(),d=u.useFetch();return J.useQuery({queryKey:[u.ACTIONS.GET_APP_SHARED_JSONLD],queryFn:async()=>await d(n,{action:u.ACTIONS.GET_APP_SHARED_JSONLD})||[],placeholderData:[],staleTime:60*60*1e3,retry:2})};function P(){const{data:n}=u.useCurrentPage(),d=w.get(n,"metadata",{})||{},[o,j]=p.useState(w.get(d,"sharedJsonLD",[])||[]),[x,h]=p.useState({show:!1,data:null}),{mutateAsync:y}=u.useUpdateActivePageMetadata(),[a,r]=p.useState(null),{data:i,isLoading:g}=S(),{mutateAsync:f}=u.useUpdateAppSharedJsonLD(),{selectedLang:b}=T.useLanguages(),l=async t=>{await y({...d,sharedJsonLD:t}),j(t),r(null)},v=async t=>{r(t);let c=[...o];w.includes(o,t)?c=c.filter(N=>N!==t):c=[...c||[],t],await l(c)},A=async t=>{r(t);try{const c=i==null?void 0:i.filter(N=>N.id!==t);await f(c),j(c),r(null)}catch{r(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!b&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:g,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:t=>{t.stopPropagation(),h({show:!0,data:null})},children:g?e.jsx(m.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(m.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!i||(i==null?void 0:i.length)===0)&&!g&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),i==null?void 0:i.map(t=>{const c=u.parseJSONWithPlaceholders(t.content),N=c.isValid?c.parsed:"",C=w.includes(o,t.id),D=!b;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${a===t.id?"pointer-events-none":""}`,children:[a===t.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(m.Loader,{className:"h-5 w-5 animate-spin text-primary"})}),e.jsx(s.CardHeader,{className:"p-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[D&&e.jsx(s.Switch,{checked:C,onCheckedChange:()=>v(t.id)}),e.jsxs("div",{children:[e.jsx(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:t.name}),(t==null?void 0:t.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:t==null?void 0:t.description})]})]}),D&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>h({show:!0,data:t}),children:e.jsx(m.Edit,{className:"h-4 w-4"})}),e.jsxs(s.AlertDialog,{children:[e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(m.Trash,{className:"h-4 w-4"})}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete ",e.jsx("span",{className:"font-medium",children:t.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>A(t.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})}),e.jsx(s.CardContent,{className:"px-2 pb-2",children:D?e.jsx(s.Textarea,{id:t.id,rows:1,readOnly:!0,value:JSON.stringify(N,null,2),className:"no-scrollbar cursor-text overflow-hidden rounded-md border-none bg-gray-100/80 text-xs"}):e.jsxs("div",{className:"flex h-20 w-full flex-col items-center justify-center rounded-lg border bg-gray-100",children:[e.jsx("div",{className:"max-w-xl text-center text-xs text-gray-500",children:"Not available in selected language, but available in default language."}),e.jsx(s.Button,{size:"sm",variant:"outline",className:"mt-2",onClick:()=>{},children:"Copy & Edit from default language"})]})})]})})]}),g&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(m.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(O,{data:x==null?void 0:x.data,show:x==null?void 0:x.show,onClose:()=>{h({show:!1,data:null})}})]})}const O=({data:n,show:d,onClose:o})=>e.jsx(s.Dialog,{open:d,onOpenChange:()=>o(),children:d&&e.jsx(F,{data:n,show:d,onClose:o})}),F=({data:n,show:d,onClose:o})=>{const[j,x]=p.useState("edit"),[h,y]=p.useState(""),[a,r]=p.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),{data:i}=S(),{mutateAsync:g,isPending:f}=u.useUpdateAppSharedJsonLD();p.useEffect(()=>{x("edit"),r({name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),n&&r({name:n.name,description:n.description,content:n.content,enabledByDefaultForNewPages:n.enabledByDefaultForNewPages})},[n,d]),p.useEffect(()=>{const l=u.parseJSONWithPlaceholders(a.content);y(l.isValid?JSON.stringify(l.parsed,null,2):"")},[a.content]);const b=async()=>{if(!a.name||!a.content){L.toast.error("Please enter a name and content");return}const l={id:n?n.id:crypto.randomUUID(),name:a.name,description:a.description,content:a.content};n?await g([...(i||[]).map(v=>v.id===n.id?l:v)]):await g([...i||[],l]),o()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(s.Input,{id:"new-name",value:a.name,onChange:l=>r({...a,name:l.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(s.Input,{id:"new-description",value:a.description||"",onChange:l=>r({...a,description:l.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsxs(s.Tabs,{value:j,onValueChange:x,className:"w-full",children:[e.jsxs("div",{className:"mb-2 flex w-full items-center justify-between",children:[e.jsxs(s.TabsList,{className:"w-max",children:[e.jsxs(s.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[e.jsx(m.Code,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]}),e.jsxs(s.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!h,children:[e.jsx(m.Eye,{className:"h-4 w-4"}),e.jsx("span",{children:"Preview"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:j==="edit"&&e.jsx(s.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>r({...a,content:h}),disabled:!h,children:"Format"})})]}),e.jsxs(s.TabsContent,{value:"edit",children:[e.jsx(s.Textarea,{id:"new-content",value:a.content||"{}",onChange:l=>r({...a,content:l.target.value}),className:"font-mono text-sm",placeholder:"Enter JSON-LD markup...",rows:10}),!h&&a.content?e.jsx("p",{className:"pt-px text-xs text-red-500",children:"Invalid JSON-LD"}):e.jsx("p",{})]}),e.jsx(s.TabsContent,{value:"preview",children:e.jsx(s.Textarea,{id:"new-content",value:h||"{}",className:"bg-muted font-mono text-sm",placeholder:"{}",rows:10,readOnly:!0})})]})]}),n&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-blue-900",children:"Apply to All Existing Pages"}),e.jsx("div",{className:"text-xs text-blue-700",children:"This will add this JSON-LD schema to all existing pages on your site a"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{size:"sm",variant:"outline",onClick:()=>{},children:"Apply to all"}),e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>{},children:"Remove to all"})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Switch,{id:"new-enabled",checked:a.enabledByDefaultForNewPages,onCheckedChange:l=>r({...a,enabledByDefaultForNewPages:l})}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(s.Button,{disabled:f,variant:"outline",type:"button",size:"sm",onClick:()=>o(),children:"Cancel"}),e.jsx(s.Button,{disabled:f||!h,type:"button",size:"sm",onClick:b,children:f?e.jsxs(e.Fragment,{children:[e.jsx(m.Loader,{className:"h-4 w-4 animate-spin"})," ",n?"Updating":"Adding"]}):n?"Update Schema":"Add Schema"})]})]})]})]})};exports.default=P;