@hotmeshio/long-tail 0.16.2 → 0.16.4

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 (200) hide show
  1. package/build/api/exports.d.ts +15 -0
  2. package/build/api/exports.js +35 -0
  3. package/build/bin/ltc.js +4 -0
  4. package/build/lib/cli/commands/workflows.d.ts +3 -0
  5. package/build/lib/cli/commands/workflows.js +22 -0
  6. package/build/routes/exports.js +11 -0
  7. package/build/sdk/index.d.ts +1 -0
  8. package/build/sdk/index.js +1 -0
  9. package/build/services/export/index.d.ts +19 -0
  10. package/build/services/export/index.js +53 -33
  11. package/build/shared/form-validation/field-validator.d.ts +8 -6
  12. package/build/shared/form-validation/field-validator.js +23 -15
  13. package/build/shared/form-validation/x-lt-options.js +35 -21
  14. package/build/system/mcp-servers/admin/exports.js +15 -0
  15. package/build/system/mcp-servers/admin/schemas.d.ts +7 -0
  16. package/build/system/mcp-servers/admin/schemas.js +5 -2
  17. package/build/system/seed/tool-manifests-admin.js +1 -0
  18. package/dashboard/dist/assets/{AdminDashboard-BrOvvDHF.js → AdminDashboard-Csq-oxmY.js} +2 -2
  19. package/dashboard/dist/assets/{AdminDashboard-BrOvvDHF.js.map → AdminDashboard-Csq-oxmY.js.map} +1 -1
  20. package/dashboard/dist/assets/{AgentConfigPage-CtVq8J0L.js → AgentConfigPage-Bnr5zbyJ.js} +2 -2
  21. package/dashboard/dist/assets/{AgentConfigPage-CtVq8J0L.js.map → AgentConfigPage-Bnr5zbyJ.js.map} +1 -1
  22. package/dashboard/dist/assets/{AgentDetailPage-DTfTQDug.js → AgentDetailPage-DgRu-Fhg.js} +2 -2
  23. package/dashboard/dist/assets/{AgentDetailPage-DTfTQDug.js.map → AgentDetailPage-DgRu-Fhg.js.map} +1 -1
  24. package/dashboard/dist/assets/{AgentsPage-vCTc3Qvj.js → AgentsPage-BuyXKkP3.js} +2 -2
  25. package/dashboard/dist/assets/{AgentsPage-vCTc3Qvj.js.map → AgentsPage-BuyXKkP3.js.map} +1 -1
  26. package/dashboard/dist/assets/{AvailableEscalationsPage-DJODShd7.js → AvailableEscalationsPage-BIzTjUMG.js} +2 -2
  27. package/dashboard/dist/assets/{AvailableEscalationsPage-DJODShd7.js.map → AvailableEscalationsPage-BIzTjUMG.js.map} +1 -1
  28. package/dashboard/dist/assets/{BotPicker-GU44inXA.js → BotPicker-xpPjRnkf.js} +2 -2
  29. package/dashboard/dist/assets/{BotPicker-GU44inXA.js.map → BotPicker-xpPjRnkf.js.map} +1 -1
  30. package/dashboard/dist/assets/{BulkAssignModal-ChqzG6FY.js → BulkAssignModal-CQ3k-7rO.js} +2 -2
  31. package/dashboard/dist/assets/{BulkAssignModal-ChqzG6FY.js.map → BulkAssignModal-CQ3k-7rO.js.map} +1 -1
  32. package/dashboard/dist/assets/{CapabilitiesPage-Y2hycdPY.js → CapabilitiesPage-DCkEJ0In.js} +2 -2
  33. package/dashboard/dist/assets/{CapabilitiesPage-Y2hycdPY.js.map → CapabilitiesPage-DCkEJ0In.js.map} +1 -1
  34. package/dashboard/dist/assets/{CollapsibleSection-CmCwt_Rs.js → CollapsibleSection-10sJSNNF.js} +2 -2
  35. package/dashboard/dist/assets/{CollapsibleSection-CmCwt_Rs.js.map → CollapsibleSection-10sJSNNF.js.map} +1 -1
  36. package/dashboard/dist/assets/{CountdownTimer-Bx2XXJOd.js → CountdownTimer-BFy9Joxb.js} +2 -2
  37. package/dashboard/dist/assets/{CountdownTimer-Bx2XXJOd.js.map → CountdownTimer-BFy9Joxb.js.map} +1 -1
  38. package/dashboard/dist/assets/{CredentialsPage-CoX_PNBe.js → CredentialsPage-DIR-fUoF.js} +2 -2
  39. package/dashboard/dist/assets/{CredentialsPage-CoX_PNBe.js.map → CredentialsPage-DIR-fUoF.js.map} +1 -1
  40. package/dashboard/dist/assets/{CronLabel-CVYKRipP.js → CronLabel-C66ASvgE.js} +2 -2
  41. package/dashboard/dist/assets/{CronLabel-CVYKRipP.js.map → CronLabel-C66ASvgE.js.map} +1 -1
  42. package/dashboard/dist/assets/{ElapsedCell-jRURiCRW.js → ElapsedCell-RWvrCHn7.js} +2 -2
  43. package/dashboard/dist/assets/{ElapsedCell-jRURiCRW.js.map → ElapsedCell-RWvrCHn7.js.map} +1 -1
  44. package/dashboard/dist/assets/{EntityTimelinePanel-G6nzvgpl.js → EntityTimelinePanel-CNaYs3nA.js} +2 -2
  45. package/dashboard/dist/assets/{EntityTimelinePanel-G6nzvgpl.js.map → EntityTimelinePanel-CNaYs3nA.js.map} +1 -1
  46. package/dashboard/dist/assets/{EscalationListSchemaPage-D-rVTQ1m.js → EscalationListSchemaPage-BsRQtDDc.js} +2 -2
  47. package/dashboard/dist/assets/{EscalationListSchemaPage-D-rVTQ1m.js.map → EscalationListSchemaPage-BsRQtDDc.js.map} +1 -1
  48. package/dashboard/dist/assets/{EscalationSchemaPage-CV0R_xY9.js → EscalationSchemaPage-BMYQmwGA.js} +2 -2
  49. package/dashboard/dist/assets/{EscalationSchemaPage-CV0R_xY9.js.map → EscalationSchemaPage-BMYQmwGA.js.map} +1 -1
  50. package/dashboard/dist/assets/{EscalationsOverview-DMdx15CQ.js → EscalationsOverview-yv4Yn6zl.js} +2 -2
  51. package/dashboard/dist/assets/{EscalationsOverview-DMdx15CQ.js.map → EscalationsOverview-yv4Yn6zl.js.map} +1 -1
  52. package/dashboard/dist/assets/{EventTable-CIvsdt-q.js → EventTable-ebZK7vXl.js} +2 -2
  53. package/dashboard/dist/assets/{EventTable-CIvsdt-q.js.map → EventTable-ebZK7vXl.js.map} +1 -1
  54. package/dashboard/dist/assets/{FilterBar-DWYGkVRH.js → FilterBar-D6JDMSHi.js} +2 -2
  55. package/dashboard/dist/assets/{FilterBar-DWYGkVRH.js.map → FilterBar-D6JDMSHi.js.map} +1 -1
  56. package/dashboard/dist/assets/{GraphInvokePage-BGHlXh4r.js → GraphInvokePage-BFntNMop.js} +2 -2
  57. package/dashboard/dist/assets/{GraphInvokePage-BGHlXh4r.js.map → GraphInvokePage-BFntNMop.js.map} +1 -1
  58. package/dashboard/dist/assets/{HomePage-BHOnp8SK.js → HomePage-B24GH9Ga.js} +2 -2
  59. package/dashboard/dist/assets/{HomePage-BHOnp8SK.js.map → HomePage-B24GH9Ga.js.map} +1 -1
  60. package/dashboard/dist/assets/{ListToolbar-iOgn_db5.js → ListToolbar-DlGreUpP.js} +2 -2
  61. package/dashboard/dist/assets/{ListToolbar-iOgn_db5.js.map → ListToolbar-DlGreUpP.js.map} +1 -1
  62. package/dashboard/dist/assets/{McpOverview-Be9sMKCA.js → McpOverview-D0G2vACW.js} +2 -2
  63. package/dashboard/dist/assets/{McpOverview-Be9sMKCA.js.map → McpOverview-D0G2vACW.js.map} +1 -1
  64. package/dashboard/dist/assets/{McpQueryDetailPage-BIgpmGJN.js → McpQueryDetailPage-LZO04PEB.js} +2 -2
  65. package/dashboard/dist/assets/{McpQueryDetailPage-BIgpmGJN.js.map → McpQueryDetailPage-LZO04PEB.js.map} +1 -1
  66. package/dashboard/dist/assets/{McpQueryPage-Okcxw_Um.js → McpQueryPage-BIwSDHgB.js} +2 -2
  67. package/dashboard/dist/assets/{McpQueryPage-Okcxw_Um.js.map → McpQueryPage-BIwSDHgB.js.map} +1 -1
  68. package/dashboard/dist/assets/{McpRunDetailPage-DT8kOfih.js → McpRunDetailPage-DjYWJLWh.js} +2 -2
  69. package/dashboard/dist/assets/{McpRunDetailPage-DT8kOfih.js.map → McpRunDetailPage-DjYWJLWh.js.map} +1 -1
  70. package/dashboard/dist/assets/{McpRunsPage-BXhoP77D.js → McpRunsPage-CTT7B-pf.js} +2 -2
  71. package/dashboard/dist/assets/{McpRunsPage-BXhoP77D.js.map → McpRunsPage-CTT7B-pf.js.map} +1 -1
  72. package/dashboard/dist/assets/{OperationsPage-rVhC8JPv.js → OperationsPage-Dd0WxAwH.js} +2 -2
  73. package/dashboard/dist/assets/{OperationsPage-rVhC8JPv.js.map → OperationsPage-Dd0WxAwH.js.map} +1 -1
  74. package/dashboard/dist/assets/{OperatorDashboard-CIt061hu.js → OperatorDashboard-BfKMaVzV.js} +2 -2
  75. package/dashboard/dist/assets/{OperatorDashboard-CIt061hu.js.map → OperatorDashboard-BfKMaVzV.js.map} +1 -1
  76. package/dashboard/dist/assets/{PersonaDetailPage-r46uNF4E.js → PersonaDetailPage-B48MX4lq.js} +2 -2
  77. package/dashboard/dist/assets/{PersonaDetailPage-r46uNF4E.js.map → PersonaDetailPage-B48MX4lq.js.map} +1 -1
  78. package/dashboard/dist/assets/{PersonasPage-CayYv9-j.js → PersonasPage-dGX6E96g.js} +2 -2
  79. package/dashboard/dist/assets/{PersonasPage-CayYv9-j.js.map → PersonasPage-dGX6E96g.js.map} +1 -1
  80. package/dashboard/dist/assets/{ProcessDetailPage-dn7lkM4c.js → ProcessDetailPage-Co5oCg31.js} +2 -2
  81. package/dashboard/dist/assets/{ProcessDetailPage-dn7lkM4c.js.map → ProcessDetailPage-Co5oCg31.js.map} +1 -1
  82. package/dashboard/dist/assets/{ProcessesListPage-DOp5J6Be.js → ProcessesListPage-CrB4VAS6.js} +2 -2
  83. package/dashboard/dist/assets/{ProcessesListPage-DOp5J6Be.js.map → ProcessesListPage-CrB4VAS6.js.map} +1 -1
  84. package/dashboard/dist/assets/{RoleDetailPage-DOlNoiAK.js → RoleDetailPage-C4UTNx0p.js} +2 -2
  85. package/dashboard/dist/assets/{RoleDetailPage-DOlNoiAK.js.map → RoleDetailPage-C4UTNx0p.js.map} +1 -1
  86. package/dashboard/dist/assets/{RolesPage-DPppT6Zl.js → RolesPage-BXo5RirX.js} +2 -2
  87. package/dashboard/dist/assets/{RolesPage-DPppT6Zl.js.map → RolesPage-BXo5RirX.js.map} +1 -1
  88. package/dashboard/dist/assets/{RunAsSelector-BgntKfSA.js → RunAsSelector-BRQiGv2-.js} +2 -2
  89. package/dashboard/dist/assets/{RunAsSelector-BgntKfSA.js.map → RunAsSelector-BRQiGv2-.js.map} +1 -1
  90. package/dashboard/dist/assets/{ScanCodesPage-DPm1lG79.js → ScanCodesPage-BUT5wjzC.js} +2 -2
  91. package/dashboard/dist/assets/{ScanCodesPage-DPm1lG79.js.map → ScanCodesPage-BUT5wjzC.js.map} +1 -1
  92. package/dashboard/dist/assets/{ScanSchemeDetailPage-CuoG89q1.js → ScanSchemeDetailPage-CkzoOyjd.js} +2 -2
  93. package/dashboard/dist/assets/{ScanSchemeDetailPage-CuoG89q1.js.map → ScanSchemeDetailPage-CkzoOyjd.js.map} +1 -1
  94. package/dashboard/dist/assets/{ScanStationPage-2SLXqqs0.js → ScanStationPage-DYamACNZ.js} +2 -2
  95. package/dashboard/dist/assets/{ScanStationPage-2SLXqqs0.js.map → ScanStationPage-DYamACNZ.js.map} +1 -1
  96. package/dashboard/dist/assets/{StickyPagination-Bc_Mzu_R.js → StickyPagination-B3yiAcrs.js} +2 -2
  97. package/dashboard/dist/assets/{StickyPagination-Bc_Mzu_R.js.map → StickyPagination-B3yiAcrs.js.map} +1 -1
  98. package/dashboard/dist/assets/{StreamMessageDetail-S1cnLGkf.js → StreamMessageDetail-C56PtZSb.js} +2 -2
  99. package/dashboard/dist/assets/{StreamMessageDetail-S1cnLGkf.js.map → StreamMessageDetail-C56PtZSb.js.map} +1 -1
  100. package/dashboard/dist/assets/{SwimlaneTimeline-BUu2sPmY.js → SwimlaneTimeline-D64ep5KY.js} +2 -2
  101. package/dashboard/dist/assets/{SwimlaneTimeline-BUu2sPmY.js.map → SwimlaneTimeline-D64ep5KY.js.map} +1 -1
  102. package/dashboard/dist/assets/{TaskDetailPage-BMfNNtbN.js → TaskDetailPage-C2V7BcgB.js} +2 -2
  103. package/dashboard/dist/assets/{TaskDetailPage-BMfNNtbN.js.map → TaskDetailPage-C2V7BcgB.js.map} +1 -1
  104. package/dashboard/dist/assets/{TasksListPage-BmNnopOU.js → TasksListPage-C4ctoAa0.js} +2 -2
  105. package/dashboard/dist/assets/{TasksListPage-BmNnopOU.js.map → TasksListPage-C4ctoAa0.js.map} +1 -1
  106. package/dashboard/dist/assets/{TimeAgo-Dip7gQQx.js → TimeAgo-BpJ7In27.js} +2 -2
  107. package/dashboard/dist/assets/{TimeAgo-Dip7gQQx.js.map → TimeAgo-BpJ7In27.js.map} +1 -1
  108. package/dashboard/dist/assets/{TimestampCell-DRAYnIrx.js → TimestampCell-BKrIaU_R.js} +2 -2
  109. package/dashboard/dist/assets/{TimestampCell-DRAYnIrx.js.map → TimestampCell-BKrIaU_R.js.map} +1 -1
  110. package/dashboard/dist/assets/{ToolTestPanel-CQVYC3Ba.js → ToolTestPanel-CdTXWPqn.js} +2 -2
  111. package/dashboard/dist/assets/{ToolTestPanel-CQVYC3Ba.js.map → ToolTestPanel-CdTXWPqn.js.map} +1 -1
  112. package/dashboard/dist/assets/{TopicDetailPage-Bmtwuksg.js → TopicDetailPage-B6tb1RG4.js} +2 -2
  113. package/dashboard/dist/assets/{TopicDetailPage-Bmtwuksg.js.map → TopicDetailPage-B6tb1RG4.js.map} +1 -1
  114. package/dashboard/dist/assets/{TopicsPage-DIgF7-mJ.js → TopicsPage-DgdOKjwE.js} +2 -2
  115. package/dashboard/dist/assets/{TopicsPage-DIgF7-mJ.js.map → TopicsPage-DgdOKjwE.js.map} +1 -1
  116. package/dashboard/dist/assets/{UserName-DNKFz7X9.js → UserName-A-ET2GnX.js} +2 -2
  117. package/dashboard/dist/assets/{UserName-DNKFz7X9.js.map → UserName-A-ET2GnX.js.map} +1 -1
  118. package/dashboard/dist/assets/{WorkflowExecutionPage-DraIBNpl.js → WorkflowExecutionPage-CzhoRsis.js} +2 -2
  119. package/dashboard/dist/assets/{WorkflowExecutionPage-DraIBNpl.js.map → WorkflowExecutionPage-CzhoRsis.js.map} +1 -1
  120. package/dashboard/dist/assets/{WorkflowsDashboard-BH7kmFjM.js → WorkflowsDashboard-B_tCYLei.js} +2 -2
  121. package/dashboard/dist/assets/{WorkflowsDashboard-BH7kmFjM.js.map → WorkflowsDashboard-B_tCYLei.js.map} +1 -1
  122. package/dashboard/dist/assets/{WorkflowsOverview-C98pCjQX.js → WorkflowsOverview-B4Bh8MIo.js} +2 -2
  123. package/dashboard/dist/assets/{WorkflowsOverview-C98pCjQX.js.map → WorkflowsOverview-B4Bh8MIo.js.map} +1 -1
  124. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BWQjXenZ.js → YamlWorkflowDetailPage-zRrcxk0e.js} +2 -2
  125. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BWQjXenZ.js.map → YamlWorkflowDetailPage-zRrcxk0e.js.map} +1 -1
  126. package/dashboard/dist/assets/{YamlWorkflowsPage-BGTI_sdP.js → YamlWorkflowsPage-DMK3ojp3.js} +2 -2
  127. package/dashboard/dist/assets/{YamlWorkflowsPage-BGTI_sdP.js.map → YamlWorkflowsPage-DMK3ojp3.js.map} +1 -1
  128. package/dashboard/dist/assets/{agents-DfMrlw54.js → agents-B67yyE1z.js} +2 -2
  129. package/dashboard/dist/assets/{agents-DfMrlw54.js.map → agents-B67yyE1z.js.map} +1 -1
  130. package/dashboard/dist/assets/{bots-B9zS0z7D.js → bots-pSLFdOm-.js} +2 -2
  131. package/dashboard/dist/assets/{bots-B9zS0z7D.js.map → bots-pSLFdOm-.js.map} +1 -1
  132. package/dashboard/dist/assets/{capabilities-DkLM1xgH.js → capabilities-B2Dem6zw.js} +2 -2
  133. package/dashboard/dist/assets/{capabilities-DkLM1xgH.js.map → capabilities-B2Dem6zw.js.map} +1 -1
  134. package/dashboard/dist/assets/{controlplane-SJK1yvbm.js → controlplane-DGdaM9f3.js} +2 -2
  135. package/dashboard/dist/assets/{controlplane-SJK1yvbm.js.map → controlplane-DGdaM9f3.js.map} +1 -1
  136. package/dashboard/dist/assets/{escalation-columns-BvAylNM1.js → escalation-columns-BM7vp-hY.js} +2 -2
  137. package/dashboard/dist/assets/{escalation-columns-BvAylNM1.js.map → escalation-columns-BM7vp-hY.js.map} +1 -1
  138. package/dashboard/dist/assets/{index-DamcWcqG.js → index-5eRsj758.js} +2 -2
  139. package/dashboard/dist/assets/{index-DamcWcqG.js.map → index-5eRsj758.js.map} +1 -1
  140. package/dashboard/dist/assets/{index-CLxuBb17.js → index-BD6nhSOu.js} +2 -2
  141. package/dashboard/dist/assets/{index-CLxuBb17.js.map → index-BD6nhSOu.js.map} +1 -1
  142. package/dashboard/dist/assets/{index-DvmyIGeZ.js → index-Baf-tOnA.js} +2 -2
  143. package/dashboard/dist/assets/{index-DvmyIGeZ.js.map → index-Baf-tOnA.js.map} +1 -1
  144. package/dashboard/dist/assets/{index-ClVNU3G3.js → index-Brf_fpE4.js} +2 -2
  145. package/dashboard/dist/assets/{index-ClVNU3G3.js.map → index-Brf_fpE4.js.map} +1 -1
  146. package/dashboard/dist/assets/{index-CXe2d5kg.js → index-CGoXyPlO.js} +2 -2
  147. package/dashboard/dist/assets/{index-CXe2d5kg.js.map → index-CGoXyPlO.js.map} +1 -1
  148. package/dashboard/dist/assets/{index-DazfFRUx.js → index-CKt5YK2z.js} +2 -2
  149. package/dashboard/dist/assets/{index-DazfFRUx.js.map → index-CKt5YK2z.js.map} +1 -1
  150. package/dashboard/dist/assets/index-CLq228E2.js +3 -0
  151. package/dashboard/dist/assets/index-CLq228E2.js.map +1 -0
  152. package/dashboard/dist/assets/{index-DKXOIcO3.js → index-Cd2RdpOx.js} +2 -2
  153. package/dashboard/dist/assets/{index-DKXOIcO3.js.map → index-Cd2RdpOx.js.map} +1 -1
  154. package/dashboard/dist/assets/{index-Cw-V0VhS.js → index-Cn__VdSf.js} +2 -2
  155. package/dashboard/dist/assets/{index-Cw-V0VhS.js.map → index-Cn__VdSf.js.map} +1 -1
  156. package/dashboard/dist/assets/{index-DSfY8oDp.js → index-CunrdEfT.js} +2 -2
  157. package/dashboard/dist/assets/{index-DSfY8oDp.js.map → index-CunrdEfT.js.map} +1 -1
  158. package/dashboard/dist/assets/{index-D2IRxjSf.js → index-DajlugVw.js} +2 -2
  159. package/dashboard/dist/assets/{index-D2IRxjSf.js.map → index-DajlugVw.js.map} +1 -1
  160. package/dashboard/dist/assets/{index-PjiXOVdw.js → index-DbLOvfv5.js} +2 -2
  161. package/dashboard/dist/assets/{index-PjiXOVdw.js.map → index-DbLOvfv5.js.map} +1 -1
  162. package/dashboard/dist/assets/{index-zrTQcPjB.js → index-zqoZDL5j.js} +3 -3
  163. package/dashboard/dist/assets/{index-zrTQcPjB.js.map → index-zqoZDL5j.js.map} +1 -1
  164. package/dashboard/dist/assets/{knowledge-BNp6MH-4.js → knowledge-BExXJ0Ib.js} +2 -2
  165. package/dashboard/dist/assets/{knowledge-BNp6MH-4.js.map → knowledge-BExXJ0Ib.js.map} +1 -1
  166. package/dashboard/dist/assets/{mcp-Bb1k5rv-.js → mcp-D2WA-SHc.js} +2 -2
  167. package/dashboard/dist/assets/{mcp-Bb1k5rv-.js.map → mcp-D2WA-SHc.js.map} +1 -1
  168. package/dashboard/dist/assets/{mcp-query-QVakMQnS.js → mcp-query-4Tsojk-z.js} +2 -2
  169. package/dashboard/dist/assets/{mcp-query-QVakMQnS.js.map → mcp-query-4Tsojk-z.js.map} +1 -1
  170. package/dashboard/dist/assets/{personas-DV2JUjVj.js → personas-Dy_XSYfJ.js} +2 -2
  171. package/dashboard/dist/assets/{personas-DV2JUjVj.js.map → personas-Dy_XSYfJ.js.map} +1 -1
  172. package/dashboard/dist/assets/{pipelines-BkVB7Q0p.js → pipelines-yDHgNtdx.js} +2 -2
  173. package/dashboard/dist/assets/{pipelines-BkVB7Q0p.js.map → pipelines-yDHgNtdx.js.map} +1 -1
  174. package/dashboard/dist/assets/{tasks-DvYWcASM.js → tasks-CGoPhQyw.js} +2 -2
  175. package/dashboard/dist/assets/{tasks-DvYWcASM.js.map → tasks-CGoPhQyw.js.map} +1 -1
  176. package/dashboard/dist/assets/{topics-B9zXFuVG.js → topics-DA1MHDwJ.js} +2 -2
  177. package/dashboard/dist/assets/{topics-B9zXFuVG.js.map → topics-DA1MHDwJ.js.map} +1 -1
  178. package/dashboard/dist/assets/{useEventHooks-JDpifqGZ.js → useEventHooks-onx-Z6IY.js} +2 -2
  179. package/dashboard/dist/assets/{useEventHooks-JDpifqGZ.js.map → useEventHooks-onx-Z6IY.js.map} +1 -1
  180. package/dashboard/dist/assets/{useNamespace-Bqr-LdWx.js → useNamespace-BkuU0SeK.js} +2 -2
  181. package/dashboard/dist/assets/{useNamespace-Bqr-LdWx.js.map → useNamespace-BkuU0SeK.js.map} +1 -1
  182. package/dashboard/dist/assets/{useYamlActivityEvents-n3naCEbw.js → useYamlActivityEvents-XXS3wg6-.js} +2 -2
  183. package/dashboard/dist/assets/{useYamlActivityEvents-n3naCEbw.js.map → useYamlActivityEvents-XXS3wg6-.js.map} +1 -1
  184. package/dashboard/dist/assets/{users-BNXLRVTS.js → users-B_9mC6D_.js} +2 -2
  185. package/dashboard/dist/assets/{users-BNXLRVTS.js.map → users-B_9mC6D_.js.map} +1 -1
  186. package/dashboard/dist/assets/{workflows-D8uMBPvQ.js → workflows-5sds1Ko8.js} +2 -2
  187. package/dashboard/dist/assets/{workflows-D8uMBPvQ.js.map → workflows-5sds1Ko8.js.map} +1 -1
  188. package/dashboard/dist/assets/{yaml-workflows-DVDOQM3Y.js → yaml-workflows-CjNa2u3I.js} +2 -2
  189. package/dashboard/dist/assets/{yaml-workflows-DVDOQM3Y.js.map → yaml-workflows-CjNa2u3I.js.map} +1 -1
  190. package/dashboard/dist/index.html +1 -1
  191. package/docs/api/http/workflows.md +35 -0
  192. package/docs/api/mcp/admin.md +14 -0
  193. package/docs/api/sdk/workflows.md +21 -0
  194. package/docs/hitl/lookups.md +10 -0
  195. package/docs/hitl/x-lt-validation.md +2 -1
  196. package/docs/hitl/x-lt-widget.md +1 -1
  197. package/docs/hitl-guide.md +2 -2
  198. package/package.json +2 -2
  199. package/dashboard/dist/assets/index-DTZxHZJO.js +0 -3
  200. package/dashboard/dist/assets/index-DTZxHZJO.js.map +0 -1
@@ -0,0 +1,3 @@
1
+ import{b as Qe,a as m,j as t}from"./vendor-query-RUZdMvN6.js";import{Z as Ws,_ as ht,g as yt,U as Qt,$ as Jt,J as Ot,c as qs,d as Us,P as at,b as Yt,m as De,a0 as Zt,a1 as Ye,X as le,L as ce,T as Ze,j as Ke,a2 as Js,a3 as Vs,a4 as Hs,i as Bs,a5 as zs,a6 as Xs,A as Gs,B as Qs,u as Ys,v as Zs,l as Ks,a7 as tn}from"./index-zqoZDL5j.js";import{u as ts,C as es,r as en,B as sn,a as nn}from"./BulkAssignModal-CQ3k-7rO.js";import{M as ss}from"./Modal-BU7No9NH.js";import{a as ns,u as de,L as jt,b as rn,e as an}from"./vendor-react-CdqEC2zv.js";import{P as on}from"./PageHeader-CFVw67M6.js";import{L as ln}from"./ListToolbar-DlGreUpP.js";import{i as qt,b as cn,d as dn,C as Vt,g as ue,H as un,m as xn,c as it,r as xe,s as pn,e as rs}from"./CountdownTimer-BFy9Joxb.js";import{u as mn}from"./workflows-5sds1Ko8.js";import{g as fn}from"./useEventHooks-onx-Z6IY.js";import{S as as}from"./StatusBadge-BDeUwPtb.js";import{R as gn}from"./RolePill-Di_5hfvw.js";import{C as dt}from"./CopyableId-4Lqlc5cU.js";import{U as pe}from"./UserName-A-ET2GnX.js";import{d as hn}from"./metadata-display-DHjqWkLG.js";import{a2 as is,J as bn,S as yn,au as jn,_ as Nn,n as vn,af as os,U as wn,ai as kn,aj as _n,ak as Cn,a8 as En,av as An,aw as Tn,ax as re,ay as Rn,az as $e,aA as On,K as Le,O as Pe,aB as Mn,X as In}from"./vendor-icons-h-jlRSb9.js";import"./users-B_9mC6D_.js";import"./constants-BHkpVaqx.js";import"./useDebouncedValue-C4P2jQuh.js";import"./DataTable-DFPMeqyQ.js";import"./EmptyState-lpUFYfun.js";import"./StickyPagination-B3yiAcrs.js";const Sn={SCHEMA_VALIDATION:"schema_validation"};function Dn(e){return typeof e=="object"&&e!==null&&e.code===Sn.SCHEMA_VALIDATION&&Array.isArray(e.violations)}function $n({escalationId:e}){var b;const s=ns(),r=de(),n=Qe(),a=(b=s.state)==null?void 0:b[Ws],[i,d]=m.useState(!1),[c,u]=m.useState(null),[p,l]=m.useState(!1);if(!a||a.escalationId!==e||p)return null;const o=()=>{l(!0),r(s.pathname,{replace:!0,state:null})},x=async()=>{var v,y,g;d(!0),u(null);try{switch(a.verb){case ht.CANCEL:await yt(`/escalations/${e}/cancel`,{method:"POST"});break;case ht.CLAIM:case ht.CLAIM_SHOW_DETAIL:await yt(`/escalations/${e}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:((v=a.params)==null?void 0:v.durationMinutes)??30})});break;case ht.RELEASE:await yt(`/escalations/${e}/release`,{method:"POST"});break;case ht.RESOLVE:await yt(`/escalations/${e}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:((y=a.params)==null?void 0:y.resolverPayload)??{}})});break;case ht.ESCALATE:await yt(`/escalations/${e}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:(g=a.params)==null?void 0:g.targetRole})});break;default:throw new Error(`Unsupported confirm verb "${a.verb}"`)}n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]}),o()}catch(j){u(j.message)}finally{d(!1)}};return t.jsx(ss,{open:!0,onClose:o,title:"Confirm scan action",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-text-secondary",children:a.prompt}),c&&t.jsx("p",{className:"text-xs text-status-error",children:c}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:o,disabled:i,className:"btn-secondary text-xs",children:"No, go back"}),t.jsx("button",{onClick:x,disabled:i,className:"btn-primary text-xs",children:i?"Working…":"Yes, continue"})]})]})})}const Wt={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))"},Kt=4;function Fe({pct:e,place:s,label:r,title:n,emphasis:a}){const i=t.jsx("span",{className:"w-px h-1 bg-text-quaternary/70","aria-hidden":!0}),d=t.jsx("span",{className:`whitespace-nowrap leading-none tabular-nums text-[10px] ${a?"text-text-tertiary":"text-text-quaternary"}`,children:r});return t.jsx("div",{title:n,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 Ln({esc:e,className:s=""}){const r=new Date(e.created_at).getTime(),n=e.claimed_at?new Date(e.claimed_at).getTime():null,a=e.status==="resolved",i=e.status==="cancelled"||e.status==="expired",d=a||i,c=qt(e),u=!!n&&(c||d),p=a&&e.resolved_at?new Date(e.resolved_at).getTime():i?new Date(e.updated_at).getTime():Date.now(),l=Math.max(p-r,1),o=u&&n?Math.max(n-r,0):l,x=u&&n?Math.max(p-n,0):0,b=Math.min(100,Math.max(0,o/l*100)),v=u?Math.max(0,100-b):0,y=a?Wt.resolved:i?Wt.cancelled:Wt.claimed,g=a?"Resolved after":i?"Cancelled after":"In progress",j=Qt(o),k=Qt(l),h=a?`Resolved in ${k} total`:i?`Cancelled after ${k}`:`Open ${k} so far`,R=`Lifecycle bar: blue = time waiting to be claimed, ${a?"green":i?"red":"orange"} = ${g.toLowerCase()} the claim.`;return t.jsxs("div",{className:s,title:R,children:[t.jsx("div",{className:"relative h-2.5 font-mono",children:u&&t.jsx(Fe,{pct:b,place:"above",label:j,title:`Time to claim: ${j}`})}),t.jsxs("div",{className:"flex w-full rounded-full overflow-hidden",style:{height:Kt,backgroundColor:"rgb(var(--lt-surface-sunken))"},title:R,children:[t.jsx("div",{style:{width:`${b}%`,minWidth:Kt,backgroundColor:Wt.pending,opacity:.75},title:`Waiting ${j} — created → claimed`}),u&&v>0&&t.jsx("div",{style:{width:`${v}%`,minWidth:Kt,backgroundColor:y,opacity:.75},title:`${g} ${Qt(x)}`})]}),t.jsx("div",{className:"relative h-2.5 font-mono",children:t.jsx(Fe,{pct:100,place:"below",emphasis:!0,label:k,title:h})})]})}function Pn({triage:e,payload:s}){const r=e.confidence??0,n=r>=.8?"text-status-success":r>=.5?"text-status-pending":"text-status-error",a=Fn(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 ${n}`,children:[Math.round(r*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}),a.length>0&&t.jsx("div",{className:"space-y-4 pt-2",children:a.map(i=>t.jsx(Wn,{diff:i},i.key))})]})}function Fn(e,s){if(!e)return[];const r=[];for(const n of Object.keys(e)){if(n.startsWith("_"))continue;const a=e[n],i=s[n];i!==void 0&&JSON.stringify(a)!==JSON.stringify(i)&&r.push({key:n,label:n.replace(/[_-]/g," "),original:a,corrected:i})}return r}function Wn({diff:e}){const s=We(e.original),r=We(e.corrected);return s!==null&&r!==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:r})]})]})}):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 We(e){return e==null?"null":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function Y(e,s){const r=s==null?void 0:s.title;if(typeof r=="string"&&r.trim().length>0)return r.trim();const n=e.split(/[_-]+/).filter(Boolean);return n.length<=1?e:n.map(a=>qn(a)?a:a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function qn(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"},ls="lt:escalation:panel:view";function Un(e){try{const s=localStorage.getItem(ls);if(s&&e.includes(s))return s}catch{}return z.HELP}function Jn({metadata:e,role:s}){const r=hn(e);return r.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:r.map(([n,a])=>{const i=typeof a=="object"&&a!==null?JSON.stringify(a):String(a),d=De(n,a,s),c=De(n,a);return t.jsxs("div",{className:"group relative",children:[t.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:Y(n)}),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(jt,{to:d,title:`Filter this queue: ${n} = ${i}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx(kn,{className:"w-3 h-3"})}),t.jsx(jt,{to:c,title:`Search all queues: ${n} = ${i}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx(_n,{className:"w-3 h-3"})})]})]},n)})})}function Vn({esc:e,claimed:s,isTerminal:r,isBuilder:n,traceUrl:a}){return t.jsxs("div",{className:"space-y-5",children:[t.jsxs("dl",{className:"space-y-3.5",children:[t.jsx(at,{label:"Status",children:t.jsx(as,{status:e.status})}),t.jsx(at,{label:"Assigned to Role",children:t.jsx(gn,{role:e.role,size:"md"})}),t.jsxs(at,{label:"Priority",children:["P",e.priority]}),(s||r)&&e.assigned_to&&t.jsx(at,{label:"Claimed By",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium text-text-primary",children:[t.jsx(wn,{className:"w-3 h-3 shrink-0 text-accent/75"}),t.jsx(pe,{userId:e.assigned_to})]})}),t.jsx(at,{label:"Created",children:t.jsx(Yt,{date:e.created_at})}),(s||r)&&e.claimed_at&&t.jsx(at,{label:"Claimed",children:t.jsx(Yt,{date:e.claimed_at})}),s&&!r&&e.assigned_until&&t.jsx(at,{label:"Time Remaining",children:t.jsx(Vt,{until:e.assigned_until})}),e.resolved_at&&t.jsx(at,{label:"Completed",children:t.jsx("span",{className:"text-status-success",children:t.jsx(Yt,{date:e.resolved_at})})})]}),n&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"border-surface-border/60"}),t.jsxs("div",{className:"space-y-3.5",children:[t.jsx(dt,{label:"Escalation ID",value:e.id}),e.task_id&&t.jsx(dt,{label:"Task ID",value:e.task_id,href:`/workflows/tasks/detail/${e.task_id}`}),e.workflow_type&&t.jsx(dt,{label:"Workflow Name",value:e.workflow_type,href:`/workflows/executions?entity=${encodeURIComponent(e.workflow_type)}`}),e.workflow_id&&t.jsx(dt,{label:"Workflow ID",value:e.workflow_id,href:`/workflows/executions/${e.workflow_id}`}),e.task_queue&&t.jsx(dt,{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(dt,{label:"Origin",value:e.origin_id,href:`/processes/detail/${e.origin_id}`}),e.trace_id&&t.jsx(dt,{label:"Trace",value:e.trace_id,href:a?a.replace("{traceId}",e.trace_id):void 0,external:!0})]})]})]})}function Hn({errors:e,schema:s}){const r=n=>{const a=document.querySelector(`[data-field-key="${n}"]`);a&&(a.scrollIntoView({behavior:"smooth",block:"center"}),a.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:n,message:a})=>{var i;return t.jsxs("button",{onClick:()=>r(n),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(os,{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:Y(n,(i=s==null?void 0:s.properties)==null?void 0:i[n])}),t.jsx("p",{className:"text-2xs text-text-tertiary group-hover:text-text-secondary transition-colors leading-snug mt-0.5",children:a})]})]},n)})}),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 Bn({esc:e,schema:s,envelope:r,payload:n,resolver:a,triage:i,hasAI:d,claimed:c,claimedByMe:u,isTerminal:p,isBuilder:l,traceUrl:o,open:x,noGutter:b,formErrors:v,activePanel:y,onPanelChange:g}){const j=de(),k=Object.values(z),[h,R]=m.useState(()=>Un(k)),I=y??h,D=m.useCallback(A=>{try{localStorage.setItem(ls,A)}catch{}R(A),g==null||g(A)},[g]);m.useEffect(()=>{y&&y!==h&&R(y)},[y]);const $=m.useMemo(()=>cn(s,{escalation:e,metadata:e.metadata??null,envelope:r,payload:n,resolver:a})??dn({isTerminal:p,status:e.status,claimed:c,claimedByMe:u}),[s,e,r,n,a,p,c,u]),W=m.useCallback(A=>{const T=A.target.closest("a"),O=T==null?void 0:T.getAttribute("href");O!=null&&O.startsWith("/")&&(A.preventDefault(),j(O))},[j]),E=[{id:z.HELP,icon:is,label:"Instructions",content:t.jsx(Jt,{content:$,onClick:W})},{id:z.DETAILS,icon:bn,label:"Details",content:t.jsx(Vn,{esc:e,claimed:c,isTerminal:p,isBuilder:l,traceUrl:o})},...d&&i?[{id:z.TRIAGE,icon:yn,label:"AI Analysis",content:t.jsx(Pn,{triage:i,payload:n??{}})}]:[],{id:z.METADATA,icon:jn,label:"Metadata",content:t.jsx(Jn,{metadata:e.metadata,role:e.role})},{id:z.CONTEXT,icon:Nn,label:"Context",content:t.jsxs("div",{className:"space-y-5",children:[r!=null&&t.jsx(Ot,{data:r,label:"Input Envelope"}),n!=null&&t.jsx(Ot,{data:n,label:"Escalation Context"}),a!=null&&t.jsx(Ot,{data:a,label:"Resolver Payload"}),r==null&&n==null&&a==null&&t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No context on this escalation."})]})},...l?[{id:z.RECORD,icon:vn,label:"Record",content:t.jsx(Ot,{data:e,label:"Escalation Record"})}]:[],...v&&v.length>0?[{id:z.ERRORS,icon:(({className:A})=>t.jsx(os,{className:`${A??""} text-status-error`})),label:"Errors",content:t.jsx(Hn,{errors:v,schema:s})}]:[]];return t.jsx(qs,{open:x,width:384,className:"h-full",children:t.jsx("div",{className:`h-full${b?"":" pl-6"}`,children:t.jsxs("div",{className:"h-full flex flex-col bg-surface-hover",children:[t.jsx("div",{className:"shrink-0 pt-2 pb-0 flex justify-center",children:t.jsx(Ln,{esc:e,className:"w-[80%]"})}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(Us,{views:E,activeId:I,onViewChange:D,stickyClassName:"h-full min-h-0"})})]})})})}const zn=/\{\{\s*([^{}]+?)\s*\}\}/g;function ae(e){return typeof e=="string"&&/\{\{[^{}]+\}\}/.test(e)}function me(e,s){if(!s)return;const r=e.indexOf("."),n=s[r===-1?e:e.slice(0,r)];if(r===-1)return n;if(!(n===null||typeof n!="object"))return ue(n,e.slice(r+1))}function cs(e,s){let r=!1;const n=e.replace(zn,(a,i)=>{const d=me(i,s);return typeof d=="string"&&d.trim().length>0?d:typeof d=="number"&&Number.isFinite(d)?String(d):(r=!0,"")});return r?null:n}const Xn="x-lt-options";function qe(e){return typeof e=="string"||typeof e=="number"&&Number.isFinite(e)}function Gn(e){if(qe(e))return{value:e,label:String(e)};if(e&&typeof e=="object"&&!Array.isArray(e)){const s=e,r=s.value!==void 0?s.value:s.id;if(qe(r)&&typeof s.label=="string"&&s.label.length>0)return{value:r,label:s.label}}return null}function ds(e,s){if(!e)return;const r=e.enum;if(Array.isArray(r)&&r.length>0)return r.map(d=>({value:d,label:String(d)}));const n=e[Xn],a=(typeof n=="string"?[n]:Array.isArray(n)?n:[]).filter(d=>typeof d=="string"&&d.length>0);if(a.length===0)return;const i=a.some(ae)?[]:void 0;for(const d of a){let c=d;if(ae(d)){const l=cs(d,s);if(l===null)continue;c=l}const u=me(c,s);if(!Array.isArray(u))continue;const p=u.map(Gn).filter(l=>l!==null);if(p.length>0)return p}return i}function fe(e,s){const r=(typeof e=="string"?[e]:Array.isArray(e)?e:[]).filter(n=>typeof n=="string"&&n.length>0);if(r.length===0||!s)return[];for(const n of r){let a=n;if(ae(n)){const d=cs(n,s);if(d===null)continue;a=d}const i=me(a,s);if(Array.isArray(i)&&i.length>0)return i}return[]}const Qn="x-lt-default-checked";function Yn(e,s,r){if((e==null?void 0:e["x-lt-widget"])!=="checklist"||e[Qn]!==!0||s&&typeof s=="object"&&!Array.isArray(s)&&Object.keys(s).length>0)return null;const n=fe(e["x-lt-source"],r);return n.length===0?null:Object.fromEntries(n.map(a=>[a.id,!0]))}function Zn(e,s,r){if((s==null?void 0:s["x-lt-widget"])!=="checklist"||s["x-lt-require-all"]!==!0)return;const a=fe(s["x-lt-source"],r).filter(c=>c.required!==!1);if(a.length===0)return;const i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},d=a.filter(c=>!i[c.id]).length;if(d!==0)return`${d} of ${a.length} checks incomplete`}function Kn(e,s){const r=s==null?void 0:s.type;if(typeof r=="string"&&!(e==null||e===""))switch(r){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 tr(e,s,r){if(!s)return;const n=ds(s,r);if(n!==void 0&&e!==void 0&&e!==null&&e!==""){if(n.length===0)return"No valid options for this selection";if(!n.some(a=>a.value===e))return`Must be one of: ${n.map(a=>String(a.value)).join(", ")}`}if(typeof e=="string"){const a=e.trim();if(a==="")return;const i=bt(s.minLength,s["x-lt-min-length"],r);if(i!==void 0&&a.length<i)return`Minimum ${i} character${i===1?"":"s"}`;const d=bt(s.maxLength,s["x-lt-max-length"],r);if(d!==void 0&&a.length>d)return`Maximum ${d} characters (${a.length} entered)`;const c=s.pattern;if(c)try{if(!new RegExp(c).test(a))return s["x-lt-pattern-error"]??"Invalid format"}catch{}const u=s.format;if(u==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a))return"Enter a valid email address";if(u==="uri"&&!/^https?:\/\/.+/.test(a))return"Enter a valid URL"}if(typeof e=="number"){const a=bt(s.minimum,s["x-lt-minimum"],r),i=bt(s.exclusiveMinimum,void 0,r),d=bt(s.maximum,s["x-lt-maximum"],r),c=bt(s.exclusiveMaximum,void 0,r);if(a!==void 0&&e<a)return`Minimum value is ${a}`;if(i!==void 0&&e<=i)return`Must be greater than ${i}`;if(d!==void 0&&e>d)return`Maximum value is ${d}`;if(c!==void 0&&e>=c)return`Must be less than ${c}`}}function bt(e,s,r){if(typeof e=="number")return e;if(typeof s=="string"&&r){const n=s.indexOf(".");if(n!==-1){const a=s.slice(0,n),i=s.slice(n+1),d=r[a];if(d&&typeof d=="object"){const c=i.split(".");let u=d;for(const p of c)if(u=u[p],u===void 0)break;if(typeof u=="number")return u;if(typeof u=="string"){const p=Number(u);if(!Number.isNaN(p))return p}}}}}function us(e,s,r,n,a){if(!n)return;if(r){if(e==null||typeof e=="boolean"&&!e||typeof e=="string"&&e.trim()==="")return"Required";if(typeof e=="object"&&!Array.isArray(e)&&e!==null){const c=Object.values(e);if(c.length===0||c.every(u=>!u))return"Required"}}const i=Kn(e,s);if(i)return i;const d=Zn(e,s,a);return d||tr(e,s,a)}function Ue(e){return e!=null&&e!==""&&e!==!1&&e!==0}function er(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Je(e,s){const r=e.indexOf("."),n=r===-1?e:e.slice(0,r);if(!un.includes(n))return{known:!1,value:void 0};const a=s[n];if(r===-1)return{known:!0,value:a};try{return{known:!0,value:ue(a,e.slice(r+1))}}catch{return{known:!0,value:void 0}}}function Ut(e,s){if(typeof e!="string"||e.length===0||!s)return!0;const r=e.startsWith("!"),n=r?e.slice(1):e,a=n.indexOf("!="),i=n.indexOf("=");if(a!==-1||i!==-1&&i!==a+1){const u=a!==-1&&(i===-1||a<i),p=u?a:i,l=n.slice(0,p).trim(),o=n.slice(p+(u?2:1)).trim(),{known:x,value:b}=Je(l,s);if(!x)return!0;const v=er(b)===o,y=u?!v:v;return r?!y:y}const{known:d,value:c}=Je(n,s);return d?r?!Ue(c):Ue(c):!0}const sr="x-lt-require-any";function nr(e){const s=e==null?void 0:e[sr];return Array.isArray(s)?s.filter(r=>Array.isArray(r)).map(r=>r.filter(n=>typeof n=="string"&&n.length>0)).filter(r=>r.length>0):[]}function rr(e){return e==null?!1:typeof e=="string"?e.trim().length>0:!0}const ar="x-lt-require-sum";function ir(e){const s=e==null?void 0:e[ar];if(!Array.isArray(s))return[];const r=[];for(const n of s){if(!n||typeof n!="object"||Array.isArray(n))continue;const{fields:a,minimum:i}=n;if(!Array.isArray(a))continue;const d=a.filter(c=>typeof c=="string"&&c.length>0);d.length!==0&&(i!==void 0&&typeof i!="number"||r.push({fields:d,minimum:typeof i=="number"?i:1}))}return r}function or(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""){const s=Number(e);if(!Number.isNaN(s))return s}return 0}function xs(e,s,r){if(!e)return[];const n=e.properties??{},a=new Set(e.required??[]),i={...r??{},resolver:s},d=[];for(const[c,u]of Object.entries(n)){if(!Ut(u["x-lt-showIf"],i))continue;const p=us(s[c],u,a.has(c),!0,i);p&&d.push({field:c,message:p})}for(const c of nr(e)){const u=c.filter(l=>n[l]&&Ut(n[l]["x-lt-showIf"],i));if(u.length===0||u.some(l=>rr(s[l])))continue;const p=u.map(l=>n[l].title??l);d.push({field:u[0],message:`Enter a value for at least one of: ${p.join(", ")}`})}for(const c of ir(e)){const u=c.fields.filter(o=>n[o]&&Ut(n[o]["x-lt-showIf"],i));if(u.length===0||u.reduce((o,x)=>o+or(s[x]),0)>=c.minimum)continue;const l=u.map(o=>n[o].title??o);d.push({field:u[0],message:`Combined value of ${l.join(", ")} must be at least ${c.minimum}`})}return d}function ie(e,s){let r;try{r=JSON.parse(e)}catch{return{payload:null,errors:[],parseError:"Invalid JSON"}}const n=r._form_schema;if(n){const d=xs(n,r,s);if(d.length>0)return{payload:null,errors:d,parseError:null}}const{_form_schema:a,...i}=r;return{payload:xn(i,n),errors:[],parseError:null}}function lr(e){const{mode:s,activeView:r,onActiveViewChange:n,onClaim:a,claimPending:i,claimNudge:d,workflowType:c,json:u,onResolve:p,resolvePending:l,resolveError:o,requestTriage:x,triageNotes:b,onRelease:v,releasePending:y,onCancel:g,assignedTo:j,assignedUntil:k,onSubmitAttempt:h,onValidationErrors:R,escalationContext:I,labels:D={},submitBlocked:$,submitBlockedMessage:W,actingName:E,badgePrompt:A,canManage:T,onReassign:O,onUnassign:M,unassignPending:H}=e,q=ts(),[Z,J]=m.useState("30"),[K,L]=m.useState(0),[w,_]=m.useState(""),N=Z==="custom",P=m.useCallback(S=>L(S),[]),V=!!$&&!x;if(s==="terminal")return null;const ot=()=>{const S=N?K:parseInt(Z);!S||S<=0||a(S)},Nt=()=>{if(_(""),x){const pt={_lt:{needsTriage:!0}};b.trim()&&(pt.notes=b.trim()),p(pt);return}const S=ie(u,I);if(S.parseError){_(S.parseError);return}if(S.errors.length>0){h==null||h(),R==null||R(S.errors);return}p(S.payload)},G=S=>`text-xs transition-colors ${S?"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:[q.map(S=>t.jsx("button",{onClick:()=>{J(S.value),L(0)},className:G(!N&&Z===S.value),children:S.label},S.value)),t.jsx("button",{onClick:()=>J("custom"),className:G(N),children:"Other"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[D.cancel!==!1&&t.jsx("button",{onClick:g,className:"text-xs text-text-tertiary hover:text-status-error transition-colors",children:D.cancel??"Cancel escalation"}),t.jsx("div",{className:"flex-1"}),N&&t.jsx(es,{onChange:P,compact:!0,autoFocus:!0}),t.jsx("button",{onClick:ot,disabled:i||N&&K<=0,className:`btn-primary text-xs ${d?"animate-[field-shake_0.4s_ease-in-out]":""}`,"data-testid":"claim-button",children:i?"Claiming...":D.claim??"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:j?t.jsx(pe,{userId:j}):"unknown"})]}),k&&t.jsx(Vt,{until:k}),o&&t.jsx("span",{className:"text-xs text-status-error",children:o.message}),A&&t.jsx("p",{className:"text-xs text-text-tertiary","data-testid":"badge-prompt",children:"If this is your claim, scan your badge."}),T&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:O,className:"text-xs text-text-tertiary hover:text-accent transition-colors","data-testid":"admin-reassign",children:"Reassign…"}),t.jsx("button",{onClick:M,disabled:H,className:"text-xs text-text-tertiary hover:text-status-error transition-colors disabled:opacity-50","data-testid":"admin-unassign",children:H?"Returning…":"Return to queue"})]})]}),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:()=>n("resolve"),className:G(r==="resolve"),children:c?"Resolve":"Acknowledge"}),t.jsx("button",{onClick:()=>n("release"),className:`text-xs transition-colors ${r==="release"?"text-status-error font-medium":"text-text-tertiary hover:text-status-error"}`,children:D.release??"Release"}),D.cancel!==!1&&t.jsx("button",{onClick:g,className:"text-xs transition-colors text-text-tertiary hover:text-status-error",children:D.cancel??"Cancel"})]}),r==="resolve"&&t.jsxs("div",{className:"flex items-center gap-4",children:[E&&t.jsxs("p",{className:"text-sm text-text-secondary","data-testid":"acting-claim-note",children:["Claimed by you ",t.jsxs("span",{className:"font-medium text-text-primary",children:["(",E,")"]})]}),E&&k&&t.jsx(Vt,{until:k}),t.jsx("div",{className:"flex-1"}),w&&t.jsx("span",{className:"text-xs text-status-error",children:w}),o&&t.jsx("span",{className:"text-xs text-status-error",children:o.message}),V&&W&&t.jsx("span",{className:"text-xs text-status-pending","data-testid":"submit-guard-message",children:W}),t.jsx("button",{onClick:Nt,disabled:l||V,className:"btn-primary text-xs",children:l?c?"Submitting...":"Acknowledging...":x?"Send to Triage":D.submit??(c?"Submit":"Acknowledge")})]}),r==="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:()=>n("resolve"),className:"btn-secondary text-xs",children:"Back"}),t.jsx("button",{onClick:v,disabled:y,className:"btn-primary text-xs bg-status-error hover:bg-status-error/80",children:y?"Releasing...":"Yes, Release"})]})]})]})}function te({children:e}){return t.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:e})}function cr({payload:e,isTerminal:s,resolverPayload:r,onRetryTriage:n,isRetrying:a}){const i=e.title,d=e.summary,c=e.diagnosis,u=e.tool_calls_made,p=e.result,l=r==null?void 0:r._lt,o=(l==null?void 0:l.triaged)===!0,x=l==null?void 0:l.triageWorkflowId,b=s&&o,[v,y]=m.useState(!1);return b?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 u=="number"&&t.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-success/10 text-status-success",children:[u," 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}),c&&t.jsxs("div",{children:[t.jsx(te,{children:"Triage diagnosis"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Zt,{content:c})})]}),t.jsx("div",{className:"flex items-center gap-3",children:x&&t.jsx(jt,{to:`/workflows/executions/${x}`,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 u=="number"&&t.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-warning/10 text-status-warning",children:[u," 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(te,{children:"What happened"}),t.jsx("div",{className:"text-xs text-text-secondary leading-relaxed",children:t.jsx(Zt,{content:d})})]}),c&&t.jsxs("div",{children:[t.jsx(te,{children:"What went wrong"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Zt,{content:c})})]}),p!=null&&t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>y(!v),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 ${v?"rotate-90":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M4.5 2l4 4-4 4"})}),"Partial results"]}),v&&t.jsx("div",{className:"mt-2",children:t.jsx(Ot,{data:p,defaultMode:"tree"})})]}),n&&!s&&t.jsx("div",{className:"pt-2",children:t.jsxs("button",{onClick:n,disabled:a,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"})}),a?"Sending to triage...":"Retry with AI Triage"]})})]})]})}function Ve(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function ps({src:e,escalation:s,schema:r,onResolve:n,onEscalate:a,submitAttempted:i,fill:d}){const c=m.useRef(null),u=m.useRef("");m.useEffect(()=>{try{const l=new URL(e);u.current=l.origin}catch{u.current=""}},[e]);const p=m.useCallback(()=>{const l=c.current;if(!(l!=null&&l.contentWindow)||!u.current)return;const x={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:Ve(s.envelope),metadata:s.metadata??null,escalation_payload:Ve(s.escalation_payload)},schema:r};l.contentWindow.postMessage(x,u.current)},[s,r]);return m.useEffect(()=>{const l=o=>{if(o.origin!==u.current)return;const x=o.data;if(!(!x||typeof x!="object"||typeof x.type!="string"))switch(x.type){case"lt:ready":p();break;case"lt:submit":x.payload&&typeof x.payload=="object"&&n(x.payload);break;case"lt:escalate":typeof x.target=="string"&&x.target&&a(x.target);break;case"lt:resize":{const b=c.current;b&&typeof x.height=="number"&&x.height>0&&(b.style.height=`${Math.min(x.height,2e3)}px`);break}}};return window.addEventListener("message",l),()=>window.removeEventListener("message",l)},[p,n,a]),m.useEffect(()=>{if(!i)return;const l=c.current;l!=null&&l.contentWindow&&u.current&&l.contentWindow.postMessage({type:"lt:validate"},u.current)},[i]),d?t.jsx("div",{className:"absolute inset-0 overflow-hidden",children:t.jsx("iframe",{ref:c,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:p})}):t.jsx("div",{className:"rounded-md border border-surface-border overflow-hidden bg-white",children:t.jsx("iframe",{ref:c,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:p})})}const dr=2600;function ur({hint:e,onLockedClick:s,children:r}){const[n,a]=m.useState(null);m.useEffect(()=>{if(!n)return;const d=setTimeout(()=>a(null),dr);return()=>clearTimeout(d)},[n]);const i=d=>{if(s==null||s(),e){const c=Math.min(Math.max(d.clientX,96),window.innerWidth-96);a(u=>({x:c,y:d.clientY,n:((u==null?void 0:u.n)??0)+1}))}};return t.jsxs("div",{className:"pb-8 max-w-form",onClick:i,"data-testid":"locked-form-frame",children:[r,e&&n&&t.jsxs("div",{role:"status",className:"fixed z-[60] pointer-events-none flex items-center gap-2 px-3 py-1.5 rounded-md bg-surface-raised border border-surface-border shadow-lg text-xs font-medium text-text-primary whitespace-nowrap animate-[click-hint_2.6s_ease-in-out_both]",style:{left:n.x,top:n.y-12},onAnimationEnd:()=>a(null),"data-testid":"locked-form-hint",children:[t.jsx(Cn,{className:"w-3.5 h-3.5 text-accent shrink-0",strokeWidth:1.5}),e]},n.n)]})}function F({children:e,isRequired:s,htmlFor:r}){return t.jsxs("label",{htmlFor:r,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 X({id:e,children:s}){return t.jsx("p",{id:e,className:"text-2xs text-text-tertiary mt-0.5 leading-snug",children:s})}function ut({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 At(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 xr(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 pr({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const i=m.useRef(null),d=(n==null?void 0:n.accept)??void 0,c=Y(e,n),u=n==null?void 0:n.description,p=m.useCallback(o=>{var v;const x=(v=o.target.files)==null?void 0:v[0];if(!x)return;const b=new FileReader;b.onload=()=>{typeof b.result=="string"&&r(b.result)},b.readAsDataURL(x)},[r]),l=s.startsWith("data:");return t.jsxs("div",{children:[t.jsx(F,{isRequired:a,children:c}),u&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:u}),t.jsxs("div",{className:"mt-1",children:[t.jsx("input",{ref:i,type:"file",accept:d,onChange:p,className:"hidden"}),t.jsx("button",{type:"button",onClick:()=>{var o;return(o=i.current)==null?void 0:o.click()},className:"btn-secondary text-xs px-3 py-1.5",children:l?"Replace file":"Choose file"}),l&&t.jsx("span",{className:"ml-2 text-xs text-status-success",children:"File attached"})]})]})}function mr({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const i=Y(e,n),d=n==null?void 0:n.description,c=(n==null?void 0:n["x-lt-language"])??"",u=m.useCallback(p=>{if(p.key==="Tab"){p.preventDefault();const l=p.currentTarget,o=l.selectionStart,x=l.selectionEnd,b=s.substring(0,o)+" "+s.substring(x);r(b),requestAnimationFrame(()=>{l.selectionStart=l.selectionEnd=o+2})}},[s,r]);return t.jsxs("div",{children:[t.jsxs(F,{isRequired:a,children:[i,c&&t.jsx("span",{className:"ml-2 text-text-tertiary/60 normal-case font-normal",children:c})]}),d&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:d}),t.jsx("textarea",{value:s,onChange:p=>r(p.target.value),onKeyDown:u,className:"input w-full mt-1 font-mono text-xs leading-relaxed",rows:10,spellCheck:!1})]})}function fr({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const i=m.useRef(null),[d,c]=m.useState(!1),u=Y(e,n),p=n==null?void 0:n.description;m.useEffect(()=>{const y=i.current;if(!y)return;const g=y.getContext("2d");if(g&&(g.lineWidth=2,g.lineCap="round",g.strokeStyle="#1E1535",s&&s.startsWith("data:"))){const j=new Image;j.onload=()=>g.drawImage(j,0,0),j.src=s}},[]);const l=m.useCallback(y=>{const g=i.current,j=g.getBoundingClientRect(),k=j.width>0?g.width/j.width:1,h=j.height>0?g.height/j.height:1;return"touches"in y?{x:(y.touches[0].clientX-j.left)*k,y:(y.touches[0].clientY-j.top)*h}:{x:(y.clientX-j.left)*k,y:(y.clientY-j.top)*h}},[]),o=m.useCallback(y=>{var k;c(!0);const g=(k=i.current)==null?void 0:k.getContext("2d");if(!g)return;const j=l(y);g.beginPath(),g.moveTo(j.x,j.y)},[l]),x=m.useCallback(y=>{var k;if(!d)return;const g=(k=i.current)==null?void 0:k.getContext("2d");if(!g)return;const j=l(y);g.lineTo(j.x,j.y),g.stroke()},[d,l]),b=m.useCallback(()=>{c(!1);const y=i.current;y&&r(y.toDataURL("image/png"))},[r]),v=m.useCallback(()=>{const y=i.current;if(!y)return;const g=y.getContext("2d");g&&(g.clearRect(0,0,y.width,y.height),r(""))},[r]);return t.jsxs("div",{children:[t.jsx(F,{isRequired:a,children:u}),p&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:p}),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:o,onMouseMove:x,onMouseUp:b,onMouseLeave:b,onTouchStart:o,onTouchMove:x,onTouchEnd:b})}),t.jsx("button",{type:"button",onClick:v,className:"mt-1 text-2xs text-text-tertiary hover:text-accent transition-colors",children:"Clear"})]})}function gr({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const i=Y(e,n),d=n==null?void 0:n.description;return t.jsxs("div",{children:[t.jsx(F,{isRequired:a,children:i}),d&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:d}),t.jsx("textarea",{value:s,onChange:c=>r(c.target.value),className:"input w-full mt-1 text-sm leading-relaxed",rows:8,placeholder:"Supports plain text. Markdown formatting is preserved."})]})}function hr({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const[i,d]=m.useState("write"),c=Y(e,n),u=n==null?void 0:n.description;return(n==null?void 0:n.readOnly)===!0?t.jsx(Jt,{content:s,className:"my-1"}):t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(F,{isRequired:a,children:c}),t.jsx("div",{className:"flex items-center gap-0.5",children:["write","preview"].map(l=>t.jsx("button",{type:"button",onClick:()=>d(l),className:`px-2 py-0.5 text-2xs rounded transition-colors ${i===l?"bg-accent/10 text-accent font-semibold":"text-text-quaternary hover:text-text-secondary"}`,children:l==="write"?"Write":"Preview"},l))})]}),u&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:u}),i==="write"?t.jsx("textarea",{value:s,onChange:l=>r(l.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(Jt,{content:s}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"Nothing to preview."})})]})}const br=28;function yr({fieldKey:e,value:s,onChange:r,schema:n,escalationContext:a,isRequired:i,submitAttempted:d,error:c}){const u=(n==null?void 0:n["x-lt-require-all"])===!0,p=fe(n==null?void 0:n["x-lt-source"],a);let l={};try{s&&(l=JSON.parse(s))}catch{}const o=(()=>{const h=Yn(n,l,a);return h?JSON.stringify(h):null})();m.useEffect(()=>{o&&r(o)},[o]);const x=h=>r(JSON.stringify({...l,[h]:!l[h]})),b=Y(e,n),v=n==null?void 0:n.description;if(p.length===0)return t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"No checklist items. None of the field's x-lt-source paths resolved on this escalation."}),c&&t.jsx("p",{className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:c})]});const y=n==null?void 0:n["x-lt-variant"],g=y==="chips"||y==="rows"?y:u||p.some(h=>h.label.length>br)?"rows":"chips",j=p.filter(h=>l[h.id]).length,k=(p.find(h=>!l[h.id]&&h.required!==!1)??p[0]).id;return t.jsxs("div",{role:"group","aria-label":b,"aria-required":i||void 0,"aria-invalid":c?!0:void 0,children:[t.jsx(F,{isRequired:i,children:b}),v&&t.jsx(X,{children:v}),g==="chips"?t.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:p.map(h=>{const R=l[h.id]??!1,I=!R&&!!d&&j===0&&(h.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)] ${R?"bg-accent border-accent text-text-inverse":I?"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:R,onChange:()=>x(h.id),className:"sr-only","data-testid":`checklist-item-${h.id}`,...h.id===k?{"data-field-key":e}:{}}),R&&t.jsx(En,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:2.5}),h.label]},h.id)})}):t.jsx("div",{className:"space-y-2.5 mt-2",children:p.map(h=>{const R=l[h.id]??!1,I=!R&&!!d&&(u?h.required!==!1:j===0&&(h.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 ${I?"bg-status-error/5":"hover:bg-surface-hover"}`,children:[t.jsx("input",{type:"checkbox",checked:R,onChange:()=>x(h.id),className:`mt-0.5 w-3.5 h-3.5 shrink-0 rounded ${I?"accent-status-error":"accent-accent"}`,"data-testid":`checklist-item-${h.id}`,...h.id===k?{"data-field-key":e}:{}}),t.jsxs("span",{className:`text-sm leading-snug transition-colors ${I?"text-status-error":"text-text-secondary group-hover:text-text-primary"}`,children:[h.label,h.required&&t.jsx("span",{className:`ml-0.5 text-2xs ${I?"text-status-error":"text-text-quaternary"}`,children:"*"})]})]},h.id)})}),t.jsx("p",{className:"text-2xs text-text-quaternary mt-3 tabular-nums",children:g==="chips"?t.jsxs(t.Fragment,{children:[j," selected",i&&j===0&&!!d&&t.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(check at least one)"})]}):t.jsxs(t.Fragment,{children:[j," / ",p.length," confirmed",u?t.jsxs("span",{className:"ml-1 text-text-quaternary/60",children:["(all required",p.some(h=>h.required===!1)?" except optional":"",")"]}):i&&j===0&&!!d&&t.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(at least one required)"})]})}),c&&t.jsx("p",{role:"alert",className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:c})]})}const jr=/\.(png|jpe?g|gif|webp|avif|bmp|svg)(\?.*)?$/i;function Nr(e){var n,a,i,d;const s=e.trim();if(!s)return{kind:"none"};const r=(a=(n=/^data:([^;,]+)[;,]/.exec(s))==null?void 0:n[1])==null?void 0:a.toLowerCase();if(r)return r.startsWith("image/")?{kind:"image",src:s}:{kind:"file",href:s,label:r==="application/pdf"?"PDF":r,isData:!0};if(/^https?:\/\//i.test(s)){if(jr.test(s))return{kind:"image",src:s};const c=(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:c??"attachment",isData:!1}}return{kind:"none"}}function He({fieldKey:e,value:s,schema:r}){const[n,a]=m.useState(!1),i=Nr(s??""),d=e.replace(/[_-]/g," "),c=r==null?void 0:r.description,u=t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:d}),c&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:c})]});return i.kind==="none"?t.jsxs("div",{children:[u,t.jsx("p",{className:"text-xs text-text-quaternary italic mt-1",children:"No attachment"})]}):i.kind==="image"?t.jsxs("div",{children:[u,t.jsxs("div",{className:"mt-1",children:[t.jsx("button",{type:"button",onClick:()=>a(!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}`})}),n&&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:()=>a(!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:[u,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(An,{className:"w-3.5 h-3.5",strokeWidth:1.5}),i.isData?`Download ${i.label}`:`Open ${i.label}`,i.isData?t.jsx(Tn,{className:"w-3 h-3",strokeWidth:1.5}):t.jsx(re,{className:"w-3 h-3",strokeWidth:1.5})]})})]})}function vr({fieldKey:e,schema:s,escalationContext:r}){const n=(s==null?void 0:s["x-lt-href"])??"",a=n&&r?it(n,r):n,i=(s==null?void 0:s.title)??(s==null?void 0:s.description)??"Open",d=s==null?void 0:s.description,c=a.startsWith("/"),u=!a.trim();return t.jsxs("div",{"data-field-key":e,children:[t.jsx(F,{children:i}),d&&t.jsx(X,{children:d}),t.jsx("div",{className:"mt-1",children:u?t.jsx("span",{className:"text-xs text-text-quaternary italic",children:"No link configured"}):c?t.jsxs(jt,{to:a,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(re,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}):t.jsxs("a",{href:a,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(re,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]})})]})}function ms({to:e,className:s=""}){return t.jsxs(jt,{to:e,title:"View details",tabIndex:-1,className:`inline-flex items-center justify-center w-6 h-6 shrink-0 rounded border border-surface-border text-accent/70 hover:text-accent hover:border-accent/60 hover:bg-accent/5 transition-colors ${s}`,children:[t.jsx(Rn,{className:"w-3.5 h-3.5",strokeWidth:2}),t.jsx("span",{className:"sr-only",children:"View details"})]})}const Be="—";function wr(e,s){if(!e||!s)return"";const r=e.indexOf(".");if(r===-1)return"";const n=e.slice(0,r),a=e.slice(r+1);try{const i=ue(s[n],a);return typeof i=="string"?i:""}catch{return""}}function kr(e,s){if(!e||e===Be)return Be;if(s==="age"){const r=new Date(e);return Number.isNaN(r.getTime())?e:le(e)}return e}function _r({fieldKey:e,schema:s,escalationContext:r}){const n=s==null?void 0:s["x-lt-source"],a=(s==null?void 0:s["x-lt-fields"])??[],i=(s==null?void 0:s.title)??"Linked escalation",d=s==null?void 0:s.description,c=wr(n,r),{data:u,isLoading:p,isError:l}=Ye(c);return t.jsxs("div",{"data-field-key":e,children:[t.jsx(F,{children:i}),d&&t.jsx(X,{children:d}),t.jsx("div",{className:"mt-1",children:!c||l?t.jsx("p",{className:"text-xs text-text-quaternary italic","data-testid":`escalation-widget-empty-${e}`,children:"No linked record"}):p?t.jsx(Er,{}):u?t.jsx(Cr,{esc:u,fields:a,fieldKey:e}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"No linked record"})})]})}function Cr({esc:e,fields:s,fieldKey:r}){if(!e)return null;const n=xe(e);return t.jsxs("div",{className:"border-l-2 border-accent-faint pl-3 py-2 space-y-2","data-testid":`escalation-widget-card-${r}`,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(as,{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(a=>{const i=it(a.value,n),d=kr(i,a.format);return t.jsxs("div",{className:"contents",children:[t.jsx("dt",{className:"text-2xs text-text-tertiary whitespace-nowrap",children:a.label}),t.jsx("dd",{className:"text-2xs text-text-primary",children:d})]},a.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," · ",le(e.created_at)]}),t.jsx(ms,{to:`/escalations/detail/${e.id}`})]})]})}function Er(){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"})]})}function Ar(e,s){if(!e)return{};const r={};for(const[n,a]of Object.entries(e))r[n]=typeof a=="string"?it(a,s):a;return r}function fs(e,s,r){const n=Ar(e.facets,s),a={role:e.role,status:e.status??"pending",facets:n,limit:e.limit,enabled:!!(e.role||Object.keys(n).length)};return e.assigned==="me"?{...a,assigned_to:r,available:!1,enabled:a.enabled&&!!r}:e.assigned==="any"?a:{...a,available:e.available??!0}}const Tr=[{label:"Description",value:"{{escalation.description}}"},{label:"Role",value:"{{escalation.role}}"},{label:"Age",value:"{{escalation.created_at}}",format:"age"}],ze="—";function Rr(e,s){if(!e||e===ze)return ze;if(s==="age"){const r=new Date(e);return Number.isNaN(r.getTime())?e:le(e)}return e}function oe(e,s){return typeof e=="string"?it(e,s):Array.isArray(e)?e.map(r=>oe(r,s)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,n])=>[r,oe(n,s)])):e}function Or({fieldKey:e,schema:s,escalationContext:r}){const n=(s==null?void 0:s["x-lt-query"])??{},a=(s==null?void 0:s["x-lt-columns"])??Tr,i=(s==null?void 0:s["x-lt-actions"])??[],d=(s==null?void 0:s.title)??"Related items",c=s==null?void 0:s.description,u=r??{},{user:p}=ce(),l=fs(n,u,p==null?void 0:p.userId),{data:o,isLoading:x}=Ze({role:l.role,status:l.status,facets:l.facets,assigned_to:l.assigned_to,available:l.available,limit:l.limit??5,enabled:l.enabled,include:pn({columns:a,actions:i})?"envelope":void 0}),b=(o==null?void 0:o.escalations)??[],v=Ke(),[y,g]=m.useState({}),[j,k]=m.useState(null),h=async(R,I)=>{const D=xe(R);if(!(I.confirm&&!window.confirm(it(I.confirm,D)))){k(R.id),g($=>({...$,[R.id]:""}));try{await v.mutateAsync({id:R.id,resolverPayload:oe(I.resolverPayload,D)})}catch($){g(W=>({...W,[R.id]:$.message}))}finally{k(null)}}};return t.jsxs("div",{"data-field-key":e,children:[t.jsx(F,{children:d}),c&&t.jsx(X,{children:c}),t.jsx("div",{className:"mt-1","data-testid":`escalation-list-widget-${e}`,children:x?t.jsx(Ir,{columns:a.length}):t.jsx(Mr,{escalations:b,columns:a,fieldKey:e,actions:i,onAction:h,pendingRow:j,rowErrors:y})})]})}function Mr({escalations:e,columns:s,fieldKey:r,actions:n,onAction:a,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-${r}`,children:"No items found"}):t.jsxs("table",{className:"w-full text-xs border-collapse","data-testid":`escalation-list-table-${r}`,children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-surface-border",children:[s.map(c=>t.jsx("th",{className:"text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary pb-1 pr-3 last:pr-0",children:c.label},c.label)),n.length>0&&t.jsx("th",{className:"w-px"}),t.jsx("th",{className:"w-8"})]})}),t.jsx("tbody",{children:e.map(c=>{const u=xe(c),p=d[c.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(l=>{const o=it(l.value,u),x=Rr(o,l.format);return t.jsx("td",{className:"py-1 pr-3 last:pr-0 text-text-primary align-top",children:x},l.label)}),n.length>0&&t.jsxs("td",{className:"py-1 pr-2 align-top whitespace-nowrap",children:[n.map(l=>t.jsx("button",{type:"button",onClick:()=>a(c,l),disabled:i===c.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-${c.id}`,children:l.label},l.label)),p&&t.jsx("p",{className:"text-2xs text-status-error mt-0.5 whitespace-normal max-w-[16rem]","data-testid":`escalation-list-action-error-${c.id}`,children:p})]}),t.jsx("td",{className:"py-1 pl-2 align-top",children:t.jsx(ms,{to:`/escalations/detail/${c.id}`})})]},c.id)})})]})}function Ir({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},(r,n)=>t.jsx("div",{className:"h-3 bg-surface-sunken rounded flex-1"},n))},s))})}const ee={"file-upload":pr,"code-editor":mr,signature:fr,"rich-text":gr,markdown:hr,checklist:yr,attachment:He,image:He,link:vr,escalation:_r,"escalation-list":Or};function gs({fieldKey:e,value:s,onChange:r,onBlur:n,schema:a,isRequired:i,isReadOnly:d,error:c,escalationContext:u,submitAttempted:p}){var W;const l=(W=a==null?void 0:a.properties)==null?void 0:W[e],o=Y(e,l),x=l==null?void 0:l["x-lt-widget"],b=`lt-field-${e}`,v=`${b}-error`,y=`${b}-help`,g=typeof(l==null?void 0:l.description)=="string"&&l.description.length>0?l.description:void 0,h={id:b,"aria-required":i||void 0,"aria-invalid":c?!0:void 0,"aria-describedby":c?v:g!==void 0?y:void 0},R=x==="markdown"&&typeof s=="string",I=(x==="attachment"||x==="image")&&typeof s=="string",D=!!(x&&x in ee);if(d&&!R&&!I&&!D){const E=s===null?"null":typeof s=="object"?JSON.stringify(s,null,2):String(s);return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,children:o}),t.jsx("p",{className:"text-sm text-text-secondary mt-0.5 whitespace-pre-wrap",children:E})]})}if(x&&x in ee){const E=ee[x],A=i||(l==null?void 0:l["x-lt-require-all"])===!0,T={fieldKey:e,schema:l,escalationContext:u,isRequired:A,submitAttempted:p,error:c};if((l==null?void 0:l.type)==="object"){const O=typeof s=="string"?s:typeof s=="object"&&s!==null&&!Array.isArray(s)?JSON.stringify(s):"";return t.jsx(E,{...T,value:O,onChange:M=>{try{r(JSON.parse(M))}catch{r(M)}}})}if(typeof s=="string")return t.jsx(E,{...T,value:s,onChange:O=>r(O)});if(typeof s=="object"&&s!==null&&!Array.isArray(s))return t.jsx(E,{...T,value:JSON.stringify(s),onChange:O=>{try{r(JSON.parse(O))}catch{r(O)}}})}const $=ds(l,u);if($&&(s===null||typeof s=="string"||typeof s=="number")){const E=s===null?"":String(s),A=$.some(T=>String(T.value)===E);return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:b,children:o}),g&&t.jsx(X,{id:y,children:g}),t.jsxs("select",{value:A?E:"",disabled:$.length===0,onChange:T=>{const O=$.find(M=>String(M.value)===T.target.value);r(O?O.value:T.target.value)},onBlur:n,"data-field-key":e,className:xr(!!c),...h,children:[!A&&t.jsx("option",{value:"",disabled:!0,children:"Choose…"}),$.map(T=>t.jsx("option",{value:String(T.value),children:T.label},String(T.value)))]}),t.jsx(ut,{error:c,id:v})]})}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:E=>{r(E.target.checked),n==null||n()},className:"w-3.5 h-3.5 rounded accent-accent","data-field-key":e,...h}),t.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[o,i&&t.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})]}),g&&t.jsx(X,{id:y,children:g}),t.jsx(ut,{error:c,id:v})]});if(typeof s=="number")return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:b,children:o}),g&&t.jsx(X,{id:y,children:g}),t.jsx("input",{type:"number",value:s,onChange:E=>r(parseFloat(E.target.value)||0),onBlur:n,step:"any","data-field-key":e,className:`${At(!!c)} max-w-48`,...h}),t.jsx(ut,{error:c,id:v})]});if(typeof s=="string"){if((l==null?void 0:l.format)==="password")return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:b,children:o}),g&&t.jsx(X,{id:y,children:g}),t.jsx("input",{type:"password",value:s,onChange:M=>r(M.target.value),onBlur:n,"data-field-key":e,className:At(!!c),autoComplete:"off",...h}),t.jsx(ut,{error:c,id:v})]});const A=l==null?void 0:l.format,T={date:"date","date-time":"datetime-local",email:"email",uri:"url"},O={date:"max-w-48","date-time":"max-w-64"};if(A&&A in T)return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:b,children:o}),g&&t.jsx(X,{id:y,children:g}),t.jsx("input",{type:T[A],value:s,onChange:M=>r(M.target.value),onBlur:n,"data-field-key":e,className:`${At(!!c)} ${O[A]??""}`,...h}),t.jsx(ut,{error:c,id:v})]});if(A==="textarea"||s.length>80){const M=l==null?void 0:l.maxLength,H=l==null?void 0:l["x-lt-max-length"];let q=M;if(q===void 0&&H&&u){const J=H.indexOf(".");if(J!==-1){const K=H.slice(0,J),L=H.slice(J+1),w=u[K];if(w&&typeof w=="object"){let _=w;for(const N of L.split("."))if(_=_[N],_===void 0)break;if(typeof _=="number")q=_;else if(typeof _=="string"){const N=Number(_);Number.isNaN(N)||(q=N)}}}}const Z=q!==void 0&&s.length>q;return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:b,children:o}),g&&t.jsx(X,{id:y,children:g}),t.jsx("textarea",{value:s,onChange:J=>{r(J.target.value),n==null||n()},onBlur:n,"data-field-key":e,className:`${At(!!c)} leading-relaxed`,rows:Math.min(6,Math.max(3,Math.ceil(s.length/60))),...h}),q!==void 0&&t.jsxs("p",{className:`text-2xs mt-0.5 text-right tabular-nums ${Z?"text-status-error font-medium":"text-text-quaternary"}`,children:[s.length," / ",q]}),t.jsx(ut,{error:c,id:v})]})}return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:b,children:o}),g&&t.jsx(X,{id:y,children:g}),t.jsx("input",{type:"text",value:s,onChange:M=>r(M.target.value),onBlur:n,"data-field-key":e,className:At(!!c),...h}),t.jsx(ut,{error:c,id:v})]})}if(s===null)return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,children:o}),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:o}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:s.map((E,A)=>t.jsx("span",{className:"px-2 py-0.5 text-2xs font-mono bg-surface-sunken rounded text-text-secondary",children:String(E)},A))})]});if(typeof s=="object"){const E=Object.entries(s);return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,children:o}),t.jsx("div",{className:"ml-4 mt-2 pl-4 border-l border-accent-faint space-y-3",children:E.map(([A,T])=>t.jsx(gs,{fieldKey:A,value:T,onChange:O=>r({...s,[A]:O})},A))})]})}return null}function Sr({items:e,columns:s=1}){if(e.length===0)return null;const r=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 ${r} items-baseline gap-x-6 @dict-pairs:gap-x-8 gap-y-1.5`,children:e.map(({key:n,label:a,value:i})=>t.jsxs(m.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:a}),t.jsx("dd",{className:"text-sm text-text-primary break-words min-w-0","data-field-key":n,children:Dr(i)})]},n))})})}function Dr(e){return e==null||e===""?"—":typeof e=="boolean"?e?"Yes":"No":typeof e=="object"?JSON.stringify(e):String(e)}const se="dictionary",$r=new Set(["markdown","attachment","image"]);function hs(e,s){if(!s)return;const r=e==null?void 0:e["x-lt-section-options"],n=r==null?void 0:r[s];return n&&typeof n=="object"?n:void 0}function Lr(e,s,r){var c,u;const n=(c=e==null?void 0:e.properties)==null?void 0:c[r];if((n==null?void 0:n.readOnly)!==!0)return!1;const a=n==null?void 0:n["x-lt-widget"];if(typeof a=="string"&&$r.has(a))return!1;const i=n==null?void 0:n["x-lt-display"];if(typeof i=="string")return i===se;const d=(u=hs(e,s))==null?void 0:u.display;return typeof d=="string"?d===se:(e==null?void 0:e["x-lt-display"])===se}function Pr(e,s,r,n){var i;const a=[];for(const d of e){const[c]=d,u=a[a.length-1];if(Lr(s,r,c)){(u==null?void 0:u.kind)==="dictionary"?u.entries.push(d):a.push({kind:"dictionary",entries:[d]});continue}const p=(i=s==null?void 0:s.properties)==null?void 0:i[c],l=p==null?void 0:p["x-lt-column-group"];if(n==="two-column"&&typeof l=="string"&&l.trim()){(u==null?void 0:u.kind)==="column-group"&&u.name===l?u.entries.push(d):a.push({kind:"column-group",name:l,entries:[d]});continue}a.push({kind:"field",entry:d})}return a}function Fr({name:e,entries:s,formSchema:r,layout:n,renderField:a}){const i=Pr(s,r,e,n),d=hs(r,e),c=(d==null?void 0:d.columns)??(n==="two-column"?2:1),u=l=>l.map(([o,x])=>{var b;return{key:o,label:Y(o,(b=r==null?void 0:r.properties)==null?void 0:b[o]),value:x}}),p=()=>i.map((l,o)=>l.kind==="dictionary"?t.jsx("div",{className:n==="two-column"?"col-span-full":"",children:t.jsx(Sr,{items:u(l.entries),columns:c})},`dict-${o}`):l.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:l.entries.map(x=>a(x))})},`group-${l.name}-${o}`):a(l.entry));return t.jsxs("div",{className:e?"border border-surface-border bg-surface-sunken rounded-[var(--lt-radius-section)] 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}),n==="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:p()})}):t.jsx("div",{className:"space-y-5",children:p()})]})}function bs({value:e,onChange:s,disabled:r,submitAttempted:n,escalationContext:a,onOpenHelp:i,onDisabledClick:d,disabledHint:c}){var K,L;const[u,p]=m.useState({}),[l,o]=m.useState({}),[x,b]=m.useState(null),[v,y]=m.useState(!1),[g,j]=m.useState(new Set);m.useEffect(()=>{try{const w=JSON.parse(e);if(typeof w=="object"&&w!==null&&!Array.isArray(w)){const _={},N={};for(const[P,V]of Object.entries(w))P.startsWith("_")?N[P]=V:_[P]=V;p(_),o(N),b(N._form_schema&&typeof N._form_schema=="object"?N._form_schema:null),y(!1)}}catch{y(!0)}},[e]);const k=m.useCallback(w=>{p(w),s(JSON.stringify({...w,...l},null,2))},[l,s]),h=m.useCallback((w,_)=>{k({...u,[w]:_})},[u,k]),R=m.useCallback(w=>{j(_=>{if(_.has(w))return _;const N=new Set(_);return N.add(w),N})},[]);if(v)return t.jsx("p",{className:"text-xs text-status-error",children:"Unable to parse resolver data as form. Use the JSON editor below."});const I=Object.entries(u);if(I.length===0)return t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No resolver fields defined."});const D=x==null?void 0:x["x-lt-order"],$=D?[...I].sort((w,_)=>{const N=D.indexOf(w[0]),P=D.indexOf(_[0]);return(N===-1?1/0:N)-(P===-1?1/0:P)}):I,W={...a??{},resolver:u},E=$.filter(([w,_])=>{var P;const N=(P=x==null?void 0:x.properties)==null?void 0:P[w];return!(!Ut(N==null?void 0:N["x-lt-showIf"],W)||(N==null?void 0:N["x-lt-hide-if-empty"])===!0&&(_==null||_===""||_===!1||_===0))}),A=new Set((x==null?void 0:x.required)??[]),T=x==null?void 0:x["x-lt-layout"],O=x==null?void 0:x.title,M=x==null?void 0:x.description,H=typeof(x==null?void 0:x["x-lt-help"])=="string"||typeof(x==null?void 0:x["x-lt-context"])=="string",q=[];for(const w of E){const[_]=w,N=(K=x==null?void 0:x.properties)==null?void 0:K[_],P=((L=N==null?void 0:N["x-lt-section"])==null?void 0:L.trim())||null,V=q[q.length-1];!V||V.name!==P?q.push({name:P,entries:[w]}):V.entries.push(w)}const Z=([w,_])=>{var S;const N=(S=x==null?void 0:x.properties)==null?void 0:S[w],P=(N==null?void 0:N.readOnly)===!0,V=(N==null?void 0:N["x-lt-span"])??1,ot=A.has(w),Nt=g.has(w)||!!n,G=us(_,N,ot,Nt,W);return t.jsx("div",{className:`animate-[field-enter_0.2s_ease-out] ${T==="two-column"&&V>=2?"col-span-full":""}`,children:t.jsx(gs,{fieldKey:w,value:_,onChange:pt=>h(w,pt),onBlur:()=>R(w),schema:x,isRequired:ot,isReadOnly:P,error:G,escalationContext:W,submitAttempted:!!n})},w)},J=t.jsxs("div",{className:r?"pointer-events-none":void 0,inert:r||void 0,"aria-disabled":r||void 0,children:[O&&t.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.jsx("h3",{className:"heading-3",children:O}),H&&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(is,{className:"w-4 h-4",strokeWidth:1.5})})]}),M&&t.jsx("p",{className:"text-sm text-text-secondary leading-relaxed mb-6",children:M}),t.jsx("div",{className:"space-y-8",children:q.map((w,_)=>t.jsx(Fr,{name:w.name,entries:w.entries,formSchema:x,layout:T,renderField:Z},w.name??`__s${_}`))})]});return r?t.jsx(ur,{hint:c,onLockedClick:d,children:J}):t.jsx("div",{className:"pb-8 max-w-form",children:J})}function Wr({json:e,onJsonChange:s,requestTriage:r,onRequestTriageChange:n,triageNotes:a,onTriageNotesChange:i,disabled:d=!1,submitAttempted:c=!1,showTriage:u=!1,escalationContext:p,onOpenHelp:l,onDisabledClick:o,disabledHint:x}){return t.jsxs(t.Fragment,{children:[u&&t.jsx("div",{className:"flex items-center justify-between mb-3",children:r?t.jsxs("button",{onClick:()=>n(!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:()=>n(!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:r?"pointer-events-none select-none":"",children:t.jsx(bs,{value:e,onChange:s,disabled:d,submitAttempted:c,escalationContext:p,onOpenHelp:l,onDisabledClick:o,disabledHint:x})}),r&&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:a,onChange:b=>i(b.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 ys(e,s){if(!e.includes("{"))return e;try{const r=a=>{if(!a)return{};try{return JSON.parse(a)}catch{return{}}},n={...s.metadata??{},...r(s.envelope),...r(s.escalation_payload)};return e.replace(/\{([^}]+)\}/g,(a,i)=>Object.prototype.hasOwnProperty.call(n,i)?String(n[i]):`{${i}}`)}catch{return e}}function Xe(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function xt(e,s){return{escalation:e,metadata:e.metadata??null,envelope:Xe(e.envelope),payload:Xe(e.escalation_payload),resolver:null,...s?{lookup:s}:{}}}function qr({isRoundsExhausted:e,payloadObj:s,isTerminal:r,resolverPayload:n,onRetryTriage:a,isRetrying:i}){return t.jsxs(t.Fragment,{children:[e&&s&&t.jsx("div",{className:"mt-8",children:t.jsx(cr,{payload:s,isTerminal:r,resolverPayload:n,onRetryTriage:a,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($e,{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(jt,{to:"/credentials",className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[t.jsx($e,{size:12}),"Go to Credentials"]})]})]})]})}function Ur({esc:e,resolverPayload:s,isTerminal:r,claimedByMe:n,activeView:a,metadataFormSchema:i,effectiveSchema:d,lookup:c,json:u,onJsonChange:p,requestTriage:l,onRequestTriageChange:o,triageNotes:x,onTriageNotesChange:b,onResolve:v,onEscalate:y,onClaim:g,submitAttempted:j,isCertified:k,hasAI:h,onOpenHelp:R,onDisabledClick:I,disabledHint:D}){const $=d,W=xt(e,c);if(r){if(s==null)return null;const O=typeof s=="object"&&s!==null?s:{},M=d??i,H=M!=null&&M.properties?{...rs(O,M),_form_schema:M}:O;return t.jsx("div",{className:"mt-3",children:t.jsx(bs,{value:JSON.stringify(H,null,2),onChange:()=>{},disabled:!0,escalationContext:W,disabledHint:D})})}if(a!=="resolve"||!(e.workflow_type||d))return null;const E=$==null?void 0:$["x-lt-viewport"],A=(E==null?void 0:E.type)==="iframe"&&!!E.src&&v&&y;if(A&&!n)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(On,{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 T=A?ys(E.src,e):"";return t.jsx("div",{className:"mt-3",children:A?t.jsx(ps,{src:T,escalation:e,schema:$,onResolve:v,onEscalate:y,submitAttempted:j}):t.jsx(Wr,{json:u,onJsonChange:p,requestTriage:l,onRequestTriageChange:o,triageNotes:x,onTriageNotesChange:b,disabled:!n,submitAttempted:j,showTriage:!!k&&!!h,escalationContext:W,onOpenHelp:R,onDisabledClick:I,disabledHint:D})})}function Jr({open:e,assignedUntil:s,onClose:r,onExtend:n,isPending:a}){const i=ts(),[d,c]=m.useState("30"),[u,p]=m.useState(0),l=d==="custom",o=l?u:parseInt(d),x=m.useCallback(b=>p(b),[]);return t.jsx(ss,{open:e,onClose:r,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(Vt,{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:b=>{c(b.target.value),p(0)},className:"select w-full text-sm","aria-label":"Extension duration",children:[i.map(b=>t.jsx("option",{value:b.value,children:b.label},b.value)),t.jsx("option",{value:"custom",children:"Other..."})]}),l&&t.jsx(es,{onChange:x,autoFocus:!0}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:r,className:"btn-secondary text-xs",children:"Dismiss"}),t.jsx("button",{onClick:()=>n(o),className:"btn-primary text-xs",disabled:a||!o||o<=0,children:a?"Extending...":"Extend Claim"})]})]})})}const Vr=9e4;function Hr(e,s=Vr){const[,r]=m.useState(0);if(m.useEffect(()=>{if(!e)return;const a=new Date(e).getTime()-Date.now();if(a<=0)return;const i=()=>r(u=>u+1),d=[],c=a-s;return c>0&&d.push(window.setTimeout(i,c)),d.push(window.setTimeout(i,a)),()=>d.forEach(u=>window.clearTimeout(u))},[e,s]),!e)return{expired:!1,expiringSoon:!1,msRemaining:0};const n=Math.max(0,new Date(e).getTime()-Date.now());return{expired:n<=0,expiringSoon:n>0&&n<=s,msRemaining:n}}const Br="lt:escalation:draft:";function ge(e){return`${Br}${e}`}function zr(e){try{return localStorage.getItem(ge(e))}catch{return null}}function Xr(e,s){try{localStorage.setItem(ge(e),s)}catch{}}function ne(e){try{localStorage.removeItem(ge(e))}catch{}}const Gr="x-lt-transition",Qr="x-lt-transition-message",Yr="x-lt-transition-max-wait-seconds",Zr="x-lt-transition-done",Kr="Submitted. Preparing your next step…",ta=30,ea=5,sa=300;function na(e){const s=typeof e=="number"?e:Number(e);return!Number.isFinite(s)||s<=0?ta:Math.min(sa,Math.max(ea,Math.round(s)))}function Ge(e){if(!e||!e[Gr])return null;const s=e[Qr];return{message:typeof s=="string"&&s.trim().length>0?s:Kr,maxWaitSeconds:na(e[Yr])}}function ra(e){const s=e==null?void 0:e[Zr];return typeof s=="string"&&s.trim().length>0?s:null}const aa="x-lt-submit-on-claim";function ia(e){return!!(e!=null&&e[aa])}const oa="x-lt-submit-guard",la="{{count}} related items are still pending";function ca(e){const s=e==null?void 0:e[oa];if(!s||typeof s!="object"||Array.isArray(s))return;const r=s;if(!(!r.query||typeof r.query!="object"))return r}function da(e,s){const{user:r}=ce(),n=fs((e==null?void 0:e.query)??{},s??{},r==null?void 0:r.userId),{data:a,isSuccess:i}=Ze({role:n.role,status:n.status,facets:n.facets,assigned_to:n.assigned_to,available:n.available,limit:1,enabled:!!e&&n.enabled}),d=!!e&&e.mustBeEmpty!==!1&&n.enabled,c=(a==null?void 0:a.total)??0,u=d&&i&&c===0,p=d&&!u;let l="";if(p)if(c>0){const o=(e==null?void 0:e.message)??la;l=it(o.replace(/\{\{count\}\}/g,String(c)),s??{})}else l="Checking related items…";return{blocked:p,count:c,message:l,confirmedEmpty:u}}function ua({open:e,message:s}){return e?rn.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(Jt,{content:s})})]})]}),document.body):null}const js="lt:escalation:panel:open";function xa(){try{const e=localStorage.getItem(js);return e===null?!0:e==="true"}catch{return!0}}function Tt(e){try{localStorage.setItem(js,String(e))}catch{}}function Rt(e){if(!e)return null;try{return JSON.parse(e)}catch{return e}}function La(){const{id:e}=an();return t.jsx(pa,{id:e},e)}function pa({id:e}){var Ee,Ae,Te,Re,Oe;const{user:s,isSuperAdmin:r,hasRoleType:n}=ce(),a=r||n("admin"),{identity:i}=Js(),d=Vs(),c=(i==null?void 0:i.actorId)??(s==null?void 0:s.userId),u=de(),p=ns(),l=Qe(),{data:o,isLoading:x,refetch:b,isFetching:v}=Ye(e);fn(e);const y=m.useMemo(()=>{if(!(o!=null&&o.envelope))return!1;try{const f=JSON.parse(o.envelope);return Array.isArray(f==null?void 0:f.lookups)&&f.lookups.length>0}catch{return!1}},[o==null?void 0:o.envelope]),{data:g}=Hs(e,y),j=m.useMemo(()=>{var f;return(f=g==null?void 0:g.lookups)!=null&&f.length?Object.fromEntries(g.lookups.filter(C=>!C.missing).map(C=>[C.as??C.key,C.data])):null},[g]),k=Bs(),h=Ke(),R=zs(),I=Xs(),D=Gs(),$=Qs(),[W,E]=m.useState(!1),[A,T]=m.useState(!1),{data:O}=mn(),{data:M}=Ys(),{isBuilder:H}=Zs(),q=O==null?void 0:O.find(f=>f.workflow_type===(o==null?void 0:o.workflow_type)),Z=((Ee=M==null?void 0:M.telemetry)==null?void 0:Ee.traceUrl)??null,[J,K]=m.useState("resolve"),[L,w]=m.useState("{}"),[_,N]=m.useState(xa),[P,V]=m.useState(!1),[ot,Nt]=m.useState(""),[G,S]=m.useState(!1),[pt,vt]=m.useState([]),[Ns,vs]=m.useState(0),[ws,wt]=m.useState(void 0),[tt,Ht]=m.useState(null),[ks,he]=m.useState(!1),be=m.useRef(!1),Mt=m.useRef(null),ye=m.useRef(!1),It=m.useRef(null),_s=Hr(o==null?void 0:o.assigned_until),[Cs,Es]=m.useState(null);m.useEffect(()=>{if(!(!G||!o))try{const f=JSON.parse(L),C=f._form_schema;if(!C){vt([]);return}vt(xs(C,f,xt(o,j)))}catch{}},[L,G,o]);const St=((Ae=o==null?void 0:o.metadata)==null?void 0:Ae.form_schema)??null,mt=(o==null?void 0:o.form_schema)??(q==null?void 0:q.resolver_schema)??null,U=St??mt,je=ia(U),et=en(U),kt=ca(U),_t=da(kt,o?xt(o,j):void 0),Dt=m.useRef(!1),$t=m.useRef(null);m.useEffect(()=>{if(Dt.current)return;const f=St??(mt!=null&&mt.properties?mt:null);if(f!=null&&f.properties){Dt.current=!0;const C=Rt(o==null?void 0:o.envelope),B=C==null?void 0:C.formDefaults,Q={...(o==null?void 0:o.metadata)??{},...typeof B=="object"&&B!==null?B:{}},ct=rs(Q,f),rt={_form_schema:f};for(const[Ie,Ps]of Object.entries(f.properties)){const Se=Ps,Fs=Se.type==="object"?{}:"";rt[Ie]=ct[Ie]??Se.default??Fs}$t.current=JSON.stringify(rt,null,2);const Me=!((o==null?void 0:o.status)==="resolved"||(o==null?void 0:o.status)==="cancelled")&&(o!=null&&o.id)?zr(o.id):null,Ft=Me?Rt(Me):null;Ft&&typeof Ft=="object"&&!Array.isArray(Ft)?w(JSON.stringify({...Ft,_form_schema:f},null,2)):w($t.current)}else U&&(Dt.current=!0,w(JSON.stringify(U,null,2)))},[U,St,mt,o==null?void 0:o.envelope,o==null?void 0:o.metadata,o==null?void 0:o.id,o==null?void 0:o.status]),m.useEffect(()=>{if(!Dt.current||$t.current===null||!(o!=null&&o.id)||o.status!=="pending")return;const f=o.id,C=window.setTimeout(()=>{L===$t.current?ne(f):Xr(f,L)},400);return()=>window.clearTimeout(C)},[L,o==null?void 0:o.id,o==null?void 0:o.status]),m.useEffect(()=>{if(!tt)return;const f=window.setTimeout(async()=>{var B;try{const Q=new URLSearchParams({parent_id:e,assigned_to:c??"",status:"pending",limit:"1"}),ct=await yt(`/escalations?${Q}`),rt=(B=ct==null?void 0:ct.escalations)==null?void 0:B[0];if(rt!=null&&rt.id&&rt.parent_id===e){Ht(null),u(`/escalations/detail/${rt.id}`);return}}catch{}Ht(null),l.resetQueries({queryKey:["escalations"]}),l.resetQueries({queryKey:["escalationStats"]});const C=tt.doneDest;C?C.startsWith("/")?u(C):window.location.assign(C):u(-1)},tt.maxWaitSeconds*1e3);return()=>window.clearTimeout(f)},[tt,e,c,u,l]),m.useEffect(()=>{var f,C;be.current||(f=p.state)!=null&&f.autoStart&&(!o||o.status!=="pending"||qt(o)||L!=="{}"&&(be.current=!0,(C=Mt.current)==null||C.call(Mt)))},[o,L,p.state]),m.useEffect(()=>{var f;ye.current||!(kt!=null&&kt.autoResolveWhenEmpty)||!_t.confirmedEmpty||!o||o.status!=="pending"||!qt(o)||o.assigned_to===c&&L!=="{}"&&(ye.current=!0,(f=It.current)==null||f.call(It))},[_t.confirmedEmpty,kt,o,L,c]);const As=(o==null?void 0:o.subtype)==="rounds_exhausted";if(x)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(!o)return t.jsx("p",{className:"text-sm text-text-secondary",children:"Escalation not found."});const Bt=qt(o),st=Bt&&o.assigned_to===c,Ne=Bt&&!st,ft=o.status==="resolved"||o.status==="cancelled",lt=U==null?void 0:U["x-lt-viewport"],zt=(lt==null?void 0:lt.type)==="iframe"&&!!(lt!=null&&lt.src)&&st&&!ft,Lt=Rt(o.escalation_payload),gt=Rt(o.resolver_payload),Pt=Rt(o.envelope),Ts=!!((Te=Pt==null?void 0:Pt.metadata)!=null&&Te.certified),ve=Ks(),we=ve!==null?ve:!!((Re=M==null?void 0:M.ai)!=null&&Re.enabled),nt=typeof Lt=="object"&&Lt!==null&&!Array.isArray(Lt)?Lt:null,Rs=nt==null?void 0:nt._triage,Os=typeof gt=="object"&&gt!==null&&!Array.isArray(gt)?gt:null,Xt=ft?"terminal":st?"claimed_by_me":Ne?"claimed_by_other":"available",Ms=Xt==="available"?`${typeof et.claim=="string"?et.claim:"Claim"} this escalation to edit the form`:Xt==="claimed_by_other"?t.jsxs(t.Fragment,{children:["Claimed by ",o.assigned_to?t.jsx(pe,{userId:o.assigned_to}):"another user"]}):o.status==="cancelled"?"This escalation is cancelled":o.status==="resolved"?"This escalation is resolved — the submitted values are shown":null,Gt=f=>{k.mutate({id:e,durationMinutes:f})},Ct=()=>{l.resetQueries({queryKey:["escalations"]}),l.resetQueries({queryKey:["escalationStats"]}),u(-1)},Is=()=>{const f=ra(U);return f&&it(f,xt(o,j))||null},Ss=f=>{l.resetQueries({queryKey:["escalations"]}),l.resetQueries({queryKey:["escalationStats"]}),f.startsWith("/")?u(f):window.location.assign(f)},Et=async f=>{try{await h.mutateAsync({id:e,resolverPayload:f})}catch(Q){if(Q instanceof tn&&Dn(Q.body)){S(!0),vt(Q.body.violations),wt(z.ERRORS);return}throw Q}ne(e);const C=Ge(U),B=Is();if(C){Ht({...C,doneDest:B});return}if(B){Ss(B);return}Ct()},ke=async f=>{try{await k.mutateAsync({id:e,durationMinutes:f})}catch{return}if(_t.blocked)return;const C=ie(L,xt(o,j));if(!C.parseError){if(C.errors.length>0){S(!0),vt(C.errors),N(!0),Tt(!0),wt(z.ERRORS);return}await Et(C.payload)}};Mt.current=async()=>{var C;const f=(C=p.state)==null?void 0:C.durationMinutes;he(!0),await ke(typeof f=="number"&&f>0?f:30),he(!1)},It.current=()=>{const f=ie(L,xt(o,j));f.parseError||f.errors.length>0||Et(f.payload)};const _e=async f=>{f&&(await R.mutateAsync({id:e,targetRole:f}),Ct())},Ds=async()=>{st||await k.mutateAsync({id:e,durationMinutes:30});const f=(nt==null?void 0:nt.diagnosis)||o.description||"";await h.mutateAsync({id:e,resolverPayload:{_lt:{needsTriage:!0},notes:f}}),Ct()},Ce=async()=>{await k.mutateAsync({id:e,durationMinutes:0}),Ct()},$s=async()=>{await I.mutateAsync(e),ne(e),E(!1),Ct()},Ls=t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ln,{onRefresh:()=>b(),isFetching:v,apiPath:`/escalations/${o.id}`,standalone:!0}),t.jsx("button",{onClick:()=>N(f=>(Tt(!f),!f)),className:"ml-2 text-accent/60 hover:text-accent transition-colors",title:_?"Hide side panel":"Show side panel",children:_?t.jsx(Le,{className:"w-5 h-5",strokeWidth:1.5}):t.jsx(Pe,{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:[zt?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:Ce,disabled:k.isPending,label:et.release??"Release",hoverClass:"hover:text-accent",icon:t.jsx(Mn,{className:"w-4 h-4",strokeWidth:1.5})},...et.cancel===!1?[]:[{onClick:()=>E(!0),disabled:!1,label:et.cancel??"Cancel",hoverClass:"hover:text-status-error",icon:t.jsx(In,{className:"w-4 h-4",strokeWidth:1.5})}],{onClick:()=>N(f=>(Tt(!f),!f)),disabled:!1,label:_?"Hide panel":"Show panel",hoverClass:"hover:text-accent",icon:_?t.jsx(Le,{className:"w-4 h-4",strokeWidth:1.5}):t.jsx(Pe,{className:"w-4 h-4",strokeWidth:1.5})}].map(({onClick:f,disabled:C,label:B,hoverClass:Q,icon:ct})=>t.jsxs("div",{className:"relative group/tip",children:[t.jsx("button",{onClick:f,disabled:C,className:`text-text-tertiary ${Q} transition-colors disabled:opacity-40 disabled:cursor-default p-1.5 rounded-md`,children:ct}),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:B})]},B))}),t.jsx(ps,{src:ys(lt.src,o),escalation:o,schema:U,onResolve:Et,onEscalate:_e,submitAttempted:G,fill:!0})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"shrink-0 pt-8 pr-page-x",children:t.jsx(on,{title:o.description||"Escalation",actions:Ls})}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto pr-page-x",children:[t.jsx(qr,{isRoundsExhausted:As,payloadObj:nt,isTerminal:ft,resolverPayload:gt,onRetryTriage:Ds,isRetrying:k.isPending||h.isPending}),t.jsx(Ur,{esc:o,resolverPayload:gt,isTerminal:ft,claimedByMe:st,activeView:J,lookup:j,metadataFormSchema:St,effectiveSchema:U,json:L,onJsonChange:w,requestTriage:P,onRequestTriageChange:V,triageNotes:ot,onTriageNotesChange:Nt,onResolve:Et,onEscalate:_e,onClaim:()=>Gt(30),submitAttempted:G,isCertified:Ts,hasAI:we,onOpenHelp:()=>{N(!0),Tt(!0),wt(z.HELP)},onDisabledClick:()=>vs(f=>f+1),disabledHint:Ms}),t.jsx("div",{className:"h-10"})]})]}),!zt&&t.jsx(lr,{escalationContext:xt(o,j),mode:Xt,activeView:J,onActiveViewChange:K,onClaim:je?ke:Gt,claimPending:k.isPending||je&&h.isPending,claimNudge:Ns,workflowType:o.workflow_type,json:L,onResolve:Et,resolvePending:h.isPending||h.isSuccess,resolveError:h.error,requestTriage:P,triageNotes:ot,onRelease:Ce,releasePending:k.isPending,onCancel:()=>E(!0),assignedTo:o.assigned_to,assignedUntil:o.assigned_until,actingName:i&&st?i.displayName:null,badgePrompt:d&&!i&&Ne,onSubmitAttempt:()=>S(!0),onValidationErrors:f=>{vt(f),N(!0),Tt(!0),wt(z.ERRORS)},labels:et,submitBlocked:_t.blocked,submitBlockedMessage:_t.message,canManage:a,onReassign:()=>T(!0),onUnassign:()=>$.mutate({ids:[e]}),unassignPending:$.isPending})]}),t.jsx(Bn,{esc:o,schema:U,envelope:Pt,payload:nt,resolver:Os,triage:Rs??null,hasAI:we,claimed:Bt,claimedByMe:st,isTerminal:ft,isBuilder:H,traceUrl:Z,open:_,noGutter:zt,formErrors:pt,activePanel:ws,onPanelChange:wt}),t.jsx(sn,{open:A,onClose:()=>T(!1),selectedCount:1,selectedRoles:o?[o.role]:[],onSubmit:(f,C)=>D.mutate({ids:[e],targetUserId:f,durationMinutes:C,reassign:!0},{onSuccess:()=>T(!1)}),isPending:D.isPending}),t.jsx(nn,{open:W,onClose:()=>E(!1),onConfirm:$s,isPending:I.isPending,error:I.error,actionLabel:typeof et.cancel=="string"?et.cancel:void 0}),t.jsx($n,{escalationId:e}),t.jsx(ua,{open:!!tt||ks,message:(tt==null?void 0:tt.message)??((Oe=Ge(U))==null?void 0:Oe.message)??"Starting…"}),st&&!ft&&o.assigned_until&&t.jsx(Jr,{open:_s.expiringSoon&&o.assigned_until!==Cs,assignedUntil:o.assigned_until,onClose:()=>Es(o.assigned_until??null),onExtend:Gt,isPending:k.isPending})]})}export{La as EscalationDetailPage};
3
+ //# sourceMappingURL=index-CLq228E2.js.map