@nivaro/react 0.3.68 → 0.3.70

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