ryco-cli 0.1.24 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/dist/{AcpNativeLogging-COepku4a.cjs → AcpNativeLogging-CA6XYzIS.cjs} +1 -1
  2. package/dist/{AcpNativeLogging-D7e1dn7s.mjs → AcpNativeLogging-D4-VoHrq.mjs} +1 -1
  3. package/dist/{AzureDevOpsSourceControlProvider-BNGEg1R8.mjs → AzureDevOpsSourceControlProvider-B_E0XXfD.mjs} +2 -2
  4. package/dist/{AzureDevOpsSourceControlProvider-CrvgKNf2.cjs → AzureDevOpsSourceControlProvider-COmd21c-.cjs} +2 -2
  5. package/dist/{BitbucketSourceControlProvider-BzhsQwH-.cjs → BitbucketSourceControlProvider-CD8IvXQK.cjs} +2 -2
  6. package/dist/{BitbucketSourceControlProvider-Bt21jw68.mjs → BitbucketSourceControlProvider-pUKsNXcg.mjs} +2 -2
  7. package/dist/{ClaudeDriver-C4yu7Jit.mjs → ClaudeDriver-CGifBixr.mjs} +2 -2
  8. package/dist/{ClaudeDriver-B7mbf51W.cjs → ClaudeDriver-Dry5uJfX.cjs} +2 -2
  9. package/dist/{CodexDriver-CR0S17Lb.cjs → CodexDriver-BzR8gA8w.cjs} +3 -3
  10. package/dist/{CodexDriver-DnnqkGoY.mjs → CodexDriver-V4CL9APE.mjs} +3 -3
  11. package/dist/{CodexTextGeneration-tlfe1S5W.cjs → CodexTextGeneration-DTrSzY-I.cjs} +1 -1
  12. package/dist/{CodexTextGeneration-Cw-FZbSS.mjs → CodexTextGeneration-DoCidwvI.mjs} +1 -1
  13. package/dist/{CopilotDriver-GxKLX5pL.mjs → CopilotDriver-Dt13X60f.mjs} +3 -3
  14. package/dist/{CopilotDriver-IBd27Ji2.cjs → CopilotDriver-rLcA8PSN.cjs} +3 -3
  15. package/dist/{CursorDriver-C4Enoe9N.cjs → CursorDriver-C3s-8s9F.cjs} +3 -3
  16. package/dist/{CursorDriver-CNo9Uzo8.mjs → CursorDriver-HIPUs7cz.mjs} +3 -3
  17. package/dist/{ForgejoSourceControlProvider-BGXysSX6.mjs → ForgejoSourceControlProvider-CmvOAzEG.mjs} +2 -2
  18. package/dist/{ForgejoSourceControlProvider-Dh6DOoc8.cjs → ForgejoSourceControlProvider-JgiyrMqp.cjs} +2 -2
  19. package/dist/{GitHubSourceControlProvider-CPCYV8Xo.mjs → GitHubSourceControlProvider-BYuvbcBf.mjs} +2 -2
  20. package/dist/{GitHubSourceControlProvider-8hsv_kCE.cjs → GitHubSourceControlProvider-CItCpOcC.cjs} +2 -2
  21. package/dist/{GitLabSourceControlProvider-B0ZbF9Zx.cjs → GitLabSourceControlProvider-CMce22nU.cjs} +2 -2
  22. package/dist/{GitLabSourceControlProvider-Bvknpaon.mjs → GitLabSourceControlProvider-DZzEaVSi.mjs} +2 -2
  23. package/dist/{GrokDriver-DSPEmiwq.mjs → GrokDriver-CduUwiOH.mjs} +3 -3
  24. package/dist/{GrokDriver-RyyFeh_q.cjs → GrokDriver-D0jraOC_.cjs} +3 -3
  25. package/dist/{OpenCodeDriver-0q44rSQX.mjs → OpenCodeDriver-Bz_uJdMA.mjs} +2 -2
  26. package/dist/{OpenCodeDriver-CDcvPT9v.cjs → OpenCodeDriver-DxGpgtDS.cjs} +2 -2
  27. package/dist/{SourceControlProviderDiscoveryCatalog-DreaAH1H.cjs → SourceControlProviderDiscoveryCatalog-Dm_lhrhv.cjs} +1 -1
  28. package/dist/{SourceControlProviderDiscoveryCatalog-B37RHe2u.mjs → SourceControlProviderDiscoveryCatalog-ZtwPWoxE.mjs} +1 -1
  29. package/dist/bin.cjs +291 -176
  30. package/dist/bin.mjs +291 -176
  31. package/dist/client/assets/AccountSettings-Bv57-JYy.js +1 -0
  32. package/dist/client/assets/{AiFocusSettings-CNmGHEcA.js → AiFocusSettings-DCPHmJpA.js} +1 -1
  33. package/dist/client/assets/{AnimatedHeight-i0YhvlGD.js → AnimatedHeight-DPqb09B0.js} +1 -1
  34. package/dist/client/assets/{AppearanceSettings-BG8W4DP0.js → AppearanceSettings-EmTrtb_U.js} +1 -1
  35. package/dist/client/assets/{BranchToolbar.logic-AgPy06Mx.js → BranchToolbar.logic-CHRK3hDt.js} +1 -1
  36. package/dist/client/assets/{BrowserPanel-BWztlNuL.js → BrowserPanel-2Xu08il5.js} +1 -1
  37. package/dist/client/assets/ChatRightPanel-C1VD6GCV.js +194 -0
  38. package/dist/client/assets/{ChatThreadRouteView-CWoBLzR_.js → ChatThreadRouteView-CNww3i2J.js} +1 -1
  39. package/dist/client/assets/CommandPaletteDialog-B_f3fKp7.js +1 -0
  40. package/dist/client/assets/{CompositeRoot-C1G-Ejus.js → CompositeRoot-B40iitmH.js} +1 -1
  41. package/dist/client/assets/ComputerUseSettings-BJs7jqR0.js +1 -0
  42. package/dist/client/assets/ConnectionsSettings-B9nfvgLG.js +7 -0
  43. package/dist/client/assets/ContextHandoffEndpointLabel-BSQOArMR.js +4 -0
  44. package/dist/client/assets/{DiagnosticsSettings-DvnNz2AZ.js → DiagnosticsSettings-BmrqOKMe.js} +1 -1
  45. package/dist/client/assets/{DialogHandle-8o3kfoiI.js → DialogHandle-pelzaaiH.js} +1 -1
  46. package/dist/client/assets/{DialogPopup-CLw6NCkW.js → DialogPopup-BLM0vN4N.js} +1 -1
  47. package/dist/client/assets/DialogRoot-CY6ZzEUS.js +1 -0
  48. package/dist/client/assets/{DialogTitle-DCHX74Tz.js → DialogTitle-BvIjMtMm.js} +1 -1
  49. package/dist/client/assets/{DialogTrigger-Bl_fcIV2.js → DialogTrigger-CIeVAA-a.js} +1 -1
  50. package/dist/client/assets/{DialogViewport-DVDl03yd.js → DialogViewport-Cz0OadGI.js} +1 -1
  51. package/dist/client/assets/{DraftChatThreadRouteView-CEDYjbKq.js → DraftChatThreadRouteView-DMIGMESb.js} +1 -1
  52. package/dist/client/assets/{ExternalIdentityWeb.logic-arHvT6AX.js → ExternalIdentityWeb.logic-3rlDV7lT.js} +1 -1
  53. package/dist/client/assets/{GlassSurface-GY6owikG.js → GlassSurface-CEVIdyfP.js} +1 -1
  54. package/dist/client/assets/{HostedConnectionControls-COUhSe9x.js → HostedConnectionControls-r9cyZPyF.js} +1 -1
  55. package/dist/client/assets/HostedHubRoot-BkfafJ5x.js +2 -0
  56. package/dist/client/assets/{HostedNativeAuthorizationRoute-DZhYxv--.js → HostedNativeAuthorizationRoute-CqHuW853.js} +2 -2
  57. package/dist/client/assets/HostedNodeRenameDialog-C7m-nvTj.js +1 -0
  58. package/dist/client/assets/{HostedRelayTrustNotice-Bl6On0Yi.js → HostedRelayTrustNotice-DNZQyAX0.js} +1 -1
  59. package/dist/client/assets/IntegrationsSettingsPanel-hul3ysgL.js +2 -0
  60. package/dist/client/assets/{KeybindingsSettings-CPtXx-W2.js → KeybindingsSettings-Cme6omBM.js} +1 -1
  61. package/dist/client/assets/{LazyBrowserPanel-SUIBB7B4.js → LazyBrowserPanel-COJFwNK7.js} +2 -2
  62. package/dist/client/assets/{McpServersSettings-BWIUud0Z.js → McpServersSettings-CPeNF8_u.js} +4 -4
  63. package/dist/client/assets/{MobileSheet-NTayGHF6.js → MobileSheet-BZo-RAfm.js} +1 -1
  64. package/dist/client/assets/{NodeSecuritySettings-BFifrshE.js → NodeSecuritySettings-CwT5nEW9.js} +1 -1
  65. package/dist/client/assets/{OpinionatedPluginsSettings-D7WuuNWZ.js → OpinionatedPluginsSettings-D8A1CbMG.js} +1 -1
  66. package/dist/client/assets/{PhoneGetAppInterstitial-R0cqI17q.js → PhoneGetAppInterstitial-BBnGXVkR.js} +1 -1
  67. package/dist/client/assets/PhoneHome-BTKOPVjw.js +1 -0
  68. package/dist/client/assets/PhoneSettingsSurface-DdVCndyt.js +2 -0
  69. package/dist/client/assets/{ProviderModelPicker-dwWhl7Uf.js → ProviderModelPicker-DoYEUZrn.js} +1 -1
  70. package/dist/client/assets/ProvidersSettingsPanel-ldDCPVIY.js +1 -0
  71. package/dist/client/assets/{QuitShortcutFeedback-CklL3jMd.js → QuitShortcutFeedback-mF7X0WMD.js} +1 -1
  72. package/dist/client/assets/{RedactedSensitiveText-CLPBtvH1.js → RedactedSensitiveText-DovqFcmM.js} +1 -1
  73. package/dist/client/assets/RootAppShell-CzmEWO9w.js +7 -0
  74. package/dist/client/assets/{Separator-CpYBhf-I.js → Separator-BhAVTIOc.js} +1 -1
  75. package/dist/client/assets/SettingsDialog-ByXgBN0U.js +2 -0
  76. package/dist/client/assets/SettingsPanels-Bgf4vkrJ.js +3 -0
  77. package/dist/client/assets/{SettingsPanels.editor-9pSZP875.js → SettingsPanels.editor-d-rVlbeN.js} +1 -1
  78. package/dist/client/assets/SourceControlSettings-dKw0FaN1.js +1 -0
  79. package/dist/client/assets/{StatisticsPage-C7v-6CTr.js → StatisticsPage-C2RuqDIK.js} +1 -1
  80. package/dist/client/assets/{StatisticsPanel-CeIjiBm8.js → StatisticsPanel-DqoXnrhQ.js} +1 -1
  81. package/dist/client/assets/{StatisticsSettingsLink-5s_violW.js → StatisticsSettingsLink-C_f31sb4.js} +1 -1
  82. package/dist/client/assets/{ThreadTerminalDrawer-CHZ60lPI.js → ThreadTerminalDrawer-DaLrSTn9.js} +11 -11
  83. package/dist/client/assets/{ThreadWorkspacePanel-Ct5kMcuY.js → ThreadWorkspacePanel-BvRZIxZQ.js} +17 -17
  84. package/dist/client/assets/{activity-BMBx2Fu0.js → activity-bn_fBQGf.js} +1 -1
  85. package/dist/client/assets/{alert-CXnC_RJc.js → alert-BmLJh6DH.js} +1 -1
  86. package/dist/client/assets/{appChrome-BzM66lXM.js → appChrome-Dy57Ve9N.js} +1 -1
  87. package/dist/client/assets/{arrow-left-CymyVbCi.js → arrow-left-pzj1cbX3.js} +1 -1
  88. package/dist/client/assets/{arrow-right-9wyq4YVq.js → arrow-right-BW5jU-vo.js} +1 -1
  89. package/dist/client/assets/{arrow-up-right-mfU38K6p.js → arrow-up-right-AfC5AaSO.js} +1 -1
  90. package/dist/client/assets/authorization-7xVVtCBu.js +1 -0
  91. package/dist/client/assets/{badge-Dg7mXiOh.js → badge-DnBuGHGL.js} +1 -1
  92. package/dist/client/assets/{bot-BR3RyOWP.js → bot-CsKkSRlb.js} +1 -1
  93. package/dist/client/assets/{capabilities-C8sxDbKT.js → capabilities-DskyVNd2.js} +1 -1
  94. package/dist/client/assets/{chart-column-CcRi3pAd.js → chart-column-DhvWXIiH.js} +1 -1
  95. package/dist/client/assets/chevron-right-CITtTwME.js +1 -0
  96. package/dist/client/assets/{clipboard-copy-ezz8rnaT.js → clipboard-copy-fJnfdl4H.js} +1 -1
  97. package/dist/client/assets/{data-list-ZLhzdlED.js → data-list-_E-Al1sf.js} +1 -1
  98. package/dist/client/assets/{desktopWorkspace-P28r2lN2.js → desktopWorkspace-DycXKuMm.js} +1 -1
  99. package/dist/client/assets/{download-BA9L9tK9.js → download-CLQzE1di.js} +1 -1
  100. package/dist/client/assets/{editorPreferences-DeKdSV3s.js → editorPreferences-Bg624RVT.js} +1 -1
  101. package/dist/client/assets/{empty-3NpXLnAM.js → empty-YXFtCUDN.js} +1 -1
  102. package/dist/client/assets/{group-D5qBdsaB.js → group-DOCkUmuY.js} +1 -1
  103. package/dist/client/assets/{hostedConnectionCoordinator-CLV-JD1S.js → hostedConnectionCoordinator-JZ1dLx4v.js} +1 -1
  104. package/dist/client/assets/{hubRoutes-EWJ3Gdod.js → hubRoutes-C2S5of9_.js} +1 -1
  105. package/dist/client/assets/{index-DxCd1PgA.js → index-CvRFRkBK.js} +2 -2
  106. package/dist/client/assets/{input-DrOL1KPS.js → input-C2xv8mMt.js} +1 -1
  107. package/dist/client/assets/{kbd-rWDjJnWX.js → kbd-4-4mGdIa.js} +1 -1
  108. package/dist/client/assets/{key-round-D2DtQ7aS.js → key-round-CYcb9lAa.js} +1 -1
  109. package/dist/client/assets/{layers-DtSJWmwy.js → layers-CGlOWYxu.js} +1 -1
  110. package/dist/client/assets/{log-out-YAp9fsOg.js → log-out-CZW2EpNJ.js} +1 -1
  111. package/dist/client/assets/{logging-BuUPX1SP.js → logging-BpmZOfmu.js} +1 -1
  112. package/dist/client/assets/main-CC-U8LrA.css +2 -0
  113. package/dist/client/assets/main-CzDOnLFw.js +9 -0
  114. package/dist/client/assets/{palette-D18VboLH.js → palette-CQOuNfSO.js} +1 -1
  115. package/dist/client/assets/{play-d3KUi4G6.js → play-CPVy9wwV.js} +1 -1
  116. package/dist/client/assets/primary-CjhRI8fe.js +2 -0
  117. package/dist/client/assets/providerDriverMeta-BVHpFupf.js +1 -0
  118. package/dist/client/assets/providerModels-BsybzP4P.js +1 -0
  119. package/dist/client/assets/{qr-code-Bk1kdf_k.js → qr-code-BPqDlVMn.js} +1 -1
  120. package/dist/client/assets/{qr-code-MAZkoKtL.js → qr-code-C6BVTc4V.js} +1 -1
  121. package/dist/client/assets/{radio-group-D-VCGinX.js → radio-group-C8qudOQH.js} +2 -2
  122. package/dist/client/assets/{refresh-cw-DY3_Ph-S.js → refresh-cw-B5Cz1z3e.js} +1 -1
  123. package/dist/client/assets/runtime-Bxg7k81u.js +17 -0
  124. package/dist/client/assets/{save-ugJXuJRM.js → save-C7zM6ey6.js} +1 -1
  125. package/dist/client/assets/{scroll-area-BMnGzd2a.js → scroll-area-5OU_pvTW.js} +1 -1
  126. package/dist/client/assets/{scrollEdges-QLSFwGSQ.js → scrollEdges-qnEXfIOg.js} +1 -1
  127. package/dist/client/assets/{separator-BwUYkCkX.js → separator-B5HfRiaO.js} +1 -1
  128. package/dist/client/assets/{settingsLayout-C6SUmJVB.js → settingsLayout-CfKq88KD.js} +1 -1
  129. package/dist/client/assets/{sheet-DLy4aeVa.js → sheet-B9gQDy_I.js} +1 -1
  130. package/dist/client/assets/{shield-alert-DfUhTI4-.js → shield-alert-7yBlEyOs.js} +1 -1
  131. package/dist/client/assets/{shield-check-CO4SMhAs.js → shield-check-CnKgVJ0F.js} +1 -1
  132. package/dist/client/assets/{shield-Zq_ygsnJ.js → shield-rdjnBE2Q.js} +1 -1
  133. package/dist/client/assets/{sidebar-DNnW-a2V.js → sidebar-BdvL1Pbj.js} +1 -1
  134. package/dist/client/assets/sidebarProjectFolders-BH8XBqNe.js +4 -0
  135. package/dist/client/assets/{sidebarStatusText-CawrXnx0.js → sidebarStatusText-CZKsUFBD.js} +1 -1
  136. package/dist/client/assets/{skeleton-DRm4_OvB.js → skeleton-CoyLqyaB.js} +1 -1
  137. package/dist/client/assets/{smartphone-O2VACDhU.js → smartphone-CBgpMHXR.js} +1 -1
  138. package/dist/client/assets/{sparkles-isHutYWU.js → sparkles-w-UZXQx1.js} +1 -1
  139. package/dist/client/assets/src-Bi-5Nw9C.js +14 -0
  140. package/dist/client/assets/{star-7UHEnC3x.js → star-BZ-RtSFD.js} +1 -1
  141. package/dist/client/assets/switch-CEJEmLe7.js +48 -0
  142. package/dist/client/assets/{toggle-CaKBNe6W.js → toggle-DVGrNHjq.js} +1 -1
  143. package/dist/client/assets/{toggle-group-UeFeTI3u.js → toggle-group-CNDOfNhH.js} +1 -1
  144. package/dist/client/assets/{tokenModePresentation-DV56ekA4.js → tokenModePresentation-CQNdC9CW.js} +1 -1
  145. package/dist/client/assets/{tooltip-DXvXxL37.js → tooltip-B7Z4qomY.js} +1 -1
  146. package/dist/client/assets/{unplug-DisTpujT.js → unplug-CRUwFNFw.js} +1 -1
  147. package/dist/client/assets/useAppSidebarCollapsed-wq6czkNJ.js +1 -0
  148. package/dist/client/assets/useBaseUiId-OYaGjnkh.js +1 -0
  149. package/dist/client/assets/{useLabelableId-BsDFG9Oj.js → useLabelableId-VMc-yITe.js} +1 -1
  150. package/dist/client/assets/{useNavigate-cLfxn_9L.js → useNavigate-DVi0rBlf.js} +1 -1
  151. package/dist/client/assets/{usePhoneThreadActions-rekHL1Mi.js → usePhoneThreadActions-CwwHikjB.js} +1 -1
  152. package/dist/client/assets/{usePopupViewport-kXU31P6l.js → usePopupViewport-BcSIK_ph.js} +1 -1
  153. package/dist/client/assets/{useScrollLock-DjMxrUJe.js → useScrollLock-BQf9VYJT.js} +1 -1
  154. package/dist/client/assets/{useStatistics-BYP-9CmW.js → useStatistics-DczKdEfy.js} +1 -1
  155. package/dist/client/assets/{useTriggerFocusGuards-DuAm2B8C.js → useTriggerFocusGuards-DjP-D0_a.js} +1 -1
  156. package/dist/client/assets/{useValueChanged-DreFjrMK.js → useValueChanged-CRwCkFdy.js} +1 -1
  157. package/dist/client/assets/{user-round-DctamWV6.js → user-round-DStbWN3z.js} +1 -1
  158. package/dist/client/assets/{vscode-icons-Dw-LGJAv.js → vscode-icons-BihBo3tb.js} +1 -1
  159. package/dist/client/assets/{workspaceMetadataProjection-BL4sEIL2.js → workspaceMetadataProjection-j3BGlVOB.js} +1 -1
  160. package/dist/client/assets/{wrench-Ds8eZerZ.js → wrench-BBIgGxy9.js} +1 -1
  161. package/dist/client/index.html +1 -1
  162. package/dist/{collectUint8StreamText-C_VNyArd.mjs → collectUint8StreamText-CE1Re5Ij.mjs} +41 -3
  163. package/dist/{collectUint8StreamText-DStwNTTK.cjs → collectUint8StreamText-whblCEfg.cjs} +52 -2
  164. package/dist/{makeManagedServerProvider-GZcpSLrW.mjs → makeManagedServerProvider-CwYhl_P-.mjs} +1 -1
  165. package/dist/{makeManagedServerProvider-VzxWN-04.cjs → makeManagedServerProvider-Dy2Ny9tk.cjs} +1 -1
  166. package/dist/resource-monitor/ryco-resource-monitor +0 -0
  167. package/dist/resource-monitor/ryco-resource-monitor.exe +0 -0
  168. package/dist/resource-monitor/win32-arm64/ryco-resource-monitor.exe +0 -0
  169. package/dist/resource-monitor/win32-x64/ryco-resource-monitor.exe +0 -0
  170. package/package.json +1 -1
  171. package/dist/client/assets/AccountSettings-ApnDA1f-.js +0 -1
  172. package/dist/client/assets/ChatRightPanel-a6UOHNMm.js +0 -194
  173. package/dist/client/assets/CommandPaletteDialog-B2iKWCUi.js +0 -1
  174. package/dist/client/assets/ComputerUseSettings-CPwWoHWj.js +0 -1
  175. package/dist/client/assets/ConnectionsSettings-CPMkuxza.js +0 -7
  176. package/dist/client/assets/ContextHandoffEndpointLabel-BildLLDY.js +0 -4
  177. package/dist/client/assets/DialogRoot-SKkIuQHA.js +0 -1
  178. package/dist/client/assets/HostedHubRoot-BTWc0XoQ.js +0 -2
  179. package/dist/client/assets/IntegrationsSettingsPanel-n9owMZf-.js +0 -2
  180. package/dist/client/assets/PhoneHome-FqWvnJP_.js +0 -1
  181. package/dist/client/assets/PhoneSettingsSurface-w5PJnoBc.js +0 -2
  182. package/dist/client/assets/ProvidersSettingsPanel-Ww1ch3xA.js +0 -1
  183. package/dist/client/assets/RootAppShell-BdQCs2XJ.js +0 -7
  184. package/dist/client/assets/SettingsDialog-DeMzEeCP.js +0 -2
  185. package/dist/client/assets/SettingsPanels-ZxNz9ZfL.js +0 -3
  186. package/dist/client/assets/SourceControlSettings-C1F3Brcn.js +0 -1
  187. package/dist/client/assets/authorization-CjOFkg7b.js +0 -1
  188. package/dist/client/assets/chevron-right-CuUjBsQV.js +0 -1
  189. package/dist/client/assets/main-BbtLAX7M.js +0 -9
  190. package/dist/client/assets/main-D4CtFNPY.css +0 -2
  191. package/dist/client/assets/monitor-OyD484tI.js +0 -1
  192. package/dist/client/assets/primary-D_D7eLwT.js +0 -2
  193. package/dist/client/assets/providerDriverMeta-DNTocCcU.js +0 -1
  194. package/dist/client/assets/providerModels-bFbEIfL9.js +0 -1
  195. package/dist/client/assets/runtime-Djy96GJd.js +0 -17
  196. package/dist/client/assets/sidebarProjectFolders-ygpaKZM6.js +0 -4
  197. package/dist/client/assets/src-BSuAGqhK.js +0 -14
  198. package/dist/client/assets/switch-DD1qVLgN.js +0 -48
  199. package/dist/client/assets/useAppSidebarCollapsed-CaAsLi1q.js +0 -1
  200. package/dist/client/assets/useBaseUiId-CJN4MvrU.js +0 -1
@@ -1 +0,0 @@
1
- import{$n as e,$r as t,$t as n,An as r,Ar as i,At as a,B as o,Bn as s,Bt as c,Cn as l,Cr as u,Ct as d,Dn as f,Dr as p,Dt as m,En as h,Er as g,Et as _,F as v,Fn as y,Ft as b,Gn as ee,Gr as x,Gt as S,Hn as C,Ht as w,In as T,It as E,Jn as D,Jt as O,Kn as k,Kr as A,Kt as j,Ln as M,Lt as N,Mn as P,Mr as te,Mt as ne,Nn as F,Nr as re,On as ie,Or as ae,Ot as oe,Pn as se,Pr as ce,Pt as le,Qn as ue,Qt as de,Rn as fe,Rt as pe,Sn as me,Sr as he,St as ge,Tn as _e,Tr as ve,Tt as ye,Un as be,Ur as xe,Ut as Se,Vn as Ce,Vt as we,Wn as Te,Wt as Ee,Xn as De,Xt as Oe,Yn as ke,Yr as Ae,Yt as je,Zn as Me,Zt as Ne,_n as Pe,_r as Fe,_t as Ie,an as Le,ar as Re,bn as ze,br as Be,bt as Ve,cn as He,cr as Ue,da as We,dn as Ge,dr as Ke,dt as qe,en as Je,er as Ye,f as Xe,fn as Ze,fr as Qe,ft as $e,gn as et,gr as tt,gt as nt,hn as rt,hr as it,ht as at,in as ot,ir as st,jn as ct,jr as lt,jt as ut,kn as dt,kr as ft,kt as pt,la as mt,ln as ht,lr as gt,mn as _t,mr as vt,mt as yt,nn as bt,nr as xt,on as St,or as Ct,pn as wt,pr as Tt,pt as Et,qn as Dt,qr as Ot,qt as kt,rn as At,rr as jt,sn as Mt,sr as Nt,t as I,tn as Pt,tr as Ft,u as It,uc as Lt,un as Rt,ur as zt,vn as Bt,vr as Vt,vt as Ht,wn as Ut,wr as Wt,wt as Gt,xn as Kt,xr as qt,xt as Jt,yn as Yt,yr as Xt,yt as Zt,zn as Qt,zt as $t}from"./src-BSuAGqhK.js";function en(e){if(!/^[A-Za-z0-9_-]+$/u.test(e))throw Error(`Invalid encoded material.`);let t=e.replace(/-/gu,`+`).replace(/_/gu,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n;try{n=atob(t)}catch{throw Error(`Invalid encoded material.`)}let r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return r}function tn(e){let t=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/gu,`-`).replace(/\//gu,`_`).replace(/=+$/gu,``)}var nn=Uint8Array.from([32,9,13,10,32,9,13,10]);function rn(e){return e.byteLength>=8&&e[0]===0}function an(e){if(e.byteLength<nn.byteLength)return!1;for(let t=0;t<nn.byteLength;t+=1)if(e[t]!==nn[t])return!1;return!0}function on(e){return an(e)?{advertised:!0,message:e.subarray(nn.byteLength)}:{advertised:!1,message:e}}function sn(e,t,n){e[0]=0,e[1]=1,e[2]=+!!n,e[3]=0,e[4]=t>>>24&255,e[5]=t>>>16&255,e[6]=t>>>8&255,e[7]=t&255}function cn(e){return(e[4]<<24>>>0)+(e[5]<<16>>>0)+(e[6]<<8>>>0)+e[7]}function ln(e,t){if(e.byteLength<=t)return[e];let n=t-8;if(n<=0)throw Error(`Relay chunk limit is too small to carry a chunk header.`);let r=[];for(let t=0;t<e.byteLength;t+=n){let i=e.subarray(t,Math.min(t+n,e.byteLength)),a=new Uint8Array(8+i.byteLength);sn(a,e.byteLength,t+i.byteLength>=e.byteLength),a.set(i,8),r.push(a)}return r}function un(e,t){if(!Number.isSafeInteger(t.maxChunkBytes)||t.maxChunkBytes<=0||!Number.isSafeInteger(t.maxMessageBytes)||t.maxMessageBytes<0||!Number.isSafeInteger(e)||e<0)throw TypeError(`Relay chunk limits must be positive and message limits non-negative safe integers.`);if(e>t.maxMessageBytes)return{kind:`error`,reason:`message_too_large`};if(e<=t.maxChunkBytes){let n=e+nn.byteLength<=t.maxChunkBytes;return{kind:`ready`,advertised:n,chunked:!1,payloadBytes:[n?nn.byteLength+e:e]}}if(!t.peerSupportsChunking)return{kind:`error`,reason:`peer_unsupported`};let n=t.maxChunkBytes-8;if(n<=0)throw Error(`Relay chunk limit is too small to carry a chunk header.`);let r=[];for(let t=0;t<e;t+=n)r.push(8+Math.min(n,e-t));return{kind:`ready`,advertised:!1,chunked:!0,payloadBytes:r}}function dn(e,t){let n=un(e.byteLength,t);if(n.kind===`error`)return n;if(n.chunked)return{kind:`ready`,payloads:ln(e,t.maxChunkBytes)};if(!n.advertised)return{kind:`ready`,payloads:[e]};let r=new Uint8Array(nn.byteLength+e.byteLength);return r.set(nn),r.set(e,nn.byteLength),{kind:`ready`,payloads:[r]}}var fn=class{#e=[];#t=0;#n=0;#r=!1;get heldBytes(){return this.#t}get incompleteMessage(){return this.#n!==0}get peerSupportsChunking(){return this.#r}push(e){if(!rn(e)){if(this.#n!==0)return this.reset(),{kind:`error`,reason:`interleaved_legacy`};let t=on(e);return t.advertised&&(this.#r=!0),{kind:`done`,message:t.message}}if(e[1]!==1||e[2]&-2||e[3]!==0)return this.reset(),{kind:`error`,reason:`bad_header`};let t=cn(e),n=e.subarray(8),r=!!(e[2]&1);if(n.byteLength===0)return this.reset(),{kind:`error`,reason:`bad_header`};if(this.#n===0){if(t>4194304||t===0)return{kind:`error`,reason:`message_too_large`};this.#n=t,this.#t=0}else if(t!==this.#n)return this.reset(),{kind:`error`,reason:`total_mismatch`};if(this.#t+n.byteLength>this.#n)return this.reset(),{kind:`error`,reason:`overflow`};this.#r=!0;let i=Uint8Array.from(n);if(n.fill(0),this.#e.push(i),this.#t+=n.byteLength,!r)return{kind:`pending`};if(this.#t!==this.#n)return this.reset(),{kind:`error`,reason:`truncated`};let a=new Uint8Array(this.#n),o=0;for(let e of this.#e)a.set(e,o),o+=e.byteLength,e.fill(0);return this.#e=[],this.#t=0,this.#n=0,{kind:`done`,message:a}}reset(){for(let e of this.#e)e.fill(0);this.#e=[],this.#t=0,this.#n=0,this.#r=!1}},pn=4096,mn=8192,hn=Ie;function gn(e){return e.maxQueuedBytes-e.maxControlFrameBytes}function _n(e){let t=Math.min(xe,e.maxQueuedBytes-e.maxControlFrameBytes),n=t-32;return{effectiveMessageCeiling:t,plaintextCeiling:n,establishable:n>0}}var vn=1500,yn=3e3,bn=3e3,xn=1500,Sn=1e3,Cn=4294967295n,wn=18446744073709551615n,Tn={digits:60,groups:12,digitsPerGroup:5,separator:` `},En={chars:8,groups:2,charsPerGroup:4,separator:`-`},Dn=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`;nn.byteLength;var On=8e3,kn=BigInt(2**32-1),An=BigInt(32);function jn(e,t=!1){return t?{h:Number(e&kn),l:Number(e>>An&kn)}:{h:Number(e>>An&kn)|0,l:Number(e&kn)|0}}function Mn(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=jn(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var Nn=e=>e/2**32|0,Pn=e=>e>>>0;function Fn(e,t,n,r){let i=Nn(n),a=Pn(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}var In=(e,t,n)=>e>>>n,Ln=(e,t,n)=>e<<32-n|t>>>n,Rn=(e,t,n)=>e>>>n|t<<32-n,zn=(e,t,n)=>e<<32-n|t>>>n,Bn=(e,t,n)=>e<<64-n|t>>>n-32,Vn=(e,t,n)=>e>>>n-32|t<<64-n;function Hn(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var Un=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Wn=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Gn=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Kn=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,qn=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Jn=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0;function Yn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var Xn=e=>e?`"${e}" `:``;function Zn(e,t=``){if(typeof e!=`number`)throw TypeError(Xn(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(Xn(t)+`expected integer >= 0, got `+e);return e}function Qn(e,t,n=``){if(Yn(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Zn(t,`length`);let r=Yn(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=Xn(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}function $n(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(Zn(e.outputLen),Zn(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}var er=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)};function tr(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function nr(e,t){Qn(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function rr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ir(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ar(e,t){return e<<32-t|e>>>t}var or=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,sr=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function cr(e){if(Qn(e),or)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=sr[e[n]];return t}function lr(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function ur(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(or)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=lr(e.charCodeAt(i)),a=lr(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function dr(e){if(typeof e!=`string`)throw TypeError(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function fr(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];Qn(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function pr(e,t,n=`opts`){return er(e,`defaults`),t!==void 0&&er(t,n),Object.assign(e,t)}function mr(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=pr({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function hr(e=32){Zn(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var gr=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function _r(e,t,n){return e&t^~e&n}function vr(e,t,n){return e&t^e&n^t&n}var yr=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=ir(this.buffer)}update(e){tr(this),Qn(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=ir(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0;continue}n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){tr(this),nr(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),Fn(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:ir(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}},br=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Sr=Uint32Array.from([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]),Cr=new Uint32Array(64),wr=class extends yr{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)Cr[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Cr[e-15],n=Cr[e-2],r=ar(t,7)^ar(t,18)^t>>>3,i=ar(n,17)^ar(n,19)^n>>>10;Cr[e]=i+Cr[e-7]+r+Cr[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=ar(o,6)^ar(o,11)^ar(o,25),u=l+t+_r(o,s,c)+Sr[e]+Cr[e]|0,d=(ar(n,2)^ar(n,13)^ar(n,22))+vr(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){rr(Cr)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),rr(this.buffer)}},Tr=class extends wr{constructor(){super(32,br)}},Er=Mn(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Dr=Er[0],Or=Er[1],kr=new Uint32Array(80),Ar=new Uint32Array(80),jr=class extends yr{Ah=0;Al=0;Bh=0;Bl=0;Ch=0;Cl=0;Dh=0;Dl=0;Eh=0;El=0;Fh=0;Fl=0;Gh=0;Gl=0;Hh=0;Hl=0;constructor(e,t){super(128,e,16,!1),this.Ah=t[0]|0,this.Al=t[1]|0,this.Bh=t[2]|0,this.Bl=t[3]|0,this.Ch=t[4]|0,this.Cl=t[5]|0,this.Dh=t[6]|0,this.Dl=t[7]|0,this.Eh=t[8]|0,this.El=t[9]|0,this.Fh=t[10]|0,this.Fl=t[11]|0,this.Gh=t[12]|0,this.Gl=t[13]|0,this.Hh=t[14]|0,this.Hl=t[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)kr[n]=e.getUint32(t),Ar[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=kr[e-15]|0,n=Ar[e-15]|0,r=Rn(t,n,1)^Rn(t,n,8)^In(t,n,7),i=zn(t,n,1)^zn(t,n,8)^Ln(t,n,7),a=kr[e-2]|0,o=Ar[e-2]|0,s=Rn(a,o,19)^Bn(a,o,61)^In(a,o,6),c=Gn(i,zn(a,o,19)^Vn(a,o,61)^Ln(a,o,6),Ar[e-7],Ar[e-16]),l=Kn(c,r,s,kr[e-7],kr[e-16]);kr[e]=l|0,Ar[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=Rn(u,d,14)^Rn(u,d,18)^Bn(u,d,41),v=zn(u,d,14)^zn(u,d,18)^Vn(u,d,41),y=u&f^~u&m,b=d&p^~d&h,ee=qn(_,v,b,Or[e],Ar[e]),x=Jn(ee,g,t,y,Dr[e],kr[e]),S=ee|0,C=Rn(n,r,28)^Bn(n,r,34)^Bn(n,r,39),w=zn(n,r,28)^Vn(n,r,34)^Vn(n,r,39),T=n&i^n&o^i&o,E=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=Hn(c|0,l|0,x|0,S|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let D=Un(S,w,E);n=Wn(D,x,C,T),r=D|0}({h:n,l:r}=Hn(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=Hn(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=Hn(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=Hn(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=Hn(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=Hn(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=Hn(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=Hn(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){rr(kr,Ar)}destroy(){this.destroyed=!0,rr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Mr=class extends jr{constructor(){super(64,xr)}},L=mr(()=>new Tr,gr(1)),Nr=mr(()=>new Mr,gr(3)),Pr=[`Object`,`RegExp`,`Date`,`Error`,`Map`,`Set`,`WeakMap`,`WeakSet`,`ArrayBuffer`,`SharedArrayBuffer`,`DataView`,`Promise`,`URL`,`HTMLElement`,`Int8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`,`Tagged`];function Fr(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(e===!0||e===!1)return`boolean`;let t=typeof e;return t===`string`||t===`number`||t===`bigint`||t===`symbol`?t:t===`function`?`Function`:Array.isArray(e)?`Array`:e instanceof Uint8Array?`Uint8Array`:e.constructor===Object?`Object`:Ir(e)||`Object`}function Ir(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Pr.includes(t))return t}var R=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:+(this.major>e.major)}static equals(e,t){return e===t||e.major===t.major&&e.name===t.name}};R.uint=new R(0,`uint`,!0),R.negint=new R(1,`negint`,!0),R.bytes=new R(2,`bytes`,!0),R.string=new R(3,`string`,!0),R.array=new R(4,`array`,!1),R.map=new R(5,`map`,!1),R.tag=new R(6,`tag`,!1),R.float=new R(7,`float`,!0),R.false=new R(7,`false`,!0),R.true=new R(7,`true`,!0),R.null=new R(7,`null`,!0),R.undefined=new R(7,`undefined`,!0),R.break=new R(7,`break`,!0);var z=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}},Lr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer==`function`,Rr=new TextEncoder;function zr(e){return Lr&&globalThis.Buffer.isBuffer(e)}function Br(e){return e instanceof Uint8Array?zr(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Vr=24,Hr=200,Ur=Lr?e=>e.length>=Vr?globalThis.Buffer.from(e):Yr(e):e=>e.length>=Hr?Rr.encode(e):Yr(e),Wr=e=>Uint8Array.from(e),Gr=Lr?(e,t,n)=>zr(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n),Kr=Lr?(e,t)=>(e=e.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),Br(globalThis.Buffer.concat(e,t))):(e,t)=>{let n=new Uint8Array(t),r=0;for(let t of e)r+t.length>n.length&&(t=t.subarray(0,n.length-r)),n.set(t,r),r+=t.length;return n},qr=Lr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Jr(e,t){if(zr(e)&&zr(t))return e.compare(t);for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return 0}function Yr(e){let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)==56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(i>=55296&&i<=57343&&(i=65533),t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t}var Xr=256,Zr=class{constructor(e=Xr){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}pushByte(e){let t=this.chunks[this.chunks.length-1];this.cursor>this.maxCursor&&(t=qr(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t));let n=t.length-(this.maxCursor-this.cursor)-1;t[n]=e,this.cursor++}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let n=t.length-(this.maxCursor-this.cursor)-1;t.set(e,n)}else{if(t){let e=t.length-(this.maxCursor-this.cursor)-1;e<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,e),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=qr(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Gr(n,0,this.cursor)}else t=Kr(this.chunks,this.cursor);return e&&this.reset(),t}},Qr=class{constructor(e){this.dest=e,this.cursor=0,this.chunks=[e]}reset(){this.cursor=0}pushByte(e){if(this.cursor>=this.dest.length)throw Error(`write out of bounds, destination buffer is too small`);this.dest[this.cursor++]=e}push(e){if(this.cursor+e.length>this.dest.length)throw Error(`write out of bounds, destination buffer is too small`);this.dest.set(e,this.cursor),this.cursor+=e.length}toBytes(e=!1){let t=this.dest.subarray(0,this.cursor);return e&&this.reset(),t}},B=`CBOR decode error:`,$r=`CBOR encode error:`;function ei(e,t,n){if(e.length-t<n)throw Error(`${B} not enough data for type`)}var ti=[24,256,65536,4294967296,BigInt(`18446744073709551616`)];function ni(e,t,n){ei(e,t,1);let r=e[t];if(n.strict===!0&&r<ti[0])throw Error(`${B} integer encoded in more bytes than necessary (strict decode)`);return r}function ri(e,t,n){ei(e,t,2);let r=e[t]<<8|e[t+1];if(n.strict===!0&&r<ti[1])throw Error(`${B} integer encoded in more bytes than necessary (strict decode)`);return r}function ii(e,t,n){ei(e,t,4);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(n.strict===!0&&r<ti[2])throw Error(`${B} integer encoded in more bytes than necessary (strict decode)`);return r}function ai(e,t,n){ei(e,t,8);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],i=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],a=(BigInt(r)<<BigInt(32))+BigInt(i);if(n.strict===!0&&a<ti[3])throw Error(`${B} integer encoded in more bytes than necessary (strict decode)`);if(a<=2**53-1)return Number(a);if(n.allowBigInt===!0)return a;throw Error(`${B} integers outside of the safe integer range are not supported`)}function oi(e,t,n,r){return new z(R.uint,ni(e,t+1,r),2)}function si(e,t,n,r){return new z(R.uint,ri(e,t+1,r),3)}function ci(e,t,n,r){return new z(R.uint,ii(e,t+1,r),5)}function li(e,t,n,r){return new z(R.uint,ai(e,t+1,r),9)}function ui(e,t){return di(e,0,t.value)}function di(e,t,n){if(n<ti[0]){let r=Number(n);e.pushByte(t|r)}else if(n<ti[1]){let r=Number(n);e.push([t|24,r])}else if(n<ti[2]){let r=Number(n);e.push([t|25,r>>>8,r&255])}else if(n<ti[3]){let r=Number(n);e.push([t|26,r>>>24&255,r>>>16&255,r>>>8&255,r&255])}else{let r=BigInt(n);if(r<ti[4]){let n=[t|27,0,0,0,0,0,0,0],i=Number(r&BigInt(4294967295)),a=Number(r>>BigInt(32)&BigInt(4294967295));n[8]=i&255,i>>=8,n[7]=i&255,i>>=8,n[6]=i&255,i>>=8,n[5]=i&255,n[4]=a&255,a>>=8,n[3]=a&255,a>>=8,n[2]=a&255,a>>=8,n[1]=a&255,e.push(n)}else throw Error(`${B} encountered BigInt larger than allowable range`)}}ui.encodedSize=function(e){return di.encodedSize(e.value)},di.encodedSize=function(e){return e<ti[0]?1:e<ti[1]?2:e<ti[2]?3:e<ti[3]?5:9},ui.compareTokens=function(e,t){return e.value<t.value?-1:+(e.value>t.value)};function fi(e,t,n,r){return new z(R.negint,-1-ni(e,t+1,r),2)}function pi(e,t,n,r){return new z(R.negint,-1-ri(e,t+1,r),3)}function mi(e,t,n,r){return new z(R.negint,-1-ii(e,t+1,r),5)}var hi=BigInt(-1),gi=BigInt(1);function _i(e,t,n,r){let i=ai(e,t+1,r);if(typeof i!=`bigint`){let e=-1-i;if(e>=-(2**53-1))return new z(R.negint,e,9)}if(r.allowBigInt!==!0)throw Error(`${B} integers outside of the safe integer range are not supported`);return new z(R.negint,hi-BigInt(i),9)}function vi(e,t){let n=t.value,r=typeof n==`bigint`?n*hi-gi:n*-1-1;di(e,t.type.majorEncoded,r)}vi.encodedSize=function(e){let t=e.value,n=typeof t==`bigint`?t*hi-gi:t*-1-1;return n<ti[0]?1:n<ti[1]?2:n<ti[2]?3:n<ti[3]?5:9},vi.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function yi(e,t,n,r){ei(e,t,n+r);let i=e.slice(t+n,t+n+r);return new z(R.bytes,i,n+r)}function bi(e,t,n,r){return yi(e,t,1,n)}function xi(e,t,n,r){return yi(e,t,2,ni(e,t+1,r))}function Si(e,t,n,r){return yi(e,t,3,ri(e,t+1,r))}function Ci(e,t,n,r){return yi(e,t,5,ii(e,t+1,r))}function wi(e,t,n,r){let i=ai(e,t+1,r);if(typeof i==`bigint`)throw Error(`${B} 64-bit integer bytes lengths not supported`);return yi(e,t,9,i)}function Ti(e){return e.encodedBytes===void 0&&(e.encodedBytes=R.equals(e.type,R.string)?Ur(e.value):e.value),e.encodedBytes}function Ei(e,t){let n=Ti(t);di(e,t.type.majorEncoded,n.length),e.push(n)}Ei.encodedSize=function(e){let t=Ti(e);return di.encodedSize(t.length)+t.length},Ei.compareTokens=function(e,t){return Di(Ti(e),Ti(t))};function Di(e,t){return e.length<t.length?-1:e.length>t.length?1:Jr(e,t)}var Oi=new TextDecoder,ki=32;function Ai(e,t,n){if(n-t<ki){let r=``;for(let i=t;i<n;i++){let a=e[i];if(a&128)return Oi.decode(e.subarray(t,n));r+=String.fromCharCode(a)}return r}return Oi.decode(e.subarray(t,n))}function ji(e,t,n,r,i){let a=n+r;ei(e,t,a);let o=new z(R.string,Ai(e,t+n,t+a),a);return i.retainStringBytes===!0&&(o.byteValue=e.slice(t+n,t+a)),o}function Mi(e,t,n,r){return ji(e,t,1,n,r)}function Ni(e,t,n,r){return ji(e,t,2,ni(e,t+1,r),r)}function Pi(e,t,n,r){return ji(e,t,3,ri(e,t+1,r),r)}function Fi(e,t,n,r){return ji(e,t,5,ii(e,t+1,r),r)}function Ii(e,t,n,r){let i=ai(e,t+1,r);if(typeof i==`bigint`)throw Error(`${B} 64-bit integer string lengths not supported`);return ji(e,t,9,i,r)}var Li=Ei;function Ri(e,t,n,r){return new z(R.array,r,n)}function zi(e,t,n,r){return Ri(e,t,1,n)}function Bi(e,t,n,r){return Ri(e,t,2,ni(e,t+1,r))}function Vi(e,t,n,r){return Ri(e,t,3,ri(e,t+1,r))}function Hi(e,t,n,r){return Ri(e,t,5,ii(e,t+1,r))}function Ui(e,t,n,r){let i=ai(e,t+1,r);if(typeof i==`bigint`)throw Error(`${B} 64-bit integer array lengths not supported`);return Ri(e,t,9,i)}function Wi(e,t,n,r){if(r.allowIndefinite===!1)throw Error(`${B} indefinite length items not allowed`);return Ri(e,t,1,1/0)}function Gi(e,t){di(e,R.array.majorEncoded,t.value)}Gi.compareTokens=ui.compareTokens,Gi.encodedSize=function(e){return di.encodedSize(e.value)};function Ki(e,t,n,r){return new z(R.map,r,n)}function qi(e,t,n,r){return Ki(e,t,1,n)}function Ji(e,t,n,r){return Ki(e,t,2,ni(e,t+1,r))}function Yi(e,t,n,r){return Ki(e,t,3,ri(e,t+1,r))}function Xi(e,t,n,r){return Ki(e,t,5,ii(e,t+1,r))}function Zi(e,t,n,r){let i=ai(e,t+1,r);if(typeof i==`bigint`)throw Error(`${B} 64-bit integer map lengths not supported`);return Ki(e,t,9,i)}function Qi(e,t,n,r){if(r.allowIndefinite===!1)throw Error(`${B} indefinite length items not allowed`);return Ki(e,t,1,1/0)}function $i(e,t){di(e,R.map.majorEncoded,t.value)}$i.compareTokens=ui.compareTokens,$i.encodedSize=function(e){return di.encodedSize(e.value)};function ea(e,t,n,r){return new z(R.tag,n,1)}function ta(e,t,n,r){return new z(R.tag,ni(e,t+1,r),2)}function na(e,t,n,r){return new z(R.tag,ri(e,t+1,r),3)}function ra(e,t,n,r){return new z(R.tag,ii(e,t+1,r),5)}function ia(e,t,n,r){return new z(R.tag,ai(e,t+1,r),9)}function aa(e,t){di(e,R.tag.majorEncoded,t.value)}aa.compareTokens=ui.compareTokens,aa.encodedSize=function(e){return di.encodedSize(e.value)};function oa(e,t,n,r){if(r.allowUndefined===!1)throw Error(`${B} undefined values are not supported`);return r.coerceUndefinedToNull===!0?new z(R.null,null,1):new z(R.undefined,void 0,1)}function sa(e,t,n,r){if(r.allowIndefinite===!1)throw Error(`${B} indefinite length items not allowed`);return new z(R.break,void 0,1)}function ca(e,t,n){if(n){if(n.allowNaN===!1&&Number.isNaN(e))throw Error(`${B} NaN values are not supported`);if(n.allowInfinity===!1&&(e===1/0||e===-1/0))throw Error(`${B} Infinity values are not supported`)}return new z(R.float,e,t)}function la(e,t,n,r){return ca(_a(e,t+1),3,r)}function ua(e,t,n,r){return ca(ya(e,t+1),5,r)}function da(e,t,n,r){return ca(xa(e,t+1),9,r)}function fa(e,t,n){let r=t.value;if(r===!1)e.pushByte(R.float.majorEncoded|20);else if(r===!0)e.pushByte(R.float.majorEncoded|21);else if(r===null)e.pushByte(R.float.majorEncoded|22);else if(r===void 0)e.pushByte(R.float.majorEncoded|23);else{let t,i=!1;(!n||n.float64!==!0)&&(ga(r),t=_a(ha,1),r===t||Number.isNaN(r)?(ha[0]=249,e.push(ha.slice(0,3)),i=!0):(va(r),t=ya(ha,1),r===t&&(ha[0]=250,e.push(ha.slice(0,5)),i=!0))),i||(ba(r),t=xa(ha,1),ha[0]=251,e.push(ha.slice(0,9)))}}fa.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n==null)return 1;if(!t||t.float64!==!0){ga(n);let e=_a(ha,1);if(n===e||Number.isNaN(n))return 3;if(va(n),e=ya(ha,1),n===e)return 5}return 9};var pa=new ArrayBuffer(9),ma=new DataView(pa,1),ha=new Uint8Array(pa,0);function ga(e){if(e===1/0)ma.setUint16(0,31744,!1);else if(e===-1/0)ma.setUint16(0,64512,!1);else if(Number.isNaN(e))ma.setUint16(0,32256,!1);else{ma.setFloat32(0,e);let t=ma.getUint32(0),n=(t&2139095040)>>23,r=t&8388607;if(n===255)ma.setUint16(0,31744,!1);else if(n===0)ma.setUint16(0,(t&2147483648)>>16|r>>13,!1);else{let e=n-127;e<-24?ma.setUint16(0,0):e<-14?ma.setUint16(0,(t&2147483648)>>16|1<<24+e,!1):ma.setUint16(0,(t&2147483648)>>16|e+15<<10|r>>13,!1)}}}function _a(e,t){if(e.length-t<2)throw Error(`${B} not enough data for float16`);let n=(e[t]<<8)+e[t+1];if(n===31744)return 1/0;if(n===64512)return-1/0;if(n===32256)return NaN;let r=n>>10&31,i=n&1023,a;return a=r===0?i*2**-24:r===31?i===0?1/0:NaN:(i+1024)*2**(r-25),n&32768?-a:a}function va(e){ma.setFloat32(0,e,!1)}function ya(e,t){if(e.length-t<4)throw Error(`${B} not enough data for float32`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function ba(e){ma.setFloat64(0,e,!1)}function xa(e,t){if(e.length-t<8)throw Error(`${B} not enough data for float64`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function Sa(e,t){let n=e.value;if(n===!1)return Uint8Array.of(R.float.majorEncoded|20);if(n===!0)return Uint8Array.of(R.float.majorEncoded|21);if(n===null)return Uint8Array.of(R.float.majorEncoded|22);if(n===void 0)return Uint8Array.of(R.float.majorEncoded|23);if(!t){if(ga(n),n===_a(ha,1)||Number.isNaN(n))return ha[0]=249,ha.slice(0,3);if(va(n),n===ya(ha,1))return ha[0]=250,ha.slice(0,5)}return ba(n),ha[0]=251,ha.slice(0,9)}function Ca(e,t){let n=e,r=t?.float64===!0,i=r?n._keyBytesFloat64:n._keyBytes;if(i!==void 0)return i;let a=Sa(e,r);return r?n._keyBytesFloat64=a:n._keyBytes=a,a}fa.compareTokens=function(e,t,n){let r=Ca(e,n),i=Ca(t,n);return r.length===i.length?Jr(r,i):r.length<i.length?-1:1};function V(e,t,n){throw Error(`${B} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function wa(e){return()=>{throw Error(`${B} ${e}`)}}var H=[];for(let e=0;e<=23;e++)H[e]=V;H[24]=oi,H[25]=si,H[26]=ci,H[27]=li,H[28]=V,H[29]=V,H[30]=V,H[31]=V;for(let e=32;e<=55;e++)H[e]=V;H[56]=fi,H[57]=pi,H[58]=mi,H[59]=_i,H[60]=V,H[61]=V,H[62]=V,H[63]=V;for(let e=64;e<=87;e++)H[e]=bi;H[88]=xi,H[89]=Si,H[90]=Ci,H[91]=wi,H[92]=V,H[93]=V,H[94]=V,H[95]=wa(`indefinite length bytes/strings are not supported`);for(let e=96;e<=119;e++)H[e]=Mi;H[120]=Ni,H[121]=Pi,H[122]=Fi,H[123]=Ii,H[124]=V,H[125]=V,H[126]=V,H[127]=wa(`indefinite length bytes/strings are not supported`);for(let e=128;e<=151;e++)H[e]=zi;H[152]=Bi,H[153]=Vi,H[154]=Hi,H[155]=Ui,H[156]=V,H[157]=V,H[158]=V,H[159]=Wi;for(let e=160;e<=183;e++)H[e]=qi;H[184]=Ji,H[185]=Yi,H[186]=Xi,H[187]=Zi,H[188]=V,H[189]=V,H[190]=V,H[191]=Qi;for(let e=192;e<=215;e++)H[e]=ea;H[216]=ta,H[217]=na,H[218]=ra,H[219]=ia,H[220]=V,H[221]=V,H[222]=V,H[223]=V;for(let e=224;e<=243;e++)H[e]=wa(`simple values are not supported`);H[244]=V,H[245]=V,H[246]=V,H[247]=oa,H[248]=wa(`simple values are not supported`),H[249]=la,H[250]=ua,H[251]=da,H[252]=V,H[253]=V,H[254]=V,H[255]=sa;var Ta=[];for(let e=0;e<24;e++)Ta[e]=new z(R.uint,e,1);for(let e=-1;e>=-24;e--)Ta[31-e]=new z(R.negint,e,1);Ta[64]=new z(R.bytes,new Uint8Array,1),Ta[96]=new z(R.string,``,1),Ta[128]=new z(R.array,0,1),Ta[160]=new z(R.map,0,1),Ta[244]=new z(R.false,!1,1),Ta[245]=new z(R.true,!0,1),Ta[246]=new z(R.null,null,1);function Ea(e){switch(e.type){case R.false:return Wr([244]);case R.true:return Wr([245]);case R.null:return Wr([246]);case R.bytes:return e.value.length?void 0:Wr([64]);case R.string:return e.value===``?Wr([96]):void 0;case R.array:return e.value===0?Wr([128]):void 0;case R.map:return e.value===0?Wr([160]):void 0;case R.uint:return e.value<24?Wr([Number(e.value)]):void 0;case R.negint:if(e.value>=-24)return Wr([31-Number(e.value)])}}var Da={float64:!1,mapSorter:La,quickEncodeToken:Ea},Oa=Object.freeze({mapSorter:Ra,quickEncodeToken:Ea});function ka(){let e=[];return e[R.uint.major]=ui,e[R.negint.major]=vi,e[R.bytes.major]=Ei,e[R.string.major]=Li,e[R.array.major]=Gi,e[R.map.major]=$i,e[R.tag.major]=aa,e[R.float.major]=fa,e}var Aa=ka(),ja=new Zr,Ma=class e{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(t,n){if(t&&t.includes(n))throw Error(`${$r} object contains circular references`);return new e(n,t)}},Na={null:new z(R.null,null),undefined:new z(R.undefined,void 0),true:new z(R.true,!0),false:new z(R.false,!1),emptyArray:new z(R.array,0),emptyMap:new z(R.map,0)},Pa={number(e,t,n,r){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new z(R.float,e):e>=0?new z(R.uint,e):new z(R.negint,e)},bigint(e,t,n,r){return e>=BigInt(0)?new z(R.uint,e):new z(R.negint,e)},Uint8Array(e,t,n,r){return new z(R.bytes,e)},string(e,t,n,r){return new z(R.string,e)},boolean(e,t,n,r){return e?Na.true:Na.false},null(e,t,n,r){return Na.null},undefined(e,t,n,r){return Na.undefined},ArrayBuffer(e,t,n,r){return new z(R.bytes,new Uint8Array(e))},DataView(e,t,n,r){return new z(R.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,n,r){if(!e.length)return n.addBreakTokens===!0?[Na.emptyArray,new z(R.break)]:Na.emptyArray;r=Ma.createCheck(r,e);let i=[],a=0;for(let t of e)i[a++]=Fa(t,n,r);return n.addBreakTokens?[new z(R.array,e.length),i,new z(R.break)]:[new z(R.array,e.length),i]},Object(e,t,n,r){let i=t!==`Object`,a=i?e.keys():Object.keys(e),o=i?e.size:a.length,s;if(o){s=Array(o),r=Ma.createCheck(r,e);let t=!i&&n.ignoreUndefinedProperties,c=0;for(let o of a){let a=i?e.get(o):e[o];t&&a===void 0||(s[c++]=[Fa(o,n,r),Fa(a,n,r)])}c<o&&(s.length=c)}return s?.length?(Ia(s,n),n.addBreakTokens?[new z(R.map,s.length),s,new z(R.break)]:[new z(R.map,s.length),s]):n.addBreakTokens===!0?[Na.emptyMap,new z(R.break)]:Na.emptyMap},Tagged(e,t,n,r){return[new z(R.tag,e.tag),Fa(e.value,n,r)]}};Pa.Map=Pa.Object,Pa.Buffer=Pa.Uint8Array;for(let e of`Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64`.split(` `))Pa[`${e}Array`]=Pa.DataView;function Fa(e,t={},n){let r=Fr(e),i=t&&t.typeEncoders&&t.typeEncoders[r]||Pa[r];if(typeof i==`function`){let a=i(e,r,t,n);if(a!=null)return a}let a=Pa[r];if(!a)throw Error(`${$r} unsupported type: ${r}`);return a(e,r,t,n)}function Ia(e,t){let n=t.mapSorter;n&&e.sort((e,r)=>n(e,r,t))}function La(e,t,n){let r=Array.isArray(e[0])?e[0][0]:e[0],i=Array.isArray(t[0])?t[0][0]:t[0];if(r.type.major!==i.type.major)return r.type.compare(i.type);let a=Aa[r.type.major].compareTokens(r,i,n);return a===0&&console.warn(`WARNING: complex key types used, CBOR key sorting guarantees are gone`),a}function Ra(e,t){if(e[0]instanceof z&&t[0]instanceof z){let n=e[0],r=t[0];return n._keyBytes||=za(n.value),r._keyBytes||=za(r.value),Jr(n._keyBytes,r._keyBytes)}throw Error(`rfc8949MapSorter: complex key types are not supported yet`)}function za(e){return ro(e,Aa,Oa)}function Ba(e,t,n,r){if(Array.isArray(t))for(let i of t)Ba(e,i,n,r);else n[t.type.major](e,t,r)}var Va=R.uint.majorEncoded,Ha=R.negint.majorEncoded,Ua=R.bytes.majorEncoded,Wa=R.string.majorEncoded,Ga=R.array.majorEncoded,Ka=R.map.majorEncoded,qa=R.float.majorEncoded|20,Ja=R.float.majorEncoded|21,Ya=R.float.majorEncoded|22,Xa=R.float.majorEncoded|23,Za=BigInt(-1),Qa=BigInt(1);function $a(e,t,n){n<24?e.pushByte(t|Number(n)):di(e,t,n)}function eo(e){return e.addBreakTokens!==!0}function to(e,t,n,r,i){let a=n===`Map`,o=a?t.keys():Object.keys(t),s=a?t.size:o.length;if(!s){e.pushByte(Ka);return}i=Ma.createCheck(i,t);let c=!a&&r.ignoreUndefinedProperties,l=Array(s),u=0;for(let e of o){let n=a?t.get(e):t[e];c&&n===void 0||(l[u++]=[Fa(e,r,i),n])}if(u===0){e.pushByte(Ka);return}u<s&&(l.length=u),l.sort((e,t)=>La(e,t,r)),$a(e,Ka,u);for(let[t,n]of l)Ba(e,t,Aa,r),no(e,n,r,i)}function no(e,t,n,r){let i=Fr(t),a=n.typeEncoders&&n.typeEncoders[i];if(a){let o=a(t,i,n,r);if(o!=null){Ba(e,o,Aa,n);return}}switch(i){case`null`:e.pushByte(Ya);return;case`undefined`:e.pushByte(Xa);return;case`boolean`:e.pushByte(t?Ja:qa);return;case`number`:!Number.isInteger(t)||!Number.isSafeInteger(t)?fa(e,new z(R.float,t),n):t>=0?$a(e,Va,t):$a(e,Ha,t*-1-1);return;case`bigint`:t>=BigInt(0)?$a(e,Va,t):$a(e,Ha,t*Za-Qa);return;case`string`:{let n=Ur(t);$a(e,Wa,n.length),e.push(n);return}case`Uint8Array`:$a(e,Ua,t.length),e.push(t);return;case`Array`:if(!t.length){e.pushByte(Ga);return}r=Ma.createCheck(r,t),$a(e,Ga,t.length);for(let i of t)no(e,i,n,r);return;case`Object`:case`Map`:n.mapSorter===La?to(e,t,i,n,r):Ba(e,Pa.Object(t,i,n,r),Aa,n);return;default:{let a=Pa[i];if(!a)throw Error(`${$r} unsupported type: ${i}`);Ba(e,a(t,i,n,r),Aa,n)}}}function ro(e,t,n,r){let i=r instanceof Uint8Array,a=i?new Qr(r):ja,o=Fa(e,n);if(!Array.isArray(o)&&n.quickEncodeToken){let e=n.quickEncodeToken(o);if(e)return i?(a.push(e),a.toBytes()):e;let r=t[o.type.major];if(r.encodedSize){let e=r.encodedSize(o,n);if(i||(a=new Zr(e)),r(a,o,n),a.chunks.length!==1)throw Error(`Unexpected error: pre-calculated length for ${o} was wrong`);return i?a.toBytes():Br(a.chunks[0])}}return a.reset(),Ba(a,o,t,n),a.toBytes(!0)}function io(e,t){return t=Object.assign({},Da,t),eo(t)?(ja.reset(),no(ja,e,t,void 0),ja.toBytes(!0)):ro(e,Aa,t)}var ao={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},oo=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=Ta[e];if(t===void 0){let n=H[e];if(!n)throw Error(`${B} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,`0`)})`);let r=e&31;t=n(this.data,this._pos,r,this.options)}return this._pos+=t.encodedLength,t}},so=Symbol.for(`DONE`),co=Symbol.for(`BREAK`);function lo(e,t,n){let r=[];for(let i=0;i<e.value;i++){let a=mo(t,n);if(a===co){if(e.value===1/0)break;throw Error(`${B} got unexpected break to lengthed array`)}if(a===so)throw Error(`${B} found array but not enough entries (got ${i}, expected ${e.value})`);r[i]=a}return r}function uo(e,t,n){let r=n.useMaps===!0,i=n.rejectDuplicateMapKeys===!0,a=r?void 0:{},o=r?new Map:void 0;for(let s=0;s<e.value;s++){let c=mo(t,n);if(c===co){if(e.value===1/0)break;throw Error(`${B} got unexpected break to lengthed map`)}if(c===so)throw Error(`${B} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(!r&&typeof c!=`string`)throw Error(`${B} non-string keys not supported (got ${typeof c})`);if(i&&(r&&o.has(c)||!r&&Object.hasOwn(a,c)))throw Error(`${B} found repeat map key "${c}"`);let l=mo(t,n);if(l===so)throw Error(`${B} found map but not enough entries (got ${s} [no value], expected ${e.value})`);r?o.set(c,l):c===`__proto__`?Object.defineProperty(a,c,{value:l,configurable:!0,enumerable:!0,writable:!0}):a[c]=l}return r?o:a}function*fo(e,t,n){for(let r=0;r<e.value;r++){let i=mo(t,n);if(i===co){if(e.value===1/0)break;throw Error(`${B} got unexpected break to lengthed map`)}if(i===so)throw Error(`${B} found map but not enough entries (got ${r} [no key], expected ${e.value})`);let a=mo(t,n);if(a===so)throw Error(`${B} found map but not enough entries (got ${r} [no value], expected ${e.value})`);yield[i,a]}}function po(e,t){let n=function(){if(n._called)throw Error(`${B} tag decode() may only be called once`);n._called=!0;let r=mo(e,t);if(r===so)throw Error(`${B} tag content missing`);if(r===co)throw Error(`${B} got unexpected break in tag content`);return r};return n.entries=function(){if(n._called)throw Error(`${B} tag decode() may only be called once`);n._called=!0;let r=e.next();if(!R.equals(r.type,R.map))throw Error(`${B} entries() requires map content, got ${r.type.name}`);let i=[];for(let n of fo(r,e,t))i.push(n);return i},n._called=!1,n}function mo(e,t){if(e.done())return so;let n=e.next();if(R.equals(n.type,R.break))return co;if(n.type.terminal)return n.value;if(R.equals(n.type,R.array))return lo(n,e,t);if(R.equals(n.type,R.map))return uo(n,e,t);if(R.equals(n.type,R.tag)){if(t.tags&&typeof t.tags[n.value]==`function`){let r=po(e,t),i=t.tags[n.value](r);if(!r._called)throw Error(`${B} tag decoder must call decode() or entries()`);return i}throw Error(`${B} tag not supported (${n.value})`)}throw Error(`unsupported`)}function ho(e,t){if(!(e instanceof Uint8Array))throw Error(`${B} data to decode must be a Uint8Array`);t=Object.assign({},ao,t);let n=Br(e),r=t.tokenizer||new oo(n,t),i=mo(r,t);if(i===so)throw Error(`${B} did not find any content to decode`);if(i===co)throw Error(`${B} got unexpected break`);return[i,e.subarray(r.pos())]}function go(e,t){let[n,r]=ho(e,t);if(r.length>0)throw Error(`${B} too many terminals, data makes no sense`);return n}Object.defineProperty(class e{constructor(e,t){if(typeof e!=`number`||!Number.isInteger(e)||e<0)throw TypeError(`Tagged: tag must be a non-negative integer`);this.tag=e,this.value=t}static decoder(t){return n=>new e(t,n())}static preserve(...t){let n={};for(let r of t)n[r]=e.decoder(r);return n}}.prototype,Symbol.toStringTag,{value:`Tagged`});function _o(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}var U=(e,t,n)=>Qn(e,t,n),vo=Zn;function yo(e,t=``){if(typeof e!=`string`){let n=t&&`"${t}" `;throw TypeError(n+`expected string, got type=`+typeof e)}return e}function bo(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function xo(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}var So=cr,Co=(...e)=>fr(...e),wo=e=>ur(e),To=Yn,Eo=e=>hr(e),Do=BigInt(0),Oo=BigInt(1),ko=e=>e?`"${e}" `:``;function Ao(e,t=``){if(typeof e!=`boolean`)throw TypeError(ko(t)+`expected boolean, got type=`+typeof e);return e}function jo(e){if(typeof e==`bigint`){if(!Bo(e))throw RangeError(`positive bigint expected, got `+e)}else vo(e);return e}function Mo(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function No(e){let t=jo(e).toString(16);return t.length&1?`0`+t:t}function Po(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?Do:BigInt(`0x`+e)}function Fo(e){return Po(cr(e))}function Io(e){return Po(cr(zo(Qn(e)).reverse()))}function Lo(e,t){if(Zn(t),t===0)throw Error(`zero output length is invalid`);e=jo(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return ur(r.padStart(n,`0`))}function Ro(e,t){return Lo(e,t).reverse()}function zo(e){return Uint8Array.from(U(e))}function Bo(e){return typeof e==`bigint`&&Do<=e}function Vo(e,t,n){return Bo(e)&&Bo(t)&&Bo(n)&&t<=e&&e<n}function Ho(e,t,n,r){if(!Vo(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Uo(e){if(e<Do)throw Error(`expected non-negative bigint, got `+e);return e===Do?0:e.toString(2).length}var Wo=e=>(Mo(e,`n`),(Oo<<BigInt(e))-Oo);function Go(e,t,n){if(Zn(e,`hashLen`),Zn(t,`qByteLen`),typeof n!=`function`)throw TypeError(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=Uint8Array.of(),a=Uint8Array.of(0),o=Uint8Array.of(1),s=r(e),c=r(e),l=0,u=()=>{s.fill(1),c.fill(0),l=0},d=(...e)=>n(c,Co(s,...e)),f=(e=i)=>{c=d(a,e),s=d(),e.length!==0&&(c=d(o,e),s=d())},p=()=>{if(l++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,n=[];for(;e<t;){s=d();let t=s.slice();n.push(t),e+=s.length}return Co(...n)};return(e,t)=>{u(),f(e);let n;for(;(n=t(p()))===void 0;)f();return u(),n}}function Ko(e,t={},n={},r=`object`){bo(e,r),bo(t,`fields`),bo(n,`optFields`);function i(t,n,i){let a=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,o=e[t];if(!Object.hasOwn(e,t)&&(i?o!==void 0:n!==`function`))throw TypeError(`${a} is invalid: expected own property`);if(i&&o===void 0)return;let s=typeof o;if(s!==n||o===null)throw TypeError(`${a} is invalid: expected ${n}, got ${s}`)}let a=(e,t)=>Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}var qo=BigInt(0),W=BigInt(1),Jo=BigInt(2),Yo=BigInt(3),Xo=BigInt(4),Zo=BigInt(5),Qo=BigInt(7),$o=BigInt(8),es=BigInt(9),ts=BigInt(15),ns=BigInt(16),rs=BigInt(`0x10000000000000000`);function G(e,t){if(t<=qo)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=qo?n:t+n}function is(e,t,n){if(n<=W)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(t<qo)throw Error(`invalid exponent, negatives unsupported`);if(t===qo)return W;if(t===W)return e;let r=e%n;if(r<qo&&(r+=n),t<rs){let e=W;for(;t>qo;)t&W&&(e=e*r%n),r=r*r%n,t>>=W;return e}let i=[];for(;t>qo;)i.push(Number(t&ts)),t>>=Xo;let a=Array(16);a[0]=W,a[1]=r;for(let e=2;e<16;e++)a[e]=a[e-1]*r%n;let o=a[i[i.length-1]];for(let e=i.length-2;e>=0;e--){o=o*o%n,o=o*o%n,o=o*o%n,o=o*o%n;let t=i[e];t!==0&&(o=o*a[t]%n)}return o}function as(e,t,n){if(n<=W)throw Error(`pow2: expected modulus > 1, got `+n);if(t<qo)throw Error(`pow2: expected non-negative exponent, got `+t);let r=e;for(;t-->qo;)r*=r,r%=n;return r}function os(e,t){if(e===qo)throw Error(`invert: expected non-zero number`);if(t<=W)throw Error(`invert: expected modulus > 1, got `+t);let n=G(e,t),r=t,i=qo,a=W;for(;n!==qo;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==W)throw Error(`invert: does not exist`);return G(i,t)}function ss(e,t){if(t<=W)throw Error(`invertCt: expected prime modulus > 1, got `+t);let n=G(e,t);if(n===qo)throw Error(`invertCt: expected non-zero number`);let r=is(n,t-Jo,t);if(G(n*r,t)!==W)throw Error(`invertCt: does not exist`);return r}function cs(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function ls(e,t){if((e&W)===qo)throw Error(t+`: expected odd modulus, got `+e)}function us(e,t){let n=e,r=(n.ORDER+W)/Xo,i=n.pow(t,r);return cs(n,i,t),i}function ds(e,t){let n=e,r=(n.ORDER-Zo)/$o,i=n.mul(t,Jo),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,Jo),a),c=n.mul(o,n.sub(s,n.ONE));return cs(n,c,t),c}function fs(e){let t=Cs(e),n=ps(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Qo)/ns;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return cs(n,m,t),m})}function ps(e){if(e<Yo)throw Error(`sqrt is not defined for small field`);ls(e,`tonelliShanks`);let t=e-W,n=0;for(;t%Jo===qo;)t/=Jo,n++;let r=Jo,i=Cs(e);for(;ys(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return us;let a=i.pow(r,t),o=(t+W)/Jo;return function(e,r){let i=e;if(i.is0(r))return r;if(ys(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))throw Error(`Cannot find square root: probably non-prime P`);let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=W<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function ms(e){return ls(e,`Fp.sqrt`),e%Xo===Yo?us:e%$o===Zo?ds:e%ns===es?fs(e):ps(e)}var hs=(e,t)=>(G(e,t)&W)===W,gs=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function _s(e){if(bo(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);Mo(e.BYTES,`BYTES`),Mo(e.BITS,`BITS`);for(let t of gs)xo(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=W)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function vs(e,t,n=!1){_s(e),_o(t,`nums`),Ao(n,`passZero`);let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function ys(e,t){_s(e);let n=e;ls(n.ORDER,`FpLegendre`);let r=(n.ORDER-W)/Jo,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function bs(e,t){if(t!==void 0&&vo(t),e<=qo)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=Uo(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var xs=new WeakMap,Ss=class{ORDER;BITS;BYTES;isLE;ZERO=qo;ONE=W;_lengths;_mod;constructor(e,t={}){if(e<=W)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=bs(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return G(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return qo<=e&&e<this.ORDER}is0(e){return e===qo}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&W)===W}neg(e){return G(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return G(e*e,this.ORDER)}add(e,t){return G(e+t,this.ORDER)}sub(e,t){return G(e-t,this.ORDER)}mul(e,t){return G(e*t,this.ORDER)}pow(e,t){return is(e,t,this.ORDER)}div(e,t){return G(e*os(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return os(e,this.ORDER)}sqrt(e){let t=xs.get(this);return t||xs.set(this,t=ms(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?Ro(e,this.BYTES):Lo(e,this.BYTES)}fromBytes(e,t=!1){U(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?Io(e):Fo(e);if(o&&(s=G(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return vs(this,e,!0)}cmov(e,t,n){return Ao(n,`condition`),n?t:e}};function Cs(e,t={}){return Object.freeze(Ss.prototype),new Ss(e,t)}function ws(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=W)throw Error(`field order must be greater than 1`);let t=Uo(e-W);return Math.ceil(t/8)}function Ts(e){let t=ws(e);return t+Math.ceil(t/2)}function Es(e,t,n=!1){U(e);let r=e.length,i=ws(t),a=Math.max(Ts(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=G(n?Io(e):Fo(e),t-W)+W;return n?Ro(o,i):Lo(o,i)}var Ds=BigInt(0),Os=BigInt(1),ks=BigInt(4),As=16,js=128,Ms=5,Ns=2**31;function Ps(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);xo(t.fromAffine,`Point.fromAffine`),xo(t.fromBytes,`Point.fromBytes`),xo(t.fromHex,`Point.fromHex`),bo(t.BASE,`Point.BASE`),bo(t.ZERO,`Point.ZERO`),_s(t.Fp),_s(t.Fn)}function Fs(e,t){Ps(e),zs(t,e);let n=vs(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function Is(e,t,n=1){if(!Number.isSafeInteger(e)||e<n||e>t)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function Ls(e,t){let n=e*(4*t+128);if(n>Ns)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+Ns/2**20+` MiB`)}function Rs(e,t){if(e!==void 0){xo(e,`randomBytes`);try{let n=e(t);if(!To(n)||n.length!==t)return}catch{return}return e}}function zs(e,t){_o(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function Bs(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):Bo(e)&&e<n))throw Error(`invalid scalar at index `+r)})}var Vs=new WeakMap;function Hs(e){return Vs.get(e)||1}function Us(e,t){let n=e.double(),r=[e];for(let e=1;e<t;e++)r.push(r[e-1].add(n));return r}function Ws(e,t){let n=2**t,r=n/2,i=BigInt(n-1),a=[];for(;e>Ds;){let t=0;e&Os&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=Os}return a}function Gs(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t<n;t++){let t=Number(e&a);e>>=o,t>i&&(t-=r,e+=Os),s.push(t)}if(e!==Ds)throw Error(`invalid wnaf`);return s}function Ks(e,t,n){let r=0;for(let e of n)r=Math.max(r,e.length);let i=e;for(let e=r-1;e>=0;e--){e!==r-1&&(i=i.double());for(let r=0;r<n.length;r++){let a=n[r][e];if(a){let e=t[r][Math.abs(a)-1>>1];i=i.add(a<0?e.negate():e)}}}return i}var qs=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,t){Ps(e),this.randomBytes=Rs(t,As),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,t,n){let r=Math.ceil(n/t)+1,i=2**(t-1),a=[],o=e;for(let e=0;e<r;e++){let e=o;for(let t=0;t<i;t++)a.push(e),e=e.add(o);o=a[a.length-1].double()}return{W:t,bits:n,windows:r,comp:a}}wnafCachedCT(e,t){let{W:n,windows:r,comp:i}=e,a=2**(n-1),o=Gs(t,n,r),s=this.ZERO,c=this.BASE;for(let e=0;e<r;e++){let t=o[e],n=e*a,r=Math.abs(t)-1,l=i[n];for(let e=1;e<a;e++)l=e===r?i[n+e]:l;let u=l.negate();t===0?c=c.add(i[n]):s=s.add(t<0?u:l)}return{p:s,f:c}}getWnafPrecomputes(e,t,n,r){let i=this.wnafPrecomputes.get(t),a=i?.find(t=>t.W===e&&t.bits===n);return a||(a=this.buildWnafTable(t,e,n),typeof r==`function`&&(a={...a,comp:r(a.comp)}),i||(i=[],this.wnafPrecomputes.set(t,i)),i.push(a)),a}assertPoint(e){if(!(e instanceof this.Point))throw TypeError(`"point" expected Point instance, got type=`+typeof e)}validateMulInput(e,t){if(this.assertPoint(e),!Vo(t,Os,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=Hs(e);return i===1?this.fixedWindowCT(e,t,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,r),t)}mulCT(e,t,n){return this.validateMulInput(e,t),this.runCT(e,t,this.bits,n)}mulCTBlinded(e,t,n){if(this.validateMulInput(e,t),this.randomBytes===void 0)throw Error(`randomBytes is required for scalar blinding`);let r=this.Point.Fn.BITS+js,i=this.randomBytes(As);if(!To(i)||i.length!==As)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+Fo(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=Ms,i=Wo(r),a=Array(32);a[0]=this.ZERO;for(let t=1;t<32;t++)a[t]=a[t-1].add(e);let o=Math.ceil(n/r),s=this.ZERO;for(let e=o-1;e>=0;e--){if(e!==o-1)for(let e=0;e<r;e++)s=s.double();let n=Number(t>>BigInt(e*r)&i),c=a[0];for(let e=1;e<32;e++)c=e===n?a[e]:c;s=s.add(c)}return{p:s,f:s}}shouldBlind(e,t){return this.randomBytes===void 0?!1:t===Os||e===this.BASE&&(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,t,n,r){return this.shouldBlind(e,n)?this.mulCTBlinded(e,t,r):this.mulCT(e,t,r)}mulUnsafe(e,t,n){if(this.assertPoint(e),!Bo(t))throw Error(`invalid scalar`);let r=Hs(e);if(r===1||t>=this.Point.Fn.ORDER)return Js(this.Point,[e],[t],!0);let i=this.getWnafPrecomputes(r,e,this.bits,n);return this.wnafCachedCT(i,t).p}setWindowSize(e,t){this.assertPoint(e),Is(t,this.bits),Ls((Math.ceil((this.bits+js)/t)+1)*2**(t-1),this.Point.Fp.BYTES),Vs.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Hs(e)!==1}};function Js(e,t,n,r=!1){if(Ps(e),zs(t,e),Ao(r,`allowOversized`),Bs(n,e.Fn,r?e.Fn.ORDER**ks:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>Us(e,4)),a=n.map(e=>Ws(e,4));return Ks(e.ZERO,i,a)}function Ys(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return _s(t),t}return Cs(e,{isLE:n})}function Xs(e,t,n={},r){if(e!==`weierstrass`&&e!==`edwards`)throw Error(`expected curve type "weierstrass" or "edwards"`);if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);Ko(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(Bo(n)&&n!==Ds))throw Error(`CURVE.${e} must be positive bigint`)}let i=Ys(t.p,n.Fp,r),a=Ys(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function Zs(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var Qs=BigInt(0),$s=BigInt(1),ec=BigInt(2),tc=BigInt(4),nc=BigInt(8);function rc(e,t,n,r){let i=e.sqr(n),a=e.sqr(r),o=e.add(e.mul(t.a,i),a),s=e.add(e.ONE,e.mul(t.d,e.mul(i,a)));return e.eql(o,s)}function ic(e,t={}){Ko(t,{},{},`extraOpts`);let n=t,r=Xs(`edwards`,e,n,n.FpFnLE),{Fp:i,Fn:a}=r,o=r.CURVE,{h:s}=o;if(ys(i,o.a)!==1)throw Error(`edwards: CURVE.a must be a square in Fp for complete addition formulas`);if(ys(i,o.d)!==-1)throw Error(`edwards: CURVE.d must be a non-square in Fp for complete addition formulas`);Ko(n,{},{uvRatio:`function`,randomBytes:`function`});let c=n.randomBytes===void 0?Eo:n.randomBytes,l=ec<<BigInt(i.BYTES*8)-$s;function u(e){if(!i.isOdd)throw Error(`Field does not have .isOdd()`);return i.isOdd(e)}let d=n.uvRatio===void 0?(e,t)=>{try{return{isValid:!0,value:i.sqrt(i.div(e,t))}}catch{return{isValid:!1,value:Qs}}}:n.uvRatio;if(!rc(i,o,o.Gx,o.Gy))throw Error(`bad curve params: generator point`);let f=i.eql(o.a,i.neg(i.ONE))?e=>i.neg(e):i.eql(o.a,i.ONE)?e=>e:e=>i.mul(o.a,e);function p(e,t,n=!1){let r=n?$s:Qs;return Ho(`coordinate `+e,t,r,l),t}function m(e){if(!(e instanceof h))throw Error(`EdwardsPoint expected`)}class h{static BASE=new h(o.Gx,o.Gy,i.ONE,i.mul(o.Gx,o.Gy));static ZERO=new h(i.ZERO,i.ONE,i.ONE,i.ZERO);static Fp=i;static Fn=a;X;Y;Z;T;constructor(e,t,n,r){this.X=p(`x`,e),this.Y=p(`y`,t),this.Z=p(`z`,n,!0),this.T=p(`t`,r),Object.freeze(this)}static CURVE(){return o}static fromAffine(e){if(e instanceof h)throw Error(`extended point not allowed`);let{x:t,y:n}=e||{};return p(`x`,t),p(`y`,n),new h(t,n,i.ONE,i.mul(t,n))}static fromBytes(e,t=!1){let n=i.BYTES,{a:r,d:a}=o;e=zo(U(e,n,`point`)),Ao(t,`zip215`);let s=zo(e),c=e[n-1];s[n-1]=c&-129;let f=Io(s);Ho(`point.y`,f,Qs,t?l:i.ORDER);let p=i.sqr(f),m=i.sub(p,i.ONE),g=i.sub(i.mulN(a,p),r),{isValid:_,value:v}=d(m,g);if(!_)throw Error(`bad point: invalid y coordinate`);let y=u(v),b=!!(c&128);if(!t&&i.is0(v)&&b)throw Error(`bad point: x=0 and x_0=1`);return b!==y&&(v=i.neg(v)),h.fromAffine({x:v,y:f})}static fromHex(e,t=!1){return h.fromBytes(wo(e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return _.setWindowSize(this,e),t||this.multiply(ec),this}assertValidity(){let e=this,{a:t,d:n}=o;if(e.is0())throw Error(`bad point: ZERO`);let{X:r,Y:a,Z:s,T:c}=e,l=i.sqr(r),u=i.sqr(a),d=i.sqr(s),f=i.sqr(d),p=i.mul(l,t),m=i.mul(i.add(p,u),d),h=i.add(f,i.mul(n,i.mul(l,u)));if(!i.eql(m,h))throw Error(`bad point: equation left != right (1)`);let g=i.mul(r,a),_=i.mul(s,c);if(!i.eql(g,_))throw Error(`bad point: equation left != right (2)`)}equals(e){m(e);let{X:t,Y:n,Z:r}=this,{X:a,Y:o,Z:s}=e,c=i.mul(t,s),l=i.mul(a,r),u=i.mul(n,s),d=i.mul(o,r);return i.eql(c,l)&&i.eql(u,d)}is0(){return this.equals(h.ZERO)}negate(){return new h(i.neg(this.X),this.Y,this.Z,i.neg(this.T))}double(){let{X:e,Y:t,Z:n}=this,r=i.sqr(e),a=i.sqr(t),o=i.mul(i.sqr(n),ec),s=f(r),c=i.addN(e,t),l=i.sub(i.subN(i.sqr(c),r),a),u=i.addN(s,a),d=i.subN(u,o),p=i.subN(s,a),m=i.mul(l,d),g=i.mul(u,p),_=i.mul(l,p),v=i.mul(d,u);return new h(m,g,v,_)}add(e){m(e);let{d:t}=o,{X:n,Y:r,Z:a,T:s}=this,{X:c,Y:l,Z:u,T:d}=e,p=i.mul(n,c),g=i.mul(r,l),_=i.mul(i.mulN(s,t),d),v=i.mul(a,u),y=i.sub(i.subN(i.mulN(i.addN(n,r),i.addN(c,l)),p),g),b=i.subN(v,_),ee=i.addN(v,_),x=i.sub(g,f(p)),S=i.mul(y,b),C=i.mul(ee,x),w=i.mul(y,x),T=i.mul(b,ee);return new h(S,C,T,w)}subtract(e){return m(e),this.add(e.negate())}multiply(e){if(!a.isValidNot0(e))throw RangeError(`invalid scalar: expected 1 <= sc < curve.n`);let{p:t,f:n}=_.mulSecret(this,e,s,g);return g([t,n])[0]}multiplyUnsafe(e){if(!a.isValid(e))throw RangeError(`invalid scalar: expected 0 <= sc < curve.n`);return e===Qs?h.ZERO:this.is0()||e===$s?this:_.mulUnsafe(this,e,g)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return _.mulUnsafe(this,o.n).is0()}toAffine(e){let t=this,n=e;if(n!=null&&typeof n!=`bigint`)throw TypeError(`"invertedZ" expected bigint, got type=`+typeof n);let{X:r,Y:a,Z:o}=t,s=t.is0();n??=s?i.create(nc):i.inv(o);let c=i.mul(r,n),l=i.mul(a,n),u=i.mul(o,n);if(s)return{x:i.ZERO,y:i.ONE};if(!i.eql(u,i.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}clearCofactor(){return s===$s?this:s===ec?this.double():s===tc?this.double().double():s===nc?this.double().double().double():this.multiplyUnsafe(s)}toBytes(){let{x:e,y:t}=this.toAffine(),n=i.toBytes(t);return n[n.length-1]|=u(e)?128:0,n}toHex(){return So(this.toBytes())}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let g=e=>Fs(h,e),_=new qs(h,c);return _.bits>=6&&h.BASE.precompute(6),Object.freeze(h.prototype),Object.freeze(h),h}function ac(e,t,n={}){if(Ps(e),typeof t!=`function`)throw Error(`"hash" function param is required`);let r=t,i=n;Ko(i,{},{adjustScalarBytes:`function`,randomBytes:`function`,domain:`function`,prehash:`function`,zip215:`boolean`,mapToCurve:`function`,toMontgomery:`function`,toMontgomerySecret:`function`});let{prehash:a}=i,{BASE:o,Fp:s,Fn:c}=e,l=r.outputLen,u=2*s.BYTES;if(l!==void 0&&(Mo(l,`hash.outputLen`),l!==u))throw Error(`hash.outputLen must be ${u}, got ${l}`);let d=i.randomBytes===void 0?Eo:i.randomBytes,f=i.toMontgomery,p=i.toMontgomerySecret,m=i.adjustScalarBytes===void 0?e=>e:i.adjustScalarBytes,h=i.domain===void 0?(e,t,n)=>{if(Ao(n,`phflag`),t.length||n)throw Error(`Contexts/pre-hash are not supported`);return e}:i.domain;function g(e){return c.create(Io(e))}function _(e){let t=w.secretKey;U(e,w.secretKey,`secretKey`);let n=U(r(e),2*t,`hashedSecretKey`),i=m(n.slice(0,t));return{head:i,prefix:n.slice(t,2*t),scalar:g(i)}}function v(e){let{head:t,prefix:n,scalar:r}=_(e),i=o.multiply(r);return{head:t,prefix:n,scalar:r,point:i,pointBytes:i.toBytes()}}function y(e){return v(e).pointBytes}function b(e=Uint8Array.of(),...t){let n=Co(...t);return g(r(h(n,U(e,void 0,`context`),!!a)))}function ee(e,t,n={}){Ko(n,{},{},`options`),e=U(e,void 0,`message`),a&&(e=a(e));let{prefix:r,scalar:i,pointBytes:s}=v(t),l=b(n.context,r,e),u=o.multiply(l).toBytes(),d=b(n.context,u,s,e),f=c.create(l+d*i);if(!c.isValid(f))throw Error(`sign failed: invalid s`);return U(Co(u,c.toBytes(f)),w.signature,`result`)}let x={zip215:i.zip215};function S(t,n,r,i=x){Ko(i);let{context:s}=i,c=i.zip215===void 0?!!x.zip215:i.zip215,l=w.signature;t=U(t,l,`signature`),n=U(n,void 0,`message`),r=U(r,w.publicKey,`publicKey`),c!==void 0&&Ao(c,`zip215`),a&&(n=a(n));let u=l/2,d=t.subarray(0,u),f=Io(t.subarray(u,l)),p,m,h;try{p=e.fromBytes(r,c),m=e.fromBytes(d,c),h=o.multiplyUnsafe(f)}catch{return!1}if(!c&&p.isSmallOrder())return!1;let g=b(s,d,r,n);return m.add(p.multiplyUnsafe(g)).subtract(h).clearCofactor().is0()}let C=s.BYTES,w={secretKey:C,publicKey:C,signature:2*C,seed:C};function T(e){return e=e===void 0?d(w.seed):e,U(e,w.seed,`seed`)}function E(e){return To(e)&&e.length===w.secretKey}function D(t,n){try{return!!e.fromBytes(t,n===void 0?x.zip215:n)}catch{return!1}}let O={getExtendedPublicKey:v,randomSecretKey:T,isValidSecretKey:E,isValidPublicKey:D,toMontgomery(t){if(f===void 0)throw Error(`Montgomery conversion is not supported for this curve`);return f(e.fromBytes(t))},toMontgomerySecret(e){if(p===void 0)throw Error(`Montgomery conversion is not supported for this curve`);return p(e)}};return Object.freeze(w),Object.freeze(O),Object.freeze({keygen:Zs(T,y),getPublicKey:y,sign:ee,verify:S,utils:O,Point:e,lengths:w})}var oc=BigInt(0),sc=BigInt(1),cc=BigInt(2);function lc(e,t){return e+t-(t>>sc<<sc)}function uc(e){let t=BigInt(6)*e;return(n,r,i)=>{let a=r+i,o=((t+i-r)*n+r)%e;return{x_2:o,x_3:a-o}}}function dc(e){return Ko(e,{P:`bigint`,type:`string`,adjustScalarBytes:`function`,powPminus2:`function`},{randomBytes:`function`,scalarMultBase:`function`}),Object.freeze({...e})}function fc(e){let t=dc(e),{P:n,type:r,adjustScalarBytes:i,powPminus2:a,randomBytes:o}=t,s=t.scalarMultBase,c=r===`x25519`;if(!c&&r!==`x448`)throw Error(`invalid type`);let l=o===void 0?Eo:o,u=c?255:448,d=uc(n),f=c?32:56,p=BigInt(c?9:5),m=BigInt(c?121665:39081),h=c?cc**BigInt(254):cc**BigInt(447),g=h+(c?BigInt(8)*(cc**BigInt(251)-sc):BigInt(4)*(cc**BigInt(445)-sc))+sc,_=e=>G(e,n),v=y(p);function y(e){return Ro(_(e),f)}function b(e){let t=zo(U(e,f,`uCoordinate`));return c&&(t[31]&=127),_(Io(t))}function ee(e){return Io(i(zo(U(e,f,`scalar`))))}let x=new Set(c?[oc,sc,n-sc,BigInt(`325606250916557431795983626356110631294008115727848805560023387167927233504`),BigInt(`39382357235489614581723060781553021112529911719440698176882885853963445705823`)]:[oc,sc,n-sc]);function S(e,t){let n=b(t);if(x.has(n))throw Error(`invalid private or public key received`);let r=E(n,ee(e));if(r===oc)throw Error(`invalid private or public key received`);return y(r)}function C(e){if(s===void 0)return S(e,v);let t=ee(e);Ho(`scalar`,t,h,g);let n=_(s(t));if(n===oc)throw Error(`invalid private or public key received`);return y(n)}let w=C,T=S;function E(e,t){Ho(`u`,e,oc,n),Ho(`scalar`,t,h,g);let r=t,i=e,o=sc,s=oc,c=e,l=sc,f=r^r>>sc;for(let e=BigInt(u-1);e>=oc;e--){let t=lc(n,f>>e);({x_2:o,x_3:c}=d(t,o,c)),{x_2:s,x_3:l}=d(t,s,l);let r=o+s,a=_(r*r),u=o-s,p=_(u*u),h=a-p,g=c+l,v=c-l,y=_(v*r),b=_(g*u),ee=y+b,x=y-b;c=_(ee*ee),l=_(i*_(x*x)),o=_(a*p),s=_(h*(a+_(m*h)))}let p=lc(n,r);({x_2:o,x_3:c}=d(p,o,c)),{x_2:s,x_3:l}=d(p,s,l);let v=a(s);return _(o*v)}let D={secretKey:f,publicKey:f,seed:f},O=e=>(e=e===void 0?l(f):e,U(e,D.seed,`seed`),e),k={randomSecretKey:O};return Object.freeze(D),Object.freeze(k),Object.freeze({keygen:Zs(O,w),getSharedSecret:T,getPublicKey:w,scalarMult:S,scalarMultBase:C,utils:k,GuBytes:v.slice(),lengths:D})}var pc=BigInt(0),mc=BigInt(1),hc=BigInt(2),gc=BigInt(3),_c=BigInt(5),vc=BigInt(8),yc=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed`),bc={p:yc,n:BigInt(`0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed`),h:vc,a:BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec`),d:BigInt(`0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3`),Gx:BigInt(`0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a`),Gy:BigInt(`0x6666666666666666666666666666666666666666666666666666666666666658`)};function xc(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),a=yc,o=e*e%a*e%a,s=as(as(o,hc,a)*o%a,mc,a)*e%a,c=as(s,_c,a)*s%a,l=as(c,t,a)*c%a,u=as(l,n,a)*l%a,d=as(u,r,a)*u%a;return{pow_p_5_8:as(as(as(as(d,i,a)*d%a,i,a)*d%a,t,a)*c%a,hc,a)*e%a,b2:o}}function Sc(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Cc=BigInt(`19681161376707505956807079304988542015446066515923890162744021073123829784752`);function wc(e,t){let n=yc,r=G(t*t*t,n),i=xc(e*G(r*r*t,n)).pow_p_5_8,a=G(e*r*i,n),o=G(t*a*a,n),s=a,c=G(a*Cc,n),l=o===e,u=o===G(-e,n),d=o===G(-e*Cc,n);return l&&(a=s),(u||d)&&(a=c),hs(a,n)&&(a=G(-a,n)),{isValid:l||u,value:a}}var Tc=ic(bc,{uvRatio:wc}),Ec=Tc.Fp;function Dc(e){let{y:t}=e;return Ec.toBytes(Ec.div(mc+t,mc-t))}function Oc(e){let t=Tc.Fp.BYTES;return Qn(e,t),Sc(Nr(e.subarray(0,t))).subarray(0,t)}function kc(e){return ac(Tc,Nr,Object.assign({adjustScalarBytes:Sc,toMontgomery:Dc,toMontgomerySecret:Oc,zip215:!0},e))}var Ac=kc({}),jc=(()=>{let e=yc,t=t=>{let{pow_p_5_8:n,b2:r}=xc(t);return G(as(n,gc,e)*r,e)};return fc({P:e,type:`x25519`,powPminus2:t,adjustScalarBytes:Sc,scalarMultBase:n=>{let r=G(n,Tc.Fn.ORDER);if(r===pc)return pc;let i=Tc.BASE.multiply(r);return G((i.Z+i.Y)*t(G(i.Z-i.Y,e)),e)}})})(),Mc=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if($n(e),Qn(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`expected Hash instance`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),rr(r)}update(e){return tr(this),this.iHash.update(e),this}digestInto(e){tr(this),nr(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o,canXOF:s}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.canXOF=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Nc=(()=>{let e=((e,t,n)=>new Mc(e,t).update(n).digest());return e.create=(e,t)=>new Mc(e,t),e})(),Pc=BigInt(0),Fc={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=Fc;if(Mo(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(yo(t,`data`),t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=No(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?No(i.length/2|128):``;return No(e)+a+i+t},decode(e,t){let{Err:n}=Fc;t=U(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.decode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=Fc;if(jo(e),e<Pc)throw new t(`integer: negative integers are not allowed`);let n=No(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=Fc;if(e.length<1)throw new t(`invalid signature integer: empty`);if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return Fo(e)}},toSig(e){let{Err:t,_int:n,_tlv:r}=Fc,i=U(e,void 0,`signature`),{v:a,l:o}=r.decode(48,i);if(o.length)throw new t(`invalid signature: left bytes after parsing`);let{v:s,l:c}=r.decode(2,a),{v:l,l:u}=r.decode(2,c);if(u.length)throw new t(`invalid signature: left bytes after parsing`);return{r:n.decode(s),s:n.decode(l)}},hexFromSig(e){let{_tlv:t,_int:n}=Fc;Ko(e,{r:`bigint`,s:`bigint`},{},`sig`);let r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},Ic=(Object.freeze(Fc._tlv),Object.freeze(Fc._int),Object.freeze(Fc)),Lc=(e,t)=>(e+(e>=0?t:-t)/Uc)/t;function Rc(e,t,n){Ho(`scalar`,e,Vc,n);let[[r,i],[a,o]]=t,s=Lc(o*e,n),c=Lc(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<Vc,f=u<Vc;d&&(l=-l),f&&(u=-u);let p=Wo(Math.ceil(Uo(n)/2))+Hc;if(l<Vc||l>=p||u<Vc||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function zc(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Bc(e,t){Ko(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return Ao(n.lowS,`lowS`),Ao(n.prehash,`prehash`),n.format!==void 0&&zc(n.format),n}var Vc=BigInt(0),Hc=BigInt(1),Uc=BigInt(2),Wc=BigInt(3),Gc=BigInt(4);function Kc(e,t={}){let n=Xs(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;Ko(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,randomBytes:`function`});let{endo:c,allowInfinityPoint:l}=t,u=t.randomBytes===void 0?Eo:t.randomBytes;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let d=Jc(r,i);function f(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function p(e,t,n){if(l&&t.is0())return Uint8Array.of(0);let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return Ao(n,`isCompressed`),n?(f(),Co(qc(!r.isOdd(a)),o)):Co(Uint8Array.of(4),o,r.toBytes(a))}function m(e){U(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=d,i=e.length,a=e[0],o=e.subarray(1);if(l&&i===1&&a===0)return{x:r.ZERO,y:r.ZERO};if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=y(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}f();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!b(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let h=t.toBytes===void 0?p:t.toBytes,g=t.fromBytes===void 0?m:t.fromBytes,_=r.mul(a.b,Wc),v=r.is0(a.a)?e=>r.ZERO:e=>r.mul(a.a,e);function y(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function b(e,t){let n=r.sqr(t),i=y(e);return r.eql(n,i)}if(!b(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let ee=r.mul(r.pow(a.a,Wc),Gc),x=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(ee,x)))throw Error(`bad curve params: a or b`);function S(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return t}function C(e){if(!(e instanceof D))throw Error(`Weierstrass Point expected`)}function w(e){if(!c||!c.basises)throw Error(`no endo`);return Rc(e,c.basises,i.ORDER)}function T(e,t,n,a){if(!i.isValid(a))throw RangeError(`invalid scalar: out of range`);if(c){let{k1neg:i,k1:o,k2neg:s,k2:l}=w(a),u=new D(r.mul(n.X,c.beta),n.Y,n.Z);e.push(i?n.negate():n,s?u.negate():u),t.push(o,l)}else e.push(n),t.push(a)}let E=new WeakSet;class D{static BASE=new D(a.Gx,a.Gy,r.ONE);static ZERO=new D(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=S(`x`,e),this.Y=S(`y`,t,!0),this.Z=S(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof D)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?D.ZERO:new D(t,n,r.ONE)}static fromBytes(e){let t=D.fromAffine(g(U(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return D.fromBytes(wo(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return k.setWindowSize(this,e),t||this.multiply(Wc),this}assertValidity(){let e=this;if(e.is0()){if(t.allowInfinityPoint&&r.is0(e.X)&&r.eql(e.Y,r.ONE)&&r.is0(e.Z))return;throw Error(`bad point: ZERO`)}if(E.has(e))return;let{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw Error(`bad point: x or y not field elements`);if(!b(n,i))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);E.add(e)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){C(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new D(this.X,r.neg(this.Y),this.Z)}double(){let{X:e,Y:t,Z:n}=this,i=r.ZERO,a=r.ZERO,o=r.ZERO,s=r.mul(e,e),c=r.mul(t,t),l=r.mul(n,n),u=r.mul(e,t);return u=r.add(u,u),o=r.mul(e,n),o=r.add(o,o),i=v(o),a=r.mul(_,l),a=r.add(i,a),i=r.sub(c,a),a=r.add(c,a),a=r.mul(i,a),i=r.mul(u,i),o=r.mul(_,o),l=v(l),u=r.sub(s,l),u=v(u),u=r.add(u,o),o=r.add(s,s),s=r.add(o,s),s=r.add(s,l),s=r.mul(s,u),a=r.add(a,s),l=r.mul(t,n),l=r.add(l,l),s=r.mul(l,u),i=r.sub(i,s),o=r.mul(l,c),o=r.add(o,o),o=r.add(o,o),new D(i,a,o)}add(e){C(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(t,a),f=r.mul(n,o),p=r.mul(i,s),m=r.add(t,n),h=r.add(a,o);m=r.mul(m,h),h=r.add(d,f),m=r.sub(m,h),h=r.add(t,i);let g=r.add(a,s);return h=r.mul(h,g),g=r.add(d,p),h=r.sub(h,g),g=r.add(n,i),c=r.add(o,s),g=r.mul(g,c),c=r.add(f,p),g=r.sub(g,c),u=v(h),c=r.mul(_,p),u=r.add(c,u),c=r.sub(f,u),u=r.add(f,u),l=r.mul(c,u),f=r.add(d,d),f=r.add(f,d),p=v(p),h=r.mul(_,h),f=r.add(f,p),p=r.sub(d,p),p=v(p),h=r.add(h,p),d=r.mul(f,h),l=r.add(l,d),d=r.mul(g,h),c=r.mul(m,c),c=r.sub(c,d),d=r.mul(m,f),u=r.mul(g,u),u=r.add(u,d),new D(c,l,u)}subtract(e){return C(e),this.add(e.negate())}is0(){return this.equals(D.ZERO)}multiply(e){if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let{p:t,f:n}=k.mulSecret(this,e,o,O);return O([t,n])[0]}multiplyUnsafe(e){let t=this,n=e;if(!i.isValid(n))throw RangeError(`invalid scalar: out of range`);if(n===Vc||t.is0())return D.ZERO;if(n===Hc)return t;if(k.hasWindowSize(this))return k.mulUnsafe(t,n,O);let r=[],a=[];return T(r,a,t,n),Js(D,r,a)}mulAddUnsafe(e,t,n){C(t);let r=[],i=[];return T(r,i,this,e),T(r,i,t,n),Js(D,r,i)}toAffine(e){let t=this,n=e;if(n!=null&&!r.isValid(n))throw RangeError(`"invertedZ" expected valid field element`);let{X:i,Y:a,Z:o}=t;if(r.eql(o,r.ONE))return{x:i,y:a};let s=t.is0();n??=s?r.ONE:r.inv(o);let c=r.mul(i,n),l=r.mul(a,n),u=r.mul(o,n);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){let{isTorsionFree:e}=t;return o===Hc?!0:e?e(D,this):k.mulUnsafe(this,s).is0()}clearCofactor(){let{clearCofactor:e}=t;return o===Hc?this:e?e(D,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===Hc?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return Ao(e,`isCompressed`),this.assertValidity(),h(D,this,e)}toHex(e=!0){return So(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let O=e=>Fs(D,e),k=new qs(D,u);return k.bits>=6&&D.BASE.precompute(6),Object.freeze(D.prototype),Object.freeze(D),D}function qc(e){return Uint8Array.of(e?2:3)}function Jc(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Yc(e,t={}){Ps(e);let{Fn:n}=e,r=t.randomBytes===void 0?Eo:t.randomBytes,i=Object.assign(Jc(e.Fp,n),{seed:Math.max(Ts(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!!e.fromBytes(t)}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,Es(U(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!To(e))return;let s=U(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t);return e.fromBytes(r).multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=Zs(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function Xc(e,t,n={}){Ps(e);let r=t;$n(r),Ko(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let i=Object.assign({},n),a=i.randomBytes===void 0?Eo:i.randomBytes,o=i.hmac===void 0?(e,t)=>Nc(r,e,t):i.hmac,{Fp:s,Fn:c}=e,{ORDER:l,BITS:u}=c,d=Ts(l),f=Rs(a,d),{keygen:p,getPublicKey:m,getSharedSecret:h,utils:g,lengths:_}=Yc(e,i),v={prehash:!0,lowS:typeof i.lowS!=`boolean`||i.lowS,format:`compact`,extraEntropy:!1},y=l*Uc+Hc<s.ORDER;function b(e){return e>l>>Hc}function ee(e,t){if(!c.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function x(){if(!s.isOdd)throw Error(`Field doesn't support isOdd`)}function S(e,t,n){return x(),(e===n?0:2)|Number(s.isOdd(t))}function C(){if(y)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function w(e,t){zc(t);let n=_.signature;return U(e,t===`compact`?n:t===`recovered`?n+1:void 0)}class T{r;s;recovery;constructor(e,t,n){if(this.r=ee(`r`,e),this.s=ee(`s`,t),n!=null){if(C(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=v.format){w(e,t);let n;if(t===`der`){let{r:t,s:n}=Ic.toSig(U(e));return new T(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=_.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new T(c.fromBytes(i),c.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(wo(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new T(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+l:n;if(!s.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let o=s.toBytes(a),u=e.fromBytes(Co(qc(!(i&1)),o)),d=c.inv(a),f=D(U(t,void 0,`msgHash`)),p=c.create(-f*d),m=c.create(r*d),h=e.BASE.mulAddUnsafe(p,u,m);if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return b(this.s)}toBytes(e=v.format){if(zc(e),e===`der`)return wo(Ic.hexFromSig(this));let{r:t,s:n}=this,r=c.toBytes(t),i=c.toBytes(n);return e===`recovered`?(C(),Co(Uint8Array.of(this.assertRecovery()),r,i)):Co(r,i)}toHex(e){return So(this.toBytes(e))}}Object.freeze(T.prototype),Object.freeze(T);let E=i.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=Fo(e),n=e.length*8-u;return n>0?t>>BigInt(n):t}:i.bits2int,D=i.bits2int_modN===void 0?function(e){return c.create(E(e))}:i.bits2int_modN,O=Wo(u);function k(e){return Ho(`num < 2^`+u,e,Vc,O),c.toBytes(e)}function A(e,t){return U(e,void 0,`message`),t?U(r(e),void 0,`prehashed message`):e}function j(t,n,r){let{lowS:i,prehash:o,extraEntropy:s}=Bc(r,v);t=A(t,o);let u=D(t),p=c.fromBytes(n);if(!c.isValidNot0(p))throw Error(`invalid private key`);let m=[k(p),k(u)];if(s!=null&&s!==!1){let e=s===!0?a(_.secretKey):s;m.push(U(e,void 0,`extraEntropy`))}let h=Co(...m),g=u;function ee(t){let n=E(t);if(!c.isValidNot0(n))return;let r=e.BASE.multiply(n).toAffine(),a=c.create(r.x);if(a===Vc)return;let o;if(f!==void 0){let e=Fo(Es(f(d),l)),t=c.inv(c.mul(e,n)),r=c.mul(e,g),i=c.mul(e,p);o=c.create(t*c.create(r+i*a))}else{let e=ss(n,l);o=c.create(e*c.create(g+a*p))}if(o===Vc)return;let s=S(r.x,r.y,a),u=o;return i&&b(o)&&(u=c.neg(o),s^=1),new T(a,u,y?void 0:s)}return{seed:h,k2sig:ee}}function M(e,t,n={}){let{seed:i,k2sig:a}=j(e,t,n);return Go(r.outputLen,c.BYTES,o)(i,a).toBytes(n.format)}function N(t,n,r,i={}){let{lowS:a,prehash:o,format:s}=Bc(i,v);if(r=U(r,void 0,`publicKey`),n=A(n,o),!To(t)){let e=t instanceof T?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}w(t,s);try{let i=T.fromBytes(t,s),o=e.fromBytes(r);if(a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=D(n),f=c.inv(u),p=c.create(d*f),m=c.create(l*f),h=e.BASE.mulAddUnsafe(p,o,m);if(h.is0())return!1;let g=h.toAffine();return!(c.create(g.x)!==l||s===`recovered`&&i.recovery!==S(g.x,g.y,l))}catch{return!1}}function P(e,t,n={}){let{prehash:r}=Bc(n,v);return t=A(t,r),T.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:p,getPublicKey:m,getSharedSecret:h,utils:g,lengths:_,Point:e,sign:M,verify:N,recoverPublicKey:P,Signature:T,hash:r})}var Zc=Xc(Kc({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}),L),Qc=class extends Error{code=`invalid_relay_e2ee_input`;constructor(){super(`Relay E2EE input is invalid.`),this.name=`RelayE2eeValidationError`}};function K(){throw new Qc}function $c(e){return L(e)}var el=`ryco.node-key.v1`,tl=`ryco.client-key.v1`,nl=`ryco.e2ee-agreement-key.v1`,rl=`ed25519`,il=`p256`,al=`x25519`,ol={"node-identity":el,"client-identity":tl,agreement:nl},sl={"node-identity":rl,"client-identity":il,agreement:al};function cl(e,t){return(!(e instanceof Uint8Array)||e.byteLength!==t)&&K(),Uint8Array.from(e)}function ll(e){let t=0n;for(let n=0;n<e.byteLength;n+=1)t=t<<8n|BigInt(e[n]);return t}function ul(e){let t=cl(e,32);return Ac.utils.isValidPublicKey(t,!1)||K(),t}function dl(e){let t=cl(e,65);t[0]!==4&&K();let n=Zc.Point.Fp.ORDER,r=ll(t.subarray(1,33)),i=ll(t.subarray(33));(r>=n||i>=n)&&K();try{Zc.Point.fromBytes(t).is0()&&K()}catch{return K()}return t}function fl(e){return cl(e,32)}function pl(e,t){switch(e){case`node-identity`:return ul(t);case`client-identity`:return dl(t);case`agreement`:return fl(t);default:return K()}}function ml(e){return cl(e,64)}function hl(e){let t=cl(e,64),n=Zc.Point.Fn.ORDER,r=ll(t.subarray(0,32)),i=ll(t.subarray(32));return(r<1n||r>=n||i<1n||i>=n)&&K(),t}function gl(e,t){let n=pl(e,t);return L(io([ol[e],sl[e],n],Oa))}function _l(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n+=1)if(e[n]!==t[n])return!1;return!0}function vl(e){try{if(e.algorithm===`ed25519`){let t=ul(e.publicKey),n=ml(e.signature);return Ac.verify(n,e.message,t,{zip215:!1})}if(e.algorithm===`p256`){let t=dl(e.publicKey),n=hl(e.signature);return Zc.verify(n,L(e.message),t,{prehash:!1,lowS:!1,format:`compact`})}return!1}catch{return!1}}function yl(e){return e===1||e===2}function bl(e){return e===`c2n`||e===`n2c`}function xl(e){return e===1||e===2||e===3||e===4}function Sl(e){return e===1||e===2||e===3}function Cl(e){switch(e){case 1:return{maxBytes:pn,exact:!1};case 2:return{maxBytes:mn,exact:!1};case 3:return{maxBytes:64,exact:!0}}}var wl=123,Tl=91,El=Object.freeze({kind:`envelope`}),Dl=Object.freeze({kind:`negotiation`}),Ol=Object.freeze({kind:`legacy-json`}),kl=Object.freeze({kind:`other`,reason:`empty`}),Al=Object.freeze({kind:`other`,reason:`unknown_discriminator`});function jl(e){if(e.byteLength===0)return kl;let t=e[0];return t===1?El:t===2?Dl:t===wl||t===Tl?Ol:Al}var Ml=1,Nl=2,Pl=3,Fl=7,Il=17;function Ll(e,t){if(typeof e!=`bigint`||e<0n||e>4294967295n)throw TypeError(`E2EE envelope epoch must be a bigint within the uint32 field range.`);if(typeof t!=`bigint`||t<0n||t>18446744073709551615n)throw TypeError(`E2EE envelope counter must be a bigint within the uint64 field range.`)}function Rl(e,t,n,r){let i=r;for(let r=n-1;r>=0;--r)e[t+r]=Number(i&255n),i>>=8n}function zl(e,t,n){let r=0n;for(let i=0;i<n;i+=1)r=r<<8n|BigInt(e[t+i]);return r}function Bl(e,t){if(!yl(t.suite))throw TypeError(`E2EE envelope suite must be a registered suite id.`);Ll(t.epoch,t.counter),e[0]=1,e[Ml]=1,e[Nl]=t.suite,Rl(e,Pl,4,t.epoch),Rl(e,Fl,8,t.counter)}function Vl(e){let t=new Uint8Array(15);return Bl(t,e),t}function Hl(e){if(e.ciphertext.byteLength<Il)throw TypeError(`E2EE envelope ciphertext must cover the inner type byte and the tag.`);let t=new Uint8Array(15+e.ciphertext.byteLength);return Bl(t,e),t.set(e.ciphertext,15),t}function Ul(e){if(e.byteLength===0||e[0]!==1)return{kind:`error`,reason:`bad_discriminator`};if(e.byteLength<32)return{kind:`error`,reason:`truncated`};if(e[Ml]!==1)return{kind:`error`,reason:`unsupported_version`};let t=e[Nl];return yl(t)?{kind:`ok`,value:{version:1,suite:t,epoch:zl(e,Pl,4),counter:zl(e,Fl,8),header:e.subarray(0,15),ciphertext:e.subarray(15)}}:{kind:`error`,reason:`unsupported_suite`}}function Wl(e,t){Ll(e,t);let n=new Uint8Array(12);return Rl(n,0,4,e),Rl(n,4,8,t),n}function Gl(e){if(e.byteLength!==15)throw TypeError(`E2EE AEAD nonce requires the exact envelope header.`);return e.subarray(Pl,15)}function Kl(e){if(e.header.byteLength!==15)throw TypeError(`E2EE AAD requires the exact envelope header.`);if(e.sessionBindingHash.byteLength!==32)throw TypeError(`E2EE AAD requires a full-length session binding hash.`);let t=new Uint8Array(50);return t.set(e.header),t.set(e.sessionBindingHash,15),t.set(ql(e.direction),47),t}function ql(e){if(!bl(e))throw TypeError(`E2EE direction must be a registered direction label.`);let t=new Uint8Array(3);for(let n=0;n<3;n+=1)t[n]=e.charCodeAt(n);return t}function Jl(e,t){if(!xl(e))throw TypeError(`E2EE inner record type must be a registered type.`);let n=new Uint8Array(1+t.byteLength);return n[0]=e,n.set(t,1),n}function Yl(e){if(e.byteLength<1)return{kind:`error`,reason:`truncated`};let t=e[0];return xl(t)?{kind:`ok`,value:{innerType:t,body:e.subarray(1)}}:{kind:`error`,reason:`reserved_inner_type`}}var Xl=2,Zl=io(new Uint8Array(60),Oa);function Ql(e,t){if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n+=1)if(e[n]!==t[n])return!1;return!0}function $l(e,t){if(!Sl(e))throw TypeError(`E2EE negotiation record type must be a registered type.`);let n=Xl+t.byteLength,r=Cl(e);if(r.exact?n!==r.maxBytes:n>r.maxBytes)throw RangeError(`E2EE negotiation record exceeds the bound its type fixes.`);if(e===3&&!Ql(t,Zl))throw TypeError(`E2EE handshake reject records are byte-identical; this body is not.`);let i=new Uint8Array(n);return i[0]=2,i[1]=e,i.set(t,Xl),i}function eu(e){if(e.byteLength===0||e[0]!==2)return{kind:`error`,reason:`bad_discriminator`};if(e.byteLength<Xl)return{kind:`error`,reason:`truncated`};let t=e[1];if(!Sl(t))return{kind:`error`,reason:`reserved_record_type`};let n=Cl(t);if(e.byteLength>n.maxBytes)return{kind:`error`,reason:`too_large`};if(n.exact&&e.byteLength!==n.maxBytes)return{kind:`error`,reason:`length_mismatch`};let r=e.subarray(Xl);return t===3&&!Ql(r,Zl)?{kind:`error`,reason:`non_canonical_reject`}:{kind:`ok`,value:{recordType:t,body:r}}}var tu=[`_tag`,`statement`],nu=new TextDecoder,ru=new TextEncoder;function iu(e){if(e.byteLength===0||e[0]!==wl)return{kind:`error`,reason:`not_carrier`};let t;try{t=JSON.parse(nu.decode(e))}catch{return{kind:`error`,reason:`not_carrier`}}if(typeof t!=`object`||!t||Array.isArray(t))return{kind:`error`,reason:`not_carrier`};let n=t;if(n._tag!==`ryco.e2ee.capability.v1`)return{kind:`error`,reason:`not_carrier`};if(e.byteLength>6969)return{kind:`error`,reason:`malformed`};let r=Object.keys(n);if(r.length!==tu.length||tu.some((e,t)=>r[t]!==e))return{kind:`error`,reason:`malformed`};let i=n.statement;if(typeof i!=`string`||i.length===0||!Ql(ru.encode(JSON.stringify({_tag:`ryco.e2ee.capability.v1`,statement:i})),e))return{kind:`error`,reason:`malformed`};let a=ou(i);return a===void 0?{kind:`error`,reason:`malformed`}:{kind:`ok`,value:a}}var au=new Map([...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`].map((e,t)=>[e,t]));function ou(e){if(e.length%4==1)return;let t=new Uint8Array(Math.floor(e.length*3/4)),n=0,r=0,i=0;for(let a of e){let e=au.get(a);if(e===void 0)return;n=n<<6|e,r+=6,r>=8&&(r-=8,t[i]=n>>r&255,n&=(1<<r)-1,i+=1)}if(!(r>0&&n&(1<<r)-1))return t}var su=`ryco.node-e2ee-prekey.v1`,cu=`ryco.client-e2ee-prekey.v1`,lu=`ryco.node-e2ee-capability-digest.v1`,uu=`ryco.relay-e2ee.context.v1`,du=`ryco.relay-e2ee.account-context.v1`,fu=`ryco.relay-e2ee.prologue.v1`,pu=`25519`,mu=`SHA256`;function hu(e){return e===`native`?`IK`:`NX`}function gu(e){return e?[`IK`]:[`IK`,`NX`]}var _u={allowIndefinite:!1,allowUndefined:!1,allowInfinity:!1,allowNaN:!1,allowBigInt:!1,strict:!0,useMaps:!0,rejectDuplicateMapKeys:!0,tags:{}};function vu(e){let t=new oo(e,_u);for(;!t.done();)if(R.equals(t.next().type,R.float))return!0;return!1}function yu(e){if(!(e instanceof Uint8Array)||e.byteLength===0)return{kind:`error`,reason:`malformed`};let t;try{t=go(e,_u)}catch{try{if(!_l(io(go(e,{..._u,strict:!1}),Oa),e))return{kind:`error`,reason:`non_canonical`}}catch{}return{kind:`error`,reason:`malformed`}}if(vu(e))return{kind:`error`,reason:`float_forbidden`};let n;try{n=io(t,Oa)}catch{return{kind:`error`,reason:`non_canonical`}}return _l(n,e)?{kind:`ok`,value:t}:{kind:`error`,reason:`non_canonical`}}function bu(e){return Uint8Array.from(io(e,Oa))}var xu=`[A-Za-z0-9_-]{22}`,Su=RegExp(`^node_${xu}$`),Cu=RegExp(`^nkey_${xu}$`),wu=RegExp(`^epk_${xu}$`),Tu=RegExp(`^nct_${xu}$`),Eu=new Set([`localhost`,`127.0.0.1`,`[::1]`]),Du=new TextEncoder,Ou=mt(x),ku=mt(Ot),Au=mt(A),ju=mt(Ht);function Mu(e,t){return(typeof e!=`string`||!t.test(e))&&K(),e}function Nu(e){return(!Number.isSafeInteger(e)||e<0)&&K(),e}function Pu(e){return(!Number.isSafeInteger(e)||e<0||e>65535)&&K(),e}function Fu(e){(typeof e!=`string`||e.length===0||e.length>512)&&K();let t;try{t=new URL(e)}catch{return K()}let n=t.protocol===`http:`&&Eu.has(t.hostname);return(t.protocol!==`https:`&&!n||t.username!==``||t.password!==``||t.pathname!==`/`||t.search!==``||t.hash!==``||e!==t.origin)&&K(),Du.encode(t.origin).byteLength>128&&K(),t.origin}function Iu(e){(typeof e!=`string`||e.length===0)&&K();let t=Du.encode(e).byteLength;return(t===0||t>256)&&K(),e}function Lu(e){return Lt(Ou(e))&&K(),e}function Ru(e){return Lt(ku(e))&&K(),e}function zu(e){return Lt(Au(e))&&K(),e}function Bu(e){return yl(e)||K(),e}function Vu(e){return(!(e instanceof Uint8Array)||e.byteLength!==32)&&K(),Uint8Array.from(e)}function Hu(e){return e.byteLength>1024&&K(),e}function Uu(e,t){let n=Fu(e.hubOrigin),r=Mu(e.nodeId,Su),i=Mu(e.identityKeyId,Cu),a=Mu(e.prekeyId,wu),o=ul(e.identityPublicKey);return Hu(bu([su,n,r,rl,i,a,o,t===void 0?gl(`node-identity`,o):Vu(t),fl(e.agreementPublicKey),pu,mu,Nu(e.createdAt),Nu(e.expiresAt)]))}function Wu(e){let t=Fu(e.hubOrigin),n=Iu(e.accountId),r=dl(e.identityPublicKey);return Hu(bu([cu,t,n,il,r,gl(`client-identity`,r),fl(e.agreementPublicKey),pu,mu,Nu(e.createdAt),Nu(e.expiresAt)]))}var Gu=13;function Ku(e){return typeof e==`string`}function qu(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Ju(e,t){return e instanceof Uint8Array&&e.byteLength===t}function Yu(e){let t=yu(e);if(t.kind===`error`)return t;let n=t.value;if(!Array.isArray(n)||n.length!==Gu)return{kind:`error`,reason:`malformed`};let[r,i,a,o,s,c,l,u,d,f,p,m,h]=n;if(r!==`ryco.node-identity-continuity.v1`||s!==`ed25519`||d!==`ed25519`||!Ku(i)||!Ku(a)||!qu(o)||!Ku(c)||!Ku(f)||!Ju(l,32)||!Ju(u,32)||!Ju(p,32)||!Ju(m,32)||!qu(h)||!Cu.test(c)||!Cu.test(f)||!Tu.test(a)||o<1)return{kind:`error`,reason:`malformed`};let g,_;try{g=gl(`node-identity`,l),_=gl(`node-identity`,p)}catch{return{kind:`error`,reason:`malformed`}}return!_l(g,u)||!_l(_,m)?{kind:`error`,reason:`malformed`}:{kind:`ok`,value:{hubOrigin:i,continuityId:a,generation:o,oldKeyId:c,oldPublicKey:l,oldFingerprint:u,newKeyId:f,newPublicKey:p,newFingerprint:m,createdAt:h}}}function Xu(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.transcript instanceof Uint8Array&&t.signature instanceof Uint8Array&&t.signature.byteLength===64}function Zu(e){if(!Array.isArray(e.chain))return{kind:`error`,failure:`malformed_entry`};if(e.chain.length>8)return{kind:`error`,failure:`chain_too_long`};let t,n;try{t=ul(e.identityPublicKey),n=gl(`node-identity`,t)}catch{return{kind:`error`,failure:`invalid_identity_key`}}let r=[],i;for(let t of e.chain){if(!Xu(t))return{kind:`error`,failure:`malformed_entry`};let n=Yu(t.transcript);if(n.kind===`error`)return{kind:`error`,failure:`malformed_entry`};let a=n.value;if(a.hubOrigin!==e.hubOrigin)return{kind:`error`,failure:`hub_origin_mismatch`};if(a.continuityId!==e.continuityId)return{kind:`error`,failure:`continuity_id_mismatch`};if(i!==void 0){if(a.generation!==i.generation+1)return{kind:`error`,failure:`generation_not_consecutive`};if(!_l(a.oldPublicKey,i.newPublicKey)||!_l(a.oldFingerprint,i.newFingerprint))return{kind:`error`,failure:`link_mismatch`}}if(!vl({algorithm:`ed25519`,publicKey:a.oldPublicKey,message:t.transcript,signature:t.signature}))return{kind:`error`,failure:`invalid_signature`};r.push(a),i=a}if(i!==void 0&&!_l(i.newPublicKey,t))return{kind:`error`,failure:`identity_key_mismatch`};let a=e.pinnedIdentityFingerprint;return a===void 0?{kind:`ok`,certificates:r}:_l(a,n)?{kind:`ok`,certificates:r,pinnedFingerprintUnchanged:!0}:r.some(e=>_l(e.oldFingerprint,a))?{kind:`ok`,certificates:r,pinnedFingerprintUnchanged:!1}:{kind:`error`,failure:`pin_not_reached`}}var Qu=2,$u=19,ed=6,td=2,nd=255;function rd(e){return e===`non_canonical`?`statement_non_canonical`:e===`float_forbidden`?`statement_float_forbidden`:`statement_malformed`}function id(e){return e===`non_canonical`?`transcript_non_canonical`:e===`float_forbidden`?`transcript_float_forbidden`:`transcript_malformed`}function ad(e){return{kind:`error`,failure:e}}function od(e){return qu(e)&&e<=65535}function sd(e){if(!Array.isArray(e)||e.length!==ed)return;let[t,n,r,i,a,o]=e;if(Ku(t)&&wu.test(t)&&Ju(n,32)&&Ju(r,64)&&Ju(i,32)&&qu(a)&&qu(o))return{prekeyId:t,agreementPublicKey:n,crossSignature:r,agreementFingerprint:i,createdAt:a,expiresAt:o}}function cd(e){if(!Array.isArray(e)||e.length!==td)return;let[t,n]=e;if(!(!(t instanceof Uint8Array)||t.byteLength===0||t.byteLength>1024||!Ju(n,64)))return{transcript:t,signature:n}}function ld(e){if(!(e instanceof Uint8Array))return ad(`statement_malformed`);if(e.byteLength>5190)return ad(`statement_too_large`);let t=yu(e);if(t.kind===`error`)return ad(rd(t.reason));if(!Array.isArray(t.value)||t.value.length!==Qu)return ad(`statement_malformed`);let[n,r]=t.value;if(!(n instanceof Uint8Array)||n.byteLength===0)return ad(`statement_malformed`);if(n.byteLength>5120)return ad(`transcript_too_large`);if(!Ju(r,64))return ad(`statement_malformed`);let i=yu(n);if(i.kind===`error`)return ad(id(i.reason));if(!Array.isArray(i.value)||i.value.length!==$u)return ad(`transcript_malformed`);let[a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,ee,x,S]=i.value;if(a!==`ryco.node-e2ee-capability.v1`||c!==`ed25519`||!Ku(o)||!Ku(s)||!Su.test(s)||!Ku(l)||!Cu.test(l)||!Ju(u,32)||!Ju(d,32)||!od(f)||!od(p)||typeof _!=`boolean`||typeof v!=`boolean`||!qu(b)||!qu(ee)||!qu(x)||!Ku(S)||!Tu.test(S))return ad(`transcript_malformed`);if(Du.encode(o).byteLength>128)return ad(`hub_origin_too_long`);try{Fu(o)}catch{return ad(`transcript_malformed`)}if(!Array.isArray(m)||m.length===0)return ad(`transcript_malformed`);if(m.length>8)return ad(`suite_registry_too_large`);if(!m.every(e=>qu(e)&&e<=nd)||!Array.isArray(g))return ad(`transcript_malformed`);if(g.length>8)return ad(`continuity_chain_too_long`);let C=[];for(let e of g){let t=cd(e);if(t===void 0)return ad(`transcript_malformed`);C.push(t)}let w=sd(h);if(w===void 0)return ad(`transcript_malformed`);let T=gu(v);return!Array.isArray(y)||y.length!==T.length||!T.every((e,t)=>y[t]===e)?ad(`transcript_malformed`):{kind:`ok`,value:{transcript:n,signature:r,hubOrigin:o,nodeId:s,identityKeyId:l,identityPublicKey:u,identityFingerprint:d,e2eeVersionMin:f,e2eeVersionMax:p,suiteRegistry:m,prekeyCertificate:w,continuityChain:C,requireE2EE:_,requireApprovedClientE2EE:v,admittedPatterns:T,policyGeneration:b,issuedAt:ee,expiresAt:x,continuityId:S}}}function ud(e){(!(e instanceof Uint8Array)||e.byteLength===0||e.byteLength>5120)&&K();let t=L(e);t.byteLength!==32&&K();let n=bu([lu,t]);return n.byteLength!==72&&K(),n}function dd(e,t){let n=Fu(e.hubOrigin),r=zu(e.channelId),i=Pu(e.relayProtocolMajor),a=Pu(e.relayProtocolMinor);e.e2eeVersion!==1&&K();let o=Bu(e.suiteId),s=Mu(e.nodeId,Su),c=Vu(e.nodeIdentityFingerprint),l=Lu(e.clientIntendedCapability),u=Ru(e.clientIntendedRole),d=Lu(e.channelOpenCapability),f=Ru(e.channelOpenEffectiveRole),p=Mu(e.nodeContinuityId,Tu);(!Array.isArray(e.nodeContinuityChainTranscripts)||e.nodeContinuityChainTranscripts.length>8)&&K();let m=[Vu(e.nodeAgreementFingerprint)];for(let t of e.nodeContinuityChainTranscripts)(!(t instanceof Uint8Array)||t.byteLength===0)&&K(),m.push(L(t));return[t,n,r,i,a,1,o,s,rl,c,e.client.tier===`native`?Iu(e.client.accountId):``,l,u,d,f,m,e.client.tier===`native`?[Vu(e.client.identityFingerprint),Vu(e.client.agreementFingerprint)]:[],p]}function fd(e){return e.suiteId!==1&&K(),bu(dd(e,uu))}function pd(e){(e.suiteId!==2||e.relayProtocolMajor!==1||e.relayProtocolMinor<3)&&K();let t=ju(e.grant);Lt(t)&&K();let n=t.value,r=Vu(e.nodeAgreementFingerprint),i=Vu(e.deviceGrantDigest);return(n.suiteId!==e.suiteId||n.issuerHubOrigin!==e.hubOrigin||n.nodeId!==e.nodeId||n.accountId!==e.client.accountId||n.nodeContinuityId!==e.nodeContinuityId||!_l(n.nodeIdentityFingerprint,e.nodeIdentityFingerprint)||!_l(n.nodeAgreementFingerprint,r)||!_l(n.deviceIdentityFingerprint,e.client.identityFingerprint)||!_l(n.deviceAgreementFingerprint,e.client.agreementFingerprint))&&K(),bu([...dd(e,du),i,n.relayTicketId,n.nodeCapabilityStatementDigest,n.clientPrekeyCertificateDigest,n.enrollmentId,n.enrollmentRevision,n.accountAuthEpoch,n.deviceAuthEpoch,n.maximumRole,[...n.capabilities],n.nonce])}function md(e,t){return(!(e instanceof Uint8Array)||e.byteLength===0||e.byteLength>1024)&&K(),bu([Uint8Array.from(e),hl(t)])}function hd(e){(!(e instanceof Uint8Array)||e.byteLength===0)&&K();let t=L(e);return t.byteLength!==32&&K(),t}function gd(e){let t=Fu(e.hubOrigin),n=zu(e.channelId),r=Pu(e.relayProtocolMajor),i=Pu(e.relayProtocolMinor);e.e2eeVersion!==1&&K();let a=Bu(e.suiteId),o=Mu(e.nodeId,Su);return(!(e.contextCommitment instanceof Uint8Array)||e.contextCommitment.byteLength!==32)&&K(),bu([fu,t,n,r,i,1,a,o,Uint8Array.from(e.contextCommitment)])}function _d(e){let t;try{if(t=Uu({hubOrigin:e.hubOrigin,nodeId:e.nodeId,identityKeyId:e.identityKeyId,prekeyId:e.prekeyCertificate.prekeyId,identityPublicKey:e.identityPublicKey,agreementPublicKey:e.prekeyCertificate.agreementPublicKey,createdAt:e.prekeyCertificate.createdAt,expiresAt:e.prekeyCertificate.expiresAt},e.identityFingerprint),!_l(gl(`node-identity`,e.identityPublicKey),e.identityFingerprint)||!_l(gl(`agreement`,e.prekeyCertificate.agreementPublicKey),e.prekeyCertificate.agreementFingerprint))return!1}catch{return!1}return vl({algorithm:rl,publicKey:e.identityPublicKey,message:t,signature:e.prekeyCertificate.crossSignature})}function vd(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var yd=e=>e?`"${e}" `:``;function bd(e,t=``){if(typeof e!=`boolean`)throw TypeError(yd(t)+`expected boolean, got type=`+typeof e);return e}function xd(e,t=``){if(typeof e!=`number`)throw TypeError(yd(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(yd(t)+`expected integer >= 0, got `+e);return e}function Sd(e,t,n=``){if(vd(e)&&(t===void 0||e.length===t))return e;t!==void 0&&xd(t,`length`);let r=vd(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=yd(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}var Cd=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`)};function wd(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function Td(e,t){Sd(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function Ed(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Dd(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Od(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var kd=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ad(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function jd(e){for(let t=0;t<e.length;t++)e[t]=Ad(e[t]);return e}var Md=kd?e=>e:jd;function Nd(e,t){return Cd(e,`defaults`),Cd(t,`opts`),Object.assign(e,t)}function Pd(e,t){if(e=Sd(e),t=Sd(t),e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function Fd(e,t,n){let r=t,i=n||(()=>[]),a=(e,t)=>r(t,...i(e)).update(e).digest(),o=r(new Uint8Array(e),...i(new Uint8Array));return a.outputLen=o.outputLen,a.blockLen=o.blockLen,a.create=(e,...t)=>r(e,...t),a}var Id=(e,t)=>{function n(n,...r){if(Sd(n,void 0,`key`),e.nonceLength!==void 0){let t=r[0];Sd(t,e.varSizeNonce?void 0:e.nonceLength,`nonce`)}let i=e.tagLength,a=e.nonceLength===void 0?0:1;if(!e.withAAD){for(let e=a;e<r.length;e++)if(vd(r[e]))throw Error(`AAD not supported`)}e.withAAD&&r[a]!==void 0&&Sd(r[a],void 0,`AAD`);let o=t(n,...r),s=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);Sd(t,void 0,`output`)}},c=!1;return{encrypt(e,t){if(c)throw Error(`cannot encrypt() twice with same key + nonce`);return c=!0,Sd(e,void 0,`data`),s(o.encrypt.length,t),o.encrypt(e,t)},decrypt(e,t){if(Sd(e,void 0,`data`),i&&e.length<i)throw Error(`"ciphertext" expected length >= tagLength=`+i);return s(o.decrypt.length,t),o.decrypt(e,t)}}}return Object.assign(n,e),n};function Ld(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(Sd(t,e,`output`),n&&!zd(t))throw Error(`invalid output, must be aligned`);return t}function Rd(e,t,n){xd(e),xd(t),bd(n);let r=new Uint8Array(16),i=Od(r);return i.setBigUint64(0,BigInt(t),n),i.setBigUint64(8,BigInt(e),n),r}function zd(e){return e.byteOffset%4==0}function Bd(e){return Uint8Array.from(Sd(e))}var Vd=e=>Uint8Array.from(e.split(``),e=>e.charCodeAt(0)),Hd=Md(Ed(Vd(`expand 16-byte k`))),Ud=Md(Ed(Vd(`expand 32-byte k`)));function q(e,t){return e<<t|e>>>32-t}var Wd=64,Gd=16,Kd=2**32-1,qd=Uint32Array.of();function Jd(e,t,n,r,i,a,o,s){let c=i.length,l=new Uint8Array(Wd),u=Ed(l),d=kd&&zd(i)&&zd(a),f=d?Ed(i):qd,p=d?Ed(a):qd;if(!kd){for(let d=0;d<c;o++){if(e(t,n,r,u,o,s),Md(u),o>=Kd)throw Error(`arx: counter overflow`);let f=Math.min(Wd,c-d);for(let e=0,t;e<f;e++)t=d+e,a[t]=i[t]^l[e];d+=f}return}for(let m=0;m<c;o++){if(e(t,n,r,u,o,s),o>=Kd)throw Error(`arx: counter overflow`);let h=Math.min(Wd,c-m);if(d&&h===Wd){let e=m/4;if(m%4!=0)throw Error(`arx: invalid block position`);for(let t=0,n;t<Gd;t++)n=e+t,p[n]=f[n]^u[t];m+=Wd;continue}for(let e=0,t;e<h;e++)t=m+e,a[t]=i[t]^l[e];m+=h}}function Yd(e,t){let{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:a,rounds:o}=Nd({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=`function`)throw Error(`core must be a function`);return xd(i),xd(o),bd(a),bd(n),(t,s,c,l,u=0)=>{Sd(t,void 0,`key`),Sd(s,void 0,`nonce`),Sd(c,void 0,`data`);let d=c.length;if(l=Ld(d,l,!1),xd(u),u<0||u>=Kd)throw Error(`arx: counter overflow`);let f=[],p=t.length,m,h;if(p===32)f.push(m=Bd(t)),h=Ud;else if(p===16&&n)m=new Uint8Array(32),m.set(t),m.set(t,16),h=Hd,f.push(m);else throw Sd(t,32,`arx key`),Error(`invalid key size`);(!kd||!zd(s))&&f.push(s=Bd(s));let g=Ed(m);if(r){if(s.length!==24)throw Error(`arx: extended nonce must be 24 bytes`);let e=s.subarray(0,16);if(kd)r(h,g,Ed(e),g);else{let t=Md(Uint32Array.from(h));r(t,g,Ed(e),g),Dd(t),Md(g)}s=s.subarray(16)}else kd||Md(g);let _=16-i;if(_!==s.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let e=new Uint8Array(12);e.set(s,a?0:12-s.length),s=e,f.push(s)}let v=Md(Ed(s));try{return Jd(e,h,g,v,c,l,u,o),l}finally{Dd(...f)}}}function Xd(e,t){return e[t++]&255|(e[t++]&255)<<8}var Zd=class{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(e){e=Bd(Sd(e,32,`key`));let t=Xd(e,0),n=Xd(e,2),r=Xd(e,4),i=Xd(e,6),a=Xd(e,8),o=Xd(e,10),s=Xd(e,12),c=Xd(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|n<<3)&8191,this.r[2]=(n>>>10|r<<6)&7939,this.r[3]=(r>>>7|i<<9)&8191,this.r[4]=(i>>>4|a<<12)&255,this.r[5]=a>>>1&8190,this.r[6]=(a>>>14|o<<2)&8191,this.r[7]=(o>>>11|s<<5)&8065,this.r[8]=(s>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=Xd(e,16+2*t)}process(e,t,n=!1){let r=n?0:2048,{h:i,r:a}=this,o=a[0],s=a[1],c=a[2],l=a[3],u=a[4],d=a[5],f=a[6],p=a[7],m=a[8],h=a[9],g=Xd(e,t+0),_=Xd(e,t+2),v=Xd(e,t+4),y=Xd(e,t+6),b=Xd(e,t+8),ee=Xd(e,t+10),x=Xd(e,t+12),S=Xd(e,t+14),C=i[0]+(g&8191),w=i[1]+((g>>>13|_<<3)&8191),T=i[2]+((_>>>10|v<<6)&8191),E=i[3]+((v>>>7|y<<9)&8191),D=i[4]+((y>>>4|b<<12)&8191),O=i[5]+(b>>>1&8191),k=i[6]+((b>>>14|ee<<2)&8191),A=i[7]+((ee>>>11|x<<5)&8191),j=i[8]+((x>>>8|S<<8)&8191),M=i[9]+(S>>>5|r),N=0,P=N+C*o+5*h*w+5*m*T+5*p*E+5*f*D;N=P>>>13,P&=8191,P+=5*d*O+5*u*k+5*l*A+5*c*j+5*s*M,N+=P>>>13,P&=8191;let te=N+C*s+w*o+5*h*T+5*m*E+5*p*D;N=te>>>13,te&=8191,te+=5*f*O+5*d*k+5*u*A+5*l*j+5*c*M,N+=te>>>13,te&=8191;let ne=N+C*c+w*s+T*o+5*h*E+5*m*D;N=ne>>>13,ne&=8191,ne+=5*p*O+5*f*k+5*d*A+5*u*j+5*l*M,N+=ne>>>13,ne&=8191;let F=N+C*l+w*c+T*s+E*o+5*h*D;N=F>>>13,F&=8191,F+=5*m*O+5*p*k+5*f*A+5*d*j+5*u*M,N+=F>>>13,F&=8191;let re=N+C*u+w*l+T*c+E*s+D*o;N=re>>>13,re&=8191,re+=5*h*O+5*m*k+5*p*A+5*f*j+5*d*M,N+=re>>>13,re&=8191;let ie=N+C*d+w*u+T*l+E*c+D*s;N=ie>>>13,ie&=8191,ie+=O*o+5*h*k+5*m*A+5*p*j+5*f*M,N+=ie>>>13,ie&=8191;let ae=N+C*f+w*d+T*u+E*l+D*c;N=ae>>>13,ae&=8191,ae+=O*s+k*o+5*h*A+5*m*j+5*p*M,N+=ae>>>13,ae&=8191;let oe=N+C*p+w*f+T*d+E*u+D*l;N=oe>>>13,oe&=8191,oe+=O*c+k*s+A*o+5*h*j+5*m*M,N+=oe>>>13,oe&=8191;let se=N+C*m+w*p+T*f+E*d+D*u;N=se>>>13,se&=8191,se+=O*l+k*c+A*s+j*o+5*h*M,N+=se>>>13,se&=8191;let ce=N+C*h+w*m+T*p+E*f+D*d;N=ce>>>13,ce&=8191,ce+=O*u+k*l+A*c+j*s+M*o,N+=ce>>>13,ce&=8191,N=(N<<2)+N|0,N=N+P|0,P=N&8191,N>>>=13,te+=N,i[0]=P,i[1]=te,i[2]=ne,i[3]=F,i[4]=re,i[5]=ie,i[6]=ae,i[7]=oe,i[8]=se,i[9]=ce}finalize(){let{h:e,pad:t}=this,n=new Uint16Array(10),r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=r*5,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(r^1)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let a=e[0]+t[0];e[0]=a&65535;for(let n=1;n<8;n++)a=(e[n]+t[n]|0)+(a>>>16)|0,e[n]=a&65535;Dd(n)}update(e){wd(this),Sd(e),e=Bd(e);let{buffer:t,blockLen:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(n-this.pos,r-i);if(a===n){for(;n<=r-i;i+=n)this.process(e,i);continue}t.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){this.destroyed=!0,Dd(this.h,this.r,this.buffer,this.pad)}digestInto(e){wd(this),Td(e,this),this.finished=!0;let{buffer:t,h:n}=this,{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}},Qd=Fd(32,e=>new Zd(e));function $d(e,t,n,r,i,a=20){let o=e[0],s=e[1],c=e[2],l=e[3],u=t[0],d=t[1],f=t[2],p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],v=i,y=n[0],b=n[1],ee=n[2],x=o,S=s,C=c,w=l,T=u,E=d,D=f,O=p,k=m,A=h,j=g,M=_,N=v,P=y,te=b,ne=ee;for(let e=0;e<a;e+=2)x=x+T|0,N=q(N^x,16),k=k+N|0,T=q(T^k,12),x=x+T|0,N=q(N^x,8),k=k+N|0,T=q(T^k,7),S=S+E|0,P=q(P^S,16),A=A+P|0,E=q(E^A,12),S=S+E|0,P=q(P^S,8),A=A+P|0,E=q(E^A,7),C=C+D|0,te=q(te^C,16),j=j+te|0,D=q(D^j,12),C=C+D|0,te=q(te^C,8),j=j+te|0,D=q(D^j,7),w=w+O|0,ne=q(ne^w,16),M=M+ne|0,O=q(O^M,12),w=w+O|0,ne=q(ne^w,8),M=M+ne|0,O=q(O^M,7),x=x+E|0,ne=q(ne^x,16),j=j+ne|0,E=q(E^j,12),x=x+E|0,ne=q(ne^x,8),j=j+ne|0,E=q(E^j,7),S=S+D|0,N=q(N^S,16),M=M+N|0,D=q(D^M,12),S=S+D|0,N=q(N^S,8),M=M+N|0,D=q(D^M,7),C=C+O|0,P=q(P^C,16),k=k+P|0,O=q(O^k,12),C=C+O|0,P=q(P^C,8),k=k+P|0,O=q(O^k,7),w=w+T|0,te=q(te^w,16),A=A+te|0,T=q(T^A,12),w=w+T|0,te=q(te^w,8),A=A+te|0,T=q(T^A,7);let F=0;r[F++]=o+x|0,r[F++]=s+S|0,r[F++]=c+C|0,r[F++]=l+w|0,r[F++]=u+T|0,r[F++]=d+E|0,r[F++]=f+D|0,r[F++]=p+O|0,r[F++]=m+k|0,r[F++]=h+A|0,r[F++]=g+j|0,r[F++]=_+M|0,r[F++]=v+N|0,r[F++]=y+P|0,r[F++]=b+te|0,r[F++]=ee+ne|0}var ef=Yd($d,{counterRight:!1,counterLength:4,allowShortKeys:!1}),tf=new Uint8Array(16),nf=(e,t)=>{e.update(t);let n=t.length%16;n&&e.update(tf.subarray(n))},rf=new Uint8Array(32);function af(e,t,n,r,i){i!==void 0&&Sd(i,void 0,`AAD`);let a=e(t,n,rf),o=Rd(r.length,i?i.length:0,!0),s=Qd.create(a);i&&nf(s,i),nf(s,r),s.update(o);let c=s.digest();return Dd(a,o),c}var of=Id({blockSize:64,nonceLength:12,tagLength:16,withAAD:!0},(e=>(t,n,r)=>({encrypt(i,a){let o=i.length;a=Ld(o+16,a,!1),a.set(i);let s=a.subarray(0,-16);e(t,n,s,s,1);let c=af(e,t,n,s,r);return a.set(c,o),Dd(c),a},decrypt(i,a){a=Ld(i.length-16,a,!1);let o=i.subarray(0,-16),s=i.subarray(-16),c=af(e,t,n,o,r);if(!Pd(s,c))throw Dd(c),Error(`invalid tag`);return a.set(i.subarray(0,-16)),e(t,n,a,a,1),Dd(c),a}}))(ef));function sf(e,t,n){return $n(e),n===void 0&&(n=new Uint8Array(e.outputLen)),Nc(e,n,t)}var cf=Uint8Array.of(0),lf=Uint8Array.of();function uf(e,t,n,r=32,i){$n(e),Zn(r,`length`),Qn(t,void 0,`prk`);let a=e.outputLen;if(t.length<a)throw Error(`"prk" must be at least HashLen octets`);if(r>255*a)throw Error(`Length must be <= 255*HashLen`);let o=Math.ceil(r/a);if(n===void 0?n=lf:Qn(n,void 0,`info`),!o)return i&&rr(t),new Uint8Array;let s=i&&o===1?t:new Uint8Array(o*a),{iHash:c,oHash:l}=Nc.create(e,t),u=i?t:new Uint8Array(a),d=o>1?i?.iHash||e.create():void 0;for(let e=0;e<o-1;e++){cf[0]=e+1;let t=c._cloneInto(d);e&&t.update(u),t.update(n).update(cf).digestInto(u),l._cloneInto(d).update(u).digestInto(u),s.set(u,a*e)}if(cf[0]=o,o>1&&c.update(u),c.update(n).update(cf).digestInto(u),l.update(u).digestInto(u),s.set(u,a*(o-1)),c.destroy(),l.destroy(),d?.destroy(),u!==s&&rr(u),rr(cf),r===s.length)return s;let f=s.slice(0,r);return rr(s),f}var df=`ryco.relay-e2ee.confirmation-key.v1`,ff=`ryco.relay-e2ee.aead-key.v1`,pf=`ryco.relay-e2ee.ratchet.v1`,mf=dr(df),hf=dr(ff),gf=dr(pf);function _f(e,t){if(!(e instanceof Uint8Array)||e.byteLength!==32)throw TypeError(`Relay E2EE ${t} must be exactly E2EE_SECRET_BYTES long.`);return e}function vf(e){if(!bl(e))throw TypeError(`Relay E2EE direction must be a registered direction label.`);return e}function yf(e,t){return fr(e,ql(vf(t)))}function bf(...e){for(let t of e)if(t instanceof Uint8Array)try{rr(t)}catch{}}function xf(e,t){try{return t()}catch(t){throw bf(...e),t}}function Sf(e){return uf(L,_f(e,`exporter secret`),mf,32)}function Cf(e,t){return uf(L,_f(e,`epoch secret`),yf(hf,t),32)}function wf(e,t){return uf(L,_f(e,`epoch secret`),yf(gf,t),32)}function Tf(e){return xf([e.epochSecretC2N,e.epochSecretN2C,e.exporterSecret],()=>({epochSecretC2N:_f(e.epochSecretC2N,`epoch secret`),epochSecretN2C:_f(e.epochSecretN2C,`epoch secret`),exporterSecret:_f(e.exporterSecret,`exporter secret`),serverConfirmationKey:Sf(e.exporterSecret)}))}function Ef(e){return Tf(e.split())}function Df(e){typeof e==`object`&&e&&bf(e.epochSecretC2N,e.epochSecretN2C,e.exporterSecret,e.serverConfirmationKey)}var Of=1+io([new Uint8Array(4),new Uint8Array(8),new Uint8Array(4),new Uint8Array(8),new Uint8Array(32)],Oa).byteLength,kf=17,Af=Object.freeze([...Array.from({length:2},()=>Of),...Array.from({length:1},()=>kf)]),jf=({version:e,suite:t,key:n})=>{if(e!==1||!yl(t))throw TypeError(`Relay E2EE record AEAD selected for an unregistered version or suite.`);return _f(n,`AEAD key`),{seal:(e,t,r)=>of(n,e,r).encrypt(t),open:(e,t,r)=>of(n,e,r).decrypt(t)}},Mf=class e{#e;#t;#n;#r;#i;#a;#o;#s=!1;constructor(t,n,r){let i=vf(t);_f(n,`epoch secret`);let a=e.#c(r);this.#e=i,this.#r=a.epoch,this.#i=a.counter,this.#a=a.epochRecords,this.#o=a.epochBytes,this.#n=Cf(n,i),this.#t=n}static#c(e){let t=e?.epoch??0n,n=e?.counter??0n,r=e?.epochRecords??0,i=e?.epochBytes??0;if(typeof t!=`bigint`||t<0n||t>4294967295n)throw RangeError(`Synthetic relay E2EE epoch must be a bigint in the uint32 range.`);if(typeof n!=`bigint`||n<0n||n>18446744073709551615n)throw RangeError(`Synthetic relay E2EE counter must be a bigint in the uint64 range.`);if(!Number.isInteger(r)||r<0||r>=65536)throw RangeError(`Synthetic relay E2EE epoch record count must leave the epoch live.`);if(!Number.isInteger(i)||i<0||i>=268435456)throw RangeError(`Synthetic relay E2EE epoch byte count must leave the epoch live.`);return{epoch:t,counter:n,epochRecords:r,epochBytes:i}}get direction(){return this.#e}get exhausted(){return this.#s}get epoch(){return this.#r}get counter(){return this.#i}get state(){return{epoch:this.#s?void 0:this.#r,counter:this.#s?void 0:this.#i,epochRecords:this.#a,epochBytes:this.#o,exhausted:this.#s}}get aeadKey(){let e=this.#n;if(e===void 0)throw TypeError(`Relay E2EE directional AEAD key is unavailable.`);return e}static#l(e,t){return e>=65536||t>=268435456}capacityFor(t){if(this.#s)return!1;let n=this.#r,r=this.#a,i=this.#o;for(let a of t){if(e.#l(r,i)){if(n>=4294967295n)return!1;n+=1n,r=0,i=0}r+=1,i+=a}return!0}advance(t){if(this.#s)throw TypeError(`Relay E2EE direction is exhausted; no record may advance it.`);if(this.#a+=1,this.#o+=t,!e.#l(this.#a,this.#o))return this.#i>=18446744073709551615n?(this.#u(),{epochCompleted:!1}):(this.#i+=1n,{epochCompleted:!1});if(this.#r>=4294967295n)return this.#u(),{epochCompleted:!0};let n=this.#t,r=this.#n;if(n===void 0)throw TypeError(`Relay E2EE epoch secret is unavailable.`);let i=wf(n,this.#e),a=xf([i],()=>Cf(i,this.#e));return bf(n,r),this.#t=i,this.#n=a,this.#r+=1n,this.#i=0n,this.#a=0,this.#o=0,{epochCompleted:!0}}#u(){this.#s=!0,this.erase()}erase(){bf(this.#t,this.#n),this.#t=void 0,this.#n=void 0}};function Nf(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`sent`||t.kind===`failed`&&(t.delivery===`none`||t.delivery===`ambiguous`)}function Pf(e){let t,n;try{if(!yl(e.suite))throw TypeError(`Relay E2EE session suite must be a registered suite id.`);if(!(e.sessionBindingHash instanceof Uint8Array)||e.sessionBindingHash.byteLength!==32)throw TypeError(`Relay E2EE session requires a full-length session binding hash.`);if(!Number.isInteger(e.plaintextCeiling)||e.plaintextCeiling<=0)throw RangeError(`Relay E2EE session requires a positive plaintext ceiling.`);let r=vf(e.sendDirection),i=r===`c2n`?`n2c`:`c2n`,a=r===`c2n`?e.secrets.epochSecretC2N:e.secrets.epochSecretN2C,o=r===`c2n`?e.secrets.epochSecretN2C:e.secrets.epochSecretC2N;return t=new Mf(r,a,e.testOnlySyntheticSendState),n=new Mf(i,o,e.testOnlySyntheticReceiveState),{suite:e.suite,sessionBindingHash:Uint8Array.from(e.sessionBindingHash),plaintextCeiling:e.plaintextCeiling,aeadFactory:e.testOnlyAeadFactory??jf,secrets:e.secrets,send:t,receive:n}}catch(r){throw t?.erase(),n?.erase(),Df(e.secrets),r}}var Ff=class{#e=1;#t;#n;#r;#i;#a;#o;#s;#c=`open`;#l=!1;#u=!1;#d=Promise.resolve();constructor(e){let t=Pf(e);this.#t=t.suite,this.#n=t.sessionBindingHash,this.#r=t.plaintextCeiling,this.#i=t.aeadFactory,this.#a=t.secrets,this.#o=t.send,this.#s=t.receive}get suite(){return this.#t}get version(){return this.#e}get sendDirection(){return this.#o.direction}get receiveDirection(){return this.#s.direction}get sendState(){return this.#o.state}get receiveState(){return this.#s.state}get postApplicationReserveHeld(){return this.#o.capacityFor(Af)}get sendPathUsable(){return!this.#u&&this.#c!==`unusable`&&this.#c!==`spent`}#f(e,t,n){if(e!==this.#e||t!==this.#t)throw TypeError(`Relay E2EE AEAD selection requires the established version and suite.`);return this.#i({version:e,suite:t,key:n})}async protect(e){if(this.#y(),!xl(e.innerType))throw TypeError(`Relay E2EE inner record type must be a registered type.`);if(!(e.body instanceof Uint8Array))throw TypeError(`Relay E2EE inner record body must be a Uint8Array.`);if(typeof e.admit!=`function`||typeof e.transmit!=`function`)throw TypeError(`Relay E2EE sends require an admission and a transmit callback.`);let t=this.#d.then(()=>this.#p(e),()=>this.#p(e));return this.#d=t.then(()=>void 0,()=>void 0),t}async#p(e){if(this.#u)return{kind:`unavailable`,reason:`session_erased`};let t=this.#h(e.innerType);if(t!==void 0)return{kind:`unavailable`,reason:t};if(e.body.byteLength>this.#r)return{kind:`refused`,reason:`e2ee_message_too_large`};let n=1+e.body.byteLength;if(e.innerType===1){if(!this.#o.capacityFor([n,...Af]))return{kind:`close_required`}}else if(!this.#o.capacityFor([n]))return{kind:`exhausted`};let r=32+e.body.byteLength;if(!await e.admit(r))return{kind:`refused`,reason:`e2ee_send_unavailable`};if(this.#u)return{kind:`unavailable`,reason:`session_erased`};let i=this.#o.epoch,a=this.#o.counter,o=Vl({suite:this.#t,epoch:i,counter:a}),s=o[1],c=o[2];if(s!==this.#e||!yl(c)||c!==this.#t)throw TypeError(`Relay E2EE envelope header disagrees with the established session.`);let l=this.#f(s,c,this.#o.aeadKey);try{return await this.#m(e,{epoch:i,counter:a,plaintextBytes:n,aead:l,header:o})}catch{return this.#c=`unusable`,{kind:`send_failed`,epoch:i,counter:a,delivery:`ambiguous`,sendPathUsable:!1,mayEmitError:!1}}}async#m(e,t){let{epoch:n,counter:r,plaintextBytes:i,aead:a,header:o}=t,s=Gl(o),c=Kl({header:o,sessionBindingHash:this.#n,direction:this.#o.direction}),l=Jl(e.innerType,e.body),u;try{let e=a.seal(s,l,c);u=Hl({suite:this.#t,epoch:n,counter:r,ciphertext:e})}catch{u=void 0}finally{bf(l)}let{epochCompleted:d}=this.#o.advance(i);if(u===void 0)return this.#c=`unusable`,{kind:`send_failed`,epoch:n,counter:r,delivery:`none`,sendPathUsable:!1,mayEmitError:!1};this.#g(e.innerType);let f;try{let t=await e.transmit(u);f=Nf(t)?t:{kind:`failed`,delivery:`ambiguous`}}catch{f={kind:`failed`,delivery:`ambiguous`}}return f.kind===`sent`?{kind:`protected`,epoch:n,counter:r,plaintextBytes:i,envelopeBytes:u.byteLength,epochCompleted:d}:f.delivery===`none`?(this.#c=`unusable`,{kind:`send_failed`,epoch:n,counter:r,delivery:`none`,sendPathUsable:!1,mayEmitError:!1}):{kind:`send_failed`,epoch:n,counter:r,delivery:`ambiguous`,sendPathUsable:this.sendPathUsable,mayEmitError:this.sendPathUsable}}#h(e){switch(this.#c){case`unusable`:return`send_path_unusable`;case`spent`:return`terminal_record_protected`;case`closing`:return e===1?`application_phase_closed`:void 0;case`open`:return}}#g(e){if(e===3){this.#c=`spent`;return}(e===2||e===4)&&this.#c===`open`&&(this.#c=`closing`)}unprotect(e){if(this.#y(),!(e instanceof Uint8Array))throw TypeError(`Relay E2EE payloads must be a Uint8Array.`);if(this.#l)return this.#v(`receive_terminated`);try{return this.#_(e)}catch(e){throw this.#l=!0,e}}#_(e){let t=Ul(e);if(t.kind===`error`)switch(t.reason){case`unsupported_version`:return this.#v(`version_mismatch`);case`unsupported_suite`:return this.#v(`suite_mismatch`);default:return this.#v(`malformed_envelope`)}let n=t.value;if(n.version!==this.#e)return this.#v(`version_mismatch`);if(n.suite!==this.#t)return this.#v(`suite_mismatch`);if(this.#s.exhausted||n.epoch!==this.#s.epoch||n.counter!==this.#s.counter)return this.#v(`sequence_mismatch`);let r=this.#f(n.version,n.suite,this.#s.aeadKey),i=Gl(n.header),a=Kl({header:n.header,sessionBindingHash:this.#n,direction:this.#s.direction}),o;try{o=r.open(i,n.ciphertext,a)}catch{return this.#v(`authentication_failed`)}let s;try{s=Yl(o)}catch(e){throw bf(o),e}if(s.kind===`error`)return bf(o),this.#v(s.reason===`truncated`?`malformed_record`:`reserved_inner_type`);let c=n.epoch,l=n.counter,{epochCompleted:u}=xf([o],()=>this.#s.advance(o.byteLength));return{kind:`authenticated`,innerType:s.value.innerType,body:s.value.body,epoch:c,counter:l,plaintextBytes:o.byteLength,epochCompleted:u}}#v(e){return this.#l=!0,{kind:`fatal`,reason:e}}erase(){this.#u||(this.#u=!0,this.#o.erase(),this.#s.erase(),Df(this.#a))}get erased(){return this.#u}#y(){if(this.#u)throw TypeError(`Relay E2EE session has been erased; it is never resumed.`)}},If=`Noise_IK_25519_ChaChaPoly_SHA256`,Lf=`Noise_NX_25519_ChaChaPoly_SHA256`,Rf=`ryco.relay-e2ee.exporter.v1`;function zf(e){return e===`IK`?If:Lf}var Bf=L.outputLen,Vf=32,Hf=32,Uf=16,Wf=65535,Gf=18446744073709551615n,Kf=dr(Rf),qf=new Uint8Array,Jf=class extends Error{code=`relay_e2ee_noise_handshake_failed`;reason;constructor(e){super(`Relay E2EE Noise handshake failed.`),this.name=`E2eeNoiseHandshakeError`,this.reason=e}};function Yf(e){throw new Jf(e)}function Xf(e,t){(!(e instanceof Uint8Array)||e.byteLength!==t)&&Yf(`invalid_key_material`)}function Zf(e,t){return Xf(e,t),Uint8Array.from(e)}function Qf(...e){for(let t of e)if(t instanceof Uint8Array)try{rr(t)}catch{}}function $f(e,t){let n=sf(L,t,e),r,i;try{r=uf(L,n,void 0,2*Bf),i=r.slice(0,Bf);let e=r.slice(Bf);return[i,e]}catch(e){throw Qf(i),e}finally{Qf(n,r)}}function ep(e){(typeof e!=`bigint`||e<0n)&&Yf(`invalid_options`),e>=Gf&&Yf(`nonce_exhausted`);let t=new Uint8Array(12),n=e;for(let e=4;e<12;e+=1)t[e]=Number(n&255n),n>>=8n;return t}function tp(e){return(!(e instanceof Uint8Array)||e.byteLength!==Bf)&&Yf(`invalid_key_material`),uf(L,e,Kf,32)}var np=class{#e=void 0;#t=0n;initializeKey(e){e.byteLength!==Hf&&Yf(`invalid_key_material`),Qf(this.#e),this.#e=e,this.#t=0n}get hasKey(){return this.#e!==void 0}encryptWithAd(e,t){let n=this.#e;if(n===void 0)return t;let r=ep(this.#t),i=of(n,r,e).encrypt(t);return rr(r),this.#t+=1n,i}decryptWithAd(e,t){let n=this.#e;if(n===void 0)return t;let r=ep(this.#t),i=of(n,r,e).decrypt(t);return rr(r),this.#t+=1n,i}erase(){Qf(this.#e),this.#e=void 0,this.#t=0n}},rp=class{#e;#t;#n=new np;constructor(e){let t=dr(e),n=new Uint8Array(Bf);t.byteLength<=Bf?n.set(t):n.set(L(t)),this.#t=n,this.#e=Uint8Array.from(n)}get hasKey(){return this.#n.hasKey}get handshakeHash(){return Uint8Array.from(this.#t)}mixKey(e){let[t,n]=$f(this.#e,e);try{Qf(this.#e),this.#e=t,this.#n.initializeKey(n)}catch(e){throw Qf(n),e}}mixHash(e){let t=L(fr(this.#t,e));Qf(this.#t),this.#t=t}encryptAndHash(e){let t=this.#n.encryptWithAd(this.#t,e);return this.mixHash(t),t}decryptAndHash(e){let t=this.#n.decryptWithAd(this.#t,e);return this.mixHash(e),t}splitAndExport(){let[e,t]=$f(this.#e,qf),n;try{return n=tp(this.#e),this.erase(),{epochSecretC2N:e,epochSecretN2C:t,exporterSecret:n}}catch(r){throw Qf(e,t,n),r}}erase(){Qf(this.#e,this.#t),this.#n.erase()}},ip={IK:[[`e`,`es`,`s`,`ss`],[`e`,`ee`,`se`]],NX:[[`e`],[`e`,`ee`,`s`,`es`]]},ap=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=0;#u;constructor(e){let t=e.pattern;t!==`IK`&&t!==`NX`&&Yf(`invalid_options`);let n=e.role;n!==`initiator`&&n!==`responder`&&Yf(`invalid_options`),e.prologue instanceof Uint8Array||Yf(`invalid_options`);let r=t===`IK`||n===`responder`,i=t===`IK`&&n===`initiator`;r!==(e.staticSecretKey!==void 0)&&Yf(`invalid_options`),i!==(e.remoteStaticPublicKey!==void 0)&&Yf(`invalid_options`);let a=e.staticSecretKey;a!==void 0&&Xf(a,Vf);let o=e.testOnlyEphemeralSecretKey;o!==void 0&&Xf(o,Vf);let s=e.remoteStaticPublicKey===void 0?void 0:Zf(e.remoteStaticPublicKey,Vf);this.#e=n,this.#t=ip[t],this.#a=s;let c=new rp(zf(t));c.mixHash(e.prologue);let l=a===void 0?void 0:jc.getPublicKey(a);t===`IK`&&c.mixHash(n===`initiator`?s:l),this.#n=c,a!==void 0&&(this.#r={secretKey:Uint8Array.from(a),publicKey:l}),this.#c=o,this.#u=n===`initiator`?`awaiting_write`:`awaiting_read`}get status(){return this.#u}get remoteStaticPublicKey(){return this.#a===void 0?void 0:Uint8Array.from(this.#a)}get remoteEphemeralPublicKey(){return this.#o===void 0?void 0:Uint8Array.from(this.#o)}get localEphemeralPublicKey(){return this.#s===void 0?void 0:Uint8Array.from(this.#s)}get testOnlyHandshakeHash(){let e=this.#n.handshakeHash;if(!e.every(e=>e===0))return e}writeMessage(e){this.#d(`awaiting_write`),e instanceof Uint8Array||Yf(`invalid_options`);try{let t=[];for(let e of this.#t[this.#l])switch(e){case`e`:{let e=this.#p();this.#i=e,this.#e===`initiator`&&(this.#s=Uint8Array.from(e.publicKey)),t.push(e.publicKey),this.#n.mixHash(e.publicKey);break}case`s`:this.#r===void 0&&Yf(`out_of_sequence`),t.push(this.#n.encryptAndHash(this.#r.publicKey));break;default:this.#m(e)}t.push(this.#n.encryptAndHash(e));let n=fr(...t);return n.byteLength>Wf&&Yf(`message_too_large`),this.#f(),n}catch(e){throw this.destroy(),e}}readMessage(e){this.#d(`awaiting_read`),e instanceof Uint8Array||Yf(`invalid_options`);try{e.byteLength>Wf&&Yf(`message_too_large`);let t=0,n=n=>{t+n>e.byteLength&&Yf(`malformed_message`);let r=e.subarray(t,t+n);return t+=n,r};for(let e of this.#t[this.#l])switch(e){case`e`:{let e=Uint8Array.from(n(Vf));this.#o=e,this.#n.mixHash(e);break}case`s`:{let e=n(this.#n.hasKey?Vf+Uf:Vf),t=this.#n.decryptAndHash(e);t.byteLength!==Vf&&Yf(`malformed_message`),this.#a=t;break}default:this.#m(e)}let r=this.#n.decryptAndHash(e.subarray(t));return this.#f(),r}catch(e){throw this.destroy(),e}}split(){this.#d(`awaiting_split`);let e;try{return e=this.#n.splitAndExport(),this.#h(),this.#u=`complete`,e}catch(t){throw e!==void 0&&Qf(e.epochSecretC2N,e.epochSecretN2C,e.exporterSecret),this.destroy(),t}}destroy(){this.#u!==`complete`&&this.#u!==`destroyed`&&(this.#n.erase(),this.#h(),this.#u=`destroyed`)}#d(e){(this.#u===`complete`||this.#u===`destroyed`)&&Yf(`handshake_consumed`),this.#u!==e&&Yf(`out_of_sequence`)}#f(){if(this.#l+=1,this.#l>=this.#t.length){this.#u=`awaiting_split`;return}this.#u=this.#u===`awaiting_write`?`awaiting_read`:`awaiting_write`}#p(){let e=this.#c;if(e!==void 0){let t=jc.getPublicKey(e);return this.#c=void 0,{secretKey:e,publicKey:t}}let t=jc.keygen();return{secretKey:t.secretKey,publicKey:t.publicKey}}#m(e){let t=this.#e===`initiator`,n,r;switch(e){case`ee`:n=this.#i,r=this.#o;break;case`es`:n=t?this.#i:this.#r,r=t?this.#a:this.#o;break;case`se`:n=t?this.#r:this.#i,r=t?this.#o:this.#a;break;case`ss`:n=this.#r,r=this.#a}(n===void 0||r===void 0)&&Yf(`out_of_sequence`);let i=jc.getSharedSecret(n.secretKey,r);try{this.#n.mixKey(i)}finally{Qf(i)}}#h(){Qf(this.#i?.secretKey,this.#r?.secretKey,this.#c),this.#i=void 0,this.#r=void 0,this.#c=void 0}},op=mt(Ht);mt(re);function sp(e){return{version:e[1],suiteId:e[2],issuerHubOrigin:e[3],keyId:e[4],grantId:e[5],accountId:e[6],accountAuthEpoch:e[7],enrollmentId:e[8],enrollmentRevision:e[9],deviceAuthEpoch:e[10],deviceIdentityAlgorithm:e[11],deviceIdentityPublicKey:e[12],deviceIdentityFingerprint:e[13],deviceAgreementAlgorithm:e[14],deviceAgreementPublicKey:e[15],deviceAgreementFingerprint:e[16],clientPrekeyCertificateDigest:e[17],nodeId:e[18],nodeIdentityAlgorithm:e[19],nodeIdentityPublicKey:e[20],nodeIdentityFingerprint:e[21],nodeAgreementAlgorithm:e[22],nodeAgreementPublicKey:e[23],nodeAgreementFingerprint:e[24],nodeContinuityId:e[25],nodePolicyGeneration:e[26],nodeCapabilityStatementDigest:e[27],relayTicketId:e[28],maximumRole:e[29],capabilities:e[30],issuedAt:e[31],notBefore:e[32],expiresAt:e[33],nonce:e[34]}}function cp(e){try{return dl(e.deviceIdentityPublicKey),fl(e.deviceAgreementPublicKey),ul(e.nodeIdentityPublicKey),fl(e.nodeAgreementPublicKey),_l(e.deviceIdentityFingerprint,gl(`client-identity`,e.deviceIdentityPublicKey))&&_l(e.deviceAgreementFingerprint,gl(`agreement`,e.deviceAgreementPublicKey))&&_l(e.nodeIdentityFingerprint,gl(`node-identity`,e.nodeIdentityPublicKey))&&_l(e.nodeAgreementFingerprint,gl(`agreement`,e.nodeAgreementPublicKey))}catch{return!1}}function lp(e){return e===`non_canonical`?`grant_non_canonical`:`grant_malformed`}function up(e){if(!(e instanceof Uint8Array))return{kind:`error`,reason:`grant_malformed`};if(e.byteLength>hn)return{kind:`error`,reason:`grant_oversize`};let t=yu(e);if(t.kind===`error`)return{kind:`error`,reason:lp(t.reason)};if(!Array.isArray(t.value)||t.value.length!==2||!(t.value[0]instanceof Uint8Array)||!(t.value[1]instanceof Uint8Array)||t.value[1].byteLength!==64)return{kind:`error`,reason:`grant_malformed`};let n=t.value[0],r=t.value[1],i=yu(n);if(i.kind===`error`)return{kind:`error`,reason:lp(i.reason)};if(!Array.isArray(i.value)||i.value.length!==35)return{kind:`error`,reason:`grant_malformed`};if(i.value[0]!==`ryco.hub-device-grant-claims.v1`||i.value[1]!==1||i.value[2]!==2)return{kind:`error`,reason:`grant_version`};let a=op(sp(i.value));if(Lt(a))return{kind:`error`,reason:`grant_malformed`};try{if(Fu(a.value.issuerHubOrigin)!==a.value.issuerHubOrigin)return{kind:`error`,reason:`grant_malformed`}}catch{return{kind:`error`,reason:`grant_malformed`}}return cp(a.value)?{kind:`ok`,claims:a.value,envelope:Uint8Array.from(e),claimsBytes:Uint8Array.from(n),signature:Uint8Array.from(r),grantDigest:L(e)}:{kind:`error`,reason:`grant_binding`}}var dp=`ryco.relay-e2ee.confirmation.v1`,fp=`ryco.relay-e2ee.session.v1`;function pp(e,t){return!(e instanceof Uint8Array)||!(t instanceof Uint8Array)?!1:Pd(e,t)}function mp(e){return Uint8Array.from(io(e,Oa))}function hp(e){return typeof e==`string`}function gp(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function _p(e,t){return e instanceof Uint8Array?t===void 0||e.byteLength===t:!1}function vp(e){return Uint8Array.from(e)}var yp={viewer:0,operator:1,owner:2};function bp(e){let t=yp[Ru(e)];return t===void 0&&K(),t}function xp(e,t){return bp(e)<=bp(t)}function Sp(e){return e.trustSource??(e.tier===`native`?`locally-verified`:`web-unsigned`)}function Cp(e,t,n){return e===2?t===`native`&&n===`account-enrolled`:t===`web`?n===`web-unsigned`:n===`locally-verified`}function wp(e){if((!Array.isArray(e.advertisedSuiteRegistry)||e.advertisedSuiteRegistry.length===0||e.advertisedSuiteRegistry.length>8||!Array.isArray(e.localSuitePreference)||e.localSuitePreference.length===0)&&K(),!Number.isSafeInteger(e.advertisedVersionMin)||!Number.isSafeInteger(e.advertisedVersionMax)||e.advertisedVersionMin>e.advertisedVersionMax||e.advertisedVersionMin>1||1>e.advertisedVersionMax)return{kind:`unusable`,reason:`protocol_version_out_of_range`};let t=hu(e.tier);if(!e.advertisedAdmittedPatterns.includes(t))return{kind:`unusable`,reason:`pattern_not_admitted`};let n=Sp(e),r=e.localSuitePreference.find(t=>yl(t)&&Cp(t,e.tier,n)&&e.advertisedSuiteRegistry.includes(t));return r===void 0||!yl(r)?{kind:`unusable`,reason:`empty_suite_intersection`}:{kind:`usable`,selectedSuite:r}}function Tp(e){return yl(e)||K(),{dh:pu,hash:mu}}var Ep=5,Dp=3;function Op(e){return e===`native`||e===`web`}function kp(e){return Op(e.tier)||K(),yl(e.selectedSuite)||K(),(!Array.isArray(e.offeredSuites)||e.offeredSuites.length===0||e.offeredSuites.length>8||!e.offeredSuites.every(gp)||!e.offeredSuites.includes(e.selectedSuite))&&K(),_p(e.clientNonce,32)||K(),_p(e.contextCommitment,32)||K(),(!_p(e.noiseMessage1)||e.noiseMessage1.byteLength===0)&&K(),$l(1,mp([1,e.tier,e.selectedSuite,[...e.offeredSuites],vp(e.clientNonce),vp(e.contextCommitment),vp(e.noiseMessage1)]))}function Ap(e){(!_p(e.clientPrekeyTranscript)||e.clientPrekeyTranscript.length===0)&&K();let t=hl(e.clientPrekeySignature);return mp([vp(e.clientPrekeyTranscript),t,Iu(e.accountId),Lu(e.intendedCapability),Ru(e.intendedRole)])}function jp(e){(!_p(e.hubDeviceGrant)||e.hubDeviceGrant.byteLength===0||e.hubDeviceGrant.byteLength>hn)&&K();let t=yu(Ap(e));return(t.kind!==`ok`||!Array.isArray(t.value))&&K(),mp([...t.value,vp(e.hubDeviceGrant)])}var Mp=new Uint8Array;function Np(e){yl(e.acceptedSuite)||K(),(!hp(e.nodePrekeyId)||e.nodePrekeyId.length===0)&&K(),_p(e.contextCommitment,32)||K(),(!_p(e.noiseMessage2)||e.noiseMessage2.byteLength===0)&&K()}function Pp(e){return Np(e),$l(2,mp([e.acceptedSuite,e.nodePrekeyId,vp(e.contextCommitment),vp(e.noiseMessage2)]))}function Fp(e){let t=eu(e);if(t.kind===`error`||t.value.recordType!==2)return{kind:`error`,reason:`bad_record`};let n=yu(t.value.body);if(n.kind===`error`)return{kind:`error`,reason:`malformed_body`};let r=n.value;if(!Array.isArray(r)||r.length!==Ep)return{kind:`error`,reason:`malformed_body`};let[i,a,o,s,c]=r;return!gp(i)||!hp(a)||a.length===0||!_p(o,32)||!_p(s)||s.byteLength===0||!_p(c,32)?{kind:`error`,reason:`malformed_body`}:{kind:`ok`,value:{acceptedSuite:i,nodePrekeyId:a,contextCommitment:o,noiseMessage2:s,serverConfirmation:c}}}function Ip(e){let t=yu(e);if(t.kind===`error`)return{kind:`error`,reason:`malformed_body`};let n=t.value;if(!Array.isArray(n)||n.length!==Dp)return{kind:`error`,reason:`malformed_body`};let[r,i,a]=n;return!hp(r)||!hp(i)||!_p(a,32)?{kind:`error`,reason:`malformed_body`}:{kind:`ok`,value:{channelOpenCapability:r,channelOpenEffectiveRole:i,nodeAgreementKeyFingerprint:a}}}function Lp(e){let t=yu(e);return(t.kind===`error`||!Array.isArray(t.value))&&K(),t.value}function Rp(e){return(!_p(e.clientHelloWireBytes)||e.clientHelloWireBytes.byteLength===0||!_p(e.serverAcceptTbsWireBytes)||e.serverAcceptTbsWireBytes.byteLength===0)&&K(),L(mp([dp,vp(e.clientHelloWireBytes),vp(e.serverAcceptTbsWireBytes),Lp(e.contextBlock)]))}function zp(e,t){return(!_p(e)||!_p(t,32))&&K(),Nc(L,e,t)}function Bp(e){(!_p(e.clientHelloWireBytes)||e.clientHelloWireBytes.byteLength===0||!_p(e.serverAcceptWireBytes)||e.serverAcceptWireBytes.byteLength===0)&&K();let t=L(mp([fp,vp(e.clientHelloWireBytes),vp(e.serverAcceptWireBytes),Lp(e.contextBlock)]));return t.byteLength!==32&&K(),t}var Vp=11;function Hp(e){let t=yu(e.transcript);if(t.kind===`error`)return{kind:`error`,failure:`malformed`};let n=t.value;if(!Array.isArray(n)||n.length!==Vp)return{kind:`error`,failure:`malformed`};let[,r,i,a,o,s,c,l,u,d,f]=n;if(!hp(r)||!hp(i)||a!==`p256`||!_p(o,65)||!_p(s,32)||!_p(c,32)||!hp(l)||!hp(u)||!gp(d)||!gp(f))return{kind:`error`,failure:`malformed`};let p,m;try{dl(o),fl(c),hl(e.signature),p=Wu({hubOrigin:r,accountId:i,identityPublicKey:o,agreementPublicKey:c,createdAt:d,expiresAt:f}),m=gl(`agreement`,c)}catch{return{kind:`error`,failure:`malformed`}}if(!pp(p,e.transcript))return{kind:`error`,failure:`malformed`};if(r!==e.hubOrigin)return{kind:`error`,failure:`hub_origin_mismatch`};let h=Tp(e.suite);return l!==h.dh||u!==h.hash?{kind:`error`,failure:`usage_mismatch`}:vl({algorithm:`p256`,publicKey:o,message:e.transcript,signature:e.signature})?f<=d||f-d>2592e6||e.now+3e5<d||e.now-3e5>f?{kind:`error`,failure:`expired`}:{kind:`ok`,certificate:{hubOrigin:r,accountId:i,identityPublicKey:o,identityFingerprint:s,agreementPublicKey:c,agreementFingerprint:m,createdAt:d,expiresAt:f}}:{kind:`error`,failure:`invalid_signature`}}function Up(e,t){return{kind:`fatal`,row:e,reason:t}}function Wp(e){return e.tier===`native`&&e.trustSource===`account-enrolled`}function Gp(e,t){return e===`web`?`web-unsigned`:t===2?`account-enrolled`:`locally-verified`}function Kp(e){let t=fd({hubOrigin:e.channel.hubOrigin,channelId:e.channel.channelId,relayProtocolMajor:e.channel.relayProtocolMajor,relayProtocolMinor:e.channel.relayProtocolMinor,e2eeVersion:1,suiteId:e.suite,nodeId:e.advertised.nodeId,nodeIdentityFingerprint:e.advertised.nodeIdentityFingerprint,clientIntendedCapability:e.intendedCapability,clientIntendedRole:e.intendedRole,channelOpenCapability:e.channel.channelOpenCapability,channelOpenEffectiveRole:e.channel.channelOpenEffectiveRole,nodeAgreementFingerprint:gl(`agreement`,e.advertised.agreementPublicKey),nodeContinuityChainTranscripts:e.advertised.continuityChainTranscripts,nodeContinuityId:e.advertised.continuityId,client:e.client});return{block:t,commitment:hd(t)}}function qp(e){let{channel:t,advertised:n,grant:r,certificate:i}=e,a=r.claims,o=t.accountGrantContext,s=n.capabilityStatementDigest,c=n.policyGeneration;return t.relayProtocolMajor===1&&t.relayProtocolMinor>=3&&o!==void 0&&s instanceof Uint8Array&&Number.isSafeInteger(c)&&c!==void 0&&a.suiteId===2&&a.issuerHubOrigin===t.hubOrigin&&a.accountId===i.accountId&&a.nodeId===n.nodeId&&a.nodeContinuityId===n.continuityId&&a.nodePolicyGeneration===c&&a.relayTicketId===o.relayTicketId&&a.capabilities.some(t=>t===e.intendedCapability)&&xp(e.intendedRole,a.maximumRole)&&pp(r.grantDigest,L(r.envelope))&&pp(r.grantDigest,o.deviceGrantDigest)&&pp(a.nodeCapabilityStatementDigest,o.nodeCapabilityStatementDigest)&&pp(a.nodeCapabilityStatementDigest,s)&&pp(a.clientPrekeyCertificateDigest,e.certificateDigest)&&pp(a.deviceIdentityPublicKey,i.identityPublicKey)&&pp(a.deviceIdentityFingerprint,i.identityFingerprint)&&pp(a.deviceAgreementPublicKey,i.agreementPublicKey)&&pp(a.deviceAgreementFingerprint,i.agreementFingerprint)&&pp(a.nodeIdentityFingerprint,n.nodeIdentityFingerprint)&&pp(a.nodeAgreementPublicKey,n.agreementPublicKey)&&pp(a.nodeAgreementFingerprint,gl(`agreement`,n.agreementPublicKey))}function Jp(e){qp(e)||K();let t=pd({hubOrigin:e.channel.hubOrigin,channelId:e.channel.channelId,relayProtocolMajor:e.channel.relayProtocolMajor,relayProtocolMinor:e.channel.relayProtocolMinor,e2eeVersion:1,suiteId:2,nodeId:e.advertised.nodeId,nodeIdentityFingerprint:e.advertised.nodeIdentityFingerprint,clientIntendedCapability:e.intendedCapability,clientIntendedRole:e.intendedRole,channelOpenCapability:e.channel.channelOpenCapability,channelOpenEffectiveRole:e.channel.channelOpenEffectiveRole,nodeAgreementFingerprint:gl(`agreement`,e.advertised.agreementPublicKey),nodeContinuityChainTranscripts:e.advertised.continuityChainTranscripts,nodeContinuityId:e.advertised.continuityId,client:{tier:`native`,accountId:e.certificate.accountId,identityFingerprint:e.certificate.identityFingerprint,agreementFingerprint:e.certificate.agreementFingerprint},grant:e.grant.claims,deviceGrantDigest:e.grant.grantDigest});return{block:t,commitment:hd(t)}}function Yp(e,t,n){return t===e.channelOpenCapability&&n===e.channelOpenEffectiveRole}function Xp(e){return e+bn}var Zp=class{#e;#t;#n=`created`;#r;#i;#a;#o;#s;constructor(e){if(!yl(e.selectedSuite))throw TypeError(`Relay E2EE client handshake requires a registered suite selection.`);let t=e.selectedSuite===2;if(t!==Wp(e.credentials)||t&&(e.credentials.tier!==`native`||e.channel.relayProtocolMajor!==1||e.channel.relayProtocolMinor<3||e.channel.accountGrantContext===void 0)||!t&&e.channel.accountGrantContext!==void 0)throw TypeError(`Relay E2EE suite, trust source, and channel context do not agree.`);this.#e=e,this.#t=e.credentials.tier}get tier(){return this.#t}get state(){return this.#n}get deadlineAt(){return this.#s}deadlineExpired(e){return this.#s!==void 0&&e>this.#s}createHello(e){if(this.#n!==`created`)return this.#u(Up(`P4`,`handshake_spent`));let t;try{return this.#c(e,e=>{t=e})}catch(e){throw t?.destroy(),this.destroy(),e}}#c(e,t){let n=this.#e,r=n.credentials;if(!Yp(n.channel,n.intendedCapability,n.intendedRole))return this.#u(Up(`P13`,`context_mismatch`));let i;if(Wp(r)){let t=md(r.prekeyTranscript,r.prekeySignature),a=Hp({transcript:r.prekeyTranscript,signature:r.prekeySignature,hubOrigin:n.channel.hubOrigin,suite:n.selectedSuite,now:e}),o=up(r.deviceGrant.envelope);if(a.kind===`error`||o.kind===`error`||!pp(o.claimsBytes,r.deviceGrant.claimsBytes)||!pp(o.signature,r.deviceGrant.signature)||!pp(o.grantDigest,r.deviceGrant.grantDigest)||a.certificate.accountId!==r.accountId||!pp(a.certificate.identityPublicKey,r.identityPublicKey)||!pp(a.certificate.agreementPublicKey,r.agreementPublicKey))throw TypeError(`Relay E2EE account grant does not match the client certificate.`);i={certificate:a.certificate,digest:L(t),grant:o}}let a=Wp(r)&&i!==void 0?Jp({channel:n.channel,advertised:n.advertised,grant:i.grant,certificate:i.certificate,certificateDigest:i.digest,intendedCapability:n.intendedCapability,intendedRole:n.intendedRole}):r.tier===`native`?Kp({channel:n.channel,advertised:n.advertised,suite:n.selectedSuite,intendedCapability:n.intendedCapability,intendedRole:n.intendedRole,client:{tier:`native`,accountId:r.accountId,identityFingerprint:gl(`client-identity`,r.identityPublicKey),agreementFingerprint:gl(`agreement`,r.agreementPublicKey)}}):Kp({channel:n.channel,advertised:n.advertised,suite:n.selectedSuite,intendedCapability:n.intendedCapability,intendedRole:n.intendedRole,client:{tier:`web`}}),o=gd({hubOrigin:n.channel.hubOrigin,channelId:n.channel.channelId,relayProtocolMajor:n.channel.relayProtocolMajor,relayProtocolMinor:n.channel.relayProtocolMinor,e2eeVersion:1,suiteId:n.selectedSuite,nodeId:n.advertised.nodeId,contextCommitment:a.commitment}),s;if(r.tier===`native`){if(!pp(jc.getPublicKey(r.agreementSecretKey),r.agreementPublicKey))throw TypeError(`Relay E2EE client agreement secret key does not match its certificate key.`);let e={clientPrekeyTranscript:r.prekeyTranscript,clientPrekeySignature:r.prekeySignature,accountId:r.accountId,intendedCapability:n.intendedCapability,intendedRole:n.intendedRole};s=Wp(r)?jp({...e,hubDeviceGrant:i.grant.envelope}):Ap(e)}else s=Mp;let c=new ap({pattern:hu(this.#t),role:`initiator`,prologue:o,staticSecretKey:r.tier===`native`?r.agreementSecretKey:void 0,remoteStaticPublicKey:r.tier===`native`?n.advertised.agreementPublicKey:void 0,testOnlyEphemeralSecretKey:n.testOnlyEphemeralSecretKey});t(c);let l;try{l=c.writeMessage(s)}catch{return c.destroy(),this.#u(Up(`P10`,`noise`))}let u=kp({tier:this.#t,selectedSuite:n.selectedSuite,offeredSuites:n.offeredSuites,clientNonce:n.testOnlyClientNonce??hr(32),contextCommitment:a.commitment,noiseMessage1:l});return this.#r=c,this.#i=u,this.#a=a.block,this.#o=a.commitment,this.#s=Xp(e),this.#n=`hello_sent`,{kind:`hello`,record:u,contextBlock:a.block,contextCommitment:a.commitment,prologue:o,deadlineAt:this.#s}}receiveServerAccept(e,t){if(this.#n!==`hello_sent`)return this.#u(Up(`P16`,`handshake_spent`));let n=this.#r,r=this.#i,i=this.#a,a=this.#o;if(n===void 0||r===void 0||i===void 0||a===void 0)return this.#u(Up(`P16`,`handshake_spent`));if(this.deadlineExpired(t))return this.#u(Up(`P20`,`handshake_deadline`));let o;try{return this.#l({payload:e,noise:n,helloRecord:r,contextBlock:i,contextCommitment:a,holdSecrets:e=>{o=e}})}catch(e){throw o!==void 0&&Df(o),this.destroy(),e}}#l(e){let{payload:t,noise:n,helloRecord:r,contextBlock:i,contextCommitment:a}=e,o=Fp(t);if(o.kind===`error`)return this.#u(o.reason===`bad_record`?Up(`P3`,`record_bounds`):Up(`P16`,`accept_mismatch`));let s=o.value;if(s.acceptedSuite!==this.#e.selectedSuite||s.nodePrekeyId!==this.#e.advertised.prekeyId)return this.#u(Up(`P16`,`accept_mismatch`));if(!pp(s.contextCommitment,a))return this.#u(Up(`P13`,`context_mismatch`));let c;try{c=n.readMessage(s.noiseMessage2)}catch{return this.#u(Up(`P10`,`noise`))}let l=n.remoteStaticPublicKey;if(l===void 0||!pp(l,this.#e.advertised.agreementPublicKey))return this.#u(Up(`P16`,`accept_mismatch`));let u=Ip(c);if(u.kind===`error`)return this.#u(Up(`P16`,`accept_mismatch`));let d=u.value;if(d.channelOpenCapability!==this.#e.channel.channelOpenCapability||d.channelOpenEffectiveRole!==this.#e.channel.channelOpenEffectiveRole||!pp(d.nodeAgreementKeyFingerprint,gl(`agreement`,this.#e.advertised.agreementPublicKey)))return this.#u(Up(`P13`,`context_mismatch`));let f;try{f=Ef(n)}catch{return this.#u(Up(`P10`,`noise`))}e.holdSecrets(f);let p=Pp({acceptedSuite:this.#e.selectedSuite,nodePrekeyId:s.nodePrekeyId,contextCommitment:s.contextCommitment,noiseMessage2:s.noiseMessage2}),m=Rp({clientHelloWireBytes:r,serverAcceptTbsWireBytes:p,contextBlock:i});if(!pp(zp(f.serverConfirmationKey,m),s.serverConfirmation))return Df(f),this.#u(Up(`P16`,`confirmation_mismatch`));let h=Bp({clientHelloWireBytes:r,serverAcceptWireBytes:t,contextBlock:i}),g;if(this.#e.credentials.tier===`web`&&(g=n.localEphemeralPublicKey,g===void 0))throw TypeError(`Relay E2EE client handshake has no local ephemeral.`);return this.#n=`established`,this.#r=void 0,{kind:`established`,sessionBindingHash:h,secrets:f,suite:this.#e.selectedSuite,trustSource:Gp(this.#t,this.#e.selectedSuite),contextBlock:i,serverAcceptTbs:p,confirmationTranscript:m,...g===void 0?{}:{webEphemeralPublicKey:g}}}destroy(){this.#r?.destroy(),this.#r=void 0,this.#n!==`established`&&(this.#n=`failed`)}#u(e){return this.destroy(),e}};function Qp(e){return{kind:`invalid`,reason:e}}var $p=new TextEncoder;function em(e){let t;try{t=Fu(e.connectedHubOrigin)}catch{return Qp(`connected_hub_origin_invalid`)}if(e.accountId!==void 0){let t=$p.encode(e.accountId).byteLength;if(t===0||t>256)return Qp(`account_scope_invalid`)}let n=ld(e.statement);if(n.kind===`error`)return Qp(n.failure);let r=n.value,i;try{i=ud(r.transcript)}catch{return Qp(`identity_signature_invalid`)}if(!vl({algorithm:`ed25519`,publicKey:r.identityPublicKey,message:i,signature:r.signature}))return Qp(`identity_signature_invalid`);if(!_l(gl(`node-identity`,r.identityPublicKey),r.identityFingerprint))return Qp(`identity_fingerprint_mismatch`);if(!_l(gl(`agreement`,r.prekeyCertificate.agreementPublicKey),r.prekeyCertificate.agreementFingerprint))return Qp(`agreement_fingerprint_mismatch`);if(r.expiresAt<r.issuedAt)return Qp(`validity_interval_inverted`);if(r.expiresAt-r.issuedAt>6e5)return Qp(`validity_interval_too_long`);if(r.issuedAt>e.now+3e5)return Qp(`issued_at_in_future`);if(r.expiresAt<e.now-3e5)return Qp(`statement_expired`);if(r.hubOrigin!==t)return Qp(`hub_origin_mismatch`);let a=r.prekeyCertificate;if(a.expiresAt<=a.createdAt)return Qp(`prekey_lifetime_inverted`);if(a.expiresAt-a.createdAt>2592e6)return Qp(`prekey_lifetime_too_long`);if(e.now+3e5<a.createdAt)return Qp(`prekey_not_yet_valid`);if(a.expiresAt<e.now-3e5)return Qp(`prekey_expired`);if(!_d({hubOrigin:r.hubOrigin,nodeId:r.nodeId,identityKeyId:r.identityKeyId,identityPublicKey:r.identityPublicKey,identityFingerprint:r.identityFingerprint,prekeyCertificate:a}))return Qp(`prekey_cross_signature_invalid`);if(e.pin!==void 0&&r.continuityId!==e.pin.continuityId)return{kind:`identity-event`,event:{reason:`pinned_continuity_id`},statement:r};let o=Zu({chain:r.continuityChain,hubOrigin:r.hubOrigin,continuityId:r.continuityId,identityPublicKey:r.identityPublicKey,...e.pin===void 0?{}:{pinnedIdentityFingerprint:e.pin.identityFingerprint}});if(o.kind===`error`)return e.pin===void 0||o.failure===`malformed_entry`?{kind:`invalid`,reason:`continuity_chain_invalid`,chainFailure:o.failure}:{kind:`identity-event`,event:{reason:`continuity_chain`,failure:o.failure},statement:r};if(e.acceptedPolicyGeneration!==void 0&&r.policyGeneration<e.acceptedPolicyGeneration)return Qp(`policy_generation_regressed`);let s=wp({tier:e.tier,...e.trustSource===void 0?{}:{trustSource:e.trustSource},localSuitePreference:e.localSuitePreference,advertisedSuiteRegistry:r.suiteRegistry,advertisedVersionMin:r.e2eeVersionMin,advertisedVersionMax:r.e2eeVersionMax,advertisedAdmittedPatterns:r.admittedPatterns});return s.kind===`unusable`?{kind:`unusable`,reason:s.reason,statement:r}:{kind:`verified`,statement:r,selectedSuite:s.selectedSuite,anchor:o.pinnedFingerprintUnchanged===void 0?`none`:o.pinnedFingerprintUnchanged?`pin-unchanged`:`pin-updated`}}var tm={[Xe.read]:`viewer`,[Xe.subscribeEvents]:`viewer`,[Xe.lifecycle]:`owner`,[Xe.input]:`owner`,[Xe.app]:`owner`,[Xe.recording]:`owner`,[It.acceptProposal]:`owner`,[It.getProposal]:`owner`,[It.listProposals]:`owner`,[It.rejectProposal]:`owner`,[It.subscribeProposals]:`owner`,[It.listIntegrations]:`owner`,[It.createIntegration]:`owner`,[It.updateIntegration]:`owner`,[It.resumeIntegrationPairing]:`owner`,[It.revokeIntegration]:`owner`,[It.deleteIntegration]:`owner`,[It.listMcpInstallations]:`owner`,[It.connectMcpInstallation]:`owner`,[It.repairMcpInstallation]:`owner`,[It.disconnectMcpInstallation]:`owner`,[I.atlassianDisconnect]:`owner`,[I.atlassianGetProjectLink]:`owner`,[I.atlassianListConnections]:`owner`,[I.atlassianListResources]:`owner`,[I.atlassianRefresh]:`owner`,[I.atlassianSaveManualBitbucketToken]:`owner`,[I.atlassianSaveManualJiraToken]:`owner`,[I.atlassianSaveProjectLink]:`owner`,[I.atlassianStartOAuth]:`owner`,[I.chatAttachmentsCreateFileUpload]:`operator`,[I.chatAttachmentsReadChunk]:`operator`,[I.filesystemBrowse]:`operator`,[I.gitArchiveWorktree]:`operator`,[I.gitCreateWorktreeForProject]:`operator`,[I.gitDeleteWorktree]:`operator`,[I.gitFindWorktreeForOrigin]:`operator`,[I.gitPreparePullRequestThread]:`operator`,[I.gitResolvePullRequest]:`operator`,[I.gitRestoreWorktree]:`operator`,[I.gitRunStackedAction]:`operator`,[I.keybindingsReplaceCustom]:`owner`,[I.mcpListServers]:`owner`,[I.mcpListWorkspaces]:`owner`,[I.mcpReloadServers]:`owner`,[I.mcpRemoveServer]:`owner`,[I.mcpSetServerEnabled]:`owner`,[I.mcpStartOauthLogin]:`owner`,[I.mcpUpsertServer]:`owner`,[o.dispatchCommand]:`operator`,[o.getFullThreadDiff]:`viewer`,[o.getTurnDiff]:`viewer`,[o.getTaskOutput]:`operator`,[o.getThreadHistoryPage]:`viewer`,[o.getThreadWindow]:`viewer`,[o.getWorkflowScript]:`operator`,[o.stopBackgroundTask]:`operator`,[o.replayEvents]:`viewer`,[o.replayEventsPage]:`viewer`,[o.searchThreadMessages]:`viewer`,[o.subscribeShell]:`viewer`,[o.subscribeThread]:`viewer`,[o.subscribeThreadWindow]:`viewer`,[v.getInspectionSummary]:`viewer`,[v.listInspectionEntries]:`viewer`,[v.readRawPayloadChunk]:`viewer`,[v.readExportChunk]:`viewer`,[I.projectsAdd]:`operator`,[I.projectsInitializeGit]:`operator`,[I.projectsList]:`viewer`,[I.projectsListEntries]:`operator`,[I.projectsReadFile]:`operator`,[I.projectsReadFileBinary]:`operator`,[I.projectsRemove]:`operator`,[I.projectsSearchEntries]:`operator`,[I.projectsStageFileReference]:`operator`,[I.projectsWriteFile]:`operator`,[I.serverCheckOpinionatedPlugins]:`owner`,[I.serverDiscoverSourceControl]:`owner`,[I.serverGetAdvertisedEndpoints]:`viewer`,[I.serverGetConfig]:`viewer`,[I.serverGetDiagnosticsMetrics]:`owner`,[I.serverGetDiagnosticsSnapshot]:`owner`,[I.serverSignalDiagnosticProcess]:`owner`,[I.serverGetResourceTelemetryHistory]:`owner`,[I.serverRetryResourceTelemetry]:`owner`,[I.serverGetSettings]:`viewer`,[I.serverGetStatistics]:`owner`,[I.serverGetUsageSummary]:`owner`,[I.serverInstallOpinionatedPlugin]:`owner`,[I.serverListOpinionatedPlugins]:`owner`,[I.serverRefreshProviders]:`owner`,[I.serverUpdateProvider]:`owner`,[I.serverUpdateSettings]:`owner`,[I.serverUpsertKeybinding]:`owner`,[I.shellOpenInEditor]:`operator`,[I.sourceControlAddChangeRequestComment]:`operator`,[I.sourceControlAddChangeRequestCommentReaction]:`operator`,[I.sourceControlAddIssueComment]:`operator`,[I.sourceControlAddIssueCommentReaction]:`operator`,[I.sourceControlCloneRepository]:`operator`,[I.sourceControlCreateIssue]:`operator`,[I.sourceControlGetChangeRequestDetail]:`operator`,[I.sourceControlGetChangeRequestDiff]:`operator`,[I.sourceControlGetIssue]:`operator`,[I.sourceControlGetWorkflowJobLog]:`operator`,[I.sourceControlGetWorkflowRunJobs]:`operator`,[I.sourceControlListChangeRequests]:`operator`,[I.sourceControlListIssueAssignees]:`operator`,[I.sourceControlListIssueLabels]:`operator`,[I.sourceControlListIssues]:`operator`,[I.sourceControlListWorkflowRuns]:`operator`,[I.sourceControlLookupRepository]:`operator`,[I.sourceControlMergeChangeRequest]:`operator`,[I.sourceControlPublishRepository]:`operator`,[I.sourceControlRerunWorkflow]:`operator`,[I.sourceControlSearchChangeRequests]:`operator`,[I.sourceControlSearchIssues]:`operator`,[I.sourceControlSearchRepositories]:`operator`,[I.subscribeAuthAccess]:`direct_owner`,[I.subscribeServerConfig]:`viewer`,[I.subscribeServerLifecycle]:`viewer`,[I.subscribeTerminalEvents]:`operator`,[I.subscribeVcsStatus]:`operator`,[I.terminalClear]:`operator`,[I.terminalClose]:`operator`,[I.terminalOpen]:`operator`,[I.terminalResize]:`operator`,[I.terminalRestart]:`operator`,[I.terminalWrite]:`operator`,[I.textGenerationGenerateBranchName]:`operator`,[I.textGenerationGenerateIssueContent]:`operator`,[I.threadPriorityEnsureCurrent]:`operator`,[I.searchThreadMessages]:`owner`,[I.threadsSetManualBucket]:`operator`,[I.threadsSetManualPosition]:`operator`,[I.vcsCreateRef]:`operator`,[I.vcsCreateWorktree]:`operator`,[I.vcsInit]:`operator`,[I.vcsListRefs]:`operator`,[I.vcsPull]:`operator`,[I.vcsRefreshStatus]:`operator`,[I.vcsRemoveWorktree]:`operator`,[I.vcsSwitchRef]:`operator`,[I.workItemsAddComment]:`operator`,[I.workItemsEditComment]:`operator`,[I.workItemsGet]:`viewer`,[I.workItemsList]:`viewer`,[I.workItemsListProjects]:`viewer`,[I.workItemsListTransitions]:`viewer`,[I.workItemsSearch]:`viewer`,[I.workItemsTransition]:`operator`,[I.workItemsUpdate]:`operator`,[I.worktreesSetManualPosition]:`operator`};function nm(e){if(!Object.hasOwn(tm,e))throw Error(`RPC method has no explicit access classification.`);return tm[e]}var rm={viewer:1,operator:2,owner:3};function im(e,t,n=!0){if(!e||!n)return!1;let r=nm(t);return r===`authenticated`||r===`direct_owner`?!1:rm[e]>=rm[r]}var am=new Set([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]);function om(){throw Error(`Invalid passkey options.`)}function sm(e){return(typeof e!=`object`||!e||Array.isArray(e))&&om(),e}function cm(e){return(typeof e!=`string`||e.length===0)&&om(),e}function lm(e){if(e!==void 0)return(typeof e!=`number`||!Number.isSafeInteger(e)||e<0)&&om(),e}function um(e){try{return en(cm(e))}catch{return om()}}function dm(e){if(e!==void 0)return Array.isArray(e)||om(),e.map(e=>{let t=sm(e);t.type!==`public-key`&&om();let n=t.transports;return n!==void 0&&!Array.isArray(n)&&om(),Array.isArray(n)&&n.some(e=>typeof e!=`string`||!am.has(e))&&om(),{id:um(t.id),type:`public-key`,...Array.isArray(n)?{transports:n}:{}}})}function fm(e){if(e!==void 0)return e===`discouraged`||e===`preferred`||e===`required`?e:om()}function pm(e){if(e!==void 0)return sm(e)}function mm(e){let t=sm(e),n={challenge:um(t.challenge)},r=lm(t.timeout),i=t.rpId===void 0?void 0:cm(t.rpId),a=dm(t.allowCredentials),o=fm(t.userVerification),s=pm(t.extensions);return r!==void 0&&(n.timeout=r),i!==void 0&&(n.rpId=i),a!==void 0&&(n.allowCredentials=a),o!==void 0&&(n.userVerification=o),s!==void 0&&(n.extensions=s),n}function hm(e){let t=sm(e),n=sm(t.rp),r=sm(t.user);(!Array.isArray(t.pubKeyCredParams)||t.pubKeyCredParams.length===0)&&om();let i=t.pubKeyCredParams.map(e=>{let t=sm(e);return(t.type!==`public-key`||typeof t.alg!=`number`||!Number.isSafeInteger(t.alg))&&om(),{type:`public-key`,alg:t.alg}}),a={challenge:um(t.challenge),rp:{name:cm(n.name),...n.id===void 0?{}:{id:cm(n.id)}},user:{id:um(r.id),name:cm(r.name),displayName:cm(r.displayName)},pubKeyCredParams:i},o=lm(t.timeout),s=dm(t.excludeCredentials),c=vm(t.authenticatorSelection),l=ym(t.attestation),u=pm(t.extensions);return o!==void 0&&(a.timeout=o),s!==void 0&&(a.excludeCredentials=s),c!==void 0&&(a.authenticatorSelection=c),l!==void 0&&(a.attestation=l),u!==void 0&&(a.extensions=u),a}function gm(e){return mm(e)}function _m(e){return hm(e)}function vm(e){if(e===void 0)return;let t=sm(e),n=t.authenticatorAttachment,r=t.residentKey,i=t.requireResidentKey,a=fm(t.userVerification);return n!==void 0&&n!==`platform`&&n!==`cross-platform`&&om(),r!==void 0&&r!==`discouraged`&&r!==`preferred`&&r!==`required`&&om(),i!==void 0&&typeof i!=`boolean`&&om(),{...n===void 0?{}:{authenticatorAttachment:n},...r===void 0?{}:{residentKey:r},...i===void 0?{}:{requireResidentKey:i},...a===void 0?{}:{userVerification:a}}}function ym(e){if(e!==void 0)return e===`none`||e===`indirect`||e===`direct`||e===`enterprise`?e:om()}var bm={authorization_rejected:`The Hub authorization request could not be verified.`,callback_rejected:`The browser response could not be verified.`,cancelled:`Authorization was cancelled.`,expired:`The authorization request expired. Try again.`,platform_invalid:`Secure browser authorization is unavailable on this device.`,superseded:`A newer authorization request replaced this one.`},xm=6e4,Sm=class extends Error{code;constructor(e){super(bm[e]),this.name=e===`cancelled`||e===`superseded`?`AbortError`:`NativeHandoffError`,this.code=e}},Cm=new Map;function wm(e,t){return We(e)(t,{onExcessProperty:`error`})}function Tm(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=1)t[n]=e.charCodeAt(n);return t}async function Em(e){let t=await e.randomBytes(32);if(!(t instanceof Uint8Array)||t.byteLength!==32)throw new Sm(`platform_invalid`);return Uint8Array.from(t)}function Dm(e,t){let n=Math.max(e.length,t.length),r=e.length^t.length;for(let i=0;i<n;i+=1)r|=(e.charCodeAt(i)||0)^(t.charCodeAt(i)||0);return r===0}function Om(e,t){let n=Cm.get(e);n&&(n.superseded=!0),n?.controller.abort();let r={generation:(n?.generation??0)+1,controller:new AbortController,superseded:!1};Cm.set(e,r);let i=()=>r.controller.abort();return t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0}),{active:r,isCurrent:()=>Cm.get(e)===r&&!r.controller.signal.aborted,cleanup:()=>{t?.removeEventListener(`abort`,i),Cm.get(e)===r&&Cm.delete(e)}}}function km(e,t){if(!t())throw new Sm(e.superseded?`superseded`:`cancelled`)}function Am(e,t){let n=e-t;if(n<-6e4)throw new Sm(`expired`);if(n>3e5+xm)throw new Sm(`authorization_rejected`)}function jm(e,t){if(t-e>xm)throw new Sm(`expired`)}function Mm(e,t){let n;try{n=new URL(e)}catch{throw new Sm(`callback_rejected`)}if(n.searchParams.has(`error`)){try{wm(E,{redirectUri:e})}catch{throw new Sm(`callback_rejected`)}let r=n.searchParams.get(`state`)??``,i=n.searchParams.get(`handoff_id`)??``;throw!Dm(r,t.state)||!Dm(i,t.handoffId)?new Sm(`callback_rejected`):new Sm(`cancelled`)}try{wm(le,{redirectUri:e})}catch{throw new Sm(`callback_rejected`)}let r=`${n.protocol}//${n.host}${n.pathname}`,i=n.searchParams.get(`state`)??``,a=n.searchParams.get(`handoff_id`)??``;if(r!==t.callbackUri||!Dm(i,t.state)||!Dm(a,t.handoffId))throw new Sm(`callback_rejected`);return{code:n.searchParams.get(`code`)}}async function Nm(e){let t;try{t=wm(b,e.callbackUri())}catch{throw new Sm(`callback_rejected`)}let n=e.deviceLabel().trim();if(n.length===0||Array.from(n).length>64)throw new Sm(`platform_invalid`);let r=tn(await Em(e)),i=tn(await Em(e)),a=await e.sha256(Tm(i));if(!(a instanceof Uint8Array)||a.byteLength!==32)throw new Sm(`platform_invalid`);let o={callbackUri:t,codeChallenge:tn(a),codeVerifier:i,deviceLabel:n,state:r};try{wm(Se,{redirectUri:o.callbackUri,codeChallenge:o.codeChallenge,codeChallengeMethod:`S256`,state:o.state,deviceLabel:o.deviceLabel})}catch{throw new Sm(`platform_invalid`)}return o}async function Pm(e){let{active:t,isCurrent:n,cleanup:r}=Om(e.coordinatorKey??e.origin,e.signal),i=e.now??Date.now;try{km(t,n);let r=await Nm(e.platform);km(t,n);let a=wm(Se,{redirectUri:r.callbackUri,codeChallenge:r.codeChallenge,codeChallengeMethod:`S256`,state:r.state,deviceLabel:r.deviceLabel,...e.purpose?{purpose:e.purpose}:{}}),o;try{o=wm(Ee,await e.start(a,t.controller.signal))}catch(e){throw n()||km(t,n),e instanceof Sm?e:new Sm(`authorization_rejected`)}let s=i(),c;try{c=new URL(o.authorizationUrl)}catch{throw new Sm(`authorization_rejected`)}if(c.origin!==new URL(e.origin).origin)throw new Sm(`authorization_rejected`);Am(o.expiresAt,s);let l=await e.platform.openSystemBrowser(o.authorizationUrl,r.callbackUri,t.controller.signal);if(km(t,n),l.type!==`success`)throw new Sm(l.type===`locked`?`authorization_rejected`:`cancelled`);jm(o.expiresAt,i());let{code:u}=Mm(l.url,{callbackUri:r.callbackUri,state:r.state,handoffId:o.handoffId});km(t,n);let d;try{d=wm(e.redeemResponseSchema,await e.redeem(wm(e.redeemRequestSchema,e.buildRedeemRequest(wm(we,{handoffId:o.handoffId,code:u,codeVerifier:r.codeVerifier}))),t.controller.signal))}catch(e){throw n()||km(t,n),e}return km(t,n),d}finally{r()}}async function Fm(e){return Pm({...e,redeemRequestSchema:we,redeemResponseSchema:w,buildRedeemRequest:e=>e})}var Im={accept:`application/json`,"content-type":`application/json`},Lm=4096,Rm=256,zm=256,Bm=100,Vm=/^node_[A-Za-z0-9_-]{22,43}$/,Hm=/^[a-z0-9._-]{1,64}$/,Um=256,Wm=512,Gm=/^[A-Za-z0-9_-]{1,512}$/,Km=/^pkey_[A-Za-z0-9_-]{22}$/,qm=256,Jm=256,Ym=2048,Xm=254,Zm=256,Qm=16,$m=128,eh=/^[A-Za-z0-9_-]{43}$/,th=`otpauth://`,nh=3e4,rh=[`/api/auth/native/bootstrap/registration/`,`/api/auth/native/invitations/registration/`];function ih(e){let t=e.toLowerCase();return rh.some(e=>t.startsWith(e))}var ah=new Set([`set-password`,`remove-password`,`revoke-totp`,`request-email-verification`,`add-passkey`,`regenerate-recovery-codes`,`connect-external-identity`,`disconnect-external-identity`]),oh=new Set([`begin-totp-enrollment`,`confirm-totp-enrollment`]),sh=`step_up_required`,ch=`passkey_session_required`;function lh(e,t,n){let r={code:e,wire:e,inferred:!1};return!n||e!==`forbidden`||t===void 0?r:ah.has(t)?{code:sh,wire:e,inferred:!0}:oh.has(t)?{code:ch,wire:e,inferred:!0}:r}var J=class extends Error{code;status;retryAfterMs;intent;wireCode;inferred;reason;constructor(e,t,n,r,i,a){super(a?dh(a).message:ph(e,r)),this.name=`HostedHubApiError`,this.code=e,this.status=t,this.retryAfterMs=n,this.intent=r,this.wireCode=i??e,this.inferred=i!==void 0&&i!==e,this.reason=a??null}},uh={"missing-signer":{reason:`missing-signer`,title:`Secure session unavailable`,message:`Secure session signing is unavailable on this device. Restart the app, then try again.`,recovery:`restart-app`},"missing-token":{reason:`missing-token`,title:`Sign in again`,message:`This device no longer has its secure Hub session. Sign in again to continue.`,recovery:`sign-in`},"proof-signing-failed":{reason:`proof-signing-failed`,title:`Secure session could not be verified`,message:`This device could not verify its secure Hub session. Unlock the device and try again; if it continues, sign in again.`,recovery:`retry`},"token-invalidated":{reason:`token-invalidated`,title:`Session no longer valid`,message:`Your secure Hub session is no longer valid. Sign in again to continue.`,recovery:`sign-in`},"request-timeout":{reason:`request-timeout`,title:`Hub did not respond`,message:`The Hub did not respond in time. Check your connection and try again.`,recovery:`retry`},"transport-unavailable":{reason:`transport-unavailable`,title:`Hub could not be reached`,message:`Ryco could not reach the Hub. Check your connection and try again.`,recovery:`retry`}};function dh(e){return uh[e]}function fh(e,t){if(e===`conflict`)switch(t){case`set-password`:return`That password has appeared in a known breach. Choose a different one.`;case`revoke-passkey`:return`That is the only passkey left on this account. Add another before removing it.`;case`begin-totp-enrollment`:return`Two-factor authentication is already set up on this account.`;case`confirm-totp-enrollment`:return`This setup is no longer in progress. Start again.`;case`request-email-verification`:return`That email address is already in use.`;case`disconnect-external-identity`:return`GitHub is the only sign-in method on this account. Add another before disconnecting it.`;default:return null}return e===`authentication_failed`&&t===`confirm-totp-enrollment`||e===`authentication_failed`&&(t===`connect-external-identity`||t===`disconnect-external-identity`)?`That code is not correct. Check your authenticator app and try again.`:e===`not_found`&&t===`revoke-passkey`?`That passkey is no longer on this account.`:null}function ph(e,t){let n=t===void 0?null:fh(e,t);if(n!==null)return n;switch(e){case sh:return`Enter a current code from your authenticator app to confirm this change.`;case ch:return`Sign in with a passkey on this device to change two-factor settings.`;case`invalid_credential_id`:return`That passkey could not be identified.`;case`external_provider_unavailable`:return`GitHub sign-in is temporarily unavailable.`;case`external_authorization_cancelled`:return`GitHub authorization was cancelled.`;case`external_authorization_expired`:return`GitHub authorization expired. Try again.`;case`external_authorization_rejected`:return`GitHub could not authorize this request.`;case`external_identity_already_linked`:return`That GitHub account is already connected.`;case`external_identity_email_conflict`:return`Sign in another way, then connect GitHub from account settings.`;case`external_identity_verified_email_required`:return`GitHub must have a verified primary email to create an account.`;case`signup_disabled`:return`New account signup is currently closed.`;case`username_unavailable`:return`That username is unavailable.`;case`last_primary_credential`:return`Add another sign-in method before disconnecting GitHub.`;case`native_authorization_unavailable`:return`Secure browser authorization is unavailable on this device.`;case`timeout`:return`The request took too long. Check your connection and try again.`;case`authentication_failed`:return`The passkey could not be verified.`;case`registration_unavailable`:return`The invitation or registration challenge is unavailable or expired.`;case`session_invalid`:case`unauthorized`:return`Your Hub session has expired.`;case`csrf_rejected`:return`The request could not be verified. Refresh and try again.`;case`forbidden`:case`authorization_failed`:return`You are not authorized to perform this action.`;case`not_found`:return`The requested item is no longer available.`;case`conflict`:case`ticket_consumed`:return`The request has already been used.`;case`rate_limited`:case`node_rate_limited`:return`Too many attempts. Wait briefly and try again.`;case`enrollment_unavailable`:return`The node enrollment is unavailable or expired.`;case`node_offline`:return`The selected node is offline.`;case`server_draining`:return`Hub is temporarily draining relay connections.`;case`unsupported_version`:return`The selected node or Hub uses an incompatible relay version.`;case`invalid_request`:return`The response was malformed or expired.`;case`browser_only_transport`:return`This action is only available in a browser.`;case`native_only_transport`:return`This action is only available in the native app.`;default:return`Hub is temporarily unavailable.`}}function mh(e){if(typeof e!=`object`||!e||Array.isArray(e))throw new J(`invalid_response`,502);return e}function Y(e,t,n){try{return We(e)(t,{onExcessProperty:`error`})}catch{throw new J(n,n===`invalid_request`?400:502)}}function hh(e){if(typeof e!=`string`)throw new J(`invalid_response`,502);try{return Iu(e)}catch{throw new J(`invalid_response`,502)}}function gh(e){return e===null||typeof e==`number`&&Number.isSafeInteger(e)}function _h(e){return e===`viewer`||e===`operator`||e===`owner`}function vh(e){return e===`darwin`||e===`linux`||e===`windows`||e===`unknown`}function yh(e){return e===`arm64`||e===`x64`||e===`other`}function bh(e){return typeof e==`string`&&e.length>0&&e.length<=Lm?e:null}function xh(e){return!Array.isArray(e)||e.some(e=>typeof e!=`string`)?null:e}function Sh(e){let t=xh(e);return!t||t.length===0||t.length>Um||t.some(e=>e.length===0||e.length>Wm)?null:t}function Ch(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;return typeof t.id!=`string`||!Gm.test(t.id)?null:{id:t.id,label:typeof t.label==`string`&&t.label.length<=Rm?t.label:null,createdAt:gh(t.createdAt)?t.createdAt:null,lastUsedAt:gh(t.lastUsedAt)?t.lastUsedAt:null,backupEligible:typeof t.backupEligible==`boolean`?t.backupEligible:null,backupState:typeof t.backupState==`boolean`?t.backupState:null,revokedAt:gh(t.revokedAt)?t.revokedAt:null,revocationReasonCode:typeof t.revocationReasonCode==`string`&&t.revocationReasonCode.length>0&&t.revocationReasonCode.length<=qm?t.revocationReasonCode:null}}function wh(e){try{return We(Ge)(e,{onExcessProperty:`error`})}catch{return null}}function Th(e){let t=e?.totpCode;return typeof t==`string`&&t.trim().length>0?{totpCode:t}:{}}function Eh(e,t){if(typeof e!=`string`||e.length===0||e.length>t)throw new J(`invalid_request`,400);return e}function Dh(e){return e==null||e===``?{}:{totpCode:Eh(e,Qm)}}function Oh(e){let t=Eh(e,64);if(!eh.test(t))throw new J(`invalid_request`,400);return t}function kh(e){return typeof e==`string`&&e.length>0&&e.length<=Jm?e:null}function Ah(e){return typeof e==`string`&&e.length<=Ym&&e.toLowerCase().startsWith(th)?e:null}var jh=/^[a-z][a-z0-9_]{0,63}$/;function Mh(e){return typeof e==`string`&&jh.test(e)?e:`unavailable`}async function Nh(e,t,n){let r;try{r=await e.json()}catch{throw new J(`invalid_response`,e.status,void 0,t)}let i=mh(r);if(!e.ok){let r=typeof i.retryAfterMs==`number`&&Number.isSafeInteger(i.retryAfterMs)&&i.retryAfterMs>=0&&i.retryAfterMs<=3e5?i.retryAfterMs:void 0,a=lh(Mh(i.error),t,n);throw new J(a.code,e.status,r,t,a.wire)}return i}var Ph=class{#e;#t;#n;#r;#i;#a;#o=null;constructor(e){if(this.#e=e.endpoint,this.#t=e.httpClient,this.#n=e.passkeyCeremony,this.#r=e.sessionCredentials,this.#i=e.dpopSigner,this.#a=e.nativeAuthorization,this.#r.mode===`bearer`){if(!this.#i)throw new J(`native_session_unavailable`,0,void 0,void 0,void 0,`missing-signer`);if(!this.#r.readBearerToken||!this.#r.writeBearerToken)throw new J(`native_session_unavailable`,0,void 0,void 0,void 0,`missing-token`)}}get#s(){return this.#r.mode===`bearer`}#c(){return this.#r.readBearerToken?.()??null}#l(e){this.#r.writeBearerToken?.(e)}get hasSessionMaterial(){return this.#s?this.#c()!==null:this.#r.readCsrfToken()!==null}clearSessionMaterial(){this.#o=null,this.#s?this.#l(null):this.#r.writeCsrfToken(null)}async getBootstrapAvailability(e){let t=await this.#E(`/api/auth/bootstrap-status`,{dpop:`mint`,...e?{signal:e}:{}});if(Object.keys(t).length!==1||typeof t.available!=`boolean`)throw new J(`invalid_response`,502);return t.available}async getPublicSignupConfiguration(e){return this.#m(),Y(u,await this.#E(Ue,e?{signal:e}:{}),`invalid_response`)}async getExternalIdentityConfiguration(e){return Y(bt,await this.#E(Oe,{...this.#s?{dpop:`mint`}:{},...e?{signal:e}:{}}),`invalid_response`)}async startExternalIdentityAuthorization(e,t){this.#m();let r=Y(Je,e,`invalid_request`);return Y(Pt,await this.#E(n,{method:`POST`,body:r,...r.intent===`link`?{csrf:!0,intent:`connect-external-identity`}:{},...t?{signal:t}:{}}),`invalid_response`)}async getPendingExternalIdentity(e){return this.#m(),Y(Le,await this.#E(Ne,e?{signal:e}:{}),`invalid_response`)}async finishExternalIdentitySignup(e,t){this.#m();let n=Y(Mt,e,`invalid_request`),r=Y(He,await this.#E(de,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`);return this.#r.writeCsrfToken(r.identity.csrfToken),r}async restoreSession(e){let t=await this.#E(`/api/auth/session`,e?{signal:e}:{});if(this.#s)return this.#b(t);let n=this.#w(t);return this.#r.writeCsrfToken(n.csrfToken),n}async signIn(e){if(this.#s&&this.#a){let t=await Fm({origin:this.#e.origin(),platform:this.#a,...e?{signal:e}:{},start:(e,t)=>this.#u(e,t),redeem:(e,t)=>this.#d(e,t)}),n=this.#C(t);return this.#l(t.token),n}let t=this.#s?`/api/auth/native/passkey`:`/api/auth/passkey`,n=await this.#E(`${t}/options`,{method:`POST`,body:{},dpop:`mint`,...e?{signal:e}:{}}),r=await this.#n.authenticate(gm(n.options),e);return this.#y(await this.#E(`${t}/verify`,{method:`POST`,body:{response:r},dpop:`mint`,...e?{signal:e}:{}}))}async signInWithExternalProvider(e,t){this.#h();let n=Y(St,e,`invalid_request`),r=this.#a;if(!r)throw new J(`native_authorization_unavailable`,400);let i=await Pm({origin:this.#e.origin(),platform:r,purpose:{kind:`sign_in`,providerHint:n},redeemRequestSchema:we,redeemResponseSchema:w,buildRedeemRequest:e=>e,...t?{signal:t}:{},start:(e,t)=>this.#u(e,t),redeem:(e,t)=>this.#d(e,t)}),a=this.#C(i);return this.#l(i.token),a}async connectExternalIdentity(e,t,n){this.#h();let r=Y(St,e,`invalid_request`),i=this.#a;if(!i)throw new J(`native_authorization_unavailable`,400);let a=this.#o;if(a&&a.expiresAt<Date.now())this.#o=null;else if(a?.provider===r){let e=Y(N,{...a.request,...Th(t)},`invalid_request`);try{let t=await this.#f(e,n);return this.#o=null,t.externalIdentity}catch(e){throw this.#p(e)||(this.#o=null),e}}let o=null;try{return(await Pm({origin:this.#e.origin(),coordinatorKey:`${this.#e.origin()}:connect:${r}`,platform:i,purpose:{kind:`connect_external_identity`,provider:r},redeemRequestSchema:N,redeemResponseSchema:pe,buildRedeemRequest:e=>({...e,purpose:{kind:`connect_external_identity`,provider:r},...Th(t)}),...n?{signal:n}:{},start:(e,t)=>this.#u(e,t),redeem:(e,t)=>(o=e,this.#f(e,t))})).externalIdentity}catch(e){throw o&&this.#p(e)&&(this.#o={provider:r,request:o,expiresAt:Date.now()+pt}),e}}cancelExternalIdentityConnection(e){let t=Y(St,e,`invalid_request`);this.#o?.provider===t&&(this.#o=null)}async signInWithNativePasskey(e){this.#h();let t=`/api/auth/native/passkey`,n=await this.#E(`${t}/options`,{method:`POST`,body:{},dpop:`mint`,...e?{signal:e}:{}}),r=await this.#n.authenticate(gm(n.options),e),i=await this.#E(`${t}/verify`,{method:`POST`,body:{response:r},dpop:`mint`,...e?{signal:e}:{}}),a=this.#T(i);return{session:a.response,token:a.token}}async startPublicSignup(e,t){this.#m();let n=Y(ft,e,`invalid_request`);return Y(i,await this.#E(Qe,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`)}async verifyPublicSignup(e,t){this.#m();let n=Y(lt,e,`invalid_request`);return Y(te,await this.#E(Tt,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`)}async finishPublicSignupWithPasskey(e,t){this.#m();let n=Y(ve,{...e,response:{}},`invalid_request`),r=Y(g,{attemptId:n.attemptId,activationSecret:n.activationSecret},`invalid_request`),i=Y(p,await this.#E(zt,{method:`POST`,body:r,...t?{signal:t}:{}}),`invalid_response`),a=await this.#n.register(_m(i.options),t),o=Y(ve,{...n,response:a},`invalid_request`),s=Y(Wt,await this.#E(gt,{method:`POST`,body:o,...t?{signal:t}:{}}),`invalid_response`);return this.#r.writeCsrfToken(s.identity.csrfToken),s}async finishPublicSignupWithPassword(e,t){this.#m();let n=Y(ae,e,`invalid_request`),r=Y(Wt,await this.#E(Ke,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`);return this.#r.writeCsrfToken(r.identity.csrfToken),r}async startPasswordLogin(e,t){this.#m();let n=Y(it,e,`invalid_request`);return Y(tt,await this.#E(st,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`)}async finishPasswordLogin(e,t){this.#m();let n=Y(vt,e,`invalid_request`),r=Y(Ze,await this.#E(jt,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`);return this.#r.writeCsrfToken(r.csrfToken),r}async requestPasswordReset(e,t){this.#m();let n=Y(Xt,e,`invalid_request`);return Y(Be,await this.#E(Ct,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`)}async verifyPasswordReset(e,t){this.#m();let n=Y(qt,e,`invalid_request`);return Y(he,await this.#E(Nt,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`)}async finishPasswordReset(e,t){this.#m();let n=Y(Fe,e,`invalid_request`),r=Y(Vt,await this.#E(Re,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`);return this.clearSessionMaterial(),r}async startNativeIdentityEmail(e,t){return this.#g(_t,r,ct,e,t)}async verifyNativeIdentityEmail(e,t){return this.#g(rt,P,F,e,t)}async claimNativeIdentityUsername(e,t){return this.#g(_e,Me,ue,e,t)}async finishNativeIdentitySignupWithPasskey(e,t){this.#h();let n=Y(Dt,{...e,response:{}},`invalid_request`),r=Y(D,{attemptId:n.attemptId,activationSecret:n.activationSecret},`invalid_request`),i=await this.#g(l,D,ke,r,t),a=await this.#n.register(_m(i.options),t);return this.#g(me,Dt,k,{...n,response:a},t)}async finishNativeIdentitySignupWithPassword(e,t){return this.#g(Ut,De,k,e,t)}async startNativeIdentityPasswordLogin(e,t){return this.#g(ze,Ce,C,e,t)}async finishNativeIdentityPasswordLogin(e,t){return this.#g(et,se,ee,e,t)}async signInNativeIdentityWithRecoveryCode(e,t){return this.#g(Kt,be,Te,e,t)}async requestNativeIdentityPasswordReset(e,t){return this.#g(Bt,M,fe,e,t)}async verifyNativeIdentityPasswordReset(e,t){return this.#g(Yt,Qt,s,e,t)}async finishNativeIdentityPasswordReset(e,t){return this.#g(Pe,y,T,e,t)}async cancelNativeIdentityAttempt(e,t){return this.#g(wt,ie,dt,e,t)}async switchActiveSpace(e,t){let n=Y(j,e,`invalid_request`);return Y(kt,await this.#E(S,{method:`POST`,body:n,csrf:!0,dpop:`session`,...t?{signal:t}:{}}),`invalid_response`)}async startNativeNodeClaim(e,t){this.#h();let n=Y(Ft,e,`invalid_request`);return Y(xt,await this.#E(f,{method:`POST`,body:n,dpop:`session`,...t?{signal:t}:{}}),`invalid_response`)}async finishNativeNodeClaim(t,n){this.#h();let r=Y(e,t,`invalid_request`);return Y(Ye,await this.#E(h,{method:`POST`,body:r,dpop:`session`,...n?{signal:n}:{}}),`invalid_response`)}async signInWithPassword(e,t){return this.#m(),this.#y(await this.#E(`/api/auth/password`,{method:`POST`,body:{email:Eh(e.email,Xm),password:Eh(e.password,Zm),...Dh(e.totpCode)},...t?{signal:t}:{}}))}async signInWithRecoveryCode(e,t){return this.#m(),this.#y(await this.#E(`/api/auth/recovery`,{method:`POST`,body:{code:Eh(e,$m)},...t?{signal:t}:{}}))}async requestEmailRecovery(e,t){this.#m();let n=await this.#E(`/api/auth/recovery/email/request`,{method:`POST`,body:{email:Eh(e,Xm)},...t?{signal:t}:{}});if(Object.keys(n).length!==1||n.ok!==!0)throw new J(`invalid_response`,502)}async confirmEmailRecovery(e,t){return this.#m(),this.#y(await this.#E(`/api/auth/recovery/email/confirm`,{method:`POST`,body:{token:Oh(e.token),...Dh(e.totpCode)},...t?{signal:t}:{}}))}async confirmEmailVerification(e,t){this.#m();let n=await this.#E(`/api/auth/email/verify`,{method:`POST`,body:{token:Oh(e)},...t?{signal:t}:{}});if(Object.keys(n).length!==1||n.ok!==!0)throw new J(`invalid_response`,502)}async startNativeHandoff(e,t){return this.#u(e,t)}async#u(e,t){if(!this.#s)throw new J(`browser_only_transport`,400);let n=Y(Se,e,`invalid_request`),r=n.purpose?.kind===`connect_external_identity`;return Y(Ee,await this.#E(ne,{method:`POST`,body:n,dpop:r?`session`:`mint`,...r?{intent:`connect-external-identity`}:{},...t?{signal:t}:{}}),`invalid_response`)}async redeemNativeHandoff(e,t){let n=await this.#d(e,t),r=this.#C(n);return this.#l(n.token),r}async#d(e,t){if(!this.#s)throw new J(`browser_only_transport`,400);let n=Y(we,e,`invalid_request`);return Y(w,await this.#E(ut,{method:`POST`,body:n,dpop:`mint`,...t?{signal:t}:{}}),`invalid_response`)}async#f(e,t){this.#h();let n=Y(N,e,`invalid_request`);return Y(pe,await this.#E(ut,{method:`POST`,body:n,dpop:`session`,intent:`connect-external-identity`,...t?{signal:t}:{}}),`invalid_response`)}#p(e){return e instanceof J&&(e.code===`step_up_required`||e.code===`authentication_failed`||e.code===`forbidden`)}async getNativeHandoffPresentation(e,t){this.#m();let n=Y($t,e,`invalid_request`);return Y(c,await this.#E(`${a}${n}`,t?{signal:t}:{}),`invalid_response`)}async approveNativeHandoff(e,t){this.#m();let n=Y($t,e,`invalid_request`);return Y(le,await this.#E(`${a}${n}${m}`,{method:`POST`,body:{},csrf:!0,...t?{signal:t}:{}}),`invalid_response`)}async cancelNativeHandoff(e,t){this.#m();let n=Y($t,e,`invalid_request`);return Y(E,await this.#E(`${a}${n}${oe}`,{method:`POST`,body:{},csrf:!0,...t?{signal:t}:{}}),`invalid_response`)}#m(){if(this.#s)throw new J(`browser_only_transport`,400)}#h(){if(!this.#s)throw new J(`native_only_transport`,400)}async#g(e,t,n,r,i){this.#h();let a=Y(t,r,`invalid_request`);return Y(n,await this.#E(e,{method:`POST`,body:a,dpop:`mint`,...i?{signal:i}:{}}),`invalid_response`)}async redeemInvitation(e,t){let n=this.#s?`/api/auth/native/invitations/registration`:`/api/auth/invitations/registration`;return this.#v(`${n}/options`,`${n}/verify`,e,{authenticated:!1,...t?{signal:t}:{},finish:e=>this.#y(e)})}async bootstrapOwner(e,t){let n=this.#s?`/api/auth/native/bootstrap/registration`:`/api/auth/bootstrap/registration`;return this.#v(`${n}/options`,`${n}/verify`,e,{authenticated:!1,...t?{signal:t}:{},finish:e=>this.#y(e)})}async listPasskeys(e){let t=await this.#E(`/api/account/passkeys`,e?{signal:e}:{});if(!Array.isArray(t.passkeys)||t.passkeys.length>zm)throw new J(`invalid_response`,502);return t.passkeys.map(e=>{let t=Ch(e);if(!t)throw new J(`invalid_response`,502);return t})}async getAccountSecurity(e){let t=wh(await this.#E(`/api/account/security`,e?{signal:e}:{}));if(!t)throw new J(`invalid_response`,502);return t}async finishBrowserExternalIdentityConnection(e,t,n){this.#m(),Y(St,e,`invalid_request`);let r=Y(O,Th(t),`invalid_request`);return Y(je,await this.#E(ht,{method:`POST`,body:r,csrf:!0,intent:`connect-external-identity`,...n?{signal:n}:{}}),`invalid_response`)}async disconnectExternalIdentity(e,t,n){Y(St,e,`invalid_request`);let r=Y(At,Th(t),`invalid_request`),i=Y(ot,await this.#E(Rt,{method:`POST`,body:r,csrf:!0,intent:`disconnect-external-identity`,...n?{signal:n}:{}}),`invalid_response`);return i.signedOut&&this.clearSessionMaterial(),i}async addPasskey(e,t){let n=typeof e.passkeyLabel==`string`?e.passkeyLabel.trim():null;return this.#v(`/api/account/passkeys/registration/options`,`/api/account/passkeys/registration/verify`,{label:n===null||n.length===0?null:n},{authenticated:!0,intent:`add-passkey`,verifyExtra:Th(e),...t?{signal:t}:{},finish:e=>this.#S(e)})}async regenerateRecoveryCodes(e,t){let n=await this.#E(`/api/account/recovery-codes`,{method:`POST`,body:Th(e),csrf:!0,intent:`regenerate-recovery-codes`,...t?{signal:t}:{}}),r=Sh(n.recoveryCodes);if(!r)throw new J(`invalid_response`,502);return this.#x(n),r}async setPassword(e,t){await this.#_(`/api/account/password`,{password:e.password,...Th(e)},t,`set-password`)}async removePassword(e,t){await this.#_(`/api/account/password/remove`,Th(e),t,`remove-password`)}async beginTotpEnrollment(e){let t=await this.#E(`/api/account/totp/enrollment/options`,{method:`POST`,body:{},csrf:!0,intent:`begin-totp-enrollment`,...e?{signal:e}:{}}),n=kh(t.secretBase32),r=Ah(t.provisioningUri);if(!n||!r)throw new J(`invalid_response`,502);return{secretBase32:n,provisioningUri:r}}async confirmTotpEnrollment(e,t){await this.#_(`/api/account/totp/enrollment/verify`,{code:e.code},t,`confirm-totp-enrollment`)}async revokeTotp(e,t){await this.#_(`/api/account/totp/revoke`,Th(e),t,`revoke-totp`)}async requestEmailVerification(e,t){await this.#_(`/api/account/email/verification`,{email:e.email,...Th(e)},t,`request-email-verification`)}async revokePasskey(e,t){if(!Km.test(e))throw new J(`invalid_credential_id`,400);await this.#_(`/api/account/passkeys/${e}/revoke`,{},t,`revoke-passkey`)}async#_(e,t,n,r){let i=await this.#E(e,{method:`POST`,body:t,csrf:!0,intent:r,...n?{signal:n}:{}});if(Object.keys(i).length!==1||i.ok!==!0)throw new J(`invalid_response`,502,void 0,r)}async#v(e,t,n,r){let i={csrf:r.authenticated,...r.authenticated?{}:{dpop:`mint`},...r.intent?{intent:r.intent}:{},...r.signal?{signal:r.signal}:{}},a=await this.#E(e,{method:`POST`,body:n,...i,narrowForbidden:!1}),o=await this.#n.register(_m(a.options),r.signal);return r.finish(await this.#E(t,{method:`POST`,body:{response:o,...r.verifyExtra},...i}))}#y(e){if(this.#s){let{response:t,token:n}=this.#T(e);return this.#l(n),t}let t=this.#w(e);return this.#r.writeCsrfToken(t.csrfToken),t}#b(e){let t=this.#C(e),n=bh(e.token);return n&&this.#l(n),t}#x(e){if(this.#s){let{token:t}=this.#T(e);this.#l(t);return}this.#r.writeCsrfToken(this.#w(e).csrfToken)}#S(e){this.#x(e);let t=Ch(e.passkey);return{passkey:t,confirmed:t!==null}}async signOut(e){await this.#E(`/api/auth/logout`,{method:`POST`,body:{},csrf:!0,...e?{signal:e}:{}}),this.clearSessionMaterial()}async listNodes(e){let n=await this.#E(`/api/nodes`,e?{signal:e}:{});if(!Array.isArray(n.nodes))throw new J(`invalid_response`,502);return n.nodes.map(e=>{let n=mh(e),r=mh(n.grant),i=mh(n.presence),a=n.capabilities===void 0?null:mh(n.capabilities),o=Y(Ae,n.id,`invalid_response`);if(typeof n.environmentId!=`string`||typeof n.label!=`string`||!vh(n.platformOs)||!yh(n.platformArch)||typeof n.clientVersion!=`string`||!gh(n.createdAt)||n.createdAt===null||!gh(n.updatedAt)||n.updatedAt===null||!gh(n.lastAuthenticatedAt)||!gh(n.revokedAt)||n.revocationReasonCode!==null&&typeof n.revocationReasonCode!=`string`||typeof r.id!=`string`||!_h(r.role)||!_h(n.effectiveRole)||typeof i.online!=`boolean`||!gh(i.lastHeartbeatAt)||a!==null&&(typeof a.repositoryIdentity!=`boolean`||typeof a.nativeClientRequired!=`boolean`||a.threadSettlement!==void 0&&typeof a.threadSettlement!=`boolean`))throw new J(`invalid_response`,502);let s={id:o,environmentId:t.make(n.environmentId),label:n.label,platformOs:n.platformOs,platformArch:n.platformArch,clientVersion:n.clientVersion,createdAt:n.createdAt,updatedAt:n.updatedAt,lastAuthenticatedAt:n.lastAuthenticatedAt,revokedAt:n.revokedAt,revocationReasonCode:n.revocationReasonCode,grant:{id:r.id,role:r.role},effectiveRole:n.effectiveRole,presence:{online:i.online,lastHeartbeatAt:i.lastHeartbeatAt}};return a?Object.assign(s,{capabilities:{repositoryIdentity:a.repositoryIdentity,nativeClientRequired:a.nativeClientRequired,...typeof a.threadSettlement==`boolean`?{threadSettlement:a.threadSettlement}:{}}}):s})}async renameNode(e,t,n){let r=t.trim();if(!Vm.test(e)||r.length===0||r.length>Bm)throw new J(`invalid_request`,400);let i=await this.#E(`/api/admin/nodes/${encodeURIComponent(e)}/rename`,{method:`POST`,body:{label:r},csrf:!0,...n?{signal:n}:{}});if(Object.keys(i).length!==1||i.ok!==!0)throw new J(`invalid_response`,502)}async revokeNode(e,t,n){if(!Vm.test(e)||!Hm.test(t))throw new J(`invalid_request`,400);let r=await this.#E(`/api/admin/nodes/${encodeURIComponent(e)}/revoke`,{method:`POST`,body:{reasonCode:t},csrf:!0,...n?{signal:n}:{}});if(Object.keys(r).length!==1||r.ok!==!0)throw new J(`invalid_response`,502)}async lookupNodeEnrollment(e,t){let n=mh((await this.#E(`/api/admin/node-enrollments/lookup`,{method:`POST`,body:{deviceCode:e},csrf:!0,...t?{signal:t}:{}})).enrollment);if(typeof n.id!=`string`||!/^enr_[A-Za-z0-9_-]{22}$/.test(n.id)||typeof n.label!=`string`||n.label.length<1||n.label.length>100||!vh(n.platformOs)||!yh(n.platformArch)||typeof n.clientVersion!=`string`||n.clientVersion.length<1||n.clientVersion.length>64||n.algorithm!==`ed25519`||typeof n.fingerprint!=`string`||!/^SHA256:[A-Za-z0-9_-]{43}$/.test(n.fingerprint)||!Number.isSafeInteger(n.createdAt)||!Number.isSafeInteger(n.expiresAt)||Number(n.expiresAt)<=Number(n.createdAt))throw new J(`invalid_response`,502);return{id:n.id,label:n.label,platformOs:n.platformOs,platformArch:n.platformArch,clientVersion:n.clientVersion,algorithm:n.algorithm,fingerprint:n.fingerprint,createdAt:n.createdAt,expiresAt:n.expiresAt}}async approveNodeEnrollment(e,t){let n=await this.#E(`/api/admin/node-enrollments/approve`,{method:`POST`,body:{deviceCode:e},csrf:!0,...t?{signal:t}:{}}),r=mh(n.node),i=mh(n.grant);if(typeof r.id!=`string`||!Vm.test(r.id)||typeof r.environmentId!=`string`||!/^env_[A-Za-z0-9_-]{22}$/.test(r.environmentId)||typeof i.id!=`string`||!/^grant_[A-Za-z0-9_-]{22}$/.test(i.id)||i.role!==`owner`)throw new J(`invalid_response`,502)}async denyNodeEnrollment(e,t){let n=await this.#E(`/api/admin/node-enrollments/deny`,{method:`POST`,body:{deviceCode:e},csrf:!0,...t?{signal:t}:{}});if(Object.keys(n).length!==1||n.ok!==!0)throw new J(`invalid_response`,502)}async issueRelayTicket(e,t){let n=Y(Ae,e,`invalid_request`),r=e=>this.#E(`/api/relay/tickets`,{method:`POST`,body:{nodeId:n,capability:`ryco.rpc`,protocolMajor:1,protocolMinor:e},csrf:!0,...t?{signal:t}:{}}),i=3,a;try{a=await r(i)}catch(e){if(!(e instanceof J)||e.status!==400||e.code!==`invalid_request`)throw e;i=2,a=await r(i)}if(Object.keys(a).length!==4||typeof a.ticket!=`string`||!Number.isSafeInteger(a.expiresAt)||a.protocolMajor!==1||a.protocolMinor!==2&&a.protocolMinor!==3||a.protocolMinor>i)throw new J(`invalid_response`,502);return{ticket:a.ticket,expiresAt:a.expiresAt,protocolMajor:1,protocolMinor:a.protocolMinor}}async upsertE2eeDeviceEnrollment(e,t){this.#h();let n=Y(ye,e,`invalid_request`);if(n.hubOrigin!==this.#e.origin())throw new J(`invalid_request`,400);return Y(_,await this.#E(Jt,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`).enrollment}async getE2eeGrantVerificationKeys(e){return this.#h(),Y(Zt,await this.#E(ge,e?{signal:e}:{}),`invalid_response`)}async issueAccountGrantRelayTicket(e,t){this.#h();let n=Y(d,e,`invalid_request`);return Y(Gt,await this.#E(Ve,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`)}async listE2eeDevices(e){return Y(Et,await this.#E(qe,e?{signal:e}:{}),`invalid_response`).devices}async renameE2eeDevice(e,t,n){let r=Y(ce,e,`invalid_request`),i=Y(at,t,`invalid_request`);return Y(yt,await this.#E(`${$e}/${encodeURIComponent(r)}/rename`,{method:`POST`,body:i,csrf:!0,...n?{signal:n}:{}}),`invalid_response`).enrollment}async revokeE2eeDevice(e,t,n){let r=Y(ce,e,`invalid_request`),i=Y(nt,t,`invalid_request`);return Y(yt,await this.#E(`${$e}/${encodeURIComponent(r)}/revoke`,{method:`POST`,body:i,csrf:!0,...n?{signal:n}:{}}),`invalid_response`).enrollment}#C(e){let t=mh(e.account),n=mh(e.session),r=hh(t.id),i=hh(n.accountId),a=e.recoveryCodes===void 0?void 0:xh(e.recoveryCodes);if(typeof t.displayName!=`string`||!_h(t.role)||!Number.isSafeInteger(t.createdAt)||!gh(t.disabledAt)||typeof n.id!=`string`||!Number.isSafeInteger(n.createdAt)||!Number.isSafeInteger(n.expiresAt)||!Number.isSafeInteger(n.lastSeenAt)||!gh(n.revokedAt)||n.revocationReasonCode!==null&&typeof n.revocationReasonCode!=`string`||a===null)throw new J(`invalid_response`,502);if(t.disabledAt!==null||n.revokedAt!==null||i!==r)throw new J(`session_invalid`,401);return{account:{id:r,displayName:t.displayName,role:t.role,createdAt:t.createdAt,disabledAt:t.disabledAt},session:{id:n.id,accountId:i,createdAt:n.createdAt,expiresAt:n.expiresAt,lastSeenAt:n.lastSeenAt,revokedAt:n.revokedAt,revocationReasonCode:n.revocationReasonCode},...a===void 0?{}:{recoveryCodes:a}}}#w(e){if(typeof e.csrfToken!=`string`||e.csrfToken.length===0)throw new J(`invalid_response`,502);return{...this.#C(e),csrfToken:e.csrfToken}}#T(e){let t=bh(e.token);if(!t)throw new J(`invalid_response`,502);return{response:this.#C(e),token:t}}async#E(e,t){let n=new URL(e,this.#e.origin());if(n.origin!==this.#e.origin()||n.search||n.hash||n.pathname.includes(`%`))throw new J(`invalid_request`,400,void 0,t.intent);if(this.#s&&ih(n.pathname))throw new J(`browser_only_transport`,400,void 0,t.intent);let r=t.method??`GET`,i={...Im},a,o;if(this.#s){let e=this.#i;if(!e)throw new J(`native_session_unavailable`,0,void 0,t.intent,void 0,`missing-signer`);let s=n.toString(),c;if(t.dpop!==`mint`&&(c=this.#c()??void 0,!c))throw new J(`session_invalid`,401,void 0,t.intent,void 0,`missing-token`);try{i.DPoP=await e.sign({method:r,url:s,...c?{token:c}:{}})}catch{throw new J(`native_session_unavailable`,0,void 0,t.intent,void 0,`proof-signing-failed`)}c&&(i.Authorization=`DPoP ${c}`),a=s,o=`omit`}else{if(t.csrf){let e=this.#r.readCsrfToken();if(!e)throw new J(`session_invalid`,401,void 0,t.intent);i[`X-Ryco-CSRF`]=e}a=n.pathname,o=`same-origin`}let s=new AbortController,c=!1,l=setTimeout(()=>{c=!0,s.abort()},nh),u=t.signal,d=()=>s.abort();u?.aborted?s.abort():u?.addEventListener(`abort`,d);let f;try{f=await this.#t.fetch(a,{method:r,credentials:o,cache:`no-store`,headers:i,...t.body===void 0?{}:{body:JSON.stringify(t.body)},signal:s.signal})}catch(e){throw c?new J(`timeout`,0,void 0,t.intent,void 0,`request-timeout`):typeof e==`object`&&e&&`name`in e&&e.name===`AbortError`?e:new J(`unavailable`,0,void 0,t.intent,void 0,`transport-unavailable`)}finally{clearTimeout(l),u?.removeEventListener(`abort`,d)}try{return await Nh(f,t.intent,t.narrowForbidden!==!1)}catch(e){throw this.#s&&t.dpop!==`mint`&&e instanceof J&&e.code===`session_invalid`?new J(e.code,e.status,e.retryAfterMs,e.intent,e.wireCode,`token-invalidated`):e}}},Fh=null,Ih=null,Lh=null;function Rh(e){Lh=e}function zh(){if(Fh||!Lh)return;let e=Lh;Lh=null,e()}function Bh(e,t){Lh=null,Fh=e,Ih=t??new Ph(e)}function Vh(){if(zh(),!Fh)throw Error(`Hosted runtime has not been configured.`);return Fh}function X(){if(zh(),!Ih)throw Error(`Hosted runtime has not been configured.`);return Ih}function Hh(e){return{environmentId:e.environmentId,label:e.label,platform:{os:e.platformOs,arch:e.platformArch},serverVersion:e.clientVersion,capabilities:{repositoryIdentity:!1,threadSettlement:!1,threadPriorityRanking:!1}}}function Uh(e){Vh().nodeLifecycle.clearNodeScopedState(e)}var Wh=null,Gh=!1,Kh=Promise.resolve();function qh(e){let t=Kh.catch(()=>void 0).then(e);return Kh=t.catch(()=>void 0),t}async function Jh(e){let t=Vh().nodeLifecycle;Vh().resetRelayAttemptFactory(),await t.disconnectPrimaryEnvironment(),Uh(e),t.writePrimaryEnvironmentDescriptor(null),Wh===e&&(Wh=null),Gh=!1}async function Yh(e){await qh(async()=>{await Jh(Wh??e)})}async function Xh(e){await qh(async()=>{(Wh??e)!==e||Gh||(Gh=!0,Vh().resetRelayAttemptFactory(),await Vh().nodeLifecycle.disconnectPrimaryEnvironment())})}async function Zh(e,t,n){await qh(async()=>{if(n?.aborted)return;let r=Wh??t;if(r===e.environmentId){if(Gh||(Vh().resetRelayAttemptFactory(),await Vh().nodeLifecycle.disconnectPrimaryEnvironment()),n?.aborted)return}else if(r&&(await Jh(r),n?.aborted))return;let i=Vh().nodeLifecycle;i.writePrimaryEnvironmentDescriptor(Hh(e)),i.setActiveEnvironmentId(e.environmentId),Wh=e.environmentId,Gh=!1,i.connectPrimaryEnvironment()})}var Qh={bootstrapAvailable:!1,accountStatus:`signed-out`,account:null,session:null,directoryStatus:`idle`,nodes:[],selectedNode:null,selectionStatus:`none`,effectiveRole:null,transportStatus:`idle`,sessionStatus:`closed`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1,browserStatus:`current`,recoveryCodes:[],totpEnrollment:null,errorMessage:null,errorReason:null,generation:0},$h={externalIdentityConfiguration:null,externalIdentityConfigurationStatus:`idle`,passkeys:[],passkeysStatus:`idle`,e2eeDevices:[],e2eeDevicesStatus:`idle`,security:null,securityStatus:`idle`,actionStatus:`idle`,errorMessage:null,errorCode:null,errorCodeInferred:!1};function eg(e){let t=e,n=new Set,r=()=>n.forEach(e=>e());return{getState:()=>t,getInitialState:()=>e,setState:(e,n=!1)=>{t=n?e:{...t,...e},r()},subscribe:e=>(n.add(e),()=>n.delete(e))}}var Z=eg(Qh),tg=eg($h),ng=eg({leased:!1});function Q(e){let t=Object.prototype.hasOwnProperty.call(e,`errorMessage`)&&!Object.prototype.hasOwnProperty.call(e,`errorReason`);Z.setState(t?{...e,errorReason:null}:e)}function $(e){tg.setState(e)}function rg(e){return e instanceof J?e.message:e instanceof Sm?e.code===`cancelled`||e.code===`superseded`?``:e.message:typeof e==`object`&&e&&`name`in e&&e.name===`NotAllowedError`?`The passkey request was cancelled or denied.`:typeof e==`object`&&e&&`name`in e&&e.name===`AbortError`?``:`Hub is temporarily unavailable.`}function ig(e){return{errorMessage:rg(e)||null,errorReason:e instanceof J?e.reason:null}}function ag(e){let t=rg(e)||null;return e instanceof J?{errorMessage:t,errorCode:e.code,errorCodeInferred:e.inferred}:{errorMessage:t,errorCode:null,errorCodeInferred:!1}}function og(e){return{errorMessage:e,errorCode:null,errorCodeInferred:!1}}var sg={errorMessage:null,errorCode:null,errorCodeInferred:!1};function cg(e,t){return t instanceof J?{status:`refused`,reason:e,errorCode:t.code,wireErrorCode:t.wireCode,inferredErrorCode:t.inferred,errorMessage:t.message||null}:{status:`refused`,reason:e,errorCode:null,wireErrorCode:null,inferredErrorCode:!1,errorMessage:t===void 0?null:rg(t)||null}}function lg(e,t){return{status:`refused`,reason:e,errorCode:null,wireErrorCode:null,inferredErrorCode:!1,errorMessage:t}}function ug(e){return e instanceof J&&(e.status===401||e.code===`session_invalid`)}function dg(){let e=0;return{bump:()=>{e+=1},issue:()=>{let t=e;return()=>t===e}}}var fg=2e4,pg=6e4,mg=3e4,hg=`Ryco state could not be synchronized.`,gg=`Another account change is still in progress.`,_g=`Sign in to change your account settings.`,vg=`The passkey could not be confirmed. Check your passkeys before relying on it.`,yg=`Your recovery codes were replaced but could not be shown. Your previous codes no longer work — generate a new set and save them.`,bg=`Two-factor setup started but its key could not be shown. Remove two-factor authentication and set it up again.`,xg=class{#e=null;#t=null;#n=0;#r=null;#i=null;#a=null;#o=null;#s=null;#c=null;#l=null;#u=null;#d=null;#f=0;#p=dg();#m=dg();#h=new Set;#g=!1;#_=null;#v=null;#y=null;#b=null;#x=null;#S=null;#C=null;#w=null;#T=0;#E=null;bootstrap(){if(this.#a)return this.#a;let e=this.#G(),t=X().restoreSession(e.signal).then(async e=>{Q({accountStatus:`authenticated`,account:e.account,session:e.session,errorMessage:null}),await this.refreshDirectory()}).catch(t=>{if(!e.signal.aborted){if(X().clearSessionMaterial(),ug(t))return X().getBootstrapAvailability(e.signal).catch(()=>!1).then(t=>{e.signal.aborted||Q({...Qh,bootstrapAvailable:t})});Q({...Qh,accountStatus:`unavailable`,...ig(t)})}}).finally(()=>{this.#e===e&&(this.#e=null),this.#a===t&&(this.#a=null)});return this.#a=t,t}async signIn(){let e=this.#G();Q({accountStatus:`authenticating`,errorMessage:null,recoveryCodes:[],totpEnrollment:null});try{let t=await X().signIn(e.signal);Q({accountStatus:`authenticated`,account:t.account,session:t.session}),await this.refreshDirectory()}catch(t){if(e.signal.aborted)return;Q({accountStatus:`signed-out`,...ig(t)})}finally{this.#e===e&&(this.#e=null)}}async signInWithExternalProvider(e){let t=this.#G();Q({accountStatus:`authenticating`,errorMessage:null,recoveryCodes:[],totpEnrollment:null});try{let n=await X().signInWithExternalProvider(e,t.signal);Q({accountStatus:`authenticated`,account:n.account,session:n.session}),await this.refreshDirectory()}catch(e){if(t.signal.aborted)return;Q({accountStatus:`signed-out`,...ig(e)})}finally{this.#e===t&&(this.#e=null)}}async redeemInvitation(e){return this.#D(t=>X().redeemInvitation(e,t))}async bootstrapOwner(e){return this.#D(t=>X().bootstrapOwner(e,t))}async adoptPublicBrowserIdentity(e,t=[]){this.#e?.abort(),this.#e=null,this.#p.bump(),this.#m.bump(),Q({accountStatus:`authenticated`,account:{id:e.account.id,displayName:e.account.displayName,role:e.activeSpace.role,createdAt:e.account.createdAt,disabledAt:e.account.disabledAt},session:{id:e.session.id,accountId:e.session.accountId,createdAt:e.session.createdAt,expiresAt:e.session.expiresAt,lastSeenAt:e.session.lastSeenAt,revokedAt:e.session.revokedAt,revocationReasonCode:e.session.revocationReasonCode},recoveryCodes:[...t],totpEnrollment:null,bootstrapAvailable:!1,errorMessage:null}),await this.refreshDirectory()}async#D(e){let t=this.#G();Q({accountStatus:`authenticating`,errorMessage:null,recoveryCodes:[],totpEnrollment:null});try{let n=await e(t.signal);Q({accountStatus:`authenticated`,account:n.account,session:n.session,recoveryCodes:n.recoveryCodes??[],bootstrapAvailable:!1}),await this.refreshDirectory()}catch(e){if(t.signal.aborted)return;Q({accountStatus:`signed-out`,...ig(e)})}finally{this.#e===t&&(this.#e=null)}}cancelAuthentication(){this.#e?.abort(),this.#e=null,this.#p.bump(),this.#m.bump(),Q({accountStatus:`signed-out`,errorMessage:null,recoveryCodes:[],totpEnrollment:null})}leaseRecoveryCodeDisplay(){let e=Symbol(`hosted-recovery-code-display-lease`);return this.#h.add(e),this.#O(),()=>{this.#h.delete(e)&&this.#k()}}#O(){let e=this.#h.size>0;ng.getState().leased!==e&&ng.setState({leased:e})}#k(){this.#g||(this.#g=!0,Promise.resolve().then(()=>{this.#g=!1,this.#O()}))}dismissRecoveryCodes(){Q({recoveryCodes:[]})}dismissTotpEnrollment(){this.#p.bump(),Q({totpEnrollment:null})}invalidateNativeE2eeAuthorization(){let e=Z.getState();e.accountStatus===`authenticated`&&(Vh().resetRelayAttemptFactory(),Q({generation:e.generation+1,effectiveRole:null,transportStatus:`reconnecting`,sessionStatus:`closed`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1}))}refreshPasskeys(e){let t=e?.force===!0;if(this.#v&&!t)return this.#v;let n=Z.getState();if(n.accountStatus!==`authenticated`)return Promise.resolve();t&&(this.#_?.abort(),this.#v=null);let r=new AbortController;this.#_=r;let i=this.#A(r,n.session?.id??null).finally(()=>{this.#_===r&&(this.#_=null),this.#v===i&&(this.#v=null)});return this.#v=i,tg.getState().passkeys.length===0&&$({passkeysStatus:`loading`}),i}async#A(e,t){try{let n=await X().listPasskeys(e.signal);if(e.signal.aborted)return;if(!this.#z(e.signal,t)){this.#M();return}$({passkeys:n,passkeysStatus:`ready`,...sg})}catch(n){if(e.signal.aborted)return;if(ug(n)){await this.#j(n);return}if(!this.#z(e.signal,t)){this.#M();return}$({passkeysStatus:`stale`,...ag(n)})}}async#j(e){await this.expireSession(e).catch(()=>void 0)}#M(){$({passkeys:[],passkeysStatus:`idle`})}refreshE2eeDevices(e){let t=e?.force===!0;if(this.#b&&!t)return this.#b;let n=Z.getState();if(n.accountStatus!==`authenticated`)return Promise.resolve();t&&(this.#y?.abort(),this.#b=null);let r=new AbortController;this.#y=r;let i=this.#N(r,n.session?.id??null).finally(()=>{this.#y===r&&(this.#y=null),this.#b===i&&(this.#b=null)});return this.#b=i,(tg.getState().e2eeDevices?.length??0)===0&&$({e2eeDevicesStatus:`loading`}),i}async#N(e,t){try{let n=await X().listE2eeDevices(e.signal);if(e.signal.aborted)return;if(!this.#z(e.signal,t)){this.#P();return}$({e2eeDevices:n,e2eeDevicesStatus:`ready`,...sg})}catch(n){if(e.signal.aborted)return;if(ug(n)){await this.#j(n);return}if(!this.#z(e.signal,t)){this.#P();return}$({e2eeDevicesStatus:`stale`,...ag(n)})}}#P(){$({e2eeDevices:[],e2eeDevicesStatus:`idle`})}refreshExternalIdentityConfiguration(e){let t=e?.force===!0;if(this.#w&&!t)return this.#w;t&&(this.#C?.abort(),this.#w=null);let n=this.#T,r=new AbortController;this.#C=r,tg.getState().externalIdentityConfiguration===null&&$({externalIdentityConfigurationStatus:`loading`});let i=X().getExternalIdentityConfiguration(r.signal).then(e=>{r.signal.aborted||n!==this.#T||$({externalIdentityConfiguration:e,externalIdentityConfigurationStatus:`ready`})}).catch(()=>{r.signal.aborted||n!==this.#T||$({externalIdentityConfigurationStatus:`stale`})}).finally(()=>{this.#C===r&&(this.#C=null),this.#w===i&&(this.#w=null)});return this.#w=i,i}refreshAccountSecurity(e){let t=e?.force===!0;if(this.#S&&!t)return this.#S;let n=Z.getState();if(n.accountStatus!==`authenticated`)return Promise.resolve();t&&(this.#x?.abort(),this.#S=null);let r=new AbortController;this.#x=r;let i=this.#F(r,n.session?.id??null).finally(()=>{this.#x===r&&(this.#x=null),this.#S===i&&(this.#S=null)});return this.#S=i,tg.getState().security===null&&$({securityStatus:`loading`}),i}async#F(e,t){try{let n=await X().getAccountSecurity(e.signal);if(e.signal.aborted)return;if(!this.#z(e.signal,t)){this.#I();return}$({security:n,securityStatus:`ready`})}catch(n){if(e.signal.aborted)return;if(ug(n)){await this.#j(n);return}if(!this.#z(e.signal,t)){this.#I();return}$({securityStatus:`stale`})}}#I(){$({security:null,securityStatus:`idle`})}async addPasskey(e){let t={result:null},n=tg.getState().passkeys.length,r=await this.#R(`adding-passkey`,async n=>{let r=await X().addPasskey(e,n);return()=>{t.result=r}});if(r.status!==`committed`)return r;let i=t.result?.passkey??null;await this.refreshPasskeys({force:!0});let a=tg.getState();return a.passkeysStatus===`ready`?(i?a.passkeys.some(e=>e.id===i.id):a.passkeys.length>n)?{status:`committed`,confirmation:`confirmed`,passkey:i}:($(og(vg)),{status:`committed`,confirmation:`missing`,passkey:i}):{status:`committed`,confirmation:`unverified`,passkey:i}}async regenerateRecoveryCodes(e){let t=this.#m.issue(),n=this.#h.size>0,r=!1,i=!1,a=await this.#R(`regenerating-recovery-codes`,async a=>{let o=await X().regenerateRecoveryCodes(e,a);return r=!0,()=>{n&&t()&&(i=!0,Q({recoveryCodes:o}))}},`account`);return r&&!i&&this.#L(yg),a.status===`committed`?{status:`committed`,displayed:i}:a}#L(e){Z.getState().accountStatus===`authenticated`&&$(og(e))}async revokePasskey(e){let t=await this.#R(`revoking-passkey`,async t=>(await X().revokePasskey(e,t),()=>void 0));return t.status===`committed`&&await this.refreshPasskeys({force:!0}),t}async renameE2eeDevice(e,t){let n=await this.#R(`renaming-e2ee-device`,async n=>(await X().renameE2eeDevice(e,t,n),()=>void 0));return n.status===`committed`&&await this.refreshE2eeDevices({force:!0}),n}async revokeE2eeDevice(e,t){let n=await this.#R(`revoking-e2ee-device`,async n=>(await X().revokeE2eeDevice(e,t,n),()=>void 0));return n.status===`committed`&&await this.refreshE2eeDevices({force:!0}),n}async setPassword(e){let t=await this.#R(`setting-password`,async t=>(await X().setPassword(e,t),()=>void 0));return t.status===`committed`&&await this.refreshAccountSecurity({force:!0}),t}async removePassword(e){let t=await this.#R(`removing-password`,async t=>(await X().removePassword(e,t),()=>void 0));return t.status===`committed`&&await this.refreshAccountSecurity({force:!0}),t}async beginTotpEnrollment(){let e=this.#p.issue(),t=!1,n=!1,r=await this.#R(`enrolling-totp`,async r=>{let i=await X().beginTotpEnrollment(r);return t=!0,()=>{e()&&(n=!0,Q({totpEnrollment:i}))}},`account`);return t&&!n&&this.#L(bg),r.status===`committed`?{status:`committed`,displayed:n}:r}async confirmTotpEnrollment(e){let t=await this.#R(`confirming-totp`,async t=>(await X().confirmTotpEnrollment(e,t),()=>{this.#p.bump(),Q({totpEnrollment:null})}));return t.status===`committed`&&await this.refreshAccountSecurity({force:!0}),t}async revokeTotp(e){let t=await this.#R(`revoking-totp`,async t=>(await X().revokeTotp(e,t),()=>{this.#p.bump(),Q({totpEnrollment:null})}));return t.status===`committed`&&await this.refreshAccountSecurity({force:!0}),t}async requestEmailVerification(e){let t=await this.#R(`requesting-email-verification`,async t=>(await X().requestEmailVerification(e,t),()=>void 0));return t.status===`committed`&&await this.refreshAccountSecurity({force:!0}),t}async connectExternalIdentity(e,t){let n=await this.#R(`connecting-external-identity`,async n=>(await X().connectExternalIdentity(e,t,n),()=>void 0));return n.status===`committed`&&await this.refreshAccountSecurity({force:!0}),n}cancelExternalIdentityConnection(e){this.cancelAccountAction(),X().cancelExternalIdentityConnection(e)}async finishBrowserExternalIdentityConnection(e,t){let n=await this.#R(`connecting-external-identity`,async n=>(await X().finishBrowserExternalIdentityConnection(e,t,n),()=>void 0));return n.status===`committed`&&await this.refreshAccountSecurity({force:!0}),n}async disconnectExternalIdentity(e,t){let n=!1,r=await this.#R(`disconnecting-external-identity`,async r=>{let i=await X().disconnectExternalIdentity(e,t,r);return()=>{n=i.signedOut}});return r.status===`committed`&&(n?await this.clearAccount(`signed-out`):await this.refreshAccountSecurity({force:!0})),r}cancelAccountAction(){this.#E&&(this.#E.abort(),this.#E=null,$({actionStatus:`idle`,...sg}))}async#R(e,t,n=`session`){if(tg.getState().actionStatus!==`idle`)return $(og(gg)),lg(`busy`,gg);let r=Z.getState();if(r.accountStatus!==`authenticated`)return $(og(_g)),lg(`signed-out`,_g);let i=r.session?.id??null,a=r.account?.id??null,o=new AbortController;this.#E=o,$({actionStatus:e,...sg});try{let e=await t(o.signal);return(n===`account`?this.#B(o.signal,a):this.#z(o.signal,i))?(e(),$(sg),{status:`committed`}):lg(o.signal.aborted?`cancelled`:`superseded`,null)}catch(e){return o.signal.aborted?lg(`cancelled`,null):ug(e)?(await this.#j(e),cg(`session-expired`,e)):this.#z(o.signal,i)?($(ag(e)),cg(`request-failed`,e)):cg(`superseded`,e)}finally{this.#E===o&&(this.#E=null,tg.getState().actionStatus===e&&$({actionStatus:`idle`}))}}#z(e,t){let n=Z.getState();return!e.aborted&&n.accountStatus===`authenticated`&&(n.session?.id??null)===t}#B(e,t){let n=Z.getState();return!e.aborted&&n.accountStatus===`authenticated`&&(n.account?.id??null)===t}#V(){this.#T+=1,this.#C?.abort(),this.#C=null,this.#w=null,this.#p.bump(),this.#m.bump(),this.#_?.abort(),this.#_=null,this.#v=null,this.#y?.abort(),this.#y=null,this.#b=null,this.#x?.abort(),this.#x=null,this.#S=null,this.#E?.abort(),this.#E=null,tg.setState($h,!0)}resetForTests(){this.#e?.abort(),this.#e=null,this.#q(),this.#n=0,this.#r?.abort(),this.#r=null,this.#i=null,this.#a=null,this.#Y(),this.#s?.abort(),this.#s=null,this.#c=null,this.#l?.abort(),this.#l=null,this.#u=null,this.#d=null,this.#f+=1,this.#V(),this.#h.clear(),this.#O(),X().clearSessionMaterial(),Z.setState(Qh,!0)}async signOut(){let e=this.#G();Q({accountStatus:`signing-out`,errorMessage:null});try{await X().signOut(e.signal)}catch{if(e.signal.aborted)return;X().clearSessionMaterial()}finally{this.#e===e&&(this.#e=null)}await this.clearAccount(`signed-out`)}async expireSession(e){X().clearSessionMaterial(),await this.clearAccount(`session-expired`),e instanceof J&&e.reason!==null&&Q(ig(e))}suspendBrowser(e){let t=Z.getState();if(t.accountStatus===`authenticated`&&(this.#f+=1,this.#l?.abort(),this.#l=null,this.#u=null,this.#s?.abort(),this.#Y(),this.#q(),this.#r?.abort(),this.#r=null,this.#i=null,Q({browserStatus:e===`offline`?`offline`:`suspended`,sessionStatus:t.sessionStatus===`delivery-unknown`?`delivery-unknown`:`stale`,sessionRecoveredAfterUnknown:!1,generation:t.generation+1}),t.selectedNode&&!this.#d)){let e=t.selectedNode.environmentId,n=Xh(e).catch(()=>void 0).finally(()=>{this.#d===n&&(this.#d=null)});this.#d=n}}resumeBrowser(){if(this.#u)return this.#u;let e=new AbortController;this.#l=e;let t=this.#H(e).finally(()=>{this.#u===t&&(this.#u=null),this.#l===e&&(this.#l=null)});return this.#u=t,t}async#H(e){let t=Z.getState();if(t.accountStatus!==`authenticated`)return;let n=this.#f+1;this.#f=n;let r=t.account?.id??null;Q({browserStatus:`checking-access`,errorMessage:null});try{let t=await X().restoreSession(e.signal);if(e.signal.aborted||this.#f!==n)return;if(Z.getState().accountStatus!==`authenticated`||t.account.id!==r){await this.expireSession();return}if(Q({account:t.account,session:t.session}),await this.refreshDirectory(),this.#f!==n)return;let i=Z.getState();if(i.accountStatus!==`authenticated`)return;if(i.directoryStatus!==`ready`){Q({browserStatus:`stale`});return}if(!i.selectedNode){Q({browserStatus:`current`});return}Q({browserStatus:`synchronizing`}),await this.#W(e.signal)}catch(t){if(e.signal.aborted||this.#f!==n)return;if(ug(t)){await this.expireSession(t);return}Q({browserStatus:`stale`,...ig(t)})}}async clearAccount(e){this.#f+=1,this.#l?.abort(),this.#l=null,this.#u=null,this.#s?.abort(),this.#s=null,this.#c=null,this.#q(),this.#Y(),this.#r?.abort(),this.#r=null,this.#i=null,this.#e?.abort(),this.#e=null,this.#V();let t=Z.getState().selectedNode?.environmentId??null;Q({...Qh,accountStatus:e,generation:Z.getState().generation+1}),t&&await Yh(t)}refreshDirectory(){if(this.#i)return this.#i;let e=new AbortController;this.#r=e;let t=this.#U(e).finally(()=>{this.#r===e&&(this.#r=null),this.#i===t&&(this.#i=null)});return this.#i=t,t}async#U(e){let t=Z.getState();if(t.accountStatus!==`authenticated`)return;let n=t.session?.id??null;this.#q(),Q({directoryStatus:t.nodes.length===0?`loading`:t.directoryStatus});try{let t=await X().listNodes(e.signal),r=Z.getState();if(e.signal.aborted||r.accountStatus!==`authenticated`||r.session?.id!==n)return;this.#n=0;let i=Z.getState(),a=i.browserStatus===`stale`,o=i.selectedNode,s=o?t.find(e=>e.id===o.id&&e.environmentId===o.environmentId)??null:null;if(o&&(!s||s.revokedAt!==null)){let e=i.generation+1;Q({nodes:t,directoryStatus:`ready`,selectionStatus:s&&s.revokedAt!==null?`revoked`:`authorization-removed`,effectiveRole:null,generation:e}),await this.#Z(o.environmentId,e)}else Q({nodes:t,directoryStatus:`ready`,...s?{selectedNode:s,selectionStatus:s.presence.online?`online`:`offline`,effectiveRole:s.effectiveRole}:{}});this.#K(fg),a&&Vh().timers.queueMicrotask(()=>{let e=Z.getState();e.accountStatus===`authenticated`&&e.directoryStatus===`ready`&&e.browserStatus===`stale`&&this.resumeBrowser()})}catch(t){if(e.signal.aborted)return;if(ug(t)){await this.expireSession(t);return}this.#n+=1,Q({directoryStatus:`stale`,effectiveRole:null,...ig(t)});let n=Math.min(pg,1e3*2**Math.min(this.#n,6));this.#K(n)}}async selectNode(e){let t=Z.getState();if(t.directoryStatus!==`ready`||t.browserStatus!==`current`)return;let n=t.nodes.find(t=>t.id===e);if(!n||n.revokedAt||t.selectedNode?.id===n.id&&t.selectedNode.environmentId===n.environmentId)return;let r=t.generation+1;Q({selectedNode:n,selectionStatus:n.presence.online?`online`:`offline`,effectiveRole:n.effectiveRole,transportStatus:`idle`,sessionStatus:`synchronizing`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1,errorMessage:null,generation:r}),this.#J(r);try{await Zh(n,t.selectedNode?.environmentId??null)}catch{this.#X(r)}}async returnToDirectory(e){let t=Z.getState(),n=t.selectedNode;if(!n)return;let r=e?.preserveTerminalSelection===!0;this.#f+=1,this.#l?.abort(),this.#l=null,this.#u=null,this.#s?.abort(),this.#s=null,this.#c=null,this.#Y(),Q({selectedNode:null,selectionStatus:r?t.selectionStatus:`none`,effectiveRole:null,transportStatus:`idle`,sessionStatus:`closed`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1,browserStatus:t.browserStatus===`synchronizing`||t.browserStatus===`checking-access`?`current`:t.browserStatus,errorMessage:r?t.errorMessage:null,errorReason:r?t.errorReason??null:null,generation:t.generation+1}),await Yh(n.environmentId)}retrySelectedNode(){if(this.#c)return this.#c;let e=new AbortController;this.#s=e;let t=this.#W(e.signal).finally(()=>{this.#s===e&&(this.#s=null),this.#c===t&&(this.#c=null)});return this.#c=t,t}async#W(e){if(e.aborted||(await this.#d,e.aborted))return;let t=Z.getState(),n=t.selectedNode;if(!n||n.revokedAt!==null||t.accountStatus!==`authenticated`||t.directoryStatus!==`ready`||(t=Z.getState(),e.aborted||t.selectedNode?.id!==n.id||t.selectedNode.environmentId!==n.environmentId||t.selectedNode.revokedAt!==null||t.accountStatus!==`authenticated`||t.directoryStatus!==`ready`))return;let r=t.sessionStatus===`delivery-unknown`||Vh().hasPendingRelayRequests(),i=t.generation+1;this.#Y(),Q({selectionStatus:n.presence.online?`online`:`offline`,effectiveRole:n.effectiveRole,transportStatus:`idle`,sessionStatus:r?`delivery-unknown`:`synchronizing`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1,errorMessage:null,generation:i}),this.#J(i);try{await Zh(n,n.environmentId,e)}catch{if(e.aborted)return;this.#X(i)}}transportStatus(e,t){Z.getState().generation===e&&Q({transportStatus:t})}sessionStatus(e,t){let n=Z.getState();if(n.generation===e){if(n.sessionStatus===`delivery-unknown`&&t!==`closed`){Q({sessionRecoveredAfterUnknown:!1});return}Q({sessionStatus:t,sessionRecoveredAfterUnknown:!1})}}role(e,t){let n=Z.getState();n.generation===e&&Q({effectiveRole:n.directoryStatus===`ready`?t:null})}failure(e,t){let n=Z.getState();if(n.generation!==e)return;let r=t.kind===`revoked`?`revoked`:t.kind===`authorization-removed`?`authorization-removed`:t.kind===`incompatible`?`incompatible`:n.selectedNode?.presence.online?n.selectionStatus:`offline`;t.retryable||this.#Y(),Q({selectionStatus:r,effectiveRole:t.retryable?n.effectiveRole:null,transportStatus:t.retryable?`reconnecting`:`terminal-failure`,sessionStatus:n.sessionStatus===`delivery-unknown`?`delivery-unknown`:`stale`,browserStatus:!t.retryable&&n.browserStatus===`synchronizing`?`current`:n.browserStatus,errorMessage:Sg(t)})}markDeliveryUnknown(e){Z.getState().generation===e&&Q({sessionStatus:`delivery-unknown`,sessionRecoveredAfterUnknown:!1})}connectionClosed(e){let t=Z.getState();t.generation===e&&t.transportStatus!==`terminal-failure`&&Q({transportStatus:`reconnecting`,sessionStatus:t.sessionStatus===`delivery-unknown`?`delivery-unknown`:`stale`,sessionRecoveredAfterUnknown:!1})}markSessionReady(e){let t=Z.getState();if(t.selectedNode?.environmentId===e){if(this.#Y(),t.sessionStatus===`delivery-unknown`){Q({sessionEstablished:!0,sessionRecoveredAfterUnknown:!0,browserStatus:t.browserStatus===`synchronizing`?`current`:t.browserStatus});return}Q({sessionStatus:`ready`,sessionEstablished:!0,sessionRecoveredAfterUnknown:!1,browserStatus:t.browserStatus===`synchronizing`?`current`:t.browserStatus})}}markSessionReplaying(e){let t=Z.getState();if(t.selectedNode?.environmentId===e){if(t.sessionStatus===`delivery-unknown`){Q({sessionRecoveredAfterUnknown:!1});return}Q({sessionStatus:`replaying`,browserStatus:t.browserStatus===`current`||t.browserStatus===`synchronizing`?`synchronizing`:t.browserStatus})}}reportShellSnapshotFailure(e){let t=Z.getState();if(t.selectedNode?.environmentId===e){if(t.sessionEstablished){console.warn(`hosted_snapshot_reconciliation_failed`);return}this.#X(t.generation)}}acknowledgeDeliveryUnknown(){let e=Z.getState();e.sessionStatus===`delivery-unknown`&&e.sessionRecoveredAfterUnknown&&Q({sessionStatus:`ready`,sessionRecoveredAfterUnknown:!1})}#G(){this.#e?.abort();let e=new AbortController;return this.#e=e,e}#K(e){this.#q();let t=Vh();if(!t.isForeground()){t.subscribeForeground(()=>{t.isForeground()&&(this.#q(),this.refreshDirectory())});return}this.#t=t.timers.setTimeout(()=>void this.refreshDirectory(),e)}#q(){this.#t&&Vh().timers.clearTimeout(this.#t),this.#t=null}#J(e){this.#Y();let t=Z.getState();t.generation!==e||t.sessionEstablished||(this.#o=Vh().timers.setTimeout(()=>this.#X(e),mg))}#Y(){this.#o&&Vh().timers.clearTimeout(this.#o),this.#o=null}#X(e){let t=Z.getState();t.generation!==e||t.sessionEstablished||(this.#Y(),Q({transportStatus:`terminal-failure`,sessionStatus:t.sessionStatus===`delivery-unknown`?`delivery-unknown`:`stale`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1,browserStatus:t.browserStatus===`synchronizing`?`current`:t.browserStatus,errorMessage:hg}))}async#Z(e,t){this.#Y(),await Yh(e),Z.getState().generation===t&&Q({selectedNode:null,transportStatus:`idle`,sessionStatus:`closed`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1})}};function Sg(e){switch(e.kind){case`offline`:return`The selected node is offline. Ryco will reconnect when it becomes available.`;case`revoked`:return`Access to the selected node was revoked.`;case`authorization-removed`:return`Your authorization for the selected node was removed.`;case`incompatible`:return`The selected node uses an incompatible relay protocol version.`;case`draining`:return`Hub is draining connections. Ryco will retry shortly.`;case`slow-consumer`:return`The relay closed a slow connection. Ryco will reconnect.`;case`authentication`:return`The relay authentication attempt expired or was rejected.`;case`rate-limited`:return`Relay attempts are temporarily rate limited.`;default:return e.retryable?`The relay connection was interrupted. Ryco is reconnecting.`:`The relay connection could not be established.`}}var Cg=new xg;function wg(e,t){Z.getState().generation===t&&Cg.markSessionReady(e)}function Tg(e,t){Z.getState().generation===t&&Cg.markSessionReplaying(e)}function Eg(e,t){Z.getState().generation===t&&Cg.reportShellSnapshotFailure(e)}var Dg={idle:`idle`,"requesting-ticket":`requesting ticket`,connecting:`connecting`,authenticating:`authenticating`,"opening-channel":`opening channel`,online:`online`,reconnecting:`Reconnecting`,draining:`draining`,"terminal-failure":`terminal failure`},Og={unavailable:`Online`,negotiating:`Securing`,verified:`Encrypted · Verified locally`,"account-trusted":`Encrypted · Account trusted`,unverified:`Not verified`,"web-unsigned":`Encrypted web`,legacy:`Legacy connection`};function kg(e){let{browserStatus:t,sessionStatus:n,selectionStatus:r,transportStatus:i}=e,a=e.e2eeStatus??`unavailable`;return t===`offline`?`Offline`:t===`checking-access`?`Checking access`:t===`synchronizing`?`Synchronizing`:t===`suspended`||t===`stale`?`Stale`:n===`delivery-unknown`?`Delivery unknown`:r===`authorization-removed`?`Authorization removed`:r===`revoked`?`Revoked`:r===`incompatible`?`Incompatible`:e.nativeDeviceSecurityStatus===`revoked`?`Revoked`:e.nativeDeviceSecurityStatus===`securing`?`Securing this device`:e.nativeDeviceSecurityStatus===`unavailable`?`Device encryption unavailable`:i===`online`&&n===`ready`?Og[a]:i===`reconnecting`?`Reconnecting`:r===`offline`?`Offline`:Dg[i]}var Ag={Offline:{shortLabel:`Offline`,connected:!1,guarantee:`none`},"Checking access":{shortLabel:`Checking`,connected:!1,guarantee:`none`},Synchronizing:{shortLabel:`Syncing`,connected:!1,guarantee:`none`},Stale:{shortLabel:`Stale`,connected:!1,guarantee:`none`},"Delivery unknown":{shortLabel:`Unconfirmed`,connected:!1,guarantee:`none`},"Authorization removed":{shortLabel:`No access`,connected:!1,guarantee:`none`},Revoked:{shortLabel:`Revoked`,connected:!1,guarantee:`none`},Incompatible:{shortLabel:`Incompatible`,connected:!1,guarantee:`none`},Online:{shortLabel:`Online`,connected:!0,guarantee:`none`},"Encrypted · Verified locally":{shortLabel:`Verified`,connected:!0,guarantee:`e2ee`},"Encrypted · Account trusted":{shortLabel:`Acct trusted`,connected:!0,guarantee:`account`},"Encrypted web":{shortLabel:`Web E2EE`,connected:!0,guarantee:`web`},"Legacy connection":{shortLabel:`Legacy`,connected:!0,guarantee:`legacy`},"Not verified":{shortLabel:`Not verified`,connected:!1,guarantee:`none`},Securing:{shortLabel:`Securing`,connected:!1,guarantee:`none`},"Securing this device":{shortLabel:`Device setup`,connected:!1,guarantee:`none`},"Device encryption unavailable":{shortLabel:`No E2EE key`,connected:!1,guarantee:`none`},Reconnecting:{shortLabel:`Reconnecting`,connected:!1,guarantee:`none`},idle:{shortLabel:`Idle`,connected:!1,guarantee:`none`},"requesting ticket":{shortLabel:`Preparing`,connected:!1,guarantee:`none`},connecting:{shortLabel:`Connecting`,connected:!1,guarantee:`none`},authenticating:{shortLabel:`Verifying`,connected:!1,guarantee:`none`},"opening channel":{shortLabel:`Opening`,connected:!1,guarantee:`none`},online:{shortLabel:`Not ready`,connected:!1,guarantee:`none`},draining:{shortLabel:`Closing`,connected:!1,guarantee:`none`},"terminal failure":{shortLabel:`Failed`,connected:!1,guarantee:`none`}};Object.keys(Ag);function jg(e){return Ag[kg(e)]}function Mg(e){return e.hosted?!e.fresh||e.browserCurrent===!1||e.sessionReady===!1?{hosted:!0,allowed:!1,reason:`This action is unavailable while Hub authorization or the relay is stale.`}:im(e.role,e.method,!0)?{hosted:!0,allowed:!0,reason:null}:{hosted:!0,allowed:!1,reason:`This action is unavailable for your role on the selected node.`}:{hosted:!1,allowed:!0,reason:null}}We(ye),We(d);export{Cn as $,sf as A,_l as B,_m as C,Ff as D,Zp as E,Wl as F,go as G,K as H,bl as I,L as J,io as K,xl as L,jl as M,iu as N,Df as O,eu as P,Dn as Q,al as R,gm as S,em as T,fl as U,$c as V,ul as W,pn as X,dr as Y,wn as Z,J as _,tg as a,Sn as at,dh as b,ng as c,_n as ct,Eg as d,fn as dt,Tn as et,Bh as f,un as ft,Ph as g,Rh as h,tn as ht,hg as i,xn as it,yu as j,uf as k,wg as l,gn as lt,Vh as m,en as mt,jg as n,On as nt,Cg as o,bn as ot,X as p,dn as pt,Oa as q,kg as r,vn as rt,Z as s,yn as st,Mg as t,En as tt,Tg as u,nn as ut,ch as v,im as w,am as x,sh as y,rl as z};
@@ -1 +0,0 @@
1
- import{Na as e}from"./runtime-Djy96GJd.js";var t={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};t.node;var n=e(t);export{n as t};