@chaibuilder/pages 0.16.13 → 0.16.15

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 (104) hide show
  1. package/dist/{2AITGKQY-D1mM4eEh.js → 2AITGKQY-2rt9M99C.js} +5 -5
  2. package/dist/{2AITGKQY-AK2WgbeT.cjs → 2AITGKQY-Cs6RBSPQ.cjs} +1 -1
  3. package/dist/{NCMVHL6D-DItDf9IY.cjs → NCMVHL6D-CsC6nsSQ.cjs} +1 -1
  4. package/dist/{NCMVHL6D-BeRsWdGV.js → NCMVHL6D-vUfYKc6i.js} +2 -2
  5. package/dist/{ZDWCUMSJ-COSBY-at.cjs → ZDWCUMSJ-B2OZjsr6.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-D6caRaY7.js → ZDWCUMSJ-CzEWKlEU.js} +1 -1
  7. package/dist/active-in-another-tab-B0N5S-Bh.js +34 -0
  8. package/dist/active-in-another-tab-BK3cZf-x.cjs +1 -0
  9. package/dist/{add-new-language-page-CQcFi0Tp.cjs → add-new-language-page-Dt1j-8Zg.cjs} +1 -1
  10. package/dist/{add-new-language-page-nnaUe-qk.js → add-new-language-page-YlqcCdlK.js} +20 -20
  11. package/dist/{add-new-page-DxObnvo_.cjs → add-new-page-DqhQUQBz.cjs} +1 -1
  12. package/dist/{add-new-page-Ba1fq6LH.js → add-new-page-aYomeid4.js} +1 -1
  13. package/dist/ai-panel-content-C6cH9rrC.js +123 -0
  14. package/dist/ai-panel-content-MOZmNIKP.cjs +1 -0
  15. package/dist/ai-panel-default-lang-BZHkFsox.js +317 -0
  16. package/dist/ai-panel-default-lang-DOk_Q0IO.cjs +3 -0
  17. package/dist/{ai-panel-other-lang-B4euTuod.js → ai-panel-other-lang-D2A46FTg.js} +10 -9
  18. package/dist/ai-panel-other-lang-qHrdvAMa.cjs +1 -0
  19. package/dist/ai-prompt-input-BZSjjNJd.cjs +1 -0
  20. package/dist/ai-prompt-input-C6gDvvLQ.js +1071 -0
  21. package/dist/{ai-translation-prompt-Ip7w2_Ey.cjs → ai-translation-prompt-BqXo2CLp.cjs} +1 -1
  22. package/dist/{ai-translation-prompt-CVuPbgXw.js → ai-translation-prompt-DTR0wbGt.js} +1 -1
  23. package/dist/continue-editing-in-this-client-C3T6Jzhi.cjs +1 -0
  24. package/dist/continue-editing-in-this-client-D2S1yCOM.js +24 -0
  25. package/dist/delete-page-BF1k60U2.js +70 -0
  26. package/dist/delete-page-x0DWKzsR.cjs +1 -0
  27. package/dist/{digital-asset-manager-CIMo79Di.cjs → digital-asset-manager-BmlFt2T_.cjs} +1 -1
  28. package/dist/{digital-asset-manager-SAFNO_mx.js → digital-asset-manager-C8udwDBW.js} +1 -1
  29. package/dist/{duplicate-page-CXK2HcxD.cjs → duplicate-page-Dt_QZkTk.cjs} +1 -1
  30. package/dist/{duplicate-page-5SwLvmkX.js → duplicate-page-u_6vUVo1.js} +7 -7
  31. package/dist/{dynamic-page-selector-Crd3y4Hk.cjs → dynamic-page-selector-Cgs_Y_Kl.cjs} +1 -1
  32. package/dist/{dynamic-page-selector-DfcuTqRN.js → dynamic-page-selector-DxBHmglP.js} +1 -1
  33. package/dist/index-BeWL6Sj6.cjs +5 -0
  34. package/dist/index-DI2Rwk5v.js +4820 -0
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.d.ts +1 -34
  37. package/dist/index.js +21 -22
  38. package/dist/{json-diff-viewer-D34kDA_c.cjs → json-diff-viewer-D2g0Yab2.cjs} +1 -1
  39. package/dist/{json-diff-viewer-CDwpbuag.js → json-diff-viewer-QdUwk7yF.js} +6 -6
  40. package/dist/{lang-panel-CUIeO5bb.js → lang-panel-B8OD0GiA.js} +24 -24
  41. package/dist/{lang-panel-CaFrYllL.cjs → lang-panel-M2Zb01lF.cjs} +1 -1
  42. package/dist/{mark-as-template-D0dLQaIB.js → mark-as-template-CJ1mlxYT.js} +7 -7
  43. package/dist/{mark-as-template-v182tmN6.cjs → mark-as-template-DONU52b1.cjs} +1 -1
  44. package/dist/{no-language-page-content-Bk4fEx_p.cjs → no-language-page-content-DD9Ok2Ku.cjs} +1 -1
  45. package/dist/{no-language-page-content-ByRFD_qA.js → no-language-page-content-Dtm37LTJ.js} +1 -1
  46. package/dist/no-language-page-dialog-D3dvenZ7.cjs +1 -0
  47. package/dist/no-language-page-dialog-Dj_z2_hF.js +10 -0
  48. package/dist/{page-creator-Bh0IUGR3.js → page-creator-DIMFISo4.js} +52 -52
  49. package/dist/{page-creator-BnvaGZVI.cjs → page-creator-DTC66ujU.cjs} +1 -1
  50. package/dist/page-lock-CI6BYvF_.cjs +1 -0
  51. package/dist/page-lock-DUlNr3os.js +30 -0
  52. package/dist/page-locked-dialog-BKwULMV7.js +133 -0
  53. package/dist/page-locked-dialog-DorIbva0.cjs +1 -0
  54. package/dist/page-manager-new-lNVrLOJp.cjs +1 -0
  55. package/dist/page-manager-new-znvqI9_L.js +354 -0
  56. package/dist/{page-manager-search-and-filter-BETHSa3y.js → page-manager-search-and-filter-C-_w7N27.js} +1 -1
  57. package/dist/{page-manager-search-and-filter-hyUIHOD_.cjs → page-manager-search-and-filter-pe0q0qnZ.cjs} +1 -1
  58. package/dist/{page-revisions-content-BCMjvZRZ.cjs → page-revisions-content-Caaj5TEI.cjs} +1 -1
  59. package/dist/{page-revisions-content-VWthKL7O.js → page-revisions-content-CyLjyxNU.js} +16 -16
  60. package/dist/pages.css +1 -1
  61. package/dist/publish-pages-content-Bih1W9C4.js +178 -0
  62. package/dist/publish-pages-content-D5beVcQI.cjs +1 -0
  63. package/dist/{save-to-lib-YYBxY7MV.js → save-to-lib-BwpkJcT2.js} +1 -1
  64. package/dist/{save-to-lib-CtGpDkC6.cjs → save-to-lib-DPAERsi4.cjs} +1 -1
  65. package/dist/{selected-block-display-DdW-DWF1.js → selected-block-display-GXSf3y2s.js} +1 -1
  66. package/dist/{selected-block-display-BEbuJn0l.cjs → selected-block-display-s99Y91qI.cjs} +1 -1
  67. package/dist/{seo-panel-CqJDhbj-.js → seo-panel-BurZA566.js} +61 -61
  68. package/dist/{seo-panel-B9P7fXjo.cjs → seo-panel-BxUfalVy.cjs} +1 -1
  69. package/dist/server.cjs +1 -1
  70. package/dist/server.js +39 -39
  71. package/dist/{shared-json-ld-CyxmC9y5.cjs → shared-json-ld-BYAdrPeC.cjs} +1 -1
  72. package/dist/{shared-json-ld-DxEPILj_.js → shared-json-ld-DHWdJvQd.js} +39 -39
  73. package/dist/{slug-input-RNiSrU3p.cjs → slug-input-CR2B1kDJ.cjs} +1 -1
  74. package/dist/{slug-input-j5z5ZQn9.js → slug-input-Z_ny7bgX.js} +1 -1
  75. package/dist/take-over-request-CnEpToCM.cjs +1 -0
  76. package/dist/take-over-request-DF2JsIes.js +63 -0
  77. package/dist/{theme-panel-footer-DD2yalfG.js → theme-panel-footer-5mxFeEua.js} +4 -4
  78. package/dist/{theme-panel-footer-CCsiDIVl.cjs → theme-panel-footer-C2CjHoBu.cjs} +1 -1
  79. package/dist/{unmark-as-template-DXjLbqOM.cjs → unmark-as-template-Dn90g1eh.cjs} +1 -1
  80. package/dist/{unmark-as-template-B2hKhAHn.js → unmark-as-template-JRRUYTOY.js} +1 -1
  81. package/dist/{unpublish-page-BdJScWMX.cjs → unpublish-page-C3C_rTRd.cjs} +1 -1
  82. package/dist/{unpublish-page-BvB1PGSz.js → unpublish-page-FZ8rbi7u.js} +9 -9
  83. package/dist/{web-preview-CwVpkcwU.js → web-preview-CGBKG162.js} +1 -1
  84. package/dist/{web-preview-BI4jd0O7.cjs → web-preview-NdxC92Fk.cjs} +1 -1
  85. package/package.json +3 -3
  86. package/dist/ai-panel-content-B2AgBWqo.cjs +0 -1
  87. package/dist/ai-panel-content-M1UnzG_f.js +0 -54
  88. package/dist/ai-panel-default-lang-CHOFEwmV.js +0 -313
  89. package/dist/ai-panel-default-lang-sy6vkQJh.cjs +0 -3
  90. package/dist/ai-panel-other-lang-BwjSDD3L.cjs +0 -1
  91. package/dist/ai-prompt-input-B_NRADBT.js +0 -988
  92. package/dist/ai-prompt-input-DcyVXcLG.cjs +0 -1
  93. package/dist/delete-page-CbY8q5M3.cjs +0 -1
  94. package/dist/delete-page-SX9X35nA.js +0 -40
  95. package/dist/index-Bz7smSC0.cjs +0 -5
  96. package/dist/index-EnM7J19_.js +0 -4960
  97. package/dist/page-lock-request-C2b1kqyA.cjs +0 -1
  98. package/dist/page-lock-request-CaNqxfD6.js +0 -75
  99. package/dist/page-locked-by-dialog--WLDdkw9.js +0 -68
  100. package/dist/page-locked-by-dialog-90ElC8aG.cjs +0 -1
  101. package/dist/page-manager-new-Bo4-zwfW.js +0 -354
  102. package/dist/page-manager-new-SNRQn7Az.cjs +0 -1
  103. package/dist/publish-pages-content-6N7aEcM1.js +0 -178
  104. package/dist/publish-pages-content-CaBwfekc.cjs +0 -1
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("./index-Bz7smSC0.cjs"),C=require("@chaibuilder/sdk"),i=require("@chaibuilder/sdk/ui"),n=require("lucide-react"),x=require("react"),N=({userId:d})=>{const{data:r}=l.useChaiUserInfo(d);return(r==null?void 0:r.name)||"Unknown"},f=({isChecking:d,lockingStatus:r,onContinue:j})=>{const{t:s}=C.useTranslation(),[u,h]=x.useState(!1),c=r==="page_is_active_in_other_tab",a=(r==null?void 0:r.length)>0,{pageLock:t,acceptTakeOver:o,rejectTakeOver:m}=l.usePageLockRequestTakeOver(),g=()=>{h(!0),a||c?j():o(),setTimeout(()=>{h(!1)},3e3)};return x.useEffect(()=>{(t==null?void 0:t.requestedBy)==="ANOTHER_TAB"&&o()},[t,o]),(t==null?void 0:t.requestedBy)==="ANOTHER_TAB"?null:d?e.jsx(l.BlurContainer,{children:e.jsx(n.Loader,{className:"h-5 w-5 animate-spin text-primary"})}):e.jsx(l.BlurContainer,{children:e.jsxs(i.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(i.CardHeader,{className:"space-y-1",children:e.jsxs(i.CardTitle,{className:"flex items-center gap-2 text-xl font-medium",children:[u?e.jsx(n.Loader,{className:"h-6 w-6 animate-spin text-gray-500"}):c?e.jsx(n.TableIcon,{className:"h-6 w-6 text-green-500"}):a?e.jsx(n.CheckCircle,{className:"h-6 w-6 text-green-500"}):e.jsx(n.Target,{className:"h-6 w-6 text-green-500"}),s(c?"Page is active in other tab":a?"You can edit the page now.":"Page take over request")]})}),e.jsx(i.CardContent,{className:"grid gap-4",children:e.jsx("div",{children:c?e.jsxs("p",{children:[s("You are already editing this page in another tab. To continue editing here, click on"),' "',s("Continue editing here"),'".']}):a?e.jsx("p",{children:s("This page is released by other user you can continue editing now.")}):e.jsxs("p",{children:[e.jsxs("b",{children:[" ",e.jsx(N,{userId:t==null?void 0:t.requestedBy})]})," ",s("has requested to take over this page."),e.jsx("br",{})," ",s("If you accept, your unsaved changes will be saved.")]})})}),e.jsxs(i.CardFooter,{className:"flex items-center justify-end gap-2",children:[e.jsx(i.Button,{disabled:u,onClick:g,className:a?"":"bg-green-500 hover:bg-green-600",children:c?e.jsxs(e.Fragment,{children:[e.jsx(n.Edit,{className:"h-5 w-5"})," ",s("Continue editing here")]}):a?e.jsxs(e.Fragment,{children:[e.jsx(n.Edit,{className:"h-5 w-5"})," ",s("Continue to edit")]}):e.jsxs(e.Fragment,{children:[e.jsx(n.Check,{className:"h-5 w-5"})," ",s("Accept")]})}),!a&&e.jsxs(i.Button,{variant:"outline",onClick:m,children:[e.jsx(n.X,{className:"h-5 w-5"})," ",s("Reject")]})]})]})})};exports.default=f;
@@ -1,75 +0,0 @@
1
- import { jsx as e, jsxs as r, Fragment as o } from "react/jsx-runtime";
2
- import { aj as w, ak as T, B as m } from "./index-EnM7J19_.js";
3
- import { useTranslation as x } from "@chaibuilder/sdk";
4
- import { Card as b, CardHeader as v, CardTitle as y, CardContent as B, CardFooter as q, Button as u } from "@chaibuilder/sdk/ui";
5
- import { Loader as f, TableIcon as _, CheckCircle as j, Target as A, Edit as g, Check as I, X as O } from "lucide-react";
6
- import { useState as k, useEffect as E } from "react";
7
- const R = ({ userId: c }) => {
8
- const { data: n } = w(c);
9
- return (n == null ? void 0 : n.name) || "Unknown";
10
- }, X = ({
11
- isChecking: c,
12
- lockingStatus: n,
13
- onContinue: p
14
- }) => {
15
- const { t } = x(), [d, h] = k(!1), i = n === "page_is_active_in_other_tab", s = (n == null ? void 0 : n.length) > 0, { pageLock: a, acceptTakeOver: l, rejectTakeOver: C } = T(), N = () => {
16
- h(!0), s || i ? p() : l(), setTimeout(() => {
17
- h(!1);
18
- }, 3e3);
19
- };
20
- return E(() => {
21
- (a == null ? void 0 : a.requestedBy) === "ANOTHER_TAB" && l();
22
- }, [a, l]), (a == null ? void 0 : a.requestedBy) === "ANOTHER_TAB" ? null : c ? /* @__PURE__ */ e(m, { children: /* @__PURE__ */ e(f, { className: "h-5 w-5 animate-spin text-primary" }) }) : /* @__PURE__ */ e(m, { children: /* @__PURE__ */ r(b, { className: "mx-auto w-full max-w-md", children: [
23
- /* @__PURE__ */ e(v, { className: "space-y-1", children: /* @__PURE__ */ r(y, { className: "flex items-center gap-2 text-xl font-medium", children: [
24
- d ? /* @__PURE__ */ e(f, { className: "h-6 w-6 animate-spin text-gray-500" }) : i ? /* @__PURE__ */ e(_, { className: "h-6 w-6 text-green-500" }) : s ? /* @__PURE__ */ e(j, { className: "h-6 w-6 text-green-500" }) : /* @__PURE__ */ e(A, { className: "h-6 w-6 text-green-500" }),
25
- t(i ? "Page is active in other tab" : s ? "You can edit the page now." : "Page take over request")
26
- ] }) }),
27
- /* @__PURE__ */ e(B, { className: "grid gap-4", children: /* @__PURE__ */ e("div", { children: i ? /* @__PURE__ */ r("p", { children: [
28
- t("You are already editing this page in another tab. To continue editing here, click on"),
29
- ' "',
30
- t("Continue editing here"),
31
- '".'
32
- ] }) : s ? /* @__PURE__ */ e("p", { children: t("This page is released by other user you can continue editing now.") }) : /* @__PURE__ */ r("p", { children: [
33
- /* @__PURE__ */ r("b", { children: [
34
- " ",
35
- /* @__PURE__ */ e(R, { userId: a == null ? void 0 : a.requestedBy })
36
- ] }),
37
- " ",
38
- t("has requested to take over this page."),
39
- /* @__PURE__ */ e("br", {}),
40
- " ",
41
- t("If you accept, your unsaved changes will be saved.")
42
- ] }) }) }),
43
- /* @__PURE__ */ r(q, { className: "flex items-center justify-end gap-2", children: [
44
- /* @__PURE__ */ e(
45
- u,
46
- {
47
- disabled: d,
48
- onClick: N,
49
- className: s ? "" : "bg-green-500 hover:bg-green-600",
50
- children: i ? /* @__PURE__ */ r(o, { children: [
51
- /* @__PURE__ */ e(g, { className: "h-5 w-5" }),
52
- " ",
53
- t("Continue editing here")
54
- ] }) : s ? /* @__PURE__ */ r(o, { children: [
55
- /* @__PURE__ */ e(g, { className: "h-5 w-5" }),
56
- " ",
57
- t("Continue to edit")
58
- ] }) : /* @__PURE__ */ r(o, { children: [
59
- /* @__PURE__ */ e(I, { className: "h-5 w-5" }),
60
- " ",
61
- t("Accept")
62
- ] })
63
- }
64
- ),
65
- !s && /* @__PURE__ */ r(u, { variant: "outline", onClick: C, children: [
66
- /* @__PURE__ */ e(O, { className: "h-5 w-5" }),
67
- " ",
68
- t("Reject")
69
- ] })
70
- ] })
71
- ] }) });
72
- };
73
- export {
74
- X as default
75
- };
@@ -1,68 +0,0 @@
1
- import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
- import { useTranslation as f } from "@chaibuilder/sdk";
3
- import { Card as x, CardHeader as h, CardTitle as N, CardContent as g, Skeleton as d, CardFooter as b, Button as w } from "@chaibuilder/sdk/ui";
4
- import { formatDistanceToNow as k } from "date-fns";
5
- import { LockKeyhole as y, UserIcon as v, Info as C, KeyIcon as T } from "lucide-react";
6
- import { useState as B } from "react";
7
- import { B as D } from "./index-EnM7J19_.js";
8
- function O({
9
- avatar: l,
10
- name: s,
11
- email: o,
12
- lastSaved: i,
13
- onTakeOver: u,
14
- isRequestRejected: n,
15
- isFetchingUserInfo: a
16
- }) {
17
- const { t } = f(), [c, m] = B(!1), p = () => {
18
- m(!0), setTimeout(() => {
19
- m(!1);
20
- }, 15e3), u();
21
- };
22
- return /* @__PURE__ */ e(D, { children: /* @__PURE__ */ r(x, { className: "mx-auto w-full max-w-md", children: [
23
- /* @__PURE__ */ e(h, { className: "space-y-1", children: /* @__PURE__ */ r(N, { className: "flex items-center gap-2 text-xl", children: [
24
- /* @__PURE__ */ e(y, { className: "h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500" }),
25
- t("Page is locked for editing")
26
- ] }) }),
27
- /* @__PURE__ */ e(g, { className: "w-md grid w-full pt-2", children: /* @__PURE__ */ r("div", { children: [
28
- /* @__PURE__ */ r("div", { className: "relative mx-auto flex w-96 items-center space-x-4 rounded-md border border-green-500 px-2 pb-2 pt-4", children: [
29
- /* @__PURE__ */ e("div", { className: "absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white", children: t("Locked By") }),
30
- l && !a ? /* @__PURE__ */ e("img", { src: l, alt: s, className: "h-14 w-14 rounded-full border border-gray-300" }) : /* @__PURE__ */ e(v, { className: "h-14 w-14 flex-shrink-0 rounded-full bg-gradient-to-br from-purple-400 to-pink-500 p-2 text-white" }),
31
- /* @__PURE__ */ r("div", { className: a ? "space-y-1.5" : "space-y-0", children: [
32
- a ? /* @__PURE__ */ e(d, { className: "h-4 w-40 rounded" }) : /* @__PURE__ */ e("span", { className: "truncate font-medium text-black", children: s }),
33
- o && !a ? /* @__PURE__ */ e("p", { className: "truncate text-sm text-muted-foreground", children: o }) : /* @__PURE__ */ e(d, { className: "h-4 w-60 rounded" }),
34
- i && !a ? /* @__PURE__ */ r("p", { className: "text-sm text-muted-foreground", children: [
35
- t("Last saved"),
36
- ":",
37
- " ",
38
- k(new Date(i), {
39
- addSuffix: !0
40
- })
41
- ] }) : /* @__PURE__ */ e(d, { className: "h-4 w-40 rounded" })
42
- ] })
43
- ] }),
44
- /* @__PURE__ */ e("div", { className: "mt-4 text-sm", children: /* @__PURE__ */ r("p", { className: "py-4 text-center text-gray-600", children: [
45
- t("This page is currently being edited by"),
46
- " ",
47
- /* @__PURE__ */ e("span", { className: "font-bold", children: s }),
48
- ".",
49
- /* @__PURE__ */ e("br", {}),
50
- /* @__PURE__ */ e("br", {}),
51
- " ",
52
- t("You can either wait until they finish editing or request to take over the page.")
53
- ] }) }),
54
- n && /* @__PURE__ */ r("div", { className: "mt-4 flex w-full items-center justify-center gap-x-2 rounded border border-red-500 bg-red-50 p-2 text-center font-medium text-red-500", children: [
55
- /* @__PURE__ */ e(C, { className: "h-5 w-5" }),
56
- " ",
57
- t("Page take over request is rejected")
58
- ] })
59
- ] }) }),
60
- /* @__PURE__ */ e(b, { children: /* @__PURE__ */ r(w, { disabled: c, onClick: p, className: "w-full", variant: "destructive", children: [
61
- /* @__PURE__ */ e(T, { className: "h-5 w-5" }),
62
- t(c ? "Page take is requested." : n ? "Request take over again" : "Request take over")
63
- ] }) })
64
- ] }) });
65
- }
66
- export {
67
- O as default
68
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),j=require("date-fns"),a=require("lucide-react"),p=require("react"),f=require("./index-Bz7smSC0.cjs");function g({avatar:l,name:d,email:n,lastSaved:c,onTakeOver:x,isRequestRejected:i,isFetchingUserInfo:r}){const{t:s}=h.useTranslation(),[o,u]=p.useState(!1),m=()=>{u(!0),setTimeout(()=>{u(!1)},15e3),x()};return e.jsx(f.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(a.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),s("Page is locked for editing")]})}),e.jsx(t.CardContent,{className:"w-md grid w-full pt-2",children:e.jsxs("div",{children:[e.jsxs("div",{className:"relative mx-auto flex w-96 items-center space-x-4 rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:s("Locked By")}),l&&!r?e.jsx("img",{src:l,alt:d,className:"h-14 w-14 rounded-full border border-gray-300"}):e.jsx(a.UserIcon,{className:"h-14 w-14 flex-shrink-0 rounded-full bg-gradient-to-br from-purple-400 to-pink-500 p-2 text-white"}),e.jsxs("div",{className:r?"space-y-1.5":"space-y-0",children:[r?e.jsx(t.Skeleton,{className:"h-4 w-40 rounded"}):e.jsx("span",{className:"truncate font-medium text-black",children:d}),n&&!r?e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:n}):e.jsx(t.Skeleton,{className:"h-4 w-60 rounded"}),c&&!r?e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s("Last saved"),":"," ",j.formatDistanceToNow(new Date(c),{addSuffix:!0})]}):e.jsx(t.Skeleton,{className:"h-4 w-40 rounded"})]})]}),e.jsx("div",{className:"mt-4 text-sm",children:e.jsxs("p",{className:"py-4 text-center text-gray-600",children:[s("This page is currently being edited by")," ",e.jsx("span",{className:"font-bold",children:d}),".",e.jsx("br",{}),e.jsx("br",{})," ",s("You can either wait until they finish editing or request to take over the page.")]})}),i&&e.jsxs("div",{className:"mt-4 flex w-full items-center justify-center gap-x-2 rounded border border-red-500 bg-red-50 p-2 text-center font-medium text-red-500",children:[e.jsx(a.Info,{className:"h-5 w-5"})," ",s("Page take over request is rejected")]})]})}),e.jsx(t.CardFooter,{children:e.jsxs(t.Button,{disabled:o,onClick:m,className:"w-full",variant:"destructive",children:[e.jsx(a.KeyIcon,{className:"h-5 w-5"}),s(o?"Page take is requested.":i?"Request take over again":"Request take over")]})})]})})}exports.default=g;
@@ -1,354 +0,0 @@
1
- import { jsxs as y, jsx as t, Fragment as O } from "react/jsx-runtime";
2
- import { au as be, f as ie, aj as ye, T as _, aD as ge, L as ke, h as Ne, b as we, i as ve, ap as Se, aE as Ae, aF as q } from "./index-EnM7J19_.js";
3
- import { u as K } from "./use-page-expand-manager-D6T75I11.js";
4
- import { compact as ce, filter as j, isEmpty as S, uniqBy as Le, keyBy as de, mapValues as Te, startCase as Ee, toLower as T, includes as R, find as M, get as Q, map as Ce } from "lodash-es";
5
- import { useTranslation as Ue, useLanguages as ae } from "@chaibuilder/sdk";
6
- import { useAtom as $e } from "jotai";
7
- import { NotepadText as Fe, MoreHorizontal as Me, Lock as je, Edit as ze, Plus as Be, ChevronRight as Ie, StarsIcon as Ge, Hash as De, File as ue } from "lucide-react";
8
- import { useMemo as V, lazy as E, useState as N, useCallback as le, useEffect as F, Suspense as L } from "react";
9
- const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
10
- j(e, (r) => {
11
- const s = T(n);
12
- return R(T((r == null ? void 0 : r.name) || ""), s) || R(T((r == null ? void 0 : r.slug) || ""), s);
13
- })
14
- ), Oe = (e, n) => {
15
- const r = /* @__PURE__ */ new Set(), s = de(e, "id");
16
- return n.forEach((o) => {
17
- let l = o;
18
- for (; l.parent && s[l.parent]; )
19
- r.add(l.parent), l = s[l.parent];
20
- }), Array.from(r).map((o) => s[o]);
21
- }, J = (e, n, r) => S(n) ? e : e.map((s) => {
22
- if (!r(s.pageType))
23
- return {
24
- ...s,
25
- shouldExpandOnSearch: !0,
26
- children: s.children ? J(s.children, n, r) : []
27
- };
28
- const o = s.children && s.children.some(
29
- (l) => R(T(l.name || ""), T(n)) || R(T(l.slug || ""), T(n))
30
- );
31
- return {
32
- ...s,
33
- shouldExpandOnSearch: o,
34
- children: s.children ? J(s.children, n, r) : []
35
- };
36
- }), Re = (e) => {
37
- if (!e || !e.length) return [];
38
- const n = {};
39
- e.forEach((s) => {
40
- n[s.id] = { ...s, children: [] };
41
- });
42
- const r = [];
43
- return Object.values(n).forEach((s) => {
44
- s.parent && n[s.parent] ? n[s.parent].children.push(s) : r.push(s);
45
- }), r;
46
- }, me = (e) => !e || !e.length ? [] : [...e].sort(
47
- (r, s) => (r.name || "").localeCompare(s.name || "")
48
- ).map((r) => ({
49
- ...r,
50
- children: r.children ? me(r.children) : []
51
- })), We = (e, n, r, s) => {
52
- if (!e || !e.length) return [];
53
- let o = e;
54
- if (r !== "all" && (o = ce(j(e, { pageType: r }))), S(n))
55
- o = oe(o, n);
56
- else {
57
- const u = oe(o, n), i = Oe(e, u);
58
- o = Le([...u, ...i], "id");
59
- }
60
- const l = me(Re(o)), f = J(l, n, s), g = j(f, (u) => s(u.pageType)).sort((u, i) => (u.name || "").localeCompare(i.name || "")), P = j(f, (u) => !s(u.pageType));
61
- let m = [];
62
- if (r === "all") {
63
- const u = de(P, "pageType");
64
- m = Object.values(
65
- Te(u, (i, x) => ({
66
- ...i,
67
- id: x,
68
- name: Ee(x),
69
- isPartialGroup: !0,
70
- children: f.filter((p) => p.pageType === x)
71
- }))
72
- );
73
- } else
74
- m = P.sort((u, i) => (u.name || "").localeCompare(i.name || ""));
75
- return [...g, ...m];
76
- }, He = ({ page: e }) => {
77
- var s, o;
78
- const { isExpanded: n, toggleExpanded: r } = K(e == null ? void 0 : e.id);
79
- return /* @__PURE__ */ t(
80
- "button",
81
- {
82
- onClick: (l) => {
83
- l.stopPropagation(), r();
84
- },
85
- disabled: !((s = e == null ? void 0 : e.children) != null && s.length),
86
- className: `flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(o = e == null ? void 0 : e.children) != null && o.length ? "hover:text-blue-400" : "opacity-0"}`,
87
- children: /* @__PURE__ */ t(
88
- Ie,
89
- {
90
- size: 12,
91
- className: `stroke-[4] transition-transform duration-200 ${n ? "rotate-90" : ""}`
92
- }
93
- )
94
- }
95
- );
96
- }, _e = ({ page: e, pageType: n }) => /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ t(Ge, { size: 12, className: "text-yellow-400" }) : n != null && n.icon ? /* @__PURE__ */ t(
97
- "div",
98
- {
99
- className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
100
- dangerouslySetInnerHTML: { __html: n.icon }
101
- }
102
- ) : n != null && n.hasSlug ? /* @__PURE__ */ t(ue, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(De, { size: 12, className: "stroke-[1] text-slate-500" }) }), qe = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), Qe = ({
103
- page: e,
104
- pageTypes: n,
105
- currentPage: r,
106
- onClickAction: s,
107
- languagePages: o,
108
- selectedLanguage: l,
109
- showUntranslatedPages: f
110
- }) => {
111
- const [g] = be(), P = ie(), m = r === e.id, u = !!e.isTemplate, i = V(() => M(n, { key: e.pageType }), [n, e.pageType]), x = g == null ? void 0 : g[e.id], { data: p } = ye(x), w = p ? p == null ? void 0 : p.name : null;
112
- let d = Q(o, e == null ? void 0 : e.id);
113
- d = Q(d, "lang") === l ? d : null;
114
- const A = l === P || !!d, C = (d == null ? void 0 : d.name) || (e == null ? void 0 : e.name) || "No name";
115
- let b = (d == null ? void 0 : d.slug) || (e == null ? void 0 : e.slug) || "";
116
- const z = b + (e != null && e.dynamic ? `/${i == null ? void 0 : i.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
117
- if (b.startsWith("/") && !f) {
118
- const c = b.split("/").pop();
119
- b = b.endsWith(c) && e.dynamic ? "" : `/${c}`;
120
- }
121
- const B = V(() => {
122
- const c = "flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]", I = `${m ? "border-primary/30 bg-primary/5" : "border-transparent hover:border-gray-200 hover:bg-gray-100"}`;
123
- return A ? `${c} ${I} ${w ? "opacity-60" : ""}` : `${c} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`;
124
- }, [A, m, w]);
125
- return /* @__PURE__ */ y("div", { className: "group relative", children: [
126
- /* @__PURE__ */ y(
127
- "div",
128
- {
129
- onClick: () => !e.isPartialGroup && A && s("select", e == null ? void 0 : e.id),
130
- className: B,
131
- children: [
132
- /* @__PURE__ */ t(He, { page: e }),
133
- !e.isPartialGroup && /* @__PURE__ */ t(qe, { isOnline: d ? d.online : e.online }),
134
- !e.isPartialGroup && /* @__PURE__ */ t(_e, { page: e, pageType: i }),
135
- /* @__PURE__ */ t(_, { content: C, side: "top", showTooltip: C.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: C }) }),
136
- (b || e.dynamic) && /* @__PURE__ */ t(_, { content: z, side: "top", showTooltip: !0, children: /* @__PURE__ */ y("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
137
- b,
138
- e.dynamic && (i == null ? void 0 : i.dynamicSlug) && /* @__PURE__ */ y("span", { className: "text-xs text-gray-500", children: [
139
- "/",
140
- i == null ? void 0 : i.dynamicSlug,
141
- e.dynamicSlugCustom
142
- ] })
143
- ] }) }),
144
- u && /* @__PURE__ */ t(_, { content: "Template", side: "top", children: /* @__PURE__ */ t("span", { className: "text-blue-500", children: /* @__PURE__ */ t(Fe, { size: 16 }) }) }),
145
- !e.isPartialGroup && A && !w ? /* @__PURE__ */ t("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ t(
146
- ge,
147
- {
148
- isLanguagePage: !!d,
149
- page: d || e,
150
- setDuplicatePage: (c) => s("duplicate", c),
151
- setAddEditPage: (c) => s("edit", d || c),
152
- setUnpublishPage: (c) => s("unpublish", c),
153
- setDeletePage: (c) => s("delete", d || c),
154
- setMarkAsTemplate: (c) => s("markAsTemplate", c),
155
- setUnmarkAsTemplate: (c) => s("unmarkAsTemplate", c),
156
- children: /* @__PURE__ */ t("div", { className: "m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white", children: /* @__PURE__ */ t(Me, { className: "h-4 w-4", onClick: (c) => c.stopPropagation() }) })
157
- }
158
- ) }) : w ? /* @__PURE__ */ t("span", { className: "duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500", children: /* @__PURE__ */ t(je, { className: "h-3.5 w-3.5 fill-red-200 text-red-500" }) }) : null
159
- ]
160
- }
161
- ),
162
- /* @__PURE__ */ t(O, { children: w && /* @__PURE__ */ y("button", { className: "absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100", children: [
163
- /* @__PURE__ */ t(ze, { size: 12, className: "stroke-[3]" }),
164
- " ",
165
- /* @__PURE__ */ t("span", { className: "font-medium", children: w }),
166
- " is editing this page"
167
- ] }) }),
168
- /* @__PURE__ */ t(O, { children: !A && !e.isPartialGroup && !w && /* @__PURE__ */ y(
169
- "button",
170
- {
171
- onClick: (c) => {
172
- c.stopPropagation(), s("addLanguagePage", { language: l, page: e });
173
- },
174
- className: "absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",
175
- children: [
176
- /* @__PURE__ */ t(Be, { size: 12, className: "stroke-[3]" }),
177
- " ",
178
- /* @__PURE__ */ y("span", { className: "text-[10px]", children: [
179
- "Add ",
180
- Q(ke, l),
181
- " Page"
182
- ] })
183
- ]
184
- }
185
- ) })
186
- ] });
187
- }, he = ({
188
- pages: e,
189
- tier: n,
190
- pageTypes: r,
191
- currentPage: s,
192
- onClickAction: o,
193
- languagePages: l,
194
- selectedLanguage: f,
195
- showUntranslatedPages: g
196
- }) => {
197
- const { expandedPages: P } = K();
198
- return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${n * 10}px` }, children: e.map((m) => /* @__PURE__ */ y(O, { children: [
199
- /* @__PURE__ */ t(
200
- Qe,
201
- {
202
- page: m,
203
- pageTypes: r,
204
- currentPage: s,
205
- onClickAction: o,
206
- languagePages: l,
207
- selectedLanguage: f,
208
- showUntranslatedPages: g
209
- }
210
- ),
211
- m.children && m.children.length > 0 && (P == null ? void 0 : P.includes(m.id)) && /* @__PURE__ */ t(
212
- he,
213
- {
214
- pages: m.children,
215
- tier: n + 1,
216
- pageTypes: r,
217
- currentPage: s,
218
- onClickAction: o,
219
- languagePages: l,
220
- selectedLanguage: f,
221
- showUntranslatedPages: g
222
- }
223
- )
224
- ] }, m.id)) });
225
- }, Ve = E(() => import("./page-manager-search-and-filter-BETHSa3y.js")), Je = E(() => import("./add-new-page-Ba1fq6LH.js")), Ke = E(() => import("./delete-page-SX9X35nA.js")), Xe = E(() => import("./duplicate-page-5SwLvmkX.js")), Ye = E(() => import("./mark-as-template-D0dLQaIB.js")), Ze = E(() => import("./unmark-as-template-B2hKhAHn.js")), et = E(() => import("./unpublish-page-BvB1PGSz.js")), ct = ({ close: e }) => {
226
- const { t: n } = Ue(), { languages: r, setSelectedLang: s } = ae(), { data: o } = Ne(), { data: l, isFetching: f } = we(), [g, P] = ve(), { updateForSelectedPage: m, expandPagesOnSearch: u } = K(null), i = ie(), x = g.get("page"), [p, w] = N(""), [d, A] = N(null), [C, b] = N(null), [z, B] = N(null), [c, I] = N(null), [U, W] = N(""), [X, Y] = N(null), [Z, ee] = N(null), [k, fe] = N(i), [Pe, xe] = N(!1), [, te] = $e(Se), G = Pe && k !== i, { data: $, isFetching: pe } = Ae(k), se = le(
227
- (h) => {
228
- var a;
229
- return (a = M(o, { key: h })) == null ? void 0 : a.hasSlug;
230
- },
231
- [o]
232
- ), v = V(() => l ? G ? j(l, (h) => !($ != null && $[h.id])) : We(l, p, U, se) : [], [l, se, p, U, $, G]);
233
- F(() => {
234
- s(i);
235
- }, [i, s]), F(() => {
236
- if (!S(U)) return;
237
- const h = sessionStorage.getItem("pageTypeFilter") || "all";
238
- !S(o) && h && (M(o, { key: h }) ? W(h) : W("all"));
239
- }, [o, U]), F(() => {
240
- if (x && !f && !M(l, { id: x })) {
241
- const a = M(l, { slug: "/" });
242
- if (a) {
243
- const D = new URLSearchParams({ page: a.id });
244
- q(D, P);
245
- } else
246
- q(new URLSearchParams({}), P, !0);
247
- }
248
- }, [l, x, f, P]), F(() => {
249
- x && !f && !S(v) && m(v, x);
250
- }, [x, f, v, m]), F(() => {
251
- !S(p) && !S(v) && u(v);
252
- }, [p, v, u]);
253
- const { setSelectedLang: H } = ae(), ne = le(
254
- (h) => {
255
- const a = new URLSearchParams({ page: h });
256
- k !== i ? (a.set("lang", k), H(k)) : H(""), q(a, P), e();
257
- },
258
- [e, P, H, k, i]
259
- ), re = (h, a) => {
260
- var D;
261
- if (a)
262
- switch (h) {
263
- case "add":
264
- b(a);
265
- break;
266
- case "select":
267
- ne(a);
268
- break;
269
- case "edit":
270
- k !== i ? te({
271
- edit: !0,
272
- id: a == null ? void 0 : a.id,
273
- primaryPage: a == null ? void 0 : a.primaryPage
274
- }) : b(a);
275
- break;
276
- case "delete":
277
- A(a);
278
- break;
279
- case "unpublish":
280
- B(a);
281
- break;
282
- case "markAsTemplate":
283
- I(a);
284
- break;
285
- case "unmarkAsTemplate":
286
- ee(a);
287
- break;
288
- case "duplicate":
289
- Y(a);
290
- break;
291
- case "addLanguagePage":
292
- te({
293
- edit: !1,
294
- primaryPage: ((D = a == null ? void 0 : a.page) == null ? void 0 : D.id) || "",
295
- preselectedLang: (a == null ? void 0 : a.language) || k
296
- });
297
- break;
298
- }
299
- };
300
- return /* @__PURE__ */ y(O, { children: [
301
- /* @__PURE__ */ y("div", { className: "flex h-full flex-col justify-between", children: [
302
- /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(
303
- Ve,
304
- {
305
- pages: v,
306
- search: p,
307
- setSearch: w,
308
- languages: [i, ...r],
309
- selectedLanguage: k,
310
- setSelectedLanguage: fe,
311
- selectedPageType: U,
312
- setSelectedPageType: W,
313
- onAddPage: (h) => re("add", h),
314
- showUntranslatedPages: G,
315
- setShowUntranslatedPages: xe
316
- }
317
- ) }),
318
- /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: f || pe ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ce([...Array(15).keys()], (h) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, h)) }) : S(v) ? /* @__PURE__ */ y("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
319
- /* @__PURE__ */ t(ue, { className: "h-6 w-6 stroke-[1]" }),
320
- n("Empty List!"),
321
- /* @__PURE__ */ t("span", { className: "font-light", children: n("Add new page to start") })
322
- ] }) : /* @__PURE__ */ t(
323
- he,
324
- {
325
- tier: 0,
326
- pages: v,
327
- pageTypes: o,
328
- currentPage: x || "",
329
- onClickAction: re,
330
- languagePages: $,
331
- selectedLanguage: k,
332
- showUntranslatedPages: G
333
- }
334
- ) })
335
- ] }),
336
- C && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(
337
- Je,
338
- {
339
- closePanel: e,
340
- editPage: ne,
341
- addEditPage: C,
342
- setAddEditPage: b
343
- }
344
- ) }),
345
- d && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Ke, { page: d, onClose: () => A(null) }) }),
346
- z && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(et, { page: z, onClose: () => B(null) }) }),
347
- c && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Ye, { page: c, onClose: () => I(null) }) }),
348
- Z && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Ze, { page: Z, onClose: () => ee(null) }) }),
349
- X && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Xe, { page: X, onClose: () => Y(null), closePanel: e }) })
350
- ] });
351
- };
352
- export {
353
- ct as default
354
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),x=require("./index-Bz7smSC0.cjs"),G=require("./use-page-expand-manager-2KjeYfVS.cjs"),n=require("lodash-es"),B=require("@chaibuilder/sdk"),te=require("jotai"),v=require("lucide-react"),l=require("react"),J=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const t=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),t)||n.includes(n.toLower((a==null?void 0:a.slug)||""),t)})),ne=(e,r)=>{const a=new Set,t=n.keyBy(e,"id");return r.forEach(c=>{let o=c;for(;o.parent&&t[o.parent];)a.add(o.parent),o=t[o.parent]}),Array.from(a).map(c=>t[c])},I=(e,r,a)=>n.isEmpty(r)?e:e.map(t=>{if(!a(t.pageType))return{...t,shouldExpandOnSearch:!0,children:t.children?I(t.children,r,a):[]};const c=t.children&&t.children.some(o=>n.includes(n.toLower(o.name||""),n.toLower(r))||n.includes(n.toLower(o.slug||""),n.toLower(r)));return{...t,shouldExpandOnSearch:c,children:t.children?I(t.children,r,a):[]}}),re=e=>{if(!e||!e.length)return[];const r={};e.forEach(t=>{r[t.id]={...t,children:[]}});const a=[];return Object.values(r).forEach(t=>{t.parent&&r[t.parent]?r[t.parent].children.push(t):a.push(t)}),a},K=e=>!e||!e.length?[]:[...e].sort((a,t)=>(a.name||"").localeCompare(t.name||"")).map(a=>({...a,children:a.children?K(a.children):[]})),ae=(e,r,a,t)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=J(c,r);else{const h=J(c,r),d=ne(e,h);c=n.uniqBy([...h,...d],"id")}const o=K(re(c)),y=I(o,r,t),S=n.filter(y,h=>t(h.pageType)).sort((h,d)=>(h.name||"").localeCompare(d.name||"")),p=n.filter(y,h=>!t(h.pageType));let f=[];if(a==="all"){const h=n.keyBy(p,"pageType");f=Object.values(n.mapValues(h,(d,j)=>({...d,id:j,name:n.startCase(j),isPartialGroup:!0,children:y.filter(b=>b.pageType===j)})))}else f=p.sort((h,d)=>(h.name||"").localeCompare(d.name||""));return[...S,...f]},le=({page:e})=>{var t,c;const{isExpanded:r,toggleExpanded:a}=G.usePageExpandManager(e==null?void 0:e.id);return s.jsx("button",{onClick:o=>{o.stopPropagation(),a()},disabled:!((t=e==null?void 0:e.children)!=null&&t.length),className:`flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:s.jsx(v.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},ie=({page:e,pageType:r})=>s.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?s.jsx(v.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?s.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:r.icon}}):r!=null&&r.hasSlug?s.jsx(v.File,{size:12,className:"stroke-[1] text-slate-500"}):s.jsx(v.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),oe=({isOnline:e})=>s.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),ce=({page:e,pageTypes:r,currentPage:a,onClickAction:t,languagePages:c,selectedLanguage:o,showUntranslatedPages:y})=>{const[S]=x.usePageUserMapping(),p=x.useFallbackLang(),f=a===e.id,h=!!e.isTemplate,d=l.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]),j=S==null?void 0:S[e.id],{data:b}=x.useChaiUserInfo(j),w=b?b==null?void 0:b.name:null;let m=n.get(c,e==null?void 0:e.id);m=n.get(m,"lang")===o?m:null;const E=o===p||!!m,L=(m==null?void 0:m.name)||(e==null?void 0:e.name)||"No name";let g=(m==null?void 0:m.slug)||(e==null?void 0:e.slug)||"";const C=g+(e!=null&&e.dynamic?`/${d==null?void 0:d.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(g.startsWith("/")&&!y){const u=g.split("/").pop();g=g.endsWith(u)&&e.dynamic?"":`/${u}`}const q=l.useMemo(()=>{const u="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",M=`${f?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${u} ${M} ${w?"opacity-60":""}`:`${u} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,f,w]);return s.jsxs("div",{className:"group relative",children:[s.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&t("select",e==null?void 0:e.id),className:q,children:[s.jsx(le,{page:e}),!e.isPartialGroup&&s.jsx(oe,{isOnline:m?m.online:e.online}),!e.isPartialGroup&&s.jsx(ie,{page:e,pageType:d}),s.jsx(x.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:s.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(g||e.dynamic)&&s.jsx(x.Tooltip,{content:C,side:"top",showTooltip:!0,children:s.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[g,e.dynamic&&(d==null?void 0:d.dynamicSlug)&&s.jsxs("span",{className:"text-xs text-gray-500",children:["/",d==null?void 0:d.dynamicSlug,e.dynamicSlugCustom]})]})}),h&&s.jsx(x.Tooltip,{content:"Template",side:"top",children:s.jsx("span",{className:"text-blue-500",children:s.jsx(v.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!w?s.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:s.jsx(x.PageActionsDropdown,{isLanguagePage:!!m,page:m||e,setDuplicatePage:u=>t("duplicate",u),setAddEditPage:u=>t("edit",m||u),setUnpublishPage:u=>t("unpublish",u),setDeletePage:u=>t("delete",m||u),setMarkAsTemplate:u=>t("markAsTemplate",u),setUnmarkAsTemplate:u=>t("unmarkAsTemplate",u),children:s.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:s.jsx(v.MoreHorizontal,{className:"h-4 w-4",onClick:u=>u.stopPropagation()})})})}):w?s.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:s.jsx(v.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]}),s.jsx(s.Fragment,{children:w&&s.jsxs("button",{className:"absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[s.jsx(v.Edit,{size:12,className:"stroke-[3]"})," ",s.jsx("span",{className:"font-medium",children:w})," is editing this page"]})}),s.jsx(s.Fragment,{children:!E&&!e.isPartialGroup&&!w&&s.jsxs("button",{onClick:u=>{u.stopPropagation(),t("addLanguagePage",{language:o,page:e})},className:"absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",children:[s.jsx(v.Plus,{size:12,className:"stroke-[3]"})," ",s.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(x.LANGUAGES,o)," Page"]})]})})]})},X=({pages:e,tier:r,pageTypes:a,currentPage:t,onClickAction:c,languagePages:o,selectedLanguage:y,showUntranslatedPages:S})=>{const{expandedPages:p}=G.usePageExpandManager();return s.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(f=>s.jsxs(s.Fragment,{children:[s.jsx(ce,{page:f,pageTypes:a,currentPage:t,onClickAction:c,languagePages:o,selectedLanguage:y,showUntranslatedPages:S}),f.children&&f.children.length>0&&(p==null?void 0:p.includes(f.id))&&s.jsx(X,{pages:f.children,tier:r+1,pageTypes:a,currentPage:t,onClickAction:c,languagePages:o,selectedLanguage:y,showUntranslatedPages:S})]},f.id))})},de=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-hyUIHOD_.cjs"))),ue=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-DxObnvo_.cjs"))),me=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-CbY8q5M3.cjs"))),he=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CXK2HcxD.cjs"))),xe=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-v182tmN6.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-DXjLbqOM.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BdJScWMX.cjs"))),ye=({close:e})=>{const{t:r}=B.useTranslation(),{languages:a,setSelectedLang:t}=B.useLanguages(),{data:c}=x.usePageTypes(),{data:o,isFetching:y}=x.useWebsitePages(),[S,p]=x.useSearchParams(),{updateForSelectedPage:f,expandPagesOnSearch:h}=G.usePageExpandManager(null),d=x.useFallbackLang(),j=S.get("page"),[b,w]=l.useState(""),[m,E]=l.useState(null),[L,g]=l.useState(null),[C,q]=l.useState(null),[u,M]=l.useState(null),[T,U]=l.useState(""),[O,R]=l.useState(null),[D,W]=l.useState(null),[k,Y]=l.useState(d),[Z,ee]=l.useState(!1),[,H]=te.useAtom(x.addNewLangAtom),z=Z&&k!==d,{data:A,isFetching:se}=x.useWebsiteLanguagePages(k),_=l.useCallback(P=>{var i;return(i=n.find(c,{key:P}))==null?void 0:i.hasSlug},[c]),N=l.useMemo(()=>o?z?n.filter(o,P=>!(A!=null&&A[P.id])):ae(o,b,T,_):[],[o,_,b,T,A,z]);l.useEffect(()=>{t(d)},[d,t]),l.useEffect(()=>{if(!n.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&P&&(n.find(c,{key:P})?U(P):U("all"))},[c,T]),l.useEffect(()=>{if(j&&!y&&!n.find(o,{id:j})){const i=n.find(o,{slug:"/"});if(i){const F=new URLSearchParams({page:i.id});x.navigateToPage(F,p)}else x.navigateToPage(new URLSearchParams({}),p,!0)}},[o,j,y,p]),l.useEffect(()=>{j&&!y&&!n.isEmpty(N)&&f(N,j)},[j,y,N,f]),l.useEffect(()=>{!n.isEmpty(b)&&!n.isEmpty(N)&&h(N)},[b,N,h]);const{setSelectedLang:$}=B.useLanguages(),Q=l.useCallback(P=>{const i=new URLSearchParams({page:P});k!==d?(i.set("lang",k),$(k)):$(""),x.navigateToPage(i,p),e()},[e,p,$,k,d]),V=(P,i)=>{var F;if(i)switch(P){case"add":g(i);break;case"select":Q(i);break;case"edit":k!==d?H({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):g(i);break;case"delete":E(i);break;case"unpublish":q(i);break;case"markAsTemplate":M(i);break;case"unmarkAsTemplate":W(i);break;case"duplicate":R(i);break;case"addLanguagePage":H({edit:!1,primaryPage:((F=i==null?void 0:i.page)==null?void 0:F.id)||"",preselectedLang:(i==null?void 0:i.language)||k});break}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex h-full flex-col justify-between",children:[s.jsx(l.Suspense,{children:s.jsx(de,{pages:N,search:b,setSearch:w,languages:[d,...a],selectedLanguage:k,setSelectedLanguage:Y,selectedPageType:T,setSelectedPageType:U,onAddPage:P=>V("add",P),showUntranslatedPages:z,setShowUntranslatedPages:ee})}),s.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:y||se?s.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],P=>s.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):n.isEmpty(N)?s.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[s.jsx(v.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),s.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):s.jsx(X,{tier:0,pages:N,pageTypes:c,currentPage:j||"",onClickAction:V,languagePages:A,selectedLanguage:k,showUntranslatedPages:z})})]}),L&&s.jsx(l.Suspense,{children:s.jsx(ue,{closePanel:e,editPage:Q,addEditPage:L,setAddEditPage:g})}),m&&s.jsx(l.Suspense,{children:s.jsx(me,{page:m,onClose:()=>E(null)})}),C&&s.jsx(l.Suspense,{children:s.jsx(Pe,{page:C,onClose:()=>q(null)})}),u&&s.jsx(l.Suspense,{children:s.jsx(xe,{page:u,onClose:()=>M(null)})}),D&&s.jsx(l.Suspense,{children:s.jsx(fe,{page:D,onClose:()=>W(null)})}),O&&s.jsx(l.Suspense,{children:s.jsx(he,{page:O,onClose:()=>R(null),closePanel:e})})]})};exports.default=ye;