@hotmeshio/long-tail 0.10.10 → 0.10.13

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 (322) hide show
  1. package/build/api/escalations/list.d.ts +1 -0
  2. package/build/api/escalations/list.js +12 -4
  3. package/build/api/escalations/metadata.d.ts +11 -0
  4. package/build/api/escalations/metadata.js +27 -7
  5. package/build/api/roles.d.ts +2 -0
  6. package/build/api/roles.js +4 -0
  7. package/build/api/scan-codes/config.d.ts +22 -0
  8. package/build/api/scan-codes/config.js +136 -0
  9. package/build/api/scan-codes/execute.d.ts +9 -0
  10. package/build/api/scan-codes/execute.js +372 -0
  11. package/build/api/scan-codes/index.d.ts +2 -0
  12. package/build/api/scan-codes/index.js +14 -0
  13. package/build/lib/db/schemas/025_ops_home_default.sql +11 -0
  14. package/build/lib/db/schemas/026_scan_codes.sql +51 -0
  15. package/build/lib/db/schemas/027_scan_codes_reindex.sql +23 -0
  16. package/build/lib/events/system-events.js +4 -0
  17. package/build/modules/features.d.ts +17 -0
  18. package/build/modules/features.js +2 -0
  19. package/build/routes/escalations/list.js +1 -0
  20. package/build/routes/index.js +2 -0
  21. package/build/routes/scan-codes.d.ts +2 -0
  22. package/build/routes/scan-codes.js +138 -0
  23. package/build/sdk/index.d.ts +4 -0
  24. package/build/services/escalation/crud.d.ts +1 -1
  25. package/build/services/escalation/crud.js +4 -2
  26. package/build/services/escalation/queries.d.ts +1 -0
  27. package/build/services/escalation/queries.js +2 -0
  28. package/build/services/escalation/sql.d.ts +11 -6
  29. package/build/services/escalation/sql.js +20 -20
  30. package/build/services/role/index.js +1 -0
  31. package/build/services/role/sql.d.ts +6 -2
  32. package/build/services/role/sql.js +11 -2
  33. package/build/services/role/types.d.ts +9 -0
  34. package/build/services/scan-code/index.d.ts +4 -0
  35. package/build/services/scan-code/index.js +21 -0
  36. package/build/services/scan-code/parse.d.ts +35 -0
  37. package/build/services/scan-code/parse.js +108 -0
  38. package/build/services/scan-code/read.d.ts +5 -0
  39. package/build/services/scan-code/read.js +50 -0
  40. package/build/services/scan-code/sql.d.ts +10 -0
  41. package/build/services/scan-code/sql.js +57 -0
  42. package/build/services/scan-code/validate.d.ts +12 -0
  43. package/build/services/scan-code/validate.js +78 -0
  44. package/build/services/scan-code/write.d.ts +26 -0
  45. package/build/services/scan-code/write.js +71 -0
  46. package/build/shared/form-validation/index.d.ts +1 -0
  47. package/build/shared/form-validation/index.js +1 -0
  48. package/build/shared/form-validation/x-lt-transition.d.ts +47 -0
  49. package/build/shared/form-validation/x-lt-transition.js +65 -0
  50. package/build/system/mcp-servers/admin/index.d.ts +1 -0
  51. package/build/system/mcp-servers/admin/index.js +5 -2
  52. package/build/system/mcp-servers/admin/scan-codes.d.ts +10 -0
  53. package/build/system/mcp-servers/admin/scan-codes.js +111 -0
  54. package/build/system/mcp-servers/admin/schemas.d.ts +235 -14
  55. package/build/system/mcp-servers/admin/schemas.js +51 -0
  56. package/build/system/mcp-servers/admin/users.js +1 -0
  57. package/build/system/seed/tool-manifests-admin.d.ts +1462 -0
  58. package/build/system/seed/tool-manifests-admin.js +7 -1
  59. package/build/tsconfig.tsbuildinfo +1 -1
  60. package/build/types/events.d.ts +9 -0
  61. package/build/types/index.d.ts +2 -0
  62. package/build/types/index.js +10 -1
  63. package/build/types/scan-code.d.ts +183 -0
  64. package/build/types/scan-code.js +80 -0
  65. package/build/types/startup.d.ts +14 -0
  66. package/dashboard/dist/assets/{AdminDashboard-cGYuppUP.js → AdminDashboard-Bv3pHBzn.js} +2 -2
  67. package/dashboard/dist/assets/{AdminDashboard-cGYuppUP.js.map → AdminDashboard-Bv3pHBzn.js.map} +1 -1
  68. package/dashboard/dist/assets/{AgentConfigPage-DwaUyoCy.js → AgentConfigPage-Dk2zlvDb.js} +6 -6
  69. package/dashboard/dist/assets/{AgentConfigPage-DwaUyoCy.js.map → AgentConfigPage-Dk2zlvDb.js.map} +1 -1
  70. package/dashboard/dist/assets/{AgentDetailPage-DxpFaltM.js → AgentDetailPage-DUno6EGs.js} +2 -2
  71. package/dashboard/dist/assets/{AgentDetailPage-DxpFaltM.js.map → AgentDetailPage-DUno6EGs.js.map} +1 -1
  72. package/dashboard/dist/assets/{AgentsPage-ByOoA8oT.js → AgentsPage-CToVu1qj.js} +2 -2
  73. package/dashboard/dist/assets/{AgentsPage-ByOoA8oT.js.map → AgentsPage-CToVu1qj.js.map} +1 -1
  74. package/dashboard/dist/assets/{AutoGrowTextarea-y-oNY51_.js → AutoGrowTextarea-DgEQeRQw.js} +2 -2
  75. package/dashboard/dist/assets/{AutoGrowTextarea-y-oNY51_.js.map → AutoGrowTextarea-DgEQeRQw.js.map} +1 -1
  76. package/dashboard/dist/assets/AvailableEscalationsPage-DldboL4W.js +2 -0
  77. package/dashboard/dist/assets/AvailableEscalationsPage-DldboL4W.js.map +1 -0
  78. package/dashboard/dist/assets/BotPicker-DQOpVB4M.js +2 -0
  79. package/dashboard/dist/assets/{BotPicker-Dohv8dhR.js.map → BotPicker-DQOpVB4M.js.map} +1 -1
  80. package/dashboard/dist/assets/{CapabilitiesPage-DeijFG3J.js → CapabilitiesPage-Dmf46PUJ.js} +2 -2
  81. package/dashboard/dist/assets/{CapabilitiesPage-DeijFG3J.js.map → CapabilitiesPage-Dmf46PUJ.js.map} +1 -1
  82. package/dashboard/dist/assets/{CollapsibleSection-BPNwS4eO.js → CollapsibleSection-CDADefUY.js} +2 -2
  83. package/dashboard/dist/assets/{CollapsibleSection-BPNwS4eO.js.map → CollapsibleSection-CDADefUY.js.map} +1 -1
  84. package/dashboard/dist/assets/{ConfirmDeleteModal-DD7SEMeX.js → ConfirmDeleteModal-CQsJUzEa.js} +2 -2
  85. package/dashboard/dist/assets/{ConfirmDeleteModal-DD7SEMeX.js.map → ConfirmDeleteModal-CQsJUzEa.js.map} +1 -1
  86. package/dashboard/dist/assets/{CopyableId-BpB-NvDh.js → CopyableId-4Lqlc5cU.js} +2 -2
  87. package/dashboard/dist/assets/{CopyableId-BpB-NvDh.js.map → CopyableId-4Lqlc5cU.js.map} +1 -1
  88. package/dashboard/dist/assets/CountdownTimer-DPjIkerB.js +2 -0
  89. package/dashboard/dist/assets/{CountdownTimer-BF71ldGF.js.map → CountdownTimer-DPjIkerB.js.map} +1 -1
  90. package/dashboard/dist/assets/{CredentialsPage-oeNmMzTM.js → CredentialsPage-8LIEvomi.js} +2 -2
  91. package/dashboard/dist/assets/{CredentialsPage-oeNmMzTM.js.map → CredentialsPage-8LIEvomi.js.map} +1 -1
  92. package/dashboard/dist/assets/{CronLabel-CebR1m2k.js → CronLabel-CK3WSsM5.js} +2 -2
  93. package/dashboard/dist/assets/{CronLabel-CebR1m2k.js.map → CronLabel-CK3WSsM5.js.map} +1 -1
  94. package/dashboard/dist/assets/{CustomDurationPicker-Bh9QdBVw.js → CustomDurationPicker-FPmlA6cE.js} +2 -2
  95. package/dashboard/dist/assets/{CustomDurationPicker-Bh9QdBVw.js.map → CustomDurationPicker-FPmlA6cE.js.map} +1 -1
  96. package/dashboard/dist/assets/{DataTable-BTu2AaEl.js → DataTable-Bir0Xs1p.js} +2 -2
  97. package/dashboard/dist/assets/{DataTable-BTu2AaEl.js.map → DataTable-Bir0Xs1p.js.map} +1 -1
  98. package/dashboard/dist/assets/{DropZone-Bavzt2QR.js → DropZone-CL9gA7pu.js} +2 -2
  99. package/dashboard/dist/assets/{DropZone-Bavzt2QR.js.map → DropZone-CL9gA7pu.js.map} +1 -1
  100. package/dashboard/dist/assets/{ElapsedCell-Caa6CU_y.js → ElapsedCell-BZVkVxE0.js} +2 -2
  101. package/dashboard/dist/assets/{ElapsedCell-Caa6CU_y.js.map → ElapsedCell-BZVkVxE0.js.map} +1 -1
  102. package/dashboard/dist/assets/{EmptyState-BcsfPq9T.js → EmptyState-lpUFYfun.js} +2 -2
  103. package/dashboard/dist/assets/{EmptyState-BcsfPq9T.js.map → EmptyState-lpUFYfun.js.map} +1 -1
  104. package/dashboard/dist/assets/{EscalationListSchemaPage-CAGfq0eK.js → EscalationListSchemaPage-kYLdUtZX.js} +3 -3
  105. package/dashboard/dist/assets/{EscalationListSchemaPage-CAGfq0eK.js.map → EscalationListSchemaPage-kYLdUtZX.js.map} +1 -1
  106. package/dashboard/dist/assets/{EscalationSchemaPage-qDD4ur6P.js → EscalationSchemaPage-kUmCDivo.js} +3 -3
  107. package/dashboard/dist/assets/{EscalationSchemaPage-qDD4ur6P.js.map → EscalationSchemaPage-kUmCDivo.js.map} +1 -1
  108. package/dashboard/dist/assets/{EscalationsOverview-CC1wRTzy.js → EscalationsOverview-D17auO-m.js} +2 -2
  109. package/dashboard/dist/assets/{EscalationsOverview-CC1wRTzy.js.map → EscalationsOverview-D17auO-m.js.map} +1 -1
  110. package/dashboard/dist/assets/{EventTable-4JeTcXr_.js → EventTable-CwPWl163.js} +2 -2
  111. package/dashboard/dist/assets/{EventTable-4JeTcXr_.js.map → EventTable-CwPWl163.js.map} +1 -1
  112. package/dashboard/dist/assets/{FilterBar-BOV8DWIO.js → FilterBar-D7GghUsU.js} +2 -2
  113. package/dashboard/dist/assets/{FilterBar-BOV8DWIO.js.map → FilterBar-D7GghUsU.js.map} +1 -1
  114. package/dashboard/dist/assets/{GraphInvokePage-C0i1speW.js → GraphInvokePage-D11uOnZi.js} +2 -2
  115. package/dashboard/dist/assets/{GraphInvokePage-C0i1speW.js.map → GraphInvokePage-D11uOnZi.js.map} +1 -1
  116. package/dashboard/dist/assets/HomePage-Bcq10Bxx.js +2 -0
  117. package/dashboard/dist/assets/HomePage-Bcq10Bxx.js.map +1 -0
  118. package/dashboard/dist/assets/ListToolbar-IPXsTb3Q.js +2 -0
  119. package/dashboard/dist/assets/ListToolbar-IPXsTb3Q.js.map +1 -0
  120. package/dashboard/dist/assets/{McpOverview-Chn2zIXr.js → McpOverview-Dx2j0KkF.js} +2 -2
  121. package/dashboard/dist/assets/{McpOverview-Chn2zIXr.js.map → McpOverview-Dx2j0KkF.js.map} +1 -1
  122. package/dashboard/dist/assets/{McpQueryDetailPage-Cv1FKrvw.js → McpQueryDetailPage-CzF_bna8.js} +3 -3
  123. package/dashboard/dist/assets/{McpQueryDetailPage-Cv1FKrvw.js.map → McpQueryDetailPage-CzF_bna8.js.map} +1 -1
  124. package/dashboard/dist/assets/{McpQueryPage-Dzn8JE4E.js → McpQueryPage-CNsuiw_q.js} +2 -2
  125. package/dashboard/dist/assets/{McpQueryPage-Dzn8JE4E.js.map → McpQueryPage-CNsuiw_q.js.map} +1 -1
  126. package/dashboard/dist/assets/{McpRunDetailPage-CuNtR4Ed.js → McpRunDetailPage-BJguEMS0.js} +2 -2
  127. package/dashboard/dist/assets/{McpRunDetailPage-CuNtR4Ed.js.map → McpRunDetailPage-BJguEMS0.js.map} +1 -1
  128. package/dashboard/dist/assets/{McpRunsPage-C8iifeKN.js → McpRunsPage-CK96s3Nt.js} +2 -2
  129. package/dashboard/dist/assets/{McpRunsPage-C8iifeKN.js.map → McpRunsPage-CK96s3Nt.js.map} +1 -1
  130. package/dashboard/dist/assets/{Modal-CA2Iv02H.js → Modal-BU7No9NH.js} +2 -2
  131. package/dashboard/dist/assets/{Modal-CA2Iv02H.js.map → Modal-BU7No9NH.js.map} +1 -1
  132. package/dashboard/dist/assets/{NamespacePill-ep9Zmokr.js → NamespacePill-B9Vc_Pz2.js} +2 -2
  133. package/dashboard/dist/assets/{NamespacePill-ep9Zmokr.js.map → NamespacePill-B9Vc_Pz2.js.map} +1 -1
  134. package/dashboard/dist/assets/OperationsPage-DvWrLuH6.js +2 -0
  135. package/dashboard/dist/assets/OperationsPage-DvWrLuH6.js.map +1 -0
  136. package/dashboard/dist/assets/OperatorDashboard-C-jE0IRA.js +2 -0
  137. package/dashboard/dist/assets/OperatorDashboard-C-jE0IRA.js.map +1 -0
  138. package/dashboard/dist/assets/{PageHeader-Bw8RNkqR.js → PageHeader-Ce4GcIYo.js} +2 -2
  139. package/dashboard/dist/assets/{PageHeader-Bw8RNkqR.js.map → PageHeader-Ce4GcIYo.js.map} +1 -1
  140. package/dashboard/dist/assets/{PageHeaderWithStats-NR_4idn6.js → PageHeaderWithStats-Ck0KZvXD.js} +2 -2
  141. package/dashboard/dist/assets/{PageHeaderWithStats-NR_4idn6.js.map → PageHeaderWithStats-Ck0KZvXD.js.map} +1 -1
  142. package/dashboard/dist/assets/{PersonaDetailPage-DKILoUqL.js → PersonaDetailPage-CJ6jqo7h.js} +2 -2
  143. package/dashboard/dist/assets/{PersonaDetailPage-DKILoUqL.js.map → PersonaDetailPage-CJ6jqo7h.js.map} +1 -1
  144. package/dashboard/dist/assets/{PersonasPage-qvzHTrFw.js → PersonasPage-D8hL3kL5.js} +2 -2
  145. package/dashboard/dist/assets/{PersonasPage-qvzHTrFw.js.map → PersonasPage-D8hL3kL5.js.map} +1 -1
  146. package/dashboard/dist/assets/{PriorityBadge-CCERr9vQ.js → PriorityBadge-BETdj4M-.js} +2 -2
  147. package/dashboard/dist/assets/{PriorityBadge-CCERr9vQ.js.map → PriorityBadge-BETdj4M-.js.map} +1 -1
  148. package/dashboard/dist/assets/{ProcessDetailPage-C3LfeKvi.js → ProcessDetailPage-Vnx8Z5_y.js} +2 -2
  149. package/dashboard/dist/assets/{ProcessDetailPage-C3LfeKvi.js.map → ProcessDetailPage-Vnx8Z5_y.js.map} +1 -1
  150. package/dashboard/dist/assets/{ProcessesListPage-OoZ_u4ty.js → ProcessesListPage-DRYtvS3N.js} +2 -2
  151. package/dashboard/dist/assets/{ProcessesListPage-OoZ_u4ty.js.map → ProcessesListPage-DRYtvS3N.js.map} +1 -1
  152. package/dashboard/dist/assets/RoleDetailPage-BKkUvTO-.js +8 -0
  153. package/dashboard/dist/assets/RoleDetailPage-BKkUvTO-.js.map +1 -0
  154. package/dashboard/dist/assets/{RolePill-TySZq7dB.js → RolePill-CnuBPhPw.js} +2 -2
  155. package/dashboard/dist/assets/{RolePill-TySZq7dB.js.map → RolePill-CnuBPhPw.js.map} +1 -1
  156. package/dashboard/dist/assets/RolesPage-BHzWK9n6.js +2 -0
  157. package/dashboard/dist/assets/{RolesPage-CNueMVuJ.js.map → RolesPage-BHzWK9n6.js.map} +1 -1
  158. package/dashboard/dist/assets/{RowActions-BA9L9djf.js → RowActions-eYrzgQSj.js} +2 -2
  159. package/dashboard/dist/assets/{RowActions-BA9L9djf.js.map → RowActions-eYrzgQSj.js.map} +1 -1
  160. package/dashboard/dist/assets/{RunAsSelector-CwWEpiSF.js → RunAsSelector-CS3KQ-BF.js} +2 -2
  161. package/dashboard/dist/assets/{RunAsSelector-CwWEpiSF.js.map → RunAsSelector-CS3KQ-BF.js.map} +1 -1
  162. package/dashboard/dist/assets/ScanCodesPage-BW4P4zWf.js +2 -0
  163. package/dashboard/dist/assets/ScanCodesPage-BW4P4zWf.js.map +1 -0
  164. package/dashboard/dist/assets/ScanSchemeDetailPage-BLykA4j-.js +2 -0
  165. package/dashboard/dist/assets/ScanSchemeDetailPage-BLykA4j-.js.map +1 -0
  166. package/dashboard/dist/assets/{ScopeBadge-C7Uixtmk.js → ScopeBadge-BUpYpS3x.js} +2 -2
  167. package/dashboard/dist/assets/{ScopeBadge-C7Uixtmk.js.map → ScopeBadge-BUpYpS3x.js.map} +1 -1
  168. package/dashboard/dist/assets/{StatCard-Ca-ngCaD.js → StatCard-BXQ8dD9Y.js} +2 -2
  169. package/dashboard/dist/assets/{StatCard-Ca-ngCaD.js.map → StatCard-BXQ8dD9Y.js.map} +1 -1
  170. package/dashboard/dist/assets/{StatusBadge-BwUvykDo.js → StatusBadge-DkgllZHv.js} +2 -2
  171. package/dashboard/dist/assets/{StatusBadge-BwUvykDo.js.map → StatusBadge-DkgllZHv.js.map} +1 -1
  172. package/dashboard/dist/assets/{StickyPagination-DvIF3kQK.js → StickyPagination-hMrnLXde.js} +2 -2
  173. package/dashboard/dist/assets/{StickyPagination-DvIF3kQK.js.map → StickyPagination-hMrnLXde.js.map} +1 -1
  174. package/dashboard/dist/assets/{StreamMessageDetail-DkFK_XGD.js → StreamMessageDetail-DyJyZwBl.js} +2 -2
  175. package/dashboard/dist/assets/{StreamMessageDetail-DkFK_XGD.js.map → StreamMessageDetail-DyJyZwBl.js.map} +1 -1
  176. package/dashboard/dist/assets/{SwimlaneTimeline-CMw-Et6h.js → SwimlaneTimeline-BlzV74V5.js} +2 -2
  177. package/dashboard/dist/assets/{SwimlaneTimeline-CMw-Et6h.js.map → SwimlaneTimeline-BlzV74V5.js.map} +1 -1
  178. package/dashboard/dist/assets/{TagInput-D8gSp48D.js → TagInput-BbZ25nNe.js} +2 -2
  179. package/dashboard/dist/assets/{TagInput-D8gSp48D.js.map → TagInput-BbZ25nNe.js.map} +1 -1
  180. package/dashboard/dist/assets/{TaskDetailPage-BhXuChOf.js → TaskDetailPage-B0p_Z4J_.js} +2 -2
  181. package/dashboard/dist/assets/{TaskDetailPage-BhXuChOf.js.map → TaskDetailPage-B0p_Z4J_.js.map} +1 -1
  182. package/dashboard/dist/assets/{TaskQueuePill-CHqolBmU.js → TaskQueuePill-D0QKBrN3.js} +2 -2
  183. package/dashboard/dist/assets/{TaskQueuePill-CHqolBmU.js.map → TaskQueuePill-D0QKBrN3.js.map} +1 -1
  184. package/dashboard/dist/assets/{TasksListPage-6JHQQ5QZ.js → TasksListPage-CiGR2QiQ.js} +2 -2
  185. package/dashboard/dist/assets/{TasksListPage-6JHQQ5QZ.js.map → TasksListPage-CiGR2QiQ.js.map} +1 -1
  186. package/dashboard/dist/assets/TimeAgo-D_DA9ucC.js +2 -0
  187. package/dashboard/dist/assets/{TimeAgo-CInx-vzY.js.map → TimeAgo-D_DA9ucC.js.map} +1 -1
  188. package/dashboard/dist/assets/{TimestampCell-Fq17Zrsu.js → TimestampCell-C7rkC9nh.js} +2 -2
  189. package/dashboard/dist/assets/{TimestampCell-Fq17Zrsu.js.map → TimestampCell-C7rkC9nh.js.map} +1 -1
  190. package/dashboard/dist/assets/{ToolPill-BbgMDhaE.js → ToolPill-8xY9rkoc.js} +2 -2
  191. package/dashboard/dist/assets/{ToolPill-BbgMDhaE.js.map → ToolPill-8xY9rkoc.js.map} +1 -1
  192. package/dashboard/dist/assets/{ToolTestPanel-DhjEe59s.js → ToolTestPanel-E8efYGYs.js} +2 -2
  193. package/dashboard/dist/assets/{ToolTestPanel-DhjEe59s.js.map → ToolTestPanel-E8efYGYs.js.map} +1 -1
  194. package/dashboard/dist/assets/{TopicDetailPage-DbIdmQpQ.js → TopicDetailPage-B455XrRc.js} +3 -3
  195. package/dashboard/dist/assets/{TopicDetailPage-DbIdmQpQ.js.map → TopicDetailPage-B455XrRc.js.map} +1 -1
  196. package/dashboard/dist/assets/{TopicsPage-CAP-GUbr.js → TopicsPage-1VAc29Qw.js} +2 -2
  197. package/dashboard/dist/assets/{TopicsPage-CAP-GUbr.js.map → TopicsPage-1VAc29Qw.js.map} +1 -1
  198. package/dashboard/dist/assets/UserName-DikzjQHJ.js +2 -0
  199. package/dashboard/dist/assets/{UserName-DggcLkSc.js.map → UserName-DikzjQHJ.js.map} +1 -1
  200. package/dashboard/dist/assets/{WorkflowExecutionPage-Bmra5fVt.js → WorkflowExecutionPage-C15GSAoe.js} +2 -2
  201. package/dashboard/dist/assets/{WorkflowExecutionPage-Bmra5fVt.js.map → WorkflowExecutionPage-C15GSAoe.js.map} +1 -1
  202. package/dashboard/dist/assets/{WorkflowPill-CcUUVugA.js → WorkflowPill-Da406nEj.js} +2 -2
  203. package/dashboard/dist/assets/{WorkflowPill-CcUUVugA.js.map → WorkflowPill-Da406nEj.js.map} +1 -1
  204. package/dashboard/dist/assets/{WorkflowsDashboard-BQsZAGYU.js → WorkflowsDashboard-BMQd_0tW.js} +2 -2
  205. package/dashboard/dist/assets/{WorkflowsDashboard-BQsZAGYU.js.map → WorkflowsDashboard-BMQd_0tW.js.map} +1 -1
  206. package/dashboard/dist/assets/{WorkflowsOverview-CeliraHZ.js → WorkflowsOverview-CdxjVifp.js} +2 -2
  207. package/dashboard/dist/assets/{WorkflowsOverview-CeliraHZ.js.map → WorkflowsOverview-CdxjVifp.js.map} +1 -1
  208. package/dashboard/dist/assets/{YamlWorkflowDetailPage-DGxlonrV.js → YamlWorkflowDetailPage-DNVffIXa.js} +13 -13
  209. package/dashboard/dist/assets/{YamlWorkflowDetailPage-DGxlonrV.js.map → YamlWorkflowDetailPage-DNVffIXa.js.map} +1 -1
  210. package/dashboard/dist/assets/{YamlWorkflowsPage-DnT8UiyQ.js → YamlWorkflowsPage-BGP8wuos.js} +2 -2
  211. package/dashboard/dist/assets/{YamlWorkflowsPage-DnT8UiyQ.js.map → YamlWorkflowsPage-BGP8wuos.js.map} +1 -1
  212. package/dashboard/dist/assets/{agents-mRV7m4sh.js → agents-BZJLIJ4h.js} +2 -2
  213. package/dashboard/dist/assets/{agents-mRV7m4sh.js.map → agents-BZJLIJ4h.js.map} +1 -1
  214. package/dashboard/dist/assets/{bots-SONCZlCM.js → bots-ClLcDGJb.js} +2 -2
  215. package/dashboard/dist/assets/{bots-SONCZlCM.js.map → bots-ClLcDGJb.js.map} +1 -1
  216. package/dashboard/dist/assets/capabilities-IaCcS7ge.js +2 -0
  217. package/dashboard/dist/assets/{capabilities-DZjCMN32.js.map → capabilities-IaCcS7ge.js.map} +1 -1
  218. package/dashboard/dist/assets/{controlplane-RQNXjna2.js → controlplane-Zi4m_MSx.js} +2 -2
  219. package/dashboard/dist/assets/{controlplane-RQNXjna2.js.map → controlplane-Zi4m_MSx.js.map} +1 -1
  220. package/dashboard/dist/assets/escalation-columns-BY2mg9DY.js +2 -0
  221. package/dashboard/dist/assets/escalation-columns-BY2mg9DY.js.map +1 -0
  222. package/dashboard/dist/assets/{index-ymm58cTW.js → index-BqGnhkh0.js} +2 -2
  223. package/dashboard/dist/assets/{index-ymm58cTW.js.map → index-BqGnhkh0.js.map} +1 -1
  224. package/dashboard/dist/assets/index-BzkE48xJ.js +6 -0
  225. package/dashboard/dist/assets/index-BzkE48xJ.js.map +1 -0
  226. package/dashboard/dist/assets/{index-CkeSxuZ0.js → index-C3o4OisO.js} +2 -2
  227. package/dashboard/dist/assets/{index-CkeSxuZ0.js.map → index-C3o4OisO.js.map} +1 -1
  228. package/dashboard/dist/assets/{index-DY_hlZCQ.js → index-CJu2PBNx.js} +2 -2
  229. package/dashboard/dist/assets/{index-DY_hlZCQ.js.map → index-CJu2PBNx.js.map} +1 -1
  230. package/dashboard/dist/assets/{index-DYKRtstT.js → index-CLmZaNTK.js} +2 -2
  231. package/dashboard/dist/assets/{index-DYKRtstT.js.map → index-CLmZaNTK.js.map} +1 -1
  232. package/dashboard/dist/assets/index-CfAi1OsI.js +65 -0
  233. package/dashboard/dist/assets/index-CfAi1OsI.js.map +1 -0
  234. package/dashboard/dist/assets/{index-CK-6m8e_.js → index-CmnNqpWg.js} +2 -2
  235. package/dashboard/dist/assets/{index-CK-6m8e_.js.map → index-CmnNqpWg.js.map} +1 -1
  236. package/dashboard/dist/assets/{index-DFJF8aWz.js → index-CvNBdkB1.js} +3 -3
  237. package/dashboard/dist/assets/{index-DFJF8aWz.js.map → index-CvNBdkB1.js.map} +1 -1
  238. package/dashboard/dist/assets/{index-DbZpL10z.js → index-D0zFReGL.js} +2 -2
  239. package/dashboard/dist/assets/{index-DbZpL10z.js.map → index-D0zFReGL.js.map} +1 -1
  240. package/dashboard/dist/assets/{index-C6GsrvX1.js → index-Dldi3Q3M.js} +2 -2
  241. package/dashboard/dist/assets/{index-C6GsrvX1.js.map → index-Dldi3Q3M.js.map} +1 -1
  242. package/dashboard/dist/assets/{index-DqsLfO-0.js → index-kiKZresb.js} +2 -2
  243. package/dashboard/dist/assets/{index-DqsLfO-0.js.map → index-kiKZresb.js.map} +1 -1
  244. package/dashboard/dist/assets/index-mKcQGi2B.js +3 -0
  245. package/dashboard/dist/assets/index-mKcQGi2B.js.map +1 -0
  246. package/dashboard/dist/assets/{index-CxVGlkK6.js → index-yGNt29V9.js} +2 -2
  247. package/dashboard/dist/assets/{index-CxVGlkK6.js.map → index-yGNt29V9.js.map} +1 -1
  248. package/dashboard/dist/assets/index-zQiUPfxA.css +1 -0
  249. package/dashboard/dist/assets/{knowledge-Bawo8u7l.js → knowledge-DWLxGTib.js} +2 -2
  250. package/dashboard/dist/assets/{knowledge-Bawo8u7l.js.map → knowledge-DWLxGTib.js.map} +1 -1
  251. package/dashboard/dist/assets/{mcp-CKIpbpRZ.js → mcp-B6AARZ2I.js} +2 -2
  252. package/dashboard/dist/assets/{mcp-CKIpbpRZ.js.map → mcp-B6AARZ2I.js.map} +1 -1
  253. package/dashboard/dist/assets/{mcp-query-vld4hYxQ.js → mcp-query-DrkvBU3a.js} +2 -2
  254. package/dashboard/dist/assets/{mcp-query-vld4hYxQ.js.map → mcp-query-DrkvBU3a.js.map} +1 -1
  255. package/dashboard/dist/assets/{personas-BsARc3df.js → personas-Cmz2SAEU.js} +2 -2
  256. package/dashboard/dist/assets/{personas-BsARc3df.js.map → personas-Cmz2SAEU.js.map} +1 -1
  257. package/dashboard/dist/assets/{pipelines-BTSL-5ko.js → pipelines-CSgfVCMy.js} +2 -2
  258. package/dashboard/dist/assets/{pipelines-BTSL-5ko.js.map → pipelines-CSgfVCMy.js.map} +1 -1
  259. package/dashboard/dist/assets/{tasks-DggQdNbj.js → tasks-UOtUkDk-.js} +2 -2
  260. package/dashboard/dist/assets/{tasks-DggQdNbj.js.map → tasks-UOtUkDk-.js.map} +1 -1
  261. package/dashboard/dist/assets/{topics-DzAKa34X.js → topics-Df5hGh6o.js} +2 -2
  262. package/dashboard/dist/assets/{topics-DzAKa34X.js.map → topics-Df5hGh6o.js.map} +1 -1
  263. package/dashboard/dist/assets/{useDebouncedValue-BA5S7V54.js → useDebouncedValue-C4P2jQuh.js} +2 -2
  264. package/dashboard/dist/assets/{useDebouncedValue-BA5S7V54.js.map → useDebouncedValue-C4P2jQuh.js.map} +1 -1
  265. package/dashboard/dist/assets/{useEventHooks-5uI9oI5W.js → useEventHooks-PDbuSJ12.js} +2 -2
  266. package/dashboard/dist/assets/{useEventHooks-5uI9oI5W.js.map → useEventHooks-PDbuSJ12.js.map} +1 -1
  267. package/dashboard/dist/assets/{useFilterParams-CvRyYHJN.js → useFilterParams-crmlBw_l.js} +2 -2
  268. package/dashboard/dist/assets/{useFilterParams-CvRyYHJN.js.map → useFilterParams-crmlBw_l.js.map} +1 -1
  269. package/dashboard/dist/assets/{useNamespace-CEKzFIqe.js → useNamespace-tZSOlge3.js} +2 -2
  270. package/dashboard/dist/assets/{useNamespace-CEKzFIqe.js.map → useNamespace-tZSOlge3.js.map} +1 -1
  271. package/dashboard/dist/assets/{useYamlActivityEvents-hHgX1Z50.js → useYamlActivityEvents-CINLzE32.js} +2 -2
  272. package/dashboard/dist/assets/{useYamlActivityEvents-hHgX1Z50.js.map → useYamlActivityEvents-CINLzE32.js.map} +1 -1
  273. package/dashboard/dist/assets/{users-AO8lUyNr.js → users-G8qwyZKS.js} +2 -2
  274. package/dashboard/dist/assets/{users-AO8lUyNr.js.map → users-G8qwyZKS.js.map} +1 -1
  275. package/dashboard/dist/assets/{vendor-icons-DN9yGSuM.js → vendor-icons-BpZiWH2f.js} +40 -40
  276. package/dashboard/dist/assets/vendor-icons-BpZiWH2f.js.map +1 -0
  277. package/dashboard/dist/assets/{vendor-query-B2UbickB.js → vendor-query-RUZdMvN6.js} +2 -2
  278. package/dashboard/dist/assets/{vendor-query-B2UbickB.js.map → vendor-query-RUZdMvN6.js.map} +1 -1
  279. package/dashboard/dist/assets/{vendor-react-BpdAFEQc.js → vendor-react-CdqEC2zv.js} +3 -3
  280. package/dashboard/dist/assets/{vendor-react-BpdAFEQc.js.map → vendor-react-CdqEC2zv.js.map} +1 -1
  281. package/dashboard/dist/assets/{workflows-PtnlRK09.js → workflows-DbPqi1TW.js} +2 -2
  282. package/dashboard/dist/assets/{workflows-PtnlRK09.js.map → workflows-DbPqi1TW.js.map} +1 -1
  283. package/dashboard/dist/assets/{yaml-workflows-DPu3Y8vG.js → yaml-workflows-DozD8hpR.js} +2 -2
  284. package/dashboard/dist/assets/{yaml-workflows-DPu3Y8vG.js.map → yaml-workflows-DozD8hpR.js.map} +1 -1
  285. package/dashboard/dist/index.html +5 -5
  286. package/docs/dashboard.md +9 -2
  287. package/docs/design-principles.md +4 -0
  288. package/docs/hitl/pinned-views.md +3 -3
  289. package/docs/hitl/x-lt-transition.md +105 -0
  290. package/docs/operations.md +1 -1
  291. package/docs/scan-codes.md +243 -0
  292. package/package.json +2 -2
  293. package/dashboard/dist/assets/AvailableEscalationsPage-C1vtTvqP.js +0 -2
  294. package/dashboard/dist/assets/AvailableEscalationsPage-C1vtTvqP.js.map +0 -1
  295. package/dashboard/dist/assets/BotPicker-Dohv8dhR.js +0 -2
  296. package/dashboard/dist/assets/CountdownTimer-BF71ldGF.js +0 -2
  297. package/dashboard/dist/assets/HomePage-HPCd8SjF.js +0 -2
  298. package/dashboard/dist/assets/HomePage-HPCd8SjF.js.map +0 -1
  299. package/dashboard/dist/assets/ListToolbar-BFHVOba6.js +0 -2
  300. package/dashboard/dist/assets/ListToolbar-BFHVOba6.js.map +0 -1
  301. package/dashboard/dist/assets/OperationsPage-flrZ-EJ9.js +0 -2
  302. package/dashboard/dist/assets/OperationsPage-flrZ-EJ9.js.map +0 -1
  303. package/dashboard/dist/assets/OperatorDashboard-Dhs2eo8p.js +0 -2
  304. package/dashboard/dist/assets/OperatorDashboard-Dhs2eo8p.js.map +0 -1
  305. package/dashboard/dist/assets/RoleDetailPage-D70jTLZm.js +0 -8
  306. package/dashboard/dist/assets/RoleDetailPage-D70jTLZm.js.map +0 -1
  307. package/dashboard/dist/assets/RolesPage-CNueMVuJ.js +0 -2
  308. package/dashboard/dist/assets/TimeAgo-CInx-vzY.js +0 -2
  309. package/dashboard/dist/assets/UserName-DggcLkSc.js +0 -2
  310. package/dashboard/dist/assets/capabilities-DZjCMN32.js +0 -2
  311. package/dashboard/dist/assets/escalation-columns-XLEcZRCg.js +0 -2
  312. package/dashboard/dist/assets/escalation-columns-XLEcZRCg.js.map +0 -1
  313. package/dashboard/dist/assets/index-2BwHxjCw.css +0 -1
  314. package/dashboard/dist/assets/index-D2CfSx_x.js +0 -5
  315. package/dashboard/dist/assets/index-D2CfSx_x.js.map +0 -1
  316. package/dashboard/dist/assets/index-Dh3CVChT.js +0 -63
  317. package/dashboard/dist/assets/index-Dh3CVChT.js.map +0 -1
  318. package/dashboard/dist/assets/index-iHV3d7o3.js +0 -6
  319. package/dashboard/dist/assets/index-iHV3d7o3.js.map +0 -1
  320. package/dashboard/dist/assets/role-display-Dvo2lDpU.js +0 -2
  321. package/dashboard/dist/assets/role-display-Dvo2lDpU.js.map +0 -1
  322. package/dashboard/dist/assets/vendor-icons-DN9yGSuM.js.map +0 -1
@@ -0,0 +1,3 @@
1
+ import{b as ve,a as p,j as t}from"./vendor-query-RUZdMvN6.js";import{T as rs,U as ft,d as gt,O as St,V as Ot,J as wt,W as as,X as is,Y as et,b as Lt,m as ce,k as zt,L as we,Z as Pt,_ as ke,R as Xt,h as Ce,g as os,$ as ls,a0 as cs,a1 as ds,u as xs,t as us,j as ps,a2 as ms}from"./index-CfAi1OsI.js";import{u as _e,C as Ee,a as fs}from"./CustomDurationPicker-FPmlA6cE.js";import{M as Ae}from"./Modal-BU7No9NH.js";import{a as hs,u as Gt,L as ct,b as gs,e as js}from"./vendor-react-CdqEC2zv.js";import{P as bs}from"./PageHeader-Ce4GcIYo.js";import{L as ys}from"./ListToolbar-IPXsTb3Q.js";import{i as Te,b as Ns,d as vs,C as Yt,H as ws,g as Qt,c as st,m as ks,r as Bt,e as Oe}from"./CountdownTimer-DPjIkerB.js";import{u as Cs}from"./workflows-DbPqi1TW.js";import{g as _s}from"./useEventHooks-PDbuSJ12.js";import{S as Re}from"./StatusBadge-DkgllZHv.js";import{R as Es}from"./RolePill-CnuBPhPw.js";import{C as ot}from"./CopyableId-4Lqlc5cU.js";import{U as De}from"./UserName-DikzjQHJ.js";import{Y as Ie,ao as As,S as Ts,ap as Os,K as Rs,o as Ds,aa as Me,U as Is,ad as Ms,ae as $s,a3 as Ss,aq as Ls,ar as Ps,as as Ht,at as de,au as Ws,av as xe,aw as ue,ax as Fs,X as qs}from"./vendor-icons-BpZiWH2f.js";import"./constants-BHkpVaqx.js";import"./DataTable-Bir0Xs1p.js";import"./EmptyState-lpUFYfun.js";import"./StickyPagination-hMrnLXde.js";import"./users-G8qwyZKS.js";const Vs={SCHEMA_VALIDATION:"schema_validation"};function Js(e){return typeof e=="object"&&e!==null&&e.code===Vs.SCHEMA_VALIDATION&&Array.isArray(e.violations)}function Hs({escalationId:e}){var h;const s=hs(),a=Gt(),r=ve(),n=(h=s.state)==null?void 0:h[rs],[i,d]=p.useState(!1),[l,c]=p.useState(null),[u,o]=p.useState(!1);if(!n||n.escalationId!==e||u)return null;const x=()=>{o(!0),a(s.pathname,{replace:!0,state:null})},m=async()=>{var b,g,f;d(!0),c(null);try{switch(n.verb){case ft.CANCEL:await gt(`/escalations/${e}/cancel`,{method:"POST"});break;case ft.CLAIM:case ft.CLAIM_SHOW_DETAIL:await gt(`/escalations/${e}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:((b=n.params)==null?void 0:b.durationMinutes)??30})});break;case ft.RELEASE:await gt(`/escalations/${e}/release`,{method:"POST"});break;case ft.RESOLVE:await gt(`/escalations/${e}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:((g=n.params)==null?void 0:g.resolverPayload)??{}})});break;case ft.ESCALATE:await gt(`/escalations/${e}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:(f=n.params)==null?void 0:f.targetRole})});break;default:throw new Error(`Unsupported confirm verb "${n.verb}"`)}r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]}),x()}catch(y){c(y.message)}finally{d(!1)}};return t.jsx(Ae,{open:!0,onClose:x,title:"Confirm scan action",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-text-secondary",children:n.prompt}),l&&t.jsx("p",{className:"text-xs text-status-error",children:l}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:x,disabled:i,className:"btn-secondary text-xs",children:"No, go back"}),t.jsx("button",{onClick:m,disabled:i,className:"btn-primary text-xs",children:i?"Working…":"Yes, continue"})]})]})})}const Et={pending:"rgb(var(--lt-status-queued-graphic))",claimed:"rgb(var(--lt-status-claimed-graphic))",resolved:"rgb(var(--lt-status-success-graphic))",cancelled:"rgb(var(--lt-status-error))"},Wt=5;function pe({pct:e,place:s,label:a,title:r,emphasis:n}){const i=t.jsx("span",{className:"w-px h-1.5 bg-text-quaternary","aria-hidden":!0}),d=t.jsx("span",{className:`whitespace-nowrap leading-none tabular-nums ${n?"text-text-secondary":"text-text-tertiary"}`,children:a});return t.jsx("div",{title:r,className:`absolute ${s==="above"?"bottom-0":"top-0"} flex flex-col items-center gap-0 -translate-x-1/2 cursor-help`,style:{left:`${e}%`},children:s==="above"?t.jsxs(t.Fragment,{children:[d,i]}):t.jsxs(t.Fragment,{children:[i,d]})})}function Us({esc:e,className:s=""}){const a=new Date(e.created_at).getTime(),r=e.claimed_at?new Date(e.claimed_at).getTime():null,n=e.status==="resolved",i=e.status==="cancelled"||e.status==="expired",d=n||i,l=Te(e),c=!!r&&(l||d),u=n&&e.resolved_at?new Date(e.resolved_at).getTime():i?new Date(e.updated_at).getTime():Date.now(),o=Math.max(u-a,1),x=c&&r?Math.max(r-a,0):o,m=c&&r?Math.max(u-r,0):0,h=Math.min(100,Math.max(0,x/o*100)),b=c?Math.max(0,100-h):0,g=n?Et.resolved:i?Et.cancelled:Et.claimed,f=n?"Resolved after":i?"Cancelled after":"In progress",y=St(x),_=St(o),j=n?`Resolved in ${_} total`:i?`Cancelled after ${_}`:`Open ${_} so far`,k=`Lifecycle bar: blue = time waiting to be claimed, ${n?"green":i?"red":"orange"} = ${f.toLowerCase()} the claim.`;return t.jsxs("div",{className:s,title:k,children:[t.jsx("div",{className:"relative h-3 text-2xs font-mono",children:c&&t.jsx(pe,{pct:h,place:"above",label:y,title:`Time to claim: ${y}`})}),t.jsxs("div",{className:"flex w-full rounded-full overflow-hidden",style:{height:Wt,backgroundColor:"rgb(var(--lt-surface-sunken))"},title:k,children:[t.jsx("div",{style:{width:`${h}%`,minWidth:Wt,backgroundColor:Et.pending,opacity:.75},title:`Waiting ${y} — created → claimed`}),c&&b>0&&t.jsx("div",{style:{width:`${b}%`,minWidth:Wt,backgroundColor:g,opacity:.75},title:`${f} ${St(m)}`})]}),t.jsx("div",{className:"relative h-3 text-2xs font-mono",children:t.jsx(pe,{pct:100,place:"below",emphasis:!0,label:_,title:j})})]})}function zs({triage:e,payload:s}){const a=e.confidence??0,r=a>=.8?"text-status-success":a>=.5?"text-status-pending":"text-status-error",n=Xs(e.originalData,s);return t.jsxs("div",{className:"space-y-5",children:[e.diagnosis&&t.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:e.diagnosis}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-text-tertiary",children:[e.tool_calls_made!=null&&t.jsxs("span",{children:[e.tool_calls_made," tool call",e.tool_calls_made!==1?"s":""]}),e.tool_calls_made!=null&&t.jsx("span",{className:"text-text-quaternary",children:"·"}),t.jsxs("span",{className:`font-medium ${r}`,children:[Math.round(a*100),"% confidence"]})]}),e.actions_taken&&e.actions_taken.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.actions_taken.map((i,d)=>t.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-2xs
2
+ text-text-secondary`,children:[t.jsx("svg",{className:"w-3 h-3 text-status-success shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),i]},d))}),e.recommendation&&t.jsx("p",{className:"text-2xs text-text-tertiary italic",children:e.recommendation}),n.length>0&&t.jsx("div",{className:"space-y-4 pt-2",children:n.map(i=>t.jsx(Gs,{diff:i},i.key))})]})}function Xs(e,s){if(!e)return[];const a=[];for(const r of Object.keys(e)){if(r.startsWith("_"))continue;const n=e[r],i=s[r];i!==void 0&&JSON.stringify(n)!==JSON.stringify(i)&&a.push({key:r,label:r.replace(/[_-]/g," "),original:n,corrected:i})}return a}function Gs({diff:e}){const s=me(e.original),a=me(e.corrected);return s!==null&&a!==null?t.jsx("div",{className:"@container",children:t.jsxs("div",{className:"grid grid-cols-1 @form-cols:grid-cols-2 gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),t.jsx("p",{className:"text-sm text-text-tertiary leading-relaxed line-through decoration-text-tertiary/30",children:s})]}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),t.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:a})]})]})}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),t.jsx("pre",{className:"text-xs text-text-tertiary font-mono whitespace-pre-wrap leading-relaxed",children:typeof e.original=="object"?JSON.stringify(e.original,null,2):String(e.original)})]}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),t.jsx("pre",{className:"text-xs text-text-primary font-mono whitespace-pre-wrap leading-relaxed",children:typeof e.corrected=="object"?JSON.stringify(e.corrected,null,2):String(e.corrected)})]})]})}function me(e){return e==null?"null":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function Q(e,s){const a=s==null?void 0:s.title;if(typeof a=="string"&&a.trim().length>0)return a.trim();const r=e.split(/[_-]+/).filter(Boolean);return r.length<=1?e:r.map(n=>Ys(n)?n:n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Ys(e){return e.length>1&&e===e.toUpperCase()&&/[A-Z]/.test(e)}const z={HELP:"help",DETAILS:"details",TRIAGE:"triage",METADATA:"metadata",CONTEXT:"context",RECORD:"record",ERRORS:"errors"},$e="lt:escalation:panel:view";function Qs(e){try{const s=localStorage.getItem($e);if(s&&e.includes(s))return s}catch{}return z.HELP}const Bs=new Set(["form_schema"]);function Zs({metadata:e,role:s}){const a=Object.entries(e??{}).filter(([r])=>!r.startsWith("_")&&!Bs.has(r));return a.length===0?t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No metadata on this escalation."}):t.jsx("dl",{className:"space-y-3.5",children:a.map(([r,n])=>{const i=typeof n=="object"&&n!==null?JSON.stringify(n):String(n),d=ce(r,n,s),l=ce(r,n);return t.jsxs("div",{className:"group relative",children:[t.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:Q(r)}),t.jsxs("dd",{className:"mt-0.5 flex items-center gap-1",children:[t.jsx("span",{className:"text-xs text-text-primary font-mono break-all flex-1",children:i}),t.jsx(ct,{to:d,title:`Filter this queue: ${r} = ${i}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx(Ms,{className:"w-3 h-3"})}),t.jsx(ct,{to:l,title:`Search all queues: ${r} = ${i}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx($s,{className:"w-3 h-3"})})]})]},r)})})}function Ks({esc:e,claimed:s,isTerminal:a,isBuilder:r,traceUrl:n}){return t.jsxs("div",{className:"space-y-5",children:[t.jsxs("dl",{className:"space-y-3.5",children:[t.jsx(et,{label:"Status",children:t.jsx(Re,{status:e.status})}),t.jsx(et,{label:"Assigned to Role",children:t.jsx(Es,{role:e.role,size:"md"})}),t.jsxs(et,{label:"Priority",children:["P",e.priority]}),(s||a)&&e.assigned_to&&t.jsx(et,{label:"Claimed By",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium text-text-primary",children:[t.jsx(Is,{className:"w-3 h-3 shrink-0 text-accent/75"}),t.jsx(De,{userId:e.assigned_to})]})}),t.jsx(et,{label:"Created",children:t.jsx(Lt,{date:e.created_at})}),(s||a)&&e.claimed_at&&t.jsx(et,{label:"Claimed",children:t.jsx(Lt,{date:e.claimed_at})}),s&&!a&&e.assigned_until&&t.jsx(et,{label:"Time Remaining",children:t.jsx(Yt,{until:e.assigned_until})}),e.resolved_at&&t.jsx(et,{label:"Completed",children:t.jsx("span",{className:"text-status-success",children:t.jsx(Lt,{date:e.resolved_at})})})]}),r&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"border-surface-border/60"}),t.jsxs("div",{className:"space-y-3.5",children:[t.jsx(ot,{label:"Escalation ID",value:e.id}),e.task_id&&t.jsx(ot,{label:"Task ID",value:e.task_id,href:`/workflows/tasks/detail/${e.task_id}`}),e.workflow_type&&t.jsx(ot,{label:"Workflow Name",value:e.workflow_type,href:`/workflows/executions?entity=${encodeURIComponent(e.workflow_type)}`}),e.workflow_id&&t.jsx(ot,{label:"Workflow ID",value:e.workflow_id,href:`/workflows/executions/${e.workflow_id}`}),e.task_queue&&t.jsx(ot,{label:"Task Queue",value:e.task_queue,href:`/admin/controlplane?queue=${encodeURIComponent(e.task_queue)}`}),e.origin_id&&e.origin_id!==e.workflow_id&&t.jsx(ot,{label:"Origin",value:e.origin_id,href:`/processes/detail/${e.origin_id}`}),e.trace_id&&t.jsx(ot,{label:"Trace",value:e.trace_id,href:n?n.replace("{traceId}",e.trace_id):void 0,external:!0})]})]})]})}function tn({errors:e,schema:s}){const a=r=>{const n=document.querySelector(`[data-field-key="${r}"]`);n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),n.focus({preventScroll:!0}))};return e.length===0?t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No errors to display."}):t.jsxs("div",{className:"space-y-1",role:"alert","aria-live":"polite",children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-wider text-status-error mb-4",children:[e.length," ",e.length===1?"issue":"issues"," to resolve"]}),t.jsx("div",{className:"space-y-1.5",children:e.map(({field:r,message:n})=>{var i;return t.jsxs("button",{onClick:()=>a(r),className:"w-full text-left flex items-start gap-3 px-3 py-2.5 rounded hover:bg-status-error/5 transition-colors group",children:[t.jsx(Me,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-status-error/60 group-hover:text-status-error transition-colors"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-2xs font-semibold text-text-primary leading-snug",children:Q(r,(i=s==null?void 0:s.properties)==null?void 0:i[r])}),t.jsx("p",{className:"text-2xs text-text-tertiary group-hover:text-text-secondary transition-colors leading-snug mt-0.5",children:n})]})]},r)})}),t.jsx("p",{className:"text-2xs text-text-quaternary mt-4 px-3",children:"Click an issue to scroll to and focus the field."})]})}function en({esc:e,schema:s,envelope:a,payload:r,resolver:n,triage:i,hasAI:d,claimed:l,claimedByMe:c,isTerminal:u,isBuilder:o,traceUrl:x,open:m,noGutter:h,formErrors:b,activePanel:g,onPanelChange:f}){const y=Gt(),_=Object.values(z),[j,k]=p.useState(()=>Qs(_)),T=g??j,$=p.useCallback(E=>{try{localStorage.setItem($e,E)}catch{}k(E),f==null||f(E)},[f]);p.useEffect(()=>{g&&g!==j&&k(g)},[g]);const M=p.useMemo(()=>Ns(s,{escalation:e,metadata:e.metadata??null,envelope:a,payload:r,resolver:n})??vs({isTerminal:u,status:e.status,claimed:l,claimedByMe:c}),[s,e,a,r,n,u,l,c]),C=p.useCallback(E=>{const I=E.target.closest("a"),P=I==null?void 0:I.getAttribute("href");P!=null&&P.startsWith("/")&&(E.preventDefault(),y(P))},[y]),D=[{id:z.HELP,icon:Ie,label:"Instructions",content:t.jsx(Ot,{content:M,onClick:C})},{id:z.DETAILS,icon:As,label:"Details",content:t.jsx(Ks,{esc:e,claimed:l,isTerminal:u,isBuilder:o,traceUrl:x})},...d&&i?[{id:z.TRIAGE,icon:Ts,label:"AI Analysis",content:t.jsx(zs,{triage:i,payload:r??{}})}]:[],{id:z.METADATA,icon:Os,label:"Metadata",content:t.jsx(Zs,{metadata:e.metadata,role:e.role})},{id:z.CONTEXT,icon:Rs,label:"Context",content:t.jsxs("div",{className:"space-y-5",children:[a!=null&&t.jsx(wt,{data:a,label:"Input Envelope"}),r!=null&&t.jsx(wt,{data:r,label:"Escalation Context"}),n!=null&&t.jsx(wt,{data:n,label:"Resolver Payload"}),a==null&&r==null&&n==null&&t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No context on this escalation."})]})},...o?[{id:z.RECORD,icon:Ds,label:"Record",content:t.jsx(wt,{data:e,label:"Escalation Record"})}]:[],...b&&b.length>0?[{id:z.ERRORS,icon:(({className:E})=>t.jsx(Me,{className:`${E??""} text-status-error`})),label:"Errors",content:t.jsx(tn,{errors:b,schema:s})}]:[]];return t.jsx(as,{open:m,width:384,className:"h-full",children:t.jsx("div",{className:`h-full${h?"":" pl-6"}`,children:t.jsxs("div",{className:"h-full flex flex-col bg-surface-hover",children:[t.jsx("div",{className:"shrink-0 pt-1.5 pb-0.5 flex justify-center",children:t.jsx(Us,{esc:e,className:"w-[80%]"})}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(is,{views:D,activeId:T,onViewChange:$,stickyClassName:"h-full min-h-0"})})]})})})}function sn(e,s){if(typeof e!="string"||!s)return[];const a=e.indexOf(".");if(a===-1)return[];const r=s[e.slice(0,a)];if(!r||typeof r!="object")return[];let n=r;for(const i of e.slice(a+1).split("."))if(n=n[i],n===void 0)return[];return Array.isArray(n)?n:[]}function nn(e,s,a){if((s==null?void 0:s["x-lt-widget"])!=="checklist"||s["x-lt-require-all"]!==!0)return;const n=sn(s["x-lt-source"],a).filter(l=>l.required!==!1);if(n.length===0)return;const i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},d=n.filter(l=>!i[l.id]).length;if(d!==0)return`${d} of ${n.length} checks incomplete`}function rn(e,s){const a=s==null?void 0:s.type;if(typeof a=="string"&&!(e==null||e===""))switch(a){case"string":return typeof e=="string"?void 0:"Expected text";case"number":return typeof e=="number"&&Number.isFinite(e)?void 0:"Expected a number";case"integer":return typeof e=="number"&&Number.isInteger(e)?void 0:"Expected a whole number";case"boolean":return typeof e=="boolean"?void 0:"Expected true or false";case"array":return Array.isArray(e)?void 0:"Expected a list";case"object":return typeof e=="object"&&!Array.isArray(e)?void 0:"Expected an object";default:return}}function an(e,s,a){if(!s)return;const r=s.enum;if(Array.isArray(r)&&r.length>0&&e!==void 0&&e!==null&&e!==""&&!r.includes(e))return`Must be one of: ${r.map(n=>String(n)).join(", ")}`;if(typeof e=="string"){const n=e.trim();if(n==="")return;const i=ht(s.minLength,s["x-lt-min-length"],a);if(i!==void 0&&n.length<i)return`Minimum ${i} character${i===1?"":"s"}`;const d=ht(s.maxLength,s["x-lt-max-length"],a);if(d!==void 0&&n.length>d)return`Maximum ${d} characters (${n.length} entered)`;const l=s.pattern;if(l)try{if(!new RegExp(l).test(n))return s["x-lt-pattern-error"]??"Invalid format"}catch{}const c=s.format;if(c==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n))return"Enter a valid email address";if(c==="uri"&&!/^https?:\/\/.+/.test(n))return"Enter a valid URL"}if(typeof e=="number"){const n=ht(s.minimum,s["x-lt-minimum"],a),i=ht(s.exclusiveMinimum,void 0,a),d=ht(s.maximum,s["x-lt-maximum"],a),l=ht(s.exclusiveMaximum,void 0,a);if(n!==void 0&&e<n)return`Minimum value is ${n}`;if(i!==void 0&&e<=i)return`Must be greater than ${i}`;if(d!==void 0&&e>d)return`Maximum value is ${d}`;if(l!==void 0&&e>=l)return`Must be less than ${l}`}}function ht(e,s,a){if(typeof e=="number")return e;if(typeof s=="string"&&a){const r=s.indexOf(".");if(r!==-1){const n=s.slice(0,r),i=s.slice(r+1),d=a[n];if(d&&typeof d=="object"){const l=i.split(".");let c=d;for(const u of l)if(c=c[u],c===void 0)break;if(typeof c=="number")return c;if(typeof c=="string"){const u=Number(c);if(!Number.isNaN(u))return u}}}}}function Se(e,s,a,r,n){if(!r)return;if(a){if(e==null||typeof e=="boolean"&&!e||typeof e=="string"&&e.trim()==="")return"Required";if(typeof e=="object"&&!Array.isArray(e)&&e!==null){const l=Object.values(e);if(l.length===0||l.every(c=>!c))return"Required"}}const i=rn(e,s);if(i)return i;const d=nn(e,s,n);return d||an(e,s,n)}function fe(e){return e!=null&&e!==""&&e!==!1&&e!==0}function on(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function he(e,s){const a=e.indexOf("."),r=a===-1?e:e.slice(0,a);if(!ws.includes(r))return{known:!1,value:void 0};const n=s[r];if(a===-1)return{known:!0,value:n};try{return{known:!0,value:Qt(n,e.slice(a+1))}}catch{return{known:!0,value:void 0}}}function Le(e,s){if(typeof e!="string"||e.length===0||!s)return!0;const a=e.startsWith("!"),r=a?e.slice(1):e,n=r.indexOf("!="),i=r.indexOf("=");if(n!==-1||i!==-1&&i!==n+1){const c=n!==-1&&(i===-1||n<i),u=c?n:i,o=r.slice(0,u).trim(),x=r.slice(u+(c?2:1)).trim(),{known:m,value:h}=he(o,s);if(!m)return!0;const b=on(h)===x,g=c?!b:b;return a?!g:g}const{known:d,value:l}=he(r,s);return d?a?!fe(l):fe(l):!0}function Pe(e,s,a){if(!e)return[];const r=e.properties??{},n=new Set(e.required??[]),i={...a??{},resolver:s},d=[];for(const[l,c]of Object.entries(r)){if(!Le(c["x-lt-showIf"],i))continue;const u=Se(s[l],c,n.has(l),!0,i);u&&d.push({field:l,message:u})}return d}function ln(e,s){if(!e)return{};const a={};for(const[r,n]of Object.entries(e))a[r]=typeof n=="string"?st(n,s):n;return a}function We(e,s,a){const r=ln(e.facets,s),n={role:e.role,status:e.status??"pending",facets:r,limit:e.limit,enabled:!!(e.role||Object.keys(r).length)};return e.assigned==="me"?{...n,assigned_to:a,available:!1,enabled:n.enabled&&!!a}:e.assigned==="any"?n:{...n,available:e.available??!0}}const cn="{{count}} related items are still pending";function dn(e,s){const{user:a}=zt(),r=We((e==null?void 0:e.query)??{},s??{},a==null?void 0:a.userId),{data:n}=we({role:r.role,status:r.status,facets:r.facets,assigned_to:r.assigned_to,available:r.available,limit:1,enabled:!!e&&r.enabled}),i=(n==null?void 0:n.total)??0,d=!!e&&e.mustBeEmpty!==!1&&i>0,l=(e==null?void 0:e.message)??cn,c=d?st(l.replace(/\{\{count\}\}/g,String(i)),s??{}):"";return{blocked:d,count:i,message:c}}function xn(e){const{mode:s,activeView:a,onActiveViewChange:r,onClaim:n,claimPending:i,claimNudge:d,workflowType:l,json:c,onResolve:u,resolvePending:o,resolveError:x,requestTriage:m,triageNotes:h,currentRole:b,escalationTargets:g,onEscalate:f,escalatePending:y,escalateError:_,onRelease:j,releasePending:k,onCancel:T,assignedTo:$,assignedUntil:M,onSubmitAttempt:C,onValidationErrors:D,escalationContext:E}=e,I=_e(),[P,V]=p.useState("30"),[L,H]=p.useState(0),[B,J]=p.useState(""),[w,O]=p.useState(""),v=P==="custom",R=p.useCallback(A=>H(A),[]),S=p.useMemo(()=>{var A;try{const W=(A=JSON.parse(c))==null?void 0:A._form_schema;return W==null?void 0:W["x-lt-submit-guard"]}catch{return}},[c]),Z=dn(S,E),dt=Z.blocked&&!m;if(s==="terminal")return null;const jt=()=>{const A=v?L:parseInt(P);!A||A<=0||n(A)},xt=()=>{if(J(""),m){const nt={_lt:{needsTriage:!0}};h.trim()&&(nt.notes=h.trim()),u(nt);return}let A;try{A=JSON.parse(c)}catch{J("Invalid JSON");return}const W=A._form_schema;if(W){const nt=Pe(W,A,E);if(nt.length>0){C==null||C(),D==null||D(nt);return}}const{_form_schema:bt,...ut}=A;u(ks(ut,W))},X=A=>`text-xs transition-colors ${A?"text-accent font-medium":"text-text-tertiary hover:text-accent"}`;return t.jsxs("div",{className:"shrink-0 h-[80px] bg-surface/95 backdrop-blur-sm border-t border-surface-border -ml-10 pl-10 pr-10 pt-3 pb-5","data-testid":"escalation-action-bar",children:[s==="available"&&t.jsxs("div",{"data-testid":"claim-bar",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[I.map(A=>t.jsx("button",{onClick:()=>{V(A.value),H(0)},className:X(!v&&P===A.value),children:A.label},A.value)),t.jsx("button",{onClick:()=>V("custom"),className:X(v),children:"Other"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:T,className:"text-xs text-text-tertiary hover:text-status-error transition-colors",children:"Cancel escalation"}),t.jsx("div",{className:"flex-1"}),v&&t.jsx(Ee,{onChange:R,compact:!0,autoFocus:!0}),t.jsx("button",{onClick:jt,disabled:i||v&&L<=0,className:`btn-primary text-xs ${d?"animate-[field-shake_0.4s_ease-in-out]":""}`,"data-testid":"claim-button",children:i?"Claiming...":"Claim"},d)]})]}),s==="claimed_by_other"&&t.jsxs("div",{className:"flex items-center gap-4","data-testid":"claimed-other-bar",children:[t.jsxs("p",{className:"text-sm text-text-secondary",children:["Claimed by ",t.jsx("span",{className:"font-medium text-text-primary",children:$?t.jsx(De,{userId:$}):"unknown"})]}),M&&t.jsx(Yt,{until:M})]}),s==="claimed_by_me"&&t.jsxs("div",{"data-testid":"action-bar",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[t.jsx("button",{onClick:()=>r("resolve"),className:X(a==="resolve"),children:l?"Resolve":"Acknowledge"}),g.length>0&&t.jsx("button",{onClick:()=>r("escalate"),className:X(a==="escalate"),children:"Escalate"}),t.jsx("button",{onClick:()=>r("release"),className:`text-xs transition-colors ${a==="release"?"text-status-error font-medium":"text-text-tertiary hover:text-status-error"}`,children:"Release"}),t.jsx("button",{onClick:T,className:"text-xs transition-colors text-text-tertiary hover:text-status-error",children:"Cancel"})]}),a==="resolve"&&t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("div",{className:"flex-1"}),B&&t.jsx("span",{className:"text-xs text-status-error",children:B}),x&&t.jsx("span",{className:"text-xs text-status-error",children:x.message}),dt&&t.jsx("span",{className:"text-xs text-status-pending","data-testid":"submit-guard-message",children:Z.message}),t.jsx("button",{onClick:xt,disabled:o||dt,className:"btn-primary text-xs",children:o?l?"Submitting...":"Acknowledging...":m?"Send to Triage":l?"Submit":"Acknowledge"})]}),a==="escalate"&&t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("span",{className:"text-xs text-text-secondary",children:["From ",t.jsx("span",{className:"font-medium text-text-primary",children:b})," to"]}),t.jsxs("select",{value:w,onChange:A=>O(A.target.value),className:"select text-xs","data-testid":"escalate-select",children:[t.jsx("option",{value:"",children:"Select role..."}),g.map(A=>t.jsx("option",{value:A,children:A},A))]}),t.jsx("div",{className:"flex-1"}),_&&t.jsx("span",{className:"text-xs text-status-error",children:_.message}),t.jsx("button",{onClick:()=>f(w),disabled:!w||y,className:"btn-primary text-xs",children:y?"Escalating...":"Escalate"})]}),a==="release"&&t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-xs text-text-secondary",children:"Release back to pool?"}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>r("resolve"),className:"btn-secondary text-xs",children:"Back"}),t.jsx("button",{onClick:j,disabled:k,className:"btn-primary text-xs bg-status-error hover:bg-status-error/80",children:k?"Releasing...":"Yes, Release"})]})]})]})}function Ft({children:e}){return t.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:e})}function un({payload:e,isTerminal:s,resolverPayload:a,onRetryTriage:r,isRetrying:n}){const i=e.title,d=e.summary,l=e.diagnosis,c=e.tool_calls_made,u=e.result,o=a==null?void 0:a._lt,x=(o==null?void 0:o.triaged)===!0,m=o==null?void 0:o.triageWorkflowId,h=s&&x,[b,g]=p.useState(!1);return h?t.jsxs("div",{className:"rounded-md border border-status-success/30 bg-surface-raised",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-status-success shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:t.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"})}),t.jsx("span",{className:"text-xs font-medium text-status-success",children:"Resolved by AI Triage"})]}),typeof c=="number"&&t.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-success/10 text-status-success",children:[c," tool calls used"]})]}),t.jsxs("div",{className:"px-4 py-4 space-y-4",children:[i&&t.jsx("p",{className:"text-sm font-medium text-text-primary",children:i}),l&&t.jsxs("div",{children:[t.jsx(Ft,{children:"Triage diagnosis"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Pt,{content:l})})]}),t.jsx("div",{className:"flex items-center gap-3",children:m&&t.jsx(ct,{to:`/workflows/executions/${m}`,className:"text-2xs text-accent hover:underline",children:"View triage execution"})})]})]}):t.jsxs("div",{className:"rounded-md border border-status-warning/30 bg-surface-raised",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-status-warning shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm0 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 4zm0 7a.75.75 0 100-1.5.75.75 0 000 1.5z"})}),t.jsx("span",{className:"text-xs font-medium text-status-warning",children:"Tool Rounds Exhausted"})]}),typeof c=="number"&&t.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-warning/10 text-status-warning",children:[c," tool calls used"]})]}),t.jsxs("div",{className:"px-4 py-4 space-y-4",children:[i&&t.jsx("p",{className:"text-sm font-medium text-text-primary",children:i}),d&&t.jsxs("div",{children:[t.jsx(Ft,{children:"What happened"}),t.jsx("div",{className:"text-xs text-text-secondary leading-relaxed",children:t.jsx(Pt,{content:d})})]}),l&&t.jsxs("div",{children:[t.jsx(Ft,{children:"What went wrong"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Pt,{content:l})})]}),u!=null&&t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>g(!b),className:"flex items-center gap-1 text-2xs font-semibold uppercase tracking-widest text-text-tertiary hover:text-text-secondary transition-colors",children:[t.jsx("svg",{className:`w-3 h-3 transition-transform ${b?"rotate-90":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M4.5 2l4 4-4 4"})}),"Partial results"]}),b&&t.jsx("div",{className:"mt-2",children:t.jsx(wt,{data:u,defaultMode:"tree"})})]}),r&&!s&&t.jsx("div",{className:"pt-2",children:t.jsxs("button",{onClick:r,disabled:n,className:"inline-flex items-center gap-2 px-4 py-2 text-xs font-medium bg-accent text-text-inverse rounded-md hover:bg-accent/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 14 14",fill:"currentColor",children:t.jsx("path",{d:"M7 1a6 6 0 100 12A6 6 0 007 1zm2.5 6.5l-3.5 2V5.5l3.5 2z"})}),n?"Sending to triage...":"Retry with AI Triage"]})})]})]})}function ge(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Fe({src:e,escalation:s,schema:a,onResolve:r,onEscalate:n,submitAttempted:i,fill:d}){const l=p.useRef(null),c=p.useRef("");p.useEffect(()=>{try{const o=new URL(e);c.current=o.origin}catch{c.current=""}},[e]);const u=p.useCallback(()=>{const o=l.current;if(!(o!=null&&o.contentWindow)||!c.current)return;const m={type:"lt:init",escalation:{id:s.id,type:s.type,subtype:s.subtype,description:s.description,status:s.status,priority:s.priority,role:s.role,workflow_type:s.workflow_type,envelope:ge(s.envelope),metadata:s.metadata??null,escalation_payload:ge(s.escalation_payload)},schema:a};o.contentWindow.postMessage(m,c.current)},[s,a]);return p.useEffect(()=>{const o=x=>{if(x.origin!==c.current)return;const m=x.data;if(!(!m||typeof m!="object"||typeof m.type!="string"))switch(m.type){case"lt:ready":u();break;case"lt:submit":m.payload&&typeof m.payload=="object"&&r(m.payload);break;case"lt:escalate":typeof m.target=="string"&&m.target&&n(m.target);break;case"lt:resize":{const h=l.current;h&&typeof m.height=="number"&&m.height>0&&(h.style.height=`${Math.min(m.height,2e3)}px`);break}}};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[u,r,n]),p.useEffect(()=>{if(!i)return;const o=l.current;o!=null&&o.contentWindow&&c.current&&o.contentWindow.postMessage({type:"lt:validate"},c.current)},[i]),d?t.jsx("div",{className:"absolute inset-0 overflow-hidden",children:t.jsx("iframe",{ref:l,src:e,sandbox:"allow-scripts allow-same-origin allow-forms allow-pointer-lock allow-downloads",className:"w-full h-full border-0 block",title:"HITL Viewport",onLoad:u})}):t.jsx("div",{className:"rounded-md border border-surface-border overflow-hidden bg-white",children:t.jsx("iframe",{ref:l,src:e,sandbox:"allow-scripts allow-same-origin allow-forms allow-pointer-lock allow-downloads",className:"w-full border-0",style:{minHeight:"600px"},title:"HITL Viewport",onLoad:u})})}function F({children:e,isRequired:s,htmlFor:a}){return t.jsxs("label",{htmlFor:a,className:"block text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[e,s&&t.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})}function G({id:e,children:s}){return t.jsx("p",{id:e,className:"text-2xs text-text-tertiary mt-0.5 leading-snug",children:s})}function lt({error:e,id:s}){return e?t.jsx("p",{id:s,role:"alert",className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:e}):null}function Nt(e){return e?"input text-sm w-full mt-1 border-status-error/50 focus:border-status-error animate-[field-shake_0.4s_ease-in-out]":"input text-sm w-full mt-1"}function pn(e){return e?"select text-sm mt-1 min-w-[min(16rem,100%)] max-w-full border-status-error/50 focus:border-status-error animate-[field-shake_0.4s_ease-in-out]":"select text-sm mt-1 min-w-[min(16rem,100%)] max-w-full"}function mn({fieldKey:e,value:s,onChange:a,schema:r,isRequired:n}){const i=p.useRef(null),d=(r==null?void 0:r.accept)??void 0,l=Q(e,r),c=r==null?void 0:r.description,u=p.useCallback(x=>{var b;const m=(b=x.target.files)==null?void 0:b[0];if(!m)return;const h=new FileReader;h.onload=()=>{typeof h.result=="string"&&a(h.result)},h.readAsDataURL(m)},[a]),o=s.startsWith("data:");return t.jsxs("div",{children:[t.jsx(F,{isRequired:n,children:l}),c&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:c}),t.jsxs("div",{className:"mt-1",children:[t.jsx("input",{ref:i,type:"file",accept:d,onChange:u,className:"hidden"}),t.jsx("button",{type:"button",onClick:()=>{var x;return(x=i.current)==null?void 0:x.click()},className:"btn-secondary text-xs px-3 py-1.5",children:o?"Replace file":"Choose file"}),o&&t.jsx("span",{className:"ml-2 text-xs text-status-success",children:"File attached"})]})]})}function fn({fieldKey:e,value:s,onChange:a,schema:r,isRequired:n}){const i=Q(e,r),d=r==null?void 0:r.description,l=(r==null?void 0:r["x-lt-language"])??"",c=p.useCallback(u=>{if(u.key==="Tab"){u.preventDefault();const o=u.currentTarget,x=o.selectionStart,m=o.selectionEnd,h=s.substring(0,x)+" "+s.substring(m);a(h),requestAnimationFrame(()=>{o.selectionStart=o.selectionEnd=x+2})}},[s,a]);return t.jsxs("div",{children:[t.jsxs(F,{isRequired:n,children:[i,l&&t.jsx("span",{className:"ml-2 text-text-tertiary/60 normal-case font-normal",children:l})]}),d&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:d}),t.jsx("textarea",{value:s,onChange:u=>a(u.target.value),onKeyDown:c,className:"input w-full mt-1 font-mono text-xs leading-relaxed",rows:10,spellCheck:!1})]})}function hn({fieldKey:e,value:s,onChange:a,schema:r,isRequired:n}){const i=p.useRef(null),[d,l]=p.useState(!1),c=Q(e,r),u=r==null?void 0:r.description;p.useEffect(()=>{const g=i.current;if(!g)return;const f=g.getContext("2d");if(f&&(f.lineWidth=2,f.lineCap="round",f.strokeStyle="#1E1535",s&&s.startsWith("data:"))){const y=new Image;y.onload=()=>f.drawImage(y,0,0),y.src=s}},[]);const o=p.useCallback(g=>{const f=i.current,y=f.getBoundingClientRect(),_=y.width>0?f.width/y.width:1,j=y.height>0?f.height/y.height:1;return"touches"in g?{x:(g.touches[0].clientX-y.left)*_,y:(g.touches[0].clientY-y.top)*j}:{x:(g.clientX-y.left)*_,y:(g.clientY-y.top)*j}},[]),x=p.useCallback(g=>{var _;l(!0);const f=(_=i.current)==null?void 0:_.getContext("2d");if(!f)return;const y=o(g);f.beginPath(),f.moveTo(y.x,y.y)},[o]),m=p.useCallback(g=>{var _;if(!d)return;const f=(_=i.current)==null?void 0:_.getContext("2d");if(!f)return;const y=o(g);f.lineTo(y.x,y.y),f.stroke()},[d,o]),h=p.useCallback(()=>{l(!1);const g=i.current;g&&a(g.toDataURL("image/png"))},[a]),b=p.useCallback(()=>{const g=i.current;if(!g)return;const f=g.getContext("2d");f&&(f.clearRect(0,0,g.width,g.height),a(""))},[a]);return t.jsxs("div",{children:[t.jsx(F,{isRequired:n,children:c}),u&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:u}),t.jsx("div",{className:"mt-1 max-w-[25rem] border border-surface-border rounded-md overflow-hidden bg-white",children:t.jsx("canvas",{ref:i,width:400,height:150,className:"w-full cursor-crosshair touch-none",onMouseDown:x,onMouseMove:m,onMouseUp:h,onMouseLeave:h,onTouchStart:x,onTouchMove:m,onTouchEnd:h})}),t.jsx("button",{type:"button",onClick:b,className:"mt-1 text-2xs text-text-tertiary hover:text-accent transition-colors",children:"Clear"})]})}function gn({fieldKey:e,value:s,onChange:a,schema:r,isRequired:n}){const i=Q(e,r),d=r==null?void 0:r.description;return t.jsxs("div",{children:[t.jsx(F,{isRequired:n,children:i}),d&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:d}),t.jsx("textarea",{value:s,onChange:l=>a(l.target.value),className:"input w-full mt-1 text-sm leading-relaxed",rows:8,placeholder:"Supports plain text. Markdown formatting is preserved."})]})}function jn({fieldKey:e,value:s,onChange:a,schema:r,isRequired:n}){const[i,d]=p.useState("write"),l=Q(e,r),c=r==null?void 0:r.description;return(r==null?void 0:r.readOnly)===!0?t.jsx(Ot,{content:s,className:"my-1"}):t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(F,{isRequired:n,children:l}),t.jsx("div",{className:"flex items-center gap-0.5",children:["write","preview"].map(o=>t.jsx("button",{type:"button",onClick:()=>d(o),className:`px-2 py-0.5 text-2xs rounded transition-colors ${i===o?"bg-accent/10 text-accent font-semibold":"text-text-quaternary hover:text-text-secondary"}`,children:o==="write"?"Write":"Preview"},o))})]}),c&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:c}),i==="write"?t.jsx("textarea",{value:s,onChange:o=>a(o.target.value),className:"input w-full mt-1 text-sm font-mono leading-relaxed",rows:10,placeholder:"Write markdown — headings, lists, tables, code blocks, and links all render."}):t.jsx("div",{className:"mt-1 px-3 py-2 border border-surface-border rounded min-h-[120px]",children:s.trim()?t.jsx(Ot,{content:s}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"Nothing to preview."})})]})}const bn=28;function yn({fieldKey:e,value:s,onChange:a,schema:r,escalationContext:n,isRequired:i,submitAttempted:d,error:l}){const c=r==null?void 0:r["x-lt-source"],u=(r==null?void 0:r["x-lt-require-all"])===!0,o=[];if(c&&n){const j=c.indexOf(".");if(j!==-1){const k=c.slice(0,j),T=c.slice(j+1);try{const $=Qt(n[k],T);Array.isArray($)&&o.push(...$)}catch{}}}let x={};try{s&&(x=JSON.parse(s))}catch{}const m=j=>a(JSON.stringify({...x,[j]:!x[j]})),h=Q(e,r),b=r==null?void 0:r.description;if(o.length===0)return t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"No checklist items. Provide checklist_items in the escalation envelope or metadata."}),l&&t.jsx("p",{className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:l})]});const g=r==null?void 0:r["x-lt-variant"],f=g==="chips"||g==="rows"?g:u||o.some(j=>j.label.length>bn)?"rows":"chips",y=o.filter(j=>x[j.id]).length,_=(o.find(j=>!x[j.id]&&j.required!==!1)??o[0]).id;return t.jsxs("div",{role:"group","aria-label":h,"aria-required":i||void 0,"aria-invalid":l?!0:void 0,children:[t.jsx(F,{isRequired:i,children:h}),b&&t.jsx(G,{children:b}),f==="chips"?t.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:o.map(j=>{const k=x[j.id]??!1,T=!k&&!!d&&y===0&&(j.required||i);return t.jsxs("label",{className:`inline-flex items-center gap-1.5 cursor-pointer select-none px-3.5 py-2 text-sm border transition-colors rounded-[var(--lt-radius-field)] ${k?"bg-accent border-accent text-text-inverse":T?"bg-surface-field border-status-error/60 text-status-error":"bg-surface-field border-surface-field-border text-text-secondary hover:border-accent hover:text-text-primary"}`,children:[t.jsx("input",{type:"checkbox",checked:k,onChange:()=>m(j.id),className:"sr-only","data-testid":`checklist-item-${j.id}`,...j.id===_?{"data-field-key":e}:{}}),k&&t.jsx(Ss,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:2.5}),j.label]},j.id)})}):t.jsx("div",{className:"space-y-2.5 mt-2",children:o.map(j=>{const k=x[j.id]??!1,T=!k&&!!d&&(u?j.required!==!1:y===0&&(j.required||i));return t.jsxs("label",{className:`flex items-start gap-3 cursor-pointer group select-none rounded px-2 py-1 -mx-2 transition-colors ${T?"bg-status-error/5":"hover:bg-surface-hover"}`,children:[t.jsx("input",{type:"checkbox",checked:k,onChange:()=>m(j.id),className:`mt-0.5 w-3.5 h-3.5 shrink-0 rounded ${T?"accent-status-error":"accent-accent"}`,"data-testid":`checklist-item-${j.id}`,...j.id===_?{"data-field-key":e}:{}}),t.jsxs("span",{className:`text-sm leading-snug transition-colors ${T?"text-status-error":"text-text-secondary group-hover:text-text-primary"}`,children:[j.label,j.required&&t.jsx("span",{className:`ml-0.5 text-2xs ${T?"text-status-error":"text-text-quaternary"}`,children:"*"})]})]},j.id)})}),t.jsx("p",{className:"text-2xs text-text-quaternary mt-3 tabular-nums",children:f==="chips"?t.jsxs(t.Fragment,{children:[y," selected",i&&y===0&&!!d&&t.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(check at least one)"})]}):t.jsxs(t.Fragment,{children:[y," / ",o.length," confirmed",u?t.jsxs("span",{className:"ml-1 text-text-quaternary/60",children:["(all required",o.some(j=>j.required===!1)?" except optional":"",")"]}):i&&y===0&&!!d&&t.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(at least one required)"})]})}),l&&t.jsx("p",{role:"alert",className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:l})]})}const Nn=/\.(png|jpe?g|gif|webp|avif|bmp|svg)(\?.*)?$/i;function vn(e){var r,n,i,d;const s=e.trim();if(!s)return{kind:"none"};const a=(n=(r=/^data:([^;,]+)[;,]/.exec(s))==null?void 0:r[1])==null?void 0:n.toLowerCase();if(a)return a.startsWith("image/")?{kind:"image",src:s}:{kind:"file",href:s,label:a==="application/pdf"?"PDF":a,isData:!0};if(/^https?:\/\//i.test(s)){if(Nn.test(s))return{kind:"image",src:s};const l=(d=(i=/\.([a-z0-9]{2,5})(\?.*)?$/i.exec(s))==null?void 0:i[1])==null?void 0:d.toUpperCase();return{kind:"file",href:s,label:l??"attachment",isData:!1}}return{kind:"none"}}function je({fieldKey:e,value:s,schema:a}){const[r,n]=p.useState(!1),i=vn(s??""),d=e.replace(/[_-]/g," "),l=a==null?void 0:a.description,c=t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:d}),l&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:l})]});return i.kind==="none"?t.jsxs("div",{children:[c,t.jsx("p",{className:"text-xs text-text-quaternary italic mt-1",children:"No attachment"})]}):i.kind==="image"?t.jsxs("div",{children:[c,t.jsxs("div",{className:"mt-1",children:[t.jsx("button",{type:"button",onClick:()=>n(!0),className:"block rounded-[0.125em] border border-surface-border overflow-hidden hover:border-accent transition-colors",title:"View full size",children:t.jsx("img",{src:i.src,alt:e.replace(/[_-]/g," "),className:"max-h-48 max-w-full object-contain","data-testid":`attachment-image-${e}`})}),r&&t.jsx("div",{className:"fixed inset-0 z-[100] bg-text-primary/60 backdrop-blur-sm flex items-center justify-center p-8 cursor-zoom-out",onClick:()=>n(!1),role:"dialog","aria-modal":"true","aria-label":`${d} — full size`,children:t.jsx("img",{src:i.src,alt:d,className:"max-h-[90vh] max-w-[90vw] object-contain"})})]})]}):t.jsxs("div",{children:[c,t.jsx("div",{className:"mt-1",children:t.jsxs("a",{href:i.href,...i.isData?{download:`${e}.${i.label==="PDF"?"pdf":"bin"}`}:{target:"_blank",rel:"noopener noreferrer"},className:"inline-flex items-center gap-1.5 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`attachment-link-${e}`,children:[t.jsx(Ls,{className:"w-3.5 h-3.5",strokeWidth:1.5}),i.isData?`Download ${i.label}`:`Open ${i.label}`,i.isData?t.jsx(Ps,{className:"w-3 h-3",strokeWidth:1.5}):t.jsx(Ht,{className:"w-3 h-3",strokeWidth:1.5})]})})]})}function wn({fieldKey:e,schema:s,escalationContext:a}){const r=(s==null?void 0:s["x-lt-href"])??"",n=r&&a?st(r,a):r,i=(s==null?void 0:s.title)??(s==null?void 0:s.description)??"Open",d=s==null?void 0:s.description,l=n.startsWith("/"),c=!n.trim();return t.jsxs("div",{"data-field-key":e,children:[t.jsx(F,{children:i}),d&&t.jsx(G,{children:d}),t.jsx("div",{className:"mt-1",children:c?t.jsx("span",{className:"text-xs text-text-quaternary italic",children:"No link configured"}):l?t.jsxs(ct,{to:n,className:"inline-flex items-center gap-1 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`link-widget-${e}`,children:[i,t.jsx(Ht,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}):t.jsxs("a",{href:n,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`link-widget-${e}`,children:[i,t.jsx(Ht,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]})})]})}const be="—";function kn(e,s){if(!e||!s)return"";const a=e.indexOf(".");if(a===-1)return"";const r=e.slice(0,a),n=e.slice(a+1);try{const i=Qt(s[r],n);return typeof i=="string"?i:""}catch{return""}}function Cn(e,s){if(!e||e===be)return be;if(s==="age"){const a=new Date(e);return Number.isNaN(a.getTime())?e:Xt(e)}return e}function _n({fieldKey:e,schema:s,escalationContext:a}){const r=s==null?void 0:s["x-lt-source"],n=(s==null?void 0:s["x-lt-fields"])??[],i=(s==null?void 0:s.title)??"Linked escalation",d=s==null?void 0:s.description,l=kn(r,a),{data:c,isLoading:u,isError:o}=ke(l);return t.jsxs("div",{"data-field-key":e,children:[t.jsx(F,{children:i}),d&&t.jsx(G,{children:d}),t.jsx("div",{className:"mt-1",children:!l||o?t.jsx("p",{className:"text-xs text-text-quaternary italic","data-testid":`escalation-widget-empty-${e}`,children:"No linked record"}):u?t.jsx(An,{}):c?t.jsx(En,{esc:c,fields:n,fieldKey:e}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"No linked record"})})]})}function En({esc:e,fields:s,fieldKey:a}){if(!e)return null;const r=Bt(e);return t.jsxs("div",{className:"border-l-2 border-accent-faint pl-3 py-2 space-y-2","data-testid":`escalation-widget-card-${a}`,children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[e.type,e.subtype&&e.subtype!==e.type?` · ${e.subtype}`:""]}),t.jsx(Re,{status:e.status})]}),e.description&&t.jsx("p",{className:"text-xs text-text-primary leading-snug",children:e.description}),s.length>0&&t.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-0.5",children:s.map(n=>{const i=st(n.value,r),d=Cn(i,n.format);return t.jsxs("div",{className:"contents",children:[t.jsx("dt",{className:"text-2xs text-text-tertiary whitespace-nowrap",children:n.label}),t.jsx("dd",{className:"text-2xs text-text-primary",children:d})]},n.label)})}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("span",{className:"text-2xs text-text-quaternary",children:[e.role," · ",Xt(e.created_at)]}),t.jsx(ct,{to:`/escalations/detail/${e.id}`,className:"text-2xs text-accent hover:text-accent-hover transition-colors",title:"Open escalation detail",children:"Detail"})]})]})}function An(){return t.jsxs("div",{className:"border-l-2 border-accent-faint pl-3 py-2 space-y-2 animate-pulse",children:[t.jsx("div",{className:"h-3 w-32 bg-surface-sunken rounded"}),t.jsx("div",{className:"h-3 w-48 bg-surface-sunken rounded"}),t.jsx("div",{className:"h-3 w-24 bg-surface-sunken rounded"})]})}const Tn=[{label:"Description",value:"{{escalation.description}}"},{label:"Role",value:"{{escalation.role}}"},{label:"Age",value:"{{escalation.created_at}}",format:"age"}],ye="—";function On(e,s){if(!e||e===ye)return ye;if(s==="age"){const a=new Date(e);return Number.isNaN(a.getTime())?e:Xt(e)}return e}function Ut(e,s){return typeof e=="string"?st(e,s):Array.isArray(e)?e.map(a=>Ut(a,s)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([a,r])=>[a,Ut(r,s)])):e}function Rn({fieldKey:e,schema:s,escalationContext:a}){const r=(s==null?void 0:s["x-lt-query"])??{},n=(s==null?void 0:s["x-lt-columns"])??Tn,i=(s==null?void 0:s["x-lt-actions"])??[],d=(s==null?void 0:s.title)??"Related items",l=s==null?void 0:s.description,c=a??{},{user:u}=zt(),o=We(r,c,u==null?void 0:u.userId),{data:x,isLoading:m}=we({role:o.role,status:o.status,facets:o.facets,assigned_to:o.assigned_to,available:o.available,limit:o.limit??5,enabled:o.enabled}),h=(x==null?void 0:x.escalations)??[],b=Ce(),[g,f]=p.useState({}),[y,_]=p.useState(null),j=async(k,T)=>{const $=Bt(k);if(!(T.confirm&&!window.confirm(st(T.confirm,$)))){_(k.id),f(M=>({...M,[k.id]:""}));try{await b.mutateAsync({id:k.id,resolverPayload:Ut(T.resolverPayload,$)})}catch(M){f(C=>({...C,[k.id]:M.message}))}finally{_(null)}}};return t.jsxs("div",{"data-field-key":e,children:[t.jsx(F,{children:d}),l&&t.jsx(G,{children:l}),t.jsx("div",{className:"mt-1","data-testid":`escalation-list-widget-${e}`,children:m?t.jsx(In,{columns:n.length}):t.jsx(Dn,{escalations:h,columns:n,fieldKey:e,actions:i,onAction:j,pendingRow:y,rowErrors:g})})]})}function Dn({escalations:e,columns:s,fieldKey:a,actions:r,onAction:n,pendingRow:i,rowErrors:d}){return e.length===0?t.jsx("p",{className:"text-xs text-text-quaternary italic py-1","data-testid":`escalation-list-empty-${a}`,children:"No items found"}):t.jsxs("table",{className:"w-full text-xs border-collapse","data-testid":`escalation-list-table-${a}`,children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-surface-border",children:[s.map(l=>t.jsx("th",{className:"text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary pb-1 pr-3 last:pr-0",children:l.label},l.label)),r.length>0&&t.jsx("th",{className:"w-px"}),t.jsx("th",{className:"w-4"})]})}),t.jsx("tbody",{children:e.map(l=>{const c=Bt(l),u=d[l.id];return t.jsxs("tr",{className:"border-b border-surface-border/50 last:border-0 hover:bg-surface-sunken/50 transition-colors",children:[s.map(o=>{const x=st(o.value,c),m=On(x,o.format);return t.jsx("td",{className:"py-1 pr-3 last:pr-0 text-text-primary align-top",children:m},o.label)}),r.length>0&&t.jsxs("td",{className:"py-1 pr-2 align-top whitespace-nowrap",children:[r.map(o=>t.jsx("button",{type:"button",onClick:()=>n(l,o),disabled:i===l.id,className:"px-2 py-0.5 text-2xs font-medium text-accent border border-accent/40 rounded hover:bg-accent/10 disabled:opacity-40 disabled:cursor-default transition-colors ml-1 first:ml-0","data-testid":`escalation-list-action-${l.id}`,children:o.label},o.label)),u&&t.jsx("p",{className:"text-2xs text-status-error mt-0.5 whitespace-normal max-w-[16rem]","data-testid":`escalation-list-action-error-${l.id}`,children:u})]}),t.jsx("td",{className:"py-1 align-top",children:t.jsx(ct,{to:`/escalations/detail/${l.id}`,className:"text-accent hover:text-accent-hover transition-colors",title:"Open escalation detail",tabIndex:-1,children:"→"})})]},l.id)})})]})}function In({columns:e}){return t.jsx("div",{className:"space-y-1.5 animate-pulse",children:[0,1,2].map(s=>t.jsx("div",{className:"flex gap-4",children:Array.from({length:e},(a,r)=>t.jsx("div",{className:"h-3 bg-surface-sunken rounded flex-1"},r))},s))})}const qt={"file-upload":mn,"code-editor":fn,signature:hn,"rich-text":gn,markdown:jn,checklist:yn,attachment:je,image:je,link:wn,escalation:_n,"escalation-list":Rn};function qe({fieldKey:e,value:s,onChange:a,onBlur:r,schema:n,isRequired:i,isReadOnly:d,error:l,escalationContext:c,submitAttempted:u}){var M;const o=(M=n==null?void 0:n.properties)==null?void 0:M[e],x=Q(e,o),m=o==null?void 0:o["x-lt-widget"],h=`lt-field-${e}`,b=`${h}-error`,g=`${h}-help`,f=typeof(o==null?void 0:o.description)=="string"&&o.description.length>0?o.description:void 0,j={id:h,"aria-required":i||void 0,"aria-invalid":l?!0:void 0,"aria-describedby":l?b:f!==void 0?g:void 0},k=m==="markdown"&&typeof s=="string",T=(m==="attachment"||m==="image")&&typeof s=="string",$=!!(m&&m in qt);if(d&&!k&&!T&&!$){const C=s===null?"null":typeof s=="object"?JSON.stringify(s,null,2):String(s);return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,children:x}),t.jsx("p",{className:"text-sm text-text-secondary mt-0.5 whitespace-pre-wrap",children:C})]})}if(m&&m in qt){const C=qt[m],D=i||(o==null?void 0:o["x-lt-require-all"])===!0,E={fieldKey:e,schema:o,escalationContext:c,isRequired:D,submitAttempted:u,error:l};if((o==null?void 0:o.type)==="object"){const I=typeof s=="string"?s:typeof s=="object"&&s!==null&&!Array.isArray(s)?JSON.stringify(s):"";return t.jsx(C,{...E,value:I,onChange:P=>{try{a(JSON.parse(P))}catch{a(P)}}})}if(typeof s=="string")return t.jsx(C,{...E,value:s,onChange:I=>a(I)});if(typeof s=="object"&&s!==null&&!Array.isArray(s))return t.jsx(C,{...E,value:JSON.stringify(s),onChange:I=>{try{a(JSON.parse(I))}catch{a(I)}}})}if(typeof s=="boolean")return t.jsxs("div",{children:[t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:s,onChange:C=>{a(C.target.checked),r==null||r()},className:"w-3.5 h-3.5 rounded accent-accent","data-field-key":e,...j}),t.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[x,i&&t.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})]}),f&&t.jsx(G,{id:g,children:f}),t.jsx(lt,{error:l,id:b})]});if(typeof s=="number")return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsx("input",{type:"number",value:s,onChange:C=>a(parseFloat(C.target.value)||0),onBlur:r,step:"any","data-field-key":e,className:`${Nt(!!l)} max-w-48`,...j}),t.jsx(lt,{error:l,id:b})]});if(typeof s=="string"){const C=(o==null?void 0:o.format)==="password",D=o==null?void 0:o.enum;if(D!=null&&D.length){const V=s===""&&!D.includes("");return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsxs("select",{value:s,onChange:L=>a(L.target.value),onBlur:r,"data-field-key":e,className:pn(!!l),...j,children:[V&&t.jsx("option",{value:"",disabled:!0,children:"Choose…"}),D.map(L=>t.jsx("option",{value:L,children:L},L))]}),t.jsx(lt,{error:l,id:b})]})}if(C)return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsx("input",{type:"password",value:s,onChange:V=>a(V.target.value),onBlur:r,"data-field-key":e,className:Nt(!!l),autoComplete:"off",...j}),t.jsx(lt,{error:l,id:b})]});const E=o==null?void 0:o.format,I={date:"date","date-time":"datetime-local",email:"email",uri:"url"},P={date:"max-w-48","date-time":"max-w-64"};if(E&&E in I)return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsx("input",{type:I[E],value:s,onChange:V=>a(V.target.value),onBlur:r,"data-field-key":e,className:`${Nt(!!l)} ${P[E]??""}`,...j}),t.jsx(lt,{error:l,id:b})]});if(E==="textarea"||s.length>80){const V=o==null?void 0:o.maxLength,L=o==null?void 0:o["x-lt-max-length"];let H=V;if(H===void 0&&L&&c){const J=L.indexOf(".");if(J!==-1){const w=L.slice(0,J),O=L.slice(J+1),v=c[w];if(v&&typeof v=="object"){let R=v;for(const S of O.split("."))if(R=R[S],R===void 0)break;if(typeof R=="number")H=R;else if(typeof R=="string"){const S=Number(R);Number.isNaN(S)||(H=S)}}}}const B=H!==void 0&&s.length>H;return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsx("textarea",{value:s,onChange:J=>{a(J.target.value),r==null||r()},onBlur:r,"data-field-key":e,className:`${Nt(!!l)} leading-relaxed`,rows:Math.min(6,Math.max(3,Math.ceil(s.length/60))),...j}),H!==void 0&&t.jsxs("p",{className:`text-2xs mt-0.5 text-right tabular-nums ${B?"text-status-error font-medium":"text-text-quaternary"}`,children:[s.length," / ",H]}),t.jsx(lt,{error:l,id:b})]})}return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsx("input",{type:"text",value:s,onChange:V=>a(V.target.value),onBlur:r,"data-field-key":e,className:Nt(!!l),...j}),t.jsx(lt,{error:l,id:b})]})}if(s===null)return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,children:x}),t.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"null"})]});if(Array.isArray(s))return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,children:x}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:s.map((C,D)=>t.jsx("span",{className:"px-2 py-0.5 text-2xs font-mono bg-surface-sunken rounded text-text-secondary",children:String(C)},D))})]});if(typeof s=="object"){const C=Object.entries(s);return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,children:x}),t.jsx("div",{className:"ml-4 mt-2 pl-4 border-l border-accent-faint space-y-3",children:C.map(([D,E])=>t.jsx(qe,{fieldKey:D,value:E,onChange:I=>a({...s,[D]:I})},D))})]})}return null}function Mn({items:e,columns:s=1}){if(e.length===0)return null;const a=s>=2&&e.length>1?"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr] @dict-pairs:grid-cols-[max-content_1fr_max-content_1fr]":"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr]";return t.jsx("div",{className:"@container",children:t.jsx("dl",{className:`grid ${a} items-baseline gap-x-6 @dict-pairs:gap-x-8 gap-y-1.5`,children:e.map(({key:r,label:n,value:i})=>t.jsxs(p.Fragment,{children:[t.jsx("dt",{className:"text-2xs font-semibold uppercase tracking-wide text-text-secondary mt-2 first:mt-0 @dict-inline:mt-0",children:n}),t.jsx("dd",{className:"text-sm text-text-primary break-words min-w-0","data-field-key":r,children:$n(i)})]},r))})})}function $n(e){return e==null||e===""?"—":typeof e=="boolean"?e?"Yes":"No":typeof e=="object"?JSON.stringify(e):String(e)}const Vt="dictionary",Sn=new Set(["markdown","attachment","image"]);function Ve(e,s){if(!s)return;const a=e==null?void 0:e["x-lt-section-options"],r=a==null?void 0:a[s];return r&&typeof r=="object"?r:void 0}function Ln(e,s,a){var l,c;const r=(l=e==null?void 0:e.properties)==null?void 0:l[a];if((r==null?void 0:r.readOnly)!==!0)return!1;const n=r==null?void 0:r["x-lt-widget"];if(typeof n=="string"&&Sn.has(n))return!1;const i=r==null?void 0:r["x-lt-display"];if(typeof i=="string")return i===Vt;const d=(c=Ve(e,s))==null?void 0:c.display;return typeof d=="string"?d===Vt:(e==null?void 0:e["x-lt-display"])===Vt}function Pn(e,s,a,r){var i;const n=[];for(const d of e){const[l]=d,c=n[n.length-1];if(Ln(s,a,l)){(c==null?void 0:c.kind)==="dictionary"?c.entries.push(d):n.push({kind:"dictionary",entries:[d]});continue}const u=(i=s==null?void 0:s.properties)==null?void 0:i[l],o=u==null?void 0:u["x-lt-column-group"];if(r==="two-column"&&typeof o=="string"&&o.trim()){(c==null?void 0:c.kind)==="column-group"&&c.name===o?c.entries.push(d):n.push({kind:"column-group",name:o,entries:[d]});continue}n.push({kind:"field",entry:d})}return n}function Wn({name:e,entries:s,formSchema:a,layout:r,renderField:n}){const i=Pn(s,a,e,r),d=Ve(a,e),l=(d==null?void 0:d.columns)??(r==="two-column"?2:1),c=o=>o.map(([x,m])=>{var h;return{key:x,label:Q(x,(h=a==null?void 0:a.properties)==null?void 0:h[x]),value:m}}),u=()=>i.map((o,x)=>o.kind==="dictionary"?t.jsx("div",{className:r==="two-column"?"col-span-full":"",children:t.jsx(Mn,{items:c(o.entries),columns:l})},`dict-${x}`):o.kind==="column-group"?t.jsx("div",{className:"@container",children:t.jsx("div",{className:"grid grid-cols-1 @grp-cols:grid-cols-2 gap-x-4 gap-y-5",children:o.entries.map(m=>n(m))})},`group-${o.name}-${x}`):n(o.entry));return t.jsxs("div",{className:e?"border border-surface-border/60 bg-surface-sunken rounded-[0.25em] p-4 animate-[section-enter_0.25s_ease-out]":"",children:[e&&t.jsx("p",{className:"mb-4 text-[1.40625rem] font-semibold tracking-wider text-heading [font-variant-caps:small-caps]",children:e}),r==="two-column"?t.jsx("div",{className:"@container",children:t.jsx("div",{className:"grid grid-cols-1 @form-cols:grid-cols-2 gap-x-col-gap gap-y-5",children:u()})}):t.jsx("div",{className:"space-y-5",children:u()})]})}function Je({value:e,onChange:s,disabled:a,submitAttempted:r,escalationContext:n,onOpenHelp:i,onDisabledClick:d}){var B,J;const[l,c]=p.useState({}),[u,o]=p.useState({}),[x,m]=p.useState(null),[h,b]=p.useState(!1),[g,f]=p.useState(new Set);p.useEffect(()=>{try{const w=JSON.parse(e);if(typeof w=="object"&&w!==null&&!Array.isArray(w)){const O={},v={};for(const[R,S]of Object.entries(w))R.startsWith("_")?v[R]=S:O[R]=S;c(O),o(v),m(v._form_schema&&typeof v._form_schema=="object"?v._form_schema:null),b(!1)}}catch{b(!0)}},[e]);const y=p.useCallback(w=>{c(w),s(JSON.stringify({...w,...u},null,2))},[u,s]),_=p.useCallback((w,O)=>{y({...l,[w]:O})},[l,y]),j=p.useCallback(w=>{f(O=>{if(O.has(w))return O;const v=new Set(O);return v.add(w),v})},[]);if(h)return t.jsx("p",{className:"text-xs text-status-error",children:"Unable to parse resolver data as form. Use the JSON editor below."});const k=Object.entries(l);if(k.length===0)return t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No resolver fields defined."});const T=x==null?void 0:x["x-lt-order"],$=T?[...k].sort((w,O)=>{const v=T.indexOf(w[0]),R=T.indexOf(O[0]);return(v===-1?1/0:v)-(R===-1?1/0:R)}):k,M={...n??{},resolver:l},C=$.filter(([w,O])=>{var R;const v=(R=x==null?void 0:x.properties)==null?void 0:R[w];return!(!Le(v==null?void 0:v["x-lt-showIf"],M)||(v==null?void 0:v["x-lt-hide-if-empty"])===!0&&(O==null||O===""||O===!1||O===0))}),D=new Set((x==null?void 0:x.required)??[]),E=x==null?void 0:x["x-lt-layout"],I=x==null?void 0:x.title,P=x==null?void 0:x.description,V=typeof(x==null?void 0:x["x-lt-help"])=="string"||typeof(x==null?void 0:x["x-lt-context"])=="string",L=[];for(const w of C){const[O]=w,v=(B=x==null?void 0:x.properties)==null?void 0:B[O],R=((J=v==null?void 0:v["x-lt-section"])==null?void 0:J.trim())||null,S=L[L.length-1];!S||S.name!==R?L.push({name:R,entries:[w]}):S.entries.push(w)}const H=([w,O])=>{var xt;const v=(xt=x==null?void 0:x.properties)==null?void 0:xt[w],R=(v==null?void 0:v.readOnly)===!0,S=(v==null?void 0:v["x-lt-span"])??1,Z=D.has(w),dt=g.has(w)||!!r,jt=Se(O,v,Z,dt,M);return t.jsx("div",{className:`animate-[field-enter_0.2s_ease-out] ${E==="two-column"&&S>=2?"col-span-full":""}`,children:t.jsx(qe,{fieldKey:w,value:O,onChange:X=>_(w,X),onBlur:()=>j(w),schema:x,isRequired:Z,isReadOnly:R,error:jt,escalationContext:M,submitAttempted:!!r})},w)};return t.jsx("div",{className:"pb-8 max-w-form",onClick:a?d:void 0,children:t.jsxs("div",{className:a?"pointer-events-none":void 0,inert:a||void 0,"aria-disabled":a||void 0,children:[I&&t.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.jsx("h3",{className:"heading-3",children:I}),V&&i&&t.jsx("button",{type:"button",onClick:i,title:"Open instructions","aria-label":"Open instructions",className:"p-1 rounded-md text-text-tertiary hover:text-accent hover:bg-surface-hover transition-colors",children:t.jsx(Ie,{className:"w-4 h-4",strokeWidth:1.5})})]}),P&&t.jsx("p",{className:"text-sm text-text-secondary leading-relaxed mb-6",children:P}),t.jsx("div",{className:"space-y-8",children:L.map((w,O)=>t.jsx(Wn,{name:w.name,entries:w.entries,formSchema:x,layout:E,renderField:H},w.name??`__s${O}`))})]})})}function Fn({json:e,onJsonChange:s,requestTriage:a,onRequestTriageChange:r,triageNotes:n,onTriageNotesChange:i,disabled:d=!1,submitAttempted:l=!1,showTriage:c=!1,escalationContext:u,onOpenHelp:o,onDisabledClick:x}){return t.jsxs(t.Fragment,{children:[c&&t.jsx("div",{className:"flex items-center justify-between mb-3",children:a?t.jsxs("button",{onClick:()=>r(!1),className:"group flex items-center gap-2 text-left","data-testid":"triage-cancel",children:[t.jsx("span",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent/10 text-accent shrink-0",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),t.jsxs("span",{className:"text-xs text-text-secondary group-hover:text-text-primary transition-colors",children:["AI Triage active."," ",t.jsx("span",{className:"text-accent group-hover:underline",children:"Cancel"})]})]}):t.jsxs("button",{onClick:()=>r(!0),className:"group flex items-center gap-2.5 text-left my-4","data-testid":"triage-callout",children:[t.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-accent/10 text-accent shrink-0 animate-[triage-glow_6s_ease-in-out_infinite]",children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.674M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),t.jsxs("span",{className:"text-sm text-text-secondary group-hover:text-text-primary transition-colors",children:["This form doesn't capture the issue?"," ",t.jsx("span",{className:"text-accent group-hover:underline",children:"Request AI Triage"})]})]})}),t.jsxs("div",{className:"relative min-h-[200px]",children:[t.jsx("div",{className:a?"pointer-events-none select-none":"",children:t.jsx(Je,{value:e,onChange:s,disabled:d,submitAttempted:l,escalationContext:u,onOpenHelp:o,onDisabledClick:x})}),a&&t.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface/90 backdrop-blur-[2px] rounded-md border border-accent/20 p-5","data-testid":"triage-overlay",children:[t.jsx("p",{className:"text-xs text-text-secondary mb-3 leading-relaxed",children:"The resolution form will not be submitted. Describe the issue so AI triage can diagnose and fix it using available tools. The corrected result will come back as a new escalation for your review."}),t.jsx("textarea",{value:n,onChange:m=>i(m.target.value),placeholder:"e.g. Content is in Spanish — needs translation to English before review...",className:"input text-xs w-full flex-1 min-h-[80px] resize-none",autoFocus:!0,"data-testid":"triage-notes"})]})]})]})}function He(e,s){if(!e.includes("{"))return e;try{const a=n=>{if(!n)return{};try{return JSON.parse(n)}catch{return{}}},r={...s.metadata??{},...a(s.envelope),...a(s.escalation_payload)};return e.replace(/\{([^}]+)\}/g,(n,i)=>Object.prototype.hasOwnProperty.call(r,i)?String(r[i]):`{${i}}`)}catch{return e}}function Ne(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Tt(e){return{escalation:e,metadata:e.metadata??null,envelope:Ne(e.envelope),payload:Ne(e.escalation_payload),resolver:null}}function qn({isRoundsExhausted:e,payloadObj:s,isTerminal:a,resolverPayload:r,onRetryTriage:n,isRetrying:i}){return t.jsxs(t.Fragment,{children:[e&&s&&t.jsx("div",{className:"mt-8",children:t.jsx(un,{payload:s,isTerminal:a,resolverPayload:r,onRetryTriage:n,isRetrying:i})}),(s==null?void 0:s.category)==="missing_credential"&&t.jsxs("div",{className:"mt-8 bg-status-warning/10 border border-status-warning/30 rounded-md px-5 py-4 flex items-start gap-3",children:[t.jsx(de,{size:20,className:"text-status-warning mt-0.5 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-text-primary mb-1",children:"Missing Credential"}),t.jsxs("p",{className:"text-xs text-text-secondary mb-3",children:["This workflow requires a ",t.jsx("span",{className:"font-medium capitalize",children:String(s.provider)})," credential to continue. Register one and then resolve this escalation to retry."]}),t.jsxs(ct,{to:"/credentials",className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[t.jsx(de,{size:12}),"Go to Credentials"]})]})]})]})}function Vn({esc:e,resolverPayload:s,isTerminal:a,claimedByMe:r,activeView:n,metadataFormSchema:i,effectiveSchema:d,json:l,onJsonChange:c,requestTriage:u,onRequestTriageChange:o,triageNotes:x,onTriageNotesChange:m,onResolve:h,onEscalate:b,onClaim:g,submitAttempted:f,isCertified:y,hasAI:_,onOpenHelp:j,onDisabledClick:k}){const T=d,$=Tt(e);if(a){if(s==null)return null;const E=typeof s=="object"&&s!==null?s:{},I=d??i,P=I!=null&&I.properties?{...Oe(E,I),_form_schema:I}:E;return t.jsx("div",{className:"mt-3",children:t.jsx(Je,{value:JSON.stringify(P,null,2),onChange:()=>{},disabled:!0,escalationContext:$})})}if(n!=="resolve"||!(e.workflow_type||d))return null;const M=T==null?void 0:T["x-lt-viewport"],C=(M==null?void 0:M.type)==="iframe"&&!!M.src&&h&&b;if(C&&!r)return t.jsxs("button",{onClick:()=>g==null?void 0:g(),disabled:!g,className:"flex flex-col items-center justify-center min-h-[55vh] w-full gap-3 text-center group disabled:opacity-50 disabled:cursor-default",children:[t.jsx(Ws,{className:"w-10 h-10 text-text-tertiary group-hover:text-accent transition-colors",strokeWidth:1}),t.jsx("p",{className:"text-base font-medium text-text-primary group-hover:text-accent transition-colors",children:"Claim to launch the editor"})]});const D=C?He(M.src,e):"";return t.jsx("div",{className:"mt-3",children:C?t.jsx(Fe,{src:D,escalation:e,schema:T,onResolve:h,onEscalate:b,submitAttempted:f}):t.jsx(Fn,{json:l,onJsonChange:c,requestTriage:u,onRequestTriageChange:o,triageNotes:x,onTriageNotesChange:m,disabled:!r,submitAttempted:f,showTriage:!!y&&!!_,escalationContext:$,onOpenHelp:j,onDisabledClick:k})})}function Jn({open:e,assignedUntil:s,onClose:a,onExtend:r,isPending:n}){const i=_e(),[d,l]=p.useState("30"),[c,u]=p.useState(0),o=d==="custom",x=o?c:parseInt(d),m=p.useCallback(h=>u(h),[]);return t.jsx(Ae,{open:e,onClose:a,title:"Claim Expiring",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-text-secondary",children:["Your claim on this escalation expires in"," ",t.jsx(Yt,{until:s}),". When it lapses, the form locks and the item returns to the queue — your edits are kept as a draft. Extend to keep working."]}),t.jsxs("select",{value:d,onChange:h=>{l(h.target.value),u(0)},className:"select w-full text-sm","aria-label":"Extension duration",children:[i.map(h=>t.jsx("option",{value:h.value,children:h.label},h.value)),t.jsx("option",{value:"custom",children:"Other..."})]}),o&&t.jsx(Ee,{onChange:m,autoFocus:!0}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:a,className:"btn-secondary text-xs",children:"Dismiss"}),t.jsx("button",{onClick:()=>r(x),className:"btn-primary text-xs",disabled:n||!x||x<=0,children:n?"Extending...":"Extend Claim"})]})]})})}const Hn=9e4;function Un(e,s=Hn){const[,a]=p.useState(0);if(p.useEffect(()=>{if(!e)return;const n=new Date(e).getTime()-Date.now();if(n<=0)return;const i=()=>a(c=>c+1),d=[],l=n-s;return l>0&&d.push(window.setTimeout(i,l)),d.push(window.setTimeout(i,n)),()=>d.forEach(c=>window.clearTimeout(c))},[e,s]),!e)return{expired:!1,expiringSoon:!1,msRemaining:0};const r=Math.max(0,new Date(e).getTime()-Date.now());return{expired:r<=0,expiringSoon:r>0&&r<=s,msRemaining:r}}const zn="lt:escalation:draft:";function Zt(e){return`${zn}${e}`}function Xn(e){try{return localStorage.getItem(Zt(e))}catch{return null}}function Gn(e,s){try{localStorage.setItem(Zt(e),s)}catch{}}function Jt(e){try{localStorage.removeItem(Zt(e))}catch{}}const Yn="x-lt-transition",Qn="x-lt-transition-message",Bn="x-lt-transition-max-wait-seconds",Zn="x-lt-transition-done",Kn="Submitted. Preparing your next step…",tr=30,er=5,sr=300;function nr(e){const s=typeof e=="number"?e:Number(e);return!Number.isFinite(s)||s<=0?tr:Math.min(sr,Math.max(er,Math.round(s)))}function rr(e){if(!e||!e[Yn])return null;const s=e[Qn];return{message:typeof s=="string"&&s.trim().length>0?s:Kn,maxWaitSeconds:nr(e[Bn])}}function ar(e){const s=e==null?void 0:e[Zn];return typeof s=="string"&&s.trim().length>0?s:null}function ir({open:e,message:s}){return e?gs.createPortal(t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center px-4",children:[t.jsx("div",{className:"absolute inset-0 bg-text-primary/40 backdrop-blur-sm"}),t.jsxs("div",{role:"status","aria-live":"polite",className:"relative w-full max-w-sm bg-surface-raised border border-surface-border rounded-lg shadow-xl px-6 py-7 text-center",children:[t.jsx("div",{className:"flex justify-center mb-4","aria-hidden":"true",children:t.jsx("span",{className:"inline-block w-7 h-7 rounded-full border-2 border-surface-border border-t-accent animate-spin"})}),t.jsx("div",{className:"text-sm text-text-secondary [&_p]:m-0 [&_p+p]:mt-2",children:t.jsx(Ot,{content:s})})]})]}),document.body):null}const Ue="lt:escalation:panel:open";function or(){try{const e=localStorage.getItem(Ue);return e===null?!0:e==="true"}catch{return!0}}function At(e){try{localStorage.setItem(Ue,String(e))}catch{}}function vt(e){if(!e)return null;try{return JSON.parse(e)}catch{return e}}function Or(){const{id:e}=js();return t.jsx(lr,{id:e},e)}function lr({id:e}){var se,ne,re,ae;const{user:s}=zt(),a=Gt(),r=ve(),{data:n,isLoading:i,refetch:d,isFetching:l}=ke(e);_s(e);const c=os(),u=Ce(),o=ls(),x=cs(),[m,h]=p.useState(!1),{data:b}=ds((n==null?void 0:n.role)??""),{data:g}=Cs(),{data:f}=xs(),{isBuilder:y}=us(),_=g==null?void 0:g.find(N=>N.workflow_type===(n==null?void 0:n.workflow_type)),j=((se=f==null?void 0:f.telemetry)==null?void 0:se.traceUrl)??null,[k,T]=p.useState("resolve"),[$,M]=p.useState("{}"),[C,D]=p.useState(or),[E,I]=p.useState(!1),[P,V]=p.useState(""),[L,H]=p.useState(!1),[B,J]=p.useState([]),[w,O]=p.useState(0),[v,R]=p.useState(void 0),[S,Z]=p.useState(null),dt=Un(n==null?void 0:n.assigned_until),[jt,xt]=p.useState(null);p.useEffect(()=>{if(!(!L||!n))try{const N=JSON.parse($),q=N._form_schema;if(!q){J([]);return}J(Pe(q,N,Tt(n)))}catch{}},[$,L,n]);const X=((ne=n==null?void 0:n.metadata)==null?void 0:ne.form_schema)??null,A=(n==null?void 0:n.form_schema)??(_==null?void 0:_.resolver_schema)??null,W=X??A,bt=p.useRef(!1),ut=p.useRef(null);p.useEffect(()=>{if(bt.current)return;const N=X??(A!=null&&A.properties?A:null);if(N!=null&&N.properties){bt.current=!0;const q=vt(n==null?void 0:n.envelope),U=q==null?void 0:q.formDefaults,Y={...(n==null?void 0:n.metadata)??{},...typeof U=="object"&&U!==null?U:{}},it=Oe(Y,N),tt={_form_schema:N};for(const[oe,ss]of Object.entries(N.properties)){const le=ss,ns=le.type==="object"?{}:"";tt[oe]=it[oe]??le.default??ns}ut.current=JSON.stringify(tt,null,2);const ie=!((n==null?void 0:n.status)==="resolved"||(n==null?void 0:n.status)==="cancelled")&&(n!=null&&n.id)?Xn(n.id):null,_t=ie?vt(ie):null;_t&&typeof _t=="object"&&!Array.isArray(_t)?M(JSON.stringify({..._t,_form_schema:N},null,2)):M(ut.current)}else W&&(bt.current=!0,M(JSON.stringify(W,null,2)))},[W,X,A,n==null?void 0:n.envelope,n==null?void 0:n.metadata,n==null?void 0:n.id,n==null?void 0:n.status]),p.useEffect(()=>{if(!bt.current||ut.current===null||!(n!=null&&n.id)||n.status!=="pending")return;const N=n.id,q=window.setTimeout(()=>{$===ut.current?Jt(N):Gn(N,$)},400);return()=>window.clearTimeout(q)},[$,n==null?void 0:n.id,n==null?void 0:n.status]),p.useEffect(()=>{if(!S)return;const N=window.setTimeout(async()=>{var U;try{const Y=new URLSearchParams({parent_id:e,assigned_to:(s==null?void 0:s.userId)??"",status:"pending",limit:"1"}),it=await gt(`/escalations?${Y}`),tt=(U=it==null?void 0:it.escalations)==null?void 0:U[0];if(tt!=null&&tt.id&&tt.parent_id===e){Z(null),a(`/escalations/detail/${tt.id}`);return}}catch{}Z(null),r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]});const q=S.doneDest;q?q.startsWith("/")?a(q):window.location.assign(q):a(-1)},S.maxWaitSeconds*1e3);return()=>window.clearTimeout(N)},[S,e,s==null?void 0:s.userId,a,r]);const nt=(n==null?void 0:n.subtype)==="rounds_exhausted";if(i)return t.jsxs("div",{className:"animate-pulse space-y-8",children:[t.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),t.jsx("div",{className:"h-32 bg-surface-sunken rounded w-full"})]});if(!n)return t.jsx("p",{className:"text-sm text-text-secondary",children:"Escalation not found."});const Rt=Te(n),rt=Rt&&n.assigned_to===(s==null?void 0:s.userId),ze=Rt&&!rt,pt=n.status==="resolved"||n.status==="cancelled",at=W==null?void 0:W["x-lt-viewport"],Dt=(at==null?void 0:at.type)==="iframe"&&!!(at!=null&&at.src)&&rt&&!pt,kt=vt(n.escalation_payload),mt=vt(n.resolver_payload),Ct=vt(n.envelope),Xe=!!((re=Ct==null?void 0:Ct.metadata)!=null&&re.certified),Kt=ps(),te=Kt!==null?Kt:!!((ae=f==null?void 0:f.ai)!=null&&ae.enabled),K=typeof kt=="object"&&kt!==null&&!Array.isArray(kt)?kt:null,Ge=K==null?void 0:K._triage,Ye=typeof mt=="object"&&mt!==null&&!Array.isArray(mt)?mt:null,Qe=pt?"terminal":rt?"claimed_by_me":ze?"claimed_by_other":"available",It=N=>{c.mutate({id:e,durationMinutes:N})},yt=()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]}),a(-1)},Be=()=>{const N=ar(W);return N&&st(N,Tt(n))||null},Ze=N=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]}),N.startsWith("/")?a(N):window.location.assign(N)},Mt=async N=>{try{await u.mutateAsync({id:e,resolverPayload:N})}catch(Y){if(Y instanceof ms&&Js(Y.body)){H(!0),J(Y.body.violations),R(z.ERRORS);return}throw Y}Jt(e);const q=rr(W),U=Be();if(q){Z({...q,doneDest:U});return}if(U){Ze(U);return}yt()},$t=async N=>{N&&(await o.mutateAsync({id:e,targetRole:N}),yt())},Ke=async()=>{rt||await c.mutateAsync({id:e,durationMinutes:30});const N=(K==null?void 0:K.diagnosis)||n.description||"";await u.mutateAsync({id:e,resolverPayload:{_lt:{needsTriage:!0},notes:N}}),yt()},ee=async()=>{await c.mutateAsync({id:e,durationMinutes:0}),yt()},ts=async()=>{await x.mutateAsync(e),Jt(e),h(!1),yt()},es=t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{onRefresh:()=>d(),isFetching:l,apiPath:`/escalations/${n.id}`,standalone:!0}),t.jsx("button",{onClick:()=>D(N=>(At(!N),!N)),className:"ml-2 text-text-tertiary hover:text-accent transition-colors",title:C?"Hide side panel":"Show side panel",children:C?t.jsx(xe,{className:"w-5 h-5",strokeWidth:1.5}):t.jsx(ue,{className:"w-5 h-5",strokeWidth:1.5})})]});return t.jsxs("div",{className:"flex-1 min-h-0 min-w-0 flex items-stretch -mt-8 -mr-page-x -mb-16",children:[t.jsxs("div",{className:"flex-1 min-w-0 flex flex-col min-h-0",children:[Dt?t.jsxs("div",{className:"relative flex-1 min-h-0 -ml-page-x",children:[t.jsx("div",{className:"absolute top-3 right-3 z-50 flex items-center gap-0.5 bg-surface/90 backdrop-blur-sm rounded-lg px-1.5 py-1 shadow-sm border border-surface-border/40",children:[{onClick:ee,disabled:c.isPending,label:"Release",hoverClass:"hover:text-accent",icon:t.jsx(Fs,{className:"w-4 h-4",strokeWidth:1.5})},{onClick:()=>h(!0),disabled:!1,label:"Cancel",hoverClass:"hover:text-status-error",icon:t.jsx(qs,{className:"w-4 h-4",strokeWidth:1.5})},{onClick:()=>D(N=>(At(!N),!N)),disabled:!1,label:C?"Hide panel":"Show panel",hoverClass:"hover:text-accent",icon:C?t.jsx(xe,{className:"w-4 h-4",strokeWidth:1.5}):t.jsx(ue,{className:"w-4 h-4",strokeWidth:1.5})}].map(({onClick:N,disabled:q,label:U,hoverClass:Y,icon:it})=>t.jsxs("div",{className:"relative group/tip",children:[t.jsx("button",{onClick:N,disabled:q,className:`text-text-tertiary ${Y} transition-colors disabled:opacity-40 disabled:cursor-default p-1.5 rounded-md`,children:it}),t.jsx("span",{className:"pointer-events-none absolute top-full left-1/2 -translate-x-1/2 mt-1.5 px-2 py-0.5 rounded text-2xs bg-surface-sunken text-text-primary whitespace-nowrap opacity-0 group-hover/tip:opacity-100 transition-opacity",children:U})]},U))}),t.jsx(Fe,{src:He(at.src,n),escalation:n,schema:W,onResolve:Mt,onEscalate:$t,submitAttempted:L,fill:!0})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"shrink-0 pt-8 pr-page-x",children:t.jsx(bs,{title:n.description||"Escalation",actions:es})}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto pr-page-x",children:[t.jsx(qn,{isRoundsExhausted:nt,payloadObj:K,isTerminal:pt,resolverPayload:mt,onRetryTriage:Ke,isRetrying:c.isPending||u.isPending}),t.jsx(Vn,{esc:n,resolverPayload:mt,isTerminal:pt,claimedByMe:rt,activeView:k,metadataFormSchema:X,effectiveSchema:W,json:$,onJsonChange:M,requestTriage:E,onRequestTriageChange:I,triageNotes:P,onTriageNotesChange:V,onResolve:Mt,onEscalate:$t,onClaim:()=>It(30),submitAttempted:L,isCertified:Xe,hasAI:te,onOpenHelp:()=>{D(!0),At(!0),R(z.HELP)},onDisabledClick:()=>O(N=>N+1)}),t.jsx("div",{className:"h-10"})]})]}),!Dt&&t.jsx(xn,{escalationContext:Tt(n),mode:Qe,activeView:k,onActiveViewChange:T,onClaim:It,claimPending:c.isPending,claimNudge:w,workflowType:n.workflow_type,json:$,onResolve:Mt,resolvePending:u.isPending||u.isSuccess,resolveError:u.error,requestTriage:E,triageNotes:P,currentRole:n.role,escalationTargets:((b==null?void 0:b.targets)??[]).filter(N=>N!==n.role),onEscalate:$t,escalatePending:o.isPending,escalateError:o.error,onRelease:ee,releasePending:c.isPending,onCancel:()=>h(!0),assignedTo:n.assigned_to,assignedUntil:n.assigned_until,onSubmitAttempt:()=>H(!0),onValidationErrors:N=>{J(N),D(!0),At(!0),R(z.ERRORS)}})]}),t.jsx(en,{esc:n,schema:W,envelope:Ct,payload:K,resolver:Ye,triage:Ge??null,hasAI:te,claimed:Rt,claimedByMe:rt,isTerminal:pt,isBuilder:y,traceUrl:j,open:C,noGutter:Dt,formErrors:B,activePanel:v,onPanelChange:R}),t.jsx(fs,{open:m,onClose:()=>h(!1),onConfirm:ts,isPending:x.isPending,error:x.error}),t.jsx(Hs,{escalationId:e}),t.jsx(ir,{open:!!S,message:(S==null?void 0:S.message)??""}),rt&&!pt&&n.assigned_until&&t.jsx(Jn,{open:dt.expiringSoon&&n.assigned_until!==jt,assignedUntil:n.assigned_until,onClose:()=>xt(n.assigned_until??null),onExtend:It,isPending:c.isPending})]})}export{Or as EscalationDetailPage};
3
+ //# sourceMappingURL=index-mKcQGi2B.js.map