@nivaro/react 0.3.67 → 0.3.69

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