@chaibuilder/sdk 4.0.0-beta.46 → 4.0.0-beta.48
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.
- package/dist/{2SSKDMRQ-B6pWs8Zk.js → 2SSKDMRQ-CLLNh3td.js} +2 -2
- package/dist/{2SSKDMRQ-B7Va8HeK.cjs → 2SSKDMRQ-DqwAKdGS.cjs} +1 -1
- package/dist/{AP7HFJJL-Xv13XYXE.cjs → AP7HFJJL-BA2SSB20.cjs} +1 -1
- package/dist/{AP7HFJJL-CNIRZpP-.js → AP7HFJJL-wgsmCJDJ.js} +1 -1
- package/dist/{IconPicker-CeAu6O-X.cjs → IconPicker-BQy4V5jA.cjs} +1 -1
- package/dist/{IconPicker-CGtjTiWr.js → IconPicker-DsT0ONLh.js} +1 -1
- package/dist/{WDYDFRGG-zZ8jN8rF.cjs → WDYDFRGG-DyEYv-Y5.cjs} +1 -1
- package/dist/{WDYDFRGG-5Lwxhw_-.js → WDYDFRGG-EEb06kwn.js} +2 -2
- package/dist/{actions-registery-BQ31lpix.cjs → actions-registery-2natwC9b.cjs} +1 -1
- package/dist/{actions-registery-B1VeX52Y.js → actions-registery-wRY05tEE.js} +1 -1
- package/dist/actions.cjs +1 -1
- package/dist/actions.js +2 -2
- package/dist/{active-in-another-tab-HtM97aRN.js → active-in-another-tab-DE2fn30l.js} +2 -2
- package/dist/{active-in-another-tab-C8FXtXk5.cjs → active-in-another-tab-p0hkvIFc.cjs} +1 -1
- package/dist/{add-new-language-page-x88_n8EW.js → add-new-language-page-CH7GtcqC.js} +3 -3
- package/dist/{add-new-language-page-gbvPI58M.cjs → add-new-language-page-f2wam593.cjs} +1 -1
- package/dist/{add-new-page-BMSePgKl.js → add-new-page-8d0Nn-zI.js} +2 -2
- package/dist/{add-new-page-CPB4yhqv.cjs → add-new-page-CV7A1XJQ.cjs} +1 -1
- package/dist/ai-panel-default-lang-BJLeTdw3.cjs +3 -0
- package/dist/ai-panel-default-lang-Dcm4e1o8.js +332 -0
- package/dist/ai-panel-other-lang-B48Y5C8z.js +147 -0
- package/dist/ai-panel-other-lang-Ch0RHXqZ.cjs +1 -0
- package/dist/ai-prompt-input-C1yoNntS.cjs +1 -0
- package/dist/{ai-prompt-input-bleYNRnH.js → ai-prompt-input-DhVfzVhy.js} +253 -258
- package/dist/{ai-translation-prompt-DvHdOZ6t.js → ai-translation-prompt-CUYVv2jG.js} +1 -1
- package/dist/{ai-translation-prompt-DGrNA2Od.cjs → ai-translation-prompt-mj26BpgQ.cjs} +1 -1
- package/dist/{change-password-modal-bce5bF3K.cjs → change-password-modal-DFupkIGx.cjs} +1 -1
- package/dist/{change-password-modal-C9afEHLW.js → change-password-modal-DiEQWZez.js} +10 -10
- package/dist/{code-editor-BVmpIZOt.cjs → code-editor-BiLiryYr.cjs} +1 -1
- package/dist/{code-editor-BfGHceIq.js → code-editor-CazbxsDv.js} +1 -1
- package/dist/{continue-editing-in-this-client-4bvChAL-.cjs → continue-editing-in-this-client-C3NoncEN.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-BFptv8tA.js → continue-editing-in-this-client-CpKDDW6u.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{css-import-modal-CEQccCmc.js → css-import-modal-BOQr_e6S.js} +1 -1
- package/dist/{css-import-modal-C9G5pbFd.cjs → css-import-modal-DFdZ471B.cjs} +1 -1
- package/dist/{delete-page-BOxoMgyl.cjs → delete-page-D8Vr-1aC.cjs} +1 -1
- package/dist/{delete-page-8h4dNP7d.js → delete-page-DIZhbU2t.js} +15 -15
- package/dist/{design-token-usage-CVPBTF21.js → design-token-usage-Co5Lj1HN.js} +1 -1
- package/dist/{design-token-usage-C5WfKLj-.cjs → design-token-usage-N5DLBdWf.cjs} +1 -1
- package/dist/{digital-asset-manager-83B0Y6L-.js → digital-asset-manager-CObQa_0R.js} +3 -3
- package/dist/{digital-asset-manager-JtBK07Ob.cjs → digital-asset-manager-uXP27Dou.cjs} +1 -1
- package/dist/{duplicate-page-DVqC24Rd.cjs → duplicate-page-DomSAvnp.cjs} +1 -1
- package/dist/{duplicate-page-DIa59iDe.js → duplicate-page-xpV-pRVU.js} +12 -12
- package/dist/{dynamic-page-selector-C9vYslOg.js → dynamic-page-selector-Bl5kYPWG.js} +2 -2
- package/dist/{dynamic-page-selector-YRCRqWlz.cjs → dynamic-page-selector-CYZv-SlK.cjs} +1 -1
- package/dist/{image-editor-CzxSXo-u.js → image-editor-CDFnNWAz.js} +1 -1
- package/dist/{image-editor-DQ8mQonU.cjs → image-editor-pOsT95KQ.cjs} +1 -1
- package/dist/{index-RwAuF_BE.js → index-BbkBlCE2.js} +297 -297
- package/dist/{index-DlTEPwjW.js → index-Cyz_Iww4.js} +828 -805
- package/dist/{index-DrzR7vXl.cjs → index-DonDtb8f.cjs} +8 -8
- package/dist/index-j-XsKW-V.cjs +5 -0
- package/dist/{json-diff-viewer-Bpsk0toO.cjs → json-diff-viewer-CoEViavL.cjs} +1 -1
- package/dist/{json-diff-viewer-is2P3TOV.js → json-diff-viewer-amjoEZ5K.js} +6 -6
- package/dist/{lang-panel-BI5OFsBY.cjs → lang-panel-BzWstLZ-.cjs} +1 -1
- package/dist/{lang-panel-DwiCJRs9.js → lang-panel-DPpIXFl4.js} +9 -9
- package/dist/{manage-design-tokens-D2Oz-jVp.js → manage-design-tokens-BVfEFOrN.js} +2 -2
- package/dist/{manage-design-tokens-sDi2Pdec.cjs → manage-design-tokens-CIiwBv2v.cjs} +1 -1
- package/dist/{manage-design-tokens-modal-ZR8PuhWC.js → manage-design-tokens-modal-CBOw_Dg6.js} +2 -2
- package/dist/{manage-design-tokens-modal-Gufu9nHL.cjs → manage-design-tokens-modal-m3D2luIa.cjs} +1 -1
- package/dist/{mark-as-template-muKJE1gk.cjs → mark-as-template-C2-S_aA2.cjs} +1 -1
- package/dist/{mark-as-template-C0Z2P_UF.js → mark-as-template-CQjchLk7.js} +2 -2
- package/dist/{models-D0RH2u4C.cjs → models-CQaC3EBW.cjs} +1 -1
- package/dist/{models-BCu-p_QK.js → models-DZ9C6CvE.js} +4 -5
- package/dist/{nested-path-selector-content-Ct80kFX-.js → nested-path-selector-content-BtsI3H0i.js} +1 -1
- package/dist/{nested-path-selector-content-DhNCvKp3.cjs → nested-path-selector-content-Dd3NzUE0.cjs} +1 -1
- package/dist/{no-language-page-content-BekrmPc5.js → no-language-page-content-BrDAjkdi.js} +2 -2
- package/dist/{no-language-page-content-zn3891M8.cjs → no-language-page-content-CggJC14_.cjs} +1 -1
- package/dist/{no-language-page-dialog-dHlAqLlU.js → no-language-page-dialog-DSbcLM8f.js} +2 -2
- package/dist/{no-language-page-dialog-wEXIlBuQ.cjs → no-language-page-dialog-Dkxdu99i.cjs} +1 -1
- package/dist/{page-creator-6L7ehzhL.js → page-creator-CR-FbJ7C.js} +33 -33
- package/dist/{page-creator-CN2phGn5.cjs → page-creator-DqKFL1sB.cjs} +1 -1
- package/dist/{page-lock-C--D8qD7.js → page-lock-CwzMBdD-.js} +2 -2
- package/dist/{page-lock-DllloCJE.cjs → page-lock-D4Anxwpy.cjs} +1 -1
- package/dist/{page-locked-dialog-BD8LHbdC.js → page-locked-dialog-Dv_unUwx.js} +11 -11
- package/dist/{page-locked-dialog-DzB8p0wl.cjs → page-locked-dialog-UrTgnXd6.cjs} +1 -1
- package/dist/{page-manager-new-uFcGaZZY.js → page-manager-new-DpCTazS0.js} +42 -42
- package/dist/{page-manager-new-DyjhsvPx.cjs → page-manager-new-DuqhyqMY.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-DK883UmG.js → page-manager-search-and-filter-B6F-ZvdQ.js} +87 -80
- package/dist/page-manager-search-and-filter-Yt0pjK_r.cjs +1 -0
- package/dist/{page-revisions-content-Bi2ehMnj.cjs → page-revisions-content-C2VMkAt4.cjs} +1 -1
- package/dist/{page-revisions-content-D3rIJj9X.js → page-revisions-content-CUPsMEVU.js} +16 -16
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +60 -1
- package/dist/pages.js +19 -19
- package/dist/{publish-pages-content-BQUHNRCX.cjs → publish-pages-content-BrjDksNY.cjs} +1 -1
- package/dist/{publish-pages-content-ByPf4lvE.js → publish-pages-content-CK0ahL2t.js} +32 -32
- package/dist/{rte-widget-modal-Tj_pS3ql.js → rte-widget-modal-DgEF73WC.js} +1 -1
- package/dist/{rte-widget-modal-BwE5wIZa.cjs → rte-widget-modal-Dktetdg4.cjs} +1 -1
- package/dist/{save-to-lib-CcUqS0s1.js → save-to-lib-Bs6-wr2u.js} +50 -50
- package/dist/{save-to-lib-Cyeqcelv.cjs → save-to-lib-CuVYPtm-.cjs} +1 -1
- package/dist/{selected-block-display-Benbb_OW.cjs → selected-block-display-BCcwnFzJ.cjs} +1 -1
- package/dist/{selected-block-display-C6LxDm0H.js → selected-block-display-D-lzXUfE.js} +2 -2
- package/dist/{seo-panel-1U9Q0Ato.js → seo-panel-By-TlhHK.js} +25 -25
- package/dist/{seo-panel-CCuvQpwV.cjs → seo-panel-DTqsu3I0.cjs} +1 -1
- package/dist/{shared-json-ld-DbzUITto.js → shared-json-ld-CMCwFEI0.js} +26 -26
- package/dist/{shared-json-ld-bj77fq_b.cjs → shared-json-ld-C_vaAxgT.cjs} +1 -1
- package/dist/{slug-input-BvIplRdd.cjs → slug-input-DCmvuN69.cjs} +1 -1
- package/dist/{slug-input-P-CLfUrw.js → slug-input-bhZSv9VS.js} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.js +1 -1
- package/dist/{take-over-request-R3HRgShm.cjs → take-over-request-BGvKpN5m.cjs} +1 -1
- package/dist/{take-over-request-Bwj_2nPR.js → take-over-request-f0dbfkLe.js} +5 -5
- package/dist/{translation-warning-modal-BdkToZwn.js → translation-warning-modal-D0-WNJnG.js} +1 -1
- package/dist/{translation-warning-modal-Bc2i-0YG.cjs → translation-warning-modal-_0YmCcU8.cjs} +1 -1
- package/dist/{unmark-as-template-BG882c_S.cjs → unmark-as-template-BE1BO8Z0.cjs} +1 -1
- package/dist/{unmark-as-template-DHDMooLZ.js → unmark-as-template-WE3WJ-RJ.js} +2 -2
- package/dist/{unpublish-page-C4e_gIX8.js → unpublish-page-B4A-GQEz.js} +8 -8
- package/dist/{unpublish-page-DudJ1znF.cjs → unpublish-page-DrZnWLVM.cjs} +1 -1
- package/dist/{unpublished-partials-modal-p_0N6V23.js → unpublished-partials-modal-CGK-4WJ3.js} +1 -1
- package/dist/{unpublished-partials-modal-i1oOnrgA.cjs → unpublished-partials-modal-KFXm1fG4.cjs} +1 -1
- package/dist/{web-preview-BA08d7DN.js → web-preview-BSmef-RL.js} +1 -1
- package/dist/{web-preview-MG0HZxgA.cjs → web-preview-ClV1a6hl.cjs} +1 -1
- package/package.json +1 -1
- package/dist/ai-panel-default-lang-DKGh1pbz.cjs +0 -3
- package/dist/ai-panel-default-lang-Dav6FRUY.js +0 -317
- package/dist/ai-panel-other-lang-CdFx2x23.js +0 -132
- package/dist/ai-panel-other-lang-DdDn2I8h.cjs +0 -1
- package/dist/ai-prompt-input-B8SFfk6N.cjs +0 -1
- package/dist/index-DXBHjFwY.cjs +0 -5
- package/dist/page-manager-search-and-filter-zfR5i_GU.cjs +0 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import { J as _, K as w, M as A, O as S, Q as K, R as F, U, V, W as I } from "./index-
|
|
3
|
-
import { B as
|
|
4
|
-
import {
|
|
2
|
+
import { J as _, K as w, M as A, O as S, Q as K, R as F, U, V, W as I } from "./index-BbkBlCE2.js";
|
|
3
|
+
import { B as p } from "./register-chai-top-bar-D6GjnauV.js";
|
|
4
|
+
import { ap as Q, an as q, a as P, ao as j, b as B, B as D, E as a, P as J } from "./index-Cyz_Iww4.js";
|
|
5
5
|
import { LockKeyhole as L, UserIcon as G, AlertCircleIcon as H, X as z, Edit as W, ShieldAlert as v } from "lucide-react";
|
|
6
|
-
import { useState as
|
|
6
|
+
import { useState as f, useRef as X, useEffect as Y, startTransition as Z } from "react";
|
|
7
7
|
import { useTranslation as $ } from "react-i18next";
|
|
8
8
|
const ie = () => {
|
|
9
|
-
const
|
|
9
|
+
const d = Q(), x = q(), { setPageStatus: T } = P(), { data: r, isFetching: k } = j((d == null ? void 0 : d.userId) || ""), { pageLockMeta: l, setPageLockMeta: E } = B(), { t: s } = $(), [o, i] = f(""), [n, g] = f({}), [N, b] = f(!1), c = X(null);
|
|
10
10
|
Y(() => {
|
|
11
11
|
l != null && l.type && (c.current && clearTimeout(c.current), Z(() => {
|
|
12
12
|
g(l), E({}), i("");
|
|
13
13
|
}));
|
|
14
14
|
}, [l, E]);
|
|
15
15
|
const R = () => {
|
|
16
|
-
|
|
16
|
+
o !== a.TAKE_OVER_REQUEST && (i(a.TAKE_OVER_REQUEST), x(a.TAKE_OVER_REQUEST), c.current = setTimeout(() => i(""), 2e4));
|
|
17
17
|
}, C = () => {
|
|
18
|
-
|
|
18
|
+
o !== a.FORCE_TAKE_OVER_REQUEST && (i(a.FORCE_TAKE_OVER_REQUEST), x(a.FORCE_TAKE_OVER_REQUEST), T(J.CHECKING), c.current = setTimeout(() => i(""), 2e4));
|
|
19
19
|
}, O = () => {
|
|
20
20
|
g({}), c.current && clearTimeout(c.current), i("");
|
|
21
|
-
}, m = k ? "Loading..." : (r == null ? void 0 : r.name) || "Current editor", u =
|
|
21
|
+
}, m = k ? "Loading..." : (r == null ? void 0 : r.name) || "Current editor", u = o === a.TAKE_OVER_REQUEST, h = o === a.FORCE_TAKE_OVER_REQUEST;
|
|
22
22
|
return /* @__PURE__ */ e(D, { children: /* @__PURE__ */ t(_, { className: "mx-auto w-full max-w-md", children: [
|
|
23
23
|
/* @__PURE__ */ e(w, { className: "space-y-1 border-b pb-3", children: /* @__PURE__ */ t(A, { className: "flex items-center gap-2 text-xl", children: [
|
|
24
24
|
/* @__PURE__ */ e(L, { className: "h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500" }),
|
|
@@ -50,7 +50,7 @@ const ie = () => {
|
|
|
50
50
|
(n == null ? void 0 : n.type) === a.TAKE_OVER_REJECTED ? " rejected your take over request." : " forcefully took over this page."
|
|
51
51
|
] })
|
|
52
52
|
] }),
|
|
53
|
-
/* @__PURE__ */ e(
|
|
53
|
+
/* @__PURE__ */ e(p, { size: "icon", variant: "ghost", onClick: O, className: "flex-shrink-0", children: /* @__PURE__ */ e(z, { className: "h-4 w-4" }) })
|
|
54
54
|
] }) })
|
|
55
55
|
] }),
|
|
56
56
|
/* @__PURE__ */ e(K, { className: "flex flex-col gap-3 border-t pt-3", children: /* @__PURE__ */ t("section", { className: "space-y-2", children: [
|
|
@@ -64,7 +64,7 @@ const ie = () => {
|
|
|
64
64
|
) })
|
|
65
65
|
] }),
|
|
66
66
|
/* @__PURE__ */ t(
|
|
67
|
-
|
|
67
|
+
p,
|
|
68
68
|
{
|
|
69
69
|
disabled: u,
|
|
70
70
|
variant: "default",
|
|
@@ -109,7 +109,7 @@ const ie = () => {
|
|
|
109
109
|
) })
|
|
110
110
|
] }),
|
|
111
111
|
/* @__PURE__ */ t(
|
|
112
|
-
|
|
112
|
+
p,
|
|
113
113
|
{
|
|
114
114
|
disabled: !N || h,
|
|
115
115
|
variant: "destructive",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-DonDtb8f.cjs"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),t=require("./index-j-XsKW-V.cjs"),c=require("lucide-react"),d=require("react"),O=require("react-i18next"),_=()=>{const m=t.useCurrentPageOwner(),f=t.useSendRealtimeEvent(),{setPageStatus:j}=t.usePageLockStatus(),{data:s,isFetching:v}=t.useChaiUserInfo((m==null?void 0:m.userId)||""),{pageLockMeta:o,setPageLockMeta:g}=t.usePageLockMeta(),{t:r}=O.useTranslation(),[u,i]=d.useState(""),[a,N]=d.useState({}),[T,k]=d.useState(!1),l=d.useRef(null);d.useEffect(()=>{o!=null&&o.type&&(l.current&&clearTimeout(l.current),d.startTransition(()=>{N(o),g({}),i("")}))},[o,g]);const b=()=>{u!==t.EVENT.TAKE_OVER_REQUEST&&(i(t.EVENT.TAKE_OVER_REQUEST),f(t.EVENT.TAKE_OVER_REQUEST),l.current=setTimeout(()=>i(""),2e4))},R=()=>{u!==t.EVENT.FORCE_TAKE_OVER_REQUEST&&(i(t.EVENT.FORCE_TAKE_OVER_REQUEST),f(t.EVENT.FORCE_TAKE_OVER_REQUEST),j(t.PAGE_STATUS.CHECKING),l.current=setTimeout(()=>i(""),2e4))},y=()=>{N({}),l.current&&clearTimeout(l.current),i("")},x=v?"Loading...":(s==null?void 0:s.name)||"Current editor",h=u===t.EVENT.TAKE_OVER_REQUEST,E=u===t.EVENT.FORCE_TAKE_OVER_REQUEST;return e.jsx(t.BlurContainer,{children:e.jsxs(n.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(n.CardHeader,{className:"space-y-1 border-b pb-3",children:e.jsxs(n.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(c.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),e.jsx("span",{children:r("Page Locked for Editing")})]})}),e.jsxs(n.CardContent,{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"relative 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:"Current Editor"}),e.jsxs("div",{className:"flex items-center space-x-4 p-1",children:[s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black text-white"}):e.jsx(c.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),e.jsxs("div",{className:"flex-1 space-y-0",children:[e.jsx("div",{className:"truncate font-medium leading-tight text-black",children:x}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),((a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED||(a==null?void 0:a.type)===t.EVENT.FORCE_TAKE_OVER_REQUEST)&&e.jsx("section",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-x-2 rounded border border-red-500 bg-red-500/10 py-2 pl-3 pr-2 text-sm font-medium text-red-500",children:[e.jsxs("div",{className:"flex items-start gap-x-2",children:[e.jsx(c.AlertCircleIcon,{className:"mt-px flex h-4 w-4 shrink-0"}),e.jsxs("div",{className:"font-light leading-tight",children:[e.jsx("span",{className:"font-medium",children:(s==null?void 0:s.name)||"The current editor"}),(a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED?" rejected your take over request.":" forcefully took over this page."]})]}),e.jsx(p.Button,{size:"icon",variant:"ghost",onClick:y,className:"flex-shrink-0",children:e.jsx(c.X,{className:"h-4 w-4"})})]})})]}),e.jsx(n.CardFooter,{className:"flex flex-col gap-3 border-t pt-3",children:e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:r("Take Over Options")}),e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-sm font-medium",children:r("Take Over Request:")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r("Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:h,variant:"default",onClick:b,className:"mt-3 w-full gap-2",children:[e.jsx(c.Edit,{className:"h-4 w-4"}),h?"Take over request sent":"Send Take Over Request"]}),h&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:r("Request sent. If no response, try again or use force take over.")})]}),e.jsx(n.Accordion,{type:"single",collapsible:!0,className:"w-full",children:e.jsxs(n.AccordionItem,{value:"force-takeover",className:"rounded-md border border-destructive/40 bg-destructive/5",children:[e.jsx(n.AccordionTrigger,{className:"px-3 py-2 hover:no-underline",children:e.jsx("div",{className:"flex items-center gap-2 text-left",children:e.jsxs("div",{children:[e.jsxs("p",{className:"flex items-center gap-x-2 text-sm font-medium text-destructive",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4 text-destructive"}),r("Force Take Over")]}),e.jsx("p",{className:"pl-6 text-xs font-normal leading-tight text-muted-foreground",children:r("Immediately take control (use with caution)")})]})})}),e.jsx(n.AccordionContent,{className:"px-3 pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2",children:[e.jsx("input",{type:"checkbox",id:"force-takeover",checked:T,onChange:C=>k(C.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"force-takeover",className:"flex-1 text-xs text-muted-foreground",children:r("I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:!T||E,variant:"destructive",onClick:R,className:"w-full gap-2",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4"}),r(E?"Take over page...":"Force Take Over")]}),E&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r("Attempting to forcefully take over this page. Please wait while we update the editing session.")})]})})]})})]})})]})})};exports.default=_;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { d as ie } from "./index-
|
|
3
|
-
import {
|
|
1
|
+
import { jsxs as w, Fragment as q, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { d as ie } from "./index-BbkBlCE2.js";
|
|
3
|
+
import { aA as be, aB as ge, ao as ke, i as de, T as D, aR as ve, L as Ne, k as Se, e as Le, c as Ce, au as Ae, aS as Ee, aT as $e } from "./index-Cyz_Iww4.js";
|
|
4
4
|
import { u as J } from "./use-page-expand-manager-Cf4MUEJw.js";
|
|
5
5
|
import { compact as ue, filter as F, isEmpty as k, uniqBy as Te, keyBy as me, mapValues as Me, startCase as Ue, toLower as T, includes as _, get as R, find as W, map as Ie } from "lodash-es";
|
|
6
|
-
import { atom as
|
|
6
|
+
import { atom as Be, useAtom as Fe, useSetAtom as ze } from "jotai";
|
|
7
7
|
import { ExternalLink as Oe, Pencil as je, MoreHorizontal as Ge, Lock as De, Plus as Re, ChevronRight as We, StarsIcon as He, Hash as _e, File as he } from "lucide-react";
|
|
8
|
-
import { useRef as qe, useEffect as $, useMemo as H, useState as N, useCallback as le, startTransition as
|
|
9
|
-
import { useTranslation as
|
|
8
|
+
import { useRef as qe, useEffect as $, useMemo as H, useState as N, useCallback as le, startTransition as Ve, Suspense as E, lazy as M } from "react";
|
|
9
|
+
import { useTranslation as Qe } from "react-i18next";
|
|
10
10
|
import { B as Xe } from "./register-chai-top-bar-D6GjnauV.js";
|
|
11
11
|
const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
12
12
|
F(e, (a) => {
|
|
@@ -57,7 +57,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
57
57
|
const m = ce(i, s), l = Ye(e, m);
|
|
58
58
|
i = Te([...m, ...l], "id");
|
|
59
59
|
}
|
|
60
|
-
const o = fe(Je(i)), f = Y(o, s, n),
|
|
60
|
+
const o = fe(Je(i)), f = Y(o, s, n), y = F(f, (m) => n(m.pageType)).sort(
|
|
61
61
|
(m, l) => (m.name || "").localeCompare(l.name || "")
|
|
62
62
|
), c = F(f, (m) => !n(m.pageType));
|
|
63
63
|
let x = [];
|
|
@@ -74,8 +74,8 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
74
74
|
);
|
|
75
75
|
} else
|
|
76
76
|
x = c.sort((m, l) => (m.name || "").localeCompare(l.name || ""));
|
|
77
|
-
return [...
|
|
78
|
-
}, Ze =
|
|
77
|
+
return [...y, ...x];
|
|
78
|
+
}, Ze = Be({
|
|
79
79
|
pageId: null,
|
|
80
80
|
position: { x: 0, y: 0 }
|
|
81
81
|
}), et = ({ pageId: e, children: s }) => {
|
|
@@ -87,11 +87,11 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
87
87
|
}, [o, n]);
|
|
88
88
|
const f = (c) => {
|
|
89
89
|
c.preventDefault(), c.stopPropagation(), n({ pageId: e, position: { x: c.clientX, y: c.clientY } });
|
|
90
|
-
},
|
|
90
|
+
}, y = () => {
|
|
91
91
|
const c = `${window.location.pathname}?page=${e}`;
|
|
92
92
|
window.open(c, "_blank"), n({ pageId: null, position: { x: 0, y: 0 } });
|
|
93
93
|
};
|
|
94
|
-
return /* @__PURE__ */
|
|
94
|
+
return /* @__PURE__ */ w(q, { children: [
|
|
95
95
|
/* @__PURE__ */ t("span", { onContextMenu: f, children: s }),
|
|
96
96
|
o && /* @__PURE__ */ t(
|
|
97
97
|
"div",
|
|
@@ -99,11 +99,11 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
99
99
|
ref: i,
|
|
100
100
|
className: "fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",
|
|
101
101
|
style: { top: a.position.y, left: a.position.x },
|
|
102
|
-
children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */
|
|
102
|
+
children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ w(
|
|
103
103
|
Xe,
|
|
104
104
|
{
|
|
105
105
|
variant: "ghost",
|
|
106
|
-
onClick:
|
|
106
|
+
onClick: y,
|
|
107
107
|
className: "w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",
|
|
108
108
|
children: [
|
|
109
109
|
/* @__PURE__ */ t(Oe, { className: "h-4 w-4" }),
|
|
@@ -149,12 +149,12 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
149
149
|
selectedLanguage: o,
|
|
150
150
|
showUntranslatedPages: f
|
|
151
151
|
}) => {
|
|
152
|
-
const
|
|
152
|
+
const y = be(), { pageToUser: c } = ge(), x = R(c, [e == null ? void 0 : e.id, "userId"]), { data: m } = ke(x), l = m && y !== x ? m == null ? void 0 : m.name : null, p = de(), v = a === e.id, P = H(() => W(s, { key: e.pageType }), [s, e.pageType]);
|
|
153
153
|
let d = R(i, e == null ? void 0 : e.id);
|
|
154
154
|
d = R(d, "lang") === o ? d : null;
|
|
155
155
|
const L = o === p || !!d, U = (d == null ? void 0 : d.name) || (e == null ? void 0 : e.name) || "No name";
|
|
156
156
|
let g = (d == null ? void 0 : d.slug) || (e == null ? void 0 : e.slug) || "";
|
|
157
|
-
const
|
|
157
|
+
const z = g + (e != null && e.dynamic ? `/${P == null ? void 0 : P.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
|
|
158
158
|
if (g.startsWith("/") && !f) {
|
|
159
159
|
const h = g.split("/").pop();
|
|
160
160
|
g = g.endsWith(h) && e.dynamic ? "" : `/${h}`;
|
|
@@ -170,8 +170,8 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
170
170
|
return !1;
|
|
171
171
|
return !0;
|
|
172
172
|
}, [d, e]);
|
|
173
|
-
return /* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */ t(et, { pageId: e.id, children: /* @__PURE__ */
|
|
173
|
+
return /* @__PURE__ */ w("div", { className: "group relative", children: [
|
|
174
|
+
/* @__PURE__ */ t(et, { pageId: e.id, children: /* @__PURE__ */ w(
|
|
175
175
|
"div",
|
|
176
176
|
{
|
|
177
177
|
onClick: () => !e.isPartialGroup && L && n("select", e == null ? void 0 : e.id),
|
|
@@ -181,9 +181,9 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
181
181
|
!e.isPartialGroup && /* @__PURE__ */ t(st, { isOnline: d ? d.online : e.online }),
|
|
182
182
|
!e.isPartialGroup && /* @__PURE__ */ t(nt, { page: e, pageType: P }),
|
|
183
183
|
/* @__PURE__ */ t(D, { content: U, side: "top", showTooltip: U.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: U }) }),
|
|
184
|
-
(g || e.dynamic) && /* @__PURE__ */ t(D, { content:
|
|
184
|
+
(g || e.dynamic) && /* @__PURE__ */ t(D, { content: z, side: "top", showTooltip: !0, children: /* @__PURE__ */ w("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
|
|
185
185
|
g,
|
|
186
|
-
e.dynamic && (P == null ? void 0 : P.dynamicSlug) && /* @__PURE__ */
|
|
186
|
+
e.dynamic && (P == null ? void 0 : P.dynamicSlug) && /* @__PURE__ */ w("span", { className: "text-xs text-gray-500", children: [
|
|
187
187
|
"/",
|
|
188
188
|
P == null ? void 0 : P.dynamicSlug,
|
|
189
189
|
e.dynamicSlugCustom
|
|
@@ -201,14 +201,14 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
201
201
|
setDeletePage: (h) => n("delete", d || h),
|
|
202
202
|
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(Ge, { className: "h-4 w-4", onClick: (h) => h.stopPropagation() }) })
|
|
203
203
|
}
|
|
204
|
-
) }) : l ? /* @__PURE__ */
|
|
204
|
+
) }) : l ? /* @__PURE__ */ w("span", { className: "duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500", children: [
|
|
205
205
|
/* @__PURE__ */ t(De, { className: "h-3 w-3 fill-red-200 text-red-500" }),
|
|
206
206
|
/* @__PURE__ */ t(D, { content: `${l} is editing this page`, children: /* @__PURE__ */ t("span", { className: "font-bold", children: l }) })
|
|
207
207
|
] }) : null
|
|
208
208
|
]
|
|
209
209
|
}
|
|
210
210
|
) }),
|
|
211
|
-
/* @__PURE__ */ t(q, { children: !L && !e.isPartialGroup && !l && /* @__PURE__ */
|
|
211
|
+
/* @__PURE__ */ t(q, { children: !L && !e.isPartialGroup && !l && /* @__PURE__ */ w(
|
|
212
212
|
"button",
|
|
213
213
|
{
|
|
214
214
|
onClick: (h) => {
|
|
@@ -218,7 +218,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
218
218
|
children: [
|
|
219
219
|
/* @__PURE__ */ t(Re, { size: 12, className: "stroke-[3]" }),
|
|
220
220
|
" ",
|
|
221
|
-
/* @__PURE__ */
|
|
221
|
+
/* @__PURE__ */ w("span", { className: "text-[10px]", children: [
|
|
222
222
|
"Add ",
|
|
223
223
|
R(Ne, o),
|
|
224
224
|
" Page"
|
|
@@ -235,10 +235,10 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
235
235
|
onClickAction: i,
|
|
236
236
|
languagePages: o,
|
|
237
237
|
selectedLanguage: f,
|
|
238
|
-
showUntranslatedPages:
|
|
238
|
+
showUntranslatedPages: y
|
|
239
239
|
}) => {
|
|
240
240
|
const { expandedPages: c } = J();
|
|
241
|
-
return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${s * 10}px` }, children: e.map((x) => /* @__PURE__ */
|
|
241
|
+
return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${s * 10}px` }, children: e.map((x) => /* @__PURE__ */ w(q, { children: [
|
|
242
242
|
/* @__PURE__ */ t(
|
|
243
243
|
at,
|
|
244
244
|
{
|
|
@@ -248,7 +248,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
248
248
|
onClickAction: i,
|
|
249
249
|
languagePages: o,
|
|
250
250
|
selectedLanguage: f,
|
|
251
|
-
showUntranslatedPages:
|
|
251
|
+
showUntranslatedPages: y
|
|
252
252
|
}
|
|
253
253
|
),
|
|
254
254
|
x.children && x.children.length > 0 && (c == null ? void 0 : c.includes(x.id)) && /* @__PURE__ */ t(
|
|
@@ -261,12 +261,12 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
261
261
|
onClickAction: i,
|
|
262
262
|
languagePages: o,
|
|
263
263
|
selectedLanguage: f,
|
|
264
|
-
showUntranslatedPages:
|
|
264
|
+
showUntranslatedPages: y
|
|
265
265
|
}
|
|
266
266
|
)
|
|
267
267
|
] }, x.id)) });
|
|
268
|
-
}, rt = M(() => import("./page-manager-search-and-filter-
|
|
269
|
-
const { t: s } =
|
|
268
|
+
}, rt = M(() => import("./page-manager-search-and-filter-B6F-ZvdQ.js")), ot = M(() => import("./add-new-page-8d0Nn-zI.js")), it = M(() => import("./delete-page-DIZhbU2t.js")), lt = M(() => import("./duplicate-page-xpV-pRVU.js")), ct = M(() => import("./mark-as-template-CQjchLk7.js")), dt = M(() => import("./unmark-as-template-WE3WJ-RJ.js")), ut = M(() => import("./unpublish-page-B4A-GQEz.js")), kt = ({ close: e }) => {
|
|
269
|
+
const { t: s } = Qe(), { languages: a, setSelectedLang: n } = ie(), { data: i } = Se(), { data: o, isFetching: f } = Le(), [y, c] = Ce(), { updateForSelectedPage: x, expandPagesOnSearch: m } = J(null), l = de(), p = y.get("page"), [v, P] = N(""), [d, L] = N(null), [U, g] = N(null), [z, O] = N(null), [j, h] = N(null), [A, V] = N(""), [K, Z] = N(null), [ee, te] = N(null), [b, Q] = N(l), [pe, we] = N(!1), ne = ze(Ae), G = pe && b !== l, { data: I, isFetching: ye } = Ee(b), se = le(
|
|
270
270
|
(u) => {
|
|
271
271
|
var r;
|
|
272
272
|
return (r = W(i, { key: u })) == null ? void 0 : r.hasSlug;
|
|
@@ -276,23 +276,23 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
276
276
|
$(() => {
|
|
277
277
|
n(l);
|
|
278
278
|
}, [l, n]), $(() => {
|
|
279
|
-
const u =
|
|
279
|
+
const u = y.get("lang");
|
|
280
280
|
if (u) {
|
|
281
|
-
const r = a, C = a[0] ?? l,
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
const r = a, C = a[0] ?? l, B = r.includes(u);
|
|
282
|
+
Ve(() => {
|
|
283
|
+
B && b !== u ? Q(u) : !B && b !== C && Q(C);
|
|
284
284
|
});
|
|
285
285
|
}
|
|
286
286
|
}, []), $(() => {
|
|
287
287
|
if (!k(A)) return;
|
|
288
288
|
const u = sessionStorage.getItem("pageTypeFilter") || "all";
|
|
289
|
-
!k(i) && u && (W(i, { key: u }) ?
|
|
289
|
+
!k(i) && u && (W(i, { key: u }) ? V(u) : V("all"));
|
|
290
290
|
}, [i, A]), $(() => {
|
|
291
291
|
if (p && !f && !W(o, { id: p })) {
|
|
292
|
-
const r = new URLSearchParams(
|
|
292
|
+
const r = new URLSearchParams(y.toString());
|
|
293
293
|
if (r.delete("page"), [...r.keys()].length > 0) {
|
|
294
294
|
if (typeof window < "u" && window.history && window.location) {
|
|
295
|
-
const C = r.toString(),
|
|
295
|
+
const C = r.toString(), B = window.location.hash || "", oe = window.location.pathname, Pe = C ? `${oe}?${C}${B}` : `${oe}${B}`;
|
|
296
296
|
window.history.replaceState(window.history.state, "", Pe);
|
|
297
297
|
}
|
|
298
298
|
c(r);
|
|
@@ -351,8 +351,8 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
351
351
|
break;
|
|
352
352
|
}
|
|
353
353
|
};
|
|
354
|
-
return /* @__PURE__ */
|
|
355
|
-
/* @__PURE__ */
|
|
354
|
+
return /* @__PURE__ */ w(q, { children: [
|
|
355
|
+
/* @__PURE__ */ w("div", { className: "flex h-full flex-col justify-between", children: [
|
|
356
356
|
/* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(
|
|
357
357
|
rt,
|
|
358
358
|
{
|
|
@@ -361,15 +361,15 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
361
361
|
setSearch: P,
|
|
362
362
|
languages: [l, ...a],
|
|
363
363
|
selectedLanguage: b,
|
|
364
|
-
setSelectedLanguage:
|
|
364
|
+
setSelectedLanguage: Q,
|
|
365
365
|
selectedPageType: A,
|
|
366
|
-
setSelectedPageType:
|
|
366
|
+
setSelectedPageType: V,
|
|
367
367
|
onAddPage: (u) => re("add", u),
|
|
368
368
|
showUntranslatedPages: G,
|
|
369
|
-
setShowUntranslatedPages:
|
|
369
|
+
setShowUntranslatedPages: we
|
|
370
370
|
}
|
|
371
371
|
) }),
|
|
372
|
-
/* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: f ||
|
|
372
|
+
/* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: f || ye ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ie([...Array(15).keys()], (u) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, u)) }) : k(S) ? /* @__PURE__ */ w("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
|
|
373
373
|
/* @__PURE__ */ t(he, { className: "h-6 w-6 stroke-[1]" }),
|
|
374
374
|
s("Empty List!"),
|
|
375
375
|
/* @__PURE__ */ t("span", { className: "font-light", children: s("Add new page to start") })
|
|
@@ -397,7 +397,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
|
|
|
397
397
|
}
|
|
398
398
|
) }),
|
|
399
399
|
d && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(it, { page: d, onClose: () => L(null) }) }),
|
|
400
|
-
|
|
400
|
+
z && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(ut, { page: z, onClose: () => O(null) }) }),
|
|
401
401
|
j && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(ct, { page: j, onClose: () => h(null) }) }),
|
|
402
402
|
ee && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(dt, { page: ee, onClose: () => te(null) }) }),
|
|
403
403
|
K && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(lt, { page: K, onClose: () => Z(null), closePanel: e }) })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),K=require("./index-DrzR7vXl.cjs"),y=require("./index-DXBHjFwY.cjs"),G=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),k=require("lucide-react"),o=require("react"),oe=require("react-i18next"),ie=require("./register-chai-top-bar-DyW9GPzV.cjs"),Z=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const s=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),s)||n.includes(n.toLower((a==null?void 0:a.slug)||""),s)})),le=(e,r)=>{const a=new Set,s=n.keyBy(e,"id");return r.forEach(c=>{let l=c;for(;l.parent&&s[l.parent];)a.add(l.parent),l=s[l.parent]}),Array.from(a).map(c=>s[c])},O=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?O(s.children,r,a):[]};const c=s.children&&s.children.some(l=>n.includes(n.toLower(l.name||""),n.toLower(r))||n.includes(n.toLower(l.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?O(s.children,r,a):[]}}),ce=e=>{if(!e||!e.length)return[];const r={};e.forEach(s=>{r[s.id]={...s,children:[]}});const a=[];return Object.values(r).forEach(s=>{s.parent&&r[s.parent]?r[s.parent].children.push(s):a.push(s)}),a},ee=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?ee(a.children):[]})),de=(e,r,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=Z(c,r);else{const x=Z(c,r),d=le(e,x);c=n.uniqBy([...x,...d],"id")}const l=ee(ce(c)),p=O(l,r,s),g=n.filter(p,x=>s(x.pageType)).sort((x,d)=>(x.name||"").localeCompare(d.name||"")),u=n.filter(p,x=>!s(x.pageType));let P=[];if(a==="all"){const x=n.keyBy(u,"pageType");P=Object.values(n.mapValues(x,(d,w)=>({...d,id:w,name:n.startCase(w),isPartialGroup:!0,children:p.filter(v=>v.pageType===w)})))}else P=u.sort((x,d)=>(x.name||"").localeCompare(d.name||""));return[...g,...P]},ue=R.atom({pageId:null,position:{x:0,y:0}}),me=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ue),c=o.useRef(null),l=a.pageId===e;o.useEffect(()=>{const u=()=>s({pageId:null,position:{x:0,y:0}});if(l)return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[l,s]);const p=u=>{u.preventDefault(),u.stopPropagation(),s({pageId:e,position:{x:u.clientX,y:u.clientY}})},g=()=>{const u=`${window.location.pathname}?page=${e}`;window.open(u,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:r}),l&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs(ie.Button,{variant:"ghost",onClick:g,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(k.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},he=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=G.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:l=>{l.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.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:t.jsx(k.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},xe=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(k.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?t.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?t.jsx(k.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(k.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),fe=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),ye=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:l,showUntranslatedPages:p})=>{const g=y.useUserId(),{pageToUser:u}=y.usePageToUser(),P=n.get(u,[e==null?void 0:e.id,"userId"]),{data:x}=y.useChaiUserInfo(P),d=x&&g!==P?x==null?void 0:x.name:null,w=y.useFallbackLang(),v=a===e.id,j=o.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let m=n.get(c,e==null?void 0:e.id);m=n.get(m,"lang")===l?m:null;const E=l===w||!!m,A=(m==null?void 0:m.name)||(e==null?void 0:e.name)||"No name";let S=(m==null?void 0:m.slug)||(e==null?void 0:e.slug)||"";const $=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!p){const f=S.split("/").pop();S=S.endsWith(f)&&e.dynamic?"":`/${f}`}const q=o.useMemo(()=>{const f="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]",C=`${v?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${f} ${C} ${d?"opacity-60":""}`:`${f} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,v,d]),I=o.useMemo(()=>{if(e.isPartialGroup)return!1;if(m){if(!m.online||n.isEmpty(m.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[m,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(me,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(he,{page:e}),!e.isPartialGroup&&t.jsx(fe,{isOnline:m?m.online:e.online}),!e.isPartialGroup&&t.jsx(xe,{page:e,pageType:j}),t.jsx(y.Tooltip,{content:A,side:"top",showTooltip:A.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:A})}),(S||e.dynamic)&&t.jsx(y.Tooltip,{content:$,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,e.dynamic&&(j==null?void 0:j.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",j==null?void 0:j.dynamicSlug,e.dynamicSlugCustom]})]})}),I&&t.jsx(y.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(k.Pencil,{size:12,className:"stroke-[2]"})})}),!e.isPartialGroup&&E&&!d?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(y.PageActionsDropdown,{isLanguagePage:!!m,page:m||e,setDuplicatePage:f=>s("duplicate",f),setAddEditPage:f=>s("edit",m||f),setUnpublishPage:f=>s("unpublish",f),setDeletePage:f=>s("delete",m||f),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(k.MoreHorizontal,{className:"h-4 w-4",onClick:f=>f.stopPropagation()})})})}):d?t.jsxs("span",{className:"duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500",children:[t.jsx(k.Lock,{className:"h-3 w-3 fill-red-200 text-red-500"}),t.jsx(y.Tooltip,{content:`${d} is editing this page`,children:t.jsx("span",{className:"font-bold",children:d})})]}):null]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!d&&t.jsxs("button",{onClick:f=>{f.stopPropagation(),s("addLanguagePage",{language:l,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:[t.jsx(k.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(y.LANGUAGES,l)," Page"]})]})})]})},te=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})=>{const{expandedPages:u}=G.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(P=>t.jsxs(t.Fragment,{children:[t.jsx(ye,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g}),P.children&&P.children.length>0&&(u==null?void 0:u.includes(P.id))&&t.jsx(te,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})]},P.id))})},pe=o.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-zfR5i_GU.cjs"))),Pe=o.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-CPB4yhqv.cjs"))),we=o.lazy(()=>Promise.resolve().then(()=>require("./delete-page-BOxoMgyl.cjs"))),ge=o.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-DVqC24Rd.cjs"))),je=o.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-muKJE1gk.cjs"))),be=o.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-BG882c_S.cjs"))),Se=o.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-DudJ1znF.cjs"))),ve=({close:e})=>{const{t:r}=oe.useTranslation(),{languages:a,setSelectedLang:s}=K.useLanguages(),{data:c}=y.usePageTypes(),{data:l,isFetching:p}=y.useWebsitePrimaryPages(),[g,u]=y.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:x}=G.usePageExpandManager(null),d=y.useFallbackLang(),w=g.get("page"),[v,j]=o.useState(""),[m,E]=o.useState(null),[A,S]=o.useState(null),[$,q]=o.useState(null),[I,f]=o.useState(null),[C,z]=o.useState(""),[D,W]=o.useState(null),[H,_]=o.useState(null),[b,F]=o.useState(d),[se,ne]=o.useState(!1),V=R.useSetAtom(y.addNewLangAtom),U=se&&b!==d,{data:M,isFetching:re}=y.useWebsiteLanguagePages(b),Q=o.useCallback(h=>{var i;return(i=n.find(c,{key:h}))==null?void 0:i.hasSlug},[c]),N=o.useMemo(()=>l?U?n.filter(l,h=>!(M!=null&&M[h.id])):de(l,v,C,Q):[],[l,Q,v,C,M,U]);o.useEffect(()=>{s(d)},[d,s]),o.useEffect(()=>{const h=g.get("lang");if(h){const i=a,L=a[0]??d,T=i.includes(h);o.startTransition(()=>{T&&b!==h?F(h):!T&&b!==L&&F(L)})}},[]),o.useEffect(()=>{if(!n.isEmpty(C))return;const h=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&h&&(n.find(c,{key:h})?z(h):z("all"))},[c,C]),o.useEffect(()=>{if(w&&!p&&!n.find(l,{id:w})){const i=new URLSearchParams(g.toString());if(i.delete("page"),[...i.keys()].length>0){if(typeof window<"u"&&window.history&&window.location){const L=i.toString(),T=window.location.hash||"",J=window.location.pathname,ae=L?`${J}?${L}${T}`:`${J}${T}`;window.history.replaceState(window.history.state,"",ae)}u(i)}else typeof window<"u"&&window.history&&window.location&&(window.history.replaceState(window.history.state,"",window.location.pathname+window.location.hash),window.dispatchEvent(new PopStateEvent("popstate",{state:window.history.state}))),u(i)}},[l,w,p,u]),o.useEffect(()=>{w&&!p&&!n.isEmpty(N)&&P(N,w)},[w,p,N,P]),o.useEffect(()=>{!n.isEmpty(v)&&!n.isEmpty(N)&&x(N)},[v,N,x]);const{setSelectedLang:B}=K.useLanguages(),X=o.useCallback(h=>{const i=new URLSearchParams({page:h});b!==d?(i.set("lang",b),B(b)):B(""),y.navigateToPage(i,u),e()},[e,u,B,b,d]),Y=(h,i)=>{var L;if(i)switch(h){case"add":S(i);break;case"select":X(i);break;case"edit":b!==d?V({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):S(i);break;case"delete":E(i);break;case"unpublish":q(i);break;case"markAsTemplate":f(i);break;case"unmarkAsTemplate":_(i);break;case"duplicate":W(i);break;case"addLanguagePage":V({edit:!1,primaryPage:((L=i==null?void 0:i.page)==null?void 0:L.id)||"",preselectedLang:(i==null?void 0:i.language)||b});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(o.Suspense,{children:t.jsx(pe,{pages:N,search:v,setSearch:j,languages:[d,...a],selectedLanguage:b,setSelectedLanguage:F,selectedPageType:C,setSelectedPageType:z,onAddPage:h=>Y("add",h),showUntranslatedPages:U,setShowUntranslatedPages:ne})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||re?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],h=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},h))}):n.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(k.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),t.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):t.jsx(te,{tier:0,pages:N,pageTypes:c,currentPage:w||"",onClickAction:Y,languagePages:M,selectedLanguage:b,showUntranslatedPages:U})})]}),A&&t.jsx(o.Suspense,{children:t.jsx(Pe,{closePanel:e,editPage:X,addEditPage:A,setAddEditPage:S})}),m&&t.jsx(o.Suspense,{children:t.jsx(we,{page:m,onClose:()=>E(null)})}),$&&t.jsx(o.Suspense,{children:t.jsx(Se,{page:$,onClose:()=>q(null)})}),I&&t.jsx(o.Suspense,{children:t.jsx(je,{page:I,onClose:()=>f(null)})}),H&&t.jsx(o.Suspense,{children:t.jsx(be,{page:H,onClose:()=>_(null)})}),D&&t.jsx(o.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null),closePanel:e})})]})};exports.default=ve;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),K=require("./index-DonDtb8f.cjs"),y=require("./index-j-XsKW-V.cjs"),G=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),k=require("lucide-react"),o=require("react"),oe=require("react-i18next"),ie=require("./register-chai-top-bar-DyW9GPzV.cjs"),Z=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const s=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),s)||n.includes(n.toLower((a==null?void 0:a.slug)||""),s)})),le=(e,r)=>{const a=new Set,s=n.keyBy(e,"id");return r.forEach(c=>{let l=c;for(;l.parent&&s[l.parent];)a.add(l.parent),l=s[l.parent]}),Array.from(a).map(c=>s[c])},O=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?O(s.children,r,a):[]};const c=s.children&&s.children.some(l=>n.includes(n.toLower(l.name||""),n.toLower(r))||n.includes(n.toLower(l.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?O(s.children,r,a):[]}}),ce=e=>{if(!e||!e.length)return[];const r={};e.forEach(s=>{r[s.id]={...s,children:[]}});const a=[];return Object.values(r).forEach(s=>{s.parent&&r[s.parent]?r[s.parent].children.push(s):a.push(s)}),a},ee=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?ee(a.children):[]})),de=(e,r,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=Z(c,r);else{const x=Z(c,r),d=le(e,x);c=n.uniqBy([...x,...d],"id")}const l=ee(ce(c)),p=O(l,r,s),g=n.filter(p,x=>s(x.pageType)).sort((x,d)=>(x.name||"").localeCompare(d.name||"")),u=n.filter(p,x=>!s(x.pageType));let P=[];if(a==="all"){const x=n.keyBy(u,"pageType");P=Object.values(n.mapValues(x,(d,w)=>({...d,id:w,name:n.startCase(w),isPartialGroup:!0,children:p.filter(v=>v.pageType===w)})))}else P=u.sort((x,d)=>(x.name||"").localeCompare(d.name||""));return[...g,...P]},ue=R.atom({pageId:null,position:{x:0,y:0}}),me=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ue),c=o.useRef(null),l=a.pageId===e;o.useEffect(()=>{const u=()=>s({pageId:null,position:{x:0,y:0}});if(l)return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[l,s]);const p=u=>{u.preventDefault(),u.stopPropagation(),s({pageId:e,position:{x:u.clientX,y:u.clientY}})},g=()=>{const u=`${window.location.pathname}?page=${e}`;window.open(u,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:r}),l&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs(ie.Button,{variant:"ghost",onClick:g,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(k.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},he=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=G.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:l=>{l.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.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:t.jsx(k.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},xe=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(k.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?t.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?t.jsx(k.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(k.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),fe=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),ye=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:l,showUntranslatedPages:p})=>{const g=y.useUserId(),{pageToUser:u}=y.usePageToUser(),P=n.get(u,[e==null?void 0:e.id,"userId"]),{data:x}=y.useChaiUserInfo(P),d=x&&g!==P?x==null?void 0:x.name:null,w=y.useFallbackLang(),v=a===e.id,j=o.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let m=n.get(c,e==null?void 0:e.id);m=n.get(m,"lang")===l?m:null;const E=l===w||!!m,A=(m==null?void 0:m.name)||(e==null?void 0:e.name)||"No name";let S=(m==null?void 0:m.slug)||(e==null?void 0:e.slug)||"";const $=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!p){const f=S.split("/").pop();S=S.endsWith(f)&&e.dynamic?"":`/${f}`}const q=o.useMemo(()=>{const f="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]",C=`${v?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${f} ${C} ${d?"opacity-60":""}`:`${f} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,v,d]),I=o.useMemo(()=>{if(e.isPartialGroup)return!1;if(m){if(!m.online||n.isEmpty(m.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[m,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(me,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(he,{page:e}),!e.isPartialGroup&&t.jsx(fe,{isOnline:m?m.online:e.online}),!e.isPartialGroup&&t.jsx(xe,{page:e,pageType:j}),t.jsx(y.Tooltip,{content:A,side:"top",showTooltip:A.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:A})}),(S||e.dynamic)&&t.jsx(y.Tooltip,{content:$,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,e.dynamic&&(j==null?void 0:j.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",j==null?void 0:j.dynamicSlug,e.dynamicSlugCustom]})]})}),I&&t.jsx(y.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(k.Pencil,{size:12,className:"stroke-[2]"})})}),!e.isPartialGroup&&E&&!d?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(y.PageActionsDropdown,{isLanguagePage:!!m,page:m||e,setDuplicatePage:f=>s("duplicate",f),setAddEditPage:f=>s("edit",m||f),setUnpublishPage:f=>s("unpublish",f),setDeletePage:f=>s("delete",m||f),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(k.MoreHorizontal,{className:"h-4 w-4",onClick:f=>f.stopPropagation()})})})}):d?t.jsxs("span",{className:"duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500",children:[t.jsx(k.Lock,{className:"h-3 w-3 fill-red-200 text-red-500"}),t.jsx(y.Tooltip,{content:`${d} is editing this page`,children:t.jsx("span",{className:"font-bold",children:d})})]}):null]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!d&&t.jsxs("button",{onClick:f=>{f.stopPropagation(),s("addLanguagePage",{language:l,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:[t.jsx(k.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(y.LANGUAGES,l)," Page"]})]})})]})},te=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})=>{const{expandedPages:u}=G.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(P=>t.jsxs(t.Fragment,{children:[t.jsx(ye,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g}),P.children&&P.children.length>0&&(u==null?void 0:u.includes(P.id))&&t.jsx(te,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})]},P.id))})},pe=o.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-Yt0pjK_r.cjs"))),Pe=o.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-CV7A1XJQ.cjs"))),we=o.lazy(()=>Promise.resolve().then(()=>require("./delete-page-D8Vr-1aC.cjs"))),ge=o.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-DomSAvnp.cjs"))),je=o.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-C2-S_aA2.cjs"))),be=o.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-BE1BO8Z0.cjs"))),Se=o.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-DrZnWLVM.cjs"))),ve=({close:e})=>{const{t:r}=oe.useTranslation(),{languages:a,setSelectedLang:s}=K.useLanguages(),{data:c}=y.usePageTypes(),{data:l,isFetching:p}=y.useWebsitePrimaryPages(),[g,u]=y.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:x}=G.usePageExpandManager(null),d=y.useFallbackLang(),w=g.get("page"),[v,j]=o.useState(""),[m,E]=o.useState(null),[A,S]=o.useState(null),[$,q]=o.useState(null),[I,f]=o.useState(null),[C,z]=o.useState(""),[D,W]=o.useState(null),[H,_]=o.useState(null),[b,F]=o.useState(d),[se,ne]=o.useState(!1),V=R.useSetAtom(y.addNewLangAtom),U=se&&b!==d,{data:M,isFetching:re}=y.useWebsiteLanguagePages(b),Q=o.useCallback(h=>{var i;return(i=n.find(c,{key:h}))==null?void 0:i.hasSlug},[c]),N=o.useMemo(()=>l?U?n.filter(l,h=>!(M!=null&&M[h.id])):de(l,v,C,Q):[],[l,Q,v,C,M,U]);o.useEffect(()=>{s(d)},[d,s]),o.useEffect(()=>{const h=g.get("lang");if(h){const i=a,L=a[0]??d,T=i.includes(h);o.startTransition(()=>{T&&b!==h?F(h):!T&&b!==L&&F(L)})}},[]),o.useEffect(()=>{if(!n.isEmpty(C))return;const h=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&h&&(n.find(c,{key:h})?z(h):z("all"))},[c,C]),o.useEffect(()=>{if(w&&!p&&!n.find(l,{id:w})){const i=new URLSearchParams(g.toString());if(i.delete("page"),[...i.keys()].length>0){if(typeof window<"u"&&window.history&&window.location){const L=i.toString(),T=window.location.hash||"",J=window.location.pathname,ae=L?`${J}?${L}${T}`:`${J}${T}`;window.history.replaceState(window.history.state,"",ae)}u(i)}else typeof window<"u"&&window.history&&window.location&&(window.history.replaceState(window.history.state,"",window.location.pathname+window.location.hash),window.dispatchEvent(new PopStateEvent("popstate",{state:window.history.state}))),u(i)}},[l,w,p,u]),o.useEffect(()=>{w&&!p&&!n.isEmpty(N)&&P(N,w)},[w,p,N,P]),o.useEffect(()=>{!n.isEmpty(v)&&!n.isEmpty(N)&&x(N)},[v,N,x]);const{setSelectedLang:B}=K.useLanguages(),X=o.useCallback(h=>{const i=new URLSearchParams({page:h});b!==d?(i.set("lang",b),B(b)):B(""),y.navigateToPage(i,u),e()},[e,u,B,b,d]),Y=(h,i)=>{var L;if(i)switch(h){case"add":S(i);break;case"select":X(i);break;case"edit":b!==d?V({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):S(i);break;case"delete":E(i);break;case"unpublish":q(i);break;case"markAsTemplate":f(i);break;case"unmarkAsTemplate":_(i);break;case"duplicate":W(i);break;case"addLanguagePage":V({edit:!1,primaryPage:((L=i==null?void 0:i.page)==null?void 0:L.id)||"",preselectedLang:(i==null?void 0:i.language)||b});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(o.Suspense,{children:t.jsx(pe,{pages:N,search:v,setSearch:j,languages:[d,...a],selectedLanguage:b,setSelectedLanguage:F,selectedPageType:C,setSelectedPageType:z,onAddPage:h=>Y("add",h),showUntranslatedPages:U,setShowUntranslatedPages:ne})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||re?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],h=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},h))}):n.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(k.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),t.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):t.jsx(te,{tier:0,pages:N,pageTypes:c,currentPage:w||"",onClickAction:Y,languagePages:M,selectedLanguage:b,showUntranslatedPages:U})})]}),A&&t.jsx(o.Suspense,{children:t.jsx(Pe,{closePanel:e,editPage:X,addEditPage:A,setAddEditPage:S})}),m&&t.jsx(o.Suspense,{children:t.jsx(we,{page:m,onClose:()=>E(null)})}),$&&t.jsx(o.Suspense,{children:t.jsx(Se,{page:$,onClose:()=>q(null)})}),I&&t.jsx(o.Suspense,{children:t.jsx(je,{page:I,onClose:()=>f(null)})}),H&&t.jsx(o.Suspense,{children:t.jsx(be,{page:H,onClose:()=>_(null)})}),D&&t.jsx(o.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null),closePanel:e})})]})};exports.default=ve;
|