@chaibuilder/pages 0.15.5 → 0.15.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/{2AITGKQY-D4uLyw6-.cjs → 2AITGKQY-BnzAO102.cjs} +1 -1
  2. package/dist/{2AITGKQY-DYwNjBFe.js → 2AITGKQY-tXLat8E2.js} +2 -2
  3. package/dist/{NCMVHL6D-DVB60g_2.js → NCMVHL6D-BwDANa-N.js} +2 -2
  4. package/dist/{NCMVHL6D-C-L7-X3f.cjs → NCMVHL6D-DooF4Fqf.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-Dp6ML_tn.js → ZDWCUMSJ-DWeYRRkj.js} +1 -1
  6. package/dist/{ZDWCUMSJ-BORULBXb.cjs → ZDWCUMSJ-DiH9kc7o.cjs} +1 -1
  7. package/dist/add-new-language-page-BCUrfgTy.cjs +1 -0
  8. package/dist/add-new-language-page-DZhjVBBf.js +401 -0
  9. package/dist/add-new-page-DWHANcUx.cjs +1 -0
  10. package/dist/add-new-page-DYuuentN.js +31 -0
  11. package/dist/delete-page-1dSWwUBg.js +40 -0
  12. package/dist/delete-page-m-Cuz7rG.cjs +1 -0
  13. package/dist/digital-asset-manager-BWZlrwFf.js +913 -0
  14. package/dist/digital-asset-manager-By_JTIbb.cjs +1 -0
  15. package/dist/duplicate-page-Dzs8ya8l.cjs +1 -0
  16. package/dist/duplicate-page-fUuBTAs7.js +133 -0
  17. package/dist/{dynamic-page-selector-Cz6zWaKo.cjs → dynamic-page-selector-CwhL4z6F.cjs} +1 -1
  18. package/dist/{dynamic-page-selector-8g1-84iW.js → dynamic-page-selector-X2qgdiNQ.js} +1 -1
  19. package/dist/image-editor-CeSSNbFY.js +108 -0
  20. package/dist/image-editor-CnDnY97s.cjs +1 -0
  21. package/dist/index-0cMGDekp.cjs +5 -0
  22. package/dist/{index-zaGKeGBW.js → index-Bk8tPO5R.js} +1168 -1219
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +10 -10
  25. package/dist/{json-diff-viewer-c3ft4c4A.cjs → json-diff-viewer-Cfa9BjZ6.cjs} +1 -1
  26. package/dist/{json-diff-viewer-BF0qFBif.js → json-diff-viewer-Cm84g19X.js} +1 -1
  27. package/dist/lang-panel-CaSKOJ8G.js +225 -0
  28. package/dist/lang-panel-CkSfJqr8.cjs +1 -0
  29. package/dist/mark-as-template-Ci82hbOm.cjs +1 -0
  30. package/dist/mark-as-template-CwsW86Zv.js +153 -0
  31. package/dist/no-language-page-content-CPt4aPy9.cjs +1 -0
  32. package/dist/no-language-page-content-DDz81nqg.js +42 -0
  33. package/dist/{page-creator-CsZpQ7Gy.cjs → page-creator-Cd2LrG4u.cjs} +1 -1
  34. package/dist/{page-creator-Crc5BzeB.js → page-creator-Dr566_Yf.js} +2 -2
  35. package/dist/page-lock-request-Bw_Wye1t.cjs +1 -0
  36. package/dist/page-lock-request-ECxkQMdS.js +75 -0
  37. package/dist/page-locked-by-dialog-AbutJT_V.cjs +1 -0
  38. package/dist/page-locked-by-dialog-CnkVUpjt.js +68 -0
  39. package/dist/page-manager-new-DLMvOata.cjs +1 -0
  40. package/dist/page-manager-new-DkqNLZ5C.js +354 -0
  41. package/dist/page-manager-search-and-filter-B98nz9xS.js +201 -0
  42. package/dist/page-manager-search-and-filter-CfEfWFeo.cjs +1 -0
  43. package/dist/{page-revisions-content-PRgwV04S.js → page-revisions-content-CBQPYFZI.js} +18 -18
  44. package/dist/{page-revisions-content-dSFvGFEO.cjs → page-revisions-content-D12GEp8C.cjs} +1 -1
  45. package/dist/{publish-pages-content-C24iBibw.js → publish-pages-content-BF5yMo_L.js} +6 -6
  46. package/dist/{publish-pages-content-akIgltlm.cjs → publish-pages-content-LNCr9tKv.cjs} +1 -1
  47. package/dist/{save-to-lib-C3H1ZPb-.cjs → save-to-lib-C1B6tWEF.cjs} +1 -1
  48. package/dist/{save-to-lib-DSPvtFSd.js → save-to-lib-SpilaoOL.js} +1 -1
  49. package/dist/{seo-panel-Ce6aTIyt.cjs → seo-panel-DkgkJUT6.cjs} +1 -1
  50. package/dist/{seo-panel-rZ8s88c0.js → seo-panel-sbYoo746.js} +17 -17
  51. package/dist/{shared-json-ld-hCiviuBf.cjs → shared-json-ld-CEUgLAev.cjs} +1 -1
  52. package/dist/{shared-json-ld-DMYOwp6B.js → shared-json-ld-D_YyVPk3.js} +27 -27
  53. package/dist/{slug-input-BN8eQgxP.cjs → slug-input-Cqj9EBju.cjs} +1 -1
  54. package/dist/{slug-input-Dhzaobv6.js → slug-input-Df-BG6xl.js} +1 -1
  55. package/dist/theme-panel-footer-B6leVWSV.js +25 -0
  56. package/dist/theme-panel-footer-Ca1UF5DA.cjs +1 -0
  57. package/dist/unmark-as-template-BOE-nKOb.cjs +1 -0
  58. package/dist/unmark-as-template-Cho9B4RN.js +39 -0
  59. package/dist/unpublish-page-BcxxZ8pr.cjs +1 -0
  60. package/dist/unpublish-page-Dr4qbwUx.js +27 -0
  61. package/dist/{web-preview-BEyjKFDL.js → web-preview-Cq82TNaS.js} +1 -1
  62. package/dist/{web-preview-TTKtpSUi.cjs → web-preview-ued-fdxs.cjs} +1 -1
  63. package/package.json +3 -3
  64. package/dist/add-new-language-page-D4VPifNs.cjs +0 -1
  65. package/dist/add-new-language-page-DENCjC_f.js +0 -390
  66. package/dist/add-new-page-BuK6We-q.cjs +0 -1
  67. package/dist/add-new-page-CD-9ppdS.js +0 -30
  68. package/dist/delete-page-B-TP6nJ7.cjs +0 -1
  69. package/dist/delete-page-CatRlDfx.js +0 -38
  70. package/dist/digital-asset-manager-DL2nAqUC.cjs +0 -1
  71. package/dist/digital-asset-manager-KakxBkBC.js +0 -917
  72. package/dist/duplicate-page-D4Oiy71Q.cjs +0 -1
  73. package/dist/duplicate-page-DEmh0df0.js +0 -120
  74. package/dist/image-editor-D9MPdtxC.js +0 -107
  75. package/dist/image-editor-Da6lrqkL.cjs +0 -1
  76. package/dist/index-Blg1T7nL.cjs +0 -5
  77. package/dist/lang-panel-D1FKTNui.js +0 -218
  78. package/dist/lang-panel-ExS97Zgk.cjs +0 -1
  79. package/dist/mark-as-template-CcnkROAU.cjs +0 -1
  80. package/dist/mark-as-template-v-I05xcZ.js +0 -146
  81. package/dist/no-language-page-content-Bm5CcsUo.js +0 -35
  82. package/dist/no-language-page-content-Ddz2hnYs.cjs +0 -1
  83. package/dist/page-lock-request-Dx6OrOwM.cjs +0 -1
  84. package/dist/page-lock-request-WKfG7Sd3.js +0 -64
  85. package/dist/page-locked-by-dialog-BvdAXZPw.cjs +0 -1
  86. package/dist/page-locked-by-dialog-jy3lYV3l.js +0 -63
  87. package/dist/page-manager-new-CNHlSwfe.js +0 -354
  88. package/dist/page-manager-new-CUlpwqpH.cjs +0 -1
  89. package/dist/page-manager-search-and-filter-CuAn82Db.js +0 -197
  90. package/dist/page-manager-search-and-filter-eFsGtm5W.cjs +0 -1
  91. package/dist/theme-panel-footer-0GrdOHO_.cjs +0 -1
  92. package/dist/theme-panel-footer-BzEy5bsg.js +0 -25
  93. package/dist/unmark-as-template-DXEs6foh.cjs +0 -1
  94. package/dist/unmark-as-template-Dsiyocm9.js +0 -38
  95. package/dist/unpublish-page-c1mqQEa_.cjs +0 -1
  96. package/dist/unpublish-page-yGyz2jiw.js +0 -26
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index-Blg1T7nL.cjs"),S=require("@tanstack/react-query"),N=require("sonner"),a=require("@chaibuilder/sdk/ui"),v=require("lodash-es"),E=require("lucide-react"),g=require("react"),q=require("./slug-input-BN8eQgxP.cjs"),C=()=>{const t=p.useApiUrl(),r=S.useQueryClient(),h=p.useFetch();return S.useMutation({mutationFn:async({pageId:c,name:u,slug:o})=>{const s={pageId:c,name:u};return o&&(s.slug=o),await h(t,{action:"DUPLICATE_PAGE",data:s})},onSuccess:()=>{r.invalidateQueries({queryKey:[p.ACTIONS.GET_WEBSITE_PAGES]}),N.toast.success("Page duplicated successfully")},onError:c=>{N.toast.error("Failed to duplicate page",{description:c.message||"An error occurred while duplicating the page"})}})},A=({page:t,onClose:r,closePanel:h=()=>{}})=>{const{mutate:c,isPending:u}=C(),[o,s]=g.useState(null),[d,P]=g.useState(`${t.name} (Copy)`),D=p.useChangePage(),i=v.isEmpty(t.slug),[m,b]=g.useState(i?"":`${t.slug.split("/").pop()}-copy`),j=i?"":v.initial(t.slug.split("/")).join("/"),[f,x]=g.useState(!1),I=n=>{if(n.preventDefault(),!d.trim()){s("Name is required");return}if(!i&&!m.trim()){s("Slug is required");return}s(null),x(!0);const y={pageId:t.id,name:d};i||(y.slug=`${j}/${m}`),c(y,{onSuccess:l=>{x(!1),r(),D(l.id,h)},onError:l=>{x(!1),l.code==="SLUG_EXISTS"?s("A page with this slug already exists. Please choose a different slug."):l.code==="INVALID_SLUG"?s("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens."):l.code==="PERMISSION_DENIED"?s("You don't have permission to duplicate this page."):s(l.message||"Failed to duplicate page. Please try again later.")}})};return e.jsx(a.Dialog,{open:!!t,onOpenChange:r,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Duplicate Page"}),e.jsx(a.DialogDescription,{children:"Create a copy of the page with a new name and slug"})]}),e.jsxs("div",{className:"mb-4 rounded-md bg-gray-50 p-3",children:[e.jsx("h3",{className:"mb-1 text-sm font-medium",children:"Duplicating:"}),e.jsxs("div",{className:"flex flex-col gap-1 text-sm text-gray-700",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",t.name]}),!i&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Slug:"})," ",t.slug]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Type:"})," ",t.pageType]})]})]}),e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(a.Input,{id:"name",value:d,onChange:n=>P(n.target.value),required:!0})]}),!i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(q.SlugInput,{value:m,onChange:n=>b(n),parentSlug:j,onValidationChange:n=>{s(n?null:"Invalid slug")}})]}),o&&e.jsxs(a.Alert,{variant:"destructive",className:"py-2",children:[e.jsx(E.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(a.Button,{type:"button",variant:"outline",onClick:r,disabled:u,children:"Cancel"}),e.jsx(a.Button,{type:"submit",disabled:!d.trim()||!i&&!m.trim()||u||f,children:u||f?"Duplicating...":"Duplicate"})]})]})]})})};exports.default=A;
@@ -1,120 +0,0 @@
1
- import { jsx as e, jsxs as s } from "react/jsx-runtime";
2
- import { al as b, am as C, A, an as T } from "./index-zaGKeGBW.js";
3
- import { useQueryClient as w, useMutation as F } from "@tanstack/react-query";
4
- import { toast as S } from "sonner";
5
- import { Dialog as _, DialogContent as q, DialogHeader as G, DialogTitle as L, DialogDescription as U, Label as v, Input as j, Alert as $, Button as D } from "@chaibuilder/sdk/ui";
6
- import { isEmpty as O, initial as B } from "lodash-es";
7
- import { AlertCircle as M } from "lucide-react";
8
- import { useState as p } from "react";
9
- import { S as Q } from "./slug-input-Dhzaobv6.js";
10
- const V = () => {
11
- const t = b(), r = w(), g = C();
12
- return F({
13
- mutationFn: async ({ pageId: c, name: o, slug: u }) => {
14
- const a = {
15
- pageId: c,
16
- name: o
17
- };
18
- return u && (a.slug = u), await g(t, {
19
- action: "DUPLICATE_PAGE",
20
- data: a
21
- });
22
- },
23
- onSuccess: () => {
24
- r.invalidateQueries({
25
- queryKey: [A.GET_WEBSITE_PAGES]
26
- }), S.success("Page duplicated successfully");
27
- },
28
- onError: (c) => {
29
- S.error("Failed to duplicate page", {
30
- description: c.message || "An error occurred while duplicating the page"
31
- });
32
- }
33
- });
34
- }, Z = ({
35
- page: t,
36
- onClose: r,
37
- closePanel: g = () => {
38
- }
39
- }) => {
40
- const { mutate: c, isPending: o } = V(), [u, a] = p(null), [m, P] = p(`${t.name} (Copy)`), x = T(), i = O(t.slug), [d, I] = p(i ? "" : `${t.slug.split("/").pop()}-copy`), f = i ? "" : B(t.slug.split("/")).join("/"), [y, h] = p(!1), E = (l) => {
41
- if (l.preventDefault(), !m.trim()) {
42
- a("Name is required");
43
- return;
44
- }
45
- if (!i && !d.trim()) {
46
- a("Slug is required");
47
- return;
48
- }
49
- a(null), h(!0);
50
- const N = {
51
- pageId: t.id,
52
- name: m
53
- };
54
- i || (N.slug = `${f}/${d}`), c(N, {
55
- onSuccess: (n) => {
56
- h(!1), r(), x(n.id, g);
57
- },
58
- onError: (n) => {
59
- h(!1), n.code === "SLUG_EXISTS" ? a("A page with this slug already exists. Please choose a different slug.") : n.code === "INVALID_SLUG" ? a("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens.") : n.code === "PERMISSION_DENIED" ? a("You don't have permission to duplicate this page.") : a(n.message || "Failed to duplicate page. Please try again later.");
60
- }
61
- });
62
- };
63
- return /* @__PURE__ */ e(_, { open: !!t, onOpenChange: r, children: /* @__PURE__ */ s(q, { className: "sm:max-w-[425px]", children: [
64
- /* @__PURE__ */ s(G, { children: [
65
- /* @__PURE__ */ e(L, { children: "Duplicate Page" }),
66
- /* @__PURE__ */ e(U, { children: "Create a copy of the page with a new name and slug" })
67
- ] }),
68
- /* @__PURE__ */ s("div", { className: "mb-4 rounded-md bg-gray-50 p-3", children: [
69
- /* @__PURE__ */ e("h3", { className: "mb-1 text-sm font-medium", children: "Duplicating:" }),
70
- /* @__PURE__ */ s("div", { className: "flex flex-col gap-1 text-sm text-gray-700", children: [
71
- /* @__PURE__ */ s("div", { children: [
72
- /* @__PURE__ */ e("span", { className: "font-medium", children: "Name:" }),
73
- " ",
74
- t.name
75
- ] }),
76
- !i && /* @__PURE__ */ s("div", { children: [
77
- /* @__PURE__ */ e("span", { className: "font-medium", children: "Slug:" }),
78
- " ",
79
- t.slug
80
- ] }),
81
- /* @__PURE__ */ s("div", { children: [
82
- /* @__PURE__ */ e("span", { className: "font-medium", children: "Type:" }),
83
- " ",
84
- t.pageType
85
- ] })
86
- ] })
87
- ] }),
88
- /* @__PURE__ */ s("form", { onSubmit: E, className: "space-y-4", children: [
89
- /* @__PURE__ */ s("div", { className: "space-y-2", children: [
90
- /* @__PURE__ */ e(v, { htmlFor: "name", className: "text-sm", children: "Name" }),
91
- /* @__PURE__ */ e(j, { id: "name", value: m, onChange: (l) => P(l.target.value), required: !0 })
92
- ] }),
93
- !i && /* @__PURE__ */ s("div", { className: "space-y-2", children: [
94
- /* @__PURE__ */ e(v, { htmlFor: "slug", className: "text-sm", children: "Slug" }),
95
- /* @__PURE__ */ e(
96
- Q,
97
- {
98
- value: d,
99
- onChange: (l) => I(l),
100
- parentSlug: f,
101
- onValidationChange: (l) => {
102
- a(l ? null : "Invalid slug");
103
- }
104
- }
105
- )
106
- ] }),
107
- u && /* @__PURE__ */ s($, { variant: "destructive", className: "py-2", children: [
108
- /* @__PURE__ */ e(M, { className: "h-4 w-4" }),
109
- /* @__PURE__ */ e("span", { className: "text-sm", children: u })
110
- ] }),
111
- /* @__PURE__ */ s("div", { className: "flex justify-end gap-2", children: [
112
- /* @__PURE__ */ e(D, { type: "button", variant: "outline", onClick: r, disabled: o, children: "Cancel" }),
113
- /* @__PURE__ */ e(D, { type: "submit", disabled: !m.trim() || !i && !d.trim() || o || y, children: o || y ? "Duplicating..." : "Duplicate" })
114
- ] })
115
- ] })
116
- ] }) });
117
- };
118
- export {
119
- Z as default
120
- };
@@ -1,107 +0,0 @@
1
- import { jsx as n, jsxs as E } from "react/jsx-runtime";
2
- import { Dialog as T, DialogContent as L } from "@chaibuilder/sdk/ui";
3
- import { debounce as R } from "lodash-es";
4
- import { Save as S, Copy as j, Loader as O } from "lucide-react";
5
- import { memo as P, useState as l, useEffect as h, useMemo as i, useCallback as x } from "react";
6
- import A from "react-filerobot-image-editor";
7
- const D = P(
8
- ({ imageUrl: r, onSave: c, onClose: m, defaultSavedImageName: b, isEditing: u = !1 }) => {
9
- const [y, o] = l(!1), [f, p] = l(!0), [v, w] = l(!1);
10
- h(() => {
11
- const e = new Image();
12
- return e.src = r, e.onload = () => w(!0), () => {
13
- e.onload = null;
14
- };
15
- }, [r]), h(() => {
16
- const e = (t) => {
17
- t.key === "Escape" && f && (t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation());
18
- };
19
- return document.addEventListener("keydown", e, !0), () => {
20
- document.removeEventListener("keydown", e, !0);
21
- };
22
- }, []);
23
- const I = i(
24
- () => R(async (e, t = !1) => {
25
- o(!0);
26
- const a = e.imageBase64;
27
- await c(a, t), p(!1), o(!1);
28
- }, 300),
29
- [c]
30
- ), s = x(
31
- (e, t = !1) => {
32
- I(e, t);
33
- },
34
- [I]
35
- ), g = x(() => {
36
- p(!1), m();
37
- }, [m]), d = i(
38
- () => ({
39
- tabsIds: ["Adjust", "Annotate", "Watermark", "Finetune", "Resize", "Filters"],
40
- toolsIds: ["Rotate"],
41
- defaultTabId: "Adjust",
42
- defaultToolId: "Rotate"
43
- }),
44
- []
45
- ), C = i(
46
- () => ({
47
- colors: {
48
- primary: "#000000",
49
- secondary: "#000000",
50
- tertiary: "#000000"
51
- }
52
- }),
53
- []
54
- ), k = i(
55
- () => u ? [
56
- {
57
- label: "Update this file",
58
- onClick: (e, t) => t((...a) => {
59
- o(!0), s(a[0], !1);
60
- }),
61
- icon: S
62
- },
63
- {
64
- label: "Save as new file",
65
- onClick: (e, t) => t((...a) => {
66
- o(!0), s(a[0], !0);
67
- }),
68
- icon: j
69
- }
70
- ] : [],
71
- [u, s]
72
- );
73
- return /* @__PURE__ */ n(T, { open: !0, onOpenChange: (e) => !e && g(), children: /* @__PURE__ */ E(
74
- L,
75
- {
76
- id: "chai-image-editor-container",
77
- className: "flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4 p-0",
78
- children: [
79
- y && /* @__PURE__ */ n("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 text-white", children: /* @__PURE__ */ n(O, { className: "h-4 w-4 animate-spin" }) }),
80
- f && v && /* @__PURE__ */ n(
81
- A,
82
- {
83
- theme: C,
84
- source: r,
85
- onSave: s,
86
- onClose: g,
87
- Text: { text: "Add text here" },
88
- Rotate: { angle: 90, componentType: "slider" },
89
- tabsIds: d.tabsIds,
90
- defaultTabId: d.defaultTabId,
91
- defaultToolId: d.defaultToolId,
92
- savingPixelRatio: 20,
93
- previewPixelRatio: 6,
94
- defaultSavedImageName: b,
95
- moreSaveOptions: k,
96
- useZoomPresetsMenu: !0
97
- }
98
- )
99
- ]
100
- }
101
- ) });
102
- }
103
- );
104
- D.displayName = "ImageEditor";
105
- export {
106
- D as default
107
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),x=require("@chaibuilder/sdk/ui"),E=require("lodash-es"),d=require("lucide-react"),a=require("react"),S=require("react-filerobot-image-editor"),b=a.memo(({imageUrl:r,onSave:c,onClose:u,defaultSavedImageName:h,isEditing:m=!1})=>{const[y,n]=a.useState(!1),[f,p]=a.useState(!0),[v,w]=a.useState(!1);a.useEffect(()=>{const e=new Image;return e.src=r,e.onload=()=>w(!0),()=>{e.onload=null}},[r]),a.useEffect(()=>{const e=t=>{t.key==="Escape"&&f&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[]);const g=a.useMemo(()=>E.debounce(async(e,t=!1)=>{n(!0);const s=e.imageBase64;await c(s,t),p(!1),n(!1)},300),[c]),i=a.useCallback((e,t=!1)=>{g(e,t)},[g]),I=a.useCallback(()=>{p(!1),u()},[u]),l=a.useMemo(()=>({tabsIds:["Adjust","Annotate","Watermark","Finetune","Resize","Filters"],toolsIds:["Rotate"],defaultTabId:"Adjust",defaultToolId:"Rotate"}),[]),j=a.useMemo(()=>({colors:{primary:"#000000",secondary:"#000000",tertiary:"#000000"}}),[]),C=a.useMemo(()=>m?[{label:"Update this file",onClick:(e,t)=>t((...s)=>{n(!0),i(s[0],!1)}),icon:d.Save},{label:"Save as new file",onClick:(e,t)=>t((...s)=>{n(!0),i(s[0],!0)}),icon:d.Copy}]:[],[m,i]);return o.jsx(x.Dialog,{open:!0,onOpenChange:e=>!e&&I(),children:o.jsxs(x.DialogContent,{id:"chai-image-editor-container",className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4 p-0",children:[y&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 text-white",children:o.jsx(d.Loader,{className:"h-4 w-4 animate-spin"})}),f&&v&&o.jsx(S,{theme:j,source:r,onSave:i,onClose:I,Text:{text:"Add text here"},Rotate:{angle:90,componentType:"slider"},tabsIds:l.tabsIds,defaultTabId:l.defaultTabId,defaultToolId:l.defaultToolId,savingPixelRatio:20,previewPixelRatio:6,defaultSavedImageName:h,moreSaveOptions:C,useZoomPresetsMenu:!0})]})})});b.displayName="ImageEditor";exports.default=b;
@@ -1,5 +0,0 @@
1
- "use strict";var zn=Object.defineProperty;var Es=e=>{throw TypeError(e)};var Wn=(e,t,s)=>t in e?zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var ge=(e,t,s)=>Wn(e,typeof t!="symbol"?t+"":t,s),ps=(e,t,s)=>t.has(e)||Es("Cannot "+s);var v=(e,t,s)=>(ps(e,t,"read from private field"),s?s.call(e):t.get(e)),R=(e,t,s)=>t.has(e)?Es("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),k=(e,t,s,n)=>(ps(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"),T=require("@tanstack/react-query"),C=require("@chaibuilder/sdk"),F=require("sonner"),m=require("@chaibuilder/sdk/ui"),w=require("lucide-react"),Ds=require("@chaibuilder/runtime"),$n=require("@chaibuilder/sdk/web-blocks");function Yn(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=Yn(h),y={GET_GLOBAL_JSONLD_ITEMS:"GET_GLOBAL_JSONLD_ITEMS",GENERATE_SEO_FIELD:"GENERATE_SEO_FIELD",UPDATE_PAGE_METADATA:"UPDATE_PAGE_METADATA",GET_BLOCK_ASYNC_PROPS:"GET_BLOCK_ASYNC_PROPS",ASK_AI:"ASK_AI",GET_DRAFT_PAGE:"GET_DRAFT_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",DUPLICATE_PAGE:"DUPLICATE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_SETTINGS:"UPDATE_WEBSITE_SETTINGS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_DRAFT_SETTINGS:"GET_WEBSITE_DRAFT_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA",GET_PAGE_REVISIONS:"GET_PAGE_REVISIONS",DELETE_PAGE_REVISION:"DELETE_PAGE_REVISION",RESTORE_PAGE_REVISION:"RESTORE_PAGE_REVISION",GET_REVISION_DATA:"GET_REVISION_DATA",GET_PAGE_DATA:"GET_PAGE_DATA",GET_COMPARE_DATA:"GET_COMPARE_DATA",GET_ROLE_AND_PERMISSIONS:"GET_ROLE_AND_PERMISSIONS",UPSERT_LIBRARY_ITEM:"UPSERT_LIBRARY_ITEM",GET_LIBRARIES:"GET_LIBRARIES",GET_LIBRARY_ITEM:"GET_LIBRARY_ITEM",GET_LIBRARY_ITEMS:"GET_LIBRARY_ITEMS",DELETE_LIBRARY_ITEM:"DELETE_LIBRARY_ITEM",MARK_AS_TEMPLATE:"MARK_AS_TEMPLATE",UNMARK_AS_TEMPLATE:"UNMARK_AS_TEMPLATE",GET_TEMPLATES_BY_TYPE:"GET_TEMPLATES_BY_TYPE",GET_DYNAMIC_PAGES:"GET_DYNAMIC_PAGES",GET_APP_SHARED_JSONLD:"GET_APP_SHARED_JSONLD",UPDATE_APP_SHARED_JSONLD:"UPDATE_APP_SHARED_JSONLD",ADD_GLOBAL_SCHEMA:"ADD_GLOBAL_SCHEMA",UPDATE_GLOBAL_SCHEMA:"UPDATE_GLOBAL_SCHEMA",DELETE_GLOBAL_SCHEMA:"DELETE_GLOBAL_SCHEMA",TOGGLE_PAGE_GLOBAL_SCHEMA:"TOGGLE_PAGE_GLOBAL_SCHEMA",APPLY_SCHEMA_TO_ALL_PAGES:"APPLY_SCHEMA_TO_ALL_PAGES",REMOVE_SCHEMA_FROM_ALL_PAGES:"REMOVE_SCHEMA_FROM_ALL_PAGES",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},Jn=H.atom({}),Gt=()=>H.useAtom(Jn),ee=(e,t)=>{const[s]=Gt();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},j=()=>ee("apiUrl","/chai/api"),Gs=()=>ee("usersApiUrl","/chai/users"),Xn=()=>ee("assetsApiUrl","/chai/assets"),Zn=()=>ee("websocket",null),er=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),L=()=>{const e=ee("onLogout"),t=ee("getAccessToken");return h.useCallback(async(s,n,r={})=>{const a=await t();if(!a)return console.error("No auth token found"),null;try{const i=p.get(n,"action","").toLowerCase(),l=await er(s+(i?`?action=${i}`:""),n,{...r,Authorization:`Bearer ${a}`});if(l.status===401)return console.log("401 Response",l),e(),window.location.reload(),null;if(!l.ok){const c=await l.json();throw console.error(`API Error (${l.status}):`,c),{status:l.status,statusText:l.statusText,...c,message:c.error||c.message||`Server error: ${l.status}`}}return await l.json()}catch(i){throw console.error("API request failed:",n,i),i}},[e,t])};function te(){const[e,t]=h.useState(new URLSearchParams(window.location.search));return h.useEffect(()=>{const s=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[]),[e,t]}const ye=e=>{const t=j(),[s]=te(),n=e??s.get("page"),r=L();return T.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})},Ae=()=>{const e=j(),t=L();return T.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:5*60*1e3,placeholderData:{languages:[],theme:{fontFamily:"",borderRadius:"",colors:{}},appKey:"",fallbackLang:""},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},ss=e=>{const{fallbackLang:t}=C.useLanguages(),{data:s}=Ae(),{data:n,isFetching:r}=ye(),a=h.useMemo(()=>{const i={[t]:!0};return p.each(p.get(s,"languages"),l=>{const c=p.find(n,{lang:l});i[l]=!!c}),i},[t,n,s]);return r||p.isEmpty(e)||e&&a[e]};class ks{constructor(t,s,n,r){ge(this,"channelId");ge(this,"websocket");ge(this,"channel",null);ge(this,"userId",null);ge(this,"clientId",null);ge(this,"pageId",null);ge(this,"callback");var a,i,l,c,d,f;this.userId=n,this.websocket=t,this.clientId=this.getClientId(),this.channelId=`WEBSITE:${s}`,this.callback=r,this.channel=this.websocket.channel(this.channelId,{config:{presence:{key:this.clientId}}}),(f=(d=(c=(l=(i=(a=this.channel)==null?void 0:a.on("presence",{event:"sync"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:i.on("presence",{event:"leave"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:l.on("presence",{event:"join"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:c.on("broadcast",{event:"TAKE_OVER_REQUESTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUESTED",u)))==null?void 0:d.on("broadcast",{event:"TAKE_OVER_REQUEST_ACCEPTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUEST_ACCEPTED",u)))==null||f.on("broadcast",{event:"TAKE_OVER_REQUEST_REJECTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUEST_REJECTED",u)).subscribe()}getClientId(){return crypto.randomUUID()}getOnlineUsers({pageId:t,userId:s}){var a;const n=(a=this.channel)==null?void 0:a.presenceState();let r=Object.values(n||{}).map(i=>i[0]).filter(Boolean);return t?r=r.filter(i=>i.pageId===t):s&&(r=r.filter(i=>i.userId===s)),r.sort((i,l)=>i.onlineAt-l.onlineAt)}getPageOwner(){const t=this.getOnlineUsers({pageId:this.pageId});return t.length>0?t[0]:null}getPageUserMapping(){const t=this.getOnlineUsers({}),s=p.groupBy(t,"pageId"),n={};return Object.keys(s).forEach(r=>{var i;const a=(i=p.minBy(s[r],"onlineAt"))==null?void 0:i.userId;a!==this.userId&&(n[r]=a)}),n}onReceiveEvent(t,s){if(!this.pageId)return;const n=this.getPageOwner();if(!n||n.clientId===this.clientId?this.callback("USER_JOINED",{isActiveInOtherTab:!1}):this.callback("PAGE_LOCKED",{isActiveInOtherTab:(n==null?void 0:n.userId)===this.userId&&(n==null?void 0:n.clientId)!==this.clientId}),s.targetClientId===this.clientId)switch(t){case"TAKE_OVER_REQUESTED":this.callback("TAKE_OVER_REQUESTED",{requestedBy:s==null?void 0:s.userId,requestingClientId:s==null?void 0:s.senderClientId,isRequestedFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_ACCEPTED":this.channel.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:n?n.onlineAt-10:+new Date}),this.callback("TAKE_OVER_REQUEST_ACCEPTED",{isTakingOverFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_REJECTED":this.callback("TAKE_OVER_REQUEST_REJECTED");break}}async joinPage(t){var s;this.pageId=t,(s=this.channel)==null||s.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:+new Date})}async leavePage(){var t;this.channel&&((t=this.channel)==null||t.untrack())}async sendEvent(t,s){var n,r;if(this.channel){const a={pageId:this.pageId,userId:this.userId,senderClientId:this.clientId};t==="TAKE_OVER_REQUESTED"?a.targetClientId=(n=this.getPageOwner())==null?void 0:n.clientId:(t==="TAKE_OVER_REQUEST_ACCEPTED"||t==="TAKE_OVER_REQUEST_REJECTED")&&(a.targetClientId=s==null?void 0:s.requestingClientId),await((r=this.channel)==null?void 0:r.send({event:t,payload:a,type:"broadcast"}))}}}const tr=H.atom(null),js=()=>H.useAtom(tr),ns=()=>{const[e]=js();return(e==null?void 0:e.slug)||""};function sr(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const nr=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=C.useLanguages(),{data:r}=Z(),a=r==null?void 0:r.pageType,i=j(),l=L(),{data:c,isFetching:d}=T.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:60*60*1e3,placeholderData:[],queryFn:async()=>await l(i,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),f=h.useMemo(()=>s===""?c.filter(u=>u.lang===""||u.lang===n):c.filter(u=>u.lang===s),[s,n,c]);return{allLangPages:c,data:f,isFetching:d}},Os=()=>{const{selectedLang:e,fallbackLang:t}=C.useLanguages(),[s,n]=js(),[r,a]=h.useState(""),i=sr(r,500),{allLangPages:l,data:c,isFetching:d}=nr({query:i}),f=h.useCallback(E=>n(E),[n]),u=h.useCallback(E=>a(E),[a]),g=h.useCallback(()=>{if(!s)return;const E=!(s!=null&&s.primaryPage),S=e.length===0,P=E?s==null?void 0:s.id:s==null?void 0:s.primaryPage,A=l.filter(x=>(x==null?void 0:x.primaryPage)===P||x.id===P).find(x=>S?x.lang===e||x.lang===t:x.lang===e);n(A||s)},[s,e,l,n,t]);return{isFetching:d,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:f,updateSearchQuery:u,onChangeLanguage:g}},rr=H.atom({lastSaved:void 0}),kt=()=>H.useAtom(rr),Z=()=>{const[e]=te(),t=e.get("page"),{data:s,isFetching:n}=ye();return{data:h.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},ue=()=>{const[e]=te(),t=e.get("lang")??"",{data:s,isFetching:n}=ye();return{data:h.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},ar=H.atom({}),ir=()=>H.useAtom(ar),or=()=>{const{data:e}=ue(),t=ns(),s=ee("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},He=()=>{const e=ee("currentUser"),t=ee("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},Rs=e=>{const t=Gs(),s=L();return T.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"})},lr=H.atom({status:"checking",requestedBy:"",isTakeOverRequested:!1,requestingClientId:"",isActiveInOtherTab:!1}),cr=H.atom(""),ur=H.atom(null),rs=H.atom({}),dr=()=>H.useAtom(rs),Se=()=>{const[e]=te(),t=e.get("page"),[s,n]=H.useAtom(lr),[r,a]=H.useAtom(ur),[i,l]=H.useAtom(cr),[c]=H.useAtom(rs);return{pageLock:s,pageToUser:c,lockingStatus:i,realtimeInstance:r,setPageLock:n,setLockingStatus:l,setRealtimeInstance:a,realtimePageLockEnabled:!!r,currentEditor:c[t||""],isLocked:t&&s.status==="locked"}},fr=()=>{const e=Zn(),{data:t}=Z(),{user:s}=He(),n=t==null?void 0:t.id,{data:r}=Ae(),{pageLock:a,setPageLock:i,setLockingStatus:l,realtimeInstance:c,setRealtimeInstance:d}=Se(),[,f]=H.useAtom(rs),u=h.useRef(!1),g=h.useRef(a),E=h.useRef(!1);return h.useEffect(()=>{if(s!=null&&s.id&&e&&!c&&(r!=null&&r.appKey)&&!E.current){E.current=!0;const S=async(_,A)=>{var x,G;switch(_){case"UPDATE_ONLINE_USERS":f((A==null?void 0:A.pageToUser)||{});break;case"PAGE_LOCKED":i({...g==null?void 0:g.current,requestedBy:"",status:"locked",isActiveInOtherTab:A==null?void 0:A.isActiveInOtherTab});break;case"USER_JOINED":if(((x=g==null?void 0:g.current)==null?void 0:x.status)==="editing")return;((G=g==null?void 0:g.current)==null?void 0:G.status)==="locked"&&l("can_edit_now"),i({...g==null?void 0:g.current,requestedBy:"",status:"editing",isActiveInOtherTab:A==null?void 0:A.isActiveInOtherTab});break;case"TAKE_OVER_REQUESTED":i({...g==null?void 0:g.current,requestingClientId:A==null?void 0:A.requestingClientId,requestedBy:A!=null&&A.isRequestedFromAnotherTab?"ANOTHER_TAB":A==null?void 0:A.requestedBy});break;case"TAKE_OVER_REQUEST_ACCEPTED":A!=null&&A.isTakingOverFromAnotherTab||(l("take_over_request_accepted"),F.toast.success("Your Page Take Over Request Accepted",{position:"top-center"})),i({...g==null?void 0:g.current,status:"editing",requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break;case"TAKE_OVER_REQUEST_REJECTED":l("take_over_request_rejected"),i({...g==null?void 0:g.current,requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break}},P=new ks(e,r==null?void 0:r.appKey,s==null?void 0:s.id,S);d(P)}},[d,e,r==null?void 0:r.appKey]),h.useEffect(()=>{g.current=a},[a]),h.useEffect(()=>{if(!(!c||!n||!(s!=null&&s.id)||u.current))return u.current=!0,c==null||c.joinPage(n),()=>{c&&u.current&&(u.current=!1,g.current={requestedBy:"",status:"checking",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1},l(""),i(g.current),c==null||c.leavePage())}},[n,c]),a==null?void 0:a.status},Us=()=>{const{data:e}=Z(),{user:t}=He(),s=e==null?void 0:e.id,{pageLock:n,setPageLock:r,realtimeInstance:a}=Se(),{savePageAsync:i}=C.useSavePage(),l=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(r({...n,isTakeOverRequested:!0}),a==null||a.sendEvent("TAKE_OVER_REQUESTED"))},[a,s,t==null?void 0:t.id,r,n]),c=h.useCallback(async()=>{!a||!s||!(t!=null&&t.id)||(await i(),a==null||a.sendEvent("TAKE_OVER_REQUEST_ACCEPTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({requestedBy:"",status:"locked",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,i,n]),d=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(a==null||a.sendEvent("TAKE_OVER_REQUEST_REJECTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({...n,requestedBy:"",status:"editing",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,n]);return{pageLock:n,acceptTakeOver:c,rejectTakeOver:d,requestTakeOver:l}},hr=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-Ddz2hnYs.cjs"))),gr=h.lazy(()=>Promise.resolve().then(()=>require("./page-locked-by-dialog-BvdAXZPw.cjs"))),Ft=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-request-Dx6OrOwM.cjs"))),mr=({isFetchingPage:e})=>{const{pageLock:t,requestTakeOver:s}=Us(),{currentEditor:n,lockingStatus:r,setLockingStatus:a,realtimePageLockEnabled:i}=Se(),{data:l,isFetching:c}=Rs(n),[d]=te(),f=d.get("page"),[u]=kt(),g=T.useQueryClient(),E=h.useCallback(()=>{s()},[s]);return!f||e||!i||(t==null?void 0:t.status)==="checking"?null:t!=null&&t.requestedBy?o.jsx(h.Suspense,{children:o.jsx(Ft,{lockingStatus:"",onContinue:()=>{s()}})}):(t==null?void 0:t.status)!=="locked"?r==="take_over_request_accepted"||r==="can_edit_now"?o.jsx(h.Suspense,{children:o.jsx(Ft,{lockingStatus:r,onContinue:()=>{g.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),a("")}})}):null:t!=null&&t.isActiveInOtherTab?o.jsx(h.Suspense,{children:o.jsx(Ft,{lockingStatus:"page_is_active_in_other_tab",onContinue:s})}):o.jsx(h.Suspense,{children:o.jsx(gr,{...l,isFetchingUserInfo:c,name:(l==null?void 0:l.name)||"Unknown User",email:(l==null?void 0:l.email)||"",lastSaved:(u==null?void 0:u.lastSaved)||"",onTakeOver:E,realtimePageLockEnabled:i,isRequestRejected:r==="take_over_request_rejected"})})},Er=()=>{const[e]=te(),t=e.get("lang");return ss(t)?null:o.jsx(h.Suspense,{children:o.jsx(hr,{})})},We={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"};function as(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 jt=H.atom(null),Ot=()=>{const{data:e}=Ae();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},is=()=>{const e=L(),t=j();return T.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},pr=e=>{const t=L(),s=j(),n=Ot();return T.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||{}})},yr=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-CUlpwqpH.cjs"))),Ms=({children:e})=>{const[t,s]=te(),n=t.get("page"),{data:r,isFetching:a}=Z(),{data:i,isFetching:l}=is(),[c,d]=h.useState(!1),[f,u]=h.useState(!0),{savePage:g}=C.useSavePage(),E=!!n&&!p.isEmpty(r),S=h.useMemo(()=>{if(!i||l)return!1;const x=i.find(G=>G.slug==="/");return x==null?void 0:x.id},[i,l]);h.useEffect(()=>{if(l||!S||i.some(q=>q.id===n))return;const G=new URLSearchParams({page:S});as(G,s),!l&&i&&u(!1)},[n,l,i,S,s]);const P=!f&&!n,_=!f&&!a&&p.isEmpty(r),A=c||P||_;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex items-center gap-x-1",children:o.jsx("div",{className:"relative",children:o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,onClick:()=>{g(),d(!0)},children:e||o.jsx(m.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:o.jsx(w.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),o.jsx(m.TooltipContent,{side:"right",children:o.jsx("p",{children:"Open pages manager"})})]})})}),o.jsx(m.Sheet,{open:A,onOpenChange:x=>!x&&E&&d(!1),children:o.jsxs(m.SheetContent,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[50vh] !max-w-[800px] border-border p-0 ${E?"":"sheet-hide-close-btn"}`,children:[o.jsxs(m.SheetHeader,{className:"mb-3 px-4 pt-4",children:[o.jsxs(m.SheetTitle,{className:"flex items-center gap-2 text-sm font-semibold",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:o.jsx(w.Folder,{className:"h-4 w-4"})}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold",children:"Pages"}),o.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:"Manage your site structure"})]})]}),o.jsx(m.SheetDescription,{className:"sr-only",children:"Manage your site structure"})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:A&&o.jsx(h.Suspense,{children:o.jsx(yr,{close:()=>d(!1)})})})]})})]})},Ar=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-D4VPifNs.cjs"))),Sr=()=>{const e=ee("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},Bs=({showAdd:e=!0,variant:t="ghost"})=>{const{fallbackLang:s,languages:n,selectedLang:r,setSelectedLang:a}=C.useLanguages(),i=p.isEmpty(r)?s:r,[,l]=te(),{isLocked:c}=Se();h.useEffect(()=>{const _=new URLSearchParams(window.location.search),A=_.get("lang");A&&(n.includes(A)?a(A):(_.delete("lang"),l(_),a("")))},[n,l,a]);const[,d]=H.useAtom(jt),{data:f}=Z(),{data:u}=Ae(),{data:g}=ye(),E=h.useMemo(()=>{const _=p.compact(p.map(p.get(u,"languages"),A=>{const x=p.find(g,{lang:A});return{key:A,value:p.get(We,A,A),isLangPageAdded:!!x}})).filter(Boolean);return[{key:s,value:p.get(We,s),isLangPageAdded:!0},..._]},[s,g,u]),S=_=>{if(document.querySelector('[data-panel-id="seo"]')){const x=new CustomEvent("seo-language-switch-check",{detail:{fromLang:i,toLang:_,switchHandler:()=>P(_)}});window.dispatchEvent(x);return}P(_)},P=_=>{a(_);const A=new URLSearchParams(window.location.search);_===s?A.delete("lang"):A.set("lang",_),as(A,l)};return p.isEmpty(n)?null:c?o.jsxs(m.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[o.jsx(w.Languages,{className:"h-4 w-4"}),p.get(We,i,i),o.jsx(w.ChevronDown,{className:"h-4 w-4"})]}):o.jsx(o.Fragment,{children:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:o.jsxs(m.Button,{disabled:!!c,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[o.jsx(w.Languages,{className:"h-4 w-4"}),p.get(We,i,i),o.jsx(w.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(m.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(E.filter(_=>_.isLangPageAdded),_=>o.jsxs(m.DropdownMenuItem,{className:C.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",_.key===i&&"!bg-gray-200 text-gray-700"),onClick:()=>S(_.key),children:[o.jsx("div",{className:"text-slate-600",children:_.value}),_.key===s&&o.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[o.jsx(w.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},_.value)),e&&!p.isEmpty(E.filter(_=>!_.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(m.Separator,{}),o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:()=>{f&&d({edit:!1,primaryPage:f.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(w.Plus,{className:"mr-1 h-3 w-3"})," Add Langauge"]})]})]})]})})};function Tr(){const[e,t]=H.useAtom(jt);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(Sr,{}),o.jsx(Ms,{}),e&&o.jsx(h.Suspense,{children:o.jsx(Ar,{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 Pr(){return o.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>o.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsx(m.Skeleton,{className:"h-4 w-3/4"}),o.jsx(m.Skeleton,{className:"h-3 w-1/2"}),o.jsx(m.Skeleton,{className:"mt-1 h-5 w-20"})]}),o.jsx(m.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const _r=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-dSFvGFEO.cjs")));function xr(){const[e,t]=z.useState(!1);return o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:0,children:[o.jsxs(m.Sheet,{open:e,onOpenChange:t,children:[o.jsx(m.SheetTrigger,{asChild:!0,children:o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs(m.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[o.jsx(w.History,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"View revision history"})]}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})})}),o.jsx(m.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&o.jsx(h.Suspense,{fallback:o.jsx(Pr,{}),children:o.jsx(_r,{isOpen:e})})})]}),o.jsx(m.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const Tt=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=C.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},Y={TOGGLE_PREVIEW:"Toggle Preview",OPEN_PREVIEW_IN_NEW_TAB:"Open preview in new tab",THEME:"Theme",SAVEDRAFT:"Save draft",SAVING:"Saving",SAVED:"Saved",PUBLISHED:"Published",PUBLISH:"Publish",UNPUBLISH:"Unpublish",WEBSITEDATA:"Website data",OPEN:"Open",EDIT_LANGUAGE:"Edit language",ADD_NEW_LANGUAGE:"Add new language page",ENTER_LANGUAGE_DETAILS:"Enter the details for the language",LANGUAGE:"Language",PAGE_NAME:"Page Name",SLUG:"Slug",UPDATE:"Update",UPDATING:"Updating...",ADDING:"Adding...",CHOOSE_LANGUAGE:"Choose language",ALL_AVAILABLE_LANGUAGE_PAGE:"All available language page is created.",TO_UPDATE_SLUG:"To update slug use 'Change slug' action",SLUG_SHOULD_START_WITH:" (Slug should start with /{lang})",CHOOSE_LANGUAGE_TO_ADD_SLUG:"Choose language to add slug",ENTER_PAGE_SLUG:"Enter page slug",ENTER_PAGE_NAME:"Enter page name",DELETE:"Delete",CHANGE_SLUG:"Change slug",PRIMARY:"Primary",SLUG_MUST_START_WITH:"Slug must start with /",EDIT:"Edit",UNPUBLISH_MSG:"Are you sure you want to unpublish",MARK_AS_TEMPLATE:"Mark as template",UNMARK_AS_TEMPLATE:"Unmark as template",PAGE_ADD_SUCCESS:"New page added successfully.",GLOBAL_BLOCK_ADD_SUCCESS:"New global block added successfully.",SEO_SETTINGS_UPDATE_SUCCESS:"SEO Settings updated successfully.",PAGE_UPDATE_SUCCESS:"Page updated successfully.",GLOBAL_BLOCK_UPDATE_SUCCESS:"Global block updated successfully.",PAGE_DELETE_SUCCESS:"Page deleted successfully.",GLOBAL_BLOCK_DELETE_SUCCESS:"Global block deleted successfully.",PAGE_UNPUBLISH_SUCCESS:"Page unpublished successfully.",GLOBAL_BLOCK_UNPUBLISH_SUCCESS:"Global block unpublished successfully.",PAGE_PUBLISH_SUCCESS:"Page published successfully.",GLOBAL_BLOCK_PUBLISH_SUCCESS:"Global block published successfully.",PAGES_PUBLISH_SUCCESS:"Your changes have been published successfully.",SLUG_CHANGE_SUCCESS:"Slug changed successfully."},vr={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},de=()=>{const e=j(),t=L();return T.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Fs=e=>{const{data:t}=de();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},wr=()=>{const e=j(),t=L();return T.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),[]}}})},br=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=de();return T.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(vr,r.message,r.message)})}})},Cr=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=ue(),{data:r}=de();return T.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})}})},Ir=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=de();return T.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})}})},Lr=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=de();return T.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?Y.PAGE_UNPUBLISH_SUCCESS:"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})}})},os=()=>{const e=j(),t=L(),s=T.useQueryClient(),{data:n}=Z(),{savePageAsync:r}=C.useSavePage();return T.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.")}})},Nr=()=>{const e=j(),t=L(),s=T.useQueryClient();return T.useMutation({mutationFn:async n=>{var r;return t(e,{action:y.MARK_AS_TEMPLATE,data:{id:(r=n.page)==null?void 0:r.id,name:n.name,description:n.description,pageType:n.pageType,previewImage:n.previewImage}})},onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page marked as template successfully.")},onError:()=>{F.toast.error("Failed to mark page as template.")}})},Dr=()=>{const e=j(),t=L(),s=T.useQueryClient();return T.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.")}})},Gr=()=>{const e=j(),t=L(),s=T.useQueryClient();return T.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(Y.SLUG_CHANGE_SUCCESS),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{F.toast.error("Failed to change slug")}})},kr=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-akIgltlm.cjs")));function jr({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=os();return o.jsx(m.Dialog,{open:e,onOpenChange:n?()=>{}:t,children:e&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:o.jsx(kr,{onClose:t,isPending:n,publishPage:s})})})}const se={...C.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"},Or={particleCount:350,spread:120,origin:{y:.6},angle:90},Rr={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Ur=async()=>{const{default:e}=await Promise.resolve().then(()=>require("./confetti.module-BuUnQuWk.cjs"));return e},Pt=e=>{let t=Rr[e];t||(t={});const s={...Or,...t};Ur().then(n=>n(s))};function Rt({children:e,content:t,side:s="bottom",delayDuration:n=700,showTooltip:r=!0}){return r?o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:n,children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:e}),o.jsx(m.TooltipContent,{side:s,sideOffset:10,children:o.jsx("p",{children:t})})]})}):e}const Mr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-c1mqQEa_.cjs"))),Br=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-Kctu12rQ.cjs"))),Fr=()=>{const{selectedLang:e,fallbackLang:t}=C.useLanguages(),s=ee("getPreviewUrl",async u=>u),[n,r]=h.useState(""),{data:a}=Z(),{data:i}=ye(),{data:l}=de(),c=h.useMemo(()=>{var u;return(u=i==null?void 0:i.find(g=>(g==null?void 0:g.lang)===e))==null?void 0:u.slug},[e,i]),d=h.useCallback(u=>{var g;return(g=p.find(l,{key:u}))==null?void 0:g.hasSlug},[l]),f=e===t?"":e;return h.useEffect(()=>{(async()=>{if(typeof s=="function"){const u=!d(a==null?void 0:a.pageType),g=await s(u?`${f!==""?f+"/":""}${a==null?void 0:a.id}`:c||"");r(g)}else r("")})()},[s,c,a==null?void 0:a.pageType,d,a==null?void 0:a.id,f]),o.jsx(o.Fragment,{children:o.jsx(Rt,{content:Y.OPEN_PREVIEW_IN_NEW_TAB,delayDuration:0,children:o.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:o.jsx(m.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(w.Play,{className:"h-4 w-4"})})})})})},qr=()=>{const[e,t]=C.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Rt,{content:Y.THEME,delayDuration:0,children:o.jsx(m.Button,{variant:e==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>t(e==="theme"?"block":"theme"),children:o.jsx(w.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},Kr=()=>{const[e,t]=h.useState(!1),{isLocked:s}=Se(),{savePageAsync:n,saveState:r}=C.useSavePage();h.useEffect(()=>{const d=f=>{r==="UNSAVED"&&(f.preventDefault(),f.returnValue=!1)};return r==="UNSAVED"&&window.addEventListener("beforeunload",d),()=>{window.removeEventListener("beforeunload",d)}},[r]);const a=h.useCallback(async()=>{e||(t(!0),await n(),t(!1))},[n,e]),{buttonIcon:i,buttonClass:l,tooltipContent:c}=h.useMemo(()=>{switch(r){case"UNSAVED":return{tooltipContent:Y.SAVEDRAFT,buttonIcon:o.jsx(w.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:Y.SAVING,buttonIcon:o.jsx(w.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:Y.SAVED,buttonIcon:o.jsx(w.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[r]);return s?null:o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:a,className:`${l} w-24 max-w-24`,children:[i," ",c]})},Hr=()=>{const{selectedLang:e}=C.useLanguages(),{data:t}=ue(),{data:s}=ye(),[n,r]=h.useState(!1),[a,i]=h.useState(!1),[l,c]=h.useState(null),{savePageAsync:d}=C.useSavePage(),[f,u]=h.useState(!1),{data:g}=Z(),{mutate:E,isPending:S}=os(),{needTranslations:P}=C.useSavePage(),_=P(),{buttonText:A,buttonClassName:x,isPublished:G}=h.useMemo(()=>{const U=g&&(g==null?void 0:g.online);return{buttonClassName:U?"hover:bg-green-600 bg-green-500":"",isPublished:U,buttonText:U?Y.PUBLISHED:Y.PUBLISH}},[g]),q=async()=>{if(_){u(!0);return}V()},V=()=>{const U=[t==null?void 0:t.id,t==null?void 0:t.primaryPage];E({ids:p.compact(U)},{onSuccess:()=>Pt("TOP_RIGHT")})},O=()=>{u(!1),V()},oe=async()=>{u(!1),await d()},le=h.useMemo(()=>p.map(s??[],"id"),[s]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(m.Button,{size:"sm",onClick:q,disabled:S||!(g!=null&&g.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${x}`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[o.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${a?"-translate-y-10":""}`,children:G?o.jsx(w.Send,{className:"h-4 w-4"}):o.jsx(w.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 ${a?"":"translate-y-10"}`,children:G?o.jsx(w.Rocket,{className:"h-4 w-4"}):o.jsx(w.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:A}),e?`(${p.upperCase(e)})`:""]}),o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",disabled:S||!(g!=null&&g.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${x}`,children:o.jsx(w.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(m.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(m.DropdownMenuItem,{disabled:S,className:"cursor-pointer text-xs",onClick:()=>E({ids:le},{onSuccess:()=>Pt("TOP_RIGHT")}),children:[Y.PUBLISH," with translation pages"]}),!G&&o.jsxs(m.DropdownMenuItem,{disabled:S,className:"cursor-pointer text-xs",onClick:()=>E({ids:[g==null?void 0:g.id]},{onSuccess:()=>Pt("TOP_RIGHT")}),children:[Y.PUBLISH," page"]}),o.jsxs(m.DropdownMenuItem,{onClick:()=>r(!0),className:"cursor-pointer text-xs",children:[Y.OPEN," publish menu"]}),G&&o.jsxs(m.DropdownMenuItem,{onClick:()=>c(t),className:"cursor-pointer text-xs",children:[Y.UNPUBLISH," page ",e?`(${p.upperCase(e)})`:""]})]})]})]}),o.jsx(jr,{showModal:n,onClose:()=>r(!1)}),l&&o.jsx(h.Suspense,{children:o.jsx(Mr,{page:l,onClose:()=>c(null)})}),f&&o.jsx(h.Suspense,{children:o.jsx(Br,{isOpen:f,onClose:oe,onContinue:O,isPending:S})})]})};function Vr(){const{isLocked:e}=Se(),[t]=te(),s=t.get("lang"),n=ss(s);return e||!n?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsx(xr,{}),o.jsx(Tt,{permission:se.EDIT_THEME,children:o.jsx(qr,{})}),o.jsx(Fr,{}),o.jsx(Tt,{permission:se.SAVE_PAGE,children:o.jsx(Kr,{})}),o.jsx(Tt,{permission:se.PUBLISH_PAGE,children:o.jsx(Hr,{})})]})}const qs=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{hasPermission:d}=C.usePermissions(),{data:f}=de(),u=h.useMemo(()=>p.find(f,{key:e.pageType}),[f,e.pageType]),g=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),E=h.useMemo(()=>!!(u!=null&&u.hasSlug),[u==null?void 0:u.hasSlug]);return!d(se.EDIT_PAGE)&&!d(se.DELETE_PAGE)&&!d(se.UNPUBLISH_PAGE)||!e?null:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,onClick:P=>P.stopPropagation(),children:l}),o.jsxs(m.DropdownMenuContent,{align:"center",className:"text-sm",children:[d(se.ADD_PAGE)&&!c&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),t(e)},children:[o.jsx(w.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),d(se.EDIT_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),s({...e,global:!(u!=null&&u.hasSlug)})},children:[o.jsx(w.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&d(se.UNPUBLISH_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),n(e)},children:[o.jsx(w.Power,{className:"size-3"}),Y.UNPUBLISH]}),d(se.DELETE_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),r(e)},children:[o.jsx(w.Trash,{className:"size-3"}),Y.DELETE]}),d(se.MARK_AS_TEMPLATE)&&E&&!c&&o.jsx(o.Fragment,{children:g?o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),i(e)},children:[o.jsx(w.SquareLibrary,{className:"size-3"}),Y.UNMARK_AS_TEMPLATE]}):o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),a(e)},children:[o.jsx(w.SquareLibrary,{className:"size-3"}),Y.MARK_AS_TEMPLATE]})})]})]})},Qr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-BuK6We-q.cjs"))),zr=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-B-TP6nJ7.cjs"))),Wr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-D4Oiy71Q.cjs"))),$r=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-CcnkROAU.cjs"))),Yr=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-DXEs6foh.cjs"))),Jr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-c1mqQEa_.cjs"))),Xr=()=>{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),[f,u]=h.useState(null),{data:g,isFetching:E}=ue(),{selectedLang:S,fallbackLang:P}=C.useLanguages(),{data:_}=ye(),A=_==null?void 0:_.find(O=>O.lang===S),{isLocked:x}=Se(),G=!(g!=null&&g.slug),[,q]=H.useAtom(jt);if(!g)return null;const V=O=>{S.length>0&&S!==P?q({edit:!0,id:O==null?void 0:O.id,primaryPage:O==null?void 0:O.primaryPage}):u(O)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between rounded px-[2px] transition-colors duration-200",children:[o.jsx(Ms,{children:o.jsx(m.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:E?o.jsx(w.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:[G?o.jsx(w.Hash,{className:"mr-1 h-4 w-4"}):o.jsx(w.File,{className:"mr-1 h-4 w-4"}),p.get(A||g,"name")??""]})})}),x?o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:o.jsx(w.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx(qs,{page:g,setDuplicatePage:O=>d(O),setAddEditPage:O=>V(O),setUnpublishPage:O=>n(O),setDeletePage:O=>t(O),setMarkAsTemplate:O=>a(O),setUnmarkAsTemplate:O=>l(O),isLanguagePage:S.length>0&&S!==P,children:o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(w.MoreHorizontal,{className:"h-4 w-4"})})})]}),f&&o.jsx(h.Suspense,{children:o.jsx(Qr,{closePanel:()=>u(null),editPage:()=>{},addEditPage:f,setAddEditPage:u})}),e&&o.jsx(h.Suspense,{children:o.jsx(zr,{page:e,onClose:()=>t(null)})}),s&&o.jsx(h.Suspense,{children:o.jsx(Jr,{page:s,onClose:()=>n(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx($r,{page:r,onClose:()=>a(null)})}),i&&o.jsx(h.Suspense,{children:o.jsx(Yr,{page:i,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(Wr,{page:c,onClose:()=>d(null),closePanel:()=>u(null)})})]})},ls=({children:e,className:t=""})=>o.jsx("div",{className:C.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}),Zr=({hasDynamicPage:e})=>o.jsx(ls,{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"})]})}),ea=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-Cz6zWaKo.cjs"))),ta=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=Os(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(Zr,{hasDynamicPage:n}),o.jsx(h.Suspense,{children:o.jsx(ea,{})})]})},sa=()=>{const{data:e,isFetching:t}=ue(),{data:s,isFetching:n}=Z(),r=p.get(s,"dynamic",!1),a=ns(),i=C.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,d=or(),f=t||n,g=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return o.jsxs("div",{className:"relative flex items-center gap-x-1",children:[o.jsx("div",{className:C.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",f&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(Xr,{})}),o.jsxs("div",{className:C.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800"+(c?" pr-2":""),f&&"max-w-0 overflow-hidden opacity-0"),children:[o.jsx(Bs,{}),o.jsxs("div",{className:"flex w-full items-center overflow-hidden",children:[o.jsx("div",{className:`w-full max-w-[200px] overflow-hidden overflow-ellipsis whitespace-nowrap pl-1 text-xs ${c?"italic text-gray-400":"font-mono text-gray-500"}`,children:g==="/"?o.jsxs("span",{className:"text-gray-900",children:["/",o.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):g}),!c&&o.jsx("a",{href: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(w.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&i&&o.jsx(ta,{})]})},na=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(Tr,{}),o.jsx(sa,{}),o.jsx(Vr,{})]}),Ks=()=>{const e=T.useQueryClient(),{data:t}=T.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},ra=()=>{const e=j(),{aiContext:t}=Ks(),s=L();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])},aa=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=Ds.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}),ia=e=>{const t=Ds.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:aa(t,s)}},[e,t])},oa=()=>{const[e]=te(),t=e.get("page"),s=j(),{setAiContext:n}=Ks(),[,r]=kt(),[,a]=ir(),[,i]=C.useIsPageLoaded(),l=L();return T.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??[],f=p.find(d,{_type:"@chai/ai-context"});return n(p.get(f,"_value","")||""),r(u=>({...u,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),d},enabled:!!t})},Hs=()=>{const{data:e}=Z(),{data:t}=ue(),s=j(),n=L(),r=Ot(),a=ns();return T.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})},Vs=()=>{const e=j(),t=T.useQueryClient(),s=L();return T.useMutation({mutationFn:async n=>s(e,{action:y.UPDATE_WEBSITE_SETTINGS,data:n}),onSuccess:(n,r)=>{var a;t.invalidateQueries({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS]}),(a=r==null?void 0:r.settings)!=null&&a.theme||F.toast.success("Website settings updated successfully.")},onError:n=>{F.toast.error("Failed to update website settings",{description:n.message})}})},la=()=>{const e=j(),t=T.useQueryClient(),s=L(),{selectedLang:n}=C.useLanguages();return T.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})}})},ca=()=>{const e=j(),t=T.useQueryClient(),s=L(),{selectedLang:n}=C.useLanguages();return T.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})}})},ua=()=>{const e=j(),t=T.useQueryClient(),s=L();return T.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})}})},da=()=>{const e=j(),t=L();return T.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})}})},fa=()=>{const e=j(),t=L();return T.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})}})},ha=()=>{const e=j(),t=L();return T.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})}})},ys={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:C.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),[]}}},ga=()=>{const e=j(),t=L();return T.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{C.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>ys.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>ys.getUILibraryBlock(a,t,e)})}),n}})},Qs=()=>{const e=Gs(),t=L(),{user:s}=He(),n=s==null?void 0:s.id;return T.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})},ma=()=>{const e=j(),t=L(),[,s]=kt();return{onSave:async({page:r,blocks:a,needTranslations:i})=>{try{const l=await t(e,{action:"UPDATE_PAGE",data:{id:r,blocks:a,needTranslations:i}});return l.code==="PAGE_LOCKED"?!0:(s(c=>({...c,lastSaved:new Date().toISOString()})),l)}catch(l){return console.error(l),new Error("Failed to save blocks")}}}},Ea=()=>{const{data:e}=is(),t=j(),s=L();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])}},pa=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-ExS97Zgk.cjs"))),ya=({isActive:e,show:t})=>{const{data:s}=Ae();return!p.has(s,"languages")||!p.get(s,"languages",[]).length?null:o.jsx(m.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:o.jsx(w.LanguagesIcon,{className:"h-4 w-4"})})},zs="lang",Aa={id:zs,label:"Languages",position:"top",panel:pa,button:ya,view:"modal",width:400},Sa=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-Ce6aTIyt.cjs"))),Ws="seo",Ta=({isActive:e,show:t})=>{const{data:s}=Z(),n=Fs(s==null?void 0:s.pageType);return!p.has(n,"hasSlug")||!n.hasSlug?null:o.jsx(m.Button,{size:"icon",className:"my-1 p-0",onClick:t,variant:e?"default":"ghost",children:o.jsxs("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M7 8h-3a1 1 0 0 0 -1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-3"}),o.jsx("path",{d:"M14 16h-4v-8h4"}),o.jsx("path",{d:"M11 12h2"}),o.jsx("path",{d:"M17 8m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]})})},Pa={id:Ws,label:"SEO",panel:Sa,button:Ta,position:"top",width:600,view:"modal"},$s="user-info",_a=()=>{const{user:e,logout:t}=He(),s=ee("onLogout",p.noop);return e?o.jsxs(m.HoverCard,{children:[o.jsx(m.HoverCardTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"ghost",className:"text-sm font-medium",children:o.jsx(w.User,{className:"h-4 w-4"})})}),o.jsxs(m.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[o.jsx("div",{className:"text-sm font-medium",children:e.name??e.email}),o.jsx("div",{className:"text-xs text-muted-foreground",children:e.email}),o.jsxs(m.AlertDialog,{children:[o.jsx(m.AlertDialogTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"outline",size:"sm",className:"w-full",children:"Logout"})}),o.jsxs(m.AlertDialogContent,{children:[o.jsxs(m.AlertDialogHeader,{children:[o.jsx(m.AlertDialogTitle,{children:"Are you sure you want to logout?"}),o.jsx(m.AlertDialogDescription,{children:"You will be redirected to the login page."})]}),o.jsxs(m.AlertDialogFooter,{children:[o.jsx(m.AlertDialogCancel,{children:"Cancel"}),o.jsx(m.AlertDialogAction,{onClick:()=>{t(),p.isFunction(s)&&s()},children:"Logout"})]})]})]})]})]}):null},xa={id:$s,label:"User Info",button:_a,position:"bottom"},va=()=>{C.registerChaiSidebarPanel(Ws,Pa),C.registerChaiSidebarPanel(zs,Aa),C.registerChaiSidebarPanel($s,xa)};var b={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return As(this.context.count)},getNextContextId(){return As(this.context.count++)}};function As(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 Ys=!1,wa=(e,t)=>e===t,vt=Symbol("solid-proxy"),Js=typeof Proxy=="function",cs=Symbol("solid-track"),wt={equals:wa},Xs=on,fe=1,bt=2,Zs={owned:null,cleanups:null,context:null,owner:null},qt={},D=null,Kt=null,ba=null,M=null,X=null,ce=null,Ut=0;function me(e,t){const s=M,n=D,r=e.length===0,a=t===void 0?n:t,i=r?Zs:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>J(()=>et(i)));D=i,M=null;try{return ie(l,!0)}finally{M=s,D=n}}function K(e,t){t=t?Object.assign({},wt,t):wt;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),an(s,r));return[rn.bind(s),n]}function en(e,t,s){const n=Mt(e,t,!0,fe);Ve(n)}function Ee(e,t,s){const n=Mt(e,t,!1,fe);Ve(n)}function us(e,t,s){Xs=Ba;const n=Mt(e,t,!1,fe);(!s||!s.render)&&(n.user=!0),ce?ce.push(n):Ve(n)}function W(e,t,s){s=s?Object.assign({},wt,s):wt;const n=Mt(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,Ve(n),rn.bind(n)}function Ca(e){return e&&typeof e=="object"&&"then"in e}function Ia(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=qt,c=null,d=!1,f="initialValue"in a,u=typeof n=="function"&&W(n);const g=new Set,[E,S]=(a.storage||K)(a.initialValue),[P,_]=K(void 0),[A,x]=K(void 0,{equals:!1}),[G,q]=K(f?"ready":"unresolved");b.context&&(c=b.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function V(I,N,$,Q){return i===I&&(i=null,Q!==void 0&&(f=!0),(I===l||N===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(Q,{value:N})),l=qt,O(N,$)),N}function O(I,N){ie(()=>{N===void 0&&S(()=>I),q(N!==void 0?"errored":f?"ready":"unresolved"),_(N);for(const $ of g.keys())$.decrement();g.clear()},!1)}function oe(){const I=Ra,N=E(),$=P();if($!==void 0&&!i)throw $;return M&&M.user,N}function le(I=!0){if(I!==!1&&d)return;d=!1;const N=u?u():n;if(N==null||N===!1){V(i,J(E));return}let $;const Q=l!==qt?l:J(()=>{try{return r(N,{value:E(),refetching:I})}catch(ne){$=ne}});if($!==void 0){V(i,void 0,_t($),N);return}else if(!Ca(Q))return V(i,Q,void 0,N),Q;return i=Q,"v"in Q?(Q.s===1?V(i,Q.v,void 0,N):V(i,void 0,_t(Q.v),N),Q):(d=!0,queueMicrotask(()=>d=!1),ie(()=>{q(f?"refreshing":"pending"),x()},!1),Q.then(ne=>V(Q,ne,void 0,N),ne=>V(Q,void 0,_t(ne),N)))}Object.defineProperties(oe,{state:{get:()=>G()},error:{get:()=>P()},loading:{get(){const I=G();return I==="pending"||I==="refreshing"}},latest:{get(){if(!f)return oe();const I=P();if(I&&!i)throw I;return E()}}});let U=D;return u?en(()=>(U=D,le(!1))):le(!1),[oe,{refetch:I=>sn(U,()=>le(I)),mutate:S}]}function La(e){return ie(e,!1)}function J(e){if(M===null)return e();const t=M;M=null;try{return e()}finally{M=t}}function Na(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=J(()=>t(l,r,i));return r=l,c}}function tn(e){us(()=>J(e))}function qe(e){return D===null||(D.cleanups===null?D.cleanups=[e]:D.cleanups.push(e)),e}function Ss(){return D}function sn(e,t){const s=D,n=M;D=e,M=null;try{return ie(t,!0)}catch(r){ds(r)}finally{D=s,M=n}}function Da(e){const t=M,s=D;return Promise.resolve().then(()=>{M=t,D=s;let n;return ie(e,!1),M=D=null,n?n.done:void 0})}var[Ga,Ko]=K(!1);function ka(){return[Ga,Da]}function ja(e,t){const s=Symbol("context");return{id:s,Provider:Fa(s),defaultValue:e}}function Oa(e){let t;return D&&D.context&&(t=D.context[e.id])!==void 0?t:e.defaultValue}function nn(e){const t=W(e),s=W(()=>zt(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var Ra;function rn(){if(this.sources&&this.state)if(this.state===fe)Ve(this);else{const e=X;X=null,ie(()=>It(this),!1),X=e}if(M){const e=this.observers?this.observers.length:0;M.sources?(M.sources.push(this),M.sourceSlots.push(e)):(M.sources=[this],M.sourceSlots=[e]),this.observers?(this.observers.push(M),this.observerSlots.push(M.sources.length-1)):(this.observers=[M],this.observerSlots=[M.sources.length-1])}return this.value}function an(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&ie(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],i=Kt&&Kt.running;i&&Kt.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?X.push(a):ce.push(a),a.observers&&ln(a)),i||(a.state=fe)}if(X.length>1e6)throw X=[],new Error},!1)),t}function Ve(e){if(!e.fn)return;et(e);const t=Ut;Ua(e,e.value,t)}function Ua(e,t,s){let n;const r=D,a=M;M=D=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=fe,e.owned&&e.owned.forEach(et),e.owned=null),e.updatedAt=s+1,ds(i)}finally{M=a,D=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?an(e,n):e.value=n,e.updatedAt=s)}function Mt(e,t,s,n=fe,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:D,context:D?D.context:null,pure:s};return D===null||D!==Zs&&(D.owned?D.owned.push(a):D.owned=[a]),a}function Ct(e){if(e.state===0)return;if(e.state===bt)return It(e);if(e.suspense&&J(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Ut);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===fe)Ve(e);else if(e.state===bt){const n=X;X=null,ie(()=>It(e,t[0]),!1),X=n}}function ie(e,t){if(X)return e();let s=!1;t||(X=[]),ce?s=!0:ce=[],Ut++;try{const n=e();return Ma(s),n}catch(n){s||(ce=null),X=null,ds(n)}}function Ma(e){if(X&&(on(X),X=null),e)return;const t=ce;ce=null,t.length&&ie(()=>Xs(t),!1)}function on(e){for(let t=0;t<e.length;t++)Ct(e[t])}function Ba(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:Ct(n)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,s));return}$e()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],s+=b.effects.length,delete b.effects),t=0;t<s;t++)Ct(e[t])}function It(e,t){e.state=0;for(let s=0;s<e.sources.length;s+=1){const n=e.sources[s];if(n.sources){const r=n.state;r===fe?n!==t&&(!n.updatedAt||n.updatedAt<Ut)&&Ct(n):r===bt&&It(n,t)}}}function ln(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=bt,s.pure?X.push(s):ce.push(s),s.observers&&ln(s))}}function et(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),r=s.observers;if(r&&r.length){const 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--)et(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)et(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function _t(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function ds(e,t=D){throw _t(e)}function zt(e){if(typeof e=="function"&&!e.length)return zt(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=zt(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Fa(e,t){return function(n){let r;return Ee(()=>r=J(()=>(D.context={...D.context,[e]:n.value},nn(()=>n.children))),void 0),r}}var Wt=Symbol("fallback");function Lt(e){for(let t=0;t<e.length;t++)e[t]()}function qa(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return qe(()=>Lt(a)),()=>{let c=e()||[],d=c.length,f,u;return c[cs],J(()=>{let E,S,P,_,A,x,G,q,V;if(d===0)i!==0&&(Lt(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[Wt],r[0]=me(O=>(a[0]=O,s.fallback())),i=1);else if(i===0){for(r=new Array(d),u=0;u<d;u++)n[u]=c[u],r[u]=me(g);i=d}else{for(P=new Array(d),_=new Array(d),l&&(A=new Array(d)),x=0,G=Math.min(i,d);x<G&&n[x]===c[x];x++);for(G=i-1,q=d-1;G>=x&&q>=x&&n[G]===c[q];G--,q--)P[q]=r[G],_[q]=a[G],l&&(A[q]=l[G]);for(E=new Map,S=new Array(q+1),u=q;u>=x;u--)V=c[u],f=E.get(V),S[u]=f===void 0?-1:f,E.set(V,u);for(f=x;f<=G;f++)V=n[f],u=E.get(V),u!==void 0&&u!==-1?(P[u]=r[f],_[u]=a[f],l&&(A[u]=l[f]),u=S[u],E.set(V,u)):a[f]();for(u=x;u<d;u++)u in P?(r[u]=P[u],a[u]=_[u],l&&(l[u]=A[u],l[u](u))):r[u]=me(g);r=r.slice(0,i=d),n=c.slice(0)}return r});function g(E){if(a[u]=E,l){const[S,P]=K(u);return l[u]=P,t(c[u],S)}return t(c[u])}}}function Ka(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return qe(()=>Lt(a)),()=>{const d=e()||[],f=d.length;return d[cs],J(()=>{if(f===0)return l!==0&&(Lt(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[Wt],r[0]=me(g=>(a[0]=g,s.fallback())),l=1),r;for(n[0]===Wt&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<f;c++)c<n.length&&n[c]!==d[c]?i[c](()=>d[c]):c>=n.length&&(r[c]=me(u));for(;c<n.length;c++)a[c]();return l=i.length=a.length=f,n=d.slice(0),r=r.slice(0,l)});function u(g){a[c]=g;const[E,S]=K(d[c]);return i[c]=S,t(E,c)}}}function fs(e,t){return J(()=>e(t||{}))}function yt(){return!0}var $t={get(e,t,s){return t===vt?s:e.get(t)},has(e,t){return t===vt?!0:e.has(t)},set:yt,deleteProperty:yt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:yt,deleteProperty:yt}},ownKeys(e){return e.keys()}};function Ht(e){return(e=typeof e=="function"?e():e)?e:{}}function Ha(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function hs(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&vt in l,e[i]=typeof l=="function"?(t=!0,W(l)):l}if(Js&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=Ht(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in Ht(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(Ht(e[l])));return[...new Set(i)]}},$t);const s={},n=Object.create(null);for(let i=e.length-1;i>=0;i--){const l=e[i];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let d=c.length-1;d>=0;d--){const f=c[d];if(f==="__proto__"||f==="constructor")continue;const u=Object.getOwnPropertyDescriptor(l,f);if(!n[f])n[f]=u.get?{enumerable:!0,configurable:!0,get:Ha.bind(s[f]=[u.get.bind(l)])}:u.value!==void 0?u:void 0;else{const g=s[f];g&&(u.get?g.push(u.get.bind(l)):u.value!==void 0&&g.push(()=>u.value))}}}const r={},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 cn(e,...t){if(Js&&vt in e){const r=new Set(t.length>1?t.flat():t[0]),a=t.map(i=>new Proxy({get(l){return i.includes(l)?e[l]:void 0},has(l){return i.includes(l)&&l in e},keys(){return i.filter(l=>l in e)}},$t));return a.push(new Proxy({get(i){return r.has(i)?void 0:e[i]},has(i){return r.has(i)?!1:i in e},keys(){return Object.keys(e).filter(i=>!r.has(i))}},$t)),a}const s={},n=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),i=!a.get&&!a.set&&a.enumerable&&a.writable&&a.configurable;let l=!1,c=0;for(const 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 un(e){let t,s;const n=r=>{const a=b.context;if(a){const[l,c]=K();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]=Ia(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return W(()=>(i=t())?J(()=>{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 Va=0;function Qa(){return b.context?b.getNextContextId():`cl-${Va++}`}var dn=e=>`Stale read from <${e}>.`;function za(e){const t="fallback"in e&&{fallback:()=>e.fallback};return W(qa(()=>e.each,e.children,t||void 0))}function Wa(e){const t="fallback"in e&&{fallback:()=>e.fallback};return W(Ka(()=>e.each,e.children,t||void 0))}function $a(e){const t=e.keyed,s=W(()=>e.when,void 0,void 0),n=t?s:W(s,void 0,{equals:(r,a)=>!r==!a});return W(()=>{const r=n();if(r){const a=e.children;return typeof a=="function"&&a.length>0?J(()=>a(t?r:()=>{if(!J(n))throw dn("Show");return s()})):a}return e.fallback},void 0,void 0)}function Ya(e){const t=nn(()=>e.children),s=W(()=>{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,f=W(()=>d()?void 0:c.when,void 0,void 0),u=c.keyed?f:W(f,void 0,{equals:(g,E)=>!g==!E});a=()=>d()||(u()?[l,f,c]:void 0)}return a});return W(()=>{const n=s()();if(!n)return e.fallback;const[r,a,i]=n,l=i.children;return typeof l=="function"&&l.length>0?J(()=>l(i.keyed?a():()=>{var d;if(((d=J(s)())==null?void 0:d[0])!==r)throw dn("Match");return a()})):l},void 0,void 0)}function Ja(e){return e}var Xa=["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"],Za=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...Xa]),ei=new Set(["innerHTML","textContent","innerText","children"]),ti=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),si=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 ni(e,t){const s=si[e];return typeof s=="object"?s[t]?s.$:void 0:s}var ri=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),ai=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"]),ii={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},oi=e=>W(()=>e());function li(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 f=a<n?l?s[l-1].nextSibling:s[a-l]:c;for(;l<a;)e.insertBefore(s[l++],f)}else if(a===l)for(;i<r;)(!d||!d.has(t[i]))&&t[i].remove(),i++;else if(t[i]===s[a-1]&&s[l]===t[r-1]){const f=t[--r].nextSibling;e.insertBefore(s[l++],t[i++].nextSibling),e.insertBefore(s[--a],f),t[r]=s[a]}else{if(!d){d=new Map;let u=l;for(;u<a;)d.set(s[u],u++)}const f=d.get(t[i]);if(f!=null)if(l<f&&f<a){let u=i,g=1,E;for(;++u<r&&u<a&&!((E=d.get(t[u]))==null||E!==f+g);)g++;if(g>f-l){const S=t[i];for(;l<f;)e.insertBefore(s[l++],S)}else e.replaceChild(s[l++],t[i++])}else i++;else t[i++].remove()}}}var Xe="_$DX_DELEGATE";function fn(e,t,s,n={}){let r;return me(a=>{r=a,t===document?e():Dt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function ci(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 hn(e,t=window.document){const s=t[Xe]||(t[Xe]=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,yn))}}function ui(e=window.document){if(e[Xe]){for(let t of e[Xe].keys())e.removeEventListener(t,yn);delete e[Xe]}}function Nt(e,t,s){xe(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function di(e,t,s,n){xe(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function fi(e,t,s){xe(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function gn(e,t){xe(e)||(t==null?e.removeAttribute("class"):e.className=t)}function mn(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 hi(e,t,s={}){const n=Object.keys(t||{}),r=Object.keys(s);let a,i;for(a=0,i=r.length;a<i;a++){const l=r[a];!l||l==="undefined"||t[l]||(Ts(e,l,!1),delete s[l])}for(a=0,i=n.length;a<i;a++){const l=n[a],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(Ts(e,l,!0),s[l]=c)}return s}function gi(e,t,s){if(!t)return s?Nt(e,"style"):t;const n=e.style;if(typeof t=="string")return n.cssText=t;typeof s=="string"&&(n.cssText=s=void 0),s||(s={}),t||(t={});let r,a;for(a in s)t[a]==null&&n.removeProperty(a),delete s[a];for(a in t)r=t[a],r!==s[a]&&(n.setProperty(a,r),s[a]=r);return s}function En(e,t={},s,n){const r={};return n||Ee(()=>r.children=tt(e,t.children,r.children)),Ee(()=>typeof t.ref=="function"&&pn(t.ref,e)),Ee(()=>mi(e,t,s,!0,r,!0)),r}function pn(e,t,s){return J(()=>e(t,s))}function Dt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return tt(e,t,n,s);Ee(r=>tt(e,t(),r,s),n)}function mi(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Ps(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Ps(e,i,l,r[i],s,a,t)}}function Ei(e){let t,s;return!xe()||!(t=b.registry.get(s=yi()))?e():(b.completed&&b.completed.add(t),b.registry.delete(s),t)}function xe(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function pi(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Ts(e,t,s){const n=t.trim().split(/\s+/);for(let r=0,a=n.length;r<a;r++)e.classList.toggle(n[r],s)}function Ps(e,t,s,n,r,a,i){let l,c,d,f,u;if(t==="style")return gi(e,s,n);if(t==="classList")return hi(e,s,n);if(s===n)return n;if(t==="ref")a||s(e);else if(t.slice(0,3)==="on:"){const g=t.slice(3);n&&e.removeEventListener(g,n,typeof n!="function"&&n),s&&e.addEventListener(g,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const g=t.slice(10);n&&e.removeEventListener(g,n,!0),s&&e.addEventListener(g,s,!0)}else if(t.slice(0,2)==="on"){const g=t.slice(2).toLowerCase(),E=ri.has(g);if(!E&&n){const S=Array.isArray(n)?n[0]:n;e.removeEventListener(g,S)}(E||s)&&(mn(e,g,s,E),E&&hn([g]))}else if(t.slice(0,5)==="attr:")Nt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")fi(e,t.slice(5),s);else if((u=t.slice(0,5)==="prop:")||(d=ei.has(t))||!r&&((f=ni(t,e.tagName))||(c=Za.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(u)t=t.slice(5),c=!0;else if(xe(e))return s;t==="class"||t==="className"?gn(e,s):l&&!c&&!d?e[pi(t)]=s:e[f||t]=s}else{const g=r&&t.indexOf(":")>-1&&ii[t.split(":")[0]];g?di(e,g,t,s):Nt(e,ti[t]||t,s)}return s}function yn(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 tt(e,t,s,n,r){const a=xe(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let d=0;d<s.length;d++){const f=s[d];f.nodeType===8&&f.data.slice(0,2)==="!$"?f.remove():c.push(f)}s=c}for(;typeof s=="function";)s=s();if(t===s)return s;const i=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,i==="string"||i==="number"){if(a||i==="number"&&(t=t.toString(),t===s))return s;if(l){let c=s[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),s=ve(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||i==="boolean"){if(a)return s;s=ve(e,s,n)}else{if(i==="function")return Ee(()=>{let c=t();for(;typeof c=="function";)c=c();s=tt(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],d=s&&Array.isArray(s);if(Yt(c,t,s,r))return Ee(()=>s=tt(e,c,s,n,!0)),()=>s;if(a){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let f=c[0];if(f.parentNode!==e)return s;const u=[f];for(;(f=f.nextSibling)!==n;)u.push(f);return s=u}if(c.length===0){if(s=ve(e,s,n),l)return s}else d?s.length===0?_s(e,c,n):li(e,s,c):(s&&ve(e),_s(e,c));s=c}else if(t.nodeType){if(a&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=ve(e,s,n,t);ve(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function Yt(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=Yt(e,l,c)||r;else if(d==="function")if(n){for(;typeof l=="function";)l=l();r=Yt(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const f=String(l);c&&c.nodeType===3&&c.data===f?e.push(c):e.push(document.createTextNode(f))}}return r}function _s(e,t,s=null){for(let n=0,r=t.length;n<r;n++)e.insertBefore(t[n],s)}function ve(e,t,s,n){if(s===void 0)return e.textContent="";const r=n||document.createTextNode("");if(t.length){let a=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(r!==l){const c=l.parentNode===e;!a&&!i?c?e.replaceChild(r,l):e.insertBefore(r,s):c&&l.remove()}else a=!0}}else e.insertBefore(r,s);return[r]}function yi(){return b.getNextContextId()}var Ai="http://www.w3.org/2000/svg";function An(e,t=!1){return t?document.createElementNS(Ai,e):document.createElement(e)}function Si(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=Ss();let a,i=!!b.context;return us(()=>{i&&(Ss().user=i=!1),a||(a=sn(r,()=>W(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,d]=K(!1),f=()=>d(!0);me(u=>Dt(l,()=>c()?u():a(),null)),qe(f)}else{const c=An(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}),Dt(d,a),l.appendChild(c),e.ref&&e.ref(c),qe(()=>l.removeChild(c))}},void 0,{render:!i}),s}function Ti(e,t){const s=W(e);return W(()=>{const n=s();switch(typeof n){case"function":return J(()=>n(t));case"string":const r=ai.has(n),a=b.context?Ei():An(n,r);return En(a,t,r),a}})}function Pi(e){const[,t]=cn(e,["component"]);return Ti(()=>e.component,t)}var _i=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()}},Sn=class{constructor(e){this.generateIdentifier=e,this.kv=new _i}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)}},xi=class extends Sn{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 vi(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 wi(e,t){const s=vi(e);if("find"in s)return s.find(t);const n=s;for(let r=0;r<n.length;r++){const a=n[r];if(t(a))return a}}function Ke(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function xt(e,t){return e.indexOf(t)!==-1}function xs(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var bi=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return wi(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Ci=e=>Object.prototype.toString.call(e).slice(8,-1),Tn=e=>typeof e>"u",Ii=e=>e===null,st=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Jt=e=>st(e)&&Object.keys(e).length===0,pe=e=>Array.isArray(e),Li=e=>typeof e=="string",Ni=e=>typeof e=="number"&&!isNaN(e),Di=e=>typeof e=="boolean",Gi=e=>e instanceof RegExp,nt=e=>e instanceof Map,rt=e=>e instanceof Set,Pn=e=>Ci(e)==="Symbol",ki=e=>e instanceof Date&&!isNaN(e.valueOf()),ji=e=>e instanceof Error,vs=e=>typeof e=="number"&&isNaN(e),Oi=e=>Di(e)||Ii(e)||Tn(e)||Ni(e)||Li(e)||Pn(e),Ri=e=>typeof e=="bigint",Ui=e=>e===1/0||e===-1/0,Mi=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),Bi=e=>e instanceof URL,_n=e=>e.replace(/\./g,"\\."),Vt=e=>e.map(String).map(_n).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 ae(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var xn=[ae(Tn,"undefined",()=>null,()=>{}),ae(Ri,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),ae(ki,"Date",e=>e.toISOString(),e=>new Date(e)),ae(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}),ae(Gi,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),ae(rt,"set",e=>[...e.values()],e=>new Set(e)),ae(nt,"map",e=>[...e.entries()],e=>new Map(e)),ae(e=>vs(e)||Ui(e),"number",e=>vs(e)?"NaN":e>0?"Infinity":"-Infinity",Number),ae(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),ae(Bi,"URL",e=>e.toString(),e=>new URL(e))];function Bt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var vn=Bt((e,t)=>Pn(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}),Fi=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),wn=Bt(Mi,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=Fi[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function bn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Cn=Bt(bn,(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)}),In=Bt((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,s)=>{const n=s.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),qi=[Cn,vn,In,wn],ws=(e,t)=>{const s=xs(qi,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=xs(xn,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Ln={};xn.forEach(e=>{Ln[e.annotation]=e});var Ki=(e,t,s)=>{if(pe(t))switch(t[0]){case"symbol":return vn.untransform(e,t,s);case"class":return Cn.untransform(e,t,s);case"custom":return In.untransform(e,t,s);case"typed-array":return wn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=Ln[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},we=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const s=e.keys();for(;t>0;)s.next(),t--;return s.next().value};function Nn(e){if(xt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(xt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(xt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var Hi=(e,t)=>{Nn(t);for(let s=0;s<t.length;s++){const n=t[s];if(rt(e))e=we(e,+n);else if(nt(e)){const r=+n,a=+t[++s]==0?"key":"value",i=we(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},Xt=(e,t,s)=>{if(Nn(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(pe(n)){const l=+i;n=n[l]}else if(st(n))n=n[i];else if(rt(n)){const l=+i;n=we(n,l)}else if(nt(n)){if(a===t.length-2)break;const c=+i,d=+t[++a]==0?"key":"value",f=we(n,c);switch(d){case"key":n=f;break;case"value":n=n.get(f);break}}}const r=t[t.length-1];if(pe(n)?n[+r]=s(n[+r]):st(n)&&(n[r]=s(n[r])),rt(n)){const a=we(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(nt(n)){const a=+t[t.length-2],i=we(n,a);switch(+r==0?"key":"value"){case"key":{const c=s(i);n.set(c,n.get(i)),c!==i&&n.delete(i);break}case"value":{n.set(i,s(n.get(i)));break}}}return e};function Zt(e,t,s=[]){if(!e)return;if(!pe(e)){Ke(e,(a,i)=>Zt(a,t,[...s,...Ze(i)]));return}const[n,r]=e;r&&Ke(r,(a,i)=>{Zt(a,t,[...s,...Ze(i)])}),t(n,s)}function Vi(e,t,s){return Zt(t,(n,r)=>{e=Xt(e,r,a=>Ki(a,n,s))}),e}function Qi(e,t){function s(n,r){const a=Hi(e,Ze(r));n.map(Ze).forEach(i=>{e=Xt(e,i,()=>a)})}if(pe(t)){const[n,r]=t;n.forEach(a=>{e=Xt(e,Ze(a),()=>e)}),r&&Ke(r,s)}else Ke(t,s);return e}var zi=(e,t)=>st(e)||pe(e)||nt(e)||rt(e)||bn(e,t);function Wi(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function $i(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(Vt):s[Vt(a)]=i.map(Vt)}),n?Jt(s)?[n]:[n,s]:Jt(s)?void 0:s}var Dn=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=Oi(e);if(!l){Wi(e,r,t);const E=i.get(e);if(E)return n?{transformedValue:null}:E}if(!zi(e,s)){const E=ws(e,s),S=E?{transformedValue:E.value,annotations:[E.type]}:{transformedValue:e};return l||i.set(e,S),S}if(xt(a,e))return{transformedValue:null};const c=ws(e,s),d=(c==null?void 0:c.value)??e,f=pe(d)?[]:{},u={};Ke(d,(E,S)=>{if(S==="__proto__"||S==="constructor"||S==="prototype")throw new Error(`Detected property ${S}. This is a prototype pollution risk, please remove it from your object.`);const P=Dn(E,t,s,n,[...r,S],[...a,e],i);f[S]=P.transformedValue,pe(P.annotations)?u[S]=P.annotations:st(P.annotations)&&Ke(P.annotations,(_,A)=>{u[_n(S)+"."+A]=_})});const g=Jt(u)?{transformedValue:f,annotations:c?[c.type]:void 0}:{transformedValue:f,annotations:c?[c.type,u]:u};return l||i.set(e,g),g};function Gn(e){return Object.prototype.toString.call(e).slice(8,-1)}function bs(e){return Gn(e)==="Array"}function Yi(e){if(Gn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function Ji(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 es(e,t={}){if(bs(e))return e.map(r=>es(r,t));if(!Yi(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(bs(t.props)&&!t.props.includes(a))return r;const i=e[a],l=es(i,t);return Ji(r,a,l,e,t.nonenumerable),r},{})}var B=class{constructor({dedupe:e=!1}={}){this.classRegistry=new xi,this.symbolRegistry=new Sn(t=>t.description??""),this.customTransformerRegistry=new bi,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=Dn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=$i(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=es(t);return s!=null&&s.values&&(n=Vi(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=Qi(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 kn=B.serialize,Xi=B.stringify;function Zi(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function eo(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function to({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function so({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function no(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var ro=(e,t=!1)=>{const{json:s}=kn(e);return JSON.stringify(s,null,t?2:void 0)},At=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,ao=(e,t)=>e.queryHash.localeCompare(t.queryHash),jn=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,io=(e,t)=>At(e)===At(t)?jn(e,t):At(e)>At(t)?1:-1,oo={status:io,"query hash":ao,"last updated":jn},St=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,On=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,lo=(e,t)=>St(e)===St(t)?On(e,t):St(e)>St(t)?1:-1,co={status:lo,"last updated":On},uo=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),fo=()=>{const[e,t]=K("dark");return tn(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)");t(s.matches?"dark":"light");const n=r=>{t(r.matches?"dark":"light")};s.addEventListener("change",n),qe(()=>s.removeEventListener("change",n))}),e},Ye=(e,t,s)=>{if(t.length===0)return s;if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.set(t[0],s),n;const[r,...a]=t;return n.set(r,Ye(n.get(r),a,s)),n}if(e instanceof Set){const n=Ye(Array.from(e),t,s);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=Ye(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]=Ye(n[r],a,s),n}return e},Je=(e,t)=>{if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.delete(t[0]),s;const[n,...r]=t;return s.set(n,Je(s.get(n),r)),s}if(e instanceof Set){const s=Je(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((a,i)=>i.toString()!==t[0]);const[n,...r]=t;return s[n]=Je(s[n],r),s}if(e instanceof Object){const s={...e};if(t.length===1)return delete s[t[0]],s;const[n,...r]=t;return s[n]=Je(s[n],r),s}return e},Rn=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const n=document.createElement("style"),r=document.createTextNode("");n.appendChild(r),n.id="_goober",n.setAttribute("nonce",e),t?t.appendChild(n):document.head.appendChild(n)},be,at,it,ot,Pe,lt,Ce,Ie,Le,Ne,De,ct,Ge,ut,Ls,ho=(Ls=class{constructor(e){R(this,be);R(this,at);R(this,it);R(this,ot);R(this,Pe,!1);R(this,lt);R(this,Ce);R(this,Ie);R(this,Le);R(this,Ne);R(this,De);R(this,ct);R(this,Ge);R(this,ut);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:f,hideDisabledQueries:u}=e;k(this,be,K(t)),k(this,it,s),k(this,ot,n),k(this,at,r),k(this,lt,d),k(this,Ce,f),k(this,Ie,K(a)),k(this,Le,K(i)),k(this,Ne,K(l)),k(this,De,K(c)),k(this,ct,K(u))}setButtonPosition(e){v(this,Ie)[1](e)}setPosition(e){v(this,Le)[1](e)}setInitialIsOpen(e){v(this,Ne)[1](e)}setErrorTypes(e){v(this,De)[1](e)}setClient(e){v(this,be)[1](e)}mount(e){if(v(this,Pe))throw new Error("Devtools is already mounted");const t=fn(()=>{const s=this,[n]=v(this,Ie),[r]=v(this,Le),[a]=v(this,Ne),[i]=v(this,De),[l]=v(this,ct),[c]=v(this,be);let d;return v(this,Ge)?d=v(this,Ge):(d=un(()=>Promise.resolve().then(()=>require("./NCMVHL6D-C-L7-X3f.cjs"))),k(this,Ge,d)),Rn(v(this,lt),v(this,Ce)),fs(d,hs({get queryFlavor(){return v(s,it)},get version(){return v(s,ot)},get onlineManager(){return v(s,at)},get shadowDOMTarget(){return v(s,Ce)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()}}))},e);k(this,Pe,!0),k(this,ut,t)}unmount(){var e;if(!v(this,Pe))throw new Error("Devtools is not mounted");(e=v(this,ut))==null||e.call(this),k(this,Pe,!1)}},be=new WeakMap,at=new WeakMap,it=new WeakMap,ot=new WeakMap,Pe=new WeakMap,lt=new WeakMap,Ce=new WeakMap,Ie=new WeakMap,Le=new WeakMap,Ne=new WeakMap,De=new WeakMap,ct=new WeakMap,Ge=new WeakMap,ut=new WeakMap,Ls),ke,dt,ft,ht,_e,gt,je,Oe,Re,Ue,Me,mt,Be,Fe,Et,Ns,go=(Ns=class{constructor(e){R(this,ke);R(this,dt);R(this,ft);R(this,ht);R(this,_e,!1);R(this,gt);R(this,je);R(this,Oe);R(this,Re);R(this,Ue);R(this,Me);R(this,mt);R(this,Be);R(this,Fe);R(this,Et);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:f,onClose:u,hideDisabledQueries:g}=e;k(this,ke,K(t)),k(this,ft,s),k(this,ht,n),k(this,dt,r),k(this,gt,d),k(this,je,f),k(this,Oe,K(a)),k(this,Re,K(i)),k(this,Ue,K(l)),k(this,Me,K(c)),k(this,mt,K(g)),k(this,Be,K(u))}setButtonPosition(e){v(this,Oe)[1](e)}setPosition(e){v(this,Re)[1](e)}setInitialIsOpen(e){v(this,Ue)[1](e)}setErrorTypes(e){v(this,Me)[1](e)}setClient(e){v(this,ke)[1](e)}setOnClose(e){v(this,Be)[1](()=>e)}mount(e){if(v(this,_e))throw new Error("Devtools is already mounted");const t=fn(()=>{const s=this,[n]=v(this,Oe),[r]=v(this,Re),[a]=v(this,Ue),[i]=v(this,Me),[l]=v(this,mt),[c]=v(this,ke),[d]=v(this,Be);let f;return v(this,Fe)?f=v(this,Fe):(f=un(()=>Promise.resolve().then(()=>require("./2AITGKQY-D4uLyw6-.cjs"))),k(this,Fe,f)),Rn(v(this,gt),v(this,je)),fs(f,hs({get queryFlavor(){return v(s,ft)},get version(){return v(s,ht)},get onlineManager(){return v(s,dt)},get shadowDOMTarget(){return v(s,je)}},{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);k(this,_e,!0),k(this,Et,t)}unmount(){var e;if(!v(this,_e))throw new Error("Devtools is not mounted");(e=v(this,Et))==null||e.call(this),k(this,_e,!1)}},ke=new WeakMap,dt=new WeakMap,ft=new WeakMap,ht=new WeakMap,_e=new WeakMap,gt=new WeakMap,je=new WeakMap,Oe=new WeakMap,Re=new WeakMap,Ue=new WeakMap,Me=new WeakMap,mt=new WeakMap,Be=new WeakMap,Fe=new WeakMap,Et=new WeakMap,Ns);function mo(e){const t=T.useQueryClient(e.client),s=z.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}=e,[f]=z.useState(new ho({client:t,queryFlavor:"React Query",version:"5",onlineManager:T.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}));return z.useEffect(()=>{f.setClient(t)},[t,f]),z.useEffect(()=>{n&&f.setButtonPosition(n)},[n,f]),z.useEffect(()=>{r&&f.setPosition(r)},[r,f]),z.useEffect(()=>{f.setInitialIsOpen(a||!1)},[a,f]),z.useEffect(()=>{f.setErrorTypes(i||[])},[i,f]),z.useEffect(()=>(s.current&&f.mount(s.current),()=>{f.unmount()}),[f]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function Eo(e){const t=T.useQueryClient(e.client),s=z.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i}=e,[l]=z.useState(new go({client:t,queryFlavor:"React Query",version:"5",onlineManager:T.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 Cs=process.env.NODE_ENV!=="development"?function(){return null}:mo;process.env.NODE_ENV;const Un=H.atom(""),po=()=>{C.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),C.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},yo=()=>{const e=j(),t=L();return T.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},Ao=()=>{const{data:e}=Z(),{data:t}=ue(),{data:s}=Ae(),n=j(),r=L(),a=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]);return T.useMutation({mutationFn:async({block:i})=>r(n,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:i,lang:(t==null?void 0:t.lang)||a,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:a,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id}}})})},Mn=()=>{const[,e]=te();return h.useCallback((t,s)=>{const r=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});r&&a.set("lang",r),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),s==null||s()},[e])},Bn=()=>{const e=Mn();return h.useCallback(({pageId:t})=>{e(t)},[e])},So=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-DL2nAqUC.cjs"))),To=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-C3H1ZPb-.cjs"))),Po=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-0GrdOHO_.cjs"))),_o=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-TTKtpSUi.cjs")));po();$n.loadWebBlocks();C.registerChaiTopBar(na);va();C.registerChaiMediaManager(So);C.registerChaiSaveToLibrary(To);const xo={role:"",permissions:null},Is=e=>{ga(),fr();const t=Ot(),{data:s=xo,isFetching:n}=Qs(),{data:r,isFetching:a}=de(),{data:i,isFetching:l}=yo(),{data:c,isFetching:d}=Ae(),f=n||a||l||d,[u]=te(),g=u.get("page"),{data:E}=Z(),{data:S,isFetching:P}=oa(),{blocks:_}=ia(S),{lockingStatus:A,pageLock:x}=Se(),{data:G,isFetching:q}=Hs(),V=ra(),{onSave:O}=ma(),{mutateAsync:oe}=Ao(),{getPartialBlocks:le,getPartialBlockBlocks:U}=Ea(),{mutateAsync:I}=wr(),{mutateAsync:N}=Vs(),$=Bn(),[Q,ne]=h.useState(!1),Qe=h.useRef([]),he=h.useMemo(()=>p.get(c,"theme",{})||{},[c]),ze=p.isEmpty(A)&&(x==null?void 0:x.status)==="editing",Te=(x==null?void 0:x.status)==="checking",gs=P||Te||q;Qe.current=_;const[Kn]=H.useAtom(Un);h.useEffect(()=>{const re=()=>{document.hidden?ne(!0):ne(!1)};return window.addEventListener("visibilitychange",re),()=>window.removeEventListener("visibilitychange",re)},[]);const Hn=h.useMemo(()=>{const re={};return s&&(re.permissions=p.get(s,"permissions",null),re.role=p.get(s,"role","user")),re},[s]),Vn=h.useCallback(async(re,pt)=>await I({pageType:re,query:pt}),[I]);return o.jsxs(o.Fragment,{children:[gs&&o.jsx(ls,{className:f?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(w.Loader,{className:`animate-spin text-primary ${f?"h-6 w-6":"h-5 w-5"}`})}),Kn&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:o.jsx(w.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(_o,{})}),o.jsx(C.ChaiBuilderEditor,{gotoPage:$,collections:i??[],getBlockAsyncProps:oe,pageExternalData:G,themePresets:e.themePresets??[],pageId:E==null?void 0:E.id,loading:P,fallbackLang:t,languages:(c==null?void 0:c.languages)||[],brandingOptions:(c==null?void 0:c.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!Q&&ze&&(e.autoSave??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:U,getPartialBlocks:le,blocks:P?[]:_,theme:p.cloneDeep(he),pageTypes:r,searchPageTypeItems:Vn,askAiCallBack:V,onSave:async({blocks:re,theme:pt,needTranslations:Qn})=>{if(!g)return!0;Qe.current=re;const ms=[...re];return await O({page:g,blocks:ms,needTranslations:Qn}),Qe.current=ms,p.isEqual(pt,he)||await N({settings:{theme:pt}}),!0},themePanelComponent:Po,...Hn}),o.jsxs("div",{children:[o.jsx(mr,{isFetchingPage:gs}),o.jsx(Er,{})]})]})},vo=new T.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),wo=e=>{const[,t]=Gt(),[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(Is,{...e}),o.jsx(Cs,{})]}):o.jsxs(T.QueryClientProvider,{client:vo,children:[o.jsx(Is,{...e}),o.jsx(Cs,{})]}):o.jsx("div",{})},bo=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-D_iF9Sm3.cjs")));function Fn({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=z.useState(!1);return o.jsxs(m.Popover,{open:r,onOpenChange:a,children:[o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsx(m.PopoverTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,disabled:n,children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:o.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),o.jsx(m.TooltipContent,{children:"Add field"})]}),r&&o.jsx(z.Suspense,{children:o.jsx(bo,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const Co=()=>{const{savePageAsync:e}=C.useSavePage(),t=T.useQueryClient();return h.useCallback(async()=>{await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t])},Io=()=>{const e=T.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},Lo=()=>{const e=j(),t=L(),{data:s}=ue(),n=T.useQueryClient();return T.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")}})},No=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-DL2nAqUC.cjs"))),Do=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const[i,l]=h.useState(!1),c=()=>{a||l(!0)},d=()=>{l(!1)},f=E=>{const S=Array.isArray(E)?E[0]:E;S!=null&&S.url&&s(p.pick(S,["url","id"])),l(!1)},u=()=>{s({url:"",id:""})},g=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return o.jsxs("div",{className:`w-full ${n}`,children:[t?o.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[g?o.jsx("div",{className:"flex h-12 items-center bg-gray-100 px-4",children:o.jsx("p",{className:"text-xs text-gray-500",children:t})}):o.jsx("img",{onClick:c,src:t,alt:"Selected image",className:"h-auto max-h-[100px] w-full bg-gray-100 object-contain"}),o.jsxs("div",{className:"absolute right-2 top-2 flex gap-2",children:[o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:u,disabled:a,children:g?o.jsx(w.X,{className:"h-4 w-4"}):o.jsx(w.Trash2,{className:"h-4 w-4"})}),!g&&o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:c,disabled:a,children:o.jsx(w.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:c,children:o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx(w.ImageIcon,{className:"h-10 w-10 text-gray-400"}),o.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),o.jsx(m.Dialog,{open:i,onOpenChange:l,children:o.jsxs(m.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[o.jsxs(m.DialogHeader,{className:"hidden border-b px-4 py-2",children:[o.jsx(m.DialogTitle,{children:"Select Image"}),o.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:d,children:o.jsx(w.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(h.Suspense,{children:o.jsx(No,{close:d,onSelect:f,mode:"image",assetId:e})})})]})})]})},Go=h.createContext(null),Qt={didCatch:!1,error:null};class qn extends h.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Qt}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(Qt)}}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&&ko(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(Qt)}}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(Go.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},l)}}function ko(){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 jo=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ts=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,f;if(c!==void 0){const u=n.substring(0,c).split(`
2
- `);d=u.length,f=u[u.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:d,column:f,position:c}}}},Oo=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(jo(i),"g");n=n.replace(l,r)}),n},Ro=(e,t)=>{if(!e)return"";let s=JSON.stringify(e,null,2);const n=/{{([^{}]+)}}/g;let r;for(;(r=n.exec(s))!==null;){const a=r[1],i=p.get(t,a,null);s=s.replace(r[0],i)}return s},Uo=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-hCiviuBf.cjs"))),Mo=({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:f})=>{const[u,g]=h.useState("edit"),[E,S]=h.useState(null),[P,_]=h.useState(""),A=h.useRef(null),[x]=Gt(),G=i==="jsonLD"&&p.get(x,"features.sharedJsonLD",!1),q=i==="jsonLD"&&!d&&!!f;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const V=U=>{if(n)return;const I=U.target.value;t(I)},O=U=>{if(U.key==="Tab"){U.preventDefault();const I=U.currentTarget,N=I.selectionStart,$=I.selectionEnd;if(N!==$){const ne=e.substring(N,$).split(`
3
- `);if(U.shiftKey){const he=ne.map(Te=>Te.startsWith(" ")?Te.substring(2):Te).join(`
4
- `),ze=e.substring(0,N)+he+e.substring($);t(ze),setTimeout(()=>{I.selectionStart=N,I.selectionEnd=N+he.length},0)}else{const he=ne.map(Te=>` ${Te}`).join(`
5
- `),ze=e.substring(0,N)+he+e.substring($);t(ze),setTimeout(()=>{I.selectionStart=N,I.selectionEnd=N+he.length},0)}}else{const Q=e.substring(0,N)+" "+e.substring($);t(Q),setTimeout(()=>{I.selectionStart=I.selectionEnd=N+2},0)}}};h.useEffect(()=>{const U=ts(e);if(U.isValid)if(S(null),U.parsed){const I=Ro(U.parsed,l);_(I)}else _("");else S(U.error),_("")},[e,l]);const oe=()=>{const U=ts(e);if(U.isValid&&U.parsed){const I=Oo(U.parsed,U.placeholders);t(I)}},le=()=>{E!=null&&E.position&&A.current&&(A.current.focus(),A.current.setSelectionRange(E.position,E.position+1))};return o.jsx(qn,{fallback:o.jsx("div",{children:"Some error"}),children:o.jsx("div",{className:"space-y-2",children:o.jsxs(m.Tabs,{value:u,onValueChange:g,className:"w-full",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs(m.TabsList,{className:"w-max",children:[o.jsxs(m.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[o.jsx(w.Code,{className:"h-4 w-4"}),o.jsx("span",{children:"Edit"})]}),o.jsxs(m.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||E!==null||q,children:[o.jsx(w.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),G&&o.jsxs(m.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||E!==null,children:[o.jsx(w.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),q?null:u==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(Fn,{dataType:"value",data:l??{},onSelect:U=>c&&c(U,i)})})]}),o.jsxs(m.TabsContent,{value:"edit",className:"relative mt-0",children:[!q&&u==="edit"&&o.jsx(Rt,{content:"Format JSON",side:"right",showTooltip:!s&&!E,children:o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",onClick:oe,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||E!==null,children:o.jsx(w.FileCode2,{})})}),q?o.jsx("div",{className:"flex h-40 items-center justify-center rounded-md bg-black/20",children:o.jsxs("div",{className:"flex max-w-[400px] flex-col items-center gap-2 rounded-md bg-white p-4 shadow-lg",children:[o.jsx("div",{className:"max-w-xl text-center text-xs text-gray-500",children:"JSON-LD for is not added for selected language. JSON LD will be used from default language."}),o.jsxs(m.Button,{type:"button",variant:"default",size:"sm",onClick:f,children:[o.jsx(w.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(m.Textarea,{ref:A,id:i,name:i,className:`rounded-md border border-input text-xs ${E?"border-red-500":""}`,onChange:V,onKeyDown:O,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),E&&o.jsxs(m.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(w.AlertTriangle,{className:"h-4 w-4"}),o.jsxs(m.AlertDescription,{className:"flex flex-col",children:[o.jsx("span",{className:"font-medium",children:"Invalid JSON"}),o.jsx("span",{className:"text-sm",children:E.message}),E.line&&E.column&&o.jsxs("span",{className:"text-sm",children:["Error at line ",E.line,", column ",E.column]}),o.jsx(m.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:le,children:"Show position"})]})]})]}),o.jsxs(m.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(m.Textarea,{rows:a,value:P,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."})]}),G&&o.jsx(m.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(Uo,{})})})]})})})},Bo=()=>{const e=ee("getAccessToken");return{getAccessToken:h.useCallback(async()=>{try{return await e()}catch{return""}},[e])}},Fo=()=>{const{logout:e}=He(),{getAccessToken:t}=Bo();return h.useCallback(async({url:s,method:n="GET",body:r={},headers:a={}})=>{const i=await t();if(!i)throw new Error("No auth token");if(!s)throw new Error("URL is required");try{const l=await fetch(s,{method:n,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`,...a},body:JSON.stringify(r)});if(l.status===401)return console.log("Session expired",l),await e(),window.location.reload(),null;if(l.status===400)throw new Error((await l.json()).error);return await l.json()}catch(l){throw console.log("Something went wrong",l),l}},[e,t])};if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=cs;exports.ACTIONS=y;exports.BlurContainer=ls;exports.CONTENT=Y;exports.ChaiBuilderPages=wo;exports.ChaiBuilderPagesRealtime=ks;exports.Dynamic=Pi;exports.ErrorBoundary=qn;exports.For=za;exports.ImagePicker=Do;exports.Index=Wa;exports.LANGUAGES=We;exports.LanguageSwitcher=Bs;exports.Match=Ja;exports.NestedPathSelector=Fn;exports.PAGES_PERMISSIONS=se;exports.PageActionsDropdown=qs;exports.PermissionChecker=Tt;exports.Portal=Si;exports.Show=$a;exports.SmartJsonInput=Mo;exports.Switch=Ya;exports.Tooltip=Rt;exports.addEventListener=mn;exports.addNewLangAtom=jt;exports.batch=La;exports.className=gn;exports.clearDelegatedEvents=ui;exports.convertRemToPixels=uo;exports.createComponent=fs;exports.createComputed=en;exports.createContext=ja;exports.createEffect=us;exports.createMemo=W;exports.createRenderEffect=Ee;exports.createRoot=me;exports.createSignal=K;exports.createUniqueId=Qa;exports.delegateEvents=hn;exports.deleteNestedDataByPath=Je;exports.displayValue=ro;exports.getMutationStatusColor=so;exports.getPreferredColorScheme=fo;exports.getQueryStatusColor=to;exports.getQueryStatusColorByLabel=no;exports.getQueryStatusLabel=Zi;exports.getSidedProp=eo;exports.insert=Dt;exports.memo=oi;exports.mergeProps=hs;exports.mutationSortFns=co;exports.navigateToPage=as;exports.on=Na;exports.onCleanup=qe;exports.onMount=tn;exports.parseJSONWithPlaceholders=ts;exports.previewUrlAtom=Un;exports.serialize=kn;exports.setAttribute=Nt;exports.sortFns=oo;exports.splitProps=cn;exports.spread=En;exports.stringify=Xi;exports.template=ci;exports.throwConfetti=Pt;exports.untrack=J;exports.updateNestedDataByPath=Ye;exports.use=pn;exports.useActivePage=ue;exports.useAddGlobalSchema=la;exports.useApiUrl=j;exports.useApplySchemaToAllPages=fa;exports.useAssetsApiUrl=Xn;exports.useBuilderPageData=Hs;exports.useChaiAuth=He;exports.useChaiFetch=Fo;exports.useChaiUserInfo=Rs;exports.useChangePage=Mn;exports.useChangeSlug=Gr;exports.useClearAll=Io;exports.useContext=Oa;exports.useCreatePage=br;exports.useCurrentPage=Z;exports.useDeleteGlobalSchema=ua;exports.useDeletePage=Ir;exports.useDynamicPageSelector=Os;exports.useFallbackLang=Ot;exports.useFetch=L;exports.useGotoPage=Bn;exports.useIsLanguagePageCreated=ss;exports.useLanguagePages=ye;exports.useMarkAsTemplate=Nr;exports.usePageEditInfo=kt;exports.usePageLockRequestTakeOver=Us;exports.usePageType=Fs;exports.usePageTypes=de;exports.usePageUserMapping=dr;exports.usePagesProps=Gt;exports.usePublishPages=os;exports.useReloadPage=Co;exports.useRemoveSchemaFromAllPages=ha;exports.useSearchParams=te;exports.useTogglePageGlobalSchema=da;exports.useTransition=ka;exports.useUnmarkAsTemplate=Dr;exports.useUnpublishPage=Lr;exports.useUpdateActivePageMetadata=Lo;exports.useUpdateGlobalSchema=ca;exports.useUpdatePage=Cr;exports.useUpdateWebsiteSettings=Vs;exports.useUserRoleAndPermissions=Qs;exports.useWebsiteLanguagePages=pr;exports.useWebsitePages=is;exports.useWebsiteSetting=Ae;