@nivaro/react 0.3.25 → 0.3.27

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.
@@ -9,7 +9,7 @@ import { noteReplayEvent as _e, createReplayCheckoutState as De } from "../share
9
9
  import { emitReplayTap as Te, setReplayRecorderMode as N, registerReplayCapture as qe, clipEndOffset as Le, withClipKind as Pe } from "../shared/lib/replay-capture.js";
10
10
  import { instrumentConsole as Ne, instrumentRequests as Fe, redactSecrets as Me } from "../shared/lib/replay-context.js";
11
11
  import { instrumentSocket as Oe } from "../shared/lib/replay-socket.js";
12
- const Ue = "nivaro-react@0.3.25", j = 1e4, We = 150, He = 3e3, Ke = 600, $e = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
12
+ const Ue = "nivaro-react@0.3.27", j = 1e4, We = 150, He = 3e3, Ke = 600, $e = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
13
13
  function Be(n) {
14
14
  return typeof n.url != "string" || typeof fetch != "function" ? null : (f, a) => {
15
15
  const u = typeof n.getToken == "function" ? n.getToken() : void 0, d = { "Content-Type": "application/json" };
@@ -2,38 +2,39 @@ import { jsx as n, jsxs as c } from "react/jsx-runtime";
2
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
- import { useNivaroClient as fe, useItemEditAuth as pe, useDrilldown as $e } from "../../context.js";
6
- import { parseAllowedCollections as Ie } from "../../lib/allowed-collections.js";
7
- import { get as C } from "../../lib/commands.js";
8
- import { useRecordReader as Ae } from "../../lib/record-loader.js";
9
- import { useOnlineUsers as he } from "../../lib/use-online-users.js";
10
- import { cn as Q, userOptionFilter as be } from "../../lib/utils.js";
11
- import { UserAvatar as ye } from "../UserAvatar.js";
12
- import { Command as xe, CommandInput as ve, CommandList as ge, CommandEmpty as ke, CommandGroup as we, CommandItem as Ne } from "../ui/command.js";
13
- import { Popover as Se, PopoverTrigger as _e, PopoverContent as Ce } from "../ui/popover.js";
14
- import { applyDisplayTemplate as qe } from "./helpers.js";
15
- import { useM2MStaging as Le } from "./M2MStagingContext.js";
16
- import { useStaleTip as Ke, RelatedItemLabel as ie } from "./RelationCombobox.js";
17
- function je(s) {
18
- return s.replace(/\(.*$/, "").trim().split(/\s+/).map((o) => o[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
19
- }
5
+ import { useNivaroClient as fe, useItemEditAuth as pe, useDrilldown as Ie } from "../../context.js";
6
+ import { parseAllowedCollections as Ae } from "../../lib/allowed-collections.js";
7
+ import { get as q } from "../../lib/commands.js";
8
+ import { compareByMatch as he } from "../../lib/picker-rank.js";
9
+ import { useRecordReader as Ke } from "../../lib/record-loader.js";
10
+ import { useOnlineUsers as be } from "../../lib/use-online-users.js";
11
+ import { cn as Q, userOptionFilter as ye } from "../../lib/utils.js";
12
+ import { UserAvatar as xe } from "../UserAvatar.js";
13
+ import { Command as ve, CommandInput as ge, CommandList as ke, CommandEmpty as we, CommandGroup as Ne, CommandItem as Se } from "../ui/command.js";
14
+ import { Popover as _e, PopoverTrigger as qe, PopoverContent as Ce } from "../ui/popover.js";
15
+ import { applyDisplayTemplate as Le } from "./helpers.js";
16
+ import { useM2MStaging as je } from "./M2MStagingContext.js";
17
+ import { useStaleTip as Je, RelatedItemLabel as ie } from "./RelationCombobox.js";
20
18
  function Fe(s) {
21
- return Ie(s == null ? void 0 : s.one_allowed_collections);
19
+ return s.replace(/\(.*$/, "").trim().split(/\s+/).map((o) => o[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
22
20
  }
23
21
  function Te(s) {
22
+ return Ae(s == null ? void 0 : s.one_allowed_collections);
23
+ }
24
+ function Oe(s) {
24
25
  if (!s) return null;
25
26
  if (s.one_collection) return s.one_collection;
26
- const o = Fe(s);
27
+ const o = Te(s);
27
28
  return o.length === 0 ? null : o.some((N) => N === "directus_users" || N === "nivaro_users") ? "nivaro_users" : o[0];
28
29
  }
29
- function et(s) {
30
+ function nt(s) {
30
31
  if (!s || s.one_collection) return null;
31
- const o = Fe(s);
32
+ const o = Te(s);
32
33
  if (o.length === 0) return null;
33
34
  const N = o.includes("directus_users") ? "directus_users" : o.includes("nivaro_users") ? "nivaro_users" : o[0];
34
35
  return { field: s.one_collection_field ?? "collection", value: N };
35
36
  }
36
- function tt({
37
+ function lt({
37
38
  relation: s,
38
39
  parentId: o,
39
40
  allRelations: N,
@@ -43,57 +44,57 @@ function tt({
43
44
  onCountChange: J,
44
45
  drilldown: D
45
46
  }) {
46
- const y = fe(), W = $e(), t = Le(), [P, q] = ne(!1), [L, T] = ne(""), le = N.find(
47
+ const y = fe(), W = Ie(), t = je(), [P, C] = ne(!1), [x, T] = ne(""), le = N.find(
47
48
  (e) => e.many_collection === s.many_collection && e.many_field === s.junction_field && e.id !== s.id
48
- ), r = Te(le), x = s.junction_field ?? "", R = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data: a } = w({
49
+ ), r = Oe(le), v = s.junction_field ?? "", R = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${v}`, { data: a } = w({
49
50
  queryKey: ["col-meta", r],
50
- queryFn: () => y.request(C(`/collections/${r}`)).then((e) => e.data),
51
+ queryFn: () => y.request(q(`/collections/${r}`)).then((e) => e.data),
51
52
  enabled: !!r,
52
53
  staleTime: 3e5,
53
54
  retry: !1
54
55
  }), { data: X = [] } = w({
55
56
  queryKey: ["m2m-items", s.many_collection, R, o],
56
57
  queryFn: () => y.request(
57
- C(`/items/${s.many_collection}`, {
58
+ q(`/items/${s.many_collection}`, {
58
59
  filter: JSON.stringify({ [R]: { _eq: o } }),
59
60
  limit: 200,
60
- fields: `id,${x}`
61
+ fields: `id,${v}`
61
62
  })
62
63
  ).then((e) => e.data ?? []),
63
64
  staleTime: 3e4,
64
65
  enabled: !!o && o !== "new"
65
- }), re = pe().isAdmin, z = r === "nivaro_users" ? be(re) : null, E = he(r === "nivaro_users"), H = h ? z ? { _and: [h, z] } : h : z, j = H ? JSON.stringify(H) : void 0, v = b && !/^-?label$/.test(b) ? b : void 0, S = (() => {
66
+ }), re = pe().isAdmin, z = r === "nivaro_users" ? ye(re) : null, E = be(r === "nivaro_users"), H = h ? z ? { _and: [h, z] } : h : z, L = H ? JSON.stringify(H) : void 0, g = b && !/^-?label$/.test(b) ? b : void 0, S = (() => {
66
67
  const e = a == null ? void 0 : a.display_template;
67
68
  if (!e || !e.includes(".")) return null;
68
69
  const i = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((u) => u[1].trim());
69
70
  return i.length === 0 ? null : ["id", ...i].join(",");
70
- })(), { data: O = [], isFetching: V } = w({
71
+ })(), { data: O = [], isFetching: B } = w({
71
72
  queryKey: [
72
73
  "m2m-options",
73
74
  r,
75
+ x,
74
76
  L,
75
- j,
76
- v ?? "",
77
+ g ?? "",
77
78
  S ?? ""
78
79
  ],
79
80
  queryFn: () => y.request(
80
- C(`/items/${r}`, {
81
+ q(`/items/${r}`, {
81
82
  limit: 200,
82
- search: L || void 0,
83
- filter: j,
83
+ search: x || void 0,
84
+ filter: L,
84
85
  picker: "1",
85
86
  // A dotted display template ({{core_category.name}}) needs the
86
87
  // nested expansion — a bare row only carries the FK id.
87
88
  ...S ? { fields: S } : {},
88
- ...v ? { sort: v } : {}
89
+ ...g ? { sort: g } : {}
89
90
  })
90
91
  ).then((e) => e.data ?? []),
91
92
  enabled: P && !!r,
92
- staleTime: j ? 0 : 3e4
93
- }), B = (t == null ? void 0 : t.getStagedLinks(d)) ?? [], g = (t == null ? void 0 : t.getStagedUnlinks(d)) ?? /* @__PURE__ */ new Set(), U = X.filter((e) => !g.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({
94
- queryKey: ["m2m-avail", r, _.join(","), j],
93
+ staleTime: L ? 0 : 3e4
94
+ }), V = (t == null ? void 0 : t.getStagedLinks(d)) ?? [], k = (t == null ? void 0 : t.getStagedUnlinks(d)) ?? /* @__PURE__ */ new Set(), U = X.filter((e) => !k.has(e.id)), f = new Set(U.map((e) => String(e[v]))), _ = [...f], Y = JSON.stringify(h ? { _and: [{ id: { _in: _ } }, h] } : { id: { _in: _ } }), { data: m } = w({
95
+ queryKey: ["m2m-avail", r, _.join(","), L],
95
96
  queryFn: () => y.request(
96
- C(`/items/${r}`, {
97
+ q(`/items/${r}`, {
97
98
  filter: Y,
98
99
  picker: "1",
99
100
  limit: 200,
@@ -102,10 +103,10 @@ function tt({
102
103
  ).then((e) => e.data ?? []),
103
104
  enabled: !!r && _.length > 0,
104
105
  staleTime: 3e4
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);
106
- F.current = J, ue(() => {
106
+ }), 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([...f, ...I]), j = me(J);
107
+ j.current = J, ue(() => {
107
108
  var e;
108
- (e = F.current) == null || e.call(F, A.size);
109
+ (e = j.current) == null || e.call(j, A.size);
109
110
  }, [A.size]);
110
111
  function G(e) {
111
112
  const i = String(e);
@@ -113,16 +114,16 @@ function tt({
113
114
  t == null || t.unstageLink(d, e);
114
115
  return;
115
116
  }
116
- const u = X.find((M) => String(M[x]) === i);
117
+ const u = X.find((M) => String(M[v]) === i);
117
118
  if (u) {
118
- g.has(u.id) ? t == null || t.unstageUnlink(d, u.id) : t == null || t.stageUnlink(d, u.id);
119
+ k.has(u.id) ? t == null || t.unstageUnlink(d, u.id) : t == null || t.stageUnlink(d, u.id);
119
120
  return;
120
121
  }
121
122
  t == null || t.stageLink(d, e);
122
123
  }
123
- function k(e) {
124
+ function F(e) {
124
125
  const i = (a == null ? void 0 : a.display_template) ?? null;
125
- return i ? qe(i, e) : String(e._display ?? e.id ?? "");
126
+ return i ? Le(i, e) : String(e._display ?? e.id ?? "");
126
127
  }
127
128
  return K ? /* @__PURE__ */ c(
128
129
  "button",
@@ -140,20 +141,20 @@ function tt({
140
141
  ]
141
142
  }
142
143
  ) : /* @__PURE__ */ n("div", { children: /* @__PURE__ */ c(
143
- Se,
144
+ _e,
144
145
  {
145
146
  open: P,
146
147
  onOpenChange: (e) => {
147
- q(e), e || T("");
148
+ C(e), e || T("");
148
149
  },
149
150
  children: [
150
- /* @__PURE__ */ n(_e, { asChild: !0, children: /* @__PURE__ */ c(
151
+ /* @__PURE__ */ n(qe, { asChild: !0, children: /* @__PURE__ */ c(
151
152
  "div",
152
153
  {
153
154
  role: "button",
154
155
  tabIndex: 0,
155
156
  onKeyDown: (e) => {
156
- (e.key === "Enter" || e.key === " ") && (e.preventDefault(), q((i) => !i));
157
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), C((i) => !i));
157
158
  },
158
159
  className: "flex min-h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-background px-3 py-1 text-sm text-left font-normal hover:bg-muted",
159
160
  children: [
@@ -166,7 +167,7 @@ function tt({
166
167
  },
167
168
  children: [
168
169
  U.map((e) => {
169
- const i = e[x], u = $.has(String(i));
170
+ const i = e[v], u = $.has(String(i));
170
171
  return /* @__PURE__ */ c(
171
172
  "span",
172
173
  {
@@ -221,7 +222,7 @@ function tt({
221
222
  String(e.id)
222
223
  );
223
224
  }),
224
- B.map((e) => /* @__PURE__ */ c(
225
+ V.map((e) => /* @__PURE__ */ c(
225
226
  "span",
226
227
  {
227
228
  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",
@@ -255,24 +256,24 @@ function tt({
255
256
  ]
256
257
  }
257
258
  ) }),
258
- /* @__PURE__ */ n(Ce, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(xe, { shouldFilter: !1, children: [
259
+ /* @__PURE__ */ n(Ce, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(ve, { shouldFilter: !1, children: [
259
260
  /* @__PURE__ */ n(
260
- ve,
261
+ ge,
261
262
  {
262
263
  placeholder: "Search…",
263
- value: L,
264
+ value: x,
264
265
  onValueChange: T,
265
266
  className: "h-9 text-[13px]"
266
267
  }
267
268
  ),
268
- /* @__PURE__ */ c(ge, { children: [
269
- 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" }),
270
- /* @__PURE__ */ n(we, { children: !V && (v ? [...O] : [...O].sort(
271
- (e, i) => b === "-label" ? k(i).localeCompare(k(e)) : k(e).localeCompare(k(i))
269
+ /* @__PURE__ */ c(ke, { children: [
270
+ 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(we, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
271
+ /* @__PURE__ */ n(Ne, { children: !B && (g ? [...O] : [...O].sort(
272
+ (e, i) => he(F(e), F(i), x, b === "-label")
272
273
  )).map((e) => {
273
274
  const i = String(e.id), u = A.has(i);
274
275
  return /* @__PURE__ */ c(
275
- Ne,
276
+ Se,
276
277
  {
277
278
  value: i,
278
279
  onSelect: () => G(e.id),
@@ -289,11 +290,11 @@ function tt({
289
290
  }
290
291
  ),
291
292
  r === "nivaro_users" && /* @__PURE__ */ n(
292
- ye,
293
+ xe,
293
294
  {
294
295
  userId: i,
295
296
  className: "h-4 w-4",
296
- fallback: /* @__PURE__ */ n("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: je(k(e)) })
297
+ fallback: /* @__PURE__ */ n("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: Fe(F(e)) })
297
298
  }
298
299
  ),
299
300
  r === "nivaro_users" && E.has(i.toUpperCase()) && /* @__PURE__ */ n(
@@ -303,7 +304,7 @@ function tt({
303
304
  "data-tip": "Online now"
304
305
  }
305
306
  ),
306
- /* @__PURE__ */ n("span", { className: "truncate", children: k(e) })
307
+ /* @__PURE__ */ n("span", { className: "truncate", children: F(e) })
307
308
  ]
308
309
  },
309
310
  i
@@ -315,7 +316,7 @@ function tt({
315
316
  }
316
317
  ) });
317
318
  }
318
- function nt({
319
+ function rt({
319
320
  relation: s,
320
321
  parentId: o,
321
322
  allRelations: N,
@@ -325,44 +326,44 @@ function nt({
325
326
  onCountChange: J,
326
327
  readOnly: D
327
328
  }) {
328
- const y = fe(), W = Ae(), t = Le(), [P, q] = ne(!1), [L, T] = ne(""), le = N.find(
329
+ const y = fe(), W = Ke(), t = je(), [P, C] = ne(!1), [x, T] = ne(""), le = N.find(
329
330
  (l) => l.many_collection === s.many_collection && l.many_field === s.junction_field && l.id !== s.id
330
- ), r = Te(le), x = s.junction_field ?? "", R = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data: a } = w({
331
+ ), r = Oe(le), v = s.junction_field ?? "", R = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${v}`, { data: a } = w({
331
332
  queryKey: ["col-meta", r],
332
- queryFn: () => y.request(C(`/collections/${r}`)).then((l) => l.data),
333
+ queryFn: () => y.request(q(`/collections/${r}`)).then((l) => l.data),
333
334
  enabled: !!r,
334
335
  staleTime: 3e5,
335
336
  retry: !1
336
337
  }), { data: X = [], isFetching: re } = w({
337
338
  queryKey: ["m2m-items", s.many_collection, R, o],
338
339
  queryFn: () => y.request(
339
- C(`/items/${s.many_collection}`, {
340
+ q(`/items/${s.many_collection}`, {
340
341
  filter: JSON.stringify({ [R]: { _eq: o } }),
341
342
  limit: 1,
342
- fields: `id,${x}`
343
+ fields: `id,${v}`
343
344
  })
344
345
  ).then((l) => l.data ?? []),
345
346
  staleTime: 3e4,
346
347
  enabled: !!o && o !== "new"
347
- }), z = pe().isAdmin, E = r === "nivaro_users" ? be(z) : null, H = he(r === "nivaro_users"), j = h ? E ? { _and: [h, E] } : h : E, v = j ? JSON.stringify(j) : void 0, S = b && !/^-?label$/.test(b) ? b : void 0, O = (() => {
348
+ }), z = pe().isAdmin, E = r === "nivaro_users" ? ye(z) : null, H = be(r === "nivaro_users"), L = h ? E ? { _and: [h, E] } : h : E, g = L ? JSON.stringify(L) : void 0, S = b && !/^-?label$/.test(b) ? b : void 0, O = (() => {
348
349
  const l = a == null ? void 0 : a.display_template;
349
350
  if (!l || !l.includes(".")) return null;
350
- const f = [...l.matchAll(/\{\{([^}]+)\}\}/g)].map((ee) => ee[1].trim());
351
- return f.length === 0 ? null : ["id", ...f].join(",");
352
- })(), { data: V = [], isFetching: B } = w({
351
+ const p = [...l.matchAll(/\{\{([^}]+)\}\}/g)].map((ee) => ee[1].trim());
352
+ return p.length === 0 ? null : ["id", ...p].join(",");
353
+ })(), { data: B = [], isFetching: V } = w({
353
354
  queryKey: [
354
355
  "m2m-options",
355
356
  r,
356
- L,
357
- v,
357
+ x,
358
+ g,
358
359
  S ?? "",
359
360
  O ?? ""
360
361
  ],
361
362
  queryFn: () => y.request(
362
- C(`/items/${r}`, {
363
+ q(`/items/${r}`, {
363
364
  limit: 200,
364
- search: L || void 0,
365
- filter: v,
365
+ search: x || void 0,
366
+ filter: g,
366
367
  picker: "1",
367
368
  // A dotted display template ({{core_category.name}}) needs the
368
369
  // nested expansion — a bare row only carries the FK id.
@@ -371,8 +372,8 @@ function nt({
371
372
  })
372
373
  ).then((l) => l.data ?? []),
373
374
  enabled: P && !!r,
374
- staleTime: v ? 0 : 3e4
375
- }), g = (t == null ? void 0 : t.getStagedLinks(d)) ?? [], U = (t == null ? void 0 : t.getStagedUnlinks(d)) ?? /* @__PURE__ */ new Set(), p = X.find((l) => !U.has(l.id)) ?? null, _ = p ? p[x] : null, Y = g.length > 0 ? g[g.length - 1] : null, m = Y ?? _, Z = g.length > 0 || U.size > 0, $ = me(J);
375
+ staleTime: g ? 0 : 3e4
376
+ }), k = (t == null ? void 0 : t.getStagedLinks(d)) ?? [], U = (t == null ? void 0 : t.getStagedUnlinks(d)) ?? /* @__PURE__ */ new Set(), f = X.find((l) => !U.has(l.id)) ?? null, _ = f ? f[v] : null, Y = k.length > 0 ? k[k.length - 1] : null, m = Y ?? _, Z = k.length > 0 || U.size > 0, $ = me(J);
376
377
  $.current = J, ue(() => {
377
378
  var l;
378
379
  (l = $.current) == null || l.call($, m != null ? 1 : 0);
@@ -382,10 +383,10 @@ function nt({
382
383
  queryFn: () => W(r, m),
383
384
  enabled: !!r && m != null,
384
385
  staleTime: 6e4
385
- }), A = JSON.stringify(h ? { _and: [{ id: { _eq: m } }, h] } : { id: { _eq: m } }), { data: F } = w({
386
- queryKey: ["relation-avail", r, String(m), v],
386
+ }), A = JSON.stringify(h ? { _and: [{ id: { _eq: m } }, h] } : { id: { _eq: m } }), { data: j } = w({
387
+ queryKey: ["relation-avail", r, String(m), g],
387
388
  queryFn: () => y.request(
388
- C(`/items/${r}`, {
389
+ q(`/items/${r}`, {
389
390
  filter: A,
390
391
  picker: "1",
391
392
  limit: 1,
@@ -394,20 +395,20 @@ function nt({
394
395
  ).then((l) => l.data ?? []),
395
396
  enabled: !!r && m != null && !!I,
396
397
  staleTime: 3e4
397
- }), G = F !== void 0 && F.length === 0, k = Ke(G), e = (a == null ? void 0 : a.display_template) ?? null;
398
+ }), G = j !== void 0 && j.length === 0, F = Je(G), e = (a == null ? void 0 : a.display_template) ?? null;
398
399
  function i(l) {
399
- return e ? qe(e, l) : String(l.name ?? l.title ?? l.label ?? l.id ?? "");
400
+ return e ? Le(e, l) : String(l.name ?? l.title ?? l.label ?? l.id ?? "");
400
401
  }
401
- const u = V.find((l) => String(l.id) === String(m)) ?? I, M = m != null && !I && !u, se = u ? i(u) : null;
402
+ const u = B.find((l) => String(l.id) === String(m)) ?? I, M = m != null && !I && !u, se = u ? i(u) : null;
402
403
  if (D)
403
404
  return /* @__PURE__ */ n("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: M ? "…" : se ?? "—" });
404
- function Oe(l) {
405
- for (const f of g) t == null || t.unstageLink(d, f);
406
- p && !U.has(p.id) && (t == null || t.stageUnlink(d, p.id)), String(l) === String(_) && p ? t == null || t.unstageUnlink(d, p.id) : String(l) !== String(m) && (t == null || t.stageLink(d, l)), q(!1), T("");
405
+ function Ue(l) {
406
+ for (const p of k) t == null || t.unstageLink(d, p);
407
+ f && !U.has(f.id) && (t == null || t.stageUnlink(d, f.id)), String(l) === String(_) && f ? t == null || t.unstageUnlink(d, f.id) : String(l) !== String(m) && (t == null || t.stageLink(d, l)), C(!1), T("");
407
408
  }
408
- function Ue() {
409
- for (const l of g) t == null || t.unstageLink(d, l);
410
- p && (t == null || t.stageUnlink(d, p.id)), q(!1);
409
+ function $e() {
410
+ for (const l of k) t == null || t.unstageLink(d, l);
411
+ f && (t == null || t.stageUnlink(d, f.id)), C(!1);
411
412
  }
412
413
  return K ? /* @__PURE__ */ c(
413
414
  "button",
@@ -424,16 +425,16 @@ function nt({
424
425
  /* @__PURE__ */ n(te, { className: "h-4 w-4 shrink-0 opacity-50" })
425
426
  ]
426
427
  }
427
- ) : /* @__PURE__ */ c("div", { ...k.bind, children: [
428
+ ) : /* @__PURE__ */ c("div", { ...F.bind, children: [
428
429
  /* @__PURE__ */ c(
429
- Se,
430
+ _e,
430
431
  {
431
432
  open: P,
432
433
  onOpenChange: (l) => {
433
- q(l), l || T("");
434
+ C(l), l || T("");
434
435
  },
435
436
  children: [
436
- /* @__PURE__ */ n(_e, { asChild: !0, children: /* @__PURE__ */ c(
437
+ /* @__PURE__ */ n(qe, { asChild: !0, children: /* @__PURE__ */ c(
437
438
  "button",
438
439
  {
439
440
  type: "button",
@@ -459,12 +460,12 @@ function nt({
459
460
  ]
460
461
  }
461
462
  ) }),
462
- /* @__PURE__ */ n(Ce, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(xe, { shouldFilter: !1, children: [
463
+ /* @__PURE__ */ n(Ce, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(ve, { shouldFilter: !1, children: [
463
464
  /* @__PURE__ */ n(
464
- ve,
465
+ ge,
465
466
  {
466
467
  placeholder: "Search…",
467
- value: L,
468
+ value: x,
468
469
  onValueChange: T,
469
470
  className: "h-9 text-[12px]"
470
471
  }
@@ -474,7 +475,7 @@ function nt({
474
475
  {
475
476
  type: "button",
476
477
  onClick: () => {
477
- Ue(), q(!1);
478
+ $e(), C(!1);
478
479
  },
479
480
  className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-slate-500 hover:bg-muted border-b border-slate-100 dark:text-slate-400 dark:border-border",
480
481
  children: [
@@ -483,17 +484,17 @@ function nt({
483
484
  ]
484
485
  }
485
486
  ),
486
- /* @__PURE__ */ c(ge, { children: [
487
- 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" }),
488
- !B && /* @__PURE__ */ n(we, { children: [...V].sort(
489
- (l, f) => S ? 0 : b === "-label" ? i(f).localeCompare(i(l)) : i(l).localeCompare(i(f))
487
+ /* @__PURE__ */ c(ke, { children: [
488
+ 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(we, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
489
+ !V && /* @__PURE__ */ n(Ne, { children: [...B].sort(
490
+ (l, p) => S ? 0 : he(i(l), i(p), x, b === "-label")
490
491
  ).map((l) => {
491
- const f = String(l.id), ee = String(m) === f;
492
+ const p = String(l.id), ee = String(m) === p;
492
493
  return /* @__PURE__ */ c(
493
- Ne,
494
+ Se,
494
495
  {
495
- value: f,
496
- onSelect: () => Oe(l.id),
496
+ value: p,
497
+ onSelect: () => Ue(l.id),
497
498
  className: "flex items-center gap-2 text-[12px]",
498
499
  children: [
499
500
  /* @__PURE__ */ n(
@@ -507,14 +508,14 @@ function nt({
507
508
  }
508
509
  ),
509
510
  r === "nivaro_users" && /* @__PURE__ */ n(
510
- ye,
511
+ xe,
511
512
  {
512
- userId: f,
513
+ userId: p,
513
514
  className: "h-4 w-4",
514
- fallback: /* @__PURE__ */ n("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: je(i(l)) })
515
+ fallback: /* @__PURE__ */ n("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: Fe(i(l)) })
515
516
  }
516
517
  ),
517
- r === "nivaro_users" && H.has(f.toUpperCase()) && /* @__PURE__ */ n(
518
+ r === "nivaro_users" && H.has(p.toUpperCase()) && /* @__PURE__ */ n(
518
519
  "span",
519
520
  {
520
521
  className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
@@ -524,7 +525,7 @@ function nt({
524
525
  /* @__PURE__ */ n("span", { className: "truncate", children: i(l) })
525
526
  ]
526
527
  },
527
- f
528
+ p
528
529
  );
529
530
  }) })
530
531
  ] })
@@ -532,12 +533,12 @@ function nt({
532
533
  ]
533
534
  }
534
535
  ),
535
- k.tip
536
+ F.tip
536
537
  ] });
537
538
  }
538
539
  export {
539
- tt as M2MCombobox,
540
- nt as M2MSingleSelectCombobox,
541
- et as m2aWriteMeta,
542
- Te as resolveM2MRelatedCollection
540
+ lt as M2MCombobox,
541
+ rt as M2MSingleSelectCombobox,
542
+ nt as m2aWriteMeta,
543
+ Oe as resolveM2MRelatedCollection
543
544
  };