@sensinum/strapi-plugin-xecp 5.0.0 → 5.0.1

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.
@@ -1,1927 +0,0 @@
1
- import { jsx as n, jsxs as u, Fragment as K } from "react/jsx-runtime";
2
- import { useFetchClient as M, useRBAC as Ct, useQueryParams as bt, Page as W, Layouts as He, Pagination as Te } from "@strapi/strapi/admin";
3
- import { Link as Re, Routes as It, Route as Ve } from "react-router-dom";
4
- import { U as _, g as a, P as xe } from "./index-pRp3V-Jg.mjs";
5
- import { L as wt, S as Et, P as Tt, Q as vt } from "./queryKeys-rUHP1d6p.mjs";
6
- import { Combobox as kt, ComboboxOption as xt, Modal as B, Button as T, Flex as P, Typography as h, Link as qe, EmptyStateLayout as z, Tooltip as Le, Checkbox as _e, Badge as ee, Table as Ke, Thead as De, Tr as V, Th as N, Tbody as Ae, Td as v, Accordion as q, Divider as Mt, Box as Rt, ProgressBar as qt, Loader as ve } from "@strapi/design-system";
7
- import { WarningCircle as Be, Information as Lt } from "@strapi/icons";
8
- import { useState as L, useEffect as oe, Fragment as _t, useMemo as Ze, useRef as We, useCallback as Ye } from "react";
9
- import { useIntl as S } from "react-intl";
10
- import ae from "zod";
11
- import { A as k, T as Y } from "./TruncatedTypography-Df3hMZdB.mjs";
12
- import { useQuery as $, useQueryClient as re, useMutation as ue } from "@tanstack/react-query";
13
- import Ne from "styled-components";
14
- const Kt = 120 * 1e3, Dt = () => {
15
- const { get: e } = M();
16
- return $({
17
- queryKey: [wt, "status"],
18
- staleTime: Kt,
19
- queryFn: async () => {
20
- const { data: t } = await e(`/${_}/license/status`);
21
- return t;
22
- }
23
- });
24
- }, je = (e, t) => t ? e.find((o) => o.value === t)?.label ?? "" : "", At = ({ name: e, onClear: t, onChange: o, options: r, value: i, placeholder: s, disabled: l }) => {
25
- const [c, d] = L(() => je(r, i));
26
- return oe(() => {
27
- d(je(r, i));
28
- }, [i, r]), /* @__PURE__ */ n(
29
- kt,
30
- {
31
- name: e,
32
- autocomplete: "list",
33
- onClear: t,
34
- onChange: o,
35
- placeholder: s,
36
- onTextValueChange: d,
37
- value: i,
38
- textValue: c,
39
- disabled: l,
40
- width: "100%",
41
- children: r.map(({ key: m, label: p, value: f }) => /* @__PURE__ */ n(xt, { value: f, children: p }, m))
42
- }
43
- );
44
- }, Bt = "90vh", me = ({
45
- open: e,
46
- onClose: t,
47
- title: o,
48
- children: r,
49
- isConfirmButtonLoading: i = !1,
50
- confirmButtonText: s,
51
- isConfirmButtonDisabled: l = !1,
52
- onSubmit: c,
53
- cancelButtonText: d,
54
- showConfirmButton: m = !0,
55
- fillMaxHeight: p = !1
56
- }) => {
57
- const { formatMessage: f } = S();
58
- return /* @__PURE__ */ n(B.Root, { open: e, onOpenChange: () => t(), children: /* @__PURE__ */ u(B.Content, { style: p ? { height: Bt } : void 0, children: [
59
- /* @__PURE__ */ n(B.Header, { children: /* @__PURE__ */ n(B.Title, { children: o }) }),
60
- /* @__PURE__ */ n(B.Body, { children: r }),
61
- /* @__PURE__ */ n(B.Footer, { style: m ? void 0 : { justifyContent: "flex-end" }, children: m ? /* @__PURE__ */ u(K, { children: [
62
- /* @__PURE__ */ n(B.Close, { children: /* @__PURE__ */ n(T, { variant: "tertiary", onClick: t, children: d || f({ id: a("common.button.close") }) }) }),
63
- /* @__PURE__ */ n(
64
- T,
65
- {
66
- loading: i,
67
- disabled: l,
68
- onClick: c,
69
- children: s || f({ id: a("common.button.submit") })
70
- }
71
- )
72
- ] }) : /* @__PURE__ */ n(B.Close, { children: /* @__PURE__ */ n(T, { variant: "tertiary", onClick: t, children: d || f({ id: a("common.button.close") }) }) }) })
73
- ] }) });
74
- }, ze = (e) => /^[\w]+(?:\.[\w]+)+$/.test(e), Nt = (e) => {
75
- if (typeof e != "object" || e === null)
76
- return;
77
- const t = e.response?.data?.error?.message;
78
- if (typeof t == "string")
79
- return t;
80
- const o = e.message;
81
- return typeof o == "string" ? o : void 0;
82
- }, ge = (e, t) => {
83
- const o = Nt(e);
84
- return o && ze(o) ? t({ id: a(o) }) : t({ id: a("homePage.error") });
85
- }, Ft = (e, t) => e && ze(e) ? t({ id: a(e) }) : null, te = {
86
- all: ["sync"],
87
- lists: () => [...te.all, "list"],
88
- list: (e) => [...te.lists(), { uid: e }]
89
- }, et = "entities-comparison", Ot = ({
90
- uid: e,
91
- page: t = 1,
92
- pageSize: o = 10,
93
- enabled: r = !0
94
- }) => {
95
- const { get: i } = M();
96
- return $({
97
- queryKey: [et, { uid: e, page: t, pageSize: o }],
98
- queryFn: async () => {
99
- const { data: s } = await i(
100
- `/${_}/entity-comparison/${e}?page=${t}&pageSize=${o}`
101
- );
102
- return s;
103
- },
104
- enabled: !!e && r
105
- });
106
- }, tt = (e) => {
107
- e.invalidateQueries({ queryKey: [et] });
108
- }, he = (e, t) => {
109
- e.invalidateQueries({ queryKey: t ? te.list(t) : te.lists() }), tt(e);
110
- }, Ut = () => {
111
- const { post: e } = M(), t = re();
112
- return ue({
113
- mutationFn: async (o) => await e(`/${_}/snapshot/${o}/sync`),
114
- onSuccess: (o, r) => {
115
- he(t, r);
116
- }
117
- });
118
- }, nt = ({ open: e, onClose: t, contentTypeUid: o }) => {
119
- const { formatMessage: r } = S(), {
120
- mutate: i,
121
- isPending: s,
122
- error: l,
123
- reset: c
124
- } = Ut();
125
- return /* @__PURE__ */ n(
126
- me,
127
- {
128
- open: e,
129
- onClose: () => {
130
- t(), c();
131
- },
132
- onSubmit: () => {
133
- i(o, {
134
- onSuccess: t
135
- });
136
- },
137
- title: r({
138
- id: a("homePage.modal.getNewSnapshot.title")
139
- }),
140
- confirmButtonText: r({
141
- id: a("homePage.modal.getNewSnapshot.confirmButtonText")
142
- }),
143
- isConfirmButtonDisabled: s || !o,
144
- isConfirmButtonLoading: s,
145
- children: /* @__PURE__ */ u(P, { direction: "column", gap: 4, alignItems: "stretch", children: [
146
- /* @__PURE__ */ n(h, { variant: "omega", children: r({
147
- id: a("homePage.modal.getNewSnapshot.description")
148
- }) }),
149
- l && /* @__PURE__ */ n(h, { variant: "omega", textColor: "danger500", children: ge(l, r) })
150
- ] })
151
- }
152
- );
153
- }, $t = ({
154
- contentTypeUid: e,
155
- selectedPromotionsLength: t,
156
- syncedAt: o,
157
- isGetSnapshotDisabled: r = !1,
158
- hasSnapshot: i,
159
- clearSelectedPromotions: s,
160
- canExecute: l
161
- }) => {
162
- const { formatMessage: c } = S(), [d, m] = L(!1);
163
- return /* @__PURE__ */ u(
164
- P,
165
- {
166
- direction: "row",
167
- justifyContent: "space-between",
168
- alignItems: "center",
169
- marginBottom: 1,
170
- marginTop: 1,
171
- children: [
172
- e && i ? /* @__PURE__ */ u(P, { direction: "row", gap: 3, alignItems: "center", children: [
173
- /* @__PURE__ */ n(h, { variant: "omega", children: c(
174
- { id: a("homePage.selectedEntities") },
175
- { count: t }
176
- ) }),
177
- t > 0 && l ? /* @__PURE__ */ n(T, { variant: "secondary", onClick: s, children: c({ id: a("homePage.clearSelectedEntities") }) }) : null
178
- ] }) : null,
179
- o ? /* @__PURE__ */ u(P, { direction: "row", gap: 3, alignItems: "center", children: [
180
- /* @__PURE__ */ n(h, { variant: "omega", textColor: "neutral600", children: c(
181
- { id: a("homePage.lastSync") },
182
- {
183
- lastSync: new Date(o).toLocaleString()
184
- }
185
- ) }),
186
- l ? /* @__PURE__ */ n(
187
- T,
188
- {
189
- variant: "secondary",
190
- onClick: () => m(!0),
191
- disabled: r,
192
- children: c({
193
- id: a("homePage.getNewSnapshot")
194
- })
195
- }
196
- ) : null
197
- ] }) : null,
198
- l ? /* @__PURE__ */ n(
199
- nt,
200
- {
201
- open: d,
202
- onClose: () => m(!1),
203
- contentTypeUid: e
204
- }
205
- ) : null
206
- ]
207
- }
208
- );
209
- }, Gt = ({ canReadSettings: e }) => {
210
- const { formatMessage: t } = S();
211
- return /* @__PURE__ */ n(
212
- k,
213
- {
214
- title: t({ id: a("homePage.alert.invalidLicense.title") }),
215
- variant: "danger",
216
- description: t({
217
- id: a(
218
- e ? "homePage.alert.invalidLicense.description" : "homePage.alert.invalidLicense.readOnlyDescription"
219
- )
220
- }),
221
- action: e ? /* @__PURE__ */ n(P, { children: /* @__PURE__ */ n(qe, { tag: Re, to: "/settings/xecp/about", children: t({ id: a("homePage.alert.invalidLicense.linkText") }) }) }) : void 0
222
- }
223
- );
224
- }, Qt = ({ compareSchemasData: e, errorCompareSchemas: t }) => {
225
- const { formatMessage: o } = S(), r = e && !e?.isMatch, i = () => o(r ? { id: a("homePage.alert.schemaMismatch.title") } : { id: a("homePage.error") }), s = () => {
226
- switch (!0) {
227
- case r:
228
- return o({ id: a("homePage.alert.schemaMismatch.description") });
229
- case !!t:
230
- return t;
231
- default:
232
- return o({ id: a("homePage.somethingWentWrong") });
233
- }
234
- };
235
- return /* @__PURE__ */ n(k, { title: i(), variant: "danger", children: s() });
236
- }, Ht = ({
237
- contentTypeUid: e,
238
- hasExistingSnapshot: t,
239
- unconfiguredRelationsError: o,
240
- isGetSnapshotDisabled: r = !1,
241
- canExecute: i,
242
- canReadSettings: s
243
- }) => {
244
- const { formatMessage: l } = S(), [c, d] = L(!1);
245
- return !t && !o ? /* @__PURE__ */ u(K, { children: [
246
- /* @__PURE__ */ n(
247
- z,
248
- {
249
- content: l({
250
- id: a(
251
- i ? "homePage.alert.noSync.description" : "homePage.alert.noSync.readOnlyDescription"
252
- )
253
- }),
254
- action: i ? /* @__PURE__ */ n(
255
- T,
256
- {
257
- onClick: () => d(!0),
258
- disabled: r,
259
- children: l({ id: a("homePage.alert.noSync.linkText") })
260
- }
261
- ) : void 0
262
- }
263
- ),
264
- i ? /* @__PURE__ */ n(
265
- nt,
266
- {
267
- open: c,
268
- onClose: () => d(!1),
269
- contentTypeUid: e
270
- }
271
- ) : null
272
- ] }) : /* @__PURE__ */ u(K, { children: [
273
- o ? /* @__PURE__ */ n(
274
- k,
275
- {
276
- title: l({
277
- id: a("homePage.alert.unconfiguredRelations.title")
278
- }),
279
- variant: "danger",
280
- action: s ? /* @__PURE__ */ n(qe, { tag: Re, to: "/settings/xecp/configuration", children: l({
281
- id: a("homePage.alert.unconfiguredRelations.linkText")
282
- }) }) : void 0,
283
- description: l(
284
- {
285
- id: a(
286
- s ? "homePage.alert.unconfiguredRelations.description" : "homePage.alert.unconfiguredRelations.readOnlyDescription"
287
- )
288
- },
289
- { relations: o.unconfiguredRelations.join(", ") }
290
- )
291
- }
292
- ) : null,
293
- /* @__PURE__ */ n(z, { content: l({ id: a("homePage.emptyState") }) })
294
- ] });
295
- }, Fe = (e) => [
296
- e,
297
- ...e.localizations ?? []
298
- ], ot = (e) => (e ?? []).flatMap(Fe), Vt = (e, t) => {
299
- const o = t?.find((r) => r.documentId === e);
300
- return o ? Fe(o) : [];
301
- }, Yt = (e) => {
302
- const t = e[0];
303
- return t ? {
304
- ...t,
305
- localizations: e.slice(1)
306
- } : null;
307
- }, pe = (e, t) => {
308
- if (!t) return e.uniqueKeyValue;
309
- const o = e?.[t];
310
- return typeof o == "string" || typeof o == "number" ? String(o) : e.uniqueKeyValue;
311
- }, se = (e) => ({
312
- documentId: e.documentId,
313
- locale: e.locale ?? "default"
314
- }), ne = (e, t) => e.documentId === t.documentId && e.locale === t.locale, ce = (e, t) => t.some((o) => ne(o, se(e))), jt = (e) => [...new Set(e.map((t) => t.documentId))], Xt = (e, t) => {
315
- if (e.length === 0)
316
- return !1;
317
- const o = e.filter((r) => t.has(r)).length;
318
- return o === 0 ? !1 : o === e.length ? !0 : "indeterminate";
319
- }, Jt = (e, t) => {
320
- const o = new Set(t);
321
- return new Set([...e].filter((r) => o.has(r)));
322
- }, Zt = "homePage.missingUniqueKey", le = {
323
- single: "homePage.hint.missingUniqueKey.single",
324
- allLocales: "homePage.hint.missingUniqueKey.allLocales",
325
- someLocales: "homePage.hint.missingUniqueKey.someLocales"
326
- }, j = (e, t) => e !== "up_to_date" && t !== "missing_unique_key", Wt = (e) => {
327
- switch (!0) {
328
- case e.every((t) => t.warning === "missing_unique_key"):
329
- return "allLocales";
330
- case e.some((t) => t.warning === "missing_unique_key"):
331
- return "someLocales";
332
- default:
333
- return null;
334
- }
335
- }, rt = (e, t, o) => {
336
- if (!e)
337
- return "homePage.tooltip.noExecutePermission";
338
- switch (!0) {
339
- case t === "up_to_date":
340
- return "homePage.tooltip.upToDate";
341
- case o === "missing_unique_key":
342
- return le.single;
343
- default:
344
- return null;
345
- }
346
- }, it = (e, t) => {
347
- if (!e)
348
- return "homePage.tooltip.noExecutePermission";
349
- switch (!0) {
350
- case t.some((o) => j(o.status, o.warning)):
351
- return null;
352
- case t.every((o) => o.status === "up_to_date"):
353
- return "homePage.tooltip.allEntitiesUpToDate";
354
- case t.every((o) => o.warning === "missing_unique_key"):
355
- return le.allLocales;
356
- default:
357
- return le.someLocales;
358
- }
359
- }, Me = ({
360
- checked: e,
361
- onCheckedChange: t,
362
- disable: o = !1,
363
- tooltipLabel: r = ""
364
- }) => /* @__PURE__ */ n("div", { onClick: (i) => i.stopPropagation(), children: /* @__PURE__ */ n(Le, { label: o ? r : "", align: "start", children: /* @__PURE__ */ n(_e, { checked: e, onCheckedChange: t, disabled: o }) }) }), ye = ({ locale: e }) => {
365
- const { formatMessage: t } = S();
366
- return e === "default" ? /* @__PURE__ */ n(ee, { variant: "neutral", children: t({ id: a("homePage.promotionResults.locale.nonLocalized") }) }) : /* @__PURE__ */ n(ee, { variant: "neutral", children: e });
367
- }, zt = (e) => {
368
- switch (e) {
369
- case "new":
370
- return "homePage.table.status.new";
371
- case "changed":
372
- return "homePage.table.status.changed";
373
- case "up_to_date":
374
- return "homePage.table.status.upToDate";
375
- default:
376
- return "homePage.table.status.new";
377
- }
378
- }, en = (e) => {
379
- switch (e) {
380
- case "new":
381
- return "success";
382
- case "changed":
383
- return "danger";
384
- case "up_to_date":
385
- return "neutral";
386
- default:
387
- return "success";
388
- }
389
- }, at = ({ status: e }) => {
390
- const { formatMessage: t } = S();
391
- return /* @__PURE__ */ n(ee, { variant: en(e), children: t({
392
- id: a(zt(e))
393
- }) });
394
- }, tn = ({ shouldShow: e, message: t, tooltipLabel: o }) => e ? /* @__PURE__ */ n(Le, { label: o, align: "start", children: /* @__PURE__ */ u(P, { direction: "row", gap: 1, alignItems: "center", children: [
395
- /* @__PURE__ */ n(Be, { fill: "warning500", width: 20, height: 20 }),
396
- /* @__PURE__ */ n(h, { variant: "pi", textColor: "warning500", children: t })
397
- ] }) }) : null, fe = ({ uniqueKey: e, missingUniqueKeyScope: t, maxCharacters: o = 40 }) => {
398
- const { formatMessage: r } = S();
399
- if (!t)
400
- return /* @__PURE__ */ n(
401
- Y,
402
- {
403
- maxCharacters: o,
404
- text: e || "N/A",
405
- variant: "pi",
406
- textColor: "neutral600"
407
- }
408
- );
409
- const i = r({
410
- id: a(Zt)
411
- }), s = r({
412
- id: a(le[t])
413
- }), l = /* @__PURE__ */ n(tn, { shouldShow: !0, tooltipLabel: s, message: i });
414
- return t === "someLocales" && e ? /* @__PURE__ */ u(P, { direction: "row", gap: 2, alignItems: "center", children: [
415
- /* @__PURE__ */ n(
416
- Y,
417
- {
418
- maxCharacters: o,
419
- text: e,
420
- variant: "pi",
421
- textColor: "neutral600"
422
- }
423
- ),
424
- l
425
- ] }) : l;
426
- }, st = ({
427
- entryTitle: e,
428
- uniqueKey: t,
429
- missingUniqueKeyScope: o,
430
- locale: r,
431
- titleMaxCharacters: i = 60,
432
- checked: s,
433
- onCheckedChange: l,
434
- checkboxDisabled: c = !1,
435
- checkboxTooltipLabel: d,
436
- status: m
437
- }) => {
438
- const p = /* @__PURE__ */ n(
439
- Y,
440
- {
441
- maxCharacters: i,
442
- text: e,
443
- variant: "omega",
444
- fontWeight: "semiBold"
445
- }
446
- );
447
- return /* @__PURE__ */ u(K, { children: [
448
- /* @__PURE__ */ u(P, { direction: "row", gap: 4, alignItems: "center", children: [
449
- /* @__PURE__ */ n(
450
- Me,
451
- {
452
- checked: s,
453
- onCheckedChange: l,
454
- disable: c,
455
- tooltipLabel: d
456
- }
457
- ),
458
- r ? /* @__PURE__ */ u(P, { direction: "row", gap: 2, alignItems: "center", children: [
459
- /* @__PURE__ */ n(ye, { locale: r }),
460
- p
461
- ] }) : p,
462
- /* @__PURE__ */ n(fe, { uniqueKey: t, missingUniqueKeyScope: o })
463
- ] }),
464
- /* @__PURE__ */ n(at, { status: m })
465
- ] });
466
- }, nn = ({
467
- entryTitle: e,
468
- uniqueKey: t,
469
- status: o,
470
- warning: r,
471
- locale: i,
472
- isChecked: s,
473
- onCheckItemChange: l,
474
- canExecute: c
475
- }) => {
476
- const { formatMessage: d } = S(), m = !c || !j(o, r), p = rt(c, o, r);
477
- return /* @__PURE__ */ n(
478
- P,
479
- {
480
- direction: "row",
481
- justifyContent: "space-between",
482
- alignItems: "center",
483
- background: "neutral0",
484
- style: {
485
- width: "100%",
486
- padding: "24px"
487
- },
488
- grow: 1,
489
- gap: 4,
490
- children: /* @__PURE__ */ n(
491
- st,
492
- {
493
- entryTitle: e,
494
- uniqueKey: t,
495
- missingUniqueKeyScope: r === "missing_unique_key" ? "single" : null,
496
- locale: i,
497
- checked: s,
498
- onCheckedChange: l,
499
- checkboxDisabled: m,
500
- checkboxTooltipLabel: p ? d({ id: a(p) }) : void 0,
501
- status: o
502
- }
503
- )
504
- }
505
- );
506
- }, on = ({
507
- isAllCheckedInEntity: e,
508
- onCheckAllInEntity: t,
509
- entityWithLocalizations: o,
510
- selectedPromotions: r,
511
- onCheckItemChange: i,
512
- isIndeterminate: s,
513
- contentTypeMainField: l,
514
- canExecute: c
515
- }) => {
516
- const { formatMessage: d } = S(), m = [
517
- {
518
- key: "checkbox"
519
- },
520
- {
521
- key: "locale",
522
- label: d({ id: a("homePage.table.locale") })
523
- },
524
- {
525
- key: "entryTitle",
526
- label: d({ id: a("homePage.table.entryTitle") })
527
- },
528
- {
529
- key: "key",
530
- label: d({ id: a("homePage.table.key") })
531
- },
532
- {
533
- key: "status",
534
- label: d({ id: a("homePage.table.status") })
535
- }
536
- ], p = !o?.some(
537
- (g) => j(g.status, g.warning)
538
- ), f = it(
539
- c,
540
- o ?? []
541
- );
542
- return /* @__PURE__ */ u(Ke, { colCount: m.length, rowCount: o?.length ?? 0, children: [
543
- /* @__PURE__ */ n(De, { children: /* @__PURE__ */ n(V, { children: m.map((g) => /* @__PURE__ */ n(N, { children: g.key === "checkbox" ? /* @__PURE__ */ n(
544
- Me,
545
- {
546
- checked: s ? "indeterminate" : e,
547
- onCheckedChange: t,
548
- disable: p || !c,
549
- tooltipLabel: f ? d({ id: a(f) }) : ""
550
- }
551
- ) : /* @__PURE__ */ n(h, { variant: "sigma", children: g.label }) }, g.key)) }) }),
552
- /* @__PURE__ */ n(Ae, { children: o?.map((g) => {
553
- const C = !c || !j(g.status, g.warning), y = rt(
554
- c,
555
- g.status,
556
- g.warning
557
- );
558
- return /* @__PURE__ */ u(V, { children: [
559
- /* @__PURE__ */ n(v, { children: /* @__PURE__ */ n(
560
- Me,
561
- {
562
- checked: ce(g, r),
563
- onCheckedChange: i(g),
564
- disable: C,
565
- tooltipLabel: y ? d({ id: a(y) }) : ""
566
- }
567
- ) }),
568
- /* @__PURE__ */ n(v, { children: g?.locale ? /* @__PURE__ */ n(ye, { locale: g.locale }) : null }),
569
- /* @__PURE__ */ n(v, { children: /* @__PURE__ */ n(
570
- Y,
571
- {
572
- maxCharacters: 50,
573
- text: pe(g, l) || ""
574
- }
575
- ) }),
576
- /* @__PURE__ */ n(v, { children: /* @__PURE__ */ n(
577
- fe,
578
- {
579
- uniqueKey: g?.uniqueKeyValue,
580
- missingUniqueKeyScope: g?.warning === "missing_unique_key" ? "single" : null
581
- }
582
- ) }),
583
- /* @__PURE__ */ n(v, { children: /* @__PURE__ */ n(at, { status: g?.status }) })
584
- ] }, `${g.documentId}-${g.locale}`);
585
- }) })
586
- ] });
587
- }, rn = Ne(q.Trigger)`
588
- width: 100%;
589
- & > span:first-child {
590
- width: 100%;
591
- display: flex;
592
- justify-content: space-between;
593
- & > span {
594
- width: 100%;
595
- }
596
- }
597
- `, an = ({
598
- uniqueKey: e,
599
- entityWithLocalizations: t,
600
- entryTitle: o,
601
- selectedPromotions: r,
602
- setSelectedPromotions: i,
603
- onCheckItemChange: s,
604
- contentTypeMainField: l,
605
- onRememberEntityGroup: c,
606
- canExecute: d
607
- }) => {
608
- const { formatMessage: m } = S(), p = t.filter(
609
- (I) => j(I.status, I.warning)
610
- ), f = (I) => {
611
- i((b) => {
612
- const G = p.map(
613
- (E) => se(E)
614
- ), Q = (E) => t.some(
615
- (O) => ne(E, se(O))
616
- );
617
- return I ? (c?.(t), [...b.filter((O) => !Q(O)), ...G]) : b.filter((E) => !Q(E));
618
- });
619
- }, g = t?.some(
620
- (I) => ce(I, r)
621
- ), C = p.length > 0 && p.every(
622
- (I) => ce(I, r)
623
- ), y = p.length === 0, R = it(
624
- d,
625
- t
626
- ), D = Wt(t), F = (() => {
627
- switch (!0) {
628
- case t?.some((I) => I?.status === "new"):
629
- return "new";
630
- case t?.some((I) => I?.status === "changed"):
631
- return "changed";
632
- default:
633
- return "up_to_date";
634
- }
635
- })(), x = g && !C;
636
- return /* @__PURE__ */ n(q.Root, { style: { width: "100%" }, size: "M", children: /* @__PURE__ */ u(q.Item, { value: `${o}-${e}`, children: [
637
- /* @__PURE__ */ n(q.Header, { children: /* @__PURE__ */ n(rn, { caretPosition: "right", children: /* @__PURE__ */ n(
638
- P,
639
- {
640
- direction: "row",
641
- justifyContent: "space-between",
642
- alignItems: "center",
643
- style: { width: "100%" },
644
- grow: 1,
645
- gap: 4,
646
- children: /* @__PURE__ */ n(
647
- st,
648
- {
649
- entryTitle: o,
650
- uniqueKey: e,
651
- missingUniqueKeyScope: D,
652
- checked: x ? "indeterminate" : C,
653
- onCheckedChange: f,
654
- checkboxDisabled: y || !d,
655
- checkboxTooltipLabel: R ? m({ id: a(R) }) : void 0,
656
- status: F
657
- }
658
- )
659
- }
660
- ) }) }),
661
- /* @__PURE__ */ n(q.Content, { children: /* @__PURE__ */ n(
662
- on,
663
- {
664
- isAllCheckedInEntity: C,
665
- onCheckAllInEntity: f,
666
- entityWithLocalizations: t,
667
- selectedPromotions: r,
668
- onCheckItemChange: s,
669
- isIndeterminate: x,
670
- contentTypeMainField: l,
671
- canExecute: d
672
- }
673
- ) })
674
- ] }) });
675
- }, sn = ({
676
- entities: e,
677
- contentTypeMainField: t,
678
- selectedPromotions: o,
679
- setSelectedPromotions: r,
680
- onRememberEntityGroup: i,
681
- canExecute: s
682
- }) => {
683
- const l = (d) => (m) => (p) => {
684
- const f = se(m);
685
- r((g) => p ? g.some((C) => ne(C, f)) ? g : (i?.(d), [...g, f]) : g.filter((C) => !ne(C, f)));
686
- }, c = (d, m) => {
687
- const p = pe(d, t), f = d?.uniqueKeyValue || "";
688
- return m.length > 1 ? /* @__PURE__ */ n(
689
- an,
690
- {
691
- uniqueKey: f,
692
- contentTypeMainField: t,
693
- entityWithLocalizations: m,
694
- entryTitle: p || "",
695
- selectedPromotions: o,
696
- setSelectedPromotions: r,
697
- onCheckItemChange: l(m),
698
- onRememberEntityGroup: i,
699
- canExecute: s
700
- }
701
- ) : /* @__PURE__ */ n(
702
- nn,
703
- {
704
- entryTitle: p || "",
705
- uniqueKey: f,
706
- status: d?.status,
707
- warning: d?.warning,
708
- locale: d?.locale,
709
- isChecked: ce(d, o),
710
- onCheckItemChange: l(m)(d),
711
- canExecute: s
712
- }
713
- );
714
- };
715
- return /* @__PURE__ */ n("div", { children: e?.map((d, m) => {
716
- const p = Fe(d);
717
- return /* @__PURE__ */ u(_t, { children: [
718
- c(d, p),
719
- e?.length - 1 > m && /* @__PURE__ */ n(Mt, {})
720
- ] }, d?.documentId);
721
- }) });
722
- }, cn = () => {
723
- const { get: e } = M();
724
- return $({
725
- queryKey: ["content-types"],
726
- queryFn: async () => {
727
- const { data: t } = await e("/content-type-builder/content-types");
728
- return t.data;
729
- }
730
- });
731
- }, ln = (e, t) => {
732
- const { get: o } = M();
733
- return $({
734
- queryKey: [Et, "related-content-types", e],
735
- queryFn: async () => {
736
- const { data: r } = await o(
737
- `/${_}/promotion/related-content-types`,
738
- {
739
- params: {
740
- contentTypeUid: e
741
- }
742
- }
743
- );
744
- return r;
745
- },
746
- enabled: !!e && t
747
- });
748
- }, dn = () => {
749
- const { post: e } = M(), t = re();
750
- return ue({
751
- mutationFn: async (o) => {
752
- const { data: r } = await e(
753
- `/${_}/promotion`,
754
- o
755
- );
756
- return r;
757
- },
758
- onSuccess: () => {
759
- tt(t);
760
- }
761
- });
762
- }, un = (e, t) => e.includes(t) ? [t, ...e.filter((o) => o !== t).sort()] : e.sort(), mn = (e) => e.filter((t) => j(t.status, t.warning)).map((t) => t.locale ?? "default"), gn = (e, t) => e.length > 0 && e.every((o) => t.includes(o)), hn = (e, t, o) => {
763
- const r = /* @__PURE__ */ new Map();
764
- for (const c of t ?? [])
765
- r.set(c.documentId, c);
766
- const i = ot(t), s = /* @__PURE__ */ new Map();
767
- for (const c of e) {
768
- const d = s.get(c.documentId) ?? [];
769
- d.push(c), s.set(c.documentId, d);
770
- }
771
- return [...new Set(e.map((c) => c.documentId))].map((c) => {
772
- const d = s.get(c) ?? [], m = r.get(c) ?? i.find((y) => y.documentId === c), p = m?.locale ?? "default", f = m ?? i.find(
773
- (y) => d.some(
774
- (R) => ne(R, {
775
- documentId: y.documentId,
776
- locale: y.locale ?? "default"
777
- })
778
- )
779
- ), g = un(
780
- d.map((y) => y.locale),
781
- p
782
- ), C = mn(
783
- Vt(c, t)
784
- );
785
- return {
786
- documentId: c,
787
- title: f ? pe(f, o) ?? c : c,
788
- locales: g,
789
- allLocalesSelected: gn(C, g),
790
- uniqueKey: f?.uniqueKeyValue ?? null
791
- };
792
- });
793
- }, de = (e, t) => t?.find((o) => o.uid === e)?.schema.displayName ?? e, pn = (e) => {
794
- const t = [
795
- e.summary,
796
- ...e.dependencyResults.map((i) => i.summary)
797
- ], o = t.reduce((i, s) => i + s.failed, 0), r = t.reduce((i, s) => i + s.total, 0);
798
- return o === 0 ? "success" : o >= r ? "failure" : "partial";
799
- }, yn = ["en", "default"], fn = (e) => {
800
- for (const t of yn) {
801
- const o = e.find((r) => r.locale === t);
802
- if (o?.uniqueKey != null && o.uniqueKey.length > 0)
803
- return o.uniqueKey;
804
- }
805
- return e.find((t) => t.uniqueKey != null && t.uniqueKey.length > 0)?.uniqueKey ?? null;
806
- }, Pn = (e, t, o) => {
807
- if (e.uniqueKey != null && e.uniqueKey.length > 0)
808
- return e.uniqueKey;
809
- const r = e.documentId ?? e.documentKey, i = ot(t).find(
810
- (s) => s.documentId === r
811
- );
812
- if (i) {
813
- const s = pe(i, o);
814
- if (s != null && String(s).length > 0)
815
- return String(s);
816
- }
817
- return r;
818
- }, Sn = (e) => {
819
- if (e.documentId != null && e.documentId.length > 0)
820
- return e.documentId;
821
- const t = e.steps.find(
822
- (r) => r.push.remoteDocumentId != null && r.push.remoteDocumentId.length > 0
823
- )?.push.remoteDocumentId;
824
- if (t != null && t.length > 0)
825
- return t;
826
- if (e.uniqueKey != null && e.uniqueKey.length > 0)
827
- return e.uniqueKey;
828
- const o = e.groupKey.lastIndexOf("::");
829
- return o === -1 ? e.groupKey : e.groupKey.slice(0, o);
830
- }, Cn = {
831
- create: "created",
832
- update: "updated"
833
- }, ct = (e) => e.push.ok ? e.push.skipped || e.action === "skip" ? "skipped" : Cn[e.action] : "failed", bn = (e) => {
834
- const t = e[0];
835
- return t ? ct(t) : "skipped";
836
- }, In = (e) => {
837
- switch (e) {
838
- case "failed":
839
- return "danger";
840
- case "skipped":
841
- return "neutral";
842
- case "updated":
843
- return "secondary";
844
- case "created":
845
- return "success";
846
- default:
847
- return "success";
848
- }
849
- }, Pe = (e) => {
850
- const t = /* @__PURE__ */ new Map();
851
- for (const o of e) {
852
- const r = o.snapshotKey, i = t.get(r) ?? [];
853
- i.push(o), t.set(r, i);
854
- }
855
- return Array.from(t.entries()).map(([o, r]) => {
856
- const i = r.some((l) => !l.push.ok), s = r[r.length - 1];
857
- return {
858
- groupKey: o,
859
- documentId: s.documentId,
860
- locale: s.locale,
861
- uniqueKey: s.uniqueKey,
862
- outcome: i ? "failed" : bn(r),
863
- steps: r,
864
- hasFailure: i
865
- };
866
- });
867
- }, lt = (e) => {
868
- const t = Pe(e), o = /* @__PURE__ */ new Map();
869
- for (const r of t) {
870
- const i = Sn(r), s = o.get(i) ?? [];
871
- s.push(r), o.set(i, s);
872
- }
873
- return Array.from(o.entries()).map(([r, i]) => {
874
- const s = i.sort(
875
- (l, c) => l.locale.localeCompare(c.locale)
876
- );
877
- return {
878
- documentKey: r,
879
- documentId: s[0]?.documentId,
880
- uniqueKey: fn(s),
881
- localeEntries: s
882
- };
883
- });
884
- }, wn = (e, t) => lt(e).map((o) => ({
885
- id: o.documentKey,
886
- title: Pn(
887
- o,
888
- t?.comparedEntities,
889
- t?.contentTypeMainField
890
- ),
891
- entries: o.localeEntries.flatMap((r) => r.steps)
892
- })), Xe = (e) => {
893
- const t = Pe(e);
894
- return {
895
- entityCount: t.length,
896
- created: t.filter((o) => o.outcome === "created").length,
897
- updated: t.filter((o) => o.outcome === "updated").length,
898
- skipped: t.filter((o) => o.outcome === "skipped").length,
899
- failed: t.filter((o) => o.outcome === "failed").length,
900
- locales: [...new Set(t.map((o) => o.locale))].sort()
901
- };
902
- }, En = (e) => {
903
- const t = {
904
- total: 0,
905
- created: 0,
906
- updated: 0,
907
- skipped: 0,
908
- failed: 0
909
- }, o = Pe(e);
910
- for (const r of o) {
911
- const i = r.steps[0];
912
- i && (t.total += 1, t[ct(i)] += 1);
913
- }
914
- return t;
915
- }, Tn = (e, t) => {
916
- const o = lt(e.entries), r = Xe(e.entries), i = [
917
- ...new Set(e.selections.map((d) => d.locale))
918
- ].sort(), s = e.dependencyResults.map((d) => {
919
- const m = Xe(d.entries);
920
- return {
921
- contentTypeUid: d.contentTypeUid,
922
- displayName: de(d.contentTypeUid, t),
923
- ...m
924
- };
925
- }), l = r.entityCount + s.reduce((d, m) => d + m.entityCount, 0), c = r.failed + s.reduce((d, m) => d + m.failed, 0);
926
- return {
927
- outcome: pn(e),
928
- primaryDisplayName: de(e.contentTypeUid, t),
929
- primaryEntityCount: o.length,
930
- dependencySummaries: s,
931
- totalEntityCount: l,
932
- totalFailed: c,
933
- selectionLocales: i,
934
- dependencyContentTypeCount: e.dependencyResults.length,
935
- mediaSummary: e.mediaSummary
936
- };
937
- }, dt = ({ entries: e, showFailuresOnly: t = !1 }) => {
938
- const { formatMessage: o } = S(), r = Ze(() => {
939
- const i = Pe(e);
940
- return t ? i.filter((s) => s.hasFailure) : i;
941
- }, [e, t]);
942
- return r.length === 0 ? /* @__PURE__ */ n(h, { variant: "omega", textColor: "neutral600", children: o({
943
- id: a(
944
- t ? "homePage.promotionResults.noFailures" : "homePage.promotionResults.noEntries"
945
- )
946
- }) }) : /* @__PURE__ */ u(Ke, { colCount: 3, rowCount: r.length, children: [
947
- /* @__PURE__ */ n(De, { children: /* @__PURE__ */ u(V, { children: [
948
- /* @__PURE__ */ n(N, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: o({ id: a("homePage.table.locale") }) }) }),
949
- /* @__PURE__ */ n(N, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: o({ id: a("homePage.table.key") }) }) }),
950
- /* @__PURE__ */ n(N, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: o({
951
- id: a("homePage.promotionResults.table.outcome")
952
- }) }) })
953
- ] }) }),
954
- /* @__PURE__ */ n(Ae, { children: r.map((i) => /* @__PURE__ */ u(V, { children: [
955
- /* @__PURE__ */ n(v, { children: /* @__PURE__ */ n(ye, { locale: i.locale }) }),
956
- /* @__PURE__ */ n(v, { children: /* @__PURE__ */ n(fe, { uniqueKey: i.uniqueKey, maxCharacters: 35 }) }),
957
- /* @__PURE__ */ n(v, { children: /* @__PURE__ */ n(ee, { variant: In(i.outcome), children: o({
958
- id: a(`homePage.promotionResults.outcome.${i.outcome}`)
959
- }) }) })
960
- ] }, i.groupKey)) })
961
- ] });
962
- }, vn = ({ summary: e }) => {
963
- const { formatMessage: t } = S(), o = [
964
- {
965
- key: "created",
966
- label: t({ id: a("homePage.promotionResults.summary.created") }),
967
- value: e.created,
968
- variant: "success"
969
- },
970
- {
971
- key: "updated",
972
- label: t({ id: a("homePage.promotionResults.summary.updated") }),
973
- value: e.updated,
974
- variant: "secondary"
975
- },
976
- ...e.skipped > 0 ? [
977
- {
978
- key: "skipped",
979
- label: t({
980
- id: a("homePage.promotionResults.summary.skipped")
981
- }),
982
- value: e.skipped,
983
- variant: "neutral"
984
- }
985
- ] : [],
986
- ...e.failed > 0 ? [
987
- {
988
- key: "failed",
989
- label: t({
990
- id: a("homePage.promotionResults.summary.failed")
991
- }),
992
- value: e.failed,
993
- variant: "danger"
994
- }
995
- ] : []
996
- ];
997
- return /* @__PURE__ */ n(P, { gap: 2, wrap: "wrap", children: o.map((r) => /* @__PURE__ */ u(ee, { variant: r.variant, children: [
998
- r.label,
999
- ": ",
1000
- r.value
1001
- ] }, r.key)) });
1002
- }, kn = Ne(q.Trigger)`
1003
- width: 100%;
1004
- font-weight: ${({ theme: e }) => e.fontWeights.regular};
1005
-
1006
- & > span:first-child {
1007
- width: 100%;
1008
- display: flex;
1009
- justify-content: space-between;
1010
- font-weight: inherit;
1011
- & > span {
1012
- width: 100%;
1013
- font-weight: inherit;
1014
- }
1015
- }
1016
- `, Je = ({ items: e }) => /* @__PURE__ */ n(q.Root, { style: { width: "100%" }, size: "S", children: e.map((t) => /* @__PURE__ */ u(q.Item, { value: t.id, children: [
1017
- /* @__PURE__ */ n(q.Header, { children: /* @__PURE__ */ n(kn, { caretPosition: "right", children: /* @__PURE__ */ u(P, { justifyContent: "space-between", alignItems: "center", width: "100%", gap: 2, children: [
1018
- /* @__PURE__ */ n(Y, { maxCharacters: 40, text: t.title, fontWeight: "regular" }),
1019
- /* @__PURE__ */ n(Rt, { style: { flexShrink: 0 }, children: /* @__PURE__ */ n(vn, { summary: En(t.entries) }) })
1020
- ] }) }) }),
1021
- /* @__PURE__ */ n(q.Content, { children: /* @__PURE__ */ n(dt, { entries: t.entries }) })
1022
- ] }, t.id)) }), xn = ({ overview: e }) => {
1023
- const { formatMessage: t } = S(), o = e.dependencySummaries.map((r) => r.displayName);
1024
- return /* @__PURE__ */ u(P, { direction: "column", alignItems: "stretch", gap: 2, children: [
1025
- /* @__PURE__ */ n(h, { variant: "omega", children: t(
1026
- { id: a("homePage.promotionResults.header.summary") },
1027
- {
1028
- primaryCount: e.primaryEntityCount,
1029
- dependencyCount: e.dependencyContentTypeCount,
1030
- entityCount: e.totalEntityCount,
1031
- failedCount: e.totalFailed
1032
- }
1033
- ) }),
1034
- o.length > 0 && /* @__PURE__ */ n(h, { variant: "pi", textColor: "neutral600", children: t(
1035
- { id: a("homePage.promotionResults.header.dependencies") },
1036
- { contentTypes: o.join(", ") }
1037
- ) }),
1038
- e.mediaSummary && /* @__PURE__ */ n(h, { variant: "pi", textColor: "neutral600", children: t(
1039
- { id: a("homePage.promotionResults.media.summary") },
1040
- {
1041
- uploaded: e.mediaSummary.uploaded,
1042
- replaced: e.mediaSummary.replaced,
1043
- failed: e.mediaSummary.failed
1044
- }
1045
- ) })
1046
- ] });
1047
- }, Mn = ({
1048
- result: e,
1049
- contentTypes: t,
1050
- comparedEntities: o,
1051
- contentTypeMainField: r
1052
- }) => {
1053
- const { formatMessage: i } = S(), s = Tn(e, t), l = s.outcome, c = [
1054
- ...e.entries,
1055
- ...e.dependencyResults.flatMap((y) => y.entries)
1056
- ], d = de(e.contentTypeUid, t), m = s.totalFailed > 0, p = e.dependencyResults.length > 0, f = wn(e.entries, {
1057
- comparedEntities: o,
1058
- contentTypeMainField: r
1059
- }), g = e.dependencyResults.map((y) => ({
1060
- id: y.contentTypeUid,
1061
- title: de(y.contentTypeUid, t),
1062
- entries: y.entries
1063
- }));
1064
- return /* @__PURE__ */ u(P, { direction: "column", alignItems: "stretch", gap: 4, children: [
1065
- (() => {
1066
- switch (l) {
1067
- case "success":
1068
- return /* @__PURE__ */ n(
1069
- k,
1070
- {
1071
- variant: "success",
1072
- title: i({
1073
- id: a("homePage.promotionResults.success.title")
1074
- }),
1075
- description: i(
1076
- { id: a("homePage.promotionResults.success.description") },
1077
- {
1078
- primaryCount: s.primaryEntityCount
1079
- }
1080
- )
1081
- }
1082
- );
1083
- case "partial":
1084
- return /* @__PURE__ */ n(
1085
- k,
1086
- {
1087
- variant: "warning",
1088
- title: i({
1089
- id: a("homePage.promotionResults.partialFailure.title")
1090
- }),
1091
- description: i({
1092
- id: a("homePage.promotionResults.partialFailure.description")
1093
- })
1094
- }
1095
- );
1096
- case "failure":
1097
- return /* @__PURE__ */ n(
1098
- k,
1099
- {
1100
- variant: "danger",
1101
- title: i({
1102
- id: a("homePage.promotionResults.failure.title")
1103
- }),
1104
- description: i({
1105
- id: a("homePage.promotionResults.failure.description")
1106
- })
1107
- }
1108
- );
1109
- }
1110
- })(),
1111
- /* @__PURE__ */ n(xn, { overview: s }),
1112
- m && /* @__PURE__ */ u(P, { direction: "column", alignItems: "stretch", gap: 2, children: [
1113
- /* @__PURE__ */ n(h, { variant: "delta", children: i({
1114
- id: a("homePage.promotionResults.failures.title")
1115
- }) }),
1116
- /* @__PURE__ */ n(dt, { entries: c, showFailuresOnly: !0 })
1117
- ] }),
1118
- /* @__PURE__ */ u(P, { direction: "column", alignItems: "stretch", gap: 2, children: [
1119
- /* @__PURE__ */ u(h, { variant: "delta", children: [
1120
- d,
1121
- ":"
1122
- ] }),
1123
- /* @__PURE__ */ n(Je, { items: f })
1124
- ] }),
1125
- p && /* @__PURE__ */ u(P, { direction: "column", alignItems: "stretch", gap: 2, children: [
1126
- /* @__PURE__ */ n(h, { variant: "delta", children: i({
1127
- id: a("homePage.promotionResults.dependencies.title")
1128
- }) }),
1129
- /* @__PURE__ */ n(Je, { items: g })
1130
- ] })
1131
- ] });
1132
- }, Rn = ({
1133
- previews: e,
1134
- mediaDocumentIds: t,
1135
- onToggleMediaDocument: o
1136
- }) => {
1137
- const { formatMessage: r } = S();
1138
- return e.length === 0 ? null : /* @__PURE__ */ u(Ke, { colCount: 4, rowCount: e.length, children: [
1139
- /* @__PURE__ */ n(De, { children: /* @__PURE__ */ u(V, { children: [
1140
- /* @__PURE__ */ u(N, { children: [
1141
- /* @__PURE__ */ n(h, { variant: "sigma", children: r({
1142
- id: a("homePage.modal.confirmPromotion.includeMedia")
1143
- }) }),
1144
- /* @__PURE__ */ n(
1145
- Le,
1146
- {
1147
- label: r({
1148
- id: a("homePage.modal.confirmPromotion.tooltip")
1149
- }),
1150
- children: /* @__PURE__ */ n(Lt, { style: { marginLeft: "4px" } })
1151
- }
1152
- )
1153
- ] }),
1154
- /* @__PURE__ */ n(N, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: r({ id: a("homePage.table.entryTitle") }) }) }),
1155
- /* @__PURE__ */ n(N, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: r({ id: a("homePage.table.locale") }) }) }),
1156
- /* @__PURE__ */ n(N, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: r({ id: a("homePage.table.key") }) }) })
1157
- ] }) }),
1158
- /* @__PURE__ */ n(Ae, { children: e.map((i) => /* @__PURE__ */ u(V, { children: [
1159
- /* @__PURE__ */ n(v, { children: /* @__PURE__ */ n(
1160
- _e,
1161
- {
1162
- checked: t.has(i.documentId),
1163
- onCheckedChange: (s) => o(i.documentId, s === !0),
1164
- "aria-label": r(
1165
- {
1166
- id: a("homePage.modal.confirmPromotion.includeMediaForDocument")
1167
- },
1168
- { title: i.title }
1169
- )
1170
- }
1171
- ) }),
1172
- /* @__PURE__ */ n(v, { children: /* @__PURE__ */ n(Y, { maxCharacters: 50, text: i.title }) }),
1173
- /* @__PURE__ */ n(v, { children: i.allLocalesSelected ? /* @__PURE__ */ n(h, { variant: "pi", children: r({
1174
- id: a("homePage.modal.confirmPromotion.allLocalesSelected")
1175
- }) }) : /* @__PURE__ */ n(P, { gap: 2, wrap: "wrap", children: i.locales.map((s) => /* @__PURE__ */ n(ye, { locale: s }, `${i.documentId}-${s}`)) }) }),
1176
- /* @__PURE__ */ n(v, { children: /* @__PURE__ */ n(fe, { uniqueKey: i.uniqueKey, maxCharacters: 35 }) })
1177
- ] }, i.documentId)) })
1178
- ] });
1179
- }, qn = ({
1180
- open: e,
1181
- onClose: t,
1182
- selectedPromotions: o,
1183
- contentTypeUid: r,
1184
- contentTypeMainField: i,
1185
- comparedEntities: s,
1186
- onPromoteComplete: l
1187
- }) => {
1188
- const { formatMessage: c } = S(), { data: d } = cn(), { data: m } = ln(
1189
- r,
1190
- e
1191
- ), [p, f] = L(null), [g, C] = L(() => /* @__PURE__ */ new Set()), y = jt(o), R = Xt(y, g), D = g.size > 0, {
1192
- mutate: X,
1193
- isPending: F,
1194
- error: x,
1195
- reset: I
1196
- } = dn(), b = () => {
1197
- f(null), C(/* @__PURE__ */ new Set()), I();
1198
- };
1199
- oe(() => {
1200
- C((w) => Jt(w, y));
1201
- }, [y]);
1202
- const G = m?.contentTypes.map((w) => w.displayName) ?? [], Q = hn(
1203
- o,
1204
- s,
1205
- i
1206
- ), E = () => {
1207
- b(), t();
1208
- }, O = (w) => {
1209
- C(w ? new Set(y) : /* @__PURE__ */ new Set());
1210
- }, H = (w, Ce) => {
1211
- C((be) => {
1212
- const U = new Set(be);
1213
- return Ce ? U.add(w) : U.delete(w), U;
1214
- });
1215
- }, Se = () => {
1216
- X(
1217
- {
1218
- selections: o,
1219
- contentTypeUid: r,
1220
- mediaDocumentIds: [...g]
1221
- },
1222
- {
1223
- onSuccess: (w) => {
1224
- f(w), l?.(w);
1225
- }
1226
- }
1227
- );
1228
- }, J = p != null;
1229
- return /* @__PURE__ */ n(
1230
- me,
1231
- {
1232
- open: e,
1233
- onClose: E,
1234
- onSubmit: Se,
1235
- title: c({
1236
- id: a(
1237
- J ? "homePage.modal.promotionResults.title" : "homePage.modal.confirmPromotion.title"
1238
- )
1239
- }),
1240
- confirmButtonText: c({
1241
- id: a("homePage.modal.confirmPromotion.confirmButtonText")
1242
- }),
1243
- isConfirmButtonDisabled: F || !r || o.length === 0,
1244
- isConfirmButtonLoading: F,
1245
- showConfirmButton: !J,
1246
- fillMaxHeight: !0,
1247
- children: J ? /* @__PURE__ */ n(
1248
- Mn,
1249
- {
1250
- result: p,
1251
- contentTypes: d,
1252
- comparedEntities: s,
1253
- contentTypeMainField: i
1254
- }
1255
- ) : /* @__PURE__ */ u(P, { direction: "column", gap: 4, alignItems: "stretch", children: [
1256
- /* @__PURE__ */ n(h, { variant: "omega", children: c(
1257
- {
1258
- id: a("homePage.modal.confirmPromotion.description")
1259
- },
1260
- { count: o.length }
1261
- ) }),
1262
- /* @__PURE__ */ n(
1263
- _e,
1264
- {
1265
- checked: R,
1266
- onCheckedChange: (w) => O(w === !0),
1267
- children: c({
1268
- id: a("homePage.modal.confirmPromotion.includeMediaAll")
1269
- })
1270
- }
1271
- ),
1272
- /* @__PURE__ */ n(
1273
- Rn,
1274
- {
1275
- previews: Q,
1276
- mediaDocumentIds: g,
1277
- onToggleMediaDocument: H
1278
- }
1279
- ),
1280
- /* @__PURE__ */ n(
1281
- k,
1282
- {
1283
- variant: "default",
1284
- title: c({
1285
- id: a("homePage.promotionResults.scope.title")
1286
- }),
1287
- description: c({
1288
- id: a("homePage.modal.confirmPromotion.localeScopeHint")
1289
- })
1290
- }
1291
- ),
1292
- D && /* @__PURE__ */ n(
1293
- k,
1294
- {
1295
- variant: "default",
1296
- title: c({
1297
- id: a("homePage.modal.confirmPromotion.mediaScopeHint.title")
1298
- }),
1299
- description: c({
1300
- id: a("homePage.modal.confirmPromotion.mediaScopeHint.description")
1301
- })
1302
- }
1303
- ),
1304
- G.length > 0 && /* @__PURE__ */ n(
1305
- k,
1306
- {
1307
- variant: "warning",
1308
- title: c({
1309
- id: a("homePage.modal.confirmPromotion.relatedWarning.title")
1310
- }),
1311
- description: c(
1312
- {
1313
- id: a("homePage.modal.confirmPromotion.relatedWarning.description")
1314
- },
1315
- { contentTypes: G.join(", ") }
1316
- )
1317
- }
1318
- ),
1319
- x && /* @__PURE__ */ n(h, { variant: "omega", textColor: "danger500", children: ge(x, c) })
1320
- ] })
1321
- }
1322
- );
1323
- }, Ln = 2500, _n = 5e3, Kn = (e) => e === "running" ? Ln : e === "queued" ? _n : !1, ut = (e, t = !0) => {
1324
- const { get: o } = M(), r = re(), i = We(void 0), s = $({
1325
- queryKey: te.list(e),
1326
- queryFn: async () => {
1327
- const { data: l } = await o(
1328
- `/${_}/snapshot/sync/${e}/status`
1329
- );
1330
- return l;
1331
- },
1332
- enabled: !!e && t,
1333
- refetchInterval: (l) => Kn(l.state.data?.status),
1334
- refetchOnWindowFocus: !0
1335
- });
1336
- return oe(() => {
1337
- if (!e)
1338
- return;
1339
- const l = i.current, c = s.data?.status;
1340
- (l === "running" && c !== "running" || l === "queued" && c === "running") && he(r, e), i.current = c;
1341
- }, [s.data?.status, e, r]), s;
1342
- }, Dn = ({
1343
- syncStatus: e,
1344
- isSyncInProgressFromComparison: t
1345
- }) => {
1346
- const o = e?.status;
1347
- switch (!0) {
1348
- case (o === "running" || t):
1349
- return "in_progress";
1350
- case o === "queued":
1351
- return "queued";
1352
- case o === "cancelled":
1353
- return "cancelled";
1354
- case o === "failed":
1355
- return "failed";
1356
- default:
1357
- return "none";
1358
- }
1359
- }, An = Ne(qt)`
1360
- background-color: ${({ theme: e }) => e.colors.neutral600};
1361
- & > div {
1362
- background-color: ${({ theme: e }) => e.colors.neutral150};
1363
- }
1364
- `, ke = ({ lastProcessedPage: e, totalPages: t }) => {
1365
- const { formatMessage: o } = S(), r = (i, s) => Math.round(Number(i) / Number(s) * 100);
1366
- return /* @__PURE__ */ u(P, { direction: "row", gap: 2, alignItems: "center", children: [
1367
- /* @__PURE__ */ n(h, { variant: "omega", children: o(
1368
- {
1369
- id: a("homePage.alert.syncInProgress.progress")
1370
- },
1371
- {
1372
- currentPage: e,
1373
- totalPages: t
1374
- }
1375
- ) }),
1376
- /* @__PURE__ */ n(An, { value: r(e, t) })
1377
- ] });
1378
- }, Bn = ({
1379
- view: e,
1380
- syncStatus: t,
1381
- onRefresh: o,
1382
- onCancel: r,
1383
- onResume: i,
1384
- canExecute: s
1385
- }) => {
1386
- const { formatMessage: l } = S();
1387
- if (e === "none")
1388
- return null;
1389
- const c = Ft(t?.error, l), m = (() => {
1390
- switch (e) {
1391
- case "queued":
1392
- return {
1393
- title: l({
1394
- id: a("homePage.alert.syncQueued.title")
1395
- }),
1396
- description: /* @__PURE__ */ u(P, { direction: "column", gap: 2, alignItems: "flex-start", children: [
1397
- /* @__PURE__ */ n(h, { variant: "omega", children: l({
1398
- id: a("homePage.alert.syncQueued.description")
1399
- }) }),
1400
- t?.queuePosition != null ? /* @__PURE__ */ n(h, { variant: "omega", textColor: "neutral600", children: l(
1401
- { id: a("homePage.alert.syncQueued.position") },
1402
- { position: t.queuePosition }
1403
- ) }) : null,
1404
- t?.queuedAt ? /* @__PURE__ */ n(h, { variant: "omega", textColor: "neutral600", children: l(
1405
- { id: a("homePage.alert.syncQueued.queuedAt") },
1406
- { queuedAt: new Date(t.queuedAt).toLocaleString() }
1407
- ) }) : null
1408
- ] }),
1409
- action: /* @__PURE__ */ n(T, { onClick: o, variant: "secondary", children: l({
1410
- id: a("homePage.alert.syncQueued.linkText")
1411
- }) }),
1412
- variant: "default"
1413
- };
1414
- case "in_progress":
1415
- return {
1416
- title: l({
1417
- id: a("homePage.alert.syncInProgress.title")
1418
- }),
1419
- description: /* @__PURE__ */ u(P, { direction: "column", gap: 2, alignItems: "flex-start", children: [
1420
- /* @__PURE__ */ n(h, { variant: "omega", children: l({
1421
- id: a("homePage.alert.syncInProgress.description")
1422
- }) }),
1423
- /* @__PURE__ */ n(
1424
- ke,
1425
- {
1426
- lastProcessedPage: t?.lastProcessedPage ?? 0,
1427
- totalPages: t?.totalPages ?? 1
1428
- }
1429
- )
1430
- ] }),
1431
- action: /* @__PURE__ */ u(P, { direction: "row", gap: 2, alignItems: "center", children: [
1432
- /* @__PURE__ */ n(T, { onClick: o, variant: "secondary", children: l({
1433
- id: a("homePage.alert.syncInProgress.linkText")
1434
- }) }),
1435
- s ? /* @__PURE__ */ n(T, { variant: "danger-light", onClick: r, children: l({
1436
- id: a("common.button.cancel")
1437
- }) }) : null
1438
- ] }),
1439
- variant: "default"
1440
- };
1441
- case "cancelled":
1442
- return {
1443
- title: l({
1444
- id: a("homePage.alert.resumeSync.title")
1445
- }),
1446
- description: /* @__PURE__ */ u(P, { direction: "column", gap: 2, alignItems: "flex-start", children: [
1447
- /* @__PURE__ */ n(h, { variant: "omega", children: l({
1448
- id: a("homePage.alert.resumeSync.description")
1449
- }) }),
1450
- /* @__PURE__ */ n(
1451
- ke,
1452
- {
1453
- lastProcessedPage: t?.lastProcessedPage ?? 0,
1454
- totalPages: t?.totalPages ?? 1
1455
- }
1456
- )
1457
- ] }),
1458
- action: s ? /* @__PURE__ */ n(T, { onClick: i, variant: "secondary", children: l({
1459
- id: a("homePage.alert.resumeSync.linkText")
1460
- }) }) : void 0,
1461
- variant: "warning"
1462
- };
1463
- case "failed":
1464
- return {
1465
- title: l({
1466
- id: a("homePage.alert.syncFailed.title")
1467
- }),
1468
- description: /* @__PURE__ */ u(P, { direction: "column", gap: 2, alignItems: "flex-start", children: [
1469
- /* @__PURE__ */ n(h, { variant: "omega", children: l({
1470
- id: a("homePage.alert.syncFailed.description")
1471
- }) }),
1472
- c ? /* @__PURE__ */ n(h, { variant: "omega", textColor: "danger500", children: c }) : null,
1473
- /* @__PURE__ */ n(
1474
- ke,
1475
- {
1476
- lastProcessedPage: t?.lastProcessedPage ?? 0,
1477
- totalPages: t?.totalPages ?? 1
1478
- }
1479
- )
1480
- ] }),
1481
- action: s ? /* @__PURE__ */ n(T, { onClick: i, variant: "secondary", children: l({
1482
- id: a("homePage.alert.syncFailed.linkText")
1483
- }) }) : void 0,
1484
- variant: "danger"
1485
- };
1486
- default:
1487
- return e;
1488
- }
1489
- })();
1490
- return /* @__PURE__ */ n(
1491
- k,
1492
- {
1493
- title: m?.title,
1494
- description: m?.description,
1495
- action: m?.action,
1496
- variant: m?.variant
1497
- }
1498
- );
1499
- }, Nn = () => {
1500
- const { post: e } = M(), t = re();
1501
- return ue({
1502
- mutationFn: async () => await e(`/${_}/snapshot/sync/cancel`),
1503
- onSuccess: () => {
1504
- he(t);
1505
- }
1506
- });
1507
- }, Fn = ({ open: e, onClose: t }) => {
1508
- const { formatMessage: o } = S(), {
1509
- mutate: r,
1510
- isPending: i,
1511
- error: s,
1512
- reset: l
1513
- } = Nn(), c = () => {
1514
- t(), l();
1515
- };
1516
- return /* @__PURE__ */ n(
1517
- me,
1518
- {
1519
- open: e,
1520
- onClose: c,
1521
- onSubmit: () => r(void 0, { onSuccess: c }),
1522
- title: /* @__PURE__ */ u(P, { direction: "row", gap: 2, alignItems: "center", children: [
1523
- /* @__PURE__ */ n(Be, { fill: "danger500", width: 20, height: 20 }),
1524
- o({
1525
- id: a("homePage.modal.cancelSync.title")
1526
- })
1527
- ] }),
1528
- confirmButtonText: o({
1529
- id: a("homePage.modal.cancelSync.confirmButtonText")
1530
- }),
1531
- isConfirmButtonLoading: i,
1532
- children: /* @__PURE__ */ u(P, { direction: "column", gap: 4, alignItems: "stretch", children: [
1533
- /* @__PURE__ */ n(h, { variant: "omega", children: o({
1534
- id: a("homePage.modal.cancelSync.description")
1535
- }) }),
1536
- s && /* @__PURE__ */ n(h, { variant: "omega", textColor: "danger500", children: ge(s, o) })
1537
- ] })
1538
- }
1539
- );
1540
- }, On = () => {
1541
- const { post: e } = M(), t = re();
1542
- return ue({
1543
- mutationFn: async (o) => await e(`/${_}/snapshot/sync/${o}/resume`),
1544
- onSuccess: () => {
1545
- he(t);
1546
- }
1547
- });
1548
- }, Un = ({ open: e, onClose: t, jobDocumentId: o }) => {
1549
- const { formatMessage: r } = S(), {
1550
- mutate: i,
1551
- isPending: s,
1552
- error: l,
1553
- reset: c
1554
- } = On(), d = () => {
1555
- t(), c();
1556
- };
1557
- return /* @__PURE__ */ n(
1558
- me,
1559
- {
1560
- open: e,
1561
- onClose: d,
1562
- onSubmit: () => i(o, { onSuccess: d }),
1563
- title: r({
1564
- id: a("homePage.modal.resumeSync.title")
1565
- }),
1566
- confirmButtonText: r({
1567
- id: a("homePage.modal.resumeSync.confirmButtonText")
1568
- }),
1569
- isConfirmButtonDisabled: !o,
1570
- isConfirmButtonLoading: s,
1571
- children: /* @__PURE__ */ u(P, { direction: "column", gap: 4, alignItems: "stretch", children: [
1572
- /* @__PURE__ */ n(h, { variant: "omega", children: r({
1573
- id: a("homePage.modal.resumeSync.description")
1574
- }) }),
1575
- l && /* @__PURE__ */ n(h, { variant: "omega", textColor: "danger500", children: ge(l, r) })
1576
- ] })
1577
- }
1578
- );
1579
- }, $n = ({
1580
- contentTypeUid: e,
1581
- isSyncInProgressFromComparison: t,
1582
- canExecute: o
1583
- }) => {
1584
- const [r, i] = L(!1), [s, l] = L(!1), { data: c, refetch: d } = ut(e), m = Dn({
1585
- syncStatus: c,
1586
- isSyncInProgressFromComparison: t
1587
- }), p = c?.jobDocumentId ?? "";
1588
- return /* @__PURE__ */ u(K, { children: [
1589
- /* @__PURE__ */ n(
1590
- Bn,
1591
- {
1592
- view: m,
1593
- syncStatus: c,
1594
- onRefresh: () => d(),
1595
- onCancel: () => i(!0),
1596
- onResume: () => l(!0),
1597
- canExecute: o
1598
- }
1599
- ),
1600
- o ? /* @__PURE__ */ u(K, { children: [
1601
- /* @__PURE__ */ n(Fn, { open: r, onClose: () => i(!1) }),
1602
- /* @__PURE__ */ n(
1603
- Un,
1604
- {
1605
- open: s,
1606
- onClose: () => l(!1),
1607
- jobDocumentId: p
1608
- }
1609
- )
1610
- ] }) : null
1611
- ] });
1612
- }, Gn = (e) => {
1613
- const { get: t } = M();
1614
- return $({
1615
- queryKey: ["compare-schemas"],
1616
- queryFn: async () => {
1617
- const { data: o } = await t(`/${_}/compare-schemas`);
1618
- return o;
1619
- },
1620
- enabled: e
1621
- });
1622
- }, Qn = (e = !0) => {
1623
- const { get: t } = M();
1624
- return $({
1625
- queryKey: [Tt],
1626
- enabled: e,
1627
- queryFn: async () => {
1628
- const { data: o } = await t(
1629
- `/${_}/promotion/promotable-content-types`
1630
- );
1631
- return o.contentTypes;
1632
- }
1633
- });
1634
- }, Hn = (e, t) => {
1635
- const o = new Set((e ?? []).map((i) => i.documentId)), r = [...t.entries()].filter(([i]) => !o.has(i)).map(([, i]) => Yt(i)).filter((i) => i != null);
1636
- return [...e ?? [], ...r];
1637
- }, Vn = (e, t) => {
1638
- const o = new Set(t.map((i) => i.documentId)), r = /* @__PURE__ */ new Map();
1639
- for (const [i, s] of e)
1640
- o.has(i) && r.set(i, s);
1641
- return r;
1642
- }, Yn = (e, t) => {
1643
- const o = t[0]?.documentId;
1644
- if (!o)
1645
- return e;
1646
- const r = new Map(e);
1647
- return r.set(o, t), r;
1648
- }, jn = (e) => {
1649
- const [t, o] = L([]), [r, i] = L(() => /* @__PURE__ */ new Map()), s = Ye(() => {
1650
- o([]), i(/* @__PURE__ */ new Map());
1651
- }, []);
1652
- oe(() => {
1653
- i(
1654
- (d) => Vn(d, t)
1655
- );
1656
- }, [t]);
1657
- const l = Ye((d) => {
1658
- i(
1659
- (m) => Yn(m, d)
1660
- );
1661
- }, []), c = Ze(
1662
- () => Hn(e, r),
1663
- [e, r]
1664
- );
1665
- return {
1666
- selectedPromotions: t,
1667
- setSelectedPromotions: o,
1668
- clear: s,
1669
- rememberEntityGroup: l,
1670
- entitiesForPreview: c
1671
- };
1672
- }, Xn = () => {
1673
- const { formatMessage: e } = S(), {
1674
- isLoading: t,
1675
- allowedActions: { canExecute: o = !1, canRead: r = !1 }
1676
- } = Ct([...xe.promotionExecute, ...xe.settingsRead]), [{ query: i }, s] = bt(), l = We(!1), c = ae.object({
1677
- page: ae.coerce.number().optional().default(1),
1678
- pageSize: ae.coerce.number().optional().default(10),
1679
- uid: ae.string().optional()
1680
- }).parse(i), [d, m] = L(!1), {
1681
- data: p,
1682
- isLoading: f,
1683
- isError: g
1684
- } = Dt(), C = !f && !g && !!p?.active, y = !f && (g || !p?.active), { data: R } = ut(c.uid ?? "", C), {
1685
- data: D,
1686
- isSuccess: X,
1687
- isLoading: F
1688
- } = Qn(C), x = X && (D?.length ?? 0) > 0, I = D?.map((A) => ({
1689
- key: A.uid,
1690
- value: A.uid,
1691
- label: A.displayName
1692
- })) ?? [], {
1693
- data: b,
1694
- isLoading: G,
1695
- error: Q
1696
- } = Ot({
1697
- uid: c.uid,
1698
- page: c.page,
1699
- pageSize: c.pageSize,
1700
- enabled: C
1701
- }), {
1702
- selectedPromotions: E,
1703
- setSelectedPromotions: O,
1704
- clear: H,
1705
- rememberEntityGroup: Se,
1706
- entitiesForPreview: J
1707
- } = jn(b?.results), w = (A) => {
1708
- l.current = !1, s({
1709
- ...i,
1710
- page: 1,
1711
- pageSize: 10,
1712
- uid: A
1713
- }), H();
1714
- }, Ce = () => {
1715
- l.current = !0, s({
1716
- ...i,
1717
- page: 1,
1718
- pageSize: 10,
1719
- uid: void 0
1720
- }), H();
1721
- }, be = () => {
1722
- m(!1), H();
1723
- }, {
1724
- data: U,
1725
- isLoading: Z,
1726
- error: Oe
1727
- } = Gn(C && x), Ue = b?.mainField, mt = b?.maxDepthReached, Ie = b?.errors, gt = Ie?.type === "unconfigured_relations" ? Ie : void 0, we = Ie?.type === "sync_in_progress", Ee = we || R?.status === "running", ie = !y && !Z && (!!Oe || !!U && !U?.isMatch), $e = !o || f || y || Z || ie || we || R?.status === "running" || R?.status === "queued", ht = !!c.uid && G, pt = () => {
1728
- switch (!0) {
1729
- case (F || ht):
1730
- return /* @__PURE__ */ n(ve, {});
1731
- case (X && !x):
1732
- return /* @__PURE__ */ n(
1733
- k,
1734
- {
1735
- title: e({
1736
- id: a("homePage.alert.configurationNeeded.title")
1737
- }),
1738
- description: e({
1739
- id: a(
1740
- r ? "homePage.alert.configurationNeeded.description" : "homePage.alert.configurationNeeded.readOnlyDescription"
1741
- )
1742
- }),
1743
- action: r ? /* @__PURE__ */ n(qe, { tag: Re, to: "/settings/xecp/configuration", children: e({
1744
- id: a("homePage.alert.configurationNeeded.linkText")
1745
- }) }) : void 0,
1746
- variant: "danger"
1747
- }
1748
- );
1749
- case Ee:
1750
- return /* @__PURE__ */ n(
1751
- z,
1752
- {
1753
- content: e({
1754
- id: a("homePage.alert.syncInProgress.contentUnavailable")
1755
- })
1756
- }
1757
- );
1758
- case (b?.results && b?.results?.length > 0):
1759
- return /* @__PURE__ */ u(K, { children: [
1760
- mt && /* @__PURE__ */ n(
1761
- k,
1762
- {
1763
- title: e({
1764
- id: a("homePage.alert.maxDepthExceeded.title")
1765
- }),
1766
- variant: "warning",
1767
- description: e({
1768
- id: a("homePage.alert.maxDepthExceeded.description")
1769
- })
1770
- }
1771
- ),
1772
- /* @__PURE__ */ n(
1773
- sn,
1774
- {
1775
- entities: b?.results,
1776
- contentTypeMainField: Ue,
1777
- selectedPromotions: E,
1778
- setSelectedPromotions: O,
1779
- onRememberEntityGroup: Se,
1780
- canExecute: o && !y
1781
- }
1782
- )
1783
- ] });
1784
- case !!Q:
1785
- return /* @__PURE__ */ n(
1786
- z,
1787
- {
1788
- icon: /* @__PURE__ */ n(Be, { width: 24, height: 24 }),
1789
- content: e({ id: a("homePage.errorLoadingEntities") })
1790
- }
1791
- );
1792
- case (b?.results && b?.results?.length === 0):
1793
- return /* @__PURE__ */ n(
1794
- Ht,
1795
- {
1796
- contentTypeUid: c.uid ?? "",
1797
- hasExistingSnapshot: b?.snapshot?.exists ?? !1,
1798
- unconfiguredRelationsError: gt,
1799
- isGetSnapshotDisabled: $e,
1800
- canExecute: o && !y,
1801
- canReadSettings: r
1802
- }
1803
- );
1804
- default:
1805
- return /* @__PURE__ */ n(
1806
- z,
1807
- {
1808
- content: e({
1809
- id: a("homePage.youNeedToSelectAContentTypeToSeeTheEntities")
1810
- })
1811
- }
1812
- );
1813
- }
1814
- }, Ge = b?.snapshot?.exists ?? !1, yt = !Ee && Ge && b?.pagination && b?.pagination?.pageCount > 0, ft = !o || f || y || Z || !x || ie || !c.uid || E.length === 0 || Ee, Pt = F || f || Z || y || ie || !x, St = () => {
1815
- switch (!0) {
1816
- case f:
1817
- return /* @__PURE__ */ u(P, { gap: 2, alignItems: "center", children: [
1818
- /* @__PURE__ */ n(ve, { small: !0 }),
1819
- /* @__PURE__ */ n(h, { variant: "omega", children: e({ id: a("homePage.verifyingLicense") }) })
1820
- ] });
1821
- case y:
1822
- return /* @__PURE__ */ n(Gt, { canReadSettings: r });
1823
- case Z:
1824
- return /* @__PURE__ */ u(P, { gap: 2, alignItems: "center", children: [
1825
- /* @__PURE__ */ n(ve, { small: !0 }),
1826
- /* @__PURE__ */ n(h, { variant: "omega", children: e({ id: a("homePage.verifyingSchemas") }) })
1827
- ] });
1828
- case ie:
1829
- return /* @__PURE__ */ n(
1830
- Qt,
1831
- {
1832
- compareSchemasData: U,
1833
- errorCompareSchemas: Oe?.message
1834
- }
1835
- );
1836
- default:
1837
- return null;
1838
- }
1839
- }, Qe = l.current || !!c.uid || !x;
1840
- return oe(() => {
1841
- if (Qe) return;
1842
- const A = D?.[0]?.uid;
1843
- A && s({
1844
- ...i,
1845
- uid: A,
1846
- page: 1,
1847
- pageSize: 10
1848
- });
1849
- }, [Qe, D, i, s]), t ? /* @__PURE__ */ n(W.Loading, {}) : /* @__PURE__ */ u(K, { children: [
1850
- /* @__PURE__ */ n(W.Title, { children: e({ id: a("homePage.title") }) }),
1851
- /* @__PURE__ */ u(W.Main, { children: [
1852
- /* @__PURE__ */ n(
1853
- He.Header,
1854
- {
1855
- title: e({ id: a("homePage.title") }),
1856
- primaryAction: o ? /* @__PURE__ */ n(T, { disabled: ft, onClick: () => m(!0), children: e({ id: a("homePage.promoteContent") }) }) : null
1857
- }
1858
- ),
1859
- /* @__PURE__ */ n(He.Content, { children: /* @__PURE__ */ u(P, { direction: "column", alignItems: "stretch", gap: 4, children: [
1860
- St(),
1861
- /* @__PURE__ */ n(P, { children: /* @__PURE__ */ n(
1862
- At,
1863
- {
1864
- name: "contentType",
1865
- placeholder: e({ id: a("homePage.selectContentType") }),
1866
- onClear: Ce,
1867
- onChange: w,
1868
- options: I,
1869
- value: c.uid,
1870
- disabled: Pt
1871
- }
1872
- ) }),
1873
- c?.uid && !y ? /* @__PURE__ */ u(K, { children: [
1874
- /* @__PURE__ */ n(
1875
- $n,
1876
- {
1877
- contentTypeUid: c.uid,
1878
- isSyncInProgressFromComparison: we,
1879
- canExecute: o && !y
1880
- }
1881
- ),
1882
- /* @__PURE__ */ n(
1883
- $t,
1884
- {
1885
- contentTypeUid: c.uid,
1886
- selectedPromotionsLength: E.length,
1887
- syncedAt: b?.snapshot?.syncedAt ?? null,
1888
- isGetSnapshotDisabled: $e,
1889
- hasSnapshot: Ge,
1890
- clearSelectedPromotions: H,
1891
- canExecute: o && !y
1892
- }
1893
- )
1894
- ] }) : null,
1895
- y ? null : pt(),
1896
- yt && !y ? /* @__PURE__ */ u(
1897
- Te.Root,
1898
- {
1899
- total: b?.pagination?.total || 0,
1900
- pageCount: b?.pagination?.pageCount || 0,
1901
- children: [
1902
- /* @__PURE__ */ n(Te.PageSize, {}),
1903
- /* @__PURE__ */ n(Te.Links, {})
1904
- ]
1905
- }
1906
- ) : null
1907
- ] }) })
1908
- ] }),
1909
- o && !y && d ? /* @__PURE__ */ n(
1910
- qn,
1911
- {
1912
- open: d,
1913
- onClose: be,
1914
- selectedPromotions: E,
1915
- contentTypeUid: c.uid ?? "",
1916
- contentTypeMainField: Ue,
1917
- comparedEntities: J
1918
- }
1919
- ) : null
1920
- ] });
1921
- }, Jn = () => /* @__PURE__ */ n(W.Protect, { permissions: [...xe.promotionRead], children: /* @__PURE__ */ n(Xn, {}) }), uo = () => /* @__PURE__ */ n(vt, { children: /* @__PURE__ */ u(It, { children: [
1922
- /* @__PURE__ */ n(Ve, { index: !0, element: /* @__PURE__ */ n(Jn, {}) }),
1923
- /* @__PURE__ */ n(Ve, { path: "*", element: /* @__PURE__ */ n(W.Error, {}) })
1924
- ] }) });
1925
- export {
1926
- uo as default
1927
- };