@hotmeshio/long-tail 0.7.0 → 0.7.2

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 (231) hide show
  1. package/build/api/escalations/create.js +30 -9
  2. package/build/api/roles.d.ts +32 -0
  3. package/build/api/roles.js +73 -0
  4. package/build/bin/ltc.js +23 -0
  5. package/build/lib/cli/commands/roles.d.ts +17 -0
  6. package/build/lib/cli/commands/roles.js +102 -0
  7. package/build/lib/db/schemas/017_role_schema_versions.sql +40 -0
  8. package/build/lib/db/schemas/018_role_upstreams.sql +21 -0
  9. package/build/routes/roles.js +20 -0
  10. package/build/scripts/ortho-populate.d.ts +80 -8
  11. package/build/scripts/ortho-populate.js +204 -52
  12. package/build/sdk/index.d.ts +2 -0
  13. package/build/sdk/index.js +2 -0
  14. package/build/services/interceptor/completion.js +17 -12
  15. package/build/services/orchestrator/condition.d.ts +25 -1
  16. package/build/services/orchestrator/condition.js +29 -1
  17. package/build/services/role/index.d.ts +15 -1
  18. package/build/services/role/index.js +45 -1
  19. package/build/services/role/sql.d.ts +23 -2
  20. package/build/services/role/sql.js +93 -16
  21. package/build/services/role/types.d.ts +41 -0
  22. package/build/system/mcp-servers/admin/index.js +3 -3
  23. package/build/system/mcp-servers/admin/schemas.d.ts +25 -2
  24. package/build/system/mcp-servers/admin/schemas.js +11 -2
  25. package/build/system/mcp-servers/admin/users.js +42 -0
  26. package/build/system/mcp-servers/human-queue-schemas.d.ts +6 -0
  27. package/build/system/mcp-servers/human-queue-schemas.js +4 -0
  28. package/build/system/mcp-servers/human-queue.js +10 -2
  29. package/build/system/seed/tool-manifests-admin.d.ts +371 -0
  30. package/build/system/seed/tool-manifests-admin.js +3 -1
  31. package/build/tsconfig.tsbuildinfo +1 -1
  32. package/build/types/escalation.d.ts +16 -0
  33. package/build/types/escalation.js +17 -0
  34. package/dashboard/dist/assets/{AdminDashboard-Bg1HgukI.js → AdminDashboard-rZDVS2G_.js} +2 -2
  35. package/dashboard/dist/assets/{AdminDashboard-Bg1HgukI.js.map → AdminDashboard-rZDVS2G_.js.map} +1 -1
  36. package/dashboard/dist/assets/{AgentConfigPage-HBe_YDU_.js → AgentConfigPage-CbyyCjCT.js} +2 -2
  37. package/dashboard/dist/assets/{AgentConfigPage-HBe_YDU_.js.map → AgentConfigPage-CbyyCjCT.js.map} +1 -1
  38. package/dashboard/dist/assets/{AgentDetailPage-BsaiYbwL.js → AgentDetailPage-DMeHvidT.js} +2 -2
  39. package/dashboard/dist/assets/{AgentDetailPage-BsaiYbwL.js.map → AgentDetailPage-DMeHvidT.js.map} +1 -1
  40. package/dashboard/dist/assets/{AgentsPage-DhN2lIBh.js → AgentsPage-C8fKLxh-.js} +2 -2
  41. package/dashboard/dist/assets/{AgentsPage-DhN2lIBh.js.map → AgentsPage-C8fKLxh-.js.map} +1 -1
  42. package/dashboard/dist/assets/{AvailableEscalationsPage-_xcWvlIz.js → AvailableEscalationsPage-CUHcybKU.js} +2 -2
  43. package/dashboard/dist/assets/{AvailableEscalationsPage-_xcWvlIz.js.map → AvailableEscalationsPage-CUHcybKU.js.map} +1 -1
  44. package/dashboard/dist/assets/{BotPicker-DY6iUVC9.js → BotPicker-DGhniNcy.js} +2 -2
  45. package/dashboard/dist/assets/{BotPicker-DY6iUVC9.js.map → BotPicker-DGhniNcy.js.map} +1 -1
  46. package/dashboard/dist/assets/{CapabilitiesPage-w1owqsmN.js → CapabilitiesPage-ClfuW4ya.js} +2 -2
  47. package/dashboard/dist/assets/{CapabilitiesPage-w1owqsmN.js.map → CapabilitiesPage-ClfuW4ya.js.map} +1 -1
  48. package/dashboard/dist/assets/{CollapsibleSection-DIMGjlJ-.js → CollapsibleSection-DnECdKEY.js} +2 -2
  49. package/dashboard/dist/assets/{CollapsibleSection-DIMGjlJ-.js.map → CollapsibleSection-DnECdKEY.js.map} +1 -1
  50. package/dashboard/dist/assets/{CredentialsPage-D1OmMHux.js → CredentialsPage-DdZ-jyyc.js} +2 -2
  51. package/dashboard/dist/assets/{CredentialsPage-D1OmMHux.js.map → CredentialsPage-DdZ-jyyc.js.map} +1 -1
  52. package/dashboard/dist/assets/{CronLabel-CQy3DrUQ.js → CronLabel-CymxLvY0.js} +2 -2
  53. package/dashboard/dist/assets/{CronLabel-CQy3DrUQ.js.map → CronLabel-CymxLvY0.js.map} +1 -1
  54. package/dashboard/dist/assets/{CustomDurationPicker-BoBkl9tw.js → CustomDurationPicker-8JHvVWD2.js} +2 -2
  55. package/dashboard/dist/assets/{CustomDurationPicker-BoBkl9tw.js.map → CustomDurationPicker-8JHvVWD2.js.map} +1 -1
  56. package/dashboard/dist/assets/{DropZone-QXbiuU0b.js → DropZone-DEX0BBqt.js} +2 -2
  57. package/dashboard/dist/assets/{DropZone-QXbiuU0b.js.map → DropZone-DEX0BBqt.js.map} +1 -1
  58. package/dashboard/dist/assets/{ElapsedCell-Donjm9gT.js → ElapsedCell-BRZfw_Af.js} +2 -2
  59. package/dashboard/dist/assets/{ElapsedCell-Donjm9gT.js.map → ElapsedCell-BRZfw_Af.js.map} +1 -1
  60. package/dashboard/dist/assets/EscalationSchemaPage-Do2iPKUl.js +9 -0
  61. package/dashboard/dist/assets/EscalationSchemaPage-Do2iPKUl.js.map +1 -0
  62. package/dashboard/dist/assets/{EscalationsOverview-CvHIJ_GG.js → EscalationsOverview-CiQO3ntf.js} +2 -2
  63. package/dashboard/dist/assets/{EscalationsOverview-CvHIJ_GG.js.map → EscalationsOverview-CiQO3ntf.js.map} +1 -1
  64. package/dashboard/dist/assets/{EventTable-DpAXMmT3.js → EventTable-CLuAbba_.js} +2 -2
  65. package/dashboard/dist/assets/{EventTable-DpAXMmT3.js.map → EventTable-CLuAbba_.js.map} +1 -1
  66. package/dashboard/dist/assets/{GraphInvokePage-De1XVx5d.js → GraphInvokePage-BFRi6Nny.js} +2 -2
  67. package/dashboard/dist/assets/{GraphInvokePage-De1XVx5d.js.map → GraphInvokePage-BFRi6Nny.js.map} +1 -1
  68. package/dashboard/dist/assets/{HomePage-BYR5VXXw.js → HomePage-m1pnxilb.js} +2 -2
  69. package/dashboard/dist/assets/{HomePage-BYR5VXXw.js.map → HomePage-m1pnxilb.js.map} +1 -1
  70. package/dashboard/dist/assets/{ListToolbar-Bx7jGzPA.js → ListToolbar-D4Y-M7wN.js} +2 -2
  71. package/dashboard/dist/assets/{ListToolbar-Bx7jGzPA.js.map → ListToolbar-D4Y-M7wN.js.map} +1 -1
  72. package/dashboard/dist/assets/{McpOverview-DXRKcJN0.js → McpOverview-mfJpETsW.js} +2 -2
  73. package/dashboard/dist/assets/{McpOverview-DXRKcJN0.js.map → McpOverview-mfJpETsW.js.map} +1 -1
  74. package/dashboard/dist/assets/{McpQueryDetailPage-CmW15w5e.js → McpQueryDetailPage-Cb99vI7v.js} +2 -2
  75. package/dashboard/dist/assets/{McpQueryDetailPage-CmW15w5e.js.map → McpQueryDetailPage-Cb99vI7v.js.map} +1 -1
  76. package/dashboard/dist/assets/{McpQueryPage-BE6I011z.js → McpQueryPage-CKKOxks0.js} +2 -2
  77. package/dashboard/dist/assets/{McpQueryPage-BE6I011z.js.map → McpQueryPage-CKKOxks0.js.map} +1 -1
  78. package/dashboard/dist/assets/{McpRunDetailPage-Dsa3G3XQ.js → McpRunDetailPage-CyTbHs0J.js} +2 -2
  79. package/dashboard/dist/assets/{McpRunDetailPage-Dsa3G3XQ.js.map → McpRunDetailPage-CyTbHs0J.js.map} +1 -1
  80. package/dashboard/dist/assets/{McpRunsPage-uTbym66Y.js → McpRunsPage-MIwmK-Ky.js} +2 -2
  81. package/dashboard/dist/assets/{McpRunsPage-uTbym66Y.js.map → McpRunsPage-MIwmK-Ky.js.map} +1 -1
  82. package/dashboard/dist/assets/{NamespacePill-BGf0jHwE.js → NamespacePill-CwKdoyRM.js} +2 -2
  83. package/dashboard/dist/assets/{NamespacePill-BGf0jHwE.js.map → NamespacePill-CwKdoyRM.js.map} +1 -1
  84. package/dashboard/dist/assets/OperationsPage-DPesph0U.js +2 -0
  85. package/dashboard/dist/assets/OperationsPage-DPesph0U.js.map +1 -0
  86. package/dashboard/dist/assets/{OperatorDashboard-i8cxaDlk.js → OperatorDashboard-K1gzULr7.js} +2 -2
  87. package/dashboard/dist/assets/{OperatorDashboard-i8cxaDlk.js.map → OperatorDashboard-K1gzULr7.js.map} +1 -1
  88. package/dashboard/dist/assets/{PageHeader-BZJsEVOC.js → PageHeader-BhaWTWcM.js} +2 -2
  89. package/dashboard/dist/assets/{PageHeader-BZJsEVOC.js.map → PageHeader-BhaWTWcM.js.map} +1 -1
  90. package/dashboard/dist/assets/{PageHeaderWithStats-BWuD7s9c.js → PageHeaderWithStats-yex5WmHB.js} +2 -2
  91. package/dashboard/dist/assets/{PageHeaderWithStats-BWuD7s9c.js.map → PageHeaderWithStats-yex5WmHB.js.map} +1 -1
  92. package/dashboard/dist/assets/{ProcessDetailPage-CP7GZhgs.js → ProcessDetailPage-DBIrY6Vd.js} +2 -2
  93. package/dashboard/dist/assets/{ProcessDetailPage-CP7GZhgs.js.map → ProcessDetailPage-DBIrY6Vd.js.map} +1 -1
  94. package/dashboard/dist/assets/{ProcessesListPage-btsU6hBR.js → ProcessesListPage-CrLGDCAD.js} +2 -2
  95. package/dashboard/dist/assets/{ProcessesListPage-btsU6hBR.js.map → ProcessesListPage-CrLGDCAD.js.map} +1 -1
  96. package/dashboard/dist/assets/RoleDetailPage-7j6Mk780.js +11 -0
  97. package/dashboard/dist/assets/RoleDetailPage-7j6Mk780.js.map +1 -0
  98. package/dashboard/dist/assets/{RolePill-Pb9TKSQN.js → RolePill-Cl71eDUA.js} +2 -2
  99. package/dashboard/dist/assets/{RolePill-Pb9TKSQN.js.map → RolePill-Cl71eDUA.js.map} +1 -1
  100. package/dashboard/dist/assets/RolesPage-B0ZgjB2V.js +2 -0
  101. package/dashboard/dist/assets/{RolesPage-1DBoEMsb.js.map → RolesPage-B0ZgjB2V.js.map} +1 -1
  102. package/dashboard/dist/assets/{RunAsSelector-Cp6j3FEY.js → RunAsSelector-DA0h41ml.js} +2 -2
  103. package/dashboard/dist/assets/{RunAsSelector-Cp6j3FEY.js.map → RunAsSelector-DA0h41ml.js.map} +1 -1
  104. package/dashboard/dist/assets/{StickyPagination-Pr8kawv8.js → StickyPagination-t5B71hwd.js} +2 -2
  105. package/dashboard/dist/assets/{StickyPagination-Pr8kawv8.js.map → StickyPagination-t5B71hwd.js.map} +1 -1
  106. package/dashboard/dist/assets/{StreamMessageDetail-BqmQ-N3y.js → StreamMessageDetail-CYFnZsYA.js} +2 -2
  107. package/dashboard/dist/assets/{StreamMessageDetail-BqmQ-N3y.js.map → StreamMessageDetail-CYFnZsYA.js.map} +1 -1
  108. package/dashboard/dist/assets/{SwimlaneTimeline-y1YmXrsj.js → SwimlaneTimeline-CY18gBek.js} +2 -2
  109. package/dashboard/dist/assets/{SwimlaneTimeline-y1YmXrsj.js.map → SwimlaneTimeline-CY18gBek.js.map} +1 -1
  110. package/dashboard/dist/assets/{TagInput-Df4myuYF.js → TagInput-B_WQiuer.js} +2 -2
  111. package/dashboard/dist/assets/{TagInput-Df4myuYF.js.map → TagInput-B_WQiuer.js.map} +1 -1
  112. package/dashboard/dist/assets/{TaskDetailPage-CT5rXHK5.js → TaskDetailPage-B9owzuhV.js} +2 -2
  113. package/dashboard/dist/assets/{TaskDetailPage-CT5rXHK5.js.map → TaskDetailPage-B9owzuhV.js.map} +1 -1
  114. package/dashboard/dist/assets/{TaskQueuePill-YalYdCNo.js → TaskQueuePill-Lgn2obNU.js} +2 -2
  115. package/dashboard/dist/assets/{TaskQueuePill-YalYdCNo.js.map → TaskQueuePill-Lgn2obNU.js.map} +1 -1
  116. package/dashboard/dist/assets/{TasksListPage-DOy6JlKS.js → TasksListPage-Dlsu7cWG.js} +2 -2
  117. package/dashboard/dist/assets/{TasksListPage-DOy6JlKS.js.map → TasksListPage-Dlsu7cWG.js.map} +1 -1
  118. package/dashboard/dist/assets/{TimeAgo-BAQwZSpq.js → TimeAgo-CSzifQXB.js} +2 -2
  119. package/dashboard/dist/assets/{TimeAgo-BAQwZSpq.js.map → TimeAgo-CSzifQXB.js.map} +1 -1
  120. package/dashboard/dist/assets/{TimestampCell-BK_jufns.js → TimestampCell-CIxgN57O.js} +2 -2
  121. package/dashboard/dist/assets/{TimestampCell-BK_jufns.js.map → TimestampCell-CIxgN57O.js.map} +1 -1
  122. package/dashboard/dist/assets/{ToolPill-VGpT6Quy.js → ToolPill-uVqcbHPE.js} +2 -2
  123. package/dashboard/dist/assets/{ToolPill-VGpT6Quy.js.map → ToolPill-uVqcbHPE.js.map} +1 -1
  124. package/dashboard/dist/assets/{ToolTestPanel-5PMQyUCe.js → ToolTestPanel-Bw844EW3.js} +2 -2
  125. package/dashboard/dist/assets/{ToolTestPanel-5PMQyUCe.js.map → ToolTestPanel-Bw844EW3.js.map} +1 -1
  126. package/dashboard/dist/assets/{TopicDetailPage-Cn1ShfR8.js → TopicDetailPage-HuDx2oAW.js} +2 -2
  127. package/dashboard/dist/assets/{TopicDetailPage-Cn1ShfR8.js.map → TopicDetailPage-HuDx2oAW.js.map} +1 -1
  128. package/dashboard/dist/assets/{TopicsPage-D67tjS8L.js → TopicsPage-CAG0RhAK.js} +2 -2
  129. package/dashboard/dist/assets/{TopicsPage-D67tjS8L.js.map → TopicsPage-CAG0RhAK.js.map} +1 -1
  130. package/dashboard/dist/assets/{UserName-Dsu1Jk4N.js → UserName-CoGYeig8.js} +2 -2
  131. package/dashboard/dist/assets/{UserName-Dsu1Jk4N.js.map → UserName-CoGYeig8.js.map} +1 -1
  132. package/dashboard/dist/assets/{WorkflowExecutionPage-BwQoOmUE.js → WorkflowExecutionPage-Dhb9EWgI.js} +2 -2
  133. package/dashboard/dist/assets/{WorkflowExecutionPage-BwQoOmUE.js.map → WorkflowExecutionPage-Dhb9EWgI.js.map} +1 -1
  134. package/dashboard/dist/assets/{WorkflowPill-pPUqmx6Q.js → WorkflowPill-IDjTRfQ8.js} +2 -2
  135. package/dashboard/dist/assets/{WorkflowPill-pPUqmx6Q.js.map → WorkflowPill-IDjTRfQ8.js.map} +1 -1
  136. package/dashboard/dist/assets/{WorkflowsDashboard-D3z7COgH.js → WorkflowsDashboard-bJ6Zebfv.js} +2 -2
  137. package/dashboard/dist/assets/{WorkflowsDashboard-D3z7COgH.js.map → WorkflowsDashboard-bJ6Zebfv.js.map} +1 -1
  138. package/dashboard/dist/assets/{WorkflowsOverview-C15JcxyY.js → WorkflowsOverview-B8262fVx.js} +2 -2
  139. package/dashboard/dist/assets/{WorkflowsOverview-C15JcxyY.js.map → WorkflowsOverview-B8262fVx.js.map} +1 -1
  140. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BYq3t7E-.js → YamlWorkflowDetailPage-DhW3q2cO.js} +2 -2
  141. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BYq3t7E-.js.map → YamlWorkflowDetailPage-DhW3q2cO.js.map} +1 -1
  142. package/dashboard/dist/assets/{YamlWorkflowsPage-B44WgwE_.js → YamlWorkflowsPage-C8hBjSn_.js} +2 -2
  143. package/dashboard/dist/assets/{YamlWorkflowsPage-B44WgwE_.js.map → YamlWorkflowsPage-C8hBjSn_.js.map} +1 -1
  144. package/dashboard/dist/assets/{agents-BRmmK6Y9.js → agents-j2YErVp4.js} +2 -2
  145. package/dashboard/dist/assets/{agents-BRmmK6Y9.js.map → agents-j2YErVp4.js.map} +1 -1
  146. package/dashboard/dist/assets/{bots-BD75mzGG.js → bots-CD8Bl5pL.js} +2 -2
  147. package/dashboard/dist/assets/{bots-BD75mzGG.js.map → bots-CD8Bl5pL.js.map} +1 -1
  148. package/dashboard/dist/assets/{capabilities-DDgC_Kds.js → capabilities-Dz190EAa.js} +2 -2
  149. package/dashboard/dist/assets/{capabilities-DDgC_Kds.js.map → capabilities-Dz190EAa.js.map} +1 -1
  150. package/dashboard/dist/assets/{controlplane-BJh12lMv.js → controlplane-CkUHGPA3.js} +2 -2
  151. package/dashboard/dist/assets/{controlplane-BJh12lMv.js.map → controlplane-CkUHGPA3.js.map} +1 -1
  152. package/dashboard/dist/assets/{escalation-DIJt2sgn.js → escalation-BXTwi4J1.js} +2 -2
  153. package/dashboard/dist/assets/{escalation-DIJt2sgn.js.map → escalation-BXTwi4J1.js.map} +1 -1
  154. package/dashboard/dist/assets/{escalation-columns-zl6E94Up.js → escalation-columns-GxxwSbDk.js} +2 -2
  155. package/dashboard/dist/assets/{escalation-columns-zl6E94Up.js.map → escalation-columns-GxxwSbDk.js.map} +1 -1
  156. package/dashboard/dist/assets/{index-DU7YumVJ.js → index-BK3PVYcd.js} +2 -2
  157. package/dashboard/dist/assets/{index-DU7YumVJ.js.map → index-BK3PVYcd.js.map} +1 -1
  158. package/dashboard/dist/assets/{index-CknKy4RA.js → index-BkwsJ-0v.js} +2 -2
  159. package/dashboard/dist/assets/{index-CknKy4RA.js.map → index-BkwsJ-0v.js.map} +1 -1
  160. package/dashboard/dist/assets/{index-B0kmiSmt.js → index-CaMVn0kW.js} +2 -2
  161. package/dashboard/dist/assets/{index-B0kmiSmt.js.map → index-CaMVn0kW.js.map} +1 -1
  162. package/dashboard/dist/assets/{index-BUbzfEA9.js → index-CkL8bpdH.js} +2 -2
  163. package/dashboard/dist/assets/{index-BUbzfEA9.js.map → index-CkL8bpdH.js.map} +1 -1
  164. package/dashboard/dist/assets/index-CoGkgm9-.js +6 -0
  165. package/dashboard/dist/assets/{index-DccCwyZl.js.map → index-CoGkgm9-.js.map} +1 -1
  166. package/dashboard/dist/assets/{index-CtDf8vvQ.js → index-D-7W2AHB.js} +9 -9
  167. package/dashboard/dist/assets/index-D-7W2AHB.js.map +1 -0
  168. package/dashboard/dist/assets/{index-CV4lEd4I.js → index-DGKgXObc.js} +2 -2
  169. package/dashboard/dist/assets/{index-CV4lEd4I.js.map → index-DGKgXObc.js.map} +1 -1
  170. package/dashboard/dist/assets/{index-DVVIeBBk.js → index-DTrcYOM2.js} +2 -2
  171. package/dashboard/dist/assets/{index-DVVIeBBk.js.map → index-DTrcYOM2.js.map} +1 -1
  172. package/dashboard/dist/assets/{index-BhznDv-4.js → index-NfVWOFbF.js} +2 -2
  173. package/dashboard/dist/assets/{index-BhznDv-4.js.map → index-NfVWOFbF.js.map} +1 -1
  174. package/dashboard/dist/assets/index-Wny0bRgq.css +1 -0
  175. package/dashboard/dist/assets/{index-DrUkTcn-.js → index-YliQ4kW_.js} +2 -2
  176. package/dashboard/dist/assets/{index-DrUkTcn-.js.map → index-YliQ4kW_.js.map} +1 -1
  177. package/dashboard/dist/assets/{index-CpgV4Kkp.js → index-eLRh-2NW.js} +2 -2
  178. package/dashboard/dist/assets/{index-CpgV4Kkp.js.map → index-eLRh-2NW.js.map} +1 -1
  179. package/dashboard/dist/assets/{index-CDPBXB4e.js → index-n-lZY5S6.js} +2 -2
  180. package/dashboard/dist/assets/{index-CDPBXB4e.js.map → index-n-lZY5S6.js.map} +1 -1
  181. package/dashboard/dist/assets/{index-j-C7g_Ej.js → index-qT7eB_Hk.js} +2 -2
  182. package/dashboard/dist/assets/{index-j-C7g_Ej.js.map → index-qT7eB_Hk.js.map} +1 -1
  183. package/dashboard/dist/assets/{knowledge-pNDWACXB.js → knowledge-CSAbLtk7.js} +2 -2
  184. package/dashboard/dist/assets/{knowledge-pNDWACXB.js.map → knowledge-CSAbLtk7.js.map} +1 -1
  185. package/dashboard/dist/assets/{mcp-xddLBwUW.js → mcp-D0Ha3aEo.js} +2 -2
  186. package/dashboard/dist/assets/{mcp-xddLBwUW.js.map → mcp-D0Ha3aEo.js.map} +1 -1
  187. package/dashboard/dist/assets/{mcp-query-CmNjvxTG.js → mcp-query-BySmvmuS.js} +2 -2
  188. package/dashboard/dist/assets/{mcp-query-CmNjvxTG.js.map → mcp-query-BySmvmuS.js.map} +1 -1
  189. package/dashboard/dist/assets/{pipelines-B05sd2nB.js → pipelines-DiqWgxJd.js} +2 -2
  190. package/dashboard/dist/assets/{pipelines-B05sd2nB.js.map → pipelines-DiqWgxJd.js.map} +1 -1
  191. package/dashboard/dist/assets/roles-BdtnzLsL.js +2 -0
  192. package/dashboard/dist/assets/roles-BdtnzLsL.js.map +1 -0
  193. package/dashboard/dist/assets/{tasks-Bm1OKrJA.js → tasks-DYCUi5nZ.js} +2 -2
  194. package/dashboard/dist/assets/{tasks-Bm1OKrJA.js.map → tasks-DYCUi5nZ.js.map} +1 -1
  195. package/dashboard/dist/assets/{topics-BVIqtmd4.js → topics-CA7i8ymr.js} +2 -2
  196. package/dashboard/dist/assets/{topics-BVIqtmd4.js.map → topics-CA7i8ymr.js.map} +1 -1
  197. package/dashboard/dist/assets/{useEventHooks-_qCzU74s.js → useEventHooks-SfWdyc5L.js} +2 -2
  198. package/dashboard/dist/assets/{useEventHooks-_qCzU74s.js.map → useEventHooks-SfWdyc5L.js.map} +1 -1
  199. package/dashboard/dist/assets/{useNamespace-CDnCSFpG.js → useNamespace-CZUsk5Vv.js} +2 -2
  200. package/dashboard/dist/assets/{useNamespace-CDnCSFpG.js.map → useNamespace-CZUsk5Vv.js.map} +1 -1
  201. package/dashboard/dist/assets/{useYamlActivityEvents-zrHMhaFM.js → useYamlActivityEvents-DKQ5dREx.js} +2 -2
  202. package/dashboard/dist/assets/{useYamlActivityEvents-zrHMhaFM.js.map → useYamlActivityEvents-DKQ5dREx.js.map} +1 -1
  203. package/dashboard/dist/assets/{users-BPBMZg27.js → users-BxKf5dAX.js} +2 -2
  204. package/dashboard/dist/assets/{users-BPBMZg27.js.map → users-BxKf5dAX.js.map} +1 -1
  205. package/dashboard/dist/assets/{vendor-icons-C1zVP_dv.js → vendor-icons-CEWCGPeJ.js} +76 -76
  206. package/dashboard/dist/assets/vendor-icons-CEWCGPeJ.js.map +1 -0
  207. package/dashboard/dist/assets/{workflows-CT6nTL1I.js → workflows-DNPQ-j-7.js} +2 -2
  208. package/dashboard/dist/assets/{workflows-CT6nTL1I.js.map → workflows-DNPQ-j-7.js.map} +1 -1
  209. package/dashboard/dist/assets/{yaml-workflows-CdfjkOKU.js → yaml-workflows-CA8BrFxc.js} +2 -2
  210. package/dashboard/dist/assets/{yaml-workflows-CdfjkOKU.js.map → yaml-workflows-CA8BrFxc.js.map} +1 -1
  211. package/dashboard/dist/index.html +3 -3
  212. package/docs/api/http/roles.md +62 -0
  213. package/docs/api/mcp/admin.md +32 -1
  214. package/docs/api/mcp/human-queue.md +2 -0
  215. package/docs/api/sdk/roles.md +39 -0
  216. package/docs/cli.md +13 -0
  217. package/docs/dashboard.md +13 -6
  218. package/docs/data.md +34 -0
  219. package/docs/hitl-guide.md +25 -3
  220. package/package.json +2 -2
  221. package/dashboard/dist/assets/OperationsPage-CAmiFHI6.js +0 -2
  222. package/dashboard/dist/assets/OperationsPage-CAmiFHI6.js.map +0 -1
  223. package/dashboard/dist/assets/RoleDetailPage-BB_e330f.js +0 -16
  224. package/dashboard/dist/assets/RoleDetailPage-BB_e330f.js.map +0 -1
  225. package/dashboard/dist/assets/RolesPage-1DBoEMsb.js +0 -2
  226. package/dashboard/dist/assets/index-BRtKQtQZ.css +0 -1
  227. package/dashboard/dist/assets/index-CtDf8vvQ.js.map +0 -1
  228. package/dashboard/dist/assets/index-DccCwyZl.js +0 -6
  229. package/dashboard/dist/assets/roles-bRgaMcdy.js +0 -2
  230. package/dashboard/dist/assets/roles-bRgaMcdy.js.map +0 -1
  231. package/dashboard/dist/assets/vendor-icons-C1zVP_dv.js.map +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-btsU6hBR.js","./vendor-query-B2UbickB.js","./tasks-Bm1OKrJA.js","./workflows-CT6nTL1I.js","./useEventHooks-_qCzU74s.js","./useFilterParams-x-Dg0Vgz.js","./vendor-react-CXumBFUA.js","./useDebouncedValue-BA5S7V54.js","./api-path-u2Jf9QXS.js","./DataTable-ZWgVQg7F.js","./EmptyState-BcsfPq9T.js","./TimestampCell-BK_jufns.js","./StickyPagination-Pr8kawv8.js","./FilterBar-BQ2JGg8U.js","./PageHeader-BZJsEVOC.js","./vendor-icons-C1zVP_dv.js","./ListToolbar-Bx7jGzPA.js","./WorkflowPill-pPUqmx6Q.js","./ProcessDetailPage-CP7GZhgs.js","./PageHeaderWithStats-BWuD7s9c.js","./StatusBadge-D9MeQHrh.js","./RolePill-Pb9TKSQN.js","./UserName-Dsu1Jk4N.js","./users-BPBMZg27.js","./McpOverview-DXRKcJN0.js","./mcp-xddLBwUW.js","./pipelines-B05sd2nB.js","./yaml-workflows-CdfjkOKU.js","./controlplane-BJh12lMv.js","./StatCard-DlgF0CJC.js","./McpRunsPage-uTbym66Y.js","./useNamespace-CDnCSFpG.js","./ElapsedCell-Donjm9gT.js","./RowActions-BA9L9djf.js","./McpRunDetailPage-Dsa3G3XQ.js","./CopyableId-blg-gZvT.js","./CollapsibleSection-DIMGjlJ-.js","./useCollapsedSections-BU5HULGs.js","./SwimlaneTimeline-y1YmXrsj.js","./StreamMessageDetail-BqmQ-N3y.js","./EventTable-DpAXMmT3.js","./McpQueryPage-BE6I011z.js","./mcp-query-CmNjvxTG.js","./McpQueryDetailPage-CmW15w5e.js","./TagInput-Df4myuYF.js","./useYamlActivityEvents-zrHMhaFM.js","./helpers-DzO-OGPe.js","./RunAsSelector-Cp6j3FEY.js","./BotPicker-DY6iUVC9.js","./bots-BD75mzGG.js","./ToolPill-VGpT6Quy.js","./TimeAgo-BAQwZSpq.js","./EscalationsOverview-CvHIJ_GG.js","./AvailableEscalationsPage-_xcWvlIz.js","./CustomDurationPicker-BoBkl9tw.js","./Modal-CSrxpXeM.js","./constants-BHkpVaqx.js","./roles-bRgaMcdy.js","./escalation-columns-zl6E94Up.js","./PriorityBadge-B4ykBH7f.js","./escalation-DIJt2sgn.js","./OperatorDashboard-i8cxaDlk.js","./index-DccCwyZl.js","./WorkflowsOverview-C15JcxyY.js","./index-BUbzfEA9.js","./NamespacePill-BGf0jHwE.js","./WorkflowsDashboard-D3z7COgH.js","./YamlWorkflowsPage-B44WgwE_.js","./GraphInvokePage-De1XVx5d.js","./YamlWorkflowDetailPage-BYq3t7E-.js","./TasksListPage-DOy6JlKS.js","./TaskDetailPage-CT5rXHK5.js","./WorkflowExecutionPage-BwQoOmUE.js","./AdminDashboard-Bg1HgukI.js","./index-CknKy4RA.js","./TaskQueuePill-YalYdCNo.js","./index-CDPBXB4e.js","./ConfirmDeleteModal-D9_1b4MW.js","./index-DU7YumVJ.js","./ToolTestPanel-5PMQyUCe.js","./index-DVVIeBBk.js","./index-BhznDv-4.js","./RolesPage-1DBoEMsb.js","./RoleDetailPage-BB_e330f.js","./index-CV4lEd4I.js","./OperationsPage-CAmiFHI6.js","./index-CpgV4Kkp.js","./index-B0kmiSmt.js","./CredentialsPage-D1OmMHux.js","./index-DrUkTcn-.js","./DropZone-QXbiuU0b.js","./index-j-C7g_Ej.js","./knowledge-pNDWACXB.js","./HomePage-BYR5VXXw.js","./AgentsPage-DhN2lIBh.js","./agents-BRmmK6Y9.js","./AgentDetailPage-BsaiYbwL.js","./CronLabel-CQy3DrUQ.js","./AgentConfigPage-HBe_YDU_.js","./capabilities-DDgC_Kds.js","./topics-BVIqtmd4.js","./CapabilitiesPage-w1owqsmN.js","./TopicsPage-D67tjS8L.js","./TopicDetailPage-Cn1ShfR8.js"])))=>i.map(i=>d[i]);
2
- var Sx=Object.defineProperty;var Ex=(r,n,s)=>n in r?Sx(r,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[n]=s;var v=(r,n,s)=>Ex(r,typeof n!="symbol"?n+"":n,s);import{r as Ax,a as O,j as d,u as _n,b as rn,c as wn,Q as jx,d as Ox}from"./vendor-query-B2UbickB.js";import{r as Tx,L as yr,u as ei,N as Co,a as fg,b as Bn,O as xr,c as hg,d as Nx,R as Cx}from"./vendor-react-CXumBFUA.js";import{I as Ef,R as dg,B as mg,U as kx,L as Af,a as s0,b as Mx,Z as Rx,S as i0,P as r0,C as Dx,W as Kf,c as zx,d as qx,F as Ux,e as Bx,f as Lx,T as Hx,N as Px,g as $x,D as Yx,M as pg,h as gg,i as Gx,j as Vx,k as Fx,E as Jx,X as $o,l as Ix,m as Qx,n as Xx,o as a0,G as Kx,p as Zx,q as Wx,r as ev,s as tv}from"./vendor-icons-C1zVP_dv.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={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-CrLGDCAD.js","./vendor-query-B2UbickB.js","./tasks-DYCUi5nZ.js","./workflows-DNPQ-j-7.js","./useEventHooks-SfWdyc5L.js","./useFilterParams-x-Dg0Vgz.js","./vendor-react-CXumBFUA.js","./useDebouncedValue-BA5S7V54.js","./api-path-u2Jf9QXS.js","./DataTable-ZWgVQg7F.js","./EmptyState-BcsfPq9T.js","./TimestampCell-CIxgN57O.js","./StickyPagination-t5B71hwd.js","./FilterBar-BQ2JGg8U.js","./PageHeader-BhaWTWcM.js","./vendor-icons-CEWCGPeJ.js","./ListToolbar-D4Y-M7wN.js","./WorkflowPill-IDjTRfQ8.js","./ProcessDetailPage-DBIrY6Vd.js","./PageHeaderWithStats-yex5WmHB.js","./StatusBadge-D9MeQHrh.js","./RolePill-Cl71eDUA.js","./UserName-CoGYeig8.js","./users-BxKf5dAX.js","./McpOverview-mfJpETsW.js","./mcp-D0Ha3aEo.js","./pipelines-DiqWgxJd.js","./yaml-workflows-CA8BrFxc.js","./controlplane-CkUHGPA3.js","./StatCard-DlgF0CJC.js","./McpRunsPage-MIwmK-Ky.js","./useNamespace-CZUsk5Vv.js","./ElapsedCell-BRZfw_Af.js","./RowActions-BA9L9djf.js","./McpRunDetailPage-CyTbHs0J.js","./CopyableId-blg-gZvT.js","./CollapsibleSection-DnECdKEY.js","./useCollapsedSections-BU5HULGs.js","./SwimlaneTimeline-CY18gBek.js","./StreamMessageDetail-CYFnZsYA.js","./EventTable-CLuAbba_.js","./McpQueryPage-CKKOxks0.js","./mcp-query-BySmvmuS.js","./McpQueryDetailPage-Cb99vI7v.js","./TagInput-B_WQiuer.js","./useYamlActivityEvents-DKQ5dREx.js","./helpers-DzO-OGPe.js","./RunAsSelector-DA0h41ml.js","./BotPicker-DGhniNcy.js","./bots-CD8Bl5pL.js","./ToolPill-uVqcbHPE.js","./TimeAgo-CSzifQXB.js","./EscalationsOverview-CiQO3ntf.js","./AvailableEscalationsPage-CUHcybKU.js","./CustomDurationPicker-8JHvVWD2.js","./Modal-CSrxpXeM.js","./constants-BHkpVaqx.js","./roles-BdtnzLsL.js","./escalation-columns-GxxwSbDk.js","./PriorityBadge-B4ykBH7f.js","./escalation-BXTwi4J1.js","./OperatorDashboard-K1gzULr7.js","./index-CoGkgm9-.js","./WorkflowsOverview-B8262fVx.js","./index-CkL8bpdH.js","./NamespacePill-CwKdoyRM.js","./WorkflowsDashboard-bJ6Zebfv.js","./YamlWorkflowsPage-C8hBjSn_.js","./GraphInvokePage-BFRi6Nny.js","./YamlWorkflowDetailPage-DhW3q2cO.js","./TasksListPage-Dlsu7cWG.js","./TaskDetailPage-B9owzuhV.js","./WorkflowExecutionPage-Dhb9EWgI.js","./AdminDashboard-rZDVS2G_.js","./index-BkwsJ-0v.js","./TaskQueuePill-Lgn2obNU.js","./index-n-lZY5S6.js","./ConfirmDeleteModal-D9_1b4MW.js","./index-BK3PVYcd.js","./ToolTestPanel-Bw844EW3.js","./index-DTrcYOM2.js","./index-NfVWOFbF.js","./RolesPage-B0ZgjB2V.js","./RoleDetailPage-7j6Mk780.js","./EscalationSchemaPage-Do2iPKUl.js","./index-DGKgXObc.js","./OperationsPage-DPesph0U.js","./index-eLRh-2NW.js","./index-CaMVn0kW.js","./CredentialsPage-DdZ-jyyc.js","./index-YliQ4kW_.js","./DropZone-DEX0BBqt.js","./index-qT7eB_Hk.js","./knowledge-CSAbLtk7.js","./HomePage-m1pnxilb.js","./AgentsPage-C8fKLxh-.js","./agents-j2YErVp4.js","./AgentDetailPage-DMeHvidT.js","./CronLabel-CymxLvY0.js","./AgentConfigPage-CbyyCjCT.js","./capabilities-Dz190EAa.js","./topics-CA7i8ymr.js","./CapabilitiesPage-ClfuW4ya.js","./TopicsPage-CAG0RhAK.js","./TopicDetailPage-HuDx2oAW.js"])))=>i.map(i=>d[i]);
2
+ var Sx=Object.defineProperty;var Ex=(r,n,s)=>n in r?Sx(r,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[n]=s;var v=(r,n,s)=>Ex(r,typeof n!="symbol"?n+"":n,s);import{r as Ax,a as O,j as d,u as _n,b as rn,c as wn,Q as jx,d as Ox}from"./vendor-query-B2UbickB.js";import{r as Tx,L as yr,u as ei,N as Co,a as fg,b as Bn,O as xr,c as hg,d as Nx,R as Cx}from"./vendor-react-CXumBFUA.js";import{I as Ef,R as dg,B as mg,U as kx,L as Af,a as s0,b as Mx,Z as Rx,S as i0,P as r0,C as Dx,W as Kf,c as zx,d as qx,F as Ux,e as Bx,f as Lx,T as Hx,N as Px,g as $x,D as Yx,M as pg,h as gg,i as Gx,j as Vx,k as Fx,E as Jx,X as $o,l as Ix,m as Qx,n as Xx,o as a0,G as Kx,p as Zx,q as Wx,r as ev,s as tv}from"./vendor-icons-CEWCGPeJ.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
5
5
  *
@@ -7,7 +7,7 @@ var Sx=Object.defineProperty;var Ex=(r,n,s)=>n in r?Sx(r,n,{enumerable:!0,config
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var l0;function nv(){return l0||(l0=1,(function(r){function n($,te){var de=$.length;$.push(te);e:for(;0<de;){var _e=de-1>>>1,be=$[_e];if(0<o(be,te))$[_e]=te,$[de]=be,de=_e;else break e}}function s($){return $.length===0?null:$[0]}function a($){if($.length===0)return null;var te=$[0],de=$.pop();if(de!==te){$[0]=de;e:for(var _e=0,be=$.length,Oe=be>>>1;_e<Oe;){var we=2*(_e+1)-1,Te=$[we],lt=we+1,Pt=$[lt];if(0>o(Te,de))lt<be&&0>o(Pt,Te)?($[_e]=Pt,$[lt]=de,_e=lt):($[_e]=Te,$[we]=de,_e=we);else if(lt<be&&0>o(Pt,de))$[_e]=Pt,$[lt]=de,_e=lt;else break e}}return te}function o($,te){var de=$.sortIndex-te.sortIndex;return de!==0?de:$.id-te.id}if(r.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;r.unstable_now=function(){return f.now()}}else{var h=Date,m=h.now();r.unstable_now=function(){return h.now()-m}}var g=[],y=[],E=1,w=null,T=3,q=!1,M=!1,D=!1,W=!1,se=typeof setTimeout=="function"?setTimeout:null,ee=typeof clearTimeout=="function"?clearTimeout:null,me=typeof setImmediate<"u"?setImmediate:null;function re($){for(var te=s(y);te!==null;){if(te.callback===null)a(y);else if(te.startTime<=$)a(y),te.sortIndex=te.expirationTime,n(g,te);else break;te=s(y)}}function C($){if(D=!1,re($),!M)if(s(g)!==null)M=!0,X||(X=!0,ne());else{var te=s(y);te!==null&&Me(C,te.startTime-$)}}var X=!1,ce=-1,V=5,G=-1;function K(){return W?!0:!(r.unstable_now()-G<V)}function ae(){if(W=!1,X){var $=r.unstable_now();G=$;var te=!0;try{e:{M=!1,D&&(D=!1,ee(ce),ce=-1),q=!0;var de=T;try{t:{for(re($),w=s(g);w!==null&&!(w.expirationTime>$&&K());){var _e=w.callback;if(typeof _e=="function"){w.callback=null,T=w.priorityLevel;var be=_e(w.expirationTime<=$);if($=r.unstable_now(),typeof be=="function"){w.callback=be,re($),te=!0;break t}w===s(g)&&a(g),re($)}else a(g);w=s(g)}if(w!==null)te=!0;else{var Oe=s(y);Oe!==null&&Me(C,Oe.startTime-$),te=!1}}break e}finally{w=null,T=de,q=!1}te=void 0}}finally{te?ne():X=!1}}}var ne;if(typeof me=="function")ne=function(){me(ae)};else if(typeof MessageChannel<"u"){var ke=new MessageChannel,He=ke.port2;ke.port1.onmessage=ae,ne=function(){He.postMessage(null)}}else ne=function(){se(ae,0)};function Me($,te){ce=se(function(){$(r.unstable_now())},te)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function($){$.callback=null},r.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<$?Math.floor(1e3/$):5},r.unstable_getCurrentPriorityLevel=function(){return T},r.unstable_next=function($){switch(T){case 1:case 2:case 3:var te=3;break;default:te=T}var de=T;T=te;try{return $()}finally{T=de}},r.unstable_requestPaint=function(){W=!0},r.unstable_runWithPriority=function($,te){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var de=T;T=$;try{return te()}finally{T=de}},r.unstable_scheduleCallback=function($,te,de){var _e=r.unstable_now();switch(typeof de=="object"&&de!==null?(de=de.delay,de=typeof de=="number"&&0<de?_e+de:_e):de=_e,$){case 1:var be=-1;break;case 2:be=250;break;case 5:be=1073741823;break;case 4:be=1e4;break;default:be=5e3}return be=de+be,$={id:E++,callback:te,priorityLevel:$,startTime:de,expirationTime:be,sortIndex:-1},de>_e?($.sortIndex=de,n(y,$),s(g)===null&&$===s(y)&&(D?(ee(ce),ce=-1):D=!0,Me(C,de-_e))):($.sortIndex=be,n(g,$),M||q||(M=!0,X||(X=!0,ne()))),$},r.unstable_shouldYield=K,r.unstable_wrapCallback=function($){var te=T;return function(){var de=T;T=te;try{return $.apply(this,arguments)}finally{T=de}}}})(cf)),cf}var o0;function sv(){return o0||(o0=1,of.exports=nv()),of.exports}/**
10
+ */var l0;function nv(){return l0||(l0=1,(function(r){function n($,te){var de=$.length;$.push(te);e:for(;0<de;){var _e=de-1>>>1,xe=$[_e];if(0<o(xe,te))$[_e]=te,$[de]=xe,de=_e;else break e}}function s($){return $.length===0?null:$[0]}function a($){if($.length===0)return null;var te=$[0],de=$.pop();if(de!==te){$[0]=de;e:for(var _e=0,xe=$.length,Oe=xe>>>1;_e<Oe;){var we=2*(_e+1)-1,Te=$[we],lt=we+1,Pt=$[lt];if(0>o(Te,de))lt<xe&&0>o(Pt,Te)?($[_e]=Pt,$[lt]=de,_e=lt):($[_e]=Te,$[we]=de,_e=we);else if(lt<xe&&0>o(Pt,de))$[_e]=Pt,$[lt]=de,_e=lt;else break e}}return te}function o($,te){var de=$.sortIndex-te.sortIndex;return de!==0?de:$.id-te.id}if(r.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;r.unstable_now=function(){return f.now()}}else{var h=Date,m=h.now();r.unstable_now=function(){return h.now()-m}}var g=[],y=[],E=1,w=null,T=3,q=!1,M=!1,D=!1,W=!1,se=typeof setTimeout=="function"?setTimeout:null,ee=typeof clearTimeout=="function"?clearTimeout:null,me=typeof setImmediate<"u"?setImmediate:null;function re($){for(var te=s(y);te!==null;){if(te.callback===null)a(y);else if(te.startTime<=$)a(y),te.sortIndex=te.expirationTime,n(g,te);else break;te=s(y)}}function C($){if(D=!1,re($),!M)if(s(g)!==null)M=!0,X||(X=!0,ne());else{var te=s(y);te!==null&&Me(C,te.startTime-$)}}var X=!1,ce=-1,V=5,G=-1;function K(){return W?!0:!(r.unstable_now()-G<V)}function ae(){if(W=!1,X){var $=r.unstable_now();G=$;var te=!0;try{e:{M=!1,D&&(D=!1,ee(ce),ce=-1),q=!0;var de=T;try{t:{for(re($),w=s(g);w!==null&&!(w.expirationTime>$&&K());){var _e=w.callback;if(typeof _e=="function"){w.callback=null,T=w.priorityLevel;var xe=_e(w.expirationTime<=$);if($=r.unstable_now(),typeof xe=="function"){w.callback=xe,re($),te=!0;break t}w===s(g)&&a(g),re($)}else a(g);w=s(g)}if(w!==null)te=!0;else{var Oe=s(y);Oe!==null&&Me(C,Oe.startTime-$),te=!1}}break e}finally{w=null,T=de,q=!1}te=void 0}}finally{te?ne():X=!1}}}var ne;if(typeof me=="function")ne=function(){me(ae)};else if(typeof MessageChannel<"u"){var ke=new MessageChannel,He=ke.port2;ke.port1.onmessage=ae,ne=function(){He.postMessage(null)}}else ne=function(){se(ae,0)};function Me($,te){ce=se(function(){$(r.unstable_now())},te)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function($){$.callback=null},r.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<$?Math.floor(1e3/$):5},r.unstable_getCurrentPriorityLevel=function(){return T},r.unstable_next=function($){switch(T){case 1:case 2:case 3:var te=3;break;default:te=T}var de=T;T=te;try{return $()}finally{T=de}},r.unstable_requestPaint=function(){W=!0},r.unstable_runWithPriority=function($,te){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var de=T;T=$;try{return te()}finally{T=de}},r.unstable_scheduleCallback=function($,te,de){var _e=r.unstable_now();switch(typeof de=="object"&&de!==null?(de=de.delay,de=typeof de=="number"&&0<de?_e+de:_e):de=_e,$){case 1:var xe=-1;break;case 2:xe=250;break;case 5:xe=1073741823;break;case 4:xe=1e4;break;default:xe=5e3}return xe=de+xe,$={id:E++,callback:te,priorityLevel:$,startTime:de,expirationTime:xe,sortIndex:-1},de>_e?($.sortIndex=de,n(y,$),s(g)===null&&$===s(y)&&(D?(ee(ce),ce=-1):D=!0,Me(C,de-_e))):($.sortIndex=xe,n(g,$),M||q||(M=!0,X||(X=!0,ne()))),$},r.unstable_shouldYield=K,r.unstable_wrapCallback=function($){var te=T;return function(){var de=T;T=te;try{return $.apply(this,arguments)}finally{T=de}}}})(cf)),cf}var o0;function sv(){return o0||(o0=1,of.exports=nv()),of.exports}/**
11
11
  * @license React
12
12
  * react-dom-client.production.js
13
13
  *
@@ -15,7 +15,7 @@ var Sx=Object.defineProperty;var Ex=(r,n,s)=>n in r?Sx(r,n,{enumerable:!0,config
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var c0;function iv(){if(c0)return Ea;c0=1;var r=sv(),n=Ax(),s=Tx();function a(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)t+="&args[]="+encodeURIComponent(arguments[i])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,i=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(i=t.return),e=t.return;while(e)}return t.tag===3?i:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function m(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function g(e){if(f(e)!==e)throw Error(a(188))}function y(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(a(188));return t!==e?null:e}for(var i=e,l=t;;){var c=i.return;if(c===null)break;var u=c.alternate;if(u===null){if(l=c.return,l!==null){i=l;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===i)return g(c),e;if(u===l)return g(c),t;u=u.sibling}throw Error(a(188))}if(i.return!==l.return)i=c,l=u;else{for(var p=!1,b=c.child;b;){if(b===i){p=!0,i=c,l=u;break}if(b===l){p=!0,l=c,i=u;break}b=b.sibling}if(!p){for(b=u.child;b;){if(b===i){p=!0,i=u,l=c;break}if(b===l){p=!0,l=u,i=c;break}b=b.sibling}if(!p)throw Error(a(189))}}if(i.alternate!==l)throw Error(a(190))}if(i.tag!==3)throw Error(a(188));return i.stateNode.current===i?e:t}function E(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=E(e),t!==null)return t;e=e.sibling}return null}var w=Object.assign,T=Symbol.for("react.element"),q=Symbol.for("react.transitional.element"),M=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),W=Symbol.for("react.strict_mode"),se=Symbol.for("react.profiler"),ee=Symbol.for("react.consumer"),me=Symbol.for("react.context"),re=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),ce=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),G=Symbol.for("react.activity"),K=Symbol.for("react.memo_cache_sentinel"),ae=Symbol.iterator;function ne(e){return e===null||typeof e!="object"?null:(e=ae&&e[ae]||e["@@iterator"],typeof e=="function"?e:null)}var ke=Symbol.for("react.client.reference");function He(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ke?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case D:return"Fragment";case se:return"Profiler";case W:return"StrictMode";case C:return"Suspense";case X:return"SuspenseList";case G:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case M:return"Portal";case me:return e.displayName||"Context";case ee:return(e._context.displayName||"Context")+".Consumer";case re:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ce:return t=e.displayName||null,t!==null?t:He(e.type)||"Memo";case V:t=e._payload,e=e._init;try{return He(e(t))}catch{}}return null}var Me=Array.isArray,$=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,de={pending:!1,data:null,method:null,action:null},_e=[],be=-1;function Oe(e){return{current:e}}function we(e){0>be||(e.current=_e[be],_e[be]=null,be--)}function Te(e,t){be++,_e[be]=e.current,e.current=t}var lt=Oe(null),Pt=Oe(null),an=Oe(null),jt=Oe(null);function Ot(e,t){switch(Te(an,t),Te(Pt,e),Te(lt,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?jp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=jp(t),e=Op(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}we(lt),Te(lt,e)}function Se(){we(lt),we(Pt),we(an)}function Tt(e){e.memoizedState!==null&&Te(jt,e);var t=lt.current,i=Op(t,e.type);t!==i&&(Te(Pt,e),Te(lt,i))}function ti(e){Pt.current===e&&(we(lt),we(Pt)),jt.current===e&&(we(jt),va._currentValue=de)}var Ni,ni;function ln(e){if(Ni===void 0)try{throw Error()}catch(i){var t=i.stack.trim().match(/\n( *(at )?)/);Ni=t&&t[1]||"",ni=-1<i.stack.indexOf(`
18
+ */var c0;function iv(){if(c0)return Ea;c0=1;var r=sv(),n=Ax(),s=Tx();function a(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)t+="&args[]="+encodeURIComponent(arguments[i])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,i=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(i=t.return),e=t.return;while(e)}return t.tag===3?i:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function m(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function g(e){if(f(e)!==e)throw Error(a(188))}function y(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(a(188));return t!==e?null:e}for(var i=e,l=t;;){var c=i.return;if(c===null)break;var u=c.alternate;if(u===null){if(l=c.return,l!==null){i=l;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===i)return g(c),e;if(u===l)return g(c),t;u=u.sibling}throw Error(a(188))}if(i.return!==l.return)i=c,l=u;else{for(var p=!1,b=c.child;b;){if(b===i){p=!0,i=c,l=u;break}if(b===l){p=!0,l=c,i=u;break}b=b.sibling}if(!p){for(b=u.child;b;){if(b===i){p=!0,i=u,l=c;break}if(b===l){p=!0,l=u,i=c;break}b=b.sibling}if(!p)throw Error(a(189))}}if(i.alternate!==l)throw Error(a(190))}if(i.tag!==3)throw Error(a(188));return i.stateNode.current===i?e:t}function E(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=E(e),t!==null)return t;e=e.sibling}return null}var w=Object.assign,T=Symbol.for("react.element"),q=Symbol.for("react.transitional.element"),M=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),W=Symbol.for("react.strict_mode"),se=Symbol.for("react.profiler"),ee=Symbol.for("react.consumer"),me=Symbol.for("react.context"),re=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),ce=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),G=Symbol.for("react.activity"),K=Symbol.for("react.memo_cache_sentinel"),ae=Symbol.iterator;function ne(e){return e===null||typeof e!="object"?null:(e=ae&&e[ae]||e["@@iterator"],typeof e=="function"?e:null)}var ke=Symbol.for("react.client.reference");function He(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ke?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case D:return"Fragment";case se:return"Profiler";case W:return"StrictMode";case C:return"Suspense";case X:return"SuspenseList";case G:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case M:return"Portal";case me:return e.displayName||"Context";case ee:return(e._context.displayName||"Context")+".Consumer";case re:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ce:return t=e.displayName||null,t!==null?t:He(e.type)||"Memo";case V:t=e._payload,e=e._init;try{return He(e(t))}catch{}}return null}var Me=Array.isArray,$=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,de={pending:!1,data:null,method:null,action:null},_e=[],xe=-1;function Oe(e){return{current:e}}function we(e){0>xe||(e.current=_e[xe],_e[xe]=null,xe--)}function Te(e,t){xe++,_e[xe]=e.current,e.current=t}var lt=Oe(null),Pt=Oe(null),an=Oe(null),jt=Oe(null);function Ot(e,t){switch(Te(an,t),Te(Pt,e),Te(lt,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?jp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=jp(t),e=Op(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}we(lt),Te(lt,e)}function Se(){we(lt),we(Pt),we(an)}function Tt(e){e.memoizedState!==null&&Te(jt,e);var t=lt.current,i=Op(t,e.type);t!==i&&(Te(Pt,e),Te(lt,i))}function ti(e){Pt.current===e&&(we(lt),we(Pt)),jt.current===e&&(we(jt),va._currentValue=de)}var Ni,ni;function ln(e){if(Ni===void 0)try{throw Error()}catch(i){var t=i.stack.trim().match(/\n( *(at )?)/);Ni=t&&t[1]||"",ni=-1<i.stack.indexOf(`
19
19
  at`)?" (<anonymous>)":-1<i.stack.indexOf("@")?"@unknown:0:0":""}return`
20
20
  `+Ni+e+ni}var Ci=!1;function ms(e,t){if(!e||Ci)return"";Ci=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var Q=function(){throw Error()};if(Object.defineProperty(Q.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Q,[])}catch(P){var L=P}Reflect.construct(e,[],Q)}else{try{Q.call()}catch(P){L=P}e.call(Q.prototype)}}else{try{throw Error()}catch(P){L=P}(Q=e())&&typeof Q.catch=="function"&&Q.catch(function(){})}}catch(P){if(P&&L&&typeof P.stack=="string")return[P.stack,L.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=l.DetermineComponentFrameRoot(),p=u[0],b=u[1];if(p&&b){var j=p.split(`
21
21
  `),B=b.split(`
@@ -29,12 +29,12 @@ ${s}: ${a[o]}`;return`${n}\r
29
29
  \r
30
30
  `}encode(){return Ti.encode(this.toString())}static validHeaderValue(n){if(/[\r\n]/.test(n))throw new ue("invalid header value - \\r and \\n are not allowed.",ie.BadHeader);return n.trim()}keys(){const n=[];for(const s of this.headers.keys())n.push(s);return n}findKeys(n,s=Kt.Exact){const a=this.keys();switch(s){case Kt.Exact:return a.filter(o=>o===n);case Kt.CanonicalMIME:return n=b0(n),a.filter(o=>o===n);default:{const o=n.toLowerCase();return a.filter(f=>o===f.toLowerCase())}}}get(n,s=Kt.Exact){const a=this.findKeys(n,s);if(a.length){const o=this.headers.get(a[0]);if(o)return Array.isArray(o)?o[0]:o}return""}last(n,s=Kt.Exact){const a=this.findKeys(n,s);if(a.length){const o=this.headers.get(a[0]);if(o)return Array.isArray(o)?o[o.length-1]:o}return""}has(n,s=Kt.Exact){return this.findKeys(n,s).length>0}set(n,s,a=Kt.Exact){this.delete(n,a),this.append(n,s,a)}append(n,s,a=Kt.Exact){const o=b0(n);a===Kt.CanonicalMIME&&(n=o);const f=this.findKeys(n,a);n=f.length>0?f[0]:n;const h=Is.validHeaderValue(s);let m=this.headers.get(n);m||(m=[],this.headers.set(n,m)),m.push(h)}values(n,s=Kt.Exact){const a=[];return this.findKeys(n,s).forEach(f=>{const h=this.headers.get(f);h&&a.push(...h)}),a}delete(n,s=Kt.Exact){this.findKeys(n,s).forEach(o=>{this.headers.delete(o)})}get hasError(){return this._code>=300}get status(){return`${this._code} ${this._description}`.trim()}toRecord(){const n={};return this.keys().forEach(s=>{n[s]=this.values(s)}),n}get code(){return this._code}get description(){return this._description}static fromRecord(n){const s=new Is;for(const a in n)s.headers.set(a,n[a]);return s}}function Tf(){return{encode(r){return Ti.encode(r)},decode(r){return en.decode(r)}}}function Mn(r){return{encode(n){try{return n===void 0&&(n=null),Ti.encode(JSON.stringify(n))}catch(s){throw ue.errorForCode(ie.BadJson,s)}},decode(n){try{return JSON.parse(en.decode(n),r)}catch(s){throw ue.errorForCode(ie.BadJson,s)}}}}function wg(r){var n;return r&&r.data.length===0&&((n=r.headers)==null?void 0:n.code)===503?ue.errorForCode(ie.NoResponders):null}class nh{constructor(n,s,a){v(this,"_headers");v(this,"_msg");v(this,"_rdata");v(this,"_reply");v(this,"_subject");v(this,"publisher");this._msg=n,this._rdata=s,this.publisher=a}get subject(){return this._subject?this._subject:(this._subject=en.decode(this._msg.subject),this._subject)}get reply(){return this._reply?this._reply:(this._reply=en.decode(this._msg.reply),this._reply)}get sid(){return this._msg.sid}get headers(){if(this._msg.hdr>-1&&!this._headers){const n=this._rdata.subarray(0,this._msg.hdr);this._headers=Is.decode(n)}return this._headers}get data(){return this._rdata?this._msg.hdr>-1?this._rdata.subarray(this._msg.hdr):this._rdata:new Uint8Array(0)}respond(n=nn,s){return this.reply?(this.publisher.publish(this.reply,n,s),!0):!1}size(){var o;const n=this._msg.subject.length,s=((o=this._msg.reply)==null?void 0:o.length)||0,a=this._msg.size===-1?0:this._msg.size;return n+s+a}json(n){return Mn(n).decode(this.data)}string(){return en.decode(this.data)}requestInfo(){var s;const n=(s=this.headers)==null?void 0:s.get("Nats-Request-Info");return n?JSON.parse(n,function(a,o){return(a==="start"||a==="stop")&&o!==""?new Date(Date.parse(o)):o}):null}}v(nh,"jc");function _r(r){return Go("durable",r)}function Mt(r){return Go("stream",r)}function Go(r,n=""){if(n==="")throw Error(`${r} name required`);return[".","*",">","/","\\"," "," ",`
31
31
  `,"\r"].forEach(a=>{if(n.indexOf(a)!==-1){switch(a){case`
32
- `:a="\\n";break;case"\r":a="\\r";break;case" ":a="\\t";break}throw Error(`invalid ${r} name - ${r} name cannot contain '${a}'`)}}),""}function ka(r,n=""){if(n==="")throw Error(`${r} name required`);const s=vv(n);if(s.length)throw new Error(`invalid ${r} name - ${r} name ${s}`)}function vv(r=""){if(r==="")throw Error("name required");const n=/^[-\w]+$/g;if(r.match(n)===null){for(const a of r.split(""))if(a.match(n)===null)return`cannot contain '${a}'`}return""}function Nf(r){if(r.data.length>0)return!1;const n=r.headers;return n?n.code>=100&&n.code<200:!1}function Cf(r){var n;return Nf(r)&&((n=r.headers)==null?void 0:n.description)==="Idle Heartbeat"}function _v(r,n,s){const a=hs(r,n),o={hdr:1,sid:0,size:0},f=new nh(o,nn,{});return f._headers=a,f._subject=s,f}function wr(r){if(r.data.length!==0)return null;const n=r.headers;return n?Sg(n.code,n.description):null}var xn;(function(r){r.MaxBatchExceeded="exceeded maxrequestbatch of",r.MaxExpiresExceeded="exceeded maxrequestexpires of",r.MaxBytesExceeded="exceeded maxrequestmaxbytes of",r.MaxMessageSizeExceeded="message size exceeds maxbytes",r.PushConsumer="consumer is push based",r.MaxWaitingExceeded="exceeded maxwaiting",r.IdleHeartbeatMissed="idle heartbeats missed",r.ConsumerDeleted="consumer deleted"})(xn||(xn={}));function wv(r){return r.code!==ie.JetStream409?!1:[xn.MaxBatchExceeded,xn.MaxExpiresExceeded,xn.MaxBytesExceeded,xn.MaxMessageSizeExceeded,xn.PushConsumer,xn.IdleHeartbeatMissed,xn.ConsumerDeleted].find(s=>r.message.indexOf(s)!==-1)!==void 0}function Sg(r,n=""){if(r<300)return null;switch(n=n.toLowerCase(),r){case 404:return new ue(n,ie.JetStream404NoMessages);case 408:return new ue(n,ie.JetStream408RequestTimeout);case 409:{const s=n.startsWith(xn.IdleHeartbeatMissed)?ie.JetStreamIdleHeartBeat:ie.JetStream409;return new ue(n,s)}case 503:return ue.errorForCode(ie.JetStreamNotEnabled,new Error(n));default:return n===""&&(n=ie.Unknown),new ue(n,`${r}`)}}class _t{constructor(){v(this,"inflight");v(this,"processed");v(this,"received");v(this,"noIterator");v(this,"iterClosed");v(this,"done");v(this,"signal");v(this,"yields");v(this,"filtered");v(this,"pendingFiltered");v(this,"ingestionFilterFn");v(this,"protocolFilterFn");v(this,"dispatchedFn");v(this,"ctx");v(this,"_data");v(this,"err");v(this,"time");v(this,"yielding");this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=st(),this.yields=[],this.iterClosed=st(),this.time=0,this.yielding=!1}[Symbol.asyncIterator](){return this.iterate()}push(n){if(this.done)return;if(typeof n=="function"){this.yields.push(n),this.signal.resolve();return}const{ingest:s,protocol:a}=this.ingestionFilterFn?this.ingestionFilterFn(n,this.ctx||this):{ingest:!0,protocol:!1};s&&(a&&(this.filtered++,this.pendingFiltered++),this.yields.push(n),this.signal.resolve())}async*iterate(){if(this.noIterator)throw new ue("unsupported iterator",ie.ApiError);if(this.yielding)throw new ue("already yielding",ie.ApiError);this.yielding=!0;try{for(;;){if(this.yields.length===0&&await this.signal,this.err)throw this.err;const n=this.yields;this.inflight=n.length,this.yields=[];for(let s=0;s<n.length;s++){if(typeof n[s]=="function"){const o=n[s];try{o()}catch(f){throw f}if(this.err)throw this.err;continue}if(this.protocolFilterFn?this.protocolFilterFn(n[s]):!0){this.processed++;const o=Date.now();yield n[s],this.time=Date.now()-o,this.dispatchedFn&&n[s]&&this.dispatchedFn(n[s])}else this.pendingFiltered--;this.inflight--}if(this.done)break;this.yields.length===0&&(n.length=0,this.yields=n,this.signal=st())}}finally{this.stop()}}stop(n){this.done||(this.err=n,this.done=!0,this.signal.resolve(),this.iterClosed.resolve(n))}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}class sh{constructor(n,s,a={maxOut:2}){v(this,"interval");v(this,"maxOut");v(this,"cancelAfter");v(this,"timer");v(this,"autoCancelTimer");v(this,"last");v(this,"missed");v(this,"count");v(this,"callback");this.interval=n,this.maxOut=(a==null?void 0:a.maxOut)||2,this.cancelAfter=(a==null?void 0:a.cancelAfter)||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=s,this._schedule()}cancel(){this.autoCancelTimer&&clearTimeout(this.autoCancelTimer),this.timer&&clearInterval(this.timer),this.timer=0,this.autoCancelTimer=0,this.missed=0}work(){this.last=Date.now(),this.missed=0}_change(n,s=0,a=2){this.interval=n,this.maxOut=a,this.cancelAfter=s,this.restart()}restart(){this.cancel(),this._schedule()}_schedule(){this.cancelAfter>0&&(this.autoCancelTimer=setTimeout(()=>{this.cancel()},this.cancelAfter)),this.timer=setInterval(()=>{if(this.count++,Date.now()-this.last>this.interval&&this.missed++,this.missed>=this.maxOut)try{this.callback(this.missed)===!0&&this.cancel()}catch(n){console.log(n)}},this.interval)}}var kf;(function(r){r.Limits="limits",r.Interest="interest",r.Workqueue="workqueue"})(kf||(kf={}));var La;(function(r){r.Old="old",r.New="new"})(La||(La={}));var Mf;(function(r){r.File="file",r.Memory="memory"})(Mf||(Mf={}));var ft;(function(r){r.All="all",r.Last="last",r.New="new",r.StartSequence="by_start_sequence",r.StartTime="by_start_time",r.LastPerSubject="last_per_subject"})(ft||(ft={}));var vt;(function(r){r.None="none",r.All="all",r.Explicit="explicit",r.NotSet=""})(vt||(vt={}));var jr;(function(r){r.Instant="instant",r.Original="original"})(jr||(jr={}));var Ws;(function(r){r.None="none",r.S2="s2"})(Ws||(Ws={}));var Do;(function(r){r.CreateOrUpdate="",r.Update="update",r.Create="create"})(Do||(Do={}));function Sv(r,n={}){return Object.assign({name:r,deliver_policy:ft.All,ack_policy:vt.Explicit,ack_wait:nt(30*1e3),replay_policy:jr.Instant},n)}var x0;(function(r){r.API="api_audit",r.StreamAction="stream_action",r.ConsumerAction="consumer_action",r.SnapshotCreate="snapshot_create",r.SnapshotComplete="snapshot_complete",r.RestoreCreate="restore_create",r.RestoreComplete="restore_complete",r.MaxDeliver="max_deliver",r.Terminated="terminated",r.Ack="consumer_ack",r.StreamLeaderElected="stream_leader_elected",r.StreamQuorumLost="stream_quorum_lost",r.ConsumerLeaderElected="consumer_leader_elected",r.ConsumerQuorumLost="consumer_quorum_lost"})(x0||(x0={}));var Dt;(function(r){r.StreamSourceHdr="Nats-Stream-Source",r.LastConsumerSeqHdr="Nats-Last-Consumer",r.LastStreamSeqHdr="Nats-Last-Stream",r.ConsumerStalledHdr="Nats-Consumer-Stalled",r.MessageSizeHdr="Nats-Msg-Size",r.RollupHdr="Nats-Rollup",r.RollupValueSubject="sub",r.RollupValueAll="all",r.PendingMessagesHdr="Nats-Pending-Messages",r.PendingBytesHdr="Nats-Pending-Bytes"})(Dt||(Dt={}));var Nn;(function(r){r.LastValue="",r.AllHistory="history",r.UpdatesOnly="updates"})(Nn||(Nn={}));var br;(function(r){r.Stream="Nats-Stream",r.Sequence="Nats-Sequence",r.TimeStamp="Nats-Time-Stamp",r.Subject="Nats-Subject"})(br||(br={}));var v0;(function(r){r.Stream="Nats-Stream",r.Subject="Nats-Subject",r.Sequence="Nats-Sequence",r.LastSequence="Nats-Last-Sequence",r.Size="Nats-Msg-Size"})(v0||(v0={}));const Zt="KV_";class Ev{constructor(n){v(this,"config");v(this,"ordered");v(this,"mack");v(this,"stream");v(this,"callbackFn");v(this,"max");v(this,"qname");v(this,"isBind");v(this,"filters");this.stream="",this.mack=!1,this.ordered=!1,this.config=Sv("",n||{})}getOpts(){var s;const n={};if(n.config=Object.assign({},this.config),n.config.filter_subject&&(this.filterSubject(n.config.filter_subject),n.config.filter_subject=void 0),n.config.filter_subjects&&((s=n.config.filter_subjects)==null||s.forEach(a=>{this.filterSubject(a)}),n.config.filter_subjects=void 0),n.mack=this.mack,n.stream=this.stream,n.callbackFn=this.callbackFn,n.max=this.max,n.queue=this.qname,n.ordered=this.ordered,n.config.ack_policy=n.ordered?vt.None:n.config.ack_policy,n.isBind=n.isBind||!1,this.filters)switch(this.filters.length){case 0:break;case 1:n.config.filter_subject=this.filters[0];break;default:n.config.filter_subjects=this.filters}return n}description(n){return this.config.description=n,this}deliverTo(n){return this.config.deliver_subject=n,this}durable(n){return _r(n),this.config.durable_name=n,this}startSequence(n){if(n<=0)throw new Error("sequence must be greater than 0");return this.config.deliver_policy=ft.StartSequence,this.config.opt_start_seq=n,this}startTime(n){return this.config.deliver_policy=ft.StartTime,this.config.opt_start_time=n.toISOString(),this}deliverAll(){return this.config.deliver_policy=ft.All,this}deliverLastPerSubject(){return this.config.deliver_policy=ft.LastPerSubject,this}deliverLast(){return this.config.deliver_policy=ft.Last,this}deliverNew(){return this.config.deliver_policy=ft.New,this}startAtTimeDelta(n){return this.startTime(new Date(Date.now()-n)),this}headersOnly(){return this.config.headers_only=!0,this}ackNone(){return this.config.ack_policy=vt.None,this}ackAll(){return this.config.ack_policy=vt.All,this}ackExplicit(){return this.config.ack_policy=vt.Explicit,this}ackWait(n){return this.config.ack_wait=nt(n),this}maxDeliver(n){return this.config.max_deliver=n,this}filterSubject(n){return this.filters=this.filters||[],this.filters.push(n),this}replayInstantly(){return this.config.replay_policy=jr.Instant,this}replayOriginal(){return this.config.replay_policy=jr.Original,this}sample(n){if(n=Math.trunc(n),n<0||n>100)throw new Error("value must be between 0-100");return this.config.sample_freq=`${n}%`,this}limit(n){return this.config.rate_limit_bps=n,this}maxWaiting(n){return this.config.max_waiting=n,this}maxAckPending(n){return this.config.max_ack_pending=n,this}idleHeartbeat(n){return this.config.idle_heartbeat=nt(n),this}flowControl(){return this.config.flow_control=!0,this}deliverGroup(n){return this.queue(n),this}manualAck(){return this.mack=!0,this}maxMessages(n){return this.max=n,this}callback(n){return this.callbackFn=n,this}queue(n){return this.qname=n,this.config.deliver_group=n,this}orderedConsumer(){return this.ordered=!0,this}bind(n,s){return this.stream=n,this.config.durable_name=s,this.isBind=!0,this}bindStream(n){return this.stream=n,this}inactiveEphemeralThreshold(n){return this.config.inactive_threshold=nt(n),this}maxPullBatch(n){return this.config.max_batch=n,this}maxPullRequestExpires(n){return this.config.max_expires=nt(n),this}memory(){return this.config.mem_storage=!0,this}numReplicas(n){return this.config.num_replicas=n,this}consumerName(n){return this.config.name=n,this}}function Qs(r){return new Ev(r)}function _0(r){return typeof r.getOpts=="function"}class Av{static encode(n){if(typeof n=="string")return btoa(n);const s=Array.from(n);return btoa(String.fromCharCode(...s))}static decode(n,s=!1){const a=atob(n);return s?Uint8Array.from(a,o=>o.charCodeAt(0)):a}}class Sr{static encode(n){return Sr.toB64URLEncoding(Av.encode(n))}static decode(n,s=!1){return Sr.decode(Sr.fromB64URLEncoding(n),s)}static toB64URLEncoding(n){return n.replace(/\+/g,"-").replace(/\//g,"_")}static fromB64URLEncoding(n){return n.replace(/_/g,"/").replace(/-/g,"+")}}class Or{constructor(){v(this,"buffers");v(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...n){let s=0;for(let f=0;f<n.length;f++)s+=n[f].length;const a=new Uint8Array(s);let o=0;for(let f=0;f<n.length;f++)a.set(n[f],o),o+=n[f].length;return a}static fromAscii(n){return n||(n=""),Ti.encode(n)}static toAscii(n){return en.decode(n)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){const n=new Uint8Array(this.byteLength);let s=0;for(let a=0;a<this.buffers.length;a++)n.set(this.buffers[a],s),s+=this.buffers[a].length;this.buffers.length=0,this.buffers.push(n)}}shift(){if(this.buffers.length){const n=this.buffers.shift();if(n)return this.byteLength-=n.length,n}return new Uint8Array(0)}drain(n){if(this.buffers.length){this.pack();const s=this.buffers.pop();if(s){const a=this.byteLength;(n===void 0||n>a)&&(n=a);const o=s.subarray(0,n);return a>n&&this.buffers.push(s.subarray(n)),this.byteLength=a-n,o}}return new Uint8Array(0)}fill(n,...s){n&&(this.buffers.push(n),this.byteLength+=n.length);for(let a=0;a<s.length;a++)s[a]&&s[a].length&&(this.buffers.push(s[a]),this.byteLength+=s[a].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}function jv(r,n){return n.forEach(function(s){s&&typeof s!="string"&&!Array.isArray(s)&&Object.keys(s).forEach(function(a){if(a!=="default"&&!(a in r)){var o=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(r,a,o.get?o:{enumerable:!0,get:function(){return s[a]}})}})}),Object.freeze(r)}var Ov=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},Aa=Ov.performance||{};Aa.now||Aa.mozNow||Aa.msNow||Aa.oNow||Aa.webkitNow;var w0={versions:{}},Tv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nv(r){if(r.__esModule)return r;var n=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(r).forEach(function(s){var a=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(n,s,a.get?a:{enumerable:!0,get:function(){return r[s]}})}),n}var hf,Vo={exports:{}},S0={},E0=Nv(jv({__proto__:null,default:S0},[S0]));hf=Vo,(function(){var r="input is invalid type",n=typeof window=="object",s=n?window:{};s.JS_SHA256_NO_WINDOW&&(n=!1);var a=!n&&typeof self=="object",o=!s.JS_SHA256_NO_NODE_JS&&w0.versions&&w0.versions.node;o?s=Tv:a&&(s=self);var f=!s.JS_SHA256_NO_COMMON_JS&&hf.exports,h=!s.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",m="0123456789abcdef".split(""),g=[-2147483648,8388608,32768,128],y=[24,16,8,0],E=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],w=["hex","array","digest","arrayBuffer"],T=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(C){return Object.prototype.toString.call(C)==="[object Array]"}),!h||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(C){return typeof C=="object"&&C.buffer&&C.buffer.constructor===ArrayBuffer});var q=function(C,X){return function(ce){return new ee(X,!0).update(ce)[C]()}},M=function(C){var X=q("hex",C);o&&(X=D(X,C)),X.create=function(){return new ee(C)},X.update=function(G){return X.create().update(G)};for(var ce=0;ce<w.length;++ce){var V=w[ce];X[V]=q(V,C)}return X},D=function(C,X){var ce,V=E0,G=E0.Buffer,K=X?"sha224":"sha256";return ce=G.from&&!s.JS_SHA256_NO_BUFFER_FROM?G.from:function(ae){return new G(ae)},function(ae){if(typeof ae=="string")return V.createHash(K).update(ae,"utf8").digest("hex");if(ae==null)throw new Error(r);return ae.constructor===ArrayBuffer&&(ae=new Uint8Array(ae)),Array.isArray(ae)||ArrayBuffer.isView(ae)||ae.constructor===G?V.createHash(K).update(ce(ae)).digest("hex"):C(ae)}},W=function(C,X){return function(ce,V){return new me(ce,X,!0).update(V)[C]()}},se=function(C){var X=W("hex",C);X.create=function(G){return new me(G,C)},X.update=function(G,K){return X.create(G).update(K)};for(var ce=0;ce<w.length;++ce){var V=w[ce];X[V]=W(V,C)}return X};function ee(C,X){X?(T[0]=T[16]=T[1]=T[2]=T[3]=T[4]=T[5]=T[6]=T[7]=T[8]=T[9]=T[10]=T[11]=T[12]=T[13]=T[14]=T[15]=0,this.blocks=T):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],C?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=C}function me(C,X,ce){var V,G=typeof C;if(G==="string"){var K,ae=[],ne=C.length,ke=0;for(V=0;V<ne;++V)(K=C.charCodeAt(V))<128?ae[ke++]=K:K<2048?(ae[ke++]=192|K>>>6,ae[ke++]=128|63&K):K<55296||K>=57344?(ae[ke++]=224|K>>>12,ae[ke++]=128|K>>>6&63,ae[ke++]=128|63&K):(K=65536+((1023&K)<<10|1023&C.charCodeAt(++V)),ae[ke++]=240|K>>>18,ae[ke++]=128|K>>>12&63,ae[ke++]=128|K>>>6&63,ae[ke++]=128|63&K);C=ae}else{if(G!=="object")throw new Error(r);if(C===null)throw new Error(r);if(h&&C.constructor===ArrayBuffer)C=new Uint8Array(C);else if(!(Array.isArray(C)||h&&ArrayBuffer.isView(C)))throw new Error(r)}C.length>64&&(C=new ee(X,!0).update(C).array());var He=[],Me=[];for(V=0;V<64;++V){var $=C[V]||0;He[V]=92^$,Me[V]=54^$}ee.call(this,X,ce),this.update(Me),this.oKeyPad=He,this.inner=!0,this.sharedMemory=ce}ee.prototype.update=function(C){if(!this.finalized){var X,ce=typeof C;if(ce!=="string"){if(ce!=="object")throw new Error(r);if(C===null)throw new Error(r);if(h&&C.constructor===ArrayBuffer)C=new Uint8Array(C);else if(!(Array.isArray(C)||h&&ArrayBuffer.isView(C)))throw new Error(r);X=!0}for(var V,G,K=0,ae=C.length,ne=this.blocks;K<ae;){if(this.hashed&&(this.hashed=!1,ne[0]=this.block,this.block=ne[16]=ne[1]=ne[2]=ne[3]=ne[4]=ne[5]=ne[6]=ne[7]=ne[8]=ne[9]=ne[10]=ne[11]=ne[12]=ne[13]=ne[14]=ne[15]=0),X)for(G=this.start;K<ae&&G<64;++K)ne[G>>>2]|=C[K]<<y[3&G++];else for(G=this.start;K<ae&&G<64;++K)(V=C.charCodeAt(K))<128?ne[G>>>2]|=V<<y[3&G++]:V<2048?(ne[G>>>2]|=(192|V>>>6)<<y[3&G++],ne[G>>>2]|=(128|63&V)<<y[3&G++]):V<55296||V>=57344?(ne[G>>>2]|=(224|V>>>12)<<y[3&G++],ne[G>>>2]|=(128|V>>>6&63)<<y[3&G++],ne[G>>>2]|=(128|63&V)<<y[3&G++]):(V=65536+((1023&V)<<10|1023&C.charCodeAt(++K)),ne[G>>>2]|=(240|V>>>18)<<y[3&G++],ne[G>>>2]|=(128|V>>>12&63)<<y[3&G++],ne[G>>>2]|=(128|V>>>6&63)<<y[3&G++],ne[G>>>2]|=(128|63&V)<<y[3&G++]);this.lastByteIndex=G,this.bytes+=G-this.start,G>=64?(this.block=ne[16],this.start=G-64,this.hash(),this.hashed=!0):this.start=G}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},ee.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var C=this.blocks,X=this.lastByteIndex;C[16]=this.block,C[X>>>2]|=g[3&X],this.block=C[16],X>=56&&(this.hashed||this.hash(),C[0]=this.block,C[16]=C[1]=C[2]=C[3]=C[4]=C[5]=C[6]=C[7]=C[8]=C[9]=C[10]=C[11]=C[12]=C[13]=C[14]=C[15]=0),C[14]=this.hBytes<<3|this.bytes>>>29,C[15]=this.bytes<<3,this.hash()}},ee.prototype.hash=function(){var C,X,ce,V,G,K,ae,ne,ke,He=this.h0,Me=this.h1,$=this.h2,te=this.h3,de=this.h4,_e=this.h5,be=this.h6,Oe=this.h7,we=this.blocks;for(C=16;C<64;++C)X=((G=we[C-15])>>>7|G<<25)^(G>>>18|G<<14)^G>>>3,ce=((G=we[C-2])>>>17|G<<15)^(G>>>19|G<<13)^G>>>10,we[C]=we[C-16]+X+we[C-7]+ce|0;for(ke=Me&$,C=0;C<64;C+=4)this.first?(this.is224?(K=300032,Oe=(G=we[0]-1413257819)-150054599|0,te=G+24177077|0):(K=704751109,Oe=(G=we[0]-210244248)-1521486534|0,te=G+143694565|0),this.first=!1):(X=(He>>>2|He<<30)^(He>>>13|He<<19)^(He>>>22|He<<10),V=(K=He&Me)^He&$^ke,Oe=te+(G=Oe+(ce=(de>>>6|de<<26)^(de>>>11|de<<21)^(de>>>25|de<<7))+(de&_e^~de&be)+E[C]+we[C])|0,te=G+(X+V)|0),X=(te>>>2|te<<30)^(te>>>13|te<<19)^(te>>>22|te<<10),V=(ae=te&He)^te&Me^K,be=$+(G=be+(ce=(Oe>>>6|Oe<<26)^(Oe>>>11|Oe<<21)^(Oe>>>25|Oe<<7))+(Oe&de^~Oe&_e)+E[C+1]+we[C+1])|0,X=(($=G+(X+V)|0)>>>2|$<<30)^($>>>13|$<<19)^($>>>22|$<<10),V=(ne=$&te)^$&He^ae,_e=Me+(G=_e+(ce=(be>>>6|be<<26)^(be>>>11|be<<21)^(be>>>25|be<<7))+(be&Oe^~be&de)+E[C+2]+we[C+2])|0,X=((Me=G+(X+V)|0)>>>2|Me<<30)^(Me>>>13|Me<<19)^(Me>>>22|Me<<10),V=(ke=Me&$)^Me&te^ne,de=He+(G=de+(ce=(_e>>>6|_e<<26)^(_e>>>11|_e<<21)^(_e>>>25|_e<<7))+(_e&be^~_e&Oe)+E[C+3]+we[C+3])|0,He=G+(X+V)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+He|0,this.h1=this.h1+Me|0,this.h2=this.h2+$|0,this.h3=this.h3+te|0,this.h4=this.h4+de|0,this.h5=this.h5+_e|0,this.h6=this.h6+be|0,this.h7=this.h7+Oe|0},ee.prototype.hex=function(){this.finalize();var C=this.h0,X=this.h1,ce=this.h2,V=this.h3,G=this.h4,K=this.h5,ae=this.h6,ne=this.h7,ke=m[C>>>28&15]+m[C>>>24&15]+m[C>>>20&15]+m[C>>>16&15]+m[C>>>12&15]+m[C>>>8&15]+m[C>>>4&15]+m[15&C]+m[X>>>28&15]+m[X>>>24&15]+m[X>>>20&15]+m[X>>>16&15]+m[X>>>12&15]+m[X>>>8&15]+m[X>>>4&15]+m[15&X]+m[ce>>>28&15]+m[ce>>>24&15]+m[ce>>>20&15]+m[ce>>>16&15]+m[ce>>>12&15]+m[ce>>>8&15]+m[ce>>>4&15]+m[15&ce]+m[V>>>28&15]+m[V>>>24&15]+m[V>>>20&15]+m[V>>>16&15]+m[V>>>12&15]+m[V>>>8&15]+m[V>>>4&15]+m[15&V]+m[G>>>28&15]+m[G>>>24&15]+m[G>>>20&15]+m[G>>>16&15]+m[G>>>12&15]+m[G>>>8&15]+m[G>>>4&15]+m[15&G]+m[K>>>28&15]+m[K>>>24&15]+m[K>>>20&15]+m[K>>>16&15]+m[K>>>12&15]+m[K>>>8&15]+m[K>>>4&15]+m[15&K]+m[ae>>>28&15]+m[ae>>>24&15]+m[ae>>>20&15]+m[ae>>>16&15]+m[ae>>>12&15]+m[ae>>>8&15]+m[ae>>>4&15]+m[15&ae];return this.is224||(ke+=m[ne>>>28&15]+m[ne>>>24&15]+m[ne>>>20&15]+m[ne>>>16&15]+m[ne>>>12&15]+m[ne>>>8&15]+m[ne>>>4&15]+m[15&ne]),ke},ee.prototype.toString=ee.prototype.hex,ee.prototype.digest=function(){this.finalize();var C=this.h0,X=this.h1,ce=this.h2,V=this.h3,G=this.h4,K=this.h5,ae=this.h6,ne=this.h7,ke=[C>>>24&255,C>>>16&255,C>>>8&255,255&C,X>>>24&255,X>>>16&255,X>>>8&255,255&X,ce>>>24&255,ce>>>16&255,ce>>>8&255,255&ce,V>>>24&255,V>>>16&255,V>>>8&255,255&V,G>>>24&255,G>>>16&255,G>>>8&255,255&G,K>>>24&255,K>>>16&255,K>>>8&255,255&K,ae>>>24&255,ae>>>16&255,ae>>>8&255,255&ae];return this.is224||ke.push(ne>>>24&255,ne>>>16&255,ne>>>8&255,255&ne),ke},ee.prototype.array=ee.prototype.digest,ee.prototype.arrayBuffer=function(){this.finalize();var C=new ArrayBuffer(this.is224?28:32),X=new DataView(C);return X.setUint32(0,this.h0),X.setUint32(4,this.h1),X.setUint32(8,this.h2),X.setUint32(12,this.h3),X.setUint32(16,this.h4),X.setUint32(20,this.h5),X.setUint32(24,this.h6),this.is224||X.setUint32(28,this.h7),C},me.prototype=new ee,me.prototype.finalize=function(){if(ee.prototype.finalize.call(this),this.inner){this.inner=!1;var C=this.array();ee.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(C),ee.prototype.finalize.call(this)}};var re=M();re.sha256=re,re.sha224=M(!0),re.sha256.hmac=se(),re.sha224.hmac=se(!0),f?hf.exports=re:(s.sha256=re.sha256,s.sha224=re.sha224)})();Vo.exports;Vo.exports.sha224;var A0=Vo.exports.sha256;function Rf(r){return zv(r)}function Cv(r){if(!/^[0-9A-Fa-f]+$/.test(r))return!1;const s=/^[0-9A-F]+$/.test(r),a=/^[0-9a-f]+$/.test(r);return s||a?r.length%2===0:!1}function kv(r){return/^[A-Za-z0-9\-_]*(={0,2})?$/.test(r)||/^[A-Za-z0-9+/]*(={0,2})?$/.test(r)}function Mv(r){return Cv(r)?"hex":kv(r)?"b64":""}function Rv(r){if(r.length%2!==0)throw new Error("hex string must have an even length");const n=new Uint8Array(r.length/2);for(let s=0;s<r.length;s+=2)n[s/2]=parseInt(r.substring(s,s+2),16);return n}function Dv(r){r=r.replace(/-/g,"+"),r=r.replace(/_/g,"/");const n=atob(r);return Uint8Array.from(n,s=>s.charCodeAt(0))}function zv(r){switch(Mv(r)){case"hex":return Rv(r);case"b64":return Dv(r)}return null}function qv(r,n){const s=typeof r=="string"?Rf(r):r,a=typeof n=="string"?Rf(n):n;if(s===null||a===null||s.length!==a.length)return!1;for(let o=0;o<s.length;o++)if(s[o]!==a[o])return!1;return!0}class Eg{constructor(n,s,a=!0){v(this,"token");v(this,"received");v(this,"ctx");v(this,"requestSubject");v(this,"mux");this.mux=n,this.requestSubject=s,this.received=0,this.token=Zs.next(),a&&(this.ctx=new Error)}}class Uv extends Eg{constructor(s,a,o={maxWait:1e3}){super(s,a);v(this,"callback");v(this,"done");v(this,"timer");v(this,"max");v(this,"opts");if(this.opts=o,typeof this.opts.callback!="function")throw new Error("callback is required");this.callback=this.opts.callback,this.max=typeof o.maxMessages=="number"&&o.maxMessages>0?o.maxMessages:-1,this.done=st(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},o.maxWait)}cancel(s){s&&this.callback(s,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(s,a){s?(this.ctx&&(s.stack+=`
32
+ `:a="\\n";break;case"\r":a="\\r";break;case" ":a="\\t";break}throw Error(`invalid ${r} name - ${r} name cannot contain '${a}'`)}}),""}function ka(r,n=""){if(n==="")throw Error(`${r} name required`);const s=vv(n);if(s.length)throw new Error(`invalid ${r} name - ${r} name ${s}`)}function vv(r=""){if(r==="")throw Error("name required");const n=/^[-\w]+$/g;if(r.match(n)===null){for(const a of r.split(""))if(a.match(n)===null)return`cannot contain '${a}'`}return""}function Nf(r){if(r.data.length>0)return!1;const n=r.headers;return n?n.code>=100&&n.code<200:!1}function Cf(r){var n;return Nf(r)&&((n=r.headers)==null?void 0:n.description)==="Idle Heartbeat"}function _v(r,n,s){const a=hs(r,n),o={hdr:1,sid:0,size:0},f=new nh(o,nn,{});return f._headers=a,f._subject=s,f}function wr(r){if(r.data.length!==0)return null;const n=r.headers;return n?Sg(n.code,n.description):null}var xn;(function(r){r.MaxBatchExceeded="exceeded maxrequestbatch of",r.MaxExpiresExceeded="exceeded maxrequestexpires of",r.MaxBytesExceeded="exceeded maxrequestmaxbytes of",r.MaxMessageSizeExceeded="message size exceeds maxbytes",r.PushConsumer="consumer is push based",r.MaxWaitingExceeded="exceeded maxwaiting",r.IdleHeartbeatMissed="idle heartbeats missed",r.ConsumerDeleted="consumer deleted"})(xn||(xn={}));function wv(r){return r.code!==ie.JetStream409?!1:[xn.MaxBatchExceeded,xn.MaxExpiresExceeded,xn.MaxBytesExceeded,xn.MaxMessageSizeExceeded,xn.PushConsumer,xn.IdleHeartbeatMissed,xn.ConsumerDeleted].find(s=>r.message.indexOf(s)!==-1)!==void 0}function Sg(r,n=""){if(r<300)return null;switch(n=n.toLowerCase(),r){case 404:return new ue(n,ie.JetStream404NoMessages);case 408:return new ue(n,ie.JetStream408RequestTimeout);case 409:{const s=n.startsWith(xn.IdleHeartbeatMissed)?ie.JetStreamIdleHeartBeat:ie.JetStream409;return new ue(n,s)}case 503:return ue.errorForCode(ie.JetStreamNotEnabled,new Error(n));default:return n===""&&(n=ie.Unknown),new ue(n,`${r}`)}}class _t{constructor(){v(this,"inflight");v(this,"processed");v(this,"received");v(this,"noIterator");v(this,"iterClosed");v(this,"done");v(this,"signal");v(this,"yields");v(this,"filtered");v(this,"pendingFiltered");v(this,"ingestionFilterFn");v(this,"protocolFilterFn");v(this,"dispatchedFn");v(this,"ctx");v(this,"_data");v(this,"err");v(this,"time");v(this,"yielding");this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=st(),this.yields=[],this.iterClosed=st(),this.time=0,this.yielding=!1}[Symbol.asyncIterator](){return this.iterate()}push(n){if(this.done)return;if(typeof n=="function"){this.yields.push(n),this.signal.resolve();return}const{ingest:s,protocol:a}=this.ingestionFilterFn?this.ingestionFilterFn(n,this.ctx||this):{ingest:!0,protocol:!1};s&&(a&&(this.filtered++,this.pendingFiltered++),this.yields.push(n),this.signal.resolve())}async*iterate(){if(this.noIterator)throw new ue("unsupported iterator",ie.ApiError);if(this.yielding)throw new ue("already yielding",ie.ApiError);this.yielding=!0;try{for(;;){if(this.yields.length===0&&await this.signal,this.err)throw this.err;const n=this.yields;this.inflight=n.length,this.yields=[];for(let s=0;s<n.length;s++){if(typeof n[s]=="function"){const o=n[s];try{o()}catch(f){throw f}if(this.err)throw this.err;continue}if(this.protocolFilterFn?this.protocolFilterFn(n[s]):!0){this.processed++;const o=Date.now();yield n[s],this.time=Date.now()-o,this.dispatchedFn&&n[s]&&this.dispatchedFn(n[s])}else this.pendingFiltered--;this.inflight--}if(this.done)break;this.yields.length===0&&(n.length=0,this.yields=n,this.signal=st())}}finally{this.stop()}}stop(n){this.done||(this.err=n,this.done=!0,this.signal.resolve(),this.iterClosed.resolve(n))}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}class sh{constructor(n,s,a={maxOut:2}){v(this,"interval");v(this,"maxOut");v(this,"cancelAfter");v(this,"timer");v(this,"autoCancelTimer");v(this,"last");v(this,"missed");v(this,"count");v(this,"callback");this.interval=n,this.maxOut=(a==null?void 0:a.maxOut)||2,this.cancelAfter=(a==null?void 0:a.cancelAfter)||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=s,this._schedule()}cancel(){this.autoCancelTimer&&clearTimeout(this.autoCancelTimer),this.timer&&clearInterval(this.timer),this.timer=0,this.autoCancelTimer=0,this.missed=0}work(){this.last=Date.now(),this.missed=0}_change(n,s=0,a=2){this.interval=n,this.maxOut=a,this.cancelAfter=s,this.restart()}restart(){this.cancel(),this._schedule()}_schedule(){this.cancelAfter>0&&(this.autoCancelTimer=setTimeout(()=>{this.cancel()},this.cancelAfter)),this.timer=setInterval(()=>{if(this.count++,Date.now()-this.last>this.interval&&this.missed++,this.missed>=this.maxOut)try{this.callback(this.missed)===!0&&this.cancel()}catch(n){console.log(n)}},this.interval)}}var kf;(function(r){r.Limits="limits",r.Interest="interest",r.Workqueue="workqueue"})(kf||(kf={}));var La;(function(r){r.Old="old",r.New="new"})(La||(La={}));var Mf;(function(r){r.File="file",r.Memory="memory"})(Mf||(Mf={}));var ft;(function(r){r.All="all",r.Last="last",r.New="new",r.StartSequence="by_start_sequence",r.StartTime="by_start_time",r.LastPerSubject="last_per_subject"})(ft||(ft={}));var vt;(function(r){r.None="none",r.All="all",r.Explicit="explicit",r.NotSet=""})(vt||(vt={}));var jr;(function(r){r.Instant="instant",r.Original="original"})(jr||(jr={}));var Ws;(function(r){r.None="none",r.S2="s2"})(Ws||(Ws={}));var Do;(function(r){r.CreateOrUpdate="",r.Update="update",r.Create="create"})(Do||(Do={}));function Sv(r,n={}){return Object.assign({name:r,deliver_policy:ft.All,ack_policy:vt.Explicit,ack_wait:nt(30*1e3),replay_policy:jr.Instant},n)}var x0;(function(r){r.API="api_audit",r.StreamAction="stream_action",r.ConsumerAction="consumer_action",r.SnapshotCreate="snapshot_create",r.SnapshotComplete="snapshot_complete",r.RestoreCreate="restore_create",r.RestoreComplete="restore_complete",r.MaxDeliver="max_deliver",r.Terminated="terminated",r.Ack="consumer_ack",r.StreamLeaderElected="stream_leader_elected",r.StreamQuorumLost="stream_quorum_lost",r.ConsumerLeaderElected="consumer_leader_elected",r.ConsumerQuorumLost="consumer_quorum_lost"})(x0||(x0={}));var Dt;(function(r){r.StreamSourceHdr="Nats-Stream-Source",r.LastConsumerSeqHdr="Nats-Last-Consumer",r.LastStreamSeqHdr="Nats-Last-Stream",r.ConsumerStalledHdr="Nats-Consumer-Stalled",r.MessageSizeHdr="Nats-Msg-Size",r.RollupHdr="Nats-Rollup",r.RollupValueSubject="sub",r.RollupValueAll="all",r.PendingMessagesHdr="Nats-Pending-Messages",r.PendingBytesHdr="Nats-Pending-Bytes"})(Dt||(Dt={}));var Nn;(function(r){r.LastValue="",r.AllHistory="history",r.UpdatesOnly="updates"})(Nn||(Nn={}));var br;(function(r){r.Stream="Nats-Stream",r.Sequence="Nats-Sequence",r.TimeStamp="Nats-Time-Stamp",r.Subject="Nats-Subject"})(br||(br={}));var v0;(function(r){r.Stream="Nats-Stream",r.Subject="Nats-Subject",r.Sequence="Nats-Sequence",r.LastSequence="Nats-Last-Sequence",r.Size="Nats-Msg-Size"})(v0||(v0={}));const Zt="KV_";class Ev{constructor(n){v(this,"config");v(this,"ordered");v(this,"mack");v(this,"stream");v(this,"callbackFn");v(this,"max");v(this,"qname");v(this,"isBind");v(this,"filters");this.stream="",this.mack=!1,this.ordered=!1,this.config=Sv("",n||{})}getOpts(){var s;const n={};if(n.config=Object.assign({},this.config),n.config.filter_subject&&(this.filterSubject(n.config.filter_subject),n.config.filter_subject=void 0),n.config.filter_subjects&&((s=n.config.filter_subjects)==null||s.forEach(a=>{this.filterSubject(a)}),n.config.filter_subjects=void 0),n.mack=this.mack,n.stream=this.stream,n.callbackFn=this.callbackFn,n.max=this.max,n.queue=this.qname,n.ordered=this.ordered,n.config.ack_policy=n.ordered?vt.None:n.config.ack_policy,n.isBind=n.isBind||!1,this.filters)switch(this.filters.length){case 0:break;case 1:n.config.filter_subject=this.filters[0];break;default:n.config.filter_subjects=this.filters}return n}description(n){return this.config.description=n,this}deliverTo(n){return this.config.deliver_subject=n,this}durable(n){return _r(n),this.config.durable_name=n,this}startSequence(n){if(n<=0)throw new Error("sequence must be greater than 0");return this.config.deliver_policy=ft.StartSequence,this.config.opt_start_seq=n,this}startTime(n){return this.config.deliver_policy=ft.StartTime,this.config.opt_start_time=n.toISOString(),this}deliverAll(){return this.config.deliver_policy=ft.All,this}deliverLastPerSubject(){return this.config.deliver_policy=ft.LastPerSubject,this}deliverLast(){return this.config.deliver_policy=ft.Last,this}deliverNew(){return this.config.deliver_policy=ft.New,this}startAtTimeDelta(n){return this.startTime(new Date(Date.now()-n)),this}headersOnly(){return this.config.headers_only=!0,this}ackNone(){return this.config.ack_policy=vt.None,this}ackAll(){return this.config.ack_policy=vt.All,this}ackExplicit(){return this.config.ack_policy=vt.Explicit,this}ackWait(n){return this.config.ack_wait=nt(n),this}maxDeliver(n){return this.config.max_deliver=n,this}filterSubject(n){return this.filters=this.filters||[],this.filters.push(n),this}replayInstantly(){return this.config.replay_policy=jr.Instant,this}replayOriginal(){return this.config.replay_policy=jr.Original,this}sample(n){if(n=Math.trunc(n),n<0||n>100)throw new Error("value must be between 0-100");return this.config.sample_freq=`${n}%`,this}limit(n){return this.config.rate_limit_bps=n,this}maxWaiting(n){return this.config.max_waiting=n,this}maxAckPending(n){return this.config.max_ack_pending=n,this}idleHeartbeat(n){return this.config.idle_heartbeat=nt(n),this}flowControl(){return this.config.flow_control=!0,this}deliverGroup(n){return this.queue(n),this}manualAck(){return this.mack=!0,this}maxMessages(n){return this.max=n,this}callback(n){return this.callbackFn=n,this}queue(n){return this.qname=n,this.config.deliver_group=n,this}orderedConsumer(){return this.ordered=!0,this}bind(n,s){return this.stream=n,this.config.durable_name=s,this.isBind=!0,this}bindStream(n){return this.stream=n,this}inactiveEphemeralThreshold(n){return this.config.inactive_threshold=nt(n),this}maxPullBatch(n){return this.config.max_batch=n,this}maxPullRequestExpires(n){return this.config.max_expires=nt(n),this}memory(){return this.config.mem_storage=!0,this}numReplicas(n){return this.config.num_replicas=n,this}consumerName(n){return this.config.name=n,this}}function Qs(r){return new Ev(r)}function _0(r){return typeof r.getOpts=="function"}class Av{static encode(n){if(typeof n=="string")return btoa(n);const s=Array.from(n);return btoa(String.fromCharCode(...s))}static decode(n,s=!1){const a=atob(n);return s?Uint8Array.from(a,o=>o.charCodeAt(0)):a}}class Sr{static encode(n){return Sr.toB64URLEncoding(Av.encode(n))}static decode(n,s=!1){return Sr.decode(Sr.fromB64URLEncoding(n),s)}static toB64URLEncoding(n){return n.replace(/\+/g,"-").replace(/\//g,"_")}static fromB64URLEncoding(n){return n.replace(/_/g,"/").replace(/-/g,"+")}}class Or{constructor(){v(this,"buffers");v(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...n){let s=0;for(let f=0;f<n.length;f++)s+=n[f].length;const a=new Uint8Array(s);let o=0;for(let f=0;f<n.length;f++)a.set(n[f],o),o+=n[f].length;return a}static fromAscii(n){return n||(n=""),Ti.encode(n)}static toAscii(n){return en.decode(n)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){const n=new Uint8Array(this.byteLength);let s=0;for(let a=0;a<this.buffers.length;a++)n.set(this.buffers[a],s),s+=this.buffers[a].length;this.buffers.length=0,this.buffers.push(n)}}shift(){if(this.buffers.length){const n=this.buffers.shift();if(n)return this.byteLength-=n.length,n}return new Uint8Array(0)}drain(n){if(this.buffers.length){this.pack();const s=this.buffers.pop();if(s){const a=this.byteLength;(n===void 0||n>a)&&(n=a);const o=s.subarray(0,n);return a>n&&this.buffers.push(s.subarray(n)),this.byteLength=a-n,o}}return new Uint8Array(0)}fill(n,...s){n&&(this.buffers.push(n),this.byteLength+=n.length);for(let a=0;a<s.length;a++)s[a]&&s[a].length&&(this.buffers.push(s[a]),this.byteLength+=s[a].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}function jv(r,n){return n.forEach(function(s){s&&typeof s!="string"&&!Array.isArray(s)&&Object.keys(s).forEach(function(a){if(a!=="default"&&!(a in r)){var o=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(r,a,o.get?o:{enumerable:!0,get:function(){return s[a]}})}})}),Object.freeze(r)}var Ov=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},Aa=Ov.performance||{};Aa.now||Aa.mozNow||Aa.msNow||Aa.oNow||Aa.webkitNow;var w0={versions:{}},Tv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nv(r){if(r.__esModule)return r;var n=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(r).forEach(function(s){var a=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(n,s,a.get?a:{enumerable:!0,get:function(){return r[s]}})}),n}var hf,Vo={exports:{}},S0={},E0=Nv(jv({__proto__:null,default:S0},[S0]));hf=Vo,(function(){var r="input is invalid type",n=typeof window=="object",s=n?window:{};s.JS_SHA256_NO_WINDOW&&(n=!1);var a=!n&&typeof self=="object",o=!s.JS_SHA256_NO_NODE_JS&&w0.versions&&w0.versions.node;o?s=Tv:a&&(s=self);var f=!s.JS_SHA256_NO_COMMON_JS&&hf.exports,h=!s.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",m="0123456789abcdef".split(""),g=[-2147483648,8388608,32768,128],y=[24,16,8,0],E=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],w=["hex","array","digest","arrayBuffer"],T=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(C){return Object.prototype.toString.call(C)==="[object Array]"}),!h||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(C){return typeof C=="object"&&C.buffer&&C.buffer.constructor===ArrayBuffer});var q=function(C,X){return function(ce){return new ee(X,!0).update(ce)[C]()}},M=function(C){var X=q("hex",C);o&&(X=D(X,C)),X.create=function(){return new ee(C)},X.update=function(G){return X.create().update(G)};for(var ce=0;ce<w.length;++ce){var V=w[ce];X[V]=q(V,C)}return X},D=function(C,X){var ce,V=E0,G=E0.Buffer,K=X?"sha224":"sha256";return ce=G.from&&!s.JS_SHA256_NO_BUFFER_FROM?G.from:function(ae){return new G(ae)},function(ae){if(typeof ae=="string")return V.createHash(K).update(ae,"utf8").digest("hex");if(ae==null)throw new Error(r);return ae.constructor===ArrayBuffer&&(ae=new Uint8Array(ae)),Array.isArray(ae)||ArrayBuffer.isView(ae)||ae.constructor===G?V.createHash(K).update(ce(ae)).digest("hex"):C(ae)}},W=function(C,X){return function(ce,V){return new me(ce,X,!0).update(V)[C]()}},se=function(C){var X=W("hex",C);X.create=function(G){return new me(G,C)},X.update=function(G,K){return X.create(G).update(K)};for(var ce=0;ce<w.length;++ce){var V=w[ce];X[V]=W(V,C)}return X};function ee(C,X){X?(T[0]=T[16]=T[1]=T[2]=T[3]=T[4]=T[5]=T[6]=T[7]=T[8]=T[9]=T[10]=T[11]=T[12]=T[13]=T[14]=T[15]=0,this.blocks=T):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],C?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=C}function me(C,X,ce){var V,G=typeof C;if(G==="string"){var K,ae=[],ne=C.length,ke=0;for(V=0;V<ne;++V)(K=C.charCodeAt(V))<128?ae[ke++]=K:K<2048?(ae[ke++]=192|K>>>6,ae[ke++]=128|63&K):K<55296||K>=57344?(ae[ke++]=224|K>>>12,ae[ke++]=128|K>>>6&63,ae[ke++]=128|63&K):(K=65536+((1023&K)<<10|1023&C.charCodeAt(++V)),ae[ke++]=240|K>>>18,ae[ke++]=128|K>>>12&63,ae[ke++]=128|K>>>6&63,ae[ke++]=128|63&K);C=ae}else{if(G!=="object")throw new Error(r);if(C===null)throw new Error(r);if(h&&C.constructor===ArrayBuffer)C=new Uint8Array(C);else if(!(Array.isArray(C)||h&&ArrayBuffer.isView(C)))throw new Error(r)}C.length>64&&(C=new ee(X,!0).update(C).array());var He=[],Me=[];for(V=0;V<64;++V){var $=C[V]||0;He[V]=92^$,Me[V]=54^$}ee.call(this,X,ce),this.update(Me),this.oKeyPad=He,this.inner=!0,this.sharedMemory=ce}ee.prototype.update=function(C){if(!this.finalized){var X,ce=typeof C;if(ce!=="string"){if(ce!=="object")throw new Error(r);if(C===null)throw new Error(r);if(h&&C.constructor===ArrayBuffer)C=new Uint8Array(C);else if(!(Array.isArray(C)||h&&ArrayBuffer.isView(C)))throw new Error(r);X=!0}for(var V,G,K=0,ae=C.length,ne=this.blocks;K<ae;){if(this.hashed&&(this.hashed=!1,ne[0]=this.block,this.block=ne[16]=ne[1]=ne[2]=ne[3]=ne[4]=ne[5]=ne[6]=ne[7]=ne[8]=ne[9]=ne[10]=ne[11]=ne[12]=ne[13]=ne[14]=ne[15]=0),X)for(G=this.start;K<ae&&G<64;++K)ne[G>>>2]|=C[K]<<y[3&G++];else for(G=this.start;K<ae&&G<64;++K)(V=C.charCodeAt(K))<128?ne[G>>>2]|=V<<y[3&G++]:V<2048?(ne[G>>>2]|=(192|V>>>6)<<y[3&G++],ne[G>>>2]|=(128|63&V)<<y[3&G++]):V<55296||V>=57344?(ne[G>>>2]|=(224|V>>>12)<<y[3&G++],ne[G>>>2]|=(128|V>>>6&63)<<y[3&G++],ne[G>>>2]|=(128|63&V)<<y[3&G++]):(V=65536+((1023&V)<<10|1023&C.charCodeAt(++K)),ne[G>>>2]|=(240|V>>>18)<<y[3&G++],ne[G>>>2]|=(128|V>>>12&63)<<y[3&G++],ne[G>>>2]|=(128|V>>>6&63)<<y[3&G++],ne[G>>>2]|=(128|63&V)<<y[3&G++]);this.lastByteIndex=G,this.bytes+=G-this.start,G>=64?(this.block=ne[16],this.start=G-64,this.hash(),this.hashed=!0):this.start=G}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},ee.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var C=this.blocks,X=this.lastByteIndex;C[16]=this.block,C[X>>>2]|=g[3&X],this.block=C[16],X>=56&&(this.hashed||this.hash(),C[0]=this.block,C[16]=C[1]=C[2]=C[3]=C[4]=C[5]=C[6]=C[7]=C[8]=C[9]=C[10]=C[11]=C[12]=C[13]=C[14]=C[15]=0),C[14]=this.hBytes<<3|this.bytes>>>29,C[15]=this.bytes<<3,this.hash()}},ee.prototype.hash=function(){var C,X,ce,V,G,K,ae,ne,ke,He=this.h0,Me=this.h1,$=this.h2,te=this.h3,de=this.h4,_e=this.h5,xe=this.h6,Oe=this.h7,we=this.blocks;for(C=16;C<64;++C)X=((G=we[C-15])>>>7|G<<25)^(G>>>18|G<<14)^G>>>3,ce=((G=we[C-2])>>>17|G<<15)^(G>>>19|G<<13)^G>>>10,we[C]=we[C-16]+X+we[C-7]+ce|0;for(ke=Me&$,C=0;C<64;C+=4)this.first?(this.is224?(K=300032,Oe=(G=we[0]-1413257819)-150054599|0,te=G+24177077|0):(K=704751109,Oe=(G=we[0]-210244248)-1521486534|0,te=G+143694565|0),this.first=!1):(X=(He>>>2|He<<30)^(He>>>13|He<<19)^(He>>>22|He<<10),V=(K=He&Me)^He&$^ke,Oe=te+(G=Oe+(ce=(de>>>6|de<<26)^(de>>>11|de<<21)^(de>>>25|de<<7))+(de&_e^~de&xe)+E[C]+we[C])|0,te=G+(X+V)|0),X=(te>>>2|te<<30)^(te>>>13|te<<19)^(te>>>22|te<<10),V=(ae=te&He)^te&Me^K,xe=$+(G=xe+(ce=(Oe>>>6|Oe<<26)^(Oe>>>11|Oe<<21)^(Oe>>>25|Oe<<7))+(Oe&de^~Oe&_e)+E[C+1]+we[C+1])|0,X=(($=G+(X+V)|0)>>>2|$<<30)^($>>>13|$<<19)^($>>>22|$<<10),V=(ne=$&te)^$&He^ae,_e=Me+(G=_e+(ce=(xe>>>6|xe<<26)^(xe>>>11|xe<<21)^(xe>>>25|xe<<7))+(xe&Oe^~xe&de)+E[C+2]+we[C+2])|0,X=((Me=G+(X+V)|0)>>>2|Me<<30)^(Me>>>13|Me<<19)^(Me>>>22|Me<<10),V=(ke=Me&$)^Me&te^ne,de=He+(G=de+(ce=(_e>>>6|_e<<26)^(_e>>>11|_e<<21)^(_e>>>25|_e<<7))+(_e&xe^~_e&Oe)+E[C+3]+we[C+3])|0,He=G+(X+V)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+He|0,this.h1=this.h1+Me|0,this.h2=this.h2+$|0,this.h3=this.h3+te|0,this.h4=this.h4+de|0,this.h5=this.h5+_e|0,this.h6=this.h6+xe|0,this.h7=this.h7+Oe|0},ee.prototype.hex=function(){this.finalize();var C=this.h0,X=this.h1,ce=this.h2,V=this.h3,G=this.h4,K=this.h5,ae=this.h6,ne=this.h7,ke=m[C>>>28&15]+m[C>>>24&15]+m[C>>>20&15]+m[C>>>16&15]+m[C>>>12&15]+m[C>>>8&15]+m[C>>>4&15]+m[15&C]+m[X>>>28&15]+m[X>>>24&15]+m[X>>>20&15]+m[X>>>16&15]+m[X>>>12&15]+m[X>>>8&15]+m[X>>>4&15]+m[15&X]+m[ce>>>28&15]+m[ce>>>24&15]+m[ce>>>20&15]+m[ce>>>16&15]+m[ce>>>12&15]+m[ce>>>8&15]+m[ce>>>4&15]+m[15&ce]+m[V>>>28&15]+m[V>>>24&15]+m[V>>>20&15]+m[V>>>16&15]+m[V>>>12&15]+m[V>>>8&15]+m[V>>>4&15]+m[15&V]+m[G>>>28&15]+m[G>>>24&15]+m[G>>>20&15]+m[G>>>16&15]+m[G>>>12&15]+m[G>>>8&15]+m[G>>>4&15]+m[15&G]+m[K>>>28&15]+m[K>>>24&15]+m[K>>>20&15]+m[K>>>16&15]+m[K>>>12&15]+m[K>>>8&15]+m[K>>>4&15]+m[15&K]+m[ae>>>28&15]+m[ae>>>24&15]+m[ae>>>20&15]+m[ae>>>16&15]+m[ae>>>12&15]+m[ae>>>8&15]+m[ae>>>4&15]+m[15&ae];return this.is224||(ke+=m[ne>>>28&15]+m[ne>>>24&15]+m[ne>>>20&15]+m[ne>>>16&15]+m[ne>>>12&15]+m[ne>>>8&15]+m[ne>>>4&15]+m[15&ne]),ke},ee.prototype.toString=ee.prototype.hex,ee.prototype.digest=function(){this.finalize();var C=this.h0,X=this.h1,ce=this.h2,V=this.h3,G=this.h4,K=this.h5,ae=this.h6,ne=this.h7,ke=[C>>>24&255,C>>>16&255,C>>>8&255,255&C,X>>>24&255,X>>>16&255,X>>>8&255,255&X,ce>>>24&255,ce>>>16&255,ce>>>8&255,255&ce,V>>>24&255,V>>>16&255,V>>>8&255,255&V,G>>>24&255,G>>>16&255,G>>>8&255,255&G,K>>>24&255,K>>>16&255,K>>>8&255,255&K,ae>>>24&255,ae>>>16&255,ae>>>8&255,255&ae];return this.is224||ke.push(ne>>>24&255,ne>>>16&255,ne>>>8&255,255&ne),ke},ee.prototype.array=ee.prototype.digest,ee.prototype.arrayBuffer=function(){this.finalize();var C=new ArrayBuffer(this.is224?28:32),X=new DataView(C);return X.setUint32(0,this.h0),X.setUint32(4,this.h1),X.setUint32(8,this.h2),X.setUint32(12,this.h3),X.setUint32(16,this.h4),X.setUint32(20,this.h5),X.setUint32(24,this.h6),this.is224||X.setUint32(28,this.h7),C},me.prototype=new ee,me.prototype.finalize=function(){if(ee.prototype.finalize.call(this),this.inner){this.inner=!1;var C=this.array();ee.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(C),ee.prototype.finalize.call(this)}};var re=M();re.sha256=re,re.sha224=M(!0),re.sha256.hmac=se(),re.sha224.hmac=se(!0),f?hf.exports=re:(s.sha256=re.sha256,s.sha224=re.sha224)})();Vo.exports;Vo.exports.sha224;var A0=Vo.exports.sha256;function Rf(r){return zv(r)}function Cv(r){if(!/^[0-9A-Fa-f]+$/.test(r))return!1;const s=/^[0-9A-F]+$/.test(r),a=/^[0-9a-f]+$/.test(r);return s||a?r.length%2===0:!1}function kv(r){return/^[A-Za-z0-9\-_]*(={0,2})?$/.test(r)||/^[A-Za-z0-9+/]*(={0,2})?$/.test(r)}function Mv(r){return Cv(r)?"hex":kv(r)?"b64":""}function Rv(r){if(r.length%2!==0)throw new Error("hex string must have an even length");const n=new Uint8Array(r.length/2);for(let s=0;s<r.length;s+=2)n[s/2]=parseInt(r.substring(s,s+2),16);return n}function Dv(r){r=r.replace(/-/g,"+"),r=r.replace(/_/g,"/");const n=atob(r);return Uint8Array.from(n,s=>s.charCodeAt(0))}function zv(r){switch(Mv(r)){case"hex":return Rv(r);case"b64":return Dv(r)}return null}function qv(r,n){const s=typeof r=="string"?Rf(r):r,a=typeof n=="string"?Rf(n):n;if(s===null||a===null||s.length!==a.length)return!1;for(let o=0;o<s.length;o++)if(s[o]!==a[o])return!1;return!0}class Eg{constructor(n,s,a=!0){v(this,"token");v(this,"received");v(this,"ctx");v(this,"requestSubject");v(this,"mux");this.mux=n,this.requestSubject=s,this.received=0,this.token=Zs.next(),a&&(this.ctx=new Error)}}class Uv extends Eg{constructor(s,a,o={maxWait:1e3}){super(s,a);v(this,"callback");v(this,"done");v(this,"timer");v(this,"max");v(this,"opts");if(this.opts=o,typeof this.opts.callback!="function")throw new Error("callback is required");this.callback=this.opts.callback,this.max=typeof o.maxMessages=="number"&&o.maxMessages>0?o.maxMessages:-1,this.done=st(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},o.maxWait)}cancel(s){s&&this.callback(s,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(s,a){s?(this.ctx&&(s.stack+=`
33
33
 
34
34
  ${this.ctx.stack}`),this.cancel(s)):(this.callback(null,a),this.opts.strategy===kn.Count&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===kn.JitterTimer&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.jitter||300)),this.opts.strategy===kn.SentinelMsg&&a&&a.data.length===0&&this.cancel())}}class Ag extends Eg{constructor(s,a,o={timeout:1e3},f=!0){super(s,a,f);v(this,"deferred");v(this,"timer");this.deferred=st(),this.timer=Ar(o.timeout,f)}resolver(s,a){this.timer&&this.timer.cancel(),s?(this.ctx&&(s.stack+=`
35
35
 
36
36
  ${this.ctx.stack}`),this.deferred.reject(s)):this.deferred.resolve(a),this.cancel()}cancel(s){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(s||ue.errorForCode(ie.Cancelled))}}const Bv="$JS.API";function Lv(r){return r=r||{},r.domain&&(r.apiPrefix=`$JS.${r.domain}.API`,delete r.domain),Yo({apiPrefix:Bv,timeout:5e3},r)}class Ga{constructor(n,s){v(this,"nc");v(this,"opts");v(this,"prefix");v(this,"timeout");v(this,"jc");this.nc=n,this.opts=Lv(s),this._parseOpts(),this.prefix=this.opts.apiPrefix,this.timeout=this.opts.timeout,this.jc=Mn()}getOptions(){return Object.assign({},this.opts)}_parseOpts(){let n=this.opts.apiPrefix;if(!n||n.length===0)throw new Error("invalid empty prefix");n[n.length-1]==="."&&(n=n.substr(0,n.length-1)),this.opts.apiPrefix=n}async _request(n,s=null,a){a=a||{},a.timeout=this.timeout;let o=nn;s&&(o=this.jc.encode(s));let{retries:f}=a;f=f||1,f=f===-1?Number.MAX_SAFE_INTEGER:f;const h=eh();for(let m=0;m<f;m++)try{const g=await this.nc.request(n,o,a);return this.parseJsResponse(g)}catch(g){const y=g;if((y.code==="503"||y.code===ie.Timeout)&&m+1<f)await Tr(h.backoff(m));else throw g}}async findStream(n){const s={subject:n},o=await this._request(`${this.prefix}.STREAM.NAMES`,s);if(!o.streams||o.streams.length!==1)throw new Error("no stream matches subject");return o.streams[0]}getConnection(){return this.nc}parseJsResponse(n){const s=this.jc.decode(n.data),a=s;if(a.error){const o=Sg(a.error.code,a.error.description);if(o!==null)throw o.api_error=a.error,o}return s}}class Ma{constructor(n,s,a,o){v(this,"err");v(this,"offset");v(this,"pageInfo");v(this,"subject");v(this,"jsm");v(this,"filter");v(this,"payload");if(!n)throw new Error("subject is required");this.subject=n,this.jsm=a,this.offset=0,this.pageInfo={},this.filter=s,this.payload=o||{}}async next(){if(this.err)return[];if(this.pageInfo&&this.offset>=this.pageInfo.total)return[];const n={offset:this.offset};this.payload&&Object.assign(n,this.payload);try{const s=await this.jsm._request(this.subject,n,{timeout:this.jsm.timeout});this.pageInfo=s;const a=this.countResponse(s);return a===0?[]:(this.offset+=a,this.filter(s))}catch(s){throw this.err=s,s}}countResponse(n){var s,a,o;switch(n==null?void 0:n.type){case"io.nats.jetstream.api.v1.stream_names_response":case"io.nats.jetstream.api.v1.stream_list_response":return((s=n.streams)==null?void 0:s.length)||0;case"io.nats.jetstream.api.v1.consumer_list_response":return((a=n.consumers)==null?void 0:a.length)||0;default:return console.error(`jslister.ts: unknown API response for paged output: ${n==null?void 0:n.type}`),((o=n.streams)==null?void 0:o.length)||0}return 0}async*[Symbol.asyncIterator](){let n=await this.next();for(;n.length>0;){for(const s of n)yield s;n=await this.next()}}}function ji(r=""){const n=r.match(/(\d+).(\d+).(\d+)/);if(n)return{major:parseInt(n[1]),minor:parseInt(n[2]),micro:parseInt(n[3])};throw new Error(`'${r}' is not a semver value`)}function Df(r,n){return r.major<n.major?-1:r.major>n.major?1:r.minor<n.minor?-1:r.minor>n.minor?1:r.micro<n.micro?-1:r.micro>n.micro?1:0}var Ue;(function(r){r.JS_KV="js_kv",r.JS_OBJECTSTORE="js_objectstore",r.JS_PULL_MAX_BYTES="js_pull_max_bytes",r.JS_NEW_CONSUMER_CREATE_API="js_new_consumer_create",r.JS_ALLOW_DIRECT="js_allow_direct",r.JS_MULTIPLE_CONSUMER_FILTER="js_multiple_consumer_filter",r.JS_SIMPLIFICATION="js_simplification",r.JS_STREAM_CONSUMER_METADATA="js_stream_consumer_metadata",r.JS_CONSUMER_FILTER_SUBJECTS="js_consumer_filter_subjects",r.JS_STREAM_FIRST_SEQ="js_stream_first_seq",r.JS_STREAM_SUBJECT_TRANSFORM="js_stream_subject_transform",r.JS_STREAM_SOURCE_SUBJECT_TRANSFORM="js_stream_source_subject_transform",r.JS_STREAM_COMPRESSION="js_stream_compression",r.JS_DEFAULT_CONSUMER_LIMITS="js_default_consumer_limits",r.JS_BATCH_DIRECT_GET="js_batch_direct_get"})(Ue||(Ue={}));class Hv{constructor(n){v(this,"server");v(this,"features");v(this,"disabled");this.features=new Map,this.disabled=[],this.update(n)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(n){this.disabled.push(n),this.update(this.server)}isDisabled(n){return this.disabled.indexOf(n)!==-1}update(n){typeof n=="string"&&(n=ji(n)),this.server=n,this.set(Ue.JS_KV,"2.6.2"),this.set(Ue.JS_OBJECTSTORE,"2.6.3"),this.set(Ue.JS_PULL_MAX_BYTES,"2.8.3"),this.set(Ue.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(Ue.JS_ALLOW_DIRECT,"2.9.0"),this.set(Ue.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(Ue.JS_SIMPLIFICATION,"2.9.4"),this.set(Ue.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(Ue.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(Ue.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(Ue.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ue.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ue.JS_STREAM_COMPRESSION,"2.10.0"),this.set(Ue.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.set(Ue.JS_BATCH_DIRECT_GET,"2.11.0"),this.disabled.forEach(s=>{this.features.delete(s)})}set(n,s){this.features.set(n,{min:s,ok:Df(this.server,ji(s))>=0})}get(n){return this.features.get(n)||{min:"unknown",ok:!1}}supports(n){var s;return((s=this.get(n))==null?void 0:s.ok)||!1}require(n){return typeof n=="string"&&(n=ji(n)),Df(this.server,n)>=0}}class zo extends Ga{constructor(n,s){super(n,s)}async add(n,s,a=Do.Create){if(Mt(n),s.deliver_group&&s.flow_control)throw new Error("jetstream flow control is not supported with queue groups");if(s.deliver_group&&s.idle_heartbeat)throw new Error("jetstream idle heartbeat is not supported with queue groups");const o={};o.config=s,o.stream_name=n,o.action=a,o.config.durable_name&&_r(o.config.durable_name);const f=this.nc;let{min:h,ok:m}=f.features.get(Ue.JS_NEW_CONSUMER_CREATE_API);const g=s.name===""?void 0:s.name;if(g&&!m)throw new Error(`consumer 'name' requires server ${h}`);if(g)try{Go("name",g)}catch(T){const q=T.message,M=q.indexOf("cannot contain");throw M!==-1?new Error(`consumer 'name' ${q.substring(M)}`):T}let y,E="";if(Array.isArray(s.filter_subjects)){const{min:T,ok:q}=f.features.get(Ue.JS_MULTIPLE_CONSUMER_FILTER);if(!q)throw new Error(`consumer 'filter_subjects' requires server ${T}`);m=!1}if(s.metadata){const{min:T,ok:q}=f.features.get(Ue.JS_STREAM_CONSUMER_METADATA);if(!q)throw new Error(`consumer 'metadata' requires server ${T}`)}if(m&&(E=s.name??s.durable_name??""),E!==""){let T=s.filter_subject??void 0;T===">"&&(T=void 0),y=T!==void 0?`${this.prefix}.CONSUMER.CREATE.${n}.${E}.${T}`:`${this.prefix}.CONSUMER.CREATE.${n}.${E}`}else y=s.durable_name?`${this.prefix}.CONSUMER.DURABLE.CREATE.${n}.${s.durable_name}`:`${this.prefix}.CONSUMER.CREATE.${n}`;return await this._request(y,o)}async update(n,s,a){const o=await this.info(n,s),f=a;return this.add(n,Object.assign(o.config,f),Do.Update)}async info(n,s){return Mt(n),_r(s),await this._request(`${this.prefix}.CONSUMER.INFO.${n}.${s}`)}async delete(n,s){return Mt(n),_r(s),(await this._request(`${this.prefix}.CONSUMER.DELETE.${n}.${s}`)).success}list(n){Mt(n);const s=o=>o.consumers,a=`${this.prefix}.CONSUMER.LIST.${n}`;return new Ma(a,s,this)}pause(n,s,a){const o=`${this.prefix}.CONSUMER.PAUSE.${n}.${s}`,f={pause_until:a.toISOString()};return this._request(o,f)}resume(n,s){return this.pause(n,s,new Date(0))}}function pr(r,n,s=!1){if(s===!0&&!r)throw ue.errorForCode(ie.ApiError,new Error(`${n} is not a function`));if(r&&typeof r!="function")throw ue.errorForCode(ie.ApiError,new Error(`${n} is not a function`))}class Pv extends _t{constructor(s,a,o){super();v(this,"sub");v(this,"adapter");v(this,"subIterDone");pr(o.adapter,"adapter",!0),this.adapter=o.adapter,o.callback&&pr(o.callback,"callback"),this.noIterator=typeof o.callback=="function",o.ingestionFilterFn&&(pr(o.ingestionFilterFn,"ingestionFilterFn"),this.ingestionFilterFn=o.ingestionFilterFn),o.protocolFilterFn&&(pr(o.protocolFilterFn,"protocolFilterFn"),this.protocolFilterFn=o.protocolFilterFn),o.dispatchedFn&&(pr(o.dispatchedFn,"dispatchedFn"),this.dispatchedFn=o.dispatchedFn),o.cleanupFn&&pr(o.cleanupFn,"cleanupFn");let f=(E,w)=>{this.callback(E,w)};if(o.callback){const E=o.callback;f=(w,T)=>{const[q,M]=this.adapter(w,T);if(q){E(q,null);return}const{ingest:D}=this.ingestionFilterFn?this.ingestionFilterFn(M,this):{ingest:!0};D&&(!this.protocolFilterFn||this.protocolFilterFn(M))&&(E(q,M),this.dispatchedFn&&M&&this.dispatchedFn(M))}}const{max:h,queue:m,timeout:g}=o,y={queue:m,timeout:g,callback:f};h&&h>0&&(y.max=h),this.sub=s.subscribe(a,y),o.cleanupFn&&(this.sub.cleanupFn=o.cleanupFn),this.noIterator||this.iterClosed.then(()=>{this.unsubscribe()}),this.subIterDone=st(),Promise.all([this.sub.closed,this.iterClosed]).then(()=>{this.subIterDone.resolve()}).catch(()=>{this.subIterDone.resolve()}),(async E=>{await E.closed,this.stop()})(this.sub).then().catch()}unsubscribe(s){this.sub.unsubscribe(s)}drain(){return this.sub.drain()}isDraining(){return this.sub.isDraining()}isClosed(){return this.sub.isClosed()}callback(s,a){this.sub.cancelTimeout();const[o,f]=this.adapter(s,a);o&&this.stop(o),f&&this.push(f)}getSubject(){return this.sub.getSubject()}getReceived(){return this.sub.getReceived()}getProcessed(){return this.sub.getProcessed()}getPending(){return this.sub.getPending()}getID(){return this.sub.getID()}getMax(){return this.sub.getMax()}get closed(){return this.sub.closed}}let tn;function $v(r){tn=r}function jg(){return tn!==void 0&&tn.defaultPort!==void 0?tn.defaultPort:4222}function df(){return tn!==void 0&&tn.urlParseFn?tn.urlParseFn:void 0}function Yv(){if(!tn||typeof tn.factory!="function")throw new Error("transport fn is not set");return tn.factory()}function zf(){return tn!==void 0&&tn.dnsResolveFn?tn.dnsResolveFn:void 0}const Eo=`\r
37
- `,qo=Or.fromAscii(Eo),Gv=new Uint8Array(qo)[0],Vv=new Uint8Array(qo)[1];function Fv(r){for(let n=0;n<r.length;n++){const s=n+1;if(r.byteLength>s&&r[n]===Gv&&r[s]===Vv)return s+1}return 0}function Jv(r){const n=Fv(r);if(n>0){const a=new Uint8Array(r).slice(0,n);return en.decode(a)}return""}const Iv=4,Og=48,Qv=65,Xv=97;function Kv(r,n,s,a){const o=new Uint8Array(16);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((h,m)=>{o[m]=h}),o[12]=r,o[13]=n,o[14]=s,o[15]=a,o}function qf(r){return Zv(r)!==void 0}function Zv(r){for(let n=0;n<r.length;n++)switch(r[n]){case".":return Tg(r);case":":return Wv(r)}}function Tg(r){const n=new Uint8Array(4);for(let s=0;s<4;s++){if(r.length===0)return;if(s>0){if(r[0]!==".")return;r=r.substring(1)}const{n:a,c:o,ok:f}=e1(r);if(!f||a>255)return;r=r.substring(o),n[s]=a}return Kv(n[0],n[1],n[2],n[3])}function Wv(r){const n=new Uint8Array(16);let s=-1;if(r.length>=2&&r[0]===":"&&r[1]===":"&&(s=0,r=r.substring(2),r.length===0))return n;let a=0;for(;a<16;){const{n:o,c:f,ok:h}=t1(r);if(!h||o>65535)return;if(f<r.length&&r[f]==="."){if(s<0&&a!=12||a+4>16)return;const m=Tg(r);if(m===void 0)return;n[a]=m[12],n[a+1]=m[13],n[a+2]=m[14],n[a+3]=m[15],r="",a+=Iv;break}if(n[a]=o>>8,n[a+1]=o,a+=2,r=r.substring(f),r.length===0)break;if(r[0]!==":"||r.length==1)return;if(r=r.substring(1),r[0]===":"){if(s>=0)return;if(s=a,r=r.substring(1),r.length===0)break}}if(r.length===0){if(a<16){if(s<0)return;const o=16-a;for(let f=a-1;f>=s;f--)n[f+o]=n[f];for(let f=s+o-1;f>=s;f--)n[f]=0}else if(s>=0)return;return n}}function e1(r){let n=0,s=0;for(n=0;n<r.length&&48<=r.charCodeAt(n)&&r.charCodeAt(n)<=57;n++)if(s=s*10+(r.charCodeAt(n)-Og),s>=16777215)return{n:16777215,c:n,ok:!1};return n===0?{n:0,c:0,ok:!1}:{n:s,c:n,ok:!0}}function t1(r){let n=0,s=0;for(s=0;s<r.length;s++){if(48<=r.charCodeAt(s)&&r.charCodeAt(s)<=57)n*=16,n+=r.charCodeAt(s)-Og;else if(97<=r.charCodeAt(s)&&r.charCodeAt(s)<=102)n*=16,n+=r.charCodeAt(s)-Xv+10;else if(65<=r.charCodeAt(s)&&r.charCodeAt(s)<=70)n*=16,n+=r.charCodeAt(s)-Qv+10;else break;if(n>=16777215)return{n:0,c:s,ok:!1}}return s===0?{n:0,c:s,ok:!1}:{n,c:s,ok:!0}}function n1(r){return r.indexOf("[")!==-1||r.indexOf("::")!==-1?!1:r.indexOf(".")!==-1||r.split(":").length<=2}function Uf(r){return!n1(r)}function s1(r){const n="::FFFF:",s=r.toUpperCase().indexOf(n);if(s!==-1&&r.indexOf(".")!==-1){let a=r.substring(s+n.length);return a=a.replace("[",""),a.replace("]","")}return r}function i1(r){r=r.trim(),r.match(/^(.*:\/\/)(.*)/m)&&(r=r.replace(/^(.*:\/\/)(.*)/gm,"$2")),r=s1(r),Uf(r)&&r.indexOf("[")===-1&&(r=`[${r}]`);const n=Uf(r)?r.match(/(]:)(\d+)/):r.match(/(:)(\d+)/),s=n&&n.length===3&&n[1]&&n[2]?parseInt(n[2]):4222,a=s===80?"https":"http",o=new URL(`${a}://${r}`);o.port=`${s}`;let f=o.hostname;return f.charAt(0)==="["&&(f=f.substring(1,f.length-1)),{listen:o.host,hostname:f,port:s}}class qa{constructor(n,s=!1){v(this,"src");v(this,"listen");v(this,"hostname");v(this,"port");v(this,"didConnect");v(this,"reconnects");v(this,"lastConnect");v(this,"gossiped");v(this,"tlsName");v(this,"resolves");this.src=n,this.tlsName="";const a=i1(n);this.listen=a.listen,this.hostname=a.hostname,this.port=a.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=s}toString(){return this.listen}async resolve(n){if(!n.fn||n.resolve===!1)return[this];const s=[];if(qf(this.hostname))return[this];{const a=await n.fn(this.hostname);n.debug&&console.log(`resolve ${this.hostname} = ${a.join(",")}`);for(const o of a){const f=this.port===80?"https":"http",h=new URL(`${f}://${Uf(o)?"["+o+"]":o}`);h.port=`${this.port}`;const m=new qa(h.host,!1);m.tlsName=this.hostname,s.push(m)}}return n.randomize&&_g(s),this.resolves=s,s}}class r1{constructor(n=[],s={}){v(this,"firstSelect");v(this,"servers");v(this,"currentServer");v(this,"tlsName");v(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=s.randomize||!1;const a=df();n&&(n.forEach(o=>{o=a?a(o):o,this.servers.push(new qa(o))}),this.randomize&&(this.servers=_g(this.servers))),this.servers.length===0&&this.addServer(`${Of}:${jg()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const n=this.getCurrentServer();qf(n.hostname)||(this.tlsName=n.hostname,this.servers.forEach(s=>{s.gossiped&&(s.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(n,s=!1){const a=df();n=a?a(n):n;const o=new qa(n,s);qf(o.hostname)&&(o.tlsName=this.tlsName),this.servers.push(o)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;const n=this.servers.shift();return n&&(this.servers.push(n),this.currentServer=n),n}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer(n){if(n){const s=this.servers.indexOf(n);this.servers.splice(s,1)}}length(){return this.servers.length}next(){return this.servers.length?this.servers[0]:void 0}getServers(){return this.servers}update(n,s){const a=[];let o=[];const f=df(),h=new Map;n.connect_urls&&n.connect_urls.length>0&&n.connect_urls.forEach(g=>{g=f?f(g,s):g;const y=new qa(g,!0);h.set(g,y)});const m=[];return this.servers.forEach((g,y)=>{const E=g.listen;g.gossiped&&this.currentServer.listen!==E&&h.get(E)===void 0&&m.push(y),h.delete(E)}),m.reverse(),m.forEach(g=>{const y=this.servers.splice(g,1);o=o.concat(y[0].listen)}),h.forEach((g,y)=>{this.servers.push(g),a.push(y)}),{added:a,deleted:o}}}class a1{constructor(){v(this,"baseInbox");v(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(n){return this.baseInbox=`${fs(n)}.`,this.baseInbox}add(n){isNaN(n.received)||(n.received=0),this.reqs.set(n.token,n)}get(n){return this.reqs.get(n)}cancel(n){this.reqs.delete(n.token)}getToken(n){const s=n.subject||"";return s.indexOf(this.baseInbox)===0?s.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(n,s){if(s&&s.permissionContext){if(n)return this.all().forEach(o=>{o.resolver(s,{})}),!0;const a=s.permissionContext;if(a.operation==="publish"){const o=this.all().find(f=>f.requestSubject===a.subject);if(o)return o.resolver(s,{}),!0}}return!1}dispatcher(){return(n,s)=>{const a=this.getToken(s);if(a){const o=this.get(a);o&&(n===null&&s.headers&&(n=wg(s)),o.resolver(n,s))}}}close(){const n=ue.errorForCode(ie.Timeout);this.reqs.forEach(s=>{s.resolver(n,{})})}}class l1{constructor(n,s,a){v(this,"ph");v(this,"interval");v(this,"maxOut");v(this,"timer");v(this,"pendings");this.ph=n,this.interval=s,this.maxOut=a,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(n){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),n&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:vr.PingTimer,data:`${this.pendings.length+1}`}),this.pendings.length===this.maxOut){this.cancel(!0);return}const n=st();this.ph.flush(n).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push(n),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(n=>(n.resolve(),!1))}}class o1 extends Error{constructor(n){super(n),this.name="AssertionError"}}function c1(r,n="Assertion failed."){if(!r)throw new o1(n)}const j0=32*1024,mf=2**32-2;function yo(r,n,s=0){const a=n.byteLength-s;return r.byteLength>a&&(r=r.subarray(0,a)),n.set(r,s),r.byteLength}class pf{constructor(n){v(this,"_buf");v(this,"_off");if(this._off=0,n==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array(n)}bytes(n={copy:!0}){return n.copy===!1?this._buf.subarray(this._off):this._buf.slice(this._off)}empty(){return this._buf.byteLength<=this._off}get length(){return this._buf.byteLength-this._off}get capacity(){return this._buf.buffer.byteLength}truncate(n){if(n===0){this.reset();return}if(n<0||n>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+n)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(n){const s=this._buf.byteLength;return n<=this.capacity-s?(this._reslice(s+n),s):-1}_reslice(n){c1(n<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,n)}readByte(){const n=new Uint8Array(1);return this.read(n)?n[0]:null}read(n){if(this.empty())return this.reset(),n.byteLength===0?0:null;const s=yo(this._buf.subarray(this._off),n);return this._off+=s,s}writeByte(n){return this.write(Uint8Array.of(n))}writeString(n){return this.write(Ti.encode(n))}write(n){const s=this._grow(n.byteLength);return yo(n,this._buf,s)}_grow(n){const s=this.length;s===0&&this._off!==0&&this.reset();const a=this._tryGrowByReslice(n);if(a>=0)return a;const o=this.capacity;if(n<=Math.floor(o/2)-s)yo(this._buf.subarray(this._off),this._buf);else{if(o+n>mf)throw new Error("The buffer cannot be grown beyond the maximum size.");{const f=new Uint8Array(Math.min(2*o+n,mf));yo(this._buf.subarray(this._off),f),this._buf=f}}return this._off=0,this._reslice(Math.min(s+n,mf)),s}grow(n){if(n<0)throw Error("Buffer._grow: negative count");const s=this._grow(n);this._reslice(s)}readFrom(n){let s=0;const a=new Uint8Array(j0);for(;;){const o=this.capacity-this.length<j0,f=o?a:new Uint8Array(this._buf.buffer,this.length),h=n.read(f);if(h===null)return s;o?this.write(f.subarray(0,h)):this._reslice(this.length+h),s+=h}}}var Rt;(function(r){r[r.OK=0]="OK",r[r.ERR=1]="ERR",r[r.MSG=2]="MSG",r[r.INFO=3]="INFO",r[r.PING=4]="PING",r[r.PONG=5]="PONG"})(Rt||(Rt={}));function O0(){const r={};return r.sid=-1,r.hdr=-1,r.size=-1,r}const u1=48;class T0{constructor(n){v(this,"dispatcher");v(this,"state");v(this,"as");v(this,"drop");v(this,"hdr");v(this,"ma");v(this,"argBuf");v(this,"msgBuf");this.dispatcher=n,this.state=le.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(n){let s;for(s=0;s<n.length;s++){const a=n[s];switch(this.state){case le.OP_START:switch(a){case oe.M:case oe.m:this.state=le.OP_M,this.hdr=-1,this.ma=O0();break;case oe.H:case oe.h:this.state=le.OP_H,this.hdr=0,this.ma=O0();break;case oe.P:case oe.p:this.state=le.OP_P;break;case oe.PLUS:this.state=le.OP_PLUS;break;case oe.MINUS:this.state=le.OP_MINUS;break;case oe.I:case oe.i:this.state=le.OP_I;break;default:throw this.fail(n.subarray(s))}break;case le.OP_H:switch(a){case oe.M:case oe.m:this.state=le.OP_M;break;default:throw this.fail(n.subarray(s))}break;case le.OP_M:switch(a){case oe.S:case oe.s:this.state=le.OP_MS;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MS:switch(a){case oe.G:case oe.g:this.state=le.OP_MSG;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MSG:switch(a){case oe.SPACE:case oe.TAB:this.state=le.OP_MSG_SPC;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MSG_SPC:switch(a){case oe.SPACE:case oe.TAB:continue;default:this.state=le.MSG_ARG,this.as=s}break;case le.MSG_ARG:switch(a){case oe.CR:this.drop=1;break;case oe.NL:{const o=this.argBuf?this.argBuf.bytes():n.subarray(this.as,s-this.drop);this.processMsgArgs(o),this.drop=0,this.as=s+1,this.state=le.MSG_PAYLOAD,s=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(a)}break;case le.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const o=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Rt.MSG,msg:this.ma,data:o}),this.argBuf=void 0,this.msgBuf=void 0,this.state=le.MSG_END}else{let o=this.ma.size-this.msgBuf.length;const f=n.length-s;f<o&&(o=f),o>0?(this.msgBuf.write(n.subarray(s,s+o)),s=s+o-1):this.msgBuf.writeByte(a)}else s-this.as>=this.ma.size&&(this.dispatcher.push({kind:Rt.MSG,msg:this.ma,data:n.subarray(this.as,s)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=le.MSG_END);break;case le.MSG_END:switch(a){case oe.NL:this.drop=0,this.as=s+1,this.state=le.OP_START;break;default:continue}break;case le.OP_PLUS:switch(a){case oe.O:case oe.o:this.state=le.OP_PLUS_O;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PLUS_O:switch(a){case oe.K:case oe.k:this.state=le.OP_PLUS_OK;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PLUS_OK:switch(a){case oe.NL:this.dispatcher.push({kind:Rt.OK}),this.drop=0,this.state=le.OP_START;break}break;case le.OP_MINUS:switch(a){case oe.E:case oe.e:this.state=le.OP_MINUS_E;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MINUS_E:switch(a){case oe.R:case oe.r:this.state=le.OP_MINUS_ER;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MINUS_ER:switch(a){case oe.R:case oe.r:this.state=le.OP_MINUS_ERR;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MINUS_ERR:switch(a){case oe.SPACE:case oe.TAB:this.state=le.OP_MINUS_ERR_SPC;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MINUS_ERR_SPC:switch(a){case oe.SPACE:case oe.TAB:continue;default:this.state=le.MINUS_ERR_ARG,this.as=s}break;case le.MINUS_ERR_ARG:switch(a){case oe.CR:this.drop=1;break;case oe.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=n.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Rt.ERR,data:o}),this.drop=0,this.as=s+1,this.state=le.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(a))}break;case le.OP_P:switch(a){case oe.I:case oe.i:this.state=le.OP_PI;break;case oe.O:case oe.o:this.state=le.OP_PO;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PO:switch(a){case oe.N:case oe.n:this.state=le.OP_PON;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PON:switch(a){case oe.G:case oe.g:this.state=le.OP_PONG;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PONG:switch(a){case oe.NL:this.dispatcher.push({kind:Rt.PONG}),this.drop=0,this.state=le.OP_START;break}break;case le.OP_PI:switch(a){case oe.N:case oe.n:this.state=le.OP_PIN;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PIN:switch(a){case oe.G:case oe.g:this.state=le.OP_PING;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PING:switch(a){case oe.NL:this.dispatcher.push({kind:Rt.PING}),this.drop=0,this.state=le.OP_START;break}break;case le.OP_I:switch(a){case oe.N:case oe.n:this.state=le.OP_IN;break;default:throw this.fail(n.subarray(s))}break;case le.OP_IN:switch(a){case oe.F:case oe.f:this.state=le.OP_INF;break;default:throw this.fail(n.subarray(s))}break;case le.OP_INF:switch(a){case oe.O:case oe.o:this.state=le.OP_INFO;break;default:throw this.fail(n.subarray(s))}break;case le.OP_INFO:switch(a){case oe.SPACE:case oe.TAB:this.state=le.OP_INFO_SPC;break;default:throw this.fail(n.subarray(s))}break;case le.OP_INFO_SPC:switch(a){case oe.SPACE:case oe.TAB:continue;default:this.state=le.INFO_ARG,this.as=s}break;case le.INFO_ARG:switch(a){case oe.CR:this.drop=1;break;case oe.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=n.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Rt.INFO,data:o}),this.drop=0,this.as=s+1,this.state=le.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(a)}break;default:throw this.fail(n.subarray(s))}}(this.state===le.MSG_ARG||this.state===le.MINUS_ERR_ARG||this.state===le.INFO_ARG)&&!this.argBuf&&(this.argBuf=new pf(n.subarray(this.as,s-this.drop))),this.state===le.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new pf(n.subarray(this.as)))}cloneMsgArg(){const n=this.ma.subject.length,s=this.ma.reply?this.ma.reply.length:0,a=new Uint8Array(n+s);a.set(this.ma.subject),this.ma.reply&&a.set(this.ma.reply,n),this.argBuf=new pf(a),this.ma.subject=a.subarray(0,n),this.ma.reply&&(this.ma.reply=a.subarray(n))}processMsgArgs(n){if(this.hdr>=0)return this.processHeaderMsgArgs(n);const s=[];let a=-1;for(let o=0;o<n.length;o++)switch(n[o]){case oe.SPACE:case oe.TAB:case oe.CR:case oe.NL:a>=0&&(s.push(n.subarray(a,o)),a=-1);break;default:a<0&&(a=o)}switch(a>=0&&s.push(n.subarray(a)),s.length){case 3:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(s[2]);break;case 4:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=s[2],this.ma.size=this.protoParseInt(s[3]);break;default:throw this.fail(n,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(n,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(n,"processMsgArgs Bad or Missing Size Error")}fail(n,s=""){return s?s=`${s} [${this.state}]`:s=`parse error [${this.state}]`,new Error(`${s}: ${en.decode(n)}`)}processHeaderMsgArgs(n){const s=[];let a=-1;for(let o=0;o<n.length;o++)switch(n[o]){case oe.SPACE:case oe.TAB:case oe.CR:case oe.NL:a>=0&&(s.push(n.subarray(a,o)),a=-1);break;default:a<0&&(a=o)}switch(a>=0&&s.push(n.subarray(a)),s.length){case 4:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(s[2]),this.ma.size=this.protoParseInt(s[3]);break;case 5:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=s[2],this.ma.hdr=this.protoParseInt(s[3]),this.ma.size=this.protoParseInt(s[4]);break;default:throw this.fail(n,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(n,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(n,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(n,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(n){if(n.length===0)return-1;let s=0;for(let a=0;a<n.length;a++){if(n[a]<48||n[a]>57)return-1;s=s*10+(n[a]-u1)}return s}}var le;(function(r){r[r.OP_START=0]="OP_START",r[r.OP_PLUS=1]="OP_PLUS",r[r.OP_PLUS_O=2]="OP_PLUS_O",r[r.OP_PLUS_OK=3]="OP_PLUS_OK",r[r.OP_MINUS=4]="OP_MINUS",r[r.OP_MINUS_E=5]="OP_MINUS_E",r[r.OP_MINUS_ER=6]="OP_MINUS_ER",r[r.OP_MINUS_ERR=7]="OP_MINUS_ERR",r[r.OP_MINUS_ERR_SPC=8]="OP_MINUS_ERR_SPC",r[r.MINUS_ERR_ARG=9]="MINUS_ERR_ARG",r[r.OP_M=10]="OP_M",r[r.OP_MS=11]="OP_MS",r[r.OP_MSG=12]="OP_MSG",r[r.OP_MSG_SPC=13]="OP_MSG_SPC",r[r.MSG_ARG=14]="MSG_ARG",r[r.MSG_PAYLOAD=15]="MSG_PAYLOAD",r[r.MSG_END=16]="MSG_END",r[r.OP_H=17]="OP_H",r[r.OP_P=18]="OP_P",r[r.OP_PI=19]="OP_PI",r[r.OP_PIN=20]="OP_PIN",r[r.OP_PING=21]="OP_PING",r[r.OP_PO=22]="OP_PO",r[r.OP_PON=23]="OP_PON",r[r.OP_PONG=24]="OP_PONG",r[r.OP_I=25]="OP_I",r[r.OP_IN=26]="OP_IN",r[r.OP_INF=27]="OP_INF",r[r.OP_INFO=28]="OP_INFO",r[r.OP_INFO_SPC=29]="OP_INFO_SPC",r[r.INFO_ARG=30]="INFO_ARG"})(le||(le={}));var oe;(function(r){r[r.CR=13]="CR",r[r.E=69]="E",r[r.e=101]="e",r[r.F=70]="F",r[r.f=102]="f",r[r.G=71]="G",r[r.g=103]="g",r[r.H=72]="H",r[r.h=104]="h",r[r.I=73]="I",r[r.i=105]="i",r[r.K=75]="K",r[r.k=107]="k",r[r.M=77]="M",r[r.m=109]="m",r[r.MINUS=45]="MINUS",r[r.N=78]="N",r[r.n=110]="n",r[r.NL=10]="NL",r[r.O=79]="O",r[r.o=111]="o",r[r.P=80]="P",r[r.p=112]="p",r[r.PLUS=43]="PLUS",r[r.R=82]="R",r[r.r=114]="r",r[r.S=83]="S",r[r.s=115]="s",r[r.SPACE=32]="SPACE",r[r.TAB=9]="TAB"})(oe||(oe={}));(function(r){var n=function(x,S){this.hi=x|0,this.lo=S|0},s=function(x){var S,_=new Float64Array(16);if(x)for(S=0;S<x.length;S++)_[S]=x[S];return _},a=function(){throw new Error("no PRNG")},o=new Uint8Array(16),f=new Uint8Array(32);f[0]=9;var h=s(),m=s([1]),g=s([56129,1]),y=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),E=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),w=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),T=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),q=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function M(x,S){return x<<S|x>>>32-S}function D(x,S){var _=x[S+3]&255;return _=_<<8|x[S+2]&255,_=_<<8|x[S+1]&255,_<<8|x[S+0]&255}function W(x,S){var _=x[S]<<24|x[S+1]<<16|x[S+2]<<8|x[S+3],A=x[S+4]<<24|x[S+5]<<16|x[S+6]<<8|x[S+7];return new n(_,A)}function se(x,S,_){var A;for(A=0;A<4;A++)x[S+A]=_&255,_>>>=8}function ee(x,S,_){x[S]=_.hi>>24&255,x[S+1]=_.hi>>16&255,x[S+2]=_.hi>>8&255,x[S+3]=_.hi&255,x[S+4]=_.lo>>24&255,x[S+5]=_.lo>>16&255,x[S+6]=_.lo>>8&255,x[S+7]=_.lo&255}function me(x,S,_,A,N){var z,I=0;for(z=0;z<N;z++)I|=x[S+z]^_[A+z];return(1&I-1>>>8)-1}function re(x,S,_,A){return me(x,S,_,A,16)}function C(x,S,_,A){return me(x,S,_,A,32)}function X(x,S,_,A,N){var z=new Uint32Array(16),I=new Uint32Array(16),Z=new Uint32Array(16),H=new Uint32Array(4),J,fe,je;for(J=0;J<4;J++)I[5*J]=D(A,4*J),I[1+J]=D(_,4*J),I[6+J]=D(S,4*J),I[11+J]=D(_,16+4*J);for(J=0;J<16;J++)Z[J]=I[J];for(J=0;J<20;J++){for(fe=0;fe<4;fe++){for(je=0;je<4;je++)H[je]=I[(5*fe+4*je)%16];for(H[1]^=M(H[0]+H[3]|0,7),H[2]^=M(H[1]+H[0]|0,9),H[3]^=M(H[2]+H[1]|0,13),H[0]^=M(H[3]+H[2]|0,18),je=0;je<4;je++)z[4*fe+(fe+je)%4]=H[je]}for(je=0;je<16;je++)I[je]=z[je]}if(N){for(J=0;J<16;J++)I[J]=I[J]+Z[J]|0;for(J=0;J<4;J++)I[5*J]=I[5*J]-D(A,4*J)|0,I[6+J]=I[6+J]-D(S,4*J)|0;for(J=0;J<4;J++)se(x,4*J,I[5*J]),se(x,16+4*J,I[6+J])}else for(J=0;J<16;J++)se(x,4*J,I[J]+Z[J]|0)}function ce(x,S,_,A){return X(x,S,_,A,!1),0}function V(x,S,_,A){return X(x,S,_,A,!0),0}var G=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function K(x,S,_,A,N,z,I){var Z=new Uint8Array(16),H=new Uint8Array(64),J,fe;if(!N)return 0;for(fe=0;fe<16;fe++)Z[fe]=0;for(fe=0;fe<8;fe++)Z[fe]=z[fe];for(;N>=64;){for(ce(H,Z,I,G),fe=0;fe<64;fe++)x[S+fe]=(_?_[A+fe]:0)^H[fe];for(J=1,fe=8;fe<16;fe++)J=J+(Z[fe]&255)|0,Z[fe]=J&255,J>>>=8;N-=64,S+=64,_&&(A+=64)}if(N>0)for(ce(H,Z,I,G),fe=0;fe<N;fe++)x[S+fe]=(_?_[A+fe]:0)^H[fe];return 0}function ae(x,S,_,A,N){return K(x,S,null,0,_,A,N)}function ne(x,S,_,A,N){var z=new Uint8Array(32);return V(z,A,N,G),ae(x,S,_,A.subarray(16),z)}function ke(x,S,_,A,N,z,I){var Z=new Uint8Array(32);return V(Z,z,I,G),K(x,S,_,A,N,z.subarray(16),Z)}function He(x,S){var _,A=0;for(_=0;_<17;_++)A=A+(x[_]+S[_]|0)|0,x[_]=A&255,A>>>=8}var Me=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function $(x,S,_,A,N,z){var I,Z,H,J,fe=new Uint32Array(17),je=new Uint32Array(17),Ke=new Uint32Array(17),Ct=new Uint32Array(17),An=new Uint32Array(17);for(H=0;H<17;H++)je[H]=Ke[H]=0;for(H=0;H<16;H++)je[H]=z[H];for(je[3]&=15,je[4]&=252,je[7]&=15,je[8]&=252,je[11]&=15,je[12]&=252,je[15]&=15;N>0;){for(H=0;H<17;H++)Ct[H]=0;for(H=0;H<16&&H<N;++H)Ct[H]=_[A+H];for(Ct[H]=1,A+=H,N-=H,He(Ke,Ct),Z=0;Z<17;Z++)for(fe[Z]=0,H=0;H<17;H++)fe[Z]=fe[Z]+Ke[H]*(H<=Z?je[Z-H]:320*je[Z+17-H]|0)|0|0;for(Z=0;Z<17;Z++)Ke[Z]=fe[Z];for(J=0,H=0;H<16;H++)J=J+Ke[H]|0,Ke[H]=J&255,J>>>=8;for(J=J+Ke[16]|0,Ke[16]=J&3,J=5*(J>>>2)|0,H=0;H<16;H++)J=J+Ke[H]|0,Ke[H]=J&255,J>>>=8;J=J+Ke[16]|0,Ke[16]=J}for(H=0;H<17;H++)An[H]=Ke[H];for(He(Ke,Me),I=-(Ke[16]>>>7)|0,H=0;H<17;H++)Ke[H]^=I&(An[H]^Ke[H]);for(H=0;H<16;H++)Ct[H]=z[H+16];for(Ct[16]=0,He(Ke,Ct),H=0;H<16;H++)x[S+H]=Ke[H];return 0}function te(x,S,_,A,N,z){var I=new Uint8Array(16);return $(I,0,_,A,N,z),re(x,S,I,0)}function de(x,S,_,A,N){var z;if(_<32)return-1;for(ke(x,0,S,0,_,A,N),$(x,16,x,32,_-32,x),z=0;z<16;z++)x[z]=0;return 0}function _e(x,S,_,A,N){var z,I=new Uint8Array(32);if(_<32||(ne(I,0,32,A,N),te(S,16,S,32,_-32,I)!==0))return-1;for(ke(x,0,S,0,_,A,N),z=0;z<32;z++)x[z]=0;return 0}function be(x,S){var _;for(_=0;_<16;_++)x[_]=S[_]|0}function Oe(x){var S,_;for(_=0;_<16;_++)x[_]+=65536,S=Math.floor(x[_]/65536),x[(_+1)*(_<15?1:0)]+=S-1+37*(S-1)*(_===15?1:0),x[_]-=S*65536}function we(x,S,_){for(var A,N=~(_-1),z=0;z<16;z++)A=N&(x[z]^S[z]),x[z]^=A,S[z]^=A}function Te(x,S){var _,A,N,z=s(),I=s();for(_=0;_<16;_++)I[_]=S[_];for(Oe(I),Oe(I),Oe(I),A=0;A<2;A++){for(z[0]=I[0]-65517,_=1;_<15;_++)z[_]=I[_]-65535-(z[_-1]>>16&1),z[_-1]&=65535;z[15]=I[15]-32767-(z[14]>>16&1),N=z[15]>>16&1,z[14]&=65535,we(I,z,1-N)}for(_=0;_<16;_++)x[2*_]=I[_]&255,x[2*_+1]=I[_]>>8}function lt(x,S){var _=new Uint8Array(32),A=new Uint8Array(32);return Te(_,x),Te(A,S),C(_,0,A,0)}function Pt(x){var S=new Uint8Array(32);return Te(S,x),S[0]&1}function an(x,S){var _;for(_=0;_<16;_++)x[_]=S[2*_]+(S[2*_+1]<<8);x[15]&=32767}function jt(x,S,_){var A;for(A=0;A<16;A++)x[A]=S[A]+_[A]|0}function Ot(x,S,_){var A;for(A=0;A<16;A++)x[A]=S[A]-_[A]|0}function Se(x,S,_){var A,N,z=new Float64Array(31);for(A=0;A<31;A++)z[A]=0;for(A=0;A<16;A++)for(N=0;N<16;N++)z[A+N]+=S[A]*_[N];for(A=0;A<15;A++)z[A]+=38*z[A+16];for(A=0;A<16;A++)x[A]=z[A];Oe(x),Oe(x)}function Tt(x,S){Se(x,S,S)}function ti(x,S){var _=s(),A;for(A=0;A<16;A++)_[A]=S[A];for(A=253;A>=0;A--)Tt(_,_),A!==2&&A!==4&&Se(_,_,S);for(A=0;A<16;A++)x[A]=_[A]}function Ni(x,S){var _=s(),A;for(A=0;A<16;A++)_[A]=S[A];for(A=250;A>=0;A--)Tt(_,_),A!==1&&Se(_,_,S);for(A=0;A<16;A++)x[A]=_[A]}function ni(x,S,_){var A=new Uint8Array(32),N=new Float64Array(80),z,I,Z=s(),H=s(),J=s(),fe=s(),je=s(),Ke=s();for(I=0;I<31;I++)A[I]=S[I];for(A[31]=S[31]&127|64,A[0]&=248,an(N,_),I=0;I<16;I++)H[I]=N[I],fe[I]=Z[I]=J[I]=0;for(Z[0]=fe[0]=1,I=254;I>=0;--I)z=A[I>>>3]>>>(I&7)&1,we(Z,H,z),we(J,fe,z),jt(je,Z,J),Ot(Z,Z,J),jt(J,H,fe),Ot(H,H,fe),Tt(fe,je),Tt(Ke,Z),Se(Z,J,Z),Se(J,H,je),jt(je,Z,J),Ot(Z,Z,J),Tt(H,Z),Ot(J,fe,Ke),Se(Z,J,g),jt(Z,Z,fe),Se(J,J,Z),Se(Z,fe,Ke),Se(fe,H,N),Tt(H,je),we(Z,H,z),we(J,fe,z);for(I=0;I<16;I++)N[I+16]=Z[I],N[I+32]=J[I],N[I+48]=H[I],N[I+64]=fe[I];var Ct=N.subarray(32),An=N.subarray(16);return ti(Ct,Ct),Se(An,An,Ct),Te(x,An),0}function ln(x,S){return ni(x,S,f)}function Ci(x,S){return a(S,32),ln(x,S)}function ms(x,S,_){var A=new Uint8Array(32);return ni(A,_,S),V(x,o,A,G)}var Ia=de,Qa=_e;function Cr(x,S,_,A,N,z){var I=new Uint8Array(32);return ms(I,N,z),Ia(x,S,_,A,I)}function kr(x,S,_,A,N,z){var I=new Uint8Array(32);return ms(I,N,z),Qa(x,S,_,A,I)}function Yn(){var x=0,S=0,_=0,A=0,N=65535,z,I,Z;for(Z=0;Z<arguments.length;Z++)z=arguments[Z].lo,I=arguments[Z].hi,x+=z&N,S+=z>>>16,_+=I&N,A+=I>>>16;return S+=x>>>16,_+=S>>>16,A+=_>>>16,new n(_&N|A<<16,x&N|S<<16)}function Xa(x,S){return new n(x.hi>>>S,x.lo>>>S|x.hi<<32-S)}function ki(){var x=0,S=0,_;for(_=0;_<arguments.length;_++)x^=arguments[_].lo,S^=arguments[_].hi;return new n(S,x)}function et(x,S){var _,A,N=32-S;return S<32?(_=x.hi>>>S|x.lo<<N,A=x.lo>>>S|x.hi<<N):S<64&&(_=x.lo>>>S|x.hi<<N,A=x.hi>>>S|x.lo<<N),new n(_,A)}function Xo(x,S,_){var A=x.hi&S.hi^~x.hi&_.hi,N=x.lo&S.lo^~x.lo&_.lo;return new n(A,N)}function Ka(x,S,_){var A=x.hi&S.hi^x.hi&_.hi^S.hi&_.hi,N=x.lo&S.lo^x.lo&_.lo^S.lo&_.lo;return new n(A,N)}function Za(x){return ki(et(x,28),et(x,34),et(x,39))}function Mi(x){return ki(et(x,14),et(x,18),et(x,41))}function Ko(x){return ki(et(x,1),et(x,8),Xa(x,7))}function Wa(x){return ki(et(x,19),et(x,61),Xa(x,6))}var Zo=[new n(1116352408,3609767458),new n(1899447441,602891725),new n(3049323471,3964484399),new n(3921009573,2173295548),new n(961987163,4081628472),new n(1508970993,3053834265),new n(2453635748,2937671579),new n(2870763221,3664609560),new n(3624381080,2734883394),new n(310598401,1164996542),new n(607225278,1323610764),new n(1426881987,3590304994),new n(1925078388,4068182383),new n(2162078206,991336113),new n(2614888103,633803317),new n(3248222580,3479774868),new n(3835390401,2666613458),new n(4022224774,944711139),new n(264347078,2341262773),new n(604807628,2007800933),new n(770255983,1495990901),new n(1249150122,1856431235),new n(1555081692,3175218132),new n(1996064986,2198950837),new n(2554220882,3999719339),new n(2821834349,766784016),new n(2952996808,2566594879),new n(3210313671,3203337956),new n(3336571891,1034457026),new n(3584528711,2466948901),new n(113926993,3758326383),new n(338241895,168717936),new n(666307205,1188179964),new n(773529912,1546045734),new n(1294757372,1522805485),new n(1396182291,2643833823),new n(1695183700,2343527390),new n(1986661051,1014477480),new n(2177026350,1206759142),new n(2456956037,344077627),new n(2730485921,1290863460),new n(2820302411,3158454273),new n(3259730800,3505952657),new n(3345764771,106217008),new n(3516065817,3606008344),new n(3600352804,1432725776),new n(4094571909,1467031594),new n(275423344,851169720),new n(430227734,3100823752),new n(506948616,1363258195),new n(659060556,3750685593),new n(883997877,3785050280),new n(958139571,3318307427),new n(1322822218,3812723403),new n(1537002063,2003034995),new n(1747873779,3602036899),new n(1955562222,1575990012),new n(2024104815,1125592928),new n(2227730452,2716904306),new n(2361852424,442776044),new n(2428436474,593698344),new n(2756734187,3733110249),new n(3204031479,2999351573),new n(3329325298,3815920427),new n(3391569614,3928383900),new n(3515267271,566280711),new n(3940187606,3454069534),new n(4118630271,4000239992),new n(116418474,1914138554),new n(174292421,2731055270),new n(289380356,3203993006),new n(460393269,320620315),new n(685471733,587496836),new n(852142971,1086792851),new n(1017036298,365543100),new n(1126000580,2618297676),new n(1288033470,3409855158),new n(1501505948,4234509866),new n(1607167915,987167468),new n(1816402316,1246189591)];function el(x,S,_){var A=[],N=[],z=[],I=[],Z,H,J;for(H=0;H<8;H++)A[H]=z[H]=W(x,8*H);for(var fe=0;_>=128;){for(H=0;H<16;H++)I[H]=W(S,8*H+fe);for(H=0;H<80;H++){for(J=0;J<8;J++)N[J]=z[J];for(Z=Yn(z[7],Mi(z[4]),Xo(z[4],z[5],z[6]),Zo[H],I[H%16]),N[7]=Yn(Z,Za(z[0]),Ka(z[0],z[1],z[2])),N[3]=Yn(N[3],Z),J=0;J<8;J++)z[(J+1)%8]=N[J];if(H%16===15)for(J=0;J<16;J++)I[J]=Yn(I[J],I[(J+9)%16],Ko(I[(J+1)%16]),Wa(I[(J+14)%16]))}for(H=0;H<8;H++)z[H]=Yn(z[H],A[H]),A[H]=z[H];fe+=128,_-=128}for(H=0;H<8;H++)ee(x,8*H,A[H]);return _}var si=new Uint8Array([106,9,230,103,243,188,201,8,187,103,174,133,132,202,167,59,60,110,243,114,254,148,248,43,165,79,245,58,95,29,54,241,81,14,82,127,173,230,130,209,155,5,104,140,43,62,108,31,31,131,217,171,251,65,189,107,91,224,205,25,19,126,33,121]);function ot(x,S,_){var A=new Uint8Array(64),N=new Uint8Array(256),z,I=_;for(z=0;z<64;z++)A[z]=si[z];for(el(A,S,_),_%=128,z=0;z<256;z++)N[z]=0;for(z=0;z<_;z++)N[z]=S[I-_+z];for(N[_]=128,_=256-128*(_<112?1:0),N[_-9]=0,ee(N,_-8,new n(I/536870912|0,I<<3)),el(A,N,_),z=0;z<64;z++)x[z]=A[z];return 0}function $t(x,S){var _=s(),A=s(),N=s(),z=s(),I=s(),Z=s(),H=s(),J=s(),fe=s();Ot(_,x[1],x[0]),Ot(fe,S[1],S[0]),Se(_,_,fe),jt(A,x[0],x[1]),jt(fe,S[0],S[1]),Se(A,A,fe),Se(N,x[3],S[3]),Se(N,N,E),Se(z,x[2],S[2]),jt(z,z,z),Ot(I,A,_),Ot(Z,z,N),jt(H,z,N),jt(J,A,_),Se(x[0],I,Z),Se(x[1],J,H),Se(x[2],H,Z),Se(x[3],I,J)}function Nt(x,S,_){var A;for(A=0;A<4;A++)we(x[A],S[A],_)}function Mr(x,S){var _=s(),A=s(),N=s();ti(N,S[2]),Se(_,S[0],N),Se(A,S[1],N),Te(x,A),x[31]^=Pt(_)<<7}function Rr(x,S,_){var A,N;for(be(x[0],h),be(x[1],m),be(x[2],m),be(x[3],h),N=255;N>=0;--N)A=_[N/8|0]>>(N&7)&1,Nt(x,S,A),$t(S,x),$t(x,x),Nt(x,S,A)}function Ri(x,S){var _=[s(),s(),s(),s()];be(_[0],w),be(_[1],T),be(_[2],m),Se(_[3],w,T),Rr(x,_,S)}function ps(x,S,_){var A=new Uint8Array(64),N=[s(),s(),s(),s()],z;for(_||a(S,32),ot(A,S,32),A[0]&=248,A[31]&=127,A[31]|=64,Ri(N,A),Mr(x,N),z=0;z<32;z++)S[z+32]=x[z];return 0}var Gn=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function gs(x,S){var _,A,N,z;for(A=63;A>=32;--A){for(_=0,N=A-32,z=A-12;N<z;++N)S[N]+=_-16*S[A]*Gn[N-(A-32)],_=Math.floor((S[N]+128)/256),S[N]-=_*256;S[N]+=_,S[A]=0}for(_=0,N=0;N<32;N++)S[N]+=_-(S[31]>>4)*Gn[N],_=S[N]>>8,S[N]&=255;for(N=0;N<32;N++)S[N]-=_*Gn[N];for(A=0;A<32;A++)S[A+1]+=S[A]>>8,x[A]=S[A]&255}function Sn(x){var S=new Float64Array(64),_;for(_=0;_<64;_++)S[_]=x[_];for(_=0;_<64;_++)x[_]=0;gs(x,S)}function ii(x,S,_,A){var N=new Uint8Array(64),z=new Uint8Array(64),I=new Uint8Array(64),Z,H,J=new Float64Array(64),fe=[s(),s(),s(),s()];ot(N,A,32),N[0]&=248,N[31]&=127,N[31]|=64;var je=_+64;for(Z=0;Z<_;Z++)x[64+Z]=S[Z];for(Z=0;Z<32;Z++)x[32+Z]=N[32+Z];for(ot(I,x.subarray(32),_+32),Sn(I),Ri(fe,I),Mr(x,fe),Z=32;Z<64;Z++)x[Z]=A[Z];for(ot(z,x,_+64),Sn(z),Z=0;Z<64;Z++)J[Z]=0;for(Z=0;Z<32;Z++)J[Z]=I[Z];for(Z=0;Z<32;Z++)for(H=0;H<32;H++)J[Z+H]+=z[Z]*N[H];return gs(x.subarray(32),J),je}function ri(x,S){var _=s(),A=s(),N=s(),z=s(),I=s(),Z=s(),H=s();return be(x[2],m),an(x[1],S),Tt(N,x[1]),Se(z,N,y),Ot(N,N,x[2]),jt(z,x[2],z),Tt(I,z),Tt(Z,I),Se(H,Z,I),Se(_,H,N),Se(_,_,z),Ni(_,_),Se(_,_,N),Se(_,_,z),Se(_,_,z),Se(x[0],_,z),Tt(A,x[0]),Se(A,A,z),lt(A,N)&&Se(x[0],x[0],q),Tt(A,x[0]),Se(A,A,z),lt(A,N)?-1:(Pt(x[0])===S[31]>>7&&Ot(x[0],h,x[0]),Se(x[3],x[0],x[1]),0)}function Dr(x,S,_,A){var N,z=new Uint8Array(32),I=new Uint8Array(64),Z=[s(),s(),s(),s()],H=[s(),s(),s(),s()];if(_<64||ri(H,A))return-1;for(N=0;N<_;N++)x[N]=S[N];for(N=0;N<32;N++)x[N+32]=A[N];if(ot(I,x,_),Sn(I),Rr(Z,H,I),Ri(H,S.subarray(32)),$t(Z,H),Mr(z,Z),_-=64,C(S,0,z,0)){for(N=0;N<_;N++)x[N]=0;return-1}for(N=0;N<_;N++)x[N]=S[N+64];return _}var Di=32,ys=24,En=32,bs=16,xs=32,ai=32,vs=32,Vn=32,li=32,zr=ys,tl=En,Rn=bs,Qe=64,it=32,Yt=64,oi=32,qr=64;r.lowlevel={crypto_core_hsalsa20:V,crypto_stream_xor:ke,crypto_stream:ne,crypto_stream_salsa20_xor:K,crypto_stream_salsa20:ae,crypto_onetimeauth:$,crypto_onetimeauth_verify:te,crypto_verify_16:re,crypto_verify_32:C,crypto_secretbox:de,crypto_secretbox_open:_e,crypto_scalarmult:ni,crypto_scalarmult_base:ln,crypto_box_beforenm:ms,crypto_box_afternm:Ia,crypto_box:Cr,crypto_box_open:kr,crypto_box_keypair:Ci,crypto_hash:ot,crypto_sign:ii,crypto_sign_keypair:ps,crypto_sign_open:Dr,crypto_secretbox_KEYBYTES:Di,crypto_secretbox_NONCEBYTES:ys,crypto_secretbox_ZEROBYTES:En,crypto_secretbox_BOXZEROBYTES:bs,crypto_scalarmult_BYTES:xs,crypto_scalarmult_SCALARBYTES:ai,crypto_box_PUBLICKEYBYTES:vs,crypto_box_SECRETKEYBYTES:Vn,crypto_box_BEFORENMBYTES:li,crypto_box_NONCEBYTES:zr,crypto_box_ZEROBYTES:tl,crypto_box_BOXZEROBYTES:Rn,crypto_sign_BYTES:Qe,crypto_sign_PUBLICKEYBYTES:it,crypto_sign_SECRETKEYBYTES:Yt,crypto_sign_SEEDBYTES:oi,crypto_hash_BYTES:qr,gf:s,D:y,L:Gn,pack25519:Te,unpack25519:an,M:Se,A:jt,S:Tt,Z:Ot,pow2523:Ni,add:$t,set25519:be,modL:gs,scalarmult:Rr,scalarbase:Ri};function nl(x,S){if(x.length!==Di)throw new Error("bad key size");if(S.length!==ys)throw new Error("bad nonce size")}function sl(x,S){if(x.length!==vs)throw new Error("bad public key size");if(S.length!==Vn)throw new Error("bad secret key size")}function yt(){for(var x=0;x<arguments.length;x++)if(!(arguments[x]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function zi(x){for(var S=0;S<x.length;S++)x[S]=0}r.randomBytes=function(x){var S=new Uint8Array(x);return a(S,x),S},r.secretbox=function(x,S,_){yt(x,S,_),nl(_,S);for(var A=new Uint8Array(En+x.length),N=new Uint8Array(A.length),z=0;z<x.length;z++)A[z+En]=x[z];return de(N,A,A.length,S,_),N.subarray(bs)},r.secretbox.open=function(x,S,_){yt(x,S,_),nl(_,S);for(var A=new Uint8Array(bs+x.length),N=new Uint8Array(A.length),z=0;z<x.length;z++)A[z+bs]=x[z];return A.length<32||_e(N,A,A.length,S,_)!==0?null:N.subarray(En)},r.secretbox.keyLength=Di,r.secretbox.nonceLength=ys,r.secretbox.overheadLength=bs,r.scalarMult=function(x,S){if(yt(x,S),x.length!==ai)throw new Error("bad n size");if(S.length!==xs)throw new Error("bad p size");var _=new Uint8Array(xs);return ni(_,x,S),_},r.scalarMult.base=function(x){if(yt(x),x.length!==ai)throw new Error("bad n size");var S=new Uint8Array(xs);return ln(S,x),S},r.scalarMult.scalarLength=ai,r.scalarMult.groupElementLength=xs,r.box=function(x,S,_,A){var N=r.box.before(_,A);return r.secretbox(x,S,N)},r.box.before=function(x,S){yt(x,S),sl(x,S);var _=new Uint8Array(li);return ms(_,x,S),_},r.box.after=r.secretbox,r.box.open=function(x,S,_,A){var N=r.box.before(_,A);return r.secretbox.open(x,S,N)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var x=new Uint8Array(vs),S=new Uint8Array(Vn);return Ci(x,S),{publicKey:x,secretKey:S}},r.box.keyPair.fromSecretKey=function(x){if(yt(x),x.length!==Vn)throw new Error("bad secret key size");var S=new Uint8Array(vs);return ln(S,x),{publicKey:S,secretKey:new Uint8Array(x)}},r.box.publicKeyLength=vs,r.box.secretKeyLength=Vn,r.box.sharedKeyLength=li,r.box.nonceLength=zr,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(x,S){if(yt(x,S),S.length!==Yt)throw new Error("bad secret key size");var _=new Uint8Array(Qe+x.length);return ii(_,x,x.length,S),_},r.sign.open=function(x,S){if(yt(x,S),S.length!==it)throw new Error("bad public key size");var _=new Uint8Array(x.length),A=Dr(_,x,x.length,S);if(A<0)return null;for(var N=new Uint8Array(A),z=0;z<N.length;z++)N[z]=_[z];return N},r.sign.detached=function(x,S){for(var _=r.sign(x,S),A=new Uint8Array(Qe),N=0;N<A.length;N++)A[N]=_[N];return A},r.sign.detached.verify=function(x,S,_){if(yt(x,S,_),S.length!==Qe)throw new Error("bad signature size");if(_.length!==it)throw new Error("bad public key size");var A=new Uint8Array(Qe+x.length),N=new Uint8Array(Qe+x.length),z;for(z=0;z<Qe;z++)A[z]=S[z];for(z=0;z<x.length;z++)A[z+Qe]=x[z];return Dr(N,A,A.length,_)>=0},r.sign.keyPair=function(){var x=new Uint8Array(it),S=new Uint8Array(Yt);return ps(x,S),{publicKey:x,secretKey:S}},r.sign.keyPair.fromSecretKey=function(x){if(yt(x),x.length!==Yt)throw new Error("bad secret key size");for(var S=new Uint8Array(it),_=0;_<S.length;_++)S[_]=x[32+_];return{publicKey:S,secretKey:new Uint8Array(x)}},r.sign.keyPair.fromSeed=function(x){if(yt(x),x.length!==oi)throw new Error("bad seed size");for(var S=new Uint8Array(it),_=new Uint8Array(Yt),A=0;A<32;A++)_[A]=x[A];return ps(S,_,!0),{publicKey:S,secretKey:_}},r.sign.publicKeyLength=it,r.sign.secretKeyLength=Yt,r.sign.seedLength=oi,r.sign.signatureLength=Qe,r.hash=function(x){yt(x);var S=new Uint8Array(qr);return ot(S,x,x.length),S},r.hash.hashLength=qr,r.verify=function(x,S){return yt(x,S),x.length===0||S.length===0||x.length!==S.length?!1:me(x,0,S,0,x.length)===0},r.setPRNG=function(x){a=x},(function(){var x=typeof globalThis<"u"?globalThis.crypto||globalThis.msCrypto:null;if(x&&x.getRandomValues){var S=65536;r.setPRNG(function(_,A){var N,z=new Uint8Array(A);for(N=0;N<A;N+=S)x.getRandomValues(z.subarray(N,N+Math.min(A-N,S)));for(N=0;N<A;N++)_[N]=z[N];zi(z)})}else typeof require<"u"&&(x=require("crypto"),x&&x.randomBytes&&r.setPRNG(function(_,A){var N,z=x.randomBytes(A);for(N=0;N<A;N++)_[N]=z[N];zi(z)}))})()})(typeof module<"u"&&module.exports?module.exports:globalThis.nacl=globalThis.nacl||{});const bo=typeof module<"u"&&module.exports?module.exports:globalThis.nacl;bo.sign.keyPair.fromSeed,bo.sign.detached,bo.sign.detached.verify,bo.randomBytes;var N0;(function(r){r.InvalidPrefixByte="nkeys: invalid prefix byte",r.InvalidKey="nkeys: invalid key",r.InvalidPublicKey="nkeys: invalid public key",r.InvalidSeedLen="nkeys: invalid seed length",r.InvalidSeed="nkeys: invalid seed",r.InvalidEncoding="nkeys: invalid encoded key",r.InvalidSignature="nkeys: signature verification failed",r.CannotSign="nkeys: cannot sign, no private key available",r.PublicKeyOnly="nkeys: no seed or private key available",r.InvalidChecksum="nkeys: invalid checksum",r.SerializationError="nkeys: serialization error",r.ApiError="nkeys: api error",r.ClearedPair="nkeys: pair is cleared"})(N0||(N0={}));var C0;(function(r){r[r.Seed=144]="Seed",r[r.Private=120]="Private",r[r.Operator=112]="Operator",r[r.Server=104]="Server",r[r.Cluster=16]="Cluster",r[r.Account=0]="Account",r[r.User=160]="User"})(C0||(C0={}));function f1(r){return n=>{let s={};return r.forEach(a=>{const o=a(n)||{};s=Object.assign(s,o)}),s}}function h1(){return()=>{}}function d1(r,n){return()=>{const s=typeof r=="function"?r():r,a=typeof n=="function"?n():n;return{user:s,pass:a}}}function m1(r){return()=>({auth_token:typeof r=="function"?r():r})}const Ng=120*1e3,p1=2,Cg=2*1e3;function g1(){return{maxPingOut:2,maxReconnectAttempts:10,noRandomize:!1,pedantic:!1,pingInterval:Ng,reconnect:!0,reconnectJitter:100,reconnectJitterTLS:1e3,reconnectTimeWait:Cg,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function y1(r){const n=[];return typeof r.authenticator=="function"&&n.push(r.authenticator),Array.isArray(r.authenticator)&&n.push(...r.authenticator),r.token&&n.push(m1(r.token)),r.user&&n.push(d1(r.user,r.pass)),n.length===0?h1():f1(n)}function b1(r){const n=`${Of}:${jg()}`;if(r=r||{servers:[n]},r.servers=r.servers||[],typeof r.servers=="string"&&(r.servers=[r.servers]),r.servers.length>0&&r.port)throw new ue("port and servers options are mutually exclusive",ie.InvalidOption);r.servers.length===0&&r.port&&(r.servers=[`${Of}:${r.port}`]),r.servers&&r.servers.length===0&&(r.servers=[n]);const s=Yo(g1(),r);if(s.authenticator=y1(s),["reconnectDelayHandler","authenticator"].forEach(a=>{if(s[a]&&typeof s[a]!="function")throw new ue(`${a} option should be a function`,ie.NotFunction)}),s.reconnectDelayHandler||(s.reconnectDelayHandler=()=>{let a=s.tls?s.reconnectJitterTLS:s.reconnectJitter;return a&&(a++,a=Math.floor(Math.random()*a)),s.reconnectTimeWait+a}),s.inboxPrefix)try{fs(s.inboxPrefix)}catch(a){throw new ue(a.message,ie.ApiError)}if(s.resolve===void 0&&(s.resolve=typeof zf()=="function"),s.resolve&&typeof zf()!="function")throw new ue("'resolve' is not supported on this client",ie.InvalidOption);return s}function x1(r,n){const{proto:s,tls_required:a,tls_available:o}=r;if((s===void 0||s<1)&&n.noEcho)throw new ue("noEcho",ie.ServerOptionNotAvailable);const f=a||o||!1;if(n.tls&&!f)throw new ue("tls",ie.ServerOptionNotAvailable)}const v1=1024*32,_1=/^INFO\s+([^\r\n]+)\r\n/i,w1=Da(`PONG\r
37
+ `,qo=Or.fromAscii(Eo),Gv=new Uint8Array(qo)[0],Vv=new Uint8Array(qo)[1];function Fv(r){for(let n=0;n<r.length;n++){const s=n+1;if(r.byteLength>s&&r[n]===Gv&&r[s]===Vv)return s+1}return 0}function Jv(r){const n=Fv(r);if(n>0){const a=new Uint8Array(r).slice(0,n);return en.decode(a)}return""}const Iv=4,Og=48,Qv=65,Xv=97;function Kv(r,n,s,a){const o=new Uint8Array(16);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((h,m)=>{o[m]=h}),o[12]=r,o[13]=n,o[14]=s,o[15]=a,o}function qf(r){return Zv(r)!==void 0}function Zv(r){for(let n=0;n<r.length;n++)switch(r[n]){case".":return Tg(r);case":":return Wv(r)}}function Tg(r){const n=new Uint8Array(4);for(let s=0;s<4;s++){if(r.length===0)return;if(s>0){if(r[0]!==".")return;r=r.substring(1)}const{n:a,c:o,ok:f}=e1(r);if(!f||a>255)return;r=r.substring(o),n[s]=a}return Kv(n[0],n[1],n[2],n[3])}function Wv(r){const n=new Uint8Array(16);let s=-1;if(r.length>=2&&r[0]===":"&&r[1]===":"&&(s=0,r=r.substring(2),r.length===0))return n;let a=0;for(;a<16;){const{n:o,c:f,ok:h}=t1(r);if(!h||o>65535)return;if(f<r.length&&r[f]==="."){if(s<0&&a!=12||a+4>16)return;const m=Tg(r);if(m===void 0)return;n[a]=m[12],n[a+1]=m[13],n[a+2]=m[14],n[a+3]=m[15],r="",a+=Iv;break}if(n[a]=o>>8,n[a+1]=o,a+=2,r=r.substring(f),r.length===0)break;if(r[0]!==":"||r.length==1)return;if(r=r.substring(1),r[0]===":"){if(s>=0)return;if(s=a,r=r.substring(1),r.length===0)break}}if(r.length===0){if(a<16){if(s<0)return;const o=16-a;for(let f=a-1;f>=s;f--)n[f+o]=n[f];for(let f=s+o-1;f>=s;f--)n[f]=0}else if(s>=0)return;return n}}function e1(r){let n=0,s=0;for(n=0;n<r.length&&48<=r.charCodeAt(n)&&r.charCodeAt(n)<=57;n++)if(s=s*10+(r.charCodeAt(n)-Og),s>=16777215)return{n:16777215,c:n,ok:!1};return n===0?{n:0,c:0,ok:!1}:{n:s,c:n,ok:!0}}function t1(r){let n=0,s=0;for(s=0;s<r.length;s++){if(48<=r.charCodeAt(s)&&r.charCodeAt(s)<=57)n*=16,n+=r.charCodeAt(s)-Og;else if(97<=r.charCodeAt(s)&&r.charCodeAt(s)<=102)n*=16,n+=r.charCodeAt(s)-Xv+10;else if(65<=r.charCodeAt(s)&&r.charCodeAt(s)<=70)n*=16,n+=r.charCodeAt(s)-Qv+10;else break;if(n>=16777215)return{n:0,c:s,ok:!1}}return s===0?{n:0,c:s,ok:!1}:{n,c:s,ok:!0}}function n1(r){return r.indexOf("[")!==-1||r.indexOf("::")!==-1?!1:r.indexOf(".")!==-1||r.split(":").length<=2}function Uf(r){return!n1(r)}function s1(r){const n="::FFFF:",s=r.toUpperCase().indexOf(n);if(s!==-1&&r.indexOf(".")!==-1){let a=r.substring(s+n.length);return a=a.replace("[",""),a.replace("]","")}return r}function i1(r){r=r.trim(),r.match(/^(.*:\/\/)(.*)/m)&&(r=r.replace(/^(.*:\/\/)(.*)/gm,"$2")),r=s1(r),Uf(r)&&r.indexOf("[")===-1&&(r=`[${r}]`);const n=Uf(r)?r.match(/(]:)(\d+)/):r.match(/(:)(\d+)/),s=n&&n.length===3&&n[1]&&n[2]?parseInt(n[2]):4222,a=s===80?"https":"http",o=new URL(`${a}://${r}`);o.port=`${s}`;let f=o.hostname;return f.charAt(0)==="["&&(f=f.substring(1,f.length-1)),{listen:o.host,hostname:f,port:s}}class qa{constructor(n,s=!1){v(this,"src");v(this,"listen");v(this,"hostname");v(this,"port");v(this,"didConnect");v(this,"reconnects");v(this,"lastConnect");v(this,"gossiped");v(this,"tlsName");v(this,"resolves");this.src=n,this.tlsName="";const a=i1(n);this.listen=a.listen,this.hostname=a.hostname,this.port=a.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=s}toString(){return this.listen}async resolve(n){if(!n.fn||n.resolve===!1)return[this];const s=[];if(qf(this.hostname))return[this];{const a=await n.fn(this.hostname);n.debug&&console.log(`resolve ${this.hostname} = ${a.join(",")}`);for(const o of a){const f=this.port===80?"https":"http",h=new URL(`${f}://${Uf(o)?"["+o+"]":o}`);h.port=`${this.port}`;const m=new qa(h.host,!1);m.tlsName=this.hostname,s.push(m)}}return n.randomize&&_g(s),this.resolves=s,s}}class r1{constructor(n=[],s={}){v(this,"firstSelect");v(this,"servers");v(this,"currentServer");v(this,"tlsName");v(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=s.randomize||!1;const a=df();n&&(n.forEach(o=>{o=a?a(o):o,this.servers.push(new qa(o))}),this.randomize&&(this.servers=_g(this.servers))),this.servers.length===0&&this.addServer(`${Of}:${jg()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const n=this.getCurrentServer();qf(n.hostname)||(this.tlsName=n.hostname,this.servers.forEach(s=>{s.gossiped&&(s.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(n,s=!1){const a=df();n=a?a(n):n;const o=new qa(n,s);qf(o.hostname)&&(o.tlsName=this.tlsName),this.servers.push(o)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;const n=this.servers.shift();return n&&(this.servers.push(n),this.currentServer=n),n}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer(n){if(n){const s=this.servers.indexOf(n);this.servers.splice(s,1)}}length(){return this.servers.length}next(){return this.servers.length?this.servers[0]:void 0}getServers(){return this.servers}update(n,s){const a=[];let o=[];const f=df(),h=new Map;n.connect_urls&&n.connect_urls.length>0&&n.connect_urls.forEach(g=>{g=f?f(g,s):g;const y=new qa(g,!0);h.set(g,y)});const m=[];return this.servers.forEach((g,y)=>{const E=g.listen;g.gossiped&&this.currentServer.listen!==E&&h.get(E)===void 0&&m.push(y),h.delete(E)}),m.reverse(),m.forEach(g=>{const y=this.servers.splice(g,1);o=o.concat(y[0].listen)}),h.forEach((g,y)=>{this.servers.push(g),a.push(y)}),{added:a,deleted:o}}}class a1{constructor(){v(this,"baseInbox");v(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(n){return this.baseInbox=`${fs(n)}.`,this.baseInbox}add(n){isNaN(n.received)||(n.received=0),this.reqs.set(n.token,n)}get(n){return this.reqs.get(n)}cancel(n){this.reqs.delete(n.token)}getToken(n){const s=n.subject||"";return s.indexOf(this.baseInbox)===0?s.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(n,s){if(s&&s.permissionContext){if(n)return this.all().forEach(o=>{o.resolver(s,{})}),!0;const a=s.permissionContext;if(a.operation==="publish"){const o=this.all().find(f=>f.requestSubject===a.subject);if(o)return o.resolver(s,{}),!0}}return!1}dispatcher(){return(n,s)=>{const a=this.getToken(s);if(a){const o=this.get(a);o&&(n===null&&s.headers&&(n=wg(s)),o.resolver(n,s))}}}close(){const n=ue.errorForCode(ie.Timeout);this.reqs.forEach(s=>{s.resolver(n,{})})}}class l1{constructor(n,s,a){v(this,"ph");v(this,"interval");v(this,"maxOut");v(this,"timer");v(this,"pendings");this.ph=n,this.interval=s,this.maxOut=a,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(n){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),n&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:vr.PingTimer,data:`${this.pendings.length+1}`}),this.pendings.length===this.maxOut){this.cancel(!0);return}const n=st();this.ph.flush(n).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push(n),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(n=>(n.resolve(),!1))}}class o1 extends Error{constructor(n){super(n),this.name="AssertionError"}}function c1(r,n="Assertion failed."){if(!r)throw new o1(n)}const j0=32*1024,mf=2**32-2;function yo(r,n,s=0){const a=n.byteLength-s;return r.byteLength>a&&(r=r.subarray(0,a)),n.set(r,s),r.byteLength}class pf{constructor(n){v(this,"_buf");v(this,"_off");if(this._off=0,n==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array(n)}bytes(n={copy:!0}){return n.copy===!1?this._buf.subarray(this._off):this._buf.slice(this._off)}empty(){return this._buf.byteLength<=this._off}get length(){return this._buf.byteLength-this._off}get capacity(){return this._buf.buffer.byteLength}truncate(n){if(n===0){this.reset();return}if(n<0||n>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+n)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(n){const s=this._buf.byteLength;return n<=this.capacity-s?(this._reslice(s+n),s):-1}_reslice(n){c1(n<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,n)}readByte(){const n=new Uint8Array(1);return this.read(n)?n[0]:null}read(n){if(this.empty())return this.reset(),n.byteLength===0?0:null;const s=yo(this._buf.subarray(this._off),n);return this._off+=s,s}writeByte(n){return this.write(Uint8Array.of(n))}writeString(n){return this.write(Ti.encode(n))}write(n){const s=this._grow(n.byteLength);return yo(n,this._buf,s)}_grow(n){const s=this.length;s===0&&this._off!==0&&this.reset();const a=this._tryGrowByReslice(n);if(a>=0)return a;const o=this.capacity;if(n<=Math.floor(o/2)-s)yo(this._buf.subarray(this._off),this._buf);else{if(o+n>mf)throw new Error("The buffer cannot be grown beyond the maximum size.");{const f=new Uint8Array(Math.min(2*o+n,mf));yo(this._buf.subarray(this._off),f),this._buf=f}}return this._off=0,this._reslice(Math.min(s+n,mf)),s}grow(n){if(n<0)throw Error("Buffer._grow: negative count");const s=this._grow(n);this._reslice(s)}readFrom(n){let s=0;const a=new Uint8Array(j0);for(;;){const o=this.capacity-this.length<j0,f=o?a:new Uint8Array(this._buf.buffer,this.length),h=n.read(f);if(h===null)return s;o?this.write(f.subarray(0,h)):this._reslice(this.length+h),s+=h}}}var Rt;(function(r){r[r.OK=0]="OK",r[r.ERR=1]="ERR",r[r.MSG=2]="MSG",r[r.INFO=3]="INFO",r[r.PING=4]="PING",r[r.PONG=5]="PONG"})(Rt||(Rt={}));function O0(){const r={};return r.sid=-1,r.hdr=-1,r.size=-1,r}const u1=48;class T0{constructor(n){v(this,"dispatcher");v(this,"state");v(this,"as");v(this,"drop");v(this,"hdr");v(this,"ma");v(this,"argBuf");v(this,"msgBuf");this.dispatcher=n,this.state=le.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(n){let s;for(s=0;s<n.length;s++){const a=n[s];switch(this.state){case le.OP_START:switch(a){case oe.M:case oe.m:this.state=le.OP_M,this.hdr=-1,this.ma=O0();break;case oe.H:case oe.h:this.state=le.OP_H,this.hdr=0,this.ma=O0();break;case oe.P:case oe.p:this.state=le.OP_P;break;case oe.PLUS:this.state=le.OP_PLUS;break;case oe.MINUS:this.state=le.OP_MINUS;break;case oe.I:case oe.i:this.state=le.OP_I;break;default:throw this.fail(n.subarray(s))}break;case le.OP_H:switch(a){case oe.M:case oe.m:this.state=le.OP_M;break;default:throw this.fail(n.subarray(s))}break;case le.OP_M:switch(a){case oe.S:case oe.s:this.state=le.OP_MS;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MS:switch(a){case oe.G:case oe.g:this.state=le.OP_MSG;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MSG:switch(a){case oe.SPACE:case oe.TAB:this.state=le.OP_MSG_SPC;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MSG_SPC:switch(a){case oe.SPACE:case oe.TAB:continue;default:this.state=le.MSG_ARG,this.as=s}break;case le.MSG_ARG:switch(a){case oe.CR:this.drop=1;break;case oe.NL:{const o=this.argBuf?this.argBuf.bytes():n.subarray(this.as,s-this.drop);this.processMsgArgs(o),this.drop=0,this.as=s+1,this.state=le.MSG_PAYLOAD,s=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(a)}break;case le.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const o=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Rt.MSG,msg:this.ma,data:o}),this.argBuf=void 0,this.msgBuf=void 0,this.state=le.MSG_END}else{let o=this.ma.size-this.msgBuf.length;const f=n.length-s;f<o&&(o=f),o>0?(this.msgBuf.write(n.subarray(s,s+o)),s=s+o-1):this.msgBuf.writeByte(a)}else s-this.as>=this.ma.size&&(this.dispatcher.push({kind:Rt.MSG,msg:this.ma,data:n.subarray(this.as,s)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=le.MSG_END);break;case le.MSG_END:switch(a){case oe.NL:this.drop=0,this.as=s+1,this.state=le.OP_START;break;default:continue}break;case le.OP_PLUS:switch(a){case oe.O:case oe.o:this.state=le.OP_PLUS_O;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PLUS_O:switch(a){case oe.K:case oe.k:this.state=le.OP_PLUS_OK;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PLUS_OK:switch(a){case oe.NL:this.dispatcher.push({kind:Rt.OK}),this.drop=0,this.state=le.OP_START;break}break;case le.OP_MINUS:switch(a){case oe.E:case oe.e:this.state=le.OP_MINUS_E;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MINUS_E:switch(a){case oe.R:case oe.r:this.state=le.OP_MINUS_ER;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MINUS_ER:switch(a){case oe.R:case oe.r:this.state=le.OP_MINUS_ERR;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MINUS_ERR:switch(a){case oe.SPACE:case oe.TAB:this.state=le.OP_MINUS_ERR_SPC;break;default:throw this.fail(n.subarray(s))}break;case le.OP_MINUS_ERR_SPC:switch(a){case oe.SPACE:case oe.TAB:continue;default:this.state=le.MINUS_ERR_ARG,this.as=s}break;case le.MINUS_ERR_ARG:switch(a){case oe.CR:this.drop=1;break;case oe.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=n.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Rt.ERR,data:o}),this.drop=0,this.as=s+1,this.state=le.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(a))}break;case le.OP_P:switch(a){case oe.I:case oe.i:this.state=le.OP_PI;break;case oe.O:case oe.o:this.state=le.OP_PO;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PO:switch(a){case oe.N:case oe.n:this.state=le.OP_PON;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PON:switch(a){case oe.G:case oe.g:this.state=le.OP_PONG;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PONG:switch(a){case oe.NL:this.dispatcher.push({kind:Rt.PONG}),this.drop=0,this.state=le.OP_START;break}break;case le.OP_PI:switch(a){case oe.N:case oe.n:this.state=le.OP_PIN;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PIN:switch(a){case oe.G:case oe.g:this.state=le.OP_PING;break;default:throw this.fail(n.subarray(s))}break;case le.OP_PING:switch(a){case oe.NL:this.dispatcher.push({kind:Rt.PING}),this.drop=0,this.state=le.OP_START;break}break;case le.OP_I:switch(a){case oe.N:case oe.n:this.state=le.OP_IN;break;default:throw this.fail(n.subarray(s))}break;case le.OP_IN:switch(a){case oe.F:case oe.f:this.state=le.OP_INF;break;default:throw this.fail(n.subarray(s))}break;case le.OP_INF:switch(a){case oe.O:case oe.o:this.state=le.OP_INFO;break;default:throw this.fail(n.subarray(s))}break;case le.OP_INFO:switch(a){case oe.SPACE:case oe.TAB:this.state=le.OP_INFO_SPC;break;default:throw this.fail(n.subarray(s))}break;case le.OP_INFO_SPC:switch(a){case oe.SPACE:case oe.TAB:continue;default:this.state=le.INFO_ARG,this.as=s}break;case le.INFO_ARG:switch(a){case oe.CR:this.drop=1;break;case oe.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=n.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Rt.INFO,data:o}),this.drop=0,this.as=s+1,this.state=le.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(a)}break;default:throw this.fail(n.subarray(s))}}(this.state===le.MSG_ARG||this.state===le.MINUS_ERR_ARG||this.state===le.INFO_ARG)&&!this.argBuf&&(this.argBuf=new pf(n.subarray(this.as,s-this.drop))),this.state===le.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new pf(n.subarray(this.as)))}cloneMsgArg(){const n=this.ma.subject.length,s=this.ma.reply?this.ma.reply.length:0,a=new Uint8Array(n+s);a.set(this.ma.subject),this.ma.reply&&a.set(this.ma.reply,n),this.argBuf=new pf(a),this.ma.subject=a.subarray(0,n),this.ma.reply&&(this.ma.reply=a.subarray(n))}processMsgArgs(n){if(this.hdr>=0)return this.processHeaderMsgArgs(n);const s=[];let a=-1;for(let o=0;o<n.length;o++)switch(n[o]){case oe.SPACE:case oe.TAB:case oe.CR:case oe.NL:a>=0&&(s.push(n.subarray(a,o)),a=-1);break;default:a<0&&(a=o)}switch(a>=0&&s.push(n.subarray(a)),s.length){case 3:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(s[2]);break;case 4:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=s[2],this.ma.size=this.protoParseInt(s[3]);break;default:throw this.fail(n,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(n,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(n,"processMsgArgs Bad or Missing Size Error")}fail(n,s=""){return s?s=`${s} [${this.state}]`:s=`parse error [${this.state}]`,new Error(`${s}: ${en.decode(n)}`)}processHeaderMsgArgs(n){const s=[];let a=-1;for(let o=0;o<n.length;o++)switch(n[o]){case oe.SPACE:case oe.TAB:case oe.CR:case oe.NL:a>=0&&(s.push(n.subarray(a,o)),a=-1);break;default:a<0&&(a=o)}switch(a>=0&&s.push(n.subarray(a)),s.length){case 4:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(s[2]),this.ma.size=this.protoParseInt(s[3]);break;case 5:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=s[2],this.ma.hdr=this.protoParseInt(s[3]),this.ma.size=this.protoParseInt(s[4]);break;default:throw this.fail(n,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(n,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(n,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(n,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(n){if(n.length===0)return-1;let s=0;for(let a=0;a<n.length;a++){if(n[a]<48||n[a]>57)return-1;s=s*10+(n[a]-u1)}return s}}var le;(function(r){r[r.OP_START=0]="OP_START",r[r.OP_PLUS=1]="OP_PLUS",r[r.OP_PLUS_O=2]="OP_PLUS_O",r[r.OP_PLUS_OK=3]="OP_PLUS_OK",r[r.OP_MINUS=4]="OP_MINUS",r[r.OP_MINUS_E=5]="OP_MINUS_E",r[r.OP_MINUS_ER=6]="OP_MINUS_ER",r[r.OP_MINUS_ERR=7]="OP_MINUS_ERR",r[r.OP_MINUS_ERR_SPC=8]="OP_MINUS_ERR_SPC",r[r.MINUS_ERR_ARG=9]="MINUS_ERR_ARG",r[r.OP_M=10]="OP_M",r[r.OP_MS=11]="OP_MS",r[r.OP_MSG=12]="OP_MSG",r[r.OP_MSG_SPC=13]="OP_MSG_SPC",r[r.MSG_ARG=14]="MSG_ARG",r[r.MSG_PAYLOAD=15]="MSG_PAYLOAD",r[r.MSG_END=16]="MSG_END",r[r.OP_H=17]="OP_H",r[r.OP_P=18]="OP_P",r[r.OP_PI=19]="OP_PI",r[r.OP_PIN=20]="OP_PIN",r[r.OP_PING=21]="OP_PING",r[r.OP_PO=22]="OP_PO",r[r.OP_PON=23]="OP_PON",r[r.OP_PONG=24]="OP_PONG",r[r.OP_I=25]="OP_I",r[r.OP_IN=26]="OP_IN",r[r.OP_INF=27]="OP_INF",r[r.OP_INFO=28]="OP_INFO",r[r.OP_INFO_SPC=29]="OP_INFO_SPC",r[r.INFO_ARG=30]="INFO_ARG"})(le||(le={}));var oe;(function(r){r[r.CR=13]="CR",r[r.E=69]="E",r[r.e=101]="e",r[r.F=70]="F",r[r.f=102]="f",r[r.G=71]="G",r[r.g=103]="g",r[r.H=72]="H",r[r.h=104]="h",r[r.I=73]="I",r[r.i=105]="i",r[r.K=75]="K",r[r.k=107]="k",r[r.M=77]="M",r[r.m=109]="m",r[r.MINUS=45]="MINUS",r[r.N=78]="N",r[r.n=110]="n",r[r.NL=10]="NL",r[r.O=79]="O",r[r.o=111]="o",r[r.P=80]="P",r[r.p=112]="p",r[r.PLUS=43]="PLUS",r[r.R=82]="R",r[r.r=114]="r",r[r.S=83]="S",r[r.s=115]="s",r[r.SPACE=32]="SPACE",r[r.TAB=9]="TAB"})(oe||(oe={}));(function(r){var n=function(x,S){this.hi=x|0,this.lo=S|0},s=function(x){var S,_=new Float64Array(16);if(x)for(S=0;S<x.length;S++)_[S]=x[S];return _},a=function(){throw new Error("no PRNG")},o=new Uint8Array(16),f=new Uint8Array(32);f[0]=9;var h=s(),m=s([1]),g=s([56129,1]),y=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),E=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),w=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),T=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),q=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function M(x,S){return x<<S|x>>>32-S}function D(x,S){var _=x[S+3]&255;return _=_<<8|x[S+2]&255,_=_<<8|x[S+1]&255,_<<8|x[S+0]&255}function W(x,S){var _=x[S]<<24|x[S+1]<<16|x[S+2]<<8|x[S+3],A=x[S+4]<<24|x[S+5]<<16|x[S+6]<<8|x[S+7];return new n(_,A)}function se(x,S,_){var A;for(A=0;A<4;A++)x[S+A]=_&255,_>>>=8}function ee(x,S,_){x[S]=_.hi>>24&255,x[S+1]=_.hi>>16&255,x[S+2]=_.hi>>8&255,x[S+3]=_.hi&255,x[S+4]=_.lo>>24&255,x[S+5]=_.lo>>16&255,x[S+6]=_.lo>>8&255,x[S+7]=_.lo&255}function me(x,S,_,A,N){var z,I=0;for(z=0;z<N;z++)I|=x[S+z]^_[A+z];return(1&I-1>>>8)-1}function re(x,S,_,A){return me(x,S,_,A,16)}function C(x,S,_,A){return me(x,S,_,A,32)}function X(x,S,_,A,N){var z=new Uint32Array(16),I=new Uint32Array(16),Z=new Uint32Array(16),H=new Uint32Array(4),J,fe,je;for(J=0;J<4;J++)I[5*J]=D(A,4*J),I[1+J]=D(_,4*J),I[6+J]=D(S,4*J),I[11+J]=D(_,16+4*J);for(J=0;J<16;J++)Z[J]=I[J];for(J=0;J<20;J++){for(fe=0;fe<4;fe++){for(je=0;je<4;je++)H[je]=I[(5*fe+4*je)%16];for(H[1]^=M(H[0]+H[3]|0,7),H[2]^=M(H[1]+H[0]|0,9),H[3]^=M(H[2]+H[1]|0,13),H[0]^=M(H[3]+H[2]|0,18),je=0;je<4;je++)z[4*fe+(fe+je)%4]=H[je]}for(je=0;je<16;je++)I[je]=z[je]}if(N){for(J=0;J<16;J++)I[J]=I[J]+Z[J]|0;for(J=0;J<4;J++)I[5*J]=I[5*J]-D(A,4*J)|0,I[6+J]=I[6+J]-D(S,4*J)|0;for(J=0;J<4;J++)se(x,4*J,I[5*J]),se(x,16+4*J,I[6+J])}else for(J=0;J<16;J++)se(x,4*J,I[J]+Z[J]|0)}function ce(x,S,_,A){return X(x,S,_,A,!1),0}function V(x,S,_,A){return X(x,S,_,A,!0),0}var G=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function K(x,S,_,A,N,z,I){var Z=new Uint8Array(16),H=new Uint8Array(64),J,fe;if(!N)return 0;for(fe=0;fe<16;fe++)Z[fe]=0;for(fe=0;fe<8;fe++)Z[fe]=z[fe];for(;N>=64;){for(ce(H,Z,I,G),fe=0;fe<64;fe++)x[S+fe]=(_?_[A+fe]:0)^H[fe];for(J=1,fe=8;fe<16;fe++)J=J+(Z[fe]&255)|0,Z[fe]=J&255,J>>>=8;N-=64,S+=64,_&&(A+=64)}if(N>0)for(ce(H,Z,I,G),fe=0;fe<N;fe++)x[S+fe]=(_?_[A+fe]:0)^H[fe];return 0}function ae(x,S,_,A,N){return K(x,S,null,0,_,A,N)}function ne(x,S,_,A,N){var z=new Uint8Array(32);return V(z,A,N,G),ae(x,S,_,A.subarray(16),z)}function ke(x,S,_,A,N,z,I){var Z=new Uint8Array(32);return V(Z,z,I,G),K(x,S,_,A,N,z.subarray(16),Z)}function He(x,S){var _,A=0;for(_=0;_<17;_++)A=A+(x[_]+S[_]|0)|0,x[_]=A&255,A>>>=8}var Me=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function $(x,S,_,A,N,z){var I,Z,H,J,fe=new Uint32Array(17),je=new Uint32Array(17),Ke=new Uint32Array(17),Ct=new Uint32Array(17),An=new Uint32Array(17);for(H=0;H<17;H++)je[H]=Ke[H]=0;for(H=0;H<16;H++)je[H]=z[H];for(je[3]&=15,je[4]&=252,je[7]&=15,je[8]&=252,je[11]&=15,je[12]&=252,je[15]&=15;N>0;){for(H=0;H<17;H++)Ct[H]=0;for(H=0;H<16&&H<N;++H)Ct[H]=_[A+H];for(Ct[H]=1,A+=H,N-=H,He(Ke,Ct),Z=0;Z<17;Z++)for(fe[Z]=0,H=0;H<17;H++)fe[Z]=fe[Z]+Ke[H]*(H<=Z?je[Z-H]:320*je[Z+17-H]|0)|0|0;for(Z=0;Z<17;Z++)Ke[Z]=fe[Z];for(J=0,H=0;H<16;H++)J=J+Ke[H]|0,Ke[H]=J&255,J>>>=8;for(J=J+Ke[16]|0,Ke[16]=J&3,J=5*(J>>>2)|0,H=0;H<16;H++)J=J+Ke[H]|0,Ke[H]=J&255,J>>>=8;J=J+Ke[16]|0,Ke[16]=J}for(H=0;H<17;H++)An[H]=Ke[H];for(He(Ke,Me),I=-(Ke[16]>>>7)|0,H=0;H<17;H++)Ke[H]^=I&(An[H]^Ke[H]);for(H=0;H<16;H++)Ct[H]=z[H+16];for(Ct[16]=0,He(Ke,Ct),H=0;H<16;H++)x[S+H]=Ke[H];return 0}function te(x,S,_,A,N,z){var I=new Uint8Array(16);return $(I,0,_,A,N,z),re(x,S,I,0)}function de(x,S,_,A,N){var z;if(_<32)return-1;for(ke(x,0,S,0,_,A,N),$(x,16,x,32,_-32,x),z=0;z<16;z++)x[z]=0;return 0}function _e(x,S,_,A,N){var z,I=new Uint8Array(32);if(_<32||(ne(I,0,32,A,N),te(S,16,S,32,_-32,I)!==0))return-1;for(ke(x,0,S,0,_,A,N),z=0;z<32;z++)x[z]=0;return 0}function xe(x,S){var _;for(_=0;_<16;_++)x[_]=S[_]|0}function Oe(x){var S,_;for(_=0;_<16;_++)x[_]+=65536,S=Math.floor(x[_]/65536),x[(_+1)*(_<15?1:0)]+=S-1+37*(S-1)*(_===15?1:0),x[_]-=S*65536}function we(x,S,_){for(var A,N=~(_-1),z=0;z<16;z++)A=N&(x[z]^S[z]),x[z]^=A,S[z]^=A}function Te(x,S){var _,A,N,z=s(),I=s();for(_=0;_<16;_++)I[_]=S[_];for(Oe(I),Oe(I),Oe(I),A=0;A<2;A++){for(z[0]=I[0]-65517,_=1;_<15;_++)z[_]=I[_]-65535-(z[_-1]>>16&1),z[_-1]&=65535;z[15]=I[15]-32767-(z[14]>>16&1),N=z[15]>>16&1,z[14]&=65535,we(I,z,1-N)}for(_=0;_<16;_++)x[2*_]=I[_]&255,x[2*_+1]=I[_]>>8}function lt(x,S){var _=new Uint8Array(32),A=new Uint8Array(32);return Te(_,x),Te(A,S),C(_,0,A,0)}function Pt(x){var S=new Uint8Array(32);return Te(S,x),S[0]&1}function an(x,S){var _;for(_=0;_<16;_++)x[_]=S[2*_]+(S[2*_+1]<<8);x[15]&=32767}function jt(x,S,_){var A;for(A=0;A<16;A++)x[A]=S[A]+_[A]|0}function Ot(x,S,_){var A;for(A=0;A<16;A++)x[A]=S[A]-_[A]|0}function Se(x,S,_){var A,N,z=new Float64Array(31);for(A=0;A<31;A++)z[A]=0;for(A=0;A<16;A++)for(N=0;N<16;N++)z[A+N]+=S[A]*_[N];for(A=0;A<15;A++)z[A]+=38*z[A+16];for(A=0;A<16;A++)x[A]=z[A];Oe(x),Oe(x)}function Tt(x,S){Se(x,S,S)}function ti(x,S){var _=s(),A;for(A=0;A<16;A++)_[A]=S[A];for(A=253;A>=0;A--)Tt(_,_),A!==2&&A!==4&&Se(_,_,S);for(A=0;A<16;A++)x[A]=_[A]}function Ni(x,S){var _=s(),A;for(A=0;A<16;A++)_[A]=S[A];for(A=250;A>=0;A--)Tt(_,_),A!==1&&Se(_,_,S);for(A=0;A<16;A++)x[A]=_[A]}function ni(x,S,_){var A=new Uint8Array(32),N=new Float64Array(80),z,I,Z=s(),H=s(),J=s(),fe=s(),je=s(),Ke=s();for(I=0;I<31;I++)A[I]=S[I];for(A[31]=S[31]&127|64,A[0]&=248,an(N,_),I=0;I<16;I++)H[I]=N[I],fe[I]=Z[I]=J[I]=0;for(Z[0]=fe[0]=1,I=254;I>=0;--I)z=A[I>>>3]>>>(I&7)&1,we(Z,H,z),we(J,fe,z),jt(je,Z,J),Ot(Z,Z,J),jt(J,H,fe),Ot(H,H,fe),Tt(fe,je),Tt(Ke,Z),Se(Z,J,Z),Se(J,H,je),jt(je,Z,J),Ot(Z,Z,J),Tt(H,Z),Ot(J,fe,Ke),Se(Z,J,g),jt(Z,Z,fe),Se(J,J,Z),Se(Z,fe,Ke),Se(fe,H,N),Tt(H,je),we(Z,H,z),we(J,fe,z);for(I=0;I<16;I++)N[I+16]=Z[I],N[I+32]=J[I],N[I+48]=H[I],N[I+64]=fe[I];var Ct=N.subarray(32),An=N.subarray(16);return ti(Ct,Ct),Se(An,An,Ct),Te(x,An),0}function ln(x,S){return ni(x,S,f)}function Ci(x,S){return a(S,32),ln(x,S)}function ms(x,S,_){var A=new Uint8Array(32);return ni(A,_,S),V(x,o,A,G)}var Ia=de,Qa=_e;function Cr(x,S,_,A,N,z){var I=new Uint8Array(32);return ms(I,N,z),Ia(x,S,_,A,I)}function kr(x,S,_,A,N,z){var I=new Uint8Array(32);return ms(I,N,z),Qa(x,S,_,A,I)}function Yn(){var x=0,S=0,_=0,A=0,N=65535,z,I,Z;for(Z=0;Z<arguments.length;Z++)z=arguments[Z].lo,I=arguments[Z].hi,x+=z&N,S+=z>>>16,_+=I&N,A+=I>>>16;return S+=x>>>16,_+=S>>>16,A+=_>>>16,new n(_&N|A<<16,x&N|S<<16)}function Xa(x,S){return new n(x.hi>>>S,x.lo>>>S|x.hi<<32-S)}function ki(){var x=0,S=0,_;for(_=0;_<arguments.length;_++)x^=arguments[_].lo,S^=arguments[_].hi;return new n(S,x)}function et(x,S){var _,A,N=32-S;return S<32?(_=x.hi>>>S|x.lo<<N,A=x.lo>>>S|x.hi<<N):S<64&&(_=x.lo>>>S|x.hi<<N,A=x.hi>>>S|x.lo<<N),new n(_,A)}function Xo(x,S,_){var A=x.hi&S.hi^~x.hi&_.hi,N=x.lo&S.lo^~x.lo&_.lo;return new n(A,N)}function Ka(x,S,_){var A=x.hi&S.hi^x.hi&_.hi^S.hi&_.hi,N=x.lo&S.lo^x.lo&_.lo^S.lo&_.lo;return new n(A,N)}function Za(x){return ki(et(x,28),et(x,34),et(x,39))}function Mi(x){return ki(et(x,14),et(x,18),et(x,41))}function Ko(x){return ki(et(x,1),et(x,8),Xa(x,7))}function Wa(x){return ki(et(x,19),et(x,61),Xa(x,6))}var Zo=[new n(1116352408,3609767458),new n(1899447441,602891725),new n(3049323471,3964484399),new n(3921009573,2173295548),new n(961987163,4081628472),new n(1508970993,3053834265),new n(2453635748,2937671579),new n(2870763221,3664609560),new n(3624381080,2734883394),new n(310598401,1164996542),new n(607225278,1323610764),new n(1426881987,3590304994),new n(1925078388,4068182383),new n(2162078206,991336113),new n(2614888103,633803317),new n(3248222580,3479774868),new n(3835390401,2666613458),new n(4022224774,944711139),new n(264347078,2341262773),new n(604807628,2007800933),new n(770255983,1495990901),new n(1249150122,1856431235),new n(1555081692,3175218132),new n(1996064986,2198950837),new n(2554220882,3999719339),new n(2821834349,766784016),new n(2952996808,2566594879),new n(3210313671,3203337956),new n(3336571891,1034457026),new n(3584528711,2466948901),new n(113926993,3758326383),new n(338241895,168717936),new n(666307205,1188179964),new n(773529912,1546045734),new n(1294757372,1522805485),new n(1396182291,2643833823),new n(1695183700,2343527390),new n(1986661051,1014477480),new n(2177026350,1206759142),new n(2456956037,344077627),new n(2730485921,1290863460),new n(2820302411,3158454273),new n(3259730800,3505952657),new n(3345764771,106217008),new n(3516065817,3606008344),new n(3600352804,1432725776),new n(4094571909,1467031594),new n(275423344,851169720),new n(430227734,3100823752),new n(506948616,1363258195),new n(659060556,3750685593),new n(883997877,3785050280),new n(958139571,3318307427),new n(1322822218,3812723403),new n(1537002063,2003034995),new n(1747873779,3602036899),new n(1955562222,1575990012),new n(2024104815,1125592928),new n(2227730452,2716904306),new n(2361852424,442776044),new n(2428436474,593698344),new n(2756734187,3733110249),new n(3204031479,2999351573),new n(3329325298,3815920427),new n(3391569614,3928383900),new n(3515267271,566280711),new n(3940187606,3454069534),new n(4118630271,4000239992),new n(116418474,1914138554),new n(174292421,2731055270),new n(289380356,3203993006),new n(460393269,320620315),new n(685471733,587496836),new n(852142971,1086792851),new n(1017036298,365543100),new n(1126000580,2618297676),new n(1288033470,3409855158),new n(1501505948,4234509866),new n(1607167915,987167468),new n(1816402316,1246189591)];function el(x,S,_){var A=[],N=[],z=[],I=[],Z,H,J;for(H=0;H<8;H++)A[H]=z[H]=W(x,8*H);for(var fe=0;_>=128;){for(H=0;H<16;H++)I[H]=W(S,8*H+fe);for(H=0;H<80;H++){for(J=0;J<8;J++)N[J]=z[J];for(Z=Yn(z[7],Mi(z[4]),Xo(z[4],z[5],z[6]),Zo[H],I[H%16]),N[7]=Yn(Z,Za(z[0]),Ka(z[0],z[1],z[2])),N[3]=Yn(N[3],Z),J=0;J<8;J++)z[(J+1)%8]=N[J];if(H%16===15)for(J=0;J<16;J++)I[J]=Yn(I[J],I[(J+9)%16],Ko(I[(J+1)%16]),Wa(I[(J+14)%16]))}for(H=0;H<8;H++)z[H]=Yn(z[H],A[H]),A[H]=z[H];fe+=128,_-=128}for(H=0;H<8;H++)ee(x,8*H,A[H]);return _}var si=new Uint8Array([106,9,230,103,243,188,201,8,187,103,174,133,132,202,167,59,60,110,243,114,254,148,248,43,165,79,245,58,95,29,54,241,81,14,82,127,173,230,130,209,155,5,104,140,43,62,108,31,31,131,217,171,251,65,189,107,91,224,205,25,19,126,33,121]);function ot(x,S,_){var A=new Uint8Array(64),N=new Uint8Array(256),z,I=_;for(z=0;z<64;z++)A[z]=si[z];for(el(A,S,_),_%=128,z=0;z<256;z++)N[z]=0;for(z=0;z<_;z++)N[z]=S[I-_+z];for(N[_]=128,_=256-128*(_<112?1:0),N[_-9]=0,ee(N,_-8,new n(I/536870912|0,I<<3)),el(A,N,_),z=0;z<64;z++)x[z]=A[z];return 0}function $t(x,S){var _=s(),A=s(),N=s(),z=s(),I=s(),Z=s(),H=s(),J=s(),fe=s();Ot(_,x[1],x[0]),Ot(fe,S[1],S[0]),Se(_,_,fe),jt(A,x[0],x[1]),jt(fe,S[0],S[1]),Se(A,A,fe),Se(N,x[3],S[3]),Se(N,N,E),Se(z,x[2],S[2]),jt(z,z,z),Ot(I,A,_),Ot(Z,z,N),jt(H,z,N),jt(J,A,_),Se(x[0],I,Z),Se(x[1],J,H),Se(x[2],H,Z),Se(x[3],I,J)}function Nt(x,S,_){var A;for(A=0;A<4;A++)we(x[A],S[A],_)}function Mr(x,S){var _=s(),A=s(),N=s();ti(N,S[2]),Se(_,S[0],N),Se(A,S[1],N),Te(x,A),x[31]^=Pt(_)<<7}function Rr(x,S,_){var A,N;for(xe(x[0],h),xe(x[1],m),xe(x[2],m),xe(x[3],h),N=255;N>=0;--N)A=_[N/8|0]>>(N&7)&1,Nt(x,S,A),$t(S,x),$t(x,x),Nt(x,S,A)}function Ri(x,S){var _=[s(),s(),s(),s()];xe(_[0],w),xe(_[1],T),xe(_[2],m),Se(_[3],w,T),Rr(x,_,S)}function ps(x,S,_){var A=new Uint8Array(64),N=[s(),s(),s(),s()],z;for(_||a(S,32),ot(A,S,32),A[0]&=248,A[31]&=127,A[31]|=64,Ri(N,A),Mr(x,N),z=0;z<32;z++)S[z+32]=x[z];return 0}var Gn=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function gs(x,S){var _,A,N,z;for(A=63;A>=32;--A){for(_=0,N=A-32,z=A-12;N<z;++N)S[N]+=_-16*S[A]*Gn[N-(A-32)],_=Math.floor((S[N]+128)/256),S[N]-=_*256;S[N]+=_,S[A]=0}for(_=0,N=0;N<32;N++)S[N]+=_-(S[31]>>4)*Gn[N],_=S[N]>>8,S[N]&=255;for(N=0;N<32;N++)S[N]-=_*Gn[N];for(A=0;A<32;A++)S[A+1]+=S[A]>>8,x[A]=S[A]&255}function Sn(x){var S=new Float64Array(64),_;for(_=0;_<64;_++)S[_]=x[_];for(_=0;_<64;_++)x[_]=0;gs(x,S)}function ii(x,S,_,A){var N=new Uint8Array(64),z=new Uint8Array(64),I=new Uint8Array(64),Z,H,J=new Float64Array(64),fe=[s(),s(),s(),s()];ot(N,A,32),N[0]&=248,N[31]&=127,N[31]|=64;var je=_+64;for(Z=0;Z<_;Z++)x[64+Z]=S[Z];for(Z=0;Z<32;Z++)x[32+Z]=N[32+Z];for(ot(I,x.subarray(32),_+32),Sn(I),Ri(fe,I),Mr(x,fe),Z=32;Z<64;Z++)x[Z]=A[Z];for(ot(z,x,_+64),Sn(z),Z=0;Z<64;Z++)J[Z]=0;for(Z=0;Z<32;Z++)J[Z]=I[Z];for(Z=0;Z<32;Z++)for(H=0;H<32;H++)J[Z+H]+=z[Z]*N[H];return gs(x.subarray(32),J),je}function ri(x,S){var _=s(),A=s(),N=s(),z=s(),I=s(),Z=s(),H=s();return xe(x[2],m),an(x[1],S),Tt(N,x[1]),Se(z,N,y),Ot(N,N,x[2]),jt(z,x[2],z),Tt(I,z),Tt(Z,I),Se(H,Z,I),Se(_,H,N),Se(_,_,z),Ni(_,_),Se(_,_,N),Se(_,_,z),Se(_,_,z),Se(x[0],_,z),Tt(A,x[0]),Se(A,A,z),lt(A,N)&&Se(x[0],x[0],q),Tt(A,x[0]),Se(A,A,z),lt(A,N)?-1:(Pt(x[0])===S[31]>>7&&Ot(x[0],h,x[0]),Se(x[3],x[0],x[1]),0)}function Dr(x,S,_,A){var N,z=new Uint8Array(32),I=new Uint8Array(64),Z=[s(),s(),s(),s()],H=[s(),s(),s(),s()];if(_<64||ri(H,A))return-1;for(N=0;N<_;N++)x[N]=S[N];for(N=0;N<32;N++)x[N+32]=A[N];if(ot(I,x,_),Sn(I),Rr(Z,H,I),Ri(H,S.subarray(32)),$t(Z,H),Mr(z,Z),_-=64,C(S,0,z,0)){for(N=0;N<_;N++)x[N]=0;return-1}for(N=0;N<_;N++)x[N]=S[N+64];return _}var Di=32,ys=24,En=32,bs=16,xs=32,ai=32,vs=32,Vn=32,li=32,zr=ys,tl=En,Rn=bs,Qe=64,it=32,Yt=64,oi=32,qr=64;r.lowlevel={crypto_core_hsalsa20:V,crypto_stream_xor:ke,crypto_stream:ne,crypto_stream_salsa20_xor:K,crypto_stream_salsa20:ae,crypto_onetimeauth:$,crypto_onetimeauth_verify:te,crypto_verify_16:re,crypto_verify_32:C,crypto_secretbox:de,crypto_secretbox_open:_e,crypto_scalarmult:ni,crypto_scalarmult_base:ln,crypto_box_beforenm:ms,crypto_box_afternm:Ia,crypto_box:Cr,crypto_box_open:kr,crypto_box_keypair:Ci,crypto_hash:ot,crypto_sign:ii,crypto_sign_keypair:ps,crypto_sign_open:Dr,crypto_secretbox_KEYBYTES:Di,crypto_secretbox_NONCEBYTES:ys,crypto_secretbox_ZEROBYTES:En,crypto_secretbox_BOXZEROBYTES:bs,crypto_scalarmult_BYTES:xs,crypto_scalarmult_SCALARBYTES:ai,crypto_box_PUBLICKEYBYTES:vs,crypto_box_SECRETKEYBYTES:Vn,crypto_box_BEFORENMBYTES:li,crypto_box_NONCEBYTES:zr,crypto_box_ZEROBYTES:tl,crypto_box_BOXZEROBYTES:Rn,crypto_sign_BYTES:Qe,crypto_sign_PUBLICKEYBYTES:it,crypto_sign_SECRETKEYBYTES:Yt,crypto_sign_SEEDBYTES:oi,crypto_hash_BYTES:qr,gf:s,D:y,L:Gn,pack25519:Te,unpack25519:an,M:Se,A:jt,S:Tt,Z:Ot,pow2523:Ni,add:$t,set25519:xe,modL:gs,scalarmult:Rr,scalarbase:Ri};function nl(x,S){if(x.length!==Di)throw new Error("bad key size");if(S.length!==ys)throw new Error("bad nonce size")}function sl(x,S){if(x.length!==vs)throw new Error("bad public key size");if(S.length!==Vn)throw new Error("bad secret key size")}function yt(){for(var x=0;x<arguments.length;x++)if(!(arguments[x]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function zi(x){for(var S=0;S<x.length;S++)x[S]=0}r.randomBytes=function(x){var S=new Uint8Array(x);return a(S,x),S},r.secretbox=function(x,S,_){yt(x,S,_),nl(_,S);for(var A=new Uint8Array(En+x.length),N=new Uint8Array(A.length),z=0;z<x.length;z++)A[z+En]=x[z];return de(N,A,A.length,S,_),N.subarray(bs)},r.secretbox.open=function(x,S,_){yt(x,S,_),nl(_,S);for(var A=new Uint8Array(bs+x.length),N=new Uint8Array(A.length),z=0;z<x.length;z++)A[z+bs]=x[z];return A.length<32||_e(N,A,A.length,S,_)!==0?null:N.subarray(En)},r.secretbox.keyLength=Di,r.secretbox.nonceLength=ys,r.secretbox.overheadLength=bs,r.scalarMult=function(x,S){if(yt(x,S),x.length!==ai)throw new Error("bad n size");if(S.length!==xs)throw new Error("bad p size");var _=new Uint8Array(xs);return ni(_,x,S),_},r.scalarMult.base=function(x){if(yt(x),x.length!==ai)throw new Error("bad n size");var S=new Uint8Array(xs);return ln(S,x),S},r.scalarMult.scalarLength=ai,r.scalarMult.groupElementLength=xs,r.box=function(x,S,_,A){var N=r.box.before(_,A);return r.secretbox(x,S,N)},r.box.before=function(x,S){yt(x,S),sl(x,S);var _=new Uint8Array(li);return ms(_,x,S),_},r.box.after=r.secretbox,r.box.open=function(x,S,_,A){var N=r.box.before(_,A);return r.secretbox.open(x,S,N)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var x=new Uint8Array(vs),S=new Uint8Array(Vn);return Ci(x,S),{publicKey:x,secretKey:S}},r.box.keyPair.fromSecretKey=function(x){if(yt(x),x.length!==Vn)throw new Error("bad secret key size");var S=new Uint8Array(vs);return ln(S,x),{publicKey:S,secretKey:new Uint8Array(x)}},r.box.publicKeyLength=vs,r.box.secretKeyLength=Vn,r.box.sharedKeyLength=li,r.box.nonceLength=zr,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(x,S){if(yt(x,S),S.length!==Yt)throw new Error("bad secret key size");var _=new Uint8Array(Qe+x.length);return ii(_,x,x.length,S),_},r.sign.open=function(x,S){if(yt(x,S),S.length!==it)throw new Error("bad public key size");var _=new Uint8Array(x.length),A=Dr(_,x,x.length,S);if(A<0)return null;for(var N=new Uint8Array(A),z=0;z<N.length;z++)N[z]=_[z];return N},r.sign.detached=function(x,S){for(var _=r.sign(x,S),A=new Uint8Array(Qe),N=0;N<A.length;N++)A[N]=_[N];return A},r.sign.detached.verify=function(x,S,_){if(yt(x,S,_),S.length!==Qe)throw new Error("bad signature size");if(_.length!==it)throw new Error("bad public key size");var A=new Uint8Array(Qe+x.length),N=new Uint8Array(Qe+x.length),z;for(z=0;z<Qe;z++)A[z]=S[z];for(z=0;z<x.length;z++)A[z+Qe]=x[z];return Dr(N,A,A.length,_)>=0},r.sign.keyPair=function(){var x=new Uint8Array(it),S=new Uint8Array(Yt);return ps(x,S),{publicKey:x,secretKey:S}},r.sign.keyPair.fromSecretKey=function(x){if(yt(x),x.length!==Yt)throw new Error("bad secret key size");for(var S=new Uint8Array(it),_=0;_<S.length;_++)S[_]=x[32+_];return{publicKey:S,secretKey:new Uint8Array(x)}},r.sign.keyPair.fromSeed=function(x){if(yt(x),x.length!==oi)throw new Error("bad seed size");for(var S=new Uint8Array(it),_=new Uint8Array(Yt),A=0;A<32;A++)_[A]=x[A];return ps(S,_,!0),{publicKey:S,secretKey:_}},r.sign.publicKeyLength=it,r.sign.secretKeyLength=Yt,r.sign.seedLength=oi,r.sign.signatureLength=Qe,r.hash=function(x){yt(x);var S=new Uint8Array(qr);return ot(S,x,x.length),S},r.hash.hashLength=qr,r.verify=function(x,S){return yt(x,S),x.length===0||S.length===0||x.length!==S.length?!1:me(x,0,S,0,x.length)===0},r.setPRNG=function(x){a=x},(function(){var x=typeof globalThis<"u"?globalThis.crypto||globalThis.msCrypto:null;if(x&&x.getRandomValues){var S=65536;r.setPRNG(function(_,A){var N,z=new Uint8Array(A);for(N=0;N<A;N+=S)x.getRandomValues(z.subarray(N,N+Math.min(A-N,S)));for(N=0;N<A;N++)_[N]=z[N];zi(z)})}else typeof require<"u"&&(x=require("crypto"),x&&x.randomBytes&&r.setPRNG(function(_,A){var N,z=x.randomBytes(A);for(N=0;N<A;N++)_[N]=z[N];zi(z)}))})()})(typeof module<"u"&&module.exports?module.exports:globalThis.nacl=globalThis.nacl||{});const bo=typeof module<"u"&&module.exports?module.exports:globalThis.nacl;bo.sign.keyPair.fromSeed,bo.sign.detached,bo.sign.detached.verify,bo.randomBytes;var N0;(function(r){r.InvalidPrefixByte="nkeys: invalid prefix byte",r.InvalidKey="nkeys: invalid key",r.InvalidPublicKey="nkeys: invalid public key",r.InvalidSeedLen="nkeys: invalid seed length",r.InvalidSeed="nkeys: invalid seed",r.InvalidEncoding="nkeys: invalid encoded key",r.InvalidSignature="nkeys: signature verification failed",r.CannotSign="nkeys: cannot sign, no private key available",r.PublicKeyOnly="nkeys: no seed or private key available",r.InvalidChecksum="nkeys: invalid checksum",r.SerializationError="nkeys: serialization error",r.ApiError="nkeys: api error",r.ClearedPair="nkeys: pair is cleared"})(N0||(N0={}));var C0;(function(r){r[r.Seed=144]="Seed",r[r.Private=120]="Private",r[r.Operator=112]="Operator",r[r.Server=104]="Server",r[r.Cluster=16]="Cluster",r[r.Account=0]="Account",r[r.User=160]="User"})(C0||(C0={}));function f1(r){return n=>{let s={};return r.forEach(a=>{const o=a(n)||{};s=Object.assign(s,o)}),s}}function h1(){return()=>{}}function d1(r,n){return()=>{const s=typeof r=="function"?r():r,a=typeof n=="function"?n():n;return{user:s,pass:a}}}function m1(r){return()=>({auth_token:typeof r=="function"?r():r})}const Ng=120*1e3,p1=2,Cg=2*1e3;function g1(){return{maxPingOut:2,maxReconnectAttempts:10,noRandomize:!1,pedantic:!1,pingInterval:Ng,reconnect:!0,reconnectJitter:100,reconnectJitterTLS:1e3,reconnectTimeWait:Cg,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function y1(r){const n=[];return typeof r.authenticator=="function"&&n.push(r.authenticator),Array.isArray(r.authenticator)&&n.push(...r.authenticator),r.token&&n.push(m1(r.token)),r.user&&n.push(d1(r.user,r.pass)),n.length===0?h1():f1(n)}function b1(r){const n=`${Of}:${jg()}`;if(r=r||{servers:[n]},r.servers=r.servers||[],typeof r.servers=="string"&&(r.servers=[r.servers]),r.servers.length>0&&r.port)throw new ue("port and servers options are mutually exclusive",ie.InvalidOption);r.servers.length===0&&r.port&&(r.servers=[`${Of}:${r.port}`]),r.servers&&r.servers.length===0&&(r.servers=[n]);const s=Yo(g1(),r);if(s.authenticator=y1(s),["reconnectDelayHandler","authenticator"].forEach(a=>{if(s[a]&&typeof s[a]!="function")throw new ue(`${a} option should be a function`,ie.NotFunction)}),s.reconnectDelayHandler||(s.reconnectDelayHandler=()=>{let a=s.tls?s.reconnectJitterTLS:s.reconnectJitter;return a&&(a++,a=Math.floor(Math.random()*a)),s.reconnectTimeWait+a}),s.inboxPrefix)try{fs(s.inboxPrefix)}catch(a){throw new ue(a.message,ie.ApiError)}if(s.resolve===void 0&&(s.resolve=typeof zf()=="function"),s.resolve&&typeof zf()!="function")throw new ue("'resolve' is not supported on this client",ie.InvalidOption);return s}function x1(r,n){const{proto:s,tls_required:a,tls_available:o}=r;if((s===void 0||s<1)&&n.noEcho)throw new ue("noEcho",ie.ServerOptionNotAvailable);const f=a||o||!1;if(n.tls&&!f)throw new ue("tls",ie.ServerOptionNotAvailable)}const v1=1024*32,_1=/^INFO\s+([^\r\n]+)\r\n/i,w1=Da(`PONG\r
38
38
  `),k0=Da(`PING\r
39
39
  `);class S1{constructor(n,s,a){v(this,"echo");v(this,"no_responders");v(this,"protocol");v(this,"verbose");v(this,"pedantic");v(this,"jwt");v(this,"nkey");v(this,"sig");v(this,"user");v(this,"pass");v(this,"auth_token");v(this,"tls_required");v(this,"name");v(this,"lang");v(this,"version");v(this,"headers");this.protocol=1,this.version=n.version,this.lang=n.lang,this.echo=s.noEcho?!1:void 0,this.verbose=s.verbose,this.pedantic=s.pedantic,this.tls_required=s.tls?!0:void 0,this.name=s.name;const o=(s&&typeof s.authenticator=="function"?s.authenticator(a):{})||{};Yo(this,o)}}class kg extends _t{constructor(s,a,o={}){var h;super();v(this,"sid");v(this,"queue");v(this,"draining");v(this,"max");v(this,"subject");v(this,"drained");v(this,"protocol");v(this,"timer");v(this,"info");v(this,"cleanupFn");v(this,"closed");v(this,"requestSubject");Yo(this,o),this.protocol=s,this.subject=a,this.draining=!1,this.noIterator=typeof o.callback=="function",this.closed=st();const f=!((h=s.options)!=null&&h.noAsyncTraces);o.timeout&&(this.timer=Ar(o.timeout,f),this.timer.then(()=>{this.timer=void 0}).catch(m=>{this.stop(m),this.noIterator&&this.callback(m,{})})),this.noIterator||this.iterClosed.then(()=>{this.closed.resolve(),this.unsubscribe()})}setPrePostHandlers(s){if(this.noIterator){const a=this.callback,o=s.ingestionFilterFn?s.ingestionFilterFn:()=>({ingest:!0,protocol:!1}),f=s.protocolFilterFn?s.protocolFilterFn:()=>!0,h=s.dispatchedFn?s.dispatchedFn:()=>{};this.callback=(m,g)=>{const{ingest:y}=o(g);y&&f(g)&&(a(m,g),h(g))}}else this.protocolFilterFn=s.protocolFilterFn,this.dispatchedFn=s.dispatchedFn}callback(s,a){this.cancelTimeout(),s?this.stop(s):this.push(a)}close(){if(!this.isClosed()){this.cancelTimeout();const s=()=>{if(this.stop(),this.cleanupFn)try{this.cleanupFn(this,this.info)}catch{}this.closed.resolve()};this.noIterator?s():this.push(s)}}unsubscribe(s){this.protocol.unsubscribe(this,s)}cancelTimeout(){this.timer&&(this.timer.cancel(),this.timer=void 0)}drain(){return this.protocol.isClosed()?Promise.reject(ue.errorForCode(ie.ConnectionClosed)):this.isClosed()?Promise.reject(ue.errorForCode(ie.SubClosed)):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush(st()).then(()=>{this.protocol.subscriptions.cancel(this)}).catch(()=>{this.protocol.subscriptions.cancel(this)})),this.drained)}isDraining(){return this.draining}isClosed(){return this.done}getSubject(){return this.subject}getMax(){return this.max}getID(){return this.sid}}class E1{constructor(){v(this,"mux");v(this,"subs");v(this,"sidCounter");this.sidCounter=0,this.mux=null,this.subs=new Map}size(){return this.subs.size}add(n){return this.sidCounter++,n.sid=this.sidCounter,this.subs.set(n.sid,n),n}setMux(n){return this.mux=n,n}getMux(){return this.mux}get(n){return this.subs.get(n)}resub(n){return this.sidCounter++,this.subs.delete(n.sid),n.sid=this.sidCounter,this.subs.set(n.sid,n),n}all(){return Array.from(this.subs.values())}cancel(n){n&&(n.close(),this.subs.delete(n.sid))}handleError(n){if(n&&n.permissionContext){const s=n.permissionContext,a=this.all();let o;if(s.operation==="subscription"&&(o=a.find(f=>f.subject===s.subject&&f.queue===s.queue)),s.operation==="publish"&&(o=a.find(f=>f.requestSubject===s.subject)),o)return o.callback(n,{}),o.close(),this.subs.delete(o.sid),o!==this.mux}return!1}close(){this.subs.forEach(n=>{n.close()})}}class Uo{constructor(n,s){v(this,"connected");v(this,"connectedOnce");v(this,"infoReceived");v(this,"info");v(this,"muxSubscriptions");v(this,"options");v(this,"outbound");v(this,"pongs");v(this,"subscriptions");v(this,"transport");v(this,"noMorePublishing");v(this,"connectError");v(this,"publisher");v(this,"_closed");v(this,"closed");v(this,"listeners");v(this,"heartbeats");v(this,"parser");v(this,"outMsgs");v(this,"inMsgs");v(this,"outBytes");v(this,"inBytes");v(this,"pendingLimit");v(this,"lastError");v(this,"abortReconnect");v(this,"whyClosed");v(this,"servers");v(this,"server");v(this,"features");v(this,"connectPromise");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=v1,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=n,this.publisher=s,this.subscriptions=new E1,this.muxSubscriptions=new a1,this.outbound=new Or,this.pongs=[],this.whyClosed="",this.pendingLimit=n.pendingLimit||this.pendingLimit,this.features=new Hv({major:0,minor:0,micro:0}),this.connectPromise=null;const a=typeof n.servers=="string"?[n.servers]:n.servers;this.servers=new r1(a,{randomize:!n.noRandomize}),this.closed=st(),this.parser=new T0(this),this.heartbeats=new l1(this,this.options.pingInterval||Ng,this.options.maxPingOut||p1)}resetOutbound(){this.outbound.reset();const n=this.pongs;this.pongs=[];const s=ue.errorForCode(ie.Disconnect);s.stack="",n.forEach(a=>{a.reject(s)}),this.parser=new T0(this),this.infoReceived=!1}dispatchStatus(n){this.listeners.forEach(s=>{s.push(n)})}status(){const n=new _t;return this.listeners.push(n),n}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const n=st();return n.catch(()=>{}),this.pongs.unshift(n),this.connectError=s=>{n.reject(s)},this.transport=Yv(),this.transport.closed().then(async s=>{if(this.connected=!1,!this.isClosed()){await this.disconnected(this.transport.closeError||this.lastError);return}}),n}disconnect(){this.dispatchStatus({type:vr.StaleConnection,data:""}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:vr.ClientInitiatedReconnect,data:""}),this.transport.disconnect()),Promise.resolve()}async disconnected(n){this.dispatchStatus({type:us.Disconnect,data:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{var s;this.dispatchStatus({type:us.Reconnect,data:this.servers.getCurrentServer().toString()}),((s=this.lastError)==null?void 0:s.code)===ie.AuthenticationExpired&&(this.lastError=void 0)}).catch(s=>{this._close(s)}):await this._close(n)}async dial(n){const s=this.prepare();let a;try{a=Ar(this.options.timeout||2e4);const o=this.transport.connect(n,this.options);await Promise.race([o,a]),(async()=>{try{for await(const f of this.transport)this.parser.parse(f)}catch(f){console.log("reader closed",f)}})().then()}catch(o){s.reject(o)}try{await Promise.race([a,s]),a&&a.cancel(),this.connected=!0,this.connectError=void 0,this.sendSubscriptions(),this.connectedOnce=!0,this.server.didConnect=!0,this.server.reconnects=0,this.flushPending(),this.heartbeats.start()}catch(o){throw a&&a.cancel(),await this.transport.close(o),o}}async _doDial(n){const{resolve:s}=this.options,a=await n.resolve({fn:zf(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:s});let o=null;for(const f of a)try{o=null,this.dispatchStatus({type:vr.Reconnecting,data:f.toString()}),await this.dial(f);return}catch(h){o=h}throw o}dialLoop(){return this.connectPromise===null&&(this.connectPromise=this.dodialLoop(),this.connectPromise.then(()=>{}).catch(()=>{}).finally(()=>{this.connectPromise=null})),this.connectPromise}async dodialLoop(){let n;for(;;){this._closed&&this.servers.clear();const s=this.options.reconnectDelayHandler?this.options.reconnectDelayHandler():Cg;let a=s;const o=this.selectServer();if(!o||this.abortReconnect)throw n||(this.lastError?this.lastError:ue.errorForCode(ie.ConnectionRefused));const f=Date.now();if(o.lastConnect===0||o.lastConnect+s<=f){o.lastConnect=Date.now();try{await this._doDial(o);break}catch(h){if(n=h,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}o.reconnects++;const m=this.options.maxReconnectAttempts||0;m!==-1&&o.reconnects>=m&&this.servers.removeCurrentServer()}}else a=Math.min(a,o.lastConnect+s-f),await Tr(a)}}static async connect(n,s){const a=new Uo(n,s);return await a.dialLoop(),a}static toError(n){const s=n?n.toLowerCase():"";if(s.indexOf("permissions violation")!==-1){const a=new ue(n,ie.PermissionsViolation),o=n.match(/(Publish|Subscription) to "(\S+)"/);if(o){a.permissionContext={operation:o[1].toLowerCase(),subject:o[2],queue:void 0};const f=n.match(/using queue "(\S+)"/);f&&(a.permissionContext.queue=f[1])}return a}else return s.indexOf("authorization violation")!==-1?new ue(n,ie.AuthorizationViolation):s.indexOf("user authentication expired")!==-1?new ue(n,ie.AuthenticationExpired):s.indexOf("account authentication expired")!=-1?new ue(n,ie.AccountExpired):s.indexOf("authentication timeout")!==-1?new ue(n,ie.AuthenticationTimeout):new ue(n,ie.ProtocolError)}processMsg(n,s){if(this.inMsgs++,this.inBytes+=s.length,!this.subscriptions.sidCounter)return;const a=this.subscriptions.get(n.sid);a&&(a.received+=1,a.callback&&a.callback(null,new nh(n,s,this)),a.max!==void 0&&a.received>=a.max&&a.unsubscribe())}processError(n){const s=d0(n),a=Uo.toError(s),o={type:us.Error,data:a.code};if(a.isPermissionError()){let f=!1;if(a.permissionContext){o.permissionContext=a.permissionContext;const h=this.subscriptions.getMux();f=(h==null?void 0:h.subject)===a.permissionContext.subject}this.subscriptions.handleError(a),this.muxSubscriptions.handleError(f,a),f&&this.subscriptions.setMux(null)}this.dispatchStatus(o),this.handleError(a)}handleError(n){n.isAuthError()?this.handleAuthError(n):n.isProtocolError()?this.lastError=n:n.isAuthTimeout()&&(this.lastError=n),n.isPermissionError()||(this.lastError=n)}handleAuthError(n){this.lastError&&n.code===this.lastError.code&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(n):this.disconnect()}processPing(){this.transport.send(w1)}processPong(){const n=this.pongs.shift();n&&n.resolve()}processInfo(n){const s=JSON.parse(d0(n));this.info=s;const a=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(s,this.transport.isEncrypted());if(!this.infoReceived){this.features.update(ji(s.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:f,lang:h}=this.transport;try{const m=new S1({version:f,lang:h},this.options,s.nonce);s.headers&&(m.headers=!0,m.no_responders=!0);const g=JSON.stringify(m);this.transport.send(Da(`CONNECT ${g}${Eo}`)),this.transport.send(k0)}catch(m){this._close(m)}}a&&this.dispatchStatus({type:us.Update,data:a}),(s.ldm!==void 0?s.ldm:!1)&&this.dispatchStatus({type:us.LDM,data:this.servers.getCurrentServer().toString()})}push(n){switch(n.kind){case Rt.MSG:{const{msg:s,data:a}=n;this.processMsg(s,a);break}case Rt.OK:break;case Rt.ERR:this.processError(n.data);break;case Rt.PING:this.processPing();break;case Rt.PONG:this.processPong();break;case Rt.INFO:this.processInfo(n.data);break}}sendCommand(n,...s){const a=this.outbound.length();let o;typeof n=="string"?o=Da(n):o=n,this.outbound.fill(o,...s),a===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(n,s=nn,a){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=Ti.encode(s);else throw ue.errorForCode(ie.BadPayload);let f=o.length;a=a||{},a.reply=a.reply||"";let h=nn,m=0;if(a.headers){if(this.info&&!this.info.headers)throw new ue("headers",ie.ServerOptionNotAvailable);h=a.headers.encode(),m=h.length,f=o.length+m}if(this.info&&f>this.info.max_payload)throw ue.errorForCode(ie.MaxPayloadExceeded);this.outBytes+=f,this.outMsgs++;let g;a.headers?(a.reply?g=`HPUB ${n} ${a.reply} ${m} ${f}\r
40
40
  `:g=`HPUB ${n} ${m} ${f}\r
@@ -50,7 +50,7 @@ ${g}`),w(M);return}m(null,D),a.strategy===kn.Count&&(y--,y===0&&w()),a.strategy=
50
50
 
51
51
  ${m.stack}`),g.unsubscribe(),h.reject(y)):(y=wg(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 Ag(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 F1(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 X1(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 X1{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 N1(this.nc,n,s)}}class K1{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 Z1{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 zg extends Pv{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=_v(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 W1 extends zg{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 e_(r,n){return r?n_(n):t_(n)}function t_(r){return(n,s)=>n?[n,null]:(n=wr(s),n?[n,null]:[null,$a(s,r)])}function n_(r){return(n,s)=>{if(n)return[n,null];const a=wr(s);return a!==null?[qg(a),null]:[null,$a(s,r)]}}function qg(r){if(r!==null)switch(r.code){case ie.JetStream404NoMessages:case ie.JetStream408RequestTimeout:return null;case ie.JetStream409:return wv(r)?r:null;default:return r}return null}function s_(r){r&&r.ack()}function i_(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 r_{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=i_(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 Ag(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=L1;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(H1,$1,o),h=n?{reply:n}:void 0;this.msg.respond(f,h)}term(n=""){let s=P1;(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 a_="1.30.3",l_="nats.ws";class o_{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=a_,this.lang=l_,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=Jv(h);if(m!==""){const g=_1.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]);x1(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 c_(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 u_(r={}){return $v({defaultPort:443,urlParseFn:c_,factory:()=>new o_}),lh.connect(r)}const f_=null,h_=null,d_="lt.events";function Ug(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 m_(){const{connected:r}=O.useContext(Fa);return{connected:r}}function p_(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 g_=O.createContext({connected:!1,subscribe:()=>()=>{}}),y_=Tf();function b_({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 D=M.get(T);D&&(D.delete(q),D.size===0&&M.delete(T))}},[]),E=O.useCallback((T,q)=>{for(const[M,D]of g.current)if(Ug(T,M))for(const W of D)try{W(q)}catch{}},[]),w=O.useCallback(async()=>{try{if(a.current)return;const T=n||f_;if(!T){console.error("[lt-nats] no NATS WebSocket URL configured — set NATS_WS_URL on the server");return}const q=await u_({servers:T,token:s||h_||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 D of M)try{const W=JSON.parse(y_.decode(D.data));E(D.subject,W)}catch{}})(),(async()=>{for await(const D of q.status())D.type==="disconnect"||D.type==="error"?h(!1):D.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(g_.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"},Bg=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Lg=typeof ArrayBuffer=="function",Hg=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,oh=({type:r,data:n},s,a)=>Bg&&n instanceof Blob?s?a(n):U0(n,a):Lg&&(n instanceof ArrayBuffer||Hg(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 x_(r,n){if(Bg&&r.data instanceof Blob)return r.data.arrayBuffer().then(B0).then(n);if(Lg&&(r.data instanceof ArrayBuffer||Hg(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 v_=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},__=typeof ArrayBuffer=="function",ch=(r,n)=>{if(typeof r!="string")return{type:"message",data:Pg(r,n)};const s=r.charAt(0);return s==="b"?{type:"message",data:w_(r.substring(1),n)}:jo[s]?r.length>1?{type:jo[s],data:r.substring(1)}:{type:jo[s]}:$f},w_=(r,n)=>{if(__){const s=v_(r);return Pg(s,n)}else return{base64:!0,data:r}},Pg=(r,n)=>{switch(n){case"blob":return r instanceof Blob?r:new Blob([r]);case"arraybuffer":default:return r instanceof ArrayBuffer?r:r.buffer}},$g="",S_=(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($g))})})},E_=(r,n)=>{const s=r.split($g),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 A_(){return new TransformStream({transform(r,n){x_(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 j_(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 Yg=4;function gt(r){if(r)return O_(r)}function O_(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")(),T_="arraybuffer";function Gg(r,...n){return n.reduce((s,a)=>(r.hasOwnProperty(a)&&(s[a]=r[a]),s),{})}const N_=vn.setTimeout,C_=vn.clearTimeout;function Io(r,n){n.useNativeTimers?(r.setTimeoutFn=N_.bind(vn),r.clearTimeoutFn=C_.bind(vn)):(r.setTimeoutFn=vn.setTimeout.bind(vn),r.clearTimeoutFn=vn.clearTimeout.bind(vn))}const k_=1.33;function M_(r){return typeof r=="string"?R_(r):Math.ceil((r.byteLength||r.size)*k_)}function R_(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 Vg(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function D_(r){let n="";for(let s in r)r.hasOwnProperty(s)&&(n.length&&(n+="&"),n+=encodeURIComponent(s)+"="+encodeURIComponent(r[s]));return n}function z_(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 q_ 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 q_(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=D_(n);return s.length?"?"+s:""}}class U_ 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)};E_(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,S_(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]=Vg()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(n,s)}}let Fg=!1;try{Fg=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const B_=Fg;function L_(){}class H_ extends U_{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=Gg(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=L_,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 P_=(function(){const r=Jg({xdomain:!1});return r&&r.responseType!==null})();class $_ extends H_{constructor(n){super(n);const s=n&&n.forceBase64;this.supportsBinary=P_&&!s}request(n={}){return Object.assign(n,{xd:this.xd},this.opts),new Pn(Jg,this.uri(),n)}}function Jg(r){const n=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!n||B_))return new XMLHttpRequest}catch{}if(!n)try{return new vn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Ig=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Y_ extends uh{get name(){return"websocket"}doOpen(){const n=this.uri(),s=this.opts.protocols,a=Ig?{}:Gg(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]=Vg()),this.supportsBinary||(s.b64=1),this.createUri(n,s)}}const vf=vn.WebSocket||vn.MozWebSocket;class G_ extends Y_{createSocket(n,s,a){return Ig?new vf(n,s,a):s?new vf(n,s):new vf(n)}doWrite(n,s){this.ws.send(s)}}class V_ 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=j_(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=n.readable.pipeThrough(s).getReader(),o=A_();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 F_={websocket:G_,webtransport:V_,polling:$_},J_=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,I_=["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=J_.exec(r||""),f={},h=14;for(;h--;)f[I_[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=Q_(f,f.path),f.queryKey=X_(f,f.query),f}function Q_(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 X_(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=T_,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=z_(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=Yg,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+=M_(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=Yg;class K_ 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 Z_=class extends K_{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=>F_[o]).filter(o=>!!o)),super(n,a)}};function W_(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 ew=typeof ArrayBuffer=="function",tw=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Qg=Object.prototype.toString,nw=typeof Blob=="function"||typeof Blob<"u"&&Qg.call(Blob)==="[object BlobConstructor]",sw=typeof File=="function"||typeof File<"u"&&Qg.call(File)==="[object FileConstructor]";function fh(r){return ew&&(r instanceof ArrayBuffer||tw(r))||nw&&r instanceof Blob||sw&&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 iw(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 rw(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 aw=["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 lw{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=iw(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 ow(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(!cw(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"&&aw.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 ow{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=rw(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const cw=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 uw=Object.freeze(Object.defineProperty({__proto__:null,Decoder:hh,Encoder:lw,get PacketType(){return qe}},Symbol.toStringTag,{value:"Module"}));function Cn(r,n,s){return r.on(n,s),function(){r.off(n,s)}}const fw=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Xg 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(fw.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||uw;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 Z_(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 Xg(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=W_(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:Xg,io:No,connect:No});const hw=O.createContext({connected:!1,subscribe:()=>()=>{}});function dw({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(Ug(m,y))for(const w of E)try{w(g)}catch{}},[]);return O.useEffect(()=>{const m=bg(),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(hw.Provider,{value:{connected:s,subscribe:f},children:d.jsx(Fa.Provider,{value:{connected:s,subscribe:f},children:r})})}function mw({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=bg();if(q)try{const M=await fetch(`${Wt}/api/nats-credentials`,{headers:{Authorization:`Bearer ${q}`}});if(M.ok){const D=await M.json();w=D.natsWsUrl??w,T=D.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(b_,{url:a.url,token:a.token,children:r}):n==="socketio"?d.jsx(dw,{children:r}):d.jsx(d.Fragment,{children:r})}function Kg(){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 pw(){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:pw,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 gw(){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 Zg=O.createContext(null),$0="lt_sidebar_collapsed";function yw({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(Zg.Provider,{value:{collapsed:n,toggle:a},children:r})}function Wg(){const r=O.useContext(Zg);if(!r)throw new Error("useSidebar must be used within SidebarProvider");return r}function ey(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 zE(r){const n=r??"24h";return _n({queryKey:["stationMetrics",n],queryFn:()=>$e(`/escalations/station-metrics?period=${n}`),staleTime:5e3})}function qE(r){const n=r?`?period=${r}`:"";return _n({queryKey:["escalationStats",r],queryFn:()=>$e(`/escalations/stats${n}`)})}function UE(){return _n({queryKey:["escalationTypes"],queryFn:()=>$e("/escalations/types")})}function BE(r=!0){return _n({queryKey:["escalationFacetKeys"],queryFn:()=>$e("/escalations/facet-keys"),enabled:r,staleTime:6e4})}function bw(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),ey(o,a),_n({queryKey:["escalations",a],queryFn:()=>$e(`/escalations?${o}`),enabled:n,...s!==void 0?{staleTime:s}:{}})}function xw(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),ey(o,a),_n({queryKey:["escalations","available",a],queryFn:()=>$e(`/escalations/available?${o}`),enabled:n,...s!==void 0?{staleTime:s}:{}})}function LE(r){return _n({queryKey:["escalations","by-workflow",r],queryFn:()=>$e(`/escalations/by-workflow/${r}`),enabled:!!r})}function HE(r){return _n({queryKey:["escalations",r],queryFn:()=>$e(`/escalations/${r}`),enabled:!!r})}function PE(){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 $E(){const r=rn();return wn({mutationFn:n=>$e(`/escalations/${n}/release`,{method:"POST"}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function YE(){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 GE(){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 VE(){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 FE(){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 JE(){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 IE(){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 QE(){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 XE(){const r=rn();return wn({mutationFn:n=>$e(`/escalations/${n}/cancel`,{method:"POST"}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function KE(){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 vw(){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]);p_(`${d_}.system.escalation.>`,o);const{data:f}=xw({limit:1}),{data:h}=bw({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("img",{src:`${Wt}/logo512.png`,alt:"LongTail",className:`shrink-0 z-0 ${o}`}),d.jsx("span",{className:`z-[1] transition-opacity duration-300 ${f} ${n?"opacity-0":""}`,children:"LongTail"})]})}function _w({onToggleEventFeed:r,onToggleDocs:n}){const{user:s,logout:a}=Oi(),{isBuilder:o}=Kg(),{available:f,mine:h}=vw(),{connected:m}=m_(),{toggleAIOverride:g}=gw(),[y,E]=O.useState(!1),w=O.useRef(null);return O.useEffect(()=>{if(!y)return;const T=q=>{w.current&&!w.current.contains(q.target)&&E(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[y]),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:T=>{(T.ctrlKey||T.metaKey)&&(T.preventDefault(),g())},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 ${f>0?"text-blue-400 hover:text-blue-300":"text-text-quaternary hover:text-text-secondary"}`,title:"Available escalations",children:[d.jsx(Ef,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"available",f>0&&d.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:f})]}),d.jsxs(yr,{to:"/escalations/queue",className:`flex items-center gap-1.5 text-[11px] transition-colors ${h>0?"text-status-warning hover:text-amber-300":"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",h>0&&d.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:h})]}),o&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"w-px h-4 bg-surface-border"}),d.jsxs("button",{type:"button",onClick:()=>{m?r==null||r():window.location.reload()},className:`flex items-center gap-1.5 text-[11px] transition-colors ${m?"text-emerald-400 hover:text-emerald-300":"text-text-quaternary hover:text-text-secondary"}`,title:m?"Live events — click to toggle feed":"Events disconnected — click to reconnect",children:[d.jsx(dg,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"events"]}),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(mg,{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:w,children:[d.jsxs("button",{onClick:()=>E(T=>!T),className:"btn-ghost text-xs flex items-center gap-1",children:[d.jsx(kx,{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"})})]}),y&&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:()=>E(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),d.jsx("button",{onClick:()=>{E(!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 ww(){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 Sw({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:ww(),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 Ew(r){return r.kind==="group"}function Aw({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}=Wg();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=>Ew(a)?d.jsx(Sw,{group:a,collapsed:s},a.label):d.jsx(Aw,{entry:a,collapsed:s},a.to))]})}function jw({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:"Available",icon:Af}];return d.jsx(Ks,{heading:"Work",entries:o})}if(!n)return d.jsx(Ks,{heading:"React",entries:[{to:"/operations",label:"Operations",icon:s0}]});const a=[...s||n?[{to:"/operations",label:"Operations",icon:s0}]:[],{to:"/topics",label:"Event Topics",icon:dg},{to:"/agents",label:r?"Agents":"Automations",icon:Mx},{to:"/capabilities",label:"Capabilities",icon:Rx}];return d.jsx(Ks,{heading:"React",entries:a})}function Ow(){const r=[{kind:"group",label:"Procedural",icon:Dx,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 Tw=[{to:"/mcp/queries",label:"Designer",icon:zx},{to:"/mcp/servers",label:"Servers & Tools",icon:qx}];function Nw(){return d.jsx(Ks,{heading:"Design",entries:Tw})}const Cw=[{to:"/files",label:"Files",icon:Ux},{to:"/knowledge",label:"Knowledge",icon:Bx}];function kw(){return d.jsx(Ks,{heading:"Storage",entries:Cw})}function Mw({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:Lx},...r||n?[{to:"/admin/roles",label:"Roles",icon:Hx}]:[]],f=[{to:"/admin/controlplane",label:"Routers",icon:Px},{to:"/admin/streams",label:"Messages",icon:$x},...a?[{to:"/admin/maintenance",label:"DB Maintenance",icon:Yx}]:[]];return d.jsxs(d.Fragment,{children:[d.jsx(Ks,{heading:"Identity & Access",entries:o}),r&&d.jsx(Ks,{heading:"Infrastructure",entries:f})]})}const ty="lt_event_feed_patterns";function Rw(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 Dw(){try{const r=localStorage.getItem(ty);return r?JSON.parse(r):[]}catch{return[]}}function _f(r){try{localStorage.setItem(ty,JSON.stringify(r))}catch{}}function zw(){const{pathname:r}=ei(),[n,s]=O.useState(Dw),a=O.useMemo(()=>Rw(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 qw({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,Y0="cubic-bezier(0.4, 0, 0.2, 1)",wo=40;function Uw(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 ny({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?Uw(h.current):"none",w=y?0:1;return fg.createPortal(d.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${wf}ms ${Y0}, opacity ${wf}ms ${Y0}`,transform:E,opacity:w,backgroundColor:"#FFFFFF"},onTransitionEnd:g,children:a}),document.body)}function Bw({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 Lw({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 Hw({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 Pw({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 $w({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 Yw({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 Gw(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 Ag(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 F1(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 X1(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 X1{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 N1(this.nc,n,s)}}class K1{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 Z1{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 zg extends Pv{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=_v(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 W1 extends zg{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 e_(r,n){return r?n_(n):t_(n)}function t_(r){return(n,s)=>n?[n,null]:(n=wr(s),n?[n,null]:[null,$a(s,r)])}function n_(r){return(n,s)=>{if(n)return[n,null];const a=wr(s);return a!==null?[qg(a),null]:[null,$a(s,r)]}}function qg(r){if(r!==null)switch(r.code){case ie.JetStream404NoMessages:case ie.JetStream408RequestTimeout:return null;case ie.JetStream409:return wv(r)?r:null;default:return r}return null}function s_(r){r&&r.ack()}function i_(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 r_{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=i_(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 Ag(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=L1;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(H1,$1,o),h=n?{reply:n}:void 0;this.msg.respond(f,h)}term(n=""){let s=P1;(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 a_="1.30.3",l_="nats.ws";class o_{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=a_,this.lang=l_,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=Jv(h);if(m!==""){const g=_1.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]);x1(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 c_(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 u_(r={}){return $v({defaultPort:443,urlParseFn:c_,factory:()=>new o_}),lh.connect(r)}const f_=null,h_=null,d_="lt.events";function Ug(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 m_(){const{connected:r}=O.useContext(Fa);return{connected:r}}function p_(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 g_=O.createContext({connected:!1,subscribe:()=>()=>{}}),y_=Tf();function b_({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 D=M.get(T);D&&(D.delete(q),D.size===0&&M.delete(T))}},[]),E=O.useCallback((T,q)=>{for(const[M,D]of g.current)if(Ug(T,M))for(const W of D)try{W(q)}catch{}},[]),w=O.useCallback(async()=>{try{if(a.current)return;const T=n||f_;if(!T){console.error("[lt-nats] no NATS WebSocket URL configured — set NATS_WS_URL on the server");return}const q=await u_({servers:T,token:s||h_||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 D of M)try{const W=JSON.parse(y_.decode(D.data));E(D.subject,W)}catch{}})(),(async()=>{for await(const D of q.status())D.type==="disconnect"||D.type==="error"?h(!1):D.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(g_.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"},Bg=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Lg=typeof ArrayBuffer=="function",Hg=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,oh=({type:r,data:n},s,a)=>Bg&&n instanceof Blob?s?a(n):U0(n,a):Lg&&(n instanceof ArrayBuffer||Hg(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 x_(r,n){if(Bg&&r.data instanceof Blob)return r.data.arrayBuffer().then(B0).then(n);if(Lg&&(r.data instanceof ArrayBuffer||Hg(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 v_=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},__=typeof ArrayBuffer=="function",ch=(r,n)=>{if(typeof r!="string")return{type:"message",data:Pg(r,n)};const s=r.charAt(0);return s==="b"?{type:"message",data:w_(r.substring(1),n)}:jo[s]?r.length>1?{type:jo[s],data:r.substring(1)}:{type:jo[s]}:$f},w_=(r,n)=>{if(__){const s=v_(r);return Pg(s,n)}else return{base64:!0,data:r}},Pg=(r,n)=>{switch(n){case"blob":return r instanceof Blob?r:new Blob([r]);case"arraybuffer":default:return r instanceof ArrayBuffer?r:r.buffer}},$g="",S_=(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($g))})})},E_=(r,n)=>{const s=r.split($g),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 A_(){return new TransformStream({transform(r,n){x_(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 j_(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 Yg=4;function gt(r){if(r)return O_(r)}function O_(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")(),T_="arraybuffer";function Gg(r,...n){return n.reduce((s,a)=>(r.hasOwnProperty(a)&&(s[a]=r[a]),s),{})}const N_=vn.setTimeout,C_=vn.clearTimeout;function Io(r,n){n.useNativeTimers?(r.setTimeoutFn=N_.bind(vn),r.clearTimeoutFn=C_.bind(vn)):(r.setTimeoutFn=vn.setTimeout.bind(vn),r.clearTimeoutFn=vn.clearTimeout.bind(vn))}const k_=1.33;function M_(r){return typeof r=="string"?R_(r):Math.ceil((r.byteLength||r.size)*k_)}function R_(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 Vg(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function D_(r){let n="";for(let s in r)r.hasOwnProperty(s)&&(n.length&&(n+="&"),n+=encodeURIComponent(s)+"="+encodeURIComponent(r[s]));return n}function z_(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 q_ 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 q_(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=D_(n);return s.length?"?"+s:""}}class U_ 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)};E_(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,S_(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]=Vg()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(n,s)}}let Fg=!1;try{Fg=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const B_=Fg;function L_(){}class H_ extends U_{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=Gg(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=L_,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 P_=(function(){const r=Jg({xdomain:!1});return r&&r.responseType!==null})();class $_ extends H_{constructor(n){super(n);const s=n&&n.forceBase64;this.supportsBinary=P_&&!s}request(n={}){return Object.assign(n,{xd:this.xd},this.opts),new Pn(Jg,this.uri(),n)}}function Jg(r){const n=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!n||B_))return new XMLHttpRequest}catch{}if(!n)try{return new vn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Ig=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Y_ extends uh{get name(){return"websocket"}doOpen(){const n=this.uri(),s=this.opts.protocols,a=Ig?{}:Gg(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]=Vg()),this.supportsBinary||(s.b64=1),this.createUri(n,s)}}const vf=vn.WebSocket||vn.MozWebSocket;class G_ extends Y_{createSocket(n,s,a){return Ig?new vf(n,s,a):s?new vf(n,s):new vf(n)}doWrite(n,s){this.ws.send(s)}}class V_ 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=j_(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=n.readable.pipeThrough(s).getReader(),o=A_();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 F_={websocket:G_,webtransport:V_,polling:$_},J_=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,I_=["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=J_.exec(r||""),f={},h=14;for(;h--;)f[I_[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=Q_(f,f.path),f.queryKey=X_(f,f.query),f}function Q_(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 X_(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=T_,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=z_(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=Yg,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+=M_(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=Yg;class K_ 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 Z_=class extends K_{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=>F_[o]).filter(o=>!!o)),super(n,a)}};function W_(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 ew=typeof ArrayBuffer=="function",tw=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Qg=Object.prototype.toString,nw=typeof Blob=="function"||typeof Blob<"u"&&Qg.call(Blob)==="[object BlobConstructor]",sw=typeof File=="function"||typeof File<"u"&&Qg.call(File)==="[object FileConstructor]";function fh(r){return ew&&(r instanceof ArrayBuffer||tw(r))||nw&&r instanceof Blob||sw&&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 iw(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 rw(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 aw=["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 lw{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=iw(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 ow(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(!cw(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"&&aw.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 ow{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=rw(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const cw=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 uw=Object.freeze(Object.defineProperty({__proto__:null,Decoder:hh,Encoder:lw,get PacketType(){return qe}},Symbol.toStringTag,{value:"Module"}));function Cn(r,n,s){return r.on(n,s),function(){r.off(n,s)}}const fw=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Xg 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(fw.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||uw;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 Z_(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 Xg(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=W_(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:Xg,io:No,connect:No});const hw=O.createContext({connected:!1,subscribe:()=>()=>{}});function dw({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(Ug(m,y))for(const w of E)try{w(g)}catch{}},[]);return O.useEffect(()=>{const m=bg(),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(hw.Provider,{value:{connected:s,subscribe:f},children:d.jsx(Fa.Provider,{value:{connected:s,subscribe:f},children:r})})}function mw({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=bg();if(q)try{const M=await fetch(`${Wt}/api/nats-credentials`,{headers:{Authorization:`Bearer ${q}`}});if(M.ok){const D=await M.json();w=D.natsWsUrl??w,T=D.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(b_,{url:a.url,token:a.token,children:r}):n==="socketio"?d.jsx(dw,{children:r}):d.jsx(d.Fragment,{children:r})}function Kg(){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 pw(){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:pw,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 gw(){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 Zg=O.createContext(null),$0="lt_sidebar_collapsed";function yw({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(Zg.Provider,{value:{collapsed:n,toggle:a},children:r})}function Wg(){const r=O.useContext(Zg);if(!r)throw new Error("useSidebar must be used within SidebarProvider");return r}function ey(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 qE(r){const n=r??"24h";return _n({queryKey:["stationMetrics",n],queryFn:()=>$e(`/escalations/station-metrics?period=${n}`),staleTime:5e3})}function UE(r){const n=r?`?period=${r}`:"";return _n({queryKey:["escalationStats",r],queryFn:()=>$e(`/escalations/stats${n}`)})}function BE(){return _n({queryKey:["escalationTypes"],queryFn:()=>$e("/escalations/types")})}function LE(r=!0){return _n({queryKey:["escalationFacetKeys"],queryFn:()=>$e("/escalations/facet-keys"),enabled:r,staleTime:6e4})}function bw(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),ey(o,a),_n({queryKey:["escalations",a],queryFn:()=>$e(`/escalations?${o}`),enabled:n,...s!==void 0?{staleTime:s}:{}})}function xw(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),ey(o,a),_n({queryKey:["escalations","available",a],queryFn:()=>$e(`/escalations/available?${o}`),enabled:n,...s!==void 0?{staleTime:s}:{}})}function HE(r){return _n({queryKey:["escalations","by-workflow",r],queryFn:()=>$e(`/escalations/by-workflow/${r}`),enabled:!!r})}function PE(r){return _n({queryKey:["escalations",r],queryFn:()=>$e(`/escalations/${r}`),enabled:!!r})}function $E(){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 YE(){const r=rn();return wn({mutationFn:n=>$e(`/escalations/${n}/release`,{method:"POST"}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function GE(){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 VE(){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 FE(){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 JE(){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 IE(){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 QE(){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 XE(){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 KE(){const r=rn();return wn({mutationFn:n=>$e(`/escalations/${n}/cancel`,{method:"POST"}),onSuccess:()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]})}})}function ZE(){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 vw(){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]);p_(`${d_}.system.escalation.>`,o);const{data:f}=xw({limit:1}),{data:h}=bw({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("img",{src:`${Wt}/logo512.png`,alt:"LongTail",className:`shrink-0 z-0 ${o}`}),d.jsx("span",{className:`z-[1] transition-opacity duration-300 ${f} ${n?"opacity-0":""}`,children:"LongTail"})]})}function _w({onToggleEventFeed:r,onToggleDocs:n}){const{user:s,logout:a}=Oi(),{isBuilder:o,isOps:f}=Kg(),{available:h,mine:m}=vw(),{connected:g}=m_(),{toggleAIOverride:y}=gw(),[E,w]=O.useState(!1),T=O.useRef(null);return O.useEffect(()=>{if(!E)return;const q=M=>{T.current&&!T.current.contains(M.target)&&w(!1)};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[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:q=>{(q.ctrlKey||q.metaKey)&&(q.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-blue-400 hover:text-blue-300":"text-text-quaternary hover:text-text-secondary"}`,title:"Available escalations",children:[d.jsx(Ef,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"available",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-amber-300":"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-emerald-400 hover:text-emerald-300":"text-text-quaternary hover:text-text-secondary"}`,title:g?"Live events — click to toggle feed":"Events disconnected — click to reconnect",children:[d.jsx(dg,{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(mg,{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:T,children:[d.jsxs("button",{onClick:()=>w(q=>!q),className:"btn-ghost text-xs flex items-center gap-1",children:[d.jsx(kx,{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.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 ww(){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 Sw({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:ww(),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 Ew(r){return r.kind==="group"}function Aw({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}=Wg();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=>Ew(a)?d.jsx(Sw,{group:a,collapsed:s},a.label):d.jsx(Aw,{entry:a,collapsed:s},a.to))]})}function jw({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:"Available",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:dg},{to:"/agents",label:r?"Agents":"Automations",icon:Mx},{to:"/capabilities",label:"Capabilities",icon:Rx}];return d.jsx(Ks,{heading:"React",entries:a})}function Ow(){const r=[{kind:"group",label:"Procedural",icon:Dx,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 Tw=[{to:"/mcp/queries",label:"Designer",icon:zx},{to:"/mcp/servers",label:"Servers & Tools",icon:qx}];function Nw(){return d.jsx(Ks,{heading:"Design",entries:Tw})}const Cw=[{to:"/files",label:"Files",icon:Ux},{to:"/knowledge",label:"Knowledge",icon:Bx}];function kw(){return d.jsx(Ks,{heading:"Storage",entries:Cw})}function Mw({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:Lx},...r||n?[{to:"/admin/roles",label:"Roles",icon:Hx}]:[]],f=[{to:"/admin/controlplane",label:"Routers",icon:Px},{to:"/admin/streams",label:"Messages",icon:$x},...a?[{to:"/admin/maintenance",label:"DB Maintenance",icon:Yx}]:[]];return d.jsxs(d.Fragment,{children:[d.jsx(Ks,{heading:"Identity & Access",entries:o}),r&&d.jsx(Ks,{heading:"Infrastructure",entries:f})]})}const ty="lt_event_feed_patterns";function Rw(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 Dw(){try{const r=localStorage.getItem(ty);return r?JSON.parse(r):[]}catch{return[]}}function _f(r){try{localStorage.setItem(ty,JSON.stringify(r))}catch{}}function zw(){const{pathname:r}=ei(),[n,s]=O.useState(Dw),a=O.useMemo(()=>Rw(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 qw({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,Y0="cubic-bezier(0.4, 0, 0.2, 1)",wo=40;function Uw(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 ny({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?Uw(h.current):"none",w=y?0:1;return fg.createPortal(d.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${wf}ms ${Y0}, opacity ${wf}ms ${Y0}`,transform:E,opacity:w,backgroundColor:"#FFFFFF"},onTransitionEnd:g,children:a}),document.body)}function Bw({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 Lw({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 Hw({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 Pw({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 $w({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 Yw({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 Gw(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 Vw(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)=>Gw(`${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 Fw=/(\*\*|^#{1,4}\s|^- |^\d+\.\s|```|^\|.*\|$|\[.+\]\(.+\))/m;function Jw(r){return Fw.test(r)}function ph({content:r,className:n,onClick:s}){const a=O.useMemo(()=>Vw(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&&Jw(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 G0({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(Yw,{className:y}):d.jsx($w,{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(Bw,{className:y}):d.jsx(Lw,{className:y})}),d.jsx("button",{onClick:o,className:E,title:"Copy to clipboard",children:f?d.jsx(Pw,{className:`${y} text-status-success`}):d.jsx(Hw,{className:y})}),h&&d.jsx("button",{onClick:h,className:E,title:"Fullscreen",children:d.jsx(pg,{className:y})}),m&&d.jsx("button",{onClick:m,className:E,title:"Close (Esc)",children:d.jsx(gg,{className:y})})]})}function Iw({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,D]=O.useState(1),W=T%2===0,se=M%2===0,ee=O.useCallback(()=>q(K=>K+1),[]),me=O.useCallback(()=>D(K=>K+1),[]);let re=r;if(typeof r=="string")try{re=JSON.parse(r)}catch{}const C=async()=>{const K=typeof r=="string"?r:JSON.stringify(re,null,2);await navigator.clipboard.writeText(K),y(!0),setTimeout(()=>y(!1),2e3)},X=O.useCallback(()=>{D(1),w(!0)},[]),ce=s==="panel",V=ce?"border border-accent-muted/40 rounded-lg p-3 bg-surface-hover/30":"",G=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:V,children:[n&&d.jsx(qw,{children:n}),d.jsxs("div",{ref:f,className:"relative",children:[d.jsx("div",{className:"absolute top-2 right-2 z-[5]",children:d.jsx(G0,{mode:h,setMode:m,isCollapsed:W,onToggleCollapse:ee,onCopy:C,copied:g,onFullscreen:X})}),d.jsx("div",{className:G,children:h==="json"?d.jsx(Lo,{data:re,generation:T}):d.jsx(Ba,{data:re})})]}),d.jsxs(ny,{open:E,onClose:()=>w(!1),sourceRef:f,children:[d.jsx("div",{className:"sticky top-0 float-right z-10",children:d.jsx(G0,{mode:h,setMode:m,isCollapsed:se,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 Qw=100,V0=500;let Xw=0;const sy={"escalation.created":"text-blue-400","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-blue-400","activity.completed":"text-status-success","activity.failed":"text-status-error","knowledge.stored":"text-violet-400","knowledge.deleted":"text-text-tertiary","agent.started":"text-accent","agent.completed":"text-status-success","agent.failed":"text-status-error","agent.status_changed":"text-blue-400",milestone:"text-violet-400"};function iy(r){const n=r.split(".");return n[0]==="system"&&n.length>=3?`${n[1]}.${n[n.length-1]}`:r}function F0({event:r,forceExpanded:n=!1}){var T,q;const[s,a]=O.useState(n),o=sy[iy(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(Iw,{data:r.data})})})]})}function Kw({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:D,addPattern:W,removePattern:se}=zw(),ee=O.useCallback(re=>{const C=String(re.type||"unknown");if(C.startsWith("mesh."))return;const X=`${C}:${re.timestamp||""}:${re.escalationId||re.workflowId||re.taskId||""}`,ce=Date.now(),V=w.current.get(X);if(!(V&&ce-V<V0)){if(w.current.set(X,ce),w.current.size>200)for(const[G,K]of w.current)ce-K>V0*2&&w.current.delete(G);f(G=>[{id:++Xw,type:C,timestamp:re.timestamp||new Date().toISOString(),data:re},...G].slice(0,Qw))}},[]),me=O.useRef(ee);return me.current=ee,O.useEffect(()=>{const re=q.map(C=>T(C,X=>me.current(X)));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(Gx,{className:"w-3 h-3 text-text-tertiary"}):d.jsx(Vx,{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 ${sy[iy(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(Fx,{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(pg,{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(Jx,{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.","")}),D.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:()=>se(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()&&(W(g.trim()),y(""))},placeholder:"task.> or file.stored",className:"input text-[10px] font-mono flex-1 py-1"}),d.jsxs("button",{onClick:()=>{g.trim()&&(W(g.trim()),y(""))},className:"text-[10px] text-accent hover:text-accent-hover flex items-center gap-0.5",children:[d.jsx(Ix,{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(F0,{event:re},re.id))})}),d.jsxs(ny,{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(gg,{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(F0,{event:re,forceExpanded:!0},re.id))]})]})}function Zw(){return _n({queryKey:["docs"],queryFn:()=>$e("/docs"),staleTime:5*6e4})}function Ww(r){return _n({queryKey:["docs",r],queryFn:()=>$e(`/docs/read?path=${encodeURIComponent(r)}`),enabled:!!r,staleTime:5*6e4})}function eS(){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,D)=>{var se;const W=h.current;if(W){const ee=((se=D==null?void 0:D.current)==null?void 0:se.scrollTop)??0;n([...m.current,{...W,scrollTop:ee}])}a([]),f({path:M,scrollTop:0})},[]),E=O.useCallback(M=>{var ee;const D=m.current;if(D.length===0)return;const W=D[D.length-1],se=h.current;if(se){const me=((ee=M==null?void 0:M.current)==null?void 0:ee.scrollTop)??0;a([...g.current,{...se,scrollTop:me}])}n(D.slice(0,-1)),f(W),requestAnimationFrame(()=>{M!=null&&M.current&&(M.current.scrollTop=W.scrollTop)})},[]),w=O.useCallback(M=>{var ee;const D=g.current;if(D.length===0)return;const W=D[D.length-1],se=h.current;if(se){const me=((ee=M==null?void 0:M.current)==null?void 0:ee.scrollTop)??0;n([...m.current,{...se,scrollTop:me}])}a(D.slice(0,-1)),f(W),requestAnimationFrame(()=>{M!=null&&M.current&&(M.current.scrollTop=W.scrollTop)})},[]),T=O.useCallback(M=>{var se,ee;const D=h.current;if(!D)return;const W=((se=M==null?void 0:M.current)==null?void 0:se.scrollTop)??0;n([...m.current,{...D,scrollTop:W}]),a([]),f({...D,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 tS(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 nS(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 sS(r){return!r||r==="README.md"?"#docs":`#docs:${r}`}function iS({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}=tS(g.dataset.docLink,n);s(E,w);return}};return d.jsx(ph,{content:r,className:"docs-content",onClick:o})}function rS(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 aS({docs:r,selected:n,onSelect:s}){const{topLevel:a,dirs:o}=rS(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(Qx,{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 lS({open:r,onClose:n}){var ce,V,G;const[s,a]=O.useState(!1),{data:o}=Zw(),f=eS(),{data:h,isLoading:m}=Ww(((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 K=(ae=g.current)==null?void 0:ae.querySelector(`#${CSS.escape(y)}`);K==null||K.scrollIntoView({behavior:"smooth",block:"start"}),E(null)})},[y,h]);const w=O.useCallback(()=>{var ne;const K=nS(window.location.hash),ae=(K==null?void 0:K.path)??"README.md";((ne=f.current)==null?void 0:ne.path)!==ae&&f.navigate(ae,g),K!=null&&K.anchor&&E(K.anchor)},[f]),T=O.useRef(!0);O.useEffect(()=>{if(!r||!f.current)return;if(T.current){T.current=!1;return}const K=sS(f.current.path);window.location.hash!==K&&window.history.replaceState(null,"",window.location.pathname+window.location.search+K)},[r,(V=f.current)==null?void 0:V.path]),O.useEffect(()=>{if(!r)return;const K=()=>{window.location.hash.startsWith("#docs")&&w()};return window.addEventListener("hashchange",K),()=>window.removeEventListener("hashchange",K)},[r,w]);const q=O.useCallback((K,ae)=>{ae&&E(ae),f.navigate(K,g)},[f]),M=O.useCallback(K=>{f.navigate(K,g)},[f]),D=O.useCallback(()=>{f.goBack(g)},[f]),W=O.useCallback(()=>{f.goForward(g)},[f]),se=O.useCallback(()=>{f.pushScrollPosition(g)},[f]);if(O.useEffect(()=>{if(r){T.current=!0,w();const K=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(K)}},[r]),!(r||s))return null;const me=()=>{a(!1),setTimeout(()=>{n(),f.reset()},200)},re=((G=f.current)==null?void 0:G.path)??null,C=f.backStack.length>0,X=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:D,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(Xx,{className:"w-4 h-4"})}),d.jsx("button",{onClick:W,disabled:!X,className:`p-0.5 transition-colors ${X?"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(mg,{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(aS,{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(iS,{content:h.content,currentPath:re,onNavigate:q,onAnchorClick:se}):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 oS(r){if(r.includes("/escalations"))return["escalation","human-queue"]}const J0=2e3;function cS(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 uS(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 ry=O.createContext(null);function fS({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??oS(n.pathname)};O.useEffect(()=>()=>{E.current&&clearInterval(E.current)},[]);const T=O.useCallback(()=>a(se=>!se),[]),q=O.useCallback(se=>{y(se)},[]),M=O.useCallback(()=>{f([]),m(null)},[]),D=O.useCallback(async se=>{var V;const ee=new Date().toISOString(),me={id:`user-${Date.now()}`,role:"user",content:se,timestamp:ee},re={id:`pending-${Date.now()}`,role:"assistant",content:"",timestamp:ee,pending:!0};f(G=>[...G,me,re]);const C={...w};(V=C.entities)!=null&&V.yamlContent&&C.entities.yamlContent.length>J0&&(C.entities={...C.entities,yamlContent:C.entities.yamlContent.slice(0,J0)+`
62
- ... (truncated)`});const ce=`${cS(o.concat(me))}${se}`;try{const K=(await $e("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ce,tags:C.suggestedTags,context:C,wait:!1,direct:!0})})).workflow_id;m(K),f(ae=>ae.map(ne=>ne.id===re.id?{...ne,workflowId:K}:ne)),E.current&&clearInterval(E.current),E.current=setInterval(async()=>{var ae;try{const ne=await $e(`/workflows/${K}/result`),ke=(ae=ne==null?void 0:ne.result)==null?void 0:ae.data;if(ke){E.current&&clearInterval(E.current),E.current=null,m(null);const He=uS(ke);let Me;try{Me=(await $e(`/workflow-states/${K}/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(G=>G.map(K=>K.id===re.id?{...K,content:"Failed to submit query. Please try again.",pending:!1}:K))}},[o,w]),W=O.useCallback(async se=>{const ee=o.find(C=>C.id===se);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(X=>X.id===se?{...X,compilationStatus:"compiling"}:X));try{const C=await $e("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:re.content,summary:ee.content})}),X=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/${X.id}/deploy`,{method:"POST"}),f(ce=>ce.map(V=>V.id===se?{...V,compilationStatus:"done"}:V))}catch(C){const X=C instanceof Error?C.message:"Compilation failed";f(ce=>ce.map(V=>V.id===se?{...V,compilationStatus:"error",compilationError:X}:V))}}},[o]);return d.jsx(ry.Provider,{value:{helpOpen:s,setHelpOpen:a,toggleHelp:T,messages:o,sendMessage:D,pageContext:w,setPageContext:q,activeWorkflowId:h,clearMessages:M,compileMessage:W},children:r})}function ay(){const r=O.useContext(ry);if(!r)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return r}function hS(){const{helpOpen:r,toggleHelp:n}=ay();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("img",{src:`${Wt}/logo512.png`,alt:"Help",className:"w-8 h-8 -rotate-[120deg]"})})}const ly=6048e5,dS=864e5,I0=6e4,Q0=525600,X0=43200,K0=1440,Z0=Symbol.for("constructDateFrom");function ds(r,n){return typeof r=="function"?r(n):r&&typeof r=="object"&&Z0 in r?r[Z0](n):r instanceof Date?new r.constructor(n):new Date(n)}function sn(r,n){return ds(n||r,r)}let mS={};function Ja(){return mS}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 oy(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 cy(r,...n){const s=ds.bind(null,r||n.find(a=>typeof a=="object"));return n.map(s)}function W0(r,n){const s=sn(r,n==null?void 0:n.in);return s.setHours(0,0,0,0),s}function pS(r,n,s){const[a,o]=cy(s==null?void 0:s.in,r,n),f=W0(a),h=W0(o),m=+f-Po(f),g=+h-Po(h);return Math.round((m-g)/dS)}function gS(r,n){const s=oy(r,n),a=ds(r,0);return a.setFullYear(s,0,4),a.setHours(0,0,0,0),Ho(a)}function yS(r,n){const s=+sn(r)-+sn(n);return s<0?-1:s>0?1:s}function bS(r){return ds(r,Date.now())}function xS(r){return r instanceof Date||typeof r=="object"&&Object.prototype.toString.call(r)==="[object Date]"}function vS(r){return!(!xS(r)&&typeof r!="number"||isNaN(+sn(r)))}function _S(r){return n=>{const a=(r?Math[r]:Math.trunc)(n);return a===0?0:a}}function wS(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 SS={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"}},ES=(r,n,s)=>{let a;const o=SS[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 AS={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},jS={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},OS={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},TS={date:Sf({formats:AS,defaultWidth:"full"}),time:Sf({formats:jS,defaultWidth:"full"}),dateTime:Sf({formats:OS,defaultWidth:"full"})},NS={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},CS=(r,n,s,a)=>NS[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 kS={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},MS={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},RS={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"]},DS={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"]},zS={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"}},qS={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"}},US=(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"},BS={ordinalNumber:US,era:Ta({values:kS,defaultWidth:"wide"}),quarter:Ta({values:MS,defaultWidth:"wide",argumentCallback:r=>r-1}),month:Ta({values:RS,defaultWidth:"wide"}),day:Ta({values:DS,defaultWidth:"wide"}),dayPeriod:Ta({values:zS,defaultWidth:"wide",formattingValues:qS,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)?HS(m,w=>w.test(h)):LS(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 LS(r,n){for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)&&n(r[s]))return s}function HS(r,n){for(let s=0;s<r.length;s++)if(n(r[s]))return s}function PS(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 $S=/^(\d+)(th|st|nd|rd)?/i,YS=/\d+/i,GS={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},VS={any:[/^b/i,/^(a|c)/i]},FS={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},JS={any:[/1/i,/2/i,/3/i,/4/i]},IS={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},QS={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]},XS={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},KS={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]},ZS={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},WS={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}},e2={ordinalNumber:PS({matchPattern:$S,parsePattern:YS,valueCallback:r=>parseInt(r,10)}),era:Na({matchPatterns:GS,defaultMatchWidth:"wide",parsePatterns:VS,defaultParseWidth:"any"}),quarter:Na({matchPatterns:FS,defaultMatchWidth:"wide",parsePatterns:JS,defaultParseWidth:"any",valueCallback:r=>r+1}),month:Na({matchPatterns:IS,defaultMatchWidth:"wide",parsePatterns:QS,defaultParseWidth:"any"}),day:Na({matchPatterns:XS,defaultMatchWidth:"wide",parsePatterns:KS,defaultParseWidth:"any"}),dayPeriod:Na({matchPatterns:ZS,defaultMatchWidth:"any",parsePatterns:WS,defaultParseWidth:"any"})},uy={code:"en-US",formatDistance:ES,formatLong:TS,formatRelative:CS,localize:BS,match:e2,options:{weekStartsOn:0,firstWeekContainsDate:1}};function t2(r,n){const s=sn(r,n==null?void 0:n.in);return pS(s,wS(s))+1}function n2(r,n){const s=sn(r,n==null?void 0:n.in),a=+Ho(s)-+gS(s);return Math.round(a/ly)+1}function fy(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 s2(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=fy(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 i2(r,n){const s=sn(r,n==null?void 0:n.in),a=+Ya(s,n)-+s2(s,n);return Math.round(a/ly)+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"},eg={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=fy(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=oy(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=i2(r,a);return n==="wo"?s.ordinalNumber(o,{unit:"week"}):Ve(o,n.length)},I:function(r,n,s){const a=n2(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=t2(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 ng(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 ng(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"+tg(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"+tg(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 tg(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 ng(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 sg=(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"})}},hy=(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"})}},r2=(r,n)=>{const s=r.match(/(P+)(p+)?/)||[],a=s[1],o=s[2];if(!o)return sg(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}}",sg(a,n)).replace("{{time}}",hy(o,n))},a2={p:hy,P:r2},l2=/^D+$/,o2=/^Y+$/,c2=["D","DD","YY","YYYY"];function u2(r){return l2.test(r)}function f2(r){return o2.test(r)}function h2(r,n,s){const a=d2(r,n,s);if(console.warn(a),c2.includes(r))throw new RangeError(a)}function d2(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 m2=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,p2=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,g2=/^'([^]*?)'?$/,y2=/''/g,b2=/[a-zA-Z]/;function gh(r,n,s){var E,w,T,q;const a=Ja(),o=a.locale??uy,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(!vS(m))throw new RangeError("Invalid time value");let g=n.match(p2).map(M=>{const D=M[0];if(D==="p"||D==="P"){const W=a2[D];return W(M,o.formatLong)}return M}).join("").match(m2).map(M=>{if(M==="''")return{isToken:!1,value:"'"};const D=M[0];if(D==="'")return{isToken:!1,value:x2(M)};if(eg[D])return{isToken:!0,value:M};if(D.match(b2))throw new RangeError("Format string contains an unescaped latin alphabet character `"+D+"`");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 D=M.value;(f2(D)||u2(D))&&h2(D,n,String(r));const W=eg[D[0]];return W(m,D,o.localize,y)}).join("")}function x2(r){const n=r.match(g2);return n?n[1].replace(y2,"'"):r}function v2(r,n,s){const a=Ja(),o=(s==null?void 0:s.locale)??a.locale??uy,f=yS(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]=cy(s==null?void 0:s.in,...f>0?[n,r]:[r,n]),y=_S((s==null?void 0:s.roundingMethod)??"round"),E=g.getTime()-m.getTime(),w=E/I0,T=Po(g)-Po(m),q=(E-T)/I0,M=s==null?void 0:s.unit;let D;if(M?D=M:w<1?D="second":w<60?D="minute":w<K0?D="hour":q<X0?D="day":q<Q0?D="month":D="year",D==="second"){const W=y(E/1e3);return o.formatDistance("xSeconds",W,h)}else if(D==="minute"){const W=y(w);return o.formatDistance("xMinutes",W,h)}else if(D==="hour"){const W=y(w/60);return o.formatDistance("xHours",W,h)}else if(D==="day"){const W=y(q/K0);return o.formatDistance("xDays",W,h)}else if(D==="month"){const W=y(q/X0);return W===12&&M!=="month"?o.formatDistance("xYears",1,h):o.formatDistance("xMonths",W,h)}else{const W=y(q/Q0);return o.formatDistance("xYears",W,h)}}function _2(r,n){return v2(r,bS(r),n)}function ZE(r){return r.toLocaleString()}function WE(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 w2(r){const n=new Date(r);return n.getTime()>Date.now()?"just now":_2(n,{addSuffix:!0})}function e3(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 t3(r){return r<=0?"Expired":yh(r)}function S2(r){return r==null?"--":yh(r)}function n3(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 s3(r,n){const s=new Date(r).getTime(),a=n?new Date(n).getTime():Date.now();return yh(a-s)}function dy({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 se=y.current.getBoundingClientRect(),ee=window.innerWidth-T-8,me=Math.max(8,Math.min(se.left,ee));g({top:se.bottom+4,left:me})},[]),M=O.useCallback(async(se,ee)=>{try{await navigator.clipboard.writeText(se),h(ee),clearTimeout(E.current),E.current=setTimeout(()=>h(null),1200)}catch{}},[]),D=O.useCallback(()=>{clearTimeout(w.current),q(),o(!0)},[q]),W=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:D,onMouseLeave:W,children:[n,a&&m&&fg.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:D,onMouseLeave:W,children:r.map(se=>d.jsxs("button",{onClick:ee=>{ee.stopPropagation(),M(se.value,se.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:se.label}),d.jsx("span",{className:"text-[10px] font-mono text-text-secondary truncate ml-2",children:f===se.label?"✓":se.value})]},se.label))}),document.body)]})}function E2(r,n){const s=new Date(r);switch(n){case"relative":return w2(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 A2(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 j2({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(()=>A2(r),[r]);return d.jsx(dy,{options:o,children:d.jsx("time",{dateTime:r,className:`text-xs text-text-tertiary ${s}`,children:E2(r,n)})})}function O2({ms:r,className:n=""}){const s=S2(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(dy,{options:a,children:d.jsx("span",{className:`text-xs text-text-tertiary ${n}`,children:s})})}const T2=["sm","md","lg","full"],ig={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"},rg={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function N2({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 C2({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 k2({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(j2,{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(O2,{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(Kx,{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 M2(){const{helpOpen:r,setHelpOpen:n,messages:s,sendMessage:a,pageContext:o,activeWorkflowId:f,clearMessages:h,compileMessage:m}=ay(),[g,y]=O.useState(""),[E,w]=O.useState("md"),[T,q]=O.useState(!0),M=O.useRef(null),D=O.useRef(null);if(O.useEffect(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[s]),O.useEffect(()=>{r&&D.current&&D.current.focus()},[r]),O.useEffect(()=>{if(!r)return;const C=X=>{X.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 W=()=>{const C=g.trim();!C||f||(a(C),y(""),D.current&&(D.current.style.height="auto"))},se=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),W())},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?ig.full:`right-6 ${ig[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:T2.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":rg[C],title:rg[C],children:d.jsx(N2,{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(Zx,{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(C2,{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(k2,{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:D,value:g,onChange:C=>{y(C.target.value);const X=C.target;X.style.height="auto",X.style.height=`${Math.min(X.scrollHeight,120)}px`},onKeyDown:se,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:W,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(Wx,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}function R2(){var M;const{isBuilder:r,isOps:n}=Kg(),{data:s}=Qo(),a=!!((M=s==null?void 0:s.ai)!=null&&M.enabled),{collapsed:o,toggle:f}=Wg(),[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 D=q.current;D&&(D.classList.remove("animate-page-in"),D.offsetWidth,D.classList.add("animate-page-in"))},[T.pathname]),O.useEffect(()=>{const D=()=>{window.location.hash.startsWith("#docs")&&w(!0)};return window.addEventListener("hashchange",D),()=>window.removeEventListener("hashchange",D)},[]),d.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[d.jsx(_w,{onToggleEventFeed:()=>m(D=>!D),onToggleDocs:()=>w(D=>!D)}),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(jw,{aiEnabled:a,isBuilder:r,isOps:n}),r&&d.jsx(Ow,{}),r&&a&&d.jsx(Nw,{}),r&&d.jsx(kw,{}),(r||n)&&d.jsx(Mw,{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(ev,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):d.jsx(tv,{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(Kw,{open:h,onToggle:()=>m(D=>!D),configOpen:g,onToggleConfig:()=>y(D=>!D)}),d.jsx(lS,{open:E,onClose:()=>{w(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),a&&d.jsx(hS,{}),a&&d.jsx(M2,{})]})}function D2(){const{isAuthenticated:r}=Oi(),n=ei();return r?d.jsx(yw,{children:d.jsx(fS,{children:d.jsx(R2,{})})}):d.jsx(Bn,{to:"/login",state:{from:n.pathname},replace:!0})}function my({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 z2(){return $e("/auth/oauth/providers")}async function q2(r,n){const s=n?`?label=${encodeURIComponent(n)}`:"";return $e(`/auth/oauth/connections/${r}${s}`,{method:"DELETE"})}function i3(){return _n({queryKey:["oauth-connections"],queryFn:()=>$e("/auth/oauth/connections")})}function r3(){const r=rn();return wn({mutationFn:({provider:n,label:s})=>q2(n,s),onSuccess:()=>{r.invalidateQueries({queryKey:["oauth-connections"]})}})}function U2(){var ce;const{login:r,isAuthenticated:n}=Oi(),s=hg(),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||""),[D,W]=O.useState(!1),[se,ee]=O.useState(!!f),[me,re]=O.useState([]),C=O.useRef(!1);if(O.useEffect(()=>{f||C.current||(C.current=!0,(async()=>{var V,G,K,ae;try{const ne=await fetch(`${Wt}/api/settings`);if(!ne.ok)return;const ke=await ne.json();if(!((V=ke.auth)!=null&&V.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&&((G=ke.auth)!=null&&G.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",ke.auth.ssoLogoutUrl),ee(!0),r(Me.token,void 0,{displayName:(K=Me.user)==null?void 0:K.display_name,username:(ae=Me.user)==null?void 0:ae.external_id}))}catch{}})())},[]),O.useEffect(()=>{f||z2().then(re).catch(()=>{})},[]),O.useEffect(()=>{if(!se)return;const V=setTimeout(()=>s(m,{replace:!0}),1500);return()=>clearTimeout(V)},[se]),n&&!se)return d.jsx(Bn,{to:m,replace:!0});const X=async V=>{var G,K;if(V.preventDefault(),M(""),!y.trim()||!w){M("Username and password are required");return}W(!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})}),ne=await ae.json();if(!ae.ok){M(ne.error||"Login failed");return}ee(!0),r(ne.token,{username:y.trim(),password:w},{displayName:(G=ne.user)==null?void 0:G.display_name,username:(K=ne.user)==null?void 0:K.external_id})}catch{M("Unable to connect to server")}finally{W(!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 ${se?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:d.jsx(dh,{size:"lg",hideLabel:se})}),d.jsxs("form",{onSubmit:X,className:`space-y-5 transition-opacity duration-300 ${se?"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:V=>E(V.target.value),className:"input",placeholder:"Enter your username",autoFocus:!se,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:V=>T(V.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:D||se,children:D?"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(V=>V.provider!=="anthropic").map(V=>d.jsxs("a",{href:`${Wt}/api/auth/oauth/${V.provider}?returnTo=${encodeURIComponent(m)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[d.jsx(my,{provider:V.provider}),"Sign in with ",V.name]},V.provider))})]})]})]})})}function ag(){const{isAuthenticated:r}=Oi(),n=hg(),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"),D=W=>{W.preventDefault();const se=f.trim();if(!se){E("A token or API key is required");return}if(!se.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(se)}&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(my,{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:D,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:W=>h(W.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:W=>g(W.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 B2({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 L2({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 H2=O.lazy(()=>ve(()=>import("./ProcessesListPage-btsU6hBR.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}))),P2=O.lazy(()=>ve(()=>import("./ProcessDetailPage-CP7GZhgs.js"),__vite__mapDeps([18,1,2,4,19,15,20,17,11,6,21,22,23]),import.meta.url).then(r=>({default:r.ProcessDetailPage}))),$2=O.lazy(()=>ve(()=>import("./McpOverview-DXRKcJN0.js"),__vite__mapDeps([24,1,25,26,27,28,14,15,29,6]),import.meta.url).then(r=>({default:r.McpOverview}))),Y2=O.lazy(()=>ve(()=>import("./McpRunsPage-uTbym66Y.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}))),G2=O.lazy(()=>ve(()=>import("./McpRunDetailPage-Dsa3G3XQ.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}))),V2=O.lazy(()=>ve(()=>import("./McpQueryPage-BE6I011z.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}))),F2=O.lazy(()=>ve(()=>import("./McpQueryDetailPage-CmW15w5e.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}))),J2=O.lazy(()=>ve(()=>import("./EscalationsOverview-CvHIJ_GG.js"),__vite__mapDeps([52,1,4,14,15,29,6]),import.meta.url).then(r=>({default:r.EscalationsOverview}))),I2=O.lazy(()=>ve(()=>import("./AvailableEscalationsPage-_xcWvlIz.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}))),Q2=O.lazy(()=>ve(()=>import("./OperatorDashboard-i8cxaDlk.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}))),X2=O.lazy(()=>ve(()=>import("./index-DccCwyZl.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}))),K2=O.lazy(()=>ve(()=>import("./WorkflowsOverview-C15JcxyY.js"),__vite__mapDeps([63,1,3,4,14,15,29,6]),import.meta.url).then(r=>({default:r.WorkflowsOverview}))),Z2=O.lazy(()=>ve(()=>import("./index-BUbzfEA9.js"),__vite__mapDeps([64,1,3,14,15,17,65,48,49,6]),import.meta.url).then(r=>({default:r.StartWorkflowPage}))),W2=O.lazy(()=>ve(()=>import("./index-BUbzfEA9.js"),__vite__mapDeps([64,1,3,14,15,17,65,48,49,6]),import.meta.url).then(r=>({default:r.DurableInvokePage}))),eE=O.lazy(()=>ve(()=>import("./WorkflowsDashboard-D3z7COgH.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"})}))),tE=O.lazy(()=>ve(()=>import("./WorkflowsDashboard-D3z7COgH.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"})}))),nE=O.lazy(()=>ve(()=>import("./YamlWorkflowsPage-B44WgwE_.js"),__vite__mapDeps([67,1,27,5,6,14,15,13,10,50,65,20]),import.meta.url).then(r=>({default:r.YamlWorkflowsPage}))),sE=O.lazy(()=>ve(()=>import("./GraphInvokePage-De1XVx5d.js"),__vite__mapDeps([68,1,27,14,15,45,47,48,49,46,6,50,65]),import.meta.url).then(r=>({default:r.GraphInvokePage}))),iE=O.lazy(()=>ve(()=>import("./YamlWorkflowDetailPage-BYq3t7E-.js"),__vite__mapDeps([69,1,27,20,65,15,6]),import.meta.url).then(r=>({default:r.YamlWorkflowDetailPage}))),rE=O.lazy(()=>ve(()=>import("./TasksListPage-DOy6JlKS.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}))),aE=O.lazy(()=>ve(()=>import("./TaskDetailPage-CT5rXHK5.js"),__vite__mapDeps([71,1,2,20,59,14,15,6]),import.meta.url).then(r=>({default:r.TaskDetailPage}))),lg=O.lazy(()=>ve(()=>import("./WorkflowExecutionPage-BwQoOmUE.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}))),lE=O.lazy(()=>ve(()=>import("./AdminDashboard-Bg1HgukI.js"),__vite__mapDeps([73,1,2,4,25,19,15,6]),import.meta.url).then(r=>({default:r.AdminDashboard}))),oE=O.lazy(()=>ve(()=>import("./index-CknKy4RA.js"),__vite__mapDeps([74,1,3,9,10,13,33,5,6,14,15,75,17]),import.meta.url).then(r=>({default:r.WorkersPage}))),cE=O.lazy(()=>ve(()=>import("./index-CDPBXB4e.js"),__vite__mapDeps([76,1,3,77,55,6,21,15,17,14,57,48,49,65]),import.meta.url).then(r=>({default:r.WorkflowConfigsPage}))),og=O.lazy(()=>ve(()=>import("./index-CDPBXB4e.js"),__vite__mapDeps([76,1,3,77,55,6,21,15,17,14,57,48,49,65]),import.meta.url).then(r=>({default:r.WorkflowConfigDetailPage}))),uE=O.lazy(()=>ve(()=>import("./index-DU7YumVJ.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}))),cg=O.lazy(()=>ve(()=>import("./index-DVVIeBBk.js"),__vite__mapDeps([80,1,25,14,15,44,6]),import.meta.url).then(r=>({default:r.McpServerDetailPage}))),fE=O.lazy(()=>ve(()=>import("./index-BhznDv-4.js"),__vite__mapDeps([81,1,23,5,6,9,10,12,13,11,77,55,33,14,15,21,49,57,51]),import.meta.url).then(r=>({default:r.UsersPage}))),hE=O.lazy(()=>ve(()=>import("./RolesPage-1DBoEMsb.js"),__vite__mapDeps([82,1,57,14,15,55,6]),import.meta.url).then(r=>({default:r.RolesPage}))),dE=O.lazy(()=>ve(()=>import("./RoleDetailPage-BB_e330f.js"),__vite__mapDeps([83,1,57,77,55,6,15]),import.meta.url).then(r=>({default:r.RoleDetailPage}))),mE=O.lazy(()=>ve(()=>import("./index-CV4lEd4I.js"),__vite__mapDeps([84,1,14,15,55,6,56]),import.meta.url).then(r=>({default:r.MaintenancePage}))),pE=O.lazy(()=>ve(()=>import("./OperationsPage-CAmiFHI6.js"),__vite__mapDeps([85,1,57,4,14,15,6]),import.meta.url).then(r=>({default:r.OperationsPage}))),gE=O.lazy(()=>ve(()=>import("./index-CpgV4Kkp.js"),__vite__mapDeps([86,1,19,15,13,5,6,31,28,55,36,75,9,10,33]),import.meta.url).then(r=>({default:r.ControlPlanePage}))),yE=O.lazy(()=>ve(()=>import("./index-B0kmiSmt.js"),__vite__mapDeps([87,1,6,39,15,5,31,28,8,9,10,12,13,11,14,16]),import.meta.url).then(r=>({default:r.StreamMessagesPage}))),bE=O.lazy(()=>ve(()=>import("./CredentialsPage-D1OmMHux.js"),__vite__mapDeps([88,1,14,15,51,77,55,6]),import.meta.url).then(r=>({default:r.CredentialsPage}))),xE=O.lazy(()=>ve(()=>import("./index-DrUkTcn-.js"),__vite__mapDeps([89,1,6,14,15,13,16,8,10,90,51]),import.meta.url).then(r=>({default:r.FilesPage}))),vE=O.lazy(()=>ve(()=>import("./index-j-C7g_Ej.js"),__vite__mapDeps([91,1,14,15,13,16,12,10,90,51,92,44,6]),import.meta.url).then(r=>({default:r.KnowledgePage}))),_E=O.lazy(()=>ve(()=>import("./HomePage-BYR5VXXw.js"),__vite__mapDeps([93,1,3,26,28,2,4,21,15,17,16,6]),import.meta.url).then(r=>({default:r.HomePage}))),wE=O.lazy(()=>ve(()=>import("./AgentsPage-DhN2lIBh.js"),__vite__mapDeps([94,1,95,4,5,6,8,9,10,12,13,14,15,16]),import.meta.url).then(r=>({default:r.AgentsPage}))),SE=O.lazy(()=>ve(()=>import("./AgentDetailPage-BsaiYbwL.js"),__vite__mapDeps([96,1,95,97,15,4,17,6]),import.meta.url).then(r=>({default:r.AgentDetailPage}))),ug=O.lazy(()=>ve(()=>import("./AgentConfigPage-HBe_YDU_.js"),__vite__mapDeps([98,1,95,97,15,14,92,47,48,49,3,27,99,100,17,6]),import.meta.url).then(r=>({default:r.AgentConfigPage}))),EE=O.lazy(()=>ve(()=>import("./CapabilitiesPage-w1owqsmN.js"),__vite__mapDeps([101,1,99,79,25,47,48,49,15,50,6,46,14]),import.meta.url).then(r=>({default:r.CapabilitiesPage}))),AE=O.lazy(()=>ve(()=>import("./TopicsPage-D67tjS8L.js"),__vite__mapDeps([102,1,100,14,15,6]),import.meta.url).then(r=>({default:r.TopicsPage}))),jE=O.lazy(()=>ve(()=>import("./TopicDetailPage-Cn1ShfR8.js"),__vite__mapDeps([103,1,100,16,15,6]),import.meta.url).then(r=>({default:r.TopicDetailPage})));function OE(){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 xe({children:r}){return d.jsx(O.Suspense,{fallback:d.jsx(OE,{}),children:d.jsx("div",{className:"animate-page-enter",children:r})})}const py=new jx({defaultOptions:{queries:{staleTime:1e4,retry:(r,n)=>n instanceof Error&&n.message==="Session expired"?!1:r<1}}});window.addEventListener("auth:unauthorized",()=>{py.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 TE=Nx([{path:"/login",element:d.jsx(U2,{})},{path:"/connect/anthropic",element:d.jsx(ag,{})},{path:"/connect/:provider",element:d.jsx(ag,{})},{path:"/",element:d.jsx(D2,{}),children:[{index:!0,element:d.jsx(xe,{children:d.jsx(_E,{})})},{path:"processes/all",element:d.jsx(xe,{children:d.jsx(H2,{})})},{path:"processes/detail/:originId",element:d.jsx(xe,{children:d.jsx(P2,{})})},{path:"credentials",element:d.jsx(xe,{children:d.jsx(bE,{})})},{path:"connections",element:d.jsx(Bn,{to:"/credentials",replace:!0})},{path:"escalations",element:d.jsx(xe,{children:d.jsx(J2,{})})},{path:"escalations/available",element:d.jsx(xe,{children:d.jsx(I2,{})})},{path:"escalations/queue",element:d.jsx(xe,{children:d.jsx(Q2,{})})},{path:"escalations/detail/:id",element:d.jsx(xe,{children:d.jsx(X2,{})})},{path:"capabilities",element:d.jsx(xe,{children:d.jsx(EE,{})})},{path:"agents",element:d.jsx(xe,{children:d.jsx(wE,{})})},{path:"agents/new",element:d.jsx(xe,{children:d.jsx(ug,{})})},{path:"agents/:id",element:d.jsx(xe,{children:d.jsx(SE,{})})},{path:"agents/:id/edit",element:d.jsx(xe,{children:d.jsx(ug,{})})},{path:"topics",element:d.jsx(xe,{children:d.jsx(AE,{})})},{path:"topics/:topic",element:d.jsx(xe,{children:d.jsx(jE,{})})},{element:d.jsx(Ca,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:d.jsx(xe,{children:d.jsx(K2,{})})},{path:"workflows/executions",element:d.jsx(xe,{children:d.jsx(tE,{})})},{path:"workflows/durable/executions",element:d.jsx(xe,{children:d.jsx(eE,{})})},{path:"workflows/durable/executions/:workflowId",element:d.jsx(xe,{children:d.jsx(lg,{})})},{path:"workflows/tasks",element:d.jsx(xe,{children:d.jsx(rE,{})})},{path:"workflows/tasks/detail/:id",element:d.jsx(xe,{children:d.jsx(aE,{})})},{path:"workflows/executions/:workflowId",element:d.jsx(xe,{children:d.jsx(lg,{})})},{path:"workflows/start",element:d.jsx(xe,{children:d.jsx(Z2,{})})},{path:"workflows/durable/invoke",element:d.jsx(xe,{children:d.jsx(W2,{})})},{path:"workflows/cron",element:d.jsx(Bn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:d.jsx(xe,{children:d.jsx(oE,{})})},{path:"workflows/registry",element:d.jsx(xe,{children:d.jsx(cE,{})})},{path:"workflows/registry/new",element:d.jsx(xe,{children:d.jsx(og,{})})},{path:"workflows/registry/:workflowType",element:d.jsx(xe,{children:d.jsx(og,{})})}]},{element:d.jsx(Ca,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:d.jsx(xe,{children:d.jsx(nE,{})})},{path:"mcp/workflows/invoke",element:d.jsx(xe,{children:d.jsx(sE,{})})},{path:"mcp/workflows/:id",element:d.jsx(xe,{children:d.jsx(iE,{})})},{path:"mcp/executions",element:d.jsx(xe,{children:d.jsx(Y2,{})})},{path:"mcp/executions/:jobId",element:d.jsx(xe,{children:d.jsx(G2,{})})},{path:"files",element:d.jsx(xe,{children:d.jsx(xE,{})})},{path:"knowledge",element:d.jsx(xe,{children:d.jsx(vE,{})})},{element:d.jsx(B2,{}),children:[{path:"mcp",element:d.jsx(xe,{children:d.jsx($2,{})})},{path:"mcp/queries",element:d.jsx(xe,{children:d.jsx(V2,{})})},{path:"mcp/queries/:workflowId",element:d.jsx(xe,{children:d.jsx(F2,{})})},{path:"mcp/tools",element:d.jsx(Bn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:d.jsx(xe,{children:d.jsx(uE,{})})},{path:"mcp/servers/new",element:d.jsx(xe,{children:d.jsx(cg,{})})},{path:"mcp/servers/:serverId",element:d.jsx(xe,{children:d.jsx(cg,{})})}]}]},{element:d.jsx(Ca,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"operations",element:d.jsx(xe,{children:d.jsx(pE,{})})}]},{element:d.jsx(Ca,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:d.jsx(xe,{children:d.jsx(lE,{})})},{path:"admin/users",element:d.jsx(xe,{children:d.jsx(fE,{})})},{path:"admin/escalation-chains",element:d.jsx(Bn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:d.jsx(xe,{children:d.jsx(hE,{})})},{path:"admin/roles/:role",element:d.jsx(xe,{children:d.jsx(dE,{})})}]},{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(L2,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:d.jsx(xe,{children:d.jsx(mE,{})})}]},{path:"admin/controlplane",element:d.jsx(xe,{children:d.jsx(gE,{})})},{path:"admin/streams",element:d.jsx(xe,{children:d.jsx(yE,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function NE(){return d.jsx(Ox,{client:py,children:d.jsx(uv,{children:d.jsx(mw,{children:d.jsx(Cx,{router:TE})})})})}av.createRoot(document.getElementById("root")).render(d.jsx(O.StrictMode,{children:d.jsx(NE,{})}));export{HE as A,GE as B,mh as C,O2 as D,XE as E,ny as F,gh as G,dy as H,t3 as I,Iw as J,zE as K,ZE as L,Wt as M,d_ as N,bg as O,i3 as P,r3 as Q,my as R,qw as S,WE as T,s3 as a,j2 as b,p_ as c,$e as d,LE as e,S2 as f,PE as g,YE as h,qE as i,Oi as j,BE as k,VE as l,FE as m,JE as n,IE as o,QE as p,KE as q,UE as r,xw as s,bw as t,Qo as u,Kg as v,$E as w,n3 as x,e3 as y,yh as z};
63
- //# sourceMappingURL=index-CtDf8vvQ.js.map
62
+ ... (truncated)`});const ce=`${cS(o.concat(me))}${se}`;try{const K=(await $e("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ce,tags:C.suggestedTags,context:C,wait:!1,direct:!0})})).workflow_id;m(K),f(ae=>ae.map(ne=>ne.id===re.id?{...ne,workflowId:K}:ne)),E.current&&clearInterval(E.current),E.current=setInterval(async()=>{var ae;try{const ne=await $e(`/workflows/${K}/result`),ke=(ae=ne==null?void 0:ne.result)==null?void 0:ae.data;if(ke){E.current&&clearInterval(E.current),E.current=null,m(null);const He=uS(ke);let Me;try{Me=(await $e(`/workflow-states/${K}/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(G=>G.map(K=>K.id===re.id?{...K,content:"Failed to submit query. Please try again.",pending:!1}:K))}},[o,w]),W=O.useCallback(async se=>{const ee=o.find(C=>C.id===se);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(X=>X.id===se?{...X,compilationStatus:"compiling"}:X));try{const C=await $e("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:re.content,summary:ee.content})}),X=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/${X.id}/deploy`,{method:"POST"}),f(ce=>ce.map(V=>V.id===se?{...V,compilationStatus:"done"}:V))}catch(C){const X=C instanceof Error?C.message:"Compilation failed";f(ce=>ce.map(V=>V.id===se?{...V,compilationStatus:"error",compilationError:X}:V))}}},[o]);return d.jsx(ry.Provider,{value:{helpOpen:s,setHelpOpen:a,toggleHelp:T,messages:o,sendMessage:D,pageContext:w,setPageContext:q,activeWorkflowId:h,clearMessages:M,compileMessage:W},children:r})}function ay(){const r=O.useContext(ry);if(!r)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return r}function hS(){const{helpOpen:r,toggleHelp:n}=ay();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("img",{src:`${Wt}/logo512.png`,alt:"Help",className:"w-8 h-8 -rotate-[120deg]"})})}const ly=6048e5,dS=864e5,I0=6e4,Q0=525600,X0=43200,K0=1440,Z0=Symbol.for("constructDateFrom");function ds(r,n){return typeof r=="function"?r(n):r&&typeof r=="object"&&Z0 in r?r[Z0](n):r instanceof Date?new r.constructor(n):new Date(n)}function sn(r,n){return ds(n||r,r)}let mS={};function Ja(){return mS}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 oy(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 cy(r,...n){const s=ds.bind(null,r||n.find(a=>typeof a=="object"));return n.map(s)}function W0(r,n){const s=sn(r,n==null?void 0:n.in);return s.setHours(0,0,0,0),s}function pS(r,n,s){const[a,o]=cy(s==null?void 0:s.in,r,n),f=W0(a),h=W0(o),m=+f-Po(f),g=+h-Po(h);return Math.round((m-g)/dS)}function gS(r,n){const s=oy(r,n),a=ds(r,0);return a.setFullYear(s,0,4),a.setHours(0,0,0,0),Ho(a)}function yS(r,n){const s=+sn(r)-+sn(n);return s<0?-1:s>0?1:s}function bS(r){return ds(r,Date.now())}function xS(r){return r instanceof Date||typeof r=="object"&&Object.prototype.toString.call(r)==="[object Date]"}function vS(r){return!(!xS(r)&&typeof r!="number"||isNaN(+sn(r)))}function _S(r){return n=>{const a=(r?Math[r]:Math.trunc)(n);return a===0?0:a}}function wS(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 SS={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"}},ES=(r,n,s)=>{let a;const o=SS[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 AS={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},jS={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},OS={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},TS={date:Sf({formats:AS,defaultWidth:"full"}),time:Sf({formats:jS,defaultWidth:"full"}),dateTime:Sf({formats:OS,defaultWidth:"full"})},NS={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},CS=(r,n,s,a)=>NS[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 kS={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},MS={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},RS={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"]},DS={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"]},zS={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"}},qS={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"}},US=(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"},BS={ordinalNumber:US,era:Ta({values:kS,defaultWidth:"wide"}),quarter:Ta({values:MS,defaultWidth:"wide",argumentCallback:r=>r-1}),month:Ta({values:RS,defaultWidth:"wide"}),day:Ta({values:DS,defaultWidth:"wide"}),dayPeriod:Ta({values:zS,defaultWidth:"wide",formattingValues:qS,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)?HS(m,w=>w.test(h)):LS(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 LS(r,n){for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)&&n(r[s]))return s}function HS(r,n){for(let s=0;s<r.length;s++)if(n(r[s]))return s}function PS(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 $S=/^(\d+)(th|st|nd|rd)?/i,YS=/\d+/i,GS={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},VS={any:[/^b/i,/^(a|c)/i]},FS={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},JS={any:[/1/i,/2/i,/3/i,/4/i]},IS={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},QS={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]},XS={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},KS={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]},ZS={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},WS={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}},e2={ordinalNumber:PS({matchPattern:$S,parsePattern:YS,valueCallback:r=>parseInt(r,10)}),era:Na({matchPatterns:GS,defaultMatchWidth:"wide",parsePatterns:VS,defaultParseWidth:"any"}),quarter:Na({matchPatterns:FS,defaultMatchWidth:"wide",parsePatterns:JS,defaultParseWidth:"any",valueCallback:r=>r+1}),month:Na({matchPatterns:IS,defaultMatchWidth:"wide",parsePatterns:QS,defaultParseWidth:"any"}),day:Na({matchPatterns:XS,defaultMatchWidth:"wide",parsePatterns:KS,defaultParseWidth:"any"}),dayPeriod:Na({matchPatterns:ZS,defaultMatchWidth:"any",parsePatterns:WS,defaultParseWidth:"any"})},uy={code:"en-US",formatDistance:ES,formatLong:TS,formatRelative:CS,localize:BS,match:e2,options:{weekStartsOn:0,firstWeekContainsDate:1}};function t2(r,n){const s=sn(r,n==null?void 0:n.in);return pS(s,wS(s))+1}function n2(r,n){const s=sn(r,n==null?void 0:n.in),a=+Ho(s)-+gS(s);return Math.round(a/ly)+1}function fy(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 s2(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=fy(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 i2(r,n){const s=sn(r,n==null?void 0:n.in),a=+Ya(s,n)-+s2(s,n);return Math.round(a/ly)+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"},eg={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=fy(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=oy(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=i2(r,a);return n==="wo"?s.ordinalNumber(o,{unit:"week"}):Ve(o,n.length)},I:function(r,n,s){const a=n2(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=t2(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 ng(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 ng(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"+tg(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"+tg(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 tg(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 ng(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 sg=(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"})}},hy=(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"})}},r2=(r,n)=>{const s=r.match(/(P+)(p+)?/)||[],a=s[1],o=s[2];if(!o)return sg(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}}",sg(a,n)).replace("{{time}}",hy(o,n))},a2={p:hy,P:r2},l2=/^D+$/,o2=/^Y+$/,c2=["D","DD","YY","YYYY"];function u2(r){return l2.test(r)}function f2(r){return o2.test(r)}function h2(r,n,s){const a=d2(r,n,s);if(console.warn(a),c2.includes(r))throw new RangeError(a)}function d2(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 m2=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,p2=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,g2=/^'([^]*?)'?$/,y2=/''/g,b2=/[a-zA-Z]/;function gh(r,n,s){var E,w,T,q;const a=Ja(),o=a.locale??uy,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(!vS(m))throw new RangeError("Invalid time value");let g=n.match(p2).map(M=>{const D=M[0];if(D==="p"||D==="P"){const W=a2[D];return W(M,o.formatLong)}return M}).join("").match(m2).map(M=>{if(M==="''")return{isToken:!1,value:"'"};const D=M[0];if(D==="'")return{isToken:!1,value:x2(M)};if(eg[D])return{isToken:!0,value:M};if(D.match(b2))throw new RangeError("Format string contains an unescaped latin alphabet character `"+D+"`");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 D=M.value;(f2(D)||u2(D))&&h2(D,n,String(r));const W=eg[D[0]];return W(m,D,o.localize,y)}).join("")}function x2(r){const n=r.match(g2);return n?n[1].replace(y2,"'"):r}function v2(r,n,s){const a=Ja(),o=(s==null?void 0:s.locale)??a.locale??uy,f=yS(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]=cy(s==null?void 0:s.in,...f>0?[n,r]:[r,n]),y=_S((s==null?void 0:s.roundingMethod)??"round"),E=g.getTime()-m.getTime(),w=E/I0,T=Po(g)-Po(m),q=(E-T)/I0,M=s==null?void 0:s.unit;let D;if(M?D=M:w<1?D="second":w<60?D="minute":w<K0?D="hour":q<X0?D="day":q<Q0?D="month":D="year",D==="second"){const W=y(E/1e3);return o.formatDistance("xSeconds",W,h)}else if(D==="minute"){const W=y(w);return o.formatDistance("xMinutes",W,h)}else if(D==="hour"){const W=y(w/60);return o.formatDistance("xHours",W,h)}else if(D==="day"){const W=y(q/K0);return o.formatDistance("xDays",W,h)}else if(D==="month"){const W=y(q/X0);return W===12&&M!=="month"?o.formatDistance("xYears",1,h):o.formatDistance("xMonths",W,h)}else{const W=y(q/Q0);return o.formatDistance("xYears",W,h)}}function _2(r,n){return v2(r,bS(r),n)}function WE(r){return r.toLocaleString()}function e3(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 w2(r){const n=new Date(r);return n.getTime()>Date.now()?"just now":_2(n,{addSuffix:!0})}function t3(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 n3(r){return r<=0?"Expired":yh(r)}function S2(r){return r==null?"--":yh(r)}function s3(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 i3(r,n){const s=new Date(r).getTime(),a=n?new Date(n).getTime():Date.now();return yh(a-s)}function dy({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 se=y.current.getBoundingClientRect(),ee=window.innerWidth-T-8,me=Math.max(8,Math.min(se.left,ee));g({top:se.bottom+4,left:me})},[]),M=O.useCallback(async(se,ee)=>{try{await navigator.clipboard.writeText(se),h(ee),clearTimeout(E.current),E.current=setTimeout(()=>h(null),1200)}catch{}},[]),D=O.useCallback(()=>{clearTimeout(w.current),q(),o(!0)},[q]),W=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:D,onMouseLeave:W,children:[n,a&&m&&fg.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:D,onMouseLeave:W,children:r.map(se=>d.jsxs("button",{onClick:ee=>{ee.stopPropagation(),M(se.value,se.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:se.label}),d.jsx("span",{className:"text-[10px] font-mono text-text-secondary truncate ml-2",children:f===se.label?"✓":se.value})]},se.label))}),document.body)]})}function E2(r,n){const s=new Date(r);switch(n){case"relative":return w2(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 A2(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 j2({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(()=>A2(r),[r]);return d.jsx(dy,{options:o,children:d.jsx("time",{dateTime:r,className:`text-xs text-text-tertiary ${s}`,children:E2(r,n)})})}function O2({ms:r,className:n=""}){const s=S2(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(dy,{options:a,children:d.jsx("span",{className:`text-xs text-text-tertiary ${n}`,children:s})})}const T2=["sm","md","lg","full"],ig={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"},rg={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function N2({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 C2({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 k2({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(j2,{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(O2,{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(Kx,{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 M2(){const{helpOpen:r,setHelpOpen:n,messages:s,sendMessage:a,pageContext:o,activeWorkflowId:f,clearMessages:h,compileMessage:m}=ay(),[g,y]=O.useState(""),[E,w]=O.useState("md"),[T,q]=O.useState(!0),M=O.useRef(null),D=O.useRef(null);if(O.useEffect(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[s]),O.useEffect(()=>{r&&D.current&&D.current.focus()},[r]),O.useEffect(()=>{if(!r)return;const C=X=>{X.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 W=()=>{const C=g.trim();!C||f||(a(C),y(""),D.current&&(D.current.style.height="auto"))},se=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),W())},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?ig.full:`right-6 ${ig[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:T2.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":rg[C],title:rg[C],children:d.jsx(N2,{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(Zx,{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(C2,{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(k2,{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:D,value:g,onChange:C=>{y(C.target.value);const X=C.target;X.style.height="auto",X.style.height=`${Math.min(X.scrollHeight,120)}px`},onKeyDown:se,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:W,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(Wx,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}function R2(){var M;const{isBuilder:r,isOps:n}=Kg(),{data:s}=Qo(),a=!!((M=s==null?void 0:s.ai)!=null&&M.enabled),{collapsed:o,toggle:f}=Wg(),[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 D=q.current;D&&(D.classList.remove("animate-page-in"),D.offsetWidth,D.classList.add("animate-page-in"))},[T.pathname]),O.useEffect(()=>{const D=()=>{window.location.hash.startsWith("#docs")&&w(!0)};return window.addEventListener("hashchange",D),()=>window.removeEventListener("hashchange",D)},[]),d.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[d.jsx(_w,{onToggleEventFeed:()=>m(D=>!D),onToggleDocs:()=>w(D=>!D)}),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(jw,{aiEnabled:a,isBuilder:r,isOps:n}),r&&d.jsx(Ow,{}),r&&a&&d.jsx(Nw,{}),r&&d.jsx(kw,{}),(r||n)&&d.jsx(Mw,{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(ev,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):d.jsx(tv,{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(Kw,{open:h,onToggle:()=>m(D=>!D),configOpen:g,onToggleConfig:()=>y(D=>!D)}),d.jsx(lS,{open:E,onClose:()=>{w(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),a&&d.jsx(hS,{}),a&&d.jsx(M2,{})]})}function D2(){const{isAuthenticated:r}=Oi(),n=ei();return r?d.jsx(yw,{children:d.jsx(fS,{children:d.jsx(R2,{})})}):d.jsx(Bn,{to:"/login",state:{from:n.pathname},replace:!0})}function my({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 z2(){return $e("/auth/oauth/providers")}async function q2(r,n){const s=n?`?label=${encodeURIComponent(n)}`:"";return $e(`/auth/oauth/connections/${r}${s}`,{method:"DELETE"})}function r3(){return _n({queryKey:["oauth-connections"],queryFn:()=>$e("/auth/oauth/connections")})}function a3(){const r=rn();return wn({mutationFn:({provider:n,label:s})=>q2(n,s),onSuccess:()=>{r.invalidateQueries({queryKey:["oauth-connections"]})}})}function U2(){var ce;const{login:r,isAuthenticated:n}=Oi(),s=hg(),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||""),[D,W]=O.useState(!1),[se,ee]=O.useState(!!f),[me,re]=O.useState([]),C=O.useRef(!1);if(O.useEffect(()=>{f||C.current||(C.current=!0,(async()=>{var V,G,K,ae;try{const ne=await fetch(`${Wt}/api/settings`);if(!ne.ok)return;const ke=await ne.json();if(!((V=ke.auth)!=null&&V.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&&((G=ke.auth)!=null&&G.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",ke.auth.ssoLogoutUrl),ee(!0),r(Me.token,void 0,{displayName:(K=Me.user)==null?void 0:K.display_name,username:(ae=Me.user)==null?void 0:ae.external_id}))}catch{}})())},[]),O.useEffect(()=>{f||z2().then(re).catch(()=>{})},[]),O.useEffect(()=>{if(!se)return;const V=setTimeout(()=>s(m,{replace:!0}),1500);return()=>clearTimeout(V)},[se]),n&&!se)return d.jsx(Bn,{to:m,replace:!0});const X=async V=>{var G,K;if(V.preventDefault(),M(""),!y.trim()||!w){M("Username and password are required");return}W(!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})}),ne=await ae.json();if(!ae.ok){M(ne.error||"Login failed");return}ee(!0),r(ne.token,{username:y.trim(),password:w},{displayName:(G=ne.user)==null?void 0:G.display_name,username:(K=ne.user)==null?void 0:K.external_id})}catch{M("Unable to connect to server")}finally{W(!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 ${se?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:d.jsx(dh,{size:"lg",hideLabel:se})}),d.jsxs("form",{onSubmit:X,className:`space-y-5 transition-opacity duration-300 ${se?"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:V=>E(V.target.value),className:"input",placeholder:"Enter your username",autoFocus:!se,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:V=>T(V.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:D||se,children:D?"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(V=>V.provider!=="anthropic").map(V=>d.jsxs("a",{href:`${Wt}/api/auth/oauth/${V.provider}?returnTo=${encodeURIComponent(m)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[d.jsx(my,{provider:V.provider}),"Sign in with ",V.name]},V.provider))})]})]})]})})}function ag(){const{isAuthenticated:r}=Oi(),n=hg(),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"),D=W=>{W.preventDefault();const se=f.trim();if(!se){E("A token or API key is required");return}if(!se.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(se)}&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(my,{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:D,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:W=>h(W.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:W=>g(W.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 B2({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 L2({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 H2=O.lazy(()=>ve(()=>import("./ProcessesListPage-CrLGDCAD.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}))),P2=O.lazy(()=>ve(()=>import("./ProcessDetailPage-DBIrY6Vd.js"),__vite__mapDeps([18,1,2,4,19,15,20,17,11,6,21,22,23]),import.meta.url).then(r=>({default:r.ProcessDetailPage}))),$2=O.lazy(()=>ve(()=>import("./McpOverview-mfJpETsW.js"),__vite__mapDeps([24,1,25,26,27,28,14,15,29,6]),import.meta.url).then(r=>({default:r.McpOverview}))),Y2=O.lazy(()=>ve(()=>import("./McpRunsPage-MIwmK-Ky.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}))),G2=O.lazy(()=>ve(()=>import("./McpRunDetailPage-CyTbHs0J.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}))),V2=O.lazy(()=>ve(()=>import("./McpQueryPage-CKKOxks0.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}))),F2=O.lazy(()=>ve(()=>import("./McpQueryDetailPage-Cb99vI7v.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}))),J2=O.lazy(()=>ve(()=>import("./EscalationsOverview-CiQO3ntf.js"),__vite__mapDeps([52,1,4,14,15,29,6]),import.meta.url).then(r=>({default:r.EscalationsOverview}))),I2=O.lazy(()=>ve(()=>import("./AvailableEscalationsPage-CUHcybKU.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}))),Q2=O.lazy(()=>ve(()=>import("./OperatorDashboard-K1gzULr7.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}))),X2=O.lazy(()=>ve(()=>import("./index-CoGkgm9-.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}))),K2=O.lazy(()=>ve(()=>import("./WorkflowsOverview-B8262fVx.js"),__vite__mapDeps([63,1,3,4,14,15,29,6]),import.meta.url).then(r=>({default:r.WorkflowsOverview}))),Z2=O.lazy(()=>ve(()=>import("./index-CkL8bpdH.js"),__vite__mapDeps([64,1,3,14,15,17,65,48,49,6]),import.meta.url).then(r=>({default:r.StartWorkflowPage}))),W2=O.lazy(()=>ve(()=>import("./index-CkL8bpdH.js"),__vite__mapDeps([64,1,3,14,15,17,65,48,49,6]),import.meta.url).then(r=>({default:r.DurableInvokePage}))),eE=O.lazy(()=>ve(()=>import("./WorkflowsDashboard-bJ6Zebfv.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"})}))),tE=O.lazy(()=>ve(()=>import("./WorkflowsDashboard-bJ6Zebfv.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"})}))),nE=O.lazy(()=>ve(()=>import("./YamlWorkflowsPage-C8hBjSn_.js"),__vite__mapDeps([67,1,27,5,6,14,15,13,10,50,65,20]),import.meta.url).then(r=>({default:r.YamlWorkflowsPage}))),sE=O.lazy(()=>ve(()=>import("./GraphInvokePage-BFRi6Nny.js"),__vite__mapDeps([68,1,27,14,15,45,47,48,49,46,6,50,65]),import.meta.url).then(r=>({default:r.GraphInvokePage}))),iE=O.lazy(()=>ve(()=>import("./YamlWorkflowDetailPage-DhW3q2cO.js"),__vite__mapDeps([69,1,27,20,65,15,6]),import.meta.url).then(r=>({default:r.YamlWorkflowDetailPage}))),rE=O.lazy(()=>ve(()=>import("./TasksListPage-Dlsu7cWG.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}))),aE=O.lazy(()=>ve(()=>import("./TaskDetailPage-B9owzuhV.js"),__vite__mapDeps([71,1,2,20,59,14,15,6]),import.meta.url).then(r=>({default:r.TaskDetailPage}))),lg=O.lazy(()=>ve(()=>import("./WorkflowExecutionPage-Dhb9EWgI.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}))),lE=O.lazy(()=>ve(()=>import("./AdminDashboard-rZDVS2G_.js"),__vite__mapDeps([73,1,2,4,25,19,15,6]),import.meta.url).then(r=>({default:r.AdminDashboard}))),oE=O.lazy(()=>ve(()=>import("./index-BkwsJ-0v.js"),__vite__mapDeps([74,1,3,9,10,13,33,5,6,14,15,75,17]),import.meta.url).then(r=>({default:r.WorkersPage}))),cE=O.lazy(()=>ve(()=>import("./index-n-lZY5S6.js"),__vite__mapDeps([76,1,3,77,55,6,21,15,17,14,57,48,49,65]),import.meta.url).then(r=>({default:r.WorkflowConfigsPage}))),og=O.lazy(()=>ve(()=>import("./index-n-lZY5S6.js"),__vite__mapDeps([76,1,3,77,55,6,21,15,17,14,57,48,49,65]),import.meta.url).then(r=>({default:r.WorkflowConfigDetailPage}))),uE=O.lazy(()=>ve(()=>import("./index-BK3PVYcd.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}))),cg=O.lazy(()=>ve(()=>import("./index-DTrcYOM2.js"),__vite__mapDeps([80,1,25,14,15,44,6]),import.meta.url).then(r=>({default:r.McpServerDetailPage}))),fE=O.lazy(()=>ve(()=>import("./index-NfVWOFbF.js"),__vite__mapDeps([81,1,23,5,6,9,10,12,13,11,77,55,33,14,15,21,49,57,51]),import.meta.url).then(r=>({default:r.UsersPage}))),hE=O.lazy(()=>ve(()=>import("./RolesPage-B0ZgjB2V.js"),__vite__mapDeps([82,1,57,14,15,55,6]),import.meta.url).then(r=>({default:r.RolesPage}))),dE=O.lazy(()=>ve(()=>import("./RoleDetailPage-7j6Mk780.js"),__vite__mapDeps([83,1,57,77,55,6,23,15]),import.meta.url).then(r=>({default:r.RoleDetailPage}))),mE=O.lazy(()=>ve(()=>import("./EscalationSchemaPage-Do2iPKUl.js"),__vite__mapDeps([84,1,57,15,6]),import.meta.url).then(r=>({default:r.EscalationSchemaPage}))),pE=O.lazy(()=>ve(()=>import("./index-DGKgXObc.js"),__vite__mapDeps([85,1,14,15,55,6,56]),import.meta.url).then(r=>({default:r.MaintenancePage}))),gE=O.lazy(()=>ve(()=>import("./OperationsPage-DPesph0U.js"),__vite__mapDeps([86,1,57,4,14,15,6]),import.meta.url).then(r=>({default:r.OperationsPage}))),yE=O.lazy(()=>ve(()=>import("./index-eLRh-2NW.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}))),bE=O.lazy(()=>ve(()=>import("./index-CaMVn0kW.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}))),xE=O.lazy(()=>ve(()=>import("./CredentialsPage-DdZ-jyyc.js"),__vite__mapDeps([89,1,14,15,51,77,55,6]),import.meta.url).then(r=>({default:r.CredentialsPage}))),vE=O.lazy(()=>ve(()=>import("./index-YliQ4kW_.js"),__vite__mapDeps([90,1,6,14,15,13,16,8,10,91,51]),import.meta.url).then(r=>({default:r.FilesPage}))),_E=O.lazy(()=>ve(()=>import("./index-qT7eB_Hk.js"),__vite__mapDeps([92,1,14,15,13,16,12,10,91,51,93,44,6]),import.meta.url).then(r=>({default:r.KnowledgePage}))),wE=O.lazy(()=>ve(()=>import("./HomePage-m1pnxilb.js"),__vite__mapDeps([94,1,3,26,28,2,4,21,15,17,16,6]),import.meta.url).then(r=>({default:r.HomePage}))),SE=O.lazy(()=>ve(()=>import("./AgentsPage-C8fKLxh-.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}))),EE=O.lazy(()=>ve(()=>import("./AgentDetailPage-DMeHvidT.js"),__vite__mapDeps([97,1,96,98,15,4,17,6]),import.meta.url).then(r=>({default:r.AgentDetailPage}))),ug=O.lazy(()=>ve(()=>import("./AgentConfigPage-CbyyCjCT.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}))),AE=O.lazy(()=>ve(()=>import("./CapabilitiesPage-ClfuW4ya.js"),__vite__mapDeps([102,1,100,79,25,47,48,49,15,50,6,46,14]),import.meta.url).then(r=>({default:r.CapabilitiesPage}))),jE=O.lazy(()=>ve(()=>import("./TopicsPage-CAG0RhAK.js"),__vite__mapDeps([103,1,101,14,15,6]),import.meta.url).then(r=>({default:r.TopicsPage}))),OE=O.lazy(()=>ve(()=>import("./TopicDetailPage-HuDx2oAW.js"),__vite__mapDeps([104,1,101,16,15,6]),import.meta.url).then(r=>({default:r.TopicDetailPage})));function TE(){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(TE,{}),children:d.jsx("div",{className:"animate-page-enter",children:r})})}const py=new jx({defaultOptions:{queries:{staleTime:1e4,retry:(r,n)=>n instanceof Error&&n.message==="Session expired"?!1:r<1}}});window.addEventListener("auth:unauthorized",()=>{py.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 NE=Nx([{path:"/login",element:d.jsx(U2,{})},{path:"/connect/anthropic",element:d.jsx(ag,{})},{path:"/connect/:provider",element:d.jsx(ag,{})},{path:"/",element:d.jsx(D2,{}),children:[{index:!0,element:d.jsx(be,{children:d.jsx(wE,{})})},{path:"processes/all",element:d.jsx(be,{children:d.jsx(H2,{})})},{path:"processes/detail/:originId",element:d.jsx(be,{children:d.jsx(P2,{})})},{path:"credentials",element:d.jsx(be,{children:d.jsx(xE,{})})},{path:"connections",element:d.jsx(Bn,{to:"/credentials",replace:!0})},{path:"escalations",element:d.jsx(be,{children:d.jsx(J2,{})})},{path:"escalations/available",element:d.jsx(be,{children:d.jsx(I2,{})})},{path:"escalations/queue",element:d.jsx(be,{children:d.jsx(Q2,{})})},{path:"escalations/detail/:id",element:d.jsx(be,{children:d.jsx(X2,{})})},{path:"capabilities",element:d.jsx(be,{children:d.jsx(AE,{})})},{path:"agents",element:d.jsx(be,{children:d.jsx(SE,{})})},{path:"agents/new",element:d.jsx(be,{children:d.jsx(ug,{})})},{path:"agents/:id",element:d.jsx(be,{children:d.jsx(EE,{})})},{path:"agents/:id/edit",element:d.jsx(be,{children:d.jsx(ug,{})})},{path:"topics",element:d.jsx(be,{children:d.jsx(jE,{})})},{path:"topics/:topic",element:d.jsx(be,{children:d.jsx(OE,{})})},{element:d.jsx(Ca,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:d.jsx(be,{children:d.jsx(K2,{})})},{path:"workflows/executions",element:d.jsx(be,{children:d.jsx(tE,{})})},{path:"workflows/durable/executions",element:d.jsx(be,{children:d.jsx(eE,{})})},{path:"workflows/durable/executions/:workflowId",element:d.jsx(be,{children:d.jsx(lg,{})})},{path:"workflows/tasks",element:d.jsx(be,{children:d.jsx(rE,{})})},{path:"workflows/tasks/detail/:id",element:d.jsx(be,{children:d.jsx(aE,{})})},{path:"workflows/executions/:workflowId",element:d.jsx(be,{children:d.jsx(lg,{})})},{path:"workflows/start",element:d.jsx(be,{children:d.jsx(Z2,{})})},{path:"workflows/durable/invoke",element:d.jsx(be,{children:d.jsx(W2,{})})},{path:"workflows/cron",element:d.jsx(Bn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:d.jsx(be,{children:d.jsx(oE,{})})},{path:"workflows/registry",element:d.jsx(be,{children:d.jsx(cE,{})})},{path:"workflows/registry/new",element:d.jsx(be,{children:d.jsx(og,{})})},{path:"workflows/registry/:workflowType",element:d.jsx(be,{children:d.jsx(og,{})})}]},{element:d.jsx(Ca,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:d.jsx(be,{children:d.jsx(nE,{})})},{path:"mcp/workflows/invoke",element:d.jsx(be,{children:d.jsx(sE,{})})},{path:"mcp/workflows/:id",element:d.jsx(be,{children:d.jsx(iE,{})})},{path:"mcp/executions",element:d.jsx(be,{children:d.jsx(Y2,{})})},{path:"mcp/executions/:jobId",element:d.jsx(be,{children:d.jsx(G2,{})})},{path:"files",element:d.jsx(be,{children:d.jsx(vE,{})})},{path:"knowledge",element:d.jsx(be,{children:d.jsx(_E,{})})},{element:d.jsx(B2,{}),children:[{path:"mcp",element:d.jsx(be,{children:d.jsx($2,{})})},{path:"mcp/queries",element:d.jsx(be,{children:d.jsx(V2,{})})},{path:"mcp/queries/:workflowId",element:d.jsx(be,{children:d.jsx(F2,{})})},{path:"mcp/tools",element:d.jsx(Bn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:d.jsx(be,{children:d.jsx(uE,{})})},{path:"mcp/servers/new",element:d.jsx(be,{children:d.jsx(cg,{})})},{path:"mcp/servers/:serverId",element:d.jsx(be,{children:d.jsx(cg,{})})}]}]},{element:d.jsx(Ca,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"operations",element:d.jsx(be,{children:d.jsx(gE,{})})}]},{element:d.jsx(Ca,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:d.jsx(be,{children:d.jsx(lE,{})})},{path:"admin/users",element:d.jsx(be,{children:d.jsx(fE,{})})},{path:"admin/escalation-chains",element:d.jsx(Bn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:d.jsx(be,{children:d.jsx(hE,{})})},{path:"admin/roles/:role",element:d.jsx(be,{children:d.jsx(dE,{})})},{path:"admin/roles/:role/schema",element:d.jsx(be,{children:d.jsx(mE,{})})}]},{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(L2,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:d.jsx(be,{children:d.jsx(pE,{})})}]},{path:"admin/controlplane",element:d.jsx(be,{children:d.jsx(yE,{})})},{path:"admin/streams",element:d.jsx(be,{children:d.jsx(bE,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function CE(){return d.jsx(Ox,{client:py,children:d.jsx(uv,{children:d.jsx(mw,{children:d.jsx(Cx,{router:NE})})})})}av.createRoot(document.getElementById("root")).render(d.jsx(O.StrictMode,{children:d.jsx(CE,{})}));export{PE as A,VE as B,mh as C,O2 as D,KE as E,ny as F,gh as G,dy as H,n3 as I,Iw as J,qE as K,WE as L,Wt as M,d_ as N,bg as O,r3 as P,a3 as Q,my as R,qw as S,e3 as T,i3 as a,j2 as b,p_ as c,$e as d,HE as e,S2 as f,$E as g,GE as h,UE as i,Oi as j,LE as k,FE as l,JE as m,IE as n,QE as o,XE as p,ZE as q,BE as r,xw as s,bw as t,Qo as u,Kg as v,YE as w,s3 as x,t3 as y,yh as z};
63
+ //# sourceMappingURL=index-D-7W2AHB.js.map