@sensinum/strapi-plugin-xecp 5.0.0 → 5.0.2

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,50 +1,50 @@
1
1
  import { jsx as t, Fragment as $, jsxs as u } from "react/jsx-runtime";
2
- import { useFetchClient as D, useForm as re, useNotification as se, Layouts as O, useRBAC as oe, Page as K, Form as ae } from "@strapi/strapi/admin";
3
- import { U, g as a, P as H } from "./index-pRp3V-Jg.mjs";
4
- import { S as P, P as le, Q as de } from "./queryKeys-rUHP1d6p.mjs";
2
+ import { useFetchClient as P, useForm as re, useNotification as se, Layouts as x, useRBAC as oe, Page as U, Form as ae } from "@strapi/strapi/admin";
3
+ import { U as D, g as a, P as G } from "./index-Bgk0cBQK.mjs";
4
+ import { S as K, P as le, Q as de } from "./queryKeys-rUHP1d6p.mjs";
5
5
  import { useEffect as ce, useRef as pe, useMemo as ue } from "react";
6
- import { useIntl as f } from "react-intl";
7
- import ge, { z as g } from "zod";
8
- import { useQuery as V, queryOptions as me, useQueryClient as he, useMutation as W } from "@tanstack/react-query";
9
- import { Box as b, Field as h, SingleSelect as ye, SingleSelectOption as Te, Typography as C, Table as fe, Thead as Ce, Tr as _, Th as L, Tbody as be, Td as I, MultiSelect as ve, MultiSelectOption as Ee, Flex as G, Tooltip as Se, Grid as A, NumberInput as Ae, TextInput as j, Button as z, Loader as we } from "@strapi/design-system";
6
+ import { useIntl as b } from "react-intl";
7
+ import me, { z as m } from "zod";
8
+ import { useQuery as _, queryOptions as ge, useQueryClient as he, useMutation as H } from "@tanstack/react-query";
9
+ import { Box as E, Field as h, SingleSelect as ye, SingleSelectOption as Te, Typography as C, Table as fe, Thead as be, Tr as O, Th as L, Tbody as Ce, Td as q, MultiSelect as Ee, MultiSelectOption as ve, Flex as W, Tooltip as Se, Grid as A, NumberInput as Ae, TextInput as j, Button as z, Loader as we } from "@strapi/design-system";
10
10
  import { Information as Re, Check as X } from "@strapi/icons";
11
- import { isEqual as De } from "lodash";
11
+ import { isEqual as Pe } from "lodash";
12
12
  import { T as Q, A as Z } from "./TruncatedTypography-Df3hMZdB.mjs";
13
- const Ue = 3, w = g.enum(["Related", "Promotable"]);
14
- g.object({
15
- targetEnvApiKey: g.string().optional(),
16
- targetEnvApiUrl: g.url().optional(),
17
- comparisonDepth: g.number().positive().optional(),
18
- contentTypes: g.array(g.object({ uid: g.string(), key: g.string(), kind: w })).optional()
13
+ const De = 3, w = m.enum(["Related", "Promotable"]);
14
+ m.object({
15
+ targetEnvApiKey: m.string().optional(),
16
+ targetEnvApiUrl: m.url().optional(),
17
+ comparisonDepth: m.number().positive().optional(),
18
+ contentTypes: m.array(m.object({ uid: m.string(), key: m.string(), kind: w })).optional()
19
19
  });
20
20
  const Fe = () => {
21
- const { get: e } = D();
22
- return V({
23
- queryKey: [P],
21
+ const { get: e } = P();
22
+ return _({
23
+ queryKey: [K],
24
24
  queryFn: async () => {
25
- const { data: n } = await e(`/${U}/settings`);
25
+ const { data: n } = await e(`/${D}/settings`);
26
26
  return n;
27
27
  }
28
28
  });
29
- }, Ke = [
30
- P,
29
+ }, Ue = [
30
+ K,
31
31
  "content-type-options"
32
- ], Pe = () => {
33
- const { get: e } = D();
34
- return V({
35
- queryKey: Ke,
32
+ ], Ke = () => {
33
+ const { get: e } = P();
34
+ return _({
35
+ queryKey: Ue,
36
36
  queryFn: async () => {
37
37
  const { data: n } = await e(
38
- `/${U}/settings/content-type-options`
38
+ `/${D}/settings/content-type-options`
39
39
  );
40
40
  return n;
41
41
  }
42
42
  });
43
- }, ke = (e) => [P, "related-content-types", e], qe = (e, n) => me({
43
+ }, ke = (e) => [K, "related-content-types", e], Ie = (e, n) => ge({
44
44
  queryKey: ke(n),
45
45
  queryFn: async () => {
46
46
  const { data: r } = await e(
47
- `/${U}/settings/related-content-types`,
47
+ `/${D}/settings/related-content-types`,
48
48
  {
49
49
  params: {
50
50
  allowed: n.join(",")
@@ -53,40 +53,40 @@ const Fe = () => {
53
53
  );
54
54
  return r;
55
55
  }
56
- }), N = (e) => {
57
- const { get: n } = D();
58
- return V({
59
- ...qe(n, e),
56
+ }), M = (e) => {
57
+ const { get: n } = P();
58
+ return _({
59
+ ...Ie(n, e),
60
60
  enabled: e.length > 0
61
61
  });
62
62
  }, Le = () => {
63
- const { put: e } = D(), n = he();
64
- return W({
65
- mutationFn: async (r) => e(`/${U}/settings`, r),
63
+ const { put: e } = P(), n = he();
64
+ return H({
65
+ mutationFn: async (r) => e(`/${D}/settings`, r),
66
66
  onSuccess: async () => {
67
67
  await Promise.all([
68
- n.invalidateQueries({ queryKey: [P] }),
68
+ n.invalidateQueries({ queryKey: [K] }),
69
69
  n.invalidateQueries({ queryKey: [le] })
70
70
  ]);
71
71
  }
72
72
  });
73
- }, Ie = (e, n) => Object.entries(n).reduce((r, [s, i]) => De(i, e[s]) ? r : {
73
+ }, qe = (e, n) => Object.entries(n).reduce((r, [o, i]) => Pe(i, e[o]) ? r : {
74
74
  ...r,
75
- [s]: i
76
- }, {}), J = g.object({
77
- allowedContentTypes: g.array(g.string()).min(1, { message: "settings.form.error.minimalArrayLength" }),
78
- contentTypeSettings: g.record(
79
- g.string(),
80
- g.object({
81
- key: g.string({ message: "settings.form.error.required" }).min(1, { message: "settings.form.error.required" }).optional()
75
+ [o]: i
76
+ }, {}), J = m.object({
77
+ allowedContentTypes: m.array(m.string()).min(1, { message: "settings.form.error.minimalArrayLength" }),
78
+ contentTypeSettings: m.record(
79
+ m.string(),
80
+ m.object({
81
+ key: m.string({ message: "settings.form.error.required" }).min(1, { message: "settings.form.error.required" }).optional()
82
82
  }).optional()
83
83
  ),
84
- targetEnvApiKey: g.string({ message: "settings.form.error.required" }).min(1, { message: "settings.form.error.required" }),
85
- targetEnvApiUrl: g.url({ message: "settings.form.error.validURL" }),
86
- comparisonDepth: g.number({ message: "settings.form.error.required" }).positive({ message: "settings.form.error.positive" })
87
- }), Me = J.extend({
88
- relatedContentTypes: g.string().array()
89
- }), Ve = Me.refine(
84
+ targetEnvApiKey: m.string({ message: "settings.form.error.required" }).min(1, { message: "settings.form.error.required" }),
85
+ targetEnvApiUrl: m.url({ message: "settings.form.error.validURL" }),
86
+ comparisonDepth: m.number({ message: "settings.form.error.required" }).positive({ message: "settings.form.error.positive" })
87
+ }), Ve = J.extend({
88
+ relatedContentTypes: m.string().array()
89
+ }), _e = Ve.refine(
90
90
  (e) => [
91
91
  ...e.allowedContentTypes,
92
92
  ...e.relatedContentTypes
@@ -100,54 +100,54 @@ const Fe = () => {
100
100
  return J.pick({ contentTypeSettings: !0 }).safeParse(e.value).success;
101
101
  }
102
102
  }
103
- ), Ne = (e, n) => {
103
+ ), Me = (e, n) => {
104
104
  const r = [...e.allowedContentTypes, ...n];
105
105
  return {
106
106
  ...e,
107
107
  contentTypeSettings: Object.fromEntries(
108
- r.map((s) => [
109
- s,
110
- e.contentTypeSettings[s]
108
+ r.map((o) => [
109
+ o,
110
+ e.contentTypeSettings[o]
111
111
  ])
112
112
  )
113
113
  };
114
- }, ee = (e) => e.replace(".", ":"), M = (e) => e.replace(/:(?!.*:)/, "."), xe = (e, n) => {
115
- const s = {
116
- ...Ne(n, e),
114
+ }, ee = (e) => e.replace(".", ":"), V = (e) => e.replace(/:(?!.*:)/, "."), Ne = (e, n) => {
115
+ const o = {
116
+ ...Me(n, e),
117
117
  relatedContentTypes: e
118
- }, i = Ve.parse(s);
118
+ }, i = _e.parse(o);
119
119
  return {
120
120
  contentTypes: [
121
121
  ...i.allowedContentTypes,
122
122
  ...i.relatedContentTypes
123
- ].map((p) => ({
124
- uid: M(p),
125
- key: i.contentTypeSettings[p]?.key,
126
- kind: i.allowedContentTypes.includes(p) ? w.enum.Promotable : w.enum.Related
123
+ ].map((l) => ({
124
+ uid: V(l),
125
+ key: i.contentTypeSettings[l]?.key,
126
+ kind: i.allowedContentTypes.includes(l) ? w.enum.Promotable : w.enum.Related
127
127
  })),
128
128
  targetEnvApiKey: i.targetEnvApiKey,
129
129
  targetEnvApiUrl: i.targetEnvApiUrl,
130
130
  comparisonDepth: i.comparisonDepth
131
131
  };
132
- }, Oe = {
132
+ }, xe = {
133
133
  background: "neutral0",
134
134
  hasRadius: !0,
135
135
  shadow: "filterShadow",
136
136
  padding: 6,
137
137
  width: "100%"
138
- }, x = ({ children: e, marginTop: n }) => /* @__PURE__ */ t(b, { ...Oe, marginTop: n, children: e }), _e = ({ onChange: e, attributes: n, value: r, name: s, error: i, disabled: d = !1 }) => {
139
- const { formatMessage: p } = f(), m = Object.entries(n).filter(
140
- ([c, o]) => o.type === "uid" || o.unique === !0
138
+ }, N = ({ children: e, marginTop: n }) => /* @__PURE__ */ t(E, { ...xe, marginTop: n, children: e }), Oe = ({ onChange: e, attributes: n, value: r, name: o, error: i, disabled: d = !1 }) => {
139
+ const { formatMessage: l } = b(), g = Object.entries(n).filter(
140
+ ([c, s]) => s.type === "uid" || s.unique === !0
141
141
  );
142
142
  return ce(() => {
143
- !r && m.length > 0 && e("");
144
- }, []), /* @__PURE__ */ t($, { children: m.length > 0 ? /* @__PURE__ */ u(h.Root, { error: i && p({ id: a(i) }), children: [
145
- /* @__PURE__ */ t(ye, { name: s, value: r, onChange: e, required: !0, disabled: d, children: m.map(([c, o]) => /* @__PURE__ */ t(Te, { value: c, children: c }, c)) }),
143
+ !r && g.length > 0 && e("");
144
+ }, []), /* @__PURE__ */ t($, { children: g.length > 0 ? /* @__PURE__ */ u(h.Root, { error: i && l({ id: a(i) }), children: [
145
+ /* @__PURE__ */ t(ye, { name: o, value: r, onChange: e, required: !0, disabled: d, children: g.map(([c, s]) => /* @__PURE__ */ t(Te, { value: c, children: c }, c)) }),
146
146
  /* @__PURE__ */ t(h.Error, {})
147
147
  ] }) : /* @__PURE__ */ t(
148
148
  h.Root,
149
149
  {
150
- error: p({ id: a("settings.table.uniqueKeyRequiredWarning") }),
150
+ error: l({ id: a("settings.table.uniqueKeyRequiredWarning") }),
151
151
  children: /* @__PURE__ */ t(h.Error, {})
152
152
  }
153
153
  ) });
@@ -155,24 +155,24 @@ const Fe = () => {
155
155
  label: e,
156
156
  contentTypes: n,
157
157
  setFormValue: r,
158
- errors: s,
158
+ errors: o,
159
159
  contentTypeSettings: i,
160
160
  shouldShowRequiredBy: d,
161
- isReadOnly: p
161
+ isReadOnly: l
162
162
  }) => {
163
- const { formatMessage: m } = f();
164
- return /* @__PURE__ */ u(b, { marginTop: 4, width: "100%", paddingTop: 4, children: [
165
- /* @__PURE__ */ t(b, { marginBottom: 1, children: /* @__PURE__ */ t(C, { variant: "pi", textColor: "neutral800", fontWeight: "bold", children: e }) }),
163
+ const { formatMessage: g } = b();
164
+ return /* @__PURE__ */ u(E, { marginTop: 4, width: "100%", paddingTop: 4, children: [
165
+ /* @__PURE__ */ t(E, { marginBottom: 1, children: /* @__PURE__ */ t(C, { variant: "pi", textColor: "neutral800", fontWeight: "bold", children: e }) }),
166
166
  /* @__PURE__ */ u(fe, { width: "100%", rowCount: n.length, colCount: d ? 3 : 2, children: [
167
- /* @__PURE__ */ t(Ce, { children: /* @__PURE__ */ u(_, { children: [
168
- /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(C, { variant: "sigma", children: m({ id: a("settings.table.contentType") }) }) }),
169
- d && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(C, { variant: "sigma", children: m({ id: a("settings.table.requiredBy") }) }) }),
170
- /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(C, { variant: "sigma", children: m({ id: a("settings.table.uniqueKey") }) }) })
167
+ /* @__PURE__ */ t(be, { children: /* @__PURE__ */ u(O, { children: [
168
+ /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(C, { variant: "sigma", children: g({ id: a("settings.table.contentType") }) }) }),
169
+ d && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(C, { variant: "sigma", children: g({ id: a("settings.table.requiredBy") }) }) }),
170
+ /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(C, { variant: "sigma", children: g({ id: a("settings.table.uniqueKey") }) }) })
171
171
  ] }) }),
172
- /* @__PURE__ */ t(be, { children: n.map((c) => {
173
- const o = `contentTypeSettings.${c.uid}.key`;
174
- return /* @__PURE__ */ u(_, { children: [
175
- /* @__PURE__ */ t(I, { width: d ? "25%" : "50%", children: /* @__PURE__ */ t(
172
+ /* @__PURE__ */ t(Ce, { children: n.map((c) => {
173
+ const s = `contentTypeSettings.${c.uid}.key`;
174
+ return /* @__PURE__ */ u(O, { children: [
175
+ /* @__PURE__ */ t(q, { width: d ? "25%" : "50%", children: /* @__PURE__ */ t(
176
176
  Q,
177
177
  {
178
178
  maxCharacters: 55,
@@ -180,7 +180,7 @@ const Fe = () => {
180
180
  textColor: "neutral800"
181
181
  }
182
182
  ) }),
183
- d && /* @__PURE__ */ t(I, { width: "25%", children: /* @__PURE__ */ t(
183
+ d && /* @__PURE__ */ t(q, { width: "25%", children: /* @__PURE__ */ t(
184
184
  Q,
185
185
  {
186
186
  maxCharacters: 55,
@@ -188,17 +188,17 @@ const Fe = () => {
188
188
  textColor: "neutral800"
189
189
  }
190
190
  ) }),
191
- /* @__PURE__ */ t(I, { width: "50%", children: /* @__PURE__ */ t(
192
- _e,
191
+ /* @__PURE__ */ t(q, { width: "50%", children: /* @__PURE__ */ t(
192
+ Oe,
193
193
  {
194
- onChange: (l) => {
195
- r(o, l);
194
+ onChange: (p) => {
195
+ r(s, p);
196
196
  },
197
197
  value: i[c.uid]?.key,
198
198
  attributes: c.schema.attributes,
199
- name: o,
200
- error: s[o],
201
- disabled: p
199
+ name: s,
200
+ error: o[s],
201
+ disabled: l
202
202
  }
203
203
  ) })
204
204
  ] }, c.uid);
@@ -209,34 +209,34 @@ const Fe = () => {
209
209
  allowedContentTypes: e,
210
210
  contentTypeSettings: n,
211
211
  setFormValue: r,
212
- promotableContentTypes: s,
212
+ promotableContentTypes: o,
213
213
  errors: i,
214
214
  isReadOnly: d
215
215
  }) => {
216
- const { formatMessage: p } = f(), m = e.map(
217
- (l) => s?.find((T) => T.uid === l)
218
- ), { data: c, isLoading: o } = N(e);
219
- return o ? null : /* @__PURE__ */ u(x, { children: [
220
- /* @__PURE__ */ t(C, { variant: "delta", children: p({ id: a("settings.allowedContentTypes") }) }),
221
- /* @__PURE__ */ t(b, { marginTop: 4, width: "100%", children: /* @__PURE__ */ u(
216
+ const { formatMessage: l } = b(), g = e.map(
217
+ (p) => o?.find((y) => y.uid === p)
218
+ ), { data: c, isLoading: s } = M(e);
219
+ return s ? null : /* @__PURE__ */ u(N, { children: [
220
+ /* @__PURE__ */ t(C, { variant: "delta", children: l({ id: a("settings.allowedContentTypes") }) }),
221
+ /* @__PURE__ */ t(E, { marginTop: 4, width: "100%", children: /* @__PURE__ */ u(
222
222
  h.Root,
223
223
  {
224
224
  width: "100%",
225
- error: i.allowedContentTypes && p({ id: a(i.allowedContentTypes) }),
225
+ error: i.allowedContentTypes && l({ id: a(i.allowedContentTypes) }),
226
226
  children: [
227
- /* @__PURE__ */ t(h.Label, { children: p({ id: a("settings.allowedContentTypes.label") }) }),
227
+ /* @__PURE__ */ t(h.Label, { children: l({ id: a("settings.allowedContentTypes.label") }) }),
228
228
  /* @__PURE__ */ t(
229
- ve,
229
+ Ee,
230
230
  {
231
231
  withTags: !0,
232
232
  name: "allowedContentTypes",
233
233
  value: e,
234
- onChange: (l) => {
235
- r("allowedContentTypes", l);
234
+ onChange: (p) => {
235
+ r("allowedContentTypes", p);
236
236
  },
237
237
  hasError: !!i.allowedContentTypes,
238
238
  disabled: d,
239
- children: s?.map((l) => /* @__PURE__ */ t(Ee, { value: l.uid, children: l.schema.displayName }, l.uid))
239
+ children: o?.map((p) => /* @__PURE__ */ t(ve, { value: p.uid, children: p.schema.displayName }, p.uid))
240
240
  }
241
241
  ),
242
242
  /* @__PURE__ */ t(h.Error, {})
@@ -246,10 +246,10 @@ const Fe = () => {
246
246
  e?.length > 0 && /* @__PURE__ */ t(
247
247
  B,
248
248
  {
249
- label: p({
249
+ label: l({
250
250
  id: a("settings.table.keyForEligibleContentTypes")
251
251
  }),
252
- contentTypes: m,
252
+ contentTypes: g,
253
253
  setFormValue: r,
254
254
  errors: i,
255
255
  contentTypeSettings: n,
@@ -259,7 +259,7 @@ const Fe = () => {
259
259
  (c?.length ?? 0) > 0 && /* @__PURE__ */ t(
260
260
  B,
261
261
  {
262
- label: p({
262
+ label: l({
263
263
  id: a("settings.table.keyForRelatedContentTypes")
264
264
  }),
265
265
  contentTypes: c ?? [],
@@ -272,8 +272,8 @@ const Fe = () => {
272
272
  )
273
273
  ] });
274
274
  }, Qe = () => {
275
- const { formatMessage: e } = f();
276
- return /* @__PURE__ */ t(b, { marginTop: 4, children: /* @__PURE__ */ t(
275
+ const { formatMessage: e } = b();
276
+ return /* @__PURE__ */ t(E, { marginTop: 4, children: /* @__PURE__ */ t(
277
277
  Z,
278
278
  {
279
279
  title: e({ id: a("settings.alert.comparisonDepthHigh.title") }),
@@ -283,10 +283,10 @@ const Fe = () => {
283
283
  })
284
284
  }
285
285
  ) });
286
- }, Be = ({ comparisonDepth: e, setFormValue: n, errors: r, isReadOnly: s }) => {
287
- const { formatMessage: i } = f();
288
- return /* @__PURE__ */ u(x, { marginTop: 4, children: [
289
- /* @__PURE__ */ u(G, { marginBottom: 4, gap: 1, children: [
286
+ }, Be = ({ comparisonDepth: e, setFormValue: n, errors: r, isReadOnly: o }) => {
287
+ const { formatMessage: i } = b();
288
+ return /* @__PURE__ */ u(N, { marginTop: 4, children: [
289
+ /* @__PURE__ */ u(W, { marginBottom: 4, gap: 1, children: [
290
290
  /* @__PURE__ */ t(C, { variant: "delta", children: i({ id: a("settings.comparisonDepth") }) }),
291
291
  /* @__PURE__ */ t(Se, { label: i({ id: a("settings.comparisonDepth.tooltip") }), children: /* @__PURE__ */ t(Re, {}) })
292
292
  ] }),
@@ -303,7 +303,7 @@ const Fe = () => {
303
303
  value: e,
304
304
  onValueChange: (d) => n("comparisonDepth", d),
305
305
  name: "comparisonDepth",
306
- disabled: s
306
+ disabled: o
307
307
  }
308
308
  ),
309
309
  /* @__PURE__ */ t(h.Error, {})
@@ -313,17 +313,17 @@ const Fe = () => {
313
313
  e > 5 && /* @__PURE__ */ t(Qe, {})
314
314
  ] });
315
315
  }, Ye = ({ staleValueMessages: e }) => {
316
- const { formatMessage: n } = f();
317
- return /* @__PURE__ */ t(b, { marginBottom: 4, children: /* @__PURE__ */ u(
316
+ const { formatMessage: n } = b();
317
+ return /* @__PURE__ */ t(E, { marginBottom: 4, children: /* @__PURE__ */ u(
318
318
  Z,
319
319
  {
320
320
  title: n({ id: a("settings.alert.staleValuesRemoved.title") }),
321
321
  variant: "danger",
322
322
  children: [
323
323
  n({ id: a("settings.alert.staleValuesRemoved.description") }),
324
- e.map((r, s) => /* @__PURE__ */ u("span", { children: [
324
+ e.map((r, o) => /* @__PURE__ */ u("span", { children: [
325
325
  /* @__PURE__ */ t("br", {}),
326
- s + 1,
326
+ o + 1,
327
327
  ".",
328
328
  " ",
329
329
  n(
@@ -332,46 +332,56 @@ const Fe = () => {
332
332
  },
333
333
  r.variables
334
334
  )
335
- ] }, s))
335
+ ] }, o))
336
336
  ]
337
337
  }
338
338
  ) });
339
339
  }, $e = () => {
340
- const { post: e } = D();
341
- return W({
340
+ const { post: e } = P();
341
+ return H({
342
342
  mutationFn: async (n) => {
343
343
  const { data: r } = await e(
344
- `/${U}/settings/testConnection`,
344
+ `/${D}/settings/testConnection`,
345
345
  n
346
346
  );
347
347
  return r;
348
348
  }
349
349
  });
350
- }, He = (e) => {
351
- if (e.isUrlCorrect)
352
- return e.isApiKeyCorrect ? e.arePermissionsCorrect ? void 0 : "settings.form.error.badKeyPermissions" : "settings.form.error.badApiKey";
350
+ }, Ge = "settings.form.error.badApiUrl", He = {
351
+ badApiKey: "settings.form.error.badApiKey",
352
+ badPermissions: "settings.form.error.badKeyPermissions"
353
353
  }, We = ({
354
354
  targetEnvApiKey: e,
355
355
  targetEnvApiUrl: n,
356
356
  setFormValue: r,
357
- errors: s,
357
+ errors: o,
358
358
  isReadOnly: i
359
359
  }) => {
360
- const { formatMessage: d } = f(), p = $e(), { setErrors: m } = re("TargetEnvConfigurationSection", (l) => l), c = async () => {
361
- const l = await p.mutateAsync({ targetEnvApiKey: e, targetEnvApiUrl: n });
362
- m({
363
- ...s,
364
- targetEnvApiUrl: l.isUrlCorrect ? void 0 : "settings.form.error.badApiUrl",
365
- targetEnvApiKey: He(l)
366
- });
367
- }, o = p.isSuccess && !s.targetEnvApiKey && !s.targetEnvApiUrl;
368
- return /* @__PURE__ */ u(x, { marginTop: 4, children: [
369
- /* @__PURE__ */ t(b, { marginBottom: 4, children: /* @__PURE__ */ t(C, { variant: "delta", children: d({ id: a("settings.targetEnvConfiguration") }) }) }),
360
+ const { formatMessage: d } = b(), l = $e(), { setErrors: g } = re("TargetEnvConfigurationSection", (y) => y), c = async () => {
361
+ const y = (f) => {
362
+ g({
363
+ ...o,
364
+ targetEnvApiUrl: f.outcome === "badUrl" ? Ge : void 0,
365
+ targetEnvApiKey: He[f.outcome]
366
+ });
367
+ };
368
+ try {
369
+ const f = await l.mutateAsync({
370
+ targetEnvApiKey: e,
371
+ targetEnvApiUrl: n
372
+ });
373
+ y(f);
374
+ } catch {
375
+ y({ outcome: "unexpected" });
376
+ }
377
+ }, s = l.isSuccess && l.data?.outcome === "reachable", p = l.isError || l.data?.outcome === "unexpected";
378
+ return /* @__PURE__ */ u(N, { marginTop: 4, children: [
379
+ /* @__PURE__ */ t(E, { marginBottom: 4, children: /* @__PURE__ */ t(C, { variant: "delta", children: d({ id: a("settings.targetEnvConfiguration") }) }) }),
370
380
  /* @__PURE__ */ u(A.Root, { gap: 4, children: [
371
381
  /* @__PURE__ */ t(A.Item, { col: 6, alignItems: "start", children: /* @__PURE__ */ u(
372
382
  h.Root,
373
383
  {
374
- error: s.targetEnvApiUrl && d({ id: a(s.targetEnvApiUrl) }),
384
+ error: o.targetEnvApiUrl && d({ id: a(o.targetEnvApiUrl) }),
375
385
  width: "100%",
376
386
  children: [
377
387
  /* @__PURE__ */ t(h.Label, { children: d({ id: a("settings.targetEnvApiUrl.label") }) }),
@@ -391,7 +401,7 @@ const Fe = () => {
391
401
  /* @__PURE__ */ t(A.Item, { col: 6, alignItems: "start", children: /* @__PURE__ */ u(
392
402
  h.Root,
393
403
  {
394
- error: s.targetEnvApiKey && d({ id: a(s.targetEnvApiKey) }),
404
+ error: o.targetEnvApiKey && d({ id: a(o.targetEnvApiKey) }),
395
405
  width: "100%",
396
406
  children: [
397
407
  /* @__PURE__ */ t(h.Label, { children: d({ id: a("settings.targetEnvApiKey.label") }) }),
@@ -409,79 +419,80 @@ const Fe = () => {
409
419
  }
410
420
  ) }),
411
421
  /* @__PURE__ */ u(A.Item, { col: 6, children: [
412
- i ? null : /* @__PURE__ */ t(z, { onClick: c, disabled: p.isPending, children: d({ id: a("settings.form.testConnection") }) }),
413
- /* @__PURE__ */ u(G, { marginLeft: 1, alignItems: "center", children: [
414
- p.isPending && /* @__PURE__ */ t(we, { small: !0 }),
415
- o && /* @__PURE__ */ t(X, { color: "#5cb176" })
422
+ i ? null : /* @__PURE__ */ t(z, { onClick: c, disabled: l.isPending, children: d({ id: a("settings.form.testConnection") }) }),
423
+ /* @__PURE__ */ u(W, { marginLeft: 1, alignItems: "center", gap: 2, children: [
424
+ l.isPending && /* @__PURE__ */ t(we, { small: !0 }),
425
+ s && /* @__PURE__ */ t(X, { color: "#5cb176" }),
426
+ p && /* @__PURE__ */ t(C, { variant: "pi", textColor: "danger600", children: d({ id: a("settings.form.error.connectionFailed") }) })
416
427
  ] })
417
428
  ] })
418
429
  ] })
419
430
  ] });
420
- }, Ge = ({
431
+ }, ze = ({
421
432
  values: e,
422
433
  onChange: n,
423
434
  errors: r,
424
- setErrors: s,
435
+ setErrors: o,
425
436
  modified: i,
426
437
  settings: d,
427
- promotableContentTypes: p,
428
- staleValuesMessages: m,
438
+ promotableContentTypes: l,
439
+ staleValuesMessages: g,
429
440
  isReadOnly: c
430
441
  }) => {
431
- const { formatMessage: o } = f(), { toggleNotification: l } = se(), T = Le(), { data: v = [], isFetching: F } = N(e.allowedContentTypes), k = async () => {
442
+ const { formatMessage: s } = b(), { toggleNotification: p } = se(), y = Le(), { data: f = [], isFetching: F } = M(e.allowedContentTypes), k = async () => {
432
443
  try {
433
- const E = v.map((S) => S.uid), R = xe(E, e), y = Ie(d, R);
434
- await T.mutateAsync(y, {
444
+ const v = f.map((S) => S.uid), R = Ne(v, e), T = qe(d, R);
445
+ await y.mutateAsync(T, {
435
446
  onSuccess: () => {
436
- s({}), l({
447
+ o({}), p({
437
448
  type: "success",
438
- message: o({ id: a("settings.form.savedSuccessfully") })
449
+ message: s({ id: a("settings.form.savedSuccessfully") })
439
450
  });
440
451
  }
441
452
  });
442
- } catch (E) {
443
- if (E instanceof ge.ZodError) {
444
- const R = E.issues.reduce((y, S) => (y[S.path.join(".")] = S.message, y), {});
445
- s(R), l({
453
+ } catch (v) {
454
+ if (v instanceof me.ZodError) {
455
+ const R = v.issues.reduce((T, S) => (T[S.path.join(".")] = S.message, T), {});
456
+ o(R), p({
446
457
  type: "warning",
447
- message: o({ id: a("settings.form.error.validationMessage") })
458
+ message: s({ id: a("settings.form.error.validationMessage") })
448
459
  });
449
460
  } else
450
- l({
461
+ p({
451
462
  type: "warning",
452
- message: o({ id: a("settings.form.error.other") })
463
+ message: s({ id: a("settings.form.error.other") })
453
464
  });
454
465
  }
455
- }, q = c || !i && m.length === 0 || F || T.isPending;
466
+ }, I = c || !i && g.length === 0 || F || y.isPending;
456
467
  return /* @__PURE__ */ u($, { children: [
457
468
  /* @__PURE__ */ t(
458
- O.Header,
469
+ x.Header,
459
470
  {
460
- title: o({ id: a("settings.title") }),
461
- subtitle: o({ id: a("settings.subtitle") }),
471
+ title: s({ id: a("settings.title") }),
472
+ subtitle: s({ id: a("settings.subtitle") }),
462
473
  primaryAction: c ? null : /* @__PURE__ */ t(
463
474
  z,
464
475
  {
465
476
  type: "submit",
466
477
  startIcon: /* @__PURE__ */ t(X, {}),
467
478
  onClick: k,
468
- disabled: q,
469
- children: o({
479
+ disabled: I,
480
+ children: s({
470
481
  id: a("settings.form.submit")
471
482
  })
472
483
  }
473
484
  )
474
485
  }
475
486
  ),
476
- /* @__PURE__ */ u(O.Content, { children: [
477
- m.length > 0 && /* @__PURE__ */ t(Ye, { staleValueMessages: m }),
487
+ /* @__PURE__ */ u(x.Content, { children: [
488
+ g.length > 0 && /* @__PURE__ */ t(Ye, { staleValueMessages: g }),
478
489
  /* @__PURE__ */ t(
479
490
  je,
480
491
  {
481
492
  allowedContentTypes: e.allowedContentTypes,
482
493
  contentTypeSettings: e.contentTypeSettings,
483
494
  setFormValue: n,
484
- promotableContentTypes: p,
495
+ promotableContentTypes: l,
485
496
  errors: r,
486
497
  isReadOnly: c
487
498
  }
@@ -508,80 +519,80 @@ const Fe = () => {
508
519
  ] })
509
520
  ] });
510
521
  }, Y = (e) => {
511
- const n = e.contentTypes ?? [], r = n.filter((i) => i.kind === w.enum.Promotable).map((i) => i.uid), s = Object.fromEntries(
522
+ const n = e.contentTypes ?? [], r = n.filter((i) => i.kind === w.enum.Promotable).map((i) => i.uid), o = Object.fromEntries(
512
523
  n.map((i) => [i.uid, { key: i.key }])
513
524
  );
514
525
  return {
515
526
  allowedContentTypes: r,
516
- contentTypeSettings: s,
527
+ contentTypeSettings: o,
517
528
  targetEnvApiKey: e?.targetEnvApiKey ?? "",
518
529
  targetEnvApiUrl: e?.targetEnvApiUrl ?? "",
519
- comparisonDepth: e?.comparisonDepth ?? Ue
530
+ comparisonDepth: e?.comparisonDepth ?? De
520
531
  };
521
- }, ze = (e, n, r) => {
532
+ }, Xe = (e, n, r) => {
522
533
  if (!e.contentTypes)
523
534
  return [Y(e), []];
524
- const s = [], i = e.contentTypes.map((o) => ({
525
- ...o,
526
- uid: ee(o.uid)
527
- })), d = n.map((o) => o.uid), m = i.filter(
528
- (o) => {
529
- const l = !d.includes(o.uid);
530
- return l && s.push({
535
+ const o = [], i = e.contentTypes.map((s) => ({
536
+ ...s,
537
+ uid: ee(s.uid)
538
+ })), d = n.map((s) => s.uid), g = i.filter(
539
+ (s) => {
540
+ const p = !d.includes(s.uid);
541
+ return p && o.push({
531
542
  message: "settings.alert.staleValuesRemoved.contentTypeDeleted",
532
- variables: { uid: M(o.uid) }
533
- }), !l;
543
+ variables: { uid: V(s.uid) }
544
+ }), !p;
534
545
  }
535
- ).filter((o) => {
536
- const l = !r.includes(o.uid) && o.kind === w.enum.Related;
537
- return l && s.push({
546
+ ).filter((s) => {
547
+ const p = !r.includes(s.uid) && s.kind === w.enum.Related;
548
+ return p && o.push({
538
549
  message: "settings.alert.staleValuesRemoved.relationDeleted",
539
- variables: { uid: M(o.uid) }
540
- }), !l;
541
- }).map((o) => {
542
- const l = n.find(
543
- (F) => F.uid === o.uid
544
- ), T = l?.schema.attributes[o.key], v = T?.type === "uid" || T?.unique === !0;
545
- return v || s.push({
550
+ variables: { uid: V(s.uid) }
551
+ }), !p;
552
+ }).map((s) => {
553
+ const p = n.find(
554
+ (F) => F.uid === s.uid
555
+ ), y = p?.schema.attributes[s.key], f = y?.type === "uid" || y?.unique === !0;
556
+ return f || o.push({
546
557
  message: "settings.alert.staleValuesRemoved.keyDeleted",
547
558
  variables: {
548
- key: o.key,
549
- schemaDisplayName: l?.schema.displayName
559
+ key: s.key,
560
+ schemaDisplayName: p?.schema.displayName
550
561
  }
551
562
  }), {
552
- ...o,
553
- key: v ? o.key : void 0
563
+ ...s,
564
+ key: f ? s.key : void 0
554
565
  };
555
566
  });
556
567
  return [Y({
557
568
  ...e,
558
- contentTypes: m
559
- }), s];
560
- }, Xe = () => {
561
- const { formatMessage: e } = f(), n = pe(null), {
569
+ contentTypes: g
570
+ }), o];
571
+ }, Ze = () => {
572
+ const { formatMessage: e } = b(), n = pe(null), {
562
573
  isLoading: r,
563
- allowedActions: { canUpdate: s }
564
- } = oe([...H.settingsUpdate]), { data: i, isLoading: d } = Fe(), { data: p, isLoading: m } = Pe(), c = ue(
565
- () => (i?.contentTypes ?? []).filter((y) => y.kind === w.enum.Promotable).map((y) => ee(y.uid)),
574
+ allowedActions: { canUpdate: o }
575
+ } = oe([...G.settingsUpdate]), { data: i, isLoading: d } = Fe(), { data: l, isLoading: g } = Ke(), c = ue(
576
+ () => (i?.contentTypes ?? []).filter((T) => T.kind === w.enum.Promotable).map((T) => ee(T.uid)),
566
577
  [i?.contentTypes]
567
578
  ), {
568
- data: o = [],
569
- isLoading: l,
570
- isFetched: T
571
- } = N(c), v = c.length === 0 || T;
572
- if (r || d || m || l || !v || !i || !p)
573
- return /* @__PURE__ */ t(K.Loading, {});
574
- const { promotableContentTypes: k, relationLookupContentTypes: q } = p, [E, R] = ze(
579
+ data: s = [],
580
+ isLoading: p,
581
+ isFetched: y
582
+ } = M(c), f = c.length === 0 || y;
583
+ if (r || d || g || p || !f || !i || !l)
584
+ return /* @__PURE__ */ t(U.Loading, {});
585
+ const { promotableContentTypes: k, relationLookupContentTypes: I } = l, [v, R] = Xe(
575
586
  i,
576
- q,
577
- o.map((y) => y.uid)
587
+ I,
588
+ s.map((T) => T.uid)
578
589
  );
579
- return /* @__PURE__ */ u(K.Main, { children: [
580
- /* @__PURE__ */ t(K.Title, { children: e({ id: a("settings.metadata.title") }) }),
581
- /* @__PURE__ */ t(ae, { width: "100%", height: "100%", ref: n, method: "PUT", initialValues: E, children: ({ values: y, onChange: S, errors: te, setErrors: ne, modified: ie }) => /* @__PURE__ */ t(
582
- Ge,
590
+ return /* @__PURE__ */ u(U.Main, { children: [
591
+ /* @__PURE__ */ t(U.Title, { children: e({ id: a("settings.metadata.title") }) }),
592
+ /* @__PURE__ */ t(ae, { width: "100%", height: "100%", ref: n, method: "PUT", initialValues: v, children: ({ values: T, onChange: S, errors: te, setErrors: ne, modified: ie }) => /* @__PURE__ */ t(
593
+ ze,
583
594
  {
584
- values: y,
595
+ values: T,
585
596
  onChange: S,
586
597
  errors: te,
587
598
  setErrors: ne,
@@ -589,11 +600,11 @@ const Fe = () => {
589
600
  settings: i,
590
601
  promotableContentTypes: k,
591
602
  staleValuesMessages: R,
592
- isReadOnly: !s
603
+ isReadOnly: !o
593
604
  }
594
605
  ) })
595
606
  ] });
596
- }, ct = () => /* @__PURE__ */ t(K.Protect, { permissions: [...H.settingsRead], children: /* @__PURE__ */ t(de, { children: /* @__PURE__ */ t(Xe, {}) }) });
607
+ }, pt = () => /* @__PURE__ */ t(U.Protect, { permissions: [...G.settingsRead], children: /* @__PURE__ */ t(de, { children: /* @__PURE__ */ t(Ze, {}) }) });
597
608
  export {
598
- ct as default
609
+ pt as default
599
610
  };