@hotmeshio/long-tail 0.22.2 → 0.23.0

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 (266) hide show
  1. package/build/api/escalations/accumulate.js +7 -1
  2. package/build/api/escalations/lookups.d.ts +9 -2
  3. package/build/api/escalations/lookups.js +15 -3
  4. package/build/api/escalations/metadata.d.ts +2 -0
  5. package/build/api/escalations/metadata.js +9 -0
  6. package/build/api/escalations/resolve-batch.d.ts +2 -1
  7. package/build/api/escalations/resolve-batch.js +6 -5
  8. package/build/api/scan-codes/locate.js +4 -0
  9. package/build/api/scan-codes/present.d.ts +1 -1
  10. package/build/api/scan-codes/present.js +43 -0
  11. package/build/api/scan-codes/verb-accumulate.js +5 -1
  12. package/build/api/scan-codes/verb-fill.js +4 -1
  13. package/build/api/scan-codes/verb-into-subject.d.ts +12 -0
  14. package/build/api/scan-codes/verb-into-subject.js +157 -0
  15. package/build/api/scan-codes/verbs-subject.d.ts +23 -4
  16. package/build/api/scan-codes/verbs-subject.js +32 -55
  17. package/build/api/scan-codes/verbs.d.ts +10 -8
  18. package/build/api/scan-codes/verbs.js +25 -16
  19. package/build/index.d.ts +1 -1
  20. package/build/index.js +3 -2
  21. package/build/sdk/index.d.ts +1 -0
  22. package/build/services/escalation/batch.d.ts +4 -4
  23. package/build/services/escalation/batch.js +7 -4
  24. package/build/services/escalation/claim-asserted.d.ts +10 -0
  25. package/build/services/escalation/claim-asserted.js +64 -0
  26. package/build/services/escalation/facets.d.ts +3 -1
  27. package/build/services/escalation/facets.js +7 -3
  28. package/build/services/escalation/index.d.ts +1 -0
  29. package/build/services/escalation/index.js +3 -1
  30. package/build/services/knowledge/lookup-cache.d.ts +16 -4
  31. package/build/services/knowledge/lookup-cache.js +53 -20
  32. package/build/services/knowledge/lookup-refs.d.ts +3 -2
  33. package/build/services/knowledge/lookup-refs.js +6 -4
  34. package/build/services/knowledge/sql.d.ts +2 -0
  35. package/build/services/knowledge/sql.js +9 -1
  36. package/build/services/mcp/server-tools.js +1 -1
  37. package/build/services/orchestrator/condition.d.ts +17 -11
  38. package/build/services/orchestrator/condition.js +12 -7
  39. package/build/services/scan-code/index.d.ts +1 -1
  40. package/build/services/scan-code/index.js +2 -1
  41. package/build/services/scan-code/validate-facts.d.ts +5 -0
  42. package/build/services/scan-code/validate-facts.js +24 -0
  43. package/build/services/scan-code/validate-query.d.ts +8 -0
  44. package/build/services/scan-code/validate-query.js +36 -0
  45. package/build/services/scan-code/validate-subject.js +29 -2
  46. package/build/services/scan-code/validate.js +17 -8
  47. package/build/shared/scan-code/gtin.d.ts +6 -0
  48. package/build/shared/scan-code/gtin.js +13 -0
  49. package/build/shared/scan-code/index.d.ts +1 -1
  50. package/build/shared/scan-code/index.js +2 -1
  51. package/build/system/mcp-servers/admin/schemas.d.ts +185 -5
  52. package/build/system/mcp-servers/admin/schemas.js +16 -3
  53. package/build/system/seed/tool-manifests-admin.d.ts +202 -1
  54. package/build/system/seed/tool-manifests-admin.js +2 -2
  55. package/build/tsconfig.tsbuildinfo +1 -1
  56. package/build/types/escalation.d.ts +23 -8
  57. package/build/types/escalation.js +18 -7
  58. package/build/types/index.d.ts +3 -3
  59. package/build/types/index.js +3 -1
  60. package/build/types/scan-code/response.d.ts +5 -0
  61. package/build/types/scan-code/rule.d.ts +32 -2
  62. package/dashboard/dist/assets/{AdminDashboard-DBW12qQt.js → AdminDashboard-DKrqLGjn.js} +2 -2
  63. package/dashboard/dist/assets/{AdminDashboard-DBW12qQt.js.map → AdminDashboard-DKrqLGjn.js.map} +1 -1
  64. package/dashboard/dist/assets/{AgentConfigPage-CmHv8U9M.js → AgentConfigPage-BoQhRW6U.js} +2 -2
  65. package/dashboard/dist/assets/{AgentConfigPage-CmHv8U9M.js.map → AgentConfigPage-BoQhRW6U.js.map} +1 -1
  66. package/dashboard/dist/assets/{AgentDetailPage-D1scIbz-.js → AgentDetailPage-DZhzuZmO.js} +2 -2
  67. package/dashboard/dist/assets/{AgentDetailPage-D1scIbz-.js.map → AgentDetailPage-DZhzuZmO.js.map} +1 -1
  68. package/dashboard/dist/assets/{AgentsPage-BA_ai9HJ.js → AgentsPage-5MynmbWX.js} +2 -2
  69. package/dashboard/dist/assets/{AgentsPage-BA_ai9HJ.js.map → AgentsPage-5MynmbWX.js.map} +1 -1
  70. package/dashboard/dist/assets/{AvailableEscalationsPage-C2_5aEFW.js → AvailableEscalationsPage-CWMyy3IL.js} +2 -2
  71. package/dashboard/dist/assets/{AvailableEscalationsPage-C2_5aEFW.js.map → AvailableEscalationsPage-CWMyy3IL.js.map} +1 -1
  72. package/dashboard/dist/assets/{BotPicker-BZo4Kp4a.js → BotPicker-C3LR6Sqy.js} +2 -2
  73. package/dashboard/dist/assets/{BotPicker-BZo4Kp4a.js.map → BotPicker-C3LR6Sqy.js.map} +1 -1
  74. package/dashboard/dist/assets/{BulkAssignModal-BFhyxY2T.js → BulkAssignModal-COjoOIIH.js} +2 -2
  75. package/dashboard/dist/assets/{BulkAssignModal-BFhyxY2T.js.map → BulkAssignModal-COjoOIIH.js.map} +1 -1
  76. package/dashboard/dist/assets/{CapabilitiesPage-CvOX6vAc.js → CapabilitiesPage-DKxLvOfB.js} +2 -2
  77. package/dashboard/dist/assets/{CapabilitiesPage-CvOX6vAc.js.map → CapabilitiesPage-DKxLvOfB.js.map} +1 -1
  78. package/dashboard/dist/assets/{CollapsibleSection-GCJsV9Oq.js → CollapsibleSection-Cz5sRx-r.js} +2 -2
  79. package/dashboard/dist/assets/{CollapsibleSection-GCJsV9Oq.js.map → CollapsibleSection-Cz5sRx-r.js.map} +1 -1
  80. package/dashboard/dist/assets/{ConfirmDeleteModal-CAgYLcef.js → ConfirmDeleteModal-Beq1vQtY.js} +2 -2
  81. package/dashboard/dist/assets/{ConfirmDeleteModal-CAgYLcef.js.map → ConfirmDeleteModal-Beq1vQtY.js.map} +1 -1
  82. package/dashboard/dist/assets/{CountdownTimer-Dik2z0M_.js → CountdownTimer-BUBl_4mP.js} +2 -2
  83. package/dashboard/dist/assets/{CountdownTimer-Dik2z0M_.js.map → CountdownTimer-BUBl_4mP.js.map} +1 -1
  84. package/dashboard/dist/assets/{CredentialsPage-twd2xCOW.js → CredentialsPage-DhiHiPsG.js} +2 -2
  85. package/dashboard/dist/assets/{CredentialsPage-twd2xCOW.js.map → CredentialsPage-DhiHiPsG.js.map} +1 -1
  86. package/dashboard/dist/assets/{CronLabel-DdnIuudX.js → CronLabel-C9SkawB-.js} +2 -2
  87. package/dashboard/dist/assets/{CronLabel-DdnIuudX.js.map → CronLabel-C9SkawB-.js.map} +1 -1
  88. package/dashboard/dist/assets/{ElapsedCell-DCctVv5R.js → ElapsedCell-BeK1SUDK.js} +2 -2
  89. package/dashboard/dist/assets/{ElapsedCell-DCctVv5R.js.map → ElapsedCell-BeK1SUDK.js.map} +1 -1
  90. package/dashboard/dist/assets/{EntityTimelinePanel-CMnskyWv.js → EntityTimelinePanel-BThdefKj.js} +2 -2
  91. package/dashboard/dist/assets/{EntityTimelinePanel-CMnskyWv.js.map → EntityTimelinePanel-BThdefKj.js.map} +1 -1
  92. package/dashboard/dist/assets/{EscalationListSchemaPage-VfCn6WDb.js → EscalationListSchemaPage-DlDIYb-p.js} +2 -2
  93. package/dashboard/dist/assets/{EscalationListSchemaPage-VfCn6WDb.js.map → EscalationListSchemaPage-DlDIYb-p.js.map} +1 -1
  94. package/dashboard/dist/assets/{EscalationListView-CGQZxcC-.js → EscalationListView-DTIVuym4.js} +2 -2
  95. package/dashboard/dist/assets/{EscalationListView-CGQZxcC-.js.map → EscalationListView-DTIVuym4.js.map} +1 -1
  96. package/dashboard/dist/assets/{EscalationSchemaPage-BX0tx-PM.js → EscalationSchemaPage-CQt-Embr.js} +2 -2
  97. package/dashboard/dist/assets/{EscalationSchemaPage-BX0tx-PM.js.map → EscalationSchemaPage-CQt-Embr.js.map} +1 -1
  98. package/dashboard/dist/assets/{EscalationTimeline-DKoSM56J.js → EscalationTimeline-DNKNp6pL.js} +2 -2
  99. package/dashboard/dist/assets/{EscalationTimeline-DKoSM56J.js.map → EscalationTimeline-DNKNp6pL.js.map} +1 -1
  100. package/dashboard/dist/assets/{EscalationTitleSelect-DWGLBOmS.js → EscalationTitleSelect-Dewrv8wX.js} +2 -2
  101. package/dashboard/dist/assets/{EscalationTitleSelect-DWGLBOmS.js.map → EscalationTitleSelect-Dewrv8wX.js.map} +1 -1
  102. package/dashboard/dist/assets/{EscalationsOverview-C2XoguaA.js → EscalationsOverview-BzH-Y-5x.js} +2 -2
  103. package/dashboard/dist/assets/{EscalationsOverview-C2XoguaA.js.map → EscalationsOverview-BzH-Y-5x.js.map} +1 -1
  104. package/dashboard/dist/assets/{EventTable-CBUWq7--.js → EventTable-C97m6IZv.js} +2 -2
  105. package/dashboard/dist/assets/{EventTable-CBUWq7--.js.map → EventTable-C97m6IZv.js.map} +1 -1
  106. package/dashboard/dist/assets/{FilterBar-8IdbleZ9.js → FilterBar-D-6xVHIw.js} +2 -2
  107. package/dashboard/dist/assets/{FilterBar-8IdbleZ9.js.map → FilterBar-D-6xVHIw.js.map} +1 -1
  108. package/dashboard/dist/assets/{GraphInvokePage-CUvoPzsW.js → GraphInvokePage-Bwi8EF9Y.js} +2 -2
  109. package/dashboard/dist/assets/{GraphInvokePage-CUvoPzsW.js.map → GraphInvokePage-Bwi8EF9Y.js.map} +1 -1
  110. package/dashboard/dist/assets/{HomePage-BP7v9GLJ.js → HomePage-Z_Q03C0z.js} +2 -2
  111. package/dashboard/dist/assets/{HomePage-BP7v9GLJ.js.map → HomePage-Z_Q03C0z.js.map} +1 -1
  112. package/dashboard/dist/assets/{ListToolbar-Cnacuwoy.js → ListToolbar-_jWTw5no.js} +2 -2
  113. package/dashboard/dist/assets/{ListToolbar-Cnacuwoy.js.map → ListToolbar-_jWTw5no.js.map} +1 -1
  114. package/dashboard/dist/assets/{McpOverview-C2JoNoDA.js → McpOverview-CjqTuP0N.js} +2 -2
  115. package/dashboard/dist/assets/{McpOverview-C2JoNoDA.js.map → McpOverview-CjqTuP0N.js.map} +1 -1
  116. package/dashboard/dist/assets/{McpQueryDetailPage-C_nih0w-.js → McpQueryDetailPage-leCsje1U.js} +2 -2
  117. package/dashboard/dist/assets/{McpQueryDetailPage-C_nih0w-.js.map → McpQueryDetailPage-leCsje1U.js.map} +1 -1
  118. package/dashboard/dist/assets/{McpQueryPage-U_wNXow2.js → McpQueryPage-C-PyXYX4.js} +2 -2
  119. package/dashboard/dist/assets/{McpQueryPage-U_wNXow2.js.map → McpQueryPage-C-PyXYX4.js.map} +1 -1
  120. package/dashboard/dist/assets/{McpRunDetailPage-DtKoJq6J.js → McpRunDetailPage-JDrr3uUQ.js} +2 -2
  121. package/dashboard/dist/assets/{McpRunDetailPage-DtKoJq6J.js.map → McpRunDetailPage-JDrr3uUQ.js.map} +1 -1
  122. package/dashboard/dist/assets/{McpRunsPage-CnYtfGhf.js → McpRunsPage-DERXQLgZ.js} +2 -2
  123. package/dashboard/dist/assets/{McpRunsPage-CnYtfGhf.js.map → McpRunsPage-DERXQLgZ.js.map} +1 -1
  124. package/dashboard/dist/assets/{OperationsPage-C7hupIer.js → OperationsPage-B2DA7n9m.js} +2 -2
  125. package/dashboard/dist/assets/{OperationsPage-C7hupIer.js.map → OperationsPage-B2DA7n9m.js.map} +1 -1
  126. package/dashboard/dist/assets/{OperatorDashboard-fVuLn2D5.js → OperatorDashboard-C8RtPv8P.js} +2 -2
  127. package/dashboard/dist/assets/{OperatorDashboard-fVuLn2D5.js.map → OperatorDashboard-C8RtPv8P.js.map} +1 -1
  128. package/dashboard/dist/assets/{PersonaDetailPage-C-4o8lPw.js → PersonaDetailPage-ChXwJ6u5.js} +2 -2
  129. package/dashboard/dist/assets/{PersonaDetailPage-C-4o8lPw.js.map → PersonaDetailPage-ChXwJ6u5.js.map} +1 -1
  130. package/dashboard/dist/assets/{PersonasPage-BL1FwLmv.js → PersonasPage-BFFxncSE.js} +2 -2
  131. package/dashboard/dist/assets/{PersonasPage-BL1FwLmv.js.map → PersonasPage-BFFxncSE.js.map} +1 -1
  132. package/dashboard/dist/assets/{PortalPage-tJG5sgb1.js → PortalPage-Xk1zVneM.js} +2 -2
  133. package/dashboard/dist/assets/{PortalPage-tJG5sgb1.js.map → PortalPage-Xk1zVneM.js.map} +1 -1
  134. package/dashboard/dist/assets/{ProcessDetailPage-Dz_jY4Yt.js → ProcessDetailPage-D7EYwW-j.js} +2 -2
  135. package/dashboard/dist/assets/{ProcessDetailPage-Dz_jY4Yt.js.map → ProcessDetailPage-D7EYwW-j.js.map} +1 -1
  136. package/dashboard/dist/assets/{ProcessesListPage-Cbn9cter.js → ProcessesListPage-CakYRtnE.js} +2 -2
  137. package/dashboard/dist/assets/{ProcessesListPage-Cbn9cter.js.map → ProcessesListPage-CakYRtnE.js.map} +1 -1
  138. package/dashboard/dist/assets/{ResolverForm-Bk8iXQ6-.js → ResolverForm-BwVOJUpJ.js} +6 -6
  139. package/dashboard/dist/assets/ResolverForm-BwVOJUpJ.js.map +1 -0
  140. package/dashboard/dist/assets/{RoleDetailPage-owPi6gI9.js → RoleDetailPage-CKbGwezP.js} +2 -2
  141. package/dashboard/dist/assets/{RoleDetailPage-owPi6gI9.js.map → RoleDetailPage-CKbGwezP.js.map} +1 -1
  142. package/dashboard/dist/assets/{RolesPage-NwmMvZFa.js → RolesPage-Czu7Zku4.js} +2 -2
  143. package/dashboard/dist/assets/{RolesPage-NwmMvZFa.js.map → RolesPage-Czu7Zku4.js.map} +1 -1
  144. package/dashboard/dist/assets/{RunAsSelector-tgEooTyU.js → RunAsSelector-6BLScYTX.js} +2 -2
  145. package/dashboard/dist/assets/{RunAsSelector-tgEooTyU.js.map → RunAsSelector-6BLScYTX.js.map} +1 -1
  146. package/dashboard/dist/assets/{ScanCodesPage-CUv_8ic6.js → ScanCodesPage-Cv9q8Bvt.js} +2 -2
  147. package/dashboard/dist/assets/{ScanCodesPage-CUv_8ic6.js.map → ScanCodesPage-Cv9q8Bvt.js.map} +1 -1
  148. package/dashboard/dist/assets/ScanSchemeDetailPage-BxazXYIc.js +2 -0
  149. package/dashboard/dist/assets/ScanSchemeDetailPage-BxazXYIc.js.map +1 -0
  150. package/dashboard/dist/assets/ScanStationPage-Cg8LCFR7.js +2 -0
  151. package/dashboard/dist/assets/ScanStationPage-Cg8LCFR7.js.map +1 -0
  152. package/dashboard/dist/assets/{StickyPagination-CsTI_gvJ.js → StickyPagination-DsdtYoXR.js} +2 -2
  153. package/dashboard/dist/assets/{StickyPagination-CsTI_gvJ.js.map → StickyPagination-DsdtYoXR.js.map} +1 -1
  154. package/dashboard/dist/assets/{StreamMessageDetail-auRlvjTh.js → StreamMessageDetail-CT3FQoT3.js} +2 -2
  155. package/dashboard/dist/assets/{StreamMessageDetail-auRlvjTh.js.map → StreamMessageDetail-CT3FQoT3.js.map} +1 -1
  156. package/dashboard/dist/assets/{SwimlaneTimeline-BLoVHYAd.js → SwimlaneTimeline-C8TjkJ10.js} +2 -2
  157. package/dashboard/dist/assets/{SwimlaneTimeline-BLoVHYAd.js.map → SwimlaneTimeline-C8TjkJ10.js.map} +1 -1
  158. package/dashboard/dist/assets/{TaskDetailPage-BPsZ1bK_.js → TaskDetailPage-DGUzdBFN.js} +2 -2
  159. package/dashboard/dist/assets/{TaskDetailPage-BPsZ1bK_.js.map → TaskDetailPage-DGUzdBFN.js.map} +1 -1
  160. package/dashboard/dist/assets/{TasksListPage-BNGM74yT.js → TasksListPage-BVIP6-EZ.js} +2 -2
  161. package/dashboard/dist/assets/{TasksListPage-BNGM74yT.js.map → TasksListPage-BVIP6-EZ.js.map} +1 -1
  162. package/dashboard/dist/assets/{TimeAgo-BnAHXGK7.js → TimeAgo-C-rd9F9g.js} +2 -2
  163. package/dashboard/dist/assets/{TimeAgo-BnAHXGK7.js.map → TimeAgo-C-rd9F9g.js.map} +1 -1
  164. package/dashboard/dist/assets/{TimestampCell-J4yae6mc.js → TimestampCell-DPbchDOI.js} +2 -2
  165. package/dashboard/dist/assets/{TimestampCell-J4yae6mc.js.map → TimestampCell-DPbchDOI.js.map} +1 -1
  166. package/dashboard/dist/assets/{ToolTestPanel-BdzzgXDu.js → ToolTestPanel-DAUC8DHK.js} +2 -2
  167. package/dashboard/dist/assets/{ToolTestPanel-BdzzgXDu.js.map → ToolTestPanel-DAUC8DHK.js.map} +1 -1
  168. package/dashboard/dist/assets/{TopicDetailPage-DJKg8lb7.js → TopicDetailPage-70mMKBzG.js} +2 -2
  169. package/dashboard/dist/assets/{TopicDetailPage-DJKg8lb7.js.map → TopicDetailPage-70mMKBzG.js.map} +1 -1
  170. package/dashboard/dist/assets/{TopicsPage-DQV0WxG6.js → TopicsPage-CE3hBthn.js} +2 -2
  171. package/dashboard/dist/assets/{TopicsPage-DQV0WxG6.js.map → TopicsPage-CE3hBthn.js.map} +1 -1
  172. package/dashboard/dist/assets/{UserName-Ct09nGh5.js → UserName-BDBDA-LR.js} +2 -2
  173. package/dashboard/dist/assets/{UserName-Ct09nGh5.js.map → UserName-BDBDA-LR.js.map} +1 -1
  174. package/dashboard/dist/assets/{WorkflowExecutionPage-B5WJOsee.js → WorkflowExecutionPage-BbkLZ1co.js} +2 -2
  175. package/dashboard/dist/assets/{WorkflowExecutionPage-B5WJOsee.js.map → WorkflowExecutionPage-BbkLZ1co.js.map} +1 -1
  176. package/dashboard/dist/assets/{WorkflowsDashboard-Hc87TRgD.js → WorkflowsDashboard-Bp1L7Ggz.js} +2 -2
  177. package/dashboard/dist/assets/{WorkflowsDashboard-Hc87TRgD.js.map → WorkflowsDashboard-Bp1L7Ggz.js.map} +1 -1
  178. package/dashboard/dist/assets/{WorkflowsOverview-CJQbyOj-.js → WorkflowsOverview-IeTKHAi4.js} +2 -2
  179. package/dashboard/dist/assets/{WorkflowsOverview-CJQbyOj-.js.map → WorkflowsOverview-IeTKHAi4.js.map} +1 -1
  180. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BMeED677.js → YamlWorkflowDetailPage-DtKCXnKt.js} +2 -2
  181. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BMeED677.js.map → YamlWorkflowDetailPage-DtKCXnKt.js.map} +1 -1
  182. package/dashboard/dist/assets/{YamlWorkflowsPage-BMMg0Id6.js → YamlWorkflowsPage-CEcZBV_3.js} +2 -2
  183. package/dashboard/dist/assets/{YamlWorkflowsPage-BMMg0Id6.js.map → YamlWorkflowsPage-CEcZBV_3.js.map} +1 -1
  184. package/dashboard/dist/assets/{agents-CdFkgFvg.js → agents-BT-sEk81.js} +2 -2
  185. package/dashboard/dist/assets/{agents-CdFkgFvg.js.map → agents-BT-sEk81.js.map} +1 -1
  186. package/dashboard/dist/assets/{bots-Mj3LHWWg.js → bots-DRoAdLek.js} +2 -2
  187. package/dashboard/dist/assets/{bots-Mj3LHWWg.js.map → bots-DRoAdLek.js.map} +1 -1
  188. package/dashboard/dist/assets/{capabilities-Dw1ObK2-.js → capabilities-Bc-nJk6y.js} +2 -2
  189. package/dashboard/dist/assets/{capabilities-Dw1ObK2-.js.map → capabilities-Bc-nJk6y.js.map} +1 -1
  190. package/dashboard/dist/assets/{controlplane-DcNE1APv.js → controlplane-aXceSIRf.js} +2 -2
  191. package/dashboard/dist/assets/{controlplane-DcNE1APv.js.map → controlplane-aXceSIRf.js.map} +1 -1
  192. package/dashboard/dist/assets/{escalation-columns-D364Trpy.js → escalation-columns-Bf09Q89t.js} +2 -2
  193. package/dashboard/dist/assets/{escalation-columns-D364Trpy.js.map → escalation-columns-Bf09Q89t.js.map} +1 -1
  194. package/dashboard/dist/assets/index-BCFEQEMC.js +2 -0
  195. package/dashboard/dist/assets/index-BCFEQEMC.js.map +1 -0
  196. package/dashboard/dist/assets/{index-Bd6-KmBE.js → index-BEPKAjna.js} +2 -2
  197. package/dashboard/dist/assets/{index-Bd6-KmBE.js.map → index-BEPKAjna.js.map} +1 -1
  198. package/dashboard/dist/assets/{index-BQeHJHYN.js → index-BUYokcrl.js} +25 -25
  199. package/dashboard/dist/assets/index-BUYokcrl.js.map +1 -0
  200. package/dashboard/dist/assets/{index-MDD4JYtu.js → index-Ba-s5Yb5.js} +2 -2
  201. package/dashboard/dist/assets/{index-MDD4JYtu.js.map → index-Ba-s5Yb5.js.map} +1 -1
  202. package/dashboard/dist/assets/{index-BRGTmoYY.js → index-C3VTJcrp.js} +2 -2
  203. package/dashboard/dist/assets/{index-BRGTmoYY.js.map → index-C3VTJcrp.js.map} +1 -1
  204. package/dashboard/dist/assets/{index-Dyotfa_k.js → index-CZyO9hRb.js} +2 -2
  205. package/dashboard/dist/assets/{index-Dyotfa_k.js.map → index-CZyO9hRb.js.map} +1 -1
  206. package/dashboard/dist/assets/{index-eDm6cz0F.js → index-CcgmR-7-.js} +2 -2
  207. package/dashboard/dist/assets/{index-eDm6cz0F.js.map → index-CcgmR-7-.js.map} +1 -1
  208. package/dashboard/dist/assets/{index-DkcI4V_H.js → index-CuBGGwXf.js} +2 -2
  209. package/dashboard/dist/assets/{index-DkcI4V_H.js.map → index-CuBGGwXf.js.map} +1 -1
  210. package/dashboard/dist/assets/index-D1mKf_qz.js +3 -0
  211. package/dashboard/dist/assets/index-D1mKf_qz.js.map +1 -0
  212. package/dashboard/dist/assets/{index-Bq5XNEzD.js → index-DBxpyIw5.js} +2 -2
  213. package/dashboard/dist/assets/{index-Bq5XNEzD.js.map → index-DBxpyIw5.js.map} +1 -1
  214. package/dashboard/dist/assets/{index-B3veJ698.js → index-DH03y-UT.js} +2 -2
  215. package/dashboard/dist/assets/{index-B3veJ698.js.map → index-DH03y-UT.js.map} +1 -1
  216. package/dashboard/dist/assets/{index-BiVce3n0.js → index-Djsoi8DI.js} +2 -2
  217. package/dashboard/dist/assets/{index-BiVce3n0.js.map → index-Djsoi8DI.js.map} +1 -1
  218. package/dashboard/dist/assets/{index-DPStdq4T.js → index-h2gX31B2.js} +2 -2
  219. package/dashboard/dist/assets/{index-DPStdq4T.js.map → index-h2gX31B2.js.map} +1 -1
  220. package/dashboard/dist/assets/{knowledge-Bafewjxk.js → knowledge-BhW8V-Hq.js} +2 -2
  221. package/dashboard/dist/assets/{knowledge-Bafewjxk.js.map → knowledge-BhW8V-Hq.js.map} +1 -1
  222. package/dashboard/dist/assets/{mcp-vLIutbnc.js → mcp-BYfSMQzh.js} +2 -2
  223. package/dashboard/dist/assets/{mcp-vLIutbnc.js.map → mcp-BYfSMQzh.js.map} +1 -1
  224. package/dashboard/dist/assets/{mcp-query-BzTtIG90.js → mcp-query-DUJoOk_q.js} +2 -2
  225. package/dashboard/dist/assets/{mcp-query-BzTtIG90.js.map → mcp-query-DUJoOk_q.js.map} +1 -1
  226. package/dashboard/dist/assets/metadata-display-B7X5hGxG.js +2 -0
  227. package/dashboard/dist/assets/metadata-display-B7X5hGxG.js.map +1 -0
  228. package/dashboard/dist/assets/{personas-WD40EDS_.js → personas-jT1O_SB4.js} +2 -2
  229. package/dashboard/dist/assets/{personas-WD40EDS_.js.map → personas-jT1O_SB4.js.map} +1 -1
  230. package/dashboard/dist/assets/{pipelines-DFwULWs3.js → pipelines-Bp-wIaz2.js} +2 -2
  231. package/dashboard/dist/assets/{pipelines-DFwULWs3.js.map → pipelines-Bp-wIaz2.js.map} +1 -1
  232. package/dashboard/dist/assets/{tasks-La_-WAUn.js → tasks-CCrvnXbz.js} +2 -2
  233. package/dashboard/dist/assets/{tasks-La_-WAUn.js.map → tasks-CCrvnXbz.js.map} +1 -1
  234. package/dashboard/dist/assets/{topics-CzYMlvqm.js → topics-Blft0I1L.js} +2 -2
  235. package/dashboard/dist/assets/{topics-CzYMlvqm.js.map → topics-Blft0I1L.js.map} +1 -1
  236. package/dashboard/dist/assets/{useDebouncedValue-C0FQyANW.js → useDebouncedValue-BYqbcism.js} +2 -2
  237. package/dashboard/dist/assets/{useDebouncedValue-C0FQyANW.js.map → useDebouncedValue-BYqbcism.js.map} +1 -1
  238. package/dashboard/dist/assets/{useNamespace-WW_XjAb3.js → useNamespace-BfxJAUgG.js} +2 -2
  239. package/dashboard/dist/assets/{useNamespace-WW_XjAb3.js.map → useNamespace-BfxJAUgG.js.map} +1 -1
  240. package/dashboard/dist/assets/{useYamlActivityEvents-B3YxPeFt.js → useYamlActivityEvents-BukJuWpb.js} +2 -2
  241. package/dashboard/dist/assets/{useYamlActivityEvents-B3YxPeFt.js.map → useYamlActivityEvents-BukJuWpb.js.map} +1 -1
  242. package/dashboard/dist/assets/{yaml-workflows-COHOjdhF.js → yaml-workflows-DeRWqMGk.js} +2 -2
  243. package/dashboard/dist/assets/{yaml-workflows-COHOjdhF.js.map → yaml-workflows-DeRWqMGk.js.map} +1 -1
  244. package/dashboard/dist/index.html +1 -1
  245. package/docs/accumulator.md +1 -1
  246. package/docs/api/sdk/escalations.md +1 -1
  247. package/docs/hitl/escalation.md +12 -0
  248. package/docs/hitl/lookups.md +27 -18
  249. package/docs/hitl/resolution.md +1 -1
  250. package/docs/hitl/x-lt-validation.md +1 -1
  251. package/docs/hitl/x-lt-widget.md +1 -1
  252. package/docs/hitl-guide.md +1 -1
  253. package/docs/scan-codes.md +86 -16
  254. package/package.json +2 -2
  255. package/dashboard/dist/assets/ResolverForm-Bk8iXQ6-.js.map +0 -1
  256. package/dashboard/dist/assets/ScanSchemeDetailPage-YHqbu7oK.js +0 -2
  257. package/dashboard/dist/assets/ScanSchemeDetailPage-YHqbu7oK.js.map +0 -1
  258. package/dashboard/dist/assets/ScanStationPage-B275l6r_.js +0 -2
  259. package/dashboard/dist/assets/ScanStationPage-B275l6r_.js.map +0 -1
  260. package/dashboard/dist/assets/index-BQeHJHYN.js.map +0 -1
  261. package/dashboard/dist/assets/index-BmNAVd4s.js +0 -2
  262. package/dashboard/dist/assets/index-BmNAVd4s.js.map +0 -1
  263. package/dashboard/dist/assets/index-WSm8bgE7.js +0 -3
  264. package/dashboard/dist/assets/index-WSm8bgE7.js.map +0 -1
  265. package/dashboard/dist/assets/metadata-display-COo3mMCr.js +0 -2
  266. package/dashboard/dist/assets/metadata-display-COo3mMCr.js.map +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-Cbn9cter.js","./vendor-query-DvWWuNIB.js","./tasks-La_-WAUn.js","./useFilterParams-DBRw1Hcv.js","./vendor-react-_9U4mKFr.js","./useDebouncedValue-C0FQyANW.js","./api-path-u2Jf9QXS.js","./DataTable-spX1dFyb.js","./EmptyState-DgC_6njU.js","./useContainerWidth-DSLp1gEm.js","./TimestampCell-J4yae6mc.js","./StickyPagination-CsTI_gvJ.js","./FilterBar-8IdbleZ9.js","./vendor-icons-CeVtUKyP.js","./PageHeader-CMd3f4bz.js","./ListToolbar-Cnacuwoy.js","./WorkflowPill-Dg7BDTyM.js","./ProcessDetailPage-Dz_jY4Yt.js","./PageHeaderWithStats-DHj8Mqox.js","./StatusBadge-DHVwxre2.js","./RolePill-Di2CAHuD.js","./UserName-Ct09nGh5.js","./McpOverview-C2JoNoDA.js","./mcp-vLIutbnc.js","./pipelines-DFwULWs3.js","./yaml-workflows-COHOjdhF.js","./controlplane-DcNE1APv.js","./StatCard-nWY4sndl.js","./McpRunsPage-CnYtfGhf.js","./useNamespace-WW_XjAb3.js","./ElapsedCell-DCctVv5R.js","./RowActions-Bdd7z4eB.js","./McpRunDetailPage-DtKoJq6J.js","./SegmentedTabs-BpJh4Hwn.js","./EventTable-CBUWq7--.js","./SwimlaneTimeline-BLoVHYAd.js","./StreamMessageDetail-auRlvjTh.js","./CopyableId-Bn02zYxt.js","./McpQueryPage-U_wNXow2.js","./mcp-query-BzTtIG90.js","./McpQueryDetailPage-C_nih0w-.js","./TagInput-CAgdLN_b.js","./CollapsibleSection-GCJsV9Oq.js","./useYamlActivityEvents-B3YxPeFt.js","./helpers-DzO-OGPe.js","./RunAsSelector-tgEooTyU.js","./BotPicker-BZo4Kp4a.js","./bots-Mj3LHWWg.js","./ToolPill-CQCsVdzD.js","./TimeAgo-BnAHXGK7.js","./EscalationsOverview-C2XoguaA.js","./AvailableEscalationsPage-C2_5aEFW.js","./task-queues-7-sHKPsN.js","./BulkAssignModal-BFhyxY2T.js","./constants-CeBBTzf5.js","./EscalationTitleSelect-DWGLBOmS.js","./EscalationTimeline-DKoSM56J.js","./EscalationListView-CGQZxcC-.js","./escalation-columns-D364Trpy.js","./EntityTimelinePanel-CMnskyWv.js","./PriorityBadge-r33mpDju.js","./CountdownTimer-Dik2z0M_.js","./OperatorDashboard-fVuLn2D5.js","./index-WSm8bgE7.js","./ResolverForm-Bk8iXQ6-.js","./metadata-display-COo3mMCr.js","./WorkflowsOverview-CJQbyOj-.js","./index-BmNAVd4s.js","./NamespacePill-DwM5pNA4.js","./WorkflowsDashboard-Hc87TRgD.js","./YamlWorkflowsPage-BMMg0Id6.js","./GraphInvokePage-CUvoPzsW.js","./YamlWorkflowDetailPage-BMeED677.js","./TasksListPage-BNGM74yT.js","./TaskDetailPage-BPsZ1bK_.js","./WorkflowExecutionPage-B5WJOsee.js","./AdminDashboard-DBW12qQt.js","./index-BRGTmoYY.js","./TaskQueuePill-h0oorVMe.js","./index-Bd6-KmBE.js","./ConfirmDeleteModal-CAgYLcef.js","./index-BiVce3n0.js","./ToolTestPanel-BdzzgXDu.js","./index-eDm6cz0F.js","./index-B3veJ698.js","./personas-WD40EDS_.js","./ScopeBadge-CSItPVOH.js","./RolesPage-NwmMvZFa.js","./RoleDetailPage-owPi6gI9.js","./AutoGrowTextarea-7X3T9La8.js","./PersonasPage-BL1FwLmv.js","./PersonaDetailPage-C-4o8lPw.js","./EscalationSchemaPage-BX0tx-PM.js","./PortalPage-tJG5sgb1.js","./EscalationListSchemaPage-VfCn6WDb.js","./ScanCodesPage-CUv_8ic6.js","./GrantScopeField-BzWGzBfA.js","./ScanSchemeDetailPage-YHqbu7oK.js","./ScanStationPage-B275l6r_.js","./index-MDD4JYtu.js","./OperationsPage-C7hupIer.js","./index-DkcI4V_H.js","./index-Bq5XNEzD.js","./CredentialsPage-twd2xCOW.js","./index-DPStdq4T.js","./DropZone-B1Tdfddc.js","./index-Dyotfa_k.js","./knowledge-Bafewjxk.js","./HomePage-BP7v9GLJ.js","./AgentsPage-BA_ai9HJ.js","./agents-CdFkgFvg.js","./AgentDetailPage-D1scIbz-.js","./CronLabel-DdnIuudX.js","./AgentConfigPage-CmHv8U9M.js","./capabilities-Dw1ObK2-.js","./topics-CzYMlvqm.js","./CapabilitiesPage-CvOX6vAc.js","./TopicsPage-DQV0WxG6.js","./TopicDetailPage-DJKg8lb7.js"])))=>i.map(i=>d[i]);
2
- var Zw=Object.defineProperty;var eS=(n,t,s)=>t in n?Zw(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var j=(n,t,s)=>eS(n,typeof t!="symbol"?t+"":t,s);import{r as tS,u as $e,a as E,j as h,b as He,c as Ve,g as nS,d as rS,Q as sS,e as iS}from"./vendor-query-DvWWuNIB.js";import{r as aS,u as ra,a as an,b as Wd,L as Cr,N as Ss,c as wn,O as Ws,d as oS,R as lS}from"./vendor-react-_9U4mKFr.js";import{X as Wt,E as cS,S as uS,M as fS,a as No,C as Zd,b as hS,c as dS,d as tx,e as hd,I as dd,U as mS,L as md,B as pS,G as yS,T as gS,R as nx,f as bS,Z as xS,P as Ag,g as rx,h as vS,i as jg,j as pd,k as kg,l as _S,W as em,m as wS,n as SS,F as ES,o as sx,p as OS,D as AS,N as jS,q as kS,r as ix,s as ax,t as ox,u as NS,v as TS,w as CS,x as MS,y as RS,z as DS,A as LS,H as qS,J as BS}from"./vendor-icons-CeVtUKyP.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const m of c.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function s(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(o){if(o.ep)return;o.ep=!0;const c=s(o);fetch(o.href,c)}})();var Gh={exports:{}},to={},Vh={exports:{}},Yh={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-CakYRtnE.js","./vendor-query-DvWWuNIB.js","./tasks-CCrvnXbz.js","./useFilterParams-DBRw1Hcv.js","./vendor-react-_9U4mKFr.js","./useDebouncedValue-BYqbcism.js","./api-path-u2Jf9QXS.js","./DataTable-spX1dFyb.js","./EmptyState-DgC_6njU.js","./useContainerWidth-DSLp1gEm.js","./TimestampCell-DPbchDOI.js","./StickyPagination-DsdtYoXR.js","./FilterBar-D-6xVHIw.js","./vendor-icons-CeVtUKyP.js","./PageHeader-CMd3f4bz.js","./ListToolbar-_jWTw5no.js","./WorkflowPill-Dg7BDTyM.js","./ProcessDetailPage-D7EYwW-j.js","./PageHeaderWithStats-DHj8Mqox.js","./StatusBadge-DHVwxre2.js","./RolePill-Di2CAHuD.js","./UserName-BDBDA-LR.js","./McpOverview-CjqTuP0N.js","./mcp-BYfSMQzh.js","./pipelines-Bp-wIaz2.js","./yaml-workflows-DeRWqMGk.js","./controlplane-aXceSIRf.js","./StatCard-nWY4sndl.js","./McpRunsPage-DERXQLgZ.js","./useNamespace-BfxJAUgG.js","./ElapsedCell-BeK1SUDK.js","./RowActions-Bdd7z4eB.js","./McpRunDetailPage-JDrr3uUQ.js","./SegmentedTabs-BpJh4Hwn.js","./EventTable-C97m6IZv.js","./SwimlaneTimeline-C8TjkJ10.js","./StreamMessageDetail-CT3FQoT3.js","./CopyableId-Bn02zYxt.js","./McpQueryPage-C-PyXYX4.js","./mcp-query-DUJoOk_q.js","./McpQueryDetailPage-leCsje1U.js","./TagInput-CAgdLN_b.js","./CollapsibleSection-Cz5sRx-r.js","./useYamlActivityEvents-BukJuWpb.js","./helpers-DzO-OGPe.js","./RunAsSelector-6BLScYTX.js","./BotPicker-C3LR6Sqy.js","./bots-DRoAdLek.js","./ToolPill-CQCsVdzD.js","./TimeAgo-C-rd9F9g.js","./EscalationsOverview-BzH-Y-5x.js","./AvailableEscalationsPage-CWMyy3IL.js","./task-queues-7-sHKPsN.js","./BulkAssignModal-COjoOIIH.js","./constants-CeBBTzf5.js","./EscalationTitleSelect-Dewrv8wX.js","./EscalationTimeline-DNKNp6pL.js","./EscalationListView-DTIVuym4.js","./escalation-columns-Bf09Q89t.js","./EntityTimelinePanel-BThdefKj.js","./PriorityBadge-r33mpDju.js","./CountdownTimer-BUBl_4mP.js","./OperatorDashboard-C8RtPv8P.js","./index-D1mKf_qz.js","./ResolverForm-BwVOJUpJ.js","./metadata-display-B7X5hGxG.js","./WorkflowsOverview-IeTKHAi4.js","./index-BCFEQEMC.js","./NamespacePill-DwM5pNA4.js","./WorkflowsDashboard-Bp1L7Ggz.js","./YamlWorkflowsPage-CEcZBV_3.js","./GraphInvokePage-Bwi8EF9Y.js","./YamlWorkflowDetailPage-DtKCXnKt.js","./TasksListPage-BVIP6-EZ.js","./TaskDetailPage-DGUzdBFN.js","./WorkflowExecutionPage-BbkLZ1co.js","./AdminDashboard-DKrqLGjn.js","./index-C3VTJcrp.js","./TaskQueuePill-h0oorVMe.js","./index-BEPKAjna.js","./ConfirmDeleteModal-Beq1vQtY.js","./index-Djsoi8DI.js","./ToolTestPanel-DAUC8DHK.js","./index-CcgmR-7-.js","./index-DH03y-UT.js","./personas-jT1O_SB4.js","./ScopeBadge-CSItPVOH.js","./RolesPage-Czu7Zku4.js","./RoleDetailPage-CKbGwezP.js","./AutoGrowTextarea-7X3T9La8.js","./PersonasPage-BFFxncSE.js","./PersonaDetailPage-ChXwJ6u5.js","./EscalationSchemaPage-CQt-Embr.js","./PortalPage-Xk1zVneM.js","./EscalationListSchemaPage-DlDIYb-p.js","./ScanCodesPage-Cv9q8Bvt.js","./GrantScopeField-BzWGzBfA.js","./ScanSchemeDetailPage-BxazXYIc.js","./ScanStationPage-Cg8LCFR7.js","./index-Ba-s5Yb5.js","./OperationsPage-B2DA7n9m.js","./index-CuBGGwXf.js","./index-DBxpyIw5.js","./CredentialsPage-DhiHiPsG.js","./index-h2gX31B2.js","./DropZone-B1Tdfddc.js","./index-CZyO9hRb.js","./knowledge-BhW8V-Hq.js","./HomePage-Z_Q03C0z.js","./AgentsPage-5MynmbWX.js","./agents-BT-sEk81.js","./AgentDetailPage-DZhzuZmO.js","./CronLabel-C9SkawB-.js","./AgentConfigPage-BoQhRW6U.js","./capabilities-Bc-nJk6y.js","./topics-Blft0I1L.js","./CapabilitiesPage-DKxLvOfB.js","./TopicsPage-CE3hBthn.js","./TopicDetailPage-70mMKBzG.js"])))=>i.map(i=>d[i]);
2
+ var Ww=Object.defineProperty;var Zw=(n,t,s)=>t in n?Ww(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var j=(n,t,s)=>Zw(n,typeof t!="symbol"?t+"":t,s);import{r as eS,u as $e,a as E,j as h,b as He,c as Ve,g as tS,d as nS,Q as rS,e as sS}from"./vendor-query-DvWWuNIB.js";import{r as iS,u as ra,a as an,b as Wd,L as Cr,N as Ss,c as wn,O as Ws,d as aS,R as oS}from"./vendor-react-_9U4mKFr.js";import{X as Wt,E as lS,S as cS,M as uS,a as No,C as Zd,b as fS,c as hS,d as ex,e as hd,I as dd,U as dS,L as md,B as mS,G as pS,T as yS,R as tx,f as gS,Z as bS,P as Ag,g as nx,h as xS,i as jg,j as pd,k as kg,l as vS,W as em,m as _S,n as wS,F as SS,o as rx,p as ES,D as OS,N as AS,q as jS,r as sx,s as ix,t as ax,u as kS,v as NS,w as TS,x as CS,y as MS,z as RS,A as DS,H as LS,J as qS}from"./vendor-icons-CeVtUKyP.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const m of c.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function s(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(o){if(o.ep)return;o.ep=!0;const c=s(o);fetch(o.href,c)}})();var Gh={exports:{}},to={},Vh={exports:{}},Yh={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
5
5
  *
@@ -7,7 +7,7 @@ var Zw=Object.defineProperty;var eS=(n,t,s)=>t in n?Zw(n,t,{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 Ng;function PS(){return Ng||(Ng=1,(function(n){function t(H,W){var ce=H.length;H.push(W);e:for(;0<ce;){var xe=ce-1>>>1,ve=H[xe];if(0<o(ve,W))H[xe]=W,H[ce]=ve,ce=xe;else break e}}function s(H){return H.length===0?null:H[0]}function i(H){if(H.length===0)return null;var W=H[0],ce=H.pop();if(ce!==W){H[0]=ce;e:for(var xe=0,ve=H.length,Ce=ve>>>1;xe<Ce;){var Ne=2*(xe+1)-1,Me=H[Ne],Ze=Ne+1,yt=H[Ze];if(0>o(Me,ce))Ze<ve&&0>o(yt,Me)?(H[xe]=yt,H[Ze]=ce,xe=Ze):(H[xe]=Me,H[Ne]=ce,xe=Ne);else if(Ze<ve&&0>o(yt,ce))H[xe]=yt,H[Ze]=ce,xe=Ze;else break e}}return W}function o(H,W){var ce=H.sortIndex-W.sortIndex;return ce!==0?ce:H.id-W.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var m=Date,y=m.now();n.unstable_now=function(){return m.now()-y}}var g=[],u=[],d=1,b=null,x=3,v=!1,w=!1,S=!1,C=!1,q=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,ie=typeof setImmediate<"u"?setImmediate:null;function le(H){for(var W=s(u);W!==null;){if(W.callback===null)i(u);else if(W.startTime<=H)i(u),W.sortIndex=W.expirationTime,t(g,W);else break;W=s(u)}}function R(H){if(S=!1,le(H),!w)if(s(g)!==null)w=!0,$||($=!0,X());else{var W=s(u);W!==null&&ke(R,W.startTime-H)}}var $=!1,ne=-1,V=5,I=-1;function D(){return C?!0:!(n.unstable_now()-I<V)}function Q(){if(C=!1,$){var H=n.unstable_now();I=H;var W=!0;try{e:{w=!1,S&&(S=!1,B(ne),ne=-1),v=!0;var ce=x;try{t:{for(le(H),b=s(g);b!==null&&!(b.expirationTime>H&&D());){var xe=b.callback;if(typeof xe=="function"){b.callback=null,x=b.priorityLevel;var ve=xe(b.expirationTime<=H);if(H=n.unstable_now(),typeof ve=="function"){b.callback=ve,le(H),W=!0;break t}b===s(g)&&i(g),le(H)}else i(g);b=s(g)}if(b!==null)W=!0;else{var Ce=s(u);Ce!==null&&ke(R,Ce.startTime-H),W=!1}}break e}finally{b=null,x=ce,v=!1}W=void 0}}finally{W?X():$=!1}}}var X;if(typeof ie=="function")X=function(){ie(Q)};else if(typeof MessageChannel<"u"){var he=new MessageChannel,Se=he.port2;he.port1.onmessage=Q,X=function(){Se.postMessage(null)}}else X=function(){q(Q,0)};function ke(H,W){ne=q(function(){H(n.unstable_now())},W)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(H){H.callback=null},n.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<H?Math.floor(1e3/H):5},n.unstable_getCurrentPriorityLevel=function(){return x},n.unstable_next=function(H){switch(x){case 1:case 2:case 3:var W=3;break;default:W=x}var ce=x;x=W;try{return H()}finally{x=ce}},n.unstable_requestPaint=function(){C=!0},n.unstable_runWithPriority=function(H,W){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var ce=x;x=H;try{return W()}finally{x=ce}},n.unstable_scheduleCallback=function(H,W,ce){var xe=n.unstable_now();switch(typeof ce=="object"&&ce!==null?(ce=ce.delay,ce=typeof ce=="number"&&0<ce?xe+ce:xe):ce=xe,H){case 1:var ve=-1;break;case 2:ve=250;break;case 5:ve=1073741823;break;case 4:ve=1e4;break;default:ve=5e3}return ve=ce+ve,H={id:d++,callback:W,priorityLevel:H,startTime:ce,expirationTime:ve,sortIndex:-1},ce>xe?(H.sortIndex=ce,t(u,H),s(g)===null&&H===s(u)&&(S?(B(ne),ne=-1):S=!0,ke(R,ce-xe))):(H.sortIndex=ve,t(g,H),w||v||(w=!0,$||($=!0,X()))),H},n.unstable_shouldYield=D,n.unstable_wrapCallback=function(H){var W=x;return function(){var ce=x;x=W;try{return H.apply(this,arguments)}finally{x=ce}}}})(Yh)),Yh}var Tg;function US(){return Tg||(Tg=1,Vh.exports=PS()),Vh.exports}/**
10
+ */var Ng;function BS(){return Ng||(Ng=1,(function(n){function t(H,W){var ce=H.length;H.push(W);e:for(;0<ce;){var xe=ce-1>>>1,ve=H[xe];if(0<o(ve,W))H[xe]=W,H[ce]=ve,ce=xe;else break e}}function s(H){return H.length===0?null:H[0]}function i(H){if(H.length===0)return null;var W=H[0],ce=H.pop();if(ce!==W){H[0]=ce;e:for(var xe=0,ve=H.length,Ce=ve>>>1;xe<Ce;){var Ne=2*(xe+1)-1,Me=H[Ne],Ze=Ne+1,yt=H[Ze];if(0>o(Me,ce))Ze<ve&&0>o(yt,Me)?(H[xe]=yt,H[Ze]=ce,xe=Ze):(H[xe]=Me,H[Ne]=ce,xe=Ne);else if(Ze<ve&&0>o(yt,ce))H[xe]=yt,H[Ze]=ce,xe=Ze;else break e}}return W}function o(H,W){var ce=H.sortIndex-W.sortIndex;return ce!==0?ce:H.id-W.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var m=Date,y=m.now();n.unstable_now=function(){return m.now()-y}}var g=[],u=[],d=1,b=null,x=3,v=!1,w=!1,S=!1,C=!1,q=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,ie=typeof setImmediate<"u"?setImmediate:null;function le(H){for(var W=s(u);W!==null;){if(W.callback===null)i(u);else if(W.startTime<=H)i(u),W.sortIndex=W.expirationTime,t(g,W);else break;W=s(u)}}function R(H){if(S=!1,le(H),!w)if(s(g)!==null)w=!0,$||($=!0,X());else{var W=s(u);W!==null&&ke(R,W.startTime-H)}}var $=!1,ne=-1,V=5,I=-1;function D(){return C?!0:!(n.unstable_now()-I<V)}function Q(){if(C=!1,$){var H=n.unstable_now();I=H;var W=!0;try{e:{w=!1,S&&(S=!1,B(ne),ne=-1),v=!0;var ce=x;try{t:{for(le(H),b=s(g);b!==null&&!(b.expirationTime>H&&D());){var xe=b.callback;if(typeof xe=="function"){b.callback=null,x=b.priorityLevel;var ve=xe(b.expirationTime<=H);if(H=n.unstable_now(),typeof ve=="function"){b.callback=ve,le(H),W=!0;break t}b===s(g)&&i(g),le(H)}else i(g);b=s(g)}if(b!==null)W=!0;else{var Ce=s(u);Ce!==null&&ke(R,Ce.startTime-H),W=!1}}break e}finally{b=null,x=ce,v=!1}W=void 0}}finally{W?X():$=!1}}}var X;if(typeof ie=="function")X=function(){ie(Q)};else if(typeof MessageChannel<"u"){var he=new MessageChannel,Se=he.port2;he.port1.onmessage=Q,X=function(){Se.postMessage(null)}}else X=function(){q(Q,0)};function ke(H,W){ne=q(function(){H(n.unstable_now())},W)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(H){H.callback=null},n.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<H?Math.floor(1e3/H):5},n.unstable_getCurrentPriorityLevel=function(){return x},n.unstable_next=function(H){switch(x){case 1:case 2:case 3:var W=3;break;default:W=x}var ce=x;x=W;try{return H()}finally{x=ce}},n.unstable_requestPaint=function(){C=!0},n.unstable_runWithPriority=function(H,W){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var ce=x;x=H;try{return W()}finally{x=ce}},n.unstable_scheduleCallback=function(H,W,ce){var xe=n.unstable_now();switch(typeof ce=="object"&&ce!==null?(ce=ce.delay,ce=typeof ce=="number"&&0<ce?xe+ce:xe):ce=xe,H){case 1:var ve=-1;break;case 2:ve=250;break;case 5:ve=1073741823;break;case 4:ve=1e4;break;default:ve=5e3}return ve=ce+ve,H={id:d++,callback:W,priorityLevel:H,startTime:ce,expirationTime:ve,sortIndex:-1},ce>xe?(H.sortIndex=ce,t(u,H),s(g)===null&&H===s(u)&&(S?(B(ne),ne=-1):S=!0,ke(R,ce-xe))):(H.sortIndex=ve,t(g,H),w||v||(w=!0,$||($=!0,X()))),H},n.unstable_shouldYield=D,n.unstable_wrapCallback=function(H){var W=x;return function(){var ce=x;x=W;try{return H.apply(this,arguments)}finally{x=ce}}}})(Yh)),Yh}var Tg;function PS(){return Tg||(Tg=1,Vh.exports=BS()),Vh.exports}/**
11
11
  * @license React
12
12
  * react-dom-client.production.js
13
13
  *
@@ -15,28 +15,28 @@ var Zw=Object.defineProperty;var eS=(n,t,s)=>t in n?Zw(n,t,{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 Cg;function zS(){if(Cg)return to;Cg=1;var n=US(),t=tS(),s=aS();function i(e){var r="https://react.dev/errors/"+e;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+r+" 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 c(e){var r=e,a=e;if(e.alternate)for(;r.return;)r=r.return;else{e=r;do r=e,(r.flags&4098)!==0&&(a=r.return),e=r.return;while(e)}return r.tag===3?a:null}function m(e){if(e.tag===13){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function y(e){if(e.tag===31){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function g(e){if(c(e)!==e)throw Error(i(188))}function u(e){var r=e.alternate;if(!r){if(r=c(e),r===null)throw Error(i(188));return r!==e?null:e}for(var a=e,l=r;;){var f=a.return;if(f===null)break;var p=f.alternate;if(p===null){if(l=f.return,l!==null){a=l;continue}break}if(f.child===p.child){for(p=f.child;p;){if(p===a)return g(f),e;if(p===l)return g(f),r;p=p.sibling}throw Error(i(188))}if(a.return!==l.return)a=f,l=p;else{for(var _=!1,O=f.child;O;){if(O===a){_=!0,a=f,l=p;break}if(O===l){_=!0,l=f,a=p;break}O=O.sibling}if(!_){for(O=p.child;O;){if(O===a){_=!0,a=p,l=f;break}if(O===l){_=!0,l=p,a=f;break}O=O.sibling}if(!_)throw Error(i(189))}}if(a.alternate!==l)throw Error(i(190))}if(a.tag!==3)throw Error(i(188));return a.stateNode.current===a?e:r}function d(e){var r=e.tag;if(r===5||r===26||r===27||r===6)return e;for(e=e.child;e!==null;){if(r=d(e),r!==null)return r;e=e.sibling}return null}var b=Object.assign,x=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),B=Symbol.for("react.consumer"),ie=Symbol.for("react.context"),le=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),Q=Symbol.iterator;function X(e){return e===null||typeof e!="object"?null:(e=Q&&e[Q]||e["@@iterator"],typeof e=="function"?e:null)}var he=Symbol.for("react.client.reference");function Se(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===he?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case q:return"Profiler";case C:return"StrictMode";case R:return"Suspense";case $:return"SuspenseList";case I:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case w:return"Portal";case ie:return e.displayName||"Context";case B:return(e._context.displayName||"Context")+".Consumer";case le:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ne:return r=e.displayName||null,r!==null?r:Se(e.type)||"Memo";case V:r=e._payload,e=e._init;try{return Se(e(r))}catch{}}return null}var ke=Array.isArray,H=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ce={pending:!1,data:null,method:null,action:null},xe=[],ve=-1;function Ce(e){return{current:e}}function Ne(e){0>ve||(e.current=xe[ve],xe[ve]=null,ve--)}function Me(e,r){ve++,xe[ve]=e.current,e.current=r}var Ze=Ce(null),yt=Ce(null),Ct=Ce(null),we=Ce(null);function Re(e,r){switch(Me(Ct,r),Me(yt,e),Me(Ze,null),r.nodeType){case 9:case 11:e=(e=r.documentElement)&&(e=e.namespaceURI)?Jy(e):0;break;default:if(e=r.tagName,r=r.namespaceURI)r=Jy(r),e=Xy(r,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Ne(Ze),Me(Ze,e)}function oe(){Ne(Ze),Ne(yt),Ne(Ct)}function Be(e){e.memoizedState!==null&&Me(we,e);var r=Ze.current,a=Xy(r,e.type);r!==a&&(Me(yt,e),Me(Ze,a))}function We(e){yt.current===e&&(Ne(Ze),Ne(yt)),we.current===e&&(Ne(we),Qa._currentValue=ce)}var ln,pe;function Ye(e){if(ln===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);ln=r&&r[1]||"",pe=-1<a.stack.indexOf(`
18
+ */var Cg;function US(){if(Cg)return to;Cg=1;var n=PS(),t=eS(),s=iS();function i(e){var r="https://react.dev/errors/"+e;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+r+" 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 c(e){var r=e,a=e;if(e.alternate)for(;r.return;)r=r.return;else{e=r;do r=e,(r.flags&4098)!==0&&(a=r.return),e=r.return;while(e)}return r.tag===3?a:null}function m(e){if(e.tag===13){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function y(e){if(e.tag===31){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function g(e){if(c(e)!==e)throw Error(i(188))}function u(e){var r=e.alternate;if(!r){if(r=c(e),r===null)throw Error(i(188));return r!==e?null:e}for(var a=e,l=r;;){var f=a.return;if(f===null)break;var p=f.alternate;if(p===null){if(l=f.return,l!==null){a=l;continue}break}if(f.child===p.child){for(p=f.child;p;){if(p===a)return g(f),e;if(p===l)return g(f),r;p=p.sibling}throw Error(i(188))}if(a.return!==l.return)a=f,l=p;else{for(var _=!1,O=f.child;O;){if(O===a){_=!0,a=f,l=p;break}if(O===l){_=!0,l=f,a=p;break}O=O.sibling}if(!_){for(O=p.child;O;){if(O===a){_=!0,a=p,l=f;break}if(O===l){_=!0,l=p,a=f;break}O=O.sibling}if(!_)throw Error(i(189))}}if(a.alternate!==l)throw Error(i(190))}if(a.tag!==3)throw Error(i(188));return a.stateNode.current===a?e:r}function d(e){var r=e.tag;if(r===5||r===26||r===27||r===6)return e;for(e=e.child;e!==null;){if(r=d(e),r!==null)return r;e=e.sibling}return null}var b=Object.assign,x=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),B=Symbol.for("react.consumer"),ie=Symbol.for("react.context"),le=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),Q=Symbol.iterator;function X(e){return e===null||typeof e!="object"?null:(e=Q&&e[Q]||e["@@iterator"],typeof e=="function"?e:null)}var he=Symbol.for("react.client.reference");function Se(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===he?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case q:return"Profiler";case C:return"StrictMode";case R:return"Suspense";case $:return"SuspenseList";case I:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case w:return"Portal";case ie:return e.displayName||"Context";case B:return(e._context.displayName||"Context")+".Consumer";case le:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ne:return r=e.displayName||null,r!==null?r:Se(e.type)||"Memo";case V:r=e._payload,e=e._init;try{return Se(e(r))}catch{}}return null}var ke=Array.isArray,H=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ce={pending:!1,data:null,method:null,action:null},xe=[],ve=-1;function Ce(e){return{current:e}}function Ne(e){0>ve||(e.current=xe[ve],xe[ve]=null,ve--)}function Me(e,r){ve++,xe[ve]=e.current,e.current=r}var Ze=Ce(null),yt=Ce(null),Ct=Ce(null),we=Ce(null);function Re(e,r){switch(Me(Ct,r),Me(yt,e),Me(Ze,null),r.nodeType){case 9:case 11:e=(e=r.documentElement)&&(e=e.namespaceURI)?Jy(e):0;break;default:if(e=r.tagName,r=r.namespaceURI)r=Jy(r),e=Xy(r,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Ne(Ze),Me(Ze,e)}function oe(){Ne(Ze),Ne(yt),Ne(Ct)}function Be(e){e.memoizedState!==null&&Me(we,e);var r=Ze.current,a=Xy(r,e.type);r!==a&&(Me(yt,e),Me(Ze,a))}function We(e){yt.current===e&&(Ne(Ze),Ne(yt)),we.current===e&&(Ne(we),Qa._currentValue=ce)}var ln,pe;function Ye(e){if(ln===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);ln=r&&r[1]||"",pe=-1<a.stack.indexOf(`
19
19
  at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
20
20
  `+ln+e+pe}var Ot=!1;function ft(e,r){if(!e||Ot)return"";Ot=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(r){var se=function(){throw Error()};if(Object.defineProperty(se.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(se,[])}catch(J){var Y=J}Reflect.construct(e,[],se)}else{try{se.call()}catch(J){Y=J}e.call(se.prototype)}}else{try{throw Error()}catch(J){Y=J}(se=e())&&typeof se.catch=="function"&&se.catch(function(){})}}catch(J){if(J&&Y&&typeof J.stack=="string")return[J.stack,Y.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var p=l.DetermineComponentFrameRoot(),_=p[0],O=p[1];if(_&&O){var M=_.split(`
21
21
  `),G=O.split(`
22
22
  `);for(f=l=0;l<M.length&&!M[l].includes("DetermineComponentFrameRoot");)l++;for(;f<G.length&&!G[f].includes("DetermineComponentFrameRoot");)f++;if(l===M.length||f===G.length)for(l=M.length-1,f=G.length-1;1<=l&&0<=f&&M[l]!==G[f];)f--;for(;1<=l&&0<=f;l--,f--)if(M[l]!==G[f]){if(l!==1||f!==1)do if(l--,f--,0>f||M[l]!==G[f]){var Z=`
23
23
  `+M[l].replace(" at new "," at ");return e.displayName&&Z.includes("<anonymous>")&&(Z=Z.replace("<anonymous>",e.displayName)),Z}while(1<=l&&0<=f);break}}}finally{Ot=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?Ye(a):""}function Pr(e,r){switch(e.tag){case 26:case 27:case 5:return Ye(e.type);case 16:return Ye("Lazy");case 13:return e.child!==r&&r!==null?Ye("Suspense Fallback"):Ye("Suspense");case 19:return Ye("SuspenseList");case 0:case 15:return ft(e.type,!1);case 11:return ft(e.type.render,!1);case 1:return ft(e.type,!0);case 31:return Ye("Activity");default:return""}}function Bo(e){try{var r="",a=null;do r+=Pr(e,a),a=e,e=e.return;while(e);return r}catch(l){return`
24
24
  Error generating stack: `+l.message+`
25
- `+l.stack}}var oa=Object.prototype.hasOwnProperty,la=n.unstable_scheduleCallback,cr=n.unstable_cancelCallback,Po=n.unstable_shouldYield,ni=n.unstable_requestPaint,ht=n.unstable_now,Du=n.unstable_getCurrentPriorityLevel,Uo=n.unstable_ImmediatePriority,zo=n.unstable_UserBlockingPriority,ri=n.unstable_NormalPriority,Lu=n.unstable_LowPriority,Io=n.unstable_IdlePriority,qu=n.log,$o=n.unstable_setDisableYieldValue,As=null,_t=null;function cn(e){if(typeof qu=="function"&&$o(e),_t&&typeof _t.setStrictMode=="function")try{_t.setStrictMode(As,e)}catch{}}var Ft=Math.clz32?Math.clz32:si,ca=Math.log,ua=Math.LN2;function si(e){return e>>>=0,e===0?32:31-(ca(e)/ua|0)|0}var Ur=256,ur=262144,zr=4194304;function $n(e){var r=e&42;if(r!==0)return r;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function js(e,r,a){var l=e.pendingLanes;if(l===0)return 0;var f=0,p=e.suspendedLanes,_=e.pingedLanes;e=e.warmLanes;var O=l&134217727;return O!==0?(l=O&~p,l!==0?f=$n(l):(_&=O,_!==0?f=$n(_):a||(a=O&~e,a!==0&&(f=$n(a))))):(O=l&~p,O!==0?f=$n(O):_!==0?f=$n(_):a||(a=l&~e,a!==0&&(f=$n(a)))),f===0?0:r!==0&&r!==f&&(r&p)===0&&(p=f&-f,a=r&-r,p>=a||p===32&&(a&4194048)!==0)?r:f}function ks(e,r){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&r)===0}function fa(e,r){switch(e){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ii(){var e=zr;return zr<<=1,(zr&62914560)===0&&(zr=4194304),e}function Ir(e){for(var r=[],a=0;31>a;a++)r.push(e);return r}function Hn(e,r){e.pendingLanes|=r,r!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function $r(e,r,a,l,f,p){var _=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var O=e.entanglements,M=e.expirationTimes,G=e.hiddenUpdates;for(a=_&~a;0<a;){var Z=31-Ft(a),se=1<<Z;O[Z]=0,M[Z]=-1;var Y=G[Z];if(Y!==null)for(G[Z]=null,Z=0;Z<Y.length;Z++){var J=Y[Z];J!==null&&(J.lane&=-536870913)}a&=~se}l!==0&&Hr(e,l,0),p!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=p&~(_&~r))}function Hr(e,r,a){e.pendingLanes|=r,e.suspendedLanes&=~r;var l=31-Ft(r);e.entangledLanes|=r,e.entanglements[l]=e.entanglements[l]|1073741824|a&261930}function Ns(e,r){var a=e.entangledLanes|=r;for(e=e.entanglements;a;){var l=31-Ft(a),f=1<<l;f&r|e[l]&r&&(e[l]|=r),a&=~f}}function Fr(e,r){var a=r&-r;return a=(a&42)!==0?1:fr(a),(a&(e.suspendedLanes|r))!==0?0:a}function fr(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ts(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function ha(){var e=W.p;return e!==0?e:(e=window.event,e===void 0?32:xg(e.type))}function Ho(e,r){var a=W.p;try{return W.p=e,r()}finally{W.p=a}}var er=Math.random().toString(36).slice(2),at="__reactFiber$"+er,gt="__reactProps$"+er,un="__reactContainer$"+er,Cs="__reactEvents$"+er,da="__reactListeners$"+er,Fo="__reactHandles$"+er,Go="__reactResources$"+er,Mt="__reactMarker$"+er;function ai(e){delete e[at],delete e[gt],delete e[Cs],delete e[da],delete e[Fo]}function A(e){var r=e[at];if(r)return r;for(var a=e.parentNode;a;){if(r=a[un]||a[at]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(e=rg(e);e!==null;){if(a=e[at])return a;e=rg(e)}return r}e=a,a=e.parentNode}return null}function N(e){if(e=e[at]||e[un]){var r=e.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return e}return null}function k(e){var r=e.tag;if(r===5||r===26||r===27||r===6)return e.stateNode;throw Error(i(33))}function T(e){var r=e[Go];return r||(r=e[Go]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function L(e){e[Mt]=!0}var z=new Set,re={};function ae(e,r){K(e,r),K(e+"Capture",r)}function K(e,r){for(re[e]=r,e=0;e<r.length;e++)z.add(r[e])}var te=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),ge={},qe={};function lt(e){return oa.call(qe,e)?!0:oa.call(ge,e)?!1:te.test(e)?qe[e]=!0:(ge[e]=!0,!1)}function Gt(e,r,a){if(lt(r))if(a===null)e.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(r);return;case"boolean":var l=r.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){e.removeAttribute(r);return}}e.setAttribute(r,""+a)}}function Fn(e,r,a){if(a===null)e.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(r);return}e.setAttribute(r,""+a)}}function hr(e,r,a,l){if(l===null)e.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(r,a,""+l)}}function Nn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Im(e){var r=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Vv(e,r,a){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,r);if(!e.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,p=l.set;return Object.defineProperty(e,r,{configurable:!0,get:function(){return f.call(this)},set:function(_){a=""+_,p.call(this,_)}}),Object.defineProperty(e,r,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){e._valueTracker=null,delete e[r]}}}}function Bu(e){if(!e._valueTracker){var r=Im(e)?"checked":"value";e._valueTracker=Vv(e,r,""+e[r])}}function $m(e){if(!e)return!1;var r=e._valueTracker;if(!r)return!0;var a=r.getValue(),l="";return e&&(l=Im(e)?e.checked?"true":"false":e.value),e=l,e!==a?(r.setValue(e),!0):!1}function Vo(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Yv=/[\n"\\]/g;function Tn(e){return e.replace(Yv,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Pu(e,r,a,l,f,p,_,O){e.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?e.type=_:e.removeAttribute("type"),r!=null?_==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+Nn(r)):e.value!==""+Nn(r)&&(e.value=""+Nn(r)):_!=="submit"&&_!=="reset"||e.removeAttribute("value"),r!=null?Uu(e,_,Nn(r)):a!=null?Uu(e,_,Nn(a)):l!=null&&e.removeAttribute("value"),f==null&&p!=null&&(e.defaultChecked=!!p),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?e.name=""+Nn(O):e.removeAttribute("name")}function Hm(e,r,a,l,f,p,_,O){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(e.type=p),r!=null||a!=null){if(!(p!=="submit"&&p!=="reset"||r!=null)){Bu(e);return}a=a!=null?""+Nn(a):"",r=r!=null?""+Nn(r):a,O||r===e.value||(e.value=r),e.defaultValue=r}l=l??f,l=typeof l!="function"&&typeof l!="symbol"&&!!l,e.checked=O?e.checked:!!l,e.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(e.name=_),Bu(e)}function Uu(e,r,a){r==="number"&&Vo(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function oi(e,r,a,l){if(e=e.options,r){r={};for(var f=0;f<a.length;f++)r["$"+a[f]]=!0;for(a=0;a<e.length;a++)f=r.hasOwnProperty("$"+e[a].value),e[a].selected!==f&&(e[a].selected=f),f&&l&&(e[a].defaultSelected=!0)}else{for(a=""+Nn(a),r=null,f=0;f<e.length;f++){if(e[f].value===a){e[f].selected=!0,l&&(e[f].defaultSelected=!0);return}r!==null||e[f].disabled||(r=e[f])}r!==null&&(r.selected=!0)}}function Fm(e,r,a){if(r!=null&&(r=""+Nn(r),r!==e.value&&(e.value=r),a==null)){e.defaultValue!==r&&(e.defaultValue=r);return}e.defaultValue=a!=null?""+Nn(a):""}function Gm(e,r,a,l){if(r==null){if(l!=null){if(a!=null)throw Error(i(92));if(ke(l)){if(1<l.length)throw Error(i(93));l=l[0]}a=l}a==null&&(a=""),r=a}a=Nn(r),e.defaultValue=a,l=e.textContent,l===a&&l!==""&&l!==null&&(e.value=l),Bu(e)}function li(e,r){if(r){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=r;return}}e.textContent=r}var Kv=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Vm(e,r,a){var l=r.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?e.setProperty(r,""):r==="float"?e.cssFloat="":e[r]="":l?e.setProperty(r,a):typeof a!="number"||a===0||Kv.has(r)?r==="float"?e.cssFloat=a:e[r]=(""+a).trim():e[r]=a+"px"}function Ym(e,r,a){if(r!=null&&typeof r!="object")throw Error(i(62));if(e=e.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||r!=null&&r.hasOwnProperty(l)||(l.indexOf("--")===0?e.setProperty(l,""):l==="float"?e.cssFloat="":e[l]="");for(var f in r)l=r[f],r.hasOwnProperty(f)&&a[f]!==l&&Vm(e,f,l)}else for(var p in r)r.hasOwnProperty(p)&&Vm(e,p,r[p])}function zu(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Jv=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Xv=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Yo(e){return Xv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function dr(){}var Iu=null;function $u(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ci=null,ui=null;function Km(e){var r=N(e);if(r&&(e=r.stateNode)){var a=e[gt]||null;e:switch(e=r.stateNode,r.type){case"input":if(Pu(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),r=a.name,a.type==="radio"&&r!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Tn(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var l=a[r];if(l!==e&&l.form===e.form){var f=l[gt]||null;if(!f)throw Error(i(90));Pu(l,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(r=0;r<a.length;r++)l=a[r],l.form===e.form&&$m(l)}break e;case"textarea":Fm(e,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&oi(e,!!a.multiple,r,!1)}}}var Hu=!1;function Jm(e,r,a){if(Hu)return e(r,a);Hu=!0;try{var l=e(r);return l}finally{if(Hu=!1,(ci!==null||ui!==null)&&(Dl(),ci&&(r=ci,e=ui,ui=ci=null,Km(r),e)))for(r=0;r<e.length;r++)Km(e[r])}}function ma(e,r){var a=e.stateNode;if(a===null)return null;var l=a[gt]||null;if(l===null)return null;a=l[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(i(231,r,typeof a));return a}var mr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fu=!1;if(mr)try{var pa={};Object.defineProperty(pa,"passive",{get:function(){Fu=!0}}),window.addEventListener("test",pa,pa),window.removeEventListener("test",pa,pa)}catch{Fu=!1}var Gr=null,Gu=null,Ko=null;function Xm(){if(Ko)return Ko;var e,r=Gu,a=r.length,l,f="value"in Gr?Gr.value:Gr.textContent,p=f.length;for(e=0;e<a&&r[e]===f[e];e++);var _=a-e;for(l=1;l<=_&&r[a-l]===f[p-l];l++);return Ko=f.slice(e,1<l?1-l:void 0)}function Jo(e){var r=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&r===13&&(e=13)):e=r,e===10&&(e=13),32<=e||e===13?e:0}function Xo(){return!0}function Qm(){return!1}function Zt(e){function r(a,l,f,p,_){this._reactName=a,this._targetInst=f,this.type=l,this.nativeEvent=p,this.target=_,this.currentTarget=null;for(var O in e)e.hasOwnProperty(O)&&(a=e[O],this[O]=a?a(p):p[O]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?Xo:Qm,this.isPropagationStopped=Qm,this}return b(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Xo)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Xo)},persist:function(){},isPersistent:Xo}),r}var Ms={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Qo=Zt(Ms),ya=b({},Ms,{view:0,detail:0}),Qv=Zt(ya),Vu,Yu,ga,Wo=b({},ya,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ju,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ga&&(ga&&e.type==="mousemove"?(Vu=e.screenX-ga.screenX,Yu=e.screenY-ga.screenY):Yu=Vu=0,ga=e),Vu)},movementY:function(e){return"movementY"in e?e.movementY:Yu}}),Wm=Zt(Wo),Wv=b({},Wo,{dataTransfer:0}),Zv=Zt(Wv),e_=b({},ya,{relatedTarget:0}),Ku=Zt(e_),t_=b({},Ms,{animationName:0,elapsedTime:0,pseudoElement:0}),n_=Zt(t_),r_=b({},Ms,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),s_=Zt(r_),i_=b({},Ms,{data:0}),Zm=Zt(i_),a_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},o_={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},l_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function c_(e){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(e):(e=l_[e])?!!r[e]:!1}function Ju(){return c_}var u_=b({},ya,{key:function(e){if(e.key){var r=a_[e.key]||e.key;if(r!=="Unidentified")return r}return e.type==="keypress"?(e=Jo(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?o_[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ju,charCode:function(e){return e.type==="keypress"?Jo(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Jo(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),f_=Zt(u_),h_=b({},Wo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),e0=Zt(h_),d_=b({},ya,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ju}),m_=Zt(d_),p_=b({},Ms,{propertyName:0,elapsedTime:0,pseudoElement:0}),y_=Zt(p_),g_=b({},Wo,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),b_=Zt(g_),x_=b({},Ms,{newState:0,oldState:0}),v_=Zt(x_),__=[9,13,27,32],Xu=mr&&"CompositionEvent"in window,ba=null;mr&&"documentMode"in document&&(ba=document.documentMode);var w_=mr&&"TextEvent"in window&&!ba,t0=mr&&(!Xu||ba&&8<ba&&11>=ba),n0=" ",r0=!1;function s0(e,r){switch(e){case"keyup":return __.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function i0(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var fi=!1;function S_(e,r){switch(e){case"compositionend":return i0(r);case"keypress":return r.which!==32?null:(r0=!0,n0);case"textInput":return e=r.data,e===n0&&r0?null:e;default:return null}}function E_(e,r){if(fi)return e==="compositionend"||!Xu&&s0(e,r)?(e=Xm(),Ko=Gu=Gr=null,fi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return t0&&r.locale!=="ko"?null:r.data;default:return null}}var O_={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function a0(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r==="input"?!!O_[e.type]:r==="textarea"}function o0(e,r,a,l){ci?ui?ui.push(l):ui=[l]:ci=l,r=Il(r,"onChange"),0<r.length&&(a=new Qo("onChange","change",null,a,l),e.push({event:a,listeners:r}))}var xa=null,va=null;function A_(e){Hy(e,0)}function Zo(e){var r=k(e);if($m(r))return e}function l0(e,r){if(e==="change")return r}var c0=!1;if(mr){var Qu;if(mr){var Wu="oninput"in document;if(!Wu){var u0=document.createElement("div");u0.setAttribute("oninput","return;"),Wu=typeof u0.oninput=="function"}Qu=Wu}else Qu=!1;c0=Qu&&(!document.documentMode||9<document.documentMode)}function f0(){xa&&(xa.detachEvent("onpropertychange",h0),va=xa=null)}function h0(e){if(e.propertyName==="value"&&Zo(va)){var r=[];o0(r,va,e,$u(e)),Jm(A_,r)}}function j_(e,r,a){e==="focusin"?(f0(),xa=r,va=a,xa.attachEvent("onpropertychange",h0)):e==="focusout"&&f0()}function k_(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Zo(va)}function N_(e,r){if(e==="click")return Zo(r)}function T_(e,r){if(e==="input"||e==="change")return Zo(r)}function C_(e,r){return e===r&&(e!==0||1/e===1/r)||e!==e&&r!==r}var fn=typeof Object.is=="function"?Object.is:C_;function _a(e,r){if(fn(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;var a=Object.keys(e),l=Object.keys(r);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var f=a[l];if(!oa.call(r,f)||!fn(e[f],r[f]))return!1}return!0}function d0(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function m0(e,r){var a=d0(e);e=0;for(var l;a;){if(a.nodeType===3){if(l=e+a.textContent.length,e<=r&&l>=r)return{node:a,offset:r-e};e=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=d0(a)}}function p0(e,r){return e&&r?e===r?!0:e&&e.nodeType===3?!1:r&&r.nodeType===3?p0(e,r.parentNode):"contains"in e?e.contains(r):e.compareDocumentPosition?!!(e.compareDocumentPosition(r)&16):!1:!1}function y0(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var r=Vo(e.document);r instanceof e.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)e=r.contentWindow;else break;r=Vo(e.document)}return r}function Zu(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r&&(r==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||r==="textarea"||e.contentEditable==="true")}var M_=mr&&"documentMode"in document&&11>=document.documentMode,hi=null,ef=null,wa=null,tf=!1;function g0(e,r,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;tf||hi==null||hi!==Vo(l)||(l=hi,"selectionStart"in l&&Zu(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),wa&&_a(wa,l)||(wa=l,l=Il(ef,"onSelect"),0<l.length&&(r=new Qo("onSelect","select",null,r,a),e.push({event:r,listeners:l}),r.target=hi)))}function Rs(e,r){var a={};return a[e.toLowerCase()]=r.toLowerCase(),a["Webkit"+e]="webkit"+r,a["Moz"+e]="moz"+r,a}var di={animationend:Rs("Animation","AnimationEnd"),animationiteration:Rs("Animation","AnimationIteration"),animationstart:Rs("Animation","AnimationStart"),transitionrun:Rs("Transition","TransitionRun"),transitionstart:Rs("Transition","TransitionStart"),transitioncancel:Rs("Transition","TransitionCancel"),transitionend:Rs("Transition","TransitionEnd")},nf={},b0={};mr&&(b0=document.createElement("div").style,"AnimationEvent"in window||(delete di.animationend.animation,delete di.animationiteration.animation,delete di.animationstart.animation),"TransitionEvent"in window||delete di.transitionend.transition);function Ds(e){if(nf[e])return nf[e];if(!di[e])return e;var r=di[e],a;for(a in r)if(r.hasOwnProperty(a)&&a in b0)return nf[e]=r[a];return e}var x0=Ds("animationend"),v0=Ds("animationiteration"),_0=Ds("animationstart"),R_=Ds("transitionrun"),D_=Ds("transitionstart"),L_=Ds("transitioncancel"),w0=Ds("transitionend"),S0=new Map,rf="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");rf.push("scrollEnd");function Gn(e,r){S0.set(e,r),ae(r,[e])}var el=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Cn=[],mi=0,sf=0;function tl(){for(var e=mi,r=sf=mi=0;r<e;){var a=Cn[r];Cn[r++]=null;var l=Cn[r];Cn[r++]=null;var f=Cn[r];Cn[r++]=null;var p=Cn[r];if(Cn[r++]=null,l!==null&&f!==null){var _=l.pending;_===null?f.next=f:(f.next=_.next,_.next=f),l.pending=f}p!==0&&E0(a,f,p)}}function nl(e,r,a,l){Cn[mi++]=e,Cn[mi++]=r,Cn[mi++]=a,Cn[mi++]=l,sf|=l,e.lanes|=l,e=e.alternate,e!==null&&(e.lanes|=l)}function af(e,r,a,l){return nl(e,r,a,l),rl(e)}function Ls(e,r){return nl(e,null,null,r),rl(e)}function E0(e,r,a){e.lanes|=a;var l=e.alternate;l!==null&&(l.lanes|=a);for(var f=!1,p=e.return;p!==null;)p.childLanes|=a,l=p.alternate,l!==null&&(l.childLanes|=a),p.tag===22&&(e=p.stateNode,e===null||e._visibility&1||(f=!0)),e=p,p=p.return;return e.tag===3?(p=e.stateNode,f&&r!==null&&(f=31-Ft(a),e=p.hiddenUpdates,l=e[f],l===null?e[f]=[r]:l.push(r),r.lane=a|536870912),p):null}function rl(e){if(50<Fa)throw Fa=0,ph=null,Error(i(185));for(var r=e.return;r!==null;)e=r,r=e.return;return e.tag===3?e.stateNode:null}var pi={};function q_(e,r,a,l){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function hn(e,r,a,l){return new q_(e,r,a,l)}function of(e){return e=e.prototype,!(!e||!e.isReactComponent)}function pr(e,r){var a=e.alternate;return a===null?(a=hn(e.tag,r,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=r,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,r=e.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function O0(e,r){e.flags&=65011714;var a=e.alternate;return a===null?(e.childLanes=0,e.lanes=r,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,r=a.dependencies,e.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),e}function sl(e,r,a,l,f,p){var _=0;if(l=e,typeof e=="function")of(e)&&(_=1);else if(typeof e=="string")_=Iw(e,a,Ze.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case I:return e=hn(31,a,r,f),e.elementType=I,e.lanes=p,e;case S:return qs(a.children,f,p,r);case C:_=8,f|=24;break;case q:return e=hn(12,a,r,f|2),e.elementType=q,e.lanes=p,e;case R:return e=hn(13,a,r,f),e.elementType=R,e.lanes=p,e;case $:return e=hn(19,a,r,f),e.elementType=$,e.lanes=p,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ie:_=10;break e;case B:_=9;break e;case le:_=11;break e;case ne:_=14;break e;case V:_=16,l=null;break e}_=29,a=Error(i(130,e===null?"null":typeof e,"")),l=null}return r=hn(_,a,r,f),r.elementType=e,r.type=l,r.lanes=p,r}function qs(e,r,a,l){return e=hn(7,e,l,r),e.lanes=a,e}function lf(e,r,a){return e=hn(6,e,null,r),e.lanes=a,e}function A0(e){var r=hn(18,null,null,0);return r.stateNode=e,r}function cf(e,r,a){return r=hn(4,e.children!==null?e.children:[],e.key,r),r.lanes=a,r.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},r}var j0=new WeakMap;function Mn(e,r){if(typeof e=="object"&&e!==null){var a=j0.get(e);return a!==void 0?a:(r={value:e,source:r,stack:Bo(r)},j0.set(e,r),r)}return{value:e,source:r,stack:Bo(r)}}var yi=[],gi=0,il=null,Sa=0,Rn=[],Dn=0,Vr=null,tr=1,nr="";function yr(e,r){yi[gi++]=Sa,yi[gi++]=il,il=e,Sa=r}function k0(e,r,a){Rn[Dn++]=tr,Rn[Dn++]=nr,Rn[Dn++]=Vr,Vr=e;var l=tr;e=nr;var f=32-Ft(l)-1;l&=~(1<<f),a+=1;var p=32-Ft(r)+f;if(30<p){var _=f-f%5;p=(l&(1<<_)-1).toString(32),l>>=_,f-=_,tr=1<<32-Ft(r)+f|a<<f|l,nr=p+e}else tr=1<<p|a<<f|l,nr=e}function uf(e){e.return!==null&&(yr(e,1),k0(e,1,0))}function ff(e){for(;e===il;)il=yi[--gi],yi[gi]=null,Sa=yi[--gi],yi[gi]=null;for(;e===Vr;)Vr=Rn[--Dn],Rn[Dn]=null,nr=Rn[--Dn],Rn[Dn]=null,tr=Rn[--Dn],Rn[Dn]=null}function N0(e,r){Rn[Dn++]=tr,Rn[Dn++]=nr,Rn[Dn++]=Vr,tr=r.id,nr=r.overflow,Vr=e}var Ut=null,ct=null,Fe=!1,Yr=null,Ln=!1,hf=Error(i(519));function Kr(e){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ea(Mn(r,e)),hf}function T0(e){var r=e.stateNode,a=e.type,l=e.memoizedProps;switch(r[at]=e,r[gt]=l,a){case"dialog":Ue("cancel",r),Ue("close",r);break;case"iframe":case"object":case"embed":Ue("load",r);break;case"video":case"audio":for(a=0;a<Va.length;a++)Ue(Va[a],r);break;case"source":Ue("error",r);break;case"img":case"image":case"link":Ue("error",r),Ue("load",r);break;case"details":Ue("toggle",r);break;case"input":Ue("invalid",r),Hm(r,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":Ue("invalid",r);break;case"textarea":Ue("invalid",r),Gm(r,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||r.textContent===""+a||l.suppressHydrationWarning===!0||Yy(r.textContent,a)?(l.popover!=null&&(Ue("beforetoggle",r),Ue("toggle",r)),l.onScroll!=null&&Ue("scroll",r),l.onScrollEnd!=null&&Ue("scrollend",r),l.onClick!=null&&(r.onclick=dr),r=!0):r=!1,r||Kr(e,!0)}function C0(e){for(Ut=e.return;Ut;)switch(Ut.tag){case 5:case 31:case 13:Ln=!1;return;case 27:case 3:Ln=!0;return;default:Ut=Ut.return}}function bi(e){if(e!==Ut)return!1;if(!Fe)return C0(e),Fe=!0,!1;var r=e.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Th(e.type,e.memoizedProps)),a=!a),a&&ct&&Kr(e),C0(e),r===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));ct=ng(e)}else if(r===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));ct=ng(e)}else r===27?(r=ct,ls(e.type)?(e=Lh,Lh=null,ct=e):ct=r):ct=Ut?Bn(e.stateNode.nextSibling):null;return!0}function Bs(){ct=Ut=null,Fe=!1}function df(){var e=Yr;return e!==null&&(rn===null?rn=e:rn.push.apply(rn,e),Yr=null),e}function Ea(e){Yr===null?Yr=[e]:Yr.push(e)}var mf=Ce(null),Ps=null,gr=null;function Jr(e,r,a){Me(mf,r._currentValue),r._currentValue=a}function br(e){e._currentValue=mf.current,Ne(mf)}function pf(e,r,a){for(;e!==null;){var l=e.alternate;if((e.childLanes&r)!==r?(e.childLanes|=r,l!==null&&(l.childLanes|=r)):l!==null&&(l.childLanes&r)!==r&&(l.childLanes|=r),e===a)break;e=e.return}}function yf(e,r,a,l){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var p=f.dependencies;if(p!==null){var _=f.child;p=p.firstContext;e:for(;p!==null;){var O=p;p=f;for(var M=0;M<r.length;M++)if(O.context===r[M]){p.lanes|=a,O=p.alternate,O!==null&&(O.lanes|=a),pf(p.return,a,e),l||(_=null);break e}p=O.next}}else if(f.tag===18){if(_=f.return,_===null)throw Error(i(341));_.lanes|=a,p=_.alternate,p!==null&&(p.lanes|=a),pf(_,a,e),_=null}else _=f.child;if(_!==null)_.return=f;else for(_=f;_!==null;){if(_===e){_=null;break}if(f=_.sibling,f!==null){f.return=_.return,_=f;break}_=_.return}f=_}}function xi(e,r,a,l){e=null;for(var f=r,p=!1;f!==null;){if(!p){if((f.flags&524288)!==0)p=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var _=f.alternate;if(_===null)throw Error(i(387));if(_=_.memoizedProps,_!==null){var O=f.type;fn(f.pendingProps.value,_.value)||(e!==null?e.push(O):e=[O])}}else if(f===we.current){if(_=f.alternate,_===null)throw Error(i(387));_.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(Qa):e=[Qa])}f=f.return}e!==null&&yf(r,e,a,l),r.flags|=262144}function al(e){for(e=e.firstContext;e!==null;){if(!fn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Us(e){Ps=e,gr=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function zt(e){return M0(Ps,e)}function ol(e,r){return Ps===null&&Us(e),M0(e,r)}function M0(e,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},gr===null){if(e===null)throw Error(i(308));gr=r,e.dependencies={lanes:0,firstContext:r},e.flags|=524288}else gr=gr.next=r;return a}var B_=typeof AbortController<"u"?AbortController:function(){var e=[],r=this.signal={aborted:!1,addEventListener:function(a,l){e.push(l)}};this.abort=function(){r.aborted=!0,e.forEach(function(a){return a()})}},P_=n.unstable_scheduleCallback,U_=n.unstable_NormalPriority,At={$$typeof:ie,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function gf(){return{controller:new B_,data:new Map,refCount:0}}function Oa(e){e.refCount--,e.refCount===0&&P_(U_,function(){e.controller.abort()})}var Aa=null,bf=0,vi=0,_i=null;function z_(e,r){if(Aa===null){var a=Aa=[];bf=0,vi=_h(),_i={status:"pending",value:void 0,then:function(l){a.push(l)}}}return bf++,r.then(R0,R0),r}function R0(){if(--bf===0&&Aa!==null){_i!==null&&(_i.status="fulfilled");var e=Aa;Aa=null,vi=0,_i=null;for(var r=0;r<e.length;r++)(0,e[r])()}}function I_(e,r){var a=[],l={status:"pending",value:null,reason:null,then:function(f){a.push(f)}};return e.then(function(){l.status="fulfilled",l.value=r;for(var f=0;f<a.length;f++)(0,a[f])(r)},function(f){for(l.status="rejected",l.reason=f,f=0;f<a.length;f++)(0,a[f])(void 0)}),l}var D0=H.S;H.S=function(e,r){gy=ht(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&z_(e,r),D0!==null&&D0(e,r)};var zs=Ce(null);function xf(){var e=zs.current;return e!==null?e:ot.pooledCache}function ll(e,r){r===null?Me(zs,zs.current):Me(zs,r.pool)}function L0(){var e=xf();return e===null?null:{parent:At._currentValue,pool:e}}var wi=Error(i(460)),vf=Error(i(474)),cl=Error(i(542)),ul={then:function(){}};function q0(e){return e=e.status,e==="fulfilled"||e==="rejected"}function B0(e,r,a){switch(a=e[a],a===void 0?e.push(r):a!==r&&(r.then(dr,dr),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw e=r.reason,U0(e),e;default:if(typeof r.status=="string")r.then(dr,dr);else{if(e=ot,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=r,e.status="pending",e.then(function(l){if(r.status==="pending"){var f=r;f.status="fulfilled",f.value=l}},function(l){if(r.status==="pending"){var f=r;f.status="rejected",f.reason=l}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw e=r.reason,U0(e),e}throw $s=r,wi}}function Is(e){try{var r=e._init;return r(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?($s=a,wi):a}}var $s=null;function P0(){if($s===null)throw Error(i(459));var e=$s;return $s=null,e}function U0(e){if(e===wi||e===cl)throw Error(i(483))}var Si=null,ja=0;function fl(e){var r=ja;return ja+=1,Si===null&&(Si=[]),B0(Si,e,r)}function ka(e,r){r=r.props.ref,e.ref=r!==void 0?r:null}function hl(e,r){throw r.$$typeof===x?Error(i(525)):(e=Object.prototype.toString.call(r),Error(i(31,e==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":e)))}function z0(e){function r(U,P){if(e){var F=U.deletions;F===null?(U.deletions=[P],U.flags|=16):F.push(P)}}function a(U,P){if(!e)return null;for(;P!==null;)r(U,P),P=P.sibling;return null}function l(U){for(var P=new Map;U!==null;)U.key!==null?P.set(U.key,U):P.set(U.index,U),U=U.sibling;return P}function f(U,P){return U=pr(U,P),U.index=0,U.sibling=null,U}function p(U,P,F){return U.index=F,e?(F=U.alternate,F!==null?(F=F.index,F<P?(U.flags|=67108866,P):F):(U.flags|=67108866,P)):(U.flags|=1048576,P)}function _(U){return e&&U.alternate===null&&(U.flags|=67108866),U}function O(U,P,F,ee){return P===null||P.tag!==6?(P=lf(F,U.mode,ee),P.return=U,P):(P=f(P,F),P.return=U,P)}function M(U,P,F,ee){var Oe=F.type;return Oe===S?Z(U,P,F.props.children,ee,F.key):P!==null&&(P.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===V&&Is(Oe)===P.type)?(P=f(P,F.props),ka(P,F),P.return=U,P):(P=sl(F.type,F.key,F.props,null,U.mode,ee),ka(P,F),P.return=U,P)}function G(U,P,F,ee){return P===null||P.tag!==4||P.stateNode.containerInfo!==F.containerInfo||P.stateNode.implementation!==F.implementation?(P=cf(F,U.mode,ee),P.return=U,P):(P=f(P,F.children||[]),P.return=U,P)}function Z(U,P,F,ee,Oe){return P===null||P.tag!==7?(P=qs(F,U.mode,ee,Oe),P.return=U,P):(P=f(P,F),P.return=U,P)}function se(U,P,F){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=lf(""+P,U.mode,F),P.return=U,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case v:return F=sl(P.type,P.key,P.props,null,U.mode,F),ka(F,P),F.return=U,F;case w:return P=cf(P,U.mode,F),P.return=U,P;case V:return P=Is(P),se(U,P,F)}if(ke(P)||X(P))return P=qs(P,U.mode,F,null),P.return=U,P;if(typeof P.then=="function")return se(U,fl(P),F);if(P.$$typeof===ie)return se(U,ol(U,P),F);hl(U,P)}return null}function Y(U,P,F,ee){var Oe=P!==null?P.key:null;if(typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint")return Oe!==null?null:O(U,P,""+F,ee);if(typeof F=="object"&&F!==null){switch(F.$$typeof){case v:return F.key===Oe?M(U,P,F,ee):null;case w:return F.key===Oe?G(U,P,F,ee):null;case V:return F=Is(F),Y(U,P,F,ee)}if(ke(F)||X(F))return Oe!==null?null:Z(U,P,F,ee,null);if(typeof F.then=="function")return Y(U,P,fl(F),ee);if(F.$$typeof===ie)return Y(U,P,ol(U,F),ee);hl(U,F)}return null}function J(U,P,F,ee,Oe){if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return U=U.get(F)||null,O(P,U,""+ee,Oe);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case v:return U=U.get(ee.key===null?F:ee.key)||null,M(P,U,ee,Oe);case w:return U=U.get(ee.key===null?F:ee.key)||null,G(P,U,ee,Oe);case V:return ee=Is(ee),J(U,P,F,ee,Oe)}if(ke(ee)||X(ee))return U=U.get(F)||null,Z(P,U,ee,Oe,null);if(typeof ee.then=="function")return J(U,P,F,fl(ee),Oe);if(ee.$$typeof===ie)return J(U,P,F,ol(P,ee),Oe);hl(P,ee)}return null}function be(U,P,F,ee){for(var Oe=null,Je=null,_e=P,Le=P=0,Ie=null;_e!==null&&Le<F.length;Le++){_e.index>Le?(Ie=_e,_e=null):Ie=_e.sibling;var Xe=Y(U,_e,F[Le],ee);if(Xe===null){_e===null&&(_e=Ie);break}e&&_e&&Xe.alternate===null&&r(U,_e),P=p(Xe,P,Le),Je===null?Oe=Xe:Je.sibling=Xe,Je=Xe,_e=Ie}if(Le===F.length)return a(U,_e),Fe&&yr(U,Le),Oe;if(_e===null){for(;Le<F.length;Le++)_e=se(U,F[Le],ee),_e!==null&&(P=p(_e,P,Le),Je===null?Oe=_e:Je.sibling=_e,Je=_e);return Fe&&yr(U,Le),Oe}for(_e=l(_e);Le<F.length;Le++)Ie=J(_e,U,Le,F[Le],ee),Ie!==null&&(e&&Ie.alternate!==null&&_e.delete(Ie.key===null?Le:Ie.key),P=p(Ie,P,Le),Je===null?Oe=Ie:Je.sibling=Ie,Je=Ie);return e&&_e.forEach(function(ds){return r(U,ds)}),Fe&&yr(U,Le),Oe}function Te(U,P,F,ee){if(F==null)throw Error(i(151));for(var Oe=null,Je=null,_e=P,Le=P=0,Ie=null,Xe=F.next();_e!==null&&!Xe.done;Le++,Xe=F.next()){_e.index>Le?(Ie=_e,_e=null):Ie=_e.sibling;var ds=Y(U,_e,Xe.value,ee);if(ds===null){_e===null&&(_e=Ie);break}e&&_e&&ds.alternate===null&&r(U,_e),P=p(ds,P,Le),Je===null?Oe=ds:Je.sibling=ds,Je=ds,_e=Ie}if(Xe.done)return a(U,_e),Fe&&yr(U,Le),Oe;if(_e===null){for(;!Xe.done;Le++,Xe=F.next())Xe=se(U,Xe.value,ee),Xe!==null&&(P=p(Xe,P,Le),Je===null?Oe=Xe:Je.sibling=Xe,Je=Xe);return Fe&&yr(U,Le),Oe}for(_e=l(_e);!Xe.done;Le++,Xe=F.next())Xe=J(_e,U,Le,Xe.value,ee),Xe!==null&&(e&&Xe.alternate!==null&&_e.delete(Xe.key===null?Le:Xe.key),P=p(Xe,P,Le),Je===null?Oe=Xe:Je.sibling=Xe,Je=Xe);return e&&_e.forEach(function(Ww){return r(U,Ww)}),Fe&&yr(U,Le),Oe}function it(U,P,F,ee){if(typeof F=="object"&&F!==null&&F.type===S&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case v:e:{for(var Oe=F.key;P!==null;){if(P.key===Oe){if(Oe=F.type,Oe===S){if(P.tag===7){a(U,P.sibling),ee=f(P,F.props.children),ee.return=U,U=ee;break e}}else if(P.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===V&&Is(Oe)===P.type){a(U,P.sibling),ee=f(P,F.props),ka(ee,F),ee.return=U,U=ee;break e}a(U,P);break}else r(U,P);P=P.sibling}F.type===S?(ee=qs(F.props.children,U.mode,ee,F.key),ee.return=U,U=ee):(ee=sl(F.type,F.key,F.props,null,U.mode,ee),ka(ee,F),ee.return=U,U=ee)}return _(U);case w:e:{for(Oe=F.key;P!==null;){if(P.key===Oe)if(P.tag===4&&P.stateNode.containerInfo===F.containerInfo&&P.stateNode.implementation===F.implementation){a(U,P.sibling),ee=f(P,F.children||[]),ee.return=U,U=ee;break e}else{a(U,P);break}else r(U,P);P=P.sibling}ee=cf(F,U.mode,ee),ee.return=U,U=ee}return _(U);case V:return F=Is(F),it(U,P,F,ee)}if(ke(F))return be(U,P,F,ee);if(X(F)){if(Oe=X(F),typeof Oe!="function")throw Error(i(150));return F=Oe.call(F),Te(U,P,F,ee)}if(typeof F.then=="function")return it(U,P,fl(F),ee);if(F.$$typeof===ie)return it(U,P,ol(U,F),ee);hl(U,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,P!==null&&P.tag===6?(a(U,P.sibling),ee=f(P,F),ee.return=U,U=ee):(a(U,P),ee=lf(F,U.mode,ee),ee.return=U,U=ee),_(U)):a(U,P)}return function(U,P,F,ee){try{ja=0;var Oe=it(U,P,F,ee);return Si=null,Oe}catch(_e){if(_e===wi||_e===cl)throw _e;var Je=hn(29,_e,null,U.mode);return Je.lanes=ee,Je.return=U,Je}finally{}}}var Hs=z0(!0),I0=z0(!1),Xr=!1;function _f(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wf(e,r){e=e.updateQueue,r.updateQueue===e&&(r.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Qr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Wr(e,r,a){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Qe&2)!==0){var f=l.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),l.pending=r,r=rl(e),E0(e,null,a),r}return nl(e,l,r,a),rl(e)}function Na(e,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194048)!==0)){var l=r.lanes;l&=e.pendingLanes,a|=l,r.lanes=a,Ns(e,a)}}function Sf(e,r){var a=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var f=null,p=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};p===null?f=p=_:p=p.next=_,a=a.next}while(a!==null);p===null?f=p=r:p=p.next=r}else f=p=r;a={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:p,shared:l.shared,callbacks:l.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=r:e.next=r,a.lastBaseUpdate=r}var Ef=!1;function Ta(){if(Ef){var e=_i;if(e!==null)throw e}}function Ca(e,r,a,l){Ef=!1;var f=e.updateQueue;Xr=!1;var p=f.firstBaseUpdate,_=f.lastBaseUpdate,O=f.shared.pending;if(O!==null){f.shared.pending=null;var M=O,G=M.next;M.next=null,_===null?p=G:_.next=G,_=M;var Z=e.alternate;Z!==null&&(Z=Z.updateQueue,O=Z.lastBaseUpdate,O!==_&&(O===null?Z.firstBaseUpdate=G:O.next=G,Z.lastBaseUpdate=M))}if(p!==null){var se=f.baseState;_=0,Z=G=M=null,O=p;do{var Y=O.lane&-536870913,J=Y!==O.lane;if(J?(ze&Y)===Y:(l&Y)===Y){Y!==0&&Y===vi&&(Ef=!0),Z!==null&&(Z=Z.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var be=e,Te=O;Y=r;var it=a;switch(Te.tag){case 1:if(be=Te.payload,typeof be=="function"){se=be.call(it,se,Y);break e}se=be;break e;case 3:be.flags=be.flags&-65537|128;case 0:if(be=Te.payload,Y=typeof be=="function"?be.call(it,se,Y):be,Y==null)break e;se=b({},se,Y);break e;case 2:Xr=!0}}Y=O.callback,Y!==null&&(e.flags|=64,J&&(e.flags|=8192),J=f.callbacks,J===null?f.callbacks=[Y]:J.push(Y))}else J={lane:Y,tag:O.tag,payload:O.payload,callback:O.callback,next:null},Z===null?(G=Z=J,M=se):Z=Z.next=J,_|=Y;if(O=O.next,O===null){if(O=f.shared.pending,O===null)break;J=O,O=J.next,J.next=null,f.lastBaseUpdate=J,f.shared.pending=null}}while(!0);Z===null&&(M=se),f.baseState=M,f.firstBaseUpdate=G,f.lastBaseUpdate=Z,p===null&&(f.shared.lanes=0),rs|=_,e.lanes=_,e.memoizedState=se}}function $0(e,r){if(typeof e!="function")throw Error(i(191,e));e.call(r)}function H0(e,r){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)$0(a[e],r)}var Ei=Ce(null),dl=Ce(0);function F0(e,r){e=jr,Me(dl,e),Me(Ei,r),jr=e|r.baseLanes}function Of(){Me(dl,jr),Me(Ei,Ei.current)}function Af(){jr=dl.current,Ne(Ei),Ne(dl)}var dn=Ce(null),qn=null;function Zr(e){var r=e.alternate;Me(wt,wt.current&1),Me(dn,e),qn===null&&(r===null||Ei.current!==null||r.memoizedState!==null)&&(qn=e)}function jf(e){Me(wt,wt.current),Me(dn,e),qn===null&&(qn=e)}function G0(e){e.tag===22?(Me(wt,wt.current),Me(dn,e),qn===null&&(qn=e)):es()}function es(){Me(wt,wt.current),Me(dn,dn.current)}function mn(e){Ne(dn),qn===e&&(qn=null),Ne(wt)}var wt=Ce(0);function ml(e){for(var r=e;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Rh(a)||Dh(a)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var xr=0,De=null,rt=null,jt=null,pl=!1,Oi=!1,Fs=!1,yl=0,Ma=0,Ai=null,$_=0;function bt(){throw Error(i(321))}function kf(e,r){if(r===null)return!1;for(var a=0;a<r.length&&a<e.length;a++)if(!fn(e[a],r[a]))return!1;return!0}function Nf(e,r,a,l,f,p){return xr=p,De=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,H.H=e===null||e.memoizedState===null?kp:Ff,Fs=!1,p=a(l,f),Fs=!1,Oi&&(p=Y0(r,a,l,f)),V0(e),p}function V0(e){H.H=La;var r=rt!==null&&rt.next!==null;if(xr=0,jt=rt=De=null,pl=!1,Ma=0,Ai=null,r)throw Error(i(300));e===null||kt||(e=e.dependencies,e!==null&&al(e)&&(kt=!0))}function Y0(e,r,a,l){De=e;var f=0;do{if(Oi&&(Ai=null),Ma=0,Oi=!1,25<=f)throw Error(i(301));if(f+=1,jt=rt=null,e.updateQueue!=null){var p=e.updateQueue;p.lastEffect=null,p.events=null,p.stores=null,p.memoCache!=null&&(p.memoCache.index=0)}H.H=Np,p=r(a,l)}while(Oi);return p}function H_(){var e=H.H,r=e.useState()[0];return r=typeof r.then=="function"?Ra(r):r,e=e.useState()[0],(rt!==null?rt.memoizedState:null)!==e&&(De.flags|=1024),r}function Tf(){var e=yl!==0;return yl=0,e}function Cf(e,r,a){r.updateQueue=e.updateQueue,r.flags&=-2053,e.lanes&=~a}function Mf(e){if(pl){for(e=e.memoizedState;e!==null;){var r=e.queue;r!==null&&(r.pending=null),e=e.next}pl=!1}xr=0,jt=rt=De=null,Oi=!1,Ma=yl=0,Ai=null}function Vt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jt===null?De.memoizedState=jt=e:jt=jt.next=e,jt}function St(){if(rt===null){var e=De.alternate;e=e!==null?e.memoizedState:null}else e=rt.next;var r=jt===null?De.memoizedState:jt.next;if(r!==null)jt=r,rt=e;else{if(e===null)throw De.alternate===null?Error(i(467)):Error(i(310));rt=e,e={memoizedState:rt.memoizedState,baseState:rt.baseState,baseQueue:rt.baseQueue,queue:rt.queue,next:null},jt===null?De.memoizedState=jt=e:jt=jt.next=e}return jt}function gl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ra(e){var r=Ma;return Ma+=1,Ai===null&&(Ai=[]),e=B0(Ai,e,r),r=De,(jt===null?r.memoizedState:jt.next)===null&&(r=r.alternate,H.H=r===null||r.memoizedState===null?kp:Ff),e}function bl(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Ra(e);if(e.$$typeof===ie)return zt(e)}throw Error(i(438,String(e)))}function Rf(e){var r=null,a=De.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var l=De.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(r={data:l.data.map(function(f){return f.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),a===null&&(a=gl(),De.updateQueue=a),a.memoCache=r,a=r.data[r.index],a===void 0)for(a=r.data[r.index]=Array(e),l=0;l<e;l++)a[l]=D;return r.index++,a}function vr(e,r){return typeof r=="function"?r(e):r}function xl(e){var r=St();return Df(r,rt,e)}function Df(e,r,a){var l=e.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=a;var f=e.baseQueue,p=l.pending;if(p!==null){if(f!==null){var _=f.next;f.next=p.next,p.next=_}r.baseQueue=f=p,l.pending=null}if(p=e.baseState,f===null)e.memoizedState=p;else{r=f.next;var O=_=null,M=null,G=r,Z=!1;do{var se=G.lane&-536870913;if(se!==G.lane?(ze&se)===se:(xr&se)===se){var Y=G.revertLane;if(Y===0)M!==null&&(M=M.next={lane:0,revertLane:0,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),se===vi&&(Z=!0);else if((xr&Y)===Y){G=G.next,Y===vi&&(Z=!0);continue}else se={lane:0,revertLane:G.revertLane,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},M===null?(O=M=se,_=p):M=M.next=se,De.lanes|=Y,rs|=Y;se=G.action,Fs&&a(p,se),p=G.hasEagerState?G.eagerState:a(p,se)}else Y={lane:se,revertLane:G.revertLane,gesture:G.gesture,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},M===null?(O=M=Y,_=p):M=M.next=Y,De.lanes|=se,rs|=se;G=G.next}while(G!==null&&G!==r);if(M===null?_=p:M.next=O,!fn(p,e.memoizedState)&&(kt=!0,Z&&(a=_i,a!==null)))throw a;e.memoizedState=p,e.baseState=_,e.baseQueue=M,l.lastRenderedState=p}return f===null&&(l.lanes=0),[e.memoizedState,l.dispatch]}function Lf(e){var r=St(),a=r.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=e;var l=a.dispatch,f=a.pending,p=r.memoizedState;if(f!==null){a.pending=null;var _=f=f.next;do p=e(p,_.action),_=_.next;while(_!==f);fn(p,r.memoizedState)||(kt=!0),r.memoizedState=p,r.baseQueue===null&&(r.baseState=p),a.lastRenderedState=p}return[p,l]}function K0(e,r,a){var l=De,f=St(),p=Fe;if(p){if(a===void 0)throw Error(i(407));a=a()}else a=r();var _=!fn((rt||f).memoizedState,a);if(_&&(f.memoizedState=a,kt=!0),f=f.queue,Pf(Q0.bind(null,l,f,e),[e]),f.getSnapshot!==r||_||jt!==null&&jt.memoizedState.tag&1){if(l.flags|=2048,ji(9,{destroy:void 0},X0.bind(null,l,f,a,r),null),ot===null)throw Error(i(349));p||(xr&127)!==0||J0(l,r,a)}return a}function J0(e,r,a){e.flags|=16384,e={getSnapshot:r,value:a},r=De.updateQueue,r===null?(r=gl(),De.updateQueue=r,r.stores=[e]):(a=r.stores,a===null?r.stores=[e]:a.push(e))}function X0(e,r,a,l){r.value=a,r.getSnapshot=l,W0(r)&&Z0(e)}function Q0(e,r,a){return a(function(){W0(r)&&Z0(e)})}function W0(e){var r=e.getSnapshot;e=e.value;try{var a=r();return!fn(e,a)}catch{return!0}}function Z0(e){var r=Ls(e,2);r!==null&&sn(r,e,2)}function qf(e){var r=Vt();if(typeof e=="function"){var a=e;if(e=a(),Fs){cn(!0);try{a()}finally{cn(!1)}}}return r.memoizedState=r.baseState=e,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:e},r}function ep(e,r,a,l){return e.baseState=a,Df(e,rt,typeof l=="function"?l:vr)}function F_(e,r,a,l,f){if(wl(e))throw Error(i(485));if(e=r.action,e!==null){var p={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){p.listeners.push(_)}};H.T!==null?a(!0):p.isTransition=!1,l(p),a=r.pending,a===null?(p.next=r.pending=p,tp(r,p)):(p.next=a.next,r.pending=a.next=p)}}function tp(e,r){var a=r.action,l=r.payload,f=e.state;if(r.isTransition){var p=H.T,_={};H.T=_;try{var O=a(f,l),M=H.S;M!==null&&M(_,O),np(e,r,O)}catch(G){Bf(e,r,G)}finally{p!==null&&_.types!==null&&(p.types=_.types),H.T=p}}else try{p=a(f,l),np(e,r,p)}catch(G){Bf(e,r,G)}}function np(e,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){rp(e,r,l)},function(l){return Bf(e,r,l)}):rp(e,r,a)}function rp(e,r,a){r.status="fulfilled",r.value=a,sp(r),e.state=a,r=e.pending,r!==null&&(a=r.next,a===r?e.pending=null:(a=a.next,r.next=a,tp(e,a)))}function Bf(e,r,a){var l=e.pending;if(e.pending=null,l!==null){l=l.next;do r.status="rejected",r.reason=a,sp(r),r=r.next;while(r!==l)}e.action=null}function sp(e){e=e.listeners;for(var r=0;r<e.length;r++)(0,e[r])()}function ip(e,r){return r}function ap(e,r){if(Fe){var a=ot.formState;if(a!==null){e:{var l=De;if(Fe){if(ct){t:{for(var f=ct,p=Ln;f.nodeType!==8;){if(!p){f=null;break t}if(f=Bn(f.nextSibling),f===null){f=null;break t}}p=f.data,f=p==="F!"||p==="F"?f:null}if(f){ct=Bn(f.nextSibling),l=f.data==="F!";break e}}Kr(l)}l=!1}l&&(r=a[0])}}return a=Vt(),a.memoizedState=a.baseState=r,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ip,lastRenderedState:r},a.queue=l,a=Op.bind(null,De,l),l.dispatch=a,l=qf(!1),p=Hf.bind(null,De,!1,l.queue),l=Vt(),f={state:r,dispatch:null,action:e,pending:null},l.queue=f,a=F_.bind(null,De,f,p,a),f.dispatch=a,l.memoizedState=e,[r,a,!1]}function op(e){var r=St();return lp(r,rt,e)}function lp(e,r,a){if(r=Df(e,r,ip)[0],e=xl(vr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var l=Ra(r)}catch(_){throw _===wi?cl:_}else l=r;r=St();var f=r.queue,p=f.dispatch;return a!==r.memoizedState&&(De.flags|=2048,ji(9,{destroy:void 0},G_.bind(null,f,a),null)),[l,p,e]}function G_(e,r){e.action=r}function cp(e){var r=St(),a=rt;if(a!==null)return lp(r,a,e);St(),r=r.memoizedState,a=St();var l=a.queue.dispatch;return a.memoizedState=e,[r,l,!1]}function ji(e,r,a,l){return e={tag:e,create:a,deps:l,inst:r,next:null},r=De.updateQueue,r===null&&(r=gl(),De.updateQueue=r),a=r.lastEffect,a===null?r.lastEffect=e.next=e:(l=a.next,a.next=e,e.next=l,r.lastEffect=e),e}function up(){return St().memoizedState}function vl(e,r,a,l){var f=Vt();De.flags|=e,f.memoizedState=ji(1|r,{destroy:void 0},a,l===void 0?null:l)}function _l(e,r,a,l){var f=St();l=l===void 0?null:l;var p=f.memoizedState.inst;rt!==null&&l!==null&&kf(l,rt.memoizedState.deps)?f.memoizedState=ji(r,p,a,l):(De.flags|=e,f.memoizedState=ji(1|r,p,a,l))}function fp(e,r){vl(8390656,8,e,r)}function Pf(e,r){_l(2048,8,e,r)}function V_(e){De.flags|=4;var r=De.updateQueue;if(r===null)r=gl(),De.updateQueue=r,r.events=[e];else{var a=r.events;a===null?r.events=[e]:a.push(e)}}function hp(e){var r=St().memoizedState;return V_({ref:r,nextImpl:e}),function(){if((Qe&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function dp(e,r){return _l(4,2,e,r)}function mp(e,r){return _l(4,4,e,r)}function pp(e,r){if(typeof r=="function"){e=e();var a=r(e);return function(){typeof a=="function"?a():r(null)}}if(r!=null)return e=e(),r.current=e,function(){r.current=null}}function yp(e,r,a){a=a!=null?a.concat([e]):null,_l(4,4,pp.bind(null,r,e),a)}function Uf(){}function gp(e,r){var a=St();r=r===void 0?null:r;var l=a.memoizedState;return r!==null&&kf(r,l[1])?l[0]:(a.memoizedState=[e,r],e)}function bp(e,r){var a=St();r=r===void 0?null:r;var l=a.memoizedState;if(r!==null&&kf(r,l[1]))return l[0];if(l=e(),Fs){cn(!0);try{e()}finally{cn(!1)}}return a.memoizedState=[l,r],l}function zf(e,r,a){return a===void 0||(xr&1073741824)!==0&&(ze&261930)===0?e.memoizedState=r:(e.memoizedState=a,e=xy(),De.lanes|=e,rs|=e,a)}function xp(e,r,a,l){return fn(a,r)?a:Ei.current!==null?(e=zf(e,a,l),fn(e,r)||(kt=!0),e):(xr&42)===0||(xr&1073741824)!==0&&(ze&261930)===0?(kt=!0,e.memoizedState=a):(e=xy(),De.lanes|=e,rs|=e,r)}function vp(e,r,a,l,f){var p=W.p;W.p=p!==0&&8>p?p:8;var _=H.T,O={};H.T=O,Hf(e,!1,r,a);try{var M=f(),G=H.S;if(G!==null&&G(O,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var Z=I_(M,l);Da(e,r,Z,gn(e))}else Da(e,r,l,gn(e))}catch(se){Da(e,r,{then:function(){},status:"rejected",reason:se},gn())}finally{W.p=p,_!==null&&O.types!==null&&(_.types=O.types),H.T=_}}function Y_(){}function If(e,r,a,l){if(e.tag!==5)throw Error(i(476));var f=_p(e).queue;vp(e,f,r,ce,a===null?Y_:function(){return wp(e),a(l)})}function _p(e){var r=e.memoizedState;if(r!==null)return r;r={memoizedState:ce,baseState:ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:ce},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},e.memoizedState=r,e=e.alternate,e!==null&&(e.memoizedState=r),r}function wp(e){var r=_p(e);r.next===null&&(r=e.alternate.memoizedState),Da(e,r.next.queue,{},gn())}function $f(){return zt(Qa)}function Sp(){return St().memoizedState}function Ep(){return St().memoizedState}function K_(e){for(var r=e.return;r!==null;){switch(r.tag){case 24:case 3:var a=gn();e=Qr(a);var l=Wr(r,e,a);l!==null&&(sn(l,r,a),Na(l,r,a)),r={cache:gf()},e.payload=r;return}r=r.return}}function J_(e,r,a){var l=gn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},wl(e)?Ap(r,a):(a=af(e,r,a,l),a!==null&&(sn(a,e,l),jp(a,r,l)))}function Op(e,r,a){var l=gn();Da(e,r,a,l)}function Da(e,r,a,l){var f={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(wl(e))Ap(r,f);else{var p=e.alternate;if(e.lanes===0&&(p===null||p.lanes===0)&&(p=r.lastRenderedReducer,p!==null))try{var _=r.lastRenderedState,O=p(_,a);if(f.hasEagerState=!0,f.eagerState=O,fn(O,_))return nl(e,r,f,0),ot===null&&tl(),!1}catch{}finally{}if(a=af(e,r,f,l),a!==null)return sn(a,e,l),jp(a,r,l),!0}return!1}function Hf(e,r,a,l){if(l={lane:2,revertLane:_h(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},wl(e)){if(r)throw Error(i(479))}else r=af(e,a,l,2),r!==null&&sn(r,e,2)}function wl(e){var r=e.alternate;return e===De||r!==null&&r===De}function Ap(e,r){Oi=pl=!0;var a=e.pending;a===null?r.next=r:(r.next=a.next,a.next=r),e.pending=r}function jp(e,r,a){if((a&4194048)!==0){var l=r.lanes;l&=e.pendingLanes,a|=l,r.lanes=a,Ns(e,a)}}var La={readContext:zt,use:bl,useCallback:bt,useContext:bt,useEffect:bt,useImperativeHandle:bt,useLayoutEffect:bt,useInsertionEffect:bt,useMemo:bt,useReducer:bt,useRef:bt,useState:bt,useDebugValue:bt,useDeferredValue:bt,useTransition:bt,useSyncExternalStore:bt,useId:bt,useHostTransitionStatus:bt,useFormState:bt,useActionState:bt,useOptimistic:bt,useMemoCache:bt,useCacheRefresh:bt};La.useEffectEvent=bt;var kp={readContext:zt,use:bl,useCallback:function(e,r){return Vt().memoizedState=[e,r===void 0?null:r],e},useContext:zt,useEffect:fp,useImperativeHandle:function(e,r,a){a=a!=null?a.concat([e]):null,vl(4194308,4,pp.bind(null,r,e),a)},useLayoutEffect:function(e,r){return vl(4194308,4,e,r)},useInsertionEffect:function(e,r){vl(4,2,e,r)},useMemo:function(e,r){var a=Vt();r=r===void 0?null:r;var l=e();if(Fs){cn(!0);try{e()}finally{cn(!1)}}return a.memoizedState=[l,r],l},useReducer:function(e,r,a){var l=Vt();if(a!==void 0){var f=a(r);if(Fs){cn(!0);try{a(r)}finally{cn(!1)}}}else f=r;return l.memoizedState=l.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},l.queue=e,e=e.dispatch=J_.bind(null,De,e),[l.memoizedState,e]},useRef:function(e){var r=Vt();return e={current:e},r.memoizedState=e},useState:function(e){e=qf(e);var r=e.queue,a=Op.bind(null,De,r);return r.dispatch=a,[e.memoizedState,a]},useDebugValue:Uf,useDeferredValue:function(e,r){var a=Vt();return zf(a,e,r)},useTransition:function(){var e=qf(!1);return e=vp.bind(null,De,e.queue,!0,!1),Vt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,r,a){var l=De,f=Vt();if(Fe){if(a===void 0)throw Error(i(407));a=a()}else{if(a=r(),ot===null)throw Error(i(349));(ze&127)!==0||J0(l,r,a)}f.memoizedState=a;var p={value:a,getSnapshot:r};return f.queue=p,fp(Q0.bind(null,l,p,e),[e]),l.flags|=2048,ji(9,{destroy:void 0},X0.bind(null,l,p,a,r),null),a},useId:function(){var e=Vt(),r=ot.identifierPrefix;if(Fe){var a=nr,l=tr;a=(l&~(1<<32-Ft(l)-1)).toString(32)+a,r="_"+r+"R_"+a,a=yl++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=$_++,r="_"+r+"r_"+a.toString(32)+"_";return e.memoizedState=r},useHostTransitionStatus:$f,useFormState:ap,useActionState:ap,useOptimistic:function(e){var r=Vt();r.memoizedState=r.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=Hf.bind(null,De,!0,a),a.dispatch=r,[e,r]},useMemoCache:Rf,useCacheRefresh:function(){return Vt().memoizedState=K_.bind(null,De)},useEffectEvent:function(e){var r=Vt(),a={impl:e};return r.memoizedState=a,function(){if((Qe&2)!==0)throw Error(i(440));return a.impl.apply(void 0,arguments)}}},Ff={readContext:zt,use:bl,useCallback:gp,useContext:zt,useEffect:Pf,useImperativeHandle:yp,useInsertionEffect:dp,useLayoutEffect:mp,useMemo:bp,useReducer:xl,useRef:up,useState:function(){return xl(vr)},useDebugValue:Uf,useDeferredValue:function(e,r){var a=St();return xp(a,rt.memoizedState,e,r)},useTransition:function(){var e=xl(vr)[0],r=St().memoizedState;return[typeof e=="boolean"?e:Ra(e),r]},useSyncExternalStore:K0,useId:Sp,useHostTransitionStatus:$f,useFormState:op,useActionState:op,useOptimistic:function(e,r){var a=St();return ep(a,rt,e,r)},useMemoCache:Rf,useCacheRefresh:Ep};Ff.useEffectEvent=hp;var Np={readContext:zt,use:bl,useCallback:gp,useContext:zt,useEffect:Pf,useImperativeHandle:yp,useInsertionEffect:dp,useLayoutEffect:mp,useMemo:bp,useReducer:Lf,useRef:up,useState:function(){return Lf(vr)},useDebugValue:Uf,useDeferredValue:function(e,r){var a=St();return rt===null?zf(a,e,r):xp(a,rt.memoizedState,e,r)},useTransition:function(){var e=Lf(vr)[0],r=St().memoizedState;return[typeof e=="boolean"?e:Ra(e),r]},useSyncExternalStore:K0,useId:Sp,useHostTransitionStatus:$f,useFormState:cp,useActionState:cp,useOptimistic:function(e,r){var a=St();return rt!==null?ep(a,rt,e,r):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Rf,useCacheRefresh:Ep};Np.useEffectEvent=hp;function Gf(e,r,a,l){r=e.memoizedState,a=a(l,r),a=a==null?r:b({},r,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Vf={enqueueSetState:function(e,r,a){e=e._reactInternals;var l=gn(),f=Qr(l);f.payload=r,a!=null&&(f.callback=a),r=Wr(e,f,l),r!==null&&(sn(r,e,l),Na(r,e,l))},enqueueReplaceState:function(e,r,a){e=e._reactInternals;var l=gn(),f=Qr(l);f.tag=1,f.payload=r,a!=null&&(f.callback=a),r=Wr(e,f,l),r!==null&&(sn(r,e,l),Na(r,e,l))},enqueueForceUpdate:function(e,r){e=e._reactInternals;var a=gn(),l=Qr(a);l.tag=2,r!=null&&(l.callback=r),r=Wr(e,l,a),r!==null&&(sn(r,e,a),Na(r,e,a))}};function Tp(e,r,a,l,f,p,_){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,p,_):r.prototype&&r.prototype.isPureReactComponent?!_a(a,l)||!_a(f,p):!0}function Cp(e,r,a,l){e=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,l),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,l),r.state!==e&&Vf.enqueueReplaceState(r,r.state,null)}function Gs(e,r){var a=r;if("ref"in r){a={};for(var l in r)l!=="ref"&&(a[l]=r[l])}if(e=e.defaultProps){a===r&&(a=b({},a));for(var f in e)a[f]===void 0&&(a[f]=e[f])}return a}function Mp(e){el(e)}function Rp(e){console.error(e)}function Dp(e){el(e)}function Sl(e,r){try{var a=e.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(l){setTimeout(function(){throw l})}}function Lp(e,r,a){try{var l=e.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function Yf(e,r,a){return a=Qr(a),a.tag=3,a.payload={element:null},a.callback=function(){Sl(e,r)},a}function qp(e){return e=Qr(e),e.tag=3,e}function Bp(e,r,a,l){var f=a.type.getDerivedStateFromError;if(typeof f=="function"){var p=l.value;e.payload=function(){return f(p)},e.callback=function(){Lp(r,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(e.callback=function(){Lp(r,a,l),typeof f!="function"&&(ss===null?ss=new Set([this]):ss.add(this));var O=l.stack;this.componentDidCatch(l.value,{componentStack:O!==null?O:""})})}function X_(e,r,a,l,f){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(r=a.alternate,r!==null&&xi(r,a,f,!0),a=dn.current,a!==null){switch(a.tag){case 31:case 13:return qn===null?Ll():a.alternate===null&&xt===0&&(xt=3),a.flags&=-257,a.flags|=65536,a.lanes=f,l===ul?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([l]):r.add(l),bh(e,l,f)),!1;case 22:return a.flags|=65536,l===ul?a.flags|=16384:(r=a.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=r):(a=r.retryQueue,a===null?r.retryQueue=new Set([l]):a.add(l)),bh(e,l,f)),!1}throw Error(i(435,a.tag))}return bh(e,l,f),Ll(),!1}if(Fe)return r=dn.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=f,l!==hf&&(e=Error(i(422),{cause:l}),Ea(Mn(e,a)))):(l!==hf&&(r=Error(i(423),{cause:l}),Ea(Mn(r,a))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,l=Mn(l,a),f=Yf(e.stateNode,l,f),Sf(e,f),xt!==4&&(xt=2)),!1;var p=Error(i(520),{cause:l});if(p=Mn(p,a),Ha===null?Ha=[p]:Ha.push(p),xt!==4&&(xt=2),r===null)return!0;l=Mn(l,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,e=f&-f,a.lanes|=e,e=Yf(a.stateNode,l,e),Sf(a,e),!1;case 1:if(r=a.type,p=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||p!==null&&typeof p.componentDidCatch=="function"&&(ss===null||!ss.has(p))))return a.flags|=65536,f&=-f,a.lanes|=f,f=qp(f),Bp(f,e,a,l),Sf(a,f),!1}a=a.return}while(a!==null);return!1}var Kf=Error(i(461)),kt=!1;function It(e,r,a,l){r.child=e===null?I0(r,null,a,l):Hs(r,e.child,a,l)}function Pp(e,r,a,l,f){a=a.render;var p=r.ref;if("ref"in l){var _={};for(var O in l)O!=="ref"&&(_[O]=l[O])}else _=l;return Us(r),l=Nf(e,r,a,_,p,f),O=Tf(),e!==null&&!kt?(Cf(e,r,f),_r(e,r,f)):(Fe&&O&&uf(r),r.flags|=1,It(e,r,l,f),r.child)}function Up(e,r,a,l,f){if(e===null){var p=a.type;return typeof p=="function"&&!of(p)&&p.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=p,zp(e,r,p,l,f)):(e=sl(a.type,null,l,r,r.mode,f),e.ref=r.ref,e.return=r,r.child=e)}if(p=e.child,!nh(e,f)){var _=p.memoizedProps;if(a=a.compare,a=a!==null?a:_a,a(_,l)&&e.ref===r.ref)return _r(e,r,f)}return r.flags|=1,e=pr(p,l),e.ref=r.ref,e.return=r,r.child=e}function zp(e,r,a,l,f){if(e!==null){var p=e.memoizedProps;if(_a(p,l)&&e.ref===r.ref)if(kt=!1,r.pendingProps=l=p,nh(e,f))(e.flags&131072)!==0&&(kt=!0);else return r.lanes=e.lanes,_r(e,r,f)}return Jf(e,r,a,l,f)}function Ip(e,r,a,l){var f=l.children,p=e!==null?e.memoizedState:null;if(e===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((r.flags&128)!==0){if(p=p!==null?p.baseLanes|a:a,e!==null){for(l=r.child=e.child,f=0;l!==null;)f=f|l.lanes|l.childLanes,l=l.sibling;l=f&~p}else l=0,r.child=null;return $p(e,r,p,a,l)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},e!==null&&ll(r,p!==null?p.cachePool:null),p!==null?F0(r,p):Of(),G0(r);else return l=r.lanes=536870912,$p(e,r,p!==null?p.baseLanes|a:a,a,l)}else p!==null?(ll(r,p.cachePool),F0(r,p),es(),r.memoizedState=null):(e!==null&&ll(r,null),Of(),es());return It(e,r,f,a),r.child}function qa(e,r){return e!==null&&e.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function $p(e,r,a,l,f){var p=xf();return p=p===null?null:{parent:At._currentValue,pool:p},r.memoizedState={baseLanes:a,cachePool:p},e!==null&&ll(r,null),Of(),G0(r),e!==null&&xi(e,r,l,!0),r.childLanes=f,null}function El(e,r){return r=Al({mode:r.mode,children:r.children},e.mode),r.ref=e.ref,e.child=r,r.return=e,r}function Hp(e,r,a){return Hs(r,e.child,null,a),e=El(r,r.pendingProps),e.flags|=2,mn(r),r.memoizedState=null,e}function Q_(e,r,a){var l=r.pendingProps,f=(r.flags&128)!==0;if(r.flags&=-129,e===null){if(Fe){if(l.mode==="hidden")return e=El(r,l),r.lanes=536870912,qa(null,e);if(jf(r),(e=ct)?(e=tg(e,Ln),e=e!==null&&e.data==="&"?e:null,e!==null&&(r.memoizedState={dehydrated:e,treeContext:Vr!==null?{id:tr,overflow:nr}:null,retryLane:536870912,hydrationErrors:null},a=A0(e),a.return=r,r.child=a,Ut=r,ct=null)):e=null,e===null)throw Kr(r);return r.lanes=536870912,null}return El(r,l)}var p=e.memoizedState;if(p!==null){var _=p.dehydrated;if(jf(r),f)if(r.flags&256)r.flags&=-257,r=Hp(e,r,a);else if(r.memoizedState!==null)r.child=e.child,r.flags|=128,r=null;else throw Error(i(558));else if(kt||xi(e,r,a,!1),f=(a&e.childLanes)!==0,kt||f){if(l=ot,l!==null&&(_=Fr(l,a),_!==0&&_!==p.retryLane))throw p.retryLane=_,Ls(e,_),sn(l,e,_),Kf;Ll(),r=Hp(e,r,a)}else e=p.treeContext,ct=Bn(_.nextSibling),Ut=r,Fe=!0,Yr=null,Ln=!1,e!==null&&N0(r,e),r=El(r,l),r.flags|=4096;return r}return e=pr(e.child,{mode:l.mode,children:l.children}),e.ref=r.ref,r.child=e,e.return=r,e}function Ol(e,r){var a=r.ref;if(a===null)e!==null&&e.ref!==null&&(r.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(i(284));(e===null||e.ref!==a)&&(r.flags|=4194816)}}function Jf(e,r,a,l,f){return Us(r),a=Nf(e,r,a,l,void 0,f),l=Tf(),e!==null&&!kt?(Cf(e,r,f),_r(e,r,f)):(Fe&&l&&uf(r),r.flags|=1,It(e,r,a,f),r.child)}function Fp(e,r,a,l,f,p){return Us(r),r.updateQueue=null,a=Y0(r,l,a,f),V0(e),l=Tf(),e!==null&&!kt?(Cf(e,r,p),_r(e,r,p)):(Fe&&l&&uf(r),r.flags|=1,It(e,r,a,p),r.child)}function Gp(e,r,a,l,f){if(Us(r),r.stateNode===null){var p=pi,_=a.contextType;typeof _=="object"&&_!==null&&(p=zt(_)),p=new a(l,p),r.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,p.updater=Vf,r.stateNode=p,p._reactInternals=r,p=r.stateNode,p.props=l,p.state=r.memoizedState,p.refs={},_f(r),_=a.contextType,p.context=typeof _=="object"&&_!==null?zt(_):pi,p.state=r.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Gf(r,a,_,l),p.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(_=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),_!==p.state&&Vf.enqueueReplaceState(p,p.state,null),Ca(r,l,p,f),Ta(),p.state=r.memoizedState),typeof p.componentDidMount=="function"&&(r.flags|=4194308),l=!0}else if(e===null){p=r.stateNode;var O=r.memoizedProps,M=Gs(a,O);p.props=M;var G=p.context,Z=a.contextType;_=pi,typeof Z=="object"&&Z!==null&&(_=zt(Z));var se=a.getDerivedStateFromProps;Z=typeof se=="function"||typeof p.getSnapshotBeforeUpdate=="function",O=r.pendingProps!==O,Z||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(O||G!==_)&&Cp(r,p,l,_),Xr=!1;var Y=r.memoizedState;p.state=Y,Ca(r,l,p,f),Ta(),G=r.memoizedState,O||Y!==G||Xr?(typeof se=="function"&&(Gf(r,a,se,l),G=r.memoizedState),(M=Xr||Tp(r,a,M,l,Y,G,_))?(Z||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount()),typeof p.componentDidMount=="function"&&(r.flags|=4194308)):(typeof p.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=l,r.memoizedState=G),p.props=l,p.state=G,p.context=_,l=M):(typeof p.componentDidMount=="function"&&(r.flags|=4194308),l=!1)}else{p=r.stateNode,wf(e,r),_=r.memoizedProps,Z=Gs(a,_),p.props=Z,se=r.pendingProps,Y=p.context,G=a.contextType,M=pi,typeof G=="object"&&G!==null&&(M=zt(G)),O=a.getDerivedStateFromProps,(G=typeof O=="function"||typeof p.getSnapshotBeforeUpdate=="function")||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(_!==se||Y!==M)&&Cp(r,p,l,M),Xr=!1,Y=r.memoizedState,p.state=Y,Ca(r,l,p,f),Ta();var J=r.memoizedState;_!==se||Y!==J||Xr||e!==null&&e.dependencies!==null&&al(e.dependencies)?(typeof O=="function"&&(Gf(r,a,O,l),J=r.memoizedState),(Z=Xr||Tp(r,a,Z,l,Y,J,M)||e!==null&&e.dependencies!==null&&al(e.dependencies))?(G||typeof p.UNSAFE_componentWillUpdate!="function"&&typeof p.componentWillUpdate!="function"||(typeof p.componentWillUpdate=="function"&&p.componentWillUpdate(l,J,M),typeof p.UNSAFE_componentWillUpdate=="function"&&p.UNSAFE_componentWillUpdate(l,J,M)),typeof p.componentDidUpdate=="function"&&(r.flags|=4),typeof p.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof p.componentDidUpdate!="function"||_===e.memoizedProps&&Y===e.memoizedState||(r.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||_===e.memoizedProps&&Y===e.memoizedState||(r.flags|=1024),r.memoizedProps=l,r.memoizedState=J),p.props=l,p.state=J,p.context=M,l=Z):(typeof p.componentDidUpdate!="function"||_===e.memoizedProps&&Y===e.memoizedState||(r.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||_===e.memoizedProps&&Y===e.memoizedState||(r.flags|=1024),l=!1)}return p=l,Ol(e,r),l=(r.flags&128)!==0,p||l?(p=r.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:p.render(),r.flags|=1,e!==null&&l?(r.child=Hs(r,e.child,null,f),r.child=Hs(r,null,a,f)):It(e,r,a,f),r.memoizedState=p.state,e=r.child):e=_r(e,r,f),e}function Vp(e,r,a,l){return Bs(),r.flags|=256,It(e,r,a,l),r.child}var Xf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Qf(e){return{baseLanes:e,cachePool:L0()}}function Wf(e,r,a){return e=e!==null?e.childLanes&~a:0,r&&(e|=yn),e}function Yp(e,r,a){var l=r.pendingProps,f=!1,p=(r.flags&128)!==0,_;if((_=p)||(_=e!==null&&e.memoizedState===null?!1:(wt.current&2)!==0),_&&(f=!0,r.flags&=-129),_=(r.flags&32)!==0,r.flags&=-33,e===null){if(Fe){if(f?Zr(r):es(),(e=ct)?(e=tg(e,Ln),e=e!==null&&e.data!=="&"?e:null,e!==null&&(r.memoizedState={dehydrated:e,treeContext:Vr!==null?{id:tr,overflow:nr}:null,retryLane:536870912,hydrationErrors:null},a=A0(e),a.return=r,r.child=a,Ut=r,ct=null)):e=null,e===null)throw Kr(r);return Dh(e)?r.lanes=32:r.lanes=536870912,null}var O=l.children;return l=l.fallback,f?(es(),f=r.mode,O=Al({mode:"hidden",children:O},f),l=qs(l,f,a,null),O.return=r,l.return=r,O.sibling=l,r.child=O,l=r.child,l.memoizedState=Qf(a),l.childLanes=Wf(e,_,a),r.memoizedState=Xf,qa(null,l)):(Zr(r),Zf(r,O))}var M=e.memoizedState;if(M!==null&&(O=M.dehydrated,O!==null)){if(p)r.flags&256?(Zr(r),r.flags&=-257,r=eh(e,r,a)):r.memoizedState!==null?(es(),r.child=e.child,r.flags|=128,r=null):(es(),O=l.fallback,f=r.mode,l=Al({mode:"visible",children:l.children},f),O=qs(O,f,a,null),O.flags|=2,l.return=r,O.return=r,l.sibling=O,r.child=l,Hs(r,e.child,null,a),l=r.child,l.memoizedState=Qf(a),l.childLanes=Wf(e,_,a),r.memoizedState=Xf,r=qa(null,l));else if(Zr(r),Dh(O)){if(_=O.nextSibling&&O.nextSibling.dataset,_)var G=_.dgst;_=G,l=Error(i(419)),l.stack="",l.digest=_,Ea({value:l,source:null,stack:null}),r=eh(e,r,a)}else if(kt||xi(e,r,a,!1),_=(a&e.childLanes)!==0,kt||_){if(_=ot,_!==null&&(l=Fr(_,a),l!==0&&l!==M.retryLane))throw M.retryLane=l,Ls(e,l),sn(_,e,l),Kf;Rh(O)||Ll(),r=eh(e,r,a)}else Rh(O)?(r.flags|=192,r.child=e.child,r=null):(e=M.treeContext,ct=Bn(O.nextSibling),Ut=r,Fe=!0,Yr=null,Ln=!1,e!==null&&N0(r,e),r=Zf(r,l.children),r.flags|=4096);return r}return f?(es(),O=l.fallback,f=r.mode,M=e.child,G=M.sibling,l=pr(M,{mode:"hidden",children:l.children}),l.subtreeFlags=M.subtreeFlags&65011712,G!==null?O=pr(G,O):(O=qs(O,f,a,null),O.flags|=2),O.return=r,l.return=r,l.sibling=O,r.child=l,qa(null,l),l=r.child,O=e.child.memoizedState,O===null?O=Qf(a):(f=O.cachePool,f!==null?(M=At._currentValue,f=f.parent!==M?{parent:M,pool:M}:f):f=L0(),O={baseLanes:O.baseLanes|a,cachePool:f}),l.memoizedState=O,l.childLanes=Wf(e,_,a),r.memoizedState=Xf,qa(e.child,l)):(Zr(r),a=e.child,e=a.sibling,a=pr(a,{mode:"visible",children:l.children}),a.return=r,a.sibling=null,e!==null&&(_=r.deletions,_===null?(r.deletions=[e],r.flags|=16):_.push(e)),r.child=a,r.memoizedState=null,a)}function Zf(e,r){return r=Al({mode:"visible",children:r},e.mode),r.return=e,e.child=r}function Al(e,r){return e=hn(22,e,null,r),e.lanes=0,e}function eh(e,r,a){return Hs(r,e.child,null,a),e=Zf(r,r.pendingProps.children),e.flags|=2,r.memoizedState=null,e}function Kp(e,r,a){e.lanes|=r;var l=e.alternate;l!==null&&(l.lanes|=r),pf(e.return,r,a)}function th(e,r,a,l,f,p){var _=e.memoizedState;_===null?e.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:f,treeForkCount:p}:(_.isBackwards=r,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=f,_.treeForkCount=p)}function Jp(e,r,a){var l=r.pendingProps,f=l.revealOrder,p=l.tail;l=l.children;var _=wt.current,O=(_&2)!==0;if(O?(_=_&1|2,r.flags|=128):_&=1,Me(wt,_),It(e,r,l,a),l=Fe?Sa:0,!O&&e!==null&&(e.flags&128)!==0)e:for(e=r.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Kp(e,a,r);else if(e.tag===19)Kp(e,a,r);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===r)break e;for(;e.sibling===null;){if(e.return===null||e.return===r)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(a=r.child,f=null;a!==null;)e=a.alternate,e!==null&&ml(e)===null&&(f=a),a=a.sibling;a=f,a===null?(f=r.child,r.child=null):(f=a.sibling,a.sibling=null),th(r,!1,f,a,p,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,f=r.child,r.child=null;f!==null;){if(e=f.alternate,e!==null&&ml(e)===null){r.child=f;break}e=f.sibling,f.sibling=a,a=f,f=e}th(r,!0,a,null,p,l);break;case"together":th(r,!1,null,null,void 0,l);break;default:r.memoizedState=null}return r.child}function _r(e,r,a){if(e!==null&&(r.dependencies=e.dependencies),rs|=r.lanes,(a&r.childLanes)===0)if(e!==null){if(xi(e,r,a,!1),(a&r.childLanes)===0)return null}else return null;if(e!==null&&r.child!==e.child)throw Error(i(153));if(r.child!==null){for(e=r.child,a=pr(e,e.pendingProps),r.child=a,a.return=r;e.sibling!==null;)e=e.sibling,a=a.sibling=pr(e,e.pendingProps),a.return=r;a.sibling=null}return r.child}function nh(e,r){return(e.lanes&r)!==0?!0:(e=e.dependencies,!!(e!==null&&al(e)))}function W_(e,r,a){switch(r.tag){case 3:Re(r,r.stateNode.containerInfo),Jr(r,At,e.memoizedState.cache),Bs();break;case 27:case 5:Be(r);break;case 4:Re(r,r.stateNode.containerInfo);break;case 10:Jr(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,jf(r),null;break;case 13:var l=r.memoizedState;if(l!==null)return l.dehydrated!==null?(Zr(r),r.flags|=128,null):(a&r.child.childLanes)!==0?Yp(e,r,a):(Zr(r),e=_r(e,r,a),e!==null?e.sibling:null);Zr(r);break;case 19:var f=(e.flags&128)!==0;if(l=(a&r.childLanes)!==0,l||(xi(e,r,a,!1),l=(a&r.childLanes)!==0),f){if(l)return Jp(e,r,a);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Me(wt,wt.current),l)break;return null;case 22:return r.lanes=0,Ip(e,r,a,r.pendingProps);case 24:Jr(r,At,e.memoizedState.cache)}return _r(e,r,a)}function Xp(e,r,a){if(e!==null)if(e.memoizedProps!==r.pendingProps)kt=!0;else{if(!nh(e,a)&&(r.flags&128)===0)return kt=!1,W_(e,r,a);kt=(e.flags&131072)!==0}else kt=!1,Fe&&(r.flags&1048576)!==0&&k0(r,Sa,r.index);switch(r.lanes=0,r.tag){case 16:e:{var l=r.pendingProps;if(e=Is(r.elementType),r.type=e,typeof e=="function")of(e)?(l=Gs(e,l),r.tag=1,r=Gp(null,r,e,l,a)):(r.tag=0,r=Jf(null,r,e,l,a));else{if(e!=null){var f=e.$$typeof;if(f===le){r.tag=11,r=Pp(null,r,e,l,a);break e}else if(f===ne){r.tag=14,r=Up(null,r,e,l,a);break e}}throw r=Se(e)||e,Error(i(306,r,""))}}return r;case 0:return Jf(e,r,r.type,r.pendingProps,a);case 1:return l=r.type,f=Gs(l,r.pendingProps),Gp(e,r,l,f,a);case 3:e:{if(Re(r,r.stateNode.containerInfo),e===null)throw Error(i(387));l=r.pendingProps;var p=r.memoizedState;f=p.element,wf(e,r),Ca(r,l,null,a);var _=r.memoizedState;if(l=_.cache,Jr(r,At,l),l!==p.cache&&yf(r,[At],a,!0),Ta(),l=_.element,p.isDehydrated)if(p={element:l,isDehydrated:!1,cache:_.cache},r.updateQueue.baseState=p,r.memoizedState=p,r.flags&256){r=Vp(e,r,l,a);break e}else if(l!==f){f=Mn(Error(i(424)),r),Ea(f),r=Vp(e,r,l,a);break e}else{switch(e=r.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(ct=Bn(e.firstChild),Ut=r,Fe=!0,Yr=null,Ln=!0,a=I0(r,null,l,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Bs(),l===f){r=_r(e,r,a);break e}It(e,r,l,a)}r=r.child}return r;case 26:return Ol(e,r),e===null?(a=og(r.type,null,r.pendingProps,null))?r.memoizedState=a:Fe||(a=r.type,e=r.pendingProps,l=$l(Ct.current).createElement(a),l[at]=r,l[gt]=e,$t(l,a,e),L(l),r.stateNode=l):r.memoizedState=og(r.type,e.memoizedProps,r.pendingProps,e.memoizedState),null;case 27:return Be(r),e===null&&Fe&&(l=r.stateNode=sg(r.type,r.pendingProps,Ct.current),Ut=r,Ln=!0,f=ct,ls(r.type)?(Lh=f,ct=Bn(l.firstChild)):ct=f),It(e,r,r.pendingProps.children,a),Ol(e,r),e===null&&(r.flags|=4194304),r.child;case 5:return e===null&&Fe&&((f=l=ct)&&(l=kw(l,r.type,r.pendingProps,Ln),l!==null?(r.stateNode=l,Ut=r,ct=Bn(l.firstChild),Ln=!1,f=!0):f=!1),f||Kr(r)),Be(r),f=r.type,p=r.pendingProps,_=e!==null?e.memoizedProps:null,l=p.children,Th(f,p)?l=null:_!==null&&Th(f,_)&&(r.flags|=32),r.memoizedState!==null&&(f=Nf(e,r,H_,null,null,a),Qa._currentValue=f),Ol(e,r),It(e,r,l,a),r.child;case 6:return e===null&&Fe&&((e=a=ct)&&(a=Nw(a,r.pendingProps,Ln),a!==null?(r.stateNode=a,Ut=r,ct=null,e=!0):e=!1),e||Kr(r)),null;case 13:return Yp(e,r,a);case 4:return Re(r,r.stateNode.containerInfo),l=r.pendingProps,e===null?r.child=Hs(r,null,l,a):It(e,r,l,a),r.child;case 11:return Pp(e,r,r.type,r.pendingProps,a);case 7:return It(e,r,r.pendingProps,a),r.child;case 8:return It(e,r,r.pendingProps.children,a),r.child;case 12:return It(e,r,r.pendingProps.children,a),r.child;case 10:return l=r.pendingProps,Jr(r,r.type,l.value),It(e,r,l.children,a),r.child;case 9:return f=r.type._context,l=r.pendingProps.children,Us(r),f=zt(f),l=l(f),r.flags|=1,It(e,r,l,a),r.child;case 14:return Up(e,r,r.type,r.pendingProps,a);case 15:return zp(e,r,r.type,r.pendingProps,a);case 19:return Jp(e,r,a);case 31:return Q_(e,r,a);case 22:return Ip(e,r,a,r.pendingProps);case 24:return Us(r),l=zt(At),e===null?(f=xf(),f===null&&(f=ot,p=gf(),f.pooledCache=p,p.refCount++,p!==null&&(f.pooledCacheLanes|=a),f=p),r.memoizedState={parent:l,cache:f},_f(r),Jr(r,At,f)):((e.lanes&a)!==0&&(wf(e,r),Ca(r,null,null,a),Ta()),f=e.memoizedState,p=r.memoizedState,f.parent!==l?(f={parent:l,cache:l},r.memoizedState=f,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=f),Jr(r,At,l)):(l=p.cache,Jr(r,At,l),l!==f.cache&&yf(r,[At],a,!0))),It(e,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function wr(e){e.flags|=4}function rh(e,r,a,l,f){if((r=(e.mode&32)!==0)&&(r=!1),r){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(Sy())e.flags|=8192;else throw $s=ul,vf}else e.flags&=-16777217}function Qp(e,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!hg(r))if(Sy())e.flags|=8192;else throw $s=ul,vf}function jl(e,r){r!==null&&(e.flags|=4),e.flags&16384&&(r=e.tag!==22?ii():536870912,e.lanes|=r,Ci|=r)}function Ba(e,r){if(!Fe)switch(e.tailMode){case"hidden":r=e.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?r||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function ut(e){var r=e.alternate!==null&&e.alternate.child===e.child,a=0,l=0;if(r)for(var f=e.child;f!==null;)a|=f.lanes|f.childLanes,l|=f.subtreeFlags&65011712,l|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)a|=f.lanes|f.childLanes,l|=f.subtreeFlags,l|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=l,e.childLanes=a,r}function Z_(e,r,a){var l=r.pendingProps;switch(ff(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ut(r),null;case 1:return ut(r),null;case 3:return a=r.stateNode,l=null,e!==null&&(l=e.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),br(At),oe(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(bi(r)?wr(r):e===null||e.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,df())),ut(r),null;case 26:var f=r.type,p=r.memoizedState;return e===null?(wr(r),p!==null?(ut(r),Qp(r,p)):(ut(r),rh(r,f,null,l,a))):p?p!==e.memoizedState?(wr(r),ut(r),Qp(r,p)):(ut(r),r.flags&=-16777217):(e=e.memoizedProps,e!==l&&wr(r),ut(r),rh(r,f,e,l,a)),null;case 27:if(We(r),a=Ct.current,f=r.type,e!==null&&r.stateNode!=null)e.memoizedProps!==l&&wr(r);else{if(!l){if(r.stateNode===null)throw Error(i(166));return ut(r),null}e=Ze.current,bi(r)?T0(r):(e=sg(f,l,a),r.stateNode=e,wr(r))}return ut(r),null;case 5:if(We(r),f=r.type,e!==null&&r.stateNode!=null)e.memoizedProps!==l&&wr(r);else{if(!l){if(r.stateNode===null)throw Error(i(166));return ut(r),null}if(p=Ze.current,bi(r))T0(r);else{var _=$l(Ct.current);switch(p){case 1:p=_.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:p=_.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":p=_.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":p=_.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":p=_.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild);break;case"select":p=typeof l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?p.multiple=!0:l.size&&(p.size=l.size);break;default:p=typeof l.is=="string"?_.createElement(f,{is:l.is}):_.createElement(f)}}p[at]=r,p[gt]=l;e:for(_=r.child;_!==null;){if(_.tag===5||_.tag===6)p.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===r)break e;for(;_.sibling===null;){if(_.return===null||_.return===r)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}r.stateNode=p;e:switch($t(p,f,l),f){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&wr(r)}}return ut(r),rh(r,r.type,e===null?null:e.memoizedProps,r.pendingProps,a),null;case 6:if(e&&r.stateNode!=null)e.memoizedProps!==l&&wr(r);else{if(typeof l!="string"&&r.stateNode===null)throw Error(i(166));if(e=Ct.current,bi(r)){if(e=r.stateNode,a=r.memoizedProps,l=null,f=Ut,f!==null)switch(f.tag){case 27:case 5:l=f.memoizedProps}e[at]=r,e=!!(e.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Yy(e.nodeValue,a)),e||Kr(r,!0)}else e=$l(e).createTextNode(l),e[at]=r,r.stateNode=e}return ut(r),null;case 31:if(a=r.memoizedState,e===null||e.memoizedState!==null){if(l=bi(r),a!==null){if(e===null){if(!l)throw Error(i(318));if(e=r.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(557));e[at]=r}else Bs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ut(r),e=!1}else a=df(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return r.flags&256?(mn(r),r):(mn(r),null);if((r.flags&128)!==0)throw Error(i(558))}return ut(r),null;case 13:if(l=r.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=bi(r),l!==null&&l.dehydrated!==null){if(e===null){if(!f)throw Error(i(318));if(f=r.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(i(317));f[at]=r}else Bs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ut(r),f=!1}else f=df(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return r.flags&256?(mn(r),r):(mn(r),null)}return mn(r),(r.flags&128)!==0?(r.lanes=a,r):(a=l!==null,e=e!==null&&e.memoizedState!==null,a&&(l=r.child,f=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(f=l.alternate.memoizedState.cachePool.pool),p=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),p!==f&&(l.flags|=2048)),a!==e&&a&&(r.child.flags|=8192),jl(r,r.updateQueue),ut(r),null);case 4:return oe(),e===null&&Oh(r.stateNode.containerInfo),ut(r),null;case 10:return br(r.type),ut(r),null;case 19:if(Ne(wt),l=r.memoizedState,l===null)return ut(r),null;if(f=(r.flags&128)!==0,p=l.rendering,p===null)if(f)Ba(l,!1);else{if(xt!==0||e!==null&&(e.flags&128)!==0)for(e=r.child;e!==null;){if(p=ml(e),p!==null){for(r.flags|=128,Ba(l,!1),e=p.updateQueue,r.updateQueue=e,jl(r,e),r.subtreeFlags=0,e=a,a=r.child;a!==null;)O0(a,e),a=a.sibling;return Me(wt,wt.current&1|2),Fe&&yr(r,l.treeForkCount),r.child}e=e.sibling}l.tail!==null&&ht()>Ml&&(r.flags|=128,f=!0,Ba(l,!1),r.lanes=4194304)}else{if(!f)if(e=ml(p),e!==null){if(r.flags|=128,f=!0,e=e.updateQueue,r.updateQueue=e,jl(r,e),Ba(l,!0),l.tail===null&&l.tailMode==="hidden"&&!p.alternate&&!Fe)return ut(r),null}else 2*ht()-l.renderingStartTime>Ml&&a!==536870912&&(r.flags|=128,f=!0,Ba(l,!1),r.lanes=4194304);l.isBackwards?(p.sibling=r.child,r.child=p):(e=l.last,e!==null?e.sibling=p:r.child=p,l.last=p)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=ht(),e.sibling=null,a=wt.current,Me(wt,f?a&1|2:a&1),Fe&&yr(r,l.treeForkCount),e):(ut(r),null);case 22:case 23:return mn(r),Af(),l=r.memoizedState!==null,e!==null?e.memoizedState!==null!==l&&(r.flags|=8192):l&&(r.flags|=8192),l?(a&536870912)!==0&&(r.flags&128)===0&&(ut(r),r.subtreeFlags&6&&(r.flags|=8192)):ut(r),a=r.updateQueue,a!==null&&jl(r,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),l=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(l=r.memoizedState.cachePool.pool),l!==a&&(r.flags|=2048),e!==null&&Ne(zs),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),br(At),ut(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function ew(e,r){switch(ff(r),r.tag){case 1:return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 3:return br(At),oe(),e=r.flags,(e&65536)!==0&&(e&128)===0?(r.flags=e&-65537|128,r):null;case 26:case 27:case 5:return We(r),null;case 31:if(r.memoizedState!==null){if(mn(r),r.alternate===null)throw Error(i(340));Bs()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 13:if(mn(r),e=r.memoizedState,e!==null&&e.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Bs()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 19:return Ne(wt),null;case 4:return oe(),null;case 10:return br(r.type),null;case 22:case 23:return mn(r),Af(),e!==null&&Ne(zs),e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 24:return br(At),null;case 25:return null;default:return null}}function Wp(e,r){switch(ff(r),r.tag){case 3:br(At),oe();break;case 26:case 27:case 5:We(r);break;case 4:oe();break;case 31:r.memoizedState!==null&&mn(r);break;case 13:mn(r);break;case 19:Ne(wt);break;case 10:br(r.type);break;case 22:case 23:mn(r),Af(),e!==null&&Ne(zs);break;case 24:br(At)}}function Pa(e,r){try{var a=r.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var f=l.next;a=f;do{if((a.tag&e)===e){l=void 0;var p=a.create,_=a.inst;l=p(),_.destroy=l}a=a.next}while(a!==f)}}catch(O){tt(r,r.return,O)}}function ts(e,r,a){try{var l=r.updateQueue,f=l!==null?l.lastEffect:null;if(f!==null){var p=f.next;l=p;do{if((l.tag&e)===e){var _=l.inst,O=_.destroy;if(O!==void 0){_.destroy=void 0,f=r;var M=a,G=O;try{G()}catch(Z){tt(f,M,Z)}}}l=l.next}while(l!==p)}}catch(Z){tt(r,r.return,Z)}}function Zp(e){var r=e.updateQueue;if(r!==null){var a=e.stateNode;try{H0(r,a)}catch(l){tt(e,e.return,l)}}}function ey(e,r,a){a.props=Gs(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(l){tt(e,r,l)}}function Ua(e,r){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var l=e.stateNode;break;case 30:l=e.stateNode;break;default:l=e.stateNode}typeof a=="function"?e.refCleanup=a(l):a.current=l}}catch(f){tt(e,r,f)}}function rr(e,r){var a=e.ref,l=e.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(f){tt(e,r,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(f){tt(e,r,f)}else a.current=null}function ty(e){var r=e.type,a=e.memoizedProps,l=e.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(f){tt(e,e.return,f)}}function sh(e,r,a){try{var l=e.stateNode;ww(l,e.type,a,r),l[gt]=r}catch(f){tt(e,e.return,f)}}function ny(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ls(e.type)||e.tag===4}function ih(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ny(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&ls(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ah(e,r,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,r?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,r):(r=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,r.appendChild(e),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=dr));else if(l!==4&&(l===27&&ls(e.type)&&(a=e.stateNode,r=null),e=e.child,e!==null))for(ah(e,r,a),e=e.sibling;e!==null;)ah(e,r,a),e=e.sibling}function kl(e,r,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,r?a.insertBefore(e,r):a.appendChild(e);else if(l!==4&&(l===27&&ls(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(kl(e,r,a),e=e.sibling;e!==null;)kl(e,r,a),e=e.sibling}function ry(e){var r=e.stateNode,a=e.memoizedProps;try{for(var l=e.type,f=r.attributes;f.length;)r.removeAttributeNode(f[0]);$t(r,l,a),r[at]=e,r[gt]=a}catch(p){tt(e,e.return,p)}}var Sr=!1,Nt=!1,oh=!1,sy=typeof WeakSet=="function"?WeakSet:Set,Lt=null;function tw(e,r){if(e=e.containerInfo,kh=Jl,e=y0(e),Zu(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var f=l.anchorOffset,p=l.focusNode;l=l.focusOffset;try{a.nodeType,p.nodeType}catch{a=null;break e}var _=0,O=-1,M=-1,G=0,Z=0,se=e,Y=null;t:for(;;){for(var J;se!==a||f!==0&&se.nodeType!==3||(O=_+f),se!==p||l!==0&&se.nodeType!==3||(M=_+l),se.nodeType===3&&(_+=se.nodeValue.length),(J=se.firstChild)!==null;)Y=se,se=J;for(;;){if(se===e)break t;if(Y===a&&++G===f&&(O=_),Y===p&&++Z===l&&(M=_),(J=se.nextSibling)!==null)break;se=Y,Y=se.parentNode}se=J}a=O===-1||M===-1?null:{start:O,end:M}}else a=null}a=a||{start:0,end:0}}else a=null;for(Nh={focusedElem:e,selectionRange:a},Jl=!1,Lt=r;Lt!==null;)if(r=Lt,e=r.child,(r.subtreeFlags&1028)!==0&&e!==null)e.return=r,Lt=e;else for(;Lt!==null;){switch(r=Lt,p=r.alternate,e=r.flags,r.tag){case 0:if((e&4)!==0&&(e=r.updateQueue,e=e!==null?e.events:null,e!==null))for(a=0;a<e.length;a++)f=e[a],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&p!==null){e=void 0,a=r,f=p.memoizedProps,p=p.memoizedState,l=a.stateNode;try{var be=Gs(a.type,f);e=l.getSnapshotBeforeUpdate(be,p),l.__reactInternalSnapshotBeforeUpdate=e}catch(Te){tt(a,a.return,Te)}}break;case 3:if((e&1024)!==0){if(e=r.stateNode.containerInfo,a=e.nodeType,a===9)Mh(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Mh(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(i(163))}if(e=r.sibling,e!==null){e.return=r.return,Lt=e;break}Lt=r.return}}function iy(e,r,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Or(e,a),l&4&&Pa(5,a);break;case 1:if(Or(e,a),l&4)if(e=a.stateNode,r===null)try{e.componentDidMount()}catch(_){tt(a,a.return,_)}else{var f=Gs(a.type,r.memoizedProps);r=r.memoizedState;try{e.componentDidUpdate(f,r,e.__reactInternalSnapshotBeforeUpdate)}catch(_){tt(a,a.return,_)}}l&64&&Zp(a),l&512&&Ua(a,a.return);break;case 3:if(Or(e,a),l&64&&(e=a.updateQueue,e!==null)){if(r=null,a.child!==null)switch(a.child.tag){case 27:case 5:r=a.child.stateNode;break;case 1:r=a.child.stateNode}try{H0(e,r)}catch(_){tt(a,a.return,_)}}break;case 27:r===null&&l&4&&ry(a);case 26:case 5:Or(e,a),r===null&&l&4&&ty(a),l&512&&Ua(a,a.return);break;case 12:Or(e,a);break;case 31:Or(e,a),l&4&&ly(e,a);break;case 13:Or(e,a),l&4&&cy(e,a),l&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=uw.bind(null,a),Tw(e,a))));break;case 22:if(l=a.memoizedState!==null||Sr,!l){r=r!==null&&r.memoizedState!==null||Nt,f=Sr;var p=Nt;Sr=l,(Nt=r)&&!p?Ar(e,a,(a.subtreeFlags&8772)!==0):Or(e,a),Sr=f,Nt=p}break;case 30:break;default:Or(e,a)}}function ay(e){var r=e.alternate;r!==null&&(e.alternate=null,ay(r)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(r=e.stateNode,r!==null&&ai(r)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var dt=null,en=!1;function Er(e,r,a){for(a=a.child;a!==null;)oy(e,r,a),a=a.sibling}function oy(e,r,a){if(_t&&typeof _t.onCommitFiberUnmount=="function")try{_t.onCommitFiberUnmount(As,a)}catch{}switch(a.tag){case 26:Nt||rr(a,r),Er(e,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Nt||rr(a,r);var l=dt,f=en;ls(a.type)&&(dt=a.stateNode,en=!1),Er(e,r,a),Ka(a.stateNode),dt=l,en=f;break;case 5:Nt||rr(a,r);case 6:if(l=dt,f=en,dt=null,Er(e,r,a),dt=l,en=f,dt!==null)if(en)try{(dt.nodeType===9?dt.body:dt.nodeName==="HTML"?dt.ownerDocument.body:dt).removeChild(a.stateNode)}catch(p){tt(a,r,p)}else try{dt.removeChild(a.stateNode)}catch(p){tt(a,r,p)}break;case 18:dt!==null&&(en?(e=dt,Zy(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Ui(e)):Zy(dt,a.stateNode));break;case 4:l=dt,f=en,dt=a.stateNode.containerInfo,en=!0,Er(e,r,a),dt=l,en=f;break;case 0:case 11:case 14:case 15:ts(2,a,r),Nt||ts(4,a,r),Er(e,r,a);break;case 1:Nt||(rr(a,r),l=a.stateNode,typeof l.componentWillUnmount=="function"&&ey(a,r,l)),Er(e,r,a);break;case 21:Er(e,r,a);break;case 22:Nt=(l=Nt)||a.memoizedState!==null,Er(e,r,a),Nt=l;break;default:Er(e,r,a)}}function ly(e,r){if(r.memoizedState===null&&(e=r.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ui(e)}catch(a){tt(r,r.return,a)}}}function cy(e,r){if(r.memoizedState===null&&(e=r.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ui(e)}catch(a){tt(r,r.return,a)}}function nw(e){switch(e.tag){case 31:case 13:case 19:var r=e.stateNode;return r===null&&(r=e.stateNode=new sy),r;case 22:return e=e.stateNode,r=e._retryCache,r===null&&(r=e._retryCache=new sy),r;default:throw Error(i(435,e.tag))}}function Nl(e,r){var a=nw(e);r.forEach(function(l){if(!a.has(l)){a.add(l);var f=fw.bind(null,e,l);l.then(f,f)}})}function tn(e,r){var a=r.deletions;if(a!==null)for(var l=0;l<a.length;l++){var f=a[l],p=e,_=r,O=_;e:for(;O!==null;){switch(O.tag){case 27:if(ls(O.type)){dt=O.stateNode,en=!1;break e}break;case 5:dt=O.stateNode,en=!1;break e;case 3:case 4:dt=O.stateNode.containerInfo,en=!0;break e}O=O.return}if(dt===null)throw Error(i(160));oy(p,_,f),dt=null,en=!1,p=f.alternate,p!==null&&(p.return=null),f.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)uy(r,e),r=r.sibling}var Vn=null;function uy(e,r){var a=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:tn(r,e),nn(e),l&4&&(ts(3,e,e.return),Pa(3,e),ts(5,e,e.return));break;case 1:tn(r,e),nn(e),l&512&&(Nt||a===null||rr(a,a.return)),l&64&&Sr&&(e=e.updateQueue,e!==null&&(l=e.callbacks,l!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var f=Vn;if(tn(r,e),nn(e),l&512&&(Nt||a===null||rr(a,a.return)),l&4){var p=a!==null?a.memoizedState:null;if(l=e.memoizedState,a===null)if(l===null)if(e.stateNode===null){e:{l=e.type,a=e.memoizedProps,f=f.ownerDocument||f;t:switch(l){case"title":p=f.getElementsByTagName("title")[0],(!p||p[Mt]||p[at]||p.namespaceURI==="http://www.w3.org/2000/svg"||p.hasAttribute("itemprop"))&&(p=f.createElement(l),f.head.insertBefore(p,f.querySelector("head > title"))),$t(p,l,a),p[at]=e,L(p),l=p;break e;case"link":var _=ug("link","href",f).get(l+(a.href||""));if(_){for(var O=0;O<_.length;O++)if(p=_[O],p.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&p.getAttribute("rel")===(a.rel==null?null:a.rel)&&p.getAttribute("title")===(a.title==null?null:a.title)&&p.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(O,1);break t}}p=f.createElement(l),$t(p,l,a),f.head.appendChild(p);break;case"meta":if(_=ug("meta","content",f).get(l+(a.content||""))){for(O=0;O<_.length;O++)if(p=_[O],p.getAttribute("content")===(a.content==null?null:""+a.content)&&p.getAttribute("name")===(a.name==null?null:a.name)&&p.getAttribute("property")===(a.property==null?null:a.property)&&p.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&p.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(O,1);break t}}p=f.createElement(l),$t(p,l,a),f.head.appendChild(p);break;default:throw Error(i(468,l))}p[at]=e,L(p),l=p}e.stateNode=l}else fg(f,e.type,e.stateNode);else e.stateNode=cg(f,l,e.memoizedProps);else p!==l?(p===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):p.count--,l===null?fg(f,e.type,e.stateNode):cg(f,l,e.memoizedProps)):l===null&&e.stateNode!==null&&sh(e,e.memoizedProps,a.memoizedProps)}break;case 27:tn(r,e),nn(e),l&512&&(Nt||a===null||rr(a,a.return)),a!==null&&l&4&&sh(e,e.memoizedProps,a.memoizedProps);break;case 5:if(tn(r,e),nn(e),l&512&&(Nt||a===null||rr(a,a.return)),e.flags&32){f=e.stateNode;try{li(f,"")}catch(be){tt(e,e.return,be)}}l&4&&e.stateNode!=null&&(f=e.memoizedProps,sh(e,f,a!==null?a.memoizedProps:f)),l&1024&&(oh=!0);break;case 6:if(tn(r,e),nn(e),l&4){if(e.stateNode===null)throw Error(i(162));l=e.memoizedProps,a=e.stateNode;try{a.nodeValue=l}catch(be){tt(e,e.return,be)}}break;case 3:if(Gl=null,f=Vn,Vn=Hl(r.containerInfo),tn(r,e),Vn=f,nn(e),l&4&&a!==null&&a.memoizedState.isDehydrated)try{Ui(r.containerInfo)}catch(be){tt(e,e.return,be)}oh&&(oh=!1,fy(e));break;case 4:l=Vn,Vn=Hl(e.stateNode.containerInfo),tn(r,e),nn(e),Vn=l;break;case 12:tn(r,e),nn(e);break;case 31:tn(r,e),nn(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Nl(e,l)));break;case 13:tn(r,e),nn(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Cl=ht()),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Nl(e,l)));break;case 22:f=e.memoizedState!==null;var M=a!==null&&a.memoizedState!==null,G=Sr,Z=Nt;if(Sr=G||f,Nt=Z||M,tn(r,e),Nt=Z,Sr=G,nn(e),l&8192)e:for(r=e.stateNode,r._visibility=f?r._visibility&-2:r._visibility|1,f&&(a===null||M||Sr||Nt||Vs(e)),a=null,r=e;;){if(r.tag===5||r.tag===26){if(a===null){M=a=r;try{if(p=M.stateNode,f)_=p.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{O=M.stateNode;var se=M.memoizedProps.style,Y=se!=null&&se.hasOwnProperty("display")?se.display:null;O.style.display=Y==null||typeof Y=="boolean"?"":(""+Y).trim()}}catch(be){tt(M,M.return,be)}}}else if(r.tag===6){if(a===null){M=r;try{M.stateNode.nodeValue=f?"":M.memoizedProps}catch(be){tt(M,M.return,be)}}}else if(r.tag===18){if(a===null){M=r;try{var J=M.stateNode;f?eg(J,!0):eg(M.stateNode,!1)}catch(be){tt(M,M.return,be)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===e)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break e;for(;r.sibling===null;){if(r.return===null||r.return===e)break e;a===r&&(a=null),r=r.return}a===r&&(a=null),r.sibling.return=r.return,r=r.sibling}l&4&&(l=e.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Nl(e,a))));break;case 19:tn(r,e),nn(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Nl(e,l)));break;case 30:break;case 21:break;default:tn(r,e),nn(e)}}function nn(e){var r=e.flags;if(r&2){try{for(var a,l=e.return;l!==null;){if(ny(l)){a=l;break}l=l.return}if(a==null)throw Error(i(160));switch(a.tag){case 27:var f=a.stateNode,p=ih(e);kl(e,p,f);break;case 5:var _=a.stateNode;a.flags&32&&(li(_,""),a.flags&=-33);var O=ih(e);kl(e,O,_);break;case 3:case 4:var M=a.stateNode.containerInfo,G=ih(e);ah(e,G,M);break;default:throw Error(i(161))}}catch(Z){tt(e,e.return,Z)}e.flags&=-3}r&4096&&(e.flags&=-4097)}function fy(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var r=e;fy(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),e=e.sibling}}function Or(e,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)iy(e,r.alternate,r),r=r.sibling}function Vs(e){for(e=e.child;e!==null;){var r=e;switch(r.tag){case 0:case 11:case 14:case 15:ts(4,r,r.return),Vs(r);break;case 1:rr(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&ey(r,r.return,a),Vs(r);break;case 27:Ka(r.stateNode);case 26:case 5:rr(r,r.return),Vs(r);break;case 22:r.memoizedState===null&&Vs(r);break;case 30:Vs(r);break;default:Vs(r)}e=e.sibling}}function Ar(e,r,a){for(a=a&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var l=r.alternate,f=e,p=r,_=p.flags;switch(p.tag){case 0:case 11:case 15:Ar(f,p,a),Pa(4,p);break;case 1:if(Ar(f,p,a),l=p,f=l.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(G){tt(l,l.return,G)}if(l=p,f=l.updateQueue,f!==null){var O=l.stateNode;try{var M=f.shared.hiddenCallbacks;if(M!==null)for(f.shared.hiddenCallbacks=null,f=0;f<M.length;f++)$0(M[f],O)}catch(G){tt(l,l.return,G)}}a&&_&64&&Zp(p),Ua(p,p.return);break;case 27:ry(p);case 26:case 5:Ar(f,p,a),a&&l===null&&_&4&&ty(p),Ua(p,p.return);break;case 12:Ar(f,p,a);break;case 31:Ar(f,p,a),a&&_&4&&ly(f,p);break;case 13:Ar(f,p,a),a&&_&4&&cy(f,p);break;case 22:p.memoizedState===null&&Ar(f,p,a),Ua(p,p.return);break;case 30:break;default:Ar(f,p,a)}r=r.sibling}}function lh(e,r){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(e=r.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Oa(a))}function ch(e,r){e=null,r.alternate!==null&&(e=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==e&&(r.refCount++,e!=null&&Oa(e))}function Yn(e,r,a,l){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)hy(e,r,a,l),r=r.sibling}function hy(e,r,a,l){var f=r.flags;switch(r.tag){case 0:case 11:case 15:Yn(e,r,a,l),f&2048&&Pa(9,r);break;case 1:Yn(e,r,a,l);break;case 3:Yn(e,r,a,l),f&2048&&(e=null,r.alternate!==null&&(e=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==e&&(r.refCount++,e!=null&&Oa(e)));break;case 12:if(f&2048){Yn(e,r,a,l),e=r.stateNode;try{var p=r.memoizedProps,_=p.id,O=p.onPostCommit;typeof O=="function"&&O(_,r.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(M){tt(r,r.return,M)}}else Yn(e,r,a,l);break;case 31:Yn(e,r,a,l);break;case 13:Yn(e,r,a,l);break;case 23:break;case 22:p=r.stateNode,_=r.alternate,r.memoizedState!==null?p._visibility&2?Yn(e,r,a,l):za(e,r):p._visibility&2?Yn(e,r,a,l):(p._visibility|=2,ki(e,r,a,l,(r.subtreeFlags&10256)!==0||!1)),f&2048&&lh(_,r);break;case 24:Yn(e,r,a,l),f&2048&&ch(r.alternate,r);break;default:Yn(e,r,a,l)}}function ki(e,r,a,l,f){for(f=f&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var p=e,_=r,O=a,M=l,G=_.flags;switch(_.tag){case 0:case 11:case 15:ki(p,_,O,M,f),Pa(8,_);break;case 23:break;case 22:var Z=_.stateNode;_.memoizedState!==null?Z._visibility&2?ki(p,_,O,M,f):za(p,_):(Z._visibility|=2,ki(p,_,O,M,f)),f&&G&2048&&lh(_.alternate,_);break;case 24:ki(p,_,O,M,f),f&&G&2048&&ch(_.alternate,_);break;default:ki(p,_,O,M,f)}r=r.sibling}}function za(e,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var a=e,l=r,f=l.flags;switch(l.tag){case 22:za(a,l),f&2048&&lh(l.alternate,l);break;case 24:za(a,l),f&2048&&ch(l.alternate,l);break;default:za(a,l)}r=r.sibling}}var Ia=8192;function Ni(e,r,a){if(e.subtreeFlags&Ia)for(e=e.child;e!==null;)dy(e,r,a),e=e.sibling}function dy(e,r,a){switch(e.tag){case 26:Ni(e,r,a),e.flags&Ia&&e.memoizedState!==null&&$w(a,Vn,e.memoizedState,e.memoizedProps);break;case 5:Ni(e,r,a);break;case 3:case 4:var l=Vn;Vn=Hl(e.stateNode.containerInfo),Ni(e,r,a),Vn=l;break;case 22:e.memoizedState===null&&(l=e.alternate,l!==null&&l.memoizedState!==null?(l=Ia,Ia=16777216,Ni(e,r,a),Ia=l):Ni(e,r,a));break;default:Ni(e,r,a)}}function my(e){var r=e.alternate;if(r!==null&&(e=r.child,e!==null)){r.child=null;do r=e.sibling,e.sibling=null,e=r;while(e!==null)}}function $a(e){var r=e.deletions;if((e.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Lt=l,yy(l,e)}my(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)py(e),e=e.sibling}function py(e){switch(e.tag){case 0:case 11:case 15:$a(e),e.flags&2048&&ts(9,e,e.return);break;case 3:$a(e);break;case 12:$a(e);break;case 22:var r=e.stateNode;e.memoizedState!==null&&r._visibility&2&&(e.return===null||e.return.tag!==13)?(r._visibility&=-3,Tl(e)):$a(e);break;default:$a(e)}}function Tl(e){var r=e.deletions;if((e.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Lt=l,yy(l,e)}my(e)}for(e=e.child;e!==null;){switch(r=e,r.tag){case 0:case 11:case 15:ts(8,r,r.return),Tl(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,Tl(r));break;default:Tl(r)}e=e.sibling}}function yy(e,r){for(;Lt!==null;){var a=Lt;switch(a.tag){case 0:case 11:case 15:ts(8,a,r);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Oa(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Lt=l;else e:for(a=e;Lt!==null;){l=Lt;var f=l.sibling,p=l.return;if(ay(l),l===a){Lt=null;break e}if(f!==null){f.return=p,Lt=f;break e}Lt=p}}}var rw={getCacheForType:function(e){var r=zt(At),a=r.data.get(e);return a===void 0&&(a=e(),r.data.set(e,a)),a},cacheSignal:function(){return zt(At).controller.signal}},sw=typeof WeakMap=="function"?WeakMap:Map,Qe=0,ot=null,Pe=null,ze=0,et=0,pn=null,ns=!1,Ti=!1,uh=!1,jr=0,xt=0,rs=0,Ys=0,fh=0,yn=0,Ci=0,Ha=null,rn=null,hh=!1,Cl=0,gy=0,Ml=1/0,Rl=null,ss=null,Rt=0,is=null,Mi=null,kr=0,dh=0,mh=null,by=null,Fa=0,ph=null;function gn(){return(Qe&2)!==0&&ze!==0?ze&-ze:H.T!==null?_h():ha()}function xy(){if(yn===0)if((ze&536870912)===0||Fe){var e=ur;ur<<=1,(ur&3932160)===0&&(ur=262144),yn=e}else yn=536870912;return e=dn.current,e!==null&&(e.flags|=32),yn}function sn(e,r,a){(e===ot&&(et===2||et===9)||e.cancelPendingCommit!==null)&&(Ri(e,0),as(e,ze,yn,!1)),Hn(e,a),((Qe&2)===0||e!==ot)&&(e===ot&&((Qe&2)===0&&(Ys|=a),xt===4&&as(e,ze,yn,!1)),sr(e))}function vy(e,r,a){if((Qe&6)!==0)throw Error(i(327));var l=!a&&(r&127)===0&&(r&e.expiredLanes)===0||ks(e,r),f=l?ow(e,r):gh(e,r,!0),p=l;do{if(f===0){Ti&&!l&&as(e,r,0,!1);break}else{if(a=e.current.alternate,p&&!iw(a)){f=gh(e,r,!1),p=!1;continue}if(f===2){if(p=r,e.errorRecoveryDisabledLanes&p)var _=0;else _=e.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){r=_;e:{var O=e;f=Ha;var M=O.current.memoizedState.isDehydrated;if(M&&(Ri(O,_).flags|=256),_=gh(O,_,!1),_!==2){if(uh&&!M){O.errorRecoveryDisabledLanes|=p,Ys|=p,f=4;break e}p=rn,rn=f,p!==null&&(rn===null?rn=p:rn.push.apply(rn,p))}f=_}if(p=!1,f!==2)continue}}if(f===1){Ri(e,0),as(e,r,0,!0);break}e:{switch(l=e,p=f,p){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:as(l,r,yn,!ns);break e;case 2:rn=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(f=Cl+300-ht(),10<f)){if(as(l,r,yn,!ns),js(l,0,!0)!==0)break e;kr=r,l.timeoutHandle=Qy(_y.bind(null,l,a,rn,Rl,hh,r,yn,Ys,Ci,ns,p,"Throttled",-0,0),f);break e}_y(l,a,rn,Rl,hh,r,yn,Ys,Ci,ns,p,null,-0,0)}}break}while(!0);sr(e)}function _y(e,r,a,l,f,p,_,O,M,G,Z,se,Y,J){if(e.timeoutHandle=-1,se=r.subtreeFlags,se&8192||(se&16785408)===16785408){se={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:dr},dy(r,p,se);var be=(p&62914560)===p?Cl-ht():(p&4194048)===p?gy-ht():0;if(be=Hw(se,be),be!==null){kr=p,e.cancelPendingCommit=be(Ny.bind(null,e,r,p,a,l,f,_,O,M,Z,se,null,Y,J)),as(e,p,_,!G);return}}Ny(e,r,p,a,l,f,_,O,M)}function iw(e){for(var r=e;;){var a=r.tag;if((a===0||a===11||a===15)&&r.flags&16384&&(a=r.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var f=a[l],p=f.getSnapshot;f=f.value;try{if(!fn(p(),f))return!1}catch{return!1}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function as(e,r,a,l){r&=~fh,r&=~Ys,e.suspendedLanes|=r,e.pingedLanes&=~r,l&&(e.warmLanes|=r),l=e.expirationTimes;for(var f=r;0<f;){var p=31-Ft(f),_=1<<p;l[p]=-1,f&=~_}a!==0&&Hr(e,a,r)}function Dl(){return(Qe&6)===0?(Ga(0),!1):!0}function yh(){if(Pe!==null){if(et===0)var e=Pe.return;else e=Pe,gr=Ps=null,Mf(e),Si=null,ja=0,e=Pe;for(;e!==null;)Wp(e.alternate,e),e=e.return;Pe=null}}function Ri(e,r){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,Ow(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),kr=0,yh(),ot=e,Pe=a=pr(e.current,null),ze=r,et=0,pn=null,ns=!1,Ti=ks(e,r),uh=!1,Ci=yn=fh=Ys=rs=xt=0,rn=Ha=null,hh=!1,(r&8)!==0&&(r|=r&32);var l=e.entangledLanes;if(l!==0)for(e=e.entanglements,l&=r;0<l;){var f=31-Ft(l),p=1<<f;r|=e[f],l&=~p}return jr=r,tl(),a}function wy(e,r){De=null,H.H=La,r===wi||r===cl?(r=P0(),et=3):r===vf?(r=P0(),et=4):et=r===Kf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,pn=r,Pe===null&&(xt=1,Sl(e,Mn(r,e.current)))}function Sy(){var e=dn.current;return e===null?!0:(ze&4194048)===ze?qn===null:(ze&62914560)===ze||(ze&536870912)!==0?e===qn:!1}function Ey(){var e=H.H;return H.H=La,e===null?La:e}function Oy(){var e=H.A;return H.A=rw,e}function Ll(){xt=4,ns||(ze&4194048)!==ze&&dn.current!==null||(Ti=!0),(rs&134217727)===0&&(Ys&134217727)===0||ot===null||as(ot,ze,yn,!1)}function gh(e,r,a){var l=Qe;Qe|=2;var f=Ey(),p=Oy();(ot!==e||ze!==r)&&(Rl=null,Ri(e,r)),r=!1;var _=xt;e:do try{if(et!==0&&Pe!==null){var O=Pe,M=pn;switch(et){case 8:yh(),_=6;break e;case 3:case 2:case 9:case 6:dn.current===null&&(r=!0);var G=et;if(et=0,pn=null,Di(e,O,M,G),a&&Ti){_=0;break e}break;default:G=et,et=0,pn=null,Di(e,O,M,G)}}aw(),_=xt;break}catch(Z){wy(e,Z)}while(!0);return r&&e.shellSuspendCounter++,gr=Ps=null,Qe=l,H.H=f,H.A=p,Pe===null&&(ot=null,ze=0,tl()),_}function aw(){for(;Pe!==null;)Ay(Pe)}function ow(e,r){var a=Qe;Qe|=2;var l=Ey(),f=Oy();ot!==e||ze!==r?(Rl=null,Ml=ht()+500,Ri(e,r)):Ti=ks(e,r);e:do try{if(et!==0&&Pe!==null){r=Pe;var p=pn;t:switch(et){case 1:et=0,pn=null,Di(e,r,p,1);break;case 2:case 9:if(q0(p)){et=0,pn=null,jy(r);break}r=function(){et!==2&&et!==9||ot!==e||(et=7),sr(e)},p.then(r,r);break e;case 3:et=7;break e;case 4:et=5;break e;case 7:q0(p)?(et=0,pn=null,jy(r)):(et=0,pn=null,Di(e,r,p,7));break;case 5:var _=null;switch(Pe.tag){case 26:_=Pe.memoizedState;case 5:case 27:var O=Pe;if(_?hg(_):O.stateNode.complete){et=0,pn=null;var M=O.sibling;if(M!==null)Pe=M;else{var G=O.return;G!==null?(Pe=G,ql(G)):Pe=null}break t}}et=0,pn=null,Di(e,r,p,5);break;case 6:et=0,pn=null,Di(e,r,p,6);break;case 8:yh(),xt=6;break e;default:throw Error(i(462))}}lw();break}catch(Z){wy(e,Z)}while(!0);return gr=Ps=null,H.H=l,H.A=f,Qe=a,Pe!==null?0:(ot=null,ze=0,tl(),xt)}function lw(){for(;Pe!==null&&!Po();)Ay(Pe)}function Ay(e){var r=Xp(e.alternate,e,jr);e.memoizedProps=e.pendingProps,r===null?ql(e):Pe=r}function jy(e){var r=e,a=r.alternate;switch(r.tag){case 15:case 0:r=Fp(a,r,r.pendingProps,r.type,void 0,ze);break;case 11:r=Fp(a,r,r.pendingProps,r.type.render,r.ref,ze);break;case 5:Mf(r);default:Wp(a,r),r=Pe=O0(r,jr),r=Xp(a,r,jr)}e.memoizedProps=e.pendingProps,r===null?ql(e):Pe=r}function Di(e,r,a,l){gr=Ps=null,Mf(r),Si=null,ja=0;var f=r.return;try{if(X_(e,f,r,a,ze)){xt=1,Sl(e,Mn(a,e.current)),Pe=null;return}}catch(p){if(f!==null)throw Pe=f,p;xt=1,Sl(e,Mn(a,e.current)),Pe=null;return}r.flags&32768?(Fe||l===1?e=!0:Ti||(ze&536870912)!==0?e=!1:(ns=e=!0,(l===2||l===9||l===3||l===6)&&(l=dn.current,l!==null&&l.tag===13&&(l.flags|=16384))),ky(r,e)):ql(r)}function ql(e){var r=e;do{if((r.flags&32768)!==0){ky(r,ns);return}e=r.return;var a=Z_(r.alternate,r,jr);if(a!==null){Pe=a;return}if(r=r.sibling,r!==null){Pe=r;return}Pe=r=e}while(r!==null);xt===0&&(xt=5)}function ky(e,r){do{var a=ew(e.alternate,e);if(a!==null){a.flags&=32767,Pe=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!r&&(e=e.sibling,e!==null)){Pe=e;return}Pe=e=a}while(e!==null);xt=6,Pe=null}function Ny(e,r,a,l,f,p,_,O,M){e.cancelPendingCommit=null;do Bl();while(Rt!==0);if((Qe&6)!==0)throw Error(i(327));if(r!==null){if(r===e.current)throw Error(i(177));if(p=r.lanes|r.childLanes,p|=sf,$r(e,a,p,_,O,M),e===ot&&(Pe=ot=null,ze=0),Mi=r,is=e,kr=a,dh=p,mh=f,by=l,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,hw(ri,function(){return Dy(),null})):(e.callbackNode=null,e.callbackPriority=0),l=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||l){l=H.T,H.T=null,f=W.p,W.p=2,_=Qe,Qe|=4;try{tw(e,r,a)}finally{Qe=_,W.p=f,H.T=l}}Rt=1,Ty(),Cy(),My()}}function Ty(){if(Rt===1){Rt=0;var e=is,r=Mi,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=H.T,H.T=null;var l=W.p;W.p=2;var f=Qe;Qe|=4;try{uy(r,e);var p=Nh,_=y0(e.containerInfo),O=p.focusedElem,M=p.selectionRange;if(_!==O&&O&&O.ownerDocument&&p0(O.ownerDocument.documentElement,O)){if(M!==null&&Zu(O)){var G=M.start,Z=M.end;if(Z===void 0&&(Z=G),"selectionStart"in O)O.selectionStart=G,O.selectionEnd=Math.min(Z,O.value.length);else{var se=O.ownerDocument||document,Y=se&&se.defaultView||window;if(Y.getSelection){var J=Y.getSelection(),be=O.textContent.length,Te=Math.min(M.start,be),it=M.end===void 0?Te:Math.min(M.end,be);!J.extend&&Te>it&&(_=it,it=Te,Te=_);var U=m0(O,Te),P=m0(O,it);if(U&&P&&(J.rangeCount!==1||J.anchorNode!==U.node||J.anchorOffset!==U.offset||J.focusNode!==P.node||J.focusOffset!==P.offset)){var F=se.createRange();F.setStart(U.node,U.offset),J.removeAllRanges(),Te>it?(J.addRange(F),J.extend(P.node,P.offset)):(F.setEnd(P.node,P.offset),J.addRange(F))}}}}for(se=[],J=O;J=J.parentNode;)J.nodeType===1&&se.push({element:J,left:J.scrollLeft,top:J.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;O<se.length;O++){var ee=se[O];ee.element.scrollLeft=ee.left,ee.element.scrollTop=ee.top}}Jl=!!kh,Nh=kh=null}finally{Qe=f,W.p=l,H.T=a}}e.current=r,Rt=2}}function Cy(){if(Rt===2){Rt=0;var e=is,r=Mi,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=H.T,H.T=null;var l=W.p;W.p=2;var f=Qe;Qe|=4;try{iy(e,r.alternate,r)}finally{Qe=f,W.p=l,H.T=a}}Rt=3}}function My(){if(Rt===4||Rt===3){Rt=0,ni();var e=is,r=Mi,a=kr,l=by;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Rt=5:(Rt=0,Mi=is=null,Ry(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(ss=null),Ts(a),r=r.stateNode,_t&&typeof _t.onCommitFiberRoot=="function")try{_t.onCommitFiberRoot(As,r,void 0,(r.current.flags&128)===128)}catch{}if(l!==null){r=H.T,f=W.p,W.p=2,H.T=null;try{for(var p=e.onRecoverableError,_=0;_<l.length;_++){var O=l[_];p(O.value,{componentStack:O.stack})}}finally{H.T=r,W.p=f}}(kr&3)!==0&&Bl(),sr(e),f=e.pendingLanes,(a&261930)!==0&&(f&42)!==0?e===ph?Fa++:(Fa=0,ph=e):Fa=0,Ga(0)}}function Ry(e,r){(e.pooledCacheLanes&=r)===0&&(r=e.pooledCache,r!=null&&(e.pooledCache=null,Oa(r)))}function Bl(){return Ty(),Cy(),My(),Dy()}function Dy(){if(Rt!==5)return!1;var e=is,r=dh;dh=0;var a=Ts(kr),l=H.T,f=W.p;try{W.p=32>a?32:a,H.T=null,a=mh,mh=null;var p=is,_=kr;if(Rt=0,Mi=is=null,kr=0,(Qe&6)!==0)throw Error(i(331));var O=Qe;if(Qe|=4,py(p.current),hy(p,p.current,_,a),Qe=O,Ga(0,!1),_t&&typeof _t.onPostCommitFiberRoot=="function")try{_t.onPostCommitFiberRoot(As,p)}catch{}return!0}finally{W.p=f,H.T=l,Ry(e,r)}}function Ly(e,r,a){r=Mn(a,r),r=Yf(e.stateNode,r,2),e=Wr(e,r,2),e!==null&&(Hn(e,2),sr(e))}function tt(e,r,a){if(e.tag===3)Ly(e,e,a);else for(;r!==null;){if(r.tag===3){Ly(r,e,a);break}else if(r.tag===1){var l=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(ss===null||!ss.has(l))){e=Mn(a,e),a=qp(2),l=Wr(r,a,2),l!==null&&(Bp(a,l,r,e),Hn(l,2),sr(l));break}}r=r.return}}function bh(e,r,a){var l=e.pingCache;if(l===null){l=e.pingCache=new sw;var f=new Set;l.set(r,f)}else f=l.get(r),f===void 0&&(f=new Set,l.set(r,f));f.has(a)||(uh=!0,f.add(a),e=cw.bind(null,e,r,a),r.then(e,e))}function cw(e,r,a){var l=e.pingCache;l!==null&&l.delete(r),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,ot===e&&(ze&a)===a&&(xt===4||xt===3&&(ze&62914560)===ze&&300>ht()-Cl?(Qe&2)===0&&Ri(e,0):fh|=a,Ci===ze&&(Ci=0)),sr(e)}function qy(e,r){r===0&&(r=ii()),e=Ls(e,r),e!==null&&(Hn(e,r),sr(e))}function uw(e){var r=e.memoizedState,a=0;r!==null&&(a=r.retryLane),qy(e,a)}function fw(e,r){var a=0;switch(e.tag){case 31:case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(a=f.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(i(314))}l!==null&&l.delete(r),qy(e,a)}function hw(e,r){return la(e,r)}var Pl=null,Li=null,xh=!1,Ul=!1,vh=!1,os=0;function sr(e){e!==Li&&e.next===null&&(Li===null?Pl=Li=e:Li=Li.next=e),Ul=!0,xh||(xh=!0,mw())}function Ga(e,r){if(!vh&&Ul){vh=!0;do for(var a=!1,l=Pl;l!==null;){if(e!==0){var f=l.pendingLanes;if(f===0)var p=0;else{var _=l.suspendedLanes,O=l.pingedLanes;p=(1<<31-Ft(42|e)+1)-1,p&=f&~(_&~O),p=p&201326741?p&201326741|1:p?p|2:0}p!==0&&(a=!0,zy(l,p))}else p=ze,p=js(l,l===ot?p:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(p&3)===0||ks(l,p)||(a=!0,zy(l,p));l=l.next}while(a);vh=!1}}function dw(){By()}function By(){Ul=xh=!1;var e=0;os!==0&&Ew()&&(e=os);for(var r=ht(),a=null,l=Pl;l!==null;){var f=l.next,p=Py(l,r);p===0?(l.next=null,a===null?Pl=f:a.next=f,f===null&&(Li=a)):(a=l,(e!==0||(p&3)!==0)&&(Ul=!0)),l=f}Rt!==0&&Rt!==5||Ga(e),os!==0&&(os=0)}function Py(e,r){for(var a=e.suspendedLanes,l=e.pingedLanes,f=e.expirationTimes,p=e.pendingLanes&-62914561;0<p;){var _=31-Ft(p),O=1<<_,M=f[_];M===-1?((O&a)===0||(O&l)!==0)&&(f[_]=fa(O,r)):M<=r&&(e.expiredLanes|=O),p&=~O}if(r=ot,a=ze,a=js(e,e===r?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l=e.callbackNode,a===0||e===r&&(et===2||et===9)||e.cancelPendingCommit!==null)return l!==null&&l!==null&&cr(l),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||ks(e,a)){if(r=a&-a,r===e.callbackPriority)return r;switch(l!==null&&cr(l),Ts(a)){case 2:case 8:a=zo;break;case 32:a=ri;break;case 268435456:a=Io;break;default:a=ri}return l=Uy.bind(null,e),a=la(a,l),e.callbackPriority=r,e.callbackNode=a,r}return l!==null&&l!==null&&cr(l),e.callbackPriority=2,e.callbackNode=null,2}function Uy(e,r){if(Rt!==0&&Rt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Bl()&&e.callbackNode!==a)return null;var l=ze;return l=js(e,e===ot?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l===0?null:(vy(e,l,r),Py(e,ht()),e.callbackNode!=null&&e.callbackNode===a?Uy.bind(null,e):null)}function zy(e,r){if(Bl())return null;vy(e,r,!0)}function mw(){Aw(function(){(Qe&6)!==0?la(Uo,dw):By()})}function _h(){if(os===0){var e=vi;e===0&&(e=Ur,Ur<<=1,(Ur&261888)===0&&(Ur=256)),os=e}return os}function Iy(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Yo(""+e)}function $y(e,r){var a=r.ownerDocument.createElement("input");return a.name=r.name,a.value=r.value,e.id&&a.setAttribute("form",e.id),r.parentNode.insertBefore(a,r),e=new FormData(e),a.parentNode.removeChild(a),e}function pw(e,r,a,l,f){if(r==="submit"&&a&&a.stateNode===f){var p=Iy((f[gt]||null).action),_=l.submitter;_&&(r=(r=_[gt]||null)?Iy(r.formAction):_.getAttribute("formAction"),r!==null&&(p=r,_=null));var O=new Qo("action","action",null,l,f);e.push({event:O,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(os!==0){var M=_?$y(f,_):new FormData(f);If(a,{pending:!0,data:M,method:f.method,action:p},null,M)}}else typeof p=="function"&&(O.preventDefault(),M=_?$y(f,_):new FormData(f),If(a,{pending:!0,data:M,method:f.method,action:p},p,M))},currentTarget:f}]})}}for(var wh=0;wh<rf.length;wh++){var Sh=rf[wh],yw=Sh.toLowerCase(),gw=Sh[0].toUpperCase()+Sh.slice(1);Gn(yw,"on"+gw)}Gn(x0,"onAnimationEnd"),Gn(v0,"onAnimationIteration"),Gn(_0,"onAnimationStart"),Gn("dblclick","onDoubleClick"),Gn("focusin","onFocus"),Gn("focusout","onBlur"),Gn(R_,"onTransitionRun"),Gn(D_,"onTransitionStart"),Gn(L_,"onTransitionCancel"),Gn(w0,"onTransitionEnd"),K("onMouseEnter",["mouseout","mouseover"]),K("onMouseLeave",["mouseout","mouseover"]),K("onPointerEnter",["pointerout","pointerover"]),K("onPointerLeave",["pointerout","pointerover"]),ae("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ae("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ae("onBeforeInput",["compositionend","keypress","textInput","paste"]),ae("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ae("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ae("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Va="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),bw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Va));function Hy(e,r){r=(r&4)!==0;for(var a=0;a<e.length;a++){var l=e[a],f=l.event;l=l.listeners;e:{var p=void 0;if(r)for(var _=l.length-1;0<=_;_--){var O=l[_],M=O.instance,G=O.currentTarget;if(O=O.listener,M!==p&&f.isPropagationStopped())break e;p=O,f.currentTarget=G;try{p(f)}catch(Z){el(Z)}f.currentTarget=null,p=M}else for(_=0;_<l.length;_++){if(O=l[_],M=O.instance,G=O.currentTarget,O=O.listener,M!==p&&f.isPropagationStopped())break e;p=O,f.currentTarget=G;try{p(f)}catch(Z){el(Z)}f.currentTarget=null,p=M}}}}function Ue(e,r){var a=r[Cs];a===void 0&&(a=r[Cs]=new Set);var l=e+"__bubble";a.has(l)||(Fy(r,e,2,!1),a.add(l))}function Eh(e,r,a){var l=0;r&&(l|=4),Fy(a,e,l,r)}var zl="_reactListening"+Math.random().toString(36).slice(2);function Oh(e){if(!e[zl]){e[zl]=!0,z.forEach(function(a){a!=="selectionchange"&&(bw.has(a)||Eh(a,!1,e),Eh(a,!0,e))});var r=e.nodeType===9?e:e.ownerDocument;r===null||r[zl]||(r[zl]=!0,Eh("selectionchange",!1,r))}}function Fy(e,r,a,l){switch(xg(r)){case 2:var f=Vw;break;case 8:f=Yw;break;default:f=zh}a=f.bind(null,r,a,e),f=void 0,!Fu||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),l?f!==void 0?e.addEventListener(r,a,{capture:!0,passive:f}):e.addEventListener(r,a,!0):f!==void 0?e.addEventListener(r,a,{passive:f}):e.addEventListener(r,a,!1)}function Ah(e,r,a,l,f){var p=l;if((r&1)===0&&(r&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var O=l.stateNode.containerInfo;if(O===f)break;if(_===4)for(_=l.return;_!==null;){var M=_.tag;if((M===3||M===4)&&_.stateNode.containerInfo===f)return;_=_.return}for(;O!==null;){if(_=A(O),_===null)return;if(M=_.tag,M===5||M===6||M===26||M===27){l=p=_;continue e}O=O.parentNode}}l=l.return}Jm(function(){var G=p,Z=$u(a),se=[];e:{var Y=S0.get(e);if(Y!==void 0){var J=Qo,be=e;switch(e){case"keypress":if(Jo(a)===0)break e;case"keydown":case"keyup":J=f_;break;case"focusin":be="focus",J=Ku;break;case"focusout":be="blur",J=Ku;break;case"beforeblur":case"afterblur":J=Ku;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":J=Wm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":J=Zv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":J=m_;break;case x0:case v0:case _0:J=n_;break;case w0:J=y_;break;case"scroll":case"scrollend":J=Qv;break;case"wheel":J=b_;break;case"copy":case"cut":case"paste":J=s_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":J=e0;break;case"toggle":case"beforetoggle":J=v_}var Te=(r&4)!==0,it=!Te&&(e==="scroll"||e==="scrollend"),U=Te?Y!==null?Y+"Capture":null:Y;Te=[];for(var P=G,F;P!==null;){var ee=P;if(F=ee.stateNode,ee=ee.tag,ee!==5&&ee!==26&&ee!==27||F===null||U===null||(ee=ma(P,U),ee!=null&&Te.push(Ya(P,ee,F))),it)break;P=P.return}0<Te.length&&(Y=new J(Y,be,null,a,Z),se.push({event:Y,listeners:Te}))}}if((r&7)===0){e:{if(Y=e==="mouseover"||e==="pointerover",J=e==="mouseout"||e==="pointerout",Y&&a!==Iu&&(be=a.relatedTarget||a.fromElement)&&(A(be)||be[un]))break e;if((J||Y)&&(Y=Z.window===Z?Z:(Y=Z.ownerDocument)?Y.defaultView||Y.parentWindow:window,J?(be=a.relatedTarget||a.toElement,J=G,be=be?A(be):null,be!==null&&(it=c(be),Te=be.tag,be!==it||Te!==5&&Te!==27&&Te!==6)&&(be=null)):(J=null,be=G),J!==be)){if(Te=Wm,ee="onMouseLeave",U="onMouseEnter",P="mouse",(e==="pointerout"||e==="pointerover")&&(Te=e0,ee="onPointerLeave",U="onPointerEnter",P="pointer"),it=J==null?Y:k(J),F=be==null?Y:k(be),Y=new Te(ee,P+"leave",J,a,Z),Y.target=it,Y.relatedTarget=F,ee=null,A(Z)===G&&(Te=new Te(U,P+"enter",be,a,Z),Te.target=F,Te.relatedTarget=it,ee=Te),it=ee,J&&be)t:{for(Te=xw,U=J,P=be,F=0,ee=U;ee;ee=Te(ee))F++;ee=0;for(var Oe=P;Oe;Oe=Te(Oe))ee++;for(;0<F-ee;)U=Te(U),F--;for(;0<ee-F;)P=Te(P),ee--;for(;F--;){if(U===P||P!==null&&U===P.alternate){Te=U;break t}U=Te(U),P=Te(P)}Te=null}else Te=null;J!==null&&Gy(se,Y,J,Te,!1),be!==null&&it!==null&&Gy(se,it,be,Te,!0)}}e:{if(Y=G?k(G):window,J=Y.nodeName&&Y.nodeName.toLowerCase(),J==="select"||J==="input"&&Y.type==="file")var Je=l0;else if(a0(Y))if(c0)Je=T_;else{Je=k_;var _e=j_}else J=Y.nodeName,!J||J.toLowerCase()!=="input"||Y.type!=="checkbox"&&Y.type!=="radio"?G&&zu(G.elementType)&&(Je=l0):Je=N_;if(Je&&(Je=Je(e,G))){o0(se,Je,a,Z);break e}_e&&_e(e,Y,G),e==="focusout"&&G&&Y.type==="number"&&G.memoizedProps.value!=null&&Uu(Y,"number",Y.value)}switch(_e=G?k(G):window,e){case"focusin":(a0(_e)||_e.contentEditable==="true")&&(hi=_e,ef=G,wa=null);break;case"focusout":wa=ef=hi=null;break;case"mousedown":tf=!0;break;case"contextmenu":case"mouseup":case"dragend":tf=!1,g0(se,a,Z);break;case"selectionchange":if(M_)break;case"keydown":case"keyup":g0(se,a,Z)}var Le;if(Xu)e:{switch(e){case"compositionstart":var Ie="onCompositionStart";break e;case"compositionend":Ie="onCompositionEnd";break e;case"compositionupdate":Ie="onCompositionUpdate";break e}Ie=void 0}else fi?s0(e,a)&&(Ie="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Ie="onCompositionStart");Ie&&(t0&&a.locale!=="ko"&&(fi||Ie!=="onCompositionStart"?Ie==="onCompositionEnd"&&fi&&(Le=Xm()):(Gr=Z,Gu="value"in Gr?Gr.value:Gr.textContent,fi=!0)),_e=Il(G,Ie),0<_e.length&&(Ie=new Zm(Ie,e,null,a,Z),se.push({event:Ie,listeners:_e}),Le?Ie.data=Le:(Le=i0(a),Le!==null&&(Ie.data=Le)))),(Le=w_?S_(e,a):E_(e,a))&&(Ie=Il(G,"onBeforeInput"),0<Ie.length&&(_e=new Zm("onBeforeInput","beforeinput",null,a,Z),se.push({event:_e,listeners:Ie}),_e.data=Le)),pw(se,e,G,a,Z)}Hy(se,r)})}function Ya(e,r,a){return{instance:e,listener:r,currentTarget:a}}function Il(e,r){for(var a=r+"Capture",l=[];e!==null;){var f=e,p=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||p===null||(f=ma(e,a),f!=null&&l.unshift(Ya(e,f,p)),f=ma(e,r),f!=null&&l.push(Ya(e,f,p))),e.tag===3)return l;e=e.return}return[]}function xw(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Gy(e,r,a,l,f){for(var p=r._reactName,_=[];a!==null&&a!==l;){var O=a,M=O.alternate,G=O.stateNode;if(O=O.tag,M!==null&&M===l)break;O!==5&&O!==26&&O!==27||G===null||(M=G,f?(G=ma(a,p),G!=null&&_.unshift(Ya(a,G,M))):f||(G=ma(a,p),G!=null&&_.push(Ya(a,G,M)))),a=a.return}_.length!==0&&e.push({event:r,listeners:_})}var vw=/\r\n?/g,_w=/\u0000|\uFFFD/g;function Vy(e){return(typeof e=="string"?e:""+e).replace(vw,`
26
- `).replace(_w,"")}function Yy(e,r){return r=Vy(r),Vy(e)===r}function st(e,r,a,l,f,p){switch(a){case"children":typeof l=="string"?r==="body"||r==="textarea"&&l===""||li(e,l):(typeof l=="number"||typeof l=="bigint")&&r!=="body"&&li(e,""+l);break;case"className":Fn(e,"class",l);break;case"tabIndex":Fn(e,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Fn(e,a,l);break;case"style":Ym(e,l,p);break;case"data":if(r!=="object"){Fn(e,"data",l);break}case"src":case"href":if(l===""&&(r!=="a"||a!=="href")){e.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Yo(""+l),e.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof p=="function"&&(a==="formAction"?(r!=="input"&&st(e,r,"name",f.name,f,null),st(e,r,"formEncType",f.formEncType,f,null),st(e,r,"formMethod",f.formMethod,f,null),st(e,r,"formTarget",f.formTarget,f,null)):(st(e,r,"encType",f.encType,f,null),st(e,r,"method",f.method,f,null),st(e,r,"target",f.target,f,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Yo(""+l),e.setAttribute(a,l);break;case"onClick":l!=null&&(e.onclick=dr);break;case"onScroll":l!=null&&Ue("scroll",e);break;case"onScrollEnd":l!=null&&Ue("scrollend",e);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(i(61));if(a=l.__html,a!=null){if(f.children!=null)throw Error(i(60));e.innerHTML=a}}break;case"multiple":e.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":e.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){e.removeAttribute("xlink:href");break}a=Yo(""+l),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""+l):e.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":l===!0?e.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,l):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?e.setAttribute(a,l):e.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?e.removeAttribute(a):e.setAttribute(a,l);break;case"popover":Ue("beforetoggle",e),Ue("toggle",e),Gt(e,"popover",l);break;case"xlinkActuate":hr(e,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":hr(e,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":hr(e,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":hr(e,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":hr(e,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":hr(e,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":hr(e,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":hr(e,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":hr(e,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Gt(e,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Jv.get(a)||a,Gt(e,a,l))}}function jh(e,r,a,l,f,p){switch(a){case"style":Ym(e,l,p);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(i(61));if(a=l.__html,a!=null){if(f.children!=null)throw Error(i(60));e.innerHTML=a}}break;case"children":typeof l=="string"?li(e,l):(typeof l=="number"||typeof l=="bigint")&&li(e,""+l);break;case"onScroll":l!=null&&Ue("scroll",e);break;case"onScrollEnd":l!=null&&Ue("scrollend",e);break;case"onClick":l!=null&&(e.onclick=dr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!re.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(f=a.endsWith("Capture"),r=a.slice(2,f?a.length-7:void 0),p=e[gt]||null,p=p!=null?p[a]:null,typeof p=="function"&&e.removeEventListener(r,p,f),typeof l=="function")){typeof p!="function"&&p!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(r,l,f);break e}a in e?e[a]=l:l===!0?e.setAttribute(a,""):Gt(e,a,l)}}}function $t(e,r,a){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ue("error",e),Ue("load",e);var l=!1,f=!1,p;for(p in a)if(a.hasOwnProperty(p)){var _=a[p];if(_!=null)switch(p){case"src":l=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:st(e,r,p,_,a,null)}}f&&st(e,r,"srcSet",a.srcSet,a,null),l&&st(e,r,"src",a.src,a,null);return;case"input":Ue("invalid",e);var O=p=_=f=null,M=null,G=null;for(l in a)if(a.hasOwnProperty(l)){var Z=a[l];if(Z!=null)switch(l){case"name":f=Z;break;case"type":_=Z;break;case"checked":M=Z;break;case"defaultChecked":G=Z;break;case"value":p=Z;break;case"defaultValue":O=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(i(137,r));break;default:st(e,r,l,Z,a,null)}}Hm(e,p,O,M,G,_,f,!1);return;case"select":Ue("invalid",e),l=_=p=null;for(f in a)if(a.hasOwnProperty(f)&&(O=a[f],O!=null))switch(f){case"value":p=O;break;case"defaultValue":_=O;break;case"multiple":l=O;default:st(e,r,f,O,a,null)}r=p,a=_,e.multiple=!!l,r!=null?oi(e,!!l,r,!1):a!=null&&oi(e,!!l,a,!0);return;case"textarea":Ue("invalid",e),p=f=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(O=a[_],O!=null))switch(_){case"value":l=O;break;case"defaultValue":f=O;break;case"children":p=O;break;case"dangerouslySetInnerHTML":if(O!=null)throw Error(i(91));break;default:st(e,r,_,O,a,null)}Gm(e,l,f,p);return;case"option":for(M in a)if(a.hasOwnProperty(M)&&(l=a[M],l!=null))switch(M){case"selected":e.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:st(e,r,M,l,a,null)}return;case"dialog":Ue("beforetoggle",e),Ue("toggle",e),Ue("cancel",e),Ue("close",e);break;case"iframe":case"object":Ue("load",e);break;case"video":case"audio":for(l=0;l<Va.length;l++)Ue(Va[l],e);break;case"image":Ue("error",e),Ue("load",e);break;case"details":Ue("toggle",e);break;case"embed":case"source":case"link":Ue("error",e),Ue("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(G in a)if(a.hasOwnProperty(G)&&(l=a[G],l!=null))switch(G){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:st(e,r,G,l,a,null)}return;default:if(zu(r)){for(Z in a)a.hasOwnProperty(Z)&&(l=a[Z],l!==void 0&&jh(e,r,Z,l,a,void 0));return}}for(O in a)a.hasOwnProperty(O)&&(l=a[O],l!=null&&st(e,r,O,l,a,null))}function ww(e,r,a,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,p=null,_=null,O=null,M=null,G=null,Z=null;for(J in a){var se=a[J];if(a.hasOwnProperty(J)&&se!=null)switch(J){case"checked":break;case"value":break;case"defaultValue":M=se;default:l.hasOwnProperty(J)||st(e,r,J,null,l,se)}}for(var Y in l){var J=l[Y];if(se=a[Y],l.hasOwnProperty(Y)&&(J!=null||se!=null))switch(Y){case"type":p=J;break;case"name":f=J;break;case"checked":G=J;break;case"defaultChecked":Z=J;break;case"value":_=J;break;case"defaultValue":O=J;break;case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(i(137,r));break;default:J!==se&&st(e,r,Y,J,l,se)}}Pu(e,_,O,M,G,Z,p,f);return;case"select":J=_=O=Y=null;for(p in a)if(M=a[p],a.hasOwnProperty(p)&&M!=null)switch(p){case"value":break;case"multiple":J=M;default:l.hasOwnProperty(p)||st(e,r,p,null,l,M)}for(f in l)if(p=l[f],M=a[f],l.hasOwnProperty(f)&&(p!=null||M!=null))switch(f){case"value":Y=p;break;case"defaultValue":O=p;break;case"multiple":_=p;default:p!==M&&st(e,r,f,p,l,M)}r=O,a=_,l=J,Y!=null?oi(e,!!a,Y,!1):!!l!=!!a&&(r!=null?oi(e,!!a,r,!0):oi(e,!!a,a?[]:"",!1));return;case"textarea":J=Y=null;for(O in a)if(f=a[O],a.hasOwnProperty(O)&&f!=null&&!l.hasOwnProperty(O))switch(O){case"value":break;case"children":break;default:st(e,r,O,null,l,f)}for(_ in l)if(f=l[_],p=a[_],l.hasOwnProperty(_)&&(f!=null||p!=null))switch(_){case"value":Y=f;break;case"defaultValue":J=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(i(91));break;default:f!==p&&st(e,r,_,f,l,p)}Fm(e,Y,J);return;case"option":for(var be in a)if(Y=a[be],a.hasOwnProperty(be)&&Y!=null&&!l.hasOwnProperty(be))switch(be){case"selected":e.selected=!1;break;default:st(e,r,be,null,l,Y)}for(M in l)if(Y=l[M],J=a[M],l.hasOwnProperty(M)&&Y!==J&&(Y!=null||J!=null))switch(M){case"selected":e.selected=Y&&typeof Y!="function"&&typeof Y!="symbol";break;default:st(e,r,M,Y,l,J)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Te in a)Y=a[Te],a.hasOwnProperty(Te)&&Y!=null&&!l.hasOwnProperty(Te)&&st(e,r,Te,null,l,Y);for(G in l)if(Y=l[G],J=a[G],l.hasOwnProperty(G)&&Y!==J&&(Y!=null||J!=null))switch(G){case"children":case"dangerouslySetInnerHTML":if(Y!=null)throw Error(i(137,r));break;default:st(e,r,G,Y,l,J)}return;default:if(zu(r)){for(var it in a)Y=a[it],a.hasOwnProperty(it)&&Y!==void 0&&!l.hasOwnProperty(it)&&jh(e,r,it,void 0,l,Y);for(Z in l)Y=l[Z],J=a[Z],!l.hasOwnProperty(Z)||Y===J||Y===void 0&&J===void 0||jh(e,r,Z,Y,l,J);return}}for(var U in a)Y=a[U],a.hasOwnProperty(U)&&Y!=null&&!l.hasOwnProperty(U)&&st(e,r,U,null,l,Y);for(se in l)Y=l[se],J=a[se],!l.hasOwnProperty(se)||Y===J||Y==null&&J==null||st(e,r,se,Y,l,J)}function Ky(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Sw(){if(typeof performance.getEntriesByType=="function"){for(var e=0,r=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var f=a[l],p=f.transferSize,_=f.initiatorType,O=f.duration;if(p&&O&&Ky(_)){for(_=0,O=f.responseEnd,l+=1;l<a.length;l++){var M=a[l],G=M.startTime;if(G>O)break;var Z=M.transferSize,se=M.initiatorType;Z&&Ky(se)&&(M=M.responseEnd,_+=Z*(M<O?1:(O-G)/(M-G)))}if(--l,r+=8*(p+_)/(f.duration/1e3),e++,10<e)break}}if(0<e)return r/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var kh=null,Nh=null;function $l(e){return e.nodeType===9?e:e.ownerDocument}function Jy(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Xy(e,r){if(e===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&r==="foreignObject"?0:e}function Th(e,r){return e==="textarea"||e==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Ch=null;function Ew(){var e=window.event;return e&&e.type==="popstate"?e===Ch?!1:(Ch=e,!0):(Ch=null,!1)}var Qy=typeof setTimeout=="function"?setTimeout:void 0,Ow=typeof clearTimeout=="function"?clearTimeout:void 0,Wy=typeof Promise=="function"?Promise:void 0,Aw=typeof queueMicrotask=="function"?queueMicrotask:typeof Wy<"u"?function(e){return Wy.resolve(null).then(e).catch(jw)}:Qy;function jw(e){setTimeout(function(){throw e})}function ls(e){return e==="head"}function Zy(e,r){var a=r,l=0;do{var f=a.nextSibling;if(e.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"||a==="/&"){if(l===0){e.removeChild(f),Ui(r);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Ka(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Ka(a);for(var p=a.firstChild;p;){var _=p.nextSibling,O=p.nodeName;p[Mt]||O==="SCRIPT"||O==="STYLE"||O==="LINK"&&p.rel.toLowerCase()==="stylesheet"||a.removeChild(p),p=_}}else a==="body"&&Ka(e.ownerDocument.body);a=f}while(a);Ui(r)}function eg(e,r){var a=e;e=0;do{var l=a.nextSibling;if(a.nodeType===1?r?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(r?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=l}while(a)}function Mh(e){var r=e.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var a=r;switch(r=r.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Mh(a),ai(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function kw(e,r,a,l){for(;e.nodeType===1;){var f=a;if(e.nodeName.toLowerCase()!==r.toLowerCase()){if(!l&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(l){if(!e[Mt])switch(r){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(p=e.getAttribute("rel"),p==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(p!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(p=e.getAttribute("src"),(p!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&p&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(r==="input"&&e.type==="hidden"){var p=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===p)return e}else return e;if(e=Bn(e.nextSibling),e===null)break}return null}function Nw(e,r,a){if(r==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=Bn(e.nextSibling),e===null))return null;return e}function tg(e,r){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=Bn(e.nextSibling),e===null))return null;return e}function Rh(e){return e.data==="$?"||e.data==="$~"}function Dh(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Tw(e,r){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=r;else if(e.data!=="$?"||a.readyState!=="loading")r();else{var l=function(){r(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}function Bn(e){for(;e!=null;e=e.nextSibling){var r=e.nodeType;if(r===1||r===3)break;if(r===8){if(r=e.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return e}var Lh=null;function ng(e){e=e.nextSibling;for(var r=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(r===0)return Bn(e.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}e=e.nextSibling}return null}function rg(e){e=e.previousSibling;for(var r=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(r===0)return e;r--}else a!=="/$"&&a!=="/&"||r++}e=e.previousSibling}return null}function sg(e,r,a){switch(r=$l(a),e){case"html":if(e=r.documentElement,!e)throw Error(i(452));return e;case"head":if(e=r.head,!e)throw Error(i(453));return e;case"body":if(e=r.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Ka(e){for(var r=e.attributes;r.length;)e.removeAttributeNode(r[0]);ai(e)}var Pn=new Map,ig=new Set;function Hl(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Nr=W.d;W.d={f:Cw,r:Mw,D:Rw,C:Dw,L:Lw,m:qw,X:Pw,S:Bw,M:Uw};function Cw(){var e=Nr.f(),r=Dl();return e||r}function Mw(e){var r=N(e);r!==null&&r.tag===5&&r.type==="form"?wp(r):Nr.r(e)}var qi=typeof document>"u"?null:document;function ag(e,r,a){var l=qi;if(l&&typeof r=="string"&&r){var f=Tn(r);f='link[rel="'+e+'"][href="'+f+'"]',typeof a=="string"&&(f+='[crossorigin="'+a+'"]'),ig.has(f)||(ig.add(f),e={rel:e,crossOrigin:a,href:r},l.querySelector(f)===null&&(r=l.createElement("link"),$t(r,"link",e),L(r),l.head.appendChild(r)))}}function Rw(e){Nr.D(e),ag("dns-prefetch",e,null)}function Dw(e,r){Nr.C(e,r),ag("preconnect",e,r)}function Lw(e,r,a){Nr.L(e,r,a);var l=qi;if(l&&e&&r){var f='link[rel="preload"][as="'+Tn(r)+'"]';r==="image"&&a&&a.imageSrcSet?(f+='[imagesrcset="'+Tn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(f+='[imagesizes="'+Tn(a.imageSizes)+'"]')):f+='[href="'+Tn(e)+'"]';var p=f;switch(r){case"style":p=Bi(e);break;case"script":p=Pi(e)}Pn.has(p)||(e=b({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:e,as:r},a),Pn.set(p,e),l.querySelector(f)!==null||r==="style"&&l.querySelector(Ja(p))||r==="script"&&l.querySelector(Xa(p))||(r=l.createElement("link"),$t(r,"link",e),L(r),l.head.appendChild(r)))}}function qw(e,r){Nr.m(e,r);var a=qi;if(a&&e){var l=r&&typeof r.as=="string"?r.as:"script",f='link[rel="modulepreload"][as="'+Tn(l)+'"][href="'+Tn(e)+'"]',p=f;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=Pi(e)}if(!Pn.has(p)&&(e=b({rel:"modulepreload",href:e},r),Pn.set(p,e),a.querySelector(f)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Xa(p)))return}l=a.createElement("link"),$t(l,"link",e),L(l),a.head.appendChild(l)}}}function Bw(e,r,a){Nr.S(e,r,a);var l=qi;if(l&&e){var f=T(l).hoistableStyles,p=Bi(e);r=r||"default";var _=f.get(p);if(!_){var O={loading:0,preload:null};if(_=l.querySelector(Ja(p)))O.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":r},a),(a=Pn.get(p))&&qh(e,a);var M=_=l.createElement("link");L(M),$t(M,"link",e),M._p=new Promise(function(G,Z){M.onload=G,M.onerror=Z}),M.addEventListener("load",function(){O.loading|=1}),M.addEventListener("error",function(){O.loading|=2}),O.loading|=4,Fl(_,r,l)}_={type:"stylesheet",instance:_,count:1,state:O},f.set(p,_)}}}function Pw(e,r){Nr.X(e,r);var a=qi;if(a&&e){var l=T(a).hoistableScripts,f=Pi(e),p=l.get(f);p||(p=a.querySelector(Xa(f)),p||(e=b({src:e,async:!0},r),(r=Pn.get(f))&&Bh(e,r),p=a.createElement("script"),L(p),$t(p,"link",e),a.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},l.set(f,p))}}function Uw(e,r){Nr.M(e,r);var a=qi;if(a&&e){var l=T(a).hoistableScripts,f=Pi(e),p=l.get(f);p||(p=a.querySelector(Xa(f)),p||(e=b({src:e,async:!0,type:"module"},r),(r=Pn.get(f))&&Bh(e,r),p=a.createElement("script"),L(p),$t(p,"link",e),a.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},l.set(f,p))}}function og(e,r,a,l){var f=(f=Ct.current)?Hl(f):null;if(!f)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(r=Bi(a.href),a=T(f).hoistableStyles,l=a.get(r),l||(l={type:"style",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Bi(a.href);var p=T(f).hoistableStyles,_=p.get(e);if(_||(f=f.ownerDocument||f,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(e,_),(p=f.querySelector(Ja(e)))&&!p._p&&(_.instance=p,_.state.loading=5),Pn.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Pn.set(e,a),p||zw(f,e,a,_.state))),r&&l===null)throw Error(i(528,""));return _}if(r&&l!==null)throw Error(i(529,""));return null;case"script":return r=a.async,a=a.src,typeof a=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Pi(a),a=T(f).hoistableScripts,l=a.get(r),l||(l={type:"script",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Bi(e){return'href="'+Tn(e)+'"'}function Ja(e){return'link[rel="stylesheet"]['+e+"]"}function lg(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function zw(e,r,a,l){e.querySelector('link[rel="preload"][as="style"]['+r+"]")?l.loading=1:(r=e.createElement("link"),l.preload=r,r.addEventListener("load",function(){return l.loading|=1}),r.addEventListener("error",function(){return l.loading|=2}),$t(r,"link",a),L(r),e.head.appendChild(r))}function Pi(e){return'[src="'+Tn(e)+'"]'}function Xa(e){return"script[async]"+e}function cg(e,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var l=e.querySelector('style[data-href~="'+Tn(a.href)+'"]');if(l)return r.instance=l,L(l),l;var f=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(e.ownerDocument||e).createElement("style"),L(l),$t(l,"style",f),Fl(l,a.precedence,e),r.instance=l;case"stylesheet":f=Bi(a.href);var p=e.querySelector(Ja(f));if(p)return r.state.loading|=4,r.instance=p,L(p),p;l=lg(a),(f=Pn.get(f))&&qh(l,f),p=(e.ownerDocument||e).createElement("link"),L(p);var _=p;return _._p=new Promise(function(O,M){_.onload=O,_.onerror=M}),$t(p,"link",l),r.state.loading|=4,Fl(p,a.precedence,e),r.instance=p;case"script":return p=Pi(a.src),(f=e.querySelector(Xa(p)))?(r.instance=f,L(f),f):(l=a,(f=Pn.get(p))&&(l=b({},a),Bh(l,f)),e=e.ownerDocument||e,f=e.createElement("script"),L(f),$t(f,"link",l),e.head.appendChild(f),r.instance=f);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(l=r.instance,r.state.loading|=4,Fl(l,a.precedence,e));return r.instance}function Fl(e,r,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=l.length?l[l.length-1]:null,p=f,_=0;_<l.length;_++){var O=l[_];if(O.dataset.precedence===r)p=O;else if(p!==f)break}p?p.parentNode.insertBefore(e,p.nextSibling):(r=a.nodeType===9?a.head:a,r.insertBefore(e,r.firstChild))}function qh(e,r){e.crossOrigin==null&&(e.crossOrigin=r.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=r.referrerPolicy),e.title==null&&(e.title=r.title)}function Bh(e,r){e.crossOrigin==null&&(e.crossOrigin=r.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=r.referrerPolicy),e.integrity==null&&(e.integrity=r.integrity)}var Gl=null;function ug(e,r,a){if(Gl===null){var l=new Map,f=Gl=new Map;f.set(a,l)}else f=Gl,l=f.get(a),l||(l=new Map,f.set(a,l));if(l.has(e))return l;for(l.set(e,null),a=a.getElementsByTagName(e),f=0;f<a.length;f++){var p=a[f];if(!(p[Mt]||p[at]||e==="link"&&p.getAttribute("rel")==="stylesheet")&&p.namespaceURI!=="http://www.w3.org/2000/svg"){var _=p.getAttribute(r)||"";_=e+_;var O=l.get(_);O?O.push(p):l.set(_,[p])}}return l}function fg(e,r,a){e=e.ownerDocument||e,e.head.insertBefore(a,r==="title"?e.querySelector("head > title"):null)}function Iw(e,r,a){if(a===1||r.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return e=r.disabled,typeof r.precedence=="string"&&e==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function hg(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function $w(e,r,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var f=Bi(l.href),p=r.querySelector(Ja(f));if(p){r=p._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(e.count++,e=Vl.bind(e),r.then(e,e)),a.state.loading|=4,a.instance=p,L(p);return}p=r.ownerDocument||r,l=lg(l),(f=Pn.get(f))&&qh(l,f),p=p.createElement("link"),L(p);var _=p;_._p=new Promise(function(O,M){_.onload=O,_.onerror=M}),$t(p,"link",l),a.instance=p}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,r),(r=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=Vl.bind(e),r.addEventListener("load",a),r.addEventListener("error",a))}}var Ph=0;function Hw(e,r){return e.stylesheets&&e.count===0&&Kl(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var l=setTimeout(function(){if(e.stylesheets&&Kl(e,e.stylesheets),e.unsuspend){var p=e.unsuspend;e.unsuspend=null,p()}},6e4+r);0<e.imgBytes&&Ph===0&&(Ph=62500*Sw());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Kl(e,e.stylesheets),e.unsuspend)){var p=e.unsuspend;e.unsuspend=null,p()}},(e.imgBytes>Ph?50:800)+r);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(f)}}:null}function Vl(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Kl(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yl=null;function Kl(e,r){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yl=new Map,r.forEach(Fw,e),Yl=null,Vl.call(e))}function Fw(e,r){if(!(r.state.loading&4)){var a=Yl.get(e);if(a)var l=a.get(null);else{a=new Map,Yl.set(e,a);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p<f.length;p++){var _=f[p];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}f=r.instance,_=f.getAttribute("data-precedence"),p=a.get(_)||l,p===l&&a.set(null,f),a.set(_,f),this.count++,l=Vl.bind(this),f.addEventListener("load",l),f.addEventListener("error",l),p?p.parentNode.insertBefore(f,p.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),r.state.loading|=4}}var Qa={$$typeof:ie,Provider:null,Consumer:null,_currentValue:ce,_currentValue2:ce,_threadCount:0};function Gw(e,r,a,l,f,p,_,O,M){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ir(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ir(0),this.hiddenUpdates=Ir(null),this.identifierPrefix=l,this.onUncaughtError=f,this.onCaughtError=p,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=M,this.incompleteTransitions=new Map}function dg(e,r,a,l,f,p,_,O,M,G,Z,se){return e=new Gw(e,r,a,_,M,G,Z,se,O),r=1,p===!0&&(r|=24),p=hn(3,null,null,r),e.current=p,p.stateNode=e,r=gf(),r.refCount++,e.pooledCache=r,r.refCount++,p.memoizedState={element:l,isDehydrated:a,cache:r},_f(p),e}function mg(e){return e?(e=pi,e):pi}function pg(e,r,a,l,f,p){f=mg(f),l.context===null?l.context=f:l.pendingContext=f,l=Qr(r),l.payload={element:a},p=p===void 0?null:p,p!==null&&(l.callback=p),a=Wr(e,l,r),a!==null&&(sn(a,e,r),Na(a,e,r))}function yg(e,r){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<r?a:r}}function Uh(e,r){yg(e,r),(e=e.alternate)&&yg(e,r)}function gg(e){if(e.tag===13||e.tag===31){var r=Ls(e,67108864);r!==null&&sn(r,e,67108864),Uh(e,67108864)}}function bg(e){if(e.tag===13||e.tag===31){var r=gn();r=fr(r);var a=Ls(e,r);a!==null&&sn(a,e,r),Uh(e,r)}}var Jl=!0;function Vw(e,r,a,l){var f=H.T;H.T=null;var p=W.p;try{W.p=2,zh(e,r,a,l)}finally{W.p=p,H.T=f}}function Yw(e,r,a,l){var f=H.T;H.T=null;var p=W.p;try{W.p=8,zh(e,r,a,l)}finally{W.p=p,H.T=f}}function zh(e,r,a,l){if(Jl){var f=Ih(l);if(f===null)Ah(e,r,l,Xl,a),vg(e,l);else if(Jw(f,e,r,a,l))l.stopPropagation();else if(vg(e,l),r&4&&-1<Kw.indexOf(e)){for(;f!==null;){var p=N(f);if(p!==null)switch(p.tag){case 3:if(p=p.stateNode,p.current.memoizedState.isDehydrated){var _=$n(p.pendingLanes);if(_!==0){var O=p;for(O.pendingLanes|=2,O.entangledLanes|=2;_;){var M=1<<31-Ft(_);O.entanglements[1]|=M,_&=~M}sr(p),(Qe&6)===0&&(Ml=ht()+500,Ga(0))}}break;case 31:case 13:O=Ls(p,2),O!==null&&sn(O,p,2),Dl(),Uh(p,2)}if(p=Ih(l),p===null&&Ah(e,r,l,Xl,a),p===f)break;f=p}f!==null&&l.stopPropagation()}else Ah(e,r,l,null,a)}}function Ih(e){return e=$u(e),$h(e)}var Xl=null;function $h(e){if(Xl=null,e=A(e),e!==null){var r=c(e);if(r===null)e=null;else{var a=r.tag;if(a===13){if(e=m(r),e!==null)return e;e=null}else if(a===31){if(e=y(r),e!==null)return e;e=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;e=null}else r!==e&&(e=null)}}return Xl=e,null}function xg(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Du()){case Uo:return 2;case zo:return 8;case ri:case Lu:return 32;case Io:return 268435456;default:return 32}default:return 32}}var Hh=!1,cs=null,us=null,fs=null,Wa=new Map,Za=new Map,hs=[],Kw="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function vg(e,r){switch(e){case"focusin":case"focusout":cs=null;break;case"dragenter":case"dragleave":us=null;break;case"mouseover":case"mouseout":fs=null;break;case"pointerover":case"pointerout":Wa.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Za.delete(r.pointerId)}}function eo(e,r,a,l,f,p){return e===null||e.nativeEvent!==p?(e={blockedOn:r,domEventName:a,eventSystemFlags:l,nativeEvent:p,targetContainers:[f]},r!==null&&(r=N(r),r!==null&&gg(r)),e):(e.eventSystemFlags|=l,r=e.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),e)}function Jw(e,r,a,l,f){switch(r){case"focusin":return cs=eo(cs,e,r,a,l,f),!0;case"dragenter":return us=eo(us,e,r,a,l,f),!0;case"mouseover":return fs=eo(fs,e,r,a,l,f),!0;case"pointerover":var p=f.pointerId;return Wa.set(p,eo(Wa.get(p)||null,e,r,a,l,f)),!0;case"gotpointercapture":return p=f.pointerId,Za.set(p,eo(Za.get(p)||null,e,r,a,l,f)),!0}return!1}function _g(e){var r=A(e.target);if(r!==null){var a=c(r);if(a!==null){if(r=a.tag,r===13){if(r=m(a),r!==null){e.blockedOn=r,Ho(e.priority,function(){bg(a)});return}}else if(r===31){if(r=y(a),r!==null){e.blockedOn=r,Ho(e.priority,function(){bg(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ql(e){if(e.blockedOn!==null)return!1;for(var r=e.targetContainers;0<r.length;){var a=Ih(e.nativeEvent);if(a===null){a=e.nativeEvent;var l=new a.constructor(a.type,a);Iu=l,a.target.dispatchEvent(l),Iu=null}else return r=N(a),r!==null&&gg(r),e.blockedOn=a,!1;r.shift()}return!0}function wg(e,r,a){Ql(e)&&a.delete(r)}function Xw(){Hh=!1,cs!==null&&Ql(cs)&&(cs=null),us!==null&&Ql(us)&&(us=null),fs!==null&&Ql(fs)&&(fs=null),Wa.forEach(wg),Za.forEach(wg)}function Wl(e,r){e.blockedOn===r&&(e.blockedOn=null,Hh||(Hh=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Xw)))}var Zl=null;function Sg(e){Zl!==e&&(Zl=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Zl===e&&(Zl=null);for(var r=0;r<e.length;r+=3){var a=e[r],l=e[r+1],f=e[r+2];if(typeof l!="function"){if($h(l||a)===null)continue;break}var p=N(a);p!==null&&(e.splice(r,3),r-=3,If(p,{pending:!0,data:f,method:a.method,action:l},l,f))}}))}function Ui(e){function r(M){return Wl(M,e)}cs!==null&&Wl(cs,e),us!==null&&Wl(us,e),fs!==null&&Wl(fs,e),Wa.forEach(r),Za.forEach(r);for(var a=0;a<hs.length;a++){var l=hs[a];l.blockedOn===e&&(l.blockedOn=null)}for(;0<hs.length&&(a=hs[0],a.blockedOn===null);)_g(a),a.blockedOn===null&&hs.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var f=a[l],p=a[l+1],_=f[gt]||null;if(typeof p=="function")_||Sg(a);else if(_){var O=null;if(p&&p.hasAttribute("formAction")){if(f=p,_=p[gt]||null)O=_.formAction;else if($h(f)!==null)continue}else O=_.action;typeof O=="function"?a[l+1]=O:(a.splice(l,3),l-=3),Sg(a)}}}function Eg(){function e(p){p.canIntercept&&p.info==="react-transition"&&p.intercept({handler:function(){return new Promise(function(_){return f=_})},focusReset:"manual",scroll:"manual"})}function r(){f!==null&&(f(),f=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var p=navigation.currentEntry;p&&p.url!=null&&navigation.navigate(p.url,{state:p.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),f!==null&&(f(),f=null)}}}function Fh(e){this._internalRoot=e}ec.prototype.render=Fh.prototype.render=function(e){var r=this._internalRoot;if(r===null)throw Error(i(409));var a=r.current,l=gn();pg(a,l,e,r,null,null)},ec.prototype.unmount=Fh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var r=e.containerInfo;pg(e.current,2,null,e,null,null),Dl(),r[un]=null}};function ec(e){this._internalRoot=e}ec.prototype.unstable_scheduleHydration=function(e){if(e){var r=ha();e={blockedOn:null,target:e,priority:r};for(var a=0;a<hs.length&&r!==0&&r<hs[a].priority;a++);hs.splice(a,0,e),a===0&&_g(e)}};var Og=t.version;if(Og!=="19.2.4")throw Error(i(527,Og,"19.2.4"));W.findDOMNode=function(e){var r=e._reactInternals;if(r===void 0)throw typeof e.render=="function"?Error(i(188)):(e=Object.keys(e).join(","),Error(i(268,e)));return e=u(r),e=e!==null?d(e):null,e=e===null?null:e.stateNode,e};var Qw={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:H,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var tc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!tc.isDisabled&&tc.supportsFiber)try{As=tc.inject(Qw),_t=tc}catch{}}return to.createRoot=function(e,r){if(!o(e))throw Error(i(299));var a=!1,l="",f=Mp,p=Rp,_=Dp;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(l=r.identifierPrefix),r.onUncaughtError!==void 0&&(f=r.onUncaughtError),r.onCaughtError!==void 0&&(p=r.onCaughtError),r.onRecoverableError!==void 0&&(_=r.onRecoverableError)),r=dg(e,1,!1,null,null,a,l,null,f,p,_,Eg),e[un]=r.current,Oh(e),new Fh(r)},to.hydrateRoot=function(e,r,a){if(!o(e))throw Error(i(299));var l=!1,f="",p=Mp,_=Rp,O=Dp,M=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(f=a.identifierPrefix),a.onUncaughtError!==void 0&&(p=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(O=a.onRecoverableError),a.formState!==void 0&&(M=a.formState)),r=dg(e,1,!0,r,a??null,l,f,M,p,_,O,Eg),r.context=mg(null),a=r.current,l=gn(),l=fr(l),f=Qr(l),f.callback=null,Wr(a,f,l),a=l,r.current.lanes=a,Hn(r,a),sr(r),e[un]=r.current,Oh(e),new ec(r)},to.version="19.2.4",to}var Mg;function IS(){if(Mg)return Gh.exports;Mg=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(t){console.error(t)}}return n(),Gh.exports=zS(),Gh.exports}var $S=IS();const HS="modulepreload",FS=function(n,t){return new URL(n,t).href},Rg={},je=function(t,s,i){let o=Promise.resolve();if(s&&s.length>0){let m=function(d){return Promise.all(d.map(b=>Promise.resolve(b).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};const y=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),u=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));o=m(s.map(d=>{if(d=FS(d,i),d in Rg)return;Rg[d]=!0;const b=d.endsWith(".css"),x=b?'[rel="stylesheet"]':"";if(!!i)for(let S=y.length-1;S>=0;S--){const C=y[S];if(C.href===d&&(!b||C.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${x}`))return;const w=document.createElement("link");if(w.rel=b?"stylesheet":HS,b||(w.as="script"),w.crossOrigin="",w.href=d,u&&w.setAttribute("nonce",u),document.head.appendChild(w),b)return new Promise((S,C)=>{w.addEventListener("load",S),w.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${d}`)))})}))}function c(m){const y=new Event("vite:preloadError",{cancelable:!0});if(y.payload=m,window.dispatchEvent(y),!y.defaultPrevented)throw m}return o.then(m=>{for(const y of m||[])y.status==="rejected"&&c(y.reason);return t().catch(c)})};function wu(n){try{const t=n.split(".");if(t.length!==3)return null;const s=atob(t[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(s)}catch{return null}}function lx(n){const t=wu(n);return!t||typeof t.exp!="number"?null:t.exp}function tm(n,t=0){const s=lx(n);return s===null?!0:Date.now()/1e3>=s-t}const Ht=window.__LT_BASE__??"",yd=`${Ht}/api`;class Dg extends Error{constructor(t,s,i){super(t),this.status=s,this.body=i,this.name="ApiError"}}let gs=null;function nc(n){gs=n}function cx(){return gs}const GS="X-LT-Acting-Token",VS="X-LT-Acting-Remaining";let Zc=null,eu=null;function Lg(n){Zc=n}let tu=null;function qg(n){tu=n}function Bg(n){eu=n}function YS(n){const t=n==null?void 0:n.error;return typeof t=="string"&&/acting[- ]identity/i.test(t)}async function Pg(){const n=sessionStorage.getItem("lt_credentials");if(!n)return null;try{const{username:t,password:s}=JSON.parse(n),i=await fetch(`${yd}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})});if(!i.ok)return null;const o=await i.json();return o.token&&o.user&&sessionStorage.setItem("lt_user_info",JSON.stringify({displayName:o.user.display_name,username:o.user.external_id})),o.token??null}catch{return null}}let ms=null;async function fe(n,t={}){const s={"Content-Type":"application/json",...t.headers};if(gs){if(tm(gs)){ms||(ms=Pg().finally(()=>{ms=null}));const y=await ms;if(y)gs=y,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:y}}));else throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}s.Authorization=`Bearer ${gs}`}const o=(t.method??"GET").toUpperCase()==="GET"?null:(Zc==null?void 0:Zc())??null;o&&(s[GS]=o);let c=await fetch(`${yd}${n}`,{...t,headers:s});const m=o?c.headers.get(VS):null;if(o&&m!==null&&(tu==null||tu(o,m==="unbounded"?null:Number(m))),c.status===401&&o){const y=await c.clone().json().catch(()=>null);if(YS(y))throw eu==null||eu(),new Dg(y.error,401,y)}if(c.status===401&&gs){ms||(ms=Pg().finally(()=>{ms=null}));const y=await ms;if(y&&(gs=y,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:y}})),s.Authorization=`Bearer ${y}`,c=await fetch(`${yd}${n}`,{...t,headers:s})),c.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}else if(c.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired");if(!c.ok){const y=await c.json().catch(()=>({error:c.statusText}));throw new Dg(y.message||y.error||c.statusText,c.status,y)}return c.json()}const KS="lt_ai_override";let rc=null;function nm(){return rc||(rc=fetch(`${Ht}/api/settings`).then(n=>{if(!n.ok)throw new Error(`settings ${n.status}`);return n.json()}).catch(n=>{throw rc=null,n})),rc}function JS(){try{if(localStorage.getItem(KS)==="off")return!1}catch{}return null}function Zn(){var s;const n=$e({queryKey:["settings"],queryFn:nm,staleTime:1/0}),t=JS();return n.data&&t===!1&&((s=n.data.ai)!=null&&s.enabled)?{...n,data:{...n.data,ai:{enabled:!1}}}:n}function XS(n){var u,d,b;const{data:t}=Zn(),s=((u=t==null?void 0:t.auth)==null?void 0:u.ssoKeepaliveSeconds)??0,i=((d=t==null?void 0:t.auth)==null?void 0:d.ssoKeepaliveIdleTimeoutSeconds)??0,o=E.useRef(Date.now()),c=E.useRef(Date.now()),m=E.useRef(!1),g=!!n&&((b=wu(n))==null?void 0:b.sso)===!0&&s>0;E.useEffect(()=>{if(!g)return;const x=()=>{o.current=Date.now()};window.addEventListener("pointerdown",x,{passive:!0}),window.addEventListener("keydown",x,{passive:!0}),window.addEventListener("wheel",x,{passive:!0});const v=async()=>{if(!m.current&&document.visibilityState==="visible"&&!(i>0&&Date.now()-o.current>i*1e3)){m.current=!0;try{const C=await fetch(`${Ht}/api/auth/sso`,{method:"POST"});if(C.status===401||C.status===403){window.dispatchEvent(new CustomEvent("auth:unauthorized"));return}if(!C.ok)return;const q=await C.json().catch(()=>null);q!=null&&q.token&&(c.current=Date.now(),window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:q.token}})))}catch{}finally{m.current=!1}}},w=setInterval(v,s*1e3),S=()=>{document.visibilityState==="visible"&&Date.now()-c.current>s*1e3&&v()};return document.addEventListener("visibilitychange",S),()=>{clearInterval(w),document.removeEventListener("visibilitychange",S),window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",x),window.removeEventListener("wheel",x)}},[g,s,i])}const ux=E.createContext(null),QS=300;function Kh(n,t){if(tm(n))return null;const s=wu(n);if(!s)return null;const i=t??(()=>{try{const o=sessionStorage.getItem("lt_user_info");return o?JSON.parse(o):null}catch{return null}})();return{userId:s.userId,displayName:(i==null?void 0:i.displayName)??null,username:(i==null?void 0:i.username)??null,roles:s.roles??[]}}function WS({children:n}){const[t,s]=E.useState(()=>{const b=sessionStorage.getItem("lt_token");return b?tm(b)?(sessionStorage.removeItem("lt_token"),null):(nc(b),Kh(b)):null}),i=E.useRef(void 0),o=E.useCallback(b=>{clearTimeout(i.current);const x=lx(b);if(!x)return;const v=(x-QS)*1e3-Date.now();v<=0||(i.current=setTimeout(async()=>{try{const w=wu(b);if(w!=null&&w.sso){const le=await fetch(`${Ht}/api/auth/sso`,{method:"POST"});if(!le.ok)return;const R=await le.json();R.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:R.token}}));return}const S=sessionStorage.getItem("lt_credentials");if(!S)return;const{username:C,password:q}=JSON.parse(S),B=await fetch(`${Ht}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:C,password:q})});if(!B.ok)return;const ie=await B.json();ie.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:ie.token}}))}catch{}},v))},[]),c=E.useCallback((b,x,v)=>{const w={displayName:(v==null?void 0:v.displayName)??null,username:(v==null?void 0:v.username)??(x==null?void 0:x.username)??null},S=Kh(b,w);S&&(nc(b),sessionStorage.setItem("lt_token",b),sessionStorage.setItem("lt_user_info",JSON.stringify(w)),x&&sessionStorage.setItem("lt_credentials",JSON.stringify(x)),s(S),o(b))},[o]),m=E.useCallback(()=>{clearTimeout(i.current);const b=sessionStorage.getItem("lt_sso_logout_url");nc(null),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info"),sessionStorage.removeItem("lt_sso_logout_url"),s(null),b&&(window.location.href=b)},[]);E.useEffect(()=>{const b=()=>m(),x=v=>{var C;const w=(C=v.detail)==null?void 0:C.token;if(!w)return;const S=Kh(w);S&&(nc(w),sessionStorage.setItem("lt_token",w),s(S),o(w))};return window.addEventListener("auth:unauthorized",b),window.addEventListener("auth:refreshed",x),()=>{window.removeEventListener("auth:unauthorized",b),window.removeEventListener("auth:refreshed",x)}},[m,o]),E.useEffect(()=>{const b=sessionStorage.getItem("lt_token");return b&&t&&o(b),()=>clearTimeout(i.current)},[]);const y=(t==null?void 0:t.roles.some(b=>b.type==="superadmin"))??!1,g=E.useCallback(b=>(t==null?void 0:t.roles.some(x=>x.role===b))??!1,[t]),u=E.useCallback(b=>(t==null?void 0:t.roles.some(x=>x.type===b))??!1,[t]),d=(t==null?void 0:t.roles.map(b=>b.role))??[];return h.jsxs(ux.Provider,{value:{user:t,isAuthenticated:!!t,isSuperAdmin:y,login:c,logout:m,hasRole:g,hasRoleType:u,userRoleNames:d},children:[h.jsx(ZS,{authenticated:t!==null}),n]})}function ZS({authenticated:n}){return XS(n?sessionStorage.getItem("lt_token"):null),null}function Pt(){const n=E.useContext(ux);if(!n)throw new Error("useAuth must be used within AuthProvider");return n}const An=new Uint8Array(0),ei=new TextEncoder,Sn=new TextDecoder;function eE(...n){let t=0;for(let o=0;o<n.length;o++)t+=n[o].length;const s=new Uint8Array(t);let i=0;for(let o=0;o<n.length;o++)s.set(n[o],i),i+=n[o].length;return s}function go(...n){const t=[];for(let s=0;s<n.length;s++)t.push(ei.encode(n[s]));return t.length===0?An:t.length===1?t[0]:eE(...t)}function Ug(n){return!n||n.length===0?"":Sn.decode(n)}const zg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ig=36,tE=0xcfd41b9100000,$g=33,nE=333,Hg=22;function rE(n){for(let t=0;t<n.length;t++)n[t]=Math.floor(Math.random()*255)}function sE(n){var t;(t=globalThis==null?void 0:globalThis.crypto)!=null&&t.getRandomValues?globalThis.crypto.getRandomValues(n):rE(n)}class iE{constructor(){j(this,"buf");j(this,"seq");j(this,"inc");j(this,"inited");this.buf=new Uint8Array(Hg),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*tE),this.inc=Math.floor(Math.random()*(nE-$g)+$g)}setPre(){const t=new Uint8Array(12);sE(t);for(let s=0;s<12;s++){const i=t[s]%36;this.buf[s]=zg.charCodeAt(i)}}fillSeq(){let t=this.seq;for(let s=Hg-1;s>=12;s--)this.buf[s]=zg.charCodeAt(t%Ig),t=Math.floor(t/Ig)}next(){return this.inited||this.init(),this.seq+=this.inc,this.seq>0xcfd41b9100000&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)}reset(){this.init()}}const Es=new iE;var Mr;(function(n){n.Disconnect="disconnect",n.Reconnect="reconnect",n.Update="update",n.LDM="ldm",n.Error="error"})(Mr||(Mr={}));var Yi;(function(n){n.Reconnecting="reconnecting",n.PingTimer="pingTimer",n.StaleConnection="staleConnection",n.ClientInitiatedReconnect="client initiated reconnect"})(Yi||(Yi={}));var ue;(function(n){n.ApiError="BAD API",n.BadAuthentication="BAD_AUTHENTICATION",n.BadCreds="BAD_CREDS",n.BadHeader="BAD_HEADER",n.BadJson="BAD_JSON",n.BadPayload="BAD_PAYLOAD",n.BadSubject="BAD_SUBJECT",n.Cancelled="CANCELLED",n.ConnectionClosed="CONNECTION_CLOSED",n.ConnectionDraining="CONNECTION_DRAINING",n.ConnectionRefused="CONNECTION_REFUSED",n.ConnectionTimeout="CONNECTION_TIMEOUT",n.Disconnect="DISCONNECT",n.InvalidOption="INVALID_OPTION",n.InvalidPayload="INVALID_PAYLOAD",n.MaxPayloadExceeded="MAX_PAYLOAD_EXCEEDED",n.NoResponders="503",n.NotFunction="NOT_FUNC",n.RequestError="REQUEST_ERROR",n.ServerOptionNotAvailable="SERVER_OPT_NA",n.SubClosed="SUB_CLOSED",n.SubDraining="SUB_DRAINING",n.Timeout="TIMEOUT",n.Tls="TLS",n.Unknown="UNKNOWN_ERROR",n.WssRequired="WSS_REQUIRED",n.JetStreamInvalidAck="JESTREAM_INVALID_ACK",n.JetStream404NoMessages="404",n.JetStream408RequestTimeout="408",n.JetStream409MaxAckPendingExceeded="409",n.JetStream409="409",n.JetStreamNotEnabled="503",n.JetStreamIdleHeartBeat="IDLE_HEARTBEAT",n.AuthorizationViolation="AUTHORIZATION_VIOLATION",n.AuthenticationExpired="AUTHENTICATION_EXPIRED",n.ProtocolError="NATS_PROTOCOL_ERR",n.PermissionsViolation="PERMISSIONS_VIOLATION",n.AuthenticationTimeout="AUTHENTICATION_TIMEOUT",n.AccountExpired="ACCOUNT_EXPIRED"})(ue||(ue={}));function aE(n){return typeof n.code=="string"}class fx{constructor(){j(this,"messages");this.messages=new Map,this.messages.set(ue.InvalidPayload,"Invalid payload type - payloads can be 'binary', 'string', or 'json'"),this.messages.set(ue.BadJson,"Bad JSON"),this.messages.set(ue.WssRequired,"TLS is required, therefore a secure websocket connection is also required")}static getMessage(t){return oE.getMessage(t)}getMessage(t){return this.messages.get(t)||t}}const oE=new fx;class ye extends Error{constructor(s,i,o){super(s);j(this,"name");j(this,"message");j(this,"code");j(this,"permissionContext");j(this,"chainedError");j(this,"api_error");this.name="NatsError",this.message=s,this.code=i,this.chainedError=o}static errorForCode(s,i){const o=fx.getMessage(s);return new ye(o,s,i)}isAuthError(){return this.code===ue.AuthenticationExpired||this.code===ue.AuthorizationViolation||this.code===ue.AccountExpired}isAuthTimeout(){return this.code===ue.AuthenticationTimeout}isPermissionError(){return this.code===ue.PermissionsViolation}isProtocolError(){return this.code===ue.ProtocolError}isJetStreamError(){return this.api_error!==void 0}jsError(){return this.api_error?this.api_error:null}}var vn;(function(n){n[n.Exact=0]="Exact",n[n.CanonicalMIME=1]="CanonicalMIME",n[n.IgnoreCase=2]="IgnoreCase"})(vn||(vn={}));var Qn;(function(n){n.Timer="timer",n.Count="count",n.JitterTimer="jitterTimer",n.SentinelMsg="sentinelMsg"})(Qn||(Qn={}));var bo;(function(n){n.STATS="io.nats.micro.v1.stats_response",n.INFO="io.nats.micro.v1.info_response",n.PING="io.nats.micro.v1.ping_response"})(bo||(bo={}));const cu="Nats-Service-Error",uu="Nats-Service-Error-Code";class fu extends Error{constructor(s,i){super(i);j(this,"code");this.code=s}static isServiceError(s){return fu.toServiceError(s)!==null}static toServiceError(s){var o,c;const i=((o=s==null?void 0:s.headers)==null?void 0:o.get(uu))||"";if(i!==""){const m=parseInt(i)||400,y=((c=s==null?void 0:s.headers)==null?void 0:c.get(cu))||"";return new fu(m,y.length?y:i)}return null}}function Rr(n=""){if(n=n||"_INBOX",typeof n!="string")throw new Error("prefix must be a string");return n.split(".").forEach(t=>{if(t==="*"||t===">")throw new Error(`inbox prefixes cannot have wildcards '${n}'`)}),`${n}.${Es.next()}`}const gd="127.0.0.1";var xs;(function(n){n.PING="PING",n.STATS="STATS",n.INFO="INFO"})(xs||(xs={}));function Su(n,...t){for(let s=0;s<t.length;s++){const i=t[s];Object.keys(i).forEach(function(o){n[o]=i[o]})}return n}function sc(n){return Sn.decode(n).replace(/\n/g,"␊").replace(/\r/g,"␍")}function ea(n,t=!0){const s=t?ye.errorForCode(ue.Timeout):null;let i,o;const c=new Promise((m,y)=>{i={cancel:()=>{o&&clearTimeout(o)}},o=setTimeout(()=>{y(s===null?ye.errorForCode(ue.Timeout):s)},n)});return Object.assign(c,i)}function sa(n=0){let t;const s=new Promise(i=>{const o=setTimeout(()=>{i()},n);t={cancel:()=>{o&&clearTimeout(o)}}});return Object.assign(s,t)}function pt(){let n={};const t=new Promise((s,i)=>{n={resolve:s,reject:i}});return Object.assign(t,n)}function hx(n){for(let t=n.length-1;t>0;t--){const s=Math.floor(Math.random()*(t+1));[n[t],n[s]]=[n[s],n[t]]}return n}function lE(n){return n===0?0:Math.floor(n/2+Math.random()*n)}function rm(n=[0,250,250,500,500,3e3,5e3]){Array.isArray(n)||(n=[0,250,250,500,500,3e3,5e3]);const t=n.length-1;return{backoff(s){return lE(s>t?n[t]:n[s])}}}function mt(n){return n*1e6}function sm(n){return Math.floor(n/1e6)}function Fg(n){let i=!0;const o=new Array(n.length);for(let c=0;c<n.length;c++){let m=n.charCodeAt(c);if(m===58||m<33||m>126)throw new ye(`'${n[c]}' is not a valid character for a header key`,ue.BadHeader);i&&97<=m&&m<=122?m-=32:!i&&65<=m&&m<=90&&(m+=32),o[c]=m,i=m==45}return String.fromCharCode(...o)}function Lr(n=0,t=""){if(n===0&&t!==""||n>0&&t==="")throw new Error("setting status requires both code and description");return new vs(n,t)}const Jh="NATS/1.0";class vs{constructor(t=0,s=""){j(this,"_code");j(this,"headers");j(this,"_description");this._code=t,this._description=s,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals(t){if(t&&this.headers.size===t.headers.size&&this._code===t._code){for(const[s,i]of this.headers){const o=t.values(s);if(i.length!==o.length)return!1;const c=[...i].sort(),m=[...o].sort();for(let y=0;y<c.length;y++)if(c[y]!==m[y])return!1}return!0}return!1}static decode(t){const s=new vs,o=Sn.decode(t).split(`\r
25
+ `+l.stack}}var oa=Object.prototype.hasOwnProperty,la=n.unstable_scheduleCallback,cr=n.unstable_cancelCallback,Po=n.unstable_shouldYield,ni=n.unstable_requestPaint,ht=n.unstable_now,Du=n.unstable_getCurrentPriorityLevel,Uo=n.unstable_ImmediatePriority,zo=n.unstable_UserBlockingPriority,ri=n.unstable_NormalPriority,Lu=n.unstable_LowPriority,Io=n.unstable_IdlePriority,qu=n.log,$o=n.unstable_setDisableYieldValue,As=null,_t=null;function cn(e){if(typeof qu=="function"&&$o(e),_t&&typeof _t.setStrictMode=="function")try{_t.setStrictMode(As,e)}catch{}}var Ft=Math.clz32?Math.clz32:si,ca=Math.log,ua=Math.LN2;function si(e){return e>>>=0,e===0?32:31-(ca(e)/ua|0)|0}var Ur=256,ur=262144,zr=4194304;function $n(e){var r=e&42;if(r!==0)return r;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function js(e,r,a){var l=e.pendingLanes;if(l===0)return 0;var f=0,p=e.suspendedLanes,_=e.pingedLanes;e=e.warmLanes;var O=l&134217727;return O!==0?(l=O&~p,l!==0?f=$n(l):(_&=O,_!==0?f=$n(_):a||(a=O&~e,a!==0&&(f=$n(a))))):(O=l&~p,O!==0?f=$n(O):_!==0?f=$n(_):a||(a=l&~e,a!==0&&(f=$n(a)))),f===0?0:r!==0&&r!==f&&(r&p)===0&&(p=f&-f,a=r&-r,p>=a||p===32&&(a&4194048)!==0)?r:f}function ks(e,r){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&r)===0}function fa(e,r){switch(e){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ii(){var e=zr;return zr<<=1,(zr&62914560)===0&&(zr=4194304),e}function Ir(e){for(var r=[],a=0;31>a;a++)r.push(e);return r}function Hn(e,r){e.pendingLanes|=r,r!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function $r(e,r,a,l,f,p){var _=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var O=e.entanglements,M=e.expirationTimes,G=e.hiddenUpdates;for(a=_&~a;0<a;){var Z=31-Ft(a),se=1<<Z;O[Z]=0,M[Z]=-1;var Y=G[Z];if(Y!==null)for(G[Z]=null,Z=0;Z<Y.length;Z++){var J=Y[Z];J!==null&&(J.lane&=-536870913)}a&=~se}l!==0&&Hr(e,l,0),p!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=p&~(_&~r))}function Hr(e,r,a){e.pendingLanes|=r,e.suspendedLanes&=~r;var l=31-Ft(r);e.entangledLanes|=r,e.entanglements[l]=e.entanglements[l]|1073741824|a&261930}function Ns(e,r){var a=e.entangledLanes|=r;for(e=e.entanglements;a;){var l=31-Ft(a),f=1<<l;f&r|e[l]&r&&(e[l]|=r),a&=~f}}function Fr(e,r){var a=r&-r;return a=(a&42)!==0?1:fr(a),(a&(e.suspendedLanes|r))!==0?0:a}function fr(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ts(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function ha(){var e=W.p;return e!==0?e:(e=window.event,e===void 0?32:xg(e.type))}function Ho(e,r){var a=W.p;try{return W.p=e,r()}finally{W.p=a}}var er=Math.random().toString(36).slice(2),at="__reactFiber$"+er,gt="__reactProps$"+er,un="__reactContainer$"+er,Cs="__reactEvents$"+er,da="__reactListeners$"+er,Fo="__reactHandles$"+er,Go="__reactResources$"+er,Mt="__reactMarker$"+er;function ai(e){delete e[at],delete e[gt],delete e[Cs],delete e[da],delete e[Fo]}function A(e){var r=e[at];if(r)return r;for(var a=e.parentNode;a;){if(r=a[un]||a[at]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(e=rg(e);e!==null;){if(a=e[at])return a;e=rg(e)}return r}e=a,a=e.parentNode}return null}function N(e){if(e=e[at]||e[un]){var r=e.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return e}return null}function k(e){var r=e.tag;if(r===5||r===26||r===27||r===6)return e.stateNode;throw Error(i(33))}function T(e){var r=e[Go];return r||(r=e[Go]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function L(e){e[Mt]=!0}var z=new Set,re={};function ae(e,r){K(e,r),K(e+"Capture",r)}function K(e,r){for(re[e]=r,e=0;e<r.length;e++)z.add(r[e])}var te=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),ge={},qe={};function lt(e){return oa.call(qe,e)?!0:oa.call(ge,e)?!1:te.test(e)?qe[e]=!0:(ge[e]=!0,!1)}function Gt(e,r,a){if(lt(r))if(a===null)e.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(r);return;case"boolean":var l=r.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){e.removeAttribute(r);return}}e.setAttribute(r,""+a)}}function Fn(e,r,a){if(a===null)e.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(r);return}e.setAttribute(r,""+a)}}function hr(e,r,a,l){if(l===null)e.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(r,a,""+l)}}function Nn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Im(e){var r=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Gv(e,r,a){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,r);if(!e.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,p=l.set;return Object.defineProperty(e,r,{configurable:!0,get:function(){return f.call(this)},set:function(_){a=""+_,p.call(this,_)}}),Object.defineProperty(e,r,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){e._valueTracker=null,delete e[r]}}}}function Bu(e){if(!e._valueTracker){var r=Im(e)?"checked":"value";e._valueTracker=Gv(e,r,""+e[r])}}function $m(e){if(!e)return!1;var r=e._valueTracker;if(!r)return!0;var a=r.getValue(),l="";return e&&(l=Im(e)?e.checked?"true":"false":e.value),e=l,e!==a?(r.setValue(e),!0):!1}function Vo(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Vv=/[\n"\\]/g;function Tn(e){return e.replace(Vv,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Pu(e,r,a,l,f,p,_,O){e.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?e.type=_:e.removeAttribute("type"),r!=null?_==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+Nn(r)):e.value!==""+Nn(r)&&(e.value=""+Nn(r)):_!=="submit"&&_!=="reset"||e.removeAttribute("value"),r!=null?Uu(e,_,Nn(r)):a!=null?Uu(e,_,Nn(a)):l!=null&&e.removeAttribute("value"),f==null&&p!=null&&(e.defaultChecked=!!p),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?e.name=""+Nn(O):e.removeAttribute("name")}function Hm(e,r,a,l,f,p,_,O){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(e.type=p),r!=null||a!=null){if(!(p!=="submit"&&p!=="reset"||r!=null)){Bu(e);return}a=a!=null?""+Nn(a):"",r=r!=null?""+Nn(r):a,O||r===e.value||(e.value=r),e.defaultValue=r}l=l??f,l=typeof l!="function"&&typeof l!="symbol"&&!!l,e.checked=O?e.checked:!!l,e.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(e.name=_),Bu(e)}function Uu(e,r,a){r==="number"&&Vo(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function oi(e,r,a,l){if(e=e.options,r){r={};for(var f=0;f<a.length;f++)r["$"+a[f]]=!0;for(a=0;a<e.length;a++)f=r.hasOwnProperty("$"+e[a].value),e[a].selected!==f&&(e[a].selected=f),f&&l&&(e[a].defaultSelected=!0)}else{for(a=""+Nn(a),r=null,f=0;f<e.length;f++){if(e[f].value===a){e[f].selected=!0,l&&(e[f].defaultSelected=!0);return}r!==null||e[f].disabled||(r=e[f])}r!==null&&(r.selected=!0)}}function Fm(e,r,a){if(r!=null&&(r=""+Nn(r),r!==e.value&&(e.value=r),a==null)){e.defaultValue!==r&&(e.defaultValue=r);return}e.defaultValue=a!=null?""+Nn(a):""}function Gm(e,r,a,l){if(r==null){if(l!=null){if(a!=null)throw Error(i(92));if(ke(l)){if(1<l.length)throw Error(i(93));l=l[0]}a=l}a==null&&(a=""),r=a}a=Nn(r),e.defaultValue=a,l=e.textContent,l===a&&l!==""&&l!==null&&(e.value=l),Bu(e)}function li(e,r){if(r){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=r;return}}e.textContent=r}var Yv=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Vm(e,r,a){var l=r.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?e.setProperty(r,""):r==="float"?e.cssFloat="":e[r]="":l?e.setProperty(r,a):typeof a!="number"||a===0||Yv.has(r)?r==="float"?e.cssFloat=a:e[r]=(""+a).trim():e[r]=a+"px"}function Ym(e,r,a){if(r!=null&&typeof r!="object")throw Error(i(62));if(e=e.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||r!=null&&r.hasOwnProperty(l)||(l.indexOf("--")===0?e.setProperty(l,""):l==="float"?e.cssFloat="":e[l]="");for(var f in r)l=r[f],r.hasOwnProperty(f)&&a[f]!==l&&Vm(e,f,l)}else for(var p in r)r.hasOwnProperty(p)&&Vm(e,p,r[p])}function zu(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Kv=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Jv=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Yo(e){return Jv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function dr(){}var Iu=null;function $u(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ci=null,ui=null;function Km(e){var r=N(e);if(r&&(e=r.stateNode)){var a=e[gt]||null;e:switch(e=r.stateNode,r.type){case"input":if(Pu(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),r=a.name,a.type==="radio"&&r!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Tn(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var l=a[r];if(l!==e&&l.form===e.form){var f=l[gt]||null;if(!f)throw Error(i(90));Pu(l,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(r=0;r<a.length;r++)l=a[r],l.form===e.form&&$m(l)}break e;case"textarea":Fm(e,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&oi(e,!!a.multiple,r,!1)}}}var Hu=!1;function Jm(e,r,a){if(Hu)return e(r,a);Hu=!0;try{var l=e(r);return l}finally{if(Hu=!1,(ci!==null||ui!==null)&&(Dl(),ci&&(r=ci,e=ui,ui=ci=null,Km(r),e)))for(r=0;r<e.length;r++)Km(e[r])}}function ma(e,r){var a=e.stateNode;if(a===null)return null;var l=a[gt]||null;if(l===null)return null;a=l[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(i(231,r,typeof a));return a}var mr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fu=!1;if(mr)try{var pa={};Object.defineProperty(pa,"passive",{get:function(){Fu=!0}}),window.addEventListener("test",pa,pa),window.removeEventListener("test",pa,pa)}catch{Fu=!1}var Gr=null,Gu=null,Ko=null;function Xm(){if(Ko)return Ko;var e,r=Gu,a=r.length,l,f="value"in Gr?Gr.value:Gr.textContent,p=f.length;for(e=0;e<a&&r[e]===f[e];e++);var _=a-e;for(l=1;l<=_&&r[a-l]===f[p-l];l++);return Ko=f.slice(e,1<l?1-l:void 0)}function Jo(e){var r=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&r===13&&(e=13)):e=r,e===10&&(e=13),32<=e||e===13?e:0}function Xo(){return!0}function Qm(){return!1}function Zt(e){function r(a,l,f,p,_){this._reactName=a,this._targetInst=f,this.type=l,this.nativeEvent=p,this.target=_,this.currentTarget=null;for(var O in e)e.hasOwnProperty(O)&&(a=e[O],this[O]=a?a(p):p[O]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?Xo:Qm,this.isPropagationStopped=Qm,this}return b(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Xo)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Xo)},persist:function(){},isPersistent:Xo}),r}var Ms={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Qo=Zt(Ms),ya=b({},Ms,{view:0,detail:0}),Xv=Zt(ya),Vu,Yu,ga,Wo=b({},ya,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ju,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ga&&(ga&&e.type==="mousemove"?(Vu=e.screenX-ga.screenX,Yu=e.screenY-ga.screenY):Yu=Vu=0,ga=e),Vu)},movementY:function(e){return"movementY"in e?e.movementY:Yu}}),Wm=Zt(Wo),Qv=b({},Wo,{dataTransfer:0}),Wv=Zt(Qv),Zv=b({},ya,{relatedTarget:0}),Ku=Zt(Zv),e_=b({},Ms,{animationName:0,elapsedTime:0,pseudoElement:0}),t_=Zt(e_),n_=b({},Ms,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),r_=Zt(n_),s_=b({},Ms,{data:0}),Zm=Zt(s_),i_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},a_={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},o_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function l_(e){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(e):(e=o_[e])?!!r[e]:!1}function Ju(){return l_}var c_=b({},ya,{key:function(e){if(e.key){var r=i_[e.key]||e.key;if(r!=="Unidentified")return r}return e.type==="keypress"?(e=Jo(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?a_[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ju,charCode:function(e){return e.type==="keypress"?Jo(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Jo(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),u_=Zt(c_),f_=b({},Wo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),e0=Zt(f_),h_=b({},ya,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ju}),d_=Zt(h_),m_=b({},Ms,{propertyName:0,elapsedTime:0,pseudoElement:0}),p_=Zt(m_),y_=b({},Wo,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),g_=Zt(y_),b_=b({},Ms,{newState:0,oldState:0}),x_=Zt(b_),v_=[9,13,27,32],Xu=mr&&"CompositionEvent"in window,ba=null;mr&&"documentMode"in document&&(ba=document.documentMode);var __=mr&&"TextEvent"in window&&!ba,t0=mr&&(!Xu||ba&&8<ba&&11>=ba),n0=" ",r0=!1;function s0(e,r){switch(e){case"keyup":return v_.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function i0(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var fi=!1;function w_(e,r){switch(e){case"compositionend":return i0(r);case"keypress":return r.which!==32?null:(r0=!0,n0);case"textInput":return e=r.data,e===n0&&r0?null:e;default:return null}}function S_(e,r){if(fi)return e==="compositionend"||!Xu&&s0(e,r)?(e=Xm(),Ko=Gu=Gr=null,fi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return t0&&r.locale!=="ko"?null:r.data;default:return null}}var E_={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function a0(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r==="input"?!!E_[e.type]:r==="textarea"}function o0(e,r,a,l){ci?ui?ui.push(l):ui=[l]:ci=l,r=Il(r,"onChange"),0<r.length&&(a=new Qo("onChange","change",null,a,l),e.push({event:a,listeners:r}))}var xa=null,va=null;function O_(e){Hy(e,0)}function Zo(e){var r=k(e);if($m(r))return e}function l0(e,r){if(e==="change")return r}var c0=!1;if(mr){var Qu;if(mr){var Wu="oninput"in document;if(!Wu){var u0=document.createElement("div");u0.setAttribute("oninput","return;"),Wu=typeof u0.oninput=="function"}Qu=Wu}else Qu=!1;c0=Qu&&(!document.documentMode||9<document.documentMode)}function f0(){xa&&(xa.detachEvent("onpropertychange",h0),va=xa=null)}function h0(e){if(e.propertyName==="value"&&Zo(va)){var r=[];o0(r,va,e,$u(e)),Jm(O_,r)}}function A_(e,r,a){e==="focusin"?(f0(),xa=r,va=a,xa.attachEvent("onpropertychange",h0)):e==="focusout"&&f0()}function j_(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Zo(va)}function k_(e,r){if(e==="click")return Zo(r)}function N_(e,r){if(e==="input"||e==="change")return Zo(r)}function T_(e,r){return e===r&&(e!==0||1/e===1/r)||e!==e&&r!==r}var fn=typeof Object.is=="function"?Object.is:T_;function _a(e,r){if(fn(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;var a=Object.keys(e),l=Object.keys(r);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var f=a[l];if(!oa.call(r,f)||!fn(e[f],r[f]))return!1}return!0}function d0(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function m0(e,r){var a=d0(e);e=0;for(var l;a;){if(a.nodeType===3){if(l=e+a.textContent.length,e<=r&&l>=r)return{node:a,offset:r-e};e=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=d0(a)}}function p0(e,r){return e&&r?e===r?!0:e&&e.nodeType===3?!1:r&&r.nodeType===3?p0(e,r.parentNode):"contains"in e?e.contains(r):e.compareDocumentPosition?!!(e.compareDocumentPosition(r)&16):!1:!1}function y0(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var r=Vo(e.document);r instanceof e.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)e=r.contentWindow;else break;r=Vo(e.document)}return r}function Zu(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r&&(r==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||r==="textarea"||e.contentEditable==="true")}var C_=mr&&"documentMode"in document&&11>=document.documentMode,hi=null,ef=null,wa=null,tf=!1;function g0(e,r,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;tf||hi==null||hi!==Vo(l)||(l=hi,"selectionStart"in l&&Zu(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),wa&&_a(wa,l)||(wa=l,l=Il(ef,"onSelect"),0<l.length&&(r=new Qo("onSelect","select",null,r,a),e.push({event:r,listeners:l}),r.target=hi)))}function Rs(e,r){var a={};return a[e.toLowerCase()]=r.toLowerCase(),a["Webkit"+e]="webkit"+r,a["Moz"+e]="moz"+r,a}var di={animationend:Rs("Animation","AnimationEnd"),animationiteration:Rs("Animation","AnimationIteration"),animationstart:Rs("Animation","AnimationStart"),transitionrun:Rs("Transition","TransitionRun"),transitionstart:Rs("Transition","TransitionStart"),transitioncancel:Rs("Transition","TransitionCancel"),transitionend:Rs("Transition","TransitionEnd")},nf={},b0={};mr&&(b0=document.createElement("div").style,"AnimationEvent"in window||(delete di.animationend.animation,delete di.animationiteration.animation,delete di.animationstart.animation),"TransitionEvent"in window||delete di.transitionend.transition);function Ds(e){if(nf[e])return nf[e];if(!di[e])return e;var r=di[e],a;for(a in r)if(r.hasOwnProperty(a)&&a in b0)return nf[e]=r[a];return e}var x0=Ds("animationend"),v0=Ds("animationiteration"),_0=Ds("animationstart"),M_=Ds("transitionrun"),R_=Ds("transitionstart"),D_=Ds("transitioncancel"),w0=Ds("transitionend"),S0=new Map,rf="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");rf.push("scrollEnd");function Gn(e,r){S0.set(e,r),ae(r,[e])}var el=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Cn=[],mi=0,sf=0;function tl(){for(var e=mi,r=sf=mi=0;r<e;){var a=Cn[r];Cn[r++]=null;var l=Cn[r];Cn[r++]=null;var f=Cn[r];Cn[r++]=null;var p=Cn[r];if(Cn[r++]=null,l!==null&&f!==null){var _=l.pending;_===null?f.next=f:(f.next=_.next,_.next=f),l.pending=f}p!==0&&E0(a,f,p)}}function nl(e,r,a,l){Cn[mi++]=e,Cn[mi++]=r,Cn[mi++]=a,Cn[mi++]=l,sf|=l,e.lanes|=l,e=e.alternate,e!==null&&(e.lanes|=l)}function af(e,r,a,l){return nl(e,r,a,l),rl(e)}function Ls(e,r){return nl(e,null,null,r),rl(e)}function E0(e,r,a){e.lanes|=a;var l=e.alternate;l!==null&&(l.lanes|=a);for(var f=!1,p=e.return;p!==null;)p.childLanes|=a,l=p.alternate,l!==null&&(l.childLanes|=a),p.tag===22&&(e=p.stateNode,e===null||e._visibility&1||(f=!0)),e=p,p=p.return;return e.tag===3?(p=e.stateNode,f&&r!==null&&(f=31-Ft(a),e=p.hiddenUpdates,l=e[f],l===null?e[f]=[r]:l.push(r),r.lane=a|536870912),p):null}function rl(e){if(50<Fa)throw Fa=0,ph=null,Error(i(185));for(var r=e.return;r!==null;)e=r,r=e.return;return e.tag===3?e.stateNode:null}var pi={};function L_(e,r,a,l){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function hn(e,r,a,l){return new L_(e,r,a,l)}function of(e){return e=e.prototype,!(!e||!e.isReactComponent)}function pr(e,r){var a=e.alternate;return a===null?(a=hn(e.tag,r,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=r,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,r=e.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function O0(e,r){e.flags&=65011714;var a=e.alternate;return a===null?(e.childLanes=0,e.lanes=r,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,r=a.dependencies,e.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),e}function sl(e,r,a,l,f,p){var _=0;if(l=e,typeof e=="function")of(e)&&(_=1);else if(typeof e=="string")_=zw(e,a,Ze.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case I:return e=hn(31,a,r,f),e.elementType=I,e.lanes=p,e;case S:return qs(a.children,f,p,r);case C:_=8,f|=24;break;case q:return e=hn(12,a,r,f|2),e.elementType=q,e.lanes=p,e;case R:return e=hn(13,a,r,f),e.elementType=R,e.lanes=p,e;case $:return e=hn(19,a,r,f),e.elementType=$,e.lanes=p,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ie:_=10;break e;case B:_=9;break e;case le:_=11;break e;case ne:_=14;break e;case V:_=16,l=null;break e}_=29,a=Error(i(130,e===null?"null":typeof e,"")),l=null}return r=hn(_,a,r,f),r.elementType=e,r.type=l,r.lanes=p,r}function qs(e,r,a,l){return e=hn(7,e,l,r),e.lanes=a,e}function lf(e,r,a){return e=hn(6,e,null,r),e.lanes=a,e}function A0(e){var r=hn(18,null,null,0);return r.stateNode=e,r}function cf(e,r,a){return r=hn(4,e.children!==null?e.children:[],e.key,r),r.lanes=a,r.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},r}var j0=new WeakMap;function Mn(e,r){if(typeof e=="object"&&e!==null){var a=j0.get(e);return a!==void 0?a:(r={value:e,source:r,stack:Bo(r)},j0.set(e,r),r)}return{value:e,source:r,stack:Bo(r)}}var yi=[],gi=0,il=null,Sa=0,Rn=[],Dn=0,Vr=null,tr=1,nr="";function yr(e,r){yi[gi++]=Sa,yi[gi++]=il,il=e,Sa=r}function k0(e,r,a){Rn[Dn++]=tr,Rn[Dn++]=nr,Rn[Dn++]=Vr,Vr=e;var l=tr;e=nr;var f=32-Ft(l)-1;l&=~(1<<f),a+=1;var p=32-Ft(r)+f;if(30<p){var _=f-f%5;p=(l&(1<<_)-1).toString(32),l>>=_,f-=_,tr=1<<32-Ft(r)+f|a<<f|l,nr=p+e}else tr=1<<p|a<<f|l,nr=e}function uf(e){e.return!==null&&(yr(e,1),k0(e,1,0))}function ff(e){for(;e===il;)il=yi[--gi],yi[gi]=null,Sa=yi[--gi],yi[gi]=null;for(;e===Vr;)Vr=Rn[--Dn],Rn[Dn]=null,nr=Rn[--Dn],Rn[Dn]=null,tr=Rn[--Dn],Rn[Dn]=null}function N0(e,r){Rn[Dn++]=tr,Rn[Dn++]=nr,Rn[Dn++]=Vr,tr=r.id,nr=r.overflow,Vr=e}var Ut=null,ct=null,Fe=!1,Yr=null,Ln=!1,hf=Error(i(519));function Kr(e){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ea(Mn(r,e)),hf}function T0(e){var r=e.stateNode,a=e.type,l=e.memoizedProps;switch(r[at]=e,r[gt]=l,a){case"dialog":Ue("cancel",r),Ue("close",r);break;case"iframe":case"object":case"embed":Ue("load",r);break;case"video":case"audio":for(a=0;a<Va.length;a++)Ue(Va[a],r);break;case"source":Ue("error",r);break;case"img":case"image":case"link":Ue("error",r),Ue("load",r);break;case"details":Ue("toggle",r);break;case"input":Ue("invalid",r),Hm(r,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":Ue("invalid",r);break;case"textarea":Ue("invalid",r),Gm(r,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||r.textContent===""+a||l.suppressHydrationWarning===!0||Yy(r.textContent,a)?(l.popover!=null&&(Ue("beforetoggle",r),Ue("toggle",r)),l.onScroll!=null&&Ue("scroll",r),l.onScrollEnd!=null&&Ue("scrollend",r),l.onClick!=null&&(r.onclick=dr),r=!0):r=!1,r||Kr(e,!0)}function C0(e){for(Ut=e.return;Ut;)switch(Ut.tag){case 5:case 31:case 13:Ln=!1;return;case 27:case 3:Ln=!0;return;default:Ut=Ut.return}}function bi(e){if(e!==Ut)return!1;if(!Fe)return C0(e),Fe=!0,!1;var r=e.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Th(e.type,e.memoizedProps)),a=!a),a&&ct&&Kr(e),C0(e),r===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));ct=ng(e)}else if(r===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));ct=ng(e)}else r===27?(r=ct,ls(e.type)?(e=Lh,Lh=null,ct=e):ct=r):ct=Ut?Bn(e.stateNode.nextSibling):null;return!0}function Bs(){ct=Ut=null,Fe=!1}function df(){var e=Yr;return e!==null&&(rn===null?rn=e:rn.push.apply(rn,e),Yr=null),e}function Ea(e){Yr===null?Yr=[e]:Yr.push(e)}var mf=Ce(null),Ps=null,gr=null;function Jr(e,r,a){Me(mf,r._currentValue),r._currentValue=a}function br(e){e._currentValue=mf.current,Ne(mf)}function pf(e,r,a){for(;e!==null;){var l=e.alternate;if((e.childLanes&r)!==r?(e.childLanes|=r,l!==null&&(l.childLanes|=r)):l!==null&&(l.childLanes&r)!==r&&(l.childLanes|=r),e===a)break;e=e.return}}function yf(e,r,a,l){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var p=f.dependencies;if(p!==null){var _=f.child;p=p.firstContext;e:for(;p!==null;){var O=p;p=f;for(var M=0;M<r.length;M++)if(O.context===r[M]){p.lanes|=a,O=p.alternate,O!==null&&(O.lanes|=a),pf(p.return,a,e),l||(_=null);break e}p=O.next}}else if(f.tag===18){if(_=f.return,_===null)throw Error(i(341));_.lanes|=a,p=_.alternate,p!==null&&(p.lanes|=a),pf(_,a,e),_=null}else _=f.child;if(_!==null)_.return=f;else for(_=f;_!==null;){if(_===e){_=null;break}if(f=_.sibling,f!==null){f.return=_.return,_=f;break}_=_.return}f=_}}function xi(e,r,a,l){e=null;for(var f=r,p=!1;f!==null;){if(!p){if((f.flags&524288)!==0)p=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var _=f.alternate;if(_===null)throw Error(i(387));if(_=_.memoizedProps,_!==null){var O=f.type;fn(f.pendingProps.value,_.value)||(e!==null?e.push(O):e=[O])}}else if(f===we.current){if(_=f.alternate,_===null)throw Error(i(387));_.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(Qa):e=[Qa])}f=f.return}e!==null&&yf(r,e,a,l),r.flags|=262144}function al(e){for(e=e.firstContext;e!==null;){if(!fn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Us(e){Ps=e,gr=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function zt(e){return M0(Ps,e)}function ol(e,r){return Ps===null&&Us(e),M0(e,r)}function M0(e,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},gr===null){if(e===null)throw Error(i(308));gr=r,e.dependencies={lanes:0,firstContext:r},e.flags|=524288}else gr=gr.next=r;return a}var q_=typeof AbortController<"u"?AbortController:function(){var e=[],r=this.signal={aborted:!1,addEventListener:function(a,l){e.push(l)}};this.abort=function(){r.aborted=!0,e.forEach(function(a){return a()})}},B_=n.unstable_scheduleCallback,P_=n.unstable_NormalPriority,At={$$typeof:ie,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function gf(){return{controller:new q_,data:new Map,refCount:0}}function Oa(e){e.refCount--,e.refCount===0&&B_(P_,function(){e.controller.abort()})}var Aa=null,bf=0,vi=0,_i=null;function U_(e,r){if(Aa===null){var a=Aa=[];bf=0,vi=_h(),_i={status:"pending",value:void 0,then:function(l){a.push(l)}}}return bf++,r.then(R0,R0),r}function R0(){if(--bf===0&&Aa!==null){_i!==null&&(_i.status="fulfilled");var e=Aa;Aa=null,vi=0,_i=null;for(var r=0;r<e.length;r++)(0,e[r])()}}function z_(e,r){var a=[],l={status:"pending",value:null,reason:null,then:function(f){a.push(f)}};return e.then(function(){l.status="fulfilled",l.value=r;for(var f=0;f<a.length;f++)(0,a[f])(r)},function(f){for(l.status="rejected",l.reason=f,f=0;f<a.length;f++)(0,a[f])(void 0)}),l}var D0=H.S;H.S=function(e,r){gy=ht(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&U_(e,r),D0!==null&&D0(e,r)};var zs=Ce(null);function xf(){var e=zs.current;return e!==null?e:ot.pooledCache}function ll(e,r){r===null?Me(zs,zs.current):Me(zs,r.pool)}function L0(){var e=xf();return e===null?null:{parent:At._currentValue,pool:e}}var wi=Error(i(460)),vf=Error(i(474)),cl=Error(i(542)),ul={then:function(){}};function q0(e){return e=e.status,e==="fulfilled"||e==="rejected"}function B0(e,r,a){switch(a=e[a],a===void 0?e.push(r):a!==r&&(r.then(dr,dr),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw e=r.reason,U0(e),e;default:if(typeof r.status=="string")r.then(dr,dr);else{if(e=ot,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=r,e.status="pending",e.then(function(l){if(r.status==="pending"){var f=r;f.status="fulfilled",f.value=l}},function(l){if(r.status==="pending"){var f=r;f.status="rejected",f.reason=l}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw e=r.reason,U0(e),e}throw $s=r,wi}}function Is(e){try{var r=e._init;return r(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?($s=a,wi):a}}var $s=null;function P0(){if($s===null)throw Error(i(459));var e=$s;return $s=null,e}function U0(e){if(e===wi||e===cl)throw Error(i(483))}var Si=null,ja=0;function fl(e){var r=ja;return ja+=1,Si===null&&(Si=[]),B0(Si,e,r)}function ka(e,r){r=r.props.ref,e.ref=r!==void 0?r:null}function hl(e,r){throw r.$$typeof===x?Error(i(525)):(e=Object.prototype.toString.call(r),Error(i(31,e==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":e)))}function z0(e){function r(U,P){if(e){var F=U.deletions;F===null?(U.deletions=[P],U.flags|=16):F.push(P)}}function a(U,P){if(!e)return null;for(;P!==null;)r(U,P),P=P.sibling;return null}function l(U){for(var P=new Map;U!==null;)U.key!==null?P.set(U.key,U):P.set(U.index,U),U=U.sibling;return P}function f(U,P){return U=pr(U,P),U.index=0,U.sibling=null,U}function p(U,P,F){return U.index=F,e?(F=U.alternate,F!==null?(F=F.index,F<P?(U.flags|=67108866,P):F):(U.flags|=67108866,P)):(U.flags|=1048576,P)}function _(U){return e&&U.alternate===null&&(U.flags|=67108866),U}function O(U,P,F,ee){return P===null||P.tag!==6?(P=lf(F,U.mode,ee),P.return=U,P):(P=f(P,F),P.return=U,P)}function M(U,P,F,ee){var Oe=F.type;return Oe===S?Z(U,P,F.props.children,ee,F.key):P!==null&&(P.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===V&&Is(Oe)===P.type)?(P=f(P,F.props),ka(P,F),P.return=U,P):(P=sl(F.type,F.key,F.props,null,U.mode,ee),ka(P,F),P.return=U,P)}function G(U,P,F,ee){return P===null||P.tag!==4||P.stateNode.containerInfo!==F.containerInfo||P.stateNode.implementation!==F.implementation?(P=cf(F,U.mode,ee),P.return=U,P):(P=f(P,F.children||[]),P.return=U,P)}function Z(U,P,F,ee,Oe){return P===null||P.tag!==7?(P=qs(F,U.mode,ee,Oe),P.return=U,P):(P=f(P,F),P.return=U,P)}function se(U,P,F){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=lf(""+P,U.mode,F),P.return=U,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case v:return F=sl(P.type,P.key,P.props,null,U.mode,F),ka(F,P),F.return=U,F;case w:return P=cf(P,U.mode,F),P.return=U,P;case V:return P=Is(P),se(U,P,F)}if(ke(P)||X(P))return P=qs(P,U.mode,F,null),P.return=U,P;if(typeof P.then=="function")return se(U,fl(P),F);if(P.$$typeof===ie)return se(U,ol(U,P),F);hl(U,P)}return null}function Y(U,P,F,ee){var Oe=P!==null?P.key:null;if(typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint")return Oe!==null?null:O(U,P,""+F,ee);if(typeof F=="object"&&F!==null){switch(F.$$typeof){case v:return F.key===Oe?M(U,P,F,ee):null;case w:return F.key===Oe?G(U,P,F,ee):null;case V:return F=Is(F),Y(U,P,F,ee)}if(ke(F)||X(F))return Oe!==null?null:Z(U,P,F,ee,null);if(typeof F.then=="function")return Y(U,P,fl(F),ee);if(F.$$typeof===ie)return Y(U,P,ol(U,F),ee);hl(U,F)}return null}function J(U,P,F,ee,Oe){if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return U=U.get(F)||null,O(P,U,""+ee,Oe);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case v:return U=U.get(ee.key===null?F:ee.key)||null,M(P,U,ee,Oe);case w:return U=U.get(ee.key===null?F:ee.key)||null,G(P,U,ee,Oe);case V:return ee=Is(ee),J(U,P,F,ee,Oe)}if(ke(ee)||X(ee))return U=U.get(F)||null,Z(P,U,ee,Oe,null);if(typeof ee.then=="function")return J(U,P,F,fl(ee),Oe);if(ee.$$typeof===ie)return J(U,P,F,ol(P,ee),Oe);hl(P,ee)}return null}function be(U,P,F,ee){for(var Oe=null,Je=null,_e=P,Le=P=0,Ie=null;_e!==null&&Le<F.length;Le++){_e.index>Le?(Ie=_e,_e=null):Ie=_e.sibling;var Xe=Y(U,_e,F[Le],ee);if(Xe===null){_e===null&&(_e=Ie);break}e&&_e&&Xe.alternate===null&&r(U,_e),P=p(Xe,P,Le),Je===null?Oe=Xe:Je.sibling=Xe,Je=Xe,_e=Ie}if(Le===F.length)return a(U,_e),Fe&&yr(U,Le),Oe;if(_e===null){for(;Le<F.length;Le++)_e=se(U,F[Le],ee),_e!==null&&(P=p(_e,P,Le),Je===null?Oe=_e:Je.sibling=_e,Je=_e);return Fe&&yr(U,Le),Oe}for(_e=l(_e);Le<F.length;Le++)Ie=J(_e,U,Le,F[Le],ee),Ie!==null&&(e&&Ie.alternate!==null&&_e.delete(Ie.key===null?Le:Ie.key),P=p(Ie,P,Le),Je===null?Oe=Ie:Je.sibling=Ie,Je=Ie);return e&&_e.forEach(function(ds){return r(U,ds)}),Fe&&yr(U,Le),Oe}function Te(U,P,F,ee){if(F==null)throw Error(i(151));for(var Oe=null,Je=null,_e=P,Le=P=0,Ie=null,Xe=F.next();_e!==null&&!Xe.done;Le++,Xe=F.next()){_e.index>Le?(Ie=_e,_e=null):Ie=_e.sibling;var ds=Y(U,_e,Xe.value,ee);if(ds===null){_e===null&&(_e=Ie);break}e&&_e&&ds.alternate===null&&r(U,_e),P=p(ds,P,Le),Je===null?Oe=ds:Je.sibling=ds,Je=ds,_e=Ie}if(Xe.done)return a(U,_e),Fe&&yr(U,Le),Oe;if(_e===null){for(;!Xe.done;Le++,Xe=F.next())Xe=se(U,Xe.value,ee),Xe!==null&&(P=p(Xe,P,Le),Je===null?Oe=Xe:Je.sibling=Xe,Je=Xe);return Fe&&yr(U,Le),Oe}for(_e=l(_e);!Xe.done;Le++,Xe=F.next())Xe=J(_e,U,Le,Xe.value,ee),Xe!==null&&(e&&Xe.alternate!==null&&_e.delete(Xe.key===null?Le:Xe.key),P=p(Xe,P,Le),Je===null?Oe=Xe:Je.sibling=Xe,Je=Xe);return e&&_e.forEach(function(Qw){return r(U,Qw)}),Fe&&yr(U,Le),Oe}function it(U,P,F,ee){if(typeof F=="object"&&F!==null&&F.type===S&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case v:e:{for(var Oe=F.key;P!==null;){if(P.key===Oe){if(Oe=F.type,Oe===S){if(P.tag===7){a(U,P.sibling),ee=f(P,F.props.children),ee.return=U,U=ee;break e}}else if(P.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===V&&Is(Oe)===P.type){a(U,P.sibling),ee=f(P,F.props),ka(ee,F),ee.return=U,U=ee;break e}a(U,P);break}else r(U,P);P=P.sibling}F.type===S?(ee=qs(F.props.children,U.mode,ee,F.key),ee.return=U,U=ee):(ee=sl(F.type,F.key,F.props,null,U.mode,ee),ka(ee,F),ee.return=U,U=ee)}return _(U);case w:e:{for(Oe=F.key;P!==null;){if(P.key===Oe)if(P.tag===4&&P.stateNode.containerInfo===F.containerInfo&&P.stateNode.implementation===F.implementation){a(U,P.sibling),ee=f(P,F.children||[]),ee.return=U,U=ee;break e}else{a(U,P);break}else r(U,P);P=P.sibling}ee=cf(F,U.mode,ee),ee.return=U,U=ee}return _(U);case V:return F=Is(F),it(U,P,F,ee)}if(ke(F))return be(U,P,F,ee);if(X(F)){if(Oe=X(F),typeof Oe!="function")throw Error(i(150));return F=Oe.call(F),Te(U,P,F,ee)}if(typeof F.then=="function")return it(U,P,fl(F),ee);if(F.$$typeof===ie)return it(U,P,ol(U,F),ee);hl(U,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,P!==null&&P.tag===6?(a(U,P.sibling),ee=f(P,F),ee.return=U,U=ee):(a(U,P),ee=lf(F,U.mode,ee),ee.return=U,U=ee),_(U)):a(U,P)}return function(U,P,F,ee){try{ja=0;var Oe=it(U,P,F,ee);return Si=null,Oe}catch(_e){if(_e===wi||_e===cl)throw _e;var Je=hn(29,_e,null,U.mode);return Je.lanes=ee,Je.return=U,Je}finally{}}}var Hs=z0(!0),I0=z0(!1),Xr=!1;function _f(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wf(e,r){e=e.updateQueue,r.updateQueue===e&&(r.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Qr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Wr(e,r,a){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Qe&2)!==0){var f=l.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),l.pending=r,r=rl(e),E0(e,null,a),r}return nl(e,l,r,a),rl(e)}function Na(e,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194048)!==0)){var l=r.lanes;l&=e.pendingLanes,a|=l,r.lanes=a,Ns(e,a)}}function Sf(e,r){var a=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var f=null,p=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};p===null?f=p=_:p=p.next=_,a=a.next}while(a!==null);p===null?f=p=r:p=p.next=r}else f=p=r;a={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:p,shared:l.shared,callbacks:l.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=r:e.next=r,a.lastBaseUpdate=r}var Ef=!1;function Ta(){if(Ef){var e=_i;if(e!==null)throw e}}function Ca(e,r,a,l){Ef=!1;var f=e.updateQueue;Xr=!1;var p=f.firstBaseUpdate,_=f.lastBaseUpdate,O=f.shared.pending;if(O!==null){f.shared.pending=null;var M=O,G=M.next;M.next=null,_===null?p=G:_.next=G,_=M;var Z=e.alternate;Z!==null&&(Z=Z.updateQueue,O=Z.lastBaseUpdate,O!==_&&(O===null?Z.firstBaseUpdate=G:O.next=G,Z.lastBaseUpdate=M))}if(p!==null){var se=f.baseState;_=0,Z=G=M=null,O=p;do{var Y=O.lane&-536870913,J=Y!==O.lane;if(J?(ze&Y)===Y:(l&Y)===Y){Y!==0&&Y===vi&&(Ef=!0),Z!==null&&(Z=Z.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var be=e,Te=O;Y=r;var it=a;switch(Te.tag){case 1:if(be=Te.payload,typeof be=="function"){se=be.call(it,se,Y);break e}se=be;break e;case 3:be.flags=be.flags&-65537|128;case 0:if(be=Te.payload,Y=typeof be=="function"?be.call(it,se,Y):be,Y==null)break e;se=b({},se,Y);break e;case 2:Xr=!0}}Y=O.callback,Y!==null&&(e.flags|=64,J&&(e.flags|=8192),J=f.callbacks,J===null?f.callbacks=[Y]:J.push(Y))}else J={lane:Y,tag:O.tag,payload:O.payload,callback:O.callback,next:null},Z===null?(G=Z=J,M=se):Z=Z.next=J,_|=Y;if(O=O.next,O===null){if(O=f.shared.pending,O===null)break;J=O,O=J.next,J.next=null,f.lastBaseUpdate=J,f.shared.pending=null}}while(!0);Z===null&&(M=se),f.baseState=M,f.firstBaseUpdate=G,f.lastBaseUpdate=Z,p===null&&(f.shared.lanes=0),rs|=_,e.lanes=_,e.memoizedState=se}}function $0(e,r){if(typeof e!="function")throw Error(i(191,e));e.call(r)}function H0(e,r){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)$0(a[e],r)}var Ei=Ce(null),dl=Ce(0);function F0(e,r){e=jr,Me(dl,e),Me(Ei,r),jr=e|r.baseLanes}function Of(){Me(dl,jr),Me(Ei,Ei.current)}function Af(){jr=dl.current,Ne(Ei),Ne(dl)}var dn=Ce(null),qn=null;function Zr(e){var r=e.alternate;Me(wt,wt.current&1),Me(dn,e),qn===null&&(r===null||Ei.current!==null||r.memoizedState!==null)&&(qn=e)}function jf(e){Me(wt,wt.current),Me(dn,e),qn===null&&(qn=e)}function G0(e){e.tag===22?(Me(wt,wt.current),Me(dn,e),qn===null&&(qn=e)):es()}function es(){Me(wt,wt.current),Me(dn,dn.current)}function mn(e){Ne(dn),qn===e&&(qn=null),Ne(wt)}var wt=Ce(0);function ml(e){for(var r=e;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Rh(a)||Dh(a)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var xr=0,De=null,rt=null,jt=null,pl=!1,Oi=!1,Fs=!1,yl=0,Ma=0,Ai=null,I_=0;function bt(){throw Error(i(321))}function kf(e,r){if(r===null)return!1;for(var a=0;a<r.length&&a<e.length;a++)if(!fn(e[a],r[a]))return!1;return!0}function Nf(e,r,a,l,f,p){return xr=p,De=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,H.H=e===null||e.memoizedState===null?kp:Ff,Fs=!1,p=a(l,f),Fs=!1,Oi&&(p=Y0(r,a,l,f)),V0(e),p}function V0(e){H.H=La;var r=rt!==null&&rt.next!==null;if(xr=0,jt=rt=De=null,pl=!1,Ma=0,Ai=null,r)throw Error(i(300));e===null||kt||(e=e.dependencies,e!==null&&al(e)&&(kt=!0))}function Y0(e,r,a,l){De=e;var f=0;do{if(Oi&&(Ai=null),Ma=0,Oi=!1,25<=f)throw Error(i(301));if(f+=1,jt=rt=null,e.updateQueue!=null){var p=e.updateQueue;p.lastEffect=null,p.events=null,p.stores=null,p.memoCache!=null&&(p.memoCache.index=0)}H.H=Np,p=r(a,l)}while(Oi);return p}function $_(){var e=H.H,r=e.useState()[0];return r=typeof r.then=="function"?Ra(r):r,e=e.useState()[0],(rt!==null?rt.memoizedState:null)!==e&&(De.flags|=1024),r}function Tf(){var e=yl!==0;return yl=0,e}function Cf(e,r,a){r.updateQueue=e.updateQueue,r.flags&=-2053,e.lanes&=~a}function Mf(e){if(pl){for(e=e.memoizedState;e!==null;){var r=e.queue;r!==null&&(r.pending=null),e=e.next}pl=!1}xr=0,jt=rt=De=null,Oi=!1,Ma=yl=0,Ai=null}function Vt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jt===null?De.memoizedState=jt=e:jt=jt.next=e,jt}function St(){if(rt===null){var e=De.alternate;e=e!==null?e.memoizedState:null}else e=rt.next;var r=jt===null?De.memoizedState:jt.next;if(r!==null)jt=r,rt=e;else{if(e===null)throw De.alternate===null?Error(i(467)):Error(i(310));rt=e,e={memoizedState:rt.memoizedState,baseState:rt.baseState,baseQueue:rt.baseQueue,queue:rt.queue,next:null},jt===null?De.memoizedState=jt=e:jt=jt.next=e}return jt}function gl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ra(e){var r=Ma;return Ma+=1,Ai===null&&(Ai=[]),e=B0(Ai,e,r),r=De,(jt===null?r.memoizedState:jt.next)===null&&(r=r.alternate,H.H=r===null||r.memoizedState===null?kp:Ff),e}function bl(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Ra(e);if(e.$$typeof===ie)return zt(e)}throw Error(i(438,String(e)))}function Rf(e){var r=null,a=De.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var l=De.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(r={data:l.data.map(function(f){return f.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),a===null&&(a=gl(),De.updateQueue=a),a.memoCache=r,a=r.data[r.index],a===void 0)for(a=r.data[r.index]=Array(e),l=0;l<e;l++)a[l]=D;return r.index++,a}function vr(e,r){return typeof r=="function"?r(e):r}function xl(e){var r=St();return Df(r,rt,e)}function Df(e,r,a){var l=e.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=a;var f=e.baseQueue,p=l.pending;if(p!==null){if(f!==null){var _=f.next;f.next=p.next,p.next=_}r.baseQueue=f=p,l.pending=null}if(p=e.baseState,f===null)e.memoizedState=p;else{r=f.next;var O=_=null,M=null,G=r,Z=!1;do{var se=G.lane&-536870913;if(se!==G.lane?(ze&se)===se:(xr&se)===se){var Y=G.revertLane;if(Y===0)M!==null&&(M=M.next={lane:0,revertLane:0,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),se===vi&&(Z=!0);else if((xr&Y)===Y){G=G.next,Y===vi&&(Z=!0);continue}else se={lane:0,revertLane:G.revertLane,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},M===null?(O=M=se,_=p):M=M.next=se,De.lanes|=Y,rs|=Y;se=G.action,Fs&&a(p,se),p=G.hasEagerState?G.eagerState:a(p,se)}else Y={lane:se,revertLane:G.revertLane,gesture:G.gesture,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},M===null?(O=M=Y,_=p):M=M.next=Y,De.lanes|=se,rs|=se;G=G.next}while(G!==null&&G!==r);if(M===null?_=p:M.next=O,!fn(p,e.memoizedState)&&(kt=!0,Z&&(a=_i,a!==null)))throw a;e.memoizedState=p,e.baseState=_,e.baseQueue=M,l.lastRenderedState=p}return f===null&&(l.lanes=0),[e.memoizedState,l.dispatch]}function Lf(e){var r=St(),a=r.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=e;var l=a.dispatch,f=a.pending,p=r.memoizedState;if(f!==null){a.pending=null;var _=f=f.next;do p=e(p,_.action),_=_.next;while(_!==f);fn(p,r.memoizedState)||(kt=!0),r.memoizedState=p,r.baseQueue===null&&(r.baseState=p),a.lastRenderedState=p}return[p,l]}function K0(e,r,a){var l=De,f=St(),p=Fe;if(p){if(a===void 0)throw Error(i(407));a=a()}else a=r();var _=!fn((rt||f).memoizedState,a);if(_&&(f.memoizedState=a,kt=!0),f=f.queue,Pf(Q0.bind(null,l,f,e),[e]),f.getSnapshot!==r||_||jt!==null&&jt.memoizedState.tag&1){if(l.flags|=2048,ji(9,{destroy:void 0},X0.bind(null,l,f,a,r),null),ot===null)throw Error(i(349));p||(xr&127)!==0||J0(l,r,a)}return a}function J0(e,r,a){e.flags|=16384,e={getSnapshot:r,value:a},r=De.updateQueue,r===null?(r=gl(),De.updateQueue=r,r.stores=[e]):(a=r.stores,a===null?r.stores=[e]:a.push(e))}function X0(e,r,a,l){r.value=a,r.getSnapshot=l,W0(r)&&Z0(e)}function Q0(e,r,a){return a(function(){W0(r)&&Z0(e)})}function W0(e){var r=e.getSnapshot;e=e.value;try{var a=r();return!fn(e,a)}catch{return!0}}function Z0(e){var r=Ls(e,2);r!==null&&sn(r,e,2)}function qf(e){var r=Vt();if(typeof e=="function"){var a=e;if(e=a(),Fs){cn(!0);try{a()}finally{cn(!1)}}}return r.memoizedState=r.baseState=e,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:e},r}function ep(e,r,a,l){return e.baseState=a,Df(e,rt,typeof l=="function"?l:vr)}function H_(e,r,a,l,f){if(wl(e))throw Error(i(485));if(e=r.action,e!==null){var p={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){p.listeners.push(_)}};H.T!==null?a(!0):p.isTransition=!1,l(p),a=r.pending,a===null?(p.next=r.pending=p,tp(r,p)):(p.next=a.next,r.pending=a.next=p)}}function tp(e,r){var a=r.action,l=r.payload,f=e.state;if(r.isTransition){var p=H.T,_={};H.T=_;try{var O=a(f,l),M=H.S;M!==null&&M(_,O),np(e,r,O)}catch(G){Bf(e,r,G)}finally{p!==null&&_.types!==null&&(p.types=_.types),H.T=p}}else try{p=a(f,l),np(e,r,p)}catch(G){Bf(e,r,G)}}function np(e,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){rp(e,r,l)},function(l){return Bf(e,r,l)}):rp(e,r,a)}function rp(e,r,a){r.status="fulfilled",r.value=a,sp(r),e.state=a,r=e.pending,r!==null&&(a=r.next,a===r?e.pending=null:(a=a.next,r.next=a,tp(e,a)))}function Bf(e,r,a){var l=e.pending;if(e.pending=null,l!==null){l=l.next;do r.status="rejected",r.reason=a,sp(r),r=r.next;while(r!==l)}e.action=null}function sp(e){e=e.listeners;for(var r=0;r<e.length;r++)(0,e[r])()}function ip(e,r){return r}function ap(e,r){if(Fe){var a=ot.formState;if(a!==null){e:{var l=De;if(Fe){if(ct){t:{for(var f=ct,p=Ln;f.nodeType!==8;){if(!p){f=null;break t}if(f=Bn(f.nextSibling),f===null){f=null;break t}}p=f.data,f=p==="F!"||p==="F"?f:null}if(f){ct=Bn(f.nextSibling),l=f.data==="F!";break e}}Kr(l)}l=!1}l&&(r=a[0])}}return a=Vt(),a.memoizedState=a.baseState=r,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ip,lastRenderedState:r},a.queue=l,a=Op.bind(null,De,l),l.dispatch=a,l=qf(!1),p=Hf.bind(null,De,!1,l.queue),l=Vt(),f={state:r,dispatch:null,action:e,pending:null},l.queue=f,a=H_.bind(null,De,f,p,a),f.dispatch=a,l.memoizedState=e,[r,a,!1]}function op(e){var r=St();return lp(r,rt,e)}function lp(e,r,a){if(r=Df(e,r,ip)[0],e=xl(vr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var l=Ra(r)}catch(_){throw _===wi?cl:_}else l=r;r=St();var f=r.queue,p=f.dispatch;return a!==r.memoizedState&&(De.flags|=2048,ji(9,{destroy:void 0},F_.bind(null,f,a),null)),[l,p,e]}function F_(e,r){e.action=r}function cp(e){var r=St(),a=rt;if(a!==null)return lp(r,a,e);St(),r=r.memoizedState,a=St();var l=a.queue.dispatch;return a.memoizedState=e,[r,l,!1]}function ji(e,r,a,l){return e={tag:e,create:a,deps:l,inst:r,next:null},r=De.updateQueue,r===null&&(r=gl(),De.updateQueue=r),a=r.lastEffect,a===null?r.lastEffect=e.next=e:(l=a.next,a.next=e,e.next=l,r.lastEffect=e),e}function up(){return St().memoizedState}function vl(e,r,a,l){var f=Vt();De.flags|=e,f.memoizedState=ji(1|r,{destroy:void 0},a,l===void 0?null:l)}function _l(e,r,a,l){var f=St();l=l===void 0?null:l;var p=f.memoizedState.inst;rt!==null&&l!==null&&kf(l,rt.memoizedState.deps)?f.memoizedState=ji(r,p,a,l):(De.flags|=e,f.memoizedState=ji(1|r,p,a,l))}function fp(e,r){vl(8390656,8,e,r)}function Pf(e,r){_l(2048,8,e,r)}function G_(e){De.flags|=4;var r=De.updateQueue;if(r===null)r=gl(),De.updateQueue=r,r.events=[e];else{var a=r.events;a===null?r.events=[e]:a.push(e)}}function hp(e){var r=St().memoizedState;return G_({ref:r,nextImpl:e}),function(){if((Qe&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function dp(e,r){return _l(4,2,e,r)}function mp(e,r){return _l(4,4,e,r)}function pp(e,r){if(typeof r=="function"){e=e();var a=r(e);return function(){typeof a=="function"?a():r(null)}}if(r!=null)return e=e(),r.current=e,function(){r.current=null}}function yp(e,r,a){a=a!=null?a.concat([e]):null,_l(4,4,pp.bind(null,r,e),a)}function Uf(){}function gp(e,r){var a=St();r=r===void 0?null:r;var l=a.memoizedState;return r!==null&&kf(r,l[1])?l[0]:(a.memoizedState=[e,r],e)}function bp(e,r){var a=St();r=r===void 0?null:r;var l=a.memoizedState;if(r!==null&&kf(r,l[1]))return l[0];if(l=e(),Fs){cn(!0);try{e()}finally{cn(!1)}}return a.memoizedState=[l,r],l}function zf(e,r,a){return a===void 0||(xr&1073741824)!==0&&(ze&261930)===0?e.memoizedState=r:(e.memoizedState=a,e=xy(),De.lanes|=e,rs|=e,a)}function xp(e,r,a,l){return fn(a,r)?a:Ei.current!==null?(e=zf(e,a,l),fn(e,r)||(kt=!0),e):(xr&42)===0||(xr&1073741824)!==0&&(ze&261930)===0?(kt=!0,e.memoizedState=a):(e=xy(),De.lanes|=e,rs|=e,r)}function vp(e,r,a,l,f){var p=W.p;W.p=p!==0&&8>p?p:8;var _=H.T,O={};H.T=O,Hf(e,!1,r,a);try{var M=f(),G=H.S;if(G!==null&&G(O,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var Z=z_(M,l);Da(e,r,Z,gn(e))}else Da(e,r,l,gn(e))}catch(se){Da(e,r,{then:function(){},status:"rejected",reason:se},gn())}finally{W.p=p,_!==null&&O.types!==null&&(_.types=O.types),H.T=_}}function V_(){}function If(e,r,a,l){if(e.tag!==5)throw Error(i(476));var f=_p(e).queue;vp(e,f,r,ce,a===null?V_:function(){return wp(e),a(l)})}function _p(e){var r=e.memoizedState;if(r!==null)return r;r={memoizedState:ce,baseState:ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:ce},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},e.memoizedState=r,e=e.alternate,e!==null&&(e.memoizedState=r),r}function wp(e){var r=_p(e);r.next===null&&(r=e.alternate.memoizedState),Da(e,r.next.queue,{},gn())}function $f(){return zt(Qa)}function Sp(){return St().memoizedState}function Ep(){return St().memoizedState}function Y_(e){for(var r=e.return;r!==null;){switch(r.tag){case 24:case 3:var a=gn();e=Qr(a);var l=Wr(r,e,a);l!==null&&(sn(l,r,a),Na(l,r,a)),r={cache:gf()},e.payload=r;return}r=r.return}}function K_(e,r,a){var l=gn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},wl(e)?Ap(r,a):(a=af(e,r,a,l),a!==null&&(sn(a,e,l),jp(a,r,l)))}function Op(e,r,a){var l=gn();Da(e,r,a,l)}function Da(e,r,a,l){var f={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(wl(e))Ap(r,f);else{var p=e.alternate;if(e.lanes===0&&(p===null||p.lanes===0)&&(p=r.lastRenderedReducer,p!==null))try{var _=r.lastRenderedState,O=p(_,a);if(f.hasEagerState=!0,f.eagerState=O,fn(O,_))return nl(e,r,f,0),ot===null&&tl(),!1}catch{}finally{}if(a=af(e,r,f,l),a!==null)return sn(a,e,l),jp(a,r,l),!0}return!1}function Hf(e,r,a,l){if(l={lane:2,revertLane:_h(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},wl(e)){if(r)throw Error(i(479))}else r=af(e,a,l,2),r!==null&&sn(r,e,2)}function wl(e){var r=e.alternate;return e===De||r!==null&&r===De}function Ap(e,r){Oi=pl=!0;var a=e.pending;a===null?r.next=r:(r.next=a.next,a.next=r),e.pending=r}function jp(e,r,a){if((a&4194048)!==0){var l=r.lanes;l&=e.pendingLanes,a|=l,r.lanes=a,Ns(e,a)}}var La={readContext:zt,use:bl,useCallback:bt,useContext:bt,useEffect:bt,useImperativeHandle:bt,useLayoutEffect:bt,useInsertionEffect:bt,useMemo:bt,useReducer:bt,useRef:bt,useState:bt,useDebugValue:bt,useDeferredValue:bt,useTransition:bt,useSyncExternalStore:bt,useId:bt,useHostTransitionStatus:bt,useFormState:bt,useActionState:bt,useOptimistic:bt,useMemoCache:bt,useCacheRefresh:bt};La.useEffectEvent=bt;var kp={readContext:zt,use:bl,useCallback:function(e,r){return Vt().memoizedState=[e,r===void 0?null:r],e},useContext:zt,useEffect:fp,useImperativeHandle:function(e,r,a){a=a!=null?a.concat([e]):null,vl(4194308,4,pp.bind(null,r,e),a)},useLayoutEffect:function(e,r){return vl(4194308,4,e,r)},useInsertionEffect:function(e,r){vl(4,2,e,r)},useMemo:function(e,r){var a=Vt();r=r===void 0?null:r;var l=e();if(Fs){cn(!0);try{e()}finally{cn(!1)}}return a.memoizedState=[l,r],l},useReducer:function(e,r,a){var l=Vt();if(a!==void 0){var f=a(r);if(Fs){cn(!0);try{a(r)}finally{cn(!1)}}}else f=r;return l.memoizedState=l.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},l.queue=e,e=e.dispatch=K_.bind(null,De,e),[l.memoizedState,e]},useRef:function(e){var r=Vt();return e={current:e},r.memoizedState=e},useState:function(e){e=qf(e);var r=e.queue,a=Op.bind(null,De,r);return r.dispatch=a,[e.memoizedState,a]},useDebugValue:Uf,useDeferredValue:function(e,r){var a=Vt();return zf(a,e,r)},useTransition:function(){var e=qf(!1);return e=vp.bind(null,De,e.queue,!0,!1),Vt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,r,a){var l=De,f=Vt();if(Fe){if(a===void 0)throw Error(i(407));a=a()}else{if(a=r(),ot===null)throw Error(i(349));(ze&127)!==0||J0(l,r,a)}f.memoizedState=a;var p={value:a,getSnapshot:r};return f.queue=p,fp(Q0.bind(null,l,p,e),[e]),l.flags|=2048,ji(9,{destroy:void 0},X0.bind(null,l,p,a,r),null),a},useId:function(){var e=Vt(),r=ot.identifierPrefix;if(Fe){var a=nr,l=tr;a=(l&~(1<<32-Ft(l)-1)).toString(32)+a,r="_"+r+"R_"+a,a=yl++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=I_++,r="_"+r+"r_"+a.toString(32)+"_";return e.memoizedState=r},useHostTransitionStatus:$f,useFormState:ap,useActionState:ap,useOptimistic:function(e){var r=Vt();r.memoizedState=r.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=Hf.bind(null,De,!0,a),a.dispatch=r,[e,r]},useMemoCache:Rf,useCacheRefresh:function(){return Vt().memoizedState=Y_.bind(null,De)},useEffectEvent:function(e){var r=Vt(),a={impl:e};return r.memoizedState=a,function(){if((Qe&2)!==0)throw Error(i(440));return a.impl.apply(void 0,arguments)}}},Ff={readContext:zt,use:bl,useCallback:gp,useContext:zt,useEffect:Pf,useImperativeHandle:yp,useInsertionEffect:dp,useLayoutEffect:mp,useMemo:bp,useReducer:xl,useRef:up,useState:function(){return xl(vr)},useDebugValue:Uf,useDeferredValue:function(e,r){var a=St();return xp(a,rt.memoizedState,e,r)},useTransition:function(){var e=xl(vr)[0],r=St().memoizedState;return[typeof e=="boolean"?e:Ra(e),r]},useSyncExternalStore:K0,useId:Sp,useHostTransitionStatus:$f,useFormState:op,useActionState:op,useOptimistic:function(e,r){var a=St();return ep(a,rt,e,r)},useMemoCache:Rf,useCacheRefresh:Ep};Ff.useEffectEvent=hp;var Np={readContext:zt,use:bl,useCallback:gp,useContext:zt,useEffect:Pf,useImperativeHandle:yp,useInsertionEffect:dp,useLayoutEffect:mp,useMemo:bp,useReducer:Lf,useRef:up,useState:function(){return Lf(vr)},useDebugValue:Uf,useDeferredValue:function(e,r){var a=St();return rt===null?zf(a,e,r):xp(a,rt.memoizedState,e,r)},useTransition:function(){var e=Lf(vr)[0],r=St().memoizedState;return[typeof e=="boolean"?e:Ra(e),r]},useSyncExternalStore:K0,useId:Sp,useHostTransitionStatus:$f,useFormState:cp,useActionState:cp,useOptimistic:function(e,r){var a=St();return rt!==null?ep(a,rt,e,r):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Rf,useCacheRefresh:Ep};Np.useEffectEvent=hp;function Gf(e,r,a,l){r=e.memoizedState,a=a(l,r),a=a==null?r:b({},r,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Vf={enqueueSetState:function(e,r,a){e=e._reactInternals;var l=gn(),f=Qr(l);f.payload=r,a!=null&&(f.callback=a),r=Wr(e,f,l),r!==null&&(sn(r,e,l),Na(r,e,l))},enqueueReplaceState:function(e,r,a){e=e._reactInternals;var l=gn(),f=Qr(l);f.tag=1,f.payload=r,a!=null&&(f.callback=a),r=Wr(e,f,l),r!==null&&(sn(r,e,l),Na(r,e,l))},enqueueForceUpdate:function(e,r){e=e._reactInternals;var a=gn(),l=Qr(a);l.tag=2,r!=null&&(l.callback=r),r=Wr(e,l,a),r!==null&&(sn(r,e,a),Na(r,e,a))}};function Tp(e,r,a,l,f,p,_){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,p,_):r.prototype&&r.prototype.isPureReactComponent?!_a(a,l)||!_a(f,p):!0}function Cp(e,r,a,l){e=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,l),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,l),r.state!==e&&Vf.enqueueReplaceState(r,r.state,null)}function Gs(e,r){var a=r;if("ref"in r){a={};for(var l in r)l!=="ref"&&(a[l]=r[l])}if(e=e.defaultProps){a===r&&(a=b({},a));for(var f in e)a[f]===void 0&&(a[f]=e[f])}return a}function Mp(e){el(e)}function Rp(e){console.error(e)}function Dp(e){el(e)}function Sl(e,r){try{var a=e.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(l){setTimeout(function(){throw l})}}function Lp(e,r,a){try{var l=e.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function Yf(e,r,a){return a=Qr(a),a.tag=3,a.payload={element:null},a.callback=function(){Sl(e,r)},a}function qp(e){return e=Qr(e),e.tag=3,e}function Bp(e,r,a,l){var f=a.type.getDerivedStateFromError;if(typeof f=="function"){var p=l.value;e.payload=function(){return f(p)},e.callback=function(){Lp(r,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(e.callback=function(){Lp(r,a,l),typeof f!="function"&&(ss===null?ss=new Set([this]):ss.add(this));var O=l.stack;this.componentDidCatch(l.value,{componentStack:O!==null?O:""})})}function J_(e,r,a,l,f){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(r=a.alternate,r!==null&&xi(r,a,f,!0),a=dn.current,a!==null){switch(a.tag){case 31:case 13:return qn===null?Ll():a.alternate===null&&xt===0&&(xt=3),a.flags&=-257,a.flags|=65536,a.lanes=f,l===ul?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([l]):r.add(l),bh(e,l,f)),!1;case 22:return a.flags|=65536,l===ul?a.flags|=16384:(r=a.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=r):(a=r.retryQueue,a===null?r.retryQueue=new Set([l]):a.add(l)),bh(e,l,f)),!1}throw Error(i(435,a.tag))}return bh(e,l,f),Ll(),!1}if(Fe)return r=dn.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=f,l!==hf&&(e=Error(i(422),{cause:l}),Ea(Mn(e,a)))):(l!==hf&&(r=Error(i(423),{cause:l}),Ea(Mn(r,a))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,l=Mn(l,a),f=Yf(e.stateNode,l,f),Sf(e,f),xt!==4&&(xt=2)),!1;var p=Error(i(520),{cause:l});if(p=Mn(p,a),Ha===null?Ha=[p]:Ha.push(p),xt!==4&&(xt=2),r===null)return!0;l=Mn(l,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,e=f&-f,a.lanes|=e,e=Yf(a.stateNode,l,e),Sf(a,e),!1;case 1:if(r=a.type,p=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||p!==null&&typeof p.componentDidCatch=="function"&&(ss===null||!ss.has(p))))return a.flags|=65536,f&=-f,a.lanes|=f,f=qp(f),Bp(f,e,a,l),Sf(a,f),!1}a=a.return}while(a!==null);return!1}var Kf=Error(i(461)),kt=!1;function It(e,r,a,l){r.child=e===null?I0(r,null,a,l):Hs(r,e.child,a,l)}function Pp(e,r,a,l,f){a=a.render;var p=r.ref;if("ref"in l){var _={};for(var O in l)O!=="ref"&&(_[O]=l[O])}else _=l;return Us(r),l=Nf(e,r,a,_,p,f),O=Tf(),e!==null&&!kt?(Cf(e,r,f),_r(e,r,f)):(Fe&&O&&uf(r),r.flags|=1,It(e,r,l,f),r.child)}function Up(e,r,a,l,f){if(e===null){var p=a.type;return typeof p=="function"&&!of(p)&&p.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=p,zp(e,r,p,l,f)):(e=sl(a.type,null,l,r,r.mode,f),e.ref=r.ref,e.return=r,r.child=e)}if(p=e.child,!nh(e,f)){var _=p.memoizedProps;if(a=a.compare,a=a!==null?a:_a,a(_,l)&&e.ref===r.ref)return _r(e,r,f)}return r.flags|=1,e=pr(p,l),e.ref=r.ref,e.return=r,r.child=e}function zp(e,r,a,l,f){if(e!==null){var p=e.memoizedProps;if(_a(p,l)&&e.ref===r.ref)if(kt=!1,r.pendingProps=l=p,nh(e,f))(e.flags&131072)!==0&&(kt=!0);else return r.lanes=e.lanes,_r(e,r,f)}return Jf(e,r,a,l,f)}function Ip(e,r,a,l){var f=l.children,p=e!==null?e.memoizedState:null;if(e===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((r.flags&128)!==0){if(p=p!==null?p.baseLanes|a:a,e!==null){for(l=r.child=e.child,f=0;l!==null;)f=f|l.lanes|l.childLanes,l=l.sibling;l=f&~p}else l=0,r.child=null;return $p(e,r,p,a,l)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},e!==null&&ll(r,p!==null?p.cachePool:null),p!==null?F0(r,p):Of(),G0(r);else return l=r.lanes=536870912,$p(e,r,p!==null?p.baseLanes|a:a,a,l)}else p!==null?(ll(r,p.cachePool),F0(r,p),es(),r.memoizedState=null):(e!==null&&ll(r,null),Of(),es());return It(e,r,f,a),r.child}function qa(e,r){return e!==null&&e.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function $p(e,r,a,l,f){var p=xf();return p=p===null?null:{parent:At._currentValue,pool:p},r.memoizedState={baseLanes:a,cachePool:p},e!==null&&ll(r,null),Of(),G0(r),e!==null&&xi(e,r,l,!0),r.childLanes=f,null}function El(e,r){return r=Al({mode:r.mode,children:r.children},e.mode),r.ref=e.ref,e.child=r,r.return=e,r}function Hp(e,r,a){return Hs(r,e.child,null,a),e=El(r,r.pendingProps),e.flags|=2,mn(r),r.memoizedState=null,e}function X_(e,r,a){var l=r.pendingProps,f=(r.flags&128)!==0;if(r.flags&=-129,e===null){if(Fe){if(l.mode==="hidden")return e=El(r,l),r.lanes=536870912,qa(null,e);if(jf(r),(e=ct)?(e=tg(e,Ln),e=e!==null&&e.data==="&"?e:null,e!==null&&(r.memoizedState={dehydrated:e,treeContext:Vr!==null?{id:tr,overflow:nr}:null,retryLane:536870912,hydrationErrors:null},a=A0(e),a.return=r,r.child=a,Ut=r,ct=null)):e=null,e===null)throw Kr(r);return r.lanes=536870912,null}return El(r,l)}var p=e.memoizedState;if(p!==null){var _=p.dehydrated;if(jf(r),f)if(r.flags&256)r.flags&=-257,r=Hp(e,r,a);else if(r.memoizedState!==null)r.child=e.child,r.flags|=128,r=null;else throw Error(i(558));else if(kt||xi(e,r,a,!1),f=(a&e.childLanes)!==0,kt||f){if(l=ot,l!==null&&(_=Fr(l,a),_!==0&&_!==p.retryLane))throw p.retryLane=_,Ls(e,_),sn(l,e,_),Kf;Ll(),r=Hp(e,r,a)}else e=p.treeContext,ct=Bn(_.nextSibling),Ut=r,Fe=!0,Yr=null,Ln=!1,e!==null&&N0(r,e),r=El(r,l),r.flags|=4096;return r}return e=pr(e.child,{mode:l.mode,children:l.children}),e.ref=r.ref,r.child=e,e.return=r,e}function Ol(e,r){var a=r.ref;if(a===null)e!==null&&e.ref!==null&&(r.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(i(284));(e===null||e.ref!==a)&&(r.flags|=4194816)}}function Jf(e,r,a,l,f){return Us(r),a=Nf(e,r,a,l,void 0,f),l=Tf(),e!==null&&!kt?(Cf(e,r,f),_r(e,r,f)):(Fe&&l&&uf(r),r.flags|=1,It(e,r,a,f),r.child)}function Fp(e,r,a,l,f,p){return Us(r),r.updateQueue=null,a=Y0(r,l,a,f),V0(e),l=Tf(),e!==null&&!kt?(Cf(e,r,p),_r(e,r,p)):(Fe&&l&&uf(r),r.flags|=1,It(e,r,a,p),r.child)}function Gp(e,r,a,l,f){if(Us(r),r.stateNode===null){var p=pi,_=a.contextType;typeof _=="object"&&_!==null&&(p=zt(_)),p=new a(l,p),r.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,p.updater=Vf,r.stateNode=p,p._reactInternals=r,p=r.stateNode,p.props=l,p.state=r.memoizedState,p.refs={},_f(r),_=a.contextType,p.context=typeof _=="object"&&_!==null?zt(_):pi,p.state=r.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Gf(r,a,_,l),p.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(_=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),_!==p.state&&Vf.enqueueReplaceState(p,p.state,null),Ca(r,l,p,f),Ta(),p.state=r.memoizedState),typeof p.componentDidMount=="function"&&(r.flags|=4194308),l=!0}else if(e===null){p=r.stateNode;var O=r.memoizedProps,M=Gs(a,O);p.props=M;var G=p.context,Z=a.contextType;_=pi,typeof Z=="object"&&Z!==null&&(_=zt(Z));var se=a.getDerivedStateFromProps;Z=typeof se=="function"||typeof p.getSnapshotBeforeUpdate=="function",O=r.pendingProps!==O,Z||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(O||G!==_)&&Cp(r,p,l,_),Xr=!1;var Y=r.memoizedState;p.state=Y,Ca(r,l,p,f),Ta(),G=r.memoizedState,O||Y!==G||Xr?(typeof se=="function"&&(Gf(r,a,se,l),G=r.memoizedState),(M=Xr||Tp(r,a,M,l,Y,G,_))?(Z||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount()),typeof p.componentDidMount=="function"&&(r.flags|=4194308)):(typeof p.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=l,r.memoizedState=G),p.props=l,p.state=G,p.context=_,l=M):(typeof p.componentDidMount=="function"&&(r.flags|=4194308),l=!1)}else{p=r.stateNode,wf(e,r),_=r.memoizedProps,Z=Gs(a,_),p.props=Z,se=r.pendingProps,Y=p.context,G=a.contextType,M=pi,typeof G=="object"&&G!==null&&(M=zt(G)),O=a.getDerivedStateFromProps,(G=typeof O=="function"||typeof p.getSnapshotBeforeUpdate=="function")||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(_!==se||Y!==M)&&Cp(r,p,l,M),Xr=!1,Y=r.memoizedState,p.state=Y,Ca(r,l,p,f),Ta();var J=r.memoizedState;_!==se||Y!==J||Xr||e!==null&&e.dependencies!==null&&al(e.dependencies)?(typeof O=="function"&&(Gf(r,a,O,l),J=r.memoizedState),(Z=Xr||Tp(r,a,Z,l,Y,J,M)||e!==null&&e.dependencies!==null&&al(e.dependencies))?(G||typeof p.UNSAFE_componentWillUpdate!="function"&&typeof p.componentWillUpdate!="function"||(typeof p.componentWillUpdate=="function"&&p.componentWillUpdate(l,J,M),typeof p.UNSAFE_componentWillUpdate=="function"&&p.UNSAFE_componentWillUpdate(l,J,M)),typeof p.componentDidUpdate=="function"&&(r.flags|=4),typeof p.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof p.componentDidUpdate!="function"||_===e.memoizedProps&&Y===e.memoizedState||(r.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||_===e.memoizedProps&&Y===e.memoizedState||(r.flags|=1024),r.memoizedProps=l,r.memoizedState=J),p.props=l,p.state=J,p.context=M,l=Z):(typeof p.componentDidUpdate!="function"||_===e.memoizedProps&&Y===e.memoizedState||(r.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||_===e.memoizedProps&&Y===e.memoizedState||(r.flags|=1024),l=!1)}return p=l,Ol(e,r),l=(r.flags&128)!==0,p||l?(p=r.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:p.render(),r.flags|=1,e!==null&&l?(r.child=Hs(r,e.child,null,f),r.child=Hs(r,null,a,f)):It(e,r,a,f),r.memoizedState=p.state,e=r.child):e=_r(e,r,f),e}function Vp(e,r,a,l){return Bs(),r.flags|=256,It(e,r,a,l),r.child}var Xf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Qf(e){return{baseLanes:e,cachePool:L0()}}function Wf(e,r,a){return e=e!==null?e.childLanes&~a:0,r&&(e|=yn),e}function Yp(e,r,a){var l=r.pendingProps,f=!1,p=(r.flags&128)!==0,_;if((_=p)||(_=e!==null&&e.memoizedState===null?!1:(wt.current&2)!==0),_&&(f=!0,r.flags&=-129),_=(r.flags&32)!==0,r.flags&=-33,e===null){if(Fe){if(f?Zr(r):es(),(e=ct)?(e=tg(e,Ln),e=e!==null&&e.data!=="&"?e:null,e!==null&&(r.memoizedState={dehydrated:e,treeContext:Vr!==null?{id:tr,overflow:nr}:null,retryLane:536870912,hydrationErrors:null},a=A0(e),a.return=r,r.child=a,Ut=r,ct=null)):e=null,e===null)throw Kr(r);return Dh(e)?r.lanes=32:r.lanes=536870912,null}var O=l.children;return l=l.fallback,f?(es(),f=r.mode,O=Al({mode:"hidden",children:O},f),l=qs(l,f,a,null),O.return=r,l.return=r,O.sibling=l,r.child=O,l=r.child,l.memoizedState=Qf(a),l.childLanes=Wf(e,_,a),r.memoizedState=Xf,qa(null,l)):(Zr(r),Zf(r,O))}var M=e.memoizedState;if(M!==null&&(O=M.dehydrated,O!==null)){if(p)r.flags&256?(Zr(r),r.flags&=-257,r=eh(e,r,a)):r.memoizedState!==null?(es(),r.child=e.child,r.flags|=128,r=null):(es(),O=l.fallback,f=r.mode,l=Al({mode:"visible",children:l.children},f),O=qs(O,f,a,null),O.flags|=2,l.return=r,O.return=r,l.sibling=O,r.child=l,Hs(r,e.child,null,a),l=r.child,l.memoizedState=Qf(a),l.childLanes=Wf(e,_,a),r.memoizedState=Xf,r=qa(null,l));else if(Zr(r),Dh(O)){if(_=O.nextSibling&&O.nextSibling.dataset,_)var G=_.dgst;_=G,l=Error(i(419)),l.stack="",l.digest=_,Ea({value:l,source:null,stack:null}),r=eh(e,r,a)}else if(kt||xi(e,r,a,!1),_=(a&e.childLanes)!==0,kt||_){if(_=ot,_!==null&&(l=Fr(_,a),l!==0&&l!==M.retryLane))throw M.retryLane=l,Ls(e,l),sn(_,e,l),Kf;Rh(O)||Ll(),r=eh(e,r,a)}else Rh(O)?(r.flags|=192,r.child=e.child,r=null):(e=M.treeContext,ct=Bn(O.nextSibling),Ut=r,Fe=!0,Yr=null,Ln=!1,e!==null&&N0(r,e),r=Zf(r,l.children),r.flags|=4096);return r}return f?(es(),O=l.fallback,f=r.mode,M=e.child,G=M.sibling,l=pr(M,{mode:"hidden",children:l.children}),l.subtreeFlags=M.subtreeFlags&65011712,G!==null?O=pr(G,O):(O=qs(O,f,a,null),O.flags|=2),O.return=r,l.return=r,l.sibling=O,r.child=l,qa(null,l),l=r.child,O=e.child.memoizedState,O===null?O=Qf(a):(f=O.cachePool,f!==null?(M=At._currentValue,f=f.parent!==M?{parent:M,pool:M}:f):f=L0(),O={baseLanes:O.baseLanes|a,cachePool:f}),l.memoizedState=O,l.childLanes=Wf(e,_,a),r.memoizedState=Xf,qa(e.child,l)):(Zr(r),a=e.child,e=a.sibling,a=pr(a,{mode:"visible",children:l.children}),a.return=r,a.sibling=null,e!==null&&(_=r.deletions,_===null?(r.deletions=[e],r.flags|=16):_.push(e)),r.child=a,r.memoizedState=null,a)}function Zf(e,r){return r=Al({mode:"visible",children:r},e.mode),r.return=e,e.child=r}function Al(e,r){return e=hn(22,e,null,r),e.lanes=0,e}function eh(e,r,a){return Hs(r,e.child,null,a),e=Zf(r,r.pendingProps.children),e.flags|=2,r.memoizedState=null,e}function Kp(e,r,a){e.lanes|=r;var l=e.alternate;l!==null&&(l.lanes|=r),pf(e.return,r,a)}function th(e,r,a,l,f,p){var _=e.memoizedState;_===null?e.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:f,treeForkCount:p}:(_.isBackwards=r,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=f,_.treeForkCount=p)}function Jp(e,r,a){var l=r.pendingProps,f=l.revealOrder,p=l.tail;l=l.children;var _=wt.current,O=(_&2)!==0;if(O?(_=_&1|2,r.flags|=128):_&=1,Me(wt,_),It(e,r,l,a),l=Fe?Sa:0,!O&&e!==null&&(e.flags&128)!==0)e:for(e=r.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Kp(e,a,r);else if(e.tag===19)Kp(e,a,r);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===r)break e;for(;e.sibling===null;){if(e.return===null||e.return===r)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(a=r.child,f=null;a!==null;)e=a.alternate,e!==null&&ml(e)===null&&(f=a),a=a.sibling;a=f,a===null?(f=r.child,r.child=null):(f=a.sibling,a.sibling=null),th(r,!1,f,a,p,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,f=r.child,r.child=null;f!==null;){if(e=f.alternate,e!==null&&ml(e)===null){r.child=f;break}e=f.sibling,f.sibling=a,a=f,f=e}th(r,!0,a,null,p,l);break;case"together":th(r,!1,null,null,void 0,l);break;default:r.memoizedState=null}return r.child}function _r(e,r,a){if(e!==null&&(r.dependencies=e.dependencies),rs|=r.lanes,(a&r.childLanes)===0)if(e!==null){if(xi(e,r,a,!1),(a&r.childLanes)===0)return null}else return null;if(e!==null&&r.child!==e.child)throw Error(i(153));if(r.child!==null){for(e=r.child,a=pr(e,e.pendingProps),r.child=a,a.return=r;e.sibling!==null;)e=e.sibling,a=a.sibling=pr(e,e.pendingProps),a.return=r;a.sibling=null}return r.child}function nh(e,r){return(e.lanes&r)!==0?!0:(e=e.dependencies,!!(e!==null&&al(e)))}function Q_(e,r,a){switch(r.tag){case 3:Re(r,r.stateNode.containerInfo),Jr(r,At,e.memoizedState.cache),Bs();break;case 27:case 5:Be(r);break;case 4:Re(r,r.stateNode.containerInfo);break;case 10:Jr(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,jf(r),null;break;case 13:var l=r.memoizedState;if(l!==null)return l.dehydrated!==null?(Zr(r),r.flags|=128,null):(a&r.child.childLanes)!==0?Yp(e,r,a):(Zr(r),e=_r(e,r,a),e!==null?e.sibling:null);Zr(r);break;case 19:var f=(e.flags&128)!==0;if(l=(a&r.childLanes)!==0,l||(xi(e,r,a,!1),l=(a&r.childLanes)!==0),f){if(l)return Jp(e,r,a);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Me(wt,wt.current),l)break;return null;case 22:return r.lanes=0,Ip(e,r,a,r.pendingProps);case 24:Jr(r,At,e.memoizedState.cache)}return _r(e,r,a)}function Xp(e,r,a){if(e!==null)if(e.memoizedProps!==r.pendingProps)kt=!0;else{if(!nh(e,a)&&(r.flags&128)===0)return kt=!1,Q_(e,r,a);kt=(e.flags&131072)!==0}else kt=!1,Fe&&(r.flags&1048576)!==0&&k0(r,Sa,r.index);switch(r.lanes=0,r.tag){case 16:e:{var l=r.pendingProps;if(e=Is(r.elementType),r.type=e,typeof e=="function")of(e)?(l=Gs(e,l),r.tag=1,r=Gp(null,r,e,l,a)):(r.tag=0,r=Jf(null,r,e,l,a));else{if(e!=null){var f=e.$$typeof;if(f===le){r.tag=11,r=Pp(null,r,e,l,a);break e}else if(f===ne){r.tag=14,r=Up(null,r,e,l,a);break e}}throw r=Se(e)||e,Error(i(306,r,""))}}return r;case 0:return Jf(e,r,r.type,r.pendingProps,a);case 1:return l=r.type,f=Gs(l,r.pendingProps),Gp(e,r,l,f,a);case 3:e:{if(Re(r,r.stateNode.containerInfo),e===null)throw Error(i(387));l=r.pendingProps;var p=r.memoizedState;f=p.element,wf(e,r),Ca(r,l,null,a);var _=r.memoizedState;if(l=_.cache,Jr(r,At,l),l!==p.cache&&yf(r,[At],a,!0),Ta(),l=_.element,p.isDehydrated)if(p={element:l,isDehydrated:!1,cache:_.cache},r.updateQueue.baseState=p,r.memoizedState=p,r.flags&256){r=Vp(e,r,l,a);break e}else if(l!==f){f=Mn(Error(i(424)),r),Ea(f),r=Vp(e,r,l,a);break e}else{switch(e=r.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(ct=Bn(e.firstChild),Ut=r,Fe=!0,Yr=null,Ln=!0,a=I0(r,null,l,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Bs(),l===f){r=_r(e,r,a);break e}It(e,r,l,a)}r=r.child}return r;case 26:return Ol(e,r),e===null?(a=og(r.type,null,r.pendingProps,null))?r.memoizedState=a:Fe||(a=r.type,e=r.pendingProps,l=$l(Ct.current).createElement(a),l[at]=r,l[gt]=e,$t(l,a,e),L(l),r.stateNode=l):r.memoizedState=og(r.type,e.memoizedProps,r.pendingProps,e.memoizedState),null;case 27:return Be(r),e===null&&Fe&&(l=r.stateNode=sg(r.type,r.pendingProps,Ct.current),Ut=r,Ln=!0,f=ct,ls(r.type)?(Lh=f,ct=Bn(l.firstChild)):ct=f),It(e,r,r.pendingProps.children,a),Ol(e,r),e===null&&(r.flags|=4194304),r.child;case 5:return e===null&&Fe&&((f=l=ct)&&(l=jw(l,r.type,r.pendingProps,Ln),l!==null?(r.stateNode=l,Ut=r,ct=Bn(l.firstChild),Ln=!1,f=!0):f=!1),f||Kr(r)),Be(r),f=r.type,p=r.pendingProps,_=e!==null?e.memoizedProps:null,l=p.children,Th(f,p)?l=null:_!==null&&Th(f,_)&&(r.flags|=32),r.memoizedState!==null&&(f=Nf(e,r,$_,null,null,a),Qa._currentValue=f),Ol(e,r),It(e,r,l,a),r.child;case 6:return e===null&&Fe&&((e=a=ct)&&(a=kw(a,r.pendingProps,Ln),a!==null?(r.stateNode=a,Ut=r,ct=null,e=!0):e=!1),e||Kr(r)),null;case 13:return Yp(e,r,a);case 4:return Re(r,r.stateNode.containerInfo),l=r.pendingProps,e===null?r.child=Hs(r,null,l,a):It(e,r,l,a),r.child;case 11:return Pp(e,r,r.type,r.pendingProps,a);case 7:return It(e,r,r.pendingProps,a),r.child;case 8:return It(e,r,r.pendingProps.children,a),r.child;case 12:return It(e,r,r.pendingProps.children,a),r.child;case 10:return l=r.pendingProps,Jr(r,r.type,l.value),It(e,r,l.children,a),r.child;case 9:return f=r.type._context,l=r.pendingProps.children,Us(r),f=zt(f),l=l(f),r.flags|=1,It(e,r,l,a),r.child;case 14:return Up(e,r,r.type,r.pendingProps,a);case 15:return zp(e,r,r.type,r.pendingProps,a);case 19:return Jp(e,r,a);case 31:return X_(e,r,a);case 22:return Ip(e,r,a,r.pendingProps);case 24:return Us(r),l=zt(At),e===null?(f=xf(),f===null&&(f=ot,p=gf(),f.pooledCache=p,p.refCount++,p!==null&&(f.pooledCacheLanes|=a),f=p),r.memoizedState={parent:l,cache:f},_f(r),Jr(r,At,f)):((e.lanes&a)!==0&&(wf(e,r),Ca(r,null,null,a),Ta()),f=e.memoizedState,p=r.memoizedState,f.parent!==l?(f={parent:l,cache:l},r.memoizedState=f,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=f),Jr(r,At,l)):(l=p.cache,Jr(r,At,l),l!==f.cache&&yf(r,[At],a,!0))),It(e,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function wr(e){e.flags|=4}function rh(e,r,a,l,f){if((r=(e.mode&32)!==0)&&(r=!1),r){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(Sy())e.flags|=8192;else throw $s=ul,vf}else e.flags&=-16777217}function Qp(e,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!hg(r))if(Sy())e.flags|=8192;else throw $s=ul,vf}function jl(e,r){r!==null&&(e.flags|=4),e.flags&16384&&(r=e.tag!==22?ii():536870912,e.lanes|=r,Ci|=r)}function Ba(e,r){if(!Fe)switch(e.tailMode){case"hidden":r=e.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?r||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function ut(e){var r=e.alternate!==null&&e.alternate.child===e.child,a=0,l=0;if(r)for(var f=e.child;f!==null;)a|=f.lanes|f.childLanes,l|=f.subtreeFlags&65011712,l|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)a|=f.lanes|f.childLanes,l|=f.subtreeFlags,l|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=l,e.childLanes=a,r}function W_(e,r,a){var l=r.pendingProps;switch(ff(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ut(r),null;case 1:return ut(r),null;case 3:return a=r.stateNode,l=null,e!==null&&(l=e.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),br(At),oe(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(bi(r)?wr(r):e===null||e.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,df())),ut(r),null;case 26:var f=r.type,p=r.memoizedState;return e===null?(wr(r),p!==null?(ut(r),Qp(r,p)):(ut(r),rh(r,f,null,l,a))):p?p!==e.memoizedState?(wr(r),ut(r),Qp(r,p)):(ut(r),r.flags&=-16777217):(e=e.memoizedProps,e!==l&&wr(r),ut(r),rh(r,f,e,l,a)),null;case 27:if(We(r),a=Ct.current,f=r.type,e!==null&&r.stateNode!=null)e.memoizedProps!==l&&wr(r);else{if(!l){if(r.stateNode===null)throw Error(i(166));return ut(r),null}e=Ze.current,bi(r)?T0(r):(e=sg(f,l,a),r.stateNode=e,wr(r))}return ut(r),null;case 5:if(We(r),f=r.type,e!==null&&r.stateNode!=null)e.memoizedProps!==l&&wr(r);else{if(!l){if(r.stateNode===null)throw Error(i(166));return ut(r),null}if(p=Ze.current,bi(r))T0(r);else{var _=$l(Ct.current);switch(p){case 1:p=_.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:p=_.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":p=_.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":p=_.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":p=_.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild);break;case"select":p=typeof l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?p.multiple=!0:l.size&&(p.size=l.size);break;default:p=typeof l.is=="string"?_.createElement(f,{is:l.is}):_.createElement(f)}}p[at]=r,p[gt]=l;e:for(_=r.child;_!==null;){if(_.tag===5||_.tag===6)p.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===r)break e;for(;_.sibling===null;){if(_.return===null||_.return===r)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}r.stateNode=p;e:switch($t(p,f,l),f){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&wr(r)}}return ut(r),rh(r,r.type,e===null?null:e.memoizedProps,r.pendingProps,a),null;case 6:if(e&&r.stateNode!=null)e.memoizedProps!==l&&wr(r);else{if(typeof l!="string"&&r.stateNode===null)throw Error(i(166));if(e=Ct.current,bi(r)){if(e=r.stateNode,a=r.memoizedProps,l=null,f=Ut,f!==null)switch(f.tag){case 27:case 5:l=f.memoizedProps}e[at]=r,e=!!(e.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Yy(e.nodeValue,a)),e||Kr(r,!0)}else e=$l(e).createTextNode(l),e[at]=r,r.stateNode=e}return ut(r),null;case 31:if(a=r.memoizedState,e===null||e.memoizedState!==null){if(l=bi(r),a!==null){if(e===null){if(!l)throw Error(i(318));if(e=r.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(557));e[at]=r}else Bs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ut(r),e=!1}else a=df(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return r.flags&256?(mn(r),r):(mn(r),null);if((r.flags&128)!==0)throw Error(i(558))}return ut(r),null;case 13:if(l=r.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=bi(r),l!==null&&l.dehydrated!==null){if(e===null){if(!f)throw Error(i(318));if(f=r.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(i(317));f[at]=r}else Bs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ut(r),f=!1}else f=df(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return r.flags&256?(mn(r),r):(mn(r),null)}return mn(r),(r.flags&128)!==0?(r.lanes=a,r):(a=l!==null,e=e!==null&&e.memoizedState!==null,a&&(l=r.child,f=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(f=l.alternate.memoizedState.cachePool.pool),p=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),p!==f&&(l.flags|=2048)),a!==e&&a&&(r.child.flags|=8192),jl(r,r.updateQueue),ut(r),null);case 4:return oe(),e===null&&Oh(r.stateNode.containerInfo),ut(r),null;case 10:return br(r.type),ut(r),null;case 19:if(Ne(wt),l=r.memoizedState,l===null)return ut(r),null;if(f=(r.flags&128)!==0,p=l.rendering,p===null)if(f)Ba(l,!1);else{if(xt!==0||e!==null&&(e.flags&128)!==0)for(e=r.child;e!==null;){if(p=ml(e),p!==null){for(r.flags|=128,Ba(l,!1),e=p.updateQueue,r.updateQueue=e,jl(r,e),r.subtreeFlags=0,e=a,a=r.child;a!==null;)O0(a,e),a=a.sibling;return Me(wt,wt.current&1|2),Fe&&yr(r,l.treeForkCount),r.child}e=e.sibling}l.tail!==null&&ht()>Ml&&(r.flags|=128,f=!0,Ba(l,!1),r.lanes=4194304)}else{if(!f)if(e=ml(p),e!==null){if(r.flags|=128,f=!0,e=e.updateQueue,r.updateQueue=e,jl(r,e),Ba(l,!0),l.tail===null&&l.tailMode==="hidden"&&!p.alternate&&!Fe)return ut(r),null}else 2*ht()-l.renderingStartTime>Ml&&a!==536870912&&(r.flags|=128,f=!0,Ba(l,!1),r.lanes=4194304);l.isBackwards?(p.sibling=r.child,r.child=p):(e=l.last,e!==null?e.sibling=p:r.child=p,l.last=p)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=ht(),e.sibling=null,a=wt.current,Me(wt,f?a&1|2:a&1),Fe&&yr(r,l.treeForkCount),e):(ut(r),null);case 22:case 23:return mn(r),Af(),l=r.memoizedState!==null,e!==null?e.memoizedState!==null!==l&&(r.flags|=8192):l&&(r.flags|=8192),l?(a&536870912)!==0&&(r.flags&128)===0&&(ut(r),r.subtreeFlags&6&&(r.flags|=8192)):ut(r),a=r.updateQueue,a!==null&&jl(r,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),l=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(l=r.memoizedState.cachePool.pool),l!==a&&(r.flags|=2048),e!==null&&Ne(zs),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),br(At),ut(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function Z_(e,r){switch(ff(r),r.tag){case 1:return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 3:return br(At),oe(),e=r.flags,(e&65536)!==0&&(e&128)===0?(r.flags=e&-65537|128,r):null;case 26:case 27:case 5:return We(r),null;case 31:if(r.memoizedState!==null){if(mn(r),r.alternate===null)throw Error(i(340));Bs()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 13:if(mn(r),e=r.memoizedState,e!==null&&e.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Bs()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 19:return Ne(wt),null;case 4:return oe(),null;case 10:return br(r.type),null;case 22:case 23:return mn(r),Af(),e!==null&&Ne(zs),e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 24:return br(At),null;case 25:return null;default:return null}}function Wp(e,r){switch(ff(r),r.tag){case 3:br(At),oe();break;case 26:case 27:case 5:We(r);break;case 4:oe();break;case 31:r.memoizedState!==null&&mn(r);break;case 13:mn(r);break;case 19:Ne(wt);break;case 10:br(r.type);break;case 22:case 23:mn(r),Af(),e!==null&&Ne(zs);break;case 24:br(At)}}function Pa(e,r){try{var a=r.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var f=l.next;a=f;do{if((a.tag&e)===e){l=void 0;var p=a.create,_=a.inst;l=p(),_.destroy=l}a=a.next}while(a!==f)}}catch(O){tt(r,r.return,O)}}function ts(e,r,a){try{var l=r.updateQueue,f=l!==null?l.lastEffect:null;if(f!==null){var p=f.next;l=p;do{if((l.tag&e)===e){var _=l.inst,O=_.destroy;if(O!==void 0){_.destroy=void 0,f=r;var M=a,G=O;try{G()}catch(Z){tt(f,M,Z)}}}l=l.next}while(l!==p)}}catch(Z){tt(r,r.return,Z)}}function Zp(e){var r=e.updateQueue;if(r!==null){var a=e.stateNode;try{H0(r,a)}catch(l){tt(e,e.return,l)}}}function ey(e,r,a){a.props=Gs(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(l){tt(e,r,l)}}function Ua(e,r){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var l=e.stateNode;break;case 30:l=e.stateNode;break;default:l=e.stateNode}typeof a=="function"?e.refCleanup=a(l):a.current=l}}catch(f){tt(e,r,f)}}function rr(e,r){var a=e.ref,l=e.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(f){tt(e,r,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(f){tt(e,r,f)}else a.current=null}function ty(e){var r=e.type,a=e.memoizedProps,l=e.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(f){tt(e,e.return,f)}}function sh(e,r,a){try{var l=e.stateNode;_w(l,e.type,a,r),l[gt]=r}catch(f){tt(e,e.return,f)}}function ny(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ls(e.type)||e.tag===4}function ih(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ny(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&ls(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ah(e,r,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,r?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,r):(r=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,r.appendChild(e),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=dr));else if(l!==4&&(l===27&&ls(e.type)&&(a=e.stateNode,r=null),e=e.child,e!==null))for(ah(e,r,a),e=e.sibling;e!==null;)ah(e,r,a),e=e.sibling}function kl(e,r,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,r?a.insertBefore(e,r):a.appendChild(e);else if(l!==4&&(l===27&&ls(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(kl(e,r,a),e=e.sibling;e!==null;)kl(e,r,a),e=e.sibling}function ry(e){var r=e.stateNode,a=e.memoizedProps;try{for(var l=e.type,f=r.attributes;f.length;)r.removeAttributeNode(f[0]);$t(r,l,a),r[at]=e,r[gt]=a}catch(p){tt(e,e.return,p)}}var Sr=!1,Nt=!1,oh=!1,sy=typeof WeakSet=="function"?WeakSet:Set,Lt=null;function ew(e,r){if(e=e.containerInfo,kh=Jl,e=y0(e),Zu(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var f=l.anchorOffset,p=l.focusNode;l=l.focusOffset;try{a.nodeType,p.nodeType}catch{a=null;break e}var _=0,O=-1,M=-1,G=0,Z=0,se=e,Y=null;t:for(;;){for(var J;se!==a||f!==0&&se.nodeType!==3||(O=_+f),se!==p||l!==0&&se.nodeType!==3||(M=_+l),se.nodeType===3&&(_+=se.nodeValue.length),(J=se.firstChild)!==null;)Y=se,se=J;for(;;){if(se===e)break t;if(Y===a&&++G===f&&(O=_),Y===p&&++Z===l&&(M=_),(J=se.nextSibling)!==null)break;se=Y,Y=se.parentNode}se=J}a=O===-1||M===-1?null:{start:O,end:M}}else a=null}a=a||{start:0,end:0}}else a=null;for(Nh={focusedElem:e,selectionRange:a},Jl=!1,Lt=r;Lt!==null;)if(r=Lt,e=r.child,(r.subtreeFlags&1028)!==0&&e!==null)e.return=r,Lt=e;else for(;Lt!==null;){switch(r=Lt,p=r.alternate,e=r.flags,r.tag){case 0:if((e&4)!==0&&(e=r.updateQueue,e=e!==null?e.events:null,e!==null))for(a=0;a<e.length;a++)f=e[a],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&p!==null){e=void 0,a=r,f=p.memoizedProps,p=p.memoizedState,l=a.stateNode;try{var be=Gs(a.type,f);e=l.getSnapshotBeforeUpdate(be,p),l.__reactInternalSnapshotBeforeUpdate=e}catch(Te){tt(a,a.return,Te)}}break;case 3:if((e&1024)!==0){if(e=r.stateNode.containerInfo,a=e.nodeType,a===9)Mh(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Mh(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(i(163))}if(e=r.sibling,e!==null){e.return=r.return,Lt=e;break}Lt=r.return}}function iy(e,r,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Or(e,a),l&4&&Pa(5,a);break;case 1:if(Or(e,a),l&4)if(e=a.stateNode,r===null)try{e.componentDidMount()}catch(_){tt(a,a.return,_)}else{var f=Gs(a.type,r.memoizedProps);r=r.memoizedState;try{e.componentDidUpdate(f,r,e.__reactInternalSnapshotBeforeUpdate)}catch(_){tt(a,a.return,_)}}l&64&&Zp(a),l&512&&Ua(a,a.return);break;case 3:if(Or(e,a),l&64&&(e=a.updateQueue,e!==null)){if(r=null,a.child!==null)switch(a.child.tag){case 27:case 5:r=a.child.stateNode;break;case 1:r=a.child.stateNode}try{H0(e,r)}catch(_){tt(a,a.return,_)}}break;case 27:r===null&&l&4&&ry(a);case 26:case 5:Or(e,a),r===null&&l&4&&ty(a),l&512&&Ua(a,a.return);break;case 12:Or(e,a);break;case 31:Or(e,a),l&4&&ly(e,a);break;case 13:Or(e,a),l&4&&cy(e,a),l&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=cw.bind(null,a),Nw(e,a))));break;case 22:if(l=a.memoizedState!==null||Sr,!l){r=r!==null&&r.memoizedState!==null||Nt,f=Sr;var p=Nt;Sr=l,(Nt=r)&&!p?Ar(e,a,(a.subtreeFlags&8772)!==0):Or(e,a),Sr=f,Nt=p}break;case 30:break;default:Or(e,a)}}function ay(e){var r=e.alternate;r!==null&&(e.alternate=null,ay(r)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(r=e.stateNode,r!==null&&ai(r)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var dt=null,en=!1;function Er(e,r,a){for(a=a.child;a!==null;)oy(e,r,a),a=a.sibling}function oy(e,r,a){if(_t&&typeof _t.onCommitFiberUnmount=="function")try{_t.onCommitFiberUnmount(As,a)}catch{}switch(a.tag){case 26:Nt||rr(a,r),Er(e,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Nt||rr(a,r);var l=dt,f=en;ls(a.type)&&(dt=a.stateNode,en=!1),Er(e,r,a),Ka(a.stateNode),dt=l,en=f;break;case 5:Nt||rr(a,r);case 6:if(l=dt,f=en,dt=null,Er(e,r,a),dt=l,en=f,dt!==null)if(en)try{(dt.nodeType===9?dt.body:dt.nodeName==="HTML"?dt.ownerDocument.body:dt).removeChild(a.stateNode)}catch(p){tt(a,r,p)}else try{dt.removeChild(a.stateNode)}catch(p){tt(a,r,p)}break;case 18:dt!==null&&(en?(e=dt,Zy(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Ui(e)):Zy(dt,a.stateNode));break;case 4:l=dt,f=en,dt=a.stateNode.containerInfo,en=!0,Er(e,r,a),dt=l,en=f;break;case 0:case 11:case 14:case 15:ts(2,a,r),Nt||ts(4,a,r),Er(e,r,a);break;case 1:Nt||(rr(a,r),l=a.stateNode,typeof l.componentWillUnmount=="function"&&ey(a,r,l)),Er(e,r,a);break;case 21:Er(e,r,a);break;case 22:Nt=(l=Nt)||a.memoizedState!==null,Er(e,r,a),Nt=l;break;default:Er(e,r,a)}}function ly(e,r){if(r.memoizedState===null&&(e=r.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ui(e)}catch(a){tt(r,r.return,a)}}}function cy(e,r){if(r.memoizedState===null&&(e=r.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ui(e)}catch(a){tt(r,r.return,a)}}function tw(e){switch(e.tag){case 31:case 13:case 19:var r=e.stateNode;return r===null&&(r=e.stateNode=new sy),r;case 22:return e=e.stateNode,r=e._retryCache,r===null&&(r=e._retryCache=new sy),r;default:throw Error(i(435,e.tag))}}function Nl(e,r){var a=tw(e);r.forEach(function(l){if(!a.has(l)){a.add(l);var f=uw.bind(null,e,l);l.then(f,f)}})}function tn(e,r){var a=r.deletions;if(a!==null)for(var l=0;l<a.length;l++){var f=a[l],p=e,_=r,O=_;e:for(;O!==null;){switch(O.tag){case 27:if(ls(O.type)){dt=O.stateNode,en=!1;break e}break;case 5:dt=O.stateNode,en=!1;break e;case 3:case 4:dt=O.stateNode.containerInfo,en=!0;break e}O=O.return}if(dt===null)throw Error(i(160));oy(p,_,f),dt=null,en=!1,p=f.alternate,p!==null&&(p.return=null),f.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)uy(r,e),r=r.sibling}var Vn=null;function uy(e,r){var a=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:tn(r,e),nn(e),l&4&&(ts(3,e,e.return),Pa(3,e),ts(5,e,e.return));break;case 1:tn(r,e),nn(e),l&512&&(Nt||a===null||rr(a,a.return)),l&64&&Sr&&(e=e.updateQueue,e!==null&&(l=e.callbacks,l!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var f=Vn;if(tn(r,e),nn(e),l&512&&(Nt||a===null||rr(a,a.return)),l&4){var p=a!==null?a.memoizedState:null;if(l=e.memoizedState,a===null)if(l===null)if(e.stateNode===null){e:{l=e.type,a=e.memoizedProps,f=f.ownerDocument||f;t:switch(l){case"title":p=f.getElementsByTagName("title")[0],(!p||p[Mt]||p[at]||p.namespaceURI==="http://www.w3.org/2000/svg"||p.hasAttribute("itemprop"))&&(p=f.createElement(l),f.head.insertBefore(p,f.querySelector("head > title"))),$t(p,l,a),p[at]=e,L(p),l=p;break e;case"link":var _=ug("link","href",f).get(l+(a.href||""));if(_){for(var O=0;O<_.length;O++)if(p=_[O],p.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&p.getAttribute("rel")===(a.rel==null?null:a.rel)&&p.getAttribute("title")===(a.title==null?null:a.title)&&p.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(O,1);break t}}p=f.createElement(l),$t(p,l,a),f.head.appendChild(p);break;case"meta":if(_=ug("meta","content",f).get(l+(a.content||""))){for(O=0;O<_.length;O++)if(p=_[O],p.getAttribute("content")===(a.content==null?null:""+a.content)&&p.getAttribute("name")===(a.name==null?null:a.name)&&p.getAttribute("property")===(a.property==null?null:a.property)&&p.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&p.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(O,1);break t}}p=f.createElement(l),$t(p,l,a),f.head.appendChild(p);break;default:throw Error(i(468,l))}p[at]=e,L(p),l=p}e.stateNode=l}else fg(f,e.type,e.stateNode);else e.stateNode=cg(f,l,e.memoizedProps);else p!==l?(p===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):p.count--,l===null?fg(f,e.type,e.stateNode):cg(f,l,e.memoizedProps)):l===null&&e.stateNode!==null&&sh(e,e.memoizedProps,a.memoizedProps)}break;case 27:tn(r,e),nn(e),l&512&&(Nt||a===null||rr(a,a.return)),a!==null&&l&4&&sh(e,e.memoizedProps,a.memoizedProps);break;case 5:if(tn(r,e),nn(e),l&512&&(Nt||a===null||rr(a,a.return)),e.flags&32){f=e.stateNode;try{li(f,"")}catch(be){tt(e,e.return,be)}}l&4&&e.stateNode!=null&&(f=e.memoizedProps,sh(e,f,a!==null?a.memoizedProps:f)),l&1024&&(oh=!0);break;case 6:if(tn(r,e),nn(e),l&4){if(e.stateNode===null)throw Error(i(162));l=e.memoizedProps,a=e.stateNode;try{a.nodeValue=l}catch(be){tt(e,e.return,be)}}break;case 3:if(Gl=null,f=Vn,Vn=Hl(r.containerInfo),tn(r,e),Vn=f,nn(e),l&4&&a!==null&&a.memoizedState.isDehydrated)try{Ui(r.containerInfo)}catch(be){tt(e,e.return,be)}oh&&(oh=!1,fy(e));break;case 4:l=Vn,Vn=Hl(e.stateNode.containerInfo),tn(r,e),nn(e),Vn=l;break;case 12:tn(r,e),nn(e);break;case 31:tn(r,e),nn(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Nl(e,l)));break;case 13:tn(r,e),nn(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Cl=ht()),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Nl(e,l)));break;case 22:f=e.memoizedState!==null;var M=a!==null&&a.memoizedState!==null,G=Sr,Z=Nt;if(Sr=G||f,Nt=Z||M,tn(r,e),Nt=Z,Sr=G,nn(e),l&8192)e:for(r=e.stateNode,r._visibility=f?r._visibility&-2:r._visibility|1,f&&(a===null||M||Sr||Nt||Vs(e)),a=null,r=e;;){if(r.tag===5||r.tag===26){if(a===null){M=a=r;try{if(p=M.stateNode,f)_=p.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{O=M.stateNode;var se=M.memoizedProps.style,Y=se!=null&&se.hasOwnProperty("display")?se.display:null;O.style.display=Y==null||typeof Y=="boolean"?"":(""+Y).trim()}}catch(be){tt(M,M.return,be)}}}else if(r.tag===6){if(a===null){M=r;try{M.stateNode.nodeValue=f?"":M.memoizedProps}catch(be){tt(M,M.return,be)}}}else if(r.tag===18){if(a===null){M=r;try{var J=M.stateNode;f?eg(J,!0):eg(M.stateNode,!1)}catch(be){tt(M,M.return,be)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===e)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break e;for(;r.sibling===null;){if(r.return===null||r.return===e)break e;a===r&&(a=null),r=r.return}a===r&&(a=null),r.sibling.return=r.return,r=r.sibling}l&4&&(l=e.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Nl(e,a))));break;case 19:tn(r,e),nn(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Nl(e,l)));break;case 30:break;case 21:break;default:tn(r,e),nn(e)}}function nn(e){var r=e.flags;if(r&2){try{for(var a,l=e.return;l!==null;){if(ny(l)){a=l;break}l=l.return}if(a==null)throw Error(i(160));switch(a.tag){case 27:var f=a.stateNode,p=ih(e);kl(e,p,f);break;case 5:var _=a.stateNode;a.flags&32&&(li(_,""),a.flags&=-33);var O=ih(e);kl(e,O,_);break;case 3:case 4:var M=a.stateNode.containerInfo,G=ih(e);ah(e,G,M);break;default:throw Error(i(161))}}catch(Z){tt(e,e.return,Z)}e.flags&=-3}r&4096&&(e.flags&=-4097)}function fy(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var r=e;fy(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),e=e.sibling}}function Or(e,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)iy(e,r.alternate,r),r=r.sibling}function Vs(e){for(e=e.child;e!==null;){var r=e;switch(r.tag){case 0:case 11:case 14:case 15:ts(4,r,r.return),Vs(r);break;case 1:rr(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&ey(r,r.return,a),Vs(r);break;case 27:Ka(r.stateNode);case 26:case 5:rr(r,r.return),Vs(r);break;case 22:r.memoizedState===null&&Vs(r);break;case 30:Vs(r);break;default:Vs(r)}e=e.sibling}}function Ar(e,r,a){for(a=a&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var l=r.alternate,f=e,p=r,_=p.flags;switch(p.tag){case 0:case 11:case 15:Ar(f,p,a),Pa(4,p);break;case 1:if(Ar(f,p,a),l=p,f=l.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(G){tt(l,l.return,G)}if(l=p,f=l.updateQueue,f!==null){var O=l.stateNode;try{var M=f.shared.hiddenCallbacks;if(M!==null)for(f.shared.hiddenCallbacks=null,f=0;f<M.length;f++)$0(M[f],O)}catch(G){tt(l,l.return,G)}}a&&_&64&&Zp(p),Ua(p,p.return);break;case 27:ry(p);case 26:case 5:Ar(f,p,a),a&&l===null&&_&4&&ty(p),Ua(p,p.return);break;case 12:Ar(f,p,a);break;case 31:Ar(f,p,a),a&&_&4&&ly(f,p);break;case 13:Ar(f,p,a),a&&_&4&&cy(f,p);break;case 22:p.memoizedState===null&&Ar(f,p,a),Ua(p,p.return);break;case 30:break;default:Ar(f,p,a)}r=r.sibling}}function lh(e,r){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(e=r.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Oa(a))}function ch(e,r){e=null,r.alternate!==null&&(e=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==e&&(r.refCount++,e!=null&&Oa(e))}function Yn(e,r,a,l){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)hy(e,r,a,l),r=r.sibling}function hy(e,r,a,l){var f=r.flags;switch(r.tag){case 0:case 11:case 15:Yn(e,r,a,l),f&2048&&Pa(9,r);break;case 1:Yn(e,r,a,l);break;case 3:Yn(e,r,a,l),f&2048&&(e=null,r.alternate!==null&&(e=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==e&&(r.refCount++,e!=null&&Oa(e)));break;case 12:if(f&2048){Yn(e,r,a,l),e=r.stateNode;try{var p=r.memoizedProps,_=p.id,O=p.onPostCommit;typeof O=="function"&&O(_,r.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(M){tt(r,r.return,M)}}else Yn(e,r,a,l);break;case 31:Yn(e,r,a,l);break;case 13:Yn(e,r,a,l);break;case 23:break;case 22:p=r.stateNode,_=r.alternate,r.memoizedState!==null?p._visibility&2?Yn(e,r,a,l):za(e,r):p._visibility&2?Yn(e,r,a,l):(p._visibility|=2,ki(e,r,a,l,(r.subtreeFlags&10256)!==0||!1)),f&2048&&lh(_,r);break;case 24:Yn(e,r,a,l),f&2048&&ch(r.alternate,r);break;default:Yn(e,r,a,l)}}function ki(e,r,a,l,f){for(f=f&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var p=e,_=r,O=a,M=l,G=_.flags;switch(_.tag){case 0:case 11:case 15:ki(p,_,O,M,f),Pa(8,_);break;case 23:break;case 22:var Z=_.stateNode;_.memoizedState!==null?Z._visibility&2?ki(p,_,O,M,f):za(p,_):(Z._visibility|=2,ki(p,_,O,M,f)),f&&G&2048&&lh(_.alternate,_);break;case 24:ki(p,_,O,M,f),f&&G&2048&&ch(_.alternate,_);break;default:ki(p,_,O,M,f)}r=r.sibling}}function za(e,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var a=e,l=r,f=l.flags;switch(l.tag){case 22:za(a,l),f&2048&&lh(l.alternate,l);break;case 24:za(a,l),f&2048&&ch(l.alternate,l);break;default:za(a,l)}r=r.sibling}}var Ia=8192;function Ni(e,r,a){if(e.subtreeFlags&Ia)for(e=e.child;e!==null;)dy(e,r,a),e=e.sibling}function dy(e,r,a){switch(e.tag){case 26:Ni(e,r,a),e.flags&Ia&&e.memoizedState!==null&&Iw(a,Vn,e.memoizedState,e.memoizedProps);break;case 5:Ni(e,r,a);break;case 3:case 4:var l=Vn;Vn=Hl(e.stateNode.containerInfo),Ni(e,r,a),Vn=l;break;case 22:e.memoizedState===null&&(l=e.alternate,l!==null&&l.memoizedState!==null?(l=Ia,Ia=16777216,Ni(e,r,a),Ia=l):Ni(e,r,a));break;default:Ni(e,r,a)}}function my(e){var r=e.alternate;if(r!==null&&(e=r.child,e!==null)){r.child=null;do r=e.sibling,e.sibling=null,e=r;while(e!==null)}}function $a(e){var r=e.deletions;if((e.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Lt=l,yy(l,e)}my(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)py(e),e=e.sibling}function py(e){switch(e.tag){case 0:case 11:case 15:$a(e),e.flags&2048&&ts(9,e,e.return);break;case 3:$a(e);break;case 12:$a(e);break;case 22:var r=e.stateNode;e.memoizedState!==null&&r._visibility&2&&(e.return===null||e.return.tag!==13)?(r._visibility&=-3,Tl(e)):$a(e);break;default:$a(e)}}function Tl(e){var r=e.deletions;if((e.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Lt=l,yy(l,e)}my(e)}for(e=e.child;e!==null;){switch(r=e,r.tag){case 0:case 11:case 15:ts(8,r,r.return),Tl(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,Tl(r));break;default:Tl(r)}e=e.sibling}}function yy(e,r){for(;Lt!==null;){var a=Lt;switch(a.tag){case 0:case 11:case 15:ts(8,a,r);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Oa(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Lt=l;else e:for(a=e;Lt!==null;){l=Lt;var f=l.sibling,p=l.return;if(ay(l),l===a){Lt=null;break e}if(f!==null){f.return=p,Lt=f;break e}Lt=p}}}var nw={getCacheForType:function(e){var r=zt(At),a=r.data.get(e);return a===void 0&&(a=e(),r.data.set(e,a)),a},cacheSignal:function(){return zt(At).controller.signal}},rw=typeof WeakMap=="function"?WeakMap:Map,Qe=0,ot=null,Pe=null,ze=0,et=0,pn=null,ns=!1,Ti=!1,uh=!1,jr=0,xt=0,rs=0,Ys=0,fh=0,yn=0,Ci=0,Ha=null,rn=null,hh=!1,Cl=0,gy=0,Ml=1/0,Rl=null,ss=null,Rt=0,is=null,Mi=null,kr=0,dh=0,mh=null,by=null,Fa=0,ph=null;function gn(){return(Qe&2)!==0&&ze!==0?ze&-ze:H.T!==null?_h():ha()}function xy(){if(yn===0)if((ze&536870912)===0||Fe){var e=ur;ur<<=1,(ur&3932160)===0&&(ur=262144),yn=e}else yn=536870912;return e=dn.current,e!==null&&(e.flags|=32),yn}function sn(e,r,a){(e===ot&&(et===2||et===9)||e.cancelPendingCommit!==null)&&(Ri(e,0),as(e,ze,yn,!1)),Hn(e,a),((Qe&2)===0||e!==ot)&&(e===ot&&((Qe&2)===0&&(Ys|=a),xt===4&&as(e,ze,yn,!1)),sr(e))}function vy(e,r,a){if((Qe&6)!==0)throw Error(i(327));var l=!a&&(r&127)===0&&(r&e.expiredLanes)===0||ks(e,r),f=l?aw(e,r):gh(e,r,!0),p=l;do{if(f===0){Ti&&!l&&as(e,r,0,!1);break}else{if(a=e.current.alternate,p&&!sw(a)){f=gh(e,r,!1),p=!1;continue}if(f===2){if(p=r,e.errorRecoveryDisabledLanes&p)var _=0;else _=e.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){r=_;e:{var O=e;f=Ha;var M=O.current.memoizedState.isDehydrated;if(M&&(Ri(O,_).flags|=256),_=gh(O,_,!1),_!==2){if(uh&&!M){O.errorRecoveryDisabledLanes|=p,Ys|=p,f=4;break e}p=rn,rn=f,p!==null&&(rn===null?rn=p:rn.push.apply(rn,p))}f=_}if(p=!1,f!==2)continue}}if(f===1){Ri(e,0),as(e,r,0,!0);break}e:{switch(l=e,p=f,p){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:as(l,r,yn,!ns);break e;case 2:rn=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(f=Cl+300-ht(),10<f)){if(as(l,r,yn,!ns),js(l,0,!0)!==0)break e;kr=r,l.timeoutHandle=Qy(_y.bind(null,l,a,rn,Rl,hh,r,yn,Ys,Ci,ns,p,"Throttled",-0,0),f);break e}_y(l,a,rn,Rl,hh,r,yn,Ys,Ci,ns,p,null,-0,0)}}break}while(!0);sr(e)}function _y(e,r,a,l,f,p,_,O,M,G,Z,se,Y,J){if(e.timeoutHandle=-1,se=r.subtreeFlags,se&8192||(se&16785408)===16785408){se={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:dr},dy(r,p,se);var be=(p&62914560)===p?Cl-ht():(p&4194048)===p?gy-ht():0;if(be=$w(se,be),be!==null){kr=p,e.cancelPendingCommit=be(Ny.bind(null,e,r,p,a,l,f,_,O,M,Z,se,null,Y,J)),as(e,p,_,!G);return}}Ny(e,r,p,a,l,f,_,O,M)}function sw(e){for(var r=e;;){var a=r.tag;if((a===0||a===11||a===15)&&r.flags&16384&&(a=r.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var f=a[l],p=f.getSnapshot;f=f.value;try{if(!fn(p(),f))return!1}catch{return!1}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function as(e,r,a,l){r&=~fh,r&=~Ys,e.suspendedLanes|=r,e.pingedLanes&=~r,l&&(e.warmLanes|=r),l=e.expirationTimes;for(var f=r;0<f;){var p=31-Ft(f),_=1<<p;l[p]=-1,f&=~_}a!==0&&Hr(e,a,r)}function Dl(){return(Qe&6)===0?(Ga(0),!1):!0}function yh(){if(Pe!==null){if(et===0)var e=Pe.return;else e=Pe,gr=Ps=null,Mf(e),Si=null,ja=0,e=Pe;for(;e!==null;)Wp(e.alternate,e),e=e.return;Pe=null}}function Ri(e,r){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,Ew(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),kr=0,yh(),ot=e,Pe=a=pr(e.current,null),ze=r,et=0,pn=null,ns=!1,Ti=ks(e,r),uh=!1,Ci=yn=fh=Ys=rs=xt=0,rn=Ha=null,hh=!1,(r&8)!==0&&(r|=r&32);var l=e.entangledLanes;if(l!==0)for(e=e.entanglements,l&=r;0<l;){var f=31-Ft(l),p=1<<f;r|=e[f],l&=~p}return jr=r,tl(),a}function wy(e,r){De=null,H.H=La,r===wi||r===cl?(r=P0(),et=3):r===vf?(r=P0(),et=4):et=r===Kf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,pn=r,Pe===null&&(xt=1,Sl(e,Mn(r,e.current)))}function Sy(){var e=dn.current;return e===null?!0:(ze&4194048)===ze?qn===null:(ze&62914560)===ze||(ze&536870912)!==0?e===qn:!1}function Ey(){var e=H.H;return H.H=La,e===null?La:e}function Oy(){var e=H.A;return H.A=nw,e}function Ll(){xt=4,ns||(ze&4194048)!==ze&&dn.current!==null||(Ti=!0),(rs&134217727)===0&&(Ys&134217727)===0||ot===null||as(ot,ze,yn,!1)}function gh(e,r,a){var l=Qe;Qe|=2;var f=Ey(),p=Oy();(ot!==e||ze!==r)&&(Rl=null,Ri(e,r)),r=!1;var _=xt;e:do try{if(et!==0&&Pe!==null){var O=Pe,M=pn;switch(et){case 8:yh(),_=6;break e;case 3:case 2:case 9:case 6:dn.current===null&&(r=!0);var G=et;if(et=0,pn=null,Di(e,O,M,G),a&&Ti){_=0;break e}break;default:G=et,et=0,pn=null,Di(e,O,M,G)}}iw(),_=xt;break}catch(Z){wy(e,Z)}while(!0);return r&&e.shellSuspendCounter++,gr=Ps=null,Qe=l,H.H=f,H.A=p,Pe===null&&(ot=null,ze=0,tl()),_}function iw(){for(;Pe!==null;)Ay(Pe)}function aw(e,r){var a=Qe;Qe|=2;var l=Ey(),f=Oy();ot!==e||ze!==r?(Rl=null,Ml=ht()+500,Ri(e,r)):Ti=ks(e,r);e:do try{if(et!==0&&Pe!==null){r=Pe;var p=pn;t:switch(et){case 1:et=0,pn=null,Di(e,r,p,1);break;case 2:case 9:if(q0(p)){et=0,pn=null,jy(r);break}r=function(){et!==2&&et!==9||ot!==e||(et=7),sr(e)},p.then(r,r);break e;case 3:et=7;break e;case 4:et=5;break e;case 7:q0(p)?(et=0,pn=null,jy(r)):(et=0,pn=null,Di(e,r,p,7));break;case 5:var _=null;switch(Pe.tag){case 26:_=Pe.memoizedState;case 5:case 27:var O=Pe;if(_?hg(_):O.stateNode.complete){et=0,pn=null;var M=O.sibling;if(M!==null)Pe=M;else{var G=O.return;G!==null?(Pe=G,ql(G)):Pe=null}break t}}et=0,pn=null,Di(e,r,p,5);break;case 6:et=0,pn=null,Di(e,r,p,6);break;case 8:yh(),xt=6;break e;default:throw Error(i(462))}}ow();break}catch(Z){wy(e,Z)}while(!0);return gr=Ps=null,H.H=l,H.A=f,Qe=a,Pe!==null?0:(ot=null,ze=0,tl(),xt)}function ow(){for(;Pe!==null&&!Po();)Ay(Pe)}function Ay(e){var r=Xp(e.alternate,e,jr);e.memoizedProps=e.pendingProps,r===null?ql(e):Pe=r}function jy(e){var r=e,a=r.alternate;switch(r.tag){case 15:case 0:r=Fp(a,r,r.pendingProps,r.type,void 0,ze);break;case 11:r=Fp(a,r,r.pendingProps,r.type.render,r.ref,ze);break;case 5:Mf(r);default:Wp(a,r),r=Pe=O0(r,jr),r=Xp(a,r,jr)}e.memoizedProps=e.pendingProps,r===null?ql(e):Pe=r}function Di(e,r,a,l){gr=Ps=null,Mf(r),Si=null,ja=0;var f=r.return;try{if(J_(e,f,r,a,ze)){xt=1,Sl(e,Mn(a,e.current)),Pe=null;return}}catch(p){if(f!==null)throw Pe=f,p;xt=1,Sl(e,Mn(a,e.current)),Pe=null;return}r.flags&32768?(Fe||l===1?e=!0:Ti||(ze&536870912)!==0?e=!1:(ns=e=!0,(l===2||l===9||l===3||l===6)&&(l=dn.current,l!==null&&l.tag===13&&(l.flags|=16384))),ky(r,e)):ql(r)}function ql(e){var r=e;do{if((r.flags&32768)!==0){ky(r,ns);return}e=r.return;var a=W_(r.alternate,r,jr);if(a!==null){Pe=a;return}if(r=r.sibling,r!==null){Pe=r;return}Pe=r=e}while(r!==null);xt===0&&(xt=5)}function ky(e,r){do{var a=Z_(e.alternate,e);if(a!==null){a.flags&=32767,Pe=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!r&&(e=e.sibling,e!==null)){Pe=e;return}Pe=e=a}while(e!==null);xt=6,Pe=null}function Ny(e,r,a,l,f,p,_,O,M){e.cancelPendingCommit=null;do Bl();while(Rt!==0);if((Qe&6)!==0)throw Error(i(327));if(r!==null){if(r===e.current)throw Error(i(177));if(p=r.lanes|r.childLanes,p|=sf,$r(e,a,p,_,O,M),e===ot&&(Pe=ot=null,ze=0),Mi=r,is=e,kr=a,dh=p,mh=f,by=l,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,fw(ri,function(){return Dy(),null})):(e.callbackNode=null,e.callbackPriority=0),l=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||l){l=H.T,H.T=null,f=W.p,W.p=2,_=Qe,Qe|=4;try{ew(e,r,a)}finally{Qe=_,W.p=f,H.T=l}}Rt=1,Ty(),Cy(),My()}}function Ty(){if(Rt===1){Rt=0;var e=is,r=Mi,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=H.T,H.T=null;var l=W.p;W.p=2;var f=Qe;Qe|=4;try{uy(r,e);var p=Nh,_=y0(e.containerInfo),O=p.focusedElem,M=p.selectionRange;if(_!==O&&O&&O.ownerDocument&&p0(O.ownerDocument.documentElement,O)){if(M!==null&&Zu(O)){var G=M.start,Z=M.end;if(Z===void 0&&(Z=G),"selectionStart"in O)O.selectionStart=G,O.selectionEnd=Math.min(Z,O.value.length);else{var se=O.ownerDocument||document,Y=se&&se.defaultView||window;if(Y.getSelection){var J=Y.getSelection(),be=O.textContent.length,Te=Math.min(M.start,be),it=M.end===void 0?Te:Math.min(M.end,be);!J.extend&&Te>it&&(_=it,it=Te,Te=_);var U=m0(O,Te),P=m0(O,it);if(U&&P&&(J.rangeCount!==1||J.anchorNode!==U.node||J.anchorOffset!==U.offset||J.focusNode!==P.node||J.focusOffset!==P.offset)){var F=se.createRange();F.setStart(U.node,U.offset),J.removeAllRanges(),Te>it?(J.addRange(F),J.extend(P.node,P.offset)):(F.setEnd(P.node,P.offset),J.addRange(F))}}}}for(se=[],J=O;J=J.parentNode;)J.nodeType===1&&se.push({element:J,left:J.scrollLeft,top:J.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;O<se.length;O++){var ee=se[O];ee.element.scrollLeft=ee.left,ee.element.scrollTop=ee.top}}Jl=!!kh,Nh=kh=null}finally{Qe=f,W.p=l,H.T=a}}e.current=r,Rt=2}}function Cy(){if(Rt===2){Rt=0;var e=is,r=Mi,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=H.T,H.T=null;var l=W.p;W.p=2;var f=Qe;Qe|=4;try{iy(e,r.alternate,r)}finally{Qe=f,W.p=l,H.T=a}}Rt=3}}function My(){if(Rt===4||Rt===3){Rt=0,ni();var e=is,r=Mi,a=kr,l=by;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Rt=5:(Rt=0,Mi=is=null,Ry(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(ss=null),Ts(a),r=r.stateNode,_t&&typeof _t.onCommitFiberRoot=="function")try{_t.onCommitFiberRoot(As,r,void 0,(r.current.flags&128)===128)}catch{}if(l!==null){r=H.T,f=W.p,W.p=2,H.T=null;try{for(var p=e.onRecoverableError,_=0;_<l.length;_++){var O=l[_];p(O.value,{componentStack:O.stack})}}finally{H.T=r,W.p=f}}(kr&3)!==0&&Bl(),sr(e),f=e.pendingLanes,(a&261930)!==0&&(f&42)!==0?e===ph?Fa++:(Fa=0,ph=e):Fa=0,Ga(0)}}function Ry(e,r){(e.pooledCacheLanes&=r)===0&&(r=e.pooledCache,r!=null&&(e.pooledCache=null,Oa(r)))}function Bl(){return Ty(),Cy(),My(),Dy()}function Dy(){if(Rt!==5)return!1;var e=is,r=dh;dh=0;var a=Ts(kr),l=H.T,f=W.p;try{W.p=32>a?32:a,H.T=null,a=mh,mh=null;var p=is,_=kr;if(Rt=0,Mi=is=null,kr=0,(Qe&6)!==0)throw Error(i(331));var O=Qe;if(Qe|=4,py(p.current),hy(p,p.current,_,a),Qe=O,Ga(0,!1),_t&&typeof _t.onPostCommitFiberRoot=="function")try{_t.onPostCommitFiberRoot(As,p)}catch{}return!0}finally{W.p=f,H.T=l,Ry(e,r)}}function Ly(e,r,a){r=Mn(a,r),r=Yf(e.stateNode,r,2),e=Wr(e,r,2),e!==null&&(Hn(e,2),sr(e))}function tt(e,r,a){if(e.tag===3)Ly(e,e,a);else for(;r!==null;){if(r.tag===3){Ly(r,e,a);break}else if(r.tag===1){var l=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(ss===null||!ss.has(l))){e=Mn(a,e),a=qp(2),l=Wr(r,a,2),l!==null&&(Bp(a,l,r,e),Hn(l,2),sr(l));break}}r=r.return}}function bh(e,r,a){var l=e.pingCache;if(l===null){l=e.pingCache=new rw;var f=new Set;l.set(r,f)}else f=l.get(r),f===void 0&&(f=new Set,l.set(r,f));f.has(a)||(uh=!0,f.add(a),e=lw.bind(null,e,r,a),r.then(e,e))}function lw(e,r,a){var l=e.pingCache;l!==null&&l.delete(r),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,ot===e&&(ze&a)===a&&(xt===4||xt===3&&(ze&62914560)===ze&&300>ht()-Cl?(Qe&2)===0&&Ri(e,0):fh|=a,Ci===ze&&(Ci=0)),sr(e)}function qy(e,r){r===0&&(r=ii()),e=Ls(e,r),e!==null&&(Hn(e,r),sr(e))}function cw(e){var r=e.memoizedState,a=0;r!==null&&(a=r.retryLane),qy(e,a)}function uw(e,r){var a=0;switch(e.tag){case 31:case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(a=f.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(i(314))}l!==null&&l.delete(r),qy(e,a)}function fw(e,r){return la(e,r)}var Pl=null,Li=null,xh=!1,Ul=!1,vh=!1,os=0;function sr(e){e!==Li&&e.next===null&&(Li===null?Pl=Li=e:Li=Li.next=e),Ul=!0,xh||(xh=!0,dw())}function Ga(e,r){if(!vh&&Ul){vh=!0;do for(var a=!1,l=Pl;l!==null;){if(e!==0){var f=l.pendingLanes;if(f===0)var p=0;else{var _=l.suspendedLanes,O=l.pingedLanes;p=(1<<31-Ft(42|e)+1)-1,p&=f&~(_&~O),p=p&201326741?p&201326741|1:p?p|2:0}p!==0&&(a=!0,zy(l,p))}else p=ze,p=js(l,l===ot?p:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(p&3)===0||ks(l,p)||(a=!0,zy(l,p));l=l.next}while(a);vh=!1}}function hw(){By()}function By(){Ul=xh=!1;var e=0;os!==0&&Sw()&&(e=os);for(var r=ht(),a=null,l=Pl;l!==null;){var f=l.next,p=Py(l,r);p===0?(l.next=null,a===null?Pl=f:a.next=f,f===null&&(Li=a)):(a=l,(e!==0||(p&3)!==0)&&(Ul=!0)),l=f}Rt!==0&&Rt!==5||Ga(e),os!==0&&(os=0)}function Py(e,r){for(var a=e.suspendedLanes,l=e.pingedLanes,f=e.expirationTimes,p=e.pendingLanes&-62914561;0<p;){var _=31-Ft(p),O=1<<_,M=f[_];M===-1?((O&a)===0||(O&l)!==0)&&(f[_]=fa(O,r)):M<=r&&(e.expiredLanes|=O),p&=~O}if(r=ot,a=ze,a=js(e,e===r?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l=e.callbackNode,a===0||e===r&&(et===2||et===9)||e.cancelPendingCommit!==null)return l!==null&&l!==null&&cr(l),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||ks(e,a)){if(r=a&-a,r===e.callbackPriority)return r;switch(l!==null&&cr(l),Ts(a)){case 2:case 8:a=zo;break;case 32:a=ri;break;case 268435456:a=Io;break;default:a=ri}return l=Uy.bind(null,e),a=la(a,l),e.callbackPriority=r,e.callbackNode=a,r}return l!==null&&l!==null&&cr(l),e.callbackPriority=2,e.callbackNode=null,2}function Uy(e,r){if(Rt!==0&&Rt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Bl()&&e.callbackNode!==a)return null;var l=ze;return l=js(e,e===ot?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l===0?null:(vy(e,l,r),Py(e,ht()),e.callbackNode!=null&&e.callbackNode===a?Uy.bind(null,e):null)}function zy(e,r){if(Bl())return null;vy(e,r,!0)}function dw(){Ow(function(){(Qe&6)!==0?la(Uo,hw):By()})}function _h(){if(os===0){var e=vi;e===0&&(e=Ur,Ur<<=1,(Ur&261888)===0&&(Ur=256)),os=e}return os}function Iy(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Yo(""+e)}function $y(e,r){var a=r.ownerDocument.createElement("input");return a.name=r.name,a.value=r.value,e.id&&a.setAttribute("form",e.id),r.parentNode.insertBefore(a,r),e=new FormData(e),a.parentNode.removeChild(a),e}function mw(e,r,a,l,f){if(r==="submit"&&a&&a.stateNode===f){var p=Iy((f[gt]||null).action),_=l.submitter;_&&(r=(r=_[gt]||null)?Iy(r.formAction):_.getAttribute("formAction"),r!==null&&(p=r,_=null));var O=new Qo("action","action",null,l,f);e.push({event:O,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(os!==0){var M=_?$y(f,_):new FormData(f);If(a,{pending:!0,data:M,method:f.method,action:p},null,M)}}else typeof p=="function"&&(O.preventDefault(),M=_?$y(f,_):new FormData(f),If(a,{pending:!0,data:M,method:f.method,action:p},p,M))},currentTarget:f}]})}}for(var wh=0;wh<rf.length;wh++){var Sh=rf[wh],pw=Sh.toLowerCase(),yw=Sh[0].toUpperCase()+Sh.slice(1);Gn(pw,"on"+yw)}Gn(x0,"onAnimationEnd"),Gn(v0,"onAnimationIteration"),Gn(_0,"onAnimationStart"),Gn("dblclick","onDoubleClick"),Gn("focusin","onFocus"),Gn("focusout","onBlur"),Gn(M_,"onTransitionRun"),Gn(R_,"onTransitionStart"),Gn(D_,"onTransitionCancel"),Gn(w0,"onTransitionEnd"),K("onMouseEnter",["mouseout","mouseover"]),K("onMouseLeave",["mouseout","mouseover"]),K("onPointerEnter",["pointerout","pointerover"]),K("onPointerLeave",["pointerout","pointerover"]),ae("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ae("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ae("onBeforeInput",["compositionend","keypress","textInput","paste"]),ae("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ae("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ae("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Va="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),gw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Va));function Hy(e,r){r=(r&4)!==0;for(var a=0;a<e.length;a++){var l=e[a],f=l.event;l=l.listeners;e:{var p=void 0;if(r)for(var _=l.length-1;0<=_;_--){var O=l[_],M=O.instance,G=O.currentTarget;if(O=O.listener,M!==p&&f.isPropagationStopped())break e;p=O,f.currentTarget=G;try{p(f)}catch(Z){el(Z)}f.currentTarget=null,p=M}else for(_=0;_<l.length;_++){if(O=l[_],M=O.instance,G=O.currentTarget,O=O.listener,M!==p&&f.isPropagationStopped())break e;p=O,f.currentTarget=G;try{p(f)}catch(Z){el(Z)}f.currentTarget=null,p=M}}}}function Ue(e,r){var a=r[Cs];a===void 0&&(a=r[Cs]=new Set);var l=e+"__bubble";a.has(l)||(Fy(r,e,2,!1),a.add(l))}function Eh(e,r,a){var l=0;r&&(l|=4),Fy(a,e,l,r)}var zl="_reactListening"+Math.random().toString(36).slice(2);function Oh(e){if(!e[zl]){e[zl]=!0,z.forEach(function(a){a!=="selectionchange"&&(gw.has(a)||Eh(a,!1,e),Eh(a,!0,e))});var r=e.nodeType===9?e:e.ownerDocument;r===null||r[zl]||(r[zl]=!0,Eh("selectionchange",!1,r))}}function Fy(e,r,a,l){switch(xg(r)){case 2:var f=Gw;break;case 8:f=Vw;break;default:f=zh}a=f.bind(null,r,a,e),f=void 0,!Fu||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),l?f!==void 0?e.addEventListener(r,a,{capture:!0,passive:f}):e.addEventListener(r,a,!0):f!==void 0?e.addEventListener(r,a,{passive:f}):e.addEventListener(r,a,!1)}function Ah(e,r,a,l,f){var p=l;if((r&1)===0&&(r&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var O=l.stateNode.containerInfo;if(O===f)break;if(_===4)for(_=l.return;_!==null;){var M=_.tag;if((M===3||M===4)&&_.stateNode.containerInfo===f)return;_=_.return}for(;O!==null;){if(_=A(O),_===null)return;if(M=_.tag,M===5||M===6||M===26||M===27){l=p=_;continue e}O=O.parentNode}}l=l.return}Jm(function(){var G=p,Z=$u(a),se=[];e:{var Y=S0.get(e);if(Y!==void 0){var J=Qo,be=e;switch(e){case"keypress":if(Jo(a)===0)break e;case"keydown":case"keyup":J=u_;break;case"focusin":be="focus",J=Ku;break;case"focusout":be="blur",J=Ku;break;case"beforeblur":case"afterblur":J=Ku;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":J=Wm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":J=Wv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":J=d_;break;case x0:case v0:case _0:J=t_;break;case w0:J=p_;break;case"scroll":case"scrollend":J=Xv;break;case"wheel":J=g_;break;case"copy":case"cut":case"paste":J=r_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":J=e0;break;case"toggle":case"beforetoggle":J=x_}var Te=(r&4)!==0,it=!Te&&(e==="scroll"||e==="scrollend"),U=Te?Y!==null?Y+"Capture":null:Y;Te=[];for(var P=G,F;P!==null;){var ee=P;if(F=ee.stateNode,ee=ee.tag,ee!==5&&ee!==26&&ee!==27||F===null||U===null||(ee=ma(P,U),ee!=null&&Te.push(Ya(P,ee,F))),it)break;P=P.return}0<Te.length&&(Y=new J(Y,be,null,a,Z),se.push({event:Y,listeners:Te}))}}if((r&7)===0){e:{if(Y=e==="mouseover"||e==="pointerover",J=e==="mouseout"||e==="pointerout",Y&&a!==Iu&&(be=a.relatedTarget||a.fromElement)&&(A(be)||be[un]))break e;if((J||Y)&&(Y=Z.window===Z?Z:(Y=Z.ownerDocument)?Y.defaultView||Y.parentWindow:window,J?(be=a.relatedTarget||a.toElement,J=G,be=be?A(be):null,be!==null&&(it=c(be),Te=be.tag,be!==it||Te!==5&&Te!==27&&Te!==6)&&(be=null)):(J=null,be=G),J!==be)){if(Te=Wm,ee="onMouseLeave",U="onMouseEnter",P="mouse",(e==="pointerout"||e==="pointerover")&&(Te=e0,ee="onPointerLeave",U="onPointerEnter",P="pointer"),it=J==null?Y:k(J),F=be==null?Y:k(be),Y=new Te(ee,P+"leave",J,a,Z),Y.target=it,Y.relatedTarget=F,ee=null,A(Z)===G&&(Te=new Te(U,P+"enter",be,a,Z),Te.target=F,Te.relatedTarget=it,ee=Te),it=ee,J&&be)t:{for(Te=bw,U=J,P=be,F=0,ee=U;ee;ee=Te(ee))F++;ee=0;for(var Oe=P;Oe;Oe=Te(Oe))ee++;for(;0<F-ee;)U=Te(U),F--;for(;0<ee-F;)P=Te(P),ee--;for(;F--;){if(U===P||P!==null&&U===P.alternate){Te=U;break t}U=Te(U),P=Te(P)}Te=null}else Te=null;J!==null&&Gy(se,Y,J,Te,!1),be!==null&&it!==null&&Gy(se,it,be,Te,!0)}}e:{if(Y=G?k(G):window,J=Y.nodeName&&Y.nodeName.toLowerCase(),J==="select"||J==="input"&&Y.type==="file")var Je=l0;else if(a0(Y))if(c0)Je=N_;else{Je=j_;var _e=A_}else J=Y.nodeName,!J||J.toLowerCase()!=="input"||Y.type!=="checkbox"&&Y.type!=="radio"?G&&zu(G.elementType)&&(Je=l0):Je=k_;if(Je&&(Je=Je(e,G))){o0(se,Je,a,Z);break e}_e&&_e(e,Y,G),e==="focusout"&&G&&Y.type==="number"&&G.memoizedProps.value!=null&&Uu(Y,"number",Y.value)}switch(_e=G?k(G):window,e){case"focusin":(a0(_e)||_e.contentEditable==="true")&&(hi=_e,ef=G,wa=null);break;case"focusout":wa=ef=hi=null;break;case"mousedown":tf=!0;break;case"contextmenu":case"mouseup":case"dragend":tf=!1,g0(se,a,Z);break;case"selectionchange":if(C_)break;case"keydown":case"keyup":g0(se,a,Z)}var Le;if(Xu)e:{switch(e){case"compositionstart":var Ie="onCompositionStart";break e;case"compositionend":Ie="onCompositionEnd";break e;case"compositionupdate":Ie="onCompositionUpdate";break e}Ie=void 0}else fi?s0(e,a)&&(Ie="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Ie="onCompositionStart");Ie&&(t0&&a.locale!=="ko"&&(fi||Ie!=="onCompositionStart"?Ie==="onCompositionEnd"&&fi&&(Le=Xm()):(Gr=Z,Gu="value"in Gr?Gr.value:Gr.textContent,fi=!0)),_e=Il(G,Ie),0<_e.length&&(Ie=new Zm(Ie,e,null,a,Z),se.push({event:Ie,listeners:_e}),Le?Ie.data=Le:(Le=i0(a),Le!==null&&(Ie.data=Le)))),(Le=__?w_(e,a):S_(e,a))&&(Ie=Il(G,"onBeforeInput"),0<Ie.length&&(_e=new Zm("onBeforeInput","beforeinput",null,a,Z),se.push({event:_e,listeners:Ie}),_e.data=Le)),mw(se,e,G,a,Z)}Hy(se,r)})}function Ya(e,r,a){return{instance:e,listener:r,currentTarget:a}}function Il(e,r){for(var a=r+"Capture",l=[];e!==null;){var f=e,p=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||p===null||(f=ma(e,a),f!=null&&l.unshift(Ya(e,f,p)),f=ma(e,r),f!=null&&l.push(Ya(e,f,p))),e.tag===3)return l;e=e.return}return[]}function bw(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Gy(e,r,a,l,f){for(var p=r._reactName,_=[];a!==null&&a!==l;){var O=a,M=O.alternate,G=O.stateNode;if(O=O.tag,M!==null&&M===l)break;O!==5&&O!==26&&O!==27||G===null||(M=G,f?(G=ma(a,p),G!=null&&_.unshift(Ya(a,G,M))):f||(G=ma(a,p),G!=null&&_.push(Ya(a,G,M)))),a=a.return}_.length!==0&&e.push({event:r,listeners:_})}var xw=/\r\n?/g,vw=/\u0000|\uFFFD/g;function Vy(e){return(typeof e=="string"?e:""+e).replace(xw,`
26
+ `).replace(vw,"")}function Yy(e,r){return r=Vy(r),Vy(e)===r}function st(e,r,a,l,f,p){switch(a){case"children":typeof l=="string"?r==="body"||r==="textarea"&&l===""||li(e,l):(typeof l=="number"||typeof l=="bigint")&&r!=="body"&&li(e,""+l);break;case"className":Fn(e,"class",l);break;case"tabIndex":Fn(e,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Fn(e,a,l);break;case"style":Ym(e,l,p);break;case"data":if(r!=="object"){Fn(e,"data",l);break}case"src":case"href":if(l===""&&(r!=="a"||a!=="href")){e.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Yo(""+l),e.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof p=="function"&&(a==="formAction"?(r!=="input"&&st(e,r,"name",f.name,f,null),st(e,r,"formEncType",f.formEncType,f,null),st(e,r,"formMethod",f.formMethod,f,null),st(e,r,"formTarget",f.formTarget,f,null)):(st(e,r,"encType",f.encType,f,null),st(e,r,"method",f.method,f,null),st(e,r,"target",f.target,f,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Yo(""+l),e.setAttribute(a,l);break;case"onClick":l!=null&&(e.onclick=dr);break;case"onScroll":l!=null&&Ue("scroll",e);break;case"onScrollEnd":l!=null&&Ue("scrollend",e);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(i(61));if(a=l.__html,a!=null){if(f.children!=null)throw Error(i(60));e.innerHTML=a}}break;case"multiple":e.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":e.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){e.removeAttribute("xlink:href");break}a=Yo(""+l),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""+l):e.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":l===!0?e.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,l):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?e.setAttribute(a,l):e.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?e.removeAttribute(a):e.setAttribute(a,l);break;case"popover":Ue("beforetoggle",e),Ue("toggle",e),Gt(e,"popover",l);break;case"xlinkActuate":hr(e,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":hr(e,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":hr(e,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":hr(e,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":hr(e,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":hr(e,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":hr(e,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":hr(e,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":hr(e,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Gt(e,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Kv.get(a)||a,Gt(e,a,l))}}function jh(e,r,a,l,f,p){switch(a){case"style":Ym(e,l,p);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(i(61));if(a=l.__html,a!=null){if(f.children!=null)throw Error(i(60));e.innerHTML=a}}break;case"children":typeof l=="string"?li(e,l):(typeof l=="number"||typeof l=="bigint")&&li(e,""+l);break;case"onScroll":l!=null&&Ue("scroll",e);break;case"onScrollEnd":l!=null&&Ue("scrollend",e);break;case"onClick":l!=null&&(e.onclick=dr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!re.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(f=a.endsWith("Capture"),r=a.slice(2,f?a.length-7:void 0),p=e[gt]||null,p=p!=null?p[a]:null,typeof p=="function"&&e.removeEventListener(r,p,f),typeof l=="function")){typeof p!="function"&&p!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(r,l,f);break e}a in e?e[a]=l:l===!0?e.setAttribute(a,""):Gt(e,a,l)}}}function $t(e,r,a){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ue("error",e),Ue("load",e);var l=!1,f=!1,p;for(p in a)if(a.hasOwnProperty(p)){var _=a[p];if(_!=null)switch(p){case"src":l=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:st(e,r,p,_,a,null)}}f&&st(e,r,"srcSet",a.srcSet,a,null),l&&st(e,r,"src",a.src,a,null);return;case"input":Ue("invalid",e);var O=p=_=f=null,M=null,G=null;for(l in a)if(a.hasOwnProperty(l)){var Z=a[l];if(Z!=null)switch(l){case"name":f=Z;break;case"type":_=Z;break;case"checked":M=Z;break;case"defaultChecked":G=Z;break;case"value":p=Z;break;case"defaultValue":O=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(i(137,r));break;default:st(e,r,l,Z,a,null)}}Hm(e,p,O,M,G,_,f,!1);return;case"select":Ue("invalid",e),l=_=p=null;for(f in a)if(a.hasOwnProperty(f)&&(O=a[f],O!=null))switch(f){case"value":p=O;break;case"defaultValue":_=O;break;case"multiple":l=O;default:st(e,r,f,O,a,null)}r=p,a=_,e.multiple=!!l,r!=null?oi(e,!!l,r,!1):a!=null&&oi(e,!!l,a,!0);return;case"textarea":Ue("invalid",e),p=f=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(O=a[_],O!=null))switch(_){case"value":l=O;break;case"defaultValue":f=O;break;case"children":p=O;break;case"dangerouslySetInnerHTML":if(O!=null)throw Error(i(91));break;default:st(e,r,_,O,a,null)}Gm(e,l,f,p);return;case"option":for(M in a)if(a.hasOwnProperty(M)&&(l=a[M],l!=null))switch(M){case"selected":e.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:st(e,r,M,l,a,null)}return;case"dialog":Ue("beforetoggle",e),Ue("toggle",e),Ue("cancel",e),Ue("close",e);break;case"iframe":case"object":Ue("load",e);break;case"video":case"audio":for(l=0;l<Va.length;l++)Ue(Va[l],e);break;case"image":Ue("error",e),Ue("load",e);break;case"details":Ue("toggle",e);break;case"embed":case"source":case"link":Ue("error",e),Ue("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(G in a)if(a.hasOwnProperty(G)&&(l=a[G],l!=null))switch(G){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:st(e,r,G,l,a,null)}return;default:if(zu(r)){for(Z in a)a.hasOwnProperty(Z)&&(l=a[Z],l!==void 0&&jh(e,r,Z,l,a,void 0));return}}for(O in a)a.hasOwnProperty(O)&&(l=a[O],l!=null&&st(e,r,O,l,a,null))}function _w(e,r,a,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,p=null,_=null,O=null,M=null,G=null,Z=null;for(J in a){var se=a[J];if(a.hasOwnProperty(J)&&se!=null)switch(J){case"checked":break;case"value":break;case"defaultValue":M=se;default:l.hasOwnProperty(J)||st(e,r,J,null,l,se)}}for(var Y in l){var J=l[Y];if(se=a[Y],l.hasOwnProperty(Y)&&(J!=null||se!=null))switch(Y){case"type":p=J;break;case"name":f=J;break;case"checked":G=J;break;case"defaultChecked":Z=J;break;case"value":_=J;break;case"defaultValue":O=J;break;case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(i(137,r));break;default:J!==se&&st(e,r,Y,J,l,se)}}Pu(e,_,O,M,G,Z,p,f);return;case"select":J=_=O=Y=null;for(p in a)if(M=a[p],a.hasOwnProperty(p)&&M!=null)switch(p){case"value":break;case"multiple":J=M;default:l.hasOwnProperty(p)||st(e,r,p,null,l,M)}for(f in l)if(p=l[f],M=a[f],l.hasOwnProperty(f)&&(p!=null||M!=null))switch(f){case"value":Y=p;break;case"defaultValue":O=p;break;case"multiple":_=p;default:p!==M&&st(e,r,f,p,l,M)}r=O,a=_,l=J,Y!=null?oi(e,!!a,Y,!1):!!l!=!!a&&(r!=null?oi(e,!!a,r,!0):oi(e,!!a,a?[]:"",!1));return;case"textarea":J=Y=null;for(O in a)if(f=a[O],a.hasOwnProperty(O)&&f!=null&&!l.hasOwnProperty(O))switch(O){case"value":break;case"children":break;default:st(e,r,O,null,l,f)}for(_ in l)if(f=l[_],p=a[_],l.hasOwnProperty(_)&&(f!=null||p!=null))switch(_){case"value":Y=f;break;case"defaultValue":J=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(i(91));break;default:f!==p&&st(e,r,_,f,l,p)}Fm(e,Y,J);return;case"option":for(var be in a)if(Y=a[be],a.hasOwnProperty(be)&&Y!=null&&!l.hasOwnProperty(be))switch(be){case"selected":e.selected=!1;break;default:st(e,r,be,null,l,Y)}for(M in l)if(Y=l[M],J=a[M],l.hasOwnProperty(M)&&Y!==J&&(Y!=null||J!=null))switch(M){case"selected":e.selected=Y&&typeof Y!="function"&&typeof Y!="symbol";break;default:st(e,r,M,Y,l,J)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Te in a)Y=a[Te],a.hasOwnProperty(Te)&&Y!=null&&!l.hasOwnProperty(Te)&&st(e,r,Te,null,l,Y);for(G in l)if(Y=l[G],J=a[G],l.hasOwnProperty(G)&&Y!==J&&(Y!=null||J!=null))switch(G){case"children":case"dangerouslySetInnerHTML":if(Y!=null)throw Error(i(137,r));break;default:st(e,r,G,Y,l,J)}return;default:if(zu(r)){for(var it in a)Y=a[it],a.hasOwnProperty(it)&&Y!==void 0&&!l.hasOwnProperty(it)&&jh(e,r,it,void 0,l,Y);for(Z in l)Y=l[Z],J=a[Z],!l.hasOwnProperty(Z)||Y===J||Y===void 0&&J===void 0||jh(e,r,Z,Y,l,J);return}}for(var U in a)Y=a[U],a.hasOwnProperty(U)&&Y!=null&&!l.hasOwnProperty(U)&&st(e,r,U,null,l,Y);for(se in l)Y=l[se],J=a[se],!l.hasOwnProperty(se)||Y===J||Y==null&&J==null||st(e,r,se,Y,l,J)}function Ky(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function ww(){if(typeof performance.getEntriesByType=="function"){for(var e=0,r=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var f=a[l],p=f.transferSize,_=f.initiatorType,O=f.duration;if(p&&O&&Ky(_)){for(_=0,O=f.responseEnd,l+=1;l<a.length;l++){var M=a[l],G=M.startTime;if(G>O)break;var Z=M.transferSize,se=M.initiatorType;Z&&Ky(se)&&(M=M.responseEnd,_+=Z*(M<O?1:(O-G)/(M-G)))}if(--l,r+=8*(p+_)/(f.duration/1e3),e++,10<e)break}}if(0<e)return r/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var kh=null,Nh=null;function $l(e){return e.nodeType===9?e:e.ownerDocument}function Jy(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Xy(e,r){if(e===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&r==="foreignObject"?0:e}function Th(e,r){return e==="textarea"||e==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Ch=null;function Sw(){var e=window.event;return e&&e.type==="popstate"?e===Ch?!1:(Ch=e,!0):(Ch=null,!1)}var Qy=typeof setTimeout=="function"?setTimeout:void 0,Ew=typeof clearTimeout=="function"?clearTimeout:void 0,Wy=typeof Promise=="function"?Promise:void 0,Ow=typeof queueMicrotask=="function"?queueMicrotask:typeof Wy<"u"?function(e){return Wy.resolve(null).then(e).catch(Aw)}:Qy;function Aw(e){setTimeout(function(){throw e})}function ls(e){return e==="head"}function Zy(e,r){var a=r,l=0;do{var f=a.nextSibling;if(e.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"||a==="/&"){if(l===0){e.removeChild(f),Ui(r);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Ka(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Ka(a);for(var p=a.firstChild;p;){var _=p.nextSibling,O=p.nodeName;p[Mt]||O==="SCRIPT"||O==="STYLE"||O==="LINK"&&p.rel.toLowerCase()==="stylesheet"||a.removeChild(p),p=_}}else a==="body"&&Ka(e.ownerDocument.body);a=f}while(a);Ui(r)}function eg(e,r){var a=e;e=0;do{var l=a.nextSibling;if(a.nodeType===1?r?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(r?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=l}while(a)}function Mh(e){var r=e.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var a=r;switch(r=r.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Mh(a),ai(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function jw(e,r,a,l){for(;e.nodeType===1;){var f=a;if(e.nodeName.toLowerCase()!==r.toLowerCase()){if(!l&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(l){if(!e[Mt])switch(r){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(p=e.getAttribute("rel"),p==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(p!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(p=e.getAttribute("src"),(p!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&p&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(r==="input"&&e.type==="hidden"){var p=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===p)return e}else return e;if(e=Bn(e.nextSibling),e===null)break}return null}function kw(e,r,a){if(r==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=Bn(e.nextSibling),e===null))return null;return e}function tg(e,r){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=Bn(e.nextSibling),e===null))return null;return e}function Rh(e){return e.data==="$?"||e.data==="$~"}function Dh(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Nw(e,r){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=r;else if(e.data!=="$?"||a.readyState!=="loading")r();else{var l=function(){r(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}function Bn(e){for(;e!=null;e=e.nextSibling){var r=e.nodeType;if(r===1||r===3)break;if(r===8){if(r=e.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return e}var Lh=null;function ng(e){e=e.nextSibling;for(var r=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(r===0)return Bn(e.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}e=e.nextSibling}return null}function rg(e){e=e.previousSibling;for(var r=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(r===0)return e;r--}else a!=="/$"&&a!=="/&"||r++}e=e.previousSibling}return null}function sg(e,r,a){switch(r=$l(a),e){case"html":if(e=r.documentElement,!e)throw Error(i(452));return e;case"head":if(e=r.head,!e)throw Error(i(453));return e;case"body":if(e=r.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Ka(e){for(var r=e.attributes;r.length;)e.removeAttributeNode(r[0]);ai(e)}var Pn=new Map,ig=new Set;function Hl(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Nr=W.d;W.d={f:Tw,r:Cw,D:Mw,C:Rw,L:Dw,m:Lw,X:Bw,S:qw,M:Pw};function Tw(){var e=Nr.f(),r=Dl();return e||r}function Cw(e){var r=N(e);r!==null&&r.tag===5&&r.type==="form"?wp(r):Nr.r(e)}var qi=typeof document>"u"?null:document;function ag(e,r,a){var l=qi;if(l&&typeof r=="string"&&r){var f=Tn(r);f='link[rel="'+e+'"][href="'+f+'"]',typeof a=="string"&&(f+='[crossorigin="'+a+'"]'),ig.has(f)||(ig.add(f),e={rel:e,crossOrigin:a,href:r},l.querySelector(f)===null&&(r=l.createElement("link"),$t(r,"link",e),L(r),l.head.appendChild(r)))}}function Mw(e){Nr.D(e),ag("dns-prefetch",e,null)}function Rw(e,r){Nr.C(e,r),ag("preconnect",e,r)}function Dw(e,r,a){Nr.L(e,r,a);var l=qi;if(l&&e&&r){var f='link[rel="preload"][as="'+Tn(r)+'"]';r==="image"&&a&&a.imageSrcSet?(f+='[imagesrcset="'+Tn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(f+='[imagesizes="'+Tn(a.imageSizes)+'"]')):f+='[href="'+Tn(e)+'"]';var p=f;switch(r){case"style":p=Bi(e);break;case"script":p=Pi(e)}Pn.has(p)||(e=b({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:e,as:r},a),Pn.set(p,e),l.querySelector(f)!==null||r==="style"&&l.querySelector(Ja(p))||r==="script"&&l.querySelector(Xa(p))||(r=l.createElement("link"),$t(r,"link",e),L(r),l.head.appendChild(r)))}}function Lw(e,r){Nr.m(e,r);var a=qi;if(a&&e){var l=r&&typeof r.as=="string"?r.as:"script",f='link[rel="modulepreload"][as="'+Tn(l)+'"][href="'+Tn(e)+'"]',p=f;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=Pi(e)}if(!Pn.has(p)&&(e=b({rel:"modulepreload",href:e},r),Pn.set(p,e),a.querySelector(f)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Xa(p)))return}l=a.createElement("link"),$t(l,"link",e),L(l),a.head.appendChild(l)}}}function qw(e,r,a){Nr.S(e,r,a);var l=qi;if(l&&e){var f=T(l).hoistableStyles,p=Bi(e);r=r||"default";var _=f.get(p);if(!_){var O={loading:0,preload:null};if(_=l.querySelector(Ja(p)))O.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":r},a),(a=Pn.get(p))&&qh(e,a);var M=_=l.createElement("link");L(M),$t(M,"link",e),M._p=new Promise(function(G,Z){M.onload=G,M.onerror=Z}),M.addEventListener("load",function(){O.loading|=1}),M.addEventListener("error",function(){O.loading|=2}),O.loading|=4,Fl(_,r,l)}_={type:"stylesheet",instance:_,count:1,state:O},f.set(p,_)}}}function Bw(e,r){Nr.X(e,r);var a=qi;if(a&&e){var l=T(a).hoistableScripts,f=Pi(e),p=l.get(f);p||(p=a.querySelector(Xa(f)),p||(e=b({src:e,async:!0},r),(r=Pn.get(f))&&Bh(e,r),p=a.createElement("script"),L(p),$t(p,"link",e),a.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},l.set(f,p))}}function Pw(e,r){Nr.M(e,r);var a=qi;if(a&&e){var l=T(a).hoistableScripts,f=Pi(e),p=l.get(f);p||(p=a.querySelector(Xa(f)),p||(e=b({src:e,async:!0,type:"module"},r),(r=Pn.get(f))&&Bh(e,r),p=a.createElement("script"),L(p),$t(p,"link",e),a.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},l.set(f,p))}}function og(e,r,a,l){var f=(f=Ct.current)?Hl(f):null;if(!f)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(r=Bi(a.href),a=T(f).hoistableStyles,l=a.get(r),l||(l={type:"style",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Bi(a.href);var p=T(f).hoistableStyles,_=p.get(e);if(_||(f=f.ownerDocument||f,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(e,_),(p=f.querySelector(Ja(e)))&&!p._p&&(_.instance=p,_.state.loading=5),Pn.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Pn.set(e,a),p||Uw(f,e,a,_.state))),r&&l===null)throw Error(i(528,""));return _}if(r&&l!==null)throw Error(i(529,""));return null;case"script":return r=a.async,a=a.src,typeof a=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Pi(a),a=T(f).hoistableScripts,l=a.get(r),l||(l={type:"script",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Bi(e){return'href="'+Tn(e)+'"'}function Ja(e){return'link[rel="stylesheet"]['+e+"]"}function lg(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function Uw(e,r,a,l){e.querySelector('link[rel="preload"][as="style"]['+r+"]")?l.loading=1:(r=e.createElement("link"),l.preload=r,r.addEventListener("load",function(){return l.loading|=1}),r.addEventListener("error",function(){return l.loading|=2}),$t(r,"link",a),L(r),e.head.appendChild(r))}function Pi(e){return'[src="'+Tn(e)+'"]'}function Xa(e){return"script[async]"+e}function cg(e,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var l=e.querySelector('style[data-href~="'+Tn(a.href)+'"]');if(l)return r.instance=l,L(l),l;var f=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(e.ownerDocument||e).createElement("style"),L(l),$t(l,"style",f),Fl(l,a.precedence,e),r.instance=l;case"stylesheet":f=Bi(a.href);var p=e.querySelector(Ja(f));if(p)return r.state.loading|=4,r.instance=p,L(p),p;l=lg(a),(f=Pn.get(f))&&qh(l,f),p=(e.ownerDocument||e).createElement("link"),L(p);var _=p;return _._p=new Promise(function(O,M){_.onload=O,_.onerror=M}),$t(p,"link",l),r.state.loading|=4,Fl(p,a.precedence,e),r.instance=p;case"script":return p=Pi(a.src),(f=e.querySelector(Xa(p)))?(r.instance=f,L(f),f):(l=a,(f=Pn.get(p))&&(l=b({},a),Bh(l,f)),e=e.ownerDocument||e,f=e.createElement("script"),L(f),$t(f,"link",l),e.head.appendChild(f),r.instance=f);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(l=r.instance,r.state.loading|=4,Fl(l,a.precedence,e));return r.instance}function Fl(e,r,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=l.length?l[l.length-1]:null,p=f,_=0;_<l.length;_++){var O=l[_];if(O.dataset.precedence===r)p=O;else if(p!==f)break}p?p.parentNode.insertBefore(e,p.nextSibling):(r=a.nodeType===9?a.head:a,r.insertBefore(e,r.firstChild))}function qh(e,r){e.crossOrigin==null&&(e.crossOrigin=r.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=r.referrerPolicy),e.title==null&&(e.title=r.title)}function Bh(e,r){e.crossOrigin==null&&(e.crossOrigin=r.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=r.referrerPolicy),e.integrity==null&&(e.integrity=r.integrity)}var Gl=null;function ug(e,r,a){if(Gl===null){var l=new Map,f=Gl=new Map;f.set(a,l)}else f=Gl,l=f.get(a),l||(l=new Map,f.set(a,l));if(l.has(e))return l;for(l.set(e,null),a=a.getElementsByTagName(e),f=0;f<a.length;f++){var p=a[f];if(!(p[Mt]||p[at]||e==="link"&&p.getAttribute("rel")==="stylesheet")&&p.namespaceURI!=="http://www.w3.org/2000/svg"){var _=p.getAttribute(r)||"";_=e+_;var O=l.get(_);O?O.push(p):l.set(_,[p])}}return l}function fg(e,r,a){e=e.ownerDocument||e,e.head.insertBefore(a,r==="title"?e.querySelector("head > title"):null)}function zw(e,r,a){if(a===1||r.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return e=r.disabled,typeof r.precedence=="string"&&e==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function hg(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Iw(e,r,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var f=Bi(l.href),p=r.querySelector(Ja(f));if(p){r=p._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(e.count++,e=Vl.bind(e),r.then(e,e)),a.state.loading|=4,a.instance=p,L(p);return}p=r.ownerDocument||r,l=lg(l),(f=Pn.get(f))&&qh(l,f),p=p.createElement("link"),L(p);var _=p;_._p=new Promise(function(O,M){_.onload=O,_.onerror=M}),$t(p,"link",l),a.instance=p}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,r),(r=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=Vl.bind(e),r.addEventListener("load",a),r.addEventListener("error",a))}}var Ph=0;function $w(e,r){return e.stylesheets&&e.count===0&&Kl(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var l=setTimeout(function(){if(e.stylesheets&&Kl(e,e.stylesheets),e.unsuspend){var p=e.unsuspend;e.unsuspend=null,p()}},6e4+r);0<e.imgBytes&&Ph===0&&(Ph=62500*ww());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Kl(e,e.stylesheets),e.unsuspend)){var p=e.unsuspend;e.unsuspend=null,p()}},(e.imgBytes>Ph?50:800)+r);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(f)}}:null}function Vl(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Kl(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yl=null;function Kl(e,r){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yl=new Map,r.forEach(Hw,e),Yl=null,Vl.call(e))}function Hw(e,r){if(!(r.state.loading&4)){var a=Yl.get(e);if(a)var l=a.get(null);else{a=new Map,Yl.set(e,a);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p<f.length;p++){var _=f[p];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}f=r.instance,_=f.getAttribute("data-precedence"),p=a.get(_)||l,p===l&&a.set(null,f),a.set(_,f),this.count++,l=Vl.bind(this),f.addEventListener("load",l),f.addEventListener("error",l),p?p.parentNode.insertBefore(f,p.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),r.state.loading|=4}}var Qa={$$typeof:ie,Provider:null,Consumer:null,_currentValue:ce,_currentValue2:ce,_threadCount:0};function Fw(e,r,a,l,f,p,_,O,M){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ir(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ir(0),this.hiddenUpdates=Ir(null),this.identifierPrefix=l,this.onUncaughtError=f,this.onCaughtError=p,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=M,this.incompleteTransitions=new Map}function dg(e,r,a,l,f,p,_,O,M,G,Z,se){return e=new Fw(e,r,a,_,M,G,Z,se,O),r=1,p===!0&&(r|=24),p=hn(3,null,null,r),e.current=p,p.stateNode=e,r=gf(),r.refCount++,e.pooledCache=r,r.refCount++,p.memoizedState={element:l,isDehydrated:a,cache:r},_f(p),e}function mg(e){return e?(e=pi,e):pi}function pg(e,r,a,l,f,p){f=mg(f),l.context===null?l.context=f:l.pendingContext=f,l=Qr(r),l.payload={element:a},p=p===void 0?null:p,p!==null&&(l.callback=p),a=Wr(e,l,r),a!==null&&(sn(a,e,r),Na(a,e,r))}function yg(e,r){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<r?a:r}}function Uh(e,r){yg(e,r),(e=e.alternate)&&yg(e,r)}function gg(e){if(e.tag===13||e.tag===31){var r=Ls(e,67108864);r!==null&&sn(r,e,67108864),Uh(e,67108864)}}function bg(e){if(e.tag===13||e.tag===31){var r=gn();r=fr(r);var a=Ls(e,r);a!==null&&sn(a,e,r),Uh(e,r)}}var Jl=!0;function Gw(e,r,a,l){var f=H.T;H.T=null;var p=W.p;try{W.p=2,zh(e,r,a,l)}finally{W.p=p,H.T=f}}function Vw(e,r,a,l){var f=H.T;H.T=null;var p=W.p;try{W.p=8,zh(e,r,a,l)}finally{W.p=p,H.T=f}}function zh(e,r,a,l){if(Jl){var f=Ih(l);if(f===null)Ah(e,r,l,Xl,a),vg(e,l);else if(Kw(f,e,r,a,l))l.stopPropagation();else if(vg(e,l),r&4&&-1<Yw.indexOf(e)){for(;f!==null;){var p=N(f);if(p!==null)switch(p.tag){case 3:if(p=p.stateNode,p.current.memoizedState.isDehydrated){var _=$n(p.pendingLanes);if(_!==0){var O=p;for(O.pendingLanes|=2,O.entangledLanes|=2;_;){var M=1<<31-Ft(_);O.entanglements[1]|=M,_&=~M}sr(p),(Qe&6)===0&&(Ml=ht()+500,Ga(0))}}break;case 31:case 13:O=Ls(p,2),O!==null&&sn(O,p,2),Dl(),Uh(p,2)}if(p=Ih(l),p===null&&Ah(e,r,l,Xl,a),p===f)break;f=p}f!==null&&l.stopPropagation()}else Ah(e,r,l,null,a)}}function Ih(e){return e=$u(e),$h(e)}var Xl=null;function $h(e){if(Xl=null,e=A(e),e!==null){var r=c(e);if(r===null)e=null;else{var a=r.tag;if(a===13){if(e=m(r),e!==null)return e;e=null}else if(a===31){if(e=y(r),e!==null)return e;e=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;e=null}else r!==e&&(e=null)}}return Xl=e,null}function xg(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Du()){case Uo:return 2;case zo:return 8;case ri:case Lu:return 32;case Io:return 268435456;default:return 32}default:return 32}}var Hh=!1,cs=null,us=null,fs=null,Wa=new Map,Za=new Map,hs=[],Yw="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function vg(e,r){switch(e){case"focusin":case"focusout":cs=null;break;case"dragenter":case"dragleave":us=null;break;case"mouseover":case"mouseout":fs=null;break;case"pointerover":case"pointerout":Wa.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Za.delete(r.pointerId)}}function eo(e,r,a,l,f,p){return e===null||e.nativeEvent!==p?(e={blockedOn:r,domEventName:a,eventSystemFlags:l,nativeEvent:p,targetContainers:[f]},r!==null&&(r=N(r),r!==null&&gg(r)),e):(e.eventSystemFlags|=l,r=e.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),e)}function Kw(e,r,a,l,f){switch(r){case"focusin":return cs=eo(cs,e,r,a,l,f),!0;case"dragenter":return us=eo(us,e,r,a,l,f),!0;case"mouseover":return fs=eo(fs,e,r,a,l,f),!0;case"pointerover":var p=f.pointerId;return Wa.set(p,eo(Wa.get(p)||null,e,r,a,l,f)),!0;case"gotpointercapture":return p=f.pointerId,Za.set(p,eo(Za.get(p)||null,e,r,a,l,f)),!0}return!1}function _g(e){var r=A(e.target);if(r!==null){var a=c(r);if(a!==null){if(r=a.tag,r===13){if(r=m(a),r!==null){e.blockedOn=r,Ho(e.priority,function(){bg(a)});return}}else if(r===31){if(r=y(a),r!==null){e.blockedOn=r,Ho(e.priority,function(){bg(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ql(e){if(e.blockedOn!==null)return!1;for(var r=e.targetContainers;0<r.length;){var a=Ih(e.nativeEvent);if(a===null){a=e.nativeEvent;var l=new a.constructor(a.type,a);Iu=l,a.target.dispatchEvent(l),Iu=null}else return r=N(a),r!==null&&gg(r),e.blockedOn=a,!1;r.shift()}return!0}function wg(e,r,a){Ql(e)&&a.delete(r)}function Jw(){Hh=!1,cs!==null&&Ql(cs)&&(cs=null),us!==null&&Ql(us)&&(us=null),fs!==null&&Ql(fs)&&(fs=null),Wa.forEach(wg),Za.forEach(wg)}function Wl(e,r){e.blockedOn===r&&(e.blockedOn=null,Hh||(Hh=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Jw)))}var Zl=null;function Sg(e){Zl!==e&&(Zl=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Zl===e&&(Zl=null);for(var r=0;r<e.length;r+=3){var a=e[r],l=e[r+1],f=e[r+2];if(typeof l!="function"){if($h(l||a)===null)continue;break}var p=N(a);p!==null&&(e.splice(r,3),r-=3,If(p,{pending:!0,data:f,method:a.method,action:l},l,f))}}))}function Ui(e){function r(M){return Wl(M,e)}cs!==null&&Wl(cs,e),us!==null&&Wl(us,e),fs!==null&&Wl(fs,e),Wa.forEach(r),Za.forEach(r);for(var a=0;a<hs.length;a++){var l=hs[a];l.blockedOn===e&&(l.blockedOn=null)}for(;0<hs.length&&(a=hs[0],a.blockedOn===null);)_g(a),a.blockedOn===null&&hs.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var f=a[l],p=a[l+1],_=f[gt]||null;if(typeof p=="function")_||Sg(a);else if(_){var O=null;if(p&&p.hasAttribute("formAction")){if(f=p,_=p[gt]||null)O=_.formAction;else if($h(f)!==null)continue}else O=_.action;typeof O=="function"?a[l+1]=O:(a.splice(l,3),l-=3),Sg(a)}}}function Eg(){function e(p){p.canIntercept&&p.info==="react-transition"&&p.intercept({handler:function(){return new Promise(function(_){return f=_})},focusReset:"manual",scroll:"manual"})}function r(){f!==null&&(f(),f=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var p=navigation.currentEntry;p&&p.url!=null&&navigation.navigate(p.url,{state:p.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),f!==null&&(f(),f=null)}}}function Fh(e){this._internalRoot=e}ec.prototype.render=Fh.prototype.render=function(e){var r=this._internalRoot;if(r===null)throw Error(i(409));var a=r.current,l=gn();pg(a,l,e,r,null,null)},ec.prototype.unmount=Fh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var r=e.containerInfo;pg(e.current,2,null,e,null,null),Dl(),r[un]=null}};function ec(e){this._internalRoot=e}ec.prototype.unstable_scheduleHydration=function(e){if(e){var r=ha();e={blockedOn:null,target:e,priority:r};for(var a=0;a<hs.length&&r!==0&&r<hs[a].priority;a++);hs.splice(a,0,e),a===0&&_g(e)}};var Og=t.version;if(Og!=="19.2.4")throw Error(i(527,Og,"19.2.4"));W.findDOMNode=function(e){var r=e._reactInternals;if(r===void 0)throw typeof e.render=="function"?Error(i(188)):(e=Object.keys(e).join(","),Error(i(268,e)));return e=u(r),e=e!==null?d(e):null,e=e===null?null:e.stateNode,e};var Xw={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:H,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var tc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!tc.isDisabled&&tc.supportsFiber)try{As=tc.inject(Xw),_t=tc}catch{}}return to.createRoot=function(e,r){if(!o(e))throw Error(i(299));var a=!1,l="",f=Mp,p=Rp,_=Dp;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(l=r.identifierPrefix),r.onUncaughtError!==void 0&&(f=r.onUncaughtError),r.onCaughtError!==void 0&&(p=r.onCaughtError),r.onRecoverableError!==void 0&&(_=r.onRecoverableError)),r=dg(e,1,!1,null,null,a,l,null,f,p,_,Eg),e[un]=r.current,Oh(e),new Fh(r)},to.hydrateRoot=function(e,r,a){if(!o(e))throw Error(i(299));var l=!1,f="",p=Mp,_=Rp,O=Dp,M=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(f=a.identifierPrefix),a.onUncaughtError!==void 0&&(p=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(O=a.onRecoverableError),a.formState!==void 0&&(M=a.formState)),r=dg(e,1,!0,r,a??null,l,f,M,p,_,O,Eg),r.context=mg(null),a=r.current,l=gn(),l=fr(l),f=Qr(l),f.callback=null,Wr(a,f,l),a=l,r.current.lanes=a,Hn(r,a),sr(r),e[un]=r.current,Oh(e),new ec(r)},to.version="19.2.4",to}var Mg;function zS(){if(Mg)return Gh.exports;Mg=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(t){console.error(t)}}return n(),Gh.exports=US(),Gh.exports}var IS=zS();const $S="modulepreload",HS=function(n,t){return new URL(n,t).href},Rg={},je=function(t,s,i){let o=Promise.resolve();if(s&&s.length>0){let m=function(d){return Promise.all(d.map(b=>Promise.resolve(b).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};const y=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),u=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));o=m(s.map(d=>{if(d=HS(d,i),d in Rg)return;Rg[d]=!0;const b=d.endsWith(".css"),x=b?'[rel="stylesheet"]':"";if(!!i)for(let S=y.length-1;S>=0;S--){const C=y[S];if(C.href===d&&(!b||C.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${x}`))return;const w=document.createElement("link");if(w.rel=b?"stylesheet":$S,b||(w.as="script"),w.crossOrigin="",w.href=d,u&&w.setAttribute("nonce",u),document.head.appendChild(w),b)return new Promise((S,C)=>{w.addEventListener("load",S),w.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${d}`)))})}))}function c(m){const y=new Event("vite:preloadError",{cancelable:!0});if(y.payload=m,window.dispatchEvent(y),!y.defaultPrevented)throw m}return o.then(m=>{for(const y of m||[])y.status==="rejected"&&c(y.reason);return t().catch(c)})};function wu(n){try{const t=n.split(".");if(t.length!==3)return null;const s=atob(t[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(s)}catch{return null}}function ox(n){const t=wu(n);return!t||typeof t.exp!="number"?null:t.exp}function tm(n,t=0){const s=ox(n);return s===null?!0:Date.now()/1e3>=s-t}const Ht=window.__LT_BASE__??"",yd=`${Ht}/api`;class Dg extends Error{constructor(t,s,i){super(t),this.status=s,this.body=i,this.name="ApiError"}}let gs=null;function nc(n){gs=n}function lx(){return gs}const FS="X-LT-Acting-Token",GS="X-LT-Acting-Remaining";let Zc=null,eu=null;function Lg(n){Zc=n}let tu=null;function qg(n){tu=n}function Bg(n){eu=n}function VS(n){const t=n==null?void 0:n.error;return typeof t=="string"&&/acting[- ]identity/i.test(t)}async function Pg(){const n=sessionStorage.getItem("lt_credentials");if(!n)return null;try{const{username:t,password:s}=JSON.parse(n),i=await fetch(`${yd}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})});if(!i.ok)return null;const o=await i.json();return o.token&&o.user&&sessionStorage.setItem("lt_user_info",JSON.stringify({displayName:o.user.display_name,username:o.user.external_id})),o.token??null}catch{return null}}let ms=null;async function fe(n,t={}){const s={"Content-Type":"application/json",...t.headers};if(gs){if(tm(gs)){ms||(ms=Pg().finally(()=>{ms=null}));const y=await ms;if(y)gs=y,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:y}}));else throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}s.Authorization=`Bearer ${gs}`}const o=(t.method??"GET").toUpperCase()==="GET"?null:(Zc==null?void 0:Zc())??null;o&&(s[FS]=o);let c=await fetch(`${yd}${n}`,{...t,headers:s});const m=o?c.headers.get(GS):null;if(o&&m!==null&&(tu==null||tu(o,m==="unbounded"?null:Number(m))),c.status===401&&o){const y=await c.clone().json().catch(()=>null);if(VS(y))throw eu==null||eu(),new Dg(y.error,401,y)}if(c.status===401&&gs){ms||(ms=Pg().finally(()=>{ms=null}));const y=await ms;if(y&&(gs=y,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:y}})),s.Authorization=`Bearer ${y}`,c=await fetch(`${yd}${n}`,{...t,headers:s})),c.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}else if(c.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired");if(!c.ok){const y=await c.json().catch(()=>({error:c.statusText}));throw new Dg(y.message||y.error||c.statusText,c.status,y)}return c.json()}const YS="lt_ai_override";let rc=null;function nm(){return rc||(rc=fetch(`${Ht}/api/settings`).then(n=>{if(!n.ok)throw new Error(`settings ${n.status}`);return n.json()}).catch(n=>{throw rc=null,n})),rc}function KS(){try{if(localStorage.getItem(YS)==="off")return!1}catch{}return null}function Zn(){var s;const n=$e({queryKey:["settings"],queryFn:nm,staleTime:1/0}),t=KS();return n.data&&t===!1&&((s=n.data.ai)!=null&&s.enabled)?{...n,data:{...n.data,ai:{enabled:!1}}}:n}function JS(n){var u,d,b;const{data:t}=Zn(),s=((u=t==null?void 0:t.auth)==null?void 0:u.ssoKeepaliveSeconds)??0,i=((d=t==null?void 0:t.auth)==null?void 0:d.ssoKeepaliveIdleTimeoutSeconds)??0,o=E.useRef(Date.now()),c=E.useRef(Date.now()),m=E.useRef(!1),g=!!n&&((b=wu(n))==null?void 0:b.sso)===!0&&s>0;E.useEffect(()=>{if(!g)return;const x=()=>{o.current=Date.now()};window.addEventListener("pointerdown",x,{passive:!0}),window.addEventListener("keydown",x,{passive:!0}),window.addEventListener("wheel",x,{passive:!0});const v=async()=>{if(!m.current&&document.visibilityState==="visible"&&!(i>0&&Date.now()-o.current>i*1e3)){m.current=!0;try{const C=await fetch(`${Ht}/api/auth/sso`,{method:"POST"});if(C.status===401||C.status===403){window.dispatchEvent(new CustomEvent("auth:unauthorized"));return}if(!C.ok)return;const q=await C.json().catch(()=>null);q!=null&&q.token&&(c.current=Date.now(),window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:q.token}})))}catch{}finally{m.current=!1}}},w=setInterval(v,s*1e3),S=()=>{document.visibilityState==="visible"&&Date.now()-c.current>s*1e3&&v()};return document.addEventListener("visibilitychange",S),()=>{clearInterval(w),document.removeEventListener("visibilitychange",S),window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",x),window.removeEventListener("wheel",x)}},[g,s,i])}const cx=E.createContext(null),XS=300;function Kh(n,t){if(tm(n))return null;const s=wu(n);if(!s)return null;const i=t??(()=>{try{const o=sessionStorage.getItem("lt_user_info");return o?JSON.parse(o):null}catch{return null}})();return{userId:s.userId,displayName:(i==null?void 0:i.displayName)??null,username:(i==null?void 0:i.username)??null,roles:s.roles??[]}}function QS({children:n}){const[t,s]=E.useState(()=>{const b=sessionStorage.getItem("lt_token");return b?tm(b)?(sessionStorage.removeItem("lt_token"),null):(nc(b),Kh(b)):null}),i=E.useRef(void 0),o=E.useCallback(b=>{clearTimeout(i.current);const x=ox(b);if(!x)return;const v=(x-XS)*1e3-Date.now();v<=0||(i.current=setTimeout(async()=>{try{const w=wu(b);if(w!=null&&w.sso){const le=await fetch(`${Ht}/api/auth/sso`,{method:"POST"});if(!le.ok)return;const R=await le.json();R.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:R.token}}));return}const S=sessionStorage.getItem("lt_credentials");if(!S)return;const{username:C,password:q}=JSON.parse(S),B=await fetch(`${Ht}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:C,password:q})});if(!B.ok)return;const ie=await B.json();ie.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:ie.token}}))}catch{}},v))},[]),c=E.useCallback((b,x,v)=>{const w={displayName:(v==null?void 0:v.displayName)??null,username:(v==null?void 0:v.username)??(x==null?void 0:x.username)??null},S=Kh(b,w);S&&(nc(b),sessionStorage.setItem("lt_token",b),sessionStorage.setItem("lt_user_info",JSON.stringify(w)),x&&sessionStorage.setItem("lt_credentials",JSON.stringify(x)),s(S),o(b))},[o]),m=E.useCallback(()=>{clearTimeout(i.current);const b=sessionStorage.getItem("lt_sso_logout_url");nc(null),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info"),sessionStorage.removeItem("lt_sso_logout_url"),s(null),b&&(window.location.href=b)},[]);E.useEffect(()=>{const b=()=>m(),x=v=>{var C;const w=(C=v.detail)==null?void 0:C.token;if(!w)return;const S=Kh(w);S&&(nc(w),sessionStorage.setItem("lt_token",w),s(S),o(w))};return window.addEventListener("auth:unauthorized",b),window.addEventListener("auth:refreshed",x),()=>{window.removeEventListener("auth:unauthorized",b),window.removeEventListener("auth:refreshed",x)}},[m,o]),E.useEffect(()=>{const b=sessionStorage.getItem("lt_token");return b&&t&&o(b),()=>clearTimeout(i.current)},[]);const y=(t==null?void 0:t.roles.some(b=>b.type==="superadmin"))??!1,g=E.useCallback(b=>(t==null?void 0:t.roles.some(x=>x.role===b))??!1,[t]),u=E.useCallback(b=>(t==null?void 0:t.roles.some(x=>x.type===b))??!1,[t]),d=(t==null?void 0:t.roles.map(b=>b.role))??[];return h.jsxs(cx.Provider,{value:{user:t,isAuthenticated:!!t,isSuperAdmin:y,login:c,logout:m,hasRole:g,hasRoleType:u,userRoleNames:d},children:[h.jsx(WS,{authenticated:t!==null}),n]})}function WS({authenticated:n}){return JS(n?sessionStorage.getItem("lt_token"):null),null}function Pt(){const n=E.useContext(cx);if(!n)throw new Error("useAuth must be used within AuthProvider");return n}const An=new Uint8Array(0),ei=new TextEncoder,Sn=new TextDecoder;function ZS(...n){let t=0;for(let o=0;o<n.length;o++)t+=n[o].length;const s=new Uint8Array(t);let i=0;for(let o=0;o<n.length;o++)s.set(n[o],i),i+=n[o].length;return s}function go(...n){const t=[];for(let s=0;s<n.length;s++)t.push(ei.encode(n[s]));return t.length===0?An:t.length===1?t[0]:ZS(...t)}function Ug(n){return!n||n.length===0?"":Sn.decode(n)}const zg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ig=36,eE=0xcfd41b9100000,$g=33,tE=333,Hg=22;function nE(n){for(let t=0;t<n.length;t++)n[t]=Math.floor(Math.random()*255)}function rE(n){var t;(t=globalThis==null?void 0:globalThis.crypto)!=null&&t.getRandomValues?globalThis.crypto.getRandomValues(n):nE(n)}class sE{constructor(){j(this,"buf");j(this,"seq");j(this,"inc");j(this,"inited");this.buf=new Uint8Array(Hg),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*eE),this.inc=Math.floor(Math.random()*(tE-$g)+$g)}setPre(){const t=new Uint8Array(12);rE(t);for(let s=0;s<12;s++){const i=t[s]%36;this.buf[s]=zg.charCodeAt(i)}}fillSeq(){let t=this.seq;for(let s=Hg-1;s>=12;s--)this.buf[s]=zg.charCodeAt(t%Ig),t=Math.floor(t/Ig)}next(){return this.inited||this.init(),this.seq+=this.inc,this.seq>0xcfd41b9100000&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)}reset(){this.init()}}const Es=new sE;var Mr;(function(n){n.Disconnect="disconnect",n.Reconnect="reconnect",n.Update="update",n.LDM="ldm",n.Error="error"})(Mr||(Mr={}));var Yi;(function(n){n.Reconnecting="reconnecting",n.PingTimer="pingTimer",n.StaleConnection="staleConnection",n.ClientInitiatedReconnect="client initiated reconnect"})(Yi||(Yi={}));var ue;(function(n){n.ApiError="BAD API",n.BadAuthentication="BAD_AUTHENTICATION",n.BadCreds="BAD_CREDS",n.BadHeader="BAD_HEADER",n.BadJson="BAD_JSON",n.BadPayload="BAD_PAYLOAD",n.BadSubject="BAD_SUBJECT",n.Cancelled="CANCELLED",n.ConnectionClosed="CONNECTION_CLOSED",n.ConnectionDraining="CONNECTION_DRAINING",n.ConnectionRefused="CONNECTION_REFUSED",n.ConnectionTimeout="CONNECTION_TIMEOUT",n.Disconnect="DISCONNECT",n.InvalidOption="INVALID_OPTION",n.InvalidPayload="INVALID_PAYLOAD",n.MaxPayloadExceeded="MAX_PAYLOAD_EXCEEDED",n.NoResponders="503",n.NotFunction="NOT_FUNC",n.RequestError="REQUEST_ERROR",n.ServerOptionNotAvailable="SERVER_OPT_NA",n.SubClosed="SUB_CLOSED",n.SubDraining="SUB_DRAINING",n.Timeout="TIMEOUT",n.Tls="TLS",n.Unknown="UNKNOWN_ERROR",n.WssRequired="WSS_REQUIRED",n.JetStreamInvalidAck="JESTREAM_INVALID_ACK",n.JetStream404NoMessages="404",n.JetStream408RequestTimeout="408",n.JetStream409MaxAckPendingExceeded="409",n.JetStream409="409",n.JetStreamNotEnabled="503",n.JetStreamIdleHeartBeat="IDLE_HEARTBEAT",n.AuthorizationViolation="AUTHORIZATION_VIOLATION",n.AuthenticationExpired="AUTHENTICATION_EXPIRED",n.ProtocolError="NATS_PROTOCOL_ERR",n.PermissionsViolation="PERMISSIONS_VIOLATION",n.AuthenticationTimeout="AUTHENTICATION_TIMEOUT",n.AccountExpired="ACCOUNT_EXPIRED"})(ue||(ue={}));function iE(n){return typeof n.code=="string"}class ux{constructor(){j(this,"messages");this.messages=new Map,this.messages.set(ue.InvalidPayload,"Invalid payload type - payloads can be 'binary', 'string', or 'json'"),this.messages.set(ue.BadJson,"Bad JSON"),this.messages.set(ue.WssRequired,"TLS is required, therefore a secure websocket connection is also required")}static getMessage(t){return aE.getMessage(t)}getMessage(t){return this.messages.get(t)||t}}const aE=new ux;class ye extends Error{constructor(s,i,o){super(s);j(this,"name");j(this,"message");j(this,"code");j(this,"permissionContext");j(this,"chainedError");j(this,"api_error");this.name="NatsError",this.message=s,this.code=i,this.chainedError=o}static errorForCode(s,i){const o=ux.getMessage(s);return new ye(o,s,i)}isAuthError(){return this.code===ue.AuthenticationExpired||this.code===ue.AuthorizationViolation||this.code===ue.AccountExpired}isAuthTimeout(){return this.code===ue.AuthenticationTimeout}isPermissionError(){return this.code===ue.PermissionsViolation}isProtocolError(){return this.code===ue.ProtocolError}isJetStreamError(){return this.api_error!==void 0}jsError(){return this.api_error?this.api_error:null}}var vn;(function(n){n[n.Exact=0]="Exact",n[n.CanonicalMIME=1]="CanonicalMIME",n[n.IgnoreCase=2]="IgnoreCase"})(vn||(vn={}));var Qn;(function(n){n.Timer="timer",n.Count="count",n.JitterTimer="jitterTimer",n.SentinelMsg="sentinelMsg"})(Qn||(Qn={}));var bo;(function(n){n.STATS="io.nats.micro.v1.stats_response",n.INFO="io.nats.micro.v1.info_response",n.PING="io.nats.micro.v1.ping_response"})(bo||(bo={}));const cu="Nats-Service-Error",uu="Nats-Service-Error-Code";class fu extends Error{constructor(s,i){super(i);j(this,"code");this.code=s}static isServiceError(s){return fu.toServiceError(s)!==null}static toServiceError(s){var o,c;const i=((o=s==null?void 0:s.headers)==null?void 0:o.get(uu))||"";if(i!==""){const m=parseInt(i)||400,y=((c=s==null?void 0:s.headers)==null?void 0:c.get(cu))||"";return new fu(m,y.length?y:i)}return null}}function Rr(n=""){if(n=n||"_INBOX",typeof n!="string")throw new Error("prefix must be a string");return n.split(".").forEach(t=>{if(t==="*"||t===">")throw new Error(`inbox prefixes cannot have wildcards '${n}'`)}),`${n}.${Es.next()}`}const gd="127.0.0.1";var xs;(function(n){n.PING="PING",n.STATS="STATS",n.INFO="INFO"})(xs||(xs={}));function Su(n,...t){for(let s=0;s<t.length;s++){const i=t[s];Object.keys(i).forEach(function(o){n[o]=i[o]})}return n}function sc(n){return Sn.decode(n).replace(/\n/g,"␊").replace(/\r/g,"␍")}function ea(n,t=!0){const s=t?ye.errorForCode(ue.Timeout):null;let i,o;const c=new Promise((m,y)=>{i={cancel:()=>{o&&clearTimeout(o)}},o=setTimeout(()=>{y(s===null?ye.errorForCode(ue.Timeout):s)},n)});return Object.assign(c,i)}function sa(n=0){let t;const s=new Promise(i=>{const o=setTimeout(()=>{i()},n);t={cancel:()=>{o&&clearTimeout(o)}}});return Object.assign(s,t)}function pt(){let n={};const t=new Promise((s,i)=>{n={resolve:s,reject:i}});return Object.assign(t,n)}function fx(n){for(let t=n.length-1;t>0;t--){const s=Math.floor(Math.random()*(t+1));[n[t],n[s]]=[n[s],n[t]]}return n}function oE(n){return n===0?0:Math.floor(n/2+Math.random()*n)}function rm(n=[0,250,250,500,500,3e3,5e3]){Array.isArray(n)||(n=[0,250,250,500,500,3e3,5e3]);const t=n.length-1;return{backoff(s){return oE(s>t?n[t]:n[s])}}}function mt(n){return n*1e6}function sm(n){return Math.floor(n/1e6)}function Fg(n){let i=!0;const o=new Array(n.length);for(let c=0;c<n.length;c++){let m=n.charCodeAt(c);if(m===58||m<33||m>126)throw new ye(`'${n[c]}' is not a valid character for a header key`,ue.BadHeader);i&&97<=m&&m<=122?m-=32:!i&&65<=m&&m<=90&&(m+=32),o[c]=m,i=m==45}return String.fromCharCode(...o)}function Lr(n=0,t=""){if(n===0&&t!==""||n>0&&t==="")throw new Error("setting status requires both code and description");return new vs(n,t)}const Jh="NATS/1.0";class vs{constructor(t=0,s=""){j(this,"_code");j(this,"headers");j(this,"_description");this._code=t,this._description=s,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals(t){if(t&&this.headers.size===t.headers.size&&this._code===t._code){for(const[s,i]of this.headers){const o=t.values(s);if(i.length!==o.length)return!1;const c=[...i].sort(),m=[...o].sort();for(let y=0;y<c.length;y++)if(c[y]!==m[y])return!1}return!0}return!1}static decode(t){const s=new vs,o=Sn.decode(t).split(`\r
27
27
  `),c=o[0];if(c!==Jh){let m=c.replace(Jh,"").trim();if(m.length>0){s._code=parseInt(m,10),isNaN(s._code)&&(s._code=0);const y=s._code.toString();m=m.replace(y,""),s._description=m.trim()}}return o.length>=1&&o.slice(1).map(m=>{if(m){const y=m.indexOf(":");if(y>-1){const g=m.slice(0,y),u=m.slice(y+1).trim();s.append(g,u)}}}),s}toString(){if(this.headers.size===0&&this._code===0)return"";let t=Jh;this._code>0&&this._description!==""&&(t+=` ${this._code} ${this._description}`);for(const[s,i]of this.headers)for(let o=0;o<i.length;o++)t=`${t}\r
28
28
  ${s}: ${i[o]}`;return`${t}\r
29
29
  \r
30
- `}encode(){return ei.encode(this.toString())}static validHeaderValue(t){if(/[\r\n]/.test(t))throw new ye("invalid header value - \\r and \\n are not allowed.",ue.BadHeader);return t.trim()}keys(){const t=[];for(const s of this.headers.keys())t.push(s);return t}findKeys(t,s=vn.Exact){const i=this.keys();switch(s){case vn.Exact:return i.filter(o=>o===t);case vn.CanonicalMIME:return t=Fg(t),i.filter(o=>o===t);default:{const o=t.toLowerCase();return i.filter(c=>o===c.toLowerCase())}}}get(t,s=vn.Exact){const i=this.findKeys(t,s);if(i.length){const o=this.headers.get(i[0]);if(o)return Array.isArray(o)?o[0]:o}return""}last(t,s=vn.Exact){const i=this.findKeys(t,s);if(i.length){const o=this.headers.get(i[0]);if(o)return Array.isArray(o)?o[o.length-1]:o}return""}has(t,s=vn.Exact){return this.findKeys(t,s).length>0}set(t,s,i=vn.Exact){this.delete(t,i),this.append(t,s,i)}append(t,s,i=vn.Exact){const o=Fg(t);i===vn.CanonicalMIME&&(t=o);const c=this.findKeys(t,i);t=c.length>0?c[0]:t;const m=vs.validHeaderValue(s);let y=this.headers.get(t);y||(y=[],this.headers.set(t,y)),y.push(m)}values(t,s=vn.Exact){const i=[];return this.findKeys(t,s).forEach(c=>{const m=this.headers.get(c);m&&i.push(...m)}),i}delete(t,s=vn.Exact){this.findKeys(t,s).forEach(o=>{this.headers.delete(o)})}get hasError(){return this._code>=300}get status(){return`${this._code} ${this._description}`.trim()}toRecord(){const t={};return this.keys().forEach(s=>{t[s]=this.values(s)}),t}get code(){return this._code}get description(){return this._description}static fromRecord(t){const s=new vs;for(const i in t)s.headers.set(i,t[i]);return s}}function bd(){return{encode(n){return ei.encode(n)},decode(n){return Sn.decode(n)}}}function Wn(n){return{encode(t){try{return t===void 0&&(t=null),ei.encode(JSON.stringify(t))}catch(s){throw ye.errorForCode(ue.BadJson,s)}},decode(t){try{return JSON.parse(Sn.decode(t),n)}catch(s){throw ye.errorForCode(ue.BadJson,s)}}}}function dx(n){var t;return n&&n.data.length===0&&((t=n.headers)==null?void 0:t.code)===503?ye.errorForCode(ue.NoResponders):null}class im{constructor(t,s,i){j(this,"_headers");j(this,"_msg");j(this,"_rdata");j(this,"_reply");j(this,"_subject");j(this,"publisher");this._msg=t,this._rdata=s,this.publisher=i}get subject(){return this._subject?this._subject:(this._subject=Sn.decode(this._msg.subject),this._subject)}get reply(){return this._reply?this._reply:(this._reply=Sn.decode(this._msg.reply),this._reply)}get sid(){return this._msg.sid}get headers(){if(this._msg.hdr>-1&&!this._headers){const t=this._rdata.subarray(0,this._msg.hdr);this._headers=vs.decode(t)}return this._headers}get data(){return this._rdata?this._msg.hdr>-1?this._rdata.subarray(this._msg.hdr):this._rdata:new Uint8Array(0)}respond(t=An,s){return this.reply?(this.publisher.publish(this.reply,t,s),!0):!1}size(){var o;const t=this._msg.subject.length,s=((o=this._msg.reply)==null?void 0:o.length)||0,i=this._msg.size===-1?0:this._msg.size;return t+s+i}json(t){return Wn(t).decode(this.data)}string(){return Sn.decode(this.data)}requestInfo(){var s;const t=(s=this.headers)==null?void 0:s.get("Nats-Request-Info");return t?JSON.parse(t,function(i,o){return(i==="start"||i==="stop")&&o!==""?new Date(Date.parse(o)):o}):null}}j(im,"jc");function Ki(n){return Eu("durable",n)}function Kt(n){return Eu("stream",n)}function Eu(n,t=""){if(t==="")throw Error(`${n} name required`);return[".","*",">","/","\\"," "," ",`
30
+ `}encode(){return ei.encode(this.toString())}static validHeaderValue(t){if(/[\r\n]/.test(t))throw new ye("invalid header value - \\r and \\n are not allowed.",ue.BadHeader);return t.trim()}keys(){const t=[];for(const s of this.headers.keys())t.push(s);return t}findKeys(t,s=vn.Exact){const i=this.keys();switch(s){case vn.Exact:return i.filter(o=>o===t);case vn.CanonicalMIME:return t=Fg(t),i.filter(o=>o===t);default:{const o=t.toLowerCase();return i.filter(c=>o===c.toLowerCase())}}}get(t,s=vn.Exact){const i=this.findKeys(t,s);if(i.length){const o=this.headers.get(i[0]);if(o)return Array.isArray(o)?o[0]:o}return""}last(t,s=vn.Exact){const i=this.findKeys(t,s);if(i.length){const o=this.headers.get(i[0]);if(o)return Array.isArray(o)?o[o.length-1]:o}return""}has(t,s=vn.Exact){return this.findKeys(t,s).length>0}set(t,s,i=vn.Exact){this.delete(t,i),this.append(t,s,i)}append(t,s,i=vn.Exact){const o=Fg(t);i===vn.CanonicalMIME&&(t=o);const c=this.findKeys(t,i);t=c.length>0?c[0]:t;const m=vs.validHeaderValue(s);let y=this.headers.get(t);y||(y=[],this.headers.set(t,y)),y.push(m)}values(t,s=vn.Exact){const i=[];return this.findKeys(t,s).forEach(c=>{const m=this.headers.get(c);m&&i.push(...m)}),i}delete(t,s=vn.Exact){this.findKeys(t,s).forEach(o=>{this.headers.delete(o)})}get hasError(){return this._code>=300}get status(){return`${this._code} ${this._description}`.trim()}toRecord(){const t={};return this.keys().forEach(s=>{t[s]=this.values(s)}),t}get code(){return this._code}get description(){return this._description}static fromRecord(t){const s=new vs;for(const i in t)s.headers.set(i,t[i]);return s}}function bd(){return{encode(n){return ei.encode(n)},decode(n){return Sn.decode(n)}}}function Wn(n){return{encode(t){try{return t===void 0&&(t=null),ei.encode(JSON.stringify(t))}catch(s){throw ye.errorForCode(ue.BadJson,s)}},decode(t){try{return JSON.parse(Sn.decode(t),n)}catch(s){throw ye.errorForCode(ue.BadJson,s)}}}}function hx(n){var t;return n&&n.data.length===0&&((t=n.headers)==null?void 0:t.code)===503?ye.errorForCode(ue.NoResponders):null}class im{constructor(t,s,i){j(this,"_headers");j(this,"_msg");j(this,"_rdata");j(this,"_reply");j(this,"_subject");j(this,"publisher");this._msg=t,this._rdata=s,this.publisher=i}get subject(){return this._subject?this._subject:(this._subject=Sn.decode(this._msg.subject),this._subject)}get reply(){return this._reply?this._reply:(this._reply=Sn.decode(this._msg.reply),this._reply)}get sid(){return this._msg.sid}get headers(){if(this._msg.hdr>-1&&!this._headers){const t=this._rdata.subarray(0,this._msg.hdr);this._headers=vs.decode(t)}return this._headers}get data(){return this._rdata?this._msg.hdr>-1?this._rdata.subarray(this._msg.hdr):this._rdata:new Uint8Array(0)}respond(t=An,s){return this.reply?(this.publisher.publish(this.reply,t,s),!0):!1}size(){var o;const t=this._msg.subject.length,s=((o=this._msg.reply)==null?void 0:o.length)||0,i=this._msg.size===-1?0:this._msg.size;return t+s+i}json(t){return Wn(t).decode(this.data)}string(){return Sn.decode(this.data)}requestInfo(){var s;const t=(s=this.headers)==null?void 0:s.get("Nats-Request-Info");return t?JSON.parse(t,function(i,o){return(i==="start"||i==="stop")&&o!==""?new Date(Date.parse(o)):o}):null}}j(im,"jc");function Ki(n){return Eu("durable",n)}function Kt(n){return Eu("stream",n)}function Eu(n,t=""){if(t==="")throw Error(`${n} name required`);return[".","*",">","/","\\"," "," ",`
31
31
  `,"\r"].forEach(i=>{if(t.indexOf(i)!==-1){switch(i){case`
32
- `:i="\\n";break;case"\r":i="\\r";break;case" ":i="\\t";break}throw Error(`invalid ${n} name - ${n} name cannot contain '${i}'`)}}),""}function mo(n,t=""){if(t==="")throw Error(`${n} name required`);const s=cE(t);if(s.length)throw new Error(`invalid ${n} name - ${n} name ${s}`)}function cE(n=""){if(n==="")throw Error("name required");const t=/^[-\w]+$/g;if(n.match(t)===null){for(const i of n.split(""))if(i.match(t)===null)return`cannot contain '${i}'`}return""}function xd(n){if(n.data.length>0)return!1;const t=n.headers;return t?t.code>=100&&t.code<200:!1}function vd(n){var t;return xd(n)&&((t=n.headers)==null?void 0:t.description)==="Idle Heartbeat"}function uE(n,t,s){const i=Lr(n,t),o={hdr:1,sid:0,size:0},c=new im(o,An,{});return c._headers=i,c._subject=s,c}function Ji(n){if(n.data.length!==0)return null;const t=n.headers;return t?mx(t.code,t.description):null}var zn;(function(n){n.MaxBatchExceeded="exceeded maxrequestbatch of",n.MaxExpiresExceeded="exceeded maxrequestexpires of",n.MaxBytesExceeded="exceeded maxrequestmaxbytes of",n.MaxMessageSizeExceeded="message size exceeds maxbytes",n.PushConsumer="consumer is push based",n.MaxWaitingExceeded="exceeded maxwaiting",n.IdleHeartbeatMissed="idle heartbeats missed",n.ConsumerDeleted="consumer deleted"})(zn||(zn={}));function fE(n){return n.code!==ue.JetStream409?!1:[zn.MaxBatchExceeded,zn.MaxExpiresExceeded,zn.MaxBytesExceeded,zn.MaxMessageSizeExceeded,zn.PushConsumer,zn.IdleHeartbeatMissed,zn.ConsumerDeleted].find(s=>n.message.indexOf(s)!==-1)!==void 0}function mx(n,t=""){if(n<300)return null;switch(t=t.toLowerCase(),n){case 404:return new ye(t,ue.JetStream404NoMessages);case 408:return new ye(t,ue.JetStream408RequestTimeout);case 409:{const s=t.startsWith(zn.IdleHeartbeatMissed)?ue.JetStreamIdleHeartBeat:ue.JetStream409;return new ye(t,s)}case 503:return ye.errorForCode(ue.JetStreamNotEnabled,new Error(t));default:return t===""&&(t=ue.Unknown),new ye(t,`${n}`)}}class Bt{constructor(){j(this,"inflight");j(this,"processed");j(this,"received");j(this,"noIterator");j(this,"iterClosed");j(this,"done");j(this,"signal");j(this,"yields");j(this,"filtered");j(this,"pendingFiltered");j(this,"ingestionFilterFn");j(this,"protocolFilterFn");j(this,"dispatchedFn");j(this,"ctx");j(this,"_data");j(this,"err");j(this,"time");j(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=pt(),this.yields=[],this.iterClosed=pt(),this.time=0,this.yielding=!1}[Symbol.asyncIterator](){return this.iterate()}push(t){if(this.done)return;if(typeof t=="function"){this.yields.push(t),this.signal.resolve();return}const{ingest:s,protocol:i}=this.ingestionFilterFn?this.ingestionFilterFn(t,this.ctx||this):{ingest:!0,protocol:!1};s&&(i&&(this.filtered++,this.pendingFiltered++),this.yields.push(t),this.signal.resolve())}async*iterate(){if(this.noIterator)throw new ye("unsupported iterator",ue.ApiError);if(this.yielding)throw new ye("already yielding",ue.ApiError);this.yielding=!0;try{for(;;){if(this.yields.length===0&&await this.signal,this.err)throw this.err;const t=this.yields;this.inflight=t.length,this.yields=[];for(let s=0;s<t.length;s++){if(typeof t[s]=="function"){const o=t[s];try{o()}catch(c){throw c}if(this.err)throw this.err;continue}if(this.protocolFilterFn?this.protocolFilterFn(t[s]):!0){this.processed++;const o=Date.now();yield t[s],this.time=Date.now()-o,this.dispatchedFn&&t[s]&&this.dispatchedFn(t[s])}else this.pendingFiltered--;this.inflight--}if(this.done)break;this.yields.length===0&&(t.length=0,this.yields=t,this.signal=pt())}}finally{this.stop()}}stop(t){this.done||(this.err=t,this.done=!0,this.signal.resolve(),this.iterClosed.resolve(t))}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}class am{constructor(t,s,i={maxOut:2}){j(this,"interval");j(this,"maxOut");j(this,"cancelAfter");j(this,"timer");j(this,"autoCancelTimer");j(this,"last");j(this,"missed");j(this,"count");j(this,"callback");this.interval=t,this.maxOut=(i==null?void 0:i.maxOut)||2,this.cancelAfter=(i==null?void 0:i.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(t,s=0,i=2){this.interval=t,this.maxOut=i,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(t){console.log(t)}},this.interval)}}var _d;(function(n){n.Limits="limits",n.Interest="interest",n.Workqueue="workqueue"})(_d||(_d={}));var wo;(function(n){n.Old="old",n.New="new"})(wo||(wo={}));var wd;(function(n){n.File="file",n.Memory="memory"})(wd||(wd={}));var Et;(function(n){n.All="all",n.Last="last",n.New="new",n.StartSequence="by_start_sequence",n.StartTime="by_start_time",n.LastPerSubject="last_per_subject"})(Et||(Et={}));var qt;(function(n){n.None="none",n.All="all",n.Explicit="explicit",n.NotSet=""})(qt||(qt={}));var ta;(function(n){n.Instant="instant",n.Original="original"})(ta||(ta={}));var Os;(function(n){n.None="none",n.S2="s2"})(Os||(Os={}));var hu;(function(n){n.CreateOrUpdate="",n.Update="update",n.Create="create"})(hu||(hu={}));function hE(n,t={}){return Object.assign({name:n,deliver_policy:Et.All,ack_policy:qt.Explicit,ack_wait:mt(30*1e3),replay_policy:ta.Instant},t)}var Gg;(function(n){n.API="api_audit",n.StreamAction="stream_action",n.ConsumerAction="consumer_action",n.SnapshotCreate="snapshot_create",n.SnapshotComplete="snapshot_complete",n.RestoreCreate="restore_create",n.RestoreComplete="restore_complete",n.MaxDeliver="max_deliver",n.Terminated="terminated",n.Ack="consumer_ack",n.StreamLeaderElected="stream_leader_elected",n.StreamQuorumLost="stream_quorum_lost",n.ConsumerLeaderElected="consumer_leader_elected",n.ConsumerQuorumLost="consumer_quorum_lost"})(Gg||(Gg={}));var Qt;(function(n){n.StreamSourceHdr="Nats-Stream-Source",n.LastConsumerSeqHdr="Nats-Last-Consumer",n.LastStreamSeqHdr="Nats-Last-Stream",n.ConsumerStalledHdr="Nats-Consumer-Stalled",n.MessageSizeHdr="Nats-Msg-Size",n.RollupHdr="Nats-Rollup",n.RollupValueSubject="sub",n.RollupValueAll="all",n.PendingMessagesHdr="Nats-Pending-Messages",n.PendingBytesHdr="Nats-Pending-Bytes"})(Qt||(Qt={}));var Jn;(function(n){n.LastValue="",n.AllHistory="history",n.UpdatesOnly="updates"})(Jn||(Jn={}));var Vi;(function(n){n.Stream="Nats-Stream",n.Sequence="Nats-Sequence",n.TimeStamp="Nats-Time-Stamp",n.Subject="Nats-Subject"})(Vi||(Vi={}));var Vg;(function(n){n.Stream="Nats-Stream",n.Subject="Nats-Subject",n.Sequence="Nats-Sequence",n.LastSequence="Nats-Last-Sequence",n.Size="Nats-Msg-Size"})(Vg||(Vg={}));const _n="KV_";class dE{constructor(t){j(this,"config");j(this,"ordered");j(this,"mack");j(this,"stream");j(this,"callbackFn");j(this,"max");j(this,"qname");j(this,"isBind");j(this,"filters");this.stream="",this.mack=!1,this.ordered=!1,this.config=hE("",t||{})}getOpts(){var s;const t={};if(t.config=Object.assign({},this.config),t.config.filter_subject&&(this.filterSubject(t.config.filter_subject),t.config.filter_subject=void 0),t.config.filter_subjects&&((s=t.config.filter_subjects)==null||s.forEach(i=>{this.filterSubject(i)}),t.config.filter_subjects=void 0),t.mack=this.mack,t.stream=this.stream,t.callbackFn=this.callbackFn,t.max=this.max,t.queue=this.qname,t.ordered=this.ordered,t.config.ack_policy=t.ordered?qt.None:t.config.ack_policy,t.isBind=t.isBind||!1,this.filters)switch(this.filters.length){case 0:break;case 1:t.config.filter_subject=this.filters[0];break;default:t.config.filter_subjects=this.filters}return t}description(t){return this.config.description=t,this}deliverTo(t){return this.config.deliver_subject=t,this}durable(t){return Ki(t),this.config.durable_name=t,this}startSequence(t){if(t<=0)throw new Error("sequence must be greater than 0");return this.config.deliver_policy=Et.StartSequence,this.config.opt_start_seq=t,this}startTime(t){return this.config.deliver_policy=Et.StartTime,this.config.opt_start_time=t.toISOString(),this}deliverAll(){return this.config.deliver_policy=Et.All,this}deliverLastPerSubject(){return this.config.deliver_policy=Et.LastPerSubject,this}deliverLast(){return this.config.deliver_policy=Et.Last,this}deliverNew(){return this.config.deliver_policy=Et.New,this}startAtTimeDelta(t){return this.startTime(new Date(Date.now()-t)),this}headersOnly(){return this.config.headers_only=!0,this}ackNone(){return this.config.ack_policy=qt.None,this}ackAll(){return this.config.ack_policy=qt.All,this}ackExplicit(){return this.config.ack_policy=qt.Explicit,this}ackWait(t){return this.config.ack_wait=mt(t),this}maxDeliver(t){return this.config.max_deliver=t,this}filterSubject(t){return this.filters=this.filters||[],this.filters.push(t),this}replayInstantly(){return this.config.replay_policy=ta.Instant,this}replayOriginal(){return this.config.replay_policy=ta.Original,this}sample(t){if(t=Math.trunc(t),t<0||t>100)throw new Error("value must be between 0-100");return this.config.sample_freq=`${t}%`,this}limit(t){return this.config.rate_limit_bps=t,this}maxWaiting(t){return this.config.max_waiting=t,this}maxAckPending(t){return this.config.max_ack_pending=t,this}idleHeartbeat(t){return this.config.idle_heartbeat=mt(t),this}flowControl(){return this.config.flow_control=!0,this}deliverGroup(t){return this.queue(t),this}manualAck(){return this.mack=!0,this}maxMessages(t){return this.max=t,this}callback(t){return this.callbackFn=t,this}queue(t){return this.qname=t,this.config.deliver_group=t,this}orderedConsumer(){return this.ordered=!0,this}bind(t,s){return this.stream=t,this.config.durable_name=s,this.isBind=!0,this}bindStream(t){return this.stream=t,this}inactiveEphemeralThreshold(t){return this.config.inactive_threshold=mt(t),this}maxPullBatch(t){return this.config.max_batch=t,this}maxPullRequestExpires(t){return this.config.max_expires=mt(t),this}memory(){return this.config.mem_storage=!0,this}numReplicas(t){return this.config.num_replicas=t,this}consumerName(t){return this.config.name=t,this}}function _s(n){return new dE(n)}function Yg(n){return typeof n.getOpts=="function"}class mE{static encode(t){if(typeof t=="string")return btoa(t);const s=Array.from(t);return btoa(String.fromCharCode(...s))}static decode(t,s=!1){const i=atob(t);return s?Uint8Array.from(i,o=>o.charCodeAt(0)):i}}class Xi{static encode(t){return Xi.toB64URLEncoding(mE.encode(t))}static decode(t,s=!1){return Xi.decode(Xi.fromB64URLEncoding(t),s)}static toB64URLEncoding(t){return t.replace(/\+/g,"-").replace(/\//g,"_")}static fromB64URLEncoding(t){return t.replace(/_/g,"/").replace(/-/g,"+")}}class na{constructor(){j(this,"buffers");j(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...t){let s=0;for(let c=0;c<t.length;c++)s+=t[c].length;const i=new Uint8Array(s);let o=0;for(let c=0;c<t.length;c++)i.set(t[c],o),o+=t[c].length;return i}static fromAscii(t){return t||(t=""),ei.encode(t)}static toAscii(t){return Sn.decode(t)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){const t=new Uint8Array(this.byteLength);let s=0;for(let i=0;i<this.buffers.length;i++)t.set(this.buffers[i],s),s+=this.buffers[i].length;this.buffers.length=0,this.buffers.push(t)}}shift(){if(this.buffers.length){const t=this.buffers.shift();if(t)return this.byteLength-=t.length,t}return new Uint8Array(0)}drain(t){if(this.buffers.length){this.pack();const s=this.buffers.pop();if(s){const i=this.byteLength;(t===void 0||t>i)&&(t=i);const o=s.subarray(0,t);return i>t&&this.buffers.push(s.subarray(t)),this.byteLength=i-t,o}}return new Uint8Array(0)}fill(t,...s){t&&(this.buffers.push(t),this.byteLength+=t.length);for(let i=0;i<s.length;i++)s[i]&&s[i].length&&(this.buffers.push(s[i]),this.byteLength+=s[i].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}function pE(n,t){return t.forEach(function(s){s&&typeof s!="string"&&!Array.isArray(s)&&Object.keys(s).forEach(function(i){if(i!=="default"&&!(i in n)){var o=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return s[i]}})}})}),Object.freeze(n)}var yE=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},no=yE.performance||{};no.now||no.mozNow||no.msNow||no.oNow||no.webkitNow;var Kg={versions:{}},gE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bE(n){if(n.__esModule)return n;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(n).forEach(function(s){var i=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return n[s]}})}),t}var Xh,Ou={exports:{}},Jg={},Xg=bE(pE({__proto__:null,default:Jg},[Jg]));Xh=Ou,(function(){var n="input is invalid type",t=typeof window=="object",s=t?window:{};s.JS_SHA256_NO_WINDOW&&(t=!1);var i=!t&&typeof self=="object",o=!s.JS_SHA256_NO_NODE_JS&&Kg.versions&&Kg.versions.node;o?s=gE:i&&(s=self);var c=!s.JS_SHA256_NO_COMMON_JS&&Xh.exports,m=!s.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",y="0123456789abcdef".split(""),g=[-2147483648,8388608,32768,128],u=[24,16,8,0],d=[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],b=["hex","array","digest","arrayBuffer"],x=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(R){return Object.prototype.toString.call(R)==="[object Array]"}),!m||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(R){return typeof R=="object"&&R.buffer&&R.buffer.constructor===ArrayBuffer});var v=function(R,$){return function(ne){return new B($,!0).update(ne)[R]()}},w=function(R){var $=v("hex",R);o&&($=S($,R)),$.create=function(){return new B(R)},$.update=function(I){return $.create().update(I)};for(var ne=0;ne<b.length;++ne){var V=b[ne];$[V]=v(V,R)}return $},S=function(R,$){var ne,V=Xg,I=Xg.Buffer,D=$?"sha224":"sha256";return ne=I.from&&!s.JS_SHA256_NO_BUFFER_FROM?I.from:function(Q){return new I(Q)},function(Q){if(typeof Q=="string")return V.createHash(D).update(Q,"utf8").digest("hex");if(Q==null)throw new Error(n);return Q.constructor===ArrayBuffer&&(Q=new Uint8Array(Q)),Array.isArray(Q)||ArrayBuffer.isView(Q)||Q.constructor===I?V.createHash(D).update(ne(Q)).digest("hex"):R(Q)}},C=function(R,$){return function(ne,V){return new ie(ne,$,!0).update(V)[R]()}},q=function(R){var $=C("hex",R);$.create=function(I){return new ie(I,R)},$.update=function(I,D){return $.create(I).update(D)};for(var ne=0;ne<b.length;++ne){var V=b[ne];$[V]=C(V,R)}return $};function B(R,$){$?(x[0]=x[16]=x[1]=x[2]=x[3]=x[4]=x[5]=x[6]=x[7]=x[8]=x[9]=x[10]=x[11]=x[12]=x[13]=x[14]=x[15]=0,this.blocks=x):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],R?(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=R}function ie(R,$,ne){var V,I=typeof R;if(I==="string"){var D,Q=[],X=R.length,he=0;for(V=0;V<X;++V)(D=R.charCodeAt(V))<128?Q[he++]=D:D<2048?(Q[he++]=192|D>>>6,Q[he++]=128|63&D):D<55296||D>=57344?(Q[he++]=224|D>>>12,Q[he++]=128|D>>>6&63,Q[he++]=128|63&D):(D=65536+((1023&D)<<10|1023&R.charCodeAt(++V)),Q[he++]=240|D>>>18,Q[he++]=128|D>>>12&63,Q[he++]=128|D>>>6&63,Q[he++]=128|63&D);R=Q}else{if(I!=="object")throw new Error(n);if(R===null)throw new Error(n);if(m&&R.constructor===ArrayBuffer)R=new Uint8Array(R);else if(!(Array.isArray(R)||m&&ArrayBuffer.isView(R)))throw new Error(n)}R.length>64&&(R=new B($,!0).update(R).array());var Se=[],ke=[];for(V=0;V<64;++V){var H=R[V]||0;Se[V]=92^H,ke[V]=54^H}B.call(this,$,ne),this.update(ke),this.oKeyPad=Se,this.inner=!0,this.sharedMemory=ne}B.prototype.update=function(R){if(!this.finalized){var $,ne=typeof R;if(ne!=="string"){if(ne!=="object")throw new Error(n);if(R===null)throw new Error(n);if(m&&R.constructor===ArrayBuffer)R=new Uint8Array(R);else if(!(Array.isArray(R)||m&&ArrayBuffer.isView(R)))throw new Error(n);$=!0}for(var V,I,D=0,Q=R.length,X=this.blocks;D<Q;){if(this.hashed&&(this.hashed=!1,X[0]=this.block,this.block=X[16]=X[1]=X[2]=X[3]=X[4]=X[5]=X[6]=X[7]=X[8]=X[9]=X[10]=X[11]=X[12]=X[13]=X[14]=X[15]=0),$)for(I=this.start;D<Q&&I<64;++D)X[I>>>2]|=R[D]<<u[3&I++];else for(I=this.start;D<Q&&I<64;++D)(V=R.charCodeAt(D))<128?X[I>>>2]|=V<<u[3&I++]:V<2048?(X[I>>>2]|=(192|V>>>6)<<u[3&I++],X[I>>>2]|=(128|63&V)<<u[3&I++]):V<55296||V>=57344?(X[I>>>2]|=(224|V>>>12)<<u[3&I++],X[I>>>2]|=(128|V>>>6&63)<<u[3&I++],X[I>>>2]|=(128|63&V)<<u[3&I++]):(V=65536+((1023&V)<<10|1023&R.charCodeAt(++D)),X[I>>>2]|=(240|V>>>18)<<u[3&I++],X[I>>>2]|=(128|V>>>12&63)<<u[3&I++],X[I>>>2]|=(128|V>>>6&63)<<u[3&I++],X[I>>>2]|=(128|63&V)<<u[3&I++]);this.lastByteIndex=I,this.bytes+=I-this.start,I>=64?(this.block=X[16],this.start=I-64,this.hash(),this.hashed=!0):this.start=I}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var R=this.blocks,$=this.lastByteIndex;R[16]=this.block,R[$>>>2]|=g[3&$],this.block=R[16],$>=56&&(this.hashed||this.hash(),R[0]=this.block,R[16]=R[1]=R[2]=R[3]=R[4]=R[5]=R[6]=R[7]=R[8]=R[9]=R[10]=R[11]=R[12]=R[13]=R[14]=R[15]=0),R[14]=this.hBytes<<3|this.bytes>>>29,R[15]=this.bytes<<3,this.hash()}},B.prototype.hash=function(){var R,$,ne,V,I,D,Q,X,he,Se=this.h0,ke=this.h1,H=this.h2,W=this.h3,ce=this.h4,xe=this.h5,ve=this.h6,Ce=this.h7,Ne=this.blocks;for(R=16;R<64;++R)$=((I=Ne[R-15])>>>7|I<<25)^(I>>>18|I<<14)^I>>>3,ne=((I=Ne[R-2])>>>17|I<<15)^(I>>>19|I<<13)^I>>>10,Ne[R]=Ne[R-16]+$+Ne[R-7]+ne|0;for(he=ke&H,R=0;R<64;R+=4)this.first?(this.is224?(D=300032,Ce=(I=Ne[0]-1413257819)-150054599|0,W=I+24177077|0):(D=704751109,Ce=(I=Ne[0]-210244248)-1521486534|0,W=I+143694565|0),this.first=!1):($=(Se>>>2|Se<<30)^(Se>>>13|Se<<19)^(Se>>>22|Se<<10),V=(D=Se&ke)^Se&H^he,Ce=W+(I=Ce+(ne=(ce>>>6|ce<<26)^(ce>>>11|ce<<21)^(ce>>>25|ce<<7))+(ce&xe^~ce&ve)+d[R]+Ne[R])|0,W=I+($+V)|0),$=(W>>>2|W<<30)^(W>>>13|W<<19)^(W>>>22|W<<10),V=(Q=W&Se)^W&ke^D,ve=H+(I=ve+(ne=(Ce>>>6|Ce<<26)^(Ce>>>11|Ce<<21)^(Ce>>>25|Ce<<7))+(Ce&ce^~Ce&xe)+d[R+1]+Ne[R+1])|0,$=((H=I+($+V)|0)>>>2|H<<30)^(H>>>13|H<<19)^(H>>>22|H<<10),V=(X=H&W)^H&Se^Q,xe=ke+(I=xe+(ne=(ve>>>6|ve<<26)^(ve>>>11|ve<<21)^(ve>>>25|ve<<7))+(ve&Ce^~ve&ce)+d[R+2]+Ne[R+2])|0,$=((ke=I+($+V)|0)>>>2|ke<<30)^(ke>>>13|ke<<19)^(ke>>>22|ke<<10),V=(he=ke&H)^ke&W^X,ce=Se+(I=ce+(ne=(xe>>>6|xe<<26)^(xe>>>11|xe<<21)^(xe>>>25|xe<<7))+(xe&ve^~xe&Ce)+d[R+3]+Ne[R+3])|0,Se=I+($+V)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+Se|0,this.h1=this.h1+ke|0,this.h2=this.h2+H|0,this.h3=this.h3+W|0,this.h4=this.h4+ce|0,this.h5=this.h5+xe|0,this.h6=this.h6+ve|0,this.h7=this.h7+Ce|0},B.prototype.hex=function(){this.finalize();var R=this.h0,$=this.h1,ne=this.h2,V=this.h3,I=this.h4,D=this.h5,Q=this.h6,X=this.h7,he=y[R>>>28&15]+y[R>>>24&15]+y[R>>>20&15]+y[R>>>16&15]+y[R>>>12&15]+y[R>>>8&15]+y[R>>>4&15]+y[15&R]+y[$>>>28&15]+y[$>>>24&15]+y[$>>>20&15]+y[$>>>16&15]+y[$>>>12&15]+y[$>>>8&15]+y[$>>>4&15]+y[15&$]+y[ne>>>28&15]+y[ne>>>24&15]+y[ne>>>20&15]+y[ne>>>16&15]+y[ne>>>12&15]+y[ne>>>8&15]+y[ne>>>4&15]+y[15&ne]+y[V>>>28&15]+y[V>>>24&15]+y[V>>>20&15]+y[V>>>16&15]+y[V>>>12&15]+y[V>>>8&15]+y[V>>>4&15]+y[15&V]+y[I>>>28&15]+y[I>>>24&15]+y[I>>>20&15]+y[I>>>16&15]+y[I>>>12&15]+y[I>>>8&15]+y[I>>>4&15]+y[15&I]+y[D>>>28&15]+y[D>>>24&15]+y[D>>>20&15]+y[D>>>16&15]+y[D>>>12&15]+y[D>>>8&15]+y[D>>>4&15]+y[15&D]+y[Q>>>28&15]+y[Q>>>24&15]+y[Q>>>20&15]+y[Q>>>16&15]+y[Q>>>12&15]+y[Q>>>8&15]+y[Q>>>4&15]+y[15&Q];return this.is224||(he+=y[X>>>28&15]+y[X>>>24&15]+y[X>>>20&15]+y[X>>>16&15]+y[X>>>12&15]+y[X>>>8&15]+y[X>>>4&15]+y[15&X]),he},B.prototype.toString=B.prototype.hex,B.prototype.digest=function(){this.finalize();var R=this.h0,$=this.h1,ne=this.h2,V=this.h3,I=this.h4,D=this.h5,Q=this.h6,X=this.h7,he=[R>>>24&255,R>>>16&255,R>>>8&255,255&R,$>>>24&255,$>>>16&255,$>>>8&255,255&$,ne>>>24&255,ne>>>16&255,ne>>>8&255,255&ne,V>>>24&255,V>>>16&255,V>>>8&255,255&V,I>>>24&255,I>>>16&255,I>>>8&255,255&I,D>>>24&255,D>>>16&255,D>>>8&255,255&D,Q>>>24&255,Q>>>16&255,Q>>>8&255,255&Q];return this.is224||he.push(X>>>24&255,X>>>16&255,X>>>8&255,255&X),he},B.prototype.array=B.prototype.digest,B.prototype.arrayBuffer=function(){this.finalize();var R=new ArrayBuffer(this.is224?28:32),$=new DataView(R);return $.setUint32(0,this.h0),$.setUint32(4,this.h1),$.setUint32(8,this.h2),$.setUint32(12,this.h3),$.setUint32(16,this.h4),$.setUint32(20,this.h5),$.setUint32(24,this.h6),this.is224||$.setUint32(28,this.h7),R},ie.prototype=new B,ie.prototype.finalize=function(){if(B.prototype.finalize.call(this),this.inner){this.inner=!1;var R=this.array();B.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(R),B.prototype.finalize.call(this)}};var le=w();le.sha256=le,le.sha224=w(!0),le.sha256.hmac=q(),le.sha224.hmac=q(!0),c?Xh.exports=le:(s.sha256=le.sha256,s.sha224=le.sha224)})();Ou.exports;Ou.exports.sha224;var Qg=Ou.exports.sha256;function Sd(n){return EE(n)}function xE(n){if(!/^[0-9A-Fa-f]+$/.test(n))return!1;const s=/^[0-9A-F]+$/.test(n),i=/^[0-9a-f]+$/.test(n);return s||i?n.length%2===0:!1}function vE(n){return/^[A-Za-z0-9\-_]*(={0,2})?$/.test(n)||/^[A-Za-z0-9+/]*(={0,2})?$/.test(n)}function _E(n){return xE(n)?"hex":vE(n)?"b64":""}function wE(n){if(n.length%2!==0)throw new Error("hex string must have an even length");const t=new Uint8Array(n.length/2);for(let s=0;s<n.length;s+=2)t[s/2]=parseInt(n.substring(s,s+2),16);return t}function SE(n){n=n.replace(/-/g,"+"),n=n.replace(/_/g,"/");const t=atob(n);return Uint8Array.from(t,s=>s.charCodeAt(0))}function EE(n){switch(_E(n)){case"hex":return wE(n);case"b64":return SE(n)}return null}function OE(n,t){const s=typeof n=="string"?Sd(n):n,i=typeof t=="string"?Sd(t):t;if(s===null||i===null||s.length!==i.length)return!1;for(let o=0;o<s.length;o++)if(s[o]!==i[o])return!1;return!0}class px{constructor(t,s,i=!0){j(this,"token");j(this,"received");j(this,"ctx");j(this,"requestSubject");j(this,"mux");this.mux=t,this.requestSubject=s,this.received=0,this.token=Es.next(),i&&(this.ctx=new Error)}}class AE extends px{constructor(s,i,o={maxWait:1e3}){super(s,i);j(this,"callback");j(this,"done");j(this,"timer");j(this,"max");j(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=pt(),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,i){s?(this.ctx&&(s.stack+=`
32
+ `:i="\\n";break;case"\r":i="\\r";break;case" ":i="\\t";break}throw Error(`invalid ${n} name - ${n} name cannot contain '${i}'`)}}),""}function mo(n,t=""){if(t==="")throw Error(`${n} name required`);const s=lE(t);if(s.length)throw new Error(`invalid ${n} name - ${n} name ${s}`)}function lE(n=""){if(n==="")throw Error("name required");const t=/^[-\w]+$/g;if(n.match(t)===null){for(const i of n.split(""))if(i.match(t)===null)return`cannot contain '${i}'`}return""}function xd(n){if(n.data.length>0)return!1;const t=n.headers;return t?t.code>=100&&t.code<200:!1}function vd(n){var t;return xd(n)&&((t=n.headers)==null?void 0:t.description)==="Idle Heartbeat"}function cE(n,t,s){const i=Lr(n,t),o={hdr:1,sid:0,size:0},c=new im(o,An,{});return c._headers=i,c._subject=s,c}function Ji(n){if(n.data.length!==0)return null;const t=n.headers;return t?dx(t.code,t.description):null}var zn;(function(n){n.MaxBatchExceeded="exceeded maxrequestbatch of",n.MaxExpiresExceeded="exceeded maxrequestexpires of",n.MaxBytesExceeded="exceeded maxrequestmaxbytes of",n.MaxMessageSizeExceeded="message size exceeds maxbytes",n.PushConsumer="consumer is push based",n.MaxWaitingExceeded="exceeded maxwaiting",n.IdleHeartbeatMissed="idle heartbeats missed",n.ConsumerDeleted="consumer deleted"})(zn||(zn={}));function uE(n){return n.code!==ue.JetStream409?!1:[zn.MaxBatchExceeded,zn.MaxExpiresExceeded,zn.MaxBytesExceeded,zn.MaxMessageSizeExceeded,zn.PushConsumer,zn.IdleHeartbeatMissed,zn.ConsumerDeleted].find(s=>n.message.indexOf(s)!==-1)!==void 0}function dx(n,t=""){if(n<300)return null;switch(t=t.toLowerCase(),n){case 404:return new ye(t,ue.JetStream404NoMessages);case 408:return new ye(t,ue.JetStream408RequestTimeout);case 409:{const s=t.startsWith(zn.IdleHeartbeatMissed)?ue.JetStreamIdleHeartBeat:ue.JetStream409;return new ye(t,s)}case 503:return ye.errorForCode(ue.JetStreamNotEnabled,new Error(t));default:return t===""&&(t=ue.Unknown),new ye(t,`${n}`)}}class Bt{constructor(){j(this,"inflight");j(this,"processed");j(this,"received");j(this,"noIterator");j(this,"iterClosed");j(this,"done");j(this,"signal");j(this,"yields");j(this,"filtered");j(this,"pendingFiltered");j(this,"ingestionFilterFn");j(this,"protocolFilterFn");j(this,"dispatchedFn");j(this,"ctx");j(this,"_data");j(this,"err");j(this,"time");j(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=pt(),this.yields=[],this.iterClosed=pt(),this.time=0,this.yielding=!1}[Symbol.asyncIterator](){return this.iterate()}push(t){if(this.done)return;if(typeof t=="function"){this.yields.push(t),this.signal.resolve();return}const{ingest:s,protocol:i}=this.ingestionFilterFn?this.ingestionFilterFn(t,this.ctx||this):{ingest:!0,protocol:!1};s&&(i&&(this.filtered++,this.pendingFiltered++),this.yields.push(t),this.signal.resolve())}async*iterate(){if(this.noIterator)throw new ye("unsupported iterator",ue.ApiError);if(this.yielding)throw new ye("already yielding",ue.ApiError);this.yielding=!0;try{for(;;){if(this.yields.length===0&&await this.signal,this.err)throw this.err;const t=this.yields;this.inflight=t.length,this.yields=[];for(let s=0;s<t.length;s++){if(typeof t[s]=="function"){const o=t[s];try{o()}catch(c){throw c}if(this.err)throw this.err;continue}if(this.protocolFilterFn?this.protocolFilterFn(t[s]):!0){this.processed++;const o=Date.now();yield t[s],this.time=Date.now()-o,this.dispatchedFn&&t[s]&&this.dispatchedFn(t[s])}else this.pendingFiltered--;this.inflight--}if(this.done)break;this.yields.length===0&&(t.length=0,this.yields=t,this.signal=pt())}}finally{this.stop()}}stop(t){this.done||(this.err=t,this.done=!0,this.signal.resolve(),this.iterClosed.resolve(t))}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}class am{constructor(t,s,i={maxOut:2}){j(this,"interval");j(this,"maxOut");j(this,"cancelAfter");j(this,"timer");j(this,"autoCancelTimer");j(this,"last");j(this,"missed");j(this,"count");j(this,"callback");this.interval=t,this.maxOut=(i==null?void 0:i.maxOut)||2,this.cancelAfter=(i==null?void 0:i.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(t,s=0,i=2){this.interval=t,this.maxOut=i,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(t){console.log(t)}},this.interval)}}var _d;(function(n){n.Limits="limits",n.Interest="interest",n.Workqueue="workqueue"})(_d||(_d={}));var wo;(function(n){n.Old="old",n.New="new"})(wo||(wo={}));var wd;(function(n){n.File="file",n.Memory="memory"})(wd||(wd={}));var Et;(function(n){n.All="all",n.Last="last",n.New="new",n.StartSequence="by_start_sequence",n.StartTime="by_start_time",n.LastPerSubject="last_per_subject"})(Et||(Et={}));var qt;(function(n){n.None="none",n.All="all",n.Explicit="explicit",n.NotSet=""})(qt||(qt={}));var ta;(function(n){n.Instant="instant",n.Original="original"})(ta||(ta={}));var Os;(function(n){n.None="none",n.S2="s2"})(Os||(Os={}));var hu;(function(n){n.CreateOrUpdate="",n.Update="update",n.Create="create"})(hu||(hu={}));function fE(n,t={}){return Object.assign({name:n,deliver_policy:Et.All,ack_policy:qt.Explicit,ack_wait:mt(30*1e3),replay_policy:ta.Instant},t)}var Gg;(function(n){n.API="api_audit",n.StreamAction="stream_action",n.ConsumerAction="consumer_action",n.SnapshotCreate="snapshot_create",n.SnapshotComplete="snapshot_complete",n.RestoreCreate="restore_create",n.RestoreComplete="restore_complete",n.MaxDeliver="max_deliver",n.Terminated="terminated",n.Ack="consumer_ack",n.StreamLeaderElected="stream_leader_elected",n.StreamQuorumLost="stream_quorum_lost",n.ConsumerLeaderElected="consumer_leader_elected",n.ConsumerQuorumLost="consumer_quorum_lost"})(Gg||(Gg={}));var Qt;(function(n){n.StreamSourceHdr="Nats-Stream-Source",n.LastConsumerSeqHdr="Nats-Last-Consumer",n.LastStreamSeqHdr="Nats-Last-Stream",n.ConsumerStalledHdr="Nats-Consumer-Stalled",n.MessageSizeHdr="Nats-Msg-Size",n.RollupHdr="Nats-Rollup",n.RollupValueSubject="sub",n.RollupValueAll="all",n.PendingMessagesHdr="Nats-Pending-Messages",n.PendingBytesHdr="Nats-Pending-Bytes"})(Qt||(Qt={}));var Jn;(function(n){n.LastValue="",n.AllHistory="history",n.UpdatesOnly="updates"})(Jn||(Jn={}));var Vi;(function(n){n.Stream="Nats-Stream",n.Sequence="Nats-Sequence",n.TimeStamp="Nats-Time-Stamp",n.Subject="Nats-Subject"})(Vi||(Vi={}));var Vg;(function(n){n.Stream="Nats-Stream",n.Subject="Nats-Subject",n.Sequence="Nats-Sequence",n.LastSequence="Nats-Last-Sequence",n.Size="Nats-Msg-Size"})(Vg||(Vg={}));const _n="KV_";class hE{constructor(t){j(this,"config");j(this,"ordered");j(this,"mack");j(this,"stream");j(this,"callbackFn");j(this,"max");j(this,"qname");j(this,"isBind");j(this,"filters");this.stream="",this.mack=!1,this.ordered=!1,this.config=fE("",t||{})}getOpts(){var s;const t={};if(t.config=Object.assign({},this.config),t.config.filter_subject&&(this.filterSubject(t.config.filter_subject),t.config.filter_subject=void 0),t.config.filter_subjects&&((s=t.config.filter_subjects)==null||s.forEach(i=>{this.filterSubject(i)}),t.config.filter_subjects=void 0),t.mack=this.mack,t.stream=this.stream,t.callbackFn=this.callbackFn,t.max=this.max,t.queue=this.qname,t.ordered=this.ordered,t.config.ack_policy=t.ordered?qt.None:t.config.ack_policy,t.isBind=t.isBind||!1,this.filters)switch(this.filters.length){case 0:break;case 1:t.config.filter_subject=this.filters[0];break;default:t.config.filter_subjects=this.filters}return t}description(t){return this.config.description=t,this}deliverTo(t){return this.config.deliver_subject=t,this}durable(t){return Ki(t),this.config.durable_name=t,this}startSequence(t){if(t<=0)throw new Error("sequence must be greater than 0");return this.config.deliver_policy=Et.StartSequence,this.config.opt_start_seq=t,this}startTime(t){return this.config.deliver_policy=Et.StartTime,this.config.opt_start_time=t.toISOString(),this}deliverAll(){return this.config.deliver_policy=Et.All,this}deliverLastPerSubject(){return this.config.deliver_policy=Et.LastPerSubject,this}deliverLast(){return this.config.deliver_policy=Et.Last,this}deliverNew(){return this.config.deliver_policy=Et.New,this}startAtTimeDelta(t){return this.startTime(new Date(Date.now()-t)),this}headersOnly(){return this.config.headers_only=!0,this}ackNone(){return this.config.ack_policy=qt.None,this}ackAll(){return this.config.ack_policy=qt.All,this}ackExplicit(){return this.config.ack_policy=qt.Explicit,this}ackWait(t){return this.config.ack_wait=mt(t),this}maxDeliver(t){return this.config.max_deliver=t,this}filterSubject(t){return this.filters=this.filters||[],this.filters.push(t),this}replayInstantly(){return this.config.replay_policy=ta.Instant,this}replayOriginal(){return this.config.replay_policy=ta.Original,this}sample(t){if(t=Math.trunc(t),t<0||t>100)throw new Error("value must be between 0-100");return this.config.sample_freq=`${t}%`,this}limit(t){return this.config.rate_limit_bps=t,this}maxWaiting(t){return this.config.max_waiting=t,this}maxAckPending(t){return this.config.max_ack_pending=t,this}idleHeartbeat(t){return this.config.idle_heartbeat=mt(t),this}flowControl(){return this.config.flow_control=!0,this}deliverGroup(t){return this.queue(t),this}manualAck(){return this.mack=!0,this}maxMessages(t){return this.max=t,this}callback(t){return this.callbackFn=t,this}queue(t){return this.qname=t,this.config.deliver_group=t,this}orderedConsumer(){return this.ordered=!0,this}bind(t,s){return this.stream=t,this.config.durable_name=s,this.isBind=!0,this}bindStream(t){return this.stream=t,this}inactiveEphemeralThreshold(t){return this.config.inactive_threshold=mt(t),this}maxPullBatch(t){return this.config.max_batch=t,this}maxPullRequestExpires(t){return this.config.max_expires=mt(t),this}memory(){return this.config.mem_storage=!0,this}numReplicas(t){return this.config.num_replicas=t,this}consumerName(t){return this.config.name=t,this}}function _s(n){return new hE(n)}function Yg(n){return typeof n.getOpts=="function"}class dE{static encode(t){if(typeof t=="string")return btoa(t);const s=Array.from(t);return btoa(String.fromCharCode(...s))}static decode(t,s=!1){const i=atob(t);return s?Uint8Array.from(i,o=>o.charCodeAt(0)):i}}class Xi{static encode(t){return Xi.toB64URLEncoding(dE.encode(t))}static decode(t,s=!1){return Xi.decode(Xi.fromB64URLEncoding(t),s)}static toB64URLEncoding(t){return t.replace(/\+/g,"-").replace(/\//g,"_")}static fromB64URLEncoding(t){return t.replace(/_/g,"/").replace(/-/g,"+")}}class na{constructor(){j(this,"buffers");j(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...t){let s=0;for(let c=0;c<t.length;c++)s+=t[c].length;const i=new Uint8Array(s);let o=0;for(let c=0;c<t.length;c++)i.set(t[c],o),o+=t[c].length;return i}static fromAscii(t){return t||(t=""),ei.encode(t)}static toAscii(t){return Sn.decode(t)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){const t=new Uint8Array(this.byteLength);let s=0;for(let i=0;i<this.buffers.length;i++)t.set(this.buffers[i],s),s+=this.buffers[i].length;this.buffers.length=0,this.buffers.push(t)}}shift(){if(this.buffers.length){const t=this.buffers.shift();if(t)return this.byteLength-=t.length,t}return new Uint8Array(0)}drain(t){if(this.buffers.length){this.pack();const s=this.buffers.pop();if(s){const i=this.byteLength;(t===void 0||t>i)&&(t=i);const o=s.subarray(0,t);return i>t&&this.buffers.push(s.subarray(t)),this.byteLength=i-t,o}}return new Uint8Array(0)}fill(t,...s){t&&(this.buffers.push(t),this.byteLength+=t.length);for(let i=0;i<s.length;i++)s[i]&&s[i].length&&(this.buffers.push(s[i]),this.byteLength+=s[i].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}function mE(n,t){return t.forEach(function(s){s&&typeof s!="string"&&!Array.isArray(s)&&Object.keys(s).forEach(function(i){if(i!=="default"&&!(i in n)){var o=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return s[i]}})}})}),Object.freeze(n)}var pE=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},no=pE.performance||{};no.now||no.mozNow||no.msNow||no.oNow||no.webkitNow;var Kg={versions:{}},yE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gE(n){if(n.__esModule)return n;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(n).forEach(function(s){var i=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return n[s]}})}),t}var Xh,Ou={exports:{}},Jg={},Xg=gE(mE({__proto__:null,default:Jg},[Jg]));Xh=Ou,(function(){var n="input is invalid type",t=typeof window=="object",s=t?window:{};s.JS_SHA256_NO_WINDOW&&(t=!1);var i=!t&&typeof self=="object",o=!s.JS_SHA256_NO_NODE_JS&&Kg.versions&&Kg.versions.node;o?s=yE:i&&(s=self);var c=!s.JS_SHA256_NO_COMMON_JS&&Xh.exports,m=!s.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",y="0123456789abcdef".split(""),g=[-2147483648,8388608,32768,128],u=[24,16,8,0],d=[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],b=["hex","array","digest","arrayBuffer"],x=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(R){return Object.prototype.toString.call(R)==="[object Array]"}),!m||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(R){return typeof R=="object"&&R.buffer&&R.buffer.constructor===ArrayBuffer});var v=function(R,$){return function(ne){return new B($,!0).update(ne)[R]()}},w=function(R){var $=v("hex",R);o&&($=S($,R)),$.create=function(){return new B(R)},$.update=function(I){return $.create().update(I)};for(var ne=0;ne<b.length;++ne){var V=b[ne];$[V]=v(V,R)}return $},S=function(R,$){var ne,V=Xg,I=Xg.Buffer,D=$?"sha224":"sha256";return ne=I.from&&!s.JS_SHA256_NO_BUFFER_FROM?I.from:function(Q){return new I(Q)},function(Q){if(typeof Q=="string")return V.createHash(D).update(Q,"utf8").digest("hex");if(Q==null)throw new Error(n);return Q.constructor===ArrayBuffer&&(Q=new Uint8Array(Q)),Array.isArray(Q)||ArrayBuffer.isView(Q)||Q.constructor===I?V.createHash(D).update(ne(Q)).digest("hex"):R(Q)}},C=function(R,$){return function(ne,V){return new ie(ne,$,!0).update(V)[R]()}},q=function(R){var $=C("hex",R);$.create=function(I){return new ie(I,R)},$.update=function(I,D){return $.create(I).update(D)};for(var ne=0;ne<b.length;++ne){var V=b[ne];$[V]=C(V,R)}return $};function B(R,$){$?(x[0]=x[16]=x[1]=x[2]=x[3]=x[4]=x[5]=x[6]=x[7]=x[8]=x[9]=x[10]=x[11]=x[12]=x[13]=x[14]=x[15]=0,this.blocks=x):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],R?(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=R}function ie(R,$,ne){var V,I=typeof R;if(I==="string"){var D,Q=[],X=R.length,he=0;for(V=0;V<X;++V)(D=R.charCodeAt(V))<128?Q[he++]=D:D<2048?(Q[he++]=192|D>>>6,Q[he++]=128|63&D):D<55296||D>=57344?(Q[he++]=224|D>>>12,Q[he++]=128|D>>>6&63,Q[he++]=128|63&D):(D=65536+((1023&D)<<10|1023&R.charCodeAt(++V)),Q[he++]=240|D>>>18,Q[he++]=128|D>>>12&63,Q[he++]=128|D>>>6&63,Q[he++]=128|63&D);R=Q}else{if(I!=="object")throw new Error(n);if(R===null)throw new Error(n);if(m&&R.constructor===ArrayBuffer)R=new Uint8Array(R);else if(!(Array.isArray(R)||m&&ArrayBuffer.isView(R)))throw new Error(n)}R.length>64&&(R=new B($,!0).update(R).array());var Se=[],ke=[];for(V=0;V<64;++V){var H=R[V]||0;Se[V]=92^H,ke[V]=54^H}B.call(this,$,ne),this.update(ke),this.oKeyPad=Se,this.inner=!0,this.sharedMemory=ne}B.prototype.update=function(R){if(!this.finalized){var $,ne=typeof R;if(ne!=="string"){if(ne!=="object")throw new Error(n);if(R===null)throw new Error(n);if(m&&R.constructor===ArrayBuffer)R=new Uint8Array(R);else if(!(Array.isArray(R)||m&&ArrayBuffer.isView(R)))throw new Error(n);$=!0}for(var V,I,D=0,Q=R.length,X=this.blocks;D<Q;){if(this.hashed&&(this.hashed=!1,X[0]=this.block,this.block=X[16]=X[1]=X[2]=X[3]=X[4]=X[5]=X[6]=X[7]=X[8]=X[9]=X[10]=X[11]=X[12]=X[13]=X[14]=X[15]=0),$)for(I=this.start;D<Q&&I<64;++D)X[I>>>2]|=R[D]<<u[3&I++];else for(I=this.start;D<Q&&I<64;++D)(V=R.charCodeAt(D))<128?X[I>>>2]|=V<<u[3&I++]:V<2048?(X[I>>>2]|=(192|V>>>6)<<u[3&I++],X[I>>>2]|=(128|63&V)<<u[3&I++]):V<55296||V>=57344?(X[I>>>2]|=(224|V>>>12)<<u[3&I++],X[I>>>2]|=(128|V>>>6&63)<<u[3&I++],X[I>>>2]|=(128|63&V)<<u[3&I++]):(V=65536+((1023&V)<<10|1023&R.charCodeAt(++D)),X[I>>>2]|=(240|V>>>18)<<u[3&I++],X[I>>>2]|=(128|V>>>12&63)<<u[3&I++],X[I>>>2]|=(128|V>>>6&63)<<u[3&I++],X[I>>>2]|=(128|63&V)<<u[3&I++]);this.lastByteIndex=I,this.bytes+=I-this.start,I>=64?(this.block=X[16],this.start=I-64,this.hash(),this.hashed=!0):this.start=I}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var R=this.blocks,$=this.lastByteIndex;R[16]=this.block,R[$>>>2]|=g[3&$],this.block=R[16],$>=56&&(this.hashed||this.hash(),R[0]=this.block,R[16]=R[1]=R[2]=R[3]=R[4]=R[5]=R[6]=R[7]=R[8]=R[9]=R[10]=R[11]=R[12]=R[13]=R[14]=R[15]=0),R[14]=this.hBytes<<3|this.bytes>>>29,R[15]=this.bytes<<3,this.hash()}},B.prototype.hash=function(){var R,$,ne,V,I,D,Q,X,he,Se=this.h0,ke=this.h1,H=this.h2,W=this.h3,ce=this.h4,xe=this.h5,ve=this.h6,Ce=this.h7,Ne=this.blocks;for(R=16;R<64;++R)$=((I=Ne[R-15])>>>7|I<<25)^(I>>>18|I<<14)^I>>>3,ne=((I=Ne[R-2])>>>17|I<<15)^(I>>>19|I<<13)^I>>>10,Ne[R]=Ne[R-16]+$+Ne[R-7]+ne|0;for(he=ke&H,R=0;R<64;R+=4)this.first?(this.is224?(D=300032,Ce=(I=Ne[0]-1413257819)-150054599|0,W=I+24177077|0):(D=704751109,Ce=(I=Ne[0]-210244248)-1521486534|0,W=I+143694565|0),this.first=!1):($=(Se>>>2|Se<<30)^(Se>>>13|Se<<19)^(Se>>>22|Se<<10),V=(D=Se&ke)^Se&H^he,Ce=W+(I=Ce+(ne=(ce>>>6|ce<<26)^(ce>>>11|ce<<21)^(ce>>>25|ce<<7))+(ce&xe^~ce&ve)+d[R]+Ne[R])|0,W=I+($+V)|0),$=(W>>>2|W<<30)^(W>>>13|W<<19)^(W>>>22|W<<10),V=(Q=W&Se)^W&ke^D,ve=H+(I=ve+(ne=(Ce>>>6|Ce<<26)^(Ce>>>11|Ce<<21)^(Ce>>>25|Ce<<7))+(Ce&ce^~Ce&xe)+d[R+1]+Ne[R+1])|0,$=((H=I+($+V)|0)>>>2|H<<30)^(H>>>13|H<<19)^(H>>>22|H<<10),V=(X=H&W)^H&Se^Q,xe=ke+(I=xe+(ne=(ve>>>6|ve<<26)^(ve>>>11|ve<<21)^(ve>>>25|ve<<7))+(ve&Ce^~ve&ce)+d[R+2]+Ne[R+2])|0,$=((ke=I+($+V)|0)>>>2|ke<<30)^(ke>>>13|ke<<19)^(ke>>>22|ke<<10),V=(he=ke&H)^ke&W^X,ce=Se+(I=ce+(ne=(xe>>>6|xe<<26)^(xe>>>11|xe<<21)^(xe>>>25|xe<<7))+(xe&ve^~xe&Ce)+d[R+3]+Ne[R+3])|0,Se=I+($+V)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+Se|0,this.h1=this.h1+ke|0,this.h2=this.h2+H|0,this.h3=this.h3+W|0,this.h4=this.h4+ce|0,this.h5=this.h5+xe|0,this.h6=this.h6+ve|0,this.h7=this.h7+Ce|0},B.prototype.hex=function(){this.finalize();var R=this.h0,$=this.h1,ne=this.h2,V=this.h3,I=this.h4,D=this.h5,Q=this.h6,X=this.h7,he=y[R>>>28&15]+y[R>>>24&15]+y[R>>>20&15]+y[R>>>16&15]+y[R>>>12&15]+y[R>>>8&15]+y[R>>>4&15]+y[15&R]+y[$>>>28&15]+y[$>>>24&15]+y[$>>>20&15]+y[$>>>16&15]+y[$>>>12&15]+y[$>>>8&15]+y[$>>>4&15]+y[15&$]+y[ne>>>28&15]+y[ne>>>24&15]+y[ne>>>20&15]+y[ne>>>16&15]+y[ne>>>12&15]+y[ne>>>8&15]+y[ne>>>4&15]+y[15&ne]+y[V>>>28&15]+y[V>>>24&15]+y[V>>>20&15]+y[V>>>16&15]+y[V>>>12&15]+y[V>>>8&15]+y[V>>>4&15]+y[15&V]+y[I>>>28&15]+y[I>>>24&15]+y[I>>>20&15]+y[I>>>16&15]+y[I>>>12&15]+y[I>>>8&15]+y[I>>>4&15]+y[15&I]+y[D>>>28&15]+y[D>>>24&15]+y[D>>>20&15]+y[D>>>16&15]+y[D>>>12&15]+y[D>>>8&15]+y[D>>>4&15]+y[15&D]+y[Q>>>28&15]+y[Q>>>24&15]+y[Q>>>20&15]+y[Q>>>16&15]+y[Q>>>12&15]+y[Q>>>8&15]+y[Q>>>4&15]+y[15&Q];return this.is224||(he+=y[X>>>28&15]+y[X>>>24&15]+y[X>>>20&15]+y[X>>>16&15]+y[X>>>12&15]+y[X>>>8&15]+y[X>>>4&15]+y[15&X]),he},B.prototype.toString=B.prototype.hex,B.prototype.digest=function(){this.finalize();var R=this.h0,$=this.h1,ne=this.h2,V=this.h3,I=this.h4,D=this.h5,Q=this.h6,X=this.h7,he=[R>>>24&255,R>>>16&255,R>>>8&255,255&R,$>>>24&255,$>>>16&255,$>>>8&255,255&$,ne>>>24&255,ne>>>16&255,ne>>>8&255,255&ne,V>>>24&255,V>>>16&255,V>>>8&255,255&V,I>>>24&255,I>>>16&255,I>>>8&255,255&I,D>>>24&255,D>>>16&255,D>>>8&255,255&D,Q>>>24&255,Q>>>16&255,Q>>>8&255,255&Q];return this.is224||he.push(X>>>24&255,X>>>16&255,X>>>8&255,255&X),he},B.prototype.array=B.prototype.digest,B.prototype.arrayBuffer=function(){this.finalize();var R=new ArrayBuffer(this.is224?28:32),$=new DataView(R);return $.setUint32(0,this.h0),$.setUint32(4,this.h1),$.setUint32(8,this.h2),$.setUint32(12,this.h3),$.setUint32(16,this.h4),$.setUint32(20,this.h5),$.setUint32(24,this.h6),this.is224||$.setUint32(28,this.h7),R},ie.prototype=new B,ie.prototype.finalize=function(){if(B.prototype.finalize.call(this),this.inner){this.inner=!1;var R=this.array();B.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(R),B.prototype.finalize.call(this)}};var le=w();le.sha256=le,le.sha224=w(!0),le.sha256.hmac=q(),le.sha224.hmac=q(!0),c?Xh.exports=le:(s.sha256=le.sha256,s.sha224=le.sha224)})();Ou.exports;Ou.exports.sha224;var Qg=Ou.exports.sha256;function Sd(n){return SE(n)}function bE(n){if(!/^[0-9A-Fa-f]+$/.test(n))return!1;const s=/^[0-9A-F]+$/.test(n),i=/^[0-9a-f]+$/.test(n);return s||i?n.length%2===0:!1}function xE(n){return/^[A-Za-z0-9\-_]*(={0,2})?$/.test(n)||/^[A-Za-z0-9+/]*(={0,2})?$/.test(n)}function vE(n){return bE(n)?"hex":xE(n)?"b64":""}function _E(n){if(n.length%2!==0)throw new Error("hex string must have an even length");const t=new Uint8Array(n.length/2);for(let s=0;s<n.length;s+=2)t[s/2]=parseInt(n.substring(s,s+2),16);return t}function wE(n){n=n.replace(/-/g,"+"),n=n.replace(/_/g,"/");const t=atob(n);return Uint8Array.from(t,s=>s.charCodeAt(0))}function SE(n){switch(vE(n)){case"hex":return _E(n);case"b64":return wE(n)}return null}function EE(n,t){const s=typeof n=="string"?Sd(n):n,i=typeof t=="string"?Sd(t):t;if(s===null||i===null||s.length!==i.length)return!1;for(let o=0;o<s.length;o++)if(s[o]!==i[o])return!1;return!0}class mx{constructor(t,s,i=!0){j(this,"token");j(this,"received");j(this,"ctx");j(this,"requestSubject");j(this,"mux");this.mux=t,this.requestSubject=s,this.received=0,this.token=Es.next(),i&&(this.ctx=new Error)}}class OE extends mx{constructor(s,i,o={maxWait:1e3}){super(s,i);j(this,"callback");j(this,"done");j(this,"timer");j(this,"max");j(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=pt(),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,i){s?(this.ctx&&(s.stack+=`
33
33
 
34
- ${this.ctx.stack}`),this.cancel(s)):(this.callback(null,i),this.opts.strategy===Qn.Count&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===Qn.JitterTimer&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.jitter||300)),this.opts.strategy===Qn.SentinelMsg&&i&&i.data.length===0&&this.cancel())}}class yx extends px{constructor(s,i,o={timeout:1e3},c=!0){super(s,i,c);j(this,"deferred");j(this,"timer");this.deferred=pt(),this.timer=ea(o.timeout,c)}resolver(s,i){this.timer&&this.timer.cancel(),s?(this.ctx&&(s.stack+=`
34
+ ${this.ctx.stack}`),this.cancel(s)):(this.callback(null,i),this.opts.strategy===Qn.Count&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===Qn.JitterTimer&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.jitter||300)),this.opts.strategy===Qn.SentinelMsg&&i&&i.data.length===0&&this.cancel())}}class px extends mx{constructor(s,i,o={timeout:1e3},c=!0){super(s,i,c);j(this,"deferred");j(this,"timer");this.deferred=pt(),this.timer=ea(o.timeout,c)}resolver(s,i){this.timer&&this.timer.cancel(),s?(this.ctx&&(s.stack+=`
35
35
 
36
- ${this.ctx.stack}`),this.deferred.reject(s)):this.deferred.resolve(i),this.cancel()}cancel(s){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(s||ye.errorForCode(ue.Cancelled))}}const jE="$JS.API";function kE(n){return n=n||{},n.domain&&(n.apiPrefix=`$JS.${n.domain}.API`,delete n.domain),Su({apiPrefix:jE,timeout:5e3},n)}class To{constructor(t,s){j(this,"nc");j(this,"opts");j(this,"prefix");j(this,"timeout");j(this,"jc");this.nc=t,this.opts=kE(s),this._parseOpts(),this.prefix=this.opts.apiPrefix,this.timeout=this.opts.timeout,this.jc=Wn()}getOptions(){return Object.assign({},this.opts)}_parseOpts(){let t=this.opts.apiPrefix;if(!t||t.length===0)throw new Error("invalid empty prefix");t[t.length-1]==="."&&(t=t.substr(0,t.length-1)),this.opts.apiPrefix=t}async _request(t,s=null,i){i=i||{},i.timeout=this.timeout;let o=An;s&&(o=this.jc.encode(s));let{retries:c}=i;c=c||1,c=c===-1?Number.MAX_SAFE_INTEGER:c;const m=rm();for(let y=0;y<c;y++)try{const g=await this.nc.request(t,o,i);return this.parseJsResponse(g)}catch(g){const u=g;if((u.code==="503"||u.code===ue.Timeout)&&y+1<c)await sa(m.backoff(y));else throw g}}async findStream(t){const s={subject:t},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(t){const s=this.jc.decode(t.data),i=s;if(i.error){const o=mx(i.error.code,i.error.description);if(o!==null)throw o.api_error=i.error,o}return s}}class po{constructor(t,s,i,o){j(this,"err");j(this,"offset");j(this,"pageInfo");j(this,"subject");j(this,"jsm");j(this,"filter");j(this,"payload");if(!t)throw new Error("subject is required");this.subject=t,this.jsm=i,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 t={offset:this.offset};this.payload&&Object.assign(t,this.payload);try{const s=await this.jsm._request(this.subject,t,{timeout:this.jsm.timeout});this.pageInfo=s;const i=this.countResponse(s);return i===0?[]:(this.offset+=i,this.filter(s))}catch(s){throw this.err=s,s}}countResponse(t){var s,i,o;switch(t==null?void 0:t.type){case"io.nats.jetstream.api.v1.stream_names_response":case"io.nats.jetstream.api.v1.stream_list_response":return((s=t.streams)==null?void 0:s.length)||0;case"io.nats.jetstream.api.v1.consumer_list_response":return((i=t.consumers)==null?void 0:i.length)||0;default:return console.error(`jslister.ts: unknown API response for paged output: ${t==null?void 0:t.type}`),((o=t.streams)==null?void 0:o.length)||0}return 0}async*[Symbol.asyncIterator](){let t=await this.next();for(;t.length>0;){for(const s of t)yield s;t=await this.next()}}}function Zs(n=""){const t=n.match(/(\d+).(\d+).(\d+)/);if(t)return{major:parseInt(t[1]),minor:parseInt(t[2]),micro:parseInt(t[3])};throw new Error(`'${n}' is not a semver value`)}function Ed(n,t){return n.major<t.major?-1:n.major>t.major?1:n.minor<t.minor?-1:n.minor>t.minor?1:n.micro<t.micro?-1:n.micro>t.micro?1:0}var Ke;(function(n){n.JS_KV="js_kv",n.JS_OBJECTSTORE="js_objectstore",n.JS_PULL_MAX_BYTES="js_pull_max_bytes",n.JS_NEW_CONSUMER_CREATE_API="js_new_consumer_create",n.JS_ALLOW_DIRECT="js_allow_direct",n.JS_MULTIPLE_CONSUMER_FILTER="js_multiple_consumer_filter",n.JS_SIMPLIFICATION="js_simplification",n.JS_STREAM_CONSUMER_METADATA="js_stream_consumer_metadata",n.JS_CONSUMER_FILTER_SUBJECTS="js_consumer_filter_subjects",n.JS_STREAM_FIRST_SEQ="js_stream_first_seq",n.JS_STREAM_SUBJECT_TRANSFORM="js_stream_subject_transform",n.JS_STREAM_SOURCE_SUBJECT_TRANSFORM="js_stream_source_subject_transform",n.JS_STREAM_COMPRESSION="js_stream_compression",n.JS_DEFAULT_CONSUMER_LIMITS="js_default_consumer_limits",n.JS_BATCH_DIRECT_GET="js_batch_direct_get"})(Ke||(Ke={}));class NE{constructor(t){j(this,"server");j(this,"features");j(this,"disabled");this.features=new Map,this.disabled=[],this.update(t)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(t){this.disabled.push(t),this.update(this.server)}isDisabled(t){return this.disabled.indexOf(t)!==-1}update(t){typeof t=="string"&&(t=Zs(t)),this.server=t,this.set(Ke.JS_KV,"2.6.2"),this.set(Ke.JS_OBJECTSTORE,"2.6.3"),this.set(Ke.JS_PULL_MAX_BYTES,"2.8.3"),this.set(Ke.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(Ke.JS_ALLOW_DIRECT,"2.9.0"),this.set(Ke.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(Ke.JS_SIMPLIFICATION,"2.9.4"),this.set(Ke.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(Ke.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(Ke.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(Ke.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ke.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ke.JS_STREAM_COMPRESSION,"2.10.0"),this.set(Ke.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.set(Ke.JS_BATCH_DIRECT_GET,"2.11.0"),this.disabled.forEach(s=>{this.features.delete(s)})}set(t,s){this.features.set(t,{min:s,ok:Ed(this.server,Zs(s))>=0})}get(t){return this.features.get(t)||{min:"unknown",ok:!1}}supports(t){var s;return((s=this.get(t))==null?void 0:s.ok)||!1}require(t){return typeof t=="string"&&(t=Zs(t)),Ed(this.server,t)>=0}}class du extends To{constructor(t,s){super(t,s)}async add(t,s,i=hu.Create){if(Kt(t),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=t,o.action=i,o.config.durable_name&&Ki(o.config.durable_name);const c=this.nc;let{min:m,ok:y}=c.features.get(Ke.JS_NEW_CONSUMER_CREATE_API);const g=s.name===""?void 0:s.name;if(g&&!y)throw new Error(`consumer 'name' requires server ${m}`);if(g)try{Eu("name",g)}catch(x){const v=x.message,w=v.indexOf("cannot contain");throw w!==-1?new Error(`consumer 'name' ${v.substring(w)}`):x}let u,d="";if(Array.isArray(s.filter_subjects)){const{min:x,ok:v}=c.features.get(Ke.JS_MULTIPLE_CONSUMER_FILTER);if(!v)throw new Error(`consumer 'filter_subjects' requires server ${x}`);y=!1}if(s.metadata){const{min:x,ok:v}=c.features.get(Ke.JS_STREAM_CONSUMER_METADATA);if(!v)throw new Error(`consumer 'metadata' requires server ${x}`)}if(y&&(d=s.name??s.durable_name??""),d!==""){let x=s.filter_subject??void 0;x===">"&&(x=void 0),u=x!==void 0?`${this.prefix}.CONSUMER.CREATE.${t}.${d}.${x}`:`${this.prefix}.CONSUMER.CREATE.${t}.${d}`}else u=s.durable_name?`${this.prefix}.CONSUMER.DURABLE.CREATE.${t}.${s.durable_name}`:`${this.prefix}.CONSUMER.CREATE.${t}`;return await this._request(u,o)}async update(t,s,i){const o=await this.info(t,s),c=i;return this.add(t,Object.assign(o.config,c),hu.Update)}async info(t,s){return Kt(t),Ki(s),await this._request(`${this.prefix}.CONSUMER.INFO.${t}.${s}`)}async delete(t,s){return Kt(t),Ki(s),(await this._request(`${this.prefix}.CONSUMER.DELETE.${t}.${s}`)).success}list(t){Kt(t);const s=o=>o.consumers,i=`${this.prefix}.CONSUMER.LIST.${t}`;return new po(i,s,this)}pause(t,s,i){const o=`${this.prefix}.CONSUMER.PAUSE.${t}.${s}`,c={pause_until:i.toISOString()};return this._request(o,c)}resume(t,s){return this.pause(t,s,new Date(0))}}function zi(n,t,s=!1){if(s===!0&&!n)throw ye.errorForCode(ue.ApiError,new Error(`${t} is not a function`));if(n&&typeof n!="function")throw ye.errorForCode(ue.ApiError,new Error(`${t} is not a function`))}class TE extends Bt{constructor(s,i,o){super();j(this,"sub");j(this,"adapter");j(this,"subIterDone");zi(o.adapter,"adapter",!0),this.adapter=o.adapter,o.callback&&zi(o.callback,"callback"),this.noIterator=typeof o.callback=="function",o.ingestionFilterFn&&(zi(o.ingestionFilterFn,"ingestionFilterFn"),this.ingestionFilterFn=o.ingestionFilterFn),o.protocolFilterFn&&(zi(o.protocolFilterFn,"protocolFilterFn"),this.protocolFilterFn=o.protocolFilterFn),o.dispatchedFn&&(zi(o.dispatchedFn,"dispatchedFn"),this.dispatchedFn=o.dispatchedFn),o.cleanupFn&&zi(o.cleanupFn,"cleanupFn");let c=(d,b)=>{this.callback(d,b)};if(o.callback){const d=o.callback;c=(b,x)=>{const[v,w]=this.adapter(b,x);if(v){d(v,null);return}const{ingest:S}=this.ingestionFilterFn?this.ingestionFilterFn(w,this):{ingest:!0};S&&(!this.protocolFilterFn||this.protocolFilterFn(w))&&(d(v,w),this.dispatchedFn&&w&&this.dispatchedFn(w))}}const{max:m,queue:y,timeout:g}=o,u={queue:y,timeout:g,callback:c};m&&m>0&&(u.max=m),this.sub=s.subscribe(i,u),o.cleanupFn&&(this.sub.cleanupFn=o.cleanupFn),this.noIterator||this.iterClosed.then(()=>{this.unsubscribe()}),this.subIterDone=pt(),Promise.all([this.sub.closed,this.iterClosed]).then(()=>{this.subIterDone.resolve()}).catch(()=>{this.subIterDone.resolve()}),(async d=>{await d.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,i){this.sub.cancelTimeout();const[o,c]=this.adapter(s,i);o&&this.stop(o),c&&this.push(c)}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 En;function CE(n){En=n}function gx(){return En!==void 0&&En.defaultPort!==void 0?En.defaultPort:4222}function Qh(){return En!==void 0&&En.urlParseFn?En.urlParseFn:void 0}function ME(){if(!En||typeof En.factory!="function")throw new Error("transport fn is not set");return En.factory()}function Od(){return En!==void 0&&En.dnsResolveFn?En.dnsResolveFn:void 0}const nu=`\r
37
- `,mu=na.fromAscii(nu),RE=new Uint8Array(mu)[0],DE=new Uint8Array(mu)[1];function LE(n){for(let t=0;t<n.length;t++){const s=t+1;if(n.byteLength>s&&n[t]===RE&&n[s]===DE)return s+1}return 0}function qE(n){const t=LE(n);if(t>0){const i=new Uint8Array(n).slice(0,t);return Sn.decode(i)}return""}const BE=4,bx=48,PE=65,UE=97;function zE(n,t,s,i){const o=new Uint8Array(16);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((m,y)=>{o[y]=m}),o[12]=n,o[13]=t,o[14]=s,o[15]=i,o}function Ad(n){return IE(n)!==void 0}function IE(n){for(let t=0;t<n.length;t++)switch(n[t]){case".":return xx(n);case":":return $E(n)}}function xx(n){const t=new Uint8Array(4);for(let s=0;s<4;s++){if(n.length===0)return;if(s>0){if(n[0]!==".")return;n=n.substring(1)}const{n:i,c:o,ok:c}=HE(n);if(!c||i>255)return;n=n.substring(o),t[s]=i}return zE(t[0],t[1],t[2],t[3])}function $E(n){const t=new Uint8Array(16);let s=-1;if(n.length>=2&&n[0]===":"&&n[1]===":"&&(s=0,n=n.substring(2),n.length===0))return t;let i=0;for(;i<16;){const{n:o,c,ok:m}=FE(n);if(!m||o>65535)return;if(c<n.length&&n[c]==="."){if(s<0&&i!=12||i+4>16)return;const y=xx(n);if(y===void 0)return;t[i]=y[12],t[i+1]=y[13],t[i+2]=y[14],t[i+3]=y[15],n="",i+=BE;break}if(t[i]=o>>8,t[i+1]=o,i+=2,n=n.substring(c),n.length===0)break;if(n[0]!==":"||n.length==1)return;if(n=n.substring(1),n[0]===":"){if(s>=0)return;if(s=i,n=n.substring(1),n.length===0)break}}if(n.length===0){if(i<16){if(s<0)return;const o=16-i;for(let c=i-1;c>=s;c--)t[c+o]=t[c];for(let c=s+o-1;c>=s;c--)t[c]=0}else if(s>=0)return;return t}}function HE(n){let t=0,s=0;for(t=0;t<n.length&&48<=n.charCodeAt(t)&&n.charCodeAt(t)<=57;t++)if(s=s*10+(n.charCodeAt(t)-bx),s>=16777215)return{n:16777215,c:t,ok:!1};return t===0?{n:0,c:0,ok:!1}:{n:s,c:t,ok:!0}}function FE(n){let t=0,s=0;for(s=0;s<n.length;s++){if(48<=n.charCodeAt(s)&&n.charCodeAt(s)<=57)t*=16,t+=n.charCodeAt(s)-bx;else if(97<=n.charCodeAt(s)&&n.charCodeAt(s)<=102)t*=16,t+=n.charCodeAt(s)-UE+10;else if(65<=n.charCodeAt(s)&&n.charCodeAt(s)<=70)t*=16,t+=n.charCodeAt(s)-PE+10;else break;if(t>=16777215)return{n:0,c:s,ok:!1}}return s===0?{n:0,c:s,ok:!1}:{n:t,c:s,ok:!0}}function GE(n){return n.indexOf("[")!==-1||n.indexOf("::")!==-1?!1:n.indexOf(".")!==-1||n.split(":").length<=2}function jd(n){return!GE(n)}function VE(n){const t="::FFFF:",s=n.toUpperCase().indexOf(t);if(s!==-1&&n.indexOf(".")!==-1){let i=n.substring(s+t.length);return i=i.replace("[",""),i.replace("]","")}return n}function YE(n){n=n.trim(),n.match(/^(.*:\/\/)(.*)/m)&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2")),n=VE(n),jd(n)&&n.indexOf("[")===-1&&(n=`[${n}]`);const t=jd(n)?n.match(/(]:)(\d+)/):n.match(/(:)(\d+)/),s=t&&t.length===3&&t[1]&&t[2]?parseInt(t[2]):4222,i=s===80?"https":"http",o=new URL(`${i}://${n}`);o.port=`${s}`;let c=o.hostname;return c.charAt(0)==="["&&(c=c.substring(1,c.length-1)),{listen:o.host,hostname:c,port:s}}class xo{constructor(t,s=!1){j(this,"src");j(this,"listen");j(this,"hostname");j(this,"port");j(this,"didConnect");j(this,"reconnects");j(this,"lastConnect");j(this,"gossiped");j(this,"tlsName");j(this,"resolves");this.src=t,this.tlsName="";const i=YE(t);this.listen=i.listen,this.hostname=i.hostname,this.port=i.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=s}toString(){return this.listen}async resolve(t){if(!t.fn||t.resolve===!1)return[this];const s=[];if(Ad(this.hostname))return[this];{const i=await t.fn(this.hostname);t.debug&&console.log(`resolve ${this.hostname} = ${i.join(",")}`);for(const o of i){const c=this.port===80?"https":"http",m=new URL(`${c}://${jd(o)?"["+o+"]":o}`);m.port=`${this.port}`;const y=new xo(m.host,!1);y.tlsName=this.hostname,s.push(y)}}return t.randomize&&hx(s),this.resolves=s,s}}class KE{constructor(t=[],s={}){j(this,"firstSelect");j(this,"servers");j(this,"currentServer");j(this,"tlsName");j(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=s.randomize||!1;const i=Qh();t&&(t.forEach(o=>{o=i?i(o):o,this.servers.push(new xo(o))}),this.randomize&&(this.servers=hx(this.servers))),this.servers.length===0&&this.addServer(`${gd}:${gx()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const t=this.getCurrentServer();Ad(t.hostname)||(this.tlsName=t.hostname,this.servers.forEach(s=>{s.gossiped&&(s.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(t,s=!1){const i=Qh();t=i?i(t):t;const o=new xo(t,s);Ad(o.hostname)&&(o.tlsName=this.tlsName),this.servers.push(o)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;const t=this.servers.shift();return t&&(this.servers.push(t),this.currentServer=t),t}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer(t){if(t){const s=this.servers.indexOf(t);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(t,s){const i=[];let o=[];const c=Qh(),m=new Map;t.connect_urls&&t.connect_urls.length>0&&t.connect_urls.forEach(g=>{g=c?c(g,s):g;const u=new xo(g,!0);m.set(g,u)});const y=[];return this.servers.forEach((g,u)=>{const d=g.listen;g.gossiped&&this.currentServer.listen!==d&&m.get(d)===void 0&&y.push(u),m.delete(d)}),y.reverse(),y.forEach(g=>{const u=this.servers.splice(g,1);o=o.concat(u[0].listen)}),m.forEach((g,u)=>{this.servers.push(g),i.push(u)}),{added:i,deleted:o}}}class JE{constructor(){j(this,"baseInbox");j(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(t){return this.baseInbox=`${Rr(t)}.`,this.baseInbox}add(t){isNaN(t.received)||(t.received=0),this.reqs.set(t.token,t)}get(t){return this.reqs.get(t)}cancel(t){this.reqs.delete(t.token)}getToken(t){const s=t.subject||"";return s.indexOf(this.baseInbox)===0?s.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(t,s){if(s&&s.permissionContext){if(t)return this.all().forEach(o=>{o.resolver(s,{})}),!0;const i=s.permissionContext;if(i.operation==="publish"){const o=this.all().find(c=>c.requestSubject===i.subject);if(o)return o.resolver(s,{}),!0}}return!1}dispatcher(){return(t,s)=>{const i=this.getToken(s);if(i){const o=this.get(i);o&&(t===null&&s.headers&&(t=dx(s)),o.resolver(t,s))}}}close(){const t=ye.errorForCode(ue.Timeout);this.reqs.forEach(s=>{s.resolver(t,{})})}}class XE{constructor(t,s,i){j(this,"ph");j(this,"interval");j(this,"maxOut");j(this,"timer");j(this,"pendings");this.ph=t,this.interval=s,this.maxOut=i,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(t){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),t&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:Yi.PingTimer,data:`${this.pendings.length+1}`}),this.pendings.length===this.maxOut){this.cancel(!0);return}const t=pt();this.ph.flush(t).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push(t),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(t=>(t.resolve(),!1))}}class QE extends Error{constructor(t){super(t),this.name="AssertionError"}}function WE(n,t="Assertion failed."){if(!n)throw new QE(t)}const Wg=32*1024,Wh=2**32-2;function ic(n,t,s=0){const i=t.byteLength-s;return n.byteLength>i&&(n=n.subarray(0,i)),t.set(n,s),n.byteLength}class Zh{constructor(t){j(this,"_buf");j(this,"_off");if(this._off=0,t==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array(t)}bytes(t={copy:!0}){return t.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(t){if(t===0){this.reset();return}if(t<0||t>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+t)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(t){const s=this._buf.byteLength;return t<=this.capacity-s?(this._reslice(s+t),s):-1}_reslice(t){WE(t<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,t)}readByte(){const t=new Uint8Array(1);return this.read(t)?t[0]:null}read(t){if(this.empty())return this.reset(),t.byteLength===0?0:null;const s=ic(this._buf.subarray(this._off),t);return this._off+=s,s}writeByte(t){return this.write(Uint8Array.of(t))}writeString(t){return this.write(ei.encode(t))}write(t){const s=this._grow(t.byteLength);return ic(t,this._buf,s)}_grow(t){const s=this.length;s===0&&this._off!==0&&this.reset();const i=this._tryGrowByReslice(t);if(i>=0)return i;const o=this.capacity;if(t<=Math.floor(o/2)-s)ic(this._buf.subarray(this._off),this._buf);else{if(o+t>Wh)throw new Error("The buffer cannot be grown beyond the maximum size.");{const c=new Uint8Array(Math.min(2*o+t,Wh));ic(this._buf.subarray(this._off),c),this._buf=c}}return this._off=0,this._reslice(Math.min(s+t,Wh)),s}grow(t){if(t<0)throw Error("Buffer._grow: negative count");const s=this._grow(t);this._reslice(s)}readFrom(t){let s=0;const i=new Uint8Array(Wg);for(;;){const o=this.capacity-this.length<Wg,c=o?i:new Uint8Array(this._buf.buffer,this.length),m=t.read(c);if(m===null)return s;o?this.write(c.subarray(0,m)):this._reslice(this.length+m),s+=m}}}var Jt;(function(n){n[n.OK=0]="OK",n[n.ERR=1]="ERR",n[n.MSG=2]="MSG",n[n.INFO=3]="INFO",n[n.PING=4]="PING",n[n.PONG=5]="PONG"})(Jt||(Jt={}));function Zg(){const n={};return n.sid=-1,n.hdr=-1,n.size=-1,n}const ZE=48;class e1{constructor(t){j(this,"dispatcher");j(this,"state");j(this,"as");j(this,"drop");j(this,"hdr");j(this,"ma");j(this,"argBuf");j(this,"msgBuf");this.dispatcher=t,this.state=de.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(t){let s;for(s=0;s<t.length;s++){const i=t[s];switch(this.state){case de.OP_START:switch(i){case me.M:case me.m:this.state=de.OP_M,this.hdr=-1,this.ma=Zg();break;case me.H:case me.h:this.state=de.OP_H,this.hdr=0,this.ma=Zg();break;case me.P:case me.p:this.state=de.OP_P;break;case me.PLUS:this.state=de.OP_PLUS;break;case me.MINUS:this.state=de.OP_MINUS;break;case me.I:case me.i:this.state=de.OP_I;break;default:throw this.fail(t.subarray(s))}break;case de.OP_H:switch(i){case me.M:case me.m:this.state=de.OP_M;break;default:throw this.fail(t.subarray(s))}break;case de.OP_M:switch(i){case me.S:case me.s:this.state=de.OP_MS;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MS:switch(i){case me.G:case me.g:this.state=de.OP_MSG;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MSG:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_MSG_SPC;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MSG_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.MSG_ARG,this.as=s}break;case de.MSG_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{const o=this.argBuf?this.argBuf.bytes():t.subarray(this.as,s-this.drop);this.processMsgArgs(o),this.drop=0,this.as=s+1,this.state=de.MSG_PAYLOAD,s=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(i)}break;case de.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const o=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Jt.MSG,msg:this.ma,data:o}),this.argBuf=void 0,this.msgBuf=void 0,this.state=de.MSG_END}else{let o=this.ma.size-this.msgBuf.length;const c=t.length-s;c<o&&(o=c),o>0?(this.msgBuf.write(t.subarray(s,s+o)),s=s+o-1):this.msgBuf.writeByte(i)}else s-this.as>=this.ma.size&&(this.dispatcher.push({kind:Jt.MSG,msg:this.ma,data:t.subarray(this.as,s)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=de.MSG_END);break;case de.MSG_END:switch(i){case me.NL:this.drop=0,this.as=s+1,this.state=de.OP_START;break;default:continue}break;case de.OP_PLUS:switch(i){case me.O:case me.o:this.state=de.OP_PLUS_O;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PLUS_O:switch(i){case me.K:case me.k:this.state=de.OP_PLUS_OK;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PLUS_OK:switch(i){case me.NL:this.dispatcher.push({kind:Jt.OK}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_MINUS:switch(i){case me.E:case me.e:this.state=de.OP_MINUS_E;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_E:switch(i){case me.R:case me.r:this.state=de.OP_MINUS_ER;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_ER:switch(i){case me.R:case me.r:this.state=de.OP_MINUS_ERR;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_ERR:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_MINUS_ERR_SPC;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_ERR_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.MINUS_ERR_ARG,this.as=s}break;case de.MINUS_ERR_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=t.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Jt.ERR,data:o}),this.drop=0,this.as=s+1,this.state=de.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(i))}break;case de.OP_P:switch(i){case me.I:case me.i:this.state=de.OP_PI;break;case me.O:case me.o:this.state=de.OP_PO;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PO:switch(i){case me.N:case me.n:this.state=de.OP_PON;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PON:switch(i){case me.G:case me.g:this.state=de.OP_PONG;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PONG:switch(i){case me.NL:this.dispatcher.push({kind:Jt.PONG}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_PI:switch(i){case me.N:case me.n:this.state=de.OP_PIN;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PIN:switch(i){case me.G:case me.g:this.state=de.OP_PING;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PING:switch(i){case me.NL:this.dispatcher.push({kind:Jt.PING}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_I:switch(i){case me.N:case me.n:this.state=de.OP_IN;break;default:throw this.fail(t.subarray(s))}break;case de.OP_IN:switch(i){case me.F:case me.f:this.state=de.OP_INF;break;default:throw this.fail(t.subarray(s))}break;case de.OP_INF:switch(i){case me.O:case me.o:this.state=de.OP_INFO;break;default:throw this.fail(t.subarray(s))}break;case de.OP_INFO:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_INFO_SPC;break;default:throw this.fail(t.subarray(s))}break;case de.OP_INFO_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.INFO_ARG,this.as=s}break;case de.INFO_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=t.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Jt.INFO,data:o}),this.drop=0,this.as=s+1,this.state=de.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(i)}break;default:throw this.fail(t.subarray(s))}}(this.state===de.MSG_ARG||this.state===de.MINUS_ERR_ARG||this.state===de.INFO_ARG)&&!this.argBuf&&(this.argBuf=new Zh(t.subarray(this.as,s-this.drop))),this.state===de.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new Zh(t.subarray(this.as)))}cloneMsgArg(){const t=this.ma.subject.length,s=this.ma.reply?this.ma.reply.length:0,i=new Uint8Array(t+s);i.set(this.ma.subject),this.ma.reply&&i.set(this.ma.reply,t),this.argBuf=new Zh(i),this.ma.subject=i.subarray(0,t),this.ma.reply&&(this.ma.reply=i.subarray(t))}processMsgArgs(t){if(this.hdr>=0)return this.processHeaderMsgArgs(t);const s=[];let i=-1;for(let o=0;o<t.length;o++)switch(t[o]){case me.SPACE:case me.TAB:case me.CR:case me.NL:i>=0&&(s.push(t.subarray(i,o)),i=-1);break;default:i<0&&(i=o)}switch(i>=0&&s.push(t.subarray(i)),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(t,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(t,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(t,"processMsgArgs Bad or Missing Size Error")}fail(t,s=""){return s?s=`${s} [${this.state}]`:s=`parse error [${this.state}]`,new Error(`${s}: ${Sn.decode(t)}`)}processHeaderMsgArgs(t){const s=[];let i=-1;for(let o=0;o<t.length;o++)switch(t[o]){case me.SPACE:case me.TAB:case me.CR:case me.NL:i>=0&&(s.push(t.subarray(i,o)),i=-1);break;default:i<0&&(i=o)}switch(i>=0&&s.push(t.subarray(i)),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(t,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(t,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(t,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(t,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(t){if(t.length===0)return-1;let s=0;for(let i=0;i<t.length;i++){if(t[i]<48||t[i]>57)return-1;s=s*10+(t[i]-ZE)}return s}}var de;(function(n){n[n.OP_START=0]="OP_START",n[n.OP_PLUS=1]="OP_PLUS",n[n.OP_PLUS_O=2]="OP_PLUS_O",n[n.OP_PLUS_OK=3]="OP_PLUS_OK",n[n.OP_MINUS=4]="OP_MINUS",n[n.OP_MINUS_E=5]="OP_MINUS_E",n[n.OP_MINUS_ER=6]="OP_MINUS_ER",n[n.OP_MINUS_ERR=7]="OP_MINUS_ERR",n[n.OP_MINUS_ERR_SPC=8]="OP_MINUS_ERR_SPC",n[n.MINUS_ERR_ARG=9]="MINUS_ERR_ARG",n[n.OP_M=10]="OP_M",n[n.OP_MS=11]="OP_MS",n[n.OP_MSG=12]="OP_MSG",n[n.OP_MSG_SPC=13]="OP_MSG_SPC",n[n.MSG_ARG=14]="MSG_ARG",n[n.MSG_PAYLOAD=15]="MSG_PAYLOAD",n[n.MSG_END=16]="MSG_END",n[n.OP_H=17]="OP_H",n[n.OP_P=18]="OP_P",n[n.OP_PI=19]="OP_PI",n[n.OP_PIN=20]="OP_PIN",n[n.OP_PING=21]="OP_PING",n[n.OP_PO=22]="OP_PO",n[n.OP_PON=23]="OP_PON",n[n.OP_PONG=24]="OP_PONG",n[n.OP_I=25]="OP_I",n[n.OP_IN=26]="OP_IN",n[n.OP_INF=27]="OP_INF",n[n.OP_INFO=28]="OP_INFO",n[n.OP_INFO_SPC=29]="OP_INFO_SPC",n[n.INFO_ARG=30]="INFO_ARG"})(de||(de={}));var me;(function(n){n[n.CR=13]="CR",n[n.E=69]="E",n[n.e=101]="e",n[n.F=70]="F",n[n.f=102]="f",n[n.G=71]="G",n[n.g=103]="g",n[n.H=72]="H",n[n.h=104]="h",n[n.I=73]="I",n[n.i=105]="i",n[n.K=75]="K",n[n.k=107]="k",n[n.M=77]="M",n[n.m=109]="m",n[n.MINUS=45]="MINUS",n[n.N=78]="N",n[n.n=110]="n",n[n.NL=10]="NL",n[n.O=79]="O",n[n.o=111]="o",n[n.P=80]="P",n[n.p=112]="p",n[n.PLUS=43]="PLUS",n[n.R=82]="R",n[n.r=114]="r",n[n.S=83]="S",n[n.s=115]="s",n[n.SPACE=32]="SPACE",n[n.TAB=9]="TAB"})(me||(me={}));(function(n){var t=function(A,N){this.hi=A|0,this.lo=N|0},s=function(A){var N,k=new Float64Array(16);if(A)for(N=0;N<A.length;N++)k[N]=A[N];return k},i=function(){throw new Error("no PRNG")},o=new Uint8Array(16),c=new Uint8Array(32);c[0]=9;var m=s(),y=s([1]),g=s([56129,1]),u=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),b=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),x=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),v=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function w(A,N){return A<<N|A>>>32-N}function S(A,N){var k=A[N+3]&255;return k=k<<8|A[N+2]&255,k=k<<8|A[N+1]&255,k<<8|A[N+0]&255}function C(A,N){var k=A[N]<<24|A[N+1]<<16|A[N+2]<<8|A[N+3],T=A[N+4]<<24|A[N+5]<<16|A[N+6]<<8|A[N+7];return new t(k,T)}function q(A,N,k){var T;for(T=0;T<4;T++)A[N+T]=k&255,k>>>=8}function B(A,N,k){A[N]=k.hi>>24&255,A[N+1]=k.hi>>16&255,A[N+2]=k.hi>>8&255,A[N+3]=k.hi&255,A[N+4]=k.lo>>24&255,A[N+5]=k.lo>>16&255,A[N+6]=k.lo>>8&255,A[N+7]=k.lo&255}function ie(A,N,k,T,L){var z,re=0;for(z=0;z<L;z++)re|=A[N+z]^k[T+z];return(1&re-1>>>8)-1}function le(A,N,k,T){return ie(A,N,k,T,16)}function R(A,N,k,T){return ie(A,N,k,T,32)}function $(A,N,k,T,L){var z=new Uint32Array(16),re=new Uint32Array(16),ae=new Uint32Array(16),K=new Uint32Array(4),te,ge,qe;for(te=0;te<4;te++)re[5*te]=S(T,4*te),re[1+te]=S(k,4*te),re[6+te]=S(N,4*te),re[11+te]=S(k,16+4*te);for(te=0;te<16;te++)ae[te]=re[te];for(te=0;te<20;te++){for(ge=0;ge<4;ge++){for(qe=0;qe<4;qe++)K[qe]=re[(5*ge+4*qe)%16];for(K[1]^=w(K[0]+K[3]|0,7),K[2]^=w(K[1]+K[0]|0,9),K[3]^=w(K[2]+K[1]|0,13),K[0]^=w(K[3]+K[2]|0,18),qe=0;qe<4;qe++)z[4*ge+(ge+qe)%4]=K[qe]}for(qe=0;qe<16;qe++)re[qe]=z[qe]}if(L){for(te=0;te<16;te++)re[te]=re[te]+ae[te]|0;for(te=0;te<4;te++)re[5*te]=re[5*te]-S(T,4*te)|0,re[6+te]=re[6+te]-S(N,4*te)|0;for(te=0;te<4;te++)q(A,4*te,re[5*te]),q(A,16+4*te,re[6+te])}else for(te=0;te<16;te++)q(A,4*te,re[te]+ae[te]|0)}function ne(A,N,k,T){return $(A,N,k,T,!1),0}function V(A,N,k,T){return $(A,N,k,T,!0),0}var I=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function D(A,N,k,T,L,z,re){var ae=new Uint8Array(16),K=new Uint8Array(64),te,ge;if(!L)return 0;for(ge=0;ge<16;ge++)ae[ge]=0;for(ge=0;ge<8;ge++)ae[ge]=z[ge];for(;L>=64;){for(ne(K,ae,re,I),ge=0;ge<64;ge++)A[N+ge]=(k?k[T+ge]:0)^K[ge];for(te=1,ge=8;ge<16;ge++)te=te+(ae[ge]&255)|0,ae[ge]=te&255,te>>>=8;L-=64,N+=64,k&&(T+=64)}if(L>0)for(ne(K,ae,re,I),ge=0;ge<L;ge++)A[N+ge]=(k?k[T+ge]:0)^K[ge];return 0}function Q(A,N,k,T,L){return D(A,N,null,0,k,T,L)}function X(A,N,k,T,L){var z=new Uint8Array(32);return V(z,T,L,I),Q(A,N,k,T.subarray(16),z)}function he(A,N,k,T,L,z,re){var ae=new Uint8Array(32);return V(ae,z,re,I),D(A,N,k,T,L,z.subarray(16),ae)}function Se(A,N){var k,T=0;for(k=0;k<17;k++)T=T+(A[k]+N[k]|0)|0,A[k]=T&255,T>>>=8}var ke=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function H(A,N,k,T,L,z){var re,ae,K,te,ge=new Uint32Array(17),qe=new Uint32Array(17),lt=new Uint32Array(17),Gt=new Uint32Array(17),Fn=new Uint32Array(17);for(K=0;K<17;K++)qe[K]=lt[K]=0;for(K=0;K<16;K++)qe[K]=z[K];for(qe[3]&=15,qe[4]&=252,qe[7]&=15,qe[8]&=252,qe[11]&=15,qe[12]&=252,qe[15]&=15;L>0;){for(K=0;K<17;K++)Gt[K]=0;for(K=0;K<16&&K<L;++K)Gt[K]=k[T+K];for(Gt[K]=1,T+=K,L-=K,Se(lt,Gt),ae=0;ae<17;ae++)for(ge[ae]=0,K=0;K<17;K++)ge[ae]=ge[ae]+lt[K]*(K<=ae?qe[ae-K]:320*qe[ae+17-K]|0)|0|0;for(ae=0;ae<17;ae++)lt[ae]=ge[ae];for(te=0,K=0;K<16;K++)te=te+lt[K]|0,lt[K]=te&255,te>>>=8;for(te=te+lt[16]|0,lt[16]=te&3,te=5*(te>>>2)|0,K=0;K<16;K++)te=te+lt[K]|0,lt[K]=te&255,te>>>=8;te=te+lt[16]|0,lt[16]=te}for(K=0;K<17;K++)Fn[K]=lt[K];for(Se(lt,ke),re=-(lt[16]>>>7)|0,K=0;K<17;K++)lt[K]^=re&(Fn[K]^lt[K]);for(K=0;K<16;K++)Gt[K]=z[K+16];for(Gt[16]=0,Se(lt,Gt),K=0;K<16;K++)A[N+K]=lt[K];return 0}function W(A,N,k,T,L,z){var re=new Uint8Array(16);return H(re,0,k,T,L,z),le(A,N,re,0)}function ce(A,N,k,T,L){var z;if(k<32)return-1;for(he(A,0,N,0,k,T,L),H(A,16,A,32,k-32,A),z=0;z<16;z++)A[z]=0;return 0}function xe(A,N,k,T,L){var z,re=new Uint8Array(32);if(k<32||(X(re,0,32,T,L),W(N,16,N,32,k-32,re)!==0))return-1;for(he(A,0,N,0,k,T,L),z=0;z<32;z++)A[z]=0;return 0}function ve(A,N){var k;for(k=0;k<16;k++)A[k]=N[k]|0}function Ce(A){var N,k;for(k=0;k<16;k++)A[k]+=65536,N=Math.floor(A[k]/65536),A[(k+1)*(k<15?1:0)]+=N-1+37*(N-1)*(k===15?1:0),A[k]-=N*65536}function Ne(A,N,k){for(var T,L=~(k-1),z=0;z<16;z++)T=L&(A[z]^N[z]),A[z]^=T,N[z]^=T}function Me(A,N){var k,T,L,z=s(),re=s();for(k=0;k<16;k++)re[k]=N[k];for(Ce(re),Ce(re),Ce(re),T=0;T<2;T++){for(z[0]=re[0]-65517,k=1;k<15;k++)z[k]=re[k]-65535-(z[k-1]>>16&1),z[k-1]&=65535;z[15]=re[15]-32767-(z[14]>>16&1),L=z[15]>>16&1,z[14]&=65535,Ne(re,z,1-L)}for(k=0;k<16;k++)A[2*k]=re[k]&255,A[2*k+1]=re[k]>>8}function Ze(A,N){var k=new Uint8Array(32),T=new Uint8Array(32);return Me(k,A),Me(T,N),R(k,0,T,0)}function yt(A){var N=new Uint8Array(32);return Me(N,A),N[0]&1}function Ct(A,N){var k;for(k=0;k<16;k++)A[k]=N[2*k]+(N[2*k+1]<<8);A[15]&=32767}function we(A,N,k){var T;for(T=0;T<16;T++)A[T]=N[T]+k[T]|0}function Re(A,N,k){var T;for(T=0;T<16;T++)A[T]=N[T]-k[T]|0}function oe(A,N,k){var T,L,z=new Float64Array(31);for(T=0;T<31;T++)z[T]=0;for(T=0;T<16;T++)for(L=0;L<16;L++)z[T+L]+=N[T]*k[L];for(T=0;T<15;T++)z[T]+=38*z[T+16];for(T=0;T<16;T++)A[T]=z[T];Ce(A),Ce(A)}function Be(A,N){oe(A,N,N)}function We(A,N){var k=s(),T;for(T=0;T<16;T++)k[T]=N[T];for(T=253;T>=0;T--)Be(k,k),T!==2&&T!==4&&oe(k,k,N);for(T=0;T<16;T++)A[T]=k[T]}function ln(A,N){var k=s(),T;for(T=0;T<16;T++)k[T]=N[T];for(T=250;T>=0;T--)Be(k,k),T!==1&&oe(k,k,N);for(T=0;T<16;T++)A[T]=k[T]}function pe(A,N,k){var T=new Uint8Array(32),L=new Float64Array(80),z,re,ae=s(),K=s(),te=s(),ge=s(),qe=s(),lt=s();for(re=0;re<31;re++)T[re]=N[re];for(T[31]=N[31]&127|64,T[0]&=248,Ct(L,k),re=0;re<16;re++)K[re]=L[re],ge[re]=ae[re]=te[re]=0;for(ae[0]=ge[0]=1,re=254;re>=0;--re)z=T[re>>>3]>>>(re&7)&1,Ne(ae,K,z),Ne(te,ge,z),we(qe,ae,te),Re(ae,ae,te),we(te,K,ge),Re(K,K,ge),Be(ge,qe),Be(lt,ae),oe(ae,te,ae),oe(te,K,qe),we(qe,ae,te),Re(ae,ae,te),Be(K,ae),Re(te,ge,lt),oe(ae,te,g),we(ae,ae,ge),oe(te,te,ae),oe(ae,ge,lt),oe(ge,K,L),Be(K,qe),Ne(ae,K,z),Ne(te,ge,z);for(re=0;re<16;re++)L[re+16]=ae[re],L[re+32]=te[re],L[re+48]=K[re],L[re+64]=ge[re];var Gt=L.subarray(32),Fn=L.subarray(16);return We(Gt,Gt),oe(Fn,Fn,Gt),Me(A,Fn),0}function Ye(A,N){return pe(A,N,c)}function Ot(A,N){return i(N,32),Ye(A,N)}function ft(A,N,k){var T=new Uint8Array(32);return pe(T,k,N),V(A,o,T,I)}var Pr=ce,Bo=xe;function oa(A,N,k,T,L,z){var re=new Uint8Array(32);return ft(re,L,z),Pr(A,N,k,T,re)}function la(A,N,k,T,L,z){var re=new Uint8Array(32);return ft(re,L,z),Bo(A,N,k,T,re)}function cr(){var A=0,N=0,k=0,T=0,L=65535,z,re,ae;for(ae=0;ae<arguments.length;ae++)z=arguments[ae].lo,re=arguments[ae].hi,A+=z&L,N+=z>>>16,k+=re&L,T+=re>>>16;return N+=A>>>16,k+=N>>>16,T+=k>>>16,new t(k&L|T<<16,A&L|N<<16)}function Po(A,N){return new t(A.hi>>>N,A.lo>>>N|A.hi<<32-N)}function ni(){var A=0,N=0,k;for(k=0;k<arguments.length;k++)A^=arguments[k].lo,N^=arguments[k].hi;return new t(N,A)}function ht(A,N){var k,T,L=32-N;return N<32?(k=A.hi>>>N|A.lo<<L,T=A.lo>>>N|A.hi<<L):N<64&&(k=A.lo>>>N|A.hi<<L,T=A.hi>>>N|A.lo<<L),new t(k,T)}function Du(A,N,k){var T=A.hi&N.hi^~A.hi&k.hi,L=A.lo&N.lo^~A.lo&k.lo;return new t(T,L)}function Uo(A,N,k){var T=A.hi&N.hi^A.hi&k.hi^N.hi&k.hi,L=A.lo&N.lo^A.lo&k.lo^N.lo&k.lo;return new t(T,L)}function zo(A){return ni(ht(A,28),ht(A,34),ht(A,39))}function ri(A){return ni(ht(A,14),ht(A,18),ht(A,41))}function Lu(A){return ni(ht(A,1),ht(A,8),Po(A,7))}function Io(A){return ni(ht(A,19),ht(A,61),Po(A,6))}var qu=[new t(1116352408,3609767458),new t(1899447441,602891725),new t(3049323471,3964484399),new t(3921009573,2173295548),new t(961987163,4081628472),new t(1508970993,3053834265),new t(2453635748,2937671579),new t(2870763221,3664609560),new t(3624381080,2734883394),new t(310598401,1164996542),new t(607225278,1323610764),new t(1426881987,3590304994),new t(1925078388,4068182383),new t(2162078206,991336113),new t(2614888103,633803317),new t(3248222580,3479774868),new t(3835390401,2666613458),new t(4022224774,944711139),new t(264347078,2341262773),new t(604807628,2007800933),new t(770255983,1495990901),new t(1249150122,1856431235),new t(1555081692,3175218132),new t(1996064986,2198950837),new t(2554220882,3999719339),new t(2821834349,766784016),new t(2952996808,2566594879),new t(3210313671,3203337956),new t(3336571891,1034457026),new t(3584528711,2466948901),new t(113926993,3758326383),new t(338241895,168717936),new t(666307205,1188179964),new t(773529912,1546045734),new t(1294757372,1522805485),new t(1396182291,2643833823),new t(1695183700,2343527390),new t(1986661051,1014477480),new t(2177026350,1206759142),new t(2456956037,344077627),new t(2730485921,1290863460),new t(2820302411,3158454273),new t(3259730800,3505952657),new t(3345764771,106217008),new t(3516065817,3606008344),new t(3600352804,1432725776),new t(4094571909,1467031594),new t(275423344,851169720),new t(430227734,3100823752),new t(506948616,1363258195),new t(659060556,3750685593),new t(883997877,3785050280),new t(958139571,3318307427),new t(1322822218,3812723403),new t(1537002063,2003034995),new t(1747873779,3602036899),new t(1955562222,1575990012),new t(2024104815,1125592928),new t(2227730452,2716904306),new t(2361852424,442776044),new t(2428436474,593698344),new t(2756734187,3733110249),new t(3204031479,2999351573),new t(3329325298,3815920427),new t(3391569614,3928383900),new t(3515267271,566280711),new t(3940187606,3454069534),new t(4118630271,4000239992),new t(116418474,1914138554),new t(174292421,2731055270),new t(289380356,3203993006),new t(460393269,320620315),new t(685471733,587496836),new t(852142971,1086792851),new t(1017036298,365543100),new t(1126000580,2618297676),new t(1288033470,3409855158),new t(1501505948,4234509866),new t(1607167915,987167468),new t(1816402316,1246189591)];function $o(A,N,k){var T=[],L=[],z=[],re=[],ae,K,te;for(K=0;K<8;K++)T[K]=z[K]=C(A,8*K);for(var ge=0;k>=128;){for(K=0;K<16;K++)re[K]=C(N,8*K+ge);for(K=0;K<80;K++){for(te=0;te<8;te++)L[te]=z[te];for(ae=cr(z[7],ri(z[4]),Du(z[4],z[5],z[6]),qu[K],re[K%16]),L[7]=cr(ae,zo(z[0]),Uo(z[0],z[1],z[2])),L[3]=cr(L[3],ae),te=0;te<8;te++)z[(te+1)%8]=L[te];if(K%16===15)for(te=0;te<16;te++)re[te]=cr(re[te],re[(te+9)%16],Lu(re[(te+1)%16]),Io(re[(te+14)%16]))}for(K=0;K<8;K++)z[K]=cr(z[K],T[K]),T[K]=z[K];ge+=128,k-=128}for(K=0;K<8;K++)B(A,8*K,T[K]);return k}var As=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 _t(A,N,k){var T=new Uint8Array(64),L=new Uint8Array(256),z,re=k;for(z=0;z<64;z++)T[z]=As[z];for($o(T,N,k),k%=128,z=0;z<256;z++)L[z]=0;for(z=0;z<k;z++)L[z]=N[re-k+z];for(L[k]=128,k=256-128*(k<112?1:0),L[k-9]=0,B(L,k-8,new t(re/536870912|0,re<<3)),$o(T,L,k),z=0;z<64;z++)A[z]=T[z];return 0}function cn(A,N){var k=s(),T=s(),L=s(),z=s(),re=s(),ae=s(),K=s(),te=s(),ge=s();Re(k,A[1],A[0]),Re(ge,N[1],N[0]),oe(k,k,ge),we(T,A[0],A[1]),we(ge,N[0],N[1]),oe(T,T,ge),oe(L,A[3],N[3]),oe(L,L,d),oe(z,A[2],N[2]),we(z,z,z),Re(re,T,k),Re(ae,z,L),we(K,z,L),we(te,T,k),oe(A[0],re,ae),oe(A[1],te,K),oe(A[2],K,ae),oe(A[3],re,te)}function Ft(A,N,k){var T;for(T=0;T<4;T++)Ne(A[T],N[T],k)}function ca(A,N){var k=s(),T=s(),L=s();We(L,N[2]),oe(k,N[0],L),oe(T,N[1],L),Me(A,T),A[31]^=yt(k)<<7}function ua(A,N,k){var T,L;for(ve(A[0],m),ve(A[1],y),ve(A[2],y),ve(A[3],m),L=255;L>=0;--L)T=k[L/8|0]>>(L&7)&1,Ft(A,N,T),cn(N,A),cn(A,A),Ft(A,N,T)}function si(A,N){var k=[s(),s(),s(),s()];ve(k[0],b),ve(k[1],x),ve(k[2],y),oe(k[3],b,x),ua(A,k,N)}function Ur(A,N,k){var T=new Uint8Array(64),L=[s(),s(),s(),s()],z;for(k||i(N,32),_t(T,N,32),T[0]&=248,T[31]&=127,T[31]|=64,si(L,T),ca(A,L),z=0;z<32;z++)N[z+32]=A[z];return 0}var ur=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 zr(A,N){var k,T,L,z;for(T=63;T>=32;--T){for(k=0,L=T-32,z=T-12;L<z;++L)N[L]+=k-16*N[T]*ur[L-(T-32)],k=Math.floor((N[L]+128)/256),N[L]-=k*256;N[L]+=k,N[T]=0}for(k=0,L=0;L<32;L++)N[L]+=k-(N[31]>>4)*ur[L],k=N[L]>>8,N[L]&=255;for(L=0;L<32;L++)N[L]-=k*ur[L];for(T=0;T<32;T++)N[T+1]+=N[T]>>8,A[T]=N[T]&255}function $n(A){var N=new Float64Array(64),k;for(k=0;k<64;k++)N[k]=A[k];for(k=0;k<64;k++)A[k]=0;zr(A,N)}function js(A,N,k,T){var L=new Uint8Array(64),z=new Uint8Array(64),re=new Uint8Array(64),ae,K,te=new Float64Array(64),ge=[s(),s(),s(),s()];_t(L,T,32),L[0]&=248,L[31]&=127,L[31]|=64;var qe=k+64;for(ae=0;ae<k;ae++)A[64+ae]=N[ae];for(ae=0;ae<32;ae++)A[32+ae]=L[32+ae];for(_t(re,A.subarray(32),k+32),$n(re),si(ge,re),ca(A,ge),ae=32;ae<64;ae++)A[ae]=T[ae];for(_t(z,A,k+64),$n(z),ae=0;ae<64;ae++)te[ae]=0;for(ae=0;ae<32;ae++)te[ae]=re[ae];for(ae=0;ae<32;ae++)for(K=0;K<32;K++)te[ae+K]+=z[ae]*L[K];return zr(A.subarray(32),te),qe}function ks(A,N){var k=s(),T=s(),L=s(),z=s(),re=s(),ae=s(),K=s();return ve(A[2],y),Ct(A[1],N),Be(L,A[1]),oe(z,L,u),Re(L,L,A[2]),we(z,A[2],z),Be(re,z),Be(ae,re),oe(K,ae,re),oe(k,K,L),oe(k,k,z),ln(k,k),oe(k,k,L),oe(k,k,z),oe(k,k,z),oe(A[0],k,z),Be(T,A[0]),oe(T,T,z),Ze(T,L)&&oe(A[0],A[0],v),Be(T,A[0]),oe(T,T,z),Ze(T,L)?-1:(yt(A[0])===N[31]>>7&&Re(A[0],m,A[0]),oe(A[3],A[0],A[1]),0)}function fa(A,N,k,T){var L,z=new Uint8Array(32),re=new Uint8Array(64),ae=[s(),s(),s(),s()],K=[s(),s(),s(),s()];if(k<64||ks(K,T))return-1;for(L=0;L<k;L++)A[L]=N[L];for(L=0;L<32;L++)A[L+32]=T[L];if(_t(re,A,k),$n(re),ua(ae,K,re),si(K,N.subarray(32)),cn(ae,K),ca(z,ae),k-=64,R(N,0,z,0)){for(L=0;L<k;L++)A[L]=0;return-1}for(L=0;L<k;L++)A[L]=N[L+64];return k}var ii=32,Ir=24,Hn=32,$r=16,Hr=32,Ns=32,Fr=32,fr=32,Ts=32,ha=Ir,Ho=Hn,er=$r,at=64,gt=32,un=64,Cs=32,da=64;n.lowlevel={crypto_core_hsalsa20:V,crypto_stream_xor:he,crypto_stream:X,crypto_stream_salsa20_xor:D,crypto_stream_salsa20:Q,crypto_onetimeauth:H,crypto_onetimeauth_verify:W,crypto_verify_16:le,crypto_verify_32:R,crypto_secretbox:ce,crypto_secretbox_open:xe,crypto_scalarmult:pe,crypto_scalarmult_base:Ye,crypto_box_beforenm:ft,crypto_box_afternm:Pr,crypto_box:oa,crypto_box_open:la,crypto_box_keypair:Ot,crypto_hash:_t,crypto_sign:js,crypto_sign_keypair:Ur,crypto_sign_open:fa,crypto_secretbox_KEYBYTES:ii,crypto_secretbox_NONCEBYTES:Ir,crypto_secretbox_ZEROBYTES:Hn,crypto_secretbox_BOXZEROBYTES:$r,crypto_scalarmult_BYTES:Hr,crypto_scalarmult_SCALARBYTES:Ns,crypto_box_PUBLICKEYBYTES:Fr,crypto_box_SECRETKEYBYTES:fr,crypto_box_BEFORENMBYTES:Ts,crypto_box_NONCEBYTES:ha,crypto_box_ZEROBYTES:Ho,crypto_box_BOXZEROBYTES:er,crypto_sign_BYTES:at,crypto_sign_PUBLICKEYBYTES:gt,crypto_sign_SECRETKEYBYTES:un,crypto_sign_SEEDBYTES:Cs,crypto_hash_BYTES:da,gf:s,D:u,L:ur,pack25519:Me,unpack25519:Ct,M:oe,A:we,S:Be,Z:Re,pow2523:ln,add:cn,set25519:ve,modL:zr,scalarmult:ua,scalarbase:si};function Fo(A,N){if(A.length!==ii)throw new Error("bad key size");if(N.length!==Ir)throw new Error("bad nonce size")}function Go(A,N){if(A.length!==Fr)throw new Error("bad public key size");if(N.length!==fr)throw new Error("bad secret key size")}function Mt(){for(var A=0;A<arguments.length;A++)if(!(arguments[A]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function ai(A){for(var N=0;N<A.length;N++)A[N]=0}n.randomBytes=function(A){var N=new Uint8Array(A);return i(N,A),N},n.secretbox=function(A,N,k){Mt(A,N,k),Fo(k,N);for(var T=new Uint8Array(Hn+A.length),L=new Uint8Array(T.length),z=0;z<A.length;z++)T[z+Hn]=A[z];return ce(L,T,T.length,N,k),L.subarray($r)},n.secretbox.open=function(A,N,k){Mt(A,N,k),Fo(k,N);for(var T=new Uint8Array($r+A.length),L=new Uint8Array(T.length),z=0;z<A.length;z++)T[z+$r]=A[z];return T.length<32||xe(L,T,T.length,N,k)!==0?null:L.subarray(Hn)},n.secretbox.keyLength=ii,n.secretbox.nonceLength=Ir,n.secretbox.overheadLength=$r,n.scalarMult=function(A,N){if(Mt(A,N),A.length!==Ns)throw new Error("bad n size");if(N.length!==Hr)throw new Error("bad p size");var k=new Uint8Array(Hr);return pe(k,A,N),k},n.scalarMult.base=function(A){if(Mt(A),A.length!==Ns)throw new Error("bad n size");var N=new Uint8Array(Hr);return Ye(N,A),N},n.scalarMult.scalarLength=Ns,n.scalarMult.groupElementLength=Hr,n.box=function(A,N,k,T){var L=n.box.before(k,T);return n.secretbox(A,N,L)},n.box.before=function(A,N){Mt(A,N),Go(A,N);var k=new Uint8Array(Ts);return ft(k,A,N),k},n.box.after=n.secretbox,n.box.open=function(A,N,k,T){var L=n.box.before(k,T);return n.secretbox.open(A,N,L)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var A=new Uint8Array(Fr),N=new Uint8Array(fr);return Ot(A,N),{publicKey:A,secretKey:N}},n.box.keyPair.fromSecretKey=function(A){if(Mt(A),A.length!==fr)throw new Error("bad secret key size");var N=new Uint8Array(Fr);return Ye(N,A),{publicKey:N,secretKey:new Uint8Array(A)}},n.box.publicKeyLength=Fr,n.box.secretKeyLength=fr,n.box.sharedKeyLength=Ts,n.box.nonceLength=ha,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(A,N){if(Mt(A,N),N.length!==un)throw new Error("bad secret key size");var k=new Uint8Array(at+A.length);return js(k,A,A.length,N),k},n.sign.open=function(A,N){if(Mt(A,N),N.length!==gt)throw new Error("bad public key size");var k=new Uint8Array(A.length),T=fa(k,A,A.length,N);if(T<0)return null;for(var L=new Uint8Array(T),z=0;z<L.length;z++)L[z]=k[z];return L},n.sign.detached=function(A,N){for(var k=n.sign(A,N),T=new Uint8Array(at),L=0;L<T.length;L++)T[L]=k[L];return T},n.sign.detached.verify=function(A,N,k){if(Mt(A,N,k),N.length!==at)throw new Error("bad signature size");if(k.length!==gt)throw new Error("bad public key size");var T=new Uint8Array(at+A.length),L=new Uint8Array(at+A.length),z;for(z=0;z<at;z++)T[z]=N[z];for(z=0;z<A.length;z++)T[z+at]=A[z];return fa(L,T,T.length,k)>=0},n.sign.keyPair=function(){var A=new Uint8Array(gt),N=new Uint8Array(un);return Ur(A,N),{publicKey:A,secretKey:N}},n.sign.keyPair.fromSecretKey=function(A){if(Mt(A),A.length!==un)throw new Error("bad secret key size");for(var N=new Uint8Array(gt),k=0;k<N.length;k++)N[k]=A[32+k];return{publicKey:N,secretKey:new Uint8Array(A)}},n.sign.keyPair.fromSeed=function(A){if(Mt(A),A.length!==Cs)throw new Error("bad seed size");for(var N=new Uint8Array(gt),k=new Uint8Array(un),T=0;T<32;T++)k[T]=A[T];return Ur(N,k,!0),{publicKey:N,secretKey:k}},n.sign.publicKeyLength=gt,n.sign.secretKeyLength=un,n.sign.seedLength=Cs,n.sign.signatureLength=at,n.hash=function(A){Mt(A);var N=new Uint8Array(da);return _t(N,A,A.length),N},n.hash.hashLength=da,n.verify=function(A,N){return Mt(A,N),A.length===0||N.length===0||A.length!==N.length?!1:ie(A,0,N,0,A.length)===0},n.setPRNG=function(A){i=A},(function(){var A=typeof globalThis<"u"?globalThis.crypto||globalThis.msCrypto:null;if(A&&A.getRandomValues){var N=65536;n.setPRNG(function(k,T){var L,z=new Uint8Array(T);for(L=0;L<T;L+=N)A.getRandomValues(z.subarray(L,L+Math.min(T-L,N)));for(L=0;L<T;L++)k[L]=z[L];ai(z)})}else typeof require<"u"&&(A=require("crypto"),A&&A.randomBytes&&n.setPRNG(function(k,T){var L,z=A.randomBytes(T);for(L=0;L<T;L++)k[L]=z[L];ai(z)}))})()})(typeof module<"u"&&module.exports?module.exports:globalThis.nacl=globalThis.nacl||{});const ac=typeof module<"u"&&module.exports?module.exports:globalThis.nacl;ac.sign.keyPair.fromSeed,ac.sign.detached,ac.sign.detached.verify,ac.randomBytes;var t1;(function(n){n.InvalidPrefixByte="nkeys: invalid prefix byte",n.InvalidKey="nkeys: invalid key",n.InvalidPublicKey="nkeys: invalid public key",n.InvalidSeedLen="nkeys: invalid seed length",n.InvalidSeed="nkeys: invalid seed",n.InvalidEncoding="nkeys: invalid encoded key",n.InvalidSignature="nkeys: signature verification failed",n.CannotSign="nkeys: cannot sign, no private key available",n.PublicKeyOnly="nkeys: no seed or private key available",n.InvalidChecksum="nkeys: invalid checksum",n.SerializationError="nkeys: serialization error",n.ApiError="nkeys: api error",n.ClearedPair="nkeys: pair is cleared"})(t1||(t1={}));var n1;(function(n){n[n.Seed=144]="Seed",n[n.Private=120]="Private",n[n.Operator=112]="Operator",n[n.Server=104]="Server",n[n.Cluster=16]="Cluster",n[n.Account=0]="Account",n[n.User=160]="User"})(n1||(n1={}));function e2(n){return t=>{let s={};return n.forEach(i=>{const o=i(t)||{};s=Object.assign(s,o)}),s}}function t2(){return()=>{}}function n2(n,t){return()=>{const s=typeof n=="function"?n():n,i=typeof t=="function"?t():t;return{user:s,pass:i}}}function r2(n){return()=>({auth_token:typeof n=="function"?n():n})}const vx=120*1e3,s2=2,_x=2*1e3;function i2(){return{maxPingOut:2,maxReconnectAttempts:10,noRandomize:!1,pedantic:!1,pingInterval:vx,reconnect:!0,reconnectJitter:100,reconnectJitterTLS:1e3,reconnectTimeWait:_x,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function a2(n){const t=[];return typeof n.authenticator=="function"&&t.push(n.authenticator),Array.isArray(n.authenticator)&&t.push(...n.authenticator),n.token&&t.push(r2(n.token)),n.user&&t.push(n2(n.user,n.pass)),t.length===0?t2():e2(t)}function o2(n){const t=`${gd}:${gx()}`;if(n=n||{servers:[t]},n.servers=n.servers||[],typeof n.servers=="string"&&(n.servers=[n.servers]),n.servers.length>0&&n.port)throw new ye("port and servers options are mutually exclusive",ue.InvalidOption);n.servers.length===0&&n.port&&(n.servers=[`${gd}:${n.port}`]),n.servers&&n.servers.length===0&&(n.servers=[t]);const s=Su(i2(),n);if(s.authenticator=a2(s),["reconnectDelayHandler","authenticator"].forEach(i=>{if(s[i]&&typeof s[i]!="function")throw new ye(`${i} option should be a function`,ue.NotFunction)}),s.reconnectDelayHandler||(s.reconnectDelayHandler=()=>{let i=s.tls?s.reconnectJitterTLS:s.reconnectJitter;return i&&(i++,i=Math.floor(Math.random()*i)),s.reconnectTimeWait+i}),s.inboxPrefix)try{Rr(s.inboxPrefix)}catch(i){throw new ye(i.message,ue.ApiError)}if(s.resolve===void 0&&(s.resolve=typeof Od()=="function"),s.resolve&&typeof Od()!="function")throw new ye("'resolve' is not supported on this client",ue.InvalidOption);return s}function l2(n,t){const{proto:s,tls_required:i,tls_available:o}=n;if((s===void 0||s<1)&&t.noEcho)throw new ye("noEcho",ue.ServerOptionNotAvailable);const c=i||o||!1;if(t.tls&&!c)throw new ye("tls",ue.ServerOptionNotAvailable)}const c2=1024*32,u2=/^INFO\s+([^\r\n]+)\r\n/i,f2=go(`PONG\r
36
+ ${this.ctx.stack}`),this.deferred.reject(s)):this.deferred.resolve(i),this.cancel()}cancel(s){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(s||ye.errorForCode(ue.Cancelled))}}const AE="$JS.API";function jE(n){return n=n||{},n.domain&&(n.apiPrefix=`$JS.${n.domain}.API`,delete n.domain),Su({apiPrefix:AE,timeout:5e3},n)}class To{constructor(t,s){j(this,"nc");j(this,"opts");j(this,"prefix");j(this,"timeout");j(this,"jc");this.nc=t,this.opts=jE(s),this._parseOpts(),this.prefix=this.opts.apiPrefix,this.timeout=this.opts.timeout,this.jc=Wn()}getOptions(){return Object.assign({},this.opts)}_parseOpts(){let t=this.opts.apiPrefix;if(!t||t.length===0)throw new Error("invalid empty prefix");t[t.length-1]==="."&&(t=t.substr(0,t.length-1)),this.opts.apiPrefix=t}async _request(t,s=null,i){i=i||{},i.timeout=this.timeout;let o=An;s&&(o=this.jc.encode(s));let{retries:c}=i;c=c||1,c=c===-1?Number.MAX_SAFE_INTEGER:c;const m=rm();for(let y=0;y<c;y++)try{const g=await this.nc.request(t,o,i);return this.parseJsResponse(g)}catch(g){const u=g;if((u.code==="503"||u.code===ue.Timeout)&&y+1<c)await sa(m.backoff(y));else throw g}}async findStream(t){const s={subject:t},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(t){const s=this.jc.decode(t.data),i=s;if(i.error){const o=dx(i.error.code,i.error.description);if(o!==null)throw o.api_error=i.error,o}return s}}class po{constructor(t,s,i,o){j(this,"err");j(this,"offset");j(this,"pageInfo");j(this,"subject");j(this,"jsm");j(this,"filter");j(this,"payload");if(!t)throw new Error("subject is required");this.subject=t,this.jsm=i,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 t={offset:this.offset};this.payload&&Object.assign(t,this.payload);try{const s=await this.jsm._request(this.subject,t,{timeout:this.jsm.timeout});this.pageInfo=s;const i=this.countResponse(s);return i===0?[]:(this.offset+=i,this.filter(s))}catch(s){throw this.err=s,s}}countResponse(t){var s,i,o;switch(t==null?void 0:t.type){case"io.nats.jetstream.api.v1.stream_names_response":case"io.nats.jetstream.api.v1.stream_list_response":return((s=t.streams)==null?void 0:s.length)||0;case"io.nats.jetstream.api.v1.consumer_list_response":return((i=t.consumers)==null?void 0:i.length)||0;default:return console.error(`jslister.ts: unknown API response for paged output: ${t==null?void 0:t.type}`),((o=t.streams)==null?void 0:o.length)||0}return 0}async*[Symbol.asyncIterator](){let t=await this.next();for(;t.length>0;){for(const s of t)yield s;t=await this.next()}}}function Zs(n=""){const t=n.match(/(\d+).(\d+).(\d+)/);if(t)return{major:parseInt(t[1]),minor:parseInt(t[2]),micro:parseInt(t[3])};throw new Error(`'${n}' is not a semver value`)}function Ed(n,t){return n.major<t.major?-1:n.major>t.major?1:n.minor<t.minor?-1:n.minor>t.minor?1:n.micro<t.micro?-1:n.micro>t.micro?1:0}var Ke;(function(n){n.JS_KV="js_kv",n.JS_OBJECTSTORE="js_objectstore",n.JS_PULL_MAX_BYTES="js_pull_max_bytes",n.JS_NEW_CONSUMER_CREATE_API="js_new_consumer_create",n.JS_ALLOW_DIRECT="js_allow_direct",n.JS_MULTIPLE_CONSUMER_FILTER="js_multiple_consumer_filter",n.JS_SIMPLIFICATION="js_simplification",n.JS_STREAM_CONSUMER_METADATA="js_stream_consumer_metadata",n.JS_CONSUMER_FILTER_SUBJECTS="js_consumer_filter_subjects",n.JS_STREAM_FIRST_SEQ="js_stream_first_seq",n.JS_STREAM_SUBJECT_TRANSFORM="js_stream_subject_transform",n.JS_STREAM_SOURCE_SUBJECT_TRANSFORM="js_stream_source_subject_transform",n.JS_STREAM_COMPRESSION="js_stream_compression",n.JS_DEFAULT_CONSUMER_LIMITS="js_default_consumer_limits",n.JS_BATCH_DIRECT_GET="js_batch_direct_get"})(Ke||(Ke={}));class kE{constructor(t){j(this,"server");j(this,"features");j(this,"disabled");this.features=new Map,this.disabled=[],this.update(t)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(t){this.disabled.push(t),this.update(this.server)}isDisabled(t){return this.disabled.indexOf(t)!==-1}update(t){typeof t=="string"&&(t=Zs(t)),this.server=t,this.set(Ke.JS_KV,"2.6.2"),this.set(Ke.JS_OBJECTSTORE,"2.6.3"),this.set(Ke.JS_PULL_MAX_BYTES,"2.8.3"),this.set(Ke.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(Ke.JS_ALLOW_DIRECT,"2.9.0"),this.set(Ke.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(Ke.JS_SIMPLIFICATION,"2.9.4"),this.set(Ke.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(Ke.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(Ke.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(Ke.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ke.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ke.JS_STREAM_COMPRESSION,"2.10.0"),this.set(Ke.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.set(Ke.JS_BATCH_DIRECT_GET,"2.11.0"),this.disabled.forEach(s=>{this.features.delete(s)})}set(t,s){this.features.set(t,{min:s,ok:Ed(this.server,Zs(s))>=0})}get(t){return this.features.get(t)||{min:"unknown",ok:!1}}supports(t){var s;return((s=this.get(t))==null?void 0:s.ok)||!1}require(t){return typeof t=="string"&&(t=Zs(t)),Ed(this.server,t)>=0}}class du extends To{constructor(t,s){super(t,s)}async add(t,s,i=hu.Create){if(Kt(t),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=t,o.action=i,o.config.durable_name&&Ki(o.config.durable_name);const c=this.nc;let{min:m,ok:y}=c.features.get(Ke.JS_NEW_CONSUMER_CREATE_API);const g=s.name===""?void 0:s.name;if(g&&!y)throw new Error(`consumer 'name' requires server ${m}`);if(g)try{Eu("name",g)}catch(x){const v=x.message,w=v.indexOf("cannot contain");throw w!==-1?new Error(`consumer 'name' ${v.substring(w)}`):x}let u,d="";if(Array.isArray(s.filter_subjects)){const{min:x,ok:v}=c.features.get(Ke.JS_MULTIPLE_CONSUMER_FILTER);if(!v)throw new Error(`consumer 'filter_subjects' requires server ${x}`);y=!1}if(s.metadata){const{min:x,ok:v}=c.features.get(Ke.JS_STREAM_CONSUMER_METADATA);if(!v)throw new Error(`consumer 'metadata' requires server ${x}`)}if(y&&(d=s.name??s.durable_name??""),d!==""){let x=s.filter_subject??void 0;x===">"&&(x=void 0),u=x!==void 0?`${this.prefix}.CONSUMER.CREATE.${t}.${d}.${x}`:`${this.prefix}.CONSUMER.CREATE.${t}.${d}`}else u=s.durable_name?`${this.prefix}.CONSUMER.DURABLE.CREATE.${t}.${s.durable_name}`:`${this.prefix}.CONSUMER.CREATE.${t}`;return await this._request(u,o)}async update(t,s,i){const o=await this.info(t,s),c=i;return this.add(t,Object.assign(o.config,c),hu.Update)}async info(t,s){return Kt(t),Ki(s),await this._request(`${this.prefix}.CONSUMER.INFO.${t}.${s}`)}async delete(t,s){return Kt(t),Ki(s),(await this._request(`${this.prefix}.CONSUMER.DELETE.${t}.${s}`)).success}list(t){Kt(t);const s=o=>o.consumers,i=`${this.prefix}.CONSUMER.LIST.${t}`;return new po(i,s,this)}pause(t,s,i){const o=`${this.prefix}.CONSUMER.PAUSE.${t}.${s}`,c={pause_until:i.toISOString()};return this._request(o,c)}resume(t,s){return this.pause(t,s,new Date(0))}}function zi(n,t,s=!1){if(s===!0&&!n)throw ye.errorForCode(ue.ApiError,new Error(`${t} is not a function`));if(n&&typeof n!="function")throw ye.errorForCode(ue.ApiError,new Error(`${t} is not a function`))}class NE extends Bt{constructor(s,i,o){super();j(this,"sub");j(this,"adapter");j(this,"subIterDone");zi(o.adapter,"adapter",!0),this.adapter=o.adapter,o.callback&&zi(o.callback,"callback"),this.noIterator=typeof o.callback=="function",o.ingestionFilterFn&&(zi(o.ingestionFilterFn,"ingestionFilterFn"),this.ingestionFilterFn=o.ingestionFilterFn),o.protocolFilterFn&&(zi(o.protocolFilterFn,"protocolFilterFn"),this.protocolFilterFn=o.protocolFilterFn),o.dispatchedFn&&(zi(o.dispatchedFn,"dispatchedFn"),this.dispatchedFn=o.dispatchedFn),o.cleanupFn&&zi(o.cleanupFn,"cleanupFn");let c=(d,b)=>{this.callback(d,b)};if(o.callback){const d=o.callback;c=(b,x)=>{const[v,w]=this.adapter(b,x);if(v){d(v,null);return}const{ingest:S}=this.ingestionFilterFn?this.ingestionFilterFn(w,this):{ingest:!0};S&&(!this.protocolFilterFn||this.protocolFilterFn(w))&&(d(v,w),this.dispatchedFn&&w&&this.dispatchedFn(w))}}const{max:m,queue:y,timeout:g}=o,u={queue:y,timeout:g,callback:c};m&&m>0&&(u.max=m),this.sub=s.subscribe(i,u),o.cleanupFn&&(this.sub.cleanupFn=o.cleanupFn),this.noIterator||this.iterClosed.then(()=>{this.unsubscribe()}),this.subIterDone=pt(),Promise.all([this.sub.closed,this.iterClosed]).then(()=>{this.subIterDone.resolve()}).catch(()=>{this.subIterDone.resolve()}),(async d=>{await d.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,i){this.sub.cancelTimeout();const[o,c]=this.adapter(s,i);o&&this.stop(o),c&&this.push(c)}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 En;function TE(n){En=n}function yx(){return En!==void 0&&En.defaultPort!==void 0?En.defaultPort:4222}function Qh(){return En!==void 0&&En.urlParseFn?En.urlParseFn:void 0}function CE(){if(!En||typeof En.factory!="function")throw new Error("transport fn is not set");return En.factory()}function Od(){return En!==void 0&&En.dnsResolveFn?En.dnsResolveFn:void 0}const nu=`\r
37
+ `,mu=na.fromAscii(nu),ME=new Uint8Array(mu)[0],RE=new Uint8Array(mu)[1];function DE(n){for(let t=0;t<n.length;t++){const s=t+1;if(n.byteLength>s&&n[t]===ME&&n[s]===RE)return s+1}return 0}function LE(n){const t=DE(n);if(t>0){const i=new Uint8Array(n).slice(0,t);return Sn.decode(i)}return""}const qE=4,gx=48,BE=65,PE=97;function UE(n,t,s,i){const o=new Uint8Array(16);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((m,y)=>{o[y]=m}),o[12]=n,o[13]=t,o[14]=s,o[15]=i,o}function Ad(n){return zE(n)!==void 0}function zE(n){for(let t=0;t<n.length;t++)switch(n[t]){case".":return bx(n);case":":return IE(n)}}function bx(n){const t=new Uint8Array(4);for(let s=0;s<4;s++){if(n.length===0)return;if(s>0){if(n[0]!==".")return;n=n.substring(1)}const{n:i,c:o,ok:c}=$E(n);if(!c||i>255)return;n=n.substring(o),t[s]=i}return UE(t[0],t[1],t[2],t[3])}function IE(n){const t=new Uint8Array(16);let s=-1;if(n.length>=2&&n[0]===":"&&n[1]===":"&&(s=0,n=n.substring(2),n.length===0))return t;let i=0;for(;i<16;){const{n:o,c,ok:m}=HE(n);if(!m||o>65535)return;if(c<n.length&&n[c]==="."){if(s<0&&i!=12||i+4>16)return;const y=bx(n);if(y===void 0)return;t[i]=y[12],t[i+1]=y[13],t[i+2]=y[14],t[i+3]=y[15],n="",i+=qE;break}if(t[i]=o>>8,t[i+1]=o,i+=2,n=n.substring(c),n.length===0)break;if(n[0]!==":"||n.length==1)return;if(n=n.substring(1),n[0]===":"){if(s>=0)return;if(s=i,n=n.substring(1),n.length===0)break}}if(n.length===0){if(i<16){if(s<0)return;const o=16-i;for(let c=i-1;c>=s;c--)t[c+o]=t[c];for(let c=s+o-1;c>=s;c--)t[c]=0}else if(s>=0)return;return t}}function $E(n){let t=0,s=0;for(t=0;t<n.length&&48<=n.charCodeAt(t)&&n.charCodeAt(t)<=57;t++)if(s=s*10+(n.charCodeAt(t)-gx),s>=16777215)return{n:16777215,c:t,ok:!1};return t===0?{n:0,c:0,ok:!1}:{n:s,c:t,ok:!0}}function HE(n){let t=0,s=0;for(s=0;s<n.length;s++){if(48<=n.charCodeAt(s)&&n.charCodeAt(s)<=57)t*=16,t+=n.charCodeAt(s)-gx;else if(97<=n.charCodeAt(s)&&n.charCodeAt(s)<=102)t*=16,t+=n.charCodeAt(s)-PE+10;else if(65<=n.charCodeAt(s)&&n.charCodeAt(s)<=70)t*=16,t+=n.charCodeAt(s)-BE+10;else break;if(t>=16777215)return{n:0,c:s,ok:!1}}return s===0?{n:0,c:s,ok:!1}:{n:t,c:s,ok:!0}}function FE(n){return n.indexOf("[")!==-1||n.indexOf("::")!==-1?!1:n.indexOf(".")!==-1||n.split(":").length<=2}function jd(n){return!FE(n)}function GE(n){const t="::FFFF:",s=n.toUpperCase().indexOf(t);if(s!==-1&&n.indexOf(".")!==-1){let i=n.substring(s+t.length);return i=i.replace("[",""),i.replace("]","")}return n}function VE(n){n=n.trim(),n.match(/^(.*:\/\/)(.*)/m)&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2")),n=GE(n),jd(n)&&n.indexOf("[")===-1&&(n=`[${n}]`);const t=jd(n)?n.match(/(]:)(\d+)/):n.match(/(:)(\d+)/),s=t&&t.length===3&&t[1]&&t[2]?parseInt(t[2]):4222,i=s===80?"https":"http",o=new URL(`${i}://${n}`);o.port=`${s}`;let c=o.hostname;return c.charAt(0)==="["&&(c=c.substring(1,c.length-1)),{listen:o.host,hostname:c,port:s}}class xo{constructor(t,s=!1){j(this,"src");j(this,"listen");j(this,"hostname");j(this,"port");j(this,"didConnect");j(this,"reconnects");j(this,"lastConnect");j(this,"gossiped");j(this,"tlsName");j(this,"resolves");this.src=t,this.tlsName="";const i=VE(t);this.listen=i.listen,this.hostname=i.hostname,this.port=i.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=s}toString(){return this.listen}async resolve(t){if(!t.fn||t.resolve===!1)return[this];const s=[];if(Ad(this.hostname))return[this];{const i=await t.fn(this.hostname);t.debug&&console.log(`resolve ${this.hostname} = ${i.join(",")}`);for(const o of i){const c=this.port===80?"https":"http",m=new URL(`${c}://${jd(o)?"["+o+"]":o}`);m.port=`${this.port}`;const y=new xo(m.host,!1);y.tlsName=this.hostname,s.push(y)}}return t.randomize&&fx(s),this.resolves=s,s}}class YE{constructor(t=[],s={}){j(this,"firstSelect");j(this,"servers");j(this,"currentServer");j(this,"tlsName");j(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=s.randomize||!1;const i=Qh();t&&(t.forEach(o=>{o=i?i(o):o,this.servers.push(new xo(o))}),this.randomize&&(this.servers=fx(this.servers))),this.servers.length===0&&this.addServer(`${gd}:${yx()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const t=this.getCurrentServer();Ad(t.hostname)||(this.tlsName=t.hostname,this.servers.forEach(s=>{s.gossiped&&(s.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(t,s=!1){const i=Qh();t=i?i(t):t;const o=new xo(t,s);Ad(o.hostname)&&(o.tlsName=this.tlsName),this.servers.push(o)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;const t=this.servers.shift();return t&&(this.servers.push(t),this.currentServer=t),t}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer(t){if(t){const s=this.servers.indexOf(t);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(t,s){const i=[];let o=[];const c=Qh(),m=new Map;t.connect_urls&&t.connect_urls.length>0&&t.connect_urls.forEach(g=>{g=c?c(g,s):g;const u=new xo(g,!0);m.set(g,u)});const y=[];return this.servers.forEach((g,u)=>{const d=g.listen;g.gossiped&&this.currentServer.listen!==d&&m.get(d)===void 0&&y.push(u),m.delete(d)}),y.reverse(),y.forEach(g=>{const u=this.servers.splice(g,1);o=o.concat(u[0].listen)}),m.forEach((g,u)=>{this.servers.push(g),i.push(u)}),{added:i,deleted:o}}}class KE{constructor(){j(this,"baseInbox");j(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(t){return this.baseInbox=`${Rr(t)}.`,this.baseInbox}add(t){isNaN(t.received)||(t.received=0),this.reqs.set(t.token,t)}get(t){return this.reqs.get(t)}cancel(t){this.reqs.delete(t.token)}getToken(t){const s=t.subject||"";return s.indexOf(this.baseInbox)===0?s.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(t,s){if(s&&s.permissionContext){if(t)return this.all().forEach(o=>{o.resolver(s,{})}),!0;const i=s.permissionContext;if(i.operation==="publish"){const o=this.all().find(c=>c.requestSubject===i.subject);if(o)return o.resolver(s,{}),!0}}return!1}dispatcher(){return(t,s)=>{const i=this.getToken(s);if(i){const o=this.get(i);o&&(t===null&&s.headers&&(t=hx(s)),o.resolver(t,s))}}}close(){const t=ye.errorForCode(ue.Timeout);this.reqs.forEach(s=>{s.resolver(t,{})})}}class JE{constructor(t,s,i){j(this,"ph");j(this,"interval");j(this,"maxOut");j(this,"timer");j(this,"pendings");this.ph=t,this.interval=s,this.maxOut=i,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(t){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),t&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:Yi.PingTimer,data:`${this.pendings.length+1}`}),this.pendings.length===this.maxOut){this.cancel(!0);return}const t=pt();this.ph.flush(t).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push(t),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(t=>(t.resolve(),!1))}}class XE extends Error{constructor(t){super(t),this.name="AssertionError"}}function QE(n,t="Assertion failed."){if(!n)throw new XE(t)}const Wg=32*1024,Wh=2**32-2;function ic(n,t,s=0){const i=t.byteLength-s;return n.byteLength>i&&(n=n.subarray(0,i)),t.set(n,s),n.byteLength}class Zh{constructor(t){j(this,"_buf");j(this,"_off");if(this._off=0,t==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array(t)}bytes(t={copy:!0}){return t.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(t){if(t===0){this.reset();return}if(t<0||t>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+t)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(t){const s=this._buf.byteLength;return t<=this.capacity-s?(this._reslice(s+t),s):-1}_reslice(t){QE(t<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,t)}readByte(){const t=new Uint8Array(1);return this.read(t)?t[0]:null}read(t){if(this.empty())return this.reset(),t.byteLength===0?0:null;const s=ic(this._buf.subarray(this._off),t);return this._off+=s,s}writeByte(t){return this.write(Uint8Array.of(t))}writeString(t){return this.write(ei.encode(t))}write(t){const s=this._grow(t.byteLength);return ic(t,this._buf,s)}_grow(t){const s=this.length;s===0&&this._off!==0&&this.reset();const i=this._tryGrowByReslice(t);if(i>=0)return i;const o=this.capacity;if(t<=Math.floor(o/2)-s)ic(this._buf.subarray(this._off),this._buf);else{if(o+t>Wh)throw new Error("The buffer cannot be grown beyond the maximum size.");{const c=new Uint8Array(Math.min(2*o+t,Wh));ic(this._buf.subarray(this._off),c),this._buf=c}}return this._off=0,this._reslice(Math.min(s+t,Wh)),s}grow(t){if(t<0)throw Error("Buffer._grow: negative count");const s=this._grow(t);this._reslice(s)}readFrom(t){let s=0;const i=new Uint8Array(Wg);for(;;){const o=this.capacity-this.length<Wg,c=o?i:new Uint8Array(this._buf.buffer,this.length),m=t.read(c);if(m===null)return s;o?this.write(c.subarray(0,m)):this._reslice(this.length+m),s+=m}}}var Jt;(function(n){n[n.OK=0]="OK",n[n.ERR=1]="ERR",n[n.MSG=2]="MSG",n[n.INFO=3]="INFO",n[n.PING=4]="PING",n[n.PONG=5]="PONG"})(Jt||(Jt={}));function Zg(){const n={};return n.sid=-1,n.hdr=-1,n.size=-1,n}const WE=48;class e1{constructor(t){j(this,"dispatcher");j(this,"state");j(this,"as");j(this,"drop");j(this,"hdr");j(this,"ma");j(this,"argBuf");j(this,"msgBuf");this.dispatcher=t,this.state=de.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(t){let s;for(s=0;s<t.length;s++){const i=t[s];switch(this.state){case de.OP_START:switch(i){case me.M:case me.m:this.state=de.OP_M,this.hdr=-1,this.ma=Zg();break;case me.H:case me.h:this.state=de.OP_H,this.hdr=0,this.ma=Zg();break;case me.P:case me.p:this.state=de.OP_P;break;case me.PLUS:this.state=de.OP_PLUS;break;case me.MINUS:this.state=de.OP_MINUS;break;case me.I:case me.i:this.state=de.OP_I;break;default:throw this.fail(t.subarray(s))}break;case de.OP_H:switch(i){case me.M:case me.m:this.state=de.OP_M;break;default:throw this.fail(t.subarray(s))}break;case de.OP_M:switch(i){case me.S:case me.s:this.state=de.OP_MS;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MS:switch(i){case me.G:case me.g:this.state=de.OP_MSG;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MSG:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_MSG_SPC;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MSG_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.MSG_ARG,this.as=s}break;case de.MSG_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{const o=this.argBuf?this.argBuf.bytes():t.subarray(this.as,s-this.drop);this.processMsgArgs(o),this.drop=0,this.as=s+1,this.state=de.MSG_PAYLOAD,s=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(i)}break;case de.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const o=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Jt.MSG,msg:this.ma,data:o}),this.argBuf=void 0,this.msgBuf=void 0,this.state=de.MSG_END}else{let o=this.ma.size-this.msgBuf.length;const c=t.length-s;c<o&&(o=c),o>0?(this.msgBuf.write(t.subarray(s,s+o)),s=s+o-1):this.msgBuf.writeByte(i)}else s-this.as>=this.ma.size&&(this.dispatcher.push({kind:Jt.MSG,msg:this.ma,data:t.subarray(this.as,s)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=de.MSG_END);break;case de.MSG_END:switch(i){case me.NL:this.drop=0,this.as=s+1,this.state=de.OP_START;break;default:continue}break;case de.OP_PLUS:switch(i){case me.O:case me.o:this.state=de.OP_PLUS_O;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PLUS_O:switch(i){case me.K:case me.k:this.state=de.OP_PLUS_OK;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PLUS_OK:switch(i){case me.NL:this.dispatcher.push({kind:Jt.OK}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_MINUS:switch(i){case me.E:case me.e:this.state=de.OP_MINUS_E;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_E:switch(i){case me.R:case me.r:this.state=de.OP_MINUS_ER;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_ER:switch(i){case me.R:case me.r:this.state=de.OP_MINUS_ERR;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_ERR:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_MINUS_ERR_SPC;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_ERR_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.MINUS_ERR_ARG,this.as=s}break;case de.MINUS_ERR_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=t.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Jt.ERR,data:o}),this.drop=0,this.as=s+1,this.state=de.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(i))}break;case de.OP_P:switch(i){case me.I:case me.i:this.state=de.OP_PI;break;case me.O:case me.o:this.state=de.OP_PO;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PO:switch(i){case me.N:case me.n:this.state=de.OP_PON;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PON:switch(i){case me.G:case me.g:this.state=de.OP_PONG;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PONG:switch(i){case me.NL:this.dispatcher.push({kind:Jt.PONG}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_PI:switch(i){case me.N:case me.n:this.state=de.OP_PIN;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PIN:switch(i){case me.G:case me.g:this.state=de.OP_PING;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PING:switch(i){case me.NL:this.dispatcher.push({kind:Jt.PING}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_I:switch(i){case me.N:case me.n:this.state=de.OP_IN;break;default:throw this.fail(t.subarray(s))}break;case de.OP_IN:switch(i){case me.F:case me.f:this.state=de.OP_INF;break;default:throw this.fail(t.subarray(s))}break;case de.OP_INF:switch(i){case me.O:case me.o:this.state=de.OP_INFO;break;default:throw this.fail(t.subarray(s))}break;case de.OP_INFO:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_INFO_SPC;break;default:throw this.fail(t.subarray(s))}break;case de.OP_INFO_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.INFO_ARG,this.as=s}break;case de.INFO_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=t.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Jt.INFO,data:o}),this.drop=0,this.as=s+1,this.state=de.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(i)}break;default:throw this.fail(t.subarray(s))}}(this.state===de.MSG_ARG||this.state===de.MINUS_ERR_ARG||this.state===de.INFO_ARG)&&!this.argBuf&&(this.argBuf=new Zh(t.subarray(this.as,s-this.drop))),this.state===de.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new Zh(t.subarray(this.as)))}cloneMsgArg(){const t=this.ma.subject.length,s=this.ma.reply?this.ma.reply.length:0,i=new Uint8Array(t+s);i.set(this.ma.subject),this.ma.reply&&i.set(this.ma.reply,t),this.argBuf=new Zh(i),this.ma.subject=i.subarray(0,t),this.ma.reply&&(this.ma.reply=i.subarray(t))}processMsgArgs(t){if(this.hdr>=0)return this.processHeaderMsgArgs(t);const s=[];let i=-1;for(let o=0;o<t.length;o++)switch(t[o]){case me.SPACE:case me.TAB:case me.CR:case me.NL:i>=0&&(s.push(t.subarray(i,o)),i=-1);break;default:i<0&&(i=o)}switch(i>=0&&s.push(t.subarray(i)),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(t,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(t,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(t,"processMsgArgs Bad or Missing Size Error")}fail(t,s=""){return s?s=`${s} [${this.state}]`:s=`parse error [${this.state}]`,new Error(`${s}: ${Sn.decode(t)}`)}processHeaderMsgArgs(t){const s=[];let i=-1;for(let o=0;o<t.length;o++)switch(t[o]){case me.SPACE:case me.TAB:case me.CR:case me.NL:i>=0&&(s.push(t.subarray(i,o)),i=-1);break;default:i<0&&(i=o)}switch(i>=0&&s.push(t.subarray(i)),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(t,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(t,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(t,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(t,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(t){if(t.length===0)return-1;let s=0;for(let i=0;i<t.length;i++){if(t[i]<48||t[i]>57)return-1;s=s*10+(t[i]-WE)}return s}}var de;(function(n){n[n.OP_START=0]="OP_START",n[n.OP_PLUS=1]="OP_PLUS",n[n.OP_PLUS_O=2]="OP_PLUS_O",n[n.OP_PLUS_OK=3]="OP_PLUS_OK",n[n.OP_MINUS=4]="OP_MINUS",n[n.OP_MINUS_E=5]="OP_MINUS_E",n[n.OP_MINUS_ER=6]="OP_MINUS_ER",n[n.OP_MINUS_ERR=7]="OP_MINUS_ERR",n[n.OP_MINUS_ERR_SPC=8]="OP_MINUS_ERR_SPC",n[n.MINUS_ERR_ARG=9]="MINUS_ERR_ARG",n[n.OP_M=10]="OP_M",n[n.OP_MS=11]="OP_MS",n[n.OP_MSG=12]="OP_MSG",n[n.OP_MSG_SPC=13]="OP_MSG_SPC",n[n.MSG_ARG=14]="MSG_ARG",n[n.MSG_PAYLOAD=15]="MSG_PAYLOAD",n[n.MSG_END=16]="MSG_END",n[n.OP_H=17]="OP_H",n[n.OP_P=18]="OP_P",n[n.OP_PI=19]="OP_PI",n[n.OP_PIN=20]="OP_PIN",n[n.OP_PING=21]="OP_PING",n[n.OP_PO=22]="OP_PO",n[n.OP_PON=23]="OP_PON",n[n.OP_PONG=24]="OP_PONG",n[n.OP_I=25]="OP_I",n[n.OP_IN=26]="OP_IN",n[n.OP_INF=27]="OP_INF",n[n.OP_INFO=28]="OP_INFO",n[n.OP_INFO_SPC=29]="OP_INFO_SPC",n[n.INFO_ARG=30]="INFO_ARG"})(de||(de={}));var me;(function(n){n[n.CR=13]="CR",n[n.E=69]="E",n[n.e=101]="e",n[n.F=70]="F",n[n.f=102]="f",n[n.G=71]="G",n[n.g=103]="g",n[n.H=72]="H",n[n.h=104]="h",n[n.I=73]="I",n[n.i=105]="i",n[n.K=75]="K",n[n.k=107]="k",n[n.M=77]="M",n[n.m=109]="m",n[n.MINUS=45]="MINUS",n[n.N=78]="N",n[n.n=110]="n",n[n.NL=10]="NL",n[n.O=79]="O",n[n.o=111]="o",n[n.P=80]="P",n[n.p=112]="p",n[n.PLUS=43]="PLUS",n[n.R=82]="R",n[n.r=114]="r",n[n.S=83]="S",n[n.s=115]="s",n[n.SPACE=32]="SPACE",n[n.TAB=9]="TAB"})(me||(me={}));(function(n){var t=function(A,N){this.hi=A|0,this.lo=N|0},s=function(A){var N,k=new Float64Array(16);if(A)for(N=0;N<A.length;N++)k[N]=A[N];return k},i=function(){throw new Error("no PRNG")},o=new Uint8Array(16),c=new Uint8Array(32);c[0]=9;var m=s(),y=s([1]),g=s([56129,1]),u=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),b=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),x=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),v=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function w(A,N){return A<<N|A>>>32-N}function S(A,N){var k=A[N+3]&255;return k=k<<8|A[N+2]&255,k=k<<8|A[N+1]&255,k<<8|A[N+0]&255}function C(A,N){var k=A[N]<<24|A[N+1]<<16|A[N+2]<<8|A[N+3],T=A[N+4]<<24|A[N+5]<<16|A[N+6]<<8|A[N+7];return new t(k,T)}function q(A,N,k){var T;for(T=0;T<4;T++)A[N+T]=k&255,k>>>=8}function B(A,N,k){A[N]=k.hi>>24&255,A[N+1]=k.hi>>16&255,A[N+2]=k.hi>>8&255,A[N+3]=k.hi&255,A[N+4]=k.lo>>24&255,A[N+5]=k.lo>>16&255,A[N+6]=k.lo>>8&255,A[N+7]=k.lo&255}function ie(A,N,k,T,L){var z,re=0;for(z=0;z<L;z++)re|=A[N+z]^k[T+z];return(1&re-1>>>8)-1}function le(A,N,k,T){return ie(A,N,k,T,16)}function R(A,N,k,T){return ie(A,N,k,T,32)}function $(A,N,k,T,L){var z=new Uint32Array(16),re=new Uint32Array(16),ae=new Uint32Array(16),K=new Uint32Array(4),te,ge,qe;for(te=0;te<4;te++)re[5*te]=S(T,4*te),re[1+te]=S(k,4*te),re[6+te]=S(N,4*te),re[11+te]=S(k,16+4*te);for(te=0;te<16;te++)ae[te]=re[te];for(te=0;te<20;te++){for(ge=0;ge<4;ge++){for(qe=0;qe<4;qe++)K[qe]=re[(5*ge+4*qe)%16];for(K[1]^=w(K[0]+K[3]|0,7),K[2]^=w(K[1]+K[0]|0,9),K[3]^=w(K[2]+K[1]|0,13),K[0]^=w(K[3]+K[2]|0,18),qe=0;qe<4;qe++)z[4*ge+(ge+qe)%4]=K[qe]}for(qe=0;qe<16;qe++)re[qe]=z[qe]}if(L){for(te=0;te<16;te++)re[te]=re[te]+ae[te]|0;for(te=0;te<4;te++)re[5*te]=re[5*te]-S(T,4*te)|0,re[6+te]=re[6+te]-S(N,4*te)|0;for(te=0;te<4;te++)q(A,4*te,re[5*te]),q(A,16+4*te,re[6+te])}else for(te=0;te<16;te++)q(A,4*te,re[te]+ae[te]|0)}function ne(A,N,k,T){return $(A,N,k,T,!1),0}function V(A,N,k,T){return $(A,N,k,T,!0),0}var I=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function D(A,N,k,T,L,z,re){var ae=new Uint8Array(16),K=new Uint8Array(64),te,ge;if(!L)return 0;for(ge=0;ge<16;ge++)ae[ge]=0;for(ge=0;ge<8;ge++)ae[ge]=z[ge];for(;L>=64;){for(ne(K,ae,re,I),ge=0;ge<64;ge++)A[N+ge]=(k?k[T+ge]:0)^K[ge];for(te=1,ge=8;ge<16;ge++)te=te+(ae[ge]&255)|0,ae[ge]=te&255,te>>>=8;L-=64,N+=64,k&&(T+=64)}if(L>0)for(ne(K,ae,re,I),ge=0;ge<L;ge++)A[N+ge]=(k?k[T+ge]:0)^K[ge];return 0}function Q(A,N,k,T,L){return D(A,N,null,0,k,T,L)}function X(A,N,k,T,L){var z=new Uint8Array(32);return V(z,T,L,I),Q(A,N,k,T.subarray(16),z)}function he(A,N,k,T,L,z,re){var ae=new Uint8Array(32);return V(ae,z,re,I),D(A,N,k,T,L,z.subarray(16),ae)}function Se(A,N){var k,T=0;for(k=0;k<17;k++)T=T+(A[k]+N[k]|0)|0,A[k]=T&255,T>>>=8}var ke=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function H(A,N,k,T,L,z){var re,ae,K,te,ge=new Uint32Array(17),qe=new Uint32Array(17),lt=new Uint32Array(17),Gt=new Uint32Array(17),Fn=new Uint32Array(17);for(K=0;K<17;K++)qe[K]=lt[K]=0;for(K=0;K<16;K++)qe[K]=z[K];for(qe[3]&=15,qe[4]&=252,qe[7]&=15,qe[8]&=252,qe[11]&=15,qe[12]&=252,qe[15]&=15;L>0;){for(K=0;K<17;K++)Gt[K]=0;for(K=0;K<16&&K<L;++K)Gt[K]=k[T+K];for(Gt[K]=1,T+=K,L-=K,Se(lt,Gt),ae=0;ae<17;ae++)for(ge[ae]=0,K=0;K<17;K++)ge[ae]=ge[ae]+lt[K]*(K<=ae?qe[ae-K]:320*qe[ae+17-K]|0)|0|0;for(ae=0;ae<17;ae++)lt[ae]=ge[ae];for(te=0,K=0;K<16;K++)te=te+lt[K]|0,lt[K]=te&255,te>>>=8;for(te=te+lt[16]|0,lt[16]=te&3,te=5*(te>>>2)|0,K=0;K<16;K++)te=te+lt[K]|0,lt[K]=te&255,te>>>=8;te=te+lt[16]|0,lt[16]=te}for(K=0;K<17;K++)Fn[K]=lt[K];for(Se(lt,ke),re=-(lt[16]>>>7)|0,K=0;K<17;K++)lt[K]^=re&(Fn[K]^lt[K]);for(K=0;K<16;K++)Gt[K]=z[K+16];for(Gt[16]=0,Se(lt,Gt),K=0;K<16;K++)A[N+K]=lt[K];return 0}function W(A,N,k,T,L,z){var re=new Uint8Array(16);return H(re,0,k,T,L,z),le(A,N,re,0)}function ce(A,N,k,T,L){var z;if(k<32)return-1;for(he(A,0,N,0,k,T,L),H(A,16,A,32,k-32,A),z=0;z<16;z++)A[z]=0;return 0}function xe(A,N,k,T,L){var z,re=new Uint8Array(32);if(k<32||(X(re,0,32,T,L),W(N,16,N,32,k-32,re)!==0))return-1;for(he(A,0,N,0,k,T,L),z=0;z<32;z++)A[z]=0;return 0}function ve(A,N){var k;for(k=0;k<16;k++)A[k]=N[k]|0}function Ce(A){var N,k;for(k=0;k<16;k++)A[k]+=65536,N=Math.floor(A[k]/65536),A[(k+1)*(k<15?1:0)]+=N-1+37*(N-1)*(k===15?1:0),A[k]-=N*65536}function Ne(A,N,k){for(var T,L=~(k-1),z=0;z<16;z++)T=L&(A[z]^N[z]),A[z]^=T,N[z]^=T}function Me(A,N){var k,T,L,z=s(),re=s();for(k=0;k<16;k++)re[k]=N[k];for(Ce(re),Ce(re),Ce(re),T=0;T<2;T++){for(z[0]=re[0]-65517,k=1;k<15;k++)z[k]=re[k]-65535-(z[k-1]>>16&1),z[k-1]&=65535;z[15]=re[15]-32767-(z[14]>>16&1),L=z[15]>>16&1,z[14]&=65535,Ne(re,z,1-L)}for(k=0;k<16;k++)A[2*k]=re[k]&255,A[2*k+1]=re[k]>>8}function Ze(A,N){var k=new Uint8Array(32),T=new Uint8Array(32);return Me(k,A),Me(T,N),R(k,0,T,0)}function yt(A){var N=new Uint8Array(32);return Me(N,A),N[0]&1}function Ct(A,N){var k;for(k=0;k<16;k++)A[k]=N[2*k]+(N[2*k+1]<<8);A[15]&=32767}function we(A,N,k){var T;for(T=0;T<16;T++)A[T]=N[T]+k[T]|0}function Re(A,N,k){var T;for(T=0;T<16;T++)A[T]=N[T]-k[T]|0}function oe(A,N,k){var T,L,z=new Float64Array(31);for(T=0;T<31;T++)z[T]=0;for(T=0;T<16;T++)for(L=0;L<16;L++)z[T+L]+=N[T]*k[L];for(T=0;T<15;T++)z[T]+=38*z[T+16];for(T=0;T<16;T++)A[T]=z[T];Ce(A),Ce(A)}function Be(A,N){oe(A,N,N)}function We(A,N){var k=s(),T;for(T=0;T<16;T++)k[T]=N[T];for(T=253;T>=0;T--)Be(k,k),T!==2&&T!==4&&oe(k,k,N);for(T=0;T<16;T++)A[T]=k[T]}function ln(A,N){var k=s(),T;for(T=0;T<16;T++)k[T]=N[T];for(T=250;T>=0;T--)Be(k,k),T!==1&&oe(k,k,N);for(T=0;T<16;T++)A[T]=k[T]}function pe(A,N,k){var T=new Uint8Array(32),L=new Float64Array(80),z,re,ae=s(),K=s(),te=s(),ge=s(),qe=s(),lt=s();for(re=0;re<31;re++)T[re]=N[re];for(T[31]=N[31]&127|64,T[0]&=248,Ct(L,k),re=0;re<16;re++)K[re]=L[re],ge[re]=ae[re]=te[re]=0;for(ae[0]=ge[0]=1,re=254;re>=0;--re)z=T[re>>>3]>>>(re&7)&1,Ne(ae,K,z),Ne(te,ge,z),we(qe,ae,te),Re(ae,ae,te),we(te,K,ge),Re(K,K,ge),Be(ge,qe),Be(lt,ae),oe(ae,te,ae),oe(te,K,qe),we(qe,ae,te),Re(ae,ae,te),Be(K,ae),Re(te,ge,lt),oe(ae,te,g),we(ae,ae,ge),oe(te,te,ae),oe(ae,ge,lt),oe(ge,K,L),Be(K,qe),Ne(ae,K,z),Ne(te,ge,z);for(re=0;re<16;re++)L[re+16]=ae[re],L[re+32]=te[re],L[re+48]=K[re],L[re+64]=ge[re];var Gt=L.subarray(32),Fn=L.subarray(16);return We(Gt,Gt),oe(Fn,Fn,Gt),Me(A,Fn),0}function Ye(A,N){return pe(A,N,c)}function Ot(A,N){return i(N,32),Ye(A,N)}function ft(A,N,k){var T=new Uint8Array(32);return pe(T,k,N),V(A,o,T,I)}var Pr=ce,Bo=xe;function oa(A,N,k,T,L,z){var re=new Uint8Array(32);return ft(re,L,z),Pr(A,N,k,T,re)}function la(A,N,k,T,L,z){var re=new Uint8Array(32);return ft(re,L,z),Bo(A,N,k,T,re)}function cr(){var A=0,N=0,k=0,T=0,L=65535,z,re,ae;for(ae=0;ae<arguments.length;ae++)z=arguments[ae].lo,re=arguments[ae].hi,A+=z&L,N+=z>>>16,k+=re&L,T+=re>>>16;return N+=A>>>16,k+=N>>>16,T+=k>>>16,new t(k&L|T<<16,A&L|N<<16)}function Po(A,N){return new t(A.hi>>>N,A.lo>>>N|A.hi<<32-N)}function ni(){var A=0,N=0,k;for(k=0;k<arguments.length;k++)A^=arguments[k].lo,N^=arguments[k].hi;return new t(N,A)}function ht(A,N){var k,T,L=32-N;return N<32?(k=A.hi>>>N|A.lo<<L,T=A.lo>>>N|A.hi<<L):N<64&&(k=A.lo>>>N|A.hi<<L,T=A.hi>>>N|A.lo<<L),new t(k,T)}function Du(A,N,k){var T=A.hi&N.hi^~A.hi&k.hi,L=A.lo&N.lo^~A.lo&k.lo;return new t(T,L)}function Uo(A,N,k){var T=A.hi&N.hi^A.hi&k.hi^N.hi&k.hi,L=A.lo&N.lo^A.lo&k.lo^N.lo&k.lo;return new t(T,L)}function zo(A){return ni(ht(A,28),ht(A,34),ht(A,39))}function ri(A){return ni(ht(A,14),ht(A,18),ht(A,41))}function Lu(A){return ni(ht(A,1),ht(A,8),Po(A,7))}function Io(A){return ni(ht(A,19),ht(A,61),Po(A,6))}var qu=[new t(1116352408,3609767458),new t(1899447441,602891725),new t(3049323471,3964484399),new t(3921009573,2173295548),new t(961987163,4081628472),new t(1508970993,3053834265),new t(2453635748,2937671579),new t(2870763221,3664609560),new t(3624381080,2734883394),new t(310598401,1164996542),new t(607225278,1323610764),new t(1426881987,3590304994),new t(1925078388,4068182383),new t(2162078206,991336113),new t(2614888103,633803317),new t(3248222580,3479774868),new t(3835390401,2666613458),new t(4022224774,944711139),new t(264347078,2341262773),new t(604807628,2007800933),new t(770255983,1495990901),new t(1249150122,1856431235),new t(1555081692,3175218132),new t(1996064986,2198950837),new t(2554220882,3999719339),new t(2821834349,766784016),new t(2952996808,2566594879),new t(3210313671,3203337956),new t(3336571891,1034457026),new t(3584528711,2466948901),new t(113926993,3758326383),new t(338241895,168717936),new t(666307205,1188179964),new t(773529912,1546045734),new t(1294757372,1522805485),new t(1396182291,2643833823),new t(1695183700,2343527390),new t(1986661051,1014477480),new t(2177026350,1206759142),new t(2456956037,344077627),new t(2730485921,1290863460),new t(2820302411,3158454273),new t(3259730800,3505952657),new t(3345764771,106217008),new t(3516065817,3606008344),new t(3600352804,1432725776),new t(4094571909,1467031594),new t(275423344,851169720),new t(430227734,3100823752),new t(506948616,1363258195),new t(659060556,3750685593),new t(883997877,3785050280),new t(958139571,3318307427),new t(1322822218,3812723403),new t(1537002063,2003034995),new t(1747873779,3602036899),new t(1955562222,1575990012),new t(2024104815,1125592928),new t(2227730452,2716904306),new t(2361852424,442776044),new t(2428436474,593698344),new t(2756734187,3733110249),new t(3204031479,2999351573),new t(3329325298,3815920427),new t(3391569614,3928383900),new t(3515267271,566280711),new t(3940187606,3454069534),new t(4118630271,4000239992),new t(116418474,1914138554),new t(174292421,2731055270),new t(289380356,3203993006),new t(460393269,320620315),new t(685471733,587496836),new t(852142971,1086792851),new t(1017036298,365543100),new t(1126000580,2618297676),new t(1288033470,3409855158),new t(1501505948,4234509866),new t(1607167915,987167468),new t(1816402316,1246189591)];function $o(A,N,k){var T=[],L=[],z=[],re=[],ae,K,te;for(K=0;K<8;K++)T[K]=z[K]=C(A,8*K);for(var ge=0;k>=128;){for(K=0;K<16;K++)re[K]=C(N,8*K+ge);for(K=0;K<80;K++){for(te=0;te<8;te++)L[te]=z[te];for(ae=cr(z[7],ri(z[4]),Du(z[4],z[5],z[6]),qu[K],re[K%16]),L[7]=cr(ae,zo(z[0]),Uo(z[0],z[1],z[2])),L[3]=cr(L[3],ae),te=0;te<8;te++)z[(te+1)%8]=L[te];if(K%16===15)for(te=0;te<16;te++)re[te]=cr(re[te],re[(te+9)%16],Lu(re[(te+1)%16]),Io(re[(te+14)%16]))}for(K=0;K<8;K++)z[K]=cr(z[K],T[K]),T[K]=z[K];ge+=128,k-=128}for(K=0;K<8;K++)B(A,8*K,T[K]);return k}var As=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 _t(A,N,k){var T=new Uint8Array(64),L=new Uint8Array(256),z,re=k;for(z=0;z<64;z++)T[z]=As[z];for($o(T,N,k),k%=128,z=0;z<256;z++)L[z]=0;for(z=0;z<k;z++)L[z]=N[re-k+z];for(L[k]=128,k=256-128*(k<112?1:0),L[k-9]=0,B(L,k-8,new t(re/536870912|0,re<<3)),$o(T,L,k),z=0;z<64;z++)A[z]=T[z];return 0}function cn(A,N){var k=s(),T=s(),L=s(),z=s(),re=s(),ae=s(),K=s(),te=s(),ge=s();Re(k,A[1],A[0]),Re(ge,N[1],N[0]),oe(k,k,ge),we(T,A[0],A[1]),we(ge,N[0],N[1]),oe(T,T,ge),oe(L,A[3],N[3]),oe(L,L,d),oe(z,A[2],N[2]),we(z,z,z),Re(re,T,k),Re(ae,z,L),we(K,z,L),we(te,T,k),oe(A[0],re,ae),oe(A[1],te,K),oe(A[2],K,ae),oe(A[3],re,te)}function Ft(A,N,k){var T;for(T=0;T<4;T++)Ne(A[T],N[T],k)}function ca(A,N){var k=s(),T=s(),L=s();We(L,N[2]),oe(k,N[0],L),oe(T,N[1],L),Me(A,T),A[31]^=yt(k)<<7}function ua(A,N,k){var T,L;for(ve(A[0],m),ve(A[1],y),ve(A[2],y),ve(A[3],m),L=255;L>=0;--L)T=k[L/8|0]>>(L&7)&1,Ft(A,N,T),cn(N,A),cn(A,A),Ft(A,N,T)}function si(A,N){var k=[s(),s(),s(),s()];ve(k[0],b),ve(k[1],x),ve(k[2],y),oe(k[3],b,x),ua(A,k,N)}function Ur(A,N,k){var T=new Uint8Array(64),L=[s(),s(),s(),s()],z;for(k||i(N,32),_t(T,N,32),T[0]&=248,T[31]&=127,T[31]|=64,si(L,T),ca(A,L),z=0;z<32;z++)N[z+32]=A[z];return 0}var ur=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 zr(A,N){var k,T,L,z;for(T=63;T>=32;--T){for(k=0,L=T-32,z=T-12;L<z;++L)N[L]+=k-16*N[T]*ur[L-(T-32)],k=Math.floor((N[L]+128)/256),N[L]-=k*256;N[L]+=k,N[T]=0}for(k=0,L=0;L<32;L++)N[L]+=k-(N[31]>>4)*ur[L],k=N[L]>>8,N[L]&=255;for(L=0;L<32;L++)N[L]-=k*ur[L];for(T=0;T<32;T++)N[T+1]+=N[T]>>8,A[T]=N[T]&255}function $n(A){var N=new Float64Array(64),k;for(k=0;k<64;k++)N[k]=A[k];for(k=0;k<64;k++)A[k]=0;zr(A,N)}function js(A,N,k,T){var L=new Uint8Array(64),z=new Uint8Array(64),re=new Uint8Array(64),ae,K,te=new Float64Array(64),ge=[s(),s(),s(),s()];_t(L,T,32),L[0]&=248,L[31]&=127,L[31]|=64;var qe=k+64;for(ae=0;ae<k;ae++)A[64+ae]=N[ae];for(ae=0;ae<32;ae++)A[32+ae]=L[32+ae];for(_t(re,A.subarray(32),k+32),$n(re),si(ge,re),ca(A,ge),ae=32;ae<64;ae++)A[ae]=T[ae];for(_t(z,A,k+64),$n(z),ae=0;ae<64;ae++)te[ae]=0;for(ae=0;ae<32;ae++)te[ae]=re[ae];for(ae=0;ae<32;ae++)for(K=0;K<32;K++)te[ae+K]+=z[ae]*L[K];return zr(A.subarray(32),te),qe}function ks(A,N){var k=s(),T=s(),L=s(),z=s(),re=s(),ae=s(),K=s();return ve(A[2],y),Ct(A[1],N),Be(L,A[1]),oe(z,L,u),Re(L,L,A[2]),we(z,A[2],z),Be(re,z),Be(ae,re),oe(K,ae,re),oe(k,K,L),oe(k,k,z),ln(k,k),oe(k,k,L),oe(k,k,z),oe(k,k,z),oe(A[0],k,z),Be(T,A[0]),oe(T,T,z),Ze(T,L)&&oe(A[0],A[0],v),Be(T,A[0]),oe(T,T,z),Ze(T,L)?-1:(yt(A[0])===N[31]>>7&&Re(A[0],m,A[0]),oe(A[3],A[0],A[1]),0)}function fa(A,N,k,T){var L,z=new Uint8Array(32),re=new Uint8Array(64),ae=[s(),s(),s(),s()],K=[s(),s(),s(),s()];if(k<64||ks(K,T))return-1;for(L=0;L<k;L++)A[L]=N[L];for(L=0;L<32;L++)A[L+32]=T[L];if(_t(re,A,k),$n(re),ua(ae,K,re),si(K,N.subarray(32)),cn(ae,K),ca(z,ae),k-=64,R(N,0,z,0)){for(L=0;L<k;L++)A[L]=0;return-1}for(L=0;L<k;L++)A[L]=N[L+64];return k}var ii=32,Ir=24,Hn=32,$r=16,Hr=32,Ns=32,Fr=32,fr=32,Ts=32,ha=Ir,Ho=Hn,er=$r,at=64,gt=32,un=64,Cs=32,da=64;n.lowlevel={crypto_core_hsalsa20:V,crypto_stream_xor:he,crypto_stream:X,crypto_stream_salsa20_xor:D,crypto_stream_salsa20:Q,crypto_onetimeauth:H,crypto_onetimeauth_verify:W,crypto_verify_16:le,crypto_verify_32:R,crypto_secretbox:ce,crypto_secretbox_open:xe,crypto_scalarmult:pe,crypto_scalarmult_base:Ye,crypto_box_beforenm:ft,crypto_box_afternm:Pr,crypto_box:oa,crypto_box_open:la,crypto_box_keypair:Ot,crypto_hash:_t,crypto_sign:js,crypto_sign_keypair:Ur,crypto_sign_open:fa,crypto_secretbox_KEYBYTES:ii,crypto_secretbox_NONCEBYTES:Ir,crypto_secretbox_ZEROBYTES:Hn,crypto_secretbox_BOXZEROBYTES:$r,crypto_scalarmult_BYTES:Hr,crypto_scalarmult_SCALARBYTES:Ns,crypto_box_PUBLICKEYBYTES:Fr,crypto_box_SECRETKEYBYTES:fr,crypto_box_BEFORENMBYTES:Ts,crypto_box_NONCEBYTES:ha,crypto_box_ZEROBYTES:Ho,crypto_box_BOXZEROBYTES:er,crypto_sign_BYTES:at,crypto_sign_PUBLICKEYBYTES:gt,crypto_sign_SECRETKEYBYTES:un,crypto_sign_SEEDBYTES:Cs,crypto_hash_BYTES:da,gf:s,D:u,L:ur,pack25519:Me,unpack25519:Ct,M:oe,A:we,S:Be,Z:Re,pow2523:ln,add:cn,set25519:ve,modL:zr,scalarmult:ua,scalarbase:si};function Fo(A,N){if(A.length!==ii)throw new Error("bad key size");if(N.length!==Ir)throw new Error("bad nonce size")}function Go(A,N){if(A.length!==Fr)throw new Error("bad public key size");if(N.length!==fr)throw new Error("bad secret key size")}function Mt(){for(var A=0;A<arguments.length;A++)if(!(arguments[A]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function ai(A){for(var N=0;N<A.length;N++)A[N]=0}n.randomBytes=function(A){var N=new Uint8Array(A);return i(N,A),N},n.secretbox=function(A,N,k){Mt(A,N,k),Fo(k,N);for(var T=new Uint8Array(Hn+A.length),L=new Uint8Array(T.length),z=0;z<A.length;z++)T[z+Hn]=A[z];return ce(L,T,T.length,N,k),L.subarray($r)},n.secretbox.open=function(A,N,k){Mt(A,N,k),Fo(k,N);for(var T=new Uint8Array($r+A.length),L=new Uint8Array(T.length),z=0;z<A.length;z++)T[z+$r]=A[z];return T.length<32||xe(L,T,T.length,N,k)!==0?null:L.subarray(Hn)},n.secretbox.keyLength=ii,n.secretbox.nonceLength=Ir,n.secretbox.overheadLength=$r,n.scalarMult=function(A,N){if(Mt(A,N),A.length!==Ns)throw new Error("bad n size");if(N.length!==Hr)throw new Error("bad p size");var k=new Uint8Array(Hr);return pe(k,A,N),k},n.scalarMult.base=function(A){if(Mt(A),A.length!==Ns)throw new Error("bad n size");var N=new Uint8Array(Hr);return Ye(N,A),N},n.scalarMult.scalarLength=Ns,n.scalarMult.groupElementLength=Hr,n.box=function(A,N,k,T){var L=n.box.before(k,T);return n.secretbox(A,N,L)},n.box.before=function(A,N){Mt(A,N),Go(A,N);var k=new Uint8Array(Ts);return ft(k,A,N),k},n.box.after=n.secretbox,n.box.open=function(A,N,k,T){var L=n.box.before(k,T);return n.secretbox.open(A,N,L)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var A=new Uint8Array(Fr),N=new Uint8Array(fr);return Ot(A,N),{publicKey:A,secretKey:N}},n.box.keyPair.fromSecretKey=function(A){if(Mt(A),A.length!==fr)throw new Error("bad secret key size");var N=new Uint8Array(Fr);return Ye(N,A),{publicKey:N,secretKey:new Uint8Array(A)}},n.box.publicKeyLength=Fr,n.box.secretKeyLength=fr,n.box.sharedKeyLength=Ts,n.box.nonceLength=ha,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(A,N){if(Mt(A,N),N.length!==un)throw new Error("bad secret key size");var k=new Uint8Array(at+A.length);return js(k,A,A.length,N),k},n.sign.open=function(A,N){if(Mt(A,N),N.length!==gt)throw new Error("bad public key size");var k=new Uint8Array(A.length),T=fa(k,A,A.length,N);if(T<0)return null;for(var L=new Uint8Array(T),z=0;z<L.length;z++)L[z]=k[z];return L},n.sign.detached=function(A,N){for(var k=n.sign(A,N),T=new Uint8Array(at),L=0;L<T.length;L++)T[L]=k[L];return T},n.sign.detached.verify=function(A,N,k){if(Mt(A,N,k),N.length!==at)throw new Error("bad signature size");if(k.length!==gt)throw new Error("bad public key size");var T=new Uint8Array(at+A.length),L=new Uint8Array(at+A.length),z;for(z=0;z<at;z++)T[z]=N[z];for(z=0;z<A.length;z++)T[z+at]=A[z];return fa(L,T,T.length,k)>=0},n.sign.keyPair=function(){var A=new Uint8Array(gt),N=new Uint8Array(un);return Ur(A,N),{publicKey:A,secretKey:N}},n.sign.keyPair.fromSecretKey=function(A){if(Mt(A),A.length!==un)throw new Error("bad secret key size");for(var N=new Uint8Array(gt),k=0;k<N.length;k++)N[k]=A[32+k];return{publicKey:N,secretKey:new Uint8Array(A)}},n.sign.keyPair.fromSeed=function(A){if(Mt(A),A.length!==Cs)throw new Error("bad seed size");for(var N=new Uint8Array(gt),k=new Uint8Array(un),T=0;T<32;T++)k[T]=A[T];return Ur(N,k,!0),{publicKey:N,secretKey:k}},n.sign.publicKeyLength=gt,n.sign.secretKeyLength=un,n.sign.seedLength=Cs,n.sign.signatureLength=at,n.hash=function(A){Mt(A);var N=new Uint8Array(da);return _t(N,A,A.length),N},n.hash.hashLength=da,n.verify=function(A,N){return Mt(A,N),A.length===0||N.length===0||A.length!==N.length?!1:ie(A,0,N,0,A.length)===0},n.setPRNG=function(A){i=A},(function(){var A=typeof globalThis<"u"?globalThis.crypto||globalThis.msCrypto:null;if(A&&A.getRandomValues){var N=65536;n.setPRNG(function(k,T){var L,z=new Uint8Array(T);for(L=0;L<T;L+=N)A.getRandomValues(z.subarray(L,L+Math.min(T-L,N)));for(L=0;L<T;L++)k[L]=z[L];ai(z)})}else typeof require<"u"&&(A=require("crypto"),A&&A.randomBytes&&n.setPRNG(function(k,T){var L,z=A.randomBytes(T);for(L=0;L<T;L++)k[L]=z[L];ai(z)}))})()})(typeof module<"u"&&module.exports?module.exports:globalThis.nacl=globalThis.nacl||{});const ac=typeof module<"u"&&module.exports?module.exports:globalThis.nacl;ac.sign.keyPair.fromSeed,ac.sign.detached,ac.sign.detached.verify,ac.randomBytes;var t1;(function(n){n.InvalidPrefixByte="nkeys: invalid prefix byte",n.InvalidKey="nkeys: invalid key",n.InvalidPublicKey="nkeys: invalid public key",n.InvalidSeedLen="nkeys: invalid seed length",n.InvalidSeed="nkeys: invalid seed",n.InvalidEncoding="nkeys: invalid encoded key",n.InvalidSignature="nkeys: signature verification failed",n.CannotSign="nkeys: cannot sign, no private key available",n.PublicKeyOnly="nkeys: no seed or private key available",n.InvalidChecksum="nkeys: invalid checksum",n.SerializationError="nkeys: serialization error",n.ApiError="nkeys: api error",n.ClearedPair="nkeys: pair is cleared"})(t1||(t1={}));var n1;(function(n){n[n.Seed=144]="Seed",n[n.Private=120]="Private",n[n.Operator=112]="Operator",n[n.Server=104]="Server",n[n.Cluster=16]="Cluster",n[n.Account=0]="Account",n[n.User=160]="User"})(n1||(n1={}));function ZE(n){return t=>{let s={};return n.forEach(i=>{const o=i(t)||{};s=Object.assign(s,o)}),s}}function e2(){return()=>{}}function t2(n,t){return()=>{const s=typeof n=="function"?n():n,i=typeof t=="function"?t():t;return{user:s,pass:i}}}function n2(n){return()=>({auth_token:typeof n=="function"?n():n})}const xx=120*1e3,r2=2,vx=2*1e3;function s2(){return{maxPingOut:2,maxReconnectAttempts:10,noRandomize:!1,pedantic:!1,pingInterval:xx,reconnect:!0,reconnectJitter:100,reconnectJitterTLS:1e3,reconnectTimeWait:vx,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function i2(n){const t=[];return typeof n.authenticator=="function"&&t.push(n.authenticator),Array.isArray(n.authenticator)&&t.push(...n.authenticator),n.token&&t.push(n2(n.token)),n.user&&t.push(t2(n.user,n.pass)),t.length===0?e2():ZE(t)}function a2(n){const t=`${gd}:${yx()}`;if(n=n||{servers:[t]},n.servers=n.servers||[],typeof n.servers=="string"&&(n.servers=[n.servers]),n.servers.length>0&&n.port)throw new ye("port and servers options are mutually exclusive",ue.InvalidOption);n.servers.length===0&&n.port&&(n.servers=[`${gd}:${n.port}`]),n.servers&&n.servers.length===0&&(n.servers=[t]);const s=Su(s2(),n);if(s.authenticator=i2(s),["reconnectDelayHandler","authenticator"].forEach(i=>{if(s[i]&&typeof s[i]!="function")throw new ye(`${i} option should be a function`,ue.NotFunction)}),s.reconnectDelayHandler||(s.reconnectDelayHandler=()=>{let i=s.tls?s.reconnectJitterTLS:s.reconnectJitter;return i&&(i++,i=Math.floor(Math.random()*i)),s.reconnectTimeWait+i}),s.inboxPrefix)try{Rr(s.inboxPrefix)}catch(i){throw new ye(i.message,ue.ApiError)}if(s.resolve===void 0&&(s.resolve=typeof Od()=="function"),s.resolve&&typeof Od()!="function")throw new ye("'resolve' is not supported on this client",ue.InvalidOption);return s}function o2(n,t){const{proto:s,tls_required:i,tls_available:o}=n;if((s===void 0||s<1)&&t.noEcho)throw new ye("noEcho",ue.ServerOptionNotAvailable);const c=i||o||!1;if(t.tls&&!c)throw new ye("tls",ue.ServerOptionNotAvailable)}const l2=1024*32,c2=/^INFO\s+([^\r\n]+)\r\n/i,u2=go(`PONG\r
38
38
  `),r1=go(`PING\r
39
- `);class h2{constructor(t,s,i){j(this,"echo");j(this,"no_responders");j(this,"protocol");j(this,"verbose");j(this,"pedantic");j(this,"jwt");j(this,"nkey");j(this,"sig");j(this,"user");j(this,"pass");j(this,"auth_token");j(this,"tls_required");j(this,"name");j(this,"lang");j(this,"version");j(this,"headers");this.protocol=1,this.version=t.version,this.lang=t.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(i):{})||{};Su(this,o)}}class wx extends Bt{constructor(s,i,o={}){var m;super();j(this,"sid");j(this,"queue");j(this,"draining");j(this,"max");j(this,"subject");j(this,"drained");j(this,"protocol");j(this,"timer");j(this,"info");j(this,"cleanupFn");j(this,"closed");j(this,"requestSubject");Su(this,o),this.protocol=s,this.subject=i,this.draining=!1,this.noIterator=typeof o.callback=="function",this.closed=pt();const c=!((m=s.options)!=null&&m.noAsyncTraces);o.timeout&&(this.timer=ea(o.timeout,c),this.timer.then(()=>{this.timer=void 0}).catch(y=>{this.stop(y),this.noIterator&&this.callback(y,{})})),this.noIterator||this.iterClosed.then(()=>{this.closed.resolve(),this.unsubscribe()})}setPrePostHandlers(s){if(this.noIterator){const i=this.callback,o=s.ingestionFilterFn?s.ingestionFilterFn:()=>({ingest:!0,protocol:!1}),c=s.protocolFilterFn?s.protocolFilterFn:()=>!0,m=s.dispatchedFn?s.dispatchedFn:()=>{};this.callback=(y,g)=>{const{ingest:u}=o(g);u&&c(g)&&(i(y,g),m(g))}}else this.protocolFilterFn=s.protocolFilterFn,this.dispatchedFn=s.dispatchedFn}callback(s,i){this.cancelTimeout(),s?this.stop(s):this.push(i)}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(ye.errorForCode(ue.ConnectionClosed)):this.isClosed()?Promise.reject(ye.errorForCode(ue.SubClosed)):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush(pt()).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 d2{constructor(){j(this,"mux");j(this,"subs");j(this,"sidCounter");this.sidCounter=0,this.mux=null,this.subs=new Map}size(){return this.subs.size}add(t){return this.sidCounter++,t.sid=this.sidCounter,this.subs.set(t.sid,t),t}setMux(t){return this.mux=t,t}getMux(){return this.mux}get(t){return this.subs.get(t)}resub(t){return this.sidCounter++,this.subs.delete(t.sid),t.sid=this.sidCounter,this.subs.set(t.sid,t),t}all(){return Array.from(this.subs.values())}cancel(t){t&&(t.close(),this.subs.delete(t.sid))}handleError(t){if(t&&t.permissionContext){const s=t.permissionContext,i=this.all();let o;if(s.operation==="subscription"&&(o=i.find(c=>c.subject===s.subject&&c.queue===s.queue)),s.operation==="publish"&&(o=i.find(c=>c.requestSubject===s.subject)),o)return o.callback(t,{}),o.close(),this.subs.delete(o.sid),o!==this.mux}return!1}close(){this.subs.forEach(t=>{t.close()})}}class pu{constructor(t,s){j(this,"connected");j(this,"connectedOnce");j(this,"infoReceived");j(this,"info");j(this,"muxSubscriptions");j(this,"options");j(this,"outbound");j(this,"pongs");j(this,"subscriptions");j(this,"transport");j(this,"noMorePublishing");j(this,"connectError");j(this,"publisher");j(this,"_closed");j(this,"closed");j(this,"listeners");j(this,"heartbeats");j(this,"parser");j(this,"outMsgs");j(this,"inMsgs");j(this,"outBytes");j(this,"inBytes");j(this,"pendingLimit");j(this,"lastError");j(this,"abortReconnect");j(this,"whyClosed");j(this,"servers");j(this,"server");j(this,"features");j(this,"connectPromise");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=c2,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=t,this.publisher=s,this.subscriptions=new d2,this.muxSubscriptions=new JE,this.outbound=new na,this.pongs=[],this.whyClosed="",this.pendingLimit=t.pendingLimit||this.pendingLimit,this.features=new NE({major:0,minor:0,micro:0}),this.connectPromise=null;const i=typeof t.servers=="string"?[t.servers]:t.servers;this.servers=new KE(i,{randomize:!t.noRandomize}),this.closed=pt(),this.parser=new e1(this),this.heartbeats=new XE(this,this.options.pingInterval||vx,this.options.maxPingOut||s2)}resetOutbound(){this.outbound.reset();const t=this.pongs;this.pongs=[];const s=ye.errorForCode(ue.Disconnect);s.stack="",t.forEach(i=>{i.reject(s)}),this.parser=new e1(this),this.infoReceived=!1}dispatchStatus(t){this.listeners.forEach(s=>{s.push(t)})}status(){const t=new Bt;return this.listeners.push(t),t}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const t=pt();return t.catch(()=>{}),this.pongs.unshift(t),this.connectError=s=>{t.reject(s)},this.transport=ME(),this.transport.closed().then(async s=>{if(this.connected=!1,!this.isClosed()){await this.disconnected(this.transport.closeError||this.lastError);return}}),t}disconnect(){this.dispatchStatus({type:Yi.StaleConnection,data:""}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:Yi.ClientInitiatedReconnect,data:""}),this.transport.disconnect()),Promise.resolve()}async disconnected(t){this.dispatchStatus({type:Mr.Disconnect,data:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{var s;this.dispatchStatus({type:Mr.Reconnect,data:this.servers.getCurrentServer().toString()}),((s=this.lastError)==null?void 0:s.code)===ue.AuthenticationExpired&&(this.lastError=void 0)}).catch(s=>{this._close(s)}):await this._close(t)}async dial(t){const s=this.prepare();let i;try{i=ea(this.options.timeout||2e4);const o=this.transport.connect(t,this.options);await Promise.race([o,i]),(async()=>{try{for await(const c of this.transport)this.parser.parse(c)}catch(c){console.log("reader closed",c)}})().then()}catch(o){s.reject(o)}try{await Promise.race([i,s]),i&&i.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 i&&i.cancel(),await this.transport.close(o),o}}async _doDial(t){const{resolve:s}=this.options,i=await t.resolve({fn:Od(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:s});let o=null;for(const c of i)try{o=null,this.dispatchStatus({type:Yi.Reconnecting,data:c.toString()}),await this.dial(c);return}catch(m){o=m}throw o}dialLoop(){return this.connectPromise===null&&(this.connectPromise=this.dodialLoop(),this.connectPromise.then(()=>{}).catch(()=>{}).finally(()=>{this.connectPromise=null})),this.connectPromise}async dodialLoop(){let t;for(;;){this._closed&&this.servers.clear();const s=this.options.reconnectDelayHandler?this.options.reconnectDelayHandler():_x;let i=s;const o=this.selectServer();if(!o||this.abortReconnect)throw t||(this.lastError?this.lastError:ye.errorForCode(ue.ConnectionRefused));const c=Date.now();if(o.lastConnect===0||o.lastConnect+s<=c){o.lastConnect=Date.now();try{await this._doDial(o);break}catch(m){if(t=m,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}o.reconnects++;const y=this.options.maxReconnectAttempts||0;y!==-1&&o.reconnects>=y&&this.servers.removeCurrentServer()}}else i=Math.min(i,o.lastConnect+s-c),await sa(i)}}static async connect(t,s){const i=new pu(t,s);return await i.dialLoop(),i}static toError(t){const s=t?t.toLowerCase():"";if(s.indexOf("permissions violation")!==-1){const i=new ye(t,ue.PermissionsViolation),o=t.match(/(Publish|Subscription) to "(\S+)"/);if(o){i.permissionContext={operation:o[1].toLowerCase(),subject:o[2],queue:void 0};const c=t.match(/using queue "(\S+)"/);c&&(i.permissionContext.queue=c[1])}return i}else return s.indexOf("authorization violation")!==-1?new ye(t,ue.AuthorizationViolation):s.indexOf("user authentication expired")!==-1?new ye(t,ue.AuthenticationExpired):s.indexOf("account authentication expired")!=-1?new ye(t,ue.AccountExpired):s.indexOf("authentication timeout")!==-1?new ye(t,ue.AuthenticationTimeout):new ye(t,ue.ProtocolError)}processMsg(t,s){if(this.inMsgs++,this.inBytes+=s.length,!this.subscriptions.sidCounter)return;const i=this.subscriptions.get(t.sid);i&&(i.received+=1,i.callback&&i.callback(null,new im(t,s,this)),i.max!==void 0&&i.received>=i.max&&i.unsubscribe())}processError(t){const s=Ug(t),i=pu.toError(s),o={type:Mr.Error,data:i.code};if(i.isPermissionError()){let c=!1;if(i.permissionContext){o.permissionContext=i.permissionContext;const m=this.subscriptions.getMux();c=(m==null?void 0:m.subject)===i.permissionContext.subject}this.subscriptions.handleError(i),this.muxSubscriptions.handleError(c,i),c&&this.subscriptions.setMux(null)}this.dispatchStatus(o),this.handleError(i)}handleError(t){t.isAuthError()?this.handleAuthError(t):t.isProtocolError()?this.lastError=t:t.isAuthTimeout()&&(this.lastError=t),t.isPermissionError()||(this.lastError=t)}handleAuthError(t){this.lastError&&t.code===this.lastError.code&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(t):this.disconnect()}processPing(){this.transport.send(f2)}processPong(){const t=this.pongs.shift();t&&t.resolve()}processInfo(t){const s=JSON.parse(Ug(t));this.info=s;const i=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(s,this.transport.isEncrypted());if(!this.infoReceived){this.features.update(Zs(s.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:c,lang:m}=this.transport;try{const y=new h2({version:c,lang:m},this.options,s.nonce);s.headers&&(y.headers=!0,y.no_responders=!0);const g=JSON.stringify(y);this.transport.send(go(`CONNECT ${g}${nu}`)),this.transport.send(r1)}catch(y){this._close(y)}}i&&this.dispatchStatus({type:Mr.Update,data:i}),(s.ldm!==void 0?s.ldm:!1)&&this.dispatchStatus({type:Mr.LDM,data:this.servers.getCurrentServer().toString()})}push(t){switch(t.kind){case Jt.MSG:{const{msg:s,data:i}=t;this.processMsg(s,i);break}case Jt.OK:break;case Jt.ERR:this.processError(t.data);break;case Jt.PING:this.processPing();break;case Jt.PONG:this.processPong();break;case Jt.INFO:this.processInfo(t.data);break}}sendCommand(t,...s){const i=this.outbound.length();let o;typeof t=="string"?o=go(t):o=t,this.outbound.fill(o,...s),i===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(t,s=An,i){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=ei.encode(s);else throw ye.errorForCode(ue.BadPayload);let c=o.length;i=i||{},i.reply=i.reply||"";let m=An,y=0;if(i.headers){if(this.info&&!this.info.headers)throw new ye("headers",ue.ServerOptionNotAvailable);m=i.headers.encode(),y=m.length,c=o.length+y}if(this.info&&c>this.info.max_payload)throw ye.errorForCode(ue.MaxPayloadExceeded);this.outBytes+=c,this.outMsgs++;let g;i.headers?(i.reply?g=`HPUB ${t} ${i.reply} ${y} ${c}\r
39
+ `);class f2{constructor(t,s,i){j(this,"echo");j(this,"no_responders");j(this,"protocol");j(this,"verbose");j(this,"pedantic");j(this,"jwt");j(this,"nkey");j(this,"sig");j(this,"user");j(this,"pass");j(this,"auth_token");j(this,"tls_required");j(this,"name");j(this,"lang");j(this,"version");j(this,"headers");this.protocol=1,this.version=t.version,this.lang=t.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(i):{})||{};Su(this,o)}}class _x extends Bt{constructor(s,i,o={}){var m;super();j(this,"sid");j(this,"queue");j(this,"draining");j(this,"max");j(this,"subject");j(this,"drained");j(this,"protocol");j(this,"timer");j(this,"info");j(this,"cleanupFn");j(this,"closed");j(this,"requestSubject");Su(this,o),this.protocol=s,this.subject=i,this.draining=!1,this.noIterator=typeof o.callback=="function",this.closed=pt();const c=!((m=s.options)!=null&&m.noAsyncTraces);o.timeout&&(this.timer=ea(o.timeout,c),this.timer.then(()=>{this.timer=void 0}).catch(y=>{this.stop(y),this.noIterator&&this.callback(y,{})})),this.noIterator||this.iterClosed.then(()=>{this.closed.resolve(),this.unsubscribe()})}setPrePostHandlers(s){if(this.noIterator){const i=this.callback,o=s.ingestionFilterFn?s.ingestionFilterFn:()=>({ingest:!0,protocol:!1}),c=s.protocolFilterFn?s.protocolFilterFn:()=>!0,m=s.dispatchedFn?s.dispatchedFn:()=>{};this.callback=(y,g)=>{const{ingest:u}=o(g);u&&c(g)&&(i(y,g),m(g))}}else this.protocolFilterFn=s.protocolFilterFn,this.dispatchedFn=s.dispatchedFn}callback(s,i){this.cancelTimeout(),s?this.stop(s):this.push(i)}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(ye.errorForCode(ue.ConnectionClosed)):this.isClosed()?Promise.reject(ye.errorForCode(ue.SubClosed)):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush(pt()).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 h2{constructor(){j(this,"mux");j(this,"subs");j(this,"sidCounter");this.sidCounter=0,this.mux=null,this.subs=new Map}size(){return this.subs.size}add(t){return this.sidCounter++,t.sid=this.sidCounter,this.subs.set(t.sid,t),t}setMux(t){return this.mux=t,t}getMux(){return this.mux}get(t){return this.subs.get(t)}resub(t){return this.sidCounter++,this.subs.delete(t.sid),t.sid=this.sidCounter,this.subs.set(t.sid,t),t}all(){return Array.from(this.subs.values())}cancel(t){t&&(t.close(),this.subs.delete(t.sid))}handleError(t){if(t&&t.permissionContext){const s=t.permissionContext,i=this.all();let o;if(s.operation==="subscription"&&(o=i.find(c=>c.subject===s.subject&&c.queue===s.queue)),s.operation==="publish"&&(o=i.find(c=>c.requestSubject===s.subject)),o)return o.callback(t,{}),o.close(),this.subs.delete(o.sid),o!==this.mux}return!1}close(){this.subs.forEach(t=>{t.close()})}}class pu{constructor(t,s){j(this,"connected");j(this,"connectedOnce");j(this,"infoReceived");j(this,"info");j(this,"muxSubscriptions");j(this,"options");j(this,"outbound");j(this,"pongs");j(this,"subscriptions");j(this,"transport");j(this,"noMorePublishing");j(this,"connectError");j(this,"publisher");j(this,"_closed");j(this,"closed");j(this,"listeners");j(this,"heartbeats");j(this,"parser");j(this,"outMsgs");j(this,"inMsgs");j(this,"outBytes");j(this,"inBytes");j(this,"pendingLimit");j(this,"lastError");j(this,"abortReconnect");j(this,"whyClosed");j(this,"servers");j(this,"server");j(this,"features");j(this,"connectPromise");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=l2,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=t,this.publisher=s,this.subscriptions=new h2,this.muxSubscriptions=new KE,this.outbound=new na,this.pongs=[],this.whyClosed="",this.pendingLimit=t.pendingLimit||this.pendingLimit,this.features=new kE({major:0,minor:0,micro:0}),this.connectPromise=null;const i=typeof t.servers=="string"?[t.servers]:t.servers;this.servers=new YE(i,{randomize:!t.noRandomize}),this.closed=pt(),this.parser=new e1(this),this.heartbeats=new JE(this,this.options.pingInterval||xx,this.options.maxPingOut||r2)}resetOutbound(){this.outbound.reset();const t=this.pongs;this.pongs=[];const s=ye.errorForCode(ue.Disconnect);s.stack="",t.forEach(i=>{i.reject(s)}),this.parser=new e1(this),this.infoReceived=!1}dispatchStatus(t){this.listeners.forEach(s=>{s.push(t)})}status(){const t=new Bt;return this.listeners.push(t),t}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const t=pt();return t.catch(()=>{}),this.pongs.unshift(t),this.connectError=s=>{t.reject(s)},this.transport=CE(),this.transport.closed().then(async s=>{if(this.connected=!1,!this.isClosed()){await this.disconnected(this.transport.closeError||this.lastError);return}}),t}disconnect(){this.dispatchStatus({type:Yi.StaleConnection,data:""}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:Yi.ClientInitiatedReconnect,data:""}),this.transport.disconnect()),Promise.resolve()}async disconnected(t){this.dispatchStatus({type:Mr.Disconnect,data:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{var s;this.dispatchStatus({type:Mr.Reconnect,data:this.servers.getCurrentServer().toString()}),((s=this.lastError)==null?void 0:s.code)===ue.AuthenticationExpired&&(this.lastError=void 0)}).catch(s=>{this._close(s)}):await this._close(t)}async dial(t){const s=this.prepare();let i;try{i=ea(this.options.timeout||2e4);const o=this.transport.connect(t,this.options);await Promise.race([o,i]),(async()=>{try{for await(const c of this.transport)this.parser.parse(c)}catch(c){console.log("reader closed",c)}})().then()}catch(o){s.reject(o)}try{await Promise.race([i,s]),i&&i.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 i&&i.cancel(),await this.transport.close(o),o}}async _doDial(t){const{resolve:s}=this.options,i=await t.resolve({fn:Od(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:s});let o=null;for(const c of i)try{o=null,this.dispatchStatus({type:Yi.Reconnecting,data:c.toString()}),await this.dial(c);return}catch(m){o=m}throw o}dialLoop(){return this.connectPromise===null&&(this.connectPromise=this.dodialLoop(),this.connectPromise.then(()=>{}).catch(()=>{}).finally(()=>{this.connectPromise=null})),this.connectPromise}async dodialLoop(){let t;for(;;){this._closed&&this.servers.clear();const s=this.options.reconnectDelayHandler?this.options.reconnectDelayHandler():vx;let i=s;const o=this.selectServer();if(!o||this.abortReconnect)throw t||(this.lastError?this.lastError:ye.errorForCode(ue.ConnectionRefused));const c=Date.now();if(o.lastConnect===0||o.lastConnect+s<=c){o.lastConnect=Date.now();try{await this._doDial(o);break}catch(m){if(t=m,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}o.reconnects++;const y=this.options.maxReconnectAttempts||0;y!==-1&&o.reconnects>=y&&this.servers.removeCurrentServer()}}else i=Math.min(i,o.lastConnect+s-c),await sa(i)}}static async connect(t,s){const i=new pu(t,s);return await i.dialLoop(),i}static toError(t){const s=t?t.toLowerCase():"";if(s.indexOf("permissions violation")!==-1){const i=new ye(t,ue.PermissionsViolation),o=t.match(/(Publish|Subscription) to "(\S+)"/);if(o){i.permissionContext={operation:o[1].toLowerCase(),subject:o[2],queue:void 0};const c=t.match(/using queue "(\S+)"/);c&&(i.permissionContext.queue=c[1])}return i}else return s.indexOf("authorization violation")!==-1?new ye(t,ue.AuthorizationViolation):s.indexOf("user authentication expired")!==-1?new ye(t,ue.AuthenticationExpired):s.indexOf("account authentication expired")!=-1?new ye(t,ue.AccountExpired):s.indexOf("authentication timeout")!==-1?new ye(t,ue.AuthenticationTimeout):new ye(t,ue.ProtocolError)}processMsg(t,s){if(this.inMsgs++,this.inBytes+=s.length,!this.subscriptions.sidCounter)return;const i=this.subscriptions.get(t.sid);i&&(i.received+=1,i.callback&&i.callback(null,new im(t,s,this)),i.max!==void 0&&i.received>=i.max&&i.unsubscribe())}processError(t){const s=Ug(t),i=pu.toError(s),o={type:Mr.Error,data:i.code};if(i.isPermissionError()){let c=!1;if(i.permissionContext){o.permissionContext=i.permissionContext;const m=this.subscriptions.getMux();c=(m==null?void 0:m.subject)===i.permissionContext.subject}this.subscriptions.handleError(i),this.muxSubscriptions.handleError(c,i),c&&this.subscriptions.setMux(null)}this.dispatchStatus(o),this.handleError(i)}handleError(t){t.isAuthError()?this.handleAuthError(t):t.isProtocolError()?this.lastError=t:t.isAuthTimeout()&&(this.lastError=t),t.isPermissionError()||(this.lastError=t)}handleAuthError(t){this.lastError&&t.code===this.lastError.code&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(t):this.disconnect()}processPing(){this.transport.send(u2)}processPong(){const t=this.pongs.shift();t&&t.resolve()}processInfo(t){const s=JSON.parse(Ug(t));this.info=s;const i=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(s,this.transport.isEncrypted());if(!this.infoReceived){this.features.update(Zs(s.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:c,lang:m}=this.transport;try{const y=new f2({version:c,lang:m},this.options,s.nonce);s.headers&&(y.headers=!0,y.no_responders=!0);const g=JSON.stringify(y);this.transport.send(go(`CONNECT ${g}${nu}`)),this.transport.send(r1)}catch(y){this._close(y)}}i&&this.dispatchStatus({type:Mr.Update,data:i}),(s.ldm!==void 0?s.ldm:!1)&&this.dispatchStatus({type:Mr.LDM,data:this.servers.getCurrentServer().toString()})}push(t){switch(t.kind){case Jt.MSG:{const{msg:s,data:i}=t;this.processMsg(s,i);break}case Jt.OK:break;case Jt.ERR:this.processError(t.data);break;case Jt.PING:this.processPing();break;case Jt.PONG:this.processPong();break;case Jt.INFO:this.processInfo(t.data);break}}sendCommand(t,...s){const i=this.outbound.length();let o;typeof t=="string"?o=go(t):o=t,this.outbound.fill(o,...s),i===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(t,s=An,i){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=ei.encode(s);else throw ye.errorForCode(ue.BadPayload);let c=o.length;i=i||{},i.reply=i.reply||"";let m=An,y=0;if(i.headers){if(this.info&&!this.info.headers)throw new ye("headers",ue.ServerOptionNotAvailable);m=i.headers.encode(),y=m.length,c=o.length+y}if(this.info&&c>this.info.max_payload)throw ye.errorForCode(ue.MaxPayloadExceeded);this.outBytes+=c,this.outMsgs++;let g;i.headers?(i.reply?g=`HPUB ${t} ${i.reply} ${y} ${c}\r
40
40
  `:g=`HPUB ${t} ${y} ${c}\r
41
41
  `,this.sendCommand(g,m,o,mu)):(i.reply?g=`PUB ${t} ${i.reply} ${c}\r
42
42
  `:g=`PUB ${t} ${c}\r
@@ -44,24 +44,24 @@ ${this.ctx.stack}`),this.deferred.reject(s)):this.deferred.resolve(i),this.cance
44
44
  `):this.sendCommand(`SUB ${t.subject} ${t.sid}\r
45
45
  `)}_subunsub(t){return this._sub(t),t.max&&this.unsubscribe(t,t.max),t}unsubscribe(t,s){this.unsub(t,s),(t.max===void 0||t.received>=t.max)&&this.subscriptions.cancel(t)}unsub(t,s){!t||this.isClosed()||(s?this.sendCommand(`UNSUB ${t.sid} ${s}\r
46
46
  `):this.sendCommand(`UNSUB ${t.sid}\r
47
- `),t.max=s)}resub(t,s){!t||this.isClosed()||(this.unsub(t),t.subject=s,this.subscriptions.resub(t),this._sub(t))}flush(t){return t||(t=pt()),this.pongs.push(t),this.outbound.fill(r1),this.flushPending(),t}sendSubscriptions(){const t=[];this.subscriptions.all().forEach(s=>{const i=s;i.queue?t.push(`SUB ${i.subject} ${i.queue} ${i.sid}${nu}`):t.push(`SUB ${i.subject} ${i.sid}${nu}`)}),t.length&&this.transport.send(go(t.join("")))}async _close(t){this._closed||(this.whyClosed=new Error("close trace").stack||"",this.heartbeats.cancel(),this.connectError&&(this.connectError(t),this.connectError=void 0),this.muxSubscriptions.close(),this.subscriptions.close(),this.listeners.forEach(s=>{s.stop()}),this._closed=!0,await this.transport.close(t),await this.closed.resolve(t))}close(){return this._close()}isClosed(){return this._closed}drain(){const t=this.subscriptions.all(),s=[];return t.forEach(i=>{s.push(i.drain())}),Promise.all(s).then(async()=>(this.noMorePublishing=!0,await this.flush(),this.close())).catch(()=>{})}flushPending(){if(!(!this.infoReceived||!this.connected)&&this.outbound.size()){const t=this.outbound.drain();this.transport.send(t)}}initMux(){if(!this.subscriptions.getMux()){const s=this.muxSubscriptions.init(this.options.inboxPrefix),i=new wx(this,`${s}*`);i.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(i),this.subscribe(i)}}selectServer(){const t=this.servers.selectServer();if(t!==void 0)return this.server=t,this.server}getServer(){return this.server}}const m2="$SRV";class s1{constructor(t){j(this,"msg");this.msg=t}get data(){return this.msg.data}get sid(){return this.msg.sid}get subject(){return this.msg.subject}get reply(){return this.msg.reply||""}get headers(){return this.msg.headers}respond(t,s){return this.msg.respond(t,s)}respondError(t,s,i,o){var c,m;return o=o||{},o.headers=o.headers||Lr(),(c=o.headers)==null||c.set(uu,`${t}`),(m=o.headers)==null||m.set(cu,s),this.msg.respond(i,o)}json(t){return this.msg.json(t)}string(){return this.msg.string()}}class So{constructor(t,s="",i=""){j(this,"subject");j(this,"queue");j(this,"srv");s!==""&&y2("service group",s);let o="";if(t instanceof Co)this.srv=t,o="";else if(t instanceof So){const c=t;this.srv=c.srv,i===""&&c.queue!==""&&(i=c.queue),o=c.subject}else throw new Error("unknown ServiceGroup type");this.subject=this.calcSubject(o,s),this.queue=i}calcSubject(t,s=""){return s===""?t:t!==""?`${t}.${s}`:s}addEndpoint(t="",s){s=s||{subject:t};const i=typeof s=="function"?{handler:s,subject:t}:s;mo("endpoint",t);let{subject:o,handler:c,metadata:m,queue:y}=i;o=o||t,y=y||this.queue,p2("endpoint subject",o),o=this.calcSubject(this.subject,o);const g={name:t,subject:o,queue:y,handler:c,metadata:m};return this.srv._addEndpoint(g)}addGroup(t="",s=""){return new So(this,t,s)}}function p2(n,t){if(t==="")throw new Error(`${n} cannot be empty`);if(t.indexOf(" ")!==-1)throw new Error(`${n} cannot contain spaces: '${t}'`);const s=t.split(".");s.forEach((i,o)=>{if(i===">"&&o!==s.length-1)throw new Error(`${n} cannot have internal '>': '${t}'`)})}function y2(n,t){if(t.indexOf(" ")!==-1)throw new Error(`${n} cannot contain spaces: '${t}'`);t.split(".").forEach(i=>{if(i===">")throw new Error(`${n} name cannot contain internal '>': '${t}'`)})}class Co{constructor(t,s={name:"",version:""}){j(this,"nc");j(this,"_id");j(this,"config");j(this,"handlers");j(this,"internal");j(this,"_stopped");j(this,"_done");j(this,"started");this.nc=t,this.config=Object.assign({},s),this.config.queue||(this.config.queue="q"),mo("name",this.config.name),mo("queue",this.config.queue),Zs(this.config.version),this._id=Es.next(),this.internal=[],this._done=pt(),this._stopped=!1,this.handlers=[],this.started=new Date().toISOString(),this.reset(),this.nc.closed().then(()=>{this.close().catch()}).catch(i=>{this.close(i).catch()})}static controlSubject(t,s="",i="",o){const c=o??m2;return s===""&&i===""?`${c}.${t}`:(mo("control subject name",s),i!==""?(mo("control subject id",i),`${c}.${t}.${s}.${i}`):`${c}.${t}.${s}`)}get subjects(){return this.handlers.filter(t=>t.internal===!1).map(t=>t.subject)}get id(){return this._id}get name(){return this.config.name}get description(){return this.config.description??""}get version(){return this.config.version}get metadata(){return this.config.metadata}errorToHeader(t){const s=Lr();if(t instanceof fu){const i=t;s.set(cu,i.message),s.set(uu,`${i.code}`)}else s.set(cu,t.message),s.set(uu,"500");return s}setupHandler(t,s=!1){const i=s?"":t.queue?t.queue:this.config.queue,{name:o,subject:c,handler:m}=t,y=t;y.internal=s,s&&this.internal.push(y),y.stats=new g2(o,c,i),y.queue=i;const g=m?(u,d)=>{if(u){this.close(u);return}const b=Date.now();try{m(u,new s1(d))}catch(x){y.stats.countError(x),d==null||d.respond(An,{headers:this.errorToHeader(x)})}finally{y.stats.countLatency(b)}}:void 0;return y.sub=this.nc.subscribe(c,{callback:g,queue:i}),y.sub.closed.then(()=>{this._stopped||this.close(new Error(`required subscription ${t.subject} stopped`)).catch()}).catch(u=>{if(!this._stopped){const d=new Error(`required subscription ${t.subject} errored: ${u.message}`);d.stack=u.stack,this.close(d).catch()}}),y}info(){return{type:bo.INFO,name:this.name,id:this.id,version:this.version,description:this.description,metadata:this.metadata,endpoints:this.endpoints()}}endpoints(){return this.handlers.map(t=>{const{subject:s,metadata:i,name:o,queue:c}=t;return{subject:s,metadata:i,name:o,queue_group:c}})}async stats(){const t=[];for(const s of this.handlers){if(typeof this.config.statsHandler=="function")try{s.stats.data=await this.config.statsHandler(s)}catch(i){s.stats.countError(i)}t.push(s.stats.stats(s.qi))}return{type:bo.STATS,name:this.name,id:this.id,version:this.version,started:this.started,metadata:this.metadata,endpoints:t}}addInternalHandler(t,s){const i=`${t}`.toUpperCase();this._doAddInternalHandler(`${i}-all`,t,s),this._doAddInternalHandler(`${i}-kind`,t,s,this.name),this._doAddInternalHandler(`${i}`,t,s,this.name,this.id)}_doAddInternalHandler(t,s,i,o="",c=""){const m={};m.name=t,m.subject=Co.controlSubject(s,o,c),m.handler=i,this.setupHandler(m,!0)}start(){const t=Wn(),s=(m,y)=>m?(this.close(m),Promise.reject(m)):this.stats().then(g=>(y==null||y.respond(t.encode(g)),Promise.resolve())),i=(m,y)=>m?(this.close(m),Promise.reject(m)):(y==null||y.respond(t.encode(this.info())),Promise.resolve()),o=t.encode(this.ping()),c=(m,y)=>m?(this.close(m).then().catch(),Promise.reject(m)):(y.respond(o),Promise.resolve());return this.addInternalHandler(xs.PING,c),this.addInternalHandler(xs.STATS,s),this.addInternalHandler(xs.INFO,i),this.handlers.forEach(m=>{const{subject:y}=m;typeof y=="string"&&m.handler!==null&&this.setupHandler(m)}),Promise.resolve(this)}close(t){if(this._stopped)return this._done;this._stopped=!0;let s=[];return this.nc.isClosed()||(s=this.handlers.concat(this.internal).map(i=>i.sub.drain())),Promise.allSettled(s).then(()=>{this._done.resolve(t||null)}),this._done}get stopped(){return this._done}get isStopped(){return this._stopped}stop(t){return this.close(t)}ping(){return{type:bo.PING,name:this.name,id:this.id,version:this.version,metadata:this.metadata}}reset(){if(this.started=new Date().toISOString(),this.handlers)for(const t of this.handlers)t.stats.reset(t.qi)}addGroup(t,s){return new So(this,t,s)}addEndpoint(t,s){return new So(this).addEndpoint(t,s)}_addEndpoint(t){const s=new Bt;s.noIterator=typeof t.handler=="function",s.noIterator||(t.handler=(o,c)=>{o?this.stop(o).catch():s.push(new s1(c))},s.iterClosed.then(()=>{this.close().catch()}));const i=this.setupHandler(t,!1);return i.qi=s,this.handlers.push(i),s}}class g2{constructor(t,s,i=""){j(this,"name");j(this,"subject");j(this,"average_processing_time");j(this,"num_requests");j(this,"processing_time");j(this,"num_errors");j(this,"last_error");j(this,"data");j(this,"metadata");j(this,"queue");this.name=t,this.subject=s,this.average_processing_time=0,this.num_errors=0,this.num_requests=0,this.processing_time=0,this.queue=i}reset(t){this.num_requests=0,this.processing_time=0,this.average_processing_time=0,this.num_errors=0,this.last_error=void 0,this.data=void 0;const s=t;s&&(s.time=0,s.processed=0)}countLatency(t){this.num_requests++,this.processing_time+=mt(Date.now()-t),this.average_processing_time=Math.round(this.processing_time/this.num_requests)}countError(t){this.num_errors++,this.last_error=t.message}_stats(){const{name:t,subject:s,average_processing_time:i,num_errors:o,num_requests:c,processing_time:m,last_error:y,data:g,queue:u}=this;return{name:t,subject:s,average_processing_time:i,num_errors:o,num_requests:c,processing_time:m,last_error:y,data:g,queue_group:u}}stats(t){const s=t;return(s==null?void 0:s.noIterator)===!1&&(this.processing_time=mt(s.time),this.num_requests=s.processed,this.average_processing_time=this.processing_time>0&&this.num_requests>0?this.processing_time/this.num_requests:0),this._stats()}}class b2{constructor(t,s={strategy:Qn.JitterTimer,maxWait:2e3},i){j(this,"nc");j(this,"prefix");j(this,"opts");this.nc=t,this.prefix=i,this.opts=s}ping(t="",s=""){return this.q(xs.PING,t,s)}stats(t="",s=""){return this.q(xs.STATS,t,s)}info(t="",s=""){return this.q(xs.INFO,t,s)}async q(t,s="",i=""){const o=new Bt,c=Wn(),m=Co.controlSubject(t,s,i,this.prefix),y=await this.nc.requestMany(m,An,this.opts);return(async()=>{for await(const g of y)try{const u=c.decode(g.data);o.push(u)}catch(u){o.push(()=>{o.stop(u)})}o.push(()=>{o.stop()})})().catch(g=>{o.stop(g)}),o}}function Sx(){return{key:{encode(n){return n},decode(n){return n}},value:{encode(n){return n},decode(n){return n}}}}function x2(){return{replicas:1,history:1,timeout:2e3,max_bytes:-1,maxValueSize:-1,codec:Sx(),storage:wd.File}}const yu="KV-Operation",i1="$KV",v2=/^[-/=.\w]+$/,_2=/^[-/=.>*\w]+$/,w2=/^[-\w]+$/;function S2(n){if(n.startsWith(".")||n.endsWith(".")||!v2.test(n))throw new Error(`invalid key: ${n}`)}function E2(n){if(n.startsWith(".")||n.endsWith(".")||!_2.test(n))throw new Error(`invalid key: ${n}`)}function O2(n){if(n.startsWith(".")||n.endsWith("."))throw new Error(`invalid key: ${n}`);const t=n.split(".");let s=!1;for(let i=0;i<t.length;i++)switch(t[i]){case"*":s=!0;break;case">":if(i!==t.length-1)throw new Error(`invalid key: ${n}`);s=!0;break}return s}function ru(n){if(!w2.test(n))throw new Error(`invalid bucket name: ${n}`)}var ir;(function(n){n.MsgIdHdr="Nats-Msg-Id",n.ExpectedStreamHdr="Nats-Expected-Stream",n.ExpectedLastSeqHdr="Nats-Expected-Last-Sequence",n.ExpectedLastMsgIdHdr="Nats-Expected-Last-Msg-Id",n.ExpectedLastSubjectSequenceHdr="Nats-Expected-Last-Subject-Sequence"})(ir||(ir={}));class Eo{constructor(t,s,i){j(this,"js");j(this,"jsm");j(this,"stream");j(this,"bucket");j(this,"direct");j(this,"codec");j(this,"prefix");j(this,"editPrefix");j(this,"useJsPrefix");j(this,"_prefixLen");j(this,"validateKey",S2);j(this,"validateSearchKey",E2);j(this,"hasWildcards",O2);ru(t),this.js=s,this.jsm=i,this.bucket=t,this.prefix=i1,this.editPrefix="",this.useJsPrefix=!1,this._prefixLen=0}static async create(t,s,i={}){ru(s);const o=await t.jetstreamManager(),c=new Eo(s,t,o);return await c.init(i),c}static async bind(t,s,i={}){const o=await t.jetstreamManager(),c={config:{allow_direct:i.allow_direct}};ru(s);const m=new Eo(s,t,o);return c.config.name=i.streamName??m.bucketName(),Object.assign(m,c),m.stream=c.config.name,m.codec=i.codec||Sx(),m.direct=c.config.allow_direct??!1,m.initializePrefixes(c),m}async init(t={}){const s=Object.assign(x2(),t);this.codec=s.codec;const i={};this.stream=i.name=t.streamName??this.bucketName(),i.retention=_d.Limits,i.max_msgs_per_subject=s.history,s.maxBucketSize&&(s.max_bytes=s.maxBucketSize),s.max_bytes&&(i.max_bytes=s.max_bytes),i.max_msg_size=s.maxValueSize,i.storage=s.storage;const o=t.placementCluster??"";if(o&&(t.placement={},t.placement.cluster=o,t.placement.tags=[]),t.placement&&(i.placement=t.placement),t.republish&&(i.republish=t.republish),t.description&&(i.description=t.description),t.mirror){const b=Object.assign({},t.mirror);b.name.startsWith(_n)||(b.name=`${_n}${b.name}`),i.mirror=b,i.mirror_direct=!0}else if(t.sources){const b=t.sources.map(x=>{const v=Object.assign({},x),w=v.name.startsWith(_n)?v.name.substring(_n.length):v.name;return v.name.startsWith(_n)||(v.name=`${_n}${v.name}`),!x.external&&w!==this.bucket&&(v.subject_transforms=[{src:`$KV.${w}.>`,dest:`$KV.${this.bucket}.>`}]),v});i.sources=b,i.subjects=[this.subjectForBucket()]}else i.subjects=[this.subjectForBucket()];t.metadata&&(i.metadata=t.metadata),typeof t.compression=="boolean"&&(i.compression=t.compression?Os.S2:Os.None);const c=this.js.nc,m=c.getServerVersion(),y=m?Ed(m,Zs("2.7.2"))>=0:!1;i.discard=y?wo.New:wo.Old;const{ok:g,min:u}=c.features.get(Ke.JS_ALLOW_DIRECT);if(!g&&t.allow_direct===!0){const b=m?`${m.major}.${m.minor}.${m.micro}`:"unknown";return Promise.reject(new Error(`allow_direct is not available on server version ${b} - requires ${u}`))}t.allow_direct=typeof t.allow_direct=="boolean"?t.allow_direct:g,i.allow_direct=t.allow_direct,this.direct=i.allow_direct,i.num_replicas=s.replicas,s.ttl&&(i.max_age=mt(s.ttl)),i.allow_rollup_hdrs=!0;let d;try{d=await this.jsm.streams.info(i.name),!d.config.allow_direct&&this.direct===!0&&(this.direct=!1)}catch(b){if(b.message==="stream not found")d=await this.jsm.streams.add(i);else throw b}this.initializePrefixes(d)}initializePrefixes(t){this._prefixLen=0,this.prefix=`$KV.${this.bucket}`,this.useJsPrefix=this.js.apiPrefix!=="$JS.API";const{mirror:s}=t.config;if(s){let i=s.name;if(i.startsWith(_n)&&(i=i.substring(_n.length)),s.external&&s.external.api!==""){const o=s.name.substring(_n.length);this.useJsPrefix=!1,this.prefix=`$KV.${o}`,this.editPrefix=`${s.external.api}.$KV.${i}`}else this.editPrefix=this.prefix}}bucketName(){return this.stream??`${_n}${this.bucket}`}subjectForBucket(){return`${this.prefix}.${this.bucket}.>`}subjectForKey(t,s=!1){const i=[];return s?(this.useJsPrefix&&i.push(this.js.apiPrefix),this.editPrefix!==""?i.push(this.editPrefix):i.push(this.prefix)):this.prefix&&i.push(this.prefix),i.push(t),i.join(".")}fullKeyName(t){return this.prefix!==""?`${this.prefix}.${t}`:`${i1}.${this.bucket}.${t}`}get prefixLen(){return this._prefixLen===0&&(this._prefixLen=this.prefix.length+1),this._prefixLen}encodeKey(t){const s=[];for(const i of t.split("."))switch(i){case">":case"*":s.push(i);break;default:s.push(this.codec.key.encode(i));break}return s.join(".")}decodeKey(t){const s=[];for(const i of t.split("."))switch(i){case">":case"*":s.push(i);break;default:s.push(this.codec.key.decode(i));break}return s.join(".")}close(){return Promise.resolve()}dataLen(t,s){const i=s&&s.get(Qt.MessageSizeHdr)||"";return i!==""?parseInt(i,10):t.length}smToEntry(t){return new z2(this.bucket,this.prefixLen,t)}jmToEntry(t){const s=this.decodeKey(t.subject.substring(this.prefixLen));return new I2(this.bucket,s,t)}async create(t,s){var c;let i;try{const m=await this.put(t,s,{previousSeq:0});return Promise.resolve(m)}catch(m){if(i=m,((c=m==null?void 0:m.api_error)==null?void 0:c.err_code)!==10071)return Promise.reject(m)}let o=0;try{const m=await this.get(t);return(m==null?void 0:m.operation)==="DEL"||(m==null?void 0:m.operation)==="PURGE"?(o=m!==null?m.revision:0,this.update(t,s,o)):Promise.reject(i)}catch(m){return Promise.reject(m)}}update(t,s,i){if(i<=0)throw new Error("version must be greater than 0");return this.put(t,s,{previousSeq:i})}async put(t,s,i={}){var m,y;const o=this.encodeKey(t);this.validateKey(o);const c={};if(i.previousSeq!==void 0){const g=Lr();c.headers=g,g.set(ir.ExpectedLastSubjectSequenceHdr,`${i.previousSeq}`)}try{return(await this.js.publish(this.subjectForKey(o,!0),s,c)).seq}catch(g){const u=g;return u.isJetStreamError()?(u.message=(m=u.api_error)==null?void 0:m.description,u.code=`${(y=u.api_error)==null?void 0:y.code}`,Promise.reject(u)):Promise.reject(g)}}async get(t,s){const i=this.encodeKey(t);this.validateKey(i);let o={last_by_subj:this.subjectForKey(i)};s&&s.revision>0&&(o={seq:s.revision});let c;try{this.direct?c=await this.jsm.direct.getMessage(this.bucketName(),o):c=await this.jsm.streams.getMessage(this.bucketName(),o);const m=this.smToEntry(c);return m.key!==i?null:m}catch(m){if(m.code===ue.JetStream404NoMessages)return null;throw m}}purge(t,s){return this._deleteOrPurge(t,"PURGE",s)}delete(t,s){return this._deleteOrPurge(t,"DEL",s)}async purgeDeletes(t=1800*1e3){const s=pt(),i=[],o=await this.watch({key:">",initializedFn:()=>{s.resolve()}});(async()=>{for await(const g of o)(g.operation==="DEL"||g.operation==="PURGE")&&i.push(g)})().then(),await s,o.stop();const c=Date.now()-t,m=i.map(g=>{const u=this.subjectForKey(g.key);return g.created.getTime()>=c?this.jsm.streams.purge(this.stream,{filter:u,keep:1}):this.jsm.streams.purge(this.stream,{filter:u,keep:0})}),y=await Promise.all(m);return y.unshift({success:!0,purged:0}),y.reduce((g,u)=>(g.purged+=u.purged,g))}async _deleteOrPurge(t,s,i){if(!this.hasWildcards(t))return this._doDeleteOrPurge(t,s,i);const o=await this.keys(t),c=[];for await(const m of o)c.push(this._doDeleteOrPurge(m,s)),c.length===100&&(await Promise.all(c),c.length=0);c.length>0&&await Promise.all(c)}async _doDeleteOrPurge(t,s,i){const o=this.encodeKey(t);this.validateKey(o);const c=Lr();c.set(yu,s),s==="PURGE"&&c.set(Qt.RollupHdr,Qt.RollupValueSubject),i!=null&&i.previousSeq&&c.set(ir.ExpectedLastSubjectSequenceHdr,`${i.previousSeq}`),await this.js.publish(this.subjectForKey(o,!0),An,{headers:c})}_buildCC(t,s,i={}){let c=(Array.isArray(t)?t:[t]).map(g=>{const u=this.encodeKey(g);return this.validateSearchKey(g),this.fullKeyName(u)}),m=Et.LastPerSubject;s===Jn.AllHistory&&(m=Et.All),s===Jn.UpdatesOnly&&(m=Et.New);let y;return c.length===1&&(y=c[0],c=void 0),Object.assign({deliver_policy:m,ack_policy:qt.None,filter_subjects:c,filter_subject:y,flow_control:!0,idle_heartbeat:mt(5*1e3)},i)}remove(t){return this.purge(t)}async history(t={}){const s=t.key??">",i=new Bt,o={};o.headers_only=t.headers_only||!1;let c;c=()=>{i.stop()};let m=0;const y=this._buildCC(s,Jn.AllHistory,o),g=y.filter_subject,u=_s(y);u.bindStream(this.stream),u.orderedConsumer(),u.callback((b,x)=>{if(b){i.stop(b);return}if(x){const v=this.jmToEntry(x);i.push(v),i.received++,(c&&m>0&&i.received>=m||x.info.pending===0)&&(i.push(c),c=void 0)}});const d=await this.js.subscribe(g,u);if(c){const{info:{last:b}}=d,x=b.num_pending+b.delivered.consumer_seq;if(x===0||i.received>=x)try{c()}catch(v){i.stop(v)}finally{c=void 0}else m=x}return i._data=d,i.iterClosed.then(()=>{d.unsubscribe()}),d.closed.then(()=>{i.stop()}).catch(b=>{i.stop(b)}),i}canSetWatcherName(){const s=this.js.nc,{ok:i}=s.features.get(Ke.JS_NEW_CONSUMER_CREATE_API);return i}async watch(t={}){const s=t.key??">",i=new Bt,o={};o.headers_only=t.headers_only||!1;let c=Jn.LastValue;t.include===Jn.AllHistory?c=Jn.AllHistory:t.include===Jn.UpdatesOnly&&(c=Jn.UpdatesOnly);const m=t.ignoreDeletes===!0;let y=t.initializedFn,g=0;const u=this._buildCC(s,c,o),d=u.filter_subject,b=_s(u);this.canSetWatcherName()&&b.consumerName(Es.next()),b.bindStream(this.stream),t.resumeFromRevision&&t.resumeFromRevision>0&&b.startSequence(t.resumeFromRevision),b.orderedConsumer(),b.callback((v,w)=>{if(v){i.stop(v);return}if(w){const S=this.jmToEntry(w);if(m&&S.operation==="DEL")return;i.push(S),i.received++,y&&(g>0&&i.received>=g||w.info.pending===0)&&(i.push(y),y=void 0)}});const x=await this.js.subscribe(d,b);if(y){const{info:{last:v}}=x,w=v.num_pending+v.delivered.consumer_seq;if(w===0||i.received>=w)try{y()}catch(S){i.stop(S)}finally{y=void 0}else g=w}return i._data=x,i.iterClosed.then(()=>{x.unsubscribe()}),x.closed.then(()=>{i.stop()}).catch(v=>{i.stop(v)}),i}async keys(t=">"){const s=new Bt,i=this._buildCC(t,Jn.LastValue,{headers_only:!0}),o=Array.isArray(t)?">":i.filter_subject,c=_s(i);c.bindStream(this.stream),c.orderedConsumer();const m=await this.js.subscribe(o,c);return(async()=>{var g;for await(const u of m){const d=(g=u.headers)==null?void 0:g.get(yu);if(d!=="DEL"&&d!=="PURGE"){const b=this.decodeKey(u.subject.substring(this.prefixLen));s.push(b)}u.info.pending===0&&m.unsubscribe()}})().then(()=>{s.stop()}).catch(g=>{s.stop(g)}),m.info.last.num_pending===0&&m.unsubscribe(),s}purgeBucket(t){return this.jsm.streams.purge(this.bucketName(),t)}destroy(){return this.jsm.streams.delete(this.bucketName())}async status(){var c;const s=((c=this.js.nc.info)==null?void 0:c.cluster)??"",i=this.bucketName(),o=await this.jsm.streams.info(i);return new Ex(o,s)}}class Ex{constructor(t,s=""){j(this,"si");j(this,"cluster");this.si=t,this.cluster=s}get bucket(){return this.si.config.name.startsWith(_n)?this.si.config.name.substring(_n.length):this.si.config.name}get values(){return this.si.state.messages}get history(){return this.si.config.max_msgs_per_subject}get ttl(){return sm(this.si.config.max_age)}get bucket_location(){return this.cluster}get backingStore(){return this.si.config.storage}get storage(){return this.si.config.storage}get replicas(){return this.si.config.num_replicas}get description(){return this.si.config.description??""}get maxBucketSize(){return this.si.config.max_bytes}get maxValueSize(){return this.si.config.max_msg_size}get max_bytes(){return this.si.config.max_bytes}get placement(){return this.si.config.placement||{cluster:"",tags:[]}}get placementCluster(){var t;return((t=this.si.config.placement)==null?void 0:t.cluster)??""}get republish(){return this.si.config.republish??{src:"",dest:""}}get streamInfo(){return this.si}get size(){return this.si.state.bytes}get metadata(){return this.si.config.metadata??{}}get compression(){return this.si.config.compression?this.si.config.compression!==Os.None:!1}}const om="OBJ_",a1="SHA-256=";function A2(n){return ru(n),`${om}${n}`}function j2(n){return n.startsWith(om)?n.substring(4):n}class kd{constructor(t){j(this,"si");j(this,"backingStore");this.si=t,this.backingStore="JetStream"}get bucket(){return j2(this.si.config.name)}get description(){return this.si.config.description??""}get ttl(){return this.si.config.max_age}get storage(){return this.si.config.storage}get replicas(){return this.si.config.num_replicas}get sealed(){return this.si.config.sealed}get size(){return this.si.state.bytes}get streamInfo(){return this.si}get metadata(){return this.si.config.metadata}get compression(){return this.si.config.compression?this.si.config.compression!==Os.None:!1}}function oc(n){if(n===void 0)return;const{domain:t}=n;if(t===void 0)return n;const s=Object.assign({},n);if(delete s.domain,t==="")return s;if(s.external)throw new Error("domain and external are both set");return s.external={api:`$JS.${t}.API`},s}var Un;(function(n){n[n.Unset=-1]="Unset",n[n.Consume=0]="Consume",n[n.Fetch=1]="Fetch"})(Un||(Un={}));var ar;(function(n){n.HeartbeatsMissed="heartbeats_missed",n.ConsumerNotFound="consumer_not_found",n.StreamNotFound="stream_not_found",n.ConsumerDeleted="consumer_deleted",n.OrderedConsumerRecreated="ordered_consumer_recreated",n.NoResponders="no_responders"})(ar||(ar={}));var Qi;(function(n){n.DebugEvent="debug",n.Discard="discard",n.Reset="reset",n.Next="next"})(Qi||(Qi={}));const o1=Uint8Array.of(43,65,67,75),k2=Uint8Array.of(45,78,65,75),ro=Uint8Array.of(43,87,80,73),N2=Uint8Array.of(43,78,88,84),T2=Uint8Array.of(43,84,69,82,77),C2=Uint8Array.of(32);function Oo(n,t=5e3){return new K2(n,t)}class ed extends Bt{constructor(s,i,o=!1){super();j(this,"consumer");j(this,"opts");j(this,"sub");j(this,"monitor");j(this,"pending");j(this,"inbox");j(this,"refilling");j(this,"pong");j(this,"callback");j(this,"timeout");j(this,"cleanupHandler");j(this,"listeners");j(this,"statusIterator");j(this,"forOrderedConsumer");j(this,"resetHandler");j(this,"abortOnMissingResource");j(this,"bind");j(this,"inBackOff");this.consumer=s;const c=i;this.opts=this.parseOptions(i,o),this.callback=c.callback||null,this.noIterator=typeof this.callback=="function",this.monitor=null,this.pong=null,this.pending={msgs:0,bytes:0,requests:0},this.refilling=o,this.timeout=null,this.inbox=Rr(s.api.nc.options.inboxPrefix),this.listeners=[],this.forOrderedConsumer=!1,this.abortOnMissingResource=c.abort_on_missing_resource===!0,this.bind=c.bind===!0,this.inBackOff=!1,this.start()}start(){const{max_messages:s,max_bytes:i,idle_heartbeat:o,threshold_bytes:c,threshold_messages:m}=this.opts;this.closed().then(g=>{if(this.cleanupHandler)try{this.cleanupHandler(g)}catch{}});const{sub:y}=this;y&&y.unsubscribe(),this.sub=this.consumer.api.nc.subscribe(this.inbox,{callback:(g,u)=>{var b,x,v,w;if(g){this.stop(g);return}if((b=this.monitor)==null||b.work(),u.subject===this.inbox){if(vd(u))return;const S=(x=u.headers)==null?void 0:x.code,C=((w=(v=u.headers)==null?void 0:v.description)==null?void 0:w.toLowerCase())||"unknown",{msgsLeft:q,bytesLeft:B}=this.parseDiscard(u.headers);if(q>0||B>0)this.pending.msgs-=q,this.pending.bytes-=B,this.pending.requests--,this.notify(Qi.Discard,{msgsLeft:q,bytesLeft:B});else if(S===400){this.stop(new ye(C,`${S}`));return}else if(S===409&&C==="consumer deleted"){if(this.notify(ar.ConsumerDeleted,`${S} ${C}`),!this.refilling||this.abortOnMissingResource){const ie=new ye(C,`${S}`);this.stop(ie);return}}else if(S===503){if(this.notify(ar.NoResponders,`${S} No Responders`),!this.refilling||this.abortOnMissingResource){const ie=new ye("no responders",`${S}`);this.stop(ie);return}}else this.notify(Qi.DebugEvent,`${S} ${C}`)}else this._push(Oo(u,this.consumer.api.timeout)),this.received++,this.pending.msgs&&this.pending.msgs--,this.pending.bytes&&(this.pending.bytes-=u.size());if(this.pending.msgs===0&&this.pending.bytes===0&&(this.pending.requests=0),this.refilling){if(s&&this.pending.msgs<=m||i&&this.pending.bytes<=c){const S=this.pullOptions();this.pull(S)}}else this.pending.requests===0&&this._push(()=>{this.stop()})}}),this.sub.closed.then(()=>{this.sub.draining&&this._push(()=>{this.stop()})}),o&&(this.monitor=new am(o,g=>(this.notify(ar.HeartbeatsMissed,g),this.resetPending().then(()=>{}).catch(()=>{}),!1),{maxOut:2})),(async()=>{var u;const g=this.consumer.api.nc.status();this.statusIterator=g;for await(const d of g)switch(d.type){case Mr.Disconnect:(u=this.monitor)==null||u.cancel();break;case Mr.Reconnect:this.resetPending().then(b=>{var x;b&&((x=this.monitor)==null||x.restart())}).catch(()=>{});break}})(),this.pull(this.pullOptions())}_push(s){if(!this.callback)super.push(s);else{const i=typeof s=="function"?s:null;try{i?i():this.callback(s)}catch(o){this.stop(o)}}}notify(s,i){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:i})})}resetPending(){return this.bind?this.resetPendingNoInfo():this.resetPendingWithInfo()}resetPendingNoInfo(){return this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),Promise.resolve(!0)}async resetPendingWithInfo(){if(this.inBackOff)return!1;let s=0,i=0;const o=rm([this.opts.expires]);let c=0;for(;;){if(this.done)return!1;if(this.consumer.api.nc.isClosed())return console.error("aborting resetPending - connection is closed"),!1;try{return await this.consumer.info(),this.inBackOff=!1,s=0,this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),!0}catch(m){if(m.message==="stream not found"){if(i++,this.notify(ar.StreamNotFound,i),!this.refilling||this.abortOnMissingResource)return this.stop(m),!1}else if(m.message==="consumer not found"){if(s++,this.notify(ar.ConsumerNotFound,s),this.resetHandler)try{this.resetHandler()}catch{}if(!this.refilling||this.abortOnMissingResource)return this.stop(m),!1;if(this.forOrderedConsumer)return!1}else s=0,i=0;this.inBackOff=!0;const y=o.backoff(c),g=sa(y);await Promise.race([g,this.consumer.api.nc.closed()]),g.cancel(),c++}}}pull(s){this.pending.bytes+=s.max_bytes??0,this.pending.msgs+=s.batch??0,this.pending.requests++;const i=this.consumer.api.nc;this._push(()=>{i.publish(`${this.consumer.api.prefix}.CONSUMER.MSG.NEXT.${this.consumer.stream}.${this.consumer.name}`,this.consumer.api.jc.encode(s),{reply:this.inbox}),this.notify(Qi.Next,s)})}pullOptions(){const s=this.opts.max_messages-this.pending.msgs,i=this.opts.max_bytes-this.pending.bytes,o=mt(this.opts.idle_heartbeat),c=mt(this.opts.expires);return{batch:s,max_bytes:i,idle_heartbeat:o,expires:c}}parseDiscard(s){const i={msgsLeft:0,bytesLeft:0},o=s==null?void 0:s.get(Qt.PendingMessagesHdr);o&&(i.msgsLeft=parseInt(o));const c=s==null?void 0:s.get(Qt.PendingBytesHdr);return c&&(i.bytesLeft=parseInt(c)),i}trackTimeout(s){this.timeout=s}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}clearTimers(){var s,i;(s=this.monitor)==null||s.cancel(),this.monitor=null,(i=this.timeout)==null||i.cancel(),this.timeout=null}setCleanupHandler(s){this.cleanupHandler=s}stop(s){var i,o;this.done||((i=this.sub)==null||i.unsubscribe(),this.clearTimers(),(o=this.statusIterator)==null||o.stop(),this._push(()=>{super.stop(s),this.listeners.forEach(c=>{c.stop()})}))}parseOptions(s,i=!1){const o=s||{};if(o.max_messages=o.max_messages||0,o.max_bytes=o.max_bytes||0,o.max_messages!==0&&o.max_bytes!==0)throw new Error("only specify one of max_messages or max_bytes");if(o.max_messages===0&&(o.max_messages=100),o.expires=o.expires||3e4,o.expires<1e3)throw new Error("expires should be at least 1000ms");if(o.idle_heartbeat=o.idle_heartbeat||o.expires/2,o.idle_heartbeat=o.idle_heartbeat>3e4?3e4:o.idle_heartbeat,i){const c=Math.round(o.max_messages*.75)||1;o.threshold_messages=o.threshold_messages||c;const m=Math.round(o.max_bytes*.75)||1;o.threshold_bytes=o.threshold_bytes||m}return o}status(){const s=new Bt;return this.listeners.push(s),Promise.resolve(s)}}class M2 extends Bt{constructor(){super();j(this,"src");j(this,"listeners");this.listeners=[]}setSource(s){this.src&&(this.src.resetHandler=void 0,this.src.setCleanupHandler(),this.src.stop()),this.src=s,this.src.setCleanupHandler(i=>{this.stop(i||void 0)}),(async()=>{const i=await this.src.status();for await(const o of i)this.notify(o.type,o.data)})().catch(()=>{})}notify(s,i){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:i})})}stop(s){var i;this.done||((i=this.src)==null||i.stop(s),super.stop(s),this.listeners.forEach(o=>{o.stop()}))}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}status(){const s=new Bt;return this.listeners.push(s),Promise.resolve(s)}}class Nd{constructor(t,s){j(this,"api");j(this,"_info");j(this,"stream");j(this,"name");this.api=t,this._info=s,this.stream=s.stream_name,this.name=s.name}consume(t={max_messages:100,expires:3e4}){return Promise.resolve(new ed(this,t,!0))}fetch(t={max_messages:100,expires:3e4}){const s=new ed(this,t,!1),i=Math.round(s.opts.expires*1.05),o=ea(i);return s.closed().catch(()=>{}).finally(()=>{o.cancel()}),o.catch(()=>{s.close().catch()}),s.trackTimeout(o),Promise.resolve(s)}next(t={expires:3e4}){const s=pt(),i=t;i.max_messages=1;const o=new ed(this,i,!1),c=Math.round(o.opts.expires*1.05);c>=6e4&&(async()=>{for await(const y of await o.status())if(y.type===ar.HeartbeatsMissed&&y.data>=2){s.reject(new Error("consumer missed heartbeats"));break}})().catch(),(async()=>{for await(const y of o){s.resolve(y);break}})().catch(()=>{});const m=ea(c);return o.closed().then(y=>{y?s.reject(y):s.resolve(null)}).catch(y=>{s.reject(y)}).finally(()=>{m.cancel()}),m.catch(y=>{s.resolve(null),o.close().catch()}),o.trackTimeout(m),s}delete(){const{stream_name:t,name:s}=this._info;return this.api.delete(t,s)}info(t=!1){if(t)return Promise.resolve(this._info);const{stream_name:s,name:i}=this._info;return this.api.info(s,i).then(o=>(this._info=o,this._info))}}class R2{constructor(t,s,i={}){j(this,"api");j(this,"consumerOpts");j(this,"consumer");j(this,"opts");j(this,"cursor");j(this,"stream");j(this,"namePrefix");j(this,"serial");j(this,"currentConsumer");j(this,"userCallback");j(this,"iter");j(this,"type");j(this,"startSeq");j(this,"maxInitialReset");this.api=t,this.stream=s,this.cursor={stream_seq:1,deliver_seq:0},this.namePrefix=Es.next(),typeof i.name_prefix=="string"&&(Eu("name_prefix",i.name_prefix),this.namePrefix=i.name_prefix+this.namePrefix),this.serial=0,this.currentConsumer=null,this.userCallback=null,this.iter=null,this.type=Un.Unset,this.consumerOpts=i,this.maxInitialReset=30,this.startSeq=this.consumerOpts.opt_start_seq||0,this.cursor.stream_seq=this.startSeq>0?this.startSeq-1:0}getConsumerOpts(t){this.serial++;const s=`${this.namePrefix}_${this.serial}`;t=t===0?1:t;const i={name:s,deliver_policy:Et.StartSequence,opt_start_seq:t,ack_policy:qt.None,inactive_threshold:mt(300*1e3),num_replicas:1};return this.consumerOpts.headers_only===!0&&(i.headers_only=!0),Array.isArray(this.consumerOpts.filterSubjects)&&(i.filter_subjects=this.consumerOpts.filterSubjects),typeof this.consumerOpts.filterSubjects=="string"&&(i.filter_subject=this.consumerOpts.filterSubjects),this.consumerOpts.replay_policy&&(i.replay_policy=this.consumerOpts.replay_policy),t===this.startSeq+1&&(i.deliver_policy=this.consumerOpts.deliver_policy||Et.StartSequence,(this.consumerOpts.deliver_policy===Et.LastPerSubject||this.consumerOpts.deliver_policy===Et.New||this.consumerOpts.deliver_policy===Et.Last)&&(delete i.opt_start_seq,i.deliver_policy=this.consumerOpts.deliver_policy),i.deliver_policy===Et.LastPerSubject&&typeof i.filter_subjects>"u"&&typeof i.filter_subject>"u"&&(i.filter_subject=">"),this.consumerOpts.opt_start_time&&(delete i.opt_start_seq,i.deliver_policy=Et.StartTime,i.opt_start_time=this.consumerOpts.opt_start_time),this.consumerOpts.inactive_threshold&&(i.inactive_threshold=mt(this.consumerOpts.inactive_threshold))),i}async resetConsumer(t=0){var m,y,g,u,d;Es.next();const s=this.serial===0;(m=this.consumer)==null||m.delete().catch(()=>{}),t=t===0?1:t,this.cursor.deliver_seq=0;const i=this.getConsumerOpts(t);i.max_deliver=1,i.mem_storage=!0;const o=rm([((y=this.opts)==null?void 0:y.expires)||3e4]);let c;for(let b=0;;b++)try{c=await this.api.add(this.stream,i),(g=this.iter)==null||g.notify(ar.OrderedConsumerRecreated,c.name);break}catch(x){if(x.message==="stream not found"&&((u=this.iter)==null||u.notify(ar.StreamNotFound,b),this.type===Un.Fetch||this.opts.abort_on_missing_resource===!0))return(d=this.iter)==null||d.stop(x),Promise.reject(x);if(s&&b>=this.maxInitialReset)throw x;await sa(o.backoff(b+1))}return c}internalHandler(t){return s=>{var o;if(this.serial!==t)return;const i=s.info.deliverySequence;if(i!==this.cursor.deliver_seq+1){this.notifyOrderedResetAndReset();return}this.cursor.deliver_seq=i,this.cursor.stream_seq=s.info.streamSequence,this.userCallback?this.userCallback(s):(o=this.iter)==null||o.push(s)}}async reset(t={max_messages:100,expires:3e4},s){var g,u;s=s||{};const i=s.fromFetch||!1,o=s.orderedReset||!1;if(this.type===Un.Fetch&&o){(g=this.iter)==null||g.src.stop(),await((u=this.iter)==null?void 0:u.closed()),this.currentConsumer=null;return}(this.currentConsumer===null||o)&&(this.currentConsumer=await this.resetConsumer(this.cursor.stream_seq+1)),(this.iter===null||i)&&(this.iter=new M2),this.consumer=new Nd(this.api,this.currentConsumer);const c=t;c.callback=this.internalHandler(this.serial);let m=null;this.type===Un.Fetch&&i?m=await this.consumer.fetch(t):this.type===Un.Consume&&(m=await this.consumer.consume(t));const y=m;y.forOrderedConsumer=!0,y.resetHandler=()=>{this.notifyOrderedResetAndReset()},this.iter.setSource(y)}notifyOrderedResetAndReset(){var t;(t=this.iter)==null||t.notify(Qi.Reset,""),this.reset(this.opts,{orderedReset:!0})}async consume(t={max_messages:100,expires:3e4}){if(t.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===Un.Fetch)return Promise.reject(new Error("ordered consumer initialized as fetch"));if(this.type===Un.Consume)return Promise.reject(new Error("ordered consumer doesn't support concurrent consume"));const{callback:i}=t;return i&&(this.userCallback=i),this.type=Un.Consume,this.opts=t,await this.reset(t),this.iter}async fetch(t={max_messages:100,expires:3e4}){var o;if(t.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===Un.Consume)return Promise.reject(new Error("ordered consumer already initialized as consume"));if(((o=this.iter)==null?void 0:o.done)===!1)return Promise.reject(new Error("ordered consumer doesn't support concurrent fetch"));const{callback:i}=t;return i&&(this.userCallback=i),this.type=Un.Fetch,this.opts=t,await this.reset(t,{fromFetch:!0}),this.iter}async next(t={expires:3e4}){const s=t;if(s.bind)return Promise.reject(new Error("bind is not supported"));s.max_messages=1;const i=pt();return s.callback=c=>{this.userCallback=null,i.resolve(c)},(await this.fetch(s)).iterClosed.then(c=>{c&&i.reject(c),i.resolve(null)}).catch(c=>{i.reject(c)}),i}delete(){return this.currentConsumer?this.api.delete(this.stream,this.currentConsumer.name).then(t=>Promise.resolve(t)).catch(t=>Promise.reject(t)).finally(()=>{this.currentConsumer=null}):Promise.resolve(!1)}async info(t){return this.currentConsumer==null?(this.currentConsumer=await this.resetConsumer(this.startSeq),Promise.resolve(this.currentConsumer)):t&&this.currentConsumer?Promise.resolve(this.currentConsumer):this.api.info(this.stream,this.currentConsumer.name)}}class Td{constructor(t){j(this,"api");j(this,"notified");this.api=t,this.notified=!1}checkVersion(){const t=this.api.nc.features.get(Ke.JS_SIMPLIFICATION);return t.ok?Promise.resolve():Promise.reject(new Error(`consumers framework is only supported on servers ${t.min} or better`))}getPullConsumerFor(t){if(t.config.deliver_subject!==void 0)throw new Error("push consumer not supported");return new Nd(this.api,t)}async get(t,s={}){return typeof s=="object"?this.ordered(t,s):(await this.checkVersion(),this.api.info(t,s).then(i=>i.config.deliver_subject!==void 0?Promise.reject(new Error("push consumer not supported")):new Nd(this.api,i)).catch(i=>Promise.reject(i)))}async ordered(t,s){await this.checkVersion();const i=this.api;return new lm(i.nc,i.opts).info(t).then(c=>Promise.resolve(new R2(this.api,t,s))).catch(c=>Promise.reject(c))}}class Au{constructor(t,s){j(this,"api");j(this,"_info");this.api=t,this._info=s}get name(){return this._info.config.name}alternates(){return this.info().then(t=>t.alternates?t.alternates:[])}async best(){if(await this.info(),this._info.alternates){const t=await this.api.info(this._info.alternates[0].name);return new Au(this.api,t)}else return this}info(t=!1,s){return t?Promise.resolve(this._info):this.api.info(this.name,s).then(i=>(this._info=i,this._info))}getConsumerFromInfo(t){return new Td(new du(this.api.nc,this.api.opts)).getPullConsumerFor(t)}getConsumer(t){return new Td(new du(this.api.nc,this.api.opts)).get(this.name,t)}getMessage(t){return this.api.getMessage(this.name,t)}deleteMessage(t,s){return this.api.deleteMessage(this.name,t,s)}}class lm extends To{constructor(t,s){super(t,s)}checkStreamConfigVersions(t){const s=this.nc;if(t.metadata){const{min:o,ok:c}=s.features.get(Ke.JS_STREAM_CONSUMER_METADATA);if(!c)throw new Error(`stream 'metadata' requires server ${o}`)}if(t.first_seq){const{min:o,ok:c}=s.features.get(Ke.JS_STREAM_FIRST_SEQ);if(!c)throw new Error(`stream 'first_seq' requires server ${o}`)}if(t.subject_transform){const{min:o,ok:c}=s.features.get(Ke.JS_STREAM_SUBJECT_TRANSFORM);if(!c)throw new Error(`stream 'subject_transform' requires server ${o}`)}if(t.compression){const{min:o,ok:c}=s.features.get(Ke.JS_STREAM_COMPRESSION);if(!c)throw new Error(`stream 'compression' requires server ${o}`)}if(t.consumer_limits){const{min:o,ok:c}=s.features.get(Ke.JS_DEFAULT_CONSUMER_LIMITS);if(!c)throw new Error(`stream 'consumer_limits' requires server ${o}`)}function i(o,c){var y;if((((y=c==null?void 0:c.subject_transforms)==null?void 0:y.length)||0)>0){const{min:g,ok:u}=s.features.get(Ke.JS_STREAM_SOURCE_SUBJECT_TRANSFORM);if(!u)throw new Error(`${o} 'subject_transforms' requires server ${g}`)}}t.sources&&t.sources.forEach(o=>{i("stream sources",o)}),t.mirror&&i("stream mirror",t.mirror)}async add(t={}){var o;this.checkStreamConfigVersions(t),Kt(t.name),t.mirror=oc(t.mirror),t.sources=(o=t.sources)==null?void 0:o.map(oc);const i=await this._request(`${this.prefix}.STREAM.CREATE.${t.name}`,t);return this._fixInfo(i),i}async delete(t){return Kt(t),(await this._request(`${this.prefix}.STREAM.DELETE.${t}`)).success}async update(t,s={}){var y;if(typeof t=="object"){const g=t;t=g.name,s=g,console.trace("\x1B[33m >> streams.update(config: StreamConfig) api changed to streams.update(name: string, config: StreamUpdateConfig) - this shim will be removed - update your code. \x1B[0m")}this.checkStreamConfigVersions(s),Kt(t);const i=await this.info(t),o=Object.assign(i.config,s);o.mirror=oc(o.mirror),o.sources=(y=o.sources)==null?void 0:y.map(oc);const m=await this._request(`${this.prefix}.STREAM.UPDATE.${t}`,o);return this._fixInfo(m),m}async info(t,s){Kt(t);const i=`${this.prefix}.STREAM.INFO.${t}`;let c=await this._request(i,s),{total:m,limit:y}=c,g=c.state.subjects?Object.getOwnPropertyNames(c.state.subjects).length:1;if(m&&m>g){const u=[c],d=s||{};let b=0;for(;m>g;){b++,d.offset=y*b;const v=await this._request(i,d);m=v.total,u.push(v);const w=Object.getOwnPropertyNames(v.state.subjects).length;if(g+=w,w<y)break}let x={};for(let v=0;v<u.length;v++)c=u[v],c.state.subjects&&(x=Object.assign(x,c.state.subjects));c.offset=0,c.total=0,c.limit=0,c.state.subjects=x}return this._fixInfo(c),c}list(t=""){const s=t!=null&&t.length?{subject:t}:{},i=c=>{const m=c;return m.streams.forEach(y=>{this._fixInfo(y)}),m.streams},o=`${this.prefix}.STREAM.LIST`;return new po(o,i,this,s)}_fixInfo(t){t.config.sealed=t.config.sealed||!1,t.config.deny_delete=t.config.deny_delete||!1,t.config.deny_purge=t.config.deny_purge||!1,t.config.allow_rollup_hdrs=t.config.allow_rollup_hdrs||!1}async purge(t,s){if(s){const{keep:o,seq:c}=s;if(typeof o=="number"&&typeof c=="number")throw new Error("can specify one of keep or seq")}return Kt(t),await this._request(`${this.prefix}.STREAM.PURGE.${t}`,s)}async deleteMessage(t,s,i=!0){Kt(t);const o={seq:s};return i||(o.no_erase=!0),(await this._request(`${this.prefix}.STREAM.MSG.DELETE.${t}`,o)).success}async getMessage(t,s){Kt(t);const o=await this._request(`${this.prefix}.STREAM.MSG.GET.${t}`,s);return new Ox(o)}find(t){return this.findStream(t)}listKvs(){const t=i=>{var g;const c=i.streams.filter(u=>u.config.name.startsWith(_n));c.forEach(u=>{this._fixInfo(u)});let m="";return c.length&&(m=((g=this.nc.info)==null?void 0:g.cluster)??""),c.map(u=>new Ex(u,m))},s=`${this.prefix}.STREAM.LIST`;return new po(s,t,this)}listObjectStores(){const t=i=>{const c=i.streams.filter(y=>y.config.name.startsWith(om));return c.forEach(y=>{this._fixInfo(y)}),c.map(y=>new kd(y))},s=`${this.prefix}.STREAM.LIST`;return new po(s,t,this)}names(t=""){const s=t!=null&&t.length?{subject:t}:{},i=c=>c.streams,o=`${this.prefix}.STREAM.NAMES`;return new po(o,i,this,s)}async get(t){const s=await this.info(t);return Promise.resolve(new Au(this,s))}}class D2 extends To{constructor(t,s){super(t,s)}async getMessage(t,s){Kt(t);let i=s;const{last_by_subj:o}=i;o&&(i=null);const c=i?this.jc.encode(i):An,m=this.opts.apiPrefix||"$JS.API",y=o?`${m}.DIRECT.GET.${t}.${o}`:`${m}.DIRECT.GET.${t}`,g=await this.nc.request(y,c,{timeout:this.timeout}),u=Ji(g);if(u)return Promise.reject(u);const d=new Cd(g);return Promise.resolve(d)}async getBatch(t,s){Kt(t);const o=`${this.opts.apiPrefix||"$JS.API"}.DIRECT.GET.${t}`;if(!Array.isArray(s.multi_last)||s.multi_last.length===0)return Promise.reject("multi_last is required");const c=JSON.stringify(s,(g,u)=>g==="up_to_time"&&u instanceof Date?u.toISOString():u),m=new Bt,y=await this.nc.requestMany(o,c,{strategy:Qn.SentinelMsg});return(async()=>{var b,x,v;let g=!1,u=!1,d;for await(const w of y){if(!g){g=!0;const S=((b=w.headers)==null?void 0:b.code)||0;if(S!==0&&S<200||S>299){d=(x=w.headers)==null?void 0:x.description.toLowerCase();break}if(((v=w.headers)==null?void 0:v.get("Nats-Num-Pending"))===""){u=!0;break}}if(w.data.length===0)break;m.push(new Cd(w))}m.push(()=>{if(u)throw new Error("batch direct get not supported by the server");if(d)throw new Error(`bad request: ${d}`);m.stop()})})(),Promise.resolve(m)}}class Cd{constructor(t){j(this,"data");j(this,"header");if(!t.headers)throw new Error("headers expected");this.data=t.data,this.header=t.headers}get subject(){return this.header.last(Vi.Subject)}get seq(){const t=this.header.last(Vi.Sequence);return typeof t=="string"?parseInt(t):0}get time(){return new Date(Date.parse(this.timestamp))}get timestamp(){return this.header.last(Vi.TimeStamp)}get stream(){return this.header.last(Vi.Stream)}json(t){return Wn(t).decode(this.data)}string(){return Sn.decode(this.data)}}j(Cd,"jc");class L2 extends To{constructor(s,i){super(s,i);j(this,"streams");j(this,"consumers");j(this,"direct");this.streams=new lm(s,i),this.consumers=new du(s,i),this.direct=new D2(s,i)}async getAccountInfo(){return await this._request(`${this.prefix}.INFO`)}jetstream(){return this.nc.jetstream(this.getOptions())}advisories(){const s=new Bt;return this.nc.subscribe("$JS.EVENT.ADVISORY.>",{callback:(i,o)=>{if(i)throw i;try{const c=this.parseJsResponse(o),m=c.type.split("."),y=m[m.length-1];s.push({kind:y,data:c})}catch(c){s.stop(c)}}}),s}}class Ox{constructor(t){j(this,"_header");j(this,"smr");this.smr=t}get subject(){return this.smr.message.subject}get seq(){return this.smr.message.seq}get timestamp(){return this.smr.message.time}get time(){return new Date(Date.parse(this.timestamp))}get data(){return this.smr.message.data?this._parse(this.smr.message.data):An}get header(){if(!this._header)if(this.smr.message.hdrs){const t=this._parse(this.smr.message.hdrs);this._header=vs.decode(t)}else this._header=Lr();return this._header}_parse(t){const s=atob(t),i=s.length,o=new Uint8Array(i);for(let c=0;c<i;c++)o[c]=s.charCodeAt(c);return o}json(t){return Wn(t).decode(this.data)}string(){return Sn.decode(this.data)}}j(Ox,"jc");class q2{constructor(t){j(this,"api");this.api=t}get(t){return this.api.info(t).then(s=>new Au(this.api,s))}}class td{constructor(t){j(this,"info");j(this,"hdrs");this.info=t}get name(){return this.info.name}get description(){return this.info.description??""}get headers(){return this.hdrs||(this.hdrs=vs.fromRecord(this.info.headers||{})),this.hdrs}get options(){return this.info.options}get bucket(){return this.info.bucket}get chunks(){return this.info.chunks}get deleted(){return this.info.deleted??!1}get digest(){return this.info.digest}get mtime(){return this.info.mtime}get nuid(){return this.info.nuid}get size(){return this.info.size}get revision(){return this.info.revision}get metadata(){return this.info.metadata||{}}isLink(){var t,s;return((t=this.info.options)==null?void 0:t.link)!==void 0&&((s=this.info.options)==null?void 0:s.link)!==null}}function l1(n){const t={name:n.name,description:n.description??"",options:n.options,metadata:n.metadata};if(n.headers){const s=n.headers;t.headers=s.toRecord()}return t}function B2(){return new ReadableStream({pull(n){n.enqueue(new Uint8Array(0)),n.close()}})}class vo{constructor(t,s,i){j(this,"jsm");j(this,"js");j(this,"stream");j(this,"name");this.name=t,this.jsm=s,this.js=i}_checkNotEmpty(t){return!t||t.length===0?{name:t,error:new Error("name cannot be empty")}:{name:t}}async info(t){const s=await this.rawInfo(t);return s?new td(s):null}async list(){const t=[],s=await this.watch({ignoreDeletes:!0,includeHistory:!0});for await(const i of s){if(i===null)break;t.push(i)}return Promise.resolve(t)}async rawInfo(t){const{name:s,error:i}=this._checkNotEmpty(t);if(i)return Promise.reject(i);const o=this._metaSubject(s);try{const c=await this.jsm.streams.getMessage(this.stream,{last_by_subj:o}),y=Wn().decode(c.data);return y.revision=c.seq,y}catch(c){return c.code==="404"?null:Promise.reject(c)}}async _si(t){try{return await this.jsm.streams.info(this.stream,t)}catch(s){return s.code==="404"?null:Promise.reject(s)}}async seal(){let t=await this._si();return t===null?Promise.reject(new Error("object store not found")):(t.config.sealed=!0,t=await this.jsm.streams.update(this.stream,t.config),Promise.resolve(new kd(t)))}async status(t){const s=await this._si(t);return s===null?Promise.reject(new Error("object store not found")):Promise.resolve(new kd(s))}destroy(){return this.jsm.streams.delete(this.stream)}async _put(t,s,i){var le;const o=this.js.getOptions();i=i||{timeout:o.timeout},i.timeout=i.timeout||o.timeout,i.previousRevision=i.previousRevision??void 0;const{timeout:c,previousRevision:m}=i,y=this.js.nc.info,g=(y==null?void 0:y.max_payload)||1024;t=t||{},t.options=t.options||{};let u=((le=t.options)==null?void 0:le.max_chunk_size)||128*1024;u=u>g?g:u,t.options.max_chunk_size=u;const d=await this.info(t.name),{name:b,error:x}=this._checkNotEmpty(t.name);if(x)return Promise.reject(x);const v=Es.next(),w=this._chunkSubject(v),S=this._metaSubject(b),C=Object.assign({bucket:this.name,nuid:v,size:0,chunks:0},l1(t)),q=pt(),B=[],ie=new na;try{const R=s?s.getReader():null,$=Qg.create();for(;;){const{done:ne,value:V}=R?await R.read():{done:!0,value:void 0};if(ne){if(ie.size()>0){const X=ie.drain();$.update(X),C.chunks++,C.size+=X.length,B.push(this.js.publish(w,X,{timeout:c}))}await Promise.all(B),B.length=0,C.mtime=new Date().toISOString();const I=Xi.encode($.digest());C.digest=`${a1}${I}`,C.deleted=!1;const D=Lr();typeof m=="number"&&D.set(ir.ExpectedLastSubjectSequenceHdr,`${m}`),D.set(Qt.RollupHdr,Qt.RollupValueSubject);const Q=await this.js.publish(S,Wn().encode(C),{headers:D,timeout:c});if(C.revision=Q.seq,d)try{await this.jsm.streams.purge(this.stream,{filter:`$O.${this.name}.C.${d.nuid}`})}catch{}q.resolve(new td(C));break}if(V)for(ie.fill(V);ie.size()>u;){C.chunks++,C.size+=u;const I=ie.drain(t.options.max_chunk_size);$.update(I),B.push(this.js.publish(w,I,{timeout:c}))}}}catch(R){await this.jsm.streams.purge(this.stream,{filter:w}),q.reject(R)}return q}putBlob(t,s,i){function o(c){return new ReadableStream({pull(m){m.enqueue(c),m.close()}})}return s===null&&(s=new Uint8Array(0)),this.put(t,o(s),i)}put(t,s,i){var o;return(o=t==null?void 0:t.options)!=null&&o.link?Promise.reject(new Error("link cannot be set when putting the object in bucket")):this._put(t,s,i)}async getBlob(t){async function s(c){const m=new na,y=c.getReader();for(;;){const{done:g,value:u}=await y.read();if(g)return m.drain();u&&u.length&&m.fill(u)}}const i=await this.get(t);if(i===null)return Promise.resolve(null);const o=await Promise.all([i.error,s(i.data)]);return o[0]?Promise.reject(o[0]):Promise.resolve(o[1])}async get(t){const s=await this.rawInfo(t);if(s===null||s.deleted)return Promise.resolve(null);if(s.options&&s.options.link){const b=s.options.link.name||"";if(b==="")throw new Error("link is a bucket");return(s.options.link.bucket!==this.name?await vo.create(this.js,s.options.link.bucket):this).get(b)}if(!s.digest.startsWith(a1))return Promise.reject(new Error(`unknown digest type: ${s.digest}`));const i=Sd(s.digest.substring(8));if(i===null)return Promise.reject(new Error(`unable to parse digest: ${s.digest}`));const o=pt(),c={info:new td(s),error:o};if(s.size===0)return c.data=B2(),o.resolve(null),Promise.resolve(c);let m;const y=_s();y.orderedConsumer();const g=Qg.create(),u=`$O.${this.name}.C.${s.nuid}`,d=await this.js.subscribe(u,y);return(async()=>{for await(const b of d)b.data.length>0&&(g.update(b.data),m.enqueue(b.data)),b.info.pending===0&&(OE(i,g.digest())?m.close():m.error(new Error(`received a corrupt object, digests do not match received: ${s.digest} calculated ${i}`)),d.unsubscribe())})().then(()=>{o.resolve()}).catch(b=>{m.error(b),o.reject(b)}),c.data=new ReadableStream({start(b){m=b},cancel(){d.unsubscribe()}}),c}linkStore(t,s){if(!(s instanceof vo))return Promise.reject("bucket required");const i=s,{name:o,error:c}=this._checkNotEmpty(t);if(c)return Promise.reject(c);const m={name:o,options:{link:{bucket:i.name}}};return this._put(m,null)}async link(t,s){const{name:i,error:o}=this._checkNotEmpty(t);if(o)return Promise.reject(o);if(s.deleted)return Promise.reject(new Error("src object is deleted"));if(s.isLink())return Promise.reject(new Error("src object is a link"));const c=await this.rawInfo(t);if(c!==null&&!c.deleted)return Promise.reject(new Error("an object already exists with that name"));const m={bucket:s.bucket,name:s.name},y={name:i,bucket:s.bucket,options:{link:m}};await this.js.publish(this._metaSubject(t),JSON.stringify(y));const g=await this.info(t);return Promise.resolve(g)}async delete(t){const s=await this.rawInfo(t);if(s===null)return Promise.resolve({purged:0,success:!1});s.deleted=!0,s.size=0,s.chunks=0,s.digest="";const i=Wn(),o=Lr();return o.set(Qt.RollupHdr,Qt.RollupValueSubject),await this.js.publish(this._metaSubject(s.name),i.encode(s),{headers:o}),this.jsm.streams.purge(this.stream,{filter:this._chunkSubject(s.nuid)})}async update(t,s={}){const i=await this.rawInfo(t);if(i===null)return Promise.reject(new Error("object not found"));if(i.deleted)return Promise.reject(new Error("cannot update meta for a deleted object"));s.name=s.name??i.name;const{name:o,error:c}=this._checkNotEmpty(s.name);if(c)return Promise.reject(c);if(t!==s.name){const g=await this.info(s.name);if(g&&!g.deleted)return Promise.reject(new Error("an object already exists with that name"))}s.name=o;const m=Object.assign({},i,l1(s)),y=await this.js.publish(this._metaSubject(m.name),JSON.stringify(m));return t!==s.name&&await this.jsm.streams.purge(this.stream,{filter:this._metaSubject(t)}),Promise.resolve(y)}async watch(t={}){t.includeHistory=t.includeHistory??!1,t.ignoreDeletes=t.ignoreDeletes??!1;let s=!1;const i=new Bt,o=this._metaSubjectAll();try{await this.jsm.streams.getMessage(this.stream,{last_by_subj:o})}catch(g){g.code==="404"?(i.push(null),s=!0):i.stop(g)}const c=Wn(),m=_s();m.orderedConsumer(),t.includeHistory?m.deliverLastPerSubject():(s=!0,m.deliverNew()),m.callback((g,u)=>{var d;if(g){i.stop(g);return}if(u!==null){const b=c.decode(u.data);b.deleted&&t.ignoreDeletes===!0||i.push(b),((d=u.info)==null?void 0:d.pending)===0&&!s&&(s=!0,i.push(null))}});const y=await this.js.subscribe(o,m);return i._data=y,i.iterClosed.then(()=>{y.unsubscribe()}),y.closed.then(()=>{i.stop()}).catch(g=>{i.stop(g)}),i}_chunkSubject(t){return`$O.${this.name}.C.${t}`}_metaSubject(t){return`$O.${this.name}.M.${Xi.encode(t)}`}_metaSubjectAll(){return`$O.${this.name}.M.>`}async init(t={}){try{this.stream=A2(this.name)}catch(o){return Promise.reject(o)}const s=(t==null?void 0:t.ttl)||0;delete t.ttl;const i=Object.assign({max_age:s},t);i.name=this.stream,i.num_replicas=t.replicas??1,i.allow_direct=!0,i.allow_rollup_hdrs=!0,i.discard=wo.New,i.subjects=[`$O.${this.name}.C.>`,`$O.${this.name}.M.>`],t.placement&&(i.placement=t.placement),t.metadata&&(i.metadata=t.metadata),typeof t.compression=="boolean"&&(i.compression=t.compression?Os.S2:Os.None);try{await this.jsm.streams.info(i.name)}catch(o){o.message==="stream not found"&&await this.jsm.streams.add(i)}}static async create(t,s,i={}){const o=await t.jetstreamManager(),c=new vo(s,o,t);return await c.init(i),Promise.resolve(c)}}class P2{constructor(t){j(this,"js");this.js=t}kv(t,s={}){const i=this.js,{ok:o,min:c}=i.nc.features.get(Ke.JS_KV);return o?s.bindOnly?Eo.bind(this.js,t,s):Eo.create(this.js,t,s):Promise.reject(new Error(`kv is only supported on servers ${c} or better`))}os(t,s={}){var m;if(typeof((m=crypto==null?void 0:crypto.subtle)==null?void 0:m.digest)!="function")return Promise.reject(new Error("objectstore: unable to calculate hashes - crypto.subtle.digest with sha256 support is required"));const i=this.js,{ok:o,min:c}=i.nc.features.get(Ke.JS_OBJECTSTORE);return o?vo.create(this.js,t,s):Promise.reject(new Error(`objectstore is only supported on servers ${c} or better`))}}class cm extends To{constructor(s,i){super(s,i);j(this,"consumers");j(this,"streams");j(this,"consumerAPI");j(this,"streamAPI");this.consumerAPI=new du(s,i),this.streamAPI=new lm(s,i),this.consumers=new Td(this.consumerAPI),this.streams=new q2(this.streamAPI)}jetstreamManager(s){s===void 0&&(s=this.opts.checkAPI);const i=Object.assign({},this.opts,{checkAPI:s});return this.nc.jetstreamManager(i)}get apiPrefix(){return this.prefix}get views(){return new P2(this)}async publish(s,i=An,o){o=o||{},o.expect=o.expect||{};const c=(o==null?void 0:o.headers)||Lr();o&&(o.msgID&&c.set(ir.MsgIdHdr,o.msgID),o.expect.lastMsgID&&c.set(ir.ExpectedLastMsgIdHdr,o.expect.lastMsgID),o.expect.streamName&&c.set(ir.ExpectedStreamHdr,o.expect.streamName),typeof o.expect.lastSequence=="number"&&c.set(ir.ExpectedLastSeqHdr,`${o.expect.lastSequence}`),typeof o.expect.lastSubjectSequence=="number"&&c.set(ir.ExpectedLastSubjectSequenceHdr,`${o.expect.lastSubjectSequence}`));const m=o.timeout||this.timeout,y={};m&&(y.timeout=m),o&&(y.headers=c);let{retries:g,retry_delay:u}=o;g=g||1,u=u||250;let d;for(let x=0;x<g;x++)try{d=await this.nc.request(s,i,y);break}catch(v){if(v.code==="503"&&x+1<g)await sa(u);else throw v}const b=this.parseJsResponse(d);if(b.stream==="")throw ye.errorForCode(ue.JetStreamInvalidAck);return b.duplicate=b.duplicate?b.duplicate:!1,b}async pull(s,i,o=0){Kt(s),Ki(i);let c=this.timeout;o>c&&(c=o),o=o<0?0:mt(o);const m={batch:1,no_wait:o===0,expires:o},y=await this.nc.request(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${i}`,this.jc.encode(m),{noMux:!0,timeout:c}),g=Ji(y);if(g)throw g;return Oo(y,this.timeout)}fetch(s,i,o={}){Kt(s),Ki(i);let c=null;const m=(o.max_bytes??0)>0;let y=0;const g=m?o.max_bytes:0;let u=null;const d={};if(d.batch=o.batch||1,g){const B=this.nc.features.get(Ke.JS_PULL_MAX_BYTES);if(!B.ok)throw new Error(`max_bytes is only supported on servers ${B.min} or better`);d.max_bytes=g}d.no_wait=o.no_wait||!1,d.no_wait&&d.expires&&(d.expires=0);const b=o.expires||0;if(b&&(d.expires=mt(b)),b===0&&d.no_wait===!1)throw new Error("expires or no_wait is required");const x=o.idle_heartbeat||0;x&&(d.idle_heartbeat=mt(x),o.delay_heartbeat===!0&&(d.idle_heartbeat=mt(x*4)));const v=new Bt,w=d.batch;let S=0;v.protocolFilterFn=(B,ie=!1)=>vd(B.msg)?(u==null||u.work(),!1):!0,v.dispatchedFn=B=>{if(B){if(m&&(y+=B.data.length),S++,c&&B.info.pending===0)return;(v.getPending()===1&&B.info.pending===0||w===S||g>0&&y>=g)&&v.stop()}};const C=Rr(this.nc.options.inboxPrefix),q=this.nc.subscribe(C,{max:o.batch,callback:(B,ie)=>{B===null&&(B=Ji(ie)),B!==null?(c&&(c.cancel(),c=null),aE(B)?v.stop(jx(B)===null?void 0:B):v.stop(B)):(u==null||u.work(),v.received++,v.push(Oo(ie,this.timeout)))}});return b&&(c=ea(b),c.catch(()=>{q.isClosed()||(q.drain().catch(()=>{}),c=null),u&&u.cancel()})),(async()=>{try{x&&(u=new am(x,B=>(v.push(()=>{v.err=new ye(`${zn.IdleHeartbeatMissed}: ${B}`,ue.JetStreamIdleHeartBeat)}),!0)))}catch{}await q.closed,c!==null&&(c.cancel(),c=null),u&&u.cancel(),v.stop()})().catch(),this.nc.publish(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${i}`,this.jc.encode(d),{reply:C}),v}async pullSubscribe(s,i=_s()){const o=await this._processOptions(s,i);if(o.ordered)throw new Error("pull subscribers cannot be be ordered");if(o.config.deliver_subject)throw new Error("consumer info specifies deliver_subject - pull consumers cannot have deliver_subject set");const c=o.config.ack_policy;if(c===qt.None||c===qt.All)throw new Error("ack policy for pull consumers must be explicit");const m=this._buildTypedSubscriptionOpts(o),y=new $2(this,o.deliver,m);y.info=o;try{await this._maybeCreateConsumer(o)}catch(g){throw y.unsubscribe(),g}return y}async subscribe(s,i=_s()){const o=await this._processOptions(s,i);if(!o.isBind&&!o.config.deliver_subject)throw new Error("push consumer requires deliver_subject");const c=this._buildTypedSubscriptionOpts(o),m=new Ax(this,o.deliver,c);m.info=o;try{await this._maybeCreateConsumer(o)}catch(y){throw m.unsubscribe(),y}return m._maybeSetupHbMonitoring(),m}async _processOptions(s,i=_s()){const o=Yg(i)?i.getOpts():i;if(o.isBind=Yg(i)?i.isBind:!1,o.flow_control={heartbeat_count:0,fc_count:0,consumer_restarts:0},o.ordered){if(o.ordered_consumer_sequence={stream_seq:0,delivery_seq:0},o.config.ack_policy!==qt.NotSet&&o.config.ack_policy!==qt.None)throw new ye("ordered consumer: ack_policy can only be set to 'none'",ue.ApiError);if(o.config.durable_name&&o.config.durable_name.length>0)throw new ye("ordered consumer: durable_name cannot be set",ue.ApiError);if(o.config.deliver_subject&&o.config.deliver_subject.length>0)throw new ye("ordered consumer: deliver_subject cannot be set",ue.ApiError);if(o.config.max_deliver!==void 0&&o.config.max_deliver>1)throw new ye("ordered consumer: max_deliver cannot be set",ue.ApiError);if(o.config.deliver_group&&o.config.deliver_group.length>0)throw new ye("ordered consumer: deliver_group cannot be set",ue.ApiError);o.config.deliver_subject=Rr(this.nc.options.inboxPrefix),o.config.ack_policy=qt.None,o.config.max_deliver=1,o.config.flow_control=!0,o.config.idle_heartbeat=o.config.idle_heartbeat||mt(5e3),o.config.ack_wait=mt(1320*60*1e3),o.config.mem_storage=!0,o.config.num_replicas=1}if(o.config.ack_policy===qt.NotSet&&(o.config.ack_policy=qt.All),o.api=this,o.config=o.config||{},o.stream=o.stream?o.stream:await this.findStream(s),o.attached=!1,o.config.durable_name)try{const c=await this.consumerAPI.info(o.stream,o.config.durable_name);if(c){if(c.config.filter_subject&&c.config.filter_subject!==s)throw new Error("subject does not match consumer");const m=o.config.deliver_group??"";if(m===""&&c.push_bound===!0)throw new Error("duplicate subscription");const y=c.config.deliver_group??"";if(m!==y)throw y===""?new Error("durable requires no queue group"):new Error(`durable requires queue group '${y}'`);o.last=c,o.config=c.config,o.attached=!0,o.config.durable_name||(o.name=c.name)}}catch(c){if(c.code!=="404")throw c}return!o.attached&&o.config.filter_subject===void 0&&o.config.filter_subjects===void 0&&(o.config.filter_subject=s),o.deliver=o.config.deliver_subject||Rr(this.nc.options.inboxPrefix),o}_buildTypedSubscriptionOpts(s){const i={};return i.adapter=H2(s.callbackFn===void 0,this.timeout),i.ingestionFilterFn=cm.ingestionFn(s.ordered),i.protocolFilterFn=(o,c=!1)=>{const m=o;return xd(m.msg)?(c||m.msg.respond(),!1):!0},!s.mack&&s.config.ack_policy!==qt.None&&(i.dispatchedFn=V2),s.callbackFn&&(i.callback=s.callbackFn),i.max=s.max||0,i.queue=s.queue,i}async _maybeCreateConsumer(s){if(s.attached)return;if(s.isBind)throw new Error(`unable to bind - durable consumer ${s.config.durable_name} doesn't exist in ${s.stream}`);s.config=Object.assign({deliver_policy:Et.All,ack_policy:qt.Explicit,ack_wait:mt(30*1e3),replay_policy:ta.Instant},s.config);const i=await this.consumerAPI.add(s.stream,s.config);if(Array.isArray(s.config.filter_subjects&&!Array.isArray(i.config.filter_subjects)))throw new Error("jetstream server doesn't support consumers with multiple filter subjects");s.name=i.name,s.config=i.config,s.last=i}static ingestionFn(s){return(i,o)=>{var g;const c=o;if(!i)return{ingest:!1,protocol:!1};const m=i;if(Ji(m.msg)||(g=c.monitor)==null||g.work(),vd(m.msg)){const u=s?c._checkHbOrderConsumer(m.msg):!0;return s||c.info.flow_control.heartbeat_count++,{ingest:u,protocol:!0}}else if(xd(m.msg))return c.info.flow_control.fc_count++,{ingest:!0,protocol:!0};return{ingest:s?c._checkOrderedConsumer(i):!0,protocol:!1}}}}class um{constructor(t){j(this,"options");j(this,"protocol");j(this,"draining");j(this,"listeners");j(this,"_services");this.draining=!1,this.options=o2(t),this.listeners=[]}static connect(t={}){return new Promise((s,i)=>{const o=new um(t);pu.connect(o.options,o).then(c=>{o.protocol=c,(async function(){for await(const m of c.status())o.listeners.forEach(y=>{y.push(m)})})(),s(o)}).catch(c=>{i(c)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(t,s,i){if(this.isClosed())throw ye.errorForCode(ue.ConnectionClosed);if(s&&this.isDraining()||i&&this.protocol.noMorePublishing)throw ye.errorForCode(ue.ConnectionDraining);if(t=t||"",t.length===0)throw ye.errorForCode(ue.BadSubject)}publish(t,s,i){this._check(t,!1,!0),this.protocol.publish(t,s,i)}publishMessage(t){return this.publish(t.subject,t.data,{reply:t.reply,headers:t.headers})}respondMessage(t){return t.reply?(this.publish(t.reply,t.data,{reply:t.reply,headers:t.headers}),!0):!1}subscribe(t,s={}){this._check(t,!0,!1);const i=new wx(this.protocol,t,s);return this.protocol.subscribe(i),i}_resub(t,s,i){this._check(s,!0,!1);const o=t;o.max=i,i&&(o.max=i+o.received),this.protocol.resub(o,s)}requestMany(t,s=An,i={maxWait:1e3,maxMessages:-1}){const o=!this.protocol.options.noAsyncTraces;try{this._check(t,!0,!0)}catch(g){return Promise.reject(g)}if(i.strategy=i.strategy||Qn.Timer,i.maxWait=i.maxWait||1e3,i.maxWait<1)return Promise.reject(new ye("timeout",ue.InvalidOption));const c=new Bt;function m(g){c.push(()=>{c.stop(g)})}function y(g,u){g||u===null?m(g===null?void 0:g):c.push(u)}if(i.noMux){const g=o?new Error().stack:null;let u=typeof i.maxMessages=="number"&&i.maxMessages>0?i.maxMessages:-1;const d=this.subscribe(Rr(this.options.inboxPrefix),{callback:(w,S)=>{var C,q;if(((C=S==null?void 0:S.data)==null?void 0:C.length)===0&&((q=S==null?void 0:S.headers)==null?void 0:q.status)===ue.NoResponders&&(w=ye.errorForCode(ue.NoResponders)),w){g&&(w.stack+=`
47
+ `),t.max=s)}resub(t,s){!t||this.isClosed()||(this.unsub(t),t.subject=s,this.subscriptions.resub(t),this._sub(t))}flush(t){return t||(t=pt()),this.pongs.push(t),this.outbound.fill(r1),this.flushPending(),t}sendSubscriptions(){const t=[];this.subscriptions.all().forEach(s=>{const i=s;i.queue?t.push(`SUB ${i.subject} ${i.queue} ${i.sid}${nu}`):t.push(`SUB ${i.subject} ${i.sid}${nu}`)}),t.length&&this.transport.send(go(t.join("")))}async _close(t){this._closed||(this.whyClosed=new Error("close trace").stack||"",this.heartbeats.cancel(),this.connectError&&(this.connectError(t),this.connectError=void 0),this.muxSubscriptions.close(),this.subscriptions.close(),this.listeners.forEach(s=>{s.stop()}),this._closed=!0,await this.transport.close(t),await this.closed.resolve(t))}close(){return this._close()}isClosed(){return this._closed}drain(){const t=this.subscriptions.all(),s=[];return t.forEach(i=>{s.push(i.drain())}),Promise.all(s).then(async()=>(this.noMorePublishing=!0,await this.flush(),this.close())).catch(()=>{})}flushPending(){if(!(!this.infoReceived||!this.connected)&&this.outbound.size()){const t=this.outbound.drain();this.transport.send(t)}}initMux(){if(!this.subscriptions.getMux()){const s=this.muxSubscriptions.init(this.options.inboxPrefix),i=new _x(this,`${s}*`);i.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(i),this.subscribe(i)}}selectServer(){const t=this.servers.selectServer();if(t!==void 0)return this.server=t,this.server}getServer(){return this.server}}const d2="$SRV";class s1{constructor(t){j(this,"msg");this.msg=t}get data(){return this.msg.data}get sid(){return this.msg.sid}get subject(){return this.msg.subject}get reply(){return this.msg.reply||""}get headers(){return this.msg.headers}respond(t,s){return this.msg.respond(t,s)}respondError(t,s,i,o){var c,m;return o=o||{},o.headers=o.headers||Lr(),(c=o.headers)==null||c.set(uu,`${t}`),(m=o.headers)==null||m.set(cu,s),this.msg.respond(i,o)}json(t){return this.msg.json(t)}string(){return this.msg.string()}}class So{constructor(t,s="",i=""){j(this,"subject");j(this,"queue");j(this,"srv");s!==""&&p2("service group",s);let o="";if(t instanceof Co)this.srv=t,o="";else if(t instanceof So){const c=t;this.srv=c.srv,i===""&&c.queue!==""&&(i=c.queue),o=c.subject}else throw new Error("unknown ServiceGroup type");this.subject=this.calcSubject(o,s),this.queue=i}calcSubject(t,s=""){return s===""?t:t!==""?`${t}.${s}`:s}addEndpoint(t="",s){s=s||{subject:t};const i=typeof s=="function"?{handler:s,subject:t}:s;mo("endpoint",t);let{subject:o,handler:c,metadata:m,queue:y}=i;o=o||t,y=y||this.queue,m2("endpoint subject",o),o=this.calcSubject(this.subject,o);const g={name:t,subject:o,queue:y,handler:c,metadata:m};return this.srv._addEndpoint(g)}addGroup(t="",s=""){return new So(this,t,s)}}function m2(n,t){if(t==="")throw new Error(`${n} cannot be empty`);if(t.indexOf(" ")!==-1)throw new Error(`${n} cannot contain spaces: '${t}'`);const s=t.split(".");s.forEach((i,o)=>{if(i===">"&&o!==s.length-1)throw new Error(`${n} cannot have internal '>': '${t}'`)})}function p2(n,t){if(t.indexOf(" ")!==-1)throw new Error(`${n} cannot contain spaces: '${t}'`);t.split(".").forEach(i=>{if(i===">")throw new Error(`${n} name cannot contain internal '>': '${t}'`)})}class Co{constructor(t,s={name:"",version:""}){j(this,"nc");j(this,"_id");j(this,"config");j(this,"handlers");j(this,"internal");j(this,"_stopped");j(this,"_done");j(this,"started");this.nc=t,this.config=Object.assign({},s),this.config.queue||(this.config.queue="q"),mo("name",this.config.name),mo("queue",this.config.queue),Zs(this.config.version),this._id=Es.next(),this.internal=[],this._done=pt(),this._stopped=!1,this.handlers=[],this.started=new Date().toISOString(),this.reset(),this.nc.closed().then(()=>{this.close().catch()}).catch(i=>{this.close(i).catch()})}static controlSubject(t,s="",i="",o){const c=o??d2;return s===""&&i===""?`${c}.${t}`:(mo("control subject name",s),i!==""?(mo("control subject id",i),`${c}.${t}.${s}.${i}`):`${c}.${t}.${s}`)}get subjects(){return this.handlers.filter(t=>t.internal===!1).map(t=>t.subject)}get id(){return this._id}get name(){return this.config.name}get description(){return this.config.description??""}get version(){return this.config.version}get metadata(){return this.config.metadata}errorToHeader(t){const s=Lr();if(t instanceof fu){const i=t;s.set(cu,i.message),s.set(uu,`${i.code}`)}else s.set(cu,t.message),s.set(uu,"500");return s}setupHandler(t,s=!1){const i=s?"":t.queue?t.queue:this.config.queue,{name:o,subject:c,handler:m}=t,y=t;y.internal=s,s&&this.internal.push(y),y.stats=new y2(o,c,i),y.queue=i;const g=m?(u,d)=>{if(u){this.close(u);return}const b=Date.now();try{m(u,new s1(d))}catch(x){y.stats.countError(x),d==null||d.respond(An,{headers:this.errorToHeader(x)})}finally{y.stats.countLatency(b)}}:void 0;return y.sub=this.nc.subscribe(c,{callback:g,queue:i}),y.sub.closed.then(()=>{this._stopped||this.close(new Error(`required subscription ${t.subject} stopped`)).catch()}).catch(u=>{if(!this._stopped){const d=new Error(`required subscription ${t.subject} errored: ${u.message}`);d.stack=u.stack,this.close(d).catch()}}),y}info(){return{type:bo.INFO,name:this.name,id:this.id,version:this.version,description:this.description,metadata:this.metadata,endpoints:this.endpoints()}}endpoints(){return this.handlers.map(t=>{const{subject:s,metadata:i,name:o,queue:c}=t;return{subject:s,metadata:i,name:o,queue_group:c}})}async stats(){const t=[];for(const s of this.handlers){if(typeof this.config.statsHandler=="function")try{s.stats.data=await this.config.statsHandler(s)}catch(i){s.stats.countError(i)}t.push(s.stats.stats(s.qi))}return{type:bo.STATS,name:this.name,id:this.id,version:this.version,started:this.started,metadata:this.metadata,endpoints:t}}addInternalHandler(t,s){const i=`${t}`.toUpperCase();this._doAddInternalHandler(`${i}-all`,t,s),this._doAddInternalHandler(`${i}-kind`,t,s,this.name),this._doAddInternalHandler(`${i}`,t,s,this.name,this.id)}_doAddInternalHandler(t,s,i,o="",c=""){const m={};m.name=t,m.subject=Co.controlSubject(s,o,c),m.handler=i,this.setupHandler(m,!0)}start(){const t=Wn(),s=(m,y)=>m?(this.close(m),Promise.reject(m)):this.stats().then(g=>(y==null||y.respond(t.encode(g)),Promise.resolve())),i=(m,y)=>m?(this.close(m),Promise.reject(m)):(y==null||y.respond(t.encode(this.info())),Promise.resolve()),o=t.encode(this.ping()),c=(m,y)=>m?(this.close(m).then().catch(),Promise.reject(m)):(y.respond(o),Promise.resolve());return this.addInternalHandler(xs.PING,c),this.addInternalHandler(xs.STATS,s),this.addInternalHandler(xs.INFO,i),this.handlers.forEach(m=>{const{subject:y}=m;typeof y=="string"&&m.handler!==null&&this.setupHandler(m)}),Promise.resolve(this)}close(t){if(this._stopped)return this._done;this._stopped=!0;let s=[];return this.nc.isClosed()||(s=this.handlers.concat(this.internal).map(i=>i.sub.drain())),Promise.allSettled(s).then(()=>{this._done.resolve(t||null)}),this._done}get stopped(){return this._done}get isStopped(){return this._stopped}stop(t){return this.close(t)}ping(){return{type:bo.PING,name:this.name,id:this.id,version:this.version,metadata:this.metadata}}reset(){if(this.started=new Date().toISOString(),this.handlers)for(const t of this.handlers)t.stats.reset(t.qi)}addGroup(t,s){return new So(this,t,s)}addEndpoint(t,s){return new So(this).addEndpoint(t,s)}_addEndpoint(t){const s=new Bt;s.noIterator=typeof t.handler=="function",s.noIterator||(t.handler=(o,c)=>{o?this.stop(o).catch():s.push(new s1(c))},s.iterClosed.then(()=>{this.close().catch()}));const i=this.setupHandler(t,!1);return i.qi=s,this.handlers.push(i),s}}class y2{constructor(t,s,i=""){j(this,"name");j(this,"subject");j(this,"average_processing_time");j(this,"num_requests");j(this,"processing_time");j(this,"num_errors");j(this,"last_error");j(this,"data");j(this,"metadata");j(this,"queue");this.name=t,this.subject=s,this.average_processing_time=0,this.num_errors=0,this.num_requests=0,this.processing_time=0,this.queue=i}reset(t){this.num_requests=0,this.processing_time=0,this.average_processing_time=0,this.num_errors=0,this.last_error=void 0,this.data=void 0;const s=t;s&&(s.time=0,s.processed=0)}countLatency(t){this.num_requests++,this.processing_time+=mt(Date.now()-t),this.average_processing_time=Math.round(this.processing_time/this.num_requests)}countError(t){this.num_errors++,this.last_error=t.message}_stats(){const{name:t,subject:s,average_processing_time:i,num_errors:o,num_requests:c,processing_time:m,last_error:y,data:g,queue:u}=this;return{name:t,subject:s,average_processing_time:i,num_errors:o,num_requests:c,processing_time:m,last_error:y,data:g,queue_group:u}}stats(t){const s=t;return(s==null?void 0:s.noIterator)===!1&&(this.processing_time=mt(s.time),this.num_requests=s.processed,this.average_processing_time=this.processing_time>0&&this.num_requests>0?this.processing_time/this.num_requests:0),this._stats()}}class g2{constructor(t,s={strategy:Qn.JitterTimer,maxWait:2e3},i){j(this,"nc");j(this,"prefix");j(this,"opts");this.nc=t,this.prefix=i,this.opts=s}ping(t="",s=""){return this.q(xs.PING,t,s)}stats(t="",s=""){return this.q(xs.STATS,t,s)}info(t="",s=""){return this.q(xs.INFO,t,s)}async q(t,s="",i=""){const o=new Bt,c=Wn(),m=Co.controlSubject(t,s,i,this.prefix),y=await this.nc.requestMany(m,An,this.opts);return(async()=>{for await(const g of y)try{const u=c.decode(g.data);o.push(u)}catch(u){o.push(()=>{o.stop(u)})}o.push(()=>{o.stop()})})().catch(g=>{o.stop(g)}),o}}function wx(){return{key:{encode(n){return n},decode(n){return n}},value:{encode(n){return n},decode(n){return n}}}}function b2(){return{replicas:1,history:1,timeout:2e3,max_bytes:-1,maxValueSize:-1,codec:wx(),storage:wd.File}}const yu="KV-Operation",i1="$KV",x2=/^[-/=.\w]+$/,v2=/^[-/=.>*\w]+$/,_2=/^[-\w]+$/;function w2(n){if(n.startsWith(".")||n.endsWith(".")||!x2.test(n))throw new Error(`invalid key: ${n}`)}function S2(n){if(n.startsWith(".")||n.endsWith(".")||!v2.test(n))throw new Error(`invalid key: ${n}`)}function E2(n){if(n.startsWith(".")||n.endsWith("."))throw new Error(`invalid key: ${n}`);const t=n.split(".");let s=!1;for(let i=0;i<t.length;i++)switch(t[i]){case"*":s=!0;break;case">":if(i!==t.length-1)throw new Error(`invalid key: ${n}`);s=!0;break}return s}function ru(n){if(!_2.test(n))throw new Error(`invalid bucket name: ${n}`)}var ir;(function(n){n.MsgIdHdr="Nats-Msg-Id",n.ExpectedStreamHdr="Nats-Expected-Stream",n.ExpectedLastSeqHdr="Nats-Expected-Last-Sequence",n.ExpectedLastMsgIdHdr="Nats-Expected-Last-Msg-Id",n.ExpectedLastSubjectSequenceHdr="Nats-Expected-Last-Subject-Sequence"})(ir||(ir={}));class Eo{constructor(t,s,i){j(this,"js");j(this,"jsm");j(this,"stream");j(this,"bucket");j(this,"direct");j(this,"codec");j(this,"prefix");j(this,"editPrefix");j(this,"useJsPrefix");j(this,"_prefixLen");j(this,"validateKey",w2);j(this,"validateSearchKey",S2);j(this,"hasWildcards",E2);ru(t),this.js=s,this.jsm=i,this.bucket=t,this.prefix=i1,this.editPrefix="",this.useJsPrefix=!1,this._prefixLen=0}static async create(t,s,i={}){ru(s);const o=await t.jetstreamManager(),c=new Eo(s,t,o);return await c.init(i),c}static async bind(t,s,i={}){const o=await t.jetstreamManager(),c={config:{allow_direct:i.allow_direct}};ru(s);const m=new Eo(s,t,o);return c.config.name=i.streamName??m.bucketName(),Object.assign(m,c),m.stream=c.config.name,m.codec=i.codec||wx(),m.direct=c.config.allow_direct??!1,m.initializePrefixes(c),m}async init(t={}){const s=Object.assign(b2(),t);this.codec=s.codec;const i={};this.stream=i.name=t.streamName??this.bucketName(),i.retention=_d.Limits,i.max_msgs_per_subject=s.history,s.maxBucketSize&&(s.max_bytes=s.maxBucketSize),s.max_bytes&&(i.max_bytes=s.max_bytes),i.max_msg_size=s.maxValueSize,i.storage=s.storage;const o=t.placementCluster??"";if(o&&(t.placement={},t.placement.cluster=o,t.placement.tags=[]),t.placement&&(i.placement=t.placement),t.republish&&(i.republish=t.republish),t.description&&(i.description=t.description),t.mirror){const b=Object.assign({},t.mirror);b.name.startsWith(_n)||(b.name=`${_n}${b.name}`),i.mirror=b,i.mirror_direct=!0}else if(t.sources){const b=t.sources.map(x=>{const v=Object.assign({},x),w=v.name.startsWith(_n)?v.name.substring(_n.length):v.name;return v.name.startsWith(_n)||(v.name=`${_n}${v.name}`),!x.external&&w!==this.bucket&&(v.subject_transforms=[{src:`$KV.${w}.>`,dest:`$KV.${this.bucket}.>`}]),v});i.sources=b,i.subjects=[this.subjectForBucket()]}else i.subjects=[this.subjectForBucket()];t.metadata&&(i.metadata=t.metadata),typeof t.compression=="boolean"&&(i.compression=t.compression?Os.S2:Os.None);const c=this.js.nc,m=c.getServerVersion(),y=m?Ed(m,Zs("2.7.2"))>=0:!1;i.discard=y?wo.New:wo.Old;const{ok:g,min:u}=c.features.get(Ke.JS_ALLOW_DIRECT);if(!g&&t.allow_direct===!0){const b=m?`${m.major}.${m.minor}.${m.micro}`:"unknown";return Promise.reject(new Error(`allow_direct is not available on server version ${b} - requires ${u}`))}t.allow_direct=typeof t.allow_direct=="boolean"?t.allow_direct:g,i.allow_direct=t.allow_direct,this.direct=i.allow_direct,i.num_replicas=s.replicas,s.ttl&&(i.max_age=mt(s.ttl)),i.allow_rollup_hdrs=!0;let d;try{d=await this.jsm.streams.info(i.name),!d.config.allow_direct&&this.direct===!0&&(this.direct=!1)}catch(b){if(b.message==="stream not found")d=await this.jsm.streams.add(i);else throw b}this.initializePrefixes(d)}initializePrefixes(t){this._prefixLen=0,this.prefix=`$KV.${this.bucket}`,this.useJsPrefix=this.js.apiPrefix!=="$JS.API";const{mirror:s}=t.config;if(s){let i=s.name;if(i.startsWith(_n)&&(i=i.substring(_n.length)),s.external&&s.external.api!==""){const o=s.name.substring(_n.length);this.useJsPrefix=!1,this.prefix=`$KV.${o}`,this.editPrefix=`${s.external.api}.$KV.${i}`}else this.editPrefix=this.prefix}}bucketName(){return this.stream??`${_n}${this.bucket}`}subjectForBucket(){return`${this.prefix}.${this.bucket}.>`}subjectForKey(t,s=!1){const i=[];return s?(this.useJsPrefix&&i.push(this.js.apiPrefix),this.editPrefix!==""?i.push(this.editPrefix):i.push(this.prefix)):this.prefix&&i.push(this.prefix),i.push(t),i.join(".")}fullKeyName(t){return this.prefix!==""?`${this.prefix}.${t}`:`${i1}.${this.bucket}.${t}`}get prefixLen(){return this._prefixLen===0&&(this._prefixLen=this.prefix.length+1),this._prefixLen}encodeKey(t){const s=[];for(const i of t.split("."))switch(i){case">":case"*":s.push(i);break;default:s.push(this.codec.key.encode(i));break}return s.join(".")}decodeKey(t){const s=[];for(const i of t.split("."))switch(i){case">":case"*":s.push(i);break;default:s.push(this.codec.key.decode(i));break}return s.join(".")}close(){return Promise.resolve()}dataLen(t,s){const i=s&&s.get(Qt.MessageSizeHdr)||"";return i!==""?parseInt(i,10):t.length}smToEntry(t){return new U2(this.bucket,this.prefixLen,t)}jmToEntry(t){const s=this.decodeKey(t.subject.substring(this.prefixLen));return new z2(this.bucket,s,t)}async create(t,s){var c;let i;try{const m=await this.put(t,s,{previousSeq:0});return Promise.resolve(m)}catch(m){if(i=m,((c=m==null?void 0:m.api_error)==null?void 0:c.err_code)!==10071)return Promise.reject(m)}let o=0;try{const m=await this.get(t);return(m==null?void 0:m.operation)==="DEL"||(m==null?void 0:m.operation)==="PURGE"?(o=m!==null?m.revision:0,this.update(t,s,o)):Promise.reject(i)}catch(m){return Promise.reject(m)}}update(t,s,i){if(i<=0)throw new Error("version must be greater than 0");return this.put(t,s,{previousSeq:i})}async put(t,s,i={}){var m,y;const o=this.encodeKey(t);this.validateKey(o);const c={};if(i.previousSeq!==void 0){const g=Lr();c.headers=g,g.set(ir.ExpectedLastSubjectSequenceHdr,`${i.previousSeq}`)}try{return(await this.js.publish(this.subjectForKey(o,!0),s,c)).seq}catch(g){const u=g;return u.isJetStreamError()?(u.message=(m=u.api_error)==null?void 0:m.description,u.code=`${(y=u.api_error)==null?void 0:y.code}`,Promise.reject(u)):Promise.reject(g)}}async get(t,s){const i=this.encodeKey(t);this.validateKey(i);let o={last_by_subj:this.subjectForKey(i)};s&&s.revision>0&&(o={seq:s.revision});let c;try{this.direct?c=await this.jsm.direct.getMessage(this.bucketName(),o):c=await this.jsm.streams.getMessage(this.bucketName(),o);const m=this.smToEntry(c);return m.key!==i?null:m}catch(m){if(m.code===ue.JetStream404NoMessages)return null;throw m}}purge(t,s){return this._deleteOrPurge(t,"PURGE",s)}delete(t,s){return this._deleteOrPurge(t,"DEL",s)}async purgeDeletes(t=1800*1e3){const s=pt(),i=[],o=await this.watch({key:">",initializedFn:()=>{s.resolve()}});(async()=>{for await(const g of o)(g.operation==="DEL"||g.operation==="PURGE")&&i.push(g)})().then(),await s,o.stop();const c=Date.now()-t,m=i.map(g=>{const u=this.subjectForKey(g.key);return g.created.getTime()>=c?this.jsm.streams.purge(this.stream,{filter:u,keep:1}):this.jsm.streams.purge(this.stream,{filter:u,keep:0})}),y=await Promise.all(m);return y.unshift({success:!0,purged:0}),y.reduce((g,u)=>(g.purged+=u.purged,g))}async _deleteOrPurge(t,s,i){if(!this.hasWildcards(t))return this._doDeleteOrPurge(t,s,i);const o=await this.keys(t),c=[];for await(const m of o)c.push(this._doDeleteOrPurge(m,s)),c.length===100&&(await Promise.all(c),c.length=0);c.length>0&&await Promise.all(c)}async _doDeleteOrPurge(t,s,i){const o=this.encodeKey(t);this.validateKey(o);const c=Lr();c.set(yu,s),s==="PURGE"&&c.set(Qt.RollupHdr,Qt.RollupValueSubject),i!=null&&i.previousSeq&&c.set(ir.ExpectedLastSubjectSequenceHdr,`${i.previousSeq}`),await this.js.publish(this.subjectForKey(o,!0),An,{headers:c})}_buildCC(t,s,i={}){let c=(Array.isArray(t)?t:[t]).map(g=>{const u=this.encodeKey(g);return this.validateSearchKey(g),this.fullKeyName(u)}),m=Et.LastPerSubject;s===Jn.AllHistory&&(m=Et.All),s===Jn.UpdatesOnly&&(m=Et.New);let y;return c.length===1&&(y=c[0],c=void 0),Object.assign({deliver_policy:m,ack_policy:qt.None,filter_subjects:c,filter_subject:y,flow_control:!0,idle_heartbeat:mt(5*1e3)},i)}remove(t){return this.purge(t)}async history(t={}){const s=t.key??">",i=new Bt,o={};o.headers_only=t.headers_only||!1;let c;c=()=>{i.stop()};let m=0;const y=this._buildCC(s,Jn.AllHistory,o),g=y.filter_subject,u=_s(y);u.bindStream(this.stream),u.orderedConsumer(),u.callback((b,x)=>{if(b){i.stop(b);return}if(x){const v=this.jmToEntry(x);i.push(v),i.received++,(c&&m>0&&i.received>=m||x.info.pending===0)&&(i.push(c),c=void 0)}});const d=await this.js.subscribe(g,u);if(c){const{info:{last:b}}=d,x=b.num_pending+b.delivered.consumer_seq;if(x===0||i.received>=x)try{c()}catch(v){i.stop(v)}finally{c=void 0}else m=x}return i._data=d,i.iterClosed.then(()=>{d.unsubscribe()}),d.closed.then(()=>{i.stop()}).catch(b=>{i.stop(b)}),i}canSetWatcherName(){const s=this.js.nc,{ok:i}=s.features.get(Ke.JS_NEW_CONSUMER_CREATE_API);return i}async watch(t={}){const s=t.key??">",i=new Bt,o={};o.headers_only=t.headers_only||!1;let c=Jn.LastValue;t.include===Jn.AllHistory?c=Jn.AllHistory:t.include===Jn.UpdatesOnly&&(c=Jn.UpdatesOnly);const m=t.ignoreDeletes===!0;let y=t.initializedFn,g=0;const u=this._buildCC(s,c,o),d=u.filter_subject,b=_s(u);this.canSetWatcherName()&&b.consumerName(Es.next()),b.bindStream(this.stream),t.resumeFromRevision&&t.resumeFromRevision>0&&b.startSequence(t.resumeFromRevision),b.orderedConsumer(),b.callback((v,w)=>{if(v){i.stop(v);return}if(w){const S=this.jmToEntry(w);if(m&&S.operation==="DEL")return;i.push(S),i.received++,y&&(g>0&&i.received>=g||w.info.pending===0)&&(i.push(y),y=void 0)}});const x=await this.js.subscribe(d,b);if(y){const{info:{last:v}}=x,w=v.num_pending+v.delivered.consumer_seq;if(w===0||i.received>=w)try{y()}catch(S){i.stop(S)}finally{y=void 0}else g=w}return i._data=x,i.iterClosed.then(()=>{x.unsubscribe()}),x.closed.then(()=>{i.stop()}).catch(v=>{i.stop(v)}),i}async keys(t=">"){const s=new Bt,i=this._buildCC(t,Jn.LastValue,{headers_only:!0}),o=Array.isArray(t)?">":i.filter_subject,c=_s(i);c.bindStream(this.stream),c.orderedConsumer();const m=await this.js.subscribe(o,c);return(async()=>{var g;for await(const u of m){const d=(g=u.headers)==null?void 0:g.get(yu);if(d!=="DEL"&&d!=="PURGE"){const b=this.decodeKey(u.subject.substring(this.prefixLen));s.push(b)}u.info.pending===0&&m.unsubscribe()}})().then(()=>{s.stop()}).catch(g=>{s.stop(g)}),m.info.last.num_pending===0&&m.unsubscribe(),s}purgeBucket(t){return this.jsm.streams.purge(this.bucketName(),t)}destroy(){return this.jsm.streams.delete(this.bucketName())}async status(){var c;const s=((c=this.js.nc.info)==null?void 0:c.cluster)??"",i=this.bucketName(),o=await this.jsm.streams.info(i);return new Sx(o,s)}}class Sx{constructor(t,s=""){j(this,"si");j(this,"cluster");this.si=t,this.cluster=s}get bucket(){return this.si.config.name.startsWith(_n)?this.si.config.name.substring(_n.length):this.si.config.name}get values(){return this.si.state.messages}get history(){return this.si.config.max_msgs_per_subject}get ttl(){return sm(this.si.config.max_age)}get bucket_location(){return this.cluster}get backingStore(){return this.si.config.storage}get storage(){return this.si.config.storage}get replicas(){return this.si.config.num_replicas}get description(){return this.si.config.description??""}get maxBucketSize(){return this.si.config.max_bytes}get maxValueSize(){return this.si.config.max_msg_size}get max_bytes(){return this.si.config.max_bytes}get placement(){return this.si.config.placement||{cluster:"",tags:[]}}get placementCluster(){var t;return((t=this.si.config.placement)==null?void 0:t.cluster)??""}get republish(){return this.si.config.republish??{src:"",dest:""}}get streamInfo(){return this.si}get size(){return this.si.state.bytes}get metadata(){return this.si.config.metadata??{}}get compression(){return this.si.config.compression?this.si.config.compression!==Os.None:!1}}const om="OBJ_",a1="SHA-256=";function O2(n){return ru(n),`${om}${n}`}function A2(n){return n.startsWith(om)?n.substring(4):n}class kd{constructor(t){j(this,"si");j(this,"backingStore");this.si=t,this.backingStore="JetStream"}get bucket(){return A2(this.si.config.name)}get description(){return this.si.config.description??""}get ttl(){return this.si.config.max_age}get storage(){return this.si.config.storage}get replicas(){return this.si.config.num_replicas}get sealed(){return this.si.config.sealed}get size(){return this.si.state.bytes}get streamInfo(){return this.si}get metadata(){return this.si.config.metadata}get compression(){return this.si.config.compression?this.si.config.compression!==Os.None:!1}}function oc(n){if(n===void 0)return;const{domain:t}=n;if(t===void 0)return n;const s=Object.assign({},n);if(delete s.domain,t==="")return s;if(s.external)throw new Error("domain and external are both set");return s.external={api:`$JS.${t}.API`},s}var Un;(function(n){n[n.Unset=-1]="Unset",n[n.Consume=0]="Consume",n[n.Fetch=1]="Fetch"})(Un||(Un={}));var ar;(function(n){n.HeartbeatsMissed="heartbeats_missed",n.ConsumerNotFound="consumer_not_found",n.StreamNotFound="stream_not_found",n.ConsumerDeleted="consumer_deleted",n.OrderedConsumerRecreated="ordered_consumer_recreated",n.NoResponders="no_responders"})(ar||(ar={}));var Qi;(function(n){n.DebugEvent="debug",n.Discard="discard",n.Reset="reset",n.Next="next"})(Qi||(Qi={}));const o1=Uint8Array.of(43,65,67,75),j2=Uint8Array.of(45,78,65,75),ro=Uint8Array.of(43,87,80,73),k2=Uint8Array.of(43,78,88,84),N2=Uint8Array.of(43,84,69,82,77),T2=Uint8Array.of(32);function Oo(n,t=5e3){return new Y2(n,t)}class ed extends Bt{constructor(s,i,o=!1){super();j(this,"consumer");j(this,"opts");j(this,"sub");j(this,"monitor");j(this,"pending");j(this,"inbox");j(this,"refilling");j(this,"pong");j(this,"callback");j(this,"timeout");j(this,"cleanupHandler");j(this,"listeners");j(this,"statusIterator");j(this,"forOrderedConsumer");j(this,"resetHandler");j(this,"abortOnMissingResource");j(this,"bind");j(this,"inBackOff");this.consumer=s;const c=i;this.opts=this.parseOptions(i,o),this.callback=c.callback||null,this.noIterator=typeof this.callback=="function",this.monitor=null,this.pong=null,this.pending={msgs:0,bytes:0,requests:0},this.refilling=o,this.timeout=null,this.inbox=Rr(s.api.nc.options.inboxPrefix),this.listeners=[],this.forOrderedConsumer=!1,this.abortOnMissingResource=c.abort_on_missing_resource===!0,this.bind=c.bind===!0,this.inBackOff=!1,this.start()}start(){const{max_messages:s,max_bytes:i,idle_heartbeat:o,threshold_bytes:c,threshold_messages:m}=this.opts;this.closed().then(g=>{if(this.cleanupHandler)try{this.cleanupHandler(g)}catch{}});const{sub:y}=this;y&&y.unsubscribe(),this.sub=this.consumer.api.nc.subscribe(this.inbox,{callback:(g,u)=>{var b,x,v,w;if(g){this.stop(g);return}if((b=this.monitor)==null||b.work(),u.subject===this.inbox){if(vd(u))return;const S=(x=u.headers)==null?void 0:x.code,C=((w=(v=u.headers)==null?void 0:v.description)==null?void 0:w.toLowerCase())||"unknown",{msgsLeft:q,bytesLeft:B}=this.parseDiscard(u.headers);if(q>0||B>0)this.pending.msgs-=q,this.pending.bytes-=B,this.pending.requests--,this.notify(Qi.Discard,{msgsLeft:q,bytesLeft:B});else if(S===400){this.stop(new ye(C,`${S}`));return}else if(S===409&&C==="consumer deleted"){if(this.notify(ar.ConsumerDeleted,`${S} ${C}`),!this.refilling||this.abortOnMissingResource){const ie=new ye(C,`${S}`);this.stop(ie);return}}else if(S===503){if(this.notify(ar.NoResponders,`${S} No Responders`),!this.refilling||this.abortOnMissingResource){const ie=new ye("no responders",`${S}`);this.stop(ie);return}}else this.notify(Qi.DebugEvent,`${S} ${C}`)}else this._push(Oo(u,this.consumer.api.timeout)),this.received++,this.pending.msgs&&this.pending.msgs--,this.pending.bytes&&(this.pending.bytes-=u.size());if(this.pending.msgs===0&&this.pending.bytes===0&&(this.pending.requests=0),this.refilling){if(s&&this.pending.msgs<=m||i&&this.pending.bytes<=c){const S=this.pullOptions();this.pull(S)}}else this.pending.requests===0&&this._push(()=>{this.stop()})}}),this.sub.closed.then(()=>{this.sub.draining&&this._push(()=>{this.stop()})}),o&&(this.monitor=new am(o,g=>(this.notify(ar.HeartbeatsMissed,g),this.resetPending().then(()=>{}).catch(()=>{}),!1),{maxOut:2})),(async()=>{var u;const g=this.consumer.api.nc.status();this.statusIterator=g;for await(const d of g)switch(d.type){case Mr.Disconnect:(u=this.monitor)==null||u.cancel();break;case Mr.Reconnect:this.resetPending().then(b=>{var x;b&&((x=this.monitor)==null||x.restart())}).catch(()=>{});break}})(),this.pull(this.pullOptions())}_push(s){if(!this.callback)super.push(s);else{const i=typeof s=="function"?s:null;try{i?i():this.callback(s)}catch(o){this.stop(o)}}}notify(s,i){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:i})})}resetPending(){return this.bind?this.resetPendingNoInfo():this.resetPendingWithInfo()}resetPendingNoInfo(){return this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),Promise.resolve(!0)}async resetPendingWithInfo(){if(this.inBackOff)return!1;let s=0,i=0;const o=rm([this.opts.expires]);let c=0;for(;;){if(this.done)return!1;if(this.consumer.api.nc.isClosed())return console.error("aborting resetPending - connection is closed"),!1;try{return await this.consumer.info(),this.inBackOff=!1,s=0,this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),!0}catch(m){if(m.message==="stream not found"){if(i++,this.notify(ar.StreamNotFound,i),!this.refilling||this.abortOnMissingResource)return this.stop(m),!1}else if(m.message==="consumer not found"){if(s++,this.notify(ar.ConsumerNotFound,s),this.resetHandler)try{this.resetHandler()}catch{}if(!this.refilling||this.abortOnMissingResource)return this.stop(m),!1;if(this.forOrderedConsumer)return!1}else s=0,i=0;this.inBackOff=!0;const y=o.backoff(c),g=sa(y);await Promise.race([g,this.consumer.api.nc.closed()]),g.cancel(),c++}}}pull(s){this.pending.bytes+=s.max_bytes??0,this.pending.msgs+=s.batch??0,this.pending.requests++;const i=this.consumer.api.nc;this._push(()=>{i.publish(`${this.consumer.api.prefix}.CONSUMER.MSG.NEXT.${this.consumer.stream}.${this.consumer.name}`,this.consumer.api.jc.encode(s),{reply:this.inbox}),this.notify(Qi.Next,s)})}pullOptions(){const s=this.opts.max_messages-this.pending.msgs,i=this.opts.max_bytes-this.pending.bytes,o=mt(this.opts.idle_heartbeat),c=mt(this.opts.expires);return{batch:s,max_bytes:i,idle_heartbeat:o,expires:c}}parseDiscard(s){const i={msgsLeft:0,bytesLeft:0},o=s==null?void 0:s.get(Qt.PendingMessagesHdr);o&&(i.msgsLeft=parseInt(o));const c=s==null?void 0:s.get(Qt.PendingBytesHdr);return c&&(i.bytesLeft=parseInt(c)),i}trackTimeout(s){this.timeout=s}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}clearTimers(){var s,i;(s=this.monitor)==null||s.cancel(),this.monitor=null,(i=this.timeout)==null||i.cancel(),this.timeout=null}setCleanupHandler(s){this.cleanupHandler=s}stop(s){var i,o;this.done||((i=this.sub)==null||i.unsubscribe(),this.clearTimers(),(o=this.statusIterator)==null||o.stop(),this._push(()=>{super.stop(s),this.listeners.forEach(c=>{c.stop()})}))}parseOptions(s,i=!1){const o=s||{};if(o.max_messages=o.max_messages||0,o.max_bytes=o.max_bytes||0,o.max_messages!==0&&o.max_bytes!==0)throw new Error("only specify one of max_messages or max_bytes");if(o.max_messages===0&&(o.max_messages=100),o.expires=o.expires||3e4,o.expires<1e3)throw new Error("expires should be at least 1000ms");if(o.idle_heartbeat=o.idle_heartbeat||o.expires/2,o.idle_heartbeat=o.idle_heartbeat>3e4?3e4:o.idle_heartbeat,i){const c=Math.round(o.max_messages*.75)||1;o.threshold_messages=o.threshold_messages||c;const m=Math.round(o.max_bytes*.75)||1;o.threshold_bytes=o.threshold_bytes||m}return o}status(){const s=new Bt;return this.listeners.push(s),Promise.resolve(s)}}class C2 extends Bt{constructor(){super();j(this,"src");j(this,"listeners");this.listeners=[]}setSource(s){this.src&&(this.src.resetHandler=void 0,this.src.setCleanupHandler(),this.src.stop()),this.src=s,this.src.setCleanupHandler(i=>{this.stop(i||void 0)}),(async()=>{const i=await this.src.status();for await(const o of i)this.notify(o.type,o.data)})().catch(()=>{})}notify(s,i){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:i})})}stop(s){var i;this.done||((i=this.src)==null||i.stop(s),super.stop(s),this.listeners.forEach(o=>{o.stop()}))}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}status(){const s=new Bt;return this.listeners.push(s),Promise.resolve(s)}}class Nd{constructor(t,s){j(this,"api");j(this,"_info");j(this,"stream");j(this,"name");this.api=t,this._info=s,this.stream=s.stream_name,this.name=s.name}consume(t={max_messages:100,expires:3e4}){return Promise.resolve(new ed(this,t,!0))}fetch(t={max_messages:100,expires:3e4}){const s=new ed(this,t,!1),i=Math.round(s.opts.expires*1.05),o=ea(i);return s.closed().catch(()=>{}).finally(()=>{o.cancel()}),o.catch(()=>{s.close().catch()}),s.trackTimeout(o),Promise.resolve(s)}next(t={expires:3e4}){const s=pt(),i=t;i.max_messages=1;const o=new ed(this,i,!1),c=Math.round(o.opts.expires*1.05);c>=6e4&&(async()=>{for await(const y of await o.status())if(y.type===ar.HeartbeatsMissed&&y.data>=2){s.reject(new Error("consumer missed heartbeats"));break}})().catch(),(async()=>{for await(const y of o){s.resolve(y);break}})().catch(()=>{});const m=ea(c);return o.closed().then(y=>{y?s.reject(y):s.resolve(null)}).catch(y=>{s.reject(y)}).finally(()=>{m.cancel()}),m.catch(y=>{s.resolve(null),o.close().catch()}),o.trackTimeout(m),s}delete(){const{stream_name:t,name:s}=this._info;return this.api.delete(t,s)}info(t=!1){if(t)return Promise.resolve(this._info);const{stream_name:s,name:i}=this._info;return this.api.info(s,i).then(o=>(this._info=o,this._info))}}class M2{constructor(t,s,i={}){j(this,"api");j(this,"consumerOpts");j(this,"consumer");j(this,"opts");j(this,"cursor");j(this,"stream");j(this,"namePrefix");j(this,"serial");j(this,"currentConsumer");j(this,"userCallback");j(this,"iter");j(this,"type");j(this,"startSeq");j(this,"maxInitialReset");this.api=t,this.stream=s,this.cursor={stream_seq:1,deliver_seq:0},this.namePrefix=Es.next(),typeof i.name_prefix=="string"&&(Eu("name_prefix",i.name_prefix),this.namePrefix=i.name_prefix+this.namePrefix),this.serial=0,this.currentConsumer=null,this.userCallback=null,this.iter=null,this.type=Un.Unset,this.consumerOpts=i,this.maxInitialReset=30,this.startSeq=this.consumerOpts.opt_start_seq||0,this.cursor.stream_seq=this.startSeq>0?this.startSeq-1:0}getConsumerOpts(t){this.serial++;const s=`${this.namePrefix}_${this.serial}`;t=t===0?1:t;const i={name:s,deliver_policy:Et.StartSequence,opt_start_seq:t,ack_policy:qt.None,inactive_threshold:mt(300*1e3),num_replicas:1};return this.consumerOpts.headers_only===!0&&(i.headers_only=!0),Array.isArray(this.consumerOpts.filterSubjects)&&(i.filter_subjects=this.consumerOpts.filterSubjects),typeof this.consumerOpts.filterSubjects=="string"&&(i.filter_subject=this.consumerOpts.filterSubjects),this.consumerOpts.replay_policy&&(i.replay_policy=this.consumerOpts.replay_policy),t===this.startSeq+1&&(i.deliver_policy=this.consumerOpts.deliver_policy||Et.StartSequence,(this.consumerOpts.deliver_policy===Et.LastPerSubject||this.consumerOpts.deliver_policy===Et.New||this.consumerOpts.deliver_policy===Et.Last)&&(delete i.opt_start_seq,i.deliver_policy=this.consumerOpts.deliver_policy),i.deliver_policy===Et.LastPerSubject&&typeof i.filter_subjects>"u"&&typeof i.filter_subject>"u"&&(i.filter_subject=">"),this.consumerOpts.opt_start_time&&(delete i.opt_start_seq,i.deliver_policy=Et.StartTime,i.opt_start_time=this.consumerOpts.opt_start_time),this.consumerOpts.inactive_threshold&&(i.inactive_threshold=mt(this.consumerOpts.inactive_threshold))),i}async resetConsumer(t=0){var m,y,g,u,d;Es.next();const s=this.serial===0;(m=this.consumer)==null||m.delete().catch(()=>{}),t=t===0?1:t,this.cursor.deliver_seq=0;const i=this.getConsumerOpts(t);i.max_deliver=1,i.mem_storage=!0;const o=rm([((y=this.opts)==null?void 0:y.expires)||3e4]);let c;for(let b=0;;b++)try{c=await this.api.add(this.stream,i),(g=this.iter)==null||g.notify(ar.OrderedConsumerRecreated,c.name);break}catch(x){if(x.message==="stream not found"&&((u=this.iter)==null||u.notify(ar.StreamNotFound,b),this.type===Un.Fetch||this.opts.abort_on_missing_resource===!0))return(d=this.iter)==null||d.stop(x),Promise.reject(x);if(s&&b>=this.maxInitialReset)throw x;await sa(o.backoff(b+1))}return c}internalHandler(t){return s=>{var o;if(this.serial!==t)return;const i=s.info.deliverySequence;if(i!==this.cursor.deliver_seq+1){this.notifyOrderedResetAndReset();return}this.cursor.deliver_seq=i,this.cursor.stream_seq=s.info.streamSequence,this.userCallback?this.userCallback(s):(o=this.iter)==null||o.push(s)}}async reset(t={max_messages:100,expires:3e4},s){var g,u;s=s||{};const i=s.fromFetch||!1,o=s.orderedReset||!1;if(this.type===Un.Fetch&&o){(g=this.iter)==null||g.src.stop(),await((u=this.iter)==null?void 0:u.closed()),this.currentConsumer=null;return}(this.currentConsumer===null||o)&&(this.currentConsumer=await this.resetConsumer(this.cursor.stream_seq+1)),(this.iter===null||i)&&(this.iter=new C2),this.consumer=new Nd(this.api,this.currentConsumer);const c=t;c.callback=this.internalHandler(this.serial);let m=null;this.type===Un.Fetch&&i?m=await this.consumer.fetch(t):this.type===Un.Consume&&(m=await this.consumer.consume(t));const y=m;y.forOrderedConsumer=!0,y.resetHandler=()=>{this.notifyOrderedResetAndReset()},this.iter.setSource(y)}notifyOrderedResetAndReset(){var t;(t=this.iter)==null||t.notify(Qi.Reset,""),this.reset(this.opts,{orderedReset:!0})}async consume(t={max_messages:100,expires:3e4}){if(t.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===Un.Fetch)return Promise.reject(new Error("ordered consumer initialized as fetch"));if(this.type===Un.Consume)return Promise.reject(new Error("ordered consumer doesn't support concurrent consume"));const{callback:i}=t;return i&&(this.userCallback=i),this.type=Un.Consume,this.opts=t,await this.reset(t),this.iter}async fetch(t={max_messages:100,expires:3e4}){var o;if(t.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===Un.Consume)return Promise.reject(new Error("ordered consumer already initialized as consume"));if(((o=this.iter)==null?void 0:o.done)===!1)return Promise.reject(new Error("ordered consumer doesn't support concurrent fetch"));const{callback:i}=t;return i&&(this.userCallback=i),this.type=Un.Fetch,this.opts=t,await this.reset(t,{fromFetch:!0}),this.iter}async next(t={expires:3e4}){const s=t;if(s.bind)return Promise.reject(new Error("bind is not supported"));s.max_messages=1;const i=pt();return s.callback=c=>{this.userCallback=null,i.resolve(c)},(await this.fetch(s)).iterClosed.then(c=>{c&&i.reject(c),i.resolve(null)}).catch(c=>{i.reject(c)}),i}delete(){return this.currentConsumer?this.api.delete(this.stream,this.currentConsumer.name).then(t=>Promise.resolve(t)).catch(t=>Promise.reject(t)).finally(()=>{this.currentConsumer=null}):Promise.resolve(!1)}async info(t){return this.currentConsumer==null?(this.currentConsumer=await this.resetConsumer(this.startSeq),Promise.resolve(this.currentConsumer)):t&&this.currentConsumer?Promise.resolve(this.currentConsumer):this.api.info(this.stream,this.currentConsumer.name)}}class Td{constructor(t){j(this,"api");j(this,"notified");this.api=t,this.notified=!1}checkVersion(){const t=this.api.nc.features.get(Ke.JS_SIMPLIFICATION);return t.ok?Promise.resolve():Promise.reject(new Error(`consumers framework is only supported on servers ${t.min} or better`))}getPullConsumerFor(t){if(t.config.deliver_subject!==void 0)throw new Error("push consumer not supported");return new Nd(this.api,t)}async get(t,s={}){return typeof s=="object"?this.ordered(t,s):(await this.checkVersion(),this.api.info(t,s).then(i=>i.config.deliver_subject!==void 0?Promise.reject(new Error("push consumer not supported")):new Nd(this.api,i)).catch(i=>Promise.reject(i)))}async ordered(t,s){await this.checkVersion();const i=this.api;return new lm(i.nc,i.opts).info(t).then(c=>Promise.resolve(new M2(this.api,t,s))).catch(c=>Promise.reject(c))}}class Au{constructor(t,s){j(this,"api");j(this,"_info");this.api=t,this._info=s}get name(){return this._info.config.name}alternates(){return this.info().then(t=>t.alternates?t.alternates:[])}async best(){if(await this.info(),this._info.alternates){const t=await this.api.info(this._info.alternates[0].name);return new Au(this.api,t)}else return this}info(t=!1,s){return t?Promise.resolve(this._info):this.api.info(this.name,s).then(i=>(this._info=i,this._info))}getConsumerFromInfo(t){return new Td(new du(this.api.nc,this.api.opts)).getPullConsumerFor(t)}getConsumer(t){return new Td(new du(this.api.nc,this.api.opts)).get(this.name,t)}getMessage(t){return this.api.getMessage(this.name,t)}deleteMessage(t,s){return this.api.deleteMessage(this.name,t,s)}}class lm extends To{constructor(t,s){super(t,s)}checkStreamConfigVersions(t){const s=this.nc;if(t.metadata){const{min:o,ok:c}=s.features.get(Ke.JS_STREAM_CONSUMER_METADATA);if(!c)throw new Error(`stream 'metadata' requires server ${o}`)}if(t.first_seq){const{min:o,ok:c}=s.features.get(Ke.JS_STREAM_FIRST_SEQ);if(!c)throw new Error(`stream 'first_seq' requires server ${o}`)}if(t.subject_transform){const{min:o,ok:c}=s.features.get(Ke.JS_STREAM_SUBJECT_TRANSFORM);if(!c)throw new Error(`stream 'subject_transform' requires server ${o}`)}if(t.compression){const{min:o,ok:c}=s.features.get(Ke.JS_STREAM_COMPRESSION);if(!c)throw new Error(`stream 'compression' requires server ${o}`)}if(t.consumer_limits){const{min:o,ok:c}=s.features.get(Ke.JS_DEFAULT_CONSUMER_LIMITS);if(!c)throw new Error(`stream 'consumer_limits' requires server ${o}`)}function i(o,c){var y;if((((y=c==null?void 0:c.subject_transforms)==null?void 0:y.length)||0)>0){const{min:g,ok:u}=s.features.get(Ke.JS_STREAM_SOURCE_SUBJECT_TRANSFORM);if(!u)throw new Error(`${o} 'subject_transforms' requires server ${g}`)}}t.sources&&t.sources.forEach(o=>{i("stream sources",o)}),t.mirror&&i("stream mirror",t.mirror)}async add(t={}){var o;this.checkStreamConfigVersions(t),Kt(t.name),t.mirror=oc(t.mirror),t.sources=(o=t.sources)==null?void 0:o.map(oc);const i=await this._request(`${this.prefix}.STREAM.CREATE.${t.name}`,t);return this._fixInfo(i),i}async delete(t){return Kt(t),(await this._request(`${this.prefix}.STREAM.DELETE.${t}`)).success}async update(t,s={}){var y;if(typeof t=="object"){const g=t;t=g.name,s=g,console.trace("\x1B[33m >> streams.update(config: StreamConfig) api changed to streams.update(name: string, config: StreamUpdateConfig) - this shim will be removed - update your code. \x1B[0m")}this.checkStreamConfigVersions(s),Kt(t);const i=await this.info(t),o=Object.assign(i.config,s);o.mirror=oc(o.mirror),o.sources=(y=o.sources)==null?void 0:y.map(oc);const m=await this._request(`${this.prefix}.STREAM.UPDATE.${t}`,o);return this._fixInfo(m),m}async info(t,s){Kt(t);const i=`${this.prefix}.STREAM.INFO.${t}`;let c=await this._request(i,s),{total:m,limit:y}=c,g=c.state.subjects?Object.getOwnPropertyNames(c.state.subjects).length:1;if(m&&m>g){const u=[c],d=s||{};let b=0;for(;m>g;){b++,d.offset=y*b;const v=await this._request(i,d);m=v.total,u.push(v);const w=Object.getOwnPropertyNames(v.state.subjects).length;if(g+=w,w<y)break}let x={};for(let v=0;v<u.length;v++)c=u[v],c.state.subjects&&(x=Object.assign(x,c.state.subjects));c.offset=0,c.total=0,c.limit=0,c.state.subjects=x}return this._fixInfo(c),c}list(t=""){const s=t!=null&&t.length?{subject:t}:{},i=c=>{const m=c;return m.streams.forEach(y=>{this._fixInfo(y)}),m.streams},o=`${this.prefix}.STREAM.LIST`;return new po(o,i,this,s)}_fixInfo(t){t.config.sealed=t.config.sealed||!1,t.config.deny_delete=t.config.deny_delete||!1,t.config.deny_purge=t.config.deny_purge||!1,t.config.allow_rollup_hdrs=t.config.allow_rollup_hdrs||!1}async purge(t,s){if(s){const{keep:o,seq:c}=s;if(typeof o=="number"&&typeof c=="number")throw new Error("can specify one of keep or seq")}return Kt(t),await this._request(`${this.prefix}.STREAM.PURGE.${t}`,s)}async deleteMessage(t,s,i=!0){Kt(t);const o={seq:s};return i||(o.no_erase=!0),(await this._request(`${this.prefix}.STREAM.MSG.DELETE.${t}`,o)).success}async getMessage(t,s){Kt(t);const o=await this._request(`${this.prefix}.STREAM.MSG.GET.${t}`,s);return new Ex(o)}find(t){return this.findStream(t)}listKvs(){const t=i=>{var g;const c=i.streams.filter(u=>u.config.name.startsWith(_n));c.forEach(u=>{this._fixInfo(u)});let m="";return c.length&&(m=((g=this.nc.info)==null?void 0:g.cluster)??""),c.map(u=>new Sx(u,m))},s=`${this.prefix}.STREAM.LIST`;return new po(s,t,this)}listObjectStores(){const t=i=>{const c=i.streams.filter(y=>y.config.name.startsWith(om));return c.forEach(y=>{this._fixInfo(y)}),c.map(y=>new kd(y))},s=`${this.prefix}.STREAM.LIST`;return new po(s,t,this)}names(t=""){const s=t!=null&&t.length?{subject:t}:{},i=c=>c.streams,o=`${this.prefix}.STREAM.NAMES`;return new po(o,i,this,s)}async get(t){const s=await this.info(t);return Promise.resolve(new Au(this,s))}}class R2 extends To{constructor(t,s){super(t,s)}async getMessage(t,s){Kt(t);let i=s;const{last_by_subj:o}=i;o&&(i=null);const c=i?this.jc.encode(i):An,m=this.opts.apiPrefix||"$JS.API",y=o?`${m}.DIRECT.GET.${t}.${o}`:`${m}.DIRECT.GET.${t}`,g=await this.nc.request(y,c,{timeout:this.timeout}),u=Ji(g);if(u)return Promise.reject(u);const d=new Cd(g);return Promise.resolve(d)}async getBatch(t,s){Kt(t);const o=`${this.opts.apiPrefix||"$JS.API"}.DIRECT.GET.${t}`;if(!Array.isArray(s.multi_last)||s.multi_last.length===0)return Promise.reject("multi_last is required");const c=JSON.stringify(s,(g,u)=>g==="up_to_time"&&u instanceof Date?u.toISOString():u),m=new Bt,y=await this.nc.requestMany(o,c,{strategy:Qn.SentinelMsg});return(async()=>{var b,x,v;let g=!1,u=!1,d;for await(const w of y){if(!g){g=!0;const S=((b=w.headers)==null?void 0:b.code)||0;if(S!==0&&S<200||S>299){d=(x=w.headers)==null?void 0:x.description.toLowerCase();break}if(((v=w.headers)==null?void 0:v.get("Nats-Num-Pending"))===""){u=!0;break}}if(w.data.length===0)break;m.push(new Cd(w))}m.push(()=>{if(u)throw new Error("batch direct get not supported by the server");if(d)throw new Error(`bad request: ${d}`);m.stop()})})(),Promise.resolve(m)}}class Cd{constructor(t){j(this,"data");j(this,"header");if(!t.headers)throw new Error("headers expected");this.data=t.data,this.header=t.headers}get subject(){return this.header.last(Vi.Subject)}get seq(){const t=this.header.last(Vi.Sequence);return typeof t=="string"?parseInt(t):0}get time(){return new Date(Date.parse(this.timestamp))}get timestamp(){return this.header.last(Vi.TimeStamp)}get stream(){return this.header.last(Vi.Stream)}json(t){return Wn(t).decode(this.data)}string(){return Sn.decode(this.data)}}j(Cd,"jc");class D2 extends To{constructor(s,i){super(s,i);j(this,"streams");j(this,"consumers");j(this,"direct");this.streams=new lm(s,i),this.consumers=new du(s,i),this.direct=new R2(s,i)}async getAccountInfo(){return await this._request(`${this.prefix}.INFO`)}jetstream(){return this.nc.jetstream(this.getOptions())}advisories(){const s=new Bt;return this.nc.subscribe("$JS.EVENT.ADVISORY.>",{callback:(i,o)=>{if(i)throw i;try{const c=this.parseJsResponse(o),m=c.type.split("."),y=m[m.length-1];s.push({kind:y,data:c})}catch(c){s.stop(c)}}}),s}}class Ex{constructor(t){j(this,"_header");j(this,"smr");this.smr=t}get subject(){return this.smr.message.subject}get seq(){return this.smr.message.seq}get timestamp(){return this.smr.message.time}get time(){return new Date(Date.parse(this.timestamp))}get data(){return this.smr.message.data?this._parse(this.smr.message.data):An}get header(){if(!this._header)if(this.smr.message.hdrs){const t=this._parse(this.smr.message.hdrs);this._header=vs.decode(t)}else this._header=Lr();return this._header}_parse(t){const s=atob(t),i=s.length,o=new Uint8Array(i);for(let c=0;c<i;c++)o[c]=s.charCodeAt(c);return o}json(t){return Wn(t).decode(this.data)}string(){return Sn.decode(this.data)}}j(Ex,"jc");class L2{constructor(t){j(this,"api");this.api=t}get(t){return this.api.info(t).then(s=>new Au(this.api,s))}}class td{constructor(t){j(this,"info");j(this,"hdrs");this.info=t}get name(){return this.info.name}get description(){return this.info.description??""}get headers(){return this.hdrs||(this.hdrs=vs.fromRecord(this.info.headers||{})),this.hdrs}get options(){return this.info.options}get bucket(){return this.info.bucket}get chunks(){return this.info.chunks}get deleted(){return this.info.deleted??!1}get digest(){return this.info.digest}get mtime(){return this.info.mtime}get nuid(){return this.info.nuid}get size(){return this.info.size}get revision(){return this.info.revision}get metadata(){return this.info.metadata||{}}isLink(){var t,s;return((t=this.info.options)==null?void 0:t.link)!==void 0&&((s=this.info.options)==null?void 0:s.link)!==null}}function l1(n){const t={name:n.name,description:n.description??"",options:n.options,metadata:n.metadata};if(n.headers){const s=n.headers;t.headers=s.toRecord()}return t}function q2(){return new ReadableStream({pull(n){n.enqueue(new Uint8Array(0)),n.close()}})}class vo{constructor(t,s,i){j(this,"jsm");j(this,"js");j(this,"stream");j(this,"name");this.name=t,this.jsm=s,this.js=i}_checkNotEmpty(t){return!t||t.length===0?{name:t,error:new Error("name cannot be empty")}:{name:t}}async info(t){const s=await this.rawInfo(t);return s?new td(s):null}async list(){const t=[],s=await this.watch({ignoreDeletes:!0,includeHistory:!0});for await(const i of s){if(i===null)break;t.push(i)}return Promise.resolve(t)}async rawInfo(t){const{name:s,error:i}=this._checkNotEmpty(t);if(i)return Promise.reject(i);const o=this._metaSubject(s);try{const c=await this.jsm.streams.getMessage(this.stream,{last_by_subj:o}),y=Wn().decode(c.data);return y.revision=c.seq,y}catch(c){return c.code==="404"?null:Promise.reject(c)}}async _si(t){try{return await this.jsm.streams.info(this.stream,t)}catch(s){return s.code==="404"?null:Promise.reject(s)}}async seal(){let t=await this._si();return t===null?Promise.reject(new Error("object store not found")):(t.config.sealed=!0,t=await this.jsm.streams.update(this.stream,t.config),Promise.resolve(new kd(t)))}async status(t){const s=await this._si(t);return s===null?Promise.reject(new Error("object store not found")):Promise.resolve(new kd(s))}destroy(){return this.jsm.streams.delete(this.stream)}async _put(t,s,i){var le;const o=this.js.getOptions();i=i||{timeout:o.timeout},i.timeout=i.timeout||o.timeout,i.previousRevision=i.previousRevision??void 0;const{timeout:c,previousRevision:m}=i,y=this.js.nc.info,g=(y==null?void 0:y.max_payload)||1024;t=t||{},t.options=t.options||{};let u=((le=t.options)==null?void 0:le.max_chunk_size)||128*1024;u=u>g?g:u,t.options.max_chunk_size=u;const d=await this.info(t.name),{name:b,error:x}=this._checkNotEmpty(t.name);if(x)return Promise.reject(x);const v=Es.next(),w=this._chunkSubject(v),S=this._metaSubject(b),C=Object.assign({bucket:this.name,nuid:v,size:0,chunks:0},l1(t)),q=pt(),B=[],ie=new na;try{const R=s?s.getReader():null,$=Qg.create();for(;;){const{done:ne,value:V}=R?await R.read():{done:!0,value:void 0};if(ne){if(ie.size()>0){const X=ie.drain();$.update(X),C.chunks++,C.size+=X.length,B.push(this.js.publish(w,X,{timeout:c}))}await Promise.all(B),B.length=0,C.mtime=new Date().toISOString();const I=Xi.encode($.digest());C.digest=`${a1}${I}`,C.deleted=!1;const D=Lr();typeof m=="number"&&D.set(ir.ExpectedLastSubjectSequenceHdr,`${m}`),D.set(Qt.RollupHdr,Qt.RollupValueSubject);const Q=await this.js.publish(S,Wn().encode(C),{headers:D,timeout:c});if(C.revision=Q.seq,d)try{await this.jsm.streams.purge(this.stream,{filter:`$O.${this.name}.C.${d.nuid}`})}catch{}q.resolve(new td(C));break}if(V)for(ie.fill(V);ie.size()>u;){C.chunks++,C.size+=u;const I=ie.drain(t.options.max_chunk_size);$.update(I),B.push(this.js.publish(w,I,{timeout:c}))}}}catch(R){await this.jsm.streams.purge(this.stream,{filter:w}),q.reject(R)}return q}putBlob(t,s,i){function o(c){return new ReadableStream({pull(m){m.enqueue(c),m.close()}})}return s===null&&(s=new Uint8Array(0)),this.put(t,o(s),i)}put(t,s,i){var o;return(o=t==null?void 0:t.options)!=null&&o.link?Promise.reject(new Error("link cannot be set when putting the object in bucket")):this._put(t,s,i)}async getBlob(t){async function s(c){const m=new na,y=c.getReader();for(;;){const{done:g,value:u}=await y.read();if(g)return m.drain();u&&u.length&&m.fill(u)}}const i=await this.get(t);if(i===null)return Promise.resolve(null);const o=await Promise.all([i.error,s(i.data)]);return o[0]?Promise.reject(o[0]):Promise.resolve(o[1])}async get(t){const s=await this.rawInfo(t);if(s===null||s.deleted)return Promise.resolve(null);if(s.options&&s.options.link){const b=s.options.link.name||"";if(b==="")throw new Error("link is a bucket");return(s.options.link.bucket!==this.name?await vo.create(this.js,s.options.link.bucket):this).get(b)}if(!s.digest.startsWith(a1))return Promise.reject(new Error(`unknown digest type: ${s.digest}`));const i=Sd(s.digest.substring(8));if(i===null)return Promise.reject(new Error(`unable to parse digest: ${s.digest}`));const o=pt(),c={info:new td(s),error:o};if(s.size===0)return c.data=q2(),o.resolve(null),Promise.resolve(c);let m;const y=_s();y.orderedConsumer();const g=Qg.create(),u=`$O.${this.name}.C.${s.nuid}`,d=await this.js.subscribe(u,y);return(async()=>{for await(const b of d)b.data.length>0&&(g.update(b.data),m.enqueue(b.data)),b.info.pending===0&&(EE(i,g.digest())?m.close():m.error(new Error(`received a corrupt object, digests do not match received: ${s.digest} calculated ${i}`)),d.unsubscribe())})().then(()=>{o.resolve()}).catch(b=>{m.error(b),o.reject(b)}),c.data=new ReadableStream({start(b){m=b},cancel(){d.unsubscribe()}}),c}linkStore(t,s){if(!(s instanceof vo))return Promise.reject("bucket required");const i=s,{name:o,error:c}=this._checkNotEmpty(t);if(c)return Promise.reject(c);const m={name:o,options:{link:{bucket:i.name}}};return this._put(m,null)}async link(t,s){const{name:i,error:o}=this._checkNotEmpty(t);if(o)return Promise.reject(o);if(s.deleted)return Promise.reject(new Error("src object is deleted"));if(s.isLink())return Promise.reject(new Error("src object is a link"));const c=await this.rawInfo(t);if(c!==null&&!c.deleted)return Promise.reject(new Error("an object already exists with that name"));const m={bucket:s.bucket,name:s.name},y={name:i,bucket:s.bucket,options:{link:m}};await this.js.publish(this._metaSubject(t),JSON.stringify(y));const g=await this.info(t);return Promise.resolve(g)}async delete(t){const s=await this.rawInfo(t);if(s===null)return Promise.resolve({purged:0,success:!1});s.deleted=!0,s.size=0,s.chunks=0,s.digest="";const i=Wn(),o=Lr();return o.set(Qt.RollupHdr,Qt.RollupValueSubject),await this.js.publish(this._metaSubject(s.name),i.encode(s),{headers:o}),this.jsm.streams.purge(this.stream,{filter:this._chunkSubject(s.nuid)})}async update(t,s={}){const i=await this.rawInfo(t);if(i===null)return Promise.reject(new Error("object not found"));if(i.deleted)return Promise.reject(new Error("cannot update meta for a deleted object"));s.name=s.name??i.name;const{name:o,error:c}=this._checkNotEmpty(s.name);if(c)return Promise.reject(c);if(t!==s.name){const g=await this.info(s.name);if(g&&!g.deleted)return Promise.reject(new Error("an object already exists with that name"))}s.name=o;const m=Object.assign({},i,l1(s)),y=await this.js.publish(this._metaSubject(m.name),JSON.stringify(m));return t!==s.name&&await this.jsm.streams.purge(this.stream,{filter:this._metaSubject(t)}),Promise.resolve(y)}async watch(t={}){t.includeHistory=t.includeHistory??!1,t.ignoreDeletes=t.ignoreDeletes??!1;let s=!1;const i=new Bt,o=this._metaSubjectAll();try{await this.jsm.streams.getMessage(this.stream,{last_by_subj:o})}catch(g){g.code==="404"?(i.push(null),s=!0):i.stop(g)}const c=Wn(),m=_s();m.orderedConsumer(),t.includeHistory?m.deliverLastPerSubject():(s=!0,m.deliverNew()),m.callback((g,u)=>{var d;if(g){i.stop(g);return}if(u!==null){const b=c.decode(u.data);b.deleted&&t.ignoreDeletes===!0||i.push(b),((d=u.info)==null?void 0:d.pending)===0&&!s&&(s=!0,i.push(null))}});const y=await this.js.subscribe(o,m);return i._data=y,i.iterClosed.then(()=>{y.unsubscribe()}),y.closed.then(()=>{i.stop()}).catch(g=>{i.stop(g)}),i}_chunkSubject(t){return`$O.${this.name}.C.${t}`}_metaSubject(t){return`$O.${this.name}.M.${Xi.encode(t)}`}_metaSubjectAll(){return`$O.${this.name}.M.>`}async init(t={}){try{this.stream=O2(this.name)}catch(o){return Promise.reject(o)}const s=(t==null?void 0:t.ttl)||0;delete t.ttl;const i=Object.assign({max_age:s},t);i.name=this.stream,i.num_replicas=t.replicas??1,i.allow_direct=!0,i.allow_rollup_hdrs=!0,i.discard=wo.New,i.subjects=[`$O.${this.name}.C.>`,`$O.${this.name}.M.>`],t.placement&&(i.placement=t.placement),t.metadata&&(i.metadata=t.metadata),typeof t.compression=="boolean"&&(i.compression=t.compression?Os.S2:Os.None);try{await this.jsm.streams.info(i.name)}catch(o){o.message==="stream not found"&&await this.jsm.streams.add(i)}}static async create(t,s,i={}){const o=await t.jetstreamManager(),c=new vo(s,o,t);return await c.init(i),Promise.resolve(c)}}class B2{constructor(t){j(this,"js");this.js=t}kv(t,s={}){const i=this.js,{ok:o,min:c}=i.nc.features.get(Ke.JS_KV);return o?s.bindOnly?Eo.bind(this.js,t,s):Eo.create(this.js,t,s):Promise.reject(new Error(`kv is only supported on servers ${c} or better`))}os(t,s={}){var m;if(typeof((m=crypto==null?void 0:crypto.subtle)==null?void 0:m.digest)!="function")return Promise.reject(new Error("objectstore: unable to calculate hashes - crypto.subtle.digest with sha256 support is required"));const i=this.js,{ok:o,min:c}=i.nc.features.get(Ke.JS_OBJECTSTORE);return o?vo.create(this.js,t,s):Promise.reject(new Error(`objectstore is only supported on servers ${c} or better`))}}class cm extends To{constructor(s,i){super(s,i);j(this,"consumers");j(this,"streams");j(this,"consumerAPI");j(this,"streamAPI");this.consumerAPI=new du(s,i),this.streamAPI=new lm(s,i),this.consumers=new Td(this.consumerAPI),this.streams=new L2(this.streamAPI)}jetstreamManager(s){s===void 0&&(s=this.opts.checkAPI);const i=Object.assign({},this.opts,{checkAPI:s});return this.nc.jetstreamManager(i)}get apiPrefix(){return this.prefix}get views(){return new B2(this)}async publish(s,i=An,o){o=o||{},o.expect=o.expect||{};const c=(o==null?void 0:o.headers)||Lr();o&&(o.msgID&&c.set(ir.MsgIdHdr,o.msgID),o.expect.lastMsgID&&c.set(ir.ExpectedLastMsgIdHdr,o.expect.lastMsgID),o.expect.streamName&&c.set(ir.ExpectedStreamHdr,o.expect.streamName),typeof o.expect.lastSequence=="number"&&c.set(ir.ExpectedLastSeqHdr,`${o.expect.lastSequence}`),typeof o.expect.lastSubjectSequence=="number"&&c.set(ir.ExpectedLastSubjectSequenceHdr,`${o.expect.lastSubjectSequence}`));const m=o.timeout||this.timeout,y={};m&&(y.timeout=m),o&&(y.headers=c);let{retries:g,retry_delay:u}=o;g=g||1,u=u||250;let d;for(let x=0;x<g;x++)try{d=await this.nc.request(s,i,y);break}catch(v){if(v.code==="503"&&x+1<g)await sa(u);else throw v}const b=this.parseJsResponse(d);if(b.stream==="")throw ye.errorForCode(ue.JetStreamInvalidAck);return b.duplicate=b.duplicate?b.duplicate:!1,b}async pull(s,i,o=0){Kt(s),Ki(i);let c=this.timeout;o>c&&(c=o),o=o<0?0:mt(o);const m={batch:1,no_wait:o===0,expires:o},y=await this.nc.request(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${i}`,this.jc.encode(m),{noMux:!0,timeout:c}),g=Ji(y);if(g)throw g;return Oo(y,this.timeout)}fetch(s,i,o={}){Kt(s),Ki(i);let c=null;const m=(o.max_bytes??0)>0;let y=0;const g=m?o.max_bytes:0;let u=null;const d={};if(d.batch=o.batch||1,g){const B=this.nc.features.get(Ke.JS_PULL_MAX_BYTES);if(!B.ok)throw new Error(`max_bytes is only supported on servers ${B.min} or better`);d.max_bytes=g}d.no_wait=o.no_wait||!1,d.no_wait&&d.expires&&(d.expires=0);const b=o.expires||0;if(b&&(d.expires=mt(b)),b===0&&d.no_wait===!1)throw new Error("expires or no_wait is required");const x=o.idle_heartbeat||0;x&&(d.idle_heartbeat=mt(x),o.delay_heartbeat===!0&&(d.idle_heartbeat=mt(x*4)));const v=new Bt,w=d.batch;let S=0;v.protocolFilterFn=(B,ie=!1)=>vd(B.msg)?(u==null||u.work(),!1):!0,v.dispatchedFn=B=>{if(B){if(m&&(y+=B.data.length),S++,c&&B.info.pending===0)return;(v.getPending()===1&&B.info.pending===0||w===S||g>0&&y>=g)&&v.stop()}};const C=Rr(this.nc.options.inboxPrefix),q=this.nc.subscribe(C,{max:o.batch,callback:(B,ie)=>{B===null&&(B=Ji(ie)),B!==null?(c&&(c.cancel(),c=null),iE(B)?v.stop(Ax(B)===null?void 0:B):v.stop(B)):(u==null||u.work(),v.received++,v.push(Oo(ie,this.timeout)))}});return b&&(c=ea(b),c.catch(()=>{q.isClosed()||(q.drain().catch(()=>{}),c=null),u&&u.cancel()})),(async()=>{try{x&&(u=new am(x,B=>(v.push(()=>{v.err=new ye(`${zn.IdleHeartbeatMissed}: ${B}`,ue.JetStreamIdleHeartBeat)}),!0)))}catch{}await q.closed,c!==null&&(c.cancel(),c=null),u&&u.cancel(),v.stop()})().catch(),this.nc.publish(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${i}`,this.jc.encode(d),{reply:C}),v}async pullSubscribe(s,i=_s()){const o=await this._processOptions(s,i);if(o.ordered)throw new Error("pull subscribers cannot be be ordered");if(o.config.deliver_subject)throw new Error("consumer info specifies deliver_subject - pull consumers cannot have deliver_subject set");const c=o.config.ack_policy;if(c===qt.None||c===qt.All)throw new Error("ack policy for pull consumers must be explicit");const m=this._buildTypedSubscriptionOpts(o),y=new I2(this,o.deliver,m);y.info=o;try{await this._maybeCreateConsumer(o)}catch(g){throw y.unsubscribe(),g}return y}async subscribe(s,i=_s()){const o=await this._processOptions(s,i);if(!o.isBind&&!o.config.deliver_subject)throw new Error("push consumer requires deliver_subject");const c=this._buildTypedSubscriptionOpts(o),m=new Ox(this,o.deliver,c);m.info=o;try{await this._maybeCreateConsumer(o)}catch(y){throw m.unsubscribe(),y}return m._maybeSetupHbMonitoring(),m}async _processOptions(s,i=_s()){const o=Yg(i)?i.getOpts():i;if(o.isBind=Yg(i)?i.isBind:!1,o.flow_control={heartbeat_count:0,fc_count:0,consumer_restarts:0},o.ordered){if(o.ordered_consumer_sequence={stream_seq:0,delivery_seq:0},o.config.ack_policy!==qt.NotSet&&o.config.ack_policy!==qt.None)throw new ye("ordered consumer: ack_policy can only be set to 'none'",ue.ApiError);if(o.config.durable_name&&o.config.durable_name.length>0)throw new ye("ordered consumer: durable_name cannot be set",ue.ApiError);if(o.config.deliver_subject&&o.config.deliver_subject.length>0)throw new ye("ordered consumer: deliver_subject cannot be set",ue.ApiError);if(o.config.max_deliver!==void 0&&o.config.max_deliver>1)throw new ye("ordered consumer: max_deliver cannot be set",ue.ApiError);if(o.config.deliver_group&&o.config.deliver_group.length>0)throw new ye("ordered consumer: deliver_group cannot be set",ue.ApiError);o.config.deliver_subject=Rr(this.nc.options.inboxPrefix),o.config.ack_policy=qt.None,o.config.max_deliver=1,o.config.flow_control=!0,o.config.idle_heartbeat=o.config.idle_heartbeat||mt(5e3),o.config.ack_wait=mt(1320*60*1e3),o.config.mem_storage=!0,o.config.num_replicas=1}if(o.config.ack_policy===qt.NotSet&&(o.config.ack_policy=qt.All),o.api=this,o.config=o.config||{},o.stream=o.stream?o.stream:await this.findStream(s),o.attached=!1,o.config.durable_name)try{const c=await this.consumerAPI.info(o.stream,o.config.durable_name);if(c){if(c.config.filter_subject&&c.config.filter_subject!==s)throw new Error("subject does not match consumer");const m=o.config.deliver_group??"";if(m===""&&c.push_bound===!0)throw new Error("duplicate subscription");const y=c.config.deliver_group??"";if(m!==y)throw y===""?new Error("durable requires no queue group"):new Error(`durable requires queue group '${y}'`);o.last=c,o.config=c.config,o.attached=!0,o.config.durable_name||(o.name=c.name)}}catch(c){if(c.code!=="404")throw c}return!o.attached&&o.config.filter_subject===void 0&&o.config.filter_subjects===void 0&&(o.config.filter_subject=s),o.deliver=o.config.deliver_subject||Rr(this.nc.options.inboxPrefix),o}_buildTypedSubscriptionOpts(s){const i={};return i.adapter=$2(s.callbackFn===void 0,this.timeout),i.ingestionFilterFn=cm.ingestionFn(s.ordered),i.protocolFilterFn=(o,c=!1)=>{const m=o;return xd(m.msg)?(c||m.msg.respond(),!1):!0},!s.mack&&s.config.ack_policy!==qt.None&&(i.dispatchedFn=G2),s.callbackFn&&(i.callback=s.callbackFn),i.max=s.max||0,i.queue=s.queue,i}async _maybeCreateConsumer(s){if(s.attached)return;if(s.isBind)throw new Error(`unable to bind - durable consumer ${s.config.durable_name} doesn't exist in ${s.stream}`);s.config=Object.assign({deliver_policy:Et.All,ack_policy:qt.Explicit,ack_wait:mt(30*1e3),replay_policy:ta.Instant},s.config);const i=await this.consumerAPI.add(s.stream,s.config);if(Array.isArray(s.config.filter_subjects&&!Array.isArray(i.config.filter_subjects)))throw new Error("jetstream server doesn't support consumers with multiple filter subjects");s.name=i.name,s.config=i.config,s.last=i}static ingestionFn(s){return(i,o)=>{var g;const c=o;if(!i)return{ingest:!1,protocol:!1};const m=i;if(Ji(m.msg)||(g=c.monitor)==null||g.work(),vd(m.msg)){const u=s?c._checkHbOrderConsumer(m.msg):!0;return s||c.info.flow_control.heartbeat_count++,{ingest:u,protocol:!0}}else if(xd(m.msg))return c.info.flow_control.fc_count++,{ingest:!0,protocol:!0};return{ingest:s?c._checkOrderedConsumer(i):!0,protocol:!1}}}}class um{constructor(t){j(this,"options");j(this,"protocol");j(this,"draining");j(this,"listeners");j(this,"_services");this.draining=!1,this.options=a2(t),this.listeners=[]}static connect(t={}){return new Promise((s,i)=>{const o=new um(t);pu.connect(o.options,o).then(c=>{o.protocol=c,(async function(){for await(const m of c.status())o.listeners.forEach(y=>{y.push(m)})})(),s(o)}).catch(c=>{i(c)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(t,s,i){if(this.isClosed())throw ye.errorForCode(ue.ConnectionClosed);if(s&&this.isDraining()||i&&this.protocol.noMorePublishing)throw ye.errorForCode(ue.ConnectionDraining);if(t=t||"",t.length===0)throw ye.errorForCode(ue.BadSubject)}publish(t,s,i){this._check(t,!1,!0),this.protocol.publish(t,s,i)}publishMessage(t){return this.publish(t.subject,t.data,{reply:t.reply,headers:t.headers})}respondMessage(t){return t.reply?(this.publish(t.reply,t.data,{reply:t.reply,headers:t.headers}),!0):!1}subscribe(t,s={}){this._check(t,!0,!1);const i=new _x(this.protocol,t,s);return this.protocol.subscribe(i),i}_resub(t,s,i){this._check(s,!0,!1);const o=t;o.max=i,i&&(o.max=i+o.received),this.protocol.resub(o,s)}requestMany(t,s=An,i={maxWait:1e3,maxMessages:-1}){const o=!this.protocol.options.noAsyncTraces;try{this._check(t,!0,!0)}catch(g){return Promise.reject(g)}if(i.strategy=i.strategy||Qn.Timer,i.maxWait=i.maxWait||1e3,i.maxWait<1)return Promise.reject(new ye("timeout",ue.InvalidOption));const c=new Bt;function m(g){c.push(()=>{c.stop(g)})}function y(g,u){g||u===null?m(g===null?void 0:g):c.push(u)}if(i.noMux){const g=o?new Error().stack:null;let u=typeof i.maxMessages=="number"&&i.maxMessages>0?i.maxMessages:-1;const d=this.subscribe(Rr(this.options.inboxPrefix),{callback:(w,S)=>{var C,q;if(((C=S==null?void 0:S.data)==null?void 0:C.length)===0&&((q=S==null?void 0:S.headers)==null?void 0:q.status)===ue.NoResponders&&(w=ye.errorForCode(ue.NoResponders)),w){g&&(w.stack+=`
48
48
 
49
- ${g}`),b(w);return}y(null,S),i.strategy===Qn.Count&&(u--,u===0&&b()),i.strategy===Qn.JitterTimer&&(v(),x=setTimeout(()=>{b()},300)),i.strategy===Qn.SentinelMsg&&S&&S.data.length===0&&b()}});d.requestSubject=t,d.closed.then(()=>{m()}).catch(w=>{c.stop(w)});const b=w=>{w&&c.push(()=>{throw w}),v(),d.drain().then(()=>{m()}).catch(S=>{m()})};c.iterClosed.then(()=>{v(),d==null||d.unsubscribe()}).catch(w=>{v(),d==null||d.unsubscribe()});try{this.publish(t,s,{reply:d.getSubject()})}catch(w){b(w)}let x=setTimeout(()=>{b()},i.maxWait);const v=()=>{x&&clearTimeout(x)}}else{const g=i;g.callback=y,c.iterClosed.then(()=>{u.cancel()}).catch(d=>{u.cancel(d)});const u=new AE(this.protocol.muxSubscriptions,t,g);this.protocol.request(u);try{this.publish(t,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${u.token}`,headers:i.headers})}catch(d){u.cancel(d)}}return Promise.resolve(c)}request(t,s,i={timeout:1e3,noMux:!1}){try{this._check(t,!0,!0)}catch(c){return Promise.reject(c)}const o=!this.protocol.options.noAsyncTraces;if(i.timeout=i.timeout||1e3,i.timeout<1)return Promise.reject(new ye("timeout",ue.InvalidOption));if(!i.noMux&&i.reply)return Promise.reject(new ye("reply can only be used with noMux",ue.InvalidOption));if(i.noMux){const c=i.reply?i.reply:Rr(this.options.inboxPrefix),m=pt(),y=o?new Error:null,g=this.subscribe(c,{max:1,timeout:i.timeout,callback:(u,d)=>{u?(y&&u.code!==ue.Timeout&&(u.stack+=`
49
+ ${g}`),b(w);return}y(null,S),i.strategy===Qn.Count&&(u--,u===0&&b()),i.strategy===Qn.JitterTimer&&(v(),x=setTimeout(()=>{b()},300)),i.strategy===Qn.SentinelMsg&&S&&S.data.length===0&&b()}});d.requestSubject=t,d.closed.then(()=>{m()}).catch(w=>{c.stop(w)});const b=w=>{w&&c.push(()=>{throw w}),v(),d.drain().then(()=>{m()}).catch(S=>{m()})};c.iterClosed.then(()=>{v(),d==null||d.unsubscribe()}).catch(w=>{v(),d==null||d.unsubscribe()});try{this.publish(t,s,{reply:d.getSubject()})}catch(w){b(w)}let x=setTimeout(()=>{b()},i.maxWait);const v=()=>{x&&clearTimeout(x)}}else{const g=i;g.callback=y,c.iterClosed.then(()=>{u.cancel()}).catch(d=>{u.cancel(d)});const u=new OE(this.protocol.muxSubscriptions,t,g);this.protocol.request(u);try{this.publish(t,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${u.token}`,headers:i.headers})}catch(d){u.cancel(d)}}return Promise.resolve(c)}request(t,s,i={timeout:1e3,noMux:!1}){try{this._check(t,!0,!0)}catch(c){return Promise.reject(c)}const o=!this.protocol.options.noAsyncTraces;if(i.timeout=i.timeout||1e3,i.timeout<1)return Promise.reject(new ye("timeout",ue.InvalidOption));if(!i.noMux&&i.reply)return Promise.reject(new ye("reply can only be used with noMux",ue.InvalidOption));if(i.noMux){const c=i.reply?i.reply:Rr(this.options.inboxPrefix),m=pt(),y=o?new Error:null,g=this.subscribe(c,{max:1,timeout:i.timeout,callback:(u,d)=>{u?(y&&u.code!==ue.Timeout&&(u.stack+=`
50
50
 
51
- ${y.stack}`),g.unsubscribe(),m.reject(u)):(u=dx(d),u?(y&&(u.stack+=`
51
+ ${y.stack}`),g.unsubscribe(),m.reject(u)):(u=hx(d),u?(y&&(u.stack+=`
52
52
 
53
- ${y.stack}`),m.reject(u)):m.resolve(d))}});return g.requestSubject=t,this.protocol.publish(t,s,{reply:c,headers:i.headers}),m}else{const c=new yx(this.protocol.muxSubscriptions,t,i,o);this.protocol.request(c);try{this.publish(t,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${c.token}`,headers:i.headers})}catch(y){c.cancel(y)}const m=Promise.race([c.timer,c.deferred]);return m.catch(()=>{c.cancel()}),m}}flush(){return this.isClosed()?Promise.reject(ye.errorForCode(ue.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(ye.errorForCode(ue.ConnectionClosed)):this.isDraining()?Promise.reject(ye.errorForCode(ue.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const t=this.protocol.getServer();return t?t.listen:""}status(){const t=new Bt;return t.iterClosed.then(()=>{const s=this.listeners.indexOf(t);this.listeners.splice(s,1)}),this.listeners.push(t),t}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request("$SYS.REQ.USER.INFO")).json((s,i)=>s==="time"?new Date(Date.parse(i)):i)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(t={}){const s=new L2(this,t);if(t.checkAPI!==!1)try{await s.getAccountInfo()}catch(i){const o=i;throw o.code===ue.NoResponders&&(o.code=ue.JetStreamNotEnabled),o}return s}jetstream(t={}){return new cm(this,t)}getServerVersion(){const t=this.info;return t?Zs(t.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw ye.errorForCode(ue.Disconnect);const t=Date.now();return await this.flush(),Date.now()-t}get features(){return this.protocol.features}get services(){return this._services||(this._services=new U2(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(ye.errorForCode(ue.ConnectionClosed)):this.isDraining()?Promise.reject(ye.errorForCode(ue.ConnectionDraining)):this.protocol.reconnect()}}class U2{constructor(t){j(this,"nc");this.nc=t}add(t){try{return new Co(this.nc,t).start()}catch(s){return Promise.reject(s)}}client(t,s){return new b2(this.nc,t,s)}}class z2{constructor(t,s,i){j(this,"bucket");j(this,"sm");j(this,"prefixLen");this.bucket=t,this.prefixLen=s,this.sm=i}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(yu)||"PUT"}get length(){const t=this.sm.header.get(Qt.MessageSizeHdr)||"";return t!==""?parseInt(t,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class I2{constructor(t,s,i){j(this,"bucket");j(this,"key");j(this,"sm");this.bucket=t,this.key=s,this.sm=i}get value(){return this.sm.data}get created(){return new Date(sm(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var t;return((t=this.sm.headers)==null?void 0:t.get(yu))||"PUT"}get delta(){return this.sm.info.pending}get length(){var s;const t=((s=this.sm.headers)==null?void 0:s.get(Qt.MessageSizeHdr))||"";return t!==""?parseInt(t,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Ax extends TE{constructor(s,i,o){super(s.nc,i,o);j(this,"js");j(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 i=Rr(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,i);const c=this.info;c.config.name=Es.next(),c.ordered_consumer_sequence.delivery_seq=0,c.flow_control.heartbeat_count=0,c.flow_control.fc_count=0,c.flow_control.consumer_restarts++,c.deliver=i,c.config.deliver_subject=i,c.config.deliver_policy=Et.StartSequence,c.config.opt_start_seq=s;const m={};m.stream_name=this.info.stream,m.config=c.config;const y=`${c.api.prefix}.CONSUMER.CREATE.${c.stream}`;this.js._request(y,m,{retries:-1}).then(g=>{const u=g,d=this.sub.info;d.last=u,this.info.config=u.config,this.info.name=u.name}).catch(g=>{const u=new ye(`unable to recreate ordered consumer ${c.stream} at seq ${s}`,ue.RequestError,g);this.sub.callback(u,{})})}_maybeSetupHbMonitoring(){var i,o;const s=((o=(i=this.info)==null?void 0:i.config)==null?void 0:o.idle_heartbeat)||0;s&&this._setupHbMonitoring(sm(s))}_setupHbMonitoring(s,i=0){const o={cancelAfter:0,maxOut:2};i&&(o.cancelAfter=i);const c=this.sub,m=y=>{var d,b,x,v;const g=uE(409,`${zn.IdleHeartbeatMissed}: ${y}`,this.sub.subject);if(!((d=this.info)==null?void 0:d.ordered))this.sub.callback(null,g);else{if(!this.js.nc.protocol.connected)return!1;const w=((x=(b=this.info)==null?void 0:b.ordered_consumer_sequence)==null?void 0:x.stream_seq)||0;return this._resetOrderedConsumer(w+1),(v=this.monitor)==null||v.restart(),!1}return!c.noIterator};this.monitor=new am(s,m,o)}_checkHbOrderConsumer(s){const i=s.headers.get(Qt.ConsumerStalledHdr);i!==""&&this.js.nc.publish(i);const o=parseInt(s.headers.get(Qt.LastConsumerSeqHdr),10),c=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,o!==c.delivery_seq&&this._resetOrderedConsumer(c.stream_seq+1),!1}_checkOrderedConsumer(s){const i=this.info.ordered_consumer_sequence,o=s.info.streamSequence,c=s.info.deliverySequence;return c!=i.delivery_seq+1?(this._resetOrderedConsumer(i.stream_seq+1),!1):(i.delivery_seq=c,i.stream_seq=o,!0)}async destroy(){this.isClosed()||await this.drain();const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.DELETE.${s.stream}.${i}`;await s.api._request(o)}async consumerInfo(){const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.INFO.${s.stream}.${i}`,c=await s.api._request(o);return s.last=c,c}}class $2 extends Ax{constructor(t,s,i){super(t,s,i)}pull(t={batch:1}){const{stream:s,config:i,name:o}=this.sub.info,c=i.durable_name??o,m={};if(m.batch=t.batch||1,m.no_wait=t.no_wait||!1,(t.max_bytes??0)>0){const u=this.js.nc.features.get(Ke.JS_PULL_MAX_BYTES);if(!u.ok)throw new Error(`max_bytes is only supported on servers ${u.min} or better`);m.max_bytes=t.max_bytes}let y=0;t.expires&&t.expires>0&&(y=t.expires,m.expires=mt(y));let g=0;if(t.idle_heartbeat&&t.idle_heartbeat>0&&(g=t.idle_heartbeat,m.idle_heartbeat=mt(g)),g&&y===0)throw new Error("idle_heartbeat requires expires");if(g>y)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),y&&g&&(this.monitor?this.monitor._change(g,y):this._setupHbMonitoring(g,y));const u=this.info.api,d=`${u.prefix}.CONSUMER.MSG.NEXT.${s}.${c}`,b=this.sub.subject;u.nc.publish(d,u.jc.encode(m),{reply:b})}}}function H2(n,t){return n?G2(t):F2(t)}function F2(n){return(t,s)=>t?[t,null]:(t=Ji(s),t?[t,null]:[null,Oo(s,n)])}function G2(n){return(t,s)=>{if(t)return[t,null];const i=Ji(s);return i!==null?[jx(i),null]:[null,Oo(s,n)]}}function jx(n){if(n!==null)switch(n.code){case ue.JetStream404NoMessages:case ue.JetStream408RequestTimeout:return null;case ue.JetStream409:return fE(n)?n:null;default:return n}return null}function V2(n){n&&n.ack()}function Y2(n){const t=n.split(".");if(t.length===9&&t.splice(2,0,"_",""),t.length<11||t[0]!=="$JS"||t[1]!=="ACK")throw new Error("not js message");const s={};return s.domain=t[2]==="_"?"":t[2],s.account_hash=t[3],s.stream=t[4],s.consumer=t[5],s.deliveryCount=parseInt(t[6],10),s.redeliveryCount=s.deliveryCount,s.redelivered=s.deliveryCount>1,s.streamSequence=parseInt(t[7],10),s.deliverySequence=parseInt(t[8],10),s.timestampNanos=parseInt(t[9],10),s.pending=parseInt(t[10],10),s}class K2{constructor(t,s){j(this,"msg");j(this,"di");j(this,"didAck");j(this,"timeout");this.msg=t,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=Y2(this.reply)),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(t){this.didAck||(this.didAck=!this.isWIP(t),this.msg.respond(t))}isWIP(t){return t.length===4&&t[0]===ro[0]&&t[1]===ro[1]&&t[2]===ro[2]&&t[3]===ro[3]}async ackAck(t){var i;t=t||{},t.timeout=t.timeout||this.timeout;const s=pt();if(this.didAck)s.resolve(!1);else if(this.didAck=!0,this.msg.reply){const c=this.msg.publisher,m=!((i=c.options)!=null&&i.noAsyncTraces),y=new yx(c.muxSubscriptions,this.msg.reply,{timeout:t.timeout},m);c.request(y);try{c.publish(this.msg.reply,o1,{reply:`${c.muxSubscriptions.baseInbox}${y.token}`})}catch(g){y.cancel(g)}try{await Promise.race([y.timer,y.deferred]),s.resolve(!0)}catch(g){y.cancel(g),s.reject(g)}}else s.resolve(!1);return s}ack(){this.doAck(o1)}nak(t){let s=k2;t&&(s=bd().encode(`-NAK ${JSON.stringify({delay:mt(t)})}`)),this.doAck(s)}working(){this.doAck(ro)}next(t,s={batch:1}){const i={};i.batch=s.batch||1,i.no_wait=s.no_wait||!1,s.expires&&s.expires>0&&(i.expires=mt(s.expires));const o=Wn().encode(i),c=na.concat(N2,C2,o),m=t?{reply:t}:void 0;this.msg.respond(c,m)}term(t=""){let s=T2;(t==null?void 0:t.length)>0&&(s=bd().encode(`+TERM ${t}`)),this.doAck(s)}json(){return this.msg.json()}string(){return this.msg.string()}}const J2="1.30.3",X2="nats.ws";class Q2{constructor(){j(this,"version");j(this,"lang");j(this,"closeError");j(this,"connected");j(this,"done");j(this,"socket");j(this,"options");j(this,"socketClosed");j(this,"encrypted");j(this,"peeked");j(this,"yields");j(this,"signal");j(this,"closedNotification");this.version=J2,this.lang=X2,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=pt(),this.closedNotification=pt()}async connect(t,s){const i=pt();if(s.tls)return i.reject(new ye("tls",ue.InvalidOption)),i;this.options=s;const o=t.src;if(s.wsFactory){const{socket:c,encrypted:m}=await s.wsFactory(t.src,s);this.socket=c,this.encrypted=m}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=c=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(c.data)),this.peeked){this.signal.resolve();return}const m=na.concat(...this.yields),y=qE(m);if(y!==""){const g=u2.exec(y);if(!g){s.debug&&console.error("!!!",sc(m)),i.reject(new Error("unexpected response from server"));return}try{const u=JSON.parse(g[1]);l2(u,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),i.resolve()}catch(u){i.reject(u);return}}},this.socket.onclose=c=>{if(this.isDiscarded())return;this.socketClosed=!0;let m;this.done||(c.wasClean||(m=new Error(c.reason)),this._closed(m))},this.socket.onerror=c=>{if(this.isDiscarded())return;const m=c,y=new ye(m.message,ue.Unknown,new Error(m.error));i.reject(y)},i}disconnect(){this._closed(void 0,!0)}async _closed(t,s=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=t,!t)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await sa(100);this.done=!0;try{this.socket.close(t?1002:1e3,t?t.message:void 0)}catch{}s&&this.closedNotification.resolve(t)}}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 t=this.yields;this.yields=[];for(let s=0;s<t.length;s++)this.options.debug&&console.info(`> ${sc(t[s])}`),yield t[s];if(this.done)break;this.yields.length===0&&(t.length=0,this.yields=t,this.signal=pt())}}isEncrypted(){return this.connected&&this.encrypted}send(t){if(!this.isDiscarded())try{this.socket.send(t.buffer),this.options.debug&&console.info(`< ${sc(t)}`);return}catch(s){this.options.debug&&console.error(`!!! ${sc(t)}: ${s}`)}}close(t){return this._closed(t,!1)}closed(){return this.closedNotification}isDiscarded(){return this.done?(this.discard(),!0):!1}discard(){var t;this.done=!0;try{(t=this.socket)==null||t.close()}catch{}}}function W2(n,t){/^(.*:\/\/)(.*)/.test(n)||(typeof t=="boolean"?n=`${t===!0?"https":"http"}://${n}`:n=`https://${n}`);let i=new URL(n);const o=i.protocol.toLowerCase();o==="ws:"&&(t=!1),o==="wss:"&&(t=!0),o!=="https:"&&o!=="http"&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2"),i=new URL(`http://${n}`));let c,m;const y=i.hostname,g=i.pathname,u=i.search||"";switch(o){case"http:":case"ws:":case"nats:":m=i.port||"80",c="ws:";break;case"https:":case"wss:":case"tls:":m=i.port||"443",c="wss:";break;default:m=i.port||t===!0?"443":"80",c=t===!0?"wss:":"ws:";break}return`${c}//${y}:${m}${g}${u}`}function Z2(n={}){return CE({defaultPort:443,urlParseFn:W2,factory:()=>new Q2}),um.connect(n)}const eO=null,tO=null,Xt="lt.events";function kx(n,t){const s=n.split("."),i=t.split(".");for(let o=0;o<i.length;o++){const c=i[o];if(c===">")return!0;if(o>=s.length||c!=="*"&&c!==s[o])return!1}return s.length===i.length}const ia=E.createContext({connected:!1,subscribe:()=>()=>{}});function Nx(){const{connected:n}=E.useContext(ia);return{connected:n}}function On(n,t){const{subscribe:s}=E.useContext(ia),i=E.useRef(t);i.current=t,E.useEffect(()=>s(n,c=>i.current(c)),[s,n])}function ti(n,t){const{subscribe:s}=E.useContext(ia),i=E.useRef(t);i.current=t;const o=n.join(","),c=E.useMemo(()=>o.split(",").filter(Boolean),[o]);E.useEffect(()=>{const m=g=>i.current(g),y=c.map(g=>s(g,m));return()=>y.forEach(g=>g())},[s,c])}const nO=E.createContext({connected:!1,subscribe:()=>()=>{}}),rO=bd();function sO({children:n,url:t,token:s}){const i=E.useRef(null),[o,c]=E.useState(!1),m=E.useRef(null),y=E.useRef(new Map),g=E.useRef(new Map),u=E.useCallback((v,w)=>{(async()=>{for await(const S of w)try{if(!kx(S.subject,v))continue;const C=JSON.parse(rO.decode(S.data)),q=y.current.get(v);if(!q)continue;for(const B of q)try{B(C)}catch{}}catch{}})()},[]),d=E.useCallback(v=>{var S;const w=i.current;if(!(!w||(S=w.isClosed)!=null&&S.call(w)||g.current.has(v)))try{const C=w.subscribe(v);g.current.set(v,C),u(v,C)}catch{}},[u]),b=E.useCallback((v,w)=>{const S=y.current;return S.has(v)||S.set(v,new Set),S.get(v).add(w),d(v),()=>{const C=S.get(v);if(C&&(C.delete(w),C.size===0)){S.delete(v);const q=g.current.get(v);if(q){g.current.delete(v);try{q.unsubscribe()}catch{}}}}},[d]),x=E.useCallback(async()=>{try{if(i.current)return;const v=t||eO;if(!v){console.error("[lt-nats] no NATS WebSocket URL configured — set NATS_WS_URL on the server");return}const w=await Z2({servers:v,token:s||tO||void 0,reconnect:!0,maxReconnectAttempts:-1,reconnectTimeWait:2e3});i.current=w,c(!0);for(const S of y.current.keys())d(S);(async()=>{for await(const S of w.status())S.type==="disconnect"?c(!1):S.type==="reconnect"&&c(!0)})()}catch{c(!1),m.current=setTimeout(x,3e3)}},[d]);return E.useEffect(()=>(x(),()=>{m.current&&clearTimeout(m.current);for(const v of g.current.values())try{v.unsubscribe()}catch{}g.current.clear(),i.current&&(i.current.close().catch(()=>{}),i.current=null),c(!1)}),[x]),h.jsx(nO.Provider,{value:{connected:o,subscribe:b},children:h.jsx(ia.Provider,{value:{connected:o,subscribe:b},children:n})})}const lr=Object.create(null);lr.open="0";lr.close="1";lr.ping="2";lr.pong="3";lr.message="4";lr.upgrade="5";lr.noop="6";const su=Object.create(null);Object.keys(lr).forEach(n=>{su[lr[n]]=n});const Md={type:"error",data:"parser error"},Tx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Cx=typeof ArrayBuffer=="function",Mx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,fm=({type:n,data:t},s,i)=>Tx&&t instanceof Blob?s?i(t):c1(t,i):Cx&&(t instanceof ArrayBuffer||Mx(t))?s?i(t):c1(new Blob([t]),i):i(lr[n]+(t||"")),c1=(n,t)=>{const s=new FileReader;return s.onload=function(){const i=s.result.split(",")[1];t("b"+(i||""))},s.readAsDataURL(n)};function u1(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let nd;function iO(n,t){if(Tx&&n.data instanceof Blob)return n.data.arrayBuffer().then(u1).then(t);if(Cx&&(n.data instanceof ArrayBuffer||Mx(n.data)))return t(u1(n.data));fm(n,!1,s=>{nd||(nd=new TextEncoder),t(nd.encode(s))})}const f1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",yo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<f1.length;n++)yo[f1.charCodeAt(n)]=n;const aO=n=>{let t=n.length*.75,s=n.length,i,o=0,c,m,y,g;n[n.length-1]==="="&&(t--,n[n.length-2]==="="&&t--);const u=new ArrayBuffer(t),d=new Uint8Array(u);for(i=0;i<s;i+=4)c=yo[n.charCodeAt(i)],m=yo[n.charCodeAt(i+1)],y=yo[n.charCodeAt(i+2)],g=yo[n.charCodeAt(i+3)],d[o++]=c<<2|m>>4,d[o++]=(m&15)<<4|y>>2,d[o++]=(y&3)<<6|g&63;return u},oO=typeof ArrayBuffer=="function",hm=(n,t)=>{if(typeof n!="string")return{type:"message",data:Rx(n,t)};const s=n.charAt(0);return s==="b"?{type:"message",data:lO(n.substring(1),t)}:su[s]?n.length>1?{type:su[s],data:n.substring(1)}:{type:su[s]}:Md},lO=(n,t)=>{if(oO){const s=aO(n);return Rx(s,t)}else return{base64:!0,data:n}},Rx=(n,t)=>{switch(t){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Dx="",cO=(n,t)=>{const s=n.length,i=new Array(s);let o=0;n.forEach((c,m)=>{fm(c,!1,y=>{i[m]=y,++o===s&&t(i.join(Dx))})})},uO=(n,t)=>{const s=n.split(Dx),i=[];for(let o=0;o<s.length;o++){const c=hm(s[o],t);if(i.push(c),c.type==="error")break}return i};function fO(){return new TransformStream({transform(n,t){iO(n,s=>{const i=s.length;let o;if(i<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,i);else if(i<65536){o=new Uint8Array(3);const c=new DataView(o.buffer);c.setUint8(0,126),c.setUint16(1,i)}else{o=new Uint8Array(9);const c=new DataView(o.buffer);c.setUint8(0,127),c.setBigUint64(1,BigInt(i))}n.data&&typeof n.data!="string"&&(o[0]|=128),t.enqueue(o),t.enqueue(s)})}})}let rd;function lc(n){return n.reduce((t,s)=>t+s.length,0)}function cc(n,t){if(n[0].length===t)return n.shift();const s=new Uint8Array(t);let i=0;for(let o=0;o<t;o++)s[o]=n[0][i++],i===n[0].length&&(n.shift(),i=0);return n.length&&i<n[0].length&&(n[0]=n[0].slice(i)),s}function hO(n,t){rd||(rd=new TextDecoder);const s=[];let i=0,o=-1,c=!1;return new TransformStream({transform(m,y){for(s.push(m);;){if(i===0){if(lc(s)<1)break;const g=cc(s,1);c=(g[0]&128)===128,o=g[0]&127,o<126?i=3:o===126?i=1:i=2}else if(i===1){if(lc(s)<2)break;const g=cc(s,2);o=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),i=3}else if(i===2){if(lc(s)<8)break;const g=cc(s,8),u=new DataView(g.buffer,g.byteOffset,g.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){y.enqueue(Md);break}o=d*Math.pow(2,32)+u.getUint32(4),i=3}else{if(lc(s)<o)break;const g=cc(s,o);y.enqueue(hm(c?g:rd.decode(g),t)),i=0}if(o===0||o>n){y.enqueue(Md);break}}}})}const Lx=4;function Tt(n){if(n)return dO(n)}function dO(n){for(var t in Tt.prototype)n[t]=Tt.prototype[t];return n}Tt.prototype.on=Tt.prototype.addEventListener=function(n,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(t),this};Tt.prototype.once=function(n,t){function s(){this.off(n,s),t.apply(this,arguments)}return s.fn=t,this.on(n,s),this};Tt.prototype.off=Tt.prototype.removeListener=Tt.prototype.removeAllListeners=Tt.prototype.removeEventListener=function(n,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+n];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,o=0;o<s.length;o++)if(i=s[o],i===t||i.fn===t){s.splice(o,1);break}return s.length===0&&delete this._callbacks["$"+n],this};Tt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),s=this._callbacks["$"+n],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(s){s=s.slice(0);for(var i=0,o=s.length;i<o;++i)s[i].apply(this,t)}return this};Tt.prototype.emitReserved=Tt.prototype.emit;Tt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};Tt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const ju=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,s)=>s(t,0),In=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),mO="arraybuffer";function qx(n,...t){return t.reduce((s,i)=>(n.hasOwnProperty(i)&&(s[i]=n[i]),s),{})}const pO=In.setTimeout,yO=In.clearTimeout;function ku(n,t){t.useNativeTimers?(n.setTimeoutFn=pO.bind(In),n.clearTimeoutFn=yO.bind(In)):(n.setTimeoutFn=In.setTimeout.bind(In),n.clearTimeoutFn=In.clearTimeout.bind(In))}const gO=1.33;function bO(n){return typeof n=="string"?xO(n):Math.ceil((n.byteLength||n.size)*gO)}function xO(n){let t=0,s=0;for(let i=0,o=n.length;i<o;i++)t=n.charCodeAt(i),t<128?s+=1:t<2048?s+=2:t<55296||t>=57344?s+=3:(i++,s+=4);return s}function Bx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function vO(n){let t="";for(let s in n)n.hasOwnProperty(s)&&(t.length&&(t+="&"),t+=encodeURIComponent(s)+"="+encodeURIComponent(n[s]));return t}function _O(n){let t={},s=n.split("&");for(let i=0,o=s.length;i<o;i++){let c=s[i].split("=");t[decodeURIComponent(c[0])]=decodeURIComponent(c[1])}return t}class wO extends Error{constructor(t,s,i){super(t),this.description=s,this.context=i,this.type="TransportError"}}class dm extends Tt{constructor(t){super(),this.writable=!1,ku(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,s,i){return super.emitReserved("error",new wO(t,s,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const s=hm(t,this.socket.binaryType);this.onPacket(s)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,s={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(s)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_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(t){const s=vO(t);return s.length?"?"+s:""}}class SO extends dm{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const s=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let i=0;this._polling&&(i++,this.once("pollComplete",function(){--i||s()})),this.writable||(i++,this.once("drain",function(){--i||s()}))}else s()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const s=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};uO(t,this.socket.binaryType).forEach(s),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,cO(t,s=>{this.doWrite(s,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",s=this.query||{};return this.opts.timestampRequests!==!1&&(s[this.opts.timestampParam]=Bx()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(t,s)}}let Px=!1;try{Px=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const EO=Px;function OO(){}class AO extends SO{constructor(t){if(super(t),typeof location<"u"){const s=location.protocol==="https:";let i=location.port;i||(i=s?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||i!==t.port}}doWrite(t,s){const i=this.request({method:"POST",data:t});i.on("success",s),i.on("error",(o,c)=>{this.onError("xhr post error",o,c)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(s,i)=>{this.onError("xhr poll error",s,i)}),this.pollXhr=t}}class or extends Tt{constructor(t,s,i){super(),this.createRequest=t,ku(this,i),this._opts=i,this._method=i.method||"GET",this._uri=s,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var t;const s=qx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(s);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&i.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var o;i.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(i.getResponseHeader("set-cookie"))),i.readyState===4&&(i.status===200||i.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof i.status=="number"?i.status:0)},0))},i.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=or.requestsCount++,or.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=OO,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete or.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}or.requestsCount=0;or.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",h1);else if(typeof addEventListener=="function"){const n="onpagehide"in In?"pagehide":"unload";addEventListener(n,h1,!1)}}function h1(){for(let n in or.requests)or.requests.hasOwnProperty(n)&&or.requests[n].abort()}const jO=(function(){const n=Ux({xdomain:!1});return n&&n.responseType!==null})();class kO extends AO{constructor(t){super(t);const s=t&&t.forceBase64;this.supportsBinary=jO&&!s}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new or(Ux,this.uri(),t)}}function Ux(n){const t=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||EO))return new XMLHttpRequest}catch{}if(!t)try{return new In[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const zx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class NO extends dm{get name(){return"websocket"}doOpen(){const t=this.uri(),s=this.opts.protocols,i=zx?{}:qx(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,s,i)}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=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let s=0;s<t.length;s++){const i=t[s],o=s===t.length-1;fm(i,this.supportsBinary,c=>{try{this.doWrite(i,c)}catch{}o&&ju(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",s=this.query||{};return this.opts.timestampRequests&&(s[this.opts.timestampParam]=Bx()),this.supportsBinary||(s.b64=1),this.createUri(t,s)}}const sd=In.WebSocket||In.MozWebSocket;class TO extends NO{createSocket(t,s,i){return zx?new sd(t,s,i):s?new sd(t,s):new sd(t)}doWrite(t,s){this.ws.send(s)}}class CO extends dm{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const s=hO(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=t.readable.pipeThrough(s).getReader(),o=fO();o.readable.pipeTo(t.writable),this._writer=o.writable.getWriter();const c=()=>{i.read().then(({done:y,value:g})=>{y||(this.onPacket(g),c())}).catch(y=>{})};c();const m={type:"open"};this.query.sid&&(m.data=`{"sid":"${this.query.sid}"}`),this._writer.write(m).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let s=0;s<t.length;s++){const i=t[s],o=s===t.length-1;this._writer.write(i).then(()=>{o&&ju(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const MO={websocket:TO,webtransport:CO,polling:kO},RO=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,DO=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Rd(n){if(n.length>8e3)throw"URI too long";const t=n,s=n.indexOf("["),i=n.indexOf("]");s!=-1&&i!=-1&&(n=n.substring(0,s)+n.substring(s,i).replace(/:/g,";")+n.substring(i,n.length));let o=RO.exec(n||""),c={},m=14;for(;m--;)c[DO[m]]=o[m]||"";return s!=-1&&i!=-1&&(c.source=t,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c.pathNames=LO(c,c.path),c.queryKey=qO(c,c.query),c}function LO(n,t){const s=/\/{2,9}/g,i=t.replace(s,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&i.splice(0,1),t.slice(-1)=="/"&&i.splice(i.length-1,1),i}function qO(n,t){const s={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,o,c){o&&(s[o]=c)}),s}const Dd=typeof addEventListener=="function"&&typeof removeEventListener=="function",iu=[];Dd&&addEventListener("offline",()=>{iu.forEach(n=>n())},!1);class ws extends Tt{constructor(t,s){if(super(),this.binaryType=mO,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(s=t,t=null),t){const i=Rd(t);s.hostname=i.host,s.secure=i.protocol==="https"||i.protocol==="wss",s.port=i.port,i.query&&(s.query=i.query)}else s.host&&(s.hostname=Rd(s.host).host);ku(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(i=>{const o=i.prototype.name;this.transports.push(o),this._transportsByName[o]=i}),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=_O(this.opts.query)),Dd&&(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"})},iu.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const s=Object.assign({},this.opts.query);s.EIO=Lx,s.transport=t,this.id&&(s.sid=this.id);const i=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&ws.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const s=this.createTransport(t);s.open(),this.setTransport(s)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.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",ws.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.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=t.data,this._onError(s);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),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 t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let s=1;for(let i=0;i<this.writeBuffer.length;i++){const o=this.writeBuffer[i].data;if(o&&(s+=bO(o)),i>0&&s>this._maxPayload)return this.writeBuffer.slice(0,i);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ju(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,s,i){return this._sendPacket("message",t,s,i),this}send(t,s,i){return this._sendPacket("message",t,s,i),this}_sendPacket(t,s,i,o){if(typeof s=="function"&&(o=s,s=void 0),typeof i=="function"&&(o=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;const c={type:t,data:s,options:i};this.emitReserved("packetCreate",c),this.writeBuffer.push(c),o&&this.once("flush",o),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),t()},i=()=>{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?i():t()}):this.upgrading?i():t()),this}_onError(t){if(ws.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,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(),Dd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=iu.indexOf(this._offlineEventListener);i!==-1&&iu.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,s),this.writeBuffer=[],this._prevBufferLen=0}}}ws.protocol=Lx;class BO extends ws{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let s=this.createTransport(t),i=!1;ws.priorWebsocketSuccess=!1;const o=()=>{i||(s.send([{type:"ping",data:"probe"}]),s.once("packet",b=>{if(!i)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",s),!s)return;ws.priorWebsocketSuccess=s.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(d(),this.setTransport(s),s.send([{type:"upgrade"}]),this.emitReserved("upgrade",s),s=null,this.upgrading=!1,this.flush())})}else{const x=new Error("probe error");x.transport=s.name,this.emitReserved("upgradeError",x)}}))};function c(){i||(i=!0,d(),s.close(),s=null)}const m=b=>{const x=new Error("probe error: "+b);x.transport=s.name,c(),this.emitReserved("upgradeError",x)};function y(){m("transport closed")}function g(){m("socket closed")}function u(b){s&&b.name!==s.name&&c()}const d=()=>{s.removeListener("open",o),s.removeListener("error",m),s.removeListener("close",y),this.off("close",g),this.off("upgrading",u)};s.once("open",o),s.once("error",m),s.once("close",y),this.once("close",g),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{i||s.open()},200):s.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const s=[];for(let i=0;i<t.length;i++)~this.transports.indexOf(t[i])&&s.push(t[i]);return s}}let PO=class extends BO{constructor(t,s={}){const i=typeof t=="object"?t:s;(!i.transports||i.transports&&typeof i.transports[0]=="string")&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(o=>MO[o]).filter(o=>!!o)),super(t,i)}};function UO(n,t="",s){let i=n;s=s||typeof location<"u"&&location,n==null&&(n=s.protocol+"//"+s.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=s.protocol+n:n=s.host+n),/^(https?|wss?):\/\//.test(n)||(typeof s<"u"?n=s.protocol+"//"+n:n="https://"+n),i=Rd(n)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const c=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+c+":"+i.port+t,i.href=i.protocol+"://"+c+(s&&s.port===i.port?"":":"+i.port),i}const zO=typeof ArrayBuffer=="function",IO=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Ix=Object.prototype.toString,$O=typeof Blob=="function"||typeof Blob<"u"&&Ix.call(Blob)==="[object BlobConstructor]",HO=typeof File=="function"||typeof File<"u"&&Ix.call(File)==="[object FileConstructor]";function mm(n){return zO&&(n instanceof ArrayBuffer||IO(n))||$O&&n instanceof Blob||HO&&n instanceof File}function au(n,t){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let s=0,i=n.length;s<i;s++)if(au(n[s]))return!0;return!1}if(mm(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return au(n.toJSON(),!0);for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&au(n[s]))return!0;return!1}function FO(n){const t=[],s=n.data,i=n;return i.data=Ld(s,t),i.attachments=t.length,{packet:i,buffers:t}}function Ld(n,t){if(!n)return n;if(mm(n)){const s={_placeholder:!0,num:t.length};return t.push(n),s}else if(Array.isArray(n)){const s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]=Ld(n[i],t);return s}else if(typeof n=="object"&&!(n instanceof Date)){const s={};for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=Ld(n[i],t));return s}return n}function GO(n,t){return n.data=qd(n.data,t),delete n.attachments,n}function qd(n,t){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<t.length)return t[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let s=0;s<n.length;s++)n[s]=qd(n[s],t);else if(typeof n=="object")for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]=qd(n[s],t));return n}const VO=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ge;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ge||(Ge={}));class YO{constructor(t){this.replacer=t}encode(t){return(t.type===Ge.EVENT||t.type===Ge.ACK)&&au(t)?this.encodeAsBinary({type:t.type===Ge.EVENT?Ge.BINARY_EVENT:Ge.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let s=""+t.type;return(t.type===Ge.BINARY_EVENT||t.type===Ge.BINARY_ACK)&&(s+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(s+=t.nsp+","),t.id!=null&&(s+=t.id),t.data!=null&&(s+=JSON.stringify(t.data,this.replacer)),s}encodeAsBinary(t){const s=FO(t),i=this.encodeAsString(s.packet),o=s.buffers;return o.unshift(i),o}}class pm extends Tt{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let s;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");s=this.decodeString(t);const i=s.type===Ge.BINARY_EVENT;i||s.type===Ge.BINARY_ACK?(s.type=i?Ge.EVENT:Ge.ACK,this.reconstructor=new KO(s),s.attachments===0&&super.emitReserved("decoded",s)):super.emitReserved("decoded",s)}else if(mm(t)||t.base64)if(this.reconstructor)s=this.reconstructor.takeBinaryData(t),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: "+t)}decodeString(t){let s=0;const i={type:Number(t.charAt(0))};if(Ge[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===Ge.BINARY_EVENT||i.type===Ge.BINARY_ACK){const c=s+1;for(;t.charAt(++s)!=="-"&&s!=t.length;);const m=t.substring(c,s);if(m!=Number(m)||t.charAt(s)!=="-")throw new Error("Illegal attachments");const y=Number(m);if(!JO(y)||y<0)throw new Error("Illegal attachments");if(y>this.opts.maxAttachments)throw new Error("too many attachments");i.attachments=y}if(t.charAt(s+1)==="/"){const c=s+1;for(;++s&&!(t.charAt(s)===","||s===t.length););i.nsp=t.substring(c,s)}else i.nsp="/";const o=t.charAt(s+1);if(o!==""&&Number(o)==o){const c=s+1;for(;++s;){const m=t.charAt(s);if(m==null||Number(m)!=m){--s;break}if(s===t.length)break}i.id=Number(t.substring(c,s+1))}if(t.charAt(++s)){const c=this.tryParse(t.substr(s));if(pm.isPayloadValid(i.type,c))i.data=c;else throw new Error("invalid payload")}return i}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,s){switch(t){case Ge.CONNECT:return d1(s);case Ge.DISCONNECT:return s===void 0;case Ge.CONNECT_ERROR:return typeof s=="string"||d1(s);case Ge.EVENT:case Ge.BINARY_EVENT:return Array.isArray(s)&&(typeof s[0]=="number"||typeof s[0]=="string"&&VO.indexOf(s[0])===-1);case Ge.ACK:case Ge.BINARY_ACK:return Array.isArray(s)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class KO{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const s=GO(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const JO=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function d1(n){return Object.prototype.toString.call(n)==="[object Object]"}const XO=Object.freeze(Object.defineProperty({__proto__:null,Decoder:pm,Encoder:YO,get PacketType(){return Ge}},Symbol.toStringTag,{value:"Module"}));function Xn(n,t,s){return n.on(t,s),function(){n.off(t,s)}}const QO=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class $x extends Tt{constructor(t,s,i){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=t,this.nsp=s,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Xn(t,"open",this.onopen.bind(this)),Xn(t,"packet",this.onpacket.bind(this)),Xn(t,"error",this.onerror.bind(this)),Xn(t,"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(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...s){var i,o,c;if(QO.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(s.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(s),this;const m={type:Ge.EVENT,data:s};if(m.options={},m.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const d=this.ids++,b=s.pop();this._registerAckCallback(d,b),m.id=d}const y=(o=(i=this.io.engine)===null||i===void 0?void 0:i.transport)===null||o===void 0?void 0:o.writable,g=this.connected&&!(!((c=this.io.engine)===null||c===void 0)&&c._hasPingExpired());return this.flags.volatile&&!y||(g?(this.notifyOutgoingListeners(m),this.packet(m)):this.sendBuffer.push(m)),this.flags={},this}_registerAckCallback(t,s){var i;const o=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(o===void 0){this.acks[t]=s;return}const c=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let y=0;y<this.sendBuffer.length;y++)this.sendBuffer[y].id===t&&this.sendBuffer.splice(y,1);s.call(this,new Error("operation has timed out"))},o),m=(...y)=>{this.io.clearTimeoutFn(c),s.apply(this,y)};m.withError=!0,this.acks[t]=m}emitWithAck(t,...s){return new Promise((i,o)=>{const c=(m,y)=>m?o(m):i(y);c.withError=!0,s.push(c),this.emit(t,...s)})}_addToQueue(t){let s;typeof t[t.length-1]=="function"&&(s=t.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((o,...c)=>(this._queue[0],o!==null?i.tryCount>this._opts.retries&&(this._queue.shift(),s&&s(o)):(this._queue.shift(),s&&s(null,...c)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const s=this._queue[0];s.pending&&!t||(s.pending=!0,s.tryCount++,this.flags=s.flags,this.emit.apply(this,s.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:Ge.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,s){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,s),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(i=>String(i.id)===t)){const i=this.acks[t];delete this.acks[t],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Ge.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.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 Ge.EVENT:case Ge.BINARY_EVENT:this.onevent(t);break;case Ge.ACK:case Ge.BINARY_ACK:this.onack(t);break;case Ge.DISCONNECT:this.ondisconnect();break;case Ge.CONNECT_ERROR:this.destroy();const i=new Error(t.data.message);i.data=t.data.data,this.emitReserved("connect_error",i);break}}onevent(t){const s=t.data||[];t.id!=null&&s.push(this.ack(t.id)),this.connected?this.emitEvent(s):this.receiveBuffer.push(Object.freeze(s))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const s=this._anyListeners.slice();for(const i of s)i.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const s=this;let i=!1;return function(...o){i||(i=!0,s.packet({type:Ge.ACK,id:t,data:o}))}}onack(t){const s=this.acks[t.id];typeof s=="function"&&(delete this.acks[t.id],s.withError&&t.data.unshift(null),s.apply(this,t.data))}onconnect(t,s){this.id=t,this.recovered=s&&this._pid===s,this._pid=s,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ge.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const s=this._anyListeners;for(let i=0;i<s.length;i++)if(t===s[i])return s.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const s=this._anyOutgoingListeners;for(let i=0;i<s.length;i++)if(t===s[i])return s.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const s=this._anyOutgoingListeners.slice();for(const i of s)i.apply(this,t.data)}}}function aa(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}aa.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),s=Math.floor(t*this.jitter*n);n=(Math.floor(t*10)&1)==0?n-s:n+s}return Math.min(n,this.max)|0};aa.prototype.reset=function(){this.attempts=0};aa.prototype.setMin=function(n){this.ms=n};aa.prototype.setMax=function(n){this.max=n};aa.prototype.setJitter=function(n){this.jitter=n};class Bd extends Tt{constructor(t,s){var i;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(s=t,t=void 0),s=s||{},s.path=s.path||"/socket.io",this.opts=s,ku(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((i=s.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new aa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(s.timeout==null?2e4:s.timeout),this._readyState="closed",this.uri=t;const o=s.parser||XO;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=s.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var s;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(s=this.backoff)===null||s===void 0||s.setMin(t),this)}randomizationFactor(t){var s;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(s=this.backoff)===null||s===void 0||s.setJitter(t),this)}reconnectionDelayMax(t){var s;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(s=this.backoff)===null||s===void 0||s.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new PO(this.uri,this.opts);const s=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const o=Xn(s,"open",function(){i.onopen(),t&&t()}),c=y=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",y),t?t(y):this.maybeReconnectOnOpen()},m=Xn(s,"error",c);if(this._timeout!==!1){const y=this._timeout,g=this.setTimeoutFn(()=>{o(),c(new Error("timeout")),s.close()},y);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(o),this.subs.push(m),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Xn(t,"ping",this.onping.bind(this)),Xn(t,"data",this.ondata.bind(this)),Xn(t,"error",this.onerror.bind(this)),Xn(t,"close",this.onclose.bind(this)),Xn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(s){this.onclose("parse error",s)}}ondecoded(t){ju(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,s){let i=this.nsps[t];return i?this._autoConnect&&!i.active&&i.connect():(i=new $x(this,t,s),this.nsps[t]=i),i}_destroy(t){const s=Object.keys(this.nsps);for(const i of s)if(this.nsps[i].active)return;this._close()}_packet(t){const s=this.encoder.encode(t);for(let i=0;i<s.length;i++)this.engine.write(s[i],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,s){var i;this.cleanup(),(i=this.engine)===null||i===void 0||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,s),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=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 i=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(o=>{o?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",o)):t.onreconnect()}))},s);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const so={};function ou(n,t){typeof n=="object"&&(t=n,n=void 0),t=t||{};const s=UO(n,t.path||"/socket.io"),i=s.source,o=s.id,c=s.path,m=so[o]&&c in so[o].nsps,y=t.forceNew||t["force new connection"]||t.multiplex===!1||m;let g;return y?g=new Bd(i,t):(so[o]||(so[o]=new Bd(i,t)),g=so[o]),s.query&&!t.query&&(t.query=s.queryKey),g.socket(s.path,t)}Object.assign(ou,{Manager:Bd,Socket:$x,io:ou,connect:ou});const WO=E.createContext({connected:!1,subscribe:()=>()=>{}});function ZO({children:n}){const{isAuthenticated:t}=Pt(),s=E.useRef(null),[i,o]=E.useState(!1),c=E.useRef(new Map),m=E.useCallback((g,u)=>{var b;const d=c.current;return d.has(g)||(d.set(g,new Set),(b=s.current)==null||b.emit("lt.subscribe",g)),d.get(g).add(u),()=>{var v;const x=d.get(g);x&&(x.delete(u),x.size===0&&(d.delete(g),(v=s.current)==null||v.emit("lt.unsubscribe",g)))}},[]),y=E.useCallback((g,u)=>{for(const[d,b]of c.current)if(kx(g,d))for(const x of b)try{x(u)}catch{}},[]);return E.useEffect(()=>{if(!t)return;const g=ou({path:`${Ht}/socket.io`,transports:["polling","websocket"],upgrade:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:2e3,auth:u=>{const d=cx();u(d?{token:d}:{})}});return s.current=g,console.log("[lt-socketio] connecting..."),g.on("connect",()=>{console.log("[lt-socketio] connected, id:",g.id),o(!0);for(const u of c.current.keys())g.emit("lt.subscribe",u)}),g.on("disconnect",u=>{console.log("[lt-socketio] disconnected:",u),o(!1)}),g.on("connect_error",u=>{console.warn("[lt-socketio] connect error:",u.message),o(!1)}),g.onAny((u,d)=>{if(u.startsWith("lt."))try{const b=typeof d=="string"?JSON.parse(d):d;y(u,b)}catch{}}),()=>{g.removeAllListeners(),g.disconnect(),s.current=null,o(!1)}},[y,t]),h.jsx(WO.Provider,{value:{connected:i,subscribe:m},children:h.jsx(ia.Provider,{value:{connected:i,subscribe:m},children:n})})}function eA({children:n}){const{isAuthenticated:t}=Pt(),[s,i]=E.useState(null),[o,c]=E.useState({url:null,token:null});return E.useEffect(()=>{let m=!1;async function y(){var g;try{console.log("[lt-transport] detecting event transport...");const u=await nm(),d=(g=u==null?void 0:u.events)==null?void 0:g.transport;if(console.log("[lt-transport] server reports:",d),!m){if(d==="nats"){let b=u.events.natsWsUrl??null,x=null;const v=cx();if(v)try{const w=await fetch(`${Ht}/api/nats-credentials`,{headers:{Authorization:`Bearer ${v}`}});if(w.ok){const S=await w.json();b=S.natsWsUrl??b,x=S.natsToken??null}}catch{console.warn("[lt-transport] failed to fetch NATS credentials")}c({url:b,token:x})}i(d==="nats"?"nats":"socketio")}}catch(u){console.warn("[lt-transport] settings fetch error, falling back to socketio",u),m||i("socketio")}}return y(),()=>{m=!0}},[t]),s==="nats"?h.jsx(sO,{url:o.url,token:o.token,children:n}):s==="socketio"?h.jsx(ZO,{children:n}):h.jsx(h.Fragment,{children:n})}const ym="lt_view_as",gm="lt_ai_override",Pd="lt_graph_enabled",Ud="lt_infrastructure_enabled",bm="lt_scan_override";function Hx(){try{const n=localStorage.getItem(gm);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function tA(n){try{localStorage.setItem(gm,String(n))}catch{}}function nA(){try{localStorage.removeItem(gm)}catch{}}function xm(){try{const n=localStorage.getItem(ym);if(n==="admin"||n==="engineer"||n==="operator")return n}catch{}return null}function rA(n){try{localStorage.setItem(ym,n)}catch{}window.location.reload()}function zd(){try{localStorage.removeItem(ym)}catch{}window.location.reload()}function Fx(){try{return localStorage.getItem(Pd)==="true"}catch{return!1}}function sA(n){try{n?localStorage.setItem(Pd,"true"):localStorage.removeItem(Pd)}catch{}}function Gx(){try{return localStorage.getItem(Ud)==="true"}catch{return!1}}function iA(n){try{n?localStorage.setItem(Ud,"true"):localStorage.removeItem(Ud)}catch{}}function Vx(){try{const n=localStorage.getItem(bm);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function aA(n){try{localStorage.setItem(bm,String(n))}catch{}}function oA(){try{localStorage.removeItem(bm)}catch{}}function Yx(){const{isSuperAdmin:n,hasRoleType:t,hasRole:s}=Pt(),i=xm(),o=n||s("engineer"),c=t("admin"),m=n||t("admin");return{isBuilder:i?!1:o,isOps:i?i==="admin"||i==="engineer":c,canBulk:i?i==="admin":m,viewAs:i,realIsBuilder:o}}function Kx(){var u;const{isSuperAdmin:n,hasRoleType:t,hasRole:s}=Pt(),{data:i}=Zn(),o=((u=i==null?void 0:i.features)==null?void 0:u.publicPaceBoard)!==!1,c=n?"superadmin":t("admin")?"admin":s("engineer")?"engineer":"operator",m=xm(),y=m==="admin"||m==="engineer"||m==="operator"?m:null,g=y??c;return{tier:g,realTier:c,viewAs:y,canSeePaceBoard:o||g==="superadmin"||g==="admin",canSeeWorkflows:g==="superadmin"||g==="engineer",showTaskQueueCards:g==="operator"&&!o}}function Jx(n){return(n??"").replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"none"}function qr(n={}){const t=n.role?Jx(n.role):"*",s=n.id??"*",i=n.verb??">";return`${Xt}.system.escalation.${t}.${s}.${i}`}function Id(n){return n.verbs.map(t=>qr({role:n.role,verb:t}))}function vm(n){const{user:t,isSuperAdmin:s,hasRoleType:i}=Pt(),o=s||i("admin"),c=((t==null?void 0:t.roles)??[]).map(y=>y.role).sort().join(","),m=(n??[]).join(",");return E.useMemo(()=>{const y=m?m.split(","):null;return o||!c?y?Id({verbs:y}):[qr({})]:c.split(",").flatMap(g=>y?Id({role:g,verbs:y}):[qr({role:g})])},[o,c,m])}const $d="/escalations/detail/";function lA(n){return n.startsWith($d)&&n.slice($d.length).split("/")[0]||void 0}function cA(){const{user:n}=Pt(),t=ra(),s=an(),i=E.useRef(s.pathname);i.current=s.pathname;const o=E.useRef(n==null?void 0:n.userId);o.current=n==null?void 0:n.userId;const c=E.useCallback(m=>{var b,x,v;if((m==null?void 0:m.assignedAtCreation)!==!0)return;const y=(m==null?void 0:m.escalationId)??((b=m==null?void 0:m.data)==null?void 0:b.id),g=(x=m==null?void 0:m.data)==null?void 0:x.assigned_to,u=(v=m==null?void 0:m.data)==null?void 0:v.parent_id;if(!y||g!==o.current||!u||u!==lA(i.current))return;const d=`${$d}${y}`;i.current!==d&&t(d)},[t]);ti(vm(["claimed"]),c)}function uA(n){const t=n??[];return t.length>0&&t.every(s=>s.type==="member"&&s.write_scope==="none")}const _m={staleTime:5*6e4,refetchOnWindowFocus:!1};function R3(n={},t={}){const s=new URLSearchParams;return n.role&&s.set("role",n.role),n.roleType&&s.set("roleType",n.roleType),n.status&&s.set("status",n.status),n.search&&s.set("search",n.search),n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),$e({queryKey:["users",n],queryFn:()=>fe(`/users?${s}`),enabled:t.enabled??!0,..._m})}const m1=200;async function fA(n){const t=[];for(let s=0;s<n.length;s+=m1){const i=await fe("/users/names",{method:"POST",body:JSON.stringify({ids:n.slice(s,s+m1)})});t.push(...i.users??[])}return t}let Hd=[],Fd=new Map,Gd=!1;function hA(){const n=Hd,t=Fd;Hd=[],Fd=new Map,Gd=!1,fA(n).then(s=>{const i=new Map(s.map(o=>[o.id,o]));for(const[o,c]of t)c.resolve(i.get(o)??null)}).catch(s=>{for(const i of t.values())i.reject(s)})}function dA(n){return new Promise((t,s)=>{Hd.push(n),Fd.set(n,{resolve:t,reject:s}),Gd||(Gd=!0,setTimeout(hA,0))})}function D3(n){return $e({queryKey:["user-name",n],queryFn:()=>dA(n),enabled:!!n,..._m})}function mA(n){return $e({queryKey:["users",n,"roles"],queryFn:async()=>(await fe(`/users/${n}/roles`)).roles??[],enabled:!!n,..._m})}function L3(){const n=He();return Ve({mutationFn:t=>fe("/users",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function q3(){const n=He();return Ve({mutationFn:({id:t,...s})=>fe(`/users/${t}`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function B3(){const n=He();return Ve({mutationFn:({id:t,ops:s})=>fe(`/users/${t}/properties`,{method:"PATCH",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function P3(){return $e({queryKey:["users","system-property-keys"],queryFn:()=>fe("/users/system-property-keys")})}function U3(){const n=He();return Ve({mutationFn:t=>fe(`/users/${t}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function z3(){const n=He();return Ve({mutationFn:({userId:t,role:s,type:i,read_scope:o,write_scope:c})=>fe(`/users/${t}/roles`,{method:"POST",body:JSON.stringify({role:s,type:i,read_scope:o,write_scope:c})}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function I3(){const n=He();return Ve({mutationFn:({userId:t,role:s})=>fe(`/users/${t}/roles/${encodeURIComponent(s)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}const $3={MAX_PORTALS:12,MAX_ROWS:4,MAX_COLS:6,MAX_COUNTS:8};function pA(){return $e({queryKey:["roles"],queryFn:()=>fe("/roles")})}function Nu(n){return $e({queryKey:["roles","details"],queryFn:()=>fe("/roles/details"),enabled:(n==null?void 0:n.enabled)??!0})}function H3(n,t,s=!0){return $e({queryKey:["roles",n,"schema",t??"latest"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/schema${t!=null?`?version=${t}`:""}`),enabled:s&&!!n})}function F3(n){return $e({queryKey:["roles",n,"schema-versions"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/schema/versions`),enabled:!!n})}function G3(n,t,s=!0){return $e({queryKey:["roles",n,"list-schema",t??"latest"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/list-schema${t!=null?`?version=${t}`:""}`),enabled:s&&!!n})}function V3(n){return $e({queryKey:["roles",n,"list-schema-versions"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/list-schema/versions`),enabled:!!n})}function Y3(){const n=He();return Ve({mutationFn:t=>fe("/roles",{method:"POST",body:JSON.stringify({role:t})}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function K3(){const n=He();return Ve({mutationFn:({role:t,...s})=>fe(`/roles/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(s)}),onMutate:async({role:t,...s})=>{await n.cancelQueries({queryKey:["roles","details"]});const i=n.getQueryData(["roles","details"]);return i&&n.setQueryData(["roles","details"],{roles:i.roles.map(o=>o.role===t?{...o,...s}:o)}),{previous:i}},onError:(t,s,i)=>{i!=null&&i.previous&&n.setQueryData(["roles","details"],i.previous)},onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function J3(){const n=He();return Ve({mutationFn:t=>fe(`/roles/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}const Xx="lt:station:kiosk-role:";function Vd(n){return`${Xx}${n}`}const Yd=new Set;function yA(){for(const n of Yd)n()}function gA(n){try{return localStorage.getItem(Vd(n))}catch{return null}}function bA(n,t){try{t===null?localStorage.removeItem(Vd(n)):localStorage.setItem(Vd(n),t)}catch{}yA()}function xA(n){Yd.add(n);const t=s=>{(s.key===null||s.key.startsWith(Xx))&&n()};try{window.addEventListener("storage",t)}catch{}return()=>{Yd.delete(n);try{window.removeEventListener("storage",t)}catch{}}}function vA(n){return E.useSyncExternalStore(xA,()=>n?gA(n):null)}const gu="/portal";function _A(n){return n===gu||n.startsWith(`${gu}/`)}function wm(n,t){const s=`${gu}/${encodeURIComponent(n)}`;return t?`${s}/${encodeURIComponent(t)}`:s}function Wi(n){return Array.isArray(n==null?void 0:n.portals)?n.portals:[]}function wA(n){return Wi(n).length>0}function X3(n,t){const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"portal",i=new Set(t);if(!i.has(s))return s;let o=2;for(;i.has(`${s}-${o}`);)o+=1;return`${s}-${o}`}function Qx(n,t){return t.length>0?wm(n,t[0].key):`/escalations/available?role=${encodeURIComponent(n)}&status=available`}function Sm(){const{user:n}=Pt(),t=(n==null?void 0:n.userId)??null,{data:s}=mA(t),{data:i}=Nu(),o=vA(t),c=E.useCallback(m=>{t&&bA(t,m)},[t]);return E.useMemo(()=>{const m={kiosk:!1,role:null,homePath:null,targets:[],selectable:!1,selectRole:c},y=s??[];if(y.length===0||y.some(v=>v.type!=="member"))return m;const g=v=>{var w;return(w=i==null?void 0:i.roles)==null?void 0:w.find(S=>S.role===v)},u=v=>{var w,S;return((S=(w=g(v))==null?void 0:w.properties)==null?void 0:S.kiosk)===!0},d=y.map(v=>v.role).filter(u),b=v=>({kiosk:!0,role:v,homePath:Qx(v,Wi(g(v))),targets:d,selectable:d.length>=2,selectRole:c});if(y.length===1)return d.length===1?b(d[0]):m;if(!uA(y)||d.length===0)return m;const x=o&&d.includes(o)?o:d.length===1?d[0]:null;return x?b(x):{...m,targets:d,selectable:!0}},[s,i,o,c])}const SA=["/escalations",gu,"/scan","/login"];function EA(n){return SA.some(t=>n===t||n.startsWith(`${t}/`)||n.startsWith(`${t}?`))}const Em=E.createContext(null),id="lt_sidebar_collapsed",Wx="(max-width: 1023px)";function OA(){try{return window.matchMedia(Wx).matches}catch{return!1}}function AA({children:n}){const[t,s]=E.useState(()=>{if(OA())return!0;try{return localStorage.getItem(id)==="true"}catch{return!1}});E.useEffect(()=>{let o;try{o=window.matchMedia(Wx)}catch{return}const c=m=>{if(m.matches)s(!0);else try{s(localStorage.getItem(id)==="true")}catch{s(!1)}};return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[]);const i=E.useCallback(()=>{s(o=>{const c=!o;try{localStorage.setItem(id,String(c))}catch{}return c})},[]);return h.jsx(Em.Provider,{value:{collapsed:t,toggle:i},children:n})}function jA({children:n}){return h.jsx(Em.Provider,{value:{collapsed:!1,toggle:()=>{}},children:n})}function Om(){const n=E.useContext(Em);if(!n)throw new Error("useSidebar must be used within SidebarProvider");return n}const p1=380,Am=E.createContext(null);function kA({children:n}){const[t,s]=E.useState({node:null,width:p1,open:!1,ownerKey:null}),i=an(),o=E.useRef(i.pathname),c=E.useCallback((y,g)=>{s({node:y,width:(g==null?void 0:g.width)??p1,open:!0,ownerKey:(g==null?void 0:g.key)??null})},[]),m=E.useCallback(y=>{s(g=>typeof y=="string"&&g.ownerKey!==y?g:{...g,open:!1})},[]);return E.useEffect(()=>{i.pathname!==o.current&&(o.current=i.pathname,s(y=>y.open||y.node?{...y,node:null,open:!1,ownerKey:null}:y))},[i.pathname]),h.jsx(Am.Provider,{value:{...t,setPanel:c,closePanel:m},children:n})}function jm(){const n=E.useContext(Am);if(!n)throw new Error("useShellPanel must be used within ShellPanelProvider");return n}function Q3(){return E.useContext(Am)}function NA({open:n,width:t=380,children:s,className:i=""}){const[o,c]=E.useState(n);return E.useEffect(()=>{n&&c(!0)},[n]),h.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${i}`,style:{width:n?t:0,maxWidth:"50%"},onTransitionEnd:m=>{!n&&m.propertyName==="width"&&c(!1)},children:h.jsx("div",{style:{width:t},className:"h-full",children:o?s:null})})}function W3({label:n,children:t}){return h.jsxs("div",{children:[h.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:n}),h.jsx("dd",{className:"text-xs text-text-primary mt-0.5",children:t})]})}function Z3({views:n,activeId:t,onViewChange:s,onClose:i,headerActions:o,stickyClassName:c,labelInline:m}){const y=n.find(g=>g.id===t)??n[0];return y?h.jsx("div",{className:"h-full bg-surface-hover",children:h.jsxs("div",{className:`flex flex-col ${c??"sticky top-0 z-10 max-h-[calc(100vh-3.5rem)]"}`,children:[h.jsxs("div",{className:`flex items-center justify-between pl-4 pr-3 shrink-0 ${m?"pt-10 pb-2":"pt-3"}`,children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1 shrink-0",role:"radiogroup","aria-label":"Panel view",children:n.map(g=>{const u=g.icon,d=g.id===y.id;return h.jsx("button",{role:"radio","aria-checked":d,onClick:()=>s(g.id),title:g.label,className:`p-1.5 rounded-md transition-colors ${d?"bg-accent/10 text-accent":"text-accent/60 hover:text-accent hover:bg-surface-hover"}`,children:h.jsx(u,{className:"w-3.5 h-3.5"})},g.id)})}),m&&h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-secondary truncate",children:y.label})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o,i&&h.jsx("button",{onClick:i,title:"Close panel",className:"p-1 rounded text-accent/60 hover:text-accent hover:bg-surface-hover transition-colors",children:h.jsx(Wt,{className:"w-3.5 h-3.5"})})]})]}),!m&&h.jsx("p",{className:"px-5 pt-2 pb-1 text-2xs font-semibold uppercase tracking-widest text-text-secondary shrink-0",children:y.label}),h.jsx("div",{className:`flex-1 overflow-y-auto px-5 ${m?"pt-4 pb-8":"pb-5 pt-1"}`,children:y.content})]})}):null}function Zx(n,t){var s,i,o,c,m;t.facets&&Object.keys(t.facets).length&&n.set("facets",JSON.stringify(t.facets)),(s=t.block)!=null&&s.length&&n.set("block",JSON.stringify(t.block)),(i=t.range)!=null&&i.length&&n.set("range",JSON.stringify(t.range)),(o=t.exists)!=null&&o.length&&n.set("exists",JSON.stringify(t.exists)),(c=t.roles)!=null&&c.length&&n.set("roles",JSON.stringify(t.roles)),(m=t.orderBy)!=null&&m.length&&n.set("orderBy",JSON.stringify(t.orderBy)),t.available!==void 0&&n.set("available",String(t.available)),t.jeopardy===!0&&n.set("jeopardy","1"),t.include&&n.set("include",t.include)}function e5(n,t,s){const i=n??"24h",o=t&&Object.keys(t).length?JSON.stringify(t):null;return $e({queryKey:["stationMetrics",i,o],queryFn:()=>fe(`/escalations/station-metrics?period=${i}${o?`&facets=${encodeURIComponent(o)}`:""}`),staleTime:5e3,enabled:(s==null?void 0:s.enabled)??!0})}function t5(n){const t=n?`?period=${n}`:"";return $e({queryKey:["escalationStats",n],queryFn:()=>fe(`/escalations/stats${t}`)})}function n5(){return $e({queryKey:["escalationTypes"],queryFn:()=>fe("/escalations/types")})}function r5(n=!0){return $e({queryKey:["escalationFacetKeys"],queryFn:()=>fe("/escalations/facet-keys"),enabled:n,staleTime:6e4})}function TA(n){return $e({queryKey:["escalationFacetValues",n],queryFn:()=>fe(`/escalations/facet-values?key=${encodeURIComponent(n)}`),enabled:!!n,staleTime:6e4})}function ev(n){const{enabled:t=!0,staleTime:s,...i}=n,o=new URLSearchParams;return i.status&&o.set("status",i.status),i.role&&o.set("role",i.role),i.type&&o.set("type",i.type),i.subtype&&o.set("subtype",i.subtype),i.assigned_to&&o.set("assigned_to",i.assigned_to),i.parent_id&&o.set("parent_id",i.parent_id),i.claimed&&o.set("claimed","true"),i.priority&&o.set("priority",String(i.priority)),i.limit&&o.set("limit",String(i.limit)),i.offset!==void 0&&o.set("offset",String(i.offset)),i.sort_by&&o.set("sort_by",i.sort_by),i.order&&o.set("order",i.order),i.search&&o.set("search",i.search),Zx(o,i),$e({queryKey:["escalations",i],queryFn:()=>fe(`/escalations?${o}`),enabled:t,...s!==void 0?{staleTime:s}:{}})}function tv(n){const{enabled:t=!0,staleTime:s,...i}=n,o=new URLSearchParams;return i.role&&o.set("role",i.role),i.type&&o.set("type",i.type),i.subtype&&o.set("subtype",i.subtype),i.priority&&o.set("priority",String(i.priority)),i.limit&&o.set("limit",String(i.limit)),i.offset!==void 0&&o.set("offset",String(i.offset)),i.sort_by&&o.set("sort_by",i.sort_by),i.order&&o.set("order",i.order),i.search&&o.set("search",i.search),Zx(o,i),$e({queryKey:["escalations","available",i],queryFn:()=>fe(`/escalations/available?${o}`),enabled:t,...s!==void 0?{staleTime:s}:{}})}function s5(n){return $e({queryKey:["escalations","by-workflow",n],queryFn:()=>fe(`/escalations/by-workflow/${n}`),enabled:!!n})}function i5(n){return $e({queryKey:["escalations",n],queryFn:()=>fe(`/escalations/${n}`),enabled:!!n})}function a5(n,t){return $e({queryKey:["escalations",n,"lookups"],queryFn:()=>fe(`/escalations/${n}/lookups`),enabled:!!n&&t,staleTime:1/0})}function o5(){const n=He();return Ve({mutationFn:({id:t,durationMinutes:s})=>fe(`/escalations/${t}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function l5(){const n=He();return Ve({mutationFn:t=>fe(`/escalations/${t}/release`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function c5(){const n=He();return Ve({mutationFn:({id:t,resolverPayload:s})=>fe(`/escalations/${t}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]}),n.resetQueries({queryKey:["tasks"]}),n.resetQueries({queryKey:["jobs"]})}})}function u5(){const n=He();return Ve({mutationFn:({id:t,itemKey:s,payload:i})=>fe(`/escalations/${t}/accumulate`,{method:"POST",body:JSON.stringify({itemKey:s,...i?{payload:i}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function f5(){const n=He();return Ve({mutationFn:({id:t,itemKey:s})=>fe(`/escalations/${t}/remove-item`,{method:"POST",body:JSON.stringify({itemKey:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function h5(){const n=He();return Ve({mutationFn:({id:t,targetRole:s})=>fe(`/escalations/${t}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function d5(){const n=He();return Ve({mutationFn:({ids:t,priority:s})=>fe("/escalations/priority",{method:"PATCH",body:JSON.stringify({ids:t,priority:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function m5(){const n=He();return Ve({mutationFn:({ids:t,durationMinutes:s})=>fe("/escalations/bulk-claim",{method:"POST",body:JSON.stringify({ids:t,durationMinutes:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function p5(){const n=He();return Ve({mutationFn:({ids:t,targetUserId:s,durationMinutes:i,reassign:o})=>fe("/escalations/bulk-assign",{method:"POST",body:JSON.stringify({ids:t,targetUserId:s,durationMinutes:i,...o?{reassign:!0}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function y5(){const n=He();return Ve({mutationFn:({ids:t})=>fe("/escalations/bulk-unassign",{method:"POST",body:JSON.stringify({ids:t})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function g5(){const n=He();return Ve({mutationFn:({ids:t,hint:s})=>fe("/escalations/bulk-triage",{method:"POST",body:JSON.stringify({ids:t,...s?{hint:s}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function b5(){const n=He();return Ve({mutationFn:t=>fe(`/escalations/${t}/cancel`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function x5(){const n=He();return Ve({mutationFn:({ids:t})=>fe("/escalations/bulk-cancel",{method:"POST",body:JSON.stringify({ids:t})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function km(n){const t=[],s=n.type.split(".");switch(s[0]==="system"?s[1]:s[0]){case"task":t.push(["tasks"]),t.push(["jobs"]),t.push(["processes"]),n.workflowId&&(t.push(["workflowExecution",n.workflowId]),t.push(["workflowState",n.workflowId]),t.push(["mcpQueryExecution",n.workflowId])),n.originId&&t.push(["processes",n.originId]);break;case"escalation":t.push(["escalations"]),t.push(["escalationStats"]),t.push(["stationMetrics"]),n.workflowId&&t.push(["workflowExecution",n.workflowId]);break;case"workflow":t.push(["jobs"]),t.push(["tasks"]),t.push(["processes"]),n.workflowId&&(t.push(["workflowExecution",n.workflowId]),t.push(["workflowState",n.workflowId]),t.push(["mcpQueryExecution",n.workflowId]),t.push(["mcpQueryResult",n.workflowId]),t.push(["builderResult",n.workflowId]));break;case"activity":n.workflowId&&t.push(["mcpRunExecution",n.workflowId]),t.push(["mcpRuns"]);break;case"milestone":n.workflowId&&(t.push(["workflowExecution",n.workflowId]),t.push(["mcpQueryExecution",n.workflowId])),t.push(["tasks"]);break;case"knowledge":t.push(["knowledge"]);break;case"file":t.push(["files"]);break;case"agent":t.push(["agents"]);break;default:t.push(["jobs"]),t.push(["tasks"]);break}return t}const CA={DETAIL:{coalesceMs:300,minIntervalMs:2e3},LIST:{coalesceMs:500,minIntervalMs:3e3},SUMMARY:{coalesceMs:1e3,minIntervalMs:1e4}},v5=300,y1={DETAIL:0,LIST:1,SUMMARY:2};function MA(n){const t=new Map,s={},i={};let o=!1;const c=()=>typeof document<"u"&&document.visibilityState==="hidden";function m(d){delete s[d],i[d]=Date.now();const b=[];for(const[v,w]of t)w===d&&b.push(v);for(const v of b)t.delete(v);if(b.length===0)return;const x=c();x&&(o=!0);for(const v of b)n.invalidateQueries({queryKey:JSON.parse(v),...x?{refetchType:"none"}:{}})}function y(d){if(s[d])return;const{coalesceMs:b,minIntervalMs:x}=CA[d],v=i[d],w=v===void 0?0:v+x-Date.now(),S=Math.max(b,w);s[d]=setTimeout(()=>m(d),S)}function g(d,b){for(const x of b){const v=JSON.stringify(x),w=t.get(v);(w===void 0||y1[d]<y1[w])&&t.set(v,d)}y(d)}const u=()=>{typeof document>"u"||document.visibilityState==="visible"&&o&&(o=!1,n.refetchQueries({type:"active",stale:!0}))};return typeof document<"u"&&document.addEventListener("visibilitychange",u),{request:g,dispose(){for(const d of Object.keys(s)){const b=s[d];b&&clearTimeout(b),delete s[d]}t.clear(),typeof document<"u"&&document.removeEventListener("visibilitychange",u)}}}const g1=new WeakMap;function RA(n){let t=g1.get(n);return t||(t=MA(n),g1.set(n,t)),t}function on(n){const t=He();return E.useCallback(s=>{RA(t).request(n,s)},[t,n])}function Nm(n){return n?[`${Xt}.system.workflow.>`,`${Xt}.system.activity.>`,`${Xt}.system.milestone.>`,`${Xt}.system.task.>`,`${Xt}.system.escalation.>`]:[]}function _5(){const n=on("LIST");On(`${Xt}.system.task.>`,()=>{n([["jobs"]])}),On(`${Xt}.system.workflow.>`,()=>{n([["jobs"]])})}function w5(n){const t=on("DETAIL");ti(Nm(n),s=>{var y;if(!n||!(s.workflowId===n||((y=s.workflowId)==null?void 0:y.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=km(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),t(m)})}function S5(n){const t=on("DETAIL");ti(Nm(n),s=>{var y;if(!n||!(s.workflowId===n||((y=s.workflowId)==null?void 0:y.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=km(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),t(m)})}function E5(n){const t=on("DETAIL");ti(Nm(n),s=>{var c;if(!n||!(s.workflowId===n||((c=s.workflowId)==null?void 0:c.includes(n))))return;const o=km(s);o.push(["workflowSets"]),o.push(["yamlWorkflows"]),t(o)})}function O5(n){const t=on("DETAIL"),s=E.useCallback(i=>{n&&(i.originId!==n&&i.workflowId!==n||t([["processes",n]]))},[n,t]);On(`${Xt}.system.task.>`,s),On(`${Xt}.system.workflow.>`,s),On(`${Xt}.system.escalation.>`,s)}function A5(){const n=on("SUMMARY");On(qr({}),()=>{n([["escalationStats"]])})}function j5(){const n=on("SUMMARY");On(qr({}),()=>{n([["stationMetrics"]])})}function k5(){const n=on("SUMMARY");On(qr({}),()=>{n([["escAggregate"],["escTimeline"]])})}function N5(n){const t=on("LIST"),s=(n==null?void 0:n.role)??null,i=((n==null?void 0:n.verbs)??[]).join(","),o=E.useMemo(()=>{const c=i?i.split(","):null;return c?Id({role:s,verbs:c}):[qr({role:s})]},[s,i]);ti(o,()=>{t([["escalations"]])})}function T5(n){const t=on("DETAIL");On(qr(n?{id:n}:{id:"__none__"}),s=>{!n||s.escalationId!==n||t([["escalations",n]])})}function C5(){const n=on("LIST");On(`${Xt}.system.agent.>`,()=>{n([["agents"]])})}function M5(){const n=on("LIST");On(`${Xt}.system.task.>`,()=>{n([["processes"]])}),On(`${Xt}.system.workflow.>`,()=>{n([["processes"]])})}function DA(){const{user:n}=Pt(),t=n==null?void 0:n.userId,s=on("SUMMARY");ti(vm(),()=>{s([["escalations"]])});const{data:i}=tv({limit:1}),{data:o}=ev({assigned_to:t,status:"pending",limit:1});return{available:(i==null?void 0:i.total)??0,mine:(o==null?void 0:o.total)??0}}function Tm({size:n="sm",hideLabel:t=!1,className:s="",appName:i="LongTail",variant:o="full"}){const c=n==="lg";if(o==="comet")return h.jsx("div",{className:`relative overflow-visible ${s}`,style:{width:"2.5rem",height:"2.5rem",flexShrink:0},children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark absolute pointer-events-none select-none",style:{"--logo-url":`url(${Ht}/logo512.png)`,width:"82px",height:"82px",top:"-12px",left:"-80px",transform:"rotate(232deg)",zIndex:-1,opacity:.55}})});if(o==="mark")return h.jsx("div",{className:`flex items-center ${s}`,children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark shrink-0 w-7 h-7",style:{"--logo-url":`url(${Ht}/logo512.png)`}})});const m=c?"w-[16rem] h-[16rem] -rotate-[120deg] opacity-55 -ml-10":"w-[12.5rem] h-[12.5rem] -rotate-[120deg] opacity-55 -ml-8",y=c?"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 h.jsxs("div",{className:`flex items-center ${s}`,style:{height:"50px"},children:[h.jsx("span",{role:"img","aria-label":i,className:`logo-mark shrink-0 z-0 ${m}`,style:{"--logo-url":`url(${Ht}/logo512.png)`}}),h.jsx("span",{className:`z-[1] transition-opacity duration-300 ${y} ${t?"opacity-0":""}`,children:i})]})}const LA="system.surfaces.dashboard",qA=`${Xt}.${LA}`;function nv(n=!0){return $e({queryKey:["announcements"],queryFn:()=>fe("/announcements"),enabled:n,staleTime:3e4})}function BA(){const n=He();return Ve({mutationFn:t=>fe("/announcements",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}function PA(){const n=He();return Ve({mutationFn:t=>fe(`/announcements/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}const rv=6048e5,UA=864e5,b1=6e4,x1=525600,v1=43200,_1=1440,w1=Symbol.for("constructDateFrom");function Br(n,t){return typeof n=="function"?n(t):n&&typeof n=="object"&&w1 in n?n[w1](t):n instanceof Date?new n.constructor(t):new Date(t)}function jn(n,t){return Br(t||n,n)}let zA={};function Mo(){return zA}function Ao(n,t){var y,g,u,d;const s=Mo(),i=(t==null?void 0:t.weekStartsOn)??((g=(y=t==null?void 0:t.locale)==null?void 0:y.options)==null?void 0:g.weekStartsOn)??s.weekStartsOn??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=jn(n,t==null?void 0:t.in),c=o.getDay(),m=(c<i?7:0)+c-i;return o.setDate(o.getDate()-m),o.setHours(0,0,0,0),o}function bu(n,t){return Ao(n,{...t,weekStartsOn:1})}function sv(n,t){const s=jn(n,t==null?void 0:t.in),i=s.getFullYear(),o=Br(s,0);o.setFullYear(i+1,0,4),o.setHours(0,0,0,0);const c=bu(o),m=Br(s,0);m.setFullYear(i,0,4),m.setHours(0,0,0,0);const y=bu(m);return s.getTime()>=c.getTime()?i+1:s.getTime()>=y.getTime()?i:i-1}function xu(n){const t=jn(n),s=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return s.setUTCFullYear(t.getFullYear()),+n-+s}function iv(n,...t){const s=Br.bind(null,n||t.find(i=>typeof i=="object"));return t.map(s)}function S1(n,t){const s=jn(n,t==null?void 0:t.in);return s.setHours(0,0,0,0),s}function IA(n,t,s){const[i,o]=iv(s==null?void 0:s.in,n,t),c=S1(i),m=S1(o),y=+c-xu(c),g=+m-xu(m);return Math.round((y-g)/UA)}function $A(n,t){const s=sv(n,t),i=Br(n,0);return i.setFullYear(s,0,4),i.setHours(0,0,0,0),bu(i)}function HA(n,t){const s=+jn(n)-+jn(t);return s<0?-1:s>0?1:s}function FA(n){return Br(n,Date.now())}function GA(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function VA(n){return!(!GA(n)&&typeof n!="number"||isNaN(+jn(n)))}function YA(n){return t=>{const i=(n?Math[n]:Math.trunc)(t);return i===0?0:i}}function KA(n,t){const s=jn(n,t==null?void 0:t.in);return s.setFullYear(s.getFullYear(),0,1),s.setHours(0,0,0,0),s}const JA={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"}},XA=(n,t,s)=>{let i;const o=JA[n];return typeof o=="string"?i=o:t===1?i=o.one:i=o.other.replace("{{count}}",t.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+i:i+" ago":i};function ad(n){return(t={})=>{const s=t.width?String(t.width):n.defaultWidth;return n.formats[s]||n.formats[n.defaultWidth]}}const QA={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},WA={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},ZA={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ej={date:ad({formats:QA,defaultWidth:"full"}),time:ad({formats:WA,defaultWidth:"full"}),dateTime:ad({formats:ZA,defaultWidth:"full"})},tj={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},nj=(n,t,s,i)=>tj[n];function io(n){return(t,s)=>{const i=s!=null&&s.context?String(s.context):"standalone";let o;if(i==="formatting"&&n.formattingValues){const m=n.defaultFormattingWidth||n.defaultWidth,y=s!=null&&s.width?String(s.width):m;o=n.formattingValues[y]||n.formattingValues[m]}else{const m=n.defaultWidth,y=s!=null&&s.width?String(s.width):n.defaultWidth;o=n.values[y]||n.values[m]}const c=n.argumentCallback?n.argumentCallback(t):t;return o[c]}}const rj={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},sj={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ij={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"]},aj={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"]},oj={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"}},lj={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"}},cj=(n,t)=>{const s=Number(n),i=s%100;if(i>20||i<10)switch(i%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},uj={ordinalNumber:cj,era:io({values:rj,defaultWidth:"wide"}),quarter:io({values:sj,defaultWidth:"wide",argumentCallback:n=>n-1}),month:io({values:ij,defaultWidth:"wide"}),day:io({values:aj,defaultWidth:"wide"}),dayPeriod:io({values:oj,defaultWidth:"wide",formattingValues:lj,defaultFormattingWidth:"wide"})};function ao(n){return(t,s={})=>{const i=s.width,o=i&&n.matchPatterns[i]||n.matchPatterns[n.defaultMatchWidth],c=t.match(o);if(!c)return null;const m=c[0],y=i&&n.parsePatterns[i]||n.parsePatterns[n.defaultParseWidth],g=Array.isArray(y)?hj(y,b=>b.test(m)):fj(y,b=>b.test(m));let u;u=n.valueCallback?n.valueCallback(g):g,u=s.valueCallback?s.valueCallback(u):u;const d=t.slice(m.length);return{value:u,rest:d}}}function fj(n,t){for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&t(n[s]))return s}function hj(n,t){for(let s=0;s<n.length;s++)if(t(n[s]))return s}function dj(n){return(t,s={})=>{const i=t.match(n.matchPattern);if(!i)return null;const o=i[0],c=t.match(n.parsePattern);if(!c)return null;let m=n.valueCallback?n.valueCallback(c[0]):c[0];m=s.valueCallback?s.valueCallback(m):m;const y=t.slice(o.length);return{value:m,rest:y}}}const mj=/^(\d+)(th|st|nd|rd)?/i,pj=/\d+/i,yj={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},gj={any:[/^b/i,/^(a|c)/i]},bj={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},xj={any:[/1/i,/2/i,/3/i,/4/i]},vj={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},_j={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]},wj={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},Sj={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]},Ej={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},Oj={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}},Aj={ordinalNumber:dj({matchPattern:mj,parsePattern:pj,valueCallback:n=>parseInt(n,10)}),era:ao({matchPatterns:yj,defaultMatchWidth:"wide",parsePatterns:gj,defaultParseWidth:"any"}),quarter:ao({matchPatterns:bj,defaultMatchWidth:"wide",parsePatterns:xj,defaultParseWidth:"any",valueCallback:n=>n+1}),month:ao({matchPatterns:vj,defaultMatchWidth:"wide",parsePatterns:_j,defaultParseWidth:"any"}),day:ao({matchPatterns:wj,defaultMatchWidth:"wide",parsePatterns:Sj,defaultParseWidth:"any"}),dayPeriod:ao({matchPatterns:Ej,defaultMatchWidth:"any",parsePatterns:Oj,defaultParseWidth:"any"})},av={code:"en-US",formatDistance:XA,formatLong:ej,formatRelative:nj,localize:uj,match:Aj,options:{weekStartsOn:0,firstWeekContainsDate:1}};function jj(n,t){const s=jn(n,t==null?void 0:t.in);return IA(s,KA(s))+1}function kj(n,t){const s=jn(n,t==null?void 0:t.in),i=+bu(s)-+$A(s);return Math.round(i/rv)+1}function ov(n,t){var d,b,x,v;const s=jn(n,t==null?void 0:t.in),i=s.getFullYear(),o=Mo(),c=(t==null?void 0:t.firstWeekContainsDate)??((b=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??o.firstWeekContainsDate??((v=(x=o.locale)==null?void 0:x.options)==null?void 0:v.firstWeekContainsDate)??1,m=Br((t==null?void 0:t.in)||n,0);m.setFullYear(i+1,0,c),m.setHours(0,0,0,0);const y=Ao(m,t),g=Br((t==null?void 0:t.in)||n,0);g.setFullYear(i,0,c),g.setHours(0,0,0,0);const u=Ao(g,t);return+s>=+y?i+1:+s>=+u?i:i-1}function Nj(n,t){var y,g,u,d;const s=Mo(),i=(t==null?void 0:t.firstWeekContainsDate)??((g=(y=t==null?void 0:t.locale)==null?void 0:y.options)==null?void 0:g.firstWeekContainsDate)??s.firstWeekContainsDate??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,o=ov(n,t),c=Br((t==null?void 0:t.in)||n,0);return c.setFullYear(o,0,i),c.setHours(0,0,0,0),Ao(c,t)}function Tj(n,t){const s=jn(n,t==null?void 0:t.in),i=+Ao(s,t)-+Nj(s,t);return Math.round(i/rv)+1}function nt(n,t){const s=n<0?"-":"",i=Math.abs(n).toString().padStart(t,"0");return s+i}const ps={y(n,t){const s=n.getFullYear(),i=s>0?s:1-s;return nt(t==="yy"?i%100:i,t.length)},M(n,t){const s=n.getMonth();return t==="M"?String(s+1):nt(s+1,2)},d(n,t){return nt(n.getDate(),t.length)},a(n,t){const s=n.getHours()/12>=1?"pm":"am";switch(t){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(n,t){return nt(n.getHours()%12||12,t.length)},H(n,t){return nt(n.getHours(),t.length)},m(n,t){return nt(n.getMinutes(),t.length)},s(n,t){return nt(n.getSeconds(),t.length)},S(n,t){const s=t.length,i=n.getMilliseconds(),o=Math.trunc(i*Math.pow(10,s-3));return nt(o,t.length)}},Ii={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},E1={G:function(n,t,s){const i=n.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return s.era(i,{width:"abbreviated"});case"GGGGG":return s.era(i,{width:"narrow"});case"GGGG":default:return s.era(i,{width:"wide"})}},y:function(n,t,s){if(t==="yo"){const i=n.getFullYear(),o=i>0?i:1-i;return s.ordinalNumber(o,{unit:"year"})}return ps.y(n,t)},Y:function(n,t,s,i){const o=ov(n,i),c=o>0?o:1-o;if(t==="YY"){const m=c%100;return nt(m,2)}return t==="Yo"?s.ordinalNumber(c,{unit:"year"}):nt(c,t.length)},R:function(n,t){const s=sv(n);return nt(s,t.length)},u:function(n,t){const s=n.getFullYear();return nt(s,t.length)},Q:function(n,t,s){const i=Math.ceil((n.getMonth()+1)/3);switch(t){case"Q":return String(i);case"QQ":return nt(i,2);case"Qo":return s.ordinalNumber(i,{unit:"quarter"});case"QQQ":return s.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return s.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(i,{width:"wide",context:"formatting"})}},q:function(n,t,s){const i=Math.ceil((n.getMonth()+1)/3);switch(t){case"q":return String(i);case"qq":return nt(i,2);case"qo":return s.ordinalNumber(i,{unit:"quarter"});case"qqq":return s.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return s.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(i,{width:"wide",context:"standalone"})}},M:function(n,t,s){const i=n.getMonth();switch(t){case"M":case"MM":return ps.M(n,t);case"Mo":return s.ordinalNumber(i+1,{unit:"month"});case"MMM":return s.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return s.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(i,{width:"wide",context:"formatting"})}},L:function(n,t,s){const i=n.getMonth();switch(t){case"L":return String(i+1);case"LL":return nt(i+1,2);case"Lo":return s.ordinalNumber(i+1,{unit:"month"});case"LLL":return s.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return s.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(i,{width:"wide",context:"standalone"})}},w:function(n,t,s,i){const o=Tj(n,i);return t==="wo"?s.ordinalNumber(o,{unit:"week"}):nt(o,t.length)},I:function(n,t,s){const i=kj(n);return t==="Io"?s.ordinalNumber(i,{unit:"week"}):nt(i,t.length)},d:function(n,t,s){return t==="do"?s.ordinalNumber(n.getDate(),{unit:"date"}):ps.d(n,t)},D:function(n,t,s){const i=jj(n);return t==="Do"?s.ordinalNumber(i,{unit:"dayOfYear"}):nt(i,t.length)},E:function(n,t,s){const i=n.getDay();switch(t){case"E":case"EE":case"EEE":return s.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return s.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(i,{width:"short",context:"formatting"});case"EEEE":default:return s.day(i,{width:"wide",context:"formatting"})}},e:function(n,t,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(t){case"e":return String(c);case"ee":return nt(c,2);case"eo":return s.ordinalNumber(c,{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(n,t,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(t){case"c":return String(c);case"cc":return nt(c,t.length);case"co":return s.ordinalNumber(c,{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(n,t,s){const i=n.getDay(),o=i===0?7:i;switch(t){case"i":return String(o);case"ii":return nt(o,t.length);case"io":return s.ordinalNumber(o,{unit:"day"});case"iii":return s.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return s.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return s.day(i,{width:"short",context:"formatting"});case"iiii":default:return s.day(i,{width:"wide",context:"formatting"})}},a:function(n,t,s){const o=n.getHours()/12>=1?"pm":"am";switch(t){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(n,t,s){const i=n.getHours();let o;switch(i===12?o=Ii.noon:i===0?o=Ii.midnight:o=i/12>=1?"pm":"am",t){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(n,t,s){const i=n.getHours();let o;switch(i>=17?o=Ii.evening:i>=12?o=Ii.afternoon:i>=4?o=Ii.morning:o=Ii.night,t){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(n,t,s){if(t==="ho"){let i=n.getHours()%12;return i===0&&(i=12),s.ordinalNumber(i,{unit:"hour"})}return ps.h(n,t)},H:function(n,t,s){return t==="Ho"?s.ordinalNumber(n.getHours(),{unit:"hour"}):ps.H(n,t)},K:function(n,t,s){const i=n.getHours()%12;return t==="Ko"?s.ordinalNumber(i,{unit:"hour"}):nt(i,t.length)},k:function(n,t,s){let i=n.getHours();return i===0&&(i=24),t==="ko"?s.ordinalNumber(i,{unit:"hour"}):nt(i,t.length)},m:function(n,t,s){return t==="mo"?s.ordinalNumber(n.getMinutes(),{unit:"minute"}):ps.m(n,t)},s:function(n,t,s){return t==="so"?s.ordinalNumber(n.getSeconds(),{unit:"second"}):ps.s(n,t)},S:function(n,t){return ps.S(n,t)},X:function(n,t,s){const i=n.getTimezoneOffset();if(i===0)return"Z";switch(t){case"X":return A1(i);case"XXXX":case"XX":return Xs(i);case"XXXXX":case"XXX":default:return Xs(i,":")}},x:function(n,t,s){const i=n.getTimezoneOffset();switch(t){case"x":return A1(i);case"xxxx":case"xx":return Xs(i);case"xxxxx":case"xxx":default:return Xs(i,":")}},O:function(n,t,s){const i=n.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+O1(i,":");case"OOOO":default:return"GMT"+Xs(i,":")}},z:function(n,t,s){const i=n.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+O1(i,":");case"zzzz":default:return"GMT"+Xs(i,":")}},t:function(n,t,s){const i=Math.trunc(+n/1e3);return nt(i,t.length)},T:function(n,t,s){return nt(+n,t.length)}};function O1(n,t=""){const s=n>0?"-":"+",i=Math.abs(n),o=Math.trunc(i/60),c=i%60;return c===0?s+String(o):s+String(o)+t+nt(c,2)}function A1(n,t){return n%60===0?(n>0?"-":"+")+nt(Math.abs(n)/60,2):Xs(n,t)}function Xs(n,t=""){const s=n>0?"-":"+",i=Math.abs(n),o=nt(Math.trunc(i/60),2),c=nt(i%60,2);return s+o+t+c}const j1=(n,t)=>{switch(n){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},lv=(n,t)=>{switch(n){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},Cj=(n,t)=>{const s=n.match(/(P+)(p+)?/)||[],i=s[1],o=s[2];if(!o)return j1(n,t);let c;switch(i){case"P":c=t.dateTime({width:"short"});break;case"PP":c=t.dateTime({width:"medium"});break;case"PPP":c=t.dateTime({width:"long"});break;case"PPPP":default:c=t.dateTime({width:"full"});break}return c.replace("{{date}}",j1(i,t)).replace("{{time}}",lv(o,t))},Mj={p:lv,P:Cj},Rj=/^D+$/,Dj=/^Y+$/,Lj=["D","DD","YY","YYYY"];function qj(n){return Rj.test(n)}function Bj(n){return Dj.test(n)}function Pj(n,t,s){const i=Uj(n,t,s);if(console.warn(i),Lj.includes(n))throw new RangeError(i)}function Uj(n,t,s){const i=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${t}\`) for formatting ${i} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const zj=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ij=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,$j=/^'([^]*?)'?$/,Hj=/''/g,Fj=/[a-zA-Z]/;function Cm(n,t,s){var d,b,x,v;const i=Mo(),o=i.locale??av,c=i.firstWeekContainsDate??((b=(d=i.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??1,m=i.weekStartsOn??((v=(x=i.locale)==null?void 0:x.options)==null?void 0:v.weekStartsOn)??0,y=jn(n,s==null?void 0:s.in);if(!VA(y))throw new RangeError("Invalid time value");let g=t.match(Ij).map(w=>{const S=w[0];if(S==="p"||S==="P"){const C=Mj[S];return C(w,o.formatLong)}return w}).join("").match(zj).map(w=>{if(w==="''")return{isToken:!1,value:"'"};const S=w[0];if(S==="'")return{isToken:!1,value:Gj(w)};if(E1[S])return{isToken:!0,value:w};if(S.match(Fj))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:w}});o.localize.preprocessor&&(g=o.localize.preprocessor(y,g));const u={firstWeekContainsDate:c,weekStartsOn:m,locale:o};return g.map(w=>{if(!w.isToken)return w.value;const S=w.value;(Bj(S)||qj(S))&&Pj(S,t,String(n));const C=E1[S[0]];return C(y,S,o.localize,u)}).join("")}function Gj(n){const t=n.match($j);return t?t[1].replace(Hj,"'"):n}function Vj(n,t,s){const i=Mo(),o=(s==null?void 0:s.locale)??i.locale??av,c=HA(n,t);if(isNaN(c))throw new RangeError("Invalid time value");const m=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:c}),[y,g]=iv(s==null?void 0:s.in,...c>0?[t,n]:[n,t]),u=YA((s==null?void 0:s.roundingMethod)??"round"),d=g.getTime()-y.getTime(),b=d/b1,x=xu(g)-xu(y),v=(d-x)/b1,w=s==null?void 0:s.unit;let S;if(w?S=w:b<1?S="second":b<60?S="minute":b<_1?S="hour":v<v1?S="day":v<x1?S="month":S="year",S==="second"){const C=u(d/1e3);return o.formatDistance("xSeconds",C,m)}else if(S==="minute"){const C=u(b);return o.formatDistance("xMinutes",C,m)}else if(S==="hour"){const C=u(b/60);return o.formatDistance("xHours",C,m)}else if(S==="day"){const C=u(v/_1);return o.formatDistance("xDays",C,m)}else if(S==="month"){const C=u(v/v1);return C===12&&w!=="month"?o.formatDistance("xYears",1,m):o.formatDistance("xMonths",C,m)}else{const C=u(v/x1);return o.formatDistance("xYears",C,m)}}function Yj(n,t){return Vj(n,FA(n),t)}function R5(n){return n.toLocaleString()}function D5(n){return n>=1e9?`${(n/1e9).toFixed(1).replace(/\.0$/,"")}B`:n>=1e6?`${(n/1e6).toFixed(1).replace(/\.0$/,"")}M`:n>=1e4?`${(n/1e3).toFixed(1).replace(/\.0$/,"")}K`:n.toLocaleString()}function Kj(n){const t=new Date(n);return t.getTime()>Date.now()?"just now":Yj(t,{addSuffix:!0})}function L5(n){const t=Date.now()-new Date(n).getTime();if(t<0)return"now";const s=Math.floor(t/1e3);if(s<60)return`${s}s`;const i=Math.floor(s/60);if(i<60)return`${i}m`;const o=Math.floor(i/60);if(o<24)return`${o}h`;const c=Math.floor(o/24);return c<7?`${c}d`:c<30?`${Math.floor(c/7)}w`:c<365?`${Math.floor(c/30)}mo`:`${Math.floor(c/365)}y`}function q5(n){return n<=0?"Expired":Mm(n)}function Jj(n){return n==null?"--":Mm(n)}function B5(n){return n?Cm(new Date(n),"MMM d, yyyy h:mm a"):"--"}function Mm(n){if(n<1e3)return`${Math.round(n)}ms`;if(n<6e4){const m=n/1e3;return Number.isInteger(m)?`${m}s`:`${m.toFixed(1)}s`}const t=Math.floor(n/1e3),s=Math.floor(t/86400),i=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),c=t%60;return s>0?i>0?`${s}d ${i}h`:`${s}d`:i>0?o>0?`${i}h ${o}m`:`${i}h`:c>0?`${o}m ${c}s`:`${o}m`}function P5(n,t){const s=new Date(n).getTime(),i=t?new Date(t).getTime():Date.now();return Mm(i-s)}function cv({options:n,children:t,className:s=""}){const[i,o]=E.useState(!1),[c,m]=E.useState(null),[y,g]=E.useState(null),u=E.useRef(null),d=E.useRef(void 0),b=E.useRef(void 0),x=220,v=E.useCallback(()=>{if(!u.current)return;const q=u.current.getBoundingClientRect(),B=window.innerWidth-x-8,ie=Math.max(8,Math.min(q.left,B));g({top:q.bottom+4,left:ie})},[]),w=E.useCallback(async(q,B)=>{try{await navigator.clipboard.writeText(q),m(B),clearTimeout(d.current),d.current=setTimeout(()=>m(null),1200)}catch{}},[]),S=E.useCallback(()=>{clearTimeout(b.current),v(),o(!0)},[v]),C=E.useCallback(()=>{b.current=setTimeout(()=>o(!1),150)},[]);return E.useEffect(()=>()=>{clearTimeout(d.current),clearTimeout(b.current)},[]),h.jsxs("span",{ref:u,className:`inline-flex items-center cursor-default ${s}`,onMouseEnter:S,onMouseLeave:C,children:[t,i&&y&&Wd.createPortal(h.jsx("span",{className:"fixed z-[9999] bg-surface-raised border border-surface-border rounded shadow-lg py-1 min-w-[180px]",style:{top:y.top,left:y.left},onMouseEnter:S,onMouseLeave:C,children:n.map(q=>h.jsxs("button",{onClick:B=>{B.stopPropagation(),w(q.value,q.label)},className:"flex items-center justify-between w-full px-2.5 py-1 text-left hover:bg-surface-hover transition-colors",children:[h.jsx("span",{className:"text-2xs font-medium uppercase tracking-wider text-text-tertiary w-10 shrink-0",children:q.label}),h.jsx("span",{className:"text-2xs font-mono text-text-secondary truncate ml-2",children:c===q.label?"✓":q.value})]},q.label))}),document.body)]})}function Xj(n,t){const s=new Date(n);switch(t){case"relative":return Kj(n);case"datetime":return Cm(s,"MMM d, yyyy h:mm a");case"time":return s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function Qj(n){const t=new Date(n);return[{label:"ms",value:String(t.getTime())},{label:"utc",value:t.toISOString()},{label:"local",value:Cm(t,"MMM d, yyyy h:mm:ss a")}]}function uv({date:n,format:t="relative",className:s=""}){const[,i]=E.useState(0);E.useEffect(()=>{if(t!=="relative")return;const c=setInterval(()=>i(m=>m+1),3e4);return()=>clearInterval(c)},[t]);const o=E.useMemo(()=>Qj(n),[n]);return h.jsx(cv,{options:o,children:h.jsx("time",{dateTime:n,className:`text-xs text-text-tertiary ${s}`,children:Xj(n,t)})})}function Wj({values:n,options:t,onChange:s,addLabel:i,emptyText:o,ariaLabel:c}){const m=t.filter(y=>!n.includes(y));return h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.map(y=>h.jsxs("button",{type:"button",onClick:()=>s(n.filter(g=>g!==y)),className:"inline-flex items-center gap-1 text-2xs font-mono text-text-primary border border-surface-border px-1.5 py-0.5 hover:text-status-error hover:border-status-error/50 transition-colors",title:`Remove ${y}`,children:[y,h.jsx(Wt,{className:"w-3 h-3",strokeWidth:1.5})]},y)),n.length===0&&o&&h.jsx("span",{className:"text-2xs text-text-tertiary italic",children:o}),m.length>0&&h.jsxs("select",{value:"",onChange:y=>y.target.value&&s([...n,y.target.value]),className:"select font-mono","aria-label":c??i,children:[h.jsx("option",{value:"",children:i}),m.map(y=>h.jsx("option",{value:y,children:y},y))]})]})}const Zj=[{minutes:1,label:"1 minute"},{minutes:15,label:"15 minutes"},{minutes:30,label:"30 minutes"},{minutes:60,label:"1 hour"},{minutes:240,label:"4 hours"},{minutes:1440,label:"24 hours"},{minutes:4320,label:"3 days"},{minutes:10080,label:"7 days"}];function ek(){const{data:n}=nv(),{data:t}=pA(),s=BA(),i=PA(),[o,c]=E.useState(""),[m,y]=E.useState(""),[g,u]=E.useState(1440),[d,b]=E.useState([]),x=(n==null?void 0:n.announcements)??[],v=()=>{m.trim()&&s.mutate({body:m.trim(),...o.trim()?{title:o.trim()}:{},...d.length?{roles:d}:{},expiresAt:new Date(Date.now()+g*6e4).toISOString()},{onSuccess:()=>{c(""),y(""),b([])}})};return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"Alerts"}),h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Title"}),h.jsx("input",{type:"text",value:o,onChange:w=>c(w.target.value),placeholder:"Optional headline",className:"input text-xs w-full"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Summary"}),h.jsx("textarea",{value:m,onChange:w=>y(w.target.value),placeholder:"What everyone should know (markdown supported)",rows:3,className:"input text-xs w-full resize-y"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible for"}),h.jsx("select",{value:g,onChange:w=>u(Number(w.target.value)),className:"select text-xs w-full",children:Zj.map(w=>h.jsx("option",{value:w.minutes,children:w.label},w.minutes))})]}),h.jsxs("div",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible to"}),h.jsx(Wj,{values:d,options:(t==null?void 0:t.roles)??[],onChange:b,addLabel:"Add a role…",emptyText:"Everyone",ariaLabel:"Add a role"})]}),s.error&&h.jsx("p",{className:"text-xs text-status-error",children:s.error.message}),h.jsx("button",{onClick:v,disabled:!m.trim()||s.isPending,className:"btn-primary text-xs w-full disabled:opacity-50",children:s.isPending?"Publishing…":"Publish alert"})]}),x.length>0&&h.jsxs("div",{className:"mt-6",children:[h.jsx("p",{className:"text-2xs text-text-tertiary mb-2",children:"Active now — stacked as banner rows, newest first"}),h.jsx("div",{className:"space-y-1",children:x.map(w=>h.jsxs("div",{className:"flex items-start gap-2 py-1.5 border-b border-surface-border/40 last:border-b-0",children:[h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsx("span",{className:"block text-xs text-text-primary truncate",children:w.title??w.body.split(`
54
- `)[0]}),h.jsxs("span",{className:"block text-2xs text-text-tertiary",children:["expires ",h.jsx(uv,{date:w.expires_at,format:"relative"})]})]}),h.jsx("button",{onClick:()=>i.mutate(w.id),disabled:i.isPending,className:"icon-link shrink-0 mt-0.5",title:"Remove for everyone","aria-label":`Remove ${w.title??"announcement"}`,children:h.jsx(Wt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]},w.id))})]})]})}const tk=[{id:null,label:"Your view",description:"Full access based on your account role",minTier:"operator"},{id:"admin",label:"Admin",description:"Pace Board + identity management",minTier:"superadmin"},{id:"engineer",label:"Engineer",description:"Work queue + identity management",minTier:"admin"},{id:"operator",label:"Operator",description:"Escalation queue only",minTier:"engineer"}],nk=["operator","engineer","admin","superadmin"];function k1(n){return nk.indexOf(n)}function rk(n,t){return k1(n)>=k1(t)}function sk({onClose:n}){var Ne,Me,Ze,yt,Ct,we,Re;const{isSuperAdmin:t,hasRoleType:s,hasRole:i}=Pt(),{data:o}=Zn(),c=xm(),m=!!((Ne=o==null?void 0:o.ai)!=null&&Ne.enabled),y=Hx(),g=y!==null?y:m,[u,d]=E.useState(g),b=(Me=o==null?void 0:o.features)==null?void 0:Me.graphWorkflows,x=b==null,[v,w]=E.useState(b===!0||x&&Fx()),S=t||i("engineer"),[C,q]=E.useState(Gx()),B=!!((Ze=o==null?void 0:o.features)!=null&&Ze.scanCodes),ie=Vx(),[le,R]=E.useState(ie!==null?ie:B),$=t?"superadmin":s("admin")?"admin":i("engineer")?"engineer":"operator",ne=((yt=o==null?void 0:o.branding)==null?void 0:yt.appName)??"LongTail",V=(Ct=o==null?void 0:o.environment)==null?void 0:Ct.longTailVersion,I=(we=o==null?void 0:o.environment)==null?void 0:we.hotmeshVersion,D=(Re=o==null?void 0:o.environment)==null?void 0:Re.nodeEnv;E.useEffect(()=>{const oe=Be=>{Be.key==="Escape"&&n()};return document.addEventListener("keydown",oe),()=>document.removeEventListener("keydown",oe)},[n]);const Q=tk.filter(oe=>rk($,oe.minTier)),X=Q.length>1,he=$!=="operator",Se=[...X?[{id:"viewas",label:"View As",icon:cS}]:[],{id:"features",label:"Features",icon:uS},...he?[{id:"alerts",label:"Alerts",icon:fS}]:[]],[ke,H]=E.useState(Se[0].id),W=oe=>{oe===null?zd():rA(oe)},ce=()=>{const oe=!u;d(oe),oe===m?nA():tA(oe),window.location.reload()},xe=()=>{const oe=!v;w(oe),sA(oe),window.location.reload()},ve=()=>{const oe=!C;q(oe),iA(oe),window.location.reload()},Ce=()=>{const oe=!le;R(oe),oe===B?oA():aA(oe),window.location.reload()};return h.jsx("div",{className:"fixed inset-0 z-[100] bg-surface-sunken/75 backdrop-blur-sm flex items-center justify-center",onClick:n,children:h.jsxs("div",{className:"relative w-[440px] max-h-[85vh] overflow-y-auto bg-surface-raised px-12 py-10",onClick:oe=>oe.stopPropagation(),children:[h.jsx("button",{onClick:n,className:"absolute top-4 right-4 text-text-quaternary hover:text-text-secondary transition-colors p-1","aria-label":"Close",children:h.jsx(Wt,{className:"w-4 h-4",strokeWidth:1.5})}),h.jsxs("div",{className:"flex flex-col items-center gap-3 pb-8",children:[h.jsx("span",{className:"logo-mark block w-20 h-20 opacity-50",style:{"--logo-url":`url(${Ht}/logo512.png)`}}),h.jsxs("div",{className:"text-center",children:[h.jsx("p",{className:"text-2xl font-light text-text-primary tracking-[0.12em]",children:ne}),V&&h.jsxs("p",{className:"mt-1 text-2xs text-text-tertiary",children:["v",V,I&&h.jsxs(h.Fragment,{children:[" · HotMesh v",I]}),D&&D!=="production"&&h.jsx("span",{className:"ml-1 text-status-warning",children:D})]})]})]}),h.jsx("hr",{className:"border-surface-border/50 mb-6"}),Se.length>1&&h.jsx("div",{className:"flex items-center justify-center gap-2 mb-8",role:"tablist",children:Se.map(oe=>{const Be=ke===oe.id;return h.jsxs("button",{role:"tab","aria-selected":Be,onClick:()=>H(oe.id),title:oe.label,className:`flex flex-col items-center gap-1.5 px-5 py-2.5 rounded-lg transition-colors ${Be?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[h.jsx(oe.icon,{className:"w-5 h-5",strokeWidth:1.5,...Be?{fill:"currentColor",fillOpacity:.15}:{}}),h.jsx("span",{className:"text-2xs font-medium",children:oe.label})]},oe.id)})}),ke==="viewas"&&X&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"View As"}),Q.map(oe=>{const Be=c===oe.id,We=oe.id===null?`Your view · ${$}`:oe.label;return h.jsxs("button",{onClick:()=>W(oe.id),className:"w-full text-left flex items-start gap-3 py-2.5 px-1 group",children:[h.jsx("span",{className:`mt-0.5 w-4 h-4 rounded-full border shrink-0 flex items-center justify-center transition-colors ${Be?"border-accent bg-accent":"border-surface-border group-hover:border-accent/60"}`,children:Be&&h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"})}),h.jsxs("span",{children:[h.jsx("span",{className:`block text-sm font-medium transition-colors ${Be?"text-accent":"text-text-primary group-hover:text-accent"}`,children:We}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:oe.description})]})]},String(oe.id))})]}),ke==="features"&&h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"Features"}),h.jsxs("button",{onClick:ce,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"AI features"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:u?"Enabled — AI assist, agent labels, bulk AI actions":"Hidden — automation labels, no AI surfaces"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${u?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${u?"translate-x-4":"translate-x-0"}`})})]}),x&&h.jsxs("button",{onClick:xe,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Graph workflows"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:v?"Visible — Graph section shown in Orchestrate sidebar":"Hidden — use Procedural workflows instead"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${v?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${v?"translate-x-4":"translate-x-0"}`})})]}),S&&h.jsxs("button",{onClick:ve,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group","data-testid":"feature-infrastructure",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Infrastructure"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:C?"Visible — Routers, Messages, and DB Maintenance in the sidebar":"Hidden — routers, message streams, and database maintenance"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${C?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${C?"translate-x-4":"translate-x-0"}`})})]}),h.jsxs("button",{onClick:Ce,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Scan input"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:le?"Enabled — header scan affordance, panel, and keyboard-wedge capture":"Hidden — the deployment opts in with features.scanCodes"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${le?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${le?"translate-x-4":"translate-x-0"}`})})]})]}),ke==="alerts"&&he&&h.jsx(ek,{}),h.jsx("hr",{className:"border-surface-border/50 mt-8"}),h.jsx("p",{className:"mt-4 text-2xs text-text-quaternary text-center",children:"Esc or click outside to close"})]})})}const fv=[{id:"violet",label:"Violet",swatch:"#7B3BE0"},{id:"red",label:"Brick",swatch:"#DC382D"},{id:"green",label:"Emerald",swatch:"#059669"},{id:"blue",label:"Electric",swatch:"#2563EB"},{id:"rose",label:"Raspberry",swatch:"#D6246E"},{id:"orange",label:"Harvest",swatch:"#E85D04"}],N1="blue",hv="lt.theme";let dv=[];function ik(n){const t=new Set(fv.map(i=>i.id)),s=new Set;dv=n.filter(i=>!(i!=null&&i.id)||t.has(i.id)||s.has(i.id)?!1:(s.add(i.id),!0))}function ak(){return[...fv,...dv]}function mv(){try{return localStorage.getItem(hv)||N1}catch{return N1}}function pv(n){document.documentElement.dataset.theme=n}function ok(n){try{localStorage.setItem(hv,n)}catch{}pv(n)}const yv=E.createContext(null);function lk(){const n=E.useContext(yv);if(!n)throw new Error("useActingIdentity must be used within ActingIdentityProvider");return n}function ck({children:n}){const[t,s]=E.useState(null),i=E.useRef(t);i.current=t,E.useEffect(()=>{if(!(t!=null&&t.expiresAt))return;const d=new Date(t.expiresAt).getTime()-Date.now();if(d<=0){s(null);return}const b=setTimeout(()=>s(null),d);return()=>clearTimeout(b)},[t]);const o=E.useCallback(d=>{var x;if(!d.actingToken||!d.actor)return null;const b=((x=i.current)==null?void 0:x.actingToken)??null;return s({actingToken:d.actingToken,actorId:d.actor.id,displayName:d.actor.displayName,expiresAt:d.expiresAt??null,subjectScoped:d.grantScope==="subject"}),b},[]),c=E.useCallback(()=>s(null),[]),m=E.useCallback((d,b)=>{const x=i.current;b===0&&(x==null?void 0:x.actingToken)===d&&s(null)},[]),y=E.useCallback((d,b)=>{const x=i.current;if(!x||x.actingToken!==d||!b.acting)return;const{consumed:v,remaining:w,bound:S}=b.acting;(v&&w===0||S&&b.clearSubject)&&s(null)},[]);E.useEffect(()=>(Lg(()=>{var d;return((d=i.current)==null?void 0:d.actingToken)??null}),Bg(c),qg(m),()=>{Lg(null),Bg(null),qg(null)}),[c,m]);const g=E.useCallback(()=>{var b;const d=(b=i.current)==null?void 0:b.expiresAt;return d?Math.max(0,Math.floor((new Date(d).getTime()-Date.now())/1e3)):0},[]),u=E.useMemo(()=>({identity:t,prime:o,clear:c,settle:y,remainingSeconds:g}),[t,o,c,y,g]);return h.jsx(yv.Provider,{value:u,children:n})}const uk=[8,12,13,14];function fk(n){if(!/^[0-9]+$/.test(n)||!uk.includes(n.length))return!1;const t=n.split("").map(Number),s=t.pop();let i=0;for(let o=t.length-1,c=3;o>=0;o--,c=c===3?1:3)i+=t[o]*c;return(10-i%10)%10===s}function U5(n){return n.padStart(14,"0")}const lu={maxKeyGapMs:500,terminators:["Enter","Tab"],minLength:6,autoFireQuietMs:300,autoFireMaxAvgKeyMs:50},gv="lt_scan_wedge_config";function bv(){try{const n=localStorage.getItem(gv);return n?{...lu,...JSON.parse(n)}:lu}catch{return lu}}function hk(n){const t={...bv(),...n};return localStorage.setItem(gv,JSON.stringify(t)),t}const Rm=[{pattern:/(?:^|[^0-9])([1-9][0-9]:[0-9]:[a-zA-Z0-9._-]+)$/,digitsOnly:!1},{pattern:/(?:^|[^0-9])([1-9][0-9]{7,})$/,digitsOnly:!0}];function dk(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function mk(n){const t=[];for(const s of n.filter(i=>i.enabled))if(s.encoding==="delimited"){const i=dk(s.delimiter);t.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}${i}[0-9]${i}[a-zA-Z0-9._-]+)$`),digitsOnly:!1})}else if(s.encoding==="fixed"){const i=1+(s.target_length??0);t.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}[0-9]{${i},${i+1}})$`),digitsOnly:!0})}else s.encoding==="gtin"&&t.push({pattern:/(?:^|[^0-9])([0-9]{8}|[0-9]{12,14})$/,digitsOnly:!0,accept:fk});return t.length?t:Rm}function pk(n,t=Rm){var i;let s=null;for(const o of t){const c=(i=n.match(o.pattern))==null?void 0:i[1];!c||o.accept&&!o.accept(c)||(!s||c.length>s.code.length)&&(s={code:c,shape:o})}return s}const yk=new Set(["Shift","CapsLock"]),uc={suppress:!1,emit:null};function gk(n=lu,t=Rm){let s={buffer:"",times:[],lastKeyMs:0};function i(u){const d=s.times.slice(-u.length);return d.length<2?!1:(d[d.length-1]-d[0])/(d.length-1)<=n.autoFireMaxAvgKeyMs}function o(){const u=pk(s.buffer,t);return!u||u.code.length<n.minLength||u.shape.digitsOnly&&!i(u.code)?null:u.code}function c(){s={buffer:"",times:[],lastKeyMs:0}}function m(u){const{key:d,timeMs:b,hasModifier:x,isRepeat:v}=u;if(yk.has(d))return uc;if(n.terminators.includes(d)){const B=o();return c(),B?{suppress:!0,emit:B,consumedLength:B.length}:uc}if(x||v||d.length!==1)return c(),uc;const w=b-s.lastKeyMs,S=s.lastKeyMs>0&&w<=n.maxKeyGapMs,C=(S?s.buffer+d:d).slice(-128),q=(S?[...s.times,b]:[b]).slice(-128);return s={buffer:C,times:q,lastKeyMs:b},uc}function y(){return{buffer:s.buffer}}function g(){const u=o();return!u||!i(u)?null:{code:u,consumedLength:u.length}}return{step:m,reset:c,snapshot:y,pendingAutoFire:g}}function bk(){const n=document.activeElement;return n instanceof HTMLInputElement?["text","search","tel","url","email","password","number"].includes(n.type)?n:null:n instanceof HTMLTextAreaElement?n:null}function xk(n,t,s){var c;const i=n instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,o=(c=Object.getOwnPropertyDescriptor(i,"value"))==null?void 0:c.set;o?o.call(n,t):n.value=t;try{n.setSelectionRange(s,s)}catch{}n.dispatchEvent(new Event("input",{bubbles:!0}))}function T1(n){if(n<=0)return;const t=bk();if(!t)return;const s=t.selectionStart??t.value.length,i=Math.max(0,s-n);xk(t,t.value.slice(0,i)+t.value.slice(s),i)}function vk({active:n,wedgeConfig:t,tailShapes:s,diagnosticsOn:i,onScan:o,onDiag:c}){const m=E.useRef({diagnosticsOn:i,onScan:o,onDiag:c});m.current={diagnosticsOn:i,onScan:o,onDiag:c};const y=E.useRef(0),g=E.useRef(0);E.useEffect(()=>{if(!n)return;const u=gk(t,s);let d=null;const b=()=>{d&&(clearTimeout(d),d=null)},x=(S,C,q)=>{C&&T1(C),m.current.diagnosticsOn&&(console.debug("[scan]",q),m.current.onDiag({seq:++y.current,key:"(quiet)",code:"",deltaMs:0,buffer:"",note:q})),m.current.onScan(S)},v=()=>{b(),u.pendingAutoFire()&&(d=setTimeout(()=>{d=null;const S=u.pendingAutoFire();S&&(u.reset(),x(S.code,S.consumedLength,`capture → ${S.code} (quiet period — no suffix)`))},t.autoFireQuietMs))},w=S=>{const C=u.snapshot().buffer,{suppress:q,emit:B,consumedLength:ie}=u.step({key:S.key,timeMs:S.timeStamp,hasModifier:S.ctrlKey||S.metaKey||S.altKey,isRepeat:S.repeat});if(q&&(S.preventDefault(),S.stopPropagation()),m.current.diagnosticsOn){const le=u.snapshot().buffer,R=t.terminators.includes(S.key),$=B?`capture → ${B}`:R?`terminator — no code tail in "${C.slice(-24)}"`:le===C?C?"neutral (chord key)":"ignored":le===""?"reset (edit/chord/non-printable)":le.length<=1&&C.length>1?"gap — new episode":"accumulate",ne=g.current?Math.round(S.timeStamp-g.current):0,V={seq:++y.current,key:S.key,code:S.code!==S.key?S.code:"",deltaMs:ne,buffer:le.slice(-24),note:$};console.debug("[scan]",V.key,V.code,`${V.deltaMs}ms`,V.note),m.current.onDiag(V)}g.current=S.timeStamp,B?(b(),ie&&T1(ie),m.current.onScan(B)):v()};return window.addEventListener("keydown",w,{capture:!0}),()=>{b(),window.removeEventListener("keydown",w,{capture:!0})}},[n,t,s])}const Ae={EXECUTED:"executed",MATCHED_LIST:"matched_list",CONFIRM_REQUIRED:"confirm_required",NO_MATCH_FALLBACK:"no_match_fallback",UNCONFIGURED:"unconfigured",INVALID_CODE:"invalid_code",FORBIDDEN:"forbidden",CONFLICT:"conflict",IDENTITY_PRIMED:"identity_primed",IDENTITY_UNKNOWN:"identity_unknown",NOT_PRIMED:"not_primed",CHOICES:"choices",NO_OPEN_CONTAINER:"no_open_container",HELD:"held",REFUSED:"refused",SUBJECT_STALE:"subject_stale"},fc={SHOW_DETAIL:"show-detail",SHOW_LIST:"show-list",CLAIM:"claim",CLAIM_SHOW_DETAIL:"claim-show-detail",RELEASE:"release",RESOLVE:"resolve",ESCALATE:"escalate",CANCEL:"cancel",ACCUMULATE:"accumulate",PRESENT:"present",HOLD:"hold",FILL:"fill"},_k={ACTION:"action",IDENTITY:"identity"};function wk(n,t){return fe("/scan-codes/execute",{method:"POST",body:JSON.stringify({code:n,...t!=null&&t.actingToken?{actingToken:t.actingToken}:{},...t!=null&&t.previousActingToken?{previousActingToken:t.previousActingToken}:{},...t!=null&&t.subject?{subject:t.subject}:{},...t!=null&&t.stationRole?{stationRole:t.stationRole}:{}})})}function z5(n){return fe("/scan-codes/execute-choice",{method:"POST",body:JSON.stringify(n)})}function xv(n){return $e({queryKey:["scan-schemes"],queryFn:()=>fe("/scan-codes/schemes"),...n})}function I5(n){return $e({queryKey:["scan-schemes",n],queryFn:()=>fe(`/scan-codes/schemes/${n}`),enabled:n!=null})}function $5(){const n=He();return Ve({mutationFn:t=>fe(`/scan-codes/schemes/${t.version}`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function H5(){const n=He();return Ve({mutationFn:t=>fe(`/scan-codes/schemes/${t}`,{method:"DELETE"}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function F5(){const n=He();return Ve({mutationFn:t=>fe(`/scan-codes/schemes/${t.scheme_version}/actions/${t.category}`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:(t,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}function G5(){const n=He();return Ve({mutationFn:t=>fe(`/scan-codes/schemes/${t.scheme_version}/actions/${t.category}`,{method:"DELETE"}),onSuccess:(t,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}const Sk=3e4;function Ek(n,t=Date.now()){if(!(!n||Date.parse(n.expiresAt)<=t))return{code:n.code,escalationId:n.escalationId}}function C1(n,t,s=Date.now()){if(t.outcome===Ae.HELD&&t.subject){const i=Math.max(0,Date.parse(t.subject.expiresAt)-s);return{...t.subject,ttlMs:i}}return t.clearSubject||!n?null:t.outcome===Ae.EXECUTED&&t.progress&&t.progress.remaining>0?{...n,expiresAt:new Date(s+n.ttlMs).toISOString()}:n}function M1(n){return n.outcome===Ae.NOT_PRIMED&&n.replayable===!0}function Ok(n,t=Date.now()){return n&&t-n.at<=Sk?n:null}const Ak=[Ae.HELD,Ae.REFUSED,Ae.SUBJECT_STALE],jo={KEYBOARD_WEDGE:"keyboard-wedge",MANUAL:"manual",TOOLBAR:"toolbar"},$i=n=>{if(n)try{return JSON.parse(n)}catch{return}},Qs=n=>n==null||Array.isArray(n)&&n.length===0||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0;function jk(n){const t={},s=$i(n.get("facets"));Qs(s)||(t.facets=s);const i=$i(n.get("block"));Qs(i)||(t.block=i);const o=$i(n.get("range"));Qs(o)||(t.range=o);const c=$i(n.get("exists"));Qs(c)||(t.exists=c);const m=$i(n.get("roles"));Qs(m)||(t.roles=m);const y=$i(n.get("orderBy"));Qs(y)||(t.orderBy=y),n.get("available")!=null&&(t.available=n.get("available")==="true");const g=n.get("jeopardy");return(g==="1"||g==="true")&&(t.jeopardy=!0),t}function V5(n,t){const s=(i,o)=>Qs(o)?n.delete(i):n.set(i,JSON.stringify(o));s("facets",t.facets),s("block",t.block),s("range",t.range),s("exists",t.exists),s("roles",t.roles),s("orderBy",t.orderBy),t.available==null?n.delete("available"):n.set("available",String(t.available)),t.jeopardy===!0?n.set("jeopardy","1"):n.delete("jeopardy")}const R1=`&status=all&view=table&orderBy=${encodeURIComponent(JSON.stringify([{field:"created_at",direction:"desc"}]))}`;function vv(n,t){const s={};for(const[o,c]of Object.entries(n))s[o]=typeof c=="object"&&c!==null?JSON.stringify(c):c;const i=encodeURIComponent(JSON.stringify(s));return t?`/escalations/available?role=${encodeURIComponent(t)}&facets=${i}${R1}`:`/escalations/available?facets=${i}${R1}`}function kk(n,t,s){return vv({[n]:t},s)}function Y5(n){var t,s,i;return Object.keys(n.facets??{}).length+(((t=n.block)==null?void 0:t.length)??0)+(((s=n.range)==null?void 0:s.length)??0)+(((i=n.exists)==null?void 0:i.length)??0)+(n.available!=null?1:0)+(n.jeopardy===!0?1:0)}function Dm(){var s;const{data:n}=Zn(),t=Vx();return t!==null?t:!!((s=n==null?void 0:n.features)!=null&&s.scanCodes)}const Lm=E.createContext(null);function qm(){const n=E.useContext(Lm);if(!n)throw new Error("useScanInput must be used within ScanInputProvider");return n}function K5(){return E.useContext(Lm)}const Nk="scanPendingAction",Tk="scanChoices",od="/scan/station";function Ck({children:n}){const{user:t}=Pt(),s=Dm(),i=ra(),o=an(),{identity:c,prime:m,clear:y,settle:g}=lk(),[u,d]=E.useState(null),[b,x]=E.useState(null),[v,w]=E.useState(null),{data:S}=xv({enabled:!!t&&s,staleTime:6e4}),C=E.useRef(null);C.current=Sm().role;const q=E.useMemo(()=>mk((S==null?void 0:S.schemes)??[]),[S]),[B,ie]=E.useState(!1),[le,R]=E.useState(()=>bv()),[$,ne]=E.useState([]),[V,I]=E.useState(!1),D=E.useCallback(we=>{var Be;const{outcome:Re}=we;if(Re===Ae.CONFIRM_REQUIRED&&we.pendingAction)return i(`/escalations/detail/${we.pendingAction.escalationId}`,{state:{[Nk]:we.pendingAction}}),!0;const oe=Re===Ae.EXECUTED&&!!H.current;if(Ak.includes(Re)||M1(we)||oe)return ce.current!==od&&i(od),!0;if(Re===Ae.EXECUTED&&we.escalation){const We=[fc.SHOW_DETAIL,fc.CLAIM_SHOW_DETAIL,fc.CLAIM,fc.ESCALATE];return we.verb&&We.includes(we.verb)?(i(`/escalations/detail/${we.escalation.id}`),!0):!1}if(Re===Ae.MATCHED_LIST&&we.listQuery){const{targetFacet:We,target:ln,roles:pe}=we.listQuery;return i(vv({[We]:ln},(pe==null?void 0:pe[0])??null)),!0}return Re===Ae.CHOICES&&we.choices?(i(od,{state:{[Tk]:we}}),!0):Re===Ae.NO_MATCH_FALLBACK&&((Be=we.fallback)!=null&&Be.route)?(i(we.fallback.route),!0):!1},[i]),Q=E.useRef(null);Q.current=(c==null?void 0:c.actingToken)??null;const X=E.useRef(null),he=E.useRef([]),Se=E.useCallback(we=>(he.current=[we,...he.current],()=>{he.current=he.current.filter(Re=>Re!==we)}),[]),ke=E.useRef(null);ke.current=b;const H=E.useRef(void 0),W=E.useRef(null);W.current=v;const ce=E.useRef(o.pathname);ce.current=o.pathname,E.useEffect(()=>{if(!b)return;const we=Date.parse(b.expiresAt)-Date.now();if(we<=0){x(null);return}const Re=setTimeout(()=>x(null),we);return()=>clearTimeout(Re)},[b]);const xe=E.useCallback(async(we,Re,oe)=>{ie(!0);const Be=Date.now();try{H.current=Ek(ke.current);const We=await wk(we,{actingToken:oe??void 0,previousActingToken:X.current??void 0,subject:H.current,stationRole:C.current??void 0});if(oe&&g(oe,We),x(pe=>C1(pe,We)),We.outcome===Ae.IDENTITY_PRIMED){X.current=m(We);const pe=Ok(W.current);if(w(null),pe&&We.actingToken){d({code:we,source:Re,at:Be,response:We,error:null,navigated:!1}),await xe(pe.code,Re,We.actingToken);return}}else M1(We)?w({code:we,at:Be}):w(null);We.outcome===Ae.NOT_PRIMED&&oe&&y();const ln=D(We);d({code:we,source:Re,at:Be,response:We,error:null,navigated:ln})}catch(We){d({code:we,source:Re,at:Be,response:null,error:We.message,navigated:!1})}finally{ie(!1)}},[D,m,y,g]),ve=E.useCallback(async(we,Re=jo.MANUAL)=>{for(const oe of he.current)if(oe(we))return;await xe(we,Re,Q.current)},[xe]),Ce=E.useCallback(()=>x(null),[]),Ne=E.useCallback(we=>{x(Re=>C1(Re,we))},[]),Me=E.useCallback(()=>w(null),[]),Ze=E.useRef(ve);Ze.current=ve,vk({active:!!t&&s,wedgeConfig:le,tailShapes:q,diagnosticsOn:V,onScan:we=>void Ze.current(we,jo.KEYBOARD_WEDGE),onDiag:we=>ne(Re=>[...Re.slice(-29),we])});const yt=E.useCallback(we=>{R(hk(we))},[]),Ct=E.useMemo(()=>({submitCode:ve,pushCodeInterceptor:Se,lastResult:u,subject:b,dropSubject:Ce,adoptResponse:Ne,pendingScan:v,dropPendingScan:Me,busy:B,wedgeConfig:le,updateWedgeConfig:yt,diagnostics:$,diagnosticsOn:V,setDiagnosticsOn:I}),[ve,Se,u,b,Ce,Ne,v,Me,B,le,yt,$,V]);return h.jsx(Lm.Provider,{value:Ct,children:n})}var hc={},oo={},dc={},D1;function kn(){if(D1)return dc;D1=1,Object.defineProperty(dc,"__esModule",{value:!0});function n(s,i){if(!(s instanceof i))throw new TypeError("Cannot call a class as a function")}var t=function s(i,o){n(this,s),this.data=i,this.text=o.text||i,this.options=o};return dc.default=t,dc}var L1;function Mk(){if(L1)return oo;L1=1,Object.defineProperty(oo,"__esModule",{value:!0}),oo.CODE39=void 0;var n=(function(){function S(C,q){for(var B=0;B<q.length;B++){var ie=q[B];ie.enumerable=ie.enumerable||!1,ie.configurable=!0,"value"in ie&&(ie.writable=!0),Object.defineProperty(C,ie.key,ie)}}return function(C,q,B){return q&&S(C.prototype,q),B&&S(C,B),C}})(),t=kn(),s=i(t);function i(S){return S&&S.__esModule?S:{default:S}}function o(S,C){if(!(S instanceof C))throw new TypeError("Cannot call a class as a function")}function c(S,C){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return C&&(typeof C=="object"||typeof C=="function")?C:S}function m(S,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof C);S.prototype=Object.create(C&&C.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),C&&(Object.setPrototypeOf?Object.setPrototypeOf(S,C):S.__proto__=C)}var y=(function(S){m(C,S);function C(q,B){return o(this,C),q=q.toUpperCase(),B.mod43&&(q+=x(w(q))),c(this,(C.__proto__||Object.getPrototypeOf(C)).call(this,q,B))}return n(C,[{key:"encode",value:function(){for(var B=d("*"),ie=0;ie<this.data.length;ie++)B+=d(this.data[ie])+"0";return B+=d("*"),{data:B,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),C})(s.default),g=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],u=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function d(S){return b(v(S))}function b(S){return u[S].toString(2)}function x(S){return g[S]}function v(S){return g.indexOf(S)}function w(S){for(var C=0,q=0;q<S.length;q++)C+=v(S[q]);return C=C%43,C}return oo.CODE39=y,oo}var Kn={},mc={},pc={},vt={},q1;function Ro(){if(q1)return vt;q1=1,Object.defineProperty(vt,"__esModule",{value:!0});var n;function t(g,u,d){return u in g?Object.defineProperty(g,u,{value:d,enumerable:!0,configurable:!0,writable:!0}):g[u]=d,g}var s=vt.SET_A=0,i=vt.SET_B=1,o=vt.SET_C=2;vt.SHIFT=98;var c=vt.START_A=103,m=vt.START_B=104,y=vt.START_C=105;return vt.MODULO=103,vt.STOP=106,vt.FNC1=207,vt.SET_BY_CODE=(n={},t(n,c,s),t(n,m,i),t(n,y,o),n),vt.SWAP={101:s,100:i,99:o},vt.A_START_CHAR="Ð",vt.B_START_CHAR="Ñ",vt.C_START_CHAR="Ò",vt.A_CHARS="[\0-_È-Ï]",vt.B_CHARS="[ -È-Ï]",vt.C_CHARS="(Ï*[0-9]{2}Ï*)",vt.BARS=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011],vt}var B1;function Tu(){if(B1)return pc;B1=1,Object.defineProperty(pc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=kn(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){c(this,d);var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b.substring(1),x));return v.bytes=b.split("").map(function(w){return w.charCodeAt(0)}),v}return n(d,[{key:"valid",value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.bytes,v=x.shift()-105,w=i.SET_BY_CODE[v];if(w===void 0)throw new RangeError("The encoding does not start with a start character.");this.shouldEncodeAsEan128()===!0&&x.unshift(i.FNC1);var S=d.next(x,1,w);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:d.getBar(v)+S.result+d.getBar((S.checksum+v)%i.MODULO)+d.getBar(i.STOP)}}},{key:"shouldEncodeAsEan128",value:function(){var x=this.options.ean128||!1;return typeof x=="string"&&(x=x.toLowerCase()==="true"),x}}],[{key:"getBar",value:function(x){return i.BARS[x]?i.BARS[x].toString():""}},{key:"correctIndex",value:function(x,v){if(v===i.SET_A){var w=x.shift();return w<32?w+64:w-32}else return v===i.SET_B?x.shift()-32:(x.shift()-48)*10+x.shift()-48}},{key:"next",value:function(x,v,w){if(!x.length)return{result:"",checksum:0};var S=void 0,C=void 0;if(x[0]>=200){C=x.shift()-105;var q=i.SWAP[C];q!==void 0?S=d.next(x,v+1,q):((w===i.SET_A||w===i.SET_B)&&C===i.SHIFT&&(x[0]=w===i.SET_A?x[0]>95?x[0]-96:x[0]:x[0]<32?x[0]+96:x[0]),S=d.next(x,v+1,w))}else C=d.correctIndex(x,w),S=d.next(x,v+1,w);var B=d.getBar(C),ie=C*v;return{result:B+S.result,checksum:ie+S.checksum}}}]),d})(s.default);return pc.default=g,pc}var yc={},P1;function Rk(){if(P1)return yc;P1=1,Object.defineProperty(yc,"__esModule",{value:!0});var n=Ro(),t=function(y){return y.match(new RegExp("^"+n.A_CHARS+"*"))[0].length},s=function(y){return y.match(new RegExp("^"+n.B_CHARS+"*"))[0].length},i=function(y){return y.match(new RegExp("^"+n.C_CHARS+"*"))[0]};function o(m,y){var g=y?n.A_CHARS:n.B_CHARS,u=m.match(new RegExp("^("+g+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(u)return u[1]+"Ì"+c(m.substring(u[1].length));var d=m.match(new RegExp("^"+g+"+"))[0];return d.length===m.length?m:d+String.fromCharCode(y?205:206)+o(m.substring(d.length),!y)}function c(m){var y=i(m),g=y.length;if(g===m.length)return m;m=m.substring(g);var u=t(m)>=s(m);return y+String.fromCharCode(u?206:205)+o(m,u)}return yc.default=function(m){var y=void 0,g=i(m).length;if(g>=2)y=n.C_START_CHAR+c(m);else{var u=t(m)>s(m);y=(u?n.A_START_CHAR:n.B_START_CHAR)+o(m,u)}return y.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,b){return"Ë"+b})},yc}var U1;function Dk(){if(U1)return mc;U1=1,Object.defineProperty(mc,"__esModule",{value:!0});var n=Tu(),t=o(n),s=Rk(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){if(c(this,d),/^[\x00-\x7F\xC8-\xD3]+$/.test(b))var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,(0,i.default)(b),x));else var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x));return m(v)}return d})(t.default);return mc.default=g,mc}var gc={},z1;function Lk(){if(z1)return gc;z1=1,Object.defineProperty(gc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=Tu(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.A_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.A_CHARS+"+$").test(this.data)}}]),d})(s.default);return gc.default=g,gc}var bc={},I1;function qk(){if(I1)return bc;I1=1,Object.defineProperty(bc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=Tu(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.B_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.B_CHARS+"+$").test(this.data)}}]),d})(s.default);return bc.default=g,bc}var xc={},$1;function Bk(){if($1)return xc;$1=1,Object.defineProperty(xc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=Tu(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.C_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.C_CHARS+"+$").test(this.data)}}]),d})(s.default);return xc.default=g,xc}var H1;function Pk(){if(H1)return Kn;H1=1,Object.defineProperty(Kn,"__esModule",{value:!0}),Kn.CODE128C=Kn.CODE128B=Kn.CODE128A=Kn.CODE128=void 0;var n=Dk(),t=g(n),s=Lk(),i=g(s),o=qk(),c=g(o),m=Bk(),y=g(m);function g(u){return u&&u.__esModule?u:{default:u}}return Kn.CODE128=t.default,Kn.CODE128A=i.default,Kn.CODE128B=c.default,Kn.CODE128C=y.default,Kn}var Yt={},vc={},Tr={},F1;function Do(){return F1||(F1=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.SIDE_BIN="101",Tr.MIDDLE_BIN="01010",Tr.BINARIES={L:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],G:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],R:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],O:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],E:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"]},Tr.EAN2_STRUCTURE=["LL","LG","GL","GG"],Tr.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],Tr.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),Tr}var _c={},wc={},G1;function Lo(){if(G1)return wc;G1=1,Object.defineProperty(wc,"__esModule",{value:!0});var n=Do(),t=function(i,o,c){var m=i.split("").map(function(g,u){return n.BINARIES[o[u]]}).map(function(g,u){return g?g[i[u]]:""});if(c){var y=i.length-1;m=m.map(function(g,u){return u<y?g+c:g})}return m.join("")};return wc.default=t,wc}var V1;function _v(){if(V1)return _c;V1=1,Object.defineProperty(_c,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var w=0;w<v.length;w++){var S=v[w];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,w){return v&&b(x.prototype,v),w&&b(x,w),x}})(),t=Do(),s=Lo(),i=m(s),o=kn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function y(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,w){y(this,x);var S=g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,w));return S.fontSize=!w.flat&&w.fontSize>w.width*10?w.width*10:w.fontSize,S.guardHeight=w.height+S.fontSize/2+w.textMargin,S}return n(x,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(w,S){return this.text.substr(w,S)}},{key:"leftEncode",value:function(w,S){return(0,i.default)(w,S)}},{key:"rightText",value:function(w,S){return this.text.substr(w,S)}},{key:"rightEncode",value:function(w,S){return(0,i.default)(w,S)}},{key:"encodeGuarded",value:function(){var w={fontSize:this.fontSize},S={height:this.guardHeight};return[{data:t.SIDE_BIN,options:S},{data:this.leftEncode(),text:this.leftText(),options:w},{data:t.MIDDLE_BIN,options:S},{data:this.rightEncode(),text:this.rightText(),options:w},{data:t.SIDE_BIN,options:S}]}},{key:"encodeFlat",value:function(){var w=[t.SIDE_BIN,this.leftEncode(),t.MIDDLE_BIN,this.rightEncode(),t.SIDE_BIN];return{data:w.join(""),text:this.text}}}]),x})(c.default);return _c.default=d,_c}var Y1;function Uk(){if(Y1)return vc;Y1=1,Object.defineProperty(vc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var w=0;w<v.length;w++){var S=v[w];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,w){return v&&b(x.prototype,v),w&&b(x,w),x}})(),t=function b(x,v,w){x===null&&(x=Function.prototype);var S=Object.getOwnPropertyDescriptor(x,v);if(S===void 0){var C=Object.getPrototypeOf(x);return C===null?void 0:b(C,v,w)}else{if("value"in S)return S.value;var q=S.get;return q===void 0?void 0:q.call(w)}},s=Do(),i=_v(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function y(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=function(x){var v=x.substr(0,12).split("").map(function(w){return+w}).reduce(function(w,S,C){return C%2?w+S*3:w+S},0);return(10-v%10)%10},d=(function(b){g(x,b);function x(v,w){m(this,x),v.search(/^[0-9]{12}$/)!==-1&&(v+=u(v));var S=y(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,w));return S.lastChar=w.lastChar,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===u(this.data)}},{key:"leftText",value:function(){return t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var w=this.data.substr(1,6),S=s.EAN13_STRUCTURE[this.data[0]];return t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftEncode",this).call(this,w,S)}},{key:"rightText",value:function(){return t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var w=this.data.substr(7,6);return t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightEncode",this).call(this,w,"RRRRRR")}},{key:"encodeGuarded",value:function(){var w=t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(w.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(w.push({data:"00"}),w.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),w}}]),x})(o.default);return vc.default=d,vc}var Sc={},K1;function zk(){if(K1)return Sc;K1=1,Object.defineProperty(Sc,"__esModule",{value:!0});var n=(function(){function d(b,x){for(var v=0;v<x.length;v++){var w=x[v];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(b,w.key,w)}}return function(b,x,v){return x&&d(b.prototype,x),v&&d(b,v),b}})(),t=function d(b,x,v){b===null&&(b=Function.prototype);var w=Object.getOwnPropertyDescriptor(b,x);if(w===void 0){var S=Object.getPrototypeOf(b);return S===null?void 0:d(S,x,v)}else{if("value"in w)return w.value;var C=w.get;return C===void 0?void 0:C.call(v)}},s=_v(),i=o(s);function o(d){return d&&d.__esModule?d:{default:d}}function c(d,b){if(!(d instanceof b))throw new TypeError("Cannot call a class as a function")}function m(d,b){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:d}function y(d,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);d.prototype=Object.create(b&&b.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(d,b):d.__proto__=b)}var g=function(b){var x=b.substr(0,7).split("").map(function(v){return+v}).reduce(function(v,w,S){return S%2?v+w:v+w*3},0);return(10-x%10)%10},u=(function(d){y(b,d);function b(x,v){return c(this,b),x.search(/^[0-9]{7}$/)!==-1&&(x+=g(x)),m(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,x,v))}return n(b,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===g(this.data)}},{key:"leftText",value:function(){return t(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftText",this).call(this,0,4)}},{key:"leftEncode",value:function(){var v=this.data.substr(0,4);return t(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftEncode",this).call(this,v,"LLLL")}},{key:"rightText",value:function(){return t(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightText",this).call(this,4,4)}},{key:"rightEncode",value:function(){var v=this.data.substr(4,4);return t(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightEncode",this).call(this,v,"RRRR")}}]),b})(i.default);return Sc.default=u,Sc}var Ec={},J1;function Ik(){if(J1)return Ec;J1=1,Object.defineProperty(Ec,"__esModule",{value:!0});var n=(function(){function x(v,w){for(var S=0;S<w.length;S++){var C=w[S];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(v,C.key,C)}}return function(v,w,S){return w&&x(v.prototype,w),S&&x(v,S),v}})(),t=Do(),s=Lo(),i=m(s),o=kn(),c=m(o);function m(x){return x&&x.__esModule?x:{default:x}}function y(x,v){if(!(x instanceof v))throw new TypeError("Cannot call a class as a function")}function g(x,v){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:x}function u(x,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);x.prototype=Object.create(v&&v.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(x,v):x.__proto__=v)}var d=function(v){var w=v.split("").map(function(S){return+S}).reduce(function(S,C,q){return q%2?S+C*9:S+C*3},0);return w%10},b=(function(x){u(v,x);function v(w,S){return y(this,v),g(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,w,S))}return n(v,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var S=t.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,i.default)(this.data,S,"01"),text:this.text}}}]),v})(c.default);return Ec.default=b,Ec}var Oc={},X1;function $k(){if(X1)return Oc;X1=1,Object.defineProperty(Oc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var w=0;w<v.length;w++){var S=v[w];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,w){return v&&b(x.prototype,v),w&&b(x,w),x}})(),t=Do(),s=Lo(),i=m(s),o=kn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function y(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,w){return y(this,x),g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,w))}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var w=t.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,i.default)(this.data,w,"01"),text:this.text}}}]),x})(c.default);return Oc.default=d,Oc}var lo={},Q1;function wv(){if(Q1)return lo;Q1=1,Object.defineProperty(lo,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var w=0;w<v.length;w++){var S=v[w];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,w){return v&&b(x.prototype,v),w&&b(x,w),x}})();lo.checksum=d;var t=Lo(),s=c(t),i=kn(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function y(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=(function(b){g(x,b);function x(v,w){m(this,x),v.search(/^[0-9]{11}$/)!==-1&&(v+=d(v));var S=y(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,w));return S.displayValue=w.displayValue,w.fontSize>w.width*10?S.fontSize=w.width*10:S.fontSize=w.fontSize,S.guardHeight=w.height+S.fontSize/2+w.textMargin,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==d(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var w="";return w+="101",w+=(0,s.default)(this.data.substr(0,6),"LLLLLL"),w+="01010",w+=(0,s.default)(this.data.substr(6,6),"RRRRRR"),w+="101",{data:w,text:this.text}}},{key:"guardedEncoding",value:function(){var w=[];return this.displayValue&&w.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),w.push({data:"101"+(0,s.default)(this.data[0],"L"),options:{height:this.guardHeight}}),w.push({data:(0,s.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),w.push({data:"01010",options:{height:this.guardHeight}}),w.push({data:(0,s.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),w.push({data:(0,s.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&w.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),w}}]),x})(o.default);function d(b){var x=0,v;for(v=1;v<11;v+=2)x+=parseInt(b[v]);for(v=0;v<11;v+=2)x+=parseInt(b[v])*3;return(10-x%10)%10}return lo.default=u,lo}var Ac={},W1;function Hk(){if(W1)return Ac;W1=1,Object.defineProperty(Ac,"__esModule",{value:!0});var n=(function(){function w(S,C){for(var q=0;q<C.length;q++){var B=C[q];B.enumerable=B.enumerable||!1,B.configurable=!0,"value"in B&&(B.writable=!0),Object.defineProperty(S,B.key,B)}}return function(S,C,q){return C&&w(S.prototype,C),q&&w(S,q),S}})(),t=Lo(),s=m(t),i=kn(),o=m(i),c=wv();function m(w){return w&&w.__esModule?w:{default:w}}function y(w,S){if(!(w instanceof S))throw new TypeError("Cannot call a class as a function")}function g(w,S){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:w}function u(w,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);w.prototype=Object.create(S&&S.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(w,S):w.__proto__=S)}var d=["XX00000XXX","XX10000XXX","XX20000XXX","XXX00000XX","XXXX00000X","XXXXX00005","XXXXX00006","XXXXX00007","XXXXX00008","XXXXX00009"],b=[["EEEOOO","OOOEEE"],["EEOEOO","OOEOEE"],["EEOOEO","OOEEOE"],["EEOOOE","OOEEEO"],["EOEEOO","OEOOEE"],["EOOEEO","OEEOOE"],["EOOOEE","OEEEOO"],["EOEOEO","OEOEOE"],["EOEOOE","OEOEEO"],["EOOEOE","OEEOEO"]],x=(function(w){u(S,w);function S(C,q){y(this,S);var B=g(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,C,q));if(B.isValid=!1,C.search(/^[0-9]{6}$/)!==-1)B.middleDigits=C,B.upcA=v(C,"0"),B.text=q.text||""+B.upcA[0]+C+B.upcA[B.upcA.length-1],B.isValid=!0;else if(C.search(/^[01][0-9]{7}$/)!==-1)if(B.middleDigits=C.substring(1,C.length-1),B.upcA=v(B.middleDigits,C[0]),B.upcA[B.upcA.length-1]===C[C.length-1])B.isValid=!0;else return g(B);else return g(B);return B.displayValue=q.displayValue,q.fontSize>q.width*10?B.fontSize=q.width*10:B.fontSize=q.fontSize,B.guardHeight=q.height+B.fontSize/2+q.textMargin,B}return n(S,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var q="";return q+="101",q+=this.encodeMiddleDigits(),q+="010101",{data:q,text:this.text}}},{key:"guardedEncoding",value:function(){var q=[];return this.displayValue&&q.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),q.push({data:"101",options:{height:this.guardHeight}}),q.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),q.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&q.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),q}},{key:"encodeMiddleDigits",value:function(){var q=this.upcA[0],B=this.upcA[this.upcA.length-1],ie=b[parseInt(B)][parseInt(q)];return(0,s.default)(this.middleDigits,ie)}}]),S})(o.default);function v(w,S){for(var C=parseInt(w[w.length-1]),q=d[C],B="",ie=0,le=0;le<q.length;le++){var R=q[le];R==="X"?B+=w[ie++]:B+=R}return B=""+S+B,""+B+(0,c.checksum)(B)}return Ac.default=x,Ac}var Z1;function Fk(){if(Z1)return Yt;Z1=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.UPCE=Yt.UPC=Yt.EAN2=Yt.EAN5=Yt.EAN8=Yt.EAN13=void 0;var n=Uk(),t=x(n),s=zk(),i=x(s),o=Ik(),c=x(o),m=$k(),y=x(m),g=wv(),u=x(g),d=Hk(),b=x(d);function x(v){return v&&v.__esModule?v:{default:v}}return Yt.EAN13=t.default,Yt.EAN8=i.default,Yt.EAN5=c.default,Yt.EAN2=y.default,Yt.UPC=u.default,Yt.UPCE=b.default,Yt}var Ks={},jc={},Hi={},eb;function Gk(){return eb||(eb=1,Object.defineProperty(Hi,"__esModule",{value:!0}),Hi.START_BIN="1010",Hi.END_BIN="11101",Hi.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),Hi}var tb;function Sv(){if(tb)return jc;tb=1,Object.defineProperty(jc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=Gk(),s=kn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return n(d,[{key:"valid",value:function(){return this.data.search(/^([0-9]{2})+$/)!==-1}},{key:"encode",value:function(){var x=this,v=this.data.match(/.{2}/g).map(function(w){return x.encodePair(w)}).join("");return{data:t.START_BIN+v+t.END_BIN,text:this.text}}},{key:"encodePair",value:function(x){var v=t.BINARIES[x[1]];return t.BINARIES[x[0]].split("").map(function(w,S){return(w==="1"?"111":"1")+(v[S]==="1"?"000":"0")}).join("")}}]),d})(i.default);return jc.default=g,jc}var kc={},nb;function Vk(){if(nb)return kc;nb=1,Object.defineProperty(kc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=Sv(),s=i(t);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var y=function(d){var b=d.substr(0,13).split("").map(function(x){return parseInt(x,10)}).reduce(function(x,v,w){return x+v*(3-w%2*2)},0);return Math.ceil(b/10)*10-b},g=(function(u){m(d,u);function d(b,x){return o(this,d),b.search(/^[0-9]{13}$/)!==-1&&(b+=y(b)),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===y(this.data)}}]),d})(s.default);return kc.default=g,kc}var rb;function Yk(){if(rb)return Ks;rb=1,Object.defineProperty(Ks,"__esModule",{value:!0}),Ks.ITF14=Ks.ITF=void 0;var n=Sv(),t=o(n),s=Vk(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Ks.ITF=t.default,Ks.ITF14=i.default,Ks}var bn={},Nc={},sb;function qo(){if(sb)return Nc;sb=1,Object.defineProperty(Nc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=kn(),s=i(t);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var y=(function(u){m(d,u);function d(b,x){return o(this,d),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"encode",value:function(){for(var x="110",v=0;v<this.data.length;v++){var w=parseInt(this.data[v]),S=w.toString(2);S=g(S,4-S.length);for(var C=0;C<S.length;C++)x+=S[C]=="0"?"100":"110"}return x+="1001",{data:x,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),d})(s.default);function g(u,d){for(var b=0;b<d;b++)u="0"+u;return u}return Nc.default=y,Nc}var Tc={},co={},ib;function Cu(){if(ib)return co;ib=1,Object.defineProperty(co,"__esModule",{value:!0}),co.mod10=n,co.mod11=t;function n(s){for(var i=0,o=0;o<s.length;o++){var c=parseInt(s[o]);(o+s.length)%2===0?i+=c:i+=c*2%10+Math.floor(c*2/10)}return(10-i%10)%10}function t(s){for(var i=0,o=[2,3,4,5,6,7],c=0;c<s.length;c++){var m=parseInt(s[s.length-1-c]);i+=o[c%o.length]*m}return(11-i%11)%11}return co}var ab;function Kk(){if(ab)return Tc;ab=1,Object.defineProperty(Tc,"__esModule",{value:!0});var n=qo(),t=i(n),s=Cu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod10)(d),b))}return u})(t.default);return Tc.default=y,Tc}var Cc={},ob;function Jk(){if(ob)return Cc;ob=1,Object.defineProperty(Cc,"__esModule",{value:!0});var n=qo(),t=i(n),s=Cu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod11)(d),b))}return u})(t.default);return Cc.default=y,Cc}var Mc={},lb;function Xk(){if(lb)return Mc;lb=1,Object.defineProperty(Mc,"__esModule",{value:!0});var n=qo(),t=i(n),s=Cu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod10)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(t.default);return Mc.default=y,Mc}var Rc={},cb;function Qk(){if(cb)return Rc;cb=1,Object.defineProperty(Rc,"__esModule",{value:!0});var n=qo(),t=i(n),s=Cu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod11)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(t.default);return Rc.default=y,Rc}var ub;function Wk(){if(ub)return bn;ub=1,Object.defineProperty(bn,"__esModule",{value:!0}),bn.MSI1110=bn.MSI1010=bn.MSI11=bn.MSI10=bn.MSI=void 0;var n=qo(),t=d(n),s=Kk(),i=d(s),o=Jk(),c=d(o),m=Xk(),y=d(m),g=Qk(),u=d(g);function d(b){return b&&b.__esModule?b:{default:b}}return bn.MSI=t.default,bn.MSI10=i.default,bn.MSI11=c.default,bn.MSI1010=y.default,bn.MSI1110=u.default,bn}var uo={},fb;function Zk(){if(fb)return uo;fb=1,Object.defineProperty(uo,"__esModule",{value:!0}),uo.pharmacode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),t=kn(),s=i(t);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){o(this,u);var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b));return x.number=parseInt(d,10),x}return n(u,[{key:"encode",value:function(){for(var b=this.number,x="";!isNaN(b)&&b!=0;)b%2===0?(x="11100"+x,b=(b-2)/2):(x="100"+x,b=(b-1)/2);return x=x.slice(0,-2),{data:x,text:this.text}}},{key:"valid",value:function(){return this.number>=3&&this.number<=131070}}]),u})(s.default);return uo.pharmacode=y,uo}var fo={},hb;function eN(){if(hb)return fo;hb=1,Object.defineProperty(fo,"__esModule",{value:!0}),fo.codabar=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),t=kn(),s=i(t);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){o(this,u),d.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(d="A"+d+"A");var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d.toUpperCase(),b));return x.text=x.options.text||x.text.replace(/[A-D]/g,""),x}return n(u,[{key:"valid",value:function(){return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)!==-1}},{key:"encode",value:function(){for(var b=[],x=this.getEncodings(),v=0;v<this.data.length;v++)b.push(x[this.data.charAt(v)]),v!==this.data.length-1&&b.push("0");return{text:this.text,data:b.join("")}}},{key:"getEncodings",value:function(){return{0:"101010011",1:"101011001",2:"101001011",3:"110010101",4:"101101001",5:"110101001",6:"100101011",7:"100101101",8:"100110101",9:"110100101","-":"101001101",$:"101100101",":":"1101011011","/":"1101101011",".":"1101101101","+":"1011011011",A:"1011001001",B:"1001001011",C:"1010010011",D:"1010011001"}}}]),u})(s.default);return fo.codabar=y,fo}var Js={},Dc={},Fi={},db;function tN(){return db||(db=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.SYMBOLS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],Fi.BINARIES=["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010","101011110"],Fi.MULTI_SYMBOLS={"\0":["(%)","U"],"":["($)","A"],"":["($)","B"],"":["($)","C"],"":["($)","D"],"":["($)","E"],"":["($)","F"],"\x07":["($)","G"],"\b":["($)","H"]," ":["($)","I"],"\n":["($)","J"],"\v":["($)","K"],"\f":["($)","L"],"\r":["($)","M"],"":["($)","N"],"":["($)","O"],"":["($)","P"],"":["($)","Q"],"":["($)","R"],"":["($)","S"],"":["($)","T"],"":["($)","U"],"":["($)","V"],"":["($)","W"],"":["($)","X"],"":["($)","Y"],"":["($)","Z"],"\x1B":["(%)","A"],"":["(%)","B"],"":["(%)","C"],"":["(%)","D"],"":["(%)","E"],"!":["(/)","A"],'"':["(/)","B"],"#":["(/)","C"],"&":["(/)","F"],"'":["(/)","G"],"(":["(/)","H"],")":["(/)","I"],"*":["(/)","J"],",":["(/)","L"],":":["(/)","Z"],";":["(%)","F"],"<":["(%)","G"],"=":["(%)","H"],">":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),Fi}var mb;function Ev(){if(mb)return Dc;mb=1,Object.defineProperty(Dc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=tN(),s=kn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.data.split("").flatMap(function(C){return t.MULTI_SYMBOLS[C]||C}),v=x.map(function(C){return d.getEncoding(C)}).join(""),w=d.checksum(x,20),S=d.checksum(x.concat(w),15);return{text:this.text,data:d.getEncoding("ÿ")+v+d.getEncoding(w)+d.getEncoding(S)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(x){return t.BINARIES[d.symbolValue(x)]}},{key:"getSymbol",value:function(x){return t.SYMBOLS[x]}},{key:"symbolValue",value:function(x){return t.SYMBOLS.indexOf(x)}},{key:"checksum",value:function(x,v){var w=x.slice().reverse().reduce(function(S,C,q){var B=q%v+1;return S+d.symbolValue(C)*B},0);return d.getSymbol(w%47)}}]),d})(i.default);return Dc.default=g,Dc}var Lc={},pb;function nN(){if(pb)return Lc;pb=1,Object.defineProperty(Lc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),t=Ev(),s=i(t);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),u})(s.default);return Lc.default=y,Lc}var yb;function rN(){if(yb)return Js;yb=1,Object.defineProperty(Js,"__esModule",{value:!0}),Js.CODE93FullASCII=Js.CODE93=void 0;var n=Ev(),t=o(n),s=nN(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Js.CODE93=t.default,Js.CODE93FullASCII=i.default,Js}var ho={},gb;function sN(){if(gb)return ho;gb=1,Object.defineProperty(ho,"__esModule",{value:!0}),ho.GenericBarcode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),t=kn(),s=i(t);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),u})(s.default);return ho.GenericBarcode=y,ho}var bb;function iN(){if(bb)return hc;bb=1,Object.defineProperty(hc,"__esModule",{value:!0});var n=Mk(),t=Pk(),s=Fk(),i=Yk(),o=Wk(),c=Zk(),m=eN(),y=rN(),g=sN();return hc.default={CODE39:n.CODE39,CODE128:t.CODE128,CODE128A:t.CODE128A,CODE128B:t.CODE128B,CODE128C:t.CODE128C,EAN13:s.EAN13,EAN8:s.EAN8,EAN5:s.EAN5,EAN2:s.EAN2,UPC:s.UPC,UPCE:s.UPCE,ITF14:i.ITF14,ITF:i.ITF,MSI:o.MSI,MSI10:o.MSI10,MSI11:o.MSI11,MSI1010:o.MSI1010,MSI1110:o.MSI1110,pharmacode:c.pharmacode,codabar:m.codabar,CODE93:y.CODE93,CODE93FullASCII:y.CODE93FullASCII,GenericBarcode:g.GenericBarcode},hc}var qc={},xb;function Mu(){if(xb)return qc;xb=1,Object.defineProperty(qc,"__esModule",{value:!0});var n=Object.assign||function(t){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t};return qc.default=function(t,s){return n({},t,s)},qc}var Bc={},vb;function aN(){if(vb)return Bc;vb=1,Object.defineProperty(Bc,"__esModule",{value:!0}),Bc.default=n;function n(t){var s=[];function i(o){if(Array.isArray(o))for(var c=0;c<o.length;c++)i(o[c]);else o.text=o.text||"",o.data=o.data||"",s.push(o)}return i(t),s}return Bc}var Pc={},_b;function oN(){if(_b)return Pc;_b=1,Object.defineProperty(Pc,"__esModule",{value:!0}),Pc.default=n;function n(t){return t.marginTop=t.marginTop||t.margin,t.marginBottom=t.marginBottom||t.margin,t.marginRight=t.marginRight||t.margin,t.marginLeft=t.marginLeft||t.margin,t}return Pc}var Uc={},zc={},Ic={},wb;function Ov(){if(wb)return Ic;wb=1,Object.defineProperty(Ic,"__esModule",{value:!0}),Ic.default=n;function n(t){var s=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var i in s)s.hasOwnProperty(i)&&(i=s[i],typeof t[i]=="string"&&(t[i]=parseInt(t[i],10)));return typeof t.displayValue=="string"&&(t.displayValue=t.displayValue!="false"),t}return Ic}var $c={},Sb;function Av(){if(Sb)return $c;Sb=1,Object.defineProperty($c,"__esModule",{value:!0});var n={width:2,height:100,format:"auto",displayValue:!0,fontOptions:"",font:"monospace",text:void 0,textAlign:"center",textPosition:"bottom",textMargin:2,fontSize:20,background:"#ffffff",lineColor:"#000000",margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}};return $c.default=n,$c}var Eb;function lN(){if(Eb)return zc;Eb=1,Object.defineProperty(zc,"__esModule",{value:!0});var n=Ov(),t=o(n),s=Av(),i=o(s);function o(m){return m&&m.__esModule?m:{default:m}}function c(m){var y={};for(var g in i.default)i.default.hasOwnProperty(g)&&(m.hasAttribute("jsbarcode-"+g.toLowerCase())&&(y[g]=m.getAttribute("jsbarcode-"+g.toLowerCase())),m.hasAttribute("data-"+g.toLowerCase())&&(y[g]=m.getAttribute("data-"+g.toLowerCase())));return y.value=m.getAttribute("jsbarcode-value")||m.getAttribute("data-value"),y=(0,t.default)(y),y}return zc.default=c,zc}var Hc={},Fc={},xn={},Ob;function jv(){if(Ob)return xn;Ob=1,Object.defineProperty(xn,"__esModule",{value:!0}),xn.getTotalWidthOfEncodings=xn.calculateEncodingAttributes=xn.getBarcodePadding=xn.getEncodingHeight=xn.getMaximumHeightOfEncodings=void 0;var n=Mu(),t=s(n);function s(u){return u&&u.__esModule?u:{default:u}}function i(u,d){return d.height+(d.displayValue&&u.text.length>0?d.fontSize+d.textMargin:0)+d.marginTop+d.marginBottom}function o(u,d,b){if(b.displayValue&&d<u){if(b.textAlign=="center")return Math.floor((u-d)/2);if(b.textAlign=="left")return 0;if(b.textAlign=="right")return Math.floor(u-d)}return 0}function c(u,d,b){for(var x=0;x<u.length;x++){var v=u[x],w=(0,t.default)(d,v.options),S;w.displayValue?S=g(v.text,w,b):S=0;var C=v.data.length*w.width;v.width=Math.ceil(Math.max(S,C)),v.height=i(v,w),v.barcodePadding=o(S,C,w)}}function m(u){for(var d=0,b=0;b<u.length;b++)d+=u[b].width;return d}function y(u){for(var d=0,b=0;b<u.length;b++)u[b].height>d&&(d=u[b].height);return d}function g(u,d,b){var x;if(b)x=b;else if(typeof document<"u")x=document.createElement("canvas").getContext("2d");else return 0;x.font=d.fontOptions+" "+d.fontSize+"px "+d.font;var v=x.measureText(u);if(!v)return 0;var w=v.width;return w}return xn.getMaximumHeightOfEncodings=y,xn.getEncodingHeight=i,xn.getBarcodePadding=o,xn.calculateEncodingAttributes=c,xn.getTotalWidthOfEncodings=m,xn}var Ab;function cN(){if(Ab)return Fc;Ab=1,Object.defineProperty(Fc,"__esModule",{value:!0});var n=(function(){function y(g,u){for(var d=0;d<u.length;d++){var b=u[d];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}return function(g,u,d){return u&&y(g.prototype,u),d&&y(g,d),g}})(),t=Mu(),s=o(t),i=jv();function o(y){return y&&y.__esModule?y:{default:y}}function c(y,g){if(!(y instanceof g))throw new TypeError("Cannot call a class as a function")}var m=(function(){function y(g,u,d){c(this,y),this.canvas=g,this.encodings=u,this.options=d}return n(y,[{key:"render",value:function(){if(!this.canvas.getContext)throw new Error("The browser does not support canvas.");this.prepareCanvas();for(var u=0;u<this.encodings.length;u++){var d=(0,s.default)(this.options,this.encodings[u].options);this.drawCanvasBarcode(d,this.encodings[u]),this.drawCanvasText(d,this.encodings[u]),this.moveCanvasDrawing(this.encodings[u])}this.restoreCanvas()}},{key:"prepareCanvas",value:function(){var u=this.canvas.getContext("2d");u.save(),(0,i.calculateEncodingAttributes)(this.encodings,this.options,u);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=d+this.options.marginLeft+this.options.marginRight,this.canvas.height=b,u.clearRect(0,0,this.canvas.width,this.canvas.height),this.options.background&&(u.fillStyle=this.options.background,u.fillRect(0,0,this.canvas.width,this.canvas.height)),u.translate(this.options.marginLeft,0)}},{key:"drawCanvasBarcode",value:function(u,d){var b=this.canvas.getContext("2d"),x=d.data,v;u.textPosition=="top"?v=u.marginTop+u.fontSize+u.textMargin:v=u.marginTop,b.fillStyle=u.lineColor;for(var w=0;w<x.length;w++){var S=w*u.width+d.barcodePadding;x[w]==="1"?b.fillRect(S,v,u.width,u.height):x[w]&&b.fillRect(S,v,u.width,u.height*x[w])}}},{key:"drawCanvasText",value:function(u,d){var b=this.canvas.getContext("2d"),x=u.fontOptions+" "+u.fontSize+"px "+u.font;if(u.displayValue){var v,w;u.textPosition=="top"?w=u.marginTop+u.fontSize-u.textMargin:w=u.height+u.textMargin+u.marginTop+u.fontSize,b.font=x,u.textAlign=="left"||d.barcodePadding>0?(v=0,b.textAlign="left"):u.textAlign=="right"?(v=d.width-1,b.textAlign="right"):(v=d.width/2,b.textAlign="center"),b.fillText(d.text,v,w)}}},{key:"moveCanvasDrawing",value:function(u){var d=this.canvas.getContext("2d");d.translate(u.width,0)}},{key:"restoreCanvas",value:function(){var u=this.canvas.getContext("2d");u.restore()}}]),y})();return Fc.default=m,Fc}var Gc={},jb;function uN(){if(jb)return Gc;jb=1,Object.defineProperty(Gc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),t=Mu(),s=o(t),i=jv();function o(g){return g&&g.__esModule?g:{default:g}}function c(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}var m="http://www.w3.org/2000/svg",y=(function(){function g(u,d,b){c(this,g),this.svg=u,this.encodings=d,this.options=b,this.document=b.xmlDocument||document}return n(g,[{key:"render",value:function(){var d=this.options.marginLeft;this.prepareSVG();for(var b=0;b<this.encodings.length;b++){var x=this.encodings[b],v=(0,s.default)(this.options,x.options),w=this.createGroup(d,v.marginTop,this.svg);this.setGroupOptions(w,v),this.drawSvgBarcode(w,v,x),this.drawSVGText(w,v,x),d+=x.width}}},{key:"prepareSVG",value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,i.calculateEncodingAttributes)(this.encodings,this.options);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings),x=d+this.options.marginLeft+this.options.marginRight;this.setSvgAttributes(x,b),this.options.background&&this.drawRect(0,0,x,b,this.svg).setAttribute("fill",this.options.background)}},{key:"drawSvgBarcode",value:function(d,b,x){var v=x.data,w;b.textPosition=="top"?w=b.fontSize+b.textMargin:w=0;for(var S=0,C=0,q=0;q<v.length;q++)C=q*b.width+x.barcodePadding,v[q]==="1"?S++:S>0&&(this.drawRect(C-b.width*S,w,b.width*S,b.height,d),S=0);S>0&&this.drawRect(C-b.width*(S-1),w,b.width*S,b.height,d)}},{key:"drawSVGText",value:function(d,b,x){var v=this.document.createElementNS(m,"text");if(b.displayValue){var w,S;v.setAttribute("font-family",b.font),v.setAttribute("font-size",b.fontSize),b.fontOptions.includes("bold")&&v.setAttribute("font-weight","bold"),b.fontOptions.includes("italic")&&v.setAttribute("font-style","italic"),b.textPosition=="top"?S=b.fontSize-b.textMargin:S=b.height+b.textMargin+b.fontSize,b.textAlign=="left"||x.barcodePadding>0?(w=0,v.setAttribute("text-anchor","start")):b.textAlign=="right"?(w=x.width-1,v.setAttribute("text-anchor","end")):(w=x.width/2,v.setAttribute("text-anchor","middle")),v.setAttribute("x",w),v.setAttribute("y",S),v.appendChild(this.document.createTextNode(x.text)),d.appendChild(v)}}},{key:"setSvgAttributes",value:function(d,b){var x=this.svg;x.setAttribute("width",d+"px"),x.setAttribute("height",b+"px"),x.setAttribute("x","0px"),x.setAttribute("y","0px"),x.setAttribute("viewBox","0 0 "+d+" "+b),x.setAttribute("xmlns",m),x.setAttribute("version","1.1")}},{key:"createGroup",value:function(d,b,x){var v=this.document.createElementNS(m,"g");return v.setAttribute("transform","translate("+d+", "+b+")"),x.appendChild(v),v}},{key:"setGroupOptions",value:function(d,b){d.setAttribute("fill",b.lineColor)}},{key:"drawRect",value:function(d,b,x,v,w){var S=this.document.createElementNS(m,"rect");return S.setAttribute("x",d),S.setAttribute("y",b),S.setAttribute("width",x),S.setAttribute("height",v),w.appendChild(S),S}}]),g})();return Gc.default=y,Gc}var Vc={},kb;function fN(){if(kb)return Vc;kb=1,Object.defineProperty(Vc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var y=c[m];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(o,y.key,y)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function t(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o,c,m){t(this,i),this.object=o,this.encodings=c,this.options=m}return n(i,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),i})();return Vc.default=s,Vc}var Nb;function hN(){if(Nb)return Hc;Nb=1,Object.defineProperty(Hc,"__esModule",{value:!0});var n=cN(),t=m(n),s=uN(),i=m(s),o=fN(),c=m(o);function m(y){return y&&y.__esModule?y:{default:y}}return Hc.default={CanvasRenderer:t.default,SVGRenderer:i.default,ObjectRenderer:c.default},Hc}var Gi={},Tb;function kv(){if(Tb)return Gi;Tb=1,Object.defineProperty(Gi,"__esModule",{value:!0});function n(m,y){if(!(m instanceof y))throw new TypeError("Cannot call a class as a function")}function t(m,y){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y&&(typeof y=="object"||typeof y=="function")?y:m}function s(m,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);m.prototype=Object.create(y&&y.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(m,y):m.__proto__=y)}var i=(function(m){s(y,m);function y(g,u){n(this,y);var d=t(this,(y.__proto__||Object.getPrototypeOf(y)).call(this));return d.name="InvalidInputException",d.symbology=g,d.input=u,d.message='"'+d.input+'" is not a valid input for '+d.symbology,d}return y})(Error),o=(function(m){s(y,m);function y(){n(this,y);var g=t(this,(y.__proto__||Object.getPrototypeOf(y)).call(this));return g.name="InvalidElementException",g.message="Not supported type to render on",g}return y})(Error),c=(function(m){s(y,m);function y(){n(this,y);var g=t(this,(y.__proto__||Object.getPrototypeOf(y)).call(this));return g.name="NoElementException",g.message="No element to render on.",g}return y})(Error);return Gi.InvalidInputException=i,Gi.InvalidElementException=o,Gi.NoElementException=c,Gi}var Cb;function dN(){if(Cb)return Uc;Cb=1,Object.defineProperty(Uc,"__esModule",{value:!0});var n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},t=lN(),s=m(t),i=hN(),o=m(i),c=kv();function m(d){return d&&d.__esModule?d:{default:d}}function y(d){if(typeof d=="string")return g(d);if(Array.isArray(d)){for(var b=[],x=0;x<d.length;x++)b.push(y(d[x]));return b}else{if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLImageElement)return u(d);if(d&&d.nodeName&&d.nodeName.toLowerCase()==="svg"||typeof SVGElement<"u"&&d instanceof SVGElement)return{element:d,options:(0,s.default)(d),renderer:o.default.SVGRenderer};if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement)return{element:d,options:(0,s.default)(d),renderer:o.default.CanvasRenderer};if(d&&d.getContext)return{element:d,renderer:o.default.CanvasRenderer};if(d&&(typeof d>"u"?"undefined":n(d))==="object"&&!d.nodeName)return{element:d,renderer:o.default.ObjectRenderer};throw new c.InvalidElementException}}function g(d){var b=document.querySelectorAll(d);if(b.length!==0){for(var x=[],v=0;v<b.length;v++)x.push(y(b[v]));return x}}function u(d){var b=document.createElement("canvas");return{element:b,options:(0,s.default)(d),renderer:o.default.CanvasRenderer,afterRender:function(){d.setAttribute("src",b.toDataURL())}}}return Uc.default=y,Uc}var Yc={},Mb;function mN(){if(Mb)return Yc;Mb=1,Object.defineProperty(Yc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var y=c[m];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(o,y.key,y)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function t(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o){t(this,i),this.api=o}return n(i,[{key:"handleCatch",value:function(c){if(c.name==="InvalidInputException")if(this.api._options.valid!==this.api._defaults.valid)this.api._options.valid(!1);else throw c.message;else throw c;this.api.render=function(){}}},{key:"wrapBarcodeCall",value:function(c){try{var m=c.apply(void 0,arguments);return this.api._options.valid(!0),m}catch(y){return this.handleCatch(y),this.api}}}]),i})();return Yc.default=s,Yc}var ld,Rb;function pN(){if(Rb)return ld;Rb=1;var n=iN(),t=q(n),s=Mu(),i=q(s),o=aN(),c=q(o),m=oN(),y=q(m),g=dN(),u=q(g),d=Ov(),b=q(d),x=mN(),v=q(x),w=kv(),S=Av(),C=q(S);function q(I){return I&&I.__esModule?I:{default:I}}var B=function(){},ie=function(D,Q,X){var he=new B;if(typeof D>"u")throw Error("No element to render on was provided.");return he._renderProperties=(0,u.default)(D),he._encodings=[],he._options=C.default,he._errorHandler=new v.default(he),typeof Q<"u"&&(X=X||{},X.format||(X.format=ne()),he.options(X)[X.format](Q,X).render()),he};ie.getModule=function(I){return t.default[I]};for(var le in t.default)t.default.hasOwnProperty(le)&&R(t.default,le);function R(I,D){B.prototype[D]=B.prototype[D.toUpperCase()]=B.prototype[D.toLowerCase()]=function(Q,X){var he=this;return he._errorHandler.wrapBarcodeCall(function(){X.text=typeof X.text>"u"?void 0:""+X.text;var Se=(0,i.default)(he._options,X);Se=(0,b.default)(Se);var ke=I[D],H=$(Q,ke,Se);return he._encodings.push(H),he})}}function $(I,D,Q){I=""+I;var X=new D(I,Q);if(!X.valid())throw new w.InvalidInputException(X.constructor.name,I);var he=X.encode();he=(0,c.default)(he);for(var Se=0;Se<he.length;Se++)he[Se].options=(0,i.default)(Q,he[Se].options);return he}function ne(){return t.default.CODE128?"CODE128":Object.keys(t.default)[0]}B.prototype.options=function(I){return this._options=(0,i.default)(this._options,I),this},B.prototype.blank=function(I){var D=new Array(I+1).join("0");return this._encodings.push({data:D}),this},B.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var I;for(var D in this._renderProperties){I=this._renderProperties[D];var Q=(0,i.default)(this._options,I.options);Q.format=="auto"&&(Q.format=ne()),this._errorHandler.wrapBarcodeCall(function(){var X=Q.value,he=t.default[Q.format.toUpperCase()],Se=$(X,he,Q);V(I,Se,Q)})}}},B.prototype.render=function(){if(!this._renderProperties)throw new w.NoElementException;if(Array.isArray(this._renderProperties))for(var I=0;I<this._renderProperties.length;I++)V(this._renderProperties[I],this._encodings,this._options);else V(this._renderProperties,this._encodings,this._options);return this},B.prototype._defaults=C.default;function V(I,D,Q){D=(0,c.default)(D);for(var X=0;X<D.length;X++)D[X].options=(0,i.default)(Q,D[X].options),(0,y.default)(D[X].options);(0,y.default)(Q);var he=I.renderer,Se=new he(I.element,D,Q);Se.render(),I.afterRender&&I.afterRender()}return typeof window<"u"&&(window.JsBarcode=ie),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(I,D){var Q=[];return jQuery(this).each(function(){Q.push(this)}),ie(Q,I,D)}),ld=ie,ld}var yN=pN();const gN=nS(yN),bN={[Ae.EXECUTED]:"Executed",[Ae.MATCHED_LIST]:"Matched list",[Ae.CONFIRM_REQUIRED]:"Awaiting confirmation",[Ae.NO_MATCH_FALLBACK]:"No match",[Ae.UNCONFIGURED]:"Not configured",[Ae.INVALID_CODE]:"Invalid code",[Ae.FORBIDDEN]:"Not permitted",[Ae.CONFLICT]:"Conflict",[Ae.IDENTITY_PRIMED]:"Identity primed",[Ae.IDENTITY_UNKNOWN]:"Badge not recognized",[Ae.NOT_PRIMED]:"Badge required",[Ae.CHOICES]:"Choices presented",[Ae.NO_OPEN_CONTAINER]:"Container closing, scan again",[Ae.HELD]:"Holding",[Ae.REFUSED]:"Not placed",[Ae.SUBJECT_STALE]:"Scan it again"},xN={[Ae.EXECUTED]:"text-status-success",[Ae.MATCHED_LIST]:"text-status-success",[Ae.CONFIRM_REQUIRED]:"text-status-warning",[Ae.NO_MATCH_FALLBACK]:"text-text-secondary",[Ae.UNCONFIGURED]:"text-status-warning",[Ae.INVALID_CODE]:"text-status-error",[Ae.FORBIDDEN]:"text-status-error",[Ae.CONFLICT]:"text-status-warning",[Ae.IDENTITY_PRIMED]:"text-status-success",[Ae.IDENTITY_UNKNOWN]:"text-status-warning",[Ae.NOT_PRIMED]:"text-status-warning",[Ae.CHOICES]:"text-status-success",[Ae.NO_OPEN_CONTAINER]:"text-status-warning",[Ae.HELD]:"text-status-success",[Ae.REFUSED]:"text-status-error",[Ae.SUBJECT_STALE]:"text-status-warning"};function vN(n){return n.outcome===Ae.IDENTITY_PRIMED&&n.actor?`Hi ${n.actor.displayName}`:`${bN[n.outcome]}${n.rule?` — ${n.rule.name}`:""}`}function Db(n){var t,s,i,o,c,m,y;return n.outcome===Ae.NO_MATCH_FALLBACK?((t=n.fallback)==null?void 0:t.markdown)??null:n.outcome===Ae.IDENTITY_UNKNOWN?((s=n.fallback)==null?void 0:s.markdown)??null:n.outcome===Ae.NOT_PRIMED?((i=n.notPrimed)==null?void 0:i.markdown)??null:n.outcome===Ae.NO_OPEN_CONTAINER?((o=n.fallback)==null?void 0:o.markdown)??null:n.outcome===Ae.REFUSED?((c=n.refusal)==null?void 0:c.markdown)??n.error??null:n.outcome===Ae.HELD?((y=(m=n.subject)==null?void 0:m.expect)==null?void 0:y.prompt)??null:n.outcome===Ae.SUBJECT_STALE?n.error??null:null}function ys(n){return n.replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 bg-surface-sunken rounded text-xs font-mono">$1</code>').replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent-primary hover:underline" target="_blank" rel="noopener noreferrer">$1</a>')}function _N({content:n,compact:t,inherit:s}){const i=[],o=/^```(\w*)\n([\s\S]*?)^```$/gm;let c=0,m;for(;(m=o.exec(n))!==null;)m.index>c&&i.push({type:"text",text:n.slice(c,m.index)}),i.push({type:"code",lang:m[1],code:m[2].replace(/\n$/,"")}),c=m.index+m[0].length;c<n.length&&i.push({type:"text",text:n.slice(c)});const y=s?{text:"",heading:"",list:"",code:"text-[0.85em]",tone:""}:t?{text:"text-xs",heading:"text-xs",list:"text-xs",code:"text-2xs",tone:"text-text-secondary"}:{text:"text-sm",heading:"text-sm",list:"text-sm",code:"text-xs",tone:"text-text-secondary"},g=[];for(const u of i){if(u.type==="code"){const d=u.code.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");g.push(`<pre class="my-2 p-2.5 bg-surface-sunken rounded-md overflow-x-auto"><code class="${y.code} font-mono text-text-secondary leading-relaxed">${d}</code></pre>`);continue}g.push(...wN(u.text,y))}return h.jsx("div",{className:s?void 0:"prose-sm",dangerouslySetInnerHTML:{__html:g.join(`
55
- `)}})}function wN(n,t){const s=n.split(`
56
- `),i=[];let o=!1,c=!1,m=[];for(const y of s){const g=y.trim();if(g.startsWith("|")&&g.endsWith("|")){const u=g.slice(1,-1).split("|").map(d=>d.trim());if(u.every(d=>/^[-:]+$/.test(d)))continue;c||(c=!0,m=[]),m.push(u);continue}if(c){c=!1;const[u,...d]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const b of u)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${ys(b)}</th>`);i.push("</tr></thead><tbody>");for(const b of d){i.push("<tr>");for(const x of b)i.push(`<td class="py-1 px-2 border-b border-border/50">${ys(x)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>"),m=[]}if(!g){o&&(i.push("</ul>"),o=!1);continue}if(g.startsWith("### ")){o&&(i.push("</ul>"),o=!1),i.push(`<h4 class="${t.heading} font-semibold text-text-primary mt-3 mb-1">${ys(g.slice(4))}</h4>`);continue}if(g.startsWith("## ")){o&&(i.push("</ul>"),o=!1),i.push(`<h3 class="${t.heading} font-semibold text-text-primary mt-3 mb-1">${ys(g.slice(3))}</h3>`);continue}if(/^[-*_]{3,}$/.test(g)){o&&(i.push("</ul>"),o=!1),i.push('<hr class="border-border my-3" />');continue}if(/^[-*] /.test(g)){o||(i.push('<ul class="space-y-1 my-1">'),o=!0),i.push(`<li class="${t.list} ${t.tone} flex gap-2"><span class="text-text-tertiary shrink-0">-</span><span>${ys(g.slice(2))}</span></li>`);continue}o&&(i.push("</ul>"),o=!1),i.push(`<p class="${t.text} ${t.tone} my-1">${ys(g)}</p>`)}if(c&&m.length){const[y,...g]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const u of y)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${ys(u)}</th>`);i.push("</tr></thead><tbody>");for(const u of g){i.push("<tr>");for(const d of u)i.push(`<td class="py-1 px-2 border-b border-border/50">${ys(d)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>")}return o&&i.push("</ul>"),i}function Bm({result:n,compact:t=!1}){const{response:s}=n,i=t?"text-xs":"text-sm";return h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:`${i} font-mono text-text-secondary truncate`,children:n.code}),s?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:`${i} font-medium ${xN[s.outcome]}`,children:vN(s)}),s.error&&h.jsx("div",{className:"text-xs text-text-tertiary mt-0.5",children:s.error}),Db(s)&&h.jsx("div",{className:"text-xs text-text-secondary mt-1.5",children:h.jsx(_N,{content:Db(s),compact:!0})})]}):h.jsx("div",{className:`${i} text-status-error`,children:n.error})]})}function Nv(n){return n.replace(/[\u2010-\u2015\u2212]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u00A0/g," ").replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\x00-\x1F\x7F]/g,"").trim()}function SN(n){const t=new Set;for(const s of n){const i=s.codePointAt(0);(i>127||i<32)&&t.add(`"${i<32?"\\x"+i.toString(16).padStart(2,"0"):s}" U+${i.toString(16).toUpperCase().padStart(4,"0")}`)}return[...t]}function EN({value:n}){const t=E.useRef(null),[s,i]=E.useState(!1);return E.useEffect(()=>{if(!(!t.current||!n))try{gN(t.current,n,{format:"CODE128",width:2,height:88,margin:12,displayValue:!0,fontSize:13,background:"#ffffff",lineColor:"#000000"}),i(!1)}catch{i(!0)}},[n]),n?h.jsxs("div",{children:[h.jsx("span",{className:"block text-xs uppercase tracking-wide text-text-tertiary mb-1",children:"Barcode"}),s?h.jsxs("p",{className:"text-xs text-status-error",children:["This value has characters Code 128 cannot carry:"," ",h.jsx("span",{className:"font-mono",children:SN(n).join(", ")||"unknown"})]}):h.jsx("div",{className:"bg-white rounded p-1 inline-block max-w-full overflow-hidden",children:h.jsx("svg",{ref:t,className:"max-w-full"})})]}):null}function ON({onClose:n}){const{submitCode:t,lastResult:s,busy:i,wedgeConfig:o,updateWedgeConfig:c,diagnostics:m,diagnosticsOn:y,setDiagnosticsOn:g}=qm(),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=w=>{w.preventDefault();const S=u.trim();S&&(d(""),t(S))};return h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[h.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-text-primary",children:[h.jsx(No,{className:"w-4 h-4"}),"Scan"]}),h.jsx("button",{type:"button",onClick:n,className:"text-text-tertiary hover:text-text-primary",title:"Close",children:h.jsx(Wt,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-6",children:[h.jsxs("form",{onSubmit:v,className:"space-y-2",children:[h.jsx("label",{className:"block text-xs uppercase tracking-wide text-text-tertiary",children:"Enter a code"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{value:u,onChange:w=>d(Nv(w.target.value)),placeholder:"10:1:SN-12345",className:"flex-1 px-2 py-1.5 text-sm bg-surface-raised border border-surface-border rounded text-text-primary","data-scan-manual-entry":!0}),h.jsx("button",{type:"submit",disabled:i||!u.trim(),className:"px-3 py-1.5 text-sm rounded bg-accent text-text-inverse disabled:opacity-50",children:"Go"})]}),h.jsx("p",{className:"text-xs text-text-tertiary",children:"Scanning with a connected scanner works from any page — this entry exists for testing and for codes you can read but not scan. Typing here also draws the code below; point the scanner at the screen to fire it for real."})]}),h.jsx(EN,{value:u.trim()}),s&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("div",{className:"text-xs uppercase tracking-wide text-text-tertiary",children:"Last scan"}),h.jsx(Bm,{result:s})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("button",{type:"button",onClick:()=>x(w=>!w),className:"text-xs uppercase tracking-wide text-text-tertiary hover:text-text-primary",children:["Capture settings ",b?"▾":"▸"]}),b&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block text-sm text-text-primary",children:[h.jsx("span",{className:"block text-xs text-text-tertiary mb-1",children:"Key gap limit (ms) — a longer pause between keys starts a new capture; raise it for scanners that pace slowly"}),h.jsx("input",{type:"number",min:100,max:2e3,step:50,value:o.maxKeyGapMs,onChange:w=>c({maxKeyGapMs:Number(w.target.value)}),className:"w-24 px-2 py-1 text-sm bg-surface-raised border border-surface-border rounded"})]}),h.jsxs("label",{className:"flex items-center gap-2 text-sm text-text-primary",children:[h.jsx("input",{type:"checkbox",checked:y,onChange:w=>g(w.target.checked)}),h.jsx("span",{children:"Diagnostics — trace every keydown the capture sees (also logged to the console)"})]}),y&&h.jsxs("div",{className:"border border-surface-border rounded",children:[h.jsx("div",{className:"px-2 py-1.5 text-2xs uppercase tracking-wide text-text-tertiary border-b border-surface-border",children:"Keydown trace — scan now, newest last"}),h.jsxs("div",{className:"max-h-64 overflow-y-auto font-mono text-2xs leading-5 px-2 py-1",children:[m.length===0&&h.jsx("div",{className:"text-text-tertiary",children:"Waiting for keys…"}),m.map(w=>h.jsxs("div",{className:"whitespace-nowrap overflow-hidden text-ellipsis",title:`buffer: ${w.buffer}`,children:[h.jsxs("span",{className:"text-text-tertiary",children:[String(w.deltaMs).padStart(4),"ms "]}),h.jsx("span",{className:"text",children:JSON.stringify(w.key)}),w.code&&h.jsxs("span",{className:"text-text-tertiary",children:[" (",w.code,")"]}),h.jsxs("span",{className:"text-text-tertiary",children:[" — ",w.note]})]},w.seq))]}),h.jsxs("div",{className:"px-2 py-1.5 text-2xs text-text-tertiary border-t border-surface-border",children:["Read it like this: a scan should end with an"," ",h.jsx("span",{className:"font-mono",children:'"Enter"'})," row saying"," ",h.jsx("span",{className:"font-mono",children:"capture → …"}),'. An Enter row saying "no code tail" means the buffer split (raise the gap limit, or a key arrived as something other than one character). No Enter row at all means the scanner sends no suffix — program its Enter/CR suffix. Keys named'," ",h.jsx("span",{className:"font-mono",children:'"Unidentified"'})," mean the decode arrives outside the keydown path."]})]})]})]})]})]})}const Tv=/^\{lt:([A-Za-z0-9_]+)\}$/;function J5(n){return`{lt:${n}}`}const Cv="lt:station:link-vars:";function Kd(n){return`${Cv}${n}`}const Jd=new Set;function AN(){for(const n of Jd)n()}let vu,Kc={};function Mv(n){let t=null;try{t=localStorage.getItem(Kd(n))}catch{t=null}if(t===vu)return Kc;vu=t;try{const s=t?JSON.parse(t):{};Kc=s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).filter(([,i])=>typeof i=="string")):{}}catch{Kc={}}return Kc}function jN(n,t,s){const i={...Mv(n)};s===null||s===""?delete i[t]:i[t]=s;try{Object.keys(i).length===0?localStorage.removeItem(Kd(n)):localStorage.setItem(Kd(n),JSON.stringify(i))}catch{}vu=void 0,AN()}function kN(n){Jd.add(n);const t=s=>{(s.key===null||s.key.startsWith(Cv))&&(vu=void 0,n())};try{window.addEventListener("storage",t)}catch{}return()=>{Jd.delete(n);try{window.removeEventListener("storage",t)}catch{}}}const NN={};function TN(n){return E.useSyncExternalStore(kN,()=>n?Mv(n):NN)}function CN(n,t,s){let i;try{i=new URL(n,"http://local")}catch{return n}const o=i.searchParams.get("facets");if(!o)return n;let c;try{const y=JSON.parse(o);if(!y||typeof y!="object"||Array.isArray(y))return n;c=y}catch{return n}let m=!1;for(const[y,g]of Object.entries(c)){if(typeof g!="string")continue;const u=Tv.exec(g);if(!u)continue;const d=t[u[1]]??s[u[1]];typeof d=="string"&&d!==""?c[y]=d:delete c[y],m=!0}return m?(Object.keys(c).length===0?i.searchParams.delete("facets"):i.searchParams.set("facets",JSON.stringify(c)),i.pathname+i.search):n}function X5(n){let t;try{t=new URL(n,"http://local")}catch{return[]}const s=t.searchParams.get("facets");if(!s)return[];try{const i=JSON.parse(s);if(!i||typeof i!="object"||Array.isArray(i))return[];const o=[];for(const c of Object.values(i)){if(typeof c!="string")continue;const m=Tv.exec(c);m&&!o.includes(m[1])&&o.push(m[1])}return o}catch{return[]}}function Pm(){const{user:n,isSuperAdmin:t,hasRoleType:s}=Pt(),i=(n==null?void 0:n.userId)??null,o=t||s("admin"),c=E.useMemo(()=>new Set(((n==null?void 0:n.roles)??[]).map(x=>x.role)),[n]),{data:m}=Nu({enabled:o||c.size>0}),y=TN(i),g=E.useMemo(()=>{var w;const x=[],v=new Set;for(const S of(m==null?void 0:m.roles)??[]){if(!o&&!c.has(S.role))continue;const C=(w=S.properties)==null?void 0:w.link_variables;if(Array.isArray(C))for(const q of C){const B=q==null?void 0:q.name;if(typeof B!="string"||B===""||v.has(B))continue;v.add(B);const ie=q.label,le=q.default;x.push({name:B,...typeof ie=="string"&&ie!==""?{label:ie}:{},...typeof le=="string"&&le!==""?{default:le}:{},fromRole:S.role})}}return x},[m,c,o]),u=E.useMemo(()=>{const x={};for(const v of g)v.default!==void 0&&(x[v.name]=v.default);return x},[g]),d=E.useCallback(x=>CN(x,y,u),[y,u]),b=E.useCallback((x,v)=>{i&&jN(i,x,v)},[i]);return{declarations:g,values:y,defaults:u,resolveUrl:d,setValue:b}}function MN({open:n,onClose:t,title:s,children:i,maxWidth:o,closeOnBackdrop:c=!0}){return E.useEffect(()=>{if(!n)return;const m=y=>{y.key==="Escape"&&t()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n,t]),n?Wd.createPortal(h.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[h.jsx("div",{className:"absolute inset-0 bg-text-primary/30",onClick:c?t:void 0}),h.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"lt-modal-title",className:`relative bg-surface-raised border border-surface-border rounded-lg shadow-xl w-full ${o??"max-w-md"} mx-4 max-h-[85vh] flex flex-col`,children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b shrink-0",children:[h.jsx("h2",{id:"lt-modal-title",className:"text-sm font-medium text-text-primary",children:s}),h.jsx("button",{onClick:t,"aria-label":"Close dialog",className:"text-text-tertiary hover:text-text-primary text-lg leading-none",children:"×"})]}),h.jsx("div",{className:"px-6 py-5 overflow-y-auto",children:i})]})]}),document.body):null}function RN({open:n,onClose:t}){const{declarations:s,values:i,setValue:o}=Pm();return h.jsxs(MN,{open:n,onClose:t,title:"Link Variables",maxWidth:"max-w-lg",children:[h.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed mb-4",children:"Values bound on this device. Pinned links and the Pace Board open scoped to the value applied; an unbound variable falls back to the role's default, or applies no filter at all."}),h.jsx("div",{className:"divide-y divide-surface-border",children:s.map((c,m)=>h.jsx(DN,{declaration:c,value:i[c.name]??"",autoFocus:m===0,onChange:y=>o(c.name,y),onClear:()=>o(c.name,null),onEnter:t},c.name))}),s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary",children:"Your roles declare no link variables."}),s.length>0&&h.jsx("div",{className:"flex justify-end pt-4",children:h.jsx("button",{onClick:t,className:"px-3 py-1.5 text-xs rounded bg-accent text-text-inverse hover:bg-accent-hover transition-colors",children:"OK"})})]})}function DN({declaration:n,value:t,autoFocus:s,onChange:i,onClear:o,onEnter:c}){const m=E.useId(),{data:y}=TA(n.name),g=(y==null?void 0:y.values)??[];return h.jsxs("div",{className:"py-3 flex items-center gap-3","data-testid":"link-var-row",children:[h.jsxs("div",{className:"w-40 shrink-0 min-w-0",children:[h.jsx("p",{className:"text-xs font-mono text-text-primary truncate",title:n.name,children:n.name}),h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:`declared by ${n.fromRole}`,children:n.label??n.fromRole})]}),h.jsx("input",{type:"text",list:m,autoFocus:s,value:t,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&c()},placeholder:n.default?`${n.default} (default)`:"no filter","aria-label":`Value for ${n.name}`,className:"input text-xs font-mono flex-1 min-w-0"}),h.jsx("datalist",{id:m,children:g.map(u=>h.jsx("option",{value:u},u))}),h.jsx("button",{onClick:o,disabled:t==="",title:`Clear ${n.name}`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors disabled:opacity-30 disabled:cursor-not-allowed shrink-0",children:"×"})]})}const Lb=["escalationId","workflowId"],LN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Rv="lt:search:mode",qN="lt:search:facet",Dt={FACET:"facet",COMMAND:"command"};function BN(n,t){return{version:n.version,category:t.category,name:t.name,schemeName:n.name,targetFacet:n.target_facet,encoding:n.encoding,delimiter:n.delimiter,targetLength:n.target_length}}function ko(n){return n.encoding==="delimited"?`${n.version}${n.delimiter}${n.category}${n.delimiter}`:`${n.version}${n.category}`}function PN(n,t){if(n.encoding==="delimited")return UN(n,t)?{code:t}:{code:`${ko(n)}${t}`};if(!/^[0-9]+$/.test(t))return{error:`${n.name} takes digits only`};const s=n.targetLength;return s&&t.length!==s&&t.length!==s+1?{error:`${n.name} takes ${s} digits`}:{code:`${ko(n)}${t}`}}function UN(n,t){const s=n.delimiter.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^[1-9][0-9]${s}[0-9]${s}.+$`).test(t)}function zN(n,t){return n==="escalationId"||n==="workflowId"?null:kk(n,t)}function IN(n){return n.kind===Dt.FACET?n.facet:n.command.name}function $N(n){return n.kind===Dt.COMMAND?n.command.targetFacet:n.facet==="escalationId"?"Escalation id":n.facet==="workflowId"?"Workflow id":n.facet}function HN(n){return n.kind===Dt.FACET?{kind:Dt.FACET,facet:n.facet}:{kind:Dt.COMMAND,version:n.command.version,category:n.command.category}}function FN(n,t,s){if((n==null?void 0:n.kind)===Dt.FACET&&t.includes(n.facet))return{kind:Dt.FACET,facet:n.facet};if((n==null?void 0:n.kind)===Dt.COMMAND){const i=s.find(o=>o.version===n.version&&o.category===n.category);if(i)return{kind:Dt.COMMAND,command:i}}return t.length>0?{kind:Dt.FACET,facet:t[0]}:s.length>0?{kind:Dt.COMMAND,command:s[0]}:null}function GN(){try{const n=localStorage.getItem(Rv);if(n){const s=JSON.parse(n);if(s.kind===Dt.FACET&&typeof s.facet=="string"||s.kind===Dt.COMMAND&&typeof s.version=="number"&&typeof s.category=="string")return s}const t=localStorage.getItem(qN);return t?{kind:Dt.FACET,facet:t}:null}catch{return null}}function VN(n){try{localStorage.setItem(Rv,JSON.stringify(n))}catch{}}const qb=5*6e4,YN=n=>({rules:n.map(t=>{var s;return((s=t.data)==null?void 0:s.rules)??null}),loading:n.some(t=>t.isLoading)});function KN(n){const t=xv({enabled:n,staleTime:qb}),s=E.useMemo(()=>{var m;return(((m=t.data)==null?void 0:m.schemes)??[]).filter(y=>y.enabled&&y.kind===_k.ACTION).sort((y,g)=>y.version-g.version)},[t.data]),{rules:i,loading:o}=rS({queries:s.map(m=>({queryKey:["scan-schemes",m.version,"actions"],queryFn:()=>fe(`/scan-codes/schemes/${m.version}/actions`),enabled:n,staleTime:qb})),combine:YN});return{commands:E.useMemo(()=>s.flatMap((m,y)=>(i[y]??[]).filter(g=>g.enabled).sort((g,u)=>g.category.localeCompare(u.category)).map(g=>BN(m,g))),[s,i]),loading:t.isLoading||o}}const JN={escalationId:"opens the item",workflowId:"opens the run"};function XN({mode:n,facets:t,commands:s,onSelect:i,onOpenScanPanel:o}){const[c,m]=E.useState(!1),y=E.useRef(null);E.useEffect(()=>{if(!c)return;const x=w=>{y.current&&!y.current.contains(w.target)&&m(!1)},v=w=>{w.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v)}},[c]);const g=n.kind===Dt.COMMAND,u=g?`${n.command.schemeName} · ${n.command.name} — ${ko(n.command)}<${n.command.targetFacet}>`:`Search by ${n.facet}`,d=QN(s),b=x=>{i(x),m(!1)};return h.jsxs("div",{ref:y,className:"relative h-full shrink-0",children:[h.jsxs("button",{type:"button",onClick:()=>m(x=>!x),"aria-expanded":c,"aria-haspopup":"listbox","aria-label":"Search or run as",title:u,className:"group flex items-center gap-1 h-full pl-2.5 pr-2 border-l border-surface-field-border hover:bg-surface-hover transition-colors rounded-r-[var(--lt-radius-field)]","data-testid":"search-mode",children:[h.jsx("span",{className:`text-2xs whitespace-nowrap truncate max-w-[9rem] ${g?"font-medium text-accent":"font-mono text-text-tertiary"}`,children:IN(n)}),h.jsx(Zd,{className:`w-3 h-3 shrink-0 text-text-quaternary group-hover:text-accent transition-transform ${c?"rotate-180":""}`,strokeWidth:1.5})]}),c&&h.jsxs("div",{role:"listbox","aria-label":"Search or run as",className:"absolute z-50 top-full right-0 mt-1.5 min-w-[17rem] max-w-[24rem] max-h-[70vh] overflow-y-auto bg-surface-raised border border-surface-border rounded-md shadow-lg py-1",children:[t.length>0&&h.jsxs(h.Fragment,{children:[h.jsx(Bb,{children:"Find"}),t.map(x=>h.jsx(Pb,{label:x,mono:!0,note:JN[x]??"filters the list",active:!g&&n.facet===x,onClick:()=>b({kind:Dt.FACET,facet:x})},x))]}),d.map(({schemeName:x,targetFacet:v,items:w})=>h.jsxs("div",{children:[h.jsxs(Bb,{note:v,children:["Run · ",x]}),w.map(S=>h.jsx(Pb,{label:S.name,note:ko(S),noteMono:!0,active:g&&n.command.version===S.version&&n.command.category===S.category,onClick:()=>b({kind:Dt.COMMAND,command:S})},`${S.version}:${S.category}`))]},x)),o&&h.jsxs(h.Fragment,{children:[h.jsx("hr",{className:"border-surface-border/60 my-1"}),h.jsxs("button",{type:"button",onClick:()=>{m(!1),o()},className:"w-full text-left px-3 py-1.5 flex items-center gap-2 text-xs text-accent hover:bg-surface-hover","data-testid":"search-mode-scan-panel",children:[h.jsx(No,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Scanner settings and barcode preview"]})]})]})]})}function QN(n){const t=[];for(const s of n){const i=t.find(o=>o.schemeName===s.schemeName);i?i.items.push(s):t.push({schemeName:s.schemeName,targetFacet:s.targetFacet,items:[s]})}return t}function Bb({children:n,note:t}){return h.jsxs("p",{className:"px-3 pt-2 pb-1 flex items-baseline gap-2 text-2xs font-semibold uppercase tracking-widest text-text-quaternary first:pt-1",children:[h.jsx("span",{className:"truncate",children:n}),t&&h.jsx("span",{className:"ml-auto font-mono font-normal normal-case tracking-normal shrink-0",children:t})]})}function Pb({label:n,note:t,active:s,mono:i,noteMono:o,onClick:c}){return h.jsxs("button",{type:"button",role:"option","aria-selected":s,onClick:c,className:`w-full text-left pl-3 pr-3 py-1.5 flex items-baseline gap-3 border-l-2 transition-colors ${s?"border-accent bg-accent/10 text-accent":"border-transparent text-text-primary hover:bg-surface-hover"}`,children:[h.jsx("span",{className:`text-xs font-medium truncate ${i?"font-mono":""}`,children:n}),h.jsx("span",{className:`ml-auto text-2xs shrink-0 ${o?"font-mono tabular-nums":""} ${s?"text-accent/70":"text-text-quaternary"}`,children:t})]})}const WN=6e3;function ZN({onOpenScanPanel:n}){const t=ra(),{data:s}=Zn(),i=Dm(),{submitCode:o,busy:c,lastResult:m}=qm(),{commands:y}=KN(i),[g,u]=E.useState(""),[d,b]=E.useState(!1),[x,v]=E.useState(null),[w,S]=E.useState(null),[C,q]=E.useState(""),[B,ie]=E.useState(null),[le,R]=E.useState(GN),$=E.useRef(null),ne=E.useMemo(()=>{var ce;if(!((ce=s==null?void 0:s.search)!=null&&ce.enabled))return[];const W=(s.search.facets??[]).filter(xe=>!Lb.includes(xe));return[...Lb,...W]},[s]),V=E.useMemo(()=>FN(le,ne,y),[le,ne,y]),I=(m==null?void 0:m.source)===jo.TOOLBAR&&!m.navigated&&B!==m.at?m:null;E.useEffect(()=>{if(!I)return;const W=setTimeout(()=>ie(I.at),WN);return()=>clearTimeout(W)},[I]);const D=()=>{v(null),S(null),m&&ie(m.at)},Q=W=>{var xe;const ce=HN(W);R(ce),VN(ce),D(),(xe=$.current)==null||xe.focus()},X=(W,ce)=>{const xe=PN(W.command,Nv(ce));if("error"in xe){v(xe.error);return}u(""),o(xe.code,jo.TOOLBAR)},he=async(W,ce)=>{const xe=zN(W,ce);if(xe){u(""),t(xe);return}if(W==="escalationId"&&!LN.test(ce)){v("That is not a valid escalation id");return}b(!0);try{if(W==="escalationId")await fe(`/escalations/${encodeURIComponent(ce)}`),u(""),t(`/escalations/detail/${encodeURIComponent(ce)}`);else{const ve=await fe(`/escalations/by-workflow/${encodeURIComponent(ce)}`),Ce=(ve==null?void 0:ve.escalations)??[];Ce.length===1?(u(""),t(`/escalations/detail/${Ce[0].id}`)):(q(ce),S(Ce))}}catch{v(`No ${W==="escalationId"?"escalation":"workflow"} found for "${ce}"`)}finally{b(!1)}},Se=()=>{const W=g.trim();!W||d||c||!V||(D(),V.kind===Dt.COMMAND?X(V,W):he(V.facet,W))};if(!V)return null;const ke=V.kind===Dt.COMMAND,H=d||c;return h.jsxs("div",{className:"relative w-full max-w-[28rem]","data-testid":"global-search",children:[h.jsxs("div",{className:"flex items-center h-8 bg-surface-field border border-surface-field-border rounded-[var(--lt-radius-field)] focus-within:border-accent focus-within:bg-surface-field-focus transition-colors",children:[h.jsxs("label",{htmlFor:"global-search-input",className:"flex items-center gap-1.5 pl-2.5 shrink-0 cursor-text",children:[ke?h.jsx(No,{className:"w-3.5 h-3.5 text-accent/65",strokeWidth:1.5}):h.jsx(hS,{className:"w-3.5 h-3.5 text-text-quaternary",strokeWidth:1.5}),ke&&h.jsx("span",{className:"font-mono text-xs tabular-nums text-text-tertiary select-none","data-testid":"search-command-prefix",children:ko(V.command)})]}),h.jsx("input",{ref:$,id:"global-search-input",type:"text",value:g,onChange:W=>{u(W.target.value),D()},onKeyDown:W=>{W.key==="Enter"&&Se(),W.key==="Escape"&&(u(""),D())},placeholder:$N(V),"aria-label":ke?"Run target":"Global search",autoComplete:"off",spellCheck:!1,className:`flex-1 min-w-0 h-full bg-transparent text-xs text-text-primary placeholder:text-text-quaternary focus:outline-none ${ke?"pl-0.5 pr-2 font-mono":"px-2"}`}),H&&h.jsx("span",{className:"w-1.5 h-1.5 mr-2 rounded-full bg-accent animate-pulse shrink-0","aria-label":"Working"}),h.jsx(XN,{mode:V,facets:ne,commands:y,onSelect:Q,onOpenScanPanel:n})]}),x&&h.jsx("p",{className:"absolute top-full left-0 mt-1 text-2xs text-status-error whitespace-nowrap",role:"alert",children:x}),I&&h.jsx("div",{role:"status",className:"absolute top-full left-0 mt-1.5 z-50 w-full max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg px-3 py-2 animate-fade-in","data-testid":"search-run-outcome",children:h.jsx(Bm,{result:I,compact:!0})}),w!==null&&h.jsxs("div",{className:"absolute top-full left-0 mt-1.5 z-50 min-w-72 max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1","data-testid":"search-workflow-results",children:[w.map(W=>h.jsxs(Cr,{to:`/escalations/detail/${W.id}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover truncate",children:[h.jsx("span",{className:"font-medium text-text-primary",children:W.role}),h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),W.status,h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),h.jsx("span",{className:"text-text-tertiary",children:W.type})]},W.id)),w.length===0&&h.jsx("p",{className:"px-3 py-1.5 text-2xs text-text-tertiary",children:"No escalations for this workflow."}),h.jsx("hr",{className:"border-surface-border/60 my-0.5"}),h.jsx(Cr,{to:`/workflows/executions/${encodeURIComponent(C)}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-accent hover:bg-surface-hover",children:"Workflow execution →"})]})]})}function eT(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[-_\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Xd(n){var t;return((t=n.title)==null?void 0:t.trim())||eT(n.role)}const Dv="lt:bookmarks",Jc="scan";function tT(){try{const n=localStorage.getItem(Dv);if(!n)return[];const t=JSON.parse(n);return Array.isArray(t)?t:[]}catch{return[]}}function Ub(n){try{localStorage.setItem(Dv,JSON.stringify(n))}catch{}}function nT({onToggleEventFeed:n,onToggleDocs:t,onToggleNav:s}){var Be,We,ln;const i=ra(),{user:o,logout:c,isSuperAdmin:m,hasRoleType:y}=Pt(),{viewAs:g,realIsBuilder:u}=Yx(),{available:d,mine:b}=DA();Kx();const{connected:x}=Nx(),{data:v}=Zn(),{role:w,targets:S,selectable:C,selectRole:q}=Sm(),{declarations:B,values:ie}=Pm(),[le,R]=E.useState(!1),{data:$}=Nu(),ne=E.useMemo(()=>{const pe=($==null?void 0:$.roles)??[],Ye=new Set(((o==null?void 0:o.roles)??[]).map(ft=>ft.role)),Ot=m||y("admin");return pe.filter(ft=>Wi(ft).length>0&&(Ot||Ye.has(ft.role))).map(ft=>({role:ft.role,title:Xd(ft),portals:Wi(ft)}))},[$,o,m,y]),{setPanel:V,closePanel:I,open:D,ownerKey:Q}=jm(),X=Dm(),he=an(),Se=()=>{D&&Q===Jc?I(Jc):V(h.jsx(ON,{onClose:()=>I(Jc)}),{width:360,key:Jc})},[ke,H]=E.useState(!1),[W,ce]=E.useState(!1),[xe,ve]=E.useState(mv),[Ce,Ne]=E.useState(tT),Me=E.useRef(null),Ze=(Be=v==null?void 0:v.branding)==null?void 0:Be.appName,yt=(We=v==null?void 0:v.branding)==null?void 0:We.themes,Ct=E.useMemo(()=>(ik(yt??[]),ak()),[yt]),we=pe=>{ok(pe),ve(pe)},Re=()=>{const pe=window.prompt("Bookmark label:");if(!(pe!=null&&pe.trim()))return;const Ye=he.pathname+he.search,Ot=[...Ce,{label:pe.trim(),url:Ye}].sort((ft,Pr)=>ft.label.localeCompare(Pr.label));Ne(Ot),Ub(Ot),H(!1)},oe=pe=>{const Ye=Ce.filter(Ot=>!(Ot.label===pe.label&&Ot.url===pe.url));Ne(Ye),Ub(Ye)};return E.useEffect(()=>{if(!ke)return;const pe=Ye=>{Me.current&&!Me.current.contains(Ye.target)&&H(!1)};return document.addEventListener("mousedown",pe),()=>document.removeEventListener("mousedown",pe)},[ke]),h.jsxs(h.Fragment,{children:[h.jsxs("header",{className:`h-14 shrink-0 border-b border-surface-border bg-surface-raised flex items-center justify-between pl-2 pr-5 relative ${ke?"z-[100]":"z-30"}`,children:[h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s&&h.jsx("button",{onClick:s,className:"lg:hidden p-2 text-text-secondary hover:text-text-primary transition-colors","aria-label":"Open navigation",children:h.jsx(dS,{className:"w-5 h-5",strokeWidth:1.5})}),h.jsx(Cr,{to:"/","aria-label":"Home",className:"shrink-0 hidden lg:block",onClick:pe=>{(pe.ctrlKey||pe.metaKey)&&(pe.preventDefault(),ce(!0))},children:h.jsx(Tm,{appName:Ze,className:"flex"})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border mx-1"}),h.jsx("button",{onClick:()=>i(-1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go back",children:h.jsx(tx,{className:"w-5 h-5",strokeWidth:2})}),h.jsx("button",{onClick:()=>i(1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go forward",children:h.jsx(hd,{className:"w-5 h-5",strokeWidth:2})})]}),(((ln=v==null?void 0:v.search)==null?void 0:ln.enabled)||X)&&h.jsx("div",{className:"hidden md:flex flex-1 min-w-0 justify-center px-4 lg:px-8",children:h.jsx(ZN,{onOpenScanPanel:X?Se:void 0})}),h.jsxs("div",{className:"flex items-center gap-5 shrink-0",children:[h.jsxs(Cr,{to:"/escalations/available",className:`flex items-center gap-1.5 text-xs transition-colors ${d>0?"text-status-queued":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[h.jsx(dd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"all"}),d>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:d})]}),h.jsxs(Cr,{to:"/escalations/queue",className:`flex items-center gap-1.5 text-xs transition-colors ${b>0?"text-status-claimed":"text-text-quaternary hover:text-text-secondary"}`,title:"My escalation queue",children:[h.jsx(dd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"mine"}),b>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:b})]}),g&&h.jsx(h.Fragment,{children:h.jsxs("span",{className:"hidden lg:flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-full bg-accent/10 border border-accent/25 text-2xs text-accent select-none",children:[h.jsxs("span",{className:"capitalize font-medium tracking-wide",children:[g," View"]}),h.jsx("button",{onClick:zd,title:"Restore your real view",className:"ml-0.5 rounded-full p-0.5 hover:bg-accent/20 transition-colors",children:h.jsx(Wt,{className:"w-2.5 h-2.5"})})]})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border"}),o&&h.jsxs("div",{className:"relative",ref:Me,children:[h.jsxs("button",{onClick:()=>H(pe=>!pe),className:"btn-ghost flex items-center gap-1",children:[h.jsxs("span",{className:"relative",children:[h.jsx(mS,{className:"w-4 h-4 text-accent/75",strokeWidth:1.5}),g&&h.jsx("span",{className:"lg:hidden absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-accent"})]}),h.jsx("span",{className:"hidden lg:inline whitespace-nowrap",children:o.displayName||o.username||o.userId}),h.jsx("svg",{className:"hidden lg:block w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),ke&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 w-52 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100]",children:[h.jsx(Cr,{to:"/credentials",onClick:()=>H(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),X&&h.jsx("button",{onClick:()=>{H(!1),Se()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-scan",children:"Scan a code"}),h.jsx("button",{onClick:()=>{H(!1),x?n==null||n():window.location.reload()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:x?"Events":"Reconnect events"}),u&&h.jsx("button",{onClick:()=>{H(!1),t==null||t()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-docs",children:"Docs"}),g&&h.jsxs("button",{onClick:()=>{H(!1),zd()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-accent hover:bg-surface-hover capitalize",children:["Exit ",g," view"]}),h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Theme"}),h.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:Ct.map(pe=>h.jsx("button",{type:"button",onClick:()=>we(pe.id),title:pe.label,"aria-label":`${pe.label} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${xe===pe.id?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:pe.swatch}},pe.id))})]}),C&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Station queue"}),h.jsxs("div",{className:"flex flex-col",children:[h.jsxs("button",{type:"button",onClick:()=>{H(!1),q(null),i("/")},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${w?"text-text-secondary":"text-accent"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${w?"bg-surface-border":"bg-accent"}`}),h.jsx("span",{className:"truncate",children:"Full dashboard"})]}),S.map(pe=>{var ft;const Ye=(ft=$==null?void 0:$.roles)==null?void 0:ft.find(Pr=>Pr.role===pe),Ot=pe===w;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),q(pe),i(Qx(pe,Wi(Ye)))},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${Ot?"text-accent":"text-text-secondary"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ot?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Xd({role:pe,title:Ye==null?void 0:Ye.title})})]},pe)})]})]}),ne.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60","data-testid":"menu-portals",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Portals"}),h.jsx("div",{className:"flex flex-col gap-1.5",children:ne.map(pe=>h.jsxs("div",{children:[ne.length>1&&h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:pe.role,children:pe.title}),pe.portals.map(Ye=>{const Ot=wm(pe.role,Ye.key),ft=he.pathname===Ot;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),i(Ot)},className:`flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded hover:bg-surface-hover ${ft?"text-accent":"text-text-secondary"}`,"data-testid":`menu-portal-${pe.role}-${Ye.key}`,children:[h.jsx(md,{className:"w-3.5 h-3.5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate",children:Ye.label})]},Ye.key)})]},pe.role))})]}),B.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Link variables"}),h.jsxs("button",{type:"button",onClick:()=>{H(!1),R(!0)},className:"flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded text-text-secondary hover:bg-surface-hover","data-testid":"link-vars-menu-entry",children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Object.keys(ie).length>0?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Object.keys(ie).length>0?Object.entries(ie).map(([pe,Ye])=>`${pe} = ${Ye}`).join(", "):"Set values for this device"})]})]}),h.jsx("button",{onClick:()=>{H(!1),c()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Sign Out"}),h.jsxs("div",{className:"border-t border-surface-border/60 pt-1",children:[Ce.map(pe=>h.jsxs("div",{className:"flex items-center group px-3 py-1.5 hover:bg-surface-hover",children:[h.jsx(Cr,{to:pe.url,onClick:()=>H(!1),title:pe.url,className:"flex-1 min-w-0 text-xs text-text-secondary hover:text-text-primary truncate",children:pe.label}),h.jsx("button",{type:"button",onClick:()=>oe(pe),title:`Remove "${pe.label}"`,className:"opacity-0 group-hover:opacity-100 transition-opacity ml-1 p-0.5 shrink-0 text-text-quaternary hover:text-status-error",children:h.jsx(Wt,{className:"w-3 h-3"})})]},`${pe.label}::${pe.url}`)),h.jsx("hr",{className:"border-surface-border/60 mx-3 my-0.5"}),h.jsxs("button",{type:"button",onClick:Re,className:"flex items-center gap-1.5 w-full px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:[h.jsx(pS,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Add Bookmark"]})]})]})]})]})]}),W&&h.jsx(sk,{onClose:()=>ce(!1)}),h.jsx(RN,{open:le,onClose:()=>R(!1)})]})}function Um({open:n,children:t}){const[s,i]=E.useState(n);return E.useEffect(()=>{n&&i(!0)},[n]),h.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-out ${n?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,onTransitionEnd:()=>{n||i(!1)},children:h.jsx("div",{className:"overflow-hidden",children:s?t:null})})}function Qd(n){return({isActive:t})=>{const s="flex items-center rounded-md transition-colors duration-150",i="bg-surface-hover text-text-primary font-medium",o="text-text-secondary hover:text-text-primary hover:bg-surface-hover";return n?`${s} justify-center w-10 h-10 mx-auto ${t?i:o}`:`${s} gap-3 px-4 py-2 text-sm ${t?i:o}`}}function rT(){return({isActive:n})=>`flex items-center gap-3 pl-11 pr-4 py-1.5 text-xs rounded-md transition-colors duration-150 ${n?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary"}`}function sT({group:n,collapsed:t}){const{pathname:s}=an(),i=n.matchPaths.some(y=>s.startsWith(y)),[o,c]=E.useState(i),m=o||i;return t?h.jsx(h.Fragment,{children:n.items.map(y=>h.jsx(Ss,{to:y.to,className:Qd(!0),title:y.label,children:y.icon&&h.jsx(y.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},y.to))}):h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>c(y=>!y),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:[h.jsxs("span",{className:"flex items-center gap-3",children:[n.icon&&h.jsx(n.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:n.label})]}),h.jsx("svg",{className:`w-3.5 h-3.5 text-text-tertiary transition-transform duration-150 ${m?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),h.jsx(Um,{open:m,children:n.items.map(y=>h.jsxs(Ss,{to:y.to,end:y.end,className:rT(),children:[y.icon&&h.jsx(y.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:y.label})]},y.to))})]})}function iT(n){return n.kind==="group"}function aT({entry:n,collapsed:t}){const{pathname:s,search:i}=an(),o=n.to.includes("?"),c=n.icon&&h.jsx(n.icon,{className:`w-5 h-5 shrink-0 text-accent/75 ${n.iconClassName??""}`,strokeWidth:1.5,...n.solid?{fill:"currentColor"}:{}});if(o){const[m,y]=n.to.split("?"),g=s===m&&i===`?${y}`,u=Qd(t)({isActive:g});return h.jsxs(Ss,{to:n.to,className:u,title:t?n.label:void 0,children:[c,!t&&h.jsx("span",{children:n.label})]})}return h.jsxs(Ss,{to:n.to,end:n.end,className:Qd(t),title:t?n.label:void 0,children:[c,!t&&h.jsx("span",{children:n.label})]})}function Dr({heading:n,entries:t}){const{collapsed:s}=Om();return h.jsxs("div",{className:"space-y-1",children:[s?h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:n}):h.jsx("p",{className:"px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary",children:n}),t.map(i=>iT(i)?h.jsx(sT,{group:i,collapsed:s},i.label):h.jsx(aT,{entry:i,collapsed:s},i.to))]})}function oT({aiEnabled:n=!1,isBuilder:t=!1,isOps:s=!1,viewAs:i=null,canSeePaceBoard:o=!1}){const c=[{to:"/pace",label:"Pace Board",icon:yS},{to:"/trends",label:"Trend Board",icon:gS}];if(!t&&(!s||i==="engineer"||i==="operator"))return o?h.jsx(Dr,{heading:"Monitor",entries:c}):null;if(!t)return h.jsx(Dr,{heading:"Monitor",entries:o?c:[]});const m=[...o?c:[],{to:"/topics",label:"Event Topics",icon:nx},{to:"/agents",label:n?"Agents":"Automations",icon:bS},{to:"/capabilities",label:"Capabilities",icon:xS}];return h.jsx(Dr,{heading:"Monitor",entries:m})}function lT(){return $e({queryKey:["me","preferences"],queryFn:()=>fe("/me/preferences"),staleTime:6e4})}function cT(){const n=He();return Ve({mutationFn:t=>fe("/me/preferences",{method:"PATCH",body:JSON.stringify(t)}),onSuccess:t=>{n.setQueryData(["me","preferences"],t)}})}const bs={TABLE:"table",RICH:"rich",TIMELINE:"timeline"},zb={COMPACT:"compact",CARDS:"cards"},cd={AVAILABLE:"/escalations/available",ALL:"/escalations"},Zi={AVAILABLE:"available",CLAIMED:"claimed",RESOLVED:"resolved",CANCELLED:"cancelled",EXPIRED:"expired"},uT={[Zi.RESOLVED]:"resolved",[Zi.CANCELLED]:"cancelled",[Zi.EXPIRED]:"expired"};function fT(n){const t=n===Zi.CLAIMED;return{available:n===Zi.AVAILABLE,claimed:t,apiStatus:t?"pending":uT[n]}}function hT(n){return n===bs.TABLE||n===bs.RICH||n===bs.TIMELINE}function dT(n){return n===zb.COMPACT||n===zb.CARDS}function mT(n,t=""){const s=n.get("priority"),i=n.get("view"),o=n.get("layout");return{statusFilter:n.get("status")||t,role:n.get("role")||void 0,type:n.get("type")||void 0,subtype:n.get("subtype")||void 0,priority:s?parseInt(s,10):void 0,search:n.get("search")||void 0,facets:jk(n),view:hT(i)?i:null,layout:dT(o)?o:null}}function pT(n){let t;try{t=new URL(n,"http://local")}catch{return null}if(t.pathname!==cd.AVAILABLE&&t.pathname!==cd.ALL)return null;const s=t.pathname===cd.AVAILABLE?Zi.AVAILABLE:"";return mT(t.searchParams,s)}function Q5(n){var t;return n.role||(((t=n.facets.roles)==null?void 0:t.length)===1?n.facets.roles[0]:null)}function W5(n,t){return n===bs.TIMELINE?bs.TIMELINE:t&&(!n||n===bs.RICH)?bs.RICH:bs.TABLE}function yT(n,t){const s=(n==null?void 0:n.pinnedViews)??[],i=new Set((n==null?void 0:n.hiddenRolePins)??[]),o=new Set(s.map(y=>y.label)),c=[...s],m=new Set;for(const{role:y,pins:g}of t)for(const u of g)o.has(u.label)||i.has(u.label)||m.has(u.label)||(m.add(u.label),c.push({...u,id:`role:${y}:${u.label}`,fromRole:y}));return c}function gT(n){const t=pT(n);if(!t)return null;const{available:s,claimed:i,apiStatus:o}=fT(t.statusFilter);return{available:s,params:{...t.facets,role:t.role,type:t.type,subtype:t.subtype,priority:t.priority,status:o,...i?{claimed:!0}:{},search:t.search}}}function bT(){return`pin-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function xT(){var I;const{collapsed:n}=Om(),{user:t}=Pt(),s=lT(),i=cT(),o=E.useMemo(()=>new Set(((t==null?void 0:t.roles)??[]).map(D=>D.role)),[t]),{data:c}=Nu({enabled:o.size>0}),m=on("SUMMARY");ti(vm(),()=>{m([["escalations"]])});const y=(I=s.data)==null?void 0:I.preferences,g=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&Array.isArray(D.default_pins)&&D.default_pins.length>0).map(D=>({role:D.role,pins:D.default_pins})),[c,o]),{resolveUrl:u}=Pm(),d=E.useMemo(()=>yT(y,g),[y,g]),b=E.useMemo(()=>new Map(d.map(D=>[D.id,D.url])),[d]),x=E.useMemo(()=>d.map(D=>({...D,url:u(D.url)})),[d,u]),v=E.useMemo(()=>new Map(((c==null?void 0:c.roles)??[]).map(D=>[D.role,Xd(D)])),[c]),w=E.useMemo(()=>x.filter(D=>!D.fromRole),[x]),S=E.useMemo(()=>new Set(((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&wA(D)).map(D=>D.role)),[c,o]),C=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>S.has(D.role)||g.some(Q=>Q.role===D.role)).map(D=>({role:D.role,title:v.get(D.role)??D.role,portals:S.has(D.role)?Wi(D):[],pins:x.filter(Q=>Q.fromRole===D.role)})).filter(D=>D.portals.length>0||D.pins.length>0),[c,g,S,v,x]),q=(y==null?void 0:y.pinnedViews)??[],B=E.useRef(null),ie=D=>i.mutate({pinnedViews:D}),le=D=>ie(q.filter(Q=>Q.id!==D)),R=D=>ie([...q,{id:bT(),label:D.label,url:b.get(D.id)??D.url,badge:D.badge}]),$=D=>i.mutate({hiddenRolePins:[...(y==null?void 0:y.hiddenRolePins)??[],D]}),ne=(D,Q)=>{if(D===Q)return;const X=[...q],[he]=X.splice(D,1);X.splice(Q,0,he),ie(X)};if(x.length===0&&S.size===0)return null;const V="px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary truncate";return h.jsxs("div",{className:"space-y-1",children:[n&&h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:"Pinned"}),!n&&w.length>0&&h.jsx("p",{className:V,children:"Pinned"}),w.map(D=>{const Q=q.findIndex(X=>X.id===D.id);return h.jsx(Ib,{pin:D,collapsed:n,draggable:Q!==-1,onDragStart:()=>{B.current=Q},onDropOn:()=>{B.current!==null&&Q!==-1&&ne(B.current,Q),B.current=null},onRemove:()=>le(D.id)},D.id)}),C.map(D=>h.jsxs("div",{children:[!n&&h.jsx("p",{className:V,title:`${D.title} — pins from the ${D.role} role`,"data-testid":"pin-group-label",children:D.title}),D.portals.map(Q=>h.jsx(vT,{role:D.role,portal:Q,collapsed:n},Q.key)),D.pins.map(Q=>h.jsx(Ib,{pin:Q,collapsed:n,draggable:!1,onDragStart:()=>{},onDropOn:()=>{},onPromote:()=>R(Q),onHide:()=>$(Q.label)},Q.id))]},D.role))]})}function vT({role:n,portal:t,collapsed:s}){const i=wm(n,t.key),o="flex items-center rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",c=`portal-link-${n}-${t.key}`;return s?h.jsx(Ss,{to:i,className:`${o} justify-center w-10 h-10 mx-auto`,title:t.label,"data-testid":c,children:h.jsx(md,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs(Ss,{to:i,title:t.label,className:({isActive:m})=>`${o} gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] ${m?"bg-surface-hover text-text-primary font-medium":""}`,"data-testid":c,children:[h.jsx(md,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:t.label})]})}function Ib({pin:n,collapsed:t,draggable:s,onDragStart:i,onDropOn:o,onRemove:c,onPromote:m,onHide:y}){const{pathname:g,search:u}=an(),[d,b=""]=n.url.split("?"),x=g===d&&u===(b?`?${b}`:""),v="group flex items-center rounded-md transition-colors duration-150",w=x?"bg-surface-hover text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover";return t?h.jsx(Ss,{to:n.url,className:`${v} ${w} justify-center w-10 h-10 mx-auto`,title:n.label,children:h.jsx(Ag,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs("div",{className:`${v} ${w} relative`,draggable:s,onDragStart:i,onDragOver:S=>S.preventDefault(),onDrop:o,children:[h.jsxs(Ss,{to:n.url,title:n.label,className:"flex items-center gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] flex-1 min-w-0",children:[h.jsx(Ag,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5,...n.fromRole?{}:{fill:"currentColor",fillOpacity:.15}}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:n.label}),n.badge&&h.jsx(_T,{url:n.url})]}),h.jsxs("span",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5 rounded px-0.5 bg-surface-hover opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity",children:[m&&h.jsx("button",{onClick:m,title:"Make mine — copy into my pins",className:"p-1 text-text-quaternary hover:text-accent transition-colors",children:h.jsx(rx,{className:"w-3 h-3"})}),y&&h.jsx("button",{onClick:y,title:"Hide this role pin",className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(vS,{className:"w-3 h-3"})}),c&&h.jsx("button",{onClick:c,title:`Remove "${n.label}"`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(Wt,{className:"w-3 h-3"})})]})]})}function _T({url:n}){var m;const t=E.useMemo(()=>gT(n),[n]),s={limit:1,staleTime:15e3},i=tv({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&t.available}),o=ev({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&!t.available});if(!t)return null;const c=t.available?i:o;return c.isError||((m=c.data)==null?void 0:m.total)===void 0?null:h.jsx("span",{className:"shrink-0 text-right text-2xs leading-none tabular-nums text-accent/80 relative -top-[0.35em]",title:`${c.data.total} matching now`,children:c.data.total})}function wT(){var c;const{data:n}=Zn(),t=(c=n==null?void 0:n.features)==null?void 0:c.graphWorkflows,s=t===!0||t!==!1&&Fx(),i=[{to:"/workflows/registry",label:"Registry",icon:jg},{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:pd},{to:"/workflows/executions",label:"Executions",icon:kg}],o=s?[{kind:"group",label:"Procedural",icon:_S,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:i},{kind:"group",label:"Graph",icon:em,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:jg,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:pd},{to:"/mcp/executions",label:"Executions",icon:kg}]}]:i;return h.jsx(Dr,{heading:"Orchestrate",entries:o})}function Z5(){return $e({queryKey:["activeWorkers"],queryFn:async()=>(await fe("/workflows/workers")).workers})}function eM(){return $e({queryKey:["discoveredWorkflows"],queryFn:async()=>(await fe("/workflows/discovered")).workflows})}function tM(){return $e({queryKey:["workflowConfigs"],queryFn:async()=>(await fe("/workflows/config")).workflows})}function Lv(){return $e({queryKey:["invocableWorkflows"],queryFn:async()=>(await fe("/workflows/invocable")).workflows})}function nM(n){return Object.fromEntries(n.filter(t=>!t.missing).map(t=>[t.as??t.key,t.data]))}function rM(n,t){return $e({queryKey:["workflows",n,"input-lookups"],queryFn:()=>fe(`/workflows/${encodeURIComponent(n)}/input-lookups`),enabled:!!n&&t,staleTime:1/0})}function sM(){return $e({queryKey:["cronStatus"],queryFn:async()=>(await fe("/workflows/cron/status")).schedules})}function iM(n){return $e({queryKey:["workflowExecution",n],queryFn:()=>fe(`/workflow-states/${n}/execution`),enabled:!!n})}function aM(n,t){const s=new URLSearchParams;return n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),n.entity&&s.set("entity",n.entity),n.search&&s.set("search",n.search),n.status&&s.set("status",n.status),n.sort_by&&s.set("sort_by",n.sort_by),n.order&&s.set("order",n.order),n.registered&&s.set("registered",n.registered),n.namespace&&s.set("namespace",n.namespace),$e({queryKey:["jobs",n],queryFn:()=>fe(`/workflow-states/jobs?${s}`),enabled:(t==null?void 0:t.enabled)??!0})}function oM(){const n=He();return Ve({mutationFn:t=>fe(`/workflows/${t}/terminate`,{method:"POST"}),onSuccess:(t,s)=>{n.invalidateQueries({queryKey:["workflowExecution",s],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function lM(){const n=He();return Ve({mutationFn:({workflow_type:t,...s})=>fe(`/workflows/${encodeURIComponent(t)}/config`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function cM(){const n=He();return Ve({mutationFn:t=>fe(`/workflows/${encodeURIComponent(t)}/config`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function uM(){const n=He();return Ve({mutationFn:({workflowType:t,data:s,metadata:i,execute_as:o})=>fe(`/workflows/${t}/invoke`,{method:"POST",body:JSON.stringify({data:s,metadata:i,...o?{execute_as:o}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["tasks"],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function ST(){const{data:n}=Lv();return n!=null&&n.length?h.jsx(Dr,{heading:"Tools",entries:[{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:pd}]}):null}const ET=[{to:"/mcp/queries",label:"Designer",icon:wS},{to:"/mcp/servers",label:"Servers & Tools",icon:SS}];function OT(){return h.jsx(Dr,{heading:"Design",entries:ET})}const AT=[{to:"/files",label:"Files",icon:ES},{to:"/knowledge",label:"Knowledge Base",icon:sx}];function jT(){return h.jsx(Dr,{heading:"Storage",entries:AT})}function kT({isBuilder:n=!1,isOps:t=!1}){var m;const{data:s}=Zn(),i=((m=s==null?void 0:s.features)==null?void 0:m.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:OS},...n||t?[{to:"/admin/roles",label:"Roles",icon:dd},{to:"/admin/personas",label:"Personas",icon:AS},{to:"/admin/scan-codes",label:"Scan Codes",icon:No}]:[]],c=[{to:"/admin/controlplane",label:"Routers",icon:jS},{to:"/admin/streams",label:"Messages",icon:sx},...i?[{to:"/admin/maintenance",label:"DB Maintenance",icon:kS}]:[]];return h.jsxs(h.Fragment,{children:[h.jsx(Dr,{heading:"Identity & Access",entries:o}),n&&Gx()&&h.jsx(Dr,{heading:"Infrastructure",entries:c})]})}function qv({aiEnabled:n,isBuilder:t,isOps:s,viewAs:i,canSeePaceBoard:o}){return h.jsxs(h.Fragment,{children:[h.jsx(oT,{aiEnabled:n,isBuilder:t,isOps:s,viewAs:i,canSeePaceBoard:o}),h.jsx(xT,{}),!t&&h.jsx(ST,{}),t&&h.jsx(wT,{}),t&&n&&h.jsx(OT,{}),t&&h.jsx(jT,{}),(t||s)&&h.jsx(kT,{isBuilder:t,isOps:s})]})}function NT({open:n,onClose:t,...s}){const i=an();return E.useEffect(()=>{t()},[i.pathname]),h.jsxs("div",{className:`lg:hidden fixed inset-y-0 left-0 z-40 flex ${n?"":"pointer-events-none"}`,children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${n?"opacity-100":"opacity-0"}`,onClick:t,"aria-hidden":!0}),h.jsxs("div",{className:`relative w-72 max-w-[85vw] h-full bg-surface-raised border-r border-surface-border shadow-xl flex flex-col transition-transform duration-200 ease-out ${n?"translate-x-0":"-translate-x-full"}`,children:[h.jsx("div",{className:"flex items-center justify-end px-3 pt-3 shrink-0",children:h.jsx("button",{onClick:t,className:"p-1.5 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-hover transition-colors","aria-label":"Close navigation",children:h.jsx(Wt,{className:"w-4 h-4"})})}),h.jsx("nav",{className:"flex-1 px-3 pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:h.jsx(jA,{children:h.jsx(qv,{...s})})})]})]})}const Bv="lt_event_feed_patterns";function TT(n,t){if(n.startsWith("/topics/")){const m=decodeURIComponent(n.replace("/topics/",""));if(m&&!m.includes("/"))return`lt.events.${m}`}const s=n.match(/^\/escalations\/detail\/(.+)/);if(s)return`lt.events.system.escalation.*.${s[1]}.>`;if(n.startsWith("/escalations")){const m=new URLSearchParams(t).get("role");return m?`lt.events.system.escalation.${Jx(m)}.>`:"lt.events.system.escalation.>"}const i=n.match(/^\/workflows\/(?:durable\/)?executions\/(.+)/);if(i)return`lt.events.system.workflow.${i[1]}.>`;if(n.startsWith("/workflows"))return"lt.events.system.workflow.>";const o=n.match(/^\/agents\/([^/]+)$/);if(o&&o[1]!=="new")return`lt.events.system.agent.${o[1]}.>`;if(n.startsWith("/agents"))return"lt.events.system.agent.>";if(n.startsWith("/knowledge"))return"lt.events.system.knowledge.>";if(n.startsWith("/files"))return"lt.events.system.file.>";if(n==="/")return"lt.events.system.>";const c=n.match(/^\/mcp\/executions\/(.+)/);return c?`lt.events.system.*.${c[1]}.>`:(n.startsWith("/mcp"),"lt.events.system.>")}function CT(){try{const n=localStorage.getItem(Bv);return n?JSON.parse(n):[]}catch{return[]}}function ud(n){try{localStorage.setItem(Bv,JSON.stringify(n))}catch{}}function MT(){const{pathname:n,search:t}=an(),[s,i]=E.useState(CT),o=E.useMemo(()=>TT(n,t),[n,t]),c=E.useMemo(()=>{const u=new Set([o,...s]);return Array.from(u)},[o,s]),m=E.useCallback(u=>{const d=u.startsWith("lt.events.")?u:`lt.events.${u}`;i(b=>{if(b.includes(d))return b;const x=[...b,d];return ud(x),x})},[]),y=E.useCallback(u=>{i(d=>{const b=d.filter(x=>x!==u);return ud(b),b})},[]),g=E.useCallback(()=>{i([]),ud([])},[]);return{patterns:c,pagePattern:o,userPatterns:s,addPattern:m,removePattern:y,clearUserPatterns:g}}function RT({children:n,className:t=""}){return h.jsx("p",{className:`text-2xs font-semibold uppercase tracking-widest text-text-tertiary ${t}`,children:n})}const fd=280,$b="cubic-bezier(0.4, 0, 0.2, 1)",Xc=40;function DT(n){if(!n)return"scale(0.92)";const t=window.innerWidth,s=window.innerHeight,i=t-Xc*2,o=s-Xc*2,c=n.width/i,m=n.height/o,y=n.left+n.width/2-(Xc+i/2),g=n.top+n.height/2-(Xc+o/2);return`translate(${y}px, ${g}px) scale(${c}, ${m})`}function Pv({open:n,onClose:t,sourceRef:s,children:i}){const[o,c]=E.useState(null),m=E.useRef(null),y=E.useRef(!1);E.useEffect(()=>{var x,v;n&&!y.current?(m.current=((x=s==null?void 0:s.current)==null?void 0:x.getBoundingClientRect())??null,c("entering")):!n&&y.current&&o==="open"&&(m.current=((v=s==null?void 0:s.current)==null?void 0:v.getBoundingClientRect())??null,c("exiting")),y.current=n},[n,s,o]),E.useEffect(()=>{if(o!=="entering")return;const x=requestAnimationFrame(()=>{requestAnimationFrame(()=>c("open"))});return()=>cancelAnimationFrame(x)},[o]),E.useEffect(()=>{if(o)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o]),E.useEffect(()=>{if(!o)return;const x=v=>{v.key==="Escape"&&t()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[o,t]);const g=E.useCallback(x=>{x.propertyName==="transform"&&o==="exiting"&&c(null)},[o]);if(E.useEffect(()=>{if(o!=="exiting")return;const x=setTimeout(()=>c(null),fd+50);return()=>clearTimeout(x)},[o]),!o)return null;const u=o==="entering"||o==="exiting",d=u?DT(m.current):"none",b=u?0:1;return Wd.createPortal(h.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${fd}ms ${$b}, opacity ${fd}ms ${$b}`,transform:d,opacity:b,backgroundColor:"rgb(var(--lt-surface))"},onTransitionEnd:g,children:i}),document.body)}function LT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h8M4 18h12"})})}function qT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7l-5 5 5 5M16 7l5 5-5 5"})})}function BT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.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 PT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}function UT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.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 zT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.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 IT(n){const t=n.trim().split(`
57
- `);if(t.length<2)return n;const s=y=>y.split("|").map(g=>g.trim()).filter(Boolean),i=s(t[0]),o=t.slice(2),c=i.map(y=>`<th class="px-3 py-1.5 text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary">${y}</th>`).join(""),m=o.map(y=>`<tr class="border-t border-surface-border">${s(y).map(d=>`<td class="px-3 py-1.5 text-xs text-text-secondary">${d}</td>`).join("")}</tr>`).join("");return`<table class="w-full my-3 text-xs"><thead><tr class="border-b border-surface-border">${c}</tr></thead><tbody>${m}</tbody></table>`}function Qc(n){return n.toLowerCase().replace(/<[^>]+>/g,"").replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").trim()}function $T(n){const t=[];let s=n.replace(/```(\w*)\n([\s\S]*?)```/g,(g,u,d)=>{const b=t.length;return t.push(`<pre class="bg-surface-sunken rounded p-3 my-2 overflow-x-auto text-2xs leading-relaxed"><code>${d}</code></pre>`),`\0CODE${b}\0`});const i=/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm;s=s.replace(i,(g,u,d,b)=>IT(`${u}
53
+ ${y.stack}`),m.reject(u)):m.resolve(d))}});return g.requestSubject=t,this.protocol.publish(t,s,{reply:c,headers:i.headers}),m}else{const c=new px(this.protocol.muxSubscriptions,t,i,o);this.protocol.request(c);try{this.publish(t,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${c.token}`,headers:i.headers})}catch(y){c.cancel(y)}const m=Promise.race([c.timer,c.deferred]);return m.catch(()=>{c.cancel()}),m}}flush(){return this.isClosed()?Promise.reject(ye.errorForCode(ue.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(ye.errorForCode(ue.ConnectionClosed)):this.isDraining()?Promise.reject(ye.errorForCode(ue.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const t=this.protocol.getServer();return t?t.listen:""}status(){const t=new Bt;return t.iterClosed.then(()=>{const s=this.listeners.indexOf(t);this.listeners.splice(s,1)}),this.listeners.push(t),t}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request("$SYS.REQ.USER.INFO")).json((s,i)=>s==="time"?new Date(Date.parse(i)):i)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(t={}){const s=new D2(this,t);if(t.checkAPI!==!1)try{await s.getAccountInfo()}catch(i){const o=i;throw o.code===ue.NoResponders&&(o.code=ue.JetStreamNotEnabled),o}return s}jetstream(t={}){return new cm(this,t)}getServerVersion(){const t=this.info;return t?Zs(t.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw ye.errorForCode(ue.Disconnect);const t=Date.now();return await this.flush(),Date.now()-t}get features(){return this.protocol.features}get services(){return this._services||(this._services=new P2(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(ye.errorForCode(ue.ConnectionClosed)):this.isDraining()?Promise.reject(ye.errorForCode(ue.ConnectionDraining)):this.protocol.reconnect()}}class P2{constructor(t){j(this,"nc");this.nc=t}add(t){try{return new Co(this.nc,t).start()}catch(s){return Promise.reject(s)}}client(t,s){return new g2(this.nc,t,s)}}class U2{constructor(t,s,i){j(this,"bucket");j(this,"sm");j(this,"prefixLen");this.bucket=t,this.prefixLen=s,this.sm=i}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(yu)||"PUT"}get length(){const t=this.sm.header.get(Qt.MessageSizeHdr)||"";return t!==""?parseInt(t,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class z2{constructor(t,s,i){j(this,"bucket");j(this,"key");j(this,"sm");this.bucket=t,this.key=s,this.sm=i}get value(){return this.sm.data}get created(){return new Date(sm(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var t;return((t=this.sm.headers)==null?void 0:t.get(yu))||"PUT"}get delta(){return this.sm.info.pending}get length(){var s;const t=((s=this.sm.headers)==null?void 0:s.get(Qt.MessageSizeHdr))||"";return t!==""?parseInt(t,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Ox extends NE{constructor(s,i,o){super(s.nc,i,o);j(this,"js");j(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 i=Rr(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,i);const c=this.info;c.config.name=Es.next(),c.ordered_consumer_sequence.delivery_seq=0,c.flow_control.heartbeat_count=0,c.flow_control.fc_count=0,c.flow_control.consumer_restarts++,c.deliver=i,c.config.deliver_subject=i,c.config.deliver_policy=Et.StartSequence,c.config.opt_start_seq=s;const m={};m.stream_name=this.info.stream,m.config=c.config;const y=`${c.api.prefix}.CONSUMER.CREATE.${c.stream}`;this.js._request(y,m,{retries:-1}).then(g=>{const u=g,d=this.sub.info;d.last=u,this.info.config=u.config,this.info.name=u.name}).catch(g=>{const u=new ye(`unable to recreate ordered consumer ${c.stream} at seq ${s}`,ue.RequestError,g);this.sub.callback(u,{})})}_maybeSetupHbMonitoring(){var i,o;const s=((o=(i=this.info)==null?void 0:i.config)==null?void 0:o.idle_heartbeat)||0;s&&this._setupHbMonitoring(sm(s))}_setupHbMonitoring(s,i=0){const o={cancelAfter:0,maxOut:2};i&&(o.cancelAfter=i);const c=this.sub,m=y=>{var d,b,x,v;const g=cE(409,`${zn.IdleHeartbeatMissed}: ${y}`,this.sub.subject);if(!((d=this.info)==null?void 0:d.ordered))this.sub.callback(null,g);else{if(!this.js.nc.protocol.connected)return!1;const w=((x=(b=this.info)==null?void 0:b.ordered_consumer_sequence)==null?void 0:x.stream_seq)||0;return this._resetOrderedConsumer(w+1),(v=this.monitor)==null||v.restart(),!1}return!c.noIterator};this.monitor=new am(s,m,o)}_checkHbOrderConsumer(s){const i=s.headers.get(Qt.ConsumerStalledHdr);i!==""&&this.js.nc.publish(i);const o=parseInt(s.headers.get(Qt.LastConsumerSeqHdr),10),c=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,o!==c.delivery_seq&&this._resetOrderedConsumer(c.stream_seq+1),!1}_checkOrderedConsumer(s){const i=this.info.ordered_consumer_sequence,o=s.info.streamSequence,c=s.info.deliverySequence;return c!=i.delivery_seq+1?(this._resetOrderedConsumer(i.stream_seq+1),!1):(i.delivery_seq=c,i.stream_seq=o,!0)}async destroy(){this.isClosed()||await this.drain();const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.DELETE.${s.stream}.${i}`;await s.api._request(o)}async consumerInfo(){const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.INFO.${s.stream}.${i}`,c=await s.api._request(o);return s.last=c,c}}class I2 extends Ox{constructor(t,s,i){super(t,s,i)}pull(t={batch:1}){const{stream:s,config:i,name:o}=this.sub.info,c=i.durable_name??o,m={};if(m.batch=t.batch||1,m.no_wait=t.no_wait||!1,(t.max_bytes??0)>0){const u=this.js.nc.features.get(Ke.JS_PULL_MAX_BYTES);if(!u.ok)throw new Error(`max_bytes is only supported on servers ${u.min} or better`);m.max_bytes=t.max_bytes}let y=0;t.expires&&t.expires>0&&(y=t.expires,m.expires=mt(y));let g=0;if(t.idle_heartbeat&&t.idle_heartbeat>0&&(g=t.idle_heartbeat,m.idle_heartbeat=mt(g)),g&&y===0)throw new Error("idle_heartbeat requires expires");if(g>y)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),y&&g&&(this.monitor?this.monitor._change(g,y):this._setupHbMonitoring(g,y));const u=this.info.api,d=`${u.prefix}.CONSUMER.MSG.NEXT.${s}.${c}`,b=this.sub.subject;u.nc.publish(d,u.jc.encode(m),{reply:b})}}}function $2(n,t){return n?F2(t):H2(t)}function H2(n){return(t,s)=>t?[t,null]:(t=Ji(s),t?[t,null]:[null,Oo(s,n)])}function F2(n){return(t,s)=>{if(t)return[t,null];const i=Ji(s);return i!==null?[Ax(i),null]:[null,Oo(s,n)]}}function Ax(n){if(n!==null)switch(n.code){case ue.JetStream404NoMessages:case ue.JetStream408RequestTimeout:return null;case ue.JetStream409:return uE(n)?n:null;default:return n}return null}function G2(n){n&&n.ack()}function V2(n){const t=n.split(".");if(t.length===9&&t.splice(2,0,"_",""),t.length<11||t[0]!=="$JS"||t[1]!=="ACK")throw new Error("not js message");const s={};return s.domain=t[2]==="_"?"":t[2],s.account_hash=t[3],s.stream=t[4],s.consumer=t[5],s.deliveryCount=parseInt(t[6],10),s.redeliveryCount=s.deliveryCount,s.redelivered=s.deliveryCount>1,s.streamSequence=parseInt(t[7],10),s.deliverySequence=parseInt(t[8],10),s.timestampNanos=parseInt(t[9],10),s.pending=parseInt(t[10],10),s}class Y2{constructor(t,s){j(this,"msg");j(this,"di");j(this,"didAck");j(this,"timeout");this.msg=t,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=V2(this.reply)),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(t){this.didAck||(this.didAck=!this.isWIP(t),this.msg.respond(t))}isWIP(t){return t.length===4&&t[0]===ro[0]&&t[1]===ro[1]&&t[2]===ro[2]&&t[3]===ro[3]}async ackAck(t){var i;t=t||{},t.timeout=t.timeout||this.timeout;const s=pt();if(this.didAck)s.resolve(!1);else if(this.didAck=!0,this.msg.reply){const c=this.msg.publisher,m=!((i=c.options)!=null&&i.noAsyncTraces),y=new px(c.muxSubscriptions,this.msg.reply,{timeout:t.timeout},m);c.request(y);try{c.publish(this.msg.reply,o1,{reply:`${c.muxSubscriptions.baseInbox}${y.token}`})}catch(g){y.cancel(g)}try{await Promise.race([y.timer,y.deferred]),s.resolve(!0)}catch(g){y.cancel(g),s.reject(g)}}else s.resolve(!1);return s}ack(){this.doAck(o1)}nak(t){let s=j2;t&&(s=bd().encode(`-NAK ${JSON.stringify({delay:mt(t)})}`)),this.doAck(s)}working(){this.doAck(ro)}next(t,s={batch:1}){const i={};i.batch=s.batch||1,i.no_wait=s.no_wait||!1,s.expires&&s.expires>0&&(i.expires=mt(s.expires));const o=Wn().encode(i),c=na.concat(k2,T2,o),m=t?{reply:t}:void 0;this.msg.respond(c,m)}term(t=""){let s=N2;(t==null?void 0:t.length)>0&&(s=bd().encode(`+TERM ${t}`)),this.doAck(s)}json(){return this.msg.json()}string(){return this.msg.string()}}const K2="1.30.3",J2="nats.ws";class X2{constructor(){j(this,"version");j(this,"lang");j(this,"closeError");j(this,"connected");j(this,"done");j(this,"socket");j(this,"options");j(this,"socketClosed");j(this,"encrypted");j(this,"peeked");j(this,"yields");j(this,"signal");j(this,"closedNotification");this.version=K2,this.lang=J2,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=pt(),this.closedNotification=pt()}async connect(t,s){const i=pt();if(s.tls)return i.reject(new ye("tls",ue.InvalidOption)),i;this.options=s;const o=t.src;if(s.wsFactory){const{socket:c,encrypted:m}=await s.wsFactory(t.src,s);this.socket=c,this.encrypted=m}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=c=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(c.data)),this.peeked){this.signal.resolve();return}const m=na.concat(...this.yields),y=LE(m);if(y!==""){const g=c2.exec(y);if(!g){s.debug&&console.error("!!!",sc(m)),i.reject(new Error("unexpected response from server"));return}try{const u=JSON.parse(g[1]);o2(u,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),i.resolve()}catch(u){i.reject(u);return}}},this.socket.onclose=c=>{if(this.isDiscarded())return;this.socketClosed=!0;let m;this.done||(c.wasClean||(m=new Error(c.reason)),this._closed(m))},this.socket.onerror=c=>{if(this.isDiscarded())return;const m=c,y=new ye(m.message,ue.Unknown,new Error(m.error));i.reject(y)},i}disconnect(){this._closed(void 0,!0)}async _closed(t,s=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=t,!t)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await sa(100);this.done=!0;try{this.socket.close(t?1002:1e3,t?t.message:void 0)}catch{}s&&this.closedNotification.resolve(t)}}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 t=this.yields;this.yields=[];for(let s=0;s<t.length;s++)this.options.debug&&console.info(`> ${sc(t[s])}`),yield t[s];if(this.done)break;this.yields.length===0&&(t.length=0,this.yields=t,this.signal=pt())}}isEncrypted(){return this.connected&&this.encrypted}send(t){if(!this.isDiscarded())try{this.socket.send(t.buffer),this.options.debug&&console.info(`< ${sc(t)}`);return}catch(s){this.options.debug&&console.error(`!!! ${sc(t)}: ${s}`)}}close(t){return this._closed(t,!1)}closed(){return this.closedNotification}isDiscarded(){return this.done?(this.discard(),!0):!1}discard(){var t;this.done=!0;try{(t=this.socket)==null||t.close()}catch{}}}function Q2(n,t){/^(.*:\/\/)(.*)/.test(n)||(typeof t=="boolean"?n=`${t===!0?"https":"http"}://${n}`:n=`https://${n}`);let i=new URL(n);const o=i.protocol.toLowerCase();o==="ws:"&&(t=!1),o==="wss:"&&(t=!0),o!=="https:"&&o!=="http"&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2"),i=new URL(`http://${n}`));let c,m;const y=i.hostname,g=i.pathname,u=i.search||"";switch(o){case"http:":case"ws:":case"nats:":m=i.port||"80",c="ws:";break;case"https:":case"wss:":case"tls:":m=i.port||"443",c="wss:";break;default:m=i.port||t===!0?"443":"80",c=t===!0?"wss:":"ws:";break}return`${c}//${y}:${m}${g}${u}`}function W2(n={}){return TE({defaultPort:443,urlParseFn:Q2,factory:()=>new X2}),um.connect(n)}const Z2=null,eO=null,Xt="lt.events";function jx(n,t){const s=n.split("."),i=t.split(".");for(let o=0;o<i.length;o++){const c=i[o];if(c===">")return!0;if(o>=s.length||c!=="*"&&c!==s[o])return!1}return s.length===i.length}const ia=E.createContext({connected:!1,subscribe:()=>()=>{}});function kx(){const{connected:n}=E.useContext(ia);return{connected:n}}function On(n,t){const{subscribe:s}=E.useContext(ia),i=E.useRef(t);i.current=t,E.useEffect(()=>s(n,c=>i.current(c)),[s,n])}function ti(n,t){const{subscribe:s}=E.useContext(ia),i=E.useRef(t);i.current=t;const o=n.join(","),c=E.useMemo(()=>o.split(",").filter(Boolean),[o]);E.useEffect(()=>{const m=g=>i.current(g),y=c.map(g=>s(g,m));return()=>y.forEach(g=>g())},[s,c])}const tO=E.createContext({connected:!1,subscribe:()=>()=>{}}),nO=bd();function rO({children:n,url:t,token:s}){const i=E.useRef(null),[o,c]=E.useState(!1),m=E.useRef(null),y=E.useRef(new Map),g=E.useRef(new Map),u=E.useCallback((v,w)=>{(async()=>{for await(const S of w)try{if(!jx(S.subject,v))continue;const C=JSON.parse(nO.decode(S.data)),q=y.current.get(v);if(!q)continue;for(const B of q)try{B(C)}catch{}}catch{}})()},[]),d=E.useCallback(v=>{var S;const w=i.current;if(!(!w||(S=w.isClosed)!=null&&S.call(w)||g.current.has(v)))try{const C=w.subscribe(v);g.current.set(v,C),u(v,C)}catch{}},[u]),b=E.useCallback((v,w)=>{const S=y.current;return S.has(v)||S.set(v,new Set),S.get(v).add(w),d(v),()=>{const C=S.get(v);if(C&&(C.delete(w),C.size===0)){S.delete(v);const q=g.current.get(v);if(q){g.current.delete(v);try{q.unsubscribe()}catch{}}}}},[d]),x=E.useCallback(async()=>{try{if(i.current)return;const v=t||Z2;if(!v){console.error("[lt-nats] no NATS WebSocket URL configured — set NATS_WS_URL on the server");return}const w=await W2({servers:v,token:s||eO||void 0,reconnect:!0,maxReconnectAttempts:-1,reconnectTimeWait:2e3});i.current=w,c(!0);for(const S of y.current.keys())d(S);(async()=>{for await(const S of w.status())S.type==="disconnect"?c(!1):S.type==="reconnect"&&c(!0)})()}catch{c(!1),m.current=setTimeout(x,3e3)}},[d]);return E.useEffect(()=>(x(),()=>{m.current&&clearTimeout(m.current);for(const v of g.current.values())try{v.unsubscribe()}catch{}g.current.clear(),i.current&&(i.current.close().catch(()=>{}),i.current=null),c(!1)}),[x]),h.jsx(tO.Provider,{value:{connected:o,subscribe:b},children:h.jsx(ia.Provider,{value:{connected:o,subscribe:b},children:n})})}const lr=Object.create(null);lr.open="0";lr.close="1";lr.ping="2";lr.pong="3";lr.message="4";lr.upgrade="5";lr.noop="6";const su=Object.create(null);Object.keys(lr).forEach(n=>{su[lr[n]]=n});const Md={type:"error",data:"parser error"},Nx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Tx=typeof ArrayBuffer=="function",Cx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,fm=({type:n,data:t},s,i)=>Nx&&t instanceof Blob?s?i(t):c1(t,i):Tx&&(t instanceof ArrayBuffer||Cx(t))?s?i(t):c1(new Blob([t]),i):i(lr[n]+(t||"")),c1=(n,t)=>{const s=new FileReader;return s.onload=function(){const i=s.result.split(",")[1];t("b"+(i||""))},s.readAsDataURL(n)};function u1(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let nd;function sO(n,t){if(Nx&&n.data instanceof Blob)return n.data.arrayBuffer().then(u1).then(t);if(Tx&&(n.data instanceof ArrayBuffer||Cx(n.data)))return t(u1(n.data));fm(n,!1,s=>{nd||(nd=new TextEncoder),t(nd.encode(s))})}const f1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",yo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<f1.length;n++)yo[f1.charCodeAt(n)]=n;const iO=n=>{let t=n.length*.75,s=n.length,i,o=0,c,m,y,g;n[n.length-1]==="="&&(t--,n[n.length-2]==="="&&t--);const u=new ArrayBuffer(t),d=new Uint8Array(u);for(i=0;i<s;i+=4)c=yo[n.charCodeAt(i)],m=yo[n.charCodeAt(i+1)],y=yo[n.charCodeAt(i+2)],g=yo[n.charCodeAt(i+3)],d[o++]=c<<2|m>>4,d[o++]=(m&15)<<4|y>>2,d[o++]=(y&3)<<6|g&63;return u},aO=typeof ArrayBuffer=="function",hm=(n,t)=>{if(typeof n!="string")return{type:"message",data:Mx(n,t)};const s=n.charAt(0);return s==="b"?{type:"message",data:oO(n.substring(1),t)}:su[s]?n.length>1?{type:su[s],data:n.substring(1)}:{type:su[s]}:Md},oO=(n,t)=>{if(aO){const s=iO(n);return Mx(s,t)}else return{base64:!0,data:n}},Mx=(n,t)=>{switch(t){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Rx="",lO=(n,t)=>{const s=n.length,i=new Array(s);let o=0;n.forEach((c,m)=>{fm(c,!1,y=>{i[m]=y,++o===s&&t(i.join(Rx))})})},cO=(n,t)=>{const s=n.split(Rx),i=[];for(let o=0;o<s.length;o++){const c=hm(s[o],t);if(i.push(c),c.type==="error")break}return i};function uO(){return new TransformStream({transform(n,t){sO(n,s=>{const i=s.length;let o;if(i<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,i);else if(i<65536){o=new Uint8Array(3);const c=new DataView(o.buffer);c.setUint8(0,126),c.setUint16(1,i)}else{o=new Uint8Array(9);const c=new DataView(o.buffer);c.setUint8(0,127),c.setBigUint64(1,BigInt(i))}n.data&&typeof n.data!="string"&&(o[0]|=128),t.enqueue(o),t.enqueue(s)})}})}let rd;function lc(n){return n.reduce((t,s)=>t+s.length,0)}function cc(n,t){if(n[0].length===t)return n.shift();const s=new Uint8Array(t);let i=0;for(let o=0;o<t;o++)s[o]=n[0][i++],i===n[0].length&&(n.shift(),i=0);return n.length&&i<n[0].length&&(n[0]=n[0].slice(i)),s}function fO(n,t){rd||(rd=new TextDecoder);const s=[];let i=0,o=-1,c=!1;return new TransformStream({transform(m,y){for(s.push(m);;){if(i===0){if(lc(s)<1)break;const g=cc(s,1);c=(g[0]&128)===128,o=g[0]&127,o<126?i=3:o===126?i=1:i=2}else if(i===1){if(lc(s)<2)break;const g=cc(s,2);o=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),i=3}else if(i===2){if(lc(s)<8)break;const g=cc(s,8),u=new DataView(g.buffer,g.byteOffset,g.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){y.enqueue(Md);break}o=d*Math.pow(2,32)+u.getUint32(4),i=3}else{if(lc(s)<o)break;const g=cc(s,o);y.enqueue(hm(c?g:rd.decode(g),t)),i=0}if(o===0||o>n){y.enqueue(Md);break}}}})}const Dx=4;function Tt(n){if(n)return hO(n)}function hO(n){for(var t in Tt.prototype)n[t]=Tt.prototype[t];return n}Tt.prototype.on=Tt.prototype.addEventListener=function(n,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(t),this};Tt.prototype.once=function(n,t){function s(){this.off(n,s),t.apply(this,arguments)}return s.fn=t,this.on(n,s),this};Tt.prototype.off=Tt.prototype.removeListener=Tt.prototype.removeAllListeners=Tt.prototype.removeEventListener=function(n,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+n];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,o=0;o<s.length;o++)if(i=s[o],i===t||i.fn===t){s.splice(o,1);break}return s.length===0&&delete this._callbacks["$"+n],this};Tt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),s=this._callbacks["$"+n],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(s){s=s.slice(0);for(var i=0,o=s.length;i<o;++i)s[i].apply(this,t)}return this};Tt.prototype.emitReserved=Tt.prototype.emit;Tt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};Tt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const ju=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,s)=>s(t,0),In=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),dO="arraybuffer";function Lx(n,...t){return t.reduce((s,i)=>(n.hasOwnProperty(i)&&(s[i]=n[i]),s),{})}const mO=In.setTimeout,pO=In.clearTimeout;function ku(n,t){t.useNativeTimers?(n.setTimeoutFn=mO.bind(In),n.clearTimeoutFn=pO.bind(In)):(n.setTimeoutFn=In.setTimeout.bind(In),n.clearTimeoutFn=In.clearTimeout.bind(In))}const yO=1.33;function gO(n){return typeof n=="string"?bO(n):Math.ceil((n.byteLength||n.size)*yO)}function bO(n){let t=0,s=0;for(let i=0,o=n.length;i<o;i++)t=n.charCodeAt(i),t<128?s+=1:t<2048?s+=2:t<55296||t>=57344?s+=3:(i++,s+=4);return s}function qx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function xO(n){let t="";for(let s in n)n.hasOwnProperty(s)&&(t.length&&(t+="&"),t+=encodeURIComponent(s)+"="+encodeURIComponent(n[s]));return t}function vO(n){let t={},s=n.split("&");for(let i=0,o=s.length;i<o;i++){let c=s[i].split("=");t[decodeURIComponent(c[0])]=decodeURIComponent(c[1])}return t}class _O extends Error{constructor(t,s,i){super(t),this.description=s,this.context=i,this.type="TransportError"}}class dm extends Tt{constructor(t){super(),this.writable=!1,ku(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,s,i){return super.emitReserved("error",new _O(t,s,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const s=hm(t,this.socket.binaryType);this.onPacket(s)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,s={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(s)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_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(t){const s=xO(t);return s.length?"?"+s:""}}class wO extends dm{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const s=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let i=0;this._polling&&(i++,this.once("pollComplete",function(){--i||s()})),this.writable||(i++,this.once("drain",function(){--i||s()}))}else s()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const s=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};cO(t,this.socket.binaryType).forEach(s),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,lO(t,s=>{this.doWrite(s,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",s=this.query||{};return this.opts.timestampRequests!==!1&&(s[this.opts.timestampParam]=qx()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(t,s)}}let Bx=!1;try{Bx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const SO=Bx;function EO(){}class OO extends wO{constructor(t){if(super(t),typeof location<"u"){const s=location.protocol==="https:";let i=location.port;i||(i=s?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||i!==t.port}}doWrite(t,s){const i=this.request({method:"POST",data:t});i.on("success",s),i.on("error",(o,c)=>{this.onError("xhr post error",o,c)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(s,i)=>{this.onError("xhr poll error",s,i)}),this.pollXhr=t}}class or extends Tt{constructor(t,s,i){super(),this.createRequest=t,ku(this,i),this._opts=i,this._method=i.method||"GET",this._uri=s,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var t;const s=Lx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(s);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&i.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var o;i.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(i.getResponseHeader("set-cookie"))),i.readyState===4&&(i.status===200||i.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof i.status=="number"?i.status:0)},0))},i.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=or.requestsCount++,or.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=EO,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete or.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}or.requestsCount=0;or.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",h1);else if(typeof addEventListener=="function"){const n="onpagehide"in In?"pagehide":"unload";addEventListener(n,h1,!1)}}function h1(){for(let n in or.requests)or.requests.hasOwnProperty(n)&&or.requests[n].abort()}const AO=(function(){const n=Px({xdomain:!1});return n&&n.responseType!==null})();class jO extends OO{constructor(t){super(t);const s=t&&t.forceBase64;this.supportsBinary=AO&&!s}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new or(Px,this.uri(),t)}}function Px(n){const t=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||SO))return new XMLHttpRequest}catch{}if(!t)try{return new In[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Ux=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class kO extends dm{get name(){return"websocket"}doOpen(){const t=this.uri(),s=this.opts.protocols,i=Ux?{}:Lx(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,s,i)}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=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let s=0;s<t.length;s++){const i=t[s],o=s===t.length-1;fm(i,this.supportsBinary,c=>{try{this.doWrite(i,c)}catch{}o&&ju(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",s=this.query||{};return this.opts.timestampRequests&&(s[this.opts.timestampParam]=qx()),this.supportsBinary||(s.b64=1),this.createUri(t,s)}}const sd=In.WebSocket||In.MozWebSocket;class NO extends kO{createSocket(t,s,i){return Ux?new sd(t,s,i):s?new sd(t,s):new sd(t)}doWrite(t,s){this.ws.send(s)}}class TO extends dm{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const s=fO(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=t.readable.pipeThrough(s).getReader(),o=uO();o.readable.pipeTo(t.writable),this._writer=o.writable.getWriter();const c=()=>{i.read().then(({done:y,value:g})=>{y||(this.onPacket(g),c())}).catch(y=>{})};c();const m={type:"open"};this.query.sid&&(m.data=`{"sid":"${this.query.sid}"}`),this._writer.write(m).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let s=0;s<t.length;s++){const i=t[s],o=s===t.length-1;this._writer.write(i).then(()=>{o&&ju(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const CO={websocket:NO,webtransport:TO,polling:jO},MO=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,RO=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Rd(n){if(n.length>8e3)throw"URI too long";const t=n,s=n.indexOf("["),i=n.indexOf("]");s!=-1&&i!=-1&&(n=n.substring(0,s)+n.substring(s,i).replace(/:/g,";")+n.substring(i,n.length));let o=MO.exec(n||""),c={},m=14;for(;m--;)c[RO[m]]=o[m]||"";return s!=-1&&i!=-1&&(c.source=t,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c.pathNames=DO(c,c.path),c.queryKey=LO(c,c.query),c}function DO(n,t){const s=/\/{2,9}/g,i=t.replace(s,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&i.splice(0,1),t.slice(-1)=="/"&&i.splice(i.length-1,1),i}function LO(n,t){const s={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,o,c){o&&(s[o]=c)}),s}const Dd=typeof addEventListener=="function"&&typeof removeEventListener=="function",iu=[];Dd&&addEventListener("offline",()=>{iu.forEach(n=>n())},!1);class ws extends Tt{constructor(t,s){if(super(),this.binaryType=dO,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(s=t,t=null),t){const i=Rd(t);s.hostname=i.host,s.secure=i.protocol==="https"||i.protocol==="wss",s.port=i.port,i.query&&(s.query=i.query)}else s.host&&(s.hostname=Rd(s.host).host);ku(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(i=>{const o=i.prototype.name;this.transports.push(o),this._transportsByName[o]=i}),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=vO(this.opts.query)),Dd&&(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"})},iu.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const s=Object.assign({},this.opts.query);s.EIO=Dx,s.transport=t,this.id&&(s.sid=this.id);const i=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&ws.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const s=this.createTransport(t);s.open(),this.setTransport(s)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.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",ws.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.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=t.data,this._onError(s);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),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 t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let s=1;for(let i=0;i<this.writeBuffer.length;i++){const o=this.writeBuffer[i].data;if(o&&(s+=gO(o)),i>0&&s>this._maxPayload)return this.writeBuffer.slice(0,i);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ju(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,s,i){return this._sendPacket("message",t,s,i),this}send(t,s,i){return this._sendPacket("message",t,s,i),this}_sendPacket(t,s,i,o){if(typeof s=="function"&&(o=s,s=void 0),typeof i=="function"&&(o=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;const c={type:t,data:s,options:i};this.emitReserved("packetCreate",c),this.writeBuffer.push(c),o&&this.once("flush",o),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),t()},i=()=>{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?i():t()}):this.upgrading?i():t()),this}_onError(t){if(ws.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,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(),Dd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=iu.indexOf(this._offlineEventListener);i!==-1&&iu.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,s),this.writeBuffer=[],this._prevBufferLen=0}}}ws.protocol=Dx;class qO extends ws{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let s=this.createTransport(t),i=!1;ws.priorWebsocketSuccess=!1;const o=()=>{i||(s.send([{type:"ping",data:"probe"}]),s.once("packet",b=>{if(!i)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",s),!s)return;ws.priorWebsocketSuccess=s.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(d(),this.setTransport(s),s.send([{type:"upgrade"}]),this.emitReserved("upgrade",s),s=null,this.upgrading=!1,this.flush())})}else{const x=new Error("probe error");x.transport=s.name,this.emitReserved("upgradeError",x)}}))};function c(){i||(i=!0,d(),s.close(),s=null)}const m=b=>{const x=new Error("probe error: "+b);x.transport=s.name,c(),this.emitReserved("upgradeError",x)};function y(){m("transport closed")}function g(){m("socket closed")}function u(b){s&&b.name!==s.name&&c()}const d=()=>{s.removeListener("open",o),s.removeListener("error",m),s.removeListener("close",y),this.off("close",g),this.off("upgrading",u)};s.once("open",o),s.once("error",m),s.once("close",y),this.once("close",g),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{i||s.open()},200):s.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const s=[];for(let i=0;i<t.length;i++)~this.transports.indexOf(t[i])&&s.push(t[i]);return s}}let BO=class extends qO{constructor(t,s={}){const i=typeof t=="object"?t:s;(!i.transports||i.transports&&typeof i.transports[0]=="string")&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(o=>CO[o]).filter(o=>!!o)),super(t,i)}};function PO(n,t="",s){let i=n;s=s||typeof location<"u"&&location,n==null&&(n=s.protocol+"//"+s.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=s.protocol+n:n=s.host+n),/^(https?|wss?):\/\//.test(n)||(typeof s<"u"?n=s.protocol+"//"+n:n="https://"+n),i=Rd(n)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const c=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+c+":"+i.port+t,i.href=i.protocol+"://"+c+(s&&s.port===i.port?"":":"+i.port),i}const UO=typeof ArrayBuffer=="function",zO=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,zx=Object.prototype.toString,IO=typeof Blob=="function"||typeof Blob<"u"&&zx.call(Blob)==="[object BlobConstructor]",$O=typeof File=="function"||typeof File<"u"&&zx.call(File)==="[object FileConstructor]";function mm(n){return UO&&(n instanceof ArrayBuffer||zO(n))||IO&&n instanceof Blob||$O&&n instanceof File}function au(n,t){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let s=0,i=n.length;s<i;s++)if(au(n[s]))return!0;return!1}if(mm(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return au(n.toJSON(),!0);for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&au(n[s]))return!0;return!1}function HO(n){const t=[],s=n.data,i=n;return i.data=Ld(s,t),i.attachments=t.length,{packet:i,buffers:t}}function Ld(n,t){if(!n)return n;if(mm(n)){const s={_placeholder:!0,num:t.length};return t.push(n),s}else if(Array.isArray(n)){const s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]=Ld(n[i],t);return s}else if(typeof n=="object"&&!(n instanceof Date)){const s={};for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=Ld(n[i],t));return s}return n}function FO(n,t){return n.data=qd(n.data,t),delete n.attachments,n}function qd(n,t){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<t.length)return t[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let s=0;s<n.length;s++)n[s]=qd(n[s],t);else if(typeof n=="object")for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]=qd(n[s],t));return n}const GO=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ge;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ge||(Ge={}));class VO{constructor(t){this.replacer=t}encode(t){return(t.type===Ge.EVENT||t.type===Ge.ACK)&&au(t)?this.encodeAsBinary({type:t.type===Ge.EVENT?Ge.BINARY_EVENT:Ge.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let s=""+t.type;return(t.type===Ge.BINARY_EVENT||t.type===Ge.BINARY_ACK)&&(s+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(s+=t.nsp+","),t.id!=null&&(s+=t.id),t.data!=null&&(s+=JSON.stringify(t.data,this.replacer)),s}encodeAsBinary(t){const s=HO(t),i=this.encodeAsString(s.packet),o=s.buffers;return o.unshift(i),o}}class pm extends Tt{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let s;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");s=this.decodeString(t);const i=s.type===Ge.BINARY_EVENT;i||s.type===Ge.BINARY_ACK?(s.type=i?Ge.EVENT:Ge.ACK,this.reconstructor=new YO(s),s.attachments===0&&super.emitReserved("decoded",s)):super.emitReserved("decoded",s)}else if(mm(t)||t.base64)if(this.reconstructor)s=this.reconstructor.takeBinaryData(t),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: "+t)}decodeString(t){let s=0;const i={type:Number(t.charAt(0))};if(Ge[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===Ge.BINARY_EVENT||i.type===Ge.BINARY_ACK){const c=s+1;for(;t.charAt(++s)!=="-"&&s!=t.length;);const m=t.substring(c,s);if(m!=Number(m)||t.charAt(s)!=="-")throw new Error("Illegal attachments");const y=Number(m);if(!KO(y)||y<0)throw new Error("Illegal attachments");if(y>this.opts.maxAttachments)throw new Error("too many attachments");i.attachments=y}if(t.charAt(s+1)==="/"){const c=s+1;for(;++s&&!(t.charAt(s)===","||s===t.length););i.nsp=t.substring(c,s)}else i.nsp="/";const o=t.charAt(s+1);if(o!==""&&Number(o)==o){const c=s+1;for(;++s;){const m=t.charAt(s);if(m==null||Number(m)!=m){--s;break}if(s===t.length)break}i.id=Number(t.substring(c,s+1))}if(t.charAt(++s)){const c=this.tryParse(t.substr(s));if(pm.isPayloadValid(i.type,c))i.data=c;else throw new Error("invalid payload")}return i}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,s){switch(t){case Ge.CONNECT:return d1(s);case Ge.DISCONNECT:return s===void 0;case Ge.CONNECT_ERROR:return typeof s=="string"||d1(s);case Ge.EVENT:case Ge.BINARY_EVENT:return Array.isArray(s)&&(typeof s[0]=="number"||typeof s[0]=="string"&&GO.indexOf(s[0])===-1);case Ge.ACK:case Ge.BINARY_ACK:return Array.isArray(s)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class YO{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const s=FO(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const KO=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function d1(n){return Object.prototype.toString.call(n)==="[object Object]"}const JO=Object.freeze(Object.defineProperty({__proto__:null,Decoder:pm,Encoder:VO,get PacketType(){return Ge}},Symbol.toStringTag,{value:"Module"}));function Xn(n,t,s){return n.on(t,s),function(){n.off(t,s)}}const XO=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Ix extends Tt{constructor(t,s,i){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=t,this.nsp=s,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Xn(t,"open",this.onopen.bind(this)),Xn(t,"packet",this.onpacket.bind(this)),Xn(t,"error",this.onerror.bind(this)),Xn(t,"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(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...s){var i,o,c;if(XO.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(s.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(s),this;const m={type:Ge.EVENT,data:s};if(m.options={},m.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const d=this.ids++,b=s.pop();this._registerAckCallback(d,b),m.id=d}const y=(o=(i=this.io.engine)===null||i===void 0?void 0:i.transport)===null||o===void 0?void 0:o.writable,g=this.connected&&!(!((c=this.io.engine)===null||c===void 0)&&c._hasPingExpired());return this.flags.volatile&&!y||(g?(this.notifyOutgoingListeners(m),this.packet(m)):this.sendBuffer.push(m)),this.flags={},this}_registerAckCallback(t,s){var i;const o=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(o===void 0){this.acks[t]=s;return}const c=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let y=0;y<this.sendBuffer.length;y++)this.sendBuffer[y].id===t&&this.sendBuffer.splice(y,1);s.call(this,new Error("operation has timed out"))},o),m=(...y)=>{this.io.clearTimeoutFn(c),s.apply(this,y)};m.withError=!0,this.acks[t]=m}emitWithAck(t,...s){return new Promise((i,o)=>{const c=(m,y)=>m?o(m):i(y);c.withError=!0,s.push(c),this.emit(t,...s)})}_addToQueue(t){let s;typeof t[t.length-1]=="function"&&(s=t.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((o,...c)=>(this._queue[0],o!==null?i.tryCount>this._opts.retries&&(this._queue.shift(),s&&s(o)):(this._queue.shift(),s&&s(null,...c)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const s=this._queue[0];s.pending&&!t||(s.pending=!0,s.tryCount++,this.flags=s.flags,this.emit.apply(this,s.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:Ge.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,s){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,s),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(i=>String(i.id)===t)){const i=this.acks[t];delete this.acks[t],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Ge.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.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 Ge.EVENT:case Ge.BINARY_EVENT:this.onevent(t);break;case Ge.ACK:case Ge.BINARY_ACK:this.onack(t);break;case Ge.DISCONNECT:this.ondisconnect();break;case Ge.CONNECT_ERROR:this.destroy();const i=new Error(t.data.message);i.data=t.data.data,this.emitReserved("connect_error",i);break}}onevent(t){const s=t.data||[];t.id!=null&&s.push(this.ack(t.id)),this.connected?this.emitEvent(s):this.receiveBuffer.push(Object.freeze(s))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const s=this._anyListeners.slice();for(const i of s)i.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const s=this;let i=!1;return function(...o){i||(i=!0,s.packet({type:Ge.ACK,id:t,data:o}))}}onack(t){const s=this.acks[t.id];typeof s=="function"&&(delete this.acks[t.id],s.withError&&t.data.unshift(null),s.apply(this,t.data))}onconnect(t,s){this.id=t,this.recovered=s&&this._pid===s,this._pid=s,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ge.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const s=this._anyListeners;for(let i=0;i<s.length;i++)if(t===s[i])return s.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const s=this._anyOutgoingListeners;for(let i=0;i<s.length;i++)if(t===s[i])return s.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const s=this._anyOutgoingListeners.slice();for(const i of s)i.apply(this,t.data)}}}function aa(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}aa.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),s=Math.floor(t*this.jitter*n);n=(Math.floor(t*10)&1)==0?n-s:n+s}return Math.min(n,this.max)|0};aa.prototype.reset=function(){this.attempts=0};aa.prototype.setMin=function(n){this.ms=n};aa.prototype.setMax=function(n){this.max=n};aa.prototype.setJitter=function(n){this.jitter=n};class Bd extends Tt{constructor(t,s){var i;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(s=t,t=void 0),s=s||{},s.path=s.path||"/socket.io",this.opts=s,ku(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((i=s.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new aa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(s.timeout==null?2e4:s.timeout),this._readyState="closed",this.uri=t;const o=s.parser||JO;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=s.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var s;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(s=this.backoff)===null||s===void 0||s.setMin(t),this)}randomizationFactor(t){var s;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(s=this.backoff)===null||s===void 0||s.setJitter(t),this)}reconnectionDelayMax(t){var s;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(s=this.backoff)===null||s===void 0||s.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new BO(this.uri,this.opts);const s=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const o=Xn(s,"open",function(){i.onopen(),t&&t()}),c=y=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",y),t?t(y):this.maybeReconnectOnOpen()},m=Xn(s,"error",c);if(this._timeout!==!1){const y=this._timeout,g=this.setTimeoutFn(()=>{o(),c(new Error("timeout")),s.close()},y);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(o),this.subs.push(m),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Xn(t,"ping",this.onping.bind(this)),Xn(t,"data",this.ondata.bind(this)),Xn(t,"error",this.onerror.bind(this)),Xn(t,"close",this.onclose.bind(this)),Xn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(s){this.onclose("parse error",s)}}ondecoded(t){ju(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,s){let i=this.nsps[t];return i?this._autoConnect&&!i.active&&i.connect():(i=new Ix(this,t,s),this.nsps[t]=i),i}_destroy(t){const s=Object.keys(this.nsps);for(const i of s)if(this.nsps[i].active)return;this._close()}_packet(t){const s=this.encoder.encode(t);for(let i=0;i<s.length;i++)this.engine.write(s[i],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,s){var i;this.cleanup(),(i=this.engine)===null||i===void 0||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,s),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=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 i=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(o=>{o?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",o)):t.onreconnect()}))},s);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const so={};function ou(n,t){typeof n=="object"&&(t=n,n=void 0),t=t||{};const s=PO(n,t.path||"/socket.io"),i=s.source,o=s.id,c=s.path,m=so[o]&&c in so[o].nsps,y=t.forceNew||t["force new connection"]||t.multiplex===!1||m;let g;return y?g=new Bd(i,t):(so[o]||(so[o]=new Bd(i,t)),g=so[o]),s.query&&!t.query&&(t.query=s.queryKey),g.socket(s.path,t)}Object.assign(ou,{Manager:Bd,Socket:Ix,io:ou,connect:ou});const QO=E.createContext({connected:!1,subscribe:()=>()=>{}});function WO({children:n}){const{isAuthenticated:t}=Pt(),s=E.useRef(null),[i,o]=E.useState(!1),c=E.useRef(new Map),m=E.useCallback((g,u)=>{var b;const d=c.current;return d.has(g)||(d.set(g,new Set),(b=s.current)==null||b.emit("lt.subscribe",g)),d.get(g).add(u),()=>{var v;const x=d.get(g);x&&(x.delete(u),x.size===0&&(d.delete(g),(v=s.current)==null||v.emit("lt.unsubscribe",g)))}},[]),y=E.useCallback((g,u)=>{for(const[d,b]of c.current)if(jx(g,d))for(const x of b)try{x(u)}catch{}},[]);return E.useEffect(()=>{if(!t)return;const g=ou({path:`${Ht}/socket.io`,transports:["polling","websocket"],upgrade:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:2e3,auth:u=>{const d=lx();u(d?{token:d}:{})}});return s.current=g,console.log("[lt-socketio] connecting..."),g.on("connect",()=>{console.log("[lt-socketio] connected, id:",g.id),o(!0);for(const u of c.current.keys())g.emit("lt.subscribe",u)}),g.on("disconnect",u=>{console.log("[lt-socketio] disconnected:",u),o(!1)}),g.on("connect_error",u=>{console.warn("[lt-socketio] connect error:",u.message),o(!1)}),g.onAny((u,d)=>{if(u.startsWith("lt."))try{const b=typeof d=="string"?JSON.parse(d):d;y(u,b)}catch{}}),()=>{g.removeAllListeners(),g.disconnect(),s.current=null,o(!1)}},[y,t]),h.jsx(QO.Provider,{value:{connected:i,subscribe:m},children:h.jsx(ia.Provider,{value:{connected:i,subscribe:m},children:n})})}function ZO({children:n}){const{isAuthenticated:t}=Pt(),[s,i]=E.useState(null),[o,c]=E.useState({url:null,token:null});return E.useEffect(()=>{let m=!1;async function y(){var g;try{console.log("[lt-transport] detecting event transport...");const u=await nm(),d=(g=u==null?void 0:u.events)==null?void 0:g.transport;if(console.log("[lt-transport] server reports:",d),!m){if(d==="nats"){let b=u.events.natsWsUrl??null,x=null;const v=lx();if(v)try{const w=await fetch(`${Ht}/api/nats-credentials`,{headers:{Authorization:`Bearer ${v}`}});if(w.ok){const S=await w.json();b=S.natsWsUrl??b,x=S.natsToken??null}}catch{console.warn("[lt-transport] failed to fetch NATS credentials")}c({url:b,token:x})}i(d==="nats"?"nats":"socketio")}}catch(u){console.warn("[lt-transport] settings fetch error, falling back to socketio",u),m||i("socketio")}}return y(),()=>{m=!0}},[t]),s==="nats"?h.jsx(rO,{url:o.url,token:o.token,children:n}):s==="socketio"?h.jsx(WO,{children:n}):h.jsx(h.Fragment,{children:n})}const ym="lt_view_as",gm="lt_ai_override",Pd="lt_graph_enabled",Ud="lt_infrastructure_enabled",bm="lt_scan_override";function $x(){try{const n=localStorage.getItem(gm);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function eA(n){try{localStorage.setItem(gm,String(n))}catch{}}function tA(){try{localStorage.removeItem(gm)}catch{}}function xm(){try{const n=localStorage.getItem(ym);if(n==="admin"||n==="engineer"||n==="operator")return n}catch{}return null}function nA(n){try{localStorage.setItem(ym,n)}catch{}window.location.reload()}function zd(){try{localStorage.removeItem(ym)}catch{}window.location.reload()}function Hx(){try{return localStorage.getItem(Pd)==="true"}catch{return!1}}function rA(n){try{n?localStorage.setItem(Pd,"true"):localStorage.removeItem(Pd)}catch{}}function Fx(){try{return localStorage.getItem(Ud)==="true"}catch{return!1}}function sA(n){try{n?localStorage.setItem(Ud,"true"):localStorage.removeItem(Ud)}catch{}}function Gx(){try{const n=localStorage.getItem(bm);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function iA(n){try{localStorage.setItem(bm,String(n))}catch{}}function aA(){try{localStorage.removeItem(bm)}catch{}}function Vx(){const{isSuperAdmin:n,hasRoleType:t,hasRole:s}=Pt(),i=xm(),o=n||s("engineer"),c=t("admin"),m=n||t("admin");return{isBuilder:i?!1:o,isOps:i?i==="admin"||i==="engineer":c,canBulk:i?i==="admin":m,viewAs:i,realIsBuilder:o}}function Yx(){var u;const{isSuperAdmin:n,hasRoleType:t,hasRole:s}=Pt(),{data:i}=Zn(),o=((u=i==null?void 0:i.features)==null?void 0:u.publicPaceBoard)!==!1,c=n?"superadmin":t("admin")?"admin":s("engineer")?"engineer":"operator",m=xm(),y=m==="admin"||m==="engineer"||m==="operator"?m:null,g=y??c;return{tier:g,realTier:c,viewAs:y,canSeePaceBoard:o||g==="superadmin"||g==="admin",canSeeWorkflows:g==="superadmin"||g==="engineer",showTaskQueueCards:g==="operator"&&!o}}function Kx(n){return(n??"").replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"none"}function qr(n={}){const t=n.role?Kx(n.role):"*",s=n.id??"*",i=n.verb??">";return`${Xt}.system.escalation.${t}.${s}.${i}`}function Id(n){return n.verbs.map(t=>qr({role:n.role,verb:t}))}function vm(n){const{user:t,isSuperAdmin:s,hasRoleType:i}=Pt(),o=s||i("admin"),c=((t==null?void 0:t.roles)??[]).map(y=>y.role).sort().join(","),m=(n??[]).join(",");return E.useMemo(()=>{const y=m?m.split(","):null;return o||!c?y?Id({verbs:y}):[qr({})]:c.split(",").flatMap(g=>y?Id({role:g,verbs:y}):[qr({role:g})])},[o,c,m])}const $d="/escalations/detail/";function oA(n){return n.startsWith($d)&&n.slice($d.length).split("/")[0]||void 0}function lA(){const{user:n}=Pt(),t=ra(),s=an(),i=E.useRef(s.pathname);i.current=s.pathname;const o=E.useRef(n==null?void 0:n.userId);o.current=n==null?void 0:n.userId;const c=E.useCallback(m=>{var b,x,v;if((m==null?void 0:m.assignedAtCreation)!==!0)return;const y=(m==null?void 0:m.escalationId)??((b=m==null?void 0:m.data)==null?void 0:b.id),g=(x=m==null?void 0:m.data)==null?void 0:x.assigned_to,u=(v=m==null?void 0:m.data)==null?void 0:v.parent_id;if(!y||g!==o.current||!u||u!==oA(i.current))return;const d=`${$d}${y}`;i.current!==d&&t(d)},[t]);ti(vm(["claimed"]),c)}function cA(n){const t=n??[];return t.length>0&&t.every(s=>s.type==="member"&&s.write_scope==="none")}const _m={staleTime:5*6e4,refetchOnWindowFocus:!1};function D3(n={},t={}){const s=new URLSearchParams;return n.role&&s.set("role",n.role),n.roleType&&s.set("roleType",n.roleType),n.status&&s.set("status",n.status),n.search&&s.set("search",n.search),n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),$e({queryKey:["users",n],queryFn:()=>fe(`/users?${s}`),enabled:t.enabled??!0,..._m})}const m1=200;async function uA(n){const t=[];for(let s=0;s<n.length;s+=m1){const i=await fe("/users/names",{method:"POST",body:JSON.stringify({ids:n.slice(s,s+m1)})});t.push(...i.users??[])}return t}let Hd=[],Fd=new Map,Gd=!1;function fA(){const n=Hd,t=Fd;Hd=[],Fd=new Map,Gd=!1,uA(n).then(s=>{const i=new Map(s.map(o=>[o.id,o]));for(const[o,c]of t)c.resolve(i.get(o)??null)}).catch(s=>{for(const i of t.values())i.reject(s)})}function hA(n){return new Promise((t,s)=>{Hd.push(n),Fd.set(n,{resolve:t,reject:s}),Gd||(Gd=!0,setTimeout(fA,0))})}function L3(n){return $e({queryKey:["user-name",n],queryFn:()=>hA(n),enabled:!!n,..._m})}function dA(n){return $e({queryKey:["users",n,"roles"],queryFn:async()=>(await fe(`/users/${n}/roles`)).roles??[],enabled:!!n,..._m})}function q3(){const n=He();return Ve({mutationFn:t=>fe("/users",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function B3(){const n=He();return Ve({mutationFn:({id:t,...s})=>fe(`/users/${t}`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function P3(){const n=He();return Ve({mutationFn:({id:t,ops:s})=>fe(`/users/${t}/properties`,{method:"PATCH",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function U3(){return $e({queryKey:["users","system-property-keys"],queryFn:()=>fe("/users/system-property-keys")})}function z3(){const n=He();return Ve({mutationFn:t=>fe(`/users/${t}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function I3(){const n=He();return Ve({mutationFn:({userId:t,role:s,type:i,read_scope:o,write_scope:c})=>fe(`/users/${t}/roles`,{method:"POST",body:JSON.stringify({role:s,type:i,read_scope:o,write_scope:c})}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function $3(){const n=He();return Ve({mutationFn:({userId:t,role:s})=>fe(`/users/${t}/roles/${encodeURIComponent(s)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}const H3={MAX_PORTALS:12,MAX_ROWS:4,MAX_COLS:6,MAX_COUNTS:8};function mA(){return $e({queryKey:["roles"],queryFn:()=>fe("/roles")})}function Nu(n){return $e({queryKey:["roles","details"],queryFn:()=>fe("/roles/details"),enabled:(n==null?void 0:n.enabled)??!0})}function F3(n,t,s=!0){return $e({queryKey:["roles",n,"schema",t??"latest"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/schema${t!=null?`?version=${t}`:""}`),enabled:s&&!!n})}function G3(n){return $e({queryKey:["roles",n,"schema-versions"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/schema/versions`),enabled:!!n})}function V3(n,t,s=!0){return $e({queryKey:["roles",n,"list-schema",t??"latest"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/list-schema${t!=null?`?version=${t}`:""}`),enabled:s&&!!n})}function Y3(n){return $e({queryKey:["roles",n,"list-schema-versions"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/list-schema/versions`),enabled:!!n})}function K3(){const n=He();return Ve({mutationFn:t=>fe("/roles",{method:"POST",body:JSON.stringify({role:t})}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function J3(){const n=He();return Ve({mutationFn:({role:t,...s})=>fe(`/roles/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(s)}),onMutate:async({role:t,...s})=>{await n.cancelQueries({queryKey:["roles","details"]});const i=n.getQueryData(["roles","details"]);return i&&n.setQueryData(["roles","details"],{roles:i.roles.map(o=>o.role===t?{...o,...s}:o)}),{previous:i}},onError:(t,s,i)=>{i!=null&&i.previous&&n.setQueryData(["roles","details"],i.previous)},onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function X3(){const n=He();return Ve({mutationFn:t=>fe(`/roles/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}const Jx="lt:station:kiosk-role:";function Vd(n){return`${Jx}${n}`}const Yd=new Set;function pA(){for(const n of Yd)n()}function yA(n){try{return localStorage.getItem(Vd(n))}catch{return null}}function gA(n,t){try{t===null?localStorage.removeItem(Vd(n)):localStorage.setItem(Vd(n),t)}catch{}pA()}function bA(n){Yd.add(n);const t=s=>{(s.key===null||s.key.startsWith(Jx))&&n()};try{window.addEventListener("storage",t)}catch{}return()=>{Yd.delete(n);try{window.removeEventListener("storage",t)}catch{}}}function xA(n){return E.useSyncExternalStore(bA,()=>n?yA(n):null)}const gu="/portal";function vA(n){return n===gu||n.startsWith(`${gu}/`)}function wm(n,t){const s=`${gu}/${encodeURIComponent(n)}`;return t?`${s}/${encodeURIComponent(t)}`:s}function Wi(n){return Array.isArray(n==null?void 0:n.portals)?n.portals:[]}function _A(n){return Wi(n).length>0}function Q3(n,t){const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"portal",i=new Set(t);if(!i.has(s))return s;let o=2;for(;i.has(`${s}-${o}`);)o+=1;return`${s}-${o}`}function Xx(n,t){return t.length>0?wm(n,t[0].key):`/escalations/available?role=${encodeURIComponent(n)}&status=available`}function Sm(){const{user:n}=Pt(),t=(n==null?void 0:n.userId)??null,{data:s}=dA(t),{data:i}=Nu(),o=xA(t),c=E.useCallback(m=>{t&&gA(t,m)},[t]);return E.useMemo(()=>{const m={kiosk:!1,role:null,homePath:null,targets:[],selectable:!1,selectRole:c},y=s??[];if(y.length===0||y.some(v=>v.type!=="member"))return m;const g=v=>{var w;return(w=i==null?void 0:i.roles)==null?void 0:w.find(S=>S.role===v)},u=v=>{var w,S;return((S=(w=g(v))==null?void 0:w.properties)==null?void 0:S.kiosk)===!0},d=y.map(v=>v.role).filter(u),b=v=>({kiosk:!0,role:v,homePath:Xx(v,Wi(g(v))),targets:d,selectable:d.length>=2,selectRole:c});if(y.length===1)return d.length===1?b(d[0]):m;if(!cA(y)||d.length===0)return m;const x=o&&d.includes(o)?o:d.length===1?d[0]:null;return x?b(x):{...m,targets:d,selectable:!0}},[s,i,o,c])}const wA="/escalations/available",SA=["/escalations",gu,"/scan","/login"];function EA(n,t=""){if(n===wA){const s=new URLSearchParams(t);if(!s.get("role")&&!s.get("facets"))return!1}return SA.some(s=>n===s||n.startsWith(`${s}/`)||n.startsWith(`${s}?`))}const Em=E.createContext(null),id="lt_sidebar_collapsed",Qx="(max-width: 1023px)";function OA(){try{return window.matchMedia(Qx).matches}catch{return!1}}function AA({children:n}){const[t,s]=E.useState(()=>{if(OA())return!0;try{return localStorage.getItem(id)==="true"}catch{return!1}});E.useEffect(()=>{let o;try{o=window.matchMedia(Qx)}catch{return}const c=m=>{if(m.matches)s(!0);else try{s(localStorage.getItem(id)==="true")}catch{s(!1)}};return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[]);const i=E.useCallback(()=>{s(o=>{const c=!o;try{localStorage.setItem(id,String(c))}catch{}return c})},[]);return h.jsx(Em.Provider,{value:{collapsed:t,toggle:i},children:n})}function jA({children:n}){return h.jsx(Em.Provider,{value:{collapsed:!1,toggle:()=>{}},children:n})}function Om(){const n=E.useContext(Em);if(!n)throw new Error("useSidebar must be used within SidebarProvider");return n}const p1=380,Am=E.createContext(null);function kA({children:n}){const[t,s]=E.useState({node:null,width:p1,open:!1,ownerKey:null}),i=an(),o=E.useRef(i.pathname),c=E.useCallback((y,g)=>{s({node:y,width:(g==null?void 0:g.width)??p1,open:!0,ownerKey:(g==null?void 0:g.key)??null})},[]),m=E.useCallback(y=>{s(g=>typeof y=="string"&&g.ownerKey!==y?g:{...g,open:!1})},[]);return E.useEffect(()=>{i.pathname!==o.current&&(o.current=i.pathname,s(y=>y.open||y.node?{...y,node:null,open:!1,ownerKey:null}:y))},[i.pathname]),h.jsx(Am.Provider,{value:{...t,setPanel:c,closePanel:m},children:n})}function jm(){const n=E.useContext(Am);if(!n)throw new Error("useShellPanel must be used within ShellPanelProvider");return n}function W3(){return E.useContext(Am)}function NA({open:n,width:t=380,children:s,className:i=""}){const[o,c]=E.useState(n);return E.useEffect(()=>{n&&c(!0)},[n]),h.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${i}`,style:{width:n?t:0,maxWidth:"50%"},onTransitionEnd:m=>{!n&&m.propertyName==="width"&&c(!1)},children:h.jsx("div",{style:{width:t},className:"h-full",children:o?s:null})})}function Z3({label:n,children:t}){return h.jsxs("div",{children:[h.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:n}),h.jsx("dd",{className:"text-xs text-text-primary mt-0.5",children:t})]})}function e5({views:n,activeId:t,onViewChange:s,onClose:i,headerActions:o,stickyClassName:c,labelInline:m}){const y=n.find(g=>g.id===t)??n[0];return y?h.jsx("div",{className:"h-full bg-surface-hover",children:h.jsxs("div",{className:`flex flex-col ${c??"sticky top-0 z-10 max-h-[calc(100vh-3.5rem)]"}`,children:[h.jsxs("div",{className:`flex items-center justify-between pl-4 pr-3 shrink-0 ${m?"pt-10 pb-2":"pt-3"}`,children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1 shrink-0",role:"radiogroup","aria-label":"Panel view",children:n.map(g=>{const u=g.icon,d=g.id===y.id;return h.jsx("button",{role:"radio","aria-checked":d,onClick:()=>s(g.id),title:g.label,className:`p-1.5 rounded-md transition-colors ${d?"bg-accent/10 text-accent":"text-accent/60 hover:text-accent hover:bg-surface-hover"}`,children:h.jsx(u,{className:"w-3.5 h-3.5"})},g.id)})}),m&&h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-secondary truncate",children:y.label})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o,i&&h.jsx("button",{onClick:i,title:"Close panel",className:"p-1 rounded text-accent/60 hover:text-accent hover:bg-surface-hover transition-colors",children:h.jsx(Wt,{className:"w-3.5 h-3.5"})})]})]}),!m&&h.jsx("p",{className:"px-5 pt-2 pb-1 text-2xs font-semibold uppercase tracking-widest text-text-secondary shrink-0",children:y.label}),h.jsx("div",{className:`flex-1 overflow-y-auto px-5 ${m?"pt-4 pb-8":"pb-5 pt-1"}`,children:y.content})]})}):null}function Wx(n,t){var s,i,o,c,m;t.facets&&Object.keys(t.facets).length&&n.set("facets",JSON.stringify(t.facets)),(s=t.block)!=null&&s.length&&n.set("block",JSON.stringify(t.block)),(i=t.range)!=null&&i.length&&n.set("range",JSON.stringify(t.range)),(o=t.exists)!=null&&o.length&&n.set("exists",JSON.stringify(t.exists)),(c=t.roles)!=null&&c.length&&n.set("roles",JSON.stringify(t.roles)),(m=t.orderBy)!=null&&m.length&&n.set("orderBy",JSON.stringify(t.orderBy)),t.available!==void 0&&n.set("available",String(t.available)),t.jeopardy===!0&&n.set("jeopardy","1"),t.include&&n.set("include",t.include)}function t5(n,t,s){const i=n??"24h",o=t&&Object.keys(t).length?JSON.stringify(t):null;return $e({queryKey:["stationMetrics",i,o],queryFn:()=>fe(`/escalations/station-metrics?period=${i}${o?`&facets=${encodeURIComponent(o)}`:""}`),staleTime:5e3,enabled:(s==null?void 0:s.enabled)??!0})}function n5(n){const t=n?`?period=${n}`:"";return $e({queryKey:["escalationStats",n],queryFn:()=>fe(`/escalations/stats${t}`)})}function r5(){return $e({queryKey:["escalationTypes"],queryFn:()=>fe("/escalations/types")})}function s5(n=!0){return $e({queryKey:["escalationFacetKeys"],queryFn:()=>fe("/escalations/facet-keys"),enabled:n,staleTime:6e4})}function TA(n){return $e({queryKey:["escalationFacetValues",n],queryFn:()=>fe(`/escalations/facet-values?key=${encodeURIComponent(n)}`),enabled:!!n,staleTime:6e4})}function Zx(n){const{enabled:t=!0,staleTime:s,...i}=n,o=new URLSearchParams;return i.status&&o.set("status",i.status),i.role&&o.set("role",i.role),i.type&&o.set("type",i.type),i.subtype&&o.set("subtype",i.subtype),i.assigned_to&&o.set("assigned_to",i.assigned_to),i.parent_id&&o.set("parent_id",i.parent_id),i.claimed&&o.set("claimed","true"),i.priority&&o.set("priority",String(i.priority)),i.limit&&o.set("limit",String(i.limit)),i.offset!==void 0&&o.set("offset",String(i.offset)),i.sort_by&&o.set("sort_by",i.sort_by),i.order&&o.set("order",i.order),i.search&&o.set("search",i.search),Wx(o,i),$e({queryKey:["escalations",i],queryFn:()=>fe(`/escalations?${o}`),enabled:t,...s!==void 0?{staleTime:s}:{}})}function ev(n){const{enabled:t=!0,staleTime:s,...i}=n,o=new URLSearchParams;return i.role&&o.set("role",i.role),i.type&&o.set("type",i.type),i.subtype&&o.set("subtype",i.subtype),i.priority&&o.set("priority",String(i.priority)),i.limit&&o.set("limit",String(i.limit)),i.offset!==void 0&&o.set("offset",String(i.offset)),i.sort_by&&o.set("sort_by",i.sort_by),i.order&&o.set("order",i.order),i.search&&o.set("search",i.search),Wx(o,i),$e({queryKey:["escalations","available",i],queryFn:()=>fe(`/escalations/available?${o}`),enabled:t,...s!==void 0?{staleTime:s}:{}})}function i5(n){return $e({queryKey:["escalations","by-workflow",n],queryFn:()=>fe(`/escalations/by-workflow/${n}`),enabled:!!n})}function a5(n){return $e({queryKey:["escalations",n],queryFn:()=>fe(`/escalations/${n}`),enabled:!!n})}function o5(n,t){return $e({queryKey:["escalations",n,"lookups"],queryFn:()=>fe(`/escalations/${n}/lookups`),enabled:!!n&&t,staleTime:0,refetchOnWindowFocus:!1})}function l5(){const n=He();return Ve({mutationFn:({id:t,durationMinutes:s})=>fe(`/escalations/${t}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function c5(){const n=He();return Ve({mutationFn:t=>fe(`/escalations/${t}/release`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function u5(){const n=He();return Ve({mutationFn:({id:t,resolverPayload:s})=>fe(`/escalations/${t}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]}),n.resetQueries({queryKey:["tasks"]}),n.resetQueries({queryKey:["jobs"]})}})}function f5(){const n=He();return Ve({mutationFn:({id:t,itemKey:s,payload:i})=>fe(`/escalations/${t}/accumulate`,{method:"POST",body:JSON.stringify({itemKey:s,...i?{payload:i}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function h5(){const n=He();return Ve({mutationFn:({id:t,itemKey:s})=>fe(`/escalations/${t}/remove-item`,{method:"POST",body:JSON.stringify({itemKey:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function d5(){const n=He();return Ve({mutationFn:({id:t,targetRole:s})=>fe(`/escalations/${t}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function m5(){const n=He();return Ve({mutationFn:({ids:t,priority:s})=>fe("/escalations/priority",{method:"PATCH",body:JSON.stringify({ids:t,priority:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function p5(){const n=He();return Ve({mutationFn:({ids:t,durationMinutes:s})=>fe("/escalations/bulk-claim",{method:"POST",body:JSON.stringify({ids:t,durationMinutes:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function y5(){const n=He();return Ve({mutationFn:({ids:t,targetUserId:s,durationMinutes:i,reassign:o})=>fe("/escalations/bulk-assign",{method:"POST",body:JSON.stringify({ids:t,targetUserId:s,durationMinutes:i,...o?{reassign:!0}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function g5(){const n=He();return Ve({mutationFn:({ids:t})=>fe("/escalations/bulk-unassign",{method:"POST",body:JSON.stringify({ids:t})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function b5(){const n=He();return Ve({mutationFn:({ids:t,hint:s})=>fe("/escalations/bulk-triage",{method:"POST",body:JSON.stringify({ids:t,...s?{hint:s}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function x5(){const n=He();return Ve({mutationFn:t=>fe(`/escalations/${t}/cancel`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function v5(){const n=He();return Ve({mutationFn:({ids:t})=>fe("/escalations/bulk-cancel",{method:"POST",body:JSON.stringify({ids:t})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function km(n){const t=[],s=n.type.split(".");switch(s[0]==="system"?s[1]:s[0]){case"task":t.push(["tasks"]),t.push(["jobs"]),t.push(["processes"]),n.workflowId&&(t.push(["workflowExecution",n.workflowId]),t.push(["workflowState",n.workflowId]),t.push(["mcpQueryExecution",n.workflowId])),n.originId&&t.push(["processes",n.originId]);break;case"escalation":t.push(["escalations"]),t.push(["escalationStats"]),t.push(["stationMetrics"]),n.workflowId&&t.push(["workflowExecution",n.workflowId]);break;case"workflow":t.push(["jobs"]),t.push(["tasks"]),t.push(["processes"]),n.workflowId&&(t.push(["workflowExecution",n.workflowId]),t.push(["workflowState",n.workflowId]),t.push(["mcpQueryExecution",n.workflowId]),t.push(["mcpQueryResult",n.workflowId]),t.push(["builderResult",n.workflowId]));break;case"activity":n.workflowId&&t.push(["mcpRunExecution",n.workflowId]),t.push(["mcpRuns"]);break;case"milestone":n.workflowId&&(t.push(["workflowExecution",n.workflowId]),t.push(["mcpQueryExecution",n.workflowId])),t.push(["tasks"]);break;case"knowledge":t.push(["knowledge"]);break;case"file":t.push(["files"]);break;case"agent":t.push(["agents"]);break;default:t.push(["jobs"]),t.push(["tasks"]);break}return t}const CA={DETAIL:{coalesceMs:300,minIntervalMs:2e3},LIST:{coalesceMs:500,minIntervalMs:3e3},SUMMARY:{coalesceMs:1e3,minIntervalMs:1e4}},_5=300,y1={DETAIL:0,LIST:1,SUMMARY:2};function MA(n){const t=new Map,s={},i={};let o=!1;const c=()=>typeof document<"u"&&document.visibilityState==="hidden";function m(d){delete s[d],i[d]=Date.now();const b=[];for(const[v,w]of t)w===d&&b.push(v);for(const v of b)t.delete(v);if(b.length===0)return;const x=c();x&&(o=!0);for(const v of b)n.invalidateQueries({queryKey:JSON.parse(v),...x?{refetchType:"none"}:{}})}function y(d){if(s[d])return;const{coalesceMs:b,minIntervalMs:x}=CA[d],v=i[d],w=v===void 0?0:v+x-Date.now(),S=Math.max(b,w);s[d]=setTimeout(()=>m(d),S)}function g(d,b){for(const x of b){const v=JSON.stringify(x),w=t.get(v);(w===void 0||y1[d]<y1[w])&&t.set(v,d)}y(d)}const u=()=>{typeof document>"u"||document.visibilityState==="visible"&&o&&(o=!1,n.refetchQueries({type:"active",stale:!0}))};return typeof document<"u"&&document.addEventListener("visibilitychange",u),{request:g,dispose(){for(const d of Object.keys(s)){const b=s[d];b&&clearTimeout(b),delete s[d]}t.clear(),typeof document<"u"&&document.removeEventListener("visibilitychange",u)}}}const g1=new WeakMap;function RA(n){let t=g1.get(n);return t||(t=MA(n),g1.set(n,t)),t}function on(n){const t=He();return E.useCallback(s=>{RA(t).request(n,s)},[t,n])}function Nm(n){return n?[`${Xt}.system.workflow.>`,`${Xt}.system.activity.>`,`${Xt}.system.milestone.>`,`${Xt}.system.task.>`,`${Xt}.system.escalation.>`]:[]}function w5(){const n=on("LIST");On(`${Xt}.system.task.>`,()=>{n([["jobs"]])}),On(`${Xt}.system.workflow.>`,()=>{n([["jobs"]])})}function S5(n){const t=on("DETAIL");ti(Nm(n),s=>{var y;if(!n||!(s.workflowId===n||((y=s.workflowId)==null?void 0:y.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=km(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),t(m)})}function E5(n){const t=on("DETAIL");ti(Nm(n),s=>{var y;if(!n||!(s.workflowId===n||((y=s.workflowId)==null?void 0:y.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=km(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),t(m)})}function O5(n){const t=on("DETAIL");ti(Nm(n),s=>{var c;if(!n||!(s.workflowId===n||((c=s.workflowId)==null?void 0:c.includes(n))))return;const o=km(s);o.push(["workflowSets"]),o.push(["yamlWorkflows"]),t(o)})}function A5(n){const t=on("DETAIL"),s=E.useCallback(i=>{n&&(i.originId!==n&&i.workflowId!==n||t([["processes",n]]))},[n,t]);On(`${Xt}.system.task.>`,s),On(`${Xt}.system.workflow.>`,s),On(`${Xt}.system.escalation.>`,s)}function j5(){const n=on("SUMMARY");On(qr({}),()=>{n([["escalationStats"]])})}function k5(){const n=on("SUMMARY");On(qr({}),()=>{n([["stationMetrics"]])})}function N5(){const n=on("SUMMARY");On(qr({}),()=>{n([["escAggregate"],["escTimeline"]])})}function T5(n){const t=on("LIST"),s=(n==null?void 0:n.role)??null,i=((n==null?void 0:n.verbs)??[]).join(","),o=E.useMemo(()=>{const c=i?i.split(","):null;return c?Id({role:s,verbs:c}):[qr({role:s})]},[s,i]);ti(o,()=>{t([["escalations"]])})}function C5(n){const t=on("DETAIL");On(qr(n?{id:n}:{id:"__none__"}),s=>{!n||s.escalationId!==n||t([["escalations",n]])})}function M5(){const n=on("LIST");On(`${Xt}.system.agent.>`,()=>{n([["agents"]])})}function R5(){const n=on("LIST");On(`${Xt}.system.task.>`,()=>{n([["processes"]])}),On(`${Xt}.system.workflow.>`,()=>{n([["processes"]])})}function DA(){const{user:n}=Pt(),t=n==null?void 0:n.userId,s=on("SUMMARY");ti(vm(),()=>{s([["escalations"]])});const{data:i}=ev({limit:1}),{data:o}=Zx({assigned_to:t,status:"pending",limit:1});return{available:(i==null?void 0:i.total)??0,mine:(o==null?void 0:o.total)??0}}function Tm({size:n="sm",hideLabel:t=!1,className:s="",appName:i="LongTail",variant:o="full"}){const c=n==="lg";if(o==="comet")return h.jsx("div",{className:`relative overflow-visible ${s}`,style:{width:"2.5rem",height:"2.5rem",flexShrink:0},children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark absolute pointer-events-none select-none",style:{"--logo-url":`url(${Ht}/logo512.png)`,width:"82px",height:"82px",top:"-12px",left:"-80px",transform:"rotate(232deg)",zIndex:-1,opacity:.55}})});if(o==="mark")return h.jsx("div",{className:`flex items-center ${s}`,children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark shrink-0 w-7 h-7",style:{"--logo-url":`url(${Ht}/logo512.png)`}})});const m=c?"w-[16rem] h-[16rem] -rotate-[120deg] opacity-55 -ml-10":"w-[12.5rem] h-[12.5rem] -rotate-[120deg] opacity-55 -ml-8",y=c?"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 h.jsxs("div",{className:`flex items-center ${s}`,style:{height:"50px"},children:[h.jsx("span",{role:"img","aria-label":i,className:`logo-mark shrink-0 z-0 ${m}`,style:{"--logo-url":`url(${Ht}/logo512.png)`}}),h.jsx("span",{className:`z-[1] transition-opacity duration-300 ${y} ${t?"opacity-0":""}`,children:i})]})}const LA="system.surfaces.dashboard",qA=`${Xt}.${LA}`;function tv(n=!0){return $e({queryKey:["announcements"],queryFn:()=>fe("/announcements"),enabled:n,staleTime:3e4})}function BA(){const n=He();return Ve({mutationFn:t=>fe("/announcements",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}function PA(){const n=He();return Ve({mutationFn:t=>fe(`/announcements/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}const nv=6048e5,UA=864e5,b1=6e4,x1=525600,v1=43200,_1=1440,w1=Symbol.for("constructDateFrom");function Br(n,t){return typeof n=="function"?n(t):n&&typeof n=="object"&&w1 in n?n[w1](t):n instanceof Date?new n.constructor(t):new Date(t)}function jn(n,t){return Br(t||n,n)}let zA={};function Mo(){return zA}function Ao(n,t){var y,g,u,d;const s=Mo(),i=(t==null?void 0:t.weekStartsOn)??((g=(y=t==null?void 0:t.locale)==null?void 0:y.options)==null?void 0:g.weekStartsOn)??s.weekStartsOn??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=jn(n,t==null?void 0:t.in),c=o.getDay(),m=(c<i?7:0)+c-i;return o.setDate(o.getDate()-m),o.setHours(0,0,0,0),o}function bu(n,t){return Ao(n,{...t,weekStartsOn:1})}function rv(n,t){const s=jn(n,t==null?void 0:t.in),i=s.getFullYear(),o=Br(s,0);o.setFullYear(i+1,0,4),o.setHours(0,0,0,0);const c=bu(o),m=Br(s,0);m.setFullYear(i,0,4),m.setHours(0,0,0,0);const y=bu(m);return s.getTime()>=c.getTime()?i+1:s.getTime()>=y.getTime()?i:i-1}function xu(n){const t=jn(n),s=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return s.setUTCFullYear(t.getFullYear()),+n-+s}function sv(n,...t){const s=Br.bind(null,n||t.find(i=>typeof i=="object"));return t.map(s)}function S1(n,t){const s=jn(n,t==null?void 0:t.in);return s.setHours(0,0,0,0),s}function IA(n,t,s){const[i,o]=sv(s==null?void 0:s.in,n,t),c=S1(i),m=S1(o),y=+c-xu(c),g=+m-xu(m);return Math.round((y-g)/UA)}function $A(n,t){const s=rv(n,t),i=Br(n,0);return i.setFullYear(s,0,4),i.setHours(0,0,0,0),bu(i)}function HA(n,t){const s=+jn(n)-+jn(t);return s<0?-1:s>0?1:s}function FA(n){return Br(n,Date.now())}function GA(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function VA(n){return!(!GA(n)&&typeof n!="number"||isNaN(+jn(n)))}function YA(n){return t=>{const i=(n?Math[n]:Math.trunc)(t);return i===0?0:i}}function KA(n,t){const s=jn(n,t==null?void 0:t.in);return s.setFullYear(s.getFullYear(),0,1),s.setHours(0,0,0,0),s}const JA={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"}},XA=(n,t,s)=>{let i;const o=JA[n];return typeof o=="string"?i=o:t===1?i=o.one:i=o.other.replace("{{count}}",t.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+i:i+" ago":i};function ad(n){return(t={})=>{const s=t.width?String(t.width):n.defaultWidth;return n.formats[s]||n.formats[n.defaultWidth]}}const QA={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},WA={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},ZA={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ej={date:ad({formats:QA,defaultWidth:"full"}),time:ad({formats:WA,defaultWidth:"full"}),dateTime:ad({formats:ZA,defaultWidth:"full"})},tj={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},nj=(n,t,s,i)=>tj[n];function io(n){return(t,s)=>{const i=s!=null&&s.context?String(s.context):"standalone";let o;if(i==="formatting"&&n.formattingValues){const m=n.defaultFormattingWidth||n.defaultWidth,y=s!=null&&s.width?String(s.width):m;o=n.formattingValues[y]||n.formattingValues[m]}else{const m=n.defaultWidth,y=s!=null&&s.width?String(s.width):n.defaultWidth;o=n.values[y]||n.values[m]}const c=n.argumentCallback?n.argumentCallback(t):t;return o[c]}}const rj={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},sj={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ij={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"]},aj={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"]},oj={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"}},lj={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"}},cj=(n,t)=>{const s=Number(n),i=s%100;if(i>20||i<10)switch(i%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},uj={ordinalNumber:cj,era:io({values:rj,defaultWidth:"wide"}),quarter:io({values:sj,defaultWidth:"wide",argumentCallback:n=>n-1}),month:io({values:ij,defaultWidth:"wide"}),day:io({values:aj,defaultWidth:"wide"}),dayPeriod:io({values:oj,defaultWidth:"wide",formattingValues:lj,defaultFormattingWidth:"wide"})};function ao(n){return(t,s={})=>{const i=s.width,o=i&&n.matchPatterns[i]||n.matchPatterns[n.defaultMatchWidth],c=t.match(o);if(!c)return null;const m=c[0],y=i&&n.parsePatterns[i]||n.parsePatterns[n.defaultParseWidth],g=Array.isArray(y)?hj(y,b=>b.test(m)):fj(y,b=>b.test(m));let u;u=n.valueCallback?n.valueCallback(g):g,u=s.valueCallback?s.valueCallback(u):u;const d=t.slice(m.length);return{value:u,rest:d}}}function fj(n,t){for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&t(n[s]))return s}function hj(n,t){for(let s=0;s<n.length;s++)if(t(n[s]))return s}function dj(n){return(t,s={})=>{const i=t.match(n.matchPattern);if(!i)return null;const o=i[0],c=t.match(n.parsePattern);if(!c)return null;let m=n.valueCallback?n.valueCallback(c[0]):c[0];m=s.valueCallback?s.valueCallback(m):m;const y=t.slice(o.length);return{value:m,rest:y}}}const mj=/^(\d+)(th|st|nd|rd)?/i,pj=/\d+/i,yj={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},gj={any:[/^b/i,/^(a|c)/i]},bj={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},xj={any:[/1/i,/2/i,/3/i,/4/i]},vj={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},_j={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]},wj={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},Sj={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]},Ej={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},Oj={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}},Aj={ordinalNumber:dj({matchPattern:mj,parsePattern:pj,valueCallback:n=>parseInt(n,10)}),era:ao({matchPatterns:yj,defaultMatchWidth:"wide",parsePatterns:gj,defaultParseWidth:"any"}),quarter:ao({matchPatterns:bj,defaultMatchWidth:"wide",parsePatterns:xj,defaultParseWidth:"any",valueCallback:n=>n+1}),month:ao({matchPatterns:vj,defaultMatchWidth:"wide",parsePatterns:_j,defaultParseWidth:"any"}),day:ao({matchPatterns:wj,defaultMatchWidth:"wide",parsePatterns:Sj,defaultParseWidth:"any"}),dayPeriod:ao({matchPatterns:Ej,defaultMatchWidth:"any",parsePatterns:Oj,defaultParseWidth:"any"})},iv={code:"en-US",formatDistance:XA,formatLong:ej,formatRelative:nj,localize:uj,match:Aj,options:{weekStartsOn:0,firstWeekContainsDate:1}};function jj(n,t){const s=jn(n,t==null?void 0:t.in);return IA(s,KA(s))+1}function kj(n,t){const s=jn(n,t==null?void 0:t.in),i=+bu(s)-+$A(s);return Math.round(i/nv)+1}function av(n,t){var d,b,x,v;const s=jn(n,t==null?void 0:t.in),i=s.getFullYear(),o=Mo(),c=(t==null?void 0:t.firstWeekContainsDate)??((b=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??o.firstWeekContainsDate??((v=(x=o.locale)==null?void 0:x.options)==null?void 0:v.firstWeekContainsDate)??1,m=Br((t==null?void 0:t.in)||n,0);m.setFullYear(i+1,0,c),m.setHours(0,0,0,0);const y=Ao(m,t),g=Br((t==null?void 0:t.in)||n,0);g.setFullYear(i,0,c),g.setHours(0,0,0,0);const u=Ao(g,t);return+s>=+y?i+1:+s>=+u?i:i-1}function Nj(n,t){var y,g,u,d;const s=Mo(),i=(t==null?void 0:t.firstWeekContainsDate)??((g=(y=t==null?void 0:t.locale)==null?void 0:y.options)==null?void 0:g.firstWeekContainsDate)??s.firstWeekContainsDate??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,o=av(n,t),c=Br((t==null?void 0:t.in)||n,0);return c.setFullYear(o,0,i),c.setHours(0,0,0,0),Ao(c,t)}function Tj(n,t){const s=jn(n,t==null?void 0:t.in),i=+Ao(s,t)-+Nj(s,t);return Math.round(i/nv)+1}function nt(n,t){const s=n<0?"-":"",i=Math.abs(n).toString().padStart(t,"0");return s+i}const ps={y(n,t){const s=n.getFullYear(),i=s>0?s:1-s;return nt(t==="yy"?i%100:i,t.length)},M(n,t){const s=n.getMonth();return t==="M"?String(s+1):nt(s+1,2)},d(n,t){return nt(n.getDate(),t.length)},a(n,t){const s=n.getHours()/12>=1?"pm":"am";switch(t){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(n,t){return nt(n.getHours()%12||12,t.length)},H(n,t){return nt(n.getHours(),t.length)},m(n,t){return nt(n.getMinutes(),t.length)},s(n,t){return nt(n.getSeconds(),t.length)},S(n,t){const s=t.length,i=n.getMilliseconds(),o=Math.trunc(i*Math.pow(10,s-3));return nt(o,t.length)}},Ii={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},E1={G:function(n,t,s){const i=n.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return s.era(i,{width:"abbreviated"});case"GGGGG":return s.era(i,{width:"narrow"});case"GGGG":default:return s.era(i,{width:"wide"})}},y:function(n,t,s){if(t==="yo"){const i=n.getFullYear(),o=i>0?i:1-i;return s.ordinalNumber(o,{unit:"year"})}return ps.y(n,t)},Y:function(n,t,s,i){const o=av(n,i),c=o>0?o:1-o;if(t==="YY"){const m=c%100;return nt(m,2)}return t==="Yo"?s.ordinalNumber(c,{unit:"year"}):nt(c,t.length)},R:function(n,t){const s=rv(n);return nt(s,t.length)},u:function(n,t){const s=n.getFullYear();return nt(s,t.length)},Q:function(n,t,s){const i=Math.ceil((n.getMonth()+1)/3);switch(t){case"Q":return String(i);case"QQ":return nt(i,2);case"Qo":return s.ordinalNumber(i,{unit:"quarter"});case"QQQ":return s.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return s.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(i,{width:"wide",context:"formatting"})}},q:function(n,t,s){const i=Math.ceil((n.getMonth()+1)/3);switch(t){case"q":return String(i);case"qq":return nt(i,2);case"qo":return s.ordinalNumber(i,{unit:"quarter"});case"qqq":return s.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return s.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(i,{width:"wide",context:"standalone"})}},M:function(n,t,s){const i=n.getMonth();switch(t){case"M":case"MM":return ps.M(n,t);case"Mo":return s.ordinalNumber(i+1,{unit:"month"});case"MMM":return s.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return s.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(i,{width:"wide",context:"formatting"})}},L:function(n,t,s){const i=n.getMonth();switch(t){case"L":return String(i+1);case"LL":return nt(i+1,2);case"Lo":return s.ordinalNumber(i+1,{unit:"month"});case"LLL":return s.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return s.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(i,{width:"wide",context:"standalone"})}},w:function(n,t,s,i){const o=Tj(n,i);return t==="wo"?s.ordinalNumber(o,{unit:"week"}):nt(o,t.length)},I:function(n,t,s){const i=kj(n);return t==="Io"?s.ordinalNumber(i,{unit:"week"}):nt(i,t.length)},d:function(n,t,s){return t==="do"?s.ordinalNumber(n.getDate(),{unit:"date"}):ps.d(n,t)},D:function(n,t,s){const i=jj(n);return t==="Do"?s.ordinalNumber(i,{unit:"dayOfYear"}):nt(i,t.length)},E:function(n,t,s){const i=n.getDay();switch(t){case"E":case"EE":case"EEE":return s.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return s.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(i,{width:"short",context:"formatting"});case"EEEE":default:return s.day(i,{width:"wide",context:"formatting"})}},e:function(n,t,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(t){case"e":return String(c);case"ee":return nt(c,2);case"eo":return s.ordinalNumber(c,{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(n,t,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(t){case"c":return String(c);case"cc":return nt(c,t.length);case"co":return s.ordinalNumber(c,{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(n,t,s){const i=n.getDay(),o=i===0?7:i;switch(t){case"i":return String(o);case"ii":return nt(o,t.length);case"io":return s.ordinalNumber(o,{unit:"day"});case"iii":return s.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return s.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return s.day(i,{width:"short",context:"formatting"});case"iiii":default:return s.day(i,{width:"wide",context:"formatting"})}},a:function(n,t,s){const o=n.getHours()/12>=1?"pm":"am";switch(t){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(n,t,s){const i=n.getHours();let o;switch(i===12?o=Ii.noon:i===0?o=Ii.midnight:o=i/12>=1?"pm":"am",t){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(n,t,s){const i=n.getHours();let o;switch(i>=17?o=Ii.evening:i>=12?o=Ii.afternoon:i>=4?o=Ii.morning:o=Ii.night,t){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(n,t,s){if(t==="ho"){let i=n.getHours()%12;return i===0&&(i=12),s.ordinalNumber(i,{unit:"hour"})}return ps.h(n,t)},H:function(n,t,s){return t==="Ho"?s.ordinalNumber(n.getHours(),{unit:"hour"}):ps.H(n,t)},K:function(n,t,s){const i=n.getHours()%12;return t==="Ko"?s.ordinalNumber(i,{unit:"hour"}):nt(i,t.length)},k:function(n,t,s){let i=n.getHours();return i===0&&(i=24),t==="ko"?s.ordinalNumber(i,{unit:"hour"}):nt(i,t.length)},m:function(n,t,s){return t==="mo"?s.ordinalNumber(n.getMinutes(),{unit:"minute"}):ps.m(n,t)},s:function(n,t,s){return t==="so"?s.ordinalNumber(n.getSeconds(),{unit:"second"}):ps.s(n,t)},S:function(n,t){return ps.S(n,t)},X:function(n,t,s){const i=n.getTimezoneOffset();if(i===0)return"Z";switch(t){case"X":return A1(i);case"XXXX":case"XX":return Xs(i);case"XXXXX":case"XXX":default:return Xs(i,":")}},x:function(n,t,s){const i=n.getTimezoneOffset();switch(t){case"x":return A1(i);case"xxxx":case"xx":return Xs(i);case"xxxxx":case"xxx":default:return Xs(i,":")}},O:function(n,t,s){const i=n.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+O1(i,":");case"OOOO":default:return"GMT"+Xs(i,":")}},z:function(n,t,s){const i=n.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+O1(i,":");case"zzzz":default:return"GMT"+Xs(i,":")}},t:function(n,t,s){const i=Math.trunc(+n/1e3);return nt(i,t.length)},T:function(n,t,s){return nt(+n,t.length)}};function O1(n,t=""){const s=n>0?"-":"+",i=Math.abs(n),o=Math.trunc(i/60),c=i%60;return c===0?s+String(o):s+String(o)+t+nt(c,2)}function A1(n,t){return n%60===0?(n>0?"-":"+")+nt(Math.abs(n)/60,2):Xs(n,t)}function Xs(n,t=""){const s=n>0?"-":"+",i=Math.abs(n),o=nt(Math.trunc(i/60),2),c=nt(i%60,2);return s+o+t+c}const j1=(n,t)=>{switch(n){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},ov=(n,t)=>{switch(n){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},Cj=(n,t)=>{const s=n.match(/(P+)(p+)?/)||[],i=s[1],o=s[2];if(!o)return j1(n,t);let c;switch(i){case"P":c=t.dateTime({width:"short"});break;case"PP":c=t.dateTime({width:"medium"});break;case"PPP":c=t.dateTime({width:"long"});break;case"PPPP":default:c=t.dateTime({width:"full"});break}return c.replace("{{date}}",j1(i,t)).replace("{{time}}",ov(o,t))},Mj={p:ov,P:Cj},Rj=/^D+$/,Dj=/^Y+$/,Lj=["D","DD","YY","YYYY"];function qj(n){return Rj.test(n)}function Bj(n){return Dj.test(n)}function Pj(n,t,s){const i=Uj(n,t,s);if(console.warn(i),Lj.includes(n))throw new RangeError(i)}function Uj(n,t,s){const i=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${t}\`) for formatting ${i} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const zj=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ij=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,$j=/^'([^]*?)'?$/,Hj=/''/g,Fj=/[a-zA-Z]/;function Cm(n,t,s){var d,b,x,v;const i=Mo(),o=i.locale??iv,c=i.firstWeekContainsDate??((b=(d=i.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??1,m=i.weekStartsOn??((v=(x=i.locale)==null?void 0:x.options)==null?void 0:v.weekStartsOn)??0,y=jn(n,s==null?void 0:s.in);if(!VA(y))throw new RangeError("Invalid time value");let g=t.match(Ij).map(w=>{const S=w[0];if(S==="p"||S==="P"){const C=Mj[S];return C(w,o.formatLong)}return w}).join("").match(zj).map(w=>{if(w==="''")return{isToken:!1,value:"'"};const S=w[0];if(S==="'")return{isToken:!1,value:Gj(w)};if(E1[S])return{isToken:!0,value:w};if(S.match(Fj))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:w}});o.localize.preprocessor&&(g=o.localize.preprocessor(y,g));const u={firstWeekContainsDate:c,weekStartsOn:m,locale:o};return g.map(w=>{if(!w.isToken)return w.value;const S=w.value;(Bj(S)||qj(S))&&Pj(S,t,String(n));const C=E1[S[0]];return C(y,S,o.localize,u)}).join("")}function Gj(n){const t=n.match($j);return t?t[1].replace(Hj,"'"):n}function Vj(n,t,s){const i=Mo(),o=(s==null?void 0:s.locale)??i.locale??iv,c=HA(n,t);if(isNaN(c))throw new RangeError("Invalid time value");const m=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:c}),[y,g]=sv(s==null?void 0:s.in,...c>0?[t,n]:[n,t]),u=YA((s==null?void 0:s.roundingMethod)??"round"),d=g.getTime()-y.getTime(),b=d/b1,x=xu(g)-xu(y),v=(d-x)/b1,w=s==null?void 0:s.unit;let S;if(w?S=w:b<1?S="second":b<60?S="minute":b<_1?S="hour":v<v1?S="day":v<x1?S="month":S="year",S==="second"){const C=u(d/1e3);return o.formatDistance("xSeconds",C,m)}else if(S==="minute"){const C=u(b);return o.formatDistance("xMinutes",C,m)}else if(S==="hour"){const C=u(b/60);return o.formatDistance("xHours",C,m)}else if(S==="day"){const C=u(v/_1);return o.formatDistance("xDays",C,m)}else if(S==="month"){const C=u(v/v1);return C===12&&w!=="month"?o.formatDistance("xYears",1,m):o.formatDistance("xMonths",C,m)}else{const C=u(v/x1);return o.formatDistance("xYears",C,m)}}function Yj(n,t){return Vj(n,FA(n),t)}function D5(n){return n.toLocaleString()}function L5(n){return n>=1e9?`${(n/1e9).toFixed(1).replace(/\.0$/,"")}B`:n>=1e6?`${(n/1e6).toFixed(1).replace(/\.0$/,"")}M`:n>=1e4?`${(n/1e3).toFixed(1).replace(/\.0$/,"")}K`:n.toLocaleString()}function Kj(n){const t=new Date(n);return t.getTime()>Date.now()?"just now":Yj(t,{addSuffix:!0})}function q5(n){const t=Date.now()-new Date(n).getTime();if(t<0)return"now";const s=Math.floor(t/1e3);if(s<60)return`${s}s`;const i=Math.floor(s/60);if(i<60)return`${i}m`;const o=Math.floor(i/60);if(o<24)return`${o}h`;const c=Math.floor(o/24);return c<7?`${c}d`:c<30?`${Math.floor(c/7)}w`:c<365?`${Math.floor(c/30)}mo`:`${Math.floor(c/365)}y`}function B5(n){return n<=0?"Expired":Mm(n)}function Jj(n){return n==null?"--":Mm(n)}function P5(n){return n?Cm(new Date(n),"MMM d, yyyy h:mm a"):"--"}function Mm(n){if(n<1e3)return`${Math.round(n)}ms`;if(n<6e4){const m=n/1e3;return Number.isInteger(m)?`${m}s`:`${m.toFixed(1)}s`}const t=Math.floor(n/1e3),s=Math.floor(t/86400),i=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),c=t%60;return s>0?i>0?`${s}d ${i}h`:`${s}d`:i>0?o>0?`${i}h ${o}m`:`${i}h`:c>0?`${o}m ${c}s`:`${o}m`}function U5(n,t){const s=new Date(n).getTime(),i=t?new Date(t).getTime():Date.now();return Mm(i-s)}function lv({options:n,children:t,className:s=""}){const[i,o]=E.useState(!1),[c,m]=E.useState(null),[y,g]=E.useState(null),u=E.useRef(null),d=E.useRef(void 0),b=E.useRef(void 0),x=220,v=E.useCallback(()=>{if(!u.current)return;const q=u.current.getBoundingClientRect(),B=window.innerWidth-x-8,ie=Math.max(8,Math.min(q.left,B));g({top:q.bottom+4,left:ie})},[]),w=E.useCallback(async(q,B)=>{try{await navigator.clipboard.writeText(q),m(B),clearTimeout(d.current),d.current=setTimeout(()=>m(null),1200)}catch{}},[]),S=E.useCallback(()=>{clearTimeout(b.current),v(),o(!0)},[v]),C=E.useCallback(()=>{b.current=setTimeout(()=>o(!1),150)},[]);return E.useEffect(()=>()=>{clearTimeout(d.current),clearTimeout(b.current)},[]),h.jsxs("span",{ref:u,className:`inline-flex items-center cursor-default ${s}`,onMouseEnter:S,onMouseLeave:C,children:[t,i&&y&&Wd.createPortal(h.jsx("span",{className:"fixed z-[9999] bg-surface-raised border border-surface-border rounded shadow-lg py-1 min-w-[180px]",style:{top:y.top,left:y.left},onMouseEnter:S,onMouseLeave:C,children:n.map(q=>h.jsxs("button",{onClick:B=>{B.stopPropagation(),w(q.value,q.label)},className:"flex items-center justify-between w-full px-2.5 py-1 text-left hover:bg-surface-hover transition-colors",children:[h.jsx("span",{className:"text-2xs font-medium uppercase tracking-wider text-text-tertiary w-10 shrink-0",children:q.label}),h.jsx("span",{className:"text-2xs font-mono text-text-secondary truncate ml-2",children:c===q.label?"✓":q.value})]},q.label))}),document.body)]})}function Xj(n,t){const s=new Date(n);switch(t){case"relative":return Kj(n);case"datetime":return Cm(s,"MMM d, yyyy h:mm a");case"time":return s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function Qj(n){const t=new Date(n);return[{label:"ms",value:String(t.getTime())},{label:"utc",value:t.toISOString()},{label:"local",value:Cm(t,"MMM d, yyyy h:mm:ss a")}]}function cv({date:n,format:t="relative",className:s=""}){const[,i]=E.useState(0);E.useEffect(()=>{if(t!=="relative")return;const c=setInterval(()=>i(m=>m+1),3e4);return()=>clearInterval(c)},[t]);const o=E.useMemo(()=>Qj(n),[n]);return h.jsx(lv,{options:o,children:h.jsx("time",{dateTime:n,className:`text-xs text-text-tertiary ${s}`,children:Xj(n,t)})})}function Wj({values:n,options:t,onChange:s,addLabel:i,emptyText:o,ariaLabel:c}){const m=t.filter(y=>!n.includes(y));return h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.map(y=>h.jsxs("button",{type:"button",onClick:()=>s(n.filter(g=>g!==y)),className:"inline-flex items-center gap-1 text-2xs font-mono text-text-primary border border-surface-border px-1.5 py-0.5 hover:text-status-error hover:border-status-error/50 transition-colors",title:`Remove ${y}`,children:[y,h.jsx(Wt,{className:"w-3 h-3",strokeWidth:1.5})]},y)),n.length===0&&o&&h.jsx("span",{className:"text-2xs text-text-tertiary italic",children:o}),m.length>0&&h.jsxs("select",{value:"",onChange:y=>y.target.value&&s([...n,y.target.value]),className:"select font-mono","aria-label":c??i,children:[h.jsx("option",{value:"",children:i}),m.map(y=>h.jsx("option",{value:y,children:y},y))]})]})}const Zj=[{minutes:1,label:"1 minute"},{minutes:15,label:"15 minutes"},{minutes:30,label:"30 minutes"},{minutes:60,label:"1 hour"},{minutes:240,label:"4 hours"},{minutes:1440,label:"24 hours"},{minutes:4320,label:"3 days"},{minutes:10080,label:"7 days"}];function ek(){const{data:n}=tv(),{data:t}=mA(),s=BA(),i=PA(),[o,c]=E.useState(""),[m,y]=E.useState(""),[g,u]=E.useState(1440),[d,b]=E.useState([]),x=(n==null?void 0:n.announcements)??[],v=()=>{m.trim()&&s.mutate({body:m.trim(),...o.trim()?{title:o.trim()}:{},...d.length?{roles:d}:{},expiresAt:new Date(Date.now()+g*6e4).toISOString()},{onSuccess:()=>{c(""),y(""),b([])}})};return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"Alerts"}),h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Title"}),h.jsx("input",{type:"text",value:o,onChange:w=>c(w.target.value),placeholder:"Optional headline",className:"input text-xs w-full"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Summary"}),h.jsx("textarea",{value:m,onChange:w=>y(w.target.value),placeholder:"What everyone should know (markdown supported)",rows:3,className:"input text-xs w-full resize-y"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible for"}),h.jsx("select",{value:g,onChange:w=>u(Number(w.target.value)),className:"select text-xs w-full",children:Zj.map(w=>h.jsx("option",{value:w.minutes,children:w.label},w.minutes))})]}),h.jsxs("div",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible to"}),h.jsx(Wj,{values:d,options:(t==null?void 0:t.roles)??[],onChange:b,addLabel:"Add a role…",emptyText:"Everyone",ariaLabel:"Add a role"})]}),s.error&&h.jsx("p",{className:"text-xs text-status-error",children:s.error.message}),h.jsx("button",{onClick:v,disabled:!m.trim()||s.isPending,className:"btn-primary text-xs w-full disabled:opacity-50",children:s.isPending?"Publishing…":"Publish alert"})]}),x.length>0&&h.jsxs("div",{className:"mt-6",children:[h.jsx("p",{className:"text-2xs text-text-tertiary mb-2",children:"Active now — stacked as banner rows, newest first"}),h.jsx("div",{className:"space-y-1",children:x.map(w=>h.jsxs("div",{className:"flex items-start gap-2 py-1.5 border-b border-surface-border/40 last:border-b-0",children:[h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsx("span",{className:"block text-xs text-text-primary truncate",children:w.title??w.body.split(`
54
+ `)[0]}),h.jsxs("span",{className:"block text-2xs text-text-tertiary",children:["expires ",h.jsx(cv,{date:w.expires_at,format:"relative"})]})]}),h.jsx("button",{onClick:()=>i.mutate(w.id),disabled:i.isPending,className:"icon-link shrink-0 mt-0.5",title:"Remove for everyone","aria-label":`Remove ${w.title??"announcement"}`,children:h.jsx(Wt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]},w.id))})]})]})}const tk=[{id:null,label:"Your view",description:"Full access based on your account role",minTier:"operator"},{id:"admin",label:"Admin",description:"Pace Board + identity management",minTier:"superadmin"},{id:"engineer",label:"Engineer",description:"Work queue + identity management",minTier:"admin"},{id:"operator",label:"Operator",description:"Escalation queue only",minTier:"engineer"}],nk=["operator","engineer","admin","superadmin"];function k1(n){return nk.indexOf(n)}function rk(n,t){return k1(n)>=k1(t)}function sk({onClose:n}){var Ne,Me,Ze,yt,Ct,we,Re;const{isSuperAdmin:t,hasRoleType:s,hasRole:i}=Pt(),{data:o}=Zn(),c=xm(),m=!!((Ne=o==null?void 0:o.ai)!=null&&Ne.enabled),y=$x(),g=y!==null?y:m,[u,d]=E.useState(g),b=(Me=o==null?void 0:o.features)==null?void 0:Me.graphWorkflows,x=b==null,[v,w]=E.useState(b===!0||x&&Hx()),S=t||i("engineer"),[C,q]=E.useState(Fx()),B=!!((Ze=o==null?void 0:o.features)!=null&&Ze.scanCodes),ie=Gx(),[le,R]=E.useState(ie!==null?ie:B),$=t?"superadmin":s("admin")?"admin":i("engineer")?"engineer":"operator",ne=((yt=o==null?void 0:o.branding)==null?void 0:yt.appName)??"LongTail",V=(Ct=o==null?void 0:o.environment)==null?void 0:Ct.longTailVersion,I=(we=o==null?void 0:o.environment)==null?void 0:we.hotmeshVersion,D=(Re=o==null?void 0:o.environment)==null?void 0:Re.nodeEnv;E.useEffect(()=>{const oe=Be=>{Be.key==="Escape"&&n()};return document.addEventListener("keydown",oe),()=>document.removeEventListener("keydown",oe)},[n]);const Q=tk.filter(oe=>rk($,oe.minTier)),X=Q.length>1,he=$!=="operator",Se=[...X?[{id:"viewas",label:"View As",icon:lS}]:[],{id:"features",label:"Features",icon:cS},...he?[{id:"alerts",label:"Alerts",icon:uS}]:[]],[ke,H]=E.useState(Se[0].id),W=oe=>{oe===null?zd():nA(oe)},ce=()=>{const oe=!u;d(oe),oe===m?tA():eA(oe),window.location.reload()},xe=()=>{const oe=!v;w(oe),rA(oe),window.location.reload()},ve=()=>{const oe=!C;q(oe),sA(oe),window.location.reload()},Ce=()=>{const oe=!le;R(oe),oe===B?aA():iA(oe),window.location.reload()};return h.jsx("div",{className:"fixed inset-0 z-[100] bg-surface-sunken/75 backdrop-blur-sm flex items-center justify-center",onClick:n,children:h.jsxs("div",{className:"relative w-[440px] max-h-[85vh] overflow-y-auto bg-surface-raised px-12 py-10",onClick:oe=>oe.stopPropagation(),children:[h.jsx("button",{onClick:n,className:"absolute top-4 right-4 text-text-quaternary hover:text-text-secondary transition-colors p-1","aria-label":"Close",children:h.jsx(Wt,{className:"w-4 h-4",strokeWidth:1.5})}),h.jsxs("div",{className:"flex flex-col items-center gap-3 pb-8",children:[h.jsx("span",{className:"logo-mark block w-20 h-20 opacity-50",style:{"--logo-url":`url(${Ht}/logo512.png)`}}),h.jsxs("div",{className:"text-center",children:[h.jsx("p",{className:"text-2xl font-light text-text-primary tracking-[0.12em]",children:ne}),V&&h.jsxs("p",{className:"mt-1 text-2xs text-text-tertiary",children:["v",V,I&&h.jsxs(h.Fragment,{children:[" · HotMesh v",I]}),D&&D!=="production"&&h.jsx("span",{className:"ml-1 text-status-warning",children:D})]})]})]}),h.jsx("hr",{className:"border-surface-border/50 mb-6"}),Se.length>1&&h.jsx("div",{className:"flex items-center justify-center gap-2 mb-8",role:"tablist",children:Se.map(oe=>{const Be=ke===oe.id;return h.jsxs("button",{role:"tab","aria-selected":Be,onClick:()=>H(oe.id),title:oe.label,className:`flex flex-col items-center gap-1.5 px-5 py-2.5 rounded-lg transition-colors ${Be?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[h.jsx(oe.icon,{className:"w-5 h-5",strokeWidth:1.5,...Be?{fill:"currentColor",fillOpacity:.15}:{}}),h.jsx("span",{className:"text-2xs font-medium",children:oe.label})]},oe.id)})}),ke==="viewas"&&X&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"View As"}),Q.map(oe=>{const Be=c===oe.id,We=oe.id===null?`Your view · ${$}`:oe.label;return h.jsxs("button",{onClick:()=>W(oe.id),className:"w-full text-left flex items-start gap-3 py-2.5 px-1 group",children:[h.jsx("span",{className:`mt-0.5 w-4 h-4 rounded-full border shrink-0 flex items-center justify-center transition-colors ${Be?"border-accent bg-accent":"border-surface-border group-hover:border-accent/60"}`,children:Be&&h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"})}),h.jsxs("span",{children:[h.jsx("span",{className:`block text-sm font-medium transition-colors ${Be?"text-accent":"text-text-primary group-hover:text-accent"}`,children:We}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:oe.description})]})]},String(oe.id))})]}),ke==="features"&&h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"Features"}),h.jsxs("button",{onClick:ce,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"AI features"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:u?"Enabled — AI assist, agent labels, bulk AI actions":"Hidden — automation labels, no AI surfaces"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${u?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${u?"translate-x-4":"translate-x-0"}`})})]}),x&&h.jsxs("button",{onClick:xe,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Graph workflows"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:v?"Visible — Graph section shown in Orchestrate sidebar":"Hidden — use Procedural workflows instead"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${v?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${v?"translate-x-4":"translate-x-0"}`})})]}),S&&h.jsxs("button",{onClick:ve,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group","data-testid":"feature-infrastructure",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Infrastructure"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:C?"Visible — Routers, Messages, and DB Maintenance in the sidebar":"Hidden — routers, message streams, and database maintenance"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${C?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${C?"translate-x-4":"translate-x-0"}`})})]}),h.jsxs("button",{onClick:Ce,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Scan input"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:le?"Enabled — header scan affordance, panel, and keyboard-wedge capture":"Hidden — the deployment opts in with features.scanCodes"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${le?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${le?"translate-x-4":"translate-x-0"}`})})]})]}),ke==="alerts"&&he&&h.jsx(ek,{}),h.jsx("hr",{className:"border-surface-border/50 mt-8"}),h.jsx("p",{className:"mt-4 text-2xs text-text-quaternary text-center",children:"Esc or click outside to close"})]})})}const uv=[{id:"violet",label:"Violet",swatch:"#7B3BE0"},{id:"red",label:"Brick",swatch:"#DC382D"},{id:"green",label:"Emerald",swatch:"#059669"},{id:"blue",label:"Electric",swatch:"#2563EB"},{id:"rose",label:"Raspberry",swatch:"#D6246E"},{id:"orange",label:"Harvest",swatch:"#E85D04"}],N1="blue",fv="lt.theme";let hv=[];function ik(n){const t=new Set(uv.map(i=>i.id)),s=new Set;hv=n.filter(i=>!(i!=null&&i.id)||t.has(i.id)||s.has(i.id)?!1:(s.add(i.id),!0))}function ak(){return[...uv,...hv]}function dv(){try{return localStorage.getItem(fv)||N1}catch{return N1}}function mv(n){document.documentElement.dataset.theme=n}function ok(n){try{localStorage.setItem(fv,n)}catch{}mv(n)}const pv=E.createContext(null);function lk(){const n=E.useContext(pv);if(!n)throw new Error("useActingIdentity must be used within ActingIdentityProvider");return n}function ck({children:n}){const[t,s]=E.useState(null),i=E.useRef(t);i.current=t,E.useEffect(()=>{if(!(t!=null&&t.expiresAt))return;const d=new Date(t.expiresAt).getTime()-Date.now();if(d<=0){s(null);return}const b=setTimeout(()=>s(null),d);return()=>clearTimeout(b)},[t]);const o=E.useCallback(d=>{var x;if(!d.actingToken||!d.actor)return null;const b=((x=i.current)==null?void 0:x.actingToken)??null;return s({actingToken:d.actingToken,actorId:d.actor.id,displayName:d.actor.displayName,expiresAt:d.expiresAt??null,subjectScoped:d.grantScope==="subject"}),b},[]),c=E.useCallback(()=>s(null),[]),m=E.useCallback((d,b)=>{const x=i.current;b===0&&(x==null?void 0:x.actingToken)===d&&s(null)},[]),y=E.useCallback((d,b)=>{const x=i.current;if(!x||x.actingToken!==d||!b.acting)return;const{consumed:v,remaining:w,bound:S}=b.acting;(v&&w===0||S&&b.clearSubject)&&s(null)},[]);E.useEffect(()=>(Lg(()=>{var d;return((d=i.current)==null?void 0:d.actingToken)??null}),Bg(c),qg(m),()=>{Lg(null),Bg(null),qg(null)}),[c,m]);const g=E.useCallback(()=>{var b;const d=(b=i.current)==null?void 0:b.expiresAt;return d?Math.max(0,Math.floor((new Date(d).getTime()-Date.now())/1e3)):0},[]),u=E.useMemo(()=>({identity:t,prime:o,clear:c,settle:y,remainingSeconds:g}),[t,o,c,y,g]);return h.jsx(pv.Provider,{value:u,children:n})}const uk=[8,12,13,14];function fk(n){if(!/^[0-9]+$/.test(n)||!uk.includes(n.length))return!1;const t=n.split("").map(Number),s=t.pop();let i=0;for(let o=t.length-1,c=3;o>=0;o--,c=c===3?1:3)i+=t[o]*c;return(10-i%10)%10===s}function z5(n){return n.padStart(14,"0")}const lu={maxKeyGapMs:500,terminators:["Enter","Tab"],minLength:6,autoFireQuietMs:300,autoFireMaxAvgKeyMs:50},yv="lt_scan_wedge_config";function gv(){try{const n=localStorage.getItem(yv);return n?{...lu,...JSON.parse(n)}:lu}catch{return lu}}function hk(n){const t={...gv(),...n};return localStorage.setItem(yv,JSON.stringify(t)),t}const Rm=[{pattern:/(?:^|[^0-9])([1-9][0-9]:[0-9]:[a-zA-Z0-9._-]+)$/,digitsOnly:!1},{pattern:/(?:^|[^0-9])([1-9][0-9]{7,})$/,digitsOnly:!0}];function dk(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function mk(n){const t=[];for(const s of n.filter(i=>i.enabled))if(s.encoding==="delimited"){const i=dk(s.delimiter);t.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}${i}[0-9]${i}[a-zA-Z0-9._-]+)$`),digitsOnly:!1})}else if(s.encoding==="fixed"){const i=1+(s.target_length??0);t.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}[0-9]{${i},${i+1}})$`),digitsOnly:!0})}else s.encoding==="gtin"&&t.push({pattern:/(?:^|[^0-9])([0-9]{8}|[0-9]{12,14})$/,digitsOnly:!0,accept:fk});return t.length?t:Rm}function pk(n,t=Rm){var i;let s=null;for(const o of t){const c=(i=n.match(o.pattern))==null?void 0:i[1];!c||o.accept&&!o.accept(c)||(!s||c.length>s.code.length)&&(s={code:c,shape:o})}return s}const yk=new Set(["Shift","CapsLock"]),uc={suppress:!1,emit:null};function gk(n=lu,t=Rm){let s={buffer:"",times:[],lastKeyMs:0};function i(u){const d=s.times.slice(-u.length);return d.length<2?!1:(d[d.length-1]-d[0])/(d.length-1)<=n.autoFireMaxAvgKeyMs}function o(){const u=pk(s.buffer,t);return!u||u.code.length<n.minLength||u.shape.digitsOnly&&!i(u.code)?null:u.code}function c(){s={buffer:"",times:[],lastKeyMs:0}}function m(u){const{key:d,timeMs:b,hasModifier:x,isRepeat:v}=u;if(yk.has(d))return uc;if(n.terminators.includes(d)){const B=o();return c(),B?{suppress:!0,emit:B,consumedLength:B.length}:uc}if(x||v||d.length!==1)return c(),uc;const w=b-s.lastKeyMs,S=s.lastKeyMs>0&&w<=n.maxKeyGapMs,C=(S?s.buffer+d:d).slice(-128),q=(S?[...s.times,b]:[b]).slice(-128);return s={buffer:C,times:q,lastKeyMs:b},uc}function y(){return{buffer:s.buffer}}function g(){const u=o();return!u||!i(u)?null:{code:u,consumedLength:u.length}}return{step:m,reset:c,snapshot:y,pendingAutoFire:g}}function bk(){const n=document.activeElement;return n instanceof HTMLInputElement?["text","search","tel","url","email","password","number"].includes(n.type)?n:null:n instanceof HTMLTextAreaElement?n:null}function xk(n,t,s){var c;const i=n instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,o=(c=Object.getOwnPropertyDescriptor(i,"value"))==null?void 0:c.set;o?o.call(n,t):n.value=t;try{n.setSelectionRange(s,s)}catch{}n.dispatchEvent(new Event("input",{bubbles:!0}))}function T1(n){if(n<=0)return;const t=bk();if(!t)return;const s=t.selectionStart??t.value.length,i=Math.max(0,s-n);xk(t,t.value.slice(0,i)+t.value.slice(s),i)}function vk({active:n,wedgeConfig:t,tailShapes:s,diagnosticsOn:i,onScan:o,onDiag:c}){const m=E.useRef({diagnosticsOn:i,onScan:o,onDiag:c});m.current={diagnosticsOn:i,onScan:o,onDiag:c};const y=E.useRef(0),g=E.useRef(0);E.useEffect(()=>{if(!n)return;const u=gk(t,s);let d=null;const b=()=>{d&&(clearTimeout(d),d=null)},x=(S,C,q)=>{C&&T1(C),m.current.diagnosticsOn&&(console.debug("[scan]",q),m.current.onDiag({seq:++y.current,key:"(quiet)",code:"",deltaMs:0,buffer:"",note:q})),m.current.onScan(S)},v=()=>{b(),u.pendingAutoFire()&&(d=setTimeout(()=>{d=null;const S=u.pendingAutoFire();S&&(u.reset(),x(S.code,S.consumedLength,`capture → ${S.code} (quiet period — no suffix)`))},t.autoFireQuietMs))},w=S=>{const C=u.snapshot().buffer,{suppress:q,emit:B,consumedLength:ie}=u.step({key:S.key,timeMs:S.timeStamp,hasModifier:S.ctrlKey||S.metaKey||S.altKey,isRepeat:S.repeat});if(q&&(S.preventDefault(),S.stopPropagation()),m.current.diagnosticsOn){const le=u.snapshot().buffer,R=t.terminators.includes(S.key),$=B?`capture → ${B}`:R?`terminator — no code tail in "${C.slice(-24)}"`:le===C?C?"neutral (chord key)":"ignored":le===""?"reset (edit/chord/non-printable)":le.length<=1&&C.length>1?"gap — new episode":"accumulate",ne=g.current?Math.round(S.timeStamp-g.current):0,V={seq:++y.current,key:S.key,code:S.code!==S.key?S.code:"",deltaMs:ne,buffer:le.slice(-24),note:$};console.debug("[scan]",V.key,V.code,`${V.deltaMs}ms`,V.note),m.current.onDiag(V)}g.current=S.timeStamp,B?(b(),ie&&T1(ie),m.current.onScan(B)):v()};return window.addEventListener("keydown",w,{capture:!0}),()=>{b(),window.removeEventListener("keydown",w,{capture:!0})}},[n,t,s])}const Ae={EXECUTED:"executed",MATCHED_LIST:"matched_list",CONFIRM_REQUIRED:"confirm_required",NO_MATCH_FALLBACK:"no_match_fallback",UNCONFIGURED:"unconfigured",INVALID_CODE:"invalid_code",FORBIDDEN:"forbidden",CONFLICT:"conflict",IDENTITY_PRIMED:"identity_primed",IDENTITY_UNKNOWN:"identity_unknown",NOT_PRIMED:"not_primed",CHOICES:"choices",NO_OPEN_CONTAINER:"no_open_container",HELD:"held",REFUSED:"refused",SUBJECT_STALE:"subject_stale"},fc={SHOW_DETAIL:"show-detail",SHOW_LIST:"show-list",CLAIM:"claim",CLAIM_SHOW_DETAIL:"claim-show-detail",RELEASE:"release",RESOLVE:"resolve",ESCALATE:"escalate",CANCEL:"cancel",ACCUMULATE:"accumulate",PRESENT:"present",HOLD:"hold",FILL:"fill"},_k={ACTION:"action",IDENTITY:"identity"};function wk(n,t){return fe("/scan-codes/execute",{method:"POST",body:JSON.stringify({code:n,...t!=null&&t.actingToken?{actingToken:t.actingToken}:{},...t!=null&&t.previousActingToken?{previousActingToken:t.previousActingToken}:{},...t!=null&&t.subject?{subject:t.subject}:{},...t!=null&&t.stationRole?{stationRole:t.stationRole}:{}})})}function I5(n){return fe("/scan-codes/execute-choice",{method:"POST",body:JSON.stringify(n)})}function bv(n){return $e({queryKey:["scan-schemes"],queryFn:()=>fe("/scan-codes/schemes"),...n})}function $5(n){return $e({queryKey:["scan-schemes",n],queryFn:()=>fe(`/scan-codes/schemes/${n}`),enabled:n!=null})}function H5(){const n=He();return Ve({mutationFn:t=>fe(`/scan-codes/schemes/${t.version}`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function F5(){const n=He();return Ve({mutationFn:t=>fe(`/scan-codes/schemes/${t}`,{method:"DELETE"}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function G5(){const n=He();return Ve({mutationFn:t=>fe(`/scan-codes/schemes/${t.scheme_version}/actions/${t.category}`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:(t,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}function V5(){const n=He();return Ve({mutationFn:t=>fe(`/scan-codes/schemes/${t.scheme_version}/actions/${t.category}`,{method:"DELETE"}),onSuccess:(t,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}const Sk=3e4;function Ek(n,t=Date.now()){if(!(!n||Date.parse(n.expiresAt)<=t))return{code:n.code,escalationId:n.escalationId}}function C1(n,t,s=Date.now()){if(t.outcome===Ae.HELD&&t.subject){const i=Math.max(0,Date.parse(t.subject.expiresAt)-s);return{...t.subject,ttlMs:i}}return t.clearSubject||!n?null:t.outcome===Ae.EXECUTED&&t.progress&&t.progress.remaining>0?{...n,expiresAt:new Date(s+n.ttlMs).toISOString()}:n}function M1(n){return n.outcome===Ae.NOT_PRIMED&&n.replayable===!0}function Ok(n,t=Date.now()){return n&&t-n.at<=Sk?n:null}const Ak=[Ae.HELD,Ae.REFUSED,Ae.SUBJECT_STALE],jo={KEYBOARD_WEDGE:"keyboard-wedge",MANUAL:"manual",TOOLBAR:"toolbar"},$i=n=>{if(n)try{return JSON.parse(n)}catch{return}},Qs=n=>n==null||Array.isArray(n)&&n.length===0||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0;function jk(n){const t={},s=$i(n.get("facets"));Qs(s)||(t.facets=s);const i=$i(n.get("block"));Qs(i)||(t.block=i);const o=$i(n.get("range"));Qs(o)||(t.range=o);const c=$i(n.get("exists"));Qs(c)||(t.exists=c);const m=$i(n.get("roles"));Qs(m)||(t.roles=m);const y=$i(n.get("orderBy"));Qs(y)||(t.orderBy=y),n.get("available")!=null&&(t.available=n.get("available")==="true");const g=n.get("jeopardy");return(g==="1"||g==="true")&&(t.jeopardy=!0),t}function Y5(n,t){const s=(i,o)=>Qs(o)?n.delete(i):n.set(i,JSON.stringify(o));s("facets",t.facets),s("block",t.block),s("range",t.range),s("exists",t.exists),s("roles",t.roles),s("orderBy",t.orderBy),t.available==null?n.delete("available"):n.set("available",String(t.available)),t.jeopardy===!0?n.set("jeopardy","1"):n.delete("jeopardy")}const R1=`&status=all&view=table&orderBy=${encodeURIComponent(JSON.stringify([{field:"created_at",direction:"desc"}]))}`;function xv(n,t){const s={};for(const[o,c]of Object.entries(n))s[o]=typeof c=="object"&&c!==null?JSON.stringify(c):c;const i=encodeURIComponent(JSON.stringify(s));return t?`/escalations/available?role=${encodeURIComponent(t)}&facets=${i}${R1}`:`/escalations/available?facets=${i}${R1}`}function kk(n,t,s){return xv({[n]:t},s)}function K5(n){var t,s,i;return Object.keys(n.facets??{}).length+(((t=n.block)==null?void 0:t.length)??0)+(((s=n.range)==null?void 0:s.length)??0)+(((i=n.exists)==null?void 0:i.length)??0)+(n.available!=null?1:0)+(n.jeopardy===!0?1:0)}function Dm(){var s;const{data:n}=Zn(),t=Gx();return t!==null?t:!!((s=n==null?void 0:n.features)!=null&&s.scanCodes)}const Lm=E.createContext(null);function qm(){const n=E.useContext(Lm);if(!n)throw new Error("useScanInput must be used within ScanInputProvider");return n}function J5(){return E.useContext(Lm)}const Nk="scanPendingAction",Tk="scanChoices",od="/scan/station";function Ck({children:n}){const{user:t}=Pt(),s=Dm(),i=ra(),o=an(),{identity:c,prime:m,clear:y,settle:g}=lk(),[u,d]=E.useState(null),[b,x]=E.useState(null),[v,w]=E.useState(null),{data:S}=bv({enabled:!!t&&s,staleTime:6e4}),C=E.useRef(null);C.current=Sm().role;const q=E.useMemo(()=>mk((S==null?void 0:S.schemes)??[]),[S]),[B,ie]=E.useState(!1),[le,R]=E.useState(()=>gv()),[$,ne]=E.useState([]),[V,I]=E.useState(!1),D=E.useCallback(we=>{var Be;const{outcome:Re}=we;if(Re===Ae.CONFIRM_REQUIRED&&we.pendingAction)return i(`/escalations/detail/${we.pendingAction.escalationId}`,{state:{[Nk]:we.pendingAction}}),!0;const oe=Re===Ae.EXECUTED&&!!H.current;if(Ak.includes(Re)||M1(we)||oe)return ce.current!==od&&i(od),!0;if(Re===Ae.EXECUTED&&we.escalation){const We=[fc.SHOW_DETAIL,fc.CLAIM_SHOW_DETAIL,fc.CLAIM,fc.ESCALATE];return we.verb&&We.includes(we.verb)?(i(`/escalations/detail/${we.escalation.id}`),!0):!1}if(Re===Ae.MATCHED_LIST&&we.listQuery){const{targetFacet:We,target:ln,roles:pe}=we.listQuery;return i(xv({[We]:ln},(pe==null?void 0:pe[0])??null)),!0}return Re===Ae.CHOICES&&we.choices?(i(od,{state:{[Tk]:we}}),!0):Re===Ae.NO_MATCH_FALLBACK&&((Be=we.fallback)!=null&&Be.route)?(i(we.fallback.route),!0):!1},[i]),Q=E.useRef(null);Q.current=(c==null?void 0:c.actingToken)??null;const X=E.useRef(null),he=E.useRef([]),Se=E.useCallback(we=>(he.current=[we,...he.current],()=>{he.current=he.current.filter(Re=>Re!==we)}),[]),ke=E.useRef(null);ke.current=b;const H=E.useRef(void 0),W=E.useRef(null);W.current=v;const ce=E.useRef(o.pathname);ce.current=o.pathname,E.useEffect(()=>{if(!b)return;const we=Date.parse(b.expiresAt)-Date.now();if(we<=0){x(null);return}const Re=setTimeout(()=>x(null),we);return()=>clearTimeout(Re)},[b]);const xe=E.useCallback(async(we,Re,oe)=>{ie(!0);const Be=Date.now();try{H.current=Ek(ke.current);const We=await wk(we,{actingToken:oe??void 0,previousActingToken:X.current??void 0,subject:H.current,stationRole:C.current??void 0});if(oe&&g(oe,We),x(pe=>C1(pe,We)),We.outcome===Ae.IDENTITY_PRIMED){X.current=m(We);const pe=Ok(W.current);if(w(null),pe&&We.actingToken){d({code:we,source:Re,at:Be,response:We,error:null,navigated:!1}),await xe(pe.code,Re,We.actingToken);return}}else M1(We)?w({code:we,at:Be}):w(null);We.outcome===Ae.NOT_PRIMED&&oe&&y();const ln=D(We);d({code:we,source:Re,at:Be,response:We,error:null,navigated:ln})}catch(We){d({code:we,source:Re,at:Be,response:null,error:We.message,navigated:!1})}finally{ie(!1)}},[D,m,y,g]),ve=E.useCallback(async(we,Re=jo.MANUAL)=>{for(const oe of he.current)if(oe(we))return;await xe(we,Re,Q.current)},[xe]),Ce=E.useCallback(()=>x(null),[]),Ne=E.useCallback(we=>{x(Re=>C1(Re,we))},[]),Me=E.useCallback(()=>w(null),[]),Ze=E.useRef(ve);Ze.current=ve,vk({active:!!t&&s,wedgeConfig:le,tailShapes:q,diagnosticsOn:V,onScan:we=>void Ze.current(we,jo.KEYBOARD_WEDGE),onDiag:we=>ne(Re=>[...Re.slice(-29),we])});const yt=E.useCallback(we=>{R(hk(we))},[]),Ct=E.useMemo(()=>({submitCode:ve,pushCodeInterceptor:Se,lastResult:u,subject:b,dropSubject:Ce,adoptResponse:Ne,pendingScan:v,dropPendingScan:Me,busy:B,wedgeConfig:le,updateWedgeConfig:yt,diagnostics:$,diagnosticsOn:V,setDiagnosticsOn:I}),[ve,Se,u,b,Ce,Ne,v,Me,B,le,yt,$,V]);return h.jsx(Lm.Provider,{value:Ct,children:n})}var hc={},oo={},dc={},D1;function kn(){if(D1)return dc;D1=1,Object.defineProperty(dc,"__esModule",{value:!0});function n(s,i){if(!(s instanceof i))throw new TypeError("Cannot call a class as a function")}var t=function s(i,o){n(this,s),this.data=i,this.text=o.text||i,this.options=o};return dc.default=t,dc}var L1;function Mk(){if(L1)return oo;L1=1,Object.defineProperty(oo,"__esModule",{value:!0}),oo.CODE39=void 0;var n=(function(){function S(C,q){for(var B=0;B<q.length;B++){var ie=q[B];ie.enumerable=ie.enumerable||!1,ie.configurable=!0,"value"in ie&&(ie.writable=!0),Object.defineProperty(C,ie.key,ie)}}return function(C,q,B){return q&&S(C.prototype,q),B&&S(C,B),C}})(),t=kn(),s=i(t);function i(S){return S&&S.__esModule?S:{default:S}}function o(S,C){if(!(S instanceof C))throw new TypeError("Cannot call a class as a function")}function c(S,C){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return C&&(typeof C=="object"||typeof C=="function")?C:S}function m(S,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof C);S.prototype=Object.create(C&&C.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),C&&(Object.setPrototypeOf?Object.setPrototypeOf(S,C):S.__proto__=C)}var y=(function(S){m(C,S);function C(q,B){return o(this,C),q=q.toUpperCase(),B.mod43&&(q+=x(w(q))),c(this,(C.__proto__||Object.getPrototypeOf(C)).call(this,q,B))}return n(C,[{key:"encode",value:function(){for(var B=d("*"),ie=0;ie<this.data.length;ie++)B+=d(this.data[ie])+"0";return B+=d("*"),{data:B,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),C})(s.default),g=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],u=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function d(S){return b(v(S))}function b(S){return u[S].toString(2)}function x(S){return g[S]}function v(S){return g.indexOf(S)}function w(S){for(var C=0,q=0;q<S.length;q++)C+=v(S[q]);return C=C%43,C}return oo.CODE39=y,oo}var Kn={},mc={},pc={},vt={},q1;function Ro(){if(q1)return vt;q1=1,Object.defineProperty(vt,"__esModule",{value:!0});var n;function t(g,u,d){return u in g?Object.defineProperty(g,u,{value:d,enumerable:!0,configurable:!0,writable:!0}):g[u]=d,g}var s=vt.SET_A=0,i=vt.SET_B=1,o=vt.SET_C=2;vt.SHIFT=98;var c=vt.START_A=103,m=vt.START_B=104,y=vt.START_C=105;return vt.MODULO=103,vt.STOP=106,vt.FNC1=207,vt.SET_BY_CODE=(n={},t(n,c,s),t(n,m,i),t(n,y,o),n),vt.SWAP={101:s,100:i,99:o},vt.A_START_CHAR="Ð",vt.B_START_CHAR="Ñ",vt.C_START_CHAR="Ò",vt.A_CHARS="[\0-_È-Ï]",vt.B_CHARS="[ -È-Ï]",vt.C_CHARS="(Ï*[0-9]{2}Ï*)",vt.BARS=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011],vt}var B1;function Tu(){if(B1)return pc;B1=1,Object.defineProperty(pc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=kn(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){c(this,d);var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b.substring(1),x));return v.bytes=b.split("").map(function(w){return w.charCodeAt(0)}),v}return n(d,[{key:"valid",value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.bytes,v=x.shift()-105,w=i.SET_BY_CODE[v];if(w===void 0)throw new RangeError("The encoding does not start with a start character.");this.shouldEncodeAsEan128()===!0&&x.unshift(i.FNC1);var S=d.next(x,1,w);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:d.getBar(v)+S.result+d.getBar((S.checksum+v)%i.MODULO)+d.getBar(i.STOP)}}},{key:"shouldEncodeAsEan128",value:function(){var x=this.options.ean128||!1;return typeof x=="string"&&(x=x.toLowerCase()==="true"),x}}],[{key:"getBar",value:function(x){return i.BARS[x]?i.BARS[x].toString():""}},{key:"correctIndex",value:function(x,v){if(v===i.SET_A){var w=x.shift();return w<32?w+64:w-32}else return v===i.SET_B?x.shift()-32:(x.shift()-48)*10+x.shift()-48}},{key:"next",value:function(x,v,w){if(!x.length)return{result:"",checksum:0};var S=void 0,C=void 0;if(x[0]>=200){C=x.shift()-105;var q=i.SWAP[C];q!==void 0?S=d.next(x,v+1,q):((w===i.SET_A||w===i.SET_B)&&C===i.SHIFT&&(x[0]=w===i.SET_A?x[0]>95?x[0]-96:x[0]:x[0]<32?x[0]+96:x[0]),S=d.next(x,v+1,w))}else C=d.correctIndex(x,w),S=d.next(x,v+1,w);var B=d.getBar(C),ie=C*v;return{result:B+S.result,checksum:ie+S.checksum}}}]),d})(s.default);return pc.default=g,pc}var yc={},P1;function Rk(){if(P1)return yc;P1=1,Object.defineProperty(yc,"__esModule",{value:!0});var n=Ro(),t=function(y){return y.match(new RegExp("^"+n.A_CHARS+"*"))[0].length},s=function(y){return y.match(new RegExp("^"+n.B_CHARS+"*"))[0].length},i=function(y){return y.match(new RegExp("^"+n.C_CHARS+"*"))[0]};function o(m,y){var g=y?n.A_CHARS:n.B_CHARS,u=m.match(new RegExp("^("+g+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(u)return u[1]+"Ì"+c(m.substring(u[1].length));var d=m.match(new RegExp("^"+g+"+"))[0];return d.length===m.length?m:d+String.fromCharCode(y?205:206)+o(m.substring(d.length),!y)}function c(m){var y=i(m),g=y.length;if(g===m.length)return m;m=m.substring(g);var u=t(m)>=s(m);return y+String.fromCharCode(u?206:205)+o(m,u)}return yc.default=function(m){var y=void 0,g=i(m).length;if(g>=2)y=n.C_START_CHAR+c(m);else{var u=t(m)>s(m);y=(u?n.A_START_CHAR:n.B_START_CHAR)+o(m,u)}return y.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,b){return"Ë"+b})},yc}var U1;function Dk(){if(U1)return mc;U1=1,Object.defineProperty(mc,"__esModule",{value:!0});var n=Tu(),t=o(n),s=Rk(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){if(c(this,d),/^[\x00-\x7F\xC8-\xD3]+$/.test(b))var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,(0,i.default)(b),x));else var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x));return m(v)}return d})(t.default);return mc.default=g,mc}var gc={},z1;function Lk(){if(z1)return gc;z1=1,Object.defineProperty(gc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=Tu(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.A_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.A_CHARS+"+$").test(this.data)}}]),d})(s.default);return gc.default=g,gc}var bc={},I1;function qk(){if(I1)return bc;I1=1,Object.defineProperty(bc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=Tu(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.B_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.B_CHARS+"+$").test(this.data)}}]),d})(s.default);return bc.default=g,bc}var xc={},$1;function Bk(){if($1)return xc;$1=1,Object.defineProperty(xc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=Tu(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.C_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.C_CHARS+"+$").test(this.data)}}]),d})(s.default);return xc.default=g,xc}var H1;function Pk(){if(H1)return Kn;H1=1,Object.defineProperty(Kn,"__esModule",{value:!0}),Kn.CODE128C=Kn.CODE128B=Kn.CODE128A=Kn.CODE128=void 0;var n=Dk(),t=g(n),s=Lk(),i=g(s),o=qk(),c=g(o),m=Bk(),y=g(m);function g(u){return u&&u.__esModule?u:{default:u}}return Kn.CODE128=t.default,Kn.CODE128A=i.default,Kn.CODE128B=c.default,Kn.CODE128C=y.default,Kn}var Yt={},vc={},Tr={},F1;function Do(){return F1||(F1=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.SIDE_BIN="101",Tr.MIDDLE_BIN="01010",Tr.BINARIES={L:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],G:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],R:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],O:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],E:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"]},Tr.EAN2_STRUCTURE=["LL","LG","GL","GG"],Tr.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],Tr.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),Tr}var _c={},wc={},G1;function Lo(){if(G1)return wc;G1=1,Object.defineProperty(wc,"__esModule",{value:!0});var n=Do(),t=function(i,o,c){var m=i.split("").map(function(g,u){return n.BINARIES[o[u]]}).map(function(g,u){return g?g[i[u]]:""});if(c){var y=i.length-1;m=m.map(function(g,u){return u<y?g+c:g})}return m.join("")};return wc.default=t,wc}var V1;function vv(){if(V1)return _c;V1=1,Object.defineProperty(_c,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var w=0;w<v.length;w++){var S=v[w];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,w){return v&&b(x.prototype,v),w&&b(x,w),x}})(),t=Do(),s=Lo(),i=m(s),o=kn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function y(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,w){y(this,x);var S=g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,w));return S.fontSize=!w.flat&&w.fontSize>w.width*10?w.width*10:w.fontSize,S.guardHeight=w.height+S.fontSize/2+w.textMargin,S}return n(x,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(w,S){return this.text.substr(w,S)}},{key:"leftEncode",value:function(w,S){return(0,i.default)(w,S)}},{key:"rightText",value:function(w,S){return this.text.substr(w,S)}},{key:"rightEncode",value:function(w,S){return(0,i.default)(w,S)}},{key:"encodeGuarded",value:function(){var w={fontSize:this.fontSize},S={height:this.guardHeight};return[{data:t.SIDE_BIN,options:S},{data:this.leftEncode(),text:this.leftText(),options:w},{data:t.MIDDLE_BIN,options:S},{data:this.rightEncode(),text:this.rightText(),options:w},{data:t.SIDE_BIN,options:S}]}},{key:"encodeFlat",value:function(){var w=[t.SIDE_BIN,this.leftEncode(),t.MIDDLE_BIN,this.rightEncode(),t.SIDE_BIN];return{data:w.join(""),text:this.text}}}]),x})(c.default);return _c.default=d,_c}var Y1;function Uk(){if(Y1)return vc;Y1=1,Object.defineProperty(vc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var w=0;w<v.length;w++){var S=v[w];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,w){return v&&b(x.prototype,v),w&&b(x,w),x}})(),t=function b(x,v,w){x===null&&(x=Function.prototype);var S=Object.getOwnPropertyDescriptor(x,v);if(S===void 0){var C=Object.getPrototypeOf(x);return C===null?void 0:b(C,v,w)}else{if("value"in S)return S.value;var q=S.get;return q===void 0?void 0:q.call(w)}},s=Do(),i=vv(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function y(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=function(x){var v=x.substr(0,12).split("").map(function(w){return+w}).reduce(function(w,S,C){return C%2?w+S*3:w+S},0);return(10-v%10)%10},d=(function(b){g(x,b);function x(v,w){m(this,x),v.search(/^[0-9]{12}$/)!==-1&&(v+=u(v));var S=y(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,w));return S.lastChar=w.lastChar,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===u(this.data)}},{key:"leftText",value:function(){return t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var w=this.data.substr(1,6),S=s.EAN13_STRUCTURE[this.data[0]];return t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftEncode",this).call(this,w,S)}},{key:"rightText",value:function(){return t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var w=this.data.substr(7,6);return t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightEncode",this).call(this,w,"RRRRRR")}},{key:"encodeGuarded",value:function(){var w=t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(w.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(w.push({data:"00"}),w.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),w}}]),x})(o.default);return vc.default=d,vc}var Sc={},K1;function zk(){if(K1)return Sc;K1=1,Object.defineProperty(Sc,"__esModule",{value:!0});var n=(function(){function d(b,x){for(var v=0;v<x.length;v++){var w=x[v];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(b,w.key,w)}}return function(b,x,v){return x&&d(b.prototype,x),v&&d(b,v),b}})(),t=function d(b,x,v){b===null&&(b=Function.prototype);var w=Object.getOwnPropertyDescriptor(b,x);if(w===void 0){var S=Object.getPrototypeOf(b);return S===null?void 0:d(S,x,v)}else{if("value"in w)return w.value;var C=w.get;return C===void 0?void 0:C.call(v)}},s=vv(),i=o(s);function o(d){return d&&d.__esModule?d:{default:d}}function c(d,b){if(!(d instanceof b))throw new TypeError("Cannot call a class as a function")}function m(d,b){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:d}function y(d,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);d.prototype=Object.create(b&&b.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(d,b):d.__proto__=b)}var g=function(b){var x=b.substr(0,7).split("").map(function(v){return+v}).reduce(function(v,w,S){return S%2?v+w:v+w*3},0);return(10-x%10)%10},u=(function(d){y(b,d);function b(x,v){return c(this,b),x.search(/^[0-9]{7}$/)!==-1&&(x+=g(x)),m(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,x,v))}return n(b,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===g(this.data)}},{key:"leftText",value:function(){return t(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftText",this).call(this,0,4)}},{key:"leftEncode",value:function(){var v=this.data.substr(0,4);return t(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftEncode",this).call(this,v,"LLLL")}},{key:"rightText",value:function(){return t(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightText",this).call(this,4,4)}},{key:"rightEncode",value:function(){var v=this.data.substr(4,4);return t(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightEncode",this).call(this,v,"RRRR")}}]),b})(i.default);return Sc.default=u,Sc}var Ec={},J1;function Ik(){if(J1)return Ec;J1=1,Object.defineProperty(Ec,"__esModule",{value:!0});var n=(function(){function x(v,w){for(var S=0;S<w.length;S++){var C=w[S];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(v,C.key,C)}}return function(v,w,S){return w&&x(v.prototype,w),S&&x(v,S),v}})(),t=Do(),s=Lo(),i=m(s),o=kn(),c=m(o);function m(x){return x&&x.__esModule?x:{default:x}}function y(x,v){if(!(x instanceof v))throw new TypeError("Cannot call a class as a function")}function g(x,v){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:x}function u(x,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);x.prototype=Object.create(v&&v.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(x,v):x.__proto__=v)}var d=function(v){var w=v.split("").map(function(S){return+S}).reduce(function(S,C,q){return q%2?S+C*9:S+C*3},0);return w%10},b=(function(x){u(v,x);function v(w,S){return y(this,v),g(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,w,S))}return n(v,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var S=t.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,i.default)(this.data,S,"01"),text:this.text}}}]),v})(c.default);return Ec.default=b,Ec}var Oc={},X1;function $k(){if(X1)return Oc;X1=1,Object.defineProperty(Oc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var w=0;w<v.length;w++){var S=v[w];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,w){return v&&b(x.prototype,v),w&&b(x,w),x}})(),t=Do(),s=Lo(),i=m(s),o=kn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function y(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,w){return y(this,x),g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,w))}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var w=t.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,i.default)(this.data,w,"01"),text:this.text}}}]),x})(c.default);return Oc.default=d,Oc}var lo={},Q1;function _v(){if(Q1)return lo;Q1=1,Object.defineProperty(lo,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var w=0;w<v.length;w++){var S=v[w];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,w){return v&&b(x.prototype,v),w&&b(x,w),x}})();lo.checksum=d;var t=Lo(),s=c(t),i=kn(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function y(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=(function(b){g(x,b);function x(v,w){m(this,x),v.search(/^[0-9]{11}$/)!==-1&&(v+=d(v));var S=y(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,w));return S.displayValue=w.displayValue,w.fontSize>w.width*10?S.fontSize=w.width*10:S.fontSize=w.fontSize,S.guardHeight=w.height+S.fontSize/2+w.textMargin,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==d(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var w="";return w+="101",w+=(0,s.default)(this.data.substr(0,6),"LLLLLL"),w+="01010",w+=(0,s.default)(this.data.substr(6,6),"RRRRRR"),w+="101",{data:w,text:this.text}}},{key:"guardedEncoding",value:function(){var w=[];return this.displayValue&&w.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),w.push({data:"101"+(0,s.default)(this.data[0],"L"),options:{height:this.guardHeight}}),w.push({data:(0,s.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),w.push({data:"01010",options:{height:this.guardHeight}}),w.push({data:(0,s.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),w.push({data:(0,s.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&w.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),w}}]),x})(o.default);function d(b){var x=0,v;for(v=1;v<11;v+=2)x+=parseInt(b[v]);for(v=0;v<11;v+=2)x+=parseInt(b[v])*3;return(10-x%10)%10}return lo.default=u,lo}var Ac={},W1;function Hk(){if(W1)return Ac;W1=1,Object.defineProperty(Ac,"__esModule",{value:!0});var n=(function(){function w(S,C){for(var q=0;q<C.length;q++){var B=C[q];B.enumerable=B.enumerable||!1,B.configurable=!0,"value"in B&&(B.writable=!0),Object.defineProperty(S,B.key,B)}}return function(S,C,q){return C&&w(S.prototype,C),q&&w(S,q),S}})(),t=Lo(),s=m(t),i=kn(),o=m(i),c=_v();function m(w){return w&&w.__esModule?w:{default:w}}function y(w,S){if(!(w instanceof S))throw new TypeError("Cannot call a class as a function")}function g(w,S){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:w}function u(w,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);w.prototype=Object.create(S&&S.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(w,S):w.__proto__=S)}var d=["XX00000XXX","XX10000XXX","XX20000XXX","XXX00000XX","XXXX00000X","XXXXX00005","XXXXX00006","XXXXX00007","XXXXX00008","XXXXX00009"],b=[["EEEOOO","OOOEEE"],["EEOEOO","OOEOEE"],["EEOOEO","OOEEOE"],["EEOOOE","OOEEEO"],["EOEEOO","OEOOEE"],["EOOEEO","OEEOOE"],["EOOOEE","OEEEOO"],["EOEOEO","OEOEOE"],["EOEOOE","OEOEEO"],["EOOEOE","OEEOEO"]],x=(function(w){u(S,w);function S(C,q){y(this,S);var B=g(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,C,q));if(B.isValid=!1,C.search(/^[0-9]{6}$/)!==-1)B.middleDigits=C,B.upcA=v(C,"0"),B.text=q.text||""+B.upcA[0]+C+B.upcA[B.upcA.length-1],B.isValid=!0;else if(C.search(/^[01][0-9]{7}$/)!==-1)if(B.middleDigits=C.substring(1,C.length-1),B.upcA=v(B.middleDigits,C[0]),B.upcA[B.upcA.length-1]===C[C.length-1])B.isValid=!0;else return g(B);else return g(B);return B.displayValue=q.displayValue,q.fontSize>q.width*10?B.fontSize=q.width*10:B.fontSize=q.fontSize,B.guardHeight=q.height+B.fontSize/2+q.textMargin,B}return n(S,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var q="";return q+="101",q+=this.encodeMiddleDigits(),q+="010101",{data:q,text:this.text}}},{key:"guardedEncoding",value:function(){var q=[];return this.displayValue&&q.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),q.push({data:"101",options:{height:this.guardHeight}}),q.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),q.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&q.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),q}},{key:"encodeMiddleDigits",value:function(){var q=this.upcA[0],B=this.upcA[this.upcA.length-1],ie=b[parseInt(B)][parseInt(q)];return(0,s.default)(this.middleDigits,ie)}}]),S})(o.default);function v(w,S){for(var C=parseInt(w[w.length-1]),q=d[C],B="",ie=0,le=0;le<q.length;le++){var R=q[le];R==="X"?B+=w[ie++]:B+=R}return B=""+S+B,""+B+(0,c.checksum)(B)}return Ac.default=x,Ac}var Z1;function Fk(){if(Z1)return Yt;Z1=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.UPCE=Yt.UPC=Yt.EAN2=Yt.EAN5=Yt.EAN8=Yt.EAN13=void 0;var n=Uk(),t=x(n),s=zk(),i=x(s),o=Ik(),c=x(o),m=$k(),y=x(m),g=_v(),u=x(g),d=Hk(),b=x(d);function x(v){return v&&v.__esModule?v:{default:v}}return Yt.EAN13=t.default,Yt.EAN8=i.default,Yt.EAN5=c.default,Yt.EAN2=y.default,Yt.UPC=u.default,Yt.UPCE=b.default,Yt}var Ks={},jc={},Hi={},eb;function Gk(){return eb||(eb=1,Object.defineProperty(Hi,"__esModule",{value:!0}),Hi.START_BIN="1010",Hi.END_BIN="11101",Hi.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),Hi}var tb;function wv(){if(tb)return jc;tb=1,Object.defineProperty(jc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=Gk(),s=kn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return n(d,[{key:"valid",value:function(){return this.data.search(/^([0-9]{2})+$/)!==-1}},{key:"encode",value:function(){var x=this,v=this.data.match(/.{2}/g).map(function(w){return x.encodePair(w)}).join("");return{data:t.START_BIN+v+t.END_BIN,text:this.text}}},{key:"encodePair",value:function(x){var v=t.BINARIES[x[1]];return t.BINARIES[x[0]].split("").map(function(w,S){return(w==="1"?"111":"1")+(v[S]==="1"?"000":"0")}).join("")}}]),d})(i.default);return jc.default=g,jc}var kc={},nb;function Vk(){if(nb)return kc;nb=1,Object.defineProperty(kc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=wv(),s=i(t);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var y=function(d){var b=d.substr(0,13).split("").map(function(x){return parseInt(x,10)}).reduce(function(x,v,w){return x+v*(3-w%2*2)},0);return Math.ceil(b/10)*10-b},g=(function(u){m(d,u);function d(b,x){return o(this,d),b.search(/^[0-9]{13}$/)!==-1&&(b+=y(b)),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===y(this.data)}}]),d})(s.default);return kc.default=g,kc}var rb;function Yk(){if(rb)return Ks;rb=1,Object.defineProperty(Ks,"__esModule",{value:!0}),Ks.ITF14=Ks.ITF=void 0;var n=wv(),t=o(n),s=Vk(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Ks.ITF=t.default,Ks.ITF14=i.default,Ks}var bn={},Nc={},sb;function qo(){if(sb)return Nc;sb=1,Object.defineProperty(Nc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=kn(),s=i(t);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var y=(function(u){m(d,u);function d(b,x){return o(this,d),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"encode",value:function(){for(var x="110",v=0;v<this.data.length;v++){var w=parseInt(this.data[v]),S=w.toString(2);S=g(S,4-S.length);for(var C=0;C<S.length;C++)x+=S[C]=="0"?"100":"110"}return x+="1001",{data:x,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),d})(s.default);function g(u,d){for(var b=0;b<d;b++)u="0"+u;return u}return Nc.default=y,Nc}var Tc={},co={},ib;function Cu(){if(ib)return co;ib=1,Object.defineProperty(co,"__esModule",{value:!0}),co.mod10=n,co.mod11=t;function n(s){for(var i=0,o=0;o<s.length;o++){var c=parseInt(s[o]);(o+s.length)%2===0?i+=c:i+=c*2%10+Math.floor(c*2/10)}return(10-i%10)%10}function t(s){for(var i=0,o=[2,3,4,5,6,7],c=0;c<s.length;c++){var m=parseInt(s[s.length-1-c]);i+=o[c%o.length]*m}return(11-i%11)%11}return co}var ab;function Kk(){if(ab)return Tc;ab=1,Object.defineProperty(Tc,"__esModule",{value:!0});var n=qo(),t=i(n),s=Cu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod10)(d),b))}return u})(t.default);return Tc.default=y,Tc}var Cc={},ob;function Jk(){if(ob)return Cc;ob=1,Object.defineProperty(Cc,"__esModule",{value:!0});var n=qo(),t=i(n),s=Cu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod11)(d),b))}return u})(t.default);return Cc.default=y,Cc}var Mc={},lb;function Xk(){if(lb)return Mc;lb=1,Object.defineProperty(Mc,"__esModule",{value:!0});var n=qo(),t=i(n),s=Cu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod10)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(t.default);return Mc.default=y,Mc}var Rc={},cb;function Qk(){if(cb)return Rc;cb=1,Object.defineProperty(Rc,"__esModule",{value:!0});var n=qo(),t=i(n),s=Cu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod11)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(t.default);return Rc.default=y,Rc}var ub;function Wk(){if(ub)return bn;ub=1,Object.defineProperty(bn,"__esModule",{value:!0}),bn.MSI1110=bn.MSI1010=bn.MSI11=bn.MSI10=bn.MSI=void 0;var n=qo(),t=d(n),s=Kk(),i=d(s),o=Jk(),c=d(o),m=Xk(),y=d(m),g=Qk(),u=d(g);function d(b){return b&&b.__esModule?b:{default:b}}return bn.MSI=t.default,bn.MSI10=i.default,bn.MSI11=c.default,bn.MSI1010=y.default,bn.MSI1110=u.default,bn}var uo={},fb;function Zk(){if(fb)return uo;fb=1,Object.defineProperty(uo,"__esModule",{value:!0}),uo.pharmacode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),t=kn(),s=i(t);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){o(this,u);var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b));return x.number=parseInt(d,10),x}return n(u,[{key:"encode",value:function(){for(var b=this.number,x="";!isNaN(b)&&b!=0;)b%2===0?(x="11100"+x,b=(b-2)/2):(x="100"+x,b=(b-1)/2);return x=x.slice(0,-2),{data:x,text:this.text}}},{key:"valid",value:function(){return this.number>=3&&this.number<=131070}}]),u})(s.default);return uo.pharmacode=y,uo}var fo={},hb;function eN(){if(hb)return fo;hb=1,Object.defineProperty(fo,"__esModule",{value:!0}),fo.codabar=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),t=kn(),s=i(t);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){o(this,u),d.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(d="A"+d+"A");var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d.toUpperCase(),b));return x.text=x.options.text||x.text.replace(/[A-D]/g,""),x}return n(u,[{key:"valid",value:function(){return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)!==-1}},{key:"encode",value:function(){for(var b=[],x=this.getEncodings(),v=0;v<this.data.length;v++)b.push(x[this.data.charAt(v)]),v!==this.data.length-1&&b.push("0");return{text:this.text,data:b.join("")}}},{key:"getEncodings",value:function(){return{0:"101010011",1:"101011001",2:"101001011",3:"110010101",4:"101101001",5:"110101001",6:"100101011",7:"100101101",8:"100110101",9:"110100101","-":"101001101",$:"101100101",":":"1101011011","/":"1101101011",".":"1101101101","+":"1011011011",A:"1011001001",B:"1001001011",C:"1010010011",D:"1010011001"}}}]),u})(s.default);return fo.codabar=y,fo}var Js={},Dc={},Fi={},db;function tN(){return db||(db=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.SYMBOLS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],Fi.BINARIES=["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010","101011110"],Fi.MULTI_SYMBOLS={"\0":["(%)","U"],"":["($)","A"],"":["($)","B"],"":["($)","C"],"":["($)","D"],"":["($)","E"],"":["($)","F"],"\x07":["($)","G"],"\b":["($)","H"]," ":["($)","I"],"\n":["($)","J"],"\v":["($)","K"],"\f":["($)","L"],"\r":["($)","M"],"":["($)","N"],"":["($)","O"],"":["($)","P"],"":["($)","Q"],"":["($)","R"],"":["($)","S"],"":["($)","T"],"":["($)","U"],"":["($)","V"],"":["($)","W"],"":["($)","X"],"":["($)","Y"],"":["($)","Z"],"\x1B":["(%)","A"],"":["(%)","B"],"":["(%)","C"],"":["(%)","D"],"":["(%)","E"],"!":["(/)","A"],'"':["(/)","B"],"#":["(/)","C"],"&":["(/)","F"],"'":["(/)","G"],"(":["(/)","H"],")":["(/)","I"],"*":["(/)","J"],",":["(/)","L"],":":["(/)","Z"],";":["(%)","F"],"<":["(%)","G"],"=":["(%)","H"],">":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),Fi}var mb;function Sv(){if(mb)return Dc;mb=1,Object.defineProperty(Dc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),t=tN(),s=kn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function y(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){y(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.data.split("").flatMap(function(C){return t.MULTI_SYMBOLS[C]||C}),v=x.map(function(C){return d.getEncoding(C)}).join(""),w=d.checksum(x,20),S=d.checksum(x.concat(w),15);return{text:this.text,data:d.getEncoding("ÿ")+v+d.getEncoding(w)+d.getEncoding(S)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(x){return t.BINARIES[d.symbolValue(x)]}},{key:"getSymbol",value:function(x){return t.SYMBOLS[x]}},{key:"symbolValue",value:function(x){return t.SYMBOLS.indexOf(x)}},{key:"checksum",value:function(x,v){var w=x.slice().reverse().reduce(function(S,C,q){var B=q%v+1;return S+d.symbolValue(C)*B},0);return d.getSymbol(w%47)}}]),d})(i.default);return Dc.default=g,Dc}var Lc={},pb;function nN(){if(pb)return Lc;pb=1,Object.defineProperty(Lc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),t=Sv(),s=i(t);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),u})(s.default);return Lc.default=y,Lc}var yb;function rN(){if(yb)return Js;yb=1,Object.defineProperty(Js,"__esModule",{value:!0}),Js.CODE93FullASCII=Js.CODE93=void 0;var n=Sv(),t=o(n),s=nN(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Js.CODE93=t.default,Js.CODE93FullASCII=i.default,Js}var ho={},gb;function sN(){if(gb)return ho;gb=1,Object.defineProperty(ho,"__esModule",{value:!0}),ho.GenericBarcode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),t=kn(),s=i(t);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var y=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),u})(s.default);return ho.GenericBarcode=y,ho}var bb;function iN(){if(bb)return hc;bb=1,Object.defineProperty(hc,"__esModule",{value:!0});var n=Mk(),t=Pk(),s=Fk(),i=Yk(),o=Wk(),c=Zk(),m=eN(),y=rN(),g=sN();return hc.default={CODE39:n.CODE39,CODE128:t.CODE128,CODE128A:t.CODE128A,CODE128B:t.CODE128B,CODE128C:t.CODE128C,EAN13:s.EAN13,EAN8:s.EAN8,EAN5:s.EAN5,EAN2:s.EAN2,UPC:s.UPC,UPCE:s.UPCE,ITF14:i.ITF14,ITF:i.ITF,MSI:o.MSI,MSI10:o.MSI10,MSI11:o.MSI11,MSI1010:o.MSI1010,MSI1110:o.MSI1110,pharmacode:c.pharmacode,codabar:m.codabar,CODE93:y.CODE93,CODE93FullASCII:y.CODE93FullASCII,GenericBarcode:g.GenericBarcode},hc}var qc={},xb;function Mu(){if(xb)return qc;xb=1,Object.defineProperty(qc,"__esModule",{value:!0});var n=Object.assign||function(t){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t};return qc.default=function(t,s){return n({},t,s)},qc}var Bc={},vb;function aN(){if(vb)return Bc;vb=1,Object.defineProperty(Bc,"__esModule",{value:!0}),Bc.default=n;function n(t){var s=[];function i(o){if(Array.isArray(o))for(var c=0;c<o.length;c++)i(o[c]);else o.text=o.text||"",o.data=o.data||"",s.push(o)}return i(t),s}return Bc}var Pc={},_b;function oN(){if(_b)return Pc;_b=1,Object.defineProperty(Pc,"__esModule",{value:!0}),Pc.default=n;function n(t){return t.marginTop=t.marginTop||t.margin,t.marginBottom=t.marginBottom||t.margin,t.marginRight=t.marginRight||t.margin,t.marginLeft=t.marginLeft||t.margin,t}return Pc}var Uc={},zc={},Ic={},wb;function Ev(){if(wb)return Ic;wb=1,Object.defineProperty(Ic,"__esModule",{value:!0}),Ic.default=n;function n(t){var s=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var i in s)s.hasOwnProperty(i)&&(i=s[i],typeof t[i]=="string"&&(t[i]=parseInt(t[i],10)));return typeof t.displayValue=="string"&&(t.displayValue=t.displayValue!="false"),t}return Ic}var $c={},Sb;function Ov(){if(Sb)return $c;Sb=1,Object.defineProperty($c,"__esModule",{value:!0});var n={width:2,height:100,format:"auto",displayValue:!0,fontOptions:"",font:"monospace",text:void 0,textAlign:"center",textPosition:"bottom",textMargin:2,fontSize:20,background:"#ffffff",lineColor:"#000000",margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}};return $c.default=n,$c}var Eb;function lN(){if(Eb)return zc;Eb=1,Object.defineProperty(zc,"__esModule",{value:!0});var n=Ev(),t=o(n),s=Ov(),i=o(s);function o(m){return m&&m.__esModule?m:{default:m}}function c(m){var y={};for(var g in i.default)i.default.hasOwnProperty(g)&&(m.hasAttribute("jsbarcode-"+g.toLowerCase())&&(y[g]=m.getAttribute("jsbarcode-"+g.toLowerCase())),m.hasAttribute("data-"+g.toLowerCase())&&(y[g]=m.getAttribute("data-"+g.toLowerCase())));return y.value=m.getAttribute("jsbarcode-value")||m.getAttribute("data-value"),y=(0,t.default)(y),y}return zc.default=c,zc}var Hc={},Fc={},xn={},Ob;function Av(){if(Ob)return xn;Ob=1,Object.defineProperty(xn,"__esModule",{value:!0}),xn.getTotalWidthOfEncodings=xn.calculateEncodingAttributes=xn.getBarcodePadding=xn.getEncodingHeight=xn.getMaximumHeightOfEncodings=void 0;var n=Mu(),t=s(n);function s(u){return u&&u.__esModule?u:{default:u}}function i(u,d){return d.height+(d.displayValue&&u.text.length>0?d.fontSize+d.textMargin:0)+d.marginTop+d.marginBottom}function o(u,d,b){if(b.displayValue&&d<u){if(b.textAlign=="center")return Math.floor((u-d)/2);if(b.textAlign=="left")return 0;if(b.textAlign=="right")return Math.floor(u-d)}return 0}function c(u,d,b){for(var x=0;x<u.length;x++){var v=u[x],w=(0,t.default)(d,v.options),S;w.displayValue?S=g(v.text,w,b):S=0;var C=v.data.length*w.width;v.width=Math.ceil(Math.max(S,C)),v.height=i(v,w),v.barcodePadding=o(S,C,w)}}function m(u){for(var d=0,b=0;b<u.length;b++)d+=u[b].width;return d}function y(u){for(var d=0,b=0;b<u.length;b++)u[b].height>d&&(d=u[b].height);return d}function g(u,d,b){var x;if(b)x=b;else if(typeof document<"u")x=document.createElement("canvas").getContext("2d");else return 0;x.font=d.fontOptions+" "+d.fontSize+"px "+d.font;var v=x.measureText(u);if(!v)return 0;var w=v.width;return w}return xn.getMaximumHeightOfEncodings=y,xn.getEncodingHeight=i,xn.getBarcodePadding=o,xn.calculateEncodingAttributes=c,xn.getTotalWidthOfEncodings=m,xn}var Ab;function cN(){if(Ab)return Fc;Ab=1,Object.defineProperty(Fc,"__esModule",{value:!0});var n=(function(){function y(g,u){for(var d=0;d<u.length;d++){var b=u[d];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}return function(g,u,d){return u&&y(g.prototype,u),d&&y(g,d),g}})(),t=Mu(),s=o(t),i=Av();function o(y){return y&&y.__esModule?y:{default:y}}function c(y,g){if(!(y instanceof g))throw new TypeError("Cannot call a class as a function")}var m=(function(){function y(g,u,d){c(this,y),this.canvas=g,this.encodings=u,this.options=d}return n(y,[{key:"render",value:function(){if(!this.canvas.getContext)throw new Error("The browser does not support canvas.");this.prepareCanvas();for(var u=0;u<this.encodings.length;u++){var d=(0,s.default)(this.options,this.encodings[u].options);this.drawCanvasBarcode(d,this.encodings[u]),this.drawCanvasText(d,this.encodings[u]),this.moveCanvasDrawing(this.encodings[u])}this.restoreCanvas()}},{key:"prepareCanvas",value:function(){var u=this.canvas.getContext("2d");u.save(),(0,i.calculateEncodingAttributes)(this.encodings,this.options,u);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=d+this.options.marginLeft+this.options.marginRight,this.canvas.height=b,u.clearRect(0,0,this.canvas.width,this.canvas.height),this.options.background&&(u.fillStyle=this.options.background,u.fillRect(0,0,this.canvas.width,this.canvas.height)),u.translate(this.options.marginLeft,0)}},{key:"drawCanvasBarcode",value:function(u,d){var b=this.canvas.getContext("2d"),x=d.data,v;u.textPosition=="top"?v=u.marginTop+u.fontSize+u.textMargin:v=u.marginTop,b.fillStyle=u.lineColor;for(var w=0;w<x.length;w++){var S=w*u.width+d.barcodePadding;x[w]==="1"?b.fillRect(S,v,u.width,u.height):x[w]&&b.fillRect(S,v,u.width,u.height*x[w])}}},{key:"drawCanvasText",value:function(u,d){var b=this.canvas.getContext("2d"),x=u.fontOptions+" "+u.fontSize+"px "+u.font;if(u.displayValue){var v,w;u.textPosition=="top"?w=u.marginTop+u.fontSize-u.textMargin:w=u.height+u.textMargin+u.marginTop+u.fontSize,b.font=x,u.textAlign=="left"||d.barcodePadding>0?(v=0,b.textAlign="left"):u.textAlign=="right"?(v=d.width-1,b.textAlign="right"):(v=d.width/2,b.textAlign="center"),b.fillText(d.text,v,w)}}},{key:"moveCanvasDrawing",value:function(u){var d=this.canvas.getContext("2d");d.translate(u.width,0)}},{key:"restoreCanvas",value:function(){var u=this.canvas.getContext("2d");u.restore()}}]),y})();return Fc.default=m,Fc}var Gc={},jb;function uN(){if(jb)return Gc;jb=1,Object.defineProperty(Gc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),t=Mu(),s=o(t),i=Av();function o(g){return g&&g.__esModule?g:{default:g}}function c(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}var m="http://www.w3.org/2000/svg",y=(function(){function g(u,d,b){c(this,g),this.svg=u,this.encodings=d,this.options=b,this.document=b.xmlDocument||document}return n(g,[{key:"render",value:function(){var d=this.options.marginLeft;this.prepareSVG();for(var b=0;b<this.encodings.length;b++){var x=this.encodings[b],v=(0,s.default)(this.options,x.options),w=this.createGroup(d,v.marginTop,this.svg);this.setGroupOptions(w,v),this.drawSvgBarcode(w,v,x),this.drawSVGText(w,v,x),d+=x.width}}},{key:"prepareSVG",value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,i.calculateEncodingAttributes)(this.encodings,this.options);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings),x=d+this.options.marginLeft+this.options.marginRight;this.setSvgAttributes(x,b),this.options.background&&this.drawRect(0,0,x,b,this.svg).setAttribute("fill",this.options.background)}},{key:"drawSvgBarcode",value:function(d,b,x){var v=x.data,w;b.textPosition=="top"?w=b.fontSize+b.textMargin:w=0;for(var S=0,C=0,q=0;q<v.length;q++)C=q*b.width+x.barcodePadding,v[q]==="1"?S++:S>0&&(this.drawRect(C-b.width*S,w,b.width*S,b.height,d),S=0);S>0&&this.drawRect(C-b.width*(S-1),w,b.width*S,b.height,d)}},{key:"drawSVGText",value:function(d,b,x){var v=this.document.createElementNS(m,"text");if(b.displayValue){var w,S;v.setAttribute("font-family",b.font),v.setAttribute("font-size",b.fontSize),b.fontOptions.includes("bold")&&v.setAttribute("font-weight","bold"),b.fontOptions.includes("italic")&&v.setAttribute("font-style","italic"),b.textPosition=="top"?S=b.fontSize-b.textMargin:S=b.height+b.textMargin+b.fontSize,b.textAlign=="left"||x.barcodePadding>0?(w=0,v.setAttribute("text-anchor","start")):b.textAlign=="right"?(w=x.width-1,v.setAttribute("text-anchor","end")):(w=x.width/2,v.setAttribute("text-anchor","middle")),v.setAttribute("x",w),v.setAttribute("y",S),v.appendChild(this.document.createTextNode(x.text)),d.appendChild(v)}}},{key:"setSvgAttributes",value:function(d,b){var x=this.svg;x.setAttribute("width",d+"px"),x.setAttribute("height",b+"px"),x.setAttribute("x","0px"),x.setAttribute("y","0px"),x.setAttribute("viewBox","0 0 "+d+" "+b),x.setAttribute("xmlns",m),x.setAttribute("version","1.1")}},{key:"createGroup",value:function(d,b,x){var v=this.document.createElementNS(m,"g");return v.setAttribute("transform","translate("+d+", "+b+")"),x.appendChild(v),v}},{key:"setGroupOptions",value:function(d,b){d.setAttribute("fill",b.lineColor)}},{key:"drawRect",value:function(d,b,x,v,w){var S=this.document.createElementNS(m,"rect");return S.setAttribute("x",d),S.setAttribute("y",b),S.setAttribute("width",x),S.setAttribute("height",v),w.appendChild(S),S}}]),g})();return Gc.default=y,Gc}var Vc={},kb;function fN(){if(kb)return Vc;kb=1,Object.defineProperty(Vc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var y=c[m];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(o,y.key,y)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function t(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o,c,m){t(this,i),this.object=o,this.encodings=c,this.options=m}return n(i,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),i})();return Vc.default=s,Vc}var Nb;function hN(){if(Nb)return Hc;Nb=1,Object.defineProperty(Hc,"__esModule",{value:!0});var n=cN(),t=m(n),s=uN(),i=m(s),o=fN(),c=m(o);function m(y){return y&&y.__esModule?y:{default:y}}return Hc.default={CanvasRenderer:t.default,SVGRenderer:i.default,ObjectRenderer:c.default},Hc}var Gi={},Tb;function jv(){if(Tb)return Gi;Tb=1,Object.defineProperty(Gi,"__esModule",{value:!0});function n(m,y){if(!(m instanceof y))throw new TypeError("Cannot call a class as a function")}function t(m,y){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y&&(typeof y=="object"||typeof y=="function")?y:m}function s(m,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);m.prototype=Object.create(y&&y.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(m,y):m.__proto__=y)}var i=(function(m){s(y,m);function y(g,u){n(this,y);var d=t(this,(y.__proto__||Object.getPrototypeOf(y)).call(this));return d.name="InvalidInputException",d.symbology=g,d.input=u,d.message='"'+d.input+'" is not a valid input for '+d.symbology,d}return y})(Error),o=(function(m){s(y,m);function y(){n(this,y);var g=t(this,(y.__proto__||Object.getPrototypeOf(y)).call(this));return g.name="InvalidElementException",g.message="Not supported type to render on",g}return y})(Error),c=(function(m){s(y,m);function y(){n(this,y);var g=t(this,(y.__proto__||Object.getPrototypeOf(y)).call(this));return g.name="NoElementException",g.message="No element to render on.",g}return y})(Error);return Gi.InvalidInputException=i,Gi.InvalidElementException=o,Gi.NoElementException=c,Gi}var Cb;function dN(){if(Cb)return Uc;Cb=1,Object.defineProperty(Uc,"__esModule",{value:!0});var n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},t=lN(),s=m(t),i=hN(),o=m(i),c=jv();function m(d){return d&&d.__esModule?d:{default:d}}function y(d){if(typeof d=="string")return g(d);if(Array.isArray(d)){for(var b=[],x=0;x<d.length;x++)b.push(y(d[x]));return b}else{if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLImageElement)return u(d);if(d&&d.nodeName&&d.nodeName.toLowerCase()==="svg"||typeof SVGElement<"u"&&d instanceof SVGElement)return{element:d,options:(0,s.default)(d),renderer:o.default.SVGRenderer};if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement)return{element:d,options:(0,s.default)(d),renderer:o.default.CanvasRenderer};if(d&&d.getContext)return{element:d,renderer:o.default.CanvasRenderer};if(d&&(typeof d>"u"?"undefined":n(d))==="object"&&!d.nodeName)return{element:d,renderer:o.default.ObjectRenderer};throw new c.InvalidElementException}}function g(d){var b=document.querySelectorAll(d);if(b.length!==0){for(var x=[],v=0;v<b.length;v++)x.push(y(b[v]));return x}}function u(d){var b=document.createElement("canvas");return{element:b,options:(0,s.default)(d),renderer:o.default.CanvasRenderer,afterRender:function(){d.setAttribute("src",b.toDataURL())}}}return Uc.default=y,Uc}var Yc={},Mb;function mN(){if(Mb)return Yc;Mb=1,Object.defineProperty(Yc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var y=c[m];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(o,y.key,y)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function t(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o){t(this,i),this.api=o}return n(i,[{key:"handleCatch",value:function(c){if(c.name==="InvalidInputException")if(this.api._options.valid!==this.api._defaults.valid)this.api._options.valid(!1);else throw c.message;else throw c;this.api.render=function(){}}},{key:"wrapBarcodeCall",value:function(c){try{var m=c.apply(void 0,arguments);return this.api._options.valid(!0),m}catch(y){return this.handleCatch(y),this.api}}}]),i})();return Yc.default=s,Yc}var ld,Rb;function pN(){if(Rb)return ld;Rb=1;var n=iN(),t=q(n),s=Mu(),i=q(s),o=aN(),c=q(o),m=oN(),y=q(m),g=dN(),u=q(g),d=Ev(),b=q(d),x=mN(),v=q(x),w=jv(),S=Ov(),C=q(S);function q(I){return I&&I.__esModule?I:{default:I}}var B=function(){},ie=function(D,Q,X){var he=new B;if(typeof D>"u")throw Error("No element to render on was provided.");return he._renderProperties=(0,u.default)(D),he._encodings=[],he._options=C.default,he._errorHandler=new v.default(he),typeof Q<"u"&&(X=X||{},X.format||(X.format=ne()),he.options(X)[X.format](Q,X).render()),he};ie.getModule=function(I){return t.default[I]};for(var le in t.default)t.default.hasOwnProperty(le)&&R(t.default,le);function R(I,D){B.prototype[D]=B.prototype[D.toUpperCase()]=B.prototype[D.toLowerCase()]=function(Q,X){var he=this;return he._errorHandler.wrapBarcodeCall(function(){X.text=typeof X.text>"u"?void 0:""+X.text;var Se=(0,i.default)(he._options,X);Se=(0,b.default)(Se);var ke=I[D],H=$(Q,ke,Se);return he._encodings.push(H),he})}}function $(I,D,Q){I=""+I;var X=new D(I,Q);if(!X.valid())throw new w.InvalidInputException(X.constructor.name,I);var he=X.encode();he=(0,c.default)(he);for(var Se=0;Se<he.length;Se++)he[Se].options=(0,i.default)(Q,he[Se].options);return he}function ne(){return t.default.CODE128?"CODE128":Object.keys(t.default)[0]}B.prototype.options=function(I){return this._options=(0,i.default)(this._options,I),this},B.prototype.blank=function(I){var D=new Array(I+1).join("0");return this._encodings.push({data:D}),this},B.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var I;for(var D in this._renderProperties){I=this._renderProperties[D];var Q=(0,i.default)(this._options,I.options);Q.format=="auto"&&(Q.format=ne()),this._errorHandler.wrapBarcodeCall(function(){var X=Q.value,he=t.default[Q.format.toUpperCase()],Se=$(X,he,Q);V(I,Se,Q)})}}},B.prototype.render=function(){if(!this._renderProperties)throw new w.NoElementException;if(Array.isArray(this._renderProperties))for(var I=0;I<this._renderProperties.length;I++)V(this._renderProperties[I],this._encodings,this._options);else V(this._renderProperties,this._encodings,this._options);return this},B.prototype._defaults=C.default;function V(I,D,Q){D=(0,c.default)(D);for(var X=0;X<D.length;X++)D[X].options=(0,i.default)(Q,D[X].options),(0,y.default)(D[X].options);(0,y.default)(Q);var he=I.renderer,Se=new he(I.element,D,Q);Se.render(),I.afterRender&&I.afterRender()}return typeof window<"u"&&(window.JsBarcode=ie),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(I,D){var Q=[];return jQuery(this).each(function(){Q.push(this)}),ie(Q,I,D)}),ld=ie,ld}var yN=pN();const gN=tS(yN),bN={[Ae.EXECUTED]:"Executed",[Ae.MATCHED_LIST]:"Matched list",[Ae.CONFIRM_REQUIRED]:"Awaiting confirmation",[Ae.NO_MATCH_FALLBACK]:"No match",[Ae.UNCONFIGURED]:"Not configured",[Ae.INVALID_CODE]:"Invalid code",[Ae.FORBIDDEN]:"Not permitted",[Ae.CONFLICT]:"Conflict",[Ae.IDENTITY_PRIMED]:"Identity primed",[Ae.IDENTITY_UNKNOWN]:"Badge not recognized",[Ae.NOT_PRIMED]:"Badge required",[Ae.CHOICES]:"Choices presented",[Ae.NO_OPEN_CONTAINER]:"Container closing, scan again",[Ae.HELD]:"Holding",[Ae.REFUSED]:"Not placed",[Ae.SUBJECT_STALE]:"Scan it again"},xN={[Ae.EXECUTED]:"text-status-success",[Ae.MATCHED_LIST]:"text-status-success",[Ae.CONFIRM_REQUIRED]:"text-status-warning",[Ae.NO_MATCH_FALLBACK]:"text-text-secondary",[Ae.UNCONFIGURED]:"text-status-warning",[Ae.INVALID_CODE]:"text-status-error",[Ae.FORBIDDEN]:"text-status-error",[Ae.CONFLICT]:"text-status-warning",[Ae.IDENTITY_PRIMED]:"text-status-success",[Ae.IDENTITY_UNKNOWN]:"text-status-warning",[Ae.NOT_PRIMED]:"text-status-warning",[Ae.CHOICES]:"text-status-success",[Ae.NO_OPEN_CONTAINER]:"text-status-warning",[Ae.HELD]:"text-status-success",[Ae.REFUSED]:"text-status-error",[Ae.SUBJECT_STALE]:"text-status-warning"};function vN(n){return n.outcome===Ae.IDENTITY_PRIMED&&n.actor?`Hi ${n.actor.displayName}`:`${bN[n.outcome]}${n.rule?` — ${n.rule.name}`:""}`}function _N(n){var t,s,i,o,c,m,y;return n.outcome===Ae.NO_MATCH_FALLBACK?((t=n.fallback)==null?void 0:t.markdown)??null:n.outcome===Ae.IDENTITY_UNKNOWN?((s=n.fallback)==null?void 0:s.markdown)??null:n.outcome===Ae.NOT_PRIMED?((i=n.notPrimed)==null?void 0:i.markdown)??null:n.outcome===Ae.NO_OPEN_CONTAINER?((o=n.fallback)==null?void 0:o.markdown)??null:n.outcome===Ae.REFUSED?((c=n.refusal)==null?void 0:c.markdown)??n.error??null:n.outcome===Ae.HELD?((y=(m=n.subject)==null?void 0:m.expect)==null?void 0:y.prompt)??null:n.outcome===Ae.SUBJECT_STALE?n.error??null:null}function ys(n){return n.replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 bg-surface-sunken rounded text-xs font-mono">$1</code>').replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent-primary hover:underline" target="_blank" rel="noopener noreferrer">$1</a>')}function wN({content:n,compact:t,inherit:s}){const i=[],o=/^```(\w*)\n([\s\S]*?)^```$/gm;let c=0,m;for(;(m=o.exec(n))!==null;)m.index>c&&i.push({type:"text",text:n.slice(c,m.index)}),i.push({type:"code",lang:m[1],code:m[2].replace(/\n$/,"")}),c=m.index+m[0].length;c<n.length&&i.push({type:"text",text:n.slice(c)});const y=s?{text:"",heading:"",list:"",code:"text-[0.85em]",tone:""}:t?{text:"text-xs",heading:"text-xs",list:"text-xs",code:"text-2xs",tone:"text-text-secondary"}:{text:"text-sm",heading:"text-sm",list:"text-sm",code:"text-xs",tone:"text-text-secondary"},g=[];for(const u of i){if(u.type==="code"){const d=u.code.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");g.push(`<pre class="my-2 p-2.5 bg-surface-sunken rounded-md overflow-x-auto"><code class="${y.code} font-mono text-text-secondary leading-relaxed">${d}</code></pre>`);continue}g.push(...SN(u.text,y))}return h.jsx("div",{className:s?void 0:"prose-sm",dangerouslySetInnerHTML:{__html:g.join(`
55
+ `)}})}function SN(n,t){const s=n.split(`
56
+ `),i=[];let o=!1,c=!1,m=[];for(const y of s){const g=y.trim();if(g.startsWith("|")&&g.endsWith("|")){const u=g.slice(1,-1).split("|").map(d=>d.trim());if(u.every(d=>/^[-:]+$/.test(d)))continue;c||(c=!0,m=[]),m.push(u);continue}if(c){c=!1;const[u,...d]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const b of u)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${ys(b)}</th>`);i.push("</tr></thead><tbody>");for(const b of d){i.push("<tr>");for(const x of b)i.push(`<td class="py-1 px-2 border-b border-border/50">${ys(x)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>"),m=[]}if(!g){o&&(i.push("</ul>"),o=!1);continue}if(g.startsWith("### ")){o&&(i.push("</ul>"),o=!1),i.push(`<h4 class="${t.heading} font-semibold text-text-primary mt-3 mb-1">${ys(g.slice(4))}</h4>`);continue}if(g.startsWith("## ")){o&&(i.push("</ul>"),o=!1),i.push(`<h3 class="${t.heading} font-semibold text-text-primary mt-3 mb-1">${ys(g.slice(3))}</h3>`);continue}if(/^[-*_]{3,}$/.test(g)){o&&(i.push("</ul>"),o=!1),i.push('<hr class="border-border my-3" />');continue}if(/^[-*] /.test(g)){o||(i.push('<ul class="space-y-1 my-1">'),o=!0),i.push(`<li class="${t.list} ${t.tone} flex gap-2"><span class="text-text-tertiary shrink-0">-</span><span>${ys(g.slice(2))}</span></li>`);continue}o&&(i.push("</ul>"),o=!1),i.push(`<p class="${t.text} ${t.tone} my-1">${ys(g)}</p>`)}if(c&&m.length){const[y,...g]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const u of y)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${ys(u)}</th>`);i.push("</tr></thead><tbody>");for(const u of g){i.push("<tr>");for(const d of u)i.push(`<td class="py-1 px-2 border-b border-border/50">${ys(d)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>")}return o&&i.push("</ul>"),i}function Bm({result:n,compact:t=!1}){const{response:s}=n,i=t?"text-xs":"text-sm",o=s?_N(s):null,c=s!=null&&s.error&&s.error!==o?s.error:null;return h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:`${i} font-mono text-text-secondary truncate`,children:n.code}),s?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:`${i} font-medium ${xN[s.outcome]}`,children:vN(s)}),c&&h.jsx("div",{className:"text-xs text-text-tertiary mt-0.5",children:c}),o&&h.jsx("div",{className:"text-xs text-text-secondary mt-1.5",children:h.jsx(wN,{content:o,compact:!0})})]}):h.jsx("div",{className:`${i} text-status-error`,children:n.error})]})}function kv(n){return n.replace(/[\u2010-\u2015\u2212]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u00A0/g," ").replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\x00-\x1F\x7F]/g,"").trim()}function EN(n){const t=new Set;for(const s of n){const i=s.codePointAt(0);(i>127||i<32)&&t.add(`"${i<32?"\\x"+i.toString(16).padStart(2,"0"):s}" U+${i.toString(16).toUpperCase().padStart(4,"0")}`)}return[...t]}function ON({value:n}){const t=E.useRef(null),[s,i]=E.useState(!1);return E.useEffect(()=>{if(!(!t.current||!n))try{gN(t.current,n,{format:"CODE128",width:2,height:88,margin:12,displayValue:!0,fontSize:13,background:"#ffffff",lineColor:"#000000"}),i(!1)}catch{i(!0)}},[n]),n?h.jsxs("div",{children:[h.jsx("span",{className:"block text-xs uppercase tracking-wide text-text-tertiary mb-1",children:"Barcode"}),s?h.jsxs("p",{className:"text-xs text-status-error",children:["This value has characters Code 128 cannot carry:"," ",h.jsx("span",{className:"font-mono",children:EN(n).join(", ")||"unknown"})]}):h.jsx("div",{className:"bg-white rounded p-1 inline-block max-w-full overflow-hidden",children:h.jsx("svg",{ref:t,className:"max-w-full"})})]}):null}function AN({onClose:n}){const{submitCode:t,lastResult:s,busy:i,wedgeConfig:o,updateWedgeConfig:c,diagnostics:m,diagnosticsOn:y,setDiagnosticsOn:g}=qm(),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=w=>{w.preventDefault();const S=u.trim();S&&(d(""),t(S))};return h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[h.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-text-primary",children:[h.jsx(No,{className:"w-4 h-4"}),"Scan"]}),h.jsx("button",{type:"button",onClick:n,className:"text-text-tertiary hover:text-text-primary",title:"Close",children:h.jsx(Wt,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-6",children:[h.jsxs("form",{onSubmit:v,className:"space-y-2",children:[h.jsx("label",{className:"block text-xs uppercase tracking-wide text-text-tertiary",children:"Enter a code"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{value:u,onChange:w=>d(kv(w.target.value)),placeholder:"10:1:SN-12345",className:"flex-1 px-2 py-1.5 text-sm bg-surface-raised border border-surface-border rounded text-text-primary","data-scan-manual-entry":!0}),h.jsx("button",{type:"submit",disabled:i||!u.trim(),className:"px-3 py-1.5 text-sm rounded bg-accent text-text-inverse disabled:opacity-50",children:"Go"})]}),h.jsx("p",{className:"text-xs text-text-tertiary",children:"Scanning with a connected scanner works from any page — this entry exists for testing and for codes you can read but not scan. Typing here also draws the code below; point the scanner at the screen to fire it for real."})]}),h.jsx(ON,{value:u.trim()}),s&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("div",{className:"text-xs uppercase tracking-wide text-text-tertiary",children:"Last scan"}),h.jsx(Bm,{result:s})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("button",{type:"button",onClick:()=>x(w=>!w),className:"text-xs uppercase tracking-wide text-text-tertiary hover:text-text-primary",children:["Capture settings ",b?"▾":"▸"]}),b&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block text-sm text-text-primary",children:[h.jsx("span",{className:"block text-xs text-text-tertiary mb-1",children:"Key gap limit (ms) — a longer pause between keys starts a new capture; raise it for scanners that pace slowly"}),h.jsx("input",{type:"number",min:100,max:2e3,step:50,value:o.maxKeyGapMs,onChange:w=>c({maxKeyGapMs:Number(w.target.value)}),className:"w-24 px-2 py-1 text-sm bg-surface-raised border border-surface-border rounded"})]}),h.jsxs("label",{className:"flex items-center gap-2 text-sm text-text-primary",children:[h.jsx("input",{type:"checkbox",checked:y,onChange:w=>g(w.target.checked)}),h.jsx("span",{children:"Diagnostics — trace every keydown the capture sees (also logged to the console)"})]}),y&&h.jsxs("div",{className:"border border-surface-border rounded",children:[h.jsx("div",{className:"px-2 py-1.5 text-2xs uppercase tracking-wide text-text-tertiary border-b border-surface-border",children:"Keydown trace — scan now, newest last"}),h.jsxs("div",{className:"max-h-64 overflow-y-auto font-mono text-2xs leading-5 px-2 py-1",children:[m.length===0&&h.jsx("div",{className:"text-text-tertiary",children:"Waiting for keys…"}),m.map(w=>h.jsxs("div",{className:"whitespace-nowrap overflow-hidden text-ellipsis",title:`buffer: ${w.buffer}`,children:[h.jsxs("span",{className:"text-text-tertiary",children:[String(w.deltaMs).padStart(4),"ms "]}),h.jsx("span",{className:"text",children:JSON.stringify(w.key)}),w.code&&h.jsxs("span",{className:"text-text-tertiary",children:[" (",w.code,")"]}),h.jsxs("span",{className:"text-text-tertiary",children:[" — ",w.note]})]},w.seq))]}),h.jsxs("div",{className:"px-2 py-1.5 text-2xs text-text-tertiary border-t border-surface-border",children:["Read it like this: a scan should end with an"," ",h.jsx("span",{className:"font-mono",children:'"Enter"'})," row saying"," ",h.jsx("span",{className:"font-mono",children:"capture → …"}),'. An Enter row saying "no code tail" means the buffer split (raise the gap limit, or a key arrived as something other than one character). No Enter row at all means the scanner sends no suffix — program its Enter/CR suffix. Keys named'," ",h.jsx("span",{className:"font-mono",children:'"Unidentified"'})," mean the decode arrives outside the keydown path."]})]})]})]})]})]})}const Nv=/^\{lt:([A-Za-z0-9_]+)\}$/;function X5(n){return`{lt:${n}}`}const Tv="lt:station:link-vars:";function Kd(n){return`${Tv}${n}`}const Jd=new Set;function jN(){for(const n of Jd)n()}let vu,Kc={};function Cv(n){let t=null;try{t=localStorage.getItem(Kd(n))}catch{t=null}if(t===vu)return Kc;vu=t;try{const s=t?JSON.parse(t):{};Kc=s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).filter(([,i])=>typeof i=="string")):{}}catch{Kc={}}return Kc}function kN(n,t,s){const i={...Cv(n)};s===null||s===""?delete i[t]:i[t]=s;try{Object.keys(i).length===0?localStorage.removeItem(Kd(n)):localStorage.setItem(Kd(n),JSON.stringify(i))}catch{}vu=void 0,jN()}function NN(n){Jd.add(n);const t=s=>{(s.key===null||s.key.startsWith(Tv))&&(vu=void 0,n())};try{window.addEventListener("storage",t)}catch{}return()=>{Jd.delete(n);try{window.removeEventListener("storage",t)}catch{}}}const TN={};function CN(n){return E.useSyncExternalStore(NN,()=>n?Cv(n):TN)}function MN(n,t,s){let i;try{i=new URL(n,"http://local")}catch{return n}const o=i.searchParams.get("facets");if(!o)return n;let c;try{const y=JSON.parse(o);if(!y||typeof y!="object"||Array.isArray(y))return n;c=y}catch{return n}let m=!1;for(const[y,g]of Object.entries(c)){if(typeof g!="string")continue;const u=Nv.exec(g);if(!u)continue;const d=t[u[1]]??s[u[1]];typeof d=="string"&&d!==""?c[y]=d:delete c[y],m=!0}return m?(Object.keys(c).length===0?i.searchParams.delete("facets"):i.searchParams.set("facets",JSON.stringify(c)),i.pathname+i.search):n}function Q5(n){let t;try{t=new URL(n,"http://local")}catch{return[]}const s=t.searchParams.get("facets");if(!s)return[];try{const i=JSON.parse(s);if(!i||typeof i!="object"||Array.isArray(i))return[];const o=[];for(const c of Object.values(i)){if(typeof c!="string")continue;const m=Nv.exec(c);m&&!o.includes(m[1])&&o.push(m[1])}return o}catch{return[]}}function Pm(){const{user:n,isSuperAdmin:t,hasRoleType:s}=Pt(),i=(n==null?void 0:n.userId)??null,o=t||s("admin"),c=E.useMemo(()=>new Set(((n==null?void 0:n.roles)??[]).map(x=>x.role)),[n]),{data:m}=Nu({enabled:o||c.size>0}),y=CN(i),g=E.useMemo(()=>{var w;const x=[],v=new Set;for(const S of(m==null?void 0:m.roles)??[]){if(!o&&!c.has(S.role))continue;const C=(w=S.properties)==null?void 0:w.link_variables;if(Array.isArray(C))for(const q of C){const B=q==null?void 0:q.name;if(typeof B!="string"||B===""||v.has(B))continue;v.add(B);const ie=q.label,le=q.default;x.push({name:B,...typeof ie=="string"&&ie!==""?{label:ie}:{},...typeof le=="string"&&le!==""?{default:le}:{},fromRole:S.role})}}return x},[m,c,o]),u=E.useMemo(()=>{const x={};for(const v of g)v.default!==void 0&&(x[v.name]=v.default);return x},[g]),d=E.useCallback(x=>MN(x,y,u),[y,u]),b=E.useCallback((x,v)=>{i&&kN(i,x,v)},[i]);return{declarations:g,values:y,defaults:u,resolveUrl:d,setValue:b}}function RN({open:n,onClose:t,title:s,children:i,maxWidth:o,closeOnBackdrop:c=!0}){return E.useEffect(()=>{if(!n)return;const m=y=>{y.key==="Escape"&&t()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n,t]),n?Wd.createPortal(h.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[h.jsx("div",{className:"absolute inset-0 bg-text-primary/30",onClick:c?t:void 0}),h.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"lt-modal-title",className:`relative bg-surface-raised border border-surface-border rounded-lg shadow-xl w-full ${o??"max-w-md"} mx-4 max-h-[85vh] flex flex-col`,children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b shrink-0",children:[h.jsx("h2",{id:"lt-modal-title",className:"text-sm font-medium text-text-primary",children:s}),h.jsx("button",{onClick:t,"aria-label":"Close dialog",className:"text-text-tertiary hover:text-text-primary text-lg leading-none",children:"×"})]}),h.jsx("div",{className:"px-6 py-5 overflow-y-auto",children:i})]})]}),document.body):null}function DN({open:n,onClose:t}){const{declarations:s,values:i,setValue:o}=Pm();return h.jsxs(RN,{open:n,onClose:t,title:"Link Variables",maxWidth:"max-w-lg",children:[h.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed mb-4",children:"Values bound on this device. Pinned links and the Pace Board open scoped to the value applied; an unbound variable falls back to the role's default, or applies no filter at all."}),h.jsx("div",{className:"divide-y divide-surface-border",children:s.map((c,m)=>h.jsx(LN,{declaration:c,value:i[c.name]??"",autoFocus:m===0,onChange:y=>o(c.name,y),onClear:()=>o(c.name,null),onEnter:t},c.name))}),s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary",children:"Your roles declare no link variables."}),s.length>0&&h.jsx("div",{className:"flex justify-end pt-4",children:h.jsx("button",{onClick:t,className:"px-3 py-1.5 text-xs rounded bg-accent text-text-inverse hover:bg-accent-hover transition-colors",children:"OK"})})]})}function LN({declaration:n,value:t,autoFocus:s,onChange:i,onClear:o,onEnter:c}){const m=E.useId(),{data:y}=TA(n.name),g=(y==null?void 0:y.values)??[];return h.jsxs("div",{className:"py-3 flex items-center gap-3","data-testid":"link-var-row",children:[h.jsxs("div",{className:"w-40 shrink-0 min-w-0",children:[h.jsx("p",{className:"text-xs font-mono text-text-primary truncate",title:n.name,children:n.name}),h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:`declared by ${n.fromRole}`,children:n.label??n.fromRole})]}),h.jsx("input",{type:"text",list:m,autoFocus:s,value:t,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&c()},placeholder:n.default?`${n.default} (default)`:"no filter","aria-label":`Value for ${n.name}`,className:"input text-xs font-mono flex-1 min-w-0"}),h.jsx("datalist",{id:m,children:g.map(u=>h.jsx("option",{value:u},u))}),h.jsx("button",{onClick:o,disabled:t==="",title:`Clear ${n.name}`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors disabled:opacity-30 disabled:cursor-not-allowed shrink-0",children:"×"})]})}const Db=["escalationId","workflowId"],qN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Mv="lt:search:mode",BN="lt:search:facet",Dt={FACET:"facet",COMMAND:"command"};function PN(n,t){return{version:n.version,category:t.category,name:t.name,schemeName:n.name,targetFacet:n.target_facet,encoding:n.encoding,delimiter:n.delimiter,targetLength:n.target_length}}function ko(n){return n.encoding==="delimited"?`${n.version}${n.delimiter}${n.category}${n.delimiter}`:`${n.version}${n.category}`}function UN(n,t){if(n.encoding==="delimited")return zN(n,t)?{code:t}:{code:`${ko(n)}${t}`};if(!/^[0-9]+$/.test(t))return{error:`${n.name} takes digits only`};const s=n.targetLength;return s&&t.length!==s&&t.length!==s+1?{error:`${n.name} takes ${s} digits`}:{code:`${ko(n)}${t}`}}function zN(n,t){const s=n.delimiter.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^[1-9][0-9]${s}[0-9]${s}.+$`).test(t)}function IN(n,t){return n==="escalationId"||n==="workflowId"?null:kk(n,t)}function $N(n){return n.kind===Dt.FACET?n.facet:n.command.name}function HN(n){return n.kind===Dt.COMMAND?n.command.targetFacet:n.facet==="escalationId"?"Escalation id":n.facet==="workflowId"?"Workflow id":n.facet}function FN(n){return n.kind===Dt.FACET?{kind:Dt.FACET,facet:n.facet}:{kind:Dt.COMMAND,version:n.command.version,category:n.command.category}}function GN(n,t,s){if((n==null?void 0:n.kind)===Dt.FACET&&t.includes(n.facet))return{kind:Dt.FACET,facet:n.facet};if((n==null?void 0:n.kind)===Dt.COMMAND){const i=s.find(o=>o.version===n.version&&o.category===n.category);if(i)return{kind:Dt.COMMAND,command:i}}return t.length>0?{kind:Dt.FACET,facet:t[0]}:s.length>0?{kind:Dt.COMMAND,command:s[0]}:null}function VN(){try{const n=localStorage.getItem(Mv);if(n){const s=JSON.parse(n);if(s.kind===Dt.FACET&&typeof s.facet=="string"||s.kind===Dt.COMMAND&&typeof s.version=="number"&&typeof s.category=="string")return s}const t=localStorage.getItem(BN);return t?{kind:Dt.FACET,facet:t}:null}catch{return null}}function YN(n){try{localStorage.setItem(Mv,JSON.stringify(n))}catch{}}const Lb=5*6e4,KN=n=>({rules:n.map(t=>{var s;return((s=t.data)==null?void 0:s.rules)??null}),loading:n.some(t=>t.isLoading)});function JN(n){const t=bv({enabled:n,staleTime:Lb}),s=E.useMemo(()=>{var m;return(((m=t.data)==null?void 0:m.schemes)??[]).filter(y=>y.enabled&&y.kind===_k.ACTION).sort((y,g)=>y.version-g.version)},[t.data]),{rules:i,loading:o}=nS({queries:s.map(m=>({queryKey:["scan-schemes",m.version,"actions"],queryFn:()=>fe(`/scan-codes/schemes/${m.version}/actions`),enabled:n,staleTime:Lb})),combine:KN});return{commands:E.useMemo(()=>s.flatMap((m,y)=>(i[y]??[]).filter(g=>g.enabled).sort((g,u)=>g.category.localeCompare(u.category)).map(g=>PN(m,g))),[s,i]),loading:t.isLoading||o}}const XN={escalationId:"opens the item",workflowId:"opens the run"};function QN({mode:n,facets:t,commands:s,onSelect:i,onOpenScanPanel:o}){const[c,m]=E.useState(!1),y=E.useRef(null);E.useEffect(()=>{if(!c)return;const x=w=>{y.current&&!y.current.contains(w.target)&&m(!1)},v=w=>{w.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v)}},[c]);const g=n.kind===Dt.COMMAND,u=g?`${n.command.schemeName} · ${n.command.name} — ${ko(n.command)}<${n.command.targetFacet}>`:`Search by ${n.facet}`,d=WN(s),b=x=>{i(x),m(!1)};return h.jsxs("div",{ref:y,className:"relative h-full shrink-0",children:[h.jsxs("button",{type:"button",onClick:()=>m(x=>!x),"aria-expanded":c,"aria-haspopup":"listbox","aria-label":"Search or run as",title:u,className:"group flex items-center gap-1 h-full pl-2.5 pr-2 border-l border-surface-field-border hover:bg-surface-hover transition-colors rounded-r-[var(--lt-radius-field)]","data-testid":"search-mode",children:[h.jsx("span",{className:`text-2xs whitespace-nowrap truncate max-w-[9rem] ${g?"font-medium text-accent":"font-mono text-text-tertiary"}`,children:$N(n)}),h.jsx(Zd,{className:`w-3 h-3 shrink-0 text-text-quaternary group-hover:text-accent transition-transform ${c?"rotate-180":""}`,strokeWidth:1.5})]}),c&&h.jsxs("div",{role:"listbox","aria-label":"Search or run as",className:"absolute z-50 top-full right-0 mt-1.5 min-w-[17rem] max-w-[24rem] max-h-[70vh] overflow-y-auto bg-surface-raised border border-surface-border rounded-md shadow-lg py-1",children:[t.length>0&&h.jsxs(h.Fragment,{children:[h.jsx(qb,{children:"Find"}),t.map(x=>h.jsx(Bb,{label:x,mono:!0,note:XN[x]??"filters the list",active:!g&&n.facet===x,onClick:()=>b({kind:Dt.FACET,facet:x})},x))]}),d.map(({schemeName:x,targetFacet:v,items:w})=>h.jsxs("div",{children:[h.jsxs(qb,{note:v,children:["Run · ",x]}),w.map(S=>h.jsx(Bb,{label:S.name,note:ko(S),noteMono:!0,active:g&&n.command.version===S.version&&n.command.category===S.category,onClick:()=>b({kind:Dt.COMMAND,command:S})},`${S.version}:${S.category}`))]},x)),o&&h.jsxs(h.Fragment,{children:[h.jsx("hr",{className:"border-surface-border/60 my-1"}),h.jsxs("button",{type:"button",onClick:()=>{m(!1),o()},className:"w-full text-left px-3 py-1.5 flex items-center gap-2 text-xs text-accent hover:bg-surface-hover","data-testid":"search-mode-scan-panel",children:[h.jsx(No,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Scanner settings and barcode preview"]})]})]})]})}function WN(n){const t=[];for(const s of n){const i=t.find(o=>o.schemeName===s.schemeName);i?i.items.push(s):t.push({schemeName:s.schemeName,targetFacet:s.targetFacet,items:[s]})}return t}function qb({children:n,note:t}){return h.jsxs("p",{className:"px-3 pt-2 pb-1 flex items-baseline gap-2 text-2xs font-semibold uppercase tracking-widest text-text-quaternary first:pt-1",children:[h.jsx("span",{className:"truncate",children:n}),t&&h.jsx("span",{className:"ml-auto font-mono font-normal normal-case tracking-normal shrink-0",children:t})]})}function Bb({label:n,note:t,active:s,mono:i,noteMono:o,onClick:c}){return h.jsxs("button",{type:"button",role:"option","aria-selected":s,onClick:c,className:`w-full text-left pl-3 pr-3 py-1.5 flex items-baseline gap-3 border-l-2 transition-colors ${s?"border-accent bg-accent/10 text-accent":"border-transparent text-text-primary hover:bg-surface-hover"}`,children:[h.jsx("span",{className:`text-xs font-medium truncate ${i?"font-mono":""}`,children:n}),h.jsx("span",{className:`ml-auto text-2xs shrink-0 ${o?"font-mono tabular-nums":""} ${s?"text-accent/70":"text-text-quaternary"}`,children:t})]})}const ZN=6e3;function eT({onOpenScanPanel:n}){const t=ra(),{data:s}=Zn(),i=Dm(),{submitCode:o,busy:c,lastResult:m}=qm(),{commands:y}=JN(i),[g,u]=E.useState(""),[d,b]=E.useState(!1),[x,v]=E.useState(null),[w,S]=E.useState(null),[C,q]=E.useState(""),[B,ie]=E.useState(null),[le,R]=E.useState(VN),$=E.useRef(null),ne=E.useMemo(()=>{var ce;if(!((ce=s==null?void 0:s.search)!=null&&ce.enabled))return[];const W=(s.search.facets??[]).filter(xe=>!Db.includes(xe));return[...Db,...W]},[s]),V=E.useMemo(()=>GN(le,ne,y),[le,ne,y]),I=(m==null?void 0:m.source)===jo.TOOLBAR&&!m.navigated&&B!==m.at?m:null;E.useEffect(()=>{if(!I)return;const W=setTimeout(()=>ie(I.at),ZN);return()=>clearTimeout(W)},[I]);const D=()=>{v(null),S(null),m&&ie(m.at)},Q=W=>{var xe;const ce=FN(W);R(ce),YN(ce),D(),(xe=$.current)==null||xe.focus()},X=(W,ce)=>{const xe=UN(W.command,kv(ce));if("error"in xe){v(xe.error);return}u(""),o(xe.code,jo.TOOLBAR)},he=async(W,ce)=>{const xe=IN(W,ce);if(xe){u(""),t(xe);return}if(W==="escalationId"&&!qN.test(ce)){v("That is not a valid escalation id");return}b(!0);try{if(W==="escalationId")await fe(`/escalations/${encodeURIComponent(ce)}`),u(""),t(`/escalations/detail/${encodeURIComponent(ce)}`);else{const ve=await fe(`/escalations/by-workflow/${encodeURIComponent(ce)}`),Ce=(ve==null?void 0:ve.escalations)??[];Ce.length===1?(u(""),t(`/escalations/detail/${Ce[0].id}`)):(q(ce),S(Ce))}}catch{v(`No ${W==="escalationId"?"escalation":"workflow"} found for "${ce}"`)}finally{b(!1)}},Se=()=>{const W=g.trim();!W||d||c||!V||(D(),V.kind===Dt.COMMAND?X(V,W):he(V.facet,W))};if(!V)return null;const ke=V.kind===Dt.COMMAND,H=d||c;return h.jsxs("div",{className:"relative w-full max-w-[28rem]","data-testid":"global-search",children:[h.jsxs("div",{className:"flex items-center h-8 bg-surface-field border border-surface-field-border rounded-[var(--lt-radius-field)] focus-within:border-accent focus-within:bg-surface-field-focus transition-colors",children:[h.jsxs("label",{htmlFor:"global-search-input",className:"flex items-center gap-1.5 pl-2.5 shrink-0 cursor-text",children:[ke?h.jsx(No,{className:"w-3.5 h-3.5 text-accent/65",strokeWidth:1.5}):h.jsx(fS,{className:"w-3.5 h-3.5 text-text-quaternary",strokeWidth:1.5}),ke&&h.jsx("span",{className:"font-mono text-xs tabular-nums text-text-tertiary select-none","data-testid":"search-command-prefix",children:ko(V.command)})]}),h.jsx("input",{ref:$,id:"global-search-input",type:"text",value:g,onChange:W=>{u(W.target.value),D()},onKeyDown:W=>{W.key==="Enter"&&Se(),W.key==="Escape"&&(u(""),D())},placeholder:HN(V),"aria-label":ke?"Run target":"Global search",autoComplete:"off",spellCheck:!1,className:`flex-1 min-w-0 h-full bg-transparent text-xs text-text-primary placeholder:text-text-quaternary focus:outline-none ${ke?"pl-0.5 pr-2 font-mono":"px-2"}`}),H&&h.jsx("span",{className:"w-1.5 h-1.5 mr-2 rounded-full bg-accent animate-pulse shrink-0","aria-label":"Working"}),h.jsx(QN,{mode:V,facets:ne,commands:y,onSelect:Q,onOpenScanPanel:n})]}),x&&h.jsx("p",{className:"absolute top-full left-0 mt-1 text-2xs text-status-error whitespace-nowrap",role:"alert",children:x}),I&&h.jsx("div",{role:"status",className:"absolute top-full left-0 mt-1.5 z-50 w-full max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg px-3 py-2 animate-fade-in","data-testid":"search-run-outcome",children:h.jsx(Bm,{result:I,compact:!0})}),w!==null&&h.jsxs("div",{className:"absolute top-full left-0 mt-1.5 z-50 min-w-72 max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1","data-testid":"search-workflow-results",children:[w.map(W=>h.jsxs(Cr,{to:`/escalations/detail/${W.id}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover truncate",children:[h.jsx("span",{className:"font-medium text-text-primary",children:W.role}),h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),W.status,h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),h.jsx("span",{className:"text-text-tertiary",children:W.type})]},W.id)),w.length===0&&h.jsx("p",{className:"px-3 py-1.5 text-2xs text-text-tertiary",children:"No escalations for this workflow."}),h.jsx("hr",{className:"border-surface-border/60 my-0.5"}),h.jsx(Cr,{to:`/workflows/executions/${encodeURIComponent(C)}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-accent hover:bg-surface-hover",children:"Workflow execution →"})]})]})}function tT(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[-_\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Xd(n){var t;return((t=n.title)==null?void 0:t.trim())||tT(n.role)}const Rv="lt:bookmarks",Jc="scan";function nT(){try{const n=localStorage.getItem(Rv);if(!n)return[];const t=JSON.parse(n);return Array.isArray(t)?t:[]}catch{return[]}}function Pb(n){try{localStorage.setItem(Rv,JSON.stringify(n))}catch{}}function rT({onToggleEventFeed:n,onToggleDocs:t,onToggleNav:s}){var Be,We,ln;const i=ra(),{user:o,logout:c,isSuperAdmin:m,hasRoleType:y}=Pt(),{viewAs:g,realIsBuilder:u}=Vx(),{available:d,mine:b}=DA();Yx();const{connected:x}=kx(),{data:v}=Zn(),{role:w,targets:S,selectable:C,selectRole:q}=Sm(),{declarations:B,values:ie}=Pm(),[le,R]=E.useState(!1),{data:$}=Nu(),ne=E.useMemo(()=>{const pe=($==null?void 0:$.roles)??[],Ye=new Set(((o==null?void 0:o.roles)??[]).map(ft=>ft.role)),Ot=m||y("admin");return pe.filter(ft=>Wi(ft).length>0&&(Ot||Ye.has(ft.role))).map(ft=>({role:ft.role,title:Xd(ft),portals:Wi(ft)}))},[$,o,m,y]),{setPanel:V,closePanel:I,open:D,ownerKey:Q}=jm(),X=Dm(),he=an(),Se=()=>{D&&Q===Jc?I(Jc):V(h.jsx(AN,{onClose:()=>I(Jc)}),{width:360,key:Jc})},[ke,H]=E.useState(!1),[W,ce]=E.useState(!1),[xe,ve]=E.useState(dv),[Ce,Ne]=E.useState(nT),Me=E.useRef(null),Ze=(Be=v==null?void 0:v.branding)==null?void 0:Be.appName,yt=(We=v==null?void 0:v.branding)==null?void 0:We.themes,Ct=E.useMemo(()=>(ik(yt??[]),ak()),[yt]),we=pe=>{ok(pe),ve(pe)},Re=()=>{const pe=window.prompt("Bookmark label:");if(!(pe!=null&&pe.trim()))return;const Ye=he.pathname+he.search,Ot=[...Ce,{label:pe.trim(),url:Ye}].sort((ft,Pr)=>ft.label.localeCompare(Pr.label));Ne(Ot),Pb(Ot),H(!1)},oe=pe=>{const Ye=Ce.filter(Ot=>!(Ot.label===pe.label&&Ot.url===pe.url));Ne(Ye),Pb(Ye)};return E.useEffect(()=>{if(!ke)return;const pe=Ye=>{Me.current&&!Me.current.contains(Ye.target)&&H(!1)};return document.addEventListener("mousedown",pe),()=>document.removeEventListener("mousedown",pe)},[ke]),h.jsxs(h.Fragment,{children:[h.jsxs("header",{className:`h-14 shrink-0 border-b border-surface-border bg-surface-raised flex items-center justify-between pl-2 pr-5 relative ${ke?"z-[100]":"z-30"}`,children:[h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s&&h.jsx("button",{onClick:s,className:"lg:hidden p-2 text-text-secondary hover:text-text-primary transition-colors","aria-label":"Open navigation",children:h.jsx(hS,{className:"w-5 h-5",strokeWidth:1.5})}),h.jsx(Cr,{to:"/","aria-label":"Home",className:"shrink-0 hidden lg:block",onClick:pe=>{(pe.ctrlKey||pe.metaKey)&&(pe.preventDefault(),ce(!0))},children:h.jsx(Tm,{appName:Ze,className:"flex"})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border mx-1"}),h.jsx("button",{onClick:()=>i(-1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go back",children:h.jsx(ex,{className:"w-5 h-5",strokeWidth:2})}),h.jsx("button",{onClick:()=>i(1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go forward",children:h.jsx(hd,{className:"w-5 h-5",strokeWidth:2})})]}),(((ln=v==null?void 0:v.search)==null?void 0:ln.enabled)||X)&&h.jsx("div",{className:"hidden md:flex flex-1 min-w-0 justify-center px-4 lg:px-8",children:h.jsx(eT,{onOpenScanPanel:X?Se:void 0})}),h.jsxs("div",{className:"flex items-center gap-5 shrink-0",children:[h.jsxs(Cr,{to:"/escalations/available",className:`flex items-center gap-1.5 text-xs transition-colors ${d>0?"text-status-queued":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[h.jsx(dd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"all"}),d>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:d})]}),h.jsxs(Cr,{to:"/escalations/queue",className:`flex items-center gap-1.5 text-xs transition-colors ${b>0?"text-status-claimed":"text-text-quaternary hover:text-text-secondary"}`,title:"My escalation queue",children:[h.jsx(dd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"mine"}),b>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:b})]}),g&&h.jsx(h.Fragment,{children:h.jsxs("span",{className:"hidden lg:flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-full bg-accent/10 border border-accent/25 text-2xs text-accent select-none",children:[h.jsxs("span",{className:"capitalize font-medium tracking-wide",children:[g," View"]}),h.jsx("button",{onClick:zd,title:"Restore your real view",className:"ml-0.5 rounded-full p-0.5 hover:bg-accent/20 transition-colors",children:h.jsx(Wt,{className:"w-2.5 h-2.5"})})]})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border"}),o&&h.jsxs("div",{className:"relative",ref:Me,children:[h.jsxs("button",{onClick:()=>H(pe=>!pe),className:"btn-ghost flex items-center gap-1",children:[h.jsxs("span",{className:"relative",children:[h.jsx(dS,{className:"w-4 h-4 text-accent/75",strokeWidth:1.5}),g&&h.jsx("span",{className:"lg:hidden absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-accent"})]}),h.jsx("span",{className:"hidden lg:inline whitespace-nowrap",children:o.displayName||o.username||o.userId}),h.jsx("svg",{className:"hidden lg:block w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),ke&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 w-52 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100]",children:[h.jsx(Cr,{to:"/credentials",onClick:()=>H(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),X&&h.jsx("button",{onClick:()=>{H(!1),Se()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-scan",children:"Scan a code"}),h.jsx("button",{onClick:()=>{H(!1),x?n==null||n():window.location.reload()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:x?"Events":"Reconnect events"}),u&&h.jsx("button",{onClick:()=>{H(!1),t==null||t()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-docs",children:"Docs"}),g&&h.jsxs("button",{onClick:()=>{H(!1),zd()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-accent hover:bg-surface-hover capitalize",children:["Exit ",g," view"]}),h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Theme"}),h.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:Ct.map(pe=>h.jsx("button",{type:"button",onClick:()=>we(pe.id),title:pe.label,"aria-label":`${pe.label} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${xe===pe.id?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:pe.swatch}},pe.id))})]}),C&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Station queue"}),h.jsxs("div",{className:"flex flex-col",children:[h.jsxs("button",{type:"button",onClick:()=>{H(!1),q(null),i("/")},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${w?"text-text-secondary":"text-accent"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${w?"bg-surface-border":"bg-accent"}`}),h.jsx("span",{className:"truncate",children:"Full dashboard"})]}),S.map(pe=>{var ft;const Ye=(ft=$==null?void 0:$.roles)==null?void 0:ft.find(Pr=>Pr.role===pe),Ot=pe===w;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),q(pe),i(Xx(pe,Wi(Ye)))},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${Ot?"text-accent":"text-text-secondary"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ot?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Xd({role:pe,title:Ye==null?void 0:Ye.title})})]},pe)})]})]}),ne.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60","data-testid":"menu-portals",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Portals"}),h.jsx("div",{className:"flex flex-col gap-1.5",children:ne.map(pe=>h.jsxs("div",{children:[ne.length>1&&h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:pe.role,children:pe.title}),pe.portals.map(Ye=>{const Ot=wm(pe.role,Ye.key),ft=he.pathname===Ot;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),i(Ot)},className:`flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded hover:bg-surface-hover ${ft?"text-accent":"text-text-secondary"}`,"data-testid":`menu-portal-${pe.role}-${Ye.key}`,children:[h.jsx(md,{className:"w-3.5 h-3.5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate",children:Ye.label})]},Ye.key)})]},pe.role))})]}),B.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Link variables"}),h.jsxs("button",{type:"button",onClick:()=>{H(!1),R(!0)},className:"flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded text-text-secondary hover:bg-surface-hover","data-testid":"link-vars-menu-entry",children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Object.keys(ie).length>0?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Object.keys(ie).length>0?Object.entries(ie).map(([pe,Ye])=>`${pe} = ${Ye}`).join(", "):"Set values for this device"})]})]}),h.jsx("button",{onClick:()=>{H(!1),c()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Sign Out"}),h.jsxs("div",{className:"border-t border-surface-border/60 pt-1",children:[Ce.map(pe=>h.jsxs("div",{className:"flex items-center group px-3 py-1.5 hover:bg-surface-hover",children:[h.jsx(Cr,{to:pe.url,onClick:()=>H(!1),title:pe.url,className:"flex-1 min-w-0 text-xs text-text-secondary hover:text-text-primary truncate",children:pe.label}),h.jsx("button",{type:"button",onClick:()=>oe(pe),title:`Remove "${pe.label}"`,className:"opacity-0 group-hover:opacity-100 transition-opacity ml-1 p-0.5 shrink-0 text-text-quaternary hover:text-status-error",children:h.jsx(Wt,{className:"w-3 h-3"})})]},`${pe.label}::${pe.url}`)),h.jsx("hr",{className:"border-surface-border/60 mx-3 my-0.5"}),h.jsxs("button",{type:"button",onClick:Re,className:"flex items-center gap-1.5 w-full px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:[h.jsx(mS,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Add Bookmark"]})]})]})]})]})]}),W&&h.jsx(sk,{onClose:()=>ce(!1)}),h.jsx(DN,{open:le,onClose:()=>R(!1)})]})}function Um({open:n,children:t}){const[s,i]=E.useState(n);return E.useEffect(()=>{n&&i(!0)},[n]),h.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-out ${n?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,onTransitionEnd:()=>{n||i(!1)},children:h.jsx("div",{className:"overflow-hidden",children:s?t:null})})}function Qd(n){return({isActive:t})=>{const s="flex items-center rounded-md transition-colors duration-150",i="bg-surface-hover text-text-primary font-medium",o="text-text-secondary hover:text-text-primary hover:bg-surface-hover";return n?`${s} justify-center w-10 h-10 mx-auto ${t?i:o}`:`${s} gap-3 px-4 py-2 text-sm ${t?i:o}`}}function sT(){return({isActive:n})=>`flex items-center gap-3 pl-11 pr-4 py-1.5 text-xs rounded-md transition-colors duration-150 ${n?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary"}`}function iT({group:n,collapsed:t}){const{pathname:s}=an(),i=n.matchPaths.some(y=>s.startsWith(y)),[o,c]=E.useState(i),m=o||i;return t?h.jsx(h.Fragment,{children:n.items.map(y=>h.jsx(Ss,{to:y.to,className:Qd(!0),title:y.label,children:y.icon&&h.jsx(y.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},y.to))}):h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>c(y=>!y),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:[h.jsxs("span",{className:"flex items-center gap-3",children:[n.icon&&h.jsx(n.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:n.label})]}),h.jsx("svg",{className:`w-3.5 h-3.5 text-text-tertiary transition-transform duration-150 ${m?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),h.jsx(Um,{open:m,children:n.items.map(y=>h.jsxs(Ss,{to:y.to,end:y.end,className:sT(),children:[y.icon&&h.jsx(y.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:y.label})]},y.to))})]})}function aT(n){return n.kind==="group"}function oT({entry:n,collapsed:t}){const{pathname:s,search:i}=an(),o=n.to.includes("?"),c=n.icon&&h.jsx(n.icon,{className:`w-5 h-5 shrink-0 text-accent/75 ${n.iconClassName??""}`,strokeWidth:1.5,...n.solid?{fill:"currentColor"}:{}});if(o){const[m,y]=n.to.split("?"),g=s===m&&i===`?${y}`,u=Qd(t)({isActive:g});return h.jsxs(Ss,{to:n.to,className:u,title:t?n.label:void 0,children:[c,!t&&h.jsx("span",{children:n.label})]})}return h.jsxs(Ss,{to:n.to,end:n.end,className:Qd(t),title:t?n.label:void 0,children:[c,!t&&h.jsx("span",{children:n.label})]})}function Dr({heading:n,entries:t}){const{collapsed:s}=Om();return h.jsxs("div",{className:"space-y-1",children:[s?h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:n}):h.jsx("p",{className:"px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary",children:n}),t.map(i=>aT(i)?h.jsx(iT,{group:i,collapsed:s},i.label):h.jsx(oT,{entry:i,collapsed:s},i.to))]})}function lT({aiEnabled:n=!1,isBuilder:t=!1,isOps:s=!1,viewAs:i=null,canSeePaceBoard:o=!1}){const c=[{to:"/pace",label:"Pace Board",icon:pS},{to:"/trends",label:"Trend Board",icon:yS}];if(!t&&(!s||i==="engineer"||i==="operator"))return o?h.jsx(Dr,{heading:"Monitor",entries:c}):null;if(!t)return h.jsx(Dr,{heading:"Monitor",entries:o?c:[]});const m=[...o?c:[],{to:"/topics",label:"Event Topics",icon:tx},{to:"/agents",label:n?"Agents":"Automations",icon:gS},{to:"/capabilities",label:"Capabilities",icon:bS}];return h.jsx(Dr,{heading:"Monitor",entries:m})}function cT(){return $e({queryKey:["me","preferences"],queryFn:()=>fe("/me/preferences"),staleTime:6e4})}function uT(){const n=He();return Ve({mutationFn:t=>fe("/me/preferences",{method:"PATCH",body:JSON.stringify(t)}),onSuccess:t=>{n.setQueryData(["me","preferences"],t)}})}const bs={TABLE:"table",RICH:"rich",TIMELINE:"timeline"},Ub={COMPACT:"compact",CARDS:"cards"},cd={AVAILABLE:"/escalations/available",ALL:"/escalations"},Zi={AVAILABLE:"available",CLAIMED:"claimed",RESOLVED:"resolved",CANCELLED:"cancelled",EXPIRED:"expired"},fT={[Zi.RESOLVED]:"resolved",[Zi.CANCELLED]:"cancelled",[Zi.EXPIRED]:"expired"};function hT(n){const t=n===Zi.CLAIMED;return{available:n===Zi.AVAILABLE,claimed:t,apiStatus:t?"pending":fT[n]}}function dT(n){return n===bs.TABLE||n===bs.RICH||n===bs.TIMELINE}function mT(n){return n===Ub.COMPACT||n===Ub.CARDS}function pT(n,t=""){const s=n.get("priority"),i=n.get("view"),o=n.get("layout");return{statusFilter:n.get("status")||t,role:n.get("role")||void 0,type:n.get("type")||void 0,subtype:n.get("subtype")||void 0,priority:s?parseInt(s,10):void 0,search:n.get("search")||void 0,facets:jk(n),view:dT(i)?i:null,layout:mT(o)?o:null}}function yT(n){let t;try{t=new URL(n,"http://local")}catch{return null}if(t.pathname!==cd.AVAILABLE&&t.pathname!==cd.ALL)return null;const s=t.pathname===cd.AVAILABLE?Zi.AVAILABLE:"";return pT(t.searchParams,s)}function W5(n){var t;return n.role||(((t=n.facets.roles)==null?void 0:t.length)===1?n.facets.roles[0]:null)}function Z5(n,t){return n===bs.TIMELINE?bs.TIMELINE:t&&(!n||n===bs.RICH)?bs.RICH:bs.TABLE}function gT(n,t){const s=(n==null?void 0:n.pinnedViews)??[],i=new Set((n==null?void 0:n.hiddenRolePins)??[]),o=new Set(s.map(y=>y.label)),c=[...s],m=new Set;for(const{role:y,pins:g}of t)for(const u of g)o.has(u.label)||i.has(u.label)||m.has(u.label)||(m.add(u.label),c.push({...u,id:`role:${y}:${u.label}`,fromRole:y}));return c}function bT(n){const t=yT(n);if(!t)return null;const{available:s,claimed:i,apiStatus:o}=hT(t.statusFilter);return{available:s,params:{...t.facets,role:t.role,type:t.type,subtype:t.subtype,priority:t.priority,status:o,...i?{claimed:!0}:{},search:t.search}}}function xT(){return`pin-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function vT(){var I;const{collapsed:n}=Om(),{user:t}=Pt(),s=cT(),i=uT(),o=E.useMemo(()=>new Set(((t==null?void 0:t.roles)??[]).map(D=>D.role)),[t]),{data:c}=Nu({enabled:o.size>0}),m=on("SUMMARY");ti(vm(),()=>{m([["escalations"]])});const y=(I=s.data)==null?void 0:I.preferences,g=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&Array.isArray(D.default_pins)&&D.default_pins.length>0).map(D=>({role:D.role,pins:D.default_pins})),[c,o]),{resolveUrl:u}=Pm(),d=E.useMemo(()=>gT(y,g),[y,g]),b=E.useMemo(()=>new Map(d.map(D=>[D.id,D.url])),[d]),x=E.useMemo(()=>d.map(D=>({...D,url:u(D.url)})),[d,u]),v=E.useMemo(()=>new Map(((c==null?void 0:c.roles)??[]).map(D=>[D.role,Xd(D)])),[c]),w=E.useMemo(()=>x.filter(D=>!D.fromRole),[x]),S=E.useMemo(()=>new Set(((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&_A(D)).map(D=>D.role)),[c,o]),C=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>S.has(D.role)||g.some(Q=>Q.role===D.role)).map(D=>({role:D.role,title:v.get(D.role)??D.role,portals:S.has(D.role)?Wi(D):[],pins:x.filter(Q=>Q.fromRole===D.role)})).filter(D=>D.portals.length>0||D.pins.length>0),[c,g,S,v,x]),q=(y==null?void 0:y.pinnedViews)??[],B=E.useRef(null),ie=D=>i.mutate({pinnedViews:D}),le=D=>ie(q.filter(Q=>Q.id!==D)),R=D=>ie([...q,{id:xT(),label:D.label,url:b.get(D.id)??D.url,badge:D.badge}]),$=D=>i.mutate({hiddenRolePins:[...(y==null?void 0:y.hiddenRolePins)??[],D]}),ne=(D,Q)=>{if(D===Q)return;const X=[...q],[he]=X.splice(D,1);X.splice(Q,0,he),ie(X)};if(x.length===0&&S.size===0)return null;const V="px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary truncate";return h.jsxs("div",{className:"space-y-1",children:[n&&h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:"Pinned"}),!n&&w.length>0&&h.jsx("p",{className:V,children:"Pinned"}),w.map(D=>{const Q=q.findIndex(X=>X.id===D.id);return h.jsx(zb,{pin:D,collapsed:n,draggable:Q!==-1,onDragStart:()=>{B.current=Q},onDropOn:()=>{B.current!==null&&Q!==-1&&ne(B.current,Q),B.current=null},onRemove:()=>le(D.id)},D.id)}),C.map(D=>h.jsxs("div",{children:[!n&&h.jsx("p",{className:V,title:`${D.title} — pins from the ${D.role} role`,"data-testid":"pin-group-label",children:D.title}),D.portals.map(Q=>h.jsx(_T,{role:D.role,portal:Q,collapsed:n},Q.key)),D.pins.map(Q=>h.jsx(zb,{pin:Q,collapsed:n,draggable:!1,onDragStart:()=>{},onDropOn:()=>{},onPromote:()=>R(Q),onHide:()=>$(Q.label)},Q.id))]},D.role))]})}function _T({role:n,portal:t,collapsed:s}){const i=wm(n,t.key),o="flex items-center rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",c=`portal-link-${n}-${t.key}`;return s?h.jsx(Ss,{to:i,className:`${o} justify-center w-10 h-10 mx-auto`,title:t.label,"data-testid":c,children:h.jsx(md,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs(Ss,{to:i,title:t.label,className:({isActive:m})=>`${o} gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] ${m?"bg-surface-hover text-text-primary font-medium":""}`,"data-testid":c,children:[h.jsx(md,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:t.label})]})}function zb({pin:n,collapsed:t,draggable:s,onDragStart:i,onDropOn:o,onRemove:c,onPromote:m,onHide:y}){const{pathname:g,search:u}=an(),[d,b=""]=n.url.split("?"),x=g===d&&u===(b?`?${b}`:""),v="group flex items-center rounded-md transition-colors duration-150",w=x?"bg-surface-hover text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover";return t?h.jsx(Ss,{to:n.url,className:`${v} ${w} justify-center w-10 h-10 mx-auto`,title:n.label,children:h.jsx(Ag,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs("div",{className:`${v} ${w} relative`,draggable:s,onDragStart:i,onDragOver:S=>S.preventDefault(),onDrop:o,children:[h.jsxs(Ss,{to:n.url,title:n.label,className:"flex items-center gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] flex-1 min-w-0",children:[h.jsx(Ag,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5,...n.fromRole?{}:{fill:"currentColor",fillOpacity:.15}}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:n.label}),n.badge&&h.jsx(wT,{url:n.url})]}),h.jsxs("span",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5 rounded px-0.5 bg-surface-hover opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity",children:[m&&h.jsx("button",{onClick:m,title:"Make mine — copy into my pins",className:"p-1 text-text-quaternary hover:text-accent transition-colors",children:h.jsx(nx,{className:"w-3 h-3"})}),y&&h.jsx("button",{onClick:y,title:"Hide this role pin",className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(xS,{className:"w-3 h-3"})}),c&&h.jsx("button",{onClick:c,title:`Remove "${n.label}"`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(Wt,{className:"w-3 h-3"})})]})]})}function wT({url:n}){var m;const t=E.useMemo(()=>bT(n),[n]),s={limit:1,staleTime:15e3},i=ev({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&t.available}),o=Zx({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&!t.available});if(!t)return null;const c=t.available?i:o;return c.isError||((m=c.data)==null?void 0:m.total)===void 0?null:h.jsx("span",{className:"shrink-0 text-right text-2xs leading-none tabular-nums text-accent/80 relative -top-[0.35em]",title:`${c.data.total} matching now`,children:c.data.total})}function ST(){var c;const{data:n}=Zn(),t=(c=n==null?void 0:n.features)==null?void 0:c.graphWorkflows,s=t===!0||t!==!1&&Hx(),i=[{to:"/workflows/registry",label:"Registry",icon:jg},{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:pd},{to:"/workflows/executions",label:"Executions",icon:kg}],o=s?[{kind:"group",label:"Procedural",icon:vS,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:i},{kind:"group",label:"Graph",icon:em,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:jg,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:pd},{to:"/mcp/executions",label:"Executions",icon:kg}]}]:i;return h.jsx(Dr,{heading:"Orchestrate",entries:o})}function eM(){return $e({queryKey:["activeWorkers"],queryFn:async()=>(await fe("/workflows/workers")).workers})}function tM(){return $e({queryKey:["discoveredWorkflows"],queryFn:async()=>(await fe("/workflows/discovered")).workflows})}function nM(){return $e({queryKey:["workflowConfigs"],queryFn:async()=>(await fe("/workflows/config")).workflows})}function Dv(){return $e({queryKey:["invocableWorkflows"],queryFn:async()=>(await fe("/workflows/invocable")).workflows})}function rM(n){return Object.fromEntries(n.filter(t=>!t.missing).map(t=>[t.as??t.key,t.data]))}function sM(n,t){return $e({queryKey:["workflows",n,"input-lookups"],queryFn:()=>fe(`/workflows/${encodeURIComponent(n)}/input-lookups`),enabled:!!n&&t,staleTime:0,refetchOnWindowFocus:!1})}function iM(){return $e({queryKey:["cronStatus"],queryFn:async()=>(await fe("/workflows/cron/status")).schedules})}function aM(n){return $e({queryKey:["workflowExecution",n],queryFn:()=>fe(`/workflow-states/${n}/execution`),enabled:!!n})}function oM(n,t){const s=new URLSearchParams;return n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),n.entity&&s.set("entity",n.entity),n.search&&s.set("search",n.search),n.status&&s.set("status",n.status),n.sort_by&&s.set("sort_by",n.sort_by),n.order&&s.set("order",n.order),n.registered&&s.set("registered",n.registered),n.namespace&&s.set("namespace",n.namespace),$e({queryKey:["jobs",n],queryFn:()=>fe(`/workflow-states/jobs?${s}`),enabled:(t==null?void 0:t.enabled)??!0})}function lM(){const n=He();return Ve({mutationFn:t=>fe(`/workflows/${t}/terminate`,{method:"POST"}),onSuccess:(t,s)=>{n.invalidateQueries({queryKey:["workflowExecution",s],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function cM(){const n=He();return Ve({mutationFn:({workflow_type:t,...s})=>fe(`/workflows/${encodeURIComponent(t)}/config`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function uM(){const n=He();return Ve({mutationFn:t=>fe(`/workflows/${encodeURIComponent(t)}/config`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function fM(){const n=He();return Ve({mutationFn:({workflowType:t,data:s,metadata:i,execute_as:o})=>fe(`/workflows/${t}/invoke`,{method:"POST",body:JSON.stringify({data:s,metadata:i,...o?{execute_as:o}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["tasks"],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function ET(){const{data:n}=Dv();return n!=null&&n.length?h.jsx(Dr,{heading:"Tools",entries:[{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:pd}]}):null}const OT=[{to:"/mcp/queries",label:"Designer",icon:_S},{to:"/mcp/servers",label:"Servers & Tools",icon:wS}];function AT(){return h.jsx(Dr,{heading:"Design",entries:OT})}const jT=[{to:"/files",label:"Files",icon:SS},{to:"/knowledge",label:"Knowledge Base",icon:rx}];function kT(){return h.jsx(Dr,{heading:"Storage",entries:jT})}function NT({isBuilder:n=!1,isOps:t=!1}){var m;const{data:s}=Zn(),i=((m=s==null?void 0:s.features)==null?void 0:m.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:ES},...n||t?[{to:"/admin/roles",label:"Roles",icon:dd},{to:"/admin/personas",label:"Personas",icon:OS},{to:"/admin/scan-codes",label:"Scan Codes",icon:No}]:[]],c=[{to:"/admin/controlplane",label:"Routers",icon:AS},{to:"/admin/streams",label:"Messages",icon:rx},...i?[{to:"/admin/maintenance",label:"DB Maintenance",icon:jS}]:[]];return h.jsxs(h.Fragment,{children:[h.jsx(Dr,{heading:"Identity & Access",entries:o}),n&&Fx()&&h.jsx(Dr,{heading:"Infrastructure",entries:c})]})}function Lv({aiEnabled:n,isBuilder:t,isOps:s,viewAs:i,canSeePaceBoard:o}){return h.jsxs(h.Fragment,{children:[h.jsx(lT,{aiEnabled:n,isBuilder:t,isOps:s,viewAs:i,canSeePaceBoard:o}),h.jsx(vT,{}),!t&&h.jsx(ET,{}),t&&h.jsx(ST,{}),t&&n&&h.jsx(AT,{}),t&&h.jsx(kT,{}),(t||s)&&h.jsx(NT,{isBuilder:t,isOps:s})]})}function TT({open:n,onClose:t,...s}){const i=an();return E.useEffect(()=>{t()},[i.pathname]),h.jsxs("div",{className:`lg:hidden fixed inset-y-0 left-0 z-40 flex ${n?"":"pointer-events-none"}`,children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${n?"opacity-100":"opacity-0"}`,onClick:t,"aria-hidden":!0}),h.jsxs("div",{className:`relative w-72 max-w-[85vw] h-full bg-surface-raised border-r border-surface-border shadow-xl flex flex-col transition-transform duration-200 ease-out ${n?"translate-x-0":"-translate-x-full"}`,children:[h.jsx("div",{className:"flex items-center justify-end px-3 pt-3 shrink-0",children:h.jsx("button",{onClick:t,className:"p-1.5 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-hover transition-colors","aria-label":"Close navigation",children:h.jsx(Wt,{className:"w-4 h-4"})})}),h.jsx("nav",{className:"flex-1 px-3 pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:h.jsx(jA,{children:h.jsx(Lv,{...s})})})]})]})}const qv="lt_event_feed_patterns";function CT(n,t){if(n.startsWith("/topics/")){const m=decodeURIComponent(n.replace("/topics/",""));if(m&&!m.includes("/"))return`lt.events.${m}`}const s=n.match(/^\/escalations\/detail\/(.+)/);if(s)return`lt.events.system.escalation.*.${s[1]}.>`;if(n.startsWith("/escalations")){const m=new URLSearchParams(t).get("role");return m?`lt.events.system.escalation.${Kx(m)}.>`:"lt.events.system.escalation.>"}const i=n.match(/^\/workflows\/(?:durable\/)?executions\/(.+)/);if(i)return`lt.events.system.workflow.${i[1]}.>`;if(n.startsWith("/workflows"))return"lt.events.system.workflow.>";const o=n.match(/^\/agents\/([^/]+)$/);if(o&&o[1]!=="new")return`lt.events.system.agent.${o[1]}.>`;if(n.startsWith("/agents"))return"lt.events.system.agent.>";if(n.startsWith("/knowledge"))return"lt.events.system.knowledge.>";if(n.startsWith("/files"))return"lt.events.system.file.>";if(n==="/")return"lt.events.system.>";const c=n.match(/^\/mcp\/executions\/(.+)/);return c?`lt.events.system.*.${c[1]}.>`:(n.startsWith("/mcp"),"lt.events.system.>")}function MT(){try{const n=localStorage.getItem(qv);return n?JSON.parse(n):[]}catch{return[]}}function ud(n){try{localStorage.setItem(qv,JSON.stringify(n))}catch{}}function RT(){const{pathname:n,search:t}=an(),[s,i]=E.useState(MT),o=E.useMemo(()=>CT(n,t),[n,t]),c=E.useMemo(()=>{const u=new Set([o,...s]);return Array.from(u)},[o,s]),m=E.useCallback(u=>{const d=u.startsWith("lt.events.")?u:`lt.events.${u}`;i(b=>{if(b.includes(d))return b;const x=[...b,d];return ud(x),x})},[]),y=E.useCallback(u=>{i(d=>{const b=d.filter(x=>x!==u);return ud(b),b})},[]),g=E.useCallback(()=>{i([]),ud([])},[]);return{patterns:c,pagePattern:o,userPatterns:s,addPattern:m,removePattern:y,clearUserPatterns:g}}function DT({children:n,className:t=""}){return h.jsx("p",{className:`text-2xs font-semibold uppercase tracking-widest text-text-tertiary ${t}`,children:n})}const fd=280,Ib="cubic-bezier(0.4, 0, 0.2, 1)",Xc=40;function LT(n){if(!n)return"scale(0.92)";const t=window.innerWidth,s=window.innerHeight,i=t-Xc*2,o=s-Xc*2,c=n.width/i,m=n.height/o,y=n.left+n.width/2-(Xc+i/2),g=n.top+n.height/2-(Xc+o/2);return`translate(${y}px, ${g}px) scale(${c}, ${m})`}function Bv({open:n,onClose:t,sourceRef:s,children:i}){const[o,c]=E.useState(null),m=E.useRef(null),y=E.useRef(!1);E.useEffect(()=>{var x,v;n&&!y.current?(m.current=((x=s==null?void 0:s.current)==null?void 0:x.getBoundingClientRect())??null,c("entering")):!n&&y.current&&o==="open"&&(m.current=((v=s==null?void 0:s.current)==null?void 0:v.getBoundingClientRect())??null,c("exiting")),y.current=n},[n,s,o]),E.useEffect(()=>{if(o!=="entering")return;const x=requestAnimationFrame(()=>{requestAnimationFrame(()=>c("open"))});return()=>cancelAnimationFrame(x)},[o]),E.useEffect(()=>{if(o)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o]),E.useEffect(()=>{if(!o)return;const x=v=>{v.key==="Escape"&&t()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[o,t]);const g=E.useCallback(x=>{x.propertyName==="transform"&&o==="exiting"&&c(null)},[o]);if(E.useEffect(()=>{if(o!=="exiting")return;const x=setTimeout(()=>c(null),fd+50);return()=>clearTimeout(x)},[o]),!o)return null;const u=o==="entering"||o==="exiting",d=u?LT(m.current):"none",b=u?0:1;return Wd.createPortal(h.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${fd}ms ${Ib}, opacity ${fd}ms ${Ib}`,transform:d,opacity:b,backgroundColor:"rgb(var(--lt-surface))"},onTransitionEnd:g,children:i}),document.body)}function qT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h8M4 18h12"})})}function BT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7l-5 5 5 5M16 7l5 5-5 5"})})}function PT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.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 UT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}function zT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.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 IT({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.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 $T(n){const t=n.trim().split(`
57
+ `);if(t.length<2)return n;const s=y=>y.split("|").map(g=>g.trim()).filter(Boolean),i=s(t[0]),o=t.slice(2),c=i.map(y=>`<th class="px-3 py-1.5 text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary">${y}</th>`).join(""),m=o.map(y=>`<tr class="border-t border-surface-border">${s(y).map(d=>`<td class="px-3 py-1.5 text-xs text-text-secondary">${d}</td>`).join("")}</tr>`).join("");return`<table class="w-full my-3 text-xs"><thead><tr class="border-b border-surface-border">${c}</tr></thead><tbody>${m}</tbody></table>`}function Qc(n){return n.toLowerCase().replace(/<[^>]+>/g,"").replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").trim()}function HT(n){const t=[];let s=n.replace(/```(\w*)\n([\s\S]*?)```/g,(g,u,d)=>{const b=t.length;return t.push(`<pre class="bg-surface-sunken rounded p-3 my-2 overflow-x-auto text-2xs leading-relaxed"><code>${d}</code></pre>`),`\0CODE${b}\0`});const i=/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm;s=s.replace(i,(g,u,d,b)=>$T(`${u}
58
58
  ${d}
59
- ${b.trimEnd()}`)),s=s.replace(/`([^`]+)`/g,'<code class="bg-surface-sunken px-1 py-0.5 rounded text-2xs">$1</code>'),s=s.replace(/^#### (.+)$/gm,(g,u)=>`<h4 id="${Qc(u)}" class="text-xs font-semibold text-text-primary mt-4 mb-1">${u}</h4>`).replace(/^### (.+)$/gm,(g,u)=>`<h3 id="${Qc(u)}" class="text-sm font-semibold text-text-primary mt-5 mb-1.5">${u}</h3>`).replace(/^## (.+)$/gm,(g,u)=>`<h2 id="${Qc(u)}" class="text-base font-semibold text-text-primary mt-6 mb-2 pb-1 border-b border-surface-border">${u}</h2>`).replace(/^# (.+)$/gm,(g,u)=>`<h1 id="${Qc(u)}" class="text-lg font-bold text-text-primary mb-3">${u}</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 u=g.replace(/^> /gm,"").trim(),d=/⚠️|warning|caution/i.test(u),b=/note:|ℹ️|info/i.test(u);return`<div class="${d?"bg-status-warning/5":b?"bg-accent/5":"bg-surface-sunken/50"} ${d?"border-status-warning":b?"border-accent":"border-text-tertiary"} border-l-2 rounded-r-md px-3 py-2 my-3 text-xs text-text-secondary leading-relaxed">${u}</div>`}).replace(/\n\n/g,"\0PARA\0").replace(/\n/g,"<br/>");const o=g=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=g=>new RegExp(`(${o(g)}[\\s\\S]*?<\\/li>(?:<br\\/>)?)+`,"g");s=s.replace(c('<li class="ml-8 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-decimal'),g=>`<ol class="list-decimal mb-3">${g}</ol>`),s=s.replace(/\x00CODE(\d+)\x00/g,(g,u)=>t[parseInt(u,10)]);const m="text-xs leading-relaxed text-text-secondary mb-2",y=/<\/(h[1-4]|pre|table|ul|ol|hr|div)>/;return s=s.split("\0PARA\0").map(g=>{const u=g.trim();if(!u)return"";const d=[];let b=u,x;for(;(x=y.exec(b))!==null;){const v=x.index+x[0].length;d.push(b.slice(0,v)),b=b.slice(v).replace(/^<br\/>/,"").trim(),y.lastIndex=0}return b&&d.push(b),d.map(v=>{const w=v.trim();return w?/^\s*<(h[1-4]|pre|table|ul|ol|hr|div)/.test(w)?w:`<p class="${m}">${w}</p>`:""}).join("")}).join(""),s}const HT=/(\*\*|^#{1,4}\s|^- |^\d+\.\s|```|^\|.*\|$|\[.+\]\(.+\))/m;function FT(n){return HT.test(n)}function Ru({content:n,className:t,onClick:s}){const i=E.useMemo(()=>$T(n),[n]);return h.jsx("div",{className:t,onClick:s,dangerouslySetInnerHTML:{__html:i}})}function _u({data:n,depth:t=0,generation:s}){const o=s!==void 0&&s>0&&s%2===1?!1:t>0,[c,m]=E.useState(o),[y,g]=E.useState(s);if(s!==void 0&&s!==y&&(g(s),m(s%2===0&&t>0)),n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return h.jsxs("span",{className:"text-text-primary",children:['"',n,'"']});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary",children:"[]"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["[",n.length," items]"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"["}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:n.map((u,d)=>h.jsxs("div",{children:[h.jsx(_u,{data:u,depth:t+1,generation:s}),d<n.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"]"})]});if(typeof n=="object"){const u=Object.entries(n);return u.length===0?h.jsx("span",{className:"text-text-tertiary",children:"{}"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["{","...","}"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"{"}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:u.map(([d,b],x)=>h.jsxs("div",{children:[h.jsx("span",{className:"text-text-secondary",children:d}),h.jsx("span",{className:"text-text-tertiary",children:": "}),h.jsx(_u,{data:b,depth:t+1,generation:s}),x<u.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"}"})]})}return h.jsx("span",{children:String(n)})}function _o({data:n,depth:t=0}){if(n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return n.length>40&&FT(n)?h.jsx(Ru,{content:n}):h.jsx("span",{className:"text-text-primary",children:n});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty list"}):h.jsx("div",{className:"space-y-2",children:n.map((s,i)=>h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsxs("span",{className:"text-text-tertiary text-2xs shrink-0",children:[i+1,"."]}),h.jsx("div",{className:"flex-1",children:h.jsx(_o,{data:s,depth:t+1})})]},i))});if(typeof n=="object"){const s=Object.entries(n);return s.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty"}):h.jsx("div",{className:t>0?"pl-4 border-l border-surface-border space-y-3":"space-y-3",children:s.map(([i,o])=>{const c=o===null||typeof o!="object";return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:i.replace(/[_-]/g," ")}),c?h.jsx("p",{className:"text-sm text-text-primary",children:h.jsx(_o,{data:o,depth:t+1})}):h.jsx(_o,{data:o,depth:t+1})]},i)})})}return h.jsx("span",{children:String(n)})}function Hb({mode:n,setMode:t,isCollapsed:s,onToggleCollapse:i,onCopy:o,copied:c,onFullscreen:m,onClose:y,large:g}){const u=g?"w-5 h-5":"w-3.5 h-3.5",d=`${g?"p-2":"p-1.5"} rounded text-accent/60 hover:text-accent hover:bg-surface-raised transition-colors duration-150`;return h.jsxs("div",{className:"flex items-center gap-0.5 bg-surface-sunken/80 rounded-md backdrop-blur-sm",children:[n==="json"&&h.jsx("button",{onClick:i,className:d,title:s?"Expand all":"Collapse all",children:s?h.jsx(zT,{className:u}):h.jsx(UT,{className:u})}),h.jsx("button",{onClick:()=>t(n==="json"?"tree":"json"),className:d,title:n==="json"?"Outline view":"JSON view",children:n==="json"?h.jsx(LT,{className:u}):h.jsx(qT,{className:u})}),h.jsx("button",{onClick:o,className:d,title:"Copy to clipboard",children:c?h.jsx(PT,{className:`${u} text-status-success`}):h.jsx(BT,{className:u})}),m&&h.jsx("button",{onClick:m,className:d,title:"Fullscreen",children:h.jsx(ix,{className:u})}),y&&h.jsx("button",{onClick:y,className:d,title:"Close (Esc)",children:h.jsx(ax,{className:u})})]})}function GT({data:n,label:t,variant:s,defaultCollapsed:i=!1,defaultMode:o}){const c=E.useRef(null),[m,y]=E.useState(o??"json"),[g,u]=E.useState(!1),[d,b]=E.useState(!1),[x,v]=E.useState(i?0:1),[w,S]=E.useState(1),C=x%2===0,q=w%2===0,B=E.useCallback(()=>v(D=>D+1),[]),ie=E.useCallback(()=>S(D=>D+1),[]);let le=n;if(typeof n=="string")try{le=JSON.parse(n)}catch{}const R=async()=>{const D=typeof n=="string"?n:JSON.stringify(le,null,2);await navigator.clipboard.writeText(D),u(!0),setTimeout(()=>u(!1),2e3)},$=E.useCallback(()=>{S(1),b(!0)},[]),ne=s==="panel",V=ne?"border border-accent-muted/40 rounded-lg p-3 bg-surface-hover/30":"",I=ne?"font-mono text-xs leading-relaxed bg-surface-raised rounded-md p-4 overflow-x-auto break-all":"font-mono text-xs leading-relaxed bg-surface-sunken border border-surface-border rounded-md p-4 overflow-x-auto break-all";return h.jsxs("div",{className:V,children:[t&&h.jsx(RT,{children:t}),h.jsxs("div",{ref:c,className:"relative",children:[h.jsx("div",{className:"absolute top-2 right-2 z-[5]",children:h.jsx(Hb,{mode:m,setMode:y,isCollapsed:C,onToggleCollapse:B,onCopy:R,copied:g,onFullscreen:$})}),h.jsx("div",{className:I,children:m==="json"?h.jsx(_u,{data:le,generation:x}):h.jsx(_o,{data:le})})]}),h.jsxs(Pv,{open:d,onClose:()=>b(!1),sourceRef:c,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx(Hb,{mode:m,setMode:y,isCollapsed:q,onToggleCollapse:ie,onCopy:R,copied:g,onClose:()=>b(!1),large:!0})}),h.jsx("div",{className:"font-mono text-sm leading-relaxed",children:m==="json"?h.jsx(_u,{data:le,generation:w}):h.jsx(_o,{data:le})})]})]})}const VT=100,Fb=500;let YT=0;const Uv={"escalation.created":"text-status-active","escalation.claimed":"text-status-warning","escalation.released":"text-text-tertiary","escalation.resolved":"text-status-success","task.created":"text-accent","task.completed":"text-status-success","task.failed":"text-status-error","task.escalated":"text-status-warning","workflow.started":"text-accent","workflow.completed":"text-status-success","workflow.failed":"text-status-error","activity.started":"text-status-active","activity.completed":"text-status-success","activity.failed":"text-status-error","knowledge.stored":"text-accent","knowledge.deleted":"text-text-tertiary","agent.started":"text-accent","agent.completed":"text-status-success","agent.failed":"text-status-error","agent.status_changed":"text-status-active",milestone:"text-accent"};function zv(n){const t=n.split(".");return t[0]==="system"&&t.length>=3?`${t[1]}.${t[t.length-1]}`:n}function Gb({event:n,forceExpanded:t=!1}){var x,v;const[s,i]=E.useState(t),o=Uv[zv(n.type)]||"text-text-tertiary";E.useEffect(()=>{i(t)},[t]);const c=t,m=c?"text-xs":"text-2xs",y=c?"text-xs":"text-2xs",g=c?"text-xs":"text-2xs",u=c?"w-3.5 h-3.5":"w-2.5 h-2.5",d=c?"py-2 px-4":"py-1 px-3",b=c?"pb-4 px-4":"pb-2 px-3";return h.jsxs("div",{className:"border-b border-surface-border/30 last:border-b-0",children:[h.jsxs("button",{onClick:()=>i(!s),className:`flex items-center gap-2 ${d} w-full text-left hover:bg-surface-hover/50 transition-colors`,children:[h.jsx("span",{className:`${m} font-mono text-text-tertiary whitespace-nowrap tabular-nums shrink-0`,children:new Date(n.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),h.jsx("span",{className:`${y} font-medium px-1 py-0.5 rounded ${o} bg-surface-sunken whitespace-nowrap shrink-0`,children:n.type}),h.jsxs("span",{className:`${g} text-text-tertiary font-mono flex-1 min-w-0 truncate`,children:[(x=n.data)!=null&&x.workflowId?String(n.data.workflowId):"",(v=n.data)!=null&&v.escalationId?` esc:${String(n.data.escalationId).slice(0,12)}`:""]}),h.jsx("svg",{className:`${u} text-text-tertiary shrink-0 transition-transform duration-150 ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),h.jsx(Um,{open:s,children:h.jsx("div",{className:b,children:h.jsx(GT,{data:n.data})})})]})}function KT({open:n,onToggle:t,configOpen:s,onToggleConfig:i}){const[o,c]=E.useState([]),[m,y]=E.useState(!1),[g,u]=E.useState(""),d=E.useRef(null),b=E.useRef(new Map),{subscribe:x}=E.useContext(ia),{connected:v}=Nx(),{patterns:w,pagePattern:S,userPatterns:C,addPattern:q,removePattern:B}=MT(),ie=E.useCallback($=>{const ne=String($.type||"unknown");if(ne.startsWith("mesh."))return;const V=`${ne}:${$.timestamp||""}:${$.escalationId||$.workflowId||$.taskId||""}`,I=Date.now(),D=b.current.get(V);if(!(D&&I-D<Fb)){if(b.current.set(V,I),b.current.size>200)for(const[Q,X]of b.current)I-X>Fb*2&&b.current.delete(Q);c(Q=>[{id:++YT,type:ne,timestamp:$.timestamp||new Date().toISOString(),data:$},...Q].slice(0,VT))}},[]),le=E.useRef(ie);le.current=ie;const R=n||m||s;return E.useEffect(()=>{if(!R)return;const $=w.map(ne=>x(ne,V=>le.current(V)));return()=>$.forEach(ne=>ne())},[x,w.join(","),R]),E.useEffect(()=>{n&&d.current&&(d.current.scrollTop=0)},[o.length,n]),h.jsxs("div",{className:"shrink-0 border-t border-surface-border bg-surface-raised",children:[h.jsxs("button",{onClick:t,className:"flex items-center gap-2 w-full px-4 py-1.5 text-left hover:bg-surface-hover transition-colors",children:[n?h.jsx(Zd,{className:"w-3 h-3 text-text-tertiary"}):h.jsx(ox,{className:"w-3 h-3 text-text-tertiary"}),h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:"Event Stream"}),o.length>0&&h.jsxs("span",{className:"text-2xs text-text-tertiary",children:[o.length," events"]}),o.length>0&&!n&&h.jsx("span",{className:`text-2xs font-medium px-1 py-0.5 rounded ${Uv[zv(o[0].type)]||"text-text-tertiary"} bg-surface-sunken`,children:o[0].type}),h.jsxs("span",{className:"ml-auto flex items-center gap-1",children:[h.jsx("span",{className:`p-0.5 ${v?"text-status-success":"text-status-warning hover:text-text-primary cursor-pointer"}`,title:v?"Live events connected":"Events disconnected — click to reconnect",onClick:$=>{$.stopPropagation(),v||window.location.reload()},children:h.jsx(nx,{className:"w-3 h-3"})}),h.jsx("span",{className:`p-0.5 cursor-pointer ${s?"text-accent":"text-text-tertiary hover:text-text-primary"}`,title:"Subscription config",onClick:$=>{$.stopPropagation(),i()},children:h.jsx(NS,{className:"w-3 h-3"})}),o.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Fullscreen",onClick:$=>{$.stopPropagation(),y(!0)},children:h.jsx(ix,{className:"w-3 h-3"})}),h.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Clear events",onClick:$=>{$.stopPropagation(),c([])},children:h.jsx(TS,{className:"w-3 h-3"})})]})]})]}),s&&h.jsxs("div",{className:"px-4 py-2 border-t border-surface-border/50 bg-surface-sunken/30",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-1.5",children:[h.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider shrink-0",children:"Subscribed:"}),h.jsx("span",{className:"text-2xs font-mono text-accent px-1.5 py-0.5 bg-accent/10 rounded",children:S.replace("lt.events.","")}),C.map($=>h.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-mono text-text-secondary px-1.5 py-0.5 bg-surface-sunken rounded",children:[$.replace("lt.events.",""),h.jsx("button",{onClick:()=>B($),className:"text-text-quaternary hover:text-status-error",children:h.jsx(Wt,{className:"w-2 h-2"})})]},$))]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"text",value:g,onChange:$=>u($.target.value),onKeyDown:$=>{$.key==="Enter"&&g.trim()&&(q(g.trim()),u(""))},placeholder:"task.> or file.stored",className:"input text-2xs font-mono flex-1 py-1"}),h.jsxs("button",{onClick:()=>{g.trim()&&(q(g.trim()),u(""))},className:"text-2xs text-accent hover:text-accent-hover flex items-center gap-0.5",children:[h.jsx(rx,{className:"w-2.5 h-2.5"})," Add"]})]})]}),h.jsx(Um,{open:n,children:h.jsx("div",{ref:d,className:"h-48 overflow-y-auto",children:o.length===0?h.jsx("p",{className:"text-2xs text-text-tertiary py-4 text-center",children:"Waiting for events..."}):o.map($=>h.jsx(Gb,{event:$},$.id))})}),h.jsxs(Pv,{open:m,onClose:()=>y(!1),sourceRef:d,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx("button",{onClick:()=>y(!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:h.jsx(ax,{className:"w-5 h-5"})})}),o.length===0?h.jsx("p",{className:"text-sm text-text-tertiary py-8",children:"No events captured"}):o.map($=>h.jsx(Gb,{event:$,forceExpanded:!0},$.id))]})]})}function JT(){return $e({queryKey:["docs"],queryFn:()=>fe("/docs"),staleTime:5*6e4})}function XT(n){return $e({queryKey:["docs",n],queryFn:()=>fe(`/docs/read?path=${encodeURIComponent(n)}`),enabled:!!n,staleTime:5*6e4})}function QT(){const[n,t]=E.useState([]),[s,i]=E.useState([]),[o,c]=E.useState(null),m=E.useRef(o),y=E.useRef(n),g=E.useRef(s);m.current=o,y.current=n,g.current=s;const u=E.useCallback((w,S)=>{var q;const C=m.current;if(C){const B=((q=S==null?void 0:S.current)==null?void 0:q.scrollTop)??0;t([...y.current,{...C,scrollTop:B}])}i([]),c({path:w,scrollTop:0})},[]),d=E.useCallback(w=>{var B;const S=y.current;if(S.length===0)return;const C=S[S.length-1],q=m.current;if(q){const ie=((B=w==null?void 0:w.current)==null?void 0:B.scrollTop)??0;i([...g.current,{...q,scrollTop:ie}])}t(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{w!=null&&w.current&&(w.current.scrollTop=C.scrollTop)})},[]),b=E.useCallback(w=>{var B;const S=g.current;if(S.length===0)return;const C=S[S.length-1],q=m.current;if(q){const ie=((B=w==null?void 0:w.current)==null?void 0:B.scrollTop)??0;t([...y.current,{...q,scrollTop:ie}])}i(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{w!=null&&w.current&&(w.current.scrollTop=C.scrollTop)})},[]),x=E.useCallback(w=>{var q,B;const S=m.current;if(!S)return;const C=((q=w==null?void 0:w.current)==null?void 0:q.scrollTop)??0;t([...y.current,{...S,scrollTop:C}]),i([]),c({...S,scrollTop:((B=w==null?void 0:w.current)==null?void 0:B.scrollTop)??0})},[]),v=E.useCallback(()=>{t([]),i([]),c(null)},[]);return{current:o,backStack:n,forwardStack:s,navigate:u,goBack:d,goForward:b,pushScrollPosition:x,reset:v}}function WT(n,t){const[s,i]=n.split("#");let o=s;if(o.startsWith("./")||o.startsWith("../")){const m=((t?t.replace(/[^/]+$/,""):"")+o).split("/"),y=[];for(const g of m)g===".."?y.pop():g&&g!=="."&&y.push(g);o=y.join("/")}return{path:o,anchor:i}}function ZT(n){if(!n.startsWith("#docs"))return null;const t=n.slice(1).split(":"),s=t[1]||"README.md",i=t[2]||void 0;return{path:s,anchor:i}}function eC(n){return!n||n==="README.md"?"#docs":`#docs:${n}`}function tC({content:n,currentPath:t,onNavigate:s,onAnchorClick:i}){const o=c=>{var u;const m=c.target,y=m.closest("[data-anchor]");if(y){c.preventDefault(),i();const d=y.dataset.anchor,b=(u=y.closest(".docs-content"))==null?void 0:u.querySelector(`#${CSS.escape(d)}`);b==null||b.scrollIntoView({behavior:"smooth",block:"start"});return}const g=m.closest("[data-doc-link]");if(g){c.preventDefault();const{path:d,anchor:b}=WT(g.dataset.docLink,t);s(d,b);return}};return h.jsx(Ru,{content:n,className:"docs-content",onClick:o})}function nC(n){const t=[],s=new Map;for(const i of n){const o=i.path.split("/");if(o.length===1){t.push(i);continue}let c=s;for(let m=0;m<o.length-1;m++){const y=o[m];c.has(y)||c.set(y,{label:y,children:[],subdirs:new Map});const g=c.get(y);m===o.length-2?g.children.push(i):c=g.subdirs}}return{topLevel:t,dirs:s}}function rC({docs:n,selected:t,onSelect:s}){const{topLevel:i,dirs:o}=nC(n),c=y=>`block w-full text-left px-3 py-1 text-xs rounded truncate transition-colors ${t===y?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-hover"}`;function m(y,g){return h.jsxs("details",{open:!0,children:[h.jsxs("summary",{className:"flex items-center gap-1.5 px-3 py-1 text-2xs font-semibold uppercase tracking-widest text-text-tertiary cursor-pointer",children:[h.jsx(CS,{className:"w-3 h-3",strokeWidth:1.5}),y.label]}),h.jsxs("div",{className:"pl-2 space-y-0.5",children:[[...y.subdirs.values()].map(u=>m(u)),y.children.map(u=>h.jsx("button",{className:c(u.path),onClick:()=>s(u.path),children:u.title},u.path))]})]},y.label)}return h.jsxs("div",{className:"space-y-0.5",children:[i.map(y=>h.jsx("button",{className:c(y.path),onClick:()=>s(y.path),children:y.title},y.path)),[...o.values()].map(y=>m(y))]})}function sC({open:n,onClose:t}){var ne,V,I;const[s,i]=E.useState(!1),{data:o}=JT(),c=QT(),{data:m,isLoading:y}=XT(((ne=c.current)==null?void 0:ne.path)??null),g=E.useRef(null),[u,d]=E.useState(null);E.useEffect(()=>{u&&(m!=null&&m.content)&&g.current&&requestAnimationFrame(()=>{var Q;const D=(Q=g.current)==null?void 0:Q.querySelector(`#${CSS.escape(u)}`);D==null||D.scrollIntoView({behavior:"smooth",block:"start"}),d(null)})},[u,m]);const b=E.useCallback(()=>{var X;const D=ZT(window.location.hash),Q=(D==null?void 0:D.path)??"README.md";((X=c.current)==null?void 0:X.path)!==Q&&c.navigate(Q,g),D!=null&&D.anchor&&d(D.anchor)},[c]),x=E.useRef(!0);E.useEffect(()=>{if(!n||!c.current)return;if(x.current){x.current=!1;return}const D=eC(c.current.path);window.location.hash!==D&&window.history.replaceState(null,"",window.location.pathname+window.location.search+D)},[n,(V=c.current)==null?void 0:V.path]),E.useEffect(()=>{if(!n)return;const D=()=>{window.location.hash.startsWith("#docs")&&b()};return window.addEventListener("hashchange",D),()=>window.removeEventListener("hashchange",D)},[n,b]);const v=E.useCallback((D,Q)=>{Q&&d(Q),c.navigate(D,g)},[c]),w=E.useCallback(D=>{c.navigate(D,g)},[c]),S=E.useCallback(()=>{c.goBack(g)},[c]),C=E.useCallback(()=>{c.goForward(g)},[c]),q=E.useCallback(()=>{c.pushScrollPosition(g)},[c]);if(E.useEffect(()=>{if(n){x.current=!0,b();const D=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(D)}},[n]),!(n||s))return null;const ie=()=>{i(!1),setTimeout(()=>{t(),c.reset()},200)},le=((I=c.current)==null?void 0:I.path)??null,R=c.backStack.length>0,$=c.forwardStack.length>0;return h.jsxs("div",{className:"fixed inset-y-0 right-0 z-50 flex",children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${s&&n?"opacity-100":"opacity-0"}`,onClick:ie}),h.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&&n?"translate-x-0":"translate-x-full"}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:S,disabled:!R,className:`p-0.5 transition-colors ${R?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Back",children:h.jsx(tx,{className:"w-4 h-4"})}),h.jsx("button",{onClick:C,disabled:!$,className:`p-0.5 transition-colors ${$?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Forward",children:h.jsx(hd,{className:"w-4 h-4"})}),h.jsx(MS,{className:"w-4 h-4 text-accent ml-1",strokeWidth:1.5}),h.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Documentation"})]}),h.jsx("button",{onClick:ie,className:"p-1 text-text-tertiary hover:text-text-primary",children:h.jsx(Wt,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[h.jsx("div",{className:"w-48 shrink-0 border-r border-surface-border overflow-y-auto py-2",children:o!=null&&o.docs?h.jsx(rC,{docs:o.docs,selected:le,onSelect:w}):h.jsx("div",{className:"px-3 py-2 text-xs text-text-tertiary",children:"Loading..."})}),h.jsx("div",{ref:g,className:"flex-1 overflow-y-auto px-6 py-4",children:le?y?h.jsxs("div",{className:"animate-pulse space-y-2",children:[h.jsx("div",{className:"h-6 bg-surface-sunken rounded w-48"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}):m!=null&&m.content?h.jsx(tC,{content:m.content,currentPath:le,onNavigate:v,onAnchorClick:q}):h.jsx("p",{className:"text-xs text-text-tertiary",children:"Document not found."}):h.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-tertiary",children:[h.jsx(hd,{className:"w-5 h-5 mb-2"}),h.jsx("p",{className:"text-xs",children:"Select a document"})]})})]})]})]})}function iC(n){if(n.includes("/escalations"))return["escalation","human-queue"]}const Vb=2e3;function aC(n){const s=n.filter(o=>!o.pending).slice(-8);return s.length===0?"":`[Prior conversation]
59
+ ${b.trimEnd()}`)),s=s.replace(/`([^`]+)`/g,'<code class="bg-surface-sunken px-1 py-0.5 rounded text-2xs">$1</code>'),s=s.replace(/^#### (.+)$/gm,(g,u)=>`<h4 id="${Qc(u)}" class="text-xs font-semibold text-text-primary mt-4 mb-1">${u}</h4>`).replace(/^### (.+)$/gm,(g,u)=>`<h3 id="${Qc(u)}" class="text-sm font-semibold text-text-primary mt-5 mb-1.5">${u}</h3>`).replace(/^## (.+)$/gm,(g,u)=>`<h2 id="${Qc(u)}" class="text-base font-semibold text-text-primary mt-6 mb-2 pb-1 border-b border-surface-border">${u}</h2>`).replace(/^# (.+)$/gm,(g,u)=>`<h1 id="${Qc(u)}" class="text-lg font-bold text-text-primary mb-3">${u}</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 u=g.replace(/^> /gm,"").trim(),d=/⚠️|warning|caution/i.test(u),b=/note:|ℹ️|info/i.test(u);return`<div class="${d?"bg-status-warning/5":b?"bg-accent/5":"bg-surface-sunken/50"} ${d?"border-status-warning":b?"border-accent":"border-text-tertiary"} border-l-2 rounded-r-md px-3 py-2 my-3 text-xs text-text-secondary leading-relaxed">${u}</div>`}).replace(/\n\n/g,"\0PARA\0").replace(/\n/g,"<br/>");const o=g=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=g=>new RegExp(`(${o(g)}[\\s\\S]*?<\\/li>(?:<br\\/>)?)+`,"g");s=s.replace(c('<li class="ml-8 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-decimal'),g=>`<ol class="list-decimal mb-3">${g}</ol>`),s=s.replace(/\x00CODE(\d+)\x00/g,(g,u)=>t[parseInt(u,10)]);const m="text-xs leading-relaxed text-text-secondary mb-2",y=/<\/(h[1-4]|pre|table|ul|ol|hr|div)>/;return s=s.split("\0PARA\0").map(g=>{const u=g.trim();if(!u)return"";const d=[];let b=u,x;for(;(x=y.exec(b))!==null;){const v=x.index+x[0].length;d.push(b.slice(0,v)),b=b.slice(v).replace(/^<br\/>/,"").trim(),y.lastIndex=0}return b&&d.push(b),d.map(v=>{const w=v.trim();return w?/^\s*<(h[1-4]|pre|table|ul|ol|hr|div)/.test(w)?w:`<p class="${m}">${w}</p>`:""}).join("")}).join(""),s}const FT=/(\*\*|^#{1,4}\s|^- |^\d+\.\s|```|^\|.*\|$|\[.+\]\(.+\))/m;function GT(n){return FT.test(n)}function Ru({content:n,className:t,onClick:s}){const i=E.useMemo(()=>HT(n),[n]);return h.jsx("div",{className:t,onClick:s,dangerouslySetInnerHTML:{__html:i}})}function _u({data:n,depth:t=0,generation:s}){const o=s!==void 0&&s>0&&s%2===1?!1:t>0,[c,m]=E.useState(o),[y,g]=E.useState(s);if(s!==void 0&&s!==y&&(g(s),m(s%2===0&&t>0)),n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return h.jsxs("span",{className:"text-text-primary",children:['"',n,'"']});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary",children:"[]"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["[",n.length," items]"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"["}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:n.map((u,d)=>h.jsxs("div",{children:[h.jsx(_u,{data:u,depth:t+1,generation:s}),d<n.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"]"})]});if(typeof n=="object"){const u=Object.entries(n);return u.length===0?h.jsx("span",{className:"text-text-tertiary",children:"{}"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["{","...","}"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"{"}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:u.map(([d,b],x)=>h.jsxs("div",{children:[h.jsx("span",{className:"text-text-secondary",children:d}),h.jsx("span",{className:"text-text-tertiary",children:": "}),h.jsx(_u,{data:b,depth:t+1,generation:s}),x<u.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"}"})]})}return h.jsx("span",{children:String(n)})}function _o({data:n,depth:t=0}){if(n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return n.length>40&&GT(n)?h.jsx(Ru,{content:n}):h.jsx("span",{className:"text-text-primary",children:n});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty list"}):h.jsx("div",{className:"space-y-2",children:n.map((s,i)=>h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsxs("span",{className:"text-text-tertiary text-2xs shrink-0",children:[i+1,"."]}),h.jsx("div",{className:"flex-1",children:h.jsx(_o,{data:s,depth:t+1})})]},i))});if(typeof n=="object"){const s=Object.entries(n);return s.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty"}):h.jsx("div",{className:t>0?"pl-4 border-l border-surface-border space-y-3":"space-y-3",children:s.map(([i,o])=>{const c=o===null||typeof o!="object";return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:i.replace(/[_-]/g," ")}),c?h.jsx("p",{className:"text-sm text-text-primary",children:h.jsx(_o,{data:o,depth:t+1})}):h.jsx(_o,{data:o,depth:t+1})]},i)})})}return h.jsx("span",{children:String(n)})}function $b({mode:n,setMode:t,isCollapsed:s,onToggleCollapse:i,onCopy:o,copied:c,onFullscreen:m,onClose:y,large:g}){const u=g?"w-5 h-5":"w-3.5 h-3.5",d=`${g?"p-2":"p-1.5"} rounded text-accent/60 hover:text-accent hover:bg-surface-raised transition-colors duration-150`;return h.jsxs("div",{className:"flex items-center gap-0.5 bg-surface-sunken/80 rounded-md backdrop-blur-sm",children:[n==="json"&&h.jsx("button",{onClick:i,className:d,title:s?"Expand all":"Collapse all",children:s?h.jsx(IT,{className:u}):h.jsx(zT,{className:u})}),h.jsx("button",{onClick:()=>t(n==="json"?"tree":"json"),className:d,title:n==="json"?"Outline view":"JSON view",children:n==="json"?h.jsx(qT,{className:u}):h.jsx(BT,{className:u})}),h.jsx("button",{onClick:o,className:d,title:"Copy to clipboard",children:c?h.jsx(UT,{className:`${u} text-status-success`}):h.jsx(PT,{className:u})}),m&&h.jsx("button",{onClick:m,className:d,title:"Fullscreen",children:h.jsx(sx,{className:u})}),y&&h.jsx("button",{onClick:y,className:d,title:"Close (Esc)",children:h.jsx(ix,{className:u})})]})}function VT({data:n,label:t,variant:s,defaultCollapsed:i=!1,defaultMode:o}){const c=E.useRef(null),[m,y]=E.useState(o??"json"),[g,u]=E.useState(!1),[d,b]=E.useState(!1),[x,v]=E.useState(i?0:1),[w,S]=E.useState(1),C=x%2===0,q=w%2===0,B=E.useCallback(()=>v(D=>D+1),[]),ie=E.useCallback(()=>S(D=>D+1),[]);let le=n;if(typeof n=="string")try{le=JSON.parse(n)}catch{}const R=async()=>{const D=typeof n=="string"?n:JSON.stringify(le,null,2);await navigator.clipboard.writeText(D),u(!0),setTimeout(()=>u(!1),2e3)},$=E.useCallback(()=>{S(1),b(!0)},[]),ne=s==="panel",V=ne?"border border-accent-muted/40 rounded-lg p-3 bg-surface-hover/30":"",I=ne?"font-mono text-xs leading-relaxed bg-surface-raised rounded-md p-4 overflow-x-auto break-all":"font-mono text-xs leading-relaxed bg-surface-sunken border border-surface-border rounded-md p-4 overflow-x-auto break-all";return h.jsxs("div",{className:V,children:[t&&h.jsx(DT,{children:t}),h.jsxs("div",{ref:c,className:"relative",children:[h.jsx("div",{className:"absolute top-2 right-2 z-[5]",children:h.jsx($b,{mode:m,setMode:y,isCollapsed:C,onToggleCollapse:B,onCopy:R,copied:g,onFullscreen:$})}),h.jsx("div",{className:I,children:m==="json"?h.jsx(_u,{data:le,generation:x}):h.jsx(_o,{data:le})})]}),h.jsxs(Bv,{open:d,onClose:()=>b(!1),sourceRef:c,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx($b,{mode:m,setMode:y,isCollapsed:q,onToggleCollapse:ie,onCopy:R,copied:g,onClose:()=>b(!1),large:!0})}),h.jsx("div",{className:"font-mono text-sm leading-relaxed",children:m==="json"?h.jsx(_u,{data:le,generation:w}):h.jsx(_o,{data:le})})]})]})}const YT=100,Hb=500;let KT=0;const Pv={"escalation.created":"text-status-active","escalation.claimed":"text-status-warning","escalation.released":"text-text-tertiary","escalation.resolved":"text-status-success","task.created":"text-accent","task.completed":"text-status-success","task.failed":"text-status-error","task.escalated":"text-status-warning","workflow.started":"text-accent","workflow.completed":"text-status-success","workflow.failed":"text-status-error","activity.started":"text-status-active","activity.completed":"text-status-success","activity.failed":"text-status-error","knowledge.stored":"text-accent","knowledge.deleted":"text-text-tertiary","agent.started":"text-accent","agent.completed":"text-status-success","agent.failed":"text-status-error","agent.status_changed":"text-status-active",milestone:"text-accent"};function Uv(n){const t=n.split(".");return t[0]==="system"&&t.length>=3?`${t[1]}.${t[t.length-1]}`:n}function Fb({event:n,forceExpanded:t=!1}){var x,v;const[s,i]=E.useState(t),o=Pv[Uv(n.type)]||"text-text-tertiary";E.useEffect(()=>{i(t)},[t]);const c=t,m=c?"text-xs":"text-2xs",y=c?"text-xs":"text-2xs",g=c?"text-xs":"text-2xs",u=c?"w-3.5 h-3.5":"w-2.5 h-2.5",d=c?"py-2 px-4":"py-1 px-3",b=c?"pb-4 px-4":"pb-2 px-3";return h.jsxs("div",{className:"border-b border-surface-border/30 last:border-b-0",children:[h.jsxs("button",{onClick:()=>i(!s),className:`flex items-center gap-2 ${d} w-full text-left hover:bg-surface-hover/50 transition-colors`,children:[h.jsx("span",{className:`${m} font-mono text-text-tertiary whitespace-nowrap tabular-nums shrink-0`,children:new Date(n.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),h.jsx("span",{className:`${y} font-medium px-1 py-0.5 rounded ${o} bg-surface-sunken whitespace-nowrap shrink-0`,children:n.type}),h.jsxs("span",{className:`${g} text-text-tertiary font-mono flex-1 min-w-0 truncate`,children:[(x=n.data)!=null&&x.workflowId?String(n.data.workflowId):"",(v=n.data)!=null&&v.escalationId?` esc:${String(n.data.escalationId).slice(0,12)}`:""]}),h.jsx("svg",{className:`${u} text-text-tertiary shrink-0 transition-transform duration-150 ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),h.jsx(Um,{open:s,children:h.jsx("div",{className:b,children:h.jsx(VT,{data:n.data})})})]})}function JT({open:n,onToggle:t,configOpen:s,onToggleConfig:i}){const[o,c]=E.useState([]),[m,y]=E.useState(!1),[g,u]=E.useState(""),d=E.useRef(null),b=E.useRef(new Map),{subscribe:x}=E.useContext(ia),{connected:v}=kx(),{patterns:w,pagePattern:S,userPatterns:C,addPattern:q,removePattern:B}=RT(),ie=E.useCallback($=>{const ne=String($.type||"unknown");if(ne.startsWith("mesh."))return;const V=`${ne}:${$.timestamp||""}:${$.escalationId||$.workflowId||$.taskId||""}`,I=Date.now(),D=b.current.get(V);if(!(D&&I-D<Hb)){if(b.current.set(V,I),b.current.size>200)for(const[Q,X]of b.current)I-X>Hb*2&&b.current.delete(Q);c(Q=>[{id:++KT,type:ne,timestamp:$.timestamp||new Date().toISOString(),data:$},...Q].slice(0,YT))}},[]),le=E.useRef(ie);le.current=ie;const R=n||m||s;return E.useEffect(()=>{if(!R)return;const $=w.map(ne=>x(ne,V=>le.current(V)));return()=>$.forEach(ne=>ne())},[x,w.join(","),R]),E.useEffect(()=>{n&&d.current&&(d.current.scrollTop=0)},[o.length,n]),h.jsxs("div",{className:"shrink-0 border-t border-surface-border bg-surface-raised",children:[h.jsxs("button",{onClick:t,className:"flex items-center gap-2 w-full px-4 py-1.5 text-left hover:bg-surface-hover transition-colors",children:[n?h.jsx(Zd,{className:"w-3 h-3 text-text-tertiary"}):h.jsx(ax,{className:"w-3 h-3 text-text-tertiary"}),h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:"Event Stream"}),o.length>0&&h.jsxs("span",{className:"text-2xs text-text-tertiary",children:[o.length," events"]}),o.length>0&&!n&&h.jsx("span",{className:`text-2xs font-medium px-1 py-0.5 rounded ${Pv[Uv(o[0].type)]||"text-text-tertiary"} bg-surface-sunken`,children:o[0].type}),h.jsxs("span",{className:"ml-auto flex items-center gap-1",children:[h.jsx("span",{className:`p-0.5 ${v?"text-status-success":"text-status-warning hover:text-text-primary cursor-pointer"}`,title:v?"Live events connected":"Events disconnected — click to reconnect",onClick:$=>{$.stopPropagation(),v||window.location.reload()},children:h.jsx(tx,{className:"w-3 h-3"})}),h.jsx("span",{className:`p-0.5 cursor-pointer ${s?"text-accent":"text-text-tertiary hover:text-text-primary"}`,title:"Subscription config",onClick:$=>{$.stopPropagation(),i()},children:h.jsx(kS,{className:"w-3 h-3"})}),o.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Fullscreen",onClick:$=>{$.stopPropagation(),y(!0)},children:h.jsx(sx,{className:"w-3 h-3"})}),h.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Clear events",onClick:$=>{$.stopPropagation(),c([])},children:h.jsx(NS,{className:"w-3 h-3"})})]})]})]}),s&&h.jsxs("div",{className:"px-4 py-2 border-t border-surface-border/50 bg-surface-sunken/30",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-1.5",children:[h.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider shrink-0",children:"Subscribed:"}),h.jsx("span",{className:"text-2xs font-mono text-accent px-1.5 py-0.5 bg-accent/10 rounded",children:S.replace("lt.events.","")}),C.map($=>h.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-mono text-text-secondary px-1.5 py-0.5 bg-surface-sunken rounded",children:[$.replace("lt.events.",""),h.jsx("button",{onClick:()=>B($),className:"text-text-quaternary hover:text-status-error",children:h.jsx(Wt,{className:"w-2 h-2"})})]},$))]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"text",value:g,onChange:$=>u($.target.value),onKeyDown:$=>{$.key==="Enter"&&g.trim()&&(q(g.trim()),u(""))},placeholder:"task.> or file.stored",className:"input text-2xs font-mono flex-1 py-1"}),h.jsxs("button",{onClick:()=>{g.trim()&&(q(g.trim()),u(""))},className:"text-2xs text-accent hover:text-accent-hover flex items-center gap-0.5",children:[h.jsx(nx,{className:"w-2.5 h-2.5"})," Add"]})]})]}),h.jsx(Um,{open:n,children:h.jsx("div",{ref:d,className:"h-48 overflow-y-auto",children:o.length===0?h.jsx("p",{className:"text-2xs text-text-tertiary py-4 text-center",children:"Waiting for events..."}):o.map($=>h.jsx(Fb,{event:$},$.id))})}),h.jsxs(Bv,{open:m,onClose:()=>y(!1),sourceRef:d,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx("button",{onClick:()=>y(!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:h.jsx(ix,{className:"w-5 h-5"})})}),o.length===0?h.jsx("p",{className:"text-sm text-text-tertiary py-8",children:"No events captured"}):o.map($=>h.jsx(Fb,{event:$,forceExpanded:!0},$.id))]})]})}function XT(){return $e({queryKey:["docs"],queryFn:()=>fe("/docs"),staleTime:5*6e4})}function QT(n){return $e({queryKey:["docs",n],queryFn:()=>fe(`/docs/read?path=${encodeURIComponent(n)}`),enabled:!!n,staleTime:5*6e4})}function WT(){const[n,t]=E.useState([]),[s,i]=E.useState([]),[o,c]=E.useState(null),m=E.useRef(o),y=E.useRef(n),g=E.useRef(s);m.current=o,y.current=n,g.current=s;const u=E.useCallback((w,S)=>{var q;const C=m.current;if(C){const B=((q=S==null?void 0:S.current)==null?void 0:q.scrollTop)??0;t([...y.current,{...C,scrollTop:B}])}i([]),c({path:w,scrollTop:0})},[]),d=E.useCallback(w=>{var B;const S=y.current;if(S.length===0)return;const C=S[S.length-1],q=m.current;if(q){const ie=((B=w==null?void 0:w.current)==null?void 0:B.scrollTop)??0;i([...g.current,{...q,scrollTop:ie}])}t(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{w!=null&&w.current&&(w.current.scrollTop=C.scrollTop)})},[]),b=E.useCallback(w=>{var B;const S=g.current;if(S.length===0)return;const C=S[S.length-1],q=m.current;if(q){const ie=((B=w==null?void 0:w.current)==null?void 0:B.scrollTop)??0;t([...y.current,{...q,scrollTop:ie}])}i(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{w!=null&&w.current&&(w.current.scrollTop=C.scrollTop)})},[]),x=E.useCallback(w=>{var q,B;const S=m.current;if(!S)return;const C=((q=w==null?void 0:w.current)==null?void 0:q.scrollTop)??0;t([...y.current,{...S,scrollTop:C}]),i([]),c({...S,scrollTop:((B=w==null?void 0:w.current)==null?void 0:B.scrollTop)??0})},[]),v=E.useCallback(()=>{t([]),i([]),c(null)},[]);return{current:o,backStack:n,forwardStack:s,navigate:u,goBack:d,goForward:b,pushScrollPosition:x,reset:v}}function ZT(n,t){const[s,i]=n.split("#");let o=s;if(o.startsWith("./")||o.startsWith("../")){const m=((t?t.replace(/[^/]+$/,""):"")+o).split("/"),y=[];for(const g of m)g===".."?y.pop():g&&g!=="."&&y.push(g);o=y.join("/")}return{path:o,anchor:i}}function eC(n){if(!n.startsWith("#docs"))return null;const t=n.slice(1).split(":"),s=t[1]||"README.md",i=t[2]||void 0;return{path:s,anchor:i}}function tC(n){return!n||n==="README.md"?"#docs":`#docs:${n}`}function nC({content:n,currentPath:t,onNavigate:s,onAnchorClick:i}){const o=c=>{var u;const m=c.target,y=m.closest("[data-anchor]");if(y){c.preventDefault(),i();const d=y.dataset.anchor,b=(u=y.closest(".docs-content"))==null?void 0:u.querySelector(`#${CSS.escape(d)}`);b==null||b.scrollIntoView({behavior:"smooth",block:"start"});return}const g=m.closest("[data-doc-link]");if(g){c.preventDefault();const{path:d,anchor:b}=ZT(g.dataset.docLink,t);s(d,b);return}};return h.jsx(Ru,{content:n,className:"docs-content",onClick:o})}function rC(n){const t=[],s=new Map;for(const i of n){const o=i.path.split("/");if(o.length===1){t.push(i);continue}let c=s;for(let m=0;m<o.length-1;m++){const y=o[m];c.has(y)||c.set(y,{label:y,children:[],subdirs:new Map});const g=c.get(y);m===o.length-2?g.children.push(i):c=g.subdirs}}return{topLevel:t,dirs:s}}function sC({docs:n,selected:t,onSelect:s}){const{topLevel:i,dirs:o}=rC(n),c=y=>`block w-full text-left px-3 py-1 text-xs rounded truncate transition-colors ${t===y?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-hover"}`;function m(y,g){return h.jsxs("details",{open:!0,children:[h.jsxs("summary",{className:"flex items-center gap-1.5 px-3 py-1 text-2xs font-semibold uppercase tracking-widest text-text-tertiary cursor-pointer",children:[h.jsx(TS,{className:"w-3 h-3",strokeWidth:1.5}),y.label]}),h.jsxs("div",{className:"pl-2 space-y-0.5",children:[[...y.subdirs.values()].map(u=>m(u)),y.children.map(u=>h.jsx("button",{className:c(u.path),onClick:()=>s(u.path),children:u.title},u.path))]})]},y.label)}return h.jsxs("div",{className:"space-y-0.5",children:[i.map(y=>h.jsx("button",{className:c(y.path),onClick:()=>s(y.path),children:y.title},y.path)),[...o.values()].map(y=>m(y))]})}function iC({open:n,onClose:t}){var ne,V,I;const[s,i]=E.useState(!1),{data:o}=XT(),c=WT(),{data:m,isLoading:y}=QT(((ne=c.current)==null?void 0:ne.path)??null),g=E.useRef(null),[u,d]=E.useState(null);E.useEffect(()=>{u&&(m!=null&&m.content)&&g.current&&requestAnimationFrame(()=>{var Q;const D=(Q=g.current)==null?void 0:Q.querySelector(`#${CSS.escape(u)}`);D==null||D.scrollIntoView({behavior:"smooth",block:"start"}),d(null)})},[u,m]);const b=E.useCallback(()=>{var X;const D=eC(window.location.hash),Q=(D==null?void 0:D.path)??"README.md";((X=c.current)==null?void 0:X.path)!==Q&&c.navigate(Q,g),D!=null&&D.anchor&&d(D.anchor)},[c]),x=E.useRef(!0);E.useEffect(()=>{if(!n||!c.current)return;if(x.current){x.current=!1;return}const D=tC(c.current.path);window.location.hash!==D&&window.history.replaceState(null,"",window.location.pathname+window.location.search+D)},[n,(V=c.current)==null?void 0:V.path]),E.useEffect(()=>{if(!n)return;const D=()=>{window.location.hash.startsWith("#docs")&&b()};return window.addEventListener("hashchange",D),()=>window.removeEventListener("hashchange",D)},[n,b]);const v=E.useCallback((D,Q)=>{Q&&d(Q),c.navigate(D,g)},[c]),w=E.useCallback(D=>{c.navigate(D,g)},[c]),S=E.useCallback(()=>{c.goBack(g)},[c]),C=E.useCallback(()=>{c.goForward(g)},[c]),q=E.useCallback(()=>{c.pushScrollPosition(g)},[c]);if(E.useEffect(()=>{if(n){x.current=!0,b();const D=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(D)}},[n]),!(n||s))return null;const ie=()=>{i(!1),setTimeout(()=>{t(),c.reset()},200)},le=((I=c.current)==null?void 0:I.path)??null,R=c.backStack.length>0,$=c.forwardStack.length>0;return h.jsxs("div",{className:"fixed inset-y-0 right-0 z-50 flex",children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${s&&n?"opacity-100":"opacity-0"}`,onClick:ie}),h.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&&n?"translate-x-0":"translate-x-full"}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:S,disabled:!R,className:`p-0.5 transition-colors ${R?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Back",children:h.jsx(ex,{className:"w-4 h-4"})}),h.jsx("button",{onClick:C,disabled:!$,className:`p-0.5 transition-colors ${$?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Forward",children:h.jsx(hd,{className:"w-4 h-4"})}),h.jsx(CS,{className:"w-4 h-4 text-accent ml-1",strokeWidth:1.5}),h.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Documentation"})]}),h.jsx("button",{onClick:ie,className:"p-1 text-text-tertiary hover:text-text-primary",children:h.jsx(Wt,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[h.jsx("div",{className:"w-48 shrink-0 border-r border-surface-border overflow-y-auto py-2",children:o!=null&&o.docs?h.jsx(sC,{docs:o.docs,selected:le,onSelect:w}):h.jsx("div",{className:"px-3 py-2 text-xs text-text-tertiary",children:"Loading..."})}),h.jsx("div",{ref:g,className:"flex-1 overflow-y-auto px-6 py-4",children:le?y?h.jsxs("div",{className:"animate-pulse space-y-2",children:[h.jsx("div",{className:"h-6 bg-surface-sunken rounded w-48"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}):m!=null&&m.content?h.jsx(nC,{content:m.content,currentPath:le,onNavigate:v,onAnchorClick:q}):h.jsx("p",{className:"text-xs text-text-tertiary",children:"Document not found."}):h.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-tertiary",children:[h.jsx(hd,{className:"w-5 h-5 mb-2"}),h.jsx("p",{className:"text-xs",children:"Select a document"})]})})]})]})]})}function aC(n){if(n.includes("/escalations"))return["escalation","human-queue"]}const Gb=2e3;function oC(n){const s=n.filter(o=>!o.pending).slice(-8);return s.length===0?"":`[Prior conversation]
60
60
  ${s.map(o=>`${o.role==="user"?"User":"Assistant"}: ${o.content}`).join(`
61
61
  `)}
62
62
  [End prior conversation]
63
63
 
64
- `}function oC(n){const t=n.summary,s=n.title;if(t){const i=t.search(/\n\s*\{[\s\S]*"title"\s*:/);return i>0?t.slice(0,i).trim():t}return s||(typeof n=="string"?n:"Query completed.")}const Iv=E.createContext(null);function lC({children:n}){const t=an(),[s,i]=E.useState(!1),[o,c]=E.useState([]),[m,y]=E.useState(null),[g,u]=E.useState({}),d=E.useRef(null),b={page:t.pathname.split("/").filter(Boolean).join("-")||"home",route:t.pathname,params:{},...g,suggestedTags:g.suggestedTags??iC(t.pathname)};E.useEffect(()=>()=>{d.current&&clearInterval(d.current)},[]);const x=E.useCallback(()=>i(q=>!q),[]),v=E.useCallback(q=>{u(q)},[]),w=E.useCallback(()=>{c([]),y(null)},[]),S=E.useCallback(async q=>{var V;const B=new Date().toISOString(),ie={id:`user-${Date.now()}`,role:"user",content:q,timestamp:B},le={id:`pending-${Date.now()}`,role:"assistant",content:"",timestamp:B,pending:!0};c(I=>[...I,ie,le]);const R={...b};(V=R.entities)!=null&&V.yamlContent&&R.entities.yamlContent.length>Vb&&(R.entities={...R.entities,yamlContent:R.entities.yamlContent.slice(0,Vb)+`
65
- ... (truncated)`});const ne=`${aC(o.concat(ie))}${q}`;try{const D=(await fe("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ne,tags:R.suggestedTags,context:R,wait:!1,direct:!0})})).workflow_id;y(D),c(Q=>Q.map(X=>X.id===le.id?{...X,workflowId:D}:X)),d.current&&clearInterval(d.current),d.current=setInterval(async()=>{var Q;try{const X=await fe(`/workflows/${D}/result`),he=(Q=X==null?void 0:X.result)==null?void 0:Q.data;if(he){d.current&&clearInterval(d.current),d.current=null,y(null);const Se=oC(he);let ke;try{ke=(await fe(`/workflow-states/${D}/execution`)).duration_ms}catch{}c(H=>H.map(W=>W.id===le.id?{...W,content:Se,timestamp:new Date().toISOString(),pending:!1,durationMs:ke}:W))}}catch{}},3e3)}catch{c(I=>I.map(D=>D.id===le.id?{...D,content:"Failed to submit query. Please try again.",pending:!1}:D))}},[o,b]),C=E.useCallback(async q=>{const B=o.find(R=>R.id===q);if(!(B!=null&&B.workflowId)||B.compilationStatus==="compiling"||B.compilationStatus==="done")return;const ie=o.indexOf(B),le=o.slice(0,ie).reverse().find(R=>R.role==="user");if(le){c(R=>R.map($=>$.id===q?{...$,compilationStatus:"compiling"}:$));try{const R=await fe("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:le.content,summary:B.content})}),$=await fe("/yaml-workflows",{method:"POST",body:JSON.stringify({workflow_id:B.workflowId,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:R.tool_name,description:R.description,tags:R.tags,app_id:""})});await fe(`/yaml-workflows/${$.id}/deploy`,{method:"POST"}),c(ne=>ne.map(V=>V.id===q?{...V,compilationStatus:"done"}:V))}catch(R){const $=R instanceof Error?R.message:"Compilation failed";c(ne=>ne.map(V=>V.id===q?{...V,compilationStatus:"error",compilationError:$}:V))}}},[o]);return h.jsx(Iv.Provider,{value:{helpOpen:s,setHelpOpen:i,toggleHelp:x,messages:o,sendMessage:S,pageContext:b,setPageContext:v,activeWorkflowId:m,clearMessages:w,compileMessage:C},children:n})}function $v(){const n=E.useContext(Iv);if(!n)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return n}function cC(){const{helpOpen:n,toggleHelp:t}=$v();return h.jsx("button",{onClick:t,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":n?"Close help":"Ask for help",children:n?h.jsx(Wt,{className:"w-5 h-5 text-text-tertiary",strokeWidth:1.5}):h.jsx("span",{role:"img","aria-label":"Help",className:"logo-mark w-8 h-8 -rotate-[120deg]",style:{"--logo-url":`url(${Ht}/logo512.png)`}})})}function uC({ms:n,className:t=""}){const s=Jj(n),i=E.useMemo(()=>n==null?[]:[{label:"ms",value:String(n)},{label:"sec",value:`${(n/1e3).toFixed(3)}s`},{label:"text",value:s}],[n,s]);return n==null?h.jsx("span",{className:`text-xs text-text-tertiary ${t}`,children:"--"}):h.jsx(cv,{options:i,children:h.jsx("span",{className:`text-xs text-text-tertiary ${t}`,children:s})})}const fC=["sm","md","lg","full"],Yb={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"},Kb={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function hC({which:n}){const t="stroke-current";switch(n){case"sm":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"5",y:"5",width:"7",height:"7",rx:"1.5",className:t,strokeWidth:"1.5"})});case"md":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"3",y:"3",width:"9",height:"9",rx:"1.5",className:t,strokeWidth:"1.5"})});case"lg":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"1.5",y:"1.5",width:"11",height:"11",rx:"1.5",className:t,strokeWidth:"1.5"})});case"full":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"0.75",y:"0.75",width:"12.5",height:"12.5",rx:"1.5",className:t,strokeWidth:"1.5"})})}}function dC({msg:n}){const[t,s]=E.useState(0);E.useEffect(()=>{const m=new Date(n.timestamp).getTime(),y=()=>s(Math.floor((Date.now()-m)/1e3));y();const g=setInterval(y,1e3);return()=>clearInterval(g)},[n.timestamp]);const i=Math.floor(t/60),o=t%60,c=i>0?`${i}m ${o}s`:`${o}s`;return h.jsxs("span",{className:"inline-flex flex-col gap-1.5",children:[h.jsxs("span",{className:"inline-flex items-center gap-1",children:[h.jsx("span",{className:"text-text-tertiary",children:"Thinking"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:150ms]"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:300ms]"}),h.jsx("span",{className:"text-text-muted ml-1 tabular-nums",children:c})]}),n.workflowId&&h.jsxs(Cr,{to:`/workflows/executions/${n.workflowId}`,className:"inline-flex items-center gap-1 text-2xs text-accent/70 hover:text-accent transition-colors",children:[h.jsx(em,{className:"w-2.5 h-2.5",strokeWidth:1.5}),"watch execution"]})]})}function mC({msg:n,compileMessage:t}){const s=n.role==="assistant";return h.jsxs("div",{className:`flex items-center gap-1.5 ${s?"justify-start":"justify-end"}`,children:[h.jsx(uv,{date:n.timestamp,format:"time",className:"!text-2xs text-text-muted/50"}),n.durationMs!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-muted/30 text-2xs",children:"·"}),h.jsx(uC,{ms:n.durationMs,className:"!text-2xs text-text-muted/50"})]}),n.workflowId&&h.jsx(Cr,{to:`/workflows/executions/${n.workflowId}`,className:"text-text-muted/40 hover:text-accent transition-colors",title:"View workflow execution",children:h.jsx(em,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),s&&n.workflowId&&!n.pending&&h.jsx("button",{onClick:()=>t(n.id),disabled:n.compilationStatus==="compiling"||n.compilationStatus==="done",className:"transition-colors",title:n.compilationStatus==="done"?"Compiled — future queries will match this pipeline":n.compilationStatus==="error"?n.compilationError??"Compilation failed":n.compilationStatus==="compiling"?"Compiling...":"Compile to fast pipeline",children:h.jsx(RS,{className:`w-2.5 h-2.5 ${n.compilationStatus==="done"?"text-status-success":n.compilationStatus==="error"?"text-status-error":n.compilationStatus==="compiling"?"text-accent/40 animate-pulse":"text-text-muted/40 hover:text-accent"}`,strokeWidth:1.5})})]})}function pC(){const{helpOpen:n,setHelpOpen:t,messages:s,sendMessage:i,pageContext:o,activeWorkflowId:c,clearMessages:m,compileMessage:y}=$v(),[g,u]=E.useState(""),[d,b]=E.useState("md"),[x,v]=E.useState(!0),w=E.useRef(null),S=E.useRef(null);if(E.useEffect(()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},[s]),E.useEffect(()=>{n&&S.current&&S.current.focus()},[n]),E.useEffect(()=>{if(!n)return;const R=$=>{$.key==="Escape"&&(d==="full"?b("lg"):d==="lg"?b("md"):d==="md"?b("sm"):t(!1))};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[n,d,t]),!n)return null;const C=()=>{const R=g.trim();!R||c||(i(R),u(""),S.current&&(S.current.style.height="auto"))},q=R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),C())},B=d==="full",ie=o.page.replace(/-/g," "),le=B?{}:{bottom:"108px"};return h.jsxs("div",{className:`fixed z-[45] flex flex-col border border-surface-border rounded-lg overflow-hidden transition-all duration-300 ${B?Yb.full:`right-6 ${Yb[d]}`} ${x?"bg-surface-raised shadow-xl":"bg-surface-raised/[0.03] shadow-lg shadow-black/5"}`,style:le,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),children:[h.jsxs("div",{className:`flex items-center justify-between px-4 py-2.5 border-b border-surface-border shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"text-xs font-medium text-text-primary truncate",children:"Help Assistant"}),h.jsx("p",{className:"text-2xs text-text-tertiary truncate",children:ie})]}),h.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[h.jsx("div",{className:"flex items-center gap-0.5 border border-surface-border rounded p-0.5",role:"radiogroup","aria-label":"Panel size",children:fC.map(R=>h.jsx("button",{onClick:()=>b(R),className:`p-1 rounded transition-colors ${R===d?"bg-accent/15 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"}`,role:"radio","aria-checked":R===d,"aria-label":Kb[R],title:Kb[R],children:h.jsx(hC,{which:R})},R))}),s.length>0&&h.jsx("button",{onClick:m,className:"p-1 text-text-tertiary hover:text-text-secondary transition-colors","aria-label":"Clear conversation",title:"Clear conversation",children:h.jsx(DS,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),h.jsx("button",{onClick:()=>t(!1),className:"p-1 text-text-tertiary hover:text-text-primary transition-colors","aria-label":"Close",title:"Close",children:h.jsx(Wt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})]}),h.jsxs("div",{ref:w,className:`flex-1 overflow-y-auto px-4 py-3 space-y-3 min-h-[120px] transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary text-center py-6",children:"Ask anything about what you're viewing."}),s.map(R=>h.jsxs("div",{className:`text-xs leading-relaxed ${R.role==="user"?"text-right":"text-left"}`,children:[h.jsx("div",{className:`inline-block max-w-[85%] px-3 py-2 rounded-md whitespace-pre-wrap ${R.role==="user"?"bg-accent/10 text-text-primary":"bg-surface-sunken text-text-secondary"}`,children:R.pending?h.jsx(dC,{msg:R}):R.role==="assistant"?h.jsx(Ru,{content:R.content}):R.content}),!R.pending&&h.jsx("div",{className:"mt-0.5",children:h.jsx(mC,{msg:R,compileMessage:y})})]},R.id))]}),h.jsxs("div",{className:`border-t border-surface-border px-3 py-2.5 flex gap-2 shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsx("textarea",{ref:S,value:g,onChange:R=>{u(R.target.value);const $=R.target;$.style.height="auto",$.style.height=`${Math.min($.scrollHeight,120)}px`},onKeyDown:q,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:!!c}),h.jsx("button",{onClick:C,disabled:!g.trim()||!!c,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:h.jsx(LS,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}const yC=6e3,gC="scan";function bC(){const{lastResult:n}=qm(),{open:t,ownerKey:s}=jm(),[i,o]=E.useState(null);return E.useEffect(()=>{if(!n)return;const c=setTimeout(()=>o(n.at),yC);return()=>clearTimeout(c)},[n]),!n||n.navigated||i===n.at||t&&s===gC||n.source===jo.TOOLBAR?null:h.jsx("div",{role:"status",className:"fixed bottom-14 right-4 z-[60] w-80 max-w-[calc(100vw-2rem)] bg-surface-raised border border-surface-border shadow-lg rounded-md animate-page-in",children:h.jsxs("div",{className:"flex items-start gap-2.5 px-3.5 py-3",children:[h.jsx(No,{className:"w-4 h-4 mt-0.5 text-accent-muted shrink-0",strokeWidth:1.5}),h.jsx("div",{className:"flex-1 min-w-0",children:h.jsx(Bm,{result:n})}),h.jsx("button",{type:"button",onClick:()=>o(n.at),className:"text-text-tertiary hover:text-text-primary shrink-0",title:"Dismiss",children:h.jsx(Wt,{className:"w-3.5 h-3.5"})})]})})}const Hv="lt-announcement-dismissed:";function xC(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function vC(n){try{return localStorage.getItem(`${Hv}${n}`)==="1"}catch{return!1}}function _C(){const{isAuthenticated:n,userRoleNames:t}=Pt(),{data:s}=nv(n),i=He(),[o,c]=E.useState(null),[m,y]=E.useState(0);On(qA,()=>{i.invalidateQueries({queryKey:["announcements"]})});const g=Date.now(),u=((s==null?void 0:s.announcements)??[]).filter(b=>!vC(b.id)&&new Date(b.expires_at).getTime()>g&&(b.roles.length===0||b.roles.some(x=>t.includes(x))));if(E.useEffect(()=>{const b=((s==null?void 0:s.announcements)??[]).map(v=>new Date(v.expires_at).getTime()-Date.now()).filter(v=>v>0);if(b.length===0)return;const x=setTimeout(()=>y(v=>v+1),Math.min(...b)+250);return()=>clearTimeout(x)},[s,m]),u.length===0)return null;const d=b=>{try{localStorage.setItem(`${Hv}${b}`,"1")}catch{}y(x=>x+1)};return h.jsx("div",{"data-testid":"announcement-banner",className:"relative z-40",children:u.map(b=>{const x=o===b.id,v=b.title??b.body.split(`
66
- `)[0];return h.jsxs("div",{className:"border-b border-accent/25 bg-accent/10",children:[h.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5",children:[h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-accent",children:"Notice"}),h.jsxs("button",{type:"button",onClick:()=>c(x?null:b.id),className:"flex items-center gap-1.5 text-xs text-text-primary hover:text-accent transition-colors min-w-0",children:[h.jsx("span",{className:"truncate",children:v}),x?h.jsx(ox,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}):h.jsx(Zd,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{type:"button",onClick:()=>d(b.id),className:"icon-link",title:"Dismiss","aria-label":`Dismiss ${v}`,children:h.jsx(Wt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]}),x&&h.jsx("div",{className:"px-4 pb-3 text-sm text-text-secondary max-w-measure",children:h.jsx(Ru,{content:xC(b.body)})})]},b.id)})})}function wC(){var $;const{isBuilder:n,isOps:t,viewAs:s}=Yx(),{canSeePaceBoard:i}=Kx();cA();const{data:o}=Zn(),c=Hx(),m=c!==null?c:!!(($=o==null?void 0:o.ai)!=null&&$.enabled),{collapsed:y,toggle:g}=Om(),[u,d]=E.useState(!1),[b,x]=E.useState(!1),[v,w]=E.useState(!1),[S,C]=E.useState(()=>window.location.hash.startsWith("#docs")),q=an(),B=E.useRef(null),{kiosk:ie,homePath:le}=Sm(),R=ie||_A(q.pathname);return E.useEffect(()=>{const ne=B.current;ne&&(ne.classList.remove("animate-page-in"),ne.offsetWidth,ne.classList.add("animate-page-in"))},[q.pathname]),E.useEffect(()=>{const ne=()=>{window.location.hash.startsWith("#docs")&&C(!0)};return window.addEventListener("hashchange",ne),()=>window.removeEventListener("hashchange",ne)},[]),ie&&le&&!EA(q.pathname)?h.jsx(wn,{to:le,replace:!0}):h.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[h.jsx(nT,{onToggleEventFeed:()=>d(ne=>!ne),onToggleDocs:()=>C(ne=>!ne),onToggleNav:R?void 0:()=>x(ne=>!ne)}),h.jsx(_C,{}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!R&&h.jsxs("aside",{className:`${y?"w-16":"w-60"} shrink-0 bg-surface-raised border-r border-surface-border hidden lg:flex flex-col transition-[width] duration-200 ease-out overflow-hidden relative z-20`,children:[h.jsx("nav",{className:"flex-1 px-3 pt-[36px] pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:h.jsx(qv,{aiEnabled:m,isBuilder:n,isOps:t,viewAs:s,canSeePaceBoard:i})}),h.jsx("button",{onClick:g,className:`shrink-0 py-3 text-text-tertiary hover:text-text-secondary transition-colors duration-150 ${y?"flex justify-center":"flex items-center px-7"}`,"aria-label":y?"Expand sidebar":"Collapse sidebar",children:y?h.jsx(qS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):h.jsx(BS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!y&&(o==null?void 0:o.environment)&&h.jsxs("div",{className:"shrink-0 px-5 pb-3 text-2xs leading-tight text-text-tertiary whitespace-nowrap overflow-hidden text-ellipsis",title:`long-tail v${o.environment.longTailVersion} · HotMesh v${o.environment.hotmeshVersion} · Node ${o.environment.nodeVersion} · ${o.environment.nodeEnv}`,children:["long-tail v",o.environment.longTailVersion,h.jsx("span",{className:"mx-1 text-surface-border",children:"·"}),"HotMesh v",o.environment.hotmeshVersion]})]}),h.jsx("main",{className:"flex-1 min-w-0 overflow-y-auto",children:h.jsx("div",{ref:B,className:"w-full px-page-x py-8 pb-16 animate-page-in h-full flex flex-col @container",children:h.jsx(Ws,{})})}),h.jsx(SC,{})]}),!R&&h.jsx(NT,{open:b,onClose:()=>x(!1),aiEnabled:m,isBuilder:n,isOps:t,viewAs:s,canSeePaceBoard:i}),h.jsx(KT,{open:u,onToggle:()=>d(ne=>!ne),configOpen:v,onToggleConfig:()=>w(ne=>!ne)}),h.jsx(sC,{open:S,onClose:()=>{C(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),m&&h.jsx(cC,{}),m&&h.jsx(pC,{}),h.jsx(bC,{})]})}function SC(){const{node:n,width:t,open:s}=jm();return h.jsx(NA,{open:s,width:t,className:"border-l border-surface-border bg-surface-raised",children:n})}function EC(){const{isAuthenticated:n}=Pt(),t=an();return n?h.jsx(AA,{children:h.jsx(kA,{children:h.jsx(lC,{children:h.jsx(ck,{children:h.jsx(Ck,{children:h.jsx(wC,{})})})})})}):h.jsx(wn,{to:"/login",state:{from:t.pathname},replace:!0})}function Fv({provider:n,className:t="w-5 h-5"}){switch(n){case"google":return h.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor",children:[h.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"}),h.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"}),h.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"}),h.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 h.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor",children:h.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 h.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("path",{d:"M3 3h8.5v8.5H3z",fill:"#F25022"}),h.jsx("path",{d:"M12.5 3H21v8.5h-8.5z",fill:"#7FBA00"}),h.jsx("path",{d:"M3 12.5h8.5V21H3z",fill:"#00A4EF"}),h.jsx("path",{d:"M12.5 12.5H21V21h-8.5z",fill:"#FFB900"})]});case"anthropic":return h.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor",children:h.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 h.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("path",{d:"M12 8v4l3 3"})]})}}async function OC(){return fe("/auth/oauth/providers")}async function AC(n,t){const s=t?`?label=${encodeURIComponent(t)}`:"";return fe(`/auth/oauth/connections/${n}${s}`,{method:"DELETE"})}function fM(){return $e({queryKey:["oauth-connections"],queryFn:()=>fe("/auth/oauth/connections")})}function hM(){const n=He();return Ve({mutationFn:({provider:t,label:s})=>AC(t,s),onSuccess:()=>{n.invalidateQueries({queryKey:["oauth-connections"]})}})}function jC(){var ne;const{login:n,isAuthenticated:t}=Pt(),s=ra(),i=an(),o=new URLSearchParams(i.search),c=o.get("token"),m=o.get("error"),y=((ne=i.state)==null?void 0:ne.from)??o.get("returnTo")??"/",g=E.useRef(!1);c&&!g.current&&(g.current=!0,n(c,void 0,{displayName:o.get("displayName"),username:o.get("username")}));const[u,d]=E.useState(""),[b,x]=E.useState(""),[v,w]=E.useState(m||""),[S,C]=E.useState(!1),[q,B]=E.useState(!!c),[ie,le]=E.useState([]),R=E.useRef(!1);if(E.useEffect(()=>{c||R.current||(R.current=!0,(async()=>{var V,I,D,Q;try{const X=await nm().catch(()=>null);if(!((V=X==null?void 0:X.auth)!=null&&V.sso))return;const he=await fetch(`${Ht}/api/auth/sso`,{method:"POST"});if(!he.ok){w("Host authentication required — please log in to your organization first");return}const Se=await he.json();Se.token&&((I=X.auth)!=null&&I.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",X.auth.ssoLogoutUrl),B(!0),n(Se.token,void 0,{displayName:(D=Se.user)==null?void 0:D.display_name,username:(Q=Se.user)==null?void 0:Q.external_id}))}catch{}})())},[]),E.useEffect(()=>{c||OC().then(le).catch(()=>{})},[]),E.useEffect(()=>{if(!q)return;const V=setTimeout(()=>s(y,{replace:!0}),1500);return()=>clearTimeout(V)},[q]),t&&!q)return h.jsx(wn,{to:y,replace:!0});const $=async V=>{var I,D;if(V.preventDefault(),w(""),!u.trim()||!b){w("Username and password are required");return}C(!0);try{const Q=await fetch(`${Ht}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:u.trim(),password:b})}),X=await Q.json();if(!Q.ok){w(X.error||"Login failed");return}B(!0),n(X.token,{username:u.trim(),password:b},{displayName:(I=X.user)==null?void 0:I.display_name,username:(D=X.user)==null?void 0:D.external_id})}catch{w("Unable to connect to server")}finally{C(!1)}};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center overflow-hidden",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:`mb-10 transition-all duration-[1500ms] ease-in ${q?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:h.jsx(Tm,{size:"lg",hideLabel:q})}),h.jsxs("form",{onSubmit:$,className:`space-y-5 transition-opacity duration-300 ${q?"opacity-0":""}`,children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-text-secondary mb-2",children:"Username"}),h.jsx("input",{id:"username",type:"text",value:u,onChange:V=>d(V.target.value),className:"input",placeholder:"Enter your username",autoFocus:!q,autoComplete:"username"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-text-secondary mb-2",children:"Password"}),h.jsx("input",{id:"password",type:"password",value:b,onChange:V=>x(V.target.value),className:"input",placeholder:"Enter your password",autoComplete:"current-password"})]}),v&&h.jsx("p",{className:"text-sm text-status-error",children:v}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:S||q,children:S?"Signing in...":"Sign In"}),ie.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[h.jsx("div",{className:"flex-1 h-px bg-border"}),h.jsx("span",{className:"text-xs text-text-tertiary",children:"or continue with"}),h.jsx("div",{className:"flex-1 h-px bg-border"})]}),h.jsx("div",{className:"space-y-2",children:ie.filter(V=>V.provider!=="anthropic").map(V=>h.jsxs("a",{href:`${Ht}/api/auth/oauth/${V.provider}?returnTo=${encodeURIComponent(y)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[h.jsx(Fv,{provider:V.provider}),"Sign in with ",V.name]},V.provider))})]})]})]})})}function Jb(){const{isAuthenticated:n}=Pt(),t=ra(),s=an(),i=new URLSearchParams(s.search),o=i.get("state")||"";E.useEffect(()=>{n||t(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[n]);const[c,m]=E.useState(""),[y,g]=E.useState(i.get("label")||"default"),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=c.trim().startsWith("sk-ant-oat"),w=c.trim().startsWith("sk-ant-api"),S=C=>{C.preventDefault();const q=c.trim();if(!q){d("A token or API key is required");return}if(!q.startsWith("sk-ant-")){d('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}x(!0),d("");const B=`${Ht}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(q)}&state=${encodeURIComponent(o)}`;window.location.href=B};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:"mb-10",children:h.jsx(Tm,{size:"lg"})}),h.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[h.jsx(Fv,{provider:"anthropic",className:"w-6 h-6"}),h.jsx("h2",{className:"heading-3",children:"Connect Anthropic"})]}),h.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."}),h.jsxs("form",{onSubmit:S,className:"space-y-5",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-text-secondary mb-2",children:"OAuth Token or API Key"}),h.jsx("input",{id:"token",type:"password",value:c,onChange:C=>m(C.target.value),className:"input",placeholder:"sk-ant-oat01-... or sk-ant-api03-...",autoFocus:!0,autoComplete:"off"}),v&&h.jsx("p",{className:"text-xs text-status-success mt-1",children:"OAuth token detected — uses your Claude subscription (flat rate)"}),w&&h.jsx("p",{className:"text-xs text-status-warning mt-1",children:"API key detected — billed per-token from your Anthropic API account"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"label",className:"block text-sm font-medium text-text-secondary mb-2",children:"Label"}),h.jsx("input",{id:"label",type:"text",value:y,onChange:C=>g(C.target.value.replace(/\s+/g,"-").toLowerCase()),className:"input",placeholder:"default",autoComplete:"off"}),h.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").'})]}),u&&h.jsx("p",{className:"text-sm text-status-error",children:u}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:b,children:b?"Validating...":"Connect"}),h.jsx("a",{href:"/",className:"block text-center text-sm text-text-tertiary hover:text-text-secondary",children:"Cancel"})]}),h.jsxs("div",{className:"mt-6 space-y-3 text-xs text-text-tertiary",children:[h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Recommended:"})," ","Run"," ",h.jsx("code",{className:"px-1 py-0.5 bg-surface-sunken rounded text-2xs",children:"claude setup-token"})," ","in your terminal to generate an OAuth token that uses your subscription."]}),h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Alternative:"})," ","Use an API key from"," ",h.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 Wc({roleTypes:n,roleNames:t,redirectTo:s="/"}){const{isSuperAdmin:i,hasRole:o,hasRoleType:c}=Pt();return i?h.jsx(Ws,{}):n&&n.some(m=>c(m))?h.jsx(Ws,{}):t&&t.some(m=>o(m))?h.jsx(Ws,{}):h.jsx(wn,{to:s,replace:!0})}function kC(){const{data:n,isSuccess:t}=Lv();return t&&n.length===0?h.jsx(wn,{to:"/",replace:!0}):h.jsx(Ws,{})}function NC({redirectTo:n="/"}){var i;const{data:t,isLoading:s}=Zn();return s||!t?null:(i=t.ai)!=null&&i.enabled?h.jsx(Ws,{}):h.jsx(wn,{to:n,replace:!0})}function TC({flag:n,redirectTo:t="/"}){var o;const{data:s,isLoading:i}=Zn();return i||!s?null:((o=s.features)==null?void 0:o[n])===!1?h.jsx(wn,{to:t,replace:!0}):h.jsx(Ws,{})}const CC=E.lazy(()=>je(()=>import("./ProcessesListPage-Cbn9cter.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),import.meta.url).then(n=>({default:n.ProcessesListPage}))),MC=E.lazy(()=>je(()=>import("./ProcessDetailPage-Dz_jY4Yt.js"),__vite__mapDeps([17,1,2,18,13,19,16,10,4,20,21]),import.meta.url).then(n=>({default:n.ProcessDetailPage}))),RC=E.lazy(()=>je(()=>import("./McpOverview-C2JoNoDA.js"),__vite__mapDeps([22,1,23,24,25,26,14,13,27,4]),import.meta.url).then(n=>({default:n.McpOverview}))),DC=E.lazy(()=>je(()=>import("./McpRunsPage-CnYtfGhf.js"),__vite__mapDeps([28,1,24,25,3,4,29,26,6,7,8,9,16,13,30,14,12,11,15,31]),import.meta.url).then(n=>({default:n.McpRunsPage}))),LC=E.lazy(()=>je(()=>import("./McpRunDetailPage-DtKoJq6J.js"),__vite__mapDeps([32,1,24,14,13,33,34,12,35,19,4,36,15,37]),import.meta.url).then(n=>({default:n.McpRunDetailPage}))),qC=E.lazy(()=>je(()=>import("./McpQueryPage-U_wNXow2.js"),__vite__mapDeps([38,1,14,13,7,8,9,12,11,15,6,10,30,16,31,3,4,39]),import.meta.url).then(n=>({default:n.McpQueryPage}))),BC=E.lazy(()=>je(()=>import("./McpQueryDetailPage-C_nih0w-.js"),__vite__mapDeps([40,1,14,13,19,39,4,25,41,42,24,2,43,44,45,46,47,48,37,49,35,36]),import.meta.url).then(n=>({default:n.McpQueryDetailPage}))),PC=E.lazy(()=>je(()=>import("./EscalationsOverview-C2XoguaA.js"),__vite__mapDeps([50,1,14,13,27,4]),import.meta.url).then(n=>({default:n.EscalationsOverview}))),UC=E.lazy(()=>je(()=>import("./AvailableEscalationsPage-C2_5aEFW.js"),__vite__mapDeps([51,1,4,52,13,53,54,5,55,56,57,7,8,9,19,21,11,58,59,12,60,20,16,61,3,31]),import.meta.url).then(n=>({default:n.AvailableEscalationsPage}))),zC=E.lazy(()=>je(()=>import("./OperatorDashboard-fVuLn2D5.js"),__vite__mapDeps([62,1,3,4,5,6,52,7,8,9,11,31,58,59,13,12,60,20,16,21,61,57,19,55,15]),import.meta.url).then(n=>({default:n.OperatorDashboard}))),IC=E.lazy(()=>je(()=>import("./index-WSm8bgE7.js"),__vite__mapDeps([63,1,53,54,5,64,13,57,7,8,9,19,21,11,4,16,14,15,20,61,37,65]),import.meta.url).then(n=>({default:n.EscalationDetailPage}))),$C=E.lazy(()=>je(()=>import("./WorkflowsOverview-CJQbyOj-.js"),__vite__mapDeps([66,1,14,13,27,4]),import.meta.url).then(n=>({default:n.WorkflowsOverview}))),HC=E.lazy(()=>je(()=>import("./index-BmNAVd4s.js"),__vite__mapDeps([67,1,14,13,12,16,64,57,7,8,9,19,21,11,4,54,68,46,47]),import.meta.url).then(n=>({default:n.StartWorkflowPage}))),FC=E.lazy(()=>je(()=>import("./index-BmNAVd4s.js"),__vite__mapDeps([67,1,14,13,12,16,64,57,7,8,9,19,21,11,4,54,68,46,47]),import.meta.url).then(n=>({default:n.DurableInvokePage}))),GC=E.lazy(()=>je(()=>import("./WorkflowsDashboard-Hc87TRgD.js"),__vite__mapDeps([69,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"durable"})}))),VC=E.lazy(()=>je(()=>import("./WorkflowsDashboard-Hc87TRgD.js"),__vite__mapDeps([69,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"all"})}))),YC=E.lazy(()=>je(()=>import("./YamlWorkflowsPage-BMMg0Id6.js"),__vite__mapDeps([70,1,25,3,4,14,13,12,8,48,68,19]),import.meta.url).then(n=>({default:n.YamlWorkflowsPage}))),KC=E.lazy(()=>je(()=>import("./GraphInvokePage-CUvoPzsW.js"),__vite__mapDeps([71,1,25,14,13,43,45,46,47,44,4,48,68]),import.meta.url).then(n=>({default:n.GraphInvokePage}))),JC=E.lazy(()=>je(()=>import("./YamlWorkflowDetailPage-BMeED677.js"),__vite__mapDeps([72,1,25,19,68,13,4]),import.meta.url).then(n=>({default:n.YamlWorkflowDetailPage}))),XC=E.lazy(()=>je(()=>import("./TasksListPage-BNGM74yT.js"),__vite__mapDeps([73,1,2,3,4,7,8,9,19,60,49,11,12,13,14,16]),import.meta.url).then(n=>({default:n.TasksListPage}))),QC=E.lazy(()=>je(()=>import("./TaskDetailPage-BPsZ1bK_.js"),__vite__mapDeps([74,1,2,19,60,14,13,4]),import.meta.url).then(n=>({default:n.TaskDetailPage}))),Xb=E.lazy(()=>je(()=>import("./WorkflowExecutionPage-B5WJOsee.js"),__vite__mapDeps([75,1,34,12,13,35,19,4,36,2,14,33,15,37]),import.meta.url).then(n=>({default:n.WorkflowExecutionPage}))),WC=E.lazy(()=>je(()=>import("./AdminDashboard-DBW12qQt.js"),__vite__mapDeps([76,1,2,23,18,13,4]),import.meta.url).then(n=>({default:n.AdminDashboard}))),ZC=E.lazy(()=>je(()=>import("./index-BRGTmoYY.js"),__vite__mapDeps([77,1,7,8,9,12,13,31,3,4,14,78,16]),import.meta.url).then(n=>({default:n.WorkersPage}))),e3=E.lazy(()=>je(()=>import("./index-Bd6-KmBE.js"),__vite__mapDeps([79,1,12,13,80,20,16,14,4,46,47,68,64,57,7,8,9,19,21,11,54]),import.meta.url).then(n=>({default:n.WorkflowConfigsPage}))),Qb=E.lazy(()=>je(()=>import("./index-Bd6-KmBE.js"),__vite__mapDeps([79,1,12,13,80,20,16,14,4,46,47,68,64,57,7,8,9,19,21,11,54]),import.meta.url).then(n=>({default:n.WorkflowConfigDetailPage}))),t3=E.lazy(()=>je(()=>import("./index-BiVce3n0.js"),__vite__mapDeps([81,1,23,8,80,14,13,12,11,3,4,82,45,46,47,48,44,31,19]),import.meta.url).then(n=>({default:n.McpServersPage}))),Wb=E.lazy(()=>je(()=>import("./index-eDm6cz0F.js"),__vite__mapDeps([83,1,23,14,13,41,4]),import.meta.url).then(n=>({default:n.McpServerDetailPage}))),n3=E.lazy(()=>je(()=>import("./index-B3veJ698.js"),__vite__mapDeps([84,1,3,4,7,8,9,11,12,13,80,31,14,20,47,49,85,86,33]),import.meta.url).then(n=>({default:n.UsersPage}))),r3=E.lazy(()=>je(()=>import("./RolesPage-NwmMvZFa.js"),__vite__mapDeps([87,1,12,13,14,20,4]),import.meta.url).then(n=>({default:n.RolesPage}))),s3=E.lazy(()=>je(()=>import("./RoleDetailPage-owPi6gI9.js"),__vite__mapDeps([88,1,89,80,13,4]),import.meta.url).then(n=>({default:n.RoleDetailPage}))),i3=E.lazy(()=>je(()=>import("./PersonasPage-BL1FwLmv.js"),__vite__mapDeps([90,1,85,12,13,14,20,4,5]),import.meta.url).then(n=>({default:n.PersonasPage}))),a3=E.lazy(()=>je(()=>import("./PersonaDetailPage-C-4o8lPw.js"),__vite__mapDeps([91,1,85,20,13,86,89,80,4]),import.meta.url).then(n=>({default:n.PersonaDetailPage}))),o3=E.lazy(()=>je(()=>import("./EscalationSchemaPage-BX0tx-PM.js"),__vite__mapDeps([92,1,64,13,57,7,8,9,19,21,11,4,54,16]),import.meta.url).then(n=>({default:n.EscalationSchemaPage}))),l3=E.lazy(()=>je(()=>import("./PortalPage-tJG5sgb1.js"),__vite__mapDeps([93,1,9,56,13,57,7,8,19,21,11,4,58,59,12,60,20,16,61]),import.meta.url).then(n=>({default:n.PortalPage}))),c3=E.lazy(()=>je(()=>import("./EscalationListSchemaPage-VfCn6WDb.js"),__vite__mapDeps([94,1,13,4]),import.meta.url).then(n=>({default:n.EscalationListSchemaPage}))),u3=E.lazy(()=>je(()=>import("./ScanCodesPage-CUv_8ic6.js"),__vite__mapDeps([95,1,96,14,13,4]),import.meta.url).then(n=>({default:n.ScanCodesPage}))),f3=E.lazy(()=>je(()=>import("./ScanSchemeDetailPage-YHqbu7oK.js"),__vite__mapDeps([97,1,80,14,13,96,4]),import.meta.url).then(n=>({default:n.ScanSchemeDetailPage}))),h3=E.lazy(()=>je(()=>import("./ScanStationPage-B275l6r_.js"),__vite__mapDeps([98,1,13,65,4]),import.meta.url).then(n=>({default:n.ScanStationPage}))),d3=E.lazy(()=>je(()=>import("./index-MDD4JYtu.js"),__vite__mapDeps([99,1,14,13,54,4]),import.meta.url).then(n=>({default:n.MaintenancePage}))),Zb=E.lazy(()=>je(()=>import("./OperationsPage-C7hupIer.js").then(n=>n.O),__vite__mapDeps([100,1,59,13,4,14,9]),import.meta.url).then(n=>({default:n.OperationsPage}))),m3=E.lazy(()=>je(()=>import("./index-DkcI4V_H.js"),__vite__mapDeps([101,1,18,13,12,3,4,29,26,42,78,7,8,9,31]),import.meta.url).then(n=>({default:n.ControlPlanePage}))),p3=E.lazy(()=>je(()=>import("./index-Bq5XNEzD.js"),__vite__mapDeps([102,1,36,13,3,4,29,26,6,7,8,9,11,12,14,15]),import.meta.url).then(n=>({default:n.StreamMessagesPage}))),y3=E.lazy(()=>je(()=>import("./CredentialsPage-twd2xCOW.js"),__vite__mapDeps([103,1,14,13,49,80,4]),import.meta.url).then(n=>({default:n.CredentialsPage}))),g3=E.lazy(()=>je(()=>import("./index-DPStdq4T.js"),__vite__mapDeps([104,1,4,14,13,12,15,6,8,105,49]),import.meta.url).then(n=>({default:n.FilesPage}))),b3=E.lazy(()=>je(()=>import("./index-Dyotfa_k.js"),__vite__mapDeps([106,1,14,13,12,15,11,8,105,49,107,41,4]),import.meta.url).then(n=>({default:n.KnowledgePage}))),x3=E.lazy(()=>je(()=>import("./HomePage-BP7v9GLJ.js"),__vite__mapDeps([108,1,24,26,20,13,16,15,100,59,4,14,9,52]),import.meta.url).then(n=>({default:n.HomePage}))),v3=E.lazy(()=>je(()=>import("./AgentsPage-BA_ai9HJ.js"),__vite__mapDeps([109,1,110,3,4,6,7,8,9,11,12,13,14,15]),import.meta.url).then(n=>({default:n.AgentsPage}))),_3=E.lazy(()=>je(()=>import("./AgentDetailPage-D1scIbz-.js"),__vite__mapDeps([111,1,110,112,13,16,4]),import.meta.url).then(n=>({default:n.AgentDetailPage}))),ex=E.lazy(()=>je(()=>import("./AgentConfigPage-CmHv8U9M.js"),__vite__mapDeps([113,1,110,112,13,14,107,45,46,47,25,114,115,16,4]),import.meta.url).then(n=>({default:n.AgentConfigPage}))),w3=E.lazy(()=>je(()=>import("./CapabilitiesPage-CvOX6vAc.js"),__vite__mapDeps([116,1,114,82,23,45,46,47,13,48,4,44,14,12]),import.meta.url).then(n=>({default:n.CapabilitiesPage}))),S3=E.lazy(()=>je(()=>import("./TopicsPage-DQV0WxG6.js"),__vite__mapDeps([117,1,115,14,13,12,4]),import.meta.url).then(n=>({default:n.TopicsPage}))),E3=E.lazy(()=>je(()=>import("./TopicDetailPage-DJKg8lb7.js"),__vite__mapDeps([118,1,115,15,13,4]),import.meta.url).then(n=>({default:n.TopicDetailPage})));function O3(){return h.jsxs("div",{className:"animate-pulse space-y-4",children:[h.jsx("div",{className:"h-8 bg-surface-sunken rounded w-48"}),h.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]})}function Ee({children:n}){return h.jsx(E.Suspense,{fallback:h.jsx(O3,{}),children:h.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:n})})}const Gv=new sS({defaultOptions:{queries:{staleTime:1e4,retry:(n,t)=>t instanceof Error&&t.message==="Session expired"?!1:n<1}}});window.addEventListener("auth:unauthorized",()=>{Gv.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const n=window.__LT_BASE__||"",t=`${n}/login`;if(window.location.pathname!==t){const s=window.location.pathname+window.location.search,i=n&&s.startsWith(n)?s.slice(n.length)||"/":s;window.location.href=`${t}?returnTo=${encodeURIComponent(i)}`}});const A3=oS([{path:"/login",element:h.jsx(jC,{})},{path:"/connect/anthropic",element:h.jsx(Jb,{})},{path:"/connect/:provider",element:h.jsx(Jb,{})},{path:"/",element:h.jsx(EC,{}),children:[{index:!0,element:h.jsx(Ee,{children:h.jsx(x3,{})})},{path:"processes/all",element:h.jsx(Ee,{children:h.jsx(CC,{})})},{path:"processes/detail/:originId",element:h.jsx(Ee,{children:h.jsx(MC,{})})},{path:"credentials",element:h.jsx(Ee,{children:h.jsx(y3,{})})},{path:"connections",element:h.jsx(wn,{to:"/credentials",replace:!0})},{path:"escalations",element:h.jsx(Ee,{children:h.jsx(PC,{})})},{path:"escalations/available",element:h.jsx(Ee,{children:h.jsx(UC,{})})},{path:"escalations/queue",element:h.jsx(Ee,{children:h.jsx(zC,{})})},{path:"escalations/detail/:id",element:h.jsx(Ee,{children:h.jsx(IC,{})})},{path:"portal/:role/:portal?",element:h.jsx(Ee,{children:h.jsx(l3,{})})},{path:"scan/station",element:h.jsx(Ee,{children:h.jsx(h3,{})})},{path:"capabilities",element:h.jsx(Ee,{children:h.jsx(w3,{})})},{path:"agents",element:h.jsx(Ee,{children:h.jsx(v3,{})})},{path:"agents/new",element:h.jsx(Ee,{children:h.jsx(ex,{})})},{path:"agents/:id",element:h.jsx(Ee,{children:h.jsx(_3,{})})},{path:"agents/:id/edit",element:h.jsx(Ee,{children:h.jsx(ex,{})})},{path:"topics",element:h.jsx(Ee,{children:h.jsx(S3,{})})},{path:"topics/:topic",element:h.jsx(Ee,{children:h.jsx(E3,{})})},{element:h.jsx(kC,{}),children:[{path:"workflows/start",element:h.jsx(Ee,{children:h.jsx(HC,{})})},{path:"workflows/durable/invoke",element:h.jsx(Ee,{children:h.jsx(FC,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:h.jsx(Ee,{children:h.jsx($C,{})})},{path:"workflows/executions",element:h.jsx(Ee,{children:h.jsx(VC,{})})},{path:"workflows/durable/executions",element:h.jsx(Ee,{children:h.jsx(GC,{})})},{path:"workflows/durable/executions/:workflowId",element:h.jsx(Ee,{children:h.jsx(Xb,{})})},{path:"workflows/tasks",element:h.jsx(Ee,{children:h.jsx(XC,{})})},{path:"workflows/tasks/detail/:id",element:h.jsx(Ee,{children:h.jsx(QC,{})})},{path:"workflows/executions/:workflowId",element:h.jsx(Ee,{children:h.jsx(Xb,{})})},{path:"workflows/cron",element:h.jsx(wn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:h.jsx(Ee,{children:h.jsx(ZC,{})})},{path:"workflows/registry",element:h.jsx(Ee,{children:h.jsx(e3,{})})},{path:"workflows/registry/new",element:h.jsx(Ee,{children:h.jsx(Qb,{})})},{path:"workflows/registry/:workflowType",element:h.jsx(Ee,{children:h.jsx(Qb,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:h.jsx(Ee,{children:h.jsx(YC,{})})},{path:"mcp/workflows/invoke",element:h.jsx(Ee,{children:h.jsx(KC,{})})},{path:"mcp/workflows/:id",element:h.jsx(Ee,{children:h.jsx(JC,{})})},{path:"mcp/executions",element:h.jsx(Ee,{children:h.jsx(DC,{})})},{path:"mcp/executions/:jobId",element:h.jsx(Ee,{children:h.jsx(LC,{})})},{path:"files",element:h.jsx(Ee,{children:h.jsx(g3,{})})},{path:"knowledge",element:h.jsx(Ee,{children:h.jsx(b3,{})})},{element:h.jsx(NC,{}),children:[{path:"mcp",element:h.jsx(Ee,{children:h.jsx(RC,{})})},{path:"mcp/queries",element:h.jsx(Ee,{children:h.jsx(qC,{})})},{path:"mcp/queries/:workflowId",element:h.jsx(Ee,{children:h.jsx(BC,{})})},{path:"mcp/tools",element:h.jsx(wn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:h.jsx(Ee,{children:h.jsx(t3,{})})},{path:"mcp/servers/new",element:h.jsx(Ee,{children:h.jsx(Wb,{})})},{path:"mcp/servers/:serverId",element:h.jsx(Ee,{children:h.jsx(Wb,{})})}]}]},{path:"pace",element:h.jsx(Ee,{children:h.jsx(Zb,{})})},{path:"trends",element:h.jsx(Ee,{children:h.jsx(Zb,{})})},{path:"operations",element:h.jsx(wn,{to:"/pace",replace:!0})},{element:h.jsx(Wc,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:h.jsx(Ee,{children:h.jsx(WC,{})})},{path:"admin/users",element:h.jsx(Ee,{children:h.jsx(n3,{})})},{path:"admin/escalation-chains",element:h.jsx(wn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:h.jsx(Ee,{children:h.jsx(r3,{})})},{path:"admin/roles/:role",element:h.jsx(Ee,{children:h.jsx(s3,{})})},{path:"admin/roles/:role/schema",element:h.jsx(Ee,{children:h.jsx(o3,{})})},{path:"admin/roles/:role/list-schema",element:h.jsx(Ee,{children:h.jsx(c3,{})})},{path:"admin/scan-codes",element:h.jsx(Ee,{children:h.jsx(u3,{})})},{path:"admin/scan-codes/:version",element:h.jsx(Ee,{children:h.jsx(f3,{})})},{path:"admin/personas",element:h.jsx(Ee,{children:h.jsx(i3,{})})},{path:"admin/personas/:key",element:h.jsx(Ee,{children:h.jsx(a3,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:h.jsx(wn,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:h.jsx(TC,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:h.jsx(Ee,{children:h.jsx(d3,{})})}]},{path:"admin/controlplane",element:h.jsx(Ee,{children:h.jsx(m3,{})})},{path:"admin/streams",element:h.jsx(Ee,{children:h.jsx(p3,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function j3(){return h.jsx(iS,{client:Gv,children:h.jsx(WS,{children:h.jsx(eA,{children:h.jsx(lS,{router:A3})})})})}pv(mv());const zm=document.createElement("link");zm.rel="stylesheet";zm.href=`${Ht}/api/settings/custom.css`;document.head.appendChild(zm);$S.createRoot(document.getElementById("root")).render(h.jsx(E.StrictMode,{children:h.jsx(j3,{})}));export{Pt as $,jk as A,V5 as B,Um as C,uC as D,r5 as E,Pv as F,Y5 as G,jm as H,lT as I,GT as J,cT as K,bT as L,MN as M,Xt as N,Yx as O,W3 as P,Sm as Q,d5 as R,RT as S,m5 as T,p5 as U,y5 as V,g5 as W,x5 as X,pA as Y,Nu as Z,n5 as _,tM as a,ti as a$,Xd as a0,mT as a1,H3 as a2,W5 as a3,Mm as a4,Zi as a5,bs as a6,l5 as a7,G3 as a8,ev as a9,Lv as aA,sM as aB,eM as aC,cv as aD,w5 as aE,oM as aF,Z5 as aG,cM as aH,lM as aI,L3 as aJ,q3 as aK,z3 as aL,I3 as aM,B3 as aN,P3 as aO,U3 as aP,Y3 as aQ,J3 as aR,K3 as aS,J5 as aT,$3 as aU,wm as aV,X3 as aW,pT as aX,Q3 as aY,F3 as aZ,L5 as a_,eT as aa,fk as ab,U5 as ac,Nk as ad,fc as ae,u5 as af,f5 as ag,Ru as ah,kk as ai,_N as aj,K5 as ak,xv as al,lk as am,Dm as an,mA as ao,i5 as ap,T5 as aq,a5 as ar,h5 as as,b5 as at,uA as au,Dg as av,R3 as aw,aM as ax,rM as ay,nM as az,O5 as b,_o as b0,uM as b1,Nx as b2,R5 as b3,Ht as b4,cx as b5,D3 as b6,fT as b7,Q5 as b8,tv as b9,fM as bA,hM as bB,Fv as bC,vm as bD,Kx as bE,C5 as bF,zb as ba,vv as bb,k5 as bc,B5 as bd,Cm as be,q5 as bf,qr as bg,Jx as bh,D5 as bi,Wi as bj,V3 as bk,_k as bl,$5 as bm,Wj as bn,F5 as bo,G5 as bp,I5 as bq,H5 as br,qm as bs,Kj as bt,Tk as bu,Ae as bv,z5 as bw,e5 as bx,j5 as by,RN as bz,Zn as c,P5 as d,v5 as e,Jj as f,uv as g,NA as h,Z3 as i,on as j,On as k,_5 as l,fe as m,iM as n,S5 as o,E5 as p,s5 as q,o5 as r,c5 as s,A5 as t,M5 as u,t5 as v,Pm as w,X5 as x,Hx as y,N5 as z};
67
- //# sourceMappingURL=index-BQeHJHYN.js.map
64
+ `}function lC(n){const t=n.summary,s=n.title;if(t){const i=t.search(/\n\s*\{[\s\S]*"title"\s*:/);return i>0?t.slice(0,i).trim():t}return s||(typeof n=="string"?n:"Query completed.")}const zv=E.createContext(null);function cC({children:n}){const t=an(),[s,i]=E.useState(!1),[o,c]=E.useState([]),[m,y]=E.useState(null),[g,u]=E.useState({}),d=E.useRef(null),b={page:t.pathname.split("/").filter(Boolean).join("-")||"home",route:t.pathname,params:{},...g,suggestedTags:g.suggestedTags??aC(t.pathname)};E.useEffect(()=>()=>{d.current&&clearInterval(d.current)},[]);const x=E.useCallback(()=>i(q=>!q),[]),v=E.useCallback(q=>{u(q)},[]),w=E.useCallback(()=>{c([]),y(null)},[]),S=E.useCallback(async q=>{var V;const B=new Date().toISOString(),ie={id:`user-${Date.now()}`,role:"user",content:q,timestamp:B},le={id:`pending-${Date.now()}`,role:"assistant",content:"",timestamp:B,pending:!0};c(I=>[...I,ie,le]);const R={...b};(V=R.entities)!=null&&V.yamlContent&&R.entities.yamlContent.length>Gb&&(R.entities={...R.entities,yamlContent:R.entities.yamlContent.slice(0,Gb)+`
65
+ ... (truncated)`});const ne=`${oC(o.concat(ie))}${q}`;try{const D=(await fe("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ne,tags:R.suggestedTags,context:R,wait:!1,direct:!0})})).workflow_id;y(D),c(Q=>Q.map(X=>X.id===le.id?{...X,workflowId:D}:X)),d.current&&clearInterval(d.current),d.current=setInterval(async()=>{var Q;try{const X=await fe(`/workflows/${D}/result`),he=(Q=X==null?void 0:X.result)==null?void 0:Q.data;if(he){d.current&&clearInterval(d.current),d.current=null,y(null);const Se=lC(he);let ke;try{ke=(await fe(`/workflow-states/${D}/execution`)).duration_ms}catch{}c(H=>H.map(W=>W.id===le.id?{...W,content:Se,timestamp:new Date().toISOString(),pending:!1,durationMs:ke}:W))}}catch{}},3e3)}catch{c(I=>I.map(D=>D.id===le.id?{...D,content:"Failed to submit query. Please try again.",pending:!1}:D))}},[o,b]),C=E.useCallback(async q=>{const B=o.find(R=>R.id===q);if(!(B!=null&&B.workflowId)||B.compilationStatus==="compiling"||B.compilationStatus==="done")return;const ie=o.indexOf(B),le=o.slice(0,ie).reverse().find(R=>R.role==="user");if(le){c(R=>R.map($=>$.id===q?{...$,compilationStatus:"compiling"}:$));try{const R=await fe("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:le.content,summary:B.content})}),$=await fe("/yaml-workflows",{method:"POST",body:JSON.stringify({workflow_id:B.workflowId,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:R.tool_name,description:R.description,tags:R.tags,app_id:""})});await fe(`/yaml-workflows/${$.id}/deploy`,{method:"POST"}),c(ne=>ne.map(V=>V.id===q?{...V,compilationStatus:"done"}:V))}catch(R){const $=R instanceof Error?R.message:"Compilation failed";c(ne=>ne.map(V=>V.id===q?{...V,compilationStatus:"error",compilationError:$}:V))}}},[o]);return h.jsx(zv.Provider,{value:{helpOpen:s,setHelpOpen:i,toggleHelp:x,messages:o,sendMessage:S,pageContext:b,setPageContext:v,activeWorkflowId:m,clearMessages:w,compileMessage:C},children:n})}function Iv(){const n=E.useContext(zv);if(!n)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return n}function uC(){const{helpOpen:n,toggleHelp:t}=Iv();return h.jsx("button",{onClick:t,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":n?"Close help":"Ask for help",children:n?h.jsx(Wt,{className:"w-5 h-5 text-text-tertiary",strokeWidth:1.5}):h.jsx("span",{role:"img","aria-label":"Help",className:"logo-mark w-8 h-8 -rotate-[120deg]",style:{"--logo-url":`url(${Ht}/logo512.png)`}})})}function fC({ms:n,className:t=""}){const s=Jj(n),i=E.useMemo(()=>n==null?[]:[{label:"ms",value:String(n)},{label:"sec",value:`${(n/1e3).toFixed(3)}s`},{label:"text",value:s}],[n,s]);return n==null?h.jsx("span",{className:`text-xs text-text-tertiary ${t}`,children:"--"}):h.jsx(lv,{options:i,children:h.jsx("span",{className:`text-xs text-text-tertiary ${t}`,children:s})})}const hC=["sm","md","lg","full"],Vb={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"},Yb={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function dC({which:n}){const t="stroke-current";switch(n){case"sm":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"5",y:"5",width:"7",height:"7",rx:"1.5",className:t,strokeWidth:"1.5"})});case"md":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"3",y:"3",width:"9",height:"9",rx:"1.5",className:t,strokeWidth:"1.5"})});case"lg":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"1.5",y:"1.5",width:"11",height:"11",rx:"1.5",className:t,strokeWidth:"1.5"})});case"full":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"0.75",y:"0.75",width:"12.5",height:"12.5",rx:"1.5",className:t,strokeWidth:"1.5"})})}}function mC({msg:n}){const[t,s]=E.useState(0);E.useEffect(()=>{const m=new Date(n.timestamp).getTime(),y=()=>s(Math.floor((Date.now()-m)/1e3));y();const g=setInterval(y,1e3);return()=>clearInterval(g)},[n.timestamp]);const i=Math.floor(t/60),o=t%60,c=i>0?`${i}m ${o}s`:`${o}s`;return h.jsxs("span",{className:"inline-flex flex-col gap-1.5",children:[h.jsxs("span",{className:"inline-flex items-center gap-1",children:[h.jsx("span",{className:"text-text-tertiary",children:"Thinking"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:150ms]"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:300ms]"}),h.jsx("span",{className:"text-text-muted ml-1 tabular-nums",children:c})]}),n.workflowId&&h.jsxs(Cr,{to:`/workflows/executions/${n.workflowId}`,className:"inline-flex items-center gap-1 text-2xs text-accent/70 hover:text-accent transition-colors",children:[h.jsx(em,{className:"w-2.5 h-2.5",strokeWidth:1.5}),"watch execution"]})]})}function pC({msg:n,compileMessage:t}){const s=n.role==="assistant";return h.jsxs("div",{className:`flex items-center gap-1.5 ${s?"justify-start":"justify-end"}`,children:[h.jsx(cv,{date:n.timestamp,format:"time",className:"!text-2xs text-text-muted/50"}),n.durationMs!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-muted/30 text-2xs",children:"·"}),h.jsx(fC,{ms:n.durationMs,className:"!text-2xs text-text-muted/50"})]}),n.workflowId&&h.jsx(Cr,{to:`/workflows/executions/${n.workflowId}`,className:"text-text-muted/40 hover:text-accent transition-colors",title:"View workflow execution",children:h.jsx(em,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),s&&n.workflowId&&!n.pending&&h.jsx("button",{onClick:()=>t(n.id),disabled:n.compilationStatus==="compiling"||n.compilationStatus==="done",className:"transition-colors",title:n.compilationStatus==="done"?"Compiled — future queries will match this pipeline":n.compilationStatus==="error"?n.compilationError??"Compilation failed":n.compilationStatus==="compiling"?"Compiling...":"Compile to fast pipeline",children:h.jsx(MS,{className:`w-2.5 h-2.5 ${n.compilationStatus==="done"?"text-status-success":n.compilationStatus==="error"?"text-status-error":n.compilationStatus==="compiling"?"text-accent/40 animate-pulse":"text-text-muted/40 hover:text-accent"}`,strokeWidth:1.5})})]})}function yC(){const{helpOpen:n,setHelpOpen:t,messages:s,sendMessage:i,pageContext:o,activeWorkflowId:c,clearMessages:m,compileMessage:y}=Iv(),[g,u]=E.useState(""),[d,b]=E.useState("md"),[x,v]=E.useState(!0),w=E.useRef(null),S=E.useRef(null);if(E.useEffect(()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},[s]),E.useEffect(()=>{n&&S.current&&S.current.focus()},[n]),E.useEffect(()=>{if(!n)return;const R=$=>{$.key==="Escape"&&(d==="full"?b("lg"):d==="lg"?b("md"):d==="md"?b("sm"):t(!1))};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[n,d,t]),!n)return null;const C=()=>{const R=g.trim();!R||c||(i(R),u(""),S.current&&(S.current.style.height="auto"))},q=R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),C())},B=d==="full",ie=o.page.replace(/-/g," "),le=B?{}:{bottom:"108px"};return h.jsxs("div",{className:`fixed z-[45] flex flex-col border border-surface-border rounded-lg overflow-hidden transition-all duration-300 ${B?Vb.full:`right-6 ${Vb[d]}`} ${x?"bg-surface-raised shadow-xl":"bg-surface-raised/[0.03] shadow-lg shadow-black/5"}`,style:le,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),children:[h.jsxs("div",{className:`flex items-center justify-between px-4 py-2.5 border-b border-surface-border shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"text-xs font-medium text-text-primary truncate",children:"Help Assistant"}),h.jsx("p",{className:"text-2xs text-text-tertiary truncate",children:ie})]}),h.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[h.jsx("div",{className:"flex items-center gap-0.5 border border-surface-border rounded p-0.5",role:"radiogroup","aria-label":"Panel size",children:hC.map(R=>h.jsx("button",{onClick:()=>b(R),className:`p-1 rounded transition-colors ${R===d?"bg-accent/15 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"}`,role:"radio","aria-checked":R===d,"aria-label":Yb[R],title:Yb[R],children:h.jsx(dC,{which:R})},R))}),s.length>0&&h.jsx("button",{onClick:m,className:"p-1 text-text-tertiary hover:text-text-secondary transition-colors","aria-label":"Clear conversation",title:"Clear conversation",children:h.jsx(RS,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),h.jsx("button",{onClick:()=>t(!1),className:"p-1 text-text-tertiary hover:text-text-primary transition-colors","aria-label":"Close",title:"Close",children:h.jsx(Wt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})]}),h.jsxs("div",{ref:w,className:`flex-1 overflow-y-auto px-4 py-3 space-y-3 min-h-[120px] transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary text-center py-6",children:"Ask anything about what you're viewing."}),s.map(R=>h.jsxs("div",{className:`text-xs leading-relaxed ${R.role==="user"?"text-right":"text-left"}`,children:[h.jsx("div",{className:`inline-block max-w-[85%] px-3 py-2 rounded-md whitespace-pre-wrap ${R.role==="user"?"bg-accent/10 text-text-primary":"bg-surface-sunken text-text-secondary"}`,children:R.pending?h.jsx(mC,{msg:R}):R.role==="assistant"?h.jsx(Ru,{content:R.content}):R.content}),!R.pending&&h.jsx("div",{className:"mt-0.5",children:h.jsx(pC,{msg:R,compileMessage:y})})]},R.id))]}),h.jsxs("div",{className:`border-t border-surface-border px-3 py-2.5 flex gap-2 shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsx("textarea",{ref:S,value:g,onChange:R=>{u(R.target.value);const $=R.target;$.style.height="auto",$.style.height=`${Math.min($.scrollHeight,120)}px`},onKeyDown:q,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:!!c}),h.jsx("button",{onClick:C,disabled:!g.trim()||!!c,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:h.jsx(DS,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}const gC=6e3,bC="scan";function xC(){const{lastResult:n}=qm(),{open:t,ownerKey:s}=jm(),[i,o]=E.useState(null);return E.useEffect(()=>{if(!n)return;const c=setTimeout(()=>o(n.at),gC);return()=>clearTimeout(c)},[n]),!n||n.navigated||i===n.at||t&&s===bC||n.source===jo.TOOLBAR?null:h.jsx("div",{role:"status",className:"fixed bottom-14 right-4 z-[60] w-80 max-w-[calc(100vw-2rem)] bg-surface-raised border border-surface-border shadow-lg rounded-md animate-page-in",children:h.jsxs("div",{className:"flex items-start gap-2.5 px-3.5 py-3",children:[h.jsx(No,{className:"w-4 h-4 mt-0.5 text-accent-muted shrink-0",strokeWidth:1.5}),h.jsx("div",{className:"flex-1 min-w-0",children:h.jsx(Bm,{result:n})}),h.jsx("button",{type:"button",onClick:()=>o(n.at),className:"text-text-tertiary hover:text-text-primary shrink-0",title:"Dismiss",children:h.jsx(Wt,{className:"w-3.5 h-3.5"})})]})})}const $v="lt-announcement-dismissed:";function vC(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _C(n){try{return localStorage.getItem(`${$v}${n}`)==="1"}catch{return!1}}function wC(){const{isAuthenticated:n,userRoleNames:t}=Pt(),{data:s}=tv(n),i=He(),[o,c]=E.useState(null),[m,y]=E.useState(0);On(qA,()=>{i.invalidateQueries({queryKey:["announcements"]})});const g=Date.now(),u=((s==null?void 0:s.announcements)??[]).filter(b=>!_C(b.id)&&new Date(b.expires_at).getTime()>g&&(b.roles.length===0||b.roles.some(x=>t.includes(x))));if(E.useEffect(()=>{const b=((s==null?void 0:s.announcements)??[]).map(v=>new Date(v.expires_at).getTime()-Date.now()).filter(v=>v>0);if(b.length===0)return;const x=setTimeout(()=>y(v=>v+1),Math.min(...b)+250);return()=>clearTimeout(x)},[s,m]),u.length===0)return null;const d=b=>{try{localStorage.setItem(`${$v}${b}`,"1")}catch{}y(x=>x+1)};return h.jsx("div",{"data-testid":"announcement-banner",className:"relative z-40",children:u.map(b=>{const x=o===b.id,v=b.title??b.body.split(`
66
+ `)[0];return h.jsxs("div",{className:"border-b border-accent/25 bg-accent/10",children:[h.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5",children:[h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-accent",children:"Notice"}),h.jsxs("button",{type:"button",onClick:()=>c(x?null:b.id),className:"flex items-center gap-1.5 text-xs text-text-primary hover:text-accent transition-colors min-w-0",children:[h.jsx("span",{className:"truncate",children:v}),x?h.jsx(ax,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}):h.jsx(Zd,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{type:"button",onClick:()=>d(b.id),className:"icon-link",title:"Dismiss","aria-label":`Dismiss ${v}`,children:h.jsx(Wt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]}),x&&h.jsx("div",{className:"px-4 pb-3 text-sm text-text-secondary max-w-measure",children:h.jsx(Ru,{content:vC(b.body)})})]},b.id)})})}function SC(){var $;const{isBuilder:n,isOps:t,viewAs:s}=Vx(),{canSeePaceBoard:i}=Yx();lA();const{data:o}=Zn(),c=$x(),m=c!==null?c:!!(($=o==null?void 0:o.ai)!=null&&$.enabled),{collapsed:y,toggle:g}=Om(),[u,d]=E.useState(!1),[b,x]=E.useState(!1),[v,w]=E.useState(!1),[S,C]=E.useState(()=>window.location.hash.startsWith("#docs")),q=an(),B=E.useRef(null),{kiosk:ie,homePath:le}=Sm(),R=ie||vA(q.pathname);return E.useEffect(()=>{const ne=B.current;ne&&(ne.classList.remove("animate-page-in"),ne.offsetWidth,ne.classList.add("animate-page-in"))},[q.pathname]),E.useEffect(()=>{const ne=()=>{window.location.hash.startsWith("#docs")&&C(!0)};return window.addEventListener("hashchange",ne),()=>window.removeEventListener("hashchange",ne)},[]),ie&&le&&!EA(q.pathname,q.search)?h.jsx(wn,{to:le,replace:!0}):h.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[h.jsx(rT,{onToggleEventFeed:()=>d(ne=>!ne),onToggleDocs:()=>C(ne=>!ne),onToggleNav:R?void 0:()=>x(ne=>!ne)}),h.jsx(wC,{}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!R&&h.jsxs("aside",{className:`${y?"w-16":"w-60"} shrink-0 bg-surface-raised border-r border-surface-border hidden lg:flex flex-col transition-[width] duration-200 ease-out overflow-hidden relative z-20`,children:[h.jsx("nav",{className:"flex-1 px-3 pt-[36px] pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:h.jsx(Lv,{aiEnabled:m,isBuilder:n,isOps:t,viewAs:s,canSeePaceBoard:i})}),h.jsx("button",{onClick:g,className:`shrink-0 py-3 text-text-tertiary hover:text-text-secondary transition-colors duration-150 ${y?"flex justify-center":"flex items-center px-7"}`,"aria-label":y?"Expand sidebar":"Collapse sidebar",children:y?h.jsx(LS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):h.jsx(qS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!y&&(o==null?void 0:o.environment)&&h.jsxs("div",{className:"shrink-0 px-5 pb-3 text-2xs leading-tight text-text-tertiary whitespace-nowrap overflow-hidden text-ellipsis",title:`long-tail v${o.environment.longTailVersion} · HotMesh v${o.environment.hotmeshVersion} · Node ${o.environment.nodeVersion} · ${o.environment.nodeEnv}`,children:["long-tail v",o.environment.longTailVersion,h.jsx("span",{className:"mx-1 text-surface-border",children:"·"}),"HotMesh v",o.environment.hotmeshVersion]})]}),h.jsx("main",{className:"flex-1 min-w-0 overflow-y-auto",children:h.jsx("div",{ref:B,className:"w-full px-page-x py-8 pb-16 animate-page-in h-full flex flex-col @container",children:h.jsx(Ws,{})})}),h.jsx(EC,{})]}),!R&&h.jsx(TT,{open:b,onClose:()=>x(!1),aiEnabled:m,isBuilder:n,isOps:t,viewAs:s,canSeePaceBoard:i}),h.jsx(JT,{open:u,onToggle:()=>d(ne=>!ne),configOpen:v,onToggleConfig:()=>w(ne=>!ne)}),h.jsx(iC,{open:S,onClose:()=>{C(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),m&&h.jsx(uC,{}),m&&h.jsx(yC,{}),h.jsx(xC,{})]})}function EC(){const{node:n,width:t,open:s}=jm();return h.jsx(NA,{open:s,width:t,className:"border-l border-surface-border bg-surface-raised",children:n})}function OC(){const{isAuthenticated:n}=Pt(),t=an();return n?h.jsx(AA,{children:h.jsx(kA,{children:h.jsx(cC,{children:h.jsx(ck,{children:h.jsx(Ck,{children:h.jsx(SC,{})})})})})}):h.jsx(wn,{to:"/login",state:{from:t.pathname},replace:!0})}function Hv({provider:n,className:t="w-5 h-5"}){switch(n){case"google":return h.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor",children:[h.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"}),h.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"}),h.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"}),h.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 h.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor",children:h.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 h.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("path",{d:"M3 3h8.5v8.5H3z",fill:"#F25022"}),h.jsx("path",{d:"M12.5 3H21v8.5h-8.5z",fill:"#7FBA00"}),h.jsx("path",{d:"M3 12.5h8.5V21H3z",fill:"#00A4EF"}),h.jsx("path",{d:"M12.5 12.5H21V21h-8.5z",fill:"#FFB900"})]});case"anthropic":return h.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor",children:h.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 h.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("path",{d:"M12 8v4l3 3"})]})}}async function AC(){return fe("/auth/oauth/providers")}async function jC(n,t){const s=t?`?label=${encodeURIComponent(t)}`:"";return fe(`/auth/oauth/connections/${n}${s}`,{method:"DELETE"})}function hM(){return $e({queryKey:["oauth-connections"],queryFn:()=>fe("/auth/oauth/connections")})}function dM(){const n=He();return Ve({mutationFn:({provider:t,label:s})=>jC(t,s),onSuccess:()=>{n.invalidateQueries({queryKey:["oauth-connections"]})}})}function kC(){var ne;const{login:n,isAuthenticated:t}=Pt(),s=ra(),i=an(),o=new URLSearchParams(i.search),c=o.get("token"),m=o.get("error"),y=((ne=i.state)==null?void 0:ne.from)??o.get("returnTo")??"/",g=E.useRef(!1);c&&!g.current&&(g.current=!0,n(c,void 0,{displayName:o.get("displayName"),username:o.get("username")}));const[u,d]=E.useState(""),[b,x]=E.useState(""),[v,w]=E.useState(m||""),[S,C]=E.useState(!1),[q,B]=E.useState(!!c),[ie,le]=E.useState([]),R=E.useRef(!1);if(E.useEffect(()=>{c||R.current||(R.current=!0,(async()=>{var V,I,D,Q;try{const X=await nm().catch(()=>null);if(!((V=X==null?void 0:X.auth)!=null&&V.sso))return;const he=await fetch(`${Ht}/api/auth/sso`,{method:"POST"});if(!he.ok){w("Host authentication required — please log in to your organization first");return}const Se=await he.json();Se.token&&((I=X.auth)!=null&&I.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",X.auth.ssoLogoutUrl),B(!0),n(Se.token,void 0,{displayName:(D=Se.user)==null?void 0:D.display_name,username:(Q=Se.user)==null?void 0:Q.external_id}))}catch{}})())},[]),E.useEffect(()=>{c||AC().then(le).catch(()=>{})},[]),E.useEffect(()=>{if(!q)return;const V=setTimeout(()=>s(y,{replace:!0}),1500);return()=>clearTimeout(V)},[q]),t&&!q)return h.jsx(wn,{to:y,replace:!0});const $=async V=>{var I,D;if(V.preventDefault(),w(""),!u.trim()||!b){w("Username and password are required");return}C(!0);try{const Q=await fetch(`${Ht}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:u.trim(),password:b})}),X=await Q.json();if(!Q.ok){w(X.error||"Login failed");return}B(!0),n(X.token,{username:u.trim(),password:b},{displayName:(I=X.user)==null?void 0:I.display_name,username:(D=X.user)==null?void 0:D.external_id})}catch{w("Unable to connect to server")}finally{C(!1)}};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center overflow-hidden",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:`mb-10 transition-all duration-[1500ms] ease-in ${q?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:h.jsx(Tm,{size:"lg",hideLabel:q})}),h.jsxs("form",{onSubmit:$,className:`space-y-5 transition-opacity duration-300 ${q?"opacity-0":""}`,children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-text-secondary mb-2",children:"Username"}),h.jsx("input",{id:"username",type:"text",value:u,onChange:V=>d(V.target.value),className:"input",placeholder:"Enter your username",autoFocus:!q,autoComplete:"username"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-text-secondary mb-2",children:"Password"}),h.jsx("input",{id:"password",type:"password",value:b,onChange:V=>x(V.target.value),className:"input",placeholder:"Enter your password",autoComplete:"current-password"})]}),v&&h.jsx("p",{className:"text-sm text-status-error",children:v}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:S||q,children:S?"Signing in...":"Sign In"}),ie.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[h.jsx("div",{className:"flex-1 h-px bg-border"}),h.jsx("span",{className:"text-xs text-text-tertiary",children:"or continue with"}),h.jsx("div",{className:"flex-1 h-px bg-border"})]}),h.jsx("div",{className:"space-y-2",children:ie.filter(V=>V.provider!=="anthropic").map(V=>h.jsxs("a",{href:`${Ht}/api/auth/oauth/${V.provider}?returnTo=${encodeURIComponent(y)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[h.jsx(Hv,{provider:V.provider}),"Sign in with ",V.name]},V.provider))})]})]})]})})}function Kb(){const{isAuthenticated:n}=Pt(),t=ra(),s=an(),i=new URLSearchParams(s.search),o=i.get("state")||"";E.useEffect(()=>{n||t(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[n]);const[c,m]=E.useState(""),[y,g]=E.useState(i.get("label")||"default"),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=c.trim().startsWith("sk-ant-oat"),w=c.trim().startsWith("sk-ant-api"),S=C=>{C.preventDefault();const q=c.trim();if(!q){d("A token or API key is required");return}if(!q.startsWith("sk-ant-")){d('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}x(!0),d("");const B=`${Ht}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(q)}&state=${encodeURIComponent(o)}`;window.location.href=B};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:"mb-10",children:h.jsx(Tm,{size:"lg"})}),h.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[h.jsx(Hv,{provider:"anthropic",className:"w-6 h-6"}),h.jsx("h2",{className:"heading-3",children:"Connect Anthropic"})]}),h.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."}),h.jsxs("form",{onSubmit:S,className:"space-y-5",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-text-secondary mb-2",children:"OAuth Token or API Key"}),h.jsx("input",{id:"token",type:"password",value:c,onChange:C=>m(C.target.value),className:"input",placeholder:"sk-ant-oat01-... or sk-ant-api03-...",autoFocus:!0,autoComplete:"off"}),v&&h.jsx("p",{className:"text-xs text-status-success mt-1",children:"OAuth token detected — uses your Claude subscription (flat rate)"}),w&&h.jsx("p",{className:"text-xs text-status-warning mt-1",children:"API key detected — billed per-token from your Anthropic API account"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"label",className:"block text-sm font-medium text-text-secondary mb-2",children:"Label"}),h.jsx("input",{id:"label",type:"text",value:y,onChange:C=>g(C.target.value.replace(/\s+/g,"-").toLowerCase()),className:"input",placeholder:"default",autoComplete:"off"}),h.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").'})]}),u&&h.jsx("p",{className:"text-sm text-status-error",children:u}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:b,children:b?"Validating...":"Connect"}),h.jsx("a",{href:"/",className:"block text-center text-sm text-text-tertiary hover:text-text-secondary",children:"Cancel"})]}),h.jsxs("div",{className:"mt-6 space-y-3 text-xs text-text-tertiary",children:[h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Recommended:"})," ","Run"," ",h.jsx("code",{className:"px-1 py-0.5 bg-surface-sunken rounded text-2xs",children:"claude setup-token"})," ","in your terminal to generate an OAuth token that uses your subscription."]}),h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Alternative:"})," ","Use an API key from"," ",h.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 Wc({roleTypes:n,roleNames:t,redirectTo:s="/"}){const{isSuperAdmin:i,hasRole:o,hasRoleType:c}=Pt();return i?h.jsx(Ws,{}):n&&n.some(m=>c(m))?h.jsx(Ws,{}):t&&t.some(m=>o(m))?h.jsx(Ws,{}):h.jsx(wn,{to:s,replace:!0})}function NC(){const{data:n,isSuccess:t}=Dv();return t&&n.length===0?h.jsx(wn,{to:"/",replace:!0}):h.jsx(Ws,{})}function TC({redirectTo:n="/"}){var i;const{data:t,isLoading:s}=Zn();return s||!t?null:(i=t.ai)!=null&&i.enabled?h.jsx(Ws,{}):h.jsx(wn,{to:n,replace:!0})}function CC({flag:n,redirectTo:t="/"}){var o;const{data:s,isLoading:i}=Zn();return i||!s?null:((o=s.features)==null?void 0:o[n])===!1?h.jsx(wn,{to:t,replace:!0}):h.jsx(Ws,{})}const MC=E.lazy(()=>je(()=>import("./ProcessesListPage-CakYRtnE.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),import.meta.url).then(n=>({default:n.ProcessesListPage}))),RC=E.lazy(()=>je(()=>import("./ProcessDetailPage-D7EYwW-j.js"),__vite__mapDeps([17,1,2,18,13,19,16,10,4,20,21]),import.meta.url).then(n=>({default:n.ProcessDetailPage}))),DC=E.lazy(()=>je(()=>import("./McpOverview-CjqTuP0N.js"),__vite__mapDeps([22,1,23,24,25,26,14,13,27,4]),import.meta.url).then(n=>({default:n.McpOverview}))),LC=E.lazy(()=>je(()=>import("./McpRunsPage-DERXQLgZ.js"),__vite__mapDeps([28,1,24,25,3,4,29,26,6,7,8,9,16,13,30,14,12,11,15,31]),import.meta.url).then(n=>({default:n.McpRunsPage}))),qC=E.lazy(()=>je(()=>import("./McpRunDetailPage-JDrr3uUQ.js"),__vite__mapDeps([32,1,24,14,13,33,34,12,35,19,4,36,15,37]),import.meta.url).then(n=>({default:n.McpRunDetailPage}))),BC=E.lazy(()=>je(()=>import("./McpQueryPage-C-PyXYX4.js"),__vite__mapDeps([38,1,14,13,7,8,9,12,11,15,6,10,30,16,31,3,4,39]),import.meta.url).then(n=>({default:n.McpQueryPage}))),PC=E.lazy(()=>je(()=>import("./McpQueryDetailPage-leCsje1U.js"),__vite__mapDeps([40,1,14,13,19,39,4,25,41,42,24,2,43,44,45,46,47,48,37,49,35,36]),import.meta.url).then(n=>({default:n.McpQueryDetailPage}))),UC=E.lazy(()=>je(()=>import("./EscalationsOverview-BzH-Y-5x.js"),__vite__mapDeps([50,1,14,13,27,4]),import.meta.url).then(n=>({default:n.EscalationsOverview}))),zC=E.lazy(()=>je(()=>import("./AvailableEscalationsPage-CWMyy3IL.js"),__vite__mapDeps([51,1,4,52,13,53,54,5,55,56,57,7,8,9,19,21,11,58,59,12,60,20,16,61,3,31]),import.meta.url).then(n=>({default:n.AvailableEscalationsPage}))),IC=E.lazy(()=>je(()=>import("./OperatorDashboard-C8RtPv8P.js"),__vite__mapDeps([62,1,3,4,5,6,52,7,8,9,11,31,58,59,13,12,60,20,16,21,61,57,19,55,15]),import.meta.url).then(n=>({default:n.OperatorDashboard}))),$C=E.lazy(()=>je(()=>import("./index-D1mKf_qz.js"),__vite__mapDeps([63,1,53,54,5,64,13,57,7,8,9,19,21,11,4,16,14,15,20,61,37,65]),import.meta.url).then(n=>({default:n.EscalationDetailPage}))),HC=E.lazy(()=>je(()=>import("./WorkflowsOverview-IeTKHAi4.js"),__vite__mapDeps([66,1,14,13,27,4]),import.meta.url).then(n=>({default:n.WorkflowsOverview}))),FC=E.lazy(()=>je(()=>import("./index-BCFEQEMC.js"),__vite__mapDeps([67,1,14,13,12,16,64,57,7,8,9,19,21,11,4,54,68,46,47]),import.meta.url).then(n=>({default:n.StartWorkflowPage}))),GC=E.lazy(()=>je(()=>import("./index-BCFEQEMC.js"),__vite__mapDeps([67,1,14,13,12,16,64,57,7,8,9,19,21,11,4,54,68,46,47]),import.meta.url).then(n=>({default:n.DurableInvokePage}))),VC=E.lazy(()=>je(()=>import("./WorkflowsDashboard-Bp1L7Ggz.js"),__vite__mapDeps([69,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"durable"})}))),YC=E.lazy(()=>je(()=>import("./WorkflowsDashboard-Bp1L7Ggz.js"),__vite__mapDeps([69,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"all"})}))),KC=E.lazy(()=>je(()=>import("./YamlWorkflowsPage-CEcZBV_3.js"),__vite__mapDeps([70,1,25,3,4,14,13,12,8,48,68,19]),import.meta.url).then(n=>({default:n.YamlWorkflowsPage}))),JC=E.lazy(()=>je(()=>import("./GraphInvokePage-Bwi8EF9Y.js"),__vite__mapDeps([71,1,25,14,13,43,45,46,47,44,4,48,68]),import.meta.url).then(n=>({default:n.GraphInvokePage}))),XC=E.lazy(()=>je(()=>import("./YamlWorkflowDetailPage-DtKCXnKt.js"),__vite__mapDeps([72,1,25,19,68,13,4]),import.meta.url).then(n=>({default:n.YamlWorkflowDetailPage}))),QC=E.lazy(()=>je(()=>import("./TasksListPage-BVIP6-EZ.js"),__vite__mapDeps([73,1,2,3,4,7,8,9,19,60,49,11,12,13,14,16]),import.meta.url).then(n=>({default:n.TasksListPage}))),WC=E.lazy(()=>je(()=>import("./TaskDetailPage-DGUzdBFN.js"),__vite__mapDeps([74,1,2,19,60,14,13,4]),import.meta.url).then(n=>({default:n.TaskDetailPage}))),Jb=E.lazy(()=>je(()=>import("./WorkflowExecutionPage-BbkLZ1co.js"),__vite__mapDeps([75,1,34,12,13,35,19,4,36,2,14,33,15,37]),import.meta.url).then(n=>({default:n.WorkflowExecutionPage}))),ZC=E.lazy(()=>je(()=>import("./AdminDashboard-DKrqLGjn.js"),__vite__mapDeps([76,1,2,23,18,13,4]),import.meta.url).then(n=>({default:n.AdminDashboard}))),e3=E.lazy(()=>je(()=>import("./index-C3VTJcrp.js"),__vite__mapDeps([77,1,7,8,9,12,13,31,3,4,14,78,16]),import.meta.url).then(n=>({default:n.WorkersPage}))),t3=E.lazy(()=>je(()=>import("./index-BEPKAjna.js"),__vite__mapDeps([79,1,12,13,80,20,16,14,4,46,47,68,64,57,7,8,9,19,21,11,54]),import.meta.url).then(n=>({default:n.WorkflowConfigsPage}))),Xb=E.lazy(()=>je(()=>import("./index-BEPKAjna.js"),__vite__mapDeps([79,1,12,13,80,20,16,14,4,46,47,68,64,57,7,8,9,19,21,11,54]),import.meta.url).then(n=>({default:n.WorkflowConfigDetailPage}))),n3=E.lazy(()=>je(()=>import("./index-Djsoi8DI.js"),__vite__mapDeps([81,1,23,8,80,14,13,12,11,3,4,82,45,46,47,48,44,31,19]),import.meta.url).then(n=>({default:n.McpServersPage}))),Qb=E.lazy(()=>je(()=>import("./index-CcgmR-7-.js"),__vite__mapDeps([83,1,23,14,13,41,4]),import.meta.url).then(n=>({default:n.McpServerDetailPage}))),r3=E.lazy(()=>je(()=>import("./index-DH03y-UT.js"),__vite__mapDeps([84,1,3,4,7,8,9,11,12,13,80,31,14,20,47,49,85,86,33]),import.meta.url).then(n=>({default:n.UsersPage}))),s3=E.lazy(()=>je(()=>import("./RolesPage-Czu7Zku4.js"),__vite__mapDeps([87,1,12,13,14,20,4]),import.meta.url).then(n=>({default:n.RolesPage}))),i3=E.lazy(()=>je(()=>import("./RoleDetailPage-CKbGwezP.js"),__vite__mapDeps([88,1,89,80,13,4]),import.meta.url).then(n=>({default:n.RoleDetailPage}))),a3=E.lazy(()=>je(()=>import("./PersonasPage-BFFxncSE.js"),__vite__mapDeps([90,1,85,12,13,14,20,4,5]),import.meta.url).then(n=>({default:n.PersonasPage}))),o3=E.lazy(()=>je(()=>import("./PersonaDetailPage-ChXwJ6u5.js"),__vite__mapDeps([91,1,85,20,13,86,89,80,4]),import.meta.url).then(n=>({default:n.PersonaDetailPage}))),l3=E.lazy(()=>je(()=>import("./EscalationSchemaPage-CQt-Embr.js"),__vite__mapDeps([92,1,64,13,57,7,8,9,19,21,11,4,54,16]),import.meta.url).then(n=>({default:n.EscalationSchemaPage}))),c3=E.lazy(()=>je(()=>import("./PortalPage-Xk1zVneM.js"),__vite__mapDeps([93,1,9,56,13,57,7,8,19,21,11,4,58,59,12,60,20,16,61]),import.meta.url).then(n=>({default:n.PortalPage}))),u3=E.lazy(()=>je(()=>import("./EscalationListSchemaPage-DlDIYb-p.js"),__vite__mapDeps([94,1,13,4]),import.meta.url).then(n=>({default:n.EscalationListSchemaPage}))),f3=E.lazy(()=>je(()=>import("./ScanCodesPage-Cv9q8Bvt.js"),__vite__mapDeps([95,1,96,14,13,4]),import.meta.url).then(n=>({default:n.ScanCodesPage}))),h3=E.lazy(()=>je(()=>import("./ScanSchemeDetailPage-BxazXYIc.js"),__vite__mapDeps([97,1,80,14,13,96,4]),import.meta.url).then(n=>({default:n.ScanSchemeDetailPage}))),d3=E.lazy(()=>je(()=>import("./ScanStationPage-Cg8LCFR7.js"),__vite__mapDeps([98,1,13,65,4]),import.meta.url).then(n=>({default:n.ScanStationPage}))),m3=E.lazy(()=>je(()=>import("./index-Ba-s5Yb5.js"),__vite__mapDeps([99,1,14,13,54,4]),import.meta.url).then(n=>({default:n.MaintenancePage}))),Wb=E.lazy(()=>je(()=>import("./OperationsPage-B2DA7n9m.js").then(n=>n.O),__vite__mapDeps([100,1,59,13,4,14,9]),import.meta.url).then(n=>({default:n.OperationsPage}))),p3=E.lazy(()=>je(()=>import("./index-CuBGGwXf.js"),__vite__mapDeps([101,1,18,13,12,3,4,29,26,42,78,7,8,9,31]),import.meta.url).then(n=>({default:n.ControlPlanePage}))),y3=E.lazy(()=>je(()=>import("./index-DBxpyIw5.js"),__vite__mapDeps([102,1,36,13,3,4,29,26,6,7,8,9,11,12,14,15]),import.meta.url).then(n=>({default:n.StreamMessagesPage}))),g3=E.lazy(()=>je(()=>import("./CredentialsPage-DhiHiPsG.js"),__vite__mapDeps([103,1,14,13,49,80,4]),import.meta.url).then(n=>({default:n.CredentialsPage}))),b3=E.lazy(()=>je(()=>import("./index-h2gX31B2.js"),__vite__mapDeps([104,1,4,14,13,12,15,6,8,105,49]),import.meta.url).then(n=>({default:n.FilesPage}))),x3=E.lazy(()=>je(()=>import("./index-CZyO9hRb.js"),__vite__mapDeps([106,1,14,13,12,15,11,8,105,49,107,41,4]),import.meta.url).then(n=>({default:n.KnowledgePage}))),v3=E.lazy(()=>je(()=>import("./HomePage-Z_Q03C0z.js"),__vite__mapDeps([108,1,24,26,20,13,16,15,100,59,4,14,9,52]),import.meta.url).then(n=>({default:n.HomePage}))),_3=E.lazy(()=>je(()=>import("./AgentsPage-5MynmbWX.js"),__vite__mapDeps([109,1,110,3,4,6,7,8,9,11,12,13,14,15]),import.meta.url).then(n=>({default:n.AgentsPage}))),w3=E.lazy(()=>je(()=>import("./AgentDetailPage-DZhzuZmO.js"),__vite__mapDeps([111,1,110,112,13,16,4]),import.meta.url).then(n=>({default:n.AgentDetailPage}))),Zb=E.lazy(()=>je(()=>import("./AgentConfigPage-BoQhRW6U.js"),__vite__mapDeps([113,1,110,112,13,14,107,45,46,47,25,114,115,16,4]),import.meta.url).then(n=>({default:n.AgentConfigPage}))),S3=E.lazy(()=>je(()=>import("./CapabilitiesPage-DKxLvOfB.js"),__vite__mapDeps([116,1,114,82,23,45,46,47,13,48,4,44,14,12]),import.meta.url).then(n=>({default:n.CapabilitiesPage}))),E3=E.lazy(()=>je(()=>import("./TopicsPage-CE3hBthn.js"),__vite__mapDeps([117,1,115,14,13,12,4]),import.meta.url).then(n=>({default:n.TopicsPage}))),O3=E.lazy(()=>je(()=>import("./TopicDetailPage-70mMKBzG.js"),__vite__mapDeps([118,1,115,15,13,4]),import.meta.url).then(n=>({default:n.TopicDetailPage})));function A3(){return h.jsxs("div",{className:"animate-pulse space-y-4",children:[h.jsx("div",{className:"h-8 bg-surface-sunken rounded w-48"}),h.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]})}function Ee({children:n}){return h.jsx(E.Suspense,{fallback:h.jsx(A3,{}),children:h.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:n})})}const Fv=new rS({defaultOptions:{queries:{staleTime:1e4,retry:(n,t)=>t instanceof Error&&t.message==="Session expired"?!1:n<1}}});window.addEventListener("auth:unauthorized",()=>{Fv.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const n=window.__LT_BASE__||"",t=`${n}/login`;if(window.location.pathname!==t){const s=window.location.pathname+window.location.search,i=n&&s.startsWith(n)?s.slice(n.length)||"/":s;window.location.href=`${t}?returnTo=${encodeURIComponent(i)}`}});const j3=aS([{path:"/login",element:h.jsx(kC,{})},{path:"/connect/anthropic",element:h.jsx(Kb,{})},{path:"/connect/:provider",element:h.jsx(Kb,{})},{path:"/",element:h.jsx(OC,{}),children:[{index:!0,element:h.jsx(Ee,{children:h.jsx(v3,{})})},{path:"processes/all",element:h.jsx(Ee,{children:h.jsx(MC,{})})},{path:"processes/detail/:originId",element:h.jsx(Ee,{children:h.jsx(RC,{})})},{path:"credentials",element:h.jsx(Ee,{children:h.jsx(g3,{})})},{path:"connections",element:h.jsx(wn,{to:"/credentials",replace:!0})},{path:"escalations",element:h.jsx(Ee,{children:h.jsx(UC,{})})},{path:"escalations/available",element:h.jsx(Ee,{children:h.jsx(zC,{})})},{path:"escalations/queue",element:h.jsx(Ee,{children:h.jsx(IC,{})})},{path:"escalations/detail/:id",element:h.jsx(Ee,{children:h.jsx($C,{})})},{path:"portal/:role/:portal?",element:h.jsx(Ee,{children:h.jsx(c3,{})})},{path:"scan/station",element:h.jsx(Ee,{children:h.jsx(d3,{})})},{path:"capabilities",element:h.jsx(Ee,{children:h.jsx(S3,{})})},{path:"agents",element:h.jsx(Ee,{children:h.jsx(_3,{})})},{path:"agents/new",element:h.jsx(Ee,{children:h.jsx(Zb,{})})},{path:"agents/:id",element:h.jsx(Ee,{children:h.jsx(w3,{})})},{path:"agents/:id/edit",element:h.jsx(Ee,{children:h.jsx(Zb,{})})},{path:"topics",element:h.jsx(Ee,{children:h.jsx(E3,{})})},{path:"topics/:topic",element:h.jsx(Ee,{children:h.jsx(O3,{})})},{element:h.jsx(NC,{}),children:[{path:"workflows/start",element:h.jsx(Ee,{children:h.jsx(FC,{})})},{path:"workflows/durable/invoke",element:h.jsx(Ee,{children:h.jsx(GC,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:h.jsx(Ee,{children:h.jsx(HC,{})})},{path:"workflows/executions",element:h.jsx(Ee,{children:h.jsx(YC,{})})},{path:"workflows/durable/executions",element:h.jsx(Ee,{children:h.jsx(VC,{})})},{path:"workflows/durable/executions/:workflowId",element:h.jsx(Ee,{children:h.jsx(Jb,{})})},{path:"workflows/tasks",element:h.jsx(Ee,{children:h.jsx(QC,{})})},{path:"workflows/tasks/detail/:id",element:h.jsx(Ee,{children:h.jsx(WC,{})})},{path:"workflows/executions/:workflowId",element:h.jsx(Ee,{children:h.jsx(Jb,{})})},{path:"workflows/cron",element:h.jsx(wn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:h.jsx(Ee,{children:h.jsx(e3,{})})},{path:"workflows/registry",element:h.jsx(Ee,{children:h.jsx(t3,{})})},{path:"workflows/registry/new",element:h.jsx(Ee,{children:h.jsx(Xb,{})})},{path:"workflows/registry/:workflowType",element:h.jsx(Ee,{children:h.jsx(Xb,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:h.jsx(Ee,{children:h.jsx(KC,{})})},{path:"mcp/workflows/invoke",element:h.jsx(Ee,{children:h.jsx(JC,{})})},{path:"mcp/workflows/:id",element:h.jsx(Ee,{children:h.jsx(XC,{})})},{path:"mcp/executions",element:h.jsx(Ee,{children:h.jsx(LC,{})})},{path:"mcp/executions/:jobId",element:h.jsx(Ee,{children:h.jsx(qC,{})})},{path:"files",element:h.jsx(Ee,{children:h.jsx(b3,{})})},{path:"knowledge",element:h.jsx(Ee,{children:h.jsx(x3,{})})},{element:h.jsx(TC,{}),children:[{path:"mcp",element:h.jsx(Ee,{children:h.jsx(DC,{})})},{path:"mcp/queries",element:h.jsx(Ee,{children:h.jsx(BC,{})})},{path:"mcp/queries/:workflowId",element:h.jsx(Ee,{children:h.jsx(PC,{})})},{path:"mcp/tools",element:h.jsx(wn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:h.jsx(Ee,{children:h.jsx(n3,{})})},{path:"mcp/servers/new",element:h.jsx(Ee,{children:h.jsx(Qb,{})})},{path:"mcp/servers/:serverId",element:h.jsx(Ee,{children:h.jsx(Qb,{})})}]}]},{path:"pace",element:h.jsx(Ee,{children:h.jsx(Wb,{})})},{path:"trends",element:h.jsx(Ee,{children:h.jsx(Wb,{})})},{path:"operations",element:h.jsx(wn,{to:"/pace",replace:!0})},{element:h.jsx(Wc,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:h.jsx(Ee,{children:h.jsx(ZC,{})})},{path:"admin/users",element:h.jsx(Ee,{children:h.jsx(r3,{})})},{path:"admin/escalation-chains",element:h.jsx(wn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:h.jsx(Ee,{children:h.jsx(s3,{})})},{path:"admin/roles/:role",element:h.jsx(Ee,{children:h.jsx(i3,{})})},{path:"admin/roles/:role/schema",element:h.jsx(Ee,{children:h.jsx(l3,{})})},{path:"admin/roles/:role/list-schema",element:h.jsx(Ee,{children:h.jsx(u3,{})})},{path:"admin/scan-codes",element:h.jsx(Ee,{children:h.jsx(f3,{})})},{path:"admin/scan-codes/:version",element:h.jsx(Ee,{children:h.jsx(h3,{})})},{path:"admin/personas",element:h.jsx(Ee,{children:h.jsx(a3,{})})},{path:"admin/personas/:key",element:h.jsx(Ee,{children:h.jsx(o3,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:h.jsx(wn,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:h.jsx(CC,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:h.jsx(Ee,{children:h.jsx(m3,{})})}]},{path:"admin/controlplane",element:h.jsx(Ee,{children:h.jsx(p3,{})})},{path:"admin/streams",element:h.jsx(Ee,{children:h.jsx(y3,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function k3(){return h.jsx(sS,{client:Fv,children:h.jsx(QS,{children:h.jsx(ZO,{children:h.jsx(oS,{router:j3})})})})}mv(dv());const zm=document.createElement("link");zm.rel="stylesheet";zm.href=`${Ht}/api/settings/custom.css`;document.head.appendChild(zm);IS.createRoot(document.getElementById("root")).render(h.jsx(E.StrictMode,{children:h.jsx(k3,{})}));export{Pt as $,jk as A,Y5 as B,Um as C,fC as D,s5 as E,Bv as F,K5 as G,jm as H,cT as I,VT as J,uT as K,xT as L,RN as M,Xt as N,Vx as O,Z3 as P,Sm as Q,m5 as R,DT as S,p5 as T,y5 as U,g5 as V,b5 as W,v5 as X,mA as Y,Nu as Z,r5 as _,nM as a,ti as a$,Xd as a0,pT as a1,F3 as a2,Z5 as a3,Mm as a4,Zi as a5,bs as a6,c5 as a7,V3 as a8,Zx as a9,Dv as aA,iM as aB,tM as aC,lv as aD,S5 as aE,lM as aF,eM as aG,uM as aH,cM as aI,q3 as aJ,B3 as aK,I3 as aL,$3 as aM,P3 as aN,U3 as aO,z3 as aP,K3 as aQ,X3 as aR,J3 as aS,X5 as aT,H3 as aU,wm as aV,Q3 as aW,yT as aX,W3 as aY,G3 as aZ,q5 as a_,tT as aa,fk as ab,z5 as ac,Nk as ad,fc as ae,f5 as af,h5 as ag,Ru as ah,kk as ai,wN as aj,J5 as ak,bv as al,lk as am,Dm as an,dA as ao,a5 as ap,C5 as aq,o5 as ar,d5 as as,x5 as at,cA as au,Dg as av,D3 as aw,oM as ax,sM as ay,rM as az,A5 as b,_o as b0,fM as b1,kx as b2,D5 as b3,Ht as b4,lx as b5,L3 as b6,hT as b7,W5 as b8,ev as b9,hM as bA,dM as bB,Hv as bC,vm as bD,Yx as bE,M5 as bF,Ub as ba,xv as bb,N5 as bc,P5 as bd,Cm as be,B5 as bf,qr as bg,Kx as bh,L5 as bi,Wi as bj,Y3 as bk,_k as bl,H5 as bm,Wj as bn,G5 as bo,V5 as bp,$5 as bq,F5 as br,qm as bs,Kj as bt,Tk as bu,Ae as bv,I5 as bw,t5 as bx,k5 as by,DN as bz,Zn as c,U5 as d,_5 as e,Jj as f,cv as g,NA as h,e5 as i,on as j,On as k,w5 as l,fe as m,aM as n,E5 as o,O5 as p,i5 as q,l5 as r,u5 as s,j5 as t,R5 as u,n5 as v,Pm as w,Q5 as x,$x as y,T5 as z};
67
+ //# sourceMappingURL=index-BUYokcrl.js.map