@hotmeshio/long-tail 0.20.0 → 0.21.0

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 (351) hide show
  1. package/README.md +4 -4
  2. package/build/api/escalations/accumulate.d.ts +96 -0
  3. package/build/api/escalations/accumulate.js +516 -0
  4. package/build/api/escalations/index.d.ts +1 -0
  5. package/build/api/escalations/index.js +10 -1
  6. package/build/api/roles.d.ts +4 -5
  7. package/build/api/roles.js +53 -4
  8. package/build/api/scan-codes/execute.js +2 -0
  9. package/build/api/scan-codes/verbs.d.ts +15 -0
  10. package/build/api/scan-codes/verbs.js +65 -0
  11. package/build/index.js +60 -0
  12. package/build/lib/db/schemas/036_role_portals.sql +12 -0
  13. package/build/routes/escalations/accumulate.d.ts +7 -0
  14. package/build/routes/escalations/accumulate.js +150 -0
  15. package/build/routes/escalations/index.js +5 -0
  16. package/build/sdk/index.d.ts +25 -0
  17. package/build/sdk/index.js +8 -0
  18. package/build/services/escalation/accumulate.d.ts +81 -0
  19. package/build/services/escalation/accumulate.js +154 -0
  20. package/build/services/escalation/index.d.ts +1 -0
  21. package/build/services/escalation/index.js +1 -0
  22. package/build/services/mcp/playwright-server/schemas.d.ts +2 -2
  23. package/build/services/orchestrator/condition.d.ts +40 -3
  24. package/build/services/orchestrator/condition.js +42 -2
  25. package/build/services/role/index.js +1 -0
  26. package/build/services/role/seed.js +6 -1
  27. package/build/services/role/sql.d.ts +6 -3
  28. package/build/services/role/sql.js +7 -2
  29. package/build/services/role/types.d.ts +38 -10
  30. package/build/services/role/types.js +10 -1
  31. package/build/services/scan-code/validate.js +16 -0
  32. package/build/shared/form-validation/display-only-widgets.d.ts +16 -0
  33. package/build/shared/form-validation/display-only-widgets.js +25 -0
  34. package/build/shared/form-validation/index.d.ts +2 -0
  35. package/build/shared/form-validation/index.js +2 -0
  36. package/build/shared/form-validation/x-lt-bind.d.ts +2 -14
  37. package/build/shared/form-validation/x-lt-bind.js +12 -8
  38. package/build/shared/form-validation/x-lt-invoke.d.ts +38 -0
  39. package/build/shared/form-validation/x-lt-invoke.js +103 -0
  40. package/build/system/mcp-servers/admin/escalations.js +39 -0
  41. package/build/system/mcp-servers/admin/schemas.d.ts +192 -13
  42. package/build/system/mcp-servers/admin/schemas.js +39 -3
  43. package/build/system/mcp-servers/admin/users.js +1 -0
  44. package/build/system/mcp-servers/docs.js +4 -0
  45. package/build/system/mcp-servers/human-queue-schemas.d.ts +85 -0
  46. package/build/system/mcp-servers/human-queue-schemas.js +19 -1
  47. package/build/system/mcp-servers/human-queue.d.ts +2 -0
  48. package/build/system/mcp-servers/human-queue.js +77 -0
  49. package/build/system/seed/tool-manifests-admin.d.ts +922 -103
  50. package/build/system/seed/tool-manifests-admin.js +4 -1
  51. package/build/system/seed/tool-manifests-escalation.d.ts +174 -0
  52. package/build/system/seed/tool-manifests-escalation.js +56 -0
  53. package/build/tsconfig.tsbuildinfo +1 -1
  54. package/build/types/escalation.d.ts +52 -0
  55. package/build/types/escalation.js +29 -1
  56. package/build/types/index.d.ts +2 -2
  57. package/build/types/index.js +3 -1
  58. package/build/types/scan-code.d.ts +24 -0
  59. package/build/types/scan-code.js +9 -0
  60. package/build/types/startup.d.ts +20 -0
  61. package/dashboard/dist/assets/{AdminDashboard-DplvDBti.js → AdminDashboard-uarpHB88.js} +2 -2
  62. package/dashboard/dist/assets/{AdminDashboard-DplvDBti.js.map → AdminDashboard-uarpHB88.js.map} +1 -1
  63. package/dashboard/dist/assets/{AgentConfigPage-D8Bf6YxO.js → AgentConfigPage-BcUaDD5E.js} +6 -6
  64. package/dashboard/dist/assets/{AgentConfigPage-D8Bf6YxO.js.map → AgentConfigPage-BcUaDD5E.js.map} +1 -1
  65. package/dashboard/dist/assets/{AgentDetailPage-BN8g0Y2G.js → AgentDetailPage-BaZBhK6i.js} +3 -3
  66. package/dashboard/dist/assets/{AgentDetailPage-BN8g0Y2G.js.map → AgentDetailPage-BaZBhK6i.js.map} +1 -1
  67. package/dashboard/dist/assets/AgentsPage-CuVFSDc4.js +2 -0
  68. package/dashboard/dist/assets/{AgentsPage-7JJBHku8.js.map → AgentsPage-CuVFSDc4.js.map} +1 -1
  69. package/dashboard/dist/assets/AvailableEscalationsPage-iO5NyyIK.js +2 -0
  70. package/dashboard/dist/assets/AvailableEscalationsPage-iO5NyyIK.js.map +1 -0
  71. package/dashboard/dist/assets/{BotPicker-CGCnIz8I.js → BotPicker-CClMby6B.js} +2 -2
  72. package/dashboard/dist/assets/{BotPicker-CGCnIz8I.js.map → BotPicker-CClMby6B.js.map} +1 -1
  73. package/dashboard/dist/assets/BulkAssignModal-BL8FRgkN.js +2 -0
  74. package/dashboard/dist/assets/{BulkAssignModal-NJBcoj-f.js.map → BulkAssignModal-BL8FRgkN.js.map} +1 -1
  75. package/dashboard/dist/assets/CapabilitiesPage-D53ogPor.js +2 -0
  76. package/dashboard/dist/assets/{CapabilitiesPage-F8dpNn9B.js.map → CapabilitiesPage-D53ogPor.js.map} +1 -1
  77. package/dashboard/dist/assets/{CollapsibleSection-BZW6VpCU.js → CollapsibleSection-ow8jpbtD.js} +2 -2
  78. package/dashboard/dist/assets/{CollapsibleSection-BZW6VpCU.js.map → CollapsibleSection-ow8jpbtD.js.map} +1 -1
  79. package/dashboard/dist/assets/{ConfirmDeleteModal-64adXLdq.js → ConfirmDeleteModal-CeEDt9iJ.js} +2 -2
  80. package/dashboard/dist/assets/{ConfirmDeleteModal-64adXLdq.js.map → ConfirmDeleteModal-CeEDt9iJ.js.map} +1 -1
  81. package/dashboard/dist/assets/{CountdownTimer-BxDub9d2.js → CountdownTimer-CSqyZMCG.js} +2 -2
  82. package/dashboard/dist/assets/{CountdownTimer-BxDub9d2.js.map → CountdownTimer-CSqyZMCG.js.map} +1 -1
  83. package/dashboard/dist/assets/{CredentialsPage-CnLzopLL.js → CredentialsPage-Dx7SxA23.js} +2 -2
  84. package/dashboard/dist/assets/{CredentialsPage-CnLzopLL.js.map → CredentialsPage-Dx7SxA23.js.map} +1 -1
  85. package/dashboard/dist/assets/{CronLabel-CAD5UYDT.js → CronLabel-LYPxpvNN.js} +2 -2
  86. package/dashboard/dist/assets/{CronLabel-CAD5UYDT.js.map → CronLabel-LYPxpvNN.js.map} +1 -1
  87. package/dashboard/dist/assets/DataTable-spX1dFyb.js +2 -0
  88. package/dashboard/dist/assets/DataTable-spX1dFyb.js.map +1 -0
  89. package/dashboard/dist/assets/{DropZone-XlcY8hEH.js → DropZone-f1o-GLM8.js} +2 -2
  90. package/dashboard/dist/assets/{DropZone-XlcY8hEH.js.map → DropZone-f1o-GLM8.js.map} +1 -1
  91. package/dashboard/dist/assets/{ElapsedCell-CwO4ufd0.js → ElapsedCell-BZJTSm9N.js} +2 -2
  92. package/dashboard/dist/assets/{ElapsedCell-CwO4ufd0.js.map → ElapsedCell-BZJTSm9N.js.map} +1 -1
  93. package/dashboard/dist/assets/EntityTimelinePanel-0wIIW2en.js +2 -0
  94. package/dashboard/dist/assets/{EntityTimelinePanel-CkF-oW-m.js.map → EntityTimelinePanel-0wIIW2en.js.map} +1 -1
  95. package/dashboard/dist/assets/{EscalationListSchemaPage-h9JO_q5f.js → EscalationListSchemaPage-CoYvtMzj.js} +3 -3
  96. package/dashboard/dist/assets/{EscalationListSchemaPage-h9JO_q5f.js.map → EscalationListSchemaPage-CoYvtMzj.js.map} +1 -1
  97. package/dashboard/dist/assets/EscalationListView-DWFHPufv.js +2 -0
  98. package/dashboard/dist/assets/EscalationListView-DWFHPufv.js.map +1 -0
  99. package/dashboard/dist/assets/{EscalationSchemaPage-mJFL5_Se.js → EscalationSchemaPage-C9Xu_A25.js} +3 -3
  100. package/dashboard/dist/assets/{EscalationSchemaPage-mJFL5_Se.js.map → EscalationSchemaPage-C9Xu_A25.js.map} +1 -1
  101. package/dashboard/dist/assets/EscalationTimeline-D8W2LNNk.js +2 -0
  102. package/dashboard/dist/assets/EscalationTimeline-D8W2LNNk.js.map +1 -0
  103. package/dashboard/dist/assets/EscalationTitleSelect-DLK8NWMp.js +2 -0
  104. package/dashboard/dist/assets/EscalationTitleSelect-DLK8NWMp.js.map +1 -0
  105. package/dashboard/dist/assets/{EscalationsOverview-DlXUFqWJ.js → EscalationsOverview-CW57FaP9.js} +2 -2
  106. package/dashboard/dist/assets/{EscalationsOverview-DlXUFqWJ.js.map → EscalationsOverview-CW57FaP9.js.map} +1 -1
  107. package/dashboard/dist/assets/{EventTable-Ike2xchn.js → EventTable-D1ctWhKf.js} +2 -2
  108. package/dashboard/dist/assets/{EventTable-Ike2xchn.js.map → EventTable-D1ctWhKf.js.map} +1 -1
  109. package/dashboard/dist/assets/{FilterBar-DMOR-O1c.js → FilterBar-C-iur-Nj.js} +2 -2
  110. package/dashboard/dist/assets/{FilterBar-DMOR-O1c.js.map → FilterBar-C-iur-Nj.js.map} +1 -1
  111. package/dashboard/dist/assets/GraphInvokePage-CcA_44M4.js +2 -0
  112. package/dashboard/dist/assets/{GraphInvokePage-CKtvWowP.js.map → GraphInvokePage-CcA_44M4.js.map} +1 -1
  113. package/dashboard/dist/assets/HomePage-Dc085ghJ.js +2 -0
  114. package/dashboard/dist/assets/{HomePage-BQ3Q791Q.js.map → HomePage-Dc085ghJ.js.map} +1 -1
  115. package/dashboard/dist/assets/ListToolbar-h_ziBt4O.js +2 -0
  116. package/dashboard/dist/assets/{ListToolbar-DdJzj472.js.map → ListToolbar-h_ziBt4O.js.map} +1 -1
  117. package/dashboard/dist/assets/{McpOverview-BbtrduWn.js → McpOverview-qXXhbNWV.js} +2 -2
  118. package/dashboard/dist/assets/{McpOverview-BbtrduWn.js.map → McpOverview-qXXhbNWV.js.map} +1 -1
  119. package/dashboard/dist/assets/{McpQueryDetailPage-C1L4T-Wt.js → McpQueryDetailPage-SEzSbZrd.js} +2 -2
  120. package/dashboard/dist/assets/{McpQueryDetailPage-C1L4T-Wt.js.map → McpQueryDetailPage-SEzSbZrd.js.map} +1 -1
  121. package/dashboard/dist/assets/McpQueryPage-Cy0V0kv9.js +2 -0
  122. package/dashboard/dist/assets/{McpQueryPage-CfJy7HZ7.js.map → McpQueryPage-Cy0V0kv9.js.map} +1 -1
  123. package/dashboard/dist/assets/{McpRunDetailPage-CA9yv7he.js → McpRunDetailPage-DjJO5vSb.js} +2 -2
  124. package/dashboard/dist/assets/{McpRunDetailPage-CA9yv7he.js.map → McpRunDetailPage-DjJO5vSb.js.map} +1 -1
  125. package/dashboard/dist/assets/McpRunsPage-BfjiJ8mM.js +2 -0
  126. package/dashboard/dist/assets/{McpRunsPage-D7QXjW9z.js.map → McpRunsPage-BfjiJ8mM.js.map} +1 -1
  127. package/dashboard/dist/assets/{NamespacePill-Bb3revqD.js → NamespacePill-DADRJOUl.js} +2 -2
  128. package/dashboard/dist/assets/{NamespacePill-Bb3revqD.js.map → NamespacePill-DADRJOUl.js.map} +1 -1
  129. package/dashboard/dist/assets/OperationsPage-dJcER0T_.js +3 -0
  130. package/dashboard/dist/assets/OperationsPage-dJcER0T_.js.map +1 -0
  131. package/dashboard/dist/assets/OperatorDashboard-zCkW4eqk.js +2 -0
  132. package/dashboard/dist/assets/{OperatorDashboard-sXNDh1Ph.js.map → OperatorDashboard-zCkW4eqk.js.map} +1 -1
  133. package/dashboard/dist/assets/{PageHeader-Di5Sz3an.js → PageHeader-Csq434-v.js} +2 -2
  134. package/dashboard/dist/assets/{PageHeader-Di5Sz3an.js.map → PageHeader-Csq434-v.js.map} +1 -1
  135. package/dashboard/dist/assets/{PageHeaderWithStats-DutKJ-h2.js → PageHeaderWithStats-CSnk1p5A.js} +2 -2
  136. package/dashboard/dist/assets/{PageHeaderWithStats-DutKJ-h2.js.map → PageHeaderWithStats-CSnk1p5A.js.map} +1 -1
  137. package/dashboard/dist/assets/{PersonaDetailPage-NeHD-Gra.js → PersonaDetailPage-Cx6L3Jvu.js} +2 -2
  138. package/dashboard/dist/assets/{PersonaDetailPage-NeHD-Gra.js.map → PersonaDetailPage-Cx6L3Jvu.js.map} +1 -1
  139. package/dashboard/dist/assets/{PersonasPage-DavKXRWX.js → PersonasPage-DOgGUlJl.js} +2 -2
  140. package/dashboard/dist/assets/{PersonasPage-DavKXRWX.js.map → PersonasPage-DOgGUlJl.js.map} +1 -1
  141. package/dashboard/dist/assets/PortalPage-BKuL1BeJ.js +2 -0
  142. package/dashboard/dist/assets/PortalPage-BKuL1BeJ.js.map +1 -0
  143. package/dashboard/dist/assets/{ProcessDetailPage-DkdKJGe6.js → ProcessDetailPage-BFcFSDUv.js} +2 -2
  144. package/dashboard/dist/assets/{ProcessDetailPage-DkdKJGe6.js.map → ProcessDetailPage-BFcFSDUv.js.map} +1 -1
  145. package/dashboard/dist/assets/ProcessesListPage-BaHV2cXp.js +2 -0
  146. package/dashboard/dist/assets/{ProcessesListPage-CjwVKe32.js.map → ProcessesListPage-BaHV2cXp.js.map} +1 -1
  147. package/dashboard/dist/assets/ResolverForm-Bgc0Zrya.js +7 -0
  148. package/dashboard/dist/assets/ResolverForm-Bgc0Zrya.js.map +1 -0
  149. package/dashboard/dist/assets/RoleDetailPage-BPY6i3CU.js +8 -0
  150. package/dashboard/dist/assets/RoleDetailPage-BPY6i3CU.js.map +1 -0
  151. package/dashboard/dist/assets/{RolePill-DhnVPK4q.js → RolePill-BafrASDX.js} +2 -2
  152. package/dashboard/dist/assets/{RolePill-DhnVPK4q.js.map → RolePill-BafrASDX.js.map} +1 -1
  153. package/dashboard/dist/assets/{RolesPage-OM9KM8Pg.js → RolesPage-DSqqKPbv.js} +2 -2
  154. package/dashboard/dist/assets/{RolesPage-OM9KM8Pg.js.map → RolesPage-DSqqKPbv.js.map} +1 -1
  155. package/dashboard/dist/assets/RunAsSelector-B29iWwel.js +2 -0
  156. package/dashboard/dist/assets/{RunAsSelector-fFMt1bGe.js.map → RunAsSelector-B29iWwel.js.map} +1 -1
  157. package/dashboard/dist/assets/{ScanCodesPage-AujH-pPQ.js → ScanCodesPage-S8aAJfnC.js} +2 -2
  158. package/dashboard/dist/assets/{ScanCodesPage-AujH-pPQ.js.map → ScanCodesPage-S8aAJfnC.js.map} +1 -1
  159. package/dashboard/dist/assets/{ScanSchemeDetailPage-eKQpmsC_.js → ScanSchemeDetailPage-CUBRAtmJ.js} +2 -2
  160. package/dashboard/dist/assets/{ScanSchemeDetailPage-eKQpmsC_.js.map → ScanSchemeDetailPage-CUBRAtmJ.js.map} +1 -1
  161. package/dashboard/dist/assets/ScanStationPage-R9t1-CeQ.js +2 -0
  162. package/dashboard/dist/assets/{ScanStationPage-C1_ppDoZ.js.map → ScanStationPage-R9t1-CeQ.js.map} +1 -1
  163. package/dashboard/dist/assets/{ScopeBadge-CXUg0FHo.js → ScopeBadge-b6MIBiYD.js} +2 -2
  164. package/dashboard/dist/assets/{ScopeBadge-CXUg0FHo.js.map → ScopeBadge-b6MIBiYD.js.map} +1 -1
  165. package/dashboard/dist/assets/{StickyPagination-B91Pk9xh.js → StickyPagination-CkW_A507.js} +2 -2
  166. package/dashboard/dist/assets/{StickyPagination-B91Pk9xh.js.map → StickyPagination-CkW_A507.js.map} +1 -1
  167. package/dashboard/dist/assets/{StreamMessageDetail-C7SPqaJt.js → StreamMessageDetail-yzWX0wac.js} +2 -2
  168. package/dashboard/dist/assets/{StreamMessageDetail-C7SPqaJt.js.map → StreamMessageDetail-yzWX0wac.js.map} +1 -1
  169. package/dashboard/dist/assets/{SwimlaneTimeline-BcHR8ylf.js → SwimlaneTimeline-Cf4DXFxj.js} +2 -2
  170. package/dashboard/dist/assets/{SwimlaneTimeline-BcHR8ylf.js.map → SwimlaneTimeline-Cf4DXFxj.js.map} +1 -1
  171. package/dashboard/dist/assets/{TagInput-BZ8vb2oW.js → TagInput-ZrIIrEUP.js} +2 -2
  172. package/dashboard/dist/assets/{TagInput-BZ8vb2oW.js.map → TagInput-ZrIIrEUP.js.map} +1 -1
  173. package/dashboard/dist/assets/{TaskDetailPage-Bqj0I_I0.js → TaskDetailPage-DCDcEps9.js} +2 -2
  174. package/dashboard/dist/assets/{TaskDetailPage-Bqj0I_I0.js.map → TaskDetailPage-DCDcEps9.js.map} +1 -1
  175. package/dashboard/dist/assets/{TaskQueuePill-Bxir8WRl.js → TaskQueuePill-DkQ1uc6y.js} +2 -2
  176. package/dashboard/dist/assets/{TaskQueuePill-Bxir8WRl.js.map → TaskQueuePill-DkQ1uc6y.js.map} +1 -1
  177. package/dashboard/dist/assets/TasksListPage-BBATgpf7.js +2 -0
  178. package/dashboard/dist/assets/{TasksListPage-BB1f79lL.js.map → TasksListPage-BBATgpf7.js.map} +1 -1
  179. package/dashboard/dist/assets/{TimeAgo-BFnODmNe.js → TimeAgo-CSNVEjch.js} +2 -2
  180. package/dashboard/dist/assets/{TimeAgo-BFnODmNe.js.map → TimeAgo-CSNVEjch.js.map} +1 -1
  181. package/dashboard/dist/assets/{TimestampCell-BXgLOBsr.js → TimestampCell-Du1nBrPn.js} +2 -2
  182. package/dashboard/dist/assets/{TimestampCell-BXgLOBsr.js.map → TimestampCell-Du1nBrPn.js.map} +1 -1
  183. package/dashboard/dist/assets/{ToolPill-FkgTXIhq.js → ToolPill-Baxm02L6.js} +2 -2
  184. package/dashboard/dist/assets/{ToolPill-FkgTXIhq.js.map → ToolPill-Baxm02L6.js.map} +1 -1
  185. package/dashboard/dist/assets/ToolTestPanel-CF-h_5Rg.js +2 -0
  186. package/dashboard/dist/assets/{ToolTestPanel-Bwe3J5lj.js.map → ToolTestPanel-CF-h_5Rg.js.map} +1 -1
  187. package/dashboard/dist/assets/{TopicDetailPage-DAF07vZ9.js → TopicDetailPage-Dr1UmWcp.js} +3 -3
  188. package/dashboard/dist/assets/{TopicDetailPage-DAF07vZ9.js.map → TopicDetailPage-Dr1UmWcp.js.map} +1 -1
  189. package/dashboard/dist/assets/TopicsPage-CUUo-Ylf.js +2 -0
  190. package/dashboard/dist/assets/{TopicsPage-C1gxBUap.js.map → TopicsPage-CUUo-Ylf.js.map} +1 -1
  191. package/dashboard/dist/assets/{UserName-BzXJUE6q.js → UserName-kBh1dc39.js} +2 -2
  192. package/dashboard/dist/assets/{UserName-BzXJUE6q.js.map → UserName-kBh1dc39.js.map} +1 -1
  193. package/dashboard/dist/assets/{WorkflowExecutionPage-SkRU5cRX.js → WorkflowExecutionPage-CCRSbnDx.js} +2 -2
  194. package/dashboard/dist/assets/{WorkflowExecutionPage-SkRU5cRX.js.map → WorkflowExecutionPage-CCRSbnDx.js.map} +1 -1
  195. package/dashboard/dist/assets/{WorkflowPill--AYMW7u_.js → WorkflowPill-ZepbO_ny.js} +2 -2
  196. package/dashboard/dist/assets/{WorkflowPill--AYMW7u_.js.map → WorkflowPill-ZepbO_ny.js.map} +1 -1
  197. package/dashboard/dist/assets/WorkflowsDashboard-BNQVvyek.js +2 -0
  198. package/dashboard/dist/assets/{WorkflowsDashboard-CZAqRk1N.js.map → WorkflowsDashboard-BNQVvyek.js.map} +1 -1
  199. package/dashboard/dist/assets/{WorkflowsOverview-BoN44VTE.js → WorkflowsOverview-DswubNJN.js} +2 -2
  200. package/dashboard/dist/assets/{WorkflowsOverview-BoN44VTE.js.map → WorkflowsOverview-DswubNJN.js.map} +1 -1
  201. package/dashboard/dist/assets/{YamlWorkflowDetailPage-CqjhtdJf.js → YamlWorkflowDetailPage-Cw9Dlmup.js} +11 -11
  202. package/dashboard/dist/assets/{YamlWorkflowDetailPage-CqjhtdJf.js.map → YamlWorkflowDetailPage-Cw9Dlmup.js.map} +1 -1
  203. package/dashboard/dist/assets/{YamlWorkflowsPage-CwnJkzyb.js → YamlWorkflowsPage-DB8xnIXy.js} +2 -2
  204. package/dashboard/dist/assets/{YamlWorkflowsPage-CwnJkzyb.js.map → YamlWorkflowsPage-DB8xnIXy.js.map} +1 -1
  205. package/dashboard/dist/assets/{agents-gV0Ys-sY.js → agents-BwEnf6N9.js} +2 -2
  206. package/dashboard/dist/assets/{agents-gV0Ys-sY.js.map → agents-BwEnf6N9.js.map} +1 -1
  207. package/dashboard/dist/assets/{bots-B97itB3I.js → bots-CCmJTT2u.js} +2 -2
  208. package/dashboard/dist/assets/{bots-B97itB3I.js.map → bots-CCmJTT2u.js.map} +1 -1
  209. package/dashboard/dist/assets/{capabilities-CR9xZgGd.js → capabilities-BZHgp_nh.js} +2 -2
  210. package/dashboard/dist/assets/{capabilities-CR9xZgGd.js.map → capabilities-BZHgp_nh.js.map} +1 -1
  211. package/dashboard/dist/assets/{constants-BHkpVaqx.js → constants-CeBBTzf5.js} +2 -2
  212. package/dashboard/dist/assets/{constants-BHkpVaqx.js.map → constants-CeBBTzf5.js.map} +1 -1
  213. package/dashboard/dist/assets/{controlplane-YxvP1KCa.js → controlplane-CyfwUlFA.js} +2 -2
  214. package/dashboard/dist/assets/{controlplane-YxvP1KCa.js.map → controlplane-CyfwUlFA.js.map} +1 -1
  215. package/dashboard/dist/assets/escalation-columns-BJPTNmLW.js +2 -0
  216. package/dashboard/dist/assets/escalation-columns-BJPTNmLW.js.map +1 -0
  217. package/dashboard/dist/assets/index-3gbd5neL.js +67 -0
  218. package/dashboard/dist/assets/index-3gbd5neL.js.map +1 -0
  219. package/dashboard/dist/assets/index-BAAVTyZ-.js +2 -0
  220. package/dashboard/dist/assets/{index-BQpV-DTG.js.map → index-BAAVTyZ-.js.map} +1 -1
  221. package/dashboard/dist/assets/{index-B9BBCqLI.js → index-BC6Jenlo.js} +2 -2
  222. package/dashboard/dist/assets/{index-B9BBCqLI.js.map → index-BC6Jenlo.js.map} +1 -1
  223. package/dashboard/dist/assets/index-C7KHqOTQ.js +2 -0
  224. package/dashboard/dist/assets/{index-Bp9KBLT5.js.map → index-C7KHqOTQ.js.map} +1 -1
  225. package/dashboard/dist/assets/index-CDrqqbSR.js +3 -0
  226. package/dashboard/dist/assets/index-CDrqqbSR.js.map +1 -0
  227. package/dashboard/dist/assets/index-CVwzCZ43.js +2 -0
  228. package/dashboard/dist/assets/{index-CFbo9FU9.js.map → index-CVwzCZ43.js.map} +1 -1
  229. package/dashboard/dist/assets/index-CaGF6TCC.js +2 -0
  230. package/dashboard/dist/assets/index-CaGF6TCC.js.map +1 -0
  231. package/dashboard/dist/assets/index-ClVbfe4z.js +13 -0
  232. package/dashboard/dist/assets/{index-Cfvkl2J0.js.map → index-ClVbfe4z.js.map} +1 -1
  233. package/dashboard/dist/assets/{index-DMeaiKgf.js → index-CuVkSmj5.js} +2 -2
  234. package/dashboard/dist/assets/{index-DMeaiKgf.js.map → index-CuVkSmj5.js.map} +1 -1
  235. package/dashboard/dist/assets/{index-ipqwPavs.js → index-DAuX_PlL.js} +2 -2
  236. package/dashboard/dist/assets/{index-ipqwPavs.js.map → index-DAuX_PlL.js.map} +1 -1
  237. package/dashboard/dist/assets/{index-CIpHj4di.js → index-DBWS5QL8.js} +2 -2
  238. package/dashboard/dist/assets/{index-CIpHj4di.js.map → index-DBWS5QL8.js.map} +1 -1
  239. package/dashboard/dist/assets/index-DIWCI6HC.js +2 -0
  240. package/dashboard/dist/assets/{index-CUZ6LYye.js.map → index-DIWCI6HC.js.map} +1 -1
  241. package/dashboard/dist/assets/{index-DwOnWeu8.js → index-DZ8X_Gp4.js} +2 -2
  242. package/dashboard/dist/assets/{index-DwOnWeu8.js.map → index-DZ8X_Gp4.js.map} +1 -1
  243. package/dashboard/dist/assets/index-Dh8MJl3L.css +1 -0
  244. package/dashboard/dist/assets/{knowledge-XX6cW4Ob.js → knowledge-CqyLhUMg.js} +2 -2
  245. package/dashboard/dist/assets/{knowledge-XX6cW4Ob.js.map → knowledge-CqyLhUMg.js.map} +1 -1
  246. package/dashboard/dist/assets/{mcp-CH13hNH2.js → mcp-Cvu6bFYH.js} +2 -2
  247. package/dashboard/dist/assets/{mcp-CH13hNH2.js.map → mcp-Cvu6bFYH.js.map} +1 -1
  248. package/dashboard/dist/assets/{mcp-query-Duydd3JA.js → mcp-query-qC6A3e9l.js} +2 -2
  249. package/dashboard/dist/assets/{mcp-query-Duydd3JA.js.map → mcp-query-qC6A3e9l.js.map} +1 -1
  250. package/dashboard/dist/assets/metadata-display-COo3mMCr.js +2 -0
  251. package/dashboard/dist/assets/metadata-display-COo3mMCr.js.map +1 -0
  252. package/dashboard/dist/assets/{personas-mDk4lLQS.js → personas-BKN_lJuV.js} +2 -2
  253. package/dashboard/dist/assets/{personas-mDk4lLQS.js.map → personas-BKN_lJuV.js.map} +1 -1
  254. package/dashboard/dist/assets/{pipelines-B5GcgCeF.js → pipelines-BldIfv85.js} +2 -2
  255. package/dashboard/dist/assets/{pipelines-B5GcgCeF.js.map → pipelines-BldIfv85.js.map} +1 -1
  256. package/dashboard/dist/assets/{tasks-CItmNsRp.js → tasks-B-Uay8uL.js} +2 -2
  257. package/dashboard/dist/assets/{tasks-CItmNsRp.js.map → tasks-B-Uay8uL.js.map} +1 -1
  258. package/dashboard/dist/assets/{topics-CJYG7BX5.js → topics-438EQogt.js} +2 -2
  259. package/dashboard/dist/assets/{topics-CJYG7BX5.js.map → topics-438EQogt.js.map} +1 -1
  260. package/dashboard/dist/assets/useContainerWidth-DSLp1gEm.js +2 -0
  261. package/dashboard/dist/assets/useContainerWidth-DSLp1gEm.js.map +1 -0
  262. package/dashboard/dist/assets/{useDebouncedValue-BrwgXcp8.js → useDebouncedValue-Cw8hYZ8y.js} +2 -2
  263. package/dashboard/dist/assets/{useDebouncedValue-BrwgXcp8.js.map → useDebouncedValue-Cw8hYZ8y.js.map} +1 -1
  264. package/dashboard/dist/assets/{useNamespace-CHty0HAS.js → useNamespace-D1218GQ8.js} +2 -2
  265. package/dashboard/dist/assets/{useNamespace-CHty0HAS.js.map → useNamespace-D1218GQ8.js.map} +1 -1
  266. package/dashboard/dist/assets/{useYamlActivityEvents-CoTsia7t.js → useYamlActivityEvents-BAQf_y_U.js} +2 -2
  267. package/dashboard/dist/assets/{useYamlActivityEvents-CoTsia7t.js.map → useYamlActivityEvents-BAQf_y_U.js.map} +1 -1
  268. package/dashboard/dist/assets/{vendor-icons-DeBdvyKJ.js → vendor-icons-B7OcUM6b.js} +2 -2
  269. package/dashboard/dist/assets/{vendor-icons-DeBdvyKJ.js.map → vendor-icons-B7OcUM6b.js.map} +1 -1
  270. package/dashboard/dist/assets/{yaml-workflows-CiWwx5rM.js → yaml-workflows-CN01gEB0.js} +2 -2
  271. package/dashboard/dist/assets/{yaml-workflows-CiWwx5rM.js.map → yaml-workflows-CN01gEB0.js.map} +1 -1
  272. package/dashboard/dist/index.html +3 -3
  273. package/docs/accumulator.md +113 -0
  274. package/docs/api/http/escalations.md +89 -0
  275. package/docs/api/http/roles.md +1 -0
  276. package/docs/api/sdk/escalations.md +91 -0
  277. package/docs/api/sdk/roles.md +2 -0
  278. package/docs/architecture.md +1 -1
  279. package/docs/code-owned-configuration.md +2 -1
  280. package/docs/dashboard.md +10 -4
  281. package/docs/hitl/design.md +1 -1
  282. package/docs/hitl/escalation.md +37 -1
  283. package/docs/hitl/invoke-form.md +4 -0
  284. package/docs/hitl/pinned-views.md +4 -0
  285. package/docs/hitl/portal.md +97 -0
  286. package/docs/hitl/resolution.md +41 -0
  287. package/docs/hitl/x-lt-embed.md +1 -1
  288. package/docs/hitl/x-lt-invoke.md +95 -0
  289. package/docs/hitl/x-lt-list-schema.md +3 -1
  290. package/docs/hitl/x-lt-widget.md +1 -0
  291. package/docs/hitl-guide.md +8 -1
  292. package/docs/scan-codes.md +15 -2
  293. package/docs/sdk.md +1 -1
  294. package/docs/workflows.md +2 -2
  295. package/package.json +4 -2
  296. package/dashboard/dist/assets/AgentsPage-7JJBHku8.js +0 -2
  297. package/dashboard/dist/assets/AvailableEscalationsPage-lz5qwSjg.js +0 -2
  298. package/dashboard/dist/assets/AvailableEscalationsPage-lz5qwSjg.js.map +0 -1
  299. package/dashboard/dist/assets/BulkAssignModal-NJBcoj-f.js +0 -2
  300. package/dashboard/dist/assets/CapabilitiesPage-F8dpNn9B.js +0 -2
  301. package/dashboard/dist/assets/DataTable-7C7riavf.js +0 -2
  302. package/dashboard/dist/assets/DataTable-7C7riavf.js.map +0 -1
  303. package/dashboard/dist/assets/EntityTimelinePanel-CkF-oW-m.js +0 -2
  304. package/dashboard/dist/assets/EscalationListView-AHW2xtlr.js +0 -2
  305. package/dashboard/dist/assets/EscalationListView-AHW2xtlr.js.map +0 -1
  306. package/dashboard/dist/assets/GraphInvokePage-CKtvWowP.js +0 -2
  307. package/dashboard/dist/assets/HomePage-BQ3Q791Q.js +0 -2
  308. package/dashboard/dist/assets/ListToolbar-DdJzj472.js +0 -2
  309. package/dashboard/dist/assets/McpQueryPage-CfJy7HZ7.js +0 -2
  310. package/dashboard/dist/assets/McpRunsPage-D7QXjW9z.js +0 -2
  311. package/dashboard/dist/assets/OperationsPage-aLHHAP2X.js +0 -3
  312. package/dashboard/dist/assets/OperationsPage-aLHHAP2X.js.map +0 -1
  313. package/dashboard/dist/assets/OperatorDashboard-sXNDh1Ph.js +0 -2
  314. package/dashboard/dist/assets/ProcessesListPage-CjwVKe32.js +0 -2
  315. package/dashboard/dist/assets/ResolverForm-Bk-wDkN-.js +0 -3
  316. package/dashboard/dist/assets/ResolverForm-Bk-wDkN-.js.map +0 -1
  317. package/dashboard/dist/assets/RoleDetailPage-WQt0y5l7.js +0 -8
  318. package/dashboard/dist/assets/RoleDetailPage-WQt0y5l7.js.map +0 -1
  319. package/dashboard/dist/assets/RunAsSelector-fFMt1bGe.js +0 -2
  320. package/dashboard/dist/assets/ScanStationPage-C1_ppDoZ.js +0 -2
  321. package/dashboard/dist/assets/TasksListPage-BB1f79lL.js +0 -2
  322. package/dashboard/dist/assets/ToolTestPanel-Bwe3J5lj.js +0 -2
  323. package/dashboard/dist/assets/TopicsPage-C1gxBUap.js +0 -2
  324. package/dashboard/dist/assets/WorkflowsDashboard-CZAqRk1N.js +0 -2
  325. package/dashboard/dist/assets/escalation-columns-uq-IV2aj.js +0 -2
  326. package/dashboard/dist/assets/escalation-columns-uq-IV2aj.js.map +0 -1
  327. package/dashboard/dist/assets/index-3ezfWLkE.js +0 -6
  328. package/dashboard/dist/assets/index-3ezfWLkE.js.map +0 -1
  329. package/dashboard/dist/assets/index-BQpV-DTG.js +0 -2
  330. package/dashboard/dist/assets/index-Bp9KBLT5.js +0 -2
  331. package/dashboard/dist/assets/index-Bpvfr4OW.css +0 -1
  332. package/dashboard/dist/assets/index-CFbo9FU9.js +0 -2
  333. package/dashboard/dist/assets/index-CIwlVfvV.js +0 -67
  334. package/dashboard/dist/assets/index-CIwlVfvV.js.map +0 -1
  335. package/dashboard/dist/assets/index-CUZ6LYye.js +0 -2
  336. package/dashboard/dist/assets/index-Cfvkl2J0.js +0 -13
  337. package/dashboard/dist/assets/index-SGyrXGp8.js +0 -3
  338. package/dashboard/dist/assets/index-SGyrXGp8.js.map +0 -1
  339. package/dashboard/dist/assets/invoke-context-DrVyUEfs.js +0 -2
  340. package/dashboard/dist/assets/invoke-context-DrVyUEfs.js.map +0 -1
  341. package/dashboard/dist/assets/metadata-display--TzK0REC.js +0 -2
  342. package/dashboard/dist/assets/metadata-display--TzK0REC.js.map +0 -1
  343. package/dashboard/dist/assets/resolver-payload-m9AGKZ3a.js +0 -2
  344. package/dashboard/dist/assets/resolver-payload-m9AGKZ3a.js.map +0 -1
  345. package/docs/compilation.md +0 -152
  346. package/docs/compiler.md +0 -311
  347. package/docs/contributing.md +0 -56
  348. package/docs/design-principles.md +0 -245
  349. package/docs/schema-exchange.md +0 -173
  350. package/docs/self-test.md +0 -106
  351. package/docs/story.md +0 -184
@@ -1 +0,0 @@
1
- {"version":3,"file":"EscalationListView-AHW2xtlr.js","sources":["../../../shared/form-validation/x-lt-bind.ts","../../../shared/form-validation/x-lt-help.ts","../../src/lib/schema-needs-envelope.ts","../../src/lib/escalation.ts","../../src/lib/type-color.ts","../../src/components/escalation/RefineDialog.tsx","../../src/components/escalation/EscalationListView.tsx"],"sourcesContent":["/**\n * x-lt-bind — maps the escalation FORM (flat field values the user edits) to and\n * from the PAYLOAD (the nested JSON the workflow consumes). A form_schema property\n * may declare `x-lt-bind: \"a.b[0].c\"`, the path its value occupies in the payload;\n * a property with no bind sits at its own name at the root (1:1). This module is\n * isomorphic — the dashboard renders forms with it, and the API layer inverts a\n * submitted payload through it to validate against the form contract. One\n * implementation, both sides.\n *\n * mapPayloadToForm — payload → flat form values, to PREFILL/display the form\n * (server-side: to validate a submitted payload)\n * mapFormToPayload — flat form values → payload, the shape submitted/stored\n */\n\ntype PathSeg = { key: string } | { index: number };\n\nconst BLOCKED_KEYS = new Set(['__proto__', 'constructor', 'prototype']);\n\n/** Parse a bind path — dot keys with optional `[n]` indices. Rejects pollution keys. */\nexport function parsePath(path: string): PathSeg[] {\n const segs: PathSeg[] = [];\n for (const raw of path.split('.')) {\n const m = raw.match(/^([^[\\]]*)((?:\\[\\d+\\])*)$/);\n if (!m) throw new Error(`invalid x-lt-bind path segment: \"${raw}\"`);\n const [, name, brackets] = m;\n if (name) {\n if (BLOCKED_KEYS.has(name)) throw new Error(`x-lt-bind path may not target \"${name}\"`);\n segs.push({ key: name });\n }\n for (const b of brackets.match(/\\d+/g) ?? []) segs.push({ index: Number(b) });\n }\n if (segs.length === 0) throw new Error(`empty x-lt-bind path: \"${path}\"`);\n return segs;\n}\n\n/** Set `value` at `path` inside `root`, creating intermediate objects/arrays. */\nexport function setDeep(root: Record<string, any>, path: string, value: unknown): void {\n const segs = parsePath(path);\n let node: any = root;\n for (let i = 0; i < segs.length - 1; i++) {\n const seg = segs[i];\n const next = segs[i + 1];\n const childKey = 'key' in seg ? seg.key : seg.index;\n const wantArray = 'index' in next;\n if (node[childKey] == null || typeof node[childKey] !== 'object') {\n node[childKey] = wantArray ? [] : {};\n }\n node = node[childKey];\n }\n const last = segs[segs.length - 1];\n node['key' in last ? last.key : last.index] = value;\n}\n\n/** Read the value at `path` inside `root` (undefined if any segment is missing). */\nexport function getDeep(root: unknown, path: string): unknown {\n let node: any = root;\n for (const seg of parsePath(path)) {\n if (node == null || typeof node !== 'object') return undefined;\n node = node['key' in seg ? seg.key : seg.index];\n }\n return node;\n}\n\n/** The bind path for a form property (its `x-lt-bind`, or the property name). */\nexport function bindPathFor(propName: string, propDef: Record<string, any> | undefined): string {\n const bind = propDef?.['x-lt-bind'];\n return typeof bind === 'string' && bind.length > 0 ? bind : propName;\n}\n\n/**\n * Assemble the payload from the form's flat values. A field absent from\n * `formValues` is omitted (so clearing/deleting a field drops it from the\n * payload). Unknown keys not declared in the schema are dropped. With no schema\n * properties, values pass through unchanged.\n */\nexport function mapFormToPayload(\n formValues: Record<string, any>,\n formSchema: Record<string, any> | null | undefined,\n): Record<string, any> {\n const props = formSchema?.properties as Record<string, any> | undefined;\n if (!props) return { ...formValues };\n const payload: Record<string, any> = {};\n for (const [name, def] of Object.entries(props)) {\n if (!(name in formValues)) continue;\n setDeep(payload, bindPathFor(name, def as Record<string, any>), formValues[name]);\n }\n return payload;\n}\n\n/**\n * Reverse of {@link mapFormToPayload}: pull each form field's value out of the\n * payload via its bind path, to prefill/display the form. A field whose bound\n * path is missing from the payload is omitted (the caller falls back to the\n * schema default).\n */\nexport function mapPayloadToForm(\n payload: Record<string, any> | null | undefined,\n formSchema: Record<string, any> | null | undefined,\n): Record<string, any> {\n const props = formSchema?.properties as Record<string, any> | undefined;\n if (!props) return payload ? { ...payload } : {};\n const form: Record<string, any> = {};\n for (const [name, def] of Object.entries(props)) {\n const v = getDeep(payload, bindPathFor(name, def as Record<string, any>));\n if (v !== undefined) form[name] = v;\n }\n return form;\n}\n","/**\n * x-lt-help — the form's guidance content, rendered in the side panel beside\n * the resolve form. A form_schema may declare schema-level `x-lt-help`: a\n * markdown string whose `{{domain.path}}` tokens interpolate values from the\n * escalation surface, so help text can reference the live record:\n *\n * {{escalation.role}} — any column on the escalation row\n * {{metadata.schema_version}} — the row's metadata dict\n * {{envelope.formDefaults.customer.name}} — the workflow-sent input envelope\n * {{payload.category}} — the escalation context payload\n * {{resolver.notes}} — the submitted resolver payload\n * {{lookup.materials.items}} — versioned knowledge lookups pinned on the row\n *\n * Paths reuse the x-lt-bind syntax (`a.b[0].c`). A missing value renders as an\n * em dash. `x-lt-context` is accepted as the plain-text fallback source when\n * `x-lt-help` is absent.\n */\nimport { getDeep } from './x-lt-bind';\n\n/** The token domains a help template may reference. `input` is the invoke-form name for the live values `resolver` also carries. */\nexport const HELP_DOMAINS = ['escalation', 'metadata', 'envelope', 'payload', 'resolver', 'lookup', 'input'] as const;\nexport type HelpDomain = (typeof HELP_DOMAINS)[number];\n\nexport type HelpTokenContext = Partial<Record<HelpDomain, Record<string, unknown> | null>>;\n\nconst TOKEN_PATTERN = /\\{\\{\\s*([^{}]+?)\\s*\\}\\}/g;\nconst MISSING_VALUE = '—';\n\nfunction formatTokenValue(value: unknown): string {\n if (value === undefined || value === null) return MISSING_VALUE;\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n try {\n return JSON.stringify(value);\n } catch {\n return MISSING_VALUE;\n }\n}\n\n/** Replace every `{{domain.path}}` token with its value from the context. */\nexport function interpolateHelp(template: string, ctx: HelpTokenContext): string {\n return template.replace(TOKEN_PATTERN, (_match, rawPath: string) => {\n const dot = rawPath.indexOf('.');\n const domain = (dot === -1 ? rawPath : rawPath.slice(0, dot)) as HelpDomain;\n if (!HELP_DOMAINS.includes(domain)) return MISSING_VALUE;\n const root = ctx[domain];\n if (dot === -1) return formatTokenValue(root);\n try {\n return formatTokenValue(getDeep(root, rawPath.slice(dot + 1)));\n } catch {\n return MISSING_VALUE;\n }\n });\n}\n\n/** The schema's help source: `x-lt-help` first, `x-lt-context` as fallback. */\nexport function resolveHelpSource(schema: Record<string, unknown> | null | undefined): string | null {\n const help = schema?.['x-lt-help'];\n if (typeof help === 'string' && help.trim().length > 0) return help;\n const context = schema?.['x-lt-context'];\n if (typeof context === 'string' && context.trim().length > 0) return context;\n return null;\n}\n\n/** The schema's help content, interpolated. Null when the schema declares none. */\nexport function buildHelpMarkdown(\n schema: Record<string, unknown> | null | undefined,\n ctx: HelpTokenContext,\n): string | null {\n const source = resolveHelpSource(schema);\n return source ? interpolateHelp(source, ctx) : null;\n}\n\nexport interface HelpStateHint {\n isTerminal: boolean;\n status?: string;\n claimed: boolean;\n claimedByMe: boolean;\n}\n\n/**\n * State-aware guidance shown when the schema carries no help content — the\n * panel always tells the user what this page expects of them right now.\n */\nexport function defaultHelpMarkdown({ isTerminal, status, claimed, claimedByMe }: HelpStateHint): string {\n if (isTerminal) {\n return status === 'cancelled'\n ? 'This escalation was cancelled. The record is shown for reference.'\n : 'This escalation has been resolved. The submitted form is shown for reference.';\n }\n if (claimedByMe) return 'You have claimed this escalation. Fill out the form and submit to resolve it.';\n if (claimed) return 'Another user has claimed this escalation. It unlocks if their claim expires or is released.';\n return 'Claim this escalation to enable the form.';\n}\n","/**\n * List rows arrive without the heavyweight `envelope`/`escalation_payload`\n * columns by default. A surface driven by an x-lt schema fragment opts back in\n * only when the fragment actually interpolates those domains — `envelope.` or\n * `payload.` in any token, condition, or source path. `metadata.` and\n * `resolver.` ride the slim rows and never trigger the opt-in.\n */\nexport function schemaNeedsEnvelope(fragment: unknown): boolean {\n if (!fragment) return false;\n try {\n const s = JSON.stringify(fragment);\n return s.includes('envelope.') || s.includes('payload.');\n } catch {\n return false;\n }\n}\n","import type { LTEscalationRecord } from '../api/types';\n\nexport function isEffectivelyClaimed(esc: LTEscalationRecord): boolean {\n return !!(\n esc.assigned_to &&\n esc.assigned_until &&\n new Date(esc.assigned_until) > new Date()\n );\n}\n\n/** An ACK escalation has no associated workflow — it's a notification, not a task. */\nexport function isAckEscalation(esc: LTEscalationRecord): boolean {\n return !esc.workflow_type;\n}\n\nexport function isAvailable(esc: LTEscalationRecord): boolean {\n return (\n esc.status === 'pending' &&\n (!esc.assigned_to ||\n !esc.assigned_until ||\n new Date(esc.assigned_until) <= new Date())\n );\n}\n","/**\n * Deterministic color assignment for workflow type names.\n *\n * Maps any string to a consistent color from a curated 24-color palette.\n * The same type name always produces the same color across the entire UI.\n * Uses a simple hash to distribute names evenly across the palette.\n *\n * Each entry provides:\n * text — icon and text color (Tailwind class)\n * bg — subtle background tint (Tailwind class)\n */\n\nconst PALETTE: Array<{ text: string; bg: string }> = [\n { text: 'text-rose-400', bg: 'bg-rose-400/[0.08]' },\n { text: 'text-pink-400', bg: 'bg-pink-400/[0.08]' },\n { text: 'text-fuchsia-400', bg: 'bg-fuchsia-400/[0.08]' },\n { text: 'text-purple-400', bg: 'bg-purple-400/[0.08]' },\n { text: 'text-violet-400', bg: 'bg-violet-400/[0.08]' },\n { text: 'text-indigo-400', bg: 'bg-indigo-400/[0.08]' },\n { text: 'text-blue-400', bg: 'bg-blue-400/[0.08]' },\n { text: 'text-sky-400', bg: 'bg-sky-400/[0.08]' },\n { text: 'text-cyan-400', bg: 'bg-cyan-400/[0.08]' },\n { text: 'text-teal-400', bg: 'bg-teal-400/[0.08]' },\n { text: 'text-emerald-400', bg: 'bg-emerald-400/[0.08]' },\n { text: 'text-green-400', bg: 'bg-green-400/[0.08]' },\n { text: 'text-lime-400', bg: 'bg-lime-400/[0.08]' },\n { text: 'text-yellow-400', bg: 'bg-yellow-400/[0.08]' },\n { text: 'text-amber-400', bg: 'bg-amber-400/[0.08]' },\n { text: 'text-orange-400', bg: 'bg-orange-400/[0.08]' },\n { text: 'text-red-400', bg: 'bg-red-400/[0.08]' },\n { text: 'text-stone-400', bg: 'bg-stone-400/[0.08]' },\n { text: 'text-rose-300', bg: 'bg-rose-300/[0.08]' },\n { text: 'text-violet-300', bg: 'bg-violet-300/[0.08]' },\n { text: 'text-sky-300', bg: 'bg-sky-300/[0.08]' },\n { text: 'text-teal-300', bg: 'bg-teal-300/[0.08]' },\n { text: 'text-amber-300', bg: 'bg-amber-300/[0.08]' },\n { text: 'text-pink-300', bg: 'bg-pink-300/[0.08]' },\n];\n\nfunction hash(str: string): number {\n let h = 0;\n for (let i = 0; i < str.length; i++) {\n h = ((h << 5) - h + str.charCodeAt(i)) | 0;\n }\n return Math.abs(h);\n}\n\nexport function typeColor(typeName: string): { text: string; bg: string } {\n return PALETTE[hash(typeName) % PALETTE.length];\n}\n","import { useState } from 'react';\nimport { Check } from 'lucide-react';\nimport { Modal } from '../common/modal/Modal';\nimport { metadataFacetsUrl } from '../../lib/facet-url';\n\n/** One refinable fact from a row: a metadata key with its authored label and value. */\nexport interface RefinePair {\n key: string;\n label: string;\n value: unknown;\n}\n\n/**\n * The row-level refine gesture for authored lists (facet-table rows, board\n * cards): the row's metadata-bound facts as full-width touch rows, each a\n * toggle. Pick one or several (multi-select ANDs the facets) and drill —\n * filter this role's queue, search every role, or merge into the live filter\n * set. One dialog replaces per-cell icon pairs, so table cells spend their\n * width on data and the affordance stays tappable on the iPad floor.\n */\nexport function RefineDialog({ open, onClose, role, pairs, onNavigate, onAddFacet }: {\n open: boolean;\n onClose: () => void;\n role: string;\n pairs: RefinePair[];\n /** Receives the facet deep-link. Hosts navigate (or open a panel). */\n onNavigate: (url: string) => void;\n /** When provided, \"Add to filters\" merges the selection into the live set. */\n onAddFacet?: (key: string, value: unknown) => void;\n}) {\n // A single fact arrives selected — the one-glance, two-tap path.\n const [selected, setSelected] = useState<Set<string>>(new Set());\n const [prevOpen, setPrevOpen] = useState(open);\n if (open !== prevOpen) {\n setPrevOpen(open);\n if (open) setSelected(new Set(pairs.length === 1 ? [pairs[0].key] : []));\n }\n\n const toggle = (key: string) => {\n setSelected((prev) => {\n const next = new Set(prev);\n if (next.has(key)) next.delete(key); else next.add(key);\n return next;\n });\n };\n\n const chosen = pairs.filter((p) => selected.has(p.key));\n const facets = Object.fromEntries(chosen.map((p) => [p.key, p.value]));\n const none = chosen.length === 0;\n\n const go = (url: string) => {\n onClose();\n onNavigate(url);\n };\n\n return (\n <Modal open={open} onClose={onClose} title=\"Refine\">\n <div className=\"space-y-4\">\n <p className=\"text-2xs text-text-tertiary\">\n Pick the facts to match — several combine into one narrower query.\n </p>\n\n <div className=\"divide-y divide-surface-border/40 -mx-1\">\n {pairs.map((p) => {\n const on = selected.has(p.key);\n return (\n <button\n key={p.key}\n type=\"button\"\n onClick={() => toggle(p.key)}\n aria-pressed={on}\n className=\"w-full flex items-center gap-3 px-1 py-2.5 text-left group min-w-0\"\n data-testid=\"refine-pair\"\n >\n <span\n className={`w-4 h-4 rounded-[3px] border flex items-center justify-center shrink-0 transition-colors ${\n on ? 'bg-accent border-accent' : 'border-surface-border group-hover:border-accent/50'\n }`}\n aria-hidden\n >\n {on && <Check className=\"w-3 h-3 text-text-inverse\" strokeWidth={3} />}\n </span>\n <span className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary w-28 shrink-0 truncate\" title={p.key}>\n {p.label}\n </span>\n <span className=\"text-xs text-text-primary truncate flex-1 min-w-0\" title={String(p.value)}>\n {String(p.value)}\n </span>\n </button>\n );\n })}\n </div>\n\n <div className=\"flex items-center justify-end gap-3 pt-2 flex-wrap\">\n {onAddFacet && (\n <button\n onClick={() => {\n chosen.forEach((p) => onAddFacet(p.key, p.value));\n onClose();\n }}\n disabled={none}\n className=\"text-xs text-text-secondary hover:text-accent transition-colors disabled:opacity-40 disabled:cursor-not-allowed mr-auto\"\n data-testid=\"refine-add-filters\"\n >\n Add to filters\n </button>\n )}\n <button\n onClick={() => go(metadataFacetsUrl(facets))}\n disabled={none}\n className=\"btn-secondary text-xs disabled:opacity-40 disabled:cursor-not-allowed\"\n data-testid=\"refine-search-all\"\n >\n Search everywhere\n </button>\n <button\n onClick={() => go(metadataFacetsUrl(facets, role))}\n disabled={none}\n className=\"btn-primary text-xs disabled:opacity-40 disabled:cursor-not-allowed\"\n data-testid=\"refine-filter-role\"\n >\n Filter {role}\n </button>\n </div>\n </div>\n </Modal>\n );\n}\n","import { useState, useEffect } from 'react';\nimport { useNavigate, useLocation } from 'react-router-dom';\nimport { interpolateHelp, type HelpTokenContext } from '../../lib/x-lt-help';\nimport { DataTable, type Column as TableColumn } from '../common/data/DataTable';\nimport { Search } from 'lucide-react';\nimport { MarkdownRenderer } from '../common/display/MarkdownRenderer';\nimport { STATUS_DOT_STYLES } from '../common/display/StatusBadge';\nimport { DateValue } from '../common/display/DateValue';\nimport { UserName } from '../common/display/UserName';\nimport { StickyPagination } from '../common/data/StickyPagination';\nimport { useEscalations, useClaimEscalation } from '../../api/escalations';\nimport { schemaNeedsEnvelope } from '../../lib/schema-needs-envelope';\nimport { isEffectivelyClaimed } from '../../lib/escalation';\nimport { formatAgoCompact } from '../../lib/format';\nimport { getDeep } from '../../lib/x-lt-bind';\nimport { typeColor } from '../../lib/type-color';\nimport { RefineDialog, type RefinePair } from './RefineDialog';\nimport type { LTEscalationRecord } from '../../api/types';\n\n/** Dot colour matches the standard table view: blue = pending unclaimed,\n * orange = under a live claim; other statuses follow the shared map. */\nfunction escalationDotClass(e: LTEscalationRecord): string {\n if (e.status === 'pending') {\n return isEffectivelyClaimed(e) ? 'bg-status-claimed-graphic' : 'bg-status-active';\n }\n return STATUS_DOT_STYLES[e.status] ?? 'bg-status-active';\n}\n\n/**\n * EscalationListView — the role-authored rich view of an escalation list, driven\n * by a versioned `list_schema` (x-lt-* markup). The list-page analog of the\n * resolve form: the same `{{domain.path}}` token binding (via interpolateHelp)\n * against each row's context, and MarkdownRenderer for rich bodies.\n *\n * Layouts:\n * active-history — single live item as a card on the left + history column on right\n * active — just the single live item card (no history)\n * facet-table — full pending queue as a table, columns from x-lt-columns\n * facet-board — one card per x-lt-group-by facet value (an entity board:\n * machines, stations), rendered from each group's latest row\n */\n\ninterface CardDef {\n title?: string;\n subtitle?: string;\n body?: string;\n fields?: { label: string; value: string; format?: string }[];\n}\n\ninterface HistoryDef {\n row?: { title?: string; subtitle?: string; meta?: string };\n limit?: number;\n status?: string;\n}\n\nexport interface ColumnDef {\n label: string;\n value: string;\n /** \"age\" renders an ISO timestamp as a compact age with an absolute tooltip. */\n format?: string;\n /**\n * Card-fold behavior when the table folds at narrow widths (same contract\n * as the engineer table): 1 = identity — always visible, forms the card's\n * title line; 2 = folds into the card body as a label/value pair; 3 =\n * dropped in card mode. Undeclared, the first column is the identity and\n * the rest fold.\n */\n priority?: 1 | 2 | 3;\n /** CSS column width (\"40%\", \"12rem\"). Unset columns share the remainder;\n * when no column declares one, the first column gets 40% — the identity\n * is nearly always the row's most important value. */\n width?: string;\n}\n\ninterface BoardCardDef {\n title?: string;\n /** Status chip — any token (commonly {{escalation.subtype}}). */\n state?: string;\n fields?: { label: string; value: string; format?: string }[];\n}\n\n/**\n * The per-row action button — the queue-working gesture, always available on\n * every layout. Template-driven: the schema author sets the action, its text,\n * and (for claim) the hold time.\n */\nexport interface RowActionDef {\n /** \"claim\" fires a one-click claim then opens the detail page already\n * claimed; \"view\" just opens it. Default \"claim\". */\n action?: 'claim' | 'view';\n /** Button text. Defaults \"Claim\" / \"View\" by action. */\n label?: string;\n /** Claim hold time in minutes. Default 30 (the platform claim default). */\n durationMinutes?: number;\n /**\n * Launch the detail page's claim-and-submit flow instead of a plain claim:\n * the row is claimed, the form's seeded defaults are resolved, and — when the\n * form declares `x-lt-transition` — the wait screen bridges to the born-assigned\n * follow-on. One list gesture (\"Start Harvesting\") starts the work and lands\n * the person on the next step. The behavior lives on the detail page (form\n * defaults, validation, transition); the list only points there with intent.\n */\n submitOnClaim?: boolean;\n}\n\ninterface ListSchema {\n 'x-lt-layout'?: string;\n 'x-lt-help'?: string;\n 'x-lt-active'?: CardDef;\n 'x-lt-history'?: HistoryDef;\n 'x-lt-columns'?: ColumnDef[];\n /** facet-board: the \"domain.path\" whose value identifies each entity. */\n 'x-lt-group-by'?: string;\n /** facet-board: the per-entity card definition. */\n 'x-lt-card'?: BoardCardDef;\n /** The per-row action button (claim | view, label, claim duration). */\n 'x-lt-row-action'?: RowActionDef;\n}\n\n/**\n * Repaint-only minute tick so `format: \"age\"` values stay current. Pure\n * re-render — no network. Mounted once at the view root, only when the\n * schema actually uses ages.\n */\nfunction useAgeTick(enabled: boolean): void {\n const [, setTick] = useState(0);\n useEffect(() => {\n if (!enabled) return;\n const t = window.setInterval(() => setTick((n) => n + 1), 60_000);\n return () => window.clearInterval(t);\n }, [enabled]);\n}\n\nfunction schemaUsesAge(schema: ListSchema): boolean {\n return [...(schema['x-lt-columns'] ?? []), ...(schema['x-lt-card']?.fields ?? [])]\n .some((f) => f.format === 'age');\n}\n\n/** Build the token context for one escalation row (payloads are JSON strings). */\nexport function rowContext(e: LTEscalationRecord): HelpTokenContext {\n const parse = (s: string | null | undefined): Record<string, unknown> | null => {\n if (!s) return null;\n try {\n const v = JSON.parse(s);\n return v && typeof v === 'object' ? v : null;\n } catch {\n return null;\n }\n };\n return {\n escalation: e as unknown as Record<string, unknown>,\n metadata: e.metadata ?? null,\n envelope: parse(e.envelope),\n payload: parse(e.escalation_payload),\n resolver: parse(e.resolver_payload),\n };\n}\n\nconst ISO_DATETIME = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}/;\nconst EM_DASH = '—';\n\n/**\n * Render an interpolated field value with a little care: `format: \"age\"` turns\n * a timestamp into a compact age (\"12m\", \"3h\") with the absolute time as its\n * tooltip; `format: \"user\"` resolves a user-id token to a display name; a full\n * ISO datetime becomes a friendly, hoverable date; an empty value a quiet em\n * dash; anything else plain text. Authors bind tokens; we make the common\n * shapes look right.\n */\nfunction FieldValue({ raw, format }: { raw: string; format?: string }) {\n if (!raw || raw === EM_DASH) return <span className=\"text-text-quaternary\">{EM_DASH}</span>;\n if (format === 'user') return <UserName userId={raw} className=\"block truncate\" />;\n if (format === 'age') {\n const d = new Date(raw);\n if (!Number.isNaN(d.getTime())) {\n return <span title={d.toLocaleString()} className=\"tabular-nums whitespace-nowrap\">{formatAgoCompact(raw)}</span>;\n }\n }\n if (ISO_DATETIME.test(raw)) return <DateValue date={raw} format=\"datetime\" className=\"text-text-primary\" />;\n return <>{raw}</>;\n}\n\nconst DEFAULT_CLAIM_MINUTES = 30;\n\n/** Claim targets pending rows without a live claim window. */\nfunction isClaimable(row: LTEscalationRecord): boolean {\n return row.status === 'pending' && !isEffectivelyClaimed(row);\n}\n\n/**\n * The x-lt-row-action button. `claim` is one click: claim for the template's\n * duration, then open the detail page already claimed — the fast path for\n * working a queue. `view` opens the detail page. Persistent (light accent at\n * rest, saturating on hover); a rejected claim surfaces its message inline.\n */\nfunction RowActionButton({ row, def, onView, prominent, forceView }: {\n row: LTEscalationRecord;\n def?: RowActionDef;\n onView?: () => void;\n /** Hero treatment for the active-card CTA; default is the compact row button. */\n prominent?: boolean;\n /** Render claim templates as view actions (see EscalationListView). */\n forceView?: boolean;\n}) {\n const authored = def?.action ?? 'claim';\n const action = forceView ? 'view' : authored;\n // The authored label describes the authored gesture. When view is forced\n // over a claim template, claim wording would mislead — use the view default.\n const label = authored === action && def?.label\n ? def.label\n : action === 'claim' ? 'Claim' : 'View';\n const claim = useClaimEscalation();\n const navigate = useNavigate();\n const location = useLocation();\n const [error, setError] = useState('');\n\n // A spent gesture stays visible — the disabled button keeps every row's\n // layout uniform instead of leaving a hole on resolved/held rows.\n const spent = action === 'claim' && !isClaimable(row);\n\n const fire = (e: React.MouseEvent) => {\n e.stopPropagation();\n if (action === 'view') {\n onView?.();\n return;\n }\n // Launch the detail page's claim → submit → transition flow. The detail\n // page owns the heavy lifting (seed defaults, validate, resolve, hand-off);\n // the list points there with the intent and the authored claim duration.\n if (def?.submitOnClaim) {\n navigate(`/escalations/detail/${row.id}`, {\n state: { autoStart: true, durationMinutes: def?.durationMinutes, from: location.pathname },\n });\n return;\n }\n setError('');\n claim.mutate(\n { id: row.id, durationMinutes: def?.durationMinutes ?? DEFAULT_CLAIM_MINUTES },\n {\n onSuccess: () => onView?.(),\n onError: (err) => setError((err as Error).message),\n },\n );\n };\n\n const classes = prominent\n ? 'btn-primary text-xs shrink-0 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-accent'\n : 'px-2 py-0.5 rounded text-2xs font-medium text-accent/70 border border-accent/30 enabled:hover:text-accent enabled:hover:border-accent/60 enabled:hover:bg-accent/5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap';\n\n return (\n <span className=\"inline-flex flex-col items-end gap-0.5\">\n <button\n type=\"button\"\n onClick={fire}\n disabled={claim.isPending || spent}\n title={spent ? (row.status === 'pending' ? 'claimed' : row.status) : undefined}\n className={classes}\n data-testid=\"row-action-button\"\n >\n {claim.isPending ? 'Claiming…' : label}\n </button>\n {error && <span className=\"text-2xs text-status-error\" data-testid=\"row-action-error\">{error}</span>}\n </span>\n );\n}\n\nfunction ActiveCard({ esc, card, rowAction, onOpen, forceView }: {\n esc: LTEscalationRecord;\n card: CardDef;\n rowAction?: RowActionDef;\n onOpen?: () => void;\n forceView?: boolean;\n}) {\n const ctx = rowContext(esc);\n const title = card.title ? interpolateHelp(card.title, ctx) : esc.type;\n return (\n <div>\n <div className=\"flex items-start justify-between gap-6\">\n <button onClick={onOpen} className=\"text-left group min-w-0\">\n <h3 className=\"heading-2 group-hover:text-accent transition-colors leading-tight\">\n {title}\n </h3>\n {card.subtitle && (\n <p className=\"text-xs text-text-tertiary mt-1.5\">{interpolateHelp(card.subtitle, ctx)}</p>\n )}\n </button>\n\n {/* The row action — one-click claim (then the detail page opens already\n claimed), or view for read-only templates. */}\n <RowActionButton row={esc} def={rowAction} onView={onOpen} prominent forceView={forceView} />\n </div>\n\n {card.fields && card.fields.length > 0 && (\n <dl className=\"flex flex-wrap gap-x-10 gap-y-4 mt-6\">\n {card.fields.map((f, i) => (\n <div key={i}>\n <dt className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary\">{f.label}</dt>\n <dd className=\"text-xs text-text-primary mt-1\"><FieldValue raw={interpolateHelp(f.value, ctx)} /></dd>\n </div>\n ))}\n </dl>\n )}\n\n {card.body && (\n <div className=\"mt-7 pt-6 border-t border-surface-border/50\">\n <MarkdownRenderer content={interpolateHelp(card.body, ctx)} />\n </div>\n )}\n </div>\n );\n}\n\nfunction HistoryColumn({ role, def, onRowClick }: {\n role: string;\n def: HistoryDef;\n onRowClick?: (row: LTEscalationRecord) => void;\n}) {\n const [show, setShow] = useState(false);\n const query = useEscalations({\n role,\n status: def.status ?? 'resolved',\n sort_by: 'resolved_at',\n order: 'desc',\n limit: def.limit ?? 25,\n enabled: show,\n include: schemaNeedsEnvelope(def) ? 'envelope' : undefined,\n });\n const rows = query.data?.escalations ?? [];\n const total = query.data?.total ?? 0;\n const rowDef = def.row ?? {};\n\n if (!show) {\n return (\n <button\n onClick={() => setShow(true)}\n className=\"text-xs text-accent hover:underline\"\n data-testid=\"load-history\"\n >\n Load full history →\n </button>\n );\n }\n\n if (query.isLoading) {\n return <p className=\"text-xs text-text-tertiary italic\">Loading history…</p>;\n }\n\n if (rows.length === 0) {\n return <p className=\"text-xs text-text-tertiary italic\">No past revisions.</p>;\n }\n\n return (\n <div>\n <div className=\"divide-y divide-surface-border/40\">\n {rows.map((e) => {\n const ctx = rowContext(e);\n return (\n <button\n key={e.id}\n onClick={() => onRowClick?.(e)}\n className=\"w-full text-left py-2.5 group flex items-center gap-3\"\n >\n {/* Status as a bare outlined dot — colour carries the meaning. */}\n <span\n className={`w-2.5 h-2.5 shrink-0 rounded-full dot-ring ${escalationDotClass(e)}`}\n title={e.status}\n />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block text-xs text-text-primary group-hover:text-accent transition-colors truncate\">\n {rowDef.title ? interpolateHelp(rowDef.title, ctx) : e.type}\n </span>\n {rowDef.subtitle && (\n <span className=\"block text-2xs text-text-tertiary truncate\">\n {interpolateHelp(rowDef.subtitle, ctx)}\n </span>\n )}\n </span>\n {rowDef.meta\n ? <span className=\"text-2xs text-text-tertiary shrink-0\">{interpolateHelp(rowDef.meta, ctx)}</span>\n : e.resolved_at && <DateValue date={e.resolved_at} format=\"relative\" className=\"text-2xs text-text-tertiary shrink-0 whitespace-nowrap\" />}\n </button>\n );\n })}\n </div>\n {total > rows.length && (\n <p className=\"text-2xs text-text-quaternary mt-3\">Showing {rows.length} of {total}.</p>\n )}\n </div>\n );\n}\n\n/**\n * The refinable facts one row offers: every column the author bound to a pure\n * metadata value, with its authored label and the row's raw value. Feeds the\n * row's RefineDialog.\n */\nexport function rowRefinePairs(row: LTEscalationRecord, columnDefs: ColumnDef[]): RefinePair[] {\n const pairs: RefinePair[] = [];\n const seen = new Set<string>();\n for (const col of columnDefs) {\n const bound = col.value.match(METADATA_TOKEN)?.[1];\n if (!bound || seen.has(bound)) continue;\n const raw = row.metadata?.[bound];\n if (raw === undefined || raw === null || raw === '') continue;\n seen.add(bound);\n pairs.push({ key: bound, label: col.label, value: raw });\n }\n return pairs;\n}\n\n/** The always-tappable row/card refine trigger — one magnifier, dialog behind it. */\nfunction RefineTrigger({ onOpen, className = '' }: { onOpen: () => void; className?: string }) {\n return (\n <button\n type=\"button\"\n onClick={(e) => { e.stopPropagation(); onOpen(); }}\n className={`p-1.5 rounded text-text-quaternary/70 hover:text-accent hover:bg-surface-hover transition-colors ${className}`}\n title=\"Refine — filter or search by this row's values\"\n aria-label=\"Refine — filter or search by this row's values\"\n data-testid=\"row-refine\"\n >\n <Search className=\"w-3.5 h-3.5\" strokeWidth={1.5} />\n </button>\n );\n}\n\n/** Multi-row pending queue as a facet table. Columns defined by x-lt-columns. */\nfunction FacetTable({ schema, rows, role, onRowClick, onAddFacet, forceView }: {\n schema: ListSchema;\n rows: LTEscalationRecord[];\n role: string;\n onRowClick?: (row: LTEscalationRecord) => void;\n /** RefineDialog \"Add to filters\" — merge into the live filter set. */\n onAddFacet?: (key: string, value: unknown) => void;\n forceView?: boolean;\n}) {\n const navigate = useNavigate();\n const columnDefs = schema['x-lt-columns'] ?? [];\n const rowAction = schema['x-lt-row-action'];\n const [refineRow, setRefineRow] = useState<LTEscalationRecord | null>(null);\n\n // The authored columns render through the SAME table the engineer views\n // use: padded cells, sticky header, and the card fold at narrow widths —\n // a table never scrolls horizontally, it folds. Authors steer the fold\n // with `priority` on each column (1 title line, 2 folds, 3 dropped);\n // undeclared, the first column is the identity.\n //\n // Cells carry DATA only — the full column width belongs to the value, with\n // the full text on hover. Refining lives on the row: one magnifier opens\n // the RefineDialog over every metadata-bound value the row carries.\n const columns: TableColumn<LTEscalationRecord>[] = [\n {\n key: '_status',\n label: '',\n priority: 1,\n className: 'w-10',\n render: (row) => (\n <span\n className={`w-2.5 h-2.5 inline-block rounded-full dot-ring ${escalationDotClass(row)}`}\n title={row.status}\n />\n ),\n },\n ...columnDefs.map((col, i): TableColumn<LTEscalationRecord> => ({\n key: `col-${i}`,\n label: col.label,\n priority: col.priority ?? (i === 0 ? 1 : 2),\n width: col.width ?? (i === 0 && !columnDefs.some((c) => c.width) ? '40%' : undefined),\n render: (row) => {\n const ctx = rowContext(row);\n const text = interpolateHelp(col.value, ctx);\n return (\n <span className=\"block truncate\" title={text && text !== EM_DASH ? text : undefined}>\n <FieldValue raw={text} format={col.format} />\n </span>\n );\n },\n })),\n {\n key: '_refine',\n label: '',\n priority: 1,\n className: 'w-9',\n render: (row) =>\n rowRefinePairs(row, columnDefs).length > 0\n ? <RefineTrigger onOpen={() => setRefineRow(row)} />\n : null,\n },\n {\n // The action column sizes to hold its button — a fixed table won't grow a\n // cell to fit content, so the width is set for the authored label (e.g.\n // \"Start Onboarding\") and the button never wraps or truncates. The\n // description column absorbs the remaining width and truncates instead.\n key: '_action',\n label: '',\n priority: 1,\n className: 'w-44 text-right whitespace-nowrap',\n render: (row) => (\n <RowActionButton row={row} def={rowAction} onView={() => onRowClick?.(row)} forceView={forceView} />\n ),\n },\n ];\n\n return (\n <>\n <DataTable\n columns={columns}\n data={rows}\n layout=\"fixed\"\n keyFn={(row) => row.id}\n onRowClick={onRowClick}\n emptyMessage=\"No pending items.\"\n />\n <RefineDialog\n open={!!refineRow}\n onClose={() => setRefineRow(null)}\n role={role}\n pairs={refineRow ? rowRefinePairs(refineRow, columnDefs) : []}\n onNavigate={navigate}\n onAddFacet={onAddFacet}\n />\n </>\n );\n}\n\nfunction SectionLabel({ children }: { children: React.ReactNode }) {\n return (\n <p className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-3\">{children}</p>\n );\n}\n\n// ── facet-board — one card per entity (machine, station) ─────────────────────\n\ninterface BoardGroup {\n key: string;\n /** The group's identity as stored (native type preserved for the facet URL). */\n rawValue: unknown;\n latest: LTEscalationRecord;\n count: number;\n}\n\n/**\n * Group rows by the resolved x-lt-group-by value; each card renders from the\n * group's most recent row (by created_at). Rows without the facet are skipped —\n * the board reflects the scope, it doesn't invent entities.\n */\nexport function groupBoardRows(rows: LTEscalationRecord[], groupBy: string): BoardGroup[] {\n const dot = groupBy.indexOf('.');\n const facetKey = groupBy.startsWith('metadata.') ? groupBy.slice('metadata.'.length) : null;\n const groups = new Map<string, BoardGroup>();\n for (const row of rows) {\n const ctx = rowContext(row);\n let v: unknown;\n try {\n v = dot === -1\n ? (ctx as unknown as Record<string, unknown>)[groupBy]\n : getDeep((ctx as unknown as Record<string, unknown>)[groupBy.slice(0, dot)], groupBy.slice(dot + 1));\n } catch {\n v = undefined;\n }\n if (v === undefined || v === null || v === '') continue;\n const key = String(v);\n const rawValue = facetKey ? (row.metadata?.[facetKey] ?? v) : v;\n const existing = groups.get(key);\n if (!existing) {\n groups.set(key, { key, rawValue, latest: row, count: 1 });\n } else {\n existing.count += 1;\n if (new Date(row.created_at) > new Date(existing.latest.created_at)) existing.latest = row;\n }\n }\n return [...groups.values()].sort((a, b) => a.key.localeCompare(b.key));\n}\n\n/** A field value token that is a pure metadata binding — facet-linkable. */\nconst METADATA_TOKEN = /^\\{\\{\\s*metadata\\.([a-zA-Z0-9_]+)\\s*\\}\\}$/;\n\nfunction FacetBoard({ schema, rows, role, onOpenDetail, onOpenGroup, onAddFacet, forceView }: {\n schema: ListSchema;\n rows: LTEscalationRecord[];\n role: string;\n forceView?: boolean;\n /** Plain card click — the group's latest row opens in the detail view. */\n onOpenDetail?: (row: LTEscalationRecord) => void;\n /** History affordances — receive a filtered table/timeline deep link. */\n onOpenGroup?: (url: string) => void;\n /** Shift+click — merge one facet into the live filter set (additive). */\n onAddFacet?: (key: string, value: unknown) => void;\n}) {\n const navigate = useNavigate();\n const groupBy = schema['x-lt-group-by'];\n const card = schema['x-lt-card'] ?? {};\n const rowAction = schema['x-lt-row-action'];\n const [refineGroup, setRefineGroup] = useState<BoardGroup | null>(null);\n\n if (!groupBy) {\n return <p className=\"text-xs text-text-tertiary italic\">facet-board needs an x-lt-group-by path.</p>;\n }\n const facetKey = groupBy.startsWith('metadata.') ? groupBy.slice('metadata.'.length) : null;\n const groups = groupBoardRows(rows, groupBy);\n if (groups.length === 0) {\n return <p className=\"text-xs text-text-tertiary italic\">No entities in scope.</p>;\n }\n\n // The card's refinable facts: the entity identity (the group-by facet)\n // plus every metadata-bound card field — one dialog per card, replacing\n // hover-revealed per-field icons (hover-only fails the iPad floor).\n const groupRefinePairs = (g: BoardGroup): RefinePair[] => {\n const pairs: RefinePair[] = [];\n if (facetKey) pairs.push({ key: facetKey, label: facetKey, value: g.rawValue });\n const seen = new Set(pairs.map((p) => p.key));\n for (const f of card.fields ?? []) {\n const bound = f.value.match(METADATA_TOKEN)?.[1];\n if (!bound || seen.has(bound)) continue;\n const raw = g.latest.metadata?.[bound];\n if (raw === undefined || raw === null || raw === '') continue;\n seen.add(bound);\n pairs.push({ key: bound, label: f.label, value: raw });\n }\n return pairs;\n };\n\n return (\n <div className=\"grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-4\" data-testid=\"facet-board\">\n {groups.map((g) => {\n const ctx = rowContext(g.latest);\n const title = card.title ? interpolateHelp(card.title, ctx) : g.key;\n const state = card.state ? interpolateHelp(card.state, ctx) : (g.latest.subtype || g.latest.status);\n const stateHue = typeColor(state);\n const refinable = groupRefinePairs(g).length > 0;\n\n const activate = (e: { shiftKey: boolean }) => {\n if (e.shiftKey && facetKey && onAddFacet) {\n onAddFacet(facetKey, g.rawValue);\n return;\n }\n onOpenDetail?.(g.latest);\n };\n\n return (\n <div\n key={g.key}\n role=\"button\"\n tabIndex={0}\n onClick={activate}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); activate(e); }\n }}\n title={facetKey ? 'Open the latest item · ⇧ click to filter the board' : 'Open the latest item'}\n className=\"group/card border-l-2 border-accent/30 bg-surface-sunken/40 rounded-[0.125em] px-4 py-3.5 cursor-pointer transition-colors hover:bg-surface-sunken/70 focus:outline-none focus-visible:ring-1 focus-visible:ring-accent/40\"\n data-testid=\"facet-board-card\"\n >\n <div className=\"flex items-center justify-between gap-2 mb-2.5\">\n <span className=\"text-2xs font-semibold uppercase tracking-wider text-text-secondary truncate\">\n {title}\n </span>\n <span className=\"flex items-center gap-1 shrink-0\">\n <span\n className=\"px-1.5 py-0.5 rounded text-2xs font-mono font-medium\"\n style={{ color: stateHue.text, backgroundColor: stateHue.bg }}\n title={state}\n >\n {state}\n </span>\n {refinable && <RefineTrigger onOpen={() => setRefineGroup(g)} className=\"-my-1 -mr-1\" />}\n </span>\n </div>\n {card.fields && card.fields.length > 0 && (\n <dl className=\"space-y-1\">\n {card.fields.map((f, i) => {\n const text = interpolateHelp(f.value, ctx);\n return (\n <div key={i} className=\"flex items-baseline justify-between gap-3\">\n <dt className=\"text-2xs uppercase tracking-wider text-text-quaternary shrink-0\">{f.label}</dt>\n <dd\n className=\"min-w-0 truncate text-2xs text-text-primary\"\n title={text && text !== EM_DASH ? text : undefined}\n >\n <FieldValue raw={text} format={f.format} />\n </dd>\n </div>\n );\n })}\n </dl>\n )}\n\n <div className=\"mt-3 flex justify-end\">\n <RowActionButton row={g.latest} def={rowAction} onView={() => onOpenDetail?.(g.latest)} forceView={forceView} />\n </div>\n </div>\n );\n })}\n\n <RefineDialog\n open={!!refineGroup}\n onClose={() => setRefineGroup(null)}\n role={role}\n pairs={refineGroup ? groupRefinePairs(refineGroup) : []}\n onNavigate={onOpenGroup ?? navigate}\n onAddFacet={onAddFacet}\n />\n </div>\n );\n}\n\nexport function EscalationListView({ role, listSchema, activeEscalations, onRowClick, onOpenGroup, onAddFacet, forceViewAction, total, page, totalPages, pageSize, onPageChange, onPageSizeChange }: {\n role: string;\n listSchema: ListSchema;\n activeEscalations: LTEscalationRecord[];\n onRowClick?: (row: LTEscalationRecord) => void;\n /** facet-board history affordances — receive a filtered deep link. */\n onOpenGroup?: (url: string) => void;\n /** facet-board ⇧ click — merge one facet into the live filter set. */\n onAddFacet?: (key: string, value: unknown) => void;\n /** Render claim row-actions as view actions. For surfaces listing rows the\n * viewer already holds (e.g. My Escalations), where a claim gesture is\n * inapplicable — the button opens the detail page instead. */\n forceViewAction?: boolean;\n total?: number;\n page?: number;\n totalPages?: number;\n pageSize?: number;\n onPageChange?: (page: number) => void;\n onPageSizeChange?: (size: number) => void;\n}) {\n const layout = listSchema['x-lt-layout'];\n const card = listSchema['x-lt-active'] ?? {};\n const rowAction = listSchema['x-lt-row-action'];\n const active = activeEscalations[0];\n const help = listSchema['x-lt-help'];\n useAgeTick(schemaUsesAge(listSchema));\n\n // The active item is a distinct surface on the page wash — the same card\n // treatment the detail page gives its form sections. The label heads the\n // card; the history column beside it stays a quiet chronicle on the wash.\n const activeBlock = (\n <div className=\"border border-surface-border/60 bg-surface-sunken rounded-[0.25em] p-4\">\n <SectionLabel>Active</SectionLabel>\n {active ? (\n <ActiveCard esc={active} card={card} rowAction={rowAction} onOpen={() => onRowClick?.(active)} forceView={forceViewAction} />\n ) : (\n <p className=\"text-xs text-text-tertiary italic\">No active item right now.</p>\n )}\n </div>\n );\n\n const header = help && active ? (\n <div className=\"mb-8\"><MarkdownRenderer content={interpolateHelp(help, rowContext(active))} /></div>\n ) : help ? (\n <div className=\"mb-8\"><MarkdownRenderer content={help} /></div>\n ) : null;\n\n if (layout === 'facet-table') {\n // The table stands alone — no header text above it. Instructions belong\n // in the form's help surfaces; totals live in the pagination bar.\n const resolvedTotal = total ?? activeEscalations.length;\n return (\n <div>\n <FacetTable schema={listSchema} rows={activeEscalations} role={role} onRowClick={onRowClick} onAddFacet={onAddFacet} forceView={forceViewAction} />\n {page !== undefined && totalPages !== undefined && onPageChange && (\n <StickyPagination\n page={page}\n totalPages={totalPages}\n onPageChange={onPageChange}\n total={resolvedTotal}\n pageSize={pageSize ?? 25}\n onPageSizeChange={onPageSizeChange}\n />\n )}\n </div>\n );\n }\n\n if (layout === 'facet-board') {\n return (\n <div>\n {header}\n <FacetBoard\n schema={listSchema}\n rows={activeEscalations}\n role={role}\n onOpenDetail={onRowClick}\n onOpenGroup={onOpenGroup}\n onAddFacet={onAddFacet}\n forceView={forceViewAction}\n />\n {page !== undefined && totalPages !== undefined && onPageChange && totalPages > 1 && (\n <StickyPagination\n page={page}\n totalPages={totalPages}\n onPageChange={onPageChange}\n total={total ?? activeEscalations.length}\n pageSize={pageSize ?? 25}\n onPageSizeChange={onPageSizeChange}\n />\n )}\n </div>\n );\n }\n\n if (layout === 'active-history') {\n return (\n <div>\n {header}\n <div className=\"grid grid-cols-1 @split:grid-cols-[1.6fr_1fr] gap-8 @split:gap-12 items-start\">\n {activeBlock}\n {/* pt-4 seats the History label on the Active label's optical line\n (the card's own padding provides that inset on the left). */}\n <div className=\"@split:pt-4\">\n <SectionLabel>History</SectionLabel>\n <HistoryColumn role={role} def={listSchema['x-lt-history'] ?? {}} onRowClick={onRowClick} />\n </div>\n </div>\n </div>\n );\n }\n\n // \"active\" (or any non-table layout): just the active card.\n return (\n <div>\n {header}\n {activeBlock}\n </div>\n );\n}\n"],"names":["BLOCKED_KEYS","parsePath","path","segs","raw","m","name","brackets","b","setDeep","root","value","node","i","seg","next","childKey","wantArray","last","getDeep","bindPathFor","propName","propDef","bind","mapFormToPayload","formValues","formSchema","props","payload","def","mapPayloadToForm","form","v","HELP_DOMAINS","TOKEN_PATTERN","MISSING_VALUE","formatTokenValue","interpolateHelp","template","ctx","_match","rawPath","dot","domain","resolveHelpSource","schema","help","context","buildHelpMarkdown","source","defaultHelpMarkdown","isTerminal","status","claimed","claimedByMe","schemaNeedsEnvelope","fragment","s","isEffectivelyClaimed","esc","isAckEscalation","PALETTE","hash","str","h","typeColor","typeName","RefineDialog","open","onClose","role","pairs","onNavigate","onAddFacet","selected","setSelected","useState","prevOpen","setPrevOpen","toggle","key","prev","chosen","p","facets","none","go","url","jsx","Modal","jsxs","on","Check","metadataFacetsUrl","escalationDotClass","e","STATUS_DOT_STYLES","useAgeTick","enabled","setTick","useEffect","t","n","schemaUsesAge","_a","f","rowContext","parse","ISO_DATETIME","EM_DASH","FieldValue","format","UserName","d","formatAgoCompact","DateValue","DEFAULT_CLAIM_MINUTES","isClaimable","row","RowActionButton","onView","prominent","forceView","authored","action","label","claim","useClaimEscalation","navigate","useNavigate","location","useLocation","error","setError","spent","fire","err","classes","ActiveCard","card","rowAction","onOpen","title","MarkdownRenderer","HistoryColumn","onRowClick","show","setShow","query","useEscalations","rows","total","_b","rowDef","rowRefinePairs","columnDefs","seen","col","bound","METADATA_TOKEN","RefineTrigger","className","Search","FacetTable","refineRow","setRefineRow","columns","c","text","Fragment","DataTable","SectionLabel","children","groupBoardRows","groupBy","facetKey","groups","rawValue","existing","FacetBoard","onOpenDetail","onOpenGroup","refineGroup","setRefineGroup","groupRefinePairs","g","state","stateHue","refinable","activate","EscalationListView","listSchema","activeEscalations","forceViewAction","page","totalPages","pageSize","onPageChange","onPageSizeChange","layout","active","activeBlock","header","resolvedTotal","StickyPagination"],"mappings":"wbAgBA,MAAMA,GAAe,IAAI,IAAI,CAAC,YAAa,cAAe,WAAW,CAAC,EAG/D,SAASC,EAAUC,EAAyB,CACjD,MAAMC,EAAkB,CAAA,EACxB,UAAWC,KAAOF,EAAK,MAAM,GAAG,EAAG,CACjC,MAAMG,EAAID,EAAI,MAAM,2BAA2B,EAC/C,GAAI,CAACC,EAAG,MAAM,IAAI,MAAM,oCAAoCD,CAAG,GAAG,EAClE,KAAM,CAAA,CAAGE,EAAMC,CAAQ,EAAIF,EAC3B,GAAIC,EAAM,CACR,GAAIN,GAAa,IAAIM,CAAI,QAAS,IAAI,MAAM,kCAAkCA,CAAI,GAAG,EACrFH,EAAK,KAAK,CAAE,IAAKG,CAAA,CAAM,CACzB,CACA,UAAWE,KAAKD,EAAS,MAAM,MAAM,GAAK,CAAA,EAAIJ,EAAK,KAAK,CAAE,MAAO,OAAOK,CAAC,EAAG,CAC9E,CACA,GAAIL,EAAK,SAAW,EAAG,MAAM,IAAI,MAAM,0BAA0BD,CAAI,GAAG,EACxE,OAAOC,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.js";import{P as E}from"./PageHeader-Di5Sz3an.js";import{u as J}from"./useYamlActivityEvents-CoTsia7t.js";import{R as P}from"./RunAsSelector-fFMt1bGe.js";import{b as $}from"./helpers-DzO-OGPe.js";import{X as z,aE as A,az as M,j as w,b as T,$ as W}from"./vendor-icons-DeBdvyKJ.js";import{L as F,f as q}from"./vendor-react-_9U4mKFr.js";import{T as G}from"./ToolPill-FkgTXIhq.js";import{N as B}from"./NamespacePill-Bb3revqD.js";import"./index-CIwlVfvV.js";import"./BotPicker-CGCnIz8I.js";import"./bots-B97itB3I.js";const k={mcp:{border:"border-status-active",text:"text-status-active",icon:"MCP"},db:{border:"border-status-active",text:"text-status-active",icon:"DB"},llm:{border:"border-accent",text:"text-accent",icon:"LLM"},transform:{border:"border-status-success",text:"text-status-success",icon:"Map"}};function U({steps:a,manifest:x,isComplete:i}){const n=x.filter(t=>t.type==="worker"),u=n.length,s=n.map(t=>{const r=a.find(f=>f.activityId===t.activity_id),d=t.tool_source||"mcp",m=k[d]||k.mcp;return{activityId:t.activity_id,title:t.title||t.mcp_tool_name||t.activity_id,toolName:t.mcp_tool_name,colors:m,status:(r==null?void 0:r.status)||"pending",error:r==null?void 0:r.error}});return e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs text-text-secondary mb-3",children:i?`All ${u} steps completed`:`Running step ${s.filter(t=>t.status==="completed").length+1} of ${u}...`}),e.jsx("div",{className:"space-y-0",children:s.map((t,r)=>{const d=r===s.length-1;return e.jsxs("div",{className:"flex items-stretch gap-2",children:[e.jsxs("div",{className:"flex flex-col items-center w-4 shrink-0",children:[e.jsx("span",{className:`w-2.5 h-2.5 rounded-full shrink-0 border-2 transition-colors ${t.status==="completed"?"bg-status-success border-status-success":t.status==="running"?`${t.colors.border} bg-transparent animate-pulse`:t.status==="failed"?"bg-status-error border-status-error":"bg-surface-sunken border-surface-border"}`}),!d&&e.jsx("span",{className:`w-px flex-1 transition-colors ${t.status==="completed"?"bg-status-success/30":"bg-surface-border"}`})]}),e.jsxs("div",{className:d?"":"pb-3",children:[e.jsx("p",{className:`text-2xs font-medium ${t.status==="running"?"text-text-primary":t.status==="completed"?"text-text-secondary":t.status==="failed"?"text-status-error":"text-text-tertiary"}`,children:t.title}),t.toolName&&e.jsx("span",{className:"text-2xs text-text-tertiary font-mono",children:t.toolName}),t.error&&e.jsx("p",{className:"text-2xs text-status-error mt-0.5",children:t.error})]})]},t.activityId)})})]})}function Y({workflow:a,onClose:x}){const i=L(),[n,u]=l.useState(!1),[s,t]=l.useState({}),[r,d]=l.useState(""),[m,f]=l.useState(""),[g,S]=l.useState(""),[h,j]=l.useState(null),[N,b]=l.useState(null),{steps:C,isComplete:y}=J(h);l.useEffect(()=>{j(null),b(null),f(""),i.reset();const c=$(a.input_schema);t(c),d(JSON.stringify(c,null,2)),u(!1)},[a.id]),l.useEffect(()=>{if(y&&h){const c=h,o=setTimeout(()=>{b({jobId:c}),j(null)},800);return()=>clearTimeout(o)}},[y,h]);const _=()=>{if(!n)d(JSON.stringify(s,null,2));else try{t(JSON.parse(r))}catch{}u(!n)},I=async()=>{f(""),b(null);let c;if(n)try{c=JSON.parse(r)}catch{f("Invalid JSON");return}else c={...s};try{const o=await i.mutateAsync({id:a.id,data:c,sync:!1,...g?{execute_as:g}:{}});o.job_id&&j(o.job_id)}catch{}},v=!!h,R=a.app_id||"";return e.jsxs("div",{className:"border-l border-surface-border bg-surface-raised flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border shrink-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-text-primary truncate",children:a.app_id}),e.jsx("code",{className:"text-2xs font-mono text-accent truncate block",children:a.graph_topic})]}),e.jsx("button",{onClick:()=>{v||x()},className:"p-1 text-text-tertiary hover:text-text-primary shrink-0 ml-2",children:e.jsx(z,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-4",children:v?e.jsx(U,{steps:C,manifest:a.activity_manifest,isComplete:y}):N?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-status-success",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm3.36 4.65a.5.5 0 00-.72 0L7 9.29 5.36 7.65a.5.5 0 10-.72.7l2 2a.5.5 0 00.72 0l4-4a.5.5 0 000-.7z"})}),e.jsx("p",{className:"text-xs font-medium text-status-success",children:"Workflow completed"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(F,{to:`/mcp/executions/${encodeURIComponent(N.jobId)}?namespace=${encodeURIComponent(R)}`,className:"inline-flex items-center gap-1.5 text-xs text-accent hover:underline",children:[e.jsx(A,{size:12})," View execution"]}),e.jsxs("button",{onClick:()=>b(null),className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[e.jsx(M,{size:12})," Run again"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{selected:g,onChange:S}),a.description&&e.jsx("p",{className:"text-2xs text-text-secondary leading-relaxed",children:a.description}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:"Input"}),e.jsx("button",{onClick:_,className:"text-2xs text-accent hover:underline",children:n?"Form view":"JSON view"})]}),n?e.jsx("textarea",{value:r,onChange:c=>d(c.target.value),className:"w-full bg-surface-sunken border border-surface-border rounded-md px-3 py-2 font-mono text-2xs text-text-primary focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary resize-y",rows:6,spellCheck:!1}):e.jsxs("div",{className:"space-y-3 max-h-[300px] overflow-y-auto",children:[Object.entries(s).map(([c,o])=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:c}),typeof o=="boolean"?e.jsxs("select",{value:String(o),onChange:p=>t({...s,[c]:p.target.value==="true"}),className:"w-full bg-surface-sunken border border-surface-border rounded-md px-3 py-1.5 text-xs text-text-primary focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary",children:[e.jsx("option",{value:"true",children:"true"}),e.jsx("option",{value:"false",children:"false"})]}):typeof o=="object"?e.jsx("textarea",{value:JSON.stringify(o,null,2),onChange:p=>{try{t({...s,[c]:JSON.parse(p.target.value)})}catch{}},className:"w-full min-h-[60px] px-3 py-1.5 bg-surface-sunken border border-surface-border rounded-md font-mono text-xs text-text-primary resize-y focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"}):e.jsx("input",{type:typeof o=="number"?"number":"text",value:String(o??""),onChange:p=>t({...s,[c]:typeof o=="number"?Number(p.target.value):p.target.value}),className:"w-full bg-surface-sunken border border-surface-border rounded-md px-3 py-1.5 text-xs text-text-primary focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"})]},c)),Object.keys(s).length===0&&e.jsx("p",{className:"text-2xs text-text-tertiary italic",children:"No input fields defined"})]}),m&&e.jsx("p",{className:"text-2xs text-status-error mt-1",children:m})]}),i.isError&&e.jsx("div",{className:"bg-status-error/10 border border-status-error/20 rounded-md px-3 py-2",children:e.jsx("p",{className:"text-2xs text-status-error",children:i.error instanceof Error?i.error.message:"Invocation failed"})}),e.jsx("button",{onClick:I,disabled:i.isPending,className:"btn-primary text-xs disabled:opacity-50 inline-flex items-center gap-1.5",children:i.isPending?"Starting...":e.jsxs(e.Fragment,{children:[e.jsx(w,{size:12})," Run"]})})]})})]})}function H({flows:a,selectedId:x,onSelect:i}){const[n,u]=l.useState(""),s=l.useMemo(()=>{if(!n.trim())return a;const t=n.toLowerCase();return a.filter(r=>{var d,m;return r.graph_topic.toLowerCase().includes(t)||((d=r.description)==null?void 0:d.toLowerCase().includes(t))||((m=r.app_id)==null?void 0:m.toLowerCase().includes(t))})},[a,n]);return e.jsxs("div",{children:[e.jsxs("div",{className:"sticky top-0 z-20 bg-surface pt-4",children:[e.jsx("div",{className:"bg-surface-sunken rounded-lg px-4 py-2 mb-3",children:e.jsxs("div",{className:"relative w-1/2",children:[e.jsx(T,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-text-quaternary pointer-events-none"}),e.jsx("input",{type:"text",value:n,onChange:t=>u(t.target.value),placeholder:`Search ${a.length} flows…`,className:"input pl-8"})]})}),e.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-surface-border",children:[e.jsx(W,{className:"w-3 h-3 text-accent",strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:"Graph Flows"}),e.jsx("span",{className:"text-xs text-text-quaternary",children:s.length})]})]}),s.length===0?e.jsx("p",{className:"text-sm text-text-tertiary py-8 text-center",children:"No flows match your search."}):e.jsx("div",{className:"divide-y divide-surface-border/30",children:s.map(t=>{const r=x===t.id;return e.jsxs("button",{onClick:()=>i(t),className:"group relative w-full text-left py-2 px-3 -mx-3 rounded-md transition-colors duration-150",children:[r&&e.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 bg-accent rounded-full"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(G,{name:t.graph_topic,size:"md"}),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("span",{className:"ml-auto shrink-0",children:e.jsx(B,{namespace:t.app_id})})]})]},t.id)})})]})}function ie(){const[a,x]=q(),i=a.get("id")??"",{data:n,isLoading:u}=O({status:"active",limit:200,offset:0}),s=(n==null?void 0:n.workflows)??[],t=s.find(r=>r.id===i)??null;return l.useEffect(()=>{s.length===1&&!a.get("id")&&x({id:s[0].id},{replace:!0})},[s.length]),u?e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-48"}),e.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]}):e.jsxs("div",{children:[e.jsx(E,{title:"Invoke",docsHash:"#docs:dashboard.md:graph-workflows"}),s.length===0?e.jsxs("div",{className:"py-16 text-center",children:[e.jsx("p",{className:"text-sm text-text-primary mb-1",children:"No active graph flows"}),e.jsx("p",{className:"text-xs text-text-tertiary",children:"Register graph flows at startup with the graphWorkflows config, or deploy one from Configure."})]}):e.jsxs("div",{className:"grid grid-cols-3 gap-8 items-start",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(H,{flows:s,selectedId:i,onSelect:r=>x({id:r.id},{replace:!0})})}),e.jsx("div",{className:"sticky top-4 transition-all duration-200 ease-out",children:t?e.jsx(Y,{workflow:t,onClose:()=>x({},{replace:!0})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[e.jsx(w,{className:"w-6 h-6 text-text-quaternary mb-3",strokeWidth:1}),e.jsx("p",{className:"text-sm text-text-tertiary",children:"Select a flow"}),e.jsx("p",{className:"text-xs text-text-quaternary mt-1",children:"Choose one from the list to run it."})]})})]})]})}export{ie as GraphInvokePage};
2
- //# sourceMappingURL=GraphInvokePage-CKtvWowP.js.map
@@ -1,2 +0,0 @@
1
- import{a as x,j as e}from"./vendor-query-DvWWuNIB.js";import{a0 as z,j as Ne,a5 as pe,au as we,bi as ke,bc as he,_ as fe,Q as _e,bj as Ce,t as Ee,l as Pe,bd as Re,w as Se,at as qe,a4 as Fe,bk as Me,g as U}from"./index-CIwlVfvV.js";import{u as Te}from"./pipelines-B5GcgCeF.js";import{u as $e}from"./controlplane-YxvP1KCa.js";import{R as Ie}from"./RolePill-DhnVPK4q.js";import{W as O}from"./WorkflowPill--AYMW7u_.js";import{L as E}from"./ListToolbar-DdJzj472.js";import{j as Ae,b as Qe,P as We}from"./OperationsPage-aLHHAP2X.js";import{i as Be}from"./task-queues-7-sHKPsN.js";import{bU as Le,aE as f,ap as De,a0 as Ue,bB as re,I as j,k as le,W as ce}from"./vendor-icons-DeBdvyKJ.js";import{u as B,f as Oe}from"./vendor-react-_9U4mKFr.js";import"./EntityTimelinePanel-CkF-oW-m.js";import"./PageHeader-Di5Sz3an.js";function ze(){const{user:s}=z();return x.useMemo(()=>{const n=((s==null?void 0:s.roles)??[]).map(t=>t.role).filter(t=>!Be(t));return Array.from(new Set(n)).sort((t,i)=>t.localeCompare(i))},[s])}function He(){const{user:s}=z(),n=s==null?void 0:s.userId,t=Ne("SUMMARY"),{data:i}=pe({assigned_to:n,status:"pending",limit:1});return we(ke(),()=>{n&&t([["escalations"]])}),(i==null?void 0:i.total)??0}function D({n:s,label:n,tone:t}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:`text-2xl font-light tabular-nums leading-none ${t==="muted"?"text-text-tertiary":"text-text-primary"}`,children:s}),e.jsx("div",{className:"text-2xs uppercase tracking-wider text-text-quaternary mt-1 truncate",children:n})]})}function Ve({role:s,title:n,metric:t,priorityFacet:i,periodLabel:l}){const d=B(),r=(t==null?void 0:t.pending)??0,u=(t==null?void 0:t.claimed)??0,g=(t==null?void 0:t.resolved)??0,m=(t==null?void 0:t.priority_count)??0;return e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>d(`/escalations/available?role=${encodeURIComponent(s)}`),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),d(`/escalations/available?role=${encodeURIComponent(s)}`))},className:"group h-full border-l-2 border-accent/30 bg-surface-sunken/40 rounded-[0.125em] px-4 py-3.5 cursor-pointer transition-colors hover:bg-surface-sunken/70 focus:outline-none focus-visible:ring-1 focus-visible:ring-accent/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-3",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary truncate",children:n||s}),e.jsx(f,{className:"w-3 h-3 shrink-0 text-text-quaternary opacity-0 group-hover:opacity-100 transition-opacity",strokeWidth:1.5})]}),e.jsxs("div",{className:"flex items-baseline gap-5",children:[e.jsx(D,{n:r,label:"pending"}),e.jsx(D,{n:u,label:"claimed"}),e.jsx(D,{n:g,label:`resolved · ${l}`,tone:"muted"})]}),e.jsx("div",{className:"mt-3 h-6 flex items-center",children:m>0?e.jsxs("button",{type:"button",onClick:p=>{p.stopPropagation(),d(Ae({role:s,priority_facet:i}))},className:"inline-flex items-center gap-1.5 pl-1.5 pr-2.5 py-1 rounded-full text-2xs font-semibold tabular-nums bg-status-error text-text-inverse transition-transform hover:scale-[1.05]",title:"Past the priority threshold — a hard limit; open oldest first",children:[e.jsx(De,{className:"w-3 h-3",strokeWidth:2.5}),m," in jeopardy"]}):e.jsx("span",{className:"text-2xs text-text-quaternary",children:"on pace"})})]})}function de({count:s}){const n=B();return e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>n("/escalations/queue"),onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),n("/escalations/queue"))},className:"group h-full border-l-2 border-status-warning/70 bg-status-warning/[0.06] rounded-[0.125em] px-4 py-3.5 cursor-pointer transition-colors hover:bg-status-warning/[0.1] focus:outline-none focus-visible:ring-1 focus-visible:ring-status-warning/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-2xs font-semibold uppercase tracking-wider text-status-warning",children:[e.jsx(Le,{className:"w-3 h-3",strokeWidth:2}),"Claimed"]}),e.jsx(f,{className:"w-3 h-3 shrink-0 text-text-quaternary opacity-0 group-hover:opacity-100 transition-opacity",strokeWidth:1.5})]}),e.jsx("div",{className:"text-2xl font-light tabular-nums leading-none text-text-primary",children:s}),e.jsx("div",{className:"text-2xs uppercase tracking-wider text-text-quaternary mt-1",children:"assigned to you"}),e.jsx("div",{className:"mt-3 h-6 flex items-center",children:e.jsx("span",{className:"text-2xs font-medium text-status-warning",children:s>0?"Finish these first →":"Nothing claimed"})})]})}const Ke=["15m","1h","24h","7d"];function Ye({maxRows:s}){const[n,t]=x.useState("24h"),i=ze(),l=He(),d=he(n),r=fe(),u=x.useMemo(()=>{var o;return new Map((((o=d.data)==null?void 0:o.stations)??[]).map(c=>[c.role,c]))},[d.data]),g=x.useMemo(()=>{var o;return new Map((((o=r.data)==null?void 0:o.roles)??[]).map(c=>[c.role,c]))},[r.data]),m=x.useMemo(()=>[...i].sort((o,c)=>{var v,M;const y=((v=u.get(o))==null?void 0:v.priority_count)??0,S=((M=u.get(c))==null?void 0:M.priority_count)??0;return S!==y?S-y:o.localeCompare(c)}),[i,u]),F=s*4-1,R=m.slice(0,F),b=m.length-R.length;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-surface-border",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-sm font-medium text-text-primary",children:[e.jsx(Ue,{className:"w-4 h-4 text-accent",strokeWidth:1.5}),"Task Queues"]}),e.jsx("div",{className:"flex items-center gap-0.5",children:Ke.map(o=>e.jsx("button",{onClick:()=>t(o),className:`px-2.5 py-1 text-2xs font-mono rounded transition-colors ${n===o?"bg-accent/10 text-accent font-semibold":"text-text-quaternary hover:text-text-secondary"}`,children:o},o))})]}),i.length===0?e.jsxs("div",{className:"grid grid-cols-1 @grp-cols:grid-cols-2 @wall:grid-cols-4 gap-4",children:[e.jsx(de,{count:l}),e.jsx("div",{className:"lg:col-span-3 flex items-center px-4 py-3.5 text-sm text-text-tertiary",children:"You are not a member of a role. Task queues appear here once you join one."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 @grp-cols:grid-cols-2 @wall:grid-cols-4 gap-4 auto-rows-fr",children:[e.jsx(de,{count:l}),R.map(o=>{var c,y;return e.jsx(Ve,{role:o,title:((c=g.get(o))==null?void 0:c.title)??null,metric:u.get(o),priorityFacet:((y=g.get(o))==null?void 0:y.priority_facet)??null,periodLabel:n},o)})]}),b>0&&e.jsxs("p",{className:"mt-3 text-2xs text-text-quaternary",children:["+",b," more ",b===1?"lane":"lanes"," in the Task Queues sidebar."]})]})]})}const Ge={completed:"bg-status-success",active:"bg-status-active",running:"bg-status-active",pending:"bg-status-pending",error:"bg-status-error",failed:"bg-status-error"};function xe(s){return Ge[s]??"bg-text-tertiary"}function k({icon:s,text:n}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[e.jsx(s,{className:"w-6 h-6 text-text-quaternary/50 mb-2",strokeWidth:1}),e.jsx("p",{className:"text-xs text-text-quaternary",children:n})]})}function Je(s,n=37){if(!s||s.length<=n)return s;const t=Math.floor((n-3)/2);return`${s.slice(0,t)}...${s.slice(-t)}`}function ue({dot:s,pill:n,id:t,date:i,onClick:l}){return e.jsxs("button",{onClick:l,className:"w-full text-left hover:bg-surface-hover/50 rounded-md px-1 py-1.5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("span",{className:`w-2.5 h-2.5 rounded-full dot-ring shrink-0 ${s}`}),e.jsx("span",{className:"text-xs text-text-primary font-mono truncate flex-1 min-w-0",children:Je(t)}),e.jsx("span",{className:"hidden @dict-inline:inline text-2xs text-text-quaternary shrink-0 whitespace-nowrap",children:e.jsx(U,{date:i})})]}),e.jsxs("div",{className:"pl-3.5 flex items-center gap-1 overflow-hidden",children:[n,e.jsx("span",{className:"flex-1 min-w-0"}),e.jsx("span",{className:"@dict-inline:hidden text-2xs text-text-quaternary shrink-0 whitespace-nowrap",children:e.jsx(U,{date:i})})]})]})}function W({esc:s,onClick:n}){const t=e.jsx(U,{date:s.updated_at??s.created_at});return e.jsxs("button",{onClick:n,className:"w-full text-left hover:bg-surface-hover/50 rounded-md px-1 py-1.5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsxs("span",{className:"text-2xs text-text-quaternary font-medium shrink-0",children:["P",s.priority??2]}),e.jsx("span",{className:"text-xs text-text-primary truncate flex-1 min-w-0",children:s.description||s.subtype||s.type}),e.jsx("span",{className:"hidden @dict-inline:inline text-2xs text-text-quaternary shrink-0",children:t})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-5 overflow-hidden",children:[e.jsx("span",{className:"hidden @dict-inline:inline-flex min-w-0",children:e.jsx(O,{type:s.type||"unknown",size:"xs"})}),e.jsx("span",{className:"flex-1 min-w-0"}),e.jsx(Ie,{role:s.role}),e.jsx("span",{className:"@dict-inline:hidden text-2xs text-text-quaternary shrink-0",children:t})]})]})}function _({to:s,icon:n,title:t}){const i=B();return e.jsx("button",{onClick:()=>i(s),className:"text-text-quaternary hover:text-accent transition-colors",title:t,children:e.jsx(n,{className:"w-2.5 h-2.5",strokeWidth:1.5})})}function me({appIds:s,selected:n,onSelect:t}){const[i,l]=x.useState(!1),d=x.useRef(null);return x.useEffect(()=>{if(!i)return;const r=u=>{d.current&&!d.current.contains(u.target)&&l(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[i]),s.length<=1?null:e.jsxs("div",{className:"relative mb-3 -mt-2",ref:d,children:[e.jsxs("button",{onClick:()=>l(r=>!r),className:"flex items-center gap-1 px-2 py-0.5 text-2xs rounded bg-accent/10 text-accent hover:bg-accent/20 transition-colors",children:[n,e.jsx("svg",{className:`w-2.5 h-2.5 transition-transform ${i?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),i&&e.jsx("div",{className:"absolute top-full left-0 mt-1 bg-surface-raised border border-surface-border rounded-md shadow-lg z-[100] py-1 min-w-[120px]",children:s.map(r=>e.jsx("button",{onClick:()=>{t(r),l(!1)},className:`w-full text-left px-3 py-1.5 text-2xs transition-colors ${n===r?"text-accent bg-accent/5":"text-text-secondary hover:bg-surface-hover"}`,children:r},r))})]})}function P({icon:s,title:n,count:t,actions:i,children:l}){return e.jsxs("div",{className:"flex-1 min-w-0 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between pt-4 pb-2 px-5 shrink-0 border-b border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s,{className:"w-3.5 h-3.5 text-accent/60",strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:n}),t!==void 0&&t>0&&e.jsx("span",{className:"px-1.5 py-0.5 rounded-full bg-accent/10 text-accent text-2xs font-semibold tabular-nums",children:Me(t)})]}),i&&e.jsx("div",{className:"flex items-center gap-2",children:i})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto py-2 px-5 @container",children:l})]})}function xs(){var G,J,X,Z,ee,se,te,ae;const s=B(),{user:n}=z(),{isBuilder:t}=_e(),i=Ce(),[l,d]=Oe(),{data:r}=$e({enabled:t}),u=x.useMemo(()=>((r==null?void 0:r.apps)??[]).map(a=>a.appId).sort(),[r]),g=u[0]??"",m=l.get("pipelinenamespace")||g,p=l.get("durablenamespace")||g,F=x.useCallback((a,A)=>{d(Q=>{const C=new URLSearchParams(Q);return C.set(a,A),C},{replace:!1})},[d]);Ee(),Pe(),Re();const R=!i.showTaskQueueCards,b=i.canSeeWorkflows&&!i.canSeePaceBoard,o=fe({enabled:i.canSeePaceBoard}),{values:c}=Se(),y=x.useMemo(()=>Object.keys(c).length?c:void 0,[c]),S=he("1h",y,{enabled:i.canSeePaceBoard}),v=qe({limit:5,sort_by:"updated_at",order:"desc",namespace:p},{enabled:b}),M=u,je=u,T=Te({limit:5,app_id:m,sort_by:"updated_at",order:"desc"},{enabled:b}),N=Fe({limit:5,sort_by:"created_at",order:"desc",enabled:R}),w=pe({assigned_to:n==null?void 0:n.userId,status:"pending",limit:5,sort_by:"created_at",order:"desc",enabled:R});x.useEffect(()=>{const a=setTimeout(()=>{w.refetch(),N.refetch()},2e3);return()=>clearTimeout(a)},[]);const q=x.useMemo(()=>{var ne,ie,oe;const a=((ne=o.data)==null?void 0:ne.roles)??[],A=Qe(a),Q=(ie=a.find(h=>h.ops_home_default))==null?void 0:ie.role,C=Q&&A.find(h=>h.stations.some(L=>L.role.role===Q))||A[0],ye=(C==null?void 0:C.stations)??[],ve=((oe=S.data)==null?void 0:oe.stations)??[];return ye.map(({role:h})=>({role:h.role,title:h.title,parent_role:h.parent_role,target_per_hour:h.target_per_hour??null,upstream_roles:h.upstream_roles??[],metric:ve.find(L=>L.role===h.role)}))},[o.data,S.data]),H=((G=v.data)==null?void 0:G.jobs)??[],ge=(J=v.data)==null?void 0:J.total,V=((X=T.data)==null?void 0:X.jobs)??[],be=(Z=T.data)==null?void 0:Z.total,$=((ee=N.data)==null?void 0:ee.escalations)??[],K=(se=N.data)==null?void 0:se.total,I=((te=w.data)==null?void 0:te.escalations)??[],Y=(ae=w.data)==null?void 0:ae.total;return i.showTaskQueueCards?e.jsxs("div",{children:[e.jsx("h1",{className:"heading-1 mb-6",children:"Console"}),e.jsx(Ye,{maxRows:2})]}):i.canSeePaceBoard?e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 px-5 shrink-0 border-b border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:"w-3.5 h-3.5 text-accent/60",strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:"Pace Board"}),q.length>0&&e.jsxs("span",{className:"text-2xs text-text-quaternary",children:[q.length," ",q.length===1?"station":"stations"," · 1h"]})]}),e.jsx(_,{to:"/pace",icon:f,title:"Open the full Pace Board"})]}),e.jsx("div",{className:"flex-1 min-h-0 cursor-pointer",onClick:()=>s("/pace"),children:q.length===0?e.jsx(k,{icon:re,text:"No roles yet — mark roles visible on the Pace Board"}):e.jsx(We,{stations:q,selectedRole:null,onSelect:()=>s("/pace"),onUpstreamSelect:()=>s("/pace"),periodHours:1,logScale:!0,fill:!0})})]}),e.jsxs("div",{className:"hidden sm:flex flex-1 min-h-0 border-t border-surface-border",children:[e.jsx(P,{icon:j,title:"All Escalations",count:K,actions:e.jsxs(e.Fragment,{children:[e.jsx(E,{onRefresh:()=>N.refetch(),isFetching:N.isFetching,apiPath:"/escalations?status=pending&limit=5&sort_by=created_at&order=desc"}),e.jsx(_,{to:"/escalations/available",icon:f,title:"All escalations"})]}),children:$.length===0?e.jsx(k,{icon:j,text:"No pending escalations"}):e.jsx("div",{className:"space-y-0.5",children:$.map(a=>e.jsx(W,{esc:a,onClick:()=>s(`/escalations/detail/${a.id}`)},a.id))})}),e.jsx("div",{className:"w-px bg-surface-border shrink-0"}),e.jsx(P,{icon:j,title:"My Escalations",count:Y,actions:e.jsxs(e.Fragment,{children:[e.jsx(E,{onRefresh:()=>w.refetch(),isFetching:w.isFetching,apiPath:`/escalations?assigned_to=${(n==null?void 0:n.userId)??""}&status=pending&limit=5&sort_by=created_at&order=desc`}),e.jsx(_,{to:"/escalations/queue",icon:f,title:"My escalation queue"})]}),children:I.length===0?e.jsx(k,{icon:j,text:"No assigned escalations"}):e.jsx("div",{className:"space-y-0.5",children:I.map(a=>e.jsx(W,{esc:a,onClick:()=>s(`/escalations/detail/${a.id}`)},a.id))})})]})]}):e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"flex-1 min-h-0 flex border-b border-surface-border",children:[e.jsx(P,{icon:j,title:"All Escalations",count:K,actions:e.jsxs(e.Fragment,{children:[e.jsx(E,{onRefresh:()=>N.refetch(),isFetching:N.isFetching,apiPath:"/escalations?status=pending&limit=5&sort_by=created_at&order=desc"}),e.jsx(_,{to:"/escalations/available",icon:f,title:"All escalations"})]}),children:$.length===0?e.jsx(k,{icon:j,text:"No pending escalations"}):e.jsx("div",{className:"space-y-0.5",children:$.map(a=>e.jsx(W,{esc:a,onClick:()=>s(`/escalations/detail/${a.id}`)},a.id))})}),e.jsx("div",{className:"w-px bg-surface-border shrink-0"}),e.jsx(P,{icon:j,title:"My Escalations",count:Y,actions:e.jsxs(e.Fragment,{children:[e.jsx(E,{onRefresh:()=>w.refetch(),isFetching:w.isFetching,apiPath:`/escalations?assigned_to=${(n==null?void 0:n.userId)??""}&status=pending&limit=5&sort_by=created_at&order=desc`}),e.jsx(_,{to:"/escalations/queue",icon:f,title:"My escalation queue"})]}),children:I.length===0?e.jsx(k,{icon:j,text:"No assigned escalations"}):e.jsx("div",{className:"space-y-0.5",children:I.map(a=>e.jsx(W,{esc:a,onClick:()=>s(`/escalations/detail/${a.id}`)},a.id))})})]}),b&&e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[e.jsxs(P,{icon:le,title:"Procedural",count:ge,actions:e.jsxs(e.Fragment,{children:[e.jsx(E,{onRefresh:()=>v.refetch(),isFetching:v.isFetching,apiPath:`/workflow-states/jobs?namespace=${p}&limit=5`}),e.jsx(_,{to:"/workflows/executions",icon:f,title:"All procedural executions"})]}),children:[e.jsx(me,{appIds:M,selected:p,onSelect:a=>F("durablenamespace",a)}),H.length===0?e.jsx(k,{icon:le,text:"No recent procedural runs"}):e.jsx("div",{className:"space-y-0.5",children:H.map(a=>e.jsx(ue,{dot:xe(a.status),pill:e.jsx(O,{type:a.entity||a.type||"workflow",size:"xs"}),id:a.workflow_id,date:a.updated_at??a.created_at,onClick:()=>s(`/workflows/executions/${a.workflow_id}`)},a.workflow_id))})]}),e.jsx("div",{className:"w-px bg-surface-border shrink-0"}),e.jsxs(P,{icon:ce,title:"Graph",count:be,actions:e.jsxs(e.Fragment,{children:[e.jsx(E,{onRefresh:()=>T.refetch(),isFetching:T.isFetching,apiPath:`/pipelines?app_id=${m}&limit=5`}),e.jsx(_,{to:"/mcp/executions",icon:f,title:"All graph executions"})]}),children:[e.jsx(me,{appIds:je,selected:m,onSelect:a=>F("pipelinenamespace",a)}),V.length===0?e.jsx(k,{icon:ce,text:"No recent graph runs"}):e.jsx("div",{className:"space-y-0.5",children:V.map(a=>e.jsx(ue,{dot:xe(a.status),pill:e.jsx(O,{type:a.entity||a.workflow_name||"pipeline",variant:"pipeline",size:"xs"}),id:a.workflow_id,date:a.updated_at??a.created_at,onClick:()=>s(`/mcp/executions/${a.workflow_id}?namespace=${m}`)},a.workflow_id))})]})]})]})}export{xs as HomePage};
2
- //# sourceMappingURL=HomePage-BQ3Q791Q.js.map
@@ -1,2 +0,0 @@
1
- import{a as C,j as s}from"./vendor-query-DvWWuNIB.js";import{aW as u,aX as j}from"./index-CIwlVfvV.js";import{aa as d,bF as N,bG as b,ao as h}from"./vendor-icons-DeBdvyKJ.js";function g({onRefresh:m,isFetching:n=!1,apiPath:t,standalone:x=!1}){const[c,r]=C.useState(null),i=(e,a)=>{navigator.clipboard.writeText(e).then(()=>{r(a),setTimeout(()=>r(null),2e3)})},p=()=>{if(!t)return;const e=`${window.location.origin}${u}/api${t}`;i(e,"url")},f=()=>{if(!t)return;const e=`${window.location.origin}${u}/api${t}`,a=j(),$=a?`curl -H "Authorization: Bearer ${a}" "${e}"`:`curl "${e}"`;i($,"curl")},l="p-1 icon-link rounded",o="w-2.5 h-2.5";return s.jsxs("div",{className:"flex items-center gap-0.5",children:[t&&s.jsxs("div",{className:x?"flex items-center gap-0.5":"hidden @filters/filters:flex items-center gap-0.5",children:[s.jsx("button",{onClick:p,className:l,title:"Copy API URL",children:c==="url"?s.jsx(d,{className:`${o} text-status-success`}):s.jsx(N,{className:o})}),s.jsx("button",{onClick:f,className:l,title:"Copy curl (includes auth token)",children:c==="curl"?s.jsx(d,{className:`${o} text-status-success`}):s.jsx(b,{className:o})})]}),s.jsx("button",{onClick:m,disabled:n,className:`${l} disabled:opacity-50`,title:"Refresh",children:s.jsx(h,{className:`${o} ${n?"animate-spin":""}`})})]})}export{g as L};
2
- //# sourceMappingURL=ListToolbar-DdJzj472.js.map
@@ -1,2 +0,0 @@
1
- import{j as e}from"./vendor-query-DvWWuNIB.js";import{P as j}from"./PageHeader-Di5Sz3an.js";import{D as _}from"./DataTable-7C7riavf.js";import{F as v,b as f}from"./FilterBar-DMOR-O1c.js";import{S as P}from"./StickyPagination-B91Pk9xh.js";import{L as N}from"./ListToolbar-DdJzj472.js";import{b as C}from"./api-path-u2Jf9QXS.js";import{T as h}from"./TimestampCell-BXgLOBsr.js";import{E as $}from"./ElapsedCell-CwO4ufd0.js";import{W}from"./WorkflowPill--AYMW7u_.js";import{E as S}from"./EmptyState-DgC_6njU.js";import{R as c}from"./RowActions-Bdd7z4eB.js";import{u as q}from"./useFilterParams-DBRw1Hcv.js";import{l as T}from"./index-CIwlVfvV.js";import{u as D}from"./mcp-query-Duydd3JA.js";import{l as y,$ as B,a0 as g,a1 as k,a2 as F,a3 as L}from"./vendor-icons-DeBdvyKJ.js";import{u as M}from"./vendor-react-_9U4mKFr.js";const E={in_progress:"bg-status-active",completed:"bg-status-success",failed:"bg-status-error"};function p(s){return s.status==="completed"||Number(s.status)===0?"completed":s.is_live?"in_progress":"failed"}function R(s){return[{key:"workflow_id",label:"Workflow ID / Type",render:t=>{const a=p(t),o=E[a]??"bg-status-pending",l=a==="in_progress"?" animate-pulse":"";return e.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[e.jsx("span",{className:`w-2.5 h-2.5 shrink-0 rounded-full dot-ring mt-1 ${o}${l}`,title:a}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"font-mono text-xs text-text-primary truncate block",children:t.workflow_id}),e.jsx("div",{className:"mt-0.5",children:e.jsx(W,{type:t.entity||"unknown"})})]})]})}},{key:"created_at",label:"Created",render:t=>e.jsx(h,{date:t.created_at}),className:"w-40",sortable:!0},{key:"updated_at",label:"Updated",render:t=>e.jsx(h,{date:t.updated_at}),className:"w-40",sortable:!0},{key:"duration",label:"Duration",render:t=>{const a=p(t);return e.jsx($,{startDate:t.created_at,endDate:a==="in_progress"?null:t.updated_at,isLive:a==="in_progress"})},className:"w-28"},{key:"actions",label:"",className:"w-28",render:t=>{const o=p(t)==="completed",l=t.entity==="mcpWorkflowBuilder";if(t.entity==="mcpWorkflowPlanner"){const r=t.set_id?`/mcp/queries/${t.workflow_id}?mode=plan&set_id=${t.set_id}`:`/mcp/queries/${t.workflow_id}?mode=plan`;return e.jsxs(c,{children:[e.jsx("button",{onClick:n=>{n.stopPropagation(),s(`${r}&step=1`)},className:"opacity-0 group-hover/row:opacity-100 text-text-tertiary hover:text-accent transition-all",title:"Plan",children:e.jsx(B,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),e.jsx("button",{onClick:n=>{n.stopPropagation(),s(`${r}&step=2`)},className:`opacity-0 group-hover/row:opacity-100 transition-all ${o?"text-text-tertiary hover:text-status-success":"text-text-tertiary/30 cursor-not-allowed"}`,title:o?"Build":"Planning...",disabled:!o,children:e.jsx(g,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})}return l?e.jsxs(c,{children:[e.jsx("button",{onClick:r=>{r.stopPropagation(),s(`/mcp/queries/${t.workflow_id}?mode=builder&step=1`)},className:"opacity-0 group-hover/row:opacity-100 text-text-tertiary hover:text-accent transition-all",title:"Describe",children:e.jsx(k,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),e.jsx("button",{onClick:r=>{r.stopPropagation(),s(`/mcp/queries/${t.workflow_id}?mode=builder&step=2`)},className:`opacity-0 group-hover/row:opacity-100 transition-all ${o?"text-text-tertiary hover:text-status-success":"text-text-tertiary/30 cursor-not-allowed"}`,title:o?"Profile":"Building...",disabled:!o,children:e.jsx(F,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]}):e.jsxs(c,{children:[e.jsx("button",{onClick:r=>{r.stopPropagation(),s(`/mcp/queries/${t.workflow_id}?step=1`)},className:"opacity-0 group-hover/row:opacity-100 text-text-tertiary hover:text-accent transition-all",title:"Describe",children:e.jsx(k,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),e.jsx("button",{onClick:r=>{r.stopPropagation(),s(`/mcp/queries/${t.workflow_id}?step=2`)},className:"opacity-0 group-hover/row:opacity-100 text-text-tertiary hover:text-status-warning transition-all",title:"Discover",children:e.jsx(L,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),e.jsx("button",{onClick:r=>{r.stopPropagation(),s(`/mcp/queries/${t.workflow_id}?step=3`)},className:`opacity-0 group-hover/row:opacity-100 transition-all ${o?"text-text-tertiary hover:text-status-success":"text-text-tertiary/30 cursor-not-allowed"}`,title:o?"Compile":"Complete discovery first",disabled:!o,children:e.jsx(g,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})}}]}function ae(){const s=M(),t=R(s),{filters:a,setFilter:o,pagination:l,sort:d,setSort:r}=q({filters:{search:"",status:"",type:""},pageSize:20}),{data:n,isLoading:m,refetch:b}=D({limit:l.pageSize,offset:l.offset,search:a.search,status:a.status,entity:a.type||void 0});T();const u=(n==null?void 0:n.jobs)??[],x=(n==null?void 0:n.total)??0;return e.jsxs(e.Fragment,{children:[e.jsx(j,{title:"MCP Tool Designer",docsHash:"#docs:dashboard.md:mcp-tool-designer",actions:e.jsxs("button",{onClick:()=>s("/mcp/queries/new"),className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[e.jsx(y,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"Create New MCP Tool"]})}),e.jsxs(v,{actions:e.jsx(N,{onRefresh:()=>b(),apiPath:C("/workflow-states/jobs",{entity:a.type||"mcpQuery,mcpTriage,mcpWorkflowPlanner",limit:l.pageSize,offset:l.offset,sort_by:"created_at",order:"desc",status:a.status||void 0,search:a.search||void 0})}),children:[e.jsx(f,{label:"Type",value:a.type,onChange:i=>o("type",i),options:[{value:"mcpQuery",label:"Discovery"},{value:"mcpWorkflowPlanner",label:"Build"},{value:"mcpTriage",label:"Triage"}]}),e.jsx(f,{label:"Status",value:a.status,onChange:i=>o("status",i),options:[{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"}]})]}),e.jsx(_,{columns:t,data:u,keyFn:i=>i.workflow_id,onRowClick:i=>{if(i.entity==="mcpWorkflowPlanner"){const w=i.set_id?`/mcp/queries/${i.workflow_id}?mode=plan&set_id=${i.set_id}`:`/mcp/queries/${i.workflow_id}?mode=plan`;s(w)}else i.entity==="mcpWorkflowBuilder"?s(`/mcp/queries/${i.workflow_id}?mode=builder`):s(`/mcp/queries/${i.workflow_id}`)},isLoading:m,emptyMessage:"",sort:d,onSort:r}),!m&&u.length===0&&e.jsx("div",{className:"cursor-pointer",onClick:()=>s("/mcp/queries/new"),children:e.jsx(S,{icon:y,title:"No tool designs yet",description:"Click to create your first MCP tool"})}),e.jsx(P,{page:l.page,pageSize:l.pageSize,total:x,totalPages:l.totalPages(x),onPageChange:l.setPage})]})}export{ae as McpQueryPage};
2
- //# sourceMappingURL=McpQueryPage-CfJy7HZ7.js.map
@@ -1,2 +0,0 @@
1
- import{a as d,j as s}from"./vendor-query-DvWWuNIB.js";import{e as F,g as b}from"./index-CIwlVfvV.js";import{a as T,u as E}from"./pipelines-B5GcgCeF.js";import{a as M}from"./yaml-workflows-CiWwx5rM.js";import{u as z}from"./useFilterParams-DBRw1Hcv.js";import{u as A}from"./useNamespace-CHty0HAS.js";import{b as $}from"./api-path-u2Jf9QXS.js";import{D as L}from"./DataTable-7C7riavf.js";import{W as U}from"./WorkflowPill--AYMW7u_.js";import{E as O}from"./ElapsedCell-CwO4ufd0.js";import{P as W}from"./PageHeader-Di5Sz3an.js";import{F as B,b as g}from"./FilterBar-DMOR-O1c.js";import{S as H}from"./StickyPagination-B91Pk9xh.js";import{L as I}from"./ListToolbar-DdJzj472.js";import{R as q,a as D}from"./RowActions-Bdd7z4eB.js";import{K as G}from"./vendor-icons-DeBdvyKJ.js";import{u as K}from"./vendor-react-_9U4mKFr.js";import"./controlplane-YxvP1KCa.js";import"./EmptyState-DgC_6njU.js";const V={running:"in_progress",completed:"completed",failed:"failed"},Y={in_progress:"bg-status-active",completed:"bg-status-success",failed:"bg-status-error"},J={running:"text-status-active",completed:"text-status-success",failed:"text-status-error"};function Q(x,f){return[{key:"workflow_id",label:"Run ID",render:t=>{const a=Y[V[t.status]??t.status]??"bg-status-pending",n=t.status==="running"?" animate-pulse":"";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:`w-2.5 h-2.5 shrink-0 rounded-full dot-ring ${a}${n}`,title:t.status}),s.jsx("span",{className:"font-mono text-xs text-text-primary truncate",children:t.workflow_id})]})}},{key:"entity",label:"Tool",render:t=>t.entity?s.jsx(U,{type:t.entity,variant:"pipeline",size:"xs"}):s.jsx("span",{className:"text-2xs text-text-tertiary",children:"—"}),className:"w-44 shrink-0"},{key:"created_at",label:"Created",sortable:!0,render:t=>s.jsx(b,{date:t.created_at,format:"relative",className:"text-xs text-text-secondary whitespace-nowrap"}),className:"w-32"},{key:"updated_at",label:"Updated",sortable:!0,render:t=>s.jsx(b,{date:t.updated_at,format:"relative",className:"text-xs text-text-secondary whitespace-nowrap"}),className:"w-32"},{key:"duration",label:"Duration",render:t=>s.jsx(O,{startDate:t.created_at,endDate:t.status==="running"?null:t.updated_at,isLive:t.status==="running"}),className:"w-28"},{key:"actions",label:"",render:t=>s.jsxs(q,{children:[s.jsx(D,{icon:G,title:`Filter by ${t.entity}`,onClick:()=>x(t.entity)}),s.jsx("button",{onClick:a=>{a.stopPropagation(),f(t.status)},className:"opacity-0 group-hover/row:opacity-100 transition-opacity",title:`Filter by ${t.status}`,children:s.jsx("svg",{className:`w-[18px] h-[18px] ${J[t.status]??"text-text-tertiary"} hover:opacity-70`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("circle",{cx:"12",cy:"12",r:"6"})})})]}),className:"w-24 text-right"}]}function he(){const x=K(),{namespace:f,available:t}=A("namespace"),{filters:a,setFilter:n,setFilters:v,pagination:o,sort:u,setSort:j}=z({filters:{search:"",entity:"",status:"",namespace:""}}),[m,_]=d.useState(a.search);d.useEffect(()=>{if(m===a.search)return;const e=setTimeout(()=>n("search",m),F);return()=>clearTimeout(e)},[m,n,a.search]);const{data:l}=M(),h=d.useMemo(()=>{const e=new Set(t);for(const r of(l==null?void 0:l.app_ids)??[])e.add(r);return[...e].sort()},[t,l==null?void 0:l.app_ids]),i=a.namespace||f,{data:c}=T(i),{data:p,isLoading:S,refetch:k,isFetching:N}=E({app_id:i,limit:o.pageSize,offset:o.offset,entity:a.entity||void 0,search:a.search||void 0,status:a.status||void 0,sort_by:u.sort_by||"created_at",order:u.order||"desc"}),y=(p==null?void 0:p.total)??0,w=(p==null?void 0:p.jobs)??[],C=Q(e=>n("entity",e),e=>n("status",e)),P=d.useMemo(()=>{const e=new Set(h);return i&&e.add(i),[...e].sort().map(r=>({value:r,label:r}))},[h,i]),R=d.useMemo(()=>{const e=new Set((c==null?void 0:c.entities)??[]);return a.entity&&!e.has(a.entity)&&e.add(a.entity),[...e].sort().map(r=>({value:r,label:r}))},[c==null?void 0:c.entities,a.entity]);return s.jsxs("div",{children:[s.jsx(W,{title:"Pipeline Executions",docsHash:"#docs:dashboard.md:graph-executions"}),s.jsxs(B,{actions:s.jsx(I,{onRefresh:()=>k(),isFetching:N,apiPath:$("/pipelines",{app_id:i,limit:o.pageSize,offset:o.offset,entity:a.entity||void 0,status:a.status||void 0,search:a.search||void 0,sort_by:u.sort_by||"created_at",order:u.order||"desc"})}),children:[s.jsx(g,{label:"Namespace",value:i,onChange:e=>{v({namespace:e,entity:""})},options:P,required:!0}),s.jsx("input",{type:"text",placeholder:"Search run ID...",value:m,onChange:e=>_(e.target.value),className:"input text-2xs py-1 px-2 w-56"}),s.jsx(g,{label:"Tool",value:a.entity,onChange:e=>n("entity",e),options:R}),s.jsx(g,{label:"Status",value:a.status,onChange:e=>n("status",e),options:[{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}]})]}),s.jsx(L,{columns:C,data:w,keyFn:e=>e.workflow_id,onRowClick:e=>x(`/mcp/executions/${encodeURIComponent(e.workflow_id)}?namespace=${i}`),isLoading:S,emptyMessage:"No pipeline executions found",sort:u,onSort:j}),s.jsx(H,{page:o.page,totalPages:o.totalPages(y),onPageChange:o.setPage,total:y,pageSize:o.pageSize,onPageSizeChange:o.setPageSize})]})}export{he as McpRunsPage};
2
- //# sourceMappingURL=McpRunsPage-D7QXjW9z.js.map
@@ -1,3 +0,0 @@
1
- import{a as g,j as e}from"./vendor-query-DvWWuNIB.js";import{a6 as de,z as Rt,aa as rt,a1 as we,G as Pt,e as Lt,bc as ot,bd as Et,aY as Ot,_ as Bt,w as Ft,be as At,aS as It,Q as Tt}from"./index-CIwlVfvV.js";import{s as Le,a as ie,u as F,b as Ve,E as ze,c as lt,i as Ee,d as ct}from"./EntityTimelinePanel-CkF-oW-m.js";import{ar as Wt,bK as Dt,au as it,d as Ut,C as dt,ap as xt,bw as zt,e as Gt,X as Ht,aE as Vt,E as ut,ao as Yt,bL as Qt,a2 as Xt}from"./vendor-icons-DeBdvyKJ.js";import{u as mt,f as pt,L as ne,a as Zt}from"./vendor-react-_9U4mKFr.js";import{P as Jt}from"./PageHeader-Di5Sz3an.js";function Kt({groups:t,colors:s}){const l=g.useMemo(()=>{const r=(t??[]).filter(n=>(n.dwellSeconds??0)>0),d=r.reduce((n,o)=>n+(o.dwellSeconds??0),0);return d?r.map(n=>({key:ie(n.subtype),label:Le(n.subtype),seconds:n.dwellSeconds??0,pct:(n.dwellSeconds??0)/d})).sort((n,o)=>o.seconds-n.seconds):null},[t]);if(!l)return e.jsx("span",{className:"text-2xs text-text-quaternary",children:"—"});const i=l.map(r=>`${r.label} ${de(r.seconds*1e3)} · ${Math.round(r.pct*100)}%`).join(`
2
- `);return e.jsxs("div",{className:"flex items-center gap-1.5",title:i,children:[e.jsx("div",{className:"w-16 h-1.5 bg-surface-sunken rounded-full overflow-hidden flex shrink-0",children:l.map(r=>e.jsx("div",{style:{width:`${r.pct*100}%`,backgroundColor:s.get(r.key)}},r.key))}),e.jsxs("span",{className:"text-2xs font-mono text-text-quaternary tabular-nums",children:[Math.round(l[0].pct*100),"%"]})]})}function Be(t){return t.reduce((s,l)=>s+(l.dwellSeconds??0),0)||1}function ht(t,s){const l=[];for(const i of t){const r=i.facets[s];r==null||(i.dwellSeconds??0)<=0||l.push(r)}return l}function ft(t,s,l,i){const r=new Map;for(const o of s){const h=o.facets[i];if(h==null||(o.dwellSeconds??0)<=0)continue;const u=r.get(h)??[];u.push(o),r.set(h,u)}const d=new Map;for(const o of l){const h=o.facets[i];h==null||(o.count??0)<=0||o.state==null||d.has(h)||d.set(h,o.state)}const n=[];for(const o of t){const h=o.facets[i];if(h==null||(o.dwellSeconds??0)<=0)continue;const u=[...r.get(h)??[]].sort((m,f)=>(f.dwellSeconds??0)-(m.dwellSeconds??0));n.push({value:h,groups:u,total:o.dwellSeconds??0,nowState:d.get(h)??null})}return n}function es(t,s,l=12){const i=new Map;for(const r of t){if((r.dwellSeconds??0)<=0)continue;const d=r.facets[s]??"no value",n=i.get(d)??[];n.push(r),i.set(d,n)}return[...i.entries()].map(([r,d])=>({value:r,groups:[...d].sort((n,o)=>(o.dwellSeconds??0)-(n.dwellSeconds??0)),total:Be(d)})).sort((r,d)=>d.total-r.total).slice(0,l)}function Ye({groups:t,colors:s,height:l,rounded:i="rounded-sm",className:r=""}){const d=Be(t),n=new Map([...s.keys()].map((h,u)=>[h,u])),o=[...t].sort((h,u)=>(n.get(h.state??"—")??1/0)-(n.get(u.state??"—")??1/0));return e.jsx("div",{className:`${l} flex ${i} overflow-hidden bg-surface-sunken ${r}`,children:o.map(h=>{const u=d>0?Math.round((h.dwellSeconds??0)/d*100):0;return e.jsx("div",{title:`${h.state??"—"} · ${u}%`,style:{width:`${(h.dwellSeconds??0)/d*100}%`,backgroundColor:s.get(h.state??"—")}},h.state??"—")})})}const ts=10;function ss(t){return t<1?`${Math.round(t*60)}m`:t<=24?`${Math.round(t)}h`:`${Math.round(t/24)}d`}function ns({groups:t,colors:s,stateLabel:l,nowByState:i,periodHours:r,tracked:d,entityKey:n}){var b;const o=Be(t),h=[...t].filter(y=>(y.dwellSeconds??0)>0).sort((y,w)=>(w.dwellSeconds??0)-(y.dwellSeconds??0)).map(y=>({state:y.state??"—",label:l(y.state),pct:o>0?Math.round((y.dwellSeconds??0)/o*100):0,color:s.get(y.state??"—"),now:i.get(y.state??"—")??0})),u=((b=h[0])==null?void 0:b.pct)||1,m=h.slice(0,ts),f=h.length-m.length,j=h[0];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[e.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:["Where the time went · ",e.jsx("span",{className:"normal-case font-mono",children:n})," system"]}),e.jsxs("div",{className:"space-y-px max-h-40 overflow-hidden",children:[m.map(y=>e.jsx("div",{className:"relative h-3 rounded-sm bg-surface-sunken overflow-hidden",title:`${y.label} · ${y.pct}%${y.now>0?` · ${y.now} now`:""}`,children:e.jsxs("div",{className:"absolute inset-y-0 left-0 flex items-center justify-end gap-1 pr-1.5 rounded-sm",style:{width:`${Math.max(y.pct/u*100,0)}%`,minWidth:"4.25rem",backgroundColor:y.color},children:[e.jsx("span",{className:"text-[10px] leading-none font-mono font-medium text-white/95 truncate",children:y.label}),e.jsxs("span",{className:"text-[10px] leading-none font-mono tabular-nums text-white/75 shrink-0",children:[y.pct,"%"]})]})},y.state)),f>0&&e.jsxs("p",{className:"text-[10px] text-text-quaternary pl-1 pt-0.5",children:["+",f," more stages"]})]})]}),e.jsxs("div",{className:"shrink-0 w-52 pl-6 border-l border-surface-border/40 flex flex-col justify-center",children:[e.jsxs("p",{className:"text-2xs uppercase tracking-widest text-text-tertiary",children:["Last ",ss(r)]}),e.jsxs("p",{className:"mt-1 flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-xl font-light text-text-primary tabular-nums leading-none",children:[(j==null?void 0:j.pct)??0,"%"]}),e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:j==null?void 0:j.color}})]}),e.jsxs("p",{className:"text-xs text-text-secondary mt-1",children:[e.jsx("span",{className:"font-mono font-medium text-text-primary",children:j==null?void 0:j.label})," is the biggest time sink"]}),e.jsxs("p",{className:"text-2xs text-text-tertiary mt-1",children:["across ",h.length," stages",d!=null&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"font-mono font-semibold text-text-primary tabular-nums",children:d})," ",e.jsx("span",{className:"font-mono",children:n})," in queue now"]})]})]})]})}function gt({text:t,tail:s=6,className:l=""}){if(t.length<=s+1)return e.jsx("span",{className:`truncate ${l}`,title:t,children:t});const i=t.slice(0,t.length-s),r=t.slice(t.length-s);return e.jsxs("span",{className:`flex items-baseline min-w-0 ${l}`,title:t,children:[e.jsx("span",{className:"truncate min-w-0",children:i}),e.jsx("span",{className:"shrink-0",children:r})]})}const Xe=15,yt="grid grid-cols-[0.6rem_7rem_minmax(2rem,1fr)_1rem] items-center gap-2.5",as=[25,50,100],rs=50;function os({facetKey:t,row:s,colors:l,stateLabel:i,onOpen:r}){const d=mt(),n=o=>{if(o.metaKey||o.ctrlKey){d(Rt(t,s.value));return}r(s.value)};return e.jsxs("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:o=>{o.key==="Enter"&&n(o)},className:`${yt} text-2xs cursor-pointer group`,children:[e.jsx("span",{className:"w-2 h-2 rounded-full justify-self-center",style:{backgroundColor:s.nowState?l.get(s.nowState):"transparent"},title:s.nowState?i(s.nowState):"no current state"}),e.jsx(gt,{text:s.value,className:"font-mono text-text-secondary group-hover:text-accent transition-colors"}),e.jsx(Ye,{groups:s.groups,colors:l,height:"h-4",className:"min-w-[2rem]"}),e.jsx("button",{className:"icon-link justify-self-center",title:`${de(s.total*1e3)} tracked · open timeline · ⌘-click row searches every queue`,onClick:o=>{o.stopPropagation(),r(s.value)},children:e.jsx(it,{className:"w-3 h-3"})})]})}function bt({facetKey:t,sliced:s,header:l,rows:i,colors:r,stateLabel:d,onOpen:n,onTarget:o,hasMore:h,emptyText:u}){return e.jsxs("div",{className:s?"w-72 shrink-0":"flex-1",children:[l&&e.jsxs("button",{type:"button",onClick:()=>o==null?void 0:o(l.value),className:`${yt} w-full text-left mb-2 group`,children:[e.jsx("span",{"aria-hidden":!0}),e.jsx(gt,{text:l.value,className:"font-mono text-xs font-medium text-text-primary group-hover:text-accent transition-colors"}),e.jsx(Ye,{groups:l.groups,colors:r,height:"h-2.5",className:"min-w-[2rem]"}),e.jsx("span",{className:"icon-link justify-self-center",title:`${de(l.total*1e3)} total in ${l.value} — the band shows the state split`,children:e.jsx(Wt,{className:"w-3 h-3"})})]}),i.length===0?e.jsx("p",{className:"text-2xs text-text-quaternary",children:u??"No entities on this page."}):e.jsx("div",{className:"space-y-px",children:i.map(m=>e.jsx(os,{facetKey:t,row:m,colors:r,stateLabel:d,onOpen:n},m.value))}),h&&l&&o&&e.jsxs("button",{type:"button",onClick:()=>o(l.value),className:"mt-2 inline-flex items-center gap-1 text-2xs text-accent hover:text-accent-hover transition-colors",children:["More ",e.jsx(Dt,{className:"w-3 h-3"})]})]})}function ls({entityKey:t,sliceKey:s,value:l,headerGroups:i,headerTotal:r,window:d,find:n,colors:o,stateLabel:h,onOpen:u,onTarget:m}){var L;const f={entity:t,equals:{[s]:l}},j=F({query:{...f,...n?{prefix:{[t]:n}}:{}},groupBy:{facets:[t]},measure:{kind:"dwell",window:d},orderBy:[{field:"dwellSeconds",direction:"desc"}],limit:Xe}),b=g.useMemo(()=>{var k;return ht(((k=j.data)==null?void 0:k.groups)??[],t)},[j.data,t]),y=b.map(k=>({[t]:k})),w=F(b.length?{query:{entity:t,anyOf:y},groupBy:{state:!0,facets:[t]},measure:{kind:"dwell",window:d},limit:Xe*4}:null),C=F(b.length?{query:{entity:t,anyOf:y},groupBy:{state:!0,facets:[t]},measure:{kind:"membership"}}:null),M=g.useMemo(()=>{var k,$,R;return ft(((k=j.data)==null?void 0:k.groups)??[],(($=w.data)==null?void 0:$.groups)??[],((R=C.data)==null?void 0:R.groups)??[],t)},[j.data,w.data,C.data,t]);return e.jsx(bt,{facetKey:t,sliced:!0,header:{value:l,groups:i,total:r},rows:M,colors:o,stateLabel:h,onOpen:u,onTarget:m,hasMore:((L=j.data)==null?void 0:L.overflow)??!1})}function cs({facetKey:t,rows:s,colors:l,stateLabel:i,onOpen:r,emptyText:d}){return e.jsx(bt,{facetKey:t,sliced:!1,rows:s,colors:l,stateLabel:i,onOpen:r,emptyText:d})}const Me="entity-timeline",is=Lt,De=12;function ds({entityKey:t,periodHours:s,roles:l,scopeFacets:i,find:r,onFindChange:d,entityValue:n,onEntityChange:o,sliceKey:h=null,onSliceKeyChange:u,sliceValue:m=null,onSliceValueChange:f}){var ye,$e,Se,be,x;const j=Ve(s),b=rt(),y=a=>i?{...a,facets:{...a.facets??{},...i}}:a,w=h??"",C=!!w,M=C&&!!m,L=C&&!m,[k,$]=g.useState(0),[R,v]=g.useState(rs);g.useEffect(()=>{$(0)},[r,j.from,j.to,t,w,m,R]);const[H,Q]=g.useState(r??""),N=g.useRef(void 0);g.useEffect(()=>()=>clearTimeout(N.current),[]),g.useEffect(()=>{Q(r??"")},[r]);const q=a=>{Q(a),clearTimeout(N.current),N.current=setTimeout(()=>{const p=a.trim();d(p||null)},is)},le=g.useMemo(()=>{const a=new Map;for(const p of l)a.set(p.role,we(p));return a},[l]),E=a=>a==null?"—":le.get(a)??a,xe=F({query:y({entity:t}),groupBy:{state:!0},measure:{kind:"dwell",window:j},orderBy:[{field:"dwellSeconds",direction:"desc"}]}),A=F({query:y({entity:t}),groupBy:{state:!0},measure:{kind:"membership"}}),K=F({query:y({entity:t}),groupBy:{},measure:{kind:"membership"},distinctBy:t}),P=F(C?{query:y({entity:t}),groupBy:{state:!0,facets:[w]},measure:{kind:"dwell",window:j},limit:200}:null),_=F(!L?{query:y({entity:t,...M?{equals:{[w]:m}}:{},...r?{prefix:{[t]:r}}:{}}),groupBy:{facets:[t]},measure:{kind:"dwell",window:j},orderBy:[{field:"dwellSeconds",direction:"desc"}],limit:R,offset:k*R}:null),ee=g.useMemo(()=>{var a;return ht(((a=_==null?void 0:_.data)==null?void 0:a.groups)??[],t)},[_==null?void 0:_.data,t]),T=ee.length?{entity:t,anyOf:ee.map(a=>({[t]:a}))}:null,te=F(T?{query:y(T),groupBy:{state:!0,facets:[t]},measure:{kind:"dwell",window:j},limit:R*10}:null),ue=F(T?{query:y(T),groupBy:{state:!0,facets:[t]},measure:{kind:"membership"}}:null),c=g.useMemo(()=>{var a,p,G;return ft(((a=_==null?void 0:_.data)==null?void 0:a.groups)??[],((p=te.data)==null?void 0:p.groups)??[],((G=ue.data)==null?void 0:G.groups)??[],t)},[_==null?void 0:_.data,te.data,ue.data,t]),S=g.useRef(()=>{}),O=g.useRef(a=>S.current(a)).current,W=g.useRef(null),B=g.useRef(!1);g.useEffect(()=>{b&&n!==W.current&&(W.current=n,n?b.setPanel(e.jsx(ze,{facetKey:t,value:n,entity:t,intervalColor:O}),{key:Me,width:420}):(B.current=!1,b.closePanel(Me)))},[n,t,b]),g.useEffect(()=>{if(!(!b||!n)){if(b.open&&b.ownerKey===Me){B.current=!0;return}B.current&&(B.current=!1,o(null))}},[b,n,o]);const U=g.useRef(b);U.current=b,g.useEffect(()=>()=>{var a;W.current&&((a=U.current)==null||a.closePanel(Me))},[]);const{data:D}=Pt(),z=g.useMemo(()=>((D==null?void 0:D.keys)??[]).filter(a=>a!==t),[D,t]),V=(((ye=xe.data)==null?void 0:ye.groups)??[]).filter(a=>(a.dwellSeconds??0)>0),X=g.useMemo(()=>{var a;return lt([...V,...((a=A.data)==null?void 0:a.groups)??[]].map(p=>({label:p.state??"—",weight:p.dwellSeconds??p.count??0})))},[V,A.data]),me=new Map(((($e=A.data)==null?void 0:$e.groups)??[]).map(a=>[a.state??"—",a.count??0])),pe=((be=(Se=K.data)==null?void 0:Se.groups[0])==null?void 0:be.count)??null,Z=g.useMemo(()=>new Set(l.filter(a=>a.entity_state_source==="subtype").map(a=>a.role)),[l]);S.current=a=>{const p=Z.has(a.role)?a.subtype??a.role:a.role;return X.get(p)};const Ne=g.useMemo(()=>{var a;return C?es(((a=P.data)==null?void 0:a.groups)??[],w,De):[]},[C,P.data,w]),ve=g.useMemo(()=>{var p;const a=new Set;for(const G of((p=P.data)==null?void 0:p.groups)??[])(G.dwellSeconds??0)>0&&G.facets[w]!=null&&a.add(G.facets[w]);return a.size},[P.data,w]),ke=g.useMemo(()=>{var p;if(!M)return{groups:[],total:0};const a=(((p=P.data)==null?void 0:p.groups)??[]).filter(G=>G.facets[w]===m);return{groups:a,total:Be(a)}},[M,P.data,w,m]),Ie=((x=_==null?void 0:_.data)==null?void 0:x.overflow)??!1,Te=Ee(_==null?void 0:_.error),We=C&&Ee(P.error);return e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 px-2 pt-4 pb-4 flex items-stretch gap-6 border-b border-surface-border/40",children:[V.length>0?e.jsx(ns,{groups:V,colors:X,stateLabel:E,nowByState:me,periodHours:s,tracked:pe,entityKey:t}):e.jsx("p",{className:"flex-1 text-2xs text-text-quaternary self-center",children:"No tracked time in this window."}),e.jsxs("div",{className:"shrink-0 w-56 space-y-2.5 self-center",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Slice by"}),e.jsxs("select",{value:w,onChange:a=>u==null?void 0:u(a.target.value||null),className:"select text-xs font-mono w-full",children:[e.jsx("option",{value:"",children:"— none —"}),z.map(a=>e.jsx("option",{value:a,children:a},a))]})]}),e.jsx("input",{type:"text",value:H,onChange:a=>q(a.target.value),placeholder:`Find by ${t}…`,"aria-label":`Find by ${t}`,className:"w-full bg-transparent border-b border-surface-border/60 focus:border-accent focus:outline-none text-xs font-mono text-text-primary placeholder:text-text-quaternary pb-0.5 transition-colors"})]})]}),M&&e.jsxs("div",{className:"shrink-0 px-2 pt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>f==null?void 0:f(null),className:"inline-flex items-center gap-1 text-2xs text-accent hover:text-accent-hover transition-colors shrink-0",children:[e.jsx(Ut,{className:"w-3 h-3"})," all ",w]}),e.jsx("span",{className:"font-mono text-xs text-text-primary shrink-0",children:m}),e.jsx(Ye,{groups:ke.groups,colors:X,height:"h-2",className:"flex-1 max-w-md"}),e.jsx("span",{className:"font-mono tabular-nums text-2xs text-text-tertiary shrink-0",children:de(ke.total*1e3)})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto px-2 py-4",children:L?We?e.jsx("p",{className:"text-2xs text-text-quaternary",children:"Slicing requires full read access to the system's queues."}):Ne.length===0?e.jsx("p",{className:"text-2xs text-text-quaternary",children:"No tracked time for this slice in the window."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex gap-6 min-w-max",children:Ne.map(a=>e.jsx(ls,{entityKey:t,sliceKey:w,value:a.value,headerGroups:a.groups,headerTotal:a.total,window:j,find:r,colors:X,stateLabel:E,onOpen:o,onTarget:p=>f==null?void 0:f(p)},a.value))}),ve>De&&e.jsxs("p",{className:"text-2xs text-text-quaternary pt-4",children:["Showing the top ",De," of ",ve," ",e.jsx("span",{className:"font-mono",children:w})," values — a facet this wide isn't a good slice dimension."]})]}):Te?e.jsx("p",{className:"text-2xs text-text-quaternary",children:"The per-entity view requires full read access to the system's queues."}):e.jsx(cs,{facetKey:t,rows:c,colors:X,stateLabel:E,onOpen:o,emptyText:r?`No ${t} starts with “${r}” in this window.`:"No entities tracked in this window."})}),!L&&e.jsxs("div",{className:"shrink-0 border-t border-surface-border bg-surface/95 px-2 pt-2 pb-3 flex items-center gap-3 text-2xs",children:[e.jsx("button",{disabled:k===0,onClick:()=>$(k-1),className:"text-text-tertiary hover:text-accent transition-colors disabled:opacity-40 disabled:hover:text-text-tertiary",children:"Prev"}),e.jsxs("span",{className:"font-mono tabular-nums text-text-quaternary",children:["page ",k+1]}),e.jsx("button",{disabled:!Ie,onClick:()=>$(k+1),className:"text-text-tertiary hover:text-accent transition-colors disabled:opacity-40 disabled:hover:text-text-tertiary",children:"Next"}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 text-text-quaternary",children:[e.jsx("span",{children:"per page"}),e.jsx("select",{value:R,onChange:a=>v(Number(a.target.value)),"aria-label":"Results per page",className:"select text-2xs font-mono py-0.5",children:as.map(a=>e.jsx("option",{value:a,children:a},a))})]})]})]})}function xs({fragments:t,activeFragment:s,lenses:l,activeLens:i,onSelectFragment:r,onSelectLens:d}){const[n,o]=g.useState(!1),h=g.useRef(null);g.useEffect(()=>{if(!n)return;const f=b=>{h.current&&!h.current.contains(b.target)&&o(!1)},j=b=>{b.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",j)}},[n]);const u=t.find(f=>f.origin===s)??t[0],m=i?null:(u==null?void 0:u.origin)??null;return e.jsxs("div",{ref:h,className:"relative",title:"Board: pace a segment of roles, or read a metadata facet's trend",children:[e.jsxs("button",{type:"button",onClick:()=>o(f=>!f),className:"group flex items-baseline gap-1.5","aria-expanded":n,"aria-haspopup":"listbox","aria-label":"Board view",children:[e.jsx("span",{className:"text-2xs uppercase tracking-widest text-text-quaternary",children:"View"}),e.jsx("span",{className:"text-xs font-medium text-accent",children:i?e.jsxs(e.Fragment,{children:["by ",e.jsx("span",{className:"font-mono",children:i})]}):(u==null?void 0:u.title)??"Pace Board"}),e.jsx(dt,{className:`w-3 h-3 self-center shrink-0 text-text-tertiary group-hover:text-accent transition-transform ${n?"rotate-180":""}`,strokeWidth:1.5})]}),n&&e.jsxs("div",{role:"listbox",className:"absolute z-[100] top-full right-0 mt-1.5 min-w-[19rem] max-h-96 overflow-y-auto bg-surface-raised border border-surface-border rounded-md shadow-lg py-1",children:[e.jsx(Ze,{children:"Pace Board"}),t.map(f=>e.jsx(jt,{label:f.title,note:`${f.roleCount} role${f.roleCount===1?"":"s"} · ${f.pending} pending`,jeopardy:f.jeopardy,active:f.origin===m,onClick:()=>{r(f.origin),o(!1)}},f.origin)),l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ze,{children:"Trend Board"}),l.map(f=>e.jsx(us,{lens:f,active:i===f,fetchCount:n,onClick:()=>{d(f),o(!1)}},f))]})]})]})}function Ze({children:t}){return e.jsx("p",{className:"px-3 pt-2 pb-1 text-2xs font-semibold uppercase tracking-widest text-text-quaternary first:pt-1",children:t})}function jt({label:t,note:s,jeopardy:l=0,active:i,mono:r,onClick:d}){return e.jsxs("button",{type:"button",role:"option","aria-selected":i,onClick:d,className:`w-full text-left pl-3 pr-2.5 py-1.5 flex items-baseline gap-2.5 border-l-2 transition-colors ${i?"border-accent bg-accent/10 text-accent":"border-transparent text-text-primary hover:bg-surface-hover"}`,children:[e.jsx("span",{className:`text-xs font-medium truncate ${r?"font-mono":""}`,children:t}),s&&e.jsx("span",{className:`ml-auto text-2xs font-mono tabular-nums shrink-0 ${i?"text-accent/70":"text-text-quaternary"}`,children:s}),e.jsx("span",{className:"w-9 shrink-0 flex items-center justify-end gap-0.5 text-2xs font-mono tabular-nums text-status-warning",title:l>0?`${l} in jeopardy`:void 0,children:l>0&&e.jsxs(e.Fragment,{children:[e.jsx(xt,{className:"w-3 h-3 shrink-0",strokeWidth:2}),l]})})]})}function us({lens:t,active:s,fetchCount:l,onClick:i}){var n,o;const d=(o=(n=F({query:{entity:t},groupBy:{},measure:{kind:"membership"},distinctBy:t},{enabled:l}).data)==null?void 0:n.groups[0])==null?void 0:o.count;return e.jsx(jt,{label:`by ${t}`,mono:!0,note:d!=null?`${d} in queue`:null,active:s,onClick:i})}const wt=800,Nt=270,ae=28,ms=60,Oe=24,ps=72,Pe=wt-ae-ms,Ge=Nt-Oe-ps,Y=Oe+Ge,Ue=ae+Pe,I="0.5s cubic-bezier(0.4, 0, 0.2, 1)",Je=9;function hs(t){return`M ${(t.x-Je).toFixed(1)} ${t.y.toFixed(1)} L ${(t.x+Je).toFixed(1)} ${t.y.toFixed(1)}`}function fe(t){if(t.length===0)return"";if(t.length===1)return hs(t[0]);const s=[];for(let l=0;l<t.length-1;l++){const i=t[Math.max(0,l-1)],r=t[l],d=t[l+1],n=t[Math.min(t.length-1,l+2)],o=(r.x+(d.x-i.x)/6).toFixed(1),h=(r.y+(d.y-i.y)/6).toFixed(1),u=(d.x-(n.x-r.x)/6).toFixed(1),m=(d.y-(n.y-r.y)/6).toFixed(1);l===0&&s.push(`M ${r.x.toFixed(1)} ${r.y.toFixed(1)}`),s.push(`C ${o} ${h}, ${u} ${m}, ${d.x.toFixed(1)} ${d.y.toFixed(1)}`)}return s.join(" ")}function fs(t,s){if(t.length<2||s.length<2)return"";const l=fe(t),i=[...s].reverse(),r=fe(i),d=r.slice(r.indexOf("C"));return`${l} L ${i[0].x.toFixed(1)} ${i[0].y.toFixed(1)} ${d} Z`}function Ke(t){return t>=1e4?`${Math.round(t/1e3)}k`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function qe(t){return t.length>0?t[t.length-1]:void 0}function gs(t){return[1,2,5,10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4].filter(l=>l>0&&l<t*.98)}function ys(t){return[.25,.5,.75].map(l=>Math.round(l*t)).filter(l=>l>0)}const re="rgb(var(--lt-status-claimed-graphic))",ge="rgb(var(--lt-status-queued-graphic))",J="rgb(var(--lt-status-success-graphic))",oe="rgb(var(--lt-text-quaternary))",je="rgb(var(--lt-status-error))";function Fe(t,s){return t.replace(/\)$/,` / ${s})`)}const bs=13;function js(t,s){const l=[...t].sort((n,o)=>n.y-o.y);let i=-1/0;const r=l.map(n=>{const o=Math.max(n.y+3,i+bs);return i=o,{...n,labelY:o}}),d=r.length>0?r[r.length-1].labelY-s:0;if(d>0)for(const n of r)n.labelY-=d;return r}function ws({stations:t,selectedRole:s,onSelect:l,onUpstreamSelect:i,onCmdClick:r,periodHours:d,logScale:n=!1,fill:o=!1}){const[h,u]=g.useState(null),m=t.length;if(m===0)return null;const f=c=>m===1?ae+Pe/2:ae+c/(m-1)*Pe,j=new Map(t.map((c,S)=>[c.role,f(S)])),b=t.map((c,S)=>{var B,U,D,z;const O=c.target_per_hour??null,W=O!=null?O*d:null;return{idx:S,x:f(S),expected:W,actual:((B=c.metric)==null?void 0:B.resolved)??0,active:((U=c.metric)==null?void 0:U.claimed)??0,pending:((D=c.metric)==null?void 0:D.pending)??0,priorityCount:((z=c.metric)==null?void 0:z.priority_count)??0}}),y=b.some(c=>c.expected!=null),C=Math.max(1,...b.map(c=>c.expected??0),...b.map(c=>c.actual),...b.map(c=>c.expected!=null?c.pending:0))*1.15,M=n?c=>{const S=Math.log(1+C);return Oe+Ge*(1-Math.log(1+Math.max(0,c))/S)}:c=>Oe+Ge*(1-Math.max(0,Math.min(c,C))/C),L=n?gs(C):ys(C),k=b.filter(c=>c.expected!=null),$=k.map(c=>({...c,y:M(c.expected)})),R=k.map(c=>({...c,y:M(c.actual)})),v=k.map(c=>({...c,y:M(c.active)})),H=k.map(c=>({...c,y:M(c.pending)})),Q=fe($),N=fe(R),q=fe(v),le=fe(H),E=qe(R),xe=qe($),A=qe(v),K=qe(H),P=R.length>=2&&E?`${N} L ${E.x.toFixed(1)} ${Y} L ${R[0].x.toFixed(1)} ${Y} Z`:"",ce=k.some(c=>c.pending>0||c.active>0),_=ce&&v.length>=2&&A?`${q} L ${A.x.toFixed(1)} ${Y} L ${v[0].x.toFixed(1)} ${Y} Z`:"",ee=ce?fs(H,v):"",T=k.some(c=>c.active>0),te=k.some(c=>c.pending>c.active),ue=js([xe?{key:"target",text:"Target",color:oe,y:xe.y}:null,E?{key:"actual",text:"Resolved",color:J,y:E.y}:null,T&&A?{key:"active",text:"Claimed",color:re,y:A.y}:null,te&&K?{key:"queued",text:"Pending",color:ge,y:K.y}:null].filter(Boolean),Y+4);return e.jsxs("svg",{viewBox:`0 0 ${wt} ${Nt}`,className:o?"w-full h-full":"w-full",preserveAspectRatio:"xMidYMid meet",style:{display:"block",...o?{}:{height:"auto"}},children:[L.map(c=>{const S=M(c);return e.jsxs("g",{children:[e.jsx("line",{x1:ae,y1:S,x2:Ue,y2:S,className:"stroke-surface-border",strokeWidth:.5,opacity:n?.45:.3,strokeDasharray:n?"2 5":void 0,style:{transition:`y1 ${I}, y2 ${I}`}}),e.jsx("text",{x:ae-4,y:S+2.5,textAnchor:"end",fontSize:6,fontFamily:"ui-monospace, monospace",opacity:.35,className:"fill-text-quaternary",children:Ke(c)})]},`grid-${c}`)}),t.map(c=>{if(!c.parent_role)return null;const S=j.get(c.parent_role);if(S==null)return null;const O=f(t.findIndex(W=>W.role===c.role));return e.jsx("line",{x1:S,y1:Y,x2:O,y2:Y,className:"stroke-surface-border",strokeWidth:.75},`dep-${c.role}`)}),P&&e.jsx("path",{d:P,opacity:.05,style:{fill:J,transition:`d ${I}`}}),_&&e.jsx("path",{d:_,opacity:.12,style:{fill:re,transition:`d ${I}`}}),ee&&e.jsx("path",{d:ee,opacity:.12,style:{fill:ge,transition:`d ${I}`}}),Q&&e.jsx("path",{d:Q,fill:"none",strokeWidth:.75,strokeDasharray:"2 3",strokeLinecap:"round",opacity:.7,style:{stroke:oe,transition:`d ${I}`}}),$.map(c=>e.jsxs("g",{transform:`translate(${c.x} ${c.y})`,style:{transition:`transform ${I}`},children:[e.jsx("circle",{r:2,opacity:.8,style:{fill:oe}}),e.jsx("text",{y:-5,textAnchor:"middle",fontSize:6.5,fontFamily:"ui-monospace, monospace",fontWeight:"500",opacity:.7,style:{fill:oe},children:Math.round(c.expected)})]},`tval-${c.idx}`)),ce&&le&&e.jsx("path",{d:le,fill:"none",strokeWidth:.75,strokeDasharray:"2 3",strokeLinecap:"round",opacity:.55,style:{stroke:ge,transition:`d ${I}`}}),q&&e.jsx("path",{d:q,fill:"none",strokeWidth:.75,strokeDasharray:"2 3",strokeLinecap:"round",opacity:.5,style:{stroke:re,transition:`d ${I}`}}),N&&e.jsx("path",{d:N,fill:"none",strokeWidth:.6,strokeLinejoin:"round",strokeLinecap:"round",opacity:.65,style:{stroke:J,transition:`d ${I}`}}),v.map((c,S)=>{if(c.pending<=0&&c.active<=0)return null;const O=Math.max(2.5,Math.min(5,2.5+c.active/10)),W=c.pending>c.active,B=Math.min(H[S].y-4,c.y-O-4);return e.jsxs("g",{children:[c.pending>0&&e.jsx("text",{x:c.x,y:B,textAnchor:"middle",fontSize:7.5,fontFamily:"ui-monospace, monospace",fontWeight:"600",style:{fill:W?ge:"rgb(var(--lt-text-tertiary))",transition:`y ${I}`},children:c.pending}),e.jsxs("g",{transform:`translate(${c.x} ${c.y})`,style:{transition:`transform ${I}`},children:[e.jsx("circle",{r:O,opacity:.85,style:{fill:re}}),c.active>0&&e.jsx("text",{y:O+9,textAnchor:"middle",fontSize:7.5,fontFamily:"ui-monospace, monospace",fontWeight:"600",style:{fill:re},children:c.active})]})]},`active-${c.idx}`)}),b.map(c=>{var pe;const S=t[c.idx],O=c.x,W=c.expected!=null?M(c.actual):Y,B=Math.max(2.25,Math.min(4,2.25+c.actual/160)),U=S.role===s,D=h===c.idx,z=c.expected==null?"idle · set a target rate to plot pace":`${c.actual} resolved · target ${Math.round(c.expected)}`+(c.pending>c.active?` · ${c.pending-c.active} pending`:"")+(c.active>0?` · ${c.active} claimed`:"")+(c.priorityCount>0?` · ${c.priorityCount} in jeopardy`:""),V=z.length*5.5+20,X=Math.max(ae+V/2+4,Math.min(Ue-V/2-4,O)),me=W-B-10;return e.jsxs("g",{onClick:Z=>{Z.metaKey||Z.ctrlKey?(Z.stopPropagation(),r==null||r(S.role)):l(S.role)},onMouseEnter:()=>u(c.idx),onMouseLeave:()=>u(null),style:{cursor:"pointer"},children:[e.jsxs("g",{transform:`translate(${O} ${W})`,style:{transition:`transform ${I}`},children:[e.jsx("circle",{r:22,fill:"transparent"}),e.jsx("circle",{r:B,opacity:.9,style:{fill:J,transition:`r ${I}`}}),c.expected!=null&&e.jsx("text",{y:-B-5,textAnchor:"middle",fontSize:9.5,fontFamily:"ui-monospace, monospace",fontWeight:"500",style:{fill:J},children:Ke(c.actual)}),D&&!U&&e.jsx("circle",{r:B+3,fill:"none",strokeWidth:1,opacity:.4,style:{stroke:J}}),U&&e.jsx("circle",{r:B+4,fill:"none",className:"stroke-accent",strokeWidth:2})]}),(((pe=S.upstream_roles)==null?void 0:pe.length)??0)>0&&e.jsxs("g",{transform:`translate(${O-20} ${Y})`,onClick:Z=>{Z.stopPropagation(),i==null||i(S.upstream_roles[0])},style:{cursor:"pointer"},children:[e.jsx("title",{children:`Fed by ${S.upstream_roles.join(", ")} — click to view that sequence`}),e.jsx("circle",{r:9,cy:-6,fill:"transparent"}),e.jsx("path",{d:"M -7 -14 C -3 -14 -1 -9 0 -2",fill:"none",className:"stroke-text-quaternary",strokeWidth:1,strokeDasharray:"2 2",strokeLinecap:"round"}),e.jsx("path",{d:"M 0 -2 L 8 -2",className:"stroke-text-quaternary",strokeWidth:1,strokeLinecap:"round"}),e.jsx("path",{d:"M 8 -2 l -3.5 -2 v 4 z",className:"fill-text-quaternary"})]}),e.jsx("text",{x:O,y:Y+(c.idx%2===0?14:27),textAnchor:"middle",fontSize:9.5,className:"fill-text-tertiary",fontFamily:"ui-sans-serif, sans-serif",fontWeight:"500",children:we(S)}),D&&e.jsxs("g",{children:[e.jsx("rect",{x:X-V/2,y:me-16,width:V,height:19,rx:3,className:"fill-text-primary",opacity:.88}),e.jsx("text",{x:X,y:me-3,textAnchor:"middle",fontSize:8.5,className:"fill-surface",fontFamily:"ui-monospace, monospace",children:z})]})]},S.role)}),!y&&e.jsx("text",{x:ae+Pe/2,y:Y+48,textAnchor:"middle",fontSize:8.5,className:"fill-text-quaternary",fontFamily:"ui-sans-serif, sans-serif",children:"Set target_per_hour on each role in Admin → Roles to enable the pace chart"}),ue.map(c=>e.jsx("text",{x:Ue+6,y:c.labelY,fontSize:8,fontFamily:"ui-sans-serif, sans-serif",fontWeight:c.key==="actual"?700:500,opacity:c.key==="active"?.85:1,style:{fill:c.color,transition:`y ${I}`},children:c.text},c.key))]})}function vt(t){const s=t.priority_facet?`metadata.${t.priority_facet}`:"created_at",l=JSON.stringify([{field:s,direction:"asc"}]);return`/escalations/available?role=${encodeURIComponent(t.role)}&jeopardy=1&view=table&orderBy=${encodeURIComponent(l)}`}function Ns({role:t,periodHours:s,onOpenEntity:l}){var L,k,$,R,v,H,Q;const i=Ve(s),r=t.entity_facet,[d,n]=g.useState(!1),[,o]=pt(),h=()=>{r&&o(N=>{const q=new URLSearchParams(N);return q.set("lens",r),q})},u=F({query:{roles:[t.role]},groupBy:{columns:["subtype"]},measure:{kind:"dwell",window:i},orderBy:[{field:"dwellSeconds",direction:"desc"}]}),m=F({query:{roles:[t.role]},groupBy:{columns:["subtype"]},measure:{kind:"membership"},orderBy:[{field:"count",direction:"desc"}]}),f=F(r?{query:{roles:[t.role]},groupBy:{},measure:{kind:"membership"},distinctBy:r}:null),j=F(r&&d?{query:{roles:[t.role],exists:[r]},groupBy:{facets:[r]},measure:{kind:"dwell",window:i},orderBy:[{field:"dwellSeconds",direction:"desc"}],limit:8}:null),b=g.useMemo(()=>{var N,q;return ct([...((N=u.data)==null?void 0:N.groups)??[],...((q=m.data)==null?void 0:q.groups)??[]])},[u.data,m.data]);if(Ee(u.error))return e.jsx("div",{className:"border-t border-surface-border/40 pt-4 mt-5",children:e.jsx("p",{className:"text-2xs text-text-quaternary",children:"Analytics require full read access to this station's queue."})});const y=(((L=u.data)==null?void 0:L.groups)??[]).filter(N=>(N.dwellSeconds??0)>0),w=y.reduce((N,q)=>N+(q.dwellSeconds??0),0),C=(((k=m.data)==null?void 0:k.groups)??[]).filter(N=>(N.count??0)>0),M=((R=($=f.data)==null?void 0:$.groups[0])==null?void 0:R.count)??null;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-surface-border/40 pt-4 mt-5",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-2.5",children:"Where the time went"}),w>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 flex rounded-full overflow-hidden bg-surface-sunken mb-2.5",children:y.map(N=>e.jsx("div",{style:{width:`${(N.dwellSeconds??0)/w*100}%`,backgroundColor:b.get(ie(N.subtype))}},ie(N.subtype)))}),e.jsx("div",{className:"space-y-1",children:y.map(N=>e.jsxs("div",{className:"flex items-center gap-2 text-2xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:b.get(ie(N.subtype))}}),e.jsx("span",{className:`font-mono truncate flex-1 ${N.subtype?"text-text-secondary":"text-text-tertiary"}`,children:Le(N.subtype)}),e.jsx("span",{className:"font-mono tabular-nums text-text-secondary shrink-0",children:de((N.dwellSeconds??0)*1e3)}),e.jsxs("span",{className:"font-mono tabular-nums text-text-quaternary w-8 text-right shrink-0",children:[Math.round((N.dwellSeconds??0)/w*100),"%"]})]},ie(N.subtype)))}),((v=u.data)==null?void 0:v.overflow)&&e.jsx("p",{className:"text-2xs text-text-quaternary mt-1.5",children:"more groups exist — narrow the window"})]}):e.jsx("p",{className:"text-2xs text-text-quaternary",children:"No tracked time in this window."})]}),e.jsxs("div",{className:"border-t border-surface-border/40 pt-4 mt-5",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-2.5",children:"In queue now"}),r&&M!=null&&e.jsxs("button",{onClick:h,className:"group flex items-center gap-1 text-2xs mb-2 text-left",title:`Open the ${r} lens — the whole system, entity-first`,children:[e.jsx("span",{className:"text-xs font-mono font-semibold text-text-primary tabular-nums",children:M})," ",e.jsx("span",{className:"font-mono text-text-tertiary group-hover:text-accent transition-colors",children:r}),e.jsx("span",{className:"text-text-quaternary",children:" in queue"}),e.jsx(zt,{className:"w-3 h-3 text-text-quaternary group-hover:text-accent transition-colors"})]}),C.length>0?e.jsx("div",{className:"space-y-1",children:C.map(N=>e.jsxs("div",{className:"flex items-center gap-2 text-2xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:b.get(ie(N.subtype))}}),e.jsx("span",{className:`font-mono truncate flex-1 ${N.subtype?"text-text-secondary":"text-text-tertiary"}`,children:Le(N.subtype)}),e.jsx("span",{className:"font-mono tabular-nums text-text-primary shrink-0",children:N.count})]},ie(N.subtype)))}):e.jsx("p",{className:"text-2xs text-text-quaternary",children:"Queue clear."}),r&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{onClick:()=>n(N=>!N),className:"flex items-center gap-1 text-2xs text-text-tertiary hover:text-accent transition-colors",children:[d?e.jsx(dt,{className:"w-3 h-3"}):e.jsx(Gt,{className:"w-3 h-3"}),"By entity"]}),d&&(Ee(j.error)?e.jsx("p",{className:"text-2xs text-text-quaternary mt-1.5",children:"Requires full read access to this station's queue."}):e.jsxs("div",{className:"space-y-1 mt-1.5",children:[(((H=j.data)==null?void 0:H.groups)??[]).map(N=>{const q=N.facets[r];return q==null?null:e.jsxs("div",{className:"flex items-center gap-2 text-2xs",children:[e.jsx("span",{className:"font-mono truncate flex-1 text-text-secondary",title:q,children:q}),e.jsx("span",{className:"font-mono tabular-nums text-text-secondary shrink-0",children:de((N.dwellSeconds??0)*1e3)}),e.jsx("button",{className:"icon-link shrink-0",title:"Open timeline",onClick:()=>l(r,q),children:e.jsx(it,{className:"w-3 h-3"})})]},q)}),j.data&&j.data.groups.length===0&&e.jsx("p",{className:"text-2xs text-text-quaternary",children:"No entities in this window."}),((Q=j.data)==null?void 0:Q.overflow)&&e.jsx("p",{className:"text-2xs text-text-quaternary",children:"top 8 by dwell"})]}))]})]})]})}const kt=["15m","1h","24h","7d","30d"],vs=t=>kt.includes(t),ks={"15m":.25,"1h":1,"24h":24,"7d":168,"30d":720};function Ce(t){if(t==null)return"—";if(t<1){const s=Math.round(t*60);return s<=0?"< 1s":`${s}s`}return t<60?`${t.toFixed(0)}m`:`${(t/60).toFixed(1)}h`}function _e({label:t,value:s}){return e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsx("span",{className:"text-2xs text-text-tertiary uppercase tracking-wider",children:t}),e.jsx("span",{className:"text-xs font-mono font-medium text-text-primary tabular-nums",children:s})]})}function $s({period:t,onChange:s}){return e.jsx("div",{className:"flex items-center gap-1 mb-4",children:kt.map(l=>e.jsx("button",{onClick:()=>s(l),className:`px-2 py-0.5 text-2xs font-mono rounded transition-colors ${t===l?"bg-accent/10 text-accent font-semibold":"icon-link"}`,children:l},l))})}function Ss({role:t,globalPeriod:s,scopeFacets:l,onClose:i}){const[r,d]=g.useState(vs(s)?s:"24h"),{data:n}=ot(r,l),o=n==null?void 0:n.stations.find(b=>b.role===t.role),h=t.sla_minutes??void 0,u=t.target_per_hour??void 0,m=t.worker_count??void 0,f=rt(),j=g.useCallback((b,y)=>{f==null||f.setPanel(t.entity_facet?e.jsx(ze,{facetKey:b,value:y,entity:t.entity_facet}):e.jsx(ze,{facetKey:b,value:y,role:t.role}),{key:"entity-timeline",width:420})},[f,t.role,t.entity_facet]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-sm font-bold text-text-primary",children:we(t)}),e.jsx("span",{className:"text-2xs font-mono text-text-secondary",children:t.role})]}),t.description&&e.jsx("p",{className:"text-2xs text-text-tertiary mt-1 line-clamp-2 leading-relaxed",children:t.description})]}),e.jsx("button",{onClick:i,className:"icon-link mt-0.5 shrink-0 ml-2",children:e.jsx(Ht,{className:"w-4 h-4"})})]}),o&&o.priority_count>0&&e.jsxs(ne,{to:vt(t),className:"flex items-center justify-between group mb-4",children:[e.jsxs("span",{className:"text-2xs",style:{color:je},children:[o.priority_count," in jeopardy — pull oldest first"]}),e.jsx(Vt,{className:"w-3 h-3 transition-colors",style:{color:je}})]}),e.jsx($s,{period:r,onChange:d}),(u||h||m)&&e.jsxs("div",{className:"flex items-center gap-6 mb-6 text-2xs border-b border-surface-border/30 pb-5",children:[u&&e.jsxs("div",{children:[e.jsxs("div",{className:"font-mono font-semibold text-text-primary text-sm",children:[u,"/h"]}),e.jsx("div",{className:"text-text-quaternary uppercase tracking-wider text-[8.5px] mt-0.5",children:"target"})]}),h&&e.jsxs("div",{children:[e.jsxs("div",{className:"font-mono font-semibold text-text-primary text-sm",children:[h,"m"]}),e.jsx("div",{className:"text-text-quaternary uppercase tracking-wider text-[8.5px] mt-0.5",children:"SLA"})]}),m&&e.jsxs("div",{children:[e.jsx("div",{className:"font-mono font-semibold text-text-primary text-sm",children:m}),e.jsx("div",{className:"text-text-quaternary uppercase tracking-wider text-[8.5px] mt-0.5",children:"workers"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs text-text-quaternary uppercase tracking-wider mb-2",children:"Wait (queue)"}),e.jsx(_e,{label:"P99",value:Ce((o==null?void 0:o.wait.p99)??null)}),e.jsx(_e,{label:"avg",value:Ce((o==null?void 0:o.wait.avg)??null)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs text-text-quaternary uppercase tracking-wider mb-2",children:"Work (proc.)"}),e.jsx(_e,{label:"P99",value:Ce((o==null?void 0:o.work.p99)??null)}),e.jsx(_e,{label:"avg",value:Ce((o==null?void 0:o.work.avg)??null)})]})]}),h&&e.jsx("div",{className:"border-t border-surface-border/40 pt-4 mt-5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-2xs text-text-tertiary",children:"SLA target"}),e.jsxs("span",{className:"text-xs font-mono text-text-secondary",children:[h,"m"]})]})}),e.jsx(Ns,{role:t,periodHours:ks[r],onOpenEntity:j})]})}function Ms({allMetrics:t,orderedRoles:s,period:l}){const i=t.reduce((u,m)=>u+m.pending,0),r=t.reduce((u,m)=>u+m.resolved,0),d=t.reduce((u,m)=>u+m.priority_count,0),n=new Map(t.map(u=>[u.role,u])),o=t.filter(u=>u.priority_count>0).length,h=t.filter(u=>u.pending>0).length;return e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-2xs text-text-quaternary uppercase tracking-wider mb-3",children:["Pipeline · ",l]}),e.jsx("div",{className:"mb-4",children:o>0?e.jsxs("p",{className:"text-2xs",style:{color:je},children:[o," role",o>1?"s":""," with items in jeopardy"]}):h>0?e.jsxs("p",{className:"text-2xs text-status-warning",children:[h," role",h>1?"s":""," with backlog"]}):r>0?e.jsx("p",{className:"text-2xs text-status-success",children:"Flowing — queue clear"}):e.jsx("p",{className:"text-2xs text-text-quaternary",children:"Quiet — awaiting work"})}),e.jsxs("div",{className:"space-y-1.5 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider",children:"Pending"}),e.jsx("span",{className:`text-xs font-mono tabular-nums ${i>0?"text-text-primary font-semibold":"text-text-quaternary"}`,children:i})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider",children:["Resolved · ",l]}),e.jsx("span",{className:"text-xs font-mono tabular-nums text-text-secondary",children:r})]}),d>0&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider",children:"Priority"}),e.jsx("span",{className:"text-xs font-mono tabular-nums font-semibold",style:{color:je},children:d})]})]}),e.jsx("div",{className:"border-t border-surface-border/40 pt-2 mb-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider flex-1",children:"Role"}),e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider w-8 text-right shrink-0",children:"pend"}),e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider w-8 text-right shrink-0",children:"clmd"}),e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider w-8 text-right shrink-0",children:"res"})]})}),e.jsx("div",{className:"space-y-0.5",children:s.map(u=>{const m=n.get(u.role),f=(m==null?void 0:m.pending)??0,j=(m==null?void 0:m.claimed)??0,b=(m==null?void 0:m.resolved)??0,y=(m==null?void 0:m.priority_count)??0,w=u.title||u.role,C=y>0,M=f>0;return e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:`text-2xs font-mono flex-1 truncate ${M?"text-text-primary":"text-text-quaternary"}`,title:w,children:w}),e.jsx("span",{className:"text-[0.625rem] leading-none font-semibold tabular-nums w-4 text-right shrink-0",style:{color:je},title:C?`${y} priority — pull oldest first`:void 0,children:C?y:""}),e.jsx("span",{className:`text-2xs font-mono tabular-nums w-8 text-right shrink-0 ${M?"text-text-primary font-semibold":"text-text-quaternary"}`,children:f>0?f:"—"}),e.jsx("span",{className:`text-2xs font-mono tabular-nums w-8 text-right shrink-0 ${j>0?"text-accent font-semibold":"text-text-quaternary"}`,children:j>0?j:"—"}),e.jsx("span",{className:`text-2xs font-mono tabular-nums w-8 text-right shrink-0 ${b>0?"text-text-secondary":"text-text-quaternary"}`,children:b>0?b:"—"})]},u.role)})}),e.jsx("p",{className:"text-2xs text-text-quaternary mt-5",children:"Select a station for queue detail."})]})}function qs({role:t,allMetrics:s,orderedRoles:l,globalPeriod:i,scopeFacets:r,mixGroups:d,onClose:n}){return e.jsx("div",{className:"w-[280px] shrink-0 px-7 py-10 flex flex-col overflow-y-auto min-h-0",children:t?e.jsx(Ss,{role:t,globalPeriod:i,scopeFacets:r,onClose:n}):e.jsxs(e.Fragment,{children:[e.jsx(Ms,{allMetrics:s,orderedRoles:l,period:i}),e.jsx(Cs,{mixGroups:d,orderedRoles:l})]})})}function Cs({mixGroups:t,orderedRoles:s}){const l=new Set(s.map(o=>o.role)),i=(t??[]).filter(o=>o.role&&l.has(o.role)&&(o.dwellSeconds??0)>0);if(i.length===0)return null;const r=new Map(s.map(o=>[o.role,o.title||o.role])),d=et(i,o=>o.role),n=et(i,o=>Le(o.subtype));return e.jsxs(e.Fragment,{children:[e.jsx(tt,{label:"Time by station",entries:d,display:o=>r.get(o)??o}),e.jsx(tt,{label:"Time by subtype",entries:n,display:o=>o})]})}function et(t,s){const l=new Map;for(const i of t){const r=s(i);l.set(r,(l.get(r)??0)+(i.dwellSeconds??0))}return[...l.entries()].sort(([,i],[,r])=>r-i)}function tt({label:t,entries:s,display:l}){const i=lt(s.map(([d,n])=>({label:d,weight:n}))),r=s.reduce((d,[,n])=>d+n,0)||1;return e.jsxs("div",{className:"border-t border-surface-border/40 pt-4 mt-5",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-2.5",children:t}),e.jsx("div",{className:"h-2 flex rounded-full overflow-hidden bg-surface-sunken mb-2",children:s.map(([d,n])=>e.jsx("div",{style:{width:`${n/r*100}%`,backgroundColor:i.get(d)}},d))}),e.jsxs("div",{className:"space-y-0.5",children:[s.slice(0,6).map(([d,n])=>e.jsxs("div",{className:"flex items-center gap-2 text-2xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:i.get(d)}}),e.jsx("span",{className:"font-mono text-text-secondary truncate flex-1",children:l(d)}),e.jsx("span",{className:"font-mono tabular-nums text-text-tertiary shrink-0",children:de(n*1e3)}),e.jsxs("span",{className:"font-mono tabular-nums text-text-quaternary w-8 text-right shrink-0",children:[Math.round(n/r*100),"%"]})]},d)),s.length>6&&e.jsxs("p",{className:"text-2xs text-text-quaternary",children:["+",s.length-6," more"]})]})]})}const _s=oe,Ae=Fe(oe,.12),$t=Ae,St=Ae,Mt=Fe(ge,.24),qt=Fe(re,.24),Ct=Fe(J,.24),st=["15m","1h","24h","7d","30d"],Re={"15m":.25,"1h":1,"24h":24,"7d":168,"30d":720};function He(t){const s=t.filter(n=>n.ops_visible),l=new Map(s.map(n=>[n.role,n])),i=new Set,d=s.filter(n=>!n.parent_role||!l.has(n.parent_role)).map(n=>{const o=[],h=[{role:n,depth:0}];for(;h.length>0;){const u=h.shift();i.has(u.role.role)||(i.add(u.role.role),o.push(u),s.filter(m=>m.parent_role===u.role.role&&!i.has(m.role)).forEach(m=>h.push({role:m,depth:u.depth+1})))}return{origin:n,stations:o}});return s.filter(n=>!i.has(n.role)).forEach(n=>d.push({origin:n,stations:[{role:n,depth:0}]})),d.sort((n,o)=>o.stations.length-n.stations.length||n.origin.role.localeCompare(o.origin.role))}function nt(t){if(t==null)return"—";if(t<1){const s=Math.round(t*60);return s<=0?"< 1s":`${s}s`}return t<60?`${t.toFixed(0)}m`:`${(t/60).toFixed(1)}h`}function Rs(t,s){if(!s||t===0)return{pct:null,color:"bg-surface-border"};const l=t/s,i=Math.round(l*100),r=l>1?"bg-status-warning":l<.2?"bg-status-draft":"bg-status-success";return{pct:i,color:r}}function at({value:t,onSave:s}){const[l,i]=g.useState(t!=null?String(t):""),r=g.useRef(void 0),d=n=>{const o=parseInt(n,10);s(!n.trim()||isNaN(o)||o<0?null:o)};return e.jsx("input",{type:"number",min:0,step:1,value:l,onChange:n=>{const o=n.target.value;i(o),clearTimeout(r.current),r.current=setTimeout(()=>d(o),400)},onBlur:n=>{clearTimeout(r.current),d(n.target.value)},onClick:n=>n.stopPropagation(),onKeyDown:n=>n.stopPropagation(),className:"w-full bg-transparent text-xs font-mono tabular-nums text-right focus:outline-none"})}function Ps({role:t,metric:s,mixGroups:l,mixColors:i,selected:r,periodHours:d,onClick:n}){var R;const o=It(),{isBuilder:h,isOps:u}=Tt(),m=(s==null?void 0:s.pending)??0,f=(s==null?void 0:s.claimed)??0,j=(s==null?void 0:s.resolved)??0,b=(s==null?void 0:s.priority_count)??0,y=t.target_per_hour??null,{pct:w,color:C}=Rs(m,y),M=w!=null?Math.min(100,w):0,L=Es(t.target_per_hour??null,t.sla_minutes??null,m,d),k=v=>o.mutate({role:t.role,target_per_hour:v}),$=v=>o.mutate({role:t.role,sla_minutes:v});return e.jsxs("tr",{tabIndex:0,onClick:n,onKeyDown:v=>{v.key==="Enter"&&n()},className:`cursor-pointer border-b border-surface-border/30 last:border-b-0 transition-colors ${r?"border-l-2 !border-l-accent":""}`,children:[e.jsx("td",{className:"pl-3 pr-2 py-1.5 overflow-hidden",children:e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-bold text-text-primary truncate text-xs",children:we(t)}),(((R=t.upstream_roles)==null?void 0:R.length)??0)>0&&e.jsx("span",{title:`Fed by ${t.upstream_roles.join(", ")}`,className:"shrink-0 leading-none",children:e.jsx(Qt,{className:"w-3 h-3 text-text-quaternary"})})]})}),e.jsx("td",{className:"hidden xl:table-cell pr-2 py-1.5 overflow-hidden",children:e.jsx("span",{className:"block font-mono text-2xs text-text-tertiary truncate",children:t.role})}),e.jsx("td",{className:"px-2 py-1.5",style:{backgroundColor:Ae},children:e.jsx(at,{value:t.target_per_hour??null,onSave:k})}),e.jsx("td",{className:"px-2 py-1.5",style:{backgroundColor:$t},children:e.jsx(at,{value:t.sla_minutes??null,onSave:$})}),e.jsx("td",{className:"px-2 py-1.5 text-right",style:{backgroundColor:St},title:L!=null?`~${L} concurrent worker${L===1?"":"s"} to sustain ${t.target_per_hour}/h within ${t.sla_minutes}m SLA`:void 0,children:e.jsx("span",{className:`text-xs font-mono tabular-nums ${L!=null?"":"text-text-quaternary"}`,children:L??"—"})}),e.jsx("td",{className:"px-2 py-1.5 text-right",style:{backgroundColor:Mt},children:e.jsx(ne,{to:`/escalations/available?role=${encodeURIComponent(t.role)}&status=available`,className:`text-xs font-mono tabular-nums hover:underline ${m>0?"text-text-primary font-semibold":"text-text-quaternary"}`,onClick:v=>v.stopPropagation(),children:m})}),e.jsx("td",{className:"px-2 py-1.5 text-right",style:{backgroundColor:qt},children:e.jsx(ne,{to:`/escalations/available?role=${encodeURIComponent(t.role)}&status=claimed`,className:`text-xs font-mono tabular-nums hover:underline ${f>0?"font-semibold":"text-text-quaternary"}`,style:f>0?{color:re}:void 0,onClick:v=>v.stopPropagation(),children:f})}),e.jsx("td",{className:"px-2 py-1.5 text-right",style:{backgroundColor:Ct},children:e.jsx(ne,{to:`/escalations/available?role=${encodeURIComponent(t.role)}&status=resolved`,className:`text-xs font-mono tabular-nums hover:underline ${j>0?"text-text-secondary":"text-text-quaternary"}`,style:j>0?{color:J}:void 0,onClick:v=>v.stopPropagation(),children:j})}),e.jsx("td",{className:"hidden xl:table-cell px-2 py-1.5 text-right",children:e.jsx("span",{className:"text-xs font-mono tabular-nums text-text-secondary",children:nt((s==null?void 0:s.wait.p99)??null)})}),e.jsx("td",{className:"hidden xl:table-cell px-2 py-1.5 text-right",children:e.jsx("span",{className:"text-xs font-mono tabular-nums text-text-secondary",children:nt((s==null?void 0:s.work.p99)??null)})}),e.jsx("td",{className:"hidden lg:table-cell px-2 py-1.5",children:e.jsx(Kt,{groups:l,colors:i})}),e.jsx("td",{className:"hidden lg:table-cell px-2 py-1.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-12 h-1.5 bg-surface-sunken rounded-full overflow-hidden shrink-0",children:e.jsx("div",{className:`h-full rounded-full ${C}`,style:{width:`${M}%`}})}),e.jsx("span",{className:`text-2xs font-mono tabular-nums ${w!=null&&w>100?"text-status-warning font-semibold":"text-text-quaternary"}`,children:w!=null?`${w}%`:"—"})]})}),e.jsx("td",{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center justify-center gap-1.5",children:[e.jsx(ne,{to:`/escalations/available?role=${encodeURIComponent(t.role)}&status=all`,className:"icon-link",title:"View all items in queue",onClick:v=>v.stopPropagation(),children:e.jsx(ut,{className:"w-3.5 h-3.5"})}),e.jsx("span",{className:"w-3.5 flex items-center justify-center",children:(h||u)&&e.jsx(ne,{to:`/admin/roles/${encodeURIComponent(t.role)}?section=pace-board`,className:"icon-link",title:"Configure this role",onClick:v=>v.stopPropagation(),children:e.jsx(Xt,{className:"w-3.5 h-3.5"})})}),e.jsx("span",{className:"w-3.5 flex items-center justify-center",children:b>0&&e.jsx(ne,{to:vt(t),className:"text-status-error hover:opacity-70 transition-opacity",title:`${b} item${b===1?"":"s"} in jeopardy — pull oldest first`,onClick:v=>v.stopPropagation(),children:e.jsx(xt,{className:"w-3.5 h-3.5",strokeWidth:2})})})]})})]})}const Ls=[{label:"TARGET/H",band:Ae,hue:oe,w:"w-[8%]"},{label:"SLA/M",band:$t,hue:_s,w:"w-[7%]"},{label:"WORKERS",band:St,hue:oe,w:"w-[8%]"},{label:"PENDING",band:Mt,hue:ge,w:"w-[8%]"},{label:"CLAIMED",band:qt,hue:re,w:"w-[8%]"},{label:"RESOLVED",band:Ct,hue:J,w:"w-[8%]"}];function Es(t,s,l,i){if(!t||!s)return null;const r=t*s/60,d=l>0?l*s/(60*i):0;return Math.ceil(r+d)}const se="sticky top-0 z-10 bg-surface border-b border-surface-border py-1.5 text-2xs font-semibold uppercase tracking-wider whitespace-nowrap";function Os(){return e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:`${se} pl-3 pr-2 text-left text-text-quaternary`,children:"NAME"}),e.jsx("th",{className:`${se} hidden xl:table-cell w-[12%] pr-2 text-left text-text-quaternary`,children:"ROLE"}),Ls.map(t=>e.jsx("th",{className:`${se} ${t.w} px-2 text-right`,style:{color:t.hue,backgroundImage:`linear-gradient(${t.band}, ${t.band})`},children:t.label},t.label)),e.jsx("th",{className:`${se} hidden xl:table-cell w-[8%] px-2 text-right text-text-quaternary`,children:"P99 WAIT"}),e.jsx("th",{className:`${se} hidden xl:table-cell w-[8%] px-2 text-right text-text-quaternary`,children:"P99 WORK"}),e.jsx("th",{className:`${se} hidden lg:table-cell w-[10%] px-2 text-left text-text-quaternary`,children:"MIX"}),e.jsx("th",{className:`${se} hidden lg:table-cell w-[11%] px-2 text-left text-text-quaternary`,children:"TREND"}),e.jsx("th",{className:`${se} w-20 px-1 text-center text-text-quaternary`,children:"ACTIONS"})]})})}function Bs(){var be;const[t,s]=g.useState(null),[l,i]=g.useState(!1),[r,d]=g.useState(!0);Et(),Ot();const{data:n,isLoading:o,refetch:h}=Bt(),{declarations:u,values:m}=Ft(),f=g.useMemo(()=>Object.keys(m).length?m:void 0,[m]),[j,b]=g.useState(!1),[y,w]=pt(),C=Zt(),M=mt(),L=C.pathname==="/trends",k=y.get("period"),$=st.includes(k)?k:"1h",R=g.useCallback(x=>{w(a=>{const p=new URLSearchParams(a);return x==="1h"?p.delete("period"):p.set("period",x),p})},[w]),{data:v,isLoading:H,refetch:Q}=ot($,f),N=(n==null?void 0:n.roles)??[],q=(v==null?void 0:v.stations)??[],le=g.useMemo(()=>{const x=new Map(q.map(p=>[p.role,p])),a=new Map;for(const p of He((n==null?void 0:n.roles)??[])){let G=0,Qe=0;for(const _t of p.stations){const he=x.get(_t.role.role);G+=(he==null?void 0:he.pending)??0,Qe+=(he==null?void 0:he.priority_count)??0}a.set(p.origin.role,{stations:p.stations.length,pending:G,jeopardy:Qe})}return a},[q,n]),E=g.useMemo(()=>He(N),[N]),xe=y.get("fragment"),A=E.find(x=>x.origin.role===xe)??E[0]??null,K=g.useCallback(x=>{s(null);const a=new URLSearchParams;x&&a.set("fragment",x),$!=="1h"&&a.set("period",$);const p=a.toString();M(p?`/pace?${p}`:"/pace")},[M,$]),P=(A==null?void 0:A.stations)??[],ce=g.useMemo(()=>new Set(P.map(({role:x})=>x.role)),[P]),_=Ve(Re[$]),ee=g.useMemo(()=>P.map(({role:x})=>x.role),[P]),{data:T}=F(ee.length?{query:{roles:ee,...f?{facets:f}:{}},groupBy:{columns:["role","subtype"]},measure:{kind:"dwell",window:_}}:null),te=g.useMemo(()=>{const x=new Map;for(const a of(T==null?void 0:T.groups)??[]){if(!a.role)continue;const p=x.get(a.role)??[];p.push(a),x.set(a.role,p)}return x},[T]),ue=g.useMemo(()=>{const x=new Map;for(const[a,p]of te)x.set(a,ct(p));return x},[te]),c=g.useMemo(()=>new Map,[]),S=g.useMemo(()=>q.filter(x=>ce.has(x.role)),[q,ce]),O=g.useMemo(()=>P.map(({role:x})=>({role:x.role,title:x.title,parent_role:x.parent_role,target_per_hour:x.target_per_hour??null,upstream_roles:x.upstream_roles??[],metric:q.find(a=>a.role===x.role)})),[P,q]),W=g.useCallback(x=>{const a=E.find(p=>p.stations.some(({role:G})=>G.role===x));a&&K(a.origin.role)},[E,K]),B=((be=P.find(({role:x})=>x.role===t))==null?void 0:be.role)??null,U=g.useMemo(()=>{const x=new Set;for(const a of N)a.ops_visible&&a.entity_facet&&x.add(a.entity_facet);return[...x].sort()},[N]),D=y.get("lens"),z=L?D&&U.includes(D)?D:U[0]??null:null,V=g.useCallback(x=>{s(null);const a=new URLSearchParams;x&&a.set("lens",x),$!=="1h"&&a.set("period",$);const p=a.toString();M(p?`/trends?${p}`:"/trends")},[M,$]),X=y.get("entity"),me=y.get("find"),pe=g.useCallback(x=>{w(a=>{const p=new URLSearchParams(a);return x?p.set("entity",x):p.delete("entity"),p})},[w]),Z=g.useCallback(x=>{w(a=>{const p=new URLSearchParams(a);return x?p.set("find",x):p.delete("find"),p},{replace:!0})},[w]),Ne=y.get("slice"),ve=y.get("sliceValue"),ke=g.useCallback(x=>{w(a=>{const p=new URLSearchParams(a);return x?p.set("slice",x):p.delete("slice"),p.delete("sliceValue"),p})},[w]),Ie=g.useCallback(x=>{w(a=>{const p=new URLSearchParams(a);return x?p.set("sliceValue",x):p.delete("sliceValue"),p})},[w]),Te=o||H,We=async()=>{i(!0),await Promise.all([h(),Q()]),i(!1)},ye=x=>s(a=>a===x?null:x),$e=g.useMemo(()=>E.map(x=>{const a=le.get(x.origin.role);return{origin:x.origin.role,title:we(x.origin),roleCount:(a==null?void 0:a.stations)??x.stations.length,pending:(a==null?void 0:a.pending)??0,jeopardy:(a==null?void 0:a.jeopardy)??0}}),[E,le]),Se=e.jsx("div",{className:"flex items-center gap-0.5",children:st.map(x=>e.jsx("button",{onClick:()=>R(x),className:`px-2.5 py-1 text-2xs font-mono rounded transition-colors ${$===x?"bg-accent/10 text-accent font-semibold":"icon-link"}`,children:x},x))});return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx(Jt,{title:z?"Trend Board":"Pace Board",docsHash:"#docs:dashboard.md:pace-board",center:Se,actions:e.jsxs("div",{className:"flex items-center gap-3",children:[u.length>0&&e.jsxs("button",{onClick:()=>b(!0),title:"Scope this board — bind facets for this device","data-testid":"board-scope-pill",className:`flex items-center gap-1.5 px-2 py-0.5 text-2xs rounded-full border transition-colors ${f?"border-accent/40 bg-accent/10 text-accent hover:bg-accent/15":"border-surface-border bg-surface-sunken text-text-tertiary hover:text-text-secondary"}`,children:[e.jsx(ut,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"truncate max-w-48 font-mono",children:f?Object.entries(m).map(([x,a])=>`${x} = ${a}`).join(", "):"All"})]}),e.jsx("button",{onClick:We,disabled:l,className:"icon-link disabled:opacity-40",children:e.jsx(Yt,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})}),Te?e.jsxs("div",{className:"animate-pulse space-y-6 mt-4",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),e.jsx("div",{className:"h-64 bg-surface-sunken rounded w-full"}),e.jsx("div",{className:"space-y-3",children:[1,2,3].map(x=>e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-full"},x))})]}):E.length===0?e.jsxs("div",{className:"mt-8",children:[e.jsx("p",{className:"text-sm text-text-secondary mb-2",children:"Roles appear here once they are marked visible in Operations."}),e.jsxs("p",{className:"text-xs text-text-tertiary",children:["Go to"," ",e.jsx(ne,{to:"/admin/roles",className:"text-accent hover:underline",children:"Roles"})," ","and enable ",e.jsx("strong",{children:"Visible in Operations"})," on the roles that belong to a pace segment."]})]}):e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[(E.length>1||U.length>0)&&e.jsx("div",{className:"flex items-end justify-end",children:e.jsx("div",{className:"px-4 pt-2 pb-0.5",children:e.jsx(xs,{fragments:$e,activeFragment:(A==null?void 0:A.origin.role)??null,lenses:U,activeLens:z,onSelectFragment:K,onSelectLens:V})})}),z?e.jsx(ds,{entityKey:z,periodHours:Re[$],roles:N,scopeFacets:f,find:me,onFindChange:Z,entityValue:X,onEntityChange:pe,sliceKey:Ne,onSliceKeyChange:ke,sliceValue:ve,onSliceValueChange:Ie},z):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 min-h-[40vh] flex items-stretch overflow-hidden",children:[e.jsxs("div",{className:"flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden px-2 py-4",children:[e.jsx("div",{className:"flex items-center justify-center gap-0.5 pb-2 shrink-0",children:["lin","log"].map(x=>e.jsx("button",{onClick:()=>d(x==="log"),className:`px-2 py-0.5 text-2xs font-mono rounded transition-colors ${(r?"log":"lin")===x?"text-accent font-semibold":"icon-link"}`,title:x==="lin"?"Linear Y axis":"Logarithmic Y axis — reveals shape across wide value ranges",children:x},x))}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col justify-center overflow-hidden",children:e.jsx(ws,{stations:O,selectedRole:t,onSelect:ye,onUpstreamSelect:W,onCmdClick:x=>M(`/escalations/available?role=${encodeURIComponent(x)}`),periodHours:Re[$],logScale:r})})]}),e.jsx("div",{className:"w-px bg-surface-border shrink-0 self-stretch"}),e.jsx(qs,{role:B,allMetrics:S,orderedRoles:P.map(x=>x.role),globalPeriod:$,scopeFacets:f,mixGroups:T==null?void 0:T.groups,onClose:()=>s(null)})]}),e.jsx("div",{className:"max-h-[30vh] flex-none overflow-y-auto border-t border-surface-border",children:e.jsxs("table",{className:"w-full table-fixed",children:[e.jsx(Os,{}),e.jsx("tbody",{children:P.map(({role:x})=>e.jsx(Ps,{role:x,metric:q.find(a=>a.role===x.role),mixGroups:te.get(x.role),mixColors:ue.get(x.role)??c,selected:t===x.role,periodHours:Re[$],onClick:()=>ye(x.role)},x.role))})]})})]})]}),e.jsx(At,{open:j,onClose:()=>b(!1)})]})}const Us=Object.freeze(Object.defineProperty({__proto__:null,OperationsPage:Bs,buildFragments:He},Symbol.toStringTag,{value:"Module"}));export{Us as O,ws as P,He as b,vt as j};
3
- //# sourceMappingURL=OperationsPage-aLHHAP2X.js.map