@nivaro/react 0.3.114 → 0.3.115

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 (281) hide show
  1. package/dist/components/ScreenShareHost.js +24 -0
  2. package/dist/full.css +50 -2
  3. package/dist/hooks/useSessionRecorder.js +61 -60
  4. package/dist/index.d.ts +1717 -21
  5. package/dist/index.js +1091 -950
  6. package/dist/shared/components/ActivityEntry.js +209 -97
  7. package/dist/shared/components/AgentPresenceChip.js +51 -0
  8. package/dist/shared/components/AnnouncementBanner.js +56 -41
  9. package/dist/shared/components/AutolinkedText.js +98 -85
  10. package/dist/shared/components/BroadcastView.js +149 -141
  11. package/dist/shared/components/CacheStamp.js +78 -30
  12. package/dist/shared/components/CollectionBrowserView.js +4088 -3592
  13. package/dist/shared/components/ConfigChangeStrip.js +63 -0
  14. package/dist/shared/components/ConfigReachNote.js +107 -0
  15. package/dist/shared/components/ConformanceView.js +389 -319
  16. package/dist/shared/components/DataTable.js +1 -0
  17. package/dist/shared/components/DelegateCoverLine.js +164 -0
  18. package/dist/shared/components/EnvironmentNotice.js +56 -65
  19. package/dist/shared/components/FilePreviewLightbox.js +89 -43
  20. package/dist/shared/components/FindingFixedMark.js +23 -0
  21. package/dist/shared/components/GridPresenceLine.js +100 -0
  22. package/dist/shared/components/IdleReloadWatcher.js +82 -43
  23. package/dist/shared/components/InStep.js +46 -0
  24. package/dist/shared/components/ItemEditForm.js +5504 -4889
  25. package/dist/shared/components/LiveAnnouncer.js +62 -0
  26. package/dist/shared/components/LiveCount.js +54 -0
  27. package/dist/shared/components/LiveFigure.js +28 -0
  28. package/dist/shared/components/LiveListControls.js +114 -0
  29. package/dist/shared/components/LiveNewMatchesPill.js +25 -0
  30. package/dist/shared/components/LiveOffNote.js +44 -0
  31. package/dist/shared/components/LivePreferenceHost.js +42 -0
  32. package/dist/shared/components/LiveRowMark.js +25 -20
  33. package/dist/shared/components/LiveTraceView.js +257 -0
  34. package/dist/shared/components/MapView.js +30 -29
  35. package/dist/shared/components/MatrixEditor.js +497 -462
  36. package/dist/shared/components/MyWorkView.js +346 -272
  37. package/dist/shared/components/NotificationBell.js +215 -201
  38. package/dist/shared/components/PageRenderer.js +636 -599
  39. package/dist/shared/components/PresenceDot.js +21 -0
  40. package/dist/shared/components/ProfileView.js +656 -536
  41. package/dist/shared/components/RealtimeStatusBanner.js +25 -25
  42. package/dist/shared/components/RecentRecordsRail.js +51 -48
  43. package/dist/shared/components/RecordCompare.js +241 -150
  44. package/dist/shared/components/RecordDrilldownSheet.js +66 -64
  45. package/dist/shared/components/RecordGridEditor.js +350 -311
  46. package/dist/shared/components/RecordHoverCard.js +147 -0
  47. package/dist/shared/components/RecordPeekHost.js +111 -0
  48. package/dist/shared/components/RecordReadView.js +414 -412
  49. package/dist/shared/components/RelativeTime.js +16 -0
  50. package/dist/shared/components/ReportView.js +1396 -1304
  51. package/dist/shared/components/ScreenRefreshButton.js +77 -0
  52. package/dist/shared/components/TabCountHost.js +10 -0
  53. package/dist/shared/components/TickerNumber.js +19 -18
  54. package/dist/shared/components/TipLayer.js +70 -58
  55. package/dist/shared/components/WidgetImageMenu.js +59 -0
  56. package/dist/shared/components/WidgetSlot.js +571 -524
  57. package/dist/shared/components/activity/RecordActivityStream.js +317 -0
  58. package/dist/shared/components/bulk/BulkSelectionNotices.js +220 -0
  59. package/dist/shared/components/cbv/approval-changed.js +20 -0
  60. package/dist/shared/components/cbv/changed-by-others.js +251 -0
  61. package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +320 -0
  62. package/dist/shared/components/change-proposals/ProposalValue.js +28 -0
  63. package/dist/shared/components/change-proposals/ProposeChangeButton.js +44 -0
  64. package/dist/shared/components/change-proposals/ProposeChangeDialog.js +359 -0
  65. package/dist/shared/components/change-proposals/types.js +4 -0
  66. package/dist/shared/components/chat/ChatPanel.js +1571 -1528
  67. package/dist/shared/components/chat/Composer.js +276 -298
  68. package/dist/shared/components/chat/room-due.js +13 -0
  69. package/dist/shared/components/collections-directory/CollectionRow.js +76 -75
  70. package/dist/shared/components/collections-directory/CollectionsDirectory.js +415 -395
  71. package/dist/shared/components/collections-directory/directory-data.js +75 -63
  72. package/dist/shared/components/imports/ImportConsole.js +159 -155
  73. package/dist/shared/components/imports/ImportDuplicatesNotice.js +46 -31
  74. package/dist/shared/components/integrations/SendStatus.js +202 -0
  75. package/dist/shared/components/integrations/console/IntegrationsConsole.js +45 -36
  76. package/dist/shared/components/integrations/console/ReadyToSendView.js +453 -0
  77. package/dist/shared/components/integrations/console/api.js +161 -117
  78. package/dist/shared/components/integrations/console/tone.js +15 -12
  79. package/dist/shared/components/item-edit/CatalogPickerField.js +1353 -1245
  80. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +162 -0
  81. package/dist/shared/components/item-edit/CloneDialog.js +208 -206
  82. package/dist/shared/components/item-edit/DerivedCauseNote.js +57 -0
  83. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +81 -70
  84. package/dist/shared/components/item-edit/DuplicateNotice.js +169 -101
  85. package/dist/shared/components/item-edit/FieldAffordances.js +294 -385
  86. package/dist/shared/components/item-edit/FieldComments.js +159 -116
  87. package/dist/shared/components/item-edit/FieldPointer.js +132 -0
  88. package/dist/shared/components/item-edit/FieldRenderer.js +277 -273
  89. package/dist/shared/components/item-edit/FieldRow.js +519 -439
  90. package/dist/shared/components/item-edit/FieldSourceBadge.js +88 -0
  91. package/dist/shared/components/item-edit/FilePickerField.js +454 -369
  92. package/dist/shared/components/item-edit/GroupSection.js +618 -567
  93. package/dist/shared/components/item-edit/HeldEditsChip.js +113 -0
  94. package/dist/shared/components/item-edit/InlineTableField.js +2891 -2723
  95. package/dist/shared/components/item-edit/ListNeighborNav.js +79 -0
  96. package/dist/shared/components/item-edit/LiveTraceSheet.js +26 -0
  97. package/dist/shared/components/item-edit/M2MCombobox.js +284 -273
  98. package/dist/shared/components/item-edit/OutboxReviewTray.js +313 -0
  99. package/dist/shared/components/item-edit/PickerBadges.js +52 -0
  100. package/dist/shared/components/item-edit/PlanGrid.js +434 -439
  101. package/dist/shared/components/item-edit/RecalcValue.js +55 -0
  102. package/dist/shared/components/item-edit/RecordChatActions.js +76 -64
  103. package/dist/shared/components/item-edit/RecordChatMentionsChip.js +103 -0
  104. package/dist/shared/components/item-edit/RecordGrantTools.js +87 -86
  105. package/dist/shared/components/item-edit/RecordHelpChip.js +70 -0
  106. package/dist/shared/components/item-edit/RecordLiveSync.js +230 -217
  107. package/dist/shared/components/item-edit/RecordOutbox.js +53 -52
  108. package/dist/shared/components/item-edit/RecordRecapStrip.js +109 -36
  109. package/dist/shared/components/item-edit/RelationCombobox.js +229 -217
  110. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +105 -100
  111. package/dist/shared/components/item-edit/RemoteChangeUi.js +454 -0
  112. package/dist/shared/components/item-edit/RemoteUploads.js +55 -0
  113. package/dist/shared/components/item-edit/RemovedLineNote.js +92 -0
  114. package/dist/shared/components/item-edit/RichTextEditorImpl.js +298 -223
  115. package/dist/shared/components/item-edit/ScheduledChangeChip.js +244 -0
  116. package/dist/shared/components/item-edit/SectionPresence.js +78 -0
  117. package/dist/shared/components/item-edit/SplitLinesButton.js +166 -0
  118. package/dist/shared/components/item-edit/catalog-line-watch.js +94 -0
  119. package/dist/shared/components/item-edit/coedit/collab.js +84 -0
  120. package/dist/shared/components/item-edit/coedit/context.js +24 -0
  121. package/dist/shared/components/item-edit/coedit/cursors.js +103 -0
  122. package/dist/shared/components/item-edit/coedit/safe-link.js +15 -0
  123. package/dist/shared/components/item-edit/coedit/session.js +382 -0
  124. package/dist/shared/components/item-edit/coedit/useCoedit.js +49 -0
  125. package/dist/shared/components/item-edit/file-live.js +77 -0
  126. package/dist/shared/components/item-edit/file-processing.js +87 -0
  127. package/dist/shared/components/item-edit/layout-switch.js +148 -0
  128. package/dist/shared/components/item-edit/live-related.js +23 -0
  129. package/dist/shared/components/item-edit/live-title.js +66 -0
  130. package/dist/shared/components/item-edit/partner-needs.js +142 -0
  131. package/dist/shared/components/item-edit/removed-line.js +58 -0
  132. package/dist/shared/components/item-edit/render-stability.js +70 -59
  133. package/dist/shared/components/layout-editor/ChangeNote.js +36 -34
  134. package/dist/shared/components/layout-editor/CollabParts.js +72 -70
  135. package/dist/shared/components/layout-editor/LayoutEditor.js +306 -303
  136. package/dist/shared/components/list/InlineEdit.js +504 -208
  137. package/dist/shared/components/list/ListViewers.js +81 -0
  138. package/dist/shared/components/merge/MergeRecordsDialog.js +1227 -0
  139. package/dist/shared/components/merge/MergeWithFlow.js +290 -0
  140. package/dist/shared/components/merge/merge-values.js +110 -0
  141. package/dist/shared/components/monitoring/InactiveUserLinksView.js +285 -258
  142. package/dist/shared/components/notifications/NotificationCenterView.js +388 -321
  143. package/dist/shared/components/notifications/NotificationDetailBits.js +205 -130
  144. package/dist/shared/components/notifications/NotificationRulesEditor.js +72 -52
  145. package/dist/shared/components/notifications/bundles.js +21 -19
  146. package/dist/shared/components/notifications/resolved-line.js +25 -0
  147. package/dist/shared/components/ops/OpsTasksView.js +45 -44
  148. package/dist/shared/components/panels/AccessGrantedNote.js +85 -0
  149. package/dist/shared/components/panels/AlertBanners.js +132 -0
  150. package/dist/shared/components/panels/AsyncUserPicker.js +54 -45
  151. package/dist/shared/components/panels/BranchLanes.js +82 -54
  152. package/dist/shared/components/panels/CommentAwareness.js +332 -0
  153. package/dist/shared/components/panels/CommentImages.js +219 -0
  154. package/dist/shared/components/panels/CommentPanel.js +649 -530
  155. package/dist/shared/components/panels/ExternalRequestsChip.js +98 -80
  156. package/dist/shared/components/panels/NewSinceChip.js +16 -0
  157. package/dist/shared/components/panels/OwnerOpenedLine.js +85 -0
  158. package/dist/shared/components/panels/PipelinePanel.js +1644 -1494
  159. package/dist/shared/components/panels/ResubmissionDiff.js +293 -0
  160. package/dist/shared/components/panels/SlaBreachBanner.js +30 -29
  161. package/dist/shared/components/panels/SlaClock.js +130 -99
  162. package/dist/shared/components/panels/TaskPanel.js +308 -287
  163. package/dist/shared/components/panels/unseen-move-check.js +101 -0
  164. package/dist/shared/components/pipeline/OwnerMatrix.js +80 -71
  165. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +495 -0
  166. package/dist/shared/components/pipeline/PipelineEditorView.js +1855 -1771
  167. package/dist/shared/components/profile/AgentNameField.js +141 -0
  168. package/dist/shared/components/profile/AgentsPanel.js +55 -46
  169. package/dist/shared/components/profile/PersonAccess.js +398 -330
  170. package/dist/shared/components/profile/PersonAdminTools.js +127 -113
  171. package/dist/shared/components/profile/PersonProfile.js +81 -73
  172. package/dist/shared/components/profile/SignInTroubleshooter.js +361 -0
  173. package/dist/shared/components/queue/QueueBulkBar.js +101 -84
  174. package/dist/shared/components/queue/QueueItemSheet.js +66 -66
  175. package/dist/shared/components/queue/QueueTeamStrip.js +279 -0
  176. package/dist/shared/components/queue/QueueWorklist.js +1927 -1635
  177. package/dist/shared/components/send-view/SendViewButton.js +136 -0
  178. package/dist/shared/components/send-view/SentViewCards.js +147 -0
  179. package/dist/shared/components/support/ReportProblem.js +1 -0
  180. package/dist/shared/components/support/ScreenShare.js +554 -0
  181. package/dist/shared/components/support/SupportView.js +160 -129
  182. package/dist/shared/components/support/TicketDetailSheet.js +101 -89
  183. package/dist/shared/components/watch-list/WatchDock.js +1044 -0
  184. package/dist/shared/components/watch-list/WatchExtras.js +723 -0
  185. package/dist/shared/components/watch-list/WatchListButton.js +46 -0
  186. package/dist/shared/components/watch-list/WatchPinButton.js +67 -0
  187. package/dist/shared/components/watch-list/WatchRows.js +348 -0
  188. package/dist/shared/lib/activity-sentence.js +87 -75
  189. package/dist/shared/lib/agent-presence.js +46 -0
  190. package/dist/shared/lib/approval-progress.js +49 -0
  191. package/dist/shared/lib/attention-prefs.js +27 -0
  192. package/dist/shared/lib/cell-locks.js +56 -0
  193. package/dist/shared/lib/co-edit.js +166 -0
  194. package/dist/shared/lib/coedit-registry.js +44 -0
  195. package/dist/shared/lib/comment-awareness.js +124 -0
  196. package/dist/shared/lib/comment-images.js +45 -0
  197. package/dist/shared/lib/config-watch.js +94 -0
  198. package/dist/shared/lib/copy-rules.js +65 -0
  199. package/dist/shared/lib/count-step.js +30 -0
  200. package/dist/shared/lib/deadline-ticker.js +68 -0
  201. package/dist/shared/lib/derived-causes.js +115 -0
  202. package/dist/shared/lib/draft-store.js +114 -85
  203. package/dist/shared/lib/error-hints.js +1 -0
  204. package/dist/shared/lib/field-merge.js +126 -0
  205. package/dist/shared/lib/filter-sentence.js +10 -10
  206. package/dist/shared/lib/focus-mode.js +16 -12
  207. package/dist/shared/lib/grid-cursors.js +77 -0
  208. package/dist/shared/lib/grid-presence.js +182 -0
  209. package/dist/shared/lib/idle-reload.js +100 -73
  210. package/dist/shared/lib/in-step.js +45 -0
  211. package/dist/shared/lib/integration-chip.js +19 -18
  212. package/dist/shared/lib/line-locks.js +141 -0
  213. package/dist/shared/lib/line-split.js +41 -0
  214. package/dist/shared/lib/linked-changes.js +150 -0
  215. package/dist/shared/lib/list-return.js +231 -0
  216. package/dist/shared/lib/list-viewers.js +52 -0
  217. package/dist/shared/lib/live-announcer.js +86 -0
  218. package/dist/shared/lib/live-counts.js +85 -0
  219. package/dist/shared/lib/live-data-changed.js +108 -0
  220. package/dist/shared/lib/live-deltas.js +81 -0
  221. package/dist/shared/lib/live-findings.js +113 -0
  222. package/dist/shared/lib/live-groups.js +122 -0
  223. package/dist/shared/lib/live-link-labels.js +162 -0
  224. package/dist/shared/lib/live-list-flow.js +334 -0
  225. package/dist/shared/lib/live-list.js +143 -129
  226. package/dist/shared/lib/live-moves.js +51 -0
  227. package/dist/shared/lib/live-ops.js +26 -26
  228. package/dist/shared/lib/live-pickers.js +7 -0
  229. package/dist/shared/lib/live-preference.js +184 -0
  230. package/dist/shared/lib/live-queries.js +226 -181
  231. package/dist/shared/lib/live-screen.js +333 -0
  232. package/dist/shared/lib/live-search.js +108 -0
  233. package/dist/shared/lib/live-seen.js +35 -0
  234. package/dist/shared/lib/live-views.js +100 -0
  235. package/dist/shared/lib/live.js +159 -133
  236. package/dist/shared/lib/missed-updates.js +198 -0
  237. package/dist/shared/lib/newer-file.js +56 -0
  238. package/dist/shared/lib/notification-sound.js +42 -20
  239. package/dist/shared/lib/own-writes.js +59 -41
  240. package/dist/shared/lib/picker-badges.js +94 -0
  241. package/dist/shared/lib/presence-signals.js +131 -84
  242. package/dist/shared/lib/realtime.js +49 -24
  243. package/dist/shared/lib/record-gaps.js +85 -0
  244. package/dist/shared/lib/record-outbox.js +369 -222
  245. package/dist/shared/lib/record-peek.js +75 -0
  246. package/dist/shared/lib/record-tabs.js +92 -72
  247. package/dist/shared/lib/relative-ticker.js +42 -0
  248. package/dist/shared/lib/request-gate.js +119 -119
  249. package/dist/shared/lib/rollup-recalc.js +107 -0
  250. package/dist/shared/lib/room-gaps.js +40 -36
  251. package/dist/shared/lib/rum.js +137 -87
  252. package/dist/shared/lib/save-progress.js +20 -0
  253. package/dist/shared/lib/scheduled-countdown.js +67 -0
  254. package/dist/shared/lib/screen-refresh.js +160 -0
  255. package/dist/shared/lib/screen-share.js +234 -0
  256. package/dist/shared/lib/seen-since.js +74 -0
  257. package/dist/shared/lib/selection-watch.js +205 -0
  258. package/dist/shared/lib/send-status.js +132 -0
  259. package/dist/shared/lib/send-view.js +23 -0
  260. package/dist/shared/lib/socket-liveness.js +155 -0
  261. package/dist/shared/lib/socket-realtime.js +168 -140
  262. package/dist/shared/lib/state-census.js +53 -0
  263. package/dist/shared/lib/summary-mode.js +61 -39
  264. package/dist/shared/lib/tab-attention.js +143 -32
  265. package/dist/shared/lib/table-density.js +64 -0
  266. package/dist/shared/lib/track-travel.js +40 -0
  267. package/dist/shared/lib/unseen-changes.js +68 -0
  268. package/dist/shared/lib/upload-file.js +33 -0
  269. package/dist/shared/lib/upload-presence.js +127 -0
  270. package/dist/shared/lib/urgent-chime.js +65 -0
  271. package/dist/shared/lib/use-online-users.js +32 -11
  272. package/dist/shared/lib/user-sync.js +155 -39
  273. package/dist/shared/lib/waiting-count.js +44 -0
  274. package/dist/shared/lib/watch-desktop.js +83 -0
  275. package/dist/shared/lib/watch-list.js +447 -0
  276. package/dist/shared/lib/widget-image-render.js +64 -0
  277. package/dist/shared/lib/widget-image.js +111 -0
  278. package/dist/shared/lib/worker-socket.js +130 -104
  279. package/dist/shared/lib/write-to-screen.js +133 -0
  280. package/package.json +1 -1
  281. package/styles.css +49 -1
@@ -1,107 +1,108 @@
1
- import { jsxs as u, jsx as s, Fragment as Ne } from "react/jsx-runtime";
2
- import { useQueryClient as Zr, useQuery as Q, useQueries as fn } from "@tanstack/react-query";
3
- import { Search as Kt, Loader2 as ue, PackageCheck as Gr, ChevronRight as Ct, Star as ct, AlertTriangle as He, AlertCircle as un, X as ut, Plus as cr, ChevronDown as Xr } from "lucide-react";
4
- import { useState as D, useRef as qe, useMemo as E, useEffect as $e, Fragment as ot } from "react";
5
- import { createPortal as es } from "react-dom";
6
- import { useNivaroClient as mt, useParentDraft as ts, useReimportHandler as ns, useItemEditAuth as sr } from "../../context.js";
7
- import { canOpenCatalogItem as ur, openCatalogItem as mr } from "../../lib/catalog-item-open.js";
8
- import { get as J, del as rs, patch as ar, post as ir } from "../../lib/commands.js";
9
- import { evaluateBoolean as ss } from "../../lib/expression.js";
10
- import { useLiveRefetchInterval as as } from "../../lib/live-queries.js";
11
- import { fetchCollectionRelations as pn, queryKeys as At } from "../../lib/query-keys.js";
12
- import { tokenize as is, matchesSearch as ls } from "../../lib/search-text.js";
13
- import { registerStagedRowLabel as os } from "../../lib/staged-row-labels.js";
14
- import { submissionLineErrors as ds, normalizeIdent as cs } from "../../lib/submission-errors.js";
15
- import { titleCase as X, cn as W, matchesAllTokens as us } from "../../lib/utils.js";
16
- import { ImportFromFileButton as ms } from "../import/ImportFromFileButton.js";
17
- import { SearchHighlight as hn } from "../SearchHighlight.js";
18
- import { useOverflowTip as fs } from "../TipLayer.js";
19
- import { useColumnWidths as lr, ResetColumnsButton as mn, ColResizeHandle as ps, fitWidth as hs } from "./catalog-columns.js";
20
- import { facetsComplete as bs, facetResults as xs, facetOptions as ys, setFacetPick as gs } from "./catalog-facets.js";
21
- import { orderCatalogMatches as ks, rowMatchesFields as ws } from "./catalog-search.js";
22
- import { applyDisplayTemplate as Ke } from "./helpers.js";
1
+ import { jsxs as u, jsx as a, Fragment as Se } from "react/jsx-runtime";
2
+ import { useQueryClient as is, useQuery as Q, useQueries as xn } from "@tanstack/react-query";
3
+ import { Search as Ct, Loader2 as ue, PackageCheck as ls, ChevronRight as Jt, Star as ft, AlertTriangle as Ae, AlertCircle as hn, X as pt, Plus as xr, ChevronDown as os } from "lucide-react";
4
+ import { useState as D, useRef as je, useMemo as R, useEffect as Fe, Fragment as ut } from "react";
5
+ import { createPortal as ds } from "react-dom";
6
+ import { useNivaroClient as ht, useParentDraft as cs, useReimportHandler as us, useItemEditAuth as ur } from "../../context.js";
7
+ import { canOpenCatalogItem as yr, openCatalogItem as gr } from "../../lib/catalog-item-open.js";
8
+ import { get as C, del as ms, patch as mr, post as fr } from "../../lib/commands.js";
9
+ import { evaluateBoolean as fs } from "../../lib/expression.js";
10
+ import { useLiveRefetchInterval as ps } from "../../lib/live-queries.js";
11
+ import { fetchCollectionRelations as yn, queryKeys as At } from "../../lib/query-keys.js";
12
+ import { tokenize as hs, matchesSearch as bs } from "../../lib/search-text.js";
13
+ import { registerStagedRowLabel as xs } from "../../lib/staged-row-labels.js";
14
+ import { submissionLineErrors as ys, normalizeIdent as gs } from "../../lib/submission-errors.js";
15
+ import { titleCase as Z, cn as W, matchesAllTokens as ks } from "../../lib/utils.js";
16
+ import { ImportFromFileButton as ws } from "../import/ImportFromFileButton.js";
17
+ import { SearchHighlight as gn } from "../SearchHighlight.js";
18
+ import { useOverflowTip as Ns } from "../TipLayer.js";
19
+ import { useColumnWidths as pr, ResetColumnsButton as bn, ColResizeHandle as vs, fitWidth as Ss } from "./catalog-columns.js";
20
+ import { facetsComplete as _s, facetResults as qs, facetOptions as $s, setFacetPick as js } from "./catalog-facets.js";
21
+ import { usePlaceName as Fs, useCatalogLineLive as Ts, stockShortText as Rs, catalogPriceText as Os, linePriceChange as Ps } from "./catalog-line-watch.js";
22
+ import { orderCatalogMatches as Ls, rowMatchesFields as Es } from "./catalog-search.js";
23
+ import { applyDisplayTemplate as Ce } from "./helpers.js";
23
24
  import { evalClientFormula as Ee } from "./InlineTableField.js";
24
- import { isIntegerFieldType as dt, checkNumberEntry as bn, mergePendingQtyRow as Ns, decimalPlacesProblem as vs, lineRuleErrors as Ss, MAX_LINE_MONEY as _s } from "./line-qty.js";
25
- import { resolveM2MRelatedCollection as qs } from "./M2MCombobox.js";
26
- import { useO2MStaging as $s } from "./O2MStagingContext.js";
27
- import { RelationCombobox as js, RelatedItemLabel as Fs } from "./RelationCombobox.js";
28
- const fr = (i, m) => {
29
- let f = i;
30
- for (const x of m.split(".")) {
31
- if (f == null || typeof f != "object") return;
32
- f = f[x];
25
+ import { isIntegerFieldType as mt, checkNumberEntry as kn, mergePendingQtyRow as Ks, decimalPlacesProblem as As, lineRuleErrors as Cs, MAX_LINE_MONEY as Js } from "./line-qty.js";
26
+ import { resolveM2MRelatedCollection as Is } from "./M2MCombobox.js";
27
+ import { useO2MStaging as Qs } from "./O2MStagingContext.js";
28
+ import { RelationCombobox as zs, RelatedItemLabel as Us } from "./RelationCombobox.js";
29
+ const kr = (i, m) => {
30
+ let p = i;
31
+ for (const g of m.split(".")) {
32
+ if (p == null || typeof p != "object") return;
33
+ p = p[g];
33
34
  }
34
- return f;
35
+ return p;
35
36
  };
36
- async function Jt(i, m, f) {
37
- const x = [];
37
+ async function It(i, m, p) {
38
+ const g = [];
38
39
  for (let _ = 1; _ <= 50; _++) {
39
- const a = await i.request(J(m, { ...f, limit: 1e3, page: _ })).then((w) => w.data ?? []);
40
- if (x.push(...a), a.length < 1e3) break;
40
+ const s = await i.request(C(m, { ...p, limit: 1e3, page: _ })).then((k) => k.data ?? []);
41
+ if (g.push(...s), s.length < 1e3) break;
41
42
  }
42
- return x;
43
+ return g;
43
44
  }
44
- function Ts(i, m, f, x) {
45
- const _ = {}, a = { ...x ?? {} };
46
- for (const w of m) {
47
- const k = i[w], T = k == null || k === "", v = !T && (x == null ? void 0 : x[w]) !== void 0 && x[w] === String(k);
48
- if (!T && !v) continue;
49
- const R = f(w);
50
- R == null || R === "" || !T && String(R) === String(k) || (_[w] = R, a[w] = String(R));
45
+ function Ms(i, m, p, g) {
46
+ const _ = {}, s = { ...g ?? {} };
47
+ for (const k of m) {
48
+ const w = i[k], O = w == null || w === "", v = !O && (g == null ? void 0 : g[k]) !== void 0 && g[k] === String(w);
49
+ if (!O && !v) continue;
50
+ const L = p(k);
51
+ L == null || L === "" || !O && String(L) === String(w) || (_[k] = L, s[k] = String(L));
51
52
  }
52
- return Object.keys(_).length > 0 ? { updates: _, auto: a } : null;
53
+ return Object.keys(_).length > 0 ? { updates: _, auto: s } : null;
53
54
  }
54
- function xn(i, m = /* @__PURE__ */ new Set()) {
55
+ function wn(i, m = /* @__PURE__ */ new Set()) {
55
56
  if (typeof i == "string" && i.startsWith("$parent.")) m.add(i.slice(8));
56
- else if (Array.isArray(i)) for (const f of i) xn(f, m);
57
+ else if (Array.isArray(i)) for (const p of i) wn(p, m);
57
58
  else if (i && typeof i == "object")
58
- for (const f of Object.values(i)) xn(f, m);
59
+ for (const p of Object.values(i)) wn(p, m);
59
60
  return m;
60
61
  }
61
- function Ye(i, m) {
62
- const f = {};
63
- let x = !1;
64
- const _ = (a) => {
65
- if (typeof a == "string" && a.startsWith("$parent.")) {
66
- const w = m == null ? void 0 : m[a.slice(8)];
67
- return w == null || w === "" ? (x = !0, a) : w;
62
+ function Ge(i, m) {
63
+ const p = {};
64
+ let g = !1;
65
+ const _ = (s) => {
66
+ if (typeof s == "string" && s.startsWith("$parent.")) {
67
+ const k = m == null ? void 0 : m[s.slice(8)];
68
+ return k == null || k === "" ? (g = !0, s) : k;
68
69
  }
69
- return Array.isArray(a) ? a.map(_) : a && typeof a == "object" ? Object.fromEntries(Object.entries(a).map(([w, k]) => [w, _(k)])) : a;
70
+ return Array.isArray(s) ? s.map(_) : s && typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([k, w]) => [k, _(w)])) : s;
70
71
  };
71
- for (const [a, w] of Object.entries(i ?? {}))
72
- if (typeof w == "string" && w.startsWith("$parent.")) {
73
- const k = m == null ? void 0 : m[w.slice(8)];
74
- if (k == null || k === "") {
75
- x = !0;
72
+ for (const [s, k] of Object.entries(i ?? {}))
73
+ if (typeof k == "string" && k.startsWith("$parent.")) {
74
+ const w = m == null ? void 0 : m[k.slice(8)];
75
+ if (w == null || w === "") {
76
+ g = !0;
76
77
  continue;
77
78
  }
78
- f[a] = { _eq: k };
79
- } else w && typeof w == "object" ? f[a] = _(w) : f[a] = { _eq: w };
80
- return x ? null : f;
79
+ p[s] = { _eq: w };
80
+ } else k && typeof k == "object" ? p[s] = _(k) : p[s] = { _eq: k };
81
+ return g ? null : p;
81
82
  }
82
- function or(i, m) {
83
+ function hr(i, m) {
83
84
  if (!i) return !0;
84
- for (const [f, x] of Object.entries(i)) {
85
- const _ = m == null ? void 0 : m[f], a = _ == null ? null : String(_), w = x && typeof x == "object" ? x : { _eq: x };
86
- for (const [k, T] of Object.entries(w))
87
- switch (k) {
85
+ for (const [p, g] of Object.entries(i)) {
86
+ const _ = m == null ? void 0 : m[p], s = _ == null ? null : String(_), k = g && typeof g == "object" ? g : { _eq: g };
87
+ for (const [w, O] of Object.entries(k))
88
+ switch (w) {
88
89
  case "_eq":
89
- if (a !== String(T)) return !1;
90
+ if (s !== String(O)) return !1;
90
91
  break;
91
92
  case "_neq":
92
- if (a === String(T)) return !1;
93
+ if (s === String(O)) return !1;
93
94
  break;
94
95
  case "_in":
95
- if (!Array.isArray(T) || !T.map(String).includes(a ?? "")) return !1;
96
+ if (!Array.isArray(O) || !O.map(String).includes(s ?? "")) return !1;
96
97
  break;
97
98
  case "_nin":
98
- if (Array.isArray(T) && T.map(String).includes(a ?? "")) return !1;
99
+ if (Array.isArray(O) && O.map(String).includes(s ?? "")) return !1;
99
100
  break;
100
101
  case "_null":
101
- if (a !== null) return !1;
102
+ if (s !== null) return !1;
102
103
  break;
103
104
  case "_nnull":
104
- if (a === null) return !1;
105
+ if (s === null) return !1;
105
106
  break;
106
107
  default:
107
108
  return !1;
@@ -109,200 +110,200 @@ function or(i, m) {
109
110
  }
110
111
  return !0;
111
112
  }
112
- const Os = 2e3;
113
- function Rs(i, m) {
113
+ const Ws = 2e3;
114
+ function Vs(i, m) {
114
115
  if (/e/i.test(i.trim())) return "Type the quantity in full digits";
115
- const f = Number(i);
116
- if (dt(m) && i.trim() !== "" && !Number.isNaN(f) && !Number.isInteger(f))
116
+ const p = Number(i);
117
+ if (mt(m) && i.trim() !== "" && !Number.isNaN(p) && !Number.isInteger(p))
117
118
  return "Whole numbers only";
118
- const x = bn(i, { type: m, min: 0, label: "Quantity" });
119
- return x.ok ? null : x.message;
119
+ const g = kn(i, { type: m, min: 0, label: "Quantity" });
120
+ return g.ok ? null : g.message;
120
121
  }
121
- function Ps(i, m, f) {
122
- const x = i.reduce((_, a) => {
123
- const w = a[m], k = w != null && w !== "" ? w : f != null && f[m] ? Ee(f[m], a) : null, T = Number(k);
124
- return _ + (k != null && Number.isFinite(T) ? T : 0);
122
+ function Bs(i, m, p) {
123
+ const g = i.reduce((_, s) => {
124
+ const k = s[m], w = k != null && k !== "" ? k : p != null && p[m] ? Ee(p[m], s) : null, O = Number(w);
125
+ return _ + (w != null && Number.isFinite(O) ? O : 0);
125
126
  }, 0);
126
- return Math.round(x * 1e6) / 1e6;
127
+ return Math.round(g * 1e6) / 1e6;
127
128
  }
128
- function Ls(i, m) {
129
- const f = m.trim();
130
- return f ? `${i} — ${f} not used` : i;
129
+ function Ds(i, m) {
130
+ const p = m.trim();
131
+ return p ? `${i} — ${p} not used` : i;
131
132
  }
132
- function Es(i) {
133
+ function Hs(i) {
133
134
  const m = { ...i.probe };
134
- for (const [f, x] of Object.entries(i.compute)) {
135
- const _ = Ee(x, m);
135
+ for (const [p, g] of Object.entries(i.compute)) {
136
+ const _ = Ee(g, m);
136
137
  if (_ === null) continue;
137
- m[f] = _;
138
- const a = i.ruleError(f, _, m);
139
- if (a) return a;
140
- if (Math.abs(_) > _s)
141
- return `${i.labelOf(f)} would be ${_.toLocaleString(void 0, { maximumFractionDigits: 2 })} — too large to save`;
138
+ m[p] = _;
139
+ const s = i.ruleError(p, _, m);
140
+ if (s) return s;
141
+ if (Math.abs(_) > Js)
142
+ return `${i.labelOf(p)} would be ${_.toLocaleString(void 0, { maximumFractionDigits: 2 })} — too large to save`;
142
143
  }
143
144
  return null;
144
145
  }
145
- function As(i) {
146
- const m = Object.entries(i.copyFields ?? {}).filter(([, f]) => f === i.field).map(([f]) => f);
147
- for (const f of m)
148
- for (const x of i.related ?? []) {
149
- if (x.copy_to !== f) continue;
150
- const _ = i.lookup(x.key);
146
+ function Ys(i) {
147
+ const m = Object.entries(i.copyFields ?? {}).filter(([, p]) => p === i.field).map(([p]) => p);
148
+ for (const p of m)
149
+ for (const g of i.related ?? []) {
150
+ if (g.copy_to !== p) continue;
151
+ const _ = i.lookup(g.key);
151
152
  if (_ != null && _ !== "") return _;
152
153
  }
153
154
  return i.catalogValue;
154
155
  }
155
- function Ks(i, m) {
156
- return i.map((f) => [f.id, ...m.map((x) => f[x])].map((x) => String(x ?? "")).join("")).join("");
156
+ function Zs(i, m) {
157
+ return i.map((p) => [p.id, ...m.map((g) => p[g])].map((g) => String(g ?? "")).join("")).join("");
157
158
  }
158
- function Cs(i) {
159
- const m = Object.keys(i).filter((x) => i[x].kind === "error");
159
+ function Gs(i) {
160
+ const m = Object.keys(i).filter((g) => i[g].kind === "error");
160
161
  if (m.length === 0) return i;
161
- const f = { ...i };
162
- for (const x of m) delete f[x];
163
- return f;
162
+ const p = { ...i };
163
+ for (const g of m) delete p[g];
164
+ return p;
164
165
  }
165
- function Js(i, m, f) {
166
- const x = Number(i[m]);
167
- if (!Number.isFinite(x) || x <= 0) return !1;
168
- const _ = f.find((w) => w in i);
166
+ function Xs(i, m, p) {
167
+ const g = Number(i[m]);
168
+ if (!Number.isFinite(g) || g <= 0) return !1;
169
+ const _ = p.find((k) => k in i);
169
170
  if (!_) return !1;
170
- const a = i[_];
171
- return a == null || a === "" || Number(a) === 0;
171
+ const s = i[_];
172
+ return s == null || s === "" || Number(s) === 0;
172
173
  }
173
- function ya({
174
+ function Pa({
174
175
  relatedCollection: i,
175
176
  manyField: m,
176
- parentId: f,
177
- parentCollection: x,
177
+ parentId: p,
178
+ parentCollection: g,
178
179
  field: _,
179
- config: a,
180
- readOnly: w = !1
180
+ config: s,
181
+ readOnly: k = !1
181
182
  }) {
182
- var Dn, Hn, Yn, Zn, Gn, Xn, er, tr;
183
- const k = mt(), T = Zr(), v = $s(), R = ts(), H = ns(), M = a.editable_fields ?? [], me = a.catalog_locked_fields ?? [], { isAdmin: fe } = sr(), P = f === "new", be = x && !P ? `?parent_collection=${encodeURIComponent(x)}&parent_id=${encodeURIComponent(f)}` : "", I = a.qty_field ?? "quantity", [pe, ge] = D(/* @__PURE__ */ new Set()), ke = qe(!1), [U, je] = D(""), [he, re] = D({}), [ee, Z] = D(/* @__PURE__ */ new Set()), [B, se] = D({}), [ie, ve] = D({}), { data: xe = [], isPending: F } = Q({
183
+ var er, tr, nr, rr, sr, ar, ir, lr, or;
184
+ const w = ht(), O = is(), v = Qs(), L = cs(), H = us(), M = s.editable_fields ?? [], me = s.catalog_locked_fields ?? [], { isAdmin: fe } = ur(), T = p === "new", be = g && !T ? `?parent_collection=${encodeURIComponent(g)}&parent_id=${encodeURIComponent(p)}` : "", z = s.qty_field ?? "quantity", [pe, ge] = D(/* @__PURE__ */ new Set()), ke = je(!1), [V, Te] = D(""), [he, re] = D({}), [ee, G] = D(/* @__PURE__ */ new Set()), [B, se] = D({}), [ie, _e] = D({}), { data: xe = [], isPending: F } = Q({
184
185
  queryKey: At.collectionRelations(i),
185
- queryFn: () => pn(k, i),
186
+ queryFn: () => yn(w, i),
186
187
  staleTime: 10 * 6e4
187
- }), y = E(
188
+ }), y = R(
188
189
  () => {
189
190
  var e;
190
191
  return ((e = xe.find(
191
- (t) => t.many_collection === i && t.many_field === a.item_field && !t.junction_field
192
+ (t) => t.many_collection === i && t.many_field === s.item_field && !t.junction_field
192
193
  )) == null ? void 0 : e.one_collection) ?? null;
193
194
  },
194
- [xe, i, a.item_field]
195
+ [xe, i, s.item_field]
195
196
  ), { data: N = [] } = Q({
196
197
  queryKey: At.fieldConfig(i, null),
197
- queryFn: () => k.request(J(`/field-config/${i}`)).then((e) => e.data ?? []),
198
+ queryFn: () => w.request(C(`/field-config/${i}`)).then((e) => e.data ?? []),
198
199
  staleTime: 6e4
199
- }), L = ((Dn = N.find((e) => e.field === I)) == null ? void 0 : Dn.type) ?? null, O = (e, t, n) => {
200
+ }), E = ((er = N.find((e) => e.field === z)) == null ? void 0 : er.type) ?? null, P = (e, t, n) => {
200
201
  var r;
201
- return ((r = Ss(
202
+ return ((r = Cs(
202
203
  N.filter((l) => l.field === e).map((l) => ({
203
204
  field: l.field,
204
- label: l.label || X(l.field),
205
+ label: l.label || Z(l.field),
205
206
  type: l.type,
206
207
  validation_rules: l.validation_rules
207
208
  })),
208
209
  { [e]: t },
209
210
  { ...n, [e]: t }
210
211
  )[0]) == null ? void 0 : r.message) ?? null;
211
- }, { data: $ } = Q({
212
+ }, { data: j } = Q({
212
213
  queryKey: ["col-meta", y],
213
- queryFn: () => k.request(J(`/collections/${y}`)).then((e) => e.data),
214
+ queryFn: () => w.request(C(`/collections/${y}`)).then((e) => e.data),
214
215
  enabled: !!y,
215
216
  staleTime: 3e5
216
- }), A = $ == null ? void 0 : $.display_template, K = E(() => {
217
- const e = a.section_by.split(".")[0];
218
- return (($ == null ? void 0 : $.relations) ?? []).find(
217
+ }), K = j == null ? void 0 : j.display_template, A = R(() => {
218
+ const e = s.section_by.split(".")[0];
219
+ return ((j == null ? void 0 : j.relations) ?? []).find(
219
220
  (t) => t.one_collection === y && t.one_field === e && !!t.junction_field
220
221
  ) ?? null;
221
- }, [$, y, a.section_by]), te = (K == null ? void 0 : K.many_collection) ?? null, { data: Ce = [] } = Q({
222
+ }, [j, y, s.section_by]), te = (A == null ? void 0 : A.many_collection) ?? null, { data: Je = [] } = Q({
222
223
  queryKey: At.collectionRelations(te),
223
- queryFn: () => pn(k, te),
224
+ queryFn: () => yn(w, te),
224
225
  enabled: !!te,
225
226
  staleTime: 10 * 6e4
226
- }), d = E(() => {
227
- if (!(K != null && K.many_field) || !te) return null;
228
- const e = String(K.junction_field), t = Ce.find(
227
+ }), d = R(() => {
228
+ if (!(A != null && A.many_field) || !te) return null;
229
+ const e = String(A.junction_field), t = Je.find(
229
230
  (r) => r.many_collection === te && r.many_field === e
230
- ), n = qs(t);
231
+ ), n = Is(t);
231
232
  return n ? {
232
233
  junction: te,
233
- fkToItem: K.many_field,
234
+ fkToItem: A.many_field,
234
235
  fkToSection: e,
235
236
  target: n,
236
- labelPath: a.section_by.split(".").slice(1).join(".") || "id"
237
+ labelPath: s.section_by.split(".").slice(1).join(".") || "id"
237
238
  } : null;
238
- }, [K, te, Ce, a.section_by]), S = R == null ? void 0 : R.draft, { resolvedFilter: G, resolvedSectionFilter: le, resolvedLinkFilter: Y, missingParents: ae } = E(() => {
239
+ }, [A, te, Je, s.section_by]), S = L == null ? void 0 : L.draft, { resolvedFilter: X, resolvedSectionFilter: le, resolvedLinkFilter: Y, missingParents: ae } = R(() => {
239
240
  const e = [], t = (o) => {
240
241
  if (typeof o == "string" && o.startsWith("$parent.")) {
241
- const h = o.slice(8), c = S == null ? void 0 : S[h];
242
- return c == null || c === "" ? (e.push(h), o) : c;
242
+ const f = o.slice(8), c = S == null ? void 0 : S[f];
243
+ return c == null || c === "" ? (e.push(f), o) : c;
243
244
  }
244
- return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([h, c]) => [h, t(c)])) : o;
245
- }, n = a.filter ? t(a.filter) : void 0, r = a.section_filter ? t(a.section_filter) : void 0, l = a.link_filter ? t(a.link_filter) : void 0;
245
+ return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([f, c]) => [f, t(c)])) : o;
246
+ }, n = s.filter ? t(s.filter) : void 0, r = s.section_filter ? t(s.section_filter) : void 0, l = s.link_filter ? t(s.link_filter) : void 0;
246
247
  return {
247
248
  resolvedFilter: n,
248
249
  resolvedSectionFilter: r,
249
250
  resolvedLinkFilter: l,
250
251
  missingParents: [...new Set(e)]
251
252
  };
252
- }, [a.filter, a.section_filter, a.link_filter, S]), ne = E(() => {
253
- if (!K || !le && !Y) return G;
253
+ }, [s.filter, s.section_filter, s.link_filter, S]), ne = R(() => {
254
+ if (!A || !le && !Y) return X;
254
255
  const e = {
255
256
  ...le ?? {},
256
257
  ...Y ? { _link: Y } : {}
257
- }, t = { [K.one_field]: { _some: e } };
258
- return G ? { _and: [G, t] } : t;
259
- }, [K, le, Y, G]), z = E(() => {
258
+ }, t = { [A.one_field]: { _some: e } };
259
+ return X ? { _and: [X, t] } : t;
260
+ }, [A, le, Y, X]), U = R(() => {
260
261
  const e = /* @__PURE__ */ new Set(["id"]);
261
- $ && !K && e.add(a.section_by);
262
- for (const t of [...(A ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
263
- for (const t of Object.values(a.copy_fields ?? {})) e.add(t);
264
- for (const t of a.columns ?? []) e.add(t.field);
262
+ j && !A && e.add(s.section_by);
263
+ for (const t of [...(K ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
264
+ for (const t of Object.values(s.copy_fields ?? {})) e.add(t);
265
+ for (const t of s.columns ?? []) e.add(t.field);
265
266
  return [...e].join(",");
266
- }, [A, $, K, a.section_by, a.copy_fields, a.columns]), Je = JSON.stringify(ne ?? null), { data: oe = [], isLoading: yn } = Q(
267
+ }, [K, j, A, s.section_by, s.copy_fields, s.columns]), Ie = JSON.stringify(ne ?? null), { data: oe = [], isLoading: Nn } = Q(
267
268
  {
268
- queryKey: ["catalog-picker", y, z, Je],
269
- queryFn: () => k.request(
270
- J(`/items/${y}`, {
271
- limit: Os,
272
- fields: z,
269
+ queryKey: ["catalog-picker", y, U, Ie],
270
+ queryFn: () => w.request(
271
+ C(`/items/${y}`, {
272
+ limit: Ws,
273
+ fields: U,
273
274
  ...ne ? { filter: JSON.stringify(ne) } : {}
274
275
  })
275
276
  ).then((e) => e.data ?? []),
276
277
  // Wait for the catalog meta: a to-many section path both narrows this
277
278
  // read and must stay out of its `fields=`.
278
- enabled: !!y && !!$ && ae.length === 0 && (!K || !!d),
279
+ enabled: !!y && !!j && ae.length === 0 && (!A || !!d),
279
280
  staleTime: 6e4
280
281
  }
281
- ), hr = JSON.stringify(le ?? null), { data: ft = [], isLoading: br } = Q({
282
- queryKey: ["catalog-sections", d == null ? void 0 : d.target, d == null ? void 0 : d.labelPath, hr],
282
+ ), Nr = JSON.stringify(le ?? null), { data: bt = [], isLoading: vr } = Q({
283
+ queryKey: ["catalog-sections", d == null ? void 0 : d.target, d == null ? void 0 : d.labelPath, Nr],
283
284
  queryFn: async () => {
284
285
  const e = d;
285
- return (await Jt(k, `/items/${e.target}`, {
286
+ return (await It(w, `/items/${e.target}`, {
286
287
  fields: `id,${e.labelPath}`,
287
288
  ...le ? { filter: JSON.stringify(le) } : {}
288
289
  })).map((n) => ({
289
290
  id: String(n.id),
290
- name: String(fr(n, e.labelPath) ?? "").trim()
291
+ name: String(kr(n, e.labelPath) ?? "").trim()
291
292
  }));
292
293
  },
293
294
  enabled: !!d && ae.length === 0,
294
295
  staleTime: 6e4
295
- }), Ze = E(() => ft.map((e) => e.id), [ft]), { data: gn = [], isLoading: xr } = Q({
296
+ }), Xe = R(() => bt.map((e) => e.id), [bt]), { data: vn = [], isLoading: Sr } = Q({
296
297
  queryKey: [
297
298
  "catalog-section-links",
298
299
  d == null ? void 0 : d.junction,
299
- Ze.join(","),
300
+ Xe.join(","),
300
301
  JSON.stringify(Y ?? null)
301
302
  ],
302
303
  queryFn: async () => {
303
304
  const e = d, t = [];
304
- for (let n = 0; n < Ze.length; n += 200) {
305
- const r = Ze.slice(n, n + 200), l = await Jt(k, `/items/${e.junction}`, {
305
+ for (let n = 0; n < Xe.length; n += 200) {
306
+ const r = Xe.slice(n, n + 200), l = await It(w, `/items/${e.junction}`, {
306
307
  fields: `${e.fkToItem},${e.fkToSection}`,
307
308
  filter: JSON.stringify(
308
309
  Y ? { _and: [{ [e.fkToSection]: { _in: r } }, Y] } : { [e.fkToSection]: { _in: r } }
@@ -313,134 +314,134 @@ function ya({
313
314
  }
314
315
  return t;
315
316
  },
316
- enabled: !!d && Ze.length > 0,
317
+ enabled: !!d && Xe.length > 0,
317
318
  staleTime: 6e4
318
- }), kn = E(() => {
319
- const e = new Map(ft.map((n) => [n.id, n.name])), t = /* @__PURE__ */ new Map();
320
- for (const n of gn) {
319
+ }), Sn = R(() => {
320
+ const e = new Map(bt.map((n) => [n.id, n.name])), t = /* @__PURE__ */ new Map();
321
+ for (const n of vn) {
321
322
  const r = e.get(n.section);
322
323
  if (!r) continue;
323
324
  const l = t.get(n.item) ?? [];
324
325
  l.includes(r) || l.push(r), t.set(n.item, l);
325
326
  }
326
327
  return t;
327
- }, [ft, gn]), pt = !!K && (!d || br || Ze.length > 0 && xr), ht = E(() => {
328
+ }, [bt, vn]), xt = !!A && (!d || vr || Xe.length > 0 && Sr), yt = R(() => {
328
329
  const e = /* @__PURE__ */ new Map();
329
330
  for (const t of oe) e.set(String(t.id), t);
330
331
  return e;
331
332
  }, [oe]), { data: we = [] } = Q({
332
- queryKey: ["o2m-rows", i, m, f],
333
- queryFn: () => k.request(
334
- J(`/items/${i}`, {
335
- filter: JSON.stringify({ [m]: { _eq: f } }),
333
+ queryKey: ["o2m-rows", i, m, p],
334
+ queryFn: () => w.request(
335
+ C(`/items/${i}`, {
336
+ filter: JSON.stringify({ [m]: { _eq: p } }),
336
337
  limit: 1e3
337
338
  })
338
339
  ).then((e) => e.data ?? []),
339
- enabled: !P,
340
+ enabled: !T,
340
341
  staleTime: 15e3
341
- }), It = E(
342
- () => Ks(we, [
343
- a.item_field,
344
- I,
342
+ }), Qt = R(
343
+ () => Zs(we, [
344
+ s.item_field,
345
+ z,
345
346
  ...M,
346
- ...Object.keys(a.compute_fields ?? {})
347
+ ...Object.keys(s.compute_fields ?? {})
347
348
  ]),
348
- [we, a.item_field, I, M, a.compute_fields]
349
- ), wn = qe(null), Qt = qe(B);
350
- Qt.current = B, $e(() => {
351
- const e = wn.current;
352
- if (wn.current = It, e === null || e === It) return;
353
- const t = Object.keys(Qt.current).filter(
354
- (n) => Qt.current[n].kind === "error"
349
+ [we, s.item_field, z, M, s.compute_fields]
350
+ ), _n = je(null), zt = je(B);
351
+ zt.current = B, Fe(() => {
352
+ const e = _n.current;
353
+ if (_n.current = Qt, e === null || e === Qt) return;
354
+ const t = Object.keys(zt.current).filter(
355
+ (n) => zt.current[n].kind === "error"
355
356
  );
356
- se((n) => Cs(n)), ve((n) => Object.keys(n).length === 0 ? n : {}), t.length > 0 && re((n) => {
357
+ se((n) => Gs(n)), _e((n) => Object.keys(n).length === 0 ? n : {}), t.length > 0 && re((n) => {
357
358
  if (!t.some((l) => l in n)) return n;
358
359
  const r = { ...n };
359
360
  for (const l of t) delete r[l];
360
361
  return r;
361
362
  });
362
- }, [It]);
363
- const Ge = !P && !!v, Fe = v ? v.getPendingRows(i, m) : [], bt = Ge ? v.getPendingEdits(i, m) : /* @__PURE__ */ new Map(), yr = JSON.stringify([...bt.entries()]), xt = E(
364
- () => bt.size === 0 ? we : we.map((e) => {
365
- const t = bt.get(String(e.id));
363
+ }, [Qt]);
364
+ const et = !T && !!v, Re = v ? v.getPendingRows(i, m) : [], gt = et ? v.getPendingEdits(i, m) : /* @__PURE__ */ new Map(), _r = JSON.stringify([...gt.entries()]), Me = R(
365
+ () => gt.size === 0 ? we : we.map((e) => {
366
+ const t = gt.get(String(e.id));
366
367
  return t ? { ...e, ...t } : e;
367
368
  }),
368
- [we, yr]
369
- ), yt = !P && v ? v.getPendingDeletes(i, m) : /* @__PURE__ */ new Set(), Xe = E(() => {
369
+ [we, _r]
370
+ ), kt = !T && v ? v.getPendingDeletes(i, m) : /* @__PURE__ */ new Set(), tt = R(() => {
370
371
  const e = /* @__PURE__ */ new Map();
371
- for (const t of xt) {
372
- const n = t[a.item_field];
372
+ for (const t of Me) {
373
+ const n = t[s.item_field];
373
374
  n != null && e.set(String(n), t);
374
375
  }
375
376
  return e;
376
- }, [xt, a.item_field]), gt = E(() => {
377
+ }, [Me, s.item_field]), wt = R(() => {
377
378
  const e = /* @__PURE__ */ new Map();
378
- return Fe.forEach((t, n) => {
379
- const r = t[a.item_field];
379
+ return Re.forEach((t, n) => {
380
+ const r = t[s.item_field];
380
381
  r != null && e.set(String(r), n);
381
382
  }), e;
382
- }, [Fe, a.item_field]), Se = E(() => {
383
- const e = Fe.filter((r) => r[a.item_field] != null).map((r) => ({ key: String(r[a.item_field]), row: r }));
384
- if (P) return e;
385
- const t = xt.filter((r) => r[a.item_field] != null).map((r) => ({ key: String(r[a.item_field]), row: r })), n = new Set(t.map((r) => r.key));
383
+ }, [Re, s.item_field]), Ne = R(() => {
384
+ const e = Re.filter((r) => r[s.item_field] != null).map((r) => ({ key: String(r[s.item_field]), row: r }));
385
+ if (T) return e;
386
+ const t = Me.filter((r) => r[s.item_field] != null).map((r) => ({ key: String(r[s.item_field]), row: r })), n = new Set(t.map((r) => r.key));
386
387
  return [...t, ...e.filter((r) => !n.has(r.key))];
387
- }, [P, Fe, xt, a.item_field]), kt = E(
388
- () => Se.filter((e) => !ht.has(e.key)).map((e) => e.key),
389
- [Se, ht]
390
- ), { data: zt = [] } = Q({
391
- queryKey: ["catalog-picker-labels", y, z, kt.join(",")],
392
- queryFn: () => k.request(
393
- J(`/items/${y}`, {
394
- filter: JSON.stringify({ id: { _in: kt } }),
395
- fields: z,
396
- limit: kt.length
388
+ }, [T, Re, Me, s.item_field]), Nt = R(
389
+ () => Ne.filter((e) => !yt.has(e.key)).map((e) => e.key),
390
+ [Ne, yt]
391
+ ), { data: Ut = [] } = Q({
392
+ queryKey: ["catalog-picker-labels", y, U, Nt.join(",")],
393
+ queryFn: () => w.request(
394
+ C(`/items/${y}`, {
395
+ filter: JSON.stringify({ id: { _in: Nt } }),
396
+ fields: U,
397
+ limit: Nt.length
397
398
  })
398
399
  ).then((e) => e.data ?? []),
399
- enabled: !!y && kt.length > 0,
400
+ enabled: !!y && Nt.length > 0,
400
401
  staleTime: 6e4
401
- }), { data: Re = [] } = Q({
402
+ }), { data: Pe = [] } = Q({
402
403
  queryKey: ["pinned-items", y],
403
- queryFn: () => k.request(J(`/pinned/${y}`)).then((e) => e.data ?? []),
404
- enabled: !!y && !!a.favorites,
404
+ queryFn: () => w.request(C(`/pinned/${y}`)).then((e) => e.data ?? []),
405
+ enabled: !!y && !!s.favorites,
405
406
  staleTime: 6e4
406
- }), Mt = E(() => new Set(Re), [Re]), { data: et = [] } = Q({
407
- queryKey: ["pinned-item-rows", y, z, Re.join(",")],
408
- queryFn: () => k.request(
409
- J(`/items/${y}`, {
410
- filter: JSON.stringify({ id: { _in: Re } }),
411
- fields: z,
412
- limit: Re.length
407
+ }), Mt = R(() => new Set(Pe), [Pe]), { data: nt = [] } = Q({
408
+ queryKey: ["pinned-item-rows", y, U, Pe.join(",")],
409
+ queryFn: () => w.request(
410
+ C(`/items/${y}`, {
411
+ filter: JSON.stringify({ id: { _in: Pe } }),
412
+ fields: U,
413
+ limit: Pe.length
413
414
  })
414
415
  ).then((e) => e.data ?? []),
415
- enabled: !!y && !!a.favorites && Re.length > 0,
416
+ enabled: !!y && !!s.favorites && Pe.length > 0,
416
417
  staleTime: 6e4
417
- }), [wt, Nn] = D(/* @__PURE__ */ new Set());
418
- async function vn(e) {
419
- if (!(!y || wt.has(e))) {
420
- Nn((t) => new Set(t).add(e));
418
+ }), [vt, qn] = D(/* @__PURE__ */ new Set());
419
+ async function $n(e) {
420
+ if (!(!y || vt.has(e))) {
421
+ qn((t) => new Set(t).add(e));
421
422
  try {
422
- await k.request(ir(`/pinned/${y}/${e}/toggle`)).catch(() => {
423
- }), await T.invalidateQueries({ queryKey: ["pinned-items", y] });
423
+ await w.request(fr(`/pinned/${y}/${e}/toggle`)).catch(() => {
424
+ }), await O.invalidateQueries({ queryKey: ["pinned-items", y] });
424
425
  } finally {
425
- Nn((t) => {
426
+ qn((t) => {
426
427
  const n = new Set(t);
427
428
  return n.delete(e), n;
428
429
  });
429
430
  }
430
431
  }
431
432
  }
432
- const [gr, Sn] = D(!1), _n = qe(null), Vt = (e) => a.favorites ? /* @__PURE__ */ s(
433
+ const [qr, jn] = D(!1), Fn = je(null), Wt = (e) => s.favorites ? /* @__PURE__ */ a(
433
434
  "button",
434
435
  {
435
436
  type: "button",
436
437
  title: Mt.has(e) ? "Remove from favorites" : "Add to favorites",
437
- disabled: wt.has(e),
438
+ disabled: vt.has(e),
438
439
  onClick: (t) => {
439
- t.stopPropagation(), vn(e);
440
+ t.stopPropagation(), $n(e);
440
441
  },
441
442
  className: "shrink-0 rounded p-0.5 transition-colors",
442
- children: wt.has(e) ? /* @__PURE__ */ s(ue, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ s(
443
- ct,
443
+ children: vt.has(e) ? /* @__PURE__ */ a(ue, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ a(
444
+ ft,
444
445
  {
445
446
  className: W(
446
447
  "h-3.5 w-3.5",
@@ -449,379 +450,406 @@ function ya({
449
450
  }
450
451
  )
451
452
  }
452
- ) : null, [ye, kr] = D("");
453
- $e(() => {
454
- const e = setTimeout(() => kr(U), 300);
453
+ ) : null, [ye, $r] = D("");
454
+ Fe(() => {
455
+ const e = setTimeout(() => $r(V), 300);
455
456
  return () => clearTimeout(e);
456
- }, [U]);
457
- const qn = E(() => {
457
+ }, [V]);
458
+ const Tn = R(() => {
458
459
  var t;
459
- const e = (t = [...(A ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
460
+ const e = (t = [...(K ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
460
461
  return e && !e.includes(".") ? e : "id";
461
- }, [A]), { shownSearchFields: Ie, otherSearchFields: $n } = E(() => {
462
+ }, [K]), { shownSearchFields: Qe, otherSearchFields: Rn } = R(() => {
462
463
  const e = new Set(
463
- (($ == null ? void 0 : $.relations) ?? []).filter((r) => r.one_collection === y && r.one_field).map((r) => r.one_field)
464
+ ((j == null ? void 0 : j.relations) ?? []).filter((r) => r.one_collection === y && r.one_field).map((r) => r.one_field)
464
465
  ), t = new Set(
465
- (($ == null ? void 0 : $.fields) ?? []).filter((r) => (r.type === "string" || r.type === "text") && !e.has(r.field)).map((r) => r.field)
466
+ ((j == null ? void 0 : j.fields) ?? []).filter((r) => (r.type === "string" || r.type === "text") && !e.has(r.field)).map((r) => r.field)
466
467
  ), n = /* @__PURE__ */ new Set();
467
- for (const r of (A ?? "").matchAll(/\{\{([\w.]+)\}\}/g)) t.has(r[1]) && n.add(r[1]);
468
- for (const r of a.columns ?? []) t.has(r.field) && n.add(r.field);
468
+ for (const r of (K ?? "").matchAll(/\{\{([\w.]+)\}\}/g)) t.has(r[1]) && n.add(r[1]);
469
+ for (const r of s.columns ?? []) t.has(r.field) && n.add(r.field);
469
470
  return {
470
471
  shownSearchFields: [...n],
471
472
  otherSearchFields: [...t].filter((r) => !n.has(r))
472
473
  };
473
- }, [$, y, A, a.columns]), tt = E(() => {
474
- const e = a.related_columns ?? [], t = e.findIndex((n) => n.stock === !0);
474
+ }, [j, y, K, s.columns]), We = R(() => {
475
+ const e = s.related_columns ?? [], t = e.findIndex((n) => n.stock === !0);
475
476
  return t !== -1 ? t : e.findIndex((n) => n.key === "on_hand" && n.stock !== !1);
476
- }, [a.related_columns]), de = tt === -1 ? null : (a.related_columns ?? [])[tt] ?? null, Pe = de ? Ye(de.match, S) : null, Qe = E(() => {
477
+ }, [s.related_columns]), de = We === -1 ? null : (s.related_columns ?? [])[We] ?? null, Le = de ? Ge(de.match, S) : null, ze = R(() => {
477
478
  for (const e of Object.values((de == null ? void 0 : de.match) ?? {}))
478
479
  if (typeof e == "string" && e.startsWith("$parent.")) return e.slice(8);
479
480
  return null;
480
- }, [de]), jn = Qe ? S == null ? void 0 : S[Qe] : null, wr = Qe ? ((Hn = R == null ? void 0 : R.fieldLabels) == null ? void 0 : Hn[Qe]) ?? X(Qe) : null, Me = y ? `nvr:catalog-in-stock:${y}:${i}.${m}` : null, [Fn, Tn] = D(!1);
481
- $e(() => {
482
- if (Me)
481
+ }, [de]), On = ze ? S == null ? void 0 : S[ze] : null, jr = ze ? ((tr = L == null ? void 0 : L.fieldLabels) == null ? void 0 : tr[ze]) ?? Z(ze) : null, Ve = y ? `nvr:catalog-in-stock:${y}:${i}.${m}` : null, [Pn, Ln] = D(!1);
482
+ Fe(() => {
483
+ if (Ve)
483
484
  try {
484
- Tn(localStorage.getItem(Me) === "1");
485
+ Ln(localStorage.getItem(Ve) === "1");
485
486
  } catch {
486
487
  }
487
- }, [Me]);
488
- const Wt = (e) => {
489
- if (Tn(e), !!Me)
488
+ }, [Ve]);
489
+ const Vt = (e) => {
490
+ if (Ln(e), !!Ve)
490
491
  try {
491
- e ? localStorage.setItem(Me, "1") : localStorage.removeItem(Me);
492
+ e ? localStorage.setItem(Ve, "1") : localStorage.removeItem(Ve);
492
493
  } catch {
493
494
  }
494
- }, ce = !!de && Fn && Pe !== null, Ut = E(() => {
495
+ }, ce = !!de && Pn && Le !== null, Bt = R(() => {
495
496
  if (!de) return null;
496
- const e = (($ == null ? void 0 : $.relations) ?? []).find(
497
+ const e = ((j == null ? void 0 : j.relations) ?? []).find(
497
498
  (t) => t.many_collection === de.collection && t.many_field === de.item_field && t.one_collection === y && !!t.one_field && !t.junction_field
498
499
  );
499
500
  return (e == null ? void 0 : e.one_field) ?? null;
500
- }, [de, $, y]), Bt = E(
501
- () => ce && Ut && de && Pe ? { [Ut]: { _some: { ...Pe, [de.value_field]: { _gt: 0 } } } } : null,
502
- [ce, Ut, de, Pe]
503
- ), Dt = JSON.stringify(Bt), Nt = ce && !Bt ? 100 : 25, Ht = (e, t) => {
504
- const n = [t, Bt].filter(Boolean);
501
+ }, [de, j, y]), Dt = R(
502
+ () => ce && Bt && de && Le ? { [Bt]: { _some: { ...Le, [de.value_field]: { _gt: 0 } } } } : null,
503
+ [ce, Bt, de, Le]
504
+ ), Ht = JSON.stringify(Dt), St = ce && !Dt ? 100 : 25, Yt = (e, t) => {
505
+ const n = [t, Dt].filter(Boolean);
505
506
  return n.length === 0 ? e : { ...e, filter: JSON.stringify(n.length === 1 ? n[0] : { _and: n }) };
506
- }, Yt = sr().userId, vt = a.recent === !1 ? 0 : typeof a.recent == "object" && Number((Yn = a.recent) == null ? void 0 : Yn.days) || 30, Zt = ["user_created", "created_by", "creator"].find(
507
+ }, Zt = ur().userId, _t = s.recent === !1 ? 0 : typeof s.recent == "object" && Number((nr = s.recent) == null ? void 0 : nr.days) || 30, Gt = ["user_created", "created_by", "creator"].find(
507
508
  (e) => N.some((t) => t.field === e)
508
- ), nt = ["date_created", "created_at"].find(
509
+ ), rt = ["date_created", "created_at"].find(
509
510
  (e) => N.some((t) => t.field === e)
510
- ), { data: rt = [] } = Q({
511
+ ), { data: st = [] } = Q({
511
512
  queryKey: [
512
513
  "catalog-recent-picks",
513
514
  i,
514
- a.item_field,
515
- Yt,
515
+ s.item_field,
516
516
  Zt,
517
- nt,
518
- vt
517
+ Gt,
518
+ rt,
519
+ _t
519
520
  ],
520
521
  queryFn: async () => {
521
- const e = new Date(Date.now() - vt * 864e5).toISOString(), t = { [Zt]: { _eq: Yt } };
522
- nt && (t[nt] = { _gte: e });
523
- const n = await k.request(
524
- J(`/items/${i}`, {
525
- fields: a.item_field,
522
+ const e = new Date(Date.now() - _t * 864e5).toISOString(), t = { [Gt]: { _eq: Zt } };
523
+ rt && (t[rt] = { _gte: e });
524
+ const n = await w.request(
525
+ C(`/items/${i}`, {
526
+ fields: s.item_field,
526
527
  filter: JSON.stringify(t),
527
528
  limit: 500,
528
529
  count: "false",
529
- ...nt ? { sort: `-${nt}` } : {}
530
+ ...rt ? { sort: `-${rt}` } : {}
530
531
  })
531
532
  ).then((l) => l.data ?? []).catch(() => []), r = [];
532
533
  for (const l of n) {
533
- const o = l[a.item_field], h = o != null && typeof o == "object" ? o.id : o;
534
- if (h != null && h !== "" && !r.includes(String(h)) && r.push(String(h)), r.length >= 150) break;
534
+ const o = l[s.item_field], f = o != null && typeof o == "object" ? o.id : o;
535
+ if (f != null && f !== "" && !r.includes(String(f)) && r.push(String(f)), r.length >= 150) break;
535
536
  }
536
537
  return r;
537
538
  },
538
- enabled: vt > 0 && !!Yt && !!Zt && !w,
539
+ enabled: _t > 0 && !!Zt && !!Gt && !k,
539
540
  staleTime: 5 * 6e4
540
- }), Nr = E(() => new Set(rt), [rt]), Gt = !!y && ye.trim().length > 0, { data: Xt = [], isFetching: vr } = Q({
541
+ }), Fr = R(() => new Set(st), [st]), Xt = !!y && ye.trim().length > 0, { data: en = [], isFetching: Tr } = Q({
541
542
  queryKey: [
542
543
  "catalog-shown-search",
543
544
  y,
544
- z,
545
+ U,
545
546
  ye,
546
- Ie,
547
- Dt,
548
- Nt
547
+ Qe,
548
+ Ht,
549
+ St
549
550
  ],
550
- queryFn: () => k.request(
551
- J(
551
+ queryFn: () => w.request(
552
+ C(
552
553
  `/items/${y}`,
553
- Ht({
554
+ Yt({
554
555
  search: ye,
555
- search_fields: Ie.join(","),
556
+ search_fields: Qe.join(","),
556
557
  search_rank: "1",
557
- fields: z,
558
- limit: Nt,
559
- sort: qn
558
+ fields: U,
559
+ limit: St,
560
+ sort: Tn
560
561
  })
561
562
  )
562
563
  ).then((e) => e.data ?? []),
563
- enabled: Gt && Ie.length > 0,
564
+ enabled: Xt && Qe.length > 0,
564
565
  staleTime: 3e4,
565
566
  placeholderData: (e) => e
566
- }), St = $n.join(","), { data: On = [], isFetching: Sr } = Q({
567
+ }), qt = Rn.join(","), { data: En = [], isFetching: Rr } = Q({
567
568
  queryKey: [
568
569
  "catalog-full-search",
569
570
  y,
570
- z,
571
+ U,
571
572
  ye,
572
- St,
573
- Dt,
574
- Nt
573
+ qt,
574
+ Ht,
575
+ St
575
576
  ],
576
- queryFn: () => k.request(
577
- J(
577
+ queryFn: () => w.request(
578
+ C(
578
579
  `/items/${y}`,
579
- Ht({
580
+ Yt({
580
581
  search: ye,
581
- fields: [z, St].filter(Boolean).join(","),
582
- limit: Nt,
583
- sort: qn
582
+ fields: [U, qt].filter(Boolean).join(","),
583
+ limit: St,
584
+ sort: Tn
584
585
  })
585
586
  )
586
587
  ).then((e) => e.data ?? []),
587
- enabled: Gt,
588
+ enabled: Xt,
588
589
  staleTime: 3e4,
589
590
  placeholderData: (e) => e
590
- }), _r = rt.join(","), { data: Rn = [] } = Q({
591
+ }), Or = st.join(","), { data: Kn = [] } = Q({
591
592
  queryKey: [
592
593
  "catalog-recent-search",
593
594
  y,
594
- z,
595
+ U,
595
596
  ye,
596
- St,
597
- _r,
598
- Dt
597
+ qt,
598
+ Or,
599
+ Ht
599
600
  ],
600
- queryFn: () => k.request(
601
- J(
601
+ queryFn: () => w.request(
602
+ C(
602
603
  `/items/${y}`,
603
- Ht(
604
+ Yt(
604
605
  {
605
606
  search: ye,
606
- fields: [z, St].filter(Boolean).join(","),
607
+ fields: [U, qt].filter(Boolean).join(","),
607
608
  limit: 10,
608
609
  count: "false"
609
610
  },
610
- { id: { _in: rt } }
611
+ { id: { _in: st } }
611
612
  )
612
613
  )
613
614
  ).then((e) => e.data ?? []).catch(() => []),
614
- enabled: Gt && rt.length > 0,
615
+ enabled: Xt && st.length > 0,
615
616
  staleTime: 3e4,
616
617
  placeholderData: (e) => e
617
- }), en = vr || Sr, Ve = E(
618
- () => ks({
619
- shown: Xt,
620
- other: On,
621
- recent: Rn,
622
- shownFields: Ie,
618
+ }), tn = Tr || Rr, Be = R(
619
+ () => Ls({
620
+ shown: en,
621
+ other: En,
622
+ recent: Kn,
623
+ shownFields: Qe,
623
624
  q: ye
624
625
  }),
625
- [Xt, On, Rn, Ie, ye]
626
- ), qr = (e) => {
627
- if (Ie.length === 0 || Xt.some((n) => String(n.id) === String(e.id)) || ws(e, Ie, ye)) return null;
628
- const t = is(ye);
629
- for (const n of $n) {
626
+ [en, En, Kn, Qe, ye]
627
+ ), Pr = (e) => {
628
+ if (Qe.length === 0 || en.some((n) => String(n.id) === String(e.id)) || Es(e, Qe, ye)) return null;
629
+ const t = hs(ye);
630
+ for (const n of Rn) {
630
631
  const r = e[n];
631
632
  if (r == null || typeof r == "object") continue;
632
633
  const l = String(r);
633
- if (t.some((o) => ls(l, o)))
634
- return `${X(n)}: ${l.length > 40 ? `${l.slice(0, 40)}…` : l}`;
634
+ if (t.some((o) => bs(l, o)))
635
+ return `${Z(n)}: ${l.length > 40 ? `${l.slice(0, 40)}…` : l}`;
635
636
  }
636
637
  return null;
637
- }, We = E(() => {
638
+ }, An = R(
639
+ () => [.../* @__PURE__ */ new Set(["id", ...Object.values(s.copy_fields ?? {})])].join(","),
640
+ [s.copy_fields]
641
+ ), at = R(
642
+ () => T ? [] : Me.map((e) => e[s.item_field]).filter((e) => e != null && e !== "").map(String),
643
+ [T, Me, s.item_field]
644
+ ), { data: Cn = [] } = Q({
645
+ queryKey: ["catalog-line-sources", y, An, at.join(",")],
646
+ queryFn: async () => {
647
+ const e = [];
648
+ for (let t = 0; t < at.length; t += 200) {
649
+ const n = at.slice(t, t + 200), r = await w.request(
650
+ C(`/items/${y}`, {
651
+ filter: JSON.stringify({ id: { _in: n } }),
652
+ fields: An,
653
+ limit: n.length
654
+ })
655
+ ).then((l) => l.data ?? []);
656
+ e.push(...r);
657
+ }
658
+ return e;
659
+ },
660
+ enabled: !k && !!y && at.length > 0 && Object.keys(s.copy_fields ?? {}).length > 0,
661
+ staleTime: 6e4
662
+ }), Lr = R(
663
+ () => new Map(Cn.map((e) => [String(e.id).toUpperCase(), e])),
664
+ [Cn]
665
+ ), De = R(() => {
638
666
  const e = /* @__PURE__ */ new Set();
639
667
  for (const t of oe) e.add(String(t.id));
640
- for (const t of Se) e.add(t.key);
641
- for (const t of Re) e.add(t);
642
- for (const t of Ve) e.add(String(t.id));
668
+ for (const t of Ne) e.add(t.key);
669
+ for (const t of Pe) e.add(t);
670
+ for (const t of Be) e.add(String(t.id));
643
671
  return [...e];
644
- }, [oe, Se, Re, Ve]), st = fn({
645
- queries: (a.related_columns ?? []).map((e) => {
646
- const t = Ye(e.match, S);
672
+ }, [oe, Ne, Pe, Be]), it = xn({
673
+ queries: (s.related_columns ?? []).map((e) => {
674
+ const t = Ge(e.match, S);
647
675
  return {
648
676
  queryKey: [
649
677
  "catalog-related",
650
678
  e.key,
651
679
  e.collection,
652
680
  JSON.stringify(t),
653
- We.join(",")
681
+ De.join(",")
654
682
  ],
655
683
  queryFn: async () => {
656
684
  const n = {};
657
- if (e.count_all && e.aggregate === "sum" && x && _) {
685
+ if (e.count_all && e.aggregate === "sum" && g && _) {
658
686
  const o = {};
659
- if (P)
660
- for (const h of xn(e.match))
661
- o[h] = (S == null ? void 0 : S[h]) ?? null;
662
- for (let h = 0; h < We.length; h += 200) {
663
- const c = We.slice(h, h + 200), p = await k.request(
664
- J("/catalog-related/count-all", {
665
- collection: x,
687
+ if (T)
688
+ for (const f of wn(e.match))
689
+ o[f] = (S == null ? void 0 : S[f]) ?? null;
690
+ for (let f = 0; f < De.length; f += 200) {
691
+ const c = De.slice(f, f + 200), h = await w.request(
692
+ C("/catalog-related/count-all", {
693
+ collection: g,
666
694
  field: _,
667
695
  key: e.key,
668
- record: P ? "new" : f,
669
- ...P ? { parent: JSON.stringify(o) } : {},
696
+ record: T ? "new" : p,
697
+ ...T ? { parent: JSON.stringify(o) } : {},
670
698
  ids: c.join(",")
671
699
  })
672
700
  );
673
- Object.assign(n, p.data ?? {});
701
+ Object.assign(n, h.data ?? {});
674
702
  }
675
703
  return n;
676
704
  }
677
705
  const r = e.aggregate === "sum", l = r ? 150 : 400;
678
- for (let o = 0; o < We.length; o += l) {
679
- const h = We.slice(o, o + l);
706
+ for (let o = 0; o < De.length; o += l) {
707
+ const f = De.slice(o, o + l);
680
708
  let c = 1;
681
709
  for (; ; ) {
682
- const p = await k.request(
683
- J(`/items/${e.collection}`, {
684
- limit: r ? 1e3 : h.length,
710
+ const h = await w.request(
711
+ C(`/items/${e.collection}`, {
712
+ limit: r ? 1e3 : f.length,
685
713
  ...r ? { page: c } : {},
686
714
  fields: `${e.item_field},${e.value_field}`,
687
- filter: JSON.stringify({ ...t, [e.item_field]: { _in: h } })
715
+ filter: JSON.stringify({ ...t, [e.item_field]: { _in: f } })
688
716
  })
689
717
  ).then((b) => b.data ?? []);
690
- for (const b of p) {
718
+ for (const b of h) {
691
719
  const q = b[e.item_field];
692
720
  if (q != null)
693
721
  if (r) {
694
- const j = Number(b[e.value_field]);
695
- n[String(q)] = (Number(n[String(q)]) || 0) + (Number.isNaN(j) ? 0 : j);
722
+ const $ = Number(b[e.value_field]);
723
+ n[String(q)] = (Number(n[String(q)]) || 0) + (Number.isNaN($) ? 0 : $);
696
724
  } else
697
725
  n[String(q)] = b[e.value_field];
698
726
  }
699
- if (!r || p.length < 1e3) break;
727
+ if (!r || h.length < 1e3) break;
700
728
  c += 1;
701
729
  }
702
730
  }
703
731
  return n;
704
732
  },
705
- enabled: !!y && t !== null && We.length > 0,
733
+ enabled: !!y && t !== null && De.length > 0,
706
734
  staleTime: 3e4
707
735
  };
708
736
  })
709
- }), at = (e, t) => {
737
+ }), lt = (e, t) => {
710
738
  var r, l;
711
- const n = (a.related_columns ?? []).findIndex((o) => o.key === e);
739
+ const n = (s.related_columns ?? []).findIndex((o) => o.key === e);
712
740
  if (n !== -1)
713
- return (l = (r = st[n]) == null ? void 0 : r.data) == null ? void 0 : l[t];
714
- }, it = tt === -1 || (Zn = st[tt]) == null ? void 0 : Zn.data, $r = ce && !!((Gn = st[tt]) != null && Gn.isFetching), Pn = (e) => {
715
- if (!ce || it === void 0) return !0;
716
- const t = Number(it[e]);
741
+ return (l = (r = it[n]) == null ? void 0 : r.data) == null ? void 0 : l[t];
742
+ }, ot = We === -1 || (rr = it[We]) == null ? void 0 : rr.data, Er = ce && !!((sr = it[We]) != null && sr.isFetching), Jn = (e) => {
743
+ if (!ce || ot === void 0) return !0;
744
+ const t = Number(ot[e]);
717
745
  return Number.isFinite(t) && t > 0;
718
- }, lt = ce ? Ve.filter((e) => Pn(String(e.id))) : Ve, tn = ce ? et.filter((e) => Pn(String(e.id))) : et, nn = (e) => {
746
+ }, dt = ce ? Be.filter((e) => Jn(String(e.id))) : Be, nn = ce ? nt.filter((e) => Jn(String(e.id))) : nt, rn = (e) => {
719
747
  var c;
720
- const t = a.qty_warning;
748
+ const t = s.qty_warning;
721
749
  if (!t) return null;
722
- const n = _e(e) ?? 0;
750
+ const n = qe(e) ?? 0;
723
751
  if (n <= 0) return null;
724
- const r = (a.related_columns ?? []).findIndex((p) => p.key === t.column);
752
+ const r = (s.related_columns ?? []).findIndex((h) => h.key === t.column);
725
753
  if (r === -1) return null;
726
- const l = (c = st[r]) == null ? void 0 : c.data;
754
+ const l = (c = it[r]) == null ? void 0 : c.data;
727
755
  if (l === void 0) return null;
728
- const o = l[e], h = o == null || o === "" ? 0 : Number(o);
729
- return Number.isNaN(h) ? null : n > h ? { available: h, qty: n } : null;
730
- }, jr = (e) => {
731
- const t = a.row_flags ?? [];
756
+ const o = l[e], f = o == null || o === "" ? 0 : Number(o);
757
+ return Number.isNaN(f) ? null : n > f ? { available: f, qty: n } : null;
758
+ }, Kr = (e) => {
759
+ const t = s.row_flags ?? [];
732
760
  if (t.length === 0) return [];
733
761
  const n = [];
734
762
  for (const r of t)
735
763
  if (!(!(r != null && r.when) || !r.label))
736
764
  try {
737
765
  const l = r.when.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, "$1");
738
- ss(l, e) && n.push(r.label);
766
+ fs(l, e) && n.push(r.label);
739
767
  } catch {
740
768
  }
741
769
  return n;
742
- }, rn = a.qty_warning ? a.qty_warning.label ?? ((Xn = (a.related_columns ?? []).find((e) => {
770
+ }, sn = s.qty_warning ? s.qty_warning.label ?? ((ar = (s.related_columns ?? []).find((e) => {
743
771
  var t;
744
- return e.key === ((t = a.qty_warning) == null ? void 0 : t.column);
745
- })) == null ? void 0 : Xn.label) ?? X(a.qty_warning.column) : "", Fr = !!a.submission_errors, _t = E(
772
+ return e.key === ((t = s.qty_warning) == null ? void 0 : t.column);
773
+ })) == null ? void 0 : ar.label) ?? Z(s.qty_warning.column) : "", Ar = !!s.submission_errors, $t = R(
746
774
  () => {
747
775
  var e;
748
- return typeof a.submission_errors == "object" && Array.isArray((e = a.submission_errors) == null ? void 0 : e.match_fields) ? a.submission_errors.match_fields.filter((t) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(t)) : [];
776
+ return typeof s.submission_errors == "object" && Array.isArray((e = s.submission_errors) == null ? void 0 : e.match_fields) ? s.submission_errors.match_fields.filter((t) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(t)) : [];
749
777
  },
750
- [a.submission_errors]
751
- ), Tr = as(6e4), { data: Ln } = Q({
752
- queryKey: ["erp-submissions", x ?? "", String(f)],
753
- queryFn: () => k.request(J(`/erp-submissions/${x}/${encodeURIComponent(f)}`)).then((e) => e.data ?? []),
754
- enabled: Fr && !P && !!x,
778
+ [s.submission_errors]
779
+ ), Cr = ps(6e4), { data: In } = Q({
780
+ queryKey: ["erp-submissions", g ?? "", String(p)],
781
+ queryFn: () => w.request(C(`/erp-submissions/${g}/${encodeURIComponent(p)}`)).then((e) => e.data ?? []),
782
+ enabled: Ar && !T && !!g,
755
783
  staleTime: 15e3,
756
- refetchInterval: Tr
757
- }), sn = E(() => {
758
- const e = (Ln ?? [])[0];
759
- return !e || e.status !== "failed" ? null : ds(e.payload, e.last_error);
760
- }, [Ln]), Or = Se.map((e) => e.key).join(","), { data: an } = Q({
761
- queryKey: ["catalog-suberr-idents", y, _t.join(","), Or],
784
+ refetchInterval: Cr
785
+ }), an = R(() => {
786
+ const e = (In ?? [])[0];
787
+ return !e || e.status !== "failed" ? null : ys(e.payload, e.last_error);
788
+ }, [In]), Jr = Ne.map((e) => e.key).join(","), { data: ln } = Q({
789
+ queryKey: ["catalog-suberr-idents", y, $t.join(","), Jr],
762
790
  queryFn: async () => {
763
- const e = Se.map((n) => n.key);
791
+ const e = Ne.map((n) => n.key);
764
792
  if (e.length === 0) return {};
765
- const t = await k.request(
766
- J(`/items/${y}`, {
793
+ const t = await w.request(
794
+ C(`/items/${y}`, {
767
795
  limit: e.length,
768
- fields: ["id", ..._t].join(","),
796
+ fields: ["id", ...$t].join(","),
769
797
  filter: JSON.stringify({ id: { _in: e } })
770
798
  })
771
799
  ).then((n) => n.data ?? []);
772
800
  return Object.fromEntries(t.map((n) => [String(n.id), n]));
773
801
  },
774
- enabled: !!y && !!sn && _t.length > 0 && Se.length > 0,
802
+ enabled: !!y && !!an && $t.length > 0 && Ne.length > 0,
775
803
  staleTime: 6e4
776
- }), Rr = (e) => {
777
- if (!sn) return null;
778
- const t = an == null ? void 0 : an[e], n = [
779
- Ot(e),
780
- ..._t.map((r) => {
781
- const l = (t == null ? void 0 : t[r]) ?? ze(e)[r];
804
+ }), Ir = (e) => {
805
+ if (!an) return null;
806
+ const t = ln == null ? void 0 : ln[e], n = [
807
+ Pt(e),
808
+ ...$t.map((r) => {
809
+ const l = (t == null ? void 0 : t[r]) ?? Ue(e)[r];
782
810
  return l != null && l !== "" ? String(l) : null;
783
811
  })
784
- ].filter((r) => !!r).map(cs);
785
- return sn.reasonFor(n);
786
- }, qt = a.summary_fields ?? [], Pr = we.map((e) => String(e.id)).join(","), Lr = fn({
787
- queries: qt.filter((e) => e.m2m).map((e) => ({
788
- queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, Pr],
812
+ ].filter((r) => !!r).map(gs);
813
+ return an.reasonFor(n);
814
+ }, jt = s.summary_fields ?? [], Qr = we.map((e) => String(e.id)).join(","), zr = xn({
815
+ queries: jt.filter((e) => e.m2m).map((e) => ({
816
+ queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, Qr],
789
817
  queryFn: async () => {
790
818
  const t = we.map((b) => String(b.id));
791
819
  if (t.length === 0) return {};
792
- const n = e.m2m, r = await k.request(
793
- J(`/items/${n.junction}`, {
820
+ const n = e.m2m, r = await w.request(
821
+ C(`/items/${n.junction}`, {
794
822
  limit: 1e3,
795
823
  fields: `${n.fk_to_child},${n.related_field}`,
796
824
  filter: JSON.stringify({ [n.fk_to_child]: { _in: t } })
797
825
  })
798
- ).then((b) => b.data ?? []).catch(() => []), l = [...new Set(r.map((b) => String(b[n.related_field])))], o = n.label_field ?? "name", h = l.length ? await k.request(
799
- J(`/items/${n.related_collection}`, {
826
+ ).then((b) => b.data ?? []).catch(() => []), l = [...new Set(r.map((b) => String(b[n.related_field])))], o = n.label_field ?? "name", f = l.length ? await w.request(
827
+ C(`/items/${n.related_collection}`, {
800
828
  limit: 500,
801
829
  fields: `id,${o}`,
802
830
  filter: JSON.stringify({ id: { _in: l } })
803
831
  })
804
- ).then((b) => b.data ?? []).catch(() => []) : [], c = new Map(h.map((b) => [String(b.id), String(b[o] ?? b.id)])), p = {};
832
+ ).then((b) => b.data ?? []).catch(() => []) : [], c = new Map(f.map((b) => [String(b.id), String(b[o] ?? b.id)])), h = {};
805
833
  for (const b of r) {
806
- const q = String(b[n.fk_to_child]), j = c.get(String(b[n.related_field]));
807
- j && (p[q] = p[q] ? `${p[q]}, ${j}` : j);
834
+ const q = String(b[n.fk_to_child]), $ = c.get(String(b[n.related_field]));
835
+ $ && (h[q] = h[q] ? `${h[q]}, ${$}` : $);
808
836
  }
809
- return p;
837
+ return h;
810
838
  },
811
- enabled: !P && we.length > 0,
839
+ enabled: !T && we.length > 0,
812
840
  staleTime: 15e3
813
841
  }))
814
- }), Er = (e, t) => {
842
+ }), Ur = (e, t) => {
815
843
  var l, o;
816
844
  if (!e.m2m) return t.row[e.field];
817
- const n = qt.filter((h) => h.m2m).findIndex((h) => h.field === e.field);
845
+ const n = jt.filter((f) => f.m2m).findIndex((f) => f.field === e.field);
818
846
  if (n === -1) return;
819
847
  const r = t.row.id;
820
848
  if (r != null)
821
- return (o = (l = Lr[n]) == null ? void 0 : l.data) == null ? void 0 : o[String(r)];
822
- }, Ar = !!((er = a.fulfilment) != null && er.shipped_field) && (a.fulfilment.show_when ? or(a.fulfilment.show_when, S) : !0), Kr = (e) => {
823
- if (!Ar || !a.fulfilment) return null;
824
- const t = Number(e[a.fulfilment.qty_field ?? I] ?? 0) || 0, n = Number(e[a.fulfilment.shipped_field] ?? 0) || 0, r = t > 0 && n >= t ? {
849
+ return (o = (l = zr[n]) == null ? void 0 : l.data) == null ? void 0 : o[String(r)];
850
+ }, Mr = !!((ir = s.fulfilment) != null && ir.shipped_field) && (s.fulfilment.show_when ? hr(s.fulfilment.show_when, S) : !0), Wr = (e) => {
851
+ if (!Mr || !s.fulfilment) return null;
852
+ const t = Number(e[s.fulfilment.qty_field ?? z] ?? 0) || 0, n = Number(e[s.fulfilment.shipped_field] ?? 0) || 0, r = t > 0 && n >= t ? {
825
853
  dot: "bg-emerald-500",
826
854
  text: "text-emerald-700 dark:text-emerald-400",
827
855
  label: "Shipped"
@@ -833,7 +861,7 @@ function ya({
833
861
  dot: "bg-slate-300 dark:bg-slate-600",
834
862
  text: "text-slate-500 dark:text-slate-400",
835
863
  // The header's ORDER STATUS word for the same order (army 11 a2 F8).
836
- label: a.fulfilment.pending_label ?? "Order Sent",
864
+ label: s.fulfilment.pending_label ?? "Order Sent",
837
865
  key: "requested"
838
866
  };
839
867
  return /* @__PURE__ */ u(
@@ -841,14 +869,14 @@ function ya({
841
869
  {
842
870
  className: "inline-flex items-center gap-1.5 whitespace-nowrap",
843
871
  "data-catalog-fulfilment": "key" in r ? r.key : r.label.split(" ")[0].toLowerCase(),
844
- title: `${a.fulfilment.label ?? "Warehouse"} · ${n} of ${t} shipped`,
872
+ title: `${s.fulfilment.label ?? "Warehouse"} · ${n} of ${t} shipped`,
845
873
  children: [
846
- /* @__PURE__ */ s("span", { "aria-hidden": !0, className: `h-1.5 w-1.5 rounded-full ${r.dot}` }),
847
- /* @__PURE__ */ s("span", { className: `text-[11px] font-medium ${r.text}`, children: r.label })
874
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: `h-1.5 w-1.5 rounded-full ${r.dot}` }),
875
+ /* @__PURE__ */ a("span", { className: `text-[11px] font-medium ${r.text}`, children: r.label })
848
876
  ]
849
877
  }
850
878
  );
851
- }, En = a.columns ?? [], An = a.related_columns ?? [], $t = En.filter((e) => !e.summary_only), ln = An.filter((e) => !e.summary_only), Kn = En.filter((e) => !e.sections_only), Cn = An.filter((e) => !e.sections_only), Jn = $t.length > 0 || ln.length > 0, on = qe(null), In = (e) => {
879
+ }, Qn = s.columns ?? [], zn = s.related_columns ?? [], Ft = Qn.filter((e) => !e.summary_only), on = zn.filter((e) => !e.summary_only), Un = Qn.filter((e) => !e.sections_only), Mn = zn.filter((e) => !e.sections_only), Wn = Ft.length > 0 || on.length > 0, dn = je(null), Vn = (e) => {
852
880
  let t = e.parentElement;
853
881
  for (; t; ) {
854
882
  const n = getComputedStyle(t);
@@ -858,101 +886,101 @@ function ya({
858
886
  }
859
887
  t = t.parentElement;
860
888
  }
861
- }, Cr = (e) => {
862
- on.current = e, e && In(e);
889
+ }, Vr = (e) => {
890
+ dn.current = e, e && Vn(e);
863
891
  };
864
- $e(() => {
892
+ Fe(() => {
865
893
  let e = 0;
866
894
  const t = () => {
867
895
  e || (e = requestAnimationFrame(() => {
868
- e = 0, on.current && In(on.current);
896
+ e = 0, dn.current && Vn(dn.current);
869
897
  }));
870
898
  };
871
899
  return window.addEventListener("scroll", t, !0), () => {
872
900
  e && cancelAnimationFrame(e), window.removeEventListener("scroll", t, !0);
873
901
  };
874
902
  }, []);
875
- const jt = (e, t) => {
903
+ const Tt = (e, t) => {
876
904
  let n = e;
877
905
  for (const r of t.split(".")) {
878
906
  if (n == null || typeof n != "object") return;
879
907
  n = n[r];
880
908
  }
881
909
  return n;
882
- }, Te = (e, t) => {
910
+ }, ve = (e, t) => {
883
911
  if (t === "presence")
884
912
  return e == null || e === "" || Number(e) === 0 ? "No" : "Yes";
885
913
  if (e == null || e === "") return "—";
886
914
  const n = Number(e);
887
915
  return t === "currency" ? Number.isNaN(n) ? String(e) : n.toLocaleString(void 0, { style: "currency", currency: "USD" }) : t === "number" ? Number.isNaN(n) ? String(e) : n.toLocaleString(void 0, { maximumFractionDigits: 2 }) : String(e);
888
- }, Ft = y ? `${y}:${i}.${m}` : null, Ae = lr(Ft && `${Ft}:catalog`), Oe = lr(Ft && `${Ft}:summary`), Qn = qe(null), Jr = (e, t) => {
889
- const n = hs(Qn.current, t);
916
+ }, Rt = y ? `${y}:${i}.${m}` : null, Ke = pr(Rt && `${Rt}:catalog`), Oe = pr(Rt && `${Rt}:summary`), Bn = je(null), Br = (e, t) => {
917
+ const n = Ss(Bn.current, t);
890
918
  n != null && e.setWidth(t, n);
891
- }, Tt = (e, t, n, r, l) => {
919
+ }, Ot = (e, t, n, r, l) => {
892
920
  const o = e.box(t, r, l);
893
921
  return /* @__PURE__ */ u("span", { ...o, className: W("relative", o.className), children: [
894
- /* @__PURE__ */ s("span", { "data-cpf-fit": !0, className: "block truncate", children: n }),
895
- /* @__PURE__ */ s(
896
- ps,
922
+ /* @__PURE__ */ a("span", { "data-cpf-fit": !0, className: "block truncate", children: n }),
923
+ /* @__PURE__ */ a(
924
+ vs,
897
925
  {
898
926
  label: n,
899
- onResize: (h) => e.setWidth(t, h),
900
- onFit: () => Jr(e, t)
927
+ onResize: (f) => e.setWidth(t, f),
928
+ onFit: () => Br(e, t)
901
929
  }
902
930
  )
903
931
  ] }, t);
904
- }, Ir = (tr = $t.find((e) => !e.format)) == null ? void 0 : tr.field, zn = (e) => e.format ? ["w-20 shrink-0", "text-right"] : e.field === Ir ? ["min-w-0 flex-[3]", ""] : ["w-36 shrink-0", ""], dn = (e, t, n) => /* @__PURE__ */ u(Ne, { children: [
905
- $t.map((r) => {
906
- const [l, o] = zn(r);
907
- return /* @__PURE__ */ s(
908
- dr,
932
+ }, Dr = (lr = Ft.find((e) => !e.format)) == null ? void 0 : lr.field, Dn = (e) => e.format ? ["w-20 shrink-0", "text-right"] : e.field === Dr ? ["min-w-0 flex-[3]", ""] : ["w-36 shrink-0", ""], cn = (e, t, n) => /* @__PURE__ */ u(Se, { children: [
933
+ Ft.map((r) => {
934
+ const [l, o] = Dn(r);
935
+ return /* @__PURE__ */ a(
936
+ br,
909
937
  {
910
- text: Te(
911
- As({
938
+ text: ve(
939
+ Ys({
912
940
  field: r.field,
913
- catalogValue: jt(t, r.field),
914
- copyFields: a.copy_fields,
915
- related: a.related_columns,
916
- lookup: (h) => at(h, e)
941
+ catalogValue: Tt(t, r.field),
942
+ copyFields: s.copy_fields,
943
+ related: s.related_columns,
944
+ lookup: (f) => lt(f, e)
917
945
  }),
918
946
  r.format
919
947
  ),
920
948
  highlight: r.format ? void 0 : n,
921
- ...Ae.box(r.field, l, W("text-slate-500 dark:text-slate-400", o))
949
+ ...Ke.box(r.field, l, W("text-slate-500 dark:text-slate-400", o))
922
950
  },
923
951
  r.field
924
952
  );
925
953
  }),
926
- ln.map((r) => /* @__PURE__ */ s(
954
+ on.map((r) => /* @__PURE__ */ a(
927
955
  "span",
928
956
  {
929
- ...Ae.box(
957
+ ...Ke.box(
930
958
  `rel:${r.key}`,
931
959
  "w-20 shrink-0",
932
960
  "truncate text-right text-slate-500 dark:text-slate-400"
933
961
  ),
934
- children: Te(at(r.key, e), r.format)
962
+ children: ve(lt(r.key, e), r.format)
935
963
  },
936
964
  r.key
937
965
  )),
938
- /* @__PURE__ */ s("span", { "aria-hidden": !0, className: "ml-auto" })
939
- ] }), Qr = ur(y), Mn = (e, t, n, r, l) => Qr ? /* @__PURE__ */ s(
966
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: "ml-auto" })
967
+ ] }), Hr = yr(y), Hn = (e, t, n, r, l) => Hr ? /* @__PURE__ */ a(
940
968
  "button",
941
969
  {
942
970
  type: "button",
943
971
  "data-cpf-fit": r || void 0,
944
- onClick: () => y && mr(y, e, S),
972
+ onClick: () => y && gr(y, e, S),
945
973
  title: "View stock & planning detail",
946
974
  className: W(
947
975
  n,
948
976
  "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600"
949
977
  ),
950
- children: l ? /* @__PURE__ */ s(hn, { text: t, query: l }) : t
978
+ children: l ? /* @__PURE__ */ a(gn, { text: t, query: l }) : t
951
979
  }
952
- ) : /* @__PURE__ */ s("span", { className: n, "data-cpf-fit": r || void 0, children: l ? /* @__PURE__ */ s(hn, { text: t, query: l }) : t }), cn = (e, t, n, r) => {
953
- const l = Ae.box("item", Jn ? "w-36 shrink-0" : "min-w-0 flex-1");
980
+ ) : /* @__PURE__ */ a("span", { className: n, "data-cpf-fit": r || void 0, children: l ? /* @__PURE__ */ a(gn, { text: t, query: l }) : t }), un = (e, t, n, r) => {
981
+ const l = Ke.box("item", Wn ? "w-36 shrink-0" : "min-w-0 flex-1");
954
982
  return /* @__PURE__ */ u("span", { ...l, className: W("flex min-w-0 items-center gap-1.5", l.className), children: [
955
- Mn(
983
+ Hn(
956
984
  e,
957
985
  t,
958
986
  "min-w-0 truncate text-slate-700 dark:text-slate-200",
@@ -961,42 +989,42 @@ function ya({
961
989
  ),
962
990
  n
963
991
  ] });
964
- }, Ot = (e) => {
965
- const t = ht.get(e) ?? zt.find((n) => String(n.id) === e) ?? et.find((n) => String(n.id) === e);
966
- return t ? Ke(A, t) : `#${e}`;
967
- }, Vn = qe(Ot);
968
- Vn.current = Ot;
969
- const Wn = qe(we);
970
- Wn.current = we, $e(
971
- () => os(i, (e) => {
972
- const t = Wn.current.find((o) => String(o.id) === String(e)), n = t == null ? void 0 : t[a.item_field], r = n && typeof n == "object" ? n.id : n;
992
+ }, Pt = (e) => {
993
+ const t = yt.get(e) ?? Ut.find((n) => String(n.id) === e) ?? nt.find((n) => String(n.id) === e);
994
+ return t ? Ce(K, t) : `#${e}`;
995
+ }, Yn = je(Pt);
996
+ Yn.current = Pt;
997
+ const Zn = je(we);
998
+ Zn.current = we, Fe(
999
+ () => xs(i, (e) => {
1000
+ const t = Zn.current.find((o) => String(o.id) === String(e)), n = t == null ? void 0 : t[s.item_field], r = n && typeof n == "object" ? n.id : n;
973
1001
  if (r == null || r === "") return null;
974
- const l = Vn.current(String(r));
1002
+ const l = Yn.current(String(r));
975
1003
  return l.startsWith("#") ? null : l;
976
1004
  }),
977
- [i, a.item_field]
1005
+ [i, s.item_field]
978
1006
  );
979
- const ze = (e) => ht.get(e) ?? zt.find((t) => String(t.id) === e) ?? et.find((t) => String(t.id) === e) ?? { id: e }, _e = (e) => {
1007
+ const Ue = (e) => yt.get(e) ?? Ut.find((t) => String(t.id) === e) ?? nt.find((t) => String(t.id) === e) ?? { id: e }, qe = (e) => {
980
1008
  var r;
981
- const t = P ? void 0 : Xe.get(e);
982
- if (t) return yt.has(String(t.id)) ? null : Number(t[I] ?? 0);
983
- const n = gt.get(e);
984
- return n === void 0 ? null : Number(((r = Fe[n]) == null ? void 0 : r[I]) ?? 0);
985
- }, zr = (e) => {
1009
+ const t = T ? void 0 : tt.get(e);
1010
+ if (t) return kt.has(String(t.id)) ? null : Number(t[z] ?? 0);
1011
+ const n = wt.get(e);
1012
+ return n === void 0 ? null : Number(((r = Re[n]) == null ? void 0 : r[z]) ?? 0);
1013
+ }, Yr = (e) => {
986
1014
  let t = e;
987
- for (const n of a.section_by.split(".")) {
1015
+ for (const n of s.section_by.split(".")) {
988
1016
  if (t == null || typeof t != "object") return "";
989
1017
  t = t[n];
990
1018
  }
991
1019
  return String(t ?? "").trim();
992
- }, Rt = E(() => {
993
- if (pt) return [];
994
- U.trim().toLowerCase();
1020
+ }, Lt = R(() => {
1021
+ if (xt) return [];
1022
+ V.trim().toLowerCase();
995
1023
  const e = /* @__PURE__ */ new Map();
996
1024
  for (const t of oe) {
997
- if (ce && it !== void 0 && !(Number(it[String(t.id)]) > 0)) continue;
998
- const n = Ke(A, t), r = K ? kn.get(String(t.id)) ?? [] : [zr(t)];
999
- if (!(K && Y && r.length === 0))
1025
+ if (ce && ot !== void 0 && !(Number(ot[String(t.id)]) > 0)) continue;
1026
+ const n = Ce(K, t), r = A ? Sn.get(String(t.id)) ?? [] : [Yr(t)];
1027
+ if (!(A && Y && r.length === 0))
1000
1028
  for (const l of r.length ? r : [""]) {
1001
1029
  const o = l || "Uncategorized";
1002
1030
  e.has(o) || e.set(o, []), e.get(o).push({ id: String(t.id), label: n, row: t });
@@ -1010,40 +1038,40 @@ function ya({
1010
1038
  }));
1011
1039
  }, [
1012
1040
  oe,
1013
- A,
1014
- U,
1015
- a.section_by,
1016
1041
  K,
1017
- kn,
1018
- pt,
1042
+ V,
1043
+ s.section_by,
1044
+ A,
1045
+ Sn,
1046
+ xt,
1019
1047
  Y,
1020
1048
  ce,
1021
- it
1049
+ ot
1022
1050
  ]);
1023
- if (!ke.current && Rt.length > 0) {
1051
+ if (!ke.current && Lt.length > 0) {
1024
1052
  ke.current = !0;
1025
1053
  const e = /* @__PURE__ */ new Set();
1026
- for (const t of Rt)
1027
- t.items.some((r) => (_e(r.id) ?? 0) > 0) || e.add(t.name);
1054
+ for (const t of Lt)
1055
+ t.items.some((r) => (qe(r.id) ?? 0) > 0) || e.add(t.name);
1028
1056
  ge(e);
1029
1057
  }
1030
- async function Mr(e) {
1058
+ async function Zr(e) {
1031
1059
  const t = {};
1032
- for (const n of a.related_columns ?? []) {
1060
+ for (const n of s.related_columns ?? []) {
1033
1061
  if (!n.copy_to) continue;
1034
- let r = at(n.key, e);
1062
+ let r = lt(n.key, e);
1035
1063
  if (r === void 0) {
1036
- const l = Ye(n.match, S);
1064
+ const l = Ge(n.match, S);
1037
1065
  if (l === null) continue;
1038
- r = await k.request(
1039
- J(`/items/${n.collection}`, {
1066
+ r = await w.request(
1067
+ C(`/items/${n.collection}`, {
1040
1068
  limit: 1,
1041
1069
  fields: `${n.item_field},${n.value_field}`,
1042
1070
  filter: JSON.stringify({ ...l, [n.item_field]: { _eq: e } })
1043
1071
  })
1044
1072
  ).then((o) => {
1045
- var h, c;
1046
- return (c = (h = o.data) == null ? void 0 : h[0]) == null ? void 0 : c[n.value_field];
1073
+ var f, c;
1074
+ return (c = (f = o.data) == null ? void 0 : f[0]) == null ? void 0 : c[n.value_field];
1047
1075
  }).catch(() => {
1048
1076
  });
1049
1077
  }
@@ -1051,263 +1079,299 @@ function ya({
1051
1079
  }
1052
1080
  return t;
1053
1081
  }
1054
- const Un = (e, t) => {
1055
- var r;
1056
- for (const l of a.related_columns ?? []) {
1057
- if (l.copy_to !== t) continue;
1058
- const o = at(l.key, e);
1059
- if (o != null && o !== "") return o;
1082
+ const mn = (e, t) => {
1083
+ var l;
1084
+ for (const o of s.related_columns ?? []) {
1085
+ if (o.copy_to !== t) continue;
1086
+ const f = lt(o.key, e);
1087
+ if (f != null && f !== "") return f;
1060
1088
  }
1061
- const n = (r = a.copy_fields) == null ? void 0 : r[t];
1062
- return n ? ze(e)[n] : void 0;
1063
- }, Bn = qe(/* @__PURE__ */ new Map()), Pt = E(() => {
1064
- const e = new Set(Object.keys(a.copy_fields ?? {}));
1065
- for (const t of a.related_columns ?? []) t.copy_to && e.add(t.copy_to);
1089
+ const n = (l = s.copy_fields) == null ? void 0 : l[t];
1090
+ if (!n) return;
1091
+ const r = Lr.get(e.toUpperCase());
1092
+ return r && n in r ? r[n] : Ue(e)[n];
1093
+ }, Gn = je(/* @__PURE__ */ new Map()), ct = R(() => {
1094
+ const e = new Set(Object.keys(s.copy_fields ?? {}));
1095
+ for (const t of s.related_columns ?? []) t.copy_to && e.add(t.copy_to);
1066
1096
  return [...e];
1067
- }, [a.copy_fields, a.related_columns]), Vr = JSON.stringify([
1068
- Fe.map((e) => [e[a.item_field], ...Pt.map((t) => e[t] ?? null)]),
1069
- st.map((e) => e.dataUpdatedAt),
1097
+ }, [s.copy_fields, s.related_columns]), fn = ct.filter(
1098
+ (e) => {
1099
+ var t;
1100
+ return !(e in (s.compute_fields ?? {})) && (((t = s.field_formats) == null ? void 0 : t[e]) === "currency" || /(^|_)price$/i.test(e));
1101
+ }
1102
+ ), Gr = (e, t) => fn.map((n) => {
1103
+ const r = Ps(e[n], mn(t, n));
1104
+ return r ? { field: n, change: r } : null;
1105
+ }).filter((n) => !!n), pn = R(() => {
1106
+ const e = (s.related_columns ?? []).find((t) => {
1107
+ var n;
1108
+ return t.key === ((n = s.qty_warning) == null ? void 0 : n.column);
1109
+ });
1110
+ for (const t of Object.values((e == null ? void 0 : e.match) ?? {})) {
1111
+ const n = t && typeof t == "object" ? t._eq : t;
1112
+ if (typeof n == "string" && n.startsWith("$parent.")) return n.slice(8);
1113
+ }
1114
+ return null;
1115
+ }, [s.related_columns, (or = s.qty_warning) == null ? void 0 : or.column]), Xr = Fs(
1116
+ k ? null : g,
1117
+ pn,
1118
+ pn ? S == null ? void 0 : S[pn] : null
1119
+ );
1120
+ Ts({
1121
+ enabled: !k && Ne.length > 0,
1122
+ catalogCol: y,
1123
+ pickedIds: at,
1124
+ related: (s.related_columns ?? []).filter(
1125
+ (e, t) => {
1126
+ var n;
1127
+ return t === We || e.key === ((n = s.qty_warning) == null ? void 0 : n.column) || !!e.copy_to && fn.includes(e.copy_to);
1128
+ }
1129
+ ).map((e) => ({ key: e.key, collection: e.collection }))
1130
+ });
1131
+ const es = JSON.stringify([
1132
+ Re.map((e) => [e[s.item_field], ...ct.map((t) => e[t] ?? null)]),
1133
+ it.map((e) => e.dataUpdatedAt),
1070
1134
  oe.length,
1071
- zt.length
1135
+ Ut.length
1072
1136
  ]);
1073
- $e(() => {
1074
- w || !v || Pt.length === 0 || Fe.forEach((e, t) => {
1075
- const n = e[a.item_field];
1137
+ Fe(() => {
1138
+ k || !v || ct.length === 0 || Re.forEach((e, t) => {
1139
+ const n = e[s.item_field];
1076
1140
  if (n == null) return;
1077
- const r = Ts(
1141
+ const r = Ms(
1078
1142
  e,
1079
- Pt,
1080
- (o) => Un(String(n), o),
1081
- Bn.current.get(String(n))
1143
+ ct,
1144
+ (o) => mn(String(n), o),
1145
+ Gn.current.get(String(n))
1082
1146
  );
1083
1147
  if (!r) return;
1084
- Bn.current.set(String(n), r.auto);
1148
+ Gn.current.set(String(n), r.auto);
1085
1149
  const l = { ...e, ...r.updates };
1086
- for (const [o, h] of Object.entries(a.compute_fields ?? {})) {
1087
- const c = Ee(h, l);
1150
+ for (const [o, f] of Object.entries(s.compute_fields ?? {})) {
1151
+ const c = Ee(f, l);
1088
1152
  c !== null && (l[o] = c);
1089
1153
  }
1090
1154
  v.updateRow(i, m, t, l);
1091
1155
  });
1092
- }, [Vr, w, Pt]);
1093
- const Wr = (e, t) => {
1094
- if (w || !M.includes(t)) return !1;
1156
+ }, [es, k, ct]);
1157
+ const ts = (e, t) => {
1158
+ if (k || !M.includes(t)) return !1;
1095
1159
  if (fe || !me.includes(t)) return !0;
1096
- const n = Un(e, t);
1160
+ const n = mn(e, t);
1097
1161
  return n == null || n === "" || !(Number(n) > 0);
1098
1162
  };
1099
- function Ue(e, t, n, r = {}) {
1163
+ function He(e, t, n, r = {}) {
1100
1164
  const l = {
1101
- [a.item_field]: n.id ?? e,
1102
- [I]: t
1165
+ [s.item_field]: n.id ?? e,
1166
+ [z]: t
1103
1167
  };
1104
- for (const [o, h] of Object.entries(a.copy_fields ?? {}))
1105
- n[h] !== void 0 && (l[o] = n[h]);
1168
+ for (const [o, f] of Object.entries(s.copy_fields ?? {}))
1169
+ n[f] !== void 0 && (l[o] = n[f]);
1106
1170
  Object.assign(l, r);
1107
- for (const [o, h] of Object.entries(a.compute_fields ?? {})) {
1108
- const c = Ee(h, l);
1171
+ for (const [o, f] of Object.entries(s.compute_fields ?? {})) {
1172
+ const c = Ee(f, l);
1109
1173
  c !== null && (l[o] = c);
1110
1174
  }
1111
1175
  return l;
1112
1176
  }
1113
- function Ur(e, t, n, r) {
1114
- return Es({
1115
- compute: a.compute_fields ?? {},
1116
- probe: { ...Ue(e, t, n), ...r, [I]: t },
1117
- ruleError: O,
1177
+ function ns(e, t, n, r) {
1178
+ return Hs({
1179
+ compute: s.compute_fields ?? {},
1180
+ probe: { ...He(e, t, n), ...r, [z]: t },
1181
+ ruleError: P,
1118
1182
  labelOf: (l) => {
1119
1183
  var o;
1120
- return ((o = N.find((h) => h.field === l)) == null ? void 0 : o.label) || X(l);
1184
+ return ((o = N.find((f) => f.field === l)) == null ? void 0 : o.label) || Z(l);
1121
1185
  }
1122
1186
  });
1123
1187
  }
1124
- async function Be(e, t, n, r = {}) {
1125
- const l = bn(t, { type: L, min: 0, label: "Quantity" });
1188
+ async function Ye(e, t, n, r = {}) {
1189
+ const l = kn(t, { type: E, min: 0, label: "Quantity" });
1126
1190
  if (!l.ok) {
1127
- se((p) => ({ ...p, [e]: { kind: "error", message: l.message } }));
1191
+ se((h) => ({ ...h, [e]: { kind: "error", message: l.message } }));
1128
1192
  return;
1129
1193
  }
1130
1194
  const o = l.value ?? 0;
1131
- if ((_e(e) ?? 0) === o) return;
1195
+ if ((qe(e) ?? 0) === o) return;
1132
1196
  if (o === 0 && !r.confirmedRemove) {
1133
- se((p) => ({ ...p, [e]: { kind: "remove", row: n } }));
1197
+ se((h) => ({ ...h, [e]: { kind: "remove", row: n } }));
1134
1198
  return;
1135
1199
  }
1136
1200
  if (o > 0) {
1137
- const p = gt.get(e), b = (P ? void 0 : Xe.get(e)) ?? (p !== void 0 ? Fe[p] : void 0) ?? {}, q = O(I, o, b) ?? Ur(e, o, n, b);
1201
+ const h = wt.get(e), b = (T ? void 0 : tt.get(e)) ?? (h !== void 0 ? Re[h] : void 0) ?? {}, q = P(z, o, b) ?? ns(e, o, n, b);
1138
1202
  if (q) {
1139
- se((j) => ({ ...j, [e]: { kind: "error", message: q } }));
1203
+ se(($) => ({ ...$, [e]: { kind: "error", message: q } }));
1140
1204
  return;
1141
1205
  }
1142
1206
  }
1143
- const c = o > 0 ? await Mr(e) : {};
1144
- if (Ge && v) {
1145
- const p = Xe.get(e);
1146
- if ((p == null ? void 0 : p.id) != null) {
1147
- const b = String(p.id);
1207
+ const c = o > 0 ? await Zr(e) : {};
1208
+ if (et && v) {
1209
+ const h = tt.get(e);
1210
+ if ((h == null ? void 0 : h.id) != null) {
1211
+ const b = String(h.id);
1148
1212
  if (o === 0) {
1149
1213
  v.cancelPendingEdit(i, m, b), v.queueDelete(i, m, b);
1150
1214
  return;
1151
1215
  }
1152
- yt.has(b) && v.cancelPendingDelete(i, m, b);
1153
- const q = Ue(e, o, n, c);
1154
- for (const g of M)
1155
- p[g] != null && p[g] !== "" && (q[g] = p[g]);
1156
- for (const [g, V] of Object.entries(a.compute_fields ?? {})) {
1157
- const Le = Ee(V, { ...p, ...q });
1158
- Le !== null && (q[g] = Le);
1216
+ kt.has(b) && v.cancelPendingDelete(i, m, b);
1217
+ const q = He(e, o, n, c);
1218
+ for (const x of M)
1219
+ h[x] != null && h[x] !== "" && (q[x] = h[x]);
1220
+ for (const [x, I] of Object.entries(s.compute_fields ?? {})) {
1221
+ const $e = Ee(I, { ...h, ...q });
1222
+ $e !== null && (q[x] = $e);
1159
1223
  }
1160
- const j = we.find((g) => String(g.id) === b) ?? {}, C = Object.fromEntries(
1161
- Object.entries(q).filter(([g, V]) => String(V ?? "") !== String(j[g] ?? ""))
1224
+ const $ = we.find((x) => String(x.id) === b) ?? {}, J = Object.fromEntries(
1225
+ Object.entries(q).filter(([x, I]) => String(I ?? "") !== String($[x] ?? ""))
1162
1226
  );
1163
- Object.keys(C).length === 0 ? v.cancelPendingEdit(i, m, b) : (v.cancelPendingEdit(i, m, b), v.queueEdit(i, m, b, C));
1227
+ Object.keys(J).length === 0 ? v.cancelPendingEdit(i, m, b) : (v.cancelPendingEdit(i, m, b), v.queueEdit(i, m, b, J));
1164
1228
  return;
1165
1229
  }
1166
1230
  }
1167
- if (P || Ge) {
1168
- const p = gt.get(e);
1169
- o === 0 ? p !== void 0 && (v == null || v.removeRow(i, m, p)) : p !== void 0 ? v == null || v.updateRow(
1231
+ if (T || et) {
1232
+ const h = wt.get(e);
1233
+ o === 0 ? h !== void 0 && (v == null || v.removeRow(i, m, h)) : h !== void 0 ? v == null || v.updateRow(
1170
1234
  i,
1171
1235
  m,
1172
- p,
1173
- Ns(
1174
- Fe[p],
1175
- Ue(e, o, n, c),
1236
+ h,
1237
+ Ks(
1238
+ Re[h],
1239
+ He(e, o, n, c),
1176
1240
  M,
1177
- a.compute_fields
1241
+ s.compute_fields
1178
1242
  )
1179
1243
  ) : v == null || v.queueRow(
1180
1244
  i,
1181
1245
  m,
1182
- Ue(e, o, n, c)
1246
+ He(e, o, n, c)
1183
1247
  );
1184
1248
  return;
1185
1249
  }
1186
- Z((p) => new Set(p).add(e));
1250
+ G((h) => new Set(h).add(e));
1187
1251
  try {
1188
- const p = Xe.get(e);
1252
+ const h = tt.get(e);
1189
1253
  if (o === 0)
1190
- (p == null ? void 0 : p.id) != null && await k.request(rs(`/items/${i}/${p.id}${be}`));
1191
- else if ((p == null ? void 0 : p.id) != null) {
1192
- const b = Ue(e, o, n, c);
1193
- for (const g of M)
1194
- p[g] != null && p[g] !== "" && (b[g] = p[g]);
1195
- for (const [g, V] of Object.entries(a.compute_fields ?? {})) {
1196
- const Le = Ee(V, { ...p, ...b });
1197
- Le !== null && (b[g] = Le);
1254
+ (h == null ? void 0 : h.id) != null && await w.request(ms(`/items/${i}/${h.id}${be}`));
1255
+ else if ((h == null ? void 0 : h.id) != null) {
1256
+ const b = He(e, o, n, c);
1257
+ for (const x of M)
1258
+ h[x] != null && h[x] !== "" && (b[x] = h[x]);
1259
+ for (const [x, I] of Object.entries(s.compute_fields ?? {})) {
1260
+ const $e = Ee(I, { ...h, ...b });
1261
+ $e !== null && (b[x] = $e);
1198
1262
  }
1199
- const q = { ...p, ...b }, { id: j, ...C } = q;
1200
- await k.request(ar(`/items/${i}/${p.id}${be}`, C));
1263
+ const q = { ...h, ...b }, { id: $, ...J } = q;
1264
+ await w.request(mr(`/items/${i}/${h.id}${be}`, J));
1201
1265
  } else
1202
- await k.request(
1203
- ir(`/items/${i}${be}`, {
1204
- [m]: f,
1205
- ...Ue(e, o, n, c)
1266
+ await w.request(
1267
+ fr(`/items/${i}${be}`, {
1268
+ [m]: p,
1269
+ ...He(e, o, n, c)
1206
1270
  })
1207
1271
  );
1208
- T.invalidateQueries({ queryKey: ["o2m-rows", i, m, f] });
1272
+ O.invalidateQueries({ queryKey: ["o2m-rows", i, m, p] });
1209
1273
  } catch {
1210
1274
  } finally {
1211
- Z((p) => {
1212
- const b = new Set(p);
1275
+ G((h) => {
1276
+ const b = new Set(h);
1213
1277
  return b.delete(e), b;
1214
1278
  });
1215
1279
  }
1216
1280
  }
1217
- async function Br(e, t, n) {
1281
+ async function Xn(e, t, n) {
1218
1282
  const r = n.trim() === "" ? null : Number(n);
1219
1283
  if (n.trim() !== "" && Number.isNaN(r)) return;
1220
- const l = (h) => {
1221
- const c = { ...h, [t]: r };
1222
- for (const [p, b] of Object.entries(a.compute_fields ?? {})) {
1284
+ const l = (f) => {
1285
+ const c = { ...f, [t]: r };
1286
+ for (const [h, b] of Object.entries(s.compute_fields ?? {})) {
1223
1287
  const q = Ee(b, c);
1224
- q !== null && (c[p] = q);
1288
+ q !== null && (c[h] = q);
1225
1289
  }
1226
1290
  return c;
1227
- }, o = P ? void 0 : Xe.get(e);
1291
+ }, o = T ? void 0 : tt.get(e);
1228
1292
  if ((o == null ? void 0 : o.id) == null) {
1229
- const h = gt.get(e);
1230
- if (h === void 0) return;
1231
- v == null || v.updateRow(i, m, h, l(Fe[h]));
1293
+ const f = wt.get(e);
1294
+ if (f === void 0) return;
1295
+ v == null || v.updateRow(i, m, f, l(Re[f]));
1232
1296
  return;
1233
1297
  }
1234
- if (Ge && v) {
1235
- const h = l(o), c = we.find((b) => String(b.id) === String(o.id)) ?? {}, p = Object.fromEntries(
1236
- Object.entries(h).filter(
1298
+ if (et && v) {
1299
+ const f = l(o), c = we.find((b) => String(b.id) === String(o.id)) ?? {}, h = Object.fromEntries(
1300
+ Object.entries(f).filter(
1237
1301
  ([b, q]) => b !== "id" && String(q ?? "") !== String(c[b] ?? "")
1238
1302
  )
1239
1303
  );
1240
- v.cancelPendingEdit(i, m, String(o.id)), Object.keys(p).length > 0 && v.queueEdit(i, m, String(o.id), p);
1304
+ v.cancelPendingEdit(i, m, String(o.id)), Object.keys(h).length > 0 && v.queueEdit(i, m, String(o.id), h);
1241
1305
  return;
1242
1306
  }
1243
- Z((h) => new Set(h).add(e));
1307
+ G((f) => new Set(f).add(e));
1244
1308
  try {
1245
- const { id: h, ...c } = l(o);
1246
- await k.request(ar(`/items/${i}/${o.id}${be}`, c)), T.invalidateQueries({ queryKey: ["o2m-rows", i, m, f] });
1309
+ const { id: f, ...c } = l(o);
1310
+ await w.request(mr(`/items/${i}/${o.id}${be}`, c)), O.invalidateQueries({ queryKey: ["o2m-rows", i, m, p] });
1247
1311
  } catch {
1248
1312
  } finally {
1249
- Z((h) => {
1250
- const c = new Set(h);
1313
+ G((f) => {
1314
+ const c = new Set(f);
1251
1315
  return c.delete(e), c;
1252
1316
  });
1253
1317
  }
1254
1318
  }
1255
- async function Dr(e) {
1319
+ async function rs(e) {
1256
1320
  if (e == null || e === "" || !y) return;
1257
- const t = String(e), n = ze(t);
1321
+ const t = String(e), n = Ue(t);
1258
1322
  let r = n;
1259
- Object.keys(n).length <= 1 && (r = await k.request(
1260
- J(`/items/${y}`, {
1323
+ Object.keys(n).length <= 1 && (r = await w.request(
1324
+ C(`/items/${y}`, {
1261
1325
  filter: JSON.stringify({ id: { _eq: e } }),
1262
- fields: z,
1326
+ fields: U,
1263
1327
  limit: 1
1264
1328
  })
1265
1329
  ).then((o) => {
1266
- var h;
1267
- return ((h = o.data) == null ? void 0 : h[0]) ?? { id: e };
1330
+ var f;
1331
+ return ((f = o.data) == null ? void 0 : f[0]) ?? { id: e };
1268
1332
  }).catch(() => ({ id: e })));
1269
- const l = (_e(t) ?? 0) + 1;
1270
- await Be(t, String(l), r);
1333
+ const l = (qe(t) ?? 0) + 1;
1334
+ await Ye(t, String(l), r);
1271
1335
  }
1272
- const Hr = Se.length, Lt = Object.keys(a.copy_fields ?? {}), De = Object.keys(a.compute_fields ?? {}), Et = (e, t) => {
1273
- const n = _e(e);
1274
- if (w)
1275
- return /* @__PURE__ */ s("span", { className: "inline-block w-20 shrink-0 text-right tabular-nums text-slate-700 dark:text-slate-200", children: n && n > 0 ? n.toLocaleString("en-US") : "—" });
1276
- const r = he[e], l = r !== void 0 ? r : n && n > 0 ? String(n) : "", o = B[e], h = () => se((p) => {
1277
- if (!(e in p)) return p;
1278
- const b = { ...p };
1336
+ const ss = Ne.length, Et = Object.keys(s.copy_fields ?? {}), Ze = Object.keys(s.compute_fields ?? {}), Kt = (e, t) => {
1337
+ const n = qe(e);
1338
+ if (k)
1339
+ return /* @__PURE__ */ a("span", { className: "inline-block w-20 shrink-0 text-right tabular-nums text-slate-700 dark:text-slate-200", children: n && n > 0 ? n.toLocaleString("en-US") : "—" });
1340
+ const r = he[e], l = r !== void 0 ? r : n && n > 0 ? String(n) : "", o = B[e], f = () => se((h) => {
1341
+ if (!(e in h)) return h;
1342
+ const b = { ...h };
1279
1343
  return delete b[e], b;
1280
- }), c = /* @__PURE__ */ s(
1344
+ }), c = /* @__PURE__ */ a(
1281
1345
  "input",
1282
1346
  {
1283
1347
  type: "number",
1284
1348
  min: 0,
1285
- step: dt(L) ? 1 : "any",
1286
- disabled: w,
1349
+ step: mt(E) ? 1 : "any",
1350
+ disabled: k,
1287
1351
  value: l,
1288
1352
  placeholder: "0",
1289
1353
  "aria-invalid": (o == null ? void 0 : o.kind) === "error" || void 0,
1290
- onFocus: h,
1291
- onChange: (p) => re((b) => ({ ...b, [e]: p.target.value })),
1292
- onBlur: (p) => {
1293
- const b = p.target.value, q = Rs(b, L);
1354
+ onFocus: f,
1355
+ onChange: (h) => re((b) => ({ ...b, [e]: h.target.value })),
1356
+ onBlur: (h) => {
1357
+ const b = h.target.value, q = Vs(b, E);
1294
1358
  if (q) {
1295
- re((j) => {
1296
- const C = { ...j };
1297
- return delete C[e], C;
1298
- }), se((j) => ({
1299
- ...j,
1300
- [e]: { kind: "error", message: Ls(q, b) }
1359
+ re(($) => {
1360
+ const J = { ...$ };
1361
+ return delete J[e], J;
1362
+ }), se(($) => ({
1363
+ ...$,
1364
+ [e]: { kind: "error", message: Ds(q, b) }
1301
1365
  }));
1302
1366
  return;
1303
1367
  }
1304
- re((j) => {
1305
- const C = { ...j };
1306
- return delete C[e], C;
1307
- }), Be(e, b, t);
1368
+ re(($) => {
1369
+ const J = { ...$ };
1370
+ return delete J[e], J;
1371
+ }), Ye(e, b, t);
1308
1372
  },
1309
- onKeyDown: (p) => {
1310
- p.key === "Enter" && p.currentTarget.blur();
1373
+ onKeyDown: (h) => {
1374
+ h.key === "Enter" && h.currentTarget.blur();
1311
1375
  },
1312
1376
  className: W(
1313
1377
  "h-7 w-20 shrink-0 rounded border border-slate-200 bg-white px-2 text-right text-[12px] outline-none focus:border-nvr-cyan disabled:opacity-50 dark:border-border dark:bg-background",
@@ -1324,7 +1388,7 @@ function ya({
1324
1388
  className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
1325
1389
  "data-catalog-qty-error": !0,
1326
1390
  children: [
1327
- /* @__PURE__ */ s(un, { className: "mt-px h-3 w-3 shrink-0" }),
1391
+ /* @__PURE__ */ a(hn, { className: "mt-px h-3 w-3 shrink-0" }),
1328
1392
  o.message,
1329
1393
  n && n > 0 ? ` — still ${n.toLocaleString("en-US")}` : ""
1330
1394
  ]
@@ -1337,23 +1401,23 @@ function ya({
1337
1401
  "data-catalog-qty-remove": !0,
1338
1402
  className: "mt-1 flex max-w-[240px] flex-wrap items-center justify-end gap-1.5 text-right text-[11px] leading-snug text-slate-700 dark:text-slate-200",
1339
1403
  children: [
1340
- /* @__PURE__ */ s("span", { children: "Remove this line?" }),
1341
- /* @__PURE__ */ s(
1404
+ /* @__PURE__ */ a("span", { children: "Remove this line?" }),
1405
+ /* @__PURE__ */ a(
1342
1406
  "button",
1343
1407
  {
1344
1408
  type: "button",
1345
- onClick: h,
1409
+ onClick: f,
1346
1410
  className: "h-6 rounded border border-slate-200 px-2 text-[11px] text-slate-600 hover:bg-muted dark:border-border dark:text-slate-300",
1347
1411
  children: "Keep"
1348
1412
  }
1349
1413
  ),
1350
- /* @__PURE__ */ s(
1414
+ /* @__PURE__ */ a(
1351
1415
  "button",
1352
1416
  {
1353
1417
  type: "button",
1354
1418
  onClick: () => {
1355
- const p = o.row;
1356
- h(), Be(e, "0", p, { confirmedRemove: !0 });
1419
+ const h = o.row;
1420
+ f(), Ye(e, "0", h, { confirmedRemove: !0 });
1357
1421
  },
1358
1422
  className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
1359
1423
  children: "Remove"
@@ -1363,32 +1427,32 @@ function ya({
1363
1427
  }
1364
1428
  )
1365
1429
  ] });
1366
- }, Yr = (e, t, n) => {
1367
- const r = `${e}:${t}`, l = ie[r], o = () => ve((b) => {
1430
+ }, as = (e, t, n) => {
1431
+ const r = `${e}:${t}`, l = ie[r], o = () => _e((b) => {
1368
1432
  if (!(r in b)) return b;
1369
1433
  const q = { ...b };
1370
1434
  return delete q[r], q;
1371
- }), h = n[t] == null ? "" : String(n[t]), c = N.find((b) => b.field === t), p = !dt(c == null ? void 0 : c.type);
1435
+ }), f = n[t] == null ? "" : String(n[t]), c = N.find((b) => b.field === t), h = !mt(c == null ? void 0 : c.type);
1372
1436
  return /* @__PURE__ */ u("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
1373
- /* @__PURE__ */ s(
1437
+ /* @__PURE__ */ a(
1374
1438
  "input",
1375
1439
  {
1376
1440
  type: "number",
1377
1441
  min: 0,
1378
- step: p ? "0.01" : "any",
1379
- defaultValue: h,
1442
+ step: h ? "0.01" : "any",
1443
+ defaultValue: f,
1380
1444
  "aria-invalid": !!l || void 0,
1381
1445
  onFocus: o,
1382
1446
  onBlur: (b) => {
1383
1447
  const q = b.target.value;
1384
- if (q !== h) {
1385
- const j = c, C = (j == null ? void 0 : j.label) || X(t), g = bn(q, { type: j == null ? void 0 : j.type, label: C }), V = g.ok ? (p ? vs(q, C) : null) ?? O(t, g.value, n) : g.message;
1386
- if (V) {
1387
- b.target.value = h, ve((Le) => ({ ...Le, [r]: V }));
1448
+ if (q !== f) {
1449
+ const $ = c, J = ($ == null ? void 0 : $.label) || Z(t), x = kn(q, { type: $ == null ? void 0 : $.type, label: J }), I = x.ok ? (h ? As(q, J) : null) ?? P(t, x.value, n) : x.message;
1450
+ if (I) {
1451
+ b.target.value = f, _e(($e) => ({ ...$e, [r]: I }));
1388
1452
  return;
1389
1453
  }
1390
1454
  }
1391
- Br(e, t, q);
1455
+ Xn(e, t, q);
1392
1456
  },
1393
1457
  onKeyDown: (b) => {
1394
1458
  b.key === "Enter" && b.currentTarget.blur();
@@ -1398,7 +1462,7 @@ function ya({
1398
1462
  l && "border-red-400 dark:border-red-600"
1399
1463
  )
1400
1464
  },
1401
- `${r}:${h}`
1465
+ `${r}:${f}`
1402
1466
  ),
1403
1467
  l && /* @__PURE__ */ u(
1404
1468
  "span",
@@ -1407,27 +1471,27 @@ function ya({
1407
1471
  className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
1408
1472
  "data-catalog-cell-error": !0,
1409
1473
  children: [
1410
- /* @__PURE__ */ s(un, { className: "mt-px h-3 w-3 shrink-0" }),
1474
+ /* @__PURE__ */ a(hn, { className: "mt-px h-3 w-3 shrink-0" }),
1411
1475
  l,
1412
- h !== "" ? ` — still ${h}` : ""
1476
+ f !== "" ? ` — still ${f}` : ""
1413
1477
  ]
1414
1478
  }
1415
1479
  )
1416
1480
  ] }, r);
1417
1481
  };
1418
1482
  return !y && F ? /* @__PURE__ */ u("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
1419
- /* @__PURE__ */ s("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
1420
- /* @__PURE__ */ s("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
1421
- ] }) : y ? /* @__PURE__ */ u("div", { ref: Qn, className: "space-y-3", children: [
1422
- !w && /* @__PURE__ */ u(Ne, { children: [
1483
+ /* @__PURE__ */ a("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
1484
+ /* @__PURE__ */ a("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
1485
+ ] }) : y ? /* @__PURE__ */ u("div", { ref: Bn, className: "space-y-3", children: [
1486
+ !k && /* @__PURE__ */ u(Se, { children: [
1423
1487
  /* @__PURE__ */ u("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1424
1488
  /* @__PURE__ */ u("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-border", children: [
1425
- /* @__PURE__ */ s(Kt, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1426
- /* @__PURE__ */ s(
1489
+ /* @__PURE__ */ a(Ct, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1490
+ /* @__PURE__ */ a(
1427
1491
  "input",
1428
1492
  {
1429
- value: U,
1430
- onChange: (e) => je(e.target.value),
1493
+ value: V,
1494
+ onChange: (e) => Te(e.target.value),
1431
1495
  placeholder: "Search catalog…",
1432
1496
  className: "w-full bg-transparent text-[12px] outline-none placeholder:text-slate-400"
1433
1497
  }
@@ -1437,28 +1501,28 @@ function ya({
1437
1501
  {
1438
1502
  type: "button",
1439
1503
  "aria-pressed": ce,
1440
- "aria-disabled": Pe === null ? "true" : void 0,
1504
+ "aria-disabled": Le === null ? "true" : void 0,
1441
1505
  onClick: () => {
1442
- Pe !== null && Wt(!Fn);
1506
+ Le !== null && Vt(!Pn);
1443
1507
  },
1444
1508
  "data-catalog-in-stock": ce ? "on" : "off",
1445
- "data-tip": Pe === null ? `Choose ${wr ?? "where stock is counted"} to show only items in stock there` : ce ? "Showing only items with stock on hand — click to show everything" : "Show only items with stock on hand",
1509
+ "data-tip": Le === null ? `Choose ${jr ?? "where stock is counted"} to show only items in stock there` : ce ? "Showing only items with stock on hand — click to show everything" : "Show only items with stock on hand",
1446
1510
  className: W(
1447
1511
  "inline-flex h-6 max-w-[220px] shrink-0 items-center gap-1 rounded border px-1.5 text-[11px] font-medium transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan aria-disabled:cursor-not-allowed aria-disabled:opacity-50",
1448
1512
  ce ? "border-nvr-cyan/40 bg-nvr-cyan/10 text-[#00728d] dark:border-nvr-cyan/40 dark:bg-nvr-cyan/15 dark:text-nvr-cyan" : "border-slate-200 bg-white text-slate-600 hover:bg-muted dark:border-border dark:bg-background dark:text-slate-300"
1449
1513
  ),
1450
1514
  children: [
1451
- $r ? /* @__PURE__ */ s(ue, { className: "h-3 w-3 shrink-0 animate-spin" }) : /* @__PURE__ */ s(Gr, { className: "h-3 w-3 shrink-0" }),
1515
+ Er ? /* @__PURE__ */ a(ue, { className: "h-3 w-3 shrink-0 animate-spin" }) : /* @__PURE__ */ a(ls, { className: "h-3 w-3 shrink-0" }),
1452
1516
  /* @__PURE__ */ u("span", { className: "truncate", children: [
1453
1517
  "In stock",
1454
- Pe !== null && Qe && jn != null && /* @__PURE__ */ u(Ne, { children: [
1518
+ Le !== null && ze && On != null && /* @__PURE__ */ u(Se, { children: [
1455
1519
  " at ",
1456
- /* @__PURE__ */ s(
1457
- zs,
1520
+ /* @__PURE__ */ a(
1521
+ na,
1458
1522
  {
1459
- parentCollection: x,
1460
- field: Qe,
1461
- id: jn
1523
+ parentCollection: g,
1524
+ field: ze,
1525
+ id: On
1462
1526
  }
1463
1527
  )
1464
1528
  ] })
@@ -1466,91 +1530,91 @@ function ya({
1466
1530
  ]
1467
1531
  }
1468
1532
  ),
1469
- de && Pe === null && /* @__PURE__ */ s("span", { className: "shrink-0 text-[11px] text-slate-500 dark:text-slate-400", children: "Pick a place first" }),
1533
+ de && Le === null && /* @__PURE__ */ a("span", { className: "shrink-0 text-[11px] text-slate-500 dark:text-slate-400", children: "Pick a place first" }),
1470
1534
  /* @__PURE__ */ u("span", { className: "shrink-0 rounded border border-slate-200 bg-slate-50 px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-muted dark:text-slate-400", children: [
1471
- Hr,
1535
+ ss,
1472
1536
  " picked"
1473
1537
  ] }),
1474
- /* @__PURE__ */ s(mn, { show: Ae.customized, onReset: Ae.reset })
1538
+ /* @__PURE__ */ a(bn, { show: Ke.customized, onReset: Ke.reset })
1475
1539
  ] }),
1476
- Jn && // Sticky: the catalog list is tall and the page scroller carries it —
1540
+ Wn && // Sticky: the catalog list is tall and the page scroller carries it —
1477
1541
  // without this the labels scroll away and favorites/section rows
1478
1542
  // read as headerless columns. Opaque bg (not the /60 tint) so rows
1479
1543
  // never bleed through while pinned.
1480
1544
  /* @__PURE__ */ u(
1481
1545
  "div",
1482
1546
  {
1483
- ref: Cr,
1547
+ ref: Vr,
1484
1548
  className: "sticky top-0 z-[5] flex items-center gap-4 border-b border-slate-200 bg-slate-50 px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-slate-500 dark:border-border dark:bg-muted dark:text-slate-400",
1485
1549
  children: [
1486
- a.favorites && /* @__PURE__ */ s("span", { className: "w-[18px] shrink-0" }),
1487
- Tt(Ae, "item", "Item", "w-36 shrink-0"),
1488
- $t.map((e) => {
1489
- const [t, n] = zn(e);
1490
- return Tt(
1491
- Ae,
1550
+ s.favorites && /* @__PURE__ */ a("span", { className: "w-[18px] shrink-0" }),
1551
+ Ot(Ke, "item", "Item", "w-36 shrink-0"),
1552
+ Ft.map((e) => {
1553
+ const [t, n] = Dn(e);
1554
+ return Ot(
1555
+ Ke,
1492
1556
  e.field,
1493
- e.label ?? X(e.field.split(".")[0]),
1557
+ e.label ?? Z(e.field.split(".")[0]),
1494
1558
  t,
1495
1559
  n
1496
1560
  );
1497
1561
  }),
1498
- ln.map(
1499
- (e) => Tt(
1500
- Ae,
1562
+ on.map(
1563
+ (e) => Ot(
1564
+ Ke,
1501
1565
  `rel:${e.key}`,
1502
- e.label ?? X(e.key),
1566
+ e.label ?? Z(e.key),
1503
1567
  "w-20 shrink-0",
1504
1568
  "text-right"
1505
1569
  )
1506
1570
  ),
1507
- /* @__PURE__ */ s("span", { "aria-hidden": !0, className: "ml-auto" }),
1508
- /* @__PURE__ */ s("span", { "aria-hidden": !0, className: "w-3.5 shrink-0" }),
1509
- /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right", children: "Qty" })
1571
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: "ml-auto" }),
1572
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: "w-3.5 shrink-0" }),
1573
+ /* @__PURE__ */ a("span", { className: "w-20 shrink-0 text-right", children: "Qty" })
1510
1574
  ]
1511
1575
  }
1512
1576
  ),
1513
- U.trim().length > 0 && lt.length === 0 && en && /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-500 dark:border-border/50 dark:text-slate-400", children: [
1514
- /* @__PURE__ */ s(ue, { className: "h-3.5 w-3.5 animate-spin" }),
1577
+ V.trim().length > 0 && dt.length === 0 && tn && /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-500 dark:border-border/50 dark:text-slate-400", children: [
1578
+ /* @__PURE__ */ a(ue, { className: "h-3.5 w-3.5 animate-spin" }),
1515
1579
  " Searching the catalog…"
1516
1580
  ] }),
1517
- U.trim().length > 0 && lt.length === 0 && !en && /* @__PURE__ */ s("p", { className: "px-3 py-4 text-center text-slate-500 dark:text-slate-400", children: ce && Ve.length > 0 ? /* @__PURE__ */ u(Ne, { children: [
1581
+ V.trim().length > 0 && dt.length === 0 && !tn && /* @__PURE__ */ a("p", { className: "px-3 py-4 text-center text-slate-500 dark:text-slate-400", children: ce && Be.length > 0 ? /* @__PURE__ */ u(Se, { children: [
1518
1582
  'Nothing in stock matches "',
1519
- U.trim(),
1583
+ V.trim(),
1520
1584
  '" —',
1521
1585
  " ",
1522
1586
  /* @__PURE__ */ u(
1523
1587
  "button",
1524
1588
  {
1525
1589
  type: "button",
1526
- onClick: () => Wt(!1),
1590
+ onClick: () => Vt(!1),
1527
1591
  className: "font-medium text-[#00728d] underline-offset-2 hover:underline dark:text-nvr-cyan",
1528
1592
  children: [
1529
1593
  "show ",
1530
- Ve.length,
1594
+ Be.length,
1531
1595
  " out of stock"
1532
1596
  ]
1533
1597
  }
1534
1598
  )
1535
- ] }) : /* @__PURE__ */ u(Ne, { children: [
1599
+ ] }) : /* @__PURE__ */ u(Se, { children: [
1536
1600
  'No items match "',
1537
- U.trim(),
1601
+ V.trim(),
1538
1602
  '"'
1539
1603
  ] }) }),
1540
- U.trim().length > 0 && lt.length > 0 && /* @__PURE__ */ u(ot, { children: [
1604
+ V.trim().length > 0 && dt.length > 0 && /* @__PURE__ */ u(ut, { children: [
1541
1605
  /* @__PURE__ */ u("div", { className: "flex w-full items-center gap-1.5 border-b border-t border-slate-200 bg-sky-50/70 px-2 py-1.5 dark:border-border dark:bg-sky-900/10", children: [
1542
- /* @__PURE__ */ s(Kt, { className: "h-3 w-3 shrink-0 text-sky-500" }),
1543
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Search results" }),
1544
- /* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: lt.length }),
1606
+ /* @__PURE__ */ a(Ct, { className: "h-3 w-3 shrink-0 text-sky-500" }),
1607
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Search results" }),
1608
+ /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: dt.length }),
1545
1609
  /* @__PURE__ */ u("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: [
1546
1610
  "across the entire catalog",
1547
1611
  ce ? ", in stock only" : "",
1548
1612
  " — enter a quantity to add"
1549
1613
  ] }),
1550
- en && /* @__PURE__ */ s(ue, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
1614
+ tn && /* @__PURE__ */ a(ue, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
1551
1615
  ] }),
1552
- lt.map((e, t) => {
1553
- const n = String(e.id), r = _e(n);
1616
+ dt.map((e, t) => {
1617
+ const n = String(e.id), r = qe(n);
1554
1618
  return /* @__PURE__ */ u(
1555
1619
  "div",
1556
1620
  {
@@ -1560,23 +1624,23 @@ function ya({
1560
1624
  (r ?? 0) > 0 && "bg-nvr-cyan/5"
1561
1625
  ),
1562
1626
  children: [
1563
- Vt(n),
1564
- cn(
1627
+ Wt(n),
1628
+ un(
1565
1629
  n,
1566
- Ke(A, e),
1630
+ Ce(K, e),
1567
1631
  (() => {
1568
- const l = qr(e), o = Nr.has(n);
1569
- return !l && !o ? null : /* @__PURE__ */ u(Ne, { children: [
1570
- o && /* @__PURE__ */ s(
1632
+ const l = Pr(e), o = Fr.has(n);
1633
+ return !l && !o ? null : /* @__PURE__ */ u(Se, { children: [
1634
+ o && /* @__PURE__ */ a(
1571
1635
  "span",
1572
1636
  {
1573
1637
  "data-catalog-recent": !0,
1574
- "data-tip": `You added this in the last ${vt} days`,
1638
+ "data-tip": `You added this in the last ${_t} days`,
1575
1639
  className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-600 dark:bg-muted dark:text-slate-400",
1576
1640
  children: "Recent"
1577
1641
  }
1578
1642
  ),
1579
- l && /* @__PURE__ */ s(
1643
+ l && /* @__PURE__ */ a(
1580
1644
  "span",
1581
1645
  {
1582
1646
  "data-catalog-match-why": !0,
@@ -1590,37 +1654,37 @@ function ya({
1590
1654
  })(),
1591
1655
  ye
1592
1656
  ),
1593
- dn(n, e, ye),
1594
- /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ee.has(n) && /* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin text-slate-400" }) }),
1595
- Et(n, e)
1657
+ cn(n, e, ye),
1658
+ /* @__PURE__ */ a("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ee.has(n) && /* @__PURE__ */ a(ue, { className: "h-3 w-3 animate-spin text-slate-400" }) }),
1659
+ Kt(n, e)
1596
1660
  ]
1597
1661
  },
1598
1662
  n
1599
1663
  );
1600
1664
  })
1601
1665
  ] }),
1602
- ae.length > 0 && !U.trim() && /* @__PURE__ */ u("p", { className: "px-3 py-6 text-center text-slate-400", children: [
1666
+ ae.length > 0 && !V.trim() && /* @__PURE__ */ u("p", { className: "px-3 py-6 text-center text-slate-400", children: [
1603
1667
  "Search the full catalog above, or select",
1604
1668
  " ",
1605
1669
  ae.map((e) => {
1606
1670
  var t;
1607
- return ((t = R == null ? void 0 : R.fieldLabels) == null ? void 0 : t[e]) ?? X(e);
1671
+ return ((t = L == null ? void 0 : L.fieldLabels) == null ? void 0 : t[e]) ?? Z(e);
1608
1672
  }).join(", "),
1609
1673
  " ",
1610
1674
  "to browse by category"
1611
1675
  ] }),
1612
- ae.length === 0 && (yn || pt) && /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-500 dark:text-slate-400", children: [
1613
- /* @__PURE__ */ s(ue, { className: "h-4 w-4 animate-spin" }),
1676
+ ae.length === 0 && (Nn || xt) && /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-500 dark:text-slate-400", children: [
1677
+ /* @__PURE__ */ a(ue, { className: "h-4 w-4 animate-spin" }),
1614
1678
  " Loading catalog…"
1615
1679
  ] }),
1616
- ae.length === 0 && !yn && !pt && Rt.length === 0 && /* @__PURE__ */ s("p", { className: "px-3 py-6 text-center text-slate-500 dark:text-slate-400", children: ce && oe.length > 0 ? /* @__PURE__ */ u(Ne, { children: [
1680
+ ae.length === 0 && !Nn && !xt && Lt.length === 0 && /* @__PURE__ */ a("p", { className: "px-3 py-6 text-center text-slate-500 dark:text-slate-400", children: ce && oe.length > 0 ? /* @__PURE__ */ u(Se, { children: [
1617
1681
  "Nothing in this catalog is in stock here —",
1618
1682
  " ",
1619
1683
  /* @__PURE__ */ u(
1620
1684
  "button",
1621
1685
  {
1622
1686
  type: "button",
1623
- onClick: () => Wt(!1),
1687
+ onClick: () => Vt(!1),
1624
1688
  className: "font-medium text-[#00728d] underline-offset-2 hover:underline dark:text-nvr-cyan",
1625
1689
  children: [
1626
1690
  "show all ",
@@ -1629,7 +1693,7 @@ function ya({
1629
1693
  }
1630
1694
  )
1631
1695
  ] }) : "No catalog items" }),
1632
- a.favorites && /* @__PURE__ */ u(ot, { children: [
1696
+ s.favorites && /* @__PURE__ */ u(ut, { children: [
1633
1697
  /* @__PURE__ */ u("div", { className: "flex w-full items-center gap-1.5 border-b border-slate-200 bg-amber-50/70 px-2 py-1 dark:border-border dark:bg-amber-900/10", children: [
1634
1698
  /* @__PURE__ */ u(
1635
1699
  "button",
@@ -1641,8 +1705,8 @@ function ya({
1641
1705
  }),
1642
1706
  className: "flex min-w-0 flex-1 items-center gap-1.5 py-0.5 text-left",
1643
1707
  children: [
1644
- /* @__PURE__ */ s(
1645
- Ct,
1708
+ /* @__PURE__ */ a(
1709
+ Jt,
1646
1710
  {
1647
1711
  className: W(
1648
1712
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
@@ -1650,26 +1714,26 @@ function ya({
1650
1714
  )
1651
1715
  }
1652
1716
  ),
1653
- /* @__PURE__ */ s(ct, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
1654
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Favorites" }),
1655
- /* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: tn.length })
1717
+ /* @__PURE__ */ a(ft, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
1718
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Favorites" }),
1719
+ /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: nn.length })
1656
1720
  ]
1657
1721
  }
1658
1722
  ),
1659
- /* @__PURE__ */ s(
1723
+ /* @__PURE__ */ a(
1660
1724
  "button",
1661
1725
  {
1662
- ref: _n,
1726
+ ref: Fn,
1663
1727
  type: "button",
1664
- onClick: () => Sn(!0),
1728
+ onClick: () => jn(!0),
1665
1729
  className: "shrink-0 rounded border border-amber-200 bg-white px-2 py-0.5 text-[10px] font-semibold text-amber-700 transition-colors hover:border-amber-300 hover:bg-amber-50 dark:border-amber-400/30 dark:bg-transparent dark:text-amber-300 dark:hover:bg-amber-400/10",
1666
1730
  children: "Manage"
1667
1731
  }
1668
1732
  )
1669
1733
  ] }),
1670
- !pe.has("__favorites__") && tn.length === 0 && /* @__PURE__ */ s("p", { className: "border-b border-slate-100 px-3 py-2 text-center text-[11px] text-slate-400 dark:border-border/50", children: et.length > 0 ? "None of your favorites are in stock here." : "No favorites yet — Manage lets you search the full catalog and star items." }),
1671
- !pe.has("__favorites__") && tn.map((e, t) => {
1672
- const n = String(e.id), r = _e(n), l = nn(n);
1734
+ !pe.has("__favorites__") && nn.length === 0 && /* @__PURE__ */ a("p", { className: "border-b border-slate-100 px-3 py-2 text-center text-[11px] text-slate-400 dark:border-border/50", children: nt.length > 0 ? "None of your favorites are in stock here." : "No favorites yet — Manage lets you search the full catalog and star items." }),
1735
+ !pe.has("__favorites__") && nn.map((e, t) => {
1736
+ const n = String(e.id), r = qe(n), l = rn(n);
1673
1737
  return /* @__PURE__ */ u(
1674
1738
  "div",
1675
1739
  {
@@ -1680,29 +1744,29 @@ function ya({
1680
1744
  l && "bg-amber-50 dark:bg-amber-900/15"
1681
1745
  ),
1682
1746
  children: [
1683
- Vt(n),
1684
- cn(n, Ke(A, e)),
1685
- dn(n, e),
1686
- /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ee.has(n) ? /* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin text-slate-400" }) : l && /* @__PURE__ */ s(
1687
- He,
1747
+ Wt(n),
1748
+ un(n, Ce(K, e)),
1749
+ cn(n, e),
1750
+ /* @__PURE__ */ a("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ee.has(n) ? /* @__PURE__ */ a(ue, { className: "h-3 w-3 animate-spin text-slate-400" }) : l && /* @__PURE__ */ a(
1751
+ Ae,
1688
1752
  {
1689
1753
  className: "h-3.5 w-3.5 text-amber-500",
1690
- "aria-label": `${rn} ${l.available} — ${l.qty} requested`
1754
+ "aria-label": `${sn} ${l.available} — ${l.qty} requested`
1691
1755
  }
1692
1756
  ) }),
1693
- Et(n, e)
1757
+ Kt(n, e)
1694
1758
  ]
1695
1759
  },
1696
1760
  n
1697
1761
  );
1698
1762
  })
1699
1763
  ] }),
1700
- ae.length === 0 && Rt.map((e) => {
1764
+ ae.length === 0 && Lt.map((e) => {
1701
1765
  const t = pe.has(e.name), n = e.items.reduce(
1702
- (r, l) => r + ((_e(l.id) ?? 0) > 0 ? 1 : 0),
1766
+ (r, l) => r + ((qe(l.id) ?? 0) > 0 ? 1 : 0),
1703
1767
  0
1704
1768
  );
1705
- return /* @__PURE__ */ u(ot, { children: [
1769
+ return /* @__PURE__ */ u(ut, { children: [
1706
1770
  /* @__PURE__ */ u(
1707
1771
  "button",
1708
1772
  {
@@ -1713,8 +1777,8 @@ function ya({
1713
1777
  }),
1714
1778
  className: "flex w-full items-center gap-1.5 border-b border-slate-200 bg-slate-100/80 px-2 py-1.5 text-left dark:border-border dark:bg-muted",
1715
1779
  children: [
1716
- /* @__PURE__ */ s(
1717
- Ct,
1780
+ /* @__PURE__ */ a(
1781
+ Jt,
1718
1782
  {
1719
1783
  className: W(
1720
1784
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
@@ -1722,8 +1786,8 @@ function ya({
1722
1786
  )
1723
1787
  }
1724
1788
  ),
1725
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: e.name }),
1726
- /* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: e.items.length }),
1789
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: e.name }),
1790
+ /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: e.items.length }),
1727
1791
  n > 0 && /* @__PURE__ */ u("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
1728
1792
  n,
1729
1793
  " picked"
@@ -1732,7 +1796,7 @@ function ya({
1732
1796
  }
1733
1797
  ),
1734
1798
  !t && e.items.map((r, l) => {
1735
- const o = _e(r.id), h = nn(r.id);
1799
+ const o = qe(r.id), f = rn(r.id);
1736
1800
  return /* @__PURE__ */ u(
1737
1801
  "div",
1738
1802
  {
@@ -1740,20 +1804,20 @@ function ya({
1740
1804
  "flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
1741
1805
  l % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1742
1806
  (o ?? 0) > 0 && "bg-nvr-cyan/5",
1743
- h && "bg-amber-50 dark:bg-amber-900/15"
1807
+ f && "bg-amber-50 dark:bg-amber-900/15"
1744
1808
  ),
1745
1809
  children: [
1746
- Vt(r.id),
1747
- cn(r.id, r.label),
1748
- dn(r.id, r.row),
1749
- /* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ee.has(r.id) ? /* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin text-slate-400" }) : h && /* @__PURE__ */ s(
1750
- He,
1810
+ Wt(r.id),
1811
+ un(r.id, r.label),
1812
+ cn(r.id, r.row),
1813
+ /* @__PURE__ */ a("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ee.has(r.id) ? /* @__PURE__ */ a(ue, { className: "h-3 w-3 animate-spin text-slate-400" }) : f && /* @__PURE__ */ a(
1814
+ Ae,
1751
1815
  {
1752
1816
  className: "h-3.5 w-3.5 text-amber-500",
1753
- "aria-label": `${rn} ${h.available} — ${h.qty} requested`
1817
+ "aria-label": `${sn} ${f.available} — ${f.qty} requested`
1754
1818
  }
1755
1819
  ) }),
1756
- Et(r.id, r.row)
1820
+ Kt(r.id, r.row)
1757
1821
  ]
1758
1822
  },
1759
1823
  r.id
@@ -1762,34 +1826,34 @@ function ya({
1762
1826
  ] }, e.name);
1763
1827
  })
1764
1828
  ] }),
1765
- (a.builders ?? []).filter((e) => or(e.show_when, S)).map(
1829
+ (s.builders ?? []).filter((e) => hr(e.show_when, S)).map(
1766
1830
  (e) => {
1767
1831
  var t;
1768
- return (t = e.facets) != null && t.length && e.source ? /* @__PURE__ */ s(
1769
- Qs,
1832
+ return (t = e.facets) != null && t.length && e.source ? /* @__PURE__ */ a(
1833
+ ta,
1770
1834
  {
1771
1835
  builder: e,
1772
1836
  catalogCol: y,
1773
- catalogFields: z,
1774
- tmpl: A,
1775
- currentQty: _e,
1776
- addQty: (n, r, l) => Be(n, String(r), l),
1777
- qtyStep: dt(L) ? 1 : "any",
1778
- readOnly: w
1837
+ catalogFields: U,
1838
+ tmpl: K,
1839
+ currentQty: qe,
1840
+ addQty: (n, r, l) => Ye(n, String(r), l),
1841
+ qtyStep: mt(E) ? 1 : "any",
1842
+ readOnly: k
1779
1843
  },
1780
1844
  e.label
1781
- ) : /* @__PURE__ */ s(
1782
- Is,
1845
+ ) : /* @__PURE__ */ a(
1846
+ ea,
1783
1847
  {
1784
1848
  builder: e,
1785
- defaultItemField: a.item_field,
1849
+ defaultItemField: s.item_field,
1786
1850
  catalogCol: y,
1787
- catalogFields: z,
1788
- tmpl: A,
1789
- currentQty: _e,
1790
- addQty: (n, r, l) => Be(n, String(r), l),
1791
- qtyStep: dt(L) ? 1 : "any",
1792
- readOnly: w
1851
+ catalogFields: U,
1852
+ tmpl: K,
1853
+ currentQty: qe,
1854
+ addQty: (n, r, l) => Ye(n, String(r), l),
1855
+ qtyStep: mt(E) ? 1 : "any",
1856
+ readOnly: k
1793
1857
  },
1794
1858
  e.label
1795
1859
  );
@@ -1798,15 +1862,15 @@ function ya({
1798
1862
  ] }),
1799
1863
  /* @__PURE__ */ u("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
1800
1864
  /* @__PURE__ */ u("div", { className: "flex items-center justify-between gap-2 border-b border-slate-200 bg-slate-50 px-3 py-2 dark:border-border dark:bg-muted", children: [
1801
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
1802
- !w && /* @__PURE__ */ u("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
1803
- a.upload_template && !P && H && x && /* @__PURE__ */ s(
1804
- ms,
1865
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
1866
+ !k && /* @__PURE__ */ u("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
1867
+ s.upload_template && !T && H && g && /* @__PURE__ */ a(
1868
+ ws,
1805
1869
  {
1806
- collection: x,
1870
+ collection: g,
1807
1871
  templateFilter: (e) => {
1808
1872
  var t;
1809
- return e.name === a.upload_template && ((t = e.reimport) == null ? void 0 : t.enabled) === !0;
1873
+ return e.name === s.upload_template && ((t = e.reimport) == null ? void 0 : t.enabled) === !0;
1810
1874
  },
1811
1875
  getLabel: (e) => {
1812
1876
  var t;
@@ -1816,32 +1880,32 @@ function ya({
1816
1880
  compact: !0
1817
1881
  }
1818
1882
  ),
1819
- /* @__PURE__ */ s("div", { className: "w-64", children: /* @__PURE__ */ s(
1820
- js,
1883
+ /* @__PURE__ */ a("div", { className: "w-64", children: /* @__PURE__ */ a(
1884
+ zs,
1821
1885
  {
1822
1886
  collection: y,
1823
1887
  value: null,
1824
- onChange: (e) => void Dr(e),
1888
+ onChange: (e) => void rs(e),
1825
1889
  placeholder: "+ Add any item…",
1826
- displayTemplate: Vs(A, a.columns)
1890
+ displayTemplate: sa(K, s.columns)
1827
1891
  }
1828
1892
  ) })
1829
1893
  ] })
1830
1894
  ] }),
1831
- Se.length === 0 ? /* @__PURE__ */ s("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
1832
- const e = Kn.filter((c) => !c.format), t = e[0], n = e.slice(1), r = Kn.filter((c) => !!c.format), l = (c, p) => p === "presence" ? c == null || c === "" || Number(c) === 0 ? "No" : "Yes" : c === !0 || c === "true" ? "✓" : c === !1 || c === "false" || c == null || c === "" ? "—" : Te(c, p), o = (c, p) => p ? Tt(
1895
+ Ne.length === 0 ? /* @__PURE__ */ a("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
1896
+ const e = Un.filter((c) => !c.format), t = e[0], n = e.slice(1), r = Un.filter((c) => !!c.format), l = (c, h) => h === "presence" ? c == null || c === "" || Number(c) === 0 ? "No" : "Yes" : c === !0 || c === "true" ? "✓" : c === !1 || c === "false" || c == null || c === "" ? "—" : ve(c, h), o = (c, h) => h ? Ot(
1833
1897
  Oe,
1834
- p,
1898
+ h,
1835
1899
  c,
1836
1900
  "w-20 shrink-0",
1837
1901
  "text-right text-[11px] font-medium text-slate-500 dark:text-slate-400"
1838
- ) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500 dark:text-slate-400", children: c }), h = (c) => M.includes(c) && !w ? void 0 : `s:${c}`;
1902
+ ) : /* @__PURE__ */ a("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500 dark:text-slate-400", children: c }), f = (c) => M.includes(c) && !k ? void 0 : `s:${c}`;
1839
1903
  return /* @__PURE__ */ u("div", { children: [
1840
1904
  /* @__PURE__ */ u("div", { className: "flex items-center gap-4 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
1841
1905
  /* @__PURE__ */ u("span", { className: "flex flex-1 items-center gap-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children: [
1842
1906
  "Item",
1843
- w && /* @__PURE__ */ s(
1844
- mn,
1907
+ k && /* @__PURE__ */ a(
1908
+ bn,
1845
1909
  {
1846
1910
  show: Oe.customized,
1847
1911
  onReset: Oe.reset,
@@ -1849,21 +1913,21 @@ function ya({
1849
1913
  }
1850
1914
  )
1851
1915
  ] }),
1852
- Lt.map((c) => /* @__PURE__ */ s(ot, { children: o(X(c), h(c)) }, c)),
1853
- o(X(I)),
1854
- De.map((c) => /* @__PURE__ */ s(ot, { children: o(X(c), `s:${c}`) }, c)),
1855
- !w && /* @__PURE__ */ s("span", { className: "-my-1 flex w-6 shrink-0 justify-end", children: /* @__PURE__ */ s(mn, { show: Oe.customized, onReset: Oe.reset }) })
1916
+ Et.map((c) => /* @__PURE__ */ a(ut, { children: o(Z(c), f(c)) }, c)),
1917
+ o(Z(z)),
1918
+ Ze.map((c) => /* @__PURE__ */ a(ut, { children: o(Z(c), `s:${c}`) }, c)),
1919
+ !k && /* @__PURE__ */ a("span", { className: "-my-1 flex w-6 shrink-0 justify-end", children: /* @__PURE__ */ a(bn, { show: Oe.customized, onReset: Oe.reset }) })
1856
1920
  ] }),
1857
- Se.map((c, p) => {
1858
- const b = c.row.id != null ? String(c.row.id) : null, q = b != null && yt.has(b), j = q ? null : nn(c.key), C = q ? null : Rr(c.key);
1921
+ Ne.map((c, h) => {
1922
+ const b = c.row.id != null ? String(c.row.id) : null, q = b != null && kt.has(b), $ = q ? null : rn(c.key), J = q ? null : Ir(c.key);
1859
1923
  return /* @__PURE__ */ u(
1860
1924
  "div",
1861
1925
  {
1862
1926
  className: W(
1863
1927
  "border-b border-slate-100 px-3 py-2 last:border-b-0 dark:border-border/50",
1864
- p % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1865
- j && "bg-amber-50 dark:bg-amber-900/15",
1866
- C && "bg-red-50/70 dark:bg-red-900/15",
1928
+ h % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
1929
+ $ && "bg-amber-50 dark:bg-amber-900/15",
1930
+ J && "bg-red-50/70 dark:bg-red-900/15",
1867
1931
  q && "opacity-60"
1868
1932
  ),
1869
1933
  children: [
@@ -1875,12 +1939,12 @@ function ya({
1875
1939
  q && "line-through decoration-slate-400"
1876
1940
  ),
1877
1941
  children: [
1878
- Mn(
1942
+ Hn(
1879
1943
  c.key,
1880
- Ot(c.key),
1944
+ Pt(c.key),
1881
1945
  "shrink-0 font-semibold text-slate-800 dark:text-slate-100"
1882
1946
  ),
1883
- Ge && !q && (b == null || bt.has(b)) && /* @__PURE__ */ s(
1947
+ et && !q && (b == null || gt.has(b)) && /* @__PURE__ */ a(
1884
1948
  "span",
1885
1949
  {
1886
1950
  "data-catalog-staged": b == null ? "new" : "edited",
@@ -1889,89 +1953,89 @@ function ya({
1889
1953
  children: b == null ? "New" : "Edited"
1890
1954
  }
1891
1955
  ),
1892
- C && /* @__PURE__ */ s(
1956
+ J && /* @__PURE__ */ a(
1893
1957
  "span",
1894
1958
  {
1895
1959
  className: "shrink-0",
1896
1960
  "data-tip": `This line was in the failed submission
1897
- ${C}`,
1961
+ ${J}`,
1898
1962
  "data-submission-error": !0,
1899
- children: /* @__PURE__ */ s(un, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
1963
+ children: /* @__PURE__ */ a(hn, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
1900
1964
  }
1901
1965
  ),
1902
- t && /* @__PURE__ */ s(
1903
- dr,
1966
+ t && /* @__PURE__ */ a(
1967
+ br,
1904
1968
  {
1905
- text: Te(jt(ze(c.key), t.field), void 0),
1969
+ text: ve(Tt(Ue(c.key), t.field), void 0),
1906
1970
  className: "min-w-0 flex-1 text-slate-600 dark:text-slate-300"
1907
1971
  }
1908
1972
  ),
1909
- !t && /* @__PURE__ */ s("span", { className: "flex-1" }),
1910
- n.map((g) => {
1911
- const V = jt(ze(c.key), g.field);
1912
- return V == null || V === "" ? null : /* @__PURE__ */ s(
1973
+ !t && /* @__PURE__ */ a("span", { className: "flex-1" }),
1974
+ n.map((x) => {
1975
+ const I = Tt(Ue(c.key), x.field);
1976
+ return I == null || I === "" ? null : /* @__PURE__ */ a(
1913
1977
  "span",
1914
1978
  {
1915
1979
  className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10.5px] font-medium text-slate-600 dark:bg-muted dark:text-slate-300",
1916
- children: String(V)
1980
+ children: String(I)
1917
1981
  },
1918
- g.field
1982
+ x.field
1919
1983
  );
1920
1984
  }),
1921
- Lt.map(
1922
- (g) => {
1923
- var V;
1924
- return Wr(c.key, g) ? Yr(c.key, g, c.row) : /* @__PURE__ */ s(
1985
+ Et.map(
1986
+ (x) => {
1987
+ var I;
1988
+ return ts(c.key, x) ? as(c.key, x, c.row) : /* @__PURE__ */ a(
1925
1989
  "span",
1926
1990
  {
1927
- "data-catalog-locked": !w && M.includes(g) ? g : void 0,
1928
- "data-tip": !w && M.includes(g) ? "Set by the catalog — only an administrator can change it" : void 0,
1991
+ "data-catalog-locked": !k && M.includes(x) ? x : void 0,
1992
+ "data-tip": !k && M.includes(x) ? "Set by the catalog — only an administrator can change it" : void 0,
1929
1993
  ...Oe.box(
1930
- `s:${g}`,
1994
+ `s:${x}`,
1931
1995
  "w-20 shrink-0",
1932
1996
  "truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
1933
1997
  ),
1934
- children: Te(c.row[g], (V = a.field_formats) == null ? void 0 : V[g])
1998
+ children: ve(c.row[x], (I = s.field_formats) == null ? void 0 : I[x])
1935
1999
  },
1936
- g
2000
+ x
1937
2001
  );
1938
2002
  }
1939
2003
  ),
1940
2004
  /* @__PURE__ */ u("span", { className: "inline-flex w-20 shrink-0 items-center justify-end gap-1", children: [
1941
- ee.has(c.key) && /* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin text-slate-400" }),
1942
- Et(c.key, ze(c.key))
2005
+ ee.has(c.key) && /* @__PURE__ */ a(ue, { className: "h-3 w-3 animate-spin text-slate-400" }),
2006
+ Kt(c.key, Ue(c.key))
1943
2007
  ] }),
1944
- De.map((g) => {
1945
- var nr, rr;
2008
+ Ze.map((x) => {
2009
+ var dr, cr;
1946
2010
  if (q)
1947
- return /* @__PURE__ */ s(
2011
+ return /* @__PURE__ */ a(
1948
2012
  "span",
1949
2013
  {
1950
2014
  "data-tip": "Not counted — this line is removed when you save",
1951
2015
  ...Oe.box(
1952
- `s:${g}`,
2016
+ `s:${x}`,
1953
2017
  "w-20 shrink-0",
1954
2018
  "text-right tabular-nums text-slate-400 dark:text-slate-500"
1955
2019
  ),
1956
2020
  children: "—"
1957
2021
  },
1958
- g
2022
+ x
1959
2023
  );
1960
- const V = c.row[g], Le = V != null && V !== "" ? V : Ee(((nr = a.compute_fields) == null ? void 0 : nr[g]) ?? "", c.row);
1961
- return /* @__PURE__ */ s(
2024
+ const I = c.row[x], $e = I != null && I !== "" ? I : Ee(((dr = s.compute_fields) == null ? void 0 : dr[x]) ?? "", c.row);
2025
+ return /* @__PURE__ */ a(
1962
2026
  "span",
1963
2027
  {
1964
2028
  ...Oe.box(
1965
- `s:${g}`,
2029
+ `s:${x}`,
1966
2030
  "w-20 shrink-0",
1967
2031
  "truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
1968
2032
  ),
1969
- children: Te(Le, (rr = a.field_formats) == null ? void 0 : rr[g])
2033
+ children: ve($e, (cr = s.field_formats) == null ? void 0 : cr[x])
1970
2034
  },
1971
- g
2035
+ x
1972
2036
  );
1973
2037
  }),
1974
- !w && q && /* @__PURE__ */ s(
2038
+ !k && q && /* @__PURE__ */ a(
1975
2039
  "button",
1976
2040
  {
1977
2041
  type: "button",
@@ -1980,181 +2044,225 @@ ${C}`,
1980
2044
  children: "Undo"
1981
2045
  }
1982
2046
  ),
1983
- !w && !q && /* @__PURE__ */ s(
2047
+ !k && !q && /* @__PURE__ */ a(
1984
2048
  "button",
1985
2049
  {
1986
2050
  type: "button",
1987
2051
  title: "Remove (applies on Save)",
1988
2052
  onClick: () => {
1989
- if (!P && v && b != null) {
2053
+ if (!T && v && b != null) {
1990
2054
  v.queueDelete(i, m, b);
1991
2055
  return;
1992
2056
  }
1993
- Be(c.key, "0", {}, { confirmedRemove: !0 });
2057
+ Ye(c.key, "0", {}, { confirmedRemove: !0 });
1994
2058
  },
1995
2059
  className: "w-6 shrink-0 rounded p-0.5 text-slate-300 transition-colors hover:text-red-500",
1996
- children: /* @__PURE__ */ s(ut, { className: "mx-auto h-3.5 w-3.5" })
2060
+ children: /* @__PURE__ */ a(pt, { className: "mx-auto h-3.5 w-3.5" })
1997
2061
  }
1998
2062
  )
1999
2063
  ]
2000
2064
  }
2001
2065
  ),
2002
- (r.length > 0 || Cn.length > 0 || qt.length > 0) && /* @__PURE__ */ u("div", { className: "mt-1 flex flex-wrap items-baseline gap-x-4 gap-y-0.5 pl-0.5 text-[11px]", children: [
2003
- r.map((g) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
2004
- /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: g.label ?? X(g.field.split(".")[0]) }),
2066
+ (r.length > 0 || Mn.length > 0 || jt.length > 0) && /* @__PURE__ */ u("div", { className: "mt-1 flex flex-wrap items-baseline gap-x-4 gap-y-0.5 pl-0.5 text-[11px]", children: [
2067
+ r.map((x) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
2068
+ /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: x.label ?? Z(x.field.split(".")[0]) }),
2005
2069
  " ",
2006
- /* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(jt(ze(c.key), g.field), g.format) })
2007
- ] }, g.field)),
2008
- Cn.map((g) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
2009
- /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: g.label ?? X(g.key) }),
2070
+ /* @__PURE__ */ a("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(Tt(Ue(c.key), x.field), x.format) })
2071
+ ] }, x.field)),
2072
+ Mn.map((x) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
2073
+ /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: x.label ?? Z(x.key) }),
2010
2074
  " ",
2011
- /* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(at(g.key, c.key), g.format) })
2012
- ] }, g.key)),
2013
- Kr(c.row),
2014
- jr(c.row).map((g) => /* @__PURE__ */ u(
2075
+ /* @__PURE__ */ a("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(lt(x.key, c.key), x.format) })
2076
+ ] }, x.key)),
2077
+ Wr(c.row),
2078
+ Kr(c.row).map((x) => /* @__PURE__ */ u(
2015
2079
  "span",
2016
2080
  {
2017
2081
  className: "inline-flex items-center gap-1 whitespace-nowrap rounded bg-amber-50 px-1.5 py-px text-[10.5px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",
2018
- "data-catalog-row-flag": g,
2082
+ "data-catalog-row-flag": x,
2019
2083
  children: [
2020
- /* @__PURE__ */ s(He, { className: "h-3 w-3" }),
2021
- g
2084
+ /* @__PURE__ */ a(Ae, { className: "h-3 w-3" }),
2085
+ x
2022
2086
  ]
2023
2087
  },
2024
- g
2088
+ x
2025
2089
  )),
2026
- qt.map((g) => {
2027
- const V = Er(g, c);
2090
+ jt.map((x) => {
2091
+ const I = Ur(x, c);
2028
2092
  return /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
2029
- /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: g.label ?? X(g.field) }),
2093
+ /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: x.label ?? Z(x.field) }),
2030
2094
  " ",
2031
- /* @__PURE__ */ s("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: l(V, g.format) })
2032
- ] }, g.field);
2095
+ /* @__PURE__ */ a("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: l(I, x.format) })
2096
+ ] }, x.field);
2033
2097
  })
2034
2098
  ] }),
2035
- j && /* @__PURE__ */ u("p", { className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400", children: [
2036
- /* @__PURE__ */ s(He, { className: "h-3 w-3 shrink-0" }),
2037
- rn,
2099
+ $ && (k ? /* @__PURE__ */ u("p", { className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400", children: [
2100
+ /* @__PURE__ */ a(Ae, { className: "h-3 w-3 shrink-0" }),
2101
+ sn,
2038
2102
  " is ",
2039
- Te(j.available, "number"),
2103
+ ve($.available, "number"),
2040
2104
  " —",
2041
2105
  " ",
2042
- Te(j.qty, "number"),
2106
+ ve($.qty, "number"),
2043
2107
  " requested"
2044
- ] }),
2045
- !q && Js(
2108
+ ] }) : (
2109
+ // rt4 #7 — what the line is short of, where.
2110
+ /* @__PURE__ */ u(
2111
+ "p",
2112
+ {
2113
+ "data-catalog-stock-short": !0,
2114
+ className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400",
2115
+ children: [
2116
+ /* @__PURE__ */ a(Ae, { className: "h-3 w-3 shrink-0" }),
2117
+ Rs(
2118
+ $.available,
2119
+ $.qty,
2120
+ Xr,
2121
+ (x) => ve(x, "number")
2122
+ )
2123
+ ]
2124
+ }
2125
+ )
2126
+ )),
2127
+ !k && b != null && !q && Gr(c.row, c.key).map(({ field: x, change: I }) => /* @__PURE__ */ u(
2128
+ "p",
2129
+ {
2130
+ "data-catalog-price-changed": x,
2131
+ className: "mt-1 flex flex-wrap items-center gap-x-1 pl-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300",
2132
+ children: [
2133
+ /* @__PURE__ */ a(Ae, { className: "h-3 w-3 shrink-0" }),
2134
+ /* @__PURE__ */ u("span", { children: [
2135
+ Os(I, ($e) => ve($e, "currency")),
2136
+ fn.length > 1 ? ` · ${Z(x)}` : ""
2137
+ ] }),
2138
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: "text-amber-500/70", children: "·" }),
2139
+ /* @__PURE__ */ a(
2140
+ "button",
2141
+ {
2142
+ type: "button",
2143
+ "data-catalog-use-new-price": x,
2144
+ className: "rounded font-semibold text-nvr-cyan underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/60",
2145
+ onClick: () => void Xn(c.key, x, String(I.now)),
2146
+ children: "Use new price"
2147
+ }
2148
+ )
2149
+ ]
2150
+ },
2151
+ x
2152
+ )),
2153
+ !q && Xs(
2046
2154
  {
2047
2155
  ...c.row,
2048
2156
  ...Object.fromEntries(
2049
- De.filter((g) => c.row[g] == null || c.row[g] === "").map((g) => {
2050
- var V;
2157
+ Ze.filter((x) => c.row[x] == null || c.row[x] === "").map((x) => {
2158
+ var I;
2051
2159
  return [
2052
- g,
2053
- Ee(((V = a.compute_fields) == null ? void 0 : V[g]) ?? "", c.row)
2160
+ x,
2161
+ Ee(((I = s.compute_fields) == null ? void 0 : I[x]) ?? "", c.row)
2054
2162
  ];
2055
2163
  })
2056
2164
  )
2057
2165
  },
2058
- I,
2059
- De.length > 0 ? De : Lt
2166
+ z,
2167
+ Ze.length > 0 ? Ze : Et
2060
2168
  ) && /* @__PURE__ */ u(
2061
2169
  "p",
2062
2170
  {
2063
2171
  "data-catalog-unpriced": !0,
2064
2172
  className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400",
2065
2173
  children: [
2066
- /* @__PURE__ */ s(He, { className: "h-3 w-3 shrink-0" }),
2174
+ /* @__PURE__ */ a(Ae, { className: "h-3 w-3 shrink-0" }),
2067
2175
  "No catalog price: check the price or hand-price it"
2068
2176
  ]
2069
2177
  }
2070
2178
  ),
2071
- q && /* @__PURE__ */ s("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
2179
+ q && /* @__PURE__ */ a("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
2072
2180
  ]
2073
2181
  },
2074
2182
  c.key
2075
2183
  );
2076
2184
  }),
2077
2185
  (() => {
2078
- const c = Se.filter((j) => {
2079
- const C = j.row.id != null ? String(j.row.id) : null;
2080
- return !(C != null && yt.has(C));
2081
- }), p = (j) => Ps(
2082
- c.map((C) => C.row),
2083
- j,
2084
- a.compute_fields
2085
- ), b = (j) => {
2086
- var C;
2087
- return ((C = a.field_formats) == null ? void 0 : C[j]) ?? "number";
2088
- }, q = (j) => /* @__PURE__ */ s(
2186
+ const c = Ne.filter(($) => {
2187
+ const J = $.row.id != null ? String($.row.id) : null;
2188
+ return !(J != null && kt.has(J));
2189
+ }), h = ($) => Bs(
2190
+ c.map((J) => J.row),
2191
+ $,
2192
+ s.compute_fields
2193
+ ), b = ($) => {
2194
+ var J;
2195
+ return ((J = s.field_formats) == null ? void 0 : J[$]) ?? "number";
2196
+ }, q = ($) => /* @__PURE__ */ a(
2089
2197
  "span",
2090
2198
  {
2091
2199
  ...Oe.box(
2092
- `s:${j}`,
2200
+ `s:${$}`,
2093
2201
  "w-20 shrink-0",
2094
2202
  "truncate text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100"
2095
2203
  ),
2096
- children: Te(p(j), b(j))
2204
+ children: ve(h($), b($))
2097
2205
  },
2098
- j
2206
+ $
2099
2207
  );
2100
2208
  return /* @__PURE__ */ u("div", { className: "flex items-center gap-4 border-t border-slate-200 bg-slate-50 px-3 py-1.5 dark:border-border dark:bg-muted/40", children: [
2101
- /* @__PURE__ */ s("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Total" }),
2102
- Lt.map((j) => {
2103
- const C = h(j);
2104
- return C ? /* @__PURE__ */ s("span", { ...Oe.box(C, "w-20 shrink-0") }, j) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0" }, j);
2209
+ /* @__PURE__ */ a("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Total" }),
2210
+ Et.map(($) => {
2211
+ const J = f($);
2212
+ return J ? /* @__PURE__ */ a("span", { ...Oe.box(J, "w-20 shrink-0") }, $) : /* @__PURE__ */ a("span", { className: "w-20 shrink-0" }, $);
2105
2213
  }),
2106
- /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: Te(p(I), "number") }),
2107
- De.map(q),
2108
- !w && /* @__PURE__ */ s("span", { className: "w-6 shrink-0" })
2214
+ /* @__PURE__ */ a("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: ve(h(z), "number") }),
2215
+ Ze.map(q),
2216
+ !k && /* @__PURE__ */ a("span", { className: "w-6 shrink-0" })
2109
2217
  ] });
2110
2218
  })()
2111
2219
  ] });
2112
2220
  })()
2113
2221
  ] }),
2114
- gr && y && /* @__PURE__ */ s(
2115
- Ms,
2222
+ qr && y && /* @__PURE__ */ a(
2223
+ ra,
2116
2224
  {
2117
2225
  catalogCol: y,
2118
- tmpl: A,
2119
- sectionBy: a.section_by,
2226
+ tmpl: K,
2227
+ sectionBy: s.section_by,
2120
2228
  sectionM2M: d,
2121
2229
  pinnedSet: Mt,
2122
- pinnedIds: Re,
2123
- savingIds: wt,
2124
- relatedCols: (a.favorites_manager_columns ?? []).map((e) => (a.related_columns ?? []).find((t) => t.key === e)).filter((e) => !!e),
2230
+ pinnedIds: Pe,
2231
+ savingIds: vt,
2232
+ relatedCols: (s.favorites_manager_columns ?? []).map((e) => (s.related_columns ?? []).find((t) => t.key === e)).filter((e) => !!e),
2125
2233
  parentDraft: S,
2126
- onToggle: (e) => void vn(e),
2127
- onClose: () => Sn(!1),
2128
- anchor: _n.current
2234
+ onToggle: (e) => void $n(e),
2235
+ onClose: () => jn(!1),
2236
+ anchor: Fn.current
2129
2237
  }
2130
2238
  )
2131
2239
  ] }) : /* @__PURE__ */ u("p", { className: "py-1 text-[12px] text-slate-400", children: [
2132
2240
  'Catalog picker: field "',
2133
- a.item_field,
2241
+ s.item_field,
2134
2242
  '" does not resolve to an M2O relation on',
2135
2243
  " ",
2136
2244
  i
2137
2245
  ] });
2138
2246
  }
2139
- function Is({
2247
+ function ea({
2140
2248
  builder: i,
2141
2249
  defaultItemField: m,
2142
- catalogCol: f,
2143
- catalogFields: x,
2250
+ catalogCol: p,
2251
+ catalogFields: g,
2144
2252
  tmpl: _,
2145
- currentQty: a,
2146
- addQty: w,
2147
- qtyStep: k,
2148
- readOnly: T
2253
+ currentQty: s,
2254
+ addQty: k,
2255
+ qtyStep: w,
2256
+ readOnly: O
2149
2257
  }) {
2150
- const v = mt(), R = i.item_field ?? m, H = i.attributes ?? [], [M, me] = D(!1), [fe, P] = D({}), [be, I] = D("1"), [pe, ge] = D(!1), ke = E(
2258
+ const v = ht(), L = i.item_field ?? m, H = i.attributes ?? [], [M, me] = D(!1), [fe, T] = D({}), [be, z] = D("1"), [pe, ge] = D(!1), ke = R(
2151
2259
  () => [
2152
2260
  "id",
2153
- R,
2261
+ L,
2154
2262
  ...H.flatMap((F) => [`${F.field}.id`, `${F.field}.${F.label_field}`])
2155
2263
  ].join(","),
2156
- [R, H]
2157
- ), { data: U = [], isLoading: je } = Q({
2264
+ [L, H]
2265
+ ), { data: V = [], isLoading: Te } = Q({
2158
2266
  queryKey: [
2159
2267
  "catalog-builder",
2160
2268
  i.collection,
@@ -2162,7 +2270,7 @@ function Is({
2162
2270
  JSON.stringify(i.filter ?? null)
2163
2271
  ],
2164
2272
  queryFn: () => v.request(
2165
- J(`/items/${i.collection}`, {
2273
+ C(`/items/${i.collection}`, {
2166
2274
  limit: 2e3,
2167
2275
  fields: ke,
2168
2276
  ...i.filter ? { filter: JSON.stringify(i.filter) } : {}
@@ -2171,29 +2279,29 @@ function Is({
2171
2279
  enabled: M,
2172
2280
  staleTime: 6e4
2173
2281
  }), he = (F, y) => {
2174
- var L;
2282
+ var E;
2175
2283
  const N = F[y];
2176
2284
  if (N == null) return null;
2177
2285
  if (typeof N == "object") {
2178
- const O = N, $ = ((L = H.find((A) => A.field === y)) == null ? void 0 : L.label_field) ?? "id";
2179
- return { id: String(O.id ?? ""), label: String(O[$] ?? O.id ?? "") };
2286
+ const P = N, j = ((E = H.find((K) => K.field === y)) == null ? void 0 : E.label_field) ?? "id";
2287
+ return { id: String(P.id ?? ""), label: String(P[j] ?? P.id ?? "") };
2180
2288
  }
2181
2289
  return { id: String(N), label: String(N) };
2182
- }, re = (F) => U.filter(
2290
+ }, re = (F) => V.filter(
2183
2291
  (y) => H.slice(0, F).every((N) => {
2184
- var O;
2185
- const L = fe[N.field];
2186
- return L ? ((O = he(y, N.field)) == null ? void 0 : O.id) === L : !0;
2292
+ var P;
2293
+ const E = fe[N.field];
2294
+ return E ? ((P = he(y, N.field)) == null ? void 0 : P.id) === E : !0;
2187
2295
  })
2188
- ), ee = H.every((F) => fe[F.field]), Z = ee ? U.find((F) => H.every((y) => {
2296
+ ), ee = H.every((F) => fe[F.field]), G = ee ? V.find((F) => H.every((y) => {
2189
2297
  var N;
2190
2298
  return ((N = he(F, y.field)) == null ? void 0 : N.id) === fe[y.field];
2191
- })) : void 0, B = (Z == null ? void 0 : Z[R]) != null ? String(Z[R]) : null, { data: se } = Q({
2192
- queryKey: ["catalog-builder-item", f, x, B],
2299
+ })) : void 0, B = (G == null ? void 0 : G[L]) != null ? String(G[L]) : null, { data: se } = Q({
2300
+ queryKey: ["catalog-builder-item", p, g, B],
2193
2301
  queryFn: () => v.request(
2194
- J(`/items/${f}`, {
2302
+ C(`/items/${p}`, {
2195
2303
  filter: JSON.stringify({ id: { _eq: B } }),
2196
- fields: x,
2304
+ fields: g,
2197
2305
  limit: 1
2198
2306
  })
2199
2307
  ).then((F) => {
@@ -2202,12 +2310,12 @@ function Is({
2202
2310
  }),
2203
2311
  enabled: !!B,
2204
2312
  staleTime: 6e4
2205
- }), ie = Number(be), ve = !!B && !!se && !pe && be.trim() !== "" && Number.isFinite(ie) && ie > 0 && (k === "any" || Number.isInteger(ie));
2313
+ }), ie = Number(be), _e = !!B && !!se && !pe && be.trim() !== "" && Number.isFinite(ie) && ie > 0 && (w === "any" || Number.isInteger(ie));
2206
2314
  async function xe() {
2207
- if (!(!ve || !B || !se)) {
2315
+ if (!(!_e || !B || !se)) {
2208
2316
  ge(!0);
2209
2317
  try {
2210
- await w(B, (a(B) ?? 0) + ie, se), P({}), I("1");
2318
+ await k(B, (s(B) ?? 0) + ie, se), T({}), z("1");
2211
2319
  } finally {
2212
2320
  ge(!1);
2213
2321
  }
@@ -2221,8 +2329,8 @@ function Is({
2221
2329
  onClick: () => me((F) => !F),
2222
2330
  className: "flex w-full items-center gap-1.5 rounded-t-lg bg-slate-100/80 px-2 py-1.5 text-left dark:bg-muted",
2223
2331
  children: [
2224
- /* @__PURE__ */ s(
2225
- Ct,
2332
+ /* @__PURE__ */ a(
2333
+ Jt,
2226
2334
  {
2227
2335
  className: W(
2228
2336
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
@@ -2230,59 +2338,59 @@ function Is({
2230
2338
  )
2231
2339
  }
2232
2340
  ),
2233
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: i.label })
2341
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: i.label })
2234
2342
  ]
2235
2343
  }
2236
2344
  ),
2237
- M && /* @__PURE__ */ s("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: je ? /* @__PURE__ */ u("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
2238
- /* @__PURE__ */ s(ue, { className: "h-4 w-4 animate-spin" }),
2345
+ M && /* @__PURE__ */ a("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: Te ? /* @__PURE__ */ u("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
2346
+ /* @__PURE__ */ a(ue, { className: "h-4 w-4 animate-spin" }),
2239
2347
  " Loading options…"
2240
2348
  ] }) : /* @__PURE__ */ u("div", { className: "flex flex-wrap items-end gap-3", children: [
2241
2349
  H.map((F, y) => {
2242
2350
  const N = /* @__PURE__ */ new Map();
2243
- for (const O of re(y)) {
2244
- const $ = he(O, F.field);
2245
- $ != null && $.id && N.set($.id, $.label);
2351
+ for (const P of re(y)) {
2352
+ const j = he(P, F.field);
2353
+ j != null && j.id && N.set(j.id, j.label);
2246
2354
  }
2247
- const L = [...N.entries()].sort(
2248
- ([, O], [, $]) => O.localeCompare($, void 0, { numeric: !0 })
2355
+ const E = [...N.entries()].sort(
2356
+ ([, P], [, j]) => P.localeCompare(j, void 0, { numeric: !0 })
2249
2357
  );
2250
- return /* @__PURE__ */ s(
2251
- pr,
2358
+ return /* @__PURE__ */ a(
2359
+ wr,
2252
2360
  {
2253
- label: X(F.field),
2361
+ label: Z(F.field),
2254
2362
  value: fe[F.field] ?? null,
2255
2363
  valueLabel: fe[F.field] ? N.get(fe[F.field]) ?? fe[F.field] : null,
2256
- options: L,
2364
+ options: E,
2257
2365
  disabled: y > 0 && !fe[H[y - 1].field],
2258
- onChange: (O) => P(($) => {
2259
- const A = {};
2260
- for (let K = 0; K < y; K++) {
2261
- const te = H[K].field;
2262
- $[te] && (A[te] = $[te]);
2366
+ onChange: (P) => T((j) => {
2367
+ const K = {};
2368
+ for (let A = 0; A < y; A++) {
2369
+ const te = H[A].field;
2370
+ j[te] && (K[te] = j[te]);
2263
2371
  }
2264
- return O && (A[F.field] = O), A;
2372
+ return P && (K[F.field] = P), K;
2265
2373
  })
2266
2374
  },
2267
2375
  F.field
2268
2376
  );
2269
2377
  }),
2270
- /* @__PURE__ */ s("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: B && se ? /* @__PURE__ */ u(Ne, { children: [
2271
- /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: Ke(_, se) }),
2272
- (a(B) ?? 0) > 0 && /* @__PURE__ */ u("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
2273
- a(B),
2378
+ /* @__PURE__ */ a("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: B && se ? /* @__PURE__ */ u(Se, { children: [
2379
+ /* @__PURE__ */ a("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: Ce(_, se) }),
2380
+ (s(B) ?? 0) > 0 && /* @__PURE__ */ u("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
2381
+ s(B),
2274
2382
  " in summary"
2275
2383
  ] }),
2276
- !T && /* @__PURE__ */ u(Ne, { children: [
2277
- /* @__PURE__ */ s(
2384
+ !O && /* @__PURE__ */ u(Se, { children: [
2385
+ /* @__PURE__ */ a(
2278
2386
  "input",
2279
2387
  {
2280
2388
  type: "number",
2281
2389
  min: 0,
2282
- step: k,
2390
+ step: w,
2283
2391
  value: be,
2284
2392
  "aria-label": "Quantity to add",
2285
- onChange: (F) => I(F.target.value),
2393
+ onChange: (F) => z(F.target.value),
2286
2394
  onKeyDown: (F) => {
2287
2395
  F.key === "Enter" && (F.preventDefault(), xe());
2288
2396
  },
@@ -2294,75 +2402,75 @@ function Is({
2294
2402
  {
2295
2403
  type: "button",
2296
2404
  onClick: () => void xe(),
2297
- disabled: !ve,
2405
+ disabled: !_e,
2298
2406
  className: "flex h-7 shrink-0 items-center gap-1 rounded bg-nvr-cyan px-2.5 text-[12px] font-medium text-white hover:bg-nvr-cyan/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan focus-visible:ring-offset-1 disabled:opacity-50",
2299
2407
  children: [
2300
- pe ? /* @__PURE__ */ s(ue, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(cr, { className: "h-3.5 w-3.5" }),
2408
+ pe ? /* @__PURE__ */ a(ue, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(xr, { className: "h-3.5 w-3.5" }),
2301
2409
  "Add"
2302
2410
  ]
2303
2411
  }
2304
2412
  )
2305
2413
  ] })
2306
- ] }) : ee ? /* @__PURE__ */ s("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ s("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
2414
+ ] }) : ee ? /* @__PURE__ */ a("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ a("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
2307
2415
  ] }) })
2308
2416
  ] });
2309
2417
  }
2310
- function Qs({
2418
+ function ta({
2311
2419
  builder: i,
2312
2420
  catalogCol: m,
2313
- catalogFields: f,
2314
- tmpl: x,
2421
+ catalogFields: p,
2422
+ tmpl: g,
2315
2423
  currentQty: _,
2316
- addQty: a,
2317
- qtyStep: w,
2318
- readOnly: k
2424
+ addQty: s,
2425
+ qtyStep: k,
2426
+ readOnly: w
2319
2427
  }) {
2320
- var ve, xe, F, y;
2321
- const T = mt(), v = i.facets ?? [], R = i.item_key ?? "item", H = ((ve = i.result) == null ? void 0 : ve.key) ?? "label", M = i.symmetric ?? null, [me, fe] = D(!1), [P, be] = D({}), [I, pe] = D({}), [ge, ke] = D(null), {
2322
- data: U = [],
2323
- isLoading: je,
2428
+ var _e, xe, F, y;
2429
+ const O = ht(), v = i.facets ?? [], L = i.item_key ?? "item", H = ((_e = i.result) == null ? void 0 : _e.key) ?? "label", M = i.symmetric ?? null, [me, fe] = D(!1), [T, be] = D({}), [z, pe] = D({}), [ge, ke] = D(null), {
2430
+ data: V = [],
2431
+ isLoading: Te,
2324
2432
  isError: he
2325
2433
  } = Q({
2326
2434
  queryKey: ["catalog-facet-builder", i.source],
2327
- queryFn: () => T.request(J(String(i.source))).then((N) => Array.isArray(N.data) ? N.data : []),
2435
+ queryFn: () => O.request(C(String(i.source))).then((N) => Array.isArray(N.data) ? N.data : []),
2328
2436
  enabled: me && !!i.source,
2329
2437
  staleTime: 5 * 6e4
2330
- }), re = bs(P, v), ee = E(
2438
+ }), re = _s(T, v), ee = R(
2331
2439
  () => {
2332
2440
  var N;
2333
- return re ? xs(U, P, v, {
2334
- itemKey: R,
2441
+ return re ? qs(V, T, v, {
2442
+ itemKey: L,
2335
2443
  labelKey: H,
2336
2444
  sortKey: (N = i.result) == null ? void 0 : N.sort,
2337
2445
  symmetric: M
2338
2446
  }) : [];
2339
2447
  },
2340
- [re, U, P, v, R, H, (xe = i.result) == null ? void 0 : xe.sort, M]
2341
- ), Z = E(() => ee.map((N) => String(N[R])), [ee, R]), { data: B = /* @__PURE__ */ new Map() } = Q({
2342
- queryKey: ["catalog-facet-items", m, f, Z.join(",")],
2448
+ [re, V, T, v, L, H, (xe = i.result) == null ? void 0 : xe.sort, M]
2449
+ ), G = R(() => ee.map((N) => String(N[L])), [ee, L]), { data: B = /* @__PURE__ */ new Map() } = Q({
2450
+ queryKey: ["catalog-facet-items", m, p, G.join(",")],
2343
2451
  queryFn: async () => {
2344
2452
  const N = /* @__PURE__ */ new Map();
2345
- for (let L = 0; L < Z.length; L += 200) {
2346
- const O = Z.slice(L, L + 200), $ = await T.request(
2347
- J(`/items/${m}`, {
2348
- filter: JSON.stringify({ id: { _in: O } }),
2349
- fields: f,
2350
- limit: O.length
2453
+ for (let E = 0; E < G.length; E += 200) {
2454
+ const P = G.slice(E, E + 200), j = await O.request(
2455
+ C(`/items/${m}`, {
2456
+ filter: JSON.stringify({ id: { _in: P } }),
2457
+ fields: p,
2458
+ limit: P.length
2351
2459
  })
2352
2460
  );
2353
- for (const A of $.data ?? []) N.set(String(A.id), A);
2461
+ for (const K of j.data ?? []) N.set(String(K.id), K);
2354
2462
  }
2355
2463
  return N;
2356
2464
  },
2357
- enabled: Z.length > 0,
2465
+ enabled: G.length > 0,
2358
2466
  staleTime: 6e4
2359
- }), se = v.filter((N) => P[N.key]).length;
2467
+ }), se = v.filter((N) => T[N.key]).length;
2360
2468
  async function ie(N) {
2361
- const L = I[N] ?? "1", O = Number(L), $ = B.get(N);
2362
- if (!(!$ || !Number.isFinite(O) || O <= 0 || w !== "any" && !Number.isInteger(O))) {
2469
+ const E = z[N] ?? "1", P = Number(E), j = B.get(N);
2470
+ if (!(!j || !Number.isFinite(P) || P <= 0 || k !== "any" && !Number.isInteger(P))) {
2363
2471
  ke(N);
2364
2472
  try {
2365
- await a(N, (_(N) ?? 0) + O, $), pe((A) => ({ ...A, [N]: "1" }));
2473
+ await s(N, (_(N) ?? 0) + P, j), pe((K) => ({ ...K, [N]: "1" }));
2366
2474
  } finally {
2367
2475
  ke(null);
2368
2476
  }
@@ -2382,8 +2490,8 @@ function Qs({
2382
2490
  "aria-expanded": me,
2383
2491
  className: "flex w-full items-center gap-1.5 rounded-t-lg bg-slate-100/80 px-2 py-1.5 text-left dark:bg-muted",
2384
2492
  children: [
2385
- /* @__PURE__ */ s(
2386
- Ct,
2493
+ /* @__PURE__ */ a(
2494
+ Jt,
2387
2495
  {
2388
2496
  className: W(
2389
2497
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
@@ -2391,25 +2499,25 @@ function Qs({
2391
2499
  )
2392
2500
  }
2393
2501
  ),
2394
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: i.label })
2502
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: i.label })
2395
2503
  ]
2396
2504
  }
2397
2505
  ),
2398
- me && /* @__PURE__ */ s("div", { className: "space-y-3 border-t border-slate-200 p-3 dark:border-border", children: je ? /* @__PURE__ */ u("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
2399
- /* @__PURE__ */ s(ue, { className: "h-4 w-4 animate-spin" }),
2506
+ me && /* @__PURE__ */ a("div", { className: "space-y-3 border-t border-slate-200 p-3 dark:border-border", children: Te ? /* @__PURE__ */ u("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
2507
+ /* @__PURE__ */ a(ue, { className: "h-4 w-4 animate-spin" }),
2400
2508
  " Loading options…"
2401
- ] }) : he ? /* @__PURE__ */ s("p", { className: "text-slate-500 dark:text-slate-400", children: "The options could not be loaded. Close and open this section to try again." }) : /* @__PURE__ */ u(Ne, { children: [
2509
+ ] }) : he ? /* @__PURE__ */ a("p", { className: "text-slate-500 dark:text-slate-400", children: "The options could not be loaded. Close and open this section to try again." }) : /* @__PURE__ */ u(Se, { children: [
2402
2510
  /* @__PURE__ */ u("div", { className: "flex flex-wrap items-end gap-3", children: [
2403
2511
  v.map((N) => {
2404
- const L = ys(U, P, v, N.key, M);
2405
- return /* @__PURE__ */ s(
2406
- pr,
2512
+ const E = $s(V, T, v, N.key, M);
2513
+ return /* @__PURE__ */ a(
2514
+ wr,
2407
2515
  {
2408
2516
  label: N.label,
2409
- value: P[N.key] ?? null,
2410
- valueLabel: P[N.key] ?? null,
2411
- options: L.map((O) => [O, O]),
2412
- onChange: (O) => be(($) => gs(U, $, v, N.key, O, M))
2517
+ value: T[N.key] ?? null,
2518
+ valueLabel: T[N.key] ?? null,
2519
+ options: E.map((P) => [P, P]),
2520
+ onChange: (P) => be((j) => js(V, j, v, N.key, P, M))
2413
2521
  },
2414
2522
  N.key
2415
2523
  );
@@ -2421,46 +2529,46 @@ function Qs({
2421
2529
  onClick: () => be({}),
2422
2530
  className: "mb-0.5 flex h-7 items-center gap-1 rounded px-2 text-[12px] text-slate-500 hover:bg-muted hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200",
2423
2531
  children: [
2424
- /* @__PURE__ */ s(ut, { className: "h-3 w-3" }),
2532
+ /* @__PURE__ */ a(pt, { className: "h-3 w-3" }),
2425
2533
  " Clear"
2426
2534
  ]
2427
2535
  }
2428
2536
  )
2429
2537
  ] }),
2430
- re ? ee.length === 0 ? /* @__PURE__ */ s("p", { className: "text-slate-400", children: "Nothing matches this combination." }) : /* @__PURE__ */ u("div", { className: "divide-y divide-slate-100 rounded border border-slate-200 dark:divide-border dark:border-border", children: [
2538
+ re ? ee.length === 0 ? /* @__PURE__ */ a("p", { className: "text-slate-400", children: "Nothing matches this combination." }) : /* @__PURE__ */ u("div", { className: "divide-y divide-slate-100 rounded border border-slate-200 dark:divide-border dark:border-border", children: [
2431
2539
  /* @__PURE__ */ u("div", { className: "flex items-center gap-2 bg-slate-50 px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-slate-500 dark:bg-muted dark:text-slate-400", children: [
2432
- /* @__PURE__ */ s("span", { className: "flex-1", children: ((y = i.result) == null ? void 0 : y.label) ?? "Option" }),
2433
- !k && /* @__PURE__ */ s("span", { className: "w-[124px] text-right", children: "Quantity" })
2540
+ /* @__PURE__ */ a("span", { className: "flex-1", children: ((y = i.result) == null ? void 0 : y.label) ?? "Option" }),
2541
+ !w && /* @__PURE__ */ a("span", { className: "w-[124px] text-right", children: "Quantity" })
2434
2542
  ] }),
2435
2543
  ee.map((N) => {
2436
- var K;
2437
- const L = String(N[R]), O = B.get(L), $ = _(L) ?? 0, A = (K = i.result) != null && K.detail ? String(N[i.result.detail] ?? "") : "";
2544
+ var A;
2545
+ const E = String(N[L]), P = B.get(E), j = _(E) ?? 0, K = (A = i.result) != null && A.detail ? String(N[i.result.detail] ?? "") : "";
2438
2546
  return /* @__PURE__ */ u(
2439
2547
  "div",
2440
2548
  {
2441
2549
  className: "flex items-center gap-2 px-2 py-1.5",
2442
- "data-facet-result": L,
2550
+ "data-facet-result": E,
2443
2551
  children: [
2444
2552
  /* @__PURE__ */ u("div", { className: "min-w-0 flex-1", children: [
2445
- /* @__PURE__ */ s("p", { className: "truncate font-medium tabular-nums text-slate-700 dark:text-slate-200", children: String(N[H] ?? "") }),
2446
- /* @__PURE__ */ s("p", { className: "truncate text-[11px] text-slate-400", children: A || (O ? Ke(x, O) : "") })
2553
+ /* @__PURE__ */ a("p", { className: "truncate font-medium tabular-nums text-slate-700 dark:text-slate-200", children: String(N[H] ?? "") }),
2554
+ /* @__PURE__ */ a("p", { className: "truncate text-[11px] text-slate-400", children: K || (P ? Ce(g, P) : "") })
2447
2555
  ] }),
2448
- $ > 0 && /* @__PURE__ */ u("span", { className: "shrink-0 rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
2449
- $,
2556
+ j > 0 && /* @__PURE__ */ u("span", { className: "shrink-0 rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
2557
+ j,
2450
2558
  " in summary"
2451
2559
  ] }),
2452
- !k && /* @__PURE__ */ u(Ne, { children: [
2453
- /* @__PURE__ */ s(
2560
+ !w && /* @__PURE__ */ u(Se, { children: [
2561
+ /* @__PURE__ */ a(
2454
2562
  "input",
2455
2563
  {
2456
2564
  type: "number",
2457
2565
  min: 0,
2458
- step: w,
2459
- value: I[L] ?? "1",
2566
+ step: k,
2567
+ value: z[E] ?? "1",
2460
2568
  "aria-label": `Quantity of ${String(N[H] ?? "")}`,
2461
- onChange: (te) => pe((Ce) => ({ ...Ce, [L]: te.target.value })),
2569
+ onChange: (te) => pe((Je) => ({ ...Je, [E]: te.target.value })),
2462
2570
  onKeyDown: (te) => {
2463
- te.key === "Enter" && (te.preventDefault(), ie(L));
2571
+ te.key === "Enter" && (te.preventDefault(), ie(E));
2464
2572
  },
2465
2573
  className: "h-7 w-16 shrink-0 rounded border border-slate-200 bg-white px-2 text-right text-[12px] outline-none focus:border-nvr-cyan dark:border-border dark:bg-background"
2466
2574
  }
@@ -2469,11 +2577,11 @@ function Qs({
2469
2577
  "button",
2470
2578
  {
2471
2579
  type: "button",
2472
- onClick: () => void ie(L),
2473
- disabled: !O || ge !== null,
2580
+ onClick: () => void ie(E),
2581
+ disabled: !P || ge !== null,
2474
2582
  className: "flex h-7 w-[52px] shrink-0 items-center justify-center gap-1 rounded bg-nvr-cyan px-2 text-[12px] font-medium text-white hover:bg-nvr-cyan/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan focus-visible:ring-offset-1 disabled:opacity-50",
2475
2583
  children: [
2476
- ge === L ? /* @__PURE__ */ s(ue, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(cr, { className: "h-3.5 w-3.5" }),
2584
+ ge === E ? /* @__PURE__ */ a(ue, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(xr, { className: "h-3.5 w-3.5" }),
2477
2585
  "Add"
2478
2586
  ]
2479
2587
  }
@@ -2481,13 +2589,13 @@ function Qs({
2481
2589
  ] })
2482
2590
  ]
2483
2591
  },
2484
- L
2592
+ E
2485
2593
  );
2486
2594
  })
2487
2595
  ] }) : /* @__PURE__ */ u("p", { className: "text-slate-400", children: [
2488
2596
  "Pick",
2489
2597
  " ",
2490
- v.filter((N) => !P[N.key]).map((N) => N.label).join(", "),
2598
+ v.filter((N) => !T[N.key]).map((N) => N.label).join(", "),
2491
2599
  " ",
2492
2600
  "to see the ",
2493
2601
  (((F = i.result) == null ? void 0 : F.label) ?? "options").toLowerCase(),
@@ -2498,202 +2606,202 @@ function Qs({
2498
2606
  }
2499
2607
  );
2500
2608
  }
2501
- function zs({
2609
+ function na({
2502
2610
  parentCollection: i,
2503
2611
  field: m,
2504
- id: f
2612
+ id: p
2505
2613
  }) {
2506
- var k;
2507
- const x = mt(), { data: _ = [] } = Q({
2614
+ var w;
2615
+ const g = ht(), { data: _ = [] } = Q({
2508
2616
  queryKey: At.collectionRelations(i),
2509
- queryFn: () => pn(x, i),
2617
+ queryFn: () => yn(g, i),
2510
2618
  enabled: !!i,
2511
2619
  staleTime: 10 * 6e4
2512
- }), a = ((k = _.find(
2513
- (T) => T.many_collection === i && T.many_field === m && !T.junction_field
2514
- )) == null ? void 0 : k.one_collection) ?? null, { data: w } = Q({
2515
- queryKey: ["col-meta", a],
2516
- queryFn: () => x.request(J(`/collections/${a}`)).then((T) => T.data),
2517
- enabled: !!a,
2620
+ }), s = ((w = _.find(
2621
+ (O) => O.many_collection === i && O.many_field === m && !O.junction_field
2622
+ )) == null ? void 0 : w.one_collection) ?? null, { data: k } = Q({
2623
+ queryKey: ["col-meta", s],
2624
+ queryFn: () => g.request(C(`/collections/${s}`)).then((O) => O.data),
2625
+ enabled: !!s,
2518
2626
  staleTime: 3e5
2519
2627
  });
2520
- return a ? /* @__PURE__ */ s(Fs, { collection: a, id: f, displayTemplate: w == null ? void 0 : w.display_template }) : /* @__PURE__ */ u(Ne, { children: [
2628
+ return s ? /* @__PURE__ */ a(Us, { collection: s, id: p, displayTemplate: k == null ? void 0 : k.display_template }) : /* @__PURE__ */ u(Se, { children: [
2521
2629
  "this ",
2522
- X(m)
2630
+ Z(m)
2523
2631
  ] });
2524
2632
  }
2525
- function dr({
2633
+ function br({
2526
2634
  text: i,
2527
2635
  highlight: m,
2528
- className: f,
2529
- ...x
2636
+ className: p,
2637
+ ...g
2530
2638
  }) {
2531
- const _ = fs(i);
2532
- return /* @__PURE__ */ s("span", { ref: _, className: W("truncate", f), ...x, children: m ? /* @__PURE__ */ s(hn, { text: i, query: m }) : i });
2639
+ const _ = Ns(i);
2640
+ return /* @__PURE__ */ a("span", { ref: _, className: W("truncate", p), ...g, children: m ? /* @__PURE__ */ a(gn, { text: i, query: m }) : i });
2533
2641
  }
2534
- function pr({
2642
+ function wr({
2535
2643
  label: i,
2536
2644
  value: m,
2537
- valueLabel: f,
2538
- options: x,
2645
+ valueLabel: p,
2646
+ options: g,
2539
2647
  disabled: _,
2540
- onChange: a
2648
+ onChange: s
2541
2649
  }) {
2542
- const [w, k] = D(!1), T = qe(null);
2543
- return $e(() => {
2544
- if (!w) return;
2545
- const v = (R) => {
2546
- T.current && !T.current.contains(R.target) && k(!1);
2650
+ const [k, w] = D(!1), O = je(null);
2651
+ return Fe(() => {
2652
+ if (!k) return;
2653
+ const v = (L) => {
2654
+ O.current && !O.current.contains(L.target) && w(!1);
2547
2655
  };
2548
2656
  return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
2549
- }, [w]), /* @__PURE__ */ u("div", { ref: T, className: "relative", children: [
2550
- /* @__PURE__ */ s("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: i }),
2657
+ }, [k]), /* @__PURE__ */ u("div", { ref: O, className: "relative", children: [
2658
+ /* @__PURE__ */ a("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: i }),
2551
2659
  /* @__PURE__ */ u(
2552
2660
  "button",
2553
2661
  {
2554
2662
  type: "button",
2555
2663
  disabled: _,
2556
- onClick: () => k((v) => !v),
2664
+ onClick: () => w((v) => !v),
2557
2665
  className: "flex w-44 items-center justify-between rounded border border-slate-200 bg-white px-2 py-1.5 text-left text-[12px] text-slate-700 hover:border-slate-300 disabled:opacity-50 dark:border-border dark:bg-background dark:text-slate-200",
2558
2666
  children: [
2559
- /* @__PURE__ */ s("span", { className: W("truncate", !f && "text-slate-400"), children: f ?? "Select…" }),
2560
- /* @__PURE__ */ s(Xr, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
2667
+ /* @__PURE__ */ a("span", { className: W("truncate", !p && "text-slate-400"), children: p ?? "Select…" }),
2668
+ /* @__PURE__ */ a(os, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
2561
2669
  ]
2562
2670
  }
2563
2671
  ),
2564
- w && /* @__PURE__ */ u("div", { className: "absolute z-50 mt-1 max-h-52 w-44 overflow-y-auto rounded-md border border-border bg-popover py-1 shadow-md", children: [
2672
+ k && /* @__PURE__ */ u("div", { className: "absolute z-50 mt-1 max-h-52 w-44 overflow-y-auto rounded-md border border-border bg-popover py-1 shadow-md", children: [
2565
2673
  m && /* @__PURE__ */ u(
2566
2674
  "button",
2567
2675
  {
2568
2676
  type: "button",
2569
2677
  onClick: () => {
2570
- a(null), k(!1);
2678
+ s(null), w(!1);
2571
2679
  },
2572
2680
  className: "flex w-full items-center gap-1.5 border-b border-slate-100 px-2 py-1 text-left text-[12px] text-slate-500 hover:bg-muted dark:border-border dark:text-slate-400",
2573
2681
  children: [
2574
- /* @__PURE__ */ s(ut, { className: "h-3 w-3 text-slate-400" }),
2682
+ /* @__PURE__ */ a(pt, { className: "h-3 w-3 text-slate-400" }),
2575
2683
  " Clear"
2576
2684
  ]
2577
2685
  }
2578
2686
  ),
2579
- x.map(([v, R]) => /* @__PURE__ */ s(
2687
+ g.map(([v, L]) => /* @__PURE__ */ a(
2580
2688
  "button",
2581
2689
  {
2582
2690
  type: "button",
2583
2691
  onClick: () => {
2584
- a(v), k(!1);
2692
+ s(v), w(!1);
2585
2693
  },
2586
2694
  className: W(
2587
2695
  "block w-full truncate px-2 py-1 text-left text-[12px] hover:bg-muted",
2588
2696
  v === m ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
2589
2697
  ),
2590
- children: R
2698
+ children: L
2591
2699
  },
2592
2700
  v
2593
2701
  ))
2594
2702
  ] })
2595
2703
  ] });
2596
2704
  }
2597
- function Ms({
2705
+ function ra({
2598
2706
  catalogCol: i,
2599
2707
  tmpl: m,
2600
- sectionBy: f,
2601
- sectionM2M: x,
2708
+ sectionBy: p,
2709
+ sectionM2M: g,
2602
2710
  pinnedSet: _,
2603
- pinnedIds: a,
2604
- savingIds: w,
2605
- relatedCols: k,
2606
- parentDraft: T,
2711
+ pinnedIds: s,
2712
+ savingIds: k,
2713
+ relatedCols: w,
2714
+ parentDraft: O,
2607
2715
  onToggle: v,
2608
- onClose: R,
2716
+ onClose: L,
2609
2717
  anchor: H
2610
2718
  }) {
2611
- const M = mt(), [me, fe] = D(""), [P, be] = D(""), [I, pe] = D(1), ge = qe(null);
2612
- $e(() => {
2719
+ const M = ht(), [me, fe] = D(""), [T, be] = D(""), [z, pe] = D(1), ge = je(null);
2720
+ Fe(() => {
2613
2721
  const d = setTimeout(() => be(me), 300);
2614
2722
  return () => clearTimeout(d);
2615
- }, [me]), $e(() => pe(1), [P]), $e(() => {
2723
+ }, [me]), Fe(() => pe(1), [T]), Fe(() => {
2616
2724
  var d;
2617
2725
  (d = ge.current) == null || d.focus();
2618
- }, []), $e(() => {
2726
+ }, []), Fe(() => {
2619
2727
  const d = (S) => {
2620
- S.key === "Escape" && (S.stopPropagation(), R());
2728
+ S.key === "Escape" && (S.stopPropagation(), L());
2621
2729
  };
2622
2730
  return window.addEventListener("keydown", d, !0), () => window.removeEventListener("keydown", d, !0);
2623
- }, [R]);
2624
- const ke = E(() => {
2731
+ }, [L]);
2732
+ const ke = R(() => {
2625
2733
  var S;
2626
2734
  const d = (S = [...(m ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : S[1];
2627
2735
  return d && !d.includes(".") ? d : "id";
2628
- }, [m]), U = !x && f.includes(".") ? `*,${f}` : "*", je = 50, { data: he, isFetching: re } = Q({
2629
- queryKey: ["favorites-manager-list", i, P, ke, I],
2736
+ }, [m]), V = !g && p.includes(".") ? `*,${p}` : "*", Te = 50, { data: he, isFetching: re } = Q({
2737
+ queryKey: ["favorites-manager-list", i, T, ke, z],
2630
2738
  queryFn: () => M.request(
2631
- J(`/items/${i}`, {
2632
- fields: U,
2633
- limit: je,
2634
- page: I,
2739
+ C(`/items/${i}`, {
2740
+ fields: V,
2741
+ limit: Te,
2742
+ page: z,
2635
2743
  sort: ke,
2636
- ...P.trim() ? { search: P } : {}
2744
+ ...T.trim() ? { search: T } : {}
2637
2745
  })
2638
2746
  ),
2639
2747
  staleTime: 3e4,
2640
2748
  placeholderData: (d) => d
2641
- }), ee = ((he == null ? void 0 : he.data) ?? []).filter((d) => !_.has(String(d.id))), Z = (he == null ? void 0 : he.total) ?? ee.length, B = Math.max(1, Math.ceil(Z / je)), { data: se = [] } = Q({
2642
- queryKey: ["favorites-manager-pinned", i, U, a.join(",")],
2749
+ }), ee = ((he == null ? void 0 : he.data) ?? []).filter((d) => !_.has(String(d.id))), G = (he == null ? void 0 : he.total) ?? ee.length, B = Math.max(1, Math.ceil(G / Te)), { data: se = [] } = Q({
2750
+ queryKey: ["favorites-manager-pinned", i, V, s.join(",")],
2643
2751
  queryFn: () => M.request(
2644
- J(`/items/${i}`, {
2645
- filter: JSON.stringify({ id: { _in: a } }),
2646
- fields: U,
2647
- limit: a.length,
2752
+ C(`/items/${i}`, {
2753
+ filter: JSON.stringify({ id: { _in: s } }),
2754
+ fields: V,
2755
+ limit: s.length,
2648
2756
  sort: ke
2649
2757
  })
2650
2758
  ).then((d) => d.data ?? []),
2651
- enabled: a.length > 0,
2759
+ enabled: s.length > 0,
2652
2760
  staleTime: 3e4
2653
- }), ie = E(() => {
2761
+ }), ie = R(() => {
2654
2762
  const d = /* @__PURE__ */ new Set();
2655
2763
  for (const S of ee) d.add(String(S.id));
2656
- for (const S of a) d.add(S);
2764
+ for (const S of s) d.add(S);
2657
2765
  return [...d];
2658
- }, [ee, a]), { data: ve = /* @__PURE__ */ new Map() } = Q({
2659
- queryKey: ["favorites-manager-sections", x == null ? void 0 : x.junction, ie.join(",")],
2766
+ }, [ee, s]), { data: _e = /* @__PURE__ */ new Map() } = Q({
2767
+ queryKey: ["favorites-manager-sections", g == null ? void 0 : g.junction, ie.join(",")],
2660
2768
  queryFn: async () => {
2661
- const d = x, S = await Jt(M, `/items/${d.junction}`, {
2769
+ const d = g, S = await It(M, `/items/${d.junction}`, {
2662
2770
  fields: `${d.fkToItem},${d.fkToSection}`,
2663
2771
  filter: JSON.stringify({ [d.fkToItem]: { _in: ie } })
2664
- }), G = [...new Set(S.map((ne) => String(ne[d.fkToSection])))], le = G.length ? await Jt(M, `/items/${d.target}`, {
2772
+ }), X = [...new Set(S.map((ne) => String(ne[d.fkToSection])))], le = X.length ? await It(M, `/items/${d.target}`, {
2665
2773
  fields: `id,${d.labelPath}`,
2666
- filter: JSON.stringify({ id: { _in: G } })
2774
+ filter: JSON.stringify({ id: { _in: X } })
2667
2775
  }) : [], Y = new Map(
2668
- le.map((ne) => [String(ne.id), String(fr(ne, d.labelPath) ?? "")])
2776
+ le.map((ne) => [String(ne.id), String(kr(ne, d.labelPath) ?? "")])
2669
2777
  ), ae = /* @__PURE__ */ new Map();
2670
2778
  for (const ne of S) {
2671
- const z = Y.get(String(ne[d.fkToSection]));
2672
- if (!z) continue;
2673
- const Je = String(ne[d.fkToItem]), oe = ae.get(Je) ?? [];
2674
- oe.includes(z) || oe.push(z), ae.set(Je, oe);
2779
+ const U = Y.get(String(ne[d.fkToSection]));
2780
+ if (!U) continue;
2781
+ const Ie = String(ne[d.fkToItem]), oe = ae.get(Ie) ?? [];
2782
+ oe.includes(U) || oe.push(U), ae.set(Ie, oe);
2675
2783
  }
2676
2784
  return ae;
2677
2785
  },
2678
- enabled: !!x && ie.length > 0,
2786
+ enabled: !!g && ie.length > 0,
2679
2787
  staleTime: 6e4
2680
- }), xe = (d) => m ? Ke(m, d) : String(d.cifa_number ?? d.name ?? `#${d.id}`), F = (d) => {
2788
+ }), xe = (d) => m ? Ce(m, d) : String(d.cifa_number ?? d.name ?? `#${d.id}`), F = (d) => {
2681
2789
  const S = d.description ?? d.long_description ?? d.name;
2682
2790
  return typeof S == "string" && S.trim() && S.trim() !== xe(d) ? S : "";
2683
2791
  }, y = (d) => {
2684
- if (x) return (ve.get(String(d.id)) ?? []).join(", ");
2685
- if (!f) return "";
2686
- const S = Ke(`{{${f}}}`, d);
2687
- return S === `{{${f}}}` ? "" : S;
2792
+ if (g) return (_e.get(String(d.id)) ?? []).join(", ");
2793
+ if (!p) return "";
2794
+ const S = Ce(`{{${p}}}`, d);
2795
+ return S === `{{${p}}}` ? "" : S;
2688
2796
  }, N = (d, S) => {
2689
2797
  if (S === "presence")
2690
2798
  return d == null || d === "" || Number(d) === 0 ? "No" : "Yes";
2691
2799
  if (d == null || d === "") return "—";
2692
- const G = Number(d);
2693
- return S === "currency" && Number.isFinite(G) ? G.toLocaleString("en-US", { style: "currency", currency: "USD" }) : S === "number" && Number.isFinite(G) ? G.toLocaleString() : String(d);
2694
- }, L = fn({
2695
- queries: k.map((d) => {
2696
- const S = Ye(d.match, T);
2800
+ const X = Number(d);
2801
+ return S === "currency" && Number.isFinite(X) ? X.toLocaleString("en-US", { style: "currency", currency: "USD" }) : S === "number" && Number.isFinite(X) ? X.toLocaleString() : String(d);
2802
+ }, E = xn({
2803
+ queries: w.map((d) => {
2804
+ const S = Ge(d.match, O);
2697
2805
  return {
2698
2806
  queryKey: [
2699
2807
  "favorites-manager-related",
@@ -2703,16 +2811,16 @@ function Ms({
2703
2811
  ie.join(",")
2704
2812
  ],
2705
2813
  queryFn: async () => {
2706
- const G = await M.request(
2707
- J(`/items/${d.collection}`, {
2814
+ const X = await M.request(
2815
+ C(`/items/${d.collection}`, {
2708
2816
  filter: JSON.stringify({ [d.item_field]: { _in: ie }, ...S ?? {} }),
2709
2817
  fields: `${d.item_field},${d.value_field}`,
2710
2818
  limit: 1e3
2711
2819
  })
2712
2820
  ).then((Y) => Y.data ?? []), le = /* @__PURE__ */ new Map();
2713
- for (const Y of G) {
2714
- const ae = String(Y[d.item_field]), ne = Y[d.value_field], z = le.get(ae);
2715
- z === void 0 ? le.set(ae, ne) : Number.isFinite(Number(z)) && Number.isFinite(Number(ne)) && le.set(ae, Number(z) + Number(ne));
2821
+ for (const Y of X) {
2822
+ const ae = String(Y[d.item_field]), ne = Y[d.value_field], U = le.get(ae);
2823
+ U === void 0 ? le.set(ae, ne) : Number.isFinite(Number(U)) && Number.isFinite(Number(ne)) && le.set(ae, Number(U) + Number(ne));
2716
2824
  }
2717
2825
  return le;
2718
2826
  },
@@ -2720,20 +2828,20 @@ function Ms({
2720
2828
  staleTime: 3e4
2721
2829
  };
2722
2830
  })
2723
- }), O = k.filter(
2724
- (d) => d.match !== void 0 && Ye(d.match, T) === null
2725
- ), $ = (d) => {
2831
+ }), P = w.filter(
2832
+ (d) => d.match !== void 0 && Ge(d.match, O) === null
2833
+ ), j = (d) => {
2726
2834
  const S = _.has(d);
2727
- return /* @__PURE__ */ s(
2835
+ return /* @__PURE__ */ a(
2728
2836
  "button",
2729
2837
  {
2730
2838
  type: "button",
2731
2839
  title: S ? "Remove from favorites" : "Add to favorites",
2732
- disabled: w.has(d),
2840
+ disabled: k.has(d),
2733
2841
  onClick: () => v(d),
2734
2842
  className: "shrink-0 rounded p-1 transition-colors hover:bg-amber-100/60 dark:hover:bg-amber-400/10",
2735
- children: w.has(d) ? /* @__PURE__ */ s(ue, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ s(
2736
- ct,
2843
+ children: k.has(d) ? /* @__PURE__ */ a(ue, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ a(
2844
+ ft,
2737
2845
  {
2738
2846
  className: W(
2739
2847
  "h-4 w-4",
@@ -2743,8 +2851,8 @@ function Ms({
2743
2851
  )
2744
2852
  }
2745
2853
  );
2746
- }, A = (d, S) => /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", { colSpan: 4 + k.length, className: W("border-b px-3 py-1.5", S), children: d }) }), K = (d, S) => {
2747
- const G = String(d.id), le = F(d);
2854
+ }, K = (d, S) => /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { colSpan: 4 + w.length, className: W("border-b px-3 py-1.5", S), children: d }) }), A = (d, S) => {
2855
+ const X = String(d.id), le = F(d);
2748
2856
  return /* @__PURE__ */ u(
2749
2857
  "tr",
2750
2858
  {
@@ -2753,43 +2861,43 @@ function Ms({
2753
2861
  S % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
2754
2862
  ),
2755
2863
  children: [
2756
- /* @__PURE__ */ s("td", { className: "px-2 py-1", children: $(G) }),
2757
- /* @__PURE__ */ s("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: ur(i) ? /* @__PURE__ */ s(
2864
+ /* @__PURE__ */ a("td", { className: "px-2 py-1", children: j(X) }),
2865
+ /* @__PURE__ */ a("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: yr(i) ? /* @__PURE__ */ a(
2758
2866
  "button",
2759
2867
  {
2760
2868
  type: "button",
2761
- onClick: () => mr(i, G, T),
2869
+ onClick: () => gr(i, X, O),
2762
2870
  title: "View stock & planning detail",
2763
2871
  className: "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600",
2764
2872
  children: xe(d)
2765
2873
  }
2766
2874
  ) : xe(d) }),
2767
- /* @__PURE__ */ s("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": le || void 0, children: le || "—" }) }),
2768
- /* @__PURE__ */ s("td", { className: "px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-500 dark:text-slate-400", children: y(d) || "—" }) }),
2769
- k.map((Y, ae) => {
2770
- var Je, oe;
2771
- const ne = Y.match !== void 0 && Ye(Y.match, T) === null, z = ne || (oe = (Je = L[ae]) == null ? void 0 : Je.data) == null ? void 0 : oe.get(G);
2772
- return /* @__PURE__ */ s(
2875
+ /* @__PURE__ */ a("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ a("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": le || void 0, children: le || "—" }) }),
2876
+ /* @__PURE__ */ a("td", { className: "px-2 py-1", children: /* @__PURE__ */ a("p", { className: "truncate text-slate-500 dark:text-slate-400", children: y(d) || "—" }) }),
2877
+ w.map((Y, ae) => {
2878
+ var Ie, oe;
2879
+ const ne = Y.match !== void 0 && Ge(Y.match, O) === null, U = ne || (oe = (Ie = E[ae]) == null ? void 0 : Ie.data) == null ? void 0 : oe.get(X);
2880
+ return /* @__PURE__ */ a(
2773
2881
  "td",
2774
2882
  {
2775
2883
  className: "whitespace-nowrap px-2 py-1 text-right tabular-nums text-slate-600 dark:text-slate-300",
2776
- children: ne ? "—" : N(z, Y.format)
2884
+ children: ne ? "—" : N(U, Y.format)
2777
2885
  },
2778
2886
  Y.key
2779
2887
  );
2780
2888
  })
2781
2889
  ]
2782
2890
  },
2783
- G
2891
+ X
2784
2892
  );
2785
- }, te = (H == null ? void 0 : H.closest('[role="dialog"]')) ?? document.body, Ce = me.trim() ? se.filter((d) => us(`${xe(d)} ${F(d)} ${y(d)}`, me)) : se;
2786
- return es(
2893
+ }, te = (H == null ? void 0 : H.closest('[role="dialog"]')) ?? document.body, Je = me.trim() ? se.filter((d) => ks(`${xe(d)} ${F(d)} ${y(d)}`, me)) : se;
2894
+ return ds(
2787
2895
  /* @__PURE__ */ u("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
2788
- /* @__PURE__ */ s(
2896
+ /* @__PURE__ */ a(
2789
2897
  "div",
2790
2898
  {
2791
2899
  className: "absolute inset-0 bg-slate-900/30 motion-safe:animate-in motion-safe:fade-in",
2792
- onClick: R
2900
+ onClick: L
2793
2901
  }
2794
2902
  ),
2795
2903
  /* @__PURE__ */ u(
@@ -2801,26 +2909,26 @@ function Ms({
2801
2909
  className: "absolute inset-y-0 right-0 flex flex-col border-l border-slate-200 bg-white shadow-2xl motion-safe:animate-in motion-safe:slide-in-from-right dark:border-border dark:bg-background",
2802
2910
  children: [
2803
2911
  /* @__PURE__ */ u("div", { className: "flex items-start gap-2.5 border-b border-slate-200 px-4 py-3 dark:border-border", children: [
2804
- /* @__PURE__ */ s(ct, { className: "mt-0.5 h-4 w-4 shrink-0 fill-amber-400 text-amber-400" }),
2912
+ /* @__PURE__ */ a(ft, { className: "mt-0.5 h-4 w-4 shrink-0 fill-amber-400 text-amber-400" }),
2805
2913
  /* @__PURE__ */ u("div", { className: "min-w-0 flex-1", children: [
2806
- /* @__PURE__ */ s("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: "CIFA favorites" }),
2807
- /* @__PURE__ */ s("p", { className: "text-[11px] leading-snug text-slate-500 dark:text-slate-400", children: "Browse the full catalog and star items — favorites appear at the top of every request's item list." })
2914
+ /* @__PURE__ */ a("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: "CIFA favorites" }),
2915
+ /* @__PURE__ */ a("p", { className: "text-[11px] leading-snug text-slate-500 dark:text-slate-400", children: "Browse the full catalog and star items — favorites appear at the top of every request's item list." })
2808
2916
  ] }),
2809
- /* @__PURE__ */ s(
2917
+ /* @__PURE__ */ a(
2810
2918
  "button",
2811
2919
  {
2812
2920
  type: "button",
2813
- onClick: R,
2921
+ onClick: L,
2814
2922
  className: "shrink-0 rounded p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-white/[0.06]",
2815
2923
  "aria-label": "Close",
2816
- children: /* @__PURE__ */ s(ut, { className: "h-4 w-4" })
2924
+ children: /* @__PURE__ */ a(pt, { className: "h-4 w-4" })
2817
2925
  }
2818
2926
  )
2819
2927
  ] }),
2820
2928
  /* @__PURE__ */ u("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
2821
2929
  /* @__PURE__ */ u("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-slate-50 px-2.5 py-1.5 focus-within:border-nvr-cyan focus-within:bg-white dark:border-border dark:bg-muted/40 dark:focus-within:bg-background", children: [
2822
- /* @__PURE__ */ s(Kt, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
2823
- /* @__PURE__ */ s(
2930
+ /* @__PURE__ */ a(Ct, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
2931
+ /* @__PURE__ */ a(
2824
2932
  "input",
2825
2933
  {
2826
2934
  ref: ge,
@@ -2830,110 +2938,110 @@ function Ms({
2830
2938
  className: "min-w-0 flex-1 bg-transparent text-[12px] text-slate-700 outline-none placeholder:text-slate-400 dark:text-slate-200"
2831
2939
  }
2832
2940
  ),
2833
- me && /* @__PURE__ */ s(
2941
+ me && /* @__PURE__ */ a(
2834
2942
  "button",
2835
2943
  {
2836
2944
  type: "button",
2837
2945
  onClick: () => fe(""),
2838
2946
  className: "shrink-0 text-slate-400 hover:text-slate-600",
2839
2947
  "aria-label": "Clear search",
2840
- children: /* @__PURE__ */ s(ut, { className: "h-3.5 w-3.5" })
2948
+ children: /* @__PURE__ */ a(pt, { className: "h-3.5 w-3.5" })
2841
2949
  }
2842
2950
  )
2843
2951
  ] }),
2844
- O.length > 0 && /* @__PURE__ */ u("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
2845
- /* @__PURE__ */ s(He, { className: "h-3 w-3 shrink-0" }),
2846
- O.map((d) => d.label ?? X(d.key)).join(", "),
2952
+ P.length > 0 && /* @__PURE__ */ u("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
2953
+ /* @__PURE__ */ a(Ae, { className: "h-3 w-3 shrink-0" }),
2954
+ P.map((d) => d.label ?? Z(d.key)).join(", "),
2847
2955
  " fill in once the form's warehouse selection is made."
2848
2956
  ] })
2849
2957
  ] }),
2850
- /* @__PURE__ */ s("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ u("table", { className: "w-full table-fixed border-collapse text-[11px]", children: [
2958
+ /* @__PURE__ */ a("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ u("table", { className: "w-full table-fixed border-collapse text-[11px]", children: [
2851
2959
  /* @__PURE__ */ u("colgroup", { children: [
2852
- /* @__PURE__ */ s("col", { className: "w-9" }),
2853
- /* @__PURE__ */ s("col", { className: "w-[88px]" }),
2854
- /* @__PURE__ */ s("col", {}),
2855
- /* @__PURE__ */ s("col", { className: "w-[130px]" }),
2856
- k.map((d) => /* @__PURE__ */ s("col", { className: "w-[86px]" }, d.key))
2960
+ /* @__PURE__ */ a("col", { className: "w-9" }),
2961
+ /* @__PURE__ */ a("col", { className: "w-[88px]" }),
2962
+ /* @__PURE__ */ a("col", {}),
2963
+ /* @__PURE__ */ a("col", { className: "w-[130px]" }),
2964
+ w.map((d) => /* @__PURE__ */ a("col", { className: "w-[86px]" }, d.key))
2857
2965
  ] }),
2858
- /* @__PURE__ */ s("thead", { className: "sticky top-0 z-[1]", children: /* @__PURE__ */ u("tr", { className: "bg-slate-100 text-left text-[10px] font-semibold uppercase tracking-wide text-slate-500 dark:bg-muted dark:text-slate-400", children: [
2859
- /* @__PURE__ */ s("th", { className: "px-2 py-1.5", "aria-label": "Favorite" }),
2860
- /* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "CIFA #" }),
2861
- /* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "Description" }),
2862
- /* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "Category" }),
2863
- k.map((d) => /* @__PURE__ */ s("th", { className: "px-2 py-1.5 text-right", children: d.label ?? X(d.key) }, d.key))
2966
+ /* @__PURE__ */ a("thead", { className: "sticky top-0 z-[1]", children: /* @__PURE__ */ u("tr", { className: "bg-slate-100 text-left text-[10px] font-semibold uppercase tracking-wide text-slate-500 dark:bg-muted dark:text-slate-400", children: [
2967
+ /* @__PURE__ */ a("th", { className: "px-2 py-1.5", "aria-label": "Favorite" }),
2968
+ /* @__PURE__ */ a("th", { className: "px-2 py-1.5", children: "CIFA #" }),
2969
+ /* @__PURE__ */ a("th", { className: "px-2 py-1.5", children: "Description" }),
2970
+ /* @__PURE__ */ a("th", { className: "px-2 py-1.5", children: "Category" }),
2971
+ w.map((d) => /* @__PURE__ */ a("th", { className: "px-2 py-1.5 text-right", children: d.label ?? Z(d.key) }, d.key))
2864
2972
  ] }) }),
2865
2973
  /* @__PURE__ */ u("tbody", { className: W(re && "opacity-50 transition-opacity"), children: [
2866
- A(
2974
+ K(
2867
2975
  /* @__PURE__ */ u("span", { className: "flex items-center gap-1.5", children: [
2868
- /* @__PURE__ */ s(ct, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
2869
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
2870
- /* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: a.length })
2976
+ /* @__PURE__ */ a(ft, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
2977
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
2978
+ /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: s.length })
2871
2979
  ] }),
2872
2980
  "border-slate-200 bg-amber-50/70 dark:border-border dark:bg-amber-900/10"
2873
2981
  ),
2874
- Ce.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
2982
+ Je.length === 0 && /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a(
2875
2983
  "td",
2876
2984
  {
2877
- colSpan: 4 + k.length,
2985
+ colSpan: 4 + w.length,
2878
2986
  className: "border-b border-slate-100 px-4 py-3 text-center text-[11px] text-slate-400 dark:border-border/50",
2879
- children: a.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
2987
+ children: s.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
2880
2988
  }
2881
2989
  ) }),
2882
- Ce.map((d, S) => K(d, S)),
2883
- A(
2990
+ Je.map((d, S) => A(d, S)),
2991
+ K(
2884
2992
  /* @__PURE__ */ u("span", { className: "flex items-center gap-1.5", children: [
2885
- /* @__PURE__ */ s(Kt, { className: "h-3 w-3 shrink-0 text-slate-400" }),
2886
- /* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "All CIFAs" }),
2887
- /* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: Z.toLocaleString() }),
2888
- re && /* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin text-slate-400" })
2993
+ /* @__PURE__ */ a(Ct, { className: "h-3 w-3 shrink-0 text-slate-400" }),
2994
+ /* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "All CIFAs" }),
2995
+ /* @__PURE__ */ a("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: G.toLocaleString() }),
2996
+ re && /* @__PURE__ */ a(ue, { className: "h-3 w-3 animate-spin text-slate-400" })
2889
2997
  ] }),
2890
2998
  "border-t border-slate-200 bg-slate-50 dark:border-border dark:bg-muted/40"
2891
2999
  ),
2892
- !re && ee.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
3000
+ !re && ee.length === 0 && /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a(
2893
3001
  "td",
2894
3002
  {
2895
- colSpan: 4 + k.length,
3003
+ colSpan: 4 + w.length,
2896
3004
  className: "px-4 py-4 text-center text-[11px] text-slate-400",
2897
- children: P.trim() ? `No CIFAs match "${P}".` : "No catalog items."
3005
+ children: T.trim() ? `No CIFAs match "${T}".` : "No catalog items."
2898
3006
  }
2899
3007
  ) }),
2900
- ee.map((d, S) => K(d, S))
3008
+ ee.map((d, S) => A(d, S))
2901
3009
  ] })
2902
3010
  ] }) }),
2903
3011
  B > 1 && /* @__PURE__ */ u("div", { className: "flex shrink-0 items-center justify-between border-t border-slate-200 px-3 py-2 dark:border-border", children: [
2904
3012
  /* @__PURE__ */ u("span", { className: "flex items-center gap-2 text-[10px] tabular-nums text-slate-400", children: [
2905
- (I - 1) * je + 1,
3013
+ (z - 1) * Te + 1,
2906
3014
  "–",
2907
- Math.min(I * je, Z),
3015
+ Math.min(z * Te, G),
2908
3016
  " of",
2909
3017
  " ",
2910
- Z.toLocaleString(),
3018
+ G.toLocaleString(),
2911
3019
  re && /* @__PURE__ */ u("span", { className: "flex items-center gap-1 text-slate-500", children: [
2912
- /* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin" }),
3020
+ /* @__PURE__ */ a(ue, { className: "h-3 w-3 animate-spin" }),
2913
3021
  " Loading…"
2914
3022
  ] })
2915
3023
  ] }),
2916
3024
  /* @__PURE__ */ u("div", { className: "flex items-center gap-1", children: [
2917
- /* @__PURE__ */ s(
3025
+ /* @__PURE__ */ a(
2918
3026
  "button",
2919
3027
  {
2920
3028
  type: "button",
2921
- disabled: I <= 1 || re,
3029
+ disabled: z <= 1 || re,
2922
3030
  onClick: () => pe((d) => Math.max(1, d - 1)),
2923
3031
  className: "rounded border border-slate-200 px-2 py-0.5 text-[11px] text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:bg-white/[0.04]",
2924
3032
  children: "‹ Prev"
2925
3033
  }
2926
3034
  ),
2927
3035
  /* @__PURE__ */ u("span", { className: "px-1 text-[10px] tabular-nums text-slate-400", children: [
2928
- I,
3036
+ z,
2929
3037
  " / ",
2930
3038
  B.toLocaleString()
2931
3039
  ] }),
2932
- /* @__PURE__ */ s(
3040
+ /* @__PURE__ */ a(
2933
3041
  "button",
2934
3042
  {
2935
3043
  type: "button",
2936
- disabled: I >= B || re,
3044
+ disabled: z >= B || re,
2937
3045
  onClick: () => pe((d) => Math.min(B, d + 1)),
2938
3046
  className: "rounded border border-slate-200 px-2 py-0.5 text-[11px] text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:bg-white/[0.04]",
2939
3047
  children: "Next ›"
@@ -2948,26 +3056,26 @@ function Ms({
2948
3056
  te
2949
3057
  );
2950
3058
  }
2951
- function Vs(i, m) {
2952
- var x;
3059
+ function sa(i, m) {
3060
+ var g;
2953
3061
  if (!i) return null;
2954
- const f = (x = (m ?? []).find((_) => !_.format && !_.sections_only)) == null ? void 0 : x.field;
2955
- return !f || i.includes(`{{${f}}}`) ? i : `${i} · {{${f}}}`;
3062
+ const p = (g = (m ?? []).find((_) => !_.format && !_.sections_only)) == null ? void 0 : g.field;
3063
+ return !p || i.includes(`{{${p}}}`) ? i : `${i} · {{${p}}}`;
2956
3064
  }
2957
3065
  export {
2958
- ya as CatalogPickerField,
2959
- Qs as FacetBuilderCard,
2960
- _s as MAX_LINE_MONEY,
2961
- Vs as catalogOptionTemplate,
2962
- Ps as footerSum,
2963
- As as gridPriceValue,
2964
- Js as isUnpricedLine,
2965
- Cs as issuesAfterLinesChanged,
2966
- Es as lineComputeError,
2967
- or as matchesShowWhen,
2968
- Rs as qtyEntryProblem,
2969
- Ls as refusedQtyNote,
2970
- xn as relatedParentTokens,
2971
- Ks as savedLinesSignature,
2972
- Ts as stagedCatalogFill
3066
+ Pa as CatalogPickerField,
3067
+ ta as FacetBuilderCard,
3068
+ Js as MAX_LINE_MONEY,
3069
+ sa as catalogOptionTemplate,
3070
+ Bs as footerSum,
3071
+ Ys as gridPriceValue,
3072
+ Xs as isUnpricedLine,
3073
+ Gs as issuesAfterLinesChanged,
3074
+ Hs as lineComputeError,
3075
+ hr as matchesShowWhen,
3076
+ Vs as qtyEntryProblem,
3077
+ Ds as refusedQtyNote,
3078
+ wn as relatedParentTokens,
3079
+ Zs as savedLinesSignature,
3080
+ Ms as stagedCatalogFill
2973
3081
  };