@chaibuilder/pages 0.17.10 → 0.17.12

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 (84) hide show
  1. package/dist/{2AITGKQY-CW6frR_j.cjs → 2AITGKQY-BEWmpMeB.cjs} +1 -1
  2. package/dist/{2AITGKQY-DQFtfYAc.js → 2AITGKQY-DdlXCCch.js} +2 -2
  3. package/dist/{NCMVHL6D-URUKohh5.cjs → NCMVHL6D-B5s3it0O.cjs} +1 -1
  4. package/dist/{NCMVHL6D-DjkLlYvC.js → NCMVHL6D-al9EBNaz.js} +2 -2
  5. package/dist/{ZDWCUMSJ-BufXbZ_h.cjs → ZDWCUMSJ-DP7083KI.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-BF7bF60j.js → ZDWCUMSJ-VYarDCOs.js} +1 -1
  7. package/dist/{active-in-another-tab-CLSHrmaH.js → active-in-another-tab-CqlFNgyP.js} +1 -1
  8. package/dist/{active-in-another-tab-CLhzUxeR.cjs → active-in-another-tab-D-_6zWws.cjs} +1 -1
  9. package/dist/{add-new-language-page-DEvWaLIe.js → add-new-language-page-D-EIH_KG.js} +2 -2
  10. package/dist/{add-new-language-page-xOwbmNJj.cjs → add-new-language-page-f3pkbC8c.cjs} +1 -1
  11. package/dist/{add-new-page-B0OggHcf.cjs → add-new-page-A7tqO7s9.cjs} +1 -1
  12. package/dist/{add-new-page-BNq_DIdw.js → add-new-page-DOPMVtXH.js} +1 -1
  13. package/dist/{ai-panel-content-NdOClQP-.cjs → ai-panel-content-CeFFzAeq.cjs} +1 -1
  14. package/dist/{ai-panel-content-ClRm3rSN.js → ai-panel-content-Cw7KS8Iz.js} +2 -2
  15. package/dist/{ai-panel-default-lang-DmSW0N9S.cjs → ai-panel-default-lang-BZ_ljHv2.cjs} +2 -2
  16. package/dist/{ai-panel-default-lang-Bs_Nu8Yz.js → ai-panel-default-lang-PCapbW1j.js} +3 -3
  17. package/dist/{ai-panel-other-lang-B36IELRv.cjs → ai-panel-other-lang-DCrHNyXS.cjs} +1 -1
  18. package/dist/{ai-panel-other-lang-BYP_eD9z.js → ai-panel-other-lang-Dn2tKImG.js} +3 -3
  19. package/dist/ai-prompt-input-9b6rLylJ.cjs +1 -0
  20. package/dist/{ai-prompt-input-i9ZufZMi.js → ai-prompt-input-jOFQ-8_t.js} +107 -113
  21. package/dist/{ai-translation-prompt-CnNrf57B.js → ai-translation-prompt-CS-mQOHq.js} +1 -1
  22. package/dist/{ai-translation-prompt-DKN6hrUF.cjs → ai-translation-prompt-hd5TMlql.cjs} +1 -1
  23. package/dist/{continue-editing-in-this-client-ChVlHB-G.cjs → continue-editing-in-this-client-pFPMr4LR.cjs} +1 -1
  24. package/dist/{continue-editing-in-this-client-XtL9c2a2.js → continue-editing-in-this-client-z0CVTX34.js} +1 -1
  25. package/dist/{delete-page-JsuCy3_9.js → delete-page-BFTuNSlS.js} +1 -1
  26. package/dist/{delete-page-CGeb5OY9.cjs → delete-page-DL74lxYB.cjs} +1 -1
  27. package/dist/{digital-asset-manager-CeuTVT2m.cjs → digital-asset-manager-CaXVt3EZ.cjs} +1 -1
  28. package/dist/{digital-asset-manager-Dr_rmq-s.js → digital-asset-manager-CcByfPoi.js} +1 -1
  29. package/dist/{duplicate-page-WQGy0j2w.cjs → duplicate-page-CM63Brzc.cjs} +1 -1
  30. package/dist/{duplicate-page-CbPlxaWw.js → duplicate-page-D4CtwyEj.js} +2 -2
  31. package/dist/{dynamic-page-selector-Cl1ui3R0.js → dynamic-page-selector-B3LPjMt5.js} +1 -1
  32. package/dist/{dynamic-page-selector-Bxc0QbN-.cjs → dynamic-page-selector-Csz2pKB7.cjs} +1 -1
  33. package/dist/{index-BoQkDiU0.js → index-B4cxEof7.js} +1382 -1321
  34. package/dist/index-DLPsza7R.cjs +5 -0
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.js +3 -3
  37. package/dist/{json-diff-viewer-C9Vtz001.js → json-diff-viewer-BxvfnruI.js} +1 -1
  38. package/dist/{json-diff-viewer-mAynlJ-t.cjs → json-diff-viewer-CP1CqGws.cjs} +1 -1
  39. package/dist/{lang-panel-_j4w2xyy.cjs → lang-panel-4qcZ7r_d.cjs} +1 -1
  40. package/dist/{lang-panel-Bbw7pLzm.js → lang-panel-RnkbDv6w.js} +2 -2
  41. package/dist/{mark-as-template-eaGMb1z4.js → mark-as-template-4Ghoxl99.js} +1 -1
  42. package/dist/{mark-as-template-Iecl3b9-.cjs → mark-as-template-DmOCvlX1.cjs} +1 -1
  43. package/dist/{no-language-page-content-BENe6zri.js → no-language-page-content-CfJSEyvP.js} +1 -1
  44. package/dist/{no-language-page-content-BNElMNrF.cjs → no-language-page-content-CiES2hgx.cjs} +1 -1
  45. package/dist/{no-language-page-dialog-CUBp8DfX.cjs → no-language-page-dialog-CA0RvERK.cjs} +1 -1
  46. package/dist/{no-language-page-dialog-B-9DnVeV.js → no-language-page-dialog-CrMNN-NZ.js} +2 -2
  47. package/dist/{page-creator-BA9amyHE.js → page-creator-Csa2adW4.js} +2 -2
  48. package/dist/{page-creator-ltZp2cvK.cjs → page-creator-Svz4sAs8.cjs} +1 -1
  49. package/dist/{page-lock-5Q89NXKg.js → page-lock-BJG3FOuQ.js} +2 -2
  50. package/dist/{page-lock-Uz94JnNt.cjs → page-lock-HtvnzoMt.cjs} +1 -1
  51. package/dist/{page-locked-dialog-CQ01l5GQ.cjs → page-locked-dialog-Bab2DfeD.cjs} +1 -1
  52. package/dist/{page-locked-dialog-BrFlnF1_.js → page-locked-dialog-CJ5DSATy.js} +1 -1
  53. package/dist/{page-manager-new-WhmwJZLE.cjs → page-manager-new-CBqk6pWg.cjs} +1 -1
  54. package/dist/{page-manager-new-VsciHCAM.js → page-manager-new-CVaAIEJq.js} +2 -2
  55. package/dist/{page-manager-search-and-filter-C25h2oZm.cjs → page-manager-search-and-filter-CG2hW34n.cjs} +1 -1
  56. package/dist/{page-manager-search-and-filter-JQpL82Sl.js → page-manager-search-and-filter-DOiUgdYA.js} +1 -1
  57. package/dist/{page-revisions-content-BJXW36z8.js → page-revisions-content-B6ttL983.js} +2 -2
  58. package/dist/{page-revisions-content-ynSnkxGq.cjs → page-revisions-content-DbW94Aqr.cjs} +1 -1
  59. package/dist/pages.css +1 -1
  60. package/dist/{publish-pages-content-CJX7kSdV.cjs → publish-pages-content-BG7hkOsG.cjs} +1 -1
  61. package/dist/{publish-pages-content-DD9OlPYp.js → publish-pages-content-WfSGxj2n.js} +2 -2
  62. package/dist/{save-to-lib-CooOVEaQ.js → save-to-lib-BVkEMHoE.js} +1 -1
  63. package/dist/{save-to-lib-D1wVNYQs.cjs → save-to-lib-BiBT_3-d.cjs} +1 -1
  64. package/dist/{selected-block-display-gP43mf34.cjs → selected-block-display-BuDBDqZD.cjs} +1 -1
  65. package/dist/{selected-block-display-DxwMm0qr.js → selected-block-display-DQEXsFkX.js} +1 -1
  66. package/dist/{seo-panel-g_OuoWp9.js → seo-panel-CY1S1tpO.js} +1 -1
  67. package/dist/{seo-panel-BZQVr7WN.cjs → seo-panel-SF1denm-.cjs} +1 -1
  68. package/dist/{shared-json-ld-jbhoi-Qv.cjs → shared-json-ld-CPGLTTPM.cjs} +1 -1
  69. package/dist/{shared-json-ld-DKwpR514.js → shared-json-ld-DyCKYT2v.js} +1 -1
  70. package/dist/{slug-input-Dc5XAgQc.js → slug-input-D-DKPODe.js} +1 -1
  71. package/dist/{slug-input-DAq9MT_P.cjs → slug-input-DTA7BsMG.cjs} +1 -1
  72. package/dist/{take-over-request-Byq9LiOV.js → take-over-request-D1F_3xeM.js} +1 -1
  73. package/dist/{take-over-request-BOGWNLpM.cjs → take-over-request-rGefOfEm.cjs} +1 -1
  74. package/dist/{theme-panel-footer-B8mn0xAf.js → theme-panel-footer-Cdxm1r9y.js} +1 -1
  75. package/dist/{theme-panel-footer-NFR6yf6k.cjs → theme-panel-footer-CfVUCIQS.cjs} +1 -1
  76. package/dist/{unmark-as-template-CIBRCR59.cjs → unmark-as-template-BRCuiVct.cjs} +1 -1
  77. package/dist/{unmark-as-template-BSjPZ86x.js → unmark-as-template-DcHmjuVo.js} +1 -1
  78. package/dist/{unpublish-page-CmUXigiU.cjs → unpublish-page-BXyhOIC8.cjs} +1 -1
  79. package/dist/{unpublish-page-Cr9AlIFG.js → unpublish-page-C0eahm0q.js} +1 -1
  80. package/dist/{web-preview-mGavSw4r.cjs → web-preview-BXxkLcVP.cjs} +1 -1
  81. package/dist/{web-preview-DK51eK9e.js → web-preview-DTw3MNBm.js} +1 -1
  82. package/package.json +3 -3
  83. package/dist/ai-prompt-input-DBlSqHCo.cjs +0 -1
  84. package/dist/index-DheBvIvo.cjs +0 -5
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./button-CMMN5Cp4.cjs"),d=require("react"),R=require("cmdk"),b=require("lucide-react"),ye=require("@radix-ui/react-dialog"),Ne=require("@radix-ui/react-dropdown-menu"),we=require("@radix-ui/react-hover-card"),J=require("class-variance-authority"),Se=require("@radix-ui/react-select"),Ie=require("@chaibuilder/sdk"),U=require("./ai-panel-content-NdOClQP-.cjs");function q(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,n.get?n:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const p=q(d),z=q(ye),w=q(Ne),G=q(we),I=q(Se),Ce=z.Root,ke=z.Trigger,Re=z.Portal,Q=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Overlay,{ref:a,className:r.cn("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));Q.displayName=z.Overlay.displayName;const Z=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(Re,{children:[e.jsx(Q,{}),e.jsxs(z.Content,{ref:n,className:r.cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a,children:[s,e.jsxs(z.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(b.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Z.displayName=z.Content.displayName;const ee=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Title,{ref:a,className:r.cn("text-lg font-semibold leading-none tracking-tight",t),...s}));ee.displayName=z.Title.displayName;const De=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Description,{ref:a,className:r.cn("text-sm text-muted-foreground",t),...s}));De.displayName=z.Description.displayName;const te=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command,{ref:a,className:r.cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));te.displayName=R.Command.displayName;const se=p.forwardRef(({className:t,...s},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(b.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(R.Command.Input,{ref:a,className:r.cn("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));se.displayName=R.Command.Input.displayName;const ae=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.List,{ref:a,className:r.cn("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));ae.displayName=R.Command.List.displayName;const ze=p.forwardRef((t,s)=>e.jsx(R.Command.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));ze.displayName=R.Command.Empty.displayName;const ne=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Group,{ref:a,className:r.cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));ne.displayName=R.Command.Group.displayName;const Pe=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Separator,{ref:a,className:r.cn("-mx-1 h-px bg-border",t),...s}));Pe.displayName=R.Command.Separator.displayName;const oe=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Item,{ref:a,className:r.cn("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t),...s}));oe.displayName=R.Command.Item.displayName;const Te=w.Root,Le=w.Trigger,Ae=p.forwardRef(({className:t,inset:s,children:a,...n},l)=>e.jsxs(w.SubTrigger,{ref:l,className:r.cn("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...n,children:[a,e.jsx(b.ChevronRight,{className:"ml-auto"})]}));Ae.displayName=w.SubTrigger.displayName;const Me=p.forwardRef(({className:t,...s},a)=>e.jsx(w.SubContent,{ref:a,className:r.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...s}));Me.displayName=w.SubContent.displayName;const re=p.forwardRef(({className:t,sideOffset:s=4,...a},n)=>e.jsx(w.Portal,{children:e.jsx(w.Content,{ref:n,sideOffset:s,className:r.cn("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...a})}));re.displayName=w.Content.displayName;const ie=p.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(w.Item,{ref:n,className:r.cn("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...a}));ie.displayName=w.Item.displayName;const _e=p.forwardRef(({className:t,children:s,checked:a,...n},l)=>e.jsxs(w.CheckboxItem,{ref:l,className:r.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:a,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(b.Check,{className:"h-4 w-4"})})}),s]}));_e.displayName=w.CheckboxItem.displayName;const Oe=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(w.RadioItem,{ref:n,className:r.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(b.Circle,{className:"h-2 w-2 fill-current"})})}),s]}));Oe.displayName=w.RadioItem.displayName;const Ue=p.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(w.Label,{ref:n,className:r.cn("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...a}));Ue.displayName=w.Label.displayName;const qe=p.forwardRef(({className:t,...s},a)=>e.jsx(w.Separator,{ref:a,className:r.cn("-mx-1 my-1 h-px bg-muted",t),...s}));qe.displayName=w.Separator.displayName;const Ee=G.Root,Be=G.Trigger,le=p.forwardRef(({className:t,align:s="center",sideOffset:a=4,...n},l)=>e.jsx(G.Content,{ref:l,align:s,sideOffset:a,className:r.cn("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-hover-card-content-transform-origin]",t),...n}));le.displayName=G.Content.displayName;const Fe=p.forwardRef(({className:t,type:s,...a},n)=>e.jsx("input",{type:s,className:r.cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...a}));Fe.displayName="Input";const ce=p.forwardRef(({className:t,...s},a)=>e.jsx("textarea",{className:r.cn("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:a,...s}));ce.displayName="Textarea";function Ge({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:r.cn("group/input-group border-input dark:bg-input/30 shadow-xs relative flex w-full items-center rounded-md border outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:ring-ring has-[[data-slot=input-group-control]:focus-visible]:ring-1","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...s})}const Ve=J.cva("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function de({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:r.cn(Ve({align:s}),t),onClick:n=>{var l,g;n.target.closest("button")||(g=(l=n.currentTarget.parentElement)==null?void 0:l.querySelector("input"))==null||g.focus()},...a})}const He=J.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function ue({className:t,type:s="button",variant:a="ghost",size:n="xs",...l}){return e.jsx(r.Button,{type:s,"data-size":n,variant:a,className:r.cn(He({size:n}),t),...l})}function We({className:t,...s}){return e.jsx(ce,{"data-slot":"input-group-control",className:r.cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...s})}const Ke=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(I.Trigger,{ref:n,className:r.cn("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...a,children:[s,e.jsx(I.Icon,{asChild:!0,children:e.jsx(b.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ke.displayName=I.Trigger.displayName;const me=p.forwardRef(({className:t,...s},a)=>e.jsx(I.ScrollUpButton,{ref:a,className:r.cn("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(b.ChevronUp,{className:"h-4 w-4"})}));me.displayName=I.ScrollUpButton.displayName;const pe=p.forwardRef(({className:t,...s},a)=>e.jsx(I.ScrollDownButton,{ref:a,className:r.cn("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(b.ChevronDown,{className:"h-4 w-4"})}));pe.displayName=I.ScrollDownButton.displayName;const Xe=p.forwardRef(({className:t,children:s,position:a="popper",...n},l)=>e.jsx(I.Portal,{children:e.jsxs(I.Content,{ref:l,className:r.cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,...n,children:[e.jsx(me,{}),e.jsx(I.Viewport,{className:r.cn("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(pe,{})]})}));Xe.displayName=I.Content.displayName;const Ye=p.forwardRef(({className:t,...s},a)=>e.jsx(I.Label,{ref:a,className:r.cn("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Ye.displayName=I.Label.displayName;const $e=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(I.Item,{ref:n,className:r.cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(I.ItemIndicator,{children:e.jsx(b.Check,{className:"h-4 w-4"})})}),e.jsx(I.ItemText,{children:s})]}));$e.displayName=I.Item.displayName;const Je=p.forwardRef(({className:t,...s},a)=>e.jsx(I.Separator,{ref:a,className:r.cn("-mx-1 my-1 h-px bg-muted",t),...s}));Je.displayName=I.Separator.displayName;const Qe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ze=(t=21)=>{let s="",a=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)s+=Qe[a[t]&63];return s};const et=d.createContext(null),tt=d.createContext(null),fe=()=>d.useContext(et),st=()=>d.useContext(tt),xe=d.createContext(null),V=()=>{const t=st(),s=d.useContext(xe),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function at({data:t,className:s,...a}){var v;const n=V(),l=t.filename||"",u=((v=t.mediaType)!=null&&v.startsWith("image/")&&t.url?"image":"file")==="image",y=l||(u?"Image":"Attachment");return e.jsxs(gt,{children:[e.jsx(Be,{asChild:!0,children:e.jsxs("div",{className:r.cn("group relative flex h-8 cursor-default select-none items-center gap-1.5 rounded-md border border-border px-1.5 text-sm font-medium transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",s),...a,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:u?e.jsx("img",{alt:l||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):e.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:e.jsx(b.PaperclipIcon,{className:"size-3"})})}),e.jsxs(r.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:k=>{k.stopPropagation(),n.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(b.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:y})]},t.id)}),e.jsx(ht,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[u&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:l||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e.jsx("h4",{className:"truncate text-sm font-semibold leading-none",children:l||(u?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function nt({children:t,className:s,...a}){const n=V();return n.files.length?e.jsx("div",{className:r.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:n.files.map(l=>e.jsx(d.Fragment,{children:t(l)},l.id))}):null}const ot=({label:t="Add photos or files",...s})=>{const a=V();return e.jsxs(ie,{...s,onSelect:n=>{n.preventDefault(),a.openFileDialog()},children:[e.jsx(b.ImageIcon,{className:"mr-2 size-4"})," ",t]})},rt=({className:t,accept:s,multiple:a,globalDrop:n,syncHiddenInput:l,maxFiles:g,maxFileSize:u,onError:y,onSubmit:v,children:k,...T})=>{const o=fe(),c=!!o,m=d.useRef(null),P=d.useRef(null),C=d.useRef(null);d.useEffect(()=>{var N;const i=(N=P.current)==null?void 0:N.closest("form");i instanceof HTMLFormElement&&(C.current=i)},[]);const[D,A]=d.useState([]),j=c?o.attachments.files:D,M=d.useCallback(()=>{var i;(i=m.current)==null||i.click()},[]),E=d.useCallback(i=>!s||s.trim()===""?!0:s.includes("image/*")?i.type.startsWith("image/"):!0,[s]),B=d.useCallback(i=>{const N=Array.from(i),h=N.filter(S=>E(S));if(N.length&&h.length===0){y==null||y({code:"accept",message:"No files match the accepted types."});return}const x=S=>u?S.size<=u:!0,f=h.filter(x);if(h.length>0&&f.length===0){y==null||y({code:"max_file_size",message:"All files exceed the maximum size."});return}A(S=>{const _=typeof g=="number"?Math.max(0,g-S.length):void 0,je=typeof _=="number"?f.slice(0,_):f;typeof _=="number"&&f.length>_&&(y==null||y({code:"max_files",message:"Too many files. Some were not added."}));const Y=[];for(const H of je)Y.push({id:Ze(),type:"file",url:URL.createObjectURL(H),mediaType:H.type,filename:H.name});return S.concat(Y)})},[E,g,u,y]),L=c?i=>o.attachments.add(i):B,O=c?i=>o.attachments.remove(i):i=>A(N=>{const h=N.find(x=>x.id===i);return h!=null&&h.url&&URL.revokeObjectURL(h.url),N.filter(x=>x.id!==i)}),F=c?()=>o.attachments.clear():()=>A(i=>{for(const N of i)N.url&&URL.revokeObjectURL(N.url);return[]}),K=c?()=>o.attachments.openFileDialog():M;d.useEffect(()=>{c&&o.__registerFileInput(m,()=>{var i;return(i=m.current)==null?void 0:i.click()})},[c,o]),d.useEffect(()=>{l&&m.current&&j.length===0&&(m.current.value="")},[j,l]),d.useEffect(()=>{const i=C.current;if(!i)return;const N=x=>{var f,S;(S=(f=x.dataTransfer)==null?void 0:f.types)!=null&&S.includes("Files")&&x.preventDefault()},h=x=>{var f,S,_;(S=(f=x.dataTransfer)==null?void 0:f.types)!=null&&S.includes("Files")&&x.preventDefault(),(_=x.dataTransfer)!=null&&_.files&&x.dataTransfer.files.length>0&&L(x.dataTransfer.files)};return i.addEventListener("dragover",N),i.addEventListener("drop",h),()=>{i.removeEventListener("dragover",N),i.removeEventListener("drop",h)}},[L]),d.useEffect(()=>{if(!n)return;const i=h=>{var x,f;(f=(x=h.dataTransfer)==null?void 0:x.types)!=null&&f.includes("Files")&&h.preventDefault()},N=h=>{var x,f,S;(f=(x=h.dataTransfer)==null?void 0:x.types)!=null&&f.includes("Files")&&h.preventDefault(),(S=h.dataTransfer)!=null&&S.files&&h.dataTransfer.files.length>0&&L(h.dataTransfer.files)};return document.addEventListener("dragover",i),document.addEventListener("drop",N),()=>{document.removeEventListener("dragover",i),document.removeEventListener("drop",N)}},[L,n]),d.useEffect(()=>()=>{if(!c)for(const i of j)i.url&&URL.revokeObjectURL(i.url)},[c,j]);const ge=i=>{i.currentTarget.files&&L(i.currentTarget.files)},he=async i=>{const h=await(await fetch(i)).blob();return new Promise((x,f)=>{const S=new FileReader;S.onloadend=()=>x(S.result),S.onerror=f,S.readAsDataURL(h)})},be=d.useMemo(()=>({files:j.map(i=>({...i,id:i.id})),add:L,remove:O,clear:F,openFileDialog:K,fileInputRef:m}),[j,L,O,F,K]),ve=i=>{i.preventDefault();const N=i.currentTarget,h=c?o.textInput.value:new FormData(N).get("message")||"";c||N.reset(),Promise.all(j.map(async({id:x,...f})=>f.url&&f.url.startsWith("blob:")?{...f,url:await he(f.url)}:f)).then(x=>{try{const f=v({text:h,files:x},i);f instanceof Promise?f.then(()=>{F(),c&&o.textInput.clear()}).catch(()=>{}):(F(),c&&o.textInput.clear())}catch{}})},X=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:P}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:a,onChange:ge,ref:m,title:"Upload files",type:"file"}),e.jsx("form",{className:r.cn("w-full",t),onSubmit:ve,...T,children:e.jsx(Ge,{className:"overflow-hidden",children:k})})]});return c?X:e.jsx(xe.Provider,{value:be,children:X})},it=({onChange:t,className:s,placeholder:a="What would you like to know?",...n})=>{const l=fe(),g=V(),[u,y]=d.useState(!1),v=o=>{if(o.key==="Enter"){if(u||o.nativeEvent.isComposing||o.shiftKey)return;o.preventDefault();const c=o.currentTarget.form,m=c==null?void 0:c.querySelector('button[type="submit"]');if(m!=null&&m.disabled)return;c==null||c.requestSubmit()}if(o.key==="Backspace"&&o.currentTarget.value===""&&g.files.length>0){o.preventDefault();const c=g.files.at(-1);c&&g.remove(c.id)}},k=o=>{var P;const c=(P=o.clipboardData)==null?void 0:P.items;if(!c)return;const m=[];for(const C of c)if(C.kind==="file"){const D=C.getAsFile();D&&m.push(D)}m.length>0&&(o.preventDefault(),g.add(m))},T=l?{value:l.textInput.value,onChange:o=>{l.textInput.setInput(o.currentTarget.value),t==null||t(o)}}:{onChange:t};return e.jsx(We,{className:r.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>y(!1),onCompositionStart:()=>y(!0),onKeyDown:v,onPaste:k,placeholder:a,...n,...T})},lt=({className:t,...s})=>e.jsx(de,{align:"block-end",className:r.cn("order-first flex-wrap gap-1",t),...s}),ct=({className:t,...s})=>e.jsx(de,{align:"block-end",className:r.cn("justify-between gap-1",t),...s}),dt=({className:t,...s})=>e.jsx("div",{className:r.cn("flex items-center gap-1",t),...s}),W=({variant:t="ghost",className:s,size:a,...n})=>{const l=a??(d.Children.count(n.children)>1?"sm":"icon-sm");return e.jsx(ue,{className:r.cn(s),size:l,type:"button",variant:t,...n})},ut=t=>e.jsx(Te,{...t}),mt=({className:t,children:s,...a})=>e.jsx(Le,{asChild:!0,children:e.jsx(W,{className:t,...a,children:s??e.jsx(b.PlusIcon,{className:"size-4"})})}),pt=({className:t,...s})=>e.jsx(re,{align:"start",className:r.cn(t),...s}),ft=({className:t,variant:s="default",size:a="icon-sm",status:n,children:l,...g})=>{let u=e.jsx(b.CornerDownLeftIcon,{className:"size-4"});return n==="submitted"?u=e.jsx(b.Loader2Icon,{className:"size-4 animate-spin"}):n==="streaming"?u=e.jsx(b.SquareIcon,{className:"size-4"}):n==="error"&&(u=e.jsx(b.XIcon,{className:"size-4"})),e.jsx(ue,{"aria-label":"Submit",className:r.cn(t),size:a,type:"submit",variant:s,...g,children:l??u})},xt=({className:t,textareaRef:s,onTranscriptionChange:a,...n})=>{const[l,g]=d.useState(!1),[u,y]=d.useState(null),v=d.useRef(null);d.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const T=window.SpeechRecognition||window.webkitSpeechRecognition,o=new T;o.continuous=!0,o.interimResults=!0,o.lang="en-US",o.onstart=()=>{g(!0)},o.onend=()=>{g(!1)},o.onresult=c=>{var P;let m="";for(let C=c.resultIndex;C<c.results.length;C++){const D=c.results[C];D.isFinal&&(m+=((P=D[0])==null?void 0:P.transcript)??"")}if(m&&(s!=null&&s.current)){const C=s.current,D=C.value,A=D+(D?" ":"")+m;C.value=A,C.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(A)}},o.onerror=c=>{console.error("Speech recognition error:",c.error),g(!1)},v.current=o,y(o)}return()=>{v.current&&v.current.stop()}},[s,a]);const k=d.useCallback(()=>{u&&(l?u.stop():u.start())},[u,l]);return e.jsx(W,{className:r.cn("relative transition-all duration-200",l&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!u,onClick:k,...n,children:e.jsx(b.MicIcon,{className:"size-4"})})},gt=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(Ee,{closeDelay:s,openDelay:t,...a}),ht=({align:t="start",...s})=>e.jsx(le,{align:t,...s}),bt=t=>e.jsx(Ce,{...t}),vt=t=>e.jsx(ke,{...t}),jt=({className:t,children:s,title:a="Model Selector",...n})=>e.jsxs(Z,{className:r.cn("p-0",t),...n,children:[e.jsx(ee,{className:"sr-only",children:a}),e.jsx(te,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),yt=({className:t,...s})=>e.jsx(se,{className:r.cn("h-auto py-3.5",t),...s}),Nt=t=>e.jsx(ae,{...t}),wt=t=>e.jsx(ne,{...t}),St=t=>e.jsx(oe,{...t}),It=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:r.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ct=({className:t,...s})=>e.jsx("span",{className:r.cn("flex-1 truncate text-left",t),...s}),kt=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[n,l]=d.useState(!1),[g,u]=d.useState(""),y=U.getModelById(t)||U.getDefaultModel(),k=U.AI_MODELS.filter(o=>o.name.toLowerCase().includes(g.toLowerCase())||o.provider.toLowerCase().includes(g.toLowerCase())).reduce((o,c)=>(o[c.provider]||(o[c.provider]=[]),o[c.provider].push(c),o),{}),T=o=>{s(o),l(!1),u("")};return e.jsxs(bt,{open:n,onOpenChange:l,children:[e.jsx(vt,{asChild:!0,children:e.jsxs(r.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(b.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:y.name})]})}),e.jsxs(jt,{className:"w-96 p-0",children:[e.jsx(yt,{placeholder:"Search models...",value:g,onValueChange:u}),e.jsx(Nt,{children:Object.entries(k).map(([o,c])=>e.jsx(wt,{heading:o.charAt(0).toUpperCase()+o.slice(1),children:c.map(m=>e.jsxs(St,{value:m.id,onSelect:()=>T(m.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(It,{provider:m.provider}),e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsx(Ct,{children:m.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:m.description})]}),t===m.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},m.id))},o))})]})]})},$="chai-ai-selected-model",Rt=({input:t,setInput:s,onSend:a,onStop:n,isLoading:l,disabled:g,selectedLang:u,selectedModel:y=U.getDefaultModel().id,onModelChange:v})=>{const{t:k}=Ie.useTranslation(),[T,o]=d.useState(y),[c,m]=d.useState(null),P=d.useRef(null),[C,D]=d.useState(!1);d.useEffect(()=>{if(!u){const j=localStorage.getItem($);if(j)o(j),v==null||v(j);else{const M=U.getDefaultModel().id;o(M),v==null||v(M)}}},[u,v]);const A=j=>{var B;const M=j.files.find(L=>{var O;return(O=L.mediaType)==null?void 0:O.startsWith("image/")}),E=(M==null?void 0:M.url)||c;a((B=j.text)==null?void 0:B.trim(),void 0,E,T),m(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(rt,{onSubmit:A,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(lt,{className:"p-0",children:e.jsx(nt,{className:"pb-0",children:j=>e.jsx(at,{className:"text-xs",data:j})})}),e.jsx(it,{ref:P,value:t,onChange:j=>s(j.target.value),placeholder:k(u?"Ask to update content":"Ask me anything..."),disabled:l,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(ct,{children:[u?e.jsx("div",{}):e.jsxs(dt,{children:[e.jsxs(ut,{children:[e.jsx(mt,{disabled:l,children:e.jsx(b.Paperclip,{size:16})}),e.jsx(pt,{children:e.jsx(ot,{})})]}),e.jsx(xt,{textareaRef:P,onTranscriptionChange:s,disabled:l}),e.jsx(kt,{selectedModel:T,onModelChange:j=>{o(j),v==null||v(j),localStorage.setItem($,j)},disabled:l}),e.jsxs(W,{className:"hidden",size:"sm",onClick:()=>D(!C),variant:C?"default":"ghost",children:[e.jsx(b.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),l?e.jsxs("button",{onClick:n,className:"z-50 flex items-center gap-x-1 rounded-md bg-red-500 p-1.5 text-white transition-colors hover:bg-red-600",title:k("Stop generation"),children:[e.jsx(b.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:k("Stop")})]}):e.jsx(ft,{disabled:!t.trim()||g,children:e.jsx(b.Send,{size:16})})]})]})})})};exports.default=Rt;
@@ -1,5 +0,0 @@
1
- "use strict";var xs=e=>{throw TypeError(e)};var ws=(e,t,s)=>t.has(e)||xs("Cannot "+s);var _=(e,t,s)=>(ws(e,t,"read from private field"),s?s.call(e):t.get(e)),R=(e,t,s)=>t.has(e)?xs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),O=(e,t,s,n)=>(ws(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);const o=require("react/jsx-runtime"),p=require("lodash-es"),h=require("react"),H=require("jotai"),S=require("@tanstack/react-query"),P=require("@chaibuilder/sdk"),g=require("@chaibuilder/sdk/ui"),x=require("lucide-react"),F=require("sonner"),Bs=require("@chaibuilder/runtime"),ar=require("@chaibuilder/sdk/web-blocks");function ir(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const z=ir(h),ze={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"},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"},or=H.atom({}),Ot=()=>H.useAtom(or),ne=(e,t)=>{const[s]=Ot();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},j=()=>ne("apiUrl","/chai/api"),Fs=()=>ne("usersApiUrl","/chai/users"),lr=()=>ne("assetsApiUrl","/chai/assets"),qs=()=>ne("websocket",null),cr=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),ur=()=>{const e=N(),t=j();return h.useCallback(async({body:s,headers:n={},url:r=t,streamResponse:a=!1})=>e(r,s,n,a),[e])},N=()=>{const e=ne("onLogout"),t=ne("getAccessToken"),s=j();return h.useCallback(async(n=s,r,a={},i=!1)=>{const l=await t();try{const c=p.get(r,"action","").toLowerCase(),d=await cr(n+(c?`?action=${c}`:""),r,{...a,Authorization:`Bearer ${l}`});if(i)return d;if(d.status===401)return console.log("401 Response",d),e(),window.location.reload(),null;if(!d.ok){const u=await d.json();throw console.error(`API Error (${d.status}):`,u),{status:d.status,statusText:d.statusText,...u,message:u.error||u.message||`Server error: ${d.status}`}}return await d.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=j(),[s]=le(),n=e??s.get("page"),r=N();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})},dr=H.atom(null),Ks=()=>H.useAtom(dr),as=()=>{const[e]=Ks();return(e==null?void 0:e.slug)||""};function fr(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const hr=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=P.useLanguages(),{data:r}=te(),a=r==null?void 0:r.pageType,i=j(),l=N(),{data:c,isFetching:d}=S.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:60*60*1e3,placeholderData:[],queryFn:async()=>await l(i,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),u=h.useMemo(()=>s===""?c.filter(f=>f.lang===""||f.lang===n):c.filter(f=>f.lang===s),[s,n,c]);return{allLangPages:c,data:u,isFetching:d}},Vs=()=>{const{selectedLang:e,fallbackLang:t}=P.useLanguages(),[s,n]=Ks(),[r,a]=h.useState(""),i=fr(r,500),{allLangPages:l,data:c,isFetching:d}=hr({query:i}),u=h.useCallback(m=>n(m),[n]),f=h.useCallback(m=>a(m),[a]),E=h.useCallback(()=>{if(!s)return;const m=!(s!=null&&s.primaryPage),A=e.length===0,w=m?s==null?void 0:s.id:s==null?void 0:s.primaryPage,M=l.filter(T=>(T==null?void 0:T.primaryPage)===w||T.id===w).find(T=>A?T.lang===e||T.lang===t:T.lang===e);n(M||s)},[s,e,l,n,t]);return{isFetching:d,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:u,updateSearchQuery:f,onChangeLanguage:E}},gr=H.atom({lastSaved:void 0}),is=()=>H.useAtom(gr),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}},he=()=>{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}},mr=H.atom({}),Er=()=>H.useAtom(mr),pr=()=>{const{data:e}=he(),t=as(),s=ne("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},Te=()=>{const e=j(),t=N();return S.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:5*60*1e3,placeholderData:{languages:[],theme:{fontFamily:"",borderRadius:"",colors:{}},appKey:"",fallbackLang:"",designTokens:{}},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})};function os(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 Rt=H.atom(null),Mt=()=>{const e=ne("currentUser"),t=ne("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"},yr=["sync","join","leave"],Ar=[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],Tr=H.atom({}),Hs=H.atom(null),Sr=H.atom(J.CHECKING),Pr=H.atom({}),_r=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},xr=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},Et=()=>{const{user:e}=Mt();return e==null?void 0:e.id},wr=()=>{const{data:e}=Te();return`WEBSITE:${e==null?void 0:e.appKey}`},pt=()=>{const{data:e}=te();return e==null?void 0:e.id},xe=crypto.randomUUID();let Vt=null;const ls=()=>{const[e,t]=H.useAtom(Tr);return{pageToUser:e,setPageToUser:t}},re=()=>{const[e,t]=H.useAtom(Sr),s=[J.LOCKED,J.ACTIVE_IN_ANOTHER_TAB].includes(e),n=[J.EDITING].includes(e);return{pageStatus:e,setPageStatus:t,isLocked:s,isEditing:n}},cs=()=>{const[e,t]=H.useAtom(Pr);return{pageLockMeta:e,setPageLockMeta:t}},Qs=()=>{const e=pt(),{pageToUser:t}=ls();return h.useMemo(()=>t[e],[t,e])},us=()=>{const e=qs(),{setPageStatus:t}=re(),[s]=H.useAtom(Hs);return h.useEffect(()=>{if(clearTimeout(Vt),!e)return Vt=setTimeout(()=>{e||t(J.EDITING)},500),()=>clearTimeout(Vt)},[e,t]),s},vr=()=>{const e=pt(),t=Et(),s=us(),{setPageToUser:n}=ls(),{setPageStatus:r,pageStatus:a}=re(),i=h.useRef(e);return i.current=e,h.useCallback(l=>{const c=l||s;if(!c)return[];const d=c==null?void 0:c.presenceState(),u=_r(d);n(u);const f=u[i.current];if(!f)r(J.CHECKING);else if(!t)r(J.CHECKING);else if(f.userId===t&&f.clientId===xe){if(a===J.TAKE_OVER_REQUESTED)return;r(J.EDITING)}else f.userId===t&&f.clientId!==xe?r(J.ACTIVE_IN_ANOTHER_TAB):r(J.LOCKED)},[s,n,r,t,a])},zs=()=>{const e=Et(),t=pt(),s=us(),n=Qs(),{setPageLockMeta:r}=cs(),a=h.useRef(t);return a.current=t,h.useCallback(async(i,l)=>{if(!s)return;const c=l||{};c.userId=e,c.pageId=a.current,c.senderClientId=xe,c.receiverClientId=(l==null?void 0:l.requestingClientId)||(n==null?void 0:n.clientId),await s.send({event:i,payload:c,type:"broadcast"}),r({})},[s,e,n,r])},br=()=>{const e=Et(),t=pt(),s=us(),{setPageStatus:n}=re(),{setPageLockMeta:r}=cs(),a=zs(),i=h.useRef(t),{savePageAsync:l}=P.useSavePage();return i.current=t,h.useCallback(c=>async({payload:d})=>{const u=d||{};if(!(!(u!=null&&u.pageId)||(u==null?void 0:u.pageId)!==i.current||(u==null?void 0:u.receiverClientId)!==xe))switch(r({}),c){case X.FORCE_TAKE_OVER_REQUEST:case X.CONTINUE_EDITING_IN_THIS_TAB_REQUEST:{try{await l(!0)}catch(f){console.error("Failed to save page before releasing lock:",f)}await a(X.CONTINUE_EDITING_IN_THIS_CLIENT,{requestingClientId:u==null?void 0:u.senderClientId}),setTimeout(()=>r({type:c}),0);break}case X.TAKE_OVER_REQUEST:{r({requestingUserId:u==null?void 0:u.userId,requestingClientId:u==null?void 0:u.senderClientId}),n(J.TAKE_OVER_REQUESTED);break}case X.CONTINUE_EDITING_IN_THIS_CLIENT:{const f=xr(s==null?void 0:s.presenceState());n(J.CHECKING),await(s==null?void 0:s.track({onlineAt:f,pageId:i.current,userId:e,clientId:xe}));break}case X.TAKE_OVER_REJECTED:{r({type:X.TAKE_OVER_REJECTED});break}}},[a,r,n,s,e,l])},Ir=()=>{const e=qs(),t=Et(),s=pt(),n=wr(),[r,a]=H.useAtom(Hs),i=br(),l=vr(),c=h.useRef(i),d=h.useRef(l);h.useEffect(()=>{c.current=i,d.current=l},[i,l]),h.useEffect(()=>{if(!e||!t||!n||r&&r.topic===n)return;const u=e.channel(n,{config:{presence:{key:xe}}});return Ar.forEach(f=>{u.on("broadcast",{event:f},E=>{c.current(f)(E)})}),yr.forEach(f=>{u.on("presence",{event:f},()=>{d.current(u)})}),u.subscribe(async f=>{f==="SUBSCRIBED"?a(u):(f==="CHANNEL_ERROR"||f==="TIMED_OUT")&&console.log("Realtime connection failed",f)}),()=>{u.unsubscribe()}},[e,t,n,a]),h.useEffect(()=>(r&&s&&t&&r.track({pageId:s,userId:t,clientId:xe,onlineAt:+new Date}),()=>{r&&s&&r.untrack()}),[r,s,t])},Ut=()=>{const{data:e}=Te();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},ds=()=>{const e=N(),t=j();return S.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},Cr=e=>{const t=N(),s=j(),n=Ut();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||{}})},Lr=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-WhmwJZLE.cjs"))),$s=({children:e})=>{const{t}=P.useTranslation(),[s,n]=le(),r=s.get("page"),{data:a,isFetching:i}=te(),{data:l,isFetching:c}=ds(),[d,u]=h.useState(!1),[f,E]=h.useState(!0),{savePage:m}=P.useSavePage(),A=!!r&&!p.isEmpty(a),{isLocked:w}=re(),v=h.useMemo(()=>{if(!l||c)return!1;const L=l.find(q=>q.slug==="/");return L==null?void 0:L.id},[l,c]);h.useEffect(()=>{if(c||!v||l.some(D=>D.id===r))return;const q=new URLSearchParams({page:v});os(q,n),!c&&l&&E(!1)},[r,c,l,v,n]);const M=!f&&!r,T=!f&&!i&&p.isEmpty(a),C=d||M||T;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex items-center gap-x-1",children:o.jsx("div",{className:"relative",children:o.jsxs(g.Tooltip,{children:[o.jsx(g.TooltipTrigger,{asChild:!0,onClick:()=>{w||m(),u(!0)},children:e||o.jsx(g.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:o.jsx(x.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),o.jsx(g.TooltipContent,{side:"right",children:o.jsx("p",{children:t("Open pages manager")})})]})})}),o.jsx(g.Sheet,{open:C,onOpenChange:L=>!L&&A&&u(!1),children:o.jsxs(g.SheetContent,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[50vh] !max-w-[800px] border-border p-0 ${A?"":"sheet-hide-close-btn"}`,children:[o.jsxs(g.SheetHeader,{className:"mb-3 px-4 pt-4",children:[o.jsxs(g.SheetTitle,{className:"flex items-center gap-2 text-sm font-semibold",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:o.jsx(x.Folder,{className:"h-4 w-4"})}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold",children:t("Pages")}),o.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:t("Manage your site structure")})]})]}),o.jsx(g.SheetDescription,{className:"sr-only",children:t("Manage your site structure")})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:C&&o.jsx(h.Suspense,{children:o.jsx(Lr,{close:()=>u(!1)})})})]})})]})},Nr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-xOwbmNJj.cjs"))),jr=()=>{const e=ne("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},Ws=({showAdd:e=!0,variant:t="ghost",goToDefaultLang:s=!1})=>{const{fallbackLang:n,languages:r,selectedLang:a,setSelectedLang:i}=P.useLanguages(),l=p.isEmpty(a)?n:a,[,c]=le(),{isLocked:d}=re(),{t:u}=P.useTranslation();h.useEffect(()=>{const T=new URLSearchParams(window.location.search),C=T.get("lang");C&&(r.includes(C)?i(C):(T.delete("lang"),c(T),i("")))},[r,c,i]);const[,f]=H.useAtom(Rt),{data:E}=te(),{data:m}=Te(),{data:A}=Ae(),w=h.useMemo(()=>{const T=p.compact(p.map(p.get(m,"languages"),C=>{const L=p.find(A,{lang:C});return{key:C,value:p.get(ze,C,C),isLangPageAdded:!!L}})).filter(Boolean);return[{key:n,value:p.get(ze,n),isLangPageAdded:!0},...T]},[n,A,m]),v=T=>{if(document.querySelector('[data-panel-id="seo"]')){const L=new CustomEvent("seo-language-switch-check",{detail:{fromLang:l,toLang:T,switchHandler:()=>M(T)}});window.dispatchEvent(L);return}M(T)},M=T=>{i(T);const C=new URLSearchParams(window.location.search);T===n?C.delete("lang"):C.set("lang",T),os(C,c)};return p.isEmpty(r)?null:d?o.jsxs(g.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[o.jsx(x.Languages,{className:"h-4 w-4"}),p.get(ze,l,l),o.jsx(x.ChevronDown,{className:"h-4 w-4"})]}):s?o.jsx(g.Button,{onClick:()=>M(n),variant:"link",size:"sm",children:u("Switch to default language")}):o.jsx(o.Fragment,{children:o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:o.jsxs(g.Button,{disabled:!!d,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[o.jsx(x.Languages,{className:"h-4 w-4"}),p.get(ze,l,l),o.jsx(x.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(g.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(w.filter(T=>T.isLangPageAdded),T=>o.jsxs(g.DropdownMenuItem,{className:P.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",T.key===l&&"!bg-gray-200 text-gray-700"),onClick:()=>v(T.key),children:[o.jsx("div",{className:"text-slate-600",children:T.value}),T.key===n&&o.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[o.jsx(x.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},T.value)),e&&!p.isEmpty(w.filter(T=>!T.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(g.Separator,{}),o.jsxs(g.Button,{size:"sm",variant:"ghost",onClick:()=>{E&&f({edit:!1,primaryPage:E.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(x.Plus,{className:"mr-1 h-3 w-3"})," Add Langauge"]})]})]})]})})};function Dr(){const[e,t]=H.useAtom(Rt);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(jr,{}),o.jsx($s,{}),e&&o.jsx(h.Suspense,{children:o.jsx(Nr,{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 Gr(){return o.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>o.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsx(g.Skeleton,{className:"h-4 w-3/4"}),o.jsx(g.Skeleton,{className:"h-3 w-1/2"}),o.jsx(g.Skeleton,{className:"mt-1 h-5 w-20"})]}),o.jsx(g.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const kr=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-ynSnkxGq.cjs")));function Or(){const[e,t]=z.useState(!1);return o.jsx(g.TooltipProvider,{children:o.jsxs(g.Tooltip,{delayDuration:0,children:[o.jsxs(g.Sheet,{open:e,onOpenChange:t,children:[o.jsx(g.SheetTrigger,{asChild:!0,children:o.jsx(g.TooltipTrigger,{asChild:!0,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs(g.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[o.jsx(x.History,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"View revision history"})]}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})})}),o.jsx(g.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&o.jsx(h.Suspense,{fallback:o.jsx(Gr,{}),children:o.jsx(kr,{isOpen:e})})})]}),o.jsx(g.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const xt=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=P.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},Rr={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},ge=()=>{const e=j(),t=N();return S.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Ys=e=>{const{data:t}=ge();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},Mr=()=>{const e=j(),t=N();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),[]}}})},Ur=()=>{const e=j(),t=S.useQueryClient(),s=N(),{data:n}=ge();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 i=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+((l=p.find(n,{key:a.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";F.toast.success(i)},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to add new ${i!=null&&i.hasSlug?"page":i.name}.`,{description:p.get(Rr,r.message,r.message)})}})},Br=()=>{const e=j(),t=S.useQueryClient(),s=N(),{data:n}=he(),{data:r}=ge();return S.useMutation({mutationFn:async a=>await s(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,i)=>{(n==null?void 0:n.id)===(i==null?void 0:i.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),i&&(i!=null&&i.primaryPage||i!=null&&i.seo)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const l=p.find(r,{key:i.pageType});F.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},Fr=()=>{const e=j(),t=S.useQueryClient(),s=N(),{data:n}=ge();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 i=p.find(n,{key:a.pageType});F.toast.error(`Failed to delete ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},qr=()=>{const e=j(),t=S.useQueryClient(),s=N(),{data:n}=ge();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 i=p.find(n,{key:a.pageType});F.toast.success(i!=null&&i.hasSlug?"Page unpublished successfully.":"New "+i.name+" added successfully.")},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to take offline ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},fs=()=>{const e=j(),t=N(),s=S.useQueryClient(),{data:n}=te(),{savePageAsync:r}=P.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.")}})},Kr=()=>{const e=j(),t=N(),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.")}})},Vr=()=>{const e=j(),t=N(),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.")}})},Hr=()=>{const e=j(),t=N(),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")}})},Qr=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-CJX7kSdV.cjs")));function zr({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=fs();return o.jsx(g.Dialog,{open:e,onOpenChange:n?()=>{}:t,children:e&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:o.jsx(Qr,{onClose:t,isPending:n,publishPage:s})})})}const se={...P.PERMISSIONS,ADD_PAGE:"add_page",EDIT_PAGE:"edit_page",EDIT_SLUG:"edit_slug",DELETE_PAGE:"delete_page",CHANGE_PAGE_TYPE:"change_page_type",PUBLISH_PAGE:"publish_page",UNPUBLISH_PAGE:"unpublish_page",MARK_AS_TEMPLATE:"mark_as_template",UNMARK_AS_TEMPLATE:"unmark_as_template",ADD_PARTIAL:"add_partial",EDIT_PARTIAL:"edit_partial",DELETE_PARTIAL:"delete_partial",PUBLISH_PARTIAL:"publish_partial",UNPUBLISH_PARTIAL:"unpublish_partial",EDIT_SEO:"edit_seo",RESTORE_REVISION:"restore_revision",DELETE_REVISION:"delete_revision",PUBLISH_THEME:"publish_theme",EDIT_SETTINGS:"edit_settings",ADD_LIBRARY_BLOCK:"create_library_block",ADD_LIBRARY_TEMPLATE:"add_library_template",EDIT_LIBRARY_BLOCK:"edit_library_block",EDIT_LIBRARY_TEMPLATE:"edit_library_template",DELETE_LIBRARY_BLOCK:"delete_library_block",DELETE_LIBRARY_TEMPLATE:"delete_library_template",ADD_MEDIA:"add_media",EDIT_MEDIA:"edit_media",DELETE_MEDIA:"delete_media"},Js=e=>{const{fallbackLang:t}=P.useLanguages(),{data:s}=Te(),{data:n,isFetching:r}=Ae(),a=h.useMemo(()=>{const i={[t]:!0};return p.each(p.get(s,"languages"),l=>{const c=p.find(n,{lang:l});i[l]=!!c}),i},[t,n,s]);return r||p.isEmpty(e)||e&&a[e]},$r={particleCount:350,spread:120,origin:{y:.6},angle:90},Wr={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Yr=async()=>{const{default:e}=await Promise.resolve().then(()=>require("./confetti.module-BuUnQuWk.cjs"));return e},wt=e=>{let t=Wr[e];t||(t={});const s={...$r,...t};Yr().then(n=>n(s))};function Bt({children:e,content:t,side:s="bottom",delayDuration:n=700,showTooltip:r=!0}){return r?o.jsx(g.TooltipProvider,{children:o.jsxs(g.Tooltip,{delayDuration:n,children:[o.jsx(g.TooltipTrigger,{asChild:!0,children:e}),o.jsx(g.TooltipContent,{side:s,sideOffset:10,children:o.jsx("p",{children:t})})]})}):e}const Jr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-CmUXigiU.cjs"))),Zr=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-Kctu12rQ.cjs"))),Xr=()=>{const{t:e}=P.useTranslation(),{selectedLang:t,fallbackLang:s}=P.useLanguages(),n=ne("getPreviewUrl",async E=>E),[r,a]=h.useState(""),{data:i}=te(),{data:l}=Ae(),{data:c}=ge(),d=h.useMemo(()=>{var E;return(E=l==null?void 0:l.find(m=>(m==null?void 0:m.lang)===t))==null?void 0:E.slug},[t,l]),u=h.useCallback(E=>{var m;return(m=p.find(c,{key:E}))==null?void 0:m.hasSlug},[c]),f=t===s?"":t;return h.useEffect(()=>{(async()=>{if(typeof n=="function"){const E=!u(i==null?void 0:i.pageType),m=await n(E?`${f!==""?f+"/":""}${i==null?void 0:i.id}`:d||"");a(m)}else a("")})()},[n,d,i==null?void 0:i.pageType,u,i==null?void 0:i.id,f]),o.jsx(o.Fragment,{children:o.jsx(Bt,{content:e("Open preview in new tab"),delayDuration:0,children:o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:o.jsx(g.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(x.Play,{className:"h-4 w-4"})})})})})},ea=()=>{const{t:e}=P.useTranslation(),[t,s]=P.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Bt,{content:e("Theme"),delayDuration:0,children:o.jsx(g.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>s(t==="theme"?"block":"theme"),children:o.jsx(x.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},ta=()=>{const{t:e}=P.useTranslation(),[t,s]=h.useState(!1),{isLocked:n}=re(),{savePageAsync:r,saveState:a}=P.useSavePage();h.useEffect(()=>{const u=f=>{a==="UNSAVED"&&(f.preventDefault(),f.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",u),()=>{window.removeEventListener("beforeunload",u)}},[a]);const i=h.useCallback(async()=>{t||(s(!0),await r(),s(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:d}=h.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:o.jsx(x.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:o.jsx(x.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:o.jsx(x.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return n?null:o.jsxs(g.Button,{size:"sm",variant:"ghost",onClick:i,className:`${c} w-24 max-w-24`,children:[l," ",d]})},sa=()=>{const{t:e}=P.useTranslation(),{selectedLang:t}=P.useLanguages(),{data:s}=he(),{data:n}=Ae(),[r,a]=h.useState(!1),[i,l]=h.useState(!1),[c,d]=h.useState(null),{savePageAsync:u}=P.useSavePage(),[f,E]=h.useState(!1),{data:m}=te(),{mutate:A,isPending:w}=fs(),{needTranslations:v}=P.useSavePage(),M=v(),{buttonText:T,buttonClassName:C,isPublished:L}=h.useMemo(()=>{const I=m&&(m==null?void 0:m.online);return{buttonClassName:I?"hover:bg-green-600 bg-green-500":"",isPublished:I,buttonText:e(I?"Published":"Publish")}},[m,e]),q=async()=>{if(M){E(!0);return}D()},D=()=>{const I=[s==null?void 0:s.id,s==null?void 0:s.primaryPage];A({ids:p.compact(I)},{onSuccess:()=>wt("TOP_RIGHT")})},ce=()=>{E(!1),D()},ue=async()=>{E(!1),await u()},K=h.useMemo(()=>p.map(n??[],"id"),[n]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(g.Button,{size:"sm",onClick:q,disabled:w||!(m!=null&&m.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:[o.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${i?"-translate-y-10":""}`,children:L?o.jsx(x.Send,{className:"h-4 w-4"}):o.jsx(x.Rocket,{className:"h-4 w-4"})}),o.jsx("span",{className:`absolute inset-0 left-3 flex items-center transition-transform duration-300 ease-in-out ${i?"":"translate-y-10"}`,children:L?o.jsx(x.Rocket,{className:"h-4 w-4"}):o.jsx(x.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:T}),t?`(${p.upperCase(t)})`:""]}),o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,children:o.jsx(g.Button,{size:"sm",disabled:w||!(m!=null&&m.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${C}`,children:o.jsx(x.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(g.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(g.DropdownMenuItem,{disabled:w,className:"cursor-pointer text-xs",onClick:()=>A({ids:K},{onSuccess:()=>wt("TOP_RIGHT")}),children:[e("Publish")," with translation pages"]}),!L&&o.jsxs(g.DropdownMenuItem,{disabled:w,className:"cursor-pointer text-xs",onClick:()=>A({ids:[m==null?void 0:m.id]},{onSuccess:()=>wt("TOP_RIGHT")}),children:[e("Publish")," page"]}),o.jsxs(g.DropdownMenuItem,{onClick:()=>a(!0),className:"cursor-pointer text-xs",children:[e("Open")," publish menu"]}),L&&o.jsxs(g.DropdownMenuItem,{onClick:()=>d(s),className:"cursor-pointer text-xs",children:[e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]})]})]})]}),o.jsx(zr,{showModal:r,onClose:()=>a(!1)}),c&&o.jsx(h.Suspense,{children:o.jsx(Jr,{page:c,onClose:()=>d(null)})}),f&&o.jsx(h.Suspense,{children:o.jsx(Zr,{isOpen:f,onClose:ue,onContinue:ce,isPending:w})})]})};function na(){const{isLocked:e}=re(),[t]=le(),s=t.get("lang"),n=Js(s);return e||!n?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsx(Or,{}),o.jsx(xt,{permission:se.EDIT_THEME,children:o.jsx(ea,{})}),o.jsx(Xr,{}),o.jsx(xt,{permission:se.SAVE_PAGE,children:o.jsx(ta,{})}),o.jsx(xt,{permission:se.PUBLISH_PAGE,children:o.jsx(sa,{})})]})}const Zs=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{t:d}=P.useTranslation(),{hasPermission:u}=P.usePermissions(),{data:f}=ge(),E=h.useMemo(()=>p.find(f,{key:e.pageType}),[f,e.pageType]),m=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),A=h.useMemo(()=>!!(E!=null&&E.hasSlug),[E==null?void 0:E.hasSlug]);return!u(se.EDIT_PAGE)&&!u(se.DELETE_PAGE)&&!u(se.UNPUBLISH_PAGE)||!e?null:o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,onClick:v=>v.stopPropagation(),children:l}),o.jsxs(g.DropdownMenuContent,{align:"center",className:"text-sm",children:[u(se.ADD_PAGE)&&!c&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),t(e)},children:[o.jsx(x.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),u(se.EDIT_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),s({...e,global:!(E!=null&&E.hasSlug)})},children:[o.jsx(x.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&u(se.UNPUBLISH_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),n(e)},children:[o.jsx(x.Power,{className:"size-3"}),d("Unpublish")]}),u(se.DELETE_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),r(e)},children:[o.jsx(x.Trash,{className:"size-3"}),d("Delete")]}),u(se.MARK_AS_TEMPLATE)&&A&&!c&&o.jsx(o.Fragment,{children:m?o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),i(e)},children:[o.jsx(x.SquareLibrary,{className:"size-3"}),d("Unmark as template")]}):o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:v=>{v.stopPropagation(),a(e)},children:[o.jsx(x.SquareLibrary,{className:"size-3"}),d("Mark as template")]})})]})]})},ra=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-B0OggHcf.cjs"))),aa=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-CGeb5OY9.cjs"))),ia=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-WQGy0j2w.cjs"))),oa=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-Iecl3b9-.cjs"))),la=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-CIBRCR59.cjs"))),ca=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-CmUXigiU.cjs"))),ua=()=>{const[e,t]=h.useState(null),[s,n]=h.useState(null),[r,a]=h.useState(null),[i,l]=h.useState(null),[c,d]=h.useState(null),[u,f]=h.useState(null),{data:E,isFetching:m}=he(),{selectedLang:A,fallbackLang:w}=P.useLanguages(),{data:v}=Ae(),M=v==null?void 0:v.find(D=>D.lang===A),{isLocked:T}=re(),C=!(E!=null&&E.slug),[,L]=H.useAtom(Rt);if(!E)return null;const q=D=>{A.length>0&&A!==w?L({edit:!0,id:D==null?void 0:D.id,primaryPage:D==null?void 0:D.primaryPage}):f(D)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between rounded px-[2px] transition-colors duration-200",children:[o.jsx($s,{children:o.jsx(g.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:m?o.jsx(x.Loader,{className:"h-4 w-4 animate-spin text-slate-400"}):o.jsxs("span",{className:"flex w-full cursor-pointer items-end overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-xs font-medium",children:[C?o.jsx(x.Hash,{className:"mr-1 h-4 w-4"}):o.jsx(x.File,{className:"mr-1 h-4 w-4"}),p.get(M||E,"name")??""]})})}),T?o.jsx(g.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:o.jsx(x.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx(Zs,{page:E,setDuplicatePage:D=>d(D),setAddEditPage:D=>q(D),setUnpublishPage:D=>n(D),setDeletePage:D=>t(D),setMarkAsTemplate:D=>a(D),setUnmarkAsTemplate:D=>l(D),isLanguagePage:A.length>0&&A!==w,children:o.jsx(g.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(x.MoreHorizontal,{className:"h-4 w-4"})})})]}),u&&o.jsx(h.Suspense,{children:o.jsx(ra,{closePanel:()=>f(null),editPage:()=>{},addEditPage:u,setAddEditPage:f})}),e&&o.jsx(h.Suspense,{children:o.jsx(aa,{page:e,onClose:()=>t(null)})}),s&&o.jsx(h.Suspense,{children:o.jsx(ca,{page:s,onClose:()=>n(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx(oa,{page:r,onClose:()=>a(null)})}),i&&o.jsx(h.Suspense,{children:o.jsx(la,{page:i,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(ia,{page:c,onClose:()=>d(null),closePanel:()=>f(null)})})]})},hs=({children:e,className:t=""})=>o.jsx("div",{className:P.mergeClasses("fixed bottom-0 left-0 right-0 top-[50px] z-[20] flex w-screen flex-col items-center justify-center bg-black/40 transition-all",t),children:e}),da=({hasDynamicPage:e})=>o.jsx(hs,{children:o.jsxs("div",{className:"flex min-w-[300px] max-w-[400px] flex-col items-center justify-center rounded-lg border bg-white p-4 shadow-lg",children:[o.jsx("h1",{className:"text-lg font-medium",children:e?"Select a page":"No pages found"}),o.jsx("p",{className:"pt-2 text-center text-sm font-light text-gray-600",children:e?"Please select a page from the list in the top header. This will enable you to edit the page.":"Please add a new page"})]})}),fa=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-Bxc0QbN-.cjs"))),ha=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=Vs(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(da,{hasDynamicPage:n}),o.jsx(h.Suspense,{children:o.jsx(fa,{})})]})},ga=()=>{const{data:e,isFetching:t}=he(),{data:s,isFetching:n}=te(),r=p.get(s,"dynamic",!1),a=as(),i=P.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,d=pr(),u=t||n,E=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return o.jsxs("div",{className:"relative flex items-center gap-x-1",children:[o.jsx("div",{className:P.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",u&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(ua,{})}),o.jsxs("div",{className:P.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800"+(c?" pr-2":""),u&&"max-w-0 overflow-hidden opacity-0"),children:[o.jsx(Ws,{}),o.jsxs("div",{className:"flex w-full items-center overflow-hidden",children:[o.jsx("div",{className:`w-full max-w-[200px] overflow-hidden overflow-ellipsis whitespace-nowrap pl-1 text-xs ${c?"italic text-gray-400":"font-mono text-gray-500"}`,children:E==="/"?o.jsxs("span",{className:"text-gray-900",children:["/",o.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):E}),!c&&o.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",children:o.jsx("div",{className:"ml-2 mr-px flex-shrink-0 rounded-sm p-1.5 text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",children:o.jsx(x.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&i&&o.jsx(ha,{})]})},ma=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(Dr,{}),o.jsx(ga,{}),o.jsx(na,{})]}),Xs=()=>{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}},Ea=()=>{const e=j(),{aiContext:t}=Xs(),s=N();return h.useCallback(async(n,r,a,i)=>s(e,{action:y.ASK_AI,data:{type:n,prompt:r,blocks:a,context:t,lang:i}}),[e,t,s])},pa=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=Bs.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}),ya=e=>{const t=Bs.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:pa(t,s)}},[e,t])},Aa=()=>{const[e]=le(),t=e.get("page"),s=j(),{setAiContext:n}=Xs(),[,r]=is(),[,a]=Er(),[,i]=P.useIsPageLoaded(),l=N();return S.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{i(!1);const c=await l(s,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),d=c.blocks??[],u=p.find(d,{_type:"@chai/ai-context"});return n(p.get(u,"_value","")||""),r(f=>({...f,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),d},enabled:!!t})},en=()=>{const{data:e}=te(),{data:t}=he(),s=j(),n=N(),r=Ut(),a=as();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})},tn=()=>{const e=j(),t=S.useQueryClient(),s=N();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})}})},Ta=()=>{const e=j(),t=S.useQueryClient(),s=N(),{selectedLang:n}=P.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})}})},Sa=()=>{const e=j(),t=S.useQueryClient(),s=N(),{selectedLang:n}=P.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})}})},Pa=()=>{const e=j(),t=S.useQueryClient(),s=N();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})}})},_a=()=>{const e=j(),t=N();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})}})},xa=()=>{const e=j(),t=N();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})}})},wa=()=>{const e=j(),t=N();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})}})},vs={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:P.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),[]}}},va=()=>{const e=j(),t=N();return S.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{P.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>vs.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>vs.getUILibraryBlock(a,t,e)})}),n}})},sn=()=>{const e=Fs(),t=N(),{user:s}=Mt(),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:{userId:n}}),enabled:!!n,staleTime:1/0})},ba=()=>{const e=j(),t=N(),[,s]=is();return{onSave:async({page:r,blocks:a,needTranslations:i})=>{try{const l=await t(e,{action:"UPDATE_PAGE",data:{id:r,blocks:a,needTranslations:i}});return l.code==="PAGE_LOCKED"?!0:(s(c=>({...c,lastSaved:new Date().toISOString()})),l)}catch(l){return console.error(l),new Error("Failed to save blocks")}}}},Ia=()=>{const{data:e}=ds(),t=j(),s=N();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])}},Ca=h.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-content-NdOClQP-.cjs")).then(e=>e.aiPanelContent)),nn="chai-chat-panel",La=({className:e="h-full w-full"})=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",version:"1.1",className:e,children:[o.jsx("title",{children:"ai"}),o.jsx("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:o.jsx("g",{id:"icon",fill:"currentColor",transform:"translate(64.000000, 64.000000)",children:o.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"})})})]}),Na=({isActive:e,show:t})=>o.jsx(g.Button,{size:"icon",className:"p-0 [&_svg]:size-6",onClick:t,variant:e?"default":"ghost",children:o.jsx(La,{className:e?"h-5 w-5 text-white":"h-5 w-5 text-primary"})}),ja={id:nn,label:"AI Assistant",button:Na,panel:Ca,position:"top"},Da=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-_j4w2xyy.cjs"))),Ga=({isActive:e,show:t})=>{const{data:s}=Te();return!p.has(s,"languages")||!p.get(s,"languages",[]).length?null:o.jsx(g.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:o.jsx(x.LanguagesIcon,{className:"h-4 w-4"})})},rn="lang",ka={id:rn,label:"Languages",position:"top",panel:Da,button:Ga,view:"modal",width:400},Oa=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-BZQVr7WN.cjs"))),an="seo",Ra=({isActive:e,show:t})=>{const{data:s}=te(),n=Ys(s==null?void 0:s.pageType);return!p.has(n,"hasSlug")||!n.hasSlug?null:o.jsx(g.Button,{size:"icon",className:"my-1 p-0",onClick:t,variant:e?"default":"ghost",children:o.jsxs("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M7 8h-3a1 1 0 0 0 -1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-3"}),o.jsx("path",{d:"M14 16h-4v-8h4"}),o.jsx("path",{d:"M11 12h2"}),o.jsx("path",{d:"M17 8m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]})})},Ma={id:an,label:"SEO",panel:Oa,button:Ra,position:"top",width:600,view:"modal"},on="user-info",Ua=()=>{const{t:e}=P.useTranslation(),{user:t,logout:s}=Mt(),n=ne("onLogout",p.noop);return t?o.jsxs(g.HoverCard,{children:[o.jsx(g.HoverCardTrigger,{asChild:!0,children:o.jsx(g.Button,{variant:"ghost",className:"text-sm font-medium",children:o.jsx(x.User,{className:"h-4 w-4"})})}),o.jsxs(g.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[o.jsx("div",{className:"text-sm font-medium",children:t.name??t.email}),o.jsx("div",{className:"text-xs text-muted-foreground",children:t.email}),o.jsxs(g.AlertDialog,{children:[o.jsx(g.AlertDialogTrigger,{asChild:!0,children:o.jsx(g.Button,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),o.jsxs(g.AlertDialogContent,{children:[o.jsxs(g.AlertDialogHeader,{children:[o.jsx(g.AlertDialogTitle,{children:e("Are you sure you want to logout?")}),o.jsx(g.AlertDialogDescription,{children:e("You will be redirected to the login page.")})]}),o.jsxs(g.AlertDialogFooter,{children:[o.jsx(g.AlertDialogCancel,{children:e("Cancel")}),o.jsx(g.AlertDialogAction,{onClick:()=>{s(),p.isFunction(n)&&n()},children:e("Logout")})]})]})]})]})]}):null},Ba={id:on,label:"User Info",button:Ua,position:"bottom"},Fa=()=>{P.registerChaiSidebarPanel(an,Ma),P.registerChaiSidebarPanel(rn,ka),P.registerChaiSidebarPanel(on,Ba),(localStorage.getItem("chai-feature-flags")??"").includes("enable-ai-chat-panel")&&P.registerChaiSidebarPanel(nn,ja)};var b={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return bs(this.context.count)},getNextContextId(){return bs(this.context.count++)}};function bs(e){const t=String(e),s=t.length-1;return b.context.id+(s?String.fromCharCode(96+s):"")+t}function $e(e){b.context=e}var ln=!1,qa=(e,t)=>e===t,It=Symbol("solid-proxy"),cn=typeof Proxy=="function",gs=Symbol("solid-track"),Ct={equals:qa},un=yn,me=1,Lt=2,dn={owned:null,cleanups:null,context:null,owner:null},Ht={},k=null,Qt=null,Ka=null,U=null,Z=null,fe=null,Ft=0;function Ee(e,t){const s=U,n=k,r=e.length===0,a=t===void 0?n:t,i=r?dn:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>Y(()=>Xe(i)));k=i,U=null;try{return oe(l,!0)}finally{U=s,k=n}}function V(e,t){t=t?Object.assign({},Ct,t):Ct;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),pn(s,r));return[En.bind(s),n]}function fn(e,t,s){const n=qt(e,t,!0,me);Qe(n)}function pe(e,t,s){const n=qt(e,t,!1,me);Qe(n)}function ms(e,t,s){un=si;const n=qt(e,t,!1,me);(!s||!s.render)&&(n.user=!0),fe?fe.push(n):Qe(n)}function $(e,t,s){s=s?Object.assign({},Ct,s):Ct;const n=qt(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,Qe(n),En.bind(n)}function Va(e){return e&&typeof e=="object"&&"then"in e}function Ha(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=Ht,c=null,d=!1,u="initialValue"in a,f=typeof n=="function"&&$(n);const E=new Set,[m,A]=(a.storage||V)(a.initialValue),[w,v]=V(void 0),[M,T]=V(void 0,{equals:!1}),[C,L]=V(u?"ready":"unresolved");b.context&&(c=b.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function q(I,G,W,Q){return i===I&&(i=null,Q!==void 0&&(u=!0),(I===l||G===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(Q,{value:G})),l=Ht,D(G,W)),G}function D(I,G){oe(()=>{G===void 0&&A(()=>I),L(G!==void 0?"errored":u?"ready":"unresolved"),v(G);for(const W of E.keys())W.decrement();E.clear()},!1)}function ce(){const I=Xa,G=m(),W=w();if(W!==void 0&&!i)throw W;return U&&U.user,G}function ue(I=!0){if(I!==!1&&d)return;d=!1;const G=f?f():n;if(G==null||G===!1){q(i,Y(m));return}let W;const Q=l!==Ht?l:Y(()=>{try{return r(G,{value:m(),refetching:I})}catch(ae){W=ae}});if(W!==void 0){q(i,void 0,vt(W),G);return}else if(!Va(Q))return q(i,Q,void 0,G),Q;return i=Q,"v"in Q?(Q.s===1?q(i,Q.v,void 0,G):q(i,void 0,vt(Q.v),G),Q):(d=!0,queueMicrotask(()=>d=!1),oe(()=>{L(u?"refreshing":"pending"),T()},!1),Q.then(ae=>q(Q,ae,void 0,G),ae=>q(Q,void 0,vt(ae),G)))}Object.defineProperties(ce,{state:{get:()=>C()},error:{get:()=>w()},loading:{get(){const I=C();return I==="pending"||I==="refreshing"}},latest:{get(){if(!u)return ce();const I=w();if(I&&!i)throw I;return m()}}});let K=k;return f?fn(()=>(K=k,ue(!1))):ue(!1),[ce,{refetch:I=>gn(K,()=>ue(I)),mutate:A}]}function Qa(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 za(e,t,s){const n=Array.isArray(e);let r,a=s&&s.defer;return i=>{let l;if(n){l=Array(e.length);for(let d=0;d<e.length;d++)l[d]=e[d]()}else l=e();if(a)return a=!1,i;const c=Y(()=>t(l,r,i));return r=l,c}}function hn(e){ms(()=>Y(e))}function Ve(e){return k===null||(k.cleanups===null?k.cleanups=[e]:k.cleanups.push(e)),e}function Is(){return k}function gn(e,t){const s=k,n=U;k=e,U=null;try{return oe(t,!0)}catch(r){Es(r)}finally{k=s,U=n}}function $a(e){const t=U,s=k;return Promise.resolve().then(()=>{U=t,k=s;let n;return oe(e,!1),U=k=null,n?n.done:void 0})}var[Wa,ll]=V(!1);function Ya(){return[Wa,$a]}function Ja(e,t){const s=Symbol("context");return{id:s,Provider:ni(s),defaultValue:e}}function Za(e){let t;return k&&k.context&&(t=k.context[e.id])!==void 0?t:e.defaultValue}function mn(e){const t=$(e),s=$(()=>Yt(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var Xa;function En(){if(this.sources&&this.state)if(this.state===me)Qe(this);else{const e=Z;Z=null,oe(()=>jt(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 pn(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],i=Qt&&Qt.running;i&&Qt.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?Z.push(a):fe.push(a),a.observers&&An(a)),i||(a.state=me)}if(Z.length>1e6)throw Z=[],new Error},!1)),t}function Qe(e){if(!e.fn)return;Xe(e);const t=Ft;ei(e,e.value,t)}function ei(e,t,s){let n;const r=k,a=U;U=k=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=me,e.owned&&e.owned.forEach(Xe),e.owned=null),e.updatedAt=s+1,Es(i)}finally{U=a,k=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?pn(e,n):e.value=n,e.updatedAt=s)}function qt(e,t,s,n=me,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:k,context:k?k.context:null,pure:s};return k===null||k!==dn&&(k.owned?k.owned.push(a):k.owned=[a]),a}function Nt(e){if(e.state===0)return;if(e.state===Lt)return jt(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<Ft);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===me)Qe(e);else if(e.state===Lt){const n=Z;Z=null,oe(()=>jt(e,t[0]),!1),Z=n}}function oe(e,t){if(Z)return e();let s=!1;t||(Z=[]),fe?s=!0:fe=[],Ft++;try{const n=e();return ti(s),n}catch(n){s||(fe=null),Z=null,Es(n)}}function ti(e){if(Z&&(yn(Z),Z=null),e)return;const t=fe;fe=null,t.length&&oe(()=>un(t),!1)}function yn(e){for(let t=0;t<e.length;t++)Nt(e[t])}function si(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:Nt(n)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,s));return}$e()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],s+=b.effects.length,delete b.effects),t=0;t<s;t++)Nt(e[t])}function jt(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===me?n!==t&&(!n.updatedAt||n.updatedAt<Ft)&&Nt(n):r===Lt&&jt(n,t)}}}function An(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=Lt,s.pure?Z.push(s):fe.push(s),s.observers&&An(s))}}function Xe(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),r=s.observers;if(r&&r.length){const a=r.pop(),i=s.observerSlots.pop();n<r.length&&(a.sourceSlots[i]=n,r[n]=a,s.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)Xe(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)Xe(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 vt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Es(e,t=k){throw vt(e)}function Yt(e){if(typeof e=="function"&&!e.length)return Yt(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Yt(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function ni(e,t){return function(n){let r;return pe(()=>r=Y(()=>(k.context={...k.context,[e]:n.value},mn(()=>n.children))),void 0),r}}var Jt=Symbol("fallback");function Dt(e){for(let t=0;t<e.length;t++)e[t]()}function ri(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return Ve(()=>Dt(a)),()=>{let c=e()||[],d=c.length,u,f;return c[gs],Y(()=>{let m,A,w,v,M,T,C,L,q;if(d===0)i!==0&&(Dt(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[Jt],r[0]=Ee(D=>(a[0]=D,s.fallback())),i=1);else if(i===0){for(r=new Array(d),f=0;f<d;f++)n[f]=c[f],r[f]=Ee(E);i=d}else{for(w=new Array(d),v=new Array(d),l&&(M=new Array(d)),T=0,C=Math.min(i,d);T<C&&n[T]===c[T];T++);for(C=i-1,L=d-1;C>=T&&L>=T&&n[C]===c[L];C--,L--)w[L]=r[C],v[L]=a[C],l&&(M[L]=l[C]);for(m=new Map,A=new Array(L+1),f=L;f>=T;f--)q=c[f],u=m.get(q),A[f]=u===void 0?-1:u,m.set(q,f);for(u=T;u<=C;u++)q=n[u],f=m.get(q),f!==void 0&&f!==-1?(w[f]=r[u],v[f]=a[u],l&&(M[f]=l[u]),f=A[f],m.set(q,f)):a[u]();for(f=T;f<d;f++)f in w?(r[f]=w[f],a[f]=v[f],l&&(l[f]=M[f],l[f](f))):r[f]=Ee(E);r=r.slice(0,i=d),n=c.slice(0)}return r});function E(m){if(a[f]=m,l){const[A,w]=V(f);return l[f]=w,t(c[f],A)}return t(c[f])}}}function ai(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return Ve(()=>Dt(a)),()=>{const d=e()||[],u=d.length;return d[gs],Y(()=>{if(u===0)return l!==0&&(Dt(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[Jt],r[0]=Ee(E=>(a[0]=E,s.fallback())),l=1),r;for(n[0]===Jt&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<u;c++)c<n.length&&n[c]!==d[c]?i[c](()=>d[c]):c>=n.length&&(r[c]=Ee(f));for(;c<n.length;c++)a[c]();return l=i.length=a.length=u,n=d.slice(0),r=r.slice(0,l)});function f(E){a[c]=E;const[m,A]=V(d[c]);return i[c]=A,t(m,c)}}}function ps(e,t){return Y(()=>e(t||{}))}function St(){return!0}var Zt={get(e,t,s){return t===It?s:e.get(t)},has(e,t){return t===It?!0:e.has(t)},set:St,deleteProperty:St,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:St,deleteProperty:St}},ownKeys(e){return e.keys()}};function zt(e){return(e=typeof e=="function"?e():e)?e:{}}function ii(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function ys(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&It in l,e[i]=typeof l=="function"?(t=!0,$(l)):l}if(cn&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=zt(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in zt(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(zt(e[l])));return[...new Set(i)]}},Zt);const s={},n=Object.create(null);for(let i=e.length-1;i>=0;i--){const l=e[i];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let d=c.length-1;d>=0;d--){const u=c[d];if(u==="__proto__"||u==="constructor")continue;const f=Object.getOwnPropertyDescriptor(l,u);if(!n[u])n[u]=f.get?{enumerable:!0,configurable:!0,get:ii.bind(s[u]=[f.get.bind(l)])}:f.value!==void 0?f:void 0;else{const E=s[u];E&&(f.get?E.push(f.get.bind(l)):f.value!==void 0&&E.push(()=>f.value))}}}const r={},a=Object.keys(n);for(let i=a.length-1;i>=0;i--){const l=a[i],c=n[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function Tn(e,...t){if(cn&&It in e){const r=new Set(t.length>1?t.flat():t[0]),a=t.map(i=>new Proxy({get(l){return i.includes(l)?e[l]:void 0},has(l){return i.includes(l)&&l in e},keys(){return i.filter(l=>l in e)}},Zt));return a.push(new Proxy({get(i){return r.has(i)?void 0:e[i]},has(i){return r.has(i)?!1:i in e},keys(){return Object.keys(e).filter(i=>!r.has(i))}},Zt)),a}const s={},n=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),i=!a.get&&!a.set&&a.enumerable&&a.writable&&a.configurable;let l=!1,c=0;for(const d of t)d.includes(r)&&(l=!0,i?n[c][r]=a.value:Object.defineProperty(n[c],r,a)),++c;l||(i?s[r]=a.value:Object.defineProperty(s,r,a))}return[...n,s]}function Sn(e){let t,s;const n=r=>{const a=b.context;if(a){const[l,c]=V();b.count||(b.count=0),b.count++,(s||(s=e())).then(d=>{!b.done&&$e(a),b.count--,c(()=>d.default),$e()}),t=l}else if(!t){const[l]=Ha(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return $(()=>(i=t())?Y(()=>{if(!a||b.done)return i(r);const l=b.context;$e(a);const c=i(r);return $e(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var oi=0;function li(){return b.context?b.getNextContextId():`cl-${oi++}`}var Pn=e=>`Stale read from <${e}>.`;function ci(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(ri(()=>e.each,e.children,t||void 0))}function ui(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(ai(()=>e.each,e.children,t||void 0))}function di(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 Pn("Show");return s()})):a}return e.fallback},void 0,void 0)}function fi(e){const t=mn(()=>e.children),s=$(()=>{const n=t(),r=Array.isArray(n)?n:[n];let a=()=>{};for(let i=0;i<r.length;i++){const l=i,c=r[i],d=a,u=$(()=>d()?void 0:c.when,void 0,void 0),f=c.keyed?u:$(u,void 0,{equals:(E,m)=>!E==!m});a=()=>d()||(f()?[l,u,c]:void 0)}return a});return $(()=>{const n=s()();if(!n)return e.fallback;const[r,a,i]=n,l=i.children;return typeof l=="function"&&l.length>0?Y(()=>l(i.keyed?a():()=>{var d;if(((d=Y(s)())==null?void 0:d[0])!==r)throw Pn("Match");return a()})):l},void 0,void 0)}function hi(e){return e}var gi=["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"],mi=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...gi]),Ei=new Set(["innerHTML","textContent","innerText","children"]),pi=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),yi=Object.assign(Object.create(null),{class:"className",novalidate:{$:"noValidate",FORM:1},formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function Ai(e,t){const s=yi[e];return typeof s=="object"?s[t]?s.$:void 0:s}var Ti=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),Si=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"]),Pi={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},_i=e=>$(()=>e());function xi(e,t,s){let n=s.length,r=t.length,a=n,i=0,l=0,c=t[r-1].nextSibling,d=null;for(;i<r||l<a;){if(t[i]===s[l]){i++,l++;continue}for(;t[r-1]===s[a-1];)r--,a--;if(r===i){const u=a<n?l?s[l-1].nextSibling:s[a-l]:c;for(;l<a;)e.insertBefore(s[l++],u)}else if(a===l)for(;i<r;)(!d||!d.has(t[i]))&&t[i].remove(),i++;else if(t[i]===s[a-1]&&s[l]===t[r-1]){const u=t[--r].nextSibling;e.insertBefore(s[l++],t[i++].nextSibling),e.insertBefore(s[--a],u),t[r]=s[a]}else{if(!d){d=new Map;let f=l;for(;f<a;)d.set(s[f],f++)}const u=d.get(t[i]);if(u!=null)if(l<u&&u<a){let f=i,E=1,m;for(;++f<r&&f<a&&!((m=d.get(t[f]))==null||m!==u+E);)E++;if(E>u-l){const A=t[i];for(;l<u;)e.insertBefore(s[l++],A)}else e.replaceChild(s[l++],t[i++])}else i++;else t[i++].remove()}}}var Je="_$DX_DELEGATE";function _n(e,t,s,n={}){let r;return Ee(a=>{r=a,t===document?e():kt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function wi(e,t,s,n){let r;const a=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},i=()=>(r||(r=a())).cloneNode(!0);return i.cloneNode=i,i}function xn(e,t=window.document){const s=t[Je]||(t[Je]=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,Cn))}}function vi(e=window.document){if(e[Je]){for(let t of e[Je].keys())e.removeEventListener(t,Cn);delete e[Je]}}function Gt(e,t,s){we(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function bi(e,t,s,n){we(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function Ii(e,t,s){we(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function wn(e,t){we(e)||(t==null?e.removeAttribute("class"):e.className=t)}function vn(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 Ci(e,t,s={}){const n=Object.keys(t||{}),r=Object.keys(s);let a,i;for(a=0,i=r.length;a<i;a++){const l=r[a];!l||l==="undefined"||t[l]||(Cs(e,l,!1),delete s[l])}for(a=0,i=n.length;a<i;a++){const l=n[a],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(Cs(e,l,!0),s[l]=c)}return s}function Li(e,t,s){if(!t)return s?Gt(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 bn(e,t={},s,n){const r={};return n||pe(()=>r.children=et(e,t.children,r.children)),pe(()=>typeof t.ref=="function"&&In(t.ref,e)),pe(()=>Ni(e,t,s,!0,r,!0)),r}function In(e,t,s){return Y(()=>e(t,s))}function kt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return et(e,t,n,s);pe(r=>et(e,t(),r,s),n)}function Ni(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Ls(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Ls(e,i,l,r[i],s,a,t)}}function ji(e){let t,s;return!we()||!(t=b.registry.get(s=Gi()))?e():(b.completed&&b.completed.add(t),b.registry.delete(s),t)}function we(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function Di(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Cs(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 Ls(e,t,s,n,r,a,i){let l,c,d,u,f;if(t==="style")return Li(e,s,n);if(t==="classList")return Ci(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(),m=Ti.has(E);if(!m&&n){const A=Array.isArray(n)?n[0]:n;e.removeEventListener(E,A)}(m||s)&&(vn(e,E,s,m),m&&xn([E]))}else if(t.slice(0,5)==="attr:")Gt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")Ii(e,t.slice(5),s);else if((f=t.slice(0,5)==="prop:")||(d=Ei.has(t))||!r&&((u=Ai(t,e.tagName))||(c=mi.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(f)t=t.slice(5),c=!0;else if(we(e))return s;t==="class"||t==="className"?wn(e,s):l&&!c&&!d?e[Di(t)]=s:e[u||t]=s}else{const E=r&&t.indexOf(":")>-1&&Pi[t.split(":")[0]];E?bi(e,E,t,s):Gt(e,pi[t]||t,s)}return s}function Cn(e){if(b.registry&&b.events&&b.events.find(([c,d])=>d===e))return;let t=e.target;const s=`$$${e.type}`,n=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),i=()=>{const c=t[s];if(c&&!t.disabled){const d=t[`${s}Data`];if(d!==void 0?c.call(t,d,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},l=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),b.registry&&!b.done&&(b.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let d=0;d<c.length-2&&(t=c[d],!!i());d++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function et(e,t,s,n,r){const a=we(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let d=0;d<s.length;d++){const u=s[d];u.nodeType===8&&u.data.slice(0,2)==="!$"?u.remove():c.push(u)}s=c}for(;typeof s=="function";)s=s();if(t===s)return s;const i=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,i==="string"||i==="number"){if(a||i==="number"&&(t=t.toString(),t===s))return s;if(l){let c=s[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),s=be(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||i==="boolean"){if(a)return s;s=be(e,s,n)}else{if(i==="function")return pe(()=>{let c=t();for(;typeof c=="function";)c=c();s=et(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],d=s&&Array.isArray(s);if(Xt(c,t,s,r))return pe(()=>s=et(e,c,s,n,!0)),()=>s;if(a){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let u=c[0];if(u.parentNode!==e)return s;const f=[u];for(;(u=u.nextSibling)!==n;)f.push(u);return s=f}if(c.length===0){if(s=be(e,s,n),l)return s}else d?s.length===0?Ns(e,c,n):xi(e,s,c):(s&&be(e),Ns(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=be(e,s,n,t);be(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function Xt(e,t,s,n){let r=!1;for(let a=0,i=t.length;a<i;a++){let l=t[a],c=s&&s[e.length],d;if(!(l==null||l===!0||l===!1))if((d=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=Xt(e,l,c)||r;else if(d==="function")if(n){for(;typeof l=="function";)l=l();r=Xt(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const u=String(l);c&&c.nodeType===3&&c.data===u?e.push(c):e.push(document.createTextNode(u))}}return r}function Ns(e,t,s=null){for(let n=0,r=t.length;n<r;n++)e.insertBefore(t[n],s)}function be(e,t,s,n){if(s===void 0)return e.textContent="";const r=n||document.createTextNode("");if(t.length){let a=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(r!==l){const c=l.parentNode===e;!a&&!i?c?e.replaceChild(r,l):e.insertBefore(r,s):c&&l.remove()}else a=!0}}else e.insertBefore(r,s);return[r]}function Gi(){return b.getNextContextId()}var ki="http://www.w3.org/2000/svg";function Ln(e,t=!1){return t?document.createElementNS(ki,e):document.createElement(e)}function Oi(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=Is();let a,i=!!b.context;return ms(()=>{i&&(Is().user=i=!1),a||(a=gn(r,()=>$(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,d]=V(!1),u=()=>d(!0);Ee(f=>kt(l,()=>c()?f():a(),null)),Ve(u)}else{const c=Ln(e.isSVG?"g":"div",e.isSVG),d=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),kt(d,a),l.appendChild(c),e.ref&&e.ref(c),Ve(()=>l.removeChild(c))}},void 0,{render:!i}),s}function Ri(e,t){const s=$(e);return $(()=>{const n=s();switch(typeof n){case"function":return Y(()=>n(t));case"string":const r=Si.has(n),a=b.context?ji():Ln(n,r);return bn(a,t,r),a}})}function Mi(e){const[,t]=Tn(e,["component"]);return Ri(()=>e.component,t)}var Ui=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()}},Nn=class{constructor(e){this.generateIdentifier=e,this.kv=new Ui}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)}},Bi=class extends Nn{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 Fi(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 qi(e,t){const s=Fi(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 He(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function bt(e,t){return e.indexOf(t)!==-1}function js(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var Ki=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return qi(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Vi=e=>Object.prototype.toString.call(e).slice(8,-1),jn=e=>typeof e>"u",Hi=e=>e===null,tt=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,es=e=>tt(e)&&Object.keys(e).length===0,ye=e=>Array.isArray(e),Qi=e=>typeof e=="string",zi=e=>typeof e=="number"&&!isNaN(e),$i=e=>typeof e=="boolean",Wi=e=>e instanceof RegExp,st=e=>e instanceof Map,nt=e=>e instanceof Set,Dn=e=>Vi(e)==="Symbol",Yi=e=>e instanceof Date&&!isNaN(e.valueOf()),Ji=e=>e instanceof Error,Ds=e=>typeof e=="number"&&isNaN(e),Zi=e=>$i(e)||Hi(e)||jn(e)||zi(e)||Qi(e)||Dn(e),Xi=e=>typeof e=="bigint",eo=e=>e===1/0||e===-1/0,to=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),so=e=>e instanceof URL,Gn=e=>e.replace(/\./g,"\\."),$t=e=>e.map(String).map(Gn).join("."),Ze=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 ie(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var kn=[ie(jn,"undefined",()=>null,()=>{}),ie(Xi,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),ie(Yi,"Date",e=>e.toISOString(),e=>new Date(e)),ie(Ji,"Error",(e,t)=>{const s={name:e.name,message:e.message};return t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s},(e,t)=>{const s=new Error(e.message);return s.name=e.name,s.stack=e.stack,t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s}),ie(Wi,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),ie(nt,"set",e=>[...e.values()],e=>new Set(e)),ie(st,"map",e=>[...e.entries()],e=>new Map(e)),ie(e=>Ds(e)||eo(e),"number",e=>Ds(e)?"NaN":e>0?"Infinity":"-Infinity",Number),ie(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),ie(so,"URL",e=>e.toString(),e=>new URL(e))];function Kt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var On=Kt((e,t)=>Dn(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}),no=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),Rn=Kt(to,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=no[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function Mn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Un=Kt(Mn,(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)}),Bn=Kt((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)}),ro=[Un,On,Bn,Rn],Gs=(e,t)=>{const s=js(ro,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=js(kn,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Fn={};kn.forEach(e=>{Fn[e.annotation]=e});var ao=(e,t,s)=>{if(ye(t))switch(t[0]){case"symbol":return On.untransform(e,t,s);case"class":return Un.untransform(e,t,s);case"custom":return Bn.untransform(e,t,s);case"typed-array":return Rn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=Fn[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 qn(e){if(bt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(bt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(bt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var io=(e,t)=>{qn(t);for(let s=0;s<t.length;s++){const n=t[s];if(nt(e))e=Ie(e,+n);else if(st(e)){const r=+n,a=+t[++s]==0?"key":"value",i=Ie(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},ts=(e,t,s)=>{if(qn(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(ye(n)){const l=+i;n=n[l]}else if(tt(n))n=n[i];else if(nt(n)){const l=+i;n=Ie(n,l)}else if(st(n)){if(a===t.length-2)break;const c=+i,d=+t[++a]==0?"key":"value",u=Ie(n,c);switch(d){case"key":n=u;break;case"value":n=n.get(u);break}}}const r=t[t.length-1];if(ye(n)?n[+r]=s(n[+r]):tt(n)&&(n[r]=s(n[r])),nt(n)){const a=Ie(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(st(n)){const a=+t[t.length-2],i=Ie(n,a);switch(+r==0?"key":"value"){case"key":{const c=s(i);n.set(c,n.get(i)),c!==i&&n.delete(i);break}case"value":{n.set(i,s(n.get(i)));break}}}return e};function ss(e,t,s=[]){if(!e)return;if(!ye(e)){He(e,(a,i)=>ss(a,t,[...s,...Ze(i)]));return}const[n,r]=e;r&&He(r,(a,i)=>{ss(a,t,[...s,...Ze(i)])}),t(n,s)}function oo(e,t,s){return ss(t,(n,r)=>{e=ts(e,r,a=>ao(a,n,s))}),e}function lo(e,t){function s(n,r){const a=io(e,Ze(r));n.map(Ze).forEach(i=>{e=ts(e,i,()=>a)})}if(ye(t)){const[n,r]=t;n.forEach(a=>{e=ts(e,Ze(a),()=>e)}),r&&He(r,s)}else He(t,s);return e}var co=(e,t)=>tt(e)||ye(e)||st(e)||nt(e)||Mn(e,t);function uo(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function fo(e,t){const s={};let n;return e.forEach(r=>{if(r.length<=1)return;t||(r=r.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...i]=r;a.length===0?n=i.map($t):s[$t(a)]=i.map($t)}),n?es(s)?[n]:[n,s]:es(s)?void 0:s}var Kn=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=Zi(e);if(!l){uo(e,r,t);const m=i.get(e);if(m)return n?{transformedValue:null}:m}if(!co(e,s)){const m=Gs(e,s),A=m?{transformedValue:m.value,annotations:[m.type]}:{transformedValue:e};return l||i.set(e,A),A}if(bt(a,e))return{transformedValue:null};const c=Gs(e,s),d=(c==null?void 0:c.value)??e,u=ye(d)?[]:{},f={};He(d,(m,A)=>{if(A==="__proto__"||A==="constructor"||A==="prototype")throw new Error(`Detected property ${A}. This is a prototype pollution risk, please remove it from your object.`);const w=Kn(m,t,s,n,[...r,A],[...a,e],i);u[A]=w.transformedValue,ye(w.annotations)?f[A]=w.annotations:tt(w.annotations)&&He(w.annotations,(v,M)=>{f[Gn(A)+"."+M]=v})});const E=es(f)?{transformedValue:u,annotations:c?[c.type]:void 0}:{transformedValue:u,annotations:c?[c.type,f]:f};return l||i.set(e,E),E};function Vn(e){return Object.prototype.toString.call(e).slice(8,-1)}function ks(e){return Vn(e)==="Array"}function ho(e){if(Vn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function go(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 ns(e,t={}){if(ks(e))return e.map(r=>ns(r,t));if(!ho(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(ks(t.props)&&!t.props.includes(a))return r;const i=e[a],l=ns(i,t);return go(r,a,l,e,t.nonenumerable),r},{})}var B=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Bi,this.symbolRegistry=new Nn(t=>t.description??""),this.customTransformerRegistry=new Ki,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=Kn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=fo(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=ns(t);return s!=null&&s.values&&(n=oo(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=lo(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 Hn=B.serialize,mo=B.stringify;function Eo(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function po(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function yo({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function Ao({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function To(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var So=(e,t=!1)=>{const{json:s}=Hn(e);return JSON.stringify(s,null,t?2:void 0)},Pt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,Po=(e,t)=>e.queryHash.localeCompare(t.queryHash),Qn=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,_o=(e,t)=>Pt(e)===Pt(t)?Qn(e,t):Pt(e)>Pt(t)?1:-1,xo={status:_o,"query hash":Po,"last updated":Qn},_t=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,zn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,wo=(e,t)=>_t(e)===_t(t)?zn(e,t):_t(e)>_t(t)?1:-1,vo={status:wo,"last updated":zn},bo=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),Io=()=>{const[e,t]=V("dark");return hn(()=>{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),Ve(()=>s.removeEventListener("change",n))}),e},We=(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,We(n.get(r),a,s)),n}if(e instanceof Set){const n=We(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]=We(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]=We(n[r],a,s),n}return e},Ye=(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,Ye(s.get(n),r)),s}if(e instanceof Set){const s=Ye(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((a,i)=>i.toString()!==t[0]);const[n,...r]=t;return s[n]=Ye(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]=Ye(s[n],r),s}return e},$n=(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)},Ce,rt,at,it,Pe,ot,Le,Ne,je,De,Ge,lt,ke,ct,Ms,Co=(Ms=class{constructor(e){R(this,Ce);R(this,rt);R(this,at);R(this,it);R(this,Pe,!1);R(this,ot);R(this,Le);R(this,Ne);R(this,je);R(this,De);R(this,Ge);R(this,lt);R(this,ke);R(this,ct);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:u,hideDisabledQueries:f}=e;O(this,Ce,V(t)),O(this,at,s),O(this,it,n),O(this,rt,r),O(this,ot,d),O(this,Le,u),O(this,Ne,V(a)),O(this,je,V(i)),O(this,De,V(l)),O(this,Ge,V(c)),O(this,lt,V(f))}setButtonPosition(e){_(this,Ne)[1](e)}setPosition(e){_(this,je)[1](e)}setInitialIsOpen(e){_(this,De)[1](e)}setErrorTypes(e){_(this,Ge)[1](e)}setClient(e){_(this,Ce)[1](e)}mount(e){if(_(this,Pe))throw new Error("Devtools is already mounted");const t=_n(()=>{const s=this,[n]=_(this,Ne),[r]=_(this,je),[a]=_(this,De),[i]=_(this,Ge),[l]=_(this,lt),[c]=_(this,Ce);let d;return _(this,ke)?d=_(this,ke):(d=Sn(()=>Promise.resolve().then(()=>require("./NCMVHL6D-URUKohh5.cjs"))),O(this,ke,d)),$n(_(this,ot),_(this,Le)),ps(d,ys({get queryFlavor(){return _(s,at)},get version(){return _(s,it)},get onlineManager(){return _(s,rt)},get shadowDOMTarget(){return _(s,Le)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()}}))},e);O(this,Pe,!0),O(this,ct,t)}unmount(){var e;if(!_(this,Pe))throw new Error("Devtools is not mounted");(e=_(this,ct))==null||e.call(this),O(this,Pe,!1)}},Ce=new WeakMap,rt=new WeakMap,at=new WeakMap,it=new WeakMap,Pe=new WeakMap,ot=new WeakMap,Le=new WeakMap,Ne=new WeakMap,je=new WeakMap,De=new WeakMap,Ge=new WeakMap,lt=new WeakMap,ke=new WeakMap,ct=new WeakMap,Ms),Oe,ut,dt,ft,_e,ht,Re,Me,Ue,Be,Fe,gt,qe,Ke,mt,Us,Lo=(Us=class{constructor(e){R(this,Oe);R(this,ut);R(this,dt);R(this,ft);R(this,_e,!1);R(this,ht);R(this,Re);R(this,Me);R(this,Ue);R(this,Be);R(this,Fe);R(this,gt);R(this,qe);R(this,Ke);R(this,mt);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:u,onClose:f,hideDisabledQueries:E}=e;O(this,Oe,V(t)),O(this,dt,s),O(this,ft,n),O(this,ut,r),O(this,ht,d),O(this,Re,u),O(this,Me,V(a)),O(this,Ue,V(i)),O(this,Be,V(l)),O(this,Fe,V(c)),O(this,gt,V(E)),O(this,qe,V(f))}setButtonPosition(e){_(this,Me)[1](e)}setPosition(e){_(this,Ue)[1](e)}setInitialIsOpen(e){_(this,Be)[1](e)}setErrorTypes(e){_(this,Fe)[1](e)}setClient(e){_(this,Oe)[1](e)}setOnClose(e){_(this,qe)[1](()=>e)}mount(e){if(_(this,_e))throw new Error("Devtools is already mounted");const t=_n(()=>{const s=this,[n]=_(this,Me),[r]=_(this,Ue),[a]=_(this,Be),[i]=_(this,Fe),[l]=_(this,gt),[c]=_(this,Oe),[d]=_(this,qe);let u;return _(this,Ke)?u=_(this,Ke):(u=Sn(()=>Promise.resolve().then(()=>require("./2AITGKQY-CW6frR_j.cjs"))),O(this,Ke,u)),$n(_(this,ht),_(this,Re)),ps(u,ys({get queryFlavor(){return _(s,dt)},get version(){return _(s,ft)},get onlineManager(){return _(s,ut)},get shadowDOMTarget(){return _(s,Re)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get onClose(){return d()}}))},e);O(this,_e,!0),O(this,mt,t)}unmount(){var e;if(!_(this,_e))throw new Error("Devtools is not mounted");(e=_(this,mt))==null||e.call(this),O(this,_e,!1)}},Oe=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,_e=new WeakMap,ht=new WeakMap,Re=new WeakMap,Me=new WeakMap,Ue=new WeakMap,Be=new WeakMap,Fe=new WeakMap,gt=new WeakMap,qe=new WeakMap,Ke=new WeakMap,mt=new WeakMap,Us);function No(e){const t=S.useQueryClient(e.client),s=z.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}=e,[u]=z.useState(new Co({client:t,queryFlavor:"React Query",version:"5",onlineManager:S.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}));return z.useEffect(()=>{u.setClient(t)},[t,u]),z.useEffect(()=>{n&&u.setButtonPosition(n)},[n,u]),z.useEffect(()=>{r&&u.setPosition(r)},[r,u]),z.useEffect(()=>{u.setInitialIsOpen(a||!1)},[a,u]),z.useEffect(()=>{u.setErrorTypes(i||[])},[i,u]),z.useEffect(()=>(s.current&&u.mount(s.current),()=>{u.unmount()}),[u]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function jo(e){const t=S.useQueryClient(e.client),s=z.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i}=e,[l]=z.useState(new Lo({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:i}));return z.useEffect(()=>{l.setClient(t)},[t,l]),z.useEffect(()=>{l.setOnClose(e.onClose??(()=>{}))},[e.onClose,l]),z.useEffect(()=>{l.setErrorTypes(n||[])},[n,l]),z.useEffect(()=>(s.current&&l.mount(s.current),()=>{l.unmount()}),[l]),o.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:s})}var Os=process.env.NODE_ENV!=="development"?function(){return null}:No;process.env.NODE_ENV;const Wn=H.atom(""),Do=()=>{P.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),P.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"}),P.registerChaiFeatureFlag("enable-ai-chat-panel",{description:"Enable AI chat panel"})},Go=()=>{const e=j(),t=N();return S.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},ko=()=>{const{data:e}=te(),{data:t}=he(),{data:s}=Te(),n=j(),r=N(),a=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]),i=h.useRef(new Map);return S.useMutation({mutationFn:async({block:l})=>{const c=l._id,d=(t==null?void 0:t.lang)||a,u=`${c}:${d}`;if(i.current.has(u))return i.current.get(u);const f=r(n,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:l,lang:d,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 i.current.set(u,f),f.finally(()=>{i.current.delete(u)}),f}})},Yn=()=>{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])},Jn=()=>{const e=Yn();return h.useCallback(({pageId:t})=>{e(t)},[e])},Oo={SITE_WIDE_USAGE:"SITE_WIDE_USAGE"},Ro=e=>{const t=N(),s=j();return S.useQuery({queryKey:[Oo.SITE_WIDE_USAGE],queryFn:async()=>e?t(s,{action:"GET_SITE_WIDE_USAGE"}):{},retry:!1})},Mo=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-Uz94JnNt.cjs"))),Uo=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-dialog-CUBp8DfX.cjs"))),Bo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-CeuTVT2m.cjs"))),Fo=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-D1wVNYQs.cjs"))),qo=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-NFR6yf6k.cjs"))),Ko=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-mGavSw4r.cjs")));Do();ar.loadWebBlocks();P.registerChaiTopBar(ma);Fa();P.registerChaiMediaManager(Bo);P.registerChaiSaveToLibrary(Fo);const Vo={role:"",permissions:null},Rs=e=>{var Ss;const{data:t}=va(),s=Ut(),{data:n=Vo,isFetching:r}=sn(),{data:a,isFetching:i}=ge(),{data:l,isFetching:c}=Go(),{data:d,isFetching:u}=Te(),f=r||i||c||u,[E]=le(),m=E.get("page"),{data:A}=te(),{data:w,isFetching:v}=Aa(),{blocks:M}=ya(w),{data:T,isFetching:C}=en(),{pageStatus:L}=re(),q=Ea(),{onSave:D}=ba(),{mutateAsync:ce}=ko(),{getPartialBlocks:ue,getPartialBlockBlocks:K}=Ia(),{mutateAsync:I}=Mr(),{mutateAsync:G}=tn(),{data:W}=Ro(((Ss=e.flags)==null?void 0:Ss.designTokens)??!1),Q=Jn(),[ae,yt]=h.useState(!1),de=h.useRef([]),ve=h.useMemo(()=>p.get(d,"theme",{})||{},[d]),Se=L===J.EDITING,er=L===J.CHECKING,As=v||er||C;de.current=M;const[tr]=H.useAtom(Wn);h.useEffect(()=>{const ee=()=>{document.hidden?yt(!0):yt(!1)};return window.addEventListener("visibilitychange",ee),()=>window.removeEventListener("visibilitychange",ee)},[]);const sr=h.useMemo(()=>{const ee={};return n&&(ee.permissions=p.get(n,"permissions",null),ee.role=p.get(n,"role","user")),ee},[n]),Ts=h.useMemo(()=>t==null?void 0:t.some(ee=>ee.isSiteLibrary),[t]),nr=h.useCallback(async(ee,At)=>await I({pageType:ee,query:At}),[I]);return o.jsxs(o.Fragment,{children:[As&&o.jsx(hs,{className:f?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(x.Loader,{className:`animate-spin text-primary ${f?"h-6 w-6":"h-5 w-5"}`})}),tr&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:o.jsx(x.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(Ko,{})}),o.jsx(P.ChaiBuilderEditor,{siteWideUsage:W??{},flags:e.flags?{...e.flags,librarySite:Ts}:{librarySite:Ts},gotoPage:Q,collections:l??[],getBlockAsyncProps:ce,pageExternalData:T,themePresets:e.themePresets??[],pageId:A==null?void 0:A.id,loading:v,fallbackLang:s,languages:(d==null?void 0:d.languages)||[],brandingOptions:(d==null?void 0:d.theme)||{},designTokens:(d==null?void 0:d.designTokens)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!ae&&Se&&(e.autoSave??!0),autoSaveActionsCount:e.autoSaveActionsCount??10,onError:e.onError||console.error,getPartialBlockBlocks:K,getPartialBlocks:ue,blocks:v?[]:M,theme:p.cloneDeep(ve),pageTypes:a,searchPageTypeItems:nr,askAiCallBack:q,onSave:async({blocks:ee,theme:At,needTranslations:rr,designTokens:Ps})=>{if(!m)return!0;de.current=ee;const _s=[...ee];await D({page:m,blocks:_s,needTranslations:rr}),de.current=_s;const Tt={};return p.isEqual(At,ve)||(Tt.theme=At),p.isEqual(Ps,d==null?void 0:d.designTokens)||(Tt.designTokens=Ps),p.isEmpty(Tt)||await G({settings:Tt}),!0},themePanelComponent:qo,...sr,children:o.jsx(Mo,{isFetchingPageData:As})}),o.jsx("div",{children:o.jsx(Uo,{})})]})},Ho=new S.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),Qo=e=>{const[,t]=Ot(),[s,n]=h.useState(!1);return h.useEffect(()=>(t(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","websocket","getLoggedInUser","features","currentUser"])),setTimeout(()=>{n(!0)},200),()=>{n(!1),t({})}),[e,t]),s?p.get(e,"hasReactQueryProvider",!1)===!0?o.jsxs(o.Fragment,{children:[o.jsx(Rs,{...e}),o.jsx(Os,{})]}):o.jsxs(S.QueryClientProvider,{client:Ho,children:[o.jsx(Rs,{...e}),o.jsx(Os,{})]}):o.jsx("div",{})},zo=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-D_iF9Sm3.cjs")));function Zn({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=z.useState(!1);return o.jsxs(g.Popover,{open:r,onOpenChange:a,children:[o.jsxs(g.Tooltip,{children:[o.jsx(g.TooltipTrigger,{asChild:!0,children:o.jsx(g.PopoverTrigger,{asChild:!0,children:o.jsx(g.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,disabled:n,children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:o.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),o.jsx(g.TooltipContent,{children:"Add field"})]}),r&&o.jsx(z.Suspense,{children:o.jsx(zo,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const $o=()=>{const{savePageAsync:e}=P.useSavePage(),t=S.useQueryClient(),{isLocked:s}=re();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])},Wo=()=>{const e=S.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},Yo=()=>{const e=j(),t=N(),{data:s}=he(),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")}})},Jo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-CeuTVT2m.cjs"))),Zo=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:i}=P.useTranslation(),[l,c]=h.useState(!1),d=()=>{a||c(!0)},u=()=>{c(!1)},f=A=>{const w=Array.isArray(A)?A[0]:A;w!=null&&w.url&&s(p.pick(w,["url","id"])),c(!1)},E=()=>{s({url:"",id:""})},m=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return o.jsxs("div",{className:`w-full ${n}`,children:[t?o.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[m?o.jsx("div",{className:"flex h-12 items-center bg-gray-100 px-4",children:o.jsx("p",{className:"text-xs text-gray-500",children:t})}):o.jsx("img",{onClick:d,src:t,alt:i("Selected image"),className:"h-auto max-h-[100px] w-full bg-gray-100 object-contain"}),o.jsxs("div",{className:"absolute right-2 top-2 flex gap-2",children:[o.jsx(g.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:E,disabled:a,children:m?o.jsx(x.X,{className:"h-4 w-4"}):o.jsx(x.Trash2,{className:"h-4 w-4"})}),!m&&o.jsx(g.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:d,disabled:a,children:o.jsx(x.ImageIcon,{className:"h-4 w-4"})})]})]}):o.jsx("div",{className:`flex cursor-pointer items-center justify-center rounded-md border border-dashed p-6 ${a?"cursor-not-allowed opacity-50":"hover:border-gray-400"}`,onClick:d,children:o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx(x.ImageIcon,{className:"h-10 w-10 text-gray-400"}),o.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),o.jsx(g.Dialog,{open:l,onOpenChange:c,children:o.jsxs(g.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[o.jsxs(g.DialogHeader,{className:"hidden border-b px-4 py-2",children:[o.jsx(g.DialogTitle,{children:i("Select Image")}),o.jsx(g.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:u,children:o.jsx(x.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(h.Suspense,{children:o.jsx(Jo,{close:u,onSelect:f,mode:"image",assetId:e})})})]})})]})},Xo=h.createContext(null),Wt={didCatch:!1,error:null};class Xn extends h.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Wt}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var s,n,r=arguments.length,a=new Array(r),i=0;i<r;i++)a[i]=arguments[i];(s=(n=this.props).onReset)===null||s===void 0||s.call(n,{args:a,reason:"imperative-api"}),this.setState(Wt)}}componentDidCatch(t,s){var n,r;(n=(r=this.props).onError)===null||n===void 0||n.call(r,t,s)}componentDidUpdate(t,s){const{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&s.error!==null&&el(t.resetKeys,r)){var a,i;(a=(i=this.props).onReset)===null||a===void 0||a.call(i,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(Wt)}}render(){const{children:t,fallbackRender:s,FallbackComponent:n,fallback:r}=this.props,{didCatch:a,error:i}=this.state;let l=t;if(a){const c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof s=="function")l=s(c);else if(n)l=h.createElement(n,c);else if(r!==void 0)l=r;else throw i}return h.createElement(Xo.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},l)}}function el(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((s,n)=>!Object.is(s,t[n]))}const tl=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),rs=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};try{return{isValid:!0,parsed:JSON.parse(e),error:null,placeholders:[]}}catch{}const t=/{{([^{}]+)}}/g,s=[];let n=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],i=r.index,l=`"__placeholder_${s.length}__"`;s.push({original:a,replaced:l,position:i}),n=n.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(n),error:null,placeholders:s}}catch(a){const i=a,l=i.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let d,u;if(c!==void 0){const f=n.substring(0,c).split(`
2
- `);d=f.length,u=f[f.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:d,column:u,position:c}}}},sl=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(tl(i),"g");n=n.replace(l,r)}),n},nl=(e,t)=>{if(!e)return"";let s=JSON.stringify(e,null,2);const n=/{{([^{}]+)}}/g;let r;for(;(r=n.exec(s))!==null;){const a=r[1],i=p.get(t,a,null);s=s.replace(r[0],i)}return s},rl=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-jbhoi-Qv.cjs"))),al=({value:e,onChange:t,disabled:s=!1,readOnly:n=!1,placeholder:r="Enter JSON",rows:a=6,id:i="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:d,copyJsonLDFromDefaultPage:u})=>{const[f,E]=h.useState("edit"),[m,A]=h.useState(null),[w,v]=h.useState(""),M=h.useRef(null),[T]=Ot(),C=i==="jsonLD"&&p.get(T,"features.sharedJsonLD",!1),L=i==="jsonLD"&&!d&&!!u;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const q=K=>{if(n)return;const I=K.target.value;t(I)},D=K=>{if(K.key==="Tab"){K.preventDefault();const I=K.currentTarget,G=I.selectionStart,W=I.selectionEnd;if(G!==W){const ae=e.substring(G,W).split(`
3
- `);if(K.shiftKey){const de=ae.map(Se=>Se.startsWith(" ")?Se.substring(2):Se).join(`
4
- `),ve=e.substring(0,G)+de+e.substring(W);t(ve),setTimeout(()=>{I.selectionStart=G,I.selectionEnd=G+de.length},0)}else{const de=ae.map(Se=>` ${Se}`).join(`
5
- `),ve=e.substring(0,G)+de+e.substring(W);t(ve),setTimeout(()=>{I.selectionStart=G,I.selectionEnd=G+de.length},0)}}else{const Q=e.substring(0,G)+" "+e.substring(W);t(Q),setTimeout(()=>{I.selectionStart=I.selectionEnd=G+2},0)}}};h.useEffect(()=>{const K=rs(e);if(K.isValid)if(A(null),K.parsed){const I=nl(K.parsed,l);v(I)}else v("");else A(K.error),v("")},[e,l]);const ce=()=>{const K=rs(e);if(K.isValid&&K.parsed){const I=sl(K.parsed,K.placeholders);t(I)}},ue=()=>{m!=null&&m.position&&M.current&&(M.current.focus(),M.current.setSelectionRange(m.position,m.position+1))};return o.jsx(Xn,{fallback:o.jsx("div",{children:"Some error"}),children:o.jsx("div",{className:"space-y-2",children:o.jsxs(g.Tabs,{value:f,onValueChange:E,className:"w-full",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs(g.TabsList,{className:"w-max",children:[o.jsxs(g.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[o.jsx(x.Code,{className:"h-4 w-4"}),o.jsx("span",{children:"Edit"})]}),o.jsxs(g.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||m!==null||L,children:[o.jsx(x.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),C&&o.jsxs(g.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||m!==null,children:[o.jsx(x.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),L?null:f==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(Zn,{dataType:"value",data:l??{},onSelect:K=>c&&c(K,i)})})]}),o.jsxs(g.TabsContent,{value:"edit",className:"relative mt-0",children:[!L&&f==="edit"&&o.jsx(Bt,{content:"Format JSON",side:"right",showTooltip:!s&&!m,children:o.jsx(g.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||m!==null,children:o.jsx(x.FileCode2,{})})}),L?o.jsx("div",{className:"flex h-40 items-center justify-center rounded-md bg-black/20",children:o.jsxs("div",{className:"flex max-w-[400px] flex-col items-center gap-2 rounded-md bg-white p-4 shadow-lg",children:[o.jsx("div",{className:"max-w-xl text-center text-xs text-gray-500",children:"JSON-LD for is not added for selected language. JSON LD will be used from default language."}),o.jsxs(g.Button,{type:"button",variant:"default",size:"sm",onClick:u,children:[o.jsx(x.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(g.Textarea,{ref:M,id:i,name:i,className:`rounded-md border border-input text-xs ${m?"border-red-500":""}`,onChange:q,onKeyDown:D,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),m&&o.jsxs(g.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(x.AlertTriangle,{className:"h-4 w-4"}),o.jsxs(g.AlertDescription,{className:"flex flex-col",children:[o.jsx("span",{className:"font-medium",children:"Invalid JSON"}),o.jsx("span",{className:"text-sm",children:m.message}),m.line&&m.column&&o.jsxs("span",{className:"text-sm",children:["Error at line ",m.line,", column ",m.column]}),o.jsx(g.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:ue,children:"Show position"})]})]})]}),o.jsxs(g.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(g.Textarea,{rows:a,value:w,readOnly:!0,className:"cursor-default bg-muted font-mono text-sm"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This is how the JSON will look after placeholder substitution."})]}),C&&o.jsx(g.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(rl,{})})})]})})})},il=e=>{const t=Fs(),s=N();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=gs;exports.ACTIONS=y;exports.BlurContainer=hs;exports.ChaiBuilderPages=Qo;exports.Dynamic=Mi;exports.EVENT=X;exports.ErrorBoundary=Xn;exports.For=ci;exports.ImagePicker=Zo;exports.Index=ui;exports.LANGUAGES=ze;exports.LanguageSwitcher=Ws;exports.Match=hi;exports.NestedPathSelector=Zn;exports.PAGES_PERMISSIONS=se;exports.PAGE_STATUS=J;exports.PageActionsDropdown=Zs;exports.PermissionChecker=xt;exports.Portal=Oi;exports.Show=di;exports.SmartJsonInput=al;exports.Switch=fi;exports.Tooltip=Bt;exports.addEventListener=vn;exports.addNewLangAtom=Rt;exports.batch=Qa;exports.className=wn;exports.clearDelegatedEvents=vi;exports.convertRemToPixels=bo;exports.createComponent=ps;exports.createComputed=fn;exports.createContext=Ja;exports.createEffect=ms;exports.createMemo=$;exports.createRenderEffect=pe;exports.createRoot=Ee;exports.createSignal=V;exports.createUniqueId=li;exports.delegateEvents=xn;exports.deleteNestedDataByPath=Ye;exports.displayValue=So;exports.getMutationStatusColor=Ao;exports.getPreferredColorScheme=Io;exports.getQueryStatusColor=yo;exports.getQueryStatusColorByLabel=To;exports.getQueryStatusLabel=Eo;exports.getSidedProp=po;exports.insert=kt;exports.memo=_i;exports.mergeProps=ys;exports.mutationSortFns=vo;exports.navigateToPage=os;exports.on=za;exports.onCleanup=Ve;exports.onMount=hn;exports.parseJSONWithPlaceholders=rs;exports.previewUrlAtom=Wn;exports.serialize=Hn;exports.setAttribute=Gt;exports.sortFns=xo;exports.splitProps=Tn;exports.spread=bn;exports.stringify=mo;exports.template=wi;exports.throwConfetti=wt;exports.untrack=Y;exports.updateNestedDataByPath=We;exports.use=In;exports.useActivePage=he;exports.useAddGlobalSchema=Ta;exports.useApiUrl=j;exports.useApplySchemaToAllPages=xa;exports.useAssetsApiUrl=lr;exports.useBuilderFetch=ur;exports.useBuilderPageData=en;exports.useChaiAuth=Mt;exports.useChaiUserInfo=il;exports.useChaibuilderRealtime=Ir;exports.useChangePage=Yn;exports.useChangeSlug=Hr;exports.useClearAll=Wo;exports.useContext=Za;exports.useCreatePage=Ur;exports.useCurrentPage=te;exports.useCurrentPageOwner=Qs;exports.useDeleteGlobalSchema=Pa;exports.useDeletePage=Fr;exports.useDynamicPageSelector=Vs;exports.useFallbackLang=Ut;exports.useFetch=N;exports.useGotoPage=Jn;exports.useIsLanguagePageCreated=Js;exports.useLanguagePages=Ae;exports.useMarkAsTemplate=Kr;exports.usePageEditInfo=is;exports.usePageLockMeta=cs;exports.usePageLockStatus=re;exports.usePageToUser=ls;exports.usePageType=Ys;exports.usePageTypes=ge;exports.usePagesProps=Ot;exports.usePublishPages=fs;exports.useReloadPage=$o;exports.useRemoveSchemaFromAllPages=wa;exports.useSearchParams=le;exports.useSendRealtimeEvent=zs;exports.useTogglePageGlobalSchema=_a;exports.useTransition=Ya;exports.useUnmarkAsTemplate=Vr;exports.useUnpublishPage=qr;exports.useUpdateActivePageMetadata=Yo;exports.useUpdateGlobalSchema=Sa;exports.useUpdatePage=Br;exports.useUpdateWebsiteSettings=tn;exports.useUserId=Et;exports.useUserRoleAndPermissions=sn;exports.useWebsiteLanguagePages=Cr;exports.useWebsitePages=ds;exports.useWebsiteSetting=Te;