@nivaro/react 0.3.117 → 0.3.119

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 (138) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +136 -14
  4. package/dist/index.js +488 -485
  5. package/dist/shared/components/ActivityEntry.js +130 -125
  6. package/dist/shared/components/AgentPresenceChip.js +36 -26
  7. package/dist/shared/components/CellCopyLayer.js +50 -45
  8. package/dist/shared/components/CollectionBrowserView.js +3757 -3695
  9. package/dist/shared/components/FilePreviewLightbox.js +96 -58
  10. package/dist/shared/components/InStep.js +18 -17
  11. package/dist/shared/components/ItemEditForm.js +4451 -4385
  12. package/dist/shared/components/JobsTray.js +8 -8
  13. package/dist/shared/components/LiveNewMatchesPill.js +21 -14
  14. package/dist/shared/components/LiveOffNote.js +3 -2
  15. package/dist/shared/components/LiveRowMark.js +53 -23
  16. package/dist/shared/components/LiveTraceView.js +162 -123
  17. package/dist/shared/components/MyWorkView.js +320 -299
  18. package/dist/shared/components/NotificationBell.js +14 -14
  19. package/dist/shared/components/OverflowRail.js +1 -1
  20. package/dist/shared/components/PageRenderer.js +120 -116
  21. package/dist/shared/components/ProfileView.js +203 -202
  22. package/dist/shared/components/RealtimeStatusBanner.js +31 -29
  23. package/dist/shared/components/RecordDrilldownSheet.js +7 -7
  24. package/dist/shared/components/RecordHoverCard.js +102 -84
  25. package/dist/shared/components/RecordReadView.js +146 -146
  26. package/dist/shared/components/ScreenRefreshButton.js +34 -32
  27. package/dist/shared/components/TipLayer.js +65 -58
  28. package/dist/shared/components/WidgetImageMenu.js +83 -43
  29. package/dist/shared/components/activity/RecordActivityStream.js +175 -173
  30. package/dist/shared/components/bulk/BulkSelectionNotices.js +142 -119
  31. package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +158 -143
  32. package/dist/shared/components/change-proposals/ProposeChangeButton.js +17 -11
  33. package/dist/shared/components/change-proposals/ProposeChangeDialog.js +201 -173
  34. package/dist/shared/components/chat/ChatAnalyticsView.js +27 -27
  35. package/dist/shared/components/chat/HuddleAnalyticsTab.js +17 -17
  36. package/dist/shared/components/collections-directory/CollectionsToolbar.js +39 -41
  37. package/dist/shared/components/collections-directory/page-model.js +72 -67
  38. package/dist/shared/components/integrations/RecordIntegrationPreview.js +48 -56
  39. package/dist/shared/components/integrations/SendStatus.js +65 -59
  40. package/dist/shared/components/integrations/console/ReadyToSendView.js +275 -209
  41. package/dist/shared/components/integrations/console/SignalCard.js +237 -230
  42. package/dist/shared/components/item-edit/CatalogPickerField.js +227 -205
  43. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +135 -94
  44. package/dist/shared/components/item-edit/CloneDialog.js +191 -161
  45. package/dist/shared/components/item-edit/DerivedCauseNote.js +44 -30
  46. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +153 -134
  47. package/dist/shared/components/item-edit/FieldComments.js +88 -85
  48. package/dist/shared/components/item-edit/FieldPointer.js +82 -67
  49. package/dist/shared/components/item-edit/FieldRow.js +106 -100
  50. package/dist/shared/components/item-edit/FieldSourceBadge.js +58 -56
  51. package/dist/shared/components/item-edit/FilePickerField.js +452 -387
  52. package/dist/shared/components/item-edit/HeaderSummaryChip.js +78 -56
  53. package/dist/shared/components/item-edit/HeaderTools.js +245 -141
  54. package/dist/shared/components/item-edit/InlineTableField.js +1242 -1218
  55. package/dist/shared/components/item-edit/ListNeighborNav.js +47 -50
  56. package/dist/shared/components/item-edit/LiveTraceSheet.js +15 -10
  57. package/dist/shared/components/item-edit/MembershipSetField.js +285 -254
  58. package/dist/shared/components/item-edit/OutboxReviewTray.js +155 -144
  59. package/dist/shared/components/item-edit/QueueReturnChip.js +15 -36
  60. package/dist/shared/components/item-edit/RecalcValue.js +57 -32
  61. package/dist/shared/components/item-edit/RecordHelpChip.js +15 -16
  62. package/dist/shared/components/item-edit/RecordLiveSync.js +283 -231
  63. package/dist/shared/components/item-edit/RelationCombobox.js +439 -393
  64. package/dist/shared/components/item-edit/RemoteChangeUi.js +292 -224
  65. package/dist/shared/components/item-edit/RemoteUploads.js +26 -20
  66. package/dist/shared/components/item-edit/RemovedLineNote.js +77 -67
  67. package/dist/shared/components/item-edit/RichTextEditorImpl.js +184 -179
  68. package/dist/shared/components/item-edit/ScheduledChangeChip.js +168 -134
  69. package/dist/shared/components/item-edit/SectionPresence.js +18 -10
  70. package/dist/shared/components/item-edit/SplitLinesButton.js +163 -139
  71. package/dist/shared/components/item-edit/UserChip.js +1 -1
  72. package/dist/shared/components/item-edit/addendum-view.js +6 -0
  73. package/dist/shared/components/item-edit/file-live.js +69 -54
  74. package/dist/shared/components/item-edit/layout-switch.js +98 -89
  75. package/dist/shared/components/item-edit/partner-needs.js +12 -12
  76. package/dist/shared/components/item-edit/removed-line.js +31 -25
  77. package/dist/shared/components/layout-editor/pickers/field-picker.js +151 -130
  78. package/dist/shared/components/list/ListViewers.js +46 -35
  79. package/dist/shared/components/notifications/NotificationCenterView.js +479 -437
  80. package/dist/shared/components/panels/AccessDeniedPanel.js +176 -101
  81. package/dist/shared/components/panels/AlertBanners.js +82 -72
  82. package/dist/shared/components/panels/BranchLanes.js +22 -22
  83. package/dist/shared/components/panels/CommentImages.js +123 -102
  84. package/dist/shared/components/panels/CommentPanel.js +186 -185
  85. package/dist/shared/components/panels/ExternalRequestsChip.js +111 -119
  86. package/dist/shared/components/panels/OwnerOpenedLine.js +31 -24
  87. package/dist/shared/components/panels/PipelinePanel.js +2037 -1885
  88. package/dist/shared/components/panels/ResubmissionDiff.js +163 -142
  89. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +400 -288
  90. package/dist/shared/components/pipeline/PipelineEditorView.js +7 -2
  91. package/dist/shared/components/profile/AgentNameField.js +107 -81
  92. package/dist/shared/components/profile/AgentsPanel.js +184 -184
  93. package/dist/shared/components/profile/PersonAccess.js +599 -495
  94. package/dist/shared/components/profile/SignInTroubleshooter.js +160 -127
  95. package/dist/shared/components/profile/SignedInDevices.js +17 -17
  96. package/dist/shared/components/profile/primitives.js +1 -1
  97. package/dist/shared/components/queue/OwnerAvatars.js +91 -54
  98. package/dist/shared/components/queue/QueueTeamStrip.js +56 -46
  99. package/dist/shared/components/queue/QueueWorklist.js +1002 -983
  100. package/dist/shared/components/support/AssignRules.js +1733 -0
  101. package/dist/shared/components/support/PersonPick.js +88 -0
  102. package/dist/shared/components/support/RequestList.js +790 -0
  103. package/dist/shared/components/support/ScreenShare.js +158 -152
  104. package/dist/shared/components/support/SupportRequestDialog.js +50 -48
  105. package/dist/shared/components/support/SupportView.js +140 -246
  106. package/dist/shared/components/support/TicketDetailSheet.js +82 -75
  107. package/dist/shared/components/support/TicketSlowScreens.js +9 -9
  108. package/dist/shared/components/support/assign-rules-text.js +171 -0
  109. package/dist/shared/components/support/support-list.js +125 -0
  110. package/dist/shared/components/ui/SimpleSelect.js +28 -20
  111. package/dist/shared/components/ui/checkbox.js +6 -6
  112. package/dist/shared/components/ui/select.js +43 -39
  113. package/dist/shared/components/ui/sheet.js +9 -9
  114. package/dist/shared/components/ui/switch.js +12 -11
  115. package/dist/shared/components/watch-list/WatchDock.js +532 -459
  116. package/dist/shared/components/watch-list/WatchExtras.js +332 -286
  117. package/dist/shared/components/watch-list/WatchRows.js +164 -140
  118. package/dist/shared/lib/activity-sentence.js +103 -91
  119. package/dist/shared/lib/agent-presence.js +27 -21
  120. package/dist/shared/lib/approval-progress.js +2 -2
  121. package/dist/shared/lib/copy-rules.js +31 -24
  122. package/dist/shared/lib/derived-causes.js +113 -78
  123. package/dist/shared/lib/grid-cursors.js +26 -26
  124. package/dist/shared/lib/label-flash.js +27 -0
  125. package/dist/shared/lib/list-return.js +137 -125
  126. package/dist/shared/lib/live-deltas.js +40 -34
  127. package/dist/shared/lib/live-groups.js +56 -52
  128. package/dist/shared/lib/live-preference.js +64 -59
  129. package/dist/shared/lib/live-screen.js +223 -192
  130. package/dist/shared/lib/partner-failure.js +11 -11
  131. package/dist/shared/lib/rollup-recalc.js +68 -64
  132. package/dist/shared/lib/screen-refresh.js +74 -68
  133. package/dist/shared/lib/screen-share.js +108 -104
  134. package/dist/shared/lib/send-status.js +77 -61
  135. package/dist/shared/lib/text-diff-window.js +29 -0
  136. package/dist/shared/lib/watch-list.js +210 -209
  137. package/dist/shared/lib/widget-image-render.js +72 -49
  138. package/package.json +1 -1
@@ -1,98 +1,123 @@
1
- import { jsxs as r, jsx as e, Fragment as ce } from "react/jsx-runtime";
2
- import { useQueryClient as We, useQuery as we } from "@tanstack/react-query";
3
- import { Clock as Oe, Download as ze, Loader2 as ve, Upload as Re, X as Ne, Plus as lt, File as Ue, FileVideo as nt, FileAudio as st, FileText as Fe, FileSpreadsheet as at, FileCode as it } from "lucide-react";
4
- import { useId as Ce, useState as b, useRef as E, useEffect as X } from "react";
5
- import { useNivaroClient as Le, useApiFetchConfig as Ke, useGridFlush as Te, useParentDraft as Me } from "../../context.js";
6
- import { useFileHealth as Ae } from "../../hooks/useFileHealth.js";
7
- import { get as ye, post as $e, del as qe } from "../../lib/commands.js";
8
- import { trackedUpload as Ee } from "../../lib/upload-presence.js";
9
- import { cn as de, formatDateTime as rt } from "../../lib/utils.js";
10
- import { useFileDownloadStats as Qe, FileDownloadCount as Be } from "./FileDownloadCount.js";
11
- import { useOnceVisible as Ve, useFileUsage as He, FileUsageChip as De } from "./FileUsage.js";
1
+ import { jsxs as i, jsx as e, Fragment as de } from "react/jsx-runtime";
2
+ import { useQueryClient as Te, useQuery as we } from "@tanstack/react-query";
3
+ import { Clock as Oe, Download as ze, Loader2 as ve, Upload as Le, X as ke, Plus as nt, File as Ue, FileVideo as rt, FileAudio as at, FileText as Ce, FileSpreadsheet as it, FileCode as ot } from "lucide-react";
4
+ import { useId as Re, useState as w, useRef as K, useEffect as D } from "react";
5
+ import { useNivaroClient as $e, useApiFetchConfig as Ke, useGridFlush as Me, useParentDraft as Ae } from "../../context.js";
6
+ import { useFileHealth as Ee } from "../../hooks/useFileHealth.js";
7
+ import { get as ye, post as Se, del as Pe } from "../../lib/commands.js";
8
+ import { trackedUpload as Qe } from "../../lib/upload-presence.js";
9
+ import { cn as ce, formatDateTime as dt } from "../../lib/utils.js";
10
+ import { useFileDownloadStats as Be, FileDownloadCount as Ve } from "./FileDownloadCount.js";
11
+ import { useOnceVisible as De, useFileUsage as He, FileUsageChip as Je } from "./FileUsage.js";
12
12
  import { useFileDownload as Ge } from "./file-download.js";
13
- import { OWN_FILE_CHANGE_MS as ot, RemovedFileRow as Je, noteOwnFileChange as be, useLiveFileList as ct, REMOVED_SHOW_MS as Pe, REMOVED_FADE_MS as dt } from "./file-live.js";
14
- import { useFileProcessing as Xe, FileProcessingBadge as Ze, FileProcessingTile as ut, chipThumbUrl as Se } from "./file-processing.js";
15
- import { liveRecordWrite as mt } from "./live-record-marks.js";
16
- import { useM2MStaging as ht } from "./M2MStagingContext.js";
17
- import { RemoteUploadRows as Ye } from "./RemoteUploads.js";
18
- function ue(n) {
19
- var C;
20
- const i = ((n == null ? void 0 : n.title) ?? "").trim(), N = ((n == null ? void 0 : n.filename_download) ?? "").trim();
21
- if (!i) return N;
22
- const f = (C = /\.([A-Za-z0-9]{1,8})$/.exec(N)) == null ? void 0 : C[1];
23
- return f ? new RegExp(`\\.${f}$`, "i").test(i) ? i : `${i}.${f}` : i;
13
+ import { OWN_FILE_CHANGE_MS as ct, RemovedFileRow as Xe, lastWriterName as Ze, noteOwnFileChange as be, useLiveFileList as ut, REMOVED_SHOW_MS as We, REMOVED_FADE_MS as mt } from "./file-live.js";
14
+ import { useFileProcessing as Ye, FileProcessingBadge as Ie, FileProcessingTile as ht, chipThumbUrl as qe } from "./file-processing.js";
15
+ import { liveRecordWrite as ft } from "./live-record-marks.js";
16
+ import { useM2MStaging as pt } from "./M2MStagingContext.js";
17
+ import { RemoteUploadRows as et } from "./RemoteUploads.js";
18
+ function ue(s) {
19
+ var x;
20
+ const n = ((s == null ? void 0 : s.title) ?? "").trim(), d = ((s == null ? void 0 : s.filename_download) ?? "").trim();
21
+ if (!n) return d;
22
+ const h = (x = /\.([A-Za-z0-9]{1,8})$/.exec(d)) == null ? void 0 : x[1];
23
+ return h ? new RegExp(`\\.${h}$`, "i").test(n) ? n : `${n}.${h}` : n;
24
24
  }
25
- function ke(n) {
26
- return n ? n < 1024 ? `${n} B` : n < 1024 * 1024 ? `${(n / 1024).toFixed(1)} KB` : `${(n / (1024 * 1024)).toFixed(1)} MB` : null;
25
+ function Ne(s) {
26
+ return s ? s < 1024 ? `${s} B` : s < 1024 * 1024 ? `${(s / 1024).toFixed(1)} KB` : `${(s / (1024 * 1024)).toFixed(1)} MB` : null;
27
27
  }
28
- function Ie(n) {
29
- return n ? rt(n) : null;
28
+ function tt(s) {
29
+ return s ? dt(s) : null;
30
30
  }
31
- function je(n) {
32
- return !!n && n.startsWith("image/");
31
+ function je(s) {
32
+ return !!s && s.startsWith("image/");
33
33
  }
34
- function ft(n, i) {
35
- return n ? n.startsWith("video/") ? /* @__PURE__ */ e(nt, { className: i, strokeWidth: 1.5 }) : n.startsWith("audio/") ? /* @__PURE__ */ e(st, { className: i, strokeWidth: 1.5 }) : n === "application/pdf" ? /* @__PURE__ */ e(Fe, { className: i, strokeWidth: 1.5 }) : n.startsWith("text/") ? /* @__PURE__ */ e(Fe, { className: i, strokeWidth: 1.5 }) : n.includes("spreadsheet") || n.includes("excel") || n === "text/csv" ? /* @__PURE__ */ e(at, { className: i, strokeWidth: 1.5 }) : n.includes("wordprocessing") || n.includes("msword") ? /* @__PURE__ */ e(Fe, { className: i, strokeWidth: 1.5 }) : n.includes("json") || n.includes("javascript") || n.includes("typescript") || n.includes("xml") ? /* @__PURE__ */ e(it, { className: i, strokeWidth: 1.5 }) : /* @__PURE__ */ e(Ue, { className: i, strokeWidth: 1.5 }) : /* @__PURE__ */ e(Ue, { className: i, strokeWidth: 1.5 });
34
+ function _e(s, n) {
35
+ var x;
36
+ const d = (s ?? "").toLowerCase(), h = ((x = (n ?? "").split(".").pop()) == null ? void 0 : x.toUpperCase()) ?? "";
37
+ return d === "application/pdf" ? "PDF" : d === "text/csv" ? "CSV" : d.includes("spreadsheet") || d.includes("excel") ? "Spreadsheet" : d.includes("wordprocessing") || d.includes("msword") ? "Word document" : d.includes("presentation") || d.includes("powerpoint") ? "Presentation" : d.startsWith("image/") ? `Image${h && (n != null && n.includes(".")) ? ` (${h})` : ""}` : d.startsWith("video/") ? "Video" : d.startsWith("audio/") ? "Audio" : d.includes("zip") || d.includes("compressed") ? "ZIP archive" : d === "text/plain" ? "Text" : d.includes("json") ? "JSON" : d.includes("xml") ? "XML" : h && h.length <= 5 && (n != null && n.includes(".")) ? h : "File";
38
+ }
39
+ function xt(s) {
40
+ const n = (s ?? "").toLowerCase();
41
+ return n === "application/pdf" ? "bg-red-50 text-red-600 dark:bg-red-500/15 dark:text-red-300" : n.includes("spreadsheet") || n.includes("excel") || n === "text/csv" ? "bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300" : n.includes("wordprocessing") || n.includes("msword") ? "bg-sky-50 text-sky-700 dark:bg-sky-500/15 dark:text-sky-300" : "bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-300";
42
+ }
43
+ function gt(s, n) {
44
+ return s ? s.startsWith("video/") ? /* @__PURE__ */ e(rt, { className: n, strokeWidth: 1.5 }) : s.startsWith("audio/") ? /* @__PURE__ */ e(at, { className: n, strokeWidth: 1.5 }) : s === "application/pdf" ? /* @__PURE__ */ e(Ce, { className: n, strokeWidth: 1.5 }) : s.startsWith("text/") ? /* @__PURE__ */ e(Ce, { className: n, strokeWidth: 1.5 }) : s.includes("spreadsheet") || s.includes("excel") || s === "text/csv" ? /* @__PURE__ */ e(it, { className: n, strokeWidth: 1.5 }) : s.includes("wordprocessing") || s.includes("msword") ? /* @__PURE__ */ e(Ce, { className: n, strokeWidth: 1.5 }) : s.includes("json") || s.includes("javascript") || s.includes("typescript") || s.includes("xml") ? /* @__PURE__ */ e(ot, { className: n, strokeWidth: 1.5 }) : /* @__PURE__ */ e(Ue, { className: n, strokeWidth: 1.5 }) : /* @__PURE__ */ e(Ue, { className: n, strokeWidth: 1.5 });
36
45
  }
37
46
  function me({
38
- url: n,
39
- type: i,
40
- filename: N,
41
- size: f = "md",
42
- processing: C = !1
47
+ url: s,
48
+ type: n,
49
+ filename: d,
50
+ size: h = "md",
51
+ processing: x = !1
43
52
  }) {
44
- const P = f === "sm" ? "h-10 w-10" : f === "lg" ? "h-20 w-20" : "h-14 w-14", [h, W] = b(!1);
45
- return je(i) && C ? /* @__PURE__ */ e(ut, { className: P }) : je(i) ? /* @__PURE__ */ e(
46
- "img",
47
- {
48
- src: h ? n : Se(n),
49
- alt: N,
50
- "data-file-thumb": !0,
51
- className: de(P, "object-cover rounded shrink-0"),
52
- loading: "lazy",
53
- onError: (w) => {
54
- if (!h && Se(n) !== n) {
55
- W(!0);
56
- return;
53
+ const P = h === "sm" ? "h-10 w-10" : h === "lg" ? "h-20 w-20" : "h-14 w-14", [g, W] = w(!1), [N, p] = w(!1), [u, f] = w(0), q = K(x);
54
+ if (D(() => {
55
+ q.current && !x && (W(!1), p(!1), f(Date.now())), q.current = x;
56
+ }, [x]), je(n) && x) return /* @__PURE__ */ e(ht, { className: P });
57
+ if (je(n) && !N) {
58
+ const z = () => {
59
+ if (!g && qe(s) !== s) {
60
+ W(!0);
61
+ return;
62
+ }
63
+ p(!0);
64
+ }, v = g ? s : qe(s);
65
+ return /* @__PURE__ */ e(
66
+ "img",
67
+ {
68
+ src: u && !/^(blob|data):/i.test(v) ? `${v}${v.includes("?") ? "&" : "?"}v=${u}` : v,
69
+ alt: d,
70
+ "data-file-thumb": !0,
71
+ className: ce(P, "object-cover rounded shrink-0"),
72
+ loading: "lazy",
73
+ onError: z,
74
+ onLoad: (j) => {
75
+ j.currentTarget.naturalWidth === 0 && z();
57
76
  }
58
- w.target.style.display = "none";
59
77
  }
78
+ );
79
+ }
80
+ return /* @__PURE__ */ e(
81
+ "div",
82
+ {
83
+ className: ce(P, "flex items-center justify-center rounded shrink-0", xt(n)),
84
+ children: gt(n, h === "sm" ? "h-4 w-4" : "h-6 w-6")
60
85
  }
61
- ) : /* @__PURE__ */ e("div", { className: de(P, "flex items-center justify-center rounded bg-slate-100 shrink-0"), children: ft(i, f === "sm" ? "h-4 w-4" : "h-6 w-6") });
86
+ );
62
87
  }
63
- function et({
64
- selected: n,
65
- multi: i,
66
- onSelect: N,
67
- onClose: f,
68
- getUrl: C
88
+ function lt({
89
+ selected: s,
90
+ multi: n,
91
+ onSelect: d,
92
+ onClose: h,
93
+ getUrl: x
69
94
  }) {
70
- const P = Le(), [h, W] = b(""), { data: w = [], isLoading: x } = we({
71
- queryKey: ["file-browser", h],
95
+ const P = $e(), [g, W] = w(""), { data: N = [], isLoading: p } = we({
96
+ queryKey: ["file-browser", g],
72
97
  queryFn: () => P.request(
73
98
  ye("/files", {
74
99
  limit: "60",
75
100
  sort: "-uploaded_on",
76
101
  fields: "id,filename_download,title,type,filesize,width,height,missing_at",
77
- ...h ? { search: h } : {}
102
+ ...g ? { search: g } : {}
78
103
  })
79
104
  ).then((u) => u.data ?? []),
80
105
  staleTime: 3e4
81
106
  });
82
- return /* @__PURE__ */ r("div", { className: "flex flex-col", style: { width: 480, maxHeight: 420 }, children: [
83
- /* @__PURE__ */ r("div", { className: "flex items-center justify-between border-b border-slate-100 px-3 py-2 shrink-0", children: [
84
- /* @__PURE__ */ r("p", { className: "text-[12px] font-medium text-slate-700", children: [
107
+ return /* @__PURE__ */ i("div", { className: "flex flex-col", style: { width: 480, maxHeight: 420 }, children: [
108
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between border-b border-slate-100 px-3 py-2 shrink-0", children: [
109
+ /* @__PURE__ */ i("p", { className: "text-[12px] font-medium text-slate-700", children: [
85
110
  "Select file",
86
- i ? "s" : ""
111
+ n ? "s" : ""
87
112
  ] }),
88
113
  /* @__PURE__ */ e(
89
114
  "button",
90
115
  {
91
116
  type: "button",
92
117
  "aria-label": "Close",
93
- onClick: f,
118
+ onClick: h,
94
119
  className: "text-slate-400 hover:text-slate-600",
95
- children: /* @__PURE__ */ e(Ne, { className: "h-3.5 w-3.5" })
120
+ children: /* @__PURE__ */ e(ke, { className: "h-3.5 w-3.5" })
96
121
  }
97
122
  )
98
123
  ] }),
@@ -101,38 +126,38 @@ function et({
101
126
  {
102
127
  type: "text",
103
128
  placeholder: "Search files…",
104
- value: h,
129
+ value: g,
105
130
  onChange: (u) => W(u.target.value),
106
131
  className: "w-full h-7 rounded border border-slate-200 px-2 text-[12px] focus:outline-none focus:ring-1 focus:ring-nvr-cyan",
107
132
  autoFocus: !0
108
133
  }
109
134
  ) }),
110
- /* @__PURE__ */ r("div", { className: "overflow-y-auto flex-1 p-3", children: [
111
- x && /* @__PURE__ */ e("div", { className: "flex justify-center py-6", children: /* @__PURE__ */ e(ve, { className: "h-5 w-5 animate-spin text-slate-300" }) }),
112
- !x && w.length === 0 && /* @__PURE__ */ e("p", { className: "text-center text-[12px] text-slate-400 py-6", children: "No files found" }),
113
- !x && w.length > 0 && /* @__PURE__ */ e("div", { className: "grid grid-cols-5 gap-2", children: w.map((u) => {
114
- const m = n.includes(u.id);
115
- return /* @__PURE__ */ r(
135
+ /* @__PURE__ */ i("div", { className: "overflow-y-auto flex-1 p-3", children: [
136
+ p && /* @__PURE__ */ e("div", { className: "flex justify-center py-6", children: /* @__PURE__ */ e(ve, { className: "h-5 w-5 animate-spin text-slate-300" }) }),
137
+ !p && N.length === 0 && /* @__PURE__ */ e("p", { className: "text-center text-[12px] text-slate-400 py-6", children: "No files found" }),
138
+ !p && N.length > 0 && /* @__PURE__ */ e("div", { className: "grid grid-cols-5 gap-2", children: N.map((u) => {
139
+ const f = s.includes(u.id);
140
+ return /* @__PURE__ */ i(
116
141
  "button",
117
142
  {
118
143
  type: "button",
119
- onClick: () => N(u.id),
120
- className: de(
144
+ onClick: () => d(u.id),
145
+ className: ce(
121
146
  "nvr-rise-in group flex flex-col items-center gap-1 rounded-lg p-1.5 text-left transition-colors border",
122
- m ? "border-nvr-cyan bg-nvr-cyan/5" : "border-transparent hover:border-slate-200 hover:bg-slate-50"
147
+ f ? "border-nvr-cyan bg-nvr-cyan/5" : "border-transparent hover:border-slate-200 hover:bg-slate-50"
123
148
  ),
124
149
  children: [
125
- /* @__PURE__ */ r("div", { className: "relative", children: [
150
+ /* @__PURE__ */ i("div", { className: "relative", children: [
126
151
  /* @__PURE__ */ e(
127
152
  me,
128
153
  {
129
- url: C(u.id),
154
+ url: x(u.id),
130
155
  type: u.type,
131
156
  filename: u.filename_download,
132
157
  size: "md"
133
158
  }
134
159
  ),
135
- m && /* @__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(
160
+ f && /* @__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(
136
161
  "svg",
137
162
  {
138
163
  className: "h-2.5 w-2.5 text-white",
@@ -167,147 +192,166 @@ function et({
167
192
  ] })
168
193
  ] });
169
194
  }
170
- function Pt({
171
- field: n,
172
- value: i,
173
- onChange: N,
174
- disabled: f,
175
- allowUpload: C = !0,
195
+ function jt({
196
+ field: s,
197
+ value: n,
198
+ onChange: d,
199
+ disabled: h,
200
+ allowUpload: x = !0,
176
201
  allowPick: P = !0,
177
- showUsage: h = !0,
202
+ showUsage: g = !0,
178
203
  showDownloads: W = !0
179
204
  }) {
180
- var ge, re, oe;
181
- const w = Le(), x = Ke(), u = We(), m = Te(), Q = Ce(), [Z, L] = b(!1), [O, te] = b(!1), [z, Y] = b(null), [p, B] = b(null), [le, U] = b(null), _ = E(null), a = !p && i ? String(i) : null, F = (d) => w.fileUrl(d), I = Ge(), o = Me(), $ = ((ge = o == null ? void 0 : o.draft) == null ? void 0 : ge.id) != null ? String(o.draft.id) : null, K = Xe(a ? [a] : [], {
205
+ var ge, ie, oe;
206
+ const N = $e(), p = Ke(), u = Te(), f = Me(), q = Re(), [z, v] = w(!1), [j, te] = w(!1), [M, Y] = w(null), [b, H] = w(null), [le, U] = w(null), C = K(null), a = !b && n ? String(n) : null, L = (m) => N.fileUrl(m), I = Ge(), o = Ae(), R = ((ge = o == null ? void 0 : o.draft) == null ? void 0 : ge.id) != null ? String(o.draft.id) : null, A = Ye(a ? [a] : [], {
182
207
  collection: o == null ? void 0 : o.collection,
183
- itemId: $
184
- }), [he, S] = Ve(!!a), j = He(
208
+ itemId: R
209
+ }), [he, T] = De(!!a), O = He(
185
210
  o == null ? void 0 : o.collection,
186
- $,
211
+ R,
187
212
  a ? [a] : [],
188
- S && h
189
- ), ne = Qe(
213
+ T && g
214
+ ), se = Be(
190
215
  o == null ? void 0 : o.collection,
191
- $,
216
+ R,
192
217
  a ? [a] : [],
193
- S && W
218
+ T && W
194
219
  );
195
- X(() => {
196
- if (!p) {
220
+ D(() => {
221
+ if (!b) {
197
222
  U(null);
198
223
  return;
199
224
  }
200
- const d = URL.createObjectURL(p);
201
- return U(d), () => URL.revokeObjectURL(d);
202
- }, [p]), X(() => {
203
- if (!(!m || !p))
204
- return m.register(Q, async () => {
205
- const d = await w.upload(p);
206
- N(d.id), B(null), u.invalidateQueries({ queryKey: ["file-browser"] });
207
- }), () => m.unregister(Q);
208
- }, [m, p, Q, w, N, u]);
209
- const g = Ae([a]), { data: s, isLoading: se } = we({
225
+ const m = URL.createObjectURL(b);
226
+ return U(m), () => URL.revokeObjectURL(m);
227
+ }, [b]), D(() => {
228
+ if (!(!f || !b))
229
+ return f.register(q, async () => {
230
+ const m = await N.upload(b);
231
+ d(m.id), H(null), u.invalidateQueries({ queryKey: ["file-browser"] });
232
+ }), () => f.unregister(q);
233
+ }, [f, b, q, N, d, u]);
234
+ const k = Ee([a]), { data: r, isLoading: ne } = we({
210
235
  queryKey: ["file-meta", a],
211
- queryFn: () => w.request(ye(`/files/${a}/meta`)).then((d) => d.data ?? null),
236
+ queryFn: () => N.request(ye(`/files/${a}/meta`)).then((m) => m.data ?? null),
212
237
  enabled: !!a,
213
238
  staleTime: 6e4
214
- }), T = E(0), fe = E(a), ae = E(null), [R, v] = b(!1), [V, M] = b(null), H = E([]);
215
- s && (ae.current = ue(s) || ae.current), X(() => {
216
- const d = fe.current;
217
- if (fe.current = a, d === a || p) return;
218
- const q = Date.now() - T.current < ot, D = o == null ? void 0 : o.collection;
219
- if (q || !D || !$ || !mt(D, $)) return;
220
- const G = (t, l) => H.current.push(setTimeout(t, l));
221
- a ? (M(null), v(!0), G(() => v(!1), 2e3)) : d && (M({ name: ae.current ?? "A file", leaving: !1 }), G(
222
- () => M((t) => t && { ...t, leaving: !0 }),
223
- Pe - dt
224
- ), G(() => M(null), Pe));
225
- }, [a]), X(() => {
226
- const d = H.current;
239
+ }), E = K(0), fe = K(a), re = K(null), [$, y] = w(!1), [J, Q] = w(null), B = K([]);
240
+ r && (re.current = ue(r) || re.current), D(() => {
241
+ const m = fe.current;
242
+ if (fe.current = a, m === a || b) return;
243
+ const S = Date.now() - E.current < ct, G = o == null ? void 0 : o.collection;
244
+ if (S || !G || !R || !ft(G, R)) return;
245
+ const X = (t, l) => B.current.push(setTimeout(t, l));
246
+ a ? (Q(null), y(!0), X(() => y(!1), 2e3)) : m && (Q({ name: re.current ?? "A file", leaving: !1 }), X(
247
+ () => Q((t) => t && { ...t, leaving: !0 }),
248
+ We - mt
249
+ ), X(() => Q(null), We));
250
+ }, [a]), D(() => {
251
+ const m = B.current;
227
252
  return () => {
228
- for (const q of d) clearTimeout(q);
253
+ for (const S of m) clearTimeout(S);
229
254
  };
230
255
  }, []);
231
- async function ie(d) {
232
- var D;
233
- const q = (D = d.target.files) == null ? void 0 : D[0];
234
- if (q)
235
- if (_.current && (_.current.value = ""), T.current = Date.now(), m)
236
- B(q);
256
+ async function ae(m) {
257
+ var G;
258
+ const S = (G = m.target.files) == null ? void 0 : G[0];
259
+ if (S)
260
+ if (C.current && (C.current.value = ""), E.current = Date.now(), f)
261
+ H(S);
237
262
  else {
238
263
  te(!0), Y(null);
239
264
  try {
240
- const G = await Ee(q, {
241
- cfg: x,
242
- fallback: (t) => w.upload(t),
243
- field: n,
265
+ const X = await Qe(S, {
266
+ cfg: p,
267
+ fallback: (t) => N.upload(t),
268
+ field: s,
244
269
  collection: o == null ? void 0 : o.collection,
245
- item: $ ?? void 0,
270
+ item: R ?? void 0,
246
271
  onProgress: Y
247
272
  });
248
- N(G.id), u.invalidateQueries({ queryKey: ["file-browser"] });
273
+ d(X.id), u.invalidateQueries({ queryKey: ["file-browser"] });
249
274
  } catch {
250
275
  } finally {
251
276
  te(!1), Y(null);
252
277
  }
253
278
  }
254
279
  }
255
- function _e(d) {
256
- T.current = Date.now(), B(null), N(d), L(!1);
280
+ function Fe(m) {
281
+ E.current = Date.now(), H(null), d(m), v(!1);
257
282
  }
258
283
  function pe() {
259
- T.current = Date.now(), B(null), N(null);
284
+ E.current = Date.now(), H(null), d(null);
260
285
  }
261
- const y = !!p, xe = y || !!a;
262
- return /* @__PURE__ */ r("div", { className: "relative", children: [
263
- !xe && V && /* @__PURE__ */ e("div", { className: "mb-1.5", children: /* @__PURE__ */ e(Je, { name: V.name, leaving: V.leaving }) }),
264
- xe ? /* @__PURE__ */ r(
286
+ const _ = !!b, xe = _ || !!a;
287
+ return /* @__PURE__ */ i("div", { className: "relative", children: [
288
+ !xe && J && /* @__PURE__ */ e("div", { className: "mb-1.5", children: /* @__PURE__ */ e(
289
+ Xe,
290
+ {
291
+ name: J.name,
292
+ leaving: J.leaving,
293
+ by: Ze(
294
+ u.getQueryData(["last-touch", o == null ? void 0 : o.collection, String(R)])
295
+ )
296
+ }
297
+ ) }),
298
+ xe ? /* @__PURE__ */ i(
265
299
  "div",
266
300
  {
267
301
  ref: he,
268
- "data-file-fresh": R ? "" : void 0,
269
- className: de(
270
- "flex items-center gap-2 rounded-lg border border-slate-200 p-2 bg-slate-50",
271
- R && "nvr-row-enter"
302
+ "data-file-fresh": $ ? "" : void 0,
303
+ className: ce(
304
+ "flex items-center gap-2 rounded-lg border border-slate-200 p-2 bg-slate-50 dark:border-border dark:bg-white/[0.03]",
305
+ $ && "nvr-row-enter"
272
306
  ),
273
307
  children: [
274
- y ? /* @__PURE__ */ e(
308
+ _ ? /* @__PURE__ */ e(
275
309
  me,
276
310
  {
277
311
  url: le ?? "",
278
- type: p.type || null,
279
- filename: p.name,
312
+ type: b.type || null,
313
+ filename: b.name,
280
314
  size: "sm"
281
315
  }
282
- ) : se ? /* @__PURE__ */ e("div", { className: "h-10 w-10 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] animate-pulse" }) : (
316
+ ) : ne ? /* @__PURE__ */ e("div", { className: "h-10 w-10 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] animate-pulse" }) : (
283
317
  // Every file click downloads (2026-11-08): no in-app preview.
284
318
  /* @__PURE__ */ e(
285
319
  "a",
286
320
  {
287
- href: `${F(a)}?download=1`,
288
- download: (s == null ? void 0 : s.filename_download) || !0,
289
- onClick: I(`${F(a)}?download=1`, s == null ? void 0 : s.filename_download),
321
+ href: `${L(a)}?download=1`,
322
+ download: (r == null ? void 0 : r.filename_download) || !0,
323
+ onClick: I(`${L(a)}?download=1`, r == null ? void 0 : r.filename_download),
290
324
  title: "Download",
291
325
  className: "shrink-0",
292
326
  children: /* @__PURE__ */ e(
293
327
  me,
294
328
  {
295
- url: F(a),
296
- type: (s == null ? void 0 : s.type) ?? null,
297
- filename: (s == null ? void 0 : s.filename_download) ?? "",
329
+ url: L(a),
330
+ type: (r == null ? void 0 : r.type) ?? null,
331
+ filename: (r == null ? void 0 : r.filename_download) ?? "",
298
332
  size: "sm",
299
- processing: !!a && K.isProcessing(a)
333
+ processing: !!a && A.isProcessing(a)
300
334
  }
301
335
  )
302
336
  }
303
337
  )
304
338
  ),
305
- /* @__PURE__ */ r("div", { className: "flex-1 min-w-0", children: [
306
- /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
307
- !y && !!a && K.isProcessing(a) && /* @__PURE__ */ e(Ze, {}),
308
- y && /* @__PURE__ */ e(Oe, { className: "h-3 w-3 text-amber-400 shrink-0" }),
309
- /* @__PURE__ */ e("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: y ? p.name : ue(s) || a }),
310
- !y && (g.verdict(a) ?? !!(s != null && s.missing_at)) && /* @__PURE__ */ e(
339
+ /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
340
+ /* @__PURE__ */ i("div", { className: "flex min-w-0 items-center gap-1.5", children: [
341
+ _ && /* @__PURE__ */ e(Oe, { className: "h-3 w-3 text-amber-400 shrink-0" }),
342
+ /* @__PURE__ */ e(
343
+ "p",
344
+ {
345
+ "data-file-name": !0,
346
+ className: "min-w-0 text-[12px] font-medium text-slate-700 truncate dark:text-slate-100",
347
+ children: _ ? b.name : r ? ue(r) || "Untitled file" : (
348
+ // Never the raw file id while the name loads.
349
+ /* @__PURE__ */ e("span", { className: "text-slate-400 dark:text-slate-500", children: "Loading name…" })
350
+ )
351
+ }
352
+ ),
353
+ !_ && !!a && A.isProcessing(a) && /* @__PURE__ */ e(Ie, {}),
354
+ !_ && (k.verdict(a) ?? !!(r != null && r.missing_at)) && /* @__PURE__ */ e(
311
355
  "span",
312
356
  {
313
357
  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",
@@ -316,69 +360,69 @@ function Pt({
316
360
  }
317
361
  )
318
362
  ] }),
319
- /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: y ? /* @__PURE__ */ r(ce, { children: [
320
- p.type && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: p.type }),
321
- /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: ke(p.size) }),
363
+ /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: _ ? /* @__PURE__ */ i(de, { children: [
364
+ b.type && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-500 dark:text-slate-400", children: _e(b.type, b.name) }),
365
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: Ne(b.size) }),
322
366
  /* @__PURE__ */ e("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
323
- ] }) : /* @__PURE__ */ r(ce, { children: [
324
- (s == null ? void 0 : s.type) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: s.type }),
325
- (s == null ? void 0 : s.filesize) != null && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: ke(s.filesize) }),
326
- (s == null ? void 0 : s.uploaded_on) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: Ie(s.uploaded_on) }),
327
- (s == null ? void 0 : s.uploaded_by_name) && /* @__PURE__ */ r("span", { className: "text-[10px] text-slate-500", children: [
367
+ ] }) : /* @__PURE__ */ i(de, { children: [
368
+ (r == null ? void 0 : r.type) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-500 dark:text-slate-400", children: _e(r.type, r.filename_download) }),
369
+ (r == null ? void 0 : r.filesize) != null && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: Ne(r.filesize) }),
370
+ (r == null ? void 0 : r.uploaded_on) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: tt(r.uploaded_on) }),
371
+ (r == null ? void 0 : r.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500", children: [
328
372
  "by ",
329
- s.uploaded_by_name
373
+ r.uploaded_by_name
330
374
  ] })
331
375
  ] }) })
332
376
  ] }),
333
- h && !y && a && /* @__PURE__ */ e(
334
- De,
377
+ g && !_ && a && /* @__PURE__ */ e(
378
+ Je,
335
379
  {
336
380
  fileId: a,
337
- uses: (re = j.data) == null ? void 0 : re[a],
338
- loading: j.isLoading,
381
+ uses: (ie = O.data) == null ? void 0 : ie[a],
382
+ loading: O.isLoading,
339
383
  collection: o == null ? void 0 : o.collection,
340
- itemId: $
384
+ itemId: R
341
385
  }
342
386
  ),
343
- W && !y && a && /* @__PURE__ */ e(Be, { fileId: a, stat: (oe = ne.data) == null ? void 0 : oe[a] }),
344
- !y && a && /* @__PURE__ */ e(
387
+ W && !_ && a && /* @__PURE__ */ e(Ve, { fileId: a, stat: (oe = se.data) == null ? void 0 : oe[a] }),
388
+ !_ && a && /* @__PURE__ */ e(
345
389
  "a",
346
390
  {
347
- href: `${F(a)}?download=1`,
348
- onClick: I(`${F(a)}?download=1`, s == null ? void 0 : s.filename_download),
391
+ href: `${L(a)}?download=1`,
392
+ onClick: I(`${L(a)}?download=1`, r == null ? void 0 : r.filename_download),
349
393
  title: "Download",
350
394
  className: "shrink-0 text-slate-400 hover:text-nvr-cyan p-0.5",
351
395
  children: /* @__PURE__ */ e(ze, { className: "h-3.5 w-3.5" })
352
396
  }
353
397
  ),
354
- !f && /* @__PURE__ */ r("div", { className: "flex items-center gap-1 shrink-0", children: [
398
+ !h && /* @__PURE__ */ i("div", { className: "flex items-center gap-1 shrink-0", children: [
355
399
  P && /* @__PURE__ */ e(
356
400
  "button",
357
401
  {
358
402
  type: "button",
359
- onClick: () => L(!0),
403
+ onClick: () => v(!0),
360
404
  className: "h-6 px-2 rounded border border-slate-200 text-[11px] text-slate-600 hover:border-slate-400",
361
405
  children: "Replace"
362
406
  }
363
407
  ),
364
- C && /* @__PURE__ */ r(ce, { children: [
365
- /* @__PURE__ */ r(
408
+ x && /* @__PURE__ */ i(de, { children: [
409
+ /* @__PURE__ */ i(
366
410
  "button",
367
411
  {
368
412
  type: "button",
369
413
  onClick: () => {
370
- var d;
371
- return (d = _.current) == null ? void 0 : d.click();
414
+ var m;
415
+ return (m = C.current) == null ? void 0 : m.click();
372
416
  },
373
- disabled: O,
417
+ disabled: j,
374
418
  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",
375
419
  children: [
376
- O ? /* @__PURE__ */ e(ve, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(Re, { className: "h-3 w-3" }),
377
- /* @__PURE__ */ e("span", { className: "tabular-nums", children: O && z != null ? `${z}%` : "Upload" })
420
+ j ? /* @__PURE__ */ e(ve, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(Le, { className: "h-3 w-3" }),
421
+ /* @__PURE__ */ e("span", { className: "tabular-nums", children: j && M != null ? `${M}%` : "Upload" })
378
422
  ]
379
423
  }
380
424
  ),
381
- /* @__PURE__ */ e("input", { ref: _, type: "file", className: "hidden", onChange: ie })
425
+ /* @__PURE__ */ e("input", { ref: C, type: "file", className: "hidden", onChange: ae })
382
426
  ] }),
383
427
  /* @__PURE__ */ e(
384
428
  "button",
@@ -387,218 +431,223 @@ function Pt({
387
431
  "aria-label": "Remove file",
388
432
  onClick: pe,
389
433
  className: "text-slate-300 hover:text-red-400 p-0.5",
390
- children: /* @__PURE__ */ e(Ne, { className: "h-3.5 w-3.5" })
434
+ children: /* @__PURE__ */ e(ke, { className: "h-3.5 w-3.5" })
391
435
  }
392
436
  )
393
437
  ] })
394
438
  ]
395
439
  },
396
440
  a ?? "pending"
397
- ) : /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
441
+ ) : /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
398
442
  P && /* @__PURE__ */ e(
399
443
  "button",
400
444
  {
401
445
  type: "button",
402
- disabled: f,
403
- onClick: () => L(!0),
404
- 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",
446
+ disabled: h,
447
+ onClick: () => v(!0),
448
+ 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 dark:border-border dark:text-slate-400 dark:hover:border-slate-500 dark:hover:text-slate-200 disabled:opacity-40 transition-colors",
405
449
  children: "Select file…"
406
450
  }
407
451
  ),
408
- C && !f && /* @__PURE__ */ r(ce, { children: [
409
- /* @__PURE__ */ r(
452
+ x && !h && /* @__PURE__ */ i(de, { children: [
453
+ /* @__PURE__ */ i(
410
454
  "button",
411
455
  {
412
456
  type: "button",
413
457
  onClick: () => {
414
- var d;
415
- return (d = _.current) == null ? void 0 : d.click();
458
+ var m;
459
+ return (m = C.current) == null ? void 0 : m.click();
416
460
  },
417
- disabled: O,
418
- 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",
461
+ disabled: j,
462
+ 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 dark:border-border dark:text-slate-400 dark:hover:border-slate-500 dark:hover:text-slate-200 disabled:opacity-40 transition-colors",
419
463
  children: [
420
- O ? /* @__PURE__ */ e(ve, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(Re, { className: "h-3.5 w-3.5" }),
421
- /* @__PURE__ */ e("span", { className: "tabular-nums", children: O && z != null ? `${z}%` : "Upload" })
464
+ j ? /* @__PURE__ */ e(ve, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(Le, { className: "h-3.5 w-3.5" }),
465
+ /* @__PURE__ */ e("span", { className: "tabular-nums", children: j && M != null ? `${M}%` : "Upload" })
422
466
  ]
423
467
  }
424
468
  ),
425
- /* @__PURE__ */ e("input", { ref: _, type: "file", className: "hidden", onChange: ie })
469
+ /* @__PURE__ */ e("input", { ref: C, type: "file", className: "hidden", onChange: ae })
426
470
  ] })
427
471
  ] }),
428
- /* @__PURE__ */ e(Ye, { collection: o == null ? void 0 : o.collection, item: $, field: n }),
429
- Z && /* @__PURE__ */ e(
472
+ /* @__PURE__ */ e(et, { collection: o == null ? void 0 : o.collection, item: R, field: s }),
473
+ z && /* @__PURE__ */ e(
430
474
  "div",
431
475
  {
432
476
  className: "absolute z-50 mt-1 rounded-lg border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card",
433
477
  style: { minWidth: 480 },
434
478
  children: /* @__PURE__ */ e(
435
- et,
479
+ lt,
436
480
  {
437
481
  selected: a ? [a] : [],
438
482
  multi: !1,
439
- onSelect: _e,
440
- onClose: () => L(!1),
441
- getUrl: F
483
+ onSelect: Fe,
484
+ onClose: () => v(!1),
485
+ getUrl: L
442
486
  }
443
487
  )
444
488
  }
445
489
  )
446
490
  ] });
447
491
  }
448
- function St({
449
- relation: n,
450
- parentId: i,
451
- allRelations: N,
452
- disabled: f,
453
- allowUpload: C = !0,
492
+ function Tt({
493
+ relation: s,
494
+ parentId: n,
495
+ allRelations: d,
496
+ disabled: h,
497
+ allowUpload: x = !0,
454
498
  allowPick: P = !0,
455
- pendingSave: h = !1,
499
+ pendingSave: g = !1,
456
500
  showUsage: W = !0,
457
- showDownloads: w = !0
501
+ showDownloads: N = !0
458
502
  }) {
459
- const x = Le(), u = We(), m = Te(), Q = Ce(), Z = Ce(), L = ht(), [O, te] = b(!1), [z, Y] = b(!1), p = Ke(), [B, le] = b(null), [U, _] = b([]), a = E(null), [F, I] = b([]), [o, $] = b(/* @__PURE__ */ new Set()), K = E(/* @__PURE__ */ new Map()), he = E(/* @__PURE__ */ new Map()), S = n.junction_field ?? "", j = n.many_field ?? "", ne = n.one_field ?? `${n.many_collection}.${S}`, g = i === "new", s = (t) => x.fileUrl(t), se = Ge();
460
- X(() => () => {
461
- _((t) => (t.forEach((l) => URL.revokeObjectURL(l.url)), []));
462
- }, []), X(() => {
463
- if (!m || !U.length || h) return;
503
+ const p = $e(), u = Te(), f = Me(), q = Re(), z = Re(), v = pt(), [j, te] = w(!1), [M, Y] = w(!1), b = Ke(), [H, le] = w(null), [U, C] = w([]), a = K(null), [L, I] = w([]), [o, R] = w(/* @__PURE__ */ new Set()), A = K(/* @__PURE__ */ new Map()), he = K(/* @__PURE__ */ new Map()), T = s.junction_field ?? "", O = s.many_field ?? "", se = s.one_field ?? `${s.many_collection}.${T}`, k = n === "new", r = (t) => p.fileUrl(t), ne = Ge();
504
+ D(() => () => {
505
+ C((t) => (t.forEach((l) => URL.revokeObjectURL(l.url)), []));
506
+ }, []), D(() => {
507
+ if (!f || !U.length || g) return;
464
508
  const t = U;
465
- return m.register(Q, async () => {
509
+ return f.register(q, async () => {
466
510
  for (const l of t) {
467
- const c = await x.upload(l.file);
468
- URL.revokeObjectURL(l.url), await q(c.id);
511
+ const c = await p.upload(l.file);
512
+ URL.revokeObjectURL(l.url), await S(c.id);
469
513
  }
470
- _([]), u.invalidateQueries({ queryKey: ["file-browser"] });
471
- }), () => m.unregister(Q);
472
- }, [m, U, Q, h]), X(() => {
473
- if (!m || !h) return;
474
- if (!(F.length > 0 || o.size > 0 || U.length > 0)) {
475
- m.unregister(Z);
514
+ C([]), u.invalidateQueries({ queryKey: ["file-browser"] });
515
+ }), () => f.unregister(q);
516
+ }, [f, U, q, g]), D(() => {
517
+ if (!f || !g) return;
518
+ if (!(L.length > 0 || o.size > 0 || U.length > 0)) {
519
+ f.unregister(z);
476
520
  return;
477
521
  }
478
- const l = F, c = new Set(o), k = U;
479
- return m.register(Z, async () => {
480
- const J = [];
481
- for (const A of k) {
482
- const ee = await x.upload(A.file);
483
- URL.revokeObjectURL(A.url), J.push(ee.id);
522
+ const l = L, c = new Set(o), F = U;
523
+ return f.register(z, async () => {
524
+ const Z = [];
525
+ for (const V of F) {
526
+ const ee = await p.upload(V.file);
527
+ URL.revokeObjectURL(V.url), Z.push(ee.id);
484
528
  }
485
- for (const A of [...l, ...J])
486
- be(K, A), await x.request(
487
- $e(`/items/${n.many_collection}`, {
488
- [j]: i,
489
- [S]: A
529
+ for (const V of [...l, ...Z])
530
+ be(A, V), await p.request(
531
+ Se(`/items/${s.many_collection}`, {
532
+ [O]: n,
533
+ [T]: V
490
534
  })
491
535
  );
492
- for (const A of c) {
493
- be(K, A);
494
- const ee = T.find((tt) => String(tt[S]) === A);
495
- ee != null && ee.id && await x.request(qe(`/items/${n.many_collection}/${ee.id}`));
536
+ for (const V of c) {
537
+ be(A, V);
538
+ const ee = E.find((st) => String(st[T]) === V);
539
+ ee != null && ee.id && await p.request(Pe(`/items/${s.many_collection}/${ee.id}`));
496
540
  }
497
- I([]), $(/* @__PURE__ */ new Set()), _([]), u.invalidateQueries({
498
- queryKey: ["m2m-items", n.many_collection, j, i]
541
+ I([]), R(/* @__PURE__ */ new Set()), C([]), u.invalidateQueries({
542
+ queryKey: ["m2m-items", s.many_collection, O, n]
499
543
  }), u.invalidateQueries({ queryKey: ["file-browser"] });
500
- }), () => m.unregister(Z);
501
- }, [m, h, F, o, U, Z]);
502
- const { data: T = [], isFetched: fe } = we({
503
- queryKey: ["m2m-items", n.many_collection, j, i],
504
- queryFn: () => x.request(
505
- ye(`/items/${n.many_collection}`, {
506
- filter: JSON.stringify({ [j]: { _eq: i } }),
544
+ }), () => f.unregister(z);
545
+ }, [f, g, L, o, U, z]);
546
+ const { data: E = [], isFetched: fe } = we({
547
+ queryKey: ["m2m-items", s.many_collection, O, n],
548
+ queryFn: () => p.request(
549
+ ye(`/items/${s.many_collection}`, {
550
+ filter: JSON.stringify({ [O]: { _eq: n } }),
507
551
  limit: "200",
508
- fields: `id,${S}`
552
+ fields: `id,${T}`
509
553
  })
510
554
  ).then((t) => t.data ?? []),
511
- enabled: !!i && !g,
555
+ enabled: !!n && !k,
512
556
  staleTime: 3e4
513
- }), ae = g && L ? L.getStagedLinks(ne) : [], R = T.map((t) => String(t[S])), v = g ? ae : h ? [...R.filter((t) => !o.has(t)), ...F] : R, V = ct(g || !fe ? null : R, K), M = Me(), H = (M == null ? void 0 : M.collection) ?? n.one_collection ?? null, ie = Xe(g ? [] : R, {
514
- collection: H,
515
- itemId: g ? null : i
516
- }), [_e, pe] = Ve(R.length > 0), y = He(
517
- H,
518
- g ? null : i,
519
- R,
557
+ }), re = k && v ? v.getStagedLinks(se) : [], $ = E.map((t) => String(t[T])), y = k ? re : g ? [...$.filter((t) => !o.has(t)), ...L] : $, J = ut(k || !fe ? null : $, A), Q = Ae(), B = (Q == null ? void 0 : Q.collection) ?? s.one_collection ?? null, ae = Ye(k ? [] : $, {
558
+ collection: B,
559
+ itemId: k ? null : n
560
+ }), [Fe, pe] = De($.length > 0), _ = He(
561
+ B,
562
+ k ? null : n,
563
+ $,
520
564
  pe && W
521
- ), xe = Qe(
522
- H,
523
- g ? null : i,
524
- R,
525
- pe && w
526
- ), ge = Ae(v), { data: re = {} } = we({
527
- queryKey: ["files-meta", ...v.sort()],
565
+ ), xe = Be(
566
+ B,
567
+ k ? null : n,
568
+ $,
569
+ pe && N
570
+ ), ge = Ee(y), { data: ie = {} } = we({
571
+ queryKey: ["files-meta", ...y.sort()],
528
572
  queryFn: async () => {
529
- if (!v.length) return {};
530
- const t = await x.request(
573
+ if (!y.length) return {};
574
+ const t = await p.request(
531
575
  ye("/files", {
532
- filter: JSON.stringify({ id: { _in: v } }),
533
- limit: String(v.length),
576
+ filter: JSON.stringify({ id: { _in: y } }),
577
+ limit: String(y.length),
534
578
  fields: "id,filename_download,title,type,filesize,uploaded_on,uploaded_by_name,missing_at"
535
579
  })
536
580
  ).then((c) => c.data ?? []), l = {};
537
- for (const c of t) l[c.id] = c;
581
+ for (const c of t) l[String(c.id).toLowerCase()] = c;
538
582
  return l;
539
583
  },
540
- enabled: v.length > 0,
584
+ enabled: y.length > 0,
541
585
  staleTime: 6e4,
586
+ // A file linked a moment ago may not read yet: ask again a few times, not for a minute.
587
+ refetchInterval: (t) => {
588
+ const l = t.state.data;
589
+ return !l || t.state.dataUpdateCount > 8 ? !1 : y.some((c) => !l[c.toLowerCase()]) ? 2e3 : !1;
590
+ },
542
591
  // A changed id list keeps the names already known on screen while the new read runs.
543
592
  placeholderData: (t) => t
544
593
  });
545
- for (const [t, l] of Object.entries(re)) {
594
+ for (const [t, l] of Object.entries(ie)) {
546
595
  const c = ue(l);
547
596
  c && he.current.set(t.toLowerCase(), c);
548
597
  }
549
- const oe = V.removed.filter(
550
- (t) => !v.some((l) => l.toLowerCase() === t.toLowerCase())
598
+ const oe = J.removed.filter(
599
+ (t) => !y.some((l) => l.toLowerCase() === t.toLowerCase())
551
600
  );
552
- async function d(t) {
553
- if (be(K, t), g && L) {
554
- L.unstageLink(ne, t);
601
+ async function m(t) {
602
+ if (be(A, t), k && v) {
603
+ v.unstageLink(se, t);
555
604
  return;
556
605
  }
557
- if (h) {
558
- F.includes(t) ? I((c) => c.filter((k) => k !== t)) : $((c) => /* @__PURE__ */ new Set([...c, t]));
606
+ if (g) {
607
+ L.includes(t) ? I((c) => c.filter((F) => F !== t)) : R((c) => /* @__PURE__ */ new Set([...c, t]));
559
608
  return;
560
609
  }
561
- const l = T.find((c) => String(c[S]) === t);
562
- l != null && l.id && (await x.request(qe(`/items/${n.many_collection}/${l.id}`)), u.invalidateQueries({ queryKey: ["m2m-items", n.many_collection, j, i] }));
610
+ const l = E.find((c) => String(c[T]) === t);
611
+ l != null && l.id && (await p.request(Pe(`/items/${s.many_collection}/${l.id}`)), u.invalidateQueries({ queryKey: ["m2m-items", s.many_collection, O, n] }));
563
612
  }
564
- async function q(t) {
565
- if (!v.includes(t)) {
566
- if (be(K, t), g && L) {
567
- L.stageLink(ne, t);
613
+ async function S(t) {
614
+ if (!y.includes(t)) {
615
+ if (be(A, t), k && v) {
616
+ v.stageLink(se, t);
568
617
  return;
569
618
  }
570
- if (h) {
619
+ if (g) {
571
620
  I((l) => l.includes(t) ? l : [...l, t]);
572
621
  return;
573
622
  }
574
- await x.request(
575
- $e(`/items/${n.many_collection}`, { [j]: i, [S]: t })
576
- ), u.invalidateQueries({ queryKey: ["m2m-items", n.many_collection, j, i] });
623
+ await p.request(
624
+ Se(`/items/${s.many_collection}`, { [O]: n, [T]: t })
625
+ ), u.invalidateQueries({ queryKey: ["m2m-items", s.many_collection, O, n] });
577
626
  }
578
627
  }
579
- function D(t) {
580
- URL.revokeObjectURL(t), _((l) => l.filter((c) => c.url !== t));
628
+ function G(t) {
629
+ URL.revokeObjectURL(t), C((l) => l.filter((c) => c.url !== t));
581
630
  }
582
- async function G(t) {
631
+ async function X(t) {
583
632
  const l = Array.from(t.target.files ?? []);
584
633
  if (l.length)
585
- if (a.current && (a.current.value = ""), m) {
586
- const c = l.map((k) => ({ file: k, url: URL.createObjectURL(k) }));
587
- _((k) => [...k, ...c]);
634
+ if (a.current && (a.current.value = ""), f) {
635
+ const c = l.map((F) => ({ file: F, url: URL.createObjectURL(F) }));
636
+ C((F) => [...F, ...c]);
588
637
  } else {
589
638
  Y(!0);
590
639
  try {
591
640
  for (const c of l) {
592
641
  le(null);
593
- const k = await Ee(c, {
594
- cfg: p,
595
- fallback: (J) => x.upload(J),
596
- field: n.one_field ?? void 0,
597
- collection: n.one_collection ?? void 0,
598
- item: g ? void 0 : String(i),
642
+ const F = await Qe(c, {
643
+ cfg: b,
644
+ fallback: (Z) => p.upload(Z),
645
+ field: s.one_field ?? void 0,
646
+ collection: s.one_collection ?? void 0,
647
+ item: k ? void 0 : String(n),
599
648
  onProgress: le
600
649
  });
601
- await q(k.id);
650
+ await S(F.id);
602
651
  }
603
652
  u.invalidateQueries({ queryKey: ["file-browser"] });
604
653
  } catch {
@@ -607,67 +656,72 @@ function St({
607
656
  }
608
657
  }
609
658
  }
610
- return /* @__PURE__ */ r("div", { className: "space-y-2", children: [
659
+ return /* @__PURE__ */ i("div", { className: "space-y-2", children: [
611
660
  /* @__PURE__ */ e(
612
- Ye,
661
+ et,
613
662
  {
614
- collection: n.one_collection,
615
- item: g ? null : String(i),
616
- field: n.one_field
663
+ collection: s.one_collection,
664
+ item: k ? null : String(n),
665
+ field: s.one_field
617
666
  }
618
667
  ),
619
- (v.length > 0 || U.length > 0 || oe.length > 0) && /* @__PURE__ */ r("div", { ref: _e, className: "flex flex-col gap-1.5", children: [
620
- v.map((t) => {
621
- var k, J;
622
- const l = re[t], c = V.fresh.has(t);
623
- return c && !l ? null : /* @__PURE__ */ r(
668
+ (y.length > 0 || U.length > 0 || oe.length > 0) && /* @__PURE__ */ i("div", { ref: Fe, className: "flex flex-col gap-1.5", children: [
669
+ y.map((t) => {
670
+ var F, Z;
671
+ const l = ie[t.toLowerCase()], c = J.fresh.has(t);
672
+ return c && !l ? null : /* @__PURE__ */ i(
624
673
  "div",
625
674
  {
626
675
  "data-file-fresh": c ? "" : void 0,
627
- className: de(
628
- "flex items-center gap-2 rounded-lg border border-slate-200 p-2 bg-slate-50",
676
+ className: ce(
677
+ "flex items-center gap-2 rounded-lg border border-slate-200 p-2 bg-slate-50 dark:border-border dark:bg-white/[0.03]",
629
678
  c && "nvr-row-enter"
630
679
  ),
631
680
  children: [
632
681
  /* @__PURE__ */ e(
633
682
  "a",
634
683
  {
635
- href: `${s(t)}?download=1`,
684
+ href: `${r(t)}?download=1`,
636
685
  download: (l == null ? void 0 : l.filename_download) || !0,
637
- onClick: se(`${s(t)}?download=1`, l == null ? void 0 : l.filename_download),
686
+ onClick: ne(`${r(t)}?download=1`, l == null ? void 0 : l.filename_download),
638
687
  title: "Download",
639
688
  className: "shrink-0",
640
689
  children: /* @__PURE__ */ e(
641
690
  me,
642
691
  {
643
- url: s(t),
692
+ url: r(t),
644
693
  type: (l == null ? void 0 : l.type) ?? null,
645
694
  filename: (l == null ? void 0 : l.filename_download) ?? t,
646
695
  size: "sm",
647
- processing: ie.isProcessing(t)
696
+ processing: ae.isProcessing(t)
648
697
  }
649
698
  )
650
699
  }
651
700
  ),
652
- /* @__PURE__ */ r("div", { className: "flex-1 min-w-0", children: [
653
- ie.isProcessing(t) && /* @__PURE__ */ e("span", { className: "float-right ml-1.5", children: /* @__PURE__ */ e(Ze, {}) }),
654
- /* @__PURE__ */ e(
655
- "a",
656
- {
657
- href: `${s(t)}?download=1`,
658
- download: (l == null ? void 0 : l.filename_download) || !0,
659
- onClick: se(`${s(t)}?download=1`, l == null ? void 0 : l.filename_download),
660
- title: "Download",
661
- "data-file-name": !0,
662
- className: "block w-full truncate text-left text-[12px] font-medium text-slate-700 hover:underline",
663
- children: ue(l) || t
664
- }
665
- ),
666
- /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: [
667
- (l == null ? void 0 : l.type) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: l.type }),
668
- (l == null ? void 0 : l.filesize) != null && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: ke(l.filesize) }),
669
- (l == null ? void 0 : l.uploaded_on) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: Ie(l.uploaded_on) }),
670
- (l == null ? void 0 : l.uploaded_by_name) && /* @__PURE__ */ r("span", { className: "text-[10px] text-slate-500", children: [
701
+ /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
702
+ /* @__PURE__ */ i("div", { className: "flex min-w-0 items-center gap-1.5", children: [
703
+ /* @__PURE__ */ e(
704
+ "a",
705
+ {
706
+ href: `${r(t)}?download=1`,
707
+ download: (l == null ? void 0 : l.filename_download) || !0,
708
+ onClick: ne(`${r(t)}?download=1`, l == null ? void 0 : l.filename_download),
709
+ title: "Download",
710
+ "data-file-name": !0,
711
+ className: "min-w-0 truncate text-left text-[12px] font-medium text-slate-700 hover:underline dark:text-slate-100",
712
+ children: l ? ue(l) || "Untitled file" : (
713
+ // The name is still loading: never show the raw file id.
714
+ /* @__PURE__ */ e("span", { className: "text-slate-400 dark:text-slate-500", children: "Loading name…" })
715
+ )
716
+ }
717
+ ),
718
+ ae.isProcessing(t) && /* @__PURE__ */ e(Ie, {})
719
+ ] }),
720
+ /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: [
721
+ (l == null ? void 0 : l.type) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-500 dark:text-slate-400", children: _e(l.type, l.filename_download) }),
722
+ (l == null ? void 0 : l.filesize) != null && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-500 dark:text-slate-400", children: Ne(l.filesize) }),
723
+ (l == null ? void 0 : l.uploaded_on) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-500 dark:text-slate-400", children: tt(l.uploaded_on) }),
724
+ (l == null ? void 0 : l.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500 dark:text-slate-400", children: [
671
725
  "by ",
672
726
  l.uploaded_by_name
673
727
  ] })
@@ -681,35 +735,35 @@ function St({
681
735
  children: "file missing"
682
736
  }
683
737
  ),
684
- W && !g && R.includes(t) && /* @__PURE__ */ e(
685
- De,
738
+ W && !k && $.includes(t) && /* @__PURE__ */ e(
739
+ Je,
686
740
  {
687
741
  fileId: t,
688
- uses: (k = y.data) == null ? void 0 : k[t],
689
- loading: y.isLoading,
690
- collection: H,
691
- itemId: i
742
+ uses: (F = _.data) == null ? void 0 : F[t],
743
+ loading: _.isLoading,
744
+ collection: B,
745
+ itemId: n
692
746
  }
693
747
  ),
694
- w && !g && R.includes(t) && /* @__PURE__ */ e(Be, { fileId: t, stat: (J = xe.data) == null ? void 0 : J[t] }),
748
+ N && !k && $.includes(t) && /* @__PURE__ */ e(Ve, { fileId: t, stat: (Z = xe.data) == null ? void 0 : Z[t] }),
695
749
  /* @__PURE__ */ e(
696
750
  "a",
697
751
  {
698
- href: `${s(t)}?download=1`,
699
- onClick: se(`${s(t)}?download=1`, l == null ? void 0 : l.filename_download),
752
+ href: `${r(t)}?download=1`,
753
+ onClick: ne(`${r(t)}?download=1`, l == null ? void 0 : l.filename_download),
700
754
  title: "Download",
701
755
  className: "shrink-0 text-slate-400 hover:text-nvr-cyan p-0.5",
702
756
  children: /* @__PURE__ */ e(ze, { className: "h-3.5 w-3.5" })
703
757
  }
704
758
  ),
705
- !f && /* @__PURE__ */ e(
759
+ !h && /* @__PURE__ */ e(
706
760
  "button",
707
761
  {
708
762
  type: "button",
709
763
  "aria-label": "Remove file",
710
- onClick: () => d(t),
764
+ onClick: () => m(t),
711
765
  className: "text-slate-300 hover:text-red-400 p-0.5 shrink-0",
712
- children: /* @__PURE__ */ e(Ne, { className: "h-3.5 w-3.5" })
766
+ children: /* @__PURE__ */ e(ke, { className: "h-3.5 w-3.5" })
713
767
  }
714
768
  )
715
769
  ]
@@ -718,14 +772,17 @@ function St({
718
772
  );
719
773
  }),
720
774
  oe.map((t) => /* @__PURE__ */ e(
721
- Je,
775
+ Xe,
722
776
  {
723
777
  name: he.current.get(t.toLowerCase()) ?? "A file",
724
- leaving: V.leaving.has(t)
778
+ leaving: J.leaving.has(t),
779
+ by: Ze(
780
+ u.getQueryData(["last-touch", B, String(n)])
781
+ )
725
782
  },
726
783
  `removed-${t}`
727
784
  )),
728
- U.map((t) => /* @__PURE__ */ r(
785
+ U.map((t) => /* @__PURE__ */ i(
729
786
  "div",
730
787
  {
731
788
  className: "flex items-center gap-2 rounded-lg border border-amber-200 p-2 bg-amber-50/50",
@@ -739,25 +796,32 @@ function St({
739
796
  size: "sm"
740
797
  }
741
798
  ),
742
- /* @__PURE__ */ r("div", { className: "flex-1 min-w-0", children: [
743
- /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
799
+ /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
800
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
744
801
  /* @__PURE__ */ e(Oe, { className: "h-3 w-3 text-amber-400 shrink-0" }),
745
- /* @__PURE__ */ e("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: t.file.name })
802
+ /* @__PURE__ */ e(
803
+ "p",
804
+ {
805
+ "data-file-name": !0,
806
+ className: "text-[12px] font-medium text-slate-700 truncate dark:text-slate-100",
807
+ children: t.file.name
808
+ }
809
+ )
746
810
  ] }),
747
- /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: [
748
- t.file.type && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: t.file.type }),
749
- /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: ke(t.file.size) }),
811
+ /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: [
812
+ t.file.type && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-500 dark:text-slate-400", children: _e(t.file.type, t.file.name) }),
813
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: Ne(t.file.size) }),
750
814
  /* @__PURE__ */ e("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
751
815
  ] })
752
816
  ] }),
753
- !f && /* @__PURE__ */ e(
817
+ !h && /* @__PURE__ */ e(
754
818
  "button",
755
819
  {
756
820
  type: "button",
757
821
  "aria-label": "Remove file",
758
- onClick: () => D(t.url),
822
+ onClick: () => G(t.url),
759
823
  className: "text-slate-300 hover:text-red-400 p-0.5 shrink-0",
760
- children: /* @__PURE__ */ e(Ne, { className: "h-3.5 w-3.5" })
824
+ children: /* @__PURE__ */ e(ke, { className: "h-3.5 w-3.5" })
761
825
  }
762
826
  )
763
827
  ]
@@ -765,40 +829,40 @@ function St({
765
829
  t.url
766
830
  ))
767
831
  ] }),
768
- !f && /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
769
- P && /* @__PURE__ */ r("div", { className: "relative", children: [
770
- /* @__PURE__ */ r(
832
+ !h && /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
833
+ P && /* @__PURE__ */ i("div", { className: "relative", children: [
834
+ /* @__PURE__ */ i(
771
835
  "button",
772
836
  {
773
837
  type: "button",
774
838
  onClick: () => te((t) => !t),
775
- 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",
839
+ 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 dark:border-border dark:text-slate-400 dark:hover:border-slate-500 dark:hover:text-slate-200 transition-colors",
776
840
  children: [
777
- /* @__PURE__ */ e(lt, { className: "h-3.5 w-3.5" }),
841
+ /* @__PURE__ */ e(nt, { className: "h-3.5 w-3.5" }),
778
842
  "Add existing…"
779
843
  ]
780
844
  }
781
845
  ),
782
- O && /* @__PURE__ */ e(
846
+ j && /* @__PURE__ */ e(
783
847
  "div",
784
848
  {
785
849
  className: "absolute z-50 mt-1 rounded-lg border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card",
786
850
  style: { minWidth: 480 },
787
851
  children: /* @__PURE__ */ e(
788
- et,
852
+ lt,
789
853
  {
790
- selected: v,
854
+ selected: y,
791
855
  multi: !0,
792
- onSelect: (t) => q(t),
856
+ onSelect: (t) => S(t),
793
857
  onClose: () => te(!1),
794
- getUrl: s
858
+ getUrl: r
795
859
  }
796
860
  )
797
861
  }
798
862
  )
799
863
  ] }),
800
- C && /* @__PURE__ */ r(ce, { children: [
801
- /* @__PURE__ */ r(
864
+ x && /* @__PURE__ */ i(de, { children: [
865
+ /* @__PURE__ */ i(
802
866
  "button",
803
867
  {
804
868
  type: "button",
@@ -806,11 +870,11 @@ function St({
806
870
  var t;
807
871
  return (t = a.current) == null ? void 0 : t.click();
808
872
  },
809
- disabled: z,
810
- 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",
873
+ disabled: M,
874
+ 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 dark:border-border dark:text-slate-400 dark:hover:border-slate-500 dark:hover:text-slate-200 disabled:opacity-40 transition-colors",
811
875
  children: [
812
- z ? /* @__PURE__ */ e(ve, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(Re, { className: "h-3.5 w-3.5" }),
813
- /* @__PURE__ */ e("span", { className: "tabular-nums", children: z && B != null ? `Uploading ${B}%` : "Upload…" })
876
+ M ? /* @__PURE__ */ e(ve, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(Le, { className: "h-3.5 w-3.5" }),
877
+ /* @__PURE__ */ e("span", { className: "tabular-nums", children: M && H != null ? `Uploading ${H}%` : "Upload…" })
814
878
  ]
815
879
  }
816
880
  ),
@@ -821,7 +885,7 @@ function St({
821
885
  type: "file",
822
886
  multiple: !0,
823
887
  className: "hidden",
824
- onChange: G
888
+ onChange: X
825
889
  }
826
890
  )
827
891
  ] })
@@ -829,7 +893,8 @@ function St({
829
893
  ] });
830
894
  }
831
895
  export {
832
- St as FileM2MField,
833
- Pt as FilePickerField,
834
- ue as fileDisplayName
896
+ Tt as FileM2MField,
897
+ jt as FilePickerField,
898
+ ue as fileDisplayName,
899
+ _e as friendlyFileType
835
900
  };