@nivaro/react 0.3.3 → 0.3.5

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,72 +1,73 @@
1
1
  import { jsx as n, jsxs as c } from "react/jsx-runtime";
2
- import { useQuery as N } from "@tanstack/react-query";
2
+ import { useQuery as w } from "@tanstack/react-query";
3
3
  import { ChevronDown as te, Loader2 as ae, AlertTriangle as ce, X as oe, Check as de } from "lucide-react";
4
4
  import { useState as ne, useRef as me, useEffect as ue } from "react";
5
5
  import { useNivaroClient as fe, useItemEditAuth as pe, useDrilldown as $e } from "../../context.js";
6
+ import { parseAllowedCollections as Ie } from "../../lib/allowed-collections.js";
6
7
  import { get as C } from "../../lib/commands.js";
7
- import { useRecordReader as Ie } from "../../lib/record-loader.js";
8
+ import { useRecordReader as Ae } from "../../lib/record-loader.js";
8
9
  import { useOnlineUsers as he } from "../../lib/use-online-users.js";
9
10
  import { cn as Q, userOptionFilter as ye } from "../../lib/utils.js";
10
11
  import { UserAvatar as be } from "../UserAvatar.js";
11
- import { Command as xe, CommandInput as ge, CommandList as ve, CommandEmpty as ke, CommandGroup as Ne, CommandItem as we } from "../ui/command.js";
12
+ import { Command as xe, CommandInput as ge, CommandList as ve, CommandEmpty as ke, CommandGroup as we, CommandItem as Ne } from "../ui/command.js";
12
13
  import { Popover as Se, PopoverTrigger as _e, PopoverContent as Ce } from "../ui/popover.js";
13
14
  import { applyDisplayTemplate as qe } from "./helpers.js";
14
15
  import { useM2MStaging as Le } from "./M2MStagingContext.js";
15
- import { useStaleTip as Ae, RelatedItemLabel as ie } from "./RelationCombobox.js";
16
+ import { useStaleTip as Ke, RelatedItemLabel as ie } from "./RelationCombobox.js";
16
17
  function je(s) {
17
- return s.replace(/\(.*$/, "").trim().split(/\s+/).map((a) => a[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
18
+ return s.replace(/\(.*$/, "").trim().split(/\s+/).map((o) => o[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
18
19
  }
19
20
  function Fe(s) {
20
- return ((s == null ? void 0 : s.one_allowed_collections) ?? "").split(",").map((a) => a.trim()).filter(Boolean);
21
+ return Ie(s == null ? void 0 : s.one_allowed_collections);
21
22
  }
22
23
  function Te(s) {
23
24
  if (!s) return null;
24
25
  if (s.one_collection) return s.one_collection;
25
- const a = Fe(s);
26
- return a.length === 0 ? null : a.some((w) => w === "directus_users" || w === "nivaro_users") ? "nivaro_users" : a[0];
26
+ const o = Fe(s);
27
+ return o.length === 0 ? null : o.some((N) => N === "directus_users" || N === "nivaro_users") ? "nivaro_users" : o[0];
27
28
  }
28
- function Ze(s) {
29
+ function et(s) {
29
30
  if (!s || s.one_collection) return null;
30
- const a = Fe(s);
31
- if (a.length === 0) return null;
32
- const w = a.includes("directus_users") ? "directus_users" : a.includes("nivaro_users") ? "nivaro_users" : a[0];
33
- return { field: s.one_collection_field ?? "collection", value: w };
31
+ const o = Fe(s);
32
+ if (o.length === 0) return null;
33
+ const N = o.includes("directus_users") ? "directus_users" : o.includes("nivaro_users") ? "nivaro_users" : o[0];
34
+ return { field: s.one_collection_field ?? "collection", value: N };
34
35
  }
35
- function Me({
36
+ function tt({
36
37
  relation: s,
37
- parentId: a,
38
- allRelations: w,
38
+ parentId: o,
39
+ allRelations: N,
39
40
  extraFilter: h,
40
41
  optionSort: y,
41
42
  requiredParent: K,
42
43
  onCountChange: J,
43
44
  drilldown: D
44
45
  }) {
45
- const b = fe(), W = $e(), t = Le(), [P, q] = ne(!1), [L, T] = ne(""), le = w.find(
46
+ const b = fe(), W = $e(), t = Le(), [P, q] = ne(!1), [L, T] = ne(""), le = N.find(
46
47
  (e) => e.many_collection === s.many_collection && e.many_field === s.junction_field && e.id !== s.id
47
- ), r = Te(le), x = s.junction_field ?? "", z = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data: o } = N({
48
+ ), r = Te(le), x = s.junction_field ?? "", z = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data: a } = w({
48
49
  queryKey: ["col-meta", r],
49
50
  queryFn: () => b.request(C(`/collections/${r}`)).then((e) => e.data),
50
51
  enabled: !!r,
51
52
  staleTime: 3e5,
52
53
  retry: !1
53
- }), { data: X = [] } = N({
54
- queryKey: ["m2m-items", s.many_collection, z, a],
54
+ }), { data: X = [] } = w({
55
+ queryKey: ["m2m-items", s.many_collection, z, o],
55
56
  queryFn: () => b.request(
56
57
  C(`/items/${s.many_collection}`, {
57
- filter: JSON.stringify({ [z]: { _eq: a } }),
58
+ filter: JSON.stringify({ [z]: { _eq: o } }),
58
59
  limit: 200,
59
60
  fields: `id,${x}`
60
61
  })
61
62
  ).then((e) => e.data ?? []),
62
63
  staleTime: 3e4,
63
- enabled: !!a && a !== "new"
64
+ enabled: !!o && o !== "new"
64
65
  }), re = pe().isAdmin, E = r === "nivaro_users" ? ye(re) : null, R = he(r === "nivaro_users"), H = h ? E ? { _and: [h, E] } : h : E, j = H ? JSON.stringify(H) : void 0, g = y && !/^-?label$/.test(y) ? y : void 0, S = (() => {
65
- const e = o == null ? void 0 : o.display_template;
66
+ const e = a == null ? void 0 : a.display_template;
66
67
  if (!e || !e.includes(".")) return null;
67
68
  const i = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((u) => u[1].trim());
68
69
  return i.length === 0 ? null : ["id", ...i].join(",");
69
- })(), { data: O = [], isFetching: B } = N({
70
+ })(), { data: O = [], isFetching: V } = w({
70
71
  queryKey: [
71
72
  "m2m-options",
72
73
  r,
@@ -89,7 +90,7 @@ function Me({
89
90
  ).then((e) => e.data ?? []),
90
91
  enabled: P && !!r,
91
92
  staleTime: j ? 0 : 3e4
92
- }), V = (t == null ? void 0 : t.getStagedLinks(d)) ?? [], v = (t == null ? void 0 : t.getStagedUnlinks(d)) ?? /* @__PURE__ */ new Set(), U = X.filter((e) => !v.has(e.id)), p = new Set(U.map((e) => String(e[x]))), _ = [...p], Y = JSON.stringify(h ? { _and: [{ id: { _in: _ } }, h] } : { id: { _in: _ } }), { data: m } = N({
93
+ }), B = (t == null ? void 0 : t.getStagedLinks(d)) ?? [], v = (t == null ? void 0 : t.getStagedUnlinks(d)) ?? /* @__PURE__ */ new Set(), U = X.filter((e) => !v.has(e.id)), p = new Set(U.map((e) => String(e[x]))), _ = [...p], Y = JSON.stringify(h ? { _and: [{ id: { _in: _ } }, h] } : { id: { _in: _ } }), { data: m } = w({
93
94
  queryKey: ["m2m-avail", r, _.join(","), j],
94
95
  queryFn: () => b.request(
95
96
  C(`/items/${r}`, {
@@ -101,7 +102,7 @@ function Me({
101
102
  ).then((e) => e.data ?? []),
102
103
  enabled: !!r && _.length > 0,
103
104
  staleTime: 3e4
104
- }), Z = new Set((m ?? []).map((e) => String(e.id))), $ = m !== void 0 ? new Set(_.filter((e) => !Z.has(e))) : /* @__PURE__ */ new Set(), I = new Set(V.map(String)), A = /* @__PURE__ */ new Set([...p, ...I]), F = me(J);
105
+ }), Z = new Set((m ?? []).map((e) => String(e.id))), $ = m !== void 0 ? new Set(_.filter((e) => !Z.has(e))) : /* @__PURE__ */ new Set(), I = new Set(B.map(String)), A = /* @__PURE__ */ new Set([...p, ...I]), F = me(J);
105
106
  F.current = J, ue(() => {
106
107
  var e;
107
108
  (e = F.current) == null || e.call(F, A.size);
@@ -120,7 +121,7 @@ function Me({
120
121
  t == null || t.stageLink(d, e);
121
122
  }
122
123
  function k(e) {
123
- const i = (o == null ? void 0 : o.display_template) ?? null;
124
+ const i = (a == null ? void 0 : a.display_template) ?? null;
124
125
  return i ? qe(i, e) : String(e._display ?? e.id ?? "");
125
126
  }
126
127
  return K ? /* @__PURE__ */ c(
@@ -193,7 +194,7 @@ function Me({
193
194
  {
194
195
  collection: r,
195
196
  id: i,
196
- displayTemplate: o == null ? void 0 : o.display_template
197
+ displayTemplate: a == null ? void 0 : a.display_template
197
198
  }
198
199
  )
199
200
  }
@@ -202,7 +203,7 @@ function Me({
202
203
  {
203
204
  collection: r,
204
205
  id: i,
205
- displayTemplate: o == null ? void 0 : o.display_template
206
+ displayTemplate: a == null ? void 0 : a.display_template
206
207
  }
207
208
  )),
208
209
  /* @__PURE__ */ n(
@@ -219,7 +220,7 @@ function Me({
219
220
  String(e.id)
220
221
  );
221
222
  }),
222
- V.map((e) => /* @__PURE__ */ c(
223
+ B.map((e) => /* @__PURE__ */ c(
223
224
  "span",
224
225
  {
225
226
  className: "inline-flex items-center gap-1 rounded-full border border-dashed border-nvr-cyan/50 bg-nvr-cyan/5 pl-2.5 pr-1.5 py-0.5 text-[12px] text-slate-600 dark:text-slate-300",
@@ -229,7 +230,7 @@ function Me({
229
230
  {
230
231
  collection: r,
231
232
  id: e,
232
- displayTemplate: o == null ? void 0 : o.display_template
233
+ displayTemplate: a == null ? void 0 : a.display_template
233
234
  }
234
235
  ) : String(e),
235
236
  /* @__PURE__ */ n(
@@ -263,13 +264,13 @@ function Me({
263
264
  }
264
265
  ),
265
266
  /* @__PURE__ */ c(ve, { children: [
266
- B ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ n(ke, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
267
- /* @__PURE__ */ n(Ne, { children: !B && (g ? [...O] : [...O].sort(
267
+ V ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ n(ke, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
268
+ /* @__PURE__ */ n(we, { children: !V && (g ? [...O] : [...O].sort(
268
269
  (e, i) => y === "-label" ? k(i).localeCompare(k(e)) : k(e).localeCompare(k(i))
269
270
  )).map((e) => {
270
271
  const i = String(e.id), u = A.has(i);
271
272
  return /* @__PURE__ */ c(
272
- we,
273
+ Ne,
273
274
  {
274
275
  value: i,
275
276
  onSelect: () => G(e.id),
@@ -312,41 +313,41 @@ function Me({
312
313
  }
313
314
  ) });
314
315
  }
315
- function et({
316
+ function nt({
316
317
  relation: s,
317
- parentId: a,
318
- allRelations: w,
318
+ parentId: o,
319
+ allRelations: N,
319
320
  extraFilter: h,
320
321
  optionSort: y,
321
322
  requiredParent: K,
322
323
  onCountChange: J,
323
324
  readOnly: D
324
325
  }) {
325
- const b = fe(), W = Ie(), t = Le(), [P, q] = ne(!1), [L, T] = ne(""), le = w.find(
326
+ const b = fe(), W = Ae(), t = Le(), [P, q] = ne(!1), [L, T] = ne(""), le = N.find(
326
327
  (l) => l.many_collection === s.many_collection && l.many_field === s.junction_field && l.id !== s.id
327
- ), r = Te(le), x = s.junction_field ?? "", z = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data: o } = N({
328
+ ), r = Te(le), x = s.junction_field ?? "", z = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data: a } = w({
328
329
  queryKey: ["col-meta", r],
329
330
  queryFn: () => b.request(C(`/collections/${r}`)).then((l) => l.data),
330
331
  enabled: !!r,
331
332
  staleTime: 3e5,
332
333
  retry: !1
333
- }), { data: X = [], isFetching: re } = N({
334
- queryKey: ["m2m-items", s.many_collection, z, a],
334
+ }), { data: X = [], isFetching: re } = w({
335
+ queryKey: ["m2m-items", s.many_collection, z, o],
335
336
  queryFn: () => b.request(
336
337
  C(`/items/${s.many_collection}`, {
337
- filter: JSON.stringify({ [z]: { _eq: a } }),
338
+ filter: JSON.stringify({ [z]: { _eq: o } }),
338
339
  limit: 1,
339
340
  fields: `id,${x}`
340
341
  })
341
342
  ).then((l) => l.data ?? []),
342
343
  staleTime: 3e4,
343
- enabled: !!a && a !== "new"
344
+ enabled: !!o && o !== "new"
344
345
  }), E = pe().isAdmin, R = r === "nivaro_users" ? ye(E) : null, H = he(r === "nivaro_users"), j = h ? R ? { _and: [h, R] } : h : R, g = j ? JSON.stringify(j) : void 0, S = y && !/^-?label$/.test(y) ? y : void 0, O = (() => {
345
- const l = o == null ? void 0 : o.display_template;
346
+ const l = a == null ? void 0 : a.display_template;
346
347
  if (!l || !l.includes(".")) return null;
347
348
  const f = [...l.matchAll(/\{\{([^}]+)\}\}/g)].map((ee) => ee[1].trim());
348
349
  return f.length === 0 ? null : ["id", ...f].join(",");
349
- })(), { data: B = [], isFetching: V } = N({
350
+ })(), { data: V = [], isFetching: B } = w({
350
351
  queryKey: [
351
352
  "m2m-options",
352
353
  r,
@@ -374,12 +375,12 @@ function et({
374
375
  var l;
375
376
  (l = $.current) == null || l.call($, m != null ? 1 : 0);
376
377
  }, [m]);
377
- const { data: I } = N({
378
+ const { data: I } = w({
378
379
  queryKey: ["relation-single", r, String(m)],
379
380
  queryFn: () => W(r, m),
380
381
  enabled: !!r && m != null,
381
382
  staleTime: 6e4
382
- }), A = JSON.stringify(h ? { _and: [{ id: { _eq: m } }, h] } : { id: { _eq: m } }), { data: F } = N({
383
+ }), A = JSON.stringify(h ? { _and: [{ id: { _eq: m } }, h] } : { id: { _eq: m } }), { data: F } = w({
383
384
  queryKey: ["relation-avail", r, String(m), g],
384
385
  queryFn: () => b.request(
385
386
  C(`/items/${r}`, {
@@ -391,11 +392,11 @@ function et({
391
392
  ).then((l) => l.data ?? []),
392
393
  enabled: !!r && m != null && !!I,
393
394
  staleTime: 3e4
394
- }), G = F !== void 0 && F.length === 0, k = Ae(G), e = (o == null ? void 0 : o.display_template) ?? null;
395
+ }), G = F !== void 0 && F.length === 0, k = Ke(G), e = (a == null ? void 0 : a.display_template) ?? null;
395
396
  function i(l) {
396
397
  return e ? qe(e, l) : String(l.name ?? l.title ?? l.label ?? l.id ?? "");
397
398
  }
398
- const u = B.find((l) => String(l.id) === String(m)) ?? I, M = m != null && !I && !u, se = u ? i(u) : null;
399
+ const u = V.find((l) => String(l.id) === String(m)) ?? I, M = m != null && !I && !u, se = u ? i(u) : null;
399
400
  if (D)
400
401
  return /* @__PURE__ */ n("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: M ? "…" : se ?? "—" });
401
402
  function Oe(l) {
@@ -439,7 +440,7 @@ function et({
439
440
  G ? "border-amber-300 dark:border-amber-600" : Z ? "border-nvr-cyan/50" : "border-input"
440
441
  ),
441
442
  children: [
442
- M || re && Y == null && a !== "new" ? /* @__PURE__ */ n(ae, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ c(
443
+ M || re && Y == null && o !== "new" ? /* @__PURE__ */ n(ae, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ c(
443
444
  "span",
444
445
  {
445
446
  className: Q(
@@ -481,13 +482,13 @@ function et({
481
482
  }
482
483
  ),
483
484
  /* @__PURE__ */ c(ve, { children: [
484
- V ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ n(ke, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
485
- !V && /* @__PURE__ */ n(Ne, { children: [...B].sort(
485
+ B ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ n(ke, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
486
+ !B && /* @__PURE__ */ n(we, { children: [...V].sort(
486
487
  (l, f) => S ? 0 : y === "-label" ? i(f).localeCompare(i(l)) : i(l).localeCompare(i(f))
487
488
  ).map((l) => {
488
489
  const f = String(l.id), ee = String(m) === f;
489
490
  return /* @__PURE__ */ c(
490
- we,
491
+ Ne,
491
492
  {
492
493
  value: f,
493
494
  onSelect: () => Oe(l.id),
@@ -533,8 +534,8 @@ function et({
533
534
  ] });
534
535
  }
535
536
  export {
536
- Me as M2MCombobox,
537
- et as M2MSingleSelectCombobox,
538
- Ze as m2aWriteMeta,
537
+ tt as M2MCombobox,
538
+ nt as M2MSingleSelectCombobox,
539
+ et as m2aWriteMeta,
539
540
  Te as resolveM2MRelatedCollection
540
541
  };
@@ -1,75 +1,87 @@
1
- import { jsxs as h, jsx as f } from "react/jsx-runtime";
2
- import { QueryClientContext as m, QueryClient as y, QueryClientProvider as b, useQueryClient as v } from "@tanstack/react-query";
3
- import { createContext as i, useContext as l, useState as C, useMemo as w, useCallback as p, useEffect as x } from "react";
4
- import { restoreMetadata as g, startMetadataPersistence as I } from "./lib/metadata-persist.js";
5
- import { isCoalesced as N, withGetCoalescing as P } from "./lib/request-gate.js";
6
- const O = i(null);
7
- function B() {
8
- return l(O);
9
- }
10
- const d = i(null);
11
- function S({ identity: e }) {
12
- const t = v(), { userId: n, epoch: o, version: r } = e;
13
- return x(() => {
1
+ import { jsxs as b, jsx as f } from "react/jsx-runtime";
2
+ import { QueryClientContext as v, QueryClient as w, QueryClientProvider as g, useQueryClient as C } from "@tanstack/react-query";
3
+ import { createContext as i, useContext as l, useState as m, useMemo as x, useCallback as h, useEffect as y } from "react";
4
+ import { restoreMetadata as I, startMetadataPersistence as N } from "./lib/metadata-persist.js";
5
+ import { isCoalesced as O, withGetCoalescing as P, releaseGatedReadsOnSharedFetch as S } from "./lib/request-gate.js";
6
+ const F = i(null);
7
+ function z() {
8
+ return l(F);
9
+ }
10
+ const p = i(null);
11
+ function $({ identity: e }) {
12
+ const t = C(), { userId: n, epoch: o, version: r } = e;
13
+ return y(() => {
14
14
  let u = () => {
15
15
  }, c = !1;
16
- return g(t, { userId: n, epoch: o, version: r }).then(() => {
17
- c || (u = I(t, { userId: n, epoch: o, version: r }));
16
+ return I(t, { userId: n, epoch: o, version: r }).then(() => {
17
+ c || (u = N(t, { userId: n, epoch: o, version: r }));
18
18
  }), () => {
19
19
  c = !0, u();
20
20
  };
21
21
  }, [t, n, o, r]), null;
22
22
  }
23
- function V({
23
+ const d = /* @__PURE__ */ new WeakMap();
24
+ function j() {
25
+ const e = C();
26
+ return y(() => {
27
+ const t = e.getQueryCache(), n = d.get(t);
28
+ return n ? n.count++ : d.set(t, { count: 1, stop: S(t) }), () => {
29
+ const o = d.get(t);
30
+ o && (o.count--, o.count <= 0 && (o.stop(), d.delete(t)));
31
+ };
32
+ }, [e]), null;
33
+ }
34
+ function L({
24
35
  client: e,
25
36
  children: t,
26
37
  batchReads: n = !1,
27
38
  persistMetadata: o = null
28
39
  }) {
29
- const r = l(m), [u] = C(
30
- () => new y({
40
+ const r = l(v), [u] = m(
41
+ () => new w({
31
42
  defaultOptions: { queries: { retry: 1, refetchOnWindowFocus: !1 } }
32
43
  })
33
- ), c = w(
34
- () => N(e) ? e : P(e, { batchReads: n }),
44
+ ), c = x(
45
+ () => O(e) ? e : P(e, { batchReads: n }),
35
46
  [e, n]
36
- ), s = /* @__PURE__ */ h(d.Provider, { value: { client: c }, children: [
37
- o ? /* @__PURE__ */ f(S, { identity: o }) : null,
47
+ ), s = /* @__PURE__ */ b(p.Provider, { value: { client: c }, children: [
48
+ o ? /* @__PURE__ */ f($, { identity: o }) : null,
49
+ typeof e.setOpen == "function" ? /* @__PURE__ */ f(j, {}) : null,
38
50
  t
39
51
  ] });
40
- return r ? s : /* @__PURE__ */ f(b, { client: u, children: s });
52
+ return r ? s : /* @__PURE__ */ f(g, { client: u, children: s });
41
53
  }
42
- function z() {
43
- const e = l(d);
54
+ function K() {
55
+ const e = l(p);
44
56
  if (!e) throw new Error("useNivaroClient must be used within <NivaroProvider>");
45
57
  return e.client;
46
58
  }
47
- function $() {
48
- const e = l(d);
59
+ function D() {
60
+ const e = l(p);
49
61
  return (e == null ? void 0 : e.client) ?? null;
50
62
  }
51
- function L() {
52
- const e = $(), t = e == null ? void 0 : e.getToken();
63
+ function X() {
64
+ const e = D(), t = e == null ? void 0 : e.getToken();
53
65
  return {
54
66
  apiBase: e ? `${e.url}/api` : "/api",
55
67
  authHeaders: t ? { Authorization: `Bearer ${t}` } : {},
56
68
  credentials: t ? "omit" : "include"
57
69
  };
58
70
  }
59
- const j = i({
71
+ const R = i({
60
72
  isAdmin: !1,
61
73
  userId: ""
62
74
  });
63
- function W() {
64
- return l(j);
75
+ function Y() {
76
+ return l(R);
65
77
  }
66
- function D(e) {
78
+ function A(e) {
67
79
  const t = JSON.stringify(e), n = new TextEncoder().encode(t);
68
80
  let o = "";
69
81
  for (const r of n) o += String.fromCharCode(r);
70
82
  return encodeURIComponent(btoa(o));
71
83
  }
72
- function K(e) {
84
+ function Z(e) {
73
85
  if (!e) return null;
74
86
  try {
75
87
  const t = atob(e.replace(/ /g, "+")), n = Uint8Array.from(t, (r) => r.charCodeAt(0)), o = JSON.parse(new TextDecoder().decode(n));
@@ -83,52 +95,52 @@ function K(e) {
83
95
  }
84
96
  }
85
97
  }
86
- const F = i({
98
+ const Q = i({
87
99
  navigate: (e) => {
88
100
  window.location.href = e;
89
101
  }
90
102
  });
91
- function R() {
92
- return l(F);
103
+ function U() {
104
+ return l(Q);
93
105
  }
94
- function A(e) {
106
+ function k(e) {
95
107
  const t = `/collections/${e.collection}/${e.itemId}`, n = [];
96
- e.layoutSlug && n.push(`layout=${encodeURIComponent(e.layoutSlug)}`), e.prefill && Object.keys(e.prefill).length && n.push(`prefill=${D(e.prefill)}`);
108
+ e.layoutSlug && n.push(`layout=${encodeURIComponent(e.layoutSlug)}`), e.prefill && Object.keys(e.prefill).length && n.push(`prefill=${A(e.prefill)}`);
97
109
  for (const [o, r] of Object.entries(e.query ?? {}))
98
110
  n.push(`${encodeURIComponent(o)}=${encodeURIComponent(r)}`);
99
111
  return n.length ? `${t}?${n.join("&")}` : t;
100
112
  }
101
- function X() {
102
- const e = R(), t = (o) => (e.itemUrl ?? A)(o);
113
+ function ee() {
114
+ const e = U(), t = (o) => (e.itemUrl ?? k)(o);
103
115
  return { urlFor: t, open: (o) => {
104
116
  var r;
105
117
  ((r = e.openItem) == null ? void 0 : r.call(e, o)) !== !0 && e.navigate(t(o));
106
118
  } };
107
119
  }
108
- const U = i(null);
109
- function Y() {
110
- return l(U);
111
- }
112
120
  const E = i(null);
113
- function Z() {
121
+ function te() {
114
122
  return l(E);
115
123
  }
116
- const Q = i({});
117
- function ee() {
118
- return l(Q);
124
+ const G = i(null);
125
+ function ne() {
126
+ return l(G);
119
127
  }
120
- const k = i(null);
121
- function te() {
122
- return l(k);
128
+ const M = i({});
129
+ function oe() {
130
+ return l(M);
131
+ }
132
+ const q = i(null);
133
+ function re() {
134
+ return l(q);
123
135
  }
124
136
  const H = i(null);
125
- function ne(e) {
126
- const t = l(H), [n, o] = C([]), r = t ? t.get(e) ?? null : n[n.length - 1] ?? null, u = p(
137
+ function le(e) {
138
+ const t = l(H), [n, o] = m([]), r = t ? t.get(e) ?? null : n[n.length - 1] ?? null, u = h(
127
139
  (s) => {
128
140
  t ? t.push(e, s) : o((a) => [...a, s]);
129
141
  },
130
142
  [t, e]
131
- ), c = p(
143
+ ), c = h(
132
144
  (s = 1) => {
133
145
  t ? t.back(s) : o((a) => a.slice(0, Math.max(0, a.length - s)));
134
146
  },
@@ -136,39 +148,39 @@ function ne(e) {
136
148
  );
137
149
  return { value: r, push: u, back: c };
138
150
  }
139
- function oe(e) {
151
+ function ie(e) {
140
152
  var u;
141
153
  const t = (u = e._overrides) == null ? void 0 : u.drilldown, n = t && typeof t == "object" ? t : null, o = e.interface === "relation-path";
142
154
  return (n == null ? void 0 : n.enabled) ?? o ? { enabled: !0, layout_id: (n == null ? void 0 : n.layout_id) ?? null, width: (n == null ? void 0 : n.width) ?? null } : null;
143
155
  }
144
- const re = i(null), M = i(null), le = () => l(M);
156
+ const ue = i(null), W = i(null), se = () => l(W);
145
157
  export {
146
- k as DrilldownContext,
147
- Q as DrilldownViewsContext,
148
- O as GridFlushContext,
149
- j as ItemEditAuthContext,
150
- F as NavigationContext,
151
- V as NivaroProvider,
158
+ q as DrilldownContext,
159
+ M as DrilldownViewsContext,
160
+ F as GridFlushContext,
161
+ R as ItemEditAuthContext,
162
+ Q as NavigationContext,
163
+ L as NivaroProvider,
152
164
  H as OverlayHistoryContext,
153
- U as ParentDraftContext,
154
- E as ReimportHandlerContext,
155
- re as RelationPathDataContext,
156
- M as StaleFieldReportContext,
157
- K as decodePrefill,
158
- A as defaultItemUrl,
159
- D as encodePrefill,
160
- oe as fieldDrilldownConfig,
161
- L as useApiFetchConfig,
162
- te as useDrilldown,
163
- ee as useDrilldownViews,
164
- B as useGridFlush,
165
- W as useItemEditAuth,
166
- X as useItemNavigation,
167
- R as useNavigation,
168
- z as useNivaroClient,
169
- $ as useOptionalNivaroClient,
170
- ne as useOverlayState,
171
- Y as useParentDraft,
172
- Z as useReimportHandler,
173
- le as useStaleFieldReporter
165
+ E as ParentDraftContext,
166
+ G as ReimportHandlerContext,
167
+ ue as RelationPathDataContext,
168
+ W as StaleFieldReportContext,
169
+ Z as decodePrefill,
170
+ k as defaultItemUrl,
171
+ A as encodePrefill,
172
+ ie as fieldDrilldownConfig,
173
+ X as useApiFetchConfig,
174
+ re as useDrilldown,
175
+ oe as useDrilldownViews,
176
+ z as useGridFlush,
177
+ Y as useItemEditAuth,
178
+ ee as useItemNavigation,
179
+ U as useNavigation,
180
+ K as useNivaroClient,
181
+ D as useOptionalNivaroClient,
182
+ le as useOverlayState,
183
+ te as useParentDraft,
184
+ ne as useReimportHandler,
185
+ se as useStaleFieldReporter
174
186
  };
@@ -0,0 +1,15 @@
1
+ function n(t) {
2
+ if (t == null || t === "") return [];
3
+ if (Array.isArray(t)) return t.map((r) => String(r).trim()).filter(Boolean);
4
+ const i = String(t).trim();
5
+ if (i.startsWith("["))
6
+ try {
7
+ const r = JSON.parse(i);
8
+ if (Array.isArray(r)) return r.map((e) => String(e).trim()).filter(Boolean);
9
+ } catch {
10
+ }
11
+ return i.split(",").map((r) => r.trim()).filter(Boolean);
12
+ }
13
+ export {
14
+ n as parseAllowedCollections
15
+ };