@nivaro/react 0.3.95 → 0.3.97

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,45 +1,48 @@
1
1
  import { jsx as r, jsxs as c } from "react/jsx-runtime";
2
2
  import { useQuery as q } from "@tanstack/react-query";
3
- import { ChevronDown as ae, Loader2 as ue, AlertTriangle as he, X as me, Check as ye } from "lucide-react";
3
+ import { ChevronDown as ae, Loader2 as ue, AlertTriangle as ye, X as me, Check as be } from "lucide-react";
4
4
  import { useState as E, useRef as fe, useEffect as pe } from "react";
5
- import { useNivaroClient as be, useItemEditAuth as xe, useDrilldown as Ee } from "../../context.js";
6
- import { parseAllowedCollections as Re } from "../../lib/allowed-collections.js";
5
+ import { useNivaroClient as xe, useItemEditAuth as ge, useDrilldown as Ee } from "../../context.js";
6
+ import { parseAllowedCollections as ze } from "../../lib/allowed-collections.js";
7
7
  import { get as U } from "../../lib/commands.js";
8
- import { compareByMatch as ge } from "../../lib/picker-rank.js";
9
- import { useRecordReader as ze } from "../../lib/record-loader.js";
10
- import { useOnlineUsers as ve } from "../../lib/use-online-users.js";
11
- import { cn as X, userOptionFilter as ke, matchesAllTokens as Ge } from "../../lib/utils.js";
12
- import { UserAvatar as we } from "../UserAvatar.js";
13
- import { Command as Se, CommandInput as Ne, CommandList as _e, CommandEmpty as Ce, CommandGroup as Le, CommandItem as Oe } from "../ui/command.js";
14
- import { Popover as Fe, PopoverTrigger as qe, PopoverContent as je } from "../ui/popover.js";
15
- import { applyDisplayTemplate as Te } from "./helpers.js";
16
- import { useM2MStaging as Ae } from "./M2MStagingContext.js";
8
+ import { compareByMatch as ve } from "../../lib/picker-rank.js";
9
+ import { useRecordReader as Ge } from "../../lib/record-loader.js";
10
+ import { useOnlineUsers as ke } from "../../lib/use-online-users.js";
11
+ import { cn as X, userOptionFilter as we, matchesAllTokens as Re } from "../../lib/utils.js";
12
+ import { UserAvatar as Se } from "../UserAvatar.js";
13
+ import { Command as Ne, CommandInput as _e, CommandList as Ce, CommandEmpty as Le, CommandGroup as Oe, CommandItem as Fe } from "../ui/command.js";
14
+ import { Popover as qe, PopoverTrigger as je, PopoverContent as Te } from "../ui/popover.js";
15
+ import { applyDisplayTemplate as Ae } from "./helpers.js";
16
+ import { useM2MStaging as Ie } from "./M2MStagingContext.js";
17
17
  import { onlyCloseMatches as Ve } from "./picker-search.js";
18
18
  import { useStaleTip as Be, RelatedItemLabel as de } from "./RelationCombobox.js";
19
- function Ie(n) {
20
- return n.replace(/\(.*$/, "").trim().split(/\s+/).map((i) => i[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
19
+ function Ue(t) {
20
+ return t.replace(/\(.*$/, "").trim().split(/\s+/).map((i) => i[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
21
21
  }
22
- function Ue(n) {
23
- return Re(n == null ? void 0 : n.one_allowed_collections);
22
+ function he(t) {
23
+ return ze(t == null ? void 0 : t.one_allowed_collections);
24
24
  }
25
- function Ke(n) {
26
- if (!n) return null;
27
- if (n.one_collection) return n.one_collection;
28
- const i = Ue(n);
25
+ function ft(t) {
26
+ return !t || t.one_collection ? 0 : he(t).length;
27
+ }
28
+ function Ke(t) {
29
+ if (!t) return null;
30
+ if (t.one_collection) return t.one_collection;
31
+ const i = he(t);
29
32
  return i.length === 0 ? null : i.some((f) => f === "directus_users" || f === "nivaro_users") ? "nivaro_users" : i[0];
30
33
  }
31
- function ft(n) {
32
- if (!n || n.one_collection) return null;
33
- const i = Ue(n);
34
+ function pt(t) {
35
+ if (!t || t.one_collection) return null;
36
+ const i = he(t);
34
37
  if (i.length === 0) return null;
35
38
  const f = i.includes("directus_users") ? "directus_users" : i.includes("nivaro_users") ? "nivaro_users" : i[0];
36
- return { field: n.one_collection_field ?? "collection", value: f };
39
+ return { field: t.one_collection_field ?? "collection", value: f };
37
40
  }
38
- function Q(n) {
39
- return String(n).toLowerCase();
41
+ function Q(t) {
42
+ return String(t).toLowerCase();
40
43
  }
41
- function pt({
42
- relation: n,
44
+ function ht({
45
+ relation: t,
43
46
  parentId: i,
44
47
  allRelations: f,
45
48
  extraFilter: d,
@@ -48,26 +51,26 @@ function pt({
48
51
  onCountChange: x,
49
52
  drilldown: b
50
53
  }) {
51
- const v = be(), A = Ee(), t = Ae(), [N, S] = E(!1), [m, L] = E(""), j = f.find(
52
- (e) => e.many_collection === n.many_collection && e.many_field === n.junction_field && e.id !== n.id
53
- ), s = Ke(j), O = n.junction_field ?? "", R = n.many_field ?? "", h = n.one_field ?? `${n.many_collection}.${O}`, { data: o } = q({
54
+ const v = xe(), A = Ee(), n = Ie(), [N, S] = E(!1), [m, L] = E(""), j = f.find(
55
+ (e) => e.many_collection === t.many_collection && e.many_field === t.junction_field && e.id !== t.id
56
+ ), s = Ke(j), O = t.junction_field ?? "", z = t.many_field ?? "", h = t.one_field ?? `${t.many_collection}.${O}`, { data: o } = q({
54
57
  queryKey: ["col-meta", s],
55
58
  queryFn: () => v.request(U(`/collections/${s}`)).then((e) => e.data),
56
59
  enabled: !!s,
57
60
  staleTime: 3e5,
58
61
  retry: !1
59
62
  }), { data: H = [] } = q({
60
- queryKey: ["m2m-items", n.many_collection, R, i],
63
+ queryKey: ["m2m-items", t.many_collection, z, i],
61
64
  queryFn: () => v.request(
62
- U(`/items/${n.many_collection}`, {
63
- filter: JSON.stringify({ [R]: { _eq: i } }),
65
+ U(`/items/${t.many_collection}`, {
66
+ filter: JSON.stringify({ [z]: { _eq: i } }),
64
67
  limit: 200,
65
68
  fields: `id,${O}`
66
69
  })
67
70
  ).then((e) => e.data ?? []),
68
71
  staleTime: 3e4,
69
72
  enabled: !!i && i !== "new"
70
- }), ce = xe().isAdmin, z = s === "nivaro_users" ? ke(ce) : null, G = ve(s === "nivaro_users"), Y = d ? z ? { _and: [d, z] } : d : z, V = Y ? JSON.stringify(Y) : void 0, B = p && !/^-?label$/.test(p) ? p : void 0, Z = (() => {
73
+ }), ce = ge().isAdmin, G = s === "nivaro_users" ? we(ce) : null, R = ke(s === "nivaro_users"), Y = d ? G ? { _and: [d, G] } : d : G, V = Y ? JSON.stringify(Y) : void 0, B = p && !/^-?label$/.test(p) ? p : void 0, Z = (() => {
71
74
  const e = o == null ? void 0 : o.display_template;
72
75
  if (!e || !e.includes(".")) return null;
73
76
  const a = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((u) => u[1].trim());
@@ -86,7 +89,7 @@ function pt({
86
89
  templateNestedFields: Z,
87
90
  enabled: N && !!s,
88
91
  labelOf: _
89
- }), ne = Pe(!!te, m), re = (t == null ? void 0 : t.getStagedLinks(h)) ?? [], F = (t == null ? void 0 : t.getStagedUnlinks(h)) ?? /* @__PURE__ */ new Set(), D = H.filter((e) => !F.has(e.id)), k = new Set(D.map((e) => String(e[O]))), T = [...k], le = JSON.stringify(d ? { _and: [{ id: { _in: T } }, d] } : { id: { _in: T } }), { data: y } = q({
92
+ }), ne = Pe(!!te, m), re = (n == null ? void 0 : n.getStagedLinks(h)) ?? [], F = (n == null ? void 0 : n.getStagedUnlinks(h)) ?? /* @__PURE__ */ new Set(), D = H.filter((e) => !F.has(e.id)), k = new Set(D.map((e) => String(e[O]))), T = [...k], le = JSON.stringify(d ? { _and: [{ id: { _in: T } }, d] } : { id: { _in: T } }), { data: y } = q({
90
93
  queryKey: ["m2m-avail", s, T.join(","), V],
91
94
  queryFn: () => v.request(
92
95
  U(`/items/${s}`, {
@@ -106,19 +109,19 @@ function pt({
106
109
  function W(e) {
107
110
  const a = Q(e);
108
111
  if (J.has(a)) {
109
- t == null || t.unstageLink(h, e);
112
+ n == null || n.unstageLink(h, e);
110
113
  return;
111
114
  }
112
115
  const u = H.find((C) => Q(C[O]) === a);
113
116
  if (u) {
114
- F.has(u.id) ? t == null || t.unstageUnlink(h, u.id) : t == null || t.stageUnlink(h, u.id);
117
+ F.has(u.id) ? n == null || n.unstageUnlink(h, u.id) : n == null || n.stageUnlink(h, u.id);
115
118
  return;
116
119
  }
117
- t == null || t.stageLink(h, e);
120
+ n == null || n.stageLink(h, e);
118
121
  }
119
122
  function _(e) {
120
123
  const a = (o == null ? void 0 : o.display_template) ?? null;
121
- return a ? Te(a, e) : String(e._display ?? e.id ?? "");
124
+ return a ? Ae(a, e) : String(e._display ?? e.id ?? "");
122
125
  }
123
126
  return w ? /* @__PURE__ */ c(
124
127
  "button",
@@ -136,14 +139,14 @@ function pt({
136
139
  ]
137
140
  }
138
141
  ) : /* @__PURE__ */ r("div", { children: /* @__PURE__ */ c(
139
- Fe,
142
+ qe,
140
143
  {
141
144
  open: N,
142
145
  onOpenChange: (e) => {
143
146
  S(e), e || L("");
144
147
  },
145
148
  children: [
146
- /* @__PURE__ */ r(qe, { asChild: !0, children: /* @__PURE__ */ c(
149
+ /* @__PURE__ */ r(je, { asChild: !0, children: /* @__PURE__ */ c(
147
150
  "div",
148
151
  {
149
152
  role: "button",
@@ -176,7 +179,7 @@ function pt({
176
179
  u ? "border-amber-300 bg-amber-50 text-amber-700 dark:border-amber-600 dark:bg-amber-950/30 dark:text-amber-400" : "border-slate-200 bg-slate-50 text-slate-700 dark:border-border dark:bg-muted dark:text-slate-200"
177
180
  ),
178
181
  children: [
179
- u && /* @__PURE__ */ r(he, { className: "h-3 w-3 shrink-0 text-amber-500" }),
182
+ u && /* @__PURE__ */ r(ye, { className: "h-3 w-3 shrink-0 text-amber-500" }),
180
183
  s && (b && A ? /* @__PURE__ */ r(
181
184
  "button",
182
185
  {
@@ -211,7 +214,7 @@ function pt({
211
214
  {
212
215
  type: "button",
213
216
  "aria-label": "Remove",
214
- onClick: () => t == null ? void 0 : t.stageUnlink(h, e.id),
217
+ onClick: () => n == null ? void 0 : n.stageUnlink(h, e.id),
215
218
  className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
216
219
  children: /* @__PURE__ */ r(me, { className: "h-3 w-3" })
217
220
  }
@@ -239,7 +242,7 @@ function pt({
239
242
  {
240
243
  type: "button",
241
244
  "aria-label": "Remove",
242
- onClick: () => t == null ? void 0 : t.unstageLink(h, e),
245
+ onClick: () => n == null ? void 0 : n.unstageLink(h, e),
243
246
  className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
244
247
  children: /* @__PURE__ */ r(me, { className: "h-3 w-3" })
245
248
  }
@@ -255,14 +258,14 @@ function pt({
255
258
  ]
256
259
  }
257
260
  ) }),
258
- /* @__PURE__ */ r(je, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
259
- Se,
261
+ /* @__PURE__ */ r(Te, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
262
+ Ne,
260
263
  {
261
264
  shouldFilter: !1,
262
265
  ...ne,
263
266
  children: [
264
267
  /* @__PURE__ */ r(
265
- Ne,
268
+ _e,
266
269
  {
267
270
  placeholder: "Search…",
268
271
  value: m,
@@ -270,8 +273,8 @@ function pt({
270
273
  className: "h-9 text-[13px]"
271
274
  }
272
275
  ),
273
- /* @__PURE__ */ c(_e, { children: [
274
- K ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ r(ue, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ r(Ce, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
276
+ /* @__PURE__ */ c(Ce, { children: [
277
+ K ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ r(ue, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ r(Le, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
275
278
  !K && te && /* @__PURE__ */ c(
276
279
  "p",
277
280
  {
@@ -284,12 +287,12 @@ function pt({
284
287
  ]
285
288
  }
286
289
  ),
287
- /* @__PURE__ */ r(Le, { children: !K && (B ? [...oe(ee, m, $, _)] : [...oe(ee, m, $, _)].sort(
288
- (e, a) => ge(_(e), _(a), m, p === "-label")
290
+ /* @__PURE__ */ r(Oe, { children: !K && (B ? [...oe(ee, m, $, _)] : [...oe(ee, m, $, _)].sort(
291
+ (e, a) => ve(_(e), _(a), m, p === "-label")
289
292
  )).map((e) => {
290
293
  const a = String(e.id), u = M.has(Q(a));
291
294
  return /* @__PURE__ */ c(
292
- Oe,
295
+ Fe,
293
296
  {
294
297
  value: a,
295
298
  onSelect: () => W(e.id),
@@ -302,18 +305,18 @@ function pt({
302
305
  "flex h-4 w-4 shrink-0 items-center justify-center rounded border",
303
306
  u ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
304
307
  ),
305
- children: u && /* @__PURE__ */ r(ye, { className: "h-2.5 w-2.5 text-white" })
308
+ children: u && /* @__PURE__ */ r(be, { className: "h-2.5 w-2.5 text-white" })
306
309
  }
307
310
  ),
308
311
  s === "nivaro_users" && /* @__PURE__ */ r(
309
- we,
312
+ Se,
310
313
  {
311
314
  userId: a,
312
315
  className: "h-4 w-4",
313
- fallback: /* @__PURE__ */ r("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: Ie(_(e)) })
316
+ fallback: /* @__PURE__ */ r("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: Ue(_(e)) })
314
317
  }
315
318
  ),
316
- s === "nivaro_users" && G.has(a.toUpperCase()) && /* @__PURE__ */ r(
319
+ s === "nivaro_users" && R.has(a.toUpperCase()) && /* @__PURE__ */ r(
317
320
  "span",
318
321
  {
319
322
  className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
@@ -334,8 +337,8 @@ function pt({
334
337
  }
335
338
  ) });
336
339
  }
337
- function $e(n) {
338
- const { client: i, relatedCollection: f, search: d, filterParam: p, serverSort: w, templateNestedFields: x } = n, b = (j) => i.request(
340
+ function $e(t) {
341
+ const { client: i, relatedCollection: f, search: d, filterParam: p, serverSort: w, templateNestedFields: x } = t, b = (j) => i.request(
339
342
  U(`/items/${f}`, {
340
343
  limit: De,
341
344
  search: j || void 0,
@@ -355,15 +358,15 @@ function $e(n) {
355
358
  p,
356
359
  w ?? "",
357
360
  x ?? ""
358
- ], A = p ? 0 : 3e4, { data: t, isFetching: N } = q({
361
+ ], A = p ? 0 : 3e4, { data: n, isFetching: N } = q({
359
362
  queryKey: v(""),
360
363
  queryFn: () => b(""),
361
- enabled: n.enabled,
364
+ enabled: t.enabled,
362
365
  staleTime: A
363
- }), S = We(t, d, n.labelOf), { data: m, isFetching: L } = q({
366
+ }), S = We(n, d, t.labelOf), { data: m, isFetching: L } = q({
364
367
  queryKey: v(d),
365
368
  queryFn: () => b(d),
366
- enabled: n.enabled && S,
369
+ enabled: t.enabled && S,
367
370
  staleTime: A
368
371
  });
369
372
  return S ? {
@@ -371,17 +374,17 @@ function $e(n) {
371
374
  isLoading: !m && L,
372
375
  localSearch: !1,
373
376
  closeMatches: Ve(m)
374
- } : { options: t ?? [], isLoading: !t && N, localSearch: !!d };
377
+ } : { options: n ?? [], isLoading: !n && N, localSearch: !!d };
375
378
  }
376
379
  const De = 200;
377
- function We(n, i, f) {
378
- return i.trim() ? !n || n.length >= De ? !0 : oe(n, i, !0, f).length === 0 : !1;
380
+ function We(t, i, f) {
381
+ return i.trim() ? !t || t.length >= De ? !0 : oe(t, i, !0, f).length === 0 : !1;
379
382
  }
380
- function oe(n, i, f, d) {
381
- return !f || !i.trim() ? n : n.filter((p) => Ge(d(p), i));
383
+ function oe(t, i, f, d) {
384
+ return !f || !i.trim() ? t : t.filter((p) => Re(d(p), i));
382
385
  }
383
- function ht({
384
- relation: n,
386
+ function yt({
387
+ relation: t,
385
388
  parentId: i,
386
389
  allRelations: f,
387
390
  extraFilter: d,
@@ -390,26 +393,26 @@ function ht({
390
393
  onCountChange: x,
391
394
  readOnly: b
392
395
  }) {
393
- const v = be(), A = ze(), t = Ae(), [N, S] = E(!1), [m, L] = E(""), j = f.find(
394
- (l) => l.many_collection === n.many_collection && l.many_field === n.junction_field && l.id !== n.id
395
- ), s = Ke(j), O = n.junction_field ?? "", R = n.many_field ?? "", h = n.one_field ?? `${n.many_collection}.${O}`, { data: o } = q({
396
+ const v = xe(), A = Ge(), n = Ie(), [N, S] = E(!1), [m, L] = E(""), j = f.find(
397
+ (l) => l.many_collection === t.many_collection && l.many_field === t.junction_field && l.id !== t.id
398
+ ), s = Ke(j), O = t.junction_field ?? "", z = t.many_field ?? "", h = t.one_field ?? `${t.many_collection}.${O}`, { data: o } = q({
396
399
  queryKey: ["col-meta", s],
397
400
  queryFn: () => v.request(U(`/collections/${s}`)).then((l) => l.data),
398
401
  enabled: !!s,
399
402
  staleTime: 3e5,
400
403
  retry: !1
401
404
  }), { data: H = [], isFetching: ce } = q({
402
- queryKey: ["m2m-items", n.many_collection, R, i],
405
+ queryKey: ["m2m-items", t.many_collection, z, i],
403
406
  queryFn: () => v.request(
404
- U(`/items/${n.many_collection}`, {
405
- filter: JSON.stringify({ [R]: { _eq: i } }),
407
+ U(`/items/${t.many_collection}`, {
408
+ filter: JSON.stringify({ [z]: { _eq: i } }),
406
409
  limit: 1,
407
410
  fields: `id,${O}`
408
411
  })
409
412
  ).then((l) => l.data ?? []),
410
413
  staleTime: 3e4,
411
414
  enabled: !!i && i !== "new"
412
- }), z = xe().isAdmin, G = s === "nivaro_users" ? ke(z) : null, Y = ve(s === "nivaro_users"), V = d ? G ? { _and: [d, G] } : d : G, B = V ? JSON.stringify(V) : void 0, Z = p && !/^-?label$/.test(p) ? p : void 0, ee = (() => {
415
+ }), G = ge().isAdmin, R = s === "nivaro_users" ? we(G) : null, Y = ke(s === "nivaro_users"), V = d ? R ? { _and: [d, R] } : d : R, B = V ? JSON.stringify(V) : void 0, Z = p && !/^-?label$/.test(p) ? p : void 0, ee = (() => {
413
416
  const l = o == null ? void 0 : o.display_template;
414
417
  if (!l || !l.includes(".")) return null;
415
418
  const g = [...l.matchAll(/\{\{([^}]+)\}\}/g)].map((ie) => ie[1].trim());
@@ -428,7 +431,7 @@ function ht({
428
431
  templateNestedFields: ee,
429
432
  enabled: N && !!s,
430
433
  labelOf: e
431
- }), re = Pe(!!ne, m), F = (t == null ? void 0 : t.getStagedLinks(h)) ?? [], D = (t == null ? void 0 : t.getStagedUnlinks(h)) ?? /* @__PURE__ */ new Set(), k = H.find((l) => !D.has(l.id)) ?? null, T = k ? k[O] : null, le = F.length > 0 ? F[F.length - 1] : null, y = le ?? T, se = F.length > 0 || D.size > 0, P = fe(x);
434
+ }), re = Pe(!!ne, m), F = (n == null ? void 0 : n.getStagedLinks(h)) ?? [], D = (n == null ? void 0 : n.getStagedUnlinks(h)) ?? /* @__PURE__ */ new Set(), k = H.find((l) => !D.has(l.id)) ?? null, T = k ? k[O] : null, le = F.length > 0 ? F[F.length - 1] : null, y = le ?? T, se = F.length > 0 || D.size > 0, P = fe(x);
432
435
  P.current = x, pe(() => {
433
436
  var l;
434
437
  (l = P.current) == null || l.call(P, y != null ? 1 : 0);
@@ -453,18 +456,18 @@ function ht({
453
456
  }), W = I !== void 0 && I.length === 0, _ = Be(W);
454
457
  function e(l) {
455
458
  const g = (o == null ? void 0 : o.display_template) ?? null;
456
- return g ? Te(g, l) : String(l.name ?? l.title ?? l.label ?? l.id ?? "");
459
+ return g ? Ae(g, l) : String(l.name ?? l.title ?? l.label ?? l.id ?? "");
457
460
  }
458
461
  const a = K.find((l) => String(l.id) === String(y)) ?? J, u = y != null && !J && !a, C = a ? e(a) : null;
459
462
  if (b)
460
463
  return /* @__PURE__ */ r("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: u ? "…" : C ?? "—" });
461
464
  function Je(l) {
462
- for (const g of F) t == null || t.unstageLink(h, g);
463
- k && !D.has(k.id) && (t == null || t.stageUnlink(h, k.id)), String(l) === String(T) && k ? t == null || t.unstageUnlink(h, k.id) : String(l) !== String(y) && (t == null || t.stageLink(h, l)), S(!1), L("");
465
+ for (const g of F) n == null || n.unstageLink(h, g);
466
+ k && !D.has(k.id) && (n == null || n.stageUnlink(h, k.id)), String(l) === String(T) && k ? n == null || n.unstageUnlink(h, k.id) : String(l) !== String(y) && (n == null || n.stageLink(h, l)), S(!1), L("");
464
467
  }
465
468
  function Me() {
466
- for (const l of F) t == null || t.unstageLink(h, l);
467
- k && (t == null || t.stageUnlink(h, k.id)), S(!1);
469
+ for (const l of F) n == null || n.unstageLink(h, l);
470
+ k && (n == null || n.stageUnlink(h, k.id)), S(!1);
468
471
  }
469
472
  return w ? /* @__PURE__ */ c(
470
473
  "button",
@@ -483,14 +486,14 @@ function ht({
483
486
  }
484
487
  ) : /* @__PURE__ */ c("div", { ..._.bind, children: [
485
488
  /* @__PURE__ */ c(
486
- Fe,
489
+ qe,
487
490
  {
488
491
  open: N,
489
492
  onOpenChange: (l) => {
490
493
  S(l), l || L("");
491
494
  },
492
495
  children: [
493
- /* @__PURE__ */ r(qe, { asChild: !0, children: /* @__PURE__ */ c(
496
+ /* @__PURE__ */ r(je, { asChild: !0, children: /* @__PURE__ */ c(
494
497
  "button",
495
498
  {
496
499
  type: "button",
@@ -507,7 +510,7 @@ function ht({
507
510
  C ? se ? "text-nvr-cyan" : "text-slate-800 dark:text-slate-100" : "text-muted-foreground"
508
511
  ),
509
512
  children: [
510
- W && /* @__PURE__ */ r(he, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
513
+ W && /* @__PURE__ */ r(ye, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
511
514
  /* @__PURE__ */ r("span", { className: "truncate", children: C ?? "Select…" })
512
515
  ]
513
516
  }
@@ -516,14 +519,14 @@ function ht({
516
519
  ]
517
520
  }
518
521
  ) }),
519
- /* @__PURE__ */ r(je, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
520
- Se,
522
+ /* @__PURE__ */ r(Te, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(
523
+ Ne,
521
524
  {
522
525
  shouldFilter: !1,
523
526
  ...re,
524
527
  children: [
525
528
  /* @__PURE__ */ r(
526
- Ne,
529
+ _e,
527
530
  {
528
531
  placeholder: "Search…",
529
532
  value: m,
@@ -545,8 +548,8 @@ function ht({
545
548
  ]
546
549
  }
547
550
  ),
548
- /* @__PURE__ */ c(_e, { children: [
549
- $ ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ r(ue, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ r(Ce, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
551
+ /* @__PURE__ */ c(Ce, { children: [
552
+ $ ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ r(ue, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ r(Le, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
550
553
  !$ && ne && /* @__PURE__ */ c(
551
554
  "p",
552
555
  {
@@ -559,12 +562,12 @@ function ht({
559
562
  ]
560
563
  }
561
564
  ),
562
- !$ && /* @__PURE__ */ r(Le, { children: [...oe(K, m, te, e)].sort(
563
- (l, g) => Z ? 0 : ge(e(l), e(g), m, p === "-label")
565
+ !$ && /* @__PURE__ */ r(Oe, { children: [...oe(K, m, te, e)].sort(
566
+ (l, g) => Z ? 0 : ve(e(l), e(g), m, p === "-label")
564
567
  ).map((l) => {
565
568
  const g = String(l.id), ie = String(y) === g;
566
569
  return /* @__PURE__ */ c(
567
- Oe,
570
+ Fe,
568
571
  {
569
572
  value: g,
570
573
  onSelect: () => Je(l.id),
@@ -577,15 +580,15 @@ function ht({
577
580
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
578
581
  ie ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
579
582
  ),
580
- children: ie && /* @__PURE__ */ r(ye, { className: "h-2.5 w-2.5 text-white" })
583
+ children: ie && /* @__PURE__ */ r(be, { className: "h-2.5 w-2.5 text-white" })
581
584
  }
582
585
  ),
583
586
  s === "nivaro_users" && /* @__PURE__ */ r(
584
- we,
587
+ Se,
585
588
  {
586
589
  userId: g,
587
590
  className: "h-4 w-4",
588
- fallback: /* @__PURE__ */ r("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: Ie(e(l)) })
591
+ fallback: /* @__PURE__ */ r("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: Ue(e(l)) })
589
592
  }
590
593
  ),
591
594
  s === "nivaro_users" && Y.has(g.toUpperCase()) && /* @__PURE__ */ r(
@@ -611,11 +614,11 @@ function ht({
611
614
  _.tip
612
615
  ] });
613
616
  }
614
- function Pe(n, i) {
617
+ function Pe(t, i) {
615
618
  const [f, d] = E(null), [p, w] = E(!1), x = fe(!1);
616
619
  return pe(() => {
617
620
  d(null), x.current = !1;
618
- }, [i]), n ? {
621
+ }, [i]), t ? {
619
622
  value: f ?? (p ? " " : ""),
620
623
  onValueChange: (b) => {
621
624
  x.current ? d(b) : w((v) => !v);
@@ -629,9 +632,10 @@ function Pe(n, i) {
629
632
  } : {};
630
633
  }
631
634
  export {
632
- pt as M2MCombobox,
633
- ht as M2MSingleSelectCombobox,
634
- ft as m2aWriteMeta,
635
+ ht as M2MCombobox,
636
+ yt as M2MSingleSelectCombobox,
637
+ ft as m2aAllowedCount,
638
+ pt as m2aWriteMeta,
635
639
  We as m2mAsksServer,
636
640
  Q as m2mIdKey,
637
641
  oe as narrowM2MOptions,