@nivaro/react 0.3.13 → 0.3.15

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.
Files changed (48) hide show
  1. package/dist/components/slots/pipeline/OwnersSection.js +79 -75
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +33 -2
  5. package/dist/index.js +520 -516
  6. package/dist/shared/components/CollectionBrowserView.js +2393 -2318
  7. package/dist/shared/components/DataTable.js +347 -335
  8. package/dist/shared/components/ItemEditForm.js +5278 -5149
  9. package/dist/shared/components/ListLoadError.js +33 -0
  10. package/dist/shared/components/PageRenderer.js +562 -529
  11. package/dist/shared/components/ProfileView.js +53 -51
  12. package/dist/shared/components/RecordReadView.js +119 -117
  13. package/dist/shared/components/ReportView.js +1268 -1241
  14. package/dist/shared/components/cbv/export-rows.js +69 -0
  15. package/dist/shared/components/cbv/saved-view-risk.js +35 -0
  16. package/dist/shared/components/cbv/unknown-fields.js +18 -0
  17. package/dist/shared/components/integrations/console/AlertsView.js +27 -25
  18. package/dist/shared/components/integrations/console/EventsView.js +244 -209
  19. package/dist/shared/components/item-edit/CatalogPickerField.js +946 -878
  20. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +84 -57
  21. package/dist/shared/components/item-edit/FieldAffordances.js +63 -61
  22. package/dist/shared/components/item-edit/FieldRow.js +195 -179
  23. package/dist/shared/components/item-edit/FilePickerField.js +257 -254
  24. package/dist/shared/components/item-edit/HeaderTools.js +139 -95
  25. package/dist/shared/components/item-edit/InlineTableField.js +2087 -2075
  26. package/dist/shared/components/item-edit/RowComments.js +1 -3
  27. package/dist/shared/components/item-edit/SummaryPanel.js +62 -62
  28. package/dist/shared/components/item-edit/UserChip.js +113 -113
  29. package/dist/shared/components/item-edit/file-download.js +18 -0
  30. package/dist/shared/components/item-edit/line-qty.js +67 -32
  31. package/dist/shared/components/item-edit/save-refusal.js +23 -0
  32. package/dist/shared/components/monitoring/TrafficMiniMap.js +9 -9
  33. package/dist/shared/components/panels/CommentPanel.js +30 -30
  34. package/dist/shared/components/panels/ItemLockBanner.js +207 -185
  35. package/dist/shared/components/panels/PipelinePanel.js +915 -786
  36. package/dist/shared/components/pipeline/PipelineEditorView.js +45 -25
  37. package/dist/shared/components/profile/DelegationCard.js +1 -1
  38. package/dist/shared/components/profile/session-actions.js +24 -24
  39. package/dist/shared/components/queue/QueueItemSheet.js +18 -18
  40. package/dist/shared/components/queue/QueueWorklist.js +517 -504
  41. package/dist/shared/components/ui/dropdown-menu.js +8 -7
  42. package/dist/shared/lib/draft-store.js +60 -33
  43. package/dist/shared/lib/leave-guard.js +38 -0
  44. package/dist/shared/lib/load-error.js +38 -17
  45. package/dist/shared/lib/summary-mode.js +25 -25
  46. package/dist/shared/lib/table-pins.js +23 -0
  47. package/dist/shared/lib/validation-rules.js +55 -51
  48. package/package.json +1 -1
@@ -1,60 +1,61 @@
1
- import { jsxs as i, jsx as e, Fragment as A } from "react/jsx-runtime";
2
- import { useQueryClient as pe, useQuery as Z } from "@tanstack/react-query";
3
- import { Clock as fe, Download as xe, Loader2 as D, Upload as ie, X as I, Plus as ze, File as ue, FileVideo as Se, FileAudio as je, FileText as ae, FileSpreadsheet as Pe, FileCode as We } from "lucide-react";
4
- import { useId as re, useState as w, useRef as ge, useEffect as B } from "react";
5
- import { useNivaroClient as ce, useGridFlush as be, useParentDraft as ye } from "../../context.js";
1
+ import { jsxs as i, jsx as t, Fragment as A } from "react/jsx-runtime";
2
+ import { useQueryClient as fe, useQuery as Z } from "@tanstack/react-query";
3
+ import { Clock as xe, Download as ge, Loader2 as I, Upload as re, X as ee, Plus as je, File as me, FileVideo as Pe, FileAudio as We, FileText as ie, FileSpreadsheet as $e, FileCode as Ke } from "lucide-react";
4
+ import { useId as oe, useState as v, useRef as be, useEffect as B } from "react";
5
+ import { useNivaroClient as de, useGridFlush as ye, useParentDraft as we } from "../../context.js";
6
6
  import { useFileHealth as ve } from "../../hooks/useFileHealth.js";
7
- import { get as ee, post as me, del as he } from "../../lib/commands.js";
8
- import { cn as oe } from "../../lib/utils.js";
9
- import { FilePreviewLightbox as we } from "../FilePreviewLightbox.js";
10
- import { useOnceVisible as Ne, useFileUsage as ke, FileUsageChip as _e } from "./FileUsage.js";
11
- import { useM2MStaging as Ke } from "./M2MStagingContext.js";
12
- function te(s) {
13
- return s ? s < 1024 ? `${s} B` : s < 1024 * 1024 ? `${(s / 1024).toFixed(1)} KB` : `${(s / (1024 * 1024)).toFixed(1)} MB` : null;
7
+ import { get as te, post as he, del as pe } from "../../lib/commands.js";
8
+ import { cn as ce } from "../../lib/utils.js";
9
+ import { FilePreviewLightbox as Ne } from "../FilePreviewLightbox.js";
10
+ import { useOnceVisible as ke, useFileUsage as _e, FileUsageChip as Fe } from "./FileUsage.js";
11
+ import { useFileDownload as Ce } from "./file-download.js";
12
+ import { useM2MStaging as Oe } from "./M2MStagingContext.js";
13
+ function le(n) {
14
+ return n ? n < 1024 ? `${n} B` : n < 1024 * 1024 ? `${(n / 1024).toFixed(1)} KB` : `${(n / (1024 * 1024)).toFixed(1)} MB` : null;
14
15
  }
15
- function Fe(s) {
16
- if (!s) return null;
17
- const a = new Date(s);
16
+ function Le(n) {
17
+ if (!n) return null;
18
+ const a = new Date(n);
18
19
  return a.toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" }) + " " + a.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
19
20
  }
20
- function $e(s) {
21
- return !!s && s.startsWith("image/");
21
+ function Qe(n) {
22
+ return !!n && n.startsWith("image/");
22
23
  }
23
- function Oe(s, a) {
24
- return s ? s.startsWith("video/") ? /* @__PURE__ */ e(Se, { className: a, strokeWidth: 1.5 }) : s.startsWith("audio/") ? /* @__PURE__ */ e(je, { className: a, strokeWidth: 1.5 }) : s === "application/pdf" ? /* @__PURE__ */ e(ae, { className: a, strokeWidth: 1.5 }) : s.startsWith("text/") ? /* @__PURE__ */ e(ae, { className: a, strokeWidth: 1.5 }) : s.includes("spreadsheet") || s.includes("excel") || s === "text/csv" ? /* @__PURE__ */ e(Pe, { className: a, strokeWidth: 1.5 }) : s.includes("wordprocessing") || s.includes("msword") ? /* @__PURE__ */ e(ae, { className: a, strokeWidth: 1.5 }) : s.includes("json") || s.includes("javascript") || s.includes("typescript") || s.includes("xml") ? /* @__PURE__ */ e(We, { className: a, strokeWidth: 1.5 }) : /* @__PURE__ */ e(ue, { className: a, strokeWidth: 1.5 }) : /* @__PURE__ */ e(ue, { className: a, strokeWidth: 1.5 });
24
+ function Te(n, a) {
25
+ return n ? n.startsWith("video/") ? /* @__PURE__ */ t(Pe, { className: a, strokeWidth: 1.5 }) : n.startsWith("audio/") ? /* @__PURE__ */ t(We, { className: a, strokeWidth: 1.5 }) : n === "application/pdf" ? /* @__PURE__ */ t(ie, { className: a, strokeWidth: 1.5 }) : n.startsWith("text/") ? /* @__PURE__ */ t(ie, { className: a, strokeWidth: 1.5 }) : n.includes("spreadsheet") || n.includes("excel") || n === "text/csv" ? /* @__PURE__ */ t($e, { className: a, strokeWidth: 1.5 }) : n.includes("wordprocessing") || n.includes("msword") ? /* @__PURE__ */ t(ie, { className: a, strokeWidth: 1.5 }) : n.includes("json") || n.includes("javascript") || n.includes("typescript") || n.includes("xml") ? /* @__PURE__ */ t(Ke, { className: a, strokeWidth: 1.5 }) : /* @__PURE__ */ t(me, { className: a, strokeWidth: 1.5 }) : /* @__PURE__ */ t(me, { className: a, strokeWidth: 1.5 });
25
26
  }
26
27
  function V({
27
- url: s,
28
+ url: n,
28
29
  type: a,
29
- filename: S,
30
+ filename: z,
30
31
  size: y = "md"
31
32
  }) {
32
33
  const L = y === "sm" ? "h-10 w-10" : y === "lg" ? "h-20 w-20" : "h-14 w-14";
33
- return $e(a) ? /* @__PURE__ */ e(
34
+ return Qe(a) ? /* @__PURE__ */ t(
34
35
  "img",
35
36
  {
36
- src: s,
37
- alt: S,
37
+ src: n,
38
+ alt: z,
38
39
  "data-file-thumb": !0,
39
- className: oe(L, "object-cover rounded shrink-0"),
40
+ className: ce(L, "object-cover rounded shrink-0"),
40
41
  loading: "lazy",
41
42
  onError: (N) => {
42
43
  N.target.style.display = "none";
43
44
  }
44
45
  }
45
- ) : /* @__PURE__ */ e("div", { className: oe(L, "flex items-center justify-center rounded bg-slate-100 shrink-0"), children: Oe(a, y === "sm" ? "h-4 w-4" : "h-6 w-6") });
46
+ ) : /* @__PURE__ */ t("div", { className: ce(L, "flex items-center justify-center rounded bg-slate-100 shrink-0"), children: Te(a, y === "sm" ? "h-4 w-4" : "h-6 w-6") });
46
47
  }
47
- function Le({
48
- selected: s,
48
+ function Re({
49
+ selected: n,
49
50
  multi: a,
50
- onSelect: S,
51
+ onSelect: z,
51
52
  onClose: y,
52
53
  getUrl: L
53
54
  }) {
54
- const N = ce(), [h, u] = w(""), { data: g = [], isLoading: p } = Z({
55
+ const N = de(), [h, u] = v(""), { data: x = [], isLoading: p } = Z({
55
56
  queryKey: ["file-browser", h],
56
57
  queryFn: () => N.request(
57
- ee("/files", {
58
+ te("/files", {
58
59
  limit: "60",
59
60
  sort: "-uploaded_on",
60
61
  fields: "id,filename_download,title,type,filesize,width,height,missing_at",
@@ -69,18 +70,18 @@ function Le({
69
70
  "Select file",
70
71
  a ? "s" : ""
71
72
  ] }),
72
- /* @__PURE__ */ e(
73
+ /* @__PURE__ */ t(
73
74
  "button",
74
75
  {
75
76
  type: "button",
76
77
  "aria-label": "Close",
77
78
  onClick: y,
78
79
  className: "text-slate-400 hover:text-slate-600",
79
- children: /* @__PURE__ */ e(I, { className: "h-3.5 w-3.5" })
80
+ children: /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" })
80
81
  }
81
82
  )
82
83
  ] }),
83
- /* @__PURE__ */ e("div", { className: "px-3 pt-2 pb-1 shrink-0", children: /* @__PURE__ */ e(
84
+ /* @__PURE__ */ t("div", { className: "px-3 pt-2 pb-1 shrink-0", children: /* @__PURE__ */ t(
84
85
  "input",
85
86
  {
86
87
  type: "text",
@@ -92,22 +93,22 @@ function Le({
92
93
  }
93
94
  ) }),
94
95
  /* @__PURE__ */ i("div", { className: "overflow-y-auto flex-1 p-3", children: [
95
- p && /* @__PURE__ */ e("div", { className: "flex justify-center py-6", children: /* @__PURE__ */ e(D, { className: "h-5 w-5 animate-spin text-slate-300" }) }),
96
- !p && g.length === 0 && /* @__PURE__ */ e("p", { className: "text-center text-[12px] text-slate-400 py-6", children: "No files found" }),
97
- !p && g.length > 0 && /* @__PURE__ */ e("div", { className: "grid grid-cols-5 gap-2", children: g.map((c) => {
98
- const v = s.includes(c.id);
96
+ p && /* @__PURE__ */ t("div", { className: "flex justify-center py-6", children: /* @__PURE__ */ t(I, { className: "h-5 w-5 animate-spin text-slate-300" }) }),
97
+ !p && x.length === 0 && /* @__PURE__ */ t("p", { className: "text-center text-[12px] text-slate-400 py-6", children: "No files found" }),
98
+ !p && x.length > 0 && /* @__PURE__ */ t("div", { className: "grid grid-cols-5 gap-2", children: x.map((c) => {
99
+ const w = n.includes(c.id);
99
100
  return /* @__PURE__ */ i(
100
101
  "button",
101
102
  {
102
103
  type: "button",
103
- onClick: () => S(c.id),
104
- className: oe(
104
+ onClick: () => z(c.id),
105
+ className: ce(
105
106
  "nvr-rise-in group flex flex-col items-center gap-1 rounded-lg p-1.5 text-left transition-colors border",
106
- v ? "border-nvr-cyan bg-nvr-cyan/5" : "border-transparent hover:border-slate-200 hover:bg-slate-50"
107
+ w ? "border-nvr-cyan bg-nvr-cyan/5" : "border-transparent hover:border-slate-200 hover:bg-slate-50"
107
108
  ),
108
109
  children: [
109
110
  /* @__PURE__ */ i("div", { className: "relative", children: [
110
- /* @__PURE__ */ e(
111
+ /* @__PURE__ */ t(
111
112
  V,
112
113
  {
113
114
  url: L(c.id),
@@ -116,14 +117,14 @@ function Le({
116
117
  size: "md"
117
118
  }
118
119
  ),
119
- v && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center rounded bg-nvr-cyan/20", children: /* @__PURE__ */ e("div", { className: "h-4 w-4 rounded-full bg-nvr-cyan flex items-center justify-center", children: /* @__PURE__ */ e(
120
+ w && /* @__PURE__ */ t("div", { className: "absolute inset-0 flex items-center justify-center rounded bg-nvr-cyan/20", children: /* @__PURE__ */ t("div", { className: "h-4 w-4 rounded-full bg-nvr-cyan flex items-center justify-center", children: /* @__PURE__ */ t(
120
121
  "svg",
121
122
  {
122
123
  className: "h-2.5 w-2.5 text-white",
123
124
  fill: "none",
124
125
  stroke: "currentColor",
125
126
  viewBox: "0 0 24 24",
126
- children: /* @__PURE__ */ e(
127
+ children: /* @__PURE__ */ t(
127
128
  "path",
128
129
  {
129
130
  strokeLinecap: "round",
@@ -135,7 +136,7 @@ function Le({
135
136
  }
136
137
  ) }) })
137
138
  ] }),
138
- /* @__PURE__ */ e(
139
+ /* @__PURE__ */ t(
139
140
  "span",
140
141
  {
141
142
  "data-file-name": !0,
@@ -151,19 +152,19 @@ function Le({
151
152
  ] })
152
153
  ] });
153
154
  }
154
- function Ye({
155
- value: s,
155
+ function Ie({
156
+ value: n,
156
157
  onChange: a,
157
- disabled: S,
158
+ disabled: z,
158
159
  allowUpload: y = !0,
159
160
  allowPick: L = !0
160
161
  }) {
161
- var z, X;
162
- const N = ce(), h = pe(), u = be(), g = re(), [p, c] = w(!1), [v, R] = w(!1), [H, E] = w(null), [m, W] = w(null), [J, K] = w(null), x = ge(null), r = !m && s ? String(s) : null, U = (d) => N.fileUrl(d), f = ye(), $ = ((z = f == null ? void 0 : f.draft) == null ? void 0 : z.id) != null ? String(f.draft.id) : null, [O, G] = Ne(!!r), _ = ke(
163
- f == null ? void 0 : f.collection,
162
+ var q, D;
163
+ const N = de(), h = fe(), u = ye(), x = oe(), [p, c] = v(!1), [w, R] = v(!1), [H, T] = v(null), [m, P] = v(null), [J, K] = v(null), f = be(null), r = !m && n ? String(n) : null, _ = (d) => N.fileUrl(d), W = Ce(), g = we(), $ = ((q = g == null ? void 0 : g.draft) == null ? void 0 : q.id) != null ? String(g.draft.id) : null, [G, U] = ke(!!r), F = _e(
164
+ g == null ? void 0 : g.collection,
164
165
  $,
165
166
  r ? [r] : [],
166
- G
167
+ U
167
168
  );
168
169
  B(() => {
169
170
  if (!m) {
@@ -174,54 +175,54 @@ function Ye({
174
175
  return K(d), () => URL.revokeObjectURL(d);
175
176
  }, [m]), B(() => {
176
177
  if (!(!u || !m))
177
- return u.register(g, async () => {
178
+ return u.register(x, async () => {
178
179
  const d = await N.upload(m);
179
- a(d.id), W(null), h.invalidateQueries({ queryKey: ["file-browser"] });
180
- }), () => u.unregister(g);
181
- }, [u, m, g, N, a, h]);
182
- const q = ve([r]), { data: n, isLoading: C } = Z({
180
+ a(d.id), P(null), h.invalidateQueries({ queryKey: ["file-browser"] });
181
+ }), () => u.unregister(x);
182
+ }, [u, m, x, N, a, h]);
183
+ const E = ve([r]), { data: s, isLoading: S } = Z({
183
184
  queryKey: ["file-meta", r],
184
- queryFn: () => N.request(ee(`/files/${r}/meta`)).then((d) => d.data ?? null),
185
+ queryFn: () => N.request(te(`/files/${r}/meta`)).then((d) => d.data ?? null),
185
186
  enabled: !!r,
186
187
  staleTime: 6e4
187
188
  });
188
- async function j(d) {
189
+ async function X(d) {
189
190
  var Y;
190
- const P = (Y = d.target.files) == null ? void 0 : Y[0];
191
- if (P)
192
- if (x.current && (x.current.value = ""), u)
193
- W(P);
191
+ const j = (Y = d.target.files) == null ? void 0 : Y[0];
192
+ if (j)
193
+ if (f.current && (f.current.value = ""), u)
194
+ P(j);
194
195
  else {
195
196
  R(!0), window.dispatchEvent(
196
- new CustomEvent("nvr:upload-state", { detail: { name: P.name, state: "start" } })
197
+ new CustomEvent("nvr:upload-state", { detail: { name: j.name, state: "start" } })
197
198
  );
198
199
  try {
199
- const se = await N.upload(P);
200
- a(se.id), h.invalidateQueries({ queryKey: ["file-browser"] });
200
+ const ne = await N.upload(j);
201
+ a(ne.id), h.invalidateQueries({ queryKey: ["file-browser"] });
201
202
  } catch {
202
203
  } finally {
203
204
  R(!1), window.dispatchEvent(
204
- new CustomEvent("nvr:upload-state", { detail: { name: P.name, state: "done" } })
205
+ new CustomEvent("nvr:upload-state", { detail: { name: j.name, state: "done" } })
205
206
  );
206
207
  }
207
208
  }
208
209
  }
209
210
  function M(d) {
210
- W(null), a(d), c(!1);
211
+ P(null), a(d), c(!1);
211
212
  }
212
- function le() {
213
- W(null), a(null);
213
+ function se() {
214
+ P(null), a(null);
214
215
  }
215
216
  const b = !!m;
216
217
  return /* @__PURE__ */ i("div", { className: "relative", children: [
217
- H && /* @__PURE__ */ e(we, { file: H, onClose: () => E(null) }),
218
+ H && /* @__PURE__ */ t(Ne, { file: H, onClose: () => T(null) }),
218
219
  b || !!r ? /* @__PURE__ */ i(
219
220
  "div",
220
221
  {
221
- ref: O,
222
+ ref: G,
222
223
  className: "flex items-center gap-2 rounded-lg border border-slate-200 p-2 bg-slate-50",
223
224
  children: [
224
- b ? /* @__PURE__ */ e(
225
+ b ? /* @__PURE__ */ t(
225
226
  V,
226
227
  {
227
228
  url: J ?? "",
@@ -229,25 +230,25 @@ function Ye({
229
230
  filename: m.name,
230
231
  size: "sm"
231
232
  }
232
- ) : C ? /* @__PURE__ */ e("div", { className: "h-10 w-10 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] animate-pulse" }) : /* @__PURE__ */ e(
233
+ ) : S ? /* @__PURE__ */ t("div", { className: "h-10 w-10 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] animate-pulse" }) : /* @__PURE__ */ t(
233
234
  "button",
234
235
  {
235
236
  type: "button",
236
237
  title: "Preview",
237
- onClick: () => E({
238
+ onClick: () => T({
238
239
  id: r,
239
- url: U(r),
240
- name: (n == null ? void 0 : n.title) || (n == null ? void 0 : n.filename_download) || r,
241
- type: (n == null ? void 0 : n.type) ?? null,
242
- size: (n == null ? void 0 : n.filesize) ?? null
240
+ url: _(r),
241
+ name: (s == null ? void 0 : s.title) || (s == null ? void 0 : s.filename_download) || r,
242
+ type: (s == null ? void 0 : s.type) ?? null,
243
+ size: (s == null ? void 0 : s.filesize) ?? null
243
244
  }),
244
245
  className: "shrink-0 cursor-zoom-in",
245
- children: /* @__PURE__ */ e(
246
+ children: /* @__PURE__ */ t(
246
247
  V,
247
248
  {
248
- url: U(r),
249
- type: (n == null ? void 0 : n.type) ?? null,
250
- filename: (n == null ? void 0 : n.filename_download) ?? "",
249
+ url: _(r),
250
+ type: (s == null ? void 0 : s.type) ?? null,
251
+ filename: (s == null ? void 0 : s.filename_download) ?? "",
251
252
  size: "sm"
252
253
  }
253
254
  )
@@ -255,9 +256,9 @@ function Ye({
255
256
  ),
256
257
  /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
257
258
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
258
- b && /* @__PURE__ */ e(fe, { className: "h-3 w-3 text-amber-400 shrink-0" }),
259
- /* @__PURE__ */ e("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: b ? m.name : (n == null ? void 0 : n.title) || (n == null ? void 0 : n.filename_download) || r }),
260
- !b && (q.verdict(r) ?? !!(n != null && n.missing_at)) && /* @__PURE__ */ e(
259
+ b && /* @__PURE__ */ t(xe, { className: "h-3 w-3 text-amber-400 shrink-0" }),
260
+ /* @__PURE__ */ t("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: b ? m.name : (s == null ? void 0 : s.title) || (s == null ? void 0 : s.filename_download) || r }),
261
+ !b && (E.verdict(r) ?? !!(s != null && s.missing_at)) && /* @__PURE__ */ t(
261
262
  "span",
262
263
  {
263
264
  className: "shrink-0 rounded bg-red-500/10 px-1.5 py-0.5 text-[9.5px] font-semibold uppercase tracking-wide text-red-600 dark:text-red-400",
@@ -266,41 +267,42 @@ function Ye({
266
267
  }
267
268
  )
268
269
  ] }),
269
- /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: b ? /* @__PURE__ */ i(A, { children: [
270
- m.type && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: m.type }),
271
- /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: te(m.size) }),
272
- /* @__PURE__ */ e("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
270
+ /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: b ? /* @__PURE__ */ i(A, { children: [
271
+ m.type && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: m.type }),
272
+ /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: le(m.size) }),
273
+ /* @__PURE__ */ t("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
273
274
  ] }) : /* @__PURE__ */ i(A, { children: [
274
- (n == null ? void 0 : n.type) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: n.type }),
275
- (n == null ? void 0 : n.filesize) != null && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: te(n.filesize) }),
276
- (n == null ? void 0 : n.uploaded_on) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: Fe(n.uploaded_on) }),
277
- (n == null ? void 0 : n.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500", children: [
275
+ (s == null ? void 0 : s.type) && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: s.type }),
276
+ (s == null ? void 0 : s.filesize) != null && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: le(s.filesize) }),
277
+ (s == null ? void 0 : s.uploaded_on) && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: Le(s.uploaded_on) }),
278
+ (s == null ? void 0 : s.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500", children: [
278
279
  "by ",
279
- n.uploaded_by_name
280
+ s.uploaded_by_name
280
281
  ] })
281
282
  ] }) })
282
283
  ] }),
283
- !b && r && /* @__PURE__ */ e(
284
- _e,
284
+ !b && r && /* @__PURE__ */ t(
285
+ Fe,
285
286
  {
286
287
  fileId: r,
287
- uses: (X = _.data) == null ? void 0 : X[r],
288
- loading: _.isLoading,
289
- collection: f == null ? void 0 : f.collection,
288
+ uses: (D = F.data) == null ? void 0 : D[r],
289
+ loading: F.isLoading,
290
+ collection: g == null ? void 0 : g.collection,
290
291
  itemId: $
291
292
  }
292
293
  ),
293
- !b && r && /* @__PURE__ */ e(
294
+ !b && r && /* @__PURE__ */ t(
294
295
  "a",
295
296
  {
296
- href: `${U(r)}?download=1`,
297
+ href: `${_(r)}?download=1`,
298
+ onClick: W(`${_(r)}?download=1`, s == null ? void 0 : s.filename_download),
297
299
  title: "Download",
298
300
  className: "shrink-0 text-slate-400 hover:text-nvr-cyan p-0.5",
299
- children: /* @__PURE__ */ e(xe, { className: "h-3.5 w-3.5" })
301
+ children: /* @__PURE__ */ t(ge, { className: "h-3.5 w-3.5" })
300
302
  }
301
303
  ),
302
- !S && /* @__PURE__ */ i("div", { className: "flex items-center gap-1 shrink-0", children: [
303
- L && /* @__PURE__ */ e(
304
+ !z && /* @__PURE__ */ i("div", { className: "flex items-center gap-1 shrink-0", children: [
305
+ L && /* @__PURE__ */ t(
304
306
  "button",
305
307
  {
306
308
  type: "button",
@@ -316,278 +318,278 @@ function Ye({
316
318
  type: "button",
317
319
  onClick: () => {
318
320
  var d;
319
- return (d = x.current) == null ? void 0 : d.click();
321
+ return (d = f.current) == null ? void 0 : d.click();
320
322
  },
321
- disabled: v,
323
+ disabled: w,
322
324
  className: "h-6 px-2 rounded border border-slate-200 text-[11px] text-slate-600 hover:border-slate-400 disabled:opacity-40 flex items-center gap-1",
323
325
  children: [
324
- v ? /* @__PURE__ */ e(D, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(ie, { className: "h-3 w-3" }),
326
+ w ? /* @__PURE__ */ t(I, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(re, { className: "h-3 w-3" }),
325
327
  "Upload"
326
328
  ]
327
329
  }
328
330
  ),
329
- /* @__PURE__ */ e("input", { ref: x, type: "file", className: "hidden", onChange: j })
331
+ /* @__PURE__ */ t("input", { ref: f, type: "file", className: "hidden", onChange: X })
330
332
  ] }),
331
- /* @__PURE__ */ e(
333
+ /* @__PURE__ */ t(
332
334
  "button",
333
335
  {
334
336
  type: "button",
335
337
  "aria-label": "Remove file",
336
- onClick: le,
338
+ onClick: se,
337
339
  className: "text-slate-300 hover:text-red-400 p-0.5",
338
- children: /* @__PURE__ */ e(I, { className: "h-3.5 w-3.5" })
340
+ children: /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" })
339
341
  }
340
342
  )
341
343
  ] })
342
344
  ]
343
345
  }
344
346
  ) : /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
345
- L && /* @__PURE__ */ e(
347
+ L && /* @__PURE__ */ t(
346
348
  "button",
347
349
  {
348
350
  type: "button",
349
- disabled: S,
351
+ disabled: z,
350
352
  onClick: () => c(!0),
351
353
  className: "flex h-9 flex-1 items-center gap-2 rounded-md border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 disabled:opacity-40 transition-colors",
352
354
  children: "Select file…"
353
355
  }
354
356
  ),
355
- y && !S && /* @__PURE__ */ i(A, { children: [
357
+ y && !z && /* @__PURE__ */ i(A, { children: [
356
358
  /* @__PURE__ */ i(
357
359
  "button",
358
360
  {
359
361
  type: "button",
360
362
  onClick: () => {
361
363
  var d;
362
- return (d = x.current) == null ? void 0 : d.click();
364
+ return (d = f.current) == null ? void 0 : d.click();
363
365
  },
364
- disabled: v,
366
+ disabled: w,
365
367
  className: "flex h-9 items-center gap-1.5 rounded-md border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 disabled:opacity-40 transition-colors",
366
368
  children: [
367
- v ? /* @__PURE__ */ e(D, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(ie, { className: "h-3.5 w-3.5" }),
369
+ w ? /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(re, { className: "h-3.5 w-3.5" }),
368
370
  "Upload"
369
371
  ]
370
372
  }
371
373
  ),
372
- /* @__PURE__ */ e("input", { ref: x, type: "file", className: "hidden", onChange: j })
374
+ /* @__PURE__ */ t("input", { ref: f, type: "file", className: "hidden", onChange: X })
373
375
  ] })
374
376
  ] }),
375
- p && /* @__PURE__ */ e(
377
+ p && /* @__PURE__ */ t(
376
378
  "div",
377
379
  {
378
380
  className: "absolute z-50 mt-1 rounded-lg border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card",
379
381
  style: { minWidth: 480 },
380
- children: /* @__PURE__ */ e(
381
- Le,
382
+ children: /* @__PURE__ */ t(
383
+ Re,
382
384
  {
383
385
  selected: r ? [r] : [],
384
386
  multi: !1,
385
387
  onSelect: M,
386
388
  onClose: () => c(!1),
387
- getUrl: U
389
+ getUrl: _
388
390
  }
389
391
  )
390
392
  }
391
393
  )
392
394
  ] });
393
395
  }
394
- function Ze({
395
- relation: s,
396
+ function et({
397
+ relation: n,
396
398
  parentId: a,
397
- allRelations: S,
399
+ allRelations: z,
398
400
  disabled: y,
399
401
  allowUpload: L = !0,
400
402
  allowPick: N = !0,
401
403
  pendingSave: h = !1
402
404
  }) {
403
- const u = ce(), g = pe(), p = be(), c = re(), v = re(), R = Ke(), [H, E] = w(!1), [m, W] = w(!1), [J, K] = w(null), [x, r] = w([]), U = ge(null), [f, $] = w([]), [O, G] = w(/* @__PURE__ */ new Set()), _ = s.junction_field ?? "", q = s.many_field ?? "", n = s.one_field ?? `${s.many_collection}.${_}`, C = a === "new", j = (l) => u.fileUrl(l);
405
+ const u = de(), x = fe(), p = ye(), c = oe(), w = oe(), R = Oe(), [H, T] = v(!1), [m, P] = v(!1), [J, K] = v(null), [f, r] = v([]), _ = be(null), [W, g] = v([]), [$, G] = v(/* @__PURE__ */ new Set()), U = n.junction_field ?? "", F = n.many_field ?? "", E = n.one_field ?? `${n.many_collection}.${U}`, s = a === "new", S = (l) => u.fileUrl(l), X = Ce();
404
406
  B(() => () => {
405
- r((l) => (l.forEach((t) => URL.revokeObjectURL(t.url)), []));
407
+ r((l) => (l.forEach((e) => URL.revokeObjectURL(e.url)), []));
406
408
  }, []), B(() => {
407
- if (!p || !x.length || h) return;
408
- const l = x;
409
+ if (!p || !f.length || h) return;
410
+ const l = f;
409
411
  return p.register(c, async () => {
410
- for (const t of l) {
411
- const o = await u.upload(t.file);
412
- URL.revokeObjectURL(t.url), await ne(o.id);
412
+ for (const e of l) {
413
+ const o = await u.upload(e.file);
414
+ URL.revokeObjectURL(e.url), await ae(o.id);
413
415
  }
414
- r([]), g.invalidateQueries({ queryKey: ["file-browser"] });
416
+ r([]), x.invalidateQueries({ queryKey: ["file-browser"] });
415
417
  }), () => p.unregister(c);
416
- }, [p, x, c, h]), B(() => {
418
+ }, [p, f, c, h]), B(() => {
417
419
  if (!p || !h) return;
418
- if (!(f.length > 0 || O.size > 0 || x.length > 0)) {
419
- p.unregister(v);
420
+ if (!(W.length > 0 || $.size > 0 || f.length > 0)) {
421
+ p.unregister(w);
420
422
  return;
421
423
  }
422
- const t = f, o = new Set(O), F = x;
423
- return p.register(v, async () => {
424
- const de = [];
425
- for (const Q of F) {
426
- const T = await u.upload(Q.file);
427
- URL.revokeObjectURL(Q.url), de.push(T.id);
424
+ const e = W, o = new Set($), C = f;
425
+ return p.register(w, async () => {
426
+ const ue = [];
427
+ for (const O of C) {
428
+ const Q = await u.upload(O.file);
429
+ URL.revokeObjectURL(O.url), ue.push(Q.id);
428
430
  }
429
- for (const Q of [...t, ...de])
431
+ for (const O of [...e, ...ue])
430
432
  await u.request(
431
- me(`/items/${s.many_collection}`, {
432
- [q]: a,
433
- [_]: Q
433
+ he(`/items/${n.many_collection}`, {
434
+ [F]: a,
435
+ [U]: O
434
436
  })
435
437
  );
436
- for (const Q of o) {
437
- const T = M.find((Ce) => String(Ce[_]) === Q);
438
- T != null && T.id && await u.request(he(`/items/${s.many_collection}/${T.id}`));
438
+ for (const O of o) {
439
+ const Q = M.find((Se) => String(Se[U]) === O);
440
+ Q != null && Q.id && await u.request(pe(`/items/${n.many_collection}/${Q.id}`));
439
441
  }
440
- $([]), G(/* @__PURE__ */ new Set()), r([]), g.invalidateQueries({
441
- queryKey: ["m2m-items", s.many_collection, q, a]
442
- }), g.invalidateQueries({ queryKey: ["file-browser"] });
443
- }), () => p.unregister(v);
444
- }, [p, h, f, O, x, v]);
442
+ g([]), G(/* @__PURE__ */ new Set()), r([]), x.invalidateQueries({
443
+ queryKey: ["m2m-items", n.many_collection, F, a]
444
+ }), x.invalidateQueries({ queryKey: ["file-browser"] });
445
+ }), () => p.unregister(w);
446
+ }, [p, h, W, $, f, w]);
445
447
  const { data: M = [] } = Z({
446
- queryKey: ["m2m-items", s.many_collection, q, a],
448
+ queryKey: ["m2m-items", n.many_collection, F, a],
447
449
  queryFn: () => u.request(
448
- ee(`/items/${s.many_collection}`, {
449
- filter: JSON.stringify({ [q]: { _eq: a } }),
450
+ te(`/items/${n.many_collection}`, {
451
+ filter: JSON.stringify({ [F]: { _eq: a } }),
450
452
  limit: "200",
451
- fields: `id,${_}`
453
+ fields: `id,${U}`
452
454
  })
453
455
  ).then((l) => l.data ?? []),
454
- enabled: !!a && !C,
456
+ enabled: !!a && !s,
455
457
  staleTime: 3e4
456
- }), le = C && R ? R.getStagedLinks(n) : [], b = M.map((l) => String(l[_])), k = C ? le : h ? [...b.filter((l) => !O.has(l)), ...f] : b, z = ye(), [X, d] = Ne(b.length > 0), P = ke(
457
- z == null ? void 0 : z.collection,
458
- C ? null : a,
458
+ }), se = s && R ? R.getStagedLinks(E) : [], b = M.map((l) => String(l[U])), k = s ? se : h ? [...b.filter((l) => !$.has(l)), ...W] : b, q = we(), [D, d] = ke(b.length > 0), j = _e(
459
+ q == null ? void 0 : q.collection,
460
+ s ? null : a,
459
461
  b,
460
462
  d
461
- ), Y = ve(k), { data: se = {} } = Z({
463
+ ), Y = ve(k), { data: ne = {} } = Z({
462
464
  queryKey: ["files-meta", ...k.sort()],
463
465
  queryFn: async () => {
464
466
  if (!k.length) return {};
465
467
  const l = await u.request(
466
- ee("/files", {
468
+ te("/files", {
467
469
  filter: JSON.stringify({ id: { _in: k } }),
468
470
  limit: String(k.length),
469
471
  fields: "id,filename_download,title,type,filesize,uploaded_on,uploaded_by_name,missing_at"
470
472
  })
471
- ).then((o) => o.data ?? []), t = {};
472
- for (const o of l) t[o.id] = o;
473
- return t;
473
+ ).then((o) => o.data ?? []), e = {};
474
+ for (const o of l) e[o.id] = o;
475
+ return e;
474
476
  },
475
477
  enabled: k.length > 0,
476
478
  staleTime: 6e4
477
479
  });
478
- async function Re(l) {
479
- if (C && R) {
480
- R.unstageLink(n, l);
480
+ async function Ue(l) {
481
+ if (s && R) {
482
+ R.unstageLink(E, l);
481
483
  return;
482
484
  }
483
485
  if (h) {
484
- f.includes(l) ? $((o) => o.filter((F) => F !== l)) : G((o) => /* @__PURE__ */ new Set([...o, l]));
486
+ W.includes(l) ? g((o) => o.filter((C) => C !== l)) : G((o) => /* @__PURE__ */ new Set([...o, l]));
485
487
  return;
486
488
  }
487
- const t = M.find((o) => String(o[_]) === l);
488
- t != null && t.id && (await u.request(he(`/items/${s.many_collection}/${t.id}`)), g.invalidateQueries({ queryKey: ["m2m-items", s.many_collection, q, a] }));
489
+ const e = M.find((o) => String(o[U]) === l);
490
+ e != null && e.id && (await u.request(pe(`/items/${n.many_collection}/${e.id}`)), x.invalidateQueries({ queryKey: ["m2m-items", n.many_collection, F, a] }));
489
491
  }
490
- async function ne(l) {
492
+ async function ae(l) {
491
493
  if (!k.includes(l)) {
492
- if (C && R) {
493
- R.stageLink(n, l);
494
+ if (s && R) {
495
+ R.stageLink(E, l);
494
496
  return;
495
497
  }
496
498
  if (h) {
497
- $((t) => t.includes(l) ? t : [...t, l]);
499
+ g((e) => e.includes(l) ? e : [...e, l]);
498
500
  return;
499
501
  }
500
502
  await u.request(
501
- me(`/items/${s.many_collection}`, { [q]: a, [_]: l })
502
- ), g.invalidateQueries({ queryKey: ["m2m-items", s.many_collection, q, a] });
503
+ he(`/items/${n.many_collection}`, { [F]: a, [U]: l })
504
+ ), x.invalidateQueries({ queryKey: ["m2m-items", n.many_collection, F, a] });
503
505
  }
504
506
  }
505
- function Ue(l) {
506
- URL.revokeObjectURL(l), r((t) => t.filter((o) => o.url !== l));
507
+ function qe(l) {
508
+ URL.revokeObjectURL(l), r((e) => e.filter((o) => o.url !== l));
507
509
  }
508
- async function qe(l) {
509
- const t = Array.from(l.target.files ?? []);
510
- if (t.length)
511
- if (U.current && (U.current.value = ""), p) {
512
- const o = t.map((F) => ({ file: F, url: URL.createObjectURL(F) }));
513
- r((F) => [...F, ...o]);
510
+ async function ze(l) {
511
+ const e = Array.from(l.target.files ?? []);
512
+ if (e.length)
513
+ if (_.current && (_.current.value = ""), p) {
514
+ const o = e.map((C) => ({ file: C, url: URL.createObjectURL(C) }));
515
+ r((C) => [...C, ...o]);
514
516
  } else {
515
- W(!0);
517
+ P(!0);
516
518
  try {
517
- for (const o of t) {
518
- const F = await u.upload(o);
519
- await ne(F.id);
519
+ for (const o of e) {
520
+ const C = await u.upload(o);
521
+ await ae(C.id);
520
522
  }
521
- g.invalidateQueries({ queryKey: ["file-browser"] });
523
+ x.invalidateQueries({ queryKey: ["file-browser"] });
522
524
  } catch {
523
525
  } finally {
524
- W(!1);
526
+ P(!1);
525
527
  }
526
528
  }
527
529
  }
528
530
  return /* @__PURE__ */ i("div", { className: "space-y-2", children: [
529
- J && /* @__PURE__ */ e(we, { file: J, onClose: () => K(null) }),
530
- (k.length > 0 || x.length > 0) && /* @__PURE__ */ i("div", { ref: X, className: "flex flex-col gap-1.5", children: [
531
+ J && /* @__PURE__ */ t(Ne, { file: J, onClose: () => K(null) }),
532
+ (k.length > 0 || f.length > 0) && /* @__PURE__ */ i("div", { ref: D, className: "flex flex-col gap-1.5", children: [
531
533
  k.map((l) => {
532
534
  var o;
533
- const t = se[l];
535
+ const e = ne[l];
534
536
  return /* @__PURE__ */ i(
535
537
  "div",
536
538
  {
537
539
  className: "flex items-center gap-2 rounded-lg border border-slate-200 p-2 bg-slate-50",
538
540
  children: [
539
- /* @__PURE__ */ e(
541
+ /* @__PURE__ */ t(
540
542
  "button",
541
543
  {
542
544
  type: "button",
543
545
  title: "Preview",
544
546
  onClick: () => K({
545
547
  id: l,
546
- url: j(l),
547
- name: (t == null ? void 0 : t.title) || (t == null ? void 0 : t.filename_download) || l,
548
- type: (t == null ? void 0 : t.type) ?? null,
549
- size: (t == null ? void 0 : t.filesize) ?? null
548
+ url: S(l),
549
+ name: (e == null ? void 0 : e.title) || (e == null ? void 0 : e.filename_download) || l,
550
+ type: (e == null ? void 0 : e.type) ?? null,
551
+ size: (e == null ? void 0 : e.filesize) ?? null
550
552
  }),
551
553
  className: "shrink-0 cursor-zoom-in",
552
- children: /* @__PURE__ */ e(
554
+ children: /* @__PURE__ */ t(
553
555
  V,
554
556
  {
555
- url: j(l),
556
- type: (t == null ? void 0 : t.type) ?? null,
557
- filename: (t == null ? void 0 : t.filename_download) ?? l,
557
+ url: S(l),
558
+ type: (e == null ? void 0 : e.type) ?? null,
559
+ filename: (e == null ? void 0 : e.filename_download) ?? l,
558
560
  size: "sm"
559
561
  }
560
562
  )
561
563
  }
562
564
  ),
563
565
  /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
564
- /* @__PURE__ */ e(
566
+ /* @__PURE__ */ t(
565
567
  "button",
566
568
  {
567
569
  type: "button",
568
570
  onClick: () => K({
569
571
  id: l,
570
- url: j(l),
571
- name: (t == null ? void 0 : t.title) || (t == null ? void 0 : t.filename_download) || l,
572
- type: (t == null ? void 0 : t.type) ?? null,
573
- size: (t == null ? void 0 : t.filesize) ?? null
572
+ url: S(l),
573
+ name: (e == null ? void 0 : e.title) || (e == null ? void 0 : e.filename_download) || l,
574
+ type: (e == null ? void 0 : e.type) ?? null,
575
+ size: (e == null ? void 0 : e.filesize) ?? null
574
576
  }),
575
577
  "data-file-name": !0,
576
578
  className: "block w-full truncate text-left text-[12px] font-medium text-slate-700 hover:underline",
577
- children: (t == null ? void 0 : t.title) || (t == null ? void 0 : t.filename_download) || l
579
+ children: (e == null ? void 0 : e.title) || (e == null ? void 0 : e.filename_download) || l
578
580
  }
579
581
  ),
580
582
  /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: [
581
- (t == null ? void 0 : t.type) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: t.type }),
582
- (t == null ? void 0 : t.filesize) != null && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: te(t.filesize) }),
583
- (t == null ? void 0 : t.uploaded_on) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: Fe(t.uploaded_on) }),
584
- (t == null ? void 0 : t.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500", children: [
583
+ (e == null ? void 0 : e.type) && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: e.type }),
584
+ (e == null ? void 0 : e.filesize) != null && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: le(e.filesize) }),
585
+ (e == null ? void 0 : e.uploaded_on) && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: Le(e.uploaded_on) }),
586
+ (e == null ? void 0 : e.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500", children: [
585
587
  "by ",
586
- t.uploaded_by_name
588
+ e.uploaded_by_name
587
589
  ] })
588
590
  ] })
589
591
  ] }),
590
- (Y.verdict(l) ?? !!(t != null && t.missing_at)) && /* @__PURE__ */ e(
592
+ (Y.verdict(l) ?? !!(e != null && e.missing_at)) && /* @__PURE__ */ t(
591
593
  "span",
592
594
  {
593
595
  className: "shrink-0 self-center rounded bg-red-500/10 px-1.5 py-0.5 text-[9.5px] font-semibold uppercase tracking-wide text-red-600 dark:text-red-400",
@@ -595,33 +597,34 @@ function Ze({
595
597
  children: "file missing"
596
598
  }
597
599
  ),
598
- !C && b.includes(l) && /* @__PURE__ */ e(
599
- _e,
600
+ !s && b.includes(l) && /* @__PURE__ */ t(
601
+ Fe,
600
602
  {
601
603
  fileId: l,
602
- uses: (o = P.data) == null ? void 0 : o[l],
603
- loading: P.isLoading,
604
- collection: z == null ? void 0 : z.collection,
604
+ uses: (o = j.data) == null ? void 0 : o[l],
605
+ loading: j.isLoading,
606
+ collection: q == null ? void 0 : q.collection,
605
607
  itemId: a
606
608
  }
607
609
  ),
608
- /* @__PURE__ */ e(
610
+ /* @__PURE__ */ t(
609
611
  "a",
610
612
  {
611
- href: `${j(l)}?download=1`,
613
+ href: `${S(l)}?download=1`,
614
+ onClick: X(`${S(l)}?download=1`, e == null ? void 0 : e.filename_download),
612
615
  title: "Download",
613
616
  className: "shrink-0 text-slate-400 hover:text-nvr-cyan p-0.5",
614
- children: /* @__PURE__ */ e(xe, { className: "h-3.5 w-3.5" })
617
+ children: /* @__PURE__ */ t(ge, { className: "h-3.5 w-3.5" })
615
618
  }
616
619
  ),
617
- !y && /* @__PURE__ */ e(
620
+ !y && /* @__PURE__ */ t(
618
621
  "button",
619
622
  {
620
623
  type: "button",
621
624
  "aria-label": "Remove file",
622
- onClick: () => Re(l),
625
+ onClick: () => Ue(l),
623
626
  className: "text-slate-300 hover:text-red-400 p-0.5 shrink-0",
624
- children: /* @__PURE__ */ e(I, { className: "h-3.5 w-3.5" })
627
+ children: /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" })
625
628
  }
626
629
  )
627
630
  ]
@@ -629,12 +632,12 @@ function Ze({
629
632
  l
630
633
  );
631
634
  }),
632
- x.map((l) => /* @__PURE__ */ i(
635
+ f.map((l) => /* @__PURE__ */ i(
633
636
  "div",
634
637
  {
635
638
  className: "flex items-center gap-2 rounded-lg border border-amber-200 p-2 bg-amber-50/50",
636
639
  children: [
637
- /* @__PURE__ */ e(
640
+ /* @__PURE__ */ t(
638
641
  V,
639
642
  {
640
643
  url: l.url,
@@ -645,23 +648,23 @@ function Ze({
645
648
  ),
646
649
  /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
647
650
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
648
- /* @__PURE__ */ e(fe, { className: "h-3 w-3 text-amber-400 shrink-0" }),
649
- /* @__PURE__ */ e("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: l.file.name })
651
+ /* @__PURE__ */ t(xe, { className: "h-3 w-3 text-amber-400 shrink-0" }),
652
+ /* @__PURE__ */ t("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: l.file.name })
650
653
  ] }),
651
654
  /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: [
652
- l.file.type && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: l.file.type }),
653
- /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: te(l.file.size) }),
654
- /* @__PURE__ */ e("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
655
+ l.file.type && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: l.file.type }),
656
+ /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: le(l.file.size) }),
657
+ /* @__PURE__ */ t("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
655
658
  ] })
656
659
  ] }),
657
- !y && /* @__PURE__ */ e(
660
+ !y && /* @__PURE__ */ t(
658
661
  "button",
659
662
  {
660
663
  type: "button",
661
664
  "aria-label": "Remove file",
662
- onClick: () => Ue(l.url),
665
+ onClick: () => qe(l.url),
663
666
  className: "text-slate-300 hover:text-red-400 p-0.5 shrink-0",
664
- children: /* @__PURE__ */ e(I, { className: "h-3.5 w-3.5" })
667
+ children: /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" })
665
668
  }
666
669
  )
667
670
  ]
@@ -675,27 +678,27 @@ function Ze({
675
678
  "button",
676
679
  {
677
680
  type: "button",
678
- onClick: () => E((l) => !l),
681
+ onClick: () => T((l) => !l),
679
682
  className: "flex h-8 items-center gap-1.5 rounded border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 transition-colors",
680
683
  children: [
681
- /* @__PURE__ */ e(ze, { className: "h-3.5 w-3.5" }),
684
+ /* @__PURE__ */ t(je, { className: "h-3.5 w-3.5" }),
682
685
  "Add existing…"
683
686
  ]
684
687
  }
685
688
  ),
686
- H && /* @__PURE__ */ e(
689
+ H && /* @__PURE__ */ t(
687
690
  "div",
688
691
  {
689
692
  className: "absolute z-50 mt-1 rounded-lg border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card",
690
693
  style: { minWidth: 480 },
691
- children: /* @__PURE__ */ e(
692
- Le,
694
+ children: /* @__PURE__ */ t(
695
+ Re,
693
696
  {
694
697
  selected: k,
695
698
  multi: !0,
696
- onSelect: (l) => ne(l),
697
- onClose: () => E(!1),
698
- getUrl: j
699
+ onSelect: (l) => ae(l),
700
+ onClose: () => T(!1),
701
+ getUrl: S
699
702
  }
700
703
  )
701
704
  }
@@ -708,24 +711,24 @@ function Ze({
708
711
  type: "button",
709
712
  onClick: () => {
710
713
  var l;
711
- return (l = U.current) == null ? void 0 : l.click();
714
+ return (l = _.current) == null ? void 0 : l.click();
712
715
  },
713
716
  disabled: m,
714
717
  className: "flex h-8 items-center gap-1.5 rounded border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 disabled:opacity-40 transition-colors",
715
718
  children: [
716
- m ? /* @__PURE__ */ e(D, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(ie, { className: "h-3.5 w-3.5" }),
719
+ m ? /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(re, { className: "h-3.5 w-3.5" }),
717
720
  "Upload…"
718
721
  ]
719
722
  }
720
723
  ),
721
- /* @__PURE__ */ e(
724
+ /* @__PURE__ */ t(
722
725
  "input",
723
726
  {
724
- ref: U,
727
+ ref: _,
725
728
  type: "file",
726
729
  multiple: !0,
727
730
  className: "hidden",
728
- onChange: qe
731
+ onChange: ze
729
732
  }
730
733
  )
731
734
  ] })
@@ -733,6 +736,6 @@ function Ze({
733
736
  ] });
734
737
  }
735
738
  export {
736
- Ze as FileM2MField,
737
- Ye as FilePickerField
739
+ et as FileM2MField,
740
+ Ie as FilePickerField
738
741
  };