@hotmeshio/long-tail 0.8.3 → 0.8.5

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 (217) hide show
  1. package/build/api/escalations/create.js +19 -60
  2. package/build/api/escalations/index.d.ts +1 -1
  3. package/build/api/escalations/index.js +2 -1
  4. package/build/api/escalations/resolve.d.ts +28 -0
  5. package/build/api/escalations/resolve.js +110 -4
  6. package/build/api/escalations/single.js +8 -4
  7. package/build/api/roles.d.ts +1 -0
  8. package/build/lib/db/index.js +12 -1
  9. package/build/lib/db/migrate.js +27 -0
  10. package/build/modules/defaults.d.ts +2 -0
  11. package/build/modules/defaults.js +3 -1
  12. package/build/routes/escalations/resolve.js +18 -0
  13. package/build/scripts/twin-farm.d.ts +12 -13
  14. package/build/scripts/twin-farm.js +61 -75
  15. package/build/sdk/index.d.ts +8 -0
  16. package/build/sdk/index.js +1 -0
  17. package/build/services/escalation/crud.d.ts +36 -0
  18. package/build/services/escalation/crud.js +53 -0
  19. package/build/services/escalation/queries.d.ts +13 -0
  20. package/build/services/escalation/queries.js +27 -0
  21. package/build/services/maintenance/index.js +22 -0
  22. package/build/services/orchestrator/condition.d.ts +18 -12
  23. package/build/services/orchestrator/condition.js +11 -8
  24. package/build/services/role/index.d.ts +1 -2
  25. package/build/services/role/index.js +1 -2
  26. package/build/services/role/schema-validator.d.ts +9 -0
  27. package/build/services/role/schema-validator.js +42 -0
  28. package/build/services/role/sql.d.ts +1 -1
  29. package/build/services/role/sql.js +2 -2
  30. package/build/services/role/types.d.ts +8 -6
  31. package/build/system/mcp-servers/admin/schemas.js +4 -2
  32. package/build/system/mcp-servers/human-queue-schemas.js +6 -2
  33. package/build/system/mcp-servers/human-queue.js +11 -3
  34. package/build/tsconfig.tsbuildinfo +1 -1
  35. package/build/types/config.d.ts +2 -0
  36. package/build/types/maintenance.d.ts +6 -1
  37. package/build/types/startup.d.ts +5 -1
  38. package/dashboard/dist/assets/{AdminDashboard-Dhr7sUq6.js → AdminDashboard-RrSvb8d-.js} +2 -2
  39. package/dashboard/dist/assets/{AdminDashboard-Dhr7sUq6.js.map → AdminDashboard-RrSvb8d-.js.map} +1 -1
  40. package/dashboard/dist/assets/{AgentConfigPage-CUPm8FjH.js → AgentConfigPage-5RMdI0ku.js} +2 -2
  41. package/dashboard/dist/assets/{AgentConfigPage-CUPm8FjH.js.map → AgentConfigPage-5RMdI0ku.js.map} +1 -1
  42. package/dashboard/dist/assets/{AgentDetailPage-C9Tmmhhc.js → AgentDetailPage-C_-sIBcr.js} +2 -2
  43. package/dashboard/dist/assets/{AgentDetailPage-C9Tmmhhc.js.map → AgentDetailPage-C_-sIBcr.js.map} +1 -1
  44. package/dashboard/dist/assets/{AgentsPage-Pj47ZJ2U.js → AgentsPage-CxNNtSsf.js} +2 -2
  45. package/dashboard/dist/assets/{AgentsPage-Pj47ZJ2U.js.map → AgentsPage-CxNNtSsf.js.map} +1 -1
  46. package/dashboard/dist/assets/{AvailableEscalationsPage-BxakNqha.js → AvailableEscalationsPage-BcbhA6NE.js} +2 -2
  47. package/dashboard/dist/assets/{AvailableEscalationsPage-BxakNqha.js.map → AvailableEscalationsPage-BcbhA6NE.js.map} +1 -1
  48. package/dashboard/dist/assets/{BotPicker-CCIo5ic0.js → BotPicker-BQVz6bye.js} +2 -2
  49. package/dashboard/dist/assets/{BotPicker-CCIo5ic0.js.map → BotPicker-BQVz6bye.js.map} +1 -1
  50. package/dashboard/dist/assets/{CapabilitiesPage-XFVq4iPX.js → CapabilitiesPage-DlZ8SgO3.js} +2 -2
  51. package/dashboard/dist/assets/{CapabilitiesPage-XFVq4iPX.js.map → CapabilitiesPage-DlZ8SgO3.js.map} +1 -1
  52. package/dashboard/dist/assets/{CollapsibleSection-CBKICsCu.js → CollapsibleSection-lo8Qx4zb.js} +2 -2
  53. package/dashboard/dist/assets/{CollapsibleSection-CBKICsCu.js.map → CollapsibleSection-lo8Qx4zb.js.map} +1 -1
  54. package/dashboard/dist/assets/{CredentialsPage-BN_d7ybc.js → CredentialsPage-DJ9DyXsO.js} +2 -2
  55. package/dashboard/dist/assets/{CredentialsPage-BN_d7ybc.js.map → CredentialsPage-DJ9DyXsO.js.map} +1 -1
  56. package/dashboard/dist/assets/{CronLabel-4V_EXMUg.js → CronLabel-o0dbisw1.js} +2 -2
  57. package/dashboard/dist/assets/{CronLabel-4V_EXMUg.js.map → CronLabel-o0dbisw1.js.map} +1 -1
  58. package/dashboard/dist/assets/{CustomDurationPicker-BdurQj-B.js → CustomDurationPicker-CGiwKSVJ.js} +2 -2
  59. package/dashboard/dist/assets/{CustomDurationPicker-BdurQj-B.js.map → CustomDurationPicker-CGiwKSVJ.js.map} +1 -1
  60. package/dashboard/dist/assets/{ElapsedCell-CO8XMSJX.js → ElapsedCell-N22STQcg.js} +2 -2
  61. package/dashboard/dist/assets/{ElapsedCell-CO8XMSJX.js.map → ElapsedCell-N22STQcg.js.map} +1 -1
  62. package/dashboard/dist/assets/EscalationSchemaPage-Zsmewko2.js +9 -0
  63. package/dashboard/dist/assets/EscalationSchemaPage-Zsmewko2.js.map +1 -0
  64. package/dashboard/dist/assets/{EscalationsOverview-qlo0mxxa.js → EscalationsOverview-CE2p70Ct.js} +2 -2
  65. package/dashboard/dist/assets/{EscalationsOverview-qlo0mxxa.js.map → EscalationsOverview-CE2p70Ct.js.map} +1 -1
  66. package/dashboard/dist/assets/{EventTable-D9RjAT_a.js → EventTable-B3Gj7Ayg.js} +2 -2
  67. package/dashboard/dist/assets/{EventTable-D9RjAT_a.js.map → EventTable-B3Gj7Ayg.js.map} +1 -1
  68. package/dashboard/dist/assets/{GraphInvokePage-CU3r2tzN.js → GraphInvokePage-DywWVSdj.js} +2 -2
  69. package/dashboard/dist/assets/{GraphInvokePage-CU3r2tzN.js.map → GraphInvokePage-DywWVSdj.js.map} +1 -1
  70. package/dashboard/dist/assets/{HomePage-B7pb4-Gx.js → HomePage-CxtBiULd.js} +2 -2
  71. package/dashboard/dist/assets/{HomePage-B7pb4-Gx.js.map → HomePage-CxtBiULd.js.map} +1 -1
  72. package/dashboard/dist/assets/{ListToolbar-C_64Y22Z.js → ListToolbar-Ok2O0wmC.js} +2 -2
  73. package/dashboard/dist/assets/{ListToolbar-C_64Y22Z.js.map → ListToolbar-Ok2O0wmC.js.map} +1 -1
  74. package/dashboard/dist/assets/{McpOverview-D-4eSOTc.js → McpOverview-CTCYZXIp.js} +2 -2
  75. package/dashboard/dist/assets/{McpOverview-D-4eSOTc.js.map → McpOverview-CTCYZXIp.js.map} +1 -1
  76. package/dashboard/dist/assets/{McpQueryDetailPage-BYwDb8LC.js → McpQueryDetailPage-BOaXf0bZ.js} +2 -2
  77. package/dashboard/dist/assets/{McpQueryDetailPage-BYwDb8LC.js.map → McpQueryDetailPage-BOaXf0bZ.js.map} +1 -1
  78. package/dashboard/dist/assets/{McpQueryPage-CIijB5t2.js → McpQueryPage-BbYojoHu.js} +2 -2
  79. package/dashboard/dist/assets/{McpQueryPage-CIijB5t2.js.map → McpQueryPage-BbYojoHu.js.map} +1 -1
  80. package/dashboard/dist/assets/{McpRunDetailPage-CQmhfgju.js → McpRunDetailPage-CXGCVmPq.js} +2 -2
  81. package/dashboard/dist/assets/{McpRunDetailPage-CQmhfgju.js.map → McpRunDetailPage-CXGCVmPq.js.map} +1 -1
  82. package/dashboard/dist/assets/{McpRunsPage-CdDyeOdi.js → McpRunsPage-Df1GqxUg.js} +2 -2
  83. package/dashboard/dist/assets/{McpRunsPage-CdDyeOdi.js.map → McpRunsPage-Df1GqxUg.js.map} +1 -1
  84. package/dashboard/dist/assets/OperationsPage-DgZYi-BC.js +2 -0
  85. package/dashboard/dist/assets/OperationsPage-DgZYi-BC.js.map +1 -0
  86. package/dashboard/dist/assets/{OperatorDashboard-DFORmS46.js → OperatorDashboard-DIR7XDeD.js} +2 -2
  87. package/dashboard/dist/assets/{OperatorDashboard-DFORmS46.js.map → OperatorDashboard-DIR7XDeD.js.map} +1 -1
  88. package/dashboard/dist/assets/{ProcessDetailPage-DwypVFE2.js → ProcessDetailPage-BuSi654J.js} +2 -2
  89. package/dashboard/dist/assets/{ProcessDetailPage-DwypVFE2.js.map → ProcessDetailPage-BuSi654J.js.map} +1 -1
  90. package/dashboard/dist/assets/{ProcessesListPage-tNLvALwT.js → ProcessesListPage-Dhik7XpW.js} +2 -2
  91. package/dashboard/dist/assets/{ProcessesListPage-tNLvALwT.js.map → ProcessesListPage-Dhik7XpW.js.map} +1 -1
  92. package/dashboard/dist/assets/RoleDetailPage-BfzqQxMU.js +8 -0
  93. package/dashboard/dist/assets/RoleDetailPage-BfzqQxMU.js.map +1 -0
  94. package/dashboard/dist/assets/{RolesPage-txueySPI.js → RolesPage-BRicD5mx.js} +2 -2
  95. package/dashboard/dist/assets/{RolesPage-txueySPI.js.map → RolesPage-BRicD5mx.js.map} +1 -1
  96. package/dashboard/dist/assets/{RunAsSelector-Bvefon9B.js → RunAsSelector-DipyBf_T.js} +2 -2
  97. package/dashboard/dist/assets/{RunAsSelector-Bvefon9B.js.map → RunAsSelector-DipyBf_T.js.map} +1 -1
  98. package/dashboard/dist/assets/{StickyPagination-CeQCzVIA.js → StickyPagination-CD4W450h.js} +2 -2
  99. package/dashboard/dist/assets/{StickyPagination-CeQCzVIA.js.map → StickyPagination-CD4W450h.js.map} +1 -1
  100. package/dashboard/dist/assets/{StreamMessageDetail-6wEm6o6t.js → StreamMessageDetail-BbDdWDUY.js} +2 -2
  101. package/dashboard/dist/assets/{StreamMessageDetail-6wEm6o6t.js.map → StreamMessageDetail-BbDdWDUY.js.map} +1 -1
  102. package/dashboard/dist/assets/{SwimlaneTimeline-C97Rldf5.js → SwimlaneTimeline-Bktv2vi5.js} +2 -2
  103. package/dashboard/dist/assets/{SwimlaneTimeline-C97Rldf5.js.map → SwimlaneTimeline-Bktv2vi5.js.map} +1 -1
  104. package/dashboard/dist/assets/{TaskDetailPage-B09mLOCE.js → TaskDetailPage-pSU3xuG9.js} +2 -2
  105. package/dashboard/dist/assets/{TaskDetailPage-B09mLOCE.js.map → TaskDetailPage-pSU3xuG9.js.map} +1 -1
  106. package/dashboard/dist/assets/{TasksListPage-CQhiSGkN.js → TasksListPage-M6ok-Nfd.js} +2 -2
  107. package/dashboard/dist/assets/{TasksListPage-CQhiSGkN.js.map → TasksListPage-M6ok-Nfd.js.map} +1 -1
  108. package/dashboard/dist/assets/{TimeAgo-BkyeBcMF.js → TimeAgo-DVWhRNbi.js} +2 -2
  109. package/dashboard/dist/assets/{TimeAgo-BkyeBcMF.js.map → TimeAgo-DVWhRNbi.js.map} +1 -1
  110. package/dashboard/dist/assets/{TimestampCell-DVp_UdEB.js → TimestampCell-rG7pmIkW.js} +2 -2
  111. package/dashboard/dist/assets/{TimestampCell-DVp_UdEB.js.map → TimestampCell-rG7pmIkW.js.map} +1 -1
  112. package/dashboard/dist/assets/{ToolTestPanel-CZOuRP_i.js → ToolTestPanel-CLcMA8OE.js} +2 -2
  113. package/dashboard/dist/assets/{ToolTestPanel-CZOuRP_i.js.map → ToolTestPanel-CLcMA8OE.js.map} +1 -1
  114. package/dashboard/dist/assets/{TopicDetailPage-0mvQde8R.js → TopicDetailPage-C9gvoWYu.js} +2 -2
  115. package/dashboard/dist/assets/{TopicDetailPage-0mvQde8R.js.map → TopicDetailPage-C9gvoWYu.js.map} +1 -1
  116. package/dashboard/dist/assets/{TopicsPage-DkvsHLLe.js → TopicsPage-CIGi3TdT.js} +2 -2
  117. package/dashboard/dist/assets/{TopicsPage-DkvsHLLe.js.map → TopicsPage-CIGi3TdT.js.map} +1 -1
  118. package/dashboard/dist/assets/{UserName-EaD_Tz9y.js → UserName-CifbOahk.js} +2 -2
  119. package/dashboard/dist/assets/{UserName-EaD_Tz9y.js.map → UserName-CifbOahk.js.map} +1 -1
  120. package/dashboard/dist/assets/{WorkflowExecutionPage-CjMSQ9Bb.js → WorkflowExecutionPage-BR0oVx_p.js} +2 -2
  121. package/dashboard/dist/assets/{WorkflowExecutionPage-CjMSQ9Bb.js.map → WorkflowExecutionPage-BR0oVx_p.js.map} +1 -1
  122. package/dashboard/dist/assets/{WorkflowsDashboard-BgUz_jO6.js → WorkflowsDashboard-CSYrYQsO.js} +2 -2
  123. package/dashboard/dist/assets/{WorkflowsDashboard-BgUz_jO6.js.map → WorkflowsDashboard-CSYrYQsO.js.map} +1 -1
  124. package/dashboard/dist/assets/{WorkflowsOverview-BzUjUfAz.js → WorkflowsOverview-CaXWYZuw.js} +2 -2
  125. package/dashboard/dist/assets/{WorkflowsOverview-BzUjUfAz.js.map → WorkflowsOverview-CaXWYZuw.js.map} +1 -1
  126. package/dashboard/dist/assets/{YamlWorkflowDetailPage-C48Ui513.js → YamlWorkflowDetailPage-CRBXahFJ.js} +2 -2
  127. package/dashboard/dist/assets/{YamlWorkflowDetailPage-C48Ui513.js.map → YamlWorkflowDetailPage-CRBXahFJ.js.map} +1 -1
  128. package/dashboard/dist/assets/{YamlWorkflowsPage-CQ-dk84N.js → YamlWorkflowsPage-D5zc8Lta.js} +2 -2
  129. package/dashboard/dist/assets/{YamlWorkflowsPage-CQ-dk84N.js.map → YamlWorkflowsPage-D5zc8Lta.js.map} +1 -1
  130. package/dashboard/dist/assets/{agents-O1GlQE9p.js → agents-D7vYXeLj.js} +2 -2
  131. package/dashboard/dist/assets/{agents-O1GlQE9p.js.map → agents-D7vYXeLj.js.map} +1 -1
  132. package/dashboard/dist/assets/{bots-DB5Z7MEk.js → bots-CKaYN2fL.js} +2 -2
  133. package/dashboard/dist/assets/{bots-DB5Z7MEk.js.map → bots-CKaYN2fL.js.map} +1 -1
  134. package/dashboard/dist/assets/{capabilities-Du9EfNdT.js → capabilities-BknM6oFm.js} +2 -2
  135. package/dashboard/dist/assets/{capabilities-Du9EfNdT.js.map → capabilities-BknM6oFm.js.map} +1 -1
  136. package/dashboard/dist/assets/{controlplane-ku4V2nVk.js → controlplane-BodNGCr-.js} +2 -2
  137. package/dashboard/dist/assets/{controlplane-ku4V2nVk.js.map → controlplane-BodNGCr-.js.map} +1 -1
  138. package/dashboard/dist/assets/{escalation-oVVz7Lw2.js → escalation-CH_XK2XM.js} +2 -2
  139. package/dashboard/dist/assets/{escalation-oVVz7Lw2.js.map → escalation-CH_XK2XM.js.map} +1 -1
  140. package/dashboard/dist/assets/{escalation-columns-C-xaR_Qg.js → escalation-columns-CcbLKRI4.js} +2 -2
  141. package/dashboard/dist/assets/{escalation-columns-C-xaR_Qg.js.map → escalation-columns-CcbLKRI4.js.map} +1 -1
  142. package/dashboard/dist/assets/index--xNp5rx6.css +1 -0
  143. package/dashboard/dist/assets/{index-aHhMmZ0W.js → index-B-LQ8fsJ.js} +2 -2
  144. package/dashboard/dist/assets/{index-aHhMmZ0W.js.map → index-B-LQ8fsJ.js.map} +1 -1
  145. package/dashboard/dist/assets/{index-CyXilW90.js → index-BH67e1Ah.js} +2 -2
  146. package/dashboard/dist/assets/{index-CyXilW90.js.map → index-BH67e1Ah.js.map} +1 -1
  147. package/dashboard/dist/assets/{index-MbEPoyTe.js → index-B_aFcGv9.js} +4 -4
  148. package/dashboard/dist/assets/{index-MbEPoyTe.js.map → index-B_aFcGv9.js.map} +1 -1
  149. package/dashboard/dist/assets/{index-DsKK1fCc.js → index-Bwofyfi8.js} +2 -2
  150. package/dashboard/dist/assets/{index-DsKK1fCc.js.map → index-Bwofyfi8.js.map} +1 -1
  151. package/dashboard/dist/assets/{index-61yKjTkk.js → index-C3QKGY5C.js} +2 -2
  152. package/dashboard/dist/assets/{index-61yKjTkk.js.map → index-C3QKGY5C.js.map} +1 -1
  153. package/dashboard/dist/assets/{index-BwXtXaw8.js → index-CJpywoA8.js} +2 -2
  154. package/dashboard/dist/assets/{index-BwXtXaw8.js.map → index-CJpywoA8.js.map} +1 -1
  155. package/dashboard/dist/assets/index-CV8soXIM.js +5 -0
  156. package/dashboard/dist/assets/index-CV8soXIM.js.map +1 -0
  157. package/dashboard/dist/assets/{index-CxlsLEr1.js → index-CdN-Z8-r.js} +2 -2
  158. package/dashboard/dist/assets/{index-CxlsLEr1.js.map → index-CdN-Z8-r.js.map} +1 -1
  159. package/dashboard/dist/assets/{index-DcZDyLHC.js → index-D7NHjvA4.js} +2 -2
  160. package/dashboard/dist/assets/{index-DcZDyLHC.js.map → index-D7NHjvA4.js.map} +1 -1
  161. package/dashboard/dist/assets/{index-DkZnXWTA.js → index-DHhz71yv.js} +2 -2
  162. package/dashboard/dist/assets/{index-DkZnXWTA.js.map → index-DHhz71yv.js.map} +1 -1
  163. package/dashboard/dist/assets/{index-DgAmkmtv.js → index-Gt2Rebs9.js} +2 -2
  164. package/dashboard/dist/assets/{index-DgAmkmtv.js.map → index-Gt2Rebs9.js.map} +1 -1
  165. package/dashboard/dist/assets/index-IIq5Tkqs.js +6 -0
  166. package/dashboard/dist/assets/index-IIq5Tkqs.js.map +1 -0
  167. package/dashboard/dist/assets/{index-Bcgsf2yD.js → index-_gh2K9DU.js} +2 -2
  168. package/dashboard/dist/assets/{index-Bcgsf2yD.js.map → index-_gh2K9DU.js.map} +1 -1
  169. package/dashboard/dist/assets/{knowledge-CTjJVvIG.js → knowledge-CE6gjN3G.js} +2 -2
  170. package/dashboard/dist/assets/{knowledge-CTjJVvIG.js.map → knowledge-CE6gjN3G.js.map} +1 -1
  171. package/dashboard/dist/assets/{mcp-CsHkygRS.js → mcp-B4F-T-7R.js} +2 -2
  172. package/dashboard/dist/assets/{mcp-CsHkygRS.js.map → mcp-B4F-T-7R.js.map} +1 -1
  173. package/dashboard/dist/assets/{mcp-query-BCt4tpjO.js → mcp-query-CYOarL1K.js} +2 -2
  174. package/dashboard/dist/assets/{mcp-query-BCt4tpjO.js.map → mcp-query-CYOarL1K.js.map} +1 -1
  175. package/dashboard/dist/assets/{pipelines-BpGmuS5V.js → pipelines-B4gB9qMx.js} +2 -2
  176. package/dashboard/dist/assets/{pipelines-BpGmuS5V.js.map → pipelines-B4gB9qMx.js.map} +1 -1
  177. package/dashboard/dist/assets/{roles-lHLgLwOY.js → roles-LZf98ePg.js} +2 -2
  178. package/dashboard/dist/assets/{roles-lHLgLwOY.js.map → roles-LZf98ePg.js.map} +1 -1
  179. package/dashboard/dist/assets/{tasks-BHfimh-E.js → tasks-GG8c_U9w.js} +2 -2
  180. package/dashboard/dist/assets/{tasks-BHfimh-E.js.map → tasks-GG8c_U9w.js.map} +1 -1
  181. package/dashboard/dist/assets/{topics-BW2cS79q.js → topics-C7-6oOgA.js} +2 -2
  182. package/dashboard/dist/assets/{topics-BW2cS79q.js.map → topics-C7-6oOgA.js.map} +1 -1
  183. package/dashboard/dist/assets/{useEventHooks-CeOIM1Ix.js → useEventHooks-82IiMmOc.js} +2 -2
  184. package/dashboard/dist/assets/{useEventHooks-CeOIM1Ix.js.map → useEventHooks-82IiMmOc.js.map} +1 -1
  185. package/dashboard/dist/assets/{useNamespace-CEVLPGGY.js → useNamespace-DQEqD2LA.js} +2 -2
  186. package/dashboard/dist/assets/{useNamespace-CEVLPGGY.js.map → useNamespace-DQEqD2LA.js.map} +1 -1
  187. package/dashboard/dist/assets/{useYamlActivityEvents-DdRNcy7s.js → useYamlActivityEvents-Bm0-ewLx.js} +2 -2
  188. package/dashboard/dist/assets/{useYamlActivityEvents-DdRNcy7s.js.map → useYamlActivityEvents-Bm0-ewLx.js.map} +1 -1
  189. package/dashboard/dist/assets/{users-CAih5Fty.js → users-DHx2ium7.js} +2 -2
  190. package/dashboard/dist/assets/{users-CAih5Fty.js.map → users-DHx2ium7.js.map} +1 -1
  191. package/dashboard/dist/assets/{workflows-C_gCwB9q.js → workflows-qIbkeQ_5.js} +2 -2
  192. package/dashboard/dist/assets/{workflows-C_gCwB9q.js.map → workflows-qIbkeQ_5.js.map} +1 -1
  193. package/dashboard/dist/assets/{yaml-workflows-CPabf8Sf.js → yaml-workflows-FibyeHpo.js} +2 -2
  194. package/dashboard/dist/assets/{yaml-workflows-CPabf8Sf.js.map → yaml-workflows-FibyeHpo.js.map} +1 -1
  195. package/dashboard/dist/index.html +2 -2
  196. package/docs/api/http/escalations.md +28 -4
  197. package/docs/api/http/roles.md +1 -1
  198. package/docs/api/http/workflows.md +1 -1
  199. package/docs/api/sdk/escalations.md +40 -5
  200. package/docs/api/sdk/workflows.md +1 -1
  201. package/docs/dashboard.md +3 -3
  202. package/docs/data.md +2 -2
  203. package/docs/hitl-guide.md +114 -6
  204. package/docs/maintenance.md +6 -3
  205. package/docs/oauth-and-delegation.md +1 -1
  206. package/package.json +2 -2
  207. package/dashboard/dist/assets/EscalationSchemaPage-hzFtuyha.js +0 -9
  208. package/dashboard/dist/assets/EscalationSchemaPage-hzFtuyha.js.map +0 -1
  209. package/dashboard/dist/assets/OperationsPage-Cz_0K8tj.js +0 -2
  210. package/dashboard/dist/assets/OperationsPage-Cz_0K8tj.js.map +0 -1
  211. package/dashboard/dist/assets/RoleDetailPage-BPsrUqIa.js +0 -11
  212. package/dashboard/dist/assets/RoleDetailPage-BPsrUqIa.js.map +0 -1
  213. package/dashboard/dist/assets/index-BdqKh0UK.css +0 -1
  214. package/dashboard/dist/assets/index-CAzFU1rn.js +0 -9
  215. package/dashboard/dist/assets/index-CAzFU1rn.js.map +0 -1
  216. package/dashboard/dist/assets/index-D0bDVU2a.js +0 -6
  217. package/dashboard/dist/assets/index-D0bDVU2a.js.map +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-tNLvALwT.js","./vendor-query-B2UbickB.js","./tasks-BHfimh-E.js","./workflows-C_gCwB9q.js","./useEventHooks-CeOIM1Ix.js","./useFilterParams-x-Dg0Vgz.js","./vendor-react-CXumBFUA.js","./useDebouncedValue-BA5S7V54.js","./api-path-u2Jf9QXS.js","./DataTable-ZWgVQg7F.js","./EmptyState-BcsfPq9T.js","./TimestampCell-DVp_UdEB.js","./StickyPagination-CeQCzVIA.js","./FilterBar-B4Mk2PvT.js","./PageHeader-DJo7yMUR.js","./vendor-icons-DOIDKgo6.js","./ListToolbar-C_64Y22Z.js","./WorkflowPill-BtNBSplz.js","./ProcessDetailPage-DwypVFE2.js","./PageHeaderWithStats-W3akV6nB.js","./StatusBadge-DZ9137bI.js","./RolePill-DHWixsQR.js","./UserName-EaD_Tz9y.js","./users-CAih5Fty.js","./McpOverview-D-4eSOTc.js","./mcp-CsHkygRS.js","./pipelines-BpGmuS5V.js","./yaml-workflows-CPabf8Sf.js","./controlplane-ku4V2nVk.js","./StatCard-DrdlUeQz.js","./McpRunsPage-CdDyeOdi.js","./useNamespace-CEVLPGGY.js","./ElapsedCell-CO8XMSJX.js","./RowActions-BA9L9djf.js","./McpRunDetailPage-CQmhfgju.js","./CopyableId-blg-gZvT.js","./CollapsibleSection-CBKICsCu.js","./useCollapsedSections-BU5HULGs.js","./SwimlaneTimeline-C97Rldf5.js","./StreamMessageDetail-6wEm6o6t.js","./EventTable-D9RjAT_a.js","./McpQueryPage-CIijB5t2.js","./mcp-query-BCt4tpjO.js","./McpQueryDetailPage-BYwDb8LC.js","./TagInput-CGGC3DTR.js","./useYamlActivityEvents-DdRNcy7s.js","./helpers-DzO-OGPe.js","./RunAsSelector-Bvefon9B.js","./BotPicker-CCIo5ic0.js","./bots-DB5Z7MEk.js","./ToolPill-BW0iRwZu.js","./TimeAgo-BkyeBcMF.js","./EscalationsOverview-qlo0mxxa.js","./AvailableEscalationsPage-BxakNqha.js","./CustomDurationPicker-BdurQj-B.js","./Modal-CSrxpXeM.js","./constants-BHkpVaqx.js","./roles-lHLgLwOY.js","./escalation-columns-C-xaR_Qg.js","./PriorityBadge-B4ykBH7f.js","./escalation-oVVz7Lw2.js","./OperatorDashboard-DFORmS46.js","./index-D0bDVU2a.js","./WorkflowsOverview-BzUjUfAz.js","./index-CyXilW90.js","./NamespacePill-SErKwgkb.js","./WorkflowsDashboard-BgUz_jO6.js","./YamlWorkflowsPage-CQ-dk84N.js","./GraphInvokePage-CU3r2tzN.js","./YamlWorkflowDetailPage-C48Ui513.js","./TasksListPage-CQhiSGkN.js","./TaskDetailPage-B09mLOCE.js","./WorkflowExecutionPage-CjMSQ9Bb.js","./AdminDashboard-Dhr7sUq6.js","./index-DgAmkmtv.js","./TaskQueuePill-D6omQJNY.js","./index-CAzFU1rn.js","./ConfirmDeleteModal-D9_1b4MW.js","./index-CxlsLEr1.js","./ToolTestPanel-CZOuRP_i.js","./index-61yKjTkk.js","./index-DsKK1fCc.js","./RolesPage-txueySPI.js","./RoleDetailPage-BPsrUqIa.js","./EscalationSchemaPage-hzFtuyha.js","./index-DkZnXWTA.js","./OperationsPage-Cz_0K8tj.js","./index-DcZDyLHC.js","./index-BwXtXaw8.js","./CredentialsPage-BN_d7ybc.js","./index-aHhMmZ0W.js","./DropZone-SgiK1WOl.js","./index-Bcgsf2yD.js","./knowledge-CTjJVvIG.js","./HomePage-B7pb4-Gx.js","./AgentsPage-Pj47ZJ2U.js","./agents-O1GlQE9p.js","./AgentDetailPage-C9Tmmhhc.js","./CronLabel-4V_EXMUg.js","./AgentConfigPage-CUPm8FjH.js","./capabilities-Du9EfNdT.js","./topics-BW2cS79q.js","./CapabilitiesPage-XFVq4iPX.js","./TopicsPage-DkvsHLLe.js","./TopicDetailPage-0mvQde8R.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-Dhik7XpW.js","./vendor-query-B2UbickB.js","./tasks-GG8c_U9w.js","./workflows-qIbkeQ_5.js","./useEventHooks-82IiMmOc.js","./useFilterParams-x-Dg0Vgz.js","./vendor-react-CXumBFUA.js","./useDebouncedValue-BA5S7V54.js","./api-path-u2Jf9QXS.js","./DataTable-ZWgVQg7F.js","./EmptyState-BcsfPq9T.js","./TimestampCell-rG7pmIkW.js","./StickyPagination-CD4W450h.js","./FilterBar-B4Mk2PvT.js","./PageHeader-DJo7yMUR.js","./vendor-icons-DOIDKgo6.js","./ListToolbar-Ok2O0wmC.js","./WorkflowPill-BtNBSplz.js","./ProcessDetailPage-BuSi654J.js","./PageHeaderWithStats-W3akV6nB.js","./StatusBadge-DZ9137bI.js","./RolePill-DHWixsQR.js","./UserName-CifbOahk.js","./users-DHx2ium7.js","./McpOverview-CTCYZXIp.js","./mcp-B4F-T-7R.js","./pipelines-B4gB9qMx.js","./yaml-workflows-FibyeHpo.js","./controlplane-BodNGCr-.js","./StatCard-DrdlUeQz.js","./McpRunsPage-Df1GqxUg.js","./useNamespace-DQEqD2LA.js","./ElapsedCell-N22STQcg.js","./RowActions-BA9L9djf.js","./McpRunDetailPage-CXGCVmPq.js","./CopyableId-blg-gZvT.js","./CollapsibleSection-lo8Qx4zb.js","./useCollapsedSections-BU5HULGs.js","./SwimlaneTimeline-Bktv2vi5.js","./StreamMessageDetail-BbDdWDUY.js","./EventTable-B3Gj7Ayg.js","./McpQueryPage-BbYojoHu.js","./mcp-query-CYOarL1K.js","./McpQueryDetailPage-BOaXf0bZ.js","./TagInput-CGGC3DTR.js","./useYamlActivityEvents-Bm0-ewLx.js","./helpers-DzO-OGPe.js","./RunAsSelector-DipyBf_T.js","./BotPicker-BQVz6bye.js","./bots-CKaYN2fL.js","./ToolPill-BW0iRwZu.js","./TimeAgo-DVWhRNbi.js","./EscalationsOverview-CE2p70Ct.js","./AvailableEscalationsPage-BcbhA6NE.js","./CustomDurationPicker-CGiwKSVJ.js","./Modal-CSrxpXeM.js","./constants-BHkpVaqx.js","./roles-LZf98ePg.js","./escalation-columns-CcbLKRI4.js","./PriorityBadge-B4ykBH7f.js","./escalation-CH_XK2XM.js","./OperatorDashboard-DIR7XDeD.js","./index-IIq5Tkqs.js","./WorkflowsOverview-CaXWYZuw.js","./index-BH67e1Ah.js","./NamespacePill-SErKwgkb.js","./WorkflowsDashboard-CSYrYQsO.js","./YamlWorkflowsPage-D5zc8Lta.js","./GraphInvokePage-DywWVSdj.js","./YamlWorkflowDetailPage-CRBXahFJ.js","./TasksListPage-M6ok-Nfd.js","./TaskDetailPage-pSU3xuG9.js","./WorkflowExecutionPage-BR0oVx_p.js","./AdminDashboard-RrSvb8d-.js","./index-Gt2Rebs9.js","./TaskQueuePill-D6omQJNY.js","./index-CV8soXIM.js","./ConfirmDeleteModal-D9_1b4MW.js","./index-CdN-Z8-r.js","./ToolTestPanel-CLcMA8OE.js","./index-C3QKGY5C.js","./index-Bwofyfi8.js","./RolesPage-BRicD5mx.js","./RoleDetailPage-BfzqQxMU.js","./EscalationSchemaPage-Zsmewko2.js","./index-DHhz71yv.js","./OperationsPage-DgZYi-BC.js","./index-D7NHjvA4.js","./index-CJpywoA8.js","./CredentialsPage-DJ9DyXsO.js","./index-B-LQ8fsJ.js","./DropZone-SgiK1WOl.js","./index-_gh2K9DU.js","./knowledge-CE6gjN3G.js","./HomePage-CxtBiULd.js","./AgentsPage-CxNNtSsf.js","./agents-D7vYXeLj.js","./AgentDetailPage-C_-sIBcr.js","./CronLabel-o0dbisw1.js","./AgentConfigPage-5RMdI0ku.js","./capabilities-BknM6oFm.js","./topics-C7-6oOgA.js","./CapabilitiesPage-DlZ8SgO3.js","./TopicsPage-CIGi3TdT.js","./TopicDetailPage-C9gvoWYu.js"])))=>i.map(i=>d[i]);
2
2
  var Nx=Object.defineProperty;var Cx=(r,n,s)=>n in r?Nx(r,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[n]=s;var v=(r,n,s)=>Cx(r,typeof n!="symbol"?n+"":n,s);import{r as kx,a as O,j as d,u as _n,b as rn,c as wn,Q as Mx,d as Rx}from"./vendor-query-B2UbickB.js";import{r as Dx,L as yr,u as ei,N as Co,a as dg,b as Bn,O as xr,c as mg,d as zx,R as qx}from"./vendor-react-CXumBFUA.js";import{I as Ef,R as pg,B as gg,U as Ux,L as Af,a as s0,b as Bx,Z as Lx,S as i0,P as r0,C as Hx,W as Kf,c as Px,d as $x,F as Yx,e as Gx,f as Vx,T as Fx,N as Jx,g as Ix,D as Qx,M as yg,h as bg,i as Xx,j as Kx,k as Zx,E as Wx,X as $o,l as ev,m as tv,n as nv,o as a0,G as sv,p as iv,q as rv,r as av,s as lv}from"./vendor-icons-DOIDKgo6.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const f of o)if(f.type==="childList")for(const h of f.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&a(h)}).observe(document,{childList:!0,subtree:!0});function s(o){const f={};return o.integrity&&(f.integrity=o.integrity),o.referrerPolicy&&(f.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?f.credentials="include":o.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function a(o){if(o.ep)return;o.ep=!0;const f=s(o);fetch(o.href,f)}})();var lf={exports:{}},Ea={},of={exports:{}},cf={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
@@ -50,7 +50,7 @@ ${g}`),w(M);return}m(null,R),a.strategy===kn.Count&&(y--,y===0&&w()),a.strategy=
50
50
 
51
51
  ${m.stack}`),g.unsubscribe(),h.reject(y)):(y=Eg(E),y?(m&&(y.stack+=`
52
52
 
53
- ${m.stack}`),h.reject(y)):h.resolve(E))}});return g.requestSubject=n,this.protocol.publish(n,s,{reply:f,headers:a.headers}),h}else{const f=new Og(this.protocol.muxSubscriptions,n,a,o);this.protocol.request(f);try{this.publish(n,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${f.token}`,headers:a.headers})}catch(m){f.cancel(m)}const h=Promise.race([f.timer,f.deferred]);return h.catch(()=>{f.cancel()}),h}}flush(){return this.isClosed()?Promise.reject(ue.errorForCode(ie.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(ue.errorForCode(ie.ConnectionClosed)):this.isDraining()?Promise.reject(ue.errorForCode(ie.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const n=this.protocol.getServer();return n?n.listen:""}status(){const n=new _t;return n.iterClosed.then(()=>{const s=this.listeners.indexOf(n);this.listeners.splice(s,1)}),this.listeners.push(n),n}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request("$SYS.REQ.USER.INFO")).json((s,a)=>s==="time"?new Date(Date.parse(a)):a)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(n={}){const s=new Z1(this,n);if(n.checkAPI!==!1)try{await s.getAccountInfo()}catch(a){const o=a;throw o.code===ie.NoResponders&&(o.code=ie.JetStreamNotEnabled),o}return s}jetstream(n={}){return new ah(this,n)}getServerVersion(){const n=this.info;return n?ji(n.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw ue.errorForCode(ie.Disconnect);const n=Date.now();return await this.flush(),Date.now()-n}get features(){return this.protocol.features}get services(){return this._services||(this._services=new n_(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(ue.errorForCode(ie.ConnectionClosed)):this.isDraining()?Promise.reject(ue.errorForCode(ie.ConnectionDraining)):this.protocol.reconnect()}}class n_{constructor(n){v(this,"nc");this.nc=n}add(n){try{return new Va(this.nc,n).start()}catch(s){return Promise.reject(s)}}client(n,s){return new z1(this.nc,n,s)}}class s_{constructor(n,s,a){v(this,"bucket");v(this,"sm");v(this,"prefixLen");this.bucket=n,this.prefixLen=s,this.sm=a}get key(){return this.sm.subject.substring(this.prefixLen)}get value(){return this.sm.data}get delta(){return 0}get created(){return this.sm.time}get revision(){return this.sm.seq}get operation(){return this.sm.header.get(Bo)||"PUT"}get length(){const n=this.sm.header.get(Dt.MessageSizeHdr)||"";return n!==""?parseInt(n,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class i_{constructor(n,s,a){v(this,"bucket");v(this,"key");v(this,"sm");this.bucket=n,this.key=s,this.sm=a}get value(){return this.sm.data}get created(){return new Date(th(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var n;return((n=this.sm.headers)==null?void 0:n.get(Bo))||"PUT"}get delta(){return this.sm.info.pending}get length(){var s;const n=((s=this.sm.headers)==null?void 0:s.get(Dt.MessageSizeHdr))||"";return n!==""?parseInt(n,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Ug extends Jv{constructor(s,a,o){super(s.nc,a,o);v(this,"js");v(this,"monitor");this.js=s,this.monitor=null,this.sub.closed.then(()=>{this.monitor&&this.monitor.cancel()})}set info(s){this.sub.info=s}get info(){return this.sub.info}_resetOrderedConsumer(s){if(this.info===null||this.sub.isClosed())return;const a=fs(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,a);const f=this.info;f.config.name=Zs.next(),f.ordered_consumer_sequence.delivery_seq=0,f.flow_control.heartbeat_count=0,f.flow_control.fc_count=0,f.flow_control.consumer_restarts++,f.deliver=a,f.config.deliver_subject=a,f.config.deliver_policy=ft.StartSequence,f.config.opt_start_seq=s;const h={};h.stream_name=this.info.stream,h.config=f.config;const m=`${f.api.prefix}.CONSUMER.CREATE.${f.stream}`;this.js._request(m,h,{retries:-1}).then(g=>{const y=g,E=this.sub.info;E.last=y,this.info.config=y.config,this.info.name=y.name}).catch(g=>{const y=new ue(`unable to recreate ordered consumer ${f.stream} at seq ${s}`,ie.RequestError,g);this.sub.callback(y,{})})}_maybeSetupHbMonitoring(){var a,o;const s=((o=(a=this.info)==null?void 0:a.config)==null?void 0:o.idle_heartbeat)||0;s&&this._setupHbMonitoring(th(s))}_setupHbMonitoring(s,a=0){const o={cancelAfter:0,maxOut:2};a&&(o.cancelAfter=a);const f=this.sub,h=m=>{var E,w,T,q;const g=Ov(409,`${xn.IdleHeartbeatMissed}: ${m}`,this.sub.subject);if(!((E=this.info)==null?void 0:E.ordered))this.sub.callback(null,g);else{if(!this.js.nc.protocol.connected)return!1;const M=((T=(w=this.info)==null?void 0:w.ordered_consumer_sequence)==null?void 0:T.stream_seq)||0;return this._resetOrderedConsumer(M+1),(q=this.monitor)==null||q.restart(),!1}return!f.noIterator};this.monitor=new sh(s,h,o)}_checkHbOrderConsumer(s){const a=s.headers.get(Dt.ConsumerStalledHdr);a!==""&&this.js.nc.publish(a);const o=parseInt(s.headers.get(Dt.LastConsumerSeqHdr),10),f=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,o!==f.delivery_seq&&this._resetOrderedConsumer(f.stream_seq+1),!1}_checkOrderedConsumer(s){const a=this.info.ordered_consumer_sequence,o=s.info.streamSequence,f=s.info.deliverySequence;return f!=a.delivery_seq+1?(this._resetOrderedConsumer(a.stream_seq+1),!1):(a.delivery_seq=f,a.stream_seq=o,!0)}async destroy(){this.isClosed()||await this.drain();const s=this.sub.info,a=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.DELETE.${s.stream}.${a}`;await s.api._request(o)}async consumerInfo(){const s=this.sub.info,a=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.INFO.${s.stream}.${a}`,f=await s.api._request(o);return s.last=f,f}}class r_ extends Ug{constructor(n,s,a){super(n,s,a)}pull(n={batch:1}){const{stream:s,config:a,name:o}=this.sub.info,f=a.durable_name??o,h={};if(h.batch=n.batch||1,h.no_wait=n.no_wait||!1,(n.max_bytes??0)>0){const y=this.js.nc.features.get(Ue.JS_PULL_MAX_BYTES);if(!y.ok)throw new Error(`max_bytes is only supported on servers ${y.min} or better`);h.max_bytes=n.max_bytes}let m=0;n.expires&&n.expires>0&&(m=n.expires,h.expires=nt(m));let g=0;if(n.idle_heartbeat&&n.idle_heartbeat>0&&(g=n.idle_heartbeat,h.idle_heartbeat=nt(g)),g&&m===0)throw new Error("idle_heartbeat requires expires");if(g>m)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),m&&g&&(this.monitor?this.monitor._change(g,m):this._setupHbMonitoring(g,m));const y=this.info.api,E=`${y.prefix}.CONSUMER.MSG.NEXT.${s}.${f}`,w=this.sub.subject;y.nc.publish(E,y.jc.encode(h),{reply:w})}}}function a_(r,n){return r?o_(n):l_(n)}function l_(r){return(n,s)=>n?[n,null]:(n=wr(s),n?[n,null]:[null,$a(s,r)])}function o_(r){return(n,s)=>{if(n)return[n,null];const a=wr(s);return a!==null?[Bg(a),null]:[null,$a(s,r)]}}function Bg(r){if(r!==null)switch(r.code){case ie.JetStream404NoMessages:case ie.JetStream408RequestTimeout:return null;case ie.JetStream409:return Tv(r)?r:null;default:return r}return null}function c_(r){r&&r.ack()}function u_(r){const n=r.split(".");if(n.length===9&&n.splice(2,0,"_",""),n.length<11||n[0]!=="$JS"||n[1]!=="ACK")throw new Error("not js message");const s={};return s.domain=n[2]==="_"?"":n[2],s.account_hash=n[3],s.stream=n[4],s.consumer=n[5],s.deliveryCount=parseInt(n[6],10),s.redeliveryCount=s.deliveryCount,s.redelivered=s.deliveryCount>1,s.streamSequence=parseInt(n[7],10),s.deliverySequence=parseInt(n[8],10),s.timestampNanos=parseInt(n[9],10),s.pending=parseInt(n[10],10),s}class f_{constructor(n,s){v(this,"msg");v(this,"di");v(this,"didAck");v(this,"timeout");this.msg=n,this.didAck=!1,this.timeout=s}get subject(){return this.msg.subject}get sid(){return this.msg.sid}get data(){return this.msg.data}get headers(){return this.msg.headers}get info(){return this.di||(this.di=u_(this.reply)),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(n){this.didAck||(this.didAck=!this.isWIP(n),this.msg.respond(n))}isWIP(n){return n.length===4&&n[0]===ja[0]&&n[1]===ja[1]&&n[2]===ja[2]&&n[3]===ja[3]}async ackAck(n){var a;n=n||{},n.timeout=n.timeout||this.timeout;const s=st();if(this.didAck)s.resolve(!1);else if(this.didAck=!0,this.msg.reply){const f=this.msg.publisher,h=!((a=f.options)!=null&&a.noAsyncTraces),m=new Og(f.muxSubscriptions,this.msg.reply,{timeout:n.timeout},h);f.request(m);try{f.publish(this.msg.reply,z0,{reply:`${f.muxSubscriptions.baseInbox}${m.token}`})}catch(g){m.cancel(g)}try{await Promise.race([m.timer,m.deferred]),s.resolve(!0)}catch(g){m.cancel(g),s.reject(g)}}else s.resolve(!1);return s}ack(){this.doAck(z0)}nak(n){let s=V1;n&&(s=Tf().encode(`-NAK ${JSON.stringify({delay:nt(n)})}`)),this.doAck(s)}working(){this.doAck(ja)}next(n,s={batch:1}){const a={};a.batch=s.batch||1,a.no_wait=s.no_wait||!1,s.expires&&s.expires>0&&(a.expires=nt(s.expires));const o=Mn().encode(a),f=Or.concat(F1,I1,o),h=n?{reply:n}:void 0;this.msg.respond(f,h)}term(n=""){let s=J1;(n==null?void 0:n.length)>0&&(s=Tf().encode(`+TERM ${n}`)),this.doAck(s)}json(){return this.msg.json()}string(){return this.msg.string()}}const h_="1.30.3",d_="nats.ws";class m_{constructor(){v(this,"version");v(this,"lang");v(this,"closeError");v(this,"connected");v(this,"done");v(this,"socket");v(this,"options");v(this,"socketClosed");v(this,"encrypted");v(this,"peeked");v(this,"yields");v(this,"signal");v(this,"closedNotification");this.version=h_,this.lang=d_,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=st(),this.closedNotification=st()}async connect(n,s){const a=st();if(s.tls)return a.reject(new ue("tls",ie.InvalidOption)),a;this.options=s;const o=n.src;if(s.wsFactory){const{socket:f,encrypted:h}=await s.wsFactory(n.src,s);this.socket=f,this.encrypted=h}else this.encrypted=o.indexOf("wss://")===0,this.socket=new WebSocket(o);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.isDiscarded()},this.socket.onmessage=f=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(f.data)),this.peeked){this.signal.resolve();return}const h=Or.concat(...this.yields),m=Wv(h);if(m!==""){const g=O1.exec(m);if(!g){s.debug&&console.error("!!!",go(h)),a.reject(new Error("unexpected response from server"));return}try{const y=JSON.parse(g[1]);A1(y,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),a.resolve()}catch(y){a.reject(y);return}}},this.socket.onclose=f=>{if(this.isDiscarded())return;this.socketClosed=!0;let h;this.done||(f.wasClean||(h=new Error(f.reason)),this._closed(h))},this.socket.onerror=f=>{if(this.isDiscarded())return;const h=f,m=new ue(h.message,ie.Unknown,new Error(h.error));a.reject(m)},a}disconnect(){this._closed(void 0,!0)}async _closed(n,s=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=n,!n)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await Tr(100);this.done=!0;try{this.socket.close(n?1002:1e3,n?n.message:void 0)}catch{}s&&this.closedNotification.resolve(n)}}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.isDiscarded())return;this.yields.length===0&&await this.signal;const n=this.yields;this.yields=[];for(let s=0;s<n.length;s++)this.options.debug&&console.info(`> ${go(n[s])}`),yield n[s];if(this.done)break;this.yields.length===0&&(n.length=0,this.yields=n,this.signal=st())}}isEncrypted(){return this.connected&&this.encrypted}send(n){if(!this.isDiscarded())try{this.socket.send(n.buffer),this.options.debug&&console.info(`< ${go(n)}`);return}catch(s){this.options.debug&&console.error(`!!! ${go(n)}: ${s}`)}}close(n){return this._closed(n,!1)}closed(){return this.closedNotification}isDiscarded(){return this.done?(this.discard(),!0):!1}discard(){var n;this.done=!0;try{(n=this.socket)==null||n.close()}catch{}}}function p_(r,n){/^(.*:\/\/)(.*)/.test(r)||(typeof n=="boolean"?r=`${n===!0?"https":"http"}://${r}`:r=`https://${r}`);let a=new URL(r);const o=a.protocol.toLowerCase();o==="ws:"&&(n=!1),o==="wss:"&&(n=!0),o!=="https:"&&o!=="http"&&(r=r.replace(/^(.*:\/\/)(.*)/gm,"$2"),a=new URL(`http://${r}`));let f,h;const m=a.hostname,g=a.pathname,y=a.search||"";switch(o){case"http:":case"ws:":case"nats:":h=a.port||"80",f="ws:";break;case"https:":case"wss:":case"tls:":h=a.port||"443",f="wss:";break;default:h=a.port||n===!0?"443":"80",f=n===!0?"wss:":"ws:";break}return`${f}//${m}:${h}${g}${y}`}function g_(r={}){return Iv({defaultPort:443,urlParseFn:p_,factory:()=>new m_}),lh.connect(r)}const y_=null,b_=null,x_="lt.events";function Lg(r,n){const s=r.split("."),a=n.split(".");for(let o=0;o<a.length;o++){const f=a[o];if(f===">")return!0;if(o>=s.length||f!=="*"&&f!==s[o])return!1}return s.length===a.length}const Fa=O.createContext({connected:!1,subscribe:()=>()=>{}});function v_(){const{connected:r}=O.useContext(Fa);return{connected:r}}function __(r,n){const{subscribe:s}=O.useContext(Fa),a=O.useRef(n);a.current=n,O.useEffect(()=>s(r,f=>a.current(f)),[s,r])}const w_=O.createContext({connected:!1,subscribe:()=>()=>{}}),S_=Tf();function E_({children:r,url:n,token:s}){const a=O.useRef(null),o=O.useRef(null),[f,h]=O.useState(!1),m=O.useRef(null),g=O.useRef(new Map),y=O.useCallback((T,q)=>{const M=g.current;return M.has(T)||M.set(T,new Set),M.get(T).add(q),()=>{const R=M.get(T);R&&(R.delete(q),R.size===0&&M.delete(T))}},[]),E=O.useCallback((T,q)=>{for(const[M,R]of g.current)if(Lg(T,M))for(const G of R)try{G(q)}catch{}},[]),w=O.useCallback(async()=>{try{if(a.current)return;const T=n||y_;if(!T){console.error("[lt-nats] no NATS WebSocket URL configured — set NATS_WS_URL on the server");return}const q=await g_({servers:T,token:s||b_||void 0,reconnect:!0,maxReconnectAttempts:-1,reconnectTimeWait:2e3});a.current=q,h(!0);const M=q.subscribe("lt.>");o.current=M,(async()=>{for await(const R of M)try{const G=JSON.parse(S_.decode(R.data));E(R.subject,G)}catch{}})(),(async()=>{for await(const R of q.status())R.type==="disconnect"||R.type==="error"?h(!1):R.type==="reconnect"&&h(!0)})()}catch{h(!1),m.current=setTimeout(w,3e3)}},[E]);return O.useEffect(()=>(w(),()=>{m.current&&clearTimeout(m.current),o.current&&o.current.unsubscribe(),a.current&&(a.current.close().catch(()=>{}),a.current=null),h(!1)}),[w]),d.jsx(w_.Provider,{value:{connected:f,subscribe:y},children:d.jsx(Fa.Provider,{value:{connected:f,subscribe:y},children:r})})}const $n=Object.create(null);$n.open="0";$n.close="1";$n.ping="2";$n.pong="3";$n.message="4";$n.upgrade="5";$n.noop="6";const jo=Object.create(null);Object.keys($n).forEach(r=>{jo[$n[r]]=r});const $f={type:"error",data:"parser error"},Hg=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Pg=typeof ArrayBuffer=="function",$g=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,oh=({type:r,data:n},s,a)=>Hg&&n instanceof Blob?s?a(n):U0(n,a):Pg&&(n instanceof ArrayBuffer||$g(n))?s?a(n):U0(new Blob([n]),a):a($n[r]+(n||"")),U0=(r,n)=>{const s=new FileReader;return s.onload=function(){const a=s.result.split(",")[1];n("b"+(a||""))},s.readAsDataURL(r)};function B0(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}let bf;function A_(r,n){if(Hg&&r.data instanceof Blob)return r.data.arrayBuffer().then(B0).then(n);if(Pg&&(r.data instanceof ArrayBuffer||$g(r.data)))return n(B0(r.data));oh(r,!1,s=>{bf||(bf=new TextEncoder),n(bf.encode(s))})}const L0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ra=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let r=0;r<L0.length;r++)Ra[L0.charCodeAt(r)]=r;const j_=r=>{let n=r.length*.75,s=r.length,a,o=0,f,h,m,g;r[r.length-1]==="="&&(n--,r[r.length-2]==="="&&n--);const y=new ArrayBuffer(n),E=new Uint8Array(y);for(a=0;a<s;a+=4)f=Ra[r.charCodeAt(a)],h=Ra[r.charCodeAt(a+1)],m=Ra[r.charCodeAt(a+2)],g=Ra[r.charCodeAt(a+3)],E[o++]=f<<2|h>>4,E[o++]=(h&15)<<4|m>>2,E[o++]=(m&3)<<6|g&63;return y},O_=typeof ArrayBuffer=="function",ch=(r,n)=>{if(typeof r!="string")return{type:"message",data:Yg(r,n)};const s=r.charAt(0);return s==="b"?{type:"message",data:T_(r.substring(1),n)}:jo[s]?r.length>1?{type:jo[s],data:r.substring(1)}:{type:jo[s]}:$f},T_=(r,n)=>{if(O_){const s=j_(r);return Yg(s,n)}else return{base64:!0,data:r}},Yg=(r,n)=>{switch(n){case"blob":return r instanceof Blob?r:new Blob([r]);case"arraybuffer":default:return r instanceof ArrayBuffer?r:r.buffer}},Gg="",N_=(r,n)=>{const s=r.length,a=new Array(s);let o=0;r.forEach((f,h)=>{oh(f,!1,m=>{a[h]=m,++o===s&&n(a.join(Gg))})})},C_=(r,n)=>{const s=r.split(Gg),a=[];for(let o=0;o<s.length;o++){const f=ch(s[o],n);if(a.push(f),f.type==="error")break}return a};function k_(){return new TransformStream({transform(r,n){A_(r,s=>{const a=s.length;let o;if(a<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,a);else if(a<65536){o=new Uint8Array(3);const f=new DataView(o.buffer);f.setUint8(0,126),f.setUint16(1,a)}else{o=new Uint8Array(9);const f=new DataView(o.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(a))}r.data&&typeof r.data!="string"&&(o[0]|=128),n.enqueue(o),n.enqueue(s)})}})}let xf;function vo(r){return r.reduce((n,s)=>n+s.length,0)}function _o(r,n){if(r[0].length===n)return r.shift();const s=new Uint8Array(n);let a=0;for(let o=0;o<n;o++)s[o]=r[0][a++],a===r[0].length&&(r.shift(),a=0);return r.length&&a<r[0].length&&(r[0]=r[0].slice(a)),s}function M_(r,n){xf||(xf=new TextDecoder);const s=[];let a=0,o=-1,f=!1;return new TransformStream({transform(h,m){for(s.push(h);;){if(a===0){if(vo(s)<1)break;const g=_o(s,1);f=(g[0]&128)===128,o=g[0]&127,o<126?a=3:o===126?a=1:a=2}else if(a===1){if(vo(s)<2)break;const g=_o(s,2);o=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),a=3}else if(a===2){if(vo(s)<8)break;const g=_o(s,8),y=new DataView(g.buffer,g.byteOffset,g.length),E=y.getUint32(0);if(E>Math.pow(2,21)-1){m.enqueue($f);break}o=E*Math.pow(2,32)+y.getUint32(4),a=3}else{if(vo(s)<o)break;const g=_o(s,o);m.enqueue(ch(f?g:xf.decode(g),n)),a=0}if(o===0||o>r){m.enqueue($f);break}}}})}const Vg=4;function gt(r){if(r)return R_(r)}function R_(r){for(var n in gt.prototype)r[n]=gt.prototype[n];return r}gt.prototype.on=gt.prototype.addEventListener=function(r,n){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(n),this};gt.prototype.once=function(r,n){function s(){this.off(r,s),n.apply(this,arguments)}return s.fn=n,this.on(r,s),this};gt.prototype.off=gt.prototype.removeListener=gt.prototype.removeAllListeners=gt.prototype.removeEventListener=function(r,n){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+r];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var a,o=0;o<s.length;o++)if(a=s[o],a===n||a.fn===n){s.splice(o,1);break}return s.length===0&&delete this._callbacks["$"+r],this};gt.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var n=new Array(arguments.length-1),s=this._callbacks["$"+r],a=1;a<arguments.length;a++)n[a-1]=arguments[a];if(s){s=s.slice(0);for(var a=0,o=s.length;a<o;++a)s[a].apply(this,n)}return this};gt.prototype.emitReserved=gt.prototype.emit;gt.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};gt.prototype.hasListeners=function(r){return!!this.listeners(r).length};const Jo=typeof Promise=="function"&&typeof Promise.resolve=="function"?n=>Promise.resolve().then(n):(n,s)=>s(n,0),vn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),D_="arraybuffer";function Fg(r,...n){return n.reduce((s,a)=>(r.hasOwnProperty(a)&&(s[a]=r[a]),s),{})}const z_=vn.setTimeout,q_=vn.clearTimeout;function Io(r,n){n.useNativeTimers?(r.setTimeoutFn=z_.bind(vn),r.clearTimeoutFn=q_.bind(vn)):(r.setTimeoutFn=vn.setTimeout.bind(vn),r.clearTimeoutFn=vn.clearTimeout.bind(vn))}const U_=1.33;function B_(r){return typeof r=="string"?L_(r):Math.ceil((r.byteLength||r.size)*U_)}function L_(r){let n=0,s=0;for(let a=0,o=r.length;a<o;a++)n=r.charCodeAt(a),n<128?s+=1:n<2048?s+=2:n<55296||n>=57344?s+=3:(a++,s+=4);return s}function Jg(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function H_(r){let n="";for(let s in r)r.hasOwnProperty(s)&&(n.length&&(n+="&"),n+=encodeURIComponent(s)+"="+encodeURIComponent(r[s]));return n}function P_(r){let n={},s=r.split("&");for(let a=0,o=s.length;a<o;a++){let f=s[a].split("=");n[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return n}class $_ extends Error{constructor(n,s,a){super(n),this.description=s,this.context=a,this.type="TransportError"}}class uh extends gt{constructor(n){super(),this.writable=!1,Io(this,n),this.opts=n,this.query=n.query,this.socket=n.socket,this.supportsBinary=!n.forceBase64}onError(n,s,a){return super.emitReserved("error",new $_(n,s,a)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(n){this.readyState==="open"&&this.write(n)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(n){const s=ch(n,this.socket.binaryType);this.onPacket(s)}onPacket(n){super.emitReserved("packet",n)}onClose(n){this.readyState="closed",super.emitReserved("close",n)}pause(n){}createUri(n,s={}){return n+"://"+this._hostname()+this._port()+this.opts.path+this._query(s)}_hostname(){const n=this.opts.hostname;return n.indexOf(":")===-1?n:"["+n+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(n){const s=H_(n);return s.length?"?"+s:""}}class Y_ extends uh{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(n){this.readyState="pausing";const s=()=>{this.readyState="paused",n()};if(this._polling||!this.writable){let a=0;this._polling&&(a++,this.once("pollComplete",function(){--a||s()})),this.writable||(a++,this.once("drain",function(){--a||s()}))}else s()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(n){const s=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};C_(n,this.socket.binaryType).forEach(s),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const n=()=>{this.write([{type:"close"}])};this.readyState==="open"?n():this.once("open",n)}write(n){this.writable=!1,N_(n,s=>{this.doWrite(s,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const n=this.opts.secure?"https":"http",s=this.query||{};return this.opts.timestampRequests!==!1&&(s[this.opts.timestampParam]=Jg()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(n,s)}}let Ig=!1;try{Ig=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const G_=Ig;function V_(){}class F_ extends Y_{constructor(n){if(super(n),typeof location<"u"){const s=location.protocol==="https:";let a=location.port;a||(a=s?"443":"80"),this.xd=typeof location<"u"&&n.hostname!==location.hostname||a!==n.port}}doWrite(n,s){const a=this.request({method:"POST",data:n});a.on("success",s),a.on("error",(o,f)=>{this.onError("xhr post error",o,f)})}doPoll(){const n=this.request();n.on("data",this.onData.bind(this)),n.on("error",(s,a)=>{this.onError("xhr poll error",s,a)}),this.pollXhr=n}}class Pn extends gt{constructor(n,s,a){super(),this.createRequest=n,Io(this,a),this._opts=a,this._method=a.method||"GET",this._uri=s,this._data=a.data!==void 0?a.data:null,this._create()}_create(){var n;const s=Fg(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;const a=this._xhr=this.createRequest(s);try{a.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&a.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{a.setRequestHeader("Accept","*/*")}catch{}(n=this._opts.cookieJar)===null||n===void 0||n.addCookies(a),"withCredentials"in a&&(a.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(a.timeout=this._opts.requestTimeout),a.onreadystatechange=()=>{var o;a.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(a.getResponseHeader("set-cookie"))),a.readyState===4&&(a.status===200||a.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof a.status=="number"?a.status:0)},0))},a.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=Pn.requestsCount++,Pn.requests[this._index]=this)}_onError(n){this.emitReserved("error",n,this._xhr),this._cleanup(!0)}_cleanup(n){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=V_,n)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Pn.requests[this._index],this._xhr=null}}_onLoad(){const n=this._xhr.responseText;n!==null&&(this.emitReserved("data",n),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Pn.requestsCount=0;Pn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",H0);else if(typeof addEventListener=="function"){const r="onpagehide"in vn?"pagehide":"unload";addEventListener(r,H0,!1)}}function H0(){for(let r in Pn.requests)Pn.requests.hasOwnProperty(r)&&Pn.requests[r].abort()}const J_=(function(){const r=Qg({xdomain:!1});return r&&r.responseType!==null})();class I_ extends F_{constructor(n){super(n);const s=n&&n.forceBase64;this.supportsBinary=J_&&!s}request(n={}){return Object.assign(n,{xd:this.xd},this.opts),new Pn(Qg,this.uri(),n)}}function Qg(r){const n=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!n||G_))return new XMLHttpRequest}catch{}if(!n)try{return new vn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Xg=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Q_ extends uh{get name(){return"websocket"}doOpen(){const n=this.uri(),s=this.opts.protocols,a=Xg?{}:Fg(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(n,s,a)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=n=>this.onClose({description:"websocket connection closed",context:n}),this.ws.onmessage=n=>this.onData(n.data),this.ws.onerror=n=>this.onError("websocket error",n)}write(n){this.writable=!1;for(let s=0;s<n.length;s++){const a=n[s],o=s===n.length-1;oh(a,this.supportsBinary,f=>{try{this.doWrite(a,f)}catch{}o&&Jo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const n=this.opts.secure?"wss":"ws",s=this.query||{};return this.opts.timestampRequests&&(s[this.opts.timestampParam]=Jg()),this.supportsBinary||(s.b64=1),this.createUri(n,s)}}const vf=vn.WebSocket||vn.MozWebSocket;class X_ extends Q_{createSocket(n,s,a){return Xg?new vf(n,s,a):s?new vf(n,s):new vf(n)}doWrite(n,s){this.ws.send(s)}}class K_ extends uh{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(n){return this.emitReserved("error",n)}this._transport.closed.then(()=>{this.onClose()}).catch(n=>{this.onError("webtransport error",n)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(n=>{const s=M_(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=n.readable.pipeThrough(s).getReader(),o=k_();o.readable.pipeTo(n.writable),this._writer=o.writable.getWriter();const f=()=>{a.read().then(({done:m,value:g})=>{m||(this.onPacket(g),f())}).catch(m=>{})};f();const h={type:"open"};this.query.sid&&(h.data=`{"sid":"${this.query.sid}"}`),this._writer.write(h).then(()=>this.onOpen())})})}write(n){this.writable=!1;for(let s=0;s<n.length;s++){const a=n[s],o=s===n.length-1;this._writer.write(a).then(()=>{o&&Jo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var n;(n=this._transport)===null||n===void 0||n.close()}}const Z_={websocket:X_,webtransport:K_,polling:I_},W_=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ew=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Yf(r){if(r.length>8e3)throw"URI too long";const n=r,s=r.indexOf("["),a=r.indexOf("]");s!=-1&&a!=-1&&(r=r.substring(0,s)+r.substring(s,a).replace(/:/g,";")+r.substring(a,r.length));let o=W_.exec(r||""),f={},h=14;for(;h--;)f[ew[h]]=o[h]||"";return s!=-1&&a!=-1&&(f.source=n,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=tw(f,f.path),f.queryKey=nw(f,f.query),f}function tw(r,n){const s=/\/{2,9}/g,a=n.replace(s,"/").split("/");return(n.slice(0,1)=="/"||n.length===0)&&a.splice(0,1),n.slice(-1)=="/"&&a.splice(a.length-1,1),a}function nw(r,n){const s={};return n.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,o,f){o&&(s[o]=f)}),s}const Gf=typeof addEventListener=="function"&&typeof removeEventListener=="function",Oo=[];Gf&&addEventListener("offline",()=>{Oo.forEach(r=>r())},!1);class Xs extends gt{constructor(n,s){if(super(),this.binaryType=D_,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,n&&typeof n=="object"&&(s=n,n=null),n){const a=Yf(n);s.hostname=a.host,s.secure=a.protocol==="https"||a.protocol==="wss",s.port=a.port,a.query&&(s.query=a.query)}else s.host&&(s.hostname=Yf(s.host).host);Io(this,s),this.secure=s.secure!=null?s.secure:typeof location<"u"&&location.protocol==="https:",s.hostname&&!s.port&&(s.port=this.secure?"443":"80"),this.hostname=s.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=s.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},s.transports.forEach(a=>{const o=a.prototype.name;this.transports.push(o),this._transportsByName[o]=a}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},s),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=P_(this.opts.query)),Gf&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Oo.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(n){const s=Object.assign({},this.opts.query);s.EIO=Vg,s.transport=n,this.id&&(s.sid=this.id);const a=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[n]);return new this._transportsByName[n](a)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const n=this.opts.rememberUpgrade&&Xs.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const s=this.createTransport(n);s.open(),this.setTransport(s)}setTransport(n){this.transport&&this.transport.removeAllListeners(),this.transport=n,n.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",s=>this._onClose("transport close",s))}onOpen(){this.readyState="open",Xs.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",n),this.emitReserved("heartbeat"),n.type){case"open":this.onHandshake(JSON.parse(n.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const s=new Error("server error");s.code=n.data,this._onError(s);break;case"message":this.emitReserved("data",n.data),this.emitReserved("message",n.data);break}}onHandshake(n){this.emitReserved("handshake",n),this.id=n.sid,this.transport.query.sid=n.sid,this._pingInterval=n.pingInterval,this._pingTimeout=n.pingTimeout,this._maxPayload=n.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const n=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+n,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},n),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const n=this._getWritablePackets();this.transport.send(n),this._prevBufferLen=n.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let s=1;for(let a=0;a<this.writeBuffer.length;a++){const o=this.writeBuffer[a].data;if(o&&(s+=B_(o)),a>0&&s>this._maxPayload)return this.writeBuffer.slice(0,a);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const n=Date.now()>this._pingTimeoutTime;return n&&(this._pingTimeoutTime=0,Jo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),n}write(n,s,a){return this._sendPacket("message",n,s,a),this}send(n,s,a){return this._sendPacket("message",n,s,a),this}_sendPacket(n,s,a,o){if(typeof s=="function"&&(o=s,s=void 0),typeof a=="function"&&(o=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;const f={type:n,data:s,options:a};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),o&&this.once("flush",o),this.flush()}close(){const n=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),n()},a=()=>{this.once("upgrade",s),this.once("upgradeError",s)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?a():n()}):this.upgrading?a():n()),this}_onError(n){if(Xs.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",n),this._onClose("transport error",n)}_onClose(n,s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Gf&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const a=Oo.indexOf(this._offlineEventListener);a!==-1&&Oo.splice(a,1)}this.readyState="closed",this.id=null,this.emitReserved("close",n,s),this.writeBuffer=[],this._prevBufferLen=0}}}Xs.protocol=Vg;class sw extends Xs{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let n=0;n<this._upgrades.length;n++)this._probe(this._upgrades[n])}_probe(n){let s=this.createTransport(n),a=!1;Xs.priorWebsocketSuccess=!1;const o=()=>{a||(s.send([{type:"ping",data:"probe"}]),s.once("packet",w=>{if(!a)if(w.type==="pong"&&w.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",s),!s)return;Xs.priorWebsocketSuccess=s.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(E(),this.setTransport(s),s.send([{type:"upgrade"}]),this.emitReserved("upgrade",s),s=null,this.upgrading=!1,this.flush())})}else{const T=new Error("probe error");T.transport=s.name,this.emitReserved("upgradeError",T)}}))};function f(){a||(a=!0,E(),s.close(),s=null)}const h=w=>{const T=new Error("probe error: "+w);T.transport=s.name,f(),this.emitReserved("upgradeError",T)};function m(){h("transport closed")}function g(){h("socket closed")}function y(w){s&&w.name!==s.name&&f()}const E=()=>{s.removeListener("open",o),s.removeListener("error",h),s.removeListener("close",m),this.off("close",g),this.off("upgrading",y)};s.once("open",o),s.once("error",h),s.once("close",m),this.once("close",g),this.once("upgrading",y),this._upgrades.indexOf("webtransport")!==-1&&n!=="webtransport"?this.setTimeoutFn(()=>{a||s.open()},200):s.open()}onHandshake(n){this._upgrades=this._filterUpgrades(n.upgrades),super.onHandshake(n)}_filterUpgrades(n){const s=[];for(let a=0;a<n.length;a++)~this.transports.indexOf(n[a])&&s.push(n[a]);return s}}let iw=class extends sw{constructor(n,s={}){const a=typeof n=="object"?n:s;(!a.transports||a.transports&&typeof a.transports[0]=="string")&&(a.transports=(a.transports||["polling","websocket","webtransport"]).map(o=>Z_[o]).filter(o=>!!o)),super(n,a)}};function rw(r,n="",s){let a=r;s=s||typeof location<"u"&&location,r==null&&(r=s.protocol+"//"+s.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=s.protocol+r:r=s.host+r),/^(https?|wss?):\/\//.test(r)||(typeof s<"u"?r=s.protocol+"//"+r:r="https://"+r),a=Yf(r)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";const f=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+f+":"+a.port+n,a.href=a.protocol+"://"+f+(s&&s.port===a.port?"":":"+a.port),a}const aw=typeof ArrayBuffer=="function",lw=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Kg=Object.prototype.toString,ow=typeof Blob=="function"||typeof Blob<"u"&&Kg.call(Blob)==="[object BlobConstructor]",cw=typeof File=="function"||typeof File<"u"&&Kg.call(File)==="[object FileConstructor]";function fh(r){return aw&&(r instanceof ArrayBuffer||lw(r))||ow&&r instanceof Blob||cw&&r instanceof File}function To(r,n){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let s=0,a=r.length;s<a;s++)if(To(r[s]))return!0;return!1}if(fh(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return To(r.toJSON(),!0);for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)&&To(r[s]))return!0;return!1}function uw(r){const n=[],s=r.data,a=r;return a.data=Vf(s,n),a.attachments=n.length,{packet:a,buffers:n}}function Vf(r,n){if(!r)return r;if(fh(r)){const s={_placeholder:!0,num:n.length};return n.push(r),s}else if(Array.isArray(r)){const s=new Array(r.length);for(let a=0;a<r.length;a++)s[a]=Vf(r[a],n);return s}else if(typeof r=="object"&&!(r instanceof Date)){const s={};for(const a in r)Object.prototype.hasOwnProperty.call(r,a)&&(s[a]=Vf(r[a],n));return s}return r}function fw(r,n){return r.data=Ff(r.data,n),delete r.attachments,r}function Ff(r,n){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<n.length)return n[r.num];throw new Error("illegal attachments")}else if(Array.isArray(r))for(let s=0;s<r.length;s++)r[s]=Ff(r[s],n);else if(typeof r=="object")for(const s in r)Object.prototype.hasOwnProperty.call(r,s)&&(r[s]=Ff(r[s],n));return r}const hw=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var qe;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(qe||(qe={}));class dw{constructor(n){this.replacer=n}encode(n){return(n.type===qe.EVENT||n.type===qe.ACK)&&To(n)?this.encodeAsBinary({type:n.type===qe.EVENT?qe.BINARY_EVENT:qe.BINARY_ACK,nsp:n.nsp,data:n.data,id:n.id}):[this.encodeAsString(n)]}encodeAsString(n){let s=""+n.type;return(n.type===qe.BINARY_EVENT||n.type===qe.BINARY_ACK)&&(s+=n.attachments+"-"),n.nsp&&n.nsp!=="/"&&(s+=n.nsp+","),n.id!=null&&(s+=n.id),n.data!=null&&(s+=JSON.stringify(n.data,this.replacer)),s}encodeAsBinary(n){const s=uw(n),a=this.encodeAsString(s.packet),o=s.buffers;return o.unshift(a),o}}class hh extends gt{constructor(n){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof n=="function"?{reviver:n}:n)}add(n){let s;if(typeof n=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");s=this.decodeString(n);const a=s.type===qe.BINARY_EVENT;a||s.type===qe.BINARY_ACK?(s.type=a?qe.EVENT:qe.ACK,this.reconstructor=new mw(s),s.attachments===0&&super.emitReserved("decoded",s)):super.emitReserved("decoded",s)}else if(fh(n)||n.base64)if(this.reconstructor)s=this.reconstructor.takeBinaryData(n),s&&(this.reconstructor=null,super.emitReserved("decoded",s));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+n)}decodeString(n){let s=0;const a={type:Number(n.charAt(0))};if(qe[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===qe.BINARY_EVENT||a.type===qe.BINARY_ACK){const f=s+1;for(;n.charAt(++s)!=="-"&&s!=n.length;);const h=n.substring(f,s);if(h!=Number(h)||n.charAt(s)!=="-")throw new Error("Illegal attachments");const m=Number(h);if(!pw(m)||m<0)throw new Error("Illegal attachments");if(m>this.opts.maxAttachments)throw new Error("too many attachments");a.attachments=m}if(n.charAt(s+1)==="/"){const f=s+1;for(;++s&&!(n.charAt(s)===","||s===n.length););a.nsp=n.substring(f,s)}else a.nsp="/";const o=n.charAt(s+1);if(o!==""&&Number(o)==o){const f=s+1;for(;++s;){const h=n.charAt(s);if(h==null||Number(h)!=h){--s;break}if(s===n.length)break}a.id=Number(n.substring(f,s+1))}if(n.charAt(++s)){const f=this.tryParse(n.substr(s));if(hh.isPayloadValid(a.type,f))a.data=f;else throw new Error("invalid payload")}return a}tryParse(n){try{return JSON.parse(n,this.opts.reviver)}catch{return!1}}static isPayloadValid(n,s){switch(n){case qe.CONNECT:return P0(s);case qe.DISCONNECT:return s===void 0;case qe.CONNECT_ERROR:return typeof s=="string"||P0(s);case qe.EVENT:case qe.BINARY_EVENT:return Array.isArray(s)&&(typeof s[0]=="number"||typeof s[0]=="string"&&hw.indexOf(s[0])===-1);case qe.ACK:case qe.BINARY_ACK:return Array.isArray(s)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class mw{constructor(n){this.packet=n,this.buffers=[],this.reconPack=n}takeBinaryData(n){if(this.buffers.push(n),this.buffers.length===this.reconPack.attachments){const s=fw(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const pw=Number.isInteger||function(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r};function P0(r){return Object.prototype.toString.call(r)==="[object Object]"}const gw=Object.freeze(Object.defineProperty({__proto__:null,Decoder:hh,Encoder:dw,get PacketType(){return qe}},Symbol.toStringTag,{value:"Module"}));function Cn(r,n,s){return r.on(n,s),function(){r.off(n,s)}}const yw=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Zg extends gt{constructor(n,s,a){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=n,this.nsp=s,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const n=this.io;this.subs=[Cn(n,"open",this.onopen.bind(this)),Cn(n,"packet",this.onpacket.bind(this)),Cn(n,"error",this.onerror.bind(this)),Cn(n,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...n){return n.unshift("message"),this.emit.apply(this,n),this}emit(n,...s){var a,o,f;if(yw.hasOwnProperty(n))throw new Error('"'+n.toString()+'" is a reserved event name');if(s.unshift(n),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(s),this;const h={type:qe.EVENT,data:s};if(h.options={},h.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const E=this.ids++,w=s.pop();this._registerAckCallback(E,w),h.id=E}const m=(o=(a=this.io.engine)===null||a===void 0?void 0:a.transport)===null||o===void 0?void 0:o.writable,g=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!m||(g?(this.notifyOutgoingListeners(h),this.packet(h)):this.sendBuffer.push(h)),this.flags={},this}_registerAckCallback(n,s){var a;const o=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(o===void 0){this.acks[n]=s;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[n];for(let m=0;m<this.sendBuffer.length;m++)this.sendBuffer[m].id===n&&this.sendBuffer.splice(m,1);s.call(this,new Error("operation has timed out"))},o),h=(...m)=>{this.io.clearTimeoutFn(f),s.apply(this,m)};h.withError=!0,this.acks[n]=h}emitWithAck(n,...s){return new Promise((a,o)=>{const f=(h,m)=>h?o(h):a(m);f.withError=!0,s.push(f),this.emit(n,...s)})}_addToQueue(n){let s;typeof n[n.length-1]=="function"&&(s=n.pop());const a={id:this._queueSeq++,tryCount:0,pending:!1,args:n,flags:Object.assign({fromQueue:!0},this.flags)};n.push((o,...f)=>(this._queue[0],o!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),s&&s(o)):(this._queue.shift(),s&&s(null,...f)),a.pending=!1,this._drainQueue())),this._queue.push(a),this._drainQueue()}_drainQueue(n=!1){if(!this.connected||this._queue.length===0)return;const s=this._queue[0];s.pending&&!n||(s.pending=!0,s.tryCount++,this.flags=s.flags,this.emit.apply(this,s.args))}packet(n){n.nsp=this.nsp,this.io._packet(n)}onopen(){typeof this.auth=="function"?this.auth(n=>{this._sendConnectPacket(n)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(n){this.packet({type:qe.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},n):n})}onerror(n){this.connected||this.emitReserved("connect_error",n)}onclose(n,s){this.connected=!1,delete this.id,this.emitReserved("disconnect",n,s),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(n=>{if(!this.sendBuffer.some(a=>String(a.id)===n)){const a=this.acks[n];delete this.acks[n],a.withError&&a.call(this,new Error("socket has been disconnected"))}})}onpacket(n){if(n.nsp===this.nsp)switch(n.type){case qe.CONNECT:n.data&&n.data.sid?this.onconnect(n.data.sid,n.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case qe.EVENT:case qe.BINARY_EVENT:this.onevent(n);break;case qe.ACK:case qe.BINARY_ACK:this.onack(n);break;case qe.DISCONNECT:this.ondisconnect();break;case qe.CONNECT_ERROR:this.destroy();const a=new Error(n.data.message);a.data=n.data.data,this.emitReserved("connect_error",a);break}}onevent(n){const s=n.data||[];n.id!=null&&s.push(this.ack(n.id)),this.connected?this.emitEvent(s):this.receiveBuffer.push(Object.freeze(s))}emitEvent(n){if(this._anyListeners&&this._anyListeners.length){const s=this._anyListeners.slice();for(const a of s)a.apply(this,n)}super.emit.apply(this,n),this._pid&&n.length&&typeof n[n.length-1]=="string"&&(this._lastOffset=n[n.length-1])}ack(n){const s=this;let a=!1;return function(...o){a||(a=!0,s.packet({type:qe.ACK,id:n,data:o}))}}onack(n){const s=this.acks[n.id];typeof s=="function"&&(delete this.acks[n.id],s.withError&&n.data.unshift(null),s.apply(this,n.data))}onconnect(n,s){this.id=n,this.recovered=s&&this._pid===s,this._pid=s,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(n=>this.emitEvent(n)),this.receiveBuffer=[],this.sendBuffer.forEach(n=>{this.notifyOutgoingListeners(n),this.packet(n)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(n=>n()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:qe.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(n){return this.flags.compress=n,this}get volatile(){return this.flags.volatile=!0,this}timeout(n){return this.flags.timeout=n,this}onAny(n){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(n),this}prependAny(n){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(n),this}offAny(n){if(!this._anyListeners)return this;if(n){const s=this._anyListeners;for(let a=0;a<s.length;a++)if(n===s[a])return s.splice(a,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(n){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(n),this}prependAnyOutgoing(n){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(n),this}offAnyOutgoing(n){if(!this._anyOutgoingListeners)return this;if(n){const s=this._anyOutgoingListeners;for(let a=0;a<s.length;a++)if(n===s[a])return s.splice(a,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(n){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const s=this._anyOutgoingListeners.slice();for(const a of s)a.apply(this,n.data)}}}function Nr(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}Nr.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var n=Math.random(),s=Math.floor(n*this.jitter*r);r=(Math.floor(n*10)&1)==0?r-s:r+s}return Math.min(r,this.max)|0};Nr.prototype.reset=function(){this.attempts=0};Nr.prototype.setMin=function(r){this.ms=r};Nr.prototype.setMax=function(r){this.max=r};Nr.prototype.setJitter=function(r){this.jitter=r};class Jf extends gt{constructor(n,s){var a;super(),this.nsps={},this.subs=[],n&&typeof n=="object"&&(s=n,n=void 0),s=s||{},s.path=s.path||"/socket.io",this.opts=s,Io(this,s),this.reconnection(s.reconnection!==!1),this.reconnectionAttempts(s.reconnectionAttempts||1/0),this.reconnectionDelay(s.reconnectionDelay||1e3),this.reconnectionDelayMax(s.reconnectionDelayMax||5e3),this.randomizationFactor((a=s.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new Nr({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(s.timeout==null?2e4:s.timeout),this._readyState="closed",this.uri=n;const o=s.parser||gw;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=s.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(n){return arguments.length?(this._reconnection=!!n,n||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(n){return n===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=n,this)}reconnectionDelay(n){var s;return n===void 0?this._reconnectionDelay:(this._reconnectionDelay=n,(s=this.backoff)===null||s===void 0||s.setMin(n),this)}randomizationFactor(n){var s;return n===void 0?this._randomizationFactor:(this._randomizationFactor=n,(s=this.backoff)===null||s===void 0||s.setJitter(n),this)}reconnectionDelayMax(n){var s;return n===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=n,(s=this.backoff)===null||s===void 0||s.setMax(n),this)}timeout(n){return arguments.length?(this._timeout=n,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(n){if(~this._readyState.indexOf("open"))return this;this.engine=new iw(this.uri,this.opts);const s=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;const o=Cn(s,"open",function(){a.onopen(),n&&n()}),f=m=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",m),n?n(m):this.maybeReconnectOnOpen()},h=Cn(s,"error",f);if(this._timeout!==!1){const m=this._timeout,g=this.setTimeoutFn(()=>{o(),f(new Error("timeout")),s.close()},m);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(o),this.subs.push(h),this}connect(n){return this.open(n)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const n=this.engine;this.subs.push(Cn(n,"ping",this.onping.bind(this)),Cn(n,"data",this.ondata.bind(this)),Cn(n,"error",this.onerror.bind(this)),Cn(n,"close",this.onclose.bind(this)),Cn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(n){try{this.decoder.add(n)}catch(s){this.onclose("parse error",s)}}ondecoded(n){Jo(()=>{this.emitReserved("packet",n)},this.setTimeoutFn)}onerror(n){this.emitReserved("error",n)}socket(n,s){let a=this.nsps[n];return a?this._autoConnect&&!a.active&&a.connect():(a=new Zg(this,n,s),this.nsps[n]=a),a}_destroy(n){const s=Object.keys(this.nsps);for(const a of s)if(this.nsps[a].active)return;this._close()}_packet(n){const s=this.encoder.encode(n);for(let a=0;a<s.length;a++)this.engine.write(s[a],n.options)}cleanup(){this.subs.forEach(n=>n()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(n,s){var a;this.cleanup(),(a=this.engine)===null||a===void 0||a.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",n,s),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const n=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const s=this.backoff.duration();this._reconnecting=!0;const a=this.setTimeoutFn(()=>{n.skipReconnect||(this.emitReserved("reconnect_attempt",n.backoff.attempts),!n.skipReconnect&&n.open(o=>{o?(n._reconnecting=!1,n.reconnect(),this.emitReserved("reconnect_error",o)):n.onreconnect()}))},s);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){const n=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",n)}}const Oa={};function No(r,n){typeof r=="object"&&(n=r,r=void 0),n=n||{};const s=rw(r,n.path||"/socket.io"),a=s.source,o=s.id,f=s.path,h=Oa[o]&&f in Oa[o].nsps,m=n.forceNew||n["force new connection"]||n.multiplex===!1||h;let g;return m?g=new Jf(a,n):(Oa[o]||(Oa[o]=new Jf(a,n)),g=Oa[o]),s.query&&!n.query&&(n.query=s.queryKey),g.socket(s.path,n)}Object.assign(No,{Manager:Jf,Socket:Zg,io:No,connect:No});const bw=O.createContext({connected:!1,subscribe:()=>()=>{}});function xw({children:r}){const n=O.useRef(null),[s,a]=O.useState(!1),o=O.useRef(new Map),f=O.useCallback((m,g)=>{const y=o.current;return y.has(m)||y.set(m,new Set),y.get(m).add(g),()=>{const E=y.get(m);E&&(E.delete(g),E.size===0&&y.delete(m))}},[]),h=O.useCallback((m,g)=>{for(const[y,E]of o.current)if(Lg(m,y))for(const w of E)try{w(g)}catch{}},[]);return O.useEffect(()=>{const m=vg(),g=No({path:`${Wt}/socket.io`,transports:["polling","websocket"],upgrade:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:2e3,...m?{auth:{token:m}}:{}});return n.current=g,console.log("[lt-socketio] connecting..."),g.on("connect",()=>{console.log("[lt-socketio] connected, id:",g.id),a(!0)}),g.on("disconnect",y=>{console.log("[lt-socketio] disconnected:",y),a(!1)}),g.on("connect_error",y=>{console.warn("[lt-socketio] connect error:",y.message),a(!1)}),g.onAny((y,E)=>{if(y.startsWith("lt."))try{const w=typeof E=="string"?JSON.parse(E):E;h(y,w)}catch{}}),()=>{g.removeAllListeners(),g.disconnect(),n.current=null,a(!1)}},[h]),d.jsx(bw.Provider,{value:{connected:s,subscribe:f},children:d.jsx(Fa.Provider,{value:{connected:s,subscribe:f},children:r})})}function vw({children:r}){const[n,s]=O.useState(null),[a,o]=O.useState({url:null,token:null});return O.useEffect(()=>{let f=!1;async function h(){var m;try{console.log("[lt-transport] detecting event transport...");const g=await fetch(`${Wt}/api/settings`);if(!g.ok){console.warn("[lt-transport] settings fetch failed, falling back to socketio"),f||s("socketio");return}const y=await g.json(),E=(m=y==null?void 0:y.events)==null?void 0:m.transport;if(console.log("[lt-transport] server reports:",E),!f){if(E==="nats"){let w=y.events.natsWsUrl??null,T=null;const q=vg();if(q)try{const M=await fetch(`${Wt}/api/nats-credentials`,{headers:{Authorization:`Bearer ${q}`}});if(M.ok){const R=await M.json();w=R.natsWsUrl??w,T=R.natsToken??null}}catch{console.warn("[lt-transport] failed to fetch NATS credentials")}o({url:w,token:T})}s(E==="nats"?"nats":"socketio")}}catch(g){console.warn("[lt-transport] settings fetch error, falling back to socketio",g),f||s("socketio")}}return h(),()=>{f=!0}},[]),n==="nats"?d.jsx(E_,{url:a.url,token:a.token,children:r}):n==="socketio"?d.jsx(xw,{children:r}):d.jsx(d.Fragment,{children:r})}function Wg(){const{isSuperAdmin:r,hasRoleType:n,hasRole:s}=Oi(),a=r||s("engineer"),o=n("admin"),f=r||n("admin");return{isBuilder:a,isOps:o,canBulk:f}}const If="lt_ai_override";function _w(){return $e("/settings")}function Qf(){try{if(localStorage.getItem(If)==="off")return!1}catch{}return null}function Qo(){var s;const r=_n({queryKey:["settings"],queryFn:_w,staleTime:1/0}),n=Qf();return r.data&&n===!1&&((s=r.data.ai)!=null&&s.enabled)?{...r,data:{...r.data,ai:{enabled:!1}}}:r}function ww(){const[r,n]=O.useState(()=>Qf()===!1),s=O.useCallback(()=>{const a=Qf()===!1;try{a?localStorage.removeItem(If):localStorage.setItem(If,"off")}catch{}n(!a),window.location.reload()},[]);return{aiOverrideActive:r,toggleAIOverride:s}}const ey=O.createContext(null),$0="lt_sidebar_collapsed";function Sw({children:r}){const[n,s]=O.useState(()=>{try{return localStorage.getItem($0)==="true"}catch{return!1}}),a=O.useCallback(()=>{s(o=>{const f=!o;try{localStorage.setItem($0,String(f))}catch{}return f})},[]);return d.jsx(ey.Provider,{value:{collapsed:n,toggle:a},children:r})}function ty(){const r=O.useContext(ey);if(!r)throw new Error("useSidebar must be used within SidebarProvider");return r}function ny(r,n){var s,a,o,f,h;n.facets&&Object.keys(n.facets).length&&r.set("facets",JSON.stringify(n.facets)),(s=n.block)!=null&&s.length&&r.set("block",JSON.stringify(n.block)),(a=n.range)!=null&&a.length&&r.set("range",JSON.stringify(n.range)),(o=n.exists)!=null&&o.length&&r.set("exists",JSON.stringify(n.exists)),(f=n.roles)!=null&&f.length&&r.set("roles",JSON.stringify(n.roles)),(h=n.orderBy)!=null&&h.length&&r.set("orderBy",JSON.stringify(n.orderBy)),n.available!==void 0&&r.set("available",String(n.available))}function VE(r,n){const s=r??"24h";return _n({queryKey:["stationMetrics",s],queryFn:()=>$e(`/escalations/station-metrics?period=${s}`),staleTime:5e3,enabled:(n==null?void 0:n.enabled)??!0})}function FE(r){const n=r?`?period=${r}`:"";return _n({queryKey:["escalationStats",r],queryFn:()=>$e(`/escalations/stats${n}`)})}function JE(){return _n({queryKey:["escalationTypes"],queryFn:()=>$e("/escalations/types")})}function IE(r=!0){return _n({queryKey:["escalationFacetKeys"],queryFn:()=>$e("/escalations/facet-keys"),enabled:r,staleTime:6e4})}function Ew(r){const{enabled:n=!0,staleTime:s,...a}=r,o=new URLSearchParams;return a.status&&o.set("status",a.status),a.role&&o.set("role",a.role),a.type&&o.set("type",a.type),a.subtype&&o.set("subtype",a.subtype),a.assigned_to&&o.set("assigned_to",a.assigned_to),a.claimed&&o.set("claimed","true"),a.priority&&o.set("priority",String(a.priority)),a.limit&&o.set("limit",String(a.limit)),a.offset!==void 0&&o.set("offset",String(a.offset)),a.sort_by&&o.set("sort_by",a.sort_by),a.order&&o.set("order",a.order),a.search&&o.set("search",a.search),ny(o,a),_n({queryKey:["escalations",a],queryFn:()=>$e(`/escalations?${o}`),enabled:n,...s!==void 0?{staleTime:s}:{}})}function Aw(r){const{enabled:n=!0,staleTime:s,...a}=r,o=new URLSearchParams;return a.role&&o.set("role",a.role),a.type&&o.set("type",a.type),a.subtype&&o.set("subtype",a.subtype),a.priority&&o.set("priority",String(a.priority)),a.limit&&o.set("limit",String(a.limit)),a.offset!==void 0&&o.set("offset",String(a.offset)),a.sort_by&&o.set("sort_by",a.sort_by),a.order&&o.set("order",a.order),a.search&&o.set("search",a.search),ny(o,a),_n({queryKey:["escalations","available",a],queryFn:()=>$e(`/escalations/available?${o}`),enabled:n,...s!==void 0?{staleTime:s}:{}})}function QE(r){return _n({queryKey:["escalations","by-workflow",r],queryFn:()=>$e(`/escalations/by-workflow/${r}`),enabled:!!r})}function XE(r){return _n({queryKey:["escalations",r],queryFn:()=>$e(`/escalations/${r}`),enabled:!!r})}function KE(){const r=rn();return wn({mutationFn:({id:n,durationMinutes:s})=>$e(`/escalations/${n}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:s})}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function ZE(){const r=rn();return wn({mutationFn:n=>$e(`/escalations/${n}/release`,{method:"POST"}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function WE(){const r=rn();return wn({mutationFn:({id:n,resolverPayload:s})=>$e(`/escalations/${n}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:s})}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]}),r.resetQueries({queryKey:["tasks"]}),r.resetQueries({queryKey:["jobs"]})}})}function e3(){const r=rn();return wn({mutationFn:({id:n,targetRole:s})=>$e(`/escalations/${n}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:s})}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function t3(){const r=rn();return wn({mutationFn:({ids:n,priority:s})=>$e("/escalations/priority",{method:"PATCH",body:JSON.stringify({ids:n,priority:s})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function n3(){const r=rn();return wn({mutationFn:({ids:n,durationMinutes:s})=>$e("/escalations/bulk-claim",{method:"POST",body:JSON.stringify({ids:n,durationMinutes:s})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function s3(){const r=rn();return wn({mutationFn:({ids:n,targetUserId:s,durationMinutes:a})=>$e("/escalations/bulk-assign",{method:"POST",body:JSON.stringify({ids:n,targetUserId:s,durationMinutes:a})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function i3(){const r=rn();return wn({mutationFn:({ids:n,targetRole:s})=>$e("/escalations/bulk-escalate",{method:"PATCH",body:JSON.stringify({ids:n,targetRole:s})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function r3(){const r=rn();return wn({mutationFn:({ids:n,hint:s})=>$e("/escalations/bulk-triage",{method:"POST",body:JSON.stringify({ids:n,...s?{hint:s}:{}})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function a3(){const r=rn();return wn({mutationFn:n=>$e(`/escalations/${n}/cancel`,{method:"POST"}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function l3(){const r=rn();return wn({mutationFn:({ids:n})=>$e("/escalations/bulk-cancel",{method:"POST",body:JSON.stringify({ids:n})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function jw(){const{user:r}=Oi(),n=r==null?void 0:r.userId,s=rn(),a=O.useRef(null),o=O.useCallback(()=>{a.current||(a.current=setTimeout(()=>{a.current=null,s.invalidateQueries({queryKey:["escalations"]})},15e3))},[s]);__(`${x_}.system.escalation.>`,o);const{data:f}=Aw({limit:1}),{data:h}=Ew({assigned_to:n,status:"pending",limit:1});return{available:(f==null?void 0:f.total)??0,mine:(h==null?void 0:h.total)??0}}function dh({size:r="sm",hideLabel:n=!1,className:s=""}){const a=r==="lg",o=a?"w-[16rem] h-[16rem] -rotate-[120deg] opacity-40 -ml-10":"w-[12.5rem] h-[12.5rem] -rotate-[120deg] opacity-40 -ml-8",f=a?"text-[44px] font-normal text-text-primary tracking-[0.15em] -ml-[12.5rem]":"text-[36px] font-normal text-text-primary tracking-[0.15em] -ml-[9.75rem]";return d.jsxs("div",{className:`flex items-center ${s}`,style:{height:"50px"},children:[d.jsx("span",{role:"img","aria-label":"LongTail",className:`logo-mark shrink-0 z-0 ${o}`,style:{"--logo-url":`url(${Wt}/logo512.png)`}}),d.jsx("span",{className:`z-[1] transition-opacity duration-300 ${f} ${n?"opacity-0":""}`,children:"LongTail"})]})}const sy=["violet","red","green","blue","rose"],Y0="blue",Ow={violet:"#7B3BE0",red:"#DC382D",green:"#059669",blue:"#1E3A8A",rose:"#D6246E"},G0={violet:"Violet",red:"Brick",green:"Emerald",blue:"Navy",rose:"Raspberry"},iy="lt.theme";function Tw(r){return sy.includes(r)}function ry(){try{const r=localStorage.getItem(iy);return Tw(r)?r:Y0}catch{return Y0}}function ay(r){document.documentElement.dataset.theme=r}function Nw(r){try{localStorage.setItem(iy,r)}catch{}ay(r)}function Cw({onToggleEventFeed:r,onToggleDocs:n}){const{user:s,logout:a}=Oi(),{isBuilder:o,isOps:f}=Wg(),{available:h,mine:m}=jw(),{connected:g}=v_(),{toggleAIOverride:y}=ww(),[E,w]=O.useState(!1),[T,q]=O.useState(ry),M=O.useRef(null),R=G=>{Nw(G),q(G)};return O.useEffect(()=>{if(!E)return;const G=ne=>{M.current&&!M.current.contains(ne.target)&&w(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[E]),d.jsxs("header",{className:"h-14 shrink-0 border-b border-surface-border bg-surface-raised flex items-center justify-between px-5 relative z-30",children:[d.jsx("div",{className:"flex items-center gap-4",children:d.jsx(yr,{to:"/","aria-label":"Home",onClick:G=>{(G.ctrlKey||G.metaKey)&&(G.preventDefault(),y())},children:d.jsx(dh,{})})}),d.jsxs("div",{className:"flex items-center gap-5",children:[d.jsxs(yr,{to:"/escalations/available",className:`flex items-center gap-1.5 text-[11px] transition-colors ${h>0?"text-status-active hover:text-status-active/80":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[d.jsx(Ef,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"all",h>0&&d.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:h})]}),d.jsxs(yr,{to:"/escalations/queue",className:`flex items-center gap-1.5 text-[11px] transition-colors ${m>0?"text-status-warning hover:text-status-warning/80":"text-text-quaternary hover:text-text-secondary"}`,title:"My escalation queue",children:[d.jsx(Ef,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"mine",m>0&&d.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:m})]}),(o||f)&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"w-px h-4 bg-surface-border"}),d.jsxs("button",{type:"button",onClick:()=>{g?r==null||r():window.location.reload()},className:`flex items-center gap-1.5 text-[11px] transition-colors ${g?"text-status-success hover:text-status-success/80":"text-text-quaternary hover:text-text-secondary"}`,title:g?"Live events — click to toggle feed":"Events disconnected — click to reconnect",children:[d.jsx(pg,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"events"]})]}),o&&d.jsx(d.Fragment,{children:d.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 text-[11px] text-text-quaternary hover:text-text-secondary transition-colors",title:"Documentation",children:[d.jsx(gg,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"docs"]})}),d.jsx("div",{className:"w-px h-4 bg-surface-border"}),s&&d.jsxs("div",{className:"relative",ref:M,children:[d.jsxs("button",{onClick:()=>w(G=>!G),className:"btn-ghost text-xs flex items-center gap-1",children:[d.jsx(Ux,{className:"w-3.5 h-3.5 text-accent/75",strokeWidth:1.5}),s.displayName||s.username||s.userId,d.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),E&&d.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-50",children:[d.jsx(yr,{to:"/credentials",onClick:()=>w(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),d.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[d.jsx("p",{className:"text-[10px] font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Theme"}),d.jsx("div",{className:"flex items-center gap-2",children:sy.map(G=>d.jsx("button",{type:"button",onClick:()=>R(G),title:G0[G],"aria-label":`${G0[G]} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${T===G?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:Ow[G]}},G))})]}),d.jsx("button",{onClick:()=>{w(!1),a()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Sign Out"})]})]})]})]})}function mh({open:r,children:n}){const[s,a]=O.useState(r);return O.useEffect(()=>{r&&a(!0)},[r]),d.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-out ${r?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,onTransitionEnd:()=>{r||a(!1)},children:d.jsx("div",{className:"overflow-hidden",children:s?n:null})})}function Xf(r){return({isActive:n})=>{const s="flex items-center rounded-md transition-colors duration-150",a="bg-surface-hover text-text-primary font-medium",o="text-text-secondary hover:text-text-primary hover:bg-surface-hover";return r?`${s} justify-center w-10 h-10 mx-auto ${n?a:o}`:`${s} gap-3 px-4 py-2 text-sm ${n?a:o}`}}function kw(){return({isActive:r})=>`flex items-center gap-3 pl-11 pr-4 py-1.5 text-xs rounded-md transition-colors duration-150 ${r?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary"}`}function Mw({group:r,collapsed:n}){const{pathname:s}=ei(),a=r.matchPaths.some(m=>s.startsWith(m)),[o,f]=O.useState(a),h=o||a;return n?d.jsx(d.Fragment,{children:r.items.map(m=>d.jsx(Co,{to:m.to,className:Xf(!0),title:m.label,children:m.icon&&d.jsx(m.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},m.to))}):d.jsxs("div",{children:[d.jsxs("button",{onClick:()=>f(m=>!m),className:"w-full flex items-center justify-between px-4 py-2 text-sm rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",children:[d.jsxs("span",{className:"flex items-center gap-3",children:[r.icon&&d.jsx(r.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),d.jsx("span",{children:r.label})]}),d.jsx("svg",{className:`w-3.5 h-3.5 text-text-tertiary transition-transform duration-150 ${h?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),d.jsx(mh,{open:h,children:r.items.map(m=>d.jsxs(Co,{to:m.to,end:m.end,className:kw(),children:[m.icon&&d.jsx(m.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),d.jsx("span",{children:m.label})]},m.to))})]})}function Rw(r){return r.kind==="group"}function Dw({entry:r,collapsed:n}){const{pathname:s,search:a}=ei();if(r.to.includes("?")){const[f,h]=r.to.split("?"),m=s===f&&a===`?${h}`,g=Xf(n)({isActive:m});return d.jsxs(Co,{to:r.to,className:g,title:n?r.label:void 0,children:[r.icon&&d.jsx(r.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),!n&&d.jsx("span",{children:r.label})]})}return d.jsxs(Co,{to:r.to,end:r.end,className:Xf(n),title:n?r.label:void 0,children:[r.icon&&d.jsx(r.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),!n&&d.jsx("span",{children:r.label})]})}function Ks({heading:r,entries:n}){const{collapsed:s}=ty();return d.jsxs("div",{className:"space-y-1",children:[s?d.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:r}):d.jsx("p",{className:"px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-accent/80",children:r}),n.map(a=>Rw(a)?d.jsx(Mw,{group:a,collapsed:s},a.label):d.jsx(Dw,{entry:a,collapsed:s},a.to))]})}function zw({aiEnabled:r=!1,isBuilder:n=!1,isOps:s=!1}){if(!n&&!s){const o=[{to:"/escalations/queue",label:"My Queue",icon:Ef},{to:"/escalations/available",label:"All",icon:Af}];return d.jsx(Ks,{heading:"Work",entries:o})}if(!n)return d.jsx(Ks,{heading:"React",entries:[{to:"/operations",label:"Pace Board",icon:s0}]});const a=[...s||n?[{to:"/operations",label:"Pace Board",icon:s0}]:[],{to:"/topics",label:"Event Topics",icon:pg},{to:"/agents",label:r?"Agents":"Automations",icon:Bx},{to:"/capabilities",label:"Capabilities",icon:Lx}];return d.jsx(Ks,{heading:"React",entries:a})}function qw(){const r=[{kind:"group",label:"Procedural",icon:Hx,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:[{to:"/workflows/registry",label:"Registry",icon:i0},{to:"/workflows/durable/invoke",label:"Invoke",icon:r0},{to:"/workflows/executions",label:"Executions",icon:Af}]},{kind:"group",label:"Graph",icon:Kf,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:i0,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:r0},{to:"/mcp/executions",label:"Executions",icon:Af}]}];return d.jsx(Ks,{heading:"Orchestrate",entries:r})}const Uw=[{to:"/mcp/queries",label:"Designer",icon:Px},{to:"/mcp/servers",label:"Servers & Tools",icon:$x}];function Bw(){return d.jsx(Ks,{heading:"Design",entries:Uw})}const Lw=[{to:"/files",label:"Files",icon:Yx},{to:"/knowledge",label:"Knowledge",icon:Gx}];function Hw(){return d.jsx(Ks,{heading:"Storage",entries:Lw})}function Pw({isBuilder:r=!1,isOps:n=!1}){var h;const{data:s}=Qo(),a=((h=s==null?void 0:s.features)==null?void 0:h.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:Vx},...r||n?[{to:"/admin/roles",label:"Roles",icon:Fx}]:[]],f=[{to:"/admin/controlplane",label:"Routers",icon:Jx},{to:"/admin/streams",label:"Messages",icon:Ix},...a?[{to:"/admin/maintenance",label:"DB Maintenance",icon:Qx}]:[]];return d.jsxs(d.Fragment,{children:[d.jsx(Ks,{heading:"Identity & Access",entries:o}),r&&d.jsx(Ks,{heading:"Infrastructure",entries:f})]})}const ly="lt_event_feed_patterns";function $w(r){if(r.startsWith("/topics/")){const f=decodeURIComponent(r.replace("/topics/",""));if(f&&!f.includes("/"))return`lt.events.${f}`}const n=r.match(/^\/escalations\/detail\/(.+)/);if(n)return`lt.events.system.escalation.${n[1]}.>`;if(r.startsWith("/escalations"))return"lt.events.system.escalation.>";const s=r.match(/^\/workflows\/(?:durable\/)?executions\/(.+)/);if(s)return`lt.events.system.workflow.${s[1]}.>`;if(r.startsWith("/workflows"))return"lt.events.system.workflow.>";const a=r.match(/^\/agents\/([^/]+)$/);if(a&&a[1]!=="new")return`lt.events.system.agent.${a[1]}.>`;if(r.startsWith("/agents"))return"lt.events.system.agent.>";if(r.startsWith("/knowledge"))return"lt.events.system.knowledge.>";if(r.startsWith("/files"))return"lt.events.system.file.>";if(r==="/")return"lt.events.system.>";const o=r.match(/^\/mcp\/executions\/(.+)/);return o?`lt.events.system.*.${o[1]}.>`:(r.startsWith("/mcp"),"lt.events.system.>")}function Yw(){try{const r=localStorage.getItem(ly);return r?JSON.parse(r):[]}catch{return[]}}function _f(r){try{localStorage.setItem(ly,JSON.stringify(r))}catch{}}function Gw(){const{pathname:r}=ei(),[n,s]=O.useState(Yw),a=O.useMemo(()=>$w(r),[r]),o=O.useMemo(()=>{const g=new Set([a,...n]);return Array.from(g)},[a,n]),f=O.useCallback(g=>{const y=g.startsWith("lt.events.")?g:`lt.events.${g}`;s(E=>{if(E.includes(y))return E;const w=[...E,y];return _f(w),w})},[]),h=O.useCallback(g=>{s(y=>{const E=y.filter(w=>w!==g);return _f(E),E})},[]),m=O.useCallback(()=>{s([]),_f([])},[]);return{patterns:o,pagePattern:a,userPatterns:n,addPattern:f,removePattern:h,clearUserPatterns:m}}function Vw({children:r,className:n=""}){return d.jsx("p",{className:`text-[10px] font-semibold uppercase tracking-widest text-text-tertiary ${n}`,children:r})}const wf=280,V0="cubic-bezier(0.4, 0, 0.2, 1)",wo=40;function Fw(r){if(!r)return"scale(0.92)";const n=window.innerWidth,s=window.innerHeight,a=n-wo*2,o=s-wo*2,f=r.width/a,h=r.height/o,m=r.left+r.width/2-(wo+a/2),g=r.top+r.height/2-(wo+o/2);return`translate(${m}px, ${g}px) scale(${f}, ${h})`}function oy({open:r,onClose:n,sourceRef:s,children:a}){const[o,f]=O.useState(null),h=O.useRef(null),m=O.useRef(!1);O.useEffect(()=>{var T,q;r&&!m.current?(h.current=((T=s==null?void 0:s.current)==null?void 0:T.getBoundingClientRect())??null,f("entering")):!r&&m.current&&o==="open"&&(h.current=((q=s==null?void 0:s.current)==null?void 0:q.getBoundingClientRect())??null,f("exiting")),m.current=r},[r,s,o]),O.useEffect(()=>{if(o!=="entering")return;const T=requestAnimationFrame(()=>{requestAnimationFrame(()=>f("open"))});return()=>cancelAnimationFrame(T)},[o]),O.useEffect(()=>{if(o)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o]),O.useEffect(()=>{if(!o)return;const T=q=>{q.key==="Escape"&&n()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[o,n]);const g=O.useCallback(T=>{T.propertyName==="transform"&&o==="exiting"&&f(null)},[o]);if(O.useEffect(()=>{if(o!=="exiting")return;const T=setTimeout(()=>f(null),wf+50);return()=>clearTimeout(T)},[o]),!o)return null;const y=o==="entering"||o==="exiting",E=y?Fw(h.current):"none",w=y?0:1;return dg.createPortal(d.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${wf}ms ${V0}, opacity ${wf}ms ${V0}`,transform:E,opacity:w,backgroundColor:"#FFFFFF"},onTransitionEnd:g,children:a}),document.body)}function Jw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h8M4 18h12"})})}function Iw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7l-5 5 5 5M16 7l5 5-5 5"})})}function Qw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3"})})}function Xw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}function Kw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 9V4.5M9 9H4.5M9 9L3.5 3.5M9 15v4.5M9 15H4.5M9 15l-5.5 5.5M15 9h4.5M15 9V4.5M15 9l5.5-5.5M15 15h4.5M15 15v4.5m0-4.5l5.5 5.5"})})}function Zw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}function Ww(r){const n=r.trim().split(`
53
+ ${m.stack}`),h.reject(y)):h.resolve(E))}});return g.requestSubject=n,this.protocol.publish(n,s,{reply:f,headers:a.headers}),h}else{const f=new Og(this.protocol.muxSubscriptions,n,a,o);this.protocol.request(f);try{this.publish(n,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${f.token}`,headers:a.headers})}catch(m){f.cancel(m)}const h=Promise.race([f.timer,f.deferred]);return h.catch(()=>{f.cancel()}),h}}flush(){return this.isClosed()?Promise.reject(ue.errorForCode(ie.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(ue.errorForCode(ie.ConnectionClosed)):this.isDraining()?Promise.reject(ue.errorForCode(ie.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const n=this.protocol.getServer();return n?n.listen:""}status(){const n=new _t;return n.iterClosed.then(()=>{const s=this.listeners.indexOf(n);this.listeners.splice(s,1)}),this.listeners.push(n),n}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request("$SYS.REQ.USER.INFO")).json((s,a)=>s==="time"?new Date(Date.parse(a)):a)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(n={}){const s=new Z1(this,n);if(n.checkAPI!==!1)try{await s.getAccountInfo()}catch(a){const o=a;throw o.code===ie.NoResponders&&(o.code=ie.JetStreamNotEnabled),o}return s}jetstream(n={}){return new ah(this,n)}getServerVersion(){const n=this.info;return n?ji(n.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw ue.errorForCode(ie.Disconnect);const n=Date.now();return await this.flush(),Date.now()-n}get features(){return this.protocol.features}get services(){return this._services||(this._services=new n_(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(ue.errorForCode(ie.ConnectionClosed)):this.isDraining()?Promise.reject(ue.errorForCode(ie.ConnectionDraining)):this.protocol.reconnect()}}class n_{constructor(n){v(this,"nc");this.nc=n}add(n){try{return new Va(this.nc,n).start()}catch(s){return Promise.reject(s)}}client(n,s){return new z1(this.nc,n,s)}}class s_{constructor(n,s,a){v(this,"bucket");v(this,"sm");v(this,"prefixLen");this.bucket=n,this.prefixLen=s,this.sm=a}get key(){return this.sm.subject.substring(this.prefixLen)}get value(){return this.sm.data}get delta(){return 0}get created(){return this.sm.time}get revision(){return this.sm.seq}get operation(){return this.sm.header.get(Bo)||"PUT"}get length(){const n=this.sm.header.get(Dt.MessageSizeHdr)||"";return n!==""?parseInt(n,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class i_{constructor(n,s,a){v(this,"bucket");v(this,"key");v(this,"sm");this.bucket=n,this.key=s,this.sm=a}get value(){return this.sm.data}get created(){return new Date(th(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var n;return((n=this.sm.headers)==null?void 0:n.get(Bo))||"PUT"}get delta(){return this.sm.info.pending}get length(){var s;const n=((s=this.sm.headers)==null?void 0:s.get(Dt.MessageSizeHdr))||"";return n!==""?parseInt(n,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Ug extends Jv{constructor(s,a,o){super(s.nc,a,o);v(this,"js");v(this,"monitor");this.js=s,this.monitor=null,this.sub.closed.then(()=>{this.monitor&&this.monitor.cancel()})}set info(s){this.sub.info=s}get info(){return this.sub.info}_resetOrderedConsumer(s){if(this.info===null||this.sub.isClosed())return;const a=fs(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,a);const f=this.info;f.config.name=Zs.next(),f.ordered_consumer_sequence.delivery_seq=0,f.flow_control.heartbeat_count=0,f.flow_control.fc_count=0,f.flow_control.consumer_restarts++,f.deliver=a,f.config.deliver_subject=a,f.config.deliver_policy=ft.StartSequence,f.config.opt_start_seq=s;const h={};h.stream_name=this.info.stream,h.config=f.config;const m=`${f.api.prefix}.CONSUMER.CREATE.${f.stream}`;this.js._request(m,h,{retries:-1}).then(g=>{const y=g,E=this.sub.info;E.last=y,this.info.config=y.config,this.info.name=y.name}).catch(g=>{const y=new ue(`unable to recreate ordered consumer ${f.stream} at seq ${s}`,ie.RequestError,g);this.sub.callback(y,{})})}_maybeSetupHbMonitoring(){var a,o;const s=((o=(a=this.info)==null?void 0:a.config)==null?void 0:o.idle_heartbeat)||0;s&&this._setupHbMonitoring(th(s))}_setupHbMonitoring(s,a=0){const o={cancelAfter:0,maxOut:2};a&&(o.cancelAfter=a);const f=this.sub,h=m=>{var E,w,T,q;const g=Ov(409,`${xn.IdleHeartbeatMissed}: ${m}`,this.sub.subject);if(!((E=this.info)==null?void 0:E.ordered))this.sub.callback(null,g);else{if(!this.js.nc.protocol.connected)return!1;const M=((T=(w=this.info)==null?void 0:w.ordered_consumer_sequence)==null?void 0:T.stream_seq)||0;return this._resetOrderedConsumer(M+1),(q=this.monitor)==null||q.restart(),!1}return!f.noIterator};this.monitor=new sh(s,h,o)}_checkHbOrderConsumer(s){const a=s.headers.get(Dt.ConsumerStalledHdr);a!==""&&this.js.nc.publish(a);const o=parseInt(s.headers.get(Dt.LastConsumerSeqHdr),10),f=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,o!==f.delivery_seq&&this._resetOrderedConsumer(f.stream_seq+1),!1}_checkOrderedConsumer(s){const a=this.info.ordered_consumer_sequence,o=s.info.streamSequence,f=s.info.deliverySequence;return f!=a.delivery_seq+1?(this._resetOrderedConsumer(a.stream_seq+1),!1):(a.delivery_seq=f,a.stream_seq=o,!0)}async destroy(){this.isClosed()||await this.drain();const s=this.sub.info,a=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.DELETE.${s.stream}.${a}`;await s.api._request(o)}async consumerInfo(){const s=this.sub.info,a=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.INFO.${s.stream}.${a}`,f=await s.api._request(o);return s.last=f,f}}class r_ extends Ug{constructor(n,s,a){super(n,s,a)}pull(n={batch:1}){const{stream:s,config:a,name:o}=this.sub.info,f=a.durable_name??o,h={};if(h.batch=n.batch||1,h.no_wait=n.no_wait||!1,(n.max_bytes??0)>0){const y=this.js.nc.features.get(Ue.JS_PULL_MAX_BYTES);if(!y.ok)throw new Error(`max_bytes is only supported on servers ${y.min} or better`);h.max_bytes=n.max_bytes}let m=0;n.expires&&n.expires>0&&(m=n.expires,h.expires=nt(m));let g=0;if(n.idle_heartbeat&&n.idle_heartbeat>0&&(g=n.idle_heartbeat,h.idle_heartbeat=nt(g)),g&&m===0)throw new Error("idle_heartbeat requires expires");if(g>m)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),m&&g&&(this.monitor?this.monitor._change(g,m):this._setupHbMonitoring(g,m));const y=this.info.api,E=`${y.prefix}.CONSUMER.MSG.NEXT.${s}.${f}`,w=this.sub.subject;y.nc.publish(E,y.jc.encode(h),{reply:w})}}}function a_(r,n){return r?o_(n):l_(n)}function l_(r){return(n,s)=>n?[n,null]:(n=wr(s),n?[n,null]:[null,$a(s,r)])}function o_(r){return(n,s)=>{if(n)return[n,null];const a=wr(s);return a!==null?[Bg(a),null]:[null,$a(s,r)]}}function Bg(r){if(r!==null)switch(r.code){case ie.JetStream404NoMessages:case ie.JetStream408RequestTimeout:return null;case ie.JetStream409:return Tv(r)?r:null;default:return r}return null}function c_(r){r&&r.ack()}function u_(r){const n=r.split(".");if(n.length===9&&n.splice(2,0,"_",""),n.length<11||n[0]!=="$JS"||n[1]!=="ACK")throw new Error("not js message");const s={};return s.domain=n[2]==="_"?"":n[2],s.account_hash=n[3],s.stream=n[4],s.consumer=n[5],s.deliveryCount=parseInt(n[6],10),s.redeliveryCount=s.deliveryCount,s.redelivered=s.deliveryCount>1,s.streamSequence=parseInt(n[7],10),s.deliverySequence=parseInt(n[8],10),s.timestampNanos=parseInt(n[9],10),s.pending=parseInt(n[10],10),s}class f_{constructor(n,s){v(this,"msg");v(this,"di");v(this,"didAck");v(this,"timeout");this.msg=n,this.didAck=!1,this.timeout=s}get subject(){return this.msg.subject}get sid(){return this.msg.sid}get data(){return this.msg.data}get headers(){return this.msg.headers}get info(){return this.di||(this.di=u_(this.reply)),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(n){this.didAck||(this.didAck=!this.isWIP(n),this.msg.respond(n))}isWIP(n){return n.length===4&&n[0]===ja[0]&&n[1]===ja[1]&&n[2]===ja[2]&&n[3]===ja[3]}async ackAck(n){var a;n=n||{},n.timeout=n.timeout||this.timeout;const s=st();if(this.didAck)s.resolve(!1);else if(this.didAck=!0,this.msg.reply){const f=this.msg.publisher,h=!((a=f.options)!=null&&a.noAsyncTraces),m=new Og(f.muxSubscriptions,this.msg.reply,{timeout:n.timeout},h);f.request(m);try{f.publish(this.msg.reply,z0,{reply:`${f.muxSubscriptions.baseInbox}${m.token}`})}catch(g){m.cancel(g)}try{await Promise.race([m.timer,m.deferred]),s.resolve(!0)}catch(g){m.cancel(g),s.reject(g)}}else s.resolve(!1);return s}ack(){this.doAck(z0)}nak(n){let s=V1;n&&(s=Tf().encode(`-NAK ${JSON.stringify({delay:nt(n)})}`)),this.doAck(s)}working(){this.doAck(ja)}next(n,s={batch:1}){const a={};a.batch=s.batch||1,a.no_wait=s.no_wait||!1,s.expires&&s.expires>0&&(a.expires=nt(s.expires));const o=Mn().encode(a),f=Or.concat(F1,I1,o),h=n?{reply:n}:void 0;this.msg.respond(f,h)}term(n=""){let s=J1;(n==null?void 0:n.length)>0&&(s=Tf().encode(`+TERM ${n}`)),this.doAck(s)}json(){return this.msg.json()}string(){return this.msg.string()}}const h_="1.30.3",d_="nats.ws";class m_{constructor(){v(this,"version");v(this,"lang");v(this,"closeError");v(this,"connected");v(this,"done");v(this,"socket");v(this,"options");v(this,"socketClosed");v(this,"encrypted");v(this,"peeked");v(this,"yields");v(this,"signal");v(this,"closedNotification");this.version=h_,this.lang=d_,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=st(),this.closedNotification=st()}async connect(n,s){const a=st();if(s.tls)return a.reject(new ue("tls",ie.InvalidOption)),a;this.options=s;const o=n.src;if(s.wsFactory){const{socket:f,encrypted:h}=await s.wsFactory(n.src,s);this.socket=f,this.encrypted=h}else this.encrypted=o.indexOf("wss://")===0,this.socket=new WebSocket(o);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.isDiscarded()},this.socket.onmessage=f=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(f.data)),this.peeked){this.signal.resolve();return}const h=Or.concat(...this.yields),m=Wv(h);if(m!==""){const g=O1.exec(m);if(!g){s.debug&&console.error("!!!",go(h)),a.reject(new Error("unexpected response from server"));return}try{const y=JSON.parse(g[1]);A1(y,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),a.resolve()}catch(y){a.reject(y);return}}},this.socket.onclose=f=>{if(this.isDiscarded())return;this.socketClosed=!0;let h;this.done||(f.wasClean||(h=new Error(f.reason)),this._closed(h))},this.socket.onerror=f=>{if(this.isDiscarded())return;const h=f,m=new ue(h.message,ie.Unknown,new Error(h.error));a.reject(m)},a}disconnect(){this._closed(void 0,!0)}async _closed(n,s=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=n,!n)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await Tr(100);this.done=!0;try{this.socket.close(n?1002:1e3,n?n.message:void 0)}catch{}s&&this.closedNotification.resolve(n)}}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.isDiscarded())return;this.yields.length===0&&await this.signal;const n=this.yields;this.yields=[];for(let s=0;s<n.length;s++)this.options.debug&&console.info(`> ${go(n[s])}`),yield n[s];if(this.done)break;this.yields.length===0&&(n.length=0,this.yields=n,this.signal=st())}}isEncrypted(){return this.connected&&this.encrypted}send(n){if(!this.isDiscarded())try{this.socket.send(n.buffer),this.options.debug&&console.info(`< ${go(n)}`);return}catch(s){this.options.debug&&console.error(`!!! ${go(n)}: ${s}`)}}close(n){return this._closed(n,!1)}closed(){return this.closedNotification}isDiscarded(){return this.done?(this.discard(),!0):!1}discard(){var n;this.done=!0;try{(n=this.socket)==null||n.close()}catch{}}}function p_(r,n){/^(.*:\/\/)(.*)/.test(r)||(typeof n=="boolean"?r=`${n===!0?"https":"http"}://${r}`:r=`https://${r}`);let a=new URL(r);const o=a.protocol.toLowerCase();o==="ws:"&&(n=!1),o==="wss:"&&(n=!0),o!=="https:"&&o!=="http"&&(r=r.replace(/^(.*:\/\/)(.*)/gm,"$2"),a=new URL(`http://${r}`));let f,h;const m=a.hostname,g=a.pathname,y=a.search||"";switch(o){case"http:":case"ws:":case"nats:":h=a.port||"80",f="ws:";break;case"https:":case"wss:":case"tls:":h=a.port||"443",f="wss:";break;default:h=a.port||n===!0?"443":"80",f=n===!0?"wss:":"ws:";break}return`${f}//${m}:${h}${g}${y}`}function g_(r={}){return Iv({defaultPort:443,urlParseFn:p_,factory:()=>new m_}),lh.connect(r)}const y_=null,b_=null,x_="lt.events";function Lg(r,n){const s=r.split("."),a=n.split(".");for(let o=0;o<a.length;o++){const f=a[o];if(f===">")return!0;if(o>=s.length||f!=="*"&&f!==s[o])return!1}return s.length===a.length}const Fa=O.createContext({connected:!1,subscribe:()=>()=>{}});function v_(){const{connected:r}=O.useContext(Fa);return{connected:r}}function __(r,n){const{subscribe:s}=O.useContext(Fa),a=O.useRef(n);a.current=n,O.useEffect(()=>s(r,f=>a.current(f)),[s,r])}const w_=O.createContext({connected:!1,subscribe:()=>()=>{}}),S_=Tf();function E_({children:r,url:n,token:s}){const a=O.useRef(null),o=O.useRef(null),[f,h]=O.useState(!1),m=O.useRef(null),g=O.useRef(new Map),y=O.useCallback((T,q)=>{const M=g.current;return M.has(T)||M.set(T,new Set),M.get(T).add(q),()=>{const R=M.get(T);R&&(R.delete(q),R.size===0&&M.delete(T))}},[]),E=O.useCallback((T,q)=>{for(const[M,R]of g.current)if(Lg(T,M))for(const G of R)try{G(q)}catch{}},[]),w=O.useCallback(async()=>{try{if(a.current)return;const T=n||y_;if(!T){console.error("[lt-nats] no NATS WebSocket URL configured — set NATS_WS_URL on the server");return}const q=await g_({servers:T,token:s||b_||void 0,reconnect:!0,maxReconnectAttempts:-1,reconnectTimeWait:2e3});a.current=q,h(!0);const M=q.subscribe("lt.>");o.current=M,(async()=>{for await(const R of M)try{const G=JSON.parse(S_.decode(R.data));E(R.subject,G)}catch{}})(),(async()=>{for await(const R of q.status())R.type==="disconnect"||R.type==="error"?h(!1):R.type==="reconnect"&&h(!0)})()}catch{h(!1),m.current=setTimeout(w,3e3)}},[E]);return O.useEffect(()=>(w(),()=>{m.current&&clearTimeout(m.current),o.current&&o.current.unsubscribe(),a.current&&(a.current.close().catch(()=>{}),a.current=null),h(!1)}),[w]),d.jsx(w_.Provider,{value:{connected:f,subscribe:y},children:d.jsx(Fa.Provider,{value:{connected:f,subscribe:y},children:r})})}const $n=Object.create(null);$n.open="0";$n.close="1";$n.ping="2";$n.pong="3";$n.message="4";$n.upgrade="5";$n.noop="6";const jo=Object.create(null);Object.keys($n).forEach(r=>{jo[$n[r]]=r});const $f={type:"error",data:"parser error"},Hg=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Pg=typeof ArrayBuffer=="function",$g=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,oh=({type:r,data:n},s,a)=>Hg&&n instanceof Blob?s?a(n):U0(n,a):Pg&&(n instanceof ArrayBuffer||$g(n))?s?a(n):U0(new Blob([n]),a):a($n[r]+(n||"")),U0=(r,n)=>{const s=new FileReader;return s.onload=function(){const a=s.result.split(",")[1];n("b"+(a||""))},s.readAsDataURL(r)};function B0(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}let bf;function A_(r,n){if(Hg&&r.data instanceof Blob)return r.data.arrayBuffer().then(B0).then(n);if(Pg&&(r.data instanceof ArrayBuffer||$g(r.data)))return n(B0(r.data));oh(r,!1,s=>{bf||(bf=new TextEncoder),n(bf.encode(s))})}const L0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ra=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let r=0;r<L0.length;r++)Ra[L0.charCodeAt(r)]=r;const j_=r=>{let n=r.length*.75,s=r.length,a,o=0,f,h,m,g;r[r.length-1]==="="&&(n--,r[r.length-2]==="="&&n--);const y=new ArrayBuffer(n),E=new Uint8Array(y);for(a=0;a<s;a+=4)f=Ra[r.charCodeAt(a)],h=Ra[r.charCodeAt(a+1)],m=Ra[r.charCodeAt(a+2)],g=Ra[r.charCodeAt(a+3)],E[o++]=f<<2|h>>4,E[o++]=(h&15)<<4|m>>2,E[o++]=(m&3)<<6|g&63;return y},O_=typeof ArrayBuffer=="function",ch=(r,n)=>{if(typeof r!="string")return{type:"message",data:Yg(r,n)};const s=r.charAt(0);return s==="b"?{type:"message",data:T_(r.substring(1),n)}:jo[s]?r.length>1?{type:jo[s],data:r.substring(1)}:{type:jo[s]}:$f},T_=(r,n)=>{if(O_){const s=j_(r);return Yg(s,n)}else return{base64:!0,data:r}},Yg=(r,n)=>{switch(n){case"blob":return r instanceof Blob?r:new Blob([r]);case"arraybuffer":default:return r instanceof ArrayBuffer?r:r.buffer}},Gg="",N_=(r,n)=>{const s=r.length,a=new Array(s);let o=0;r.forEach((f,h)=>{oh(f,!1,m=>{a[h]=m,++o===s&&n(a.join(Gg))})})},C_=(r,n)=>{const s=r.split(Gg),a=[];for(let o=0;o<s.length;o++){const f=ch(s[o],n);if(a.push(f),f.type==="error")break}return a};function k_(){return new TransformStream({transform(r,n){A_(r,s=>{const a=s.length;let o;if(a<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,a);else if(a<65536){o=new Uint8Array(3);const f=new DataView(o.buffer);f.setUint8(0,126),f.setUint16(1,a)}else{o=new Uint8Array(9);const f=new DataView(o.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(a))}r.data&&typeof r.data!="string"&&(o[0]|=128),n.enqueue(o),n.enqueue(s)})}})}let xf;function vo(r){return r.reduce((n,s)=>n+s.length,0)}function _o(r,n){if(r[0].length===n)return r.shift();const s=new Uint8Array(n);let a=0;for(let o=0;o<n;o++)s[o]=r[0][a++],a===r[0].length&&(r.shift(),a=0);return r.length&&a<r[0].length&&(r[0]=r[0].slice(a)),s}function M_(r,n){xf||(xf=new TextDecoder);const s=[];let a=0,o=-1,f=!1;return new TransformStream({transform(h,m){for(s.push(h);;){if(a===0){if(vo(s)<1)break;const g=_o(s,1);f=(g[0]&128)===128,o=g[0]&127,o<126?a=3:o===126?a=1:a=2}else if(a===1){if(vo(s)<2)break;const g=_o(s,2);o=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),a=3}else if(a===2){if(vo(s)<8)break;const g=_o(s,8),y=new DataView(g.buffer,g.byteOffset,g.length),E=y.getUint32(0);if(E>Math.pow(2,21)-1){m.enqueue($f);break}o=E*Math.pow(2,32)+y.getUint32(4),a=3}else{if(vo(s)<o)break;const g=_o(s,o);m.enqueue(ch(f?g:xf.decode(g),n)),a=0}if(o===0||o>r){m.enqueue($f);break}}}})}const Vg=4;function gt(r){if(r)return R_(r)}function R_(r){for(var n in gt.prototype)r[n]=gt.prototype[n];return r}gt.prototype.on=gt.prototype.addEventListener=function(r,n){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(n),this};gt.prototype.once=function(r,n){function s(){this.off(r,s),n.apply(this,arguments)}return s.fn=n,this.on(r,s),this};gt.prototype.off=gt.prototype.removeListener=gt.prototype.removeAllListeners=gt.prototype.removeEventListener=function(r,n){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+r];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var a,o=0;o<s.length;o++)if(a=s[o],a===n||a.fn===n){s.splice(o,1);break}return s.length===0&&delete this._callbacks["$"+r],this};gt.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var n=new Array(arguments.length-1),s=this._callbacks["$"+r],a=1;a<arguments.length;a++)n[a-1]=arguments[a];if(s){s=s.slice(0);for(var a=0,o=s.length;a<o;++a)s[a].apply(this,n)}return this};gt.prototype.emitReserved=gt.prototype.emit;gt.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};gt.prototype.hasListeners=function(r){return!!this.listeners(r).length};const Jo=typeof Promise=="function"&&typeof Promise.resolve=="function"?n=>Promise.resolve().then(n):(n,s)=>s(n,0),vn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),D_="arraybuffer";function Fg(r,...n){return n.reduce((s,a)=>(r.hasOwnProperty(a)&&(s[a]=r[a]),s),{})}const z_=vn.setTimeout,q_=vn.clearTimeout;function Io(r,n){n.useNativeTimers?(r.setTimeoutFn=z_.bind(vn),r.clearTimeoutFn=q_.bind(vn)):(r.setTimeoutFn=vn.setTimeout.bind(vn),r.clearTimeoutFn=vn.clearTimeout.bind(vn))}const U_=1.33;function B_(r){return typeof r=="string"?L_(r):Math.ceil((r.byteLength||r.size)*U_)}function L_(r){let n=0,s=0;for(let a=0,o=r.length;a<o;a++)n=r.charCodeAt(a),n<128?s+=1:n<2048?s+=2:n<55296||n>=57344?s+=3:(a++,s+=4);return s}function Jg(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function H_(r){let n="";for(let s in r)r.hasOwnProperty(s)&&(n.length&&(n+="&"),n+=encodeURIComponent(s)+"="+encodeURIComponent(r[s]));return n}function P_(r){let n={},s=r.split("&");for(let a=0,o=s.length;a<o;a++){let f=s[a].split("=");n[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return n}class $_ extends Error{constructor(n,s,a){super(n),this.description=s,this.context=a,this.type="TransportError"}}class uh extends gt{constructor(n){super(),this.writable=!1,Io(this,n),this.opts=n,this.query=n.query,this.socket=n.socket,this.supportsBinary=!n.forceBase64}onError(n,s,a){return super.emitReserved("error",new $_(n,s,a)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(n){this.readyState==="open"&&this.write(n)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(n){const s=ch(n,this.socket.binaryType);this.onPacket(s)}onPacket(n){super.emitReserved("packet",n)}onClose(n){this.readyState="closed",super.emitReserved("close",n)}pause(n){}createUri(n,s={}){return n+"://"+this._hostname()+this._port()+this.opts.path+this._query(s)}_hostname(){const n=this.opts.hostname;return n.indexOf(":")===-1?n:"["+n+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(n){const s=H_(n);return s.length?"?"+s:""}}class Y_ extends uh{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(n){this.readyState="pausing";const s=()=>{this.readyState="paused",n()};if(this._polling||!this.writable){let a=0;this._polling&&(a++,this.once("pollComplete",function(){--a||s()})),this.writable||(a++,this.once("drain",function(){--a||s()}))}else s()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(n){const s=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};C_(n,this.socket.binaryType).forEach(s),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const n=()=>{this.write([{type:"close"}])};this.readyState==="open"?n():this.once("open",n)}write(n){this.writable=!1,N_(n,s=>{this.doWrite(s,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const n=this.opts.secure?"https":"http",s=this.query||{};return this.opts.timestampRequests!==!1&&(s[this.opts.timestampParam]=Jg()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(n,s)}}let Ig=!1;try{Ig=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const G_=Ig;function V_(){}class F_ extends Y_{constructor(n){if(super(n),typeof location<"u"){const s=location.protocol==="https:";let a=location.port;a||(a=s?"443":"80"),this.xd=typeof location<"u"&&n.hostname!==location.hostname||a!==n.port}}doWrite(n,s){const a=this.request({method:"POST",data:n});a.on("success",s),a.on("error",(o,f)=>{this.onError("xhr post error",o,f)})}doPoll(){const n=this.request();n.on("data",this.onData.bind(this)),n.on("error",(s,a)=>{this.onError("xhr poll error",s,a)}),this.pollXhr=n}}class Pn extends gt{constructor(n,s,a){super(),this.createRequest=n,Io(this,a),this._opts=a,this._method=a.method||"GET",this._uri=s,this._data=a.data!==void 0?a.data:null,this._create()}_create(){var n;const s=Fg(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;const a=this._xhr=this.createRequest(s);try{a.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&a.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{a.setRequestHeader("Accept","*/*")}catch{}(n=this._opts.cookieJar)===null||n===void 0||n.addCookies(a),"withCredentials"in a&&(a.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(a.timeout=this._opts.requestTimeout),a.onreadystatechange=()=>{var o;a.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(a.getResponseHeader("set-cookie"))),a.readyState===4&&(a.status===200||a.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof a.status=="number"?a.status:0)},0))},a.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=Pn.requestsCount++,Pn.requests[this._index]=this)}_onError(n){this.emitReserved("error",n,this._xhr),this._cleanup(!0)}_cleanup(n){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=V_,n)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Pn.requests[this._index],this._xhr=null}}_onLoad(){const n=this._xhr.responseText;n!==null&&(this.emitReserved("data",n),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Pn.requestsCount=0;Pn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",H0);else if(typeof addEventListener=="function"){const r="onpagehide"in vn?"pagehide":"unload";addEventListener(r,H0,!1)}}function H0(){for(let r in Pn.requests)Pn.requests.hasOwnProperty(r)&&Pn.requests[r].abort()}const J_=(function(){const r=Qg({xdomain:!1});return r&&r.responseType!==null})();class I_ extends F_{constructor(n){super(n);const s=n&&n.forceBase64;this.supportsBinary=J_&&!s}request(n={}){return Object.assign(n,{xd:this.xd},this.opts),new Pn(Qg,this.uri(),n)}}function Qg(r){const n=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!n||G_))return new XMLHttpRequest}catch{}if(!n)try{return new vn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Xg=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Q_ extends uh{get name(){return"websocket"}doOpen(){const n=this.uri(),s=this.opts.protocols,a=Xg?{}:Fg(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(n,s,a)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=n=>this.onClose({description:"websocket connection closed",context:n}),this.ws.onmessage=n=>this.onData(n.data),this.ws.onerror=n=>this.onError("websocket error",n)}write(n){this.writable=!1;for(let s=0;s<n.length;s++){const a=n[s],o=s===n.length-1;oh(a,this.supportsBinary,f=>{try{this.doWrite(a,f)}catch{}o&&Jo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const n=this.opts.secure?"wss":"ws",s=this.query||{};return this.opts.timestampRequests&&(s[this.opts.timestampParam]=Jg()),this.supportsBinary||(s.b64=1),this.createUri(n,s)}}const vf=vn.WebSocket||vn.MozWebSocket;class X_ extends Q_{createSocket(n,s,a){return Xg?new vf(n,s,a):s?new vf(n,s):new vf(n)}doWrite(n,s){this.ws.send(s)}}class K_ extends uh{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(n){return this.emitReserved("error",n)}this._transport.closed.then(()=>{this.onClose()}).catch(n=>{this.onError("webtransport error",n)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(n=>{const s=M_(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=n.readable.pipeThrough(s).getReader(),o=k_();o.readable.pipeTo(n.writable),this._writer=o.writable.getWriter();const f=()=>{a.read().then(({done:m,value:g})=>{m||(this.onPacket(g),f())}).catch(m=>{})};f();const h={type:"open"};this.query.sid&&(h.data=`{"sid":"${this.query.sid}"}`),this._writer.write(h).then(()=>this.onOpen())})})}write(n){this.writable=!1;for(let s=0;s<n.length;s++){const a=n[s],o=s===n.length-1;this._writer.write(a).then(()=>{o&&Jo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var n;(n=this._transport)===null||n===void 0||n.close()}}const Z_={websocket:X_,webtransport:K_,polling:I_},W_=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ew=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Yf(r){if(r.length>8e3)throw"URI too long";const n=r,s=r.indexOf("["),a=r.indexOf("]");s!=-1&&a!=-1&&(r=r.substring(0,s)+r.substring(s,a).replace(/:/g,";")+r.substring(a,r.length));let o=W_.exec(r||""),f={},h=14;for(;h--;)f[ew[h]]=o[h]||"";return s!=-1&&a!=-1&&(f.source=n,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=tw(f,f.path),f.queryKey=nw(f,f.query),f}function tw(r,n){const s=/\/{2,9}/g,a=n.replace(s,"/").split("/");return(n.slice(0,1)=="/"||n.length===0)&&a.splice(0,1),n.slice(-1)=="/"&&a.splice(a.length-1,1),a}function nw(r,n){const s={};return n.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,o,f){o&&(s[o]=f)}),s}const Gf=typeof addEventListener=="function"&&typeof removeEventListener=="function",Oo=[];Gf&&addEventListener("offline",()=>{Oo.forEach(r=>r())},!1);class Xs extends gt{constructor(n,s){if(super(),this.binaryType=D_,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,n&&typeof n=="object"&&(s=n,n=null),n){const a=Yf(n);s.hostname=a.host,s.secure=a.protocol==="https"||a.protocol==="wss",s.port=a.port,a.query&&(s.query=a.query)}else s.host&&(s.hostname=Yf(s.host).host);Io(this,s),this.secure=s.secure!=null?s.secure:typeof location<"u"&&location.protocol==="https:",s.hostname&&!s.port&&(s.port=this.secure?"443":"80"),this.hostname=s.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=s.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},s.transports.forEach(a=>{const o=a.prototype.name;this.transports.push(o),this._transportsByName[o]=a}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},s),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=P_(this.opts.query)),Gf&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Oo.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(n){const s=Object.assign({},this.opts.query);s.EIO=Vg,s.transport=n,this.id&&(s.sid=this.id);const a=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[n]);return new this._transportsByName[n](a)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const n=this.opts.rememberUpgrade&&Xs.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const s=this.createTransport(n);s.open(),this.setTransport(s)}setTransport(n){this.transport&&this.transport.removeAllListeners(),this.transport=n,n.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",s=>this._onClose("transport close",s))}onOpen(){this.readyState="open",Xs.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",n),this.emitReserved("heartbeat"),n.type){case"open":this.onHandshake(JSON.parse(n.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const s=new Error("server error");s.code=n.data,this._onError(s);break;case"message":this.emitReserved("data",n.data),this.emitReserved("message",n.data);break}}onHandshake(n){this.emitReserved("handshake",n),this.id=n.sid,this.transport.query.sid=n.sid,this._pingInterval=n.pingInterval,this._pingTimeout=n.pingTimeout,this._maxPayload=n.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const n=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+n,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},n),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const n=this._getWritablePackets();this.transport.send(n),this._prevBufferLen=n.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let s=1;for(let a=0;a<this.writeBuffer.length;a++){const o=this.writeBuffer[a].data;if(o&&(s+=B_(o)),a>0&&s>this._maxPayload)return this.writeBuffer.slice(0,a);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const n=Date.now()>this._pingTimeoutTime;return n&&(this._pingTimeoutTime=0,Jo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),n}write(n,s,a){return this._sendPacket("message",n,s,a),this}send(n,s,a){return this._sendPacket("message",n,s,a),this}_sendPacket(n,s,a,o){if(typeof s=="function"&&(o=s,s=void 0),typeof a=="function"&&(o=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;const f={type:n,data:s,options:a};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),o&&this.once("flush",o),this.flush()}close(){const n=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),n()},a=()=>{this.once("upgrade",s),this.once("upgradeError",s)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?a():n()}):this.upgrading?a():n()),this}_onError(n){if(Xs.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",n),this._onClose("transport error",n)}_onClose(n,s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Gf&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const a=Oo.indexOf(this._offlineEventListener);a!==-1&&Oo.splice(a,1)}this.readyState="closed",this.id=null,this.emitReserved("close",n,s),this.writeBuffer=[],this._prevBufferLen=0}}}Xs.protocol=Vg;class sw extends Xs{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let n=0;n<this._upgrades.length;n++)this._probe(this._upgrades[n])}_probe(n){let s=this.createTransport(n),a=!1;Xs.priorWebsocketSuccess=!1;const o=()=>{a||(s.send([{type:"ping",data:"probe"}]),s.once("packet",w=>{if(!a)if(w.type==="pong"&&w.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",s),!s)return;Xs.priorWebsocketSuccess=s.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(E(),this.setTransport(s),s.send([{type:"upgrade"}]),this.emitReserved("upgrade",s),s=null,this.upgrading=!1,this.flush())})}else{const T=new Error("probe error");T.transport=s.name,this.emitReserved("upgradeError",T)}}))};function f(){a||(a=!0,E(),s.close(),s=null)}const h=w=>{const T=new Error("probe error: "+w);T.transport=s.name,f(),this.emitReserved("upgradeError",T)};function m(){h("transport closed")}function g(){h("socket closed")}function y(w){s&&w.name!==s.name&&f()}const E=()=>{s.removeListener("open",o),s.removeListener("error",h),s.removeListener("close",m),this.off("close",g),this.off("upgrading",y)};s.once("open",o),s.once("error",h),s.once("close",m),this.once("close",g),this.once("upgrading",y),this._upgrades.indexOf("webtransport")!==-1&&n!=="webtransport"?this.setTimeoutFn(()=>{a||s.open()},200):s.open()}onHandshake(n){this._upgrades=this._filterUpgrades(n.upgrades),super.onHandshake(n)}_filterUpgrades(n){const s=[];for(let a=0;a<n.length;a++)~this.transports.indexOf(n[a])&&s.push(n[a]);return s}}let iw=class extends sw{constructor(n,s={}){const a=typeof n=="object"?n:s;(!a.transports||a.transports&&typeof a.transports[0]=="string")&&(a.transports=(a.transports||["polling","websocket","webtransport"]).map(o=>Z_[o]).filter(o=>!!o)),super(n,a)}};function rw(r,n="",s){let a=r;s=s||typeof location<"u"&&location,r==null&&(r=s.protocol+"//"+s.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=s.protocol+r:r=s.host+r),/^(https?|wss?):\/\//.test(r)||(typeof s<"u"?r=s.protocol+"//"+r:r="https://"+r),a=Yf(r)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";const f=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+f+":"+a.port+n,a.href=a.protocol+"://"+f+(s&&s.port===a.port?"":":"+a.port),a}const aw=typeof ArrayBuffer=="function",lw=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Kg=Object.prototype.toString,ow=typeof Blob=="function"||typeof Blob<"u"&&Kg.call(Blob)==="[object BlobConstructor]",cw=typeof File=="function"||typeof File<"u"&&Kg.call(File)==="[object FileConstructor]";function fh(r){return aw&&(r instanceof ArrayBuffer||lw(r))||ow&&r instanceof Blob||cw&&r instanceof File}function To(r,n){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let s=0,a=r.length;s<a;s++)if(To(r[s]))return!0;return!1}if(fh(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return To(r.toJSON(),!0);for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)&&To(r[s]))return!0;return!1}function uw(r){const n=[],s=r.data,a=r;return a.data=Vf(s,n),a.attachments=n.length,{packet:a,buffers:n}}function Vf(r,n){if(!r)return r;if(fh(r)){const s={_placeholder:!0,num:n.length};return n.push(r),s}else if(Array.isArray(r)){const s=new Array(r.length);for(let a=0;a<r.length;a++)s[a]=Vf(r[a],n);return s}else if(typeof r=="object"&&!(r instanceof Date)){const s={};for(const a in r)Object.prototype.hasOwnProperty.call(r,a)&&(s[a]=Vf(r[a],n));return s}return r}function fw(r,n){return r.data=Ff(r.data,n),delete r.attachments,r}function Ff(r,n){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<n.length)return n[r.num];throw new Error("illegal attachments")}else if(Array.isArray(r))for(let s=0;s<r.length;s++)r[s]=Ff(r[s],n);else if(typeof r=="object")for(const s in r)Object.prototype.hasOwnProperty.call(r,s)&&(r[s]=Ff(r[s],n));return r}const hw=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var qe;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(qe||(qe={}));class dw{constructor(n){this.replacer=n}encode(n){return(n.type===qe.EVENT||n.type===qe.ACK)&&To(n)?this.encodeAsBinary({type:n.type===qe.EVENT?qe.BINARY_EVENT:qe.BINARY_ACK,nsp:n.nsp,data:n.data,id:n.id}):[this.encodeAsString(n)]}encodeAsString(n){let s=""+n.type;return(n.type===qe.BINARY_EVENT||n.type===qe.BINARY_ACK)&&(s+=n.attachments+"-"),n.nsp&&n.nsp!=="/"&&(s+=n.nsp+","),n.id!=null&&(s+=n.id),n.data!=null&&(s+=JSON.stringify(n.data,this.replacer)),s}encodeAsBinary(n){const s=uw(n),a=this.encodeAsString(s.packet),o=s.buffers;return o.unshift(a),o}}class hh extends gt{constructor(n){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof n=="function"?{reviver:n}:n)}add(n){let s;if(typeof n=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");s=this.decodeString(n);const a=s.type===qe.BINARY_EVENT;a||s.type===qe.BINARY_ACK?(s.type=a?qe.EVENT:qe.ACK,this.reconstructor=new mw(s),s.attachments===0&&super.emitReserved("decoded",s)):super.emitReserved("decoded",s)}else if(fh(n)||n.base64)if(this.reconstructor)s=this.reconstructor.takeBinaryData(n),s&&(this.reconstructor=null,super.emitReserved("decoded",s));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+n)}decodeString(n){let s=0;const a={type:Number(n.charAt(0))};if(qe[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===qe.BINARY_EVENT||a.type===qe.BINARY_ACK){const f=s+1;for(;n.charAt(++s)!=="-"&&s!=n.length;);const h=n.substring(f,s);if(h!=Number(h)||n.charAt(s)!=="-")throw new Error("Illegal attachments");const m=Number(h);if(!pw(m)||m<0)throw new Error("Illegal attachments");if(m>this.opts.maxAttachments)throw new Error("too many attachments");a.attachments=m}if(n.charAt(s+1)==="/"){const f=s+1;for(;++s&&!(n.charAt(s)===","||s===n.length););a.nsp=n.substring(f,s)}else a.nsp="/";const o=n.charAt(s+1);if(o!==""&&Number(o)==o){const f=s+1;for(;++s;){const h=n.charAt(s);if(h==null||Number(h)!=h){--s;break}if(s===n.length)break}a.id=Number(n.substring(f,s+1))}if(n.charAt(++s)){const f=this.tryParse(n.substr(s));if(hh.isPayloadValid(a.type,f))a.data=f;else throw new Error("invalid payload")}return a}tryParse(n){try{return JSON.parse(n,this.opts.reviver)}catch{return!1}}static isPayloadValid(n,s){switch(n){case qe.CONNECT:return P0(s);case qe.DISCONNECT:return s===void 0;case qe.CONNECT_ERROR:return typeof s=="string"||P0(s);case qe.EVENT:case qe.BINARY_EVENT:return Array.isArray(s)&&(typeof s[0]=="number"||typeof s[0]=="string"&&hw.indexOf(s[0])===-1);case qe.ACK:case qe.BINARY_ACK:return Array.isArray(s)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class mw{constructor(n){this.packet=n,this.buffers=[],this.reconPack=n}takeBinaryData(n){if(this.buffers.push(n),this.buffers.length===this.reconPack.attachments){const s=fw(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const pw=Number.isInteger||function(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r};function P0(r){return Object.prototype.toString.call(r)==="[object Object]"}const gw=Object.freeze(Object.defineProperty({__proto__:null,Decoder:hh,Encoder:dw,get PacketType(){return qe}},Symbol.toStringTag,{value:"Module"}));function Cn(r,n,s){return r.on(n,s),function(){r.off(n,s)}}const yw=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Zg extends gt{constructor(n,s,a){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=n,this.nsp=s,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const n=this.io;this.subs=[Cn(n,"open",this.onopen.bind(this)),Cn(n,"packet",this.onpacket.bind(this)),Cn(n,"error",this.onerror.bind(this)),Cn(n,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...n){return n.unshift("message"),this.emit.apply(this,n),this}emit(n,...s){var a,o,f;if(yw.hasOwnProperty(n))throw new Error('"'+n.toString()+'" is a reserved event name');if(s.unshift(n),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(s),this;const h={type:qe.EVENT,data:s};if(h.options={},h.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const E=this.ids++,w=s.pop();this._registerAckCallback(E,w),h.id=E}const m=(o=(a=this.io.engine)===null||a===void 0?void 0:a.transport)===null||o===void 0?void 0:o.writable,g=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!m||(g?(this.notifyOutgoingListeners(h),this.packet(h)):this.sendBuffer.push(h)),this.flags={},this}_registerAckCallback(n,s){var a;const o=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(o===void 0){this.acks[n]=s;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[n];for(let m=0;m<this.sendBuffer.length;m++)this.sendBuffer[m].id===n&&this.sendBuffer.splice(m,1);s.call(this,new Error("operation has timed out"))},o),h=(...m)=>{this.io.clearTimeoutFn(f),s.apply(this,m)};h.withError=!0,this.acks[n]=h}emitWithAck(n,...s){return new Promise((a,o)=>{const f=(h,m)=>h?o(h):a(m);f.withError=!0,s.push(f),this.emit(n,...s)})}_addToQueue(n){let s;typeof n[n.length-1]=="function"&&(s=n.pop());const a={id:this._queueSeq++,tryCount:0,pending:!1,args:n,flags:Object.assign({fromQueue:!0},this.flags)};n.push((o,...f)=>(this._queue[0],o!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),s&&s(o)):(this._queue.shift(),s&&s(null,...f)),a.pending=!1,this._drainQueue())),this._queue.push(a),this._drainQueue()}_drainQueue(n=!1){if(!this.connected||this._queue.length===0)return;const s=this._queue[0];s.pending&&!n||(s.pending=!0,s.tryCount++,this.flags=s.flags,this.emit.apply(this,s.args))}packet(n){n.nsp=this.nsp,this.io._packet(n)}onopen(){typeof this.auth=="function"?this.auth(n=>{this._sendConnectPacket(n)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(n){this.packet({type:qe.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},n):n})}onerror(n){this.connected||this.emitReserved("connect_error",n)}onclose(n,s){this.connected=!1,delete this.id,this.emitReserved("disconnect",n,s),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(n=>{if(!this.sendBuffer.some(a=>String(a.id)===n)){const a=this.acks[n];delete this.acks[n],a.withError&&a.call(this,new Error("socket has been disconnected"))}})}onpacket(n){if(n.nsp===this.nsp)switch(n.type){case qe.CONNECT:n.data&&n.data.sid?this.onconnect(n.data.sid,n.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case qe.EVENT:case qe.BINARY_EVENT:this.onevent(n);break;case qe.ACK:case qe.BINARY_ACK:this.onack(n);break;case qe.DISCONNECT:this.ondisconnect();break;case qe.CONNECT_ERROR:this.destroy();const a=new Error(n.data.message);a.data=n.data.data,this.emitReserved("connect_error",a);break}}onevent(n){const s=n.data||[];n.id!=null&&s.push(this.ack(n.id)),this.connected?this.emitEvent(s):this.receiveBuffer.push(Object.freeze(s))}emitEvent(n){if(this._anyListeners&&this._anyListeners.length){const s=this._anyListeners.slice();for(const a of s)a.apply(this,n)}super.emit.apply(this,n),this._pid&&n.length&&typeof n[n.length-1]=="string"&&(this._lastOffset=n[n.length-1])}ack(n){const s=this;let a=!1;return function(...o){a||(a=!0,s.packet({type:qe.ACK,id:n,data:o}))}}onack(n){const s=this.acks[n.id];typeof s=="function"&&(delete this.acks[n.id],s.withError&&n.data.unshift(null),s.apply(this,n.data))}onconnect(n,s){this.id=n,this.recovered=s&&this._pid===s,this._pid=s,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(n=>this.emitEvent(n)),this.receiveBuffer=[],this.sendBuffer.forEach(n=>{this.notifyOutgoingListeners(n),this.packet(n)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(n=>n()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:qe.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(n){return this.flags.compress=n,this}get volatile(){return this.flags.volatile=!0,this}timeout(n){return this.flags.timeout=n,this}onAny(n){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(n),this}prependAny(n){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(n),this}offAny(n){if(!this._anyListeners)return this;if(n){const s=this._anyListeners;for(let a=0;a<s.length;a++)if(n===s[a])return s.splice(a,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(n){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(n),this}prependAnyOutgoing(n){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(n),this}offAnyOutgoing(n){if(!this._anyOutgoingListeners)return this;if(n){const s=this._anyOutgoingListeners;for(let a=0;a<s.length;a++)if(n===s[a])return s.splice(a,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(n){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const s=this._anyOutgoingListeners.slice();for(const a of s)a.apply(this,n.data)}}}function Nr(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}Nr.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var n=Math.random(),s=Math.floor(n*this.jitter*r);r=(Math.floor(n*10)&1)==0?r-s:r+s}return Math.min(r,this.max)|0};Nr.prototype.reset=function(){this.attempts=0};Nr.prototype.setMin=function(r){this.ms=r};Nr.prototype.setMax=function(r){this.max=r};Nr.prototype.setJitter=function(r){this.jitter=r};class Jf extends gt{constructor(n,s){var a;super(),this.nsps={},this.subs=[],n&&typeof n=="object"&&(s=n,n=void 0),s=s||{},s.path=s.path||"/socket.io",this.opts=s,Io(this,s),this.reconnection(s.reconnection!==!1),this.reconnectionAttempts(s.reconnectionAttempts||1/0),this.reconnectionDelay(s.reconnectionDelay||1e3),this.reconnectionDelayMax(s.reconnectionDelayMax||5e3),this.randomizationFactor((a=s.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new Nr({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(s.timeout==null?2e4:s.timeout),this._readyState="closed",this.uri=n;const o=s.parser||gw;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=s.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(n){return arguments.length?(this._reconnection=!!n,n||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(n){return n===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=n,this)}reconnectionDelay(n){var s;return n===void 0?this._reconnectionDelay:(this._reconnectionDelay=n,(s=this.backoff)===null||s===void 0||s.setMin(n),this)}randomizationFactor(n){var s;return n===void 0?this._randomizationFactor:(this._randomizationFactor=n,(s=this.backoff)===null||s===void 0||s.setJitter(n),this)}reconnectionDelayMax(n){var s;return n===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=n,(s=this.backoff)===null||s===void 0||s.setMax(n),this)}timeout(n){return arguments.length?(this._timeout=n,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(n){if(~this._readyState.indexOf("open"))return this;this.engine=new iw(this.uri,this.opts);const s=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;const o=Cn(s,"open",function(){a.onopen(),n&&n()}),f=m=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",m),n?n(m):this.maybeReconnectOnOpen()},h=Cn(s,"error",f);if(this._timeout!==!1){const m=this._timeout,g=this.setTimeoutFn(()=>{o(),f(new Error("timeout")),s.close()},m);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(o),this.subs.push(h),this}connect(n){return this.open(n)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const n=this.engine;this.subs.push(Cn(n,"ping",this.onping.bind(this)),Cn(n,"data",this.ondata.bind(this)),Cn(n,"error",this.onerror.bind(this)),Cn(n,"close",this.onclose.bind(this)),Cn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(n){try{this.decoder.add(n)}catch(s){this.onclose("parse error",s)}}ondecoded(n){Jo(()=>{this.emitReserved("packet",n)},this.setTimeoutFn)}onerror(n){this.emitReserved("error",n)}socket(n,s){let a=this.nsps[n];return a?this._autoConnect&&!a.active&&a.connect():(a=new Zg(this,n,s),this.nsps[n]=a),a}_destroy(n){const s=Object.keys(this.nsps);for(const a of s)if(this.nsps[a].active)return;this._close()}_packet(n){const s=this.encoder.encode(n);for(let a=0;a<s.length;a++)this.engine.write(s[a],n.options)}cleanup(){this.subs.forEach(n=>n()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(n,s){var a;this.cleanup(),(a=this.engine)===null||a===void 0||a.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",n,s),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const n=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const s=this.backoff.duration();this._reconnecting=!0;const a=this.setTimeoutFn(()=>{n.skipReconnect||(this.emitReserved("reconnect_attempt",n.backoff.attempts),!n.skipReconnect&&n.open(o=>{o?(n._reconnecting=!1,n.reconnect(),this.emitReserved("reconnect_error",o)):n.onreconnect()}))},s);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){const n=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",n)}}const Oa={};function No(r,n){typeof r=="object"&&(n=r,r=void 0),n=n||{};const s=rw(r,n.path||"/socket.io"),a=s.source,o=s.id,f=s.path,h=Oa[o]&&f in Oa[o].nsps,m=n.forceNew||n["force new connection"]||n.multiplex===!1||h;let g;return m?g=new Jf(a,n):(Oa[o]||(Oa[o]=new Jf(a,n)),g=Oa[o]),s.query&&!n.query&&(n.query=s.queryKey),g.socket(s.path,n)}Object.assign(No,{Manager:Jf,Socket:Zg,io:No,connect:No});const bw=O.createContext({connected:!1,subscribe:()=>()=>{}});function xw({children:r}){const n=O.useRef(null),[s,a]=O.useState(!1),o=O.useRef(new Map),f=O.useCallback((m,g)=>{const y=o.current;return y.has(m)||y.set(m,new Set),y.get(m).add(g),()=>{const E=y.get(m);E&&(E.delete(g),E.size===0&&y.delete(m))}},[]),h=O.useCallback((m,g)=>{for(const[y,E]of o.current)if(Lg(m,y))for(const w of E)try{w(g)}catch{}},[]);return O.useEffect(()=>{const m=vg(),g=No({path:`${Wt}/socket.io`,transports:["polling","websocket"],upgrade:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:2e3,...m?{auth:{token:m}}:{}});return n.current=g,console.log("[lt-socketio] connecting..."),g.on("connect",()=>{console.log("[lt-socketio] connected, id:",g.id),a(!0)}),g.on("disconnect",y=>{console.log("[lt-socketio] disconnected:",y),a(!1)}),g.on("connect_error",y=>{console.warn("[lt-socketio] connect error:",y.message),a(!1)}),g.onAny((y,E)=>{if(y.startsWith("lt."))try{const w=typeof E=="string"?JSON.parse(E):E;h(y,w)}catch{}}),()=>{g.removeAllListeners(),g.disconnect(),n.current=null,a(!1)}},[h]),d.jsx(bw.Provider,{value:{connected:s,subscribe:f},children:d.jsx(Fa.Provider,{value:{connected:s,subscribe:f},children:r})})}function vw({children:r}){const[n,s]=O.useState(null),[a,o]=O.useState({url:null,token:null});return O.useEffect(()=>{let f=!1;async function h(){var m;try{console.log("[lt-transport] detecting event transport...");const g=await fetch(`${Wt}/api/settings`);if(!g.ok){console.warn("[lt-transport] settings fetch failed, falling back to socketio"),f||s("socketio");return}const y=await g.json(),E=(m=y==null?void 0:y.events)==null?void 0:m.transport;if(console.log("[lt-transport] server reports:",E),!f){if(E==="nats"){let w=y.events.natsWsUrl??null,T=null;const q=vg();if(q)try{const M=await fetch(`${Wt}/api/nats-credentials`,{headers:{Authorization:`Bearer ${q}`}});if(M.ok){const R=await M.json();w=R.natsWsUrl??w,T=R.natsToken??null}}catch{console.warn("[lt-transport] failed to fetch NATS credentials")}o({url:w,token:T})}s(E==="nats"?"nats":"socketio")}}catch(g){console.warn("[lt-transport] settings fetch error, falling back to socketio",g),f||s("socketio")}}return h(),()=>{f=!0}},[]),n==="nats"?d.jsx(E_,{url:a.url,token:a.token,children:r}):n==="socketio"?d.jsx(xw,{children:r}):d.jsx(d.Fragment,{children:r})}function Wg(){const{isSuperAdmin:r,hasRoleType:n,hasRole:s}=Oi(),a=r||s("engineer"),o=n("admin"),f=r||n("admin");return{isBuilder:a,isOps:o,canBulk:f}}const If="lt_ai_override";function _w(){return $e("/settings")}function Qf(){try{if(localStorage.getItem(If)==="off")return!1}catch{}return null}function Qo(){var s;const r=_n({queryKey:["settings"],queryFn:_w,staleTime:1/0}),n=Qf();return r.data&&n===!1&&((s=r.data.ai)!=null&&s.enabled)?{...r,data:{...r.data,ai:{enabled:!1}}}:r}function ww(){const[r,n]=O.useState(()=>Qf()===!1),s=O.useCallback(()=>{const a=Qf()===!1;try{a?localStorage.removeItem(If):localStorage.setItem(If,"off")}catch{}n(!a),window.location.reload()},[]);return{aiOverrideActive:r,toggleAIOverride:s}}const ey=O.createContext(null),$0="lt_sidebar_collapsed";function Sw({children:r}){const[n,s]=O.useState(()=>{try{return localStorage.getItem($0)==="true"}catch{return!1}}),a=O.useCallback(()=>{s(o=>{const f=!o;try{localStorage.setItem($0,String(f))}catch{}return f})},[]);return d.jsx(ey.Provider,{value:{collapsed:n,toggle:a},children:r})}function ty(){const r=O.useContext(ey);if(!r)throw new Error("useSidebar must be used within SidebarProvider");return r}function ny(r,n){var s,a,o,f,h;n.facets&&Object.keys(n.facets).length&&r.set("facets",JSON.stringify(n.facets)),(s=n.block)!=null&&s.length&&r.set("block",JSON.stringify(n.block)),(a=n.range)!=null&&a.length&&r.set("range",JSON.stringify(n.range)),(o=n.exists)!=null&&o.length&&r.set("exists",JSON.stringify(n.exists)),(f=n.roles)!=null&&f.length&&r.set("roles",JSON.stringify(n.roles)),(h=n.orderBy)!=null&&h.length&&r.set("orderBy",JSON.stringify(n.orderBy)),n.available!==void 0&&r.set("available",String(n.available))}function VE(r,n){const s=r??"24h";return _n({queryKey:["stationMetrics",s],queryFn:()=>$e(`/escalations/station-metrics?period=${s}`),staleTime:5e3,enabled:(n==null?void 0:n.enabled)??!0})}function FE(r){const n=r?`?period=${r}`:"";return _n({queryKey:["escalationStats",r],queryFn:()=>$e(`/escalations/stats${n}`)})}function JE(){return _n({queryKey:["escalationTypes"],queryFn:()=>$e("/escalations/types")})}function IE(r=!0){return _n({queryKey:["escalationFacetKeys"],queryFn:()=>$e("/escalations/facet-keys"),enabled:r,staleTime:6e4})}function Ew(r){const{enabled:n=!0,staleTime:s,...a}=r,o=new URLSearchParams;return a.status&&o.set("status",a.status),a.role&&o.set("role",a.role),a.type&&o.set("type",a.type),a.subtype&&o.set("subtype",a.subtype),a.assigned_to&&o.set("assigned_to",a.assigned_to),a.claimed&&o.set("claimed","true"),a.priority&&o.set("priority",String(a.priority)),a.limit&&o.set("limit",String(a.limit)),a.offset!==void 0&&o.set("offset",String(a.offset)),a.sort_by&&o.set("sort_by",a.sort_by),a.order&&o.set("order",a.order),a.search&&o.set("search",a.search),ny(o,a),_n({queryKey:["escalations",a],queryFn:()=>$e(`/escalations?${o}`),enabled:n,...s!==void 0?{staleTime:s}:{}})}function Aw(r){const{enabled:n=!0,staleTime:s,...a}=r,o=new URLSearchParams;return a.role&&o.set("role",a.role),a.type&&o.set("type",a.type),a.subtype&&o.set("subtype",a.subtype),a.priority&&o.set("priority",String(a.priority)),a.limit&&o.set("limit",String(a.limit)),a.offset!==void 0&&o.set("offset",String(a.offset)),a.sort_by&&o.set("sort_by",a.sort_by),a.order&&o.set("order",a.order),a.search&&o.set("search",a.search),ny(o,a),_n({queryKey:["escalations","available",a],queryFn:()=>$e(`/escalations/available?${o}`),enabled:n,...s!==void 0?{staleTime:s}:{}})}function QE(r){return _n({queryKey:["escalations","by-workflow",r],queryFn:()=>$e(`/escalations/by-workflow/${r}`),enabled:!!r})}function XE(r){return _n({queryKey:["escalations",r],queryFn:()=>$e(`/escalations/${r}`),enabled:!!r})}function KE(){const r=rn();return wn({mutationFn:({id:n,durationMinutes:s})=>$e(`/escalations/${n}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:s})}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function ZE(){const r=rn();return wn({mutationFn:n=>$e(`/escalations/${n}/release`,{method:"POST"}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function WE(){const r=rn();return wn({mutationFn:({id:n,resolverPayload:s})=>$e(`/escalations/${n}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:s})}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]}),r.resetQueries({queryKey:["tasks"]}),r.resetQueries({queryKey:["jobs"]})}})}function e3(){const r=rn();return wn({mutationFn:({id:n,targetRole:s})=>$e(`/escalations/${n}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:s})}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function t3(){const r=rn();return wn({mutationFn:({ids:n,priority:s})=>$e("/escalations/priority",{method:"PATCH",body:JSON.stringify({ids:n,priority:s})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function n3(){const r=rn();return wn({mutationFn:({ids:n,durationMinutes:s})=>$e("/escalations/bulk-claim",{method:"POST",body:JSON.stringify({ids:n,durationMinutes:s})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function s3(){const r=rn();return wn({mutationFn:({ids:n,targetUserId:s,durationMinutes:a})=>$e("/escalations/bulk-assign",{method:"POST",body:JSON.stringify({ids:n,targetUserId:s,durationMinutes:a})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function i3(){const r=rn();return wn({mutationFn:({ids:n,targetRole:s})=>$e("/escalations/bulk-escalate",{method:"PATCH",body:JSON.stringify({ids:n,targetRole:s})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function r3(){const r=rn();return wn({mutationFn:({ids:n,hint:s})=>$e("/escalations/bulk-triage",{method:"POST",body:JSON.stringify({ids:n,...s?{hint:s}:{}})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function a3(){const r=rn();return wn({mutationFn:n=>$e(`/escalations/${n}/cancel`,{method:"POST"}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function l3(){const r=rn();return wn({mutationFn:({ids:n})=>$e("/escalations/bulk-cancel",{method:"POST",body:JSON.stringify({ids:n})}),onSuccess:()=>{r.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),r.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function jw(){const{user:r}=Oi(),n=r==null?void 0:r.userId,s=rn(),a=O.useRef(null),o=O.useCallback(()=>{a.current||(a.current=setTimeout(()=>{a.current=null,s.invalidateQueries({queryKey:["escalations"]})},15e3))},[s]);__(`${x_}.system.escalation.>`,o);const{data:f}=Aw({limit:1}),{data:h}=Ew({assigned_to:n,status:"pending",limit:1});return{available:(f==null?void 0:f.total)??0,mine:(h==null?void 0:h.total)??0}}function dh({size:r="sm",hideLabel:n=!1,className:s=""}){const a=r==="lg",o=a?"w-[16rem] h-[16rem] -rotate-[120deg] opacity-40 -ml-10":"w-[12.5rem] h-[12.5rem] -rotate-[120deg] opacity-40 -ml-8",f=a?"text-[44px] font-normal text-text-primary tracking-[0.15em] -ml-[12.5rem]":"text-[36px] font-normal text-text-primary tracking-[0.15em] -ml-[9.75rem]";return d.jsxs("div",{className:`flex items-center ${s}`,style:{height:"50px"},children:[d.jsx("span",{role:"img","aria-label":"LongTail",className:`logo-mark shrink-0 z-0 ${o}`,style:{"--logo-url":`url(${Wt}/logo512.png)`}}),d.jsx("span",{className:`z-[1] transition-opacity duration-300 ${f} ${n?"opacity-0":""}`,children:"LongTail"})]})}const sy=["violet","red","green","blue","rose"],Y0="blue",Ow={violet:"#7B3BE0",red:"#DC382D",green:"#059669",blue:"#1E3A8A",rose:"#D6246E"},G0={violet:"Violet",red:"Brick",green:"Emerald",blue:"Navy",rose:"Raspberry"},iy="lt.theme";function Tw(r){return sy.includes(r)}function ry(){try{const r=localStorage.getItem(iy);return Tw(r)?r:Y0}catch{return Y0}}function ay(r){document.documentElement.dataset.theme=r}function Nw(r){try{localStorage.setItem(iy,r)}catch{}ay(r)}function Cw({onToggleEventFeed:r,onToggleDocs:n}){const{user:s,logout:a}=Oi(),{isBuilder:o,isOps:f}=Wg(),{available:h,mine:m}=jw(),{connected:g}=v_(),{toggleAIOverride:y}=ww(),[E,w]=O.useState(!1),[T,q]=O.useState(ry),M=O.useRef(null),R=G=>{Nw(G),q(G)};return O.useEffect(()=>{if(!E)return;const G=ne=>{M.current&&!M.current.contains(ne.target)&&w(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[E]),d.jsxs("header",{className:"h-14 shrink-0 border-b border-surface-border bg-surface-raised flex items-center justify-between px-5 relative z-30",children:[d.jsx("div",{className:"flex items-center gap-4",children:d.jsx(yr,{to:"/","aria-label":"Home",onClick:G=>{(G.ctrlKey||G.metaKey)&&(G.preventDefault(),y())},children:d.jsx(dh,{})})}),d.jsxs("div",{className:"flex items-center gap-5",children:[d.jsxs(yr,{to:"/escalations/available",className:`flex items-center gap-1.5 text-[11px] transition-colors ${h>0?"text-status-active hover:text-status-active/80":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[d.jsx(Ef,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"all",h>0&&d.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:h})]}),d.jsxs(yr,{to:"/escalations/queue",className:`flex items-center gap-1.5 text-[11px] transition-colors ${m>0?"text-status-warning hover:text-status-warning/80":"text-text-quaternary hover:text-text-secondary"}`,title:"My escalation queue",children:[d.jsx(Ef,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"mine",m>0&&d.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:m})]}),(o||f)&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"w-px h-4 bg-surface-border"}),d.jsxs("button",{type:"button",onClick:()=>{g?r==null||r():window.location.reload()},className:`flex items-center gap-1.5 text-[11px] transition-colors ${g?"text-status-success hover:text-status-success/80":"text-text-quaternary hover:text-text-secondary"}`,title:g?"Live events — click to toggle feed":"Events disconnected — click to reconnect",children:[d.jsx(pg,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"events"]})]}),o&&d.jsx(d.Fragment,{children:d.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 text-[11px] text-text-quaternary hover:text-text-secondary transition-colors",title:"Documentation",children:[d.jsx(gg,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"docs"]})}),d.jsx("div",{className:"w-px h-4 bg-surface-border"}),s&&d.jsxs("div",{className:"relative",ref:M,children:[d.jsxs("button",{onClick:()=>w(G=>!G),className:"btn-ghost text-xs flex items-center gap-1",children:[d.jsx(Ux,{className:"w-3.5 h-3.5 text-accent/75",strokeWidth:1.5}),s.displayName||s.username||s.userId,d.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),E&&d.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-50",children:[d.jsx(yr,{to:"/credentials",onClick:()=>w(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),d.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[d.jsx("p",{className:"text-[10px] font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Theme"}),d.jsx("div",{className:"flex items-center gap-2",children:sy.map(G=>d.jsx("button",{type:"button",onClick:()=>R(G),title:G0[G],"aria-label":`${G0[G]} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${T===G?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:Ow[G]}},G))})]}),d.jsx("button",{onClick:()=>{w(!1),a()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Sign Out"})]})]})]})]})}function mh({open:r,children:n}){const[s,a]=O.useState(r);return O.useEffect(()=>{r&&a(!0)},[r]),d.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-out ${r?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,onTransitionEnd:()=>{r||a(!1)},children:d.jsx("div",{className:"overflow-hidden",children:s?n:null})})}function Xf(r){return({isActive:n})=>{const s="flex items-center rounded-md transition-colors duration-150",a="bg-surface-hover text-text-primary font-medium",o="text-text-secondary hover:text-text-primary hover:bg-surface-hover";return r?`${s} justify-center w-10 h-10 mx-auto ${n?a:o}`:`${s} gap-3 px-4 py-2 text-sm ${n?a:o}`}}function kw(){return({isActive:r})=>`flex items-center gap-3 pl-11 pr-4 py-1.5 text-xs rounded-md transition-colors duration-150 ${r?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary"}`}function Mw({group:r,collapsed:n}){const{pathname:s}=ei(),a=r.matchPaths.some(m=>s.startsWith(m)),[o,f]=O.useState(a),h=o||a;return n?d.jsx(d.Fragment,{children:r.items.map(m=>d.jsx(Co,{to:m.to,className:Xf(!0),title:m.label,children:m.icon&&d.jsx(m.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},m.to))}):d.jsxs("div",{children:[d.jsxs("button",{onClick:()=>f(m=>!m),className:"w-full flex items-center justify-between px-4 py-2 text-sm rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",children:[d.jsxs("span",{className:"flex items-center gap-3",children:[r.icon&&d.jsx(r.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),d.jsx("span",{children:r.label})]}),d.jsx("svg",{className:`w-3.5 h-3.5 text-text-tertiary transition-transform duration-150 ${h?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),d.jsx(mh,{open:h,children:r.items.map(m=>d.jsxs(Co,{to:m.to,end:m.end,className:kw(),children:[m.icon&&d.jsx(m.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),d.jsx("span",{children:m.label})]},m.to))})]})}function Rw(r){return r.kind==="group"}function Dw({entry:r,collapsed:n}){const{pathname:s,search:a}=ei();if(r.to.includes("?")){const[f,h]=r.to.split("?"),m=s===f&&a===`?${h}`,g=Xf(n)({isActive:m});return d.jsxs(Co,{to:r.to,className:g,title:n?r.label:void 0,children:[r.icon&&d.jsx(r.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),!n&&d.jsx("span",{children:r.label})]})}return d.jsxs(Co,{to:r.to,end:r.end,className:Xf(n),title:n?r.label:void 0,children:[r.icon&&d.jsx(r.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),!n&&d.jsx("span",{children:r.label})]})}function Ks({heading:r,entries:n}){const{collapsed:s}=ty();return d.jsxs("div",{className:"space-y-1",children:[s?d.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:r}):d.jsx("p",{className:"px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-accent/80",children:r}),n.map(a=>Rw(a)?d.jsx(Mw,{group:a,collapsed:s},a.label):d.jsx(Dw,{entry:a,collapsed:s},a.to))]})}function zw({aiEnabled:r=!1,isBuilder:n=!1,isOps:s=!1}){if(!n&&!s){const o=[{to:"/escalations/queue",label:"My Queue",icon:Ef},{to:"/escalations/available",label:"All",icon:Af}];return d.jsx(Ks,{heading:"Work",entries:o})}if(!n)return d.jsx(Ks,{heading:"Monitor",entries:[{to:"/operations",label:"Pace Board",icon:s0}]});const a=[...s||n?[{to:"/operations",label:"Pace Board",icon:s0}]:[],{to:"/topics",label:"Event Topics",icon:pg},{to:"/agents",label:r?"Agents":"Automations",icon:Bx},{to:"/capabilities",label:"Capabilities",icon:Lx}];return d.jsx(Ks,{heading:"Monitor",entries:a})}function qw(){const r=[{kind:"group",label:"Procedural",icon:Hx,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:[{to:"/workflows/registry",label:"Registry",icon:i0},{to:"/workflows/durable/invoke",label:"Invoke",icon:r0},{to:"/workflows/executions",label:"Executions",icon:Af}]},{kind:"group",label:"Graph",icon:Kf,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:i0,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:r0},{to:"/mcp/executions",label:"Executions",icon:Af}]}];return d.jsx(Ks,{heading:"Orchestrate",entries:r})}const Uw=[{to:"/mcp/queries",label:"Designer",icon:Px},{to:"/mcp/servers",label:"Servers & Tools",icon:$x}];function Bw(){return d.jsx(Ks,{heading:"Design",entries:Uw})}const Lw=[{to:"/files",label:"Files",icon:Yx},{to:"/knowledge",label:"Knowledge",icon:Gx}];function Hw(){return d.jsx(Ks,{heading:"Storage",entries:Lw})}function Pw({isBuilder:r=!1,isOps:n=!1}){var h;const{data:s}=Qo(),a=((h=s==null?void 0:s.features)==null?void 0:h.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:Vx},...r||n?[{to:"/admin/roles",label:"Roles",icon:Fx}]:[]],f=[{to:"/admin/controlplane",label:"Routers",icon:Jx},{to:"/admin/streams",label:"Messages",icon:Ix},...a?[{to:"/admin/maintenance",label:"DB Maintenance",icon:Qx}]:[]];return d.jsxs(d.Fragment,{children:[d.jsx(Ks,{heading:"Identity & Access",entries:o}),r&&d.jsx(Ks,{heading:"Infrastructure",entries:f})]})}const ly="lt_event_feed_patterns";function $w(r){if(r.startsWith("/topics/")){const f=decodeURIComponent(r.replace("/topics/",""));if(f&&!f.includes("/"))return`lt.events.${f}`}const n=r.match(/^\/escalations\/detail\/(.+)/);if(n)return`lt.events.system.escalation.${n[1]}.>`;if(r.startsWith("/escalations"))return"lt.events.system.escalation.>";const s=r.match(/^\/workflows\/(?:durable\/)?executions\/(.+)/);if(s)return`lt.events.system.workflow.${s[1]}.>`;if(r.startsWith("/workflows"))return"lt.events.system.workflow.>";const a=r.match(/^\/agents\/([^/]+)$/);if(a&&a[1]!=="new")return`lt.events.system.agent.${a[1]}.>`;if(r.startsWith("/agents"))return"lt.events.system.agent.>";if(r.startsWith("/knowledge"))return"lt.events.system.knowledge.>";if(r.startsWith("/files"))return"lt.events.system.file.>";if(r==="/")return"lt.events.system.>";const o=r.match(/^\/mcp\/executions\/(.+)/);return o?`lt.events.system.*.${o[1]}.>`:(r.startsWith("/mcp"),"lt.events.system.>")}function Yw(){try{const r=localStorage.getItem(ly);return r?JSON.parse(r):[]}catch{return[]}}function _f(r){try{localStorage.setItem(ly,JSON.stringify(r))}catch{}}function Gw(){const{pathname:r}=ei(),[n,s]=O.useState(Yw),a=O.useMemo(()=>$w(r),[r]),o=O.useMemo(()=>{const g=new Set([a,...n]);return Array.from(g)},[a,n]),f=O.useCallback(g=>{const y=g.startsWith("lt.events.")?g:`lt.events.${g}`;s(E=>{if(E.includes(y))return E;const w=[...E,y];return _f(w),w})},[]),h=O.useCallback(g=>{s(y=>{const E=y.filter(w=>w!==g);return _f(E),E})},[]),m=O.useCallback(()=>{s([]),_f([])},[]);return{patterns:o,pagePattern:a,userPatterns:n,addPattern:f,removePattern:h,clearUserPatterns:m}}function Vw({children:r,className:n=""}){return d.jsx("p",{className:`text-[10px] font-semibold uppercase tracking-widest text-text-tertiary ${n}`,children:r})}const wf=280,V0="cubic-bezier(0.4, 0, 0.2, 1)",wo=40;function Fw(r){if(!r)return"scale(0.92)";const n=window.innerWidth,s=window.innerHeight,a=n-wo*2,o=s-wo*2,f=r.width/a,h=r.height/o,m=r.left+r.width/2-(wo+a/2),g=r.top+r.height/2-(wo+o/2);return`translate(${m}px, ${g}px) scale(${f}, ${h})`}function oy({open:r,onClose:n,sourceRef:s,children:a}){const[o,f]=O.useState(null),h=O.useRef(null),m=O.useRef(!1);O.useEffect(()=>{var T,q;r&&!m.current?(h.current=((T=s==null?void 0:s.current)==null?void 0:T.getBoundingClientRect())??null,f("entering")):!r&&m.current&&o==="open"&&(h.current=((q=s==null?void 0:s.current)==null?void 0:q.getBoundingClientRect())??null,f("exiting")),m.current=r},[r,s,o]),O.useEffect(()=>{if(o!=="entering")return;const T=requestAnimationFrame(()=>{requestAnimationFrame(()=>f("open"))});return()=>cancelAnimationFrame(T)},[o]),O.useEffect(()=>{if(o)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o]),O.useEffect(()=>{if(!o)return;const T=q=>{q.key==="Escape"&&n()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[o,n]);const g=O.useCallback(T=>{T.propertyName==="transform"&&o==="exiting"&&f(null)},[o]);if(O.useEffect(()=>{if(o!=="exiting")return;const T=setTimeout(()=>f(null),wf+50);return()=>clearTimeout(T)},[o]),!o)return null;const y=o==="entering"||o==="exiting",E=y?Fw(h.current):"none",w=y?0:1;return dg.createPortal(d.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${wf}ms ${V0}, opacity ${wf}ms ${V0}`,transform:E,opacity:w,backgroundColor:"#FFFFFF"},onTransitionEnd:g,children:a}),document.body)}function Jw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h8M4 18h12"})})}function Iw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7l-5 5 5 5M16 7l5 5-5 5"})})}function Qw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3"})})}function Xw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}function Kw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 9V4.5M9 9H4.5M9 9L3.5 3.5M9 15v4.5M9 15H4.5M9 15l-5.5 5.5M15 9h4.5M15 9V4.5M15 9l5.5-5.5M15 15h4.5M15 15v4.5m0-4.5l5.5 5.5"})})}function Zw({className:r}){return d.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}function Ww(r){const n=r.trim().split(`
54
54
  `);if(n.length<2)return r;const s=m=>m.split("|").map(g=>g.trim()).filter(Boolean),a=s(n[0]),o=n.slice(2),f=a.map(m=>`<th class="px-3 py-1.5 text-left text-[10px] font-semibold uppercase tracking-wider text-text-tertiary">${m}</th>`).join(""),h=o.map(m=>`<tr class="border-t border-surface-border">${s(m).map(E=>`<td class="px-3 py-1.5 text-xs text-text-secondary">${E}</td>`).join("")}</tr>`).join("");return`<table class="w-full my-3 text-xs"><thead><tr class="border-b border-surface-border">${f}</tr></thead><tbody>${h}</tbody></table>`}function So(r){return r.toLowerCase().replace(/<[^>]+>/g,"").replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").trim()}function eS(r){const n=[];let s=r.replace(/```(\w*)\n([\s\S]*?)```/g,(g,y,E)=>{const w=n.length;return n.push(`<pre class="bg-surface-sunken rounded p-3 my-2 overflow-x-auto text-[11px] leading-relaxed"><code>${E}</code></pre>`),`\0CODE${w}\0`});const a=/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm;s=s.replace(a,(g,y,E,w)=>Ww(`${y}
55
55
  ${E}
56
56
  ${w.trimEnd()}`)),s=s.replace(/`([^`]+)`/g,'<code class="bg-surface-sunken px-1 py-0.5 rounded text-[11px]">$1</code>'),s=s.replace(/^#### (.+)$/gm,(g,y)=>`<h4 id="${So(y)}" class="text-xs font-semibold text-text-primary mt-4 mb-1">${y}</h4>`).replace(/^### (.+)$/gm,(g,y)=>`<h3 id="${So(y)}" class="text-sm font-semibold text-text-primary mt-5 mb-1.5">${y}</h3>`).replace(/^## (.+)$/gm,(g,y)=>`<h2 id="${So(y)}" class="text-base font-semibold text-text-primary mt-6 mb-2 pb-1 border-b border-surface-border">${y}</h2>`).replace(/^# (.+)$/gm,(g,y)=>`<h1 id="${So(y)}" class="text-lg font-bold text-text-primary mb-3">${y}</h1>`),s=s.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(#([^)]+)\)/g,'<a data-anchor="$2" class="text-accent hover:underline cursor-pointer">$1</a>').replace(/\[([^\]]+)\]\(([^)]*\.md(?:#[^)]*)?)\)/g,'<a data-doc-link="$2" class="text-accent hover:underline cursor-pointer">$1</a>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent hover:underline">$1</a>').replace(/^ - (.+)$/gm,'<li class="ml-8 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^ - (.+)$/gm,'<li class="ml-8 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^- (.+)$/gm,'<li class="ml-4 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^\d+\. (.+)$/gm,'<li class="ml-4 list-decimal text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^---+$/gm,'<hr class="border-surface-border my-4" />').replace(/(?:^> (.+)$\n?)+/gm,g=>{const y=g.replace(/^> /gm,"").trim(),E=/⚠️|warning|caution/i.test(y),w=/note:|ℹ️|info/i.test(y);return`<div class="${E?"bg-status-warning/5":w?"bg-accent/5":"bg-surface-sunken/50"} ${E?"border-status-warning":w?"border-accent":"border-text-tertiary"} border-l-2 rounded-r-md px-3 py-2 my-3 text-xs text-text-secondary leading-relaxed">${y}</div>`}).replace(/\n\n/g,"\0PARA\0").replace(/\n/g,"<br/>");const o=g=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),f=g=>new RegExp(`(${o(g)}[\\s\\S]*?<\\/li>(?:<br\\/>)?)+`,"g");s=s.replace(f('<li class="ml-8 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(f('<li class="ml-4 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(f('<li class="ml-4 list-decimal'),g=>`<ol class="list-decimal mb-3">${g}</ol>`),s=s.replace(/\x00CODE(\d+)\x00/g,(g,y)=>n[parseInt(y,10)]);const h="text-xs leading-relaxed text-text-secondary mb-2",m=/<\/(h[1-4]|pre|table|ul|ol|hr|div)>/;return s=s.split("\0PARA\0").map(g=>{const y=g.trim();if(!y)return"";const E=[];let w=y,T;for(;(T=m.exec(w))!==null;){const q=T.index+T[0].length;E.push(w.slice(0,q)),w=w.slice(q).replace(/^<br\/>/,"").trim(),m.lastIndex=0}return w&&E.push(w),E.map(q=>{const M=q.trim();return M?/^\s*<(h[1-4]|pre|table|ul|ol|hr|div)/.test(M)?M:`<p class="${h}">${M}</p>`:""}).join("")}).join(""),s}const tS=/(\*\*|^#{1,4}\s|^- |^\d+\.\s|```|^\|.*\|$|\[.+\]\(.+\))/m;function nS(r){return tS.test(r)}function ph({content:r,className:n,onClick:s}){const a=O.useMemo(()=>eS(r),[r]);return d.jsx("div",{className:n,onClick:s,dangerouslySetInnerHTML:{__html:a}})}function Lo({data:r,depth:n=0,generation:s}){const o=s!==void 0&&s>0&&s%2===1?!1:n>0,[f,h]=O.useState(o),[m,g]=O.useState(s);if(s!==void 0&&s!==m&&(g(s),h(s%2===0&&n>0)),r==null)return d.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof r=="string")return d.jsxs("span",{className:"text-text-primary",children:['"',r,'"']});if(typeof r=="number"||typeof r=="boolean")return d.jsx("span",{className:"text-text-primary font-medium",children:String(r)});if(Array.isArray(r))return r.length===0?d.jsx("span",{className:"text-text-tertiary",children:"[]"}):f?d.jsxs("button",{onClick:()=>h(!1),className:"text-text-secondary hover:text-text-primary",children:["[",r.length," items]"]}):d.jsxs("span",{children:[d.jsx("button",{onClick:()=>h(!0),className:"text-text-tertiary hover:text-text-primary",children:"["}),d.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:r.map((y,E)=>d.jsxs("div",{children:[d.jsx(Lo,{data:y,depth:n+1,generation:s}),E<r.length-1&&d.jsx("span",{className:"text-text-tertiary",children:","})]},E))}),d.jsx("span",{className:"text-text-tertiary",children:"]"})]});if(typeof r=="object"){const y=Object.entries(r);return y.length===0?d.jsx("span",{className:"text-text-tertiary",children:"{}"}):f?d.jsxs("button",{onClick:()=>h(!1),className:"text-text-secondary hover:text-text-primary",children:["{","...","}"]}):d.jsxs("span",{children:[d.jsx("button",{onClick:()=>h(!0),className:"text-text-tertiary hover:text-text-primary",children:"{"}),d.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:y.map(([E,w],T)=>d.jsxs("div",{children:[d.jsx("span",{className:"text-text-secondary",children:E}),d.jsx("span",{className:"text-text-tertiary",children:": "}),d.jsx(Lo,{data:w,depth:n+1,generation:s}),T<y.length-1&&d.jsx("span",{className:"text-text-tertiary",children:","})]},E))}),d.jsx("span",{className:"text-text-tertiary",children:"}"})]})}return d.jsx("span",{children:String(r)})}function Ba({data:r,depth:n=0}){if(r==null)return d.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof r=="string")return r.length>40&&nS(r)?d.jsx(ph,{content:r}):d.jsx("span",{className:"text-text-primary",children:r});if(typeof r=="number"||typeof r=="boolean")return d.jsx("span",{className:"text-text-primary font-medium",children:String(r)});if(Array.isArray(r))return r.length===0?d.jsx("span",{className:"text-text-tertiary italic",children:"empty list"}):d.jsx("div",{className:"space-y-2",children:r.map((s,a)=>d.jsxs("div",{className:"flex items-baseline gap-2",children:[d.jsxs("span",{className:"text-text-tertiary text-[10px] shrink-0",children:[a+1,"."]}),d.jsx("div",{className:"flex-1",children:d.jsx(Ba,{data:s,depth:n+1})})]},a))});if(typeof r=="object"){const s=Object.entries(r);return s.length===0?d.jsx("span",{className:"text-text-tertiary italic",children:"empty"}):d.jsx("div",{className:n>0?"pl-4 border-l border-surface-border space-y-3":"space-y-3",children:s.map(([a,o])=>{const f=o===null||typeof o!="object";return d.jsxs("div",{children:[d.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:a.replace(/[_-]/g," ")}),f?d.jsx("p",{className:"text-sm text-text-primary",children:d.jsx(Ba,{data:o,depth:n+1})}):d.jsx(Ba,{data:o,depth:n+1})]},a)})})}return d.jsx("span",{children:String(r)})}function F0({mode:r,setMode:n,isCollapsed:s,onToggleCollapse:a,onCopy:o,copied:f,onFullscreen:h,onClose:m,large:g}){const y=g?"w-5 h-5":"w-3.5 h-3.5",E=`${g?"p-2":"p-1.5"} rounded text-text-tertiary hover:text-text-primary hover:bg-surface-raised transition-colors duration-150`;return d.jsxs("div",{className:"flex items-center gap-0.5 bg-surface-sunken/80 rounded-md backdrop-blur-sm",children:[r==="json"&&d.jsx("button",{onClick:a,className:E,title:s?"Expand all":"Collapse all",children:s?d.jsx(Zw,{className:y}):d.jsx(Kw,{className:y})}),d.jsx("button",{onClick:()=>n(r==="json"?"tree":"json"),className:E,title:r==="json"?"Outline view":"JSON view",children:r==="json"?d.jsx(Jw,{className:y}):d.jsx(Iw,{className:y})}),d.jsx("button",{onClick:o,className:E,title:"Copy to clipboard",children:f?d.jsx(Xw,{className:`${y} text-status-success`}):d.jsx(Qw,{className:y})}),h&&d.jsx("button",{onClick:h,className:E,title:"Fullscreen",children:d.jsx(yg,{className:y})}),m&&d.jsx("button",{onClick:m,className:E,title:"Close (Esc)",children:d.jsx(bg,{className:y})})]})}function sS({data:r,label:n,variant:s,defaultCollapsed:a=!1,defaultMode:o}){const f=O.useRef(null),[h,m]=O.useState(o??"json"),[g,y]=O.useState(!1),[E,w]=O.useState(!1),[T,q]=O.useState(a?0:1),[M,R]=O.useState(1),G=T%2===0,ne=M%2===0,ee=O.useCallback(()=>q(Z=>Z+1),[]),me=O.useCallback(()=>R(Z=>Z+1),[]);let re=r;if(typeof r=="string")try{re=JSON.parse(r)}catch{}const C=async()=>{const Z=typeof r=="string"?r:JSON.stringify(re,null,2);await navigator.clipboard.writeText(Z),y(!0),setTimeout(()=>y(!1),2e3)},K=O.useCallback(()=>{R(1),w(!0)},[]),ce=s==="panel",F=ce?"border border-accent-muted/40 rounded-lg p-3 bg-surface-hover/30":"",V=ce?"font-mono text-xs leading-relaxed bg-white rounded-md p-4 overflow-x-auto break-all":"font-mono text-xs leading-relaxed bg-surface-sunken rounded-md p-4 overflow-x-auto break-all";return d.jsxs("div",{className:F,children:[n&&d.jsx(Vw,{children:n}),d.jsxs("div",{ref:f,className:"relative",children:[d.jsx("div",{className:"absolute top-2 right-2 z-[5]",children:d.jsx(F0,{mode:h,setMode:m,isCollapsed:G,onToggleCollapse:ee,onCopy:C,copied:g,onFullscreen:K})}),d.jsx("div",{className:V,children:h==="json"?d.jsx(Lo,{data:re,generation:T}):d.jsx(Ba,{data:re})})]}),d.jsxs(oy,{open:E,onClose:()=>w(!1),sourceRef:f,children:[d.jsx("div",{className:"sticky top-0 float-right z-10",children:d.jsx(F0,{mode:h,setMode:m,isCollapsed:ne,onToggleCollapse:me,onCopy:C,copied:g,onClose:()=>w(!1),large:!0})}),d.jsx("div",{className:"font-mono text-sm leading-relaxed",children:h==="json"?d.jsx(Lo,{data:re,generation:M}):d.jsx(Ba,{data:re})})]})]})}const iS=100,J0=500;let rS=0;const cy={"escalation.created":"text-status-active","escalation.claimed":"text-status-warning","escalation.released":"text-text-tertiary","escalation.resolved":"text-status-success","task.created":"text-accent","task.completed":"text-status-success","task.failed":"text-status-error","task.escalated":"text-status-warning","workflow.started":"text-accent","workflow.completed":"text-status-success","workflow.failed":"text-status-error","activity.started":"text-status-active","activity.completed":"text-status-success","activity.failed":"text-status-error","knowledge.stored":"text-accent","knowledge.deleted":"text-text-tertiary","agent.started":"text-accent","agent.completed":"text-status-success","agent.failed":"text-status-error","agent.status_changed":"text-status-active",milestone:"text-accent"};function uy(r){const n=r.split(".");return n[0]==="system"&&n.length>=3?`${n[1]}.${n[n.length-1]}`:r}function I0({event:r,forceExpanded:n=!1}){var T,q;const[s,a]=O.useState(n),o=cy[uy(r.type)]||"text-text-tertiary";O.useEffect(()=>{a(n)},[n]);const f=n,h=f?"text-xs":"text-[9px]",m=f?"text-xs":"text-[9px]",g=f?"text-xs":"text-[9px]",y=f?"w-3.5 h-3.5":"w-2.5 h-2.5",E=f?"py-2 px-4":"py-1 px-3",w=f?"pb-4 px-4":"pb-2 px-3";return d.jsxs("div",{className:"border-b border-surface-border/30 last:border-b-0",children:[d.jsxs("button",{onClick:()=>a(!s),className:`flex items-center gap-2 ${E} w-full text-left hover:bg-surface-hover/50 transition-colors`,children:[d.jsx("span",{className:`${h} font-mono text-text-tertiary whitespace-nowrap tabular-nums shrink-0`,children:new Date(r.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),d.jsx("span",{className:`${m} font-medium px-1 py-0.5 rounded ${o} bg-surface-sunken whitespace-nowrap shrink-0`,children:r.type}),d.jsxs("span",{className:`${g} text-text-tertiary font-mono flex-1 min-w-0 truncate`,children:[(T=r.data)!=null&&T.workflowId?String(r.data.workflowId):"",(q=r.data)!=null&&q.escalationId?` esc:${String(r.data.escalationId).slice(0,12)}`:""]}),d.jsx("svg",{className:`${y} text-text-tertiary shrink-0 transition-transform duration-150 ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),d.jsx(mh,{open:s,children:d.jsx("div",{className:w,children:d.jsx(sS,{data:r.data})})})]})}function aS({open:r,onToggle:n,configOpen:s,onToggleConfig:a}){const[o,f]=O.useState([]),[h,m]=O.useState(!1),[g,y]=O.useState(""),E=O.useRef(null),w=O.useRef(new Map),{subscribe:T}=O.useContext(Fa),{patterns:q,pagePattern:M,userPatterns:R,addPattern:G,removePattern:ne}=Gw(),ee=O.useCallback(re=>{const C=String(re.type||"unknown");if(C.startsWith("mesh."))return;const K=`${C}:${re.timestamp||""}:${re.escalationId||re.workflowId||re.taskId||""}`,ce=Date.now(),F=w.current.get(K);if(!(F&&ce-F<J0)){if(w.current.set(K,ce),w.current.size>200)for(const[V,Z]of w.current)ce-Z>J0*2&&w.current.delete(V);f(V=>[{id:++rS,type:C,timestamp:re.timestamp||new Date().toISOString(),data:re},...V].slice(0,iS))}},[]),me=O.useRef(ee);return me.current=ee,O.useEffect(()=>{const re=q.map(C=>T(C,K=>me.current(K)));return()=>re.forEach(C=>C())},[T,q.join(",")]),O.useEffect(()=>{r&&E.current&&(E.current.scrollTop=0)},[o.length,r]),d.jsxs("div",{className:"shrink-0 border-t border-surface-border bg-surface-raised",children:[d.jsxs("button",{onClick:n,className:"flex items-center gap-2 w-full px-4 py-1.5 text-left hover:bg-surface-hover transition-colors",children:[r?d.jsx(Xx,{className:"w-3 h-3 text-text-tertiary"}):d.jsx(Kx,{className:"w-3 h-3 text-text-tertiary"}),d.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:"Event Stream"}),o.length>0&&d.jsxs("span",{className:"text-[9px] text-text-tertiary",children:[o.length," events"]}),o.length>0&&!r&&d.jsx("span",{className:`text-[9px] font-medium px-1 py-0.5 rounded ${cy[uy(o[0].type)]||"text-text-tertiary"} bg-surface-sunken`,children:o[0].type}),d.jsxs("span",{className:"ml-auto flex items-center gap-1",children:[d.jsx("span",{className:`p-0.5 cursor-pointer ${s?"text-accent":"text-text-tertiary hover:text-text-primary"}`,title:"Subscription config",onClick:re=>{re.stopPropagation(),a()},children:d.jsx(Zx,{className:"w-3 h-3"})}),o.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Fullscreen",onClick:re=>{re.stopPropagation(),m(!0)},children:d.jsx(yg,{className:"w-3 h-3"})}),d.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Clear events",onClick:re=>{re.stopPropagation(),f([])},children:d.jsx(Wx,{className:"w-3 h-3"})})]})]})]}),s&&d.jsxs("div",{className:"px-4 py-2 border-t border-surface-border/50 bg-surface-sunken/30",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-1.5",children:[d.jsx("span",{className:"text-[9px] text-text-quaternary uppercase tracking-wider shrink-0",children:"Subscribed:"}),d.jsx("span",{className:"text-[9px] font-mono text-accent px-1.5 py-0.5 bg-accent/10 rounded",children:M.replace("lt.events.","")}),R.map(re=>d.jsxs("span",{className:"inline-flex items-center gap-1 text-[9px] font-mono text-text-secondary px-1.5 py-0.5 bg-surface-sunken rounded",children:[re.replace("lt.events.",""),d.jsx("button",{onClick:()=>ne(re),className:"text-text-quaternary hover:text-status-error",children:d.jsx($o,{className:"w-2 h-2"})})]},re))]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("input",{type:"text",value:g,onChange:re=>y(re.target.value),onKeyDown:re=>{re.key==="Enter"&&g.trim()&&(G(g.trim()),y(""))},placeholder:"task.> or file.stored",className:"input text-[10px] font-mono flex-1 py-1"}),d.jsxs("button",{onClick:()=>{g.trim()&&(G(g.trim()),y(""))},className:"text-[10px] text-accent hover:text-accent-hover flex items-center gap-0.5",children:[d.jsx(ev,{className:"w-2.5 h-2.5"})," Add"]})]})]}),d.jsx(mh,{open:r,children:d.jsx("div",{ref:E,className:"h-48 overflow-y-auto",children:o.length===0?d.jsx("p",{className:"text-[10px] text-text-tertiary py-4 text-center",children:"Waiting for events..."}):o.map(re=>d.jsx(I0,{event:re},re.id))})}),d.jsxs(oy,{open:h,onClose:()=>m(!1),sourceRef:E,children:[d.jsx("div",{className:"sticky top-0 float-right z-10",children:d.jsx("button",{onClick:()=>m(!1),className:"p-2 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-raised transition-colors duration-150 bg-surface-sunken/80 backdrop-blur-sm",title:"Close (Esc)",children:d.jsx(bg,{className:"w-5 h-5"})})}),o.length===0?d.jsx("p",{className:"text-sm text-text-tertiary py-8",children:"No events captured"}):o.map(re=>d.jsx(I0,{event:re,forceExpanded:!0},re.id))]})]})}function lS(){return _n({queryKey:["docs"],queryFn:()=>$e("/docs"),staleTime:5*6e4})}function oS(r){return _n({queryKey:["docs",r],queryFn:()=>$e(`/docs/read?path=${encodeURIComponent(r)}`),enabled:!!r,staleTime:5*6e4})}function cS(){const[r,n]=O.useState([]),[s,a]=O.useState([]),[o,f]=O.useState(null),h=O.useRef(o),m=O.useRef(r),g=O.useRef(s);h.current=o,m.current=r,g.current=s;const y=O.useCallback((M,R)=>{var ne;const G=h.current;if(G){const ee=((ne=R==null?void 0:R.current)==null?void 0:ne.scrollTop)??0;n([...m.current,{...G,scrollTop:ee}])}a([]),f({path:M,scrollTop:0})},[]),E=O.useCallback(M=>{var ee;const R=m.current;if(R.length===0)return;const G=R[R.length-1],ne=h.current;if(ne){const me=((ee=M==null?void 0:M.current)==null?void 0:ee.scrollTop)??0;a([...g.current,{...ne,scrollTop:me}])}n(R.slice(0,-1)),f(G),requestAnimationFrame(()=>{M!=null&&M.current&&(M.current.scrollTop=G.scrollTop)})},[]),w=O.useCallback(M=>{var ee;const R=g.current;if(R.length===0)return;const G=R[R.length-1],ne=h.current;if(ne){const me=((ee=M==null?void 0:M.current)==null?void 0:ee.scrollTop)??0;n([...m.current,{...ne,scrollTop:me}])}a(R.slice(0,-1)),f(G),requestAnimationFrame(()=>{M!=null&&M.current&&(M.current.scrollTop=G.scrollTop)})},[]),T=O.useCallback(M=>{var ne,ee;const R=h.current;if(!R)return;const G=((ne=M==null?void 0:M.current)==null?void 0:ne.scrollTop)??0;n([...m.current,{...R,scrollTop:G}]),a([]),f({...R,scrollTop:((ee=M==null?void 0:M.current)==null?void 0:ee.scrollTop)??0})},[]),q=O.useCallback(()=>{n([]),a([]),f(null)},[]);return{current:o,backStack:r,forwardStack:s,navigate:y,goBack:E,goForward:w,pushScrollPosition:T,reset:q}}function uS(r,n){const[s,a]=r.split("#");let o=s;if(o.startsWith("./")||o.startsWith("../")){const h=((n?n.replace(/[^/]+$/,""):"")+o).split("/"),m=[];for(const g of h)g===".."?m.pop():g&&g!=="."&&m.push(g);o=m.join("/")}return{path:o,anchor:a}}function fS(r){if(!r.startsWith("#docs"))return null;const n=r.slice(1).split(":"),s=n[1]||"README.md",a=n[2]||void 0;return{path:s,anchor:a}}function hS(r){return!r||r==="README.md"?"#docs":`#docs:${r}`}function dS({content:r,currentPath:n,onNavigate:s,onAnchorClick:a}){const o=f=>{var y;const h=f.target,m=h.closest("[data-anchor]");if(m){f.preventDefault(),a();const E=m.dataset.anchor,w=(y=m.closest(".docs-content"))==null?void 0:y.querySelector(`#${CSS.escape(E)}`);w==null||w.scrollIntoView({behavior:"smooth",block:"start"});return}const g=h.closest("[data-doc-link]");if(g){f.preventDefault();const{path:E,anchor:w}=uS(g.dataset.docLink,n);s(E,w);return}};return d.jsx(ph,{content:r,className:"docs-content",onClick:o})}function mS(r){const n=[],s=new Map;for(const a of r){const o=a.path.split("/");if(o.length===1){n.push(a);continue}let f=s;for(let h=0;h<o.length-1;h++){const m=o[h];f.has(m)||f.set(m,{label:m,children:[],subdirs:new Map});const g=f.get(m);h===o.length-2?g.children.push(a):f=g.subdirs}}return{topLevel:n,dirs:s}}function pS({docs:r,selected:n,onSelect:s}){const{topLevel:a,dirs:o}=mS(r),f=m=>`block w-full text-left px-3 py-1 text-xs rounded truncate transition-colors ${n===m?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-hover"}`;function h(m,g){return d.jsxs("details",{open:!0,children:[d.jsxs("summary",{className:"flex items-center gap-1.5 px-3 py-1 text-[10px] font-semibold uppercase tracking-widest text-text-tertiary cursor-pointer",children:[d.jsx(tv,{className:"w-3 h-3",strokeWidth:1.5}),m.label]}),d.jsxs("div",{className:"pl-2 space-y-0.5",children:[[...m.subdirs.values()].map(y=>h(y)),m.children.map(y=>d.jsx("button",{className:f(y.path),onClick:()=>s(y.path),children:y.title},y.path))]})]},m.label)}return d.jsxs("div",{className:"space-y-0.5",children:[a.map(m=>d.jsx("button",{className:f(m.path),onClick:()=>s(m.path),children:m.title},m.path)),[...o.values()].map(m=>h(m))]})}function gS({open:r,onClose:n}){var ce,F,V;const[s,a]=O.useState(!1),{data:o}=lS(),f=cS(),{data:h,isLoading:m}=oS(((ce=f.current)==null?void 0:ce.path)??null),g=O.useRef(null),[y,E]=O.useState(null);O.useEffect(()=>{y&&(h!=null&&h.content)&&g.current&&requestAnimationFrame(()=>{var ae;const Z=(ae=g.current)==null?void 0:ae.querySelector(`#${CSS.escape(y)}`);Z==null||Z.scrollIntoView({behavior:"smooth",block:"start"}),E(null)})},[y,h]);const w=O.useCallback(()=>{var se;const Z=fS(window.location.hash),ae=(Z==null?void 0:Z.path)??"README.md";((se=f.current)==null?void 0:se.path)!==ae&&f.navigate(ae,g),Z!=null&&Z.anchor&&E(Z.anchor)},[f]),T=O.useRef(!0);O.useEffect(()=>{if(!r||!f.current)return;if(T.current){T.current=!1;return}const Z=hS(f.current.path);window.location.hash!==Z&&window.history.replaceState(null,"",window.location.pathname+window.location.search+Z)},[r,(F=f.current)==null?void 0:F.path]),O.useEffect(()=>{if(!r)return;const Z=()=>{window.location.hash.startsWith("#docs")&&w()};return window.addEventListener("hashchange",Z),()=>window.removeEventListener("hashchange",Z)},[r,w]);const q=O.useCallback((Z,ae)=>{ae&&E(ae),f.navigate(Z,g)},[f]),M=O.useCallback(Z=>{f.navigate(Z,g)},[f]),R=O.useCallback(()=>{f.goBack(g)},[f]),G=O.useCallback(()=>{f.goForward(g)},[f]),ne=O.useCallback(()=>{f.pushScrollPosition(g)},[f]);if(O.useEffect(()=>{if(r){T.current=!0,w();const Z=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(Z)}},[r]),!(r||s))return null;const me=()=>{a(!1),setTimeout(()=>{n(),f.reset()},200)},re=((V=f.current)==null?void 0:V.path)??null,C=f.backStack.length>0,K=f.forwardStack.length>0;return d.jsxs("div",{className:"fixed inset-y-0 right-0 z-50 flex",children:[d.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${s&&r?"opacity-100":"opacity-0"}`,onClick:me}),d.jsxs("div",{className:`relative ml-auto w-[40vw] min-w-[800px] max-w-[90vw] h-full bg-surface-raised border-l border-surface-border flex flex-col shadow-xl transition-transform duration-200 ease-out ${s&&r?"translate-x-0":"translate-x-full"}`,children:[d.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border shrink-0",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{onClick:R,disabled:!C,className:`p-0.5 transition-colors ${C?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Back",children:d.jsx(nv,{className:"w-4 h-4"})}),d.jsx("button",{onClick:G,disabled:!K,className:`p-0.5 transition-colors ${K?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Forward",children:d.jsx(a0,{className:"w-4 h-4"})}),d.jsx(gg,{className:"w-4 h-4 text-accent ml-1",strokeWidth:1.5}),d.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Documentation"})]}),d.jsx("button",{onClick:me,className:"p-1 text-text-tertiary hover:text-text-primary",children:d.jsx($o,{className:"w-4 h-4"})})]}),d.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[d.jsx("div",{className:"w-48 shrink-0 border-r border-surface-border overflow-y-auto py-2",children:o!=null&&o.docs?d.jsx(pS,{docs:o.docs,selected:re,onSelect:M}):d.jsx("div",{className:"px-3 py-2 text-xs text-text-tertiary",children:"Loading..."})}),d.jsx("div",{ref:g,className:"flex-1 overflow-y-auto px-6 py-4",children:re?m?d.jsxs("div",{className:"animate-pulse space-y-2",children:[d.jsx("div",{className:"h-6 bg-surface-sunken rounded w-48"}),d.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),d.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}):h!=null&&h.content?d.jsx(dS,{content:h.content,currentPath:re,onNavigate:q,onAnchorClick:ne}):d.jsx("p",{className:"text-xs text-text-tertiary",children:"Document not found."}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-tertiary",children:[d.jsx(a0,{className:"w-5 h-5 mb-2"}),d.jsx("p",{className:"text-xs",children:"Select a document"})]})})]})]})]})}function yS(r){if(r.includes("/escalations"))return["escalation","human-queue"]}const Q0=2e3;function bS(r){const s=r.filter(o=>!o.pending).slice(-8);return s.length===0?"":`[Prior conversation]
@@ -59,5 +59,5 @@ ${s.map(o=>`${o.role==="user"?"User":"Assistant"}: ${o.content}`).join(`
59
59
  [End prior conversation]
60
60
 
61
61
  `}function xS(r){const n=r.summary,s=r.title;if(n){const a=n.search(/\n\s*\{[\s\S]*"title"\s*:/);return a>0?n.slice(0,a).trim():n}return s||(typeof r=="string"?r:"Query completed.")}const fy=O.createContext(null);function vS({children:r}){const n=ei(),[s,a]=O.useState(!1),[o,f]=O.useState([]),[h,m]=O.useState(null),[g,y]=O.useState({}),E=O.useRef(null),w={page:n.pathname.split("/").filter(Boolean).join("-")||"home",route:n.pathname,params:{},...g,suggestedTags:g.suggestedTags??yS(n.pathname)};O.useEffect(()=>()=>{E.current&&clearInterval(E.current)},[]);const T=O.useCallback(()=>a(ne=>!ne),[]),q=O.useCallback(ne=>{y(ne)},[]),M=O.useCallback(()=>{f([]),m(null)},[]),R=O.useCallback(async ne=>{var F;const ee=new Date().toISOString(),me={id:`user-${Date.now()}`,role:"user",content:ne,timestamp:ee},re={id:`pending-${Date.now()}`,role:"assistant",content:"",timestamp:ee,pending:!0};f(V=>[...V,me,re]);const C={...w};(F=C.entities)!=null&&F.yamlContent&&C.entities.yamlContent.length>Q0&&(C.entities={...C.entities,yamlContent:C.entities.yamlContent.slice(0,Q0)+`
62
- ... (truncated)`});const ce=`${bS(o.concat(me))}${ne}`;try{const Z=(await $e("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ce,tags:C.suggestedTags,context:C,wait:!1,direct:!0})})).workflow_id;m(Z),f(ae=>ae.map(se=>se.id===re.id?{...se,workflowId:Z}:se)),E.current&&clearInterval(E.current),E.current=setInterval(async()=>{var ae;try{const se=await $e(`/workflows/${Z}/result`),ke=(ae=se==null?void 0:se.result)==null?void 0:ae.data;if(ke){E.current&&clearInterval(E.current),E.current=null,m(null);const He=xS(ke);let Me;try{Me=(await $e(`/workflow-states/${Z}/execution`)).duration_ms}catch{}f($=>$.map(te=>te.id===re.id?{...te,content:He,timestamp:new Date().toISOString(),pending:!1,durationMs:Me}:te))}}catch{}},3e3)}catch{f(V=>V.map(Z=>Z.id===re.id?{...Z,content:"Failed to submit query. Please try again.",pending:!1}:Z))}},[o,w]),G=O.useCallback(async ne=>{const ee=o.find(C=>C.id===ne);if(!(ee!=null&&ee.workflowId)||ee.compilationStatus==="compiling"||ee.compilationStatus==="done")return;const me=o.indexOf(ee),re=o.slice(0,me).reverse().find(C=>C.role==="user");if(re){f(C=>C.map(K=>K.id===ne?{...K,compilationStatus:"compiling"}:K));try{const C=await $e("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:re.content,summary:ee.content})}),K=await $e("/yaml-workflows",{method:"POST",body:JSON.stringify({workflow_id:ee.workflowId,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:C.tool_name,description:C.description,tags:C.tags,app_id:""})});await $e(`/yaml-workflows/${K.id}/deploy`,{method:"POST"}),f(ce=>ce.map(F=>F.id===ne?{...F,compilationStatus:"done"}:F))}catch(C){const K=C instanceof Error?C.message:"Compilation failed";f(ce=>ce.map(F=>F.id===ne?{...F,compilationStatus:"error",compilationError:K}:F))}}},[o]);return d.jsx(fy.Provider,{value:{helpOpen:s,setHelpOpen:a,toggleHelp:T,messages:o,sendMessage:R,pageContext:w,setPageContext:q,activeWorkflowId:h,clearMessages:M,compileMessage:G},children:r})}function hy(){const r=O.useContext(fy);if(!r)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return r}function _S(){const{helpOpen:r,toggleHelp:n}=hy();return d.jsx("button",{onClick:n,className:"fixed right-3 z-[45] flex items-center justify-center w-10 h-10 rounded-full bg-surface-raised shadow-lg hover:scale-110 transition-transform duration-150 border border-accent/30",style:{bottom:"44px"},"aria-label":r?"Close help":"Ask for help",children:r?d.jsx($o,{className:"w-5 h-5 text-text-tertiary",strokeWidth:1.5}):d.jsx("span",{role:"img","aria-label":"Help",className:"logo-mark w-8 h-8 -rotate-[120deg]",style:{"--logo-url":`url(${Wt}/logo512.png)`}})})}const dy=6048e5,wS=864e5,X0=6e4,K0=525600,Z0=43200,W0=1440,eg=Symbol.for("constructDateFrom");function ds(r,n){return typeof r=="function"?r(n):r&&typeof r=="object"&&eg in r?r[eg](n):r instanceof Date?new r.constructor(n):new Date(n)}function sn(r,n){return ds(n||r,r)}let SS={};function Ja(){return SS}function Ya(r,n){var m,g,y,E;const s=Ja(),a=(n==null?void 0:n.weekStartsOn)??((g=(m=n==null?void 0:n.locale)==null?void 0:m.options)==null?void 0:g.weekStartsOn)??s.weekStartsOn??((E=(y=s.locale)==null?void 0:y.options)==null?void 0:E.weekStartsOn)??0,o=sn(r,n==null?void 0:n.in),f=o.getDay(),h=(f<a?7:0)+f-a;return o.setDate(o.getDate()-h),o.setHours(0,0,0,0),o}function Ho(r,n){return Ya(r,{...n,weekStartsOn:1})}function my(r,n){const s=sn(r,n==null?void 0:n.in),a=s.getFullYear(),o=ds(s,0);o.setFullYear(a+1,0,4),o.setHours(0,0,0,0);const f=Ho(o),h=ds(s,0);h.setFullYear(a,0,4),h.setHours(0,0,0,0);const m=Ho(h);return s.getTime()>=f.getTime()?a+1:s.getTime()>=m.getTime()?a:a-1}function Po(r){const n=sn(r),s=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()));return s.setUTCFullYear(n.getFullYear()),+r-+s}function py(r,...n){const s=ds.bind(null,r||n.find(a=>typeof a=="object"));return n.map(s)}function tg(r,n){const s=sn(r,n==null?void 0:n.in);return s.setHours(0,0,0,0),s}function ES(r,n,s){const[a,o]=py(s==null?void 0:s.in,r,n),f=tg(a),h=tg(o),m=+f-Po(f),g=+h-Po(h);return Math.round((m-g)/wS)}function AS(r,n){const s=my(r,n),a=ds(r,0);return a.setFullYear(s,0,4),a.setHours(0,0,0,0),Ho(a)}function jS(r,n){const s=+sn(r)-+sn(n);return s<0?-1:s>0?1:s}function OS(r){return ds(r,Date.now())}function TS(r){return r instanceof Date||typeof r=="object"&&Object.prototype.toString.call(r)==="[object Date]"}function NS(r){return!(!TS(r)&&typeof r!="number"||isNaN(+sn(r)))}function CS(r){return n=>{const a=(r?Math[r]:Math.trunc)(n);return a===0?0:a}}function kS(r,n){const s=sn(r,n==null?void 0:n.in);return s.setFullYear(s.getFullYear(),0,1),s.setHours(0,0,0,0),s}const MS={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},RS=(r,n,s)=>{let a;const o=MS[r];return typeof o=="string"?a=o:n===1?a=o.one:a=o.other.replace("{{count}}",n.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+a:a+" ago":a};function Sf(r){return(n={})=>{const s=n.width?String(n.width):r.defaultWidth;return r.formats[s]||r.formats[r.defaultWidth]}}const DS={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},zS={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},qS={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},US={date:Sf({formats:DS,defaultWidth:"full"}),time:Sf({formats:zS,defaultWidth:"full"}),dateTime:Sf({formats:qS,defaultWidth:"full"})},BS={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},LS=(r,n,s,a)=>BS[r];function Ta(r){return(n,s)=>{const a=s!=null&&s.context?String(s.context):"standalone";let o;if(a==="formatting"&&r.formattingValues){const h=r.defaultFormattingWidth||r.defaultWidth,m=s!=null&&s.width?String(s.width):h;o=r.formattingValues[m]||r.formattingValues[h]}else{const h=r.defaultWidth,m=s!=null&&s.width?String(s.width):r.defaultWidth;o=r.values[m]||r.values[h]}const f=r.argumentCallback?r.argumentCallback(n):n;return o[f]}}const HS={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},PS={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},$S={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},YS={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},GS={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},VS={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},FS=(r,n)=>{const s=Number(r),a=s%100;if(a>20||a<10)switch(a%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},JS={ordinalNumber:FS,era:Ta({values:HS,defaultWidth:"wide"}),quarter:Ta({values:PS,defaultWidth:"wide",argumentCallback:r=>r-1}),month:Ta({values:$S,defaultWidth:"wide"}),day:Ta({values:YS,defaultWidth:"wide"}),dayPeriod:Ta({values:GS,defaultWidth:"wide",formattingValues:VS,defaultFormattingWidth:"wide"})};function Na(r){return(n,s={})=>{const a=s.width,o=a&&r.matchPatterns[a]||r.matchPatterns[r.defaultMatchWidth],f=n.match(o);if(!f)return null;const h=f[0],m=a&&r.parsePatterns[a]||r.parsePatterns[r.defaultParseWidth],g=Array.isArray(m)?QS(m,w=>w.test(h)):IS(m,w=>w.test(h));let y;y=r.valueCallback?r.valueCallback(g):g,y=s.valueCallback?s.valueCallback(y):y;const E=n.slice(h.length);return{value:y,rest:E}}}function IS(r,n){for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)&&n(r[s]))return s}function QS(r,n){for(let s=0;s<r.length;s++)if(n(r[s]))return s}function XS(r){return(n,s={})=>{const a=n.match(r.matchPattern);if(!a)return null;const o=a[0],f=n.match(r.parsePattern);if(!f)return null;let h=r.valueCallback?r.valueCallback(f[0]):f[0];h=s.valueCallback?s.valueCallback(h):h;const m=n.slice(o.length);return{value:h,rest:m}}}const KS=/^(\d+)(th|st|nd|rd)?/i,ZS=/\d+/i,WS={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},e2={any:[/^b/i,/^(a|c)/i]},t2={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},n2={any:[/1/i,/2/i,/3/i,/4/i]},s2={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},i2={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},r2={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},a2={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},l2={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},o2={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},c2={ordinalNumber:XS({matchPattern:KS,parsePattern:ZS,valueCallback:r=>parseInt(r,10)}),era:Na({matchPatterns:WS,defaultMatchWidth:"wide",parsePatterns:e2,defaultParseWidth:"any"}),quarter:Na({matchPatterns:t2,defaultMatchWidth:"wide",parsePatterns:n2,defaultParseWidth:"any",valueCallback:r=>r+1}),month:Na({matchPatterns:s2,defaultMatchWidth:"wide",parsePatterns:i2,defaultParseWidth:"any"}),day:Na({matchPatterns:r2,defaultMatchWidth:"wide",parsePatterns:a2,defaultParseWidth:"any"}),dayPeriod:Na({matchPatterns:l2,defaultMatchWidth:"any",parsePatterns:o2,defaultParseWidth:"any"})},gy={code:"en-US",formatDistance:RS,formatLong:US,formatRelative:LS,localize:JS,match:c2,options:{weekStartsOn:0,firstWeekContainsDate:1}};function u2(r,n){const s=sn(r,n==null?void 0:n.in);return ES(s,kS(s))+1}function f2(r,n){const s=sn(r,n==null?void 0:n.in),a=+Ho(s)-+AS(s);return Math.round(a/dy)+1}function yy(r,n){var E,w,T,q;const s=sn(r,n==null?void 0:n.in),a=s.getFullYear(),o=Ja(),f=(n==null?void 0:n.firstWeekContainsDate)??((w=(E=n==null?void 0:n.locale)==null?void 0:E.options)==null?void 0:w.firstWeekContainsDate)??o.firstWeekContainsDate??((q=(T=o.locale)==null?void 0:T.options)==null?void 0:q.firstWeekContainsDate)??1,h=ds((n==null?void 0:n.in)||r,0);h.setFullYear(a+1,0,f),h.setHours(0,0,0,0);const m=Ya(h,n),g=ds((n==null?void 0:n.in)||r,0);g.setFullYear(a,0,f),g.setHours(0,0,0,0);const y=Ya(g,n);return+s>=+m?a+1:+s>=+y?a:a-1}function h2(r,n){var m,g,y,E;const s=Ja(),a=(n==null?void 0:n.firstWeekContainsDate)??((g=(m=n==null?void 0:n.locale)==null?void 0:m.options)==null?void 0:g.firstWeekContainsDate)??s.firstWeekContainsDate??((E=(y=s.locale)==null?void 0:y.options)==null?void 0:E.firstWeekContainsDate)??1,o=yy(r,n),f=ds((n==null?void 0:n.in)||r,0);return f.setFullYear(o,0,a),f.setHours(0,0,0,0),Ya(f,n)}function d2(r,n){const s=sn(r,n==null?void 0:n.in),a=+Ya(s,n)-+h2(s,n);return Math.round(a/dy)+1}function Ve(r,n){const s=r<0?"-":"",a=Math.abs(r).toString().padStart(n,"0");return s+a}const Vs={y(r,n){const s=r.getFullYear(),a=s>0?s:1-s;return Ve(n==="yy"?a%100:a,n.length)},M(r,n){const s=r.getMonth();return n==="M"?String(s+1):Ve(s+1,2)},d(r,n){return Ve(r.getDate(),n.length)},a(r,n){const s=r.getHours()/12>=1?"pm":"am";switch(n){case"a":case"aa":return s.toUpperCase();case"aaa":return s;case"aaaaa":return s[0];case"aaaa":default:return s==="am"?"a.m.":"p.m."}},h(r,n){return Ve(r.getHours()%12||12,n.length)},H(r,n){return Ve(r.getHours(),n.length)},m(r,n){return Ve(r.getMinutes(),n.length)},s(r,n){return Ve(r.getSeconds(),n.length)},S(r,n){const s=n.length,a=r.getMilliseconds(),o=Math.trunc(a*Math.pow(10,s-3));return Ve(o,n.length)}},gr={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},ng={G:function(r,n,s){const a=r.getFullYear()>0?1:0;switch(n){case"G":case"GG":case"GGG":return s.era(a,{width:"abbreviated"});case"GGGGG":return s.era(a,{width:"narrow"});case"GGGG":default:return s.era(a,{width:"wide"})}},y:function(r,n,s){if(n==="yo"){const a=r.getFullYear(),o=a>0?a:1-a;return s.ordinalNumber(o,{unit:"year"})}return Vs.y(r,n)},Y:function(r,n,s,a){const o=yy(r,a),f=o>0?o:1-o;if(n==="YY"){const h=f%100;return Ve(h,2)}return n==="Yo"?s.ordinalNumber(f,{unit:"year"}):Ve(f,n.length)},R:function(r,n){const s=my(r);return Ve(s,n.length)},u:function(r,n){const s=r.getFullYear();return Ve(s,n.length)},Q:function(r,n,s){const a=Math.ceil((r.getMonth()+1)/3);switch(n){case"Q":return String(a);case"QQ":return Ve(a,2);case"Qo":return s.ordinalNumber(a,{unit:"quarter"});case"QQQ":return s.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return s.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(a,{width:"wide",context:"formatting"})}},q:function(r,n,s){const a=Math.ceil((r.getMonth()+1)/3);switch(n){case"q":return String(a);case"qq":return Ve(a,2);case"qo":return s.ordinalNumber(a,{unit:"quarter"});case"qqq":return s.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return s.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(a,{width:"wide",context:"standalone"})}},M:function(r,n,s){const a=r.getMonth();switch(n){case"M":case"MM":return Vs.M(r,n);case"Mo":return s.ordinalNumber(a+1,{unit:"month"});case"MMM":return s.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return s.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(a,{width:"wide",context:"formatting"})}},L:function(r,n,s){const a=r.getMonth();switch(n){case"L":return String(a+1);case"LL":return Ve(a+1,2);case"Lo":return s.ordinalNumber(a+1,{unit:"month"});case"LLL":return s.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return s.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(a,{width:"wide",context:"standalone"})}},w:function(r,n,s,a){const o=d2(r,a);return n==="wo"?s.ordinalNumber(o,{unit:"week"}):Ve(o,n.length)},I:function(r,n,s){const a=f2(r);return n==="Io"?s.ordinalNumber(a,{unit:"week"}):Ve(a,n.length)},d:function(r,n,s){return n==="do"?s.ordinalNumber(r.getDate(),{unit:"date"}):Vs.d(r,n)},D:function(r,n,s){const a=u2(r);return n==="Do"?s.ordinalNumber(a,{unit:"dayOfYear"}):Ve(a,n.length)},E:function(r,n,s){const a=r.getDay();switch(n){case"E":case"EE":case"EEE":return s.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return s.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(a,{width:"short",context:"formatting"});case"EEEE":default:return s.day(a,{width:"wide",context:"formatting"})}},e:function(r,n,s,a){const o=r.getDay(),f=(o-a.weekStartsOn+8)%7||7;switch(n){case"e":return String(f);case"ee":return Ve(f,2);case"eo":return s.ordinalNumber(f,{unit:"day"});case"eee":return s.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return s.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return s.day(o,{width:"short",context:"formatting"});case"eeee":default:return s.day(o,{width:"wide",context:"formatting"})}},c:function(r,n,s,a){const o=r.getDay(),f=(o-a.weekStartsOn+8)%7||7;switch(n){case"c":return String(f);case"cc":return Ve(f,n.length);case"co":return s.ordinalNumber(f,{unit:"day"});case"ccc":return s.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return s.day(o,{width:"narrow",context:"standalone"});case"cccccc":return s.day(o,{width:"short",context:"standalone"});case"cccc":default:return s.day(o,{width:"wide",context:"standalone"})}},i:function(r,n,s){const a=r.getDay(),o=a===0?7:a;switch(n){case"i":return String(o);case"ii":return Ve(o,n.length);case"io":return s.ordinalNumber(o,{unit:"day"});case"iii":return s.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return s.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return s.day(a,{width:"short",context:"formatting"});case"iiii":default:return s.day(a,{width:"wide",context:"formatting"})}},a:function(r,n,s){const o=r.getHours()/12>=1?"pm":"am";switch(n){case"a":case"aa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(r,n,s){const a=r.getHours();let o;switch(a===12?o=gr.noon:a===0?o=gr.midnight:o=a/12>=1?"pm":"am",n){case"b":case"bb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(r,n,s){const a=r.getHours();let o;switch(a>=17?o=gr.evening:a>=12?o=gr.afternoon:a>=4?o=gr.morning:o=gr.night,n){case"B":case"BB":case"BBB":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(r,n,s){if(n==="ho"){let a=r.getHours()%12;return a===0&&(a=12),s.ordinalNumber(a,{unit:"hour"})}return Vs.h(r,n)},H:function(r,n,s){return n==="Ho"?s.ordinalNumber(r.getHours(),{unit:"hour"}):Vs.H(r,n)},K:function(r,n,s){const a=r.getHours()%12;return n==="Ko"?s.ordinalNumber(a,{unit:"hour"}):Ve(a,n.length)},k:function(r,n,s){let a=r.getHours();return a===0&&(a=24),n==="ko"?s.ordinalNumber(a,{unit:"hour"}):Ve(a,n.length)},m:function(r,n,s){return n==="mo"?s.ordinalNumber(r.getMinutes(),{unit:"minute"}):Vs.m(r,n)},s:function(r,n,s){return n==="so"?s.ordinalNumber(r.getSeconds(),{unit:"second"}):Vs.s(r,n)},S:function(r,n){return Vs.S(r,n)},X:function(r,n,s){const a=r.getTimezoneOffset();if(a===0)return"Z";switch(n){case"X":return ig(a);case"XXXX":case"XX":return Ai(a);case"XXXXX":case"XXX":default:return Ai(a,":")}},x:function(r,n,s){const a=r.getTimezoneOffset();switch(n){case"x":return ig(a);case"xxxx":case"xx":return Ai(a);case"xxxxx":case"xxx":default:return Ai(a,":")}},O:function(r,n,s){const a=r.getTimezoneOffset();switch(n){case"O":case"OO":case"OOO":return"GMT"+sg(a,":");case"OOOO":default:return"GMT"+Ai(a,":")}},z:function(r,n,s){const a=r.getTimezoneOffset();switch(n){case"z":case"zz":case"zzz":return"GMT"+sg(a,":");case"zzzz":default:return"GMT"+Ai(a,":")}},t:function(r,n,s){const a=Math.trunc(+r/1e3);return Ve(a,n.length)},T:function(r,n,s){return Ve(+r,n.length)}};function sg(r,n=""){const s=r>0?"-":"+",a=Math.abs(r),o=Math.trunc(a/60),f=a%60;return f===0?s+String(o):s+String(o)+n+Ve(f,2)}function ig(r,n){return r%60===0?(r>0?"-":"+")+Ve(Math.abs(r)/60,2):Ai(r,n)}function Ai(r,n=""){const s=r>0?"-":"+",a=Math.abs(r),o=Ve(Math.trunc(a/60),2),f=Ve(a%60,2);return s+o+n+f}const rg=(r,n)=>{switch(r){case"P":return n.date({width:"short"});case"PP":return n.date({width:"medium"});case"PPP":return n.date({width:"long"});case"PPPP":default:return n.date({width:"full"})}},by=(r,n)=>{switch(r){case"p":return n.time({width:"short"});case"pp":return n.time({width:"medium"});case"ppp":return n.time({width:"long"});case"pppp":default:return n.time({width:"full"})}},m2=(r,n)=>{const s=r.match(/(P+)(p+)?/)||[],a=s[1],o=s[2];if(!o)return rg(r,n);let f;switch(a){case"P":f=n.dateTime({width:"short"});break;case"PP":f=n.dateTime({width:"medium"});break;case"PPP":f=n.dateTime({width:"long"});break;case"PPPP":default:f=n.dateTime({width:"full"});break}return f.replace("{{date}}",rg(a,n)).replace("{{time}}",by(o,n))},p2={p:by,P:m2},g2=/^D+$/,y2=/^Y+$/,b2=["D","DD","YY","YYYY"];function x2(r){return g2.test(r)}function v2(r){return y2.test(r)}function _2(r,n,s){const a=w2(r,n,s);if(console.warn(a),b2.includes(r))throw new RangeError(a)}function w2(r,n,s){const a=r[0]==="Y"?"years":"days of the month";return`Use \`${r.toLowerCase()}\` instead of \`${r}\` (in \`${n}\`) for formatting ${a} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const S2=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,E2=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,A2=/^'([^]*?)'?$/,j2=/''/g,O2=/[a-zA-Z]/;function gh(r,n,s){var E,w,T,q;const a=Ja(),o=a.locale??gy,f=a.firstWeekContainsDate??((w=(E=a.locale)==null?void 0:E.options)==null?void 0:w.firstWeekContainsDate)??1,h=a.weekStartsOn??((q=(T=a.locale)==null?void 0:T.options)==null?void 0:q.weekStartsOn)??0,m=sn(r,s==null?void 0:s.in);if(!NS(m))throw new RangeError("Invalid time value");let g=n.match(E2).map(M=>{const R=M[0];if(R==="p"||R==="P"){const G=p2[R];return G(M,o.formatLong)}return M}).join("").match(S2).map(M=>{if(M==="''")return{isToken:!1,value:"'"};const R=M[0];if(R==="'")return{isToken:!1,value:T2(M)};if(ng[R])return{isToken:!0,value:M};if(R.match(O2))throw new RangeError("Format string contains an unescaped latin alphabet character `"+R+"`");return{isToken:!1,value:M}});o.localize.preprocessor&&(g=o.localize.preprocessor(m,g));const y={firstWeekContainsDate:f,weekStartsOn:h,locale:o};return g.map(M=>{if(!M.isToken)return M.value;const R=M.value;(v2(R)||x2(R))&&_2(R,n,String(r));const G=ng[R[0]];return G(m,R,o.localize,y)}).join("")}function T2(r){const n=r.match(A2);return n?n[1].replace(j2,"'"):r}function N2(r,n,s){const a=Ja(),o=(s==null?void 0:s.locale)??a.locale??gy,f=jS(r,n);if(isNaN(f))throw new RangeError("Invalid time value");const h=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:f}),[m,g]=py(s==null?void 0:s.in,...f>0?[n,r]:[r,n]),y=CS((s==null?void 0:s.roundingMethod)??"round"),E=g.getTime()-m.getTime(),w=E/X0,T=Po(g)-Po(m),q=(E-T)/X0,M=s==null?void 0:s.unit;let R;if(M?R=M:w<1?R="second":w<60?R="minute":w<W0?R="hour":q<Z0?R="day":q<K0?R="month":R="year",R==="second"){const G=y(E/1e3);return o.formatDistance("xSeconds",G,h)}else if(R==="minute"){const G=y(w);return o.formatDistance("xMinutes",G,h)}else if(R==="hour"){const G=y(w/60);return o.formatDistance("xHours",G,h)}else if(R==="day"){const G=y(q/W0);return o.formatDistance("xDays",G,h)}else if(R==="month"){const G=y(q/Z0);return G===12&&M!=="month"?o.formatDistance("xYears",1,h):o.formatDistance("xMonths",G,h)}else{const G=y(q/K0);return o.formatDistance("xYears",G,h)}}function C2(r,n){return N2(r,OS(r),n)}function o3(r){return r.toLocaleString()}function c3(r){return r>=1e9?`${(r/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(r/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(r/1e3).toFixed(1).replace(/\.0$/,"")}K`:r.toLocaleString()}function k2(r){const n=new Date(r);return n.getTime()>Date.now()?"just now":C2(n,{addSuffix:!0})}function u3(r){const n=Date.now()-new Date(r).getTime();if(n<0)return"now";const s=Math.floor(n/1e3);if(s<60)return`${s}s`;const a=Math.floor(s/60);if(a<60)return`${a}m`;const o=Math.floor(a/60);if(o<24)return`${o}h`;const f=Math.floor(o/24);return f<7?`${f}d`:f<30?`${Math.floor(f/7)}w`:f<365?`${Math.floor(f/30)}mo`:`${Math.floor(f/365)}y`}function f3(r){return r<=0?"Expired":yh(r)}function M2(r){return r==null?"--":yh(r)}function h3(r){return r?gh(new Date(r),"MMM d, yyyy h:mm a"):"--"}function yh(r){if(r<1e3)return`${Math.round(r)}ms`;if(r<6e4){const h=r/1e3;return Number.isInteger(h)?`${h}s`:`${h.toFixed(1)}s`}const n=Math.floor(r/1e3),s=Math.floor(n/86400),a=Math.floor(n%86400/3600),o=Math.floor(n%3600/60),f=n%60;return s>0?a>0?`${s}d ${a}h`:`${s}d`:a>0?o>0?`${a}h ${o}m`:`${a}h`:f>0?`${o}m ${f}s`:`${o}m`}function d3(r,n){const s=new Date(r).getTime(),a=n?new Date(n).getTime():Date.now();return yh(a-s)}function xy({options:r,children:n,className:s=""}){const[a,o]=O.useState(!1),[f,h]=O.useState(null),[m,g]=O.useState(null),y=O.useRef(null),E=O.useRef(void 0),w=O.useRef(void 0),T=220,q=O.useCallback(()=>{if(!y.current)return;const ne=y.current.getBoundingClientRect(),ee=window.innerWidth-T-8,me=Math.max(8,Math.min(ne.left,ee));g({top:ne.bottom+4,left:me})},[]),M=O.useCallback(async(ne,ee)=>{try{await navigator.clipboard.writeText(ne),h(ee),clearTimeout(E.current),E.current=setTimeout(()=>h(null),1200)}catch{}},[]),R=O.useCallback(()=>{clearTimeout(w.current),q(),o(!0)},[q]),G=O.useCallback(()=>{w.current=setTimeout(()=>o(!1),150)},[]);return O.useEffect(()=>()=>{clearTimeout(E.current),clearTimeout(w.current)},[]),d.jsxs("span",{ref:y,className:`inline-flex items-center cursor-default ${s}`,onMouseEnter:R,onMouseLeave:G,children:[n,a&&m&&dg.createPortal(d.jsx("span",{className:"fixed z-[9999] bg-surface-raised border border-surface-border rounded shadow-lg py-1 min-w-[180px]",style:{top:m.top,left:m.left},onMouseEnter:R,onMouseLeave:G,children:r.map(ne=>d.jsxs("button",{onClick:ee=>{ee.stopPropagation(),M(ne.value,ne.label)},className:"flex items-center justify-between w-full px-2.5 py-1 text-left hover:bg-surface-hover transition-colors",children:[d.jsx("span",{className:"text-[9px] font-medium uppercase tracking-wider text-text-tertiary w-10 shrink-0",children:ne.label}),d.jsx("span",{className:"text-[10px] font-mono text-text-secondary truncate ml-2",children:f===ne.label?"✓":ne.value})]},ne.label))}),document.body)]})}function R2(r,n){const s=new Date(r);switch(n){case"relative":return k2(r);case"datetime":return gh(s,"MMM d, yyyy h:mm a");case"time":return s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function D2(r){const n=new Date(r);return[{label:"ms",value:String(n.getTime())},{label:"utc",value:n.toISOString()},{label:"local",value:gh(n,"MMM d, yyyy h:mm:ss a")}]}function z2({date:r,format:n="relative",className:s=""}){const[,a]=O.useState(0);O.useEffect(()=>{if(n!=="relative")return;const f=setInterval(()=>a(h=>h+1),3e4);return()=>clearInterval(f)},[n]);const o=O.useMemo(()=>D2(r),[r]);return d.jsx(xy,{options:o,children:d.jsx("time",{dateTime:r,className:`text-xs text-text-tertiary ${s}`,children:R2(r,n)})})}function q2({ms:r,className:n=""}){const s=M2(r),a=O.useMemo(()=>r==null?[]:[{label:"ms",value:String(r)},{label:"sec",value:`${(r/1e3).toFixed(3)}s`},{label:"text",value:s}],[r,s]);return r==null?d.jsx("span",{className:`text-xs text-text-tertiary ${n}`,children:"--"}):d.jsx(xy,{options:a,children:d.jsx("span",{className:`text-xs text-text-tertiary ${n}`,children:s})})}const U2=["sm","md","lg","full"],ag={sm:"w-[28rem] max-h-[40vh]",md:"w-[36rem] max-h-[60vh]",lg:"w-[48rem] max-h-[80vh]",full:"inset-4 w-auto max-h-none"},lg={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function B2({which:r}){const n="stroke-current";switch(r){case"sm":return d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:d.jsx("rect",{x:"5",y:"5",width:"7",height:"7",rx:"1.5",className:n,strokeWidth:"1.5"})});case"md":return d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:d.jsx("rect",{x:"3",y:"3",width:"9",height:"9",rx:"1.5",className:n,strokeWidth:"1.5"})});case"lg":return d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:d.jsx("rect",{x:"1.5",y:"1.5",width:"11",height:"11",rx:"1.5",className:n,strokeWidth:"1.5"})});case"full":return d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:d.jsx("rect",{x:"0.75",y:"0.75",width:"12.5",height:"12.5",rx:"1.5",className:n,strokeWidth:"1.5"})})}}function L2({msg:r}){const[n,s]=O.useState(0);O.useEffect(()=>{const h=new Date(r.timestamp).getTime(),m=()=>s(Math.floor((Date.now()-h)/1e3));m();const g=setInterval(m,1e3);return()=>clearInterval(g)},[r.timestamp]);const a=Math.floor(n/60),o=n%60,f=a>0?`${a}m ${o}s`:`${o}s`;return d.jsxs("span",{className:"inline-flex flex-col gap-1.5",children:[d.jsxs("span",{className:"inline-flex items-center gap-1",children:[d.jsx("span",{className:"text-text-tertiary",children:"Thinking"}),d.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse"}),d.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:150ms]"}),d.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:300ms]"}),d.jsx("span",{className:"text-text-muted ml-1 tabular-nums",children:f})]}),r.workflowId&&d.jsxs(yr,{to:`/workflows/executions/${r.workflowId}`,className:"inline-flex items-center gap-1 text-[10px] text-accent/70 hover:text-accent transition-colors",children:[d.jsx(Kf,{className:"w-2.5 h-2.5",strokeWidth:1.5}),"watch execution"]})]})}function H2({msg:r,compileMessage:n}){const s=r.role==="assistant";return d.jsxs("div",{className:`flex items-center gap-1.5 ${s?"justify-start":"justify-end"}`,children:[d.jsx(z2,{date:r.timestamp,format:"time",className:"!text-[9px] text-text-muted/50"}),r.durationMs!=null&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-text-muted/30 text-[8px]",children:"·"}),d.jsx(q2,{ms:r.durationMs,className:"!text-[9px] text-text-muted/50"})]}),r.workflowId&&d.jsx(yr,{to:`/workflows/executions/${r.workflowId}`,className:"text-text-muted/40 hover:text-accent transition-colors",title:"View workflow execution",children:d.jsx(Kf,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),s&&r.workflowId&&!r.pending&&d.jsx("button",{onClick:()=>n(r.id),disabled:r.compilationStatus==="compiling"||r.compilationStatus==="done",className:"transition-colors",title:r.compilationStatus==="done"?"Compiled — future queries will match this pipeline":r.compilationStatus==="error"?r.compilationError??"Compilation failed":r.compilationStatus==="compiling"?"Compiling...":"Compile to fast pipeline",children:d.jsx(sv,{className:`w-2.5 h-2.5 ${r.compilationStatus==="done"?"text-status-success":r.compilationStatus==="error"?"text-status-error":r.compilationStatus==="compiling"?"text-accent/40 animate-pulse":"text-text-muted/40 hover:text-accent"}`,strokeWidth:1.5})})]})}function P2(){const{helpOpen:r,setHelpOpen:n,messages:s,sendMessage:a,pageContext:o,activeWorkflowId:f,clearMessages:h,compileMessage:m}=hy(),[g,y]=O.useState(""),[E,w]=O.useState("md"),[T,q]=O.useState(!0),M=O.useRef(null),R=O.useRef(null);if(O.useEffect(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[s]),O.useEffect(()=>{r&&R.current&&R.current.focus()},[r]),O.useEffect(()=>{if(!r)return;const C=K=>{K.key==="Escape"&&(E==="full"?w("lg"):E==="lg"?w("md"):E==="md"?w("sm"):n(!1))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[r,E,n]),!r)return null;const G=()=>{const C=g.trim();!C||f||(a(C),y(""),R.current&&(R.current.style.height="auto"))},ne=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),G())},ee=E==="full",me=o.page.replace(/-/g," "),re=ee?{}:{bottom:"108px"};return d.jsxs("div",{className:`fixed z-[45] flex flex-col border border-surface-border rounded-lg overflow-hidden transition-all duration-300 ${ee?ag.full:`right-6 ${ag[E]}`} ${T?"bg-surface-raised shadow-xl":"bg-surface-raised/[0.03] shadow-lg shadow-black/5"}`,style:re,onMouseEnter:()=>q(!0),onMouseLeave:()=>q(!1),children:[d.jsxs("div",{className:`flex items-center justify-between px-4 py-2.5 border-b border-surface-border shrink-0 transition-all duration-300 ${T?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"text-xs font-medium text-text-primary truncate",children:"Help Assistant"}),d.jsx("p",{className:"text-[10px] text-text-tertiary truncate",children:me})]}),d.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[d.jsx("div",{className:"flex items-center gap-0.5 border border-surface-border rounded p-0.5",role:"radiogroup","aria-label":"Panel size",children:U2.map(C=>d.jsx("button",{onClick:()=>w(C),className:`p-1 rounded transition-colors ${C===E?"bg-accent/15 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"}`,role:"radio","aria-checked":C===E,"aria-label":lg[C],title:lg[C],children:d.jsx(B2,{which:C})},C))}),s.length>0&&d.jsx("button",{onClick:h,className:"p-1 text-text-tertiary hover:text-text-secondary transition-colors","aria-label":"Clear conversation",title:"Clear conversation",children:d.jsx(iv,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),d.jsx("button",{onClick:()=>n(!1),className:"p-1 text-text-tertiary hover:text-text-primary transition-colors","aria-label":"Close",title:"Close",children:d.jsx($o,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})]}),d.jsxs("div",{ref:M,className:`flex-1 overflow-y-auto px-4 py-3 space-y-3 min-h-[120px] transition-all duration-300 ${T?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[s.length===0&&d.jsx("p",{className:"text-xs text-text-tertiary text-center py-6",children:"Ask anything about what you're viewing."}),s.map(C=>d.jsxs("div",{className:`text-xs leading-relaxed ${C.role==="user"?"text-right":"text-left"}`,children:[d.jsx("div",{className:`inline-block max-w-[85%] px-3 py-2 rounded-md whitespace-pre-wrap ${C.role==="user"?"bg-accent/10 text-text-primary":"bg-surface-sunken text-text-secondary"}`,children:C.pending?d.jsx(L2,{msg:C}):C.role==="assistant"?d.jsx(ph,{content:C.content}):C.content}),!C.pending&&d.jsx("div",{className:"mt-0.5",children:d.jsx(H2,{msg:C,compileMessage:m})})]},C.id))]}),d.jsxs("div",{className:`border-t border-surface-border px-3 py-2.5 flex gap-2 shrink-0 transition-all duration-300 ${T?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[d.jsx("textarea",{ref:R,value:g,onChange:C=>{y(C.target.value);const K=C.target;K.style.height="auto",K.style.height=`${Math.min(K.scrollHeight,120)}px`},onKeyDown:ne,placeholder:"Ask a question...",rows:2,className:"flex-1 resize-none bg-surface text-xs text-text-primary placeholder:text-text-tertiary rounded px-2.5 py-1.5 border border-surface-border focus:outline-none focus:border-accent",style:{minHeight:"2.5rem"},disabled:!!f}),d.jsx("button",{onClick:G,disabled:!g.trim()||!!f,className:"px-2.5 py-1.5 text-accent hover:text-accent-hover disabled:text-text-muted transition-colors self-end","aria-label":"Send",children:d.jsx(rv,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}function $2(){var M;const{isBuilder:r,isOps:n}=Wg(),{data:s}=Qo(),a=!!((M=s==null?void 0:s.ai)!=null&&M.enabled),{collapsed:o,toggle:f}=ty(),[h,m]=O.useState(!1),[g,y]=O.useState(!1),[E,w]=O.useState(()=>window.location.hash.startsWith("#docs")),T=ei(),q=O.useRef(null);return O.useEffect(()=>{const R=q.current;R&&(R.classList.remove("animate-page-in"),R.offsetWidth,R.classList.add("animate-page-in"))},[T.pathname]),O.useEffect(()=>{const R=()=>{window.location.hash.startsWith("#docs")&&w(!0)};return window.addEventListener("hashchange",R),()=>window.removeEventListener("hashchange",R)},[]),d.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[d.jsx(Cw,{onToggleEventFeed:()=>m(R=>!R),onToggleDocs:()=>w(R=>!R)}),d.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[d.jsxs("aside",{className:`${o?"w-16":"w-60"} shrink-0 bg-surface-raised border-r border-surface-border flex flex-col transition-[width] duration-200 ease-out overflow-hidden relative z-20`,children:[d.jsxs("nav",{className:"flex-1 px-3 pt-[36px] pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:[d.jsx(zw,{aiEnabled:a,isBuilder:r,isOps:n}),r&&d.jsx(qw,{}),r&&a&&d.jsx(Bw,{}),r&&d.jsx(Hw,{}),(r||n)&&d.jsx(Pw,{isBuilder:r,isOps:n})]}),d.jsx("button",{onClick:f,className:`shrink-0 py-3 text-text-tertiary hover:text-text-secondary transition-colors duration-150 ${o?"flex justify-center":"flex items-center px-7"}`,"aria-label":o?"Expand sidebar":"Collapse sidebar",children:o?d.jsx(av,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):d.jsx(lv,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!o&&(s==null?void 0:s.environment)&&d.jsxs("div",{className:"shrink-0 px-5 pb-3 text-[10px] leading-tight text-text-tertiary whitespace-nowrap overflow-hidden text-ellipsis",title:`long-tail v${s.environment.longTailVersion} · HotMesh v${s.environment.hotmeshVersion} · Node ${s.environment.nodeVersion} · ${s.environment.nodeEnv}`,children:["long-tail v",s.environment.longTailVersion,d.jsx("span",{className:"mx-1 text-surface-border",children:"·"}),"HotMesh v",s.environment.hotmeshVersion]})]}),d.jsx("main",{className:"flex-1 overflow-y-auto",children:d.jsx("div",{ref:q,className:"max-w-dashboard mx-auto px-10 py-10 pb-16 animate-page-in h-full flex flex-col",children:d.jsx(xr,{})})})]}),d.jsx(aS,{open:h,onToggle:()=>m(R=>!R),configOpen:g,onToggleConfig:()=>y(R=>!R)}),d.jsx(gS,{open:E,onClose:()=>{w(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),a&&d.jsx(_S,{}),a&&d.jsx(P2,{})]})}function Y2(){const{isAuthenticated:r}=Oi(),n=ei();return r?d.jsx(Sw,{children:d.jsx(vS,{children:d.jsx($2,{})})}):d.jsx(Bn,{to:"/login",state:{from:n.pathname},replace:!0})}function vy({provider:r,className:n="w-5 h-5"}){switch(r){case"google":return d.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"currentColor",children:[d.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),d.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),d.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),d.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]});case"github":return d.jsx("svg",{className:n,viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})});case"microsoft":return d.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"currentColor",children:[d.jsx("path",{d:"M3 3h8.5v8.5H3z",fill:"#F25022"}),d.jsx("path",{d:"M12.5 3H21v8.5h-8.5z",fill:"#7FBA00"}),d.jsx("path",{d:"M3 12.5h8.5V21H3z",fill:"#00A4EF"}),d.jsx("path",{d:"M12.5 12.5H21V21h-8.5z",fill:"#FFB900"})]});case"anthropic":return d.jsx("svg",{className:n,viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M13.827 3.52h3.603L24 20.48h-3.603l-6.57-16.96zm-7.258 0h3.767L16.906 20.48h-3.674l-1.343-3.461H6.396l-1.34 3.461H1.5l5.07-16.96zm2.327 5.14l-2.065 5.326h4.108l-2.043-5.326z"})});default:return d.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("path",{d:"M12 8v4l3 3"})]})}}async function G2(){return $e("/auth/oauth/providers")}async function V2(r,n){const s=n?`?label=${encodeURIComponent(n)}`:"";return $e(`/auth/oauth/connections/${r}${s}`,{method:"DELETE"})}function m3(){return _n({queryKey:["oauth-connections"],queryFn:()=>$e("/auth/oauth/connections")})}function p3(){const r=rn();return wn({mutationFn:({provider:n,label:s})=>V2(n,s),onSuccess:()=>{r.invalidateQueries({queryKey:["oauth-connections"]})}})}function F2(){var ce;const{login:r,isAuthenticated:n}=Oi(),s=mg(),a=ei(),o=new URLSearchParams(a.search),f=o.get("token"),h=o.get("error"),m=((ce=a.state)==null?void 0:ce.from)??o.get("returnTo")??"/",g=O.useRef(!1);f&&!g.current&&(g.current=!0,r(f,void 0,{displayName:o.get("displayName"),username:o.get("username")}));const[y,E]=O.useState(""),[w,T]=O.useState(""),[q,M]=O.useState(h||""),[R,G]=O.useState(!1),[ne,ee]=O.useState(!!f),[me,re]=O.useState([]),C=O.useRef(!1);if(O.useEffect(()=>{f||C.current||(C.current=!0,(async()=>{var F,V,Z,ae;try{const se=await fetch(`${Wt}/api/settings`);if(!se.ok)return;const ke=await se.json();if(!((F=ke.auth)!=null&&F.sso))return;const He=await fetch(`${Wt}/api/auth/sso`,{method:"POST"});if(!He.ok){M("Host authentication required — please log in to your organization first");return}const Me=await He.json();Me.token&&((V=ke.auth)!=null&&V.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",ke.auth.ssoLogoutUrl),ee(!0),r(Me.token,void 0,{displayName:(Z=Me.user)==null?void 0:Z.display_name,username:(ae=Me.user)==null?void 0:ae.external_id}))}catch{}})())},[]),O.useEffect(()=>{f||G2().then(re).catch(()=>{})},[]),O.useEffect(()=>{if(!ne)return;const F=setTimeout(()=>s(m,{replace:!0}),1500);return()=>clearTimeout(F)},[ne]),n&&!ne)return d.jsx(Bn,{to:m,replace:!0});const K=async F=>{var V,Z;if(F.preventDefault(),M(""),!y.trim()||!w){M("Username and password are required");return}G(!0);try{const ae=await fetch(`${Wt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:y.trim(),password:w})}),se=await ae.json();if(!ae.ok){M(se.error||"Login failed");return}ee(!0),r(se.token,{username:y.trim(),password:w},{displayName:(V=se.user)==null?void 0:V.display_name,username:(Z=se.user)==null?void 0:Z.external_id})}catch{M("Unable to connect to server")}finally{G(!1)}};return d.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center overflow-hidden",children:d.jsxs("div",{className:"w-full max-w-md p-10",children:[d.jsx("div",{className:`mb-10 transition-all duration-[1500ms] ease-in ${ne?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:d.jsx(dh,{size:"lg",hideLabel:ne})}),d.jsxs("form",{onSubmit:K,className:`space-y-5 transition-opacity duration-300 ${ne?"opacity-0":""}`,children:[d.jsxs("div",{children:[d.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-text-secondary mb-2",children:"Username"}),d.jsx("input",{id:"username",type:"text",value:y,onChange:F=>E(F.target.value),className:"input",placeholder:"Enter your username",autoFocus:!ne,autoComplete:"username"})]}),d.jsxs("div",{children:[d.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-text-secondary mb-2",children:"Password"}),d.jsx("input",{id:"password",type:"password",value:w,onChange:F=>T(F.target.value),className:"input",placeholder:"Enter your password",autoComplete:"current-password"})]}),q&&d.jsx("p",{className:"text-sm text-status-error",children:q}),d.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:R||ne,children:R?"Signing in...":"Sign In"}),me.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[d.jsx("div",{className:"flex-1 h-px bg-border"}),d.jsx("span",{className:"text-xs text-text-tertiary",children:"or continue with"}),d.jsx("div",{className:"flex-1 h-px bg-border"})]}),d.jsx("div",{className:"space-y-2",children:me.filter(F=>F.provider!=="anthropic").map(F=>d.jsxs("a",{href:`${Wt}/api/auth/oauth/${F.provider}?returnTo=${encodeURIComponent(m)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[d.jsx(vy,{provider:F.provider}),"Sign in with ",F.name]},F.provider))})]})]})]})})}function og(){const{isAuthenticated:r}=Oi(),n=mg(),s=ei(),a=new URLSearchParams(s.search),o=a.get("state")||"";O.useEffect(()=>{r||n(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[r]);const[f,h]=O.useState(""),[m,g]=O.useState(a.get("label")||"default"),[y,E]=O.useState(""),[w,T]=O.useState(!1),q=f.trim().startsWith("sk-ant-oat"),M=f.trim().startsWith("sk-ant-api"),R=G=>{G.preventDefault();const ne=f.trim();if(!ne){E("A token or API key is required");return}if(!ne.startsWith("sk-ant-")){E('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}T(!0),E("");const ee=`${Wt}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(ne)}&state=${encodeURIComponent(o)}`;window.location.href=ee};return d.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:d.jsxs("div",{className:"w-full max-w-md p-10",children:[d.jsx("div",{className:"mb-10",children:d.jsx(dh,{size:"lg"})}),d.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[d.jsx(vy,{provider:"anthropic",className:"w-6 h-6"}),d.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Connect Anthropic"})]}),d.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"Connect your Anthropic account so Claude Code tasks run under your credentials. Your token is encrypted at rest."}),d.jsxs("form",{onSubmit:R,className:"space-y-5",children:[d.jsxs("div",{children:[d.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-text-secondary mb-2",children:"OAuth Token or API Key"}),d.jsx("input",{id:"token",type:"password",value:f,onChange:G=>h(G.target.value),className:"input",placeholder:"sk-ant-oat01-... or sk-ant-api03-...",autoFocus:!0,autoComplete:"off"}),q&&d.jsx("p",{className:"text-xs text-status-success mt-1",children:"OAuth token detected — uses your Claude subscription (flat rate)"}),M&&d.jsx("p",{className:"text-xs text-status-warning mt-1",children:"API key detected — billed per-token from your Anthropic API account"})]}),d.jsxs("div",{children:[d.jsx("label",{htmlFor:"label",className:"block text-sm font-medium text-text-secondary mb-2",children:"Label"}),d.jsx("input",{id:"label",type:"text",value:m,onChange:G=>g(G.target.value.replace(/\s+/g,"-").toLowerCase()),className:"input",placeholder:"default",autoComplete:"off"}),d.jsx("p",{className:"text-xs text-text-tertiary mt-1",children:'A name for this credential. Use different labels to store multiple credentials (e.g., "subscription", "api-batch").'})]}),y&&d.jsx("p",{className:"text-sm text-status-error",children:y}),d.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:w,children:w?"Validating...":"Connect"}),d.jsx("a",{href:"/",className:"block text-center text-sm text-text-tertiary hover:text-text-secondary",children:"Cancel"})]}),d.jsxs("div",{className:"mt-6 space-y-3 text-xs text-text-tertiary",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium text-text-secondary",children:"Recommended:"})," ","Run"," ",d.jsx("code",{className:"px-1 py-0.5 bg-surface-sunken rounded text-[11px]",children:"claude setup-token"})," ","in your terminal to generate an OAuth token that uses your subscription."]}),d.jsxs("div",{children:[d.jsx("span",{className:"font-medium text-text-secondary",children:"Alternative:"})," ","Use an API key from"," ",d.jsx("a",{href:"https://console.anthropic.com/settings/keys",target:"_blank",rel:"noopener noreferrer",className:"text-accent-secondary hover:underline",children:"console.anthropic.com"})," ","(billed per-token)."]})]})]})})}function Ca({roleTypes:r,roleNames:n,redirectTo:s="/"}){const{isSuperAdmin:a,hasRole:o,hasRoleType:f}=Oi();return a?d.jsx(xr,{}):r&&r.some(h=>f(h))?d.jsx(xr,{}):n&&n.some(h=>o(h))?d.jsx(xr,{}):d.jsx(Bn,{to:s,replace:!0})}function J2({redirectTo:r="/"}){var a;const{data:n,isLoading:s}=Qo();return s||!n?null:(a=n.ai)!=null&&a.enabled?d.jsx(xr,{}):d.jsx(Bn,{to:r,replace:!0})}function I2({flag:r,redirectTo:n="/"}){var o;const{data:s,isLoading:a}=Qo();return a||!s?null:((o=s.features)==null?void 0:o[r])===!1?d.jsx(Bn,{to:n,replace:!0}):d.jsx(xr,{})}const Q2=O.lazy(()=>ve(()=>import("./ProcessesListPage-tNLvALwT.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]),import.meta.url).then(r=>({default:r.ProcessesListPage}))),X2=O.lazy(()=>ve(()=>import("./ProcessDetailPage-DwypVFE2.js"),__vite__mapDeps([18,1,2,4,19,15,20,17,11,6,21,22,23]),import.meta.url).then(r=>({default:r.ProcessDetailPage}))),K2=O.lazy(()=>ve(()=>import("./McpOverview-D-4eSOTc.js"),__vite__mapDeps([24,1,25,26,27,28,14,15,29,6]),import.meta.url).then(r=>({default:r.McpOverview}))),Z2=O.lazy(()=>ve(()=>import("./McpRunsPage-CdDyeOdi.js"),__vite__mapDeps([30,1,26,27,5,6,31,28,8,9,10,17,15,32,14,13,12,16,33]),import.meta.url).then(r=>({default:r.McpRunsPage}))),W2=O.lazy(()=>ve(()=>import("./McpRunDetailPage-CQmhfgju.js"),__vite__mapDeps([34,1,26,20,14,15,35,6,36,37,16,38,39,40,13]),import.meta.url).then(r=>({default:r.McpRunDetailPage}))),eE=O.lazy(()=>ve(()=>import("./McpQueryPage-CIijB5t2.js"),__vite__mapDeps([41,1,14,15,9,10,13,12,16,8,11,32,17,33,5,6,4,42]),import.meta.url).then(r=>({default:r.McpQueryPage}))),tE=O.lazy(()=>ve(()=>import("./McpQueryDetailPage-BYwDb8LC.js"),__vite__mapDeps([43,1,14,15,20,42,6,27,4,44,36,26,3,2,45,46,47,48,49,50,35,51,38,39]),import.meta.url).then(r=>({default:r.McpQueryDetailPage}))),nE=O.lazy(()=>ve(()=>import("./EscalationsOverview-qlo0mxxa.js"),__vite__mapDeps([52,1,4,14,15,29,6]),import.meta.url).then(r=>({default:r.EscalationsOverview}))),sE=O.lazy(()=>ve(()=>import("./AvailableEscalationsPage-BxakNqha.js"),__vite__mapDeps([53,1,6,4,54,55,56,57,5,7,8,9,10,12,14,15,23,58,13,59,21,17,60,33,16]),import.meta.url).then(r=>({default:r.AvailableEscalationsPage}))),iE=O.lazy(()=>ve(()=>import("./OperatorDashboard-DFORmS46.js"),__vite__mapDeps([61,1,4,57,5,6,7,8,9,10,14,15,12,33,58,13,59,21,17,60,16]),import.meta.url).then(r=>({default:r.OperatorDashboard}))),rE=O.lazy(()=>ve(()=>import("./index-D0bDVU2a.js"),__vite__mapDeps([62,1,37,54,55,6,56,57,14,15,60,16,3,4,22,23,20,21,35,36]),import.meta.url).then(r=>({default:r.EscalationDetailPage}))),aE=O.lazy(()=>ve(()=>import("./WorkflowsOverview-BzUjUfAz.js"),__vite__mapDeps([63,1,3,4,14,15,29,6]),import.meta.url).then(r=>({default:r.WorkflowsOverview}))),lE=O.lazy(()=>ve(()=>import("./index-CyXilW90.js"),__vite__mapDeps([64,1,3,14,15,13,17,65,48,49,6]),import.meta.url).then(r=>({default:r.StartWorkflowPage}))),oE=O.lazy(()=>ve(()=>import("./index-CyXilW90.js"),__vite__mapDeps([64,1,3,14,15,13,17,65,48,49,6]),import.meta.url).then(r=>({default:r.DurableInvokePage}))),cE=O.lazy(()=>ve(()=>import("./WorkflowsDashboard-BgUz_jO6.js"),__vite__mapDeps([66,1,32,3,31,28,6,4,5,8,9,10,17,15,14,13,12,16,33]),import.meta.url).then(r=>({default:()=>r.WorkflowsDashboard({tier:"durable"})}))),uE=O.lazy(()=>ve(()=>import("./WorkflowsDashboard-BgUz_jO6.js"),__vite__mapDeps([66,1,32,3,31,28,6,4,5,8,9,10,17,15,14,13,12,16,33]),import.meta.url).then(r=>({default:()=>r.WorkflowsDashboard({tier:"all"})}))),fE=O.lazy(()=>ve(()=>import("./YamlWorkflowsPage-CQ-dk84N.js"),__vite__mapDeps([67,1,27,5,6,14,15,13,10,50,65,20]),import.meta.url).then(r=>({default:r.YamlWorkflowsPage}))),hE=O.lazy(()=>ve(()=>import("./GraphInvokePage-CU3r2tzN.js"),__vite__mapDeps([68,1,27,14,15,45,47,48,49,46,6,50,65]),import.meta.url).then(r=>({default:r.GraphInvokePage}))),dE=O.lazy(()=>ve(()=>import("./YamlWorkflowDetailPage-C48Ui513.js"),__vite__mapDeps([69,1,27,20,65,15,6]),import.meta.url).then(r=>({default:r.YamlWorkflowDetailPage}))),mE=O.lazy(()=>ve(()=>import("./TasksListPage-CQhiSGkN.js"),__vite__mapDeps([70,1,2,3,5,6,9,10,20,59,51,12,13,14,15,17]),import.meta.url).then(r=>({default:r.TasksListPage}))),pE=O.lazy(()=>ve(()=>import("./TaskDetailPage-B09mLOCE.js"),__vite__mapDeps([71,1,2,20,59,14,15,6]),import.meta.url).then(r=>({default:r.TaskDetailPage}))),cg=O.lazy(()=>ve(()=>import("./WorkflowExecutionPage-CjMSQ9Bb.js"),__vite__mapDeps([72,1,3,4,37,2,14,15,36,16,20,35,6,38,39,40,13]),import.meta.url).then(r=>({default:r.WorkflowExecutionPage}))),gE=O.lazy(()=>ve(()=>import("./AdminDashboard-Dhr7sUq6.js"),__vite__mapDeps([73,1,2,4,25,19,15,6]),import.meta.url).then(r=>({default:r.AdminDashboard}))),yE=O.lazy(()=>ve(()=>import("./index-DgAmkmtv.js"),__vite__mapDeps([74,1,3,9,10,13,33,5,6,14,15,75,17]),import.meta.url).then(r=>({default:r.WorkersPage}))),bE=O.lazy(()=>ve(()=>import("./index-CAzFU1rn.js"),__vite__mapDeps([76,1,3,13,77,55,6,21,15,17,14,57,48,49,65]),import.meta.url).then(r=>({default:r.WorkflowConfigsPage}))),ug=O.lazy(()=>ve(()=>import("./index-CAzFU1rn.js"),__vite__mapDeps([76,1,3,13,77,55,6,21,15,17,14,57,48,49,65]),import.meta.url).then(r=>({default:r.WorkflowConfigDetailPage}))),xE=O.lazy(()=>ve(()=>import("./index-CxlsLEr1.js"),__vite__mapDeps([78,1,25,10,77,55,6,14,15,13,12,5,79,47,48,49,50,46,33,20]),import.meta.url).then(r=>({default:r.McpServersPage}))),fg=O.lazy(()=>ve(()=>import("./index-61yKjTkk.js"),__vite__mapDeps([80,1,25,14,15,44,6]),import.meta.url).then(r=>({default:r.McpServerDetailPage}))),vE=O.lazy(()=>ve(()=>import("./index-DsKK1fCc.js"),__vite__mapDeps([81,1,23,5,6,9,10,12,13,77,55,33,14,15,21,49,11,57,51]),import.meta.url).then(r=>({default:r.UsersPage}))),_E=O.lazy(()=>ve(()=>import("./RolesPage-txueySPI.js"),__vite__mapDeps([82,1,57,14,15,55,6]),import.meta.url).then(r=>({default:r.RolesPage}))),wE=O.lazy(()=>ve(()=>import("./RoleDetailPage-BPsrUqIa.js"),__vite__mapDeps([83,1,57,77,55,6,23,15]),import.meta.url).then(r=>({default:r.RoleDetailPage}))),SE=O.lazy(()=>ve(()=>import("./EscalationSchemaPage-hzFtuyha.js"),__vite__mapDeps([84,1,57,15,6]),import.meta.url).then(r=>({default:r.EscalationSchemaPage}))),EE=O.lazy(()=>ve(()=>import("./index-DkZnXWTA.js"),__vite__mapDeps([85,1,14,15,55,6,56]),import.meta.url).then(r=>({default:r.MaintenancePage}))),AE=O.lazy(()=>ve(()=>import("./OperationsPage-Cz_0K8tj.js").then(r=>r.O),__vite__mapDeps([86,1,57,4,14,15,6]),import.meta.url).then(r=>({default:r.OperationsPage}))),jE=O.lazy(()=>ve(()=>import("./index-DcZDyLHC.js"),__vite__mapDeps([87,1,19,15,13,5,6,31,28,55,36,75,9,10,33]),import.meta.url).then(r=>({default:r.ControlPlanePage}))),OE=O.lazy(()=>ve(()=>import("./index-BwXtXaw8.js"),__vite__mapDeps([88,1,6,39,15,5,31,28,8,9,10,12,13,11,14,16]),import.meta.url).then(r=>({default:r.StreamMessagesPage}))),TE=O.lazy(()=>ve(()=>import("./CredentialsPage-BN_d7ybc.js"),__vite__mapDeps([89,1,14,15,51,77,55,6]),import.meta.url).then(r=>({default:r.CredentialsPage}))),NE=O.lazy(()=>ve(()=>import("./index-aHhMmZ0W.js"),__vite__mapDeps([90,1,6,14,15,13,16,8,10,91,51]),import.meta.url).then(r=>({default:r.FilesPage}))),CE=O.lazy(()=>ve(()=>import("./index-Bcgsf2yD.js"),__vite__mapDeps([92,1,14,15,13,16,12,10,91,51,93,44,6]),import.meta.url).then(r=>({default:r.KnowledgePage}))),kE=O.lazy(()=>ve(()=>import("./HomePage-B7pb4-Gx.js"),__vite__mapDeps([94,1,57,3,26,28,4,21,15,17,16,86,14,6]),import.meta.url).then(r=>({default:r.HomePage}))),ME=O.lazy(()=>ve(()=>import("./AgentsPage-Pj47ZJ2U.js"),__vite__mapDeps([95,1,96,4,5,6,8,9,10,12,13,14,15,16]),import.meta.url).then(r=>({default:r.AgentsPage}))),RE=O.lazy(()=>ve(()=>import("./AgentDetailPage-C9Tmmhhc.js"),__vite__mapDeps([97,1,96,98,15,4,17,6]),import.meta.url).then(r=>({default:r.AgentDetailPage}))),hg=O.lazy(()=>ve(()=>import("./AgentConfigPage-CUPm8FjH.js"),__vite__mapDeps([99,1,96,98,15,14,93,47,48,49,3,27,100,101,17,6]),import.meta.url).then(r=>({default:r.AgentConfigPage}))),DE=O.lazy(()=>ve(()=>import("./CapabilitiesPage-XFVq4iPX.js"),__vite__mapDeps([102,1,100,79,25,47,48,49,15,50,6,46,14,13]),import.meta.url).then(r=>({default:r.CapabilitiesPage}))),zE=O.lazy(()=>ve(()=>import("./TopicsPage-DkvsHLLe.js"),__vite__mapDeps([103,1,101,14,15,13,6]),import.meta.url).then(r=>({default:r.TopicsPage}))),qE=O.lazy(()=>ve(()=>import("./TopicDetailPage-0mvQde8R.js"),__vite__mapDeps([104,1,101,16,15,6]),import.meta.url).then(r=>({default:r.TopicDetailPage})));function UE(){return d.jsxs("div",{className:"animate-pulse space-y-4",children:[d.jsx("div",{className:"h-8 bg-surface-sunken rounded w-48"}),d.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]})}function be({children:r}){return d.jsx(O.Suspense,{fallback:d.jsx(UE,{}),children:d.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:r})})}const _y=new Mx({defaultOptions:{queries:{staleTime:1e4,retry:(r,n)=>n instanceof Error&&n.message==="Session expired"?!1:r<1}}});window.addEventListener("auth:unauthorized",()=>{_y.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const r=window.__LT_BASE__||"",n=`${r}/login`;if(window.location.pathname!==n){const s=window.location.pathname+window.location.search,a=r&&s.startsWith(r)?s.slice(r.length)||"/":s;window.location.href=`${n}?returnTo=${encodeURIComponent(a)}`}});const BE=zx([{path:"/login",element:d.jsx(F2,{})},{path:"/connect/anthropic",element:d.jsx(og,{})},{path:"/connect/:provider",element:d.jsx(og,{})},{path:"/",element:d.jsx(Y2,{}),children:[{index:!0,element:d.jsx(be,{children:d.jsx(kE,{})})},{path:"processes/all",element:d.jsx(be,{children:d.jsx(Q2,{})})},{path:"processes/detail/:originId",element:d.jsx(be,{children:d.jsx(X2,{})})},{path:"credentials",element:d.jsx(be,{children:d.jsx(TE,{})})},{path:"connections",element:d.jsx(Bn,{to:"/credentials",replace:!0})},{path:"escalations",element:d.jsx(be,{children:d.jsx(nE,{})})},{path:"escalations/available",element:d.jsx(be,{children:d.jsx(sE,{})})},{path:"escalations/queue",element:d.jsx(be,{children:d.jsx(iE,{})})},{path:"escalations/detail/:id",element:d.jsx(be,{children:d.jsx(rE,{})})},{path:"capabilities",element:d.jsx(be,{children:d.jsx(DE,{})})},{path:"agents",element:d.jsx(be,{children:d.jsx(ME,{})})},{path:"agents/new",element:d.jsx(be,{children:d.jsx(hg,{})})},{path:"agents/:id",element:d.jsx(be,{children:d.jsx(RE,{})})},{path:"agents/:id/edit",element:d.jsx(be,{children:d.jsx(hg,{})})},{path:"topics",element:d.jsx(be,{children:d.jsx(zE,{})})},{path:"topics/:topic",element:d.jsx(be,{children:d.jsx(qE,{})})},{element:d.jsx(Ca,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:d.jsx(be,{children:d.jsx(aE,{})})},{path:"workflows/executions",element:d.jsx(be,{children:d.jsx(uE,{})})},{path:"workflows/durable/executions",element:d.jsx(be,{children:d.jsx(cE,{})})},{path:"workflows/durable/executions/:workflowId",element:d.jsx(be,{children:d.jsx(cg,{})})},{path:"workflows/tasks",element:d.jsx(be,{children:d.jsx(mE,{})})},{path:"workflows/tasks/detail/:id",element:d.jsx(be,{children:d.jsx(pE,{})})},{path:"workflows/executions/:workflowId",element:d.jsx(be,{children:d.jsx(cg,{})})},{path:"workflows/start",element:d.jsx(be,{children:d.jsx(lE,{})})},{path:"workflows/durable/invoke",element:d.jsx(be,{children:d.jsx(oE,{})})},{path:"workflows/cron",element:d.jsx(Bn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:d.jsx(be,{children:d.jsx(yE,{})})},{path:"workflows/registry",element:d.jsx(be,{children:d.jsx(bE,{})})},{path:"workflows/registry/new",element:d.jsx(be,{children:d.jsx(ug,{})})},{path:"workflows/registry/:workflowType",element:d.jsx(be,{children:d.jsx(ug,{})})}]},{element:d.jsx(Ca,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:d.jsx(be,{children:d.jsx(fE,{})})},{path:"mcp/workflows/invoke",element:d.jsx(be,{children:d.jsx(hE,{})})},{path:"mcp/workflows/:id",element:d.jsx(be,{children:d.jsx(dE,{})})},{path:"mcp/executions",element:d.jsx(be,{children:d.jsx(Z2,{})})},{path:"mcp/executions/:jobId",element:d.jsx(be,{children:d.jsx(W2,{})})},{path:"files",element:d.jsx(be,{children:d.jsx(NE,{})})},{path:"knowledge",element:d.jsx(be,{children:d.jsx(CE,{})})},{element:d.jsx(J2,{}),children:[{path:"mcp",element:d.jsx(be,{children:d.jsx(K2,{})})},{path:"mcp/queries",element:d.jsx(be,{children:d.jsx(eE,{})})},{path:"mcp/queries/:workflowId",element:d.jsx(be,{children:d.jsx(tE,{})})},{path:"mcp/tools",element:d.jsx(Bn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:d.jsx(be,{children:d.jsx(xE,{})})},{path:"mcp/servers/new",element:d.jsx(be,{children:d.jsx(fg,{})})},{path:"mcp/servers/:serverId",element:d.jsx(be,{children:d.jsx(fg,{})})}]}]},{element:d.jsx(Ca,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"operations",element:d.jsx(be,{children:d.jsx(AE,{})})}]},{element:d.jsx(Ca,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:d.jsx(be,{children:d.jsx(gE,{})})},{path:"admin/users",element:d.jsx(be,{children:d.jsx(vE,{})})},{path:"admin/escalation-chains",element:d.jsx(Bn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:d.jsx(be,{children:d.jsx(_E,{})})},{path:"admin/roles/:role",element:d.jsx(be,{children:d.jsx(wE,{})})},{path:"admin/roles/:role/schema",element:d.jsx(be,{children:d.jsx(SE,{})})}]},{element:d.jsx(Ca,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:d.jsx(Bn,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:d.jsx(I2,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:d.jsx(be,{children:d.jsx(EE,{})})}]},{path:"admin/controlplane",element:d.jsx(be,{children:d.jsx(jE,{})})},{path:"admin/streams",element:d.jsx(be,{children:d.jsx(OE,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function LE(){return d.jsx(Rx,{client:_y,children:d.jsx(gv,{children:d.jsx(vw,{children:d.jsx(qx,{router:BE})})})})}ay(ry());hv.createRoot(document.getElementById("root")).render(d.jsx(O.StrictMode,{children:d.jsx(LE,{})}));export{XE as A,e3 as B,mh as C,q2 as D,a3 as E,oy as F,gh as G,xy as H,f3 as I,sS as J,o3 as K,Wt as L,vg as M,x_ as N,VE as O,m3 as P,p3 as Q,vy as R,Vw as S,c3 as T,d3 as a,z2 as b,__ as c,$e as d,QE as e,M2 as f,KE as g,WE as h,FE as i,Oi as j,IE as k,t3 as l,n3 as m,s3 as n,i3 as o,r3 as p,l3 as q,JE as r,Aw as s,Ew as t,Qo as u,Wg as v,ZE as w,h3 as x,u3 as y,yh as z};
63
- //# sourceMappingURL=index-MbEPoyTe.js.map
62
+ ... (truncated)`});const ce=`${bS(o.concat(me))}${ne}`;try{const Z=(await $e("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ce,tags:C.suggestedTags,context:C,wait:!1,direct:!0})})).workflow_id;m(Z),f(ae=>ae.map(se=>se.id===re.id?{...se,workflowId:Z}:se)),E.current&&clearInterval(E.current),E.current=setInterval(async()=>{var ae;try{const se=await $e(`/workflows/${Z}/result`),ke=(ae=se==null?void 0:se.result)==null?void 0:ae.data;if(ke){E.current&&clearInterval(E.current),E.current=null,m(null);const He=xS(ke);let Me;try{Me=(await $e(`/workflow-states/${Z}/execution`)).duration_ms}catch{}f($=>$.map(te=>te.id===re.id?{...te,content:He,timestamp:new Date().toISOString(),pending:!1,durationMs:Me}:te))}}catch{}},3e3)}catch{f(V=>V.map(Z=>Z.id===re.id?{...Z,content:"Failed to submit query. Please try again.",pending:!1}:Z))}},[o,w]),G=O.useCallback(async ne=>{const ee=o.find(C=>C.id===ne);if(!(ee!=null&&ee.workflowId)||ee.compilationStatus==="compiling"||ee.compilationStatus==="done")return;const me=o.indexOf(ee),re=o.slice(0,me).reverse().find(C=>C.role==="user");if(re){f(C=>C.map(K=>K.id===ne?{...K,compilationStatus:"compiling"}:K));try{const C=await $e("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:re.content,summary:ee.content})}),K=await $e("/yaml-workflows",{method:"POST",body:JSON.stringify({workflow_id:ee.workflowId,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:C.tool_name,description:C.description,tags:C.tags,app_id:""})});await $e(`/yaml-workflows/${K.id}/deploy`,{method:"POST"}),f(ce=>ce.map(F=>F.id===ne?{...F,compilationStatus:"done"}:F))}catch(C){const K=C instanceof Error?C.message:"Compilation failed";f(ce=>ce.map(F=>F.id===ne?{...F,compilationStatus:"error",compilationError:K}:F))}}},[o]);return d.jsx(fy.Provider,{value:{helpOpen:s,setHelpOpen:a,toggleHelp:T,messages:o,sendMessage:R,pageContext:w,setPageContext:q,activeWorkflowId:h,clearMessages:M,compileMessage:G},children:r})}function hy(){const r=O.useContext(fy);if(!r)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return r}function _S(){const{helpOpen:r,toggleHelp:n}=hy();return d.jsx("button",{onClick:n,className:"fixed right-3 z-[45] flex items-center justify-center w-10 h-10 rounded-full bg-surface-raised shadow-lg hover:scale-110 transition-transform duration-150 border border-accent/30",style:{bottom:"44px"},"aria-label":r?"Close help":"Ask for help",children:r?d.jsx($o,{className:"w-5 h-5 text-text-tertiary",strokeWidth:1.5}):d.jsx("span",{role:"img","aria-label":"Help",className:"logo-mark w-8 h-8 -rotate-[120deg]",style:{"--logo-url":`url(${Wt}/logo512.png)`}})})}const dy=6048e5,wS=864e5,X0=6e4,K0=525600,Z0=43200,W0=1440,eg=Symbol.for("constructDateFrom");function ds(r,n){return typeof r=="function"?r(n):r&&typeof r=="object"&&eg in r?r[eg](n):r instanceof Date?new r.constructor(n):new Date(n)}function sn(r,n){return ds(n||r,r)}let SS={};function Ja(){return SS}function Ya(r,n){var m,g,y,E;const s=Ja(),a=(n==null?void 0:n.weekStartsOn)??((g=(m=n==null?void 0:n.locale)==null?void 0:m.options)==null?void 0:g.weekStartsOn)??s.weekStartsOn??((E=(y=s.locale)==null?void 0:y.options)==null?void 0:E.weekStartsOn)??0,o=sn(r,n==null?void 0:n.in),f=o.getDay(),h=(f<a?7:0)+f-a;return o.setDate(o.getDate()-h),o.setHours(0,0,0,0),o}function Ho(r,n){return Ya(r,{...n,weekStartsOn:1})}function my(r,n){const s=sn(r,n==null?void 0:n.in),a=s.getFullYear(),o=ds(s,0);o.setFullYear(a+1,0,4),o.setHours(0,0,0,0);const f=Ho(o),h=ds(s,0);h.setFullYear(a,0,4),h.setHours(0,0,0,0);const m=Ho(h);return s.getTime()>=f.getTime()?a+1:s.getTime()>=m.getTime()?a:a-1}function Po(r){const n=sn(r),s=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()));return s.setUTCFullYear(n.getFullYear()),+r-+s}function py(r,...n){const s=ds.bind(null,r||n.find(a=>typeof a=="object"));return n.map(s)}function tg(r,n){const s=sn(r,n==null?void 0:n.in);return s.setHours(0,0,0,0),s}function ES(r,n,s){const[a,o]=py(s==null?void 0:s.in,r,n),f=tg(a),h=tg(o),m=+f-Po(f),g=+h-Po(h);return Math.round((m-g)/wS)}function AS(r,n){const s=my(r,n),a=ds(r,0);return a.setFullYear(s,0,4),a.setHours(0,0,0,0),Ho(a)}function jS(r,n){const s=+sn(r)-+sn(n);return s<0?-1:s>0?1:s}function OS(r){return ds(r,Date.now())}function TS(r){return r instanceof Date||typeof r=="object"&&Object.prototype.toString.call(r)==="[object Date]"}function NS(r){return!(!TS(r)&&typeof r!="number"||isNaN(+sn(r)))}function CS(r){return n=>{const a=(r?Math[r]:Math.trunc)(n);return a===0?0:a}}function kS(r,n){const s=sn(r,n==null?void 0:n.in);return s.setFullYear(s.getFullYear(),0,1),s.setHours(0,0,0,0),s}const MS={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},RS=(r,n,s)=>{let a;const o=MS[r];return typeof o=="string"?a=o:n===1?a=o.one:a=o.other.replace("{{count}}",n.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+a:a+" ago":a};function Sf(r){return(n={})=>{const s=n.width?String(n.width):r.defaultWidth;return r.formats[s]||r.formats[r.defaultWidth]}}const DS={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},zS={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},qS={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},US={date:Sf({formats:DS,defaultWidth:"full"}),time:Sf({formats:zS,defaultWidth:"full"}),dateTime:Sf({formats:qS,defaultWidth:"full"})},BS={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},LS=(r,n,s,a)=>BS[r];function Ta(r){return(n,s)=>{const a=s!=null&&s.context?String(s.context):"standalone";let o;if(a==="formatting"&&r.formattingValues){const h=r.defaultFormattingWidth||r.defaultWidth,m=s!=null&&s.width?String(s.width):h;o=r.formattingValues[m]||r.formattingValues[h]}else{const h=r.defaultWidth,m=s!=null&&s.width?String(s.width):r.defaultWidth;o=r.values[m]||r.values[h]}const f=r.argumentCallback?r.argumentCallback(n):n;return o[f]}}const HS={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},PS={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},$S={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},YS={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},GS={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},VS={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},FS=(r,n)=>{const s=Number(r),a=s%100;if(a>20||a<10)switch(a%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},JS={ordinalNumber:FS,era:Ta({values:HS,defaultWidth:"wide"}),quarter:Ta({values:PS,defaultWidth:"wide",argumentCallback:r=>r-1}),month:Ta({values:$S,defaultWidth:"wide"}),day:Ta({values:YS,defaultWidth:"wide"}),dayPeriod:Ta({values:GS,defaultWidth:"wide",formattingValues:VS,defaultFormattingWidth:"wide"})};function Na(r){return(n,s={})=>{const a=s.width,o=a&&r.matchPatterns[a]||r.matchPatterns[r.defaultMatchWidth],f=n.match(o);if(!f)return null;const h=f[0],m=a&&r.parsePatterns[a]||r.parsePatterns[r.defaultParseWidth],g=Array.isArray(m)?QS(m,w=>w.test(h)):IS(m,w=>w.test(h));let y;y=r.valueCallback?r.valueCallback(g):g,y=s.valueCallback?s.valueCallback(y):y;const E=n.slice(h.length);return{value:y,rest:E}}}function IS(r,n){for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)&&n(r[s]))return s}function QS(r,n){for(let s=0;s<r.length;s++)if(n(r[s]))return s}function XS(r){return(n,s={})=>{const a=n.match(r.matchPattern);if(!a)return null;const o=a[0],f=n.match(r.parsePattern);if(!f)return null;let h=r.valueCallback?r.valueCallback(f[0]):f[0];h=s.valueCallback?s.valueCallback(h):h;const m=n.slice(o.length);return{value:h,rest:m}}}const KS=/^(\d+)(th|st|nd|rd)?/i,ZS=/\d+/i,WS={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},e2={any:[/^b/i,/^(a|c)/i]},t2={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},n2={any:[/1/i,/2/i,/3/i,/4/i]},s2={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},i2={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},r2={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},a2={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},l2={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},o2={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},c2={ordinalNumber:XS({matchPattern:KS,parsePattern:ZS,valueCallback:r=>parseInt(r,10)}),era:Na({matchPatterns:WS,defaultMatchWidth:"wide",parsePatterns:e2,defaultParseWidth:"any"}),quarter:Na({matchPatterns:t2,defaultMatchWidth:"wide",parsePatterns:n2,defaultParseWidth:"any",valueCallback:r=>r+1}),month:Na({matchPatterns:s2,defaultMatchWidth:"wide",parsePatterns:i2,defaultParseWidth:"any"}),day:Na({matchPatterns:r2,defaultMatchWidth:"wide",parsePatterns:a2,defaultParseWidth:"any"}),dayPeriod:Na({matchPatterns:l2,defaultMatchWidth:"any",parsePatterns:o2,defaultParseWidth:"any"})},gy={code:"en-US",formatDistance:RS,formatLong:US,formatRelative:LS,localize:JS,match:c2,options:{weekStartsOn:0,firstWeekContainsDate:1}};function u2(r,n){const s=sn(r,n==null?void 0:n.in);return ES(s,kS(s))+1}function f2(r,n){const s=sn(r,n==null?void 0:n.in),a=+Ho(s)-+AS(s);return Math.round(a/dy)+1}function yy(r,n){var E,w,T,q;const s=sn(r,n==null?void 0:n.in),a=s.getFullYear(),o=Ja(),f=(n==null?void 0:n.firstWeekContainsDate)??((w=(E=n==null?void 0:n.locale)==null?void 0:E.options)==null?void 0:w.firstWeekContainsDate)??o.firstWeekContainsDate??((q=(T=o.locale)==null?void 0:T.options)==null?void 0:q.firstWeekContainsDate)??1,h=ds((n==null?void 0:n.in)||r,0);h.setFullYear(a+1,0,f),h.setHours(0,0,0,0);const m=Ya(h,n),g=ds((n==null?void 0:n.in)||r,0);g.setFullYear(a,0,f),g.setHours(0,0,0,0);const y=Ya(g,n);return+s>=+m?a+1:+s>=+y?a:a-1}function h2(r,n){var m,g,y,E;const s=Ja(),a=(n==null?void 0:n.firstWeekContainsDate)??((g=(m=n==null?void 0:n.locale)==null?void 0:m.options)==null?void 0:g.firstWeekContainsDate)??s.firstWeekContainsDate??((E=(y=s.locale)==null?void 0:y.options)==null?void 0:E.firstWeekContainsDate)??1,o=yy(r,n),f=ds((n==null?void 0:n.in)||r,0);return f.setFullYear(o,0,a),f.setHours(0,0,0,0),Ya(f,n)}function d2(r,n){const s=sn(r,n==null?void 0:n.in),a=+Ya(s,n)-+h2(s,n);return Math.round(a/dy)+1}function Ve(r,n){const s=r<0?"-":"",a=Math.abs(r).toString().padStart(n,"0");return s+a}const Vs={y(r,n){const s=r.getFullYear(),a=s>0?s:1-s;return Ve(n==="yy"?a%100:a,n.length)},M(r,n){const s=r.getMonth();return n==="M"?String(s+1):Ve(s+1,2)},d(r,n){return Ve(r.getDate(),n.length)},a(r,n){const s=r.getHours()/12>=1?"pm":"am";switch(n){case"a":case"aa":return s.toUpperCase();case"aaa":return s;case"aaaaa":return s[0];case"aaaa":default:return s==="am"?"a.m.":"p.m."}},h(r,n){return Ve(r.getHours()%12||12,n.length)},H(r,n){return Ve(r.getHours(),n.length)},m(r,n){return Ve(r.getMinutes(),n.length)},s(r,n){return Ve(r.getSeconds(),n.length)},S(r,n){const s=n.length,a=r.getMilliseconds(),o=Math.trunc(a*Math.pow(10,s-3));return Ve(o,n.length)}},gr={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},ng={G:function(r,n,s){const a=r.getFullYear()>0?1:0;switch(n){case"G":case"GG":case"GGG":return s.era(a,{width:"abbreviated"});case"GGGGG":return s.era(a,{width:"narrow"});case"GGGG":default:return s.era(a,{width:"wide"})}},y:function(r,n,s){if(n==="yo"){const a=r.getFullYear(),o=a>0?a:1-a;return s.ordinalNumber(o,{unit:"year"})}return Vs.y(r,n)},Y:function(r,n,s,a){const o=yy(r,a),f=o>0?o:1-o;if(n==="YY"){const h=f%100;return Ve(h,2)}return n==="Yo"?s.ordinalNumber(f,{unit:"year"}):Ve(f,n.length)},R:function(r,n){const s=my(r);return Ve(s,n.length)},u:function(r,n){const s=r.getFullYear();return Ve(s,n.length)},Q:function(r,n,s){const a=Math.ceil((r.getMonth()+1)/3);switch(n){case"Q":return String(a);case"QQ":return Ve(a,2);case"Qo":return s.ordinalNumber(a,{unit:"quarter"});case"QQQ":return s.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return s.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(a,{width:"wide",context:"formatting"})}},q:function(r,n,s){const a=Math.ceil((r.getMonth()+1)/3);switch(n){case"q":return String(a);case"qq":return Ve(a,2);case"qo":return s.ordinalNumber(a,{unit:"quarter"});case"qqq":return s.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return s.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(a,{width:"wide",context:"standalone"})}},M:function(r,n,s){const a=r.getMonth();switch(n){case"M":case"MM":return Vs.M(r,n);case"Mo":return s.ordinalNumber(a+1,{unit:"month"});case"MMM":return s.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return s.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(a,{width:"wide",context:"formatting"})}},L:function(r,n,s){const a=r.getMonth();switch(n){case"L":return String(a+1);case"LL":return Ve(a+1,2);case"Lo":return s.ordinalNumber(a+1,{unit:"month"});case"LLL":return s.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return s.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(a,{width:"wide",context:"standalone"})}},w:function(r,n,s,a){const o=d2(r,a);return n==="wo"?s.ordinalNumber(o,{unit:"week"}):Ve(o,n.length)},I:function(r,n,s){const a=f2(r);return n==="Io"?s.ordinalNumber(a,{unit:"week"}):Ve(a,n.length)},d:function(r,n,s){return n==="do"?s.ordinalNumber(r.getDate(),{unit:"date"}):Vs.d(r,n)},D:function(r,n,s){const a=u2(r);return n==="Do"?s.ordinalNumber(a,{unit:"dayOfYear"}):Ve(a,n.length)},E:function(r,n,s){const a=r.getDay();switch(n){case"E":case"EE":case"EEE":return s.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return s.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(a,{width:"short",context:"formatting"});case"EEEE":default:return s.day(a,{width:"wide",context:"formatting"})}},e:function(r,n,s,a){const o=r.getDay(),f=(o-a.weekStartsOn+8)%7||7;switch(n){case"e":return String(f);case"ee":return Ve(f,2);case"eo":return s.ordinalNumber(f,{unit:"day"});case"eee":return s.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return s.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return s.day(o,{width:"short",context:"formatting"});case"eeee":default:return s.day(o,{width:"wide",context:"formatting"})}},c:function(r,n,s,a){const o=r.getDay(),f=(o-a.weekStartsOn+8)%7||7;switch(n){case"c":return String(f);case"cc":return Ve(f,n.length);case"co":return s.ordinalNumber(f,{unit:"day"});case"ccc":return s.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return s.day(o,{width:"narrow",context:"standalone"});case"cccccc":return s.day(o,{width:"short",context:"standalone"});case"cccc":default:return s.day(o,{width:"wide",context:"standalone"})}},i:function(r,n,s){const a=r.getDay(),o=a===0?7:a;switch(n){case"i":return String(o);case"ii":return Ve(o,n.length);case"io":return s.ordinalNumber(o,{unit:"day"});case"iii":return s.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return s.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return s.day(a,{width:"short",context:"formatting"});case"iiii":default:return s.day(a,{width:"wide",context:"formatting"})}},a:function(r,n,s){const o=r.getHours()/12>=1?"pm":"am";switch(n){case"a":case"aa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(r,n,s){const a=r.getHours();let o;switch(a===12?o=gr.noon:a===0?o=gr.midnight:o=a/12>=1?"pm":"am",n){case"b":case"bb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(r,n,s){const a=r.getHours();let o;switch(a>=17?o=gr.evening:a>=12?o=gr.afternoon:a>=4?o=gr.morning:o=gr.night,n){case"B":case"BB":case"BBB":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(r,n,s){if(n==="ho"){let a=r.getHours()%12;return a===0&&(a=12),s.ordinalNumber(a,{unit:"hour"})}return Vs.h(r,n)},H:function(r,n,s){return n==="Ho"?s.ordinalNumber(r.getHours(),{unit:"hour"}):Vs.H(r,n)},K:function(r,n,s){const a=r.getHours()%12;return n==="Ko"?s.ordinalNumber(a,{unit:"hour"}):Ve(a,n.length)},k:function(r,n,s){let a=r.getHours();return a===0&&(a=24),n==="ko"?s.ordinalNumber(a,{unit:"hour"}):Ve(a,n.length)},m:function(r,n,s){return n==="mo"?s.ordinalNumber(r.getMinutes(),{unit:"minute"}):Vs.m(r,n)},s:function(r,n,s){return n==="so"?s.ordinalNumber(r.getSeconds(),{unit:"second"}):Vs.s(r,n)},S:function(r,n){return Vs.S(r,n)},X:function(r,n,s){const a=r.getTimezoneOffset();if(a===0)return"Z";switch(n){case"X":return ig(a);case"XXXX":case"XX":return Ai(a);case"XXXXX":case"XXX":default:return Ai(a,":")}},x:function(r,n,s){const a=r.getTimezoneOffset();switch(n){case"x":return ig(a);case"xxxx":case"xx":return Ai(a);case"xxxxx":case"xxx":default:return Ai(a,":")}},O:function(r,n,s){const a=r.getTimezoneOffset();switch(n){case"O":case"OO":case"OOO":return"GMT"+sg(a,":");case"OOOO":default:return"GMT"+Ai(a,":")}},z:function(r,n,s){const a=r.getTimezoneOffset();switch(n){case"z":case"zz":case"zzz":return"GMT"+sg(a,":");case"zzzz":default:return"GMT"+Ai(a,":")}},t:function(r,n,s){const a=Math.trunc(+r/1e3);return Ve(a,n.length)},T:function(r,n,s){return Ve(+r,n.length)}};function sg(r,n=""){const s=r>0?"-":"+",a=Math.abs(r),o=Math.trunc(a/60),f=a%60;return f===0?s+String(o):s+String(o)+n+Ve(f,2)}function ig(r,n){return r%60===0?(r>0?"-":"+")+Ve(Math.abs(r)/60,2):Ai(r,n)}function Ai(r,n=""){const s=r>0?"-":"+",a=Math.abs(r),o=Ve(Math.trunc(a/60),2),f=Ve(a%60,2);return s+o+n+f}const rg=(r,n)=>{switch(r){case"P":return n.date({width:"short"});case"PP":return n.date({width:"medium"});case"PPP":return n.date({width:"long"});case"PPPP":default:return n.date({width:"full"})}},by=(r,n)=>{switch(r){case"p":return n.time({width:"short"});case"pp":return n.time({width:"medium"});case"ppp":return n.time({width:"long"});case"pppp":default:return n.time({width:"full"})}},m2=(r,n)=>{const s=r.match(/(P+)(p+)?/)||[],a=s[1],o=s[2];if(!o)return rg(r,n);let f;switch(a){case"P":f=n.dateTime({width:"short"});break;case"PP":f=n.dateTime({width:"medium"});break;case"PPP":f=n.dateTime({width:"long"});break;case"PPPP":default:f=n.dateTime({width:"full"});break}return f.replace("{{date}}",rg(a,n)).replace("{{time}}",by(o,n))},p2={p:by,P:m2},g2=/^D+$/,y2=/^Y+$/,b2=["D","DD","YY","YYYY"];function x2(r){return g2.test(r)}function v2(r){return y2.test(r)}function _2(r,n,s){const a=w2(r,n,s);if(console.warn(a),b2.includes(r))throw new RangeError(a)}function w2(r,n,s){const a=r[0]==="Y"?"years":"days of the month";return`Use \`${r.toLowerCase()}\` instead of \`${r}\` (in \`${n}\`) for formatting ${a} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const S2=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,E2=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,A2=/^'([^]*?)'?$/,j2=/''/g,O2=/[a-zA-Z]/;function gh(r,n,s){var E,w,T,q;const a=Ja(),o=a.locale??gy,f=a.firstWeekContainsDate??((w=(E=a.locale)==null?void 0:E.options)==null?void 0:w.firstWeekContainsDate)??1,h=a.weekStartsOn??((q=(T=a.locale)==null?void 0:T.options)==null?void 0:q.weekStartsOn)??0,m=sn(r,s==null?void 0:s.in);if(!NS(m))throw new RangeError("Invalid time value");let g=n.match(E2).map(M=>{const R=M[0];if(R==="p"||R==="P"){const G=p2[R];return G(M,o.formatLong)}return M}).join("").match(S2).map(M=>{if(M==="''")return{isToken:!1,value:"'"};const R=M[0];if(R==="'")return{isToken:!1,value:T2(M)};if(ng[R])return{isToken:!0,value:M};if(R.match(O2))throw new RangeError("Format string contains an unescaped latin alphabet character `"+R+"`");return{isToken:!1,value:M}});o.localize.preprocessor&&(g=o.localize.preprocessor(m,g));const y={firstWeekContainsDate:f,weekStartsOn:h,locale:o};return g.map(M=>{if(!M.isToken)return M.value;const R=M.value;(v2(R)||x2(R))&&_2(R,n,String(r));const G=ng[R[0]];return G(m,R,o.localize,y)}).join("")}function T2(r){const n=r.match(A2);return n?n[1].replace(j2,"'"):r}function N2(r,n,s){const a=Ja(),o=(s==null?void 0:s.locale)??a.locale??gy,f=jS(r,n);if(isNaN(f))throw new RangeError("Invalid time value");const h=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:f}),[m,g]=py(s==null?void 0:s.in,...f>0?[n,r]:[r,n]),y=CS((s==null?void 0:s.roundingMethod)??"round"),E=g.getTime()-m.getTime(),w=E/X0,T=Po(g)-Po(m),q=(E-T)/X0,M=s==null?void 0:s.unit;let R;if(M?R=M:w<1?R="second":w<60?R="minute":w<W0?R="hour":q<Z0?R="day":q<K0?R="month":R="year",R==="second"){const G=y(E/1e3);return o.formatDistance("xSeconds",G,h)}else if(R==="minute"){const G=y(w);return o.formatDistance("xMinutes",G,h)}else if(R==="hour"){const G=y(w/60);return o.formatDistance("xHours",G,h)}else if(R==="day"){const G=y(q/W0);return o.formatDistance("xDays",G,h)}else if(R==="month"){const G=y(q/Z0);return G===12&&M!=="month"?o.formatDistance("xYears",1,h):o.formatDistance("xMonths",G,h)}else{const G=y(q/K0);return o.formatDistance("xYears",G,h)}}function C2(r,n){return N2(r,OS(r),n)}function o3(r){return r.toLocaleString()}function c3(r){return r>=1e9?`${(r/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(r/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(r/1e3).toFixed(1).replace(/\.0$/,"")}K`:r.toLocaleString()}function k2(r){const n=new Date(r);return n.getTime()>Date.now()?"just now":C2(n,{addSuffix:!0})}function u3(r){const n=Date.now()-new Date(r).getTime();if(n<0)return"now";const s=Math.floor(n/1e3);if(s<60)return`${s}s`;const a=Math.floor(s/60);if(a<60)return`${a}m`;const o=Math.floor(a/60);if(o<24)return`${o}h`;const f=Math.floor(o/24);return f<7?`${f}d`:f<30?`${Math.floor(f/7)}w`:f<365?`${Math.floor(f/30)}mo`:`${Math.floor(f/365)}y`}function f3(r){return r<=0?"Expired":yh(r)}function M2(r){return r==null?"--":yh(r)}function h3(r){return r?gh(new Date(r),"MMM d, yyyy h:mm a"):"--"}function yh(r){if(r<1e3)return`${Math.round(r)}ms`;if(r<6e4){const h=r/1e3;return Number.isInteger(h)?`${h}s`:`${h.toFixed(1)}s`}const n=Math.floor(r/1e3),s=Math.floor(n/86400),a=Math.floor(n%86400/3600),o=Math.floor(n%3600/60),f=n%60;return s>0?a>0?`${s}d ${a}h`:`${s}d`:a>0?o>0?`${a}h ${o}m`:`${a}h`:f>0?`${o}m ${f}s`:`${o}m`}function d3(r,n){const s=new Date(r).getTime(),a=n?new Date(n).getTime():Date.now();return yh(a-s)}function xy({options:r,children:n,className:s=""}){const[a,o]=O.useState(!1),[f,h]=O.useState(null),[m,g]=O.useState(null),y=O.useRef(null),E=O.useRef(void 0),w=O.useRef(void 0),T=220,q=O.useCallback(()=>{if(!y.current)return;const ne=y.current.getBoundingClientRect(),ee=window.innerWidth-T-8,me=Math.max(8,Math.min(ne.left,ee));g({top:ne.bottom+4,left:me})},[]),M=O.useCallback(async(ne,ee)=>{try{await navigator.clipboard.writeText(ne),h(ee),clearTimeout(E.current),E.current=setTimeout(()=>h(null),1200)}catch{}},[]),R=O.useCallback(()=>{clearTimeout(w.current),q(),o(!0)},[q]),G=O.useCallback(()=>{w.current=setTimeout(()=>o(!1),150)},[]);return O.useEffect(()=>()=>{clearTimeout(E.current),clearTimeout(w.current)},[]),d.jsxs("span",{ref:y,className:`inline-flex items-center cursor-default ${s}`,onMouseEnter:R,onMouseLeave:G,children:[n,a&&m&&dg.createPortal(d.jsx("span",{className:"fixed z-[9999] bg-surface-raised border border-surface-border rounded shadow-lg py-1 min-w-[180px]",style:{top:m.top,left:m.left},onMouseEnter:R,onMouseLeave:G,children:r.map(ne=>d.jsxs("button",{onClick:ee=>{ee.stopPropagation(),M(ne.value,ne.label)},className:"flex items-center justify-between w-full px-2.5 py-1 text-left hover:bg-surface-hover transition-colors",children:[d.jsx("span",{className:"text-[9px] font-medium uppercase tracking-wider text-text-tertiary w-10 shrink-0",children:ne.label}),d.jsx("span",{className:"text-[10px] font-mono text-text-secondary truncate ml-2",children:f===ne.label?"✓":ne.value})]},ne.label))}),document.body)]})}function R2(r,n){const s=new Date(r);switch(n){case"relative":return k2(r);case"datetime":return gh(s,"MMM d, yyyy h:mm a");case"time":return s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function D2(r){const n=new Date(r);return[{label:"ms",value:String(n.getTime())},{label:"utc",value:n.toISOString()},{label:"local",value:gh(n,"MMM d, yyyy h:mm:ss a")}]}function z2({date:r,format:n="relative",className:s=""}){const[,a]=O.useState(0);O.useEffect(()=>{if(n!=="relative")return;const f=setInterval(()=>a(h=>h+1),3e4);return()=>clearInterval(f)},[n]);const o=O.useMemo(()=>D2(r),[r]);return d.jsx(xy,{options:o,children:d.jsx("time",{dateTime:r,className:`text-xs text-text-tertiary ${s}`,children:R2(r,n)})})}function q2({ms:r,className:n=""}){const s=M2(r),a=O.useMemo(()=>r==null?[]:[{label:"ms",value:String(r)},{label:"sec",value:`${(r/1e3).toFixed(3)}s`},{label:"text",value:s}],[r,s]);return r==null?d.jsx("span",{className:`text-xs text-text-tertiary ${n}`,children:"--"}):d.jsx(xy,{options:a,children:d.jsx("span",{className:`text-xs text-text-tertiary ${n}`,children:s})})}const U2=["sm","md","lg","full"],ag={sm:"w-[28rem] max-h-[40vh]",md:"w-[36rem] max-h-[60vh]",lg:"w-[48rem] max-h-[80vh]",full:"inset-4 w-auto max-h-none"},lg={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function B2({which:r}){const n="stroke-current";switch(r){case"sm":return d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:d.jsx("rect",{x:"5",y:"5",width:"7",height:"7",rx:"1.5",className:n,strokeWidth:"1.5"})});case"md":return d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:d.jsx("rect",{x:"3",y:"3",width:"9",height:"9",rx:"1.5",className:n,strokeWidth:"1.5"})});case"lg":return d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:d.jsx("rect",{x:"1.5",y:"1.5",width:"11",height:"11",rx:"1.5",className:n,strokeWidth:"1.5"})});case"full":return d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:d.jsx("rect",{x:"0.75",y:"0.75",width:"12.5",height:"12.5",rx:"1.5",className:n,strokeWidth:"1.5"})})}}function L2({msg:r}){const[n,s]=O.useState(0);O.useEffect(()=>{const h=new Date(r.timestamp).getTime(),m=()=>s(Math.floor((Date.now()-h)/1e3));m();const g=setInterval(m,1e3);return()=>clearInterval(g)},[r.timestamp]);const a=Math.floor(n/60),o=n%60,f=a>0?`${a}m ${o}s`:`${o}s`;return d.jsxs("span",{className:"inline-flex flex-col gap-1.5",children:[d.jsxs("span",{className:"inline-flex items-center gap-1",children:[d.jsx("span",{className:"text-text-tertiary",children:"Thinking"}),d.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse"}),d.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:150ms]"}),d.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:300ms]"}),d.jsx("span",{className:"text-text-muted ml-1 tabular-nums",children:f})]}),r.workflowId&&d.jsxs(yr,{to:`/workflows/executions/${r.workflowId}`,className:"inline-flex items-center gap-1 text-[10px] text-accent/70 hover:text-accent transition-colors",children:[d.jsx(Kf,{className:"w-2.5 h-2.5",strokeWidth:1.5}),"watch execution"]})]})}function H2({msg:r,compileMessage:n}){const s=r.role==="assistant";return d.jsxs("div",{className:`flex items-center gap-1.5 ${s?"justify-start":"justify-end"}`,children:[d.jsx(z2,{date:r.timestamp,format:"time",className:"!text-[9px] text-text-muted/50"}),r.durationMs!=null&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-text-muted/30 text-[8px]",children:"·"}),d.jsx(q2,{ms:r.durationMs,className:"!text-[9px] text-text-muted/50"})]}),r.workflowId&&d.jsx(yr,{to:`/workflows/executions/${r.workflowId}`,className:"text-text-muted/40 hover:text-accent transition-colors",title:"View workflow execution",children:d.jsx(Kf,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),s&&r.workflowId&&!r.pending&&d.jsx("button",{onClick:()=>n(r.id),disabled:r.compilationStatus==="compiling"||r.compilationStatus==="done",className:"transition-colors",title:r.compilationStatus==="done"?"Compiled — future queries will match this pipeline":r.compilationStatus==="error"?r.compilationError??"Compilation failed":r.compilationStatus==="compiling"?"Compiling...":"Compile to fast pipeline",children:d.jsx(sv,{className:`w-2.5 h-2.5 ${r.compilationStatus==="done"?"text-status-success":r.compilationStatus==="error"?"text-status-error":r.compilationStatus==="compiling"?"text-accent/40 animate-pulse":"text-text-muted/40 hover:text-accent"}`,strokeWidth:1.5})})]})}function P2(){const{helpOpen:r,setHelpOpen:n,messages:s,sendMessage:a,pageContext:o,activeWorkflowId:f,clearMessages:h,compileMessage:m}=hy(),[g,y]=O.useState(""),[E,w]=O.useState("md"),[T,q]=O.useState(!0),M=O.useRef(null),R=O.useRef(null);if(O.useEffect(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[s]),O.useEffect(()=>{r&&R.current&&R.current.focus()},[r]),O.useEffect(()=>{if(!r)return;const C=K=>{K.key==="Escape"&&(E==="full"?w("lg"):E==="lg"?w("md"):E==="md"?w("sm"):n(!1))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[r,E,n]),!r)return null;const G=()=>{const C=g.trim();!C||f||(a(C),y(""),R.current&&(R.current.style.height="auto"))},ne=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),G())},ee=E==="full",me=o.page.replace(/-/g," "),re=ee?{}:{bottom:"108px"};return d.jsxs("div",{className:`fixed z-[45] flex flex-col border border-surface-border rounded-lg overflow-hidden transition-all duration-300 ${ee?ag.full:`right-6 ${ag[E]}`} ${T?"bg-surface-raised shadow-xl":"bg-surface-raised/[0.03] shadow-lg shadow-black/5"}`,style:re,onMouseEnter:()=>q(!0),onMouseLeave:()=>q(!1),children:[d.jsxs("div",{className:`flex items-center justify-between px-4 py-2.5 border-b border-surface-border shrink-0 transition-all duration-300 ${T?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"text-xs font-medium text-text-primary truncate",children:"Help Assistant"}),d.jsx("p",{className:"text-[10px] text-text-tertiary truncate",children:me})]}),d.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[d.jsx("div",{className:"flex items-center gap-0.5 border border-surface-border rounded p-0.5",role:"radiogroup","aria-label":"Panel size",children:U2.map(C=>d.jsx("button",{onClick:()=>w(C),className:`p-1 rounded transition-colors ${C===E?"bg-accent/15 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"}`,role:"radio","aria-checked":C===E,"aria-label":lg[C],title:lg[C],children:d.jsx(B2,{which:C})},C))}),s.length>0&&d.jsx("button",{onClick:h,className:"p-1 text-text-tertiary hover:text-text-secondary transition-colors","aria-label":"Clear conversation",title:"Clear conversation",children:d.jsx(iv,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),d.jsx("button",{onClick:()=>n(!1),className:"p-1 text-text-tertiary hover:text-text-primary transition-colors","aria-label":"Close",title:"Close",children:d.jsx($o,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})]}),d.jsxs("div",{ref:M,className:`flex-1 overflow-y-auto px-4 py-3 space-y-3 min-h-[120px] transition-all duration-300 ${T?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[s.length===0&&d.jsx("p",{className:"text-xs text-text-tertiary text-center py-6",children:"Ask anything about what you're viewing."}),s.map(C=>d.jsxs("div",{className:`text-xs leading-relaxed ${C.role==="user"?"text-right":"text-left"}`,children:[d.jsx("div",{className:`inline-block max-w-[85%] px-3 py-2 rounded-md whitespace-pre-wrap ${C.role==="user"?"bg-accent/10 text-text-primary":"bg-surface-sunken text-text-secondary"}`,children:C.pending?d.jsx(L2,{msg:C}):C.role==="assistant"?d.jsx(ph,{content:C.content}):C.content}),!C.pending&&d.jsx("div",{className:"mt-0.5",children:d.jsx(H2,{msg:C,compileMessage:m})})]},C.id))]}),d.jsxs("div",{className:`border-t border-surface-border px-3 py-2.5 flex gap-2 shrink-0 transition-all duration-300 ${T?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[d.jsx("textarea",{ref:R,value:g,onChange:C=>{y(C.target.value);const K=C.target;K.style.height="auto",K.style.height=`${Math.min(K.scrollHeight,120)}px`},onKeyDown:ne,placeholder:"Ask a question...",rows:2,className:"flex-1 resize-none bg-surface text-xs text-text-primary placeholder:text-text-tertiary rounded px-2.5 py-1.5 border border-surface-border focus:outline-none focus:border-accent",style:{minHeight:"2.5rem"},disabled:!!f}),d.jsx("button",{onClick:G,disabled:!g.trim()||!!f,className:"px-2.5 py-1.5 text-accent hover:text-accent-hover disabled:text-text-muted transition-colors self-end","aria-label":"Send",children:d.jsx(rv,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}function $2(){var M;const{isBuilder:r,isOps:n}=Wg(),{data:s}=Qo(),a=!!((M=s==null?void 0:s.ai)!=null&&M.enabled),{collapsed:o,toggle:f}=ty(),[h,m]=O.useState(!1),[g,y]=O.useState(!1),[E,w]=O.useState(()=>window.location.hash.startsWith("#docs")),T=ei(),q=O.useRef(null);return O.useEffect(()=>{const R=q.current;R&&(R.classList.remove("animate-page-in"),R.offsetWidth,R.classList.add("animate-page-in"))},[T.pathname]),O.useEffect(()=>{const R=()=>{window.location.hash.startsWith("#docs")&&w(!0)};return window.addEventListener("hashchange",R),()=>window.removeEventListener("hashchange",R)},[]),d.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[d.jsx(Cw,{onToggleEventFeed:()=>m(R=>!R),onToggleDocs:()=>w(R=>!R)}),d.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[d.jsxs("aside",{className:`${o?"w-16":"w-60"} shrink-0 bg-surface-raised border-r border-surface-border flex flex-col transition-[width] duration-200 ease-out overflow-hidden relative z-20`,children:[d.jsxs("nav",{className:"flex-1 px-3 pt-[36px] pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:[d.jsx(zw,{aiEnabled:a,isBuilder:r,isOps:n}),r&&d.jsx(qw,{}),r&&a&&d.jsx(Bw,{}),r&&d.jsx(Hw,{}),(r||n)&&d.jsx(Pw,{isBuilder:r,isOps:n})]}),d.jsx("button",{onClick:f,className:`shrink-0 py-3 text-text-tertiary hover:text-text-secondary transition-colors duration-150 ${o?"flex justify-center":"flex items-center px-7"}`,"aria-label":o?"Expand sidebar":"Collapse sidebar",children:o?d.jsx(av,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):d.jsx(lv,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!o&&(s==null?void 0:s.environment)&&d.jsxs("div",{className:"shrink-0 px-5 pb-3 text-[10px] leading-tight text-text-tertiary whitespace-nowrap overflow-hidden text-ellipsis",title:`long-tail v${s.environment.longTailVersion} · HotMesh v${s.environment.hotmeshVersion} · Node ${s.environment.nodeVersion} · ${s.environment.nodeEnv}`,children:["long-tail v",s.environment.longTailVersion,d.jsx("span",{className:"mx-1 text-surface-border",children:"·"}),"HotMesh v",s.environment.hotmeshVersion]})]}),d.jsx("main",{className:"flex-1 overflow-y-auto",children:d.jsx("div",{ref:q,className:"w-full px-10 py-10 pb-16 animate-page-in h-full flex flex-col",children:d.jsx(xr,{})})})]}),d.jsx(aS,{open:h,onToggle:()=>m(R=>!R),configOpen:g,onToggleConfig:()=>y(R=>!R)}),d.jsx(gS,{open:E,onClose:()=>{w(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),a&&d.jsx(_S,{}),a&&d.jsx(P2,{})]})}function Y2(){const{isAuthenticated:r}=Oi(),n=ei();return r?d.jsx(Sw,{children:d.jsx(vS,{children:d.jsx($2,{})})}):d.jsx(Bn,{to:"/login",state:{from:n.pathname},replace:!0})}function vy({provider:r,className:n="w-5 h-5"}){switch(r){case"google":return d.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"currentColor",children:[d.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),d.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),d.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),d.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]});case"github":return d.jsx("svg",{className:n,viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})});case"microsoft":return d.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"currentColor",children:[d.jsx("path",{d:"M3 3h8.5v8.5H3z",fill:"#F25022"}),d.jsx("path",{d:"M12.5 3H21v8.5h-8.5z",fill:"#7FBA00"}),d.jsx("path",{d:"M3 12.5h8.5V21H3z",fill:"#00A4EF"}),d.jsx("path",{d:"M12.5 12.5H21V21h-8.5z",fill:"#FFB900"})]});case"anthropic":return d.jsx("svg",{className:n,viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M13.827 3.52h3.603L24 20.48h-3.603l-6.57-16.96zm-7.258 0h3.767L16.906 20.48h-3.674l-1.343-3.461H6.396l-1.34 3.461H1.5l5.07-16.96zm2.327 5.14l-2.065 5.326h4.108l-2.043-5.326z"})});default:return d.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("path",{d:"M12 8v4l3 3"})]})}}async function G2(){return $e("/auth/oauth/providers")}async function V2(r,n){const s=n?`?label=${encodeURIComponent(n)}`:"";return $e(`/auth/oauth/connections/${r}${s}`,{method:"DELETE"})}function m3(){return _n({queryKey:["oauth-connections"],queryFn:()=>$e("/auth/oauth/connections")})}function p3(){const r=rn();return wn({mutationFn:({provider:n,label:s})=>V2(n,s),onSuccess:()=>{r.invalidateQueries({queryKey:["oauth-connections"]})}})}function F2(){var ce;const{login:r,isAuthenticated:n}=Oi(),s=mg(),a=ei(),o=new URLSearchParams(a.search),f=o.get("token"),h=o.get("error"),m=((ce=a.state)==null?void 0:ce.from)??o.get("returnTo")??"/",g=O.useRef(!1);f&&!g.current&&(g.current=!0,r(f,void 0,{displayName:o.get("displayName"),username:o.get("username")}));const[y,E]=O.useState(""),[w,T]=O.useState(""),[q,M]=O.useState(h||""),[R,G]=O.useState(!1),[ne,ee]=O.useState(!!f),[me,re]=O.useState([]),C=O.useRef(!1);if(O.useEffect(()=>{f||C.current||(C.current=!0,(async()=>{var F,V,Z,ae;try{const se=await fetch(`${Wt}/api/settings`);if(!se.ok)return;const ke=await se.json();if(!((F=ke.auth)!=null&&F.sso))return;const He=await fetch(`${Wt}/api/auth/sso`,{method:"POST"});if(!He.ok){M("Host authentication required — please log in to your organization first");return}const Me=await He.json();Me.token&&((V=ke.auth)!=null&&V.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",ke.auth.ssoLogoutUrl),ee(!0),r(Me.token,void 0,{displayName:(Z=Me.user)==null?void 0:Z.display_name,username:(ae=Me.user)==null?void 0:ae.external_id}))}catch{}})())},[]),O.useEffect(()=>{f||G2().then(re).catch(()=>{})},[]),O.useEffect(()=>{if(!ne)return;const F=setTimeout(()=>s(m,{replace:!0}),1500);return()=>clearTimeout(F)},[ne]),n&&!ne)return d.jsx(Bn,{to:m,replace:!0});const K=async F=>{var V,Z;if(F.preventDefault(),M(""),!y.trim()||!w){M("Username and password are required");return}G(!0);try{const ae=await fetch(`${Wt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:y.trim(),password:w})}),se=await ae.json();if(!ae.ok){M(se.error||"Login failed");return}ee(!0),r(se.token,{username:y.trim(),password:w},{displayName:(V=se.user)==null?void 0:V.display_name,username:(Z=se.user)==null?void 0:Z.external_id})}catch{M("Unable to connect to server")}finally{G(!1)}};return d.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center overflow-hidden",children:d.jsxs("div",{className:"w-full max-w-md p-10",children:[d.jsx("div",{className:`mb-10 transition-all duration-[1500ms] ease-in ${ne?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:d.jsx(dh,{size:"lg",hideLabel:ne})}),d.jsxs("form",{onSubmit:K,className:`space-y-5 transition-opacity duration-300 ${ne?"opacity-0":""}`,children:[d.jsxs("div",{children:[d.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-text-secondary mb-2",children:"Username"}),d.jsx("input",{id:"username",type:"text",value:y,onChange:F=>E(F.target.value),className:"input",placeholder:"Enter your username",autoFocus:!ne,autoComplete:"username"})]}),d.jsxs("div",{children:[d.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-text-secondary mb-2",children:"Password"}),d.jsx("input",{id:"password",type:"password",value:w,onChange:F=>T(F.target.value),className:"input",placeholder:"Enter your password",autoComplete:"current-password"})]}),q&&d.jsx("p",{className:"text-sm text-status-error",children:q}),d.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:R||ne,children:R?"Signing in...":"Sign In"}),me.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[d.jsx("div",{className:"flex-1 h-px bg-border"}),d.jsx("span",{className:"text-xs text-text-tertiary",children:"or continue with"}),d.jsx("div",{className:"flex-1 h-px bg-border"})]}),d.jsx("div",{className:"space-y-2",children:me.filter(F=>F.provider!=="anthropic").map(F=>d.jsxs("a",{href:`${Wt}/api/auth/oauth/${F.provider}?returnTo=${encodeURIComponent(m)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[d.jsx(vy,{provider:F.provider}),"Sign in with ",F.name]},F.provider))})]})]})]})})}function og(){const{isAuthenticated:r}=Oi(),n=mg(),s=ei(),a=new URLSearchParams(s.search),o=a.get("state")||"";O.useEffect(()=>{r||n(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[r]);const[f,h]=O.useState(""),[m,g]=O.useState(a.get("label")||"default"),[y,E]=O.useState(""),[w,T]=O.useState(!1),q=f.trim().startsWith("sk-ant-oat"),M=f.trim().startsWith("sk-ant-api"),R=G=>{G.preventDefault();const ne=f.trim();if(!ne){E("A token or API key is required");return}if(!ne.startsWith("sk-ant-")){E('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}T(!0),E("");const ee=`${Wt}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(ne)}&state=${encodeURIComponent(o)}`;window.location.href=ee};return d.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:d.jsxs("div",{className:"w-full max-w-md p-10",children:[d.jsx("div",{className:"mb-10",children:d.jsx(dh,{size:"lg"})}),d.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[d.jsx(vy,{provider:"anthropic",className:"w-6 h-6"}),d.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Connect Anthropic"})]}),d.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"Connect your Anthropic account so Claude Code tasks run under your credentials. Your token is encrypted at rest."}),d.jsxs("form",{onSubmit:R,className:"space-y-5",children:[d.jsxs("div",{children:[d.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-text-secondary mb-2",children:"OAuth Token or API Key"}),d.jsx("input",{id:"token",type:"password",value:f,onChange:G=>h(G.target.value),className:"input",placeholder:"sk-ant-oat01-... or sk-ant-api03-...",autoFocus:!0,autoComplete:"off"}),q&&d.jsx("p",{className:"text-xs text-status-success mt-1",children:"OAuth token detected — uses your Claude subscription (flat rate)"}),M&&d.jsx("p",{className:"text-xs text-status-warning mt-1",children:"API key detected — billed per-token from your Anthropic API account"})]}),d.jsxs("div",{children:[d.jsx("label",{htmlFor:"label",className:"block text-sm font-medium text-text-secondary mb-2",children:"Label"}),d.jsx("input",{id:"label",type:"text",value:m,onChange:G=>g(G.target.value.replace(/\s+/g,"-").toLowerCase()),className:"input",placeholder:"default",autoComplete:"off"}),d.jsx("p",{className:"text-xs text-text-tertiary mt-1",children:'A name for this credential. Use different labels to store multiple credentials (e.g., "subscription", "api-batch").'})]}),y&&d.jsx("p",{className:"text-sm text-status-error",children:y}),d.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:w,children:w?"Validating...":"Connect"}),d.jsx("a",{href:"/",className:"block text-center text-sm text-text-tertiary hover:text-text-secondary",children:"Cancel"})]}),d.jsxs("div",{className:"mt-6 space-y-3 text-xs text-text-tertiary",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium text-text-secondary",children:"Recommended:"})," ","Run"," ",d.jsx("code",{className:"px-1 py-0.5 bg-surface-sunken rounded text-[11px]",children:"claude setup-token"})," ","in your terminal to generate an OAuth token that uses your subscription."]}),d.jsxs("div",{children:[d.jsx("span",{className:"font-medium text-text-secondary",children:"Alternative:"})," ","Use an API key from"," ",d.jsx("a",{href:"https://console.anthropic.com/settings/keys",target:"_blank",rel:"noopener noreferrer",className:"text-accent-secondary hover:underline",children:"console.anthropic.com"})," ","(billed per-token)."]})]})]})})}function Ca({roleTypes:r,roleNames:n,redirectTo:s="/"}){const{isSuperAdmin:a,hasRole:o,hasRoleType:f}=Oi();return a?d.jsx(xr,{}):r&&r.some(h=>f(h))?d.jsx(xr,{}):n&&n.some(h=>o(h))?d.jsx(xr,{}):d.jsx(Bn,{to:s,replace:!0})}function J2({redirectTo:r="/"}){var a;const{data:n,isLoading:s}=Qo();return s||!n?null:(a=n.ai)!=null&&a.enabled?d.jsx(xr,{}):d.jsx(Bn,{to:r,replace:!0})}function I2({flag:r,redirectTo:n="/"}){var o;const{data:s,isLoading:a}=Qo();return a||!s?null:((o=s.features)==null?void 0:o[r])===!1?d.jsx(Bn,{to:n,replace:!0}):d.jsx(xr,{})}const Q2=O.lazy(()=>ve(()=>import("./ProcessesListPage-Dhik7XpW.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]),import.meta.url).then(r=>({default:r.ProcessesListPage}))),X2=O.lazy(()=>ve(()=>import("./ProcessDetailPage-BuSi654J.js"),__vite__mapDeps([18,1,2,4,19,15,20,17,11,6,21,22,23]),import.meta.url).then(r=>({default:r.ProcessDetailPage}))),K2=O.lazy(()=>ve(()=>import("./McpOverview-CTCYZXIp.js"),__vite__mapDeps([24,1,25,26,27,28,14,15,29,6]),import.meta.url).then(r=>({default:r.McpOverview}))),Z2=O.lazy(()=>ve(()=>import("./McpRunsPage-Df1GqxUg.js"),__vite__mapDeps([30,1,26,27,5,6,31,28,8,9,10,17,15,32,14,13,12,16,33]),import.meta.url).then(r=>({default:r.McpRunsPage}))),W2=O.lazy(()=>ve(()=>import("./McpRunDetailPage-CXGCVmPq.js"),__vite__mapDeps([34,1,26,20,14,15,35,6,36,37,16,38,39,40,13]),import.meta.url).then(r=>({default:r.McpRunDetailPage}))),eE=O.lazy(()=>ve(()=>import("./McpQueryPage-BbYojoHu.js"),__vite__mapDeps([41,1,14,15,9,10,13,12,16,8,11,32,17,33,5,6,4,42]),import.meta.url).then(r=>({default:r.McpQueryPage}))),tE=O.lazy(()=>ve(()=>import("./McpQueryDetailPage-BOaXf0bZ.js"),__vite__mapDeps([43,1,14,15,20,42,6,27,4,44,36,26,3,2,45,46,47,48,49,50,35,51,38,39]),import.meta.url).then(r=>({default:r.McpQueryDetailPage}))),nE=O.lazy(()=>ve(()=>import("./EscalationsOverview-CE2p70Ct.js"),__vite__mapDeps([52,1,4,14,15,29,6]),import.meta.url).then(r=>({default:r.EscalationsOverview}))),sE=O.lazy(()=>ve(()=>import("./AvailableEscalationsPage-BcbhA6NE.js"),__vite__mapDeps([53,1,6,4,54,55,56,57,5,7,8,9,10,12,14,15,23,58,13,59,21,17,60,33,16]),import.meta.url).then(r=>({default:r.AvailableEscalationsPage}))),iE=O.lazy(()=>ve(()=>import("./OperatorDashboard-DIR7XDeD.js"),__vite__mapDeps([61,1,4,57,5,6,7,8,9,10,14,15,12,33,58,13,59,21,17,60,16]),import.meta.url).then(r=>({default:r.OperatorDashboard}))),rE=O.lazy(()=>ve(()=>import("./index-IIq5Tkqs.js"),__vite__mapDeps([62,1,37,54,55,6,56,57,14,15,60,16,3,4,22,23,20,21,35,36]),import.meta.url).then(r=>({default:r.EscalationDetailPage}))),aE=O.lazy(()=>ve(()=>import("./WorkflowsOverview-CaXWYZuw.js"),__vite__mapDeps([63,1,3,4,14,15,29,6]),import.meta.url).then(r=>({default:r.WorkflowsOverview}))),lE=O.lazy(()=>ve(()=>import("./index-BH67e1Ah.js"),__vite__mapDeps([64,1,3,14,15,13,17,65,48,49,6]),import.meta.url).then(r=>({default:r.StartWorkflowPage}))),oE=O.lazy(()=>ve(()=>import("./index-BH67e1Ah.js"),__vite__mapDeps([64,1,3,14,15,13,17,65,48,49,6]),import.meta.url).then(r=>({default:r.DurableInvokePage}))),cE=O.lazy(()=>ve(()=>import("./WorkflowsDashboard-CSYrYQsO.js"),__vite__mapDeps([66,1,32,3,31,28,6,4,5,8,9,10,17,15,14,13,12,16,33]),import.meta.url).then(r=>({default:()=>r.WorkflowsDashboard({tier:"durable"})}))),uE=O.lazy(()=>ve(()=>import("./WorkflowsDashboard-CSYrYQsO.js"),__vite__mapDeps([66,1,32,3,31,28,6,4,5,8,9,10,17,15,14,13,12,16,33]),import.meta.url).then(r=>({default:()=>r.WorkflowsDashboard({tier:"all"})}))),fE=O.lazy(()=>ve(()=>import("./YamlWorkflowsPage-D5zc8Lta.js"),__vite__mapDeps([67,1,27,5,6,14,15,13,10,50,65,20]),import.meta.url).then(r=>({default:r.YamlWorkflowsPage}))),hE=O.lazy(()=>ve(()=>import("./GraphInvokePage-DywWVSdj.js"),__vite__mapDeps([68,1,27,14,15,45,47,48,49,46,6,50,65]),import.meta.url).then(r=>({default:r.GraphInvokePage}))),dE=O.lazy(()=>ve(()=>import("./YamlWorkflowDetailPage-CRBXahFJ.js"),__vite__mapDeps([69,1,27,20,65,15,6]),import.meta.url).then(r=>({default:r.YamlWorkflowDetailPage}))),mE=O.lazy(()=>ve(()=>import("./TasksListPage-M6ok-Nfd.js"),__vite__mapDeps([70,1,2,3,5,6,9,10,20,59,51,12,13,14,15,17]),import.meta.url).then(r=>({default:r.TasksListPage}))),pE=O.lazy(()=>ve(()=>import("./TaskDetailPage-pSU3xuG9.js"),__vite__mapDeps([71,1,2,20,59,14,15,6]),import.meta.url).then(r=>({default:r.TaskDetailPage}))),cg=O.lazy(()=>ve(()=>import("./WorkflowExecutionPage-BR0oVx_p.js"),__vite__mapDeps([72,1,3,4,37,2,14,15,36,16,20,35,6,38,39,40,13]),import.meta.url).then(r=>({default:r.WorkflowExecutionPage}))),gE=O.lazy(()=>ve(()=>import("./AdminDashboard-RrSvb8d-.js"),__vite__mapDeps([73,1,2,4,25,19,15,6]),import.meta.url).then(r=>({default:r.AdminDashboard}))),yE=O.lazy(()=>ve(()=>import("./index-Gt2Rebs9.js"),__vite__mapDeps([74,1,3,9,10,13,33,5,6,14,15,75,17]),import.meta.url).then(r=>({default:r.WorkersPage}))),bE=O.lazy(()=>ve(()=>import("./index-CV8soXIM.js"),__vite__mapDeps([76,1,3,13,77,55,6,21,15,17,14,57,48,49,65]),import.meta.url).then(r=>({default:r.WorkflowConfigsPage}))),ug=O.lazy(()=>ve(()=>import("./index-CV8soXIM.js"),__vite__mapDeps([76,1,3,13,77,55,6,21,15,17,14,57,48,49,65]),import.meta.url).then(r=>({default:r.WorkflowConfigDetailPage}))),xE=O.lazy(()=>ve(()=>import("./index-CdN-Z8-r.js"),__vite__mapDeps([78,1,25,10,77,55,6,14,15,13,12,5,79,47,48,49,50,46,33,20]),import.meta.url).then(r=>({default:r.McpServersPage}))),fg=O.lazy(()=>ve(()=>import("./index-C3QKGY5C.js"),__vite__mapDeps([80,1,25,14,15,44,6]),import.meta.url).then(r=>({default:r.McpServerDetailPage}))),vE=O.lazy(()=>ve(()=>import("./index-Bwofyfi8.js"),__vite__mapDeps([81,1,23,5,6,9,10,12,13,77,55,33,14,15,21,49,11,57,51]),import.meta.url).then(r=>({default:r.UsersPage}))),_E=O.lazy(()=>ve(()=>import("./RolesPage-BRicD5mx.js"),__vite__mapDeps([82,1,57,14,15,55,6]),import.meta.url).then(r=>({default:r.RolesPage}))),wE=O.lazy(()=>ve(()=>import("./RoleDetailPage-BfzqQxMU.js"),__vite__mapDeps([83,1,57,77,55,6,23,15]),import.meta.url).then(r=>({default:r.RoleDetailPage}))),SE=O.lazy(()=>ve(()=>import("./EscalationSchemaPage-Zsmewko2.js"),__vite__mapDeps([84,1,57,15,6]),import.meta.url).then(r=>({default:r.EscalationSchemaPage}))),EE=O.lazy(()=>ve(()=>import("./index-DHhz71yv.js"),__vite__mapDeps([85,1,14,15,55,6,56]),import.meta.url).then(r=>({default:r.MaintenancePage}))),AE=O.lazy(()=>ve(()=>import("./OperationsPage-DgZYi-BC.js").then(r=>r.O),__vite__mapDeps([86,1,57,4,14,15,6]),import.meta.url).then(r=>({default:r.OperationsPage}))),jE=O.lazy(()=>ve(()=>import("./index-D7NHjvA4.js"),__vite__mapDeps([87,1,19,15,13,5,6,31,28,55,36,75,9,10,33]),import.meta.url).then(r=>({default:r.ControlPlanePage}))),OE=O.lazy(()=>ve(()=>import("./index-CJpywoA8.js"),__vite__mapDeps([88,1,6,39,15,5,31,28,8,9,10,12,13,11,14,16]),import.meta.url).then(r=>({default:r.StreamMessagesPage}))),TE=O.lazy(()=>ve(()=>import("./CredentialsPage-DJ9DyXsO.js"),__vite__mapDeps([89,1,14,15,51,77,55,6]),import.meta.url).then(r=>({default:r.CredentialsPage}))),NE=O.lazy(()=>ve(()=>import("./index-B-LQ8fsJ.js"),__vite__mapDeps([90,1,6,14,15,13,16,8,10,91,51]),import.meta.url).then(r=>({default:r.FilesPage}))),CE=O.lazy(()=>ve(()=>import("./index-_gh2K9DU.js"),__vite__mapDeps([92,1,14,15,13,16,12,10,91,51,93,44,6]),import.meta.url).then(r=>({default:r.KnowledgePage}))),kE=O.lazy(()=>ve(()=>import("./HomePage-CxtBiULd.js"),__vite__mapDeps([94,1,57,3,26,28,4,21,15,17,16,86,14,6]),import.meta.url).then(r=>({default:r.HomePage}))),ME=O.lazy(()=>ve(()=>import("./AgentsPage-CxNNtSsf.js"),__vite__mapDeps([95,1,96,4,5,6,8,9,10,12,13,14,15,16]),import.meta.url).then(r=>({default:r.AgentsPage}))),RE=O.lazy(()=>ve(()=>import("./AgentDetailPage-C_-sIBcr.js"),__vite__mapDeps([97,1,96,98,15,4,17,6]),import.meta.url).then(r=>({default:r.AgentDetailPage}))),hg=O.lazy(()=>ve(()=>import("./AgentConfigPage-5RMdI0ku.js"),__vite__mapDeps([99,1,96,98,15,14,93,47,48,49,3,27,100,101,17,6]),import.meta.url).then(r=>({default:r.AgentConfigPage}))),DE=O.lazy(()=>ve(()=>import("./CapabilitiesPage-DlZ8SgO3.js"),__vite__mapDeps([102,1,100,79,25,47,48,49,15,50,6,46,14,13]),import.meta.url).then(r=>({default:r.CapabilitiesPage}))),zE=O.lazy(()=>ve(()=>import("./TopicsPage-CIGi3TdT.js"),__vite__mapDeps([103,1,101,14,15,13,6]),import.meta.url).then(r=>({default:r.TopicsPage}))),qE=O.lazy(()=>ve(()=>import("./TopicDetailPage-C9gvoWYu.js"),__vite__mapDeps([104,1,101,16,15,6]),import.meta.url).then(r=>({default:r.TopicDetailPage})));function UE(){return d.jsxs("div",{className:"animate-pulse space-y-4",children:[d.jsx("div",{className:"h-8 bg-surface-sunken rounded w-48"}),d.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]})}function be({children:r}){return d.jsx(O.Suspense,{fallback:d.jsx(UE,{}),children:d.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:r})})}const _y=new Mx({defaultOptions:{queries:{staleTime:1e4,retry:(r,n)=>n instanceof Error&&n.message==="Session expired"?!1:r<1}}});window.addEventListener("auth:unauthorized",()=>{_y.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const r=window.__LT_BASE__||"",n=`${r}/login`;if(window.location.pathname!==n){const s=window.location.pathname+window.location.search,a=r&&s.startsWith(r)?s.slice(r.length)||"/":s;window.location.href=`${n}?returnTo=${encodeURIComponent(a)}`}});const BE=zx([{path:"/login",element:d.jsx(F2,{})},{path:"/connect/anthropic",element:d.jsx(og,{})},{path:"/connect/:provider",element:d.jsx(og,{})},{path:"/",element:d.jsx(Y2,{}),children:[{index:!0,element:d.jsx(be,{children:d.jsx(kE,{})})},{path:"processes/all",element:d.jsx(be,{children:d.jsx(Q2,{})})},{path:"processes/detail/:originId",element:d.jsx(be,{children:d.jsx(X2,{})})},{path:"credentials",element:d.jsx(be,{children:d.jsx(TE,{})})},{path:"connections",element:d.jsx(Bn,{to:"/credentials",replace:!0})},{path:"escalations",element:d.jsx(be,{children:d.jsx(nE,{})})},{path:"escalations/available",element:d.jsx(be,{children:d.jsx(sE,{})})},{path:"escalations/queue",element:d.jsx(be,{children:d.jsx(iE,{})})},{path:"escalations/detail/:id",element:d.jsx(be,{children:d.jsx(rE,{})})},{path:"capabilities",element:d.jsx(be,{children:d.jsx(DE,{})})},{path:"agents",element:d.jsx(be,{children:d.jsx(ME,{})})},{path:"agents/new",element:d.jsx(be,{children:d.jsx(hg,{})})},{path:"agents/:id",element:d.jsx(be,{children:d.jsx(RE,{})})},{path:"agents/:id/edit",element:d.jsx(be,{children:d.jsx(hg,{})})},{path:"topics",element:d.jsx(be,{children:d.jsx(zE,{})})},{path:"topics/:topic",element:d.jsx(be,{children:d.jsx(qE,{})})},{element:d.jsx(Ca,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:d.jsx(be,{children:d.jsx(aE,{})})},{path:"workflows/executions",element:d.jsx(be,{children:d.jsx(uE,{})})},{path:"workflows/durable/executions",element:d.jsx(be,{children:d.jsx(cE,{})})},{path:"workflows/durable/executions/:workflowId",element:d.jsx(be,{children:d.jsx(cg,{})})},{path:"workflows/tasks",element:d.jsx(be,{children:d.jsx(mE,{})})},{path:"workflows/tasks/detail/:id",element:d.jsx(be,{children:d.jsx(pE,{})})},{path:"workflows/executions/:workflowId",element:d.jsx(be,{children:d.jsx(cg,{})})},{path:"workflows/start",element:d.jsx(be,{children:d.jsx(lE,{})})},{path:"workflows/durable/invoke",element:d.jsx(be,{children:d.jsx(oE,{})})},{path:"workflows/cron",element:d.jsx(Bn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:d.jsx(be,{children:d.jsx(yE,{})})},{path:"workflows/registry",element:d.jsx(be,{children:d.jsx(bE,{})})},{path:"workflows/registry/new",element:d.jsx(be,{children:d.jsx(ug,{})})},{path:"workflows/registry/:workflowType",element:d.jsx(be,{children:d.jsx(ug,{})})}]},{element:d.jsx(Ca,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:d.jsx(be,{children:d.jsx(fE,{})})},{path:"mcp/workflows/invoke",element:d.jsx(be,{children:d.jsx(hE,{})})},{path:"mcp/workflows/:id",element:d.jsx(be,{children:d.jsx(dE,{})})},{path:"mcp/executions",element:d.jsx(be,{children:d.jsx(Z2,{})})},{path:"mcp/executions/:jobId",element:d.jsx(be,{children:d.jsx(W2,{})})},{path:"files",element:d.jsx(be,{children:d.jsx(NE,{})})},{path:"knowledge",element:d.jsx(be,{children:d.jsx(CE,{})})},{element:d.jsx(J2,{}),children:[{path:"mcp",element:d.jsx(be,{children:d.jsx(K2,{})})},{path:"mcp/queries",element:d.jsx(be,{children:d.jsx(eE,{})})},{path:"mcp/queries/:workflowId",element:d.jsx(be,{children:d.jsx(tE,{})})},{path:"mcp/tools",element:d.jsx(Bn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:d.jsx(be,{children:d.jsx(xE,{})})},{path:"mcp/servers/new",element:d.jsx(be,{children:d.jsx(fg,{})})},{path:"mcp/servers/:serverId",element:d.jsx(be,{children:d.jsx(fg,{})})}]}]},{element:d.jsx(Ca,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"operations",element:d.jsx(be,{children:d.jsx(AE,{})})}]},{element:d.jsx(Ca,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:d.jsx(be,{children:d.jsx(gE,{})})},{path:"admin/users",element:d.jsx(be,{children:d.jsx(vE,{})})},{path:"admin/escalation-chains",element:d.jsx(Bn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:d.jsx(be,{children:d.jsx(_E,{})})},{path:"admin/roles/:role",element:d.jsx(be,{children:d.jsx(wE,{})})},{path:"admin/roles/:role/schema",element:d.jsx(be,{children:d.jsx(SE,{})})}]},{element:d.jsx(Ca,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:d.jsx(Bn,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:d.jsx(I2,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:d.jsx(be,{children:d.jsx(EE,{})})}]},{path:"admin/controlplane",element:d.jsx(be,{children:d.jsx(jE,{})})},{path:"admin/streams",element:d.jsx(be,{children:d.jsx(OE,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function LE(){return d.jsx(Rx,{client:_y,children:d.jsx(gv,{children:d.jsx(vw,{children:d.jsx(qx,{router:BE})})})})}ay(ry());hv.createRoot(document.getElementById("root")).render(d.jsx(O.StrictMode,{children:d.jsx(LE,{})}));export{XE as A,e3 as B,mh as C,q2 as D,a3 as E,oy as F,gh as G,xy as H,f3 as I,sS as J,o3 as K,Wt as L,ph as M,x_ as N,vg as O,VE as P,m3 as Q,p3 as R,Vw as S,vy as T,c3 as U,d3 as a,z2 as b,__ as c,$e as d,QE as e,M2 as f,KE as g,WE as h,FE as i,Oi as j,IE as k,t3 as l,n3 as m,s3 as n,i3 as o,r3 as p,l3 as q,JE as r,Aw as s,Ew as t,Qo as u,Wg as v,ZE as w,h3 as x,u3 as y,yh as z};
63
+ //# sourceMappingURL=index-B_aFcGv9.js.map