UNPKG

strapi-plugin-navigation

Version:
1,659 lines (1,656 loc) 156 kB
import jn, { useRef as We, useEffect as V, useCallback as E, useState as N, useMemo as X, createContext as tn, useContext as nn } from "react"; import { jsx as n, jsxs as w, Fragment as ie } from "react/jsx-runtime"; import oe, { useTheme as Bn } from "styled-components"; import { getFetchClient as j, useRBAC as On, useMediaQuery as Pt, useIsMobile as an, useIsTablet as zn, useIsDesktop as _n, Form as at, useNotification as Oe, Layouts as qe, useStrapiApp as Qn, Page as Te, useAuth as Un } from "@strapi/strapi/admin"; import { useDrop as Kn, useDrag as Wn, DndProvider as Hn } from "react-dnd"; import { HTML5Backend as Xn } from "react-dnd-html5-backend"; import { Routes as Gn, Route as Mt } from "react-router-dom"; import { useQuery as Fe, useMutation as ge, useQueryClient as be, QueryClient as on, QueryClientProvider as rn } from "@tanstack/react-query"; import { once as Zn, isEmpty as Y, capitalize as ln, get as J, first as Ct, orderBy as Jn, isObject as He, isNil as Be, isString as ot, set as it, sortBy as Xe, isNumber as kt, isBoolean as Yn, isNull as ea, isArray as ta } from "lodash"; import { useIntl as A } from "react-intl"; import { Dialog as Qe, Flex as P, Typography as F, Button as K, Modal as H, Grid as S, TextInput as we, Toggle as me, Box as D, Table as sn, Thead as dn, Tr as et, Th as ce, Checkbox as qt, IconButton as ye, Tbody as cn, Td as ue, Loader as bt, Tag as na, Field as Dt, SingleSelect as xe, SingleSelectOption as Ae, Badge as aa, CardTitle as oa, IconButtonGroup as un, Card as ia, CardBody as Vt, Divider as tt, TextButton as ra, Link as la, MultiSelect as De, MultiSelectOption as Ve, Textarea as sa, Combobox as pn, ComboboxOption as da, Searchbar as ca, Alert as ua, NumberInput as pa, Accordion as Ue, VisuallyHidden as ma, Tooltip as ga, TFooter as ha } from "@strapi/design-system"; import { Check as Ge, WarningCircle as fa, Feather as ya, Pencil as vt, Trash as Tt, Information as ba, CaretDown as Ia, CaretUp as Ca, Drag as va, Eye as mn, ArrowClockwise as Ta, Earth as wa, Cog as Sa, Link as xa, Plus as wt, ArrowRight as Aa, Search as Fa, ListPlus as Na, Typhoon as Ra, Play as La, Minus as $a, EyeStriked as Ea, PriceTag as Pa } from "@strapi/icons"; import * as s from "zod"; import { z as g } from "zod"; import { usePluginTheme as Ma, Field as $, prefixPluginTranslations as jt, flattenObject as Bt } from "@sensinum/strapi-utils"; import { prop as nt } from "lodash/fp"; const de = "navigation", ka = ({ setPlugin: e }) => { const t = We(e); return V(() => { t.current?.(de); }, []), null; }, qa = 92, Da = oe.svg` path { fill: ${({ theme: e }) => e.colors.neutral500}; } `, Va = ({ width: e = 20, height: t = 20 }) => /* @__PURE__ */ n( Da, { viewBox: `0 0 ${e} ${t}`, xmlns: "http://www.w3.org/2000/svg", height: t, width: e, children: /* @__PURE__ */ n("g", { style: { transform: `scale(${e / qa})` }, children: /* @__PURE__ */ n( "path", { d: `M78,23.5H14c-3.6,0-6.5-2.9-6.5-6.5s2.9-6.5,6.5-6.5h64c3.6,0,6.5,2.9,6.5,6.5S81.6,23.5,78,23.5z M84.5,46 c0-3.6-2.9-6.5-6.5-6.5H14c-3.6,0-6.5,2.9-6.5,6.5s2.9,6.5,6.5,6.5h64C81.6,52.5,84.5,49.6,84.5,46z M84.5,75c0-3.6-2.9-6.5-6.5-6.5 H14c-3.6,0-6.5,2.9-6.5,6.5s2.9,6.5,6.5,6.5h64C81.6,81.5,84.5,78.6,84.5,75z` } ) }) } ), ja = () => /* @__PURE__ */ n(Va, {}), Ot = { en: () => import("../_chunks/en-ngsBvlEG.mjs"), fr: () => import("../_chunks/fr-BwEbhMNV.mjs"), ca: () => import("../_chunks/ca-BZeeYBM5.mjs") }, It = (e) => `${de}.${e}`, l = (e, t) => ({ id: It(e), defaultMessage: t ?? It(e) }), St = g.object({ name: g.string({ required_error: "requiredError" }).nonempty("requiredError").refine((e) => !e.includes(" "), { message: "noSpaceError" }), label: g.string({ required_error: "requiredError" }).nonempty("requiredError"), description: g.string().optional(), placeholder: g.string().optional(), required: g.boolean().optional(), enabled: g.boolean().optional() }), Ba = St.extend({ type: g.literal("select"), multi: g.boolean(), options: g.array(g.string(), { required_error: "requiredError" }).min(1, { message: "requiredError" }) }), Oa = St.extend({ type: g.enum(["boolean", "string"]), multi: g.literal(!1).optional(), options: g.array(g.string()).max(0).optional() }), za = St.extend({ type: g.literal("media"), multi: g.literal(!1).optional(), options: g.array(g.string()).max(0).optional() }), gn = g.discriminatedUnion("type", [ Oa, za, Ba ]), _a = g.union([ g.literal("audience"), gn ]), Qa = g.object({ additionalFields: g.array(_a), allowedLevels: g.number(), availableAudience: g.object({ id: g.number(), documentId: g.string(), name: g.string(), key: g.string() }).array(), contentTypes: g.array(g.string()), defaultContentType: g.string().optional(), contentTypesNameFields: g.record(g.string(), g.array(g.string())), contentTypesPopulate: g.record(g.string(), g.array(g.string())), gql: g.object({ navigationItemRelated: g.array(g.string()) }), pathDefaultFields: g.record(g.string(), g.any()), cascadeMenuAttached: g.boolean(), preferCustomContentTypes: g.boolean(), isCacheEnabled: g.boolean().optional(), isCachePluginEnabled: g.boolean().optional() }), Ua = g.object({ uid: g.string(), isDisplayed: g.boolean(), apiID: g.string(), kind: g.enum(["collectionType", "singleType"]), info: g.object({ singularName: g.string(), pluralName: g.string(), displayName: g.string(), description: g.string().optional() }), attributes: g.record(g.string(), g.unknown()) }), Ka = s.object({ id: s.number(), documentId: s.string(), name: s.string(), key: s.string() }), hn = s.enum(["INTERNAL", "EXTERNAL", "WRAPPER"]), Wa = s.object({ id: s.number(), documentId: s.string(), title: s.string(), type: hn, path: s.string().or(s.null()).optional(), externalPath: s.string().or(s.null()).optional(), uiRouterKey: s.string(), menuAttached: s.boolean(), order: s.number().int(), collapsed: s.boolean(), autoSync: s.boolean().or(s.null()).optional(), related: s.object({ documentId: s.string().optional(), __type: s.string() }).catchall(s.unknown()).nullish(), additionalFields: s.record(s.string(), s.unknown()).or(s.null()).optional(), audience: s.array(Ka).or(s.null()).optional(), viewId: s.number().optional(), viewParentId: s.number().optional(), structureId: s.string().optional(), removed: s.boolean().optional(), isSearchActive: s.boolean().optional(), updated: s.boolean().optional() }), fn = Wa.extend({ items: s.lazy(() => fn.array().or(s.null())).optional() }), zt = s.object({ id: s.number(), documentId: s.string(), name: s.string(), slug: s.string(), locale: s.string(), visible: s.boolean(), items: s.array(fn) }), xt = s.object({ name: s.string({ required_error: "requiredError" }).nonempty("requiredError").refine((e) => !e.includes(" "), { message: "noSpaceError" }), label: s.string({ required_error: "requiredError" }).nonempty("requiredError"), description: s.string().optional(), placeholder: s.string().optional(), required: s.boolean().optional(), enabled: s.boolean().optional() }), Ha = xt.extend({ type: s.literal("select"), multi: s.boolean(), options: s.array(s.string(), { required_error: "requiredError" }).min(1, { message: "requiredError" }) }), Xa = xt.extend({ type: s.enum(["boolean", "string"]), multi: s.literal(!1).optional(), options: s.array(s.string()).max(0).optional() }), Ga = xt.extend({ type: s.literal("media"), multi: s.literal(!1).optional(), options: s.array(s.string()).max(0).optional() }), Za = s.discriminatedUnion("type", [ Xa, Ga, Ha ]), Ja = s.union([ s.literal("audience"), Za ]), Ya = s.object({ uid: s.string(), name: s.string(), draftAndPublish: s.boolean(), isSingle: s.boolean(), description: s.string(), collectionName: s.string(), contentTypeName: s.string(), label: s.string(), endpoint: s.string(), available: s.boolean(), visible: s.boolean() }), eo = s.object({ additionalFields: s.array(Ja), allowedLevels: s.number(), availableAudience: s.object({ id: s.number(), documentId: s.string(), name: s.string(), key: s.string() }).array(), contentTypes: s.array(s.string()), defaultContentType: s.string().optional(), contentTypesNameFields: s.record(s.string(), s.array(s.string())), contentTypesPopulate: s.record(s.string(), s.array(s.string())), gql: s.object({ navigationItemRelated: s.array(s.string()) }), pathDefaultFields: s.record(s.string(), s.string().array()), cascadeMenuAttached: s.boolean(), preferCustomContentTypes: s.boolean(), allowedContentTypes: s.string().array(), restrictedContentTypes: s.string().array(), isCacheEnabled: s.boolean().optional(), isCachePluginEnabled: s.boolean().optional() }), _t = eo.omit({ contentTypes: !0 }).extend({ contentTypes: Ya.array() }), to = s.object({ defaultLocale: s.string(), restLocale: s.string().array() }), no = s.enum(["collectionType", "singleType"]), ao = s.object({ singularName: s.string(), pluralName: s.string(), displayName: s.string(), description: s.string().optional(), name: s.string().optional() }), yn = s.object({ required: s.boolean().optional(), max: s.number().optional(), min: s.number().optional(), minLength: s.number().optional(), maxLength: s.number().optional(), private: s.boolean().optional(), configurable: s.boolean().optional(), default: s.any().optional() }), oo = s.enum([ "string", "text", "richtext", "blocks", "email", "password", "date", "time", "datetime", "timestamp", "boolean", "integer", "biginteger", "float", "decimal", "json", "relation", "media" ]), io = yn.extend({ type: oo }), ro = yn.extend({ type: s.literal("enumeration"), enum: s.string().array() }), lo = s.object({ type: s.literal("component"), component: s.string(), repeatable: s.boolean().optional() }), so = s.object({ type: s.literal("dynamiczone"), components: s.string().array() }), co = s.object({ media: s.literal("media"), allowedTypes: s.enum(["images", "videos", "audios", "files"]).array(), required: s.boolean().optional() }), uo = s.enum([ "oneToOne", "oneToMany", "manyToOne", "manyToMany", "morphToMany", "manyToMorph" ]), po = s.object({ type: s.literal("relation"), relation: uo, target: s.string(), mappedBy: s.string().optional(), inversedBy: s.string().optional() }), mo = s.record( s.string(), s.union([ io, ro, lo, so, po, co ]) ), go = s.object({ kind: no, collectionName: s.string(), info: ao, options: s.object({ draftAndPublish: s.boolean().optional(), hidden: s.boolean().optional(), templateName: s.string().optional() }).optional(), attributes: mo, actions: s.record(s.string(), s.any()).optional(), lifecycles: s.record(s.string(), s.any()).optional(), uid: s.string(), apiName: s.string().optional(), // TODO?: remove associations: s.object({ model: s.string(), alias: s.string() }).array().optional(), modelName: s.string().optional(), plugin: s.string().optional(), pluginOptions: s.record(s.string(), s.any()).optional(), isSingle: s.boolean().optional() }); go.pick({ info: !0, kind: !0, attributes: !0, options: !0 }); const ho = s.object({ id: s.number(), documentId: s.string(), locale: s.string().or(s.null()).optional() }).and(s.record(s.string(), s.any())), fo = s.object({ slug: s.string() }), yo = s.object({ externalPath: s.string().or(s.null()).optional(), path: s.string().or(s.null()).optional(), related: s.object({ documentId: s.string().optional(), __type: s.string() }).catchall(s.unknown()).nullish(), title: s.string(), type: hn, uiRouterKey: s.string() }), q = "navigation", B = Zn((e) => ({ getIndexPrefix() { return [q]; }, readAll() { return e.get(`/${q}`).then(({ data: t }) => zt.array().parse(t)); }, readAllIndex() { return [q, "navigations"]; }, delete(t) { return e.del(`/${q}/${t}`); }, create(t) { return e.post(`/${q}/`, t); }, update(t) { return e.put(`/${q}/${t.documentId}`, t).then(({ data: a }) => a).then(zt.parse); }, purge({ documentId: t, withLangVersions: a }) { return e.del( `/${q}/cache/purge/${t ?? ""}?clearLocalisations=${!!a}` ); }, slugify(t) { const a = new URLSearchParams(); return a.append("q", t), e.get(`/${q}/slug?${a.toString()}`).then(({ data: o }) => fo.parse(o)).then(({ slug: o }) => o); }, readConfig() { return e.get(`/${q}/config`).then(({ data: t }) => _t.parse(t)); }, readConfigIndex() { return [q, "config"]; }, healthCheck() { return e.get("/_health"); }, healthCheckIndex() { return ["health"]; }, readNavigationItemFromLocale({ source: t, structureId: a, target: o, documentId: i }) { return e.get( `/${q}/i18n/item/read/${i}/${t}/${o}?path=${a}` ); }, updateConfig(t) { return e.put(`/${q}/config`, t).then(() => { }); }, restart() { return e.get(`/${q}/settings/restart`).then(() => { }); }, restoreConfig() { return e.del(`/${q}/config`).then(() => { }); }, readSettingsConfig() { return e.get(`/${q}/settings/config`).then(({ data: t }) => { const a = _t.parse(t); return { ...a, contentTypes: a.contentTypes.map(({ uid: o }) => o) }; }); }, readSettingsConfigIndex() { return [q, "config"]; }, readContentType() { return e.get("/content-manager/content-types").then(({ data: t }) => Ua.array().parse(t.data)); }, readContentTypeIndex() { return [q, "content-manager", "content-types"]; }, readContentTypeItems({ uid: t, locale: a, query: o }) { const i = new URLSearchParams(); return o && i.append("_q", o), a && i.append("locale", a), e.get(`/${q}/content-type-items/${t}?${i.toString()}`).then(({ data: r }) => ho.array().parse(r)); }, readContentTypeItemsIndex({ uid: t, locale: a, query: o }) { return [q, "content-manager", "content-type-items", t, a, o]; }, readLocale() { return e.get(`/${q}/settings/locale`).then((t) => to.parse(t.data)); }, readLocaleIndex() { return [q, "locale"]; }, copyNavigationLocale({ documentId: t, source: a, target: o }) { return e.put(`/${q}/i18n/copy/${t}/${a}/${o}`); }, copyNavigationItemLocale({ source: t, structureId: a = "", target: o }) { return e.get(`/${q}/i18n/item/read/${t}/${o}?path=${a}`).then((i) => yo.parse(i.data)); } })), rt = (e) => ({ ...e, viewId: Math.floor(Math.random() * 152e4), items: e.items?.map(rt) }), At = () => { const e = j(), t = B(e); return Fe({ queryKey: t.readLocaleIndex(), queryFn: t.readLocale, staleTime: 1 / 0 }); }, bn = (e) => { const t = j(), a = B(t); return Fe({ queryKey: a.readContentTypeItemsIndex(e), queryFn: () => a.readContentTypeItems(e), staleTime: 1e3 * 60 * 3, enabled: !!e.uid }); }, bo = () => { const e = j(), t = B(e); return Fe({ queryKey: t.readContentTypeIndex(), queryFn: () => t.readContentType(), staleTime: 1e3 * 60 * 3 }); }, Io = () => { const e = j(), t = B(e), a = be(); return () => { a.resetQueries({ queryKey: t.readAllIndex() }); }; }, Co = () => { const e = j(), t = B(e), a = be(); return () => { a.resetQueries({ queryKey: t.readContentTypeIndex() }); }; }, vo = (e) => { const t = j(), a = B(t), o = be(); return () => { o.invalidateQueries({ queryKey: a.readContentTypeItemsIndex(e) }); }; }, To = () => { const e = j(), t = B(e), a = be(); return () => { a.invalidateQueries({ queryKey: t.readAllIndex() }); }; }, wo = () => { const e = j(), t = B(e), a = be(); return () => a.invalidateQueries({ queryKey: t.readLocaleIndex() }); }, Ft = () => { const e = j(), t = B(e); return Fe({ queryKey: t.readAllIndex(), queryFn() { return t.readAll().then( (a) => a.map( (o) => ({ ...o, items: o.items.map(rt) }) ) ); }, staleTime: 1e3 * 60 * 5 }); }, So = () => { const e = be(), t = j(), a = B(t); return E(() => { e.invalidateQueries({ queryKey: a.getIndexPrefix() }); }, [e, t, a]); }, xo = () => { const e = j(), t = B(e); return ge({ mutationFn(a) { return Promise.all(a.map(t.delete)); } }); }, Ao = () => { const e = j(), t = B(e); return ge({ mutationFn: t.copyNavigationItemLocale }); }, Fo = () => { const e = j(), t = B(e), a = be(); return ge({ mutationFn: t.copyNavigationLocale, onSuccess() { a.invalidateQueries({ queryKey: t.readAllIndex() }); } }); }, No = () => { const e = j(), t = B(e), a = be(); return ge({ mutationFn: t.create, onSuccess() { a.invalidateQueries({ queryKey: t.readAllIndex() }); } }); }, In = ({ onError: e, onSuccess: t }) => { const a = j(), o = B(a), i = be(); return ge({ mutationFn: o.update, onSuccess(r) { i.invalidateQueries({ queryKey: o.readAllIndex() }), t?.(r); }, onError: e }); }, Cn = () => { const e = j(), t = B(e); return ge({ mutationFn(a) { return a?.length ? Promise.all( a.map((o) => t.purge({ documentId: o, withLangVersions: !0 })) ) : t.purge({}); } }); }, ne = () => { const e = j(), t = B(e); return Fe({ queryKey: t.readConfigIndex(), queryFn: t.readConfig }); }, Ro = /* @__PURE__ */ n(fa, {}), lt = ({ isVisible: e = !1, isActionAsync: t = !1, children: a, onConfirm: o, onCancel: i, header: r, labelCancel: d, labelConfirm: c, iconConfirm: m, mainIcon: p = Ro }) => { const { formatMessage: u } = A(); return e ? /* @__PURE__ */ n( Qe.Root, { open: e, onOpenChange: (C) => { !C && e && i?.(void 0); }, title: r || u(l("components.confirmation.dialog.header", "Confirmation")), children: /* @__PURE__ */ w(Qe.Content, { children: [ /* @__PURE__ */ n(Qe.Body, { icon: p, children: /* @__PURE__ */ n(P, { justifyContent: "center", children: /* @__PURE__ */ n(F, { id: "dialog-confirm-description", children: a || u(l("components.confirmation.dialog.description")) }) }) }), /* @__PURE__ */ w(Qe.Footer, { children: [ /* @__PURE__ */ n(Qe.Cancel, { children: /* @__PURE__ */ n(K, { fullWidth: !0, onClick: i, variant: "tertiary", disabled: t, children: d || u(l("components.confirmation.dialog.button.cancel", "Cancel")) }) }), /* @__PURE__ */ n( K, { fullWidth: !0, onClick: o, variant: "danger-light", startIcon: m || /* @__PURE__ */ n(Ge, {}), disabled: t, children: c || u(l("components.confirmation.dialog.button.confirm", "Confirm")) } ) ] }) ] }) } ) : null; }, Qt = /* @__PURE__ */ n(ie, {}), Lo = ({ onConfirm: e, onCancel: t }) => { const { formatMessage: a } = A(); return /* @__PURE__ */ n( lt, { isVisible: !0, header: a(l("pages.view.actions.i18nCopyItems.confirmation.header")), labelConfirm: a(l("pages.view.actions.i18nCopyItems.confirmation.confirm")), iconConfirm: Qt, mainIcon: Qt, onConfirm: e, onCancel: t, children: a(l("pages.view.actions.i18nCopyItems.confirmation.content")) } ); }, $o = (e) => { const [t, a] = N(!1), [o, i] = N(void 0), r = E(() => { a(!1); }, [a]), d = E(() => { o && (e(o), a(!1)); }, [e, o]), c = X( () => t ? /* @__PURE__ */ n(Lo, { onConfirm: d, onCancel: r }) : null, [t, d, r] ); return X( () => ({ setI18nCopyModalOpened: a, setI18nCopySourceLocale: i, i18nCopyItemsModal: c, i18nCopySourceLocale: o }), [i, a, c, o] ); }, Eo = () => { const e = wo(), t = To(); V(() => { e(), t(); }, []); }, Po = ({ cancel: e, perform: t, trigger: a }) => { const o = {}; return { perform: (i) => { const r = i ?? o.value; r && t(r); }, trigger: (i) => { o.value = i, a(); }, cancel: e }; }, Mo = (e, t) => { const a = At(), [o, i] = N(), [r, d] = N(!1), c = X( () => Po({ perform: (p) => { i(p), d(!1), t(!1); }, trigger: () => d(!0), cancel: () => d(!1) }), [i, d] ), m = X( () => (a.data ? [a.data.defaultLocale, ...a.data.restLocale] : []).filter((p) => p !== o), [a.data, o] ); return V(() => { !o && a.data?.defaultLocale && (i(a.data?.defaultLocale), t(!1)); }, [e, o, a.data?.defaultLocale]), { localeData: a.data, currentLocale: o, isChangeLanguageVisible: r, changeCurrentLocaleAction: c, availableLocales: m }; }, ko = (e) => { const [t, a] = N(), [o, i] = N(!1), r = E( (p, u = {}) => { a(u), i(p); }, [i] ), d = E(() => { r(!1); }, [r]), c = E( (p, u, C = !0, b = "", v = !0, h = "0", f = 0) => { e && (p.preventDefault(), p.stopPropagation(), r(!0, { viewParentId: u, isMenuAllowedLevel: C, levelPath: b, parentAttachedToMenu: v, structureId: h, viewId: void 0, order: f + 1 })); }, [r, e] ), m = E( ({ item: p, levelPath: u = "", parentAttachedToMenu: C = !0 }) => { r(!0, { ...p, levelPath: u, parentAttachedToMenu: C }); }, [r] ); return { activeNavigationItem: t, addNewNavigationItem: c, editNavigationItem: m, closeNavigationItemPopup: d, isItemPopupVisible: o }; }, vn = (e, t, a) => { const o = e.reduce((i, r) => { const d = r.items?.length ? vn(r.items ?? [], t) : []; return t(r) ? [r, ...d, ...i] : [...d, ...i]; }, []); if (a !== void 0) { const i = a % o.length; return o.map((r, d) => i === d ? { ...r, isSearchActive: !0 } : r); } return o; }, qo = (e) => { const [{ value: t, index: a }, o] = N({ value: "", index: 0 }), i = Y(t), r = (t || "").toLowerCase(), d = i ? [] : vn( e?.items.map((c) => ({ ...c })) ?? [], (c) => (c?.title || "").toLowerCase().includes(r), r ? a : void 0 ); return { searchValue: t, setSearchValue: o, isSearchEmpty: i, filteredList: d }; }, mt = (e) => `plugin::navigation.${e}`, gt = { read: "read", update: "update", settings: "settings" }, $e = { access: [{ action: mt(gt.read), subject: null }], update: [{ action: mt(gt.update), subject: null }], settings: [{ action: mt(gt.settings), subject: null }] }, Do = () => { const e = X( () => ({ access: $e.access || $e.update, update: $e.update }), [] ), { isLoading: t, allowedActions: { canUpdate: a, canAccess: o } } = On(e); return { canAccess: o, canUpdate: a, isLoadingForPermissions: t }; }, Ze = () => { const { theme: { breakpoints: e } } = Ma(), t = !Pt(e.small), a = an(), o = zn(), i = _n(), r = Pt("@media (min-width: 1280px)"); return { isSmallMobile: t, isMobile: a, isTablet: o, isDesktop: i, isLargeDesktop: r }; }, Ke = (e = []) => Jn(e, ["order"], ["asc"]).map((t, a) => { const o = a + 1; return { ...t, order: o, updated: t.updated || o !== t.order }; }), Ye = (e, t) => e.type === "INTERNAL" ? { type: "INTERNAL", collapsed: !!e.collapsed, id: e.id, documentId: e.documentId, menuAttached: !!e.menuAttached, order: e.order ?? 0, path: e.path, title: e.title, uiRouterKey: e.uiRouterKey, additionalFields: e.additionalFields, audience: e.audience?.map( (a) => t.availableAudience.find((o) => o.documentId === a) ) ?? [], autoSync: e.autoSync, items: e.items?.length ? je(e, e.items, t) : e.items, related: { __type: e.relatedType, documentId: e.related }, viewId: e.viewId, viewParentId: e.viewParentId, structureId: e.structureId, removed: e.removed, updated: e.updated } : e.type === "EXTERNAL" ? { type: "EXTERNAL", collapsed: !!e.collapsed, id: e.id, documentId: e.documentId, menuAttached: !!e.menuAttached, order: e.order ?? 0, title: e.title, uiRouterKey: e.uiRouterKey, additionalFields: e.additionalFields, autoSync: e.autoSync, items: e.items?.length ? je(e, e.items, t) : e.items, path: "", viewId: e.viewId, structureId: e.structureId, viewParentId: e.viewParentId, removed: e.removed, updated: e.updated, externalPath: e.externalPath ?? "", audience: e.audience?.map( (a) => t.availableAudience.find((o) => o.documentId === a) ) ?? [] } : { type: "WRAPPER", collapsed: !!e.collapsed, id: e.id, documentId: e.documentId, menuAttached: !!e.menuAttached, order: e.order ?? 0, path: e.path ?? "", title: e.title, uiRouterKey: e.uiRouterKey, additionalFields: e.additionalFields, audience: e.audience?.map( (a) => t.availableAudience.find((o) => o.documentId === a) ) ?? [], autoSync: e.autoSync, items: e.items?.length ? je(e, e.items, t) : e.items, viewId: e.viewId, viewParentId: e.viewParentId, structureId: e.structureId, removed: e.removed, updated: e.updated }, je = (e, t = [], a) => { if (!e.viewParentId) { if (e.viewId) { const i = t.map((r) => r.viewId === e.viewId ? Ye(e, a) : { ...r, items: r.items?.length ? je(e, r.items, a) : r.items }); return Ke(i); } return [ ...Ke([...t, Ye({ ...e, viewId: Date.now() }, a)]) ]; } const o = t.map((i) => { const r = i.items || []; if (e.viewParentId === i.viewId) { if (!e.viewId) return { ...i, items: [ ...Ke([ ...r, Ye({ ...e, viewId: Date.now() }, a) ]) ] }; const d = r.map((c) => c.viewId === e.viewId ? Ye(e, a) : c); return { ...i, items: Ke(d) }; } return { ...i, items: i.items?.length ? je(e, i.items, a) : i.items }; }); return Ke(o); }, st = (e, t) => { const a = t?.contentTypes ?? [], o = t?.contentTypesNameFields ?? {}, i = o.default ?? [], { __collectionUid: r } = e, d = a.find(({ uid: u }) => u === r); if (d?.isSingle) return d.label; const c = [ ...i, ...i.map((u) => ln(u)) ], m = J( o, `${d ? d.uid : r}`, c ), p = (Y(m) ? c : m).map((u) => e[u]).filter((u) => u); return Ct(p) || ""; }, Vo = ({ relatedRef: e, relatedType: t = {}, type: a, isCollection: o }) => o ? t.available || e.available : a === "INTERNAL" && (e ? "publishedAt" in e : !1) ? J(e, "publishedAt", !0) : !0, Se = (e, t = !1) => { const { __type: a, documentId: o } = e.type === "INTERNAL" && e.related ? e.related : { __type: "", documentId: "" }; return e.type === "INTERNAL" ? { type: "INTERNAL", id: e.id, documentId: e.documentId, additionalFields: e.additionalFields ?? {}, path: e.path ?? "", relatedType: a, related: o, title: e.title, uiRouterKey: e.uiRouterKey, autoSync: e.autoSync ?? void 0, collapsed: e.collapsed, externalPath: void 0, order: e.order ?? 0, menuAttached: e.menuAttached, viewId: e.viewId, viewParentId: e.viewParentId, items: t ? e.items : e.items?.map((i) => Se(i)) ?? void 0, removed: e.removed, updated: e.updated, isSearchActive: e.isSearchActive } : e.type === "EXTERNAL" ? { type: "EXTERNAL", id: e.id, documentId: e.documentId, additionalFields: e.additionalFields ?? {}, title: e.title, uiRouterKey: e.uiRouterKey, autoSync: e.autoSync ?? void 0, collapsed: e.collapsed, externalPath: e.externalPath, order: e.order ?? 0, menuAttached: e.menuAttached, viewId: e.viewId, viewParentId: e.viewParentId, items: t ? e.items : e.items?.map((i) => Se(i)) ?? void 0, removed: e.removed, updated: e.updated, isSearchActive: e.isSearchActive } : { type: "WRAPPER", id: e.id, documentId: e.documentId, additionalFields: e.additionalFields ?? {}, title: e.title, uiRouterKey: e.uiRouterKey, autoSync: e.autoSync ?? void 0, collapsed: e.collapsed, order: e.order ?? 0, menuAttached: e.menuAttached, viewId: e.viewId, viewParentId: e.viewParentId, items: t ? e.items : e.items?.map((i) => Se(i)) ?? void 0, removed: e.removed, updated: e.updated, isSearchActive: e.isSearchActive, path: e.path ?? "" }; }, Tn = (e) => e.find(({ isPending: t }) => t), ke = (e, t) => e.collapsed !== t ? { ...e, collapsed: t, updated: !0, items: e.items?.map((a) => ke(a, t)) } : { ...e, items: e.items?.map((a) => ke(a, t)) }, ze = ({ start: e, end: t }) => /* @__PURE__ */ w(H.Footer, { children: [ /* @__PURE__ */ n(H.Close, { children: Ut(e) }), Ut(t) ] }), Ut = (e) => e ? /* @__PURE__ */ n(K, { onClick: e.onClick, variant: e.variant, disabled: e.disabled, children: e.children }) : null, jo = ({ alreadyUsedNames: e }) => g.object({ name: g.string().min(2).and(g.string().refine((t) => !e.includes(t), "Name already used")), // TODO: add translation visible: g.boolean() }), wn = ({ navigation: e, onChange: t, alreadyUsedNames: a = [], isLoading: o }) => { const [i, r] = N({}), [d, c] = N(), { formatMessage: m } = A(), { name: p, visible: u } = i, C = (h, f, I) => { if (I) { let y = h, T = f; if (He(h)) { const { name: L, value: z } = h.target; y = L, T = Be(T) ? z : T; } return ot(y) && b(y, T), I(h, T); } }, b = (h, f) => { r( it( { ...i }, h, f ) ); }, v = (h) => { const f = J(d, h); if (f) return f; }; return V(() => { e && (e.name ? r({ ...e }) : (r({ name: "New navigation", visible: !0 }), t({ name: "New navigation", visible: !0, disabled: !0 }))); }, []), V(() => { if (`${p}-${u}` != `${e.name}-${e.visible}`) { const { error: h } = jo({ alreadyUsedNames: a }).safeParse(i); t({ ...e, name: p, visible: u, disabled: !Y(h?.issues) }), c( h ? h.issues.reduce((f, I) => ({ ...f, [I.path.join(".")]: I.message }), {}) : void 0 ); } }, [p, u]), /* @__PURE__ */ n(at, { width: "auto", height: "auto", method: "POST", initialValues: i, children: ({ values: h, onChange: f }) => /* @__PURE__ */ w(S.Root, { gap: 5, children: [ /* @__PURE__ */ n(S.Item, { m: 6, xs: 12, children: /* @__PURE__ */ n( $, { name: "name", label: m(l("popup.navigation.form.name.label", "Name")), error: v("name"), children: /* @__PURE__ */ n( we, { name: "name", type: "string", placeholder: m( l("popup.navigation.form.name.placeholder", "Navigations's name") ), onChange: (I, y) => C(I, y, f), value: h.name, disabled: o } ) } ) }), /* @__PURE__ */ n(S.Item, { m: 6, xs: 12, children: /* @__PURE__ */ n( $, { name: "visible", label: m(l("popup.navigation.form.visible.label", "Visibility")), error: v("visible"), children: /* @__PURE__ */ n( me, { name: "visible", checked: h.visible, onChange: (I) => C(I, !h.visible, f), onLabel: m(l("popup.navigation.form.visible.toggle.visible")), offLabel: m(l("popup.navigation.form.visible.toggle.hidden")), disabled: o, width: "100%" } ) } ) }) ] }) }); }, Bo = { name: "", items: [], visible: !1 }, Oo = ({ setState: e, current: t, isLoading: a, alreadyUsedNames: o }) => { const i = E( ({ disabled: r, ...d }) => { e({ view: "CREATE", current: d, alreadyUsedNames: o, disabled: r }); }, [e] ); return /* @__PURE__ */ n( wn, { alreadyUsedNames: o, navigation: t, onChange: i, isLoading: a } ); }, zo = ({ onSubmit: e, onReset: t, disabled: a, isLoading: o }) => { const { formatMessage: i } = A(); return /* @__PURE__ */ n( ze, { start: { children: i(l("popup.item.form.button.cancel")), variant: "tertiary", disabled: o, onClick: t }, end: { children: i(l("popup.navigation.manage.button.save")), variant: "default", disabled: o || a, onClick: e } } ); }, _o = /* @__PURE__ */ n(vt, {}), Qo = /* @__PURE__ */ n(Tt, {}), Kt = /* @__PURE__ */ n(ya, {}), Uo = ({ navigations: e, selected: t, setState: a }) => { const o = ne(), i = !!t.length, { formatMessage: r } = A(), d = At(), c = E( () => a({ navigations: e, selected: i ? [] : e.map((I) => I), view: "LIST" }), [a, e, i] ), m = X(() => new Set(t.map(nt("documentId"))), [t]), p = (I, y) => () => { a({ navigations: e, selected: y ? t.filter(({ documentId: T }) => T !== I.documentId) : t.concat([I]), view: "LIST" }); }, u = (I) => () => { a({ view: "EDIT", current: I, navigation: I, alreadyUsedNames: e.reduce( (y, { name: T }) => T !== I.name ? y.concat([T]) : y, [] ) }); }, C = (I) => () => { a({ view: "DELETE", navigations: I }); }, b = (I) => () => { a({ view: "CACHE_PURGE", navigations: I }); }, v = E(C(t), [C]), h = E(b(t), [b]), f = (I) => [I].concat( e.filter( (y) => y.documentId === I.documentId && y.locale !== I.locale ) ); return /* @__PURE__ */ w(ie, { children: [ /* @__PURE__ */ n(S.Root, { children: /* @__PURE__ */ n(S.Item, { col: 12, paddingBottom: 3, children: i ? /* @__PURE__ */ w(P, { direction: "row", gap: 1, children: [ /* @__PURE__ */ n(D, { paddingRight: 3, children: r(l("popup.navigation.manage.table.hasSelected"), { count: t.length }) }), /* @__PURE__ */ n(K, { onClick: v, variant: "tertiary", children: r(l("popup.navigation.manage.button.delete")) }), o.data?.isCacheEnabled ? /* @__PURE__ */ n(K, { onClick: h, variant: "tertiary", children: r(l("popup.navigation.manage.button.purge")) }) : null ] }) : null }) }), /* @__PURE__ */ w(sn, { rowCount: e.length, colCount: 6, children: [ /* @__PURE__ */ n(dn, { children: /* @__PURE__ */ w(et, { children: [ /* @__PURE__ */ n(ce, { children: /* @__PURE__ */ n(qt, { onCheckedChange: c, check: i }) }), /* @__PURE__ */ n(ce, { children: /* @__PURE__ */ n(F, { textColor: "neutral800", children: r(l("popup.navigation.manage.table.id")) }) }), /* @__PURE__ */ n(ce, { children: /* @__PURE__ */ n(F, { textColor: "neutral800", children: r(l("popup.navigation.manage.table.name")) }) }), /* @__PURE__ */ n(ce, { children: /* @__PURE__ */ n(F, { textColor: "neutral800", children: r(l("popup.navigation.manage.table.locale")) }) }), /* @__PURE__ */ n(ce, { children: /* @__PURE__ */ n(F, { textColor: "neutral800", children: r(l("popup.navigation.manage.table.visibility")) }) }), /* @__PURE__ */ n(ce, { children: o.data?.isCacheEnabled ? /* @__PURE__ */ n(P, { direction: "row", children: /* @__PURE__ */ n(D, { paddingLeft: 1, children: /* @__PURE__ */ n( ye, { onClick: b([]), label: r(l("popup.navigation.manage.button.purge")), noBorder: !0, children: Kt } ) }) }) : null }) ] }) }), /* @__PURE__ */ n(cn, { children: e.filter(({ locale: I }) => I === d.data?.defaultLocale).map((I) => /* @__PURE__ */ w(et, { children: [ /* @__PURE__ */ n(ue, { children: /* @__PURE__ */ n( qt, { onCheckedChange: p( I, m.has(I.documentId) ), checked: m.has(I.documentId) } ) }), /* @__PURE__ */ n(ue, { children: /* @__PURE__ */ n(F, { textColor: "neutral800", children: I.documentId }) }), /* @__PURE__ */ n(ue, { children: /* @__PURE__ */ n(F, { textColor: "neutral800", children: I.name }) }), /* @__PURE__ */ n(ue, { children: /* @__PURE__ */ n(F, { textColor: "neutral800", children: f(I).map(nt("locale")).join(", ") }) }), /* @__PURE__ */ n(ue, { children: /* @__PURE__ */ n(F, { textColor: "neutral800", children: I.visible ? r(l("popup.navigation.manage.navigation.visible")) : r(l("popup.navigation.manage.navigation.hidden")) }) }), /* @__PURE__ */ n(ue, { children: /* @__PURE__ */ w(P, { width: "100%", direction: "row", alignItems: "center", justifyContent: "flex-end", children: [ /* @__PURE__ */ n(D, { paddingLeft: 1, children: /* @__PURE__ */ n( ye, { onClick: u(I), label: r(l("popup.navigation.manage.button.edit")), noBorder: !0, children: _o } ) }), /* @__PURE__ */ n(D, { paddingLeft: 1, children: /* @__PURE__ */ n( ye, { onClick: C([I]), label: r(l("popup.navigation.manage.button.delete")), noBorder: !0, children: Qo } ) }), o.data?.isCacheEnabled ? /* @__PURE__ */ n(D, { paddingLeft: 1, children: /* @__PURE__ */ n( ye, { onClick: b([I]), label: r(l("popup.navigation.manage.button.purge")), noBorder: !0, children: Kt } ) }) : null ] }) }) ] }, I.documentId)) }) ] }) ] }); }, Ko = ({ onClose: e, state: t, setState: a, navigations: o, isLoading: i }) => { const { formatMessage: r } = A(); return /* @__PURE__ */ n( ze, { start: { onClick: e, variant: "tertiary", disabled: i, children: r(l("popup.item.form.button.cancel")) }, end: { onClick: () => a({ view: "CREATE", alreadyUsedNames: o.map(({ name: d }) => d), current: Bo }), variant: "default", disabled: i, children: r(l("popup.navigation.manage.button.create")) } } ); }, Wo = ({ navigations: e }) => { const { formatMessage: t } = A(); return /* @__PURE__ */ w(S.Root, { children: [ /* @__PURE__ */ n(S.Item, { col: 12, paddingBottom: 1, children: /* @__PURE__ */ n(P, { children: /* @__PURE__ */ n(F, { variant: "beta", children: t(l("popup.navigation.manage.delete.header")) }) }) }), /* @__PURE__ */ n(S.Item, { col: 12, paddingBottom: 1, children: /* @__PURE__ */ n(F, { variant: "omega", fontWeight: "semiBold", children: Xo(e) }) }) ] }); }, Ho = ({ state: e, onSubmit: t, onReset: a, isLoading: o }) => { const { formatMessage: i } = A(); return /* @__PURE__ */ n( ze, { start: { children: i(l("popup.item.form.button.cancel")), disabled: o, onClick: a, variant: "tertiary" }, end: { children: i(l("popup.navigation.manage.button.delete")), disabled: o, onClick: t, variant: "danger" } } ); }, Xo = (e) => e.map(nt("name")).join(", "), Go = ({ errors: e }) => { const { formatMessage: t } = A(), { toggleNotification: a } = Oe(); return V(() => { e.map((o) => { a({ type: "warning", message: t({ id: "", defaultMessage: o.message }) }), console.error(o); }); }, []), /* @__PURE__ */ n(S.Root, { children: /* @__PURE__ */ n(S.Item, { col: 12, children: t(l("popup.navigation.manage.error.message")) }) }); }, Zo = ({ onReset: e }) => { const { formatMessage: t } = A(); return /* @__PURE__ */ n( ze, { end: { children: t(l("popup.navigation.manage.button.goBack")), onClick: e, variant: "secondary" } } ); }, Jo = ({ alreadyUsedNames: e, current: t, isLoading: a, navigation: o, setState: i }) => { const r = X(() => t ?? o, [t]), d = E( ({ disabled: c, ...m }) => { i({ view: "EDIT", alreadyUsedNames: e, current: m, disabled: c, navigation: o }); }, [i, o, e] ); return /* @__PURE__ */ n( wn, { navigation: r, onChange: d, isLoading: a, alreadyUsedNames: e } ); }, Yo = ({ onSubmit: e, onReset: t, disabled: a, isLoading: o }) => { const { formatMessage: i } = A(); return /* @__PURE__ */ n( ze, { start: { children: i(l("popup.item.form.button.cancel")), disabled: o, onClick: t, variant: "tertiary" }, end: { children: i(l("popup.navigation.manage.button.save")), disabled: o || a, onClick: e, variant: "secondary" } } ); }, ei = ({ navigations: e }) => { const { formatMessage: t } = A(); return /* @__PURE__ */ w(S.Root, { children: [ /* @__PURE__ */ n(S.Item, { col: 12, paddingBottom: 1, children: /* @__PURE__ */ n(P, { children: /* @__PURE__ */ n(F, { variant: "beta", children: t(l("popup.navigation.manage.purge.header")) }) }) }), /* @__PURE__ */ n(S.Item, { col: 12, paddingBottom: 1, children: /* @__PURE__ */ n(F, { variant: "omega", fontWeight: "semiBold", children: ni(e) }) }) ] }); }, ti = ({ onSubmit: e, onReset: t, isLoading: a }) => { const { formatMessage: o } = A(); return /* @__PURE__ */ n( ze, { start: { children: o(l("popup.item.form.button.cancel")), disabled: a, onClick: t, variant: "tertiary" }, end: { children: o(l("popup.navigation.manage.footer.button.purge")), disabled: a, onClick: e, variant: "danger" } } ); }, ni = (e) => e.map(nt("name")).join(", "), ai = ({ initialState: e, isOpened: t, onClose: a }) => { const { formatMessage: o } = A(), [i, r] = N(e), { toggleNotification: d } = Oe(), c = So(), m = xo(), p = No(), u = In({}), C = Cn(), b = Ft(), v = At(), h = X( () => Xe(b.data ?? [], "id"), [b.data] ), f = Tn([ m, b, p, u, C, v ]), I = E(() => r({ view: "INITIAL" }), [r]), y = E(async () => { const k = i.view === "DELETE" ? () => { m.mutate( i.navigations.reduce((x, M) => (M.documentId && x.push(M.documentId), x), []), { onSuccess: c } ); } : i.view === "EDIT" ? () => { u.mutate(i.current, { onSuccess() { c(), d({ type: "success", message: o(l("notification.navigation.submit")) }); }, onError(x) { console.warn(x), d({ type: "warning", message: o(l("notification.navigation.error"), { errorTitles: "" }) }); } }); } : i.view === "CREATE" && i.current ? () => { p.mutate(i.current, { onSuccess() { c(), d({ type: "success", message: o(l("notification.navigation.submit")) }); }, onError(x) { console.warn(x), d({ type: "warning", message: o(l("notification.navigation.error"), { errorTitles: "" }) }); } }); } : i.view === "CACHE_PURGE" ? () => { C.mutate( i.navigations.reduce((x, M) => (M.documentId && x.push(M.documentId), x), []), { onSuccess: c } ); } : () => { }; try { k(), r({ view: "INITIAL" }); } catch (x) { r({ view: "ERROR", errors: x instanceof Error ? [x] : [] }); } }, [ i, r, c, p, C, u, m, d, o, l ]); V(() => { (i.view === "INITIAL" || i.view === "LIST") && r({ view: "LIST", navigations: h, selected: [] }); }, [i.view, h]); const T = oi(i, o, !!f), L = ii(i, r, !!f), z = ri({ state: i, setState: r, onClose: a, onSubmit: y, onReset: I, navigations: h, isLoading: !!f }); return /* @__PURE__ */ n( H.Root, { labelledBy: "condition-modal-breadcrumbs", onOpenChange: (k) => { k || a?.(); }, open: t, children: /* @__PURE__ */ w(H.Content, { children: [ /* @__PURE__ */ n(H.Header, { children: /* @__PURE__ */ n(F, { variant: "omega", fontWeight: "bold", textColor: "neutral800", as: "h2", children: T }) }), /* @__PURE__ */ n(H.Body, { children: L }), z ] }) } ); }, oi = (e, t, a) => { switch (e.view) { case "LIST": case "CREATE": case "ERROR": case "CACHE_PURGE": case "DELETE": return /* @__PURE__ */ w(P, { direction: "row", children: [ a ? /* @__PURE__ */ n(bt, { small: !0 }) : null, t(l(`popup.navigation.manage.header.${e.view}`)) ] }); case "EDIT": return /* @__PURE__ */ w(P, { direction: "row", children: [ a ? /* @__PURE__ */ n(bt, { small: !0 }) : null, t(l("popup.navigation.manage.header.EDIT"), { name: e.navigation.name }) ] }); case "INITIAL": return null; default: return Nt(e); } }, ii = (e, t, a) => { const o = { setState: t, isLoading: a }; switch (e.view) { case "LIST": return /* @__PURE__ */ n(Uo, { ...e, ...o }); case "EDIT": return /* @__PURE__ */ n(Jo, { ...e, ...o }); case "CREATE": return /* @__PURE__ */ n(Oo, { ...e, ...o }); case "DELETE": return /* @__PURE__ */ n(Wo, { ...e, ...o }); case "CACHE_PURGE": return /* @__PURE__ */ n(ei, { ...e, ...o }); case "INITIAL": return /* @__PURE__ */ n(bt, { small: !0 }); case "ERROR": return /* @__PURE__ */ n(Go, { ...e, ...o }); default: return Nt(e); } }, ri = (e) => { switch (e.state.view) { case "LIST": return /* @__PURE__ */ n(Ko, { ...e }); case "CREATE": return /* @__PURE__ */ n(zo, { ...e, disabled: e.state.disabled }); case "EDIT": return /* @__PURE__ */ n(Yo, { ...e, disabled: e.state.disabled }); case "DELETE": return /* @__PURE__ */ n(Ho, { ...e }); case "CACHE_PURGE": return /* @__PURE__ */ n(ti, { ...e }); case "ERROR": return /* @__PURE__ */ n(Zo, { ...e }); case "INITIAL": return null; default: return Nt(e.state); } }, Nt = (e) => (console.warn(`Unknown state "${e?.view}". (${JSON.stringify(e)})`), null), li = () => { const [e, t] = N(!1), a = E(() => t(!0), [t]), o = E(() => t(!1), [t]), i = X( () => e ? /* @__PURE__ */ n(ai, { initialState: { view: "INITIAL" }, isOpened: !0, onClose: o }) : null, [e, o] ); return X( () => ({ navigationManagerModal: i, openNavigationManagerModal: a, closeNavigationManagerModal: o }), [i, a, o] ); }, Me = oe(S.Item)` order: ${({ orderInitial: e }) => e ?? "unset"}; @media (min-width: 520px) { order: ${({ orderSmall: e }) => e ?? "unset"}; } @media (min-width: 768px) { order: ${({ orderMedium: e }) => e ?? "unset"}; } `, Wt = /* @__PURE__ */ n(Ge, {}), si = ({ activeNavigation: e, availableNavigations: t, structureHasErrors: a, structureHasChanged: o, isSaving: i, handleChangeSelection: r, handleLocalizationSelection: d, handleSave: c, handleCachePurge: m, permissions: p = {}, locale: u, currentLocale: C }) => { const { formatMessage: b } = A(), { openNavigationManagerModal: v, navigationManagerModal: h } = li(), f = ne(), I = !!u.restLocale?.length, y = f.data?.isCacheEnabled, { canUpdate: T } = p, { isDesktop: L, isMobile: z, isLargeDesktop: k } = Ze(); return /* @__PURE__ */ n(ie, { children: /* @__PURE__ */ n( qe.Header, { title: b(l("header.title", "UI Navigation")), subtitle: k && b(l("header.description")), primaryAction: /* @__PURE__ */ w( P, { direction: "row", size: 2, width: k ? "auto" : z ? "100%" : "728px", children: [ /* @__PURE__ */ n(D, { width: "100%", children: /* @__PURE__ */ w( S.Root, { gap: { initial: 2, medium: 4 }, width: "100%", style: f.data?.isCacheEnabled ? { display: "flex" } : void 0, children: [ !I && k ? /* @__PURE__ */ n(S.Item, { m: 2, xs: 0 }) : null, T && /* @__PURE__ */ n( Me, { m: 3, xs: y ? 4 : 6, orderInitial: 3, orderSmall: 3, orderMedium: 1, children: /* @__PURE__ */ n( K, { onClick: v, startIcon: null, type: "button", variant: "secondary", fullWidth: !0, size: "S", children: b(l("header.action.manage")) } ) } ), /* @__PURE__ */ n( Me, { m: T ? 4 : 10, xs: I ? 9 : 12, orderInitial: 1, orderSmall: 1,