@fluidgrids/fe-sdk 0.0.0-stage → 2026.1203.7

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 (323) hide show
  1. package/README.md +564 -2
  2. package/dist/ActivityOptionsFields-C2u-hY2U.js +142 -0
  3. package/dist/AiStudioPage-B_hNTj-_.js +1137 -0
  4. package/dist/ApprovalInboxPage-ClITra3n.js +1312 -0
  5. package/dist/ChoiceSelect-LkK-uS9J.js +65 -0
  6. package/dist/ConfirmActionDialog-DHWTDRbp.js +31 -0
  7. package/dist/ConnectionFormDialog-C0kDgcrZ.js +153 -0
  8. package/dist/CreateFluidgridsTagDocument-Dtp9KPLJ.js +1055 -0
  9. package/dist/DataSinkDashboardPage-b4ezeqa6.js +278 -0
  10. package/dist/DataTablesPage-C1d9YGHz.js +5575 -0
  11. package/dist/DateTimeField-B1qR4ruo.js +51 -0
  12. package/dist/Disclosure-BNKij7-v.js +45 -0
  13. package/dist/ElementLibraryPage-8jNO6YmE.js +2256 -0
  14. package/dist/ElementLibrarySequenceDocument-B-W8SPzn.js +3979 -0
  15. package/dist/EnsureThemeProvider-BvlNjAd0.js +24 -0
  16. package/dist/EntityTagBadge-1OlP6p0c.js +25 -0
  17. package/dist/EntityTagPicker-BBrU5cE0.js +137 -0
  18. package/dist/ExecuteStepDocument-B4j1mdRT.js +189 -0
  19. package/dist/ExecutionDetailDocument-D6QuM-kp.js +875 -0
  20. package/dist/ExecutionDetailPage-D4CBtFdo.js +12217 -0
  21. package/dist/ExecutionDetailPage-DvQ667OE.d.ts +10 -0
  22. package/dist/ExecutionStatusBadge-BsDVor9t.js +221 -0
  23. package/dist/ExecutionsListDocument-Dan7ZiqB.js +459 -0
  24. package/dist/ExecutionsListPage-B3XT8ITL.js +4307 -0
  25. package/dist/FailureTriagePanel-DOJMaJ0n.js +1285 -0
  26. package/dist/FileDownloadUrlDocument-CVOYKcL5.js +92 -0
  27. package/dist/FluidGridsDocsLink-bX0Hnhxr.js +66 -0
  28. package/dist/FluidGridsMark-CE2blT7K.js +74 -0
  29. package/dist/HeldLoadRegion-BtTxbvOW.js +34 -0
  30. package/dist/HistoryPage-BLoRpJ1R.d.ts +6 -0
  31. package/dist/HistoryPage-BSBISXoj.js +2835 -0
  32. package/dist/Icon-BtQ0HXLh.js +160 -0
  33. package/dist/InsightsPage-D7ybj8N9.js +11245 -0
  34. package/dist/IsolationSetting-vy911E8b.js +1153 -0
  35. package/dist/LibraryParts-DOeNgR8A.js +413 -0
  36. package/dist/ManagedAiPolicyAuthority-BxwJ3ptd.js +40 -0
  37. package/dist/ManagedAiPolicyAuthority-DM3t3wNr.d.ts +18 -0
  38. package/dist/ManagedAiPolicyAuthorityContext-CNkxIOZ1.js +10 -0
  39. package/dist/McpTriggerServers-BCPCAOWB.js +459 -0
  40. package/dist/MissingNodesInstallModal-rO_SEDrC.js +224 -0
  41. package/dist/NavigationV2Provider-DCDt35eG.js +17 -0
  42. package/dist/NodeSchemaIntrospectionDocument-C1vAIcHd.js +95 -0
  43. package/dist/NodesPage-DEbnz9iU.d.ts +6 -0
  44. package/dist/NodesPage-O7KeeKtd.js +653 -0
  45. package/dist/OfflineIcon-TwMKYWjA.js +207 -0
  46. package/dist/OpenTemplateAsCodeButton-BhWJWIF3.js +94 -0
  47. package/dist/PaidTemplateConfirm-_G3ag6S4.js +28 -0
  48. package/dist/PublishCustomNodeAction-CIySbK4c.js +134 -0
  49. package/dist/RecordTaskDialog-BkpCDvhR.js +2078 -0
  50. package/dist/RunActionsMenu-DodOgIQm.js +59 -0
  51. package/dist/RunnerStatusPill-C1v967iq.js +24 -0
  52. package/dist/RunnersPage-dB0RSdY_.js +1929 -0
  53. package/dist/SandboxRuntimeExhaustedNotice-BFOIF93C.js +120 -0
  54. package/dist/SchedulesPage-DPWr1yvf.js +1607 -0
  55. package/dist/SearchBox-BGtYjvfs.js +49 -0
  56. package/dist/SequenceEditor-CFiHeHkR.js +497 -0
  57. package/dist/SettingsPage-0CQBNPZV.js +8695 -0
  58. package/dist/StewardPages-DAJhepen.js +47 -0
  59. package/dist/StewardRunImportPanel-Kva2DO0u.js +2844 -0
  60. package/dist/StoreTemplateCardCompact-CHn5kP7A.js +2166 -0
  61. package/dist/TagFilterSelect-CyA8QrS7.js +42 -0
  62. package/dist/TaskQueuesPage-DdnDCyat.js +3571 -0
  63. package/dist/TechnicalDetails-B0Oi4aZw.js +19 -0
  64. package/dist/TemplateConfigurationModal-CdvCYJLM.js +332 -0
  65. package/dist/TemplateDetailPanel-CbiKciuB.js +222 -0
  66. package/dist/TemplatePreview-cx7-NOeG.js +868 -0
  67. package/dist/TemplatesPage-BG3H-6v6.d.ts +10 -0
  68. package/dist/TemplatesPage-BVQpGYIV.js +3251 -0
  69. package/dist/TerminateExecutionDocument-B_HKNVrN.js +581 -0
  70. package/dist/TranslationBridge-Bd4aJKMs.d.ts +11 -0
  71. package/dist/TranslationBridge-Da-TPgQm.js +68 -0
  72. package/dist/TriggerWorkflowDocument-D9Km2Vv2.js +460 -0
  73. package/dist/UiSequencePickerSequenceDocument-BSYnSDV7.js +607 -0
  74. package/dist/UiStepScreenshot-Qh4QMyUp.js +146 -0
  75. package/dist/UsageTimeSeriesDocument-DcInx9-z.js +177 -0
  76. package/dist/VariablesPage-ChfGuW22.js +2243 -0
  77. package/dist/VersionDiffDialog-Bd2AeUwf.js +1702 -0
  78. package/dist/VersionLifecycleBar-BBeWVtz-.js +143 -0
  79. package/dist/WebhookDeliveriesPage-D66bua0j.js +1563 -0
  80. package/dist/WorkflowBuilder-B6wQD1TK.js +539 -0
  81. package/dist/WorkflowBuilder-DR4ku8Tr.js +1611 -0
  82. package/dist/WorkflowDefinitionDocument-DZLbTPUZ.js +321 -0
  83. package/dist/WorkflowEmbed-BXfFGy0i.js +708 -0
  84. package/dist/WorkflowEmbed-Cbqe1s1z.d.ts +6 -0
  85. package/dist/WorkflowPinnedDataDocument-BODT5omd.js +782 -0
  86. package/dist/WorkflowProposalCard-BruukdeF.js +96 -0
  87. package/dist/WorkflowProposalDocument-BdUbsrd0.js +620 -0
  88. package/dist/WorkflowSearchRedirect-C7zJ2MKH.js +40 -0
  89. package/dist/WorkflowSettingsDrawer-MVU1BKfY.d.ts +18 -0
  90. package/dist/WorkflowSettingsDrawer-gazs97WR.js +196 -0
  91. package/dist/WorkflowShareDialog-e8jJtLjU.js +469 -0
  92. package/dist/WorkflowVersionsDocument-DRVOp8Uj.js +3213 -0
  93. package/dist/WorkflowsList--hR2_8gf.js +4593 -0
  94. package/dist/WorkflowsList-CcNDQge5.d.ts +6 -0
  95. package/dist/WorkflowsListPageDocument-CnzcQm_o.js +934 -0
  96. package/dist/addonCatalog-CbZS4deh.js +58 -0
  97. package/dist/addonCatalog-sjlonAmR.d.ts +15 -0
  98. package/dist/addons.d.ts +3 -0
  99. package/dist/addons.js +4 -0
  100. package/dist/agent-form-Bfvm32j1.js +83 -0
  101. package/dist/agent-tools.d.ts +3 -0
  102. package/dist/agent-tools.js +5 -0
  103. package/dist/agentTools-CyL7DLOF.js +320 -0
  104. package/dist/ai-usage-BrxDgvdR.js +240 -0
  105. package/dist/aiCreditsBridge-BuE92tKo.js +49 -0
  106. package/dist/api-BKq-nIOZ.js +2286 -0
  107. package/dist/api-Ol7I8NxE.js +8289 -0
  108. package/dist/apollo-type-policies.d.ts +11 -0
  109. package/dist/apollo-type-policies.js +64 -0
  110. package/dist/askAboutBridge-ByYsQams.js +106 -0
  111. package/dist/askQuestions-Cmx7VnMm.js +742 -0
  112. package/dist/assert-rules-lfYEMc99.js +318 -0
  113. package/dist/assistant.d.ts +94 -0
  114. package/dist/assistant.js +99 -0
  115. package/dist/attach-node-helpers-HDKQOtrD.js +32 -0
  116. package/dist/badge-CXfPhoMH.js +26 -0
  117. package/dist/basil.generated-BK-EHbwN.js +10 -0
  118. package/dist/browser-steps-DMpS5TyB.js +533 -0
  119. package/dist/builderTimings-pvGnK1m-.js +510 -0
  120. package/dist/button-DG7y_FVJ.js +48 -0
  121. package/dist/canvasNoteTools-BxuP_AYO.js +137 -0
  122. package/dist/card-Bomy_1UG.js +44 -0
  123. package/dist/catalogGrid-BOrfMgi-.js +41 -0
  124. package/dist/channel-CPyQ1NR1.js +212 -0
  125. package/dist/chips-CvNrYJZa.js +27 -0
  126. package/dist/client-holder-C0M5Cfwl.js +68 -0
  127. package/dist/cn-QqidFIgr.js +10 -0
  128. package/dist/code-editor-diagnostics-Zr0cIcx1.js +46 -0
  129. package/dist/code-editor-field-x_JrY8KR.js +113 -0
  130. package/dist/codec-client-DPuD6mw7.js +515 -0
  131. package/dist/conditionBuilder-DwfEF0Q-.js +1144 -0
  132. package/dist/config-DO68jw5k.js +322 -0
  133. package/dist/constants-DgbVc24O.d.ts +296 -0
  134. package/dist/constants-DlRnHBfQ.js +217 -0
  135. package/dist/convert-browser-action-pfecelF7.js +347 -0
  136. package/dist/convert-dialog-B_o22NiJ.js +382 -0
  137. package/dist/create-workflow-first-Azg3JUdX.js +120 -0
  138. package/dist/definition-canvas-Bsda-rDT.js +31 -0
  139. package/dist/dialog-BVd152GS.js +94 -0
  140. package/dist/durable-nodes-BXyYCLxT.js +91 -0
  141. package/dist/duration-CDb7-mT_.js +33 -0
  142. package/dist/edge-mapper-wEAdGVU2.js +4477 -0
  143. package/dist/element-library-DkSlg_VE.js +727 -0
  144. package/dist/entities-I_0kio3q.js +38 -0
  145. package/dist/error-advice-QLr5NCm7.js +65 -0
  146. package/dist/errors-ClKb5sEt.js +188 -0
  147. package/dist/executions.d.ts +3 -0
  148. package/dist/executions.js +5 -0
  149. package/dist/feature-flags-B2qetXKd.js +385 -0
  150. package/dist/field-label-DPZRmE_B.js +153 -0
  151. package/dist/firstWorkflow-C_h0KMB2.js +133 -0
  152. package/dist/flags.d.ts +3 -0
  153. package/dist/flags.js +4 -0
  154. package/dist/flow-builder-DIvLOhz0.js +28038 -0
  155. package/dist/flow-store-holder-CUN7Terz.js +52 -0
  156. package/dist/fluent.generated-CA_e6-4l.js +14 -0
  157. package/dist/fluidgridsEvents-bbEQbwU6.js +175 -0
  158. package/dist/fluidgridsTheme-DUhvOgoy.js +297 -0
  159. package/dist/global-client-BQPuFrFa.js +433 -0
  160. package/dist/global-operations-BG6YgxrM.js +136 -0
  161. package/dist/graphql-types-UTYtujY9.js +21358 -0
  162. package/dist/history.d.ts +3 -0
  163. package/dist/history.js +4 -0
  164. package/dist/index-AoJAa5vU.d.ts +164958 -0
  165. package/dist/index-DEMT3iAM.d.ts +120 -0
  166. package/dist/index-ROZzNGyY.d.ts +76 -0
  167. package/dist/index.d.ts +20 -0
  168. package/dist/index.js +8123 -0
  169. package/dist/ion.generated-mbajjcAg.js +10 -0
  170. package/dist/label-Lzb8ZXf_.js +29 -0
  171. package/dist/labels-rXd9gYQz.js +1236 -0
  172. package/dist/liveCanvas-D5ytXDp8.js +103 -0
  173. package/dist/logos.generated-X6_0kjVR.js +21 -0
  174. package/dist/logs-panel-Cw0DkG0l.js +468 -0
  175. package/dist/lucide.generated-B6NVd3GT.js +29 -0
  176. package/dist/marksStore-a9oIMMot.js +175 -0
  177. package/dist/mcp-trigger-D0nRdvq5.js +307 -0
  178. package/dist/mdi.generated-D1BV74d6.js +292 -0
  179. package/dist/menus-CU3hDGYl.js +160 -0
  180. package/dist/mynaui.generated-DMWr5cXz.js +66 -0
  181. package/dist/navigation-v2.d.ts +3 -0
  182. package/dist/navigation-v2.js +5 -0
  183. package/dist/node-detail-view-Cgm5H1P-.js +1372 -0
  184. package/dist/node-editor-tab-body-CZ0fVuVP.js +187 -0
  185. package/dist/node-operation-selection-CdV3KI_V.js +3534 -0
  186. package/dist/node-registry-refresh-s3okf83X.js +27 -0
  187. package/dist/node-role-TMbnkmeP.js +132 -0
  188. package/dist/node-type-icon-BZa8n4iG.js +33 -0
  189. package/dist/nodes.d.ts +3 -0
  190. package/dist/nodes.js +4 -0
  191. package/dist/notesKey-5EaREBGA.js +12 -0
  192. package/dist/observability.d.ts +3 -0
  193. package/dist/observability.js +5 -0
  194. package/dist/offset-pages-zghoClB3.js +55 -0
  195. package/dist/operations-BBmT9ToP.js +663 -0
  196. package/dist/operations-WxRJWeqO.js +3133 -0
  197. package/dist/output-files-Ba8bu5lv.js +196 -0
  198. package/dist/page-operation-DrWuhd6Y.js +129 -0
  199. package/dist/page-twins.d.ts +13 -0
  200. package/dist/page-twins.js +186 -0
  201. package/dist/pageControlSpecs-DZJ9K37m.js +134 -0
  202. package/dist/pageControlsBridge-0pX9s-3k.js +54 -0
  203. package/dist/pageControlsBridge-DAuT3w7L.d.ts +36 -0
  204. package/dist/panels-PfBBAToE.js +346 -0
  205. package/dist/parts-B7fBcw-B.js +346 -0
  206. package/dist/popover-Dms9Vz3j.js +3389 -0
  207. package/dist/preloadable-lazy-Pp47mqQ9.js +65 -0
  208. package/dist/proactive.d.ts +66 -0
  209. package/dist/proactive.js +237 -0
  210. package/dist/quick-config-panel-DFd77xho.js +451 -0
  211. package/dist/quota-DeA_CJ2e.js +175 -0
  212. package/dist/quota.d.ts +3 -0
  213. package/dist/quota.js +4 -0
  214. package/dist/read-only-context-Dt9N9SIG.js +18 -0
  215. package/dist/relative-time-Dxt8ZIIu.js +55 -0
  216. package/dist/results-CwK_yDxK.js +325 -0
  217. package/dist/rolldown-runtime-hDbaFkMy.js +18 -0
  218. package/dist/route-data.d.ts +12 -0
  219. package/dist/route-data.js +69 -0
  220. package/dist/route-match-C-0_EnAt.d.ts +5 -0
  221. package/dist/route-match-DMkUICYV.js +41 -0
  222. package/dist/route-preload-C4DlGoCd.js +120 -0
  223. package/dist/run-display-UjLAoYqQ.js +81 -0
  224. package/dist/run-history-arGiHzGU.js +285 -0
  225. package/dist/run-list-links-DJn4Mf1T.js +98 -0
  226. package/dist/run-mode-USmM0-Uo.js +82 -0
  227. package/dist/run-parity-CWXqEJqM.js +144 -0
  228. package/dist/runsQuota-B6SyTbne.js +100 -0
  229. package/dist/runsQuota-DsniKiSg.d.ts +20 -0
  230. package/dist/safe-expression-Cw7-SCsm.js +1251 -0
  231. package/dist/save-status-store-C7nEYpfb.js +631 -0
  232. package/dist/schedule-panel-B4GYXzXQ.js +13774 -0
  233. package/dist/schedule-rules-ggVKRkBH.js +358 -0
  234. package/dist/secrets-Re_wSiE3.js +153 -0
  235. package/dist/settings.d.ts +4 -0
  236. package/dist/settings.js +6 -0
  237. package/dist/shared-DAWGGMSM.js +177 -0
  238. package/dist/sidebar-node-editor-6eSSgCzc.js +178 -0
  239. package/dist/solar.generated-CGYuUQAC.js +10 -0
  240. package/dist/stableTabbedDialog-BBhrfXGe.js +20 -0
  241. package/dist/start-url-CT6Yz96K.js +24 -0
  242. package/dist/status-CessxGpm.js +55 -0
  243. package/dist/store-icon-OctYp5zP.js +155 -0
  244. package/dist/styles-WGmTnZ2n.js +26 -0
  245. package/dist/styles.css +139 -0
  246. package/dist/svg-spinners.generated-CIPT7IhM.js +10 -0
  247. package/dist/template-code-CzN6JWNV.js +191 -0
  248. package/dist/template-graph-DLF9dygU.js +20 -0
  249. package/dist/template-preview-DcIIKOOL.js +32 -0
  250. package/dist/template-price-CdUHZRMF.js +40 -0
  251. package/dist/templates.d.ts +3 -0
  252. package/dist/templates.js +5 -0
  253. package/dist/theme-provider-CntfC4_i.js +23 -0
  254. package/dist/transient-DgZfhDfN.js +57 -0
  255. package/dist/typed-calls-C5tO03wq.js +26 -0
  256. package/dist/ui-script-By74Guk3.js +1094 -0
  257. package/dist/ui-script-editor-CqPu2bCN.js +2447 -0
  258. package/dist/ui-step-fix-8uM2_Hft.js +67 -0
  259. package/dist/ui-step-fix-store-CcO1FdRx.js +19 -0
  260. package/dist/ui-step-run-context-o7bLE6KP.js +46 -0
  261. package/dist/ui-target-editor-D2JhB_lD.js +673 -0
  262. package/dist/uiMarkTools-CSznnO1i.js +1054 -0
  263. package/dist/upgradePrompt-BAFBKKW5.js +72 -0
  264. package/dist/use-bare-node-registry-O6mKJO_n.js +11498 -0
  265. package/dist/use-browser-available-hj8wc3Kb.js +241 -0
  266. package/dist/use-edge-mapper-schemas-Bonofxow.js +496 -0
  267. package/dist/use-extension-bridge-B9ZreOkQ.js +608 -0
  268. package/dist/use-mobile-BTqCUjzS.js +27 -0
  269. package/dist/use-sdk-query-C697xZVv.js +116 -0
  270. package/dist/use-workflow-code-editor-CFoRFrZ5.js +753 -0
  271. package/dist/useActionParam-B2tU2BlY.js +85 -0
  272. package/dist/useAgentTokenStream-Bko_J0d0.js +4217 -0
  273. package/dist/useBrowserClients-3v95-gSh.js +103 -0
  274. package/dist/useCodeWorkflowInsights-w0tz9Ap_.js +600 -0
  275. package/dist/useConnections-DsgEJs05.js +439 -0
  276. package/dist/useDebouncedValue-BFekcv6n.js +18 -0
  277. package/dist/useDurableParity-8fnMZmBc.js +1787 -0
  278. package/dist/useEntityTags-D0spL6Ut.js +460 -0
  279. package/dist/useExecutions-2u5nGJJk.js +681 -0
  280. package/dist/useFluidGridsAnalytics-VM8lAi2x.js +238 -0
  281. package/dist/useGlobalStoreClient-BTdhkA2I.js +24 -0
  282. package/dist/useHumanRequests-zlYDp3l1.js +221 -0
  283. package/dist/useNavigationV2-C2WeqN7d.js +29 -0
  284. package/dist/useNavigationV2-DANUmg12.d.ts +9 -0
  285. package/dist/useObservability-BRlQ0tOA.js +285 -0
  286. package/dist/useRequestedProposal-B7uPXfZB.js +51 -0
  287. package/dist/useRunHistory-CXCMUPyf.js +2759 -0
  288. package/dist/useRunLive-D0JvVZT2.js +1060 -0
  289. package/dist/useRunnerList-Dbi59i1K.js +446 -0
  290. package/dist/useRunners-URUc5quU.js +173 -0
  291. package/dist/useRunsPage-DG656UCK.js +2709 -0
  292. package/dist/useVariables-BIelxcWr.js +463 -0
  293. package/dist/useVersionHistoryData-CTjqVw7l.js +292 -0
  294. package/dist/useWorkflowCodeExport-pqxyLHD1.js +522 -0
  295. package/dist/useWorkflowListExport-hcZNvTaB.js +232 -0
  296. package/dist/useWorkflowOrganization-CpBbOrs7.js +1772 -0
  297. package/dist/useWorkflowProposal-BH0VdNMA.js +3280 -0
  298. package/dist/useWorkflows-Cvg-Z_IE.js +1606 -0
  299. package/dist/utils-fvBb5qOD.js +89 -0
  300. package/dist/webhook-deliveries-AvQujaZy.js +99 -0
  301. package/dist/workflow-builder-CJygVkVv.d.ts +2 -0
  302. package/dist/workflow-builder.d.ts +3 -0
  303. package/dist/workflow-builder.js +8 -0
  304. package/dist/workflow-code-transfer-Bsy0JKAZ.js +323 -0
  305. package/dist/workflow-embed.d.ts +3 -0
  306. package/dist/workflow-embed.js +4 -0
  307. package/dist/workflow-git-sync--K9ZsPDC.js +263 -0
  308. package/dist/workflow-host.d.ts +6 -0
  309. package/dist/workflow-host.js +11 -0
  310. package/dist/workflow-pages-D-7ByLTB.d.ts +68 -0
  311. package/dist/workflow-pages.d.ts +3 -0
  312. package/dist/workflow-pages.js +115 -0
  313. package/dist/workflow-preview-canvas-CO8yzdE3.js +848 -0
  314. package/dist/workflow-preview.d.ts +65 -0
  315. package/dist/workflow-preview.js +4 -0
  316. package/dist/workflow-route.d.ts +33 -0
  317. package/dist/workflow-route.js +4 -0
  318. package/dist/workflow-save-state-D0l-DkLf.js +767 -0
  319. package/dist/workflow-transfer-CQnQC-ke.js +104 -0
  320. package/dist/workflowRouteData-BkfVOc-O.js +169 -0
  321. package/dist/workflows-list.d.ts +10 -0
  322. package/dist/workflows-list.js +5 -0
  323. package/package.json +320 -4
@@ -0,0 +1,2256 @@
1
+ "use client";
2
+ import { r as useTr } from "./TranslationBridge-Da-TPgQm.js";
3
+ import { S as saveUiScreen, T as updateUiApplication, _ as fetchUiElements, a as usePagedLibraryList, c as createUiApplication, f as fetchUiApplication, g as fetchUiElementUsage, h as fetchUiElementHealth, i as SectionTitle, l as deleteUiApplication, m as fetchUiElement, n as LibraryError, o as useLibraryRead, p as fetchUiApplications, r as RpaOffBanner, s as applyUiElementVersion, t as Field, u as deleteUiElement, w as setUiElementStatus, x as saveUiElement, y as fetchUiSharedSequences } from "./LibraryParts-DOeNgR8A.js";
4
+ import { Mt as ApplyUiElementVersionStatus, pV as UiElementStatus } from "./graphql-types-UTYtujY9.js";
5
+ import { M as isPickedTarget, N as readPickedElement, O as usageByWorkflow, S as percentText, T as rpaErrorCode, b as pageOfUrlPattern, c as elementFormValues, d as elementsOnScreen, g as keyFromName, i as applyItemText, l as elementSaveInput, n as LIBRARY_KEY_PATTERN, o as durationText, p as fallbackRuns, r as applyCandidates, s as elementFormKey, u as elementTargetChanged, v as methodShares, x as parseUrlPatterns, y as methodText } from "./element-library-DkSlg_VE.js";
6
+ import { t as UiTargetMethodsEditor } from "./ui-target-editor-D2JhB_lD.js";
7
+ import { t as useFluidGridsAnalytics } from "./useFluidGridsAnalytics-VM8lAi2x.js";
8
+ import { a as MIN_BRIDGE_EXTENSION_VERSION, i as isOperationOpen, n as useBridgeAvailability, o as PICK_CAPABILITIES, r as useBridgeOperation, t as canUseBridgeHere } from "./use-extension-bridge-B9ZreOkQ.js";
9
+ import { t as startUrlOf } from "./start-url-CT6Yz96K.js";
10
+ import { t as readTyped } from "./typed-calls-C5tO03wq.js";
11
+ import { t as FileDownloadUrlDocument } from "./FileDownloadUrlDocument-CVOYKcL5.js";
12
+ import { v as useRpaWebEnabled } from "./feature-flags-B2qetXKd.js";
13
+ import { s as useFluidGridsPermission, t as FLUIDGRIDS_PERMISSIONS } from "./constants-DlRnHBfQ.js";
14
+ import { Suspense, lazy, useCallback, useEffect, useMemo, useState } from "react";
15
+ import { Link, useSearchParams } from "react-router";
16
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
17
+ import { AlertTriangle, AppWindow, ArrowLeft, Boxes, Pencil, Plus, Search, Trash2 } from "lucide-react";
18
+ import { toast } from "sonner";
19
+ import { cn } from "@burdenoff/fe-libs/utils";
20
+ import { Badge, Button, Checkbox, EmptyState, Input, PagePurpose, ResponsiveDialog, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, Skeleton, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemedSelect } from "@burdenoff/fe-libs/ui";
21
+ import { Button as Button$1 } from "@burdenoff/fe-libs/button";
22
+
23
+ // src/modules/element-library/components/ApplicationPanel.tsx
24
+ /**
25
+ * One application of the Element library (spec 19 M4 marker 2): its screens
26
+ * with their elements, and beside them its shared sequences. Applications
27
+ * group screens; screens group elements; an element need not sit on a screen.
28
+ */
29
+ function ElementRow({ element, selected, onSelect }) {
30
+ const tr = useTr();
31
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
32
+ type: "button",
33
+ onClick: onSelect,
34
+ "aria-current": selected ? "true" : void 0,
35
+ className: cn("flex w-full min-w-0 items-center justify-between gap-2 rounded px-2 py-1.5 text-left text-sm", selected ? "bg-primary/10 text-text-primary" : "hover:bg-muted"),
36
+ "data-testid": `element-library-element-row-${element.key}`,
37
+ children: [/* @__PURE__ */ jsx("span", {
38
+ className: "min-w-0 truncate",
39
+ children: element.name
40
+ }), /* @__PURE__ */ jsxs("span", {
41
+ className: "flex shrink-0 items-center gap-1",
42
+ children: [element.status === "DEPRECATED" && /* @__PURE__ */ jsx(Badge, {
43
+ variant: "outline",
44
+ children: tr("fluidgrids.elementLibrary.element.deprecated", "Deprecated")
45
+ }), /* @__PURE__ */ jsxs("span", {
46
+ className: "text-xs text-text-secondary",
47
+ children: ["v", element.currentVersion]
48
+ })]
49
+ })]
50
+ }) });
51
+ }
52
+ function ScreenGroup({ title, screen, elements, selectedElementId, onSelectElement, onNewElement, onEditScreen, access }) {
53
+ const tr = useTr();
54
+ return /* @__PURE__ */ jsxs("div", {
55
+ className: "flex min-w-0 flex-col gap-1 rounded-md border border-border-default p-2",
56
+ "data-testid": `element-library-screen-${screen?.key ?? "none"}`,
57
+ children: [/* @__PURE__ */ jsxs("div", {
58
+ className: "flex min-w-0 items-center justify-between gap-2",
59
+ children: [/* @__PURE__ */ jsxs("div", {
60
+ className: "flex min-w-0 flex-col",
61
+ children: [/* @__PURE__ */ jsx("span", {
62
+ className: "truncate text-sm font-medium text-text-primary",
63
+ children: title
64
+ }), /* @__PURE__ */ jsx("span", {
65
+ className: "text-xs text-text-secondary",
66
+ children: tr("fluidgrids.elementLibrary.screen.count", "{{count}} elements", { count: elements.length })
67
+ })]
68
+ }), access.canUpdate && /* @__PURE__ */ jsxs("div", {
69
+ className: "flex shrink-0 items-center gap-1",
70
+ children: [screen && /* @__PURE__ */ jsx("button", {
71
+ type: "button",
72
+ onClick: () => onEditScreen(screen),
73
+ "aria-label": tr("fluidgrids.elementLibrary.editScreen", "Edit screen"),
74
+ className: "rounded p-1 text-text-secondary hover:bg-muted",
75
+ "data-testid": `element-library-screen-${screen.key}-edit`,
76
+ children: /* @__PURE__ */ jsx(Pencil, {
77
+ className: "size-3.5",
78
+ "aria-hidden": "true"
79
+ })
80
+ }), /* @__PURE__ */ jsx("button", {
81
+ type: "button",
82
+ onClick: () => onNewElement(screen?.id ?? null),
83
+ "aria-label": tr("fluidgrids.elementLibrary.newElement", "New element"),
84
+ className: "rounded p-1 text-text-secondary hover:bg-muted",
85
+ "data-testid": `element-library-screen-${screen?.key ?? "none"}-add`,
86
+ children: /* @__PURE__ */ jsx(Plus, {
87
+ className: "size-3.5",
88
+ "aria-hidden": "true"
89
+ })
90
+ })]
91
+ })]
92
+ }), elements.length > 0 && /* @__PURE__ */ jsx("ul", {
93
+ className: "flex flex-col",
94
+ children: elements.map((element) => /* @__PURE__ */ jsx(ElementRow, {
95
+ element,
96
+ selected: element.id === selectedElementId,
97
+ onSelect: () => onSelectElement(element.id)
98
+ }, element.id))
99
+ })]
100
+ });
101
+ }
102
+ function ElementsTab({ application, elements, selectedElementId, onSelectElement, onNewElement, onNewScreen, onEditScreen, access }) {
103
+ const tr = useTr();
104
+ const unscreened = elementsOnScreen(elements.items, null);
105
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
106
+ access.canUpdate && /* @__PURE__ */ jsxs("div", {
107
+ className: "flex flex-wrap gap-2",
108
+ children: [/* @__PURE__ */ jsxs(Button$1, {
109
+ size: "sm",
110
+ variant: "outline",
111
+ onClick: onNewScreen,
112
+ "data-testid": "element-library-new-screen",
113
+ children: [/* @__PURE__ */ jsx(Plus, {
114
+ className: "mr-1 size-4",
115
+ "aria-hidden": "true"
116
+ }), tr("fluidgrids.elementLibrary.newScreen", "New screen")]
117
+ }), /* @__PURE__ */ jsxs(Button$1, {
118
+ size: "sm",
119
+ variant: "outline",
120
+ onClick: () => onNewElement(null),
121
+ "data-testid": "element-library-new-element",
122
+ children: [/* @__PURE__ */ jsx(Plus, {
123
+ className: "mr-1 size-4",
124
+ "aria-hidden": "true"
125
+ }), tr("fluidgrids.elementLibrary.newElement", "New element")]
126
+ })]
127
+ }),
128
+ /* @__PURE__ */ jsx(LibraryError, {
129
+ error: elements.error,
130
+ testId: "element-library-elements-error"
131
+ }),
132
+ elements.loading && elements.items.length === 0 ? /* @__PURE__ */ jsx(Skeleton, { className: "h-24 w-full" }) : application.screens.length === 0 && elements.items.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
133
+ kind: "first-use",
134
+ size: "panel",
135
+ compact: true,
136
+ icon: null,
137
+ title: tr("fluidgrids.elementLibrary.noElements", "No screens or elements yet"),
138
+ description: tr("fluidgrids.elementLibrary.noElementsDescription", "Add a screen for each page of the app, then save its buttons and fields as elements. The picker in the browser extension saves them here too.")
139
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [application.screens.map((screen) => /* @__PURE__ */ jsx(ScreenGroup, {
140
+ title: screen.name,
141
+ screen,
142
+ elements: elementsOnScreen(elements.items, screen.id),
143
+ selectedElementId,
144
+ onSelectElement,
145
+ onNewElement,
146
+ onEditScreen,
147
+ access
148
+ }, screen.id)), unscreened.length > 0 && /* @__PURE__ */ jsx(ScreenGroup, {
149
+ title: tr("fluidgrids.elementLibrary.noScreen", "No screen"),
150
+ screen: null,
151
+ elements: unscreened,
152
+ selectedElementId,
153
+ onSelectElement,
154
+ onNewElement,
155
+ onEditScreen,
156
+ access
157
+ })] }),
158
+ elements.hasMore && /* @__PURE__ */ jsx(Button$1, {
159
+ size: "sm",
160
+ variant: "outline",
161
+ disabled: elements.loadingMore,
162
+ onClick: () => void elements.loadMore(),
163
+ "data-testid": "element-library-elements-more",
164
+ children: tr("fluidgrids.elementLibrary.loadMore", "Show more")
165
+ })
166
+ ] });
167
+ }
168
+ function SequencesTab({ sequences, selectedSequenceId, onSelectSequence, onNewSequence, access }) {
169
+ const tr = useTr();
170
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
171
+ access.canUpdate && /* @__PURE__ */ jsxs(Button$1, {
172
+ size: "sm",
173
+ variant: "outline",
174
+ className: "self-start",
175
+ onClick: onNewSequence,
176
+ "data-testid": "element-library-new-sequence",
177
+ children: [/* @__PURE__ */ jsx(Plus, {
178
+ className: "mr-1 size-4",
179
+ "aria-hidden": "true"
180
+ }), tr("fluidgrids.elementLibrary.newSequence", "New sequence")]
181
+ }),
182
+ /* @__PURE__ */ jsx(LibraryError, {
183
+ error: sequences.error,
184
+ testId: "element-library-sequences-error"
185
+ }),
186
+ sequences.loading && sequences.items.length === 0 ? /* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full" }) : sequences.items.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
187
+ kind: "first-use",
188
+ size: "panel",
189
+ compact: true,
190
+ icon: null,
191
+ title: tr("fluidgrids.elementLibrary.noSequences", "No shared sequences yet"),
192
+ description: tr("fluidgrids.elementLibrary.noSequencesDescription", "A shared sequence is a set of steps, such as logging in, that any Use Browser step can call.")
193
+ }) : /* @__PURE__ */ jsx("ul", {
194
+ className: "flex flex-col gap-1",
195
+ children: sequences.items.map((sequence) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
196
+ type: "button",
197
+ onClick: () => onSelectSequence(sequence.id),
198
+ "aria-current": sequence.id === selectedSequenceId ? "true" : void 0,
199
+ className: cn("flex w-full min-w-0 flex-col rounded-md border border-border-default p-2 text-left", sequence.id === selectedSequenceId ? "bg-primary/10" : "hover:bg-muted"),
200
+ "data-testid": `element-library-sequence-row-${sequence.key}`,
201
+ children: [/* @__PURE__ */ jsxs("span", {
202
+ className: "flex min-w-0 items-center justify-between gap-2",
203
+ children: [/* @__PURE__ */ jsx("span", {
204
+ className: "truncate text-sm font-medium text-text-primary",
205
+ children: sequence.name
206
+ }), /* @__PURE__ */ jsxs("span", {
207
+ className: "shrink-0 text-xs text-text-secondary",
208
+ children: ["v", sequence.currentVersion]
209
+ })]
210
+ }), sequence.description && /* @__PURE__ */ jsx("span", {
211
+ className: "truncate text-xs text-text-secondary",
212
+ children: sequence.description
213
+ })]
214
+ }) }, sequence.id))
215
+ }),
216
+ sequences.hasMore && /* @__PURE__ */ jsx(Button$1, {
217
+ size: "sm",
218
+ variant: "outline",
219
+ disabled: sequences.loadingMore,
220
+ onClick: () => void sequences.loadMore(),
221
+ "data-testid": "element-library-sequences-more",
222
+ children: tr("fluidgrids.elementLibrary.loadMore", "Show more")
223
+ })
224
+ ] });
225
+ }
226
+ function ApplicationPanel({ application, elements, sequences, tab, onTab, selectedElementId, selectedSequenceId, onSelectElement, onSelectSequence, onNewSequence, onNewElement, onNewScreen, onEditScreen, onEditApplication, onDeleteApplication, onBack, access, actionError }) {
227
+ const tr = useTr();
228
+ return /* @__PURE__ */ jsxs("section", {
229
+ className: "flex min-w-0 flex-col gap-3",
230
+ "aria-label": application.name,
231
+ "data-testid": "element-library-application",
232
+ children: [
233
+ /* @__PURE__ */ jsxs("div", {
234
+ className: "flex min-w-0 flex-col gap-1",
235
+ children: [
236
+ /* @__PURE__ */ jsxs("button", {
237
+ type: "button",
238
+ onClick: onBack,
239
+ className: "flex items-center gap-1 self-start text-xs text-primary hover:underline lg:hidden",
240
+ "data-testid": "element-library-application-back",
241
+ children: [/* @__PURE__ */ jsx(ArrowLeft, {
242
+ className: "size-3.5",
243
+ "aria-hidden": "true"
244
+ }), tr("fluidgrids.elementLibrary.applications", "Applications")]
245
+ }),
246
+ /* @__PURE__ */ jsxs("div", {
247
+ className: "flex min-w-0 flex-wrap items-center justify-between gap-2",
248
+ children: [/* @__PURE__ */ jsx("h2", {
249
+ className: "truncate text-lg font-semibold text-text-primary",
250
+ "data-testid": "element-library-application-title",
251
+ children: application.name
252
+ }), /* @__PURE__ */ jsxs("div", {
253
+ className: "flex shrink-0 items-center gap-1",
254
+ children: [access.canUpdate && /* @__PURE__ */ jsx(Button$1, {
255
+ size: "sm",
256
+ variant: "ghost",
257
+ onClick: onEditApplication,
258
+ "aria-label": tr("fluidgrids.elementLibrary.editApplication", "Edit application"),
259
+ "data-testid": "element-library-application-edit",
260
+ children: /* @__PURE__ */ jsx(Pencil, {
261
+ className: "size-4",
262
+ "aria-hidden": "true"
263
+ })
264
+ }), access.canDelete && /* @__PURE__ */ jsx(Button$1, {
265
+ size: "sm",
266
+ variant: "ghost",
267
+ onClick: onDeleteApplication,
268
+ "aria-label": tr("fluidgrids.elementLibrary.deleteApplication", "Delete application"),
269
+ "data-testid": "element-library-application-delete",
270
+ children: /* @__PURE__ */ jsx(Trash2, {
271
+ className: "size-4",
272
+ "aria-hidden": "true"
273
+ })
274
+ })]
275
+ })]
276
+ }),
277
+ /* @__PURE__ */ jsx("span", {
278
+ className: "break-all font-mono text-xs text-text-secondary",
279
+ children: application.urlPatterns.join(", ")
280
+ })
281
+ ]
282
+ }),
283
+ /* @__PURE__ */ jsx(LibraryError, {
284
+ error: actionError,
285
+ testId: "element-library-application-action-error"
286
+ }),
287
+ /* @__PURE__ */ jsxs(Tabs, {
288
+ value: tab,
289
+ onValueChange: (value) => onTab(value === "sequences" ? "sequences" : "elements"),
290
+ children: [
291
+ /* @__PURE__ */ jsxs(TabsList, {
292
+ className: "w-full justify-start overflow-x-auto",
293
+ children: [/* @__PURE__ */ jsx(TabsTrigger, {
294
+ value: "elements",
295
+ "data-testid": "element-library-tab-elements",
296
+ children: tr("fluidgrids.elementLibrary.tab.elements", "Screens and elements")
297
+ }), /* @__PURE__ */ jsx(TabsTrigger, {
298
+ value: "sequences",
299
+ "data-testid": "element-library-tab-sequences",
300
+ children: tr("fluidgrids.elementLibrary.tab.sequences", "Sequences ({{count}})", { count: sequences.totalCount ?? sequences.items.length })
301
+ })]
302
+ }),
303
+ /* @__PURE__ */ jsx(TabsContent, {
304
+ value: "elements",
305
+ className: "mt-3 flex flex-col gap-2",
306
+ children: /* @__PURE__ */ jsx(ElementsTab, {
307
+ application,
308
+ elements,
309
+ selectedElementId,
310
+ onSelectElement,
311
+ onNewElement,
312
+ onNewScreen,
313
+ onEditScreen,
314
+ access
315
+ })
316
+ }),
317
+ /* @__PURE__ */ jsx(TabsContent, {
318
+ value: "sequences",
319
+ className: "mt-3 flex flex-col gap-2",
320
+ children: /* @__PURE__ */ jsx(SequencesTab, {
321
+ sequences,
322
+ selectedSequenceId,
323
+ onSelectSequence,
324
+ onNewSequence,
325
+ access
326
+ })
327
+ })
328
+ ]
329
+ })
330
+ ]
331
+ });
332
+ }
333
+
334
+ // src/modules/element-library/components/ApplicationsPanel.tsx
335
+ /**
336
+ * The applications of the Element library (spec 19 M4 marker 1): one card per
337
+ * application with its first URL pattern and what it holds. Choosing one opens
338
+ * its screens, elements and sequences.
339
+ */
340
+ function ApplicationCard({ application, selected, onSelect }) {
341
+ const tr = useTr();
342
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
343
+ type: "button",
344
+ onClick: onSelect,
345
+ "aria-current": selected ? "true" : void 0,
346
+ className: cn("flex w-full min-w-0 flex-col gap-0.5 rounded-md border p-3 text-left transition-colors", selected ? "border-primary bg-primary/10" : "border-border-default hover:bg-muted"),
347
+ "data-testid": `element-library-application-${application.key}`,
348
+ children: [
349
+ /* @__PURE__ */ jsx("span", {
350
+ className: "truncate text-sm font-medium text-text-primary",
351
+ children: application.name
352
+ }),
353
+ application.urlPatterns[0] && /* @__PURE__ */ jsx("span", {
354
+ className: "truncate font-mono text-xs text-text-secondary",
355
+ children: application.urlPatterns[0]
356
+ }),
357
+ /* @__PURE__ */ jsx("span", {
358
+ className: "text-xs text-text-secondary",
359
+ children: tr("fluidgrids.elementLibrary.applicationCounts", "{{elements}} elements · {{sequences}} sequences", {
360
+ elements: application.elementCount,
361
+ sequences: application.sequenceCount
362
+ })
363
+ })
364
+ ]
365
+ }) });
366
+ }
367
+ function ApplicationsEmpty({ searching, onCreate }) {
368
+ const tr = useTr();
369
+ return /* @__PURE__ */ jsx(EmptyState, {
370
+ kind: searching ? "no-results" : "first-use",
371
+ size: "panel",
372
+ compact: true,
373
+ icon: /* @__PURE__ */ jsx(AppWindow, {
374
+ className: "size-6",
375
+ "aria-hidden": "true"
376
+ }),
377
+ title: searching ? tr("fluidgrids.elementLibrary.noApplicationsMatch", "No application matches your search.") : tr("fluidgrids.elementLibrary.emptyTitle", "No applications yet"),
378
+ description: searching ? void 0 : tr("fluidgrids.elementLibrary.emptyDescription", "Add the web app your workflows work in, then save its buttons and fields here so every Use Browser step can reuse them."),
379
+ action: !searching && onCreate ? /* @__PURE__ */ jsx(Button$1, {
380
+ size: "sm",
381
+ onClick: onCreate,
382
+ "data-testid": "element-library-empty-create",
383
+ children: tr("fluidgrids.elementLibrary.newApplication", "New application")
384
+ }) : void 0
385
+ });
386
+ }
387
+ function ApplicationsPanel({ applications, loading, error, hasMore, loadingMore, onLoadMore, selectedId, onSelect, onCreate, searching }) {
388
+ const tr = useTr();
389
+ return /* @__PURE__ */ jsxs("section", {
390
+ className: "flex min-w-0 flex-col gap-2",
391
+ "aria-label": tr("fluidgrids.elementLibrary.applications", "Applications"),
392
+ "data-testid": "element-library-applications",
393
+ children: [
394
+ /* @__PURE__ */ jsx("h2", {
395
+ className: "text-sm font-semibold text-text-primary",
396
+ children: tr("fluidgrids.elementLibrary.applications", "Applications")
397
+ }),
398
+ /* @__PURE__ */ jsx(LibraryError, {
399
+ error,
400
+ testId: "element-library-applications-error"
401
+ }),
402
+ loading && applications.length === 0 ? /* @__PURE__ */ jsxs("div", {
403
+ className: "flex flex-col gap-2",
404
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full" })]
405
+ }) : applications.length === 0 && !error ? /* @__PURE__ */ jsx(ApplicationsEmpty, {
406
+ searching,
407
+ onCreate
408
+ }) : /* @__PURE__ */ jsx("ul", {
409
+ className: "flex flex-col gap-2",
410
+ children: applications.map((application) => /* @__PURE__ */ jsx(ApplicationCard, {
411
+ application,
412
+ selected: application.id === selectedId,
413
+ onSelect: () => onSelect(application.id)
414
+ }, application.id))
415
+ }),
416
+ hasMore && /* @__PURE__ */ jsx(Button$1, {
417
+ variant: "outline",
418
+ size: "sm",
419
+ disabled: loadingMore,
420
+ onClick: onLoadMore,
421
+ "data-testid": "element-library-applications-more",
422
+ children: tr("fluidgrids.elementLibrary.loadMore", "Show more")
423
+ })
424
+ ]
425
+ });
426
+ }
427
+
428
+ // src/modules/element-library/components/ApplyDialog.tsx
429
+ /**
430
+ * Apply to workflows (spec 19 M5 markers 4 to 6, P1-05
431
+ * `applyUiElementVersionToWorkflows`): each selected workflow gets a new
432
+ * version that differs only in the pinned element version, and where the
433
+ * replaced version was active the new one is activated.
434
+ *
435
+ * The service replays each workflow's steps on its stored snapshots first: a
436
+ * workflow whose replay fails is skipped and nothing is written for it; one
437
+ * with no snapshot is untested and skipped unless "Also apply to workflows
438
+ * that have no snapshot test" is ticked (`allowUntested`, off by default).
439
+ * Workflows the person cannot open are counted, never named. The result says
440
+ * per workflow what happened and why.
441
+ */
442
+ function ApplyForm({ elementId, version, candidates, restrictedCount, onClose, onApplied }) {
443
+ const tr = useTr();
444
+ const [rows] = useState(() => [...candidates]);
445
+ const [selected, setSelected] = useState(() => new Set(candidates.slice(0, 50).map((entry) => entry.workflowKey)));
446
+ const [allowUntested, setAllowUntested] = useState(false);
447
+ const [applying, setApplying] = useState(false);
448
+ const [error, setError] = useState(null);
449
+ const [result, setResult] = useState(null);
450
+ const items = new Map((result?.items ?? []).map((item) => [item.workflowKey, item]));
451
+ const toggle = (key, on) => setSelected((current) => {
452
+ const next = new Set(current);
453
+ if (on && next.size < 50) next.add(key);
454
+ else next.delete(key);
455
+ return next;
456
+ });
457
+ const apply = async () => {
458
+ if (selected.size === 0 || applying) return;
459
+ setApplying(true);
460
+ setError(null);
461
+ try {
462
+ const applied = await applyUiElementVersion({
463
+ elementId,
464
+ version,
465
+ workflowKeys: [...selected],
466
+ allowUntested,
467
+ activate: true
468
+ });
469
+ setResult(applied);
470
+ setSelected(new Set(applied.items.filter((item) => item.status !== "APPLIED").map((item) => item.workflowKey)));
471
+ onApplied(applied);
472
+ } catch (err) {
473
+ setError(err);
474
+ } finally {
475
+ setApplying(false);
476
+ }
477
+ };
478
+ return /* @__PURE__ */ jsxs("div", {
479
+ className: "flex flex-col gap-3",
480
+ "data-testid": "element-library-apply-form",
481
+ children: [
482
+ /* @__PURE__ */ jsx("ul", {
483
+ className: "flex max-h-[50vh] flex-col gap-1.5 overflow-y-auto",
484
+ children: rows.map((entry) => {
485
+ const item = items.get(entry.workflowKey);
486
+ const done = item?.status === "APPLIED";
487
+ const text = item ? applyItemText(item) : null;
488
+ const id = `element-library-apply-${entry.workflowKey}`;
489
+ return /* @__PURE__ */ jsxs("li", {
490
+ className: "flex min-w-0 items-start gap-2 rounded-md border border-border-default p-2",
491
+ "data-testid": id,
492
+ children: [
493
+ /* @__PURE__ */ jsx(Checkbox, {
494
+ id,
495
+ checked: selected.has(entry.workflowKey),
496
+ disabled: done || applying,
497
+ onCheckedChange: (checked) => toggle(entry.workflowKey, checked === true),
498
+ "aria-label": entry.workflowName,
499
+ "data-testid": `${id}-select`
500
+ }),
501
+ /* @__PURE__ */ jsxs("label", {
502
+ htmlFor: id,
503
+ className: "flex min-w-0 flex-1 flex-col",
504
+ children: [
505
+ /* @__PURE__ */ jsx("span", {
506
+ className: "truncate text-sm font-medium text-text-primary",
507
+ children: entry.workflowName
508
+ }),
509
+ /* @__PURE__ */ jsx("span", {
510
+ className: "text-xs text-text-secondary",
511
+ children: tr("fluidgrids.elementLibrary.apply.row", "Pins v{{pinned}} · workflow v{{version}}{{active}}", {
512
+ pinned: entry.elementVersion,
513
+ version: entry.workflowVersion,
514
+ active: entry.isActive ? tr("fluidgrids.elementLibrary.apply.activeSuffix", ", active") : ""
515
+ })
516
+ }),
517
+ text && /* @__PURE__ */ jsx("span", {
518
+ className: done ? "text-xs text-status-success-text" : "text-xs text-status-warning-text",
519
+ "data-testid": `${id}-result`,
520
+ children: tr(text.key, text.fallback, text.vars)
521
+ })
522
+ ]
523
+ }),
524
+ done && /* @__PURE__ */ jsx(Badge, {
525
+ variant: "outline",
526
+ children: tr("fluidgrids.elementLibrary.apply.done", "Updated")
527
+ })
528
+ ]
529
+ }, entry.workflowKey);
530
+ })
531
+ }),
532
+ restrictedCount > 0 && /* @__PURE__ */ jsx("p", {
533
+ className: "text-xs text-text-secondary",
534
+ "data-testid": "element-library-apply-restricted",
535
+ children: tr("fluidgrids.elementLibrary.apply.restricted", "{{count}} restricted workflows also pin this element. Ask someone who can open them.", { count: restrictedCount })
536
+ }),
537
+ /* @__PURE__ */ jsxs("label", {
538
+ className: "flex items-start gap-2 text-sm text-text-primary",
539
+ children: [/* @__PURE__ */ jsx(Checkbox, {
540
+ checked: allowUntested,
541
+ disabled: applying,
542
+ onCheckedChange: (checked) => setAllowUntested(checked === true),
543
+ "data-testid": "element-library-apply-untested"
544
+ }), /* @__PURE__ */ jsx("span", { children: tr("fluidgrids.elementLibrary.apply.allowUntested", "Also apply to workflows that have no snapshot test") })]
545
+ }),
546
+ /* @__PURE__ */ jsx("p", {
547
+ className: "text-xs text-text-secondary",
548
+ children: tr("fluidgrids.elementLibrary.apply.audit", "Each workflow is tested on its stored snapshots first; one whose test fails is not changed. Every new version records this change and can be rolled back in Version history.")
549
+ }),
550
+ result && /* @__PURE__ */ jsx("p", {
551
+ role: "status",
552
+ className: "text-sm text-text-primary",
553
+ "data-testid": "element-library-apply-summary",
554
+ children: tr("fluidgrids.elementLibrary.apply.summary", "{{applied}} updated, {{skipped}} not updated.", {
555
+ applied: result.applied,
556
+ skipped: result.skipped
557
+ })
558
+ }),
559
+ /* @__PURE__ */ jsx(LibraryError, {
560
+ error,
561
+ testId: "element-library-apply-error"
562
+ }),
563
+ /* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
564
+ variant: "outline",
565
+ onClick: onClose,
566
+ children: result ? tr("fluidgrids.elementLibrary.close", "Close") : tr("fluidgrids.elementLibrary.cancel", "Cancel")
567
+ }), /* @__PURE__ */ jsx(Button$1, {
568
+ disabled: selected.size === 0 || applying,
569
+ onClick: () => void apply(),
570
+ "data-testid": "element-library-apply-submit",
571
+ children: tr("fluidgrids.elementLibrary.apply.submit", "Apply to {{count}} workflows", { count: selected.size })
572
+ })] })
573
+ ]
574
+ });
575
+ }
576
+ function ApplyDialog({ open, onOpenChange, ...props }) {
577
+ const tr = useTr();
578
+ return /* @__PURE__ */ jsx(ResponsiveDialog, {
579
+ open,
580
+ onOpenChange,
581
+ children: /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
582
+ className: "max-h-[90vh] overflow-y-auto sm:max-w-xl",
583
+ children: [/* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: tr("fluidgrids.elementLibrary.apply.title", "Apply {{name}} v{{version}} to workflows", {
584
+ name: props.elementName,
585
+ version: props.version
586
+ }) }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: tr("fluidgrids.elementLibrary.apply.description", "Each selected workflow gets a new version that differs only in the pinned element version. Where the replaced version was active, the new version is activated in the same step.") })] }), open && /* @__PURE__ */ jsx(ApplyForm, {
587
+ elementId: props.elementId,
588
+ version: props.version,
589
+ candidates: props.candidates,
590
+ restrictedCount: props.restrictedCount,
591
+ onApplied: props.onApplied,
592
+ onClose: () => onOpenChange(false)
593
+ }, `${props.elementId}:${props.version}`)]
594
+ })
595
+ });
596
+ }
597
+
598
+ // src/modules/element-library/components/ElementActions.tsx
599
+ /**
600
+ * An element's actions (spec 19 M4 marker 6): Edit, Apply to workflows (only
601
+ * with the publish permission), Deprecate or Use again, and Delete. A delete
602
+ * of an element in use is refused by the service; the refusal says how many
603
+ * workflows use it.
604
+ */
605
+ function ElementActions({ detail, access, canApply, inUse, onEdit, onApply, onStatusChanged, onDeleted, onRefusedInUse }) {
606
+ const tr = useTr();
607
+ const [busy, setBusy] = useState(false);
608
+ const [error, setError] = useState(null);
609
+ const active = detail.status === "ACTIVE";
610
+ const changeStatus = async () => {
611
+ setBusy(true);
612
+ setError(null);
613
+ try {
614
+ onStatusChanged(await setUiElementStatus(detail.id, active ? "DEPRECATED" : "ACTIVE"));
615
+ } catch (err) {
616
+ setError(err);
617
+ } finally {
618
+ setBusy(false);
619
+ }
620
+ };
621
+ const remove = async () => {
622
+ if (!window.confirm(tr("fluidgrids.elementLibrary.element.deleteConfirm", "Delete {{name}}? This cannot be undone.", { name: detail.name }))) return;
623
+ setBusy(true);
624
+ setError(null);
625
+ try {
626
+ await deleteUiElement(detail.id);
627
+ toast.success(tr("fluidgrids.elementLibrary.element.deleted", "Element deleted"));
628
+ onDeleted();
629
+ } catch (err) {
630
+ setError(err);
631
+ if (rpaErrorCode(err) === "IN_USE") onRefusedInUse();
632
+ } finally {
633
+ setBusy(false);
634
+ }
635
+ };
636
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
637
+ className: "flex flex-wrap gap-2",
638
+ children: [
639
+ access.canUpdate && /* @__PURE__ */ jsxs(Button$1, {
640
+ size: "sm",
641
+ variant: "outline",
642
+ onClick: onEdit,
643
+ "data-testid": "element-library-element-edit",
644
+ children: [/* @__PURE__ */ jsx(Pencil, {
645
+ className: "mr-1 size-4",
646
+ "aria-hidden": "true"
647
+ }), tr("fluidgrids.elementLibrary.element.edit", "Edit")]
648
+ }),
649
+ access.canPublish && /* @__PURE__ */ jsx(Button$1, {
650
+ size: "sm",
651
+ disabled: !canApply,
652
+ onClick: onApply,
653
+ "data-testid": "element-library-element-apply",
654
+ children: tr("fluidgrids.elementLibrary.apply.open", "Apply to workflows")
655
+ }),
656
+ access.canUpdate && /* @__PURE__ */ jsx(Button$1, {
657
+ size: "sm",
658
+ variant: "outline",
659
+ disabled: busy,
660
+ onClick: () => void changeStatus(),
661
+ "data-testid": "element-library-element-status",
662
+ children: active ? tr("fluidgrids.elementLibrary.element.deprecate", "Deprecate") : tr("fluidgrids.elementLibrary.element.reactivate", "Use again")
663
+ }),
664
+ access.canDelete && /* @__PURE__ */ jsxs(Button$1, {
665
+ size: "sm",
666
+ variant: "outline",
667
+ disabled: busy,
668
+ onClick: () => void remove(),
669
+ "data-testid": "element-library-element-delete",
670
+ children: [/* @__PURE__ */ jsx(Trash2, {
671
+ className: "mr-1 size-4",
672
+ "aria-hidden": "true"
673
+ }), tr("fluidgrids.elementLibrary.element.delete", "Delete")]
674
+ })
675
+ ]
676
+ }), rpaErrorCode(error) === "IN_USE" ? /* @__PURE__ */ jsx("p", {
677
+ role: "alert",
678
+ className: "text-sm text-status-error-text",
679
+ "data-testid": "element-library-element-delete-refused",
680
+ children: tr("fluidgrids.elementLibrary.element.deleteRefused", "Refused while {{count}} workflows use this element.", { count: Math.max(inUse, 1) })
681
+ }) : /* @__PURE__ */ jsx(LibraryError, {
682
+ error,
683
+ testId: "element-library-element-action-error"
684
+ })] });
685
+ }
686
+
687
+ // src/modules/element-library/components/picker-status.ts
688
+ /** Whether the picker waits on the extension (Cancel is offered). */
689
+ function isPickerOpen(state) {
690
+ return state.phase === "starting" || isOperationOpen(state);
691
+ }
692
+ /** The status line under the picker, or null when there is nothing to say. */
693
+ function pickerStatusText(tr, state, badPick) {
694
+ switch (state.phase) {
695
+ case "consent": return tr("fluidgrids.elementLibrary.picker.consent", "Allow picking on the site in the page the extension opened.");
696
+ case "active": return tr("fluidgrids.elementLibrary.picker.active", "Click the element in the other tab. Esc cancels.");
697
+ case "confirming": return tr("fluidgrids.elementLibrary.picker.confirm", "Waiting for you to confirm in the extension");
698
+ case "declined": return tr("fluidgrids.elementLibrary.picker.declined", "You chose not to send the picked element.");
699
+ case "failed": return tr("fluidgrids.elementLibrary.picker.failed", "The picker stopped: {{message}}", { message: state.message });
700
+ case "ended": return tr("fluidgrids.elementLibrary.picker.ended", "Picking was cancelled.");
701
+ default: return badPick ? tr("fluidgrids.elementLibrary.picker.bad", "The picked element could not be read. Pick it again.") : null;
702
+ }
703
+ }
704
+
705
+ // src/modules/element-library/components/ElementPicker.tsx
706
+ /**
707
+ * Pick in the browser, in the element form (RPA plan P1-12, "picker to
708
+ * library"): the extension's element picker (P1-10) runs on a page the person
709
+ * names, and the element they click fills the form: its target, its name and,
710
+ * on save, the highlighted crop, its bounds and the tree snapshot
711
+ * (`saveUiElement` with `createdVia: PICKER`).
712
+ *
713
+ * The extension asks the person to allow picking on the site, and to confirm
714
+ * "Send the picked element to FluidGrids?" before anything reaches the page.
715
+ * Shown only where the extension's bridge answers (the FluidGrids app); with
716
+ * no extension or an older one it says what is needed and the form still
717
+ * works by hand. Nothing here loads the RPA engine.
718
+ */
719
+ /** The extension is missing or too old for the picker. */
720
+ function PickerUnavailable({ onRecheck }) {
721
+ const tr = useTr();
722
+ return /* @__PURE__ */ jsxs("div", {
723
+ className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground",
724
+ "data-testid": "element-library-picker-unavailable",
725
+ children: [/* @__PURE__ */ jsx("span", { children: tr("fluidgrids.elementLibrary.picker.needsExtension", "Pick in the browser needs the FluidGrids extension {{version}} in this browser.", { version: MIN_BRIDGE_EXTENSION_VERSION }) }), /* @__PURE__ */ jsx(Button, {
726
+ type: "button",
727
+ size: "sm",
728
+ variant: "ghost",
729
+ onClick: onRecheck,
730
+ children: tr("fluidgrids.elementLibrary.picker.recheck", "Check again")
731
+ })]
732
+ });
733
+ }
734
+ /** The page to pick on and the start, or Cancel while the extension works. */
735
+ function PickerControls({ operation, defaultUrl, badPick, onStart }) {
736
+ const tr = useTr();
737
+ const [urlText, setUrlText] = useState(defaultUrl);
738
+ const { state } = operation;
739
+ const url = startUrlOf(urlText);
740
+ const open = isPickerOpen(state);
741
+ const status = pickerStatusText(tr, state, badPick);
742
+ return /* @__PURE__ */ jsxs("div", {
743
+ className: "flex flex-col gap-1.5",
744
+ "data-testid": "element-library-picker",
745
+ children: [
746
+ !open && /* @__PURE__ */ jsxs("div", {
747
+ className: "flex flex-col gap-2 sm:flex-row",
748
+ children: [/* @__PURE__ */ jsx(Input, {
749
+ value: urlText,
750
+ inputMode: "url",
751
+ placeholder: "https://",
752
+ "aria-label": tr("fluidgrids.elementLibrary.picker.pageLabel", "Page to pick on"),
753
+ onChange: (event) => setUrlText(event.target.value),
754
+ className: "h-9 text-sm",
755
+ "data-testid": "element-library-picker-url"
756
+ }), /* @__PURE__ */ jsx(Button, {
757
+ type: "button",
758
+ variant: "outline",
759
+ disabled: !url,
760
+ onClick: () => {
761
+ if (!url) return;
762
+ onStart();
763
+ operation.start(url);
764
+ },
765
+ "data-testid": "element-library-picker-start",
766
+ children: tr("fluidgrids.elementLibrary.picker.start", "Pick in the browser")
767
+ })]
768
+ }),
769
+ status && /* @__PURE__ */ jsx("span", {
770
+ className: "text-xs text-muted-foreground",
771
+ role: "status",
772
+ "data-testid": "element-library-picker-status",
773
+ children: status
774
+ }),
775
+ open && /* @__PURE__ */ jsxs("div", {
776
+ className: "flex gap-2",
777
+ children: [state.phase === "declined" && /* @__PURE__ */ jsx(Button, {
778
+ type: "button",
779
+ size: "sm",
780
+ onClick: operation.askAgain,
781
+ children: tr("fluidgrids.elementLibrary.picker.askAgain", "Send it now")
782
+ }), /* @__PURE__ */ jsx(Button, {
783
+ type: "button",
784
+ size: "sm",
785
+ variant: "outline",
786
+ onClick: operation.cancel,
787
+ "data-testid": "element-library-picker-cancel",
788
+ children: tr("fluidgrids.elementLibrary.cancel", "Cancel")
789
+ })]
790
+ })
791
+ ]
792
+ });
793
+ }
794
+ function PickerBody({ defaultUrl = "", onPicked }) {
795
+ const tr = useTr();
796
+ const { workspaceId } = useFluidGridsAnalytics();
797
+ const { availability, recheck } = useBridgeAvailability(true, PICK_CAPABILITIES);
798
+ const [badPick, setBadPick] = useState(false);
799
+ const onReceived = useCallback((data) => {
800
+ const picked = readPickedElement(data);
801
+ setBadPick(picked === null);
802
+ if (picked) onPicked(picked);
803
+ }, [onPicked]);
804
+ const operation = useBridgeOperation("pick", workspaceId, onReceived);
805
+ if (availability === null) return /* @__PURE__ */ jsx("span", {
806
+ className: "text-xs text-muted-foreground",
807
+ role: "status",
808
+ children: tr("fluidgrids.elementLibrary.picker.checking", "Looking for the FluidGrids extension…")
809
+ });
810
+ if (availability.kind === "unsupported") return null;
811
+ if (availability.kind !== "ready") return /* @__PURE__ */ jsx(PickerUnavailable, { onRecheck: recheck });
812
+ return /* @__PURE__ */ jsx(PickerControls, {
813
+ operation,
814
+ defaultUrl,
815
+ badPick,
816
+ onStart: () => setBadPick(false)
817
+ });
818
+ }
819
+ /** Pick in the browser, or nothing outside the FluidGrids app. */
820
+ function ElementPicker(props) {
821
+ if (!canUseBridgeHere()) return null;
822
+ return /* @__PURE__ */ jsx(PickerBody, { ...props });
823
+ }
824
+
825
+ // src/modules/element-library/components/ElementDialog.tsx
826
+ /**
827
+ * New element and Edit element (spec 19 M4 marker 3): its name, key, screen,
828
+ * control type and notes, and its target, the ordered methods the resolver
829
+ * tries. Saving a changed target writes the next version; workflows keep the
830
+ * version they pinned until someone applies the new one. `expectedVersion`
831
+ * makes a save fail when someone saved a newer version meanwhile.
832
+ *
833
+ * The picker and the recorder save elements too (P1-10, P1-12); this dialog
834
+ * is the manual way, with the same method editor as a Use Browser step.
835
+ */
836
+ const NO_SCREEN = "";
837
+ function ElementFields({ values, keyFixed, screens, onName, onKey, onScreen, onControlType, onNotes }) {
838
+ const tr = useTr();
839
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
840
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
841
+ children: [
842
+ /* @__PURE__ */ jsx(Field, {
843
+ id: "element-library-element-name",
844
+ label: tr("fluidgrids.elementLibrary.field.name", "Name"),
845
+ children: /* @__PURE__ */ jsx(Input, {
846
+ id: "element-library-element-name",
847
+ value: values.name,
848
+ maxLength: 200,
849
+ onChange: (event) => onName(event.target.value),
850
+ placeholder: tr("fluidgrids.elementLibrary.element.namePlaceholder", "Search"),
851
+ "data-testid": "element-library-element-name"
852
+ })
853
+ }),
854
+ /* @__PURE__ */ jsx(Field, {
855
+ id: "element-library-element-key",
856
+ label: tr("fluidgrids.elementLibrary.field.key", "Key"),
857
+ hint: tr("fluidgrids.elementLibrary.field.elementKeyHint", "Starts with a letter or _; unique in the application."),
858
+ children: /* @__PURE__ */ jsx(Input, {
859
+ id: "element-library-element-key",
860
+ value: values.key,
861
+ readOnly: keyFixed,
862
+ maxLength: 64,
863
+ onChange: (event) => onKey(event.target.value),
864
+ className: "font-mono",
865
+ "data-testid": "element-library-element-key"
866
+ })
867
+ }),
868
+ /* @__PURE__ */ jsx(Field, {
869
+ id: "element-library-element-screen",
870
+ label: tr("fluidgrids.elementLibrary.field.screen", "Screen"),
871
+ children: /* @__PURE__ */ jsxs(ThemedSelect, {
872
+ id: "element-library-element-screen",
873
+ value: values.screen,
874
+ onChange: (event) => onScreen(event.target.value),
875
+ "data-testid": "element-library-element-screen",
876
+ children: [/* @__PURE__ */ jsx("option", {
877
+ value: NO_SCREEN,
878
+ children: tr("fluidgrids.elementLibrary.noScreen", "No screen")
879
+ }), screens.map((option) => /* @__PURE__ */ jsx("option", {
880
+ value: option.id,
881
+ children: option.name
882
+ }, option.id))]
883
+ })
884
+ }),
885
+ /* @__PURE__ */ jsx(Field, {
886
+ id: "element-library-element-control",
887
+ label: tr("fluidgrids.elementLibrary.field.controlType", "Control type"),
888
+ hint: tr("fluidgrids.elementLibrary.field.optional", "Optional."),
889
+ children: /* @__PURE__ */ jsx(Input, {
890
+ id: "element-library-element-control",
891
+ value: values.controlType,
892
+ maxLength: 64,
893
+ placeholder: tr("fluidgrids.elementLibrary.element.controlPlaceholder", "button"),
894
+ onChange: (event) => onControlType(event.target.value),
895
+ "data-testid": "element-library-element-control"
896
+ })
897
+ })
898
+ ]
899
+ }), /* @__PURE__ */ jsx(Field, {
900
+ id: "element-library-element-notes",
901
+ label: tr("fluidgrids.elementLibrary.field.notes", "Notes"),
902
+ hint: tr("fluidgrids.elementLibrary.field.optional", "Optional."),
903
+ children: /* @__PURE__ */ jsx(Textarea, {
904
+ id: "element-library-element-notes",
905
+ value: values.notes,
906
+ rows: 2,
907
+ maxLength: 4e3,
908
+ onChange: (event) => onNotes(event.target.value),
909
+ "data-testid": "element-library-element-notes"
910
+ })
911
+ })] });
912
+ }
913
+ function ElementForm({ applicationId, screens, screenId, element, onCancel, onSaved, pickUrl }) {
914
+ const tr = useTr();
915
+ const editing = element !== null;
916
+ const [values, setValues] = useState(() => elementFormValues(element, screenId));
917
+ const [saving, setSaving] = useState(false);
918
+ const [error, setError] = useState(null);
919
+ const [picked, setPicked] = useState(null);
920
+ const set = (changes) => setValues((current) => ({
921
+ ...current,
922
+ ...changes
923
+ }));
924
+ const onPicked = useCallback((pick) => {
925
+ setPicked(pick);
926
+ setValues((current) => ({
927
+ ...current,
928
+ target: pick.target,
929
+ name: current.name.trim() ? current.name : pick.name ?? current.name
930
+ }));
931
+ }, []);
932
+ const input = elementSaveInput(values, applicationId, element, picked);
933
+ const targetChanged = elementTargetChanged(values, element);
934
+ const submit = async (event) => {
935
+ event.preventDefault();
936
+ if (!input || saving) return;
937
+ setSaving(true);
938
+ setError(null);
939
+ try {
940
+ onSaved(await saveUiElement(input));
941
+ } catch (err) {
942
+ setError(err);
943
+ } finally {
944
+ setSaving(false);
945
+ }
946
+ };
947
+ return /* @__PURE__ */ jsxs("form", {
948
+ onSubmit: (event) => void submit(event),
949
+ className: "flex flex-col gap-4",
950
+ "data-testid": "element-library-element-form",
951
+ children: [
952
+ /* @__PURE__ */ jsx(ElementFields, {
953
+ values: {
954
+ ...values,
955
+ key: elementFormKey(values)
956
+ },
957
+ keyFixed: editing,
958
+ screens,
959
+ onName: (name) => set({ name }),
960
+ onKey: (key) => set({ key }),
961
+ onScreen: (screen) => set({ screen }),
962
+ onControlType: (controlType) => set({ controlType }),
963
+ onNotes: (notes) => set({ notes })
964
+ }),
965
+ /* @__PURE__ */ jsxs("section", {
966
+ className: "flex flex-col gap-1.5",
967
+ children: [
968
+ /* @__PURE__ */ jsx("span", {
969
+ className: "text-sm font-medium text-text-primary",
970
+ children: tr("fluidgrids.elementLibrary.field.target", "How it is found")
971
+ }),
972
+ /* @__PURE__ */ jsx(ElementPicker, {
973
+ defaultUrl: pickUrl,
974
+ onPicked
975
+ }),
976
+ isPickedTarget(values.target, picked) && /* @__PURE__ */ jsx("span", {
977
+ className: "text-xs text-muted-foreground",
978
+ "data-testid": "element-library-element-picked",
979
+ children: tr("fluidgrids.elementLibrary.picker.picked", "Picked in the browser. Saving keeps its picture and a snapshot of the page.")
980
+ }),
981
+ /* @__PURE__ */ jsx(UiTargetMethodsEditor, {
982
+ target: values.target,
983
+ onChange: (target) => set({ target }),
984
+ testId: "element-library-element-target"
985
+ })
986
+ ]
987
+ }),
988
+ editing && targetChanged && /* @__PURE__ */ jsx(Field, {
989
+ id: "element-library-element-version-note",
990
+ label: tr("fluidgrids.elementLibrary.field.versionNote", "Why this change"),
991
+ hint: tr("fluidgrids.elementLibrary.element.newVersionHint", "Saving creates v{{version}}. Workflows keep the version they pinned.", { version: (element?.currentVersion ?? 0) + 1 }),
992
+ children: /* @__PURE__ */ jsx(Input, {
993
+ id: "element-library-element-version-note",
994
+ value: values.note,
995
+ maxLength: 2e3,
996
+ onChange: (event) => set({ note: event.target.value }),
997
+ "data-testid": "element-library-element-version-note"
998
+ })
999
+ }),
1000
+ /* @__PURE__ */ jsx(LibraryError, {
1001
+ error,
1002
+ testId: "element-library-element-error"
1003
+ }),
1004
+ /* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
1005
+ type: "button",
1006
+ variant: "outline",
1007
+ onClick: onCancel,
1008
+ children: tr("fluidgrids.elementLibrary.cancel", "Cancel")
1009
+ }), /* @__PURE__ */ jsx(Button$1, {
1010
+ type: "submit",
1011
+ disabled: !input || saving,
1012
+ "data-testid": "element-library-element-save",
1013
+ children: editing ? tr("fluidgrids.elementLibrary.save", "Save") : tr("fluidgrids.elementLibrary.create", "Create")
1014
+ })] })
1015
+ ]
1016
+ });
1017
+ }
1018
+ function ElementDialog({ open, onOpenChange, applicationId, screens, screenId = null, element = null, onSaved, pickUrl }) {
1019
+ const tr = useTr();
1020
+ return /* @__PURE__ */ jsx(ResponsiveDialog, {
1021
+ open,
1022
+ onOpenChange,
1023
+ children: /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
1024
+ className: "max-h-[90vh] overflow-y-auto sm:max-w-2xl",
1025
+ children: [/* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: element ? tr("fluidgrids.elementLibrary.editElement", "Edit element") : tr("fluidgrids.elementLibrary.newElement", "New element") }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: tr("fluidgrids.elementLibrary.element.description", "A named button, field or link that Use Browser steps can use. Editing how it is found creates a new version.") })] }), open && /* @__PURE__ */ jsx(ElementForm, {
1026
+ applicationId,
1027
+ screens,
1028
+ screenId,
1029
+ element,
1030
+ onCancel: () => onOpenChange(false),
1031
+ onSaved,
1032
+ pickUrl
1033
+ }, element?.id ?? "new")]
1034
+ })
1035
+ });
1036
+ }
1037
+
1038
+ // src/modules/element-library/components/ElementInsights.tsx
1039
+ /**
1040
+ * An element's health and where it is used (spec 19 M4 markers 4 and 5).
1041
+ *
1042
+ * Health: runs, success rate, median time to find and which method found the
1043
+ * element over the last 30 days. **Degraded** means the first method stopped
1044
+ * matching while runs still pass by a fallback method.
1045
+ *
1046
+ * Where used: each workflow that pins the element, with the version that runs
1047
+ * and the element version it pins. Workflows the person cannot open are only
1048
+ * counted, never named.
1049
+ */
1050
+ function Figure({ value, label, testId }) {
1051
+ return /* @__PURE__ */ jsxs("div", {
1052
+ className: "flex min-w-0 flex-col",
1053
+ "data-testid": testId,
1054
+ children: [/* @__PURE__ */ jsx("span", {
1055
+ className: "text-lg font-semibold text-text-primary",
1056
+ children: value
1057
+ }), /* @__PURE__ */ jsx("span", {
1058
+ className: "text-xs text-text-secondary",
1059
+ children: label
1060
+ })]
1061
+ });
1062
+ }
1063
+ function ElementHealthCard({ health, loading, error }) {
1064
+ const tr = useTr();
1065
+ const shares = health ? methodShares(health.resolvedBy) : [];
1066
+ return /* @__PURE__ */ jsxs("section", {
1067
+ className: "flex flex-col gap-2",
1068
+ "data-testid": "element-library-health",
1069
+ children: [
1070
+ /* @__PURE__ */ jsx(SectionTitle, { children: tr("fluidgrids.elementLibrary.health.title", "Health, last 30 days") }),
1071
+ /* @__PURE__ */ jsx(LibraryError, {
1072
+ error,
1073
+ testId: "element-library-health-error"
1074
+ }),
1075
+ loading && !health ? /* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full" }) : health ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
1076
+ health.degraded && /* @__PURE__ */ jsxs("div", {
1077
+ role: "status",
1078
+ className: "flex items-start gap-2 rounded-md border border-status-warning-border bg-status-warning-bg-subtle p-2 text-xs text-status-warning-text",
1079
+ "data-testid": "element-library-health-degraded",
1080
+ children: [/* @__PURE__ */ jsx(AlertTriangle, {
1081
+ className: "mt-0.5 size-4 shrink-0",
1082
+ "aria-hidden": "true"
1083
+ }), /* @__PURE__ */ jsx("span", { children: tr("fluidgrids.elementLibrary.health.degraded", "Degraded. The first way of finding this element stopped matching; runs still pass because a fallback method finds it. Edit the element to fix it.") })]
1084
+ }),
1085
+ health.runs === 0 ? /* @__PURE__ */ jsx("p", {
1086
+ className: "text-xs text-text-secondary",
1087
+ "data-testid": "element-library-health-empty",
1088
+ children: tr("fluidgrids.elementLibrary.health.noRuns", "No runs have used this element in the last 30 days.")
1089
+ }) : /* @__PURE__ */ jsxs("div", {
1090
+ className: "grid grid-cols-2 gap-3 sm:grid-cols-4",
1091
+ children: [
1092
+ /* @__PURE__ */ jsx(Figure, {
1093
+ value: health.runs,
1094
+ label: tr("fluidgrids.elementLibrary.health.runs", "runs"),
1095
+ testId: "element-library-health-runs"
1096
+ }),
1097
+ /* @__PURE__ */ jsx(Figure, {
1098
+ value: percentText(health.successRate),
1099
+ label: tr("fluidgrids.elementLibrary.health.success", "success"),
1100
+ testId: "element-library-health-success"
1101
+ }),
1102
+ /* @__PURE__ */ jsx(Figure, {
1103
+ value: durationText(health.medianFindMs),
1104
+ label: tr("fluidgrids.elementLibrary.health.medianFind", "median time to find"),
1105
+ testId: "element-library-health-median"
1106
+ }),
1107
+ /* @__PURE__ */ jsx(Figure, {
1108
+ value: fallbackRuns(health.daily),
1109
+ label: tr("fluidgrids.elementLibrary.health.fallbacks", "found by a fallback"),
1110
+ testId: "element-library-health-fallbacks"
1111
+ })
1112
+ ]
1113
+ }),
1114
+ shares.length > 0 && /* @__PURE__ */ jsxs("p", {
1115
+ className: "text-xs text-text-secondary",
1116
+ "data-testid": "element-library-health-methods",
1117
+ children: [
1118
+ tr("fluidgrids.elementLibrary.health.foundBy", "Found by"),
1119
+ " ",
1120
+ shares.map((share) => {
1121
+ const text = methodText(share.method);
1122
+ return `${tr(text.key, text.fallback, text.vars)} ${share.share}%`;
1123
+ }).join(" · ")
1124
+ ]
1125
+ })
1126
+ ] }) : null
1127
+ ]
1128
+ });
1129
+ }
1130
+ function ElementUsageList({ usage, restrictedCount, currentVersion, loading, error }) {
1131
+ const tr = useTr();
1132
+ return /* @__PURE__ */ jsxs("section", {
1133
+ className: "flex flex-col gap-2",
1134
+ "data-testid": "element-library-usage",
1135
+ children: [
1136
+ /* @__PURE__ */ jsx(SectionTitle, { children: tr("fluidgrids.elementLibrary.usage.title", "Where used") }),
1137
+ /* @__PURE__ */ jsx(LibraryError, {
1138
+ error,
1139
+ testId: "element-library-usage-error"
1140
+ }),
1141
+ loading && usage.length === 0 ? /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full" }) : usage.length === 0 && restrictedCount === 0 ? /* @__PURE__ */ jsx("p", {
1142
+ className: "text-xs text-text-secondary",
1143
+ "data-testid": "element-library-usage-empty",
1144
+ children: tr("fluidgrids.elementLibrary.usage.none", "No workflow uses this element yet.")
1145
+ }) : /* @__PURE__ */ jsx("ul", {
1146
+ className: "flex flex-col gap-1.5",
1147
+ children: usage.map((entry) => /* @__PURE__ */ jsxs("li", {
1148
+ className: "flex min-w-0 flex-wrap items-center justify-between gap-2 rounded-md border border-border-default p-2",
1149
+ "data-testid": `element-library-usage-${entry.workflowKey}`,
1150
+ children: [/* @__PURE__ */ jsxs("div", {
1151
+ className: "flex min-w-0 flex-col",
1152
+ children: [/* @__PURE__ */ jsx(Link, {
1153
+ to: `../workflow/${encodeURIComponent(entry.workflowKey)}/${encodeURIComponent(entry.workflowVersion)}`,
1154
+ className: "truncate text-sm font-medium text-primary hover:underline",
1155
+ children: entry.workflowName
1156
+ }), /* @__PURE__ */ jsx("span", {
1157
+ className: "text-xs text-text-secondary",
1158
+ children: entry.isActive ? tr("fluidgrids.elementLibrary.usage.versionActive", "v{{version}}, active", { version: entry.workflowVersion }) : tr("fluidgrids.elementLibrary.usage.version", "v{{version}}", { version: entry.workflowVersion })
1159
+ })]
1160
+ }), /* @__PURE__ */ jsxs("div", {
1161
+ className: "flex shrink-0 items-center gap-1.5",
1162
+ children: [/* @__PURE__ */ jsx("span", {
1163
+ className: "text-xs text-text-secondary",
1164
+ children: tr("fluidgrids.elementLibrary.usage.pins", "pins v{{version}}", { version: entry.elementVersion })
1165
+ }), entry.elementVersion < currentVersion && /* @__PURE__ */ jsx(Badge, {
1166
+ variant: "outline",
1167
+ "data-testid": `element-library-usage-${entry.workflowKey}-older`,
1168
+ children: tr("fluidgrids.elementLibrary.usage.older", "Older version")
1169
+ })]
1170
+ })]
1171
+ }, entry.workflowKey))
1172
+ }),
1173
+ restrictedCount > 0 && /* @__PURE__ */ jsx("p", {
1174
+ className: "text-xs text-text-secondary",
1175
+ "data-testid": "element-library-usage-restricted",
1176
+ children: tr("fluidgrids.elementLibrary.usage.restricted", "and {{count}} restricted workflows you cannot open", { count: restrictedCount })
1177
+ })
1178
+ ]
1179
+ });
1180
+ }
1181
+
1182
+ // src/modules/element-library/components/ElementScreenshot.tsx
1183
+ /**
1184
+ * The highlighted crop the picker or a recording saved with an element version
1185
+ * (stored in Files). Its download link is short-lived and asked for only when
1186
+ * the crop is shown; nothing shows when the version has no crop or the link
1187
+ * cannot be had.
1188
+ */
1189
+ /** How long the crop's download link lives, in seconds. */
1190
+ const LINK_SECONDS = 600;
1191
+ function ElementScreenshot({ fileId }) {
1192
+ const tr = useTr();
1193
+ const [url, setUrl] = useState(null);
1194
+ useEffect(() => {
1195
+ let live = true;
1196
+ setUrl(null);
1197
+ if (!fileId) return void 0;
1198
+ readTyped(FileDownloadUrlDocument, {
1199
+ id: fileId,
1200
+ expiresIn: LINK_SECONDS
1201
+ }).then((data) => {
1202
+ if (live) setUrl(data.getFileDownloadUrl || null);
1203
+ }).catch(() => {});
1204
+ return () => {
1205
+ live = false;
1206
+ };
1207
+ }, [fileId]);
1208
+ if (!url) return null;
1209
+ return /* @__PURE__ */ jsx("img", {
1210
+ src: url,
1211
+ alt: tr("fluidgrids.elementLibrary.element.screenshot", "The element as it was captured"),
1212
+ className: "max-h-48 max-w-full self-start rounded-md border border-border-default object-contain",
1213
+ "data-testid": "element-library-element-screenshot"
1214
+ });
1215
+ }
1216
+
1217
+ // src/modules/element-library/components/ElementVersions.tsx
1218
+ /**
1219
+ * An element's versions, newest first (spec 19 M4 marker 3): how each was
1220
+ * made, when, and the note it carries. Editing how the element is found
1221
+ * writes a new version; workflows keep the version they pinned.
1222
+ */
1223
+ function createdViaText(via) {
1224
+ switch (via) {
1225
+ case "RECORDER": return {
1226
+ key: "fluidgrids.elementLibrary.version.viaRecorder",
1227
+ fallback: "Created by a recording"
1228
+ };
1229
+ case "PICKER": return {
1230
+ key: "fluidgrids.elementLibrary.version.viaPicker",
1231
+ fallback: "Picked in the browser"
1232
+ };
1233
+ case "IMPORT": return {
1234
+ key: "fluidgrids.elementLibrary.version.viaImport",
1235
+ fallback: "Imported"
1236
+ };
1237
+ default: return {
1238
+ key: "fluidgrids.elementLibrary.version.viaManual",
1239
+ fallback: "Edited by hand"
1240
+ };
1241
+ }
1242
+ }
1243
+ function ElementVersions({ versions }) {
1244
+ const tr = useTr();
1245
+ return /* @__PURE__ */ jsxs("section", {
1246
+ className: "flex flex-col gap-2",
1247
+ "data-testid": "element-library-versions",
1248
+ children: [
1249
+ /* @__PURE__ */ jsx(SectionTitle, { children: tr("fluidgrids.elementLibrary.versions.title", "Versions") }),
1250
+ /* @__PURE__ */ jsx("ul", {
1251
+ className: "flex flex-col gap-1",
1252
+ children: versions.map((version) => {
1253
+ const via = createdViaText(version.createdVia);
1254
+ return /* @__PURE__ */ jsxs("li", {
1255
+ className: "flex min-w-0 flex-col text-xs",
1256
+ "data-testid": `element-library-version-${version.version}`,
1257
+ children: [/* @__PURE__ */ jsx("span", {
1258
+ className: "text-text-primary",
1259
+ children: tr("fluidgrids.elementLibrary.versions.row", "v{{version}}: {{via}}, {{date}}", {
1260
+ version: version.version,
1261
+ via: tr(via.key, via.fallback),
1262
+ date: new Date(version.createdAt).toLocaleDateString()
1263
+ })
1264
+ }), version.note && /* @__PURE__ */ jsx("span", {
1265
+ className: "text-text-secondary",
1266
+ children: version.note
1267
+ })]
1268
+ }, version.id);
1269
+ })
1270
+ }),
1271
+ /* @__PURE__ */ jsx("p", {
1272
+ className: "text-xs text-text-secondary",
1273
+ children: tr("fluidgrids.elementLibrary.versions.hint", "Editing how the element is found creates a new version. Workflows keep the version they pinned until you apply the new one.")
1274
+ })
1275
+ ]
1276
+ });
1277
+ }
1278
+
1279
+ // src/modules/element-library/components/ElementPanel.tsx
1280
+ /**
1281
+ * One element of the Element library (spec 19 M4 markers 3 to 6): the crop
1282
+ * the picker saved, its versions, its health, where it is used, and its
1283
+ * actions. Apply to workflows needs the publish permission; without it the
1284
+ * button is absent. Delete is refused while any workflow uses the element.
1285
+ * Technical details (the stored target) sit behind "Show technical details".
1286
+ */
1287
+ function ElementHeading({ detail, applicationName, screenName, onBack }) {
1288
+ const tr = useTr();
1289
+ return /* @__PURE__ */ jsxs("div", {
1290
+ className: "flex min-w-0 flex-col gap-1",
1291
+ children: [
1292
+ /* @__PURE__ */ jsxs("button", {
1293
+ type: "button",
1294
+ onClick: onBack,
1295
+ className: "flex items-center gap-1 self-start text-xs text-primary hover:underline lg:hidden",
1296
+ "data-testid": "element-library-element-back",
1297
+ children: [/* @__PURE__ */ jsx(ArrowLeft, {
1298
+ className: "size-3.5",
1299
+ "aria-hidden": "true"
1300
+ }), applicationName]
1301
+ }),
1302
+ /* @__PURE__ */ jsxs("div", {
1303
+ className: "flex min-w-0 flex-wrap items-center gap-2",
1304
+ children: [
1305
+ /* @__PURE__ */ jsx("h2", {
1306
+ className: "truncate text-lg font-semibold text-text-primary",
1307
+ "data-testid": "element-library-element-name",
1308
+ children: detail.name
1309
+ }),
1310
+ /* @__PURE__ */ jsx(Badge, {
1311
+ variant: "secondary",
1312
+ "data-testid": "element-library-element-version",
1313
+ children: tr("fluidgrids.elementLibrary.element.latest", "v{{version}} (latest)", { version: detail.currentVersion })
1314
+ }),
1315
+ detail.status === "DEPRECATED" && /* @__PURE__ */ jsx(Badge, {
1316
+ variant: "outline",
1317
+ "data-testid": "element-library-element-deprecated",
1318
+ children: tr("fluidgrids.elementLibrary.element.deprecated", "Deprecated")
1319
+ })
1320
+ ]
1321
+ }),
1322
+ /* @__PURE__ */ jsx("span", {
1323
+ className: "text-xs text-text-secondary",
1324
+ children: [
1325
+ detail.controlType,
1326
+ screenName,
1327
+ applicationName
1328
+ ].filter(Boolean).join(" · ")
1329
+ }),
1330
+ detail.notes && /* @__PURE__ */ jsx("p", {
1331
+ className: "whitespace-pre-wrap text-sm text-text-secondary",
1332
+ children: detail.notes
1333
+ })
1334
+ ]
1335
+ });
1336
+ }
1337
+ function TechnicalDetails({ detail }) {
1338
+ const tr = useTr();
1339
+ const [open, setOpen] = useState(false);
1340
+ return /* @__PURE__ */ jsxs("div", {
1341
+ className: "flex flex-col gap-1",
1342
+ children: [/* @__PURE__ */ jsx("button", {
1343
+ type: "button",
1344
+ onClick: () => setOpen((value) => !value),
1345
+ className: "self-start text-xs text-primary hover:underline",
1346
+ "aria-expanded": open,
1347
+ "data-testid": "element-library-element-technical-toggle",
1348
+ children: open ? tr("fluidgrids.elementLibrary.technical.hide", "Hide technical details") : tr("fluidgrids.elementLibrary.technical.show", "Show technical details")
1349
+ }), open && /* @__PURE__ */ jsx("pre", {
1350
+ className: "max-h-64 overflow-auto rounded-md border border-border-default bg-muted p-2 font-mono text-xs text-text-primary",
1351
+ "data-testid": "element-library-element-technical",
1352
+ children: JSON.stringify({
1353
+ key: detail.key,
1354
+ id: detail.id,
1355
+ target: detail.current.target
1356
+ }, null, 2)
1357
+ })]
1358
+ });
1359
+ }
1360
+ function ElementMissing({ error }) {
1361
+ const tr = useTr();
1362
+ return /* @__PURE__ */ jsxs("div", {
1363
+ className: "flex flex-col gap-2",
1364
+ children: [/* @__PURE__ */ jsx(LibraryError, {
1365
+ error,
1366
+ testId: "element-library-element-load-error"
1367
+ }), !error && /* @__PURE__ */ jsx("p", {
1368
+ className: "text-sm text-text-secondary",
1369
+ children: tr("fluidgrids.elementLibrary.error.notFound", "It no longer exists, or you cannot open it.")
1370
+ })]
1371
+ });
1372
+ }
1373
+ function ElementPanel({ elementId, applicationName, screens, access, onBack, onChanged }) {
1374
+ const tr = useTr();
1375
+ const element = useLibraryRead(elementId, fetchUiElement);
1376
+ const health = useLibraryRead(elementId, (id) => fetchUiElementHealth(id));
1377
+ const usage = useLibraryRead(elementId, fetchUiElementUsage);
1378
+ const [editing, setEditing] = useState(false);
1379
+ const [applying, setApplying] = useState(false);
1380
+ const workflows = useMemo(() => usageByWorkflow(usage.data?.visible ?? []), [usage.data]);
1381
+ const restrictedCount = usage.data?.restrictedCount ?? 0;
1382
+ const detail = element.data;
1383
+ if (element.loading && !detail) return /* @__PURE__ */ jsxs("div", {
1384
+ className: "flex flex-col gap-3",
1385
+ "data-testid": "element-library-element-loading",
1386
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-1/2" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-32 w-full" })]
1387
+ });
1388
+ if (!detail) return /* @__PURE__ */ jsx(ElementMissing, { error: element.error });
1389
+ const candidates = applyCandidates(workflows, detail.currentVersion);
1390
+ return /* @__PURE__ */ jsxs("div", {
1391
+ className: "flex min-w-0 flex-col gap-4",
1392
+ "data-testid": "element-library-element",
1393
+ children: [
1394
+ /* @__PURE__ */ jsx(ElementHeading, {
1395
+ detail,
1396
+ applicationName,
1397
+ screenName: screens.find((entry) => entry.id === detail.screenId)?.name,
1398
+ onBack
1399
+ }),
1400
+ /* @__PURE__ */ jsx(ElementActions, {
1401
+ detail,
1402
+ access,
1403
+ canApply: candidates.length > 0,
1404
+ inUse: workflows.length + restrictedCount,
1405
+ onEdit: () => setEditing(true),
1406
+ onApply: () => setApplying(true),
1407
+ onStatusChanged: (updated) => {
1408
+ element.refetch();
1409
+ onChanged(updated);
1410
+ },
1411
+ onDeleted: () => onChanged(null),
1412
+ onRefusedInUse: () => void usage.refetch()
1413
+ }),
1414
+ /* @__PURE__ */ jsx(ElementScreenshot, { fileId: detail.current.screenshotFileId ?? null }),
1415
+ /* @__PURE__ */ jsx(ElementVersions, { versions: detail.versions.nodes }),
1416
+ /* @__PURE__ */ jsx(ElementHealthCard, {
1417
+ health: health.data,
1418
+ loading: health.loading,
1419
+ error: health.error
1420
+ }),
1421
+ /* @__PURE__ */ jsx(ElementUsageList, {
1422
+ usage: workflows,
1423
+ restrictedCount,
1424
+ currentVersion: detail.currentVersion,
1425
+ loading: usage.loading,
1426
+ error: usage.error
1427
+ }),
1428
+ /* @__PURE__ */ jsx(TechnicalDetails, { detail }),
1429
+ /* @__PURE__ */ jsx(ElementDialog, {
1430
+ open: editing,
1431
+ onOpenChange: setEditing,
1432
+ applicationId: detail.applicationId,
1433
+ screens,
1434
+ element: {
1435
+ ...detail,
1436
+ target: detail.current.target
1437
+ },
1438
+ onSaved: (saved) => {
1439
+ setEditing(false);
1440
+ toast.success(tr("fluidgrids.elementLibrary.element.saved", "Element saved"));
1441
+ element.refetch();
1442
+ onChanged(saved);
1443
+ }
1444
+ }),
1445
+ /* @__PURE__ */ jsx(ApplyDialog, {
1446
+ open: applying,
1447
+ onOpenChange: setApplying,
1448
+ elementId: detail.id,
1449
+ elementName: detail.name,
1450
+ version: detail.currentVersion,
1451
+ candidates,
1452
+ restrictedCount,
1453
+ onApplied: () => void usage.refetch()
1454
+ })
1455
+ ]
1456
+ });
1457
+ }
1458
+
1459
+ // src/modules/element-library/components/LazySequenceEditor.tsx
1460
+ /**
1461
+ * The shared-sequence editor, loaded on first use: it brings the Use Browser
1462
+ * step editor and `@burdenoff/ui-engine`, which the Element library's lists do
1463
+ * not need. This file must not import the editor statically.
1464
+ */
1465
+ const SequenceEditor = lazy(() => import("./SequenceEditor-CFiHeHkR.js"));
1466
+ function LazySequenceEditor(props) {
1467
+ return /* @__PURE__ */ jsx(Suspense, {
1468
+ fallback: /* @__PURE__ */ jsxs("div", {
1469
+ className: "flex flex-col gap-3",
1470
+ "data-testid": "element-library-sequence-loading",
1471
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-1/2" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-48 w-full" })]
1472
+ }),
1473
+ children: /* @__PURE__ */ jsx(SequenceEditor, { ...props })
1474
+ });
1475
+ }
1476
+
1477
+ // src/modules/element-library/components/ApplicationDialog.tsx
1478
+ /**
1479
+ * New application and Edit application (spec 19 M4): a name, a key (fixed
1480
+ * once created), the URL patterns that identify the app's pages and where a
1481
+ * recording or a run starts. The service checks every field again.
1482
+ */
1483
+ function ApplicationForm({ application, onCancel, onSaved }) {
1484
+ const tr = useTr();
1485
+ const editing = application !== null;
1486
+ const [name, setName] = useState(application?.name ?? "");
1487
+ const [key, setKey] = useState(application?.key ?? "");
1488
+ const [keyTouched, setKeyTouched] = useState(editing);
1489
+ const [patterns, setPatterns] = useState(() => (application?.urlPatterns ?? []).join("\n"));
1490
+ const [startUrl, setStartUrl] = useState(application?.startUrl ?? "");
1491
+ const [saving, setSaving] = useState(false);
1492
+ const [error, setError] = useState(null);
1493
+ const effectiveKey = keyTouched ? key : keyFromName(name);
1494
+ const urlPatterns = parseUrlPatterns(patterns);
1495
+ const keyValid = LIBRARY_KEY_PATTERN.test(effectiveKey);
1496
+ const valid = name.trim().length > 0 && keyValid && urlPatterns.length > 0;
1497
+ const submit = async (event) => {
1498
+ event.preventDefault();
1499
+ if (!valid || saving) return;
1500
+ setSaving(true);
1501
+ setError(null);
1502
+ try {
1503
+ onSaved(application ? await updateUiApplication(application.id, {
1504
+ name: name.trim(),
1505
+ urlPatterns,
1506
+ startUrl: startUrl.trim() || null
1507
+ }) : await createUiApplication({
1508
+ name: name.trim(),
1509
+ key: effectiveKey,
1510
+ urlPatterns,
1511
+ startUrl: startUrl.trim() || null
1512
+ }));
1513
+ } catch (err) {
1514
+ setError(err);
1515
+ } finally {
1516
+ setSaving(false);
1517
+ }
1518
+ };
1519
+ return /* @__PURE__ */ jsxs("form", {
1520
+ onSubmit: (event) => void submit(event),
1521
+ className: "flex flex-col gap-4",
1522
+ "data-testid": "element-library-application-form",
1523
+ children: [
1524
+ /* @__PURE__ */ jsx(Field, {
1525
+ id: "element-library-application-name",
1526
+ label: tr("fluidgrids.elementLibrary.field.name", "Name"),
1527
+ children: /* @__PURE__ */ jsx(Input, {
1528
+ id: "element-library-application-name",
1529
+ value: name,
1530
+ maxLength: 200,
1531
+ onChange: (event) => setName(event.target.value),
1532
+ placeholder: tr("fluidgrids.elementLibrary.application.namePlaceholder", "Supplier portal"),
1533
+ "data-testid": "element-library-application-name"
1534
+ })
1535
+ }),
1536
+ /* @__PURE__ */ jsx(Field, {
1537
+ id: "element-library-application-key",
1538
+ label: tr("fluidgrids.elementLibrary.field.key", "Key"),
1539
+ hint: editing ? tr("fluidgrids.elementLibrary.field.keyFixed", "The key never changes once the application exists.") : tr("fluidgrids.elementLibrary.field.libraryKeyHint", "Letters, digits, hyphens and underscores; unique in the workspace."),
1540
+ children: /* @__PURE__ */ jsx(Input, {
1541
+ id: "element-library-application-key",
1542
+ value: effectiveKey,
1543
+ readOnly: editing,
1544
+ maxLength: 64,
1545
+ "aria-invalid": effectiveKey.length > 0 && !keyValid,
1546
+ onChange: (event) => {
1547
+ setKeyTouched(true);
1548
+ setKey(event.target.value);
1549
+ },
1550
+ className: "font-mono",
1551
+ "data-testid": "element-library-application-key"
1552
+ })
1553
+ }),
1554
+ /* @__PURE__ */ jsx(Field, {
1555
+ id: "element-library-application-patterns",
1556
+ label: tr("fluidgrids.elementLibrary.field.urlPatterns", "URL patterns"),
1557
+ hint: tr("fluidgrids.elementLibrary.field.urlPatternsHint", "One per line, with * as a wildcard, such as https://portal.example.com/*"),
1558
+ children: /* @__PURE__ */ jsx(Textarea, {
1559
+ id: "element-library-application-patterns",
1560
+ value: patterns,
1561
+ rows: 3,
1562
+ onChange: (event) => setPatterns(event.target.value),
1563
+ className: "font-mono",
1564
+ "data-testid": "element-library-application-patterns"
1565
+ })
1566
+ }),
1567
+ /* @__PURE__ */ jsx(Field, {
1568
+ id: "element-library-application-start",
1569
+ label: tr("fluidgrids.elementLibrary.field.startUrl", "Start page"),
1570
+ hint: tr("fluidgrids.elementLibrary.field.startUrlHint", "Optional. Where a recording or a run starts."),
1571
+ children: /* @__PURE__ */ jsx(Input, {
1572
+ id: "element-library-application-start",
1573
+ type: "url",
1574
+ value: startUrl,
1575
+ maxLength: 2048,
1576
+ onChange: (event) => setStartUrl(event.target.value),
1577
+ className: "font-mono",
1578
+ "data-testid": "element-library-application-start"
1579
+ })
1580
+ }),
1581
+ /* @__PURE__ */ jsx(LibraryError, {
1582
+ error,
1583
+ testId: "element-library-application-error"
1584
+ }),
1585
+ /* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
1586
+ type: "button",
1587
+ variant: "outline",
1588
+ onClick: onCancel,
1589
+ children: tr("fluidgrids.elementLibrary.cancel", "Cancel")
1590
+ }), /* @__PURE__ */ jsx(Button$1, {
1591
+ type: "submit",
1592
+ disabled: !valid || saving,
1593
+ "data-testid": "element-library-application-save",
1594
+ children: editing ? tr("fluidgrids.elementLibrary.save", "Save") : tr("fluidgrids.elementLibrary.create", "Create")
1595
+ })] })
1596
+ ]
1597
+ });
1598
+ }
1599
+ function ApplicationDialog({ open, onOpenChange, application = null, onSaved }) {
1600
+ const tr = useTr();
1601
+ return /* @__PURE__ */ jsx(ResponsiveDialog, {
1602
+ open,
1603
+ onOpenChange,
1604
+ children: /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
1605
+ className: "max-h-[90vh] overflow-y-auto sm:max-w-lg",
1606
+ children: [/* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: application ? tr("fluidgrids.elementLibrary.editApplication", "Edit application") : tr("fluidgrids.elementLibrary.newApplication", "New application") }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: tr("fluidgrids.elementLibrary.application.description", "A web app your workflows work in. Its screens and elements are saved under it.") })] }), open && /* @__PURE__ */ jsx(ApplicationForm, {
1607
+ application,
1608
+ onCancel: () => onOpenChange(false),
1609
+ onSaved
1610
+ }, application?.id ?? "new")]
1611
+ })
1612
+ });
1613
+ }
1614
+
1615
+ // src/modules/element-library/components/ScreenDialog.tsx
1616
+ /**
1617
+ * New screen and Edit screen (spec 19 M4 marker 2): a page of an application,
1618
+ * or a part of one, that groups elements. A URL or title pattern helps tell
1619
+ * the screens apart; both are optional.
1620
+ */
1621
+ function ScreenForm({ applicationId, screen, onCancel, onSaved }) {
1622
+ const tr = useTr();
1623
+ const [name, setName] = useState(screen?.name ?? "");
1624
+ const [key, setKey] = useState(screen?.key ?? "");
1625
+ const [keyTouched, setKeyTouched] = useState(screen !== null);
1626
+ const [urlPattern, setUrlPattern] = useState(screen?.urlPattern ?? "");
1627
+ const [titlePattern, setTitlePattern] = useState(screen?.titlePattern ?? "");
1628
+ const [saving, setSaving] = useState(false);
1629
+ const [error, setError] = useState(null);
1630
+ const effectiveKey = keyTouched ? key : keyFromName(name);
1631
+ const valid = name.trim().length > 0 && LIBRARY_KEY_PATTERN.test(effectiveKey);
1632
+ const submit = async (event) => {
1633
+ event.preventDefault();
1634
+ if (!valid || saving) return;
1635
+ setSaving(true);
1636
+ setError(null);
1637
+ try {
1638
+ onSaved(await saveUiScreen({
1639
+ id: screen?.id ?? null,
1640
+ applicationId,
1641
+ key: effectiveKey,
1642
+ name: name.trim(),
1643
+ urlPattern: urlPattern.trim() || null,
1644
+ titlePattern: titlePattern.trim() || null
1645
+ }));
1646
+ } catch (err) {
1647
+ setError(err);
1648
+ } finally {
1649
+ setSaving(false);
1650
+ }
1651
+ };
1652
+ return /* @__PURE__ */ jsxs("form", {
1653
+ onSubmit: (event) => void submit(event),
1654
+ className: "flex flex-col gap-4",
1655
+ "data-testid": "element-library-screen-form",
1656
+ children: [
1657
+ /* @__PURE__ */ jsx(Field, {
1658
+ id: "element-library-screen-name",
1659
+ label: tr("fluidgrids.elementLibrary.field.name", "Name"),
1660
+ children: /* @__PURE__ */ jsx(Input, {
1661
+ id: "element-library-screen-name",
1662
+ value: name,
1663
+ maxLength: 200,
1664
+ onChange: (event) => setName(event.target.value),
1665
+ placeholder: tr("fluidgrids.elementLibrary.screen.namePlaceholder", "Invoice search"),
1666
+ "data-testid": "element-library-screen-name"
1667
+ })
1668
+ }),
1669
+ /* @__PURE__ */ jsx(Field, {
1670
+ id: "element-library-screen-key",
1671
+ label: tr("fluidgrids.elementLibrary.field.key", "Key"),
1672
+ hint: tr("fluidgrids.elementLibrary.field.screenKeyHint", "Letters, digits, hyphens and underscores; unique in the application."),
1673
+ children: /* @__PURE__ */ jsx(Input, {
1674
+ id: "element-library-screen-key",
1675
+ value: effectiveKey,
1676
+ readOnly: screen !== null,
1677
+ maxLength: 64,
1678
+ onChange: (event) => {
1679
+ setKeyTouched(true);
1680
+ setKey(event.target.value);
1681
+ },
1682
+ className: "font-mono",
1683
+ "data-testid": "element-library-screen-key"
1684
+ })
1685
+ }),
1686
+ /* @__PURE__ */ jsx(Field, {
1687
+ id: "element-library-screen-url",
1688
+ label: tr("fluidgrids.elementLibrary.field.urlPattern", "URL pattern"),
1689
+ hint: tr("fluidgrids.elementLibrary.field.optional", "Optional."),
1690
+ children: /* @__PURE__ */ jsx(Input, {
1691
+ id: "element-library-screen-url",
1692
+ value: urlPattern,
1693
+ maxLength: 500,
1694
+ onChange: (event) => setUrlPattern(event.target.value),
1695
+ className: "font-mono",
1696
+ "data-testid": "element-library-screen-url"
1697
+ })
1698
+ }),
1699
+ /* @__PURE__ */ jsx(Field, {
1700
+ id: "element-library-screen-title",
1701
+ label: tr("fluidgrids.elementLibrary.field.titlePattern", "Title pattern"),
1702
+ hint: tr("fluidgrids.elementLibrary.field.optional", "Optional."),
1703
+ children: /* @__PURE__ */ jsx(Input, {
1704
+ id: "element-library-screen-title",
1705
+ value: titlePattern,
1706
+ maxLength: 500,
1707
+ onChange: (event) => setTitlePattern(event.target.value),
1708
+ "data-testid": "element-library-screen-title"
1709
+ })
1710
+ }),
1711
+ /* @__PURE__ */ jsx(LibraryError, {
1712
+ error,
1713
+ testId: "element-library-screen-error"
1714
+ }),
1715
+ /* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button$1, {
1716
+ type: "button",
1717
+ variant: "outline",
1718
+ onClick: onCancel,
1719
+ children: tr("fluidgrids.elementLibrary.cancel", "Cancel")
1720
+ }), /* @__PURE__ */ jsx(Button$1, {
1721
+ type: "submit",
1722
+ disabled: !valid || saving,
1723
+ "data-testid": "element-library-screen-save",
1724
+ children: tr("fluidgrids.elementLibrary.save", "Save")
1725
+ })] })
1726
+ ]
1727
+ });
1728
+ }
1729
+ function ScreenDialog({ open, onOpenChange, applicationId, screen = null, onSaved }) {
1730
+ const tr = useTr();
1731
+ return /* @__PURE__ */ jsx(ResponsiveDialog, {
1732
+ open,
1733
+ onOpenChange,
1734
+ children: /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
1735
+ className: "max-h-[90vh] overflow-y-auto sm:max-w-lg",
1736
+ children: [/* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: screen ? tr("fluidgrids.elementLibrary.editScreen", "Edit screen") : tr("fluidgrids.elementLibrary.newScreen", "New screen") }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: tr("fluidgrids.elementLibrary.screen.description", "A page of the application, or a part of one, that groups its elements.") })] }), open && /* @__PURE__ */ jsx(ScreenForm, {
1737
+ applicationId,
1738
+ screen,
1739
+ onCancel: () => onOpenChange(false),
1740
+ onSaved
1741
+ }, screen?.id ?? "new")]
1742
+ })
1743
+ });
1744
+ }
1745
+
1746
+ // src/modules/element-library/components/LibraryDialogs.tsx
1747
+ /**
1748
+ * The Element library page's dialogs: a new or edited application, a new or
1749
+ * edited screen, and a new element. One is open at a time.
1750
+ */
1751
+ function LibraryDialogs({ dialog, onClose, application, onApplicationSaved, onScreenSaved, onElementSaved }) {
1752
+ const tr = useTr();
1753
+ const close = (open) => {
1754
+ if (!open) onClose();
1755
+ };
1756
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1757
+ /* @__PURE__ */ jsx(ApplicationDialog, {
1758
+ open: dialog?.kind === "application",
1759
+ onOpenChange: close,
1760
+ application: dialog?.kind === "application" && dialog.editing ? application : null,
1761
+ onSaved: (saved) => {
1762
+ onClose();
1763
+ toast.success(tr("fluidgrids.elementLibrary.application.saved", "Application saved"));
1764
+ onApplicationSaved(saved);
1765
+ }
1766
+ }),
1767
+ application && /* @__PURE__ */ jsx(ScreenDialog, {
1768
+ open: dialog?.kind === "screen",
1769
+ onOpenChange: close,
1770
+ applicationId: application.id,
1771
+ screen: dialog?.kind === "screen" ? dialog.screen : null,
1772
+ onSaved: () => {
1773
+ onClose();
1774
+ toast.success(tr("fluidgrids.elementLibrary.screen.saved", "Screen saved"));
1775
+ onScreenSaved();
1776
+ }
1777
+ }),
1778
+ application && /* @__PURE__ */ jsx(ElementDialog, {
1779
+ open: dialog?.kind === "element",
1780
+ onOpenChange: close,
1781
+ applicationId: application.id,
1782
+ screens: application.screens,
1783
+ screenId: dialog?.kind === "element" ? dialog.screenId : null,
1784
+ pickUrl: pageOfUrlPattern(application.urlPatterns[0]),
1785
+ onSaved: (saved) => {
1786
+ onClose();
1787
+ toast.success(tr("fluidgrids.elementLibrary.element.saved", "Element saved"));
1788
+ onElementSaved(saved);
1789
+ }
1790
+ })
1791
+ ] });
1792
+ }
1793
+
1794
+ // src/modules/element-library/components/LibraryHeader.tsx
1795
+ /**
1796
+ * The Element library page's header: its title and purpose, New application
1797
+ * for people who may create one, the kill-switch banner, and the search box.
1798
+ * The tour anchors sit on the header (shown in every state), the search and
1799
+ * the create button.
1800
+ */
1801
+ function LibraryHeader({ access, searchText, onSearchText, onCreate }) {
1802
+ const tr = useTr();
1803
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1804
+ /* @__PURE__ */ jsxs("header", {
1805
+ className: "flex min-w-0 flex-wrap items-start justify-between gap-4",
1806
+ "data-tour": "fluidgrids-element-library-header",
1807
+ children: [/* @__PURE__ */ jsxs("div", {
1808
+ className: "min-w-0",
1809
+ children: [/* @__PURE__ */ jsx("h1", {
1810
+ className: "text-2xl font-semibold text-text-primary",
1811
+ children: tr("fluidgrids.elementLibrary.title", "Element library")
1812
+ }), /* @__PURE__ */ jsx(PagePurpose, {
1813
+ icon: /* @__PURE__ */ jsx(Boxes, {
1814
+ className: "size-4",
1815
+ "aria-hidden": "true"
1816
+ }),
1817
+ children: tr("fluidgrids.elementLibrary.subtitle", "Applications, their screens and elements, and shared sequences that any Use Browser step can use.")
1818
+ })]
1819
+ }), access.canCreate && /* @__PURE__ */ jsxs(Button$1, {
1820
+ onClick: onCreate,
1821
+ "data-tour": "fluidgrids-element-library-create",
1822
+ "data-testid": "element-library-new-application",
1823
+ children: [/* @__PURE__ */ jsx(Plus, {
1824
+ className: "mr-1 size-4",
1825
+ "aria-hidden": "true"
1826
+ }), tr("fluidgrids.elementLibrary.newApplication", "New application")]
1827
+ })]
1828
+ }),
1829
+ !access.rpaWeb && /* @__PURE__ */ jsx(RpaOffBanner, {}),
1830
+ /* @__PURE__ */ jsxs("div", {
1831
+ className: "relative w-full max-w-md",
1832
+ "data-tour": "fluidgrids-element-library-search",
1833
+ children: [/* @__PURE__ */ jsx(Search, {
1834
+ className: "pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-text-secondary",
1835
+ "aria-hidden": "true"
1836
+ }), /* @__PURE__ */ jsx(Input, {
1837
+ type: "search",
1838
+ value: searchText,
1839
+ onChange: (event) => onSearchText(event.target.value),
1840
+ placeholder: tr("fluidgrids.elementLibrary.search", "Search elements"),
1841
+ "aria-label": tr("fluidgrids.elementLibrary.search", "Search elements"),
1842
+ className: "pl-9",
1843
+ "data-testid": "element-library-search"
1844
+ })]
1845
+ })
1846
+ ] });
1847
+ }
1848
+
1849
+ // src/modules/element-library/components/SearchResults.tsx
1850
+ /**
1851
+ * The elements across the workspace that match the Element library search
1852
+ * (spec 19 M4 marker 1). Choosing one opens it in its application.
1853
+ */
1854
+ function SearchResults({ query, results, onOpen }) {
1855
+ const tr = useTr();
1856
+ let body;
1857
+ if (results.loading && results.items.length === 0) body = /* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full" });
1858
+ else if (results.items.length === 0) body = /* @__PURE__ */ jsx(EmptyState, {
1859
+ kind: "no-results",
1860
+ size: "panel",
1861
+ compact: true,
1862
+ icon: null,
1863
+ title: tr("fluidgrids.elementLibrary.noResults", "No element matches your search.")
1864
+ });
1865
+ else body = /* @__PURE__ */ jsx("ul", {
1866
+ className: "flex flex-col gap-1",
1867
+ children: results.items.map((element) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
1868
+ type: "button",
1869
+ onClick: () => onOpen(element),
1870
+ className: "flex w-full min-w-0 items-center justify-between gap-2 rounded-md border border-border-default p-2 text-left text-sm hover:bg-muted",
1871
+ "data-testid": `element-library-result-${element.key}`,
1872
+ children: [/* @__PURE__ */ jsx("span", {
1873
+ className: "min-w-0 truncate",
1874
+ children: element.name
1875
+ }), /* @__PURE__ */ jsxs("span", {
1876
+ className: "shrink-0 text-xs text-text-secondary",
1877
+ children: ["v", element.currentVersion]
1878
+ })]
1879
+ }) }, element.id))
1880
+ });
1881
+ return /* @__PURE__ */ jsxs("section", {
1882
+ className: "flex min-w-0 flex-col gap-2",
1883
+ "data-testid": "element-library-results",
1884
+ children: [
1885
+ /* @__PURE__ */ jsx("h2", {
1886
+ className: "text-sm font-semibold text-text-primary",
1887
+ children: tr("fluidgrids.elementLibrary.results", "Elements matching “{{query}}”", { query })
1888
+ }),
1889
+ /* @__PURE__ */ jsx(LibraryError, {
1890
+ error: results.error,
1891
+ testId: "element-library-results-error"
1892
+ }),
1893
+ body
1894
+ ]
1895
+ });
1896
+ }
1897
+
1898
+ // src/modules/element-library/hooks/useElementLibraryAccess.ts
1899
+ /**
1900
+ * What the person may do on the Element library page (RPA plan P1-13): the
1901
+ * `ui-element` actions of the gateway's `@rbac` directives, and whether the
1902
+ * workspace's `fluidgrids.rpa.web` kill switch lets changes through. Reads
1903
+ * need only `ui-element:read`; the gateway and the service stay the
1904
+ * enforcement point, so these only decide which buttons are offered.
1905
+ */
1906
+ function useElementLibraryAccess() {
1907
+ const rpaWeb = useRpaWebEnabled();
1908
+ const create = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.UI_ELEMENT_CREATE);
1909
+ const update = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.UI_ELEMENT_UPDATE);
1910
+ const remove = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.UI_ELEMENT_DELETE);
1911
+ const publish = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.UI_ELEMENT_PUBLISH);
1912
+ const test = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.UI_ELEMENT_TEST);
1913
+ return {
1914
+ rpaWeb,
1915
+ canCreate: rpaWeb && create.allowed,
1916
+ canUpdate: rpaWeb && update.allowed,
1917
+ canDelete: rpaWeb && remove.allowed,
1918
+ canPublish: rpaWeb && publish.allowed,
1919
+ canTest: test.allowed
1920
+ };
1921
+ }
1922
+
1923
+ // src/modules/element-library/hooks/useLibraryUrl.ts
1924
+ /**
1925
+ * What the Element library page has open, kept in the URL so a link opens
1926
+ * the same view: `?app=<id>&element=<id>`, `?app=<id>&tab=sequences&sequence=<id|new>`
1927
+ * and `?q=<search>`.
1928
+ *
1929
+ * The search box writes `q` once typing pauses. Otherwise the box follows the
1930
+ * URL, so Back and Forward bring their search back instead of the box writing
1931
+ * its old text over them.
1932
+ */
1933
+ /** The `sequence` value of the URL that opens a new, unsaved sequence. */
1934
+ const NEW_SEQUENCE = "new";
1935
+ /** How long the search waits after a keystroke before it asks. */
1936
+ const SEARCH_DELAY_MS = 300;
1937
+ function useLibraryUrl() {
1938
+ const [params, setParams] = useSearchParams();
1939
+ const appId = params.get("app");
1940
+ const elementId = params.get("element");
1941
+ const sequenceParam = params.get("sequence");
1942
+ const query = params.get("q") ?? "";
1943
+ const tab = params.get("tab") === "sequences" || sequenceParam ? "sequences" : "elements";
1944
+ const [searchText, setSearchText] = useState(query);
1945
+ const [typing, setTyping] = useState(false);
1946
+ const [seenQuery, setSeenQuery] = useState(query);
1947
+ if (query !== seenQuery) {
1948
+ setSeenQuery(query);
1949
+ if (!typing) setSearchText(query);
1950
+ }
1951
+ const update = useCallback((changes) => {
1952
+ setParams((current) => {
1953
+ const next = new URLSearchParams(current);
1954
+ for (const [key, value] of Object.entries(changes)) if (value === null) next.delete(key);
1955
+ else next.set(key, value);
1956
+ return next;
1957
+ });
1958
+ }, [setParams]);
1959
+ useEffect(() => {
1960
+ if (!typing) return void 0;
1961
+ const timer = setTimeout(() => {
1962
+ setTyping(false);
1963
+ if (searchText.trim() !== query) update({ q: searchText.trim() || null });
1964
+ }, SEARCH_DELAY_MS);
1965
+ return () => clearTimeout(timer);
1966
+ }, [
1967
+ typing,
1968
+ searchText,
1969
+ query,
1970
+ update
1971
+ ]);
1972
+ const onSearchText = useCallback((text) => {
1973
+ setTyping(true);
1974
+ setSearchText(text);
1975
+ }, []);
1976
+ const leaveSearch = useCallback((changes) => {
1977
+ setTyping(false);
1978
+ setSearchText("");
1979
+ update({
1980
+ ...changes,
1981
+ q: null
1982
+ });
1983
+ }, [update]);
1984
+ return {
1985
+ appId,
1986
+ elementId,
1987
+ sequenceParam,
1988
+ sequenceId: sequenceParam && sequenceParam !== "new" ? sequenceParam : null,
1989
+ tab,
1990
+ query,
1991
+ searchText,
1992
+ onSearchText,
1993
+ update,
1994
+ leaveSearch
1995
+ };
1996
+ }
1997
+
1998
+ // src/modules/element-library/pages/ElementLibraryPage.tsx
1999
+ /**
2000
+ * Element library page (RPA plan P1-13, spec 19 M4 and M5; More tools ›
2001
+ * Element library): the applications a workspace automates, their screens
2002
+ * and elements, and the shared sequences any Use Browser step can call.
2003
+ *
2004
+ * Three panels side by side on a wide screen (applications, one application,
2005
+ * one element or sequence); on a phone one panel at a time with a way back,
2006
+ * and never a sideways scroll. What is open lives in the URL
2007
+ * (`useLibraryUrl`), so a link opens the same view.
2008
+ *
2009
+ * Reads need `ui-element:read`. Buttons for changes show only to people who
2010
+ * may make them, and only while the workspace's `fluidgrids.rpa.web` kill
2011
+ * switch is on; the gateway and the service enforce both regardless.
2012
+ */
2013
+ /** The reads of the page, for what the URL has open. */
2014
+ function useLibraryData(url) {
2015
+ return {
2016
+ applications: usePagedLibraryList("all", (_key, after) => fetchUiApplications(null, after)),
2017
+ application: useLibraryRead(url.appId, fetchUiApplication),
2018
+ elements: usePagedLibraryList(url.appId, (id, after) => fetchUiElements({ applicationId: id }, after)),
2019
+ sequences: usePagedLibraryList(url.appId, (id, after) => fetchUiSharedSequences(id, null, after)),
2020
+ results: usePagedLibraryList(url.query || null, (text, after) => fetchUiElements({ search: text }, after))
2021
+ };
2022
+ }
2023
+ /** The URL changes that close the open application. */
2024
+ const CLOSE_APPLICATION = {
2025
+ app: null,
2026
+ element: null,
2027
+ sequence: null,
2028
+ tab: null
2029
+ };
2030
+ /** The middle panel without an open application: loading, refused, or a hint. */
2031
+ function NoApplication({ appId, application }) {
2032
+ const tr = useTr();
2033
+ if (!appId) return /* @__PURE__ */ jsx("p", {
2034
+ className: "hidden text-sm text-text-secondary lg:block",
2035
+ children: tr("fluidgrids.elementLibrary.chooseApplication", "Choose an application to see its screens, elements and sequences.")
2036
+ });
2037
+ if (application.loading) return /* @__PURE__ */ jsx(Skeleton, { className: "h-32 w-full" });
2038
+ return /* @__PURE__ */ jsx(LibraryError, {
2039
+ error: application.error ?? /* @__PURE__ */ new Error("Not found"),
2040
+ testId: "element-library-application-load-error"
2041
+ });
2042
+ }
2043
+ /** The right-hand panel: the open sequence, or the open element. */
2044
+ function Detail({ url, data, access, refreshApplication }) {
2045
+ const detail = data.application.data ?? null;
2046
+ if (url.sequenceParam !== null && detail) return /* @__PURE__ */ jsx(LazySequenceEditor, {
2047
+ sequenceId: url.sequenceId,
2048
+ applicationId: detail.id,
2049
+ applicationName: detail.name,
2050
+ elements: data.elements.items,
2051
+ access,
2052
+ onClose: () => url.update({ sequence: null }),
2053
+ onChanged: (saved) => {
2054
+ data.sequences.refetch();
2055
+ refreshApplication();
2056
+ url.update({ sequence: saved ? saved.id : null });
2057
+ }
2058
+ }, url.sequenceParam);
2059
+ if (!url.elementId) return null;
2060
+ return /* @__PURE__ */ jsx(ElementPanel, {
2061
+ elementId: url.elementId,
2062
+ applicationName: detail?.name ?? "",
2063
+ screens: detail?.screens ?? [],
2064
+ access,
2065
+ onBack: () => url.update({ element: null }),
2066
+ onChanged: (changed) => {
2067
+ data.elements.refetch();
2068
+ refreshApplication();
2069
+ if (!changed) url.update({ element: null });
2070
+ }
2071
+ }, url.elementId);
2072
+ }
2073
+ /** The middle panel: search results, the open application, or neither. */
2074
+ function LibraryMiddle({ url, data, access, onDialog, onDeleteApplication, actionError }) {
2075
+ const detail = data.application.data ?? null;
2076
+ if (url.query) return /* @__PURE__ */ jsx(SearchResults, {
2077
+ query: url.query,
2078
+ results: data.results,
2079
+ onOpen: (element) => url.leaveSearch({
2080
+ app: element.applicationId,
2081
+ element: element.id,
2082
+ sequence: null,
2083
+ tab: null
2084
+ })
2085
+ });
2086
+ else if (detail) return /* @__PURE__ */ jsx(ApplicationPanel, {
2087
+ application: detail,
2088
+ elements: data.elements,
2089
+ sequences: data.sequences,
2090
+ tab: url.tab,
2091
+ onTab: (next) => url.update({
2092
+ tab: next === "sequences" ? "sequences" : null,
2093
+ sequence: null
2094
+ }),
2095
+ selectedElementId: url.elementId,
2096
+ selectedSequenceId: url.sequenceId,
2097
+ onSelectElement: (id) => url.update({
2098
+ element: id,
2099
+ sequence: null
2100
+ }),
2101
+ onSelectSequence: (id) => url.update({
2102
+ sequence: id,
2103
+ element: null,
2104
+ tab: "sequences"
2105
+ }),
2106
+ onNewSequence: () => url.update({
2107
+ sequence: "new",
2108
+ element: null,
2109
+ tab: "sequences"
2110
+ }),
2111
+ onNewElement: (screenId) => onDialog({
2112
+ kind: "element",
2113
+ screenId
2114
+ }),
2115
+ onNewScreen: () => onDialog({
2116
+ kind: "screen",
2117
+ screen: null
2118
+ }),
2119
+ onEditScreen: (screen) => onDialog({
2120
+ kind: "screen",
2121
+ screen
2122
+ }),
2123
+ onEditApplication: () => onDialog({
2124
+ kind: "application",
2125
+ editing: true
2126
+ }),
2127
+ onDeleteApplication: () => onDeleteApplication(),
2128
+ onBack: () => url.update(CLOSE_APPLICATION),
2129
+ access,
2130
+ actionError
2131
+ });
2132
+ else return /* @__PURE__ */ jsx(NoApplication, {
2133
+ appId: url.appId,
2134
+ application: data.application
2135
+ });
2136
+ }
2137
+ function ElementLibraryPage() {
2138
+ const tr = useTr();
2139
+ const access = useElementLibraryAccess();
2140
+ const url = useLibraryUrl();
2141
+ const data = useLibraryData(url);
2142
+ const [dialog, setDialog] = useState(null);
2143
+ const [appActionError, setAppActionError] = useState(null);
2144
+ const detail = data.application.data ?? null;
2145
+ const sequenceOpen = url.sequenceParam !== null && detail !== null;
2146
+ let level = 0;
2147
+ if (sequenceOpen || url.elementId) level = 2;
2148
+ else if (url.appId || url.query) level = 1;
2149
+ const refreshApplication = () => {
2150
+ data.application.refetch();
2151
+ data.applications.refetch();
2152
+ };
2153
+ const deleteApplication = async () => {
2154
+ if (!detail) return;
2155
+ if (!window.confirm(tr("fluidgrids.elementLibrary.application.deleteConfirm", "Delete {{name}} with its screens? This cannot be undone.", { name: detail.name }))) return;
2156
+ setAppActionError(null);
2157
+ try {
2158
+ await deleteUiApplication(detail.id);
2159
+ toast.success(tr("fluidgrids.elementLibrary.application.deleted", "Application deleted"));
2160
+ url.update(CLOSE_APPLICATION);
2161
+ data.applications.refetch();
2162
+ } catch (err) {
2163
+ setAppActionError(err);
2164
+ }
2165
+ };
2166
+ const middle = /* @__PURE__ */ jsx(LibraryMiddle, {
2167
+ url,
2168
+ data,
2169
+ access,
2170
+ onDialog: setDialog,
2171
+ onDeleteApplication: () => void deleteApplication(),
2172
+ actionError: appActionError
2173
+ });
2174
+ const right = /* @__PURE__ */ jsx(Detail, {
2175
+ url,
2176
+ data,
2177
+ access,
2178
+ refreshApplication
2179
+ });
2180
+ const rightOpen = sequenceOpen || url.elementId !== null;
2181
+ return /* @__PURE__ */ jsxs("div", {
2182
+ className: "flex min-w-0 flex-col gap-6 p-4 sm:p-6",
2183
+ "data-testid": "element-library-page",
2184
+ children: [
2185
+ /* @__PURE__ */ jsx(LibraryHeader, {
2186
+ access,
2187
+ searchText: url.searchText,
2188
+ onSearchText: url.onSearchText,
2189
+ onCreate: () => setDialog({
2190
+ kind: "application",
2191
+ editing: false
2192
+ })
2193
+ }),
2194
+ /* @__PURE__ */ jsxs("div", {
2195
+ className: cn("grid min-w-0 grid-cols-1 gap-6", sequenceOpen ? "lg:grid-cols-[minmax(0,16rem)_minmax(0,1fr)]" : "lg:grid-cols-[minmax(0,16rem)_minmax(0,1fr)_minmax(0,26rem)]"),
2196
+ children: [
2197
+ /* @__PURE__ */ jsx("div", {
2198
+ className: cn("min-w-0", level === 0 ? "block" : "hidden lg:block"),
2199
+ children: /* @__PURE__ */ jsx(ApplicationsPanel, {
2200
+ applications: data.applications.items,
2201
+ loading: data.applications.loading,
2202
+ error: data.applications.error,
2203
+ hasMore: data.applications.hasMore,
2204
+ loadingMore: data.applications.loadingMore,
2205
+ onLoadMore: () => void data.applications.loadMore(),
2206
+ selectedId: url.appId,
2207
+ onSelect: (id) => url.leaveSearch({
2208
+ ...CLOSE_APPLICATION,
2209
+ app: id
2210
+ }),
2211
+ onCreate: access.canCreate ? () => setDialog({
2212
+ kind: "application",
2213
+ editing: false
2214
+ }) : void 0,
2215
+ searching: false
2216
+ })
2217
+ }),
2218
+ !sequenceOpen && /* @__PURE__ */ jsx("div", {
2219
+ className: cn("min-w-0", level === 1 ? "block" : "hidden lg:block"),
2220
+ children: middle
2221
+ }),
2222
+ /* @__PURE__ */ jsx("div", {
2223
+ className: cn("min-w-0", level === 2 ? "block" : "hidden lg:block", !rightOpen && "lg:hidden"),
2224
+ "data-testid": "element-library-detail",
2225
+ children: right
2226
+ })
2227
+ ]
2228
+ }),
2229
+ /* @__PURE__ */ jsx(LibraryDialogs, {
2230
+ dialog,
2231
+ onClose: () => setDialog(null),
2232
+ application: detail,
2233
+ onApplicationSaved: (saved) => {
2234
+ data.applications.refetch();
2235
+ if (saved.id === url.appId) data.application.refetch();
2236
+ else url.leaveSearch({
2237
+ ...CLOSE_APPLICATION,
2238
+ app: saved.id
2239
+ });
2240
+ },
2241
+ onScreenSaved: () => void data.application.refetch(),
2242
+ onElementSaved: (saved) => {
2243
+ data.elements.refetch();
2244
+ refreshApplication();
2245
+ url.update({
2246
+ element: saved.id,
2247
+ sequence: null,
2248
+ tab: null
2249
+ });
2250
+ }
2251
+ })
2252
+ ]
2253
+ });
2254
+ }
2255
+
2256
+ export { ElementLibraryPage, ElementLibraryPage as default };