@hotmeshio/long-tail 0.30.4 → 0.30.5

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 (249) hide show
  1. package/build/api/escalations/index.d.ts +1 -0
  2. package/build/api/escalations/index.js +5 -2
  3. package/build/api/escalations/roster-action.d.ts +11 -0
  4. package/build/api/escalations/roster-action.js +47 -30
  5. package/build/api/escalations/roster-scan.d.ts +26 -0
  6. package/build/api/escalations/roster-scan.js +114 -0
  7. package/build/api/scan-codes/context.d.ts +9 -1
  8. package/build/api/scan-codes/context.js +16 -1
  9. package/build/api/scan-codes/execute.js +6 -1
  10. package/build/api/scan-codes/fill-labels.d.ts +8 -0
  11. package/build/api/scan-codes/fill-labels.js +23 -2
  12. package/build/api/scan-codes/hold.js +2 -0
  13. package/build/api/scan-codes/located.d.ts +10 -0
  14. package/build/api/scan-codes/located.js +74 -0
  15. package/build/api/scan-codes/open.d.ts +9 -0
  16. package/build/api/scan-codes/open.js +99 -0
  17. package/build/api/scan-codes/present.js +1 -0
  18. package/build/api/scan-codes/verb-fill.js +1 -1
  19. package/build/routes/escalations/resolve.js +18 -0
  20. package/build/services/role/index.d.ts +2 -0
  21. package/build/services/role/index.js +7 -0
  22. package/build/services/role/scan-done.js +4 -1
  23. package/build/services/role/sql.d.ts +1 -0
  24. package/build/services/role/sql.js +3 -1
  25. package/build/services/role/types.d.ts +2 -0
  26. package/build/services/scan-code/index.d.ts +1 -1
  27. package/build/services/scan-code/index.js +2 -1
  28. package/build/services/scan-code/parse.d.ts +5 -1
  29. package/build/services/scan-code/parse.js +8 -2
  30. package/build/services/scan-code/validate-station.d.ts +13 -0
  31. package/build/services/scan-code/validate-station.js +81 -0
  32. package/build/services/scan-code/validate-subject.js +33 -6
  33. package/build/services/scan-code/validate.js +12 -18
  34. package/build/system/mcp-servers/admin/schemas.d.ts +471 -4
  35. package/build/system/mcp-servers/admin/schemas.js +32 -4
  36. package/build/tsconfig.tsbuildinfo +1 -1
  37. package/build/types/index.d.ts +1 -1
  38. package/build/types/scan-choice.d.ts +2 -4
  39. package/build/types/scan-code/constants.d.ts +1 -0
  40. package/build/types/scan-code/constants.js +1 -0
  41. package/build/types/scan-code/response.d.ts +22 -4
  42. package/build/types/scan-code/rule.d.ts +61 -3
  43. package/dashboard/dist/assets/{AdminDashboard-VQ1fhhJP.js → AdminDashboard-D12QiMM5.js} +2 -2
  44. package/dashboard/dist/assets/{AdminDashboard-VQ1fhhJP.js.map → AdminDashboard-D12QiMM5.js.map} +1 -1
  45. package/dashboard/dist/assets/{AgentConfigPage-BOe_W2Ij.js → AgentConfigPage-BKQd9b8m.js} +2 -2
  46. package/dashboard/dist/assets/{AgentConfigPage-BOe_W2Ij.js.map → AgentConfigPage-BKQd9b8m.js.map} +1 -1
  47. package/dashboard/dist/assets/{AgentDetailPage-5ov5D9V2.js → AgentDetailPage-ie-DxsIj.js} +3 -3
  48. package/dashboard/dist/assets/{AgentDetailPage-5ov5D9V2.js.map → AgentDetailPage-ie-DxsIj.js.map} +1 -1
  49. package/dashboard/dist/assets/{AgentsPage-DDFMKHhI.js → AgentsPage-Nqm2DxCP.js} +2 -2
  50. package/dashboard/dist/assets/{AgentsPage-DDFMKHhI.js.map → AgentsPage-Nqm2DxCP.js.map} +1 -1
  51. package/dashboard/dist/assets/{AvailableEscalationsPage-GFn8Sgg1.js → AvailableEscalationsPage-BRKyG5qZ.js} +2 -2
  52. package/dashboard/dist/assets/{AvailableEscalationsPage-GFn8Sgg1.js.map → AvailableEscalationsPage-BRKyG5qZ.js.map} +1 -1
  53. package/dashboard/dist/assets/{BotPicker-Dqpo36dM.js → BotPicker-BizdmeJp.js} +2 -2
  54. package/dashboard/dist/assets/{BotPicker-Dqpo36dM.js.map → BotPicker-BizdmeJp.js.map} +1 -1
  55. package/dashboard/dist/assets/{BulkAssignModal-CmLVxkz-.js → BulkAssignModal-BWfzPrRk.js} +2 -2
  56. package/dashboard/dist/assets/{BulkAssignModal-CmLVxkz-.js.map → BulkAssignModal-BWfzPrRk.js.map} +1 -1
  57. package/dashboard/dist/assets/{CapabilitiesPage-Dfkip6_b.js → CapabilitiesPage-DT8q7Zlh.js} +2 -2
  58. package/dashboard/dist/assets/{CapabilitiesPage-Dfkip6_b.js.map → CapabilitiesPage-DT8q7Zlh.js.map} +1 -1
  59. package/dashboard/dist/assets/{CollapsibleSection-CYNYMYSa.js → CollapsibleSection-al5mqR4O.js} +2 -2
  60. package/dashboard/dist/assets/{CollapsibleSection-CYNYMYSa.js.map → CollapsibleSection-al5mqR4O.js.map} +1 -1
  61. package/dashboard/dist/assets/{ConfirmDeleteModal-CpJNP-8w.js → ConfirmDeleteModal-BrlVktv2.js} +2 -2
  62. package/dashboard/dist/assets/{ConfirmDeleteModal-CpJNP-8w.js.map → ConfirmDeleteModal-BrlVktv2.js.map} +1 -1
  63. package/dashboard/dist/assets/{ConnectedAppsPage-DXIp2Dpl.js → ConnectedAppsPage-CLAsJ2yQ.js} +2 -2
  64. package/dashboard/dist/assets/{ConnectedAppsPage-DXIp2Dpl.js.map → ConnectedAppsPage-CLAsJ2yQ.js.map} +1 -1
  65. package/dashboard/dist/assets/{CountdownTimer-CuPY7zkb.js → CountdownTimer-D2D68exl.js} +2 -2
  66. package/dashboard/dist/assets/{CountdownTimer-CuPY7zkb.js.map → CountdownTimer-D2D68exl.js.map} +1 -1
  67. package/dashboard/dist/assets/{CredentialsPage-CtrnkHcj.js → CredentialsPage-DWrZbEI0.js} +2 -2
  68. package/dashboard/dist/assets/{CredentialsPage-CtrnkHcj.js.map → CredentialsPage-DWrZbEI0.js.map} +1 -1
  69. package/dashboard/dist/assets/{CronLabel-DVjTw5Ri.js → CronLabel-DuXR8iWq.js} +2 -2
  70. package/dashboard/dist/assets/{CronLabel-DVjTw5Ri.js.map → CronLabel-DuXR8iWq.js.map} +1 -1
  71. package/dashboard/dist/assets/{ElapsedCell-gY_mGMTF.js → ElapsedCell-ronqG5-E.js} +2 -2
  72. package/dashboard/dist/assets/{ElapsedCell-gY_mGMTF.js.map → ElapsedCell-ronqG5-E.js.map} +1 -1
  73. package/dashboard/dist/assets/{EntityTimelinePanel-DJN_ZEQa.js → EntityTimelinePanel-CKsktd84.js} +2 -2
  74. package/dashboard/dist/assets/{EntityTimelinePanel-DJN_ZEQa.js.map → EntityTimelinePanel-CKsktd84.js.map} +1 -1
  75. package/dashboard/dist/assets/{EscalationListSchemaPage-A4KpTdJA.js → EscalationListSchemaPage-C954ngy3.js} +3 -3
  76. package/dashboard/dist/assets/{EscalationListSchemaPage-A4KpTdJA.js.map → EscalationListSchemaPage-C954ngy3.js.map} +1 -1
  77. package/dashboard/dist/assets/{EscalationSchemaPage-nfCn42hT.js → EscalationSchemaPage-Dij9K0ON.js} +2 -2
  78. package/dashboard/dist/assets/{EscalationSchemaPage-nfCn42hT.js.map → EscalationSchemaPage-Dij9K0ON.js.map} +1 -1
  79. package/dashboard/dist/assets/{EscalationTimeline-CLvSr1SD.js → EscalationTimeline-DT2Owdl0.js} +2 -2
  80. package/dashboard/dist/assets/{EscalationTimeline-CLvSr1SD.js.map → EscalationTimeline-DT2Owdl0.js.map} +1 -1
  81. package/dashboard/dist/assets/{EscalationTitleSelect-CT7mYHkb.js → EscalationTitleSelect-BdbfMA98.js} +2 -2
  82. package/dashboard/dist/assets/{EscalationTitleSelect-CT7mYHkb.js.map → EscalationTitleSelect-BdbfMA98.js.map} +1 -1
  83. package/dashboard/dist/assets/{EscalationsOverview-CKaGRh-E.js → EscalationsOverview-niahs84P.js} +2 -2
  84. package/dashboard/dist/assets/{EscalationsOverview-CKaGRh-E.js.map → EscalationsOverview-niahs84P.js.map} +1 -1
  85. package/dashboard/dist/assets/{EventTable-2ywJsOLy.js → EventTable-DuLMBrSx.js} +2 -2
  86. package/dashboard/dist/assets/{EventTable-2ywJsOLy.js.map → EventTable-DuLMBrSx.js.map} +1 -1
  87. package/dashboard/dist/assets/{FilterBar-Dy0b7wwf.js → FilterBar-jtY6KNpL.js} +2 -2
  88. package/dashboard/dist/assets/{FilterBar-Dy0b7wwf.js.map → FilterBar-jtY6KNpL.js.map} +1 -1
  89. package/dashboard/dist/assets/{GraphInvokePage-yOVpraAy.js → GraphInvokePage-DSRAI0Zt.js} +2 -2
  90. package/dashboard/dist/assets/{GraphInvokePage-yOVpraAy.js.map → GraphInvokePage-DSRAI0Zt.js.map} +1 -1
  91. package/dashboard/dist/assets/{HomePage-67xXjKjN.js → HomePage-BUlSnCg8.js} +2 -2
  92. package/dashboard/dist/assets/{HomePage-67xXjKjN.js.map → HomePage-BUlSnCg8.js.map} +1 -1
  93. package/dashboard/dist/assets/{LinePage-CMsYtukW.js → LinePage-BJKhVM9Y.js} +3 -3
  94. package/dashboard/dist/assets/{LinePage-CMsYtukW.js.map → LinePage-BJKhVM9Y.js.map} +1 -1
  95. package/dashboard/dist/assets/{LinesPage-pwL46mOS.js → LinesPage-CrpJua3_.js} +3 -3
  96. package/dashboard/dist/assets/{LinesPage-pwL46mOS.js.map → LinesPage-CrpJua3_.js.map} +1 -1
  97. package/dashboard/dist/assets/{ListToolbar-CJmvGy2B.js → ListToolbar-BN0UPt0L.js} +2 -2
  98. package/dashboard/dist/assets/{ListToolbar-CJmvGy2B.js.map → ListToolbar-BN0UPt0L.js.map} +1 -1
  99. package/dashboard/dist/assets/{McpOverview-DA9LLvNG.js → McpOverview-BgbJXYPh.js} +2 -2
  100. package/dashboard/dist/assets/{McpOverview-DA9LLvNG.js.map → McpOverview-BgbJXYPh.js.map} +1 -1
  101. package/dashboard/dist/assets/{McpQueryDetailPage-N7qLmfE8.js → McpQueryDetailPage-BNjm2nrc.js} +2 -2
  102. package/dashboard/dist/assets/{McpQueryDetailPage-N7qLmfE8.js.map → McpQueryDetailPage-BNjm2nrc.js.map} +1 -1
  103. package/dashboard/dist/assets/{McpQueryPage-CpsP3w7x.js → McpQueryPage-DplR8wP9.js} +2 -2
  104. package/dashboard/dist/assets/{McpQueryPage-CpsP3w7x.js.map → McpQueryPage-DplR8wP9.js.map} +1 -1
  105. package/dashboard/dist/assets/{McpRunDetailPage-qHRQ1pEY.js → McpRunDetailPage-BHVEcKV5.js} +2 -2
  106. package/dashboard/dist/assets/{McpRunDetailPage-qHRQ1pEY.js.map → McpRunDetailPage-BHVEcKV5.js.map} +1 -1
  107. package/dashboard/dist/assets/{McpRunsPage-BRDDYpTM.js → McpRunsPage-CtlLagcs.js} +2 -2
  108. package/dashboard/dist/assets/{McpRunsPage-BRDDYpTM.js.map → McpRunsPage-CtlLagcs.js.map} +1 -1
  109. package/dashboard/dist/assets/{OperationsPage-zUaab-CL.js → OperationsPage-DH67bcW9.js} +3 -3
  110. package/dashboard/dist/assets/{OperationsPage-zUaab-CL.js.map → OperationsPage-DH67bcW9.js.map} +1 -1
  111. package/dashboard/dist/assets/{OperatorDashboard-el5BquXN.js → OperatorDashboard-CMkgMewd.js} +2 -2
  112. package/dashboard/dist/assets/{OperatorDashboard-el5BquXN.js.map → OperatorDashboard-CMkgMewd.js.map} +1 -1
  113. package/dashboard/dist/assets/{PersonaDetailPage-B_tb8gfl.js → PersonaDetailPage-Cs1FFdNq.js} +2 -2
  114. package/dashboard/dist/assets/{PersonaDetailPage-B_tb8gfl.js.map → PersonaDetailPage-Cs1FFdNq.js.map} +1 -1
  115. package/dashboard/dist/assets/{PersonasPage-BPI7mqM8.js → PersonasPage-CHTRdneF.js} +2 -2
  116. package/dashboard/dist/assets/{PersonasPage-BPI7mqM8.js.map → PersonasPage-CHTRdneF.js.map} +1 -1
  117. package/dashboard/dist/assets/{PortalPage-e_rBb1do.js → PortalPage-ChB5pBTZ.js} +2 -2
  118. package/dashboard/dist/assets/{PortalPage-e_rBb1do.js.map → PortalPage-ChB5pBTZ.js.map} +1 -1
  119. package/dashboard/dist/assets/{ProcessDetailPage-D35RX1bB.js → ProcessDetailPage-CzyqSfal.js} +2 -2
  120. package/dashboard/dist/assets/{ProcessDetailPage-D35RX1bB.js.map → ProcessDetailPage-CzyqSfal.js.map} +1 -1
  121. package/dashboard/dist/assets/{ProcessesListPage-CT81miI5.js → ProcessesListPage-rOwNkaU9.js} +2 -2
  122. package/dashboard/dist/assets/{ProcessesListPage-CT81miI5.js.map → ProcessesListPage-rOwNkaU9.js.map} +1 -1
  123. package/dashboard/dist/assets/{ResolverForm-BxJkoKAO.js → ResolverForm-DibnlZ-A.js} +2 -2
  124. package/dashboard/dist/assets/{ResolverForm-BxJkoKAO.js.map → ResolverForm-DibnlZ-A.js.map} +1 -1
  125. package/dashboard/dist/assets/{RoleDetailPage-DtU7vsJm.js → RoleDetailPage-Bv9R7iQC.js} +3 -3
  126. package/dashboard/dist/assets/{RoleDetailPage-DtU7vsJm.js.map → RoleDetailPage-Bv9R7iQC.js.map} +1 -1
  127. package/dashboard/dist/assets/{RolesPage-BE7RWt9q.js → RolesPage-CUP7EH5U.js} +2 -2
  128. package/dashboard/dist/assets/{RolesPage-BE7RWt9q.js.map → RolesPage-CUP7EH5U.js.map} +1 -1
  129. package/dashboard/dist/assets/{RosterWidget-BJMx0a8Z.js → RosterWidget-DZtmQcjU.js} +2 -2
  130. package/dashboard/dist/assets/RosterWidget-DZtmQcjU.js.map +1 -0
  131. package/dashboard/dist/assets/{RunAsSelector-Co6s9bqA.js → RunAsSelector-B9-1vgZr.js} +2 -2
  132. package/dashboard/dist/assets/{RunAsSelector-Co6s9bqA.js.map → RunAsSelector-B9-1vgZr.js.map} +1 -1
  133. package/dashboard/dist/assets/{ScanCodesPage-C2TETaj5.js → ScanCodesPage-KN_e2rJl.js} +2 -2
  134. package/dashboard/dist/assets/{ScanCodesPage-C2TETaj5.js.map → ScanCodesPage-KN_e2rJl.js.map} +1 -1
  135. package/dashboard/dist/assets/{ScanSchemeDetailPage-C2UgU8l-.js → ScanSchemeDetailPage-CqItQ67Y.js} +4 -4
  136. package/dashboard/dist/assets/{ScanSchemeDetailPage-C2UgU8l-.js.map → ScanSchemeDetailPage-CqItQ67Y.js.map} +1 -1
  137. package/dashboard/dist/assets/ScanStationPage-B0qbUOwc.js +2 -0
  138. package/dashboard/dist/assets/ScanStationPage-B0qbUOwc.js.map +1 -0
  139. package/dashboard/dist/assets/{SchemeMatchFields-9H7SmbED.js → SchemeMatchFields-CL7TKnw3.js} +2 -2
  140. package/dashboard/dist/assets/{SchemeMatchFields-9H7SmbED.js.map → SchemeMatchFields-CL7TKnw3.js.map} +1 -1
  141. package/dashboard/dist/assets/{StickyPagination-miUdVAKw.js → StickyPagination-CUwxfBQH.js} +2 -2
  142. package/dashboard/dist/assets/{StickyPagination-miUdVAKw.js.map → StickyPagination-CUwxfBQH.js.map} +1 -1
  143. package/dashboard/dist/assets/{StreamMessageDetail-D5Rk7pn7.js → StreamMessageDetail-DOjcO7d2.js} +2 -2
  144. package/dashboard/dist/assets/{StreamMessageDetail-D5Rk7pn7.js.map → StreamMessageDetail-DOjcO7d2.js.map} +1 -1
  145. package/dashboard/dist/assets/{SwimlaneTimeline-B1QY1ZzH.js → SwimlaneTimeline-SPMpoLHP.js} +2 -2
  146. package/dashboard/dist/assets/{SwimlaneTimeline-B1QY1ZzH.js.map → SwimlaneTimeline-SPMpoLHP.js.map} +1 -1
  147. package/dashboard/dist/assets/{TaskDetailPage-DKUM37o8.js → TaskDetailPage-DvfzR2IQ.js} +2 -2
  148. package/dashboard/dist/assets/{TaskDetailPage-DKUM37o8.js.map → TaskDetailPage-DvfzR2IQ.js.map} +1 -1
  149. package/dashboard/dist/assets/{TasksListPage-CUulwvm-.js → TasksListPage-Jp6wmL7t.js} +2 -2
  150. package/dashboard/dist/assets/{TasksListPage-CUulwvm-.js.map → TasksListPage-Jp6wmL7t.js.map} +1 -1
  151. package/dashboard/dist/assets/{TimeAgo-CHTelacB.js → TimeAgo-BCQA0Gb_.js} +2 -2
  152. package/dashboard/dist/assets/{TimeAgo-CHTelacB.js.map → TimeAgo-BCQA0Gb_.js.map} +1 -1
  153. package/dashboard/dist/assets/{TimestampCell-NanLWLKo.js → TimestampCell-xhdMHDQt.js} +2 -2
  154. package/dashboard/dist/assets/{TimestampCell-NanLWLKo.js.map → TimestampCell-xhdMHDQt.js.map} +1 -1
  155. package/dashboard/dist/assets/{ToolTestPanel-CF1CHzgz.js → ToolTestPanel-D8M3ITrJ.js} +2 -2
  156. package/dashboard/dist/assets/{ToolTestPanel-CF1CHzgz.js.map → ToolTestPanel-D8M3ITrJ.js.map} +1 -1
  157. package/dashboard/dist/assets/{TopicDetailPage-CGO8XV_a.js → TopicDetailPage-DdBJQp31.js} +2 -2
  158. package/dashboard/dist/assets/{TopicDetailPage-CGO8XV_a.js.map → TopicDetailPage-DdBJQp31.js.map} +1 -1
  159. package/dashboard/dist/assets/{TopicsPage-Bt8gOKYr.js → TopicsPage-vpvsynD9.js} +2 -2
  160. package/dashboard/dist/assets/{TopicsPage-Bt8gOKYr.js.map → TopicsPage-vpvsynD9.js.map} +1 -1
  161. package/dashboard/dist/assets/{UserName-DKXnK7DD.js → UserName-BK6Lzsdw.js} +2 -2
  162. package/dashboard/dist/assets/{UserName-DKXnK7DD.js.map → UserName-BK6Lzsdw.js.map} +1 -1
  163. package/dashboard/dist/assets/{WorkflowExecutionPage-Crf7AIFc.js → WorkflowExecutionPage-DkM1TS4I.js} +2 -2
  164. package/dashboard/dist/assets/{WorkflowExecutionPage-Crf7AIFc.js.map → WorkflowExecutionPage-DkM1TS4I.js.map} +1 -1
  165. package/dashboard/dist/assets/{WorkflowsDashboard--isjt06C.js → WorkflowsDashboard-g_N4y3QS.js} +2 -2
  166. package/dashboard/dist/assets/{WorkflowsDashboard--isjt06C.js.map → WorkflowsDashboard-g_N4y3QS.js.map} +1 -1
  167. package/dashboard/dist/assets/{WorkflowsOverview-D7Oqf4-V.js → WorkflowsOverview-Drjo-Lu-.js} +2 -2
  168. package/dashboard/dist/assets/{WorkflowsOverview-D7Oqf4-V.js.map → WorkflowsOverview-Drjo-Lu-.js.map} +1 -1
  169. package/dashboard/dist/assets/{YamlWorkflowDetailPage-B0wxgrGP.js → YamlWorkflowDetailPage-CLltNHjZ.js} +2 -2
  170. package/dashboard/dist/assets/{YamlWorkflowDetailPage-B0wxgrGP.js.map → YamlWorkflowDetailPage-CLltNHjZ.js.map} +1 -1
  171. package/dashboard/dist/assets/{YamlWorkflowsPage-BVdLnm6K.js → YamlWorkflowsPage-CxQCB-Zi.js} +2 -2
  172. package/dashboard/dist/assets/{YamlWorkflowsPage-BVdLnm6K.js.map → YamlWorkflowsPage-CxQCB-Zi.js.map} +1 -1
  173. package/dashboard/dist/assets/{agents-CHjbjHXA.js → agents-Dk25jjhj.js} +2 -2
  174. package/dashboard/dist/assets/{agents-CHjbjHXA.js.map → agents-Dk25jjhj.js.map} +1 -1
  175. package/dashboard/dist/assets/{bots-WrUhEPWs.js → bots-bRkCqhlq.js} +2 -2
  176. package/dashboard/dist/assets/{bots-WrUhEPWs.js.map → bots-bRkCqhlq.js.map} +1 -1
  177. package/dashboard/dist/assets/{capabilities-CunMmkj8.js → capabilities-DARawLry.js} +2 -2
  178. package/dashboard/dist/assets/{capabilities-CunMmkj8.js.map → capabilities-DARawLry.js.map} +1 -1
  179. package/dashboard/dist/assets/{controlplane-D6IZIZoh.js → controlplane-DKccxxs6.js} +2 -2
  180. package/dashboard/dist/assets/{controlplane-D6IZIZoh.js.map → controlplane-DKccxxs6.js.map} +1 -1
  181. package/dashboard/dist/assets/{escalation-columns-Bvo6JI4Z.js → escalation-columns-BaYuzMYf.js} +2 -2
  182. package/dashboard/dist/assets/{escalation-columns-Bvo6JI4Z.js.map → escalation-columns-BaYuzMYf.js.map} +1 -1
  183. package/dashboard/dist/assets/{escalation-items-DFGRwo49.js → escalation-items-CwbNFnsH.js} +2 -2
  184. package/dashboard/dist/assets/{escalation-items-DFGRwo49.js.map → escalation-items-CwbNFnsH.js.map} +1 -1
  185. package/dashboard/dist/assets/{index-B8qrHwp9.js → index-BZgtzkkG.js} +2 -2
  186. package/dashboard/dist/assets/{index-B8qrHwp9.js.map → index-BZgtzkkG.js.map} +1 -1
  187. package/dashboard/dist/assets/{index-DRw0FXdX.js → index-Bx9HVzuT.js} +2 -2
  188. package/dashboard/dist/assets/{index-DRw0FXdX.js.map → index-Bx9HVzuT.js.map} +1 -1
  189. package/dashboard/dist/assets/{index-ygxyAKcc.js → index-CU2UW2y6.js} +14 -14
  190. package/dashboard/dist/assets/index-CU2UW2y6.js.map +1 -0
  191. package/dashboard/dist/assets/{index-OuKQ_0eB.js → index-Cf6qCgTf.js} +2 -2
  192. package/dashboard/dist/assets/{index-OuKQ_0eB.js.map → index-Cf6qCgTf.js.map} +1 -1
  193. package/dashboard/dist/assets/{index-DRK7M1_9.js → index-CtrSYqmL.js} +2 -2
  194. package/dashboard/dist/assets/{index-DRK7M1_9.js.map → index-CtrSYqmL.js.map} +1 -1
  195. package/dashboard/dist/assets/{index-Bo8QU31k.js → index-D1uliPqS.js} +2 -2
  196. package/dashboard/dist/assets/{index-Bo8QU31k.js.map → index-D1uliPqS.js.map} +1 -1
  197. package/dashboard/dist/assets/{index-B95LbYhW.js → index-DU-1gMks.js} +2 -2
  198. package/dashboard/dist/assets/{index-B95LbYhW.js.map → index-DU-1gMks.js.map} +1 -1
  199. package/dashboard/dist/assets/{index-CpCchhQv.js → index-DU2QCbgH.js} +2 -2
  200. package/dashboard/dist/assets/{index-CpCchhQv.js.map → index-DU2QCbgH.js.map} +1 -1
  201. package/dashboard/dist/assets/{index-BZFSXEkr.js → index-DgpL_Lgc.js} +2 -2
  202. package/dashboard/dist/assets/{index-BZFSXEkr.js.map → index-DgpL_Lgc.js.map} +1 -1
  203. package/dashboard/dist/assets/{index-boT612Jo.js → index-E_hJ7vtX.js} +2 -2
  204. package/dashboard/dist/assets/{index-boT612Jo.js.map → index-E_hJ7vtX.js.map} +1 -1
  205. package/dashboard/dist/assets/{index-DCJ483vt.js → index-dShcvdg3.js} +2 -2
  206. package/dashboard/dist/assets/{index-DCJ483vt.js.map → index-dShcvdg3.js.map} +1 -1
  207. package/dashboard/dist/assets/{index-C7EIu1mG.js → index-hKOlahpE.js} +2 -2
  208. package/dashboard/dist/assets/{index-C7EIu1mG.js.map → index-hKOlahpE.js.map} +1 -1
  209. package/dashboard/dist/assets/index-kzifJWbM.js +3 -0
  210. package/dashboard/dist/assets/index-kzifJWbM.js.map +1 -0
  211. package/dashboard/dist/assets/{knowledge-BubJBTwg.js → knowledge-DOe5ks-E.js} +2 -2
  212. package/dashboard/dist/assets/{knowledge-BubJBTwg.js.map → knowledge-DOe5ks-E.js.map} +1 -1
  213. package/dashboard/dist/assets/{machines-DSm5NFgs.js → machines-Zq_00v7k.js} +2 -2
  214. package/dashboard/dist/assets/{machines-DSm5NFgs.js.map → machines-Zq_00v7k.js.map} +1 -1
  215. package/dashboard/dist/assets/{mcp-D6MckqOV.js → mcp-BL8kD0oh.js} +2 -2
  216. package/dashboard/dist/assets/{mcp-D6MckqOV.js.map → mcp-BL8kD0oh.js.map} +1 -1
  217. package/dashboard/dist/assets/{mcp-query-VyCdOag6.js → mcp-query-BpokmJWi.js} +2 -2
  218. package/dashboard/dist/assets/{mcp-query-VyCdOag6.js.map → mcp-query-BpokmJWi.js.map} +1 -1
  219. package/dashboard/dist/assets/{personas-CyJc10xe.js → personas-BubCnQZ8.js} +2 -2
  220. package/dashboard/dist/assets/{personas-CyJc10xe.js.map → personas-BubCnQZ8.js.map} +1 -1
  221. package/dashboard/dist/assets/{pipelines-B2inDtx3.js → pipelines--DUoMx7K.js} +2 -2
  222. package/dashboard/dist/assets/{pipelines-B2inDtx3.js.map → pipelines--DUoMx7K.js.map} +1 -1
  223. package/dashboard/dist/assets/{tasks-DOP4d3M6.js → tasks-CJXN4OB4.js} +2 -2
  224. package/dashboard/dist/assets/{tasks-DOP4d3M6.js.map → tasks-CJXN4OB4.js.map} +1 -1
  225. package/dashboard/dist/assets/{topics-CNOjSWpX.js → topics-CAG08Ruo.js} +2 -2
  226. package/dashboard/dist/assets/{topics-CNOjSWpX.js.map → topics-CAG08Ruo.js.map} +1 -1
  227. package/dashboard/dist/assets/{useDebouncedValue-CgO0TGMd.js → useDebouncedValue-DQ2D8cm2.js} +2 -2
  228. package/dashboard/dist/assets/{useDebouncedValue-CgO0TGMd.js.map → useDebouncedValue-DQ2D8cm2.js.map} +1 -1
  229. package/dashboard/dist/assets/{useNamespace-BWHvUKtK.js → useNamespace-DjEVAlJQ.js} +2 -2
  230. package/dashboard/dist/assets/{useNamespace-BWHvUKtK.js.map → useNamespace-DjEVAlJQ.js.map} +1 -1
  231. package/dashboard/dist/assets/{useYamlActivityEvents-BZQ__ZGD.js → useYamlActivityEvents-etcpfIwo.js} +2 -2
  232. package/dashboard/dist/assets/{useYamlActivityEvents-BZQ__ZGD.js.map → useYamlActivityEvents-etcpfIwo.js.map} +1 -1
  233. package/dashboard/dist/assets/{validate-CAin6WM_.js → validate-YJK_6a7m.js} +2 -2
  234. package/dashboard/dist/assets/{validate-CAin6WM_.js.map → validate-YJK_6a7m.js.map} +1 -1
  235. package/dashboard/dist/assets/{yaml-workflows-Dyln3od-.js → yaml-workflows-D97Bz6li.js} +2 -2
  236. package/dashboard/dist/assets/{yaml-workflows-Dyln3od-.js.map → yaml-workflows-D97Bz6li.js.map} +1 -1
  237. package/dashboard/dist/index.html +1 -1
  238. package/docs/api/http/escalations.md +15 -0
  239. package/docs/dashboard.md +2 -2
  240. package/docs/hitl/x-lt-roster.md +2 -0
  241. package/docs/hitl/x-lt-scan.md +12 -0
  242. package/docs/scan-codes.md +81 -3
  243. package/package.json +1 -1
  244. package/dashboard/dist/assets/RosterWidget-BJMx0a8Z.js.map +0 -1
  245. package/dashboard/dist/assets/ScanStationPage-nWYz-OD3.js +0 -2
  246. package/dashboard/dist/assets/ScanStationPage-nWYz-OD3.js.map +0 -1
  247. package/dashboard/dist/assets/index-P-DlgAWj.js +0 -3
  248. package/dashboard/dist/assets/index-P-DlgAWj.js.map +0 -1
  249. package/dashboard/dist/assets/index-ygxyAKcc.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{u as M,c as O,j as e,a as i,b as ae}from"./vendor-query-DvWWuNIB.js";import{f as ne,b as le}from"./vendor-react-_9U4mKFr.js";import{m as N,e as ie}from"./index-ygxyAKcc.js";import{P as oe}from"./PageHeader-DiGWAQlR.js";import{F as ce,a as xe}from"./FilterBar-Dy0b7wwf.js";import{L as de}from"./ListToolbar-CJmvGy2B.js";import{b as ue}from"./api-path-u2Jf9QXS.js";import{E as pe}from"./EmptyState-DgC_6njU.js";import{D as me}from"./DropZone-DefYTYQy.js";import{p as he,e as X,ad as J,ae as fe,y as ge,bl as be,bR as je,bS as ye,bq as Ne,bT as ve,X as we,aV as ke,aC as Se,bJ as Ce,H as Fe,aY as G,bU as Te,d as Pe}from"./vendor-icons-en0_uSRD.js";import{T as Q}from"./TimeAgo-CHTelacB.js";function Ue(t,a=100,n){const s=new URLSearchParams;t&&s.set("prefix",t),s.set("pageSize",String(a)),n&&s.set("continuationToken",n);const o=s.toString();return M({queryKey:["fileBrowse",t,a,n],queryFn:()=>N(`/file-browser/browse?${o}`)})}function Ee(t){return M({queryKey:["fileMetadata",t],queryFn:()=>N(`/file-browser/metadata/${t}`),enabled:!!t})}function $e(){return O({mutationFn:t=>N("/file-browser/signed-url",{method:"POST",body:JSON.stringify(t)})})}function De(){return O({mutationFn:t=>N(`/file-browser/delete/${t}`,{method:"DELETE"})})}function Be(){return O({mutationFn:async({path:t,file:a})=>{const n=await a.arrayBuffer();return N(`/file-browser/upload?path=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:n})}})}function Le(t){return M({queryKey:["filePreviewUrl",t],queryFn:async()=>(await N("/file-browser/signed-url",{method:"POST",body:JSON.stringify({path:t,expiresIn:3600})})).url,enabled:!!t,staleTime:3e3*1e3})}function Re({prefix:t,onNavigate:a}){const n=t?t.replace(/\/+$/,"").split("/").filter(Boolean):[];return e.jsxs("nav",{className:"flex items-center gap-1 text-sm mb-6 min-h-[28px]",children:[e.jsxs("button",{onClick:()=>a(""),className:`flex items-center gap-1.5 px-1.5 py-0.5 rounded transition-colors ${n.length===0?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover"}`,children:[e.jsx(he,{className:"w-4 h-4 text-accent/75",strokeWidth:1.5}),e.jsx("span",{children:"Root"})]}),n.map((s,o)=>{const l=o===n.length-1,d=n.slice(0,o+1).join("/")+"/";return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"w-3.5 h-3.5 text-text-tertiary"}),e.jsx("button",{onClick:()=>a(d),className:`px-1.5 py-0.5 rounded transition-colors ${l?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover"}`,children:s})]},d)})]})}function _e(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function S(t){return t.split("/").pop()||t}function _({label:t,value:a,mono:n,children:s}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5",children:t}),e.jsx("dd",{className:`text-sm text-text-secondary ${n?"font-mono text-xs break-all":""}`,children:s||a})]})}function Me({url:t}){const[a,n]=i.useState(null),[s,o]=i.useState(!1);return a===null&&!s&&fetch(t).then(l=>{if(!l.ok)throw new Error;return l.text()}).then(l=>n(l.slice(0,1e5))).catch(()=>o(!0)),s?e.jsx("p",{className:"text-xs text-text-tertiary",children:"Could not load preview"}):a===null?e.jsx("div",{className:"animate-pulse h-32 bg-surface-sunken rounded"}):e.jsx("pre",{className:"font-mono text-xs text-text-secondary bg-surface-sunken rounded-md p-3 overflow-x-auto max-h-[400px] overflow-y-auto whitespace-pre-wrap break-words",children:a})}function Oe({metadata:t}){const[a,n]=i.useState(null);async function s(o,l){await navigator.clipboard.writeText(o),n(l),setTimeout(()=>n(null),2e3)}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5",children:"Path"}),e.jsxs("dd",{onClick:()=>s(t.path,"path"),className:"group flex items-center gap-1.5 text-xs font-mono text-text-secondary break-all cursor-pointer hover:text-text-primary transition-colors",title:"Click to copy",children:[e.jsx("span",{className:"flex-1",children:t.path}),a==="path"?e.jsx(J,{className:"w-3.5 h-3.5 text-status-success shrink-0"}):e.jsx(fe,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-100 text-text-tertiary shrink-0 transition-opacity"})]})]}),e.jsx(_,{label:"Type",value:t.content_type}),e.jsx(_,{label:"Size",value:_e(t.size)}),e.jsx(_,{label:"Modified",children:e.jsx(Q,{date:t.modified_at})})]})}async function Ie(t,a){const s=await(await fetch(t)).blob(),o=URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=a,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)}function qe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function ze(t){var n;const a=((n=t.split(".").pop())==null?void 0:n.toLowerCase())||"";return["png","jpg","jpeg","gif","svg","webp"].includes(a)?e.jsx(be,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["json"].includes(a)?e.jsx(je,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["csv","xlsx","xls"].includes(a)?e.jsx(ye,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["txt","md","html","xml","yaml","yml","css","js","ts"].includes(a)?e.jsx(Ne,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):e.jsx(ve,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5})}function We(t){var n;const a=((n=t.split(".").pop())==null?void 0:n.toLowerCase())||"";return["png","jpg","jpeg","gif","svg","webp"].includes(a)}function Ae(t){const a=t.replace(/\/+$/,"");return a.split("/").pop()||a}function Ke(t){return t.split("/").pop()||t}function He({directories:t,files:a,onNavigate:n,onSelect:s,selectedFile:o}){return e.jsxs("table",{className:"w-full mt-2",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-2xs uppercase tracking-wider text-text-tertiary",children:[e.jsx("th",{className:"pb-2 pl-2 font-medium",children:"Name"}),e.jsx("th",{className:"pb-2 font-medium w-24 text-right",children:"Size"}),e.jsx("th",{className:"pb-2 pr-2 font-medium w-40 text-right",children:"Modified"})]})}),e.jsxs("tbody",{children:[t.map(l=>e.jsxs("tr",{onClick:()=>n(l),className:"row-hover cursor-pointer group",children:[e.jsx("td",{className:"py-2 pl-2",children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[e.jsx(ge,{className:"w-4 h-4 text-accent/75 shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"text-sm text-text-primary group-hover:text-accent transition-colors",children:Ae(l)})]})}),e.jsx("td",{className:"py-2 text-right text-xs text-text-tertiary",children:"—"}),e.jsx("td",{className:"py-2 pr-2 text-right text-xs text-text-tertiary",children:"—"})]},l)),a.map(l=>e.jsxs("tr",{onClick:()=>s(l.path),className:`row-hover cursor-pointer group ${o===l.path?"bg-surface-hover":""}`,children:[e.jsx("td",{className:"py-2 pl-2",children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[ze(l.path),e.jsx("span",{className:"text-sm text-text-primary truncate",children:Ke(l.path)})]})}),e.jsx("td",{className:"py-2 text-right text-xs text-text-secondary tabular-nums",children:qe(l.size)}),e.jsx("td",{className:"py-2 pr-2 text-right text-xs text-text-secondary",children:e.jsx(Q,{date:l.modified_at})})]},l.path))]})]})}const Ge=[{label:"1 hour",value:3600},{label:"6 hours",value:21600},{label:"24 hours",value:86400},{label:"7 days",value:604800},{label:"30 days",value:2592e3}];function Xe({filePath:t,onClose:a,onDeleted:n}){var b,k;const{data:s,isLoading:o}=Ee(t),l=$e(),d=De(),[v,f]=i.useState(!1),[w,C]=i.useState(!1),[j,h]=i.useState(!1),{data:u}=Le(t),g=((b=s==null?void 0:s.content_type)==null?void 0:b.startsWith("image/"))||We(t),F=/\.(ts|tsx|js|jsx|json|md|yaml|yml|toml|xml|csv|sql|sh|py|rb|go|rs|java|c|cpp|h|css|scss|html|txt|log|env|ini|cfg|conf)$/i,p=((k=s==null?void 0:s.content_type)==null?void 0:k.startsWith("text/"))||(s==null?void 0:s.content_type)==="application/json"||(s==null?void 0:s.content_type)==="application/xml"||(s==null?void 0:s.content_type)==="application/octet-stream"&&F.test(t),E=(s==null?void 0:s.content_type)==="application/pdf";async function $(){try{const c=await l.mutateAsync({path:t,expiresIn:3600}),x=c.url.startsWith("http")?c.url:`${window.location.origin}${c.url}`;Ie(x,S(t))}catch{}}async function T(c){f(!1);try{const x=await l.mutateAsync({path:t,expiresIn:c}),y=x.url.startsWith("http")?x.url:`${window.location.origin}${x.url}`;await navigator.clipboard.writeText(y),C(!0),setTimeout(()=>C(!1),2e3)}catch{}}return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"w-[380px] shrink-0 border-l border-surface-border bg-surface overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 bg-surface z-10 px-5 pt-5 pb-3 border-b border-surface-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary truncate pr-2",title:S(t),children:S(t)}),e.jsx("button",{onClick:a,className:"text-text-tertiary hover:text-text-primary shrink-0",children:e.jsx(we,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsxs("button",{onClick:$,className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Download",children:[e.jsx(ke,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Download"})]}),e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Open in new tab",children:[e.jsx(Se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Open"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>f(c=>!c),className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Share with signed URL",children:[w?e.jsx(J,{className:"w-3.5 h-3.5 text-status-success"}):e.jsx(Ce,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Share"})]}),v&&e.jsx("div",{className:"absolute top-full left-0 mt-1 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100] min-w-[120px]",children:Ge.map(c=>e.jsx("button",{onClick:()=>T(c.value),className:"w-full text-left px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover hover:text-text-primary transition-colors",children:c.label},c.value))})]}),e.jsxs("button",{onClick:()=>h(!0),className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs text-status-error/70 hover:text-status-error",title:"Delete file",children:[e.jsx(Fe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Delete"})]})]}),j&&e.jsxs("div",{className:"mt-3 p-3 bg-status-error/5 border border-status-error/20 rounded-md",children:[e.jsxs("p",{className:"text-xs text-text-primary mb-2",children:["Permanently delete ",e.jsx("span",{className:"font-medium",children:S(t)}),"? This cannot be undone."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>h(!1),className:"btn-secondary text-xs",disabled:d.isPending,children:"Cancel"}),e.jsx("button",{onClick:async()=>{try{await d.mutateAsync(t),h(!1),n==null||n()}catch{}},className:"btn-primary text-xs !bg-status-error hover:!bg-status-error/90",disabled:d.isPending,children:d.isPending?"Deleting...":"Delete"})]}),d.isError&&e.jsx("p",{className:"text-xs text-status-error mt-2",children:d.error.message})]}),l.isError&&e.jsx("p",{className:"text-xs text-status-error mt-2",children:l.error.message})]}),e.jsx("div",{className:"p-5",children:o?e.jsxs("div",{className:"animate-pulse space-y-3",children:[e.jsx("div",{className:"h-48 bg-surface-sunken rounded"}),e.jsx("div",{className:"h-4 bg-surface-sunken rounded w-2/3"})]}):e.jsxs(e.Fragment,{children:[g&&u&&e.jsx("div",{className:"mb-5 rounded-md border border-surface-border bg-surface-sunken overflow-hidden",style:{maxHeight:"400px"},children:e.jsx("img",{src:u,alt:S(t),className:"w-full object-cover object-top",style:{maxHeight:"400px"}})}),p&&u&&e.jsx("div",{className:"mb-5",children:e.jsx(Me,{url:u})}),E&&u&&e.jsx("div",{className:"mb-5 p-4 bg-surface-sunken rounded-md text-center",children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:text-accent-hover text-sm font-medium",children:"Open PDF in new tab"})}),s&&e.jsx(Oe,{metadata:s})]})})]})})}const Je=[25,50,100,200];function it(){const[t,a]=ne(),n=t.get("prefix")||"",[s,o]=i.useState(""),[l,d]=i.useState(""),[v,f]=i.useState(null),[w,C]=i.useState(100),[j,h]=i.useState([]),[u,g]=i.useState();i.useEffect(()=>{const r=setTimeout(()=>{d(s),g(void 0),h([])},ie);return()=>clearTimeout(r)},[s]);const F=l?`${n}${l}`:n,{data:p,isLoading:E,isFetching:$,refetch:T}=Ue(F,w,u),b=Be(),k=ae(),c=i.useRef(null),[x,y]=i.useState(null),[P,I]=i.useState(""),q=i.useCallback(r=>{y(r),I(n)},[n]),[z,W]=i.useState(""),V=i.useCallback(()=>{if(!x)return;W("");let r=x.length;for(const m of x){const K=`${P}${m.name}`;b.mutate({path:K,file:m},{onSuccess:()=>{r--,k.invalidateQueries({queryKey:["fileBrowse"]}),r<=0&&y(null)},onError:H=>{r--,W(H.message),console.error("[Upload] failed:",K,H)}})}},[x,P,b,k]),D=(p==null?void 0:p.directories)??[],U=(p==null?void 0:p.files)??[],B=p==null?void 0:p.nextToken,A=i.useCallback(r=>{o(""),d(""),f(null),g(void 0),h([]),a(r?{prefix:r}:{})},[a]);function Y(){B&&(h(r=>[...r,u||""]),g(B))}function Z(){if(j.length===0)return;const r=[...j],m=r.pop();h(r),g(m||void 0)}function ee(r){C(r),g(void 0),h([])}const te=D.length===0&&U.length===0,se=j.length+1,L=!!B,R=j.length>0,re=ue("/file-browser/browse",{prefix:F,pageSize:w,continuationToken:u||void 0});return e.jsxs(me,{onDrop:q,label:"Drop files to upload",children:[e.jsxs("div",{className:"flex gap-0",children:[e.jsx("input",{ref:c,type:"file",multiple:!0,className:"hidden",onChange:r=>{const m=Array.from(r.target.files||[]);m.length&&q(m),r.target.value=""}}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden pr-6",children:[e.jsx(oe,{title:"Files",docsHash:"#docs:dashboard.md:files",actions:e.jsxs("button",{onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},disabled:b.isPending,className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[e.jsx(G,{className:"w-3.5 h-3.5"}),b.isPending?"Uploading...":"Upload"]})}),e.jsx(Re,{prefix:n,onNavigate:A}),e.jsx(ce,{actions:e.jsx(de,{onRefresh:()=>T(),isFetching:$,apiPath:re}),children:e.jsx(xe,{label:"Search",value:s,onChange:o,placeholder:"Filter by prefix..."})}),E?e.jsx("div",{className:"animate-pulse space-y-2 mt-4",children:Array.from({length:6}).map((r,m)=>e.jsx("div",{className:"h-10 bg-surface-sunken rounded"},m))}):te?e.jsx("div",{className:"cursor-pointer",onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},children:e.jsx(pe,{icon:Te,title:s?"No matching files":"No files yet",description:s?void 0:"Drop files here or click to upload"})}):e.jsx(He,{directories:D,files:U,onNavigate:A,onSelect:f,selectedFile:v}),(R||L||U.length>0)&&e.jsxs("div",{className:"flex items-center justify-between pt-4 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("p",{className:"text-xs text-text-tertiary",children:["Page ",se," · ",U.length+D.length," items"]}),e.jsx("select",{value:w,onChange:r=>ee(parseInt(r.target.value)),className:"select text-xs py-1",children:Je.map(r=>e.jsxs("option",{value:r,children:[r," / page"]},r))})]}),(R||L)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:Z,disabled:!R,className:"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1",children:[e.jsx(Pe,{className:"w-3.5 h-3.5"}),"Previous"]}),e.jsxs("button",{onClick:Y,disabled:!L,className:"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1",children:["Next",e.jsx(X,{className:"w-3.5 h-3.5"})]})]})]})]}),v&&e.jsx(Xe,{filePath:v,onClose:()=>f(null),onDeleted:()=>{f(null),T()}})]}),x&&le.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-black/30",onClick:()=>y(null)}),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-surface-raised border border-surface-border rounded-lg shadow-lg w-full max-w-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-surface-border",children:e.jsxs("h3",{className:"text-sm font-medium text-text-primary",children:["Upload ",x.length," file",x.length>1?"s":""]})}),e.jsxs("div",{className:"px-5 py-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Destination folder"}),e.jsx("input",{type:"text",value:P,onChange:r=>I(r.target.value),placeholder:"e.g., images/ or leave empty for root",className:"input text-xs w-full font-mono"})]}),e.jsx("div",{className:"text-2xs text-text-quaternary space-y-0.5",children:x.map((r,m)=>e.jsxs("p",{className:"truncate",children:[P,r.name," ",e.jsxs("span",{className:"text-text-tertiary",children:["(",(r.size/1024).toFixed(1)," KB)"]})]},m))}),z&&e.jsx("p",{className:"text-xs text-status-error",children:z})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-surface-border",children:[e.jsx("button",{onClick:()=>y(null),className:"btn-ghost text-xs",children:"Cancel"}),e.jsxs("button",{onClick:V,className:"btn-primary text-xs",children:[e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5 inline"}),"Upload"]})]})]})})]}),document.body)]})}export{it as FilesPage};
2
- //# sourceMappingURL=index-BZFSXEkr.js.map
1
+ import{u as M,c as O,j as e,a as i,b as ae}from"./vendor-query-DvWWuNIB.js";import{f as ne,b as le}from"./vendor-react-_9U4mKFr.js";import{m as N,e as ie}from"./index-CU2UW2y6.js";import{P as oe}from"./PageHeader-DiGWAQlR.js";import{F as ce,a as xe}from"./FilterBar-jtY6KNpL.js";import{L as de}from"./ListToolbar-BN0UPt0L.js";import{b as ue}from"./api-path-u2Jf9QXS.js";import{E as pe}from"./EmptyState-DgC_6njU.js";import{D as me}from"./DropZone-DefYTYQy.js";import{p as he,e as X,ad as J,ae as fe,y as ge,bl as be,bR as je,bS as ye,bq as Ne,bT as ve,X as we,aV as ke,aC as Se,bJ as Ce,H as Fe,aY as G,bU as Te,d as Pe}from"./vendor-icons-en0_uSRD.js";import{T as Q}from"./TimeAgo-BCQA0Gb_.js";function Ue(t,a=100,n){const s=new URLSearchParams;t&&s.set("prefix",t),s.set("pageSize",String(a)),n&&s.set("continuationToken",n);const o=s.toString();return M({queryKey:["fileBrowse",t,a,n],queryFn:()=>N(`/file-browser/browse?${o}`)})}function Ee(t){return M({queryKey:["fileMetadata",t],queryFn:()=>N(`/file-browser/metadata/${t}`),enabled:!!t})}function $e(){return O({mutationFn:t=>N("/file-browser/signed-url",{method:"POST",body:JSON.stringify(t)})})}function De(){return O({mutationFn:t=>N(`/file-browser/delete/${t}`,{method:"DELETE"})})}function Be(){return O({mutationFn:async({path:t,file:a})=>{const n=await a.arrayBuffer();return N(`/file-browser/upload?path=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:n})}})}function Le(t){return M({queryKey:["filePreviewUrl",t],queryFn:async()=>(await N("/file-browser/signed-url",{method:"POST",body:JSON.stringify({path:t,expiresIn:3600})})).url,enabled:!!t,staleTime:3e3*1e3})}function Re({prefix:t,onNavigate:a}){const n=t?t.replace(/\/+$/,"").split("/").filter(Boolean):[];return e.jsxs("nav",{className:"flex items-center gap-1 text-sm mb-6 min-h-[28px]",children:[e.jsxs("button",{onClick:()=>a(""),className:`flex items-center gap-1.5 px-1.5 py-0.5 rounded transition-colors ${n.length===0?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover"}`,children:[e.jsx(he,{className:"w-4 h-4 text-accent/75",strokeWidth:1.5}),e.jsx("span",{children:"Root"})]}),n.map((s,o)=>{const l=o===n.length-1,d=n.slice(0,o+1).join("/")+"/";return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"w-3.5 h-3.5 text-text-tertiary"}),e.jsx("button",{onClick:()=>a(d),className:`px-1.5 py-0.5 rounded transition-colors ${l?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover"}`,children:s})]},d)})]})}function _e(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function S(t){return t.split("/").pop()||t}function _({label:t,value:a,mono:n,children:s}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5",children:t}),e.jsx("dd",{className:`text-sm text-text-secondary ${n?"font-mono text-xs break-all":""}`,children:s||a})]})}function Me({url:t}){const[a,n]=i.useState(null),[s,o]=i.useState(!1);return a===null&&!s&&fetch(t).then(l=>{if(!l.ok)throw new Error;return l.text()}).then(l=>n(l.slice(0,1e5))).catch(()=>o(!0)),s?e.jsx("p",{className:"text-xs text-text-tertiary",children:"Could not load preview"}):a===null?e.jsx("div",{className:"animate-pulse h-32 bg-surface-sunken rounded"}):e.jsx("pre",{className:"font-mono text-xs text-text-secondary bg-surface-sunken rounded-md p-3 overflow-x-auto max-h-[400px] overflow-y-auto whitespace-pre-wrap break-words",children:a})}function Oe({metadata:t}){const[a,n]=i.useState(null);async function s(o,l){await navigator.clipboard.writeText(o),n(l),setTimeout(()=>n(null),2e3)}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5",children:"Path"}),e.jsxs("dd",{onClick:()=>s(t.path,"path"),className:"group flex items-center gap-1.5 text-xs font-mono text-text-secondary break-all cursor-pointer hover:text-text-primary transition-colors",title:"Click to copy",children:[e.jsx("span",{className:"flex-1",children:t.path}),a==="path"?e.jsx(J,{className:"w-3.5 h-3.5 text-status-success shrink-0"}):e.jsx(fe,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-100 text-text-tertiary shrink-0 transition-opacity"})]})]}),e.jsx(_,{label:"Type",value:t.content_type}),e.jsx(_,{label:"Size",value:_e(t.size)}),e.jsx(_,{label:"Modified",children:e.jsx(Q,{date:t.modified_at})})]})}async function Ie(t,a){const s=await(await fetch(t)).blob(),o=URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=a,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)}function qe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function ze(t){var n;const a=((n=t.split(".").pop())==null?void 0:n.toLowerCase())||"";return["png","jpg","jpeg","gif","svg","webp"].includes(a)?e.jsx(be,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["json"].includes(a)?e.jsx(je,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["csv","xlsx","xls"].includes(a)?e.jsx(ye,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["txt","md","html","xml","yaml","yml","css","js","ts"].includes(a)?e.jsx(Ne,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):e.jsx(ve,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5})}function We(t){var n;const a=((n=t.split(".").pop())==null?void 0:n.toLowerCase())||"";return["png","jpg","jpeg","gif","svg","webp"].includes(a)}function Ae(t){const a=t.replace(/\/+$/,"");return a.split("/").pop()||a}function Ke(t){return t.split("/").pop()||t}function He({directories:t,files:a,onNavigate:n,onSelect:s,selectedFile:o}){return e.jsxs("table",{className:"w-full mt-2",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-2xs uppercase tracking-wider text-text-tertiary",children:[e.jsx("th",{className:"pb-2 pl-2 font-medium",children:"Name"}),e.jsx("th",{className:"pb-2 font-medium w-24 text-right",children:"Size"}),e.jsx("th",{className:"pb-2 pr-2 font-medium w-40 text-right",children:"Modified"})]})}),e.jsxs("tbody",{children:[t.map(l=>e.jsxs("tr",{onClick:()=>n(l),className:"row-hover cursor-pointer group",children:[e.jsx("td",{className:"py-2 pl-2",children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[e.jsx(ge,{className:"w-4 h-4 text-accent/75 shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"text-sm text-text-primary group-hover:text-accent transition-colors",children:Ae(l)})]})}),e.jsx("td",{className:"py-2 text-right text-xs text-text-tertiary",children:"—"}),e.jsx("td",{className:"py-2 pr-2 text-right text-xs text-text-tertiary",children:"—"})]},l)),a.map(l=>e.jsxs("tr",{onClick:()=>s(l.path),className:`row-hover cursor-pointer group ${o===l.path?"bg-surface-hover":""}`,children:[e.jsx("td",{className:"py-2 pl-2",children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[ze(l.path),e.jsx("span",{className:"text-sm text-text-primary truncate",children:Ke(l.path)})]})}),e.jsx("td",{className:"py-2 text-right text-xs text-text-secondary tabular-nums",children:qe(l.size)}),e.jsx("td",{className:"py-2 pr-2 text-right text-xs text-text-secondary",children:e.jsx(Q,{date:l.modified_at})})]},l.path))]})]})}const Ge=[{label:"1 hour",value:3600},{label:"6 hours",value:21600},{label:"24 hours",value:86400},{label:"7 days",value:604800},{label:"30 days",value:2592e3}];function Xe({filePath:t,onClose:a,onDeleted:n}){var b,k;const{data:s,isLoading:o}=Ee(t),l=$e(),d=De(),[v,f]=i.useState(!1),[w,C]=i.useState(!1),[j,h]=i.useState(!1),{data:u}=Le(t),g=((b=s==null?void 0:s.content_type)==null?void 0:b.startsWith("image/"))||We(t),F=/\.(ts|tsx|js|jsx|json|md|yaml|yml|toml|xml|csv|sql|sh|py|rb|go|rs|java|c|cpp|h|css|scss|html|txt|log|env|ini|cfg|conf)$/i,p=((k=s==null?void 0:s.content_type)==null?void 0:k.startsWith("text/"))||(s==null?void 0:s.content_type)==="application/json"||(s==null?void 0:s.content_type)==="application/xml"||(s==null?void 0:s.content_type)==="application/octet-stream"&&F.test(t),E=(s==null?void 0:s.content_type)==="application/pdf";async function $(){try{const c=await l.mutateAsync({path:t,expiresIn:3600}),x=c.url.startsWith("http")?c.url:`${window.location.origin}${c.url}`;Ie(x,S(t))}catch{}}async function T(c){f(!1);try{const x=await l.mutateAsync({path:t,expiresIn:c}),y=x.url.startsWith("http")?x.url:`${window.location.origin}${x.url}`;await navigator.clipboard.writeText(y),C(!0),setTimeout(()=>C(!1),2e3)}catch{}}return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"w-[380px] shrink-0 border-l border-surface-border bg-surface overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 bg-surface z-10 px-5 pt-5 pb-3 border-b border-surface-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary truncate pr-2",title:S(t),children:S(t)}),e.jsx("button",{onClick:a,className:"text-text-tertiary hover:text-text-primary shrink-0",children:e.jsx(we,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsxs("button",{onClick:$,className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Download",children:[e.jsx(ke,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Download"})]}),e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Open in new tab",children:[e.jsx(Se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Open"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>f(c=>!c),className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Share with signed URL",children:[w?e.jsx(J,{className:"w-3.5 h-3.5 text-status-success"}):e.jsx(Ce,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Share"})]}),v&&e.jsx("div",{className:"absolute top-full left-0 mt-1 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100] min-w-[120px]",children:Ge.map(c=>e.jsx("button",{onClick:()=>T(c.value),className:"w-full text-left px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover hover:text-text-primary transition-colors",children:c.label},c.value))})]}),e.jsxs("button",{onClick:()=>h(!0),className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs text-status-error/70 hover:text-status-error",title:"Delete file",children:[e.jsx(Fe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Delete"})]})]}),j&&e.jsxs("div",{className:"mt-3 p-3 bg-status-error/5 border border-status-error/20 rounded-md",children:[e.jsxs("p",{className:"text-xs text-text-primary mb-2",children:["Permanently delete ",e.jsx("span",{className:"font-medium",children:S(t)}),"? This cannot be undone."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>h(!1),className:"btn-secondary text-xs",disabled:d.isPending,children:"Cancel"}),e.jsx("button",{onClick:async()=>{try{await d.mutateAsync(t),h(!1),n==null||n()}catch{}},className:"btn-primary text-xs !bg-status-error hover:!bg-status-error/90",disabled:d.isPending,children:d.isPending?"Deleting...":"Delete"})]}),d.isError&&e.jsx("p",{className:"text-xs text-status-error mt-2",children:d.error.message})]}),l.isError&&e.jsx("p",{className:"text-xs text-status-error mt-2",children:l.error.message})]}),e.jsx("div",{className:"p-5",children:o?e.jsxs("div",{className:"animate-pulse space-y-3",children:[e.jsx("div",{className:"h-48 bg-surface-sunken rounded"}),e.jsx("div",{className:"h-4 bg-surface-sunken rounded w-2/3"})]}):e.jsxs(e.Fragment,{children:[g&&u&&e.jsx("div",{className:"mb-5 rounded-md border border-surface-border bg-surface-sunken overflow-hidden",style:{maxHeight:"400px"},children:e.jsx("img",{src:u,alt:S(t),className:"w-full object-cover object-top",style:{maxHeight:"400px"}})}),p&&u&&e.jsx("div",{className:"mb-5",children:e.jsx(Me,{url:u})}),E&&u&&e.jsx("div",{className:"mb-5 p-4 bg-surface-sunken rounded-md text-center",children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:text-accent-hover text-sm font-medium",children:"Open PDF in new tab"})}),s&&e.jsx(Oe,{metadata:s})]})})]})})}const Je=[25,50,100,200];function it(){const[t,a]=ne(),n=t.get("prefix")||"",[s,o]=i.useState(""),[l,d]=i.useState(""),[v,f]=i.useState(null),[w,C]=i.useState(100),[j,h]=i.useState([]),[u,g]=i.useState();i.useEffect(()=>{const r=setTimeout(()=>{d(s),g(void 0),h([])},ie);return()=>clearTimeout(r)},[s]);const F=l?`${n}${l}`:n,{data:p,isLoading:E,isFetching:$,refetch:T}=Ue(F,w,u),b=Be(),k=ae(),c=i.useRef(null),[x,y]=i.useState(null),[P,I]=i.useState(""),q=i.useCallback(r=>{y(r),I(n)},[n]),[z,W]=i.useState(""),V=i.useCallback(()=>{if(!x)return;W("");let r=x.length;for(const m of x){const K=`${P}${m.name}`;b.mutate({path:K,file:m},{onSuccess:()=>{r--,k.invalidateQueries({queryKey:["fileBrowse"]}),r<=0&&y(null)},onError:H=>{r--,W(H.message),console.error("[Upload] failed:",K,H)}})}},[x,P,b,k]),D=(p==null?void 0:p.directories)??[],U=(p==null?void 0:p.files)??[],B=p==null?void 0:p.nextToken,A=i.useCallback(r=>{o(""),d(""),f(null),g(void 0),h([]),a(r?{prefix:r}:{})},[a]);function Y(){B&&(h(r=>[...r,u||""]),g(B))}function Z(){if(j.length===0)return;const r=[...j],m=r.pop();h(r),g(m||void 0)}function ee(r){C(r),g(void 0),h([])}const te=D.length===0&&U.length===0,se=j.length+1,L=!!B,R=j.length>0,re=ue("/file-browser/browse",{prefix:F,pageSize:w,continuationToken:u||void 0});return e.jsxs(me,{onDrop:q,label:"Drop files to upload",children:[e.jsxs("div",{className:"flex gap-0",children:[e.jsx("input",{ref:c,type:"file",multiple:!0,className:"hidden",onChange:r=>{const m=Array.from(r.target.files||[]);m.length&&q(m),r.target.value=""}}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden pr-6",children:[e.jsx(oe,{title:"Files",docsHash:"#docs:dashboard.md:files",actions:e.jsxs("button",{onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},disabled:b.isPending,className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[e.jsx(G,{className:"w-3.5 h-3.5"}),b.isPending?"Uploading...":"Upload"]})}),e.jsx(Re,{prefix:n,onNavigate:A}),e.jsx(ce,{actions:e.jsx(de,{onRefresh:()=>T(),isFetching:$,apiPath:re}),children:e.jsx(xe,{label:"Search",value:s,onChange:o,placeholder:"Filter by prefix..."})}),E?e.jsx("div",{className:"animate-pulse space-y-2 mt-4",children:Array.from({length:6}).map((r,m)=>e.jsx("div",{className:"h-10 bg-surface-sunken rounded"},m))}):te?e.jsx("div",{className:"cursor-pointer",onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},children:e.jsx(pe,{icon:Te,title:s?"No matching files":"No files yet",description:s?void 0:"Drop files here or click to upload"})}):e.jsx(He,{directories:D,files:U,onNavigate:A,onSelect:f,selectedFile:v}),(R||L||U.length>0)&&e.jsxs("div",{className:"flex items-center justify-between pt-4 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("p",{className:"text-xs text-text-tertiary",children:["Page ",se," · ",U.length+D.length," items"]}),e.jsx("select",{value:w,onChange:r=>ee(parseInt(r.target.value)),className:"select text-xs py-1",children:Je.map(r=>e.jsxs("option",{value:r,children:[r," / page"]},r))})]}),(R||L)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:Z,disabled:!R,className:"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1",children:[e.jsx(Pe,{className:"w-3.5 h-3.5"}),"Previous"]}),e.jsxs("button",{onClick:Y,disabled:!L,className:"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1",children:["Next",e.jsx(X,{className:"w-3.5 h-3.5"})]})]})]})]}),v&&e.jsx(Xe,{filePath:v,onClose:()=>f(null),onDeleted:()=>{f(null),T()}})]}),x&&le.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-black/30",onClick:()=>y(null)}),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-surface-raised border border-surface-border rounded-lg shadow-lg w-full max-w-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-surface-border",children:e.jsxs("h3",{className:"text-sm font-medium text-text-primary",children:["Upload ",x.length," file",x.length>1?"s":""]})}),e.jsxs("div",{className:"px-5 py-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Destination folder"}),e.jsx("input",{type:"text",value:P,onChange:r=>I(r.target.value),placeholder:"e.g., images/ or leave empty for root",className:"input text-xs w-full font-mono"})]}),e.jsx("div",{className:"text-2xs text-text-quaternary space-y-0.5",children:x.map((r,m)=>e.jsxs("p",{className:"truncate",children:[P,r.name," ",e.jsxs("span",{className:"text-text-tertiary",children:["(",(r.size/1024).toFixed(1)," KB)"]})]},m))}),z&&e.jsx("p",{className:"text-xs text-status-error",children:z})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-surface-border",children:[e.jsx("button",{onClick:()=>y(null),className:"btn-ghost text-xs",children:"Cancel"}),e.jsxs("button",{onClick:V,className:"btn-primary text-xs",children:[e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5 inline"}),"Upload"]})]})]})})]}),document.body)]})}export{it as FilesPage};
2
+ //# sourceMappingURL=index-DgpL_Lgc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-BZFSXEkr.js","sources":["../../src/api/files.ts","../../src/pages/files/FileBreadcrumbs.tsx","../../src/pages/files/FilePreviewContent.tsx","../../src/pages/files/FileListViews.tsx","../../src/pages/files/FilePreviewPanel.tsx","../../src/pages/files/FilesPage.tsx"],"sourcesContent":["import { useQuery, useMutation } from '@tanstack/react-query';\nimport { apiFetch } from './client';\nimport { LT_BASE } from '../lib/base-path';\n\nexport interface FileEntry {\n path: string;\n size: number;\n modified_at: string;\n}\n\nexport interface BrowseResponse {\n files: FileEntry[];\n directories: string[];\n nextToken?: string;\n}\n\nexport interface FileMetadata {\n path: string;\n size: number;\n modified_at: string;\n content_type: string;\n}\n\nexport interface SignedUrlResponse {\n url: string;\n expiresAt: string;\n}\n\nexport function useFileBrowse(prefix: string, pageSize = 100, continuationToken?: string) {\n const params = new URLSearchParams();\n if (prefix) params.set('prefix', prefix);\n params.set('pageSize', String(pageSize));\n if (continuationToken) params.set('continuationToken', continuationToken);\n const qs = params.toString();\n\n return useQuery<BrowseResponse>({\n queryKey: ['fileBrowse', prefix, pageSize, continuationToken],\n queryFn: () => apiFetch(`/file-browser/browse?${qs}`),\n });\n}\n\nexport function useFileMetadata(filePath: string | null) {\n return useQuery<FileMetadata>({\n queryKey: ['fileMetadata', filePath],\n queryFn: () => apiFetch(`/file-browser/metadata/${filePath}`),\n enabled: !!filePath,\n });\n}\n\nexport function useGenerateSignedUrl() {\n return useMutation<SignedUrlResponse, Error, { path: string; expiresIn: number }>({\n mutationFn: (data) =>\n apiFetch('/file-browser/signed-url', {\n method: 'POST',\n body: JSON.stringify(data),\n }),\n });\n}\n\nexport function useDeleteFile() {\n return useMutation<{ deleted: boolean; path: string }, Error, string>({\n mutationFn: (filePath) =>\n apiFetch(`/file-browser/delete/${filePath}`, { method: 'DELETE' }),\n });\n}\n\nexport function useUploadFile() {\n return useMutation<{ path: string; size: number; content_type: string }, Error, { path: string; file: File }>({\n mutationFn: async ({ path, file }) => {\n const buffer = await file.arrayBuffer();\n // Always send as octet-stream to bypass Express JSON body parser\n return apiFetch(`/file-browser/upload?path=${encodeURIComponent(path)}`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/octet-stream' },\n body: buffer,\n });\n },\n });\n}\n\nexport function useFilePreviewUrl(filePath: string | null) {\n return useQuery<string>({\n queryKey: ['filePreviewUrl', filePath],\n queryFn: async () => {\n const result = await apiFetch<SignedUrlResponse>('/file-browser/signed-url', {\n method: 'POST',\n body: JSON.stringify({ path: filePath, expiresIn: 3600 }),\n });\n return result.url;\n },\n enabled: !!filePath,\n staleTime: 50 * 60 * 1000, // cache for 50 min (token valid for 60)\n });\n}\n\n/** @deprecated Use useFilePreviewUrl() for signed access */\nexport function getFilePreviewUrl(filePath: string): string {\n return `${LT_BASE}/api/files/${filePath.replace(/^\\/+/, '')}`;\n}\n\nexport function getFileDownloadUrl(filePath: string): string {\n return `${LT_BASE}/api/file-browser/download/${filePath.replace(/^\\/+/, '')}`;\n}\n","import { ChevronRight, FolderOpen } from 'lucide-react';\n\ninterface FileBreadcrumbsProps {\n prefix: string;\n onNavigate: (prefix: string) => void;\n}\n\nexport function FileBreadcrumbs({ prefix, onNavigate }: FileBreadcrumbsProps) {\n const segments = prefix ? prefix.replace(/\\/+$/, '').split('/').filter(Boolean) : [];\n\n return (\n <nav className=\"flex items-center gap-1 text-sm mb-6 min-h-[28px]\">\n <button\n onClick={() => onNavigate('')}\n className={`flex items-center gap-1.5 px-1.5 py-0.5 rounded transition-colors ${\n segments.length === 0\n ? 'text-text-primary font-medium'\n : 'text-text-secondary hover:text-text-primary hover:bg-surface-hover'\n }`}\n >\n <FolderOpen className=\"w-4 h-4 text-accent/75\" strokeWidth={1.5} />\n <span>Root</span>\n </button>\n\n {segments.map((segment, i) => {\n const isLast = i === segments.length - 1;\n const targetPrefix = segments.slice(0, i + 1).join('/') + '/';\n return (\n <span key={targetPrefix} className=\"flex items-center gap-1\">\n <ChevronRight className=\"w-3.5 h-3.5 text-text-tertiary\" />\n <button\n onClick={() => onNavigate(targetPrefix)}\n className={`px-1.5 py-0.5 rounded transition-colors ${\n isLast\n ? 'text-text-primary font-medium'\n : 'text-text-secondary hover:text-text-primary hover:bg-surface-hover'\n }`}\n >\n {segment}\n </button>\n </span>\n );\n })}\n </nav>\n );\n}\n","import { useState } from 'react';\nimport { Copy, Check } from 'lucide-react';\nimport { TimeAgo } from '../../components/common/display/TimeAgo';\n\ninterface FileMetadata {\n path: string;\n content_type: string;\n size: number;\n modified_at: string;\n}\n\nfunction formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;\n}\n\nexport function fileName(filePath: string): string {\n return filePath.split('/').pop() || filePath;\n}\n\nexport function MetaRow({ label, value, mono, children }: {\n label: string;\n value?: string;\n mono?: boolean;\n children?: React.ReactNode;\n}) {\n return (\n <div>\n <dt className=\"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5\">{label}</dt>\n <dd className={`text-sm text-text-secondary ${mono ? 'font-mono text-xs break-all' : ''}`}>\n {children || value}\n </dd>\n </div>\n );\n}\n\nexport function TextPreview({ url }: { url: string }) {\n const [content, setContent] = useState<string | null>(null);\n const [error, setError] = useState(false);\n\n if (content === null && !error) {\n fetch(url)\n .then((res) => {\n if (!res.ok) throw new Error();\n return res.text();\n })\n .then((text) => setContent(text.slice(0, 100_000)))\n .catch(() => setError(true));\n }\n\n if (error) return <p className=\"text-xs text-text-tertiary\">Could not load preview</p>;\n if (content === null) {\n return <div className=\"animate-pulse h-32 bg-surface-sunken rounded\" />;\n }\n\n return (\n <pre className=\"font-mono text-xs text-text-secondary bg-surface-sunken rounded-md p-3 overflow-x-auto max-h-[400px] overflow-y-auto whitespace-pre-wrap break-words\">\n {content}\n </pre>\n );\n}\n\nexport function FileMetadataDisplay({ metadata }: {\n metadata: FileMetadata;\n}) {\n const [copied, setCopied] = useState<string | null>(null);\n\n async function copyToClipboard(text: string, label: string) {\n await navigator.clipboard.writeText(text);\n setCopied(label);\n setTimeout(() => setCopied(null), 2000);\n }\n\n return (\n <div className=\"space-y-3\">\n <div>\n <dt className=\"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5\">Path</dt>\n <dd\n onClick={() => copyToClipboard(metadata.path, 'path')}\n className=\"group flex items-center gap-1.5 text-xs font-mono text-text-secondary break-all cursor-pointer hover:text-text-primary transition-colors\"\n title=\"Click to copy\"\n >\n <span className=\"flex-1\">{metadata.path}</span>\n {copied === 'path'\n ? <Check className=\"w-3.5 h-3.5 text-status-success shrink-0\" />\n : <Copy className=\"w-3.5 h-3.5 opacity-0 group-hover:opacity-100 text-text-tertiary shrink-0 transition-opacity\" />}\n </dd>\n </div>\n <MetaRow label=\"Type\" value={metadata.content_type} />\n <MetaRow label=\"Size\" value={formatSize(metadata.size)} />\n <MetaRow label=\"Modified\">\n <TimeAgo date={metadata.modified_at} />\n </MetaRow>\n </div>\n );\n}\n\nexport async function triggerDownload(url: string, name: string) {\n const res = await fetch(url);\n const blob = await res.blob();\n const blobUrl = URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = blobUrl;\n a.download = name;\n a.style.display = 'none';\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n URL.revokeObjectURL(blobUrl);\n}\n","import {\n Folder,\n File,\n Image,\n FileText,\n FileJson2,\n FileSpreadsheet,\n} from 'lucide-react';\nimport { TimeAgo } from '../../components/common/display/TimeAgo';\nimport { getFilePreviewUrl } from '../../api/files';\n\nexport function formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;\n}\n\nexport function fileIcon(filePath: string) {\n const ext = filePath.split('.').pop()?.toLowerCase() || '';\n if (['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp'].includes(ext)) {\n return <Image className=\"w-4 h-4 text-accent/60\" strokeWidth={1.5} />;\n }\n if (['json'].includes(ext)) {\n return <FileJson2 className=\"w-4 h-4 text-accent/60\" strokeWidth={1.5} />;\n }\n if (['csv', 'xlsx', 'xls'].includes(ext)) {\n return <FileSpreadsheet className=\"w-4 h-4 text-accent/60\" strokeWidth={1.5} />;\n }\n if (['txt', 'md', 'html', 'xml', 'yaml', 'yml', 'css', 'js', 'ts'].includes(ext)) {\n return <FileText className=\"w-4 h-4 text-accent/60\" strokeWidth={1.5} />;\n }\n return <File className=\"w-4 h-4 text-accent/60\" strokeWidth={1.5} />;\n}\n\nexport function isImagePath(filePath: string): boolean {\n const ext = filePath.split('.').pop()?.toLowerCase() || '';\n return ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp'].includes(ext);\n}\n\nexport function dirName(dirPath: string): string {\n const stripped = dirPath.replace(/\\/+$/, '');\n return stripped.split('/').pop() || stripped;\n}\n\nexport function fileNameFromPath(filePath: string): string {\n return filePath.split('/').pop() || filePath;\n}\n\ninterface ViewProps {\n directories: string[];\n files: Array<{ path: string; size: number; modified_at: string }>;\n onNavigate: (prefix: string) => void;\n onSelect: (path: string) => void;\n selectedFile: string | null;\n}\n\nexport function ListView({ directories, files, onNavigate, onSelect, selectedFile }: ViewProps) {\n return (\n <table className=\"w-full mt-2\">\n <thead>\n <tr className=\"text-left text-2xs uppercase tracking-wider text-text-tertiary\">\n <th className=\"pb-2 pl-2 font-medium\">Name</th>\n <th className=\"pb-2 font-medium w-24 text-right\">Size</th>\n <th className=\"pb-2 pr-2 font-medium w-40 text-right\">Modified</th>\n </tr>\n </thead>\n <tbody>\n {directories.map((dir) => (\n <tr\n key={dir}\n onClick={() => onNavigate(dir)}\n className=\"row-hover cursor-pointer group\"\n >\n <td className=\"py-2 pl-2\">\n <span className=\"flex items-center gap-2.5\">\n <Folder className=\"w-4 h-4 text-accent/75 shrink-0\" strokeWidth={1.5} />\n <span className=\"text-sm text-text-primary group-hover:text-accent transition-colors\">\n {dirName(dir)}\n </span>\n </span>\n </td>\n <td className=\"py-2 text-right text-xs text-text-tertiary\">&mdash;</td>\n <td className=\"py-2 pr-2 text-right text-xs text-text-tertiary\">&mdash;</td>\n </tr>\n ))}\n {files.map((file) => (\n <tr\n key={file.path}\n onClick={() => onSelect(file.path)}\n className={`row-hover cursor-pointer group ${\n selectedFile === file.path ? 'bg-surface-hover' : ''\n }`}\n >\n <td className=\"py-2 pl-2\">\n <span className=\"flex items-center gap-2.5\">\n {fileIcon(file.path)}\n <span className=\"text-sm text-text-primary truncate\">\n {fileNameFromPath(file.path)}\n </span>\n </span>\n </td>\n <td className=\"py-2 text-right text-xs text-text-secondary tabular-nums\">\n {formatSize(file.size)}\n </td>\n <td className=\"py-2 pr-2 text-right text-xs text-text-secondary\">\n <TimeAgo date={file.modified_at} />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n\nexport function GridView({ directories, files, onNavigate, onSelect, selectedFile }: ViewProps) {\n return (\n <div className=\"mt-4\">\n {/* Directories as compact list */}\n {directories.length > 0 && (\n <div className=\"flex flex-wrap gap-2 mb-6\">\n {directories.map((dir) => (\n <button\n key={dir}\n onClick={() => onNavigate(dir)}\n className=\"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-text-secondary hover:text-text-primary hover:bg-surface-hover transition-colors\"\n >\n <Folder className=\"w-4 h-4 text-accent/75\" strokeWidth={1.5} />\n <span>{dirName(dir)}</span>\n </button>\n ))}\n </div>\n )}\n\n {/* Files as thumbnail grid */}\n <div className=\"grid grid-cols-2 @grp-cols:grid-cols-3 @split:grid-cols-4 @wall:grid-cols-5 gap-3\">\n {files.map((file) => {\n const isImg = isImagePath(file.path);\n return (\n <button\n key={file.path}\n onClick={() => onSelect(file.path)}\n className={`group text-left rounded-lg overflow-hidden transition-all ${\n selectedFile === file.path\n ? 'ring-2 ring-accent/40 bg-surface-hover'\n : 'hover:bg-surface-hover'\n }`}\n >\n <div className=\"aspect-square bg-surface-sunken flex items-center justify-center overflow-hidden\">\n {isImg ? (\n <img\n src={getFilePreviewUrl(file.path)}\n alt={fileNameFromPath(file.path)}\n loading=\"lazy\"\n className=\"w-full h-full object-cover\"\n />\n ) : (\n <div className=\"flex flex-col items-center gap-2 text-text-tertiary\">\n {fileIcon(file.path)}\n <span className=\"text-2xs uppercase tracking-wider\">\n {file.path.split('.').pop()?.toUpperCase()}\n </span>\n </div>\n )}\n </div>\n <div className=\"px-2 py-1.5\">\n <p className=\"text-xs text-text-primary truncate\" title={fileNameFromPath(file.path)}>\n {fileNameFromPath(file.path)}\n </p>\n <p className=\"text-2xs text-text-tertiary tabular-nums\">\n {formatSize(file.size)}\n </p>\n </div>\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n","import { useState } from 'react';\nimport {\n X,\n Download,\n ExternalLink,\n Link,\n Check,\n Trash2,\n} from 'lucide-react';\nimport { useFileMetadata, useFilePreviewUrl, useGenerateSignedUrl, useDeleteFile } from '../../api/files';\nimport { fileName, triggerDownload, TextPreview, FileMetadataDisplay } from './FilePreviewContent';\nimport { isImagePath } from './FileListViews';\n\ninterface FilePreviewPanelProps {\n filePath: string;\n onClose: () => void;\n onDeleted?: () => void;\n}\n\nconst EXPIRY_OPTIONS = [\n { label: '1 hour', value: 3600 },\n { label: '6 hours', value: 21600 },\n { label: '24 hours', value: 86400 },\n { label: '7 days', value: 604800 },\n { label: '30 days', value: 2592000 },\n];\n\nexport function FilePreviewPanel({ filePath, onClose, onDeleted }: FilePreviewPanelProps) {\n const { data: metadata, isLoading } = useFileMetadata(filePath);\n const signedUrlMutation = useGenerateSignedUrl();\n const deleteMutation = useDeleteFile();\n const [showShareMenu, setShowShareMenu] = useState(false);\n const [copied, setCopied] = useState(false);\n const [confirmDelete, setConfirmDelete] = useState(false);\n\n const { data: previewUrl } = useFilePreviewUrl(filePath);\n const isImage = metadata?.content_type?.startsWith('image/') || isImagePath(filePath);\n const TEXT_EXTENSIONS = /\\.(ts|tsx|js|jsx|json|md|yaml|yml|toml|xml|csv|sql|sh|py|rb|go|rs|java|c|cpp|h|css|scss|html|txt|log|env|ini|cfg|conf)$/i;\n const isText = metadata?.content_type?.startsWith('text/')\n || metadata?.content_type === 'application/json'\n || metadata?.content_type === 'application/xml'\n || (metadata?.content_type === 'application/octet-stream' && TEXT_EXTENSIONS.test(filePath));\n const isPdf = metadata?.content_type === 'application/pdf';\n\n async function handleDownload() {\n try {\n const result = await signedUrlMutation.mutateAsync({ path: filePath, expiresIn: 3600 });\n const fullUrl = result.url.startsWith('http')\n ? result.url\n : `${window.location.origin}${result.url}`;\n triggerDownload(fullUrl, fileName(filePath));\n } catch {\n // handled by mutation state\n }\n }\n\n async function handleShare(expiresIn: number) {\n setShowShareMenu(false);\n try {\n const result = await signedUrlMutation.mutateAsync({ path: filePath, expiresIn });\n const fullUrl = result.url.startsWith('http')\n ? result.url\n : `${window.location.origin}${result.url}`;\n await navigator.clipboard.writeText(fullUrl);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch {\n // handled by mutation state\n }\n }\n\n return (\n <>\n {/* Fullscreen — opens image in a new tab */}\n\n {/* Panel */}\n <div className=\"w-[380px] shrink-0 border-l border-surface-border bg-surface overflow-y-auto\">\n {/* Header */}\n <div className=\"sticky top-0 bg-surface z-10 px-5 pt-5 pb-3 border-b border-surface-border\">\n <div className=\"flex items-center justify-between mb-3\">\n <h3 className=\"text-sm font-medium text-text-primary truncate pr-2\" title={fileName(filePath)}>\n {fileName(filePath)}\n </h3>\n <button onClick={onClose} className=\"text-text-tertiary hover:text-text-primary shrink-0\">\n <X className=\"w-4 h-4\" />\n </button>\n </div>\n\n {/* Actions */}\n <div className=\"flex items-center gap-1 flex-wrap\">\n <button\n onClick={handleDownload}\n className=\"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs\"\n title=\"Download\"\n >\n <Download className=\"w-3.5 h-3.5\" />\n <span>Download</span>\n </button>\n\n <a\n href={previewUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs\"\n title=\"Open in new tab\"\n >\n <ExternalLink className=\"w-3.5 h-3.5\" />\n <span>Open</span>\n </a>\n\n <div className=\"relative\">\n <button\n onClick={() => setShowShareMenu((v) => !v)}\n className=\"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs\"\n title=\"Share with signed URL\"\n >\n {copied ? <Check className=\"w-3.5 h-3.5 text-status-success\" /> : <Link className=\"w-3.5 h-3.5\" />}\n <span>Share</span>\n </button>\n {showShareMenu && (\n <div className=\"absolute top-full left-0 mt-1 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100] min-w-[120px]\">\n {EXPIRY_OPTIONS.map((opt) => (\n <button\n key={opt.value}\n onClick={() => handleShare(opt.value)}\n className=\"w-full text-left px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover hover:text-text-primary transition-colors\"\n >\n {opt.label}\n </button>\n ))}\n </div>\n )}\n </div>\n\n <button\n onClick={() => setConfirmDelete(true)}\n className=\"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs text-status-error/70 hover:text-status-error\"\n title=\"Delete file\"\n >\n <Trash2 className=\"w-3.5 h-3.5\" />\n <span>Delete</span>\n </button>\n </div>\n\n {/* Delete confirmation */}\n {confirmDelete && (\n <div className=\"mt-3 p-3 bg-status-error/5 border border-status-error/20 rounded-md\">\n <p className=\"text-xs text-text-primary mb-2\">\n Permanently delete <span className=\"font-medium\">{fileName(filePath)}</span>? This cannot be undone.\n </p>\n <div className=\"flex gap-2\">\n <button\n onClick={() => setConfirmDelete(false)}\n className=\"btn-secondary text-xs\"\n disabled={deleteMutation.isPending}\n >\n Cancel\n </button>\n <button\n onClick={async () => {\n try {\n await deleteMutation.mutateAsync(filePath);\n setConfirmDelete(false);\n onDeleted?.();\n } catch {\n // error shown below\n }\n }}\n className=\"btn-primary text-xs !bg-status-error hover:!bg-status-error/90\"\n disabled={deleteMutation.isPending}\n >\n {deleteMutation.isPending ? 'Deleting...' : 'Delete'}\n </button>\n </div>\n {deleteMutation.isError && (\n <p className=\"text-xs text-status-error mt-2\">{deleteMutation.error.message}</p>\n )}\n </div>\n )}\n\n {signedUrlMutation.isError && (\n <p className=\"text-xs text-status-error mt-2\">{signedUrlMutation.error.message}</p>\n )}\n </div>\n\n {/* Preview area */}\n <div className=\"p-5\">\n {isLoading ? (\n <div className=\"animate-pulse space-y-3\">\n <div className=\"h-48 bg-surface-sunken rounded\" />\n <div className=\"h-4 bg-surface-sunken rounded w-2/3\" />\n </div>\n ) : (\n <>\n {isImage && previewUrl && (\n <div\n className=\"mb-5 rounded-md border border-surface-border bg-surface-sunken overflow-hidden\"\n style={{ maxHeight: '400px' }}\n >\n <img\n src={previewUrl}\n alt={fileName(filePath)}\n className=\"w-full object-cover object-top\"\n style={{ maxHeight: '400px' }}\n />\n </div>\n )}\n\n {isText && previewUrl && (\n <div className=\"mb-5\">\n <TextPreview url={previewUrl} />\n </div>\n )}\n\n {isPdf && previewUrl && (\n <div className=\"mb-5 p-4 bg-surface-sunken rounded-md text-center\">\n <a\n href={previewUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-accent hover:text-accent-hover text-sm font-medium\"\n >\n Open PDF in new tab\n </a>\n </div>\n )}\n\n {metadata && (\n <FileMetadataDisplay metadata={metadata} />\n )}\n </>\n )}\n </div>\n </div>\n </>\n );\n}\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useSearchParams } from 'react-router-dom';\nimport {\n ChevronLeft,\n ChevronRight,\n Upload,\n UploadCloud,\n} from 'lucide-react';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { SEARCH_DEBOUNCE_MS } from '../../lib/realtime-refresh';\nimport { PageHeader } from '../../components/common/layout/PageHeader';\nimport { FilterBar, FilterInput } from '../../components/common/data/FilterBar';\nimport { ListToolbar } from '../../components/common/data/ListToolbar';\nimport { buildApiPath } from '../../lib/api-path';\nimport { EmptyState } from '../../components/common/display/EmptyState';\nimport { DropZone } from '../../components/common/DropZone';\nimport { useFileBrowse, useUploadFile } from '../../api/files';\nimport { FileBreadcrumbs } from './FileBreadcrumbs';\nimport { FilePreviewPanel } from './FilePreviewPanel';\nimport { ListView } from './FileListViews';\n\nconst PAGE_SIZES = [25, 50, 100, 200];\n\nexport function FilesPage() {\n const [searchParams, setSearchParams] = useSearchParams();\n const prefix = searchParams.get('prefix') || '';\n const [search, setSearch] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n const [selectedFile, setSelectedFile] = useState<string | null>(null);\n const [pageSize, setPageSize] = useState(100);\n const [tokenStack, setTokenStack] = useState<string[]>([]);\n const [currentToken, setCurrentToken] = useState<string | undefined>();\n\n // Debounce search — refines the prefix sent to S3\n useEffect(() => {\n const t = setTimeout(() => {\n setDebouncedSearch(search);\n setCurrentToken(undefined);\n setTokenStack([]);\n }, SEARCH_DEBOUNCE_MS);\n return () => clearTimeout(t);\n }, [search]);\n\n const effectivePrefix = debouncedSearch\n ? `${prefix}${debouncedSearch}`\n : prefix;\n\n const { data, isLoading, isFetching, refetch } = useFileBrowse(effectivePrefix, pageSize, currentToken);\n const uploadMutation = useUploadFile();\n const queryClient = useQueryClient();\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n const [pendingFiles, setPendingFiles] = useState<File[] | null>(null);\n const [uploadPrefix, setUploadPrefix] = useState('');\n\n const handleUploadFiles = useCallback((files: File[]) => {\n setPendingFiles(files);\n setUploadPrefix(prefix);\n }, [prefix]);\n\n const [uploadError, setUploadError] = useState('');\n\n const confirmUpload = useCallback(() => {\n if (!pendingFiles) return;\n setUploadError('');\n let remaining = pendingFiles.length;\n for (const file of pendingFiles) {\n const targetPath = `${uploadPrefix}${file.name}`;\n uploadMutation.mutate({ path: targetPath, file }, {\n onSuccess: () => {\n remaining--;\n queryClient.invalidateQueries({ queryKey: ['fileBrowse'] });\n if (remaining <= 0) setPendingFiles(null);\n },\n onError: (err) => {\n remaining--;\n setUploadError(err.message);\n console.error('[Upload] failed:', targetPath, err);\n },\n });\n }\n }, [pendingFiles, uploadPrefix, uploadMutation, queryClient]);\n\n const directories = data?.directories ?? [];\n const files = data?.files ?? [];\n const nextToken = data?.nextToken;\n\n const navigateTo = useCallback((newPrefix: string) => {\n setSearch('');\n setDebouncedSearch('');\n setSelectedFile(null);\n setCurrentToken(undefined);\n setTokenStack([]);\n if (newPrefix) {\n setSearchParams({ prefix: newPrefix });\n } else {\n setSearchParams({});\n }\n }, [setSearchParams]);\n\n function goNextPage() {\n if (!nextToken) return;\n setTokenStack((prev) => [...prev, currentToken || '']);\n setCurrentToken(nextToken);\n }\n\n function goPrevPage() {\n if (tokenStack.length === 0) return;\n const prev = [...tokenStack];\n const token = prev.pop()!;\n setTokenStack(prev);\n setCurrentToken(token || undefined);\n }\n\n function changePageSize(size: number) {\n setPageSize(size);\n setCurrentToken(undefined);\n setTokenStack([]);\n }\n\n const isEmpty = directories.length === 0 && files.length === 0;\n const pageNum = tokenStack.length + 1;\n const hasNextPage = !!nextToken;\n const hasPrevPage = tokenStack.length > 0;\n\n const apiPath = buildApiPath('/file-browser/browse', {\n prefix: effectivePrefix,\n pageSize,\n continuationToken: currentToken || undefined,\n });\n\n return (\n <DropZone onDrop={handleUploadFiles} label=\"Drop files to upload\">\n <div className=\"flex gap-0\">\n {/* Hidden file input for button-triggered upload */}\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple\n className=\"hidden\"\n onChange={(e) => {\n const files = Array.from(e.target.files || []);\n if (files.length) handleUploadFiles(files);\n e.target.value = '';\n }}\n />\n\n {/* Main content */}\n <div className=\"flex-1 min-w-0 overflow-hidden pr-6\">\n <PageHeader\n title=\"Files\"\n docsHash=\"#docs:dashboard.md:files\"\n actions={\n <button\n onClick={() => fileInputRef.current?.click()}\n disabled={uploadMutation.isPending}\n className=\"btn-primary text-xs inline-flex items-center gap-1.5\"\n >\n <Upload className=\"w-3.5 h-3.5\" />\n {uploadMutation.isPending ? 'Uploading...' : 'Upload'}\n </button>\n }\n />\n\n <FileBreadcrumbs prefix={prefix} onNavigate={navigateTo} />\n\n <FilterBar actions={\n <ListToolbar\n onRefresh={() => refetch()}\n isFetching={isFetching}\n apiPath={apiPath}\n />\n }>\n <FilterInput\n label=\"Search\"\n value={search}\n onChange={setSearch}\n placeholder=\"Filter by prefix...\"\n />\n </FilterBar>\n\n {isLoading ? (\n <div className=\"animate-pulse space-y-2 mt-4\">\n {Array.from({ length: 6 }).map((_, i) => (\n <div key={i} className=\"h-10 bg-surface-sunken rounded\" />\n ))}\n </div>\n ) : isEmpty ? (\n <div className=\"cursor-pointer\" onClick={() => fileInputRef.current?.click()}>\n <EmptyState\n icon={UploadCloud}\n title={search ? 'No matching files' : 'No files yet'}\n description={search ? undefined : 'Drop files here or click to upload'}\n />\n </div>\n ) : (\n <ListView\n directories={directories}\n files={files}\n onNavigate={navigateTo}\n onSelect={setSelectedFile}\n selectedFile={selectedFile}\n />\n )}\n\n {/* Cursor-based pagination */}\n {(hasPrevPage || hasNextPage || files.length > 0) && (\n <div className=\"flex items-center justify-between pt-4 pb-2\">\n <div className=\"flex items-center gap-4\">\n <p className=\"text-xs text-text-tertiary\">\n Page {pageNum} &middot; {files.length + directories.length} items\n </p>\n <select\n value={pageSize}\n onChange={(e) => changePageSize(parseInt(e.target.value))}\n className=\"select text-xs py-1\"\n >\n {PAGE_SIZES.map((size) => (\n <option key={size} value={size}>{size} / page</option>\n ))}\n </select>\n </div>\n {(hasPrevPage || hasNextPage) && (\n <div className=\"flex items-center gap-1\">\n <button\n onClick={goPrevPage}\n disabled={!hasPrevPage}\n className=\"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1\"\n >\n <ChevronLeft className=\"w-3.5 h-3.5\" />\n Previous\n </button>\n <button\n onClick={goNextPage}\n disabled={!hasNextPage}\n className=\"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1\"\n >\n Next\n <ChevronRight className=\"w-3.5 h-3.5\" />\n </button>\n </div>\n )}\n </div>\n )}\n </div>\n\n {/* Preview panel */}\n {selectedFile && (\n <FilePreviewPanel\n filePath={selectedFile}\n onClose={() => setSelectedFile(null)}\n onDeleted={() => { setSelectedFile(null); refetch(); }}\n />\n )}\n </div>\n {/* Upload confirmation dialog */}\n {pendingFiles && createPortal(\n <>\n <div className=\"fixed inset-0 z-40 bg-black/30\" onClick={() => setPendingFiles(null)} />\n <div className=\"fixed inset-0 z-50 flex items-center justify-center p-4\">\n <div className=\"bg-surface-raised border border-surface-border rounded-lg shadow-lg w-full max-w-sm\">\n <div className=\"px-5 py-4 border-b border-surface-border\">\n <h3 className=\"text-sm font-medium text-text-primary\">Upload {pendingFiles.length} file{pendingFiles.length > 1 ? 's' : ''}</h3>\n </div>\n <div className=\"px-5 py-4 space-y-3\">\n <div>\n <label className=\"block text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1\">Destination folder</label>\n <input\n type=\"text\"\n value={uploadPrefix}\n onChange={(e) => setUploadPrefix(e.target.value)}\n placeholder=\"e.g., images/ or leave empty for root\"\n className=\"input text-xs w-full font-mono\"\n />\n </div>\n <div className=\"text-2xs text-text-quaternary space-y-0.5\">\n {pendingFiles.map((f, i) => (\n <p key={i} className=\"truncate\">{uploadPrefix}{f.name} <span className=\"text-text-tertiary\">({(f.size / 1024).toFixed(1)} KB)</span></p>\n ))}\n </div>\n {uploadError && <p className=\"text-xs text-status-error\">{uploadError}</p>}\n </div>\n <div className=\"flex justify-end gap-2 px-5 py-3 border-t border-surface-border\">\n <button onClick={() => setPendingFiles(null)} className=\"btn-ghost text-xs\">Cancel</button>\n <button onClick={confirmUpload} className=\"btn-primary text-xs\">\n <Upload className=\"w-3.5 h-3.5 mr-1.5 inline\" />\n Upload\n </button>\n </div>\n </div>\n </div>\n </>,\n document.body,\n )}\n </DropZone>\n );\n}\n"],"names":["useFileBrowse","prefix","pageSize","continuationToken","params","qs","useQuery","apiFetch","useFileMetadata","filePath","useGenerateSignedUrl","useMutation","data","useDeleteFile","useUploadFile","path","file","buffer","useFilePreviewUrl","FileBreadcrumbs","onNavigate","segments","jsxs","jsx","FolderOpen","segment","i","isLast","targetPrefix","ChevronRight","formatSize","bytes","fileName","MetaRow","label","value","mono","children","TextPreview","url","content","setContent","useState","error","setError","res","text","FileMetadataDisplay","metadata","copied","setCopied","copyToClipboard","Check","Copy","TimeAgo","triggerDownload","name","blob","blobUrl","a","fileIcon","ext","_a","Image","FileJson2","FileSpreadsheet","FileText","File","isImagePath","dirName","dirPath","stripped","fileNameFromPath","ListView","directories","files","onSelect","selectedFile","dir","Folder","EXPIRY_OPTIONS","FilePreviewPanel","onClose","onDeleted","isLoading","signedUrlMutation","deleteMutation","showShareMenu","setShowShareMenu","confirmDelete","setConfirmDelete","previewUrl","isImage","TEXT_EXTENSIONS","isText","_b","isPdf","handleDownload","result","fullUrl","handleShare","expiresIn","Fragment","X","Download","ExternalLink","v","Link","opt","Trash2","PAGE_SIZES","FilesPage","searchParams","setSearchParams","useSearchParams","search","setSearch","debouncedSearch","setDebouncedSearch","setSelectedFile","setPageSize","tokenStack","setTokenStack","currentToken","setCurrentToken","useEffect","t","SEARCH_DEBOUNCE_MS","effectivePrefix","isFetching","refetch","uploadMutation","queryClient","useQueryClient","fileInputRef","useRef","pendingFiles","setPendingFiles","uploadPrefix","setUploadPrefix","handleUploadFiles","useCallback","uploadError","setUploadError","confirmUpload","remaining","targetPath","err","nextToken","navigateTo","newPrefix","goNextPage","prev","goPrevPage","token","changePageSize","size","isEmpty","pageNum","hasNextPage","hasPrevPage","apiPath","buildApiPath","DropZone","e","PageHeader","Upload","FilterBar","ListToolbar","FilterInput","_","EmptyState","UploadClo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ages/files/FilePreviewContent.tsx","../../src/pages/files/FileListViews.tsx","../../src/pages/files/FilePreviewPanel.tsx","../../src/pages/files/FilesPage.tsx"],"sourcesContent":["import { useQuery, useMutation } from '@tanstack/react-query';\nimport { apiFetch } from './client';\nimport { LT_BASE } from '../lib/base-path';\n\nexport interface FileEntry {\n path: string;\n size: number;\n modified_at: string;\n}\n\nexport interface BrowseResponse {\n files: FileEntry[];\n directories: string[];\n nextToken?: string;\n}\n\nexport interface FileMetadata {\n path: string;\n size: number;\n modified_at: string;\n content_type: string;\n}\n\nexport interface SignedUrlResponse {\n url: string;\n expiresAt: string;\n}\n\nexport function useFileBrowse(prefix: string, pageSize = 100, continuationToken?: string) {\n const params = new URLSearchParams();\n if (prefix) params.set('prefix', prefix);\n params.set('pageSize', String(pageSize));\n if (continuationToken) params.set('continuationToken', continuationToken);\n const qs = params.toString();\n\n return useQuery<BrowseResponse>({\n queryKey: ['fileBrowse', prefix, pageSize, continuationToken],\n queryFn: () => apiFetch(`/file-browser/browse?${qs}`),\n });\n}\n\nexport function useFileMetadata(filePath: string | null) {\n return useQuery<FileMetadata>({\n queryKey: ['fileMetadata', filePath],\n queryFn: () => apiFetch(`/file-browser/metadata/${filePath}`),\n enabled: !!filePath,\n });\n}\n\nexport function useGenerateSignedUrl() {\n return useMutation<SignedUrlResponse, Error, { path: string; expiresIn: number }>({\n mutationFn: (data) =>\n apiFetch('/file-browser/signed-url', {\n method: 'POST',\n body: JSON.stringify(data),\n }),\n });\n}\n\nexport function useDeleteFile() {\n return useMutation<{ deleted: boolean; path: string }, Error, string>({\n mutationFn: (filePath) =>\n apiFetch(`/file-browser/delete/${filePath}`, { method: 'DELETE' }),\n });\n}\n\nexport function useUploadFile() {\n return useMutation<{ path: string; size: number; content_type: string }, Error, { path: string; file: File }>({\n mutationFn: async ({ path, file }) => {\n const buffer = await file.arrayBuffer();\n // Always send as octet-stream to bypass Express JSON body parser\n return apiFetch(`/file-browser/upload?path=${encodeURIComponent(path)}`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/octet-stream' },\n body: buffer,\n });\n },\n });\n}\n\nexport function useFilePreviewUrl(filePath: string | null) {\n return useQuery<string>({\n queryKey: ['filePreviewUrl', filePath],\n queryFn: async () => {\n const result = await apiFetch<SignedUrlResponse>('/file-browser/signed-url', {\n method: 'POST',\n body: JSON.stringify({ path: filePath, expiresIn: 3600 }),\n });\n return result.url;\n },\n enabled: !!filePath,\n staleTime: 50 * 60 * 1000, // cache for 50 min (token valid for 60)\n });\n}\n\n/** @deprecated Use useFilePreviewUrl() for signed access */\nexport function getFilePreviewUrl(filePath: string): string {\n return `${LT_BASE}/api/files/${filePath.replace(/^\\/+/, '')}`;\n}\n\nexport function getFileDownloadUrl(filePath: string): string {\n return `${LT_BASE}/api/file-browser/download/${filePath.replace(/^\\/+/, '')}`;\n}\n","import { ChevronRight, FolderOpen } from 'lucide-react';\n\ninterface FileBreadcrumbsProps {\n prefix: string;\n onNavigate: (prefix: string) => void;\n}\n\nexport function FileBreadcrumbs({ prefix, onNavigate }: FileBreadcrumbsProps) {\n const segments = prefix ? prefix.replace(/\\/+$/, '').split('/').filter(Boolean) : [];\n\n return (\n <nav className=\"flex items-center gap-1 text-sm mb-6 min-h-[28px]\">\n <button\n onClick={() => onNavigate('')}\n className={`flex items-center gap-1.5 px-1.5 py-0.5 rounded transition-colors ${\n segments.length === 0\n ? 'text-text-primary font-medium'\n : 'text-text-secondary hover:text-text-primary hover:bg-surface-hover'\n }`}\n >\n <FolderOpen className=\"w-4 h-4 text-accent/75\" strokeWidth={1.5} />\n <span>Root</span>\n </button>\n\n {segments.map((segment, i) => {\n const isLast = i === segments.length - 1;\n const targetPrefix = segments.slice(0, i + 1).join('/') + '/';\n return (\n <span key={targetPrefix} className=\"flex items-center gap-1\">\n <ChevronRight className=\"w-3.5 h-3.5 text-text-tertiary\" />\n <button\n onClick={() => onNavigate(targetPrefix)}\n className={`px-1.5 py-0.5 rounded transition-colors ${\n isLast\n ? 'text-text-primary font-medium'\n : 'text-text-secondary hover:text-text-primary hover:bg-surface-hover'\n }`}\n >\n {segment}\n </button>\n </span>\n );\n })}\n </nav>\n );\n}\n","import { useState } from 'react';\nimport { Copy, Check } from 'lucide-react';\nimport { TimeAgo } from '../../components/common/display/TimeAgo';\n\ninterface FileMetadata {\n path: string;\n content_type: string;\n size: number;\n modified_at: string;\n}\n\nfunction formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;\n}\n\nexport function fileName(filePath: string): string {\n return filePath.split('/').pop() || filePath;\n}\n\nexport function MetaRow({ label, value, mono, children }: {\n label: string;\n value?: string;\n mono?: boolean;\n children?: React.ReactNode;\n}) {\n return (\n <div>\n <dt className=\"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5\">{label}</dt>\n <dd className={`text-sm text-text-secondary ${mono ? 'font-mono text-xs break-all' : ''}`}>\n {children || value}\n </dd>\n </div>\n );\n}\n\nexport function TextPreview({ url }: { url: string }) {\n const [content, setContent] = useState<string | null>(null);\n const [error, setError] = useState(false);\n\n if (content === null && !error) {\n fetch(url)\n .then((res) => {\n if (!res.ok) throw new Error();\n return res.text();\n })\n .then((text) => setContent(text.slice(0, 100_000)))\n .catch(() => setError(true));\n }\n\n if (error) return <p className=\"text-xs text-text-tertiary\">Could not load preview</p>;\n if (content === null) {\n return <div className=\"animate-pulse h-32 bg-surface-sunken rounded\" />;\n }\n\n return (\n <pre className=\"font-mono text-xs text-text-secondary bg-surface-sunken rounded-md p-3 overflow-x-auto max-h-[400px] overflow-y-auto whitespace-pre-wrap break-words\">\n {content}\n </pre>\n );\n}\n\nexport function FileMetadataDisplay({ metadata }: {\n metadata: FileMetadata;\n}) {\n const [copied, setCopied] = useState<string | null>(null);\n\n async function copyToClipboard(text: string, label: string) {\n await navigator.clipboard.writeText(text);\n setCopied(label);\n setTimeout(() => setCopied(null), 2000);\n }\n\n return (\n <div className=\"space-y-3\">\n <div>\n <dt className=\"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5\">Path</dt>\n <dd\n onClick={() => copyToClipboard(metadata.path, 'path')}\n className=\"group flex items-center gap-1.5 text-xs font-mono text-text-secondary break-all cursor-pointer hover:text-text-primary transition-colors\"\n title=\"Click to copy\"\n >\n <span className=\"flex-1\">{metadata.path}</span>\n {copied === 'path'\n ? <Check className=\"w-3.5 h-3.5 text-status-success shrink-0\" />\n : <Copy className=\"w-3.5 h-3.5 opacity-0 group-hover:opacity-100 text-text-tertiary shrink-0 transition-opacity\" />}\n </dd>\n </div>\n <MetaRow label=\"Type\" value={metadata.content_type} />\n <MetaRow label=\"Size\" value={formatSize(metadata.size)} />\n <MetaRow label=\"Modified\">\n <TimeAgo date={metadata.modified_at} />\n </MetaRow>\n </div>\n );\n}\n\nexport async function triggerDownload(url: string, name: string) {\n const res = await fetch(url);\n const blob = await res.blob();\n const blobUrl = URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = blobUrl;\n a.download = name;\n a.style.display = 'none';\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n URL.revokeObjectURL(blobUrl);\n}\n","import {\n Folder,\n File,\n Image,\n FileText,\n FileJson2,\n FileSpreadsheet,\n} from 'lucide-react';\nimport { TimeAgo } from '../../components/common/display/TimeAgo';\nimport { getFilePreviewUrl } from '../../api/files';\n\nexport function formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;\n}\n\nexport function fileIcon(filePath: string) {\n const ext = filePath.split('.').pop()?.toLowerCase() || '';\n if (['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp'].includes(ext)) {\n return <Image className=\"w-4 h-4 text-accent/60\" strokeWidth={1.5} />;\n }\n if (['json'].includes(ext)) {\n return <FileJson2 className=\"w-4 h-4 text-accent/60\" strokeWidth={1.5} />;\n }\n if (['csv', 'xlsx', 'xls'].includes(ext)) {\n return <FileSpreadsheet className=\"w-4 h-4 text-accent/60\" strokeWidth={1.5} />;\n }\n if (['txt', 'md', 'html', 'xml', 'yaml', 'yml', 'css', 'js', 'ts'].includes(ext)) {\n return <FileText className=\"w-4 h-4 text-accent/60\" strokeWidth={1.5} />;\n }\n return <File className=\"w-4 h-4 text-accent/60\" strokeWidth={1.5} />;\n}\n\nexport function isImagePath(filePath: string): boolean {\n const ext = filePath.split('.').pop()?.toLowerCase() || '';\n return ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp'].includes(ext);\n}\n\nexport function dirName(dirPath: string): string {\n const stripped = dirPath.replace(/\\/+$/, '');\n return stripped.split('/').pop() || stripped;\n}\n\nexport function fileNameFromPath(filePath: string): string {\n return filePath.split('/').pop() || filePath;\n}\n\ninterface ViewProps {\n directories: string[];\n files: Array<{ path: string; size: number; modified_at: string }>;\n onNavigate: (prefix: string) => void;\n onSelect: (path: string) => void;\n selectedFile: string | null;\n}\n\nexport function ListView({ directories, files, onNavigate, onSelect, selectedFile }: ViewProps) {\n return (\n <table className=\"w-full mt-2\">\n <thead>\n <tr className=\"text-left text-2xs uppercase tracking-wider text-text-tertiary\">\n <th className=\"pb-2 pl-2 font-medium\">Name</th>\n <th className=\"pb-2 font-medium w-24 text-right\">Size</th>\n <th className=\"pb-2 pr-2 font-medium w-40 text-right\">Modified</th>\n </tr>\n </thead>\n <tbody>\n {directories.map((dir) => (\n <tr\n key={dir}\n onClick={() => onNavigate(dir)}\n className=\"row-hover cursor-pointer group\"\n >\n <td className=\"py-2 pl-2\">\n <span className=\"flex items-center gap-2.5\">\n <Folder className=\"w-4 h-4 text-accent/75 shrink-0\" strokeWidth={1.5} />\n <span className=\"text-sm text-text-primary group-hover:text-accent transition-colors\">\n {dirName(dir)}\n </span>\n </span>\n </td>\n <td className=\"py-2 text-right text-xs text-text-tertiary\">&mdash;</td>\n <td className=\"py-2 pr-2 text-right text-xs text-text-tertiary\">&mdash;</td>\n </tr>\n ))}\n {files.map((file) => (\n <tr\n key={file.path}\n onClick={() => onSelect(file.path)}\n className={`row-hover cursor-pointer group ${\n selectedFile === file.path ? 'bg-surface-hover' : ''\n }`}\n >\n <td className=\"py-2 pl-2\">\n <span className=\"flex items-center gap-2.5\">\n {fileIcon(file.path)}\n <span className=\"text-sm text-text-primary truncate\">\n {fileNameFromPath(file.path)}\n </span>\n </span>\n </td>\n <td className=\"py-2 text-right text-xs text-text-secondary tabular-nums\">\n {formatSize(file.size)}\n </td>\n <td className=\"py-2 pr-2 text-right text-xs text-text-secondary\">\n <TimeAgo date={file.modified_at} />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n\nexport function GridView({ directories, files, onNavigate, onSelect, selectedFile }: ViewProps) {\n return (\n <div className=\"mt-4\">\n {/* Directories as compact list */}\n {directories.length > 0 && (\n <div className=\"flex flex-wrap gap-2 mb-6\">\n {directories.map((dir) => (\n <button\n key={dir}\n onClick={() => onNavigate(dir)}\n className=\"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-text-secondary hover:text-text-primary hover:bg-surface-hover transition-colors\"\n >\n <Folder className=\"w-4 h-4 text-accent/75\" strokeWidth={1.5} />\n <span>{dirName(dir)}</span>\n </button>\n ))}\n </div>\n )}\n\n {/* Files as thumbnail grid */}\n <div className=\"grid grid-cols-2 @grp-cols:grid-cols-3 @split:grid-cols-4 @wall:grid-cols-5 gap-3\">\n {files.map((file) => {\n const isImg = isImagePath(file.path);\n return (\n <button\n key={file.path}\n onClick={() => onSelect(file.path)}\n className={`group text-left rounded-lg overflow-hidden transition-all ${\n selectedFile === file.path\n ? 'ring-2 ring-accent/40 bg-surface-hover'\n : 'hover:bg-surface-hover'\n }`}\n >\n <div className=\"aspect-square bg-surface-sunken flex items-center justify-center overflow-hidden\">\n {isImg ? (\n <img\n src={getFilePreviewUrl(file.path)}\n alt={fileNameFromPath(file.path)}\n loading=\"lazy\"\n className=\"w-full h-full object-cover\"\n />\n ) : (\n <div className=\"flex flex-col items-center gap-2 text-text-tertiary\">\n {fileIcon(file.path)}\n <span className=\"text-2xs uppercase tracking-wider\">\n {file.path.split('.').pop()?.toUpperCase()}\n </span>\n </div>\n )}\n </div>\n <div className=\"px-2 py-1.5\">\n <p className=\"text-xs text-text-primary truncate\" title={fileNameFromPath(file.path)}>\n {fileNameFromPath(file.path)}\n </p>\n <p className=\"text-2xs text-text-tertiary tabular-nums\">\n {formatSize(file.size)}\n </p>\n </div>\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n","import { useState } from 'react';\nimport {\n X,\n Download,\n ExternalLink,\n Link,\n Check,\n Trash2,\n} from 'lucide-react';\nimport { useFileMetadata, useFilePreviewUrl, useGenerateSignedUrl, useDeleteFile } from '../../api/files';\nimport { fileName, triggerDownload, TextPreview, FileMetadataDisplay } from './FilePreviewContent';\nimport { isImagePath } from './FileListViews';\n\ninterface FilePreviewPanelProps {\n filePath: string;\n onClose: () => void;\n onDeleted?: () => void;\n}\n\nconst EXPIRY_OPTIONS = [\n { label: '1 hour', value: 3600 },\n { label: '6 hours', value: 21600 },\n { label: '24 hours', value: 86400 },\n { label: '7 days', value: 604800 },\n { label: '30 days', value: 2592000 },\n];\n\nexport function FilePreviewPanel({ filePath, onClose, onDeleted }: FilePreviewPanelProps) {\n const { data: metadata, isLoading } = useFileMetadata(filePath);\n const signedUrlMutation = useGenerateSignedUrl();\n const deleteMutation = useDeleteFile();\n const [showShareMenu, setShowShareMenu] = useState(false);\n const [copied, setCopied] = useState(false);\n const [confirmDelete, setConfirmDelete] = useState(false);\n\n const { data: previewUrl } = useFilePreviewUrl(filePath);\n const isImage = metadata?.content_type?.startsWith('image/') || isImagePath(filePath);\n const TEXT_EXTENSIONS = /\\.(ts|tsx|js|jsx|json|md|yaml|yml|toml|xml|csv|sql|sh|py|rb|go|rs|java|c|cpp|h|css|scss|html|txt|log|env|ini|cfg|conf)$/i;\n const isText = metadata?.content_type?.startsWith('text/')\n || metadata?.content_type === 'application/json'\n || metadata?.content_type === 'application/xml'\n || (metadata?.content_type === 'application/octet-stream' && TEXT_EXTENSIONS.test(filePath));\n const isPdf = metadata?.content_type === 'application/pdf';\n\n async function handleDownload() {\n try {\n const result = await signedUrlMutation.mutateAsync({ path: filePath, expiresIn: 3600 });\n const fullUrl = result.url.startsWith('http')\n ? result.url\n : `${window.location.origin}${result.url}`;\n triggerDownload(fullUrl, fileName(filePath));\n } catch {\n // handled by mutation state\n }\n }\n\n async function handleShare(expiresIn: number) {\n setShowShareMenu(false);\n try {\n const result = await signedUrlMutation.mutateAsync({ path: filePath, expiresIn });\n const fullUrl = result.url.startsWith('http')\n ? result.url\n : `${window.location.origin}${result.url}`;\n await navigator.clipboard.writeText(fullUrl);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch {\n // handled by mutation state\n }\n }\n\n return (\n <>\n {/* Fullscreen — opens image in a new tab */}\n\n {/* Panel */}\n <div className=\"w-[380px] shrink-0 border-l border-surface-border bg-surface overflow-y-auto\">\n {/* Header */}\n <div className=\"sticky top-0 bg-surface z-10 px-5 pt-5 pb-3 border-b border-surface-border\">\n <div className=\"flex items-center justify-between mb-3\">\n <h3 className=\"text-sm font-medium text-text-primary truncate pr-2\" title={fileName(filePath)}>\n {fileName(filePath)}\n </h3>\n <button onClick={onClose} className=\"text-text-tertiary hover:text-text-primary shrink-0\">\n <X className=\"w-4 h-4\" />\n </button>\n </div>\n\n {/* Actions */}\n <div className=\"flex items-center gap-1 flex-wrap\">\n <button\n onClick={handleDownload}\n className=\"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs\"\n title=\"Download\"\n >\n <Download className=\"w-3.5 h-3.5\" />\n <span>Download</span>\n </button>\n\n <a\n href={previewUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs\"\n title=\"Open in new tab\"\n >\n <ExternalLink className=\"w-3.5 h-3.5\" />\n <span>Open</span>\n </a>\n\n <div className=\"relative\">\n <button\n onClick={() => setShowShareMenu((v) => !v)}\n className=\"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs\"\n title=\"Share with signed URL\"\n >\n {copied ? <Check className=\"w-3.5 h-3.5 text-status-success\" /> : <Link className=\"w-3.5 h-3.5\" />}\n <span>Share</span>\n </button>\n {showShareMenu && (\n <div className=\"absolute top-full left-0 mt-1 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100] min-w-[120px]\">\n {EXPIRY_OPTIONS.map((opt) => (\n <button\n key={opt.value}\n onClick={() => handleShare(opt.value)}\n className=\"w-full text-left px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover hover:text-text-primary transition-colors\"\n >\n {opt.label}\n </button>\n ))}\n </div>\n )}\n </div>\n\n <button\n onClick={() => setConfirmDelete(true)}\n className=\"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs text-status-error/70 hover:text-status-error\"\n title=\"Delete file\"\n >\n <Trash2 className=\"w-3.5 h-3.5\" />\n <span>Delete</span>\n </button>\n </div>\n\n {/* Delete confirmation */}\n {confirmDelete && (\n <div className=\"mt-3 p-3 bg-status-error/5 border border-status-error/20 rounded-md\">\n <p className=\"text-xs text-text-primary mb-2\">\n Permanently delete <span className=\"font-medium\">{fileName(filePath)}</span>? This cannot be undone.\n </p>\n <div className=\"flex gap-2\">\n <button\n onClick={() => setConfirmDelete(false)}\n className=\"btn-secondary text-xs\"\n disabled={deleteMutation.isPending}\n >\n Cancel\n </button>\n <button\n onClick={async () => {\n try {\n await deleteMutation.mutateAsync(filePath);\n setConfirmDelete(false);\n onDeleted?.();\n } catch {\n // error shown below\n }\n }}\n className=\"btn-primary text-xs !bg-status-error hover:!bg-status-error/90\"\n disabled={deleteMutation.isPending}\n >\n {deleteMutation.isPending ? 'Deleting...' : 'Delete'}\n </button>\n </div>\n {deleteMutation.isError && (\n <p className=\"text-xs text-status-error mt-2\">{deleteMutation.error.message}</p>\n )}\n </div>\n )}\n\n {signedUrlMutation.isError && (\n <p className=\"text-xs text-status-error mt-2\">{signedUrlMutation.error.message}</p>\n )}\n </div>\n\n {/* Preview area */}\n <div className=\"p-5\">\n {isLoading ? (\n <div className=\"animate-pulse space-y-3\">\n <div className=\"h-48 bg-surface-sunken rounded\" />\n <div className=\"h-4 bg-surface-sunken rounded w-2/3\" />\n </div>\n ) : (\n <>\n {isImage && previewUrl && (\n <div\n className=\"mb-5 rounded-md border border-surface-border bg-surface-sunken overflow-hidden\"\n style={{ maxHeight: '400px' }}\n >\n <img\n src={previewUrl}\n alt={fileName(filePath)}\n className=\"w-full object-cover object-top\"\n style={{ maxHeight: '400px' }}\n />\n </div>\n )}\n\n {isText && previewUrl && (\n <div className=\"mb-5\">\n <TextPreview url={previewUrl} />\n </div>\n )}\n\n {isPdf && previewUrl && (\n <div className=\"mb-5 p-4 bg-surface-sunken rounded-md text-center\">\n <a\n href={previewUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-accent hover:text-accent-hover text-sm font-medium\"\n >\n Open PDF in new tab\n </a>\n </div>\n )}\n\n {metadata && (\n <FileMetadataDisplay metadata={metadata} />\n )}\n </>\n )}\n </div>\n </div>\n </>\n );\n}\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useSearchParams } from 'react-router-dom';\nimport {\n ChevronLeft,\n ChevronRight,\n Upload,\n UploadCloud,\n} from 'lucide-react';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { SEARCH_DEBOUNCE_MS } from '../../lib/realtime-refresh';\nimport { PageHeader } from '../../components/common/layout/PageHeader';\nimport { FilterBar, FilterInput } from '../../components/common/data/FilterBar';\nimport { ListToolbar } from '../../components/common/data/ListToolbar';\nimport { buildApiPath } from '../../lib/api-path';\nimport { EmptyState } from '../../components/common/display/EmptyState';\nimport { DropZone } from '../../components/common/DropZone';\nimport { useFileBrowse, useUploadFile } from '../../api/files';\nimport { FileBreadcrumbs } from './FileBreadcrumbs';\nimport { FilePreviewPanel } from './FilePreviewPanel';\nimport { ListView } from './FileListViews';\n\nconst PAGE_SIZES = [25, 50, 100, 200];\n\nexport function FilesPage() {\n const [searchParams, setSearchParams] = useSearchParams();\n const prefix = searchParams.get('prefix') || '';\n const [search, setSearch] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n const [selectedFile, setSelectedFile] = useState<string | null>(null);\n const [pageSize, setPageSize] = useState(100);\n const [tokenStack, setTokenStack] = useState<string[]>([]);\n const [currentToken, setCurrentToken] = useState<string | undefined>();\n\n // Debounce search — refines the prefix sent to S3\n useEffect(() => {\n const t = setTimeout(() => {\n setDebouncedSearch(search);\n setCurrentToken(undefined);\n setTokenStack([]);\n }, SEARCH_DEBOUNCE_MS);\n return () => clearTimeout(t);\n }, [search]);\n\n const effectivePrefix = debouncedSearch\n ? `${prefix}${debouncedSearch}`\n : prefix;\n\n const { data, isLoading, isFetching, refetch } = useFileBrowse(effectivePrefix, pageSize, currentToken);\n const uploadMutation = useUploadFile();\n const queryClient = useQueryClient();\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n const [pendingFiles, setPendingFiles] = useState<File[] | null>(null);\n const [uploadPrefix, setUploadPrefix] = useState('');\n\n const handleUploadFiles = useCallback((files: File[]) => {\n setPendingFiles(files);\n setUploadPrefix(prefix);\n }, [prefix]);\n\n const [uploadError, setUploadError] = useState('');\n\n const confirmUpload = useCallback(() => {\n if (!pendingFiles) return;\n setUploadError('');\n let remaining = pendingFiles.length;\n for (const file of pendingFiles) {\n const targetPath = `${uploadPrefix}${file.name}`;\n uploadMutation.mutate({ path: targetPath, file }, {\n onSuccess: () => {\n remaining--;\n queryClient.invalidateQueries({ queryKey: ['fileBrowse'] });\n if (remaining <= 0) setPendingFiles(null);\n },\n onError: (err) => {\n remaining--;\n setUploadError(err.message);\n console.error('[Upload] failed:', targetPath, err);\n },\n });\n }\n }, [pendingFiles, uploadPrefix, uploadMutation, queryClient]);\n\n const directories = data?.directories ?? [];\n const files = data?.files ?? [];\n const nextToken = data?.nextToken;\n\n const navigateTo = useCallback((newPrefix: string) => {\n setSearch('');\n setDebouncedSearch('');\n setSelectedFile(null);\n setCurrentToken(undefined);\n setTokenStack([]);\n if (newPrefix) {\n setSearchParams({ prefix: newPrefix });\n } else {\n setSearchParams({});\n }\n }, [setSearchParams]);\n\n function goNextPage() {\n if (!nextToken) return;\n setTokenStack((prev) => [...prev, currentToken || '']);\n setCurrentToken(nextToken);\n }\n\n function goPrevPage() {\n if (tokenStack.length === 0) return;\n const prev = [...tokenStack];\n const token = prev.pop()!;\n setTokenStack(prev);\n setCurrentToken(token || undefined);\n }\n\n function changePageSize(size: number) {\n setPageSize(size);\n setCurrentToken(undefined);\n setTokenStack([]);\n }\n\n const isEmpty = directories.length === 0 && files.length === 0;\n const pageNum = tokenStack.length + 1;\n const hasNextPage = !!nextToken;\n const hasPrevPage = tokenStack.length > 0;\n\n const apiPath = buildApiPath('/file-browser/browse', {\n prefix: effectivePrefix,\n pageSize,\n continuationToken: currentToken || undefined,\n });\n\n return (\n <DropZone onDrop={handleUploadFiles} label=\"Drop files to upload\">\n <div className=\"flex gap-0\">\n {/* Hidden file input for button-triggered upload */}\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple\n className=\"hidden\"\n onChange={(e) => {\n const files = Array.from(e.target.files || []);\n if (files.length) handleUploadFiles(files);\n e.target.value = '';\n }}\n />\n\n {/* Main content */}\n <div className=\"flex-1 min-w-0 overflow-hidden pr-6\">\n <PageHeader\n title=\"Files\"\n docsHash=\"#docs:dashboard.md:files\"\n actions={\n <button\n onClick={() => fileInputRef.current?.click()}\n disabled={uploadMutation.isPending}\n className=\"btn-primary text-xs inline-flex items-center gap-1.5\"\n >\n <Upload className=\"w-3.5 h-3.5\" />\n {uploadMutation.isPending ? 'Uploading...' : 'Upload'}\n </button>\n }\n />\n\n <FileBreadcrumbs prefix={prefix} onNavigate={navigateTo} />\n\n <FilterBar actions={\n <ListToolbar\n onRefresh={() => refetch()}\n isFetching={isFetching}\n apiPath={apiPath}\n />\n }>\n <FilterInput\n label=\"Search\"\n value={search}\n onChange={setSearch}\n placeholder=\"Filter by prefix...\"\n />\n </FilterBar>\n\n {isLoading ? (\n <div className=\"animate-pulse space-y-2 mt-4\">\n {Array.from({ length: 6 }).map((_, i) => (\n <div key={i} className=\"h-10 bg-surface-sunken rounded\" />\n ))}\n </div>\n ) : isEmpty ? (\n <div className=\"cursor-pointer\" onClick={() => fileInputRef.current?.click()}>\n <EmptyState\n icon={UploadCloud}\n title={search ? 'No matching files' : 'No files yet'}\n description={search ? undefined : 'Drop files here or click to upload'}\n />\n </div>\n ) : (\n <ListView\n directories={directories}\n files={files}\n onNavigate={navigateTo}\n onSelect={setSelectedFile}\n selectedFile={selectedFile}\n />\n )}\n\n {/* Cursor-based pagination */}\n {(hasPrevPage || hasNextPage || files.length > 0) && (\n <div className=\"flex items-center justify-between pt-4 pb-2\">\n <div className=\"flex items-center gap-4\">\n <p className=\"text-xs text-text-tertiary\">\n Page {pageNum} &middot; {files.length + directories.length} items\n </p>\n <select\n value={pageSize}\n onChange={(e) => changePageSize(parseInt(e.target.value))}\n className=\"select text-xs py-1\"\n >\n {PAGE_SIZES.map((size) => (\n <option key={size} value={size}>{size} / page</option>\n ))}\n </select>\n </div>\n {(hasPrevPage || hasNextPage) && (\n <div className=\"flex items-center gap-1\">\n <button\n onClick={goPrevPage}\n disabled={!hasPrevPage}\n className=\"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1\"\n >\n <ChevronLeft className=\"w-3.5 h-3.5\" />\n Previous\n </button>\n <button\n onClick={goNextPage}\n disabled={!hasNextPage}\n className=\"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1\"\n >\n Next\n <ChevronRight className=\"w-3.5 h-3.5\" />\n </button>\n </div>\n )}\n </div>\n )}\n </div>\n\n {/* Preview panel */}\n {selectedFile && (\n <FilePreviewPanel\n filePath={selectedFile}\n onClose={() => setSelectedFile(null)}\n onDeleted={() => { setSelectedFile(null); refetch(); }}\n />\n )}\n </div>\n {/* Upload confirmation dialog */}\n {pendingFiles && createPortal(\n <>\n <div className=\"fixed inset-0 z-40 bg-black/30\" onClick={() => setPendingFiles(null)} />\n <div className=\"fixed inset-0 z-50 flex items-center justify-center p-4\">\n <div className=\"bg-surface-raised border border-surface-border rounded-lg shadow-lg w-full max-w-sm\">\n <div className=\"px-5 py-4 border-b border-surface-border\">\n <h3 className=\"text-sm font-medium text-text-primary\">Upload {pendingFiles.length} file{pendingFiles.length > 1 ? 's' : ''}</h3>\n </div>\n <div className=\"px-5 py-4 space-y-3\">\n <div>\n <label className=\"block text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1\">Destination folder</label>\n <input\n type=\"text\"\n value={uploadPrefix}\n onChange={(e) => setUploadPrefix(e.target.value)}\n placeholder=\"e.g., images/ or leave empty for root\"\n className=\"input text-xs w-full font-mono\"\n />\n </div>\n <div className=\"text-2xs text-text-quaternary space-y-0.5\">\n {pendingFiles.map((f, i) => (\n <p key={i} className=\"truncate\">{uploadPrefix}{f.name} <span className=\"text-text-tertiary\">({(f.size / 1024).toFixed(1)} KB)</span></p>\n ))}\n </div>\n {uploadError && <p className=\"text-xs text-status-error\">{uploadError}</p>}\n </div>\n <div className=\"flex justify-end gap-2 px-5 py-3 border-t border-surface-border\">\n <button onClick={() => setPendingFiles(null)} className=\"btn-ghost text-xs\">Cancel</button>\n <button onClick={confirmUpload} className=\"btn-primary text-xs\">\n <Upload className=\"w-3.5 h-3.5 mr-1.5 inline\" />\n Upload\n </button>\n </div>\n </div>\n </div>\n </>,\n document.body,\n )}\n </DropZone>\n );\n}\n"],"names":["useFileBrowse","prefix","pageSize","continuationToken","params","qs","useQuery","apiFetch","useFileMetadata","filePath","useGenerateSignedUrl","useMutation","data","useDeleteFile","useUploadFile","path","file","buffer","useFilePreviewUrl","FileBreadcrumbs","onNavigate","segments","jsxs","jsx","FolderOpen","segment","i","isLast","targetPrefix","ChevronRight","formatSize","bytes","fileName","MetaRow","label","value","mono","children","TextPreview","url","content","setContent","useState","error","setError","res","text","FileMetadataDisplay","metadata","copied","setCopied","copyToClipboard","Check","Copy","TimeAgo","triggerDownload","name","blob","blobUrl","a","fileIcon","ext","_a","Image","FileJson2","FileSpreadsheet","FileText","File","isImagePath","dirName","dirPath","stripped","fileNameFromPath","ListView","directories","files","onSelect","selectedFile","dir","Folder","EXPIRY_OPTIONS","FilePreviewPanel","onClose","onDeleted","isLoading","signedUrlMutation","deleteMutation","showShareMenu","setShowShareMenu","confirmDelete","setConfirmDelete","previewUrl","isImage","TEXT_EXTENSIONS","isText","_b","isPdf","handleDownload","result","fullUrl","handleShare","expiresIn","Fragment","X","Download","ExternalLink","v","Link","opt","Trash2","PAGE_SIZES","FilesPage","searchParams","setSearchParams","useSearchParams","search","setSearch","debouncedSearch","setDebouncedSearch","setSelectedFile","setPageSize","tokenStack","setTokenStack","currentToken","setCurrentToken","useEffect","t","SEARCH_DEBOUNCE_MS","effectivePrefix","isFetching","refetch","uploadMutation","queryClient","useQueryClient","fileInputRef","useRef","pendingFiles","setPendingFiles","uploadPrefix","setUploadPrefix","handleUploadFiles","useCallback","uploadError","setUploadError","confirmUpload","remaining","targetPath","err","nextToken","navigateTo","newPrefix","goNextPage","prev","goPrevPage","token","changePageSize","size","isEmpty","pageNum","hasNextPage","hasPrevPage","apiPath","buildApiPath","DropZone","e","PageHeader","Upload","FilterBar","ListToolbar","FilterInput","_","EmptyState","UploadCloud","ChevronLeft","createPortal","f"],"mappings":"urBA4BO,SAASA,GAAcC,EAAgBC,EAAW,IAAKC,EAA4B,CACxF,MAAMC,EAAS,IAAI,gBACfH,GAAQG,EAAO,IAAI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,SAAA,CAAAC,EAAAA,IAAC,QAAA,CAAM,UAAU,iFAAiF,SAAA,qBAAkB,EACpHA,EAAAA,IAAC,QAAA,CACC,KAAK,OACL,MAAOmH,EACP,SAAW0B,GAAMzB,EAAgByB,EAAE,OAAO,KAAK,EAC/C,YAAY,wCACZ,UAAU,gCAAA,CAAA,CACZ,EACF,EACA7I,EAAAA,IAAC,MAAA,CAAI,UAAU,4CACZ,SAAAiH,EAAa,IAAI,CAACuC,EAAGrJ,IACpBJ,EAAAA,KAAC,IAAA,CAAU,UAAU,WAAY,SAAA,CAAAoH,EAAcqC,EAAE,KAAK,IAACzJ,EAAAA,KAAC,OAAA,CAAK,UAAU,qBAAqB,SAAA,CAAA,KAAGyJ,EAAE,KAAO,MAAM,QAAQ,CAAC,EAAE,MAAA,CAAA,CAAI,CAAA,GAArHrJ,CAA4H,CACrI,EACH,EACCoH,GAAevH,EAAAA,IAAC,IAAA,CAAE,UAAU,4BAA6B,SAAAuH,CAAA,CAAY,CAAA,EACxE,EACAxH,EAAAA,KAAC,MAAA,CAAI,UAAU,kEACb,SAAA,CAAAC,EAAAA,IAAC,SAAA,CAAO,QAAS,IAAMkH,EAAgB,IAAI,EAAG,UAAU,oBAAoB,SAAA,QAAA,CAAM,EAClFnH,EAAAA,KAAC,SAAA,CAAO,QAAS0H,EAAe,UAAU,sBACxC,SAAA,CAAAzH,EAAAA,IAAC+I,EAAA,CAAO,UAAU,2BAAA,CAA4B,EAAE,QAAA,CAAA,CAElD,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CACF,CAAA,EACF,EACA,SAAS,IAAA,CACX,EACA,CAEJ"}
@@ -1,4 +1,4 @@
1
- import{a as d,j as e}from"./vendor-query-DvWWuNIB.js";import{aD as Z,aI as A,Y as ee,a as te,aJ as se,az as re,aA as oe,ay as ne}from"./index-ygxyAKcc.js";import{F as ae,b as le,a as ie}from"./FilterBar-Dy0b7wwf.js";import{C as Q}from"./ConfirmDeleteModal-CpJNP-8w.js";import{R as L}from"./RolePill-D3hkAdKf.js";import{W as ce}from"./WorkflowPill-CKHip3hH.js";import{P as ue}from"./PageHeader-DiGWAQlR.js";import{Q as de,ay as F,aB as B,aF as me,k as z,aG as xe,aH as H,a5 as pe,U as J,X as he,C as fe,ad as we,aI as T,m as ke,E as ve}from"./vendor-icons-en0_uSRD.js";import{u as G,e as ge,f as je}from"./vendor-react-_9U4mKFr.js";import{B as ye}from"./BotPicker-Dqpo36dM.js";import{N as Ne}from"./NamespacePill-CeSfHH-j.js";import{c as be,f as _e,R as Ce,g as Se,h as U}from"./ResolverForm-BxJkoKAO.js";import"./bots-WrUhEPWs.js";import"./RosterWidget-BJMx0a8Z.js";import"./escalation-items-DFGRwo49.js";import"./UserName-DKXnK7DD.js";import"./validate-CAin6WM_.js";import"./StatusBadge-DHVwxre2.js";import"./constants-CeBBTzf5.js";function Ie({tier:t}){return t==="certified"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-medium text-status-success",children:[e.jsx(B,{className:"w-3 h-3"}),"Certified"]}):t==="registered"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-medium text-text-secondary",children:[e.jsx(pe,{className:"w-3 h-3"}),"Registered"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-medium text-text-quaternary",children:[e.jsx(F,{className:"w-3 h-3"}),"Durable"]})}function rt(){const t=G(),{data:o,isLoading:i}=Z(),m=A(),[u,p]=d.useState(""),[r,k]=d.useState(null),[f,g]=d.useState(null),a=o??[],y=d.useMemo(()=>[...new Set(a.map(l=>l.task_queue).filter(Boolean))].sort(),[a]),c=d.useMemo(()=>{const l=u.toLowerCase().trim();return(r?[r]:y).map(h=>({queue:h,workflows:a.filter(S=>{var N;return S.task_queue===h&&(!l||S.workflow_type.toLowerCase().includes(l)||((N=S.description)==null?void 0:N.toLowerCase().includes(l)))})})).filter(h=>h.workflows.length>0)},[a,y,u,r]),x=d.useMemo(()=>{const l=u.toLowerCase().trim();return r?[]:a.filter(s=>{var h;return!s.task_queue&&(!l||s.workflow_type.toLowerCase().includes(l)||((h=s.description)==null?void 0:h.toLowerCase().includes(l)))})},[a,u,r]),C=l=>{l.registered?t(`/workflows/registry/${encodeURIComponent(l.workflow_type)}`):t(`/workflows/registry/new?workflow_type=${encodeURIComponent(l.workflow_type)}&task_queue=${encodeURIComponent(l.task_queue??"")}`)},I=()=>{f&&m.mutate(f,{onSuccess:()=>g(null)})};return e.jsxs("div",{children:[e.jsx(ue,{title:"Registered Workflows",docsHash:"#docs:dashboard.md:workflow-registry",actions:e.jsx("button",{onClick:()=>t("/workflows/registry/new"),className:"btn-primary text-xs",children:"Register Workflow"})}),!i&&y.length>0&&e.jsxs(ae,{children:[e.jsx(le,{label:"Queue",value:r??"",onChange:l=>k(l||null),options:y.map(l=>({value:l,label:l}))}),e.jsx(ie,{label:"Search",value:u,onChange:p,placeholder:`${a.length} workflows…`})]}),i?e.jsx(We,{}):c.length===0&&x.length===0?e.jsx("p",{className:"text-sm text-text-tertiary mt-8",children:u||r?"No workflows match your filter.":"No workflows discovered yet."}):e.jsxs("div",{className:"space-y-10",children:[c.map(({queue:l,workflows:s})=>e.jsxs("div",{children:[e.jsxs("div",{className:"sticky top-[60px] z-10 bg-surface flex items-center gap-2 py-2 mb-2 border-b border-surface-border",children:[e.jsx(de,{className:"w-3 h-3 text-accent",strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:l}),e.jsx("span",{className:"text-xs text-text-quaternary",children:s.length})]}),e.jsx($,{}),e.jsx("div",{className:"divide-y divide-surface-border/30",children:s.map(h=>e.jsx(M,{wf:h,onRowClick:C,onDelete:g,onNavigate:t},h.workflow_type))})]},l)),x.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"sticky top-[60px] z-10 bg-surface flex items-center gap-2 py-2 mb-2 border-b border-surface-border",children:[e.jsx(F,{className:"w-3 h-3 text-text-quaternary",strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:"No Queue"}),e.jsx("span",{className:"text-xs text-text-quaternary",children:x.length})]}),e.jsx($,{}),e.jsx("div",{className:"divide-y divide-surface-border/30",children:x.map(l=>e.jsx(M,{wf:l,onRowClick:C,onDelete:g,onNavigate:t},l.workflow_type))})]})]}),e.jsx(Q,{open:!!f,onClose:()=>g(null),onConfirm:I,title:"Unregister Workflow",description:e.jsxs(e.Fragment,{children:["Delete the registration for"," ",e.jsx("span",{className:"font-mono font-medium text-text-primary",children:f}),"? This removes its invocation settings, certification, and interceptor treatment; the workflow keeps running as a plain durable workflow. To demote certified → registered instead, open the workflow and uncheck Certify — that keeps every setting."]}),isPending:m.isPending,error:m.error})]})}const K="grid grid-cols-[minmax(0,1fr)_7rem_13rem_4.5rem] gap-x-6";function $(){return e.jsxs("div",{className:`${K} px-3 pb-2 pt-1`,children:[e.jsx("span",{className:"text-2xs font-medium text-text-quaternary",children:"Workflow"}),e.jsx("span",{className:"text-2xs font-medium text-text-quaternary",children:"Tier"}),e.jsx("span",{className:"text-2xs font-medium text-text-quaternary",children:"Access"}),e.jsx("span",{})]})}function M({wf:t,onRowClick:o,onDelete:i,onNavigate:m}){const u=t.roles??[],p=t.invocation_roles??[];return e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>o(t),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&o(t)},className:`group ${K} py-2 px-3 -mx-3 rounded-md cursor-pointer transition-colors items-center`,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ce,{type:t.workflow_type,size:"md",variant:t.tier==="certified"?"certified":t.tier==="registered"?"registered":"durable"}),t.description&&e.jsx("p",{className:"flex-1 min-w-0 truncate text-2xs text-text-tertiary group-hover:text-text-secondary transition-colors",children:t.description})]}),e.jsx("div",{children:e.jsx(Ie,{tier:t.tier??"durable"})}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden whitespace-nowrap",children:[u.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{title:"Escalation roles",children:e.jsx(B,{className:"w-3 h-3 text-text-quaternary shrink-0"})}),u.map(r=>e.jsx(L,{role:r},`e-${r}`))]}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{title:"Invocation roles",children:e.jsx(me,{className:"w-3 h-3 text-text-quaternary shrink-0"})}),p.map(r=>e.jsx(L,{role:r},`i-${r}`))]}),u.length===0&&p.length===0&&e.jsx("span",{className:"text-xs text-text-quaternary",children:"—"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[t.invocable&&e.jsx("button",{title:"Invoke workflow",onClick:r=>{r.stopPropagation(),m(`/workflows/start?type=${encodeURIComponent(t.workflow_type)}&mode=now`)},className:"text-text-quaternary hover:text-status-success transition-colors",children:e.jsx(z,{className:"w-3.5 h-3.5"})}),t.tier==="durable"&&e.jsx("button",{title:"Configure workflow",onClick:r=>{r.stopPropagation(),m(`/workflows/registry/new?workflow_type=${encodeURIComponent(t.workflow_type)}&task_queue=${encodeURIComponent(t.task_queue??"")}`)},className:"text-text-quaternary hover:text-status-info transition-colors",children:e.jsx(F,{className:"w-3.5 h-3.5"})}),t.tier==="registered"&&e.jsx("button",{title:"Certify workflow",onClick:r=>{r.stopPropagation(),m(`/workflows/registry/${encodeURIComponent(t.workflow_type)}`)},className:"text-text-quaternary hover:text-status-success transition-colors",children:e.jsx(xe,{className:"w-3.5 h-3.5"})}),t.registered&&e.jsx("button",{title:"Unregister workflow",onClick:r=>{r.stopPropagation(),i(t.workflow_type)},className:"text-text-quaternary hover:text-status-warning transition-colors",children:e.jsx(H,{className:"w-3.5 h-3.5"})})]})]})}function We(){return e.jsx("div",{className:"animate-pulse space-y-8 mt-4",children:[1,2].map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"h-4 bg-surface-sunken rounded w-36 mb-4"}),e.jsx("div",{className:"space-y-4",children:[1,2,3].map(o=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"}),e.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]},o))})]},t))})}function Re({selected:t,onChange:o,single:i,placeholder:m}){const{data:u}=ee(),p=(u==null?void 0:u.roles)??[],[r,k]=d.useState(!1),f=d.useRef(null);d.useEffect(()=>{const c=x=>{f.current&&!f.current.contains(x.target)&&k(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]);const g=c=>{i?(o(t.includes(c)?[]:[c]),k(!1)):o(t.includes(c)?t.filter(x=>x!==c):[...t,c])},a=c=>{o(t.filter(x=>x!==c))},y=m??(i?"Select role...":"Add roles...");return e.jsxs("div",{ref:f,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>k(!r),className:"flex flex-wrap items-center gap-1.5 w-full min-h-[34px] px-2 py-1.5 bg-surface-sunken border border-surface-border rounded-md text-left cursor-pointer hover:border-accent/40 transition-colors focus:ring-1 focus:ring-accent focus:outline-none",children:[t.length===0&&e.jsx("span",{className:"text-xs text-text-tertiary",children:y}),t.map(c=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-lg bg-accent/[0.08] text-text-secondary text-2xs",children:[e.jsx(J,{className:"w-2.5 h-2.5 shrink-0 text-accent/75"}),c,e.jsx("span",{role:"button",onClick:x=>{x.stopPropagation(),a(c)},className:"ml-0.5 hover:text-status-error transition-colors",children:e.jsx(he,{className:"w-2.5 h-2.5"})})]},c)),e.jsx(fe,{className:`w-3.5 h-3.5 ml-auto shrink-0 text-text-tertiary transition-transform ${r?"rotate-180":""}`})]}),r&&e.jsx("div",{className:"absolute z-[100] mt-1 w-full bg-surface-raised border border-surface-border rounded-md shadow-lg max-h-48 overflow-y-auto",children:p.length===0?e.jsx("p",{className:"px-3 py-2 text-xs text-text-tertiary",children:"No roles defined"}):p.map(c=>{const x=t.includes(c);return e.jsxs("button",{type:"button",onClick:()=>g(c),className:`flex items-center gap-2 w-full px-3 py-1.5 text-left text-xs transition-colors ${x?"bg-accent/[0.06] text-accent":"text-text-primary hover:bg-surface-sunken"}`,children:[e.jsx(J,{className:"w-3 h-3 shrink-0 text-accent/60"}),e.jsx("span",{className:"flex-1",children:c}),x&&e.jsx(we,{className:"w-3 h-3 shrink-0"})]},c)})})]})}function W(t){return t.split(",").map(o=>o.trim()).filter(Boolean)}const R={workflow_type:"",description:"",task_queue:"",default_role:"reviewer",invocable:!1,roles:"",invocation_roles:"",consumes:"",envelope_schema:"",input_schema:"",input_lookups:"",icon:"",resolver_schema:"",cron_schedule:"",execute_as:"",certified:!1};function qe(t){var m;const o=(t.roles??[]).join(", "),i=(t.consumes??[]).join(", ");return{workflow_type:t.workflow_type,description:t.description??"",task_queue:t.task_queue??"",default_role:t.default_role,invocable:t.invocable,roles:o,invocation_roles:(t.invocation_roles??[]).join(", "),consumes:i,envelope_schema:t.envelope_schema?JSON.stringify(t.envelope_schema,null,2):"",input_schema:t.input_schema?JSON.stringify(t.input_schema,null,2):"",input_lookups:(m=t.input_lookups)!=null&&m.length?JSON.stringify(t.input_lookups,null,2):"",icon:t.icon??"",resolver_schema:t.resolver_schema?JSON.stringify(t.resolver_schema,null,2):"",cron_schedule:t.cron_schedule??"",execute_as:t.execute_as??"",certified:t.certified}}function _(t){if(!t.trim())return!0;try{return JSON.parse(t),!0}catch{return!1}}function Pe(t){if(!t.trim())return null;try{const o=JSON.parse(t);return o&&typeof o=="object"&&!Array.isArray(o)&&o.properties?o:null}catch{return null}}function Fe({schemaText:t,lookup:o}){const i=d.useMemo(()=>Pe(t),[t]),m=d.useMemo(()=>i?be(i):"",[i]),[u,p]=d.useState(m);d.useEffect(()=>{p(m)},[m]);const r=d.useMemo(()=>({..._e({},o),resolver:null}),[o]);return i?e.jsx("div",{className:"@container","data-testid":"input-form-preview",children:e.jsx(Ce,{value:u,onChange:p,escalationContext:r})}):e.jsxs("p",{className:"text-2xs text-text-tertiary",children:["A schema with ",e.jsx("code",{className:"font-mono",children:"properties"})," previews here as the operator's form."]})}function Oe({value:t,onChange:o}){const[i,m]=d.useState(""),u=d.useMemo(()=>Se(i),[i]),p=U(t);return e.jsxs("div",{className:"space-y-2","data-testid":"workflow-icon-picker",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:i,onChange:r=>m(r.target.value),placeholder:"Filter icons…","aria-label":"Filter icons",className:"input text-2xs py-1 w-40"}),e.jsxs("span",{className:"flex items-center gap-1.5 text-2xs text-text-tertiary min-w-0",children:[p?e.jsx(p,{className:"w-3.5 h-3.5 text-accent shrink-0",strokeWidth:1.5}):e.jsx(T,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"font-mono truncate",children:t||"tier glyph"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",role:"listbox","aria-label":"Workflow icon",children:[e.jsx("button",{type:"button",role:"option","aria-selected":!t,title:"No icon (tier glyph)",onClick:()=>o(""),className:`p-1.5 rounded-md border transition-colors ${t?"border-transparent text-text-quaternary hover:bg-surface-hover hover:text-text-secondary":"border-accent bg-accent/10 text-accent"}`,children:e.jsx(T,{className:"w-4 h-4",strokeWidth:1.5})}),u.map(r=>{const k=U(r),f=t===r;return e.jsx("button",{type:"button",role:"option","aria-selected":f,title:r,onClick:()=>o(r),className:`p-1.5 rounded-md border transition-colors ${f?"border-accent bg-accent/10 text-accent":"border-transparent text-text-tertiary hover:bg-surface-hover hover:text-text-primary"}`,children:e.jsx(k,{className:"w-4 h-4",strokeWidth:1.5})},r)}),u.length===0&&e.jsx("p",{className:"text-2xs text-text-tertiary px-1 py-1.5",children:"No icon matches."})]})]})}function q({icon:t,color:o,children:i}){return e.jsxs("div",{className:"flex items-center gap-2 mb-4 pb-2 border-b border-surface-border",children:[e.jsx(t,{className:`w-4 h-4 ${o}`,strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:i})]})}function j({label:t,hint:o,children:i}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"label",children:t}),i,o&&e.jsx("p",{className:"hint",children:o})]})}const P="input-json w-full";function De(t){return W(t)}function Ee(t){return t.join(", ")}const Le=new Set(["mcpQuery","mcpDeterministic","mcpQueryRouter","mcpTriage","mcpTriageRouter","mcpTriageDeterministic","insightQuery"]);function ot(){const{workflowType:t}=ge(),o=!t,i=G(),[m]=je(),{data:u,isLoading:p}=te(),r=se(),k=A(),[f,g]=d.useState(!1),a=(u==null?void 0:u.find(n=>n.workflow_type===t))??null,y=Array.isArray(a==null?void 0:a.input_lookups)&&a.input_lookups.length>0,{data:c}=re((a==null?void 0:a.workflow_type)??"",y),x=d.useMemo(()=>c?oe(c.lookups):void 0,[c]),{data:C}=ne({limit:500}),I=d.useMemo(()=>{const n=new Set((u??[]).map(v=>v.workflow_type));return[...new Set(((C==null?void 0:C.jobs)??[]).map(v=>v.entity))].filter(v=>!n.has(v)&&!Le.has(v)).sort()},[u,C]),l=d.useMemo(()=>{if(!o)return R;const n=m.get("workflow_type")??"",b=m.get("task_queue")??"";return n||b?{...R,workflow_type:n,task_queue:b}:R},[o,m]),[s,h]=d.useState(l),[S,N]=d.useState(""),[O,D]=d.useState(!1),w=d.useCallback((n,b)=>h(v=>({...v,[n]:b})),[]);d.useEffect(()=>{if(!O){if(o){h(l),D(!0);return}a&&(h(qe(a)),D(!0))}},[a,o,O,l]);const Y=()=>{if(!s.workflow_type.trim())return;N("");let n=null,b=null,v=null,E=null;try{s.envelope_schema.trim()&&(n=JSON.parse(s.envelope_schema))}catch{N("Invalid JSON in Envelope Schema");return}try{s.input_schema.trim()&&(b=JSON.parse(s.input_schema))}catch{N("Invalid JSON in Input Form");return}try{s.input_lookups.trim()&&(v=JSON.parse(s.input_lookups))}catch{N("Invalid JSON in Lookups");return}try{s.resolver_schema.trim()&&(E=JSON.parse(s.resolver_schema))}catch{N("Invalid JSON in Resolver Schema");return}r.mutate({workflow_type:s.workflow_type.trim(),description:s.description.trim()||null,task_queue:s.task_queue.trim()||null,default_role:s.default_role.trim()||"reviewer",invocable:s.invocable,certified:s.certified,roles:W(s.roles),invocation_roles:W(s.invocation_roles),consumes:W(s.consumes),envelope_schema:n,input_schema:b,input_lookups:v,icon:s.icon||null,resolver_schema:E,cron_schedule:s.cron_schedule.trim()||null,execute_as:s.execute_as.trim()||null},{onSuccess:()=>i("/workflows/registry")})};if(p)return e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),e.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]});if(!o&&!a)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Config not found."});const V=!!s.workflow_type.trim()&&_(s.envelope_schema)&&_(s.input_schema)&&_(s.input_lookups)&&_(s.resolver_schema),X=o&&!s.workflow_type&&I.length>0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-light font-mono text-text-primary",children:o?"New Workflow":(a==null?void 0:a.workflow_type)??""}),a&&e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsx(Ne,{namespace:"durable"})})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[a&&e.jsxs("button",{onClick:()=>g(!0),className:"flex items-center gap-1.5 text-2xs text-status-warning hover:underline mr-3",title:"Delete this registration — the workflow returns to plain durable",children:[e.jsx(H,{className:"w-3 h-3",strokeWidth:1.5})," Unregister"]}),e.jsx("button",{onClick:()=>i("/workflows/registry"),className:"btn-ghost text-xs",children:"Cancel"}),e.jsx("button",{onClick:Y,disabled:!V||r.isPending,className:"btn-primary text-xs",children:r.isPending?"Saving…":o?"Register":"Save"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 @wall:grid-cols-3 gap-x-14 gap-y-10",children:[e.jsxs("div",{children:[e.jsx(q,{icon:ke,color:"text-accent",children:"Identity"}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(j,{label:"Workflow Type",hint:"Register a workflow to configure invocation and HITL escalation routing.",children:X?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-text-secondary",children:"Select a durable workflow to register:"}),e.jsx("div",{className:"grid gap-1",children:I.map(n=>e.jsx("button",{onClick:()=>w("workflow_type",n),className:"flex items-center gap-2 px-3 py-2 text-left text-xs font-mono rounded-md border border-surface-border hover:border-accent/50 hover:bg-accent/[0.04] transition-colors",children:n},n))}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("span",{className:"text-2xs text-text-tertiary",children:"or"}),e.jsx("input",{type:"text",onChange:n=>w("workflow_type",n.target.value),placeholder:"Enter type manually",className:"input font-mono flex-1"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:s.workflow_type,onChange:n=>w("workflow_type",n.target.value),disabled:!o,placeholder:"reviewContent",className:"input font-mono w-full"}),o&&s.workflow_type&&I.length>0&&e.jsx("button",{onClick:()=>w("workflow_type",""),className:"text-2xs text-accent hover:underline mt-1",children:"Choose from durable workflows"})]})}),e.jsx(j,{label:"Icon",hint:"Leads the workflow's row and heading on the Invoke Tool page so operators tell tools apart at a glance. Declared in code as WORKFLOW_ICONS.*",children:e.jsx(Oe,{value:s.icon,onChange:n=>w("icon",n)})}),e.jsx(j,{label:"Description",children:e.jsx("input",{type:"text",value:s.description,onChange:n=>w("description",n.target.value),placeholder:"Describe what this workflow does",className:"input text-xs w-full"})}),e.jsx(j,{label:"Task Queue",hint:"Durable task queue this workflow listens on.",children:e.jsx("input",{type:"text",value:s.task_queue,onChange:n=>w("task_queue",n.target.value),placeholder:"lt-review",className:"input font-mono w-full"})})]})]}),e.jsxs("div",{children:[e.jsx(q,{icon:z,color:"text-accent",children:"Invocation"}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.invocable,onChange:n=>w("invocable",n.target.checked),className:"w-4 h-4 rounded border-border accent-accent"}),e.jsx("span",{className:"text-xs text-text-primary font-medium",children:"Invocable"})]}),e.jsx("p",{className:"hint",children:"Allow this workflow to be started from the dashboard or API."})]}),s.invocable?e.jsxs(e.Fragment,{children:[e.jsx(j,{label:"Run As",hint:"Bot identity to run under. Default runs as the invoking user.",children:e.jsx(ye,{selected:s.execute_as,onChange:n=>w("execute_as",n)})}),e.jsx(j,{label:"Invocation Roles",hint:"Only users with these roles can start this workflow. Empty = all authenticated users.",children:e.jsx(Re,{selected:De(s.invocation_roles),onChange:n=>w("invocation_roles",Ee(n)),placeholder:"Select roles…"})}),e.jsxs(j,{label:"Input Form",hint:e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#docs:hitl/invoke-form.md"},className:"text-accent hover:underline",children:"Authoring reference →"}),children:[e.jsx("textarea",{value:s.input_schema,onChange:n=>w("input_schema",n.target.value),placeholder:`{
1
+ import{a as d,j as e}from"./vendor-query-DvWWuNIB.js";import{aE as Z,aJ as A,Y as ee,a as te,aK as se,aA as re,aB as oe,az as ne}from"./index-CU2UW2y6.js";import{F as ae,b as le,a as ie}from"./FilterBar-jtY6KNpL.js";import{C as Q}from"./ConfirmDeleteModal-BrlVktv2.js";import{R as L}from"./RolePill-D3hkAdKf.js";import{W as ce}from"./WorkflowPill-CKHip3hH.js";import{P as ue}from"./PageHeader-DiGWAQlR.js";import{Q as de,ay as F,aB as B,aF as me,k as z,aG as xe,aH as H,a5 as pe,U as J,X as he,C as fe,ad as we,aI as T,m as ke,E as ve}from"./vendor-icons-en0_uSRD.js";import{u as G,e as ge,f as je}from"./vendor-react-_9U4mKFr.js";import{B as ye}from"./BotPicker-BizdmeJp.js";import{N as Ne}from"./NamespacePill-CeSfHH-j.js";import{c as be,f as _e,R as Ce,g as Se,h as U}from"./ResolverForm-DibnlZ-A.js";import"./bots-bRkCqhlq.js";import"./RosterWidget-DZtmQcjU.js";import"./escalation-items-CwbNFnsH.js";import"./UserName-BK6Lzsdw.js";import"./validate-YJK_6a7m.js";import"./StatusBadge-DHVwxre2.js";import"./constants-CeBBTzf5.js";function Ie({tier:t}){return t==="certified"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-medium text-status-success",children:[e.jsx(B,{className:"w-3 h-3"}),"Certified"]}):t==="registered"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-medium text-text-secondary",children:[e.jsx(pe,{className:"w-3 h-3"}),"Registered"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-medium text-text-quaternary",children:[e.jsx(F,{className:"w-3 h-3"}),"Durable"]})}function rt(){const t=G(),{data:o,isLoading:i}=Z(),m=A(),[u,p]=d.useState(""),[r,k]=d.useState(null),[f,g]=d.useState(null),a=o??[],y=d.useMemo(()=>[...new Set(a.map(l=>l.task_queue).filter(Boolean))].sort(),[a]),c=d.useMemo(()=>{const l=u.toLowerCase().trim();return(r?[r]:y).map(h=>({queue:h,workflows:a.filter(S=>{var N;return S.task_queue===h&&(!l||S.workflow_type.toLowerCase().includes(l)||((N=S.description)==null?void 0:N.toLowerCase().includes(l)))})})).filter(h=>h.workflows.length>0)},[a,y,u,r]),x=d.useMemo(()=>{const l=u.toLowerCase().trim();return r?[]:a.filter(s=>{var h;return!s.task_queue&&(!l||s.workflow_type.toLowerCase().includes(l)||((h=s.description)==null?void 0:h.toLowerCase().includes(l)))})},[a,u,r]),C=l=>{l.registered?t(`/workflows/registry/${encodeURIComponent(l.workflow_type)}`):t(`/workflows/registry/new?workflow_type=${encodeURIComponent(l.workflow_type)}&task_queue=${encodeURIComponent(l.task_queue??"")}`)},I=()=>{f&&m.mutate(f,{onSuccess:()=>g(null)})};return e.jsxs("div",{children:[e.jsx(ue,{title:"Registered Workflows",docsHash:"#docs:dashboard.md:workflow-registry",actions:e.jsx("button",{onClick:()=>t("/workflows/registry/new"),className:"btn-primary text-xs",children:"Register Workflow"})}),!i&&y.length>0&&e.jsxs(ae,{children:[e.jsx(le,{label:"Queue",value:r??"",onChange:l=>k(l||null),options:y.map(l=>({value:l,label:l}))}),e.jsx(ie,{label:"Search",value:u,onChange:p,placeholder:`${a.length} workflows…`})]}),i?e.jsx(We,{}):c.length===0&&x.length===0?e.jsx("p",{className:"text-sm text-text-tertiary mt-8",children:u||r?"No workflows match your filter.":"No workflows discovered yet."}):e.jsxs("div",{className:"space-y-10",children:[c.map(({queue:l,workflows:s})=>e.jsxs("div",{children:[e.jsxs("div",{className:"sticky top-[60px] z-10 bg-surface flex items-center gap-2 py-2 mb-2 border-b border-surface-border",children:[e.jsx(de,{className:"w-3 h-3 text-accent",strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:l}),e.jsx("span",{className:"text-xs text-text-quaternary",children:s.length})]}),e.jsx($,{}),e.jsx("div",{className:"divide-y divide-surface-border/30",children:s.map(h=>e.jsx(M,{wf:h,onRowClick:C,onDelete:g,onNavigate:t},h.workflow_type))})]},l)),x.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"sticky top-[60px] z-10 bg-surface flex items-center gap-2 py-2 mb-2 border-b border-surface-border",children:[e.jsx(F,{className:"w-3 h-3 text-text-quaternary",strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:"No Queue"}),e.jsx("span",{className:"text-xs text-text-quaternary",children:x.length})]}),e.jsx($,{}),e.jsx("div",{className:"divide-y divide-surface-border/30",children:x.map(l=>e.jsx(M,{wf:l,onRowClick:C,onDelete:g,onNavigate:t},l.workflow_type))})]})]}),e.jsx(Q,{open:!!f,onClose:()=>g(null),onConfirm:I,title:"Unregister Workflow",description:e.jsxs(e.Fragment,{children:["Delete the registration for"," ",e.jsx("span",{className:"font-mono font-medium text-text-primary",children:f}),"? This removes its invocation settings, certification, and interceptor treatment; the workflow keeps running as a plain durable workflow. To demote certified → registered instead, open the workflow and uncheck Certify — that keeps every setting."]}),isPending:m.isPending,error:m.error})]})}const K="grid grid-cols-[minmax(0,1fr)_7rem_13rem_4.5rem] gap-x-6";function $(){return e.jsxs("div",{className:`${K} px-3 pb-2 pt-1`,children:[e.jsx("span",{className:"text-2xs font-medium text-text-quaternary",children:"Workflow"}),e.jsx("span",{className:"text-2xs font-medium text-text-quaternary",children:"Tier"}),e.jsx("span",{className:"text-2xs font-medium text-text-quaternary",children:"Access"}),e.jsx("span",{})]})}function M({wf:t,onRowClick:o,onDelete:i,onNavigate:m}){const u=t.roles??[],p=t.invocation_roles??[];return e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>o(t),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&o(t)},className:`group ${K} py-2 px-3 -mx-3 rounded-md cursor-pointer transition-colors items-center`,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ce,{type:t.workflow_type,size:"md",variant:t.tier==="certified"?"certified":t.tier==="registered"?"registered":"durable"}),t.description&&e.jsx("p",{className:"flex-1 min-w-0 truncate text-2xs text-text-tertiary group-hover:text-text-secondary transition-colors",children:t.description})]}),e.jsx("div",{children:e.jsx(Ie,{tier:t.tier??"durable"})}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden whitespace-nowrap",children:[u.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{title:"Escalation roles",children:e.jsx(B,{className:"w-3 h-3 text-text-quaternary shrink-0"})}),u.map(r=>e.jsx(L,{role:r},`e-${r}`))]}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{title:"Invocation roles",children:e.jsx(me,{className:"w-3 h-3 text-text-quaternary shrink-0"})}),p.map(r=>e.jsx(L,{role:r},`i-${r}`))]}),u.length===0&&p.length===0&&e.jsx("span",{className:"text-xs text-text-quaternary",children:"—"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[t.invocable&&e.jsx("button",{title:"Invoke workflow",onClick:r=>{r.stopPropagation(),m(`/workflows/start?type=${encodeURIComponent(t.workflow_type)}&mode=now`)},className:"text-text-quaternary hover:text-status-success transition-colors",children:e.jsx(z,{className:"w-3.5 h-3.5"})}),t.tier==="durable"&&e.jsx("button",{title:"Configure workflow",onClick:r=>{r.stopPropagation(),m(`/workflows/registry/new?workflow_type=${encodeURIComponent(t.workflow_type)}&task_queue=${encodeURIComponent(t.task_queue??"")}`)},className:"text-text-quaternary hover:text-status-info transition-colors",children:e.jsx(F,{className:"w-3.5 h-3.5"})}),t.tier==="registered"&&e.jsx("button",{title:"Certify workflow",onClick:r=>{r.stopPropagation(),m(`/workflows/registry/${encodeURIComponent(t.workflow_type)}`)},className:"text-text-quaternary hover:text-status-success transition-colors",children:e.jsx(xe,{className:"w-3.5 h-3.5"})}),t.registered&&e.jsx("button",{title:"Unregister workflow",onClick:r=>{r.stopPropagation(),i(t.workflow_type)},className:"text-text-quaternary hover:text-status-warning transition-colors",children:e.jsx(H,{className:"w-3.5 h-3.5"})})]})]})}function We(){return e.jsx("div",{className:"animate-pulse space-y-8 mt-4",children:[1,2].map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"h-4 bg-surface-sunken rounded w-36 mb-4"}),e.jsx("div",{className:"space-y-4",children:[1,2,3].map(o=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"}),e.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]},o))})]},t))})}function Re({selected:t,onChange:o,single:i,placeholder:m}){const{data:u}=ee(),p=(u==null?void 0:u.roles)??[],[r,k]=d.useState(!1),f=d.useRef(null);d.useEffect(()=>{const c=x=>{f.current&&!f.current.contains(x.target)&&k(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]);const g=c=>{i?(o(t.includes(c)?[]:[c]),k(!1)):o(t.includes(c)?t.filter(x=>x!==c):[...t,c])},a=c=>{o(t.filter(x=>x!==c))},y=m??(i?"Select role...":"Add roles...");return e.jsxs("div",{ref:f,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>k(!r),className:"flex flex-wrap items-center gap-1.5 w-full min-h-[34px] px-2 py-1.5 bg-surface-sunken border border-surface-border rounded-md text-left cursor-pointer hover:border-accent/40 transition-colors focus:ring-1 focus:ring-accent focus:outline-none",children:[t.length===0&&e.jsx("span",{className:"text-xs text-text-tertiary",children:y}),t.map(c=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-lg bg-accent/[0.08] text-text-secondary text-2xs",children:[e.jsx(J,{className:"w-2.5 h-2.5 shrink-0 text-accent/75"}),c,e.jsx("span",{role:"button",onClick:x=>{x.stopPropagation(),a(c)},className:"ml-0.5 hover:text-status-error transition-colors",children:e.jsx(he,{className:"w-2.5 h-2.5"})})]},c)),e.jsx(fe,{className:`w-3.5 h-3.5 ml-auto shrink-0 text-text-tertiary transition-transform ${r?"rotate-180":""}`})]}),r&&e.jsx("div",{className:"absolute z-[100] mt-1 w-full bg-surface-raised border border-surface-border rounded-md shadow-lg max-h-48 overflow-y-auto",children:p.length===0?e.jsx("p",{className:"px-3 py-2 text-xs text-text-tertiary",children:"No roles defined"}):p.map(c=>{const x=t.includes(c);return e.jsxs("button",{type:"button",onClick:()=>g(c),className:`flex items-center gap-2 w-full px-3 py-1.5 text-left text-xs transition-colors ${x?"bg-accent/[0.06] text-accent":"text-text-primary hover:bg-surface-sunken"}`,children:[e.jsx(J,{className:"w-3 h-3 shrink-0 text-accent/60"}),e.jsx("span",{className:"flex-1",children:c}),x&&e.jsx(we,{className:"w-3 h-3 shrink-0"})]},c)})})]})}function W(t){return t.split(",").map(o=>o.trim()).filter(Boolean)}const R={workflow_type:"",description:"",task_queue:"",default_role:"reviewer",invocable:!1,roles:"",invocation_roles:"",consumes:"",envelope_schema:"",input_schema:"",input_lookups:"",icon:"",resolver_schema:"",cron_schedule:"",execute_as:"",certified:!1};function qe(t){var m;const o=(t.roles??[]).join(", "),i=(t.consumes??[]).join(", ");return{workflow_type:t.workflow_type,description:t.description??"",task_queue:t.task_queue??"",default_role:t.default_role,invocable:t.invocable,roles:o,invocation_roles:(t.invocation_roles??[]).join(", "),consumes:i,envelope_schema:t.envelope_schema?JSON.stringify(t.envelope_schema,null,2):"",input_schema:t.input_schema?JSON.stringify(t.input_schema,null,2):"",input_lookups:(m=t.input_lookups)!=null&&m.length?JSON.stringify(t.input_lookups,null,2):"",icon:t.icon??"",resolver_schema:t.resolver_schema?JSON.stringify(t.resolver_schema,null,2):"",cron_schedule:t.cron_schedule??"",execute_as:t.execute_as??"",certified:t.certified}}function _(t){if(!t.trim())return!0;try{return JSON.parse(t),!0}catch{return!1}}function Pe(t){if(!t.trim())return null;try{const o=JSON.parse(t);return o&&typeof o=="object"&&!Array.isArray(o)&&o.properties?o:null}catch{return null}}function Fe({schemaText:t,lookup:o}){const i=d.useMemo(()=>Pe(t),[t]),m=d.useMemo(()=>i?be(i):"",[i]),[u,p]=d.useState(m);d.useEffect(()=>{p(m)},[m]);const r=d.useMemo(()=>({..._e({},o),resolver:null}),[o]);return i?e.jsx("div",{className:"@container","data-testid":"input-form-preview",children:e.jsx(Ce,{value:u,onChange:p,escalationContext:r})}):e.jsxs("p",{className:"text-2xs text-text-tertiary",children:["A schema with ",e.jsx("code",{className:"font-mono",children:"properties"})," previews here as the operator's form."]})}function Oe({value:t,onChange:o}){const[i,m]=d.useState(""),u=d.useMemo(()=>Se(i),[i]),p=U(t);return e.jsxs("div",{className:"space-y-2","data-testid":"workflow-icon-picker",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:i,onChange:r=>m(r.target.value),placeholder:"Filter icons…","aria-label":"Filter icons",className:"input text-2xs py-1 w-40"}),e.jsxs("span",{className:"flex items-center gap-1.5 text-2xs text-text-tertiary min-w-0",children:[p?e.jsx(p,{className:"w-3.5 h-3.5 text-accent shrink-0",strokeWidth:1.5}):e.jsx(T,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"font-mono truncate",children:t||"tier glyph"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",role:"listbox","aria-label":"Workflow icon",children:[e.jsx("button",{type:"button",role:"option","aria-selected":!t,title:"No icon (tier glyph)",onClick:()=>o(""),className:`p-1.5 rounded-md border transition-colors ${t?"border-transparent text-text-quaternary hover:bg-surface-hover hover:text-text-secondary":"border-accent bg-accent/10 text-accent"}`,children:e.jsx(T,{className:"w-4 h-4",strokeWidth:1.5})}),u.map(r=>{const k=U(r),f=t===r;return e.jsx("button",{type:"button",role:"option","aria-selected":f,title:r,onClick:()=>o(r),className:`p-1.5 rounded-md border transition-colors ${f?"border-accent bg-accent/10 text-accent":"border-transparent text-text-tertiary hover:bg-surface-hover hover:text-text-primary"}`,children:e.jsx(k,{className:"w-4 h-4",strokeWidth:1.5})},r)}),u.length===0&&e.jsx("p",{className:"text-2xs text-text-tertiary px-1 py-1.5",children:"No icon matches."})]})]})}function q({icon:t,color:o,children:i}){return e.jsxs("div",{className:"flex items-center gap-2 mb-4 pb-2 border-b border-surface-border",children:[e.jsx(t,{className:`w-4 h-4 ${o}`,strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:i})]})}function j({label:t,hint:o,children:i}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"label",children:t}),i,o&&e.jsx("p",{className:"hint",children:o})]})}const P="input-json w-full";function Ee(t){return W(t)}function De(t){return t.join(", ")}const Le=new Set(["mcpQuery","mcpDeterministic","mcpQueryRouter","mcpTriage","mcpTriageRouter","mcpTriageDeterministic","insightQuery"]);function ot(){const{workflowType:t}=ge(),o=!t,i=G(),[m]=je(),{data:u,isLoading:p}=te(),r=se(),k=A(),[f,g]=d.useState(!1),a=(u==null?void 0:u.find(n=>n.workflow_type===t))??null,y=Array.isArray(a==null?void 0:a.input_lookups)&&a.input_lookups.length>0,{data:c}=re((a==null?void 0:a.workflow_type)??"",y),x=d.useMemo(()=>c?oe(c.lookups):void 0,[c]),{data:C}=ne({limit:500}),I=d.useMemo(()=>{const n=new Set((u??[]).map(v=>v.workflow_type));return[...new Set(((C==null?void 0:C.jobs)??[]).map(v=>v.entity))].filter(v=>!n.has(v)&&!Le.has(v)).sort()},[u,C]),l=d.useMemo(()=>{if(!o)return R;const n=m.get("workflow_type")??"",b=m.get("task_queue")??"";return n||b?{...R,workflow_type:n,task_queue:b}:R},[o,m]),[s,h]=d.useState(l),[S,N]=d.useState(""),[O,E]=d.useState(!1),w=d.useCallback((n,b)=>h(v=>({...v,[n]:b})),[]);d.useEffect(()=>{if(!O){if(o){h(l),E(!0);return}a&&(h(qe(a)),E(!0))}},[a,o,O,l]);const Y=()=>{if(!s.workflow_type.trim())return;N("");let n=null,b=null,v=null,D=null;try{s.envelope_schema.trim()&&(n=JSON.parse(s.envelope_schema))}catch{N("Invalid JSON in Envelope Schema");return}try{s.input_schema.trim()&&(b=JSON.parse(s.input_schema))}catch{N("Invalid JSON in Input Form");return}try{s.input_lookups.trim()&&(v=JSON.parse(s.input_lookups))}catch{N("Invalid JSON in Lookups");return}try{s.resolver_schema.trim()&&(D=JSON.parse(s.resolver_schema))}catch{N("Invalid JSON in Resolver Schema");return}r.mutate({workflow_type:s.workflow_type.trim(),description:s.description.trim()||null,task_queue:s.task_queue.trim()||null,default_role:s.default_role.trim()||"reviewer",invocable:s.invocable,certified:s.certified,roles:W(s.roles),invocation_roles:W(s.invocation_roles),consumes:W(s.consumes),envelope_schema:n,input_schema:b,input_lookups:v,icon:s.icon||null,resolver_schema:D,cron_schedule:s.cron_schedule.trim()||null,execute_as:s.execute_as.trim()||null},{onSuccess:()=>i("/workflows/registry")})};if(p)return e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),e.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]});if(!o&&!a)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Config not found."});const V=!!s.workflow_type.trim()&&_(s.envelope_schema)&&_(s.input_schema)&&_(s.input_lookups)&&_(s.resolver_schema),X=o&&!s.workflow_type&&I.length>0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-light font-mono text-text-primary",children:o?"New Workflow":(a==null?void 0:a.workflow_type)??""}),a&&e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsx(Ne,{namespace:"durable"})})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[a&&e.jsxs("button",{onClick:()=>g(!0),className:"flex items-center gap-1.5 text-2xs text-status-warning hover:underline mr-3",title:"Delete this registration — the workflow returns to plain durable",children:[e.jsx(H,{className:"w-3 h-3",strokeWidth:1.5})," Unregister"]}),e.jsx("button",{onClick:()=>i("/workflows/registry"),className:"btn-ghost text-xs",children:"Cancel"}),e.jsx("button",{onClick:Y,disabled:!V||r.isPending,className:"btn-primary text-xs",children:r.isPending?"Saving…":o?"Register":"Save"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 @wall:grid-cols-3 gap-x-14 gap-y-10",children:[e.jsxs("div",{children:[e.jsx(q,{icon:ke,color:"text-accent",children:"Identity"}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(j,{label:"Workflow Type",hint:"Register a workflow to configure invocation and HITL escalation routing.",children:X?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-text-secondary",children:"Select a durable workflow to register:"}),e.jsx("div",{className:"grid gap-1",children:I.map(n=>e.jsx("button",{onClick:()=>w("workflow_type",n),className:"flex items-center gap-2 px-3 py-2 text-left text-xs font-mono rounded-md border border-surface-border hover:border-accent/50 hover:bg-accent/[0.04] transition-colors",children:n},n))}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("span",{className:"text-2xs text-text-tertiary",children:"or"}),e.jsx("input",{type:"text",onChange:n=>w("workflow_type",n.target.value),placeholder:"Enter type manually",className:"input font-mono flex-1"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:s.workflow_type,onChange:n=>w("workflow_type",n.target.value),disabled:!o,placeholder:"reviewContent",className:"input font-mono w-full"}),o&&s.workflow_type&&I.length>0&&e.jsx("button",{onClick:()=>w("workflow_type",""),className:"text-2xs text-accent hover:underline mt-1",children:"Choose from durable workflows"})]})}),e.jsx(j,{label:"Icon",hint:"Leads the workflow's row and heading on the Invoke Tool page so operators tell tools apart at a glance. Declared in code as WORKFLOW_ICONS.*",children:e.jsx(Oe,{value:s.icon,onChange:n=>w("icon",n)})}),e.jsx(j,{label:"Description",children:e.jsx("input",{type:"text",value:s.description,onChange:n=>w("description",n.target.value),placeholder:"Describe what this workflow does",className:"input text-xs w-full"})}),e.jsx(j,{label:"Task Queue",hint:"Durable task queue this workflow listens on.",children:e.jsx("input",{type:"text",value:s.task_queue,onChange:n=>w("task_queue",n.target.value),placeholder:"lt-review",className:"input font-mono w-full"})})]})]}),e.jsxs("div",{children:[e.jsx(q,{icon:z,color:"text-accent",children:"Invocation"}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.invocable,onChange:n=>w("invocable",n.target.checked),className:"w-4 h-4 rounded border-border accent-accent"}),e.jsx("span",{className:"text-xs text-text-primary font-medium",children:"Invocable"})]}),e.jsx("p",{className:"hint",children:"Allow this workflow to be started from the dashboard or API."})]}),s.invocable?e.jsxs(e.Fragment,{children:[e.jsx(j,{label:"Run As",hint:"Bot identity to run under. Default runs as the invoking user.",children:e.jsx(ye,{selected:s.execute_as,onChange:n=>w("execute_as",n)})}),e.jsx(j,{label:"Invocation Roles",hint:"Only users with these roles can start this workflow. Empty = all authenticated users.",children:e.jsx(Re,{selected:Ee(s.invocation_roles),onChange:n=>w("invocation_roles",De(n)),placeholder:"Select roles…"})}),e.jsxs(j,{label:"Input Form",hint:e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#docs:hitl/invoke-form.md"},className:"text-accent hover:underline",children:"Authoring reference →"}),children:[e.jsx("textarea",{value:s.input_schema,onChange:n=>w("input_schema",n.target.value),placeholder:`{
2
2
  "x-lt-layout": "two-column",
3
3
  "required": ["serialNumber"],
4
4
  "properties": {
@@ -10,4 +10,4 @@ import{a as d,j as e}from"./vendor-query-DvWWuNIB.js";import{aD as Z,aI as A,Y a
10
10
  "data": {},
11
11
  "metadata": {}
12
12
  }`,className:P,rows:8,spellCheck:!1}),s.envelope_schema.trim()&&!_(s.envelope_schema)&&e.jsx("p",{className:"text-2xs text-status-error mt-1",children:"Invalid JSON"})]})]}):e.jsxs("p",{className:"text-2xs text-text-tertiary py-2",children:["Enable ",e.jsx("span",{className:"font-medium text-text-secondary",children:"Invocable"})," to configure invocation roles and an input template."]})]})]}),e.jsxs("div",{className:"@wall:sticky @wall:top-0 self-start max-h-[calc(100vh-6rem)] overflow-y-auto",children:[e.jsx(q,{icon:ve,color:"text-accent",children:"Preview"}),s.invocable&&s.input_schema.trim()&&_(s.input_schema)?e.jsx(Fe,{schemaText:s.input_schema,lookup:x}):e.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed",children:s.invocable?"Declare an Input Form and it previews here as the operator's form, live as you type.":"Enable Invocable and declare an Input Form to preview the operator's form here."})]})]}),(S||r.error)&&e.jsx("p",{className:"text-xs text-status-error mt-8",children:S||r.error.message}),e.jsx(Q,{open:f,onClose:()=>g(!1),onConfirm:()=>k.mutate(a.workflow_type,{onSuccess:()=>i("/workflows/registry")}),title:"Unregister Workflow",description:e.jsxs(e.Fragment,{children:["Delete the registration for"," ",e.jsx("span",{className:"font-mono font-medium text-text-primary",children:a==null?void 0:a.workflow_type}),"? This removes its invocation settings, certification, and interceptor treatment; the workflow keeps running as a plain durable workflow. Escalation schemas versioned on roles are untouched."]}),isPending:k.isPending,error:k.error})]})}export{ot as WorkflowConfigDetailPage,rt as WorkflowConfigsPage};
13
- //# sourceMappingURL=index-boT612Jo.js.map
13
+ //# sourceMappingURL=index-E_hJ7vtX.js.map