@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,171 +1,355 @@
1
- import { jsxs as f, jsx as s, Fragment as V } from "react/jsx-runtime";
2
- import { useQueryClient as de, useQuery as ie } from "@tanstack/react-query";
3
- import { AlertTriangle as ue, Plus as ce } from "lucide-react";
4
- import { useState as g, useEffect as v, useCallback as L, useRef as A, useMemo as P } from "react";
5
- import { createPortal as me } from "react-dom";
6
- import { useNivaroClient as fe } from "../../context.js";
7
- import { get as pe } from "../../lib/commands.js";
8
- import { UNGROUPED_KEY as ye, HEADER_GROUP_KEY as he } from "../../lib/layout-ops.js";
9
- import { cn as J } from "../../lib/utils.js";
10
- import { modalHostOf as be } from "../ui/popover.js";
11
- import { Skeleton as j } from "../ui/skeleton.js";
12
- import { AddPanel as ge } from "./AddPanel.js";
13
- import { bundleToActiveLayout as xe, previewForRole as ve, roleMarker as ke } from "./bundle-to-active.js";
14
- import { targetKey as we } from "./design-context.js";
15
- import { LayoutDndProvider as Le, useLayoutDnd as Ne } from "./dnd/LayoutDndProvider.js";
16
- import { EditorCanvas as Ee } from "./EditorCanvas.js";
17
- import { EditorTopBar as Ie } from "./EditorTopBar.js";
18
- import { useLayoutEditorHost as Se } from "./host.js";
19
- import { LayoutsRail as Pe } from "./LayoutsRail.js";
20
- import { useLayoutOverview as Re, useOverviewFields as Ke, useInvalidateLayouts as W, useRuleChoiceLabels as Ce, useApproxRecordCount as De } from "./overview/overview-api.js";
21
- import { purposeSegments as _e, Sentence as Oe } from "./overview/purpose.js";
22
- import { useRolePreview as Ae } from "./settings/settings-api.js";
23
- import { useLayoutDraft as Fe, useLayoutBundle as Te, layoutDraftKeys as qe, touchesOverview as Ue } from "./useLayoutDraft.js";
24
- import { FormSettings as $e } from "./settings/FormSettings.js";
25
- import { Inspector as ze } from "./inspector/Inspector.js";
26
- const X = (e) => {
27
- const r = e;
28
- return r != null && r.closest ? r.isContentEditable || !!r.closest(
29
- 'input, textarea, select, [role="textbox"], [contenteditable]:not([contenteditable="false"])'
30
- ) : !1;
31
- };
32
- function Be(e) {
33
- v(() => {
34
- const r = (t) => {
35
- if (!(t.metaKey || t.ctrlKey) || t.altKey) return;
36
- const n = t.key.toLowerCase(), l = n === "z" && t.shiftKey || n === "y" && !t.shiftKey;
37
- n !== "z" && !l || X(t.target) || (t.preventDefault(), l ? e.redo() : e.undo());
1
+ import { jsxs as h, jsx as o, Fragment as de } from "react/jsx-runtime";
2
+ import { useQueryClient as er, useQuery as tr } from "@tanstack/react-query";
3
+ import { Percent as rr, ListOrdered as or, AlertTriangle as ht, Lock as nr, Plus as ar, BarChart3 as sr, LayoutGrid as ir, Table2 as lr, Grid3x3 as dr, Users as cr } from "lucide-react";
4
+ import { useState as R, useEffect as $, useMemo as S, useRef as j, useCallback as C } from "react";
5
+ import { createPortal as ur } from "react-dom";
6
+ import { toast as vt } from "sonner";
7
+ import { useNivaroClient as pr } from "../../context.js";
8
+ import { get as mr } from "../../lib/commands.js";
9
+ import { HEADER_GROUP_KEY as At, UNGROUPED_KEY as fr } from "../../lib/layout-ops.js";
10
+ import { activeFreeze as yr, dayWords as hr } from "../../lib/layout-resolve.js";
11
+ import { useMyUserId as vr } from "../../lib/presence-signals.js";
12
+ import { cn as G } from "../../lib/utils.js";
13
+ import { modalHostOf as gr } from "../ui/popover.js";
14
+ import { Skeleton as gt } from "../ui/skeleton.js";
15
+ import { AddPanel as kr } from "./AddPanel.js";
16
+ import { AutoArrangeButton as br } from "./AutoArrange.js";
17
+ import { AiToolsButton as wr } from "./ai/AiToolsButton.js";
18
+ import { pinsToMarks as xr, mergeMarks as kt } from "./ai/ai-tools-api.js";
19
+ import { AiFormsButton as Sr } from "./ai-forms/AiFormsButton.js";
20
+ import { AskButton as Cr, AskPanel as Tr } from "./assist/AskPanel.js";
21
+ import { useAskThread as Ar } from "./assist/assist-api.js";
22
+ import { jumpToSetting as Nr } from "./assist/jump.js";
23
+ import { ProposalsButton as Or } from "./assist/ProposalsButton.js";
24
+ import { BulkChangesButton as Rr } from "./bulk/BulkChangesButton.js";
25
+ import { useMacroRecorder as Lr } from "./bulk/useMacroRecorder.js";
26
+ import { bundleToActiveLayout as Nt, previewForRole as Pr, roleMarker as Er } from "./bundle-to-active.js";
27
+ import { useCanvasCompare as Fr, CompareBanner as Ir } from "./CanvasCompare.js";
28
+ import { changeNotePolicyOf as bt, changeNoteMeta as Kr, changeNoteReady as Dr, ChangeNoteFields as _r, ChangeNoteSave as Mr } from "./ChangeNote.js";
29
+ import { PresenceAvatars as Br, DroppedBanner as qr, RecoveryBanner as $r, UnsavedList as Ur } from "./CollabParts.js";
30
+ import { CommandPalette as zr } from "./commands/CommandPalette.js";
31
+ import { nextSelection as Vr, targetKey as z } from "./design-context.js";
32
+ import { WIDTH_LABELS as Hr } from "./field-zones.js";
33
+ import { LayoutDndProvider as Wr, useLayoutDnd as jr } from "./dnd/LayoutDndProvider.js";
34
+ import { NO_DND as Gr } from "./dnd/node.js";
35
+ import { useDraftRecovery as Qr, stagedTip as Jr } from "./draft-recovery.js";
36
+ import { canvasRenderer as Yr, EditorCanvas as Zr } from "./EditorCanvas.js";
37
+ import { EditorTopBar as Xr } from "./EditorTopBar.js";
38
+ import { notesOf as eo, noteKey as to } from "./editor-notes.js";
39
+ import { EntryEditorContext as wt } from "./entry/entry-editor-context.js";
40
+ import { useTabOrderEditor as ro, TabOrderBar as oo } from "./entry/tab-order.js";
41
+ import { useAppIsDark as no, ThemePreviewTool as ao, previewThemeClass as so } from "./entry/theme-preview.js";
42
+ import { useRulesView as io, explainMarks as lo, RulesToggle as co, RuleLoopsBanner as uo } from "./explain/CanvasRules.js";
43
+ import { useDriverHover as po } from "./explain/driver-hover.js";
44
+ import { useCanvasExplain as mo, useDefaultGhosts as fo } from "./explain/use-explain.js";
45
+ import { FindReplaceButton as yo } from "./FindReplace.js";
46
+ import { OutputsButton as ho } from "./outputs/OutputsButton.js";
47
+ import { FormMapButton as vo } from "./FormMapButton.js";
48
+ import { useSectionChanges as go } from "./history-api.js";
49
+ import { useLayoutEditorHost as ko } from "./host.js";
50
+ import { overriddenTargets as bo, overrideMark as wo } from "./inheritance.js";
51
+ import { BulkInspector as xo } from "./inspector/BulkInspector.js";
52
+ import { requestInspectorTab as So } from "./inspector/tab-request.js";
53
+ import { isTyping as $e } from "./is-typing.js";
54
+ import { ARROW_DIRS as Co, altArrowMove as To } from "./keyboard-move.js";
55
+ import { LayoutsRail as Ao } from "./LayoutsRail.js";
56
+ import { LintButton as No, LintPanel as Oo } from "./lint/LintPanel.js";
57
+ import { useLayoutLint as Ro } from "./lint/lint-api.js";
58
+ import { FieldStateMatrix as Lo } from "./matrix/FieldStateMatrix.js";
59
+ import { RoleSectionMatrix as Po } from "./matrix/RoleSectionMatrix.js";
60
+ import { FindTool as Eo, OutlineTool as Fo, ViewTools as Io, ShortcutsTool as Ko } from "./nav/NavTools.js";
61
+ import { OutlinePanel as Do } from "./nav/OutlinePanel.js";
62
+ import { useEditorNav as _o } from "./nav/useEditorNav.js";
63
+ import { COMPACT_ZOOM as Mo } from "./nav/view-prefs.js";
64
+ import { useLayoutOverview as Bo, useOverviewFields as qo, useInvalidateLayouts as Ot, useRuleChoiceLabels as $o, useApproxRecordCount as Uo } from "./overview/overview-api.js";
65
+ import { purposeSegments as zo, Sentence as Vo } from "./overview/purpose.js";
66
+ import { PlacementsTable as Ho } from "./PlacementsTable.js";
67
+ import { segTrack as Wo, amberStrip as _e, segOption as jo } from "./panel-style.js";
68
+ import { useLayoutPresence as Go, peersByTarget as Qo } from "./presence.js";
69
+ import { PreviewModes as Jo } from "./preview/PreviewModes.js";
70
+ import { PreviewPanes as Yo } from "./preview/PreviewPanes.js";
71
+ import { FormMoreMenu as Zo } from "./reuse/FormMoreMenu.js";
72
+ import { useRailCopy as Xo } from "./reuse/useRailCopy.js";
73
+ import { StagedByOthers as en } from "./StagedChip.js";
74
+ import { StructureActions as tn, usePinMarks as rn } from "./StructureMenu.js";
75
+ import { useRolePreview as on } from "./settings/settings-api.js";
76
+ import { layoutKindOf as nn } from "./settings/settings-registry.js";
77
+ import { useStagedDraft as an, useStagedWriter as sn } from "./staged-api.js";
78
+ import { ImpactButton as ln, TestingButton as dn } from "./testing/TestingPanels.js";
79
+ import { MenuSeparator as Se, ToolButton as xt } from "./toolbar-kit.js";
80
+ import { unsavedText as cn, UnsavedConfirm as un } from "./UnsavedConfirm.js";
81
+ import { unsavedKeys as pn, targetFromKey as St, describeTarget as Ct } from "./unsaved-marks.js";
82
+ import { UsagePanel as mn } from "./usage/UsagePanel.js";
83
+ import { useShowFillRates as fn, useFieldFillRates as yn, usageTodayText as hn, useLayoutUsageToday as vn } from "./usage/usage-api.js";
84
+ import { useLayoutDraft as gn, useLayoutBundle as Me, layoutDraftKeys as kn, touchesOverview as bn } from "./useLayoutDraft.js";
85
+ import { FormSettings as wn } from "./settings/FormSettings.js";
86
+ import { Inspector as xn } from "./inspector/Inspector.js";
87
+ function Sn(r) {
88
+ $(() => {
89
+ const l = (s) => {
90
+ if (!(s.metaKey || s.ctrlKey) || s.altKey) return;
91
+ const i = s.key.toLowerCase();
92
+ if (i === "s" && !s.shiftKey) {
93
+ s.preventDefault(), r.autosave ? r.flush() : r.save();
94
+ return;
95
+ }
96
+ const m = i === "z" && s.shiftKey || i === "y" && !s.shiftKey;
97
+ i !== "z" && !m || $e(s.target) || (s.preventDefault(), m ? r.redo() : r.undo());
38
98
  };
39
- return window.addEventListener("keydown", r), () => window.removeEventListener("keydown", r);
40
- }, [e.undo, e.redo]);
99
+ return window.addEventListener("keydown", l), () => window.removeEventListener("keydown", l);
100
+ }, [r.undo, r.redo, r.autosave, r.flush, r.save]);
41
101
  }
42
- function He(e) {
43
- const r = e.status === "saving";
44
- v(() => {
45
- if (!r) return;
46
- const t = (n) => {
47
- e.flush(), n.preventDefault(), n.returnValue = "";
102
+ function Cn(r, l, s, i, m) {
103
+ $(() => {
104
+ const d = (c) => {
105
+ const v = Co[c.key];
106
+ if (!v || !c.altKey || c.metaKey || c.ctrlKey || c.shiftKey || c.defaultPrevented || !r || l.length !== 1 || i.current || $e(c.target) || document.querySelector('[data-radix-popper-content-wrapper], [role="menu"]')) return;
107
+ c.preventDefault();
108
+ const p = To(r, l[0], v);
109
+ if (!p) return;
110
+ s(p.ops, { label: p.label }), m(p.next);
111
+ const u = z(p.next);
112
+ requestAnimationFrame(() => {
113
+ var Q;
114
+ const g = document.querySelector(
115
+ `[data-layout-editor] [data-design-target="${CSS.escape(u)}"]`
116
+ );
117
+ g == null || g.focus({ preventScroll: !0 }), (Q = g == null ? void 0 : g.scrollIntoView) == null || Q.call(g, { block: "nearest" });
118
+ });
48
119
  };
49
- return window.addEventListener("beforeunload", t), () => window.removeEventListener("beforeunload", t);
50
- }, [r, e.flush]), v(() => {
51
- const t = () => e.flush();
52
- return window.addEventListener("pagehide", t), () => window.removeEventListener("pagehide", t);
53
- }, [e.flush]);
120
+ return window.addEventListener("keydown", d), () => window.removeEventListener("keydown", d);
121
+ }, [r, l, s, i, m]);
54
122
  }
55
- function Me(e) {
56
- const r = de(), t = W(e);
57
- return L(
58
- (n, l) => {
59
- const d = Number(n.layout.id);
60
- Number.isFinite(d) && r.invalidateQueries({ queryKey: qe.versions(d) }), t({ lazy: !Ue(l) });
123
+ function Tn(r) {
124
+ const l = r.status === "saving" || r.dirty;
125
+ $(() => {
126
+ if (!l) return;
127
+ const s = (i) => {
128
+ r.flush(), i.preventDefault(), i.returnValue = "";
129
+ };
130
+ return window.addEventListener("beforeunload", s), () => window.removeEventListener("beforeunload", s);
131
+ }, [l, r.flush]), $(() => {
132
+ const s = () => r.flush();
133
+ return window.addEventListener("pagehide", s), () => window.removeEventListener("pagehide", s);
134
+ }, [r.flush]);
135
+ }
136
+ function An(r) {
137
+ const l = er(), s = Ot(r);
138
+ return C(
139
+ (i, m) => {
140
+ const d = Number(i.layout.id);
141
+ Number.isFinite(d) && l.invalidateQueries({ queryKey: kn.versions(d) }), s({ lazy: !bn(m) });
61
142
  },
62
- [r, t]
143
+ [l, s]
63
144
  );
64
145
  }
65
- function Ge(e, r) {
66
- const t = fe();
67
- return ie({
68
- queryKey: ["layout-editor", "preview-record", e, r],
69
- queryFn: () => t.request(
70
- pe(`/items/${encodeURIComponent(e)}/${encodeURIComponent(String(r))}`)
71
- ).then((n) => n.data ?? null),
72
- enabled: r != null,
146
+ function Nn(r, l) {
147
+ const s = pr();
148
+ return tr({
149
+ queryKey: ["layout-editor", "preview-record", r, l],
150
+ queryFn: () => s.request(
151
+ mr(`/items/${encodeURIComponent(r)}/${encodeURIComponent(String(l))}`)
152
+ ).then((i) => i.data ?? null),
153
+ enabled: l != null,
73
154
  staleTime: 3e4
74
155
  });
75
156
  }
76
- function Qe(e, r, t = null) {
77
- const n = (l) => {
78
- if (e.kind === "group") return e.key === ye || l.groups.some((c) => c.key === e.key);
79
- const d = e.kind === "header" ? he : e.group_key;
80
- return l.placements.some((c) => c.field === e.field && c.group_key === d);
157
+ function On(r, l) {
158
+ const s = j(l);
159
+ s.current = l, $(() => {
160
+ if (!r) return;
161
+ let i = !1;
162
+ const m = (d) => {
163
+ var p, u;
164
+ if (i || d.defaultPrevented || d.button !== 0 || d.metaKey || d.ctrlKey || d.shiftKey || d.altKey) return;
165
+ const c = (u = (p = d.target) == null ? void 0 : p.closest) == null ? void 0 : u.call(p, "a[href]");
166
+ if (!c || c.target && c.target !== "_self" || c.hasAttribute("download")) return;
167
+ let v;
168
+ try {
169
+ v = new URL(c.href, window.location.href);
170
+ } catch {
171
+ return;
172
+ }
173
+ v.origin === window.location.origin && v.pathname + v.search !== window.location.pathname + window.location.search && (d.preventDefault(), d.stopPropagation(), s.current(() => {
174
+ i = !0;
175
+ try {
176
+ c.click();
177
+ } finally {
178
+ i = !1;
179
+ }
180
+ }, c));
181
+ };
182
+ return document.addEventListener("click", m, !0), () => document.removeEventListener("click", m, !0);
183
+ }, [r]);
184
+ }
185
+ function Be(r, l, s = null) {
186
+ const i = (m) => {
187
+ if (r.kind === "group") return r.key === fr || m.groups.some((c) => c.key === r.key);
188
+ const d = r.kind === "header" ? At : r.group_key;
189
+ return m.placements.some((c) => c.field === r.field && c.group_key === d);
81
190
  };
82
- return n(r) || t != null && n(t);
191
+ return i(l) || s != null && i(s);
83
192
  }
84
- function je(e, r, t) {
85
- const n = A(null), l = A(r);
86
- return l.current = r, v(() => {
87
- var m;
88
- if (!e) return;
193
+ function Rn(r, l, s) {
194
+ const i = j(null), m = j(l);
195
+ return m.current = l, $(() => {
196
+ var v;
197
+ if (!r) return;
89
198
  const d = document.activeElement;
90
- (m = n.current) == null || m.focus();
91
- const c = (i) => {
92
- i.key !== "Escape" || i.defaultPrevented || t.current || X(i.target) || document.querySelector('[data-radix-popper-content-wrapper], [role="menu"]') || (i.preventDefault(), l.current());
199
+ (v = i.current) == null || v.focus();
200
+ const c = (p) => {
201
+ p.key !== "Escape" || p.defaultPrevented || s.current || $e(p.target) || document.querySelector('[data-radix-popper-content-wrapper], [role="menu"]') || (p.preventDefault(), m.current());
93
202
  };
94
203
  return document.addEventListener("keydown", c), () => {
95
204
  document.removeEventListener("keydown", c), d != null && d.isConnected && d.focus();
96
205
  };
97
- }, [e, t]), n;
206
+ }, [r, s]), i;
98
207
  }
99
- function Ye({
100
- collection: e,
101
- bundle: r,
102
- parent: t,
103
- preview: n,
104
- record: l,
105
- selected: d,
106
- onSelect: c,
107
- showHidden: m,
108
- apply: i,
109
- whenIdle: N
208
+ function Ln({
209
+ collection: r,
210
+ bundle: l,
211
+ parent: s,
212
+ roleId: i,
213
+ stateKey: m = null,
214
+ marks: d,
215
+ overlay: c,
216
+ ruleMarks: v,
217
+ ghost: p,
218
+ deps: u,
219
+ noDnd: g = !1,
220
+ record: Q,
221
+ selected: n,
222
+ selection: ye,
223
+ onSelect: t,
224
+ showHidden: E,
225
+ fold: te = null,
226
+ reveal: V = null,
227
+ apply: N,
228
+ whenIdle: Ce,
229
+ fillRate: he,
230
+ unsaved: ve,
231
+ peers: ce,
232
+ compare: y,
233
+ lastChanges: L
110
234
  }) {
111
- const E = Ne(), a = P(() => xe(r, t), [r, t]), o = P(
112
- () => ve(a.active, n.roleId, m),
113
- [a.active, n.roleId, m]
114
- ), { data: y = null } = Ae(e, n.roleId), k = P(
115
- () => n.roleId ? ke(y) : void 0,
116
- [n.roleId, y]
117
- ), I = P(
235
+ const re = jr(), K = g ? Gr : re, se = Yr(String(l.layout.layout_type ?? "grouped")), ie = (se === "item-edit-form" || se === "read-view") && (y == null ? void 0 : y.diff.bundle) || l, M = S(() => Nt(ie, s), [ie, s]), J = S(
236
+ () => s ? bo(l, s) : null,
237
+ [l, s]
238
+ ), H = S(() => J != null && J.size ? (k) => {
239
+ const P = J.get(z(k)), oe = (d == null ? void 0 : d(k)) ?? [];
240
+ return P ? [...oe, wo(P)] : oe;
241
+ } : d, [J, d]), Te = S(
242
+ () => Pr(M.active, i, E),
243
+ [M.active, i, E]
244
+ ), { data: D = null } = on(r, i), Y = S(
245
+ () => i ? Er(D) : void 0,
246
+ [i, D]
247
+ ), O = S(() => eo(l), [l]), _ = S(
248
+ () => H && v ? (k) => [...H(k), ...v(k)] : H ?? v,
249
+ [H, v]
250
+ ), B = rn(l, _), Ae = S(
118
251
  () => ({
119
- selected: d,
120
- onSelect: c,
121
- showHidden: m,
122
- inheritedFrom: (w) => a.inherited.get(we(w)) ?? null,
123
- dnd: E,
124
- roleMark: k
252
+ selected: n,
253
+ selection: ye,
254
+ onSelect: t,
255
+ showHidden: E,
256
+ inheritedFrom: (k) => M.inherited.get(z(k)) ?? null,
257
+ dnd: K,
258
+ roleMark: Y,
259
+ marks: B,
260
+ overlay: c,
261
+ fillRate: he,
262
+ note: (k) => {
263
+ const P = to(k);
264
+ return P ? O.get(P) ?? null : null;
265
+ },
266
+ fold: te,
267
+ reveal: V,
268
+ unsaved: ve,
269
+ peers: ce,
270
+ diffMark: y ? (k) => y.diff.marks.get(z(k)) ?? null : void 0,
271
+ lastChange: L ? (k) => k.kind === "group" ? L[k.key] ?? null : null : void 0,
272
+ ghost: p,
273
+ resizeWidth: g ? void 0 : (k, P) => {
274
+ k.kind !== "field" && k.kind !== "slot" || N(
275
+ [
276
+ {
277
+ op: "update_placement",
278
+ at: { field: k.field, group_key: k.group_key },
279
+ patch: { col_span: P === 12 ? null : P }
280
+ }
281
+ ],
282
+ { label: `Set the width to ${Hr[P] ?? P}` }
283
+ );
284
+ }
125
285
  }),
126
- [d, c, m, a.inherited, E, k]
127
- );
128
- return /* @__PURE__ */ s(
129
- Ee,
286
+ [
287
+ n,
288
+ ye,
289
+ t,
290
+ E,
291
+ M.inherited,
292
+ K,
293
+ Y,
294
+ B,
295
+ c,
296
+ he,
297
+ O,
298
+ te,
299
+ V,
300
+ ve,
301
+ ce,
302
+ y,
303
+ L,
304
+ p,
305
+ N,
306
+ g
307
+ ]
308
+ ), T = po(u);
309
+ return /* @__PURE__ */ o("div", { ref: T, className: "flex min-h-full flex-col", children: /* @__PURE__ */ o(
310
+ Zr,
130
311
  {
131
- collection: e,
132
- bundle: r,
133
- layout: o,
134
- record: l,
135
- design: I,
136
- apply: i,
137
- whenIdle: N
312
+ collection: r,
313
+ bundle: ie,
314
+ layout: Te,
315
+ record: Q,
316
+ stateKey: m,
317
+ roleId: i,
318
+ design: Ae,
319
+ apply: N,
320
+ whenIdle: Ce
138
321
  }
139
- );
322
+ ) });
140
323
  }
141
- function Ve({
142
- collection: e,
143
- name: r,
144
- row: t,
145
- rows: n,
146
- fields: l,
147
- onDone: d
324
+ function Pn({
325
+ collection: r,
326
+ name: l,
327
+ row: s,
328
+ layoutId: i,
329
+ rows: m,
330
+ fields: d,
331
+ onDone: c
148
332
  }) {
149
- const c = Ce(e, l, n), { data: m } = De(e, t, n), i = t ? t.section === "forms" && (t.reason.kind === "default" || t.reason.kind === "fallback") ? [{ text: "used by every record no rule catches" }] : _e(t, l, c) : [];
150
- return i.length > 0 && typeof m == "number" && i.push({ text: ` (≈ ${m.toLocaleString()} ${m === 1 ? "record" : "records"})` }), /* @__PURE__ */ f(
333
+ const v = $o(r, d, m), { data: p } = Uo(r, s, m), u = hn(vn(i).data), g = s ? s.section === "forms" && (s.reason.kind === "default" || s.reason.kind === "fallback") ? [{ text: "used by every record no rule catches" }] : zo(s, d, v) : [];
334
+ return g.length > 0 && typeof p == "number" && g.push({ text: ` (≈ ${p.toLocaleString()} ${p === 1 ? "record" : "records"})` }), u && g.push({ text: g.length > 0 ? `; ${u}` : u }), /* @__PURE__ */ h(
151
335
  "div",
152
336
  {
153
337
  "data-editing-banner": "",
154
338
  className: "flex shrink-0 items-center gap-3 border-b border-nvr-cyan/30 bg-nvr-cyan/10 px-4 py-1.5 text-[12.5px] text-slate-700 dark:text-slate-200",
155
339
  children: [
156
- /* @__PURE__ */ f("p", { className: "m-0 min-w-0 flex-1 truncate", children: [
340
+ /* @__PURE__ */ h("p", { className: "m-0 min-w-0 flex-1 truncate", children: [
157
341
  "Editing ",
158
- /* @__PURE__ */ s("b", { className: "font-semibold text-slate-900 dark:text-foreground", children: r }),
159
- i.length > 0 && /* @__PURE__ */ f(V, { children: [
342
+ /* @__PURE__ */ o("b", { className: "font-semibold text-slate-900 dark:text-foreground", children: l }),
343
+ g.length > 0 && /* @__PURE__ */ h(de, { children: [
160
344
  " — ",
161
- /* @__PURE__ */ s(Oe, { segs: i, muted: !0 })
345
+ /* @__PURE__ */ o(Vo, { segs: g, muted: !0 })
162
346
  ] })
163
347
  ] }),
164
- /* @__PURE__ */ s(
348
+ /* @__PURE__ */ o(
165
349
  "button",
166
350
  {
167
351
  type: "button",
168
- onClick: d,
352
+ onClick: (Q) => c(Q.currentTarget),
169
353
  className: "inline-flex h-7 shrink-0 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-medium text-white transition-opacity hover:opacity-90",
170
354
  children: "Done"
171
355
  }
@@ -174,220 +358,927 @@ function Ve({
174
358
  }
175
359
  );
176
360
  }
177
- const Y = (e) => J(
361
+ function En({ view: r, onView: l }) {
362
+ const s = (i, m, d, c) => /* @__PURE__ */ h(
363
+ "button",
364
+ {
365
+ type: "button",
366
+ "aria-pressed": r === i,
367
+ "aria-label": m,
368
+ "data-editor-view": i,
369
+ "data-tip": c,
370
+ onClick: () => l(i),
371
+ className: G(jo(r === i), "inline-flex items-center justify-center gap-1"),
372
+ children: [
373
+ /* @__PURE__ */ o(d, { className: "h-3.5 w-3.5 shrink-0" }),
374
+ /* @__PURE__ */ o("span", { "data-tb-xwide": "", children: m })
375
+ ]
376
+ }
377
+ );
378
+ return /* @__PURE__ */ h(
379
+ "fieldset",
380
+ {
381
+ "aria-label": "Show the form as",
382
+ className: G("m-0 min-w-0 shrink-0 border-0", Wo(4)),
383
+ children: [
384
+ s("canvas", "Canvas", ir, "The form as people see it"),
385
+ s("table", "Table", lr, "Every field as a row: label, section, width, rules"),
386
+ s(
387
+ "states",
388
+ "States",
389
+ dr,
390
+ "Every field by workflow state: editable, read-only, required"
391
+ ),
392
+ s("roles", "Roles", cr, "Every section by role: can edit, read-only, hidden")
393
+ ]
394
+ }
395
+ );
396
+ }
397
+ const qe = (r) => G(
178
398
  "inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[12px] font-medium transition-colors",
179
- e ? "bg-accent text-slate-900 dark:text-foreground" : "text-slate-500 hover:bg-muted hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground"
399
+ r ? "bg-accent text-slate-900 dark:text-foreground" : "text-slate-500 hover:bg-muted hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground"
180
400
  );
181
- function kt({
182
- collection: e,
183
- layoutId: r,
184
- onBack: t,
185
- mode: n,
186
- onLayoutChange: l,
401
+ function us({
402
+ collection: r,
403
+ layoutId: l,
404
+ onBack: s,
405
+ mode: i,
406
+ onLayoutChange: m,
187
407
  previewRecordId: d = null,
188
- portalContainer: c
408
+ portalContainer: c,
409
+ onDirtyChange: v
189
410
  }) {
190
- var Q;
191
- const m = Se(), [i, N] = g(r);
192
- v(() => N(r), [r]);
193
- const E = Me(e), a = Fe(i, { onSaved: E }), o = a.bundle, [y, k] = g("layouts"), [I, w] = g("inspector"), [x, R] = g(null), [F, Z] = g(!1), [S, T] = g({
411
+ var ct, ut, pt, mt, ft, yt;
412
+ const p = ko(), [u, g] = R(l);
413
+ $(() => g(l), [l]);
414
+ const Q = An(r), { draft: n, recorder: ye } = Lr(gn(u, { onSaved: Q })), t = n.bundle, [E, te] = R("layouts"), [V, N] = R("inspector"), [Ce, he] = Ar(), [ve, ce] = R(null), [y, L] = R([]), re = y.length > 0 ? y[y.length - 1] : null, [K, se] = R("canvas"), [ge, ie] = R(!1), [M, J] = fn(), { data: H } = yn(r, M), Te = S(
415
+ () => M && H && H.total > 0 ? (e) => H.pct.get(e) ?? null : void 0,
416
+ [M, H]
417
+ ), [D, Y] = R({
194
418
  record: d ? { id: d, label: `#${d}` } : null,
195
419
  roleId: null
196
- }), { data: p } = Re(e), { data: q = [] } = Ke(e), h = p == null ? void 0 : p.rows.find((u) => u.layout_id === i), ee = (o == null ? void 0 : o.layout.parent_layout_id) != null ? Number(o.layout.parent_layout_id) : null, { data: K = null } = Te(ee), { data: te = null } = Ge(e, ((Q = S.record) == null ? void 0 : Q.id) ?? null);
197
- Be(a), He(a);
198
- const U = W(e), C = L(() => {
199
- const u = a.whenIdle();
200
- u.then(() => U()), t(u);
201
- }, [a.whenIdle, U, t]);
202
- v(() => {
203
- x && o && !Qe(x, o, K) && R(null);
204
- }, [x, o, K]);
205
- const b = n === "overlay", [D, re] = g(null), $ = A(!1), ne = L((u) => {
206
- $.current = u;
207
- }, []), oe = je(b && D != null, C, $), z = L((u) => {
208
- R(u), w("inspector");
209
- }, []), ae = L(
210
- (u) => T((O) => O.roleId === u ? O : { ...O, roleId: u }),
420
+ }), { data: O } = Bo(r), { data: _ = [] } = qo(r), B = O == null ? void 0 : O.rows.find((e) => e.layout_id === u), Ae = (t == null ? void 0 : t.layout.parent_layout_id) != null ? Number(t.layout.parent_layout_id) : null, { data: T = null } = Me(Ae), { data: k = null } = Nn(r, ((ct = D.record) == null ? void 0 : ct.id) ?? null), P = S(
421
+ () => t ? Nt(t, T).active : null,
422
+ [t, T]
423
+ ), oe = Ro(r, t, T), { data: Rt } = Me(u), Z = Fr(t, Rt ?? null, n.unsavedCount, u), { data: Lt } = go(u, t != null), [Ue, Pt] = R([]), Et = S(() => {
424
+ const e = xr(Ue), a = /* @__PURE__ */ new WeakMap();
425
+ return (f) => {
426
+ if (!f || !e) return kt(f, e);
427
+ const b = a.get(f);
428
+ if (b) return b;
429
+ const I = kt(f, e);
430
+ return a.set(f, I), I;
431
+ };
432
+ }, [Ue]), [ue, Ft] = io(), ke = mo(r, P, ue), pe = fo(r, P, ue && !D.record), { data: le } = Me(u), X = yr(((ut = le == null ? void 0 : le.layout) == null ? void 0 : ut.conditions) ?? ((pt = t == null ? void 0 : t.layout) == null ? void 0 : pt.conditions)), F = bt(le == null ? void 0 : le.layout) ?? bt(t == null ? void 0 : t.layout) ?? (X ? "note" : null), [me, Ne] = R({ reason: "", ticket: "" }), [ze, Ve] = R(null), Oe = j(me);
433
+ Oe.current = me;
434
+ const He = C(async () => {
435
+ const e = F ? {
436
+ ...Kr(Oe.current),
437
+ ...X ? { freeze_override: Oe.current.reason.trim() } : {}
438
+ } : void 0;
439
+ await n.save(e);
440
+ const a = n.unsavedOps().length === 0;
441
+ return a && e && Ne((f) => ({ ...f, reason: "" })), a;
442
+ }, [n.save, n.unsavedOps, F, X]), We = C(() => {
443
+ var e, a;
444
+ return F ? (n.unsavedOps().length > 0 && Ve(
445
+ ((e = U.current) == null ? void 0 : e.querySelector("[data-editor-save]")) ?? ((a = U.current) == null ? void 0 : a.querySelector("[data-editor-topbar]")) ?? null
446
+ ), Promise.resolve()) : n.save();
447
+ }, [F, n.save, n.unsavedOps]);
448
+ $(() => {
449
+ F && n.autosave && n.setAutosave(!1);
450
+ }, [F, n.autosave, n.setAutosave]);
451
+ const It = F ? { ...n, save: We, setAutosave: void 0 } : n;
452
+ Sn(F ? { ...n, save: We } : n), Tn(n);
453
+ const U = j(null), [Kt, je] = R(null), Ge = j(n.dirty);
454
+ Ge.current = n.dirty;
455
+ const ne = C((e, a, f) => {
456
+ var I, fe;
457
+ if (!Ge.current) return a();
458
+ const b = ((I = U.current) == null ? void 0 : I.querySelector("[data-editor-save]")) ?? ((fe = U.current) == null ? void 0 : fe.querySelector("[data-editor-topbar]")) ?? null;
459
+ je({ what: e, go: a, anchor: f ?? b });
460
+ }, []), Dt = He;
461
+ On(n.dirty, (e, a) => ne("leave this page", e, a)), $(() => {
462
+ v == null || v(n.dirty);
463
+ }, [n.dirty, v]);
464
+ const Qe = j(n.unsavedOps);
465
+ Qe.current = n.unsavedOps, $(
466
+ () => () => {
467
+ Qe.current().length > 0 && vt.warning("Unsaved form changes kept — open the form again to save or discard them");
468
+ },
211
469
  []
212
- ), B = (u) => {
213
- w("inspector"), u !== i && (a.flush(), R(null), N(u), l == null || l(u));
214
- }, _ = String((o == null ? void 0 : o.layout.name) ?? (h == null ? void 0 : h.name) ?? ""), se = String((o == null ? void 0 : o.layout.layout_type) ?? (h == null ? void 0 : h.layout_type) ?? "grouped"), H = m.warning ?? (p == null ? void 0 : p.warning) ?? null, le = b ? {
470
+ );
471
+ const Je = Ot(r), Ye = C(() => {
472
+ const e = n.whenIdle();
473
+ e.then(() => Je()), s(e);
474
+ }, [n.whenIdle, Je, s]), Re = C(
475
+ (e) => ne(i === "overlay" ? "go back to the record" : "leave this form", Ye, e),
476
+ [ne, Ye, i]
477
+ );
478
+ $(() => {
479
+ if (!t || y.length === 0) return;
480
+ const e = y.filter((a) => Be(a, t, T));
481
+ e.length !== y.length && L(e);
482
+ }, [y, t, T]);
483
+ const ae = i === "overlay", [Le, _t] = R(null), Pe = j(!1), Mt = C((e) => {
484
+ Pe.current = e;
485
+ }, []), Bt = Rn(ae && Le != null, () => Re(), Pe), A = C((e, a) => {
486
+ L((f) => Vr(f, e, a)), N("inspector");
487
+ }, []), Ze = C((e) => L([e]), []), q = ro(t, n.apply), qt = S(() => q.intercept(A), [q.intercept, A]), [Ee, $t] = R(!1), Fe = no(), Ie = S(
488
+ () => ({
489
+ tabOrderActive: q.active,
490
+ startTabOrder: () => {
491
+ se("canvas"), q.start();
492
+ }
493
+ }),
494
+ [q.active, q.start]
495
+ ), Xe = C(
496
+ (e, a) => {
497
+ if (e.kind === "group") return A({ kind: "group", key: e.key });
498
+ if (e.kind === "tab") {
499
+ A(a), (a.kind === "field" || a.kind === "header") && So(a.field, e.tab);
500
+ return;
501
+ }
502
+ if (e.kind === "pipeline")
503
+ return ne(
504
+ "open the pipeline",
505
+ () => p.navigate(`/pipelines/${encodeURIComponent(e.id)}`)
506
+ );
507
+ ne(
508
+ "open the field rules",
509
+ () => p.navigate(`/data-model/${encodeURIComponent(r)}?tab=rules`)
510
+ );
511
+ },
512
+ [A, ne, p, r]
513
+ ), Ut = S(() => {
514
+ const e = /* @__PURE__ */ new Map();
515
+ for (const [a, f] of pe)
516
+ (f.type === "boolean" || f.text.endsWith(" linked")) && e.set(a, f.text);
517
+ return lo(ke, { chips: ue, ghostTags: e, open: Xe });
518
+ }, [ke, ue, pe, Xe]), zt = S(
519
+ () => pe.size > 0 ? (e) => {
520
+ var a;
521
+ return ((a = pe.get(e)) == null ? void 0 : a.text) ?? null;
522
+ } : void 0,
523
+ [pe]
524
+ ), Vt = C(
525
+ (e) => {
526
+ const a = t == null ? void 0 : t.placements.find((b) => b.field === e);
527
+ if (!a) return;
528
+ const f = a.group_key === At ? { kind: "header", field: e } : { kind: "field", field: e, group_key: a.group_key };
529
+ A(f), requestAnimationFrame(
530
+ () => {
531
+ var b, I;
532
+ return (I = (b = document.querySelector(`[data-layout-editor] [data-design-target="${CSS.escape(z(f))}"]`)) == null ? void 0 : b.scrollIntoView) == null ? void 0 : I.call(b, { block: "center" });
533
+ }
534
+ );
535
+ },
536
+ [t, A]
537
+ );
538
+ Cn(t, y, n.apply, Pe, Ze);
539
+ const Ke = Go(u, re ? z(re) : null), et = S(() => Qo(Ke), [Ke]), Ht = C(
540
+ (e) => (et.get(z(e)) ?? []).map((a) => ({
541
+ id: a.id,
542
+ name: a.name,
543
+ outline: a.tone.outline,
544
+ chip: a.tone.chip
545
+ })),
546
+ [et]
547
+ ), tt = S(() => pn(n.unsavedSteps), [n.unsavedSteps]), Wt = C((e) => tt.has(z(e)), [tt]), [rt, be] = R(null), ot = C((e) => {
548
+ se("canvas"), L([e]), N("inspector"), requestAnimationFrame(() => {
549
+ var f;
550
+ const a = document.querySelector(
551
+ `[data-layout-editor] [data-design-target="${CSS.escape(z(e))}"]`
552
+ );
553
+ (f = a == null ? void 0 : a.scrollIntoView) == null || f.call(a, { block: "center" }), a == null || a.focus({ preventScroll: !0 });
554
+ });
555
+ }, []), jt = vr(), W = an(u), nt = sn(), Gt = S(
556
+ () => {
557
+ var e, a;
558
+ return {
559
+ settled: W.isFetched || W.isError,
560
+ draft: ((e = W.data) == null ? void 0 : e.data) ?? null,
561
+ available: ((a = W.data) == null ? void 0 : a.available) ?? !W.isError,
562
+ writer: nt
563
+ };
564
+ },
565
+ [W.isFetched, W.isError, W.data, nt]
566
+ ), we = Qr(n, u, jt, Gt), Qt = C(
567
+ (e) => Y((a) => a.roleId === e ? a : { ...a, roleId: e }),
568
+ []
569
+ ), ee = (e) => {
570
+ var b;
571
+ if (N("inspector"), e === u) return;
572
+ const a = document.activeElement, f = a instanceof HTMLElement && ((b = U.current) != null && b.contains(a)) ? a : null;
573
+ ne(
574
+ "open another form",
575
+ () => {
576
+ n.flush(), L([]), g(e), m == null || m(e);
577
+ },
578
+ f
579
+ );
580
+ }, Jt = Xo(r, t, (O == null ? void 0 : O.rows) ?? [], ee), Yt = C(
581
+ (e) => t ? Nr(e, {
582
+ bundle: t,
583
+ selection: y,
584
+ select: (a) => {
585
+ L([a]), N("inspector");
586
+ },
587
+ openSettings: () => N("settings"),
588
+ openAddPanel: () => te("add"),
589
+ root: U.current
590
+ }) : Promise.resolve({ ok: !1, message: "The form is still loading" }),
591
+ [t, y]
592
+ ), at = j(ee);
593
+ at.current = ee;
594
+ const Zt = C(
595
+ (e) => {
596
+ if (e.kind === "record")
597
+ Y((a) => ({ ...a, record: { id: e.id, label: `#${e.id}` } }));
598
+ else if (e.kind === "layout") at.current(e.id);
599
+ else {
600
+ const a = t == null ? void 0 : t.placements.find((b) => b.field === e.field);
601
+ if (!a) return vt.info(`${e.label} is not on this form`);
602
+ const f = { kind: "field", field: a.field, group_key: a.group_key };
603
+ A(f), requestAnimationFrame(
604
+ () => {
605
+ var b, I, fe;
606
+ return (fe = (I = (b = U.current) == null ? void 0 : b.querySelector(`[data-design-target="${CSS.escape(z(f))}"]`)) == null ? void 0 : I.scrollIntoView) == null ? void 0 : fe.call(I, { block: "center" });
607
+ }
608
+ );
609
+ }
610
+ },
611
+ [t, A]
612
+ ), xe = String((t == null ? void 0 : t.layout.name) ?? (B == null ? void 0 : B.name) ?? ""), De = String((t == null ? void 0 : t.layout.layout_type) ?? (B == null ? void 0 : B.layout_type) ?? "grouped"), w = De !== "table" && De !== "file", x = _o({
613
+ bodyRef: U,
614
+ bundle: t,
615
+ parent: T,
616
+ fields: _,
617
+ onSelect: A,
618
+ showHidden: ge,
619
+ setShowHidden: ie,
620
+ canvasShown: !(w && K === "table")
621
+ }), st = x.outlineOpen && !!t && w, it = p.warning ?? (O == null ? void 0 : O.warning) ?? null, Xt = ae ? {
215
622
  role: "dialog",
216
623
  "aria-modal": !0,
217
- "aria-label": `Edit layout ${_}`,
624
+ "aria-label": `Edit form ${xe}`,
218
625
  tabIndex: -1
219
- } : {}, M = /* @__PURE__ */ f(
626
+ } : {}, lt = /* @__PURE__ */ h(
220
627
  "div",
221
628
  {
222
- ref: b ? oe : void 0,
629
+ ref: (e) => {
630
+ U.current = e, ae && (Bt.current = e);
631
+ },
223
632
  "data-layout-editor": "",
224
- "data-mode": n,
225
- ...le,
226
- className: J(
633
+ "data-mode": i,
634
+ ...Xt,
635
+ className: G(
227
636
  "flex min-h-0 flex-col bg-slate-50 outline-none dark:bg-background",
228
- b ? "fixed inset-0 z-[90]" : "flex-1"
637
+ ae ? "fixed inset-0 z-[90]" : "flex-1"
229
638
  ),
230
639
  children: [
231
- /* @__PURE__ */ s(
232
- Ie,
640
+ /* @__PURE__ */ o(
641
+ Xr,
233
642
  {
234
- collection: e,
235
- layoutId: i,
236
- layoutName: _,
237
- layoutType: se,
238
- row: h,
239
- fields: q,
240
- draft: a,
241
- preview: S,
242
- onPreview: T,
243
- showHidden: F,
244
- onShowHidden: Z,
245
- onBack: C,
246
- backLabel: b ? "Back to record" : "Layouts"
643
+ collection: r,
644
+ layoutId: u,
645
+ layoutName: xe,
646
+ layoutType: De,
647
+ row: B,
648
+ fields: _,
649
+ draft: It,
650
+ preview: D,
651
+ onPreview: Y,
652
+ showHidden: ge,
653
+ onShowHidden: ie,
654
+ onBack: Re,
655
+ backLabel: ae ? "Back to record" : "Forms",
656
+ onShowOnCanvas: Z.showVersion,
657
+ onReviewChanges: Z.toggleReview,
658
+ reviewing: ((mt = Z.compare) == null ? void 0 : mt.kind) === "unsaved",
659
+ onOpenUnsaved: be,
660
+ pendingTip: Jr(we.sync),
661
+ presence: /* @__PURE__ */ h(de, { children: [
662
+ /* @__PURE__ */ o(
663
+ Br,
664
+ {
665
+ peers: Ke,
666
+ describe: (e) => {
667
+ const a = St(e);
668
+ return a && t && Be(a, t, T) ? Ct(a, t, _) : null;
669
+ },
670
+ onJump: (e) => {
671
+ const a = St(e);
672
+ a && ot(a);
673
+ }
674
+ }
675
+ ),
676
+ /* @__PURE__ */ o(en, { others: ((ft = W.data) == null ? void 0 : ft.others) ?? [] })
677
+ ] }),
678
+ onSelectField: (e) => {
679
+ var a;
680
+ return A({
681
+ kind: "field",
682
+ field: e,
683
+ group_key: ((a = t == null ? void 0 : t.placements.find((f) => f.field === e)) == null ? void 0 : a.group_key) ?? null
684
+ });
685
+ },
686
+ view: t && w ? /* @__PURE__ */ h(de, { children: [
687
+ /* @__PURE__ */ o(En, { view: K, onView: se }),
688
+ /* @__PURE__ */ o(co, { on: ue, onChange: Ft })
689
+ ] }) : null,
690
+ tools: /* @__PURE__ */ h(de, { children: [
691
+ t && w && /* @__PURE__ */ o(br, { bundle: t, apply: n.apply }),
692
+ t && /* @__PURE__ */ o(Eo, { find: x.find }),
693
+ t && w && /* @__PURE__ */ o(yo, { bundle: t, apply: n.apply, collection: r }),
694
+ t && w && /* @__PURE__ */ o(ho, { bundle: t, apply: n.apply, collection: r }),
695
+ /* @__PURE__ */ o(Se, {}),
696
+ t && /* @__PURE__ */ o(
697
+ Fo,
698
+ {
699
+ outline: w ? {
700
+ open: x.outlineOpen,
701
+ onToggle: () => x.setOutlineOpen(!x.outlineOpen)
702
+ } : null
703
+ }
704
+ ),
705
+ t && /* @__PURE__ */ o(
706
+ Io,
707
+ {
708
+ view: w && K === "canvas" ? {
709
+ compact: x.compact,
710
+ onCompact: x.setCompact,
711
+ onExpandAll: x.expandAll,
712
+ onCollapseAll: x.collapseAll
713
+ } : null
714
+ }
715
+ ),
716
+ t && w && /* @__PURE__ */ o(
717
+ xt,
718
+ {
719
+ label: "Show how full each field is",
720
+ icon: /* @__PURE__ */ o(rr, { className: "h-3.5 w-3.5" }),
721
+ hint: "The share of records with a value, on each field",
722
+ checked: M,
723
+ onClick: () => J(!M),
724
+ data: { "data-editor-fill-toggle": "" }
725
+ }
726
+ ),
727
+ t && w && /* @__PURE__ */ o(
728
+ xt,
729
+ {
730
+ label: "Set the tab order",
731
+ icon: /* @__PURE__ */ o(or, { className: "h-3.5 w-3.5" }),
732
+ hint: "Click fields in the order Tab should visit them",
733
+ checked: q.active,
734
+ onClick: () => q.active ? q.cancel() : Ie.startTabOrder(),
735
+ data: { "data-editor-tab-order-toggle": "" }
736
+ }
737
+ ),
738
+ t && w && /* @__PURE__ */ o(
739
+ ao,
740
+ {
741
+ on: Ee,
742
+ onChange: $t,
743
+ appDark: Fe,
744
+ disabled: K !== "canvas"
745
+ }
746
+ ),
747
+ /* @__PURE__ */ o(Se, {}),
748
+ /* @__PURE__ */ o(
749
+ Rr,
750
+ {
751
+ collection: r,
752
+ layoutId: u,
753
+ dirty: n.dirty,
754
+ recorder: ye
755
+ }
756
+ ),
757
+ /* @__PURE__ */ o(vo, { bundle: t, collection: r }),
758
+ /* @__PURE__ */ o(Se, {}),
759
+ t && /* @__PURE__ */ o(Ko, { shortcuts: x.shortcuts })
760
+ ] }),
761
+ ai: /* @__PURE__ */ h(de, { children: [
762
+ t && w && /* @__PURE__ */ o(
763
+ Sr,
764
+ {
765
+ collection: r,
766
+ layoutId: u,
767
+ draft: n,
768
+ onOpenLayout: ee
769
+ }
770
+ ),
771
+ t && /* @__PURE__ */ o(
772
+ wr,
773
+ {
774
+ collection: r,
775
+ layoutId: u,
776
+ bundle: t,
777
+ apply: n.apply,
778
+ previewRecordShown: D.record != null,
779
+ onPins: Pt,
780
+ onSelect: A
781
+ }
782
+ ),
783
+ /* @__PURE__ */ o(Se, {}),
784
+ t && p.isAdmin && /* @__PURE__ */ o(
785
+ Cr,
786
+ {
787
+ active: V === "ask",
788
+ onClick: () => N((e) => e === "ask" ? "inspector" : "ask")
789
+ }
790
+ ),
791
+ /* @__PURE__ */ o(zr, { collection: r, layoutId: u, draft: n }),
792
+ t && /* @__PURE__ */ o(Or, { layoutId: u, draft: n })
793
+ ] }),
794
+ testing: t ? /* @__PURE__ */ o(
795
+ dn,
796
+ {
797
+ collection: r,
798
+ layoutId: u,
799
+ bundle: t,
800
+ parent: T,
801
+ apply: n.apply,
802
+ dirty: n.dirty,
803
+ fields: _
804
+ }
805
+ ) : null,
806
+ beforeSave: t ? /* @__PURE__ */ o(
807
+ ln,
808
+ {
809
+ collection: r,
810
+ layoutId: u,
811
+ bundle: t,
812
+ parent: T,
813
+ apply: n.apply,
814
+ dirty: n.dirty,
815
+ fields: _
816
+ }
817
+ ) : null,
818
+ previewExtra: /* @__PURE__ */ o(
819
+ Jo,
820
+ {
821
+ collection: r,
822
+ value: D,
823
+ onChange: Y,
824
+ layout: P,
825
+ fields: _
826
+ }
827
+ ),
828
+ problems: t && /* @__PURE__ */ o(
829
+ No,
830
+ {
831
+ findings: oe.findings,
832
+ active: V === "checks",
833
+ onClick: () => N((e) => e === "checks" ? "inspector" : "checks")
834
+ }
835
+ ),
836
+ more: /* @__PURE__ */ o(
837
+ Zo,
838
+ {
839
+ collection: r,
840
+ bundle: t,
841
+ previewRecord: D.record,
842
+ onOpenLayout: ee
843
+ }
844
+ )
247
845
  }
248
846
  ),
249
- b && /* @__PURE__ */ s(
250
- Ve,
847
+ ae && /* @__PURE__ */ o(
848
+ Pn,
251
849
  {
252
- collection: e,
253
- name: _,
254
- row: h,
255
- rows: (p == null ? void 0 : p.rows) ?? [],
256
- fields: q,
257
- onDone: C
850
+ collection: r,
851
+ layoutId: u,
852
+ name: xe,
853
+ row: B,
854
+ rows: (O == null ? void 0 : O.rows) ?? [],
855
+ fields: _,
856
+ onDone: Re
258
857
  }
259
858
  ),
260
- H && /* @__PURE__ */ f(
859
+ n.status === "conflict" && n.dirty && /* @__PURE__ */ h(
860
+ "div",
861
+ {
862
+ role: "alert",
863
+ "data-unsaved-conflict": "",
864
+ className: G(
865
+ "flex shrink-0 items-center gap-3 border-b px-4 py-1.5 text-[12.5px]",
866
+ _e
867
+ ),
868
+ children: [
869
+ /* @__PURE__ */ o(ht, { className: "h-3.5 w-3.5 shrink-0" }),
870
+ /* @__PURE__ */ h("p", { className: "m-0 min-w-0 flex-1", children: [
871
+ n.error ?? "Someone else saved this form",
872
+ ". Save again to try once more, or reload their version."
873
+ ] }),
874
+ /* @__PURE__ */ h(
875
+ "button",
876
+ {
877
+ type: "button",
878
+ "data-unsaved-reload": "",
879
+ onClick: n.discard,
880
+ className: "inline-flex h-7 shrink-0 items-center rounded-md border border-amber-300 px-2.5 text-[12px] font-medium hover:bg-amber-100 dark:border-amber-500/40 dark:hover:bg-amber-500/15",
881
+ children: [
882
+ "Reload (discard my ",
883
+ cn(n.unsavedCount),
884
+ ")"
885
+ ]
886
+ }
887
+ )
888
+ ]
889
+ }
890
+ ),
891
+ /* @__PURE__ */ o(qr, { labels: n.dropped, onDismiss: n.clearDropped }),
892
+ /* @__PURE__ */ o(
893
+ $r,
894
+ {
895
+ state: we.state,
896
+ onRecover: we.recover,
897
+ onDismiss: we.dismiss
898
+ }
899
+ ),
900
+ it && /* @__PURE__ */ h(
261
901
  "div",
262
902
  {
263
903
  role: "note",
264
- className: "flex shrink-0 items-center gap-2 border-b border-amber-200 bg-amber-50 px-4 py-1.5 text-[12.5px] text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",
904
+ className: G(
905
+ "flex shrink-0 items-center gap-2 border-b px-4 py-1.5 text-[12.5px]",
906
+ _e
907
+ ),
265
908
  children: [
266
- /* @__PURE__ */ s(ue, { className: "h-3.5 w-3.5 shrink-0" }),
267
- H
909
+ /* @__PURE__ */ o(ht, { className: "h-3.5 w-3.5 shrink-0" }),
910
+ it
268
911
  ]
269
912
  }
270
913
  ),
271
- /* @__PURE__ */ s(Le, { bundle: o, apply: a.apply, onDragActive: ne, children: /* @__PURE__ */ f("div", { className: "flex min-h-0 flex-1 overflow-hidden", children: [
272
- /* @__PURE__ */ f("aside", { className: "flex w-[260px] shrink-0 flex-col border-r border-slate-200 bg-white dark:border-border dark:bg-card", children: [
273
- /* @__PURE__ */ f(
274
- "div",
275
- {
276
- role: "tablist",
277
- "aria-label": "Left panel",
278
- className: "flex shrink-0 items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-border",
279
- children: [
280
- /* @__PURE__ */ s(
281
- "button",
282
- {
283
- type: "button",
284
- role: "tab",
285
- "aria-selected": y === "layouts",
286
- "data-editor-tab": "layouts",
287
- className: Y(y === "layouts"),
288
- onClick: () => k("layouts"),
289
- children: "Layouts"
290
- }
914
+ X && /* @__PURE__ */ h(
915
+ "div",
916
+ {
917
+ role: "note",
918
+ "data-editor-frozen": X.until,
919
+ className: G(
920
+ "flex shrink-0 items-center gap-2 border-b px-4 py-1.5 text-[12.5px]",
921
+ _e
922
+ ),
923
+ children: [
924
+ /* @__PURE__ */ o(nr, { className: "h-3.5 w-3.5 shrink-0" }),
925
+ Tt(X)
926
+ ]
927
+ }
928
+ ),
929
+ /* @__PURE__ */ o(uo, { explain: ke, onShow: Vt }),
930
+ /* @__PURE__ */ o(
931
+ Wr,
932
+ {
933
+ bundle: t,
934
+ apply: n.apply,
935
+ onDragActive: Mt,
936
+ onDropOnLayout: Jt,
937
+ children: /* @__PURE__ */ h("div", { className: "flex min-h-0 flex-1 overflow-hidden", children: [
938
+ /* @__PURE__ */ h(
939
+ "aside",
940
+ {
941
+ className: G(
942
+ "flex w-[260px] shrink-0 flex-col border-r border-slate-200 bg-white dark:border-border dark:bg-card",
943
+ st && "hidden"
291
944
  ),
292
- /* @__PURE__ */ f(
293
- "button",
945
+ children: [
946
+ /* @__PURE__ */ h(
947
+ "div",
948
+ {
949
+ role: "tablist",
950
+ "aria-label": "Left panel",
951
+ className: "flex shrink-0 items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-border",
952
+ children: [
953
+ /* @__PURE__ */ o(
954
+ "button",
955
+ {
956
+ type: "button",
957
+ role: "tab",
958
+ "aria-selected": E === "layouts",
959
+ "data-editor-tab": "layouts",
960
+ className: qe(E === "layouts"),
961
+ onClick: () => te("layouts"),
962
+ children: "Forms"
963
+ }
964
+ ),
965
+ /* @__PURE__ */ h(
966
+ "button",
967
+ {
968
+ type: "button",
969
+ role: "tab",
970
+ "aria-selected": E === "add",
971
+ "data-editor-tab": "add",
972
+ className: qe(E === "add"),
973
+ onClick: () => te("add"),
974
+ disabled: !t,
975
+ "data-tip": "Add a field, section, panel or widget after the selection",
976
+ children: [
977
+ /* @__PURE__ */ o(ar, { className: "h-3.5 w-3.5" }),
978
+ "Add"
979
+ ]
980
+ }
981
+ ),
982
+ /* @__PURE__ */ h(
983
+ "button",
984
+ {
985
+ type: "button",
986
+ role: "tab",
987
+ "aria-selected": E === "usage",
988
+ "data-editor-tab": "usage",
989
+ className: qe(E === "usage"),
990
+ onClick: () => te("usage"),
991
+ disabled: !t,
992
+ "data-tip": "How this form is used and where it slows people down",
993
+ children: [
994
+ /* @__PURE__ */ o(sr, { className: "h-3.5 w-3.5" }),
995
+ "Usage"
996
+ ]
997
+ }
998
+ )
999
+ ]
1000
+ }
1001
+ ),
1002
+ /* @__PURE__ */ o("div", { className: "min-h-0 flex-1 overflow-y-auto", children: E === "add" && t ? /* @__PURE__ */ o(
1003
+ kr,
1004
+ {
1005
+ bundle: t,
1006
+ collection: r,
1007
+ selected: re,
1008
+ apply: n.apply,
1009
+ onSelect: A
1010
+ }
1011
+ ) : E === "usage" && t ? /* @__PURE__ */ o(
1012
+ mn,
1013
+ {
1014
+ bundle: t,
1015
+ collection: r,
1016
+ fields: _,
1017
+ apply: n.apply,
1018
+ showFill: M,
1019
+ onShowFill: J,
1020
+ onOpenLayout: ee
1021
+ }
1022
+ ) : /* @__PURE__ */ o(
1023
+ Ao,
1024
+ {
1025
+ collection: r,
1026
+ currentId: u,
1027
+ onOpen: ee,
1028
+ settingsOpen: V === "settings",
1029
+ onSettings: () => N("settings"),
1030
+ dropTargets: !0
1031
+ }
1032
+ ) })
1033
+ ]
1034
+ }
1035
+ ),
1036
+ st && t && /* @__PURE__ */ o(
1037
+ "aside",
1038
+ {
1039
+ "data-editor-outline-panel": "",
1040
+ className: "flex w-[260px] shrink-0 flex-col border-r border-slate-200 bg-white dark:border-border dark:bg-card",
1041
+ children: /* @__PURE__ */ o(
1042
+ Do,
294
1043
  {
295
- type: "button",
296
- role: "tab",
297
- "aria-selected": y === "add",
298
- "data-editor-tab": "add",
299
- className: Y(y === "add"),
300
- onClick: () => k("add"),
301
- disabled: !o,
302
- "data-tip": "Add a field, section, panel or widget after the selection",
303
- children: [
304
- /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5" }),
305
- "Add"
306
- ]
1044
+ bundle: t,
1045
+ nodes: x.nodes,
1046
+ selection: y,
1047
+ onPick: x.selectAndReveal,
1048
+ onMoved: Ze,
1049
+ apply: n.apply,
1050
+ onClose: () => x.setOutlineOpen(!1)
307
1051
  }
308
1052
  )
309
- ]
310
- }
311
- ),
312
- /* @__PURE__ */ s("div", { className: "min-h-0 flex-1 overflow-y-auto", children: y === "add" && o ? /* @__PURE__ */ s(
313
- ge,
314
- {
315
- bundle: o,
316
- collection: e,
317
- selected: x,
318
- apply: a.apply,
319
- onSelect: z
320
- }
321
- ) : /* @__PURE__ */ s(
322
- Pe,
323
- {
324
- collection: e,
325
- currentId: i,
326
- onOpen: B,
327
- settingsOpen: I === "settings",
328
- onSettings: () => w("settings")
329
- }
330
- ) })
331
- ] }),
332
- /* @__PURE__ */ s("main", { className: "min-w-0 flex-1 overflow-y-auto", children: o ? /* @__PURE__ */ s(
333
- Ye,
334
- {
335
- collection: e,
336
- bundle: o,
337
- parent: K,
338
- preview: S,
339
- record: te,
340
- selected: x,
341
- onSelect: z,
342
- showHidden: F,
343
- apply: a.apply,
344
- whenIdle: a.whenIdle
345
- }
346
- ) : a.error ? /* @__PURE__ */ s("p", { className: "p-6 text-[13px] text-red-700 dark:text-red-300", children: a.error }) : /* @__PURE__ */ f("div", { className: "flex flex-col gap-3 p-6", children: [
347
- /* @__PURE__ */ s(j, { className: "h-10 w-full rounded-lg" }),
348
- /* @__PURE__ */ s(j, { className: "h-48 w-full rounded-lg" })
349
- ] }) }),
350
- /* @__PURE__ */ s(
351
- "aside",
352
- {
353
- "data-editor-inspector": "",
354
- className: "flex w-[344px] shrink-0 flex-col overflow-hidden border-l border-slate-200 bg-white dark:border-border dark:bg-card",
355
- children: o && (I === "settings" ? /* @__PURE__ */ s(
356
- $e,
357
- {
358
- bundle: o,
359
- apply: a.apply,
360
- flush: a.flush,
361
- collection: e,
362
- previewRoleId: S.roleId,
363
- onPreviewRoleChange: ae
364
1053
  }
365
- ) : /* @__PURE__ */ s(
366
- ze,
1054
+ ),
1055
+ /* @__PURE__ */ h("main", { className: "min-w-0 flex-1 overflow-y-auto", children: [
1056
+ K === "canvas" && /* @__PURE__ */ o(oo, { editor: q }),
1057
+ Z.compare && (K === "canvas" || !w) && /* @__PURE__ */ o(Ir, { compare: Z.compare, onClose: Z.close }),
1058
+ t && w && K === "states" ? /* @__PURE__ */ o(
1059
+ Lo,
1060
+ {
1061
+ bundle: t,
1062
+ parent: T,
1063
+ collection: r,
1064
+ apply: n.apply,
1065
+ onSelect: A
1066
+ }
1067
+ ) : t && w && K === "roles" ? /* @__PURE__ */ o(
1068
+ Po,
1069
+ {
1070
+ bundle: t,
1071
+ parent: T,
1072
+ apply: n.apply,
1073
+ onSelect: A
1074
+ }
1075
+ ) : t && w && K === "table" ? /* @__PURE__ */ o(
1076
+ Ho,
1077
+ {
1078
+ bundle: t,
1079
+ collection: r,
1080
+ apply: n.apply,
1081
+ flush: n.flush,
1082
+ selection: y,
1083
+ onSelect: A,
1084
+ onSelection: L
1085
+ }
1086
+ ) : t ? /* @__PURE__ */ o(
1087
+ "div",
1088
+ {
1089
+ "data-canvas-density": x.compact && w ? "compact" : "normal",
1090
+ style: x.compact && w ? { zoom: Mo } : void 0,
1091
+ className: G(
1092
+ "min-h-full",
1093
+ so(Ee, Fe),
1094
+ Ee && !Fe && "bg-background text-foreground"
1095
+ ),
1096
+ children: /* @__PURE__ */ o(
1097
+ Yo,
1098
+ {
1099
+ collection: r,
1100
+ bundle: t,
1101
+ parent: T,
1102
+ preview: D,
1103
+ onPreview: Y,
1104
+ record: k,
1105
+ fields: _,
1106
+ renderPane: (e) => /* @__PURE__ */ o(
1107
+ Ln,
1108
+ {
1109
+ collection: r,
1110
+ bundle: t,
1111
+ parent: T,
1112
+ roleId: e.roleId,
1113
+ stateKey: e.stateKey,
1114
+ marks: Et(e.marks),
1115
+ overlay: q.overlay(e.overlay),
1116
+ ruleMarks: Ut,
1117
+ ghost: zt,
1118
+ deps: ke.deps,
1119
+ noDnd: e.noDnd,
1120
+ record: e.record,
1121
+ selected: re,
1122
+ selection: y,
1123
+ onSelect: qt,
1124
+ showHidden: ge,
1125
+ fold: x.fold,
1126
+ reveal: x.reveal,
1127
+ apply: n.apply,
1128
+ whenIdle: n.whenIdle,
1129
+ fillRate: Te,
1130
+ unsaved: Wt,
1131
+ peers: Ht,
1132
+ compare: Z.compare,
1133
+ lastChanges: Z.compare ? void 0 : Lt
1134
+ }
1135
+ )
1136
+ }
1137
+ )
1138
+ }
1139
+ ) : n.error ? /* @__PURE__ */ o("p", { className: "p-6 text-[13px] text-red-700 dark:text-red-300", children: n.error }) : /* @__PURE__ */ h("div", { className: "flex flex-col gap-3 p-6", children: [
1140
+ /* @__PURE__ */ o(gt, { className: "h-10 w-full rounded-lg" }),
1141
+ /* @__PURE__ */ o(gt, { className: "h-48 w-full rounded-lg" })
1142
+ ] })
1143
+ ] }),
1144
+ /* @__PURE__ */ o(
1145
+ "aside",
367
1146
  {
368
- bundle: o,
369
- target: x,
370
- apply: a.apply,
371
- flush: a.flush,
372
- collection: e,
373
- openLayout: B
1147
+ "data-editor-inspector": "",
1148
+ className: "flex w-[344px] shrink-0 flex-col overflow-hidden border-l border-slate-200 bg-white dark:border-border dark:bg-card",
1149
+ children: t && (V === "ask" ? /* @__PURE__ */ o(
1150
+ Tr,
1151
+ {
1152
+ layoutId: u,
1153
+ layoutName: xe,
1154
+ kind: nn(t.layout),
1155
+ bundle: t,
1156
+ thread: Ce,
1157
+ setThread: he,
1158
+ pending: ve,
1159
+ onPendingTaken: () => ce(null),
1160
+ jump: Yt,
1161
+ onCite: Zt,
1162
+ recordId: ((yt = D.record) == null ? void 0 : yt.id) ?? null
1163
+ }
1164
+ ) : V === "checks" ? /* @__PURE__ */ o(
1165
+ Oo,
1166
+ {
1167
+ findings: oe.findings,
1168
+ health: oe.health,
1169
+ ready: oe.ready,
1170
+ onSelect: (e) => L([e]),
1171
+ apply: n.apply,
1172
+ onOpenAiReview: p.aiReviewSlot ? () => N("settings") : void 0
1173
+ }
1174
+ ) : V === "settings" ? /* @__PURE__ */ o(
1175
+ wn,
1176
+ {
1177
+ bundle: t,
1178
+ apply: n.apply,
1179
+ flush: n.flush,
1180
+ collection: r,
1181
+ previewRoleId: D.roleId,
1182
+ onPreviewRoleChange: Qt,
1183
+ onAskWhere: p.isAdmin ? (e) => {
1184
+ ce(e), N("ask");
1185
+ } : void 0
1186
+ }
1187
+ ) : y.length > 1 ? /* @__PURE__ */ o(
1188
+ xo,
1189
+ {
1190
+ bundle: t,
1191
+ selection: y,
1192
+ apply: n.apply,
1193
+ collection: r,
1194
+ onSelection: L
1195
+ }
1196
+ ) : /* @__PURE__ */ o(
1197
+ xn,
1198
+ {
1199
+ bundle: t,
1200
+ target: re,
1201
+ apply: n.apply,
1202
+ flush: n.flush,
1203
+ collection: r,
1204
+ openLayout: ee,
1205
+ onSelect: x.selectAndReveal
1206
+ }
1207
+ ))
374
1208
  }
375
- ))
376
- }
377
- )
378
- ] }) })
1209
+ )
1210
+ ] })
1211
+ }
1212
+ ),
1213
+ /* @__PURE__ */ o(
1214
+ tn,
1215
+ {
1216
+ bundle: t,
1217
+ selection: y,
1218
+ apply: n.apply,
1219
+ onSelection: L,
1220
+ rootRef: U
1221
+ }
1222
+ ),
1223
+ /* @__PURE__ */ o(
1224
+ un,
1225
+ {
1226
+ request: Kt,
1227
+ count: n.unsavedCount,
1228
+ onSave: Dt,
1229
+ onDiscard: n.discard,
1230
+ onKeep: () => je(null),
1231
+ note: F ? /* @__PURE__ */ o(_r, { policy: F, value: me, onChange: Ne }) : void 0,
1232
+ canSave: Dr(F, me)
1233
+ }
1234
+ ),
1235
+ F && ze && /* @__PURE__ */ o(
1236
+ Mr,
1237
+ {
1238
+ open: !0,
1239
+ anchor: ze,
1240
+ policy: F,
1241
+ intro: X ? Tt(X) : void 0,
1242
+ count: n.unsavedCount,
1243
+ value: me,
1244
+ onChange: Ne,
1245
+ onSave: He,
1246
+ onClose: () => Ve(null)
1247
+ }
1248
+ ),
1249
+ rt && /* @__PURE__ */ o(
1250
+ Ur,
1251
+ {
1252
+ anchor: rt,
1253
+ steps: n.unsavedSteps,
1254
+ exists: (e) => !!t && Be(e, t, T),
1255
+ describe: (e) => Ct(e, t, _),
1256
+ onJump: (e) => {
1257
+ be(null), ot(e);
1258
+ },
1259
+ onSettings: () => {
1260
+ be(null), N("settings");
1261
+ },
1262
+ onClose: () => be(null)
1263
+ }
1264
+ )
379
1265
  ]
380
1266
  }
381
1267
  );
382
- if (!b) return M;
383
- const G = c ?? (D ? be(D) ?? document.body : null);
384
- return /* @__PURE__ */ f(V, { children: [
385
- /* @__PURE__ */ s("span", { ref: re, hidden: !0, "data-layout-editor-marker": "" }),
386
- G && me(M, G)
1268
+ if (!ae)
1269
+ return /* @__PURE__ */ o(wt.Provider, { value: Ie, children: lt });
1270
+ const dt = c ?? (Le ? gr(Le) ?? document.body : null);
1271
+ return /* @__PURE__ */ h(de, { children: [
1272
+ /* @__PURE__ */ o("span", { ref: _t, hidden: !0, "data-layout-editor-marker": "" }),
1273
+ /* @__PURE__ */ o(wt.Provider, { value: Ie, children: dt && ur(lt, dt) })
387
1274
  ] });
388
1275
  }
1276
+ function Tt(r) {
1277
+ const l = r.reason.trim() ? `: ${r.reason.trim()}` : "";
1278
+ return `Frozen until ${hr(r.until)}${l}. Saving asks for an override note, kept in History.`;
1279
+ }
389
1280
  export {
390
- kt as LayoutEditor,
391
- X as isTyping,
392
- Qe as targetExists
1281
+ us as LayoutEditor,
1282
+ $e as isTyping,
1283
+ Be as targetExists
393
1284
  };