@nivaro/react 0.2.53 → 0.2.55

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 (294) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +99 -98
  3. package/dist/index.d.ts +452 -4
  4. package/dist/index.js +644 -618
  5. package/dist/layout-editor.d.ts +252 -2
  6. package/dist/shared/components/BackgroundRunOffer.js +117 -0
  7. package/dist/shared/components/BroadcastView.js +214 -213
  8. package/dist/shared/components/CollectionBrowserView.js +2592 -2695
  9. package/dist/shared/components/FormWhatsNew.js +60 -0
  10. package/dist/shared/components/ItemEditForm.js +3968 -3618
  11. package/dist/shared/components/JobsTray.js +100 -55
  12. package/dist/shared/components/MyWorkView.js +91 -89
  13. package/dist/shared/components/NotificationBell.js +80 -79
  14. package/dist/shared/components/ProfileView.js +568 -520
  15. package/dist/shared/components/RecordCompare.js +254 -0
  16. package/dist/shared/components/RecordReadView.js +598 -543
  17. package/dist/shared/components/ReportView.js +578 -543
  18. package/dist/shared/components/RowPresence.js +91 -0
  19. package/dist/shared/components/TipLayer.js +27 -27
  20. package/dist/shared/components/WidgetSlot.js +474 -458
  21. package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
  22. package/dist/shared/components/ai/AskPanel.js +139 -119
  23. package/dist/shared/components/ai/FirstWeekCard.js +126 -0
  24. package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
  25. package/dist/shared/components/bulk/bulk-field-options.js +45 -0
  26. package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
  27. package/dist/shared/components/chat/ChannelArchive.js +326 -0
  28. package/dist/shared/components/chat/ChannelExtras.js +141 -121
  29. package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
  30. package/dist/shared/components/chat/ChatPanel.js +1695 -1733
  31. package/dist/shared/components/chat/Composer.js +357 -303
  32. package/dist/shared/components/chat/MessageActions.js +92 -0
  33. package/dist/shared/components/chat/MessageFormat.js +290 -264
  34. package/dist/shared/components/chat/OutboxBubbles.js +146 -0
  35. package/dist/shared/components/chat/RequestIdCard.js +135 -0
  36. package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
  37. package/dist/shared/components/chat/RoomParts.js +213 -274
  38. package/dist/shared/components/chat/ScreenClip.js +184 -0
  39. package/dist/shared/components/chat/chat-core.js +402 -483
  40. package/dist/shared/components/chat/chat-drafts.js +59 -0
  41. package/dist/shared/components/chat/chat-emoji.js +348 -0
  42. package/dist/shared/components/chat/chat-local-time.js +41 -0
  43. package/dist/shared/components/chat/chat-outbox.js +303 -0
  44. package/dist/shared/components/chat/chat-window.js +163 -0
  45. package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
  46. package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
  47. package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
  48. package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
  49. package/dist/shared/components/help-videos/api.js +80 -67
  50. package/dist/shared/components/help-videos/editor/DetailsTab.js +147 -130
  51. package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
  52. package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
  53. package/dist/shared/components/item-edit/FieldAffordances.js +9 -8
  54. package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
  55. package/dist/shared/components/item-edit/FieldRow.js +382 -320
  56. package/dist/shared/components/item-edit/FormHelpVideoButton.js +59 -0
  57. package/dist/shared/components/item-edit/GroupSection.js +786 -639
  58. package/dist/shared/components/item-edit/HeaderTools.js +59 -56
  59. package/dist/shared/components/item-edit/InlineTableField.js +3 -1
  60. package/dist/shared/components/item-edit/LayoutContentBlock.js +47 -24
  61. package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
  62. package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
  63. package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
  64. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
  65. package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
  66. package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
  67. package/dist/shared/components/item-edit/lazy-sections.js +36 -0
  68. package/dist/shared/components/item-edit/lock-why.js +94 -0
  69. package/dist/shared/components/item-edit/picker-miss.js +26 -0
  70. package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
  71. package/dist/shared/components/item-edit/useFormUsageBeacon.js +65 -0
  72. package/dist/shared/components/layout-editor/AddPanel.js +226 -151
  73. package/dist/shared/components/layout-editor/ArrangeButton.js +34 -0
  74. package/dist/shared/components/layout-editor/AutoArrange.js +86 -0
  75. package/dist/shared/components/layout-editor/CanvasCompare.js +79 -0
  76. package/dist/shared/components/layout-editor/ChangeNote.js +147 -0
  77. package/dist/shared/components/layout-editor/CollabParts.js +175 -0
  78. package/dist/shared/components/layout-editor/DesignNode.js +311 -116
  79. package/dist/shared/components/layout-editor/EditorCanvas.js +30 -26
  80. package/dist/shared/components/layout-editor/EditorTopBar.js +463 -175
  81. package/dist/shared/components/layout-editor/FindReplace.js +188 -0
  82. package/dist/shared/components/layout-editor/FormMapButton.js +141 -0
  83. package/dist/shared/components/layout-editor/HistoryPanel.js +250 -109
  84. package/dist/shared/components/layout-editor/LayoutEditor.js +1196 -305
  85. package/dist/shared/components/layout-editor/LayoutsRail.js +94 -67
  86. package/dist/shared/components/layout-editor/NoteMarker.js +38 -0
  87. package/dist/shared/components/layout-editor/PlacementsTable.js +187 -0
  88. package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
  89. package/dist/shared/components/layout-editor/ScheduleChange.js +106 -0
  90. package/dist/shared/components/layout-editor/SessionHistory.js +84 -0
  91. package/dist/shared/components/layout-editor/StagedChip.js +22 -0
  92. package/dist/shared/components/layout-editor/StructureMenu.js +464 -0
  93. package/dist/shared/components/layout-editor/UnsavedConfirm.js +103 -0
  94. package/dist/shared/components/layout-editor/ai/AiToolsButton.js +625 -0
  95. package/dist/shared/components/layout-editor/ai/ChangeCheck.js +153 -0
  96. package/dist/shared/components/layout-editor/ai/ai-tools-api.js +80 -0
  97. package/dist/shared/components/layout-editor/ai/assist-ops.js +38 -0
  98. package/dist/shared/components/layout-editor/ai/autofill-ops.js +73 -0
  99. package/dist/shared/components/layout-editor/ai/canvas-capture.js +41 -0
  100. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +271 -0
  101. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +182 -0
  102. package/dist/shared/components/layout-editor/ai-forms/MeaningSuggestions.js +109 -0
  103. package/dist/shared/components/layout-editor/ai-forms/SlimPanel.js +170 -0
  104. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +40 -0
  105. package/dist/shared/components/layout-editor/ai-forms/pending.js +25 -0
  106. package/dist/shared/components/layout-editor/ai-forms/plan.js +263 -0
  107. package/dist/shared/components/layout-editor/ai-rules/AiAskPopover.js +160 -0
  108. package/dist/shared/components/layout-editor/ai-rules/CascadeWriter.js +175 -0
  109. package/dist/shared/components/layout-editor/ai-rules/FieldRuleWriter.js +97 -0
  110. package/dist/shared/components/layout-editor/ai-rules/RuleWriter.js +94 -0
  111. package/dist/shared/components/layout-editor/ai-rules/ValidationSuggest.js +153 -0
  112. package/dist/shared/components/layout-editor/ai-rules/api.js +6 -0
  113. package/dist/shared/components/layout-editor/ai-text/AiTextTools.js +383 -0
  114. package/dist/shared/components/layout-editor/ai-text/text-ops.js +125 -0
  115. package/dist/shared/components/layout-editor/assist/AskPanel.js +278 -0
  116. package/dist/shared/components/layout-editor/assist/ExplainDiff.js +93 -0
  117. package/dist/shared/components/layout-editor/assist/ProposalsButton.js +150 -0
  118. package/dist/shared/components/layout-editor/assist/assist-api.js +63 -0
  119. package/dist/shared/components/layout-editor/assist/jump.js +142 -0
  120. package/dist/shared/components/layout-editor/assist/settings-index.js +118 -0
  121. package/dist/shared/components/layout-editor/auto-arrange.js +101 -0
  122. package/dist/shared/components/layout-editor/bulk/BulkChangesButton.js +221 -0
  123. package/dist/shared/components/layout-editor/bulk/BulkRun.js +237 -0
  124. package/dist/shared/components/layout-editor/bulk/MacrosPanel.js +230 -0
  125. package/dist/shared/components/layout-editor/bulk/bulk-api.js +65 -0
  126. package/dist/shared/components/layout-editor/bulk/field-labels.js +22 -0
  127. package/dist/shared/components/layout-editor/bulk/macro-record.js +142 -0
  128. package/dist/shared/components/layout-editor/bulk/useMacroRecorder.js +65 -0
  129. package/dist/shared/components/layout-editor/bundle-to-active.js +1 -0
  130. package/dist/shared/components/layout-editor/canvas-diff.js +157 -0
  131. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +388 -0
  132. package/dist/shared/components/layout-editor/collab/collab-api.js +80 -0
  133. package/dist/shared/components/layout-editor/commands/CommandPalette.js +221 -0
  134. package/dist/shared/components/layout-editor/commands/intents.js +214 -0
  135. package/dist/shared/components/layout-editor/commands/parse.js +242 -0
  136. package/dist/shared/components/layout-editor/design-context.js +26 -6
  137. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +181 -164
  138. package/dist/shared/components/layout-editor/dnd/collision.js +25 -23
  139. package/dist/shared/components/layout-editor/dnd/node.js +69 -57
  140. package/dist/shared/components/layout-editor/dnd/rail-drop.js +56 -0
  141. package/dist/shared/components/layout-editor/draft-recovery.js +131 -0
  142. package/dist/shared/components/layout-editor/editor-notes.js +78 -0
  143. package/dist/shared/components/layout-editor/editors/swap-config.js +1 -0
  144. package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
  145. package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
  146. package/dist/shared/components/layout-editor/entry/presets.js +71 -0
  147. package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
  148. package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
  149. package/dist/shared/components/layout-editor/explain/CanvasRules.js +142 -0
  150. package/dist/shared/components/layout-editor/explain/default-ghosts.js +81 -0
  151. package/dist/shared/components/layout-editor/explain/driver-hover.js +62 -0
  152. package/dist/shared/components/layout-editor/explain/field-sources.js +246 -0
  153. package/dist/shared/components/layout-editor/explain/rule-graph.js +215 -0
  154. package/dist/shared/components/layout-editor/explain/use-explain.js +132 -0
  155. package/dist/shared/components/layout-editor/field-zones.js +116 -0
  156. package/dist/shared/components/layout-editor/form-map.js +138 -0
  157. package/dist/shared/components/layout-editor/grid-guides.js +142 -0
  158. package/dist/shared/components/layout-editor/history-api.js +87 -0
  159. package/dist/shared/components/layout-editor/inheritance.js +55 -0
  160. package/dist/shared/components/layout-editor/inspect/inspect-api.js +66 -0
  161. package/dist/shared/components/layout-editor/inspect/picker-preview.js +48 -0
  162. package/dist/shared/components/layout-editor/inspect/width-fit.js +87 -0
  163. package/dist/shared/components/layout-editor/inspector/AiFillSetting.js +85 -0
  164. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
  165. package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +36 -0
  166. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +179 -0
  167. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +112 -0
  168. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +291 -141
  169. package/dist/shared/components/layout-editor/inspector/HelpTab.js +174 -0
  170. package/dist/shared/components/layout-editor/inspector/Inspector.js +282 -180
  171. package/dist/shared/components/layout-editor/inspector/LookTab.js +166 -109
  172. package/dist/shared/components/layout-editor/inspector/OverrideNotice.js +61 -0
  173. package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
  174. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +134 -0
  175. package/dist/shared/components/layout-editor/inspector/PickerTab.js +146 -118
  176. package/dist/shared/components/layout-editor/inspector/RulesTab.js +162 -111
  177. package/dist/shared/components/layout-editor/inspector/Translations.js +156 -0
  178. package/dist/shared/components/layout-editor/inspector/kit.js +71 -70
  179. package/dist/shared/components/layout-editor/inspector/tab-request.js +21 -0
  180. package/dist/shared/components/layout-editor/is-typing.js +9 -0
  181. package/dist/shared/components/layout-editor/keyboard-move.js +66 -0
  182. package/dist/shared/components/layout-editor/lint/LintPanel.js +190 -0
  183. package/dist/shared/components/layout-editor/lint/lint-api.js +52 -0
  184. package/dist/shared/components/layout-editor/load-error.js +37 -0
  185. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +305 -0
  186. package/dist/shared/components/layout-editor/matrix/MatrixGrid.js +181 -0
  187. package/dist/shared/components/layout-editor/matrix/RoleSectionMatrix.js +147 -0
  188. package/dist/shared/components/layout-editor/matrix/matrix-api.js +48 -0
  189. package/dist/shared/components/layout-editor/matrix/role-matrix.js +36 -0
  190. package/dist/shared/components/layout-editor/matrix/state-matrix.js +145 -0
  191. package/dist/shared/components/layout-editor/nav/FindPanel.js +109 -0
  192. package/dist/shared/components/layout-editor/nav/NavTools.js +114 -0
  193. package/dist/shared/components/layout-editor/nav/OutlinePanel.js +228 -0
  194. package/dist/shared/components/layout-editor/nav/ShortcutSheet.js +31 -0
  195. package/dist/shared/components/layout-editor/nav/find.js +20 -0
  196. package/dist/shared/components/layout-editor/nav/tree.js +142 -0
  197. package/dist/shared/components/layout-editor/nav/useEditorNav.js +101 -0
  198. package/dist/shared/components/layout-editor/nav/view-prefs.js +34 -0
  199. package/dist/shared/components/layout-editor/ops/ChangeRequestsPanel.js +143 -0
  200. package/dist/shared/components/layout-editor/ops/DependencyDiagram.js +179 -0
  201. package/dist/shared/components/layout-editor/ops/LayoutOpsBlocks.js +92 -0
  202. package/dist/shared/components/layout-editor/ops/PromotePanel.js +287 -0
  203. package/dist/shared/components/layout-editor/ops/ops-api.js +122 -0
  204. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
  205. package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
  206. package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
  207. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -3
  208. package/dist/shared/components/layout-editor/overview/describe-conditions.js +24 -14
  209. package/dist/shared/components/layout-editor/overview/overview-api.js +105 -88
  210. package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
  211. package/dist/shared/components/layout-editor/panel-style.js +8 -7
  212. package/dist/shared/components/layout-editor/parity-keys.json.js +4 -0
  213. package/dist/shared/components/layout-editor/pin.js +25 -0
  214. package/dist/shared/components/layout-editor/presence.js +111 -0
  215. package/dist/shared/components/layout-editor/preview/PreviewModes.js +224 -0
  216. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +262 -0
  217. package/dist/shared/components/layout-editor/preview/preview-api.js +57 -0
  218. package/dist/shared/components/layout-editor/preview/preview-model.js +157 -0
  219. package/dist/shared/components/layout-editor/restore-piece.js +192 -0
  220. package/dist/shared/components/layout-editor/reuse/FieldMapStep.js +70 -0
  221. package/dist/shared/components/layout-editor/reuse/FormMoreMenu.js +127 -0
  222. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +150 -0
  223. package/dist/shared/components/layout-editor/reuse/NewFormStart.js +20 -0
  224. package/dist/shared/components/layout-editor/reuse/SectionReuseActions.js +291 -0
  225. package/dist/shared/components/layout-editor/reuse/field-match.js +77 -0
  226. package/dist/shared/components/layout-editor/reuse/reuse-api.js +73 -0
  227. package/dist/shared/components/layout-editor/reuse/seed.js +13 -0
  228. package/dist/shared/components/layout-editor/reuse/useFormFromRecord.js +43 -0
  229. package/dist/shared/components/layout-editor/reuse/useRailCopy.js +34 -0
  230. package/dist/shared/components/layout-editor/section-structure.js +241 -0
  231. package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
  232. package/dist/shared/components/layout-editor/settings/FormSettings.js +125 -103
  233. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +1 -1
  234. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
  235. package/dist/shared/components/layout-editor/settings/ToolsSection.js +215 -105
  236. package/dist/shared/components/layout-editor/settings/WhoSection.js +139 -100
  237. package/dist/shared/components/layout-editor/settings/controls.js +8 -8
  238. package/dist/shared/components/layout-editor/settings/settings-registry.js +142 -21
  239. package/dist/shared/components/layout-editor/shortcuts.js +88 -0
  240. package/dist/shared/components/layout-editor/show-when.js +35 -0
  241. package/dist/shared/components/layout-editor/slot-names.js +4 -3
  242. package/dist/shared/components/layout-editor/staged-api.js +64 -0
  243. package/dist/shared/components/layout-editor/structure-ops.js +403 -0
  244. package/dist/shared/components/layout-editor/testing/CostLimitSetting.js +42 -0
  245. package/dist/shared/components/layout-editor/testing/TestingPanels.js +556 -0
  246. package/dist/shared/components/layout-editor/testing/testing-api.js +67 -0
  247. package/dist/shared/components/layout-editor/testing/testing-model.js +406 -0
  248. package/dist/shared/components/layout-editor/testing/use-record-check.js +44 -0
  249. package/dist/shared/components/layout-editor/toolbar-kit.js +242 -0
  250. package/dist/shared/components/layout-editor/unsaved-marks.js +72 -0
  251. package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
  252. package/dist/shared/components/layout-editor/usage/FillChip.js +27 -0
  253. package/dist/shared/components/layout-editor/usage/UsagePanel.js +232 -0
  254. package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
  255. package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
  256. package/dist/shared/components/layout-editor/usage/suggest-sections.js +55 -0
  257. package/dist/shared/components/layout-editor/usage/usage-api.js +104 -0
  258. package/dist/shared/components/layout-editor/useLayoutDraft.js +573 -306
  259. package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
  260. package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
  261. package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
  262. package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
  263. package/dist/shared/components/profile/AgentsPanel.js +479 -0
  264. package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
  265. package/dist/shared/components/support/SuggestFormChange.js +143 -0
  266. package/dist/shared/components/support/SupportAnalytics.js +171 -0
  267. package/dist/shared/components/support/SupportView.js +75 -73
  268. package/dist/shared/lib/ai-fill.js +37 -0
  269. package/dist/shared/lib/background-runs.js +150 -0
  270. package/dist/shared/lib/delivery-ack.js +9 -0
  271. package/dist/shared/lib/entry-badge-style.js +13 -0
  272. package/dist/shared/lib/entry-config.js +71 -0
  273. package/dist/shared/lib/form-sections.js +64 -0
  274. package/dist/shared/lib/form-structure.js +99 -0
  275. package/dist/shared/lib/form-usage-beacon.js +133 -0
  276. package/dist/shared/lib/jobs-tray.js +25 -23
  277. package/dist/shared/lib/keyset-pager.js +37 -0
  278. package/dist/shared/lib/layout-i18n.js +66 -0
  279. package/dist/shared/lib/layout-lint.js +490 -0
  280. package/dist/shared/lib/layout-ops.js +116 -110
  281. package/dist/shared/lib/layout-resolve.js +113 -0
  282. package/dist/shared/lib/placement-behaviour.js +144 -0
  283. package/dist/shared/lib/prefetch.js +149 -0
  284. package/dist/shared/lib/presence-hooks.js +199 -0
  285. package/dist/shared/lib/record-outbox.js +82 -81
  286. package/dist/shared/lib/replay-socket.js +93 -0
  287. package/dist/shared/lib/request-gate.js +51 -50
  288. package/dist/shared/lib/room-gaps.js +96 -0
  289. package/dist/shared/lib/screenshot.js +54 -28
  290. package/dist/shared/lib/search-log.js +27 -0
  291. package/dist/shared/lib/socket-realtime.js +101 -80
  292. package/dist/shared/lib/visible-when.js +34 -0
  293. package/dist/shared/lib/worker-socket.js +200 -0
  294. package/package.json +1 -1
@@ -1,23 +1,26 @@
1
- import { jsxs as o, jsx as n } from "react/jsx-runtime";
2
- import { useQueryClient as ye, useQueries as Pe, useQuery as z, useMutation as Ee } from "@tanstack/react-query";
3
- import { Info as Ae, Loader2 as De, Sparkles as Me, Lock as Oe, SlidersHorizontal as Ke, History as Ue, BellRing as We, Bell as Be, Sigma as ze } from "lucide-react";
4
- import { useState as ee, useRef as te, useEffect as be } from "react";
5
- import { toast as he } from "sonner";
6
- import { useParentDraft as Ge, useNivaroClient as G } from "../../context.js";
7
- import { get as j, del as Qe, post as ge } from "../../lib/commands.js";
8
- import { titleCase as fe, cn as q } from "../../lib/utils.js";
9
- import { GlossaryLabel as Ve } from "../ai/GlossaryText.js";
10
- import { Label as He } from "../ui/label.js";
11
- import { TooltipProvider as K, Tooltip as U, TooltipTrigger as W, TooltipContent as B } from "../ui/tooltip.js";
12
- import { useAddendumFields as Ye } from "./AddendumFieldContext.js";
13
- import { AutoIdPreviewField as Je } from "./AutoIdPreviewField.js";
14
- import { useFieldAffordances as Xe, useFieldContextMenu as Ze, usePresenceSoftLock as Ie, LockReasonBadge as et, PresenceSoftLockStrip as tt, RemoteChangeGhost as nt } from "./FieldAffordances.js";
15
- import { FieldRenderer as at } from "./FieldRenderer.js";
16
- import { getCascadeFilters as lt, SYSTEM_FIELDS as rt, parseJson as it, buildCascadeFilter as st, CascadeEffectController as ot } from "./helpers.js";
17
- import { isDerivedForRecord as dt } from "./live-rollups.js";
18
- import { useM2MStaging as ct } from "./M2MStagingContext.js";
19
- import { resolveOptionFilterTokens as ut } from "../../lib/option-filter-tokens.js";
20
- const mt = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger", "number"]), pt = /* @__PURE__ */ new Set(["string", "text", "richtext", "textarea", "markdown", "json", "csv"]), xt = /* @__PURE__ */ new Set([
1
+ import { jsxs as d, jsx as n } from "react/jsx-runtime";
2
+ import { useQueryClient as Ce, useQueries as We, useQuery as Z, useMutation as Ve } from "@tanstack/react-query";
3
+ import { Info as ze, Loader2 as Ge, Sparkles as Qe, Lock as Ye, SlidersHorizontal as Je, History as Xe, BellRing as Ze, Bell as Ie, Sigma as et } from "lucide-react";
4
+ import { useState as ce, useRef as ue, useEffect as Fe } from "react";
5
+ import { toast as K } from "sonner";
6
+ import { useParentDraft as tt, useNivaroClient as I } from "../../context.js";
7
+ import { showsAiButton as nt, AUTOFILL_CHECK_KEY as at, readAiFill as rt } from "../../lib/ai-fill.js";
8
+ import { get as O, del as lt, post as de } from "../../lib/commands.js";
9
+ import { titleCase as se, cn as P } from "../../lib/utils.js";
10
+ import { GlossaryLabel as Ne } from "../ai/GlossaryText.js";
11
+ import { Label as it } from "../ui/label.js";
12
+ import { TooltipProvider as Q, Tooltip as Y, TooltipTrigger as J, TooltipContent as X } from "../ui/tooltip.js";
13
+ import { useAddendumFields as ot } from "./AddendumFieldContext.js";
14
+ import { AutoIdPreviewField as st } from "./AutoIdPreviewField.js";
15
+ import { useFieldAffordances as dt, useFieldContextMenu as ct, usePresenceSoftLock as ut, LockReasonBadge as mt, PresenceSoftLockStrip as pt, RemoteChangeGhost as ht } from "./FieldAffordances.js";
16
+ import { FieldRenderer as xt } from "./FieldRenderer.js";
17
+ import { FormHelpVideoButton as ft } from "./FormHelpVideoButton.js";
18
+ import { getCascadeFilters as yt, SYSTEM_FIELDS as bt, parseJson as gt, buildCascadeFilter as vt, CascadeEffectController as wt } from "./helpers.js";
19
+ import { isDerivedForRecord as kt } from "./live-rollups.js";
20
+ import { useM2MStaging as _t } from "./M2MStagingContext.js";
21
+ import { usePlacementTextContext as Nt, placementFieldText as Ct, isDisplayFormulaRow as Ft, fieldCounterConfig as Lt, fieldIsRecommended as Rt, RecommendedMarker as $t, RepeatLastButton as St, DisplayFormulaValue as Tt, FieldCounter as qt } from "./placement-behaviour.js";
22
+ import { resolveOptionFilterTokens as jt } from "../../lib/option-filter-tokens.js";
23
+ const Pt = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger", "number"]), Et = /* @__PURE__ */ new Set(["string", "text", "richtext", "textarea", "markdown", "json", "csv"]), At = /* @__PURE__ */ new Set([
21
24
  "input",
22
25
  "textarea",
23
26
  "wysiwyg",
@@ -25,7 +28,7 @@ const mt = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
25
28
  "input-rich-text-html",
26
29
  "rich_text",
27
30
  "extension-editorjs"
28
- ]), ht = /* @__PURE__ */ new Set([
31
+ ]), Dt = /* @__PURE__ */ new Set([
29
32
  "relation-m2o",
30
33
  "relation-m2m",
31
34
  "select-multiple-m2m",
@@ -36,92 +39,92 @@ const mt = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
36
39
  "file",
37
40
  "files",
38
41
  "image"
39
- ]), ft = /* @__PURE__ */ new Set(["file", "file-image", "files-m2m", "files", "image"]);
40
- function yt(e) {
41
- const s = e.interface ?? "";
42
- return ht.has(s) || s.startsWith("relation-") || s.endsWith("-m2o") || s.endsWith("-m2m") ? !1 : !!(pt.has(e.type ?? "") || xt.has(s) || !s && e.type && !mt.has(e.type));
42
+ ]), Mt = /* @__PURE__ */ new Set(["file", "file-image", "files-m2m", "files", "image"]);
43
+ function Kt(e) {
44
+ const o = e.interface ?? "";
45
+ return Dt.has(o) || o.startsWith("relation-") || o.endsWith("-m2o") || o.endsWith("-m2m") ? !1 : !!(Et.has(e.type ?? "") || At.has(o) || !o && e.type && !Pt.has(e.type));
43
46
  }
44
- function bt(e, s, h, c) {
45
- const u = G();
46
- return z({
47
- queryKey: ["field-lineage", e, s, h],
48
- queryFn: () => u.request(
49
- j(`/lineage/${e}/${encodeURIComponent(s)}/${h}`)
47
+ function Ot(e, o, f, p) {
48
+ const c = I();
49
+ return Z({
50
+ queryKey: ["field-lineage", e, o, f],
51
+ queryFn: () => c.request(
52
+ O(`/lineage/${e}/${encodeURIComponent(o)}/${f}`)
50
53
  ).then((i) => i.data),
51
- enabled: c,
54
+ enabled: p,
52
55
  staleTime: 3e4
53
56
  });
54
57
  }
55
- function Ut(e, s = "rows") {
56
- var d, w, m;
58
+ function pn(e, o = "rows") {
59
+ var u, _, m;
57
60
  if (e && (e.kind === "write" || e.kind === "read") && e.formula) {
58
- const g = (f) => typeof f == "number" ? f.toLocaleString(void 0, { maximumFractionDigits: 2 }) : f == null || f === "" ? "∅" : String(f);
59
- return `= ${e.formula.replace(/item\.([A-Za-z_][A-Za-z0-9_]*)/g, (f, a) => {
60
- var p;
61
- return g((p = e.inputs) == null ? void 0 : p[a]);
61
+ const v = (y) => typeof y == "number" ? y.toLocaleString(void 0, { maximumFractionDigits: 2 }) : y == null || y === "" ? "∅" : String(y);
62
+ return `= ${e.formula.replace(/item\.([A-Za-z_][A-Za-z0-9_]*)/g, (y, a) => {
63
+ var h;
64
+ return v((h = e.inputs) == null ? void 0 : h[a]);
62
65
  }).replace(/\s*-\s*/g, " − ").replace(/\s*\*\s*/g, " × ").replace(/\s*\/\s*/g, " ÷ ")}`;
63
66
  }
64
67
  if (!e || e.kind !== "rollup") return null;
65
- const h = (e.sources ?? []).reduce((g, l) => g + l.rows.length, 0), c = (e.sources ?? []).reduce((g, l) => {
66
- var f;
67
- return g + (((f = l.excluded) == null ? void 0 : f.length) ?? 0);
68
- }, 0), u = (m = (w = (d = (e.sources ?? []).find((g) => {
68
+ const f = (e.sources ?? []).reduce((v, l) => v + l.rows.length, 0), p = (e.sources ?? []).reduce((v, l) => {
69
+ var y;
70
+ return v + (((y = l.excluded) == null ? void 0 : y.length) ?? 0);
71
+ }, 0), c = (m = (_ = (u = (e.sources ?? []).find((v) => {
69
72
  var l;
70
- return (l = g.excluded) == null ? void 0 : l.length;
71
- })) == null ? void 0 : d.excluded) == null ? void 0 : w[0]) == null ? void 0 : m.reason, i = [`= ${h} ${h === 1 ? s.replace(/s$/, "") : s}`];
72
- return c && i.push(
73
- `${c} excluded${u ? ` (${u.replace(/^does not match: /, "")})` : ""}`
73
+ return (l = v.excluded) == null ? void 0 : l.length;
74
+ })) == null ? void 0 : u.excluded) == null ? void 0 : _[0]) == null ? void 0 : m.reason, i = [`= ${f} ${f === 1 ? o.replace(/s$/, "") : o}`];
75
+ return p && i.push(
76
+ `${p} excluded${c ? ` (${c.replace(/^does not match: /, "")})` : ""}`
74
77
  ), i.join(" · ");
75
78
  }
76
- function gt({
79
+ function Ut({
77
80
  collection: e,
78
- itemId: s,
79
- field: h
81
+ itemId: o,
82
+ field: f
80
83
  }) {
81
- const [c, u] = ee(!1), i = te(null), { data: d, isLoading: w } = bt(e, s, h, c);
82
- be(() => {
83
- if (!c) return;
84
- const l = (f) => {
84
+ const [p, c] = ce(!1), i = ue(null), { data: u, isLoading: _ } = Ot(e, o, f, p);
85
+ Fe(() => {
86
+ if (!p) return;
87
+ const l = (y) => {
85
88
  var a;
86
- (a = i.current) != null && a.contains(f.target) || u(!1);
89
+ (a = i.current) != null && a.contains(y.target) || c(!1);
87
90
  };
88
91
  return window.addEventListener("mousedown", l), () => window.removeEventListener("mousedown", l);
89
- }, [c]);
90
- const m = (l) => l == null ? "—" : Number(l).toLocaleString(void 0, { maximumFractionDigits: 2 }), g = (d == null ? void 0 : d.stored_value) != null ? Number(d.stored_value) : null;
91
- return /* @__PURE__ */ o("div", { ref: i, className: "relative inline-flex", children: [
92
+ }, [p]);
93
+ const m = (l) => l == null ? "—" : Number(l).toLocaleString(void 0, { maximumFractionDigits: 2 }), v = (u == null ? void 0 : u.stored_value) != null ? Number(u.stored_value) : null;
94
+ return /* @__PURE__ */ d("div", { ref: i, className: "relative inline-flex", children: [
92
95
  /* @__PURE__ */ n(
93
96
  "button",
94
97
  {
95
98
  type: "button",
96
- onClick: () => u((l) => !l),
99
+ onClick: () => c((l) => !l),
97
100
  title: "Where does this number come from?",
98
- className: q(
101
+ className: P(
99
102
  "inline-flex items-center rounded p-0.5 transition-opacity",
100
- c ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
103
+ p ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
101
104
  ),
102
105
  "data-field-lineage": !0,
103
- children: /* @__PURE__ */ n(ze, { className: "h-3 w-3" })
106
+ children: /* @__PURE__ */ n(et, { className: "h-3 w-3" })
104
107
  }
105
108
  ),
106
- c && /* @__PURE__ */ o("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-[340px] w-[360px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
109
+ p && /* @__PURE__ */ d("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-[340px] w-[360px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
107
110
  /* @__PURE__ */ n("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Where this number comes from" }),
108
- w && /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }),
109
- (d == null ? void 0 : d.kind) === "write" && /* @__PURE__ */ o("div", { className: "space-y-1 px-1 py-1", children: [
110
- /* @__PURE__ */ n("p", { className: "font-mono text-[11px] text-slate-600 dark:text-slate-300", children: d.formula }),
111
- Object.entries(d.inputs ?? {}).map(([l, f]) => /* @__PURE__ */ o("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
111
+ _ && /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }),
112
+ (u == null ? void 0 : u.kind) === "write" && /* @__PURE__ */ d("div", { className: "space-y-1 px-1 py-1", children: [
113
+ /* @__PURE__ */ n("p", { className: "font-mono text-[11px] text-slate-600 dark:text-slate-300", children: u.formula }),
114
+ Object.entries(u.inputs ?? {}).map(([l, y]) => /* @__PURE__ */ d("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
112
115
  /* @__PURE__ */ n("span", { className: "font-mono", children: l }),
113
116
  " = ",
114
- m(f)
117
+ m(y)
115
118
  ] }, l)),
116
- /* @__PURE__ */ o("p", { className: "pt-1 text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: [
119
+ /* @__PURE__ */ d("p", { className: "pt-1 text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: [
117
120
  "= ",
118
- m(d.stored_value)
121
+ m(u.stored_value)
119
122
  ] })
120
123
  ] }),
121
- (d == null ? void 0 : d.kind) === "rollup" && (d.sources ?? []).map((l, f) => {
124
+ (u == null ? void 0 : u.kind) === "rollup" && (u.sources ?? []).map((l, y) => {
122
125
  var a;
123
- return /* @__PURE__ */ o("div", { className: "mb-1.5", children: [
124
- /* @__PURE__ */ o("p", { className: "px-1 text-[10.5px] text-slate-400", children: [
126
+ return /* @__PURE__ */ d("div", { className: "mb-1.5", children: [
127
+ /* @__PURE__ */ d("p", { className: "px-1 text-[10.5px] text-slate-400", children: [
125
128
  (l.aggregate ?? "sum").toUpperCase(),
126
129
  l.value_field ? ` of ${l.value_field}` : "",
127
130
  " across ",
@@ -130,126 +133,126 @@ function gt({
130
133
  ] }),
131
134
  l.error && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-amber-600 dark:text-amber-400", children: l.error }),
132
135
  l.note && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-slate-400", children: l.note }),
133
- l.rows.length > 0 && /* @__PURE__ */ n("div", { className: "mt-0.5 space-y-px", children: l.rows.map((p) => /* @__PURE__ */ o(
136
+ l.rows.length > 0 && /* @__PURE__ */ n("div", { className: "mt-0.5 space-y-px", children: l.rows.map((h) => /* @__PURE__ */ d(
134
137
  "div",
135
138
  {
136
139
  className: "flex items-baseline gap-2 rounded px-1 py-0.5 text-[11.5px] hover:bg-slate-50 dark:hover:bg-muted",
137
140
  children: [
138
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: p.label }),
139
- /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums text-slate-800 dark:text-slate-100", children: m(p.value) }),
141
+ /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: h.label }),
142
+ /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums text-slate-800 dark:text-slate-100", children: m(h.value) }),
140
143
  /* @__PURE__ */ n(
141
144
  "span",
142
145
  {
143
146
  className: "w-[88px] shrink-0 truncate text-right text-[10px] text-slate-400",
144
- "data-tip": p.updated_at ? `${p.updated_by ?? "unknown"} · ${new Date(p.updated_at).toLocaleString()}` : void 0,
145
- children: p.updated_by ?? ""
147
+ "data-tip": h.updated_at ? `${h.updated_by ?? "unknown"} · ${new Date(h.updated_at).toLocaleString()}` : void 0,
148
+ children: h.updated_by ?? ""
146
149
  }
147
150
  )
148
151
  ]
149
152
  },
150
- p.id
153
+ h.id
151
154
  )) }),
152
155
  l.truncated && /* @__PURE__ */ n("p", { className: "px-1 pt-0.5 text-[10.5px] text-amber-600 dark:text-amber-400", children: "Showing the first 200 rows — the subtotal covers only these." }),
153
- l.subtotal != null && /* @__PURE__ */ o("p", { className: "border-t border-slate-100 px-1 pt-1 text-right text-[11.5px] font-medium text-slate-700 dark:border-border dark:text-slate-200", children: [
156
+ l.subtotal != null && /* @__PURE__ */ d("p", { className: "border-t border-slate-100 px-1 pt-1 text-right text-[11.5px] font-medium text-slate-700 dark:border-border dark:text-slate-200", children: [
154
157
  "subtotal ",
155
158
  m(l.subtotal)
156
159
  ] }),
157
- (((a = l.excluded) == null ? void 0 : a.length) ?? 0) > 0 && /* @__PURE__ */ o("div", { className: "mt-1 rounded bg-slate-50 px-1 py-1 dark:bg-muted/40", children: [
158
- /* @__PURE__ */ o("p", { className: "text-[10.5px] text-slate-500 dark:text-muted-foreground", children: [
160
+ (((a = l.excluded) == null ? void 0 : a.length) ?? 0) > 0 && /* @__PURE__ */ d("div", { className: "mt-1 rounded bg-slate-50 px-1 py-1 dark:bg-muted/40", children: [
161
+ /* @__PURE__ */ d("p", { className: "text-[10.5px] text-slate-500 dark:text-muted-foreground", children: [
159
162
  l.excluded.length,
160
163
  " excluded —",
161
164
  " ",
162
165
  l.excluded[0].reason.replace(/^does not match: /, "")
163
166
  ] }),
164
- l.excluded.slice(0, 8).map((p) => /* @__PURE__ */ o(
167
+ l.excluded.slice(0, 8).map((h) => /* @__PURE__ */ d(
165
168
  "div",
166
169
  {
167
170
  className: "flex items-baseline gap-2 px-0.5 text-[11px] text-slate-400",
168
171
  children: [
169
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate line-through decoration-slate-300", children: p.label }),
170
- /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums", children: m(p.value) })
172
+ /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate line-through decoration-slate-300", children: h.label }),
173
+ /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums", children: m(h.value) })
171
174
  ]
172
175
  },
173
- p.id
176
+ h.id
174
177
  )),
175
- l.excluded.length > 8 && /* @__PURE__ */ o("p", { className: "px-0.5 text-[10.5px] text-slate-400", children: [
178
+ l.excluded.length > 8 && /* @__PURE__ */ d("p", { className: "px-0.5 text-[10.5px] text-slate-400", children: [
176
179
  "+",
177
180
  l.excluded.length - 8,
178
181
  " more"
179
182
  ] })
180
183
  ] })
181
- ] }, f);
184
+ ] }, y);
182
185
  }),
183
- (d == null ? void 0 : d.kind) === "rollup" && g != null && /* @__PURE__ */ o("p", { className: "px-1 pt-0.5 text-right text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
186
+ (u == null ? void 0 : u.kind) === "rollup" && v != null && /* @__PURE__ */ d("p", { className: "px-1 pt-0.5 text-right text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
184
187
  "stored ",
185
- m(g),
188
+ m(v),
186
189
  (() => {
187
- const l = (d.sources ?? []).reduce((a, p) => a + (p.subtotal ?? 0), 0);
188
- return (d.sources ?? []).some((a) => a.truncated) ? null : Math.abs(l - g) < 0.01 ? /* @__PURE__ */ n("span", { className: "ml-1 text-emerald-600 dark:text-emerald-400", children: "✓ matches" }) : /* @__PURE__ */ n("span", { className: "ml-1 text-amber-600 dark:text-amber-400", children: "✕ differs from contributions" });
190
+ const l = (u.sources ?? []).reduce((a, h) => a + (h.subtotal ?? 0), 0);
191
+ return (u.sources ?? []).some((a) => a.truncated) ? null : Math.abs(l - v) < 0.01 ? /* @__PURE__ */ n("span", { className: "ml-1 text-emerald-600 dark:text-emerald-400", children: "✓ matches" }) : /* @__PURE__ */ n("span", { className: "ml-1 text-amber-600 dark:text-amber-400", children: "✕ differs from contributions" });
189
192
  })()
190
193
  ] })
191
194
  ] })
192
195
  ] });
193
196
  }
194
- function vt({
197
+ function Bt({
195
198
  collection: e,
196
- itemId: s,
197
- field: h,
198
- formatValue: c,
199
- onRestore: u
199
+ itemId: o,
200
+ field: f,
201
+ formatValue: p,
202
+ onRestore: c
200
203
  }) {
201
- const i = G(), [d, w] = ee(!1), m = te(null), { data: g, isLoading: l } = z({
202
- queryKey: ["field-value-history", e, s, h],
203
- queryFn: () => i.request(j(`/field-history/${e}/${encodeURIComponent(s)}/${h}`)).then((a) => a.data ?? []),
204
- enabled: d,
204
+ const i = I(), [u, _] = ce(!1), m = ue(null), { data: v, isLoading: l } = Z({
205
+ queryKey: ["field-value-history", e, o, f],
206
+ queryFn: () => i.request(O(`/field-history/${e}/${encodeURIComponent(o)}/${f}`)).then((a) => a.data ?? []),
207
+ enabled: u,
205
208
  staleTime: 6e4
206
209
  });
207
- be(() => {
208
- if (!d) return;
209
- const a = (p) => {
210
- var P;
211
- (P = m.current) != null && P.contains(p.target) || w(!1);
210
+ Fe(() => {
211
+ if (!u) return;
212
+ const a = (h) => {
213
+ var U;
214
+ (U = m.current) != null && U.contains(h.target) || _(!1);
212
215
  };
213
216
  return window.addEventListener("mousedown", a), () => window.removeEventListener("mousedown", a);
214
- }, [d]);
215
- const f = (a, p) => p || (a == null || a === "" ? "—" : c ? c(a) : typeof a == "boolean" || a === "true" || a === "false" ? a === !0 || a === "true" ? "Yes" : "No" : typeof a == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(a) ? new Date(a).toLocaleString() : typeof a == "object" ? JSON.stringify(a).slice(0, 60) : String(a).slice(0, 80));
216
- return /* @__PURE__ */ o("div", { ref: m, className: "relative inline-flex", children: [
217
+ }, [u]);
218
+ const y = (a, h) => h || (a == null || a === "" ? "—" : p ? p(a) : typeof a == "boolean" || a === "true" || a === "false" ? a === !0 || a === "true" ? "Yes" : "No" : typeof a == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(a) ? new Date(a).toLocaleString() : typeof a == "object" ? JSON.stringify(a).slice(0, 60) : String(a).slice(0, 80));
219
+ return /* @__PURE__ */ d("div", { ref: m, className: "relative inline-flex", children: [
217
220
  /* @__PURE__ */ n(
218
221
  "button",
219
222
  {
220
223
  type: "button",
221
- onClick: () => w((a) => !a),
224
+ onClick: () => _((a) => !a),
222
225
  title: "Value history",
223
- className: q(
226
+ className: P(
224
227
  "inline-flex items-center rounded p-0.5 transition-opacity",
225
- d ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
228
+ u ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
226
229
  ),
227
230
  "data-field-history": !0,
228
- children: /* @__PURE__ */ n(Ue, { className: "h-3 w-3" })
231
+ children: /* @__PURE__ */ n(Xe, { className: "h-3 w-3" })
229
232
  }
230
233
  ),
231
- d && /* @__PURE__ */ o("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-64 w-[300px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
234
+ u && /* @__PURE__ */ d("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-64 w-[300px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
232
235
  /* @__PURE__ */ n("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Value history" }),
233
- l ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }) : (g ?? []).length === 0 ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "No recorded changes for this field." }) : /* @__PURE__ */ n("div", { className: "space-y-1", children: (g ?? []).map((a, p) => /* @__PURE__ */ o(
236
+ l ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }) : (v ?? []).length === 0 ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "No recorded changes for this field." }) : /* @__PURE__ */ n("div", { className: "space-y-1", children: (v ?? []).map((a, h) => /* @__PURE__ */ d(
234
237
  "div",
235
238
  {
236
239
  className: "rounded px-1 py-1 text-[11.5px] leading-snug hover:bg-slate-50 dark:hover:bg-muted",
237
240
  children: [
238
- /* @__PURE__ */ o("span", { className: "flex items-baseline justify-between gap-2", children: [
239
- /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: f(a.value, a.display) }),
240
- u && p > 0 && /* @__PURE__ */ n(
241
+ /* @__PURE__ */ d("span", { className: "flex items-baseline justify-between gap-2", children: [
242
+ /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: y(a.value, a.display) }),
243
+ c && h > 0 && /* @__PURE__ */ n(
241
244
  "button",
242
245
  {
243
246
  type: "button",
244
247
  onClick: () => {
245
- u(a.value ?? null), w(!1);
248
+ c(a.value ?? null), _(!1);
246
249
  },
247
250
  className: "shrink-0 rounded border border-slate-200 px-1.5 py-px text-[10px] text-slate-500 hover:border-nvr-cyan/60 hover:text-nvr-navy dark:border-border dark:hover:text-nvr-cyan",
248
251
  children: "Restore"
249
252
  }
250
253
  )
251
254
  ] }),
252
- /* @__PURE__ */ o("span", { className: "block text-[10.5px] text-slate-400", children: [
255
+ /* @__PURE__ */ d("span", { className: "block text-[10.5px] text-slate-400", children: [
253
256
  a.action === "create" ? "initial value" : "changed",
254
257
  a.timestamp ? ` · ${new Date(a.timestamp).toLocaleString()}` : "",
255
258
  a.user_name ? ` · ${a.user_name}` : "",
@@ -261,121 +264,145 @@ function vt({
261
264
  }
262
265
  )
263
266
  ] }),
264
- a.note && /* @__PURE__ */ o("span", { className: "block text-[10.5px] italic text-slate-500 dark:text-slate-400", children: [
267
+ a.note && /* @__PURE__ */ d("span", { className: "block text-[10.5px] italic text-slate-500 dark:text-slate-400", children: [
265
268
  "“",
266
269
  a.note,
267
270
  "”"
268
271
  ] })
269
272
  ]
270
273
  },
271
- p
274
+ h
272
275
  )) })
273
276
  ] })
274
277
  ] });
275
278
  }
276
- function wt({
279
+ function Ht({
277
280
  collection: e,
278
- itemId: s,
279
- field: h
281
+ itemId: o,
282
+ field: f
280
283
  }) {
281
- const c = G(), u = ye(), { data: i } = z({
284
+ const p = I(), c = Ce(), { data: i } = Z({
282
285
  queryKey: ["field-watch-config"],
283
- queryFn: () => c.request(j("/field-watches/config")).then((l) => l.data).catch(() => ({ enabled: !1 })),
286
+ queryFn: () => p.request(O("/field-watches/config")).then((l) => l.data).catch(() => ({ enabled: !1 })),
284
287
  staleTime: 5 * 6e4
285
- }), d = ["field-watch-self", e, s], { data: w = [] } = z({
286
- queryKey: d,
287
- queryFn: () => c.request(j("/field-watches/self", { collection: e, item_id: s })).then((l) => l.data ?? []).catch(() => []),
288
+ }), u = ["field-watch-self", e, o], { data: _ = [] } = Z({
289
+ queryKey: u,
290
+ queryFn: () => p.request(O("/field-watches/self", { collection: e, item_id: o })).then((l) => l.data ?? []).catch(() => []),
288
291
  enabled: !!(i != null && i.enabled),
289
292
  staleTime: 6e4
290
- }), m = w.includes(h), g = Ee({
291
- mutationFn: () => m ? c.request(
292
- Qe(
293
- `/field-watches/self?collection=${encodeURIComponent(e)}&field=${encodeURIComponent(h)}&item_id=${encodeURIComponent(s)}`
293
+ }), m = _.includes(f), v = Ve({
294
+ mutationFn: () => m ? p.request(
295
+ lt(
296
+ `/field-watches/self?collection=${encodeURIComponent(e)}&field=${encodeURIComponent(f)}&item_id=${encodeURIComponent(o)}`
294
297
  )
295
- ) : c.request(ge("/field-watches/self", { collection: e, field: h, item_id: s })),
298
+ ) : p.request(de("/field-watches/self", { collection: e, field: f, item_id: o })),
296
299
  onSuccess: () => {
297
- u.invalidateQueries({ queryKey: d }), he.success(
300
+ c.invalidateQueries({ queryKey: u }), K.success(
298
301
  m ? "No longer watching this field" : "Watching — you will be notified when it changes"
299
302
  );
300
303
  },
301
- onError: () => he.error("Could not update the watch")
304
+ onError: () => K.error("Could not update the watch")
302
305
  });
303
306
  return i != null && i.enabled ? /* @__PURE__ */ n(
304
307
  "button",
305
308
  {
306
309
  type: "button",
307
- onClick: () => g.mutate(),
310
+ onClick: () => v.mutate(),
308
311
  title: m ? "Stop watching this field on this record" : "Watch this field on this record",
309
- "data-field-watch": h,
312
+ "data-field-watch": f,
310
313
  className: `rounded p-0.5 transition-colors ${m ? "text-nvr-navy dark:text-nvr-cyan" : "text-slate-300 hover:text-slate-500"}`,
311
- children: m ? /* @__PURE__ */ n(We, { className: "h-3 w-3" }) : /* @__PURE__ */ n(Be, { className: "h-3 w-3" })
314
+ children: m ? /* @__PURE__ */ n(Ze, { className: "h-3 w-3" }) : /* @__PURE__ */ n(Ie, { className: "h-3 w-3" })
312
315
  }
313
316
  ) : null;
314
317
  }
315
- function Wt({
318
+ function hn({
316
319
  field: e,
317
- draft: s,
318
- onChange: h,
319
- relations: c,
320
- collection: u,
320
+ draft: o,
321
+ onChange: f,
322
+ relations: p,
323
+ collection: c,
321
324
  itemId: i,
322
- error: d,
323
- visible: w,
325
+ error: u,
326
+ visible: _,
324
327
  locked: m,
325
- layoutAiEnabled: g,
328
+ layoutAiEnabled: v,
326
329
  renderField: l,
327
- onCountChange: f,
330
+ onCountChange: y,
328
331
  swapButton: a,
329
- swapContent: p,
330
- forceVisible: P,
331
- autoFillTick: ne
332
+ swapContent: h,
333
+ forceVisible: U,
334
+ autoFillTick: me
332
335
  }) {
333
- var me, pe;
334
- const Q = ft.has(e.interface ?? ""), k = Ge(), b = ct(), ae = ye(), le = G(), [re, ie] = ee(!1), y = Xe(), V = te(null), {
335
- onContextMenu: ve,
336
- onKeyDown: we,
337
- menu: ke
338
- } = Ze({
339
- wrapperRef: V,
336
+ var we, ke, _e;
337
+ const ee = Mt.has(e.interface ?? ""), F = tt(), b = _t(), pe = Ce(), te = I(), [he, B] = ce(!1), s = dt(), ne = ue(null), {
338
+ onContextMenu: Le,
339
+ onKeyDown: Re,
340
+ menu: $e
341
+ } = ct({
342
+ wrapperRef: ne,
340
343
  field: e,
341
- value: s[e.field],
342
- relations: c,
343
- collection: u,
344
+ value: o[e.field],
345
+ relations: p,
346
+ collection: c,
344
347
  itemId: i,
345
- openRelated: y == null ? void 0 : y.openRelated
346
- }), L = Ie(V), se = y == null ? void 0 : y.remoteChanges[e.field], E = y == null ? void 0 : y.lockReasons[e.field], F = y == null ? void 0 : y.applyToLines[e.field];
347
- async function Ne() {
348
+ openRelated: s == null ? void 0 : s.openRelated
349
+ }), $ = ut(ne), Se = Nt(), xe = s == null ? void 0 : s.remoteChanges[e.field], E = s == null ? void 0 : s.lockReasons[e.field], L = s == null ? void 0 : s.applyToLines[e.field], H = nt(e._overrides, v, Kt(e)), ae = !!(s != null && s.fromAutofill) && !!e._overrides && e._overrides[at] === !0;
350
+ async function Te() {
348
351
  var t;
349
- ie(!0);
352
+ if (H.perField) return qe();
353
+ B(!0);
350
354
  try {
351
- const r = await le.request(
352
- ge("/ai/generate", {
353
- collection: u,
355
+ const r = await te.request(
356
+ de("/ai/generate", {
357
+ collection: c,
354
358
  item_id: i !== "new" ? i : void 0,
355
359
  field: e.field
356
360
  })
357
361
  );
358
- ((t = r.data) == null ? void 0 : t.value) != null && h(e.field, r.data.value);
362
+ ((t = r.data) == null ? void 0 : t.value) != null && f(e.field, r.data.value);
359
363
  } catch {
360
364
  } finally {
361
- ie(!1);
365
+ B(!1);
362
366
  }
363
367
  }
364
- const R = lt(e.dependency_config), oe = R.flatMap((t) => {
365
- const r = c.find(
366
- (N) => N.one_collection === u && N.one_field === t.parent_field
368
+ async function qe() {
369
+ var r, x, N, j, R, C;
370
+ const t = {};
371
+ for (const g of ((r = rt(e._overrides)) == null ? void 0 : r.tokens) ?? []) g in o && (t[g] = o[g]);
372
+ B(!0);
373
+ try {
374
+ const g = await te.request(
375
+ de("/ai/field-fill", {
376
+ collection: c,
377
+ layout_id: (s == null ? void 0 : s.layoutId) ?? null,
378
+ field: e.field,
379
+ item_id: i && i !== "new" ? i : null,
380
+ values: t
381
+ })
382
+ ), k = (x = g.data) == null ? void 0 : x.value;
383
+ typeof k == "string" && k !== "" ? f(e.field, k) : K.info("The AI had nothing to write here"), (j = (N = g.data) == null ? void 0 : N.missing) != null && j.length && K.info(`Filled without ${g.data.missing.join(", ")} (empty or not visible to you)`);
384
+ } catch (g) {
385
+ const k = g;
386
+ K.error(((C = (R = k == null ? void 0 : k.response) == null ? void 0 : R.data) == null ? void 0 : C.error) ?? (k == null ? void 0 : k.message) ?? "AI fill failed");
387
+ } finally {
388
+ B(!1);
389
+ }
390
+ }
391
+ const S = yt(e.dependency_config), fe = S.flatMap((t) => {
392
+ const r = p.find(
393
+ (N) => N.one_collection === c && N.one_field === t.parent_field
367
394
  );
368
395
  if (!r) return [];
369
396
  if (r.junction_field) return [{ rule: t, rel: r }];
370
- const x = c.find(
397
+ const x = p.find(
371
398
  (N) => N.many_collection === r.many_collection && N.id !== r.id
372
399
  );
373
400
  return x != null && x.many_field ? [{ rule: t, rel: { ...r, junction_field: x.many_field } }] : [];
374
- }), _e = Pe({
375
- queries: oe.map(({ rel: t }) => ({
401
+ }), je = We({
402
+ queries: fe.map(({ rel: t }) => ({
376
403
  queryKey: ["m2m-items", t.many_collection, t.many_field, i],
377
- queryFn: () => le.request(
378
- j(`/items/${t.many_collection}`, {
404
+ queryFn: () => te.request(
405
+ O(`/items/${t.many_collection}`, {
379
406
  filter: JSON.stringify({ [t.many_field]: { _eq: i } }),
380
407
  limit: 200,
381
408
  fields: `id,${t.junction_field}`
@@ -384,40 +411,40 @@ function Wt({
384
411
  enabled: !!i && i !== "new",
385
412
  staleTime: 3e4
386
413
  }))
387
- }), Ce = Object.fromEntries(
388
- oe.map(({ rule: t, rel: r }, x) => {
389
- var O;
390
- const N = r.one_field ?? `${r.many_collection}.${r.junction_field}`, I = (b == null ? void 0 : b.getStagedUnlinks(N)) ?? /* @__PURE__ */ new Set();
414
+ }), Pe = Object.fromEntries(
415
+ fe.map(({ rule: t, rel: r }, x) => {
416
+ var R;
417
+ const N = r.one_field ?? `${r.many_collection}.${r.junction_field}`, j = (b == null ? void 0 : b.getStagedUnlinks(N)) ?? /* @__PURE__ */ new Set();
391
418
  return [
392
419
  t.parent_field,
393
- (((O = _e[x]) == null ? void 0 : O.data) ?? []).filter((C) => !I.has(C.id)).map((C) => C[r.junction_field])
420
+ (((R = je[x]) == null ? void 0 : R.data) ?? []).filter((C) => !j.has(C.id)).map((C) => C[r.junction_field])
394
421
  ];
395
422
  })
396
- ), A = Ye()[e.field] ?? [];
397
- if (!P && (!w || !e.layout_assigned && (e.hidden || rt.has(e.field))))
423
+ ), W = ot()[e.field] ?? [];
424
+ if (!U && (!_ || !e.layout_assigned && (e.hidden || bt.has(e.field))))
398
425
  return null;
399
- const H = s[e.field] ?? null, Y = e.label ?? fe(e.field), Fe = dt(e, s), Le = (pe = (me = it(e.options)) == null ? void 0 : me.auto_id) == null ? void 0 : pe.pattern, v = (() => {
400
- const t = c.find(
401
- (x) => x.one_collection === u && x.one_field === e.field
426
+ const re = o[e.field] ?? null, V = Ct(e, Se), A = V.label ?? se(e.field), T = Ft(e), ye = T ? null : Lt(e), Ee = !T && !m && !e.readonly && ((we = e._overrides) == null ? void 0 : we.repeat_last) === !0, Ae = kt(e, o), De = (_e = (ke = gt(e.options)) == null ? void 0 : ke.auto_id) == null ? void 0 : _e.pattern, w = (() => {
427
+ const t = p.find(
428
+ (x) => x.one_collection === c && x.one_field === e.field
402
429
  );
403
430
  if (!t) return null;
404
431
  if (t.junction_field) return t;
405
- const r = c.find(
432
+ const r = p.find(
406
433
  (x) => x.many_collection === t.many_collection && x.id !== t.id
407
434
  );
408
435
  return r ? { ...t, junction_field: r.many_field } : null;
409
- })(), J = v ? null : c.find((t) => t.many_collection === u && t.many_field === e.field) ?? null, X = v ? c.find(
410
- (t) => t.many_collection === v.many_collection && t.many_field === v.junction_field && t.id !== v.id
411
- ) ?? null : null, $ = v ? v.one_field ?? `${v.many_collection}.${v.junction_field}` : null, de = $ ? (b == null ? void 0 : b.getStagedLinks($)) ?? [] : [], Re = v ? (ae.getQueryData([
436
+ })(), le = w ? null : p.find((t) => t.many_collection === c && t.many_field === e.field) ?? null, ie = w ? p.find(
437
+ (t) => t.many_collection === w.many_collection && t.many_field === w.junction_field && t.id !== w.id
438
+ ) ?? null : null, D = w ? w.one_field ?? `${w.many_collection}.${w.junction_field}` : null, be = D ? (b == null ? void 0 : b.getStagedLinks(D)) ?? [] : [], Me = w ? (pe.getQueryData([
412
439
  "m2m-items",
413
- v.many_collection,
414
- v.many_field,
440
+ w.many_collection,
441
+ w.many_field,
415
442
  i
416
- ]) ?? []).map((t) => t[v.junction_field]) : [], Se = v ? de[0] ?? Re[0] ?? null : H, $e = (X == null ? void 0 : X.one_collection) ?? (J == null ? void 0 : J.one_collection) ?? void 0, D = (t) => {
443
+ ]) ?? []).map((t) => t[w.junction_field]) : [], Ke = w ? be[0] ?? Me[0] ?? null : re, Oe = (ie == null ? void 0 : ie.one_collection) ?? (le == null ? void 0 : le.one_collection) ?? void 0, z = (t) => {
417
444
  var r;
418
- return ((k == null ? void 0 : k.collection) === u ? (r = k == null ? void 0 : k.fieldLabels) == null ? void 0 : r[t] : void 0) ?? fe(String(t));
419
- }, S = st({
420
- rules: R,
445
+ return ((F == null ? void 0 : F.collection) === c ? (r = F == null ? void 0 : F.fieldLabels) == null ? void 0 : r[t] : void 0) ?? se(String(t));
446
+ }, q = vt({
447
+ rules: S,
421
448
  // A parent whose value THIS field's own pick derived must not narrow this
422
449
  // field's options — otherwise picking a region locks the region picker
423
450
  // into the zone the pick itself filled, and cross-zone changes read as
@@ -427,28 +454,28 @@ function Wt({
427
454
  return ((r = b == null ? void 0 : b.getDerivedOrigin) == null ? void 0 : r.call(b, t)) === e.field;
428
455
  },
429
456
  parentValue: (t) => {
430
- if (s[t] != null) return s[t];
431
- const r = c.find((_) => _.one_collection === u && _.one_field === t);
457
+ if (o[t] != null) return o[t];
458
+ const r = p.find((g) => g.one_collection === c && g.one_field === t);
432
459
  if (!r) return null;
433
460
  let x = r;
434
461
  if (!x.junction_field) {
435
- const _ = c.find(
436
- (xe) => xe.many_collection === r.many_collection && xe.id !== r.id
462
+ const g = p.find(
463
+ (k) => k.many_collection === r.many_collection && k.id !== r.id
437
464
  );
438
- if (_ != null && _.many_field) x = { ...r, junction_field: _.many_field };
465
+ if (g != null && g.many_field) x = { ...r, junction_field: g.many_field };
439
466
  else return null;
440
467
  }
441
- const N = x.one_field ?? `${x.many_collection}.${x.junction_field}`, I = (b == null ? void 0 : b.getStagedLinks(N)) ?? [], O = Ce[t] ?? [], C = [...new Set([...I, ...O].map((_) => String(_)))];
468
+ const N = x.one_field ?? `${x.many_collection}.${x.junction_field}`, j = (b == null ? void 0 : b.getStagedLinks(N)) ?? [], R = Pe[t] ?? [], C = [...new Set([...j, ...R].map((g) => String(g)))];
442
469
  return C.length === 0 ? null : C.length === 1 ? C[0] : C;
443
470
  },
444
471
  parentOptionFilter: (t) => {
445
472
  var x;
446
- const r = (k == null ? void 0 : k.collection) === u ? (x = k.fieldOptionFilters) == null ? void 0 : x[t] : void 0;
447
- return r ? ut(r, s, i) : void 0;
473
+ const r = (F == null ? void 0 : F.collection) === c ? (x = F.fieldOptionFilters) == null ? void 0 : x[t] : void 0;
474
+ return r ? jt(r, o, i) : void 0;
448
475
  }
449
- }), T = S.filter, M = S.satisfiedParents.map(D), ce = S.satisfiedParents, Te = S.unsatisfiedParents.length ? D(S.unsatisfiedParents[0]) : null, Z = S.missingRequiredParents, ue = Z.length ? D(Z[0]) : null;
450
- function qe() {
451
- for (const t of ce) {
476
+ }), M = q.filter, G = q.satisfiedParents.map(z), ge = q.satisfiedParents, Ue = q.unsatisfiedParents.length ? z(q.unsatisfiedParents[0]) : null, oe = q.missingRequiredParents, ve = oe.length ? z(oe[0]) : null;
477
+ function Be() {
478
+ for (const t of ge) {
452
479
  const r = document.querySelector(`[data-field="${t}"]`);
453
480
  r && (r.scrollIntoView({ behavior: "smooth", block: "center" }), r.style.transition = "box-shadow 0.15s ease", r.style.boxShadow = "0 0 0 2px rgb(var(--nvr-cyan-rgb, 0 206 255)), 0 0 0 5px rgb(var(--nvr-cyan-rgb, 0 206 255) / 0.25)", r.style.borderRadius = "12px", setTimeout(() => {
454
481
  r.style.boxShadow = "none", setTimeout(() => {
@@ -457,110 +484,134 @@ function Wt({
457
484
  }, 900));
458
485
  }
459
486
  }
460
- const je = () => {
461
- if (v && $) {
462
- for (const r of de) b == null || b.unstageLink($, r);
463
- const t = ae.getQueryData([
487
+ const He = () => {
488
+ if (w && D) {
489
+ for (const r of be) b == null || b.unstageLink(D, r);
490
+ const t = pe.getQueryData([
464
491
  "m2m-items",
465
- v.many_collection,
466
- v.many_field,
492
+ w.many_collection,
493
+ w.many_field,
467
494
  i
468
495
  ]) ?? [];
469
- for (const r of t) b == null || b.stageUnlink($, r.id);
496
+ for (const r of t) b == null || b.stageUnlink(D, r.id);
470
497
  } else
471
- h(e.field, null);
498
+ f(e.field, null);
472
499
  };
473
500
  return (
474
501
  // biome-ignore lint/a11y/noStaticElementInteractions: the wrapper only hosts the field context menu (right-click / Shift+F10); the inputs inside stay the controls
475
- /* @__PURE__ */ o(
502
+ /* @__PURE__ */ d(
476
503
  "div",
477
504
  {
478
- ref: V,
505
+ ref: ne,
479
506
  "data-field": e.field,
480
- "data-field-collection": u,
507
+ "data-field-collection": c,
481
508
  "data-field-interface": e.interface ?? void 0,
482
- className: "group/fieldrow space-y-1.5",
483
- onContextMenu: ve,
484
- onKeyDown: we,
485
- onFocusCapture: L.onFocusCapture,
509
+ "data-autofill-check": ae ? "" : void 0,
510
+ className: P(
511
+ "group/fieldrow space-y-1.5",
512
+ ae && "rounded-md bg-amber-50/60 p-1.5 ring-1 ring-amber-300 dark:bg-amber-500/10 dark:ring-amber-500/40"
513
+ ),
514
+ onContextMenu: Le,
515
+ onKeyDown: Re,
516
+ onFocusCapture: $.onFocusCapture,
486
517
  children: [
487
- ke,
488
- R.length > 0 && /* @__PURE__ */ n(
489
- ot,
518
+ $e,
519
+ S.length > 0 && /* @__PURE__ */ n(
520
+ wt,
490
521
  {
491
- cascadeRules: R,
492
- cascadeFilter: T,
493
- currentValue: Se,
494
- relatedCollection: $e,
495
- missingRequiredParents: Z,
496
- onClear: je
522
+ cascadeRules: S,
523
+ cascadeFilter: M,
524
+ currentValue: Ke,
525
+ relatedCollection: Oe,
526
+ missingRequiredParents: oe,
527
+ onClear: He
497
528
  }
498
529
  ),
499
- (Y !== "" || A.length > 0) && /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-1.5 min-h-[1.5rem]", children: [
500
- Y !== "" && /* @__PURE__ */ o(He, { "data-field-label": !0, className: "text-sm font-medium", children: [
501
- /* @__PURE__ */ n(Ve, { text: Y, collection: u }),
502
- e.required && /* @__PURE__ */ n("span", { className: "ml-0.5 text-destructive", children: "*" })
530
+ (A !== "" || W.length > 0) && /* @__PURE__ */ d("div", { className: "flex flex-wrap items-center gap-1.5 min-h-[1.5rem]", children: [
531
+ A !== "" && /* @__PURE__ */ d(it, { "data-field-label": !0, className: "text-sm font-medium", children: [
532
+ /* @__PURE__ */ n(Ne, { text: A, collection: c }),
533
+ e.required && /* @__PURE__ */ n("span", { className: "ml-0.5 text-destructive", children: "*" }),
534
+ Rt(e) && /* @__PURE__ */ n($t, {})
503
535
  ] }),
504
- e.note && /* @__PURE__ */ n(K, { delayDuration: 100, children: /* @__PURE__ */ o(U, { children: [
505
- /* @__PURE__ */ n(W, { asChild: !0, children: /* @__PURE__ */ n(Ae, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
506
- /* @__PURE__ */ n(B, { side: "top", className: "max-w-[240px] text-[12px]", children: e.note })
536
+ V.note && /* @__PURE__ */ n(Q, { delayDuration: 100, children: /* @__PURE__ */ d(Y, { children: [
537
+ /* @__PURE__ */ n(J, { asChild: !0, children: /* @__PURE__ */ n(ze, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
538
+ /* @__PURE__ */ n(X, { side: "top", className: "max-w-[240px] text-[12px]", children: (s == null ? void 0 : s.glossaryHelp) === !1 ? V.note : /* @__PURE__ */ n(Ne, { text: V.note, collection: c }) })
507
539
  ] }) }),
508
- i && i !== "new" && /* @__PURE__ */ n(
509
- vt,
540
+ !T && i && i !== "new" && /* @__PURE__ */ n(
541
+ Bt,
510
542
  {
511
- collection: u,
543
+ collection: c,
512
544
  itemId: i,
513
545
  field: e.field,
514
- onRestore: e.readonly ? void 0 : (t) => h(e.field, t)
546
+ onRestore: e.readonly ? void 0 : (t) => f(e.field, t)
515
547
  }
516
548
  ),
517
- i && i !== "new" && /* @__PURE__ */ n(wt, { collection: u, itemId: i, field: e.field }),
518
- i && i !== "new" && Fe && /* @__PURE__ */ n(gt, { collection: u, itemId: i, field: e.field }),
519
- yt(e) && g && /* @__PURE__ */ o(
549
+ !T && i && i !== "new" && /* @__PURE__ */ n(Ht, { collection: c, itemId: i, field: e.field }),
550
+ i && i !== "new" && Ae && /* @__PURE__ */ n(Ut, { collection: c, itemId: i, field: e.field }),
551
+ Ee && /* @__PURE__ */ n(
552
+ St,
553
+ {
554
+ collection: c,
555
+ itemId: i,
556
+ field: e.field,
557
+ label: A || se(e.field),
558
+ onFill: (t) => f(e.field, t)
559
+ }
560
+ ),
561
+ !T && H.show && !(H.perField && (m || e.readonly)) && /* @__PURE__ */ d(
520
562
  "button",
521
563
  {
522
564
  type: "button",
523
- onClick: Ne,
524
- disabled: re,
565
+ onClick: Te,
566
+ disabled: he,
567
+ "data-ai-fill": H.perField ? e.field : void 0,
525
568
  className: "inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium text-nvr-cyan hover:bg-nvr-cyan/10 disabled:opacity-50 transition-colors",
526
569
  title: "Generate with AI",
527
570
  children: [
528
- re ? /* @__PURE__ */ n(De, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ n(Me, { className: "h-3 w-3" }),
571
+ he ? /* @__PURE__ */ n(Ge, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ n(Qe, { className: "h-3 w-3" }),
529
572
  "AI"
530
573
  ]
531
574
  }
532
575
  ),
576
+ ae && /* @__PURE__ */ n(
577
+ "span",
578
+ {
579
+ "data-tip": "People often change what the AI read from the document here — check it",
580
+ className: "inline-flex items-center rounded px-1.5 py-0.5 text-[10.5px] font-medium text-amber-800 bg-amber-100 dark:bg-amber-500/15 dark:text-amber-200",
581
+ children: "Check this"
582
+ }
583
+ ),
533
584
  a,
534
- F && !m && !e.readonly && /* @__PURE__ */ o(
585
+ L && !m && !e.readonly && /* @__PURE__ */ d(
535
586
  "button",
536
587
  {
537
588
  type: "button",
538
- onClick: () => F.onApply(s[e.field] ?? null),
539
- disabled: s[e.field] == null || s[e.field] === "" || F.count === 0,
589
+ onClick: () => L.onApply(o[e.field] ?? null),
590
+ disabled: o[e.field] == null || o[e.field] === "" || L.count === 0,
540
591
  "data-apply-to-lines": e.field,
541
- "data-tip": F.count === 0 ? "No lines yet — add lines first" : s[e.field] == null || s[e.field] === "" ? "Pick a value first" : F.count != null ? `Copy this value onto all ${F.count} lines (staged until you save)` : "Copy this value onto every line (staged until you save)",
592
+ "data-tip": L.count === 0 ? "No lines yet — add lines first" : o[e.field] == null || o[e.field] === "" ? "Pick a value first" : L.count != null ? `Copy this value onto all ${L.count} lines (staged until you save)` : "Copy this value onto every line (staged until you save)",
542
593
  className: "inline-flex items-center gap-1 rounded border border-nvr-cyan/40 px-1.5 py-0.5 text-[10.5px] font-medium text-[#0e7490] transition-colors hover:bg-nvr-cyan/10 disabled:cursor-not-allowed disabled:opacity-40 dark:text-nvr-cyan",
543
594
  children: [
544
- F.label ?? "Apply to lines",
595
+ L.label ?? "Apply to lines",
545
596
  " ↓"
546
597
  ]
547
598
  }
548
599
  ),
549
- A.length > 0 && /* @__PURE__ */ n(K, { delayDuration: 100, children: /* @__PURE__ */ o(U, { children: [
550
- /* @__PURE__ */ n(W, { asChild: !0, children: /* @__PURE__ */ o("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20 cursor-default", children: [
600
+ W.length > 0 && /* @__PURE__ */ n(Q, { delayDuration: 100, children: /* @__PURE__ */ d(Y, { children: [
601
+ /* @__PURE__ */ n(J, { asChild: !0, children: /* @__PURE__ */ d("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20 cursor-default", children: [
551
602
  /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
552
603
  "addendum"
553
604
  ] }) }),
554
- /* @__PURE__ */ o(B, { side: "top", className: "max-w-[220px] text-[12px]", children: [
555
- /* @__PURE__ */ o("p", { className: "font-medium mb-1", children: [
605
+ /* @__PURE__ */ d(X, { side: "top", className: "max-w-[220px] text-[12px]", children: [
606
+ /* @__PURE__ */ d("p", { className: "font-medium mb-1", children: [
556
607
  "In active addendum",
557
- A.length > 1 ? "s" : "",
608
+ W.length > 1 ? "s" : "",
558
609
  ":"
559
610
  ] }),
560
- A.map((t) => /* @__PURE__ */ o("p", { className: "text-slate-400", children: [
611
+ W.map((t) => /* @__PURE__ */ d("p", { className: "text-slate-400", children: [
561
612
  t.title,
562
613
  " ",
563
- /* @__PURE__ */ o("span", { className: "capitalize", children: [
614
+ /* @__PURE__ */ d("span", { className: "capitalize", children: [
564
615
  "(",
565
616
  t.status,
566
617
  ")"
@@ -568,111 +619,122 @@ function Wt({
568
619
  ] }, t.id))
569
620
  ] })
570
621
  ] }) }),
571
- (m || e.readonly) && E ? /* @__PURE__ */ n(et, { reason: E }) : m ? /* @__PURE__ */ n(K, { delayDuration: 200, children: /* @__PURE__ */ o(U, { children: [
572
- /* @__PURE__ */ n(W, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ n(Oe, { className: "h-3 w-3" }) }) }),
573
- /* @__PURE__ */ n(B, { side: "top", className: "text-[12px]", children: "This field is locked" })
622
+ /* @__PURE__ */ n(
623
+ ft,
624
+ {
625
+ collection: c,
626
+ kind: "field",
627
+ name: e.field,
628
+ label: A
629
+ }
630
+ ),
631
+ (m || e.readonly) && E ? /* @__PURE__ */ n(mt, { reason: E, onHover: s == null ? void 0 : s.onLockHover }) : m ? /* @__PURE__ */ n(Q, { delayDuration: 200, children: /* @__PURE__ */ d(Y, { children: [
632
+ /* @__PURE__ */ n(J, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ n(Ye, { className: "h-3 w-3" }) }) }),
633
+ /* @__PURE__ */ n(X, { side: "top", className: "text-[12px]", children: "This field is locked" })
574
634
  ] }) }) : null,
575
- R.length > 0 && (() => {
576
- const t = !!T && Object.keys(T).length > 0 && M.length > 0, r = R.map(
577
- (x) => D(String(x.parent_field))
635
+ S.length > 0 && (() => {
636
+ const t = !!M && Object.keys(M).length > 0 && G.length > 0, r = S.map(
637
+ (x) => z(String(x.parent_field))
578
638
  );
579
- return /* @__PURE__ */ n(K, { delayDuration: 100, children: /* @__PURE__ */ o(U, { children: [
580
- /* @__PURE__ */ n(W, { asChild: !0, children: /* @__PURE__ */ n(
639
+ return /* @__PURE__ */ n(Q, { delayDuration: 100, children: /* @__PURE__ */ d(Y, { children: [
640
+ /* @__PURE__ */ n(J, { asChild: !0, children: /* @__PURE__ */ n(
581
641
  "button",
582
642
  {
583
643
  type: "button",
584
- onClick: qe,
585
- className: q(
644
+ onClick: Be,
645
+ className: P(
586
646
  "inline-flex items-center transition-colors",
587
647
  t ? "text-nvr-cyan hover:text-nvr-cyan" : "text-slate-300 hover:text-nvr-cyan dark:text-slate-600 dark:hover:text-nvr-cyan"
588
648
  ),
589
- children: /* @__PURE__ */ n(Ke, { className: "h-3 w-3" })
649
+ children: /* @__PURE__ */ n(Je, { className: "h-3 w-3" })
590
650
  }
591
651
  ) }),
592
- /* @__PURE__ */ n(B, { side: "top", className: "text-[12px]", children: t ? `Filtered by ${M.join(", ")} — click to highlight` : `Options filter by ${r.join(", ")} once set` })
652
+ /* @__PURE__ */ n(X, { side: "top", className: "text-[12px]", children: t ? `Filtered by ${G.join(", ")} — click to highlight` : `Options filter by ${r.join(", ")} once set` })
593
653
  ] }) });
594
654
  })()
595
655
  ] }),
596
- L.editor && !m && /* @__PURE__ */ n(
597
- tt,
656
+ $.editor && !m && /* @__PURE__ */ n(
657
+ pt,
598
658
  {
599
- editor: L.editor,
600
- confirming: L.confirming,
601
- onConfirm: L.confirm,
602
- onCancel: L.cancel
659
+ editor: $.editor,
660
+ confirming: $.confirming,
661
+ onConfirm: $.confirm,
662
+ onCancel: $.cancel
603
663
  }
604
664
  ),
605
- p ?? /* @__PURE__ */ n(
665
+ h ?? /* @__PURE__ */ n(
606
666
  "div",
607
667
  {
608
- className: q(m && !Q && "cursor-not-allowed"),
668
+ className: P(m && !ee && "cursor-not-allowed"),
609
669
  "data-tip": (m || e.readonly) && E ? E : void 0,
670
+ onPointerEnter: (m || e.readonly) && E ? s == null ? void 0 : s.onLockHover : void 0,
610
671
  children: /* @__PURE__ */ n(
611
672
  "div",
612
673
  {
613
- className: q(
674
+ className: P(
614
675
  // A locked FILE field stays interactive: its chips keep the
615
676
  // download link and preview click (the component itself hides
616
677
  // upload/replace/remove when readonly) — blocking pointer events
617
678
  // made attachments unopenable on every locked form (addendum
618
679
  // view, terminal states).
619
- m && !Q && "pointer-events-none opacity-60",
680
+ m && !ee && "pointer-events-none opacity-60",
620
681
  // The ring lands with a 2px shake so the eye finds the field;
621
682
  // the animation runs once when the class is added.
622
- d && "nvr-shake ring-1 ring-red-400 rounded-md",
623
- ne && "nvr-autofill-glow"
683
+ u && "nvr-shake ring-1 ring-red-400 rounded-md",
684
+ me && "nvr-autofill-glow"
624
685
  ),
625
- children: Le ? /* @__PURE__ */ n(
626
- Je,
686
+ children: T ? /* @__PURE__ */ n(Tt, { field: e, values: o }) : De ? /* @__PURE__ */ n(
687
+ st,
627
688
  {
628
- collection: u,
689
+ collection: c,
629
690
  field: e,
630
- draft: s,
691
+ draft: o,
631
692
  itemId: i
632
693
  }
633
694
  ) : l ? l({
634
695
  field: e,
635
- value: H,
636
- onChange: (t) => h(e.field, t),
696
+ value: re,
697
+ onChange: (t) => f(e.field, t),
637
698
  disabled: m,
638
- collection: u,
699
+ collection: c,
639
700
  itemId: i,
640
- relations: c,
641
- cascadeFilter: T,
642
- unsatisfiedParentLabel: Te,
643
- requiredParentLabel: ue
701
+ relations: p,
702
+ cascadeFilter: M,
703
+ unsatisfiedParentLabel: Ue,
704
+ requiredParentLabel: ve
644
705
  }) : /* @__PURE__ */ n(
645
- at,
706
+ xt,
646
707
  {
647
- field: m && Q ? { ...e, readonly: !0 } : e,
648
- value: H,
649
- onChange: (t) => h(e.field, t),
650
- relations: c,
651
- collection: u,
708
+ field: m && ee ? { ...e, readonly: !0 } : e,
709
+ value: re,
710
+ onChange: (t) => f(e.field, t),
711
+ relations: p,
712
+ collection: c,
652
713
  itemId: i,
653
- cascadeFilter: T,
654
- requiredParentLabel: ue,
655
- narrowedBy: M.length > 0 ? {
656
- labels: M,
657
- keys: ce,
658
- onClear: (t) => h(t, null)
714
+ cascadeFilter: M,
715
+ requiredParentLabel: ve,
716
+ narrowedBy: G.length > 0 ? {
717
+ labels: G,
718
+ keys: ge,
719
+ onClear: (t) => f(t, null)
659
720
  } : void 0,
660
- onCountChange: f ? (t) => f(e.field, t) : void 0
721
+ onCountChange: y ? (t) => y(e.field, t) : void 0
661
722
  }
662
723
  )
663
724
  },
664
- ne ?? 0
725
+ me ?? 0
665
726
  )
666
727
  }
667
728
  ),
668
- se && /* @__PURE__ */ n(
669
- nt,
729
+ ye && /* @__PURE__ */ n(qt, { value: o[e.field], config: ye }),
730
+ xe && /* @__PURE__ */ n(
731
+ ht,
670
732
  {
671
- change: se,
672
- onDismiss: () => y == null ? void 0 : y.dismissRemoteChange(e.field),
673
- onTakeTheirs: y != null && y.takeRemoteChange ? () => {
733
+ change: xe,
734
+ onDismiss: () => s == null ? void 0 : s.dismissRemoteChange(e.field),
735
+ onTakeTheirs: s != null && s.takeRemoteChange ? () => {
674
736
  var t;
675
- return (t = y.takeRemoteChange) == null ? void 0 : t.call(y, e.field);
737
+ return (t = s.takeRemoteChange) == null ? void 0 : t.call(s, e.field);
676
738
  } : void 0
677
739
  }
678
740
  )
@@ -682,7 +744,7 @@ function Wt({
682
744
  );
683
745
  }
684
746
  export {
685
- Wt as FieldRow,
686
- Ut as lineageSummary,
687
- bt as useFieldLineage
747
+ hn as FieldRow,
748
+ pn as lineageSummary,
749
+ Ot as useFieldLineage
688
750
  };