@hotmeshio/long-tail 0.16.0 → 0.16.1

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 (182) hide show
  1. package/build/shared/form-validation/field-validator.js +4 -3
  2. package/build/shared/form-validation/x-lt-options.d.ts +7 -2
  3. package/build/shared/form-validation/x-lt-options.js +32 -10
  4. package/dashboard/dist/assets/{AdminDashboard-BVgjY4zN.js → AdminDashboard-Dnj4asuh.js} +2 -2
  5. package/dashboard/dist/assets/{AdminDashboard-BVgjY4zN.js.map → AdminDashboard-Dnj4asuh.js.map} +1 -1
  6. package/dashboard/dist/assets/{AgentConfigPage-ChL59YL5.js → AgentConfigPage-CS0CezLt.js} +2 -2
  7. package/dashboard/dist/assets/{AgentConfigPage-ChL59YL5.js.map → AgentConfigPage-CS0CezLt.js.map} +1 -1
  8. package/dashboard/dist/assets/{AgentDetailPage-IJfgCOIF.js → AgentDetailPage-CG0HO-MG.js} +2 -2
  9. package/dashboard/dist/assets/{AgentDetailPage-IJfgCOIF.js.map → AgentDetailPage-CG0HO-MG.js.map} +1 -1
  10. package/dashboard/dist/assets/{AgentsPage-C7PnPXz_.js → AgentsPage-cLZPda64.js} +2 -2
  11. package/dashboard/dist/assets/{AgentsPage-C7PnPXz_.js.map → AgentsPage-cLZPda64.js.map} +1 -1
  12. package/dashboard/dist/assets/{AvailableEscalationsPage-C5f2rqHa.js → AvailableEscalationsPage-Dv5GE_NU.js} +2 -2
  13. package/dashboard/dist/assets/{AvailableEscalationsPage-C5f2rqHa.js.map → AvailableEscalationsPage-Dv5GE_NU.js.map} +1 -1
  14. package/dashboard/dist/assets/{BotPicker-CBf6bHLV.js → BotPicker-BgXaJfUZ.js} +2 -2
  15. package/dashboard/dist/assets/{BotPicker-CBf6bHLV.js.map → BotPicker-BgXaJfUZ.js.map} +1 -1
  16. package/dashboard/dist/assets/{BulkAssignModal-CkxoPByA.js → BulkAssignModal-BUfV9aba.js} +2 -2
  17. package/dashboard/dist/assets/{BulkAssignModal-CkxoPByA.js.map → BulkAssignModal-BUfV9aba.js.map} +1 -1
  18. package/dashboard/dist/assets/{CapabilitiesPage-D7USh3F0.js → CapabilitiesPage-CaiDhtmq.js} +2 -2
  19. package/dashboard/dist/assets/{CapabilitiesPage-D7USh3F0.js.map → CapabilitiesPage-CaiDhtmq.js.map} +1 -1
  20. package/dashboard/dist/assets/{CollapsibleSection-DfPpAIxa.js → CollapsibleSection-C6R7Lhao.js} +2 -2
  21. package/dashboard/dist/assets/{CollapsibleSection-DfPpAIxa.js.map → CollapsibleSection-C6R7Lhao.js.map} +1 -1
  22. package/dashboard/dist/assets/{CountdownTimer-DVL7WIcE.js → CountdownTimer-CFR2pPT9.js} +2 -2
  23. package/dashboard/dist/assets/{CountdownTimer-DVL7WIcE.js.map → CountdownTimer-CFR2pPT9.js.map} +1 -1
  24. package/dashboard/dist/assets/{CredentialsPage-BHZ5SKIu.js → CredentialsPage-9d2xZhfU.js} +2 -2
  25. package/dashboard/dist/assets/{CredentialsPage-BHZ5SKIu.js.map → CredentialsPage-9d2xZhfU.js.map} +1 -1
  26. package/dashboard/dist/assets/{CronLabel-wE8Hms6c.js → CronLabel-BfIYBjTD.js} +2 -2
  27. package/dashboard/dist/assets/{CronLabel-wE8Hms6c.js.map → CronLabel-BfIYBjTD.js.map} +1 -1
  28. package/dashboard/dist/assets/{ElapsedCell-B4VxKHpw.js → ElapsedCell-DV-35FDF.js} +2 -2
  29. package/dashboard/dist/assets/{ElapsedCell-B4VxKHpw.js.map → ElapsedCell-DV-35FDF.js.map} +1 -1
  30. package/dashboard/dist/assets/{EntityTimelinePanel-CFbQDHOj.js → EntityTimelinePanel-mHaN_i7a.js} +2 -2
  31. package/dashboard/dist/assets/{EntityTimelinePanel-CFbQDHOj.js.map → EntityTimelinePanel-mHaN_i7a.js.map} +1 -1
  32. package/dashboard/dist/assets/{EscalationListSchemaPage-YTgexl4f.js → EscalationListSchemaPage-Km5jnrIW.js} +2 -2
  33. package/dashboard/dist/assets/{EscalationListSchemaPage-YTgexl4f.js.map → EscalationListSchemaPage-Km5jnrIW.js.map} +1 -1
  34. package/dashboard/dist/assets/{EscalationSchemaPage-Sjk05eHP.js → EscalationSchemaPage-CAJGIBv2.js} +2 -2
  35. package/dashboard/dist/assets/{EscalationSchemaPage-Sjk05eHP.js.map → EscalationSchemaPage-CAJGIBv2.js.map} +1 -1
  36. package/dashboard/dist/assets/{EscalationsOverview-gHWPjUpZ.js → EscalationsOverview-nk9FXKmv.js} +2 -2
  37. package/dashboard/dist/assets/{EscalationsOverview-gHWPjUpZ.js.map → EscalationsOverview-nk9FXKmv.js.map} +1 -1
  38. package/dashboard/dist/assets/{EventTable-C9lHQ57t.js → EventTable-DNRaYzTn.js} +2 -2
  39. package/dashboard/dist/assets/{EventTable-C9lHQ57t.js.map → EventTable-DNRaYzTn.js.map} +1 -1
  40. package/dashboard/dist/assets/{FilterBar-BY--ANxv.js → FilterBar-CmRA_E6x.js} +2 -2
  41. package/dashboard/dist/assets/{FilterBar-BY--ANxv.js.map → FilterBar-CmRA_E6x.js.map} +1 -1
  42. package/dashboard/dist/assets/{GraphInvokePage-B-Oo5s-W.js → GraphInvokePage-HJfa82kv.js} +2 -2
  43. package/dashboard/dist/assets/{GraphInvokePage-B-Oo5s-W.js.map → GraphInvokePage-HJfa82kv.js.map} +1 -1
  44. package/dashboard/dist/assets/{HomePage-BrcjKOaJ.js → HomePage-B2JDwmmh.js} +2 -2
  45. package/dashboard/dist/assets/{HomePage-BrcjKOaJ.js.map → HomePage-B2JDwmmh.js.map} +1 -1
  46. package/dashboard/dist/assets/{ListToolbar-D5TQ4X_M.js → ListToolbar-CKuJ7HUH.js} +2 -2
  47. package/dashboard/dist/assets/{ListToolbar-D5TQ4X_M.js.map → ListToolbar-CKuJ7HUH.js.map} +1 -1
  48. package/dashboard/dist/assets/{McpOverview-jlukVWQ7.js → McpOverview-CZCzbiRs.js} +2 -2
  49. package/dashboard/dist/assets/{McpOverview-jlukVWQ7.js.map → McpOverview-CZCzbiRs.js.map} +1 -1
  50. package/dashboard/dist/assets/{McpQueryDetailPage-BWKbvJSd.js → McpQueryDetailPage-C081BBcH.js} +2 -2
  51. package/dashboard/dist/assets/{McpQueryDetailPage-BWKbvJSd.js.map → McpQueryDetailPage-C081BBcH.js.map} +1 -1
  52. package/dashboard/dist/assets/{McpQueryPage-BH2Pon4M.js → McpQueryPage-841V8CXb.js} +2 -2
  53. package/dashboard/dist/assets/{McpQueryPage-BH2Pon4M.js.map → McpQueryPage-841V8CXb.js.map} +1 -1
  54. package/dashboard/dist/assets/{McpRunDetailPage-kUnq2QSO.js → McpRunDetailPage-DZjlgp5W.js} +2 -2
  55. package/dashboard/dist/assets/{McpRunDetailPage-kUnq2QSO.js.map → McpRunDetailPage-DZjlgp5W.js.map} +1 -1
  56. package/dashboard/dist/assets/{McpRunsPage-BTucgt64.js → McpRunsPage-DW0VVd46.js} +2 -2
  57. package/dashboard/dist/assets/{McpRunsPage-BTucgt64.js.map → McpRunsPage-DW0VVd46.js.map} +1 -1
  58. package/dashboard/dist/assets/{OperationsPage-Cp8WL-ld.js → OperationsPage-DAw7z_Sh.js} +2 -2
  59. package/dashboard/dist/assets/{OperationsPage-Cp8WL-ld.js.map → OperationsPage-DAw7z_Sh.js.map} +1 -1
  60. package/dashboard/dist/assets/{OperatorDashboard-wHyeLWzX.js → OperatorDashboard-BAnQNuD6.js} +2 -2
  61. package/dashboard/dist/assets/{OperatorDashboard-wHyeLWzX.js.map → OperatorDashboard-BAnQNuD6.js.map} +1 -1
  62. package/dashboard/dist/assets/{PersonaDetailPage-BXlTqLDK.js → PersonaDetailPage-XENbpbSr.js} +2 -2
  63. package/dashboard/dist/assets/{PersonaDetailPage-BXlTqLDK.js.map → PersonaDetailPage-XENbpbSr.js.map} +1 -1
  64. package/dashboard/dist/assets/{PersonasPage-DlmdJ3Dm.js → PersonasPage-CoWH5Fj8.js} +2 -2
  65. package/dashboard/dist/assets/{PersonasPage-DlmdJ3Dm.js.map → PersonasPage-CoWH5Fj8.js.map} +1 -1
  66. package/dashboard/dist/assets/{ProcessDetailPage-D88ocvmT.js → ProcessDetailPage-BDxOt-9L.js} +2 -2
  67. package/dashboard/dist/assets/{ProcessDetailPage-D88ocvmT.js.map → ProcessDetailPage-BDxOt-9L.js.map} +1 -1
  68. package/dashboard/dist/assets/{ProcessesListPage-DpXm-KtK.js → ProcessesListPage-BuNOmgig.js} +2 -2
  69. package/dashboard/dist/assets/{ProcessesListPage-DpXm-KtK.js.map → ProcessesListPage-BuNOmgig.js.map} +1 -1
  70. package/dashboard/dist/assets/{RoleDetailPage-DE2Rj2QE.js → RoleDetailPage-DAzkfZ4T.js} +2 -2
  71. package/dashboard/dist/assets/{RoleDetailPage-DE2Rj2QE.js.map → RoleDetailPage-DAzkfZ4T.js.map} +1 -1
  72. package/dashboard/dist/assets/{RolesPage-CZSvJlsz.js → RolesPage-C9jZL4aM.js} +2 -2
  73. package/dashboard/dist/assets/{RolesPage-CZSvJlsz.js.map → RolesPage-C9jZL4aM.js.map} +1 -1
  74. package/dashboard/dist/assets/{RunAsSelector-BawZcqAk.js → RunAsSelector-DswUl2-8.js} +2 -2
  75. package/dashboard/dist/assets/{RunAsSelector-BawZcqAk.js.map → RunAsSelector-DswUl2-8.js.map} +1 -1
  76. package/dashboard/dist/assets/{ScanCodesPage-DSlpA9kK.js → ScanCodesPage-D_FDxJgT.js} +2 -2
  77. package/dashboard/dist/assets/{ScanCodesPage-DSlpA9kK.js.map → ScanCodesPage-D_FDxJgT.js.map} +1 -1
  78. package/dashboard/dist/assets/{ScanSchemeDetailPage-BK4hisGD.js → ScanSchemeDetailPage-Cbkpob5g.js} +2 -2
  79. package/dashboard/dist/assets/{ScanSchemeDetailPage-BK4hisGD.js.map → ScanSchemeDetailPage-Cbkpob5g.js.map} +1 -1
  80. package/dashboard/dist/assets/{ScanStationPage-D3QjajFD.js → ScanStationPage-BI_cDWVp.js} +2 -2
  81. package/dashboard/dist/assets/{ScanStationPage-D3QjajFD.js.map → ScanStationPage-BI_cDWVp.js.map} +1 -1
  82. package/dashboard/dist/assets/{StickyPagination-BfZwU2NR.js → StickyPagination-CfTEnlh5.js} +2 -2
  83. package/dashboard/dist/assets/{StickyPagination-BfZwU2NR.js.map → StickyPagination-CfTEnlh5.js.map} +1 -1
  84. package/dashboard/dist/assets/{StreamMessageDetail-C7zIHX5D.js → StreamMessageDetail-oa7Bx0lB.js} +2 -2
  85. package/dashboard/dist/assets/{StreamMessageDetail-C7zIHX5D.js.map → StreamMessageDetail-oa7Bx0lB.js.map} +1 -1
  86. package/dashboard/dist/assets/{SwimlaneTimeline-DNSo8AT8.js → SwimlaneTimeline-CO96ep4N.js} +2 -2
  87. package/dashboard/dist/assets/{SwimlaneTimeline-DNSo8AT8.js.map → SwimlaneTimeline-CO96ep4N.js.map} +1 -1
  88. package/dashboard/dist/assets/{TaskDetailPage-BOJ8pwh3.js → TaskDetailPage-BiO2eFQ0.js} +2 -2
  89. package/dashboard/dist/assets/{TaskDetailPage-BOJ8pwh3.js.map → TaskDetailPage-BiO2eFQ0.js.map} +1 -1
  90. package/dashboard/dist/assets/{TasksListPage-C4CYqZf8.js → TasksListPage-DQ4WJfJo.js} +2 -2
  91. package/dashboard/dist/assets/{TasksListPage-C4CYqZf8.js.map → TasksListPage-DQ4WJfJo.js.map} +1 -1
  92. package/dashboard/dist/assets/{TimeAgo-JRPi9IEd.js → TimeAgo-ZwSSU_EG.js} +2 -2
  93. package/dashboard/dist/assets/{TimeAgo-JRPi9IEd.js.map → TimeAgo-ZwSSU_EG.js.map} +1 -1
  94. package/dashboard/dist/assets/{TimestampCell-BVYyU-nl.js → TimestampCell-BHmJ7das.js} +2 -2
  95. package/dashboard/dist/assets/{TimestampCell-BVYyU-nl.js.map → TimestampCell-BHmJ7das.js.map} +1 -1
  96. package/dashboard/dist/assets/{ToolTestPanel-IGrd44Au.js → ToolTestPanel-DARNx6e0.js} +2 -2
  97. package/dashboard/dist/assets/{ToolTestPanel-IGrd44Au.js.map → ToolTestPanel-DARNx6e0.js.map} +1 -1
  98. package/dashboard/dist/assets/{TopicDetailPage-DhianNey.js → TopicDetailPage-BYcF0lO8.js} +2 -2
  99. package/dashboard/dist/assets/{TopicDetailPage-DhianNey.js.map → TopicDetailPage-BYcF0lO8.js.map} +1 -1
  100. package/dashboard/dist/assets/{TopicsPage-Glhqz_Nv.js → TopicsPage-CG-IZfpq.js} +2 -2
  101. package/dashboard/dist/assets/{TopicsPage-Glhqz_Nv.js.map → TopicsPage-CG-IZfpq.js.map} +1 -1
  102. package/dashboard/dist/assets/{UserName-CD9OqhNI.js → UserName-BGn4sSx1.js} +2 -2
  103. package/dashboard/dist/assets/{UserName-CD9OqhNI.js.map → UserName-BGn4sSx1.js.map} +1 -1
  104. package/dashboard/dist/assets/{WorkflowExecutionPage-8Q2438Ry.js → WorkflowExecutionPage-Dt_lskas.js} +2 -2
  105. package/dashboard/dist/assets/{WorkflowExecutionPage-8Q2438Ry.js.map → WorkflowExecutionPage-Dt_lskas.js.map} +1 -1
  106. package/dashboard/dist/assets/{WorkflowsDashboard-CkAoYT86.js → WorkflowsDashboard-Dl3carpF.js} +2 -2
  107. package/dashboard/dist/assets/{WorkflowsDashboard-CkAoYT86.js.map → WorkflowsDashboard-Dl3carpF.js.map} +1 -1
  108. package/dashboard/dist/assets/{WorkflowsOverview-Zh_EidMp.js → WorkflowsOverview-6CplKLvQ.js} +2 -2
  109. package/dashboard/dist/assets/{WorkflowsOverview-Zh_EidMp.js.map → WorkflowsOverview-6CplKLvQ.js.map} +1 -1
  110. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BKJbFT8C.js → YamlWorkflowDetailPage-CZf6zZ4Q.js} +2 -2
  111. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BKJbFT8C.js.map → YamlWorkflowDetailPage-CZf6zZ4Q.js.map} +1 -1
  112. package/dashboard/dist/assets/{YamlWorkflowsPage-DK1z6iFt.js → YamlWorkflowsPage-DRQ_3CZG.js} +2 -2
  113. package/dashboard/dist/assets/{YamlWorkflowsPage-DK1z6iFt.js.map → YamlWorkflowsPage-DRQ_3CZG.js.map} +1 -1
  114. package/dashboard/dist/assets/{agents-BEASyYpg.js → agents-BvtecCN5.js} +2 -2
  115. package/dashboard/dist/assets/{agents-BEASyYpg.js.map → agents-BvtecCN5.js.map} +1 -1
  116. package/dashboard/dist/assets/{bots-CaXqSHat.js → bots-CSmIqXtL.js} +2 -2
  117. package/dashboard/dist/assets/{bots-CaXqSHat.js.map → bots-CSmIqXtL.js.map} +1 -1
  118. package/dashboard/dist/assets/{capabilities-Cijq-qev.js → capabilities-xMqvjbWI.js} +2 -2
  119. package/dashboard/dist/assets/{capabilities-Cijq-qev.js.map → capabilities-xMqvjbWI.js.map} +1 -1
  120. package/dashboard/dist/assets/{controlplane-HGuRC7AW.js → controlplane-Bi-tz-Gr.js} +2 -2
  121. package/dashboard/dist/assets/{controlplane-HGuRC7AW.js.map → controlplane-Bi-tz-Gr.js.map} +1 -1
  122. package/dashboard/dist/assets/{escalation-columns-BLVz8XCP.js → escalation-columns-DSalfPHI.js} +2 -2
  123. package/dashboard/dist/assets/{escalation-columns-BLVz8XCP.js.map → escalation-columns-DSalfPHI.js.map} +1 -1
  124. package/dashboard/dist/assets/{index-t1JXcmBG.js → index-BIK4b7Ei.js} +2 -2
  125. package/dashboard/dist/assets/{index-t1JXcmBG.js.map → index-BIK4b7Ei.js.map} +1 -1
  126. package/dashboard/dist/assets/{index-Xi3LO4Ye.js → index-BWyPrDYG.js} +2 -2
  127. package/dashboard/dist/assets/{index-Xi3LO4Ye.js.map → index-BWyPrDYG.js.map} +1 -1
  128. package/dashboard/dist/assets/{index-CLQ0HBHR.js → index-BYukuL1u.js} +2 -2
  129. package/dashboard/dist/assets/{index-CLQ0HBHR.js.map → index-BYukuL1u.js.map} +1 -1
  130. package/dashboard/dist/assets/index-Bf9cfGX_.js +3 -0
  131. package/dashboard/dist/assets/index-Bf9cfGX_.js.map +1 -0
  132. package/dashboard/dist/assets/{index-IkgBE7e_.js → index-BjxQVsbg.js} +2 -2
  133. package/dashboard/dist/assets/{index-IkgBE7e_.js.map → index-BjxQVsbg.js.map} +1 -1
  134. package/dashboard/dist/assets/{index-YMd3ZiPd.js → index-C8pPqnJb.js} +2 -2
  135. package/dashboard/dist/assets/{index-YMd3ZiPd.js.map → index-C8pPqnJb.js.map} +1 -1
  136. package/dashboard/dist/assets/{index-tCDjx1kF.js → index-CEsGT3c9.js} +2 -2
  137. package/dashboard/dist/assets/{index-tCDjx1kF.js.map → index-CEsGT3c9.js.map} +1 -1
  138. package/dashboard/dist/assets/{index-Cg0vCZng.js → index-DATqc8Gv.js} +2 -2
  139. package/dashboard/dist/assets/{index-Cg0vCZng.js.map → index-DATqc8Gv.js.map} +1 -1
  140. package/dashboard/dist/assets/{index-D2OU2MJb.js → index-cX2H_U7R.js} +2 -2
  141. package/dashboard/dist/assets/{index-D2OU2MJb.js.map → index-cX2H_U7R.js.map} +1 -1
  142. package/dashboard/dist/assets/{index-CEIp6WWg.js → index-gHDAcM64.js} +2 -2
  143. package/dashboard/dist/assets/{index-CEIp6WWg.js.map → index-gHDAcM64.js.map} +1 -1
  144. package/dashboard/dist/assets/{index-CgXVDPW-.js → index-sbfCx2CF.js} +3 -3
  145. package/dashboard/dist/assets/{index-CgXVDPW-.js.map → index-sbfCx2CF.js.map} +1 -1
  146. package/dashboard/dist/assets/{index-BJDAXUzO.js → index-shnwALdy.js} +2 -2
  147. package/dashboard/dist/assets/{index-BJDAXUzO.js.map → index-shnwALdy.js.map} +1 -1
  148. package/dashboard/dist/assets/{index-ClY0ihQ5.js → index-uqT6ovVQ.js} +2 -2
  149. package/dashboard/dist/assets/{index-ClY0ihQ5.js.map → index-uqT6ovVQ.js.map} +1 -1
  150. package/dashboard/dist/assets/{knowledge-DpaUJtVW.js → knowledge-DbDvUbq7.js} +2 -2
  151. package/dashboard/dist/assets/{knowledge-DpaUJtVW.js.map → knowledge-DbDvUbq7.js.map} +1 -1
  152. package/dashboard/dist/assets/{mcp-BkkLq6OE.js → mcp-I2OmwD8P.js} +2 -2
  153. package/dashboard/dist/assets/{mcp-BkkLq6OE.js.map → mcp-I2OmwD8P.js.map} +1 -1
  154. package/dashboard/dist/assets/{mcp-query-DeXu3La5.js → mcp-query-DwTp77HP.js} +2 -2
  155. package/dashboard/dist/assets/{mcp-query-DeXu3La5.js.map → mcp-query-DwTp77HP.js.map} +1 -1
  156. package/dashboard/dist/assets/{personas-BRbKVVko.js → personas-DDr8gQGC.js} +2 -2
  157. package/dashboard/dist/assets/{personas-BRbKVVko.js.map → personas-DDr8gQGC.js.map} +1 -1
  158. package/dashboard/dist/assets/{pipelines-B7xo92sK.js → pipelines-uptnM5Qj.js} +2 -2
  159. package/dashboard/dist/assets/{pipelines-B7xo92sK.js.map → pipelines-uptnM5Qj.js.map} +1 -1
  160. package/dashboard/dist/assets/{tasks-BGyqM1Ho.js → tasks-Em0f5Rsk.js} +2 -2
  161. package/dashboard/dist/assets/{tasks-BGyqM1Ho.js.map → tasks-Em0f5Rsk.js.map} +1 -1
  162. package/dashboard/dist/assets/{topics-I81rKc75.js → topics-B81zAt9U.js} +2 -2
  163. package/dashboard/dist/assets/{topics-I81rKc75.js.map → topics-B81zAt9U.js.map} +1 -1
  164. package/dashboard/dist/assets/{useEventHooks-CjV3uNxt.js → useEventHooks-B_Bqqzlo.js} +2 -2
  165. package/dashboard/dist/assets/{useEventHooks-CjV3uNxt.js.map → useEventHooks-B_Bqqzlo.js.map} +1 -1
  166. package/dashboard/dist/assets/{useNamespace-B-HMdRka.js → useNamespace-CZfue_oE.js} +2 -2
  167. package/dashboard/dist/assets/{useNamespace-B-HMdRka.js.map → useNamespace-CZfue_oE.js.map} +1 -1
  168. package/dashboard/dist/assets/{useYamlActivityEvents-CNsAlsgz.js → useYamlActivityEvents-DjQ7rsOC.js} +2 -2
  169. package/dashboard/dist/assets/{useYamlActivityEvents-CNsAlsgz.js.map → useYamlActivityEvents-DjQ7rsOC.js.map} +1 -1
  170. package/dashboard/dist/assets/{users-DiTqBepm.js → users-CwUL9YJT.js} +2 -2
  171. package/dashboard/dist/assets/{users-DiTqBepm.js.map → users-CwUL9YJT.js.map} +1 -1
  172. package/dashboard/dist/assets/{workflows-TA0p_3B8.js → workflows-gSjgU0KB.js} +2 -2
  173. package/dashboard/dist/assets/{workflows-TA0p_3B8.js.map → workflows-gSjgU0KB.js.map} +1 -1
  174. package/dashboard/dist/assets/{yaml-workflows-DN9-DBnQ.js → yaml-workflows-a_7IO_a6.js} +2 -2
  175. package/dashboard/dist/assets/{yaml-workflows-DN9-DBnQ.js.map → yaml-workflows-a_7IO_a6.js.map} +1 -1
  176. package/dashboard/dist/index.html +1 -1
  177. package/docs/hitl/lookups.md +11 -0
  178. package/docs/hitl/x-lt-validation.md +2 -1
  179. package/docs/hitl-guide.md +1 -1
  180. package/package.json +1 -1
  181. package/dashboard/dist/assets/index-CK_ohh6Q.js +0 -3
  182. package/dashboard/dist/assets/index-CK_ohh6Q.js.map +0 -1
@@ -1,3 +0,0 @@
1
- import{b as ze,a as m,j as t}from"./vendor-query-RUZdMvN6.js";import{Z as Ps,_ as ht,g as yt,U as Yt,$ as Vt,J as Ot,c as Fs,d as Ws,P as at,b as Zt,m as Se,a0 as Kt,a1 as Xe,X as le,L as ce,T as Ge,j as Qe,a2 as qs,a3 as Us,a4 as Vs,i as Js,a5 as Hs,a6 as Bs,A as zs,B as Xs,u as Gs,v as Qs,l as Ys,a7 as Zs}from"./index-CgXVDPW-.js";import{u as Ye,C as Ze,r as Ks,B as tn,a as en}from"./BulkAssignModal-CkxoPByA.js";import{M as Ke}from"./Modal-BU7No9NH.js";import{a as ts,u as de,L as jt,b as sn,e as nn}from"./vendor-react-CdqEC2zv.js";import{P as rn}from"./PageHeader-CFVw67M6.js";import{L as an}from"./ListToolbar-D5TQ4X_M.js";import{i as qt,b as on,d as ln,C as Jt,g as Ht,H as cn,m as dn,c as it,r as ue,s as un,e as es}from"./CountdownTimer-DVL7WIcE.js";import{u as xn}from"./workflows-TA0p_3B8.js";import{g as pn}from"./useEventHooks-CjV3uNxt.js";import{S as ss}from"./StatusBadge-BDeUwPtb.js";import{R as mn}from"./RolePill-Di_5hfvw.js";import{C as dt}from"./CopyableId-4Lqlc5cU.js";import{U as xe}from"./UserName-CD9OqhNI.js";import{d as fn}from"./metadata-display-DHjqWkLG.js";import{a2 as ns,J as gn,S as hn,au as bn,_ as yn,n as jn,af as rs,U as Nn,ai as vn,aj as wn,ak as kn,a8 as _n,av as Cn,aw as En,ax as ae,ay as An,az as Ie,aA as Tn,K as De,O as $e,aB as Rn,X as On}from"./vendor-icons-h-jlRSb9.js";import"./users-DiTqBepm.js";import"./constants-BHkpVaqx.js";import"./useDebouncedValue-C4P2jQuh.js";import"./DataTable-DFPMeqyQ.js";import"./EmptyState-lpUFYfun.js";import"./StickyPagination-BfZwU2NR.js";const Mn={SCHEMA_VALIDATION:"schema_validation"};function Sn(e){return typeof e=="object"&&e!==null&&e.code===Mn.SCHEMA_VALIDATION&&Array.isArray(e.violations)}function In({escalationId:e}){var b;const s=ts(),r=de(),n=ze(),a=(b=s.state)==null?void 0:b[Ps],[o,d]=m.useState(!1),[c,u]=m.useState(null),[p,l]=m.useState(!1);if(!a||a.escalationId!==e||p)return null;const i=()=>{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"]}),i()}catch(j){u(j.message)}finally{d(!1)}};return t.jsx(Ke,{open:!0,onClose:i,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:i,disabled:o,className:"btn-secondary text-xs",children:"No, go back"}),t.jsx("button",{onClick:x,disabled:o,className:"btn-primary text-xs",children:o?"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))"},te=4;function Le({pct:e,place:s,label:r,title:n,emphasis:a}){const o=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,o]}):t.jsxs(t.Fragment,{children:[o,d]})})}function Dn({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",o=e.status==="cancelled"||e.status==="expired",d=a||o,c=qt(e),u=!!n&&(c||d),p=a&&e.resolved_at?new Date(e.resolved_at).getTime():o?new Date(e.updated_at).getTime():Date.now(),l=Math.max(p-r,1),i=u&&n?Math.max(n-r,0):l,x=u&&n?Math.max(p-n,0):0,b=Math.min(100,Math.max(0,i/l*100)),v=u?Math.max(0,100-b):0,y=a?Wt.resolved:o?Wt.cancelled:Wt.claimed,g=a?"Resolved after":o?"Cancelled after":"In progress",j=Yt(i),k=Yt(l),h=a?`Resolved in ${k} total`:o?`Cancelled after ${k}`:`Open ${k} so far`,T=`Lifecycle bar: blue = time waiting to be claimed, ${a?"green":o?"red":"orange"} = ${g.toLowerCase()} the claim.`;return t.jsxs("div",{className:s,title:T,children:[t.jsx("div",{className:"relative h-2.5 font-mono",children:u&&t.jsx(Le,{pct:b,place:"above",label:j,title:`Time to claim: ${j}`})}),t.jsxs("div",{className:"flex w-full rounded-full overflow-hidden",style:{height:te,backgroundColor:"rgb(var(--lt-surface-sunken))"},title:T,children:[t.jsx("div",{style:{width:`${b}%`,minWidth:te,backgroundColor:Wt.pending,opacity:.75},title:`Waiting ${j} — created → claimed`}),u&&v>0&&t.jsx("div",{style:{width:`${v}%`,minWidth:te,backgroundColor:y,opacity:.75},title:`${g} ${Yt(x)}`})]}),t.jsx("div",{className:"relative h-2.5 font-mono",children:t.jsx(Le,{pct:100,place:"below",emphasis:!0,label:k,title:h})})]})}function $n({triage:e,payload:s}){const r=e.confidence??0,n=r>=.8?"text-status-success":r>=.5?"text-status-pending":"text-status-error",a=Ln(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((o,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"})}),o]},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(o=>t.jsx(Pn,{diff:o},o.key))})]})}function Ln(e,s){if(!e)return[];const r=[];for(const n of Object.keys(e)){if(n.startsWith("_"))continue;const a=e[n],o=s[n];o!==void 0&&JSON.stringify(a)!==JSON.stringify(o)&&r.push({key:n,label:n.replace(/[_-]/g," "),original:a,corrected:o})}return r}function Pn({diff:e}){const s=Pe(e.original),r=Pe(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 Pe(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=>Fn(a)?a:a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function Fn(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"},as="lt:escalation:panel:view";function Wn(e){try{const s=localStorage.getItem(as);if(s&&e.includes(s))return s}catch{}return z.HELP}function qn({metadata:e,role:s}){const r=fn(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 o=typeof a=="object"&&a!==null?JSON.stringify(a):String(a),d=Se(n,a,s),c=Se(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:o}),t.jsx(jt,{to:d,title:`Filter this queue: ${n} = ${o}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx(vn,{className:"w-3 h-3"})}),t.jsx(jt,{to:c,title:`Search all queues: ${n} = ${o}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx(wn,{className:"w-3 h-3"})})]})]},n)})})}function Un({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(ss,{status:e.status})}),t.jsx(at,{label:"Assigned to Role",children:t.jsx(mn,{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(Nn,{className:"w-3 h-3 shrink-0 text-accent/75"}),t.jsx(xe,{userId:e.assigned_to})]})}),t.jsx(at,{label:"Created",children:t.jsx(Zt,{date:e.created_at})}),(s||r)&&e.claimed_at&&t.jsx(at,{label:"Claimed",children:t.jsx(Zt,{date:e.claimed_at})}),s&&!r&&e.assigned_until&&t.jsx(at,{label:"Time Remaining",children:t.jsx(Jt,{until:e.assigned_until})}),e.resolved_at&&t.jsx(at,{label:"Completed",children:t.jsx("span",{className:"text-status-success",children:t.jsx(Zt,{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 Vn({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 o;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(rs,{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,(o=s==null?void 0:s.properties)==null?void 0:o[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 Jn({esc:e,schema:s,envelope:r,payload:n,resolver:a,triage:o,hasAI:d,claimed:c,claimedByMe:u,isTerminal:p,isBuilder:l,traceUrl:i,open:x,noGutter:b,formErrors:v,activePanel:y,onPanelChange:g}){const j=de(),k=Object.values(z),[h,T]=m.useState(()=>Wn(k)),S=y??h,I=m.useCallback(A=>{try{localStorage.setItem(as,A)}catch{}T(A),g==null||g(A)},[g]);m.useEffect(()=>{y&&y!==h&&T(y)},[y]);const $=m.useMemo(()=>on(s,{escalation:e,metadata:e.metadata??null,envelope:r,payload:n,resolver:a})??ln({isTerminal:p,status:e.status,claimed:c,claimedByMe:u}),[s,e,r,n,a,p,c,u]),W=m.useCallback(A=>{const R=A.target.closest("a"),M=R==null?void 0:R.getAttribute("href");M!=null&&M.startsWith("/")&&(A.preventDefault(),j(M))},[j]),E=[{id:z.HELP,icon:ns,label:"Instructions",content:t.jsx(Vt,{content:$,onClick:W})},{id:z.DETAILS,icon:gn,label:"Details",content:t.jsx(Un,{esc:e,claimed:c,isTerminal:p,isBuilder:l,traceUrl:i})},...d&&o?[{id:z.TRIAGE,icon:hn,label:"AI Analysis",content:t.jsx($n,{triage:o,payload:n??{}})}]:[],{id:z.METADATA,icon:bn,label:"Metadata",content:t.jsx(qn,{metadata:e.metadata,role:e.role})},{id:z.CONTEXT,icon:yn,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:jn,label:"Record",content:t.jsx(Ot,{data:e,label:"Escalation Record"})}]:[],...v&&v.length>0?[{id:z.ERRORS,icon:(({className:A})=>t.jsx(rs,{className:`${A??""} text-status-error`})),label:"Errors",content:t.jsx(Vn,{errors:v,schema:s})}]:[]];return t.jsx(Fs,{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(Dn,{esc:e,className:"w-[80%]"})}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(Ws,{views:E,activeId:S,onViewChange:I,stickyClassName:"h-full min-h-0"})})]})})})}const Hn=/\{\{\s*([^{}]+?)\s*\}\}/g;function is(e){return typeof e=="string"&&/\{\{[^{}]+\}\}/.test(e)}function pe(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 Ht(n,e.slice(r+1))}function os(e,s){let r=!1;const n=e.replace(Hn,(a,o)=>{const d=pe(o,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 Bn="x-lt-options";function ls(e,s){if(!e)return;const r=e.enum;if(Array.isArray(r)&&r.length>0)return r;const n=e[Bn];if(typeof n!="string")return;const a=is(n),o=a?[]:void 0;let d=n;if(a){const p=os(n,s);if(p===null)return o;d=p}const c=pe(d,s);if(!Array.isArray(c))return o;const u=c.filter(p=>typeof p=="string"||typeof p=="number"&&Number.isFinite(p));return u.length>0?u:o}function zn(e,s){if(typeof e!="string"||!s)return[];let r=e;if(is(e)){const a=os(e,s);if(a===null)return[];r=a}const n=pe(r,s);return Array.isArray(n)?n:[]}function Xn(e,s,r){if((s==null?void 0:s["x-lt-widget"])!=="checklist"||s["x-lt-require-all"]!==!0)return;const a=zn(s["x-lt-source"],r).filter(c=>c.required!==!1);if(a.length===0)return;const o=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},d=a.filter(c=>!o[c.id]).length;if(d!==0)return`${d} of ${a.length} checks incomplete`}function Gn(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 Qn(e,s,r){if(!s)return;const n=ls(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.includes(e))return`Must be one of: ${n.map(a=>String(a)).join(", ")}`}if(typeof e=="string"){const a=e.trim();if(a==="")return;const o=bt(s.minLength,s["x-lt-min-length"],r);if(o!==void 0&&a.length<o)return`Minimum ${o} character${o===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),o=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(o!==void 0&&e<=o)return`Must be greater than ${o}`;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),o=s.slice(n+1),d=r[a];if(d&&typeof d=="object"){const c=o.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 cs(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 o=Gn(e,s);if(o)return o;const d=Xn(e,s,a);return d||Qn(e,s,a)}function Fe(e){return e!=null&&e!==""&&e!==!1&&e!==0}function Yn(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function We(e,s){const r=e.indexOf("."),n=r===-1?e:e.slice(0,r);if(!cn.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:Ht(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("!="),o=n.indexOf("=");if(a!==-1||o!==-1&&o!==a+1){const u=a!==-1&&(o===-1||a<o),p=u?a:o,l=n.slice(0,p).trim(),i=n.slice(p+(u?2:1)).trim(),{known:x,value:b}=We(l,s);if(!x)return!0;const v=Yn(b)===i,y=u?!v:v;return r?!y:y}const{known:d,value:c}=We(n,s);return d?r?!Fe(c):Fe(c):!0}const Zn="x-lt-require-any";function Kn(e){const s=e==null?void 0:e[Zn];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 tr(e){return e==null?!1:typeof e=="string"?e.trim().length>0:!0}const er="x-lt-require-sum";function sr(e){const s=e==null?void 0:e[er];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:o}=n;if(!Array.isArray(a))continue;const d=a.filter(c=>typeof c=="string"&&c.length>0);d.length!==0&&(o!==void 0&&typeof o!="number"||r.push({fields:d,minimum:typeof o=="number"?o:1}))}return r}function nr(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 ds(e,s,r){if(!e)return[];const n=e.properties??{},a=new Set(e.required??[]),o={...r??{},resolver:s},d=[];for(const[c,u]of Object.entries(n)){if(!Ut(u["x-lt-showIf"],o))continue;const p=cs(s[c],u,a.has(c),!0,o);p&&d.push({field:c,message:p})}for(const c of Kn(e)){const u=c.filter(l=>n[l]&&Ut(n[l]["x-lt-showIf"],o));if(u.length===0||u.some(l=>tr(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 sr(e)){const u=c.fields.filter(i=>n[i]&&Ut(n[i]["x-lt-showIf"],o));if(u.length===0||u.reduce((i,x)=>i+nr(s[x]),0)>=c.minimum)continue;const l=u.map(i=>n[i].title??i);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=ds(n,r,s);if(d.length>0)return{payload:null,errors:d,parseError:null}}const{_form_schema:a,...o}=r;return{payload:dn(o,n),errors:[],parseError:null}}function rr(e){const{mode:s,activeView:r,onActiveViewChange:n,onClaim:a,claimPending:o,claimNudge:d,workflowType:c,json:u,onResolve:p,resolvePending:l,resolveError:i,requestTriage:x,triageNotes:b,onRelease:v,releasePending:y,onCancel:g,assignedTo:j,assignedUntil:k,onSubmitAttempt:h,onValidationErrors:T,escalationContext:S,labels:I={},submitBlocked:$,submitBlockedMessage:W,actingName:E,badgePrompt:A,canManage:R,onReassign:M,onUnassign:O,unassignPending:H}=e,q=Ye(),[Z,V]=m.useState("30"),[K,L]=m.useState(0),[w,_]=m.useState(""),N=Z==="custom",P=m.useCallback(D=>L(D),[]),J=!!$&&!x;if(s==="terminal")return null;const ot=()=>{const D=N?K:parseInt(Z);!D||D<=0||a(D)},Nt=()=>{if(_(""),x){const pt={_lt:{needsTriage:!0}};b.trim()&&(pt.notes=b.trim()),p(pt);return}const D=ie(u,S);if(D.parseError){_(D.parseError);return}if(D.errors.length>0){h==null||h(),T==null||T(D.errors);return}p(D.payload)},G=D=>`text-xs transition-colors ${D?"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(D=>t.jsx("button",{onClick:()=>{V(D.value),L(0)},className:G(!N&&Z===D.value),children:D.label},D.value)),t.jsx("button",{onClick:()=>V("custom"),className:G(N),children:"Other"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[I.cancel!==!1&&t.jsx("button",{onClick:g,className:"text-xs text-text-tertiary hover:text-status-error transition-colors",children:I.cancel??"Cancel escalation"}),t.jsx("div",{className:"flex-1"}),N&&t.jsx(Ze,{onChange:P,compact:!0,autoFocus:!0}),t.jsx("button",{onClick:ot,disabled:o||N&&K<=0,className:`btn-primary text-xs ${d?"animate-[field-shake_0.4s_ease-in-out]":""}`,"data-testid":"claim-button",children:o?"Claiming...":I.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(xe,{userId:j}):"unknown"})]}),k&&t.jsx(Jt,{until:k}),i&&t.jsx("span",{className:"text-xs text-status-error",children:i.message}),A&&t.jsx("p",{className:"text-xs text-text-tertiary","data-testid":"badge-prompt",children:"If this is your claim, scan your badge."}),R&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:M,className:"text-xs text-text-tertiary hover:text-accent transition-colors","data-testid":"admin-reassign",children:"Reassign…"}),t.jsx("button",{onClick:O,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:I.release??"Release"}),I.cancel!==!1&&t.jsx("button",{onClick:g,className:"text-xs transition-colors text-text-tertiary hover:text-status-error",children:I.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(Jt,{until:k}),t.jsx("div",{className:"flex-1"}),w&&t.jsx("span",{className:"text-xs text-status-error",children:w}),i&&t.jsx("span",{className:"text-xs text-status-error",children:i.message}),J&&W&&t.jsx("span",{className:"text-xs text-status-pending","data-testid":"submit-guard-message",children:W}),t.jsx("button",{onClick:Nt,disabled:l||J,className:"btn-primary text-xs",children:l?c?"Submitting...":"Acknowledging...":x?"Send to Triage":I.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 ee({children:e}){return t.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:e})}function ar({payload:e,isTerminal:s,resolverPayload:r,onRetryTriage:n,isRetrying:a}){const o=e.title,d=e.summary,c=e.diagnosis,u=e.tool_calls_made,p=e.result,l=r==null?void 0:r._lt,i=(l==null?void 0:l.triaged)===!0,x=l==null?void 0:l.triageWorkflowId,b=s&&i,[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:[o&&t.jsx("p",{className:"text-sm font-medium text-text-primary",children:o}),c&&t.jsxs("div",{children:[t.jsx(ee,{children:"Triage diagnosis"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Kt,{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:[o&&t.jsx("p",{className:"text-sm font-medium text-text-primary",children:o}),d&&t.jsxs("div",{children:[t.jsx(ee,{children:"What happened"}),t.jsx("div",{className:"text-xs text-text-secondary leading-relaxed",children:t.jsx(Kt,{content:d})})]}),c&&t.jsxs("div",{children:[t.jsx(ee,{children:"What went wrong"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Kt,{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 qe(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function us({src:e,escalation:s,schema:r,onResolve:n,onEscalate:a,submitAttempted:o,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:qe(s.envelope),metadata:s.metadata??null,escalation_payload:qe(s.escalation_payload)},schema:r};l.contentWindow.postMessage(x,u.current)},[s,r]);return m.useEffect(()=>{const l=i=>{if(i.origin!==u.current)return;const x=i.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(!o)return;const l=c.current;l!=null&&l.contentWindow&&u.current&&l.contentWindow.postMessage({type:"lt:validate"},u.current)},[o]),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 ir=2600;function or({hint:e,onLockedClick:s,children:r}){const[n,a]=m.useState(null);m.useEffect(()=>{if(!n)return;const d=setTimeout(()=>a(null),ir);return()=>clearTimeout(d)},[n]);const o=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:o,"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(kn,{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 lr(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 cr({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const o=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(i=>{var v;const x=(v=i.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:o,type:"file",accept:d,onChange:p,className:"hidden"}),t.jsx("button",{type:"button",onClick:()=>{var i;return(i=o.current)==null?void 0:i.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 dr({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const o=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,i=l.selectionStart,x=l.selectionEnd,b=s.substring(0,i)+" "+s.substring(x);r(b),requestAnimationFrame(()=>{l.selectionStart=l.selectionEnd=i+2})}},[s,r]);return t.jsxs("div",{children:[t.jsxs(F,{isRequired:a,children:[o,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 ur({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const o=m.useRef(null),[d,c]=m.useState(!1),u=Y(e,n),p=n==null?void 0:n.description;m.useEffect(()=>{const y=o.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=o.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}},[]),i=m.useCallback(y=>{var k;c(!0);const g=(k=o.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=o.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=o.current;y&&r(y.toDataURL("image/png"))},[r]),v=m.useCallback(()=>{const y=o.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:o,width:400,height:150,className:"w-full cursor-crosshair touch-none",onMouseDown:i,onMouseMove:x,onMouseUp:b,onMouseLeave:b,onTouchStart:i,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 xr({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const o=Y(e,n),d=n==null?void 0:n.description;return t.jsxs("div",{children:[t.jsx(F,{isRequired:a,children:o}),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 pr({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const[o,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(Vt,{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 ${o===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}),o==="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(Vt,{content:s}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"Nothing to preview."})})]})}const mr=28;function fr({fieldKey:e,value:s,onChange:r,schema:n,escalationContext:a,isRequired:o,submitAttempted:d,error:c}){const u=n==null?void 0:n["x-lt-source"],p=(n==null?void 0:n["x-lt-require-all"])===!0,l=[];if(u&&a){const h=u.indexOf(".");if(h!==-1){const T=u.slice(0,h),S=u.slice(h+1);try{const I=Ht(a[T],S);Array.isArray(I)&&l.push(...I)}catch{}}}let i={};try{s&&(i=JSON.parse(s))}catch{}const x=h=>r(JSON.stringify({...i,[h]:!i[h]})),b=Y(e,n),v=n==null?void 0:n.description;if(l.length===0)return t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"No checklist items. Provide checklist_items in the escalation envelope or metadata."}),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:p||l.some(h=>h.label.length>mr)?"rows":"chips",j=l.filter(h=>i[h.id]).length,k=(l.find(h=>!i[h.id]&&h.required!==!1)??l[0]).id;return t.jsxs("div",{role:"group","aria-label":b,"aria-required":o||void 0,"aria-invalid":c?!0:void 0,children:[t.jsx(F,{isRequired:o,children:b}),v&&t.jsx(X,{children:v}),g==="chips"?t.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:l.map(h=>{const T=i[h.id]??!1,S=!T&&!!d&&j===0&&(h.required||o);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)] ${T?"bg-accent border-accent text-text-inverse":S?"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:T,onChange:()=>x(h.id),className:"sr-only","data-testid":`checklist-item-${h.id}`,...h.id===k?{"data-field-key":e}:{}}),T&&t.jsx(_n,{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:l.map(h=>{const T=i[h.id]??!1,S=!T&&!!d&&(p?h.required!==!1:j===0&&(h.required||o));return t.jsxs("label",{className:`flex items-start gap-3 cursor-pointer group select-none rounded px-2 py-1 -mx-2 transition-colors ${S?"bg-status-error/5":"hover:bg-surface-hover"}`,children:[t.jsx("input",{type:"checkbox",checked:T,onChange:()=>x(h.id),className:`mt-0.5 w-3.5 h-3.5 shrink-0 rounded ${S?"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 ${S?"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 ${S?"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",o&&j===0&&!!d&&t.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(check at least one)"})]}):t.jsxs(t.Fragment,{children:[j," / ",l.length," confirmed",p?t.jsxs("span",{className:"ml-1 text-text-quaternary/60",children:["(all required",l.some(h=>h.required===!1)?" except optional":"",")"]}):o&&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 gr=/\.(png|jpe?g|gif|webp|avif|bmp|svg)(\?.*)?$/i;function hr(e){var n,a,o,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(gr.test(s))return{kind:"image",src:s};const c=(d=(o=/\.([a-z0-9]{2,5})(\?.*)?$/i.exec(s))==null?void 0:o[1])==null?void 0:d.toUpperCase();return{kind:"file",href:s,label:c??"attachment",isData:!1}}return{kind:"none"}}function Ue({fieldKey:e,value:s,schema:r}){const[n,a]=m.useState(!1),o=hr(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 o.kind==="none"?t.jsxs("div",{children:[u,t.jsx("p",{className:"text-xs text-text-quaternary italic mt-1",children:"No attachment"})]}):o.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:o.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:o.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:o.href,...o.isData?{download:`${e}.${o.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(Cn,{className:"w-3.5 h-3.5",strokeWidth:1.5}),o.isData?`Download ${o.label}`:`Open ${o.label}`,o.isData?t.jsx(En,{className:"w-3 h-3",strokeWidth:1.5}):t.jsx(ae,{className:"w-3 h-3",strokeWidth:1.5})]})})]})}function br({fieldKey:e,schema:s,escalationContext:r}){const n=(s==null?void 0:s["x-lt-href"])??"",a=n&&r?it(n,r):n,o=(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:o}),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:[o,t.jsx(ae,{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:[o,t.jsx(ae,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]})})]})}function xs({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(An,{className:"w-3.5 h-3.5",strokeWidth:2}),t.jsx("span",{className:"sr-only",children:"View details"})]})}const Ve="—";function yr(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 o=Ht(s[n],a);return typeof o=="string"?o:""}catch{return""}}function jr(e,s){if(!e||e===Ve)return Ve;if(s==="age"){const r=new Date(e);return Number.isNaN(r.getTime())?e:le(e)}return e}function Nr({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"])??[],o=(s==null?void 0:s.title)??"Linked escalation",d=s==null?void 0:s.description,c=yr(n,r),{data:u,isLoading:p,isError:l}=Xe(c);return t.jsxs("div",{"data-field-key":e,children:[t.jsx(F,{children:o}),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(wr,{}):u?t.jsx(vr,{esc:u,fields:a,fieldKey:e}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"No linked record"})})]})}function vr({esc:e,fields:s,fieldKey:r}){if(!e)return null;const n=ue(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(ss,{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 o=it(a.value,n),d=jr(o,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(xs,{to:`/escalations/detail/${e.id}`})]})]})}function wr(){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 kr(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 ps(e,s,r){const n=kr(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 _r=[{label:"Description",value:"{{escalation.description}}"},{label:"Role",value:"{{escalation.role}}"},{label:"Age",value:"{{escalation.created_at}}",format:"age"}],Je="—";function Cr(e,s){if(!e||e===Je)return Je;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 Er({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"])??_r,o=(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=ps(n,u,p==null?void 0:p.userId),{data:i,isLoading:x}=Ge({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:un({columns:a,actions:o})?"envelope":void 0}),b=(i==null?void 0:i.escalations)??[],v=Qe(),[y,g]=m.useState({}),[j,k]=m.useState(null),h=async(T,S)=>{const I=ue(T);if(!(S.confirm&&!window.confirm(it(S.confirm,I)))){k(T.id),g($=>({...$,[T.id]:""}));try{await v.mutateAsync({id:T.id,resolverPayload:oe(S.resolverPayload,I)})}catch($){g(W=>({...W,[T.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(Tr,{columns:a.length}):t.jsx(Ar,{escalations:b,columns:a,fieldKey:e,actions:o,onAction:h,pendingRow:j,rowErrors:y})})]})}function Ar({escalations:e,columns:s,fieldKey:r,actions:n,onAction:a,pendingRow:o,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=ue(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 i=it(l.value,u),x=Cr(i,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:o===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(xs,{to:`/escalations/detail/${c.id}`})})]},c.id)})})]})}function Tr({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 se={"file-upload":cr,"code-editor":dr,signature:ur,"rich-text":xr,markdown:pr,checklist:fr,attachment:Ue,image:Ue,link:br,escalation:Nr,"escalation-list":Er};function ms({fieldKey:e,value:s,onChange:r,onBlur:n,schema:a,isRequired:o,isReadOnly:d,error:c,escalationContext:u,submitAttempted:p}){var W;const l=(W=a==null?void 0:a.properties)==null?void 0:W[e],i=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":o||void 0,"aria-invalid":c?!0:void 0,"aria-describedby":c?v:g!==void 0?y:void 0},T=x==="markdown"&&typeof s=="string",S=(x==="attachment"||x==="image")&&typeof s=="string",I=!!(x&&x in se);if(d&&!T&&!S&&!I){const E=s===null?"null":typeof s=="object"?JSON.stringify(s,null,2):String(s);return t.jsxs("div",{children:[t.jsx(F,{isRequired:o,children:i}),t.jsx("p",{className:"text-sm text-text-secondary mt-0.5 whitespace-pre-wrap",children:E})]})}if(x&&x in se){const E=se[x],A=o||(l==null?void 0:l["x-lt-require-all"])===!0,R={fieldKey:e,schema:l,escalationContext:u,isRequired:A,submitAttempted:p,error:c};if((l==null?void 0:l.type)==="object"){const M=typeof s=="string"?s:typeof s=="object"&&s!==null&&!Array.isArray(s)?JSON.stringify(s):"";return t.jsx(E,{...R,value:M,onChange:O=>{try{r(JSON.parse(O))}catch{r(O)}}})}if(typeof s=="string")return t.jsx(E,{...R,value:s,onChange:M=>r(M)});if(typeof s=="object"&&s!==null&&!Array.isArray(s))return t.jsx(E,{...R,value:JSON.stringify(s),onChange:M=>{try{r(JSON.parse(M))}catch{r(M)}}})}const $=ls(l,u);if($&&(s===null||typeof s=="string"||typeof s=="number")){const E=s===null?"":String(s),A=$.some(R=>String(R)===E);return t.jsxs("div",{children:[t.jsx(F,{isRequired:o,htmlFor:b,children:i}),g&&t.jsx(X,{id:y,children:g}),t.jsxs("select",{value:A?E:"",disabled:$.length===0,onChange:R=>{const M=$.find(O=>String(O)===R.target.value);r(M??R.target.value)},onBlur:n,"data-field-key":e,className:lr(!!c),...h,children:[!A&&t.jsx("option",{value:"",disabled:!0,children:"Choose…"}),$.map(R=>t.jsx("option",{value:String(R),children:String(R)},String(R)))]}),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:[i,o&&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:o,htmlFor:b,children:i}),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:o,htmlFor:b,children:i}),g&&t.jsx(X,{id:y,children:g}),t.jsx("input",{type:"password",value:s,onChange:O=>r(O.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,R={date:"date","date-time":"datetime-local",email:"email",uri:"url"},M={date:"max-w-48","date-time":"max-w-64"};if(A&&A in R)return t.jsxs("div",{children:[t.jsx(F,{isRequired:o,htmlFor:b,children:i}),g&&t.jsx(X,{id:y,children:g}),t.jsx("input",{type:R[A],value:s,onChange:O=>r(O.target.value),onBlur:n,"data-field-key":e,className:`${At(!!c)} ${M[A]??""}`,...h}),t.jsx(ut,{error:c,id:v})]});if(A==="textarea"||s.length>80){const O=l==null?void 0:l.maxLength,H=l==null?void 0:l["x-lt-max-length"];let q=O;if(q===void 0&&H&&u){const V=H.indexOf(".");if(V!==-1){const K=H.slice(0,V),L=H.slice(V+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:o,htmlFor:b,children:i}),g&&t.jsx(X,{id:y,children:g}),t.jsx("textarea",{value:s,onChange:V=>{r(V.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:o,htmlFor:b,children:i}),g&&t.jsx(X,{id:y,children:g}),t.jsx("input",{type:"text",value:s,onChange:O=>r(O.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:o,children:i}),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:o,children:i}),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:o,children:i}),t.jsx("div",{className:"ml-4 mt-2 pl-4 border-l border-accent-faint space-y-3",children:E.map(([A,R])=>t.jsx(ms,{fieldKey:A,value:R,onChange:M=>r({...s,[A]:M})},A))})]})}return null}function Rr({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:o})=>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:Or(o)})]},n))})})}function Or(e){return e==null||e===""?"—":typeof e=="boolean"?e?"Yes":"No":typeof e=="object"?JSON.stringify(e):String(e)}const ne="dictionary",Mr=new Set(["markdown","attachment","image"]);function fs(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 Sr(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"&&Mr.has(a))return!1;const o=n==null?void 0:n["x-lt-display"];if(typeof o=="string")return o===ne;const d=(u=fs(e,s))==null?void 0:u.display;return typeof d=="string"?d===ne:(e==null?void 0:e["x-lt-display"])===ne}function Ir(e,s,r,n){var o;const a=[];for(const d of e){const[c]=d,u=a[a.length-1];if(Sr(s,r,c)){(u==null?void 0:u.kind)==="dictionary"?u.entries.push(d):a.push({kind:"dictionary",entries:[d]});continue}const p=(o=s==null?void 0:s.properties)==null?void 0:o[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 Dr({name:e,entries:s,formSchema:r,layout:n,renderField:a}){const o=Ir(s,r,e,n),d=fs(r,e),c=(d==null?void 0:d.columns)??(n==="two-column"?2:1),u=l=>l.map(([i,x])=>{var b;return{key:i,label:Y(i,(b=r==null?void 0:r.properties)==null?void 0:b[i]),value:x}}),p=()=>o.map((l,i)=>l.kind==="dictionary"?t.jsx("div",{className:n==="two-column"?"col-span-full":"",children:t.jsx(Rr,{items:u(l.entries),columns:c})},`dict-${i}`):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}-${i}`):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 gs({value:e,onChange:s,disabled:r,submitAttempted:n,escalationContext:a,onOpenHelp:o,onDisabledClick:d,disabledHint:c}){var K,L;const[u,p]=m.useState({}),[l,i]=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,J]of Object.entries(w))P.startsWith("_")?N[P]=J:_[P]=J;p(_),i(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]),T=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 S=Object.entries(u);if(S.length===0)return t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No resolver fields defined."});const I=x==null?void 0:x["x-lt-order"],$=I?[...S].sort((w,_)=>{const N=I.indexOf(w[0]),P=I.indexOf(_[0]);return(N===-1?1/0:N)-(P===-1?1/0:P)}):S,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)??[]),R=x==null?void 0:x["x-lt-layout"],M=x==null?void 0:x.title,O=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,J=q[q.length-1];!J||J.name!==P?q.push({name:P,entries:[w]}):J.entries.push(w)}const Z=([w,_])=>{var D;const N=(D=x==null?void 0:x.properties)==null?void 0:D[w],P=(N==null?void 0:N.readOnly)===!0,J=(N==null?void 0:N["x-lt-span"])??1,ot=A.has(w),Nt=g.has(w)||!!n,G=cs(_,N,ot,Nt,W);return t.jsx("div",{className:`animate-[field-enter_0.2s_ease-out] ${R==="two-column"&&J>=2?"col-span-full":""}`,children:t.jsx(ms,{fieldKey:w,value:_,onChange:pt=>h(w,pt),onBlur:()=>T(w),schema:x,isRequired:ot,isReadOnly:P,error:G,escalationContext:W,submitAttempted:!!n})},w)},V=t.jsxs("div",{className:r?"pointer-events-none":void 0,inert:r||void 0,"aria-disabled":r||void 0,children:[M&&t.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.jsx("h3",{className:"heading-3",children:M}),H&&o&&t.jsx("button",{type:"button",onClick:o,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(ns,{className:"w-4 h-4",strokeWidth:1.5})})]}),O&&t.jsx("p",{className:"text-sm text-text-secondary leading-relaxed mb-6",children:O}),t.jsx("div",{className:"space-y-8",children:q.map((w,_)=>t.jsx(Dr,{name:w.name,entries:w.entries,formSchema:x,layout:R,renderField:Z},w.name??`__s${_}`))})]});return r?t.jsx(or,{hint:c,onLockedClick:d,children:V}):t.jsx("div",{className:"pb-8 max-w-form",children:V})}function $r({json:e,onJsonChange:s,requestTriage:r,onRequestTriageChange:n,triageNotes:a,onTriageNotesChange:o,disabled:d=!1,submitAttempted:c=!1,showTriage:u=!1,escalationContext:p,onOpenHelp:l,onDisabledClick:i,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(gs,{value:e,onChange:s,disabled:d,submitAttempted:c,escalationContext:p,onOpenHelp:l,onDisabledClick:i,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=>o(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 hs(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,o)=>Object.prototype.hasOwnProperty.call(n,o)?String(n[o]):`{${o}}`)}catch{return e}}function He(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:He(e.envelope),payload:He(e.escalation_payload),resolver:null,...s?{lookup:s}:{}}}function Lr({isRoundsExhausted:e,payloadObj:s,isTerminal:r,resolverPayload:n,onRetryTriage:a,isRetrying:o}){return t.jsxs(t.Fragment,{children:[e&&s&&t.jsx("div",{className:"mt-8",children:t.jsx(ar,{payload:s,isTerminal:r,resolverPayload:n,onRetryTriage:a,isRetrying:o})}),(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(Ie,{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(Ie,{size:12}),"Go to Credentials"]})]})]})]})}function Pr({esc:e,resolverPayload:s,isTerminal:r,claimedByMe:n,activeView:a,metadataFormSchema:o,effectiveSchema:d,lookup:c,json:u,onJsonChange:p,requestTriage:l,onRequestTriageChange:i,triageNotes:x,onTriageNotesChange:b,onResolve:v,onEscalate:y,onClaim:g,submitAttempted:j,isCertified:k,hasAI:h,onOpenHelp:T,onDisabledClick:S,disabledHint:I}){const $=d,W=xt(e,c);if(r){if(s==null)return null;const M=typeof s=="object"&&s!==null?s:{},O=d??o,H=O!=null&&O.properties?{...es(M,O),_form_schema:O}:M;return t.jsx("div",{className:"mt-3",children:t.jsx(gs,{value:JSON.stringify(H,null,2),onChange:()=>{},disabled:!0,escalationContext:W,disabledHint:I})})}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(Tn,{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 R=A?hs(E.src,e):"";return t.jsx("div",{className:"mt-3",children:A?t.jsx(us,{src:R,escalation:e,schema:$,onResolve:v,onEscalate:y,submitAttempted:j}):t.jsx($r,{json:u,onJsonChange:p,requestTriage:l,onRequestTriageChange:i,triageNotes:x,onTriageNotesChange:b,disabled:!n,submitAttempted:j,showTriage:!!k&&!!h,escalationContext:W,onOpenHelp:T,onDisabledClick:S,disabledHint:I})})}function Fr({open:e,assignedUntil:s,onClose:r,onExtend:n,isPending:a}){const o=Ye(),[d,c]=m.useState("30"),[u,p]=m.useState(0),l=d==="custom",i=l?u:parseInt(d),x=m.useCallback(b=>p(b),[]);return t.jsx(Ke,{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(Jt,{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:[o.map(b=>t.jsx("option",{value:b.value,children:b.label},b.value)),t.jsx("option",{value:"custom",children:"Other..."})]}),l&&t.jsx(Ze,{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(i),className:"btn-primary text-xs",disabled:a||!i||i<=0,children:a?"Extending...":"Extend Claim"})]})]})})}const Wr=9e4;function qr(e,s=Wr){const[,r]=m.useState(0);if(m.useEffect(()=>{if(!e)return;const a=new Date(e).getTime()-Date.now();if(a<=0)return;const o=()=>r(u=>u+1),d=[],c=a-s;return c>0&&d.push(window.setTimeout(o,c)),d.push(window.setTimeout(o,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 Ur="lt:escalation:draft:";function me(e){return`${Ur}${e}`}function Vr(e){try{return localStorage.getItem(me(e))}catch{return null}}function Jr(e,s){try{localStorage.setItem(me(e),s)}catch{}}function re(e){try{localStorage.removeItem(me(e))}catch{}}const Hr="x-lt-transition",Br="x-lt-transition-message",zr="x-lt-transition-max-wait-seconds",Xr="x-lt-transition-done",Gr="Submitted. Preparing your next step…",Qr=30,Yr=5,Zr=300;function Kr(e){const s=typeof e=="number"?e:Number(e);return!Number.isFinite(s)||s<=0?Qr:Math.min(Zr,Math.max(Yr,Math.round(s)))}function Be(e){if(!e||!e[Hr])return null;const s=e[Br];return{message:typeof s=="string"&&s.trim().length>0?s:Gr,maxWaitSeconds:Kr(e[zr])}}function ta(e){const s=e==null?void 0:e[Xr];return typeof s=="string"&&s.trim().length>0?s:null}const ea="x-lt-submit-on-claim";function sa(e){return!!(e!=null&&e[ea])}const na="x-lt-submit-guard",ra="{{count}} related items are still pending";function aa(e){const s=e==null?void 0:e[na];if(!s||typeof s!="object"||Array.isArray(s))return;const r=s;if(!(!r.query||typeof r.query!="object"))return r}function ia(e,s){const{user:r}=ce(),n=ps((e==null?void 0:e.query)??{},s??{},r==null?void 0:r.userId),{data:a,isSuccess:o}=Ge({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&&o&&c===0,p=d&&!u;let l="";if(p)if(c>0){const i=(e==null?void 0:e.message)??ra;l=it(i.replace(/\{\{count\}\}/g,String(c)),s??{})}else l="Checking related items…";return{blocked:p,count:c,message:l,confirmedEmpty:u}}function oa({open:e,message:s}){return e?sn.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(Vt,{content:s})})]})]}),document.body):null}const bs="lt:escalation:panel:open";function la(){try{const e=localStorage.getItem(bs);return e===null?!0:e==="true"}catch{return!0}}function Tt(e){try{localStorage.setItem(bs,String(e))}catch{}}function Rt(e){if(!e)return null;try{return JSON.parse(e)}catch{return e}}function Sa(){const{id:e}=nn();return t.jsx(ca,{id:e},e)}function ca({id:e}){var _e,Ce,Ee,Ae,Te;const{user:s,isSuperAdmin:r,hasRoleType:n}=ce(),a=r||n("admin"),{identity:o}=qs(),d=Us(),c=(o==null?void 0:o.actorId)??(s==null?void 0:s.userId),u=de(),p=ts(),l=ze(),{data:i,isLoading:x,refetch:b,isFetching:v}=Xe(e);pn(e);const y=m.useMemo(()=>{if(!(i!=null&&i.envelope))return!1;try{const f=JSON.parse(i.envelope);return Array.isArray(f==null?void 0:f.lookups)&&f.lookups.length>0}catch{return!1}},[i==null?void 0:i.envelope]),{data:g}=Vs(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=Js(),h=Qe(),T=Hs(),S=Bs(),I=zs(),$=Xs(),[W,E]=m.useState(!1),[A,R]=m.useState(!1),{data:M}=xn(),{data:O}=Gs(),{isBuilder:H}=Qs(),q=M==null?void 0:M.find(f=>f.workflow_type===(i==null?void 0:i.workflow_type)),Z=((_e=O==null?void 0:O.telemetry)==null?void 0:_e.traceUrl)??null,[V,K]=m.useState("resolve"),[L,w]=m.useState("{}"),[_,N]=m.useState(la),[P,J]=m.useState(!1),[ot,Nt]=m.useState(""),[G,D]=m.useState(!1),[pt,vt]=m.useState([]),[ys,js]=m.useState(0),[Ns,wt]=m.useState(void 0),[tt,Bt]=m.useState(null),[vs,fe]=m.useState(!1),ge=m.useRef(!1),Mt=m.useRef(null),he=m.useRef(!1),St=m.useRef(null),ws=qr(i==null?void 0:i.assigned_until),[ks,_s]=m.useState(null);m.useEffect(()=>{if(!(!G||!i))try{const f=JSON.parse(L),C=f._form_schema;if(!C){vt([]);return}vt(ds(C,f,xt(i,j)))}catch{}},[L,G,i]);const It=((Ce=i==null?void 0:i.metadata)==null?void 0:Ce.form_schema)??null,mt=(i==null?void 0:i.form_schema)??(q==null?void 0:q.resolver_schema)??null,U=It??mt,be=sa(U),et=Ks(U),kt=aa(U),_t=ia(kt,i?xt(i,j):void 0),Dt=m.useRef(!1),$t=m.useRef(null);m.useEffect(()=>{if(Dt.current)return;const f=It??(mt!=null&&mt.properties?mt:null);if(f!=null&&f.properties){Dt.current=!0;const C=Rt(i==null?void 0:i.envelope),B=C==null?void 0:C.formDefaults,Q={...(i==null?void 0:i.metadata)??{},...typeof B=="object"&&B!==null?B:{}},ct=es(Q,f),rt={_form_schema:f};for(const[Oe,$s]of Object.entries(f.properties)){const Me=$s,Ls=Me.type==="object"?{}:"";rt[Oe]=ct[Oe]??Me.default??Ls}$t.current=JSON.stringify(rt,null,2);const Re=!((i==null?void 0:i.status)==="resolved"||(i==null?void 0:i.status)==="cancelled")&&(i!=null&&i.id)?Vr(i.id):null,Ft=Re?Rt(Re):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,It,mt,i==null?void 0:i.envelope,i==null?void 0:i.metadata,i==null?void 0:i.id,i==null?void 0:i.status]),m.useEffect(()=>{if(!Dt.current||$t.current===null||!(i!=null&&i.id)||i.status!=="pending")return;const f=i.id,C=window.setTimeout(()=>{L===$t.current?re(f):Jr(f,L)},400);return()=>window.clearTimeout(C)},[L,i==null?void 0:i.id,i==null?void 0:i.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){Bt(null),u(`/escalations/detail/${rt.id}`);return}}catch{}Bt(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;ge.current||(f=p.state)!=null&&f.autoStart&&(!i||i.status!=="pending"||qt(i)||L!=="{}"&&(ge.current=!0,(C=Mt.current)==null||C.call(Mt)))},[i,L,p.state]),m.useEffect(()=>{var f;he.current||!(kt!=null&&kt.autoResolveWhenEmpty)||!_t.confirmedEmpty||!i||i.status!=="pending"||!qt(i)||i.assigned_to===c&&L!=="{}"&&(he.current=!0,(f=St.current)==null||f.call(St))},[_t.confirmedEmpty,kt,i,L,c]);const Cs=(i==null?void 0:i.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(!i)return t.jsx("p",{className:"text-sm text-text-secondary",children:"Escalation not found."});const zt=qt(i),st=zt&&i.assigned_to===c,ye=zt&&!st,ft=i.status==="resolved"||i.status==="cancelled",lt=U==null?void 0:U["x-lt-viewport"],Xt=(lt==null?void 0:lt.type)==="iframe"&&!!(lt!=null&&lt.src)&&st&&!ft,Lt=Rt(i.escalation_payload),gt=Rt(i.resolver_payload),Pt=Rt(i.envelope),Es=!!((Ee=Pt==null?void 0:Pt.metadata)!=null&&Ee.certified),je=Ys(),Ne=je!==null?je:!!((Ae=O==null?void 0:O.ai)!=null&&Ae.enabled),nt=typeof Lt=="object"&&Lt!==null&&!Array.isArray(Lt)?Lt:null,As=nt==null?void 0:nt._triage,Ts=typeof gt=="object"&&gt!==null&&!Array.isArray(gt)?gt:null,Gt=ft?"terminal":st?"claimed_by_me":ye?"claimed_by_other":"available",Rs=Gt==="available"?`${typeof et.claim=="string"?et.claim:"Claim"} this escalation to edit the form`:Gt==="claimed_by_other"?t.jsxs(t.Fragment,{children:["Claimed by ",i.assigned_to?t.jsx(xe,{userId:i.assigned_to}):"another user"]}):i.status==="cancelled"?"This escalation is cancelled":i.status==="resolved"?"This escalation is resolved — the submitted values are shown":null,Qt=f=>{k.mutate({id:e,durationMinutes:f})},Ct=()=>{l.resetQueries({queryKey:["escalations"]}),l.resetQueries({queryKey:["escalationStats"]}),u(-1)},Os=()=>{const f=ta(U);return f&&it(f,xt(i,j))||null},Ms=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 Zs&&Sn(Q.body)){D(!0),vt(Q.body.violations),wt(z.ERRORS);return}throw Q}re(e);const C=Be(U),B=Os();if(C){Bt({...C,doneDest:B});return}if(B){Ms(B);return}Ct()},ve=async f=>{try{await k.mutateAsync({id:e,durationMinutes:f})}catch{return}if(_t.blocked)return;const C=ie(L,xt(i,j));if(!C.parseError){if(C.errors.length>0){D(!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;fe(!0),await ve(typeof f=="number"&&f>0?f:30),fe(!1)},St.current=()=>{const f=ie(L,xt(i,j));f.parseError||f.errors.length>0||Et(f.payload)};const we=async f=>{f&&(await T.mutateAsync({id:e,targetRole:f}),Ct())},Ss=async()=>{st||await k.mutateAsync({id:e,durationMinutes:30});const f=(nt==null?void 0:nt.diagnosis)||i.description||"";await h.mutateAsync({id:e,resolverPayload:{_lt:{needsTriage:!0},notes:f}}),Ct()},ke=async()=>{await k.mutateAsync({id:e,durationMinutes:0}),Ct()},Is=async()=>{await S.mutateAsync(e),re(e),E(!1),Ct()},Ds=t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(an,{onRefresh:()=>b(),isFetching:v,apiPath:`/escalations/${i.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(De,{className:"w-5 h-5",strokeWidth:1.5}):t.jsx($e,{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:[Xt?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:ke,disabled:k.isPending,label:et.release??"Release",hoverClass:"hover:text-accent",icon:t.jsx(Rn,{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(On,{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(De,{className:"w-4 h-4",strokeWidth:1.5}):t.jsx($e,{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(us,{src:hs(lt.src,i),escalation:i,schema:U,onResolve:Et,onEscalate:we,submitAttempted:G,fill:!0})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"shrink-0 pt-8 pr-page-x",children:t.jsx(rn,{title:i.description||"Escalation",actions:Ds})}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto pr-page-x",children:[t.jsx(Lr,{isRoundsExhausted:Cs,payloadObj:nt,isTerminal:ft,resolverPayload:gt,onRetryTriage:Ss,isRetrying:k.isPending||h.isPending}),t.jsx(Pr,{esc:i,resolverPayload:gt,isTerminal:ft,claimedByMe:st,activeView:V,lookup:j,metadataFormSchema:It,effectiveSchema:U,json:L,onJsonChange:w,requestTriage:P,onRequestTriageChange:J,triageNotes:ot,onTriageNotesChange:Nt,onResolve:Et,onEscalate:we,onClaim:()=>Qt(30),submitAttempted:G,isCertified:Es,hasAI:Ne,onOpenHelp:()=>{N(!0),Tt(!0),wt(z.HELP)},onDisabledClick:()=>js(f=>f+1),disabledHint:Rs}),t.jsx("div",{className:"h-10"})]})]}),!Xt&&t.jsx(rr,{escalationContext:xt(i,j),mode:Gt,activeView:V,onActiveViewChange:K,onClaim:be?ve:Qt,claimPending:k.isPending||be&&h.isPending,claimNudge:ys,workflowType:i.workflow_type,json:L,onResolve:Et,resolvePending:h.isPending||h.isSuccess,resolveError:h.error,requestTriage:P,triageNotes:ot,onRelease:ke,releasePending:k.isPending,onCancel:()=>E(!0),assignedTo:i.assigned_to,assignedUntil:i.assigned_until,actingName:o&&st?o.displayName:null,badgePrompt:d&&!o&&ye,onSubmitAttempt:()=>D(!0),onValidationErrors:f=>{vt(f),N(!0),Tt(!0),wt(z.ERRORS)},labels:et,submitBlocked:_t.blocked,submitBlockedMessage:_t.message,canManage:a,onReassign:()=>R(!0),onUnassign:()=>$.mutate({ids:[e]}),unassignPending:$.isPending})]}),t.jsx(Jn,{esc:i,schema:U,envelope:Pt,payload:nt,resolver:Ts,triage:As??null,hasAI:Ne,claimed:zt,claimedByMe:st,isTerminal:ft,isBuilder:H,traceUrl:Z,open:_,noGutter:Xt,formErrors:pt,activePanel:Ns,onPanelChange:wt}),t.jsx(tn,{open:A,onClose:()=>R(!1),selectedCount:1,selectedRoles:i?[i.role]:[],onSubmit:(f,C)=>I.mutate({ids:[e],targetUserId:f,durationMinutes:C,reassign:!0},{onSuccess:()=>R(!1)}),isPending:I.isPending}),t.jsx(en,{open:W,onClose:()=>E(!1),onConfirm:Is,isPending:S.isPending,error:S.error,actionLabel:typeof et.cancel=="string"?et.cancel:void 0}),t.jsx(In,{escalationId:e}),t.jsx(oa,{open:!!tt||vs,message:(tt==null?void 0:tt.message)??((Te=Be(U))==null?void 0:Te.message)??"Starting…"}),st&&!ft&&i.assigned_until&&t.jsx(Fr,{open:ws.expiringSoon&&i.assigned_until!==ks,assignedUntil:i.assigned_until,onClose:()=>_s(i.assigned_until??null),onExtend:Qt,isPending:k.isPending})]})}export{Sa as EscalationDetailPage};
3
- //# sourceMappingURL=index-CK_ohh6Q.js.map