@hotmeshio/long-tail 0.12.0 → 0.13.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 (257) hide show
  1. package/README.md +1 -0
  2. package/build/api/escalations/helpers.js +4 -2
  3. package/build/api/settings.js +3 -0
  4. package/build/services/agent/index.d.ts +11 -0
  5. package/build/services/agent/index.js +32 -0
  6. package/build/services/agent/sql.d.ts +7 -0
  7. package/build/services/agent/sql.js +32 -1
  8. package/build/services/agent/subscription-sql.d.ts +6 -0
  9. package/build/services/agent/subscription-sql.js +32 -1
  10. package/build/services/agent/subscriptions.d.ts +6 -0
  11. package/build/services/agent/subscriptions.js +23 -0
  12. package/build/services/config/index.d.ts +1 -1
  13. package/build/services/config/index.js +2 -1
  14. package/build/services/config/write.d.ts +10 -0
  15. package/build/services/config/write.js +49 -2
  16. package/build/services/domain/seed.d.ts +12 -5
  17. package/build/services/domain/seed.js +25 -6
  18. package/build/services/mcp/db.d.ts +16 -0
  19. package/build/services/mcp/db.js +24 -0
  20. package/build/services/mcp/sql.d.ts +8 -0
  21. package/build/services/mcp/sql.js +24 -1
  22. package/build/services/role/seed.d.ts +21 -0
  23. package/build/services/role/seed.js +113 -0
  24. package/build/services/role/sql.d.ts +8 -0
  25. package/build/services/role/sql.js +24 -1
  26. package/build/services/role/types.d.ts +7 -3
  27. package/build/services/role/types.js +7 -3
  28. package/build/services/topics/index.d.ts +2 -0
  29. package/build/services/topics/index.js +7 -0
  30. package/build/services/topics/sql.d.ts +2 -0
  31. package/build/services/topics/sql.js +5 -1
  32. package/build/services/topics/system-topics.d.ts +3 -2
  33. package/build/services/topics/system-topics.js +4 -3
  34. package/build/services/user/index.d.ts +1 -1
  35. package/build/services/user/index.js +2 -1
  36. package/build/services/user/roles.d.ts +8 -0
  37. package/build/services/user/roles.js +29 -0
  38. package/build/services/user/sql.d.ts +6 -0
  39. package/build/services/user/sql.js +9 -1
  40. package/build/services/user/sso-provision.js +14 -3
  41. package/build/start/apply-report.d.ts +26 -0
  42. package/build/start/apply-report.js +65 -0
  43. package/build/start/config.js +8 -1
  44. package/build/start/workers.js +170 -33
  45. package/build/tsconfig.tsbuildinfo +1 -1
  46. package/build/types/auth.d.ts +27 -1
  47. package/build/types/index.d.ts +1 -1
  48. package/build/types/startup.d.ts +108 -4
  49. package/dashboard/dist/assets/{AdminDashboard-CahUELrr.js → AdminDashboard-D2unnS2b.js} +2 -2
  50. package/dashboard/dist/assets/{AdminDashboard-CahUELrr.js.map → AdminDashboard-D2unnS2b.js.map} +1 -1
  51. package/dashboard/dist/assets/{AgentConfigPage-CkMv-cTV.js → AgentConfigPage-CBkf403g.js} +2 -2
  52. package/dashboard/dist/assets/{AgentConfigPage-CkMv-cTV.js.map → AgentConfigPage-CBkf403g.js.map} +1 -1
  53. package/dashboard/dist/assets/{AgentDetailPage-ZGea3Z4A.js → AgentDetailPage-CAIU3yzo.js} +2 -2
  54. package/dashboard/dist/assets/{AgentDetailPage-ZGea3Z4A.js.map → AgentDetailPage-CAIU3yzo.js.map} +1 -1
  55. package/dashboard/dist/assets/{AgentsPage-BMWSUJGi.js → AgentsPage-qP9fWMyT.js} +2 -2
  56. package/dashboard/dist/assets/{AgentsPage-BMWSUJGi.js.map → AgentsPage-qP9fWMyT.js.map} +1 -1
  57. package/dashboard/dist/assets/AvailableEscalationsPage-DvWaiafI.js +2 -0
  58. package/dashboard/dist/assets/AvailableEscalationsPage-DvWaiafI.js.map +1 -0
  59. package/dashboard/dist/assets/{BotPicker-DN8tq7pz.js → BotPicker-BN-MKITV.js} +2 -2
  60. package/dashboard/dist/assets/{BotPicker-DN8tq7pz.js.map → BotPicker-BN-MKITV.js.map} +1 -1
  61. package/dashboard/dist/assets/{CapabilitiesPage-EAO3Ae0S.js → CapabilitiesPage-CJfmWokN.js} +2 -2
  62. package/dashboard/dist/assets/{CapabilitiesPage-EAO3Ae0S.js.map → CapabilitiesPage-CJfmWokN.js.map} +1 -1
  63. package/dashboard/dist/assets/{CollapsibleSection-J-RejbjG.js → CollapsibleSection-BvMHlHyt.js} +2 -2
  64. package/dashboard/dist/assets/{CollapsibleSection-J-RejbjG.js.map → CollapsibleSection-BvMHlHyt.js.map} +1 -1
  65. package/dashboard/dist/assets/{CountdownTimer-Dw8N9tmQ.js → CountdownTimer-By4rbMDN.js} +2 -2
  66. package/dashboard/dist/assets/{CountdownTimer-Dw8N9tmQ.js.map → CountdownTimer-By4rbMDN.js.map} +1 -1
  67. package/dashboard/dist/assets/{CredentialsPage-CTurxwRn.js → CredentialsPage-2TvvRwGJ.js} +2 -2
  68. package/dashboard/dist/assets/{CredentialsPage-CTurxwRn.js.map → CredentialsPage-2TvvRwGJ.js.map} +1 -1
  69. package/dashboard/dist/assets/{CronLabel-DZ5TmIQG.js → CronLabel-HxmsDSnV.js} +2 -2
  70. package/dashboard/dist/assets/{CronLabel-DZ5TmIQG.js.map → CronLabel-HxmsDSnV.js.map} +1 -1
  71. package/dashboard/dist/assets/{CustomDurationPicker-BES_FTrm.js → CustomDurationPicker-8Ao-1pKA.js} +2 -2
  72. package/dashboard/dist/assets/{CustomDurationPicker-BES_FTrm.js.map → CustomDurationPicker-8Ao-1pKA.js.map} +1 -1
  73. package/dashboard/dist/assets/{DropZone-BWD9aGOz.js → DropZone-DovkhN2p.js} +2 -2
  74. package/dashboard/dist/assets/{DropZone-BWD9aGOz.js.map → DropZone-DovkhN2p.js.map} +1 -1
  75. package/dashboard/dist/assets/{ElapsedCell-CIGRporU.js → ElapsedCell-BkRu9Xpd.js} +2 -2
  76. package/dashboard/dist/assets/{ElapsedCell-CIGRporU.js.map → ElapsedCell-BkRu9Xpd.js.map} +1 -1
  77. package/dashboard/dist/assets/EntityTimelinePanel--E6hLMCM.js +2 -0
  78. package/dashboard/dist/assets/{EntityTimelinePanel-CKIFsDOB.js.map → EntityTimelinePanel--E6hLMCM.js.map} +1 -1
  79. package/dashboard/dist/assets/{EscalationListSchemaPage-DOrv-quD.js → EscalationListSchemaPage-CdFtqEEX.js} +3 -3
  80. package/dashboard/dist/assets/{EscalationListSchemaPage-DOrv-quD.js.map → EscalationListSchemaPage-CdFtqEEX.js.map} +1 -1
  81. package/dashboard/dist/assets/{EscalationSchemaPage-DAOVAxAM.js → EscalationSchemaPage-BsjS2axz.js} +2 -2
  82. package/dashboard/dist/assets/{EscalationSchemaPage-DAOVAxAM.js.map → EscalationSchemaPage-BsjS2axz.js.map} +1 -1
  83. package/dashboard/dist/assets/{EscalationsOverview-B27sDn5O.js → EscalationsOverview-FL-xteVc.js} +2 -2
  84. package/dashboard/dist/assets/{EscalationsOverview-B27sDn5O.js.map → EscalationsOverview-FL-xteVc.js.map} +1 -1
  85. package/dashboard/dist/assets/{EventTable-Co1d40Qq.js → EventTable-BOcgZ78i.js} +2 -2
  86. package/dashboard/dist/assets/{EventTable-Co1d40Qq.js.map → EventTable-BOcgZ78i.js.map} +1 -1
  87. package/dashboard/dist/assets/{FilterBar-2ZfU21EA.js → FilterBar-DfCiCmm-.js} +2 -2
  88. package/dashboard/dist/assets/{FilterBar-2ZfU21EA.js.map → FilterBar-DfCiCmm-.js.map} +1 -1
  89. package/dashboard/dist/assets/{GraphInvokePage-pdvc9VSv.js → GraphInvokePage-DfVeiN-8.js} +2 -2
  90. package/dashboard/dist/assets/{GraphInvokePage-pdvc9VSv.js.map → GraphInvokePage-DfVeiN-8.js.map} +1 -1
  91. package/dashboard/dist/assets/{HomePage-CLlDsBnw.js → HomePage-C2IhF9WB.js} +2 -2
  92. package/dashboard/dist/assets/{HomePage-CLlDsBnw.js.map → HomePage-C2IhF9WB.js.map} +1 -1
  93. package/dashboard/dist/assets/{ListToolbar-DMremj2e.js → ListToolbar-DA0PTOl5.js} +2 -2
  94. package/dashboard/dist/assets/{ListToolbar-DMremj2e.js.map → ListToolbar-DA0PTOl5.js.map} +1 -1
  95. package/dashboard/dist/assets/{McpOverview-BhztmhoL.js → McpOverview-DstPch5M.js} +2 -2
  96. package/dashboard/dist/assets/{McpOverview-BhztmhoL.js.map → McpOverview-DstPch5M.js.map} +1 -1
  97. package/dashboard/dist/assets/{McpQueryDetailPage-BseZfrhc.js → McpQueryDetailPage-Csv0PKE0.js} +2 -2
  98. package/dashboard/dist/assets/{McpQueryDetailPage-BseZfrhc.js.map → McpQueryDetailPage-Csv0PKE0.js.map} +1 -1
  99. package/dashboard/dist/assets/{McpQueryPage-DMzkble7.js → McpQueryPage-DxmqCkly.js} +2 -2
  100. package/dashboard/dist/assets/{McpQueryPage-DMzkble7.js.map → McpQueryPage-DxmqCkly.js.map} +1 -1
  101. package/dashboard/dist/assets/{McpRunDetailPage-DqaBQAnn.js → McpRunDetailPage-CcJOlp_B.js} +2 -2
  102. package/dashboard/dist/assets/{McpRunDetailPage-DqaBQAnn.js.map → McpRunDetailPage-CcJOlp_B.js.map} +1 -1
  103. package/dashboard/dist/assets/{McpRunsPage-Du8GnHFv.js → McpRunsPage-BZCR043j.js} +2 -2
  104. package/dashboard/dist/assets/{McpRunsPage-Du8GnHFv.js.map → McpRunsPage-BZCR043j.js.map} +1 -1
  105. package/dashboard/dist/assets/{NamespacePill-C09QuOEz.js → NamespacePill-BeifzjUm.js} +2 -2
  106. package/dashboard/dist/assets/{NamespacePill-C09QuOEz.js.map → NamespacePill-BeifzjUm.js.map} +1 -1
  107. package/dashboard/dist/assets/{OperationsPage-CL2feqwS.js → OperationsPage-DMsPXITh.js} +3 -3
  108. package/dashboard/dist/assets/{OperationsPage-CL2feqwS.js.map → OperationsPage-DMsPXITh.js.map} +1 -1
  109. package/dashboard/dist/assets/{OperatorDashboard-BHiGQZN_.js → OperatorDashboard-DSloftQ5.js} +2 -2
  110. package/dashboard/dist/assets/{OperatorDashboard-BHiGQZN_.js.map → OperatorDashboard-DSloftQ5.js.map} +1 -1
  111. package/dashboard/dist/assets/{PageHeader-B7YJxa4o.js → PageHeader-BpeBHqyc.js} +2 -2
  112. package/dashboard/dist/assets/{PageHeader-B7YJxa4o.js.map → PageHeader-BpeBHqyc.js.map} +1 -1
  113. package/dashboard/dist/assets/{PageHeaderWithStats-gT-5ovJh.js → PageHeaderWithStats-JXeUFa_g.js} +2 -2
  114. package/dashboard/dist/assets/{PageHeaderWithStats-gT-5ovJh.js.map → PageHeaderWithStats-JXeUFa_g.js.map} +1 -1
  115. package/dashboard/dist/assets/{PersonaDetailPage-D6GGZgUS.js → PersonaDetailPage-jDVRCLbU.js} +2 -2
  116. package/dashboard/dist/assets/{PersonaDetailPage-D6GGZgUS.js.map → PersonaDetailPage-jDVRCLbU.js.map} +1 -1
  117. package/dashboard/dist/assets/{PersonasPage-BQYCdmAs.js → PersonasPage-DnDDwXoy.js} +2 -2
  118. package/dashboard/dist/assets/{PersonasPage-BQYCdmAs.js.map → PersonasPage-DnDDwXoy.js.map} +1 -1
  119. package/dashboard/dist/assets/{ProcessDetailPage-P45jOLim.js → ProcessDetailPage-CfAUU6q2.js} +2 -2
  120. package/dashboard/dist/assets/{ProcessDetailPage-P45jOLim.js.map → ProcessDetailPage-CfAUU6q2.js.map} +1 -1
  121. package/dashboard/dist/assets/{ProcessesListPage-CgdzgCY6.js → ProcessesListPage-CnAXzaVv.js} +2 -2
  122. package/dashboard/dist/assets/{ProcessesListPage-CgdzgCY6.js.map → ProcessesListPage-CnAXzaVv.js.map} +1 -1
  123. package/dashboard/dist/assets/RoleDetailPage-Dg1p6Qz_.js +8 -0
  124. package/dashboard/dist/assets/RoleDetailPage-Dg1p6Qz_.js.map +1 -0
  125. package/dashboard/dist/assets/{RolePill-CtYI1_k1.js → RolePill-EocCXZh0.js} +2 -2
  126. package/dashboard/dist/assets/{RolePill-CtYI1_k1.js.map → RolePill-EocCXZh0.js.map} +1 -1
  127. package/dashboard/dist/assets/{RolesPage-Ci7_PbPt.js → RolesPage-DeRVQux8.js} +2 -2
  128. package/dashboard/dist/assets/{RolesPage-Ci7_PbPt.js.map → RolesPage-DeRVQux8.js.map} +1 -1
  129. package/dashboard/dist/assets/{RunAsSelector-CB0pV097.js → RunAsSelector-BFNqQGuG.js} +2 -2
  130. package/dashboard/dist/assets/{RunAsSelector-CB0pV097.js.map → RunAsSelector-BFNqQGuG.js.map} +1 -1
  131. package/dashboard/dist/assets/{ScanCodesPage-DpbPhAj1.js → ScanCodesPage-D0GOdk5m.js} +2 -2
  132. package/dashboard/dist/assets/{ScanCodesPage-DpbPhAj1.js.map → ScanCodesPage-D0GOdk5m.js.map} +1 -1
  133. package/dashboard/dist/assets/{ScanSchemeDetailPage-CGnMGlt0.js → ScanSchemeDetailPage-vFqoe_P4.js} +2 -2
  134. package/dashboard/dist/assets/{ScanSchemeDetailPage-CGnMGlt0.js.map → ScanSchemeDetailPage-vFqoe_P4.js.map} +1 -1
  135. package/dashboard/dist/assets/ScanStationPage-DH1ynTX9.js +2 -0
  136. package/dashboard/dist/assets/{ScanStationPage-BTeV7TGy.js.map → ScanStationPage-DH1ynTX9.js.map} +1 -1
  137. package/dashboard/dist/assets/{ScopeBadge-B76rOtA0.js → ScopeBadge-H5dEqeHi.js} +2 -2
  138. package/dashboard/dist/assets/{ScopeBadge-B76rOtA0.js.map → ScopeBadge-H5dEqeHi.js.map} +1 -1
  139. package/dashboard/dist/assets/{StickyPagination-DH-0JEyx.js → StickyPagination-B99hVu95.js} +2 -2
  140. package/dashboard/dist/assets/{StickyPagination-DH-0JEyx.js.map → StickyPagination-B99hVu95.js.map} +1 -1
  141. package/dashboard/dist/assets/{StreamMessageDetail-u-pDrHfS.js → StreamMessageDetail-DcDGISrv.js} +2 -2
  142. package/dashboard/dist/assets/{StreamMessageDetail-u-pDrHfS.js.map → StreamMessageDetail-DcDGISrv.js.map} +1 -1
  143. package/dashboard/dist/assets/{SwimlaneTimeline-vN1N8BGy.js → SwimlaneTimeline-BP3mSQAg.js} +2 -2
  144. package/dashboard/dist/assets/{SwimlaneTimeline-vN1N8BGy.js.map → SwimlaneTimeline-BP3mSQAg.js.map} +1 -1
  145. package/dashboard/dist/assets/{TagInput-BQAPOp17.js → TagInput-Ch5u6iPH.js} +2 -2
  146. package/dashboard/dist/assets/{TagInput-BQAPOp17.js.map → TagInput-Ch5u6iPH.js.map} +1 -1
  147. package/dashboard/dist/assets/{TaskDetailPage-CAQm6avs.js → TaskDetailPage-_XWLJzt-.js} +2 -2
  148. package/dashboard/dist/assets/{TaskDetailPage-CAQm6avs.js.map → TaskDetailPage-_XWLJzt-.js.map} +1 -1
  149. package/dashboard/dist/assets/{TaskQueuePill-C2NImrwl.js → TaskQueuePill-Bz146p-P.js} +2 -2
  150. package/dashboard/dist/assets/{TaskQueuePill-C2NImrwl.js.map → TaskQueuePill-Bz146p-P.js.map} +1 -1
  151. package/dashboard/dist/assets/{TasksListPage-C1bT3DT9.js → TasksListPage-iGriKiO2.js} +2 -2
  152. package/dashboard/dist/assets/{TasksListPage-C1bT3DT9.js.map → TasksListPage-iGriKiO2.js.map} +1 -1
  153. package/dashboard/dist/assets/{TimeAgo-qZxkJ8Am.js → TimeAgo-BO33VeFl.js} +2 -2
  154. package/dashboard/dist/assets/{TimeAgo-qZxkJ8Am.js.map → TimeAgo-BO33VeFl.js.map} +1 -1
  155. package/dashboard/dist/assets/{TimestampCell-CC3dz6FG.js → TimestampCell-KAjX7w35.js} +2 -2
  156. package/dashboard/dist/assets/{TimestampCell-CC3dz6FG.js.map → TimestampCell-KAjX7w35.js.map} +1 -1
  157. package/dashboard/dist/assets/{ToolPill-FOZm67TS.js → ToolPill-sj8OkBB0.js} +2 -2
  158. package/dashboard/dist/assets/{ToolPill-FOZm67TS.js.map → ToolPill-sj8OkBB0.js.map} +1 -1
  159. package/dashboard/dist/assets/{ToolTestPanel-C3sSQUvw.js → ToolTestPanel-BchG2yC6.js} +2 -2
  160. package/dashboard/dist/assets/{ToolTestPanel-C3sSQUvw.js.map → ToolTestPanel-BchG2yC6.js.map} +1 -1
  161. package/dashboard/dist/assets/{TopicDetailPage-ClI0I8Mu.js → TopicDetailPage-BaK8H0o1.js} +2 -2
  162. package/dashboard/dist/assets/{TopicDetailPage-ClI0I8Mu.js.map → TopicDetailPage-BaK8H0o1.js.map} +1 -1
  163. package/dashboard/dist/assets/{TopicsPage-CNf2VZud.js → TopicsPage-DEyvm669.js} +2 -2
  164. package/dashboard/dist/assets/{TopicsPage-CNf2VZud.js.map → TopicsPage-DEyvm669.js.map} +1 -1
  165. package/dashboard/dist/assets/{UserName-BdMHmyL3.js → UserName-BV6SKI9P.js} +2 -2
  166. package/dashboard/dist/assets/{UserName-BdMHmyL3.js.map → UserName-BV6SKI9P.js.map} +1 -1
  167. package/dashboard/dist/assets/{WorkflowExecutionPage-Ba4mYFoW.js → WorkflowExecutionPage-1sKoEFNC.js} +2 -2
  168. package/dashboard/dist/assets/{WorkflowExecutionPage-Ba4mYFoW.js.map → WorkflowExecutionPage-1sKoEFNC.js.map} +1 -1
  169. package/dashboard/dist/assets/{WorkflowPill-C5TEWlfO.js → WorkflowPill-BcA7S3gI.js} +2 -2
  170. package/dashboard/dist/assets/{WorkflowPill-C5TEWlfO.js.map → WorkflowPill-BcA7S3gI.js.map} +1 -1
  171. package/dashboard/dist/assets/{WorkflowsDashboard-ImEm16tX.js → WorkflowsDashboard-YTHDZZOD.js} +2 -2
  172. package/dashboard/dist/assets/{WorkflowsDashboard-ImEm16tX.js.map → WorkflowsDashboard-YTHDZZOD.js.map} +1 -1
  173. package/dashboard/dist/assets/{WorkflowsOverview-BpWyV_tj.js → WorkflowsOverview-ucXPLTtm.js} +2 -2
  174. package/dashboard/dist/assets/{WorkflowsOverview-BpWyV_tj.js.map → WorkflowsOverview-ucXPLTtm.js.map} +1 -1
  175. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BFBlw1YY.js → YamlWorkflowDetailPage-C_RTZKqZ.js} +2 -2
  176. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BFBlw1YY.js.map → YamlWorkflowDetailPage-C_RTZKqZ.js.map} +1 -1
  177. package/dashboard/dist/assets/{YamlWorkflowsPage-C9gxapRg.js → YamlWorkflowsPage-Usid3w2W.js} +2 -2
  178. package/dashboard/dist/assets/{YamlWorkflowsPage-C9gxapRg.js.map → YamlWorkflowsPage-Usid3w2W.js.map} +1 -1
  179. package/dashboard/dist/assets/{agents-BJQtJTiz.js → agents-BTDsRK8e.js} +2 -2
  180. package/dashboard/dist/assets/{agents-BJQtJTiz.js.map → agents-BTDsRK8e.js.map} +1 -1
  181. package/dashboard/dist/assets/{bots-DDlU1gMy.js → bots-DxLrfdfr.js} +2 -2
  182. package/dashboard/dist/assets/{bots-DDlU1gMy.js.map → bots-DxLrfdfr.js.map} +1 -1
  183. package/dashboard/dist/assets/{capabilities-qYrUpdid.js → capabilities-DbTmeW-S.js} +2 -2
  184. package/dashboard/dist/assets/{capabilities-qYrUpdid.js.map → capabilities-DbTmeW-S.js.map} +1 -1
  185. package/dashboard/dist/assets/{controlplane-DnJ1VDTs.js → controlplane-CEBntAL4.js} +2 -2
  186. package/dashboard/dist/assets/{controlplane-DnJ1VDTs.js.map → controlplane-CEBntAL4.js.map} +1 -1
  187. package/dashboard/dist/assets/escalation-columns-Carqdwoh.js +2 -0
  188. package/dashboard/dist/assets/escalation-columns-Carqdwoh.js.map +1 -0
  189. package/dashboard/dist/assets/{index-KotwPxGB.js → index-B2hz0pUh.js} +2 -2
  190. package/dashboard/dist/assets/{index-KotwPxGB.js.map → index-B2hz0pUh.js.map} +1 -1
  191. package/dashboard/dist/assets/{index-04QQsxMp.js → index-B9m7fA3M.js} +2 -2
  192. package/dashboard/dist/assets/{index-04QQsxMp.js.map → index-B9m7fA3M.js.map} +1 -1
  193. package/dashboard/dist/assets/{index-B5q8ksfv.js → index-BhapT-Vl.js} +2 -2
  194. package/dashboard/dist/assets/{index-B5q8ksfv.js.map → index-BhapT-Vl.js.map} +1 -1
  195. package/dashboard/dist/assets/{index-CtAPxA03.js → index-Bqm4zu46.js} +2 -2
  196. package/dashboard/dist/assets/{index-CtAPxA03.js.map → index-Bqm4zu46.js.map} +1 -1
  197. package/dashboard/dist/assets/{index-LiLVAQzB.js → index-C0hSttF5.js} +2 -2
  198. package/dashboard/dist/assets/{index-LiLVAQzB.js.map → index-C0hSttF5.js.map} +1 -1
  199. package/dashboard/dist/assets/{index-DhRdWzz0.js → index-CDkg6iOE.js} +4 -4
  200. package/dashboard/dist/assets/{index-DhRdWzz0.js.map → index-CDkg6iOE.js.map} +1 -1
  201. package/dashboard/dist/assets/{index-D-5F3Bw-.js → index-CVBBkW8V.js} +2 -2
  202. package/dashboard/dist/assets/{index-D-5F3Bw-.js.map → index-CVBBkW8V.js.map} +1 -1
  203. package/dashboard/dist/assets/{index-BUpB9ezn.js → index-CgIBjZta.js} +2 -2
  204. package/dashboard/dist/assets/{index-BUpB9ezn.js.map → index-CgIBjZta.js.map} +1 -1
  205. package/dashboard/dist/assets/{index-C991QfUN.js → index-DBXm49S6.js} +27 -27
  206. package/dashboard/dist/assets/index-DBXm49S6.js.map +1 -0
  207. package/dashboard/dist/assets/{index-BAqQSgxn.js → index-De8iV1y2.js} +2 -2
  208. package/dashboard/dist/assets/{index-BAqQSgxn.js.map → index-De8iV1y2.js.map} +1 -1
  209. package/dashboard/dist/assets/{index-BHbO4F8Z.js → index-DsgjFRvA.js} +2 -2
  210. package/dashboard/dist/assets/{index-BHbO4F8Z.js.map → index-DsgjFRvA.js.map} +1 -1
  211. package/dashboard/dist/assets/{index-CFlmubaP.js → index-kes8V4Xw.js} +2 -2
  212. package/dashboard/dist/assets/{index-CFlmubaP.js.map → index-kes8V4Xw.js.map} +1 -1
  213. package/dashboard/dist/assets/{index-CroJTX8g.js → index-nwLh3CK2.js} +2 -2
  214. package/dashboard/dist/assets/{index-CroJTX8g.js.map → index-nwLh3CK2.js.map} +1 -1
  215. package/dashboard/dist/assets/{knowledge-CnMeg8Rw.js → knowledge-oFYAanUp.js} +2 -2
  216. package/dashboard/dist/assets/{knowledge-CnMeg8Rw.js.map → knowledge-oFYAanUp.js.map} +1 -1
  217. package/dashboard/dist/assets/{mcp-CHPSFv7m.js → mcp-C9Kw4Ow8.js} +2 -2
  218. package/dashboard/dist/assets/{mcp-CHPSFv7m.js.map → mcp-C9Kw4Ow8.js.map} +1 -1
  219. package/dashboard/dist/assets/{mcp-query-C19EGwdN.js → mcp-query-BwzpZ91Z.js} +2 -2
  220. package/dashboard/dist/assets/{mcp-query-C19EGwdN.js.map → mcp-query-BwzpZ91Z.js.map} +1 -1
  221. package/dashboard/dist/assets/{personas-Br1Vo2S3.js → personas-D5ehmtRb.js} +2 -2
  222. package/dashboard/dist/assets/{personas-Br1Vo2S3.js.map → personas-D5ehmtRb.js.map} +1 -1
  223. package/dashboard/dist/assets/{pipelines-QMrFoJZX.js → pipelines-xgPKGEdD.js} +2 -2
  224. package/dashboard/dist/assets/{pipelines-QMrFoJZX.js.map → pipelines-xgPKGEdD.js.map} +1 -1
  225. package/dashboard/dist/assets/{tasks-Doy_7cGX.js → tasks-CLyrl-MU.js} +2 -2
  226. package/dashboard/dist/assets/{tasks-Doy_7cGX.js.map → tasks-CLyrl-MU.js.map} +1 -1
  227. package/dashboard/dist/assets/{topics-BcJS4G09.js → topics-B_gO7CQ0.js} +2 -2
  228. package/dashboard/dist/assets/{topics-BcJS4G09.js.map → topics-B_gO7CQ0.js.map} +1 -1
  229. package/dashboard/dist/assets/{useEventHooks-ldE5o0ok.js → useEventHooks-BdWYm63U.js} +2 -2
  230. package/dashboard/dist/assets/{useEventHooks-ldE5o0ok.js.map → useEventHooks-BdWYm63U.js.map} +1 -1
  231. package/dashboard/dist/assets/{useNamespace-CCu8fZc6.js → useNamespace-C238M4Qn.js} +2 -2
  232. package/dashboard/dist/assets/{useNamespace-CCu8fZc6.js.map → useNamespace-C238M4Qn.js.map} +1 -1
  233. package/dashboard/dist/assets/{useYamlActivityEvents-DDrXwFXX.js → useYamlActivityEvents-B2ryEK4S.js} +2 -2
  234. package/dashboard/dist/assets/{useYamlActivityEvents-DDrXwFXX.js.map → useYamlActivityEvents-B2ryEK4S.js.map} +1 -1
  235. package/dashboard/dist/assets/{users-BvKhSq1i.js → users-BFaTe6Mt.js} +2 -2
  236. package/dashboard/dist/assets/{users-BvKhSq1i.js.map → users-BFaTe6Mt.js.map} +1 -1
  237. package/dashboard/dist/assets/{vendor-icons-Aw7bzBxa.js → vendor-icons-BPsNpK3Y.js} +142 -137
  238. package/dashboard/dist/assets/vendor-icons-BPsNpK3Y.js.map +1 -0
  239. package/dashboard/dist/assets/{workflows-D09ysQF1.js → workflows-DXz7tZxp.js} +2 -2
  240. package/dashboard/dist/assets/{workflows-D09ysQF1.js.map → workflows-DXz7tZxp.js.map} +1 -1
  241. package/dashboard/dist/assets/{yaml-workflows-BFHrxEl4.js → yaml-workflows-u3xuRAnS.js} +2 -2
  242. package/dashboard/dist/assets/{yaml-workflows-BFHrxEl4.js.map → yaml-workflows-u3xuRAnS.js.map} +1 -1
  243. package/dashboard/dist/index.html +2 -2
  244. package/docs/code-owned-configuration.md +131 -0
  245. package/docs/hitl/x-lt-transition.md +13 -0
  246. package/docs/scan-codes.md +24 -0
  247. package/package.json +1 -1
  248. package/dashboard/dist/assets/AvailableEscalationsPage-BjsbfsWW.js +0 -2
  249. package/dashboard/dist/assets/AvailableEscalationsPage-BjsbfsWW.js.map +0 -1
  250. package/dashboard/dist/assets/EntityTimelinePanel-CKIFsDOB.js +0 -2
  251. package/dashboard/dist/assets/RoleDetailPage-Dme2pa9z.js +0 -8
  252. package/dashboard/dist/assets/RoleDetailPage-Dme2pa9z.js.map +0 -1
  253. package/dashboard/dist/assets/ScanStationPage-BTeV7TGy.js +0 -2
  254. package/dashboard/dist/assets/escalation-columns-BCnVWr_n.js +0 -2
  255. package/dashboard/dist/assets/escalation-columns-BCnVWr_n.js.map +0 -1
  256. package/dashboard/dist/assets/index-C991QfUN.js.map +0 -1
  257. package/dashboard/dist/assets/vendor-icons-Aw7bzBxa.js.map +0 -1
@@ -0,0 +1,131 @@
1
+ # Code-Owned Configuration
2
+
3
+ Long-tail configuration — workflow registration profiles, roles and their
4
+ schemas, topics, MCP server definitions, agents, and the domain dictionary —
5
+ can be owned by either the database or the code that declares it. The
6
+ `configSource` dial on `LTStartConfig` decides, and every declarable entry can
7
+ override it individually.
8
+
9
+ ```typescript
10
+ const lt = await start({
11
+ database: { connectionString: dbUrl },
12
+ configSource: 'code', // declarations apply on every boot
13
+ roles: ROLES,
14
+ workers: WORKERS,
15
+ topics: TOPICS,
16
+ agents: AGENTS,
17
+ });
18
+ ```
19
+
20
+ ## The two ownership modes
21
+
22
+ **`'db'` (default).** Declarations are seeded insert-if-absent: the first boot
23
+ writes each record, and the database owns it from then on. Admins edit live
24
+ through the dashboard and APIs; when code and database disagree, boot logs a
25
+ `config drift:` warning and leaves the row alone.
26
+
27
+ **`'code'`.** Declarations are compared against the database and applied on
28
+ every boot. Code is the source of truth: a changed declaration overwrites the
29
+ stored config fields, and dashboard edits to declared surfaces are replaced at
30
+ the next deploy. An unchanged declaration is a no-op — no write, no version
31
+ bump. Records present in the database but absent from code are reported at
32
+ boot as orphans and never deleted.
33
+
34
+ Code ownership fits deployments that manage configuration through git and
35
+ CI/CD: the same declaration produces the same state in local, staging, and
36
+ production, without a database wipe. Local development that reseeds on every
37
+ `docker compose down -v` and a long-lived production database converge on
38
+ identical configuration.
39
+
40
+ ### Per-entry override
41
+
42
+ Every entry accepts `reset?: boolean`, which wins over the global dial in
43
+ either direction:
44
+
45
+ ```typescript
46
+ configSource: 'code',
47
+ topics: [
48
+ { topic: 'order.created', ... }, // code-owned (follows the dial)
49
+ { topic: 'ops.notes', ..., reset: false }, // db-owned — admins keep editing it
50
+ ],
51
+ ```
52
+
53
+ The domain dictionary's override lives beside its path:
54
+ `mcp.domainDictionaryReset`.
55
+
56
+ ## Per-surface semantics
57
+
58
+ | Surface | Declared via | Code-owned apply writes | Left alone (runtime state) |
59
+ |---|---|---|---|
60
+ | Workflow profiles | `workers[].config` | full profile incl. role lists (replace semantics) | task history, escalations |
61
+ | Roles | `roles[]` | declared fields only (PATCH); escalation targets replace | membership, undeclared fields |
62
+ | Topics | `topics[]` | whole catalog entry (`managed: true`) | `last_seen_at` |
63
+ | MCP servers | `mcp.serverFactories[].config` | description, tags, category, compile hints, credential providers | tool manifest, connection status |
64
+ | Agents | `agents[]` | description, status, goals, rules, domain, schedules | capabilities, metadata, run history |
65
+ | Agent subscriptions | `agents[].subscriptions` | reaction fields on (agent, topic) | `enabled` — the admin kill-switch |
66
+ | Domain dictionary | `mcp.domainDictionaryPath` | whole document (version bumps once per change) | — |
67
+ | Graph workflows | `graphWorkflows[]` | always compare-and-apply: description/schema sync, redeploy on YAML version bump | run history |
68
+
69
+ `certified` on a workflow profile is explicit-only under code ownership: an
70
+ omitted flag registers the workflow as **not** certified. (The db-owned seed
71
+ path keeps the roles/consumes derivation, so existing declarations behave as
72
+ they always have.)
73
+
74
+ ## Roles: first-class declarations
75
+
76
+ `roles[]` registers roles with titles, versioned form/metadata/list schemas,
77
+ escalation targets, upstream inputs, dials, and pins:
78
+
79
+ ```typescript
80
+ roles: [
81
+ {
82
+ role: 'finisher',
83
+ title: 'Finisher',
84
+ form_schema: FINISHER_FORM, // versioned — see below
85
+ escalation_targets: ['engineer'],
86
+ sla_minutes: 30,
87
+ properties: { kiosk: true },
88
+ },
89
+ ],
90
+ ```
91
+
92
+ Only declared fields are ever written — an omitted field keeps whatever the
93
+ database holds, under either ownership mode. Under `'db'` the declaration is
94
+ written once when the role is first created (the role belongs to the database
95
+ afterward); under `'code'` it is diffed and applied every boot.
96
+
97
+ ### Versioned schemas
98
+
99
+ Role schemas version through the same write path the dashboard uses. Applying
100
+ a declaration whose `form_schema` or `metadata_schema` differs from the stored
101
+ pair advances the role's schema version and snapshots the new pair into the
102
+ version history with the change summary `startup apply (code)`. In-flight
103
+ escalations pin the version they were created against, so the forms they
104
+ render keep working while new escalations pick up the new shape. Version
105
+ lineage only grows — an apply never rewinds or rewrites an existing version.
106
+ `list_schema` versions independently, exactly as it does from the dashboard.
107
+
108
+ ## The boot report
109
+
110
+ Each surface logs one line summarizing its pass:
111
+
112
+ ```
113
+ [long-tail] config apply (workflows): applied 2, unchanged 31, db-owned 0
114
+ [long-tail] config apply (roles): applied 1, unchanged 11, db-owned 0, orphans: [old-station]
115
+ ```
116
+
117
+ Orphans — database records of a declared surface with no matching declaration
118
+ in code — are reported at warn level and left untouched. Removing a workflow
119
+ config, role, topic, or agent remains a deliberate act through the dashboard
120
+ or API. For roles, only rows carrying real configuration (a title or a form
121
+ schema) are orphan candidates; bare rows auto-created for foreign keys and
122
+ membership-only roles never appear. Orphan reporting for roles is skipped when
123
+ `examples: true` (the demo seeders own their roles).
124
+
125
+ ## Concurrency
126
+
127
+ Concurrently booting containers serialize their configuration pass on a
128
+ dedicated advisory lock, separate from the migration lock. Single-statement
129
+ applies are also individually race-safe: every upsert carries an
130
+ `IS DISTINCT FROM` guard, so an identical declaration arriving from two
131
+ containers writes once and no-ops once.
@@ -88,6 +88,19 @@ Resolution order on submit: `x-lt-transition` (wait for the hand-off) →
88
88
  transition step, `x-lt-transition-done` is also where the wait lands if the
89
89
  follow-on never arrives.
90
90
 
91
+ **Station recipe — submit lands on the list.** Shared-station flows (badge
92
+ scan → claim → resolve) arrive at the detail page from angles where browser
93
+ history is meaningless, so the `history.back()` default confuses. Declare the
94
+ destination on the role's form-schema root and every submit returns to the
95
+ role's queue:
96
+
97
+ ```jsonc
98
+ { "x-lt-transition-done": "/escalations/available?role={{escalation.role}}&status=available" }
99
+ ```
100
+
101
+ No `x-lt-transition` needed when there is no follow-on to wait for — the
102
+ navigation is immediate.
103
+
91
104
  ## If the live event is missed
92
105
 
93
106
  Event delivery is at-most-once: a crash between the commit and the publish drops
@@ -216,6 +216,30 @@ takes the badge layer, and `write_scope: 'none'` is the structural
216
216
  backstop — even a misconfigured rule cannot mutate as the station, because
217
217
  the RBAC write gate denies the account itself.
218
218
 
219
+ `write_scope: 'none'` is also what makes the badge challenge fire:
220
+ `requireActingIdentity` is satisfied by a badge grant **or** by a login whose
221
+ own write scope covers the step, so a write-capable base login self-satisfies
222
+ the requirement and claims/resolves as itself with no badge demanded. The
223
+ badge-every-time contract requires the read-all/write-none base login.
224
+
225
+ ### Kiosk mode — the locked station viewport
226
+
227
+ A role opts in with `properties.kiosk: true` (the reserved role-property key,
228
+ set with the same `PATCH /api/roles/:role` as every other dial). When the
229
+ signed-in user is a **member of exactly that one role** — the station-login
230
+ shape — the dashboard locks the viewport: the left nav is gone entirely, the
231
+ role's escalation list is home (`/` and every other surface redirect to it),
232
+ and the session is held to the list, the escalation detail page, and the scan
233
+ screens (choice, badge). The header toolbar and event feed remain. A user
234
+ holding more than one role, or an admin-type grant, always gets full chrome —
235
+ kiosk is for the single-role floor login, never a way to hide the product from
236
+ a real operator.
237
+
238
+ Pair kiosk with `x-lt-transition-done` on the role's form schema
239
+ (`"/escalations/available?role={{escalation.role}}&status=available"`) so a
240
+ resolve lands back on the list rather than walking browser history — see
241
+ [x-lt-transition](./hitl/x-lt-transition.md).
242
+
219
243
  Mutations attribute to the badged person (`assigned_to`, `resolved_by`)
220
244
  with the device recorded beside them (`scanStation` in the scan
221
245
  provenance) — every action individually owned and geographically placed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/long-tail",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Long Tail Workflows — Durable AI workflows with human-in-the-loop escalation. Powered by PostgreSQL.",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -1,2 +0,0 @@
1
- import{j as e,a as f}from"./vendor-query-RUZdMvN6.js";import{u as At,l as Tt,m as Je,n as Le,p as Ot,w as Et,o as Ft,q as _t,r as $t,s as Lt,t as Bt,v as Rt,x as zt,i as qt,y as Dt,z as It,A as Ut,B as Vt,E as Gt,G as Ht,H as Qt,I as Jt,K as Kt,L as Wt,M as Xt,O as Yt,Q as Zt}from"./index-C991QfUN.js";import{i as es}from"./task-queues-7-sHKPsN.js";import{f as ts}from"./useEventHooks-ldE5o0ok.js";import{X as te,ag as ss,ah as as,C as ns,b as rs,ai as is,aj as ls,t as os,s as cs,ak as ds,B as us,al as Be,am as xs,Q as ms,P as hs,g as ps,an as fs}from"./vendor-icons-Aw7bzBxa.js";import{u as he,C as Ke,a as gs}from"./CustomDurationPicker-BES_FTrm.js";import{m as bs,E as ys,a as js}from"./escalation-columns-BCnVWr_n.js";import{i as vs,E as Ns}from"./CountdownTimer-Dw8N9tmQ.js";import{u as Cs}from"./useFilterParams-crmlBw_l.js";import{u as We}from"./useDebouncedValue-C4P2jQuh.js";import{b as ks}from"./api-path-u2Jf9QXS.js";import{D as ws}from"./DataTable-Bir0Xs1p.js";import{S as Ss}from"./StickyPagination-DH-0JEyx.js";import{P as Ps}from"./constants-BHkpVaqx.js";import{M as pe}from"./Modal-BU7No9NH.js";import{u as Ms}from"./users-BvKhSq1i.js";import{R as As,a as Ts}from"./RowActions-eYrzgQSj.js";import{L as Os}from"./ListToolbar-DMremj2e.js";import{L as Re,u as Es,f as Fs,a as _s}from"./vendor-react-CdqEC2zv.js";import"./EntityTimelinePanel-CKIFsDOB.js";import"./FilterBar-2ZfU21EA.js";import"./PriorityBadge-BETdj4M-.js";import"./RolePill-CtYI1_k1.js";import"./WorkflowPill-C5TEWlfO.js";import"./StatusBadge-DkgllZHv.js";import"./EmptyState-lpUFYfun.js";const $s=["<","<=",">",">=","="],Ls=["priority","created_at","updated_at","status","role"],z="input text-xs py-1",ze="select text-xs py-1",Z="text-text-tertiary hover:text-text-primary transition-colors";function qe(t){return t==="true"?!0:t==="false"?!1:t.trim()!==""&&!Number.isNaN(Number(t))?Number(t):t}const Bs=t=>Object.entries(t??{}).map(([s,l])=>({key:s,value:String(l)})),Rs=t=>(t??[]).map(s=>{const[l,i]=Object.entries(s)[0]??["",""];return{key:l,value:String(i)}});function R({title:t,hint:s,children:l}){return e.jsxs("div",{className:"border-t border-surface-border/50 py-3 first:border-t-0 first:pt-1",children:[e.jsxs("div",{className:"mb-1.5 flex items-baseline justify-between",children:[e.jsx("span",{className:"text-2xs font-medium uppercase tracking-wide text-text-tertiary",children:t}),s&&e.jsx("span",{className:"text-2xs font-mono text-text-tertiary/70",children:s})]}),l]})}function ee({value:t,onChange:s,placeholder:l}){return e.jsx("input",{list:"lt-facet-keys",className:`${z} w-40`,placeholder:l,value:t,onChange:i=>s(i.target.value)})}function zs({value:t,onChange:s,facetKeys:l=[],search:i="",onSearchChange:p}){const m=Bs(t.facets),h=Rs(t.block),d=t.range??[],x=t.exists??[],g=t.orderBy??[],C=r=>{const u={};for(const o of r)o.key&&(u[o.key]=qe(o.value));s({...t,facets:Object.keys(u).length?u:void 0})},S=r=>{const u=r.filter(o=>o.key).map(o=>({[o.key]:qe(o.value)}));s({...t,block:u.length?u:void 0})},P=r=>s({...t,range:r.length?r:void 0}),j=r=>s({...t,exists:r.length?r:void 0}),k=r=>s({...t,orderBy:r.length?r:void 0});return e.jsxs("div",{className:"text-xs",children:[e.jsx("datalist",{id:"lt-facet-keys",children:l.map(r=>e.jsx("option",{value:r},r))}),e.jsxs("datalist",{id:"lt-sort-fields",children:[Ls.map(r=>e.jsx("option",{value:r},r)),l.map(r=>e.jsx("option",{value:`metadata.${r}`},r))]}),p&&e.jsx(R,{title:"Match id",hint:"id · workflow · origin",children:e.jsx("input",{className:`${z} w-full`,placeholder:"Exact escalation, workflow, or origin id…",value:i,onChange:r=>p(r.target.value)})}),e.jsx(R,{title:"Has facet",hint:"metadata @>",children:[...m,{key:"",value:""}].map((r,u)=>e.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[e.jsx(ee,{value:r.key,placeholder:"key",onChange:o=>{const c=[...m];c[u]={...r,key:o},C(c)}}),e.jsx("span",{className:"text-text-tertiary",children:"="}),e.jsx("input",{className:`${z} w-40`,placeholder:"value",value:r.value,onChange:o=>{const c=[...m];c[u]={...r,value:o.target.value},C(c)}}),u<m.length&&e.jsx("button",{className:Z,onClick:()=>C(m.filter((o,c)=>c!==u)),children:"×"})]},u))}),e.jsx(R,{title:"Range",hint:"numeric",children:[...d,{facet:"",op:"<=",value:0}].map((r,u)=>e.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[e.jsx(ee,{value:r.facet,placeholder:"numeric facet",onChange:o=>{const c=[...d];c[u]={...r,facet:o},P(c.filter(a=>a.facet))}}),e.jsx("select",{className:ze,value:r.op,onChange:o=>{const c=[...d];c[u]={...r,op:o.target.value},P(c.filter(a=>a.facet))},children:$s.map(o=>e.jsx("option",{value:o,children:o},o))}),e.jsx("input",{type:"number",className:`${z} w-24`,value:r.value,onChange:o=>{const c=[...d];c[u]={...r,value:Number(o.target.value)},P(c.filter(a=>a.facet))}}),u<d.length&&e.jsx("button",{className:Z,onClick:()=>P(d.filter((o,c)=>c!==u)),children:"×"})]},u))}),e.jsx(R,{title:"Has key",hint:"metadata ? key",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[x.map(r=>e.jsxs("span",{className:"flex items-center gap-1 rounded bg-accent/15 px-1.5 py-0.5 text-accent",children:[r,e.jsx("button",{className:"text-accent/70 hover:text-accent",onClick:()=>j(x.filter(u=>u!==r)),children:"×"})]},r)),e.jsx(ee,{value:"",placeholder:"+ key",onChange:r=>{r&&!x.includes(r)&&j([...x,r])}})]})}),e.jsx(R,{title:"Exclude",hint:"NOT @>",children:[...h,{key:"",value:""}].map((r,u)=>e.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[e.jsx(ee,{value:r.key,placeholder:"key",onChange:o=>{const c=[...h];c[u]={...r,key:o},S(c)}}),e.jsx("span",{className:"text-text-tertiary",children:"="}),e.jsx("input",{className:`${z} w-40`,placeholder:"value",value:r.value,onChange:o=>{const c=[...h];c[u]={...r,value:o.target.value},S(c)}}),u<h.length&&e.jsx("button",{className:Z,onClick:()=>S(h.filter((o,c)=>c!==u)),children:"×"})]},u))}),e.jsx(R,{title:"Sort by",children:[...g,{field:"",direction:"asc"}].map((r,u)=>e.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[e.jsx("input",{list:"lt-sort-fields",className:`${z} w-44`,placeholder:"column or metadata.key",value:r.field,onChange:o=>{const c=[...g];c[u]={...r,field:o.target.value},k(c.filter(a=>a.field))}}),e.jsxs("select",{className:ze,value:r.direction??"asc",onChange:o=>{const c=[...g];c[u]={...r,direction:o.target.value},k(c.filter(a=>a.field))},children:[e.jsx("option",{value:"asc",children:"asc"}),e.jsx("option",{value:"desc",children:"desc"})]}),e.jsxs("label",{className:"flex items-center gap-1 text-text-tertiary",children:[e.jsx("input",{type:"checkbox",checked:!!r.numeric,onChange:o=>{const c=[...g];c[u]={...r,numeric:o.target.checked},k(c.filter(a=>a.field))}}),"num"]}),u<g.length&&e.jsx("button",{className:Z,onClick:()=>k(g.filter((o,c)=>c!==u)),children:"×"})]},u))})]})}function qs({value:t,onChange:s,facetKeys:l,search:i,onSearchChange:p,activeFacetCount:m,onClear:h,onClose:d}){return e.jsxs("div",{className:"h-full overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-4 py-3 bg-surface-raised border-b border-surface-border/50",children:[e.jsx("span",{className:"text-xs font-semibold text-text-primary",children:"Faceted query"}),e.jsxs("div",{className:"flex items-center gap-2",children:[m>0&&e.jsx("button",{onClick:h,className:"text-2xs text-text-tertiary hover:text-text-primary transition-colors",children:"Clear"}),e.jsx("button",{onClick:d,className:"p-1 rounded hover:bg-surface-hover text-text-tertiary hover:text-text-primary transition-colors",title:"Close",children:e.jsx(te,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"px-4 py-2",children:[e.jsxs("p",{className:"mb-2 text-2xs leading-snug text-text-tertiary",children:["Precise metadata facets plus exact correlation-id lookup — they compose in one SQL query. Facet keys are the ones that actually exist in your visible escalations. Set status to ",e.jsx("span",{className:"font-medium",children:"All"})," to find an order across every status; the whole query is shareable via the URL."]}),e.jsx(zs,{value:t,onChange:s,facetKeys:l,search:i,onSearchChange:p})]})]})}const De="created_at";function xe(t){return t.replace(/^metadata\./,"")}function Ds({orderBy:t,onChange:s}){const l=t==null?void 0:t[0],i=(l==null?void 0:l.field)??De,p=(l==null?void 0:l.direction)??"desc",m=i===De,h=d=>s([{...l??{},field:i,direction:d}]);return e.jsxs("div",{className:"flex items-center gap-1.5",children:[!m&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-accent/25 bg-accent/8 px-2 py-0.5 text-2xs font-medium text-accent/90",children:[e.jsx("span",{className:"text-text-quaternary",children:"sort"}),e.jsx("span",{className:"font-mono max-w-[120px] truncate",title:i,children:xe(i)}),e.jsx("button",{onClick:()=>s(void 0),className:"ml-0.5 -mr-0.5 flex items-center text-text-quaternary hover:text-status-error transition-colors","aria-label":"Reset sort to created date",children:e.jsx(te,{className:"w-2.5 h-2.5"})})]}),e.jsxs("div",{className:"flex items-center rounded overflow-hidden border border-surface-border",role:"radiogroup","aria-label":"Sort direction",children:[e.jsx("button",{type:"button",role:"radio","aria-checked":p==="desc",onClick:()=>h("desc"),className:`px-1.5 py-1 transition-colors ${p==="desc"?"bg-accent text-text-inverse":"icon-link hover:bg-surface-hover"}`,title:m?"Newest first":`${xe(i)} descending`,children:e.jsx(ss,{className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",role:"radio","aria-checked":p==="asc",onClick:()=>h("asc"),className:`px-1.5 py-1 border-l border-surface-border transition-colors ${p==="asc"?"bg-accent text-text-inverse":"icon-link hover:bg-surface-hover"}`,title:m?"Oldest first":`${xe(i)} ascending`,children:e.jsx(as,{className:"w-3.5 h-3.5"})})]})]})}const Is=t=>t.isPriorityPending||t.isClaimPending||t.isAssignPending||t.isTriagePending||t.isCancelPending,me="inline-flex items-center h-7 px-2.5 text-2xs font-medium text-text-secondary bg-surface border border-surface-border rounded-[4px] hover:border-accent/50 hover:text-text-primary transition-colors disabled:opacity-50 disabled:hover:border-surface-border",Ie=`${me} appearance-none cursor-pointer`,Us="inline-flex items-center h-7 px-2.5 text-2xs font-medium text-status-error bg-surface border border-status-error/30 rounded-[4px] hover:border-status-error hover:bg-status-error/5 transition-colors disabled:opacity-50";function Vs(t){var d;const s=Is(t),l=he(),{data:i}=At(),p=Tt(),m=p!==null?p:((d=i==null?void 0:i.ai)==null?void 0:d.enabled)===!0,h=t.selectedCount>0;return e.jsx("div",{className:`grid transition-all duration-200 ease-in-out ${h?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0 pointer-events-none"}`,children:e.jsx("div",{className:"overflow-hidden",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-2.5 pl-3 pr-2 mt-4 mb-3 bg-surface-sunken/60 border-l-2 border-l-accent",children:[e.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-accent tabular-nums",children:[t.selectedCount," selected"]}),e.jsx("div",{className:"mx-1 h-4 w-px bg-surface-border"}),e.jsxs("select",{onChange:x=>{x.target.value&&(t.onSetPriority(parseInt(x.target.value)),x.target.value="")},disabled:s,className:Ie,defaultValue:"",children:[e.jsx("option",{value:"",disabled:!0,children:"Priority…"}),Ps.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))]}),e.jsxs("select",{onChange:x=>{x.target.value&&(t.onClaim(parseInt(x.target.value)),x.target.value="")},disabled:s,className:Ie,defaultValue:"",children:[e.jsx("option",{value:"",disabled:!0,children:"Claim for…"}),l.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))]}),e.jsx("button",{onClick:t.onAssign,disabled:s,className:me,children:t.isAssignPending?"Assigning…":"Assign to…"}),m&&e.jsx("button",{onClick:t.onTriage,disabled:s,className:me,children:t.isTriagePending?"Triaging…":"Triage"}),e.jsx("button",{onClick:t.onCancel,disabled:s,className:Us,children:t.isCancelPending?"Cancelling…":"Cancel"}),e.jsx("div",{className:"flex-1"}),s&&e.jsx("span",{className:"text-2xs text-text-tertiary animate-pulse",children:"Processing…"}),e.jsx("button",{onClick:t.onClearSelection,className:"px-1 text-2xs font-medium text-text-tertiary hover:text-text-primary transition-colors",children:"Clear"})]})})})}function Gs({open:t,onClose:s,selectedCount:l,selectedRoles:i,onSubmit:p,isPending:m}){const{isSuperAdmin:h}=Je(),d=he(),[x,g]=f.useState("user"),[C,S]=f.useState(null),[P,j]=f.useState(""),[k,r]=f.useState("30"),[u,o]=f.useState(0),c=f.useCallback(y=>o(y),[]),a=!h&&i.length===1?i[0]:void 0,N=We(P,250),{data:w,isLoading:M}=Ms({role:a,status:"active",search:N.trim()||void 0,limit:200}),A=(w==null?void 0:w.users)??[],T=()=>{g("user"),S(null),j(""),r("30"),o(0),s()},O=y=>{S(y),g("duration")},q=()=>{g("user")},D=()=>{if(!C)return;const y=k==="custom"?u:parseInt(k);!y||y<=0||p(C.id,y)};return e.jsx(pe,{open:t,onClose:T,title:"Assign Escalations",children:e.jsxs("div",{className:"space-y-4",children:[x==="user"&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-text-secondary",children:["Select a user to assign"," ",e.jsx("span",{className:"font-medium text-text-primary",children:l})," ","escalation(s) to:"]}),e.jsx("input",{type:"text",value:P,onChange:y=>j(y.target.value),placeholder:"Search by name or email...",className:"input text-xs w-full",autoFocus:!0}),e.jsxs("div",{className:"max-h-60 overflow-y-auto border border-surface-border rounded-lg divide-y divide-surface-border",children:[M&&e.jsx("p",{className:"text-xs text-text-tertiary p-3",children:"Loading users..."}),!M&&A.length===0&&e.jsx("p",{className:"text-xs text-text-tertiary p-3",children:"No users found"}),A.map(y=>e.jsxs("button",{onClick:()=>O(y),className:"w-full text-left px-3 py-2 hover:bg-surface-hover transition-colors",children:[e.jsx("p",{className:"text-xs font-medium text-text-primary",children:y.display_name||y.external_id}),y.email&&e.jsx("p",{className:"text-2xs text-text-tertiary",children:y.email})]},y.id))]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx("button",{onClick:T,className:"btn-secondary text-xs",children:"Cancel"})})]}),x==="duration"&&C&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-text-secondary",children:["Assign to"," ",e.jsx("span",{className:"font-medium text-text-primary",children:C.display_name||C.external_id})," ","for:"]}),e.jsxs("select",{value:k,onChange:y=>{r(y.target.value),o(0)},className:"select w-full text-sm",children:[d.map(y=>e.jsx("option",{value:y.value,children:y.label},y.value)),e.jsx("option",{value:"custom",children:"Other..."})]}),k==="custom"&&e.jsx(Ke,{onChange:c,autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:q,className:"btn-secondary text-xs",children:"Back"}),e.jsx("button",{onClick:D,disabled:m,className:"btn-primary text-xs",children:m?"Assigning...":"Assign"})]})]})]})})}function Hs({open:t,onClose:s,selectedCount:l,onSubmit:i,isPending:p}){const[m,h]=f.useState(""),d=()=>{i(m||void 0)};return e.jsx(pe,{open:t,onClose:s,title:"Submit for AI Triage",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-text-secondary",children:["Submit ",e.jsx("span",{className:"font-medium text-text-primary",children:l})," escalation(s) for AI triage? The triage orchestrator will take over resolution."]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium text-text-secondary block mb-1",children:["Triage hint ",e.jsx("span",{className:"text-text-tertiary",children:"(optional)"})]}),e.jsx("input",{type:"text",value:m,onChange:x=>h(x.target.value),placeholder:"e.g., image_orientation",className:"input text-xs font-mono w-full"}),e.jsx("p",{className:"text-2xs text-text-tertiary mt-1",children:"Guides the triage workflow on what remediation to apply"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:s,className:"btn-secondary text-xs",children:"Cancel"}),e.jsx("button",{onClick:d,disabled:p,className:"btn-primary text-xs",children:p?"Submitting...":"Submit for Triage"})]})]})})}function V(t,s,l){return i=>{t.mutate(i,{onSuccess:()=>{s(),l==null||l()}})}}function Qs(t){const s=()=>[...t.selectedIds];return{handleSetPriority:d=>{V(t.setPriority,t.clearSelection)({ids:s(),priority:d})},handleBulkClaim:d=>{V(t.bulkClaim,t.clearSelection)({ids:s(),durationMinutes:d})},handleBulkTriage:d=>{V(t.bulkTriage,t.clearSelection,t.closeTriageModal)({ids:s(),hint:d})},handleBulkAssign:(d,x)=>{V(t.bulkAssign,t.clearSelection,t.closeAssignModal)({ids:s(),targetUserId:d,durationMinutes:x})},handleBulkCancel:()=>{V(t.bulkCancel,t.clearSelection,t.closeCancelModal)({ids:s()})}}}function Js({claimTarget:t,onClose:s,claimDuration:l,onDurationChange:i,claimDurations:p,onCustomClaimChange:m,onClaim:h,isPending:d}){return e.jsx(pe,{open:!!t,onClose:s,title:"Claim Escalation",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-text-secondary",children:["Claim ",e.jsx("span",{className:"font-medium text-text-primary",children:t==null?void 0:t.type})," for:"]}),e.jsxs("select",{value:l,onChange:x=>{i(x.target.value)},className:"select w-full text-sm",children:[p.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value)),e.jsx("option",{value:"custom",children:"Other..."})]}),l==="custom"&&e.jsx(Ke,{onChange:m,autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:s,className:"btn-secondary text-xs",children:"Cancel"}),e.jsx("button",{onClick:h,className:"btn-primary text-xs",disabled:d,children:d?"Claiming...":"Claim"})]})]})})}const Xe={pending:"--lt-status-queued-graphic",claimed:"--lt-status-claimed-graphic",resolved:"--lt-status-success-graphic",cancelled:"--lt-text-quaternary",expired:"--lt-text-tertiary"},Ye="--lt-text-quaternary";function Ks(t){return Xe[t]??Ye}const G=Object.fromEntries(Object.entries(Xe).map(([t,s])=>[t,`rgb(var(${s}))`])),Ue=40,Ws=64,Xs=24,Ve=3;function Ze(t){return t<6e4?`${Math.round(t/1e3)}s`:t<36e5?`${Math.round(t/6e4)}m`:t<864e5?`${(t/36e5).toFixed(1)}h`:`${(t/864e5).toFixed(1)}d`}function Ge(t){const s=Date.now()-t;return s<6e4?"just now":s<36e5?`${Math.round(s/6e4)}m ago`:s<864e5?`${Math.round(s/36e5)}h ago`:`${Math.round(s/864e5)}d ago`}function He(t){return t.replace(/-/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Ys(t,s){return t?[...s.filter(i=>i in t),...Object.keys(t).filter(i=>!s.includes(i))].map(i=>[i,t[i]]):[]}function Zs({e:t}){const s=t.endMs-t.startMs;if(s<=0)return null;const l=G.pending,i=G.claimed,p=t.status==="cancelled"||t.status==="expired"?G.cancelled:G.resolved;let m=100,h=0,d=0;return t.claimedMs!==null?(m=Math.max(0,Math.min(100,(t.claimedMs-t.startMs)/s*100)),t.isOpen?h=100-m:(h=Math.max(0,Math.min(100-m,(t.endMs-t.claimedMs)/s*100)),d=Math.max(0,100-m-h))):t.isOpen||(d=100,m=0),e.jsxs("div",{className:"mt-2 h-0.5 rounded-full overflow-hidden flex bg-surface-sunken",children:[m>0&&e.jsx("div",{style:{width:`${m}%`,backgroundColor:l,opacity:.6}}),h>0&&e.jsx("div",{style:{width:`${h}%`,backgroundColor:i,opacity:.6}}),d>0&&e.jsx("div",{style:{width:`${d}%`,backgroundColor:p,opacity:.6}})]})}function ea({gapMs:t,heightPx:s}){return e.jsx("div",{className:"relative flex items-center justify-center",style:{height:s},children:t>=6e4&&e.jsx("span",{className:"text-2xs text-text-quaternary font-mono bg-surface px-2 relative z-10",children:Ze(t)})})}function Qe({e:t,highlightKeys:s,onRowClick:l}){const[i,p]=f.useState(!1),m=G[t.displayStatus]??`rgb(var(${Ye}))`,h=Ys(t.metadata,s),d=i?h:h.slice(0,Ve),x=h.length-Ve;return e.jsxs("div",{className:"cursor-pointer max-w-[460px] min-w-[260px] w-full bg-surface-raised rounded-lg shadow-sm border border-surface-border/60 px-3.5 pt-2.5 pb-2 hover:shadow-md hover:border-surface-border transition-all duration-150",style:{borderTopWidth:"3px",borderTopColor:m},onClick:()=>l==null?void 0:l(t),children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1.5",children:[e.jsx("span",{className:"text-2xs font-bold uppercase tracking-widest text-text-quaternary shrink-0",children:He(t.role)}),e.jsxs("span",{className:"text-xs font-semibold text-text-primary truncate",title:t.type,children:[t.type,t.subtype&&t.subtype!==t.type&&t.subtype!==""&&e.jsxs("span",{className:"font-normal text-text-tertiary",children:[" · ",t.subtype]})]})]}),d.length>0&&e.jsxs("div",{className:"border-t border-surface-border/40 pt-1 space-y-px",children:[d.map(([g,C])=>{const S=String(C),P=s.includes(g);return e.jsxs("div",{className:"group/row flex items-center gap-1.5 -mx-1 px-1 py-[2px] rounded",children:[e.jsx("span",{className:`shrink-0 w-[60px] text-2xs font-mono uppercase tracking-wide truncate ${P?"text-accent":"text-text-quaternary"}`,title:g,children:g}),e.jsx("span",{className:`flex-1 min-w-0 text-2xs font-medium truncate ${P?"text-text-primary":"text-text-tertiary"}`,title:S,children:S}),e.jsxs("span",{className:"flex items-center gap-px shrink-0 opacity-0 group-hover/row:opacity-100 transition-opacity",children:[e.jsx(Re,{to:Le(g,C,t.role),className:"p-0.5 rounded text-text-quaternary hover:text-accent transition-colors",title:`Filter ${He(t.role)}: ${g} = ${S}`,onClick:j=>j.stopPropagation(),children:e.jsx(is,{className:"w-2.5 h-2.5"})}),e.jsx(Re,{to:Le(g,C),className:"p-0.5 rounded text-text-quaternary hover:text-accent transition-colors",title:`Search all: ${g} = ${S}`,onClick:j=>j.stopPropagation(),children:e.jsx(ls,{className:"w-2.5 h-2.5"})})]})]},g)}),x>0&&e.jsx("button",{className:"flex items-center gap-0.5 text-2xs text-text-quaternary hover:text-accent transition-colors mt-0.5 -mx-1 px-1 py-px",onClick:g=>{g.stopPropagation(),p(C=>!C)},children:i?e.jsxs(e.Fragment,{children:[e.jsx(os,{className:"w-2.5 h-2.5"})," less"]}):e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-2.5 h-2.5"})," ",x," more"]})})]}),e.jsx(Zs,{e:t})]})}function ta({escalations:t,highlightKeys:s=[],onRowClick:l,total:i,page:p,totalPages:m,onPageChange:h}){var o,c;const d=Date.now(),g=t.map(a=>{const N=new Date(a.created_at).getTime(),w=a.resolved_at?new Date(a.resolved_at).getTime():null,M=a.claimed_at?new Date(a.claimed_at).getTime():null,A=!w&&a.status!=="cancelled"&&a.status!=="expired",T=w??(A?d:N+3e4),O=a.status==="pending"&&vs(a)?"claimed":a.status;return{...a,startMs:N,claimedMs:M,endMs:T,isOpen:A,displayStatus:O}});if(g.length===0)return e.jsx("p",{className:"mt-12 text-center text-sm text-text-tertiary",children:"No escalations matched."});const C=g.length,P=Math.max(Math.abs((((o=g[C-1])==null?void 0:o.startMs)??0)-(((c=g[0])==null?void 0:c.startMs)??0)),1)/Math.max(C-1,1),j=Ws/Math.max(P,1),r=new Set(g.map(a=>new Date(a.startMs).toDateString())).size>1;function u(a){const N=new Date(a),w=N.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return r?N.toLocaleDateString([],{month:"short",day:"numeric"})+" "+w:w}return e.jsxs("div",{className:"mt-4 pb-24",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-1/2 -translate-x-px inset-y-0 w-px bg-surface-border/80"}),g.map((a,N)=>{const w=g[N-1],M=w?Math.abs(a.startMs-w.startMs):null,A=M!==null?Math.max(Xs,Math.round(M*j)):0,T=N%2===0,O=Ks(a.displayStatus),q=`rgb(var(${O}))`,D=a.endMs-a.startMs,y=a.isOpen?Ge(a.startMs):`${Ge(a.startMs)} · ${Ze(D)}`;return e.jsxs("div",{children:[N>0&&e.jsx(ea,{gapMs:M,heightPx:A}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-1 flex justify-end items-center",children:T?e.jsxs("div",{className:"flex items-center",children:[e.jsx(Qe,{e:a,highlightKeys:s,onRowClick:l}),e.jsx("div",{className:"flex-shrink-0 h-px bg-surface-border/70",style:{width:Ue}})]}):e.jsx("span",{className:"text-2xs text-text-quaternary font-mono tabular-nums pr-3",children:y})}),e.jsx("div",{className:"relative z-10 flex-shrink-0 w-3.5 h-3.5 rounded-full border-2 border-surface cursor-pointer transition-all duration-150 hover:scale-[1.5]",style:{backgroundColor:q,boxShadow:`0 0 0 3px rgb(var(${O}) / 0.16), 0 1px 3px rgb(var(${O}) / 0.19)`},onClick:()=>l==null?void 0:l(a)}),e.jsx("div",{className:"flex-1 flex justify-start items-center",children:T?e.jsx("span",{className:"text-2xs text-text-quaternary font-mono tabular-nums pl-3",children:y}):e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0 h-px bg-surface-border/70",style:{width:Ue}}),e.jsx(Qe,{e:a,highlightKeys:s,onRowClick:l})]})})]}),e.jsx("div",{className:"flex justify-center relative z-10 mt-0.5",children:e.jsx("span",{className:"text-2xs text-text-quaternary font-mono tabular-nums bg-surface px-1.5",children:u(a.startMs)})})]},a.id)})]}),m>1&&e.jsxs("div",{className:"sticky bottom-0 z-20 bg-surface/95 backdrop-blur-sm border-t border-surface-border -mx-page-x px-page-x pt-2 pb-4 flex items-center justify-between mt-10",children:[e.jsxs("span",{className:"text-2xs text-text-tertiary",children:["Page ",e.jsx("span",{className:"font-medium text-text-secondary",children:p})," ","of ",e.jsx("span",{className:"font-medium text-text-secondary",children:m})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>h(p-1),disabled:p<=1,className:"p-1.5 rounded hover:bg-surface-hover disabled:opacity-30 text-text-tertiary hover:text-text-primary transition-colors disabled:cursor-not-allowed",children:e.jsx(ns,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>h(p+1),disabled:p>=m,className:"p-1.5 rounded hover:bg-surface-hover disabled:opacity-30 text-text-tertiary hover:text-text-primary transition-colors disabled:cursor-not-allowed",children:e.jsx(rs,{className:"w-4 h-4"})})]})]})]})}function Aa(){var Ae,Te,Oe,Ee,Fe,_e,$e;const t=Es(),{filters:s,setFilter:l,pagination:i}=Cs({filters:{role:"",type:"",priority:"",status:"available",search:""}});ts({role:s.role||null,verbs:["created","claimed"]});const p=We(s.search,300),m=he(),[h,d]=f.useState(null),[x,g]=f.useState("30"),[C,S]=f.useState(0),P=f.useCallback(n=>S(n),[]),[j,k]=f.useState(new Set),[r,u]=f.useState(!1),[o,c]=Fs(),a=f.useMemo(()=>Ot(o),[o]),N=f.useCallback(n=>{c(b=>{const v=new URLSearchParams(b);return Et(v,n),v.delete("page"),v})},[c]),{data:w}=Ft(r),M=_t(a)+(s.search?1:0),A="facet-query",{setPanel:T,closePanel:O,open:q,ownerKey:D}=$t();f.useEffect(()=>{if(!r){O(A);return}T(e.jsx(qs,{value:a,onChange:N,facetKeys:(w==null?void 0:w.keys)??[],search:s.search??"",onSearchChange:n=>l("search",n),activeFacetCount:M,onClear:()=>{N({}),l("search","")},onClose:()=>u(!1)}),{width:420,key:A})},[r,a,N,w,s.search,l,M,T,O]);const y=q&&D===A,se=f.useRef(!1);f.useEffect(()=>{if(y){se.current=!0;return}se.current&&(se.current=!1,u(!1))},[y]);const[et,ae]=f.useState(!1),[tt,ne]=f.useState(!1),[st,re]=f.useState(!1),at=f.useCallback(n=>N({...a,orderBy:n}),[a,N]),H=_s(),{data:Q}=Lt(),fe=Bt(),nt=f.useCallback(()=>{var v;const n=window.prompt("Pin label:");if(!(n!=null&&n.trim()))return;const b=((v=Q==null?void 0:Q.preferences)==null?void 0:v.pinnedViews)??[];fe.mutate({pinnedViews:[...b,{id:Rt(),label:n.trim(),url:H.pathname+H.search,badge:!0}]})},[H.pathname,H.search,Q,fe]),{canBulk:rt}=zt(),ge=a.facets?Object.keys(a.facets):[],ie=o.get("view"),be=f.useCallback(n=>{c(b=>{const v=new URLSearchParams(b);return n?v.set("view",n):v.delete("view"),v},{replace:!0})},[c]),_=ie==="timeline",it=f.useCallback(n=>{const{[n]:b,...v}=a.facets??{};N({...a,facets:Object.keys(v).length>0?v:void 0})},[a,N]),ye=qt(),je=Dt(),ve=It(),le=Ut(),oe=Vt(),J=Gt(),{data:ce}=Ht(),{data:$}=Qt(),{data:de}=Jt(),{user:K,isSuperAdmin:lt,hasRoleType:ot}=Je(),Ne=lt||ot("admin"),Ce=f.useMemo(()=>new Set(((K==null?void 0:K.roles)??[]).map(n=>n.role)),[K]),ct=f.useMemo(()=>{const n=($==null?void 0:$.roles)??[];return(Ne?n:n.filter(v=>Ce.has(v.role)&&!es(v.role))).map(v=>({value:v.role,label:Kt(v)})).sort((v,Mt)=>v.label.localeCompare(Mt.label))},[$,Ne,Ce]);f.useEffect(()=>{k(new Set)},[s.role,s.type,s.priority,s.status,p,i.page,i.pageSize]);const I=s.status||"",U=I==="available",ue=I==="claimed",ke=ue?"pending":I==="resolved"?"resolved":I==="cancelled"?"cancelled":I==="expired"?"expired":void 0,we=100,Se={role:s.role||void 0,type:s.type||void 0,priority:s.priority?parseInt(s.priority):void 0,limit:_?we:i.pageSize,offset:i.offset,sort_by:"created_at",order:"desc",search:p||void 0,...a},dt=Wt({...Se,enabled:U}),ut=Xt({status:ke,claimed:ue||void 0,...Se,enabled:!U}),xt=U?dt:ut,{data:B,isLoading:mt,error:W,refetch:ht,isFetching:pt}=xt,ft=ks(`/escalations${U?"/available":""}`,{status:ke,claimed:ue||void 0,role:s.role||void 0,type:s.type||void 0,priority:s.priority||void 0,search:p||void 0,sort_by:"created_at",order:"desc",limit:i.pageSize,offset:i.offset,facets:a.facets&&Object.keys(a.facets).length?JSON.stringify(a.facets):void 0,block:(Ae=a.block)!=null&&Ae.length?JSON.stringify(a.block):void 0,range:(Te=a.range)!=null&&Te.length?JSON.stringify(a.range):void 0,exists:(Oe=a.exists)!=null&&Oe.length?JSON.stringify(a.exists):void 0,roles:(Ee=a.roles)!=null&&Ee.length?JSON.stringify(a.roles):void 0,orderBy:(Fe=a.orderBy)!=null&&Fe.length?JSON.stringify(a.orderBy):void 0,available:a.available!=null?String(a.available):void 0}),F=(B==null?void 0:B.escalations)??[],E=(B==null?void 0:B.total)??0,L=s.role||(((_e=a.roles)==null?void 0:_e.length)===1?a.roles[0]:null),X=(($e=Yt(L??"",void 0,!!L).data)==null?void 0:$e.list_schema)??null,Pe=!!L&&!!X&&!!X["x-lt-layout"]&&X["x-lt-layout"]!=="table",Y=Pe&&!_&&(ie?ie==="rich":!0),Me=f.useMemo(()=>{if(!a.jeopardy||!L)return null;const n=(($==null?void 0:$.roles)??[]).find(v=>v.role===L),b=(n==null?void 0:n.priority_threshold_minutes)??(n==null?void 0:n.sla_minutes)??null;return b!=null?Zt(b*6e4):null},[a.jeopardy,L,$]),gt=f.useMemo(()=>{const n=new Set;for(const b of F)j.has(b.id)&&n.add(b.role);return[...n]},[F,j]),bt=f.useCallback(()=>k(new Set),[]),yt=()=>{if(!h)return;const n=x==="custom"?C:parseInt(x);!n||n<=0||ye.mutate({id:h.id,durationMinutes:n},{onSuccess:()=>{d(null),t(`/escalations/detail/${h.id}`)}})},{handleSetPriority:jt,handleBulkClaim:vt,handleBulkTriage:Nt,handleBulkAssign:Ct,handleBulkCancel:kt}=Qs({selectedIds:j,clearSelection:bt,setPriority:je,bulkClaim:ve,bulkTriage:oe,bulkAssign:le,bulkCancel:J,closeTriageModal:()=>ae(!1),closeAssignModal:()=>ne(!1),closeCancelModal:()=>re(!1)}),wt=n=>{const b=new Set(j);b.has(n)?b.delete(n):b.add(n),k(b)},St=()=>{j.size===F.length?k(new Set):k(new Set(F.map(n=>n.id)))},Pt=[rt?{key:"select",label:e.jsx("input",{type:"checkbox",checked:F.length>0&&j.size===F.length,onChange:St,className:"rounded"}),render:n=>e.jsx("input",{type:"checkbox",checked:j.has(n.id),onChange:b=>{b.stopPropagation(),wt(n.id)},onClick:b=>b.stopPropagation(),className:"rounded"}),className:"w-10",priority:1}:{key:"spacer",label:"",render:()=>null,className:"w-10",priority:3},...bs({highlightKeys:ge}),{key:"actions",label:"",render:n=>e.jsx(As,{children:e.jsx(Ts,{icon:ds,title:"Claim escalation",onClick:()=>d(n),alwaysVisible:!0,colorClass:"text-accent/40 hover:text-accent",size:"sm"})}),className:"w-10 text-right"}];return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-10 min-w-0",children:[e.jsx(ys,{role:s.role,options:ct,onChange:n=>l("role",n)}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:dashboard.md:all-escalations"},className:"text-text-quaternary hover:text-accent transition-colors mt-1 shrink-0",title:"Open docs for this page",children:e.jsx(us,{className:"w-4 h-4",strokeWidth:1.5})})]}),e.jsx(js,{filters:s,setFilter:l,roles:(ce==null?void 0:ce.roles)??[],types:(de==null?void 0:de.types)??[],showStatus:!0,showSearch:!1,actions:e.jsxs(e.Fragment,{children:[_&&e.jsxs("span",{className:"text-2xs text-text-tertiary whitespace-nowrap",children:[E>100&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"font-medium text-text-secondary",children:[(i.page-1)*100+1,"–",Math.min(i.page*100,E)]})," of "]}),e.jsx("span",{className:"font-medium text-text-secondary",children:E})," ",E===1?"escalation":"escalations"]}),e.jsx(Ds,{orderBy:a.orderBy,onChange:at}),e.jsx("span",{className:"h-3.5 w-px bg-surface-border shrink-0"}),e.jsx(Os,{onRefresh:()=>ht(),isFetching:pt,apiPath:ft}),Pe&&!_&&e.jsx("button",{onClick:()=>be(Y?"table":"rich"),className:"ml-2 inline-flex h-7 w-7 items-center justify-center rounded icon-link hover:bg-surface-hover",title:Y?"Table view":"Rich view",children:Y?e.jsx(Be,{className:"w-4 h-4"}):e.jsx(xs,{className:"w-4 h-4"})}),M>0&&e.jsx("button",{onClick:()=>be(_?"table":"timeline"),className:"ml-2 inline-flex h-7 w-7 items-center justify-center rounded icon-link hover:bg-surface-hover",title:_?"Table view":"Timeline view",children:_?e.jsx(Be,{className:"w-4 h-4"}):e.jsx(ms,{className:"w-4 h-4"})}),e.jsx("button",{onClick:nt,className:"ml-2 inline-flex h-7 w-7 items-center justify-center rounded icon-link hover:bg-surface-hover",title:"Pin this view — save the current filters to your Pinned section","data-testid":"pin-current-view",children:e.jsx(hs,{className:"w-4 h-4"})}),e.jsxs("button",{onClick:()=>u(n=>!n),className:"relative ml-2 inline-flex h-7 w-7 items-center justify-center rounded icon-link hover:bg-surface-hover",title:"Faceted query",children:[e.jsx(ps,{className:"w-4 h-4"}),M>0&&e.jsx("span",{className:"absolute -right-1 -top-1 flex h-3.5 min-w-[14px] items-center justify-center rounded-full bg-accent px-0.5 text-2xs font-medium text-text-inverse",children:M})]})]})}),e.jsx(Vs,{selectedCount:j.size,onClearSelection:()=>k(new Set),onSetPriority:jt,onClaim:vt,onAssign:()=>ne(!0),onTriage:()=>ae(!0),onCancel:()=>re(!0),isPriorityPending:je.isPending,isClaimPending:ve.isPending,isAssignPending:le.isPending,isTriagePending:oe.isPending,isCancelPending:J.isPending}),(a.facets&&Object.keys(a.facets).length>0||a.jeopardy)&&e.jsxs("div",{className:"sticky top-14 z-30 bg-surface/98 backdrop-blur-sm border-b border-surface-border/30 -mx-page-x px-page-x py-2 flex items-center gap-1.5 flex-wrap",children:[a.jeopardy&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-status-error px-2.5 py-0.5 text-2xs font-semibold text-text-inverse",children:[e.jsx(fs,{className:"w-2.5 h-2.5",strokeWidth:2.5}),"in jeopardy",Me&&e.jsxs("span",{className:"font-mono font-normal opacity-90",children:["> ",Me]}),e.jsx("button",{onClick:()=>N({...a,jeopardy:void 0}),className:"ml-0.5 -mr-0.5 flex items-center text-text-inverse/70 hover:text-text-inverse transition-colors","aria-label":"Clear jeopardy filter",children:e.jsx(te,{className:"w-2.5 h-2.5"})})]}),Object.entries(a.facets??{}).map(([n,b])=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-accent/25 bg-accent/8 px-2.5 py-0.5 text-2xs font-medium text-accent/90",children:[e.jsx("span",{className:"font-mono text-text-tertiary",children:n}),e.jsx("span",{className:"text-text-quaternary",children:"="}),e.jsx("span",{className:"font-mono max-w-[160px] truncate",title:String(b),children:String(b)}),e.jsx("button",{onClick:()=>it(n),className:"ml-0.5 -mr-0.5 flex items-center text-text-quaternary hover:text-status-error transition-colors","aria-label":`Remove ${n} filter`,children:e.jsx(te,{className:"w-2.5 h-2.5"})})]},n)),Object.keys(a.facets??{}).length>1&&e.jsx("button",{onClick:()=>N({...a,facets:void 0}),className:"text-2xs text-text-quaternary hover:text-text-secondary transition-colors px-1",children:"clear all"})]}),W&&e.jsx("div",{className:"mb-4 px-4 py-3 rounded-md bg-status-error/10 border border-status-error/20 text-xs text-status-error",children:W.message==="Session expired"?"Your session has expired. Please log in again.":`Failed to load escalations: ${W.message}`}),_?e.jsx(ta,{escalations:F,highlightKeys:ge,onRowClick:n=>t(`/escalations/detail/${n.id}`,{state:{from:"/escalations/available"}}),total:E,page:i.page,totalPages:Math.ceil(E/we),onPageChange:i.setPage}):Y?e.jsx(Ns,{role:L,listSchema:X,activeEscalations:F,onRowClick:n=>t(`/escalations/detail/${n.id}`,{state:{from:"/escalations/available"}}),onOpenGroup:n=>t(n),onAddFacet:(n,b)=>N({...a,facets:{...a.facets??{},[n]:typeof b=="object"&&b!==null?JSON.stringify(b):b}}),total:E,page:i.page,totalPages:i.totalPages(E),pageSize:i.pageSize,onPageChange:i.setPage,onPageSizeChange:i.setPageSize}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{columns:Pt,data:F,layout:"fixed",keyFn:n=>n.id,onRowClick:n=>t(`/escalations/detail/${n.id}`,{state:{from:"/escalations/available"}}),isLoading:mt,emptyMessage:W?"Unable to load data":"No escalations"}),e.jsx(Ss,{page:i.page,totalPages:i.totalPages(E),onPageChange:i.setPage,total:E,pageSize:i.pageSize,onPageSizeChange:i.setPageSize})]}),e.jsx(Js,{claimTarget:h,onClose:()=>d(null),claimDuration:x,onDurationChange:n=>{g(n),S(0)},claimDurations:m,customClaimMinutes:C,onCustomClaimChange:P,onClaim:yt,isPending:ye.isPending}),e.jsx(Hs,{open:et,onClose:()=>ae(!1),selectedCount:j.size,onSubmit:Nt,isPending:oe.isPending}),e.jsx(Gs,{open:tt,onClose:()=>ne(!1),selectedCount:j.size,selectedRoles:gt,onSubmit:Ct,isPending:le.isPending}),e.jsx(gs,{open:st,onClose:()=>re(!1),onConfirm:kt,selectedCount:j.size,isPending:J.isPending,error:J.error})]})}export{Aa as AvailableEscalationsPage};
2
- //# sourceMappingURL=AvailableEscalationsPage-BjsbfsWW.js.map