@chaibuilder/sdk 4.0.0-beta.3 → 4.0.0-beta.6

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 (186) hide show
  1. package/dist/{2SSKDMRQ-BnsZi3K3.cjs → 2SSKDMRQ-BIryEtW-.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-CnSDkQcy.js → 2SSKDMRQ-trME0kvt.js} +2 -2
  3. package/dist/{AP7HFJJL-B31839PG.cjs → AP7HFJJL-5ZR38Hyh.cjs} +1 -1
  4. package/dist/{AP7HFJJL-CymCmW14.js → AP7HFJJL-CAGB9iMp.js} +1 -1
  5. package/dist/IconPicker-CQ-BgNNU.cjs +1 -0
  6. package/dist/{IconPicker-B1rWC-Ex.js → IconPicker-Mu75ni5T.js} +8 -7
  7. package/dist/{WDYDFRGG-BUVnbAci.js → WDYDFRGG-Cd4hRWj-.js} +2 -2
  8. package/dist/{WDYDFRGG-BxhOCHc3.cjs → WDYDFRGG-n8sBZVFG.cjs} +1 -1
  9. package/dist/{actions-registery-YnFmU21O.cjs → actions-registery-JdxhXhT6.cjs} +1 -1
  10. package/dist/{actions-registery-CZ1w0NKa.js → actions-registery-y_ENc8zj.js} +2 -2
  11. package/dist/actions.cjs +1 -1
  12. package/dist/actions.js +2 -2
  13. package/dist/active-in-another-tab-CZLV-uAW.cjs +1 -0
  14. package/dist/active-in-another-tab-Cb6tnX9u.js +35 -0
  15. package/dist/{add-new-language-page-WmlCnytQ.js → add-new-language-page-BKcBaqZu.js} +54 -53
  16. package/dist/add-new-language-page-C3UzNV7W.cjs +1 -0
  17. package/dist/{add-new-page-soZ8GAkN.cjs → add-new-page-mULv9r3z.cjs} +1 -1
  18. package/dist/{add-new-page-VW2wAYZp.js → add-new-page-pH3PwqJe.js} +2 -2
  19. package/dist/ai-panel-content-BPgRdgye.cjs +1 -0
  20. package/dist/{ai-panel-content-D_o7Q_A-.js → ai-panel-content-CNxN84pv.js} +12 -11
  21. package/dist/{ai-panel-default-lang-DnElspF0.js → ai-panel-default-lang-CYcHjk8U.js} +40 -40
  22. package/dist/{ai-panel-default-lang-COYaxNwn.cjs → ai-panel-default-lang-DhTPtPgD.cjs} +2 -2
  23. package/dist/{ai-panel-other-lang-CkynNlAU.cjs → ai-panel-other-lang-CGNU3-FI.cjs} +1 -1
  24. package/dist/{ai-panel-other-lang-Dp0E9_Hx.js → ai-panel-other-lang-D8Ofvj8F.js} +8 -8
  25. package/dist/ai-prompt-input-CUutJjlf.cjs +1 -0
  26. package/dist/{ai-prompt-input-Bhc0ds7X.js → ai-prompt-input-Ceuy5bs3.js} +68 -67
  27. package/dist/{ai-translation-prompt-CZ55HQmo.js → ai-translation-prompt-BiepZRcN.js} +2 -2
  28. package/dist/ai-translation-prompt-CoCPLEed.cjs +1 -0
  29. package/dist/{apply-binding-6iwlED02.js → apply-binding-BvWfJCSZ.js} +204 -196
  30. package/dist/apply-binding-IsUf6UWJ.cjs +1 -0
  31. package/dist/{code-display-DhD_RBcg.js → code-display-Ck81Id9K.js} +1 -1
  32. package/dist/code-display-DloSPyPr.cjs +1 -0
  33. package/dist/code-editor-C1ewJzDJ.cjs +1 -0
  34. package/dist/{code-editor-DRIAnNbb.js → code-editor-Z14ByBIv.js} +11 -10
  35. package/dist/{continue-editing-in-this-client-CS2aQ7yY.js → continue-editing-in-this-client-Byi6ER3L.js} +10 -9
  36. package/dist/continue-editing-in-this-client-k9Ab5E63.cjs +1 -0
  37. package/dist/core-Dr7QYemB.js +56 -0
  38. package/dist/core-Y0lXLwkq.cjs +1 -0
  39. package/dist/core.cjs +1 -1
  40. package/dist/core.d.ts +3 -3
  41. package/dist/core.js +32 -31
  42. package/dist/css-import-modal--bSJR-_y.cjs +13 -0
  43. package/dist/{css-import-modal-Byg6wV0O.js → css-import-modal-De7Kvg5C.js} +4 -3
  44. package/dist/{delete-design-token-BRZZiWtQ.js → delete-design-token-B97CnFDU.js} +1 -1
  45. package/dist/{delete-design-token-DkVs1oBf.cjs → delete-design-token-C6s-ESB_.cjs} +1 -1
  46. package/dist/delete-page-Djn97HiP.cjs +1 -0
  47. package/dist/{delete-page-BzyX9TN-.js → delete-page-Dnf97ZHP.js} +11 -10
  48. package/dist/{design-token-usage-xQs6SlaJ.js → design-token-usage-B-SykAjD.js} +14 -13
  49. package/dist/design-token-usage-OTd93kS8.cjs +1 -0
  50. package/dist/digital-asset-manager-DHYRXaaq.cjs +1 -0
  51. package/dist/{digital-asset-manager-DbtwzxRz.js → digital-asset-manager-b8gDuLnI.js} +6 -5
  52. package/dist/{duplicate-page-BR7Dlo9d.js → duplicate-page-Bdtpl7_R.js} +19 -18
  53. package/dist/duplicate-page-C4Ovp8Ff.cjs +1 -0
  54. package/dist/dynamic-page-selector-B8DdnfrF.cjs +1 -0
  55. package/dist/{dynamic-page-selector-Cb5r_W8s.js → dynamic-page-selector-BVnIM1Rq.js} +15 -14
  56. package/dist/get-chai-builder-tailwind-config-DNp8Vhme.cjs +1 -0
  57. package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +5 -5
  58. package/dist/{get-chai-builder-theme-Dl72X7cz.cjs → get-chai-builder-theme-BApShjRz.cjs} +1 -1
  59. package/dist/{get-chai-builder-theme-BYtp20KD.js → get-chai-builder-theme-DDVRJQ6Z.js} +1 -1
  60. package/dist/{image-editor-G-K28aTS.cjs → image-editor-C2zOHeKv.cjs} +1 -1
  61. package/dist/{image-editor-DV8kUKhl.js → image-editor-cckqPmk5.js} +1 -1
  62. package/dist/index-B0e71wJ1.cjs +160 -0
  63. package/dist/{index-ZuacEL1j.js → index-Bn0fFN58.js} +665 -663
  64. package/dist/{index-Ct7ElCGK.js → index-CAhEmHYP.js} +3744 -3920
  65. package/dist/index-DKuwxj1x.cjs +5 -0
  66. package/dist/{json-diff-viewer-D7z4zNvv.cjs → json-diff-viewer-D9DVIBz4.cjs} +3 -3
  67. package/dist/{json-diff-viewer-krslPepD.js → json-diff-viewer-DNizzMnu.js} +5 -4
  68. package/dist/lang-panel-C1dbn163.cjs +1 -0
  69. package/dist/{lang-panel-BwIewMyw.js → lang-panel-DL_BtSRD.js} +15 -14
  70. package/dist/manage-design-tokens-CXjYkarE.cjs +1 -0
  71. package/dist/{manage-design-tokens-Caz_20VK.js → manage-design-tokens-xxMO_RYg.js} +12 -11
  72. package/dist/{mark-as-template-D295ZQtU.js → mark-as-template-Ba2bmVd9.js} +17 -16
  73. package/dist/mark-as-template-DF1KIMr0.cjs +1 -0
  74. package/dist/{nested-path-selector-content-CKYYK-C5.js → nested-path-selector-content-Br1IWhK5.js} +24 -23
  75. package/dist/nested-path-selector-content-Cuk7NB-u.cjs +1 -0
  76. package/dist/{no-language-page-content-BvqRBP6y.js → no-language-page-content-9B2Fm-on.js} +10 -9
  77. package/dist/no-language-page-content-CxTp-LIM.cjs +1 -0
  78. package/dist/{no-language-page-dialog-PjNqTUpl.js → no-language-page-dialog-CPlKMyb8.js} +2 -2
  79. package/dist/{no-language-page-dialog-BcEoqyQB.cjs → no-language-page-dialog-DynACvgV.cjs} +1 -1
  80. package/dist/{page-creator-DiOITEMw.js → page-creator-BtyJz2sx.js} +115 -114
  81. package/dist/page-creator-Cbfv9N0P.cjs +1 -0
  82. package/dist/{page-lock-Bfbs6RgL.js → page-lock-CzsxrmN5.js} +2 -2
  83. package/dist/{page-lock-BdYmCks0.cjs → page-lock-fRos9wRU.cjs} +1 -1
  84. package/dist/{page-locked-dialog-B6MKTRfY.js → page-locked-dialog-D2q9qkPk.js} +18 -15
  85. package/dist/page-locked-dialog-D57d2gvn.cjs +1 -0
  86. package/dist/{page-manager-new-CzX22g2n.js → page-manager-new-D6DVIx2S.js} +30 -29
  87. package/dist/page-manager-new-aE198gKS.cjs +1 -0
  88. package/dist/{page-manager-search-and-filter-CM0UMb6U.js → page-manager-search-and-filter-CuZkQaZg.js} +13 -12
  89. package/dist/page-manager-search-and-filter-DGQEgKzy.cjs +1 -0
  90. package/dist/{page-revisions-content-NH9JK4Ey.js → page-revisions-content-5rbicFbD.js} +34 -31
  91. package/dist/page-revisions-content-CefqOvKX.cjs +1 -0
  92. package/dist/pages.cjs +1 -1
  93. package/dist/pages.d.ts +4 -4
  94. package/dist/pages.js +1 -1
  95. package/dist/{plugin-C6rgJDNQ.cjs → plugin-BGlQf0iy.cjs} +1 -1
  96. package/dist/{plugin-3ZKK6RXm.js → plugin-C-ht41UZ.js} +1 -1
  97. package/dist/publish-pages-content-DBb8M3TG.cjs +1 -0
  98. package/dist/{publish-pages-content-D9aixMN5.js → publish-pages-content-WeGk-YLC.js} +66 -65
  99. package/dist/register-chai-top-bar-BqwKw4uy.cjs +1 -0
  100. package/dist/register-chai-top-bar-ESJHs5s-.js +237 -0
  101. package/dist/render.cjs +2 -2
  102. package/dist/render.d.ts +2 -2
  103. package/dist/render.js +87 -80
  104. package/dist/rte-widget-modal-DBoPRXq-.cjs +1 -0
  105. package/dist/{rte-widget-modal-DOJEXLIf.js → rte-widget-modal-J-_AytmK.js} +15 -14
  106. package/dist/runtime.cjs +1 -1
  107. package/dist/runtime.d.ts +168 -4
  108. package/dist/runtime.js +68 -38
  109. package/dist/save-to-lib-0ysmXVbI.cjs +1 -0
  110. package/dist/{save-to-lib-eiOc_SSN.js → save-to-lib-CQQxoovF.js} +39 -38
  111. package/dist/sdk.css +1 -1
  112. package/dist/selected-block-display-BWupQFoQ.cjs +16 -0
  113. package/dist/{selected-block-display-CBFePS19.js → selected-block-display-CgoXS8Hr.js} +37 -36
  114. package/dist/{seo-panel-C1-iMOR1.js → seo-panel-B798Myp_.js} +12 -11
  115. package/dist/seo-panel-BkFbXIL0.cjs +2 -0
  116. package/dist/{shared-json-ld-B4PxAM_0.js → shared-json-ld-Clg_UEhd.js} +68 -67
  117. package/dist/shared-json-ld-Cn3MCW6I.cjs +1 -0
  118. package/dist/slug-input-BHyD8cxk.cjs +1 -0
  119. package/dist/{slug-input-AwNJs9im.js → slug-input-hX5VaZpj.js} +9 -8
  120. package/dist/supabase-actions.cjs +1 -1
  121. package/dist/supabase-actions.d.ts +1 -1
  122. package/dist/supabase-actions.js +1 -1
  123. package/dist/take-over-request-Dzczo20q.cjs +1 -0
  124. package/dist/{take-over-request-C4FeDtN_.js → take-over-request-s1L5Yofb.js} +17 -16
  125. package/dist/theme-panel-footer-NTNCL0SW.cjs +1 -0
  126. package/dist/{theme-panel-footer-uBQqSJXm.js → theme-panel-footer-sK6bYhEb.js} +11 -10
  127. package/dist/translation-warning-modal-BfM4HGck.cjs +1 -0
  128. package/dist/{translation-warning-modal-B64YqlbI.js → translation-warning-modal-Jadkcver.js} +9 -8
  129. package/dist/unmark-as-template-CqkHI3gR.cjs +1 -0
  130. package/dist/{unmark-as-template-CZ9sQp_P.js → unmark-as-template-D5b775eR.js} +11 -10
  131. package/dist/unpublish-page-BT5bCfs6.cjs +1 -0
  132. package/dist/unpublish-page-DLLLgY43.js +28 -0
  133. package/dist/utils.cjs +1 -1
  134. package/dist/utils.d.ts +3 -0
  135. package/dist/utils.js +2 -2
  136. package/dist/web-blocks.cjs +1 -1
  137. package/dist/web-blocks.js +5 -5
  138. package/dist/{web-preview-Djy6WIyj.js → web-preview-C_yFwxEe.js} +2 -2
  139. package/dist/web-preview-DU1MgppY.cjs +1 -0
  140. package/package.json +4 -2
  141. package/dist/IconPicker-DREyo007.cjs +0 -1
  142. package/dist/active-in-another-tab-B47YjQGN.cjs +0 -1
  143. package/dist/active-in-another-tab-CyjngVA6.js +0 -34
  144. package/dist/add-new-language-page-88xzrUy8.cjs +0 -1
  145. package/dist/ai-panel-content-7zCil042.cjs +0 -1
  146. package/dist/ai-prompt-input-CThbVp0_.cjs +0 -1
  147. package/dist/ai-translation-prompt-C2kJQFDX.cjs +0 -1
  148. package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
  149. package/dist/code-display-BnqzqzoP.cjs +0 -1
  150. package/dist/code-editor-o3___nu2.cjs +0 -1
  151. package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +0 -1
  152. package/dist/core-BoRDjj4h.cjs +0 -1
  153. package/dist/core-yvI6kCyw.js +0 -56
  154. package/dist/css-import-modal-CyqkXWCO.cjs +0 -13
  155. package/dist/delete-page-DxX7PFIE.cjs +0 -1
  156. package/dist/design-token-usage-CAHzEGgJ.cjs +0 -1
  157. package/dist/digital-asset-manager--uO8Agia.cjs +0 -1
  158. package/dist/duplicate-page-CaNAbXwV.cjs +0 -1
  159. package/dist/dynamic-page-selector-Cxk_gjni.cjs +0 -1
  160. package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
  161. package/dist/index-DF5DEvqb.cjs +0 -160
  162. package/dist/index-WQwzsC7A.cjs +0 -5
  163. package/dist/lang-panel-DT96k1xg.cjs +0 -1
  164. package/dist/manage-design-tokens-CrmLe7UT.cjs +0 -1
  165. package/dist/mark-as-template-W3LmpiqN.cjs +0 -1
  166. package/dist/nested-path-selector-content-CoS_d3dc.cjs +0 -1
  167. package/dist/no-language-page-content-DkfeMl90.cjs +0 -1
  168. package/dist/page-creator-C4gc5NSC.cjs +0 -1
  169. package/dist/page-locked-dialog-B1FAtK92.cjs +0 -1
  170. package/dist/page-manager-new-CHDueBDk.cjs +0 -1
  171. package/dist/page-manager-search-and-filter-DkkRIH86.cjs +0 -1
  172. package/dist/page-revisions-content-ChY-4f2V.cjs +0 -1
  173. package/dist/publish-pages-content-x-JuSFJ9.cjs +0 -1
  174. package/dist/rte-widget-modal-BaHIuEjF.cjs +0 -1
  175. package/dist/save-to-lib-Cgpxw8-g.cjs +0 -1
  176. package/dist/selected-block-display-BgRY82CT.cjs +0 -16
  177. package/dist/seo-panel-DfAb8U7W.cjs +0 -2
  178. package/dist/shared-json-ld-DzG398hr.cjs +0 -1
  179. package/dist/slug-input-C_ijLQ_X.cjs +0 -1
  180. package/dist/take-over-request-BNxcjY2j.cjs +0 -1
  181. package/dist/theme-panel-footer-Cq9pljro.cjs +0 -1
  182. package/dist/translation-warning-modal-BZAcwM2_.cjs +0 -1
  183. package/dist/unmark-as-template-EVvk0vmp.cjs +0 -1
  184. package/dist/unpublish-page-D4VwOlxc.js +0 -27
  185. package/dist/unpublish-page-bdSmwAVQ.cjs +0 -1
  186. package/dist/web-preview-Cio70gk5.cjs +0 -1
@@ -0,0 +1,5 @@
1
+ "use strict";var or=Object.create;var bs=Object.defineProperty;var lr=Object.getOwnPropertyDescriptor;var cr=Object.getOwnPropertyNames;var ur=Object.getPrototypeOf,dr=Object.prototype.hasOwnProperty;var Cs=e=>{throw TypeError(e)};var fr=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of cr(t))!dr.call(e,r)&&r!==s&&bs(e,r,{get:()=>t[r],enumerable:!(n=lr(t,r))||n.enumerable});return e};var hr=(e,t,s)=>(s=e!=null?or(ur(e)):{},fr(t||!e||!e.__esModule?bs(s,"default",{value:e,enumerable:!0}):s,e));var Is=(e,t,s)=>t.has(e)||Cs("Cannot "+s);var P=(e,t,s)=>(Is(e,t,"read from private field"),s?s.call(e):t.get(e)),R=(e,t,s)=>t.has(e)?Cs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),D=(e,t,s,n)=>(Is(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);const i=require("react/jsx-runtime"),m=require("./index-B0e71wJ1.cjs"),L=require("./register-chai-top-bar-BqwKw4uy.cjs"),H=require("jotai"),p=require("lodash-es"),h=require("react"),S=require("@tanstack/react-query"),x=require("lucide-react"),he=require("react-i18next"),jt=require("./common-functions-B3a4xKt_.cjs"),F=require("sonner"),Vs=require("./core-Y0lXLwkq.cjs"),gr=require("./apply-binding-IsUf6UWJ.cjs"),mr=require("./web-blocks.cjs"),Er=require("react-error-boundary");function pr(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=pr(h),st=H.atom(null),y={GET_GLOBAL_JSONLD_ITEMS:"GET_GLOBAL_JSONLD_ITEMS",GENERATE_SEO_FIELD:"GENERATE_SEO_FIELD",UPDATE_PAGE_METADATA:"UPDATE_PAGE_METADATA",GET_BLOCK_ASYNC_PROPS:"GET_BLOCK_ASYNC_PROPS",ASK_AI:"ASK_AI",GET_DRAFT_PAGE:"GET_DRAFT_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",DUPLICATE_PAGE:"DUPLICATE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_SETTINGS:"UPDATE_WEBSITE_SETTINGS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_DRAFT_SETTINGS:"GET_WEBSITE_DRAFT_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA",GET_PAGE_REVISIONS:"GET_PAGE_REVISIONS",DELETE_PAGE_REVISION:"DELETE_PAGE_REVISION",RESTORE_PAGE_REVISION:"RESTORE_PAGE_REVISION",GET_REVISION_DATA:"GET_REVISION_DATA",GET_PAGE_DATA:"GET_PAGE_DATA",GET_COMPARE_DATA:"GET_COMPARE_DATA",GET_ROLE_AND_PERMISSIONS:"GET_ROLE_AND_PERMISSIONS",UPSERT_LIBRARY_ITEM:"UPSERT_LIBRARY_ITEM",GET_LIBRARIES:"GET_LIBRARIES",GET_LIBRARY_ITEM:"GET_LIBRARY_ITEM",GET_LIBRARY_ITEMS:"GET_LIBRARY_ITEMS",DELETE_LIBRARY_ITEM:"DELETE_LIBRARY_ITEM",MARK_AS_TEMPLATE:"MARK_AS_TEMPLATE",UNMARK_AS_TEMPLATE:"UNMARK_AS_TEMPLATE",GET_TEMPLATES_BY_TYPE:"GET_TEMPLATES_BY_TYPE",GET_DYNAMIC_PAGES:"GET_DYNAMIC_PAGES",GET_APP_SHARED_JSONLD:"GET_APP_SHARED_JSONLD",UPDATE_APP_SHARED_JSONLD:"UPDATE_APP_SHARED_JSONLD",ADD_GLOBAL_SCHEMA:"ADD_GLOBAL_SCHEMA",UPDATE_GLOBAL_SCHEMA:"UPDATE_GLOBAL_SCHEMA",DELETE_GLOBAL_SCHEMA:"DELETE_GLOBAL_SCHEMA",TOGGLE_PAGE_GLOBAL_SCHEMA:"TOGGLE_PAGE_GLOBAL_SCHEMA",APPLY_SCHEMA_TO_ALL_PAGES:"APPLY_SCHEMA_TO_ALL_PAGES",REMOVE_SCHEMA_FROM_ALL_PAGES:"REMOVE_SCHEMA_FROM_ALL_PAGES",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},yr=H.atom({}),Ft=()=>H.useAtom(yr),ie=(e,t)=>{const[s]=Ft();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},N=()=>ie("apiUrl","/chai/api"),Hs=()=>ie("websocket",null),Tr=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),Ar=()=>{const e=j(),t=N();return h.useCallback(async({body:s,headers:n={},url:r=t,streamResponse:a=!1})=>e(r,s,n,a),[e])},j=()=>{const e=ie("onLogout"),t=ie("getAccessToken"),s=N();return h.useCallback(async(n=s,r,a={},o=!1)=>{const l=await t();try{const c=p.get(r,"action","").toLowerCase(),f=await Tr(n+(c?`?action=${c}`:""),r,{...a,Authorization:`Bearer ${l}`});if(o)return f;if(f.status===401)return console.log("401 Response",f),e(),window.location.reload(),null;if(!f.ok){const d=await f.json();throw console.error(`API Error (${f.status}):`,d),{status:f.status,statusText:f.statusText,...d,message:d.error||d.message||`Server error: ${f.status}`}}return await f.json()}catch(c){throw console.error("API request failed:",r,c),c}},[e,t])};function le(){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 Ae=e=>{const t=N(),[s]=le(),n=e??s.get("page"),r=j();return S.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,n],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!n)return null;const a=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:n}});return p.reverse(p.sortBy(a,"primaryPage"))},enabled:!!n})},Sr=H.atom(null),Qs=()=>H.useAtom(Sr),ls=()=>{const[e]=Qs();return(e==null?void 0:e.slug)||""};function Pr(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const xr=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=m.useLanguages(),{data:r}=te(),a=r==null?void 0:r.pageType,o=N(),l=j(),{data:c,isFetching:f}=S.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:3600*1e3,placeholderData:[],queryFn:async()=>await l(o,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),d=h.useMemo(()=>s===""?c.filter(u=>u.lang===""||u.lang===n):c.filter(u=>u.lang===s),[s,n,c]);return{allLangPages:c,data:d,isFetching:f}},zs=()=>{const{selectedLang:e,fallbackLang:t}=m.useLanguages(),[s,n]=Qs(),[r,a]=h.useState(""),o=Pr(r,500),{allLangPages:l,data:c,isFetching:f}=xr({query:o}),d=h.useCallback(g=>n(g),[n]),u=h.useCallback(g=>a(g),[a]),E=h.useCallback(()=>{if(!s)return;const g=!(s!=null&&s.primaryPage),T=e.length===0,_=g?s==null?void 0:s.id:s==null?void 0:s.primaryPage,M=l.filter(A=>(A==null?void 0:A.primaryPage)===_||A.id===_).find(A=>T?A.lang===e||A.lang===t:A.lang===e);n(M||s)},[s,e,l,n,t]);return{isFetching:f,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:d,updateSearchQuery:u,onChangeLanguage:E}},_r=H.atom({lastSaved:void 0}),cs=()=>H.useAtom(_r),te=()=>{const[e]=le(),t=e.get("page"),{data:s,isFetching:n}=Ae();return{data:h.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},ge=()=>{const[e]=le(),t=e.get("lang")??"",{data:s,isFetching:n}=Ae();return{data:h.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},wr=H.atom({}),vr=()=>H.useAtom(wr),br=()=>{const{data:e}=ge(),t=ls(),s=ie("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},se={...m.PERMISSIONS,ADD_PAGE:"add_page",EDIT_PAGE:"edit_page",DELETE_PAGE:"delete_page",CHANGE_PAGE_TYPE:"change_page_type",PUBLISH_PAGE:"publish_page",UNPUBLISH_PAGE:"unpublish_page",MARK_AS_TEMPLATE:"mark_as_template",EDIT_SEO:"edit_seo",RESTORE_REVISION:"restore_revision",DELETE_REVISION:"delete_revision",DELETE_LIBRARY_BLOCK:"delete_library_block"},me=()=>{const e=N(),t=j();return S.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},$s=e=>{const{data:t}=me();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},Cr=()=>{const e=N(),t=j();return S.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),[]}}})},Ws=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:o,children:l,isLanguagePage:c})=>{const{t:f}=he.useTranslation(),{hasPermission:d}=m.usePermissions(),{data:u}=me(),E=h.useMemo(()=>p.find(u,{key:e.pageType}),[u,e.pageType]),g=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),T=h.useMemo(()=>!!(E!=null&&E.hasSlug),[E==null?void 0:E.hasSlug]);return!d(se.EDIT_PAGE)&&!d(se.DELETE_PAGE)&&!d(se.UNPUBLISH_PAGE)||!e?null:i.jsxs(m.DropdownMenu,{children:[i.jsx(m.DropdownMenuTrigger,{asChild:!0,onClick:w=>w.stopPropagation(),children:l}),i.jsxs(m.DropdownMenuContent,{align:"center",className:"text-sm",children:[d(se.ADD_PAGE)&&!c&&i.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),t(e)},children:[i.jsx(x.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),d(se.EDIT_PAGE)&&i.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),s({...e,global:!(E!=null&&E.hasSlug)})},children:[i.jsx(x.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&d(se.UNPUBLISH_PAGE)&&i.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),n(e)},children:[i.jsx(x.Power,{className:"size-3"}),f("Unpublish")]}),d(se.DELETE_PAGE)&&i.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),r(e)},children:[i.jsx(x.Trash,{className:"size-3"}),f("Delete")]}),d(se.MARK_AS_TEMPLATE)&&T&&!c&&i.jsx(i.Fragment,{children:g?i.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),o(e)},children:[i.jsx(x.SquareLibrary,{className:"size-3"}),f("Unmark as template")]}):i.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),a(e)},children:[i.jsx(x.SquareLibrary,{className:"size-3"}),f("Mark as template")]})})]})]})},Se=()=>{const e=N(),t=j();return S.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:300*1e3,placeholderData:{languages:[],theme:{fontFamily:"",borderRadius:"",colors:{}},appKey:"",fallbackLang:"",designTokens:{}},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},qt=()=>{const e=ie("currentUser"),t=ie("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},J={LOCKED:"LOCKED",EDITING:"EDITING",CHECKING:"CHECKING",TAKE_OVER_REQUESTED:"TAKE_OVER_REQUESTED",ACTIVE_IN_ANOTHER_TAB:"ACTIVE_IN_ANOTHER_TAB",FORCE_TAKE_OVER:"FORCE_TAKE_OVER",CONNECTION_LOST:"CONNECTION_LOST"},X={FORCE_TAKE_OVER:"FORCE_TAKE_OVER",TAKE_OVER_REQUEST:"TAKE_OVER_REQUEST",TAKE_OVER_APPROVED:"TAKE_OVER_APPROVED",TAKE_OVER_REJECTED:"TAKE_OVER_REJECTED",FORCE_TAKE_OVER_REQUEST:"FORCE_TAKE_OVER_REQUEST",CONTINUE_EDITING_IN_THIS_CLIENT:"CONTINUE_EDITING_IN_THIS_CLIENT",CONTINUE_EDITING_IN_THIS_TAB_REQUEST:"CONTINUE_EDITING_IN_THIS_TAB_REQUEST"},Ir=["sync","join","leave"],Lr=[X.FORCE_TAKE_OVER,X.TAKE_OVER_REQUEST,X.TAKE_OVER_APPROVED,X.TAKE_OVER_REJECTED,X.FORCE_TAKE_OVER_REQUEST,X.CONTINUE_EDITING_IN_THIS_CLIENT,X.CONTINUE_EDITING_IN_THIS_TAB_REQUEST],Nr=H.atom({}),Ys=H.atom(null),jr=H.atom(J.CHECKING),Gr=H.atom({}),kr=e=>{const t={},s=p.groupBy(p.values(e).map(p.first).filter(Boolean),"pageId");return Object.entries(s).forEach(([n,r])=>t[n]=p.minBy(r,"onlineAt")),t},Dr=e=>{const t=p.minBy(p.values(e).map(p.first).filter(Boolean),"onlineAt"),s=t==null?void 0:t.onlineAt;return s?s-100:+new Date-1e3*60*60*4},At=()=>{const{user:e}=qt();return e==null?void 0:e.id},Or=()=>{const{data:e}=Se();return`WEBSITE:${e==null?void 0:e.appKey}`},St=()=>{const{data:e}=te();return e==null?void 0:e.id},we=crypto.randomUUID();let $t=null;const us=()=>{const[e,t]=H.useAtom(Nr);return{pageToUser:e,setPageToUser:t}},ne=()=>{const[e,t]=H.useAtom(jr),s=[J.LOCKED,J.ACTIVE_IN_ANOTHER_TAB].includes(e),n=[J.EDITING].includes(e);return{pageStatus:e,setPageStatus:t,isLocked:s,isEditing:n}},ds=()=>{const[e,t]=H.useAtom(Gr);return{pageLockMeta:e,setPageLockMeta:t}},Js=()=>{const e=St(),{pageToUser:t}=us();return h.useMemo(()=>t[e],[t,e])},fs=()=>{const e=Hs(),{setPageStatus:t}=ne(),[s]=H.useAtom(Ys);return h.useEffect(()=>{if(clearTimeout($t),!e)return $t=setTimeout(()=>{e||t(J.EDITING)},500),()=>clearTimeout($t)},[e,t]),s},Rr=()=>{const e=St(),t=At(),s=fs(),{setPageToUser:n}=us(),{setPageStatus:r,pageStatus:a}=ne(),o=h.useRef(e);return o.current=e,h.useCallback(l=>{const c=l||s;if(!c)return[];const f=c==null?void 0:c.presenceState(),d=kr(f);n(d);const u=d[o.current];if(!u)r(J.CHECKING);else if(!t)r(J.CHECKING);else if(u.userId===t&&u.clientId===we){if(a===J.TAKE_OVER_REQUESTED)return;r(J.EDITING)}else u.userId===t&&u.clientId!==we?r(J.ACTIVE_IN_ANOTHER_TAB):r(J.LOCKED)},[s,n,r,t,a])},Zs=()=>{const e=At(),t=St(),s=fs(),n=Js(),{setPageLockMeta:r}=ds(),a=h.useRef(t);return a.current=t,h.useCallback(async(o,l)=>{if(!s)return;const c=l||{};c.userId=e,c.pageId=a.current,c.senderClientId=we,c.receiverClientId=(l==null?void 0:l.requestingClientId)||(n==null?void 0:n.clientId),await s.send({event:o,payload:c,type:"broadcast"}),r({})},[s,e,n,r])},Mr=()=>{const e=At(),t=St(),s=fs(),{setPageStatus:n}=ne(),{setPageLockMeta:r}=ds(),a=Zs(),o=h.useRef(t),{savePageAsync:l}=m.useSavePage();return o.current=t,h.useCallback(c=>async({payload:f})=>{const d=f||{};if(!(!(d!=null&&d.pageId)||(d==null?void 0:d.pageId)!==o.current||(d==null?void 0:d.receiverClientId)!==we))switch(r({}),c){case X.FORCE_TAKE_OVER_REQUEST:case X.CONTINUE_EDITING_IN_THIS_TAB_REQUEST:{try{await l(!0)}catch(u){console.error("Failed to save page before releasing lock:",u)}await a(X.CONTINUE_EDITING_IN_THIS_CLIENT,{requestingClientId:d==null?void 0:d.senderClientId}),setTimeout(()=>r({type:c}),0);break}case X.TAKE_OVER_REQUEST:{r({requestingUserId:d==null?void 0:d.userId,requestingClientId:d==null?void 0:d.senderClientId}),n(J.TAKE_OVER_REQUESTED);break}case X.CONTINUE_EDITING_IN_THIS_CLIENT:{const u=Dr(s==null?void 0:s.presenceState());n(J.CHECKING),await(s==null?void 0:s.track({onlineAt:u,pageId:o.current,userId:e,clientId:we}));break}case X.TAKE_OVER_REJECTED:{r({type:X.TAKE_OVER_REJECTED});break}}},[a,r,n,s,e,l])},Ur=()=>{const e=Hs(),t=At(),s=St(),n=Or(),[r,a]=H.useAtom(Ys),o=Mr(),l=Rr(),c=h.useRef(o),f=h.useRef(l);h.useEffect(()=>{c.current=o,f.current=l},[o,l]),h.useEffect(()=>{if(!e||!t||!n||r&&r.topic===n)return;const d=e.channel(n,{config:{presence:{key:we}}});return Lr.forEach(u=>{d.on("broadcast",{event:u},E=>{c.current(u)(E)})}),Ir.forEach(u=>{d.on("presence",{event:u},()=>{f.current(d)})}),d.subscribe(async u=>{u==="SUBSCRIBED"?a(d):(u==="CHANNEL_ERROR"||u==="TIMED_OUT")&&console.log("Realtime connection failed",u)}),()=>{d.unsubscribe()}},[e,t,n,a]),h.useEffect(()=>(r&&s&&t&&r.track({pageId:s,userId:t,clientId:we,onlineAt:+new Date}),()=>{r&&s&&r.untrack()}),[r,s,t])},Kt=()=>{const{data:e}=Se();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},hs=()=>{const e=j(),t=N();return S.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},Br=e=>{const t=j(),s=N(),n=Kt();return S.useQuery({queryKey:[y.GET_WEBSITE_PAGES,e,n],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(n===e)return{};const r=await t(s,{action:y.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})};function gs(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 Fr=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-aE198gKS.cjs"))),Xs=({children:e})=>{const{t}=he.useTranslation(),[s,n]=le(),r=s.get("page"),{data:a,isFetching:o}=te(),{data:l,isFetching:c}=hs(),[f,d]=h.useState(!1),[u,E]=h.useState(!0),{savePage:g}=m.useSavePage(),T=!!r&&!p.isEmpty(a),{isLocked:_}=ne(),w=h.useMemo(()=>{if(!l||c)return!1;const I=l.find(q=>q.slug==="/");return I==null?void 0:I.id},[l,c]);h.useEffect(()=>{if(c||!w||l.some(G=>G.id===r))return;const q=new URLSearchParams({page:w});gs(q,n),!c&&l&&E(!1)},[r,c,l,w,n]);const M=!u&&!r,A=!u&&!o&&p.isEmpty(a),C=f||M||A;return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex items-center gap-x-1",children:i.jsx("div",{className:"relative",children:i.jsxs(m.Tooltip,{children:[i.jsx(m.TooltipTrigger,{asChild:!0,onClick:()=>{_||g(),d(!0)},children:e||i.jsx(L.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:i.jsx(x.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),i.jsx(m.TooltipContent,{side:"right",children:i.jsx("p",{children:t("Open pages manager")})})]})})}),i.jsx(m.Sheet,{open:C,onOpenChange:I=>!I&&T&&d(!1),children:i.jsxs(m.SheetContent,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[50vh] !max-w-[800px] border-border p-0 ${T?"":"sheet-hide-close-btn"}`,children:[i.jsxs(m.SheetHeader,{className:"mb-3 px-4 pt-4",children:[i.jsxs(m.SheetTitle,{className:"flex items-center gap-2 text-sm font-semibold",children:[i.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:i.jsx(x.Folder,{className:"h-4 w-4"})}),i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"text-sm font-semibold",children:t("Pages")}),i.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:t("Manage your site structure")})]})]}),i.jsx(m.SheetDescription,{className:"sr-only",children:t("Manage your site structure")})]}),i.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:C&&i.jsx(h.Suspense,{children:i.jsx(Fr,{close:()=>d(!1)})})})]})})]})},qr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-mULv9r3z.cjs"))),Kr=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-Djn97HiP.cjs"))),Vr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-C4Ovp8Ff.cjs"))),Hr=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DF1KIMr0.cjs"))),Qr=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-CqkHI3gR.cjs"))),zr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BT5bCfs6.cjs"))),$r=()=>{const[e,t]=h.useState(null),[s,n]=h.useState(null),[r,a]=h.useState(null),[o,l]=h.useState(null),[c,f]=h.useState(null),[d,u]=h.useState(null),{data:E,isFetching:g}=ge(),{selectedLang:T,fallbackLang:_}=m.useLanguages(),{data:w}=Ae(),M=w==null?void 0:w.find(G=>G.lang===T),{isLocked:A}=ne(),C=!(E!=null&&E.slug),I=H.useSetAtom(st);if(!E)return null;const q=G=>{T.length>0&&T!==_?I({edit:!0,id:G==null?void 0:G.id,primaryPage:G==null?void 0:G.primaryPage}):u(G)};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between rounded px-[2px] transition-colors duration-200",children:[i.jsx(Xs,{children:i.jsx(L.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:g?i.jsx(x.Loader,{className:"h-4 w-4 animate-spin text-slate-400"}):i.jsxs("span",{className:"flex w-full cursor-pointer items-end overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-xs font-medium",children:[C?i.jsx(x.Hash,{className:"mr-1 h-4 w-4"}):i.jsx(x.File,{className:"mr-1 h-4 w-4"}),p.get(M||E,"name")??""]})})}),A?i.jsx(L.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:i.jsx(x.MoreHorizontal,{className:"h-4 w-4"})}):i.jsx(Ws,{page:E,setDuplicatePage:G=>f(G),setAddEditPage:G=>q(G),setUnpublishPage:G=>n(G),setDeletePage:G=>t(G),setMarkAsTemplate:G=>a(G),setUnmarkAsTemplate:G=>l(G),isLanguagePage:T.length>0&&T!==_,children:i.jsx(L.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:i.jsx(x.MoreHorizontal,{className:"h-4 w-4"})})})]}),d&&i.jsx(h.Suspense,{children:i.jsx(qr,{closePanel:()=>u(null),editPage:()=>{},addEditPage:d,setAddEditPage:u})}),e&&i.jsx(h.Suspense,{children:i.jsx(Kr,{page:e,onClose:()=>t(null)})}),s&&i.jsx(h.Suspense,{children:i.jsx(zr,{page:s,onClose:()=>n(null)})}),r&&i.jsx(h.Suspense,{children:i.jsx(Hr,{page:r,onClose:()=>a(null)})}),o&&i.jsx(h.Suspense,{children:i.jsx(Qr,{page:o,onClose:()=>l(null)})}),c&&i.jsx(h.Suspense,{children:i.jsx(Vr,{page:c,onClose:()=>f(null),closePanel:()=>u(null)})})]})},ms=({children:e,className:t=""})=>i.jsx("div",{className:jt.cn("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}),Wr=({hasDynamicPage:e})=>i.jsx(ms,{children:i.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:[i.jsx("h1",{className:"text-lg font-medium",children:e?"Select a page":"No pages found"}),i.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"})]})}),Ye={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"},Yr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-C3UzNV7W.cjs"))),Jr=()=>{const e=ie("topLeftCorner",null);return e?i.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},en=({showAdd:e=!0,variant:t="ghost",goToDefaultLang:s=!1})=>{const{fallbackLang:n,languages:r,selectedLang:a,setSelectedLang:o}=m.useLanguages(),l=p.isEmpty(a)?n:a,[,c]=le(),{isLocked:f}=ne(),{t:d}=he.useTranslation();h.useEffect(()=>{const A=new URLSearchParams(window.location.search),C=A.get("lang");C&&(r.includes(C)?o(C):(A.delete("lang"),c(A),o("")))},[r,c,o]);const u=H.useSetAtom(st),{data:E}=te(),{data:g}=Se(),{data:T}=Ae(),_=h.useMemo(()=>{const A=p.compact(p.map(p.get(g,"languages"),C=>{const I=p.find(T,{lang:C});return{key:C,value:p.get(Ye,C,C),isLangPageAdded:!!I}})).filter(Boolean);return[{key:n,value:p.get(Ye,n),isLangPageAdded:!0},...A]},[n,T,g]),w=A=>{if(document.querySelector('[data-panel-id="seo"]')){const I=new CustomEvent("seo-language-switch-check",{detail:{fromLang:l,toLang:A,switchHandler:()=>M(A)}});window.dispatchEvent(I);return}M(A)},M=A=>{o(A);const C=new URLSearchParams(window.location.search);A===n?C.delete("lang"):C.set("lang",A),gs(C,c)};return p.isEmpty(r)?null:f?i.jsxs(L.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[i.jsx(x.Languages,{className:"h-4 w-4"}),p.get(Ye,l,l),i.jsx(x.ChevronDown,{className:"h-4 w-4"})]}):s?i.jsx(L.Button,{onClick:()=>M(n),variant:"link",size:"sm",children:d("Switch to default language")}):i.jsx(i.Fragment,{children:i.jsxs(m.DropdownMenu,{children:[i.jsx(m.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:i.jsxs(L.Button,{disabled:!!f,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[i.jsx(x.Languages,{className:"h-4 w-4"}),p.get(Ye,l,l),i.jsx(x.ChevronDown,{className:"h-4 w-4"})]})}),i.jsxs(m.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(_.filter(A=>A.isLangPageAdded),A=>i.jsxs(m.DropdownMenuItem,{className:jt.cn("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",A.key===l&&"!bg-gray-200 text-gray-700"),onClick:()=>w(A.key),children:[i.jsx("div",{className:"text-slate-600",children:A.value}),A.key===n&&i.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[i.jsx(x.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},A.value)),e&&!p.isEmpty(_.filter(A=>!A.isLangPageAdded))&&i.jsxs(i.Fragment,{children:[i.jsx(m.Separator,{}),i.jsxs(L.Button,{size:"sm",variant:"ghost",onClick:()=>{E&&u({edit:!1,primaryPage:E.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[i.jsx(x.Plus,{className:"mr-1 h-3 w-3"})," Add Language"]})]})]})]})})};function Zr(){const e=H.useAtomValue(st),t=H.useSetAtom(st);return i.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[i.jsx(Jr,{}),i.jsx(Xs,{}),e&&i.jsx(h.Suspense,{children:i.jsx(Yr,{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 Xr(){return i.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>i.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsx(m.Skeleton,{className:"h-4 w-3/4"}),i.jsx(m.Skeleton,{className:"h-3 w-1/2"}),i.jsx(m.Skeleton,{className:"mt-1 h-5 w-20"})]}),i.jsx(m.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const ea=Q.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-CefqOvKX.cjs")));function ta(){const[e,t]=Q.useState(!1);return i.jsx(m.TooltipProvider,{children:i.jsxs(m.Tooltip,{delayDuration:0,children:[i.jsxs(m.Sheet,{open:e,onOpenChange:t,children:[i.jsx(m.SheetTrigger,{asChild:!0,children:i.jsx(m.TooltipTrigger,{asChild:!0,children:i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsxs(L.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[i.jsx(x.History,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"View revision history"})]}),i.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})})}),i.jsx(m.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&i.jsx(h.Suspense,{fallback:i.jsx(Xr,{}),children:i.jsx(ea,{isOpen:e})})})]}),i.jsx(m.TooltipContent,{side:"bottom",children:i.jsx("p",{children:"Revision history"})})]})})}const Ct=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=m.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},sa={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},na=()=>{const e=N(),t=S.useQueryClient(),s=j(),{data:n}=me();return S.useMutation({mutationFn:async r=>await s(e,{action:y.CREATE_PAGE,data:r}),onSuccess:(r,a)=>{var l;a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const o=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+((l=p.find(n,{key:a.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";F.toast.success(o)},onError:(r,a)=>{const o=p.find(n,{key:a.pageType});F.toast.error(`Failed to add new ${o!=null&&o.hasSlug?"page":o.name}.`,{description:p.get(sa,r.message,r.message)})}})},ra=()=>{const e=N(),t=S.useQueryClient(),s=j(),{data:n}=ge(),{data:r}=me();return S.useMutation({mutationFn:async a=>await s(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,o)=>{(n==null?void 0:n.id)===(o==null?void 0:o.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),o&&(o!=null&&o.primaryPage||o!=null&&o.seo)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,o==null?void 0:o.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(a,o)=>{const l=p.find(r,{key:o.pageType});F.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},aa=()=>{const e=N(),t=S.useQueryClient(),s=j(),{data:n}=me();return S.useMutation({mutationFn:async r=>s(e,{action:y.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{if(r.code==="PAGE_LOCKED"){F.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(r,a)=>{const o=p.find(n,{key:a.pageType});F.toast.error(`Failed to delete ${o!=null&&o.hasSlug?"page":o.name}.`,{description:r.message})}})},ia=()=>{const e=N(),t=S.useQueryClient(),s=j(),{data:n}=me();return S.useMutation({mutationFn:async r=>s(e,{action:y.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const o=p.find(n,{key:a.pageType});F.toast.success(o!=null&&o.hasSlug?"Page unpublished successfully.":"New "+o.name+" added successfully.")},onError:(r,a)=>{const o=p.find(n,{key:a.pageType});F.toast.error(`Failed to take offline ${o!=null&&o.hasSlug?"page":o.name}.`,{description:r.message})}})},Es=()=>{const e=N(),t=j(),s=S.useQueryClient(),{data:n}=te(),{savePageAsync:r}=m.useSavePage();return S.useMutation({mutationFn:async({ids:a})=>(await r(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:a}})),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_CHANGES]}),s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,n==null?void 0:n.id]})},onError:a=>{console.log("##",a),F.toast.error("Failed to publish pages.")}})},oa=()=>{const e=N(),t=j(),s=S.useQueryClient();return S.useMutation({mutationFn:async n=>{var r;return t(e,{action:y.MARK_AS_TEMPLATE,data:{id:(r=n.page)==null?void 0:r.id,name:n.name,description:n.description,pageType:n.pageType,previewImage:n.previewImage}})},onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page marked as template successfully.")},onError:()=>{F.toast.error("Failed to mark page as template.")}})},la=()=>{const e=N(),t=j(),s=S.useQueryClient();return S.useMutation({mutationFn:async n=>t(e,{action:y.UNMARK_AS_TEMPLATE,data:{id:n==null?void 0:n.id}}),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page unmarked as template successfully.")},onError:()=>{F.toast.error("Failed to unmark page as template.")}})},ca=()=>{const e=N(),t=j(),s=S.useQueryClient();return S.useMutation({mutationFn:async({id:n,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:n,slug:r}}),onSuccess:(n,{primaryPage:r})=>{F.toast.success("Slug changed successfully."),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{F.toast.error("Failed to change slug")}})},ua=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-DBb8M3TG.cjs")));function da({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=Es();return i.jsx(m.Dialog,{open:e,onOpenChange:n?()=>{}:t,children:e&&i.jsx(h.Suspense,{fallback:i.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:i.jsx(ua,{onClose:t,isPending:n,publishPage:s})})})}const tn=e=>{const{fallbackLang:t}=m.useLanguages(),{data:s}=Se(),{data:n,isFetching:r}=Ae(),a=h.useMemo(()=>{const o={[t]:!0};return p.each(p.get(s,"languages"),l=>{const c=p.find(n,{lang:l});o[l]=!!c}),o},[t,n,s]);return r||p.isEmpty(e)||e&&a[e]},fa={particleCount:350,spread:120,origin:{y:.6},angle:90},ha={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},ga=async()=>{const{default:e}=await import("canvas-confetti");return e},It=e=>{let t=ha[e];t||(t={});const s={...fa,...t};ga().then(n=>n(s))};function Vt({children:e,content:t,side:s="bottom",delayDuration:n=700,showTooltip:r=!0}){return r?i.jsx(m.TooltipProvider,{children:i.jsxs(m.Tooltip,{delayDuration:n,children:[i.jsx(m.TooltipTrigger,{asChild:!0,children:e}),i.jsx(m.TooltipContent,{side:s,sideOffset:10,children:i.jsx("p",{children:t})})]})}):e}const ma=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BT5bCfs6.cjs"))),Ea=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-BfM4HGck.cjs"))),pa=()=>{const{t:e}=he.useTranslation(),{selectedLang:t,fallbackLang:s}=m.useLanguages(),n=ie("getPreviewUrl",async E=>E),[r,a]=h.useState(""),{data:o}=te(),{data:l}=Ae(),{data:c}=me(),f=h.useMemo(()=>{var E;return(E=l==null?void 0:l.find(g=>(g==null?void 0:g.lang)===t))==null?void 0:E.slug},[t,l]),d=h.useCallback(E=>{var g;return(g=p.find(c,{key:E}))==null?void 0:g.hasSlug},[c]),u=t===s?"":t;return h.useEffect(()=>{(async()=>{if(typeof n=="function"){const E=!d(o==null?void 0:o.pageType),g=await n(E?`${u!==""?u+"/":""}${o==null?void 0:o.id}`:f||"");a(g)}else a("")})()},[n,f,o==null?void 0:o.pageType,d,o==null?void 0:o.id,u]),i.jsx(i.Fragment,{children:i.jsx(Vt,{content:e("Open preview in new tab"),delayDuration:0,children:i.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:i.jsx(L.Button,{variant:"ghost",size:"sm",className:"gap-2",children:i.jsx(x.Play,{className:"h-4 w-4"})})})})})},ya=()=>{const{t:e}=he.useTranslation(),[t,s]=m.useRightPanel();return i.jsxs(i.Fragment,{children:[i.jsx(Vt,{content:e("Theme"),delayDuration:0,children:i.jsx(L.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>s(t==="theme"?"block":"theme"),children:i.jsx(x.Palette,{className:"h-4 w-4"})})}),i.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},Ta=()=>{const{t:e}=he.useTranslation(),[t,s]=h.useState(!1),{isLocked:n}=ne(),{savePageAsync:r,saveState:a}=m.useSavePage();h.useEffect(()=>{const d=u=>{a==="UNSAVED"&&(u.preventDefault(),u.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",d),()=>{window.removeEventListener("beforeunload",d)}},[a]);const o=h.useCallback(async()=>{t||(s(!0),await r(),s(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:f}=h.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:i.jsx(x.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:i.jsx(x.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:i.jsx(x.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return n?null:i.jsxs(L.Button,{size:"sm",variant:"ghost",onClick:o,className:`${c} w-24 max-w-24`,children:[l," ",f]})},Aa=()=>{const{t:e}=he.useTranslation(),{selectedLang:t}=m.useLanguages(),{data:s}=ge(),{data:n}=Ae(),[r,a]=h.useState(!1),[o,l]=h.useState(!1),[c,f]=h.useState(null),{savePageAsync:d}=m.useSavePage(),[u,E]=h.useState(!1),{data:g}=te(),{mutate:T,isPending:_}=Es(),{needTranslations:w}=m.useSavePage(),M=w(),{buttonText:A,buttonClassName:C,isPublished:I}=h.useMemo(()=>{const b=g&&(g==null?void 0:g.online);return{buttonClassName:b?"hover:bg-green-600 bg-green-500":"",isPublished:b,buttonText:e(b?"Published":"Publish")}},[g,e]),q=async()=>{if(M){E(!0);return}G()},G=()=>{const b=[s==null?void 0:s.id,s==null?void 0:s.primaryPage];T({ids:p.compact(b)},{onSuccess:()=>It("TOP_RIGHT")})},ce=()=>{E(!1),G()},ue=async()=>{E(!1),await d()},V=h.useMemo(()=>p.map(n??[],"id"),[n]);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex",children:[i.jsxs(L.Button,{size:"sm",onClick:q,disabled:_||!(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 ${C}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[i.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${o?"-translate-y-10":""}`,children:I?i.jsx(x.Send,{className:"h-4 w-4"}):i.jsx(x.Rocket,{className:"h-4 w-4"})}),i.jsx("span",{className:`absolute inset-0 left-3 flex items-center transition-transform duration-300 ease-in-out ${o?"":"translate-y-10"}`,children:I?i.jsx(x.Rocket,{className:"h-4 w-4"}):i.jsx(x.Send,{className:"h-4 w-4"})}),i.jsx("span",{children:A}),t?`(${p.upperCase(t)})`:""]}),i.jsxs(m.DropdownMenu,{children:[i.jsx(m.DropdownMenuTrigger,{asChild:!0,children:i.jsx(L.Button,{size:"sm",disabled:_||!(g!=null&&g.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${C}`,children:i.jsx(x.ChevronDown,{className:"h-4 w-4"})})}),i.jsxs(m.DropdownMenuContent,{align:"end",className:"w-52",children:[i.jsxs(m.DropdownMenuItem,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>T({ids:V},{onSuccess:()=>It("TOP_RIGHT")}),children:[e("Publish")," with translation pages"]}),!I&&i.jsxs(m.DropdownMenuItem,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>T({ids:[g==null?void 0:g.id]},{onSuccess:()=>It("TOP_RIGHT")}),children:[e("Publish")," page"]}),i.jsxs(m.DropdownMenuItem,{onClick:()=>a(!0),className:"cursor-pointer text-xs",children:[e("Open")," publish menu"]}),I&&i.jsxs(m.DropdownMenuItem,{onClick:()=>f(s),className:"cursor-pointer text-xs",children:[e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]})]})]})]}),i.jsx(da,{showModal:r,onClose:()=>a(!1)}),c&&i.jsx(h.Suspense,{children:i.jsx(ma,{page:c,onClose:()=>f(null)})}),u&&i.jsx(h.Suspense,{children:i.jsx(Ea,{isOpen:u,onClose:ue,onContinue:ce,isPending:_})})]})};function Sa(){const{isLocked:e}=ne(),[t]=le(),s=t.get("lang"),n=tn(s);return e||!n?i.jsx("div",{}):i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx(ta,{}),i.jsx(Ct,{permission:se.EDIT_THEME,children:i.jsx(ya,{})}),i.jsx(pa,{}),i.jsx(Ct,{permission:se.SAVE_PAGE,children:i.jsx(Ta,{})}),i.jsx(Ct,{permission:se.PUBLISH_PAGE,children:i.jsx(Aa,{})})]})}const Pa=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-B8DdnfrF.cjs"))),xa=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=zs(),n=t.length>0;return s?null:i.jsxs("div",{className:"relative",children:[!e&&i.jsx(Wr,{hasDynamicPage:n}),i.jsx(h.Suspense,{children:i.jsx(Pa,{})})]})},_a=()=>{const{data:e,isFetching:t}=ge(),{data:s,isFetching:n}=te(),r=p.get(s,"dynamic",!1),a=ls(),o=L.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,f=br(),d=t||n,E=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return i.jsxs("div",{className:"relative flex items-center gap-x-1",children:[i.jsx("div",{className:jt.cn("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",d&&"max-w-0 overflow-hidden opacity-0"),children:i.jsx($r,{})}),i.jsxs("div",{className:jt.cn("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":""),d&&"max-w-0 overflow-hidden opacity-0"),children:[i.jsx(en,{}),i.jsxs("div",{className:"flex w-full items-center overflow-hidden",children:[i.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:E==="/"?i.jsxs("span",{className:"text-gray-900",children:["/",i.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):E}),!c&&i.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:i.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:i.jsx(x.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&o&&i.jsx(xa,{})]})},wa=()=>i.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[i.jsx(Zr,{}),i.jsx(_a,{}),i.jsx(Sa,{})]}),sn=()=>{const e=S.useQueryClient(),{data:t}=S.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},va=()=>{const e=N(),{aiContext:t}=sn(),s=j();return h.useCallback(async(n,r,a,o)=>s(e,{action:y.ASK_AI,data:{type:n,prompt:r,blocks:a,context:t,lang:o}}),[e,t,s])},ba=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=Vs.getDefaultBlockProps(s._type);return{...n,...p.pick(s,[...p.keys(n),"_type","_id","_name","_parent","_bindings"]),...p.pickBy(s,(r,a)=>p.endsWith(a,"_attrs")),...s}}return s}),Ca=e=>{const t=Vs.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:ba(t,s)}},[e,t])},Ia=()=>{const[e]=le(),t=e.get("page"),s=N(),{setAiContext:n}=sn(),[,r]=cs(),[,a]=vr(),[,o]=m.useIsPageLoaded(),l=j();return S.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{o(!1);const c=await l(s,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),f=c.blocks??[],d=p.find(f,{_type:"@chai/ai-context"});return n(p.get(d,"_value","")||""),r(u=>({...u,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>o(!0),500),f},enabled:!!t})},nn=()=>{const{data:e}=te(),{data:t}=ge(),s=N(),n=j(),r=Kt(),a=ls();return S.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>n(s,{action:y.GET_BUILDER_PAGE_DATA,data:{pageType:e==null?void 0:e.pageType,lang:(t==null?void 0:t.lang)||r,dynamic:e==null?void 0:e.dynamic,pageProps:{slug:(t==null?void 0:t.slug)+a,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:r,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id,metadata:e.metadata||{}}}}),enabled:!!(e!=null&&e.pageType)&&!!t.id})},rn=()=>{const e=N(),t=S.useQueryClient(),s=j();return S.useMutation({mutationFn:async n=>s(e,{action:y.UPDATE_WEBSITE_SETTINGS,data:n}),onSuccess:(n,r)=>{var a;t.invalidateQueries({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS]}),(a=r==null?void 0:r.settings)!=null&&a.theme||F.toast.success("Website settings updated successfully.")},onError:n=>{F.toast.error("Failed to update website settings",{description:n.message})}})},La=()=>{const e=N(),t=S.useQueryClient(),s=j(),{selectedLang:n}=m.useLanguages();return S.useMutation({mutationFn:async r=>s(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema added successfully.")},onError:r=>{F.toast.error("Failed to add schema",{description:r.message})}})},Na=()=>{const e=N(),t=S.useQueryClient(),s=j(),{selectedLang:n}=m.useLanguages();return S.useMutation({mutationFn:async r=>s(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema updated successfully.")},onError:r=>{F.toast.error("Failed to update schema",{description:r.message})}})},ja=()=>{const e=N(),t=S.useQueryClient(),s=j();return S.useMutation({mutationFn:async n=>s(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema deleted successfully.")},onError:n=>{F.toast.error("Failed to delete schema",{description:n.message})}})},Ga=()=>{const e=N(),t=j();return S.useMutation({mutationFn:async s=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:s}),onError:s=>{F.toast.error("Failed to toggle schema",{description:s.message})}})},ka=()=>{const e=N(),t=j();return S.useMutation({mutationFn:async s=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema applied to ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to apply schema to all pages",{description:s.message})}})},Da=()=>{const e=N(),t=j();return S.useMutation({mutationFn:async s=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema removed from ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to remove schema from all pages",{description:s.message})}})},Ls={async getUILibraryBlock(e,t,s){const n=await t(s,{action:"GET_LIBRARY_ITEM",data:{id:e.id}}),r=p.get(n,"html",""),a=p.get(n,"blocks",[]);return p.isArray(a)?a:gr.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),[]}}},Oa=()=>{const e=N(),t=j();return S.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{L.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>Ls.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>Ls.getUILibraryBlock(a,t,e)})}),n}})},an=()=>{const e=N(),t=j(),{user:s}=qt(),n=s==null?void 0:s.id;return S.useQuery({queryKey:[y.GET_ROLE_AND_PERMISSIONS,n],queryFn:()=>t(e,{action:y.GET_ROLE_AND_PERMISSIONS,data:{}}),enabled:!!n,staleTime:1/0})},Ra=()=>{const e=N(),t=j(),[,s]=cs();return{onSave:async({page:r,blocks:a,needTranslations:o})=>{try{const l=await t(e,{action:"UPDATE_PAGE",data:{id:r,blocks:a,needTranslations:o}});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")}}}},Ma=()=>{const{data:e}=hs(),t=N(),s=j();return{getPartialBlocks:h.useCallback(async()=>{const n={};for(const r of e??[])p.isEmpty(r==null?void 0:r.slug)&&(n[r.id]={type:r.pageType,name:p.startCase(r.name??r.slug),description:""});return n},[e]),getPartialBlockBlocks:h.useCallback(async n=>{if(!n)return[];try{const r=await s(t,{action:"GET_DRAFT_PAGE",data:{id:n,draft:!0,editor:!1}});return p.filter(r.blocks,a=>p.has(a,"_id"))}catch(r){return console.error(r),[]}},[s,t])}},Ua=h.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-content-BPgRdgye.cjs"))),on="chai-chat-panel",Ba=({className:e="h-full w-full"})=>i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",version:"1.1",className:e,children:[i.jsx("title",{children:"ai"}),i.jsx("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:i.jsx("g",{id:"icon",fill:"currentColor",transform:"translate(64.000000, 64.000000)",children:i.jsx("path",{d:"M320,64 L320,320 L64,320 L64,64 L320,64 Z M171.749388,128 L146.817842,128 L99.4840387,256 L121.976629,256 L130.913039,230.977 L187.575039,230.977 L196.319607,256 L220.167172,256 L171.749388,128 Z M260.093778,128 L237.691519,128 L237.691519,256 L260.093778,256 L260.093778,128 Z M159.094727,149.47526 L181.409039,213.333 L137.135039,213.333 L159.094727,149.47526 Z M341.333333,256 L384,256 L384,298.666667 L341.333333,298.666667 L341.333333,256 Z M85.3333333,341.333333 L128,341.333333 L128,384 L85.3333333,384 L85.3333333,341.333333 Z M170.666667,341.333333 L213.333333,341.333333 L213.333333,384 L170.666667,384 L170.666667,341.333333 Z M85.3333333,0 L128,0 L128,42.6666667 L85.3333333,42.6666667 L85.3333333,0 Z M256,341.333333 L298.666667,341.333333 L298.666667,384 L256,384 L256,341.333333 Z M170.666667,0 L213.333333,0 L213.333333,42.6666667 L170.666667,42.6666667 L170.666667,0 Z M256,0 L298.666667,0 L298.666667,42.6666667 L256,42.6666667 L256,0 Z M341.333333,170.666667 L384,170.666667 L384,213.333333 L341.333333,213.333333 L341.333333,170.666667 Z M0,256 L42.6666667,256 L42.6666667,298.666667 L0,298.666667 L0,256 Z M341.333333,85.3333333 L384,85.3333333 L384,128 L341.333333,128 L341.333333,85.3333333 Z M0,170.666667 L42.6666667,170.666667 L42.6666667,213.333333 L0,213.333333 L0,170.666667 Z M0,85.3333333 L42.6666667,85.3333333 L42.6666667,128 L0,128 L0,85.3333333 Z",id:"Combined-Shape"})})})]}),Fa=({isActive:e,show:t})=>i.jsx(L.Button,{size:"icon",className:"p-0 [&_svg]:size-6",onClick:t,variant:e?"default":"ghost",children:i.jsx(Ba,{className:e?"h-5 w-5 text-white":"h-5 w-5 text-primary"})}),qa={id:on,label:"AI Assistant",button:Fa,panel:Ua,position:"top"},Ka=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-C1dbn163.cjs"))),Va=({isActive:e,show:t})=>{const{data:s}=Se();return!p.has(s,"languages")||!p.get(s,"languages",[]).length?null:i.jsx(L.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:i.jsx(x.LanguagesIcon,{className:"h-4 w-4"})})},ln="lang",Ha={id:ln,label:"Languages",position:"top",panel:Ka,button:Va,view:"modal",width:400},Qa=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-BkFbXIL0.cjs"))),cn="seo",za=({isActive:e,show:t})=>{const{data:s}=te(),n=$s(s==null?void 0:s.pageType);return!p.has(n,"hasSlug")||!n.hasSlug?null:i.jsx(L.Button,{size:"icon",className:"my-1 p-0",onClick:t,variant:e?"default":"ghost",children:i.jsxs("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[i.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"}),i.jsx("path",{d:"M14 16h-4v-8h4"}),i.jsx("path",{d:"M11 12h2"}),i.jsx("path",{d:"M17 8m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]})})},$a={id:cn,label:"SEO",panel:Qa,button:za,position:"top",width:600,view:"modal"},un="user-info",Wa=()=>{const{t:e}=he.useTranslation(),{user:t,logout:s}=qt(),n=ie("onLogout",p.noop);return t?i.jsxs(m.HoverCard,{children:[i.jsx(m.HoverCardTrigger,{asChild:!0,children:i.jsx(L.Button,{variant:"ghost",className:"text-sm font-medium",children:i.jsx(x.User,{className:"h-4 w-4"})})}),i.jsxs(m.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[i.jsx("div",{className:"text-sm font-medium",children:t.name??t.email}),i.jsx("div",{className:"text-xs text-muted-foreground",children:t.email}),i.jsxs(m.AlertDialog,{children:[i.jsx(m.AlertDialogTrigger,{asChild:!0,children:i.jsx(L.Button,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),i.jsxs(m.AlertDialogContent,{children:[i.jsxs(m.AlertDialogHeader,{children:[i.jsx(m.AlertDialogTitle,{children:e("Are you sure you want to logout?")}),i.jsx(m.AlertDialogDescription,{children:e("You will be redirected to the login page.")})]}),i.jsxs(m.AlertDialogFooter,{children:[i.jsx(m.AlertDialogCancel,{children:e("Cancel")}),i.jsx(m.AlertDialogAction,{onClick:()=>{s(),p.isFunction(n)&&n()},children:e("Logout")})]})]})]})]})]}):null},Ya={id:un,label:"User Info",button:Wa,position:"bottom"},Ja=()=>{L.registerChaiSidebarPanel(cn,$a),L.registerChaiSidebarPanel(ln,Ha),L.registerChaiSidebarPanel(un,Ya),L.registerChaiSidebarPanel(on,qa)};var v={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return Ns(this.context.count)},getNextContextId(){return Ns(this.context.count++)}};function Ns(e){const t=String(e),s=t.length-1;return v.context.id+(s?String.fromCharCode(96+s):"")+t}function Je(e){v.context=e}var dn=!1,Za=(e,t)=>e===t,Gt=Symbol("solid-proxy"),fn=typeof Proxy=="function",ps=Symbol("solid-track"),kt={equals:Za},hn=Sn,Ee=1,Dt=2,gn={owned:null,cleanups:null,context:null,owner:null},Wt={},O=null,Yt=null,Xa=null,U=null,Z=null,fe=null,Ht=0;function pe(e,t){const s=U,n=O,r=e.length===0,a=t===void 0?n:t,o=r?gn:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>Y(()=>nt(o)));O=o,U=null;try{return oe(l,!0)}finally{U=s,O=n}}function K(e,t){t=t?Object.assign({},kt,t):kt;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),An(s,r));return[Tn.bind(s),n]}function mn(e,t,s){const n=Qt(e,t,!0,Ee);We(n)}function ye(e,t,s){const n=Qt(e,t,!1,Ee);We(n)}function ys(e,t,s){hn=fi;const n=Qt(e,t,!1,Ee);(!s||!s.render)&&(n.user=!0),fe?fe.push(n):We(n)}function $(e,t,s){s=s?Object.assign({},kt,s):kt;const n=Qt(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,We(n),Tn.bind(n)}function ei(e){return e&&typeof e=="object"&&"then"in e}function ti(e,t,s){let n,r,a;n=!0,r=e,a={};let o=null,l=Wt,c=null,f=!1,d="initialValue"in a,u=typeof n=="function"&&$(n);const E=new Set,[g,T]=(a.storage||K)(a.initialValue),[_,w]=K(void 0),[M,A]=K(void 0,{equals:!1}),[C,I]=K(d?"ready":"unresolved");v.context&&(c=v.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:v.load&&v.has(c)&&(l=v.load(c)));function q(b,k,W,z){return o===b&&(o=null,z!==void 0&&(d=!0),(b===l||k===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(z,{value:k})),l=Wt,G(k,W)),k}function G(b,k){oe(()=>{k===void 0&&T(()=>b),I(k!==void 0?"errored":d?"ready":"unresolved"),w(k);for(const W of E.keys())W.decrement();E.clear()},!1)}function ce(){const b=ci,k=g(),W=_();if(W!==void 0&&!o)throw W;return U&&U.user,k}function ue(b=!0){if(b!==!1&&f)return;f=!1;const k=u?u():n;if(k==null||k===!1){q(o,Y(g));return}let W;const z=l!==Wt?l:Y(()=>{try{return r(k,{value:g(),refetching:b})}catch(re){W=re}});if(W!==void 0){q(o,void 0,Lt(W),k);return}else if(!ei(z))return q(o,z,void 0,k),z;return o=z,"v"in z?(z.s===1?q(o,z.v,void 0,k):q(o,void 0,Lt(z.v),k),z):(f=!0,queueMicrotask(()=>f=!1),oe(()=>{I(d?"refreshing":"pending"),A()},!1),z.then(re=>q(z,re,void 0,k),re=>q(z,void 0,Lt(re),k)))}Object.defineProperties(ce,{state:{get:()=>C()},error:{get:()=>_()},loading:{get(){const b=C();return b==="pending"||b==="refreshing"}},latest:{get(){if(!d)return ce();const b=_();if(b&&!o)throw b;return g()}}});let V=O;return u?mn(()=>(V=O,ue(!1))):ue(!1),[ce,{refetch:b=>pn(V,()=>ue(b)),mutate:T}]}function si(e){return oe(e,!1)}function Y(e){if(U===null)return e();const t=U;U=null;try{return e()}finally{U=t}}function ni(e,t,s){const n=Array.isArray(e);let r,a=s&&s.defer;return o=>{let l;if(n){l=Array(e.length);for(let f=0;f<e.length;f++)l[f]=e[f]()}else l=e();if(a)return a=!1,o;const c=Y(()=>t(l,r,o));return r=l,c}}function En(e){ys(()=>Y(e))}function ze(e){return O===null||(O.cleanups===null?O.cleanups=[e]:O.cleanups.push(e)),e}function js(){return O}function pn(e,t){const s=O,n=U;O=e,U=null;try{return oe(t,!0)}catch(r){Ts(r)}finally{O=s,U=n}}function ri(e){const t=U,s=O;return Promise.resolve().then(()=>{U=t,O=s;let n;return oe(e,!1),U=O=null,n?n.done:void 0})}var[ai,El]=K(!1);function ii(){return[ai,ri]}function oi(e,t){const s=Symbol("context");return{id:s,Provider:hi(s),defaultValue:e}}function li(e){let t;return O&&O.context&&(t=O.context[e.id])!==void 0?t:e.defaultValue}function yn(e){const t=$(e),s=$(()=>Xt(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var ci;function Tn(){if(this.sources&&this.state)if(this.state===Ee)We(this);else{const e=Z;Z=null,oe(()=>Rt(this),!1),Z=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 An(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&oe(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],o=Yt&&Yt.running;o&&Yt.disposed.has(a),(o?!a.tState:!a.state)&&(a.pure?Z.push(a):fe.push(a),a.observers&&Pn(a)),o||(a.state=Ee)}if(Z.length>1e6)throw Z=[],new Error},!1)),t}function We(e){if(!e.fn)return;nt(e);const t=Ht;ui(e,e.value,t)}function ui(e,t,s){let n;const r=O,a=U;U=O=e;try{n=e.fn(t)}catch(o){return e.pure&&(e.state=Ee,e.owned&&e.owned.forEach(nt),e.owned=null),e.updatedAt=s+1,Ts(o)}finally{U=a,O=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?An(e,n):e.value=n,e.updatedAt=s)}function Qt(e,t,s,n=Ee,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:O,context:O?O.context:null,pure:s};return O===null||O!==gn&&(O.owned?O.owned.push(a):O.owned=[a]),a}function Ot(e){if(e.state===0)return;if(e.state===Dt)return Rt(e);if(e.suspense&&Y(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Ht);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===Ee)We(e);else if(e.state===Dt){const n=Z;Z=null,oe(()=>Rt(e,t[0]),!1),Z=n}}function oe(e,t){if(Z)return e();let s=!1;t||(Z=[]),fe?s=!0:fe=[],Ht++;try{const n=e();return di(s),n}catch(n){s||(fe=null),Z=null,Ts(n)}}function di(e){if(Z&&(Sn(Z),Z=null),e)return;const t=fe;fe=null,t.length&&oe(()=>hn(t),!1)}function Sn(e){for(let t=0;t<e.length;t++)Ot(e[t])}function fi(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:Ot(n)}if(v.context){if(v.count){v.effects||(v.effects=[]),v.effects.push(...e.slice(0,s));return}Je()}for(v.effects&&(v.done||!v.count)&&(e=[...v.effects,...e],s+=v.effects.length,delete v.effects),t=0;t<s;t++)Ot(e[t])}function Rt(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===Ee?n!==t&&(!n.updatedAt||n.updatedAt<Ht)&&Ot(n):r===Dt&&Rt(n,t)}}}function Pn(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=Dt,s.pure?Z.push(s):fe.push(s),s.observers&&Pn(s))}}function nt(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),r=s.observers;if(r&&r.length){const a=r.pop(),o=s.observerSlots.pop();n<r.length&&(a.sourceSlots[o]=n,r[n]=a,s.observerSlots[n]=o)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)nt(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)nt(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 Lt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Ts(e,t=O){throw Lt(e)}function Xt(e){if(typeof e=="function"&&!e.length)return Xt(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Xt(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function hi(e,t){return function(n){let r;return ye(()=>r=Y(()=>(O.context={...O.context,[e]:n.value},yn(()=>n.children))),void 0),r}}var es=Symbol("fallback");function Mt(e){for(let t=0;t<e.length;t++)e[t]()}function gi(e,t,s={}){let n=[],r=[],a=[],o=0,l=t.length>1?[]:null;return ze(()=>Mt(a)),()=>{let c=e()||[],f=c.length,d,u;return c[ps],Y(()=>{let g,T,_,w,M,A,C,I,q;if(f===0)o!==0&&(Mt(a),a=[],n=[],r=[],o=0,l&&(l=[])),s.fallback&&(n=[es],r[0]=pe(G=>(a[0]=G,s.fallback())),o=1);else if(o===0){for(r=new Array(f),u=0;u<f;u++)n[u]=c[u],r[u]=pe(E);o=f}else{for(_=new Array(f),w=new Array(f),l&&(M=new Array(f)),A=0,C=Math.min(o,f);A<C&&n[A]===c[A];A++);for(C=o-1,I=f-1;C>=A&&I>=A&&n[C]===c[I];C--,I--)_[I]=r[C],w[I]=a[C],l&&(M[I]=l[C]);for(g=new Map,T=new Array(I+1),u=I;u>=A;u--)q=c[u],d=g.get(q),T[u]=d===void 0?-1:d,g.set(q,u);for(d=A;d<=C;d++)q=n[d],u=g.get(q),u!==void 0&&u!==-1?(_[u]=r[d],w[u]=a[d],l&&(M[u]=l[d]),u=T[u],g.set(q,u)):a[d]();for(u=A;u<f;u++)u in _?(r[u]=_[u],a[u]=w[u],l&&(l[u]=M[u],l[u](u))):r[u]=pe(E);r=r.slice(0,o=f),n=c.slice(0)}return r});function E(g){if(a[u]=g,l){const[T,_]=K(u);return l[u]=_,t(c[u],T)}return t(c[u])}}}function mi(e,t,s={}){let n=[],r=[],a=[],o=[],l=0,c;return ze(()=>Mt(a)),()=>{const f=e()||[],d=f.length;return f[ps],Y(()=>{if(d===0)return l!==0&&(Mt(a),a=[],n=[],r=[],l=0,o=[]),s.fallback&&(n=[es],r[0]=pe(E=>(a[0]=E,s.fallback())),l=1),r;for(n[0]===es&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<d;c++)c<n.length&&n[c]!==f[c]?o[c](()=>f[c]):c>=n.length&&(r[c]=pe(u));for(;c<n.length;c++)a[c]();return l=o.length=a.length=d,n=f.slice(0),r=r.slice(0,l)});function u(E){a[c]=E;const[g,T]=K(f[c]);return o[c]=T,t(g,c)}}}function As(e,t){return Y(()=>e(t||{}))}function wt(){return!0}var ts={get(e,t,s){return t===Gt?s:e.get(t)},has(e,t){return t===Gt?!0:e.has(t)},set:wt,deleteProperty:wt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:wt,deleteProperty:wt}},ownKeys(e){return e.keys()}};function Jt(e){return(e=typeof e=="function"?e():e)?e:{}}function Ei(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function Ss(...e){let t=!1;for(let o=0;o<e.length;o++){const l=e[o];t=t||!!l&&Gt in l,e[o]=typeof l=="function"?(t=!0,$(l)):l}if(fn&&t)return new Proxy({get(o){for(let l=e.length-1;l>=0;l--){const c=Jt(e[l])[o];if(c!==void 0)return c}},has(o){for(let l=e.length-1;l>=0;l--)if(o in Jt(e[l]))return!0;return!1},keys(){const o=[];for(let l=0;l<e.length;l++)o.push(...Object.keys(Jt(e[l])));return[...new Set(o)]}},ts);const s={},n=Object.create(null);for(let o=e.length-1;o>=0;o--){const l=e[o];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let f=c.length-1;f>=0;f--){const d=c[f];if(d==="__proto__"||d==="constructor")continue;const u=Object.getOwnPropertyDescriptor(l,d);if(!n[d])n[d]=u.get?{enumerable:!0,configurable:!0,get:Ei.bind(s[d]=[u.get.bind(l)])}:u.value!==void 0?u:void 0;else{const E=s[d];E&&(u.get?E.push(u.get.bind(l)):u.value!==void 0&&E.push(()=>u.value))}}}const r={},a=Object.keys(n);for(let o=a.length-1;o>=0;o--){const l=a[o],c=n[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function xn(e,...t){if(fn&&Gt in e){const r=new Set(t.length>1?t.flat():t[0]),a=t.map(o=>new Proxy({get(l){return o.includes(l)?e[l]:void 0},has(l){return o.includes(l)&&l in e},keys(){return o.filter(l=>l in e)}},ts));return a.push(new Proxy({get(o){return r.has(o)?void 0:e[o]},has(o){return r.has(o)?!1:o in e},keys(){return Object.keys(e).filter(o=>!r.has(o))}},ts)),a}const s={},n=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),o=!a.get&&!a.set&&a.enumerable&&a.writable&&a.configurable;let l=!1,c=0;for(const f of t)f.includes(r)&&(l=!0,o?n[c][r]=a.value:Object.defineProperty(n[c],r,a)),++c;l||(o?s[r]=a.value:Object.defineProperty(s,r,a))}return[...n,s]}function _n(e){let t,s;const n=r=>{const a=v.context;if(a){const[l,c]=K();v.count||(v.count=0),v.count++,(s||(s=e())).then(f=>{!v.done&&Je(a),v.count--,c(()=>f.default),Je()}),t=l}else if(!t){const[l]=ti(()=>(s||(s=e())).then(c=>c.default));t=l}let o;return $(()=>(o=t())?Y(()=>{if(!a||v.done)return o(r);const l=v.context;Je(a);const c=o(r);return Je(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var pi=0;function yi(){return v.context?v.getNextContextId():`cl-${pi++}`}var wn=e=>`Stale read from <${e}>.`;function Ti(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(gi(()=>e.each,e.children,t||void 0))}function Ai(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(mi(()=>e.each,e.children,t||void 0))}function Si(e){const t=e.keyed,s=$(()=>e.when,void 0,void 0),n=t?s:$(s,void 0,{equals:(r,a)=>!r==!a});return $(()=>{const r=n();if(r){const a=e.children;return typeof a=="function"&&a.length>0?Y(()=>a(t?r:()=>{if(!Y(n))throw wn("Show");return s()})):a}return e.fallback},void 0,void 0)}function Pi(e){const t=yn(()=>e.children),s=$(()=>{const n=t(),r=Array.isArray(n)?n:[n];let a=()=>{};for(let o=0;o<r.length;o++){const l=o,c=r[o],f=a,d=$(()=>f()?void 0:c.when,void 0,void 0),u=c.keyed?d:$(d,void 0,{equals:(E,g)=>!E==!g});a=()=>f()||(u()?[l,d,c]:void 0)}return a});return $(()=>{const n=s()();if(!n)return e.fallback;const[r,a,o]=n,l=o.children;return typeof l=="function"&&l.length>0?Y(()=>l(o.keyed?a():()=>{var f;if(((f=Y(s)())==null?void 0:f[0])!==r)throw wn("Match");return a()})):l},void 0,void 0)}function xi(e){return e}var _i=["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"],wi=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",..._i]),vi=new Set(["innerHTML","textContent","innerText","children"]),bi=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),Ci=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 Ii(e,t){const s=Ci[e];return typeof s=="object"?s[t]?s.$:void 0:s}var Li=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),Ni=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"]),ji={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},Gi=e=>$(()=>e());function ki(e,t,s){let n=s.length,r=t.length,a=n,o=0,l=0,c=t[r-1].nextSibling,f=null;for(;o<r||l<a;){if(t[o]===s[l]){o++,l++;continue}for(;t[r-1]===s[a-1];)r--,a--;if(r===o){const d=a<n?l?s[l-1].nextSibling:s[a-l]:c;for(;l<a;)e.insertBefore(s[l++],d)}else if(a===l)for(;o<r;)(!f||!f.has(t[o]))&&t[o].remove(),o++;else if(t[o]===s[a-1]&&s[l]===t[r-1]){const d=t[--r].nextSibling;e.insertBefore(s[l++],t[o++].nextSibling),e.insertBefore(s[--a],d),t[r]=s[a]}else{if(!f){f=new Map;let u=l;for(;u<a;)f.set(s[u],u++)}const d=f.get(t[o]);if(d!=null)if(l<d&&d<a){let u=o,E=1,g;for(;++u<r&&u<a&&!((g=f.get(t[u]))==null||g!==d+E);)E++;if(E>d-l){const T=t[o];for(;l<d;)e.insertBefore(s[l++],T)}else e.replaceChild(s[l++],t[o++])}else o++;else t[o++].remove()}}}var et="_$DX_DELEGATE";function vn(e,t,s,n={}){let r;return pe(a=>{r=a,t===document?e():Bt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function Di(e,t,s,n){let r;const a=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},o=()=>(r||(r=a())).cloneNode(!0);return o.cloneNode=o,o}function bn(e,t=window.document){const s=t[et]||(t[et]=new Set);for(let n=0,r=e.length;n<r;n++){const a=e[n];s.has(a)||(s.add(a),t.addEventListener(a,jn))}}function Oi(e=window.document){if(e[et]){for(let t of e[et].keys())e.removeEventListener(t,jn);delete e[et]}}function Ut(e,t,s){ve(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function Ri(e,t,s,n){ve(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function Mi(e,t,s){ve(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function Cn(e,t){ve(e)||(t==null?e.removeAttribute("class"):e.className=t)}function In(e,t,s,n){if(n)Array.isArray(s)?(e[`$$${t}`]=s[0],e[`$$${t}Data`]=s[1]):e[`$$${t}`]=s;else if(Array.isArray(s)){const r=s[0];e.addEventListener(t,s[0]=a=>r.call(e,s[1],a))}else e.addEventListener(t,s,typeof s!="function"&&s)}function Ui(e,t,s={}){const n=Object.keys(t||{}),r=Object.keys(s);let a,o;for(a=0,o=r.length;a<o;a++){const l=r[a];!l||l==="undefined"||t[l]||(Gs(e,l,!1),delete s[l])}for(a=0,o=n.length;a<o;a++){const l=n[a],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(Gs(e,l,!0),s[l]=c)}return s}function Bi(e,t,s){if(!t)return s?Ut(e,"style"):t;const n=e.style;if(typeof t=="string")return n.cssText=t;typeof s=="string"&&(n.cssText=s=void 0),s||(s={}),t||(t={});let r,a;for(a in s)t[a]==null&&n.removeProperty(a),delete s[a];for(a in t)r=t[a],r!==s[a]&&(n.setProperty(a,r),s[a]=r);return s}function Ln(e,t={},s,n){const r={};return n||ye(()=>r.children=rt(e,t.children,r.children)),ye(()=>typeof t.ref=="function"&&Nn(t.ref,e)),ye(()=>Fi(e,t,s,!0,r,!0)),r}function Nn(e,t,s){return Y(()=>e(t,s))}function Bt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return rt(e,t,n,s);ye(r=>rt(e,t(),r,s),n)}function Fi(e,t,s,n,r={},a=!1){t||(t={});for(const o in r)if(!(o in t)){if(o==="children")continue;r[o]=ks(e,o,null,r[o],s,a,t)}for(const o in t){if(o==="children")continue;const l=t[o];r[o]=ks(e,o,l,r[o],s,a,t)}}function qi(e){let t,s;return!ve()||!(t=v.registry.get(s=Vi()))?e():(v.completed&&v.completed.add(t),v.registry.delete(s),t)}function ve(e){return!!v.context&&!v.done&&(!e||e.isConnected)}function Ki(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Gs(e,t,s){const n=t.trim().split(/\s+/);for(let r=0,a=n.length;r<a;r++)e.classList.toggle(n[r],s)}function ks(e,t,s,n,r,a,o){let l,c,f,d,u;if(t==="style")return Bi(e,s,n);if(t==="classList")return Ui(e,s,n);if(s===n)return n;if(t==="ref")a||s(e);else if(t.slice(0,3)==="on:"){const E=t.slice(3);n&&e.removeEventListener(E,n,typeof n!="function"&&n),s&&e.addEventListener(E,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const E=t.slice(10);n&&e.removeEventListener(E,n,!0),s&&e.addEventListener(E,s,!0)}else if(t.slice(0,2)==="on"){const E=t.slice(2).toLowerCase(),g=Li.has(E);if(!g&&n){const T=Array.isArray(n)?n[0]:n;e.removeEventListener(E,T)}(g||s)&&(In(e,E,s,g),g&&bn([E]))}else if(t.slice(0,5)==="attr:")Ut(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")Mi(e,t.slice(5),s);else if((u=t.slice(0,5)==="prop:")||(f=vi.has(t))||!r&&((d=Ii(t,e.tagName))||(c=wi.has(t)))||(l=e.nodeName.includes("-")||"is"in o)){if(u)t=t.slice(5),c=!0;else if(ve(e))return s;t==="class"||t==="className"?Cn(e,s):l&&!c&&!f?e[Ki(t)]=s:e[d||t]=s}else{const E=r&&t.indexOf(":")>-1&&ji[t.split(":")[0]];E?Ri(e,E,t,s):Ut(e,bi[t]||t,s)}return s}function jn(e){if(v.registry&&v.events&&v.events.find(([c,f])=>f===e))return;let t=e.target;const s=`$$${e.type}`,n=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),o=()=>{const c=t[s];if(c&&!t.disabled){const f=t[`${s}Data`];if(f!==void 0?c.call(t,f,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},l=()=>{for(;o()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),v.registry&&!v.done&&(v.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let f=0;f<c.length-2&&(t=c[f],!!o());f++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function rt(e,t,s,n,r){const a=ve(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let f=0;f<s.length;f++){const d=s[f];d.nodeType===8&&d.data.slice(0,2)==="!$"?d.remove():c.push(d)}s=c}for(;typeof s=="function";)s=s();if(t===s)return s;const o=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,o==="string"||o==="number"){if(a||o==="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=Ce(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||o==="boolean"){if(a)return s;s=Ce(e,s,n)}else{if(o==="function")return ye(()=>{let c=t();for(;typeof c=="function";)c=c();s=rt(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],f=s&&Array.isArray(s);if(ss(c,t,s,r))return ye(()=>s=rt(e,c,s,n,!0)),()=>s;if(a){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let d=c[0];if(d.parentNode!==e)return s;const u=[d];for(;(d=d.nextSibling)!==n;)u.push(d);return s=u}if(c.length===0){if(s=Ce(e,s,n),l)return s}else f?s.length===0?Ds(e,c,n):ki(e,s,c):(s&&Ce(e),Ds(e,c));s=c}else if(t.nodeType){if(a&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=Ce(e,s,n,t);Ce(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function ss(e,t,s,n){let r=!1;for(let a=0,o=t.length;a<o;a++){let l=t[a],c=s&&s[e.length],f;if(!(l==null||l===!0||l===!1))if((f=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=ss(e,l,c)||r;else if(f==="function")if(n){for(;typeof l=="function";)l=l();r=ss(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const d=String(l);c&&c.nodeType===3&&c.data===d?e.push(c):e.push(document.createTextNode(d))}}return r}function Ds(e,t,s=null){for(let n=0,r=t.length;n<r;n++)e.insertBefore(t[n],s)}function Ce(e,t,s,n){if(s===void 0)return e.textContent="";const r=n||document.createTextNode("");if(t.length){let a=!1;for(let o=t.length-1;o>=0;o--){const l=t[o];if(r!==l){const c=l.parentNode===e;!a&&!o?c?e.replaceChild(r,l):e.insertBefore(r,s):c&&l.remove()}else a=!0}}else e.insertBefore(r,s);return[r]}function Vi(){return v.getNextContextId()}var Hi="http://www.w3.org/2000/svg";function Gn(e,t=!1){return t?document.createElementNS(Hi,e):document.createElement(e)}function Qi(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=js();let a,o=!!v.context;return ys(()=>{o&&(js().user=o=!1),a||(a=pn(r,()=>$(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,f]=K(!1),d=()=>f(!0);pe(u=>Bt(l,()=>c()?u():a(),null)),ze(d)}else{const c=Gn(e.isSVG?"g":"div",e.isSVG),f=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Bt(f,a),l.appendChild(c),e.ref&&e.ref(c),ze(()=>l.removeChild(c))}},void 0,{render:!o}),s}function zi(e,t){const s=$(e);return $(()=>{const n=s();switch(typeof n){case"function":return Y(()=>n(t));case"string":const r=Ni.has(n),a=v.context?qi():Gn(n,r);return Ln(a,t,r),a}})}function $i(e){const[,t]=xn(e,["component"]);return zi(()=>e.component,t)}var Wi=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()}},kn=class{constructor(e){this.generateIdentifier=e,this.kv=new Wi}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)}},Yi=class extends kn{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 Ji(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 Zi(e,t){const s=Ji(e);if("find"in s)return s.find(t);const n=s;for(let r=0;r<n.length;r++){const a=n[r];if(t(a))return a}}function $e(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function Nt(e,t){return e.indexOf(t)!==-1}function Os(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var Xi=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Zi(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},eo=e=>Object.prototype.toString.call(e).slice(8,-1),Dn=e=>typeof e>"u",to=e=>e===null,at=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,ns=e=>at(e)&&Object.keys(e).length===0,Te=e=>Array.isArray(e),so=e=>typeof e=="string",no=e=>typeof e=="number"&&!isNaN(e),ro=e=>typeof e=="boolean",ao=e=>e instanceof RegExp,it=e=>e instanceof Map,ot=e=>e instanceof Set,On=e=>eo(e)==="Symbol",io=e=>e instanceof Date&&!isNaN(e.valueOf()),oo=e=>e instanceof Error,Rs=e=>typeof e=="number"&&isNaN(e),lo=e=>ro(e)||to(e)||Dn(e)||no(e)||so(e)||On(e),co=e=>typeof e=="bigint",uo=e=>e===1/0||e===-1/0,fo=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),ho=e=>e instanceof URL,Rn=e=>e.replace(/\./g,"\\."),Zt=e=>e.map(String).map(Rn).join("."),tt=e=>{const t=[];let s="";for(let r=0;r<e.length;r++){let a=e.charAt(r);if(a==="\\"&&e.charAt(r+1)==="."){s+=".",r++;continue}if(a==="."){t.push(s),s="";continue}s+=a}const n=s;return t.push(n),t};function ae(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var Mn=[ae(Dn,"undefined",()=>null,()=>{}),ae(co,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),ae(io,"Date",e=>e.toISOString(),e=>new Date(e)),ae(oo,"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}),ae(ao,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),ae(ot,"set",e=>[...e.values()],e=>new Set(e)),ae(it,"map",e=>[...e.entries()],e=>new Map(e)),ae(e=>Rs(e)||uo(e),"number",e=>Rs(e)?"NaN":e>0?"Infinity":"-Infinity",Number),ae(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),ae(ho,"URL",e=>e.toString(),e=>new URL(e))];function zt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var Un=zt((e,t)=>On(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}),go=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),Bn=zt(fo,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=go[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function Fn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var qn=zt(Fn,(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)}),Kn=zt((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)}),mo=[qn,Un,Kn,Bn],Ms=(e,t)=>{const s=Os(mo,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=Os(Mn,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Vn={};Mn.forEach(e=>{Vn[e.annotation]=e});var Eo=(e,t,s)=>{if(Te(t))switch(t[0]){case"symbol":return Un.untransform(e,t,s);case"class":return qn.untransform(e,t,s);case"custom":return Kn.untransform(e,t,s);case"typed-array":return Bn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=Vn[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},Ie=(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 Hn(e){if(Nt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Nt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(Nt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var po=(e,t)=>{Hn(t);for(let s=0;s<t.length;s++){const n=t[s];if(ot(e))e=Ie(e,+n);else if(it(e)){const r=+n,a=+t[++s]==0?"key":"value",o=Ie(e,r);switch(a){case"key":e=o;break;case"value":e=e.get(o);break}}else e=e[n]}return e},rs=(e,t,s)=>{if(Hn(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const o=t[a];if(Te(n)){const l=+o;n=n[l]}else if(at(n))n=n[o];else if(ot(n)){const l=+o;n=Ie(n,l)}else if(it(n)){if(a===t.length-2)break;const c=+o,f=+t[++a]==0?"key":"value",d=Ie(n,c);switch(f){case"key":n=d;break;case"value":n=n.get(d);break}}}const r=t[t.length-1];if(Te(n)?n[+r]=s(n[+r]):at(n)&&(n[r]=s(n[r])),ot(n)){const a=Ie(n,+r),o=s(a);a!==o&&(n.delete(a),n.add(o))}if(it(n)){const a=+t[t.length-2],o=Ie(n,a);switch(+r==0?"key":"value"){case"key":{const c=s(o);n.set(c,n.get(o)),c!==o&&n.delete(o);break}case"value":{n.set(o,s(n.get(o)));break}}}return e};function as(e,t,s=[]){if(!e)return;if(!Te(e)){$e(e,(a,o)=>as(a,t,[...s,...tt(o)]));return}const[n,r]=e;r&&$e(r,(a,o)=>{as(a,t,[...s,...tt(o)])}),t(n,s)}function yo(e,t,s){return as(t,(n,r)=>{e=rs(e,r,a=>Eo(a,n,s))}),e}function To(e,t){function s(n,r){const a=po(e,tt(r));n.map(tt).forEach(o=>{e=rs(e,o,()=>a)})}if(Te(t)){const[n,r]=t;n.forEach(a=>{e=rs(e,tt(a),()=>e)}),r&&$e(r,s)}else $e(t,s);return e}var Ao=(e,t)=>at(e)||Te(e)||it(e)||ot(e)||Fn(e,t);function So(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function Po(e,t){const s={};let n;return e.forEach(r=>{if(r.length<=1)return;t||(r=r.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...o]=r;a.length===0?n=o.map(Zt):s[Zt(a)]=o.map(Zt)}),n?ns(s)?[n]:[n,s]:ns(s)?void 0:s}var Qn=(e,t,s,n,r=[],a=[],o=new Map)=>{const l=lo(e);if(!l){So(e,r,t);const g=o.get(e);if(g)return n?{transformedValue:null}:g}if(!Ao(e,s)){const g=Ms(e,s),T=g?{transformedValue:g.value,annotations:[g.type]}:{transformedValue:e};return l||o.set(e,T),T}if(Nt(a,e))return{transformedValue:null};const c=Ms(e,s),f=(c==null?void 0:c.value)??e,d=Te(f)?[]:{},u={};$e(f,(g,T)=>{if(T==="__proto__"||T==="constructor"||T==="prototype")throw new Error(`Detected property ${T}. This is a prototype pollution risk, please remove it from your object.`);const _=Qn(g,t,s,n,[...r,T],[...a,e],o);d[T]=_.transformedValue,Te(_.annotations)?u[T]=_.annotations:at(_.annotations)&&$e(_.annotations,(w,M)=>{u[Rn(T)+"."+M]=w})});const E=ns(u)?{transformedValue:d,annotations:c?[c.type]:void 0}:{transformedValue:d,annotations:c?[c.type,u]:u};return l||o.set(e,E),E};function zn(e){return Object.prototype.toString.call(e).slice(8,-1)}function Us(e){return zn(e)==="Array"}function xo(e){if(zn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function _o(e,t,s,n,r){const a={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=s),r&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function is(e,t={}){if(Us(e))return e.map(r=>is(r,t));if(!xo(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(Us(t.props)&&!t.props.includes(a))return r;const o=e[a],l=is(o,t);return _o(r,a,l,e,t.nonenumerable),r},{})}var B=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Yi,this.symbolRegistry=new kn(t=>t.description??""),this.customTransformerRegistry=new Xi,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=Qn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=Po(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=is(t);return s!=null&&s.values&&(n=yo(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=To(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)}};B.defaultInstance=new B;B.serialize=B.defaultInstance.serialize.bind(B.defaultInstance);B.deserialize=B.defaultInstance.deserialize.bind(B.defaultInstance);B.stringify=B.defaultInstance.stringify.bind(B.defaultInstance);B.parse=B.defaultInstance.parse.bind(B.defaultInstance);B.registerClass=B.defaultInstance.registerClass.bind(B.defaultInstance);B.registerSymbol=B.defaultInstance.registerSymbol.bind(B.defaultInstance);B.registerCustom=B.defaultInstance.registerCustom.bind(B.defaultInstance);B.allowErrorProps=B.defaultInstance.allowErrorProps.bind(B.defaultInstance);var $n=B.serialize,wo=B.stringify;function vo(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function bo(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function Co({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function Io({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function Lo(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var No=(e,t=!1)=>{const{json:s}=$n(e);return JSON.stringify(s,null,t?2:void 0)},vt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,jo=(e,t)=>e.queryHash.localeCompare(t.queryHash),Wn=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,Go=(e,t)=>vt(e)===vt(t)?Wn(e,t):vt(e)>vt(t)?1:-1,ko={status:Go,"query hash":jo,"last updated":Wn},bt=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,Yn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,Do=(e,t)=>bt(e)===bt(t)?Yn(e,t):bt(e)>bt(t)?1:-1,Oo={status:Do,"last updated":Yn},Ro=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),Mo=()=>{const[e,t]=K("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),ze(()=>s.removeEventListener("change",n))}),e},Ze=(e,t,s)=>{if(t.length===0)return s;if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.set(t[0],s),n;const[r,...a]=t;return n.set(r,Ze(n.get(r),a,s)),n}if(e instanceof Set){const n=Ze(Array.from(e),t,s);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=Ze(n[r],a,s),n}if(e instanceof Object){const n={...e};if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=Ze(n[r],a,s),n}return e},Xe=(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,Xe(s.get(n),r)),s}if(e instanceof Set){const s=Xe(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((a,o)=>o.toString()!==t[0]);const[n,...r]=t;return s[n]=Xe(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]=Xe(s[n],r),s}return e},Jn=(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)},Le,lt,ct,ut,xe,dt,Ne,je,Ge,ke,De,ft,Oe,Re,ht,qs,Uo=(qs=class{constructor(e){R(this,Le);R(this,lt);R(this,ct);R(this,ut);R(this,xe,!1);R(this,dt);R(this,Ne);R(this,je);R(this,Ge);R(this,ke);R(this,De);R(this,ft);R(this,Oe);R(this,Re);R(this,ht);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:o,initialIsOpen:l,errorTypes:c,styleNonce:f,shadowDOMTarget:d,hideDisabledQueries:u,theme:E}=e;D(this,Le,K(t)),D(this,ct,s),D(this,ut,n),D(this,lt,r),D(this,dt,f),D(this,Ne,d),D(this,je,K(a)),D(this,Ge,K(o)),D(this,ke,K(l)),D(this,De,K(c)),D(this,ft,K(u)),D(this,Re,K(E))}setButtonPosition(e){P(this,je)[1](e)}setPosition(e){P(this,Ge)[1](e)}setInitialIsOpen(e){P(this,ke)[1](e)}setErrorTypes(e){P(this,De)[1](e)}setClient(e){P(this,Le)[1](e)}setTheme(e){P(this,Re)[1](e)}mount(e){if(P(this,xe))throw new Error("Devtools is already mounted");const t=vn(()=>{const s=this,[n]=P(this,je),[r]=P(this,Ge),[a]=P(this,ke),[o]=P(this,De),[l]=P(this,ft),[c]=P(this,Le),[f]=P(this,Re);let d;return P(this,Oe)?d=P(this,Oe):(d=_n(()=>Promise.resolve().then(()=>require("./WDYDFRGG-n8sBZVFG.cjs"))),D(this,Oe,d)),Jn(P(this,dt),P(this,Ne)),As(d,Ss({get queryFlavor(){return P(s,ct)},get version(){return P(s,ut)},get onlineManager(){return P(s,lt)},get shadowDOMTarget(){return P(s,Ne)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return o()},get hideDisabledQueries(){return l()},get theme(){return f()}}))},e);D(this,xe,!0),D(this,ht,t)}unmount(){var e;if(!P(this,xe))throw new Error("Devtools is not mounted");(e=P(this,ht))==null||e.call(this),D(this,xe,!1)}},Le=new WeakMap,lt=new WeakMap,ct=new WeakMap,ut=new WeakMap,xe=new WeakMap,dt=new WeakMap,Ne=new WeakMap,je=new WeakMap,Ge=new WeakMap,ke=new WeakMap,De=new WeakMap,ft=new WeakMap,Oe=new WeakMap,Re=new WeakMap,ht=new WeakMap,qs),Me,gt,mt,Et,_e,pt,Ue,Be,Fe,qe,Ke,yt,Ve,He,Qe,Tt,Ks,Bo=(Ks=class{constructor(e){R(this,Me);R(this,gt);R(this,mt);R(this,Et);R(this,_e,!1);R(this,pt);R(this,Ue);R(this,Be);R(this,Fe);R(this,qe);R(this,Ke);R(this,yt);R(this,Ve);R(this,He);R(this,Qe);R(this,Tt);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:o,initialIsOpen:l,errorTypes:c,styleNonce:f,shadowDOMTarget:d,onClose:u,hideDisabledQueries:E,theme:g}=e;D(this,Me,K(t)),D(this,mt,s),D(this,Et,n),D(this,gt,r),D(this,pt,f),D(this,Ue,d),D(this,Be,K(a)),D(this,Fe,K(o)),D(this,qe,K(l)),D(this,Ke,K(c)),D(this,yt,K(E)),D(this,Ve,K(u)),D(this,Qe,K(g))}setButtonPosition(e){P(this,Be)[1](e)}setPosition(e){P(this,Fe)[1](e)}setInitialIsOpen(e){P(this,qe)[1](e)}setErrorTypes(e){P(this,Ke)[1](e)}setClient(e){P(this,Me)[1](e)}setOnClose(e){P(this,Ve)[1](()=>e)}setTheme(e){P(this,Qe)[1](e)}mount(e){if(P(this,_e))throw new Error("Devtools is already mounted");const t=vn(()=>{const s=this,[n]=P(this,Be),[r]=P(this,Fe),[a]=P(this,qe),[o]=P(this,Ke),[l]=P(this,yt),[c]=P(this,Me),[f]=P(this,Ve),[d]=P(this,Qe);let u;return P(this,He)?u=P(this,He):(u=_n(()=>Promise.resolve().then(()=>require("./2SSKDMRQ-BIryEtW-.cjs"))),D(this,He,u)),Jn(P(this,pt),P(this,Ue)),As(u,Ss({get queryFlavor(){return P(s,mt)},get version(){return P(s,Et)},get onlineManager(){return P(s,gt)},get shadowDOMTarget(){return P(s,Ue)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return o()},get hideDisabledQueries(){return l()},get onClose(){return f()},get theme(){return d()}}))},e);D(this,_e,!0),D(this,Tt,t)}unmount(){var e;if(!P(this,_e))throw new Error("Devtools is not mounted");(e=P(this,Tt))==null||e.call(this),D(this,_e,!1)}},Me=new WeakMap,gt=new WeakMap,mt=new WeakMap,Et=new WeakMap,_e=new WeakMap,pt=new WeakMap,Ue=new WeakMap,Be=new WeakMap,Fe=new WeakMap,qe=new WeakMap,Ke=new WeakMap,yt=new WeakMap,Ve=new WeakMap,He=new WeakMap,Qe=new WeakMap,Tt=new WeakMap,Ks);function Fo(e){const t=S.useQueryClient(e.client),s=Q.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:o,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:f,theme:d}=e,[u]=Q.useState(new Uo({client:t,queryFlavor:"React Query",version:"5",onlineManager:S.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:o,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:f,theme:d}));return Q.useEffect(()=>{u.setClient(t)},[t,u]),Q.useEffect(()=>{n&&u.setButtonPosition(n)},[n,u]),Q.useEffect(()=>{r&&u.setPosition(r)},[r,u]),Q.useEffect(()=>{u.setInitialIsOpen(a||!1)},[a,u]),Q.useEffect(()=>{u.setErrorTypes(o||[])},[o,u]),Q.useEffect(()=>{u.setTheme(d)},[d,u]),Q.useEffect(()=>(s.current&&u.mount(s.current),()=>{u.unmount()}),[u]),i.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function qo(e){const t=S.useQueryClient(e.client),s=Q.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:o,theme:l}=e,[c]=Q.useState(new Bo({client:t,queryFlavor:"React Query",version:"5",onlineManager:S.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:n,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:o,theme:l}));return Q.useEffect(()=>{c.setClient(t)},[t,c]),Q.useEffect(()=>{c.setOnClose(e.onClose??(()=>{}))},[e.onClose,c]),Q.useEffect(()=>{c.setErrorTypes(n||[])},[n,c]),Q.useEffect(()=>{c.setTheme(l)},[l,c]),Q.useEffect(()=>(s.current&&c.mount(s.current),()=>{c.unmount()}),[c]),i.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:s})}var Bs=process.env.NODE_ENV!=="development"?function(){return null}:Fo;process.env.NODE_ENV;const Zn=H.atom(""),Ko=()=>{L.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),L.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},Vo=()=>{const e=N(),t=j();return S.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},Ho=()=>{const{data:e}=te(),{data:t}=ge(),{data:s}=Se(),n=N(),r=j(),a=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]),o=h.useRef(new Map);return S.useMutation({mutationFn:async({block:l})=>{const c=l._id,f=(t==null?void 0:t.lang)||a,d=`${c}:${f}`;if(o.current.has(d))return o.current.get(d);const u=r(n,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:l,lang:f,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:a,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id}}});return o.current.set(d,u),u.finally(()=>{o.current.delete(d)}),u}})},Xn=()=>{const[,e]=le();return h.useCallback((t,s)=>{const r=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});r&&a.set("lang",r),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),s==null||s()},[e])},er=()=>{const e=Xn();return h.useCallback(({pageId:t})=>{e(t)},[e])},Qo={SITE_WIDE_USAGE:"SITE_WIDE_USAGE"},zo=e=>{const t=j(),s=N();return S.useQuery({queryKey:[Qo.SITE_WIDE_USAGE],queryFn:async()=>e?t(s,{action:"GET_SITE_WIDE_USAGE"}):{},retry:!1})},$o=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-fRos9wRU.cjs"))),Wo=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-dialog-DynACvgV.cjs"))),Yo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-DHYRXaaq.cjs"))),Jo=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-0ysmXVbI.cjs"))),Zo=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-NTNCL0SW.cjs"))),Xo=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-DU1MgppY.cjs")));Ko();mr.loadWebBlocks();L.registerChaiTopBar(wa);Ja();L.registerChaiMediaManager(Yo);L.registerChaiSaveToLibrary(Jo);const el={role:"",permissions:null},Fs=e=>{var _s;const{data:t}=Oa(),s=Kt(),{data:n=el,isFetching:r}=an(),{data:a,isFetching:o}=me(),{data:l,isFetching:c}=Vo(),{data:f,isFetching:d}=Se(),u=r||o||c||d,[E]=le(),g=E.get("page"),{data:T}=te(),{data:_,isFetching:w}=Ia(),{blocks:M}=Ca(_),{data:A,isFetching:C}=nn(),{pageStatus:I}=ne(),q=va(),{onSave:G}=Ra(),{mutateAsync:ce}=Ho(),{getPartialBlocks:ue,getPartialBlockBlocks:V}=Ma(),{mutateAsync:b}=Cr(),{mutateAsync:k}=rn(),{data:W}=zo(((_s=e.flags)==null?void 0:_s.designTokens)??!1),z=er(),[re,Pt]=h.useState(!1),de=h.useRef([]),be=h.useMemo(()=>p.get(f,"theme",{})||{},[f]),Pe=I===J.EDITING,sr=I===J.CHECKING,Ps=w||sr||C;de.current=M;const[nr]=H.useAtom(Zn);h.useEffect(()=>{const ee=()=>{document.hidden?Pt(!0):Pt(!1)};return window.addEventListener("visibilitychange",ee),()=>window.removeEventListener("visibilitychange",ee)},[]);const rr=h.useMemo(()=>{const ee={};return n&&(ee.permissions=p.get(n,"permissions",null),ee.role=p.get(n,"role","user")),ee},[n]),xs=h.useMemo(()=>t==null?void 0:t.some(ee=>ee.isSiteLibrary),[t]),ar=h.useCallback(async(ee,xt)=>await b({pageType:ee,query:xt}),[b]);return i.jsxs(i.Fragment,{children:[Ps&&i.jsx(ms,{className:u?"fixed inset-0 bg-white":"bg-white/75",children:i.jsx(x.Loader,{className:`animate-spin text-primary ${u?"h-6 w-6":"h-5 w-5"}`})}),nr&&i.jsx(h.Suspense,{fallback:i.jsx("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:i.jsx(x.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:i.jsx(Xo,{})}),i.jsx(m.ChaiBuilderEditor,{siteWideUsage:W??{},flags:e.flags?{...e.flags,librarySite:xs}:{librarySite:xs},gotoPage:z,collections:l??[],getBlockAsyncProps:ce,pageExternalData:A,themePresets:e.themePresets??[],pageId:T==null?void 0:T.id,loading:w,fallbackLang:s,languages:(f==null?void 0:f.languages)||[],brandingOptions:(f==null?void 0:f.theme)||{},designTokens:(f==null?void 0:f.designTokens)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!re&&Pe&&(e.autoSave??!0),autoSaveActionsCount:e.autoSaveActionsCount??10,onError:e.onError||console.error,getPartialBlockBlocks:V,getPartialBlocks:ue,blocks:w?[]:M,theme:p.cloneDeep(be),pageTypes:a,searchPageTypeItems:ar,askAiCallBack:q,onSave:async({blocks:ee,theme:xt,needTranslations:ir,designTokens:ws})=>{if(!g)return!0;de.current=ee;const vs=[...ee];await G({page:g,blocks:vs,needTranslations:ir}),de.current=vs;const _t={};return p.isEqual(xt,be)||(_t.theme=xt),p.isEqual(ws,f==null?void 0:f.designTokens)||(_t.designTokens=ws),p.isEmpty(_t)||await k({settings:_t}),!0},themePanelComponent:Zo,...rr,children:i.jsx($o,{isFetchingPageData:Ps})}),i.jsx("div",{children:i.jsx(Wo,{})})]})},tl=new S.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),sl=e=>{const[,t]=Ft(),[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?i.jsxs(i.Fragment,{children:[i.jsx(Fs,{...e}),i.jsx(Bs,{})]}):i.jsxs(S.QueryClientProvider,{client:tl,children:[i.jsx(Fs,{...e}),i.jsx(Bs,{})]}):i.jsx("div",{})},nl=Q.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-Cuk7NB-u.cjs")));function tr({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=Q.useState(!1);return i.jsxs(m.Popover,{open:r,onOpenChange:a,children:[i.jsxs(m.Tooltip,{children:[i.jsx(m.TooltipTrigger,{asChild:!0,children:i.jsx(m.PopoverTrigger,{asChild:!0,children:i.jsx(L.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:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:i.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"})})})})}),i.jsx(m.TooltipContent,{children:"Add field"})]}),r&&i.jsx(Q.Suspense,{children:i.jsx(nl,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const rl=()=>{const{savePageAsync:e}=m.useSavePage(),t=S.useQueryClient(),{isLocked:s}=ne();return h.useCallback(async()=>{s||await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t,s])},al=()=>{const e=S.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},il=()=>{const e=N(),t=j(),{data:s}=ge(),n=S.useQueryClient();return S.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")}})},ol=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-DHYRXaaq.cjs"))),ll=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:o}=he.useTranslation(),[l,c]=h.useState(!1),f=()=>{a||c(!0)},d=()=>{c(!1)},u=T=>{const _=Array.isArray(T)?T[0]:T;_!=null&&_.url&&s(p.pick(_,["url","id"])),c(!1)},E=()=>{s({url:"",id:""})},g=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return i.jsxs("div",{className:`w-full ${n}`,children:[t?i.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[g?i.jsx("div",{className:"flex h-12 items-center bg-gray-100 px-4",children:i.jsx("p",{className:"text-xs text-gray-500",children:t})}):i.jsx("img",{onClick:f,src:t,alt:o("Selected image"),className:"h-auto max-h-[100px] w-full bg-gray-100 object-contain"}),i.jsxs("div",{className:"absolute right-2 top-2 flex gap-2",children:[i.jsx(L.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:E,disabled:a,children:g?i.jsx(x.X,{className:"h-4 w-4"}):i.jsx(x.Trash2,{className:"h-4 w-4"})}),!g&&i.jsx(L.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:f,disabled:a,children:i.jsx(x.ImageIcon,{className:"h-4 w-4"})})]})]}):i.jsx("div",{className:`flex cursor-pointer items-center justify-center rounded-md border border-dashed p-6 ${a?"cursor-not-allowed opacity-50":"hover:border-gray-400"}`,onClick:f,children:i.jsxs("div",{className:"flex flex-col items-center gap-2",children:[i.jsx(x.ImageIcon,{className:"h-10 w-10 text-gray-400"}),i.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),i.jsx(m.Dialog,{open:l,onOpenChange:c,children:i.jsxs(m.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[i.jsxs(m.DialogHeader,{className:"hidden border-b px-4 py-2",children:[i.jsx(m.DialogTitle,{children:o("Select Image")}),i.jsx(L.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:d,children:i.jsx(x.X,{className:"h-4 w-4"})})]}),i.jsx("div",{className:"h-full flex-1 p-4",children:i.jsx(h.Suspense,{children:i.jsx(ol,{close:d,onSelect:u,mode:"image",assetId:e})})})]})})]})},cl=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),os=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};try{return{isValid:!0,parsed:JSON.parse(e),error:null,placeholders:[]}}catch{}const t=/{{([^{}]+)}}/g,s=[];let n=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],o=r.index,l=`"__placeholder_${s.length}__"`;s.push({original:a,replaced:l,position:o}),n=n.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(n),error:null,placeholders:s}}catch(a){const o=a,l=o.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let f,d;if(c!==void 0){const u=n.substring(0,c).split(`
2
+ `);f=u.length,d=u[u.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:o.message,line:f,column:d,position:c}}}},ul=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const o=`"__placeholder_${a}__"`,l=new RegExp(cl(o),"g");n=n.replace(l,r)}),n},dl=(e,t)=>{if(!e)return"";let s=JSON.stringify(e,null,2);const n=/{{([^{}]+)}}/g;let r;for(;(r=n.exec(s))!==null;){const a=r[1],o=p.get(t,a,null);s=s.replace(r[0],o)}return s},fl=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-Cn3MCW6I.cjs"))),hl=({value:e,onChange:t,disabled:s=!1,readOnly:n=!1,placeholder:r="Enter JSON",rows:a=6,id:o="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:f,copyJsonLDFromDefaultPage:d})=>{const[u,E]=h.useState("edit"),[g,T]=h.useState(null),[_,w]=h.useState(""),M=h.useRef(null),[A]=Ft(),C=o==="jsonLD"&&p.get(A,"features.sharedJsonLD",!1),I=o==="jsonLD"&&!f&&!!d;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const q=V=>{if(n)return;const b=V.target.value;t(b)},G=V=>{if(V.key==="Tab"){V.preventDefault();const b=V.currentTarget,k=b.selectionStart,W=b.selectionEnd;if(k!==W){const re=e.substring(k,W).split(`
3
+ `);if(V.shiftKey){const de=re.map(Pe=>Pe.startsWith(" ")?Pe.substring(2):Pe).join(`
4
+ `),be=e.substring(0,k)+de+e.substring(W);t(be),setTimeout(()=>{b.selectionStart=k,b.selectionEnd=k+de.length},0)}else{const de=re.map(Pe=>` ${Pe}`).join(`
5
+ `),be=e.substring(0,k)+de+e.substring(W);t(be),setTimeout(()=>{b.selectionStart=k,b.selectionEnd=k+de.length},0)}}else{const z=e.substring(0,k)+" "+e.substring(W);t(z),setTimeout(()=>{b.selectionStart=b.selectionEnd=k+2},0)}}};h.useEffect(()=>{const V=os(e);V.isValid?h.startTransition(()=>{if(T(null),V.parsed){const b=dl(V.parsed,l);w(b)}else w("")}):h.startTransition(()=>{T(V.error),w("")})},[e,l]);const ce=()=>{const V=os(e);if(V.isValid&&V.parsed){const b=ul(V.parsed,V.placeholders);t(b)}},ue=()=>{g!=null&&g.position&&M.current&&(M.current.focus(),M.current.setSelectionRange(g.position,g.position+1))};return i.jsx(Er.ErrorBoundary,{fallback:i.jsx("div",{children:"Some error"}),children:i.jsx("div",{className:"space-y-2",children:i.jsxs(m.Tabs,{value:u,onValueChange:E,className:"w-full",children:[i.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[i.jsxs(m.TabsList,{className:"w-max",children:[i.jsxs(m.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[i.jsx(x.Code,{className:"h-4 w-4"}),i.jsx("span",{children:"Edit"})]}),i.jsxs(m.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||g!==null||I,children:[i.jsx(x.Eye,{className:"h-4 w-4"}),i.jsx("span",{children:"Preview"})]}),C&&i.jsxs(m.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||g!==null,children:[i.jsx(x.Share2,{className:"h-4 w-4"}),i.jsx("span",{children:"Shared"})]})]}),I?null:u==="edit"&&!n&&i.jsx("div",{className:"flex items-center gap-2",children:i.jsx(tr,{dataType:"value",data:l??{},onSelect:V=>c&&c(V,o)})})]}),i.jsxs(m.TabsContent,{value:"edit",className:"relative mt-0",children:[!I&&u==="edit"&&i.jsx(Vt,{content:"Format JSON",side:"right",showTooltip:!s&&!g,children:i.jsx(L.Button,{type:"button",variant:"outline",size:"icon",onClick:ce,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||g!==null,children:i.jsx(x.FileCode2,{})})}),I?i.jsx("div",{className:"flex h-40 items-center justify-center rounded-md bg-black/20",children:i.jsxs("div",{className:"flex max-w-[400px] flex-col items-center gap-2 rounded-md bg-white p-4 shadow-lg",children:[i.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."}),i.jsxs(L.Button,{type:"button",variant:"default",size:"sm",onClick:d,children:[i.jsx(x.Plus,{}),"Copy & Edit from default language"]})]})}):i.jsx(m.Textarea,{ref:M,id:o,name:o,className:`rounded-md border border-input text-xs ${g?"border-red-500":""}`,onChange:q,onKeyDown:G,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),g&&i.jsxs(L.Alert,{variant:"destructive",className:"mt-2",children:[i.jsx(x.AlertTriangle,{className:"h-4 w-4"}),i.jsxs(L.AlertDescription,{className:"flex flex-col",children:[i.jsx("span",{className:"font-medium",children:"Invalid JSON"}),i.jsx("span",{className:"text-sm",children:g.message}),g.line&&g.column&&i.jsxs("span",{className:"text-sm",children:["Error at line ",g.line,", column ",g.column]}),i.jsx(L.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:ue,children:"Show position"})]})]})]}),i.jsxs(m.TabsContent,{value:"preview",className:"mt-0",children:[i.jsx(m.Textarea,{rows:a,value:_,readOnly:!0,className:"cursor-default bg-muted font-mono text-sm"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This is how the JSON will look after placeholder substitution."})]}),C&&i.jsx(m.TabsContent,{value:"shared",className:"mt-0",children:i.jsx(h.Suspense,{children:i.jsx(fl,{})})})]})})})},gl=e=>{const t=N(),s=j();return S.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"})};if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=ps;exports.ACTIONS=y;exports.BlurContainer=ms;exports.ChaiWebsiteBuilder=sl;exports.Dynamic=$i;exports.EVENT=X;exports.For=Ti;exports.ImagePicker=ll;exports.Index=Ai;exports.LANGUAGES=Ye;exports.LanguageSwitcher=en;exports.Match=xi;exports.NestedPathSelector=tr;exports.PAGES_PERMISSIONS=se;exports.PAGE_STATUS=J;exports.PageActionsDropdown=Ws;exports.PermissionChecker=Ct;exports.Portal=Qi;exports.Show=Si;exports.SmartJsonInput=hl;exports.Switch=Pi;exports.Tooltip=Vt;exports.addEventListener=In;exports.addNewLangAtom=st;exports.batch=si;exports.className=Cn;exports.clearDelegatedEvents=Oi;exports.convertRemToPixels=Ro;exports.createComponent=As;exports.createComputed=mn;exports.createContext=oi;exports.createEffect=ys;exports.createMemo=$;exports.createRenderEffect=ye;exports.createRoot=pe;exports.createSignal=K;exports.createUniqueId=yi;exports.delegateEvents=bn;exports.deleteNestedDataByPath=Xe;exports.displayValue=No;exports.getMutationStatusColor=Io;exports.getPreferredColorScheme=Mo;exports.getQueryStatusColor=Co;exports.getQueryStatusColorByLabel=Lo;exports.getQueryStatusLabel=vo;exports.getSidedProp=bo;exports.insert=Bt;exports.memo=Gi;exports.mergeProps=Ss;exports.mutationSortFns=Oo;exports.navigateToPage=gs;exports.on=ni;exports.onCleanup=ze;exports.onMount=En;exports.parseJSONWithPlaceholders=os;exports.previewUrlAtom=Zn;exports.serialize=$n;exports.setAttribute=Ut;exports.sortFns=ko;exports.splitProps=xn;exports.spread=Ln;exports.stringify=wo;exports.template=Di;exports.throwConfetti=It;exports.untrack=Y;exports.updateNestedDataByPath=Ze;exports.use=Nn;exports.useActivePage=ge;exports.useAddGlobalSchema=La;exports.useApiUrl=N;exports.useApplySchemaToAllPages=ka;exports.useBuilderFetch=Ar;exports.useBuilderPageData=nn;exports.useChaiAuth=qt;exports.useChaiCurrentPage=te;exports.useChaiUserInfo=gl;exports.useChaibuilderRealtime=Ur;exports.useChangePage=Xn;exports.useChangeSlug=ca;exports.useClearAll=al;exports.useContext=li;exports.useCreatePage=na;exports.useCurrentPageOwner=Js;exports.useDeleteGlobalSchema=ja;exports.useDeletePage=aa;exports.useDynamicPageSelector=zs;exports.useFallbackLang=Kt;exports.useFetch=j;exports.useGotoPage=er;exports.useIsLanguagePageCreated=tn;exports.useLanguagePages=Ae;exports.useMarkAsTemplate=oa;exports.usePageEditInfo=cs;exports.usePageLockMeta=ds;exports.usePageLockStatus=ne;exports.usePageToUser=us;exports.usePageType=$s;exports.usePageTypes=me;exports.usePagesProps=Ft;exports.usePublishPages=Es;exports.useReloadPage=rl;exports.useRemoveSchemaFromAllPages=Da;exports.useSearchParams=le;exports.useSendRealtimeEvent=Zs;exports.useTogglePageGlobalSchema=Ga;exports.useTransition=ii;exports.useUnmarkAsTemplate=la;exports.useUnpublishPage=ia;exports.useUpdateActivePageMetadata=il;exports.useUpdateGlobalSchema=Na;exports.useUpdatePage=ra;exports.useUpdateWebsiteSettings=rn;exports.useUserId=At;exports.useUserRoleAndPermissions=an;exports.useWebsiteLanguagePages=Br;exports.useWebsitePages=hs;exports.useWebsiteSetting=Se;
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("./index-DF5DEvqb.cjs"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-WQwzsC7A.cjs"),B=require("@tanstack/react-query");function H(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return B.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=u=>u==="draft"||u==="live"?u:"revision",s=u=>p.replace(u.uid,`${u.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:f?0:1/0})}const K=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",f=t.label==="draft";return e.jsxs("span",{className:`flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":f?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":f?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:f?"Currently editing":"Published by"}),!f&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),e.jsx("div",{className:"text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},L=({version:t})=>e.jsx(K,{version:t});function V(t,r,o="data.json"){const n=JSON.stringify(t,null,2),f=JSON.stringify(r,null,2),l=n.split(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./index-B0e71wJ1.cjs"),L=require("./register-chai-top-bar-BqwKw4uy.cjs"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-DKuwxj1x.cjs"),H=require("@tanstack/react-query");function K(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return H.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=u=>u==="draft"||u==="live"?u:"revision",s=u=>p.replace(u.uid,`${u.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:f?0:1/0})}const V=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",f=t.label==="draft";return e.jsxs("span",{className:`flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":f?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":f?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:f?"Currently editing":"Published by"}),!f&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),e.jsx("div",{className:"text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},F=({version:t})=>e.jsx(V,{version:t});function U(t,r,o="data.json"){const n=JSON.stringify(t,null,2),f=JSON.stringify(r,null,2),l=n.split(`
2
2
  `),s=f.split(`
3
3
  `);let d=`--- a/${o}
4
4
  `;d+=`+++ b/${o}
5
- `;const u=[];let c=0,m=0;for(;c<l.length||m<s.length;){const g=l[c]||"",v=s[m]||"";if(g===v)u.push(` ${g}`),c++,m++;else{let h=-1,j=-1;for(let a=c+1;a<l.length;a++)if(s[m]===l[a]){h=a;break}for(let a=m+1;a<s.length;a++)if(l[c]===s[a]){j=a;break}if(h!==-1&&(j===-1||h-c<=j-m)){for(let a=c;a<h;a++)u.push(`-${l[a]}`);c=h}else if(j!==-1){for(let a=m;a<j;a++)u.push(`+${s[a]}`);m=j}else g&&u.push(`-${g}`),v&&u.push(`+${v}`),c++,m++}}const w=l.length,J=s.length;return d+=`@@ -1,${w} +1,${J} @@
5
+ `;const u=[];let c=0,x=0;for(;c<l.length||x<s.length;){const g=l[c]||"",v=s[x]||"";if(g===v)u.push(` ${g}`),c++,x++;else{let h=-1,j=-1;for(let a=c+1;a<l.length;a++)if(s[x]===l[a]){h=a;break}for(let a=x+1;a<s.length;a++)if(l[c]===s[a]){j=a;break}if(h!==-1&&(j===-1||h-c<=j-x)){for(let a=c;a<h;a++)u.push(`-${l[a]}`);c=h}else if(j!==-1){for(let a=x;a<j;a++)u.push(`+${s[a]}`);x=j}else g&&u.push(`-${g}`),v&&u.push(`+${v}`),c++,x++}}const w=l.length,J=s.length;return d+=`@@ -1,${w} +1,${J} @@
6
6
  `,d+=u.join(`
7
7
  `)+`
8
- `,d}function T(t,r=!0,o=!1){if(p.isString(t)){const n=p.trim(t);if(p.startsWith(n,"{")||p.startsWith(n,"[")||r&&(n==="true"||n==="false"||n==="null"||/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(n)))try{const l=JSON.parse(n);return T(l,r,o)}catch{if(o)throw new Error(`Invalid JSON string: ${n}`);return{}}return t}return p.isArray(t)?p.map(t,n=>T(n,r,o)):p.isPlainObject(t)?p.mapValues(t,n=>T(n,r,o)):t}const U=t=>{switch(t){case"blocks":return"Blocks";case"seo":return"SEO";case"tracking":return"Tracking";default:return t}},W=(t,r)=>{if(!t||!r)return[{key:"blocks",label:"Blocks"}];const o=Object.keys(t),n=Object.keys(r);return o.filter(s=>n.includes(s)).map(s=>({key:s,label:U(s)})).filter(s=>s.key.length>0)},_=(t,r=3)=>{const o=new Set;t.map((s,d)=>({change:s,index:d})).filter(({change:s})=>s.type!=="normal").map(({index:s})=>s).forEach(s=>{const d=Math.max(0,s-r),u=Math.min(t.length-1,s+r);for(let c=d;c<=u;c++)o.add(c)});const f=[];let l=-1;return t.forEach((s,d)=>{if(o.has(d)){if(l!==-1&&d-l>1){const u=t[l].lineNumber!=null?t[l].lineNumber+1:l+2,c=t[d].lineNumber!=null?t[d].lineNumber-1:d;f.push({content:e.jsx(x.Badge,{className:"pointer-events-none w-60 -translate-x-1/2 cursor-default border-none bg-transparent py-1 shadow-none",children:e.jsxs("span",{className:"rounded border border-border bg-muted px-3 py-1 text-xs font-light leading-none text-muted-foreground",children:["No changes from ",u," to ",c," line"]})})})}f.push(s),l=d}}),f};function P({open:t,compare:r,onOpenChange:o}){const n=r[0],f=r[1],[l,s]=b.useState(null),[d,u]=b.useState("split"),[c,m]=b.useState(!1),[w,J]=b.useState(!0),[g,v]=b.useState("blocks"),{data:h,isLoading:j}=H(n,f),{leftData:a,rightData:k,options:F}=b.useMemo(()=>{var y,R;const i=(y=h==null?void 0:h.version1)==null?void 0:y[g],C=(R=h==null?void 0:h.version2)==null?void 0:R[g],S=T(i),D=T(C),q=W(h==null?void 0:h.version1,h==null?void 0:h.version2);return{leftData:S,rightData:D,options:q}},[h,g]),$=b.useMemo(()=>!a||!k?"":V(a,k),[a,k]),A=b.useMemo(()=>{if(!$)return[];try{return M.parseDiff($)}catch(i){return console.error("Failed to parse diff:",i),[]}},[$]),I=async(i,C)=>{try{await navigator.clipboard.writeText(JSON.stringify(i,null,2)),s(C),setTimeout(()=>s(null),2e3)}catch(S){console.error("Failed to copy:",S)}},E=i=>JSON.stringify(i,null,2);return e.jsx(x.Dialog,{open:t,onOpenChange:o,children:e.jsxs(x.DialogContent,{className:"flex h-[90vh] w-[95vw] max-w-[1900px] flex-col p-6",children:[e.jsx(x.DialogHeader,{className:"pb-4 pt-0",children:e.jsxs(x.DialogTitle,{className:"flex items-center justify-between gap-2 leading-none",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N.FileJson,{className:"h-5 w-5"}),"Compare","",F.map(i=>e.jsx("div",{className:`cursor-pointer rounded-full border px-2.5 py-1 text-xs leading-none ${g===i.key?"border-blue-500 bg-blue-500 text-white":"border-gray-600 text-gray-600 hover:bg-gray-200"}`,onClick:()=>v(i.key),children:i.label},i.key))]}),e.jsx("div",{className:"flex flex-1 items-center justify-end pr-8",children:e.jsxs("div",{className:"flex w-max items-center justify-end gap-2 rounded-md border px-1.5 py-1",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{disabled:c,checked:c?!0:d==="split",onCheckedChange:i=>u(i?"split":"unified")}),e.jsx("label",{className:"text-sm",children:"Split View"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{checked:c,onCheckedChange:i=>m(i)}),e.jsx("label",{className:"text-sm",children:"Show Raw Data"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{checked:w,onCheckedChange:i=>J(i)}),e.jsx("label",{className:"text-sm",children:"Hide Common Data"})]})]})})]})}),j?e.jsx("div",{className:"flex h-full w-full items-center justify-center",children:e.jsx(N.Loader,{className:"h-6 w-6 animate-spin text-primary"})}):e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsxs("div",{className:"relative min-h-0 flex-1",children:[e.jsxs("div",{className:"absolute -top-5 z-50 mt-0.5 flex w-full items-center justify-between gap-2",children:[e.jsx("div",{className:"flex w-1/2 items-center justify-center gap-2",children:e.jsx(L,{version:n})}),e.jsx("div",{className:"flex w-1/2 items-center justify-center gap-2",children:e.jsx(L,{version:f})})]}),c?e.jsxs("div",{className:"grid h-full grid-cols-2 gap-3 rounded-lg border",children:[e.jsxs("div",{className:"relative flex min-h-0 flex-col border-r",children:[e.jsx("div",{className:"absolute -top-4 right-4 z-50",children:e.jsxs(x.Button,{variant:"outline",size:"sm",onClick:()=>I(a,"left"),children:[l==="left"?e.jsx(N.Check,{className:"text-green-500"}):e.jsx(N.Copy,{}),"Copy"]})}),e.jsx(x.ScrollArea,{className:"flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:E(a)})})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-col",children:[e.jsx("div",{className:"absolute -top-4 right-4 z-50",children:e.jsxs(x.Button,{variant:"outline",size:"sm",onClick:()=>I(k,"right"),children:[l==="right"?e.jsx(N.Check,{className:"text-green-500"}):e.jsx(N.Copy,{}),"Copy"]})}),e.jsx(x.ScrollArea,{className:"flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:E(k)})})]})]}):e.jsx(x.ScrollArea,{className:"h-full overflow-y-auto rounded-lg border bg-slate-50 text-xs dark:bg-slate-900",children:A.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(N.FileJson,{className:"mx-auto mb-2 h-8 w-8 opacity-50"}),e.jsx("p",{children:"No differences found or unable to parse diff"})]})}):e.jsx("div",{children:A.map((i,C)=>e.jsx("div",{className:"relative mb-4",children:e.jsx(M.Diff,{viewType:d,diffType:i.type,hunks:i.hunks,className:"rounded-lg text-xs",children:S=>S.map((D,q)=>{const y=w?_(D.changes):D.changes;return(y==null?void 0:y.length)===0?e.jsx("div",{className:"absolute h-full w-full border-l pt-64 text-center font-sans text-sm",children:e.jsx("span",{children:"No difference found"})}):e.jsx(M.Hunk,{hunk:{...D,changes:y}},q)})},w?"hide-common-data":"show-common-data")},C))})})]})})]})})}exports.default=P;
8
+ `,d}function T(t,r=!0,o=!1){if(p.isString(t)){const n=p.trim(t);if(p.startsWith(n,"{")||p.startsWith(n,"[")||r&&(n==="true"||n==="false"||n==="null"||/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(n)))try{const l=JSON.parse(n);return T(l,r,o)}catch{if(o)throw new Error(`Invalid JSON string: ${n}`);return{}}return t}return p.isArray(t)?p.map(t,n=>T(n,r,o)):p.isPlainObject(t)?p.mapValues(t,n=>T(n,r,o)):t}const W=t=>{switch(t){case"blocks":return"Blocks";case"seo":return"SEO";case"tracking":return"Tracking";default:return t}},_=(t,r)=>{if(!t||!r)return[{key:"blocks",label:"Blocks"}];const o=Object.keys(t),n=Object.keys(r);return o.filter(s=>n.includes(s)).map(s=>({key:s,label:W(s)})).filter(s=>s.key.length>0)},P=(t,r=3)=>{const o=new Set;t.map((s,d)=>({change:s,index:d})).filter(({change:s})=>s.type!=="normal").map(({index:s})=>s).forEach(s=>{const d=Math.max(0,s-r),u=Math.min(t.length-1,s+r);for(let c=d;c<=u;c++)o.add(c)});const f=[];let l=-1;return t.forEach((s,d)=>{if(o.has(d)){if(l!==-1&&d-l>1){const u=t[l].lineNumber!=null?t[l].lineNumber+1:l+2,c=t[d].lineNumber!=null?t[d].lineNumber-1:d;f.push({content:e.jsx(m.Badge,{className:"pointer-events-none w-60 -translate-x-1/2 cursor-default border-none bg-transparent py-1 shadow-none",children:e.jsxs("span",{className:"rounded border border-border bg-muted px-3 py-1 text-xs font-light leading-none text-muted-foreground",children:["No changes from ",u," to ",c," line"]})})})}f.push(s),l=d}}),f};function G({open:t,compare:r,onOpenChange:o}){const n=r[0],f=r[1],[l,s]=b.useState(null),[d,u]=b.useState("split"),[c,x]=b.useState(!1),[w,J]=b.useState(!0),[g,v]=b.useState("blocks"),{data:h,isLoading:j}=K(n,f),{leftData:a,rightData:k,options:B}=b.useMemo(()=>{var y,R;const i=(y=h==null?void 0:h.version1)==null?void 0:y[g],C=(R=h==null?void 0:h.version2)==null?void 0:R[g],S=T(i),D=T(C),q=_(h==null?void 0:h.version1,h==null?void 0:h.version2);return{leftData:S,rightData:D,options:q}},[h,g]),$=b.useMemo(()=>!a||!k?"":U(a,k),[a,k]),A=b.useMemo(()=>{if(!$)return[];try{return M.parseDiff($)}catch(i){return console.error("Failed to parse diff:",i),[]}},[$]),I=async(i,C)=>{try{await navigator.clipboard.writeText(JSON.stringify(i,null,2)),s(C),setTimeout(()=>s(null),2e3)}catch(S){console.error("Failed to copy:",S)}},E=i=>JSON.stringify(i,null,2);return e.jsx(m.Dialog,{open:t,onOpenChange:o,children:e.jsxs(m.DialogContent,{className:"flex h-[90vh] w-[95vw] max-w-[1900px] flex-col p-6",children:[e.jsx(m.DialogHeader,{className:"pb-4 pt-0",children:e.jsxs(m.DialogTitle,{className:"flex items-center justify-between gap-2 leading-none",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N.FileJson,{className:"h-5 w-5"}),"Compare","",B.map(i=>e.jsx("div",{className:`cursor-pointer rounded-full border px-2.5 py-1 text-xs leading-none ${g===i.key?"border-blue-500 bg-blue-500 text-white":"border-gray-600 text-gray-600 hover:bg-gray-200"}`,onClick:()=>v(i.key),children:i.label},i.key))]}),e.jsx("div",{className:"flex flex-1 items-center justify-end pr-8",children:e.jsxs("div",{className:"flex w-max items-center justify-end gap-2 rounded-md border px-1.5 py-1",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(m.Switch,{disabled:c,checked:c?!0:d==="split",onCheckedChange:i=>u(i?"split":"unified")}),e.jsx("label",{className:"text-sm",children:"Split View"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(m.Switch,{checked:c,onCheckedChange:i=>x(i)}),e.jsx("label",{className:"text-sm",children:"Show Raw Data"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(m.Switch,{checked:w,onCheckedChange:i=>J(i)}),e.jsx("label",{className:"text-sm",children:"Hide Common Data"})]})]})})]})}),j?e.jsx("div",{className:"flex h-full w-full items-center justify-center",children:e.jsx(N.Loader,{className:"h-6 w-6 animate-spin text-primary"})}):e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsxs("div",{className:"relative min-h-0 flex-1",children:[e.jsxs("div",{className:"absolute -top-5 z-50 mt-0.5 flex w-full items-center justify-between gap-2",children:[e.jsx("div",{className:"flex w-1/2 items-center justify-center gap-2",children:e.jsx(F,{version:n})}),e.jsx("div",{className:"flex w-1/2 items-center justify-center gap-2",children:e.jsx(F,{version:f})})]}),c?e.jsxs("div",{className:"grid h-full grid-cols-2 gap-3 rounded-lg border",children:[e.jsxs("div",{className:"relative flex min-h-0 flex-col border-r",children:[e.jsx("div",{className:"absolute -top-4 right-4 z-50",children:e.jsxs(L.Button,{variant:"outline",size:"sm",onClick:()=>I(a,"left"),children:[l==="left"?e.jsx(N.Check,{className:"text-green-500"}):e.jsx(N.Copy,{}),"Copy"]})}),e.jsx(m.ScrollArea,{className:"flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:E(a)})})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-col",children:[e.jsx("div",{className:"absolute -top-4 right-4 z-50",children:e.jsxs(L.Button,{variant:"outline",size:"sm",onClick:()=>I(k,"right"),children:[l==="right"?e.jsx(N.Check,{className:"text-green-500"}):e.jsx(N.Copy,{}),"Copy"]})}),e.jsx(m.ScrollArea,{className:"flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:E(k)})})]})]}):e.jsx(m.ScrollArea,{className:"h-full overflow-y-auto rounded-lg border bg-slate-50 text-xs dark:bg-slate-900",children:A.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(N.FileJson,{className:"mx-auto mb-2 h-8 w-8 opacity-50"}),e.jsx("p",{children:"No differences found or unable to parse diff"})]})}):e.jsx("div",{children:A.map((i,C)=>e.jsx("div",{className:"relative mb-4",children:e.jsx(M.Diff,{viewType:d,diffType:i.type,hunks:i.hunks,className:"rounded-lg text-xs",children:S=>S.map((D,q)=>{const y=w?P(D.changes):D.changes;return(y==null?void 0:y.length)===0?e.jsx("div",{className:"absolute h-full w-full border-l pt-64 text-center font-sans text-sm",children:e.jsx("span",{children:"No difference found"})}):e.jsx(M.Hunk,{hunk:{...D,changes:y}},q)})},w?"hide-common-data":"show-common-data")},C))})})]})})]})})}exports.default=G;
@@ -1,11 +1,12 @@
1
1
  import { jsx as e, jsxs as h } from "react/jsx-runtime";
2
- import { D as V, d as _, e as q, f as G, aj as $, a5 as I, B as z, ak as P } from "./index-Ct7ElCGK.js";
2
+ import { D as V, d as _, e as q, f as G, af as $, a2 as I, ag as P } from "./index-CAhEmHYP.js";
3
+ import { B as z } from "./register-chai-top-bar-ESJHs5s-.js";
3
4
  import { formatDate as Q } from "date-fns";
4
5
  import { startsWith as T, replace as W, isString as X, trim as Y, isArray as Z, map as ee, isPlainObject as te, mapValues as re } from "lodash-es";
5
6
  import { FileJson as B, Loader as ne, Check as F, Copy as H } from "lucide-react";
6
7
  import { useState as D, useMemo as A } from "react";
7
8
  import { parseDiff as se, Diff as le, Hunk as ae } from "react-diff-view";
8
- import { ar as ie, as as oe, A as ce, ap as de } from "./index-ZuacEL1j.js";
9
+ import { ar as ie, as as oe, A as ce, ap as de } from "./index-Bn0fFN58.js";
9
10
  import { useQuery as fe } from "@tanstack/react-query";
10
11
  function me(t, n) {
11
12
  const o = ie(), s = oe(), u = T(t.uid, "draft:") || T(n.uid, "live:");
@@ -156,7 +157,7 @@ const pe = (t) => {
156
157
  }
157
158
  }), u;
158
159
  };
159
- function Te({ open: t, compare: n, onOpenChange: o }) {
160
+ function je({ open: t, compare: n, onOpenChange: o }) {
160
161
  const s = n[0], u = n[1], [l, r] = D(null), [d, f] = D("split"), [c, p] = D(!1), [y, j] = D(!0), [g, N] = D("blocks"), { data: m, isLoading: x } = me(s, u), { leftData: a, rightData: w, options: U } = A(() => {
161
162
  var b, R;
162
163
  const i = (b = m == null ? void 0 : m.version1) == null ? void 0 : b[g], v = (R = m == null ? void 0 : m.version2) == null ? void 0 : R[g], k = S(i), C = S(v), J = ge(m == null ? void 0 : m.version1, m == null ? void 0 : m.version2);
@@ -254,5 +255,5 @@ function Te({ open: t, compare: n, onOpenChange: o }) {
254
255
  ] }) });
255
256
  }
256
257
  export {
257
- Te as default
258
+ je as default
258
259
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-BqwKw4uy.cjs"),a=require("./index-B0e71wJ1.cjs"),n=require("./index-DKuwxj1x.cjs"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),I=require("react-i18next"),L=require("sonner"),k=require("jotai"),M=({page:s,onClose:p})=>{const{t:l}=I.useTranslation(),[o,P]=c.useState(s.slug||""),{mutate:y,isPending:f}=n.useChangeSlug(),{data:i}=n.usePageTypes(),d=r.find(i,{key:s==null?void 0:s.pageType}),E=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(S=>o===`/${S}`||r.startsWith(o,`/${S}/`))){L.toast.error(l("Error"),{description:l("Slugs cannot start with a language code for primary page")});return}y({...s,slug:o},{onSuccess:p})},m=(s==null?void 0:s.lang)||"";return e.jsx(a.Dialog,{open:!!s,onOpenChange:p,children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:l("Change Slug")}),e.jsx(a.DialogDescription,{className:"text-xs",children:e.jsxs(N.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),l("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:E,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[l("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[l("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(a.Label,{htmlFor:"slug",className:"text-right",children:[l("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[l("Slug should start with")," /",m]})]}),e.jsx(N.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&P(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:l("Slug must start with /"),placeholder:l("Enter page slug")})]})]}),e.jsx(a.DialogFooter,{children:e.jsx(N.Button,{type:"submit",disabled:f||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:l(f?"Changing...":"Change Slug")})})]})]})})},T=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-Djn97HiP.cjs"))),q=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BT5bCfs6.cjs"))),_=()=>{const{t:s}=I.useTranslation(),p=k.useSetAtom(n.addNewLangAtom),{selectedLang:l,fallbackLang:o,setSelectedLang:P}=a.useLanguages(),{data:y,isFetching:f}=n.useLanguagePages(),{data:i}=n.useChaiCurrentPage(),{data:d}=n.usePageTypes(),E=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(i==null?void 0:i.pageType));return i!=null&&i.dynamic?t==null?void 0:t.dynamicSlug:""},[d,i==null?void 0:i.pageType,i==null?void 0:i.dynamic]),[m,h]=c.useState(null),[x,C]=c.useState(null),[S,A]=c.useState(null),{data:b}=n.useWebsiteSetting(),D=r.filter(r.get(b,"languages")||["en"],t=>!r.find(y,{lang:t})&&t!==r.get(b,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:f?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(y,t=>{const g=t.lang,v=t.slug,w=!t.primaryPage,G=g===l;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${G?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>P(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,w?o:g,g)]}),e.jsxs("div",{children:[v&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:E?`${v}/${E}`:v})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),w?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(N.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(a.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),p({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),C(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(N.Button,{variant:"default",size:"sm",disabled:r.isEmpty(D),onClick:()=>{p({primaryPage:i==null?void 0:i.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(T,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(q,{page:x,onClose:()=>C(null)})}),S&&e.jsx(c.Suspense,{children:e.jsx(M,{page:S,onClose:()=>A(null)})})]})};exports.default=_;
@@ -1,6 +1,7 @@
1
1
  import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
2
- import { D as j, d as F, e as B, f as H, p as O, A as W, L as q, I as R, q as J, B as A, n as K, r as Q, s as V, t as X, v as w } from "./index-Ct7ElCGK.js";
3
- import { au as Y, m as I, L as T, av as Z, l as ee, aw as se, j as ae, ax as f, ay as o } from "./index-ZuacEL1j.js";
2
+ import { D as j, z as F, B as A } from "./register-chai-top-bar-ESJHs5s-.js";
3
+ import { D as B, d as H, e as O, f as W, p as q, L as R, q as J, n as K, r as Q, s as V, t as X, v as w } from "./index-CAhEmHYP.js";
4
+ import { au as Y, m as T, L as I, av as Z, l as ee, aw as se, j as ae, ax as f, ay as o } from "./index-Bn0fFN58.js";
4
5
  import { find as G, startsWith as E, isEqual as ne, filter as te, get as D, map as le, isEmpty as ie } from "lodash-es";
5
6
  import { AlertCircle as re, StarIcon as ce, MoreHorizontal as oe, PencilIcon as de, Power as me, TrashIcon as ue } from "lucide-react";
6
7
  import { useState as S, useMemo as he, Suspense as L, lazy as z } from "react";
@@ -8,8 +9,8 @@ import { useTranslation as U } from "react-i18next";
8
9
  import { toast as ge } from "sonner";
9
10
  import { useSetAtom as pe } from "jotai";
10
11
  const fe = ({ page: a, onClose: g }) => {
11
- const { t: l } = U(), [i, v] = S(a.slug || ""), { mutate: N, isPending: y } = Y(), { data: t } = I(), r = G(t, { key: a == null ? void 0 : a.pageType }), x = (m) => {
12
- if (m.preventDefault(), !(a != null && a.primaryPage) && Object.keys(T).some((p) => i === `/${p}` || E(i, `/${p}/`))) {
12
+ const { t: l } = U(), [i, v] = S(a.slug || ""), { mutate: N, isPending: y } = Y(), { data: t } = T(), r = G(t, { key: a == null ? void 0 : a.pageType }), x = (m) => {
13
+ if (m.preventDefault(), !(a != null && a.primaryPage) && Object.keys(I).some((p) => i === `/${p}` || E(i, `/${p}/`))) {
13
14
  ge.error(l("Error"), {
14
15
  description: l("Slugs cannot start with a language code for primary page")
15
16
  });
@@ -17,10 +18,10 @@ const fe = ({ page: a, onClose: g }) => {
17
18
  }
18
19
  N({ ...a, slug: i }, { onSuccess: g });
19
20
  }, d = (a == null ? void 0 : a.lang) || "";
20
- return /* @__PURE__ */ e(j, { open: !!a, onOpenChange: g, children: /* @__PURE__ */ s(F, { children: [
21
- /* @__PURE__ */ s(B, { children: [
22
- /* @__PURE__ */ e(H, { children: l("Change Slug") }),
23
- /* @__PURE__ */ e(O, { className: "text-xs", children: /* @__PURE__ */ s(W, { variant: "destructive", className: "mt-2", children: [
21
+ return /* @__PURE__ */ e(B, { open: !!a, onOpenChange: g, children: /* @__PURE__ */ s(H, { children: [
22
+ /* @__PURE__ */ s(O, { children: [
23
+ /* @__PURE__ */ e(W, { children: l("Change Slug") }),
24
+ /* @__PURE__ */ e(q, { className: "text-xs", children: /* @__PURE__ */ s(j, { variant: "destructive", className: "mt-2", children: [
24
25
  /* @__PURE__ */ e(re, { className: "h-4 w-4" }),
25
26
  l("Changing the slug may have impact on your SEO. Please proceed with caution.")
26
27
  ] }) })
@@ -50,7 +51,7 @@ const fe = ({ page: a, onClose: g }) => {
50
51
  ] })
51
52
  ] }),
52
53
  /* @__PURE__ */ s("div", { className: "space-y-1", children: [
53
- /* @__PURE__ */ s(q, { htmlFor: "slug", className: "text-right", children: [
54
+ /* @__PURE__ */ s(R, { htmlFor: "slug", className: "text-right", children: [
54
55
  l("Slug"),
55
56
  " ",
56
57
  /* @__PURE__ */ s("small", { className: "font-light text-gray-500", children: [
@@ -60,7 +61,7 @@ const fe = ({ page: a, onClose: g }) => {
60
61
  ] })
61
62
  ] }),
62
63
  /* @__PURE__ */ e(
63
- R,
64
+ F,
64
65
  {
65
66
  id: "slug",
66
67
  value: i,
@@ -80,8 +81,8 @@ const fe = ({ page: a, onClose: g }) => {
80
81
  /* @__PURE__ */ e(J, { children: /* @__PURE__ */ e(A, { type: "submit", disabled: y || !E(i, `/${d}`) || ne(a == null ? void 0 : a.slug, i), children: l(y ? "Changing..." : "Change Slug") }) })
81
82
  ] })
82
83
  ] }) });
83
- }, Ne = z(() => import("./delete-page-BzyX9TN-.js")), ye = z(() => import("./unpublish-page-D4VwOlxc.js")), Pe = () => {
84
- const { t: a } = U(), g = pe(Z), { selectedLang: l, fallbackLang: i, setSelectedLang: v } = K(), { data: N, isFetching: y } = ee(), { data: t } = se(), { data: r } = I(), x = he(() => {
84
+ }, Ne = z(() => import("./delete-page-Dnf97ZHP.js")), ye = z(() => import("./unpublish-page-DLLLgY43.js")), ke = () => {
85
+ const { t: a } = U(), g = pe(Z), { selectedLang: l, fallbackLang: i, setSelectedLang: v } = K(), { data: N, isFetching: y } = ee(), { data: t } = se(), { data: r } = T(), x = he(() => {
85
86
  const n = r == null ? void 0 : r.find((h) => h.key === (t == null ? void 0 : t.pageType));
86
87
  return t != null && t.dynamic ? n == null ? void 0 : n.dynamicSlug : "";
87
88
  }, [r, t == null ? void 0 : t.pageType, t == null ? void 0 : t.dynamic]), [d, m] = S(null), [u, C] = S(null), [p, _] = S(null), { data: P } = ae(), $ = te(
@@ -105,7 +106,7 @@ const fe = ({ page: a, onClose: g }) => {
105
106
  /* @__PURE__ */ s("div", { className: "flex-1 gap-x-3", children: [
106
107
  /* @__PURE__ */ s("div", { className: "flex items-center gap-x-2 text-[13px] text-slate-800", children: [
107
108
  /* @__PURE__ */ e("div", { className: `h-2.5 w-2.5 rounded-full ${n.online ? "bg-green-300" : "bg-gray-300"}` }),
108
- D(T, k ? i : h, h)
109
+ D(I, k ? i : h, h)
109
110
  ] }),
110
111
  /* @__PURE__ */ s("div", { children: [
111
112
  b && /* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
@@ -211,5 +212,5 @@ const fe = ({ page: a, onClose: g }) => {
211
212
  ] });
212
213
  };
213
214
  export {
214
- Pe as default
215
+ ke as default
215
216
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./register-chai-top-bar-BqwKw4uy.cjs"),v=require("./index-B0e71wJ1.cjs"),Z=require("./apply-binding-IsUf6UWJ.cjs"),u=require("@radix-ui/react-icons"),$=require("jotai"),U=require("nanoid"),a=require("react"),Q=require("react-i18next"),p=require("sonner"),_=require("tailwind-merge"),q=t=>{const n=t.trim();return n.length===0||n.length>25?!1:/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(n)},H=(t,n,o,m=!1,i)=>{const x=t.trim();return x.length===0?"":x.length>25?o("Token name must be 25 characters or less"):/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(x)?Object.entries(n).find(([l,N])=>N.name===x&&(!m||l!==i))?o("Token name already exists"):"":o("Only alphanumeric characters and hyphens allowed")},K=t=>t.replace(/\s+/g,"-"),X=a.lazy(()=>Promise.resolve().then(()=>require("./delete-design-token-C6s-ESB_.cjs"))),J=a.lazy(()=>Promise.resolve().then(()=>require("./design-token-usage-OTd93kS8.cjs"))),Y=({tokenId:t,token:n,isDisabled:o,onEdit:m,onDelete:i})=>e.jsxs("div",{className:"group relative flex items-center justify-between overflow-hidden rounded border p-2 transition-all duration-150 hover:bg-muted/90",children:[e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:"text-xs font-semibold",children:n.name}),e.jsx("div",{className:"w-full max-w-52 truncate text-[10px] font-light",children:n.value})]}),e.jsxs("div",{className:"absolute right-1 top-1 flex flex-shrink-0 items-center opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:[e.jsx(a.Suspense,{fallback:null,children:e.jsx(J,{tokenId:t,tokenName:n.name,children:e.jsx(c.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 rounded-full p-0 hover:bg-primary/10 hover:text-primary",children:e.jsx(u.EyeOpenIcon,{className:"h-3 w-3"})})})}),e.jsx(c.Button,{variant:"ghost",size:"sm",onClick:()=>m(t),disabled:o,className:"h-6 w-6 rounded-full p-0 hover:bg-primary/10 hover:text-primary",children:e.jsx(u.Pencil1Icon,{className:"h-3 w-3"})}),e.jsx(a.Suspense,{fallback:null,children:e.jsx(X,{tokenName:n.name,tokenValue:n.value,onDelete:()=>i(t),children:e.jsx(c.Button,{variant:"ghost",size:"sm",disabled:o,className:"h-6 w-6 rounded-full p-0 hover:bg-destructive/10",children:e.jsx(u.TrashIcon,{className:"h-3 w-3 text-destructive"})})})})]})]}),ee=({})=>{const{t}=Q.useTranslation(),[n,o]=$.useAtom(v.chaiDesignTokensAtom),m=v.useIncrementActionsCount(),[i,x]=a.useState("view"),[j,k]=a.useState(null),[l,N]=a.useState(""),[h,b]=a.useState(""),[T,y]=a.useState(""),[w,E]=a.useState(""),[z,C]=a.useState(!1),f=a.useRef(null),I=a.useMemo(()=>Object.entries(n).filter(([,s])=>s.name.toLowerCase().includes(w.toLowerCase())||s.value.toLowerCase().includes(w.toLowerCase())),[n,w]);a.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const S=a.useCallback((s,r)=>{!j||i!=="edit"||!s.trim()||!r.trim()||!q(s)||Object.entries(n).find(([g,W])=>W.name===s.trim()&&g!==j)||(C(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{const g={...n,[j]:{name:s.trim(),value:r.trim()}};o(g),m(),C(!1)},250))},[j,i,n,o,m]),M=()=>{if(!l.trim()||!h.trim()){p.toast.error(t("Please fill in both token name and classes"));return}if(!q(l)){p.toast.error(t("Invalid design token name format"));return}if(Object.values(n).find(g=>g.name===l.trim())){p.toast.error(t("Token already exists"));return}const r=`${Z.DESIGN_TOKEN_PREFIX}${U.nanoid(12)}`,d={...n,[r]:{name:l.trim(),value:h.trim()}};o(d),m(),p.toast.success(t("Token added successfully")),A()},P=s=>{const r={...n};delete r[s],o(r),m(),p.toast.success(t("Token deleted successfully"))},R=s=>{const r=n[s];r&&(k(s),N(r.name),b(r.value),y(""),x("edit"))},B=()=>{k(null),N(""),b(""),y(""),x("add")},A=()=>{f.current&&clearTimeout(f.current),k(null),N(""),b(""),y(""),C(!1),x("view")},O=s=>{const r=K(s);N(r);const d=H(r,n,t,i==="edit",j||void 0);y(d),i==="edit"&&!d&&S(r,h)},D=s=>{b(s),i==="edit"&&!T&&l.trim()&&S(l,s)},L=s=>{const r=v.orderClassesByBreakpoint(v.removeDuplicateClasses(_.twMerge(h,s)));D(r)},F=s=>{const r=h.split(" ").filter(d=>d!==s).join(" ");D(r)},G=()=>{const s=i==="edit",r=t(s?"Edit Design Token":"Add Design Token"),d=t(s?"Update design token. Auto-saved.":"Create a reusable design token");return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-border/50 bg-muted p-1.5",children:[e.jsx(c.Button,{variant:"ghost",size:"sm",onClick:A,className:"h-6 w-6 rounded-full p-0 hover:bg-muted",children:e.jsx(u.ArrowLeftIcon,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:r}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d})]}),s&&z&&e.jsx("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:e.jsx("div",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-primary"})})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v.Label,{htmlFor:"token-name",className:"text-xs font-medium",children:t("Token Name")}),e.jsx(c.Input,{id:"token-name",placeholder:"Button-Primary",value:l,onChange:g=>O(g.target.value),className:"h-7 text-xs"}),T?e.jsx("span",{className:"text-[10px] text-destructive",children:T}):e.jsx("span",{className:"text-[10px] font-light text-muted-foreground",children:t("Button-Primary, Card-Header, Text-Large etc.")})]}),e.jsx(v.ManualClasses,{from:"designToken",classFromProps:h,onAddNew:L,onRemove:F}),!s&&e.jsxs("div",{className:"mt-3 flex items-center justify-end gap-2 pt-3",children:[e.jsx(c.Button,{variant:"outline",onClick:A,className:"h-7 text-xs",children:t("Cancel")}),e.jsx(c.Button,{onClick:M,disabled:!l.trim()||!h.trim()||!!T,className:"h-7 text-xs",children:t("Add Token")})]})]})]})},V=()=>e.jsxs(e.Fragment,{children:[Object.entries(n).length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(u.MagnifyingGlassIcon,{className:"absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(c.Input,{placeholder:t("Search tokens"),value:w,onChange:s=>E(s.target.value),className:"h-6 pl-7 text-xs"})]}),e.jsxs(c.Button,{variant:"outline",onClick:B,size:"sm",className:"h-6 border-primary text-xs text-primary hover:bg-primary/10 hover:text-primary",children:[e.jsx(u.PlusIcon,{className:"h-3 w-3"}),t("Add")]})]}),e.jsx("div",{className:"no-scrollbar flex flex-1 flex-col overflow-hidden pt-2",children:e.jsx(v.ScrollArea,{className:"h-full flex-1",children:e.jsxs("div",{className:"space-y-1",children:[Object.entries(n).length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-muted bg-muted/20 py-8",children:[e.jsx("div",{className:"mb-2 text-3xl",children:e.jsx(u.TokensIcon,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:t("No design tokens yet")}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:t("Create reusable design tokens to streamline your styling")}),e.jsxs(c.Button,{variant:"default",onClick:B,size:"sm",className:"mt-4 h-7 text-xs leading-tight",children:[e.jsx(u.PlusIcon,{className:"mr-1 h-3 w-3"}),t("Add first design token")]})]}):I.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-muted bg-muted/20 py-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx(u.MagnifyingGlassIcon,{className:"h-10 w-10 text-muted-foreground"})}),e.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:t("No tokens found")}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:t("No design tokens match your search")})]}):I.map(([s,r])=>e.jsx(Y,{token:r,tokenId:s,onEdit:R,onDelete:P,isDisabled:!1},s)),e.jsx("div",{className:"h-44"})]})})})]});return e.jsx("div",{className:"flex h-full w-full flex-col",children:i==="view"?V():G()})};exports.default=ee;